本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: Bputname
void
Bputname(Biobuf *b, Sym *s)
{
Bprint(b, "%s", s->pkg->prefix);
Bputc(b, '.');
Bwrite(b, s->name, strlen(s->name)+1);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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");
}
示例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);
}
示例12: gzwrite
static int
gzwrite(void *bout, void *buf, int n)
{
if(n != Bwrite(bout, buf, n)){
eof = 1;
return -1;
}
return n;
}
示例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);
}
}
示例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;
}
示例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);
}