当前位置: 首页>>代码示例>>C++>>正文


C++ Brdline函数代码示例

本文整理汇总了C++中Brdline函数的典型用法代码示例。如果您正苦于以下问题:C++ Brdline函数的具体用法?C++ Brdline怎么用?C++ Brdline使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Brdline函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rowloadfonts

/*
 * Get font names from load file so we don't load fonts we won't use
 */
void
rowloadfonts(char *file)
{
	int i;
	Biobuf *b;
	char *l;

	b = Bopen(file, OREAD);
	if(b == nil)
		return;
	/* current directory */
	l = Brdline(b, '\n');
	if(l == nil)
		goto Return;
	/* global fonts */
	for(i=0; i<2; i++){
		l = Brdline(b, '\n');
		if(l == nil)
			goto Return;
		l[Blinelen(b)-1] = 0;
		if(*l && strcmp(l, fontnames[i])!=0){
			free(fontnames[i]);
			fontnames[i] = estrdup(l);
		}
	}
    Return:
	Bterm(b);
}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:31,代码来源:rows.c

示例2: main

main(void)
{
	char *re;
	char *line;
	Reprog *prog;
	char *cp;
	Biobuf in;

	Binit(&in, 0, OREAD);
	print("re> ");
	while(re = Brdline(&in, '\n')){
		re[Blinelen(&in)-1] = 0;
		if(*re == 0)
			break;
		prog = regcomp(re);
		print("> ");
		while(line = Brdline(&in, '\n')){
			line[Blinelen(&in)-1] = 0;
			if(cp = strchr(line, '\n'))
				*cp = 0;
			if(*line == 0)
				break;
			if(regexec(prog, line, 0))
				print("yes\n");
			else
				print("no\n");
			print("> ");
		}
		print("re> ");
	}
}
开发者ID:99years,项目名称:plan9,代码行数:31,代码来源:regtest.c

示例3: rune2html

/*
 * Translate Unicode to HTML by asking tcs(1).
 * This way we don't have yet another table.
 */
Rune*
rune2html(Rune r)
{
	static Biobuf b;
	static int fd = -1;
	static Rune **tcscache[256];
	int p[2];
	char *q;
	
	if(r == '\n')
		return L("\n");

	if(((uint)r&~0xFFFF) != 0){
		/* The cache must grow a lot to handle them */
		fprint(2, "%s: can't handle rune '%C'\n", argv0, r);
		return L("?");
	}

	if(tcscache[r>>8] && tcscache[r>>8][r&0xFF])
		return tcscache[r>>8][r&0xFF];

	if(fd < 0){
		if(pipe(p) < 0)
			sysfatal("pipe: %r");
		switch(fork()){
		case -1:
			sysfatal("fork: %r");
		case 0:
			dup2(p[0], 0);
			dup2(p[1], 1);
			close(p[0]);
			close(p[1]);
			execl(BINDIR "/tcs", "tcs", "-t", "html", nil);
			_exits(0);
		default:
			fd = p[1];
			Binit(&b, p[0], OREAD);
			break;
		}
	}
	/* HACK: extra newlines force rune+\n through tcs now */
	fprint(fd, "%C\n\n\n\n", r);
	q = Brdline(&(b.Biobufhdr), '\n');
	while (q != nil && *q == '\n')
		q = Brdline(&(b.Biobufhdr), '\n');
	if(q == nil)
		sysfatal("tcs: early eof");
	q[Blinelen(&(b.Biobufhdr))-1] = 0;
	if(tcscache[r>>8] == nil)
		tcscache[r>>8] = emalloc(256*sizeof tcscache[0][0]);
	tcscache[r>>8][r&0xFF] = erunesmprint("%s", q);
	return tcscache[r>>8][r&0xFF];
}
开发者ID:n-t-roff,项目名称:Plan9_troff,代码行数:57,代码来源:char.c

示例4: readsnap

Proc*
readsnap(Biobuf *b)
{
	char *q;
	char buf[12];
	int32_t pid;
	Proc *p, *plist;
	int i, n;

	if((q = Brdline(b, '\n')) == nil)
		panic("error reading snapshot file");
	if(strncmp(q, "process snapshot", strlen("process snapshot")) != 0)
		panic("bad snapshot file format");

	plist = nil;
	while(q = Brdline(b, '\n')) {
		q[Blinelen(b)-1] = 0;
		pid = atol(q);
		q += 12;
		p = findpid(plist, pid);
		if(p == nil) {
			p = emalloc(sizeof(*p));
			p->link = plist;
			p->pid = pid;
			plist = p;
		}

		for(i=0; i<Npfile; i++) {
			if(strcmp(pfile[i], q) == 0) {
				p->d[i] = readdata(b);
				break;
			}
		}
		if(i != Npfile)
			continue;
		if(strcmp(q, "mem") == 0) {
			if(Bread(b, buf, 12) != 12) 
				panic("can't read memory section");
			n = atoi(buf);
			p->nseg = n;
			p->seg = emalloc(n*sizeof(*p->seg));
			for(i=0; i<n; i++)
				readseg(&p->seg[i], b, plist);
		} else if(strcmp(q, "text") == 0)
			readseg(&p->text, b, plist);
		else
			panic("unknown section");
	}
	return plist;
}
开发者ID:aahud,项目名称:harvey,代码行数:50,代码来源:read.c

