int main( int argc, char *argv[]) { void *theEnv; theEnv = CreateEnvironment(); RerouteStdin(theEnv,argc,argv); CommandLoop(theEnv); /*==================================================================*/ /* Control does not normally return from the CommandLoop function. */ /* However if you are embedding CLIPS, have replaced CommandLoop */ /* with your own embedded calls that will return to this point, and */ /* are running software that helps detect memory leaks, you need to */ /* add function calls here to deallocate memory still being used by */ /* CLIPS. If you have a multi-threaded application, no environments */ /* can be currently executing. If the ALLOW_ENVIRONMENT_GLOBALS */ /* flag in setup.h has been set to TRUE (the default value), you */ /* call the DeallocateEnvironmentData function which will call */ /* DestroyEnvironment for each existing environment and then */ /* deallocate the remaining data used to keep track of allocated */ /* environments. Otherwise, you must explicitly call */ /* DestroyEnvironment for each environment you create. */ /*==================================================================*/ /* DeallocateEnvironmentData(); */ /* DestroyEnvironment(theEnv); */ return(-1); }
int main( int argc, char *argv[]) { mainEnv = CreateEnvironment(); RerouteStdin(mainEnv,argc,argv); #if UNIX_V || LINUX || DARWIN || UNIX_7 || WIN_GCC || WIN_MVC signal(SIGINT,CatchCtrlC); #endif CommandLoop(mainEnv); #if UNIX_V || LINUX || DARWIN || UNIX_7 || WIN_GCC || WIN_MVC signal(SIGINT,CatchCtrlC); #endif /*==================================================================*/ /* Control does not normally return from the CommandLoop function. */ /* However if you are embedding CLIPS, have replaced CommandLoop */ /* with your own embedded calls that will return to this point, and */ /* are running software that helps detect memory leaks, you need to */ /* add function calls here to deallocate memory still being used by */ /* CLIPS. If you have a multi-threaded application, no environments */ /* can be currently executing. */ /*==================================================================*/ DestroyEnvironment(mainEnv); return(-1); }
int main( int argc, char *argv[]) { InitializeEnvironment(); RerouteStdin(argc,argv); CommandLoop(); return(-1); }
main() { cmdScannerADT cs; printf("Test program for the symbol table package\n"); cs = NewCommandScanner(); SetCommandData(cs, NewSymbolTable()); InitCommandTable(cs); CommandLoop(cs, "-> "); FreeSymbolTable(GetCommandData(cs)); FreeCommandScanner(cs); }
/* * Main entry point. * * We don't currently take any arguments, so this is pretty straightforward. */ int main(void) { NuError result; long majorVersion, minorVersion, bugVersion; const char* nufxLibDate; const char* nufxLibFlags; (void) NuGetVersion(&majorVersion, &minorVersion, &bugVersion, &nufxLibDate, &nufxLibFlags); printf("NufxLib exerciser, linked with NufxLib v%ld.%ld.%ld [%s]\n\n", majorVersion, minorVersion, bugVersion, nufxLibFlags); printf("Use 'h' or '?' for help, 'q' to quit.\n"); /* stuff useful when debugging lots */ if (unlink(kTempFile) == 0) fprintf(stderr, "NOTE: whacked exer-temp\n"); if (unlink("new.shk") == 0) fprintf(stderr, "NOTE: whacked new.shk\n"); #if defined(HAS_MALLOC_CHECK_) && !defined(USE_DMALLOC) /* * This is really nice to have on Linux and any other system that * uses the GNU libc/malloc stuff. It slows things down, but it * tells you when you do something dumb with malloc/realloc/free. * (Solaris 2.7 has a similar feature that is enabled by setting the * environment variable LD_PRELOAD to include watchmalloc.so. Other * OSs and 3rd-party malloc packages may have similar features.) * * This environment variable must be set when the program is launched. * Tweaking the environment within the program has no effect. * * Now that the Linux world has "valgrind", this is probably * unnecessary. */ { char* debugSet = getenv("MALLOC_CHECK_"); if (debugSet == nil) printf("WARNING: MALLOC_CHECK_ not enabled\n\n"); } #endif result = CommandLoop(); exit(result != kNuErrNone); }
main() { cmdScannerADT cs; scannerADT scanner; graphADT graph; printf("Graph test program\n"); cs = NewCommandScanner(); scanner = GetTokenScanner(cs); SetScannerStringOption(scanner, ScanQuotesAsStrings); graph = NewGraph(); SetGraphData(graph, NewSymbolTable()); SetCommandData(cs, graph); InitCommandTable(cs); CommandLoop(cs, "G> "); FreeCommandScanner(cs); }
int main(int argc, char **argv) { SOCKET s; char *remote; if(argc > 1) remote = argv[1]; else remote = REMOTE_ADDR; printf("Starting Winsock... "); if(StartWinsock() != 0) { printf("Failed.\n"); return EXIT_FAILURE; } printf("OK.\n"); printf("Connecting to %s:%d... ", remote, SERVER_PORT); if((s = CreateConnectSocket(remote, SERVER_PORT)) == SOCKET_ERROR) { printf("Failed.\n"); return EXIT_FAILURE; } printf("OK.\n\n"); if(ClientHandshake(s)) CommandLoop(s); WSACleanup(); if(conn.dh_remote_key) free(conn.dh_remote_key); if(conn.dh_shared_key) free(conn.dh_shared_key); if(conn.nonce) free(conn.nonce); #ifdef _DEBUG showmemstats(stdout); #endif return EXIT_SUCCESS; }
int main() { Command cmd = GetCommand(); assert(cmd.type == CommandType_Ident && cmd.params.size() == 1); int self_id = std::stoi(cmd.params[0]); std::cout << "TellerVote" << std::endl; std::cout.flush(); cmd = GetCommand(); assert(cmd.type == CommandType_Players && cmd.params.size() == 1); int num_players = std::stoi(cmd.params[0]); for (int i = 0; i < num_players; i++) { _players.emplace_back(i, i == self_id); } /* Firt turn player id unused */ cmd = GetCommand(); assert(cmd.type == CommandType_Start && cmd.params.size() == 1); /* Draw first card */ DrawCard(self_id); for (;;) CommandLoop(self_id); }
/* start(): * Called at the end of reset.s as the first C function after processor * bootup. It is passed a state that is used to determine whether or not * the CPU is restarting as a result of a warmstart or a coldstart. If * the restart is a coldstart, then state will be INITIALIZE. if the * restart is a warmstart, then there are a few typical values of state, * the most common of which are APP_EXIT and EXCEPTION. * * The bss_start and bss_end variables are usually defined in the * target-specific linker memory-map definition file. They symbolically * identify the beginning and end of the .bss section. Many compilers * support intrinsic tags for this; however, since it is apparently not * consistent from one toolset to the next; I chose to make up my own * tags so that this file never changes from one toolset to the next. * * The FORCE_BSS_INIT definition can be established in the target-specific * config.h file to force .bss space initialization regardless of warm/cold * start. */ void start(int state) { char buf[48]; #ifdef FORCE_BSS_INIT state = INITIALIZE; #endif /* Based on the incoming value of 'state' we may or may not initialize * monitor-owned ram. Ideally, we only want to initialize * monitor-owned ram when 'state' is INITIALIZE (power-up or reset); * however, to support the case where the incoming state variable may * be corrupted, we also initialize monitor-owned ram when 'state' * is anything unexpected... */ switch(state) { case EXCEPTION: case APP_EXIT: break; case INITIALIZE: default: umonBssInit(); break; } /* Now that the BSS clear loop has been done, we can copy the * value of state (either a register or on stack) to the global * variable (in BSS) StateOfMonitor... */ StateOfMonitor = state; /* Step through different phases of startup... */ init0(); init1(); init2(); /* Depending on the type of startup, alert the console and do * further initialization as needed... */ switch(StateOfMonitor) { case INITIALIZE: reginit(); init3(); break; case APP_EXIT: EthernetStartup(0,0); if(!MFLAGS_NOEXITSTATUS()) { printf("\nApplication Exit Status: %d (0x%x)\n", AppExitStatus,AppExitStatus); } break; case EXCEPTION: EthernetStartup(0,0); printf("\n%s: '%s'\n",EXCEPTION_HEADING, ExceptionType2String(ExceptionType)); printf(" Occurred near 0x%lx",ExceptionAddr); if(AddrToSym(-1,ExceptionAddr,buf,0)) { printf(" (within %s)",buf); } printf("\n\n"); exceptionAutoRestart(INITIALIZE); break; default: printf("Unexpected monitor state: 0x%x (sp @ 0x%x)\n", StateOfMonitor, buf); /* To attempt to recover from the bad state, just do * what INITIALIZE would do... */ reginit(); init3(); break; } #ifdef LOCK_FLASH_PROTECT_RANGE /* Issue the command that will cause the range of sectors * designated by FLASH_PROTECT_RANGE to be locked. This only * works if the flash device is capable of being locked. */ sprintf(buf,"flash lock %s",FLASH_PROTECT_RANGE); docommand(buf,0); #endif #ifdef PRE_COMMANDLOOP_HOOK PRE_COMMANDLOOP_HOOK(); #endif /* Enter the endless loop of command processing: */ CommandLoop(); printf("ERROR: CommandLoop() returned\n"); monrestart(INITIALIZE); }