예제 #1
0
int main(int argc, char *argv[]) {

    gengetopt_args_info args;
    if( cmdline_parser( argc, argv, &args ) != 0 ){
        exit(1);
    }

    QApplication a(argc, argv);
    MainWindow w;
    if( args.no_gui_arg > 0  ) {
        w.hide();
        QString config_filename(args.config_arg);
        QString paths_filename(args.paths_arg);
        QString log_filename(args.log_arg);
        QString weight_filename(args.weight_arg);
        std::cout << "loading " << config_filename.toStdString() << std::endl;
        if(w.planPath(config_filename, paths_filename, weight_filename, log_filename )) {
            std::cout << "dumping weight to " << weight_filename.toStdString() << std::endl;
            std::cout << "saving to " << paths_filename.toStdString() << std::endl;
            std::cout << "logging to " << log_filename.toStdString() << std::endl;
        }
        return 0;
    }

    w.show();
    return a.exec();
}
int model_controller::init_internal_structures (int argc, char *argv[])
{
  if (cmdline_parser (argc, argv, &cmd_param) != 0)
    return -1;

  return 0;
}
예제 #3
0
int main (int argc, char **argv)
{
	struct gengetopt_args_info opts;
	struct vfi_source *s;
	struct vfi_dev *dev;

	vfi_open(&dev,NULL,opts.timeout_arg);

	cmdline_parser_init(&opts);

	cmdline_parser(argc,argv,&opts);

	if (opts.file_given) {
		vfi_setup_file(dev,&s,fopen(opts.file_arg,"r"));
		process_commands(dev,s,&opts);
	}

	if (opts.inputs_num) {
		setup_inputs(dev,&s,&opts);
		process_commands(dev,s,&opts);
	}

	if (opts.interactive_given) {
		vfi_setup_file(dev,&s,stdin);
		process_commands(dev,s,&opts);
	}

	vfi_close(dev);

	return 0;
}
예제 #4
0
static int ParseOptions(int argc, char ** argv, struct gengetopt_args_info * ai, Options * options)
{
    int result = EXIT_SUCCESS;
    if (cmdline_parser(argc, argv, ai) == 0)
    {
        options->IPAddress = ai->ip_arg;
        options->InterfaceName = ai->interface_arg;
        options->AddressFamily = ai->addressFamily_arg == 4 ? AF_INET : AF_INET6;
        options->CoapPort = ai->port_arg;
        options->IpcPort = ai->ipcPort_arg;
        options->ContentType = ai->contentType_arg;
        options->Secure = ai->secure_flag;
        int i;
        for (i = 0; i < ai->objDefs_given; ++i)
        {
            options->ObjDefsFiles[i] = ai->objDefs_arg[i];
        }
        options->NumObjDefsFiles = ai->objDefs_given;
        options->Daemonise = ai->daemonize_flag;
        options->Verbose = ai->verbose_flag;
        options->LogFile = ai->logFile_arg;
        options->Version = ai->version_flag;

        if (options->Secure && strcmp(DTLS_LibraryName, "None") == 0)
        {
            printf("Error: not built with DTLS support\n\n");
            result = EXIT_FAILURE;
        }
    }
    else
    {
        result = EXIT_FAILURE;
    }
    return result;
}
예제 #5
0
파일: main.cpp 프로젝트: 0-T-0/openthread
int main(int argc, char *argv[])
{
    uint32_t atomic_state;

    if (cmdline_parser(argc, argv, &args_info) != 0)
    {
        exit(1);
    }

    hwAlarmInit();
    hwRadioInit();
    hwRandomInit();

    otInit();
    sCliServer.Start();

    while (1)
    {
        otProcessNextTasklet();

        atomic_state = otPlatAtomicBegin();

        if (!otAreTaskletsPending())
        {
            hwSleep();
        }

        otPlatAtomicEnd(atomic_state);
    }

    return 0;
}
예제 #6
0
int main(int argc, char **argv) {
        static struct gengetopt_args_info args_info;
        assert(cmdline_parser(argc, argv, &args_info) == 0);
        char* pattern = args_info.pattern_orig;
        char* text = read_text(args_info.text_arg);
        uint32_t n = strlen(text);
        uint32_t m = strlen(pattern);
        /* occ[] stores if a position is an occurrence */
        uint32_t* occ = calloc(n, sizeof(*occ));
        assert(occ != NULL);

        /* Initialize random number generator */
        gsl_rng *rng = gsl_rng_alloc(gsl_rng_mt19937);
        uint32_t num_rounds = (size_t) args_info.rounds_arg;
        for (size_t i = 0; i < num_rounds; i++) {
                uint32_t mod = random_prime(rng);
                for (size_t j = 0; j < m; j++)
                        for (size_t c = 0; c < 4; c++)
                                corrections[c] = (j == 0) ? c : (corrections[c] << 2) % mod;
                uint32_t pattern_h = init_h(pattern, m, mod);
                uint32_t pos = m;
                for (uint32_t text_h = init_h(text, m, mod); pos < n;
                     text_h = next_h(text_h, text[pos - m], text[pos], mod), pos++)
                        if (pattern_h == text_h)
                                occ[pos - m]++;
        }
        for (uint32_t pos = 0; pos < n; pos++)
                if (occ[pos] >= num_rounds) {
                        char* x = strndupa(text + pos, m);
                        printf("Occurrence %s at position %d\n", x, pos);
                }
        free(occ);
}
예제 #7
0
int main(int argc, char *argv[]) {
    gengetopt_args_info ai;
    if (cmdline_parser(argc, argv, &ai) != 0) {
        exit(1);
    }

    std::cout << ai.filename_arg << std::endl;

    if (ai.size_given) {
        std::cout << ai.size_arg[0] << " "
        << ai.size_arg[1] << " "
        << ai.size_arg[2] << std::endl;
    }

    for (int i = 0; i < ai.array_given; ++i) {
        std::cout << ai.array_arg[i] << " ";
    }
    std::cout << std::endl;

    if (ai.long_option_given) {
        std::cout << ai.long_option_arg << std::endl;
    }

    std::cout << ai.default_value_arg << std::endl;
    std::cout << ai.console_flag << std::endl;

    return 0;
}
예제 #8
0
파일: main.c 프로젝트: ivohof/Barriers
static int decode_switches (int argc, char **argv)
{
    int i;

    if (cmdline_parser (argc, argv, &args_info) != 0)
        exit(1) ;
    if (args_info.help_given) cmdline_parser_print_help();
    if (args_info.full_help_given) cmdline_parser_print_full_help();

    opt.max_print = args_info.max_arg;
    opt.minh = args_info.minh_arg;
    opt.poset = args_info.poset_arg;
    opt.want_quiet = args_info.quiet_given;
    opt.want_verbose = args_info.verbose_given;
    opt.bsize = args_info.bsize_given;
    opt.ssize = args_info.ssize_given;
    opt.print_saddles = args_info.saddle_given;
    opt.rates = args_info.rates_given;
    opt.microrates = args_info.microrates_given;
    GRAPH = args_info.graph_arg;
    if (args_info.moves_given) opt.MOVESET = args_info.moves_arg;
    if (args_info.temp_given) opt.kT = args_info.temp_arg;
    for (i = 0; i < args_info.path_given; ++i) {
        int L1,L2;
        if (sscanf(args_info.path_arg[i], "%d=%d", &L1, &L2) != 2)
            nrerror("specifiy paths as e.g.  -P 1=3");
    }
    if (args_info.inputs_num>1)
        nrerror("only one input file allowed");

    return 0;
}
예제 #9
0
int main(int argc, char *argv[])
{
	atexit( gengetopt_free );

	if( cmdline_parser(argc, argv, &args_info) != 0 ) {
		return 2; // exit
	}

	check_display_args();
	gengetopt_check_opts();

	TwsXml::setSkipDefaults( !skipdefp );
	if( !durationStrp ) {
		durationStrp = max_durationStr( barSizeSettingp );
	}
	split_whatToShow();
	set_includeExpired();

	if( histjobp ) {
		if( !gen_hist_job() ) {
			return 1;
		}
	} else if( to_csvp ) {
		if( !gen_csv() ) {
			return 1;
		}
	} else {
		fprintf( stderr, "error, nothing to do, use -H or -C.\n" );
		return 2;
	}

	return 0;
}
예제 #10
0
int main( unsigned int argc, char * const argv[])
{
  int ulFlag = ID3TT_ID3;
  ID3D_INIT_DOUT();
  gengetopt_args_info args;

  if (cmdline_parser(argc, argv, &args) != 0)
  {
    exit(1);
  }

#if defined ID3_ENABLE_DEBUG
  if (args.warning_flag)
  {
    ID3D_INIT_WARNING();
    ID3D_WARNING ( "warnings turned on" );
  }
  if (args.notice_flag)
  {
    ID3D_INIT_NOTICE();
    ID3D_NOTICE ( "notices turned on" );
  }
#endif

  if (args.v1tag_flag)
  {
    ulFlag = ID3TT_ID3V1;
  }

  if (args.v2tag_flag)
  {
    ulFlag = ID3TT_ID3V2;
  }
  

  if (args.inputs_num != 2)
  {
    cerr << "Usage: id3cp [OPTIONS] SOURCE DEST" << endl;
    exit(1);
  }

  const char *source = args.inputs[0], *dest = args.inputs[1];
  
  ID3_Tag myTag;
  
  cout << "Parsing " << source << ": ";
  
  myTag.Clear();
  myTag.Link(source, ID3TT_ALL);
  
  cout << "done.  Copying to " << dest << ": ";
  
  myTag.Link(dest, ID3TT_NONE);
  myTag.Update(ulFlag);
  
  cout << "done" << endl;
  
  return 0;
}
예제 #11
0
int main(int argc, char **argv) {
    sxc_client_t *sx;
    sxc_logger_t log;
    struct gengetopt_args_info args;
    char file[1024];
    const char *filter_dir;

    if(cmdline_parser(argc, argv, &args))
	return 1;

    if(args.version_given) {
	printf("%s %s\n", CMDLINE_PARSER_PACKAGE, SRC_VERSION);
	cmdline_parser_free(&args);
	return 0;
    }

    if(args.output_given)
        snprintf(file, sizeof(file), "%s", args.output_arg);
    else
	snprintf(file, sizeof(file), "sxreport-client-%ld.log", (long)time(NULL));

    umask(077);
    if(!(sx = sxc_init(SRC_VERSION, sxc_file_logger(&log, argv[0], file, 1), NULL, NULL))) {
	cmdline_parser_free(&args);
	return 1;
    }
    if(args.config_dir_given && sxc_set_confdir(sx, args.config_dir_arg)) {
        cmdline_parser_free(&args);
        sxc_shutdown(sx, 0);
        return 1;
    }
    sxc_set_verbose(sx, 1);

    filter_dir = get_filter_dir(sx, args.filter_dir_arg);
    if(sxc_filter_loadall(sx, filter_dir)) {
        cmdline_parser_free(&args);
        sxc_shutdown(sx, 0);
        return 1;
    }
    sxi_report_build_info(sx);
#define INFO_PKGCONFIG ""
#define INFO_PKGCONFIG_LIBDIR ""
#define INFO_PKGCONFIG_PATH ""
    sxi_report_build_flags(sx);
    sxi_report_library_versions(sx, SRC_VERSION);
    sxi_report_system_info(sx);
    sxi_report_limits(sx);
    sxi_report_section(sx, "Filters");
    sxi_info(sx,"Default filter directory: %s\n", SX_FILTER_DIR);
    sxi_info(sx,"Current filter directory: %s\n", filter_dir);
    filter_list(sx);
    sxi_report_configuration(sx, args.config_dir_arg);
    printf("Report stored in %s\n", file);
    printf("You can attach it to a bugreport at %s\n", PACKAGE_BUGREPORT);
    cmdline_parser_free(&args);
    sxc_shutdown(sx, 0);
    return 0;
}
예제 #12
0
파일: strptime.c 프로젝트: vicgc/dateutils
int
main(int argc, char *argv[])
{
	static char dflt_fmt[] = "%Y-%m-%d\n\0H:%M:%S %Z\n";
	struct gengetopt_args_info argi[1];
	char *outfmt = dflt_fmt;
	char **infmt;
	size_t ninfmt;
	char **input;
	size_t ninput;
	int quietp;
	int res = 0;

	if (cmdline_parser(argc, argv, argi)) {
		res = 1;
		goto out;
	}

	if (argi->format_given) {
		outfmt = argi->format_arg;
		/* unescape sequences, maybe */
		if (argi->backslash_escapes_given) {
			dt_io_unescape(outfmt);
		}
	} else if (argi->time_given) {
		outfmt[8] = ' ';
		outfmt[9] = '%';
	}

	if (!argi->input_format_given) {
		infmt = argi->inputs;
		ninfmt = argi->inputs_num;
		input = NULL;
		ninput = 0;
	} else {
		infmt = argi->input_format_arg;
		ninfmt = argi->input_format_given;
		input = argi->inputs;
		ninput = argi->inputs_num;
	}
	/* get quiet predicate */
	quietp = argi->quiet_given;

	/* get lines one by one, apply format string and print date/time */
	if (ninput == 0) {
		/* read from stdin */
		proc_lines((const char*const*)infmt, ninfmt, outfmt, quietp);
	} else {
		const char *const *cinfmt = (const char*const*)infmt;
		for (size_t i = 0; i < ninput; i++) {
			proc_line(input[i], cinfmt, ninfmt, outfmt, quietp);
		}
	}

out:
	cmdline_parser_free(argi);
	return res;
}
예제 #13
0
static int ParseOptions(int argc, char ** argv, struct gengetopt_args_info * ai, Options * options)
{
    int result = EXIT_SUCCESS;
    if (cmdline_parser(argc, argv, ai) == 0)
    {
        options->CoapPort = ai->port_arg;
        options->AddressFamily = ai->addressFamily_arg == 4 ? AF_INET : AF_INET6;
        options->IpcPort = ai->ipcPort_arg;
        options->EndPointName = ai->endPointName_arg;
        if (ai->bootstrap_given)
            options->BootStrap = ai->bootstrap_arg;

        if (ai->pskIdentity_given)
            options->PskIdentity = ai->pskIdentity_arg;
        if (ai->pskKey_given)
            options->PskKey = ai->pskKey_arg;

        if (ai->certificate_given)
            options->CertificateFile = ai->certificate_arg;

        if (ai->factoryBootstrap_given)
            options->FactoryBootstrapFile = ai->factoryBootstrap_arg;
        int i;
        for (i = 0; i < ai->objDefs_given; ++i)
        {
            options->ObjDefsFiles[i] = ai->objDefs_arg[i];
        }
        if (ai->defaultContentType_given)
        {
            options->DefaultContentType = (AwaContentType)ai->defaultContentType_arg;
        }
        options->NumObjDefsFiles = ai->objDefs_given;
        options->Daemonise = ai->daemonize_flag;
        options->Verbose = ai->verbose_flag;
        options->LogFile = ai->logFile_arg;
        options->Version = ai->version_flag;

        // Check to see if at least one bootstrap option is specified
        if (!options->Version && (options->BootStrap == NULL) && (options->FactoryBootstrapFile == NULL))
        {
            printf("Error: specify a bootstrap option (--bootstrap or --factoryBootstrap) or --version\n\n");
            result = EXIT_FAILURE;
        }
    }
    else
    {
        result = EXIT_FAILURE;
    }
    return result;
}
예제 #14
0
파일: syms.c 프로젝트: rrthomas/syms
int
main(int argc, char *argv[])
{
  setlocale(LC_ALL, "");

  // Process command-line options
  if (cmdline_parser(argc, argv, &args_info) != 0)
    exit(EXIT_FAILURE);
  if (args_info.help_given)
    cmdline_parser_print_help();
  if (args_info.version_given)
    cmdline_parser_print_version();

  // Compile regex
  regex_t re;
  int err = regcomp(&re, args_info.symbol_arg, REG_EXTENDED);
  if (err != 0) {
    size_t errlen = regerror(err, &re, NULL, 0);
    char *errbuf = xmalloc(errlen);
    regerror(err, &re, errbuf, errlen);
    error(EXIT_FAILURE, errno, "%s", errbuf);
  }

  // Process input
  for (unsigned i = 0; i <= args_info.inputs_num; i++) {
    if (i < args_info.inputs_num && strcmp(args_info.inputs[i], "-") != 0) {
      if (!freopen(args_info.inputs[i], "r", stdin))
        error(EXIT_FAILURE, errno, "cannot open %s", quote(args_info.inputs[i]));
    }
    size_t len;
    for (char *line = NULL; getline(&line, &len, stdin) != -1; line = NULL) {
      char *symbol = NULL, *p = line;
      for (char *end; (symbol = get_symbol(&re, p, &end)); p = end) {
        // Temporarily insert a NUL to make the symbol a string
        char c = *end;
        *end = '\0';
        printf("%s\n", symbol);
        *end = c; // Restore the overwritten character
      }
      free(line);
    }
    fclose(stdin);
    if (i < (unsigned)args_info.inputs_num - 1)
      putchar('\n');
  }

  return EXIT_SUCCESS;
}
예제 #15
0
파일: cvc-print.c 프로젝트: d0/openpace
int main(int argc, char *argv[])
{
    int fail = 1;
    unsigned char *cvc_data = NULL, *desc_data = NULL, *csr_data = NULL;
    size_t cvc_len = 0, desc_len = 0, csr_len = 0;
    struct gengetopt_args_info cmdline;

    /* Parse command line */
    if (cmdline_parser (argc, argv, &cmdline) != 0) {
        return fail;
    }

    if (cmdline.cvc_arg) {
        fail = read_file(cmdline.cvc_arg, &cvc_data, &cvc_len);
        if (fail) {
            fprintf(stderr, "failed to read %s\n", cmdline.cvc_arg);
            goto err;
        }
    }

    if (cmdline.description_arg) {
        fail = read_file(cmdline.description_arg, &desc_data, &desc_len);
        if (fail) {
            fprintf(stderr, "failed to read %s\n", cmdline.description_arg);
            goto err;
        }
    }

    if (cmdline.csr_arg) {
        fail = read_file(cmdline.csr_arg, &csr_data, &csr_len);
        if (fail) {
            fprintf(stderr, "failed to read %s\n", cmdline.csr_arg);
            goto err;
        }
    }

    EAC_init();
    fail = print_cvc(cvc_data, cvc_len, desc_data, desc_len, csr_data, csr_len);

err:
    cmdline_parser_free (&cmdline);
    free(cvc_data);
    free(desc_data);
    EAC_cleanup();

    return fail;
}
예제 #16
0
/**! Constructor
  Constructs a mediator object with a CCompositeFilter
  as the default filter. We also set up the proper 
  skip and processing counts that user supplied.

  \throw can throw a CFatalException

*/
CFilterMain::CFilterMain(int argc, char** argv)
  : m_mediator(0),
  m_argsInfo(new gengetopt_args_info)
{
  cmdline_parser(argc,argv,m_argsInfo);  

  try {

    if (m_argsInfo->oneshot_given) {
      m_mediator = new COneShotMediator(0,new CCompositeFilter,0,
          m_argsInfo->number_of_sources_arg); 
    } else {
      m_mediator = new CInfiniteMediator(0,new CCompositeFilter,0);
    } 
    // Set up the data source 
    CDataSource* source = constructDataSource(); 
    m_mediator->setDataSource(source);

    // Set up the sink source 
    CDataSink* sink = constructDataSink(); 
    m_mediator->setDataSink(sink);

    // set up the skip and count args
    if (m_argsInfo->skip_given) {
      m_mediator->setSkipCount(m_argsInfo->skip_arg);
    }  

    if (m_argsInfo->count_given) {
      m_mediator->setProcessCount(m_argsInfo->count_arg);
    }  



  } catch (CException& exc) {
    std::cout << exc.ReasonText() << std::endl;
    std::cout << exc.WasDoing() << std::endl;
    throw CFatalException();
  }
  catch (std::exception& e) {
    std::cout << e.what() << std::endl;
    throw CFatalException();
  }
  catch (...) {
    std::cout << "Unanticipated exception type\n";
    throw CFatalException();
  }
}
예제 #17
0
void handle_lispd_command_line(int argc, char **argv)
{
    struct gengetopt_args_info args_info;

    if (cmdline_parser(argc, argv, &args_info) != 0) 
        exit(EXIT_FAILURE);

    if (args_info.nodaemonize_given) {
        daemonize = 0;
    }
    if (args_info.config_file_given) {
        config_file = strdup(args_info.config_file_arg);
    }
    if (args_info.map_request_retries_given) {
        map_request_retries = args_info.map_request_retries_arg;
    }
}
예제 #18
0
/*
 * init the gengetopt stuff
 */
