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


C++ Blinelen函數代碼示例

本文整理匯總了C++中Blinelen函數的典型用法代碼示例。如果您正苦於以下問題:C++ Blinelen函數的具體用法?C++ Blinelen怎麽用?C++ Blinelen使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Blinelen函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

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

示例2: replywindow

void
replywindow(Article *m)
{
	Biobuf *b;
	char *p, *ep, *q, tmp[40];
	int fd, copy;
	Article *reply;

	sprint(tmp, "%d/article", m->n);
	p = estrstrdup(dir, tmp);
	if((fd = open(p, OREAD)) < 0){
		free(p);	
		return;
	}
	free(p);

	reply = newpost();
	winopenbody(reply->w, OWRITE);
	b = emalloc(sizeof(*b));
	Binit(b, fd, OREAD);
	copy = 0;
	while(p = Brdline(b, '\n')){
		if(Blinelen(b)==1)
			break;
		ep = p+Blinelen(b);
		if(!isspace(*p)){
			copy = 0;
			if(cistrncmp(p, "newsgroups:", 11)==0){
				for(q=p+11; *q!='\n'; q++)
					if(*q==',')
						*q = ' ';
				copy = 1;
			}else if(cistrncmp(p, "subject:", 8)==0){
				if(!strstr(p, " Re:") && !strstr(p, " RE:") && !strstr(p, " re:")){
					p = skip(p, "subject:");
					ep[-1] = '\0';
					Bprint(reply->w->body, "Subject: Re: %s\n", p);
				}else
					copy = 1;
			}else if(cistrncmp(p, "message-id:", 11)==0){
				Bprint(reply->w->body, "References: ");
				p += 11;
				copy = 1;
			}
		}
		if(copy)
			Bwrite(reply->w->body, p, ep-p);
	}
	Bterm(b);
	close(fd);
	free(b);
	Bprint(reply->w->body, "\n");
	winclean(reply->w);
	winselect(reply->w, "$", 0);
}
開發者ID:carriercomm,項目名稱:plan9-gpl,代碼行數:55,代碼來源:news.c

示例3: cat

void
cat(int f, char *s)
{
	Biobuf b;
	char *p;

	Binit(&b, f, OREAD);
	while((p = Brdline(&b, '\n')) != nil)
		if(write(1, p, Blinelen(&b)) != Blinelen(&b))
			sysfatal("write error copying %s: %r", s);
	Bterm(&b);
}
開發者ID:Requaos,項目名稱:harvey,代碼行數:12,代碼來源:lines.c

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

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

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

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

int main(void) {
	Rune r; char *s; int n = 0;
	Biobuf *i = Bfdopen(0,O_RDONLY);
	print("enum codepoints {");
	while((r=Bgetrune(i))>0 && r != '\n') {
		s = Brdline(i,'\n');
		if(!Blinelen(i)) break;
		s[Blinelen(i)-1] = '\0';
		*s = 'U';
		print("%s\n\t%-8s = 0x%X",n?",":"", s,r);
		n = 1;
	}
	print("\n};\n");
	Bterm(i);
	return 0;
}
開發者ID:droyo,項目名稱:APL,代碼行數:16,代碼來源:utf.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: 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

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

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

示例14: rdbio

void
rdbio(char *file, char *user, Acctbio *a)
{
	int i,n;
	Biobuf *b;
	char *p;
	char *field[20];

	memset(a, 0, sizeof(Acctbio));
	b = Bopen(file, OREAD);
	if(b != 0){
		while(p = Brdline(b, '\n')){
			p[Blinelen(b)-1] = 0;
			n = getfields(p, field, nelem(field), 0, "|");
			if(n < 4)
				continue;
			if(strcmp(field[0], user) != 0)
				continue;

			clrbio(a);

			a->postid = strdup(field[1]);
			a->name = strdup(field[2]);
			a->dept = strdup(field[3]);
			if(n-4 >= Nemail)
				n = Nemail-4;
			for(i = 4; i < n; i++)
				a->email[i-4] = strdup(field[i]);
		}
		Bterm(b);
	}
	a->user = strdup(user);
}
開發者ID:Nurb432,項目名稱:plan9front,代碼行數:33,代碼來源:rdbio.c

示例15: buildmap

static void
buildmap(Biobuf *fp)	/* map goes from char name to value to print via *string() */
{
    uchar *p, *line, ch[100];
    int val;
    Rune r;

    curmap++;
    if(curmap >= NMAP) {
        fprint(2, "proof: out of char maps; recompile\n");
        exits("charmap");
    }
    while ((line = Brdline(fp, '\n'))!= 0) {
        if (line[0] == '\n')
            return;
        line[Blinelen(fp)-1] = 0;
        scanstr((char *) line, (char *) ch, (char **) &p);
        if (ch[0] == '\0') {
            fprint(2, "bad map file line '%s'\n", (char*)line);
            continue;
        }
        val = strtol((char *) p, 0, 10);
        dprint(2, "buildmap %s (%x %x) %s %d\n", (char*)ch, ch[0], ch[1], (char*)p, val);
        chartorune(&r, (char*)ch);
        if(utflen((char*)ch)==1 && r<QUICK)
            charmap[curmap].quick[r] = val;
        else
            addmap(curmap, strdup((char *) ch), val);	/* put somewhere else */
    }
}
開發者ID:grobe0ba,項目名稱:plan9front,代碼行數:30,代碼來源:font.c


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