int EsdlCMDShell::run() { try { if (!parseCommandLineOptions(args)) return 1; finalizeOptions(globals); return processCMD(args); } catch (IException *E) { StringBuffer m; fputs(E->errorMessage(m).newline().str(), stderr); E->Release(); return 2; } #ifndef _DEBUG catch (...) { ERRLOG("Unexpected exception\n"); return 4; } #endif return 0; }
/* Xavier Thomas Section U01 I affirm that this program is entirely my own work and none of it is the work of any other person. */ int main(int argc, char *argv[]){ printf("Welcome To assignment 1\n"); int caseSensitive = 0; char *outputFile = NULL; char *inputFile = NULL; parseCommandLineOptions(argc,argv,&caseSensitive,&outputFile,&inputFile); // printf("Case '%d' , outputFile '%s' inputfile '%s'\n",caseSensitive,outputFile,inputFile); int readType = determineRead(inputFile); // printf("Read Type '%d'\n", readType); if(readType){ readFile(inputFile,caseSensitive); }else{ readFromInput(caseSensitive); } determineOutput(outputFile); printPostOrder(&root); printf("End Of Assingment\n"); return 0; }
Value parseCommandLineOptions(int argc, const char16_t * wargv[], const Function<int (Value &ret, char c, const char *str)> &switchCallback, const Function<int (Value &ret, const String &str, int argc, const char * argv[])> &stringCallback) { Vector<String> vec; vec.reserve(argc); Vector<const char *> argv; argv.reserve(argc); for (int i = 0; i < argc; ++ i) { vec.push_back(string::toUtf8(wargv[i])); argv.push_back(vec.back().c_str()); } return parseCommandLineOptions(argc, argv.data(), switchCallback, stringCallback); }
int main(int argc, char **argv) { parseCommandLineOptions(argc, argv); // Allocate and initialize constant and mutable weights. uint8_t *constantWeightVarsAddr = initConstantWeights("zfnet512.weights", zfnet512_config); uint8_t *mutableWeightVarsAddr = initMutableWeightVars(zfnet512_config); uint8_t *activationsAddr = initActivations(zfnet512_config); // Perform the computation. zfnet512(constantWeightVarsAddr, mutableWeightVarsAddr, activationsAddr); // Report the results. dumpInferenceResults(zfnet512_config, mutableWeightVarsAddr); // Free all resources. free(activationsAddr); free(constantWeightVarsAddr); free(mutableWeightVarsAddr); }
int EclCMDShell::run() { if (!parseCommandLineOptions(args)) return 1; if (!optIniFilename) { if (checkFileExists(INIFILE)) optIniFilename.set(INIFILE); else { StringBuffer fn(SYSTEMCONFDIR); fn.append(PATHSEPSTR).append(DEFAULTINIFILE); if (checkFileExists(fn)) optIniFilename.set(fn); } } globals.setown(createProperties(optIniFilename, true)); finalizeOptions(globals); try { return processCMD(args); } catch (IException *E) { StringBuffer m("Error: "); fputs(E->errorMessage(m).newline().str(), stderr); E->Release(); return 2; } #ifndef _DEBUG catch (...) { ERRLOG("Unexpected exception\n"); return 4; } #endif return 0; }
int main(int argc, char* argv[]) { if (!parseCommandLineOptions(argc, argv)) return EXIT_FAILURE; Evas* evas = initEfl(); RefPtr<Evas_Object> actualImage; RefPtr<Evas_Object> baselineImage; char buffer[2048]; while (fgets(buffer, sizeof(buffer), stdin)) { char* contentLengthStart = strstr(buffer, "Content-Length: "); if (!contentLengthStart) continue; long imageSize; if (sscanf(contentLengthStart, "Content-Length: %ld", &imageSize) == 1) { if (imageSize <= 0) abortWithErrorMessage("image size must be specified"); if (!actualImage) actualImage = readImageFromStdin(evas, imageSize); else if (!baselineImage) { baselineImage = readImageFromStdin(evas, imageSize); printImageDifferences(baselineImage.get(), actualImage.get()); actualImage.clear(); baselineImage.clear(); } } fflush(stdout); } gEcoreEvas.clear(); // Make sure ecore_evas_free is called before the EFL are shut down shutdownEfl(); return EXIT_SUCCESS; }
/* * Main program loop */ int main(int iArgCount, char *aArgList[]) { uint8_t *aBBAPkt; /* Buffer to hold a bba packet read from the wire */ struct stBBAPacketInfo oPktInfo; /* Struct to hold information from the packet header */ double dPrevTime; int bOKToSend; char *sOutPkt; /* Packet to put onto the orb */ int iOutPktLen; /* Length of sOutPkt */ elog_init(iArgCount, aArgList); /* Parse out command line options */ if (parseCommandLineOptions(iArgCount, aArgList) == RESULT_SUCCESS) { /* Read in the parameter file */ if (paramFileRead() == RESULT_FAILURE) { elog_complain(1, "main(): Error encountered during paramFileRead() operation."); dcbbaCleanup(-1); } /* Exit if bPFValidateFlag is set */ if (oConfig.bPFValidateFlag == TRUE) { elog_notify( 0, "main(): Parameter File %s validated successfully. Exiting.", oConfig.sParamFileName); dcbbaCleanup(0); } /* Allocate memory for our packet */ allot (uint8_t *, aBBAPkt, oConfig.iBBAPktBufSz); /* Set up a signal handler to re-read the parameter file on SIGUSR1*/ signal(SIGUSR1, sig_hdlr); /* Connect to the ORB */ if ((orbfd = orbopen(oConfig.sOrbName, "w&")) < 0) { elog_complain(1, "orbopen: unable to connect to ORB \"%s\".", oConfig.sOrbName); dcbbaCleanup(-1); } /* Connect to Data Concentrator's Data read port */ if (dcDataConnect(oConfig.iConnectionType, oConfig.sDCConnectionParams) == RESULT_SUCCESS) { dPrevTime = now(); /*** BEGIN MAIN LOOP ***/ while (readFromDC(&oPktInfo, aBBAPkt) == RESULT_SUCCESS) { bOKToSend = TRUE; /* Check the packet age */ /*if (fabs(oPktInfo.dPktTime - dPrevTime) > 86400.0) { dPrevTime = now(); if (fabs(oPktInfo.dPktTime - dPrevTime) > 86400.0) { elog_complain( 0, "%s packet has bad time - %s (epoch:%lf). Will discard packet.\n", oPktInfo.sSrcname, sTimeStamp = strtime( oPktInfo.dPktTime), oPktInfo.dPktTime); free(sTimeStamp); bOKToSend = FALSE; } else dPrevTime = oPktInfo.dPktTime; } else dPrevTime = oPktInfo.dPktTime;*/ if (bOKToSend == TRUE) { /* Add orb header to Packet */ iOutPktLen = (int) stuffBBAPkt(&oPktInfo, aBBAPkt, &sOutPkt); if (iOutPktLen == 0) { /* There was an error stuffing the packet*/ elog_complain( 1, "An error occurred while adding the ORB header to the raw packet. Not submitting to the orb."); } else if (sOutPkt == 0) { elog_die(1, "Output packet length was non-zero but pointer to Output packet is null"); } else { /* put it into the orb */ if (oConfig.bVerboseModeFlag == TRUE) { showPkt(0, oPktInfo.sSrcname, oPktInfo.dPktTime, sOutPkt, iOutPktLen, stderr, PKT_UNSTUFF); showPkt(0, oPktInfo.sSrcname, oPktInfo.dPktTime, sOutPkt, iOutPktLen, stderr, PKT_DUMP); } if (orbput(orbfd, oPktInfo.sSrcname, oPktInfo.dPktTime, sOutPkt, iOutPktLen)) { elog_complain(0, "orbput() failed in main()\n"); dcbbaCleanup(-1); } if (oConfig.bVerboseModeFlag == TRUE) elog_notify(0, "packet submitted under %s\n", oPktInfo.sSrcname); /* Free the packet */ free(sOutPkt); } } } /* * If we get here, it means readFromDC failed to get a packet from oDCDataBNS. * This could be either that an EOF was reached if we were reading from a file, * or that the socket died unexpectedly. */ dcbbaCleanup(-1); } /* Else unable to connect, cleanup with failure (-1) exit code */ else dcbbaCleanup(-1); } else {
int PL_initialise(int argc, char **argv) { int n; bool compile = FALSE; const char *rcpath = "<none>"; if ( GD->initialised ) succeed; initAlloc(); initPrologThreads(); /* initialise thread system */ SinitStreams(); GD->cmdline.os_argc = argc; GD->cmdline.os_argv = argv; initOs(); /* Initialise OS bindings */ initDefaults(); /* Initialise global defaults */ initPaths(argc, (const char**)argv); /* fetch some useful paths */ { GET_LD #ifdef HAVE_SIGNAL setPrologFlagMask(PLFLAG_SIGNALS); /* default: handle signals */ #endif if ( (GD->resourceDB = rc_open_archive(GD->paths.executable, RC_RDONLY)) #ifdef __WINDOWS__ || (GD->resourceDB = rc_open_archive(GD->paths.module, RC_RDONLY)) #endif ) { rcpath = ((RcArchive)GD->resourceDB)->path; initDefaultOptions(); } if ( !GD->resourceDB || !streq(GD->options.saveclass, "runtime") ) { int done; argc--; argv++; if ( argc == 1 && giveVersionInfo(argv[0]) ) /* -help, -v, etc */ { exit(0); } for(n=0; n<argc; n++) /* need to check this first */ { if ( streq(argv[n], "--" ) ) /* --: terminates argument list */ break; if ( streq(argv[n], "-b" ) ) /* -b: boot compilation */ { GD->bootsession = TRUE; break; } } DEBUG(1, if (GD->bootsession) Sdprintf("Boot session\n");); if ( !GD->resourceDB ) { if ( !(GD->resourceDB = openResourceDB(argc, argv)) ) { fatalError("Could not find system resources"); } rcpath = ((RcArchive)GD->resourceDB)->path; initDefaultOptions(); } if ( (done = parseCommandLineOptions(argc, argv, &compile)) < 0 ) { usage(); fail; } argc -= done; argv += done; }
int main(int argc, char *argv[]) { parseCommandLineOptions(argc, argv); initializeRandomNumberGeneratorTo(rng_seed); initializeOutput(); setInitialConditions(); if (graphicsModeEnabled()) initializeDisplay(); perturbation_length=fixed_perturbation_length; for(monte_carlo_steps=start_mcs; monte_carlo_steps<=end_mcs; monte_carlo_steps++) { updatePairList(); generateOutput(); attempted_moves = 0; accepted_moves = 0; for (monte_carlo_step_counter=0; monte_carlo_step_counter<number_of_molecules; monte_carlo_step_counter++) { double boltzmann_factor; double the_exponential; delta_energy = 0; attemptMove(); attempted_moves++; if (delta_energy < 0) { change_flag = 1; accepted_moves++; continue; /* move accepted */ } // the following uses reduced temperature the_exponential = 0.0 - delta_energy/temperature; /* evaluate exponential, unless it's arbitrarily small */ if (the_exponential > -25) { boltzmann_factor = exp(the_exponential); if (boltzmann_factor > rnd()) { change_flag = 1; accepted_moves++; continue; /* move accepted */ } } // revert move x[particle_number] -= dx; y[particle_number] -= dy; z[particle_number] -= dz; } if (monte_carlo_steps < relaxation_allowance) { acceptance_ratio = (0.0 + accepted_moves)/(0.0 + attempted_moves); if (acceptance_ratio < target_acceptance_ratio) perturbation_length *= .9; else if (perturbation_length*perturbation_length*perturbation_length*16 < box_x*box_y*box_z) perturbation_length *=1.1; } else perturbation_length = fixed_perturbation_length; if (graphicsModeEnabled() && changeFlagIsSet()) drawGraphicalRepresentation(); } finalizeOutput(); return 0; } /* end main */
int main(int argc, char **argv) #endif { int expectedMods = 0; #ifdef macintosh doSiouxStuff(); argc = ccommand(&argv); #endif /* Added by Bob Goode/Tam Ngo, 5/21/97, for WINSOCK option. */ #ifdef OS2 sock_init(); #elif defined(_WINSOCK_) startWinsock(); #endif /* Winsock DLL loading */ x_ipcModuleInitialize(); #ifdef VXWORKS /* Do this only after the socket is set up (in case there is an old central lying around that needs killed */ centralTID = taskIdSelf(); #endif globalSInit(); #if !defined(THINK_C) && !defined(macintosh) && !defined(__TURBOC__) && !defined(OS2) && !defined(_WIN95_MSC_) && !defined(WINNT) && !defined(WIN32) (void)signal(SIGINT, abortCentral); (void)signal(SIGBUS, abortCentral); (void)signal(SIGSEGV, abortCentral); (void)signal(SIGPIPE, pipeClosedHnd); (void)signal(SIGTERM, abortCentral); #endif /* !THINK_C && !macintosh */ #ifndef VXWORKS if ((argc > 1) && (STREQ(argv[1], "-v"))) displayVersion(); else if ((argc > 1) && (STREQ(argv[1], "-h"))) { displayOptions(argv[0]); #ifdef macintosh SIOUXSettings.autocloseonquit = FALSE; #endif } else { parseExpectedMods(argc, argv, &expectedMods); parseCommandLineOptions(argc, argv); #else if ((options!= NULL) && (strstr(options, "-v") || strstr(options, "-V"))) { displayVersion(); } else if ((options!= NULL) && (strstr(options, "-h") || strstr(options, "-H"))) { displayOptions("central"); } else { parseOpsFromStr(options, &expectedMods, FALSE); #endif if (expectedMods < 1) expectedMods = 1; if (!serverInitialize(expectedMods)) { X_IPC_ERROR("ERROR: Unable to start server, Is one already running?\n"); } #ifndef VXWORKS /* Register a method for freeing memory in an emergency. */ x_ipcRegisterFreeMemHnd(centralFreeMemory,3); if (GET_S_GLOBAL(listenToStdin)) printPrompt(); #endif #ifndef DEFAULT_OPTIONS fprintf(stderr, "central running...\n"); #endif listenLoop(); } #ifdef _WINSOCK_ WSACleanup(); printf("Socket cleaned up."); #endif /* Unload Winsock DLL */ #ifndef VXWORKS return 1; #endif }