int main(int argc, char *argv[]) { char *opt = NULL; int verbose = 0, fipsmode = 1, i = 0; FILE *fp = NULL; /* Process command line arguments */ i = 0; while(++i < argc) { opt = argv[i]; if (0 /*match*/ == strcmp(opt,"-v")) verbose = 1; else if (0 /*match*/ == strcmp(opt,"-c")) fipsmode = 0; else if ('-' == opt[0]) { doUsage(argv[0]); exit(1); } else break; } /* Enter FIPS mode by default */ if (fipsmode) { if(verbose) { printf("Attempting FIPS mode...\n"); } if(FIPS_mode_set(1)) { if(verbose) { printf("FIPS mode enabled\n"); } } else { ERR_load_crypto_strings(); ERR_print_errors_fp(stderr); exit(2); } } /* If no file arguments, process stdin */ if (i >= argc) { doFile(stdin); } else { while((i < argc) && (opt = argv[i++])) { if ((fp = fopen(opt,"rb")) == NULL) { fprintf(stderr,"Unable to open file \"%s\"\n", opt); exit(1); } if(verbose) { printf("%s: ", opt); } doFile(fp); fclose(fp), fp = NULL; } } return 0; }
static void ExtractIds(char *fname) { strCollection *text = istrCollection.CreateFromFile(fname); Iterator *it = istrCollection.NewIterator(text); char *p; for (p = it->GetFirst(it); p != NULL; p = it->GetNext(it)) { char buf[512]; if (strstr(p,"typedef") && strstr(p,"struct") && strchr(p,'{')) { char *q = strstr(p,"struct"); char *name; q += 6; while (*q == ' ' || *q == '\t') q++; if (*q == 't' && q[1] == 'a' && q[2] == 'g') q += 3; if (*q == '{') { strcpy(buf,"ValArray"); doFile(buf,it); } else { int i = 0; while (*q != ' ' && *q != '{' && *q) buf[i++] = *q++; buf[i]=0; q = strstr(buf,"Interface"); if (q) *q=0; if (FindType(buf) >= 0) { doFile(buf,it); } else if (strstr(buf,"WDictionary")) { strcpy(buf,"WDictionary"); doFile(buf,it); } else if (strstr(buf,"HeapAllocator")) { strcpy(buf,"ContainerHeap"); doFile(buf,it); } } } } for (p = it->GetFirst(it); p != NULL; p = it->GetNext(it)) { int r = ScanOneLine(p); } istrCollection.DeleteIterator(it); istrCollection.Finalize(text); }
void Core::init() { lua = luaL_newstate(); assert(lua != 0); luaL_checkversion(lua); // Stop garbage collector. lua_gc(lua, LUA_GCSTOP, 0); // Load Lua core libraries. // \todo maybe don't load lua libraries to save memory (and omit from build). luaL_openlibs(lua); // Register core function with Lua. lua_register(lua, "create", Script::create); lua_register(lua, "destroy", Script::destroy); lua_register(lua, "help", Script::help); lua_register(lua, "moveby", Script::moveby); lua_register(lua, "moveto", Script::moveto); lua_register(lua, "quit", Script::quit); lua_register(lua, "setBackgroundColor", Script::setBackgroundColor); // Restart garbage collector. lua_gc(lua, LUA_GCRESTART, 0); doFile("scripts/init.lua"); Graphics::init(); }
int main (int argc, char ** argv) { char* moduleName = 0; validateArgs(argc, argv, moduleName); assert(moduleName); doFile(moduleName); return 0; }
CLua::CLua() { L = luaL_newstate(); luaL_openlibs(L); //把游戏中的类声明到Lua里 declareClass2Lua(); //过滤一些函数.... //doFile("lua/env.lua"); //lua_getglobal(L, "env"); //printf("%d\n", lua_setupvalue(L, -2, 1)); doFile("lua/class.lua"); }
/****f* ROBOhdrs/main * NAME * main * SYNOPSIS * int main(int argc, char **argv) * SOURCE */ int main( int argc, char **argv ) { initMe( ); cmdLine( argc, argv ); argc -= optind; argv += optind; if ( argc == 1 ) { doFile( projName, argv[0] ); } else { usage( ); } cleanUp( ); return 0; }
void MergeInfoPP::execute( MergeInfoSection * sect, MergeFile & outFile, WCPtrOrderedVector<MergeFile> & inFiles ) //------------------------------------------------------------------- { uint i; uint j; uint k; PPReqNP * vector; InfoPPReq * req; uint maxSize = 0; for( i = 0; i < _numFiles; i += 1 ) { maxSize = (_reqCount[ i ] > maxSize) ? _reqCount[ i ] : maxSize; } vector = new PPReqNP[ maxSize ]; for( i = 0; i < _numFiles; i += 1 ) { k = 0; for( j = 0, req = _requests[ i ]; j < _reqCount[ i ]; j += 1 ) { vector[ j ] = &req->nodes[ k++ ]; if( k >= req->unused ) { req = req->next; k = 0; } } // now j == _reqCount[ i ] if( j ) { qsort( vector, j, sizeof( InfoPPReqNode * ), (icbvv) &CompReq ); doFile( sect, outFile, *inFiles[ i ], i, vector, j ); } } delete [] vector; }
void fsScriptLua::runTest( ) { std::cout << "fsScriptLua::runTest"; std::cout << "//-testing a file\n"; doFile("scripts/hello.lua"); std::cout << "//-testing a string\n"; doString("io.write ('hello again\\n')"); std::cout << "//-putting some vars\n"; doString("someInt = 5"); doString("someFloat = 8.1234123"); doString("someString = 'ffffffffffffffffff'"); std::cout << "//-getting some vars\n"; std::cout << "someInt:" << getInt("someInt") << std::endl; std::cout << "someFloat:" << getFloat("someFloat") << std::endl; std::cout << "someString:" << getString("someString") << std::endl; }
STATIC void parseString( const char *str ) { /**/myassert( str != NULL ); for(;;) { while( isspace( *str ) ) ++str; switch( *str ) { case 0: return; case SWCHAR: case '-': str += 2; switch( str[-1] ) { case 'o': str = doOutput( str ); break; case 'd': str = doDebug( str ); break; case 'p': str = doParse( str ); break; case 'f': str = doFile( str ); break; case 'q': /* FALL THROUGH */ #if 0 case 'l': #endif case 'b': str = doToggle( str ); break; default: usage(); } if( !isBreakChar( *str ) ) usage(); break; case INCCHAR: str = doInclude( str + 1 ); break; case CMTCHAR: str = doComment( str + 1 ); break; default: str = addFile( str ); break; } } }
BattleFormula::BattleFormula(const char * filename) { doFile(filename); }
int main( int argc, char** argv ) { NameIndex ni; int i; const char* finame = NULL; #if HAVE_POSTGRES dbspec = getenv("PGPOLLDB"); #endif for ( i = 1; i < argc; i++ ) { if ( !strcmp( argv[i], "--dump" )) { redumpVotes = 1; } else if ( !strcmp( argv[i], "--debug" )) { debug = true; } else if ( !strcmp( argv[i], "--preindexed" )) { preindexed = 1; } else if ( !strcmp( argv[i], "--full-html" )) { fullHtml = 1; } else if ( !strcmp( argv[i], "--no-full-html" )) { fullHtml = 0; } else if ( !strcmp( argv[i], "--no-html-head" )) { fullHtml = 0; } else if ( !strcmp( argv[i], "--test" )) { fullHtml = 0; testOutput = 1; } else if ( !strcmp( argv[i], "--enable" )) { int j; int any = 0; i++; for ( j = 0; votestFatoryTable[j].enableName != NULL; j++ ) { if ( !strcmp(votestFatoryTable[j].enableName, argv[i]) ) { votestFatoryTable[j].enabled = 1; any = 1; } } if ( ! any ) { printf("unknown --enable method \"%s\"\n\toptions are: %s", argv[i], votestFatoryTable[0].enableName ); for ( j = 1; votestFatoryTable[j].enableName != NULL; j++ ) { printf(", %s", votestFatoryTable[j].enableName ); } printf("\n"); exit(1); } } else if ( !strcmp( argv[i], "--disable" )) { int j; int any = 0; i++; for ( j = 0; votestFatoryTable[j].enableName != NULL; j++ ) { if ( !strcmp(votestFatoryTable[j].enableName, argv[i]) ) { votestFatoryTable[j].enabled = 0; any = 1; } } if ( ! any ) { printf("unknown --disable method \"%s\"\n", argv[i] ); exit(1); } } else if ( !strcmp( argv[i], "--disable-all" )) { int j; for ( j = 0; votestFatoryTable[j].name != NULL; j++ ) { votestFatoryTable[j].enabled = 0; } } else if ( !strcmp( argv[i], "--enable-all" )) { int j; for ( j = 0; votestFatoryTable[j].name != NULL; j++ ) { votestFatoryTable[j].enabled = 1; } #if HAVE_POSTGRES } else if ( !strcmp( argv[i], "--pg" )) { i++; dbspec = argv[i]; } else if ( !strcmp( argv[i], "--query" )) { i++; dbquery = argv[i]; #endif } else if ( (!strcmp( argv[i], "--help" )) || (!strcmp( argv[i], "-h" )) ) { int j; puts(helptext); printf("known methods (short name for enable/disable, long name, enabled by default):\n"); for ( j = 0; votestFatoryTable[j].enableName != NULL; j++ ) { printf("\t%s \"%s\" (%s)\n", votestFatoryTable[j].enableName, votestFatoryTable[j].name, votestFatoryTable[j].enabled ? "enabled" : "disabled" ); } exit(0); } else if ( !strcmp( argv[i], "-i" )) { i++; finame = argv[i]; } else if ( finame == NULL ) { finame = argv[i]; } else { fprintf(stderr,"bogus arg \"%s\"\n", argv[i] ); exit(1); } } if ( fullHtml ) { printf("<html><head><title>vote results</title></head><body bgcolor=\"#ffffff\" text=\"#000000\">\n"); } if ( debug ) { printf("<pre>debug:\n"); } i = 0; while ( votestFatoryTable[i].name != NULL ) { //printf("found system %d: %s\n", numSystems, votestFatoryTable[numSystems].name ); if ( votestFatoryTable[i].enabled ) { numSystems++; } i++; } systems = (NameVotingSystem**)malloc( sizeof(NameVotingSystem*)*numSystems ); systemNames = (const char**)malloc( sizeof(const char*)*numSystems ); numSystems = 0; i = 0; while ( votestFatoryTable[i].name != NULL ) { //printf("found system %d: %s\n", numSystems, votestFatoryTable[numSystems].name ); if ( votestFatoryTable[i].enabled ) { systems[numSystems] = votestFatoryTable[i].make(); systemNames[numSystems] = votestFatoryTable[i].name; systems[numSystems]->setSharedNameIndex( &ni ); // printf("system[%d] \"%s\" initted\n", i, votestFatoryTable[i].name ); numSystems++; } i++; } // done with setup, read and count votes #if HAVE_POSTGRES if ( dbspec != NULL ) { doPG( finame, &ni ); } else #endif { doFile( finame, &ni ); } if ( debug ) { printf("</pre>\n"); } // print results NameVote* winners = NULL; for ( i = 0; i < numSystems; i++ ) { winners = NULL; int numWinners; numWinners = systems[i]->getWinners( 0, &winners ); if ( testOutput ) { printf( "%s: ", systemNames[i] ); if ( numWinners > 0 ) { int w; printf( "%s", winners[0].name ); for ( w = 1; w < numWinners; w++ ) { printf( ", %s", winners[w].name ); } } printf( "\n" ); } else if ( 1 ) { printf( "<h2>%s</h2>", systemNames[i] ); systems[i]->htmlSummary( stdout ); } else { printf("system[%d]: \"%s\"\n", i, votestFatoryTable[i].name ); int j; for ( j = 0; j < numWinners; j++ ) { printf( "\"%s\"\t%.9g\n", winners[j].name, winners[j].rating ); } printf( "\n" ); } } //printf( "done\n" ); if ( fullHtml ) { printf("</body></html>\n"); } return 0; }
bool ScriptManager::initializeScripts() { return doFile("config/cfg.lua") && doFile("lib/init.lua"); }
GameActionLua::GameActionLua(UInt8 tid, const char * path) : _player1(NULL), _player2(NULL), _tid(tid) { doFile(path); }
int main( int argc, char** argv ) { NameIndex ni; int i; const char* finame = NULL; const char* foname = NULL; FILE* out = stdout; #if HAVE_POSTGRES dbspec = getenv("PGPOLLDB"); #endif for ( i = 1; i < argc; i++ ) { if ( !strcmp( argv[i], "--dump" )) { redumpVotes = 1; } else if ( !strcmp( argv[i], "--debug" )) { debug = 1; } else if ( !strcmp( argv[i], "--preindexed" )) { preindexed = 1; } else if ( !strcmp( argv[i], "--rankings" )) { inputIsRankings = 1; } else if ( !strcmp( argv[i], "--explain" )) { explain = 1; } else if ( !strcmp( argv[i], "--full-html" )) { fullHtml = 1; } else if ( !strcmp( argv[i], "--no-full-html" )) { fullHtml = 0; } else if ( !strcmp( argv[i], "--no-html-head" )) { fullHtml = 0; } else if ( !strcmp( argv[i], "--seats" )) { char* endp; i++; seats = strtol(argv[i], &endp, 10); if ((endp == argv[i]) || (errno == ERANGE) || (errno == EINVAL) || (seats <= 0)) { fprintf(stderr, "can't understand --seats \"%s\"\n", argv[i]); exit(1); } if (seats > 1) { // disable all, enable multi-seat capable. int j; for ( j = 0; votestFatoryTable[j].name != NULL; j++ ) { votestFatoryTable[j].enabled = 0; } assert(setMethodEnabled("hist", 1)); assert(setMethodEnabled("stv", 1)); } } else if ( !strcmp( argv[i], "--test" )) { int j; fullHtml = 0; testOutput = 1; for ( j = 0; votestFatoryTable[j].name != NULL; j++ ) { votestFatoryTable[j].enabled = 1; } assert(setMethodEnabled("hist", 0)); } else if ( !strcmp( argv[i], "--enable" )) { int any = 0; i++; any = setMethodEnabled(argv[i], 1); if ( ! any ) { fprintf(stderr, "unknown --enable method \"%s\"\n", argv[i] ); listMethods(stderr); exit(1); } } else if ( !strcmp( argv[i], "--disable" )) { int any = 0; i++; any = setMethodEnabled(argv[i], 0); if ( ! any ) { fprintf(stderr, "unknown --disable method \"%s\"\n", argv[i] ); listMethods(stderr); exit(1); } } else if ( !strcmp( argv[i], "--disable-all" )) { int j; for ( j = 0; votestFatoryTable[j].name != NULL; j++ ) { votestFatoryTable[j].enabled = 0; } } else if ( !strcmp( argv[i], "--enable-all" )) { int j; for ( j = 0; votestFatoryTable[j].name != NULL; j++ ) { votestFatoryTable[j].enabled = 1; } #if HAVE_POSTGRES } else if ( !strcmp( argv[i], "--pg" )) { i++; dbspec = argv[i]; } else if ( !strcmp( argv[i], "--query" )) { i++; dbquery = argv[i]; #endif } else if ( (!strcmp( argv[i], "--help" )) || (!strcmp( argv[i], "-h" )) || (!strcmp( argv[i], "-help" )) || (!strcmp( argv[i], "--list" )) || (!strcmp( argv[i], "-list" )) ) { puts(helptext); listMethods(stdout); exit(0); } else if ( (!strcmp( argv[i], "-o" )) || (!strcmp( argv[i], "--out")) ) { i++; foname = argv[i]; out = fopen(foname, "w"); if (out == NULL) { perror(foname); exit(1); } } else if ( !strcmp( argv[i], "-i" )) { i++; finame = argv[i]; } else if ( !strcmp( argv[i], "-igz" )) { i++; finame = argv[i]; doGz = 1; } else if ( finame == NULL ) { finame = argv[i]; } else { fprintf(stderr,"bogus arg \"%s\"\n", argv[i] ); exit(1); } } initNameIndex( &ni ); if ( fullHtml ) { fprintf(out, "<html><head><title>vote results</title></head><body bgcolor=\"#ffffff\" text=\"#000000\">\n"); } if ( debug ) { fprintf(out, "<pre>debug:\n"); } i = 0; while ( votestFatoryTable[i].name != NULL ) { //printf("found system %d: %s\n", numSystems, votestFatoryTable[numSystems].name ); if ( votestFatoryTable[i].enabled ) { numSystems++; } i++; } systems = (VirtualVotingSystem**)malloc( sizeof(VirtualVotingSystem*)*numSystems ); systemNames = (const char**)malloc( sizeof(const char*)*numSystems ); numSystems = 0; i = 0; while ( votestFatoryTable[i].name != NULL ) { //printf("found system %d: %s\n", numSystems, votestFatoryTable[numSystems].name ); if ( votestFatoryTable[i].enabled ) { systems[numSystems] = votestFatoryTable[i].make(); if ( testOutput && 0 ) { systemNames[numSystems] = votestFatoryTable[i].enableName; } else { systemNames[numSystems] = votestFatoryTable[i].name; } systems[numSystems]->setSharedNameIndex( systems[numSystems]->it, &ni ); // printf("system[%d] \"%s\" initted\n", i, votestFatoryTable[i].name ); if ( seats != 1 ) { if ( systems[numSystems]->setSeats == NULL ) { fprintf(stderr, "electing %d seats but system \"%s\" is not multi-seat capable\n", seats, systemNames[numSystems] ); exit(1); } systems[numSystems]->setSeats(systems[numSystems]->it, seats); } numSystems++; } i++; } // done with setup, read and count votes #if HAVE_POSTGRES if ( dbspec != NULL ) { doPG( finame, &ni ); } else #endif if ( doGz ) { doGzFile( finame, &ni ); } else { doFile( finame, &ni ); } if ( debug ) { fprintf(out, "</pre>\n"); } // print results NameVote* winners = NULL; for ( i = 0; i < numSystems; i++ ) { winners = NULL; int numWinners; if ( testOutput ) { numWinners = systems[i]->getWinners( systems[i]->it, 0, &winners ); fprintf(out, "%s: ", systemNames[i] ); if ( numWinners > 0 ) { int w; fprintf(out, "%s", winners[0].name ); for ( w = 1; w < numWinners; w++ ) { fprintf(out, ", %s", winners[w].name ); } } fprintf(out, "\n" ); } else if ( 1 ) { fprintf(out, "<h2>%s</h2>", systemNames[i] ); if ( explain ) { systems[i]->htmlExplain( systems[i]->it, out ); } else { // numWinners = systems[i]->getWinners( systems[i]->it, 0, &winners ); systems[i]->htmlSummary( systems[i]->it, out ); } } else { fprintf(out, "system[%d]: \"%s\"\n", i, votestFatoryTable[i].name ); int j; for ( j = 0; j < numWinners; j++ ) { fprintf(out, "\"%s\"\t%.9g\n", winners[j].name, winners[j].rating ); } fprintf(out, "\n" ); } } //printf( "done\n" ); if ( fullHtml ) { fprintf(out, "</body></html>\n"); } return 0; }