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


C++ Bterm函数代码示例

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


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

示例1: dumpobj

void
dumpobj(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,代码来源:obj.c

示例2: getc

int
getc(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,代码来源:lex.c

示例3: readpatterns

/*
 *  patterns are either
 *	~ regular expression
 *	= exact match string
 *
 *  all comparisons are case insensitive
 */
static int
readpatterns(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,代码来源:list.c

示例4: threadmain

void
threadmain(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,代码来源:printindex.c

示例5: reread

void
reread(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,代码来源:server.c

示例6: writesnarf

void
writesnarf(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,代码来源:wsys.c

示例7: ndbreopen

/*
 *  dump any cached information, forget the hash tables, and reopen a single file
 */
int
ndbreopen(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,代码来源:ndbopen.c

示例8: main

void
main(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,代码来源:pr.c

示例9: rdgeom

static void
rdgeom(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,代码来源:parts.c

示例10: freemem

static uint32_t
freemem(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,代码来源:venti.c

示例11: readlife

void
readlife(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,代码来源:life.c

示例12: main

void
main(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,代码来源:lmain.c

示例13: main

void
main(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,代码来源:split.c

示例14: image2psfile

int
image2psfile(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,代码来源:pslib.c

示例15: main

void
main(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,代码来源:scanmail.c


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