本文整理汇总了C++中poptGetArg函数的典型用法代码示例。如果您正苦于以下问题:C++ poptGetArg函数的具体用法?C++ poptGetArg怎么用?C++ poptGetArg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了poptGetArg函数的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" },
{ "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);
}
示例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" },
{ "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);
}
示例3: rdiff_patch
static rs_result rdiff_patch(poptContext opcon)
{
/* patch BASIS [DELTA [NEWFILE]] */
FILE *basis_file, *delta_file, *new_file;
char const *basis_name;
rs_stats_t stats;
rs_result result;
if (!(basis_name = poptGetArg(opcon))) {
rdiff_usage("Usage for patch: "
"rdiff [OPTIONS] patch BASIS [DELTA [NEW]]");
return RS_SYNTAX_ERROR;
}
basis_file = rs_file_open(basis_name, "rb");
delta_file = rs_file_open(poptGetArg(opcon), "rb");
new_file = rs_file_open(poptGetArg(opcon), "wb");
rdiff_no_more_args(opcon);
result = rs_patch_file(basis_file, delta_file, new_file, &stats);
rs_file_close(new_file);
rs_file_close(delta_file);
rs_file_close(basis_file);
if (show_stats)
rs_log_stats(&stats);
return result;
}
示例4: 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);
}
示例5: main
int main(int argc, const char **argv)
{
NET_API_STATUS status;
struct libnetapi_ctx *ctx = NULL;
const char *hostname = NULL;
const char *domain = NULL;
uint8_t *buffer = NULL;
poptContext pc;
int opt;
struct poptOption long_options[] = {
POPT_AUTOHELP
POPT_COMMON_LIBNETAPI_EXAMPLES
POPT_TABLEEND
};
status = libnetapi_init(&ctx);
if (status != 0) {
return status;
}
pc = poptGetContext("getdc", argc, argv, long_options, 0);
poptSetOtherOptionHelp(pc, "hostname domainname");
while((opt = poptGetNextOpt(pc)) != -1) {
}
if (!poptPeekArg(pc)) {
poptPrintHelp(pc, stderr, 0);
goto out;
}
hostname = poptGetArg(pc);
if (!poptPeekArg(pc)) {
poptPrintHelp(pc, stderr, 0);
goto out;
}
domain = poptGetArg(pc);
/* NetGetDCName */
status = NetGetDCName(hostname, domain, &buffer);
if (status != 0) {
printf("GetDcName failed with: %s\n", libnetapi_errstr(status));
} else {
printf("%s\n", (char *)buffer);
}
out:
NetApiBufferFree(buffer);
libnetapi_free(ctx);
poptFreeContext(pc);
return status;
}
示例6: main
int main(int argc, const char **argv)
{
NET_API_STATUS status;
struct libnetapi_ctx *ctx = NULL;
const char *hostname = NULL;
const char *sharename = NULL;
poptContext pc;
int opt;
struct poptOption long_options[] = {
POPT_AUTOHELP
POPT_COMMON_LIBNETAPI_EXAMPLES
POPT_TABLEEND
};
status = libnetapi_init(&ctx);
if (status != 0) {
return status;
}
pc = poptGetContext("share_del", argc, argv, long_options, 0);
poptSetOtherOptionHelp(pc, "hostname sharename");
while((opt = poptGetNextOpt(pc)) != -1) {
}
if (!poptPeekArg(pc)) {
poptPrintHelp(pc, stderr, 0);
goto out;
}
hostname = poptGetArg(pc);
if (!poptPeekArg(pc)) {
poptPrintHelp(pc, stderr, 0);
goto out;
}
sharename = poptGetArg(pc);
/* NetShareDel */
status = NetShareDel(hostname,
sharename,
0);
if (status != 0) {
printf("NetShareDel failed with: %s\n",
libnetapi_get_error_string(ctx, status));
goto out;
}
out:
libnetapi_free(ctx);
poptFreeContext(pc);
return status;
}
示例7: main
int main(int argc, const char *argv[])
{
const char *config_file = get_dyn_CONFIGFILE();
const char *sequence = "";
poptContext pc;
char *buff;
TALLOC_CTX *ctx = talloc_stackframe();
struct poptOption long_options[] = {
POPT_AUTOHELP
POPT_COMMON_VERSION
POPT_TABLEEND
};
load_case_tables();
pc = poptGetContext(NULL, argc, argv, long_options,
POPT_CONTEXT_KEEP_FIRST);
poptSetOtherOptionHelp(pc, "[OPTION...] <sequence-string>");
while(poptGetNextOpt(pc) != -1);
setup_logging(poptGetArg(pc), true);
sequence = poptGetArg(pc);
if (sequence == NULL) {
fprintf(stderr, "ERROR: missing sequence string\n");
return 1;
}
dbf = x_stderr;
DEBUGLEVEL = 0;
AllowDebugChange = false;
if (!lp_load(config_file,false,true,false,true)) {
fprintf(stderr,"Error loading services.\n");
return 1;
}
while(next_token_talloc(ctx, &sequence, &buff, NULL)) {
printf("[%s]\n", buff);
}
talloc_free(ctx);
return 0;
}
示例8: inputBox
int inputBox(const char * text, int height, int width, poptContext optCon,
int flags, char ** result) {
newtComponent form, entry, okay, cancel, answer, tb;
char * val;
int rc = DLG_OKAY;
int top;
val = poptGetArg(optCon);
tb = textbox(height - 3 - buttonHeight, width - 2,
text, flags, &top);
form = newtForm(NULL, NULL, 0);
entry = newtEntry(1, top + 1, val, width - 2, &val,
NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
newtFormAddComponents(form, tb, entry, NULL);
addButtons(height, width, form, &okay, &cancel, flags);
answer = newtRunForm(form);
if (answer == cancel)
rc = DLG_CANCEL;
*result = val;
return rc;
}
示例9: rdiff_no_more_args
static void rdiff_no_more_args(poptContext opcon)
{
if (poptGetArg(opcon)) {
rdiff_usage("rdiff: too many arguments");
exit(RS_SYNTAX_ERROR);
}
}
示例10: cmd_view
/*
* The 'view <options>' first level command
*/
int cmd_view(int argc, const char **argv)
{
int opt, ret = CMD_SUCCESS;
static poptContext pc;
pc = poptGetContext(NULL, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
if (lttng_opt_mi) {
WARN("mi does not apply to view command");
}
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
SHOW_HELP();
goto end;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
goto end;
default:
ret = CMD_UNDEFINED;
goto end;
}
}
opt_session_name = (char*) poptGetArg(pc);
ret = view_trace();
end:
poptFreeContext(pc);
return ret;
}
示例11: init
char *
init(const int argc, const char **argv,
const echoping_options global_external_options)
{
int value;
char *msg = malloc(256);
char *rest;
/* popt variables */
struct poptOption options[] = {
{"conninfo", 'c', POPT_ARG_STRING, &conninfo, 0,
"Connection information for the Postgresql server. Something like 'host=foo dbname=bar''",
""},
{"readall", 'a', POPT_ARG_NONE, &readall, 0,
"Read all the data sent by the Postgresql server",
""},
{"connect-each-time", 'e', POPT_ARG_NONE, &connect_each_time, 0,
"(Re)Connect to the Postgresql server at each iteration",
""},
POPT_AUTOHELP POPT_TABLEEND
};
global_options = global_external_options;
if (global_options.udp)
err_quit("UDP makes no sense for a PostgreSQL connection");
postgresql_poptcon = poptGetContext(NULL, argc,
argv, options, POPT_CONTEXT_POSIXMEHARDER);
while ((value = poptGetNextOpt(postgresql_poptcon)) > 0) {
}
if (value < -1) {
sprintf(msg, "%s: %s",
poptBadOption(postgresql_poptcon, POPT_BADOPTION_NOALIAS),
poptStrerror(value));
postgresql_usage(msg);
}
request = poptGetArg(postgresql_poptcon);
if (request == NULL)
request = "SELECT now()";
rest = poptGetArg(postgresql_poptcon);
if (rest != NULL)
postgresql_usage("Erroneous additional arguments");
if (conninfo == NULL)
conninfo = "";
return NULL; /* We only use the conninfo, echoping does not see
* our hostname or port */
}
示例12: rdiff_delta
static rs_result rdiff_delta(poptContext opcon)
{
FILE *sig_file, *new_file, *delta_file;
char const *sig_name;
rs_result result;
rs_signature_t *sumset;
rs_stats_t stats;
if (!(sig_name = poptGetArg(opcon))) {
rdiff_usage("Usage for delta: "
"rdiff [OPTIONS] delta SIGNATURE [NEWFILE [DELTA]]");
return RS_SYNTAX_ERROR;
}
sig_file = rs_file_open(sig_name, "rb");
new_file = rs_file_open(poptGetArg(opcon), "rb");
delta_file = rs_file_open(poptGetArg(opcon), "wb");
rdiff_no_more_args(opcon);
result = rs_loadsig_file(sig_file, &sumset, &stats);
if (result != RS_DONE)
return result;
if (show_stats)
rs_log_stats(&stats);
if ((result = rs_build_hash_table(sumset)) != RS_DONE)
return result;
result = rs_delta_file(sumset, new_file, delta_file, &stats);
rs_free_sumset(sumset);
rs_file_close(delta_file);
rs_file_close(new_file);
rs_file_close(sig_file);
if (show_stats)
rs_log_stats(&stats);
return result;
}
示例13: doSign
/* TODO: permit overriding macro setup on the command line */
static int doSign(poptContext optCon)
{
int rc = EXIT_FAILURE;
char * passPhrase = NULL;
char * name = rpmExpand("%{?_gpg_name}", NULL);
struct rpmSignArgs sig = {NULL, 0, 0};
char *key = NULL;
if (rstreq(name, "")) {
fprintf(stderr, _("You must set \"%%_gpg_name\" in your macro file\n"));
goto exit;
}
if (fileSigningKey) {
addMacro(NULL, "_file_signing_key", NULL, fileSigningKey, RMIL_GLOBAL);
}
if (signfiles) {
key = rpmExpand("%{?_file_signing_key}", NULL);
if (rstreq(key, "")) {
fprintf(stderr, _("You must set \"$$_file_signing_key\" in your macro file or on the command line with --fskpath\n"));
goto exit;
}
if (fskpass) {
#ifndef WITH_IMAEVM
argerror(_("--fskpass may only be specified when signing files"));
#else
fileSigningKeyPassword = get_fskpass();
#endif
}
addMacro(NULL, "_file_signing_key_password", NULL,
fileSigningKeyPassword, RMIL_CMDLINE);
if (fileSigningKeyPassword) {
memset(fileSigningKeyPassword, 0, strlen(fileSigningKeyPassword));
free(fileSigningKeyPassword);
}
sig.signfiles = 1;
}
const char *arg;
rc = 0;
while ((arg = poptGetArg(optCon)) != NULL) {
rc += rpmPkgSign(arg, &sig);
}
exit:
free(key);
free(passPhrase);
free(name);
return rc;
}
示例14: rdiff_sig
/**
* Generate signature from remaining command line arguments.
*/
static rs_result rdiff_sig(poptContext opcon)
{
FILE *basis_file, *sig_file;
rs_stats_t stats;
rs_result result;
basis_file = rs_file_open(poptGetArg(opcon), "rb");
sig_file = rs_file_open(poptGetArg(opcon), "wb");
rdiff_no_more_args(opcon);
result = rs_sig_file(basis_file, sig_file, block_len, strong_len, &stats);
if (result != RS_DONE)
return result;
if (show_stats)
rs_log_stats(&stats);
return result;
}
示例15: cmd_disable_events
/*
* cmd_disable_events
*
* Disable event to trace session
*/
int cmd_disable_events(int argc, const char **argv)
{
int opt, ret = CMD_SUCCESS;
static poptContext pc;
char *session_name = NULL;
pc = poptGetContext(NULL, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
usage(stdout);
goto end;
case OPT_USERSPACE:
opt_userspace = 1;
break;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
goto end;
default:
usage(stderr);
ret = CMD_UNDEFINED;
goto end;
}
}
opt_event_list = (char*) poptGetArg(pc);
if (opt_event_list == NULL && opt_disable_all == 0) {
ERR("Missing event name(s).\n");
usage(stderr);
ret = CMD_ERROR;
goto end;
}
if (!opt_session_name) {
session_name = get_session_name();
if (session_name == NULL) {
ret = CMD_ERROR;
goto end;
}
} else {
session_name = opt_session_name;
}
ret = disable_events(session_name);
end:
if (!opt_session_name && session_name) {
free(session_name);
}
poptFreeContext(pc);
return ret;
}