/* * Routine: usage(char *param_name, char *msg) * Purpose: display a usage message, with an optional error message * Algorithm: * Data Structures: * * Params: * Returns: * Called By: * Calls: * Assumptions: * Side Effects: * TODO: None */ int usage (char *param_name, char *msg) { init_params(); fprintf (stderr, "%s Population Generator (Version %d.%d.%d%s)\n", get_str("PROG"), VERSION, RELEASE, MODIFICATION, PATCH); fprintf (stderr, "Copyright %s %s\n", COPYRIGHT, C_DATES); if (msg != NULL) printf("\nERROR: %s\n\n", msg); printf("\n\nUSAGE: %s [options]\n", get_str("PROG")); printf("\nNote: When defined in a parameter file (using -p), parmeters should\n"); printf("use the form below. Each option can also be set from the command\n"); printf("line, using a form of '%cparam [optional argument]'\n", OPTION_START); printf("Unique anchored substrings of options are also recognized, and \n"); printf("case is ignored, so '%csc' is equivalent to '%cSCALE'\n\n", OPTION_START, OPTION_START); printf("General Options\n===============\n"); print_options(options, 0); printf("\n"); printf("Advanced Options\n===============\n"); print_options(options, 1); printf("\n"); exit((msg == NULL)?0:1); }
SIM_DESC sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, char **argv) { callbacks = callback; /* Note: The simulation is not created by sim_open() because complete information is not yet available */ /* trace the call */ TRACE(trace_gdb, ("sim_open called\n")); if (root_device != NULL) sim_io_printf_filtered("Warning - re-open of simulator leaks memory\n"); root_device = psim_tree(); simulator = NULL; psim_options(root_device, argv + 1); if (ppc_trace[trace_opts]) print_options (); /* fudge our descriptor for now */ return (SIM_DESC) 1; }
int main(int argc, char **argv) { t_vm vm; vm_init(&vm); if (argc > 1) { ft_handle_args(argc, argv, &vm); } else { //ft_error("Not enough arguments"); print_options(); return(0); } ft_init_arena(&vm); ft_init_lst_proc(&vm); ft_print_header(&vm); cpu(&vm); //system("clear"); // print_t_proc(&vm); print_finish(&vm); return (0); }
/** * @brief Read in files with arrays and join them into a single file * @param argc * @param argv[] * @return */ int main (int argc, char *argv[]) { AnyOption opt; opt.setFlag ("help", 'h'); /* a flag (takes no argument), supporting long and short form */ opt.setOption ("verbose", 'v'); opt.setOption ("random", 'r'); opt.addUsage ("OA: unittest: Perform some checks on the code"); opt.addUsage ("Usage: unittest [OPTIONS]"); opt.addUsage (""); opt.addUsage (" -v --verbose Print documentation"); opt.addUsage (" -r --random Seed for random number generator"); opt.processCommandArgs (argc, argv); int verbose = opt.getIntValue ('v', 1); int random = opt.getIntValue ('r', 0); if (opt.getFlag ("help") || opt.getFlag ('h')) { opt.printUsage (); exit (0); } if (verbose) { print_copyright (); } if (verbose >= 2) { print_options (std::cout); } oaunittest (verbose, 1, random); return 0; }
/*------------------------------------------------------------------------- * Function: hrepack * * Purpose: locate all high-level HDF objects in the file * and compress/chunk them using options * * Algorythm: 2 traversals are made to the file; the 1st builds a list of * the high-level objects, the 2nd makes a copy of them, using the options; * the reason for the 1st traversal is to check for invalid object name requests * * Return: FAIL, SUCCEED * * Programmer: Pedro Vicente, [email protected] * * Date: July 10, 2003 * *------------------------------------------------------------------------- */ int hrepack_main(const char* infile, const char* outfile, options_t *options) { options->trip=0; /* also checks input */ if (print_options(options)<0) return FAIL; /* first check for objects in input that are in the file */ if (list_main(infile,outfile,options)<0) return FAIL; /* the real deal now */ options->trip=1; if (options->verbose) printf("Making new file %s...\n",outfile); /* this can fail for different reasons */ if (list_main(infile,outfile,options)<0) return FAIL; return SUCCEED; }
static void arg_help(char *arg) { printf("usage: saucy [OPTION]... FILE\n"); print_options(options); exit(0); }
//================================================================================================== int main(int argc, char **argv) { struct sigaction sigact; int chose, res; int closeFlag = 0; struct timeval; Byte handleNum; options_t options; get_options(argc, argv, &options); print_options(&options); if (DTV_Initialize(options.dev_handle) == ERR_INVALID_DEV_TYPE) { return 0; } sigact.sa_handler = sighandler; sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); sigaction(SIGQUIT, &sigact, NULL); sigaction(SIGPIPE, &sigact, NULL); fprintf(stderr, "\n========== ITEtech Linux DTV receiver control program ==========\n"); GetDriverInfo(); fprintf(stderr, "================================================================\n"); if (ChannelLock(&options) < 0) { fprintf(stderr, "Lock channel fail!\n"); } else { if (options.stat_count >= 0) { ChannelStatisticTest(&options); } else { if (options.ts_filename) { dvbout(&options); } else { dvbtraffic(&options); } } } DTV_Finalize(); return 0; }
void write_fd(register FILE *f, int r0, int c0, int rn, int cn) { register struct ent **pp; int r, c; (void) fprintf(f, "# This data file was generated by SCIM.\n"); (void) fprintf(f, "# You almost certainly shouldn't edit it.\n\n"); print_options(f); for (c = 0; c < COLFORMATS; c++) if (colformat[c]) (void) fprintf (f, "format %d = \"%s\"\n", c, colformat[c]); for (c = c0; c <= cn; c++) if (fwidth[c] != DEFWIDTH || precision[c] != DEFPREC || realfmt[c] != DEFREFMT) (void) fprintf (f, "format %s %d %d %d\n", coltoa(c), fwidth[c], precision[c], realfmt[c]); for (c = c0; c <= cn; c++) if (col_hidden[c]) (void) fprintf(f, "hide %s\n", coltoa(c)); for (r = r0; r <= rn; r++) if (row_hidden[r]) (void) fprintf(f, "hide %d\n", r); //write_ranges(f); write_marks(f); if (mdir) (void) fprintf(f, "mdir \"%s\"\n", mdir); if (autorun) (void) fprintf(f, "autorun \"%s\"\n", autorun); for (c = 0; c < FKEYS; c++) if (fkey[c]) (void) fprintf(f, "fkey %d = \"%s\"\n", c + 1, fkey[c]); write_cells(f, r0, c0, rn, cn, r0, c0); // write blocked cells for (r = r0; r <= rn; r++) { pp = ATBL(tbl, r, c0); for (c = c0; c <= cn; c++, pp++) if (*pp) { if ((*pp)->flags & is_locked) (void) fprintf(f, "lock %s%d\n", coltoa((*pp)->col), (*pp)->row); /*if ((*pp)->nrow >= 0) { (void) fprintf(f, "addnote %s ", v_name((*pp)->row, (*pp)->col)); (void) fprintf(f, "%s\n", r_name((*pp)->nrow, (*pp)->ncol, (*pp)->nlastrow, (*pp)->nlastcol)); }*/ } } /* * Don't try to combine these into a single fprintf(). v_name() has * a single buffer that is overwritten on each call, so the first part * needs to be written to the file before making the second call. */ fprintf(f, "goto %s", v_name(currow, curcol)); //fprintf(f, " %s\n", v_name(strow, stcol)); fprintf(f, "\n"); }
static void print_all_options( char *caller_name, debug_option *options) { char opt_prefix[100], *prefix_end; prefix_end = sc(opt_prefix,caller_name); prefix_end = sc(prefix_end,": "); print_options(options,opt_prefix,prefix_end); }
int main(int argc, char **argv) { if (argc < 2) { printf("Usage: ./main <function> <data> <sensitivity>\n"); return -1; } string function, data; int sensitivity; if (argc == 2) function = argv[1]; else if (argc == 3) { function = argv[1]; data = argv[2]; } else if (argc == 4) { function = argv[1]; data = argv[2]; sensitivity = atoi(argv[3]); } if (function.compare("--options") == 0) print_options(); else if (function.compare("blur") == 0) blur_image(data); else if (function.compare("videoCapture") == 0) video_capture(); else if (function.compare("cannyVideo") == 0) canny_video(); else if (function.compare("displayImage") == 0) display_image(data); else if (function.compare("videoFromFile") == 0) video_from_file(data); else if (function.compare("objectDetection") == 0) object_tracking(data, sensitivity); else if (function.compare("lucasKanade") == 0){ //Mat imgA = imread("/Users/edwinweill/Clemson/opencvData/images/blue/IMG_1604.JPG", CV_LOAD_IMAGE_GRAYSCALE); //Mat imgB = imread("/Users/edwinweill/Clemson/opencvData/images/blue/IMG_1605.jpg", CV_LOAD_IMAGE_GRAYSCALE); //namedWindow("test1",1); //namedWindow("test2",1); //imshow("test1",imgA); //imshow("test2",imgB); //cvWaitKey(0); lucas_kanade("/Users/edwinweill/Clemson/opencvData/images/blue/IMG_1604.JPG", "/Users/edwinweill/Clemson/opencvData/images/blue/IMG_1605.jpg"); } else printf("Unknown option\n"); return 0; }
static void hbh_save(const void *ip, const struct xt_entry_match *match) { const struct ip6t_opts *optinfo = (struct ip6t_opts *)match->data; if (optinfo->flags & IP6T_OPTS_LEN) { printf("%s --hbh-len %u", (optinfo->invflags & IP6T_OPTS_INV_LEN) ? " !" : "", optinfo->hdrlen); } if (optinfo->flags & IP6T_OPTS_OPTS) printf(" --hbh-opts"); print_options(optinfo->optsnr, (uint16_t *)optinfo->opts); }
int main (int argc, char **argv) { int error = 1; fence_kdump_opts_t opts; init_options (&opts); if (argc > 1) { get_options (argc, argv, &opts); } else { get_options_stdin (&opts); } openlog ("fence_kdump", LOG_CONS|LOG_PID, LOG_DAEMON); if (opts.action == FENCE_KDUMP_ACTION_OFF) { if (opts.nodename == NULL) { log_error (0, "action 'off' requires nodename\n"); exit (1); } if (get_options_node (&opts) != 0) { log_error (0, "failed to get node '%s'\n", opts.nodename); exit (1); } } if (verbose != 0) { print_options (&opts); } switch (opts.action) { case FENCE_KDUMP_ACTION_OFF: error = do_action_off (&opts); break; case FENCE_KDUMP_ACTION_METADATA: error = do_action_metadata (argv[0]); break; case FENCE_KDUMP_ACTION_MONITOR: error = do_action_monitor (); break; default: break; } free_options (&opts); return (error); }
void print_use() { print_version(); printf( "A relay tool that captures outgoing broadcast starcraft packets" EOL "and injects them to a specific host." EOL EOL "Use: sov capture_device game_creator_ip" EOL "\tcapture_device: the name of the interface to capture local starcraft packets from." EOL "\tgame_creator_ip: the host to forward packets to" EOL EOL "Arguments:" EOL); print_options(sov_arguments); }
static void print_options(MojoGuiSetupOptions *opts, int *line, int level) { if (opts != NULL) { int i; int spacing = 1; if (opts->is_group_parent) spacing += 6; else { (*line)++; printf("%2d [%c]", *line, opts->value ? 'X' : ' '); } // else for (i = 0; i < (level + spacing); i++) putchar(' '); printf("%s%s\n", opts->description, opts->is_group_parent ? ":" : ""); if ((opts->value) || (opts->is_group_parent)) print_options(opts->child, line, level+1); print_options(opts->next_sibling, line, level); } // if } // print_options
int main(int argc, char **argv) { std::cout << "Welcome to the libmxl example enter filename of db to load: "; std::string filename; getline(std::cin, filename); mxlParser p; p.parseMXL_file(filename); char c = 'y'; while(c == 'y') { std::cout << "Options are :\n1 dispaly all numbers\n2 search\n3 enter number\n4 exit saving changes\n5 exit discarding changes\n"; int op; std::cout << "enter option: "; std::string op_s; getline(std::cin, op_s); op = atoi(op_s.c_str()); switch(op) { case 1: display_all(p); break; case 2: display_find(p); break; case 3: print_options(p); break; case 4: exit_save(p); exit(EXIT_SUCCESS); break; case 5: exit(EXIT_SUCCESS); break; } } return EXIT_SUCCESS; }
static void hbh_print(const void *ip, const struct xt_entry_match *match, int numeric) { const struct ip6t_opts *optinfo = (struct ip6t_opts *)match->data; printf(" hbh"); if (optinfo->flags & IP6T_OPTS_LEN) { printf(" length"); printf(":%s", optinfo->invflags & IP6T_OPTS_INV_LEN ? "!" : ""); printf("%u", optinfo->hdrlen); } if (optinfo->flags & IP6T_OPTS_OPTS) printf(" opts"); print_options(optinfo->optsnr, (uint16_t *)optinfo->opts); if (optinfo->invflags & ~IP6T_OPTS_INV_MASK) printf(" Unknown invflags: 0x%X", optinfo->invflags & ~IP6T_OPTS_INV_MASK); }
int main(int argc,char **argv){ if(argc<2){ printf("Usage %s <options_file.ini>\n",*argv); exit(1); } sys_options options; if(ini_parse(argv[1],handler,&options)<0){ perror("Options file not found"); exit(1); } print_options(&options); return 0; }
/* Saves the union ip6t_matchinfo in parsable form to stdout. */ static void save(const struct ip6t_ip6 *ip, const struct ip6t_entry_match *match) { const struct ip6t_opts *optinfo = (struct ip6t_opts *)match->data; if (optinfo->flags & IP6T_OPTS_LEN) { printf("--" LNAME "-len %s%u ", (optinfo->invflags & IP6T_OPTS_INV_LEN) ? "! " : "", optinfo->hdrlen); } if (optinfo->flags & IP6T_OPTS_OPTS) printf("--" LNAME "-opts "); print_options(optinfo->optsnr, (u_int16_t *)optinfo->opts); if (optinfo->flags & IP6T_OPTS_NSTRICT) printf("--" LNAME "-not-strict "); }
static int MojoGui_stdio_options(MojoGuiSetupOptions *opts, boolean can_back, boolean can_fwd) { const char *inst_opts_str = xstrdup(_("Options")); const char *prompt = xstrdup(_("Choose number to change.")); int retval = -1; boolean getout = false; char buf[128]; int len = 0; while (!getout) { int line = 0; printf("\n\n"); printf("%s", inst_opts_str); printf("\n"); print_options(opts, &line, 1); printf("\n"); if ((len = readstr(prompt, buf, sizeof (buf), can_back, true)) < 0) getout = true; else if (len == 0) { getout = true; retval = 1; } // else if else { char *endptr = NULL; int target = (int) strtol(buf, &endptr, 10); if (*endptr == '\0') // complete string was a valid number? { line = 0; toggle_option(NULL, opts, &line, target); } // if } // else } // while free((void *) inst_opts_str); free((void *) prompt); return retval; } // MojoGui_stdio_options
static void help ( G_GNUC_UNUSED int argc, char **argv ) { printf ( "%s usage:\n", argv[0] ); printf ( "\t%s [-options ...]\n\n", argv[0] ); printf ( "Command line only options:\n" ); print_main_application_options (); printf ( "DMENU command line options:\n" ); print_dmenu_options (); printf ( "Global options:\n" ); print_options (); printf ( "\n" ); printf ( "For more information see: man rofi\n" ); #ifdef GIT_VERSION printf ( "Version: "GIT_VERSION "\n" ); #else printf ( "Version: "VERSION "\n" ); #endif printf ( "Bugreports: "PACKAGE_BUGREPORT "\n" ); }
int main(int argc, char **argv) { int fd; parse_args(argc, argv); print_options(); fd = open(rtcdev, O_RDONLY); if (fd == -1) { perror(rtcdev); exit(errno); } if (autotest) { auto_test(fd); goto done; } if (!strcmp(cmd, "read")) { test_read_time(fd); } else if (!strcmp(cmd, "write")) { test_set_time(fd); } else if (!strcmp(cmd, "vl")) { test_low_voltage(fd); } else if (!strcmp(cmd, "update")) { test_update(fd); } else if (!strcmp(cmd, "alarm")) { test_alarm(fd); } else if (!strcmp(cmd, "periodic")) { test_periodic(fd); } else { printf("invalid command %s\n", cmd); } goto done; done: fprintf(stderr, "\n*** Test complete ***\n"); close(fd); return 0; }
void print_msg(mc_message_t* const msg) { if (msg == 0) { printf("no response received\n"); } else { uint8_t code = mc_message_get_code(msg); printf("version: %d.\n", mc_message_get_version(msg)); printf("type: %d.\n", mc_message_get_type(msg)); printf("msgid: %d.\n", mc_message_get_message_id(msg)); print_token(msg->token); printf("category: %d.\n", mc_code_get_category(code)); printf("detail: %d.\n", mc_code_get_detail(code)); print_options(msg->options); /** @todo check content type. */ if (msg->payload) printf("%.*s\n", msg->payload->nbytes, msg->payload->bytes); } }
static void print_options( debug_option *options, char *ps, char *pe) { debug_option *op; char *npe; for (op = options; NULL != op && NULL != op->name; op++) { if (NULL == op->sub_table) { printk(KERN_ERR "%s%s - %s\n", ps,op->name,op->description); } else { npe = sc(pe,op->name); npe = sc(npe,"/"); print_options(op->sub_table,ps,npe); *pe = 0; } } }
int main(int argc, char * argv[]) { int sockfd = -1; controller_options_t opts; // Parse and apply command line options parse_options(argc, argv, &opts); print_options(&opts); DEBUG("main(): Finished parsing options...\n"); set_log_level(opts.log_level); enable_syslog("citwater-controller", 1); // Remove any previous instance. Removing arbitrary file is a bit dangerous remove_file(opts.socket_file); sockfd = init_server(opts.socket_file); if (sockfd == -1) { PERROR("main() -- init_server()"); exit(1); } if (daemon(0, 0) == -1) { PERROR("main() -- daemon()"); exit(1); } if (atlsci_init() < 0) { ERROR("main() -- atlsci_init()"); exit(1); } main_loop(sockfd); atlsci_deinit(); disable_syslog(); return 0; }
static void dst_print(const void *ip, const struct xt_entry_match *match, int numeric) { const struct ip6t_opts *optinfo = (struct ip6t_opts *)match->data; printf("dst "); if (optinfo->flags & IP6T_OPTS_LEN) printf("length:%s%u ", optinfo->invflags & IP6T_OPTS_INV_LEN ? "!" : "", optinfo->hdrlen); if (optinfo->flags & IP6T_OPTS_OPTS) printf("opts "); print_options(optinfo->optsnr, (u_int16_t *)optinfo->opts); if (optinfo->flags & IP6T_OPTS_NSTRICT) printf("not-strict "); if (optinfo->invflags & ~IP6T_OPTS_INV_MASK) printf("Unknown invflags: 0x%X ", optinfo->invflags & ~IP6T_OPTS_INV_MASK); }
/** * Main entry point. Doesn't do much except works out whether we are a client * or a server. */ int main(int argc, char *argv[]) { #ifdef WIN32 WSADATA wsaData; WORD wVersionRequested = MAKEWORD(2, 2); WSAStartup(wVersionRequested, &wsaData); #elif !defined(CONFIG_PLATFORM_SOLARIS) signal(SIGPIPE, SIG_IGN); /* ignore pipe errors */ #endif if (argc == 2 && strcmp(argv[1], "version") == 0) { printf("axssl %s %s\n", ssl_version(), __DATE__); exit(0); } if (argc < 2 || ( strcmp(argv[1], "s_server") && strcmp(argv[1], "s_client"))) print_options(argc > 1 ? argv[1] : ""); strcmp(argv[1], "s_server") ? do_client(argc, argv) : do_server(argc, argv); return 0; }
static gpointer read_user (gpointer data) { char opt; while (!exit_read) { print_options (); do { opt = getchar (); if (exit_read) { break; } } while (opt == '\n'); run_options (opt); } return NULL; }
int parse_inputs (KokkosKernels::Experiment::Parameters ¶ms, int argc, char **argv){ for ( int i = 1 ; i < argc ; ++i ) { if ( 0 == strcasecmp( argv[i] , "--threads" ) ) { params.use_threads = atoi( argv[++i] ); } else if ( 0 == strcasecmp( argv[i] , "--serial" ) ) { params.use_serial = atoi( argv[++i] ); } else if ( 0 == strcasecmp( argv[i] , "--openmp" ) ) { params.use_openmp = atoi( argv[++i] ); } else if ( 0 == strcasecmp( argv[i] , "--cuda" ) ) { params.use_cuda = 1; } else if ( 0 == strcasecmp( argv[i] , "--repeat" ) ) { params.repeat = atoi( argv[++i] ); } else if ( 0 == strcasecmp( argv[i] , "--chunksize" ) ) { params.chunk_size = atoi( argv[++i] ) ; } else if ( 0 == strcasecmp( argv[i] , "--teamsize" ) ) { params.team_size = atoi( argv[++i] ) ; } else if ( 0 == strcasecmp( argv[i] , "--vectorsize" ) ) { params.vector_size = atoi( argv[++i] ) ; } else if ( 0 == strcasecmp( argv[i] , "--amtx" ) ) { params.a_mtx_bin_file = argv[++i]; } else if ( 0 == strcasecmp( argv[i] , "--dynamic" ) ) { params.use_dynamic_scheduling = 1; } else if ( 0 == strcasecmp( argv[i] , "--verbose" ) ) { params.verbose = 1; } else if ( 0 == strcasecmp( argv[i] , "--algorithm" ) ) { ++i; if ( 0 == strcasecmp( argv[i] , "COLORING_DEFAULT" ) ) { params.algorithm = 1; } else if ( 0 == strcasecmp( argv[i] , "COLORING_SERIAL" ) ) { params.algorithm = 2; } else if ( 0 == strcasecmp( argv[i] , "COLORING_VB" ) ) { params.algorithm = 3; } else if ( 0 == strcasecmp( argv[i] , "COLORING_VBBIT" ) ) { params.algorithm = 4; } else if ( 0 == strcasecmp( argv[i] , "COLORING_VBCS" ) ) { params.algorithm = 5; } else if ( 0 == strcasecmp( argv[i] , "COLORING_EB" ) ) { params.algorithm = 6; } else { std::cerr << "2-Unrecognized command line argument #" << i << ": " << argv[i] << std::endl ; print_options(); return 1; } } else { std::cerr << "3-Unrecognized command line argument #" << i << ": " << argv[i] << std::endl ; print_options(); return 1; } } return 0; }
void CLIENT_STATE::parse_cmdline(int argc, char** argv) { int i; bool show_options = false; // NOTE: if you change or add anything, make the same chane // in show_options() (above) and in doc/client.php for (i=1; i<argc; i++) { if (0) { } else if (ARG(abort_jobs_on_exit)) { config.abort_jobs_on_exit = true; } else if (ARG(allow_multiple_clients)) { config.allow_multiple_clients = true; } else if (ARG(allow_remote_gui_rpc)) { config.allow_remote_gui_rpc = true; } else if (ARG(attach_project)) { if (i >= argc-2) { show_options = true; } else { safe_strcpy(attach_project_url, argv[++i]); safe_strcpy(attach_project_auth, argv[++i]); } } else if (ARG(check_all_logins)) { check_all_logins = true; } else if (ARG(daemon)) { executing_as_daemon = true; } else if (ARG(detach_phase_two)) { detach_console = true; } else if (ARG(detach_project)) { if (i == argc-1) show_options = true; else safe_strcpy(detach_project_url, argv[++i]); } else if (ARG(dir)) { if (i == argc-1) { show_options = true; } else { if (chdir(argv[++i])) { perror("chdir"); exit(1); } } } else if (ARG(exit_after_app_start)) { if (i == argc-1) show_options = true; else exit_after_app_start_secs = atoi(argv[++i]); } else if (ARG(exit_after_finish)) { config.exit_after_finish = true; } else if (ARG(exit_before_start)) { exit_before_start = true; } else if (ARG(exit_before_upload)) { exit_before_upload = true; } else if (ARG(exit_when_idle)) { config.exit_when_idle = true; config.report_results_immediately = true; } else if (ARG(fetch_minimal_work)) { config.fetch_minimal_work = true; } else if (ARG(file_xfer_giveup_period)) { if (i == argc-1) show_options = true; else file_xfer_giveup_period = atoi(argv[++i]); } else if (ARG(gui_rpc_port)) { if (i == argc-1) show_options = true; else cmdline_gui_rpc_port = atoi(argv[++i]); } else if (ARG(help)) { print_options(argv[0]); exit(0); } else if (ARG(insecure)) { #ifdef SANDBOX g_use_sandbox = false; #endif } else if (ARG(launched_by_manager)) { launched_by_manager = true; } else if (ARG(master_fetch_interval)) { if (i == argc-1) show_options = true; else master_fetch_interval = atoi(argv[++i]); } else if (ARG(master_fetch_period)) { if (i == argc-1) show_options = true; else master_fetch_period = atoi(argv[++i]); } else if (ARG(master_fetch_retry_cap)) { if (i == argc-1) show_options = true; else master_fetch_retry_cap = atoi(argv[++i]); } else if (ARG(no_gpus)) { config.no_gpus = true; } else if (ARG(no_gui_rpc)) { no_gui_rpc = true; } else if (ARG(no_info_fetch)) { config.no_info_fetch = true; } else if (ARG(no_priority_change)) { config.no_priority_change = true; } else if (ARG(pers_giveup)) { if (i == argc-1) show_options = true; else pers_giveup = atoi(argv[++i]); } else if (ARG(pers_retry_delay_max)) { if (i == argc-1) show_options = true; else pers_retry_delay_max = atoi(argv[++i]); } else if (ARG(pers_retry_delay_min)) { if (i == argc-1) show_options = true; else pers_retry_delay_min = atoi(argv[++i]); } else if (!strncmp(argv[i], "-psn_", strlen("-psn_"))) { // ignore -psn argument on Mac OS X } else if (ARG(redirectio)) { redirect_io = true; } else if (ARG(reset_project)) { if (i == argc-1) show_options = true; else safe_strcpy(reset_project_url, argv[++i]); } else if (ARG(retry_cap)) { if (i == argc-1) show_options = true; else retry_cap = atoi(argv[++i]); } else if (ARG(run_by_updater)) { run_by_updater = true; } else if (ARG(run_cpu_benchmarks)) { run_cpu_benchmarks = true; } else if (ARG(saver)) { started_by_screensaver = true; } else if (ARG(sched_retry_delay_max)) { if (i == argc-1) show_options = true; else sched_retry_delay_max = atoi(argv[++i]); } else if (ARG(sched_retry_delay_min)) { if (i == argc-1) show_options = true; else sched_retry_delay_min = atoi(argv[++i]); } else if (ARG(show_projects)) { show_projects = true; } else if (ARG(skip_cpu_benchmarks)) { config.skip_cpu_benchmarks = true; } else if (ARG(start_delay)) { if (i == argc-1) show_options = true; else config.start_delay = atof(argv[++i]); } else if (ARG(unsigned_apps_ok)) { config.unsigned_apps_ok = true; } else if (ARG(update_prefs)) { if (i == argc-1) show_options = true; else safe_strcpy(update_prefs_url, argv[++i]); } else if(ARG(parent_lifecycle)) { config.parent_lifecycle = true; } else if (ARG(version)) { #if (defined (__APPLE__) && (defined(__i386__) || defined(__x86_64__))) CLIENT_STATE cs; cs.detect_platforms(); printf(BOINC_VERSION_STRING " %s\n", HOSTTYPE); #else printf(BOINC_VERSION_STRING " " HOSTTYPE "\n"); #endif exit(0); } else { printf("Unknown option: %s\n", argv[i]); show_options = true; } } if (show_options) { print_options(argv[0]); exit(1); } }
int main (int argc, char **argv) { atexit(atexit_runsttysane); char log_file_name[MAX_FILENAME_LENGTH], log_file_name2[MAX_FILENAME_LENGTH+3], templog_file_name[MAX_FILENAME_LENGTH], templog_file_name2[MAX_FILENAME_LENGTH]; char clog_file_name[MAX_FILENAME_LENGTH], clog_file_name2[MAX_FILENAME_LENGTH+3]; struct cpu_heirarchy_info chi; struct cpu_socket_info socket_0={.max_cpu=0, .socket_num=0, .processor_num={-1,-1,-1,-1,-1,-1,-1,-1}}; struct cpu_socket_info socket_1={.max_cpu=0, .socket_num=1, .processor_num={-1,-1,-1,-1,-1,-1,-1,-1}}; //////////////////// GET ARGUMENTS ////////////////////// int c; //char *cvalue = NULL; //static bool logging_val_append=false, logging_val_replace=false; bool presupplied_socket_info = false; static struct option long_options[]= { {"write", required_argument, 0, 'w'}, {"socket0", required_argument,0 ,'z'}, {"socket1", required_argument,0 ,'y'}, {"logfile", required_argument,0,'l'}, {"templogfile", required_argument, 0, 'x'}, {"cstatelogfile", required_argument, 0, 'p'}, {"help", no_argument, 0, 'h'}, {"nogui", no_argument, 0, 'n'}, {"version", no_argument, 0, 'v'}, {"logtemp", no_argument, 0, 't'}, {"logcstate", no_argument, 0, 'c'}, {NULL, 0, 0, 0} }; prog_options.logging=0; //0=no logging, 1=logging, 2=appending prog_options.templogging = 0; prog_options.cstatelogging = 0; while(1) { int option_index = 0; c = getopt_long(argc, argv,"w:z:y:l:x:p:hnvtc", long_options, &option_index); if (c==-1) break; //printf("got option %c\n", c); switch(c) { case 'z': socket_0_num = atoi(optarg); presupplied_socket_info = true; printf("Socket_0 information will be about socket %d\n", socket_0.socket_num); break; case 'y': socket_1_num = atoi(optarg); presupplied_socket_info = true; printf("Socket_1 information will be about socket %d\n", socket_1.socket_num); break; case 'w': //printf("write options specified %s\n", optarg); if (strcmp("l",optarg)==0) { prog_options.logging = 1; printf("Logging is ON and set to replace\n"); } if (strcmp("a",optarg)==0) { prog_options.logging = 2; printf("Logging is ON and set to append\n"); } break; case 'l': strncpy(log_file_name, optarg, MAX_FILENAME_LENGTH-3); strcpy(log_file_name2, log_file_name); strcat(log_file_name2, "_%d"); CPU_FREQUENCY_LOGGING_FILE_single = log_file_name; CPU_FREQUENCY_LOGGING_FILE_dual = log_file_name2; printf("Logging frequencies to %s for single sockets, %s for dual sockets(0,1 for multiple sockets)\n", CPU_FREQUENCY_LOGGING_FILE_single, CPU_FREQUENCY_LOGGING_FILE_dual); break; case 'p': strncpy(clog_file_name, optarg, MAX_FILENAME_LENGTH-3); strcpy(clog_file_name2, clog_file_name); strcat(clog_file_name2, "_%d"); CSTATE_LOGGING_FILE_single = clog_file_name; CSTATE_LOGGING_FILE_dual = clog_file_name2; prog_options.cstatelogging = 1; break; case 'c': prog_options.cstatelogging = 1; break; case 'x': strncpy(templog_file_name, optarg, MAX_FILENAME_LENGTH-3); strcpy(templog_file_name2, templog_file_name); strcat(templog_file_name2, "_%d"); TEMP_LOGGING_FILE_single = templog_file_name; TEMP_LOGGING_FILE_dual = templog_file_name2; prog_options.templogging = 1; break; case 't': prog_options.templogging = 1; //print_options(prog_options); break; case 'n': use_ncurses = false; printf("Not Spawning the GUI\n"); break; case 'h': printf("\ni7z Tool Supports the following functions:\n"); printf("Append to a log file (freq is always logged when logging is enabled): "); printf("%c[%d;%d;%dm./i7z --write a ", 0x1B,1,31,40); printf("%c[%dm[OR] ",0x1B,0); printf("%c[%d;%d;%dm./i7z -w a\n", 0x1B,1,31,40); printf("%c[%dm",0x1B,0); printf("Replacement instead of Append: "); printf("%c[%d;%d;%dm./i7z --write l ", 0x1B,1,31,40); printf("%c[%dm[OR]", 0x1B,0); printf(" %c[%d;%d;%dm./i7z -w l\n", 0x1B,1,31,40); printf("%c[%dm",0x1B,0); printf("(Enabling) Log the temperature (also needs the -w l or -w a option): "); printf("%c[%d;%d;%dm./i7z --logtemp ", 0x1B,1,31,40); printf("%c[%dm[OR]", 0x1B,0); printf(" %c[%d;%d;%dm./i7z -t\n", 0x1B,1,31,40); printf("%c[%dm",0x1B,0); printf("(Enabling) Log the C-states (also needs the -w l or -w a option): "); printf("%c[%d;%d;%dm./i7z --logcstate ", 0x1B,1,31,40); printf("%c[%dm[OR]", 0x1B,0); printf(" %c[%d;%d;%dm./i7z -c\n", 0x1B,1,31,40); printf("%c[%dm",0x1B,0); printf("Specifying a particular socket to print: %c[%d;%d;%dm./i7z --socket0 X \n", 0x1B,1,31,40); printf("%c[%dm",0x1B,0); printf("In order to print to a second socket use: %c[%d;%d;%dm./i7z --socket1 X \n", 0x1B,1,31,40); printf("%c[%dm",0x1B,0); printf("To turn the ncurses GUI off use: %c[%d;%d;%dm./i7z --nogui\n", 0x1B, 1, 31, 40); printf("%c[%dm",0x1B,0); printf("\nLOGGING DEFAULTS:\n(ENABLED by default when logging is enable) Default (freq) log file name is %s (single socket) or %s (dual socket)\n", CPU_FREQUENCY_LOGGING_FILE_single, CPU_FREQUENCY_LOGGING_FILE_dual); printf("(DISABLED by default) Default temp log file name is %s (single socket) or %s (dual socket)\n", TEMP_LOGGING_FILE_single, TEMP_LOGGING_FILE_dual); printf("(DISABLED by default) Default cstate log file name is %s (single socket) or %s (dual socket)\n\n", CSTATE_LOGGING_FILE_single, CSTATE_LOGGING_FILE_dual); printf("Specifying a different log file (freq): "); printf("%c[%d;%d;%dm./i7z --logfile filename ", 0x1B,1,31,40); printf("%c[%dm[OR] ", 0x1B,0); printf("%c[%d;%d;%dm./i7z -l filename\n", 0x1B,1,31,40); printf("%c[%dm",0x1B,0); printf("Specifying a different temperature log file: "); printf("%c[%d;%d;%dm./i7z --templogfile filename ", 0x1B,1,31,40); printf("%c[%dm[OR] ", 0x1B,0); printf("%c[%d;%d;%dm./i7z -x filename\n", 0x1B,1,31,40); printf("%c[%dm",0x1B,0); printf("Specifying a different cstate log file: "); printf("%c[%d;%d;%dm./i7z --cstatelogfile filename ", 0x1B,1,31,40); printf("%c[%dm[OR] ", 0x1B,0); printf("%c[%d;%d;%dm./i7z -p filename\n", 0x1B,1,31,40); printf("%c[%dm",0x1B,0); printf("Example: To print for two sockets and also change the log file %c[%d;%d;%dm./i7z --socket0 0 --socket1 1 -logfile /tmp/logfilei7z -w l\n", 0x1B, 1, 31, 40); printf("%c[%dm",0x1B,0); exit(1); case 'v': printf("Version: Nov-16-2012\n"); exit(1); default: printf("no such option"); exit(1); } } if(prog_options.templogging) { printf("Logging temperature to %s for single sockets, %s for dual sockets(0,1 for multiple sockets)\n", TEMP_LOGGING_FILE_single, TEMP_LOGGING_FILE_dual); } if(prog_options.cstatelogging) { printf("Logging cstates to %s for single sockets, %s for dual sockets(0,1 for multiple sockets)\n", CSTATE_LOGGING_FILE_single, CSTATE_LOGGING_FILE_dual); } Print_Version_Information(); Print_Information_Processor (&prog_options.i7_version.nehalem, &prog_options.i7_version.sandy_bridge); // printf("nehalem %d, sandy brdige %d\n", prog_options.i7_version.nehalem, prog_options.i7_version.sandy_bridge); Test_Or_Make_MSR_DEVICE_FILES (); modprobing_msr(); /* prog_options.logging = 0; if (logging_val_replace){ prog_options.logging = 1; printf("Logging is ON and set to replace\n"); } if (logging_val_append){ prog_options.logging = 2; printf("Logging is ON and set to append\n"); } */ /* while( (c=getopt(argc,argv,"w:")) !=-1){ cvalue = optarg; //printf("argument %c\n",c); if(cvalue == NULL){ printf("With -w option, requires an argument for append or logging\n"); exit(1); }else{ //printf(" %s\n",cvalue); if(strcmp(cvalue,"a")==0){ printf("Appending frequencies to %s (single_socket) or cpu_freq_log_dual_(%d/%d).txt (dual socket)\n", CPU_FREQUENCY_LOGGING_FILE_single,0,1); prog_options.logging=2; }else if(strcmp(cvalue,"l")==0){ printf("Logging frequencies to %s (single socket) or cpu_freq_log_dual_(%d/%d).txt (dual socket) \n", CPU_FREQUENCY_LOGGING_FILE_single,0,1); prog_options.logging=1; }else{ printf("Unknown Option, ignoring -w option.\n"); prog_options.logging=0; } sleep(3); } } */ /////////////////////////////////////////////////////////// construct_CPU_Heirarchy_info(&chi); construct_sibling_list(&chi); print_CPU_Heirarchy(chi); construct_socket_information(&chi, &socket_0, &socket_1, socket_0_num, socket_1_num); print_socket_information(&socket_0); print_socket_information(&socket_1); if (!use_ncurses){ printf("GUI has been Turned OFF\n"); print_options(prog_options); } else { printf("GUI has been Turned ON\n"); print_options(prog_options); /* if (prog_options.logging ==0) { printf("Logging is OFF\n"); } else { printf("Logging is ON\n"); if (prog_options.cstatelogging) { printf("Cstate logging is enabled\n"); } if (prog_options.templogging) { printf("temp logging is enabled\n"); } } */ } if (!presupplied_socket_info){ if (socket_0.max_cpu>0 && socket_1.max_cpu>0) { //Path for Dual Socket Code printf("i7z DEBUG: Dual Socket Detected\n"); //Dual_Socket(&prog_options); Dual_Socket(); } else { //Path for Single Socket Code printf("i7z DEBUG: Single Socket Detected\n"); //Single_Socket(&prog_options); Single_Socket(); } } else { Dual_Socket(); } return(1); }