示例5: menu

int
menu(Biobuf *bp, int net)
{
	char *cp;
	int done;

	comm->stopped = 1;

	rawoff();
	fprint(2, ">>> ");
	for(done = 0; !done; ){
		cp = Brdline(bp, '\n');
		if(cp == 0){
			comm->stopped = 0;
			return -1;
		}
		cp[Blinelen(bp)-1] = 0;
		switch(*cp){
		case '!':
			system(Bfildes(bp), cp+1);
			done = 1;
			break;
		case '.':
			done = 1;
			break;
		case 'q':
			comm->stopped = 0;
			return -1;
		case 'o':
			switch(*(cp+1)){
			case 'd':
				send3(net, Iac, Do, atoi(cp+2));
				break;
			case 'w':
				send3(net, Iac, Will, atoi(cp+2));
				break;
			}
			break;
		case 'r':
			comm->returns = !comm->returns;
			done = 1;
			break;
		case 'i':
			send2(net, Iac, Interrupt);
			break;
		case 'b':
			send2(net, Iac, Break);
			break;
		default:
			fprint(2, STDHELP);
			break;
		}
		if(!done)
			fprint(2, ">>> ");
	}

	rawon();
	comm->stopped = 0;
	return 0;
}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:60,代码来源:telnet.c

示例6: 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

示例7: awk

int
awk(Biobuf *b, char **field, int n)
{
	char *line;
	int i;

	while(line = Brdline(b, '\n')){
		line[Blinelen(b)-1] = 0;
		while(*line == ' ' || *line == '\t')
			*line++ = 0;
		for(i = 0; i < n; i++){
			if(*line == 0 || *line == '#')
				break;
			field[i] = line;
			while(*line && *line != ' ' && *line != '\t')
				line++;
			while(*line == ' ' || *line == '\t')
				*line++ = 0;
		}
		if(i)
			return i;
	}

	return 0;
}
开发者ID:99years,项目名称:plan9,代码行数:25,代码来源:depend.c

示例8: readroutes

void
readroutes(void)
{
	int n;
	char *p;
	Biobuf *b;
	char *f[6];
	Route route;

	b = Bopen(routefile, OREAD);
	if(b == 0)
		return;
	while(p = Brdline(b, '\n')){
		p[Blinelen(b)-1] = 0;
		n = getfields(p, f, 6, 1, " \t");
		if(n < 5)
			continue;
		v4parseip(route.dest, f[0]);
		v4parseipmask(route.mask, f[1]);
		v4parseip(route.gate, f[2]);
		route.metric = Infinity;
		if(equivip(route.dest, ralloc.def.dest)
		&& equivip(route.mask, ralloc.def.mask))
			memmove(ralloc.def.gate, route.gate, Pasize);
		else if(!equivip(route.dest, route.gate) && strchr(f[3], 'i') == 0)
			considerroute(&route);
	}
	Bterm(b);
}
开发者ID:aahud,项目名称:harvey,代码行数:29,代码来源:rip.c

示例9: wrd

int
wrd(void)
{
	static int nlines;
	char *l, *src[13];
	int n;

	l = Brdline(wr, '\n');
	if(l == 0)
		return -1;
	++nlines;
	l[BLINELEN(wr)-1] = 0;
	n = strparse(l, src, 13, " ");
	if(n != 12 || src[0][0] == 0 || src[0][1] != 0){
		fprint(2, "wrap file format error, line %d\n", nlines);
		exits("format");
	}
	wbuf.stype = src[0][0];
	wbuf.mark = strtol(src[1], 0, 10);
	strncpy(wbuf.sname, src[2], sizeof wbuf.sname);
	wbuf.slen = strtol(src[3], 0, 10);
	coord(&wbuf.pent[0], &src[4]);
	coord(&wbuf.pent[1], &src[8]);
	return 0;
}
开发者ID:kahrs,项目名称:cda,代码行数:25,代码来源:lib.c

示例10: conslock

int
conslock(void)
{
	char *ln;
	char nkey1[DESKEYLEN];
	static char zeroes[DESKEYLEN];

	if(memcmp(nvr.machkey, zeroes, DESKEYLEN) == 0) {
		print("no password set\n");
		return 0;
	}

	for(;;) {
		print("%s password:", service);
		/* could turn off echo here */

		if ((ln = Brdline(&bin, '\n')) == nil)
			return 0;
		ln[Blinelen(&bin)-1] = '\0';

		/* could turn on echo here */
		memset(nkey1, 0, DESKEYLEN);
		passtokey(nkey1, ln);
		if(memcmp(nkey1, nvr.machkey, DESKEYLEN) == 0) {
			prdate();
			break;
		}

		print("Bad password\n");
		delay(1000);
	}
	return 1;
}
开发者ID:Nurb432,项目名称:plan9front,代码行数:33,代码来源:auth.c

