int main(int argc, char *argv[]) { unsigned port = CPORT; /* Actual number of workers & routers */ int nworkers = 1; int nrouters = 1; /* Max number of clients */ int c; int level = 1; bool console = true; while ((c = getopt(argc, argv, "hv:p:r:w:c:C")) != -1) { switch (c) { case 'h': usage(argv[0]); break; case 'v': level = atoi(optarg); break; case 'p': port = atoi(optarg); break; case 'r': nrouters = atoi(optarg); break; case 'w': nworkers = atoi(optarg); break; case 'c': maxclients = atoi(optarg); break; case 'C': console = false; break; default: printf("Unknown option '%c'\n", c); usage(argv[0]); break; } } set_verblevel(level); if (signal(SIGTERM, sigterm_handler) == SIG_ERR) err(false, "Couldn't install signal handler"); init_controller(port, nrouters, nworkers); if (!console) block_console(); run_controller(NULL); mem_status(stdout); chunk_status(stdout); return 0; }
int main(int argc, char *argv[]) { char buf[BUFSIZE] = "localhost"; unsigned port = CPORT; int c; int level = 1; bool try_local_router = false; bool try_self_route = true; while ((c = getopt(argc, argv, "hv:H:P:nr")) != -1) { switch (c) { case 'h': usage(argv[0]); break; case 'H': strncpy(buf, optarg, BUFSIZE-1); buf[BUFSIZE-1] = '\0'; break; case 'v': level = atoi(optarg); break; case 'P': port = atoi(optarg); break; case 'n': try_self_route = false; break; case 'r': try_local_router = true; break; default: printf("Unknown option '%c'\n", c); usage(argv[0]); break; } } set_verblevel(level); init(buf, port, try_self_route, try_local_router); if (signal(SIGTERM, sigterm_handler) == SIG_ERR) err(false, "Couldn't install signal handler"); run_worker(); finish(); mem_status(stdout); chunk_status(stdout); return 0; }
void __cdecl main( unsigned argc, char *argv[], char *envp[]) /* environment variables */ { extern unsigned saveBytes; extern char **envPtr; int status; /* returned by doMake */ extern char *makeStr; #ifdef OS2_SIGNALS PUSHORT prev; unsigned long _FAR *pfnsig; #endif InitializeEnv(); #if defined(FLAT) fRunningUnderTNT = FIsTNT(); #endif initCharmap(); initMacroTable(macroTable); #ifdef DEBUG_MEMORY //This puts 0xff in all free entries in the heap _heapset(0xff); #endif envPtr = envp; #ifdef DEBUG_COMMANDLINE { int iArg = argc; char **chchArg = argv; for (; iArg--; chchArg++) printf("'%s' ", *chchArg); printf("\n"); } #endif #ifdef TEST_RUNTIME //Tests RunTime error R6001 {char near *foo = NULL; *foo = '1';} #endif #ifdef DOS startupDir = getCurDir(); #endif #ifdef FLAT resultbuf_size = sizeof(struct _finddata_t); #ifdef NT ext_size = CCHMAXPATHCOMP; filename_size = CCHMAXPATHCOMP; filenameext_size = CCHMAXPATH; #endif #else /* If OS/2 1.2 and beyond then allowed max sizes vary */ if (_osmajor < 10 || _osmode == DOS_MODE) resultbuf_size = sizeof(struct find_t); else if (_osminor < 20) resultbuf_size = sizeof(struct FileFindBuf); else { ext_size = CCHMAXPATHCOMP; filename_size = CCHMAXPATHCOMP; filenameext_size = CCHMAXPATH; resultbuf_size = sizeof(struct _FILEFINDBUF); } #endif if (!makeStr) /* extract file name */ if (!filename(_ftcscpy(fileStr, _pgmptr), &makeStr)) makeStr = "NMAKE"; // Initialize the message file SetErrorFile("nmake.err", _pgmptr, 1); // 1=Search Exe Path #if defined(SELF_RECURSE) initSavPtr = (char *)allocate(saveBytes = (&endOfSave - &startOfSave)); memmove(initSavPtr, &startOfSave, saveBytes); #endif /* set up handler for .PRECIOUS the handler tries to remove the * current target when control-C'd, unless it is "precious" */ #ifdef OS2_SIGNALS This commented out part was trial for using OS/2 function calls It still has some problems DOSSETSIGHANDLER(chkPrecious, pfnsig, prev, SIGA_ACCEPT, SIG_CTRLC); if (_osmode == OS2_MODE) { DOSSETSIGHANDLER(chkPrecious, NULL, NULL, SIGA_ACCEPT, SIG_CTRLBREAK); DOSSETSIGHANDLER(chkPrecious, NULL, NULL, SIGA_ACCEPT, SIG_KILLPROCESS); } #endif signal(SIGINT, chkPrecious); signal(SIGTERM, chkPrecious); makeIdeMessage(0, 0); status = doMake(argc, argv, NULL); #ifndef NO_OPTION_Z /* If -Z is specified then NMAKE needs to have errorLevel check in the * batch file. So add the goto label for exit and print the Reverse batch * file */ if (ON(gFlags, F1_REVERSE_BATCH_FILE)) { STRINGLIST *revCmd; //Adds ':NMAKEEXIT' to jump to end when error occurs revCmd = makeNewStrListElement(); revCmd->text = nmakeExitLabelCmd; prependItem(&revList, revCmd); //'=c' means echo at current line revCmd = makeNewStrListElement(); revCmd->text = makeString("=c"); appendItem(&revList, revCmd); //'=d' turns echoing on (unless preceeded by @) revCmd = makeNewStrListElement(); revCmd->text = makeString("=d"); appendItem(&revList, revCmd); } #endif delScriptFiles(); #ifndef NO_OPTION_Z if (ON(gFlags, F1_REVERSE_BATCH_FILE)) printReverseFile(); #endif #ifdef MEMORY_DEBUG mem_status(); #endif #ifdef HEAP_DIAGNOSTICS printHeapDiagnostics(); #endif #ifdef NMK_DEBUG fprintf(stderr, "Exiting...\n"); #endif if (!fSlashKStatus) //error when slashK specified status = 1; #if !defined(NDEBUG) && !defined(NT_BUILD) printStats(); #endif exit(status); }