// // main: int main(int argc, char *argv[]) { printf("Commander is a command line parsing module writed by L. Maddalena\n"); t_commander *cmd = makecommander(); addparam(cmd, "source"); addparam(cmd, "destination"); addoption(cmd, "f", "foo", "the foo parameter", 0, "value"); addoption(cmd, "g", "gas", "the gas parameter", 0, NULL); addoption(cmd, "b", "bar", "the bar parameter", 1, "1|2|3"); addoption(cmd, "z", "baz", "the baz parameter", 1, "name"); addoption(cmd, "h", "help", "output usage information", 0, NULL); int p = parseargs(cmd, argc, argv); if(argc == 1) { showusage(argv[0], cmd); return 0; } if(p == 0 || strcmp(getoptionbysname("h", cmd)->value, "1") == 0) { showhelp(argv[0], cmd); return 0; } showreport(cmd); }
int main(int argc, char** argv) { webserver_initialise(); int rc = parseargs(argc, argv); if (rc)return rc; logconsole(PKGBANNER); logconsole(PKGBUILD); rc = opendb(); if (rc)return rc; webserver_set_defaults(); webserver_add_search_int("/stanox", corpus_find_stanox); webserver_add_search_int("/nlc", corpus_find_nlc); webserver_add_search_int("/uic", corpus_find_uic); webserver_add_search_str("/3alpha", corpus_find_3alpha); webserver_add_search_str("/tiploc", corpus_find_tiploc); logconsole("Starting webserver on port %d", webserver.port); webserver_start(); while (1) { sleep(60); } }
int main(int argc, char *argv[]) { parseargs(argc, argv); openfiles(); filter(); exit(EXIT_SUCCESS); }
void IFCParser::parselist(wistream& is, Attribute& args) { args.clear(); wstring tok; while ((tok = lookahead(is)).length() > 0) { if (tok[0] == L',') { gettok(is); continue; // more } if (tok[0] == L')') break; if (tok[0] == L'(') { Attribute* f = new Attribute(); // add a list parseargs(is, *f); args.add(f); continue; } tok = gettok(is); args.add(tok); // add a value } }
static int checkargs (int argc, char **argv, bool_t *double_resolution, bool_t *panel, int *fps, char **image_name, fiasco_d_options_t **options) /* * Check validness of command line parameters and of the parameter files. * * Return value. * index in argv of the first argv-element that is not an option. * * Side effects: * 'double_resolution', 'panel', 'fps', 'image_name' and 'options' * are modified. */ { int optind; /* last processed commandline param */ optind = parseargs (params, argc, argv, "Decode FIASCO-FILEs and write frame(s) to disk.", "With no FIASCO-FILE, or if FIASCO-FILE is -, " "read standard input.\n" "Environment:\n" "FIASCO_DATA Search path for automata files. " "Default: ./\n" "FIASCO_IMAGES Save path for image files. " "Default: ./", " [FIASCO-FILE]...", FIASCO_SHARE, "system.fiascorc", ".fiascorc"); *image_name = (char *) parameter_value (params, "output"); *double_resolution = *((bool_t *) parameter_value (params, "double")); *panel = *((bool_t *) parameter_value (params, "panel")); *fps = *((int *) parameter_value (params, "framerate")); /* * Additional options ... (have to be set with the fiasco_set_... methods) */ *options = fiasco_d_options_new (); { int n = *((int *) parameter_value (params, "smoothing")); if (!fiasco_d_options_set_smoothing (*options, max (-1, n))) error (fiasco_get_error_message ()); } { int n = *((int *) parameter_value (params, "magnify")); if (!fiasco_d_options_set_magnification (*options, n)) error (fiasco_get_error_message ()); } { bool_t n = *((bool_t *) parameter_value (params, "fast")); if (!fiasco_d_options_set_4_2_0_format (*options, n > 0 ? YES : NO)) error (fiasco_get_error_message ()); } return optind; }
int main(int argc, char **argv) { if(signal(SIGINT, safe_exit) == SIG_ERR) SIGFAIL() if(signal(SIGQUIT, safe_exit) == SIG_ERR) SIGFAIL() if(signal(SIGTERM, safe_exit) == SIG_ERR) SIGFAIL() appname = argv[0]; setconfigdefaults(); if(parseargs(argc, argv) != 0) { return(1); } #ifdef DEBUG (void)printf("name: %s\n", config.name); (void)printf("host: %s\n", config.host); (void)printf("port: %s\n", config.port); (void)printf("limit: %d\n", (int)config.limit); #endif if(createandconnectsocket() != 0) { cleanup(); return(1); } while(rcvmsg() == 0 && quit == 0) { if(processmsg() != 0) { break; } } cleanup(); return(0); }
ram_reply_t main2(int argc, char *argv[]) { ramtest_params_t testparams; ram_reply_t e = RAM_REPLY_INSANE; RAM_FAIL_TRAP(ram_initialize(NULL, NULL)); RAM_FAIL_TRAP(initdefaults(&testparams)); e = parseargs(&testparams, argc, argv); switch (e) { default: RAM_FAIL_TRAP(e); case RAM_REPLY_OK: break; case RAM_REPLY_INPUTFAIL: return e; } e = runtest(&testparams); switch (e) { default: RAM_FAIL_TRAP(e); case RAM_REPLY_OK: break; case RAM_REPLY_INPUTFAIL: return e; } return RAM_REPLY_OK; }
int cor_thresh(char *keyword, char *args) { static char *realargs[10]; int res; int val; int x = 0; res = parseargs(args, realargs, 1, ','); if (res != 1) { error("Incorrect number of arguments to 'corthresh' (should be <value>)\n"); return -1; } res = sscanf(realargs[0], "%d", &val); if ((res == 1) && (val < 1)) res = -1; for(x = 0; corthreshes[x]; x++) { if (corthreshes[x] == val) break; } if (!corthreshes[x]) res = -1; if (res != 1) { error("Invalid value '%s', should be a number > 0.\n", realargs[0]); return -1; } corthresh = x + 1; return 0; }
int tx(char *keyword, char *args) { static char *realargs[10]; int res; int txtone; int isdcs = 0; res = parseargs(args, realargs, 1, ','); if (res != 1) { error("Incorrect number of arguments to 'tx' (should be <txtone>)\n"); return -1; } if ((*realargs[0] == 'D') || (*realargs[0] == 'd')) { realargs[0]++; isdcs = 0x8000; } res = sscanf(realargs[0], "%d", &txtone); if ((res == 1) && (txtone < 1)) res = -1; if (res != 1) { error("Invalid tx (tone) '%s', should be a number > 0.\n", realargs[0]); return -1; } txtones[0] = txtone | isdcs; return 0; }
int ext_tone(char *keyword, char *args) { static char *realargs[10]; int res; int val; res = parseargs(args, realargs, 1, ','); if (res != 1) { error("Incorrect number of arguments to 'exttone' (should be <value>)\n"); return -1; } if ((*realargs[0] == 'y') || (*realargs[0] == 'Y')) val = 1; else if ((*realargs[0] == 'n') || (*realargs[0] == 'N')) val = 0; else if ((*realargs[0] == 'i') || (*realargs[0] == 'I')) val = 2; else { res = sscanf(realargs[0], "%d", &val); if ((res == 1) && (val < 0)) res = -1; if (val > 2) res = -1; if (res != 1) { error("Invalid value '%s', should be a number > 0.\n", realargs[0]); return -1; } } exttone = val; return 0; }
/* ******************************************************************************* * * FUNCTION: ExecCommandline * * DESCRIPTION: This function is used to process an input string, split the * input string into command and parameter strings, find a command * structure in the command list array and execute the command. * * INPUT PARAMETERS: cmdListP is a pointer to the command list array. * cmdStringP is a pointer to the input string. * * RETURNS: none. ******************************************************************************* */ void ExecCommandline (CommandListEntry_T * cmdListP, char * inputStringP) { CommandListEntry_T * cmdListEntryP; int argc; char *argv[16]; char *resid; while (*inputStringP) { memset(argv, 0, sizeof(argv)); parseargs(inputStringP, &argc, argv, &resid); if (argc > 0) { if ((cmdListEntryP=findCmd(cmdListP, argv[0])) == NULL) { SerialPutString("Command is not found\r\n"); } else { cmdListEntryP->func(argc, (const char **)argv); } } inputStringP = resid; } }
int main (int ac, char **av) { int ncount, ecount, foundtour = 0, rval = 0; int *mytour; int *elist = (int *) NULL; int *elen = (int *) NULL; double bestlen, *mylen; rval = parseargs (ac, av); if (rval) return 1; if (wantlen) { mytour = &foundtour; mylen = &bestlen; } else { mytour = (int *) NULL; mylen = (double *) NULL; } rval = CCutil_getedgelist_n (&ncount, filelist[0], &ecount, &elist, &elen, 0); if (rval) { fprintf (stderr, "CCutil_getedgelist_n failed\n"); goto CLEANUP; } CC_IFFREE (elist, int); CC_IFFREE (elen, int); rval = CCutil_edge_file_union (ncount, nfiles, filelist, &ecount, &elist, &elen, mytour, mylen); if (rval) { fprintf (stderr, "CCutil_edge_file_union failed\n"); goto CLEANUP; } printf ("Merged Edge List: %d edges\n", ecount); fflush (stdout); if (outfname) { rval = CCutil_writeedges_int (ncount, outfname, ecount, elist, elen, 0); if (rval) { fprintf (stderr, "CCutil_writeedges_int failed\n"); goto CLEANUP; } } if (wantlen) { if (foundtour == 1) { printf ("Best Tour: %.0f\n", bestlen); fflush (stdout); } else { printf ("No tours\n"); fflush (stdout); } } CLEANUP: CC_IFFREE (elist, int); CC_IFFREE (elen, int); return rval; }
int main(int argc, char *argv[]) { LALFrStream *stream; REAL8TimeSeries *series; LIGOTimeGPS start; XLALSetErrorHandler(XLALAbortErrorHandler); parseargs(argc, argv); /* get the data */ stream = XLALFrStreamCacheOpen(cache); XLALGPSSetREAL8(&start, t0 - pad); series = XLALFrStreamInputREAL8TimeSeries(stream, channel, &start, dt + 2.0 * pad, 0); XLALFrStreamClose(stream); /* manipulate the data */ if (srate > 0) XLALResampleREAL8TimeSeries(series, 1.0 / srate); if (minfreq > 0) XLALHighPassREAL8TimeSeries(series, minfreq, 0.9, 8); if (maxfreq > 0) XLALLowPassREAL8TimeSeries(series, maxfreq, 0.9, 8); if (pad > 0) series = XLALResizeREAL8TimeSeries(series, pad / series->deltaT, dt / series->deltaT); if (df > 0) { /* we are computing a spectrum */ REAL8FrequencySeries *spectrum; REAL8FFTPlan *plan; REAL8Window *window; size_t seglen = 1.0 / (df * series->deltaT); /* make sure that the time series length is commensurate with seglen */ if (((2 * series->data->length) % seglen) != 0) { size_t newlen = ((2 * series->data->length) / seglen) * seglen; series = XLALResizeREAL8TimeSeries(series, 0, newlen); } spectrum = XLALCreateREAL8FrequencySeries(series->name, &series->epoch, 0.0, df, &lalDimensionlessUnit, seglen/2 + 1); plan = XLALCreateForwardREAL8FFTPlan(seglen, 0); window = XLALCreateHannREAL8Window(seglen); XLALREAL8AverageSpectrumWelch(spectrum, series, seglen, seglen/2, window, plan); if (minfreq > 0 || maxfreq > 0) { size_t first = minfreq / spectrum->deltaF; size_t last = maxfreq > 0 ? maxfreq / spectrum->deltaF : spectrum->data->length; spectrum = XLALResizeREAL8FrequencySeries(spectrum, first, last - first); } output_fs(outfile, spectrum); XLALDestroyREAL8Window(window); XLALDestroyREAL8FFTPlan(plan); XLALDestroyREAL8FrequencySeries(spectrum); } else { /* we are outputting a time series */ output_ts(outfile, series); } XLALDestroyREAL8TimeSeries(series); return 0; }
int main(int argc, char **argv) { startup_checks(); parseargs(argc, argv); connect_to_server(); gethandle(); while (1) do_something(); }
int main(int argc, char *argv[]) { char tstr[32]; // string to hold GPS time -- 31 characters is enough const double H0 = 0.72 * LAL_H0FAC_SI; // Hubble's constant in seconds const size_t length = 65536; // number of points in a segment const size_t stride = length / 2; // number of points in a stride size_t i, n; REAL8FrequencySeries *OmegaGW = NULL; REAL8TimeSeries **seg = NULL; LIGOTimeGPS epoch; gsl_rng *rng; XLALSetErrorHandler(XLALAbortErrorHandler); parseargs(argc, argv); XLALGPSSetREAL8(&epoch, tstart); gsl_rng_env_setup(); rng = gsl_rng_alloc(gsl_rng_default); OmegaGW = XLALSimSGWBOmegaGWFlatSpectrum(Omega0, flow, srate/length, length/2 + 1); n = duration * srate; seg = LALCalloc(numDetectors, sizeof(*seg)); printf("# time (s)"); for (i = 0; i < numDetectors; ++i) { char name[LALNameLength]; snprintf(name, sizeof(name), "%s:STRAIN", detectors[i].frDetector.prefix); seg[i] = XLALCreateREAL8TimeSeries(name, &epoch, 0.0, 1.0/srate, &lalStrainUnit, length); printf("\t%s (strain)", name); } printf("\n"); XLALSimSGWB(seg, detectors, numDetectors, 0, OmegaGW, H0, rng); // first time to initilize while (1) { // infinite loop size_t j; for (j = 0; j < stride; ++j, --n) { // output first stride points LIGOTimeGPS t = seg[0]->epoch; if (n == 0) // check if we're done goto end; printf("%s", XLALGPSToStr(tstr, XLALGPSAdd(&t, j * seg[0]->deltaT))); for (i = 0; i < numDetectors; ++i) printf("\t%e", seg[i]->data->data[j]); printf("\n"); } XLALSimSGWB(seg, detectors, numDetectors, stride, OmegaGW, H0, rng); // make more data } end: for (i = 0; i < numDetectors; ++i) XLALDestroyREAL8TimeSeries(seg[i]); XLALFree(seg); XLALDestroyREAL8FrequencySeries(OmegaGW); LALCheckMemoryLeaks(); return 0; }
int main(int argc, char** argv){ struct timeval tv; if(argc > 4 || parseargs(argc, argv) == 0) return -1; /* This starts the xuartctl daemon TODO - Should we start it */ /* printf("Starting xuartctl...");*/ /* fflush(stdout);*/ /* system("xuartctl -d -p 0 -o 8n1 -s 9600");*/ /* printf("done\n");*/ printf("Starting gps with device %s\n", gps_device); uart_init( 0, stderr, gps_device); original_tries = tries; for(;!is_gps_ready(); tries--) { if(tries <= 0) { fprintf(stderr, "Number of tries limit of %u was reached. Returning error -1\n", original_tries); return -1; } sleep(1); } printf("GPS is ready. Reading value and setting it in kernel.\n"); switch(getGPStimeUTC(&tv)){ case 1: fprintf(stderr, "Unable to read time from GPS (Error 1)\n"); return -1; case 2: fprintf(stderr, "An error occured while waiting for a time reply (Error 2)\n"); return -1; } printf("GPS returned with UNIX seconds: %ld\n", tv.tv_sec); // set miavita time set_seconds((uint64_t) tv.tv_sec); /* Set's the seconds in the miavia counter in the kernel cat ts7500_kernel/ipc/miavita_syscall.c:sys_miavitasetseconds */ printf("Seconds set in the miavita kernel variable: %lu\n", get_mean_value()); printf("Now I'm going to set the current date to the OS\n"); printf("Time at before setting:\n"); print_time(); // set system time time_t seconds_time = (time_t) tv.tv_sec; stime(&seconds_time); sleep(2); printf("Time at after setting:\n"); print_time(); printf("Program finished without errors.\n"); return 0; }
int main (int ac, char **av) { CC_SPORT *p = (CC_SPORT *) NULL; CC_SFILE *f = (CC_SFILE *) NULL; int rval = 0; if (parseargs (ac, av)) return 0; CCutil_signal_init (); if (debug) { printf ("Serving files for %s\n", probname); fflush (stdout); } p = CCutil_snet_listen (probport); if (p == (CC_SPORT *) NULL) { fprintf (stderr, "CCutil_snet_listen failed\n"); rval = 1; goto CLEANUP; } for (;;) { if (debug) { printf ("Waiting for connection\n"); fflush (stdout); } f = CCutil_snet_receive (p); if (f == (CC_SFILE *) NULL) { fprintf (stderr, "CCutil_snet_receive failed\n"); continue; } if (debug) { printf ("Received connection\n"); fflush (stdout); } rval = serve_file (f, probname, run_silently); if (rval) { fprintf (stderr, "serve_file failed\n"); if (CCutil_sclose (f)) { fprintf (stderr, "CCutil_sclose failed\n"); } continue; } if (debug) { printf ("Closing connection\n"); fflush (stdout); } rval = CCutil_sclose (f); if (rval) { fprintf (stderr, "CCutil_sclose failed\n"); } f = (CC_SFILE *) NULL; } CLEANUP: if (f != (CC_SFILE *) NULL) CCutil_sclose (f); if (p != (CC_SPORT *) NULL) CCutil_snet_unlisten (p); return rval; }
//Begin ClientCode int main(int argc, char ** argv) { #ifdef CSEC_VERIFY assume_string("clientID"); assume_string("serverID"); assume_string("port_ascii"); // Assumption that the corresponding argv fields indeed contains the correct ids: readenvL(argv[1], strlen(argv[1]), "clientID"); readenvL(argv[2], strlen(argv[2]), "serverID"); readenvL(argv[3], strlen(argv[3]), "port_ascii"); #endif RPCstate clState; clState.end = CLIENT; if (parseargs(argc,argv,&clState)) { #ifdef VERBOSE fprintf(stdout, "Usage: client clientAddress serverAddress [port] request\n"); #endif exit(-1); } #ifdef VERBOSE printf("Client: Now connecting to "); print_text_buffer(clState.other,clState.other_len); printf(", port %d.\n", clState.port); fflush(stdout); #endif // Getting arguments if (socket_connect(&(clState.conn_fd),(char*) clState.other, clState.other_len, clState.port)) return -1; clState.k_ab = get_shared_key(clState.self, clState.self_len, clState.other, clState.other_len, &(clState.k_ab_len)); clState.k = mk_session_key(&(clState.k_len)); clState.response = NULL; #ifdef CSEC_VERIFY event3("client_begin", clState.self, clState.self_len, clState.other, clState.other_len, clState.request, clState.request_len); #endif /* Send request */ if (send_request(&clState) < 0) return -1; /* Receive response */ if (recv_response(&clState) < 0) return -1; #ifdef CSEC_VERIFY event4("client_accept", clState.self, clState.self_len, clState.other, clState.other_len, clState.request, clState.request_len, clState.response, clState.response_len); #endif return 0; }
int main(int argc, char *argv[]) { int ret; if (argc < 2) usage(EXIT_FAILURE); color_init(false); ret = parseargs(argc, argv); fclose(stdout); return ret; }
/** * Parse command line options and return dynamically allocated structure * to global parameters * @param argc - copy of argc from main * @param argv - copy of argv from main * @return allocated structure with global parameters */ glob_pars *parse_args(int argc, char **argv){ void *ptr; ptr = memcpy(&G, &Gdefault, sizeof(G)); assert(ptr); // format of help: "Usage: progname [args]\n" change_helpstring("Usage: %s [args]\n\n\tWhere args are:\n"); // parse arguments parseargs(&argc, &argv, cmdlnopts); if(help || argc > 0) showhelp(-1, cmdlnopts); return &G; }
int main(int argc, char *argv[]) { loginit(NULL); if (argc < 4) fatal("Expected 3 arguments"); parseargs(argc, argv); rng(&r); int w = strtol(argv[1], NULL, 10); int h = strtol(argv[2], NULL, 10); int d = strtol(argv[3], NULL, 10); Lvl *lvl = lvlnew(d, w, h, 0); unsigned int x0 = 2, y0 = 2; if (randstart) { x0 = rnd(1, w-2); y0 = rnd(1, h-2); } mvsinit(); do{ init(lvl); if (addwater) water(lvl); Loc loc = (Loc) { x0, y0, 0 }; Path *p = pathnew(lvl); pathbuild(lvl, p, loc); pathfree(p); morereach(lvl); closeunits(lvl); }while(closeunreach(lvl) < lvl->w * lvl->h * lvl->d * 0.40); stairs(&r, lvl, x0, y0); bool foundstart = false; for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { if (blk(lvl, x, y, 0)->tile == 'u' || blk(lvl, x, y, 0)->tile == 'U') { foundstart = true; break; } } } assert(foundstart); lvlwrite(stdout, lvl); lvlfree(lvl); return 0; }
int main(int ac, char **av) { int rval = 0; int d; MWSSgraph graph; MWSSdata data; wstable_info info; wstable_parameters parms; MWISNW goal = MWISNW_MAX; reset_pointers(&graph, &data, &info); default_parameters(&parms); parseargs (ac, av, &parms); if (test) { for(n = 10; n <= 100; n = n + 10) { for(d = 1; d <= 9; d = d + 2) { seed = 3.1567; rval = testprobs(&graph, &data, &parms, n, d / 10.0, &seed, &info); MWIScheck_rval(rval,"Failed in testprobs"); } } } else { if (gen) { rval = rgrphgen(&graph, n, density, &seed); MWIScheck_rval(rval,"Failed in rgrphgen"); } else { rval = read_dimacs(&graph, prob_file); MWIScheck_rval(rval,"Failed in read_dimacs"); } if(parms.prn_info > 0) prn_graph(&graph); rval = initialize_max_wstable(&graph, &info); MWIScheck_rval(rval,"Failed in initialize_max_wstable"); if (lower_bound > 0) { goal = lower_bound + 1; } rval = call_max_wstable(&graph, &data, &parms, &info, goal, lower_bound); MWIScheck_rval(rval,"Failed in call_max_wstable"); if (rval == 0) { printf("Found best stable set of weight %d.\n",data.best_z); fflush(stdout); } } CLEANUP: free_max_wstable(&graph,&data, &info); return rval; }
void initglobal(int argc,char *argv[]) { char *ptr; parseargs(argc,argv); ptr=strrchr(PROGNAME,'/'); if (ptr==NULL) PROGNAME[0]='\0'; else *ptr='\0'; VOLREN=new volren(PROGNAME); if (strlen(OUTNAME)>0) { loadvolume(); VOLREN->savePVMvolume(OUTNAME); exit(0); } EYE_X=0.0f; EYE_Y=0.0f; EYE_Z=3.0f; EYE_SPEED=0.0f; VOLREN->get_tfunc()->set_line(0.0f,0.0f,0.33f,1.0f,VOLREN->get_tfunc()->get_be()); VOLREN->get_tfunc()->set_line(0.33f,1.0f,0.67f,0.0f,VOLREN->get_tfunc()->get_be()); VOLREN->get_tfunc()->set_line(0.33f,0.0f,0.67f,1.0f,VOLREN->get_tfunc()->get_ge()); VOLREN->get_tfunc()->set_line(0.67f,1.0f,1.0f,0.0f,VOLREN->get_tfunc()->get_ge()); VOLREN->get_tfunc()->set_line(0.67f,0.0f,1.0f,1.0f,VOLREN->get_tfunc()->get_re()); VOLREN->get_tfunc()->set_line(0.0f,0.0f,1.0f,1.0f,VOLREN->get_tfunc()->get_ra()); VOLREN->get_tfunc()->set_line(0.0f,0.0f,1.0f,1.0f,VOLREN->get_tfunc()->get_ga()); VOLREN->get_tfunc()->set_line(0.0f,0.0f,1.0f,1.0f,VOLREN->get_tfunc()->get_ba()); loadhook(); if ((GUI_recfile=fopen(RECORD,"rb"))!=NULL) { GUI_demo=TRUE; fclose(GUI_recfile); } if (GUI_record) { if ((GUI_recfile=fopen(RECORD,"wb"))==NULL) ERRORMSG(); GUI_demo=FALSE; } if (GUI_demo) { if ((GUI_recfile=fopen(RECORD,"rb"))==NULL) ERRORMSG(); GUI_start=gettime(); } }
static int Init(int argc, const char **argv) { if ((App = AppAlloc(&AppInfo,argc,argv)) == NULL) return -1; if (parseargs() != 0) return -1; if (init() != 0) return -1; return 0; }
bool readargs(uchar *file) { FILE *fp; ulong line,firstarg,newargs,pos; uchar s[1000],w[200]; if(!(fp=fopen(file,"r"))) { printf("Failed to open %s\n",file); return(FALSE); } line=0; while(fgets(s,999,fp)) { line++; strip(s); if(s[0] != '#') { firstarg=fileargc; newargs=0; pos=0; while(getcfgword(s,&pos,w,200)) { if(fileargc == MAXFILEARGS) { printf("Too many options in %s, max is %d\n",file,MAXFILEARGS); fclose(fp); return(FALSE); } if(!(fileargv[fileargc++] = strdup(w))) { fclose(fp); return(FALSE); } newargs++; } if(newargs) { if(!(parseargs(newargs,&fileargv[firstarg],file,line))) return(FALSE); } } } fclose(fp); return(TRUE); }
void aplus_main(long argc, char** argv) { #if !defined(_INTERPRETER_ONLY) extern void AplusLoop(); #endif I i; /* the number of arguments parsed */ #if !defined(_INTERPRETER_ONLY) dapinit(); #endif initReleaseData(_releaseCode); initVersion(); initDefaultATREE(argv[0]); initCallouts(); i = parseargs(argc, argv); if( !_quiet ) printId(); atmpinit(); envinit(); if(0!=_megsforheap)setk1(_megsforheap); /* must be before mem init! */ ai(_workarea); /* initialize */ if(_enable_coredump) { setSigv(1); setSigb(1); coreLimSet(aplusInfinity); } versSet(_version); releaseCodeSet(_releaseCode); phaseOfReleaseSet(_phaseOfRelease); majorReleaseSet(_majorRelease); minorReleaseSet(_minorRelease); startupSyslog(_version); xi(argv[0]); /* installation */ argvInstall(argc, argv, i); /* set up _argv */ uextInstall(); /* user lib install */ #if !defined(_INTERPRETER_ONLY) AplusLoop(argc, argv, i); #else if (i < argc && argv[i] && *argv[i]) loadafile(argv[i],0); if (Tf) pr(); while(1) getm(); #endif /********************************************************************** These functions are moved to AplusLoop if (i < argc && argv[i] && *argv[i]) loadafile(argv[i],0); / * load script * / if (Tf) pr(); / * initial prompt * / **********************************************************************/ }
int ctcss(char *keyword, char *args) { static char *realargs[10]; int res; int rxtone; int rxtag; int txtone; int isdcs = 0; res = parseargs(args, realargs, 3, ','); if (res != 3) { error("Incorrect number of arguments to 'ctcss' (should be <rxtone>,<rxtag>,<txtone>)\n"); return -1; } res = sscanf(realargs[0], "%d", &rxtone); if ((res == 1) && (rxtone < 1)) res = -1; if (res != 1) { error("Invalid rxtone '%s', should be a number > 0.\n", realargs[0]); return -1; } res = sscanf(realargs[1], "%d", &rxtag); if ((res == 1) && (rxtag < 0)) res = -1; if (res != 1) { error("Invalid rxtag '%s', should be a number > 0.\n", realargs[1]); return -1; } if ((*realargs[2] == 'D') || (*realargs[2] == 'd')) { realargs[2]++; isdcs = 0x8000; } res = sscanf(realargs[2], "%d", &txtone); if ((res == 1) && (rxtag < 0)) res = -1; if (res != 1) { error("Invalid txtone '%s', should be a number > 0.\n", realargs[2]); return -1; } if (toneindex >= NUM_TONES) { error("Cannot specify more then %d CTCSS tones\n",NUM_TONES); return -1; } rxtones[toneindex] = rxtone; rxtags[toneindex] = rxtag; txtones[toneindex] = txtone | isdcs; toneindex++; return 0; }
int main(int argc, char *argv[]) { io s; parseenv(); parseargs(argc, argv); initconn(&s); c = &s; atexit(quit); greeting(&s); getlatest(&s); exit(EXIT_SUCCESS); }
int main(int argc, char *argv[]) { const double H0 = 0.72 * LAL_H0FAC_SI; // Hubble's constant in seconds const double srate = 16384.0; // sampling rate in Hertz const size_t length = 65536; // number of points in a segment const size_t stride = length / 2; // number of points in a stride size_t i, n; REAL8FrequencySeries *OmegaGW = NULL; REAL8TimeSeries **seg = NULL; LIGOTimeGPS epoch; gsl_rng *rng; XLALSetErrorHandler(XLALAbortErrorHandler); parseargs(argc, argv); XLALGPSSetREAL8(&epoch, tstart); gsl_rng_env_setup(); rng = gsl_rng_alloc(gsl_rng_default); OmegaGW = XLALSimSGWBOmegaGWFlatSpectrum(Omega0, flow, srate/length, length/2 + 1); n = duration * srate; seg = LALCalloc(numDetectors, sizeof(*seg)); for (i = 0; i < numDetectors; ++i) seg[i] = XLALCreateREAL8TimeSeries("STRAIN", &epoch, 0.0, 1.0/srate, &lalStrainUnit, length); XLALSimSGWB(seg, detectors, numDetectors, 0, OmegaGW, H0, rng); // first time to initilize while (1) { // infinite loop double t0 = XLALGPSGetREAL8(&seg[0]->epoch); size_t j; for (j = 0; j < stride; ++j, --n) { // output first stride points if (n == 0) // check if we're done goto end; printf("%.9f", t0 + j * seg[0]->deltaT); for (i = 0; i < numDetectors; ++i) printf("\t%e", seg[i]->data->data[j]); printf("\n"); } XLALSimSGWB(seg, detectors, numDetectors, stride, OmegaGW, H0, rng); // make more data } end: for (i = 0; i < numDetectors; ++i) XLALDestroyREAL8TimeSeries(seg[i]); XLALFree(seg); XLALDestroyREAL8FrequencySeries(OmegaGW); LALCheckMemoryLeaks(); return 0; }
/* parse and execute a string */ void execcmd(void) { char *resid; char *p = cmd_buf; while (*p) { memset(argv, 0, sizeof(argv)); parseargs(p, &argc, argv, &resid); /* execute a function */ if (argc > 0) { execfunc(argc, (const char **) argv); } p = resid; } }