示例11: main

void
main(int argc, char *argv[])
{
	double n;
	int i;
	char *l;

	if(argc > 1) {
		for(i=1; i<argc; i++) {
			n = atof(argv[i]);
			factor(n);
		}
		exits(0);
	}

	Binit(&bin, 0, OREAD);
	for(;;) {
		l = Brdline(&bin, '\n');
		if(l ==  0)
			break;
		n = atof(l);
		if(n <= 0)
			break;
		factor(n);
	}
	exits(0);
}
开发者ID:00001,项目名称:plan9port,代码行数:27,代码来源:factor.c

示例12: contentinit

void
contentinit(void)
{
	static Biobuf *b = nil;
	static Qid qid;
	char *file, *s;
	Suffix *this;

	file = "/sys/lib/mimetype";
	if(b == nil){ /* first time */
		b = Bopen(file, OREAD);
		if(b == nil)
			sysfatal("can't read from %s", file);
	}
	if(updateQid(Bfildes(b), &qid) == 0)
		return;
	Bseek(b, 0, 0);
	while(suffixes!=nil){
		this = suffixes;
		suffixes = suffixes->next;
		free(this->suffix);
		free(this->generic);
		free(this->specific);
		free(this->encoding);
		free(this);
	}

	while((s = Brdline(b, '\n')) != nil){
		s[Blinelen(b) - 1] = 0;
		suffixes = parsesuffix(s, suffixes);
	}
}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:32,代码来源:content.c

示例13: inqsize

Devsize
inqsize(char *file)
{
	int nf;
	char *ln, *end, *data = malloc(strlen(file) + 5 + 1);
	char *fields[4];
	Devsize rv = -1;
	Biobuf *bp;

	strcpy(data, file);
	end = strstr(data, "/data");
	if (end == nil)
		strcat(data, "/ctl");
	else
		strcpy(end, "/ctl");
	bp = Bopen(data, OREAD);
	if (bp) {
		while (rv < 0 && (ln = Brdline(bp, '\n')) != nil) {
			ln[Blinelen(bp)-1] = '\0';
			nf = tokenize(ln, fields, nelem(fields));
			if (nf == 3 && strcmp(fields[0], "geometry") == 0)
				rv = atoi(fields[2]);
		}
		Bterm(bp);
	}
	free(data);
	return rv;
}
开发者ID:Requaos,项目名称:harvey,代码行数:28,代码来源:main.c

示例14: okfile

static int
okfile(char *cp, Biobuf *fp)
{
	char *buf;
	int len;
	char *bp, *ep;
	int c;

	len = strlen(cp);
	Bseek(fp, 0, 0);
	
	/* one iteration per system name in the file */
	while(buf = Brdline(fp, '\n')) {
		ep = &buf[Blinelen(fp)];
		for(bp=buf; bp < ep;){
			while(isspace(*bp) || *bp==',')
				bp++;
			if(strncmp(bp, cp, len) == 0) {
				c = *(bp+len);
				if(isspace(c) || c==',')
					return 1;
			}
			while(bp < ep && (!isspace(*bp)) && *bp!=',')
				bp++;
		}
	}

	/* didn't find it, prohibit forwarding */
	return 0;
}
开发者ID:00001,项目名称:plan9port,代码行数:30,代码来源:skipequiv.c

示例15: msgheadline

void
msgheadline(Biobuf *bin, int n, Biobuf *bout)
{
	char *p, *q;
	char *date;
	char *from;
	char *subject;

	date = nil;
	from = nil;
	subject = nil;
	while(p = Brdline(bin, '\n')){
		p[Blinelen(bin)-1] = '\0';
		if((q = strchr(p, ':')) == nil)
			continue;
		*q++ = '\0';
		if(cistrcmp(p, "from")==0)
			from = fixfrom(skipwhite(q));
		else if(cistrcmp(p, "subject")==0)
			subject = estrdup(skipwhite(q));
		else if(cistrcmp(p, "date")==0)
			date = fixdate(skipwhite(q));
	}

	Bprint(bout, "%d/\t%s", n, from ? from : "");
	if(date)
		Bprint(bout, "\t%s", date);
	if(subject)
		Bprint(bout, "\n\t%s", subject);
	Bprint(bout, "\n");

	free(date);
	free(from);
	free(subject);
}
开发者ID:carriercomm,项目名称:plan9-gpl,代码行数:35,代码来源:news.c


注:本文中的Brdline函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。