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


C++ Bflush函數代碼示例

本文整理匯總了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;
}
開發者ID:99years,項目名稱:plan9,代碼行數:37,代碼來源:message.c

示例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);
}
開發者ID:mkhl,項目名稱:plan9port,代碼行數:49,代碼來源:mc.c

示例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;
}
開發者ID:UIKit0,項目名稱:newsqueak,代碼行數:28,代碼來源:bprint.c

示例4: winclean

void
winclean(Window *w)
{
	if(w->body)
		Bflush(w->body);
	ctlprint(w->ctl, "clean\n");
}
開發者ID:Requaos,項目名稱:harvey,代碼行數:7,代碼來源:win.c

示例5: r_fl

void
r_fl(int argc, Rune **argv)
{
	USED(argc);
	USED(argv);
	Bflush(&bout);
}
開發者ID:00001,項目名稱:plan9port,代碼行數:7,代碼來源:t20.c

示例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;
}
開發者ID:npe9,項目名稱:harvey,代碼行數:29,代碼來源:pop3.c

示例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);
}
開發者ID:99years,項目名稱:plan9,代碼行數:35,代碼來源:mk.c

示例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);
}
開發者ID:00001,項目名稱:plan9port,代碼行數:25,代碼來源:ed.c

示例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;
		}
	}
}
開發者ID:bbarker,項目名稱:plan9,代碼行數:60,代碼來源:pass.c

示例10: wclean

void
wclean(Win *w)
{
	if(w->body)
		Bflush(w->body);
	ctlwrite(w, "clean\n");
}
開發者ID:CoryXie,項目名稱:nix-os,代碼行數:7,代碼來源:win.c

示例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);
}
開發者ID:bhanug,項目名稱:harvey,代碼行數:60,代碼來源:cifscmd.c

示例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;
}
開發者ID:carriercomm,項目名稱:legacy,代碼行數:25,代碼來源:syscall.c

示例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);
}
開發者ID:JamesLinus,項目名稱:inferno,代碼行數:31,代碼來源:exec.c

示例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);
}
開發者ID:bhanug,項目名稱:harvey,代碼行數:35,代碼來源:netstat.c

示例15: cclean

void
cclean(void)
{

	outcode(AEND, Always, &nullgen, NREG, &nullgen);
	Bflush(&obuf);
}
開發者ID:hfeeki,項目名稱:go,代碼行數:7,代碼來源:lex.c


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