这篇教程C++ Bterm函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Bterm函数的典型用法代码示例。如果您正苦于以下问题:C++ Bterm函数的具体用法?C++ Bterm怎么用?C++ Bterm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Bterm函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: dumpobjvoiddumpobj(void){ NodeList *externs, *tmp; bout = Bopen(outfile, OWRITE); if(bout == nil) { flusherrors(); print("can't create %s: %r/n", outfile); errorexit(); } Bprint(bout, "go object %s %s %s %s/n", getgoos(), thestring, getgoversion(), expstring()); Bprint(bout, " exports automatically generated from/n"); Bprint(bout, " %s in package /"%s/"/n", curio.infile, localpkg->name); dumpexport(); Bprint(bout, "/n!/n"); outhist(bout); externs = nil; if(externdcl != nil) externs = externdcl->end; dumpglobls(); dumptypestructs(); // Dump extra globals. tmp = externdcl; if(externs != nil) externdcl = externs->next; dumpglobls(); externdcl = tmp; dumpdata(); dumpfuncs(); Bterm(bout);}
开发者ID:ejchet,项目名称:godfly,代码行数:39,
示例2: getcintgetc(void){ if(peekc>=0){ lastc=peekc; peekc=-1; return lastc; } if(lbuf==0){ File *f; if(file->next==0) return lastc=-1; free(file->name); Bterm(file->b); free(file->b); close(file->fd); f=file->next; free((char *)file); file=f; line=file->line; lbuf=file->lbuf; if(lbuf==0) lbuf=(unsigned char *)""; --nfile; } if(*lbuf==0){ file->line++; line=file->line; if(file->lbuf){ free((char *)file->lbuf); file->lbuf=0; } lbuf=(unsigned char *)Brdline(file->b, '/n'); if(lbuf) lbuf[BLINELEN(file->b)-1] = 0; return lastc='/n'; } return lastc=*lbuf++;}
开发者ID:UIKit0,项目名称:newsqueak,代码行数:38,
示例3: readpatterns/* * patterns are either * ~ regular expression * = exact match string * * all comparisons are case insensitive */static intreadpatterns(char *path){ Biobuf *b; char *p; char *token[2]; int n; int bang; b = Bopen(path, OREAD); if(b == nil) return -1; while((p = Brdline(b, '/n')) != nil){ p[Blinelen(b)-1] = 0; n = tokenize(p, token, 2); if(n == 0) continue; mklower(token[0]); p = token[0]; if(*p == '!'){ p++; bang = 1; } else bang = 0; if(*p == '='){ if(newpattern(Texact, p+1, bang) < 0) return -1; } else if(*p == '~'){ if(newpattern(Tregexp, p+1, bang) < 0) return -1; } else if(strcmp(token[0], "#include") == 0 && n == 2) readpatterns(token[1]); } Bterm(b); return 0;}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:45,
示例4: threadmainvoidthreadmain(int argc, char *argv[]){ int i; Index *ix; u32int bcmem; bcmem = 0; ARGBEGIN{ case 'B': bcmem = unittoull(ARGF()); break; default: usage(); break; }ARGEND if(argc < 1) usage(); fmtinstall('H', encodefmt); if(initventi(argv[0], &conf) < 0) sysfatal("can't init venti: %r"); if(bcmem < maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16)) bcmem = maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16); if(0) fprint(2, "initialize %d bytes of disk block cache/n", bcmem); initdcache(bcmem); ix = mainindex; Binit(&bout, 1, OWRITE); for(i=0; i<ix->nsects; i++) if(shoulddump(ix->sects[i]->name, argc-1, argv+1)) dumpisect(ix->sects[i]); Bterm(&bout); threadexitsall(0);}
开发者ID:99years,项目名称:plan9,代码行数:38,
示例5: rereadvoidreread(void){ int i; extern int catnr; char *q; assert(f == nil); if((f = Bopen(mapname, OREAD)) == nil) fprint(2, "reread: %s: %r/n", mapname); freetree(root); root = nil; for(i = 0; i< ntoken; i++){ free(tokenlist[i].name); catsetfree(&tokenlist[i].categories); } catnr = 0; free(tokenlist); free(catobjects); catobjects = nil; ncat = 0; tokenlist = nil; ntoken = Ntoken; inittokenlist(); free(file); file = strdup(mapname); free(startdir); startdir = strdup(mapname); if ((q = strrchr(startdir, '/'))) *q = '/0'; else startdir[0] = '/0'; getobject(Root, nil); root->parent = root; Bterm(f); f = nil;}
开发者ID:99years,项目名称:plan9,代码行数:37,
示例6: writesnarfvoidwritesnarf(Vnc *v, long n){ uchar buf[8192]; long m; Biobuf *b; if((b = Bopen("/dev/snarf", OWRITE)) == nil) { vncgobble(v, n); return; } while(n > 0) { m = n; if(m > sizeof(buf)) m = sizeof(buf); vncrdbytes(v, buf, m); n -= m; Bwrite(b, buf, m); } Bterm(b); snarfvers++;}
开发者ID:aberg001,项目名称:plan9,代码行数:24,
示例7: ndbreopen/* * dump any cached information, forget the hash tables, and reopen a single file */intndbreopen(Ndb *db){ int fd; Dir *d; /* forget what we know about the open files */ if(db->mtime){ _ndbcacheflush(db); hffree(db); close(Bfildes(&db->b)); Bterm(&db->b); db->mtime = 0; } /* try the open again */ fd = open(db->file, OREAD); if(fd < 0) return -1; d = dirfstat(fd); if(d == nil){ close(fd); return -1; } /* no hashfile for /net/ndb (avoids deadlock in cs) */ if(d->type == 'I') db->nohash = 1; db->qid = d->qid; db->mtime = d->mtime; db->length = d->length; Binits(&db->b, fd, OREAD, db->buf, sizeof(db->buf)); free(d); return 0;}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:39,
示例8: mainvoidmain(int argc, char *argv[]){ Fils fstr[NFILES]; int nfdone = 0; Binit(&bout, 1, OWRITE); Files = fstr; for(argc = findopt(argc, argv); argc > 0; --argc, ++argv) if(Multi == 'm') { if(Nfiles >= NFILES - 1) die("too many files"); if(mustopen(*argv, &Files[Nfiles++]) == 0) nfdone++; /* suppress printing */ } else { if(pr(*argv)) Bterm(Files->f_f); nfdone++; } if(!nfdone) /* no files named, use stdin */ pr(nulls); /* on GCOS, use current file, if any */ errprint(); /* print accumulated error reports */ exits(error? "error": 0);}
开发者ID:00001,项目名称:plan9port,代码行数:24,
示例9: rdgeomstatic voidrdgeom(SDunit *unit){ char *line; char *flds[5]; Biobuf bb; Biobuf *bp; static char geom[] = "geometry "; bp = &bb; seek(unit->ctl, 0, 0); Binit(bp, unit->ctl, OREAD); while((line = Brdline(bp, '/n')) != nil){ line[Blinelen(bp) - 1] = '/0'; if (strncmp(line, geom, sizeof geom - 1) == 0) break; } if (line != nil && tokenize(line, flds, nelem(flds)) >= 3) { unit->sectors = atoll(flds[1]); unit->secsize = atoll(flds[2]); } Bterm(bp); seek(unit->ctl, 0, 0);}
开发者ID:lufia,项目名称:plan9-contrib,代码行数:24,
示例10: freememstatic uint32_tfreemem(void){ int nf, pgsize = 0; uint64_t size, userpgs = 0, userused = 0; char *ln, *sl; char *fields[2]; Biobuf *bp; size = 64*1024*1024; bp = Bopen("#c/swap", OREAD); if (bp != nil) { while ((ln = Brdline(bp, '/n')) != nil) { ln[Blinelen(bp)-1] = '/0'; nf = tokenize(ln, fields, nelem(fields)); if (nf != 2) continue; if (strcmp(fields[1], "pagesize") == 0) pgsize = atoi(fields[0]); else if (strcmp(fields[1], "user") == 0) { sl = strchr(fields[0], '/'); if (sl == nil) continue; userpgs = atoll(sl+1); userused = atoll(fields[0]); } } Bterm(bp); if (pgsize > 0 && userpgs > 0 && userused > 0) size = (userpgs - userused) * pgsize; } /* cap it to keep the size within 32 bits */ if (size >= 3840UL * 1024 * 1024) size = 3840UL * 1024 * 1024; return size;}
开发者ID:npe9,项目名称:harvey,代码行数:36,
示例11: readlifevoidreadlife(char *filename){ int c, i, j; char name[256]; Biobuf *bp; if ((bp = Bopen(filename, OREAD)) == nil) { snprint(name, sizeof name, "/sys/games/lib/life/%s", filename); if ((bp = Bopen(name, OREAD)) == nil) sysfatal("can't read %s: %r", name); } draw(screen, screen->r, display->white, nil, ZP); for (i = 0; i != NLIFE; i++) { row[i] = col[i] = 0; for (j = 0; j != NLIFE; j++) life[i][j] = 0; } c = 0; for (i = 1; i != NLIFE - 1 && c >= 0; i++) { j = 1; while ((c = Bgetc(bp)) >= 0 && c != '/n') if (j != NLIFE - 1) switch (c) { case '.': j++; break; case 'x': birth(i, j); j++; break; } } Bterm(bp); centerlife();}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:36,
示例12: mainvoidmain(int argc, char **argv){ int i; ARGBEGIN {# ifdef DEBUG case 'd': debug++; break; case 'y': yydebug = TRUE; break;# endif case 't': case 'T': Binit(&fout, 1, OWRITE); errorf= 2; foutopen = 1; break; case 'v': case 'V': report = 1; break; case 'n': case 'N': report = 0; break; case '9': nine = 1; break; default: warning("Unknown option %c", ARGC()); } ARGEND sargc = argc; sargv = argv; if (argc > 0){ yyfile = argv[fptr++]; fin = Bopen(yyfile, OREAD); if(fin == 0) error ("%s - can't open file: %r", yyfile); sargc--; sargv++; } else { yyfile = "/fd/0"; fin = myalloc(sizeof(Biobuf), 1); if(fin == 0) exits("core"); Binit(fin, 0, OREAD); } if(Bgetc(fin) == Beof) /* no input */ exits(0); Bseek(fin, 0, 0); gch(); /* may be gotten: def, subs, sname, stchar, ccl, dchar */ get1core(); /* may be gotten: name, left, right, nullstr, parent, ptr */ strcpy((char*)sp, "INITIAL"); sname[0] = sp; sp += strlen("INITIAL") + 1; sname[1] = 0; if(yyparse()) exits("error"); /* error return code */ /* may be disposed of: def, subs, dchar */ free1core(); /* may be gotten: tmpstat, foll, positions, gotof, nexts, nchar, state, atable, sfall, cpackflg */ get2core(); ptail(); mkmatch();# ifdef DEBUG if(debug) pccl();# endif sect = ENDSECTION; if(tptr>0)cfoll(tptr-1);# ifdef DEBUG if(debug)pfoll();# endif cgoto();# ifdef DEBUG if(debug){ print("Print %d states:/n",stnum+1); for(i=0;i<=stnum;i++)stprt(i); }# endif /* may be disposed of: positions, tmpstat, foll, state, name, left, right, parent, ccl, stchar, sname */ /* may be gotten: verify, advance, stoff */ free2core(); get3core(); layout(); /* may be disposed of: verify, advance, stoff, nexts, nchar, gotof, atable, ccpackflg, sfall */# ifdef DEBUG free3core();# endif fother = Bopen(cname,OREAD); if(fother == 0) error("Lex driver missing, file %s: %r",cname); while ( (i=Bgetc(fother)) != Beof) Bputc(&fout, i); Bterm(fother); Bterm(&fout); if(# ifdef DEBUG debug ||# endif report == 1)statistics();//.........这里部分代码省略.........
开发者ID:dancrossnyc,项目名称:harvey,代码行数:101,
示例13: mainvoidmain(int argc, char *argv[]){ Reprog *exp; char *pattern = 0; int n = 1000; char *line; int xflag = 0; int iflag = 0; Biobuf bin; Biobuf *b = &bin; char buf[256]; ARGBEGIN { case 'l': case 'n': n=atoi(EARGF(usage())); break; case 'e': pattern = strdup(EARGF(usage())); break; case 'f': stem = strdup(EARGF(usage())); break; case 's': suffix = strdup(EARGF(usage())); break; case 'x': xflag++; break; case 'i': iflag++; break; default: usage(); break; } ARGEND; if(argc < 0 || argc > 1) usage(); if(argc != 0) { b = Bopen(argv[0], OREAD); if(b == nil) { fprint(2, "split: can't open %s: %r/n", argv[0]); exits("open"); } } else Binit(b, 0, OREAD); if(pattern) { Resub match[2]; if(!(exp = regcomp(iflag? fold(pattern, strlen(pattern)): pattern))) badexp(); memset(match, 0, sizeof match); matchfile(match); while((line=Brdline(b,'/n')) != 0) { memset(match, 0, sizeof match); line[Blinelen(b)-1] = 0; if(regexec(exp, iflag? fold(line, Blinelen(b)-1): line, match, 2)) { if(matchfile(match) && xflag) continue; } else if(output == 0) nextfile(); /* at most once */ Bwrite(output, line, Blinelen(b)-1); Bputc(output, '/n'); } } else { int linecnt = n; while((line=Brdline(b,'/n')) != 0) { if(++linecnt > n) { nextfile(); linecnt = 1; } Bwrite(output, line, Blinelen(b)); } /* * in case we didn't end with a newline, tack whatever's * left onto the last file */ while((n = Bread(b, buf, sizeof(buf))) > 0) Bwrite(output, buf, n); } if(b != nil) Bterm(b); exits(0);}
开发者ID:99years,项目名称:plan9,代码行数:93,
示例14: image2psfileintimage2psfile(int fd, Memimage *im, int dpi) { Rectangle r; Rectangle bbox; int e; int xmargin = 36; int ymargin = 36; double paperaspectratio; double imageaspectratio; Biobuf ioutb; Memimage *tmp; if(im->depth >= 8 && im->chan != CMAP8 && im->chan != GREY8){ /* * the postscript libraries can only handle [1248]-bit grey, 8-bit cmap, * and 24-bit color, so convert. */ tmp = allocmemimage(im->r, strtochan("b8g8r8")); if(tmp == nil) return 1; memimagedraw(tmp, tmp->r, im, im->r.min, nil, ZP, S); freememimage(im); im = tmp; } Binit(&ioutb, fd, OWRITE); r = im->r; width = Dx(r); height = Dy(r); imageaspectratio = (double) width / (double) height; if (landscape) { paperaspectratio = ((double)paperlength - (ymargin * 2)) / ((double)paperwidth - (xmargin * 2)); if (dpi > 0) { iwidth = width * 72 / dpi; iheight = height * 72 / dpi; } else if (imageaspectratio > paperaspectratio) { iwidth = paperlength - (ymargin * 2); iheight = iwidth / imageaspectratio; } else { iheight = paperwidth - (xmargin * 2); iwidth = iheight * imageaspectratio; } xstart = paperwidth - xmargin - (iheight * ymagnification); ystart = paperlength - ymargin; rotation = -90; } else { paperaspectratio = ((double)paperwidth - (xmargin * 2)) / ((double)paperlength - (ymargin * 2)); if (dpi > 0) { iwidth = width * 72 / dpi; iheight = height * 72 / dpi; } else if (imageaspectratio > paperaspectratio) { iwidth = paperwidth - (xmargin * 2); iheight = iwidth / imageaspectratio; } else { iheight = paperlength - (ymargin * 2); iwidth = iheight * imageaspectratio; } xstart = xmargin; ystart = paperlength - ymargin - (iheight * ymagnification); rotation = 0; } bbox = Rect(xstart,ystart,xstart+iwidth,ystart+iheight); e = preamble(&ioutb, bbox); if(e != 0) return e; Bprint(&ioutb, "%%%%Page: 1/n%%%%BeginPageSetup/n"); Bprint(&ioutb, "/pgsave save def/n"); Bprint(&ioutb, "%%%%EndPageSetup/n"); bps = im->depth; Bprint(&ioutb, "%d 0 %d %d %d %d %d %d %s doimage/n", iheight, iwidth, ystart, xstart, height, width, bps, im->flags&Fgrey ? "true" : "false"); imagebits(&ioutb, im); Bprint(&ioutb, "pgsave restore/nshowpage/n"); e = trailer(&ioutb, 1); if(e != 0) return e; Bterm(&ioutb); return 0;}
开发者ID:99years,项目名称:plan9,代码行数:78,
示例15: mainvoidmain(int argc, char *argv[]){ int i, n, nolines, optout; char **args, **a, *cp, *buf; char body[Bodysize+2]; Resub match[1]; Biobuf *bp; optout = 1; a = args = Malloc((argc+1)*sizeof(char*)); sprint(patfile, "%s/patterns", UPASLIB); sprint(linefile, "%s/lines", UPASLOG); sprint(holdqueue, "%s/queue.hold", SPOOL); sprint(copydir, "%s/copy", SPOOL); *a++ = argv[0]; for(argc--, argv++; argv[0] && argv[0][0] == '-'; argc--, argv++) { switch(argv[0][1]) { case 'c': /* save copy of message */ cflag = 1; break; case 'd': /* debug */ debug++; *a++ = argv[0]; break; case 'h': /* queue held messages by sender domain */ hflag = 1; /* -q flag must be set also */ break; case 'n': /* NOHOLD mode */ nflag = 1; break; case 'p': /* pattern file */ if(argv[0][2] || argv[1] == 0) usage(); argc--; argv++; strecpy(patfile, patfile+sizeof patfile, *argv); break; case 'q': /* queue name */ if(argv[0][2] || argv[1] == 0) usage(); *a++ = argv[0]; argc--; argv++; qname = a; *a++ = argv[0]; break; case 's': /* save copy of dumped message */ sflag = 1; break; case 't': /* test mode - don't log match * and write message to /dev/null */ tflag = 1; break; case 'v': /* vebose - print matches */ vflag = 1; break; default: *a++ = argv[0]; break; } } if(argc < 3) usage(); Binit(&bin, 0, OREAD); bp = Bopen(patfile, OREAD); if(bp) { parsepats(bp); Bterm(bp); } qdir = a; sender = argv[2]; /* copy the rest of argv, acummulating the recipients as we go */ for(i = 0; argv[i]; i++) { *a++ = argv[i]; if(i < 4) /* skip queue, 'mail', sender, dest sys */ continue; /* recipients and smtp flags - skip the latter*/ if(strcmp(argv[i], "-g") == 0) { *a++ = argv[++i]; continue; } if(recips) s_append(recips, ", "); else recips = s_new(); s_append(recips, argv[i]); if(optout && !optoutofspamfilter(argv[i])) optout = 0; } *a = 0; /* construct a command string for matching */ snprint(cmd, sizeof(cmd)-1, "%s %s", sender, s_to_c(recips)); cmd[sizeof(cmd)-1] = 0; for(cp = cmd; *cp; cp++)//.........这里部分代码省略.........
开发者ID:npe9,项目名称:harvey,代码行数:101,
示例16: objfilevoidobjfile(char *file, char *pkg){ vlong off, l; Biobuf *f; char magbuf[SARMAG]; char pname[150]; struct ar_hdr arhdr; pkg = smprint("%i", pkg); if(debug['v'] > 1) Bprint(&bso, "%5.2f ldobj: %s (%s)/n", cputime(), file, pkg); Bflush(&bso); f = Bopen(file, 0); if(f == nil) { diag("cannot open file: %s", file); errorexit(); } l = Bread(f, magbuf, SARMAG); if(l != SARMAG || strncmp(magbuf, ARMAG, SARMAG)){ /* load it as a regular file */ l = Bseek(f, 0L, 2); Bseek(f, 0L, 0); ldobj(f, pkg, l, file, file, FileObj); Bterm(f); free(pkg); return; } /* skip over optional __.GOSYMDEF and process __.PKGDEF */ off = Boffset(f); l = nextar(f, off, &arhdr); if(l <= 0) { diag("%s: short read on archive file symbol header", file); goto out; } if(strncmp(arhdr.name, symname, strlen(symname)) == 0) { off += l; l = nextar(f, off, &arhdr); if(l <= 0) { diag("%s: short read on archive file symbol header", file); goto out; } } if(strncmp(arhdr.name, pkgname, strlen(pkgname))) { diag("%s: cannot find package header", file); goto out; } off += l; if(debug['u']) ldpkg(f, pkg, atolwhex(arhdr.size), file, Pkgdef); /* * load all the object files from the archive now. * this gives us sequential file access and keeps us * from needing to come back later to pick up more * objects. it breaks the usual C archive model, but * this is Go, not C. the common case in Go is that * we need to load all the objects, and then we throw away * the individual symbols that are unused. * * loading every object will also make it possible to * load foreign objects not referenced by __.GOSYMDEF. */ for(;;) { l = nextar(f, off, &arhdr); if(l == 0) break; if(l < 0) { diag("%s: malformed archive", file); goto out; } off += l; l = SARNAME; while(l > 0 && arhdr.name[l-1] == ' ') l--; snprint(pname, sizeof pname, "%s(%.*s)", file, utfnlen(arhdr.name, l), arhdr.name); l = atolwhex(arhdr.size); ldobj(f, pkg, l, pname, file, ArchiveObj); }out: Bterm(f); free(pkg);}
开发者ID:TomHoenderdos,项目名称:go-sunos,代码行数:89,
示例17: hostlinkvoidhostlink(void){ char *p, **argv; int c, i, w, n, argc, len; Hostobj *h; Biobuf *f; static char buf[64<<10]; if(linkmode != LinkExternal || nerrors > 0) return; c = 0; p = extldflags; while(p != nil) { while(*p == ' ') p++; if(*p == '/0') break; c++; p = strchr(p + 1, ' '); } argv = malloc((13+nhostobj+nldflag+c)*sizeof argv[0]); argc = 0; if(extld == nil) extld = "gcc"; argv[argc++] = extld; switch(thechar){ case '8': argv[argc++] = "-m32"; break; case '6': argv[argc++] = "-m64"; break; case '5': argv[argc++] = "-marm"; break; } if(!debug['s'] && !debug_s) { argv[argc++] = "-gdwarf-2"; } else { argv[argc++] = "-s"; } if(HEADTYPE == Hdarwin) argv[argc++] = "-Wl,-no_pie,-pagezero_size,4000000"; if(HEADTYPE == Hopenbsd) argv[argc++] = "-Wl,-nopie"; if(iself && AssumeGoldLinker) argv[argc++] = "-Wl,--rosegment"; if(flag_shared) { argv[argc++] = "-Wl,-Bsymbolic"; argv[argc++] = "-shared"; } argv[argc++] = "-o"; argv[argc++] = outfile; if(rpath) argv[argc++] = smprint("-Wl,-rpath,%s", rpath); // Force global symbols to be exported for dlopen, etc. if(iself) argv[argc++] = "-rdynamic"; // already wrote main object file // copy host objects to temporary directory for(i=0; i<nhostobj; i++) { h = &hostobj[i]; f = Bopen(h->file, OREAD); if(f == nil) { ctxt->cursym = S; diag("cannot reopen %s: %r", h->pn); errorexit(); } Bseek(f, h->off, 0); p = smprint("%s/%06d.o", tmpdir, i); argv[argc++] = p; w = create(p, 1, 0775); if(w < 0) { ctxt->cursym = S; diag("cannot create %s: %r", p); errorexit(); } len = h->len; while(len > 0 && (n = Bread(f, buf, sizeof buf)) > 0){ if(n > len) n = len; dowrite(w, buf, n); len -= n; } if(close(w) < 0) { ctxt->cursym = S; diag("cannot write %s: %r", p); errorexit(); } Bterm(f); } //.........这里部分代码省略.........
开发者ID:TomHoenderdos,项目名称:go-sunos,代码行数:101,
示例18: loadfont//.........这里部分代码省略......... for(; i >= MINSIZE; i--) { /* if .font file exists, take that */ snprint(file, sizeof file, "%s/%s%d.font", libfont, try[t], i); ff = openfont(display, file); if(ff != 0) { fonttab[n][s] = ff; dprint(2, "using %s for font %d %d/n", file, n, s); return; } /* else look for a subfont file */ for (deep = log2[screen->depth]; deep >= 0; deep--) { snprint(file, sizeof file, "%s/%s%d.%d", libfont, try[t], i, deep); dprint(2, "trying %s for %d/n", file, i); if ((fd = open(file, 0)) >= 0) { f = readsubfont(display, file, fd, 0); if (f == 0) { fprint(2, "can't rdsubfontfile %s: %r/n", file); exits("rdsubfont"); } close(fd); ff = mkfont(f, 0); if(ff == 0) { fprint(2, "can't mkfont %s: %r/n", file); exits("rdsubfont"); } fonttab[n][s] = ff; dprint(2, "using %s for font %d %d/n", file, n, s); return; } } } } fprint(2, "can't find font %s.%d or substitute, quitting/n", fname[n], s); exits("no font");}voidloadfontname(int n, char *s){ int i; Font *f, *g = 0; if (strcmp(s, fname[n]) == 0) return; if(fname[n] && fname[n][0]) { if(lastload[n] && strcmp(lastload[n], fname[n]) == 0) return; strcpy(lastload[n], fname[n]); } fontlookup(n, s); for (i = 0; i < NSIZE; i++) if (f = fonttab[n][i]) { if (f != g) { freefont(f); g = f; } fonttab[n][i] = 0; }}voidallfree(void){ int i; for (i=0; i<NFONT; i++) loadfontname(i, "??");}voidreadmapfile(char *file){ Biobuf *fp; char *p, cmd[100]; if ((fp=Bopen(file, OREAD)) == 0) { fprint(2, "proof: can't open map file %s/n", file); exits("urk"); } while((p=Brdline(fp, '/n')) != 0) { p[Blinelen(fp)-1] = 0; scanstr(p, cmd, 0); if(p[0]=='/0' || eq(cmd, "#")) /* skip comments, empty */ continue; else if(eq(cmd, "xheight")) buildxheight(fp); else if(eq(cmd, "map")) buildmap(fp); else if(eq(cmd, "special")) buildtroff(p); else if(eq(cmd, "troff")) buildtroff(p); else fprint(2, "weird map line %s/n", p); } Bterm(fp);}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:101,
示例19: dumpobjvoiddumpobj(void){ NodeList *externs, *tmp; char arhdr[ArhdrSize]; vlong startobj, size; Sym *zero; bout = Bopen(outfile, OWRITE); if(bout == nil) { flusherrors(); print("can't create %s: %r/n", outfile); errorexit(); } startobj = 0; if(writearchive) { Bwrite(bout, "!<arch>/n", 8); memset(arhdr, 0, sizeof arhdr); Bwrite(bout, arhdr, sizeof arhdr); startobj = Boffset(bout); } Bprint(bout, "go object %s %s %s %s/n", getgoos(), getgoarch(), getgoversion(), expstring()); dumpexport(); if(writearchive) { Bflush(bout); size = Boffset(bout) - startobj; if(size&1) Bputc(bout, 0); Bseek(bout, startobj - ArhdrSize, 0); formathdr(arhdr, "__.PKGDEF", size); Bwrite(bout, arhdr, ArhdrSize); Bflush(bout); Bseek(bout, startobj + size + (size&1), 0); memset(arhdr, 0, ArhdrSize); Bwrite(bout, arhdr, ArhdrSize); startobj = Boffset(bout); Bprint(bout, "go object %s %s %s %s/n", getgoos(), getgoarch(), getgoversion(), expstring()); } Bprint(bout, "/n!/n"); externs = nil; if(externdcl != nil) externs = externdcl->end; dumpglobls(); dumptypestructs(); // Dump extra globals. tmp = externdcl; if(externs != nil) externdcl = externs->next; dumpglobls(); externdcl = tmp; zero = pkglookup("zerovalue", runtimepkg); ggloblsym(zero, zerosize, 1, 1); dumpdata(); writeobj(ctxt, bout); if(writearchive) { Bflush(bout); size = Boffset(bout) - startobj; if(size&1) Bputc(bout, 0); Bseek(bout, startobj - ArhdrSize, 0); snprint(namebuf, sizeof namebuf, "_go_.%c", thechar); formathdr(arhdr, namebuf, size); Bwrite(bout, arhdr, ArhdrSize); } Bterm(bout);}
开发者ID:Rasender,项目名称:Hello-ACS-560,代码行数:76,
示例20: bzipstatic intbzip(char *file, long mtime, int ifd, Biobuf *bout){ int e, n, done, onemore; char buf[8192]; char obuf[8192]; Biobuf bin; bz_stream strm; USED(file); USED(mtime); memset(&strm, 0, sizeof strm); BZ2_bzCompressInit(&strm, level, verbose, 0); strm.next_in = buf; strm.avail_in = 0; strm.next_out = obuf; strm.avail_out = sizeof obuf; done = 0; Binit(&bin, ifd, OREAD); /* * onemore is a crummy hack to go 'round the loop * once after we finish, to flush the output buffer. */ onemore = 1; SET(e); do { if(!done && strm.avail_in < sizeof buf) { if(strm.avail_in) memmove(buf, strm.next_in, strm.avail_in); n = Bread(&bin, buf+strm.avail_in, sizeof(buf)-strm.avail_in); if(n <= 0) done = 1; else strm.avail_in += n; strm.next_in = buf; } if(strm.avail_out < sizeof obuf) { Bwrite(bout, obuf, sizeof(obuf)-strm.avail_out); strm.next_out = obuf; strm.avail_out = sizeof obuf; } if(onemore == 0) break; } while((e=BZ2_bzCompress(&strm, done ? BZ_FINISH : BZ_RUN)) == BZ_RUN_OK || e == BZ_FINISH_OK || onemore--); if(e != BZ_STREAM_END) { fprint(2, "bzip2: compress failed/n"); return 0; } if(BZ2_bzCompressEnd(&strm) != BZ_OK) { fprint(2, "bzip2: compress end failed (can't happen)/n"); return 0; } Bterm(&bin); return 1;}
开发者ID:00001,项目名称:plan9port,代码行数:65,
示例21: bzipfstatic intbzipf(char *file, int stdout){ Dir *dir; char ofile[128], *f, *s; int ifd, ofd, ok; ifd = open(file, OREAD); if(ifd < 0){ fprint(2, "bzip2: can't open %s: %r/n", file); return 0; } dir = dirfstat(ifd); if(dir == nil){ fprint(2, "bzip2: can't stat %s: %r/n", file); close(ifd); return 0; } if(dir->mode & DMDIR){ fprint(2, "bzip2: can't compress a directory/n"); close(ifd); free(dir); return 0; } if(stdout){ ofd = 1; strcpy(ofile, "<stdout>"); }else{ f = strrchr(file, '/'); if(f != nil) f++; else f = file; s = strrchr(f, '.'); if(s != nil && s != ofile && strcmp(s, ".tar") == 0){ *s = '/0'; snprint(ofile, sizeof(ofile), "%s.tbz", f); }else snprint(ofile, sizeof(ofile), "%s.bz2", f); ofd = create(ofile, OWRITE, 0666); if(ofd < 0){ fprint(2, "bzip2: can't open %s: %r/n", ofile); free(dir); close(ifd); return 0; } } if(verbose) fprint(2, "compressing %s to %s/n", file, ofile); Binit(&bout, ofd, OWRITE); ok = bzip(file, dir->mtime, ifd, &bout); if(!ok || Bflush(&bout) < 0){ fprint(2, "bzip2: error writing %s: %r/n", ofile); if(!stdout) remove(ofile); } Bterm(&bout); free(dir); close(ifd); close(ofd); return ok;}
开发者ID:00001,项目名称:plan9port,代码行数:65,
示例22: bunzipstatic intbunzip(int ofd, char *ofile, Biobuf *bin){ int e, n, done, onemore; char buf[8192]; char obuf[8192]; Biobuf bout; bz_stream strm; USED(ofile); memset(&strm, 0, sizeof strm); BZ2_bzDecompressInit(&strm, verbose, 0); strm.next_in = buf; strm.avail_in = 0; strm.next_out = obuf; strm.avail_out = sizeof obuf; done = 0; Binit(&bout, ofd, OWRITE); /* * onemore is a crummy hack to go 'round the loop * once after we finish, to flush the output buffer. */ onemore = 1; SET(e); do { if(!done && strm.avail_in < sizeof buf) { if(strm.avail_in) memmove(buf, strm.next_in, strm.avail_in); n = Bread(bin, buf+strm.avail_in, sizeof(buf)-strm.avail_in); if(n <= 0) done = 1; else strm.avail_in += n; strm.next_in = buf; } if(strm.avail_out < sizeof obuf) { Bwrite(&bout, obuf, sizeof(obuf)-strm.avail_out); strm.next_out = obuf; strm.avail_out = sizeof obuf; } if(onemore == 0) break; if(strm.avail_in == 0 && strm.avail_out == sizeof obuf) break; } while((e=BZ2_bzDecompress(&strm)) == BZ_OK || onemore--); if(e != BZ_STREAM_END) { fprint(2, "bunzip2: decompress failed/n"); return 0; } if(BZ2_bzDecompressEnd(&strm) != BZ_OK) { fprint(2, "bunzip2: decompress end failed (can't happen)/n"); return 0; } Bterm(&bout); return 1;}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:65,
示例23: bunzipfstatic intbunzipf(char *file, int stdout){ char ofile[64], *s; int ofd, ifd, ok; infile = file; ifd = open(file, OREAD); if(ifd < 0){ fprint(2, "bunzip2: can't open %s: %r/n", file); return 0; } Binit(&bin, ifd, OREAD); if(Bgetc(&bin) != 'B' || Bgetc(&bin) != 'Z' || Bgetc(&bin) != 'h'){ fprint(2, "bunzip2: %s is not a bzip2 file/n", file); Bterm(&bin); close(ifd); return 0; } Bungetc(&bin); Bungetc(&bin); Bungetc(&bin); if(stdout){ ofd = 1; strcpy(ofile, "<stdout>"); }else{ s = strrchr(file, '/'); if(s != nil) s++; else s = file; strecpy(ofile, ofile+sizeof ofile, s); s = strrchr(ofile, '.'); if(s != nil && s != ofile && strcmp(s, ".bz2") == 0) *s = '/0'; else if(s != nil && (strcmp(s, ".tbz") == 0 || strcmp(s, ".tbz2") == 0)) strcpy(s, ".tar"); else if(strcmp(file, ofile) == 0){ fprint(2, "bunzip2: can't overwrite %s/n", file); Bterm(&bin); close(ifd); return 0; } ofd = create(ofile, OWRITE, 0666); if(ofd < 0){ fprint(2, "bunzip2: can't create %s: %r/n", ofile); Bterm(&bin); close(ifd); return 0; } delfile = ofile; } ok = bunzip(ofd, ofile, &bin); Bterm(&bin); close(ifd); if(!ok){ fprint(2, "bunzip2: can't write %s: %r/n", ofile); if(delfile) remove(delfile); } delfile = nil; if(!stdout && ofd >= 0) close(ofd); return ok;}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:69,
示例24: mainvoidmain(int argc, char *argv[]){ int i, fd, n, aflag, vflag; char body[Bodysize+2], *raw, *ret; Biobuf *bp; sprint(patfile, "%s/patterns", UPASLIB); aflag = -1; vflag = 0; ARGBEGIN { case 'a': aflag = 1; break; case 'v': vflag = 1; break; case 'd': debug++; break; case 'p': strcpy(patfile,ARGF()); break; } ARGEND bp = Bopen(patfile, OREAD); if(bp){ parsepats(bp); Bterm(bp); } if(argc >= 1){ fd = open(*argv, OREAD); if(fd < 0){ fprint(2, "can't open %s/n", *argv); exits("open"); } Binit(&bin, fd, OREAD); } else Binit(&bin, 0, OREAD); *body = 0; *header = 0; ret = 0; for(;;){ raw = canon(&bin, header+1, body+1, &n); if(raw == 0) break; if(aflag == 0) continue; if(aflag < 0) aflag = 0; if(vflag){ if(header[1]) { fprint(2, "/t**** Header ****/n/n"); write(2, header+1, strlen(header+1)); fprint(2, "/n"); } fprint(2, "/t**** Body ****/n/n"); if(body[1]) write(2, body+1, strlen(body+1)); fprint(2, "/n"); } for(i = 0; patterns[i].action; i++){ if(matchaction(&patterns[i], header+1)) ret = patterns[i].action; if(i == HoldHeader) continue; if(matchaction(&patterns[i], body+1)) ret = patterns[i].action; } } exits(ret);}
开发者ID:npe9,项目名称:harvey,代码行数:75,
示例25: main//.........这里部分代码省略......... tag = nil; Binit(&bin, 0, OREAD); Binit(&bout, 1, OWRITE); ep = msg; p = msg; eof = 0; off = 0; hdr = 1; for(;;){ /* replenish buffer */ if(ep - p < 512 && !eof){ if(p > msg + 1){ n = ep - p; memmove(msg, p-1, ep-(p-1)); off += (p-1) - msg; p = msg+1; ep = p + n; } n = Bread(&bin, ep, msg+(sizeof msg - 1)- ep); if(n < 0) sysfatal("read error: %r"); if(n == 0) eof = 1; ep += n; *ep = 0; } if(p >= ep) break; if(*p == 0){ p++; continue; } if(hdr && p[-1]=='/n'){ if(p[0]=='/n') hdr = 0; else if(cistrncmp(p-1, "/nfrom:", 6) == 0) tag = "From*"; else if(cistrncmp(p-1, "/nto:", 4) == 0) tag = "To*"; else if(cistrncmp(p-1, "/nsubject:", 9) == 0) tag = "Subject*"; else if(cistrncmp(p-1, "/nreturn-path:", 13) == 0) tag = "Return-Path*"; else tag = nil; } m[0] = dregexec(re[0], p, p==msg || p[-1]=='/n'); m[1] = dregexec(re[1], p, p==msg || p[-1]=='/n'); m[2] = dregexec(re[2], p, p==msg || p[-1]=='/n'); n = m[0]; if(n < m[1]) n = m[1]; if(n < m[2]) n = m[2]; if(n <= 0){fprint(2, " C++ BubbleSort函数代码示例 C++ Bseek函数代码示例
|