本文整理汇总了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> ");
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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 */
}
}