char *cliInit(int argc, char **argv)
{
	char *devicename;

    cmdline_parser (argc, argv, &gCmdLine);
    if(argc==1) // nothing on cmdline
    {
    		cmdline_parser_print_help();
    		exit(1);
    }
    // extra command line arg for test settings
    lxDummyArg = argv[optind]; // this is the remaining argv

    // generic flags
    if (gCmdLine.verbose_given) {
    	cli_verbose= 1;
    	lxScribo_verbose      =  (1 & gCmdLine.verbose_arg)!=0;
    	socket_verbose 		  =  (2 & gCmdLine.verbose_arg)!=0;
    	i2cserver_verbose     =  (4 & gCmdLine.verbose_arg)!=0;
    	gTfaRun_timingVerbose =  (8 & gCmdLine.verbose_arg)!=0;
    }
    //lxScribo_verbose=
    tfa98xx_verbose = cli_verbose;
    tfa98xx_quiet = gCmdLine.quiet_given;
    cli_trace=gCmdLine.trace_given;
//    tfa98xx_trace = cli_trace;
#ifndef WIN32
    i2c_trace = cli_verbose;
#endif
    NXP_I2C_verbose= cli_trace;
    cli_quiet=gCmdLine.quiet_given;

    if (gCmdLine.device_given)
    	devicename=gCmdLine.device_arg;
    else
#ifdef TFA_I2CDEVICE
    	devicename=TFA_I2CDEVICE;
#else
    	devicename=DEVNAME;
#endif
    return devicename;

}
예제 #19
0
int main()
{
	pid_t child_id, pid;
	int status = 0, i = 0;
	
	while(1)
	{
		char** parsed = cmdline_parser();
		
		if((strlen(parsed[0]) != 0)) 
			if ((child_id = fork()) == -1)
				perror("fork error");
			else if (child_id == 0) 
			{
				execv(parsed[0], parsed);
				fprintf(stderr, "'%s' :  %s \n", parsed[0], strerror(errno));
			}
			else
				while(1)	// wait child process to finish
					if ((pid = waitpid(child_id, &status, 1)) == -1)
					{
						perror("waitpid error");
						break;
					}
					else if (pid == 0) 
						sleep(1);
					else if (pid == child_id) 
						break;
		else
		{
			free(parsed[0]);
			return 0;
		}

		while(i <= custom_argc)
			free(parsed[(i = i + 1) - 1]);			
		
		i = 0;
		free(parsed);
	}
	
	return 0;
}
예제 #20
0
파일: main.c 프로젝트: nikicat/eenvoudig
int main(int argc, char* argv[])
{
    printf("Hello world from %s!\n", PACKAGE_STRING);
    struct gengetopt_args_info args;
    int res = cmdline_parser(argc, argv, &args_info);
    if (res != 0)
        exit(EXIT_FAILURE);

    printf("listening on %s:%hu\n", args.listen_address_arg, args.listen_port_arg);

    int server_sock;
    if (start_server(&args, &server_sock) != 0)
        err(EXIT_FAILURE, "Could not start server");

    pthread_t workers[args.worker_count_arg];
    start_worker_threads(&args_info, workers, args.worker_count_arg);

    join_worker_threads(workers, args.worker_count_args);

    return 0;
}
예제 #21
0
파일: globals.c 프로젝트: marcelTBI/treekin
/*==============================*/
void
parse_commandline(int argc, char **argv)
{
  ini_globs();
  if (cmdline_parser (argc, argv, &args_info) != 0) {
    fprintf(stderr, "error while parsing command-line options\n");
    exit(EXIT_FAILURE);
  }

  //input file:
  if (args_info.inputs_num) {
    char *infile=NULL;
    to_basename(args_info.inputs[0]);
    infile = (char *)calloc(strlen(opt.basename)+5, sizeof(char));
    strncpy(infile, opt.basename, strlen(opt.basename));
    if (opt.method == 'F') strcat(infile, ".sub");
    else strcat(infile, ".bar");
    opt.INFILE = fopen(infile, "r");
    if (opt.INFILE == NULL) {
      fprintf(stderr, "Error opening input file \"%s\".\n", infile);
      free(infile);
      exit(EXIT_FAILURE);
    }
    free(infile);
  } else {
    opt.INFILE = stdin;
  }

  // rate file?
  if (args_info.ratesfile_given) {
    opt.RATFILE = fopen(args_info.ratesfile_arg, "r");
    if (opt.RATFILE == NULL) {
      if (!opt.quiet) fprintf(stderr, "Cannot open rate file %s!\n", args_info.ratesfile_arg);
    }
  } else {
    opt.RATFILE = NULL;
  }

  set_parameters();
}
예제 #22
0
int
main (int argc, char *argv[])
{
  struct gengetopt_args_info args_info;
  int rc;

  set_program_name (argv[0]);

  if (cmdline_parser (argc, argv, &args_info) != 0)
    return EXIT_FAILURE;

  rc = pskc_global_init ();
  if (rc != PSKC_OK)
    error (EXIT_FAILURE, 0, "libpskc initialization failed: %s",
	   pskc_strerror (rc));

  if (args_info.debug_flag)
    pskc_global_log (debuglog);

  if (args_info.version_given)
    version ();
  else if (args_info.validate_flag)
    validate (&args_info);
  else if (args_info.sign_flag)
    sign (&args_info);
  else if (args_info.verify_flag)
    verify (&args_info);
  else if (args_info.info_flag)
    info (&args_info);
  else
    {
      cmdline_parser_print_help ();
      emit_bug_reporting_address ();
    }

  pskc_global_done ();

  return EXIT_SUCCESS;
}
예제 #23
0
int
main(int argc, char **argv)
{
	struct gengetopt_args_info cmdline;

	if (cmdline_parser(argc, argv, &cmdline) != 0)
		return 1;

	const char *module_path = cmdline.module_arg;
	if (!cmdline.module_given)
		module_path = default_pkcs11_provider;
#ifdef _WIN32
	DWORD expanded_len;
	char module_path_expanded[PATH_MAX], default_expanded[PATH_MAX], onepin_expanded[PATH_MAX];
	expand(module_path, module_path_expanded, expanded_len);
	expand(default_pkcs11_provider, default_expanded, expanded_len);
	expand(default_onepin_pkcs11_provider, onepin_expanded, expanded_len);
#endif

	const char *module_name = get_module_name(module_path);
	if (!module_name) {
		fprintf(stderr, "Could not load initialize %s\n", module_path);
		return 1;
	}

	if (!cmdline.skip_chrome_flag)
		add_module_chrome(module_path, module_name);
	if (!cmdline.skip_firefox_flag)
		add_module_firefox(module_path, module_name);
	if (!cmdline.skip_thunderbird_flag)
		add_module_thunderbird(module_path, module_name);
	if (!cmdline.skip_seamonkey_flag)
		add_module_seamonkey(module_path, module_name);

	cmdline_parser_free (&cmdline);

	return 0;
}
예제 #24
0
int main(int argc, char *argv[])
{
	struct gengetopt_args_info args_info;
	cmdline_parser_init(&args_info);
	if (cmdline_parser(argc, argv, &args_info) != 0)
		exit(1);

	if (args_info.arg_given)
	{
		printf("arg given: %s\n", args_info.arg_arg);
	}

	if (args_info.grp1c_given)
	{
		printf("Value of group switch: %d\n", args_info.grp1c_arg);
	}
	else
	{
		printf("Value of group switch (not set): %d\n", args_info.grp1c_arg);
	}

	return 0;
}
예제 #25
0
파일: atem.cpp 프로젝트: rudimeier/atem
int main(int argc, char *argv[])
{
	int ret = 0;
	const char *ms_dirp = ".";

#ifdef _WIN32
	/* never write CRLF line feeds */
	_setmode(_fileno(stderr),_O_BINARY);
	_setmode(_fileno(stdout),_O_BINARY);
#endif

	atexit( gengetopt_free );

	if( cmdline_parser(argc, argv, &args_info) != 0 ) {
		ret = 2;
		goto end;
	}

	check_display_args();

	if( args_info.inputs_num == 1 ) {
		ms_dirp = args_info.inputs[0];
	} else if( args_info.inputs_num > 1 ) {
		fprintf( stderr, "error: bad usage\n" );
		ret = 2;
		goto end;
	}

	ret = ms2csv( ms_dirp );

end:
	/* TODO teach Metastock::setError() to distinguish usage and other errors */
	if( ret == 2 ) {
		fprintf( stderr, "Try `%s --help' for more information.\n", argv[0] );
	}
	return ret; // exit
}
예제 #26
0
int main(int argc, char *argv[]) {
    struct gengetopt_args_info args_info;
    if (cmdline_parser(argc, argv, &args_info) != 0) {
        exit(1);
    }

    if (args_info.inputs_num != 1) {
        fprintf(stderr, "Program requires filename argument\n");
        return EXIT_FAILURE;
    }
    const char *input_filename = args_info.inputs[0];

    char *output_filename;
    if (args_info.output_given) {
        output_filename = args_info.output_arg;
    } else {
        output_filename = "output.fits";
    }


    perform_stuff(input_filename, output_filename);

    return EXIT_SUCCESS;
}
예제 #27
0
파일: oor.c 프로젝트: biels/oor
static void
handle_oor_command_line(int argc, char **argv)
{
    struct gengetopt_args_info args_info;

    if (cmdline_parser(argc, argv, &args_info) != 0) {
        exit_cleanup();
    }

    if (args_info.daemonize_given) {
        daemonize = TRUE;
    }
    if (args_info.config_file_given) {
        config_file = strdup(args_info.config_file_arg);
    }
    if (args_info.debug_given) {
        debug_level = args_info.debug_arg;
    }
    if (args_info.afi_given) {
        switch (args_info.afi_arg) {
        case 0: /* afi given = 4 */
            default_rloc_afi = AF_INET;
            break;
        case 1: /* afi given = 6 */
            default_rloc_afi = AF_INET6;
            break;
        default:
            OOR_LOG(LINF, "AFI must be IPv4 (-a 4) or IPv6 (-a 6)\n");
            break;
        }
    } else {
        default_rloc_afi = AF_UNSPEC;
    }

    cmdline_parser_free(&args_info);
}
예제 #28
0
int
main (int argc, char **argv)
{
	CHandle handle = 0;
	CResult res = C_SUCCESS;

	// Parse the command line
	if(cmdline_parser(argc, argv, &args_info) != 0)
		exit(1);
	
	// Display help if no arguments were specified
	if(argc == 1) {
		cmdline_parser_print_help();
		exit(0);
	}

	res = c_init();
	if(res) goto done;
	
	// Open the device
	if (!args_info.list_given && (!args_info.import_given || args_info.device_given)) {
		handle = c_open_device(args_info.device_arg);
		if(!handle) {
			print_error("Unable to open device", -1);
			res = C_INVALID_DEVICE;
			goto done;
		}
	}

	// List devices
	if(args_info.list_given) {
		res = list_devices();
		goto done;
	}
	// Import dynamic controls from XML file
	else if(args_info.import_given) {
		res = add_control_mappings(handle, args_info.import_arg);
		goto done;
	}
	// Import dynamic controls from XML files at default location
	if(args_info.addctrl_given) {
		// list all xml files at default data/vid dir
		int nf=0;
		char vid[5];
		char pid[5];
		short pid_set = 0;
		if(fnmatch("[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]", args_info.addctrl_arg, 0))
		{
			if(fnmatch("[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]", args_info.addctrl_arg, 0))
			{
				printf("%s invalid: set at least a valid vid value, :pid is optional\n", args_info.addctrl_arg);
				goto done;
			}
			else
			{
				/*extract vid and reset pid*/
				int c = 0;
				for (c = 0; c < 4; c++)
				{
					vid[c] = args_info.addctrl_arg[c];
					pid[c] = 0;
				}
				vid[4] = '\0';
				pid[4] = '\0';
			}
		}
		else 
		{
			/*extract vid and pid*/
			int c = 0;
			for (c = 0; c < 4; c++)
			{
				vid[c] = args_info.addctrl_arg[c];
				pid[c] = args_info.addctrl_arg[c+5];
			}
			vid[4] = '\0';
			pid[4] = '\0';
			pid_set = 1; /*flag pid.xml check*/
			//printf("vid:%s pid:%s\n", vid, pid);
		}
		
		/* get xml file list from DATA_DIR/vid/ */ 
		char **xml_files = get_filename (DATA_DIR, vid);
 
		/*check for pid.xml*/
		char fname[9];
		strcpy(fname, pid);
		strcat(fname,".xml");
		if(pid_set)
		{
			pid_set = 0; /*reset*/
			nf=0;
			while (xml_files[nf] != NULL)
			{
				if ( strcasecmp(fname, xml_files[nf]) == 0)
					pid_set = 1; /*file exists so flag it*/
				nf++;
			}
		}
		
		/*parse xml files*/
		nf = 0;
		while (xml_files[nf] != NULL)
		{
			/* if pid was set and pid.xml exists parse it*/
			if(pid_set)
			{
				if ((strcasecmp(fname, xml_files[nf]) == 0))
				{
					printf ( "Parsing: %s \n", xml_files[nf]);
					res = add_control_mappings(handle, xml_files[nf]);
				}
			}
			else /* parse all xml files inside vid dir */
			{
				printf ( "Parsing: %s \n", xml_files[nf]);
				res = add_control_mappings(handle, xml_files[nf]);
			}
			free(xml_files[nf]);
			xml_files[nf]=NULL;
			nf++;
		}
		free(xml_files);
		goto done;
	}

	// List frame formats
	if(args_info.formats_given) {
		printf("Listing available frame formats for device %s:\n", args_info.device_arg);
		res = list_frame_formats(handle);
	}
	// List controls
	else if(args_info.clist_given) {
		printf("Listing available controls for device %s:\n", args_info.device_arg);
		res = list_controls(handle);
	}
	// Retrieve control value
	else if(args_info.get_given) {
		CControlValue value;
		
		// Resolve the control Id
		CControlId controlId = get_control_id(handle, args_info.get_arg);
		if(!controlId) {
			res = 1;
			print_handle_error(handle, "Unknown control specified", -1);
			goto done;
		}

		// Retrieve the control value
		res = c_get_control(handle, controlId, &value);
		if(res) {
			print_handle_error(handle, "Unable to retrieve control value", res);
			goto done;
		}
		printf("%d\n", value.value);
	}
	// Retrieve raw control value
	else if(args_info.get_raw_given) {
		//scan input
		uint16_t unit_id;
		unsigned char selector;
		sscanf(args_info.get_raw_arg, "%hu:%hhu", &unit_id, &selector);
		CControlValue value;
		value.type = CC_TYPE_RAW;
		// the entity is only used for the generating a control name
		//TODO: pass the guid through cmdline (optional)
		unsigned char entity[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
		res = c_read_xu_control(handle, entity, unit_id, selector, &value);
		if(res) {
			print_handle_error(handle, "Unable to retrieve control value", res);
			goto done;
		}
		
		//print the raw value
		uint8_t * val = value.raw.data;
		int i=0;
		printf("query current value of: (LE)0x");
		for(i=0; i<value.raw.size; i++)	{
			printf("%.2x", val[i]);
		}
		printf("  (BE)0x");
		for(i=value.raw.size-1; i >=0; i--) {
			printf("%.2x", val[i]);
		}
		printf("\n");
		//free the raw value alocation
		if(value.raw.data) free(value.raw.data);
	}
	else if(args_info.set_given) {
		CControlValue value;

		// Parse the control value
		if(args_info.inputs_num < 1) {
			res = 3;
			print_error("No control value specified", -1);
			goto done;
		}
		if(parse_control_value(args_info.inputs[0], &value)) {
			res = 2;
			print_error("Invalid control value specified", -1);
			goto done;
		}

		// Resolve the control Id
		CControlId controlId = get_control_id(handle, args_info.set_arg);
		if(!controlId) {
			res = 1;
			print_handle_error(handle, "Unknown control specified", -1);
			goto done;
		}

		// Set the new control value
		res = c_set_control(handle, controlId, &value);
		if(res) {
			print_handle_error(handle, "Unable to set new control value", res);
			goto done;
		}
	}
	// Set the raw control value
	else if(args_info.set_raw_given) {
		CControlValue value;
		
		// Parse the control value
		if(args_info.inputs_num < 1) {
			res = 3;
			print_error("No raw control value specified", -1);
			goto done;
		}
		uint16_t unit_id;
		unsigned char selector;

		sscanf(args_info.set_raw_arg, "%hu:%hhu", &unit_id, &selector);
		
		parse_raw_control_value (args_info.inputs[0], &value);
		
		// the entity is only used for the generating a control name
		//TODO: pass the guid through cmdline (optional)
		unsigned char entity[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
		res = c_write_xu_control(handle, entity, unit_id, selector, &value);
		if(res) {
			print_handle_error(handle, "Unable to set the control value", res);
			goto done;
		}
		
		//print the raw value le and be format
		uint8_t * val = value.raw.data;
		int i=0;
		printf("set value of          : (LE)0x");
		for(i=0; i<value.raw.size; i++)	{
			printf("%.2x", val[i]);
		}
		printf("  (BE)0x");
		for(i=value.raw.size-1; i >=0; i--) {
			printf("%.2x", val[i]);
		}
		printf("\n");
		//free the raw value alocation
		if(value.raw.data) free(value.raw.data);
	}
	else if(args_info.save_ctrl_given) {
		res = save_controls( handle, args_info.save_ctrl_arg);
	}
	else if(args_info.load_ctrl_given) {
		res = load_controls( handle, args_info.load_ctrl_arg);
	}

	// Clean up
done:
	if(handle) c_close_device(handle);
	c_cleanup();
	cmdline_parser_free(&args_info);

	return res;
}
예제 #29
0
int
main ( int argc, char *argv[] )
{
   int rc;
   struct stat struct_stat;
   pthread_t pid;
   pthread_attr_t attr;
   int i, num_sources;
   uid_t gmetad_uid;
   mode_t rrd_umask;
   char * gmetad_username;
   struct passwd *pw;
   gmetad_config_t *c = &gmetad_config;
   apr_interval_time_t sleep_time;
   apr_time_t last_metadata;
   double random_sleep_factor;
   unsigned int rand_seed;

   rc = apr_initialize();
   if (rc != APR_SUCCESS) {
      return -1;
   }

   /* create a memory pool. */
   apr_pool_create(&global_context, NULL);

   /* Ignore SIGPIPE */
   signal( SIGPIPE, SIG_IGN );

   initialize_scoreboard();

   /* Mark the time this gmetad started */
   started = apr_time_now();

   if (cmdline_parser(argc, argv, &args_info) != 0)
      err_quit("command-line parser error");

   num_sources = number_of_datasources( args_info.conf_arg );
   if(!num_sources)
      {
         err_quit("%s doesn't have any data sources specified", args_info.conf_arg);
      }

   memset(&root, 0, sizeof(root));
   root.id = ROOT_NODE;

   /* Get the real number of data sources later */
   sources = hash_create( num_sources + 10 );
   if (! sources )
      {
         err_quit("Unable to create sources hash\n");
      }

   root.authority = hash_create( num_sources + 10 );
   if (!root.authority)
      {
         err_quit("Unable to create root authority (our grids and clusters) hash\n");
      }

   root.metric_summary = hash_create (DEFAULT_METRICSIZE);
   if (!root.metric_summary)
      {
         err_quit("Unable to create root summary hash");
      }

   parse_config_file ( args_info.conf_arg );
    /* If given, use command line directives over config file ones. */
   if (args_info.debug_given)
      {
         c->debug_level = args_info.debug_arg;
      }
   debug_level = c->debug_level;
   set_debug_msg_level(debug_level);

   /* Setup our default authority pointer if the conf file hasnt yet.
    * Done in the style of hash node strings. */
   if (!root.stringslen)
      {
         gethostname(hostname, HOSTNAMESZ);
         root.authority_ptr = 0;
         sprintf(root.strings, "http://%s/ganglia/", hostname);
         root.stringslen += strlen(root.strings) + 1;
      }

   rand_seed = apr_time_now() * (int)pthread_self();
   for(i = 0; i < root.stringslen; rand_seed = rand_seed * root.strings[i++]);

   /* Debug level 1 is error output only, and no daemonizing. */
   if (!debug_level)
      {
         rrd_umask = c->umask;
         daemon_init (argv[0], 0, rrd_umask);
      }

   if (args_info.pid_file_given)
     {
       update_pidfile (args_info.pid_file_arg);
     }

   /* The rrd_rootdir must be writable by the gmetad process */
   if( c->should_setuid )
      {
         if(! (pw = getpwnam(c->setuid_username)))
            {
               err_sys("Getpwnam error");
            }
         gmetad_uid = pw->pw_uid;
         gmetad_username = c->setuid_username;
      }
   else
      {
         gmetad_uid = getuid();
         if(! (pw = getpwuid(gmetad_uid)))
            {
               err_sys("Getpwnam error");
            } 
         gmetad_username = strdup(pw->pw_name);
      }

   debug_msg("Going to run as user %s", gmetad_username);
   if( c->should_setuid )
      {
         become_a_nobody(c->setuid_username);
      }

   if( c->write_rrds )
      {
         if( stat( c->rrd_rootdir, &struct_stat ) )
            {
                err_sys("Please make sure that %s exists", c->rrd_rootdir);
            }
         if ( struct_stat.st_uid != gmetad_uid )
            {
                err_quit("Please make sure that %s is owned by %s", c->rrd_rootdir, gmetad_username);
            }
         if (! (struct_stat.st_mode & S_IWUSR) )
            {
                err_quit("Please make sure %s has WRITE permission for %s", gmetad_username, c->rrd_rootdir);
            }
      }

   if(debug_level)
      {
         fprintf(stderr,"Sources are ...\n");
         hash_foreach( sources, print_sources, NULL);
      }

#ifdef WITH_MEMCACHED
   if (c->memcached_parameters != NULL)
      {
         memcached_connection_pool = memcached_pool(c->memcached_parameters, strlen(c->memcached_parameters));
      }
#endif /* WITH_MEMCACHED */

   server_socket = g_tcp_socket_server_new( c->xml_port );
   if (server_socket == NULL)
      {
         err_quit("tcp_listen() on xml_port failed");
      }
   debug_msg("xml listening on port %d", c->xml_port);
   
   interactive_socket = g_tcp_socket_server_new( c->interactive_port );
   if (interactive_socket == NULL)
      {
         err_quit("tcp_listen() on interactive_port failed");
      }
   debug_msg("interactive xml listening on port %d", c->interactive_port);

    /* Forward metrics to Graphite using carbon protocol */
    if (c->carbon_server != NULL)
      {
         if (!strcmp(c->carbon_protocol, "udp"))
            {
               carbon_udp_socket = init_carbon_udp_socket (c->carbon_server, c->carbon_port);

               if (carbon_udp_socket == NULL)
                  err_quit("carbon %s socket failed for %s:%d", c->carbon_protocol, c->carbon_server, c->carbon_port);
            }
         debug_msg("carbon forwarding ready to send via %s to %s:%d", c->carbon_protocol, c->carbon_server, c->carbon_port);
      }

#ifdef WITH_RIEMANN
    if (c->riemann_server !=NULL)
      {
         if (!strcmp(c->riemann_protocol, "udp"))
            {
               riemann_udp_socket = init_riemann_udp_socket (c->riemann_server, c->riemann_port);

               if (riemann_udp_socket == NULL)
                  err_quit("[riemann] %s socket failed for %s:%d", c->riemann_protocol, c->riemann_server, c->riemann_port);
            } else {
               err_quit("[riemann] TCP transport not supported yet.");
            }
         debug_msg("[riemann] ready to forward metrics via %s to %s:%d", c->riemann_protocol, c->riemann_server, c->riemann_port);
      }
#endif /* WITH_RIEMANN */

   /* initialize summary mutex */
   root.sum_finished = (pthread_mutex_t *) 
                          malloc(sizeof(pthread_mutex_t));
   pthread_mutex_init(root.sum_finished, NULL);

   pthread_attr_init( &attr );
   pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );

   /* Spin off the non-interactive server threads. (Half as many as interactive). */
   for (i=0; i < c->server_threads/2; i++)
      pthread_create(&pid, &attr, server_thread, (void*) 0);

   /* Spin off the interactive server threads. */
   for (i=0; i < c->server_threads; i++)
      pthread_create(&pid, &attr, server_thread, (void*) 1);

   hash_foreach( sources, spin_off_the_data_threads, NULL );

   /* A thread to cleanup old metrics and hosts */
   pthread_create(&pid, &attr, cleanup_thread, (void *) NULL);
   debug_msg("cleanup thread has been started");

    /* Meta data */
   last_metadata = 0;
   for(;;)
      {
         /* Do at a random interval, between 
                 (shortest_step/2) +/- METADATA_SLEEP_RANDOMIZE percent */
         random_sleep_factor = (1 + (METADATA_SLEEP_RANDOMIZE / 50.0) * ((rand_r(&rand_seed) - RAND_MAX/2)/(float)RAND_MAX));
         sleep_time = random_sleep_factor * apr_time_from_sec(c->shortest_step) / 2;
         /* Make sure the sleep time is at least 1 second */
         if(apr_time_sec(apr_time_now() + sleep_time) < (METADATA_MINIMUM_SLEEP + apr_time_sec(apr_time_now())))
            sleep_time += apr_time_from_sec(METADATA_MINIMUM_SLEEP);
         apr_sleep(sleep_time);

         /* Need to be sure root is locked while doing summary */
         pthread_mutex_lock(root.sum_finished);

         /* Flush the old values */
         hash_foreach(root.metric_summary, zero_out_summary, NULL);
         root.hosts_up = 0;
         root.hosts_down = 0;

         /* Sum the new values */
         hash_foreach(root.authority, do_root_summary, NULL );

         /* summary completed */
         pthread_mutex_unlock(root.sum_finished);

         /* Save them to RRD */
         hash_foreach(root.metric_summary, write_root_summary, NULL);

         /* Remember our last run */
         last_metadata = apr_time_now();
      }

   apr_pool_destroy(global_context);

   apr_terminate();
   return 0;
}
예제 #30
0
int main(int argc, char *argv[])
{
    int rval;
    gexec_cluster_t cluster;
    gexec_host_t *host;
    llist_entry *li;

    debug_level = 1;
    set_debug_msg_level(debug_level);

    if (cmdline_parser (argc, argv, &args_info) != 0)
        exit(1) ;

    rval = gexec_cluster(&cluster, args_info.gmond_ip_arg, args_info.gmond_port_arg );
    if ( rval != 0)
    {
        printf("Unable to get hostlist from %s %d!\n", args_info.gmond_ip_arg, args_info.gmond_port_arg);
        exit(-1);
    }

    if( args_info.mpifile_flag )
    {
        if( args_info.all_flag )
            li = cluster.hosts;
        else
            li = cluster.gexec_hosts;

        for( ; li != NULL; li = li->next )
        {
            host = li->val;
            if( host->name_resolved && ! args_info.numeric_flag )
            {
                if(!strcmp(host->domain, "unspecified"))
                    printf("%s:%d\n", host->name, host->cpu_num);
                else
                    printf("%s.%s:%d\n", host->name, host->domain, host->cpu_num);
            }
            else
            {
                printf("%s:%d\n", host->ip, host->cpu_num);
            }
        }
        exit(0);
    }

    if(! args_info.list_flag )
    {
        printf("CLUSTER INFORMATION\n");
        printf("       Name: %s\n", cluster.name);
        printf("      Hosts: %d\n", cluster.num_hosts);
        printf("Gexec Hosts: %d\n", cluster.num_gexec_hosts);
        printf(" Dead Hosts: %d\n", cluster.num_dead_hosts);
        printf("  Localtime: %s\n", ctime(&(cluster.localtime)) );
    }

    if( args_info.dead_flag)
    {
        if(! args_info.list_flag )
            printf("DEAD CLUSTER HOSTS\n");
        if(cluster.num_dead_hosts)
        {
            if(! args_info.list_flag )
                printf("%32.32s   Last Reported\n", "Hostname");
            for( li = cluster.dead_hosts; li != NULL; li = li->next)
            {
                host= li->val;
                printf("%32.32s   %s", host->name, ctime(&(host->last_reported)));
            }
        }
        else
        {
            printf("There are no hosts down at this time\n");
        }
        gexec_cluster_free(&cluster);
        exit(0);
    }

    if( args_info.all_flag )
    {
        li = cluster.hosts;
        if(! cluster.num_hosts )
        {
            printf("There are no hosts up at this time\n");
            gexec_cluster_free(&cluster);
            exit(0);
        }
    }
    else
    {
        li = cluster.gexec_hosts;
        if(! cluster.num_gexec_hosts)
        {
            printf("There are no hosts running gexec at this time\n");
            gexec_cluster_free(&cluster);
            exit(0);
        }
    }

    if(! args_info.list_flag )
    {
        printf("CLUSTER HOSTS\n");
        printf("Hostname                     LOAD                       CPU              Gexec\n");
        printf(" CPUs (Procs/Total) [     1,     5, 15min] [  User,  Nice, System, Idle, Wio]\n\n");
    }
    for(; li != NULL; li = li->next)
    {
        host = li->val;
        if( host->name_resolved && ! args_info.numeric_flag )
        {
            if(!strcmp(host->domain, "unspecified"))
                printf("%s", host->name);
            else
                printf("%s.%s", host->name, host->domain);
        }
        else
        {
            printf("%s", host->ip);
        }
        if( args_info.single_line_flag )
            printf(" ");
        else
            printf("\n");

        printf(" %4d (%5d/%5d) [%6.2f,%6.2f,%6.2f] [%6.1f,%6.1f,%6.1f,%6.1f,%6.1f] ",
               host->cpu_num, host->proc_run, host->proc_total,
               host->load_one, host->load_five, host->load_fifteen,
               host->cpu_user, host->cpu_nice, host->cpu_system, host->cpu_idle, host->cpu_wio);
        if(host->gexec_on)
            printf("%s\n", "ON");
        else
            printf("%s\n", "OFF");
    }

    gexec_cluster_free(&cluster);
    return 0;
}