当前位置: 首页>>代码示例>>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;未经允许,请勿转载。