本文整理汇总了C++中poptSetOtherOptionHelp函数的典型用法代码示例。如果您正苦于以下问题:C++ poptSetOtherOptionHelp函数的具体用法?C++ poptSetOtherOptionHelp怎么用?C++ poptSetOtherOptionHelp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了poptSetOtherOptionHelp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:ParaStation,项目名称:pscom,代码行数:60,代码来源:extoll_pp_velo.c
示例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);
}
开发者ID:JonBau,项目名称:pscom,代码行数:60,代码来源:dapl_pp.c
示例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);
}
开发者ID:ParaStation,项目名称:pscom,代码行数:59,代码来源:pscom_ondemand.c
示例4: 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);
}
开发者ID:stojadin,项目名称:oml,代码行数:58,代码来源:oml2-proxy-server.c
示例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;
}
开发者ID:ElijahLuk,项目名称:samba,代码行数:57,代码来源:getdc.c
示例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;
}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:56,代码来源:share_del.c
示例7: main
int main(int argc, char *argv[]){
char errbuf[PCAP_ERRBUF_SIZE], *device="any",*output_filename="/tmp/test.dump",*filter;
const char *tmp;
struct bpf_program fcode;
int count=0;
int timer=10;
int c;
poptContext context;
struct poptOption optionsTable[] = {
{"output", 'o', POPT_ARG_STRING, &output_filename, 'o'},
{"count", 'c', POPT_ARG_INT, &count, 'c'},
{"time", 't', POPT_ARG_INT, &timer, 't'},
{NULL,0,0,NULL,0}
};
context = poptGetContext(NULL, argc, (const char **) argv, optionsTable, 0);
poptSetOtherOptionHelp(context, "<tcpdump filter>");
while (poptGetNextOpt(context) >= 0) {}
filter = (char *)malloc(256);
strcpy (filter,"");
while ((tmp = poptGetArg(context))!=NULL) {
if (strcmp(filter,"")) filter = strcat(filter," ");
filter = strcat(filter,tmp);
}
if (strcmp(filter,"")==0) filter = "port 3306";
poptFreeContext(context);
printf("file=%s, count=%d, time=%d, filter=%s\n",output_filename,count,timer,filter);
signal(SIGTERM, cleanup);
signal(SIGALRM, cleanup);
signal(SIGINT, cleanup);
memset(errbuf,0,PCAP_ERRBUF_SIZE);
descr = pcap_open_live(device,BUFSIZ,0,100,errbuf);
if (descr == NULL) {
fprintf(stderr, "Couldn't open device %s: %s\n", device, errbuf);
return(2);
}
if (pcap_compile(descr, &fcode, filter, 0, 0) < 0){
fprintf(stderr,"can not analyze filter:%s\n", filter);
exit(1);
}
if (pcap_setfilter(descr,&fcode) == -1) {
fprintf(stderr, "filter can not use: %s\n", filter);
exit(1);
}
dumper = pcap_dump_open(descr,output_filename);
alarm(timer);
pcap_loop(descr,count,write_captured_packet,NULL);
pcap_close(descr);
pcap_dump_close(dumper);
exit(0);
}
开发者ID:junpei-yoshino,项目名称:dump4mkd,代码行数:52,代码来源:dump4mkd.c
示例8: main
/** Process command line arguements and decide how to proceed.
* Includes explanatory text for inline help and self-documentation.
*/
int main( int argc, char *argv[] )
{
int descend_flag = 0, hadoop_flag = 0, stats_flag = 0, verbose_flag = 0, json_flag = 0;
int count = 0, ret_val = 0;
g_dir_arg = "."; /// set the default directory argument to "here"
poptContext pc;
struct poptOption po[] = {
{"descend", 'd', POPT_ARG_NONE, &descend_flag, 0, UNIMPL"Parallelise and descend into subdirectories.", NULL},
{"stats", 's', POPT_ARG_NONE, &stats_flag, 0, "Print detailed statistics.", NULL},
{"verbose", 'v', POPT_ARG_NONE, &verbose_flag, 0, UNIMPL"Expand statistics output for each subdirectory.", NULL},
{"json", 'j', POPT_ARG_NONE, &json_flag, 0, UNIMPL"Write output in JSON format.", NULL},
POPT_AUTOHELP
POPT_TABLEEND
};
pc = poptGetContext(NULL, argc, (const char **)argv, po, 0);
poptSetOtherOptionHelp(pc, "[directory]");
while ( (count = poptGetNextOpt(pc) ) >= 0 ) {
printf("poptGetNextOpt return val %d\n", count);
}
for ( count = 0 ; poptPeekArg(pc) != NULL ; ++count ) {
asprintf(&g_dir_arg, (char*)poptGetArg(pc));
if ( count > 0 ) {
poptPrintUsage(pc, stderr, 0);
goto EXITNOW;
}
}
if ( descend_flag + hadoop_flag + stats_flag + verbose_flag + json_flag > 5 ) {
poptPrintUsage(pc, stderr, 0);
goto EXITNOW;
} else {
if ( descend_flag != POPT_ARG_NONE ) printf("%s: %s %s\n", PROGNAME, UNIMPL, "descend");
else if ( stats_flag != POPT_ARG_NONE ) ret_val = getdirent(g_dir_arg);
else if ( verbose_flag != POPT_ARG_NONE ) printf("%s: %s %s\n", PROGNAME, UNIMPL, "verbose");
else if ( json_flag != POPT_ARG_NONE ) printf("%s: %s %s\n", PROGNAME, UNIMPL, "json");
else ret_val = quickcount(g_dir_arg);
}
if ( ret_val == 0 ) {
exit(EXIT_SUCCESS);
} else {
goto EXITNOW;
}
EXITNOW:
exit(EXIT_FAILURE);
}
开发者ID:wgdavies,项目名称:fs-utils,代码行数:54,代码来源:fsls.c
示例9: show_help
/* Show program help. */
static void show_help (poptContext ctx)
{
size_t ix;
show_banner ();
poptSetOtherOptionHelp (ctx, mocp_summary);
poptPrintHelp (ctx, stdout, 0);
printf ("\nEnvironment variables:\n\n");
for (ix = 0; ix < ARRAY_SIZE(environment_variables); ix += 1)
printf (" %-34s%s\n", environment_variables[ix].name,
environment_variables[ix].desc);
printf ("\n");
}
开发者ID:mir-ror,项目名称:moc,代码行数:15,代码来源:main.c
示例10: 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;
}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:48,代码来源:split_tokens.c
示例11: main
int main(int argc, const char *argv[])
{
int c;
char
*fetch = NULL,
*convert = NULL;
poptContext pc;
struct poptOption options[] = {
USERLAND_RESERVED_OPTIONS
{"fetch", 'f', POPT_ARG_STRING, &fetch, 0, "Fetch all wav files or specified wav file from the Palm", "[file|all]"},
{"convert", 'c', POPT_ARG_STRING, &convert, 0, "Convert <file>.wav.pdb file to wav", "file"},
POPT_TABLEEND
};
pc = poptGetContext("pilot-wav", argc, argv, options, 0);
poptSetOtherOptionHelp(pc,"\n\n"
" Decodes Palm Voice Memo files to wav files you can read\n\n"
" Example arguments: \n"
" pilot-wav -p /dev/pilot -f MyVoiceMemo.wav.pdb\n"
" pilot-wav -c MyVoiceMemo.wav.pdb\n\n");
if (argc < 2 ) {
poptPrintUsage(pc,stderr,0);
return 1;
}
while ((c = poptGetNextOpt(pc)) >= 0) {
fprintf(stderr," ERROR: Unhandled option %d.\n",c);
return 1;
}
if (c < -1) {
plu_badoption(pc,c);
}
if(convert != NULL)
pdb_to_wav(convert);
if(fetch != NULL)
do_fetch(fetch);
return 0;
}
开发者ID:jichu4n,项目名称:pilot-link,代码行数:47,代码来源:pilot-wav.c
示例12: g_new0
AirOptionCtx *air_option_context_new(
const char *helpstr,
int *argc,
char ***argv,
AirOptionEntry *entries)
{
AirOptionCtx *aoctx;
#if USE_GOPTION
GOptionContext *octx = NULL;
#elif USE_POPT
poptContext octx = NULL;
int i = 0;
#endif
aoctx = g_new0(AirOptionCtx, 1);
#if USE_GOPTION
octx = g_option_context_new(helpstr);
if (entries) {
g_option_context_add_main_entries(octx, entries, NULL);
}
#elif USE_POPT
aoctx->options = g_array_sized_new(TRUE, TRUE, sizeof(AirOptionEntry), 64);
if (entries) {
for (i=0; !AF_OPTION_EMPTY(entries[i]); i++) {
g_array_append_val(aoctx->options, entries[i]);
}
}
octx = poptGetContext(NULL, *argc, (const char **) *argv,
(AirOptionEntry *) aoctx->options->data, 0);
poptSetOtherOptionHelp(octx, helpstr);
#endif
aoctx->argc = argc;
aoctx->argv = argv;
aoctx->octx = octx;
return aoctx;
}
开发者ID:aming2007,项目名称:dpi-test-suite,代码行数:41,代码来源:airopt.c
示例13: process_options
poptContext process_options(int argc, const char **argv,
struct poptOption *options,
const char *help)
{
int c;
poptContext opts = poptGetContext(NULL, argc, argv, options, 0);
poptSetOtherOptionHelp(opts, help);
while ((c = poptGetNextOpt(opts)) >= 0) {
/* no options require explicit handling */
}
if (c < -1) {
fprintf(stderr, "%s: %s\n",
poptBadOption(opts, POPT_BADOPTION_NOALIAS),
poptStrerror(c));
poptPrintUsage(opts, stderr, 0);
exit(1);
}
return opts;
}
开发者ID:7tomek,项目名称:librabbitmqc,代码行数:22,代码来源:common.c
示例14: poptSetOtherOptionHelp
bool Utils::parse(const poptContext& pc)
{ // http://privatemisc.blogspot.com/2012/12/popt-basic-example.html
poptSetOtherOptionHelp(pc, "[ARG...]");
// process options and handle each val returned
int val;
while ((val = poptGetNextOpt(pc)) >= 0)
{
}
// poptGetNextOpt returns -1 when the final argument has been parsed
if (val != -1)
{
poptPrintUsage(pc, stderr, 0);
// handle error
switch (val)
{
case POPT_ERROR_NOARG:
printf("Argument expected but missing for an option.\n");
return false;
case POPT_ERROR_BADOPT:
printf("Failed to parse argument.\n");
return false;
case POPT_ERROR_BADNUMBER:
case POPT_ERROR_OVERFLOW:
printf("Option could not be converted to number\n");
return false;
default:
printf("Unknown error in option processing\n");
return false;
}
}
poptFreeContext(pc);
return true;
}
开发者ID:Jesse-V,项目名称:OnioNS-common,代码行数:37,代码来源:Utils.cpp
示例15: main
int main(int argc, const char **argv)
{
poptContext pc;
int opt;
struct tevent_context *evt_ctx;
struct messaging_context *msg_ctx;
static struct poptOption long_options[] = {
/* POPT_AUTOHELP */
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, help_options,
0, "Help options:", NULL },
{ "timeout", 't', POPT_ARG_INT, &timeout, 't',
"Set timeout value in seconds", "TIMEOUT" },
POPT_COMMON_SAMBA
POPT_TABLEEND
};
TALLOC_CTX *frame = talloc_stackframe();
int ret = 0;
load_case_tables();
setup_logging(argv[0], DEBUG_STDOUT);
/* Parse command line arguments using popt */
pc = poptGetContext(
"smbcontrol", argc, (const char **)argv, long_options, 0);
poptSetOtherOptionHelp(pc, "[OPTION...] <destination> <message-type> "
"<parameters>");
if (argc == 1)
usage(pc);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch(opt) {
case 't': /* --timeout */
break;
default:
fprintf(stderr, "Invalid option\n");
poptPrintHelp(pc, stderr, 0);
break;
}
}
/* We should now have the remaining command line arguments in
argv. The argc parameter should have been decremented to the
correct value in the above switch statement. */
argv = (const char **)poptGetArgs(pc);
argc = 0;
if (argv != NULL) {
while (argv[argc] != NULL) {
argc++;
}
}
if (argc <= 1)
usage(pc);
lp_load_global(get_dyn_CONFIGFILE());
/* Need to invert sense of return code -- samba
* routines mostly return True==1 for success, but
* shell needs 0. */
if (!(evt_ctx = tevent_context_init(NULL)) ||
!(msg_ctx = messaging_init(NULL, evt_ctx))) {
fprintf(stderr, "could not init messaging context\n");
TALLOC_FREE(frame);
exit(1);
}
ret = !do_command(evt_ctx, msg_ctx, argc, argv);
TALLOC_FREE(frame);
return ret;
}
开发者ID:srimalik,项目名称:samba,代码行数:78,代码来源:smbcontrol.c
示例16: main
int main(int argc, const char **argv)
{
poptContext pc;
int opt;
static struct poptOption wbinfo_options[] = {
{ "timeout", 't', POPT_ARG_INT, &timeout, 't',
"Set timeout value in seconds", "TIMEOUT" },
{ "configfile", 's', POPT_ARG_STRING, NULL, 's',
"Use alternative configuration file", "CONFIGFILE" },
POPT_TABLEEND
};
struct poptOption options[] = {
{ NULL, 0, POPT_ARG_INCLUDE_TABLE, wbinfo_options, 0,
"Options" },
POPT_AUTOHELP
POPT_COMMON_VERSION
POPT_TABLEEND
};
setup_logging(argv[0],True);
/* Parse command line arguments using popt */
pc = poptGetContext(
"smbcontrol", argc, (const char **)argv, options, 0);
poptSetOtherOptionHelp(pc, "[OPTION...] <destination> <message-type> "
"<parameters>");
if (argc == 1)
usage(&pc);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch(opt) {
case 't': /* --timeout */
argc -= 2;
break;
case 's': /* --configfile */
pstrcpy(dyn_CONFIGFILE, poptGetOptArg(pc));
argc -= 2;
break;
default:
fprintf(stderr, "Invalid option\n");
poptPrintHelp(pc, stderr, 0);
break;
}
}
/* We should now have the remaining command line arguments in
argv. The argc parameter should have been decremented to the
correct value in the above switch statement. */
argv = (const char **)poptGetArgs(pc);
argc--; /* Don't forget about argv[0] */
if (argc == 1)
usage(&pc);
lp_load(dyn_CONFIGFILE,False,False,False);
/* Need to invert sense of return code -- samba
* routines mostly return True==1 for success, but
* shell needs 0. */
return !do_command(argc, argv);
}
开发者ID:hajuuk,项目名称:R7000,代码行数:71,代码来源:smbcontrol.c
示例17: main
int main(int argc, const char **argv)
{
int ret = EXIT_SUCCESS;
struct tools_ctx *tctx = NULL;
const char *pc_username = NULL;
int pc_debug = SSSDBG_DEFAULT;
int pc_remove = 0;
int pc_force = 0;
int pc_kick = 0;
poptContext pc = NULL;
struct poptOption long_options[] = {
POPT_AUTOHELP
{ "debug", '\0', POPT_ARG_INT | POPT_ARGFLAG_DOC_HIDDEN, &pc_debug,
0, _("The debug level to run with"), NULL },
{ "remove", 'r', POPT_ARG_NONE, NULL, 'r',
_("Remove home directory and mail spool"), NULL },
{ "no-remove", 'R', POPT_ARG_NONE, NULL, 'R',
_("Do not remove home directory and mail spool"), NULL },
{ "force", 'f', POPT_ARG_NONE, NULL, 'f',
_("Force removal of files not owned by the user"), NULL },
{ "kick", 'k', POPT_ARG_NONE, NULL, 'k',
_("Kill users' processes before removing him"), NULL },
POPT_TABLEEND
};
debug_prg_name = argv[0];
ret = set_locale();
if (ret != EOK) {
DEBUG(1, ("set_locale failed (%d): %s\n", ret, strerror(ret)));
ERROR("Error setting the locale\n");
ret = EXIT_FAILURE;
goto fini;
}
/* parse parameters */
pc = poptGetContext(NULL, argc, argv, long_options, 0);
poptSetOtherOptionHelp(pc, "USERNAME");
while ((ret = poptGetNextOpt(pc)) > 0) {
switch (ret) {
case 'r':
pc_remove = DO_REMOVE_HOME;
break;
case 'R':
pc_remove = DO_NOT_REMOVE_HOME;
break;
case 'f':
pc_force = DO_FORCE_REMOVAL;
break;
case 'k':
pc_kick = 1;
break;
}
}
debug_level = debug_convert_old_level(pc_debug);
if (ret != -1) {
BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini);
}
pc_username = poptGetArg(pc);
if (pc_username == NULL) {
BAD_POPT_PARAMS(pc, _("Specify user to delete\n"), ret, fini);
}
CHECK_ROOT(ret, debug_prg_name);
ret = init_sss_tools(&tctx);
if (ret != EOK) {
DEBUG(1, ("init_sss_tools failed (%d): %s\n", ret, strerror(ret)));
if (ret == ENOENT) {
ERROR("Error initializing the tools - no local domain\n");
} else {
ERROR("Error initializing the tools\n");
}
ret = EXIT_FAILURE;
goto fini;
}
/* if the domain was not given as part of FQDN, default to local domain */
ret = parse_name_domain(tctx, pc_username);
if (ret != EOK) {
ERROR("Invalid domain specified in FQDN\n");
ret = EXIT_FAILURE;
goto fini;
}
/*
* Fills in defaults for ops_ctx user did not specify.
*/
ret = userdel_defaults(tctx, tctx->confdb, tctx->octx, pc_remove);
if (ret != EOK) {
ERROR("Cannot set default values\n");
ret = EXIT_FAILURE;
goto fini;
//.........这里部分代码省略.........
开发者ID:nguay,项目名称:SSSD,代码行数:101,代码来源:sss_userdel.c
示例18: main
/* int segs2name (poptContext *optCon, char **filename, int *seg_list); */
int main (int argc, char **argv)
{
int i, ret;
LorsExnode *exnode;
char *s;
char *output_filename = "-";
char *filename;
int same_name=0;
int v;
int file_cnt = 0;
int opts = LORS_MANAGE_CAP;
XndRc xndrc;
poptContext optCon; /* context for parsing command-line options */
struct poptOption optionsTable[] = {
{ "samename", 'f', POPT_ARG_NONE, 0, SAME_OUTPUTNAME,
"Save the modified exNode to the original exNode filename.", NULL },
{ "outputfile", 'o', POPT_ARG_STRING, &output_filename, OUTPUTNAME,
"Specify the name for the output exNode file.", NULL},
{ "read-cap", 'r', POPT_ARG_NONE, 0, LORS_READ_CAP,
"Delete the read capabilities from the exNode.", NULL},
{ "write-cap", 'w', POPT_ARG_NONE, 0, LORS_WRITE_CAP,
"Delete the write capabilities from the exNode.", NULL},
{ "manage-cap", 'm', POPT_ARG_NONE, 0, LORS_MANAGE_CAP,
"Delete the manage capabilities from the exNode.", NULL},
{ "version", 'v', POPT_ARG_NONE, 0, LORS_VERSION,
"Display Version information about this package.", NULL},
{ "verbose", 'V', POPT_ARG_INT, &xndrc.verbose, VERBOSE,
"Modify the level or mode of Verbosity in output messages.", "0"},
/* { "demo", 'D', POPT_ARG_NONE, 0, LORS_ARG_DEMO,
"Add the messages understood by the LoRS View visualization.", NULL}, */
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0 }
};
parse_xndrc_files(&xndrc);
g_lors_demo = xndrc.demo;
optCon = poptGetContext(NULL, argc, (const char **)argv, optionsTable, 0);
poptSetOtherOptionHelp(optCon, "<filename>");
if ( argc < 2 )
{
poptPrintUsage(optCon, stderr, 0);
poptPrintHelp(optCon, stderr, 0);
exit(EXIT_FAILURE);
}
while ( (v=poptGetNextOpt(optCon)) >= 0)
{
switch(v)
{
case LORS_READ_CAP:
case LORS_WRITE_CAP:
case LORS_MANAGE_CAP:
opts |= v;
break;
case SAME_OUTPUTNAME:
same_name = 1;
break;
case LORS_ARG_DEMO:
g_lors_demo = (!g_lors_demo);
break;
case LORS_VERSION:
{
const char *package;
double version;
lorsGetLibraryVersion(&package, &version);
fprintf(stderr, "Version: %s %f\n", package, version);
exit(EXIT_FAILURE);
break;
}
default:
/*fprintf(stderr, "Unsupported option: %d\n", v);*/
break;
}
}
g_db_level = xndrc.verbose;
if ( v < -1 )
{
fprintf(stderr, "error: %d\n", v);
fprintf(stderr, "%s: %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(v));
}
while ( (filename = (char *)poptGetArg(optCon)) != NULL )
{
file_cnt++;
/* output_filename= NULL;*/
if (same_name == 1) output_filename = filename;
ret = lorsModifyFile(filename, output_filename, opts);
if ( ret != LORS_SUCCESS )
{
fprintf(stderr, "An error occured during modify: %d\n", ret);
}
}
if ( file_cnt == 0 )
{
//.........这里部分代码省略.........
开发者ID:LogisticalComputingAndInternetworking,项目名称:LoRS,代码行数:101,代码来源:lors_modify.c
示例19: main
int main(int argc, const char **argv)
{
NET_API_STATUS status;
struct libnetapi_ctx *ctx = NULL;
const char *hostname = NULL;
uint32_t level = 0;
uint8_t *buffer = NULL;
uint32_t entries_read = 0;
uint32_t total_entries = 0;
uint32_t resume_handle = 0;
int i;
struct SHARE_INFO_0 *i0 = NULL;
struct SHARE_INFO_1 *i1 = NULL;
struct SHARE_INFO_2 *i2 = 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_enum", argc, argv, long_options, 0);
poptSetOtherOptionHelp(pc, "hostname level");
while((opt = poptGetNextOpt(pc)) != -1) {
}
if (!poptPeekArg(pc)) {
poptPrintHelp(pc, stderr, 0);
goto out;
}
hostname = poptGetArg(pc);
if (poptPeekArg(pc)) {
level = atoi(poptGetArg(pc));
}
/* NetShareEnum */
do {
status = NetShareEnum(hostname,
level,
&buffer,
(uint32_t)-1,
&entries_read,
&total_entries,
&resume_handle);
if (status == 0 || status == ERROR_MORE_DATA) {
printf("total entries: %d\n", total_entries);
switch (level) {
case 0:
i0 = (struct SHARE_INFO_0 *)buffer;
break;
case 1:
i1 = (struct SHARE_INFO_1 *)buffer;
break;
case 2:
i2 = (struct SHARE_INFO_2 *)buffer;
break;
default:
break;
}
for (i=0; i<entries_read; i++) {
switch (level) {
case 0:
printf("#%d netname: %s\n", i, i0->shi0_netname);
i0++;
break;
case 1:
printf("#%d netname: %s\n", i, i1->shi1_netname);
printf("#%d type: %d\n", i, i1->shi1_type);
printf("#%d remark: %s\n", i, i1->shi1_remark);
i1++;
break;
case 2:
printf("#%d netname: %s\n", i, i2->shi2_netname);
printf("#%d type: %d\n", i, i2->shi2_type);
printf("#%d remark: %s\n", i, i2->shi2_remark);
printf("#%d permissions: %d\n", i, i2->shi2_permissions);
printf("#%d max users: %d\n", i, i2->shi2_max_uses);
printf("#%d current users: %d\n", i, i2->shi2_current_uses);
printf("#%d path: %s\n", i, i2->shi2_path);
printf("#%d password: %s\n", i, i2->shi2_passwd);
i2++;
break;
default:
break;
}
}
NetApiBufferFree(buffer);
}
//.........这里部分代码省略.........
开发者ID:0x24bin,项目名称:winexe-1,代码行数:101,代码来源:share_enum.c
示例20: 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;
const char *comment = "NetApi generated Share comment";
uint32_t level = 1004;
uint8_t *buffer = NULL;
uint32_t parm_err = 0;
struct SHARE_INFO_1004 i1004;
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_setinfo", argc, argv, long_options, 0);
poptSetOtherOptionHelp(pc, "hostname sharename comment");
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);
if (poptPeekArg(pc)) {
comment = poptGetArg(pc);
}
/* NetShareSetInfo */
switch (level) {
case 1004:
i1004.shi1004_remark = comment;
buffer = (uint8_t *)&i1004;
break;
default:
break;
}
status = NetShareSetInfo(hostname,
sharename,
level,
buffer,
&parm_err);
if (status != 0) {
printf("NetShareSetInfo failed with: %s\n",
libnetapi_get_error_string(ctx, status));
goto out;
}
out:
libnetapi_free(ctx);
poptFreeContext(pc);
return status;
}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:76,代码来源:share_setinfo.c
注:本文中的poptSetOtherOptionHelp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论