Exemplo n.º 1
0
/* options parameter can't be a local variable because caller can use the
 * returned poptContext which contains  pointer inside the options array */
static poptContext do_parse_options(int argc, char const ** argv,
                                    vector<poptOption> & options,
                                    vector<string> & additional_params)
{
	options = popt_options;

	int const nr_appended_options =
		sizeof(appended_options) / sizeof(appended_options[0]);

	options.insert(options.end(), appended_options,
		       appended_options + nr_appended_options);

	poptContext con = op_poptGetContext(NULL, argc, argv, &options[0], 0);

	if (showvers) {
		show_version(argv[0]);
	}

	char const * file;
	while ((file = poptGetArg(con)) != 0) {
		additional_params.push_back(file);
	}

	for (size_t i = 0 ; i < options_list.size() ; ++i) {
		options_list[i]->post_process();
	}

	return con;
}
Exemplo n.º 2
0
/**
 * get_options - process command line
 * @param argc  program arg count
 * @param argv  program arg array
 *
 * Process the arguments, fatally complaining on error.
 */
static void get_options(int argc, char const * argv[])
{
	optcon = op_poptGetContext(NULL, argc, argv, options, 0);

	if (show_vers) {
		show_version(argv[0]);
	}

	/* non-option, must be a valid event name or event specs */
	chosen_events = poptGetArgs(optcon);

	/* don't free the context now, we need chosen_events */
}