• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ poptGetArg函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中poptGetArg函数的典型用法代码示例。如果您正苦于以下问题:C++ poptGetArg函数的具体用法?C++ poptGetArg怎么用?C++ poptGetArg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了poptGetArg函数的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" },

		{ "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


示例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);
}
开发者ID:ParaStation,项目名称:pscom,代码行数:60,代码来源:extoll_pp_velo.c


示例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;
}
开发者ID:Estevo-Aleixo,项目名称:librsync,代码行数:31,代码来源:rdiff.c


示例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);
}
开发者ID:ParaStation,项目名称:pscom,代码行数:59,代码来源:pscom_ondemand.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, 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


示例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;
}
开发者ID:tpenguin,项目名称:solarisvoip-asterisk-newt,代码行数:27,代码来源:dialogboxes.c


示例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);
    }
}
开发者ID:Estevo-Aleixo,项目名称:librsync,代码行数:7,代码来源:rdiff.c


示例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;
}
开发者ID:WhiteSymmetry,项目名称:lttng-tools,代码行数:37,代码来源:view.c


示例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 */
}
开发者ID:pkrul,项目名称:echoping,代码行数:44,代码来源:postgresql.c


示例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;
}
开发者ID:Estevo-Aleixo,项目名称:librsync,代码行数:43,代码来源:rdiff.c


示例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;
}
开发者ID:crossbuild,项目名称:rpm,代码行数:55,代码来源:rpmsign.c


示例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;
}
开发者ID:opieproject,项目名称:opie,代码行数:23,代码来源:rdiff.c


示例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;
}
开发者ID:phuongtg,项目名称:lttng-tools,代码行数:59,代码来源:disable_events.c


示例16: 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


示例17: HREnextArg

char* HREnextArg(){
    if (optCon) {
        pthread_mutex_lock(&next_arg_mutex);
        char* res=HREstrdup(poptGetArg(optCon));
        if (!res) {
            poptFreeContext(optCon);
            optCon=NULL;
        }
        pthread_mutex_unlock(&next_arg_mutex);
        return res;
    }
    return NULL;
}
开发者ID:alaarman,项目名称:ltsmin,代码行数:13,代码来源:hre_popt.c


示例18: 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


示例19: DecodeCommandLine

void DecodeCommandLine(int argc, const char **argv)
{
    signed int c;

    poptContext optCon;           // context for parsing command-line options

    struct poptOption optionsTable[] = {
        { "configfile", 'c', POPT_ARG_STRING, &sConfigFile,  0,  NULL, NULL },
        { "hostname",   'n', POPT_ARG_STRING, &sHostName,    0,  NULL, NULL },
        { "all",        'a', 0,               0,            'a', NULL, NULL },
        { "verbose",    'v', 0,               0,            'v', NULL, NULL },
        { "help",       'h', 0,               0,            'h', NULL, NULL },
        { NULL,         0,   0,               NULL,          0,  NULL, NULL }
    };

    if( argc < 2 ){
        usage(argc,argv);
    }

    optCon = poptGetContext((const char *)NULL,
		            argc,
			    (const char **)argv,
			    (const struct poptOption *)optionsTable,
			    0 );

    while( ( c = poptGetNextOpt(optCon) ) >= 0 ) {
        switch(c){
            case 'a': fDumpAll = TRUE;
                      break;
            case 'h': usage(argc,argv);
                      break;
            case 'v': verbose = TRUE;
                      break;
        }
    }

    //
    // Make sure they supplied the name of a configuration key
    //
    if( ! fDumpAll ){
        if( ( pOptionName = (char *)poptGetArg(optCon) ) == NULL ){
            usage(argc,argv);
        }
    }

    poptFreeContext(optCon);
}
开发者ID:Pursuit92,项目名称:ltsp-arch,代码行数:47,代码来源:getltscfg.c


示例20: rdiff_action

static rs_result rdiff_action(poptContext opcon)
{
    const char      *action;

    action = poptGetArg(opcon);
    if (!action) 
        ;
    else if (isprefix(action, "signature")) 
        return rdiff_sig(opcon);
    else if (isprefix(action, "delta")) 
        return rdiff_delta(opcon);
    else if (isprefix(action, "patch"))
        return rdiff_patch(opcon);
    
    rdiff_usage("rdiff: You must specify an action: `signature', `delta', or `patch'.");
    return RS_SYNTAX_ERROR;
}
开发者ID:Estevo-Aleixo,项目名称:librsync,代码行数:17,代码来源:rdiff.c



注:本文中的poptGetArg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ poptGetArgs函数代码示例发布时间:2022-05-30
下一篇:
C++ poptFreeContext函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap