コード例 #1
0
ファイル: quine.c プロジェクト: kahrs/cda
int
main(int argc, char *argv[])
{
	int i, j;

 	stin= stdin;
	warn = 1000;
	buildclass();
	while(argc > 1 && argv[1][0] == '-') {
		for(i=1; j = argv[1][i]; i++) {
			switch(j) {
			default:
				fprintf(stderr, "unknown flag -%c\n", j);
				continue;

			case 'q':
				qflag = 1;
				break;

			case 'w':
				warn = atoi(&argv[1][i+1]);
				break;
			}
			break;
		}
		argc--;
		argv++;
	}
	if(argc > 2)
		fprintf(stderr, "Too many arguments -- ignored\n");
	if(argc > 1) {
		stin = fopen(argv[1], "r");
		if(stin == 0) {
			fprintf(stderr, "cannot open %s\n", argv[1]);
			doexit(1);
		}
	}

readmore:
	nterm = 0;
	itmpp = 0;
	peekc = opeekc;
	peeks = opeeks;
	numb = onumb;
	if(rdata())
		doexit(0);
	opeeks = peeks;
	opeekc = peekc;
	onumb = numb;
	if(qflag)
		doimpq(itmp, &itmp[itmpp], mask, 1L);
	else
		doimp(itmp, &itmp[itmpp], mask, 1L);
	if(nterm % PERLINE)
		fprintf(stdout, "\n");
	goto readmore;
}
コード例 #2
0
ファイル: shmctl.c プロジェクト: ptt/pttbbs
void buildclass(int bid, int level)
{
    boardheader_t  *bptr;
    if( level == 20 ){ /* for safty */
	printf("is there something wrong? class level: %d\n", level);
	return;
    }
    bptr = &bcache[bid];
    if (bptr->firstchild[0] == NULL || bptr->childcount <= 0)
        load_uidofgid(bid + 1, 1); /* 因為這邊 bid從 0開始, 所以再 +1 回來 */
    if (bptr->firstchild[1] == NULL || bptr->childcount <= 0)
        load_uidofgid(bid + 1, 1); /* 因為這邊 bid從 0開始, 所以再 +1 回來 */

    for (bptr = bptr->firstchild[0]; bptr != NULL ; bptr = bptr->next[0]) {
	if( bptr->brdattr & BRD_GROUPBOARD )
            buildclass(bptr - bcache, level + 1);
    }
}
コード例 #3
0
ファイル: shmctl.c プロジェクト: ptt/pttbbs
int SHMinit(int argc, char **argv)
{
    int     ch;
    int     no_uhash_loader = 0;
    while( (ch = getopt(argc, argv, "n")) != -1 )
	switch( ch ){
	case 'n':
	    no_uhash_loader = 1;
	    break;
	default:
	    printf("usage:\tshmctl\tSHMinit\n");
	    return 0;
	}

    puts("loading uhash...");
    system("bin/uhash_loader");

    attach_SHM();

    puts("loading bcache...");
    reload_bcache();

    puts("building BMcache...");
    bBMC(1, argv);

#if 0
    puts("building class...");
    buildclass(0, 0);
#endif

    if( !no_uhash_loader ){
	puts("utmpsortd...");
	utmpsortd(1, argv);
    }

#ifdef NOKILLWATERBALL
    puts("nkwbd...");
    nkwbd(1, argv);
#endif

    return 0;
}