本文整理汇总了C++中opt_init函数的典型用法代码示例。如果您正苦于以下问题:C++ opt_init函数的具体用法?C++ opt_init怎么用?C++ opt_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了opt_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: opt_init
/* duck: search duckduckgo with a query string */
int CmdHandler::duck(char *out, struct command *c)
{
char query[MAX_MSG];
int opt;
static struct l_option long_opts[] = {
{ "help", NO_ARG, 'h' },
{ 0, 0, 0 }
};
opt_init();
while ((opt = l_getopt_long(c->argc, c->argv, "", long_opts)) != EOF) {
switch (opt) {
case 'h':
HELPMSG(out, CMDNAME, CMDUSAGE, CMDDESCR);
return EXIT_SUCCESS;
case '?':
snprintf(out, MAX_MSG, "%s", l_opterr());
return EXIT_FAILURE;
default:
return EXIT_FAILURE;
}
}
if (l_optind == c->argc) {
USAGEMSG(out, CMDNAME, CMDUSAGE);
return EXIT_FAILURE;
}
argvcat(query, c->argc, c->argv, l_optind, 1);
snprintf(out, MAX_MSG, "[DUCK] %s%s", DDG_QUERY, tw::pencode(query).c_str());
return EXIT_SUCCESS;
}
开发者ID:frolv,项目名称:lynxbot,代码行数:33,代码来源:duck.cpp
示例2: option_table_create
/*
* Create getopt_long(3) option table and return.
* Also create shortopts table if sp != NULL and return by value.
*/
static struct option * option_table_create (optparse_t p, char **sp)
{
struct option_info *o;
struct option *opts;
int n;
int j;
ListIterator i;
n = list_count (p->option_list);
opts = malloc ((n + 1) * sizeof (struct option));
if (opts == NULL)
return (NULL);
j = 0;
i = list_iterator_create (p->option_list);
while ((o = list_next (i))) {
if (o->isdoc)
continue;
/* Initialize option field from cached option structure */
opt_init (&opts[j++], o->p_opt);
if (sp) {
*sp = optstring_append (*sp, o->p_opt);
if (*sp == NULL) {
free (opts);
opts = NULL;
break;
}
}
}
list_iterator_destroy (i);
return (opts);
}
开发者ID:surajpkn,项目名称:flux-core,代码行数:38,代码来源:optparse.c
示例3: opt_init
/* active: view current poll */
int CmdHandler::active(char *out, struct command *c)
{
int opt;
static struct l_option long_opts[] = {
{ "help", NO_ARG, 'h' },
{ 0, 0, 0 }
};
opt_init();
while ((opt = l_getopt_long(c->argc, c->argv, "", long_opts)) != EOF) {
switch (opt) {
case 'h':
HELPMSG(out, CMDNAME, CMDUSAGE, CMDDESCR);
return EXIT_SUCCESS;
case '?':
snprintf(out, MAX_MSG, "%s", l_opterr());
return EXIT_FAILURE;
default:
return EXIT_FAILURE;
}
}
if (l_optind != c->argc) {
USAGEMSG(out, CMDNAME, CMDUSAGE);
return EXIT_FAILURE;
}
if (!*poll)
snprintf(out, MAX_MSG, "[ACTIVE] no poll has been created");
else
snprintf(out, MAX_MSG, "[ACTIVE] %s/%s", SP_HOST, poll);
return EXIT_SUCCESS;
}
开发者ID:frolv,项目名称:lynxbot,代码行数:34,代码来源:active.cpp
示例4: main
int main(int argc,char** argv)
{
//load config
configure conf(conf_path);
conf.parse_config_file();
//conf.load_from_db(); //从远程数据库加载参数
conf.load_from_url(); //从远程url加载参数
//conf.debug_print();
//parse opt
if(!opt_init(argc,argv,conf))
return 0;
//load module manager
modmgr mgr(&conf);
mgr.load_modules(conf.modules_path);
//mgr.print_modules();
//start
switch(conf.run_state)
{
case RUN_CRON:
run_cron(conf,mgr);
break;
case RUN_LIVE:
run_live(conf,mgr);
break;
case RUN_NULL:
break;
}
return 0;
}
开发者ID:lcplj123,项目名称:zebra,代码行数:32,代码来源:zebra.cpp
示例5: parse_opts
static int parse_opts(int argc, char** argv, options_t* opt)
{
opt_state_t s;
int id;
opt_init(args, &s, &argc, argv);
while((id = opt_next(&s)) != -1)
{
switch(id)
{
case OPT_THREADS: opt->threads = atoi(s.arg_val); break;
case OPT_CDMIN: opt->cd_min_deferred = atoi(s.arg_val); break;
case OPT_CDMAX: opt->cd_max_deferred = atoi(s.arg_val); break;
case OPT_CDCONF: opt->cd_conf_group = atoi(s.arg_val); break;
case OPT_GCINITIAL: opt->gc_initial = atoi(s.arg_val); break;
case OPT_GCFACTOR: opt->gc_factor = atof(s.arg_val); break;
case OPT_SCHED:
if(!strcmp(s.arg_val, "coop"))
opt->mpmcq = false;
else if(!strcmp(s.arg_val, "mpmcq"))
opt->mpmcq = true;
break;
case OPT_NOYIELD: opt->noyield = true; break;
case OPT_FORCECD: opt->forcecd = true; break;
default: exit(-1);
}
}
argv[argc] = NULL;
return argc;
}
开发者ID:ozra,项目名称:ponyc,代码行数:32,代码来源:start.c
示例6: bpf_optimize
/*
* Optimize the filter code in its dag representation.
*/
void
bpf_optimize(struct block **rootp)
{
struct block *root;
root = *rootp;
opt_init(root);
opt_loop(root, 0);
opt_loop(root, 1);
intern_blocks(root);
#ifdef BDEBUG
if (dflag > 1) {
printf("after intern_blocks()\n");
opt_dump(root);
}
#endif
opt_root(rootp);
#ifdef BDEBUG
if (dflag > 1) {
printf("after opt_root()\n");
opt_dump(root);
}
#endif
opt_cleanup();
}
开发者ID:enukane,项目名称:netbsd-src,代码行数:29,代码来源:optimize.c
示例7: genrsa_main
int genrsa_main(int argc, char **argv)
{
BN_GENCB *cb = BN_GENCB_new();
PW_CB_DATA cb_data;
ENGINE *eng = NULL;
BIGNUM *bn = BN_new();
BIO *out = NULL;
BIGNUM *e;
RSA *rsa = NULL;
const EVP_CIPHER *enc = NULL;
int ret = 1, num = DEFBITS, private = 0;
unsigned long f4 = RSA_F4;
char *outfile = NULL, *passoutarg = NULL, *passout = NULL;
char *inrand = NULL, *prog, *hexe, *dece;
OPTION_CHOICE o;
if (bn == NULL || cb == NULL)
goto end;
BN_GENCB_set(cb, genrsa_cb, bio_err);
prog = opt_init(argc, argv, genrsa_options);
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_EOF:
case OPT_ERR:
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
goto end;
case OPT_HELP:
ret = 0;
opt_help(genrsa_options);
goto end;
case OPT_3:
f4 = 3;
break;
case OPT_F4:
f4 = RSA_F4;
break;
case OPT_OUT:
outfile = opt_arg();
break;
case OPT_ENGINE:
eng = setup_engine(opt_arg(), 0);
break;
case OPT_RAND:
inrand = opt_arg();
break;
case OPT_PASSOUT:
passoutarg = opt_arg();
break;
case OPT_CIPHER:
if (!opt_cipher(opt_unknown(), &enc))
goto end;
break;
}
}
argc = opt_num_rest();
argv = opt_rest();
private = 1;
开发者ID:ArmanIzad,项目名称:openssl,代码行数:59,代码来源:genrsa.c
示例8: john_init
static void john_init(char *name, int argc, char **argv)
{
int make_check = (argc == 2 && !strcmp(argv[1], "--make_check"));
if (make_check)
argv[1] = "--test=0";
#if CPU_DETECT
if (!CPU_detect()) {
#if CPU_REQ
#if CPU_FALLBACK
#if defined(__DJGPP__) || defined(__CYGWIN32__)
#error CPU_FALLBACK is incompatible with the current DOS and Win32 code
#endif
if (!make_check) {
#define CPU_FALLBACK_PATHNAME JOHN_SYSTEMWIDE_EXEC "/" CPU_FALLBACK_BINARY
execv(CPU_FALLBACK_PATHNAME, argv);
perror("execv: " CPU_FALLBACK_PATHNAME);
}
#endif
fprintf(stderr, "Sorry, %s is required\n", CPU_NAME);
if (make_check)
exit(0);
error();
#endif
}
#endif
if (!make_check) {
path_init(argv);
status_init(NULL, 1);
opt_init(name, argc, argv);
if (options.flags & FLG_CONFIG_CLI)
{
cfg_init(options.config, 1);
cfg_init(CFG_ALT_NAME, 0);
}
else
{
#if JOHN_SYSTEMWIDE
cfg_init(CFG_PRIVATE_FULL_NAME, 1);
cfg_init(CFG_PRIVATE_ALT_NAME, 1);
#endif
cfg_init(CFG_FULL_NAME, 1);
cfg_init(CFG_ALT_NAME, 0);
}
}
john_register_all();
common_init();
sig_init();
john_load();
}
开发者ID:earthquake,项目名称:GI-John,代码行数:56,代码来源:john.c
示例9: help_main
int help_main(int argc, char **argv)
{
FUNCTION *fp;
int i, nl;
FUNC_TYPE tp;
char *prog;
HELP_CHOICE o;
DISPLAY_COLUMNS dc;
prog = opt_init(argc, argv, help_options);
while ((o = opt_next()) != OPT_hEOF) {
switch (o) {
case OPT_hERR:
case OPT_hEOF:
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
return 1;
case OPT_hHELP:
opt_help(help_options);
return 0;
}
}
if (opt_num_rest() != 0) {
BIO_printf(bio_err, "Usage: %s\n", prog);
return 1;
}
calculate_columns(&dc);
BIO_printf(bio_err, "Standard commands");
i = 0;
tp = FT_none;
for (fp = functions; fp->name != NULL; fp++) {
nl = 0;
if (i++ % dc.columns == 0) {
BIO_printf(bio_err, "\n");
nl = 1;
}
if (fp->type != tp) {
tp = fp->type;
if (!nl)
BIO_printf(bio_err, "\n");
if (tp == FT_md) {
i = 1;
BIO_printf(bio_err,
"\nMessage Digest commands (see the `dgst' command for more details)\n");
} else if (tp == FT_cipher) {
i = 1;
BIO_printf(bio_err,
"\nCipher commands (see the `enc' command for more details)\n");
}
}
BIO_printf(bio_err, "%-*s", dc.width, fp->name);
}
BIO_printf(bio_err, "\n\n");
return 0;
}
开发者ID:Bilibili,项目名称:openssl,代码行数:56,代码来源:openssl.c
示例10: help_main
int help_main(int argc, char **argv)
{
FUNCTION *fp;
int i, nl;
FUNC_TYPE tp;
char *prog;
HELPLIST_CHOICE o;
prog = opt_init(argc, argv, help_options);
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
default:
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
return 1;
case OPT_HELP:
opt_help(help_options);
return 0;
}
}
argc = opt_num_rest();
argv = opt_rest();
if (argc != 0) {
BIO_printf(bio_err, "Usage: %s\n", prog);
return 1;
}
BIO_printf(bio_err, "\nStandard commands");
i = 0;
tp = FT_none;
for (fp = functions; fp->name != NULL; fp++) {
nl = 0;
if (((i++) % COLUMNS) == 0) {
BIO_printf(bio_err, "\n");
nl = 1;
}
if (fp->type != tp) {
tp = fp->type;
if (!nl)
BIO_printf(bio_err, "\n");
if (tp == FT_md) {
i = 1;
BIO_printf(bio_err,
"\nMessage Digest commands (see the `dgst' command for more details)\n");
} else if (tp == FT_cipher) {
i = 1;
BIO_printf(bio_err,
"\nCipher commands (see the `enc' command for more details)\n");
}
}
BIO_printf(bio_err, FORMAT, fp->name);
}
BIO_printf(bio_err, "\n\n");
return 0;
}
开发者ID:NTASTE,项目名称:openssl,代码行数:55,代码来源:openssl.c
示例11: list_main
int list_main(int argc, char **argv)
{
char *prog;
HELPLIST_CHOICE o;
int done = 0;
prog = opt_init(argc, argv, list_options);
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_EOF: /* Never hit, but suppresses warning */
case OPT_ERR:
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
return 1;
case OPT_HELP:
opt_help(list_options);
break;
case OPT_COMMANDS:
list_type(FT_general);
break;
case OPT_DIGEST_COMMANDS:
list_type(FT_md);
break;
case OPT_DIGEST_ALGORITHMS:
EVP_MD_do_all_sorted(list_md_fn, bio_out);
break;
case OPT_CIPHER_COMMANDS:
list_type(FT_cipher);
break;
case OPT_CIPHER_ALGORITHMS:
EVP_CIPHER_do_all_sorted(list_cipher_fn, bio_out);
break;
case OPT_PK_ALGORITHMS:
list_pkey();
break;
case OPT_PK_METHOD:
list_pkey_meth();
break;
case OPT_DISABLED:
list_disabled();
break;
case OPT_MISSING_HELP:
list_missing_help();
break;
}
done = 1;
}
if (!done) {
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
return 1;
}
return 0;
}
开发者ID:Vonage,项目名称:openssl,代码行数:54,代码来源:openssl.c
示例12: main
int main(int ac, char **av)
{
OPTION_CHOICE o;
char **rest;
char *prog;
bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
prog = opt_init(ac, av, options);
while ((o = opt_next()) != OPT_EOF) {
switch (c) {
case OPT_NOTUSED:
case OPT_EOF:
case OPT_ERR:
printf("%s: Usage error; try -help.\n", prog);
return 1;
case OPT_HELP:
opt_help(options);
return 0;
case OPT_IN:
printf("in %s\n", opt_arg());
break;
case OPT_INFORM:
printf("inform %s\n", opt_arg());
break;
case OPT_OUT:
printf("out %s\n", opt_arg());
break;
case OPT_COUNT:
printf("count %s\n", opt_arg());
break;
case OPT_U:
printf("u %s\n", opt_arg());
break;
case OPT_FLAG:
printf("flag\n");
break;
case OPT_STR:
printf("str %s\n", opt_arg());
break;
}
}
argc = opt_num_rest();
argv = opt_rest();
printf("args = %d\n", argc);
if (argc)
while (*argv)
printf(" %s\n", *argv++);
return 0;
}
开发者ID:mtrojnar,项目名称:openssl,代码行数:51,代码来源:opt.c
示例13: main
/**
@brief AutoBuilder Entry Point
@param argc Number of arguments passed through argv
@param argv String representation of arguments passed to the
application
@return EXIT_SUCCESS on success or a non-zero integer on failure.
**/
int
main (int argc, char ** argv)
{
conf_t conf;
conf_err_t cerr;
opt_t opt;
opt_err_t oerr;
const char *db_type, *db_host, *db_port, *db_user, *db_pass, *db_db;
/* Parse the command line */
oerr = opt_init(&opt, argc, argv, 1);
if (oerr != OPT_OK)
{
fprintf (stderr, "%s\n", SHORT_HELP);
opt_destroy (&opt);
return EXIT_FAILURE;
}
if (opt.help)
{
fprintf (stderr, "%s\n", HELP_TXT);
return EXIT_SUCCESS;
}
/* Parse the configuration */
cerr = conf_init (&conf, opt.conf);
if (cerr != CONF_OK)
{
fprintf (stderr, "Configuration Error: %s", conf_get_err (&conf));
conf_destroy (&conf);
opt_destroy (&opt);
return EXIT_FAILURE;
}
/* Read Database Options */
db_type = conf_get (&conf, "DB_TYPE");
db_host = conf_get (&conf, "DB_HOST");
db_port = conf_get (&conf, "DB_PORT");
db_user = conf_get (&conf, "DB_USER");
db_pass = conf_get (&conf, "DB_PASS");
db_db = conf_get (&conf, "DB_DB");
/* Connect to the database */
//db_connect (db_type, db_host, db_port, db_user, db_pass, db_db);
/* Cleanup */
conf_destroy (&conf);
opt_destroy (&opt);
return EXIT_SUCCESS;
}
开发者ID:wkennington,项目名称:build,代码行数:57,代码来源:main.c
示例14: opt_init
/* about: print bot information */
int CmdHandler::about(char *out, struct command *c)
{
int opt, type;
static struct l_option long_opts[] = {
{ "help", NO_ARG, 'h' },
{ "latest-release", NO_ARG, 'r' },
{ "source", NO_ARG, 's' },
{ 0, 0, 0 }
};
opt_init();
type = ABT;
while ((opt = l_getopt_long(c->argc, c->argv, "rs", long_opts)) != EOF) {
switch (opt) {
case 'h':
HELPMSG(out, CMDNAME, CMDUSAGE, CMDDESCR);
return EXIT_SUCCESS;
case 'r':
type = REL;
break;
case 's':
type = SRC;
break;
case '?':
snprintf(out, MAX_MSG, "%s", l_opterr());
return EXIT_FAILURE;
default:
return EXIT_FAILURE;
}
}
if (l_optind != c->argc) {
USAGEMSG(out, CMDNAME, CMDUSAGE);
return EXIT_FAILURE;
}
switch (type) {
case REL:
case SRC:
snprintf(out, MAX_MSG, "[ABOUT] %s",
type == REL ? RELEASE : SOURCE);
break;
default:
snprintf(out, MAX_MSG, "[ABOUT] %s is running " BOT_NAME
" " BOT_VERSION ". Find out more at "
BOT_WEBSITE, bot_name);
break;
}
return EXIT_SUCCESS;
}
开发者ID:frolv,项目名称:lynxbot,代码行数:51,代码来源:about.cpp
示例15: gendsa_main
int gendsa_main(int argc, char **argv)
{
ENGINE *e = NULL;
BIO *out = NULL, *in = NULL;
DSA *dsa = NULL;
const EVP_CIPHER *enc = NULL;
char *dsaparams = NULL;
char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
OPTION_CHOICE o;
int ret = 1, private = 0, verbose = 0;
const BIGNUM *p = NULL;
prog = opt_init(argc, argv, gendsa_options);
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_EOF:
case OPT_ERR:
opthelp:
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
goto end;
case OPT_HELP:
ret = 0;
opt_help(gendsa_options);
goto end;
case OPT_OUT:
outfile = opt_arg();
break;
case OPT_PASSOUT:
passoutarg = opt_arg();
break;
case OPT_ENGINE:
e = setup_engine(opt_arg(), 0);
break;
case OPT_R_CASES:
if (!opt_rand(o))
goto end;
break;
case OPT_CIPHER:
if (!opt_cipher(opt_unknown(), &enc))
goto end;
break;
case OPT_VERBOSE:
verbose = 1;
break;
}
}
argc = opt_num_rest();
argv = opt_rest();
private = 1;
开发者ID:akamai,项目名称:openssl,代码行数:49,代码来源:gendsa.c
示例16: opt_init
/* cgrep: find commands matching a pattern */
int CmdHandler::cgrep(char *out, struct command *c)
{
int opt;
static struct l_option long_opts[] = {
{ "active", NO_ARG, 'a' },
{ "custom", NO_ARG, 'c' },
{ "default", NO_ARG, 'd' },
{ "help", NO_ARG, 'h' },
{ "ignore-case", NO_ARG, 'i' },
{ 0, 0, 0 }
};
opt_init();
act = ign = 0;
type = ALL;
while ((opt = l_getopt_long(c->argc, c->argv, "acdi",
long_opts)) != EOF) {
switch (opt) {
case 'a':
act = 1;
break;
case 'c':
type = CUSTOM;
break;
case 'd':
type = DEFAULT;
break;
case 'h':
HELPMSG(out, CMDNAME, CMDUSAGE, CMDDESCR);
return EXIT_SUCCESS;
case 'i':
ign = 1;
break;
case '?':
snprintf(out, MAX_MSG, "%s", l_opterr());
return EXIT_FAILURE;
default:
return EXIT_FAILURE;
}
}
if (l_optind != c->argc - 1) {
USAGEMSG(out, CMDNAME, CMDUSAGE);
return EXIT_FAILURE;
}
return findcmds(out, &default_cmds, custom_cmds->commands(),
c->argv[l_optind]);
}
开发者ID:frolv,项目名称:lynxbot,代码行数:50,代码来源:cgrep.cpp
示例17: main
int
main(int argc, char **argv) {
setprogname(argv[0]);
opt_struct opt;
opt_init(&opt);
parse_option(argc,argv,&opt);
//argc -= optind;
//argv += optind;
do_sws(&opt);
return EXIT_SUCCESS;
}
开发者ID:todatamining,项目名称:db1,代码行数:16,代码来源:main.c
示例18: PERM_DENIED
/* strawpoll: create polls */
int CmdHandler::strawpoll(char *out, struct command *c)
{
int opt;
static struct l_option long_opts[] = {
{ "binary", NO_ARG, 'b' },
{ "captcha", NO_ARG, 'c' },
{ "help", NO_ARG, 'h' },
{ "multi", NO_ARG, 'm' },
{ 0, 0, 0 }
};
if (!P_ALMOD(c->privileges)) {
PERM_DENIED(out, c->nick, c->argv[0]);
return EXIT_FAILURE;
}
opt_init();
binary = captcha = multi = false;
while ((opt = l_getopt_long(c->argc, c->argv, "bcm", long_opts)) != EOF) {
switch (opt) {
case 'b':
binary = true;
break;
case 'c':
captcha = true;
break;
case 'h':
HELPMSG(out, CMDNAME, CMDUSAGE, CMDDESCR);
return EXIT_SUCCESS;
case 'm':
multi = true;
break;
case '?':
snprintf(out, MAX_MSG, "%s", l_opterr());
return EXIT_FAILURE;
default:
return EXIT_FAILURE;
}
}
if (l_optind == c->argc) {
USAGEMSG(out, CMDNAME, CMDUSAGE);
return EXIT_FAILURE;
}
return create_poll(out, poll, c);
}
开发者ID:frolv,项目名称:lynxbot,代码行数:48,代码来源:strawpoll.cpp
示例19: errstr_main
int errstr_main(int argc, char **argv)
{
OPTION_CHOICE o;
char buf[256], *prog;
int ret = 1;
unsigned long l;
prog = opt_init(argc, argv, errstr_options);
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_EOF:
case OPT_ERR:
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
goto end;
case OPT_HELP:
opt_help(errstr_options);
ret = 0;
goto end;
case OPT_STATS:
lh_ERR_STRING_DATA_node_stats_bio(ERR_get_string_table(),
bio_out);
lh_ERR_STRING_DATA_stats_bio(ERR_get_string_table(), bio_out);
lh_ERR_STRING_DATA_node_usage_stats_bio(ERR_get_string_table(),
bio_out);
ret = 0;
goto end;
}
}
ret = 0;
for (argv = opt_rest(); *argv; argv++) {
if (sscanf(*argv, "%lx", &l) == 0)
ret++;
else {
/* We're not really an SSL application so this won't auto-init, but
* we're still interested in SSL error strings
*/
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS
| OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
ERR_error_string_n(l, buf, sizeof buf);
BIO_printf(bio_out, "%s\n", buf);
}
}
end:
return (ret);
}
开发者ID:XuLei123456789,项目名称:openssl,代码行数:46,代码来源:errstr.c
示例20: opt_init
/* man: view command reference manuals */
int CmdHandler::man(char *out, struct command *c)
{
Json::Value *ccmd;
char url[MAX_URL];
int opt;
static struct l_option long_opts[] = {
{ "help", NO_ARG, 'h' },
{ 0, 0, 0 }
};
opt_init();
while ((opt = l_getopt_long(c->argc, c->argv, "", long_opts)) != EOF) {
switch (opt) {
case 'h':
HELPMSG(out, CMDNAME, CMDUSAGE, CMDDESCR);
return EXIT_SUCCESS;
case '?':
snprintf(out, MAX_MSG, "%s", l_opterr());
return EXIT_FAILURE;
default:
return EXIT_FAILURE;
}
}
if (l_optind != c->argc - 1) {
snprintf(out, MAX_MSG, "What manual page do you want?");
return EXIT_FAILURE;
}
snprintf(url, MAX_URL, BOT_WEBSITE "/manual/");
if (help.find(c->argv[l_optind]) != help.end())
snprintf(out, MAX_MSG, "[MAN] %s%s.html", url,
help[c->argv[l_optind]].c_str());
else if (default_cmds.find(c->argv[l_optind]) != default_cmds.end())
snprintf(out, MAX_MSG, "[MAN] %s%s.html", url, c->argv[l_optind]);
else if ((ccmd = custom_cmds->getcom(c->argv[l_optind])))
snprintf(out, MAX_MSG, "[MAN] '%s' is a custom command.",
c->argv[l_optind]);
else
snprintf(out, MAX_MSG, "%s: no manual entry for '%s'",
c->argv[0], c->argv[l_optind]);
return EXIT_SUCCESS;
}
开发者ID:frolv,项目名称:lynxbot,代码行数:46,代码来源:man.cpp
注:本文中的opt_init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论