本文整理汇总了C++中poptStrerror函数的典型用法代码示例。如果您正苦于以下问题:C++ poptStrerror函数的具体用法?C++ poptStrerror怎么用?C++ poptStrerror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了poptStrerror函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_opt
static
void parse_opt(int argc, char **argv)
{
int c;
poptContext optCon;
const char *no_arg;
struct poptOption optionsTable[] = {
{ "loops" , 'n', POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_INT,
&arg_loops , 0, "pp loops", "count" },
{ "time" , 't', POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_INT,
&arg_maxtime, 0, "max time", "ms" },
{ "maxsize" , 0, POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_INT,
&arg_maxmsize , 0, "maximal messagesize", "size" },
{ "nokill" , 'k', POPT_ARGFLAG_OR | POPT_ARG_VAL,
&arg_nokill, 1, "Dont kill the server afterwards", NULL },
{ "port" , 'p', POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_STRING,
&arg_port, 0, "server port to use", "port" },
{ "verbose" , 'v', POPT_ARG_NONE,
NULL , 'v', "increase verbosity", NULL },
POPT_AUTOHELP
POPT_TABLEEND
};
optCon = poptGetContext(NULL, argc, (const char **) argv, optionsTable, 0);
poptSetOtherOptionHelp(optCon, "[serveraddr]");
while ((c = poptGetNextOpt(optCon)) >= 0) {
switch (c) { // c = poptOption.val;
case 'v': arg_verbose++; break;
}
}
if (c < -1) { /* an error occurred during option processing */
fprintf(stderr, "%s: %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(c));
poptPrintHelp(optCon, stderr, 0);
exit(1);
}
// arg_1 = poptGetArg(optCon);
// arg_2 = poptGetArg(optCon);
arg_servername = poptGetArg(optCon);
is_server = !arg_servername;
no_arg = poptGetArg(optCon); // should return NULL
if (no_arg) {
fprintf(stderr, "%s: %s\n",
no_arg, poptStrerror(POPT_ERROR_BADOPT));
poptPrintHelp(optCon, stderr, 0);
exit(1);
}
poptFreeContext(optCon);
}
示例2: parse_opt
static
void parse_opt(int argc, char **argv)
{
int c;
poptContext optCon;
const char *no_arg;
struct poptOption optionsTable[] = {
{ "loops" , 'n', POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_INT,
&arg_loops , 0, "pp loops", "count" },
{ "time" , 't', POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_INT,
&arg_maxtime, 0, "max time", "ms" },
{ "maxsize" , 0, POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_INT,
&arg_maxmsize , 0, "maximal messagesize", "size" },
{ "once" , '1', POPT_ARGFLAG_OR | POPT_ARG_VAL,
&arg_run_once, 1, "stop after one client", NULL },
{ "verbose" , 'v', POPT_ARG_NONE,
NULL , 'v', "increase verbosity", NULL },
POPT_AUTOHELP
POPT_TABLEEND
};
optCon = poptGetContext(NULL, argc, (const char **) argv, optionsTable, 0);
poptSetOtherOptionHelp(optCon, "[serveraddr]");
while ((c = poptGetNextOpt(optCon)) >= 0) {
switch (c) { // c = poptOption.val;
case 'v': arg_verbose++; break;
//default: fprintf(stderr, "unhandled popt value %d\n", c); break;
}
}
if (c < -1) { /* an error occurred during option processing */
fprintf(stderr, "%s: %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(c));
poptPrintHelp(optCon, stderr, 0);
exit(1);
}
// arg_1 = poptGetArg(optCon);
// arg_2 = poptGetArg(optCon);
/* if (arg_client)*/ {
const char *server = poptGetArg(optCon);
if (server) arg_server_addr = server;
}
no_arg = poptGetArg(optCon); // should return NULL
if (no_arg) {
fprintf(stderr, "%s: %s\n",
no_arg, poptStrerror(POPT_ERROR_BADOPT));
poptPrintHelp(optCon, stderr, 0);
exit(1);
}
poptFreeContext(optCon);
}
示例3: parse_opt
void parse_opt(int argc, char **argv)
{
int c;
poptContext optCon;
const char *no_arg;
struct poptOption optionsTable[] = {
{ "send" , 's', POPT_ARGFLAG_OR | POPT_ARG_VAL,
&arg_send, 1, "first send", NULL },
{ "lport" , 'l', POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_INT,
&arg_listenport, 0, "listen on port", "port" },
{ "lname" , 'n', POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_STRING,
&arg_listenname, 0, "listen on name", "name" },
{ "verbose" , 'v', POPT_ARG_NONE,
NULL , 'v', "increase verbosity", NULL },
POPT_AUTOHELP
POPT_TABLEEND
};
optCon = poptGetContext(NULL, argc, (const char **) argv, optionsTable, 0);
poptSetOtherOptionHelp(optCon, "[peer address]");
while ((c = poptGetNextOpt(optCon)) >= 0) {
switch (c) { // c = poptOption.val;
case 'v': arg_verbose++; break;
//default: fprintf(stderr, "unhandled popt value %d\n", c); break;
}
}
if (c < -1) { /* an error occurred during option processing */
fprintf(stderr, "%s: %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(c));
poptPrintHelp(optCon, stderr, 0);
exit(1);
}
{
const char *s;
s = poptGetArg(optCon);
if (s) {
arg_peer_str = s;
}
}
no_arg = poptGetArg(optCon); // should return NULL
if (no_arg) {
fprintf(stderr, "%s: %s\n",
no_arg, poptStrerror(POPT_ERROR_BADOPT));
poptPrintHelp(optCon, stderr, 0);
exit(1);
}
poptFreeContext(optCon);
}
示例4: args_execute
void args_execute(int argc, char *argv[])
{
poptContext con;
int nextopt;
if (iopt_tables == NULL)
return;
con = poptGetContext(PACKAGE, argc, argv,
(struct poptOption *) (iopt_tables->data), 0);
poptReadDefaultConfig(con, TRUE);
while ((nextopt = poptGetNextOpt(con)) > 0) ;
if (nextopt != -1) {
printf("Error on option %s: %s.\n"
"Run '%s --help' to see a full list of "
"available command line options.\n",
poptBadOption(con, 0), poptStrerror(nextopt), argv[0]);
exit(1);
}
g_array_free(iopt_tables, TRUE);
iopt_tables = NULL;
poptFreeContext(con);
}
示例5: main
int
main(int argc, char *argv[])
{
poptContext pc;
const char **extra_args;
int opt;
pc = poptGetContext(PROGRAM, argc, (const char **)argv,
long_options, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case 'h':
tls_usage(0);
default:
fprintf(stderr,
"%s: %s\n",
poptBadOption(pc, POPT_BADOPTION_NOALIAS),
poptStrerror(opt));
tls_usage(1);
}
}
extra_args = poptGetArgs(pc);
if (!extra_args || *extra_args == NULL)
tls_usage(1);
for (; *extra_args; extra_args++)
list_file(*extra_args);
poptFreeContext(pc);
return 0;
}
示例6: main
int main(int argc, const char *argv[])
{
poptContext pc;
int opt;
int rv;
struct poptOption long_options[] = {
POPT_AUTOHELP
SSSD_DEBUG_OPTS
POPT_TABLEEND
};
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_deskprofile_get_filename_path),
};
/* Set debug level to invalid value so we can decide if -d 0 was used. */
debug_level = SSSDBG_INVALID;
pc = poptGetContext(argv[0], argc, argv, long_options, 0);
while((opt = poptGetNextOpt(pc)) != -1) {
switch(opt) {
default:
fprintf(stderr, "\nInvalid option %s: %s\n\n",
poptBadOption(pc, 0), poptStrerror(opt));
poptPrintUsage(pc, stderr, 0);
return 1;
}
}
poptFreeContext(pc);
DEBUG_CLI_INIT(debug_level);
rv = cmocka_run_group_tests(tests, NULL, NULL);
return rv;
}
示例7: parse_options
/*
parse options
*/
static isc_result_t parse_options(struct dlz_bind9_data *state,
unsigned int argc, char *argv[],
struct b9_options *options)
{
int opt;
poptContext pc;
struct poptOption long_options[] = {
{ "url", 'H', POPT_ARG_STRING, &options->url, 0, "database URL", "URL" },
{ "debug", 'd', POPT_ARG_STRING, &options->debug, 0, "debug level", "DEBUG" },
{ NULL }
};
pc = poptGetContext("dlz_bind9", argc, (const char **)argv, long_options,
POPT_CONTEXT_KEEP_FIRST);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
default:
state->log(ISC_LOG_ERROR, "dlz_bind9: Invalid option %s: %s",
poptBadOption(pc, 0), poptStrerror(opt));
return ISC_R_FAILURE;
}
}
return ISC_R_SUCCESS;
}
示例8: main
int main(int argc, char *argv[])
{
poptContext optCon; /* context for parsing command-line options */
int rc;
struct poptOption optionsTable[] = {
{ "np", '\0', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH,
&arg_np, 0, "number of processes to start", "num"},
POPT_AUTOHELP
{ NULL, '\0', 0, NULL, 0, NULL, NULL}
};
//printf(__DATE__" "__TIME__"\n");
optCon = poptGetContext(NULL, argc, (const char **)argv, optionsTable, 0);
rc = poptGetNextOpt(optCon);
if (rc < -1) {
/* an error occurred during option processing */
poptPrintUsage(optCon, stderr, 0);
fprintf(stderr, "%s: %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(rc));
return 1;
}
if (arg_np <= 0) {
fprintf(stderr,"missing arg -np\n");
exit(1);
}
run(argc,argv,arg_np);
return 0;
}
示例9: main
int main(int argc, const char *argv[])
{
int opt;
poptContext pc;
struct main_context *main_ctx;
int ret;
uid_t uid;
gid_t gid;
struct poptOption long_options[] = {
POPT_AUTOHELP
SSSD_MAIN_OPTS
SSSD_SERVER_OPTS(uid, gid)
POPT_TABLEEND
};
/* Set debug level to invalid value so we can decide if -d 0 was used. */
debug_level = SSSDBG_INVALID;
umask(DFL_RSP_UMASK);
pc = poptGetContext(argv[0], argc, argv, long_options, 0);
while((opt = poptGetNextOpt(pc)) != -1) {
switch(opt) {
default:
fprintf(stderr, "\nInvalid option %s: %s\n\n",
poptBadOption(pc, 0), poptStrerror(opt));
poptPrintUsage(pc, stderr, 0);
return 1;
}
}
poptFreeContext(pc);
DEBUG_INIT(debug_level);
/* set up things like debug, signals, daemonization, etc... */
debug_log_file = "sssd_pac";
ret = server_setup("sssd[pac]", 0, uid, gid,
CONFDB_PAC_CONF_ENTRY, &main_ctx);
if (ret != EOK) return 2;
ret = die_if_parent_died();
if (ret != EOK) {
/* This is not fatal, don't return */
DEBUG(SSSDBG_OP_FAILURE, "Could not set up to exit when parent process does\n");
}
ret = pac_process_init(main_ctx,
main_ctx->event_ctx,
main_ctx->confdb_ctx);
if (ret != EOK) return 3;
/* loop on main */
server_loop(main_ctx);
return 0;
}
示例10: main
int main(int argc, const char *argv[])
{
int rv;
int no_cleanup = 0;
poptContext pc;
int opt;
struct poptOption long_options[] = {
POPT_AUTOHELP
SSSD_DEBUG_OPTS
{"no-cleanup", 'n', POPT_ARG_NONE, &no_cleanup, 0,
_("Do not delete the test database after a test run"), NULL },
POPT_TABLEEND
};
const UnitTest tests[] = {
/* Utility functions unit test */
unit_test(dyndns_test_get_ifaddr),
/* Dynamic DNS update unit tests*/
unit_test_setup_teardown(dyndns_test_ok,
dyndns_test_setup, dyndns_test_teardown),
unit_test_setup_teardown(dyndns_test_error,
dyndns_test_setup, dyndns_test_teardown),
unit_test_setup_teardown(dyndns_test_timeout,
dyndns_test_setup, dyndns_test_teardown),
unit_test_setup_teardown(dyndns_test_interval,
dyndns_test_setup, dyndns_test_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
debug_level = SSSDBG_INVALID;
pc = poptGetContext(argv[0], argc, argv, long_options, 0);
while((opt = poptGetNextOpt(pc)) != -1) {
switch(opt) {
default:
fprintf(stderr, "\nInvalid option %s: %s\n\n",
poptBadOption(pc, 0), poptStrerror(opt));
poptPrintUsage(pc, stderr, 0);
return 1;
}
}
poptFreeContext(pc);
DEBUG_CLI_INIT(debug_level);
/* Even though normally the tests should clean up after themselves
* they might not after a failed run. Remove the old db to be sure */
tests_set_cwd();
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
test_dom_suite_setup(TESTS_PATH);
rv = run_tests(tests);
if (rv == 0 && !no_cleanup) {
test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_SYSDB_FILE);
}
return rv;
}
示例11: main
int
main(int argc, const char *argv[])
{
Socket* serverSock, *controlSock;
int c;
poptContext optCon = poptGetContext(NULL, argc, argv, options, 0);
poptSetOtherOptionHelp(optCon, "configFile");
while ((c = poptGetNextOpt(optCon)) >= 0) {
switch (c) {
case 'v':
printf(V_STRING, VERSION);
printf(COPYRIGHT);
return 0;
}
}
setup_logging (logfile_name, log_level);
if (c < -1) {
/* an error occurred during option processing */
fprintf(stderr, "%s: %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(c));
return -1;
}
loginfo (V_STRING, VERSION);
loginfo (COPYRIGHT);
struct sigaction new_action, old_action;
new_action.sa_handler = sigpipe_handler;
sigemptyset (&new_action.sa_mask);
new_action.sa_flags = 0;
sigaction (SIGPIPE, NULL, &old_action);
if (old_action.sa_handler != SIG_IGN)
sigaction (SIGPIPE, &new_action, NULL);
prepare_stdin(NULL);
eventloop_init();
session = (Session*) malloc(sizeof(Session));
memset(session, 0, sizeof(Session));
session->state = ProxyState_PAUSED;
serverSock = socket_server_new("proxy_server", listen_port, on_connect, NULL);
controlSock = socket_server_new("proxy_server_control", listen_port + 1, on_control_connect, NULL);
eventloop_on_stdin(stdin_handler, session);
eventloop_run();
socket_free(serverSock);
socket_free(controlSock);
return(0);
}
示例12: main
/*
main program
*/
int main(int argc, const char *argv[])
{
struct ctdb_context *ctdb;
struct ctdb_db_context *ctdb_db;
struct poptOption popt_options[] = {
POPT_AUTOHELP
POPT_CTDB_CMDLINE
{ "num-records", 'r', POPT_ARG_INT, &num_records, 0, "num_records", "integer" },
{ "base-rec", 'b', POPT_ARG_INT, &base_rec, 0, "base_rec", "integer" },
{ "delete-pct", 'p', POPT_ARG_INT, &delete_pct, 0, "delete_pct", "integer" },
POPT_TABLEEND
};
int opt;
const char **extra_argv;
int extra_argc = 0;
poptContext pc;
struct event_context *ev;
pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
default:
fprintf(stderr, "Invalid option %s: %s\n",
poptBadOption(pc, 0), poptStrerror(opt));
exit(1);
}
}
/* setup the remaining options for the main program to use */
extra_argv = poptGetArgs(pc);
if (extra_argv) {
extra_argv++;
while (extra_argv[extra_argc]) extra_argc++;
}
ev = event_context_init(NULL);
ctdb = ctdb_cmdline_client(ev, timeval_current_ofs(3, 0));
if (ctdb == NULL) {
printf("failed to connect to daemon\n");
exit(1);
}
/* attach to a specific database */
ctdb_db = ctdb_attach(ctdb, timeval_current_ofs(2, 0), "test.tdb",
false, 0);
if (!ctdb_db) {
printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb));
exit(1);
}
store_records(ctdb, ev);
return 0;
}
示例13: main
int main(int argc, const char *argv[])
{
poptContext pc;
int opt;
struct poptOption long_options[] = {
POPT_AUTOHELP
SSSD_DEBUG_OPTS
POPT_TABLEEND
};
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_add_domain,
test_sss_idmap_setup,
test_sss_idmap_teardown),
cmocka_unit_test_setup_teardown(test_map_id,
test_sss_idmap_setup_with_domains,
test_sss_idmap_teardown),
cmocka_unit_test_setup_teardown(test_map_id_external,
test_sss_idmap_setup_with_external_mappings,
test_sss_idmap_teardown),
cmocka_unit_test_setup_teardown(test_check_sid_id,
test_sss_idmap_setup_with_domains,
test_sss_idmap_teardown),
cmocka_unit_test_setup_teardown(test_check_sid_id,
test_sss_idmap_setup_with_external_mappings,
test_sss_idmap_teardown),
cmocka_unit_test_setup_teardown(test_has_algorithmic,
test_sss_idmap_setup_with_both,
test_sss_idmap_teardown),
cmocka_unit_test_setup_teardown(test_has_algorithmic_by_name,
test_sss_idmap_setup_with_both,
test_sss_idmap_teardown),
cmocka_unit_test(test_sss_idmap_check_collision_ex),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
debug_level = SSSDBG_INVALID;
pc = poptGetContext(argv[0], argc, argv, long_options, 0);
while((opt = poptGetNextOpt(pc)) != -1) {
switch(opt) {
default:
fprintf(stderr, "\nInvalid option %s: %s\n\n",
poptBadOption(pc, 0), poptStrerror(opt));
poptPrintUsage(pc, stderr, 0);
return 1;
}
}
poptFreeContext(pc);
DEBUG_CLI_INIT(debug_level);
tests_set_cwd();
return cmocka_run_group_tests(tests, NULL, NULL);
}
示例14: bad_option
static void bad_option(poptContext opcon, int error)
{
char msgbuf[1000];
snprintf(msgbuf, sizeof msgbuf-1, "%s: %s: %s",
PROGRAM, poptStrerror(error), poptBadOption(opcon, 0));
rdiff_usage(msgbuf);
exit(RS_SYNTAX_ERROR);
}
示例15: RTparseOptions
void RTparseOptions(const char* argline,int *argc_p,char***argv_p){
int len=strlen(argline)+8;
char cmdline[len];
sprintf(cmdline,"fake %s",argline);
int res=poptParseArgvString(cmdline,argc_p,(const char ***)argv_p);
if (res){
Fatal(1,error,"could not parse %s: %s",cmdline,poptStrerror(res));
}
(*argv_p)[0]=strdup(HREgetApplication());
}