當前位置: 首頁>>代碼示例>>C++>>正文


C++ Bwrite函數代碼示例

本文整理匯總了C++中Bwrite函數的典型用法代碼示例。如果您正苦於以下問題:C++ Bwrite函數的具體用法?C++ Bwrite怎麽用?C++ Bwrite使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Bwrite函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: bprintnode

/*
 *  print out a header line, expanding any domainless addresses into
 *  [email protected]
 */
char*
bprintnode(Biobuf *b, Node *p, int *cntp)
{
	int len;

	*cntp = 0;
	if(p->s){
		if(p->addr && strchr(s_to_c(p->s), '@') == nil){
			if(Bprint(b, "%[email protected]%s", s_to_c(p->s), him) < 0)
				return nil;
			*cntp += s_len(p->s) + 1 + strlen(him);
		} else {
			len = s_len(p->s);
			if(Bwrite(b, s_to_c(p->s), len) < 0)
				return nil;
			*cntp += len;
		}
	}else{
		if(Bputc(b, p->c) < 0)
			return nil;
		++*cntp;
	}
	if(p->white) {
		len = s_len(p->white);
		if(Bwrite(b, s_to_c(p->white), len) < 0)
			return nil;
		*cntp += len;
	}
	return p->end+1;
}
開發者ID:99years,項目名稱:plan9,代碼行數:34,代碼來源:smtpd.c

示例2: m_escape

/*
 *  Output the message body with '^From ' escapes.
 *  Ensures that any line starting with a 'From ' gets a ' ' stuck
 *  in front of it.
 */
static int
m_escape(message *mp, Biobuf *fp)
{
	char *p, *np;
	char *end;
	long offset;
	int m, n;
	char *start;

	for(offset = 0; offset < mp->size; offset += n){
		n = m_get(mp, offset, &start);
		if(n < 0){
			Bflush(fp);
			return -1;
		}

		p = start;
		for(end = p+n; p < end; p += m){
			np = memchr(p, '\n', end-p);
			if(np == 0){
				Bwrite(fp, p, end-p);
				break;
			}
			m = np - p + 1;
			if(m > 5 && strncmp(p, "From ", 5) == 0)
				Bputc(fp, ' ');
			Bwrite(fp, p, m);
		}
	}
	Bflush(fp);
	return 0;
}
開發者ID:99years,項目名稱:plan9,代碼行數:37,代碼來源:message.c

示例3: retrcmd

static int
retrcmd(char *arg)
{
	int n;
	Biobuf *b;
	char buf[40], *p;

	if(*arg == 0)
		return senderr("RETR requires a message number");
	n = atoi(arg)-1;
	if(n < 0 || n >= nmsg || msg[n].deleted)
		return senderr("no such message");
	snprint(buf, sizeof buf, "%d/raw", msg[n].upasnum);
	if((b = Bopen(buf, OREAD)) == nil)
		return senderr("message disappeared");
	sendok("");
	while((p = Brdstr(b, '\n', 1)) != nil){
		if(p[0]=='.')
			Bwrite(&out, ".", 1);
		Bwrite(&out, p, strlen(p));
		Bwrite(&out, "\r\n", 2);
		free(p);
	}
	Bterm(b);
	sendcrnl(".");
	return 0;
}
開發者ID:npe9,項目名稱:harvey,代碼行數:27,代碼來源:pop3.c

示例4: qmail

char*
qmail(char **argv, char *buf, int n, Biobuf *cout)
{
    Waitmsg *status;
    int i, pid, pipefd[2];
    char path[512];
    Biobuf *bp;

    pid = 0;
    if(tflag == 0) {
        if(pipe(pipefd) < 0)
            exits("pipe");
        pid = fork();
        if(pid == 0) {
            dup(pipefd[0], 0);
            for(i = sysfiles(); i >= 3; i--)
                close(i);
            snprint(path, sizeof(path), "%s/qer", UPASBIN);
            *argv=path;
            exec(path, argv);
            exits("exec");
        }
        Binit(&bout, pipefd[1], OWRITE);
        bp = &bout;
    } else
        bp = Bopen("/dev/null", OWRITE);

    while(n > 0) {
        Bwrite(bp, buf, n);
        if(cout)
            Bwrite(cout, buf, n);
        n = Bread(&bin, buf, sizeof(buf)-1);
    }
    Bterm(bp);
    if(cout)
        Bterm(cout);
    if(tflag)
        return 0;

    close(pipefd[1]);
    close(pipefd[0]);
    for(;;) {
        status = wait();
        if(status == nil || status->pid == pid)
            break;
        free(status);
    }
    if(status == nil)
        strcpy(buf, "wait failed");
    else {
        strcpy(buf, status->msg);
        free(status);
    }
    return buf;
}
開發者ID:npe9,項目名稱:harvey,代碼行數:55,代碼來源:scanmail.c

示例5: Bputname

void
Bputname(Biobuf *b, Sym *s)
{
	Bprint(b, "%s", s->pkg->prefix);
	Bputc(b, '.');
	Bwrite(b, s->name, strlen(s->name)+1);
}
開發者ID:gnanderson,項目名稱:go,代碼行數:7,代碼來源:obj.c

示例6: nntppost

char*
nntppost(Netbuf *n, char *msg)
{
	char *p, *q;

	if(nntpcmd(n, "POST", 34) < 0)
		return n->response;

	for(p=msg; *p; p=q){
		if((q = strchr(p, '\n')) != nil)
			*q++ = '\0';
		else
			q = p+strlen(p);

		if(p[0]=='.')
			Bputc(&n->bw, '.');
		Bwrite(&n->bw, p, strlen(p));
		Bputc(&n->bw, '\r');
		Bputc(&n->bw, '\n');
	}
	Bprint(&n->bw, ".\r\n");

	if(nntpresponse(n, 0, nil) < 0)
		return n->response;

	if(n->code/100 != 2)
		return n->response;
	return nil;
}
開發者ID:dancrossnyc,項目名稱:harvey,代碼行數:29,代碼來源:nntpfs.c

示例7: outWrite

void
outWrite(void *buf, int n)
{
	if(Bwrite(out, buf, n) < n)
		sysfatal("write failed: %r");
	outdg = sha1((uchar*)buf, n, nil, outdg);
}
開發者ID:grobe0ba,項目名稱:plan9front,代碼行數:7,代碼來源:mkpaqfs.c

示例8: fetchBodyStr

/*
 * return a simple string
 */
void
fetchBodyStr(Fetch *f, char *buf, ulong size)
{
    Pair p;

    p = fetchBodyPart(f, size);
    Bwrite(&bout, &buf[p.start], p.stop-p.start);
}
開發者ID:aberg001,項目名稱:plan9,代碼行數:11,代碼來源:fetch.c

示例9: topcmd

static int
topcmd(char *arg)
{
	int done, i, lines, n;
	char buf[40], *p;
	Biobuf *b;

	if(*arg == 0)
		return senderr("TOP requires a message number");
	n = atoi(arg)-1;
	if(n < 0 || n >= nmsg || msg[n].deleted)
		return senderr("no such message");
	arg = nextarg(arg);
	if(*arg == 0)
		return senderr("TOP requires a line count");
	lines = atoi(arg);
	if(lines < 0)
		return senderr("bad args to TOP");
	snprint(buf, sizeof buf, "%d/raw", msg[n].upasnum);
	if((b = Bopen(buf, OREAD)) == nil)
		return senderr("message disappeared");
	sendok("");
	while(p = Brdstr(b, '\n', 1)){
		if(p[0]=='.')
			Bputc(&out, '.');
		Bwrite(&out, p, strlen(p));
		Bwrite(&out, "\r\n", 2);
		done = p[0]=='\0';
		free(p);
		if(done)
			break;
	}
	for(i=0; i<lines; i++){
		p = Brdstr(b, '\n', 1);
		if(p == nil)
			break;
		if(p[0]=='.')
			Bwrite(&out, ".", 1);
		Bwrite(&out, p, strlen(p));
		Bwrite(&out, "\r\n", 2);
		free(p);
	}
	sendcrnl(".");
	Bterm(b);
	return 0;
}
開發者ID:npe9,項目名稱:harvey,代碼行數:46,代碼來源:pop3.c

示例10: winwritebody

void
winwritebody(Window *w, char *s, int n)
{
	if(w->body == nil)
		winopenbody(w, OWRITE);
	if(Bwrite(w->body, s, n) != n)
		error("write error to window: %r");
}
開發者ID:Requaos,項目名稱:harvey,代碼行數:8,代碼來源:win.c

示例11: Cwrite

void
Cwrite(Cdimg *cd, void *buf, int n)
{
	assert(Boffset(&cd->bwr) >= 16*Blocksize);

	if(Bwrite(&cd->bwr, buf, n) != n)
		sysfatal("Bwrite: %r");
	Bflush(&cd->brd);
}
開發者ID:00001,項目名稱:plan9port,代碼行數:9,代碼來源:cdrdwr.c

示例12: gzwrite

static int
gzwrite(void *bout, void *buf, int n)
{
	if(n != Bwrite(bout, buf, n)){
		eof = 1;
		return -1;
	}
	return n;
}
開發者ID:aahud,項目名稱:harvey,代碼行數:9,代碼來源:gzip.c

示例13: vncwrbytes

void
vncwrbytes(Vnc *v, void *a, int n)
{
	if(Bwrite(&v->out, a, n) < 0){
		if(verbose > 1) 
			fprint(2, "hungup while writing bytes\n");
		vnchungup(v);
	}
}
開發者ID:AustenConrad,項目名稱:plan-9,代碼行數:9,代碼來源:proto.c

示例14: dBprint

int
dBprint(char *fmt, ...)
{
	char buf[SIZE], *out;
	va_list arg;
	int n;

	va_start(arg, fmt);
	out = vseprint(buf, buf+SIZE, fmt, arg);
	va_end(arg);
	if(debug){
		Bwrite(&berr, buf, (long)(out-buf));
		Bflush(&berr);
	}
	n = Bwrite(&bout, buf, (long)(out-buf));
	Bflush(&bout);
	return n;
}
開發者ID:grobe0ba,項目名稱:plan9front,代碼行數:18,代碼來源:smtp.c

示例15: wwritebody

void
wwritebody(Win *w, char *s, int n)
{
	if(w->body == nil)
		openbody(w, OWRITE);
	if(Bwrite(w->body, s, n) != n)
		  fprint(2,"write error to window: %r");
	Bflush(w->body);
}
開發者ID:CoryXie,項目名稱:nix-os,代碼行數:9,代碼來源:win.c


注:本文中的Bwrite函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。