//MAIN Program int main (int argc, char* argv[]){ //Argumnets check int exec_flag = arg_checker(&argc); //Check foe execution mode if(exec_flag < 0) error(7); else if (exec_flag == 0) { //Call interactive mode shell //printf ("Entering shell mode\n"); int ret_s = shell_mode(); if (ret_s != 0) error(8); } else { //printf ("Entering batch mode\n"); char* batch_file = argv[1]; int ret_b = batch_mode(batch_file); if (ret_b != 0) error(9); } return 0; }
int main (int argc, char **argv) { pa_explain("-input","generic-grabbers generic grabbers params") ("-config","config file input") ("-size","grabbers desired image size") ("-nogui","start without gui") ("-output","for no gui batchmode: define output-image pattern\n" "use ##### for the image index in this pattern"); pa_init(argc,argv,"[m]-input|-i(device,device-params) " "-output|-o(output-file-pattern) -config|-c(cfg-filename) " " -nogui|-n -color -size|-s(size=VGA)"); if(pa("-nogui")){ batch_mode(); }else{ return ICLApp(argc,argv,"",init,run).exec(); } }
int main(int argc, char **argv) { bool non_batch = false; bool batch = false; bool employee = false; bool guest = false; bool arrival = false; bool departure = false; int32_t timestamp = -1; const char *token = NULL; const char *name = NULL; int32_t room = -1; const char *filename = NULL; struct log_entry l; int opt; static const char *optstr = "T:K:E:G:ALR:B"; opterr = 0; while((opt = getopt(argc, argv, optstr)) != -1) { switch(opt) { case 'T': non_batch = true; if (!parse_num(optarg, ×tamp)) invalid(true); if (!validate_int_range(timestamp, TIMESTAMP_MIN, TIMESTAMP_MAX)) invalid(true); break; case 'K': non_batch = true; token = optarg; if (!validate_token(token)) invalid(true); break; case 'E': non_batch = true; if (guest) invalid(true); employee = true; name = optarg; if (!validate_name(name)) invalid(true); break; case 'G': non_batch = true; if (employee) invalid(true); guest = true; name = optarg; if (!validate_name(name)) invalid(true); break; case 'A': non_batch = true; if (departure) invalid(true); arrival = true; break; case 'L': non_batch = true; if (arrival) invalid(true); departure = true; break; case 'R': non_batch = true; if (!parse_num(optarg, &room)) invalid(true); if (!validate_int_range(room, ROOM_MIN, ROOM_MAX)) invalid(true); break; case 'B': if (non_batch) invalid(true); batch = true; break; default: invalid(true); break; } } if (optind >= argc) invalid(true); else filename = argv[optind]; if (filename && !validate_filename(filename)) invalid(true); if (batch && non_batch) invalid(true); if (batch) { batch_mode(filename); } else { int ret; if (!timestamp || !token || !(employee || guest) || !(arrival || departure)) invalid(true); if (employee && guest) invalid(true); l.timestamp = (uint32_t) timestamp; l.room = room; l.action = arrival ? ARRIVAL : DEPARTURE; l.type = guest ? GUEST : EMPLOYEE; l.name = strdup(name); ret = append_log_entry(&l, filename, token); free((void *)l.name); l.name = NULL; if (ret != CAPSTONE_EXIT_SUCCESS) { invalid(true); } } exit(CAPSTONE_EXIT_SUCCESS); }
int main(int argc, char* argv[]) { char* path_to_config; char* path_to_errors; int is_batch_mode; int key = 0; int list_scr = 0; struct process_list* proc_list; screen_t* screen = NULL; int screen_num = 0; int q; int paranoia_level; /* Check OS to make sure we can run. */ paranoia_level = check(); init_options(&options); options.paranoia_level = paranoia_level; path_to_config = get_path_to_config(argc, argv); path_to_errors = get_path_to_error(argc, argv); is_batch_mode = get_batch_mode(argc, argv); init_errors(is_batch_mode, path_to_errors); q = read_config(path_to_config, &options); if (q == 0) { debug_printf("Config file successfully parsed.\n"); options.config_file = 1; } else debug_printf("Could not parse config file.\n"); /* Parse command line arguments. */ parse_command_line(argc, argv, &options, &list_scr, &screen_num); /* Add default screens */ if (options.default_screen == 1) init_screen(); /* Remove unused but declared counters */ tamp_counters(); if (list_scr) { list_screens(); delete_screens(); exit(0); } if (options.spawn_pos) { /* monitor only spawned process */ int child = spawn(argv + options.spawn_pos); options.only_pid = child; options.idle = 1; } do { if (screen_num >= 0) screen = get_screen(screen_num); else screen = get_screen_by_name(argv[-screen_num]); if (!screen) { fprintf(stderr, "No such screen.\n"); exit(EXIT_FAILURE); } /* initialize the list of processes, and then run */ proc_list = init_proc_list(); if (options.spawn_pos) { options.spawn_pos = 0; /* do this only once */ new_processes(proc_list, screen, &options); start_child(); } if (options.batch) { batch_mode(proc_list, screen); key = 'q'; } #ifdef HAVE_LIBCURSES else { key = live_mode(proc_list, screen); if ((key == '+') || (key == KEY_RIGHT)) { screen_num = (screen_num + 1) % get_num_screens(); active_col = 0; done_proc_list(proc_list); free(header); } if ((key == '-') || (key == KEY_LEFT)) { int n = get_num_screens(); screen_num = (screen_num + n - 1) % n; active_col = 0; done_proc_list(proc_list); free(header); } if ((key == 'u') || (key == 'K') || (key == 'p')) { done_proc_list(proc_list); } } #endif } while (key != 'q'); /* done, free memory (makes valgrind happy) */ close_error(); delete_screens(); done_proc_list(proc_list); free_options(&options); return 0; }