本文整理汇总了C++中Bflush函数的典型用法代码示例。如果您正苦于以下问题:C++ Bflush函数的具体用法?C++ Bflush怎么用?C++ Bflush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Bflush函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: threadmain
void
threadmain(int argc, char *argv[])
{
int i;
int lineset;
int ifd;
lineset = 0;
Binit(&bout, 1, OWRITE);
while(argc > 1 && argv[1][0] == '-'){
--argc; argv++;
switch(argv[0][1]){
case '\0':
colonflag = 1;
break;
case 't':
tabflag = 0;
break;
default:
linewidth = atoi(&argv[0][1]);
if(linewidth <= 1)
linewidth = WIDTH;
lineset = 1;
break;
}
}
if(lineset == 0)
getwidth();
cbuf = cbufp = malloc(ALLOC_QUANTA*(sizeof *cbuf));
word = malloc(WORD_ALLOC_QUANTA*(sizeof *word));
if(word == 0 || cbuf == 0)
error("out of memory");
if(argc == 1)
readbuf(0);
else{
for(i = 1; i < argc; i++){
if((ifd = open(*++argv, OREAD)) == -1)
fprint(2, "mc: can't open %s (%r)\n", *argv);
else{
readbuf(ifd);
Bflush(&bin);
close(ifd);
}
}
}
columnate();
Bflush(&bout);
threadexitsall(0);
}
示例3: Bprint
int
Bprint(Biobuf *bb, char *fmt, ...)
{
va_list arg;
int n, pcol;
char *ip, *ep, *out;
Biobufhdr *bp = &bb->_h;
va_start(arg, fmt);
ep = (char*)bp->ebuf;
ip = ep + bp->ocount;
pcol = printcol;
out = doprint(ip, ep, fmt, arg);
if(out >= ep-UTFmax-1) {
Bflush(bb);
ip = ep + bp->ocount;
printcol = pcol;
out = doprint(ip, ep, fmt, arg);
if(out >= ep-UTFmax-1) {
va_end(arg);
return Beof;
}
}
n = out-ip;
bp->ocount += n;
va_end(arg);
return n;
}
示例4: winclean
void
winclean(Window *w)
{
if(w->body)
Bflush(w->body);
ctlprint(w->ctl, "clean\n");
}
示例5: r_fl
void
r_fl(int argc, Rune **argv)
{
USED(argc);
USED(argv);
Bflush(&bout);
}
示例6: stlscmd
static int
stlscmd(char*)
{
int fd;
TLSconn conn;
if(didtls)
return senderr("tls already started");
if(!tlscert)
return senderr("don't have any tls credentials");
sendok("");
Bflush(&out);
memset(&conn, 0, sizeof conn);
conn.cert = tlscert;
conn.certlen = ntlscert;
if(debug)
conn.trace = trace;
fd = tlsServer(0, &conn);
if(fd < 0)
sysfatal("tlsServer: %r");
dup(fd, 0);
dup(fd, 1);
close(fd);
Binit(&in, 0, OREAD);
Binit(&out, 1, OWRITE);
didtls = 1;
return 0;
}
示例7: mk
void
mk(char *target)
{
Node *node;
int did = 0;
nproc(); /* it can be updated dynamically */
nrep(); /* it can be updated dynamically */
runerrs = 0;
node = graph(target);
if(DEBUG(D_GRAPH)){
dumpn("new target\n", node);
Bflush(&bout);
}
clrmade(node);
while(node->flags&NOTMADE){
if(work(node, (Node *)0, (Arc *)0))
did = 1; /* found something to do */
else {
if(waitup(1, (int *)0) > 0){
if(node->flags&(NOTMADE|BEINGMADE)){
assert(/*must be run errors*/ runerrs);
break; /* nothing more waiting */
}
}
}
}
if(node->flags&BEINGMADE)
waitup(-1, (int *)0);
while(jobs)
waitup(-2, (int *)0);
assert(/*target didnt get done*/ runerrs || (node->flags&MADE));
if(did == 0)
Bprint(&bout, "mk: '%s' is up to date\n", node->name);
}
示例8: putfile
void
putfile(void)
{
int *a1;
Rune *lp;
long c;
a1 = addr1;
do {
lp = getline(*a1++);
for(;;) {
count++;
c = *lp++;
if(c == 0) {
if(Bputrune(&iobuf, '\n') < 0)
error(Q);
break;
}
if(Bputrune(&iobuf, c) < 0)
error(Q);
}
} while(a1 <= addr2);
if(Bflush(&iobuf) < 0)
error(Q);
}
示例9: patch
void
patch(void)
{
vlong c, vexit;
Prog *p, *q;
Sym *s;
int a;
if(debug['v'])
Bprint(&bso, "%5.2f patch\n", cputime());
Bflush(&bso);
mkfwd();
s = lookup("exit", 0);
vexit = s->value;
for(p = firstp; p != P; p = p->link) {
a = p->as;
if(a == ATEXT)
curtext = p;
if((a == AJAL || a == AJMP || a == ARET) &&
p->to.type != D_BRANCH && p->to.sym != S) {
s = p->to.sym;
if(s->type != STEXT) {
diag("undefined: %s\n%P", s->name, p);
s->type = STEXT;
s->value = vexit;
}
p->to.offset = s->value;
p->to.type = D_BRANCH;
}
if(p->to.type != D_BRANCH)
continue;
c = p->to.offset;
for(q = firstp; q != P;) {
if(q->forwd != P)
if(c >= q->forwd->pc) {
q = q->forwd;
continue;
}
if(c == q->pc)
break;
q = q->link;
}
if(q == P) {
diag("branch out of range %lld\n%P", c, p);
p->to.type = D_NONE;
}
p->cond = q;
}
for(p = firstp; p != P; p = p->link) {
if(p->as == ATEXT)
curtext = p;
if(p->cond != P) {
p->cond = brloop(p->cond);
if(p->cond != P)
if(p->to.type == D_BRANCH)
p->to.offset = p->cond->pc;
}
}
}
示例10: wclean
void
wclean(Win *w)
{
if(w->body)
Bflush(w->body);
ctlwrite(w, "clean\n");
}
示例11: threadmain
void
threadmain(int argc, char *argv[])
{
char *errmsg;
int ac;
char *ap, *av[256];
Cmd *cp;
int32_t status;
if (argc > 3) {
print("usage: cifscmd [to [share]]\n");
exits("args");
}
smbglobalsguess(1);
errmsg = nil;
if (Binit(&bin, 0, OREAD) == Beof || Binit(&bout, 1, OWRITE) == Beof) {
fprint(2, "%s: can't init bio: %r\n", argv0);
threadexits("Binit");
}
if (argc > 1) {
c = smbconnect(argv[1], argc == 3 ? argv[2] : nil, &errmsg);
if (c == nil)
fprint(2, "failed to connect: %s\n", errmsg);
}
while (ap = Brdline(&bin, '\n')) {
ap[Blinelen(&bin) - 1] = 0;
switch (ac = parse(ap, av, nelem(av))) {
default:
for (cp = cmd; cp->name; cp++) {
if (strcmp(cp->name, av[0]) == 0)
break;
}
if (cp->name == 0) {
Bprint(&bout, "eh?\n");
break;
}
if (c == 0 && cp->connected) {
Bprint(&bout, "not currently connected\n");
break;
}
if ((status = (*cp->f)(c, ac - 1, &av[1])) != -1) {
if(verbose)
Bprint(&bout, "ok %ld/%ld\n", status >> 16, status & 0xffff);
break;
}
break;
case -1:
Bprint(&bout, "eh?\n");
break;
case 0:
break;
}
Bflush(&bout);
}
threadexits(0);
}
示例12: syswrite
void
syswrite(int64_t offset)
{
int fd;
uint32_t size, a;
char *buf;
int n;
fd = getmem_w(reg.r[13]+4);
a = getmem_w(reg.r[13]+8);
size = getmem_w(reg.r[13]+12);
Bflush(bioout);
buf = memio(0, a, size, MemRead);
n = pwrite(fd, buf, size, offset);
if(n < 0)
errstr(errbuf, sizeof errbuf);
if(sysdbg)
itrace("write(%d, %lux, %d, 0x%llx) = %d", fd, a, size, offset, n);
free(buf);
reg.r[REGRET] = n;
}
示例13: error
void
error(char *fmt, ...)
{
int i;
char buf[2048];
va_list arg;
/* Unstack io channels */
if(iop != 0) {
for(i = 1; i < iop; i++)
Bterm(io[i]);
bout = io[0];
iop = 0;
}
ret = 0;
gotint = 0;
Bflush(bout);
if(silent)
silent = 0;
else {
va_start(arg, fmt);
vseprint(buf, buf+sizeof(buf), fmt, arg);
va_end(arg);
fprint(2, "%L: (error) %s\n", buf);
}
while(popio())
;
interactive = 1;
longjmp(err, 1);
}
示例14: pipifc
void
pipifc(void)
{
Ipifc *ip, *nip;
Iplifc *lifc;
char buf[100];
int l, i;
fmtinstall('I', eipfmt);
fmtinstall('M', eipfmt);
ip = readipifc(netroot, nil, -1);
l = 7;
for(nip = ip; nip; nip = nip->next){
for(lifc = nip->lifc; lifc; lifc = lifc->next){
i = snprint(buf, sizeof buf, "%I", lifc->ip);
if(i > l)
l = i;
i = snprint(buf, sizeof buf, "%I", lifc->net);
if(i > l)
l = i;
}
}
for(nip = ip; nip; nip = nip->next){
for(lifc = nip->lifc; lifc; lifc = lifc->next)
Bprint(&out, "%-12s %5d %-*I %5M %-*I %8lud %8lud %8lud %8lud\n",
nip->dev, nip->mtu,
l, lifc->ip, lifc->mask, l, lifc->net,
nip->pktin, nip->pktout,
nip->errin, nip->errout);
}
Bflush(&out);
}
示例15: cclean
void
cclean(void)
{
outcode(AEND, Always, &nullgen, NREG, &nullgen);
Bflush(&obuf);
}