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

C++ poptGetArgs函数代码示例

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

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



在下文中一共展示了poptGetArgs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:Distrotech,项目名称:rsync,代码行数:32,代码来源:tls.c


示例2: main

int
main(int argc, char *argv[])
	/*@globals __assert_program_name,
		rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
	/*@modifies __assert_program_name, _rpmrepo,
		rpmGlobalMacroContext, fileSystem, internalState @*/
{
    poptContext optCon = rpmioInit(argc, argv, optionsTable);
    const char ** av = NULL;
    int ac;
    int rc = 1;		/* assume failure. */
    int i;

/*@-observertrans -readonlytrans @*/
    __progname = "rpmgpg";
/*@=observertrans =readonlytrans @*/

    av = poptGetArgs(optCon);
    if (av == NULL || av[0] == NULL) {
	poptPrintUsage(optCon, stderr, 0);
	goto exit;
    }
    ac = argvCount(av);

    if (av != NULL)
    for (i = 0; i < ac; i++) {
    }
    rc = 0;

exit:
    optCon = rpmioFini(optCon);

    return rc;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:34,代码来源:rpmgpg.c


示例3: main

int
main(int argc, char *argv[])
{
    poptContext optCon = rpmioInit(argc, argv, optionsTable);
    const char * pythonFN = NULL;
    int pythonFlags = 0;
    rpmpython python = rpmpythonNew(pythonFN, pythonFlags);
    ARGV_t av = poptGetArgs(optCon);
    int ac = argvCount(av);
    const char * fn;
    int rc = 1;		/* assume failure */

    if (ac < 1) {
	poptPrintUsage(optCon, stderr, 0);
	goto exit;
    }

    while ((fn = *av++) != NULL) {
	const char * result;
	rpmRC ret;
	result = NULL;
	if ((ret = rpmpythonRunFile(python, fn, &result)) != RPMRC_OK)
	    goto exit;
	if (result != NULL && *result != '\0')
	    fprintf(stdout, "%s\n", result);
    }
    rc = 0;

exit:
    python = rpmpythonFree(python);
    optCon = rpmioFini(optCon);

    return rc;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:34,代码来源:tpython.c


示例4: 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;
}
开发者ID:hef,项目名称:samba,代码行数:61,代码来源:ctdb_randrec.c


示例5: main

/*
  main program
*/
int main(int argc, const char *argv[])
{
	struct poptOption popt_options[] = {
		POPT_AUTOHELP
		{ "socket", 0, POPT_ARG_STRING, &globals.socketname, 0, "local socket name", "filename" },
		POPT_TABLEEND
	};
	int opt;
	const char **extra_argv;
	int extra_argc = 0;
	poptContext pc;

	DEBUGLEVEL = DEBUG_INFO;

	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++;
	}

	if (globals.socketname == NULL) {
		DEBUG(DEBUG_CRIT,("Socket name is undefined\n"));
		exit(1);
	}
	if (socket_server_create()) {
		DEBUG(DEBUG_CRIT,("Socket error: exiting\n"));
		exit(1);
	}
	if (fork_helper()) {
		DEBUG(DEBUG_CRIT,("Forking error: exiting\n"));
		exit(1);
	}
	/* FIXME: Test tcp_checksum6, tcp_checksum */
	/* FIXME: Test ctdb_sys_send_arp, ctdb_sys_send_tcp */
	/* FIXME: Test ctdb_sys_{open,close}_capture_socket, ctdb_sys_read_tcp_packet */
	test_ctdb_sys_check_iface_exists();
	test_ctdb_get_peer_pid();

	socket_server_close();

	DEBUG(DEBUG_INFO,("%d/%d tests successfull\n", globals.successcount, globals.testcount));
	return 0;
}
开发者ID:bhanug,项目名称:samba,代码行数:58,代码来源:ctdb_porting_tests.c


示例6: main

int
main(int argc, char *argv[])
{
    poptContext con = rpmioInit(argc, argv, optionsTable);
    ARGV_t av = poptGetArgs(con);
    int ac = argvCount(av);;
    const char ** keyids = NULL;
    int ec = 0;
    int xx;

_rpmhkp_lvl = RPMLOG_INFO;	/* XXX default is RPMLOG_DEBUG */

    if (_hkp_keyserver == NULL)
	_hkp_keyserver = xstrdup("keys.rpm5.org");
    if (_rpmhkp_spew)
	_rpmhkp_debug = -1;

    /* XXX no macros are loaded if using poptIO. */
    addMacro(NULL, "_hkp_keyserver",		NULL, _hkp_keyserver, -1);
    addMacro(NULL, "_hkp_keyserver_query",	NULL, _hkp_keyserver_query, -1);

    if (ac == 0) {
	xx = argvAppend(&keyids, _keyids);
    } else {
	int gotstdin = 0;
	int i;
	for (i = 0; i < ac; i++) {
	    if (strcmp(av[i], "-")) {
		xx = argvAdd(&keyids, (ARGstr_t)av[i]);
		continue;
	    }
	    if (gotstdin)
		continue;
	    gotstdin++;
	    if (argvFgets(&keyids, NULL))
		goto exit;
	}
    }

    ec = rpmhkpReadKeys(keyids);

    if (_rpmhkp_stats)
	_rpmhkpPrintStats(NULL);

exit:
    keyids = argvFree(keyids);
    _hkp_keyserver = _free(_hkp_keyserver);

/*@[email protected]*/ urlFreeCache();

    con = rpmioFini(con);

    return ec;
}
开发者ID:pombredanne,项目名称:tools-yocto1-rpm,代码行数:54,代码来源:thkp.c


示例7: main

int main(int argc, char *argv[]) 
{
    rpmts ts = NULL;
    enum modes bigMode = MODE_INSTALL;
    struct rpmInstallArguments_s *ia = &rpmIArgs;
    poptContext optCon;
    int ec = 0;
    int ret = 0;
    char rpmFile[1][PATH_MAX];
    memset(&rpmFile,0,PATH_MAX);
    snprintf(rpmFile[0],PATH_MAX,"%s",argv[1]);
    char *p[2];
    p[0] = "";
    p[1] = (char *)&rpmFile[0];
    optCon = rpmcliInit(2, p, optionsTable);


    printf("\n argc[%d],bigmode[%s]\n",argc,bigMode == MODE_UNKNOWN?"unknow":"others");
    ia->installInterfaceFlags = INSTALL_INSTALL | INSTALL_LABEL | INSTALL_PERCENT;

    ts = rpmtsCreate();
    rpmtsSetRootDir(ts, rpmcliRootDir);

        if (!ia->incldocs) {
            if (rpmExpandNumeric("%{_excludedocs}"))
                ia->transFlags |= RPMTRANS_FLAG_NODOCS;
        }

        if (ia->noDeps) 
            ia->installInterfaceFlags |= INSTALL_NODEPS;

        if (ia->prefix) {
            ia->relocations = malloc(2 * sizeof(*ia->relocations));
            ia->relocations[0].oldPath = NULL;   /* special case magic */
            ia->relocations[0].newPath = ia->prefix;
            ia->relocations[1].oldPath = NULL;
            ia->relocations[1].newPath = NULL;
        } else if (ia->relocations) {
            ia->relocations = realloc(ia->relocations, 
                sizeof(*ia->relocations) * (ia->numRelocations + 1));
            ia->relocations[ia->numRelocations].oldPath = NULL;
            ia->relocations[ia->numRelocations].newPath = NULL;
        }

    ret= rpmInstall(ts, ia, (ARGV_t) poptGetArgs(optCon));
    printf("\n ret[%d]\n",ret);

    rpmtsFree(ts);
    ts = NULL;

    rpmcliFini(optCon);

    return 0;
}
开发者ID:bxeldor,项目名称:leetcode-2,代码行数:54,代码来源:hello_rpm.c


示例8: main

int main(int argc, char **argv)
{
    poptContext optCon = rpmioInit(argc, argv, optionsTable);
    const char ** av = NULL;
    int ac;
    int r = -1;

_rpmaug_debug = -1;
    if (_rpmaugLoadargv != NULL)
	_rpmaugLoadpath = argvJoin(_rpmaugLoadargv, PATH_SEP_CHAR);

    _rpmaugI = rpmaugNew(_rpmaugRoot, _rpmaugLoadpath, _rpmaugFlags);
    if (_rpmaugI == NULL) {
        fprintf(stderr, "Failed to initialize Augeas\n");
	goto exit;
    }

#if defined(WITH_READLINE)
    readline_init();
#endif

    av = poptGetArgs(optCon);
    ac = argvCount(av);
    if (ac > 0) {	// Accept one command from the command line
	const char * cmd = argvJoin(av, ' ');
	const char *buf;

	buf = NULL;
        r = rpmaugRun(NULL, cmd, &buf);
	cmd = _free(cmd);
	if (buf && *buf)
	    fprintf(stdout, "%s", buf);
    } else {
        r = main_loop();
    }

exit:
    if (_rpmaugLoadargv)
	_rpmaugLoadpath = _free(_rpmaugLoadpath);
    _rpmaugLoadargv = argvFree(_rpmaugLoadargv);
    _rpmaugI = rpmaugFree(_rpmaugI);

    optCon = rpmioFini(optCon);

    return (r == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
开发者ID:cmjonze,项目名称:rpm5_tarballs,代码行数:46,代码来源:augtool.c


示例9: main

int main (int argc, char *argv[])
{
    LEErrorCode   fontStatus = LE_NO_ERROR;
    poptContext   ptctx;
    GtkWidget    *app;
    const char   *defaultArgs[] = {"Sample.txt", NULL};
    const char  **args;
    int i;

    FT_Init_FreeType(&engine);

    gnome_init_with_popt_table("gnomelayout", "0.1", argc, argv, NULL, 0, &ptctx);

    guiSupport = gs_gnomeGuiSupportOpen();
    fontMap    = fm_gnomeFontMapOpen(engine, "FontMap.Gnome", 24, guiSupport, &fontStatus);
    font       = le_scriptCompositeFontOpen(fontMap);

    if (LE_FAILURE(fontStatus)) {
        FT_Done_FreeType(engine);
        return 1;
    }

    args = poptGetArgs(ptctx);
    
    if (args == NULL) {
        args = defaultArgs;
    }

    for (i = 0; args[i] != NULL; i += 1) {
       app = newSample(args[i]);
           
       gtk_widget_show_all(app);
    }
    
    poptFreeContext(ptctx);
    
    gtk_main();

    le_fontClose(font);
    gs_gnomeGuiSupportClose(guiSupport);

    FT_Done_FreeType(engine);

    exit(0);
}
开发者ID:icu-project,项目名称:icu4c,代码行数:45,代码来源:cgnomelayout.c


示例10: main

int
main(int argc, char *argv[])
{
    poptContext optCon = rpmioInit(argc, argv, optionsTable);
    const char * perlFN = NULL;
    int perlFlags = 0;
    rpmperl perl = rpmperlNew(perlFN, perlFlags);
    ARGV_t av = poptGetArgs(optCon);
    int ac = argvCount(av);
#ifdef	NOTYET
    const char * fn;
#endif
    const char * result;
    int rc = 1;		/* assume failure */

#ifdef	NOTYET
    if (ac < 1) {
	poptPrintUsage(optCon, stderr, 0);
	goto exit;
    }

    while ((fn = *av++) != NULL) {
	rpmRC ret;
	result = NULL;
	if ((ret = rpmperlRunFile(perl, fn, &result)) != RPMRC_OK)
	    goto exit;
	if (result != NULL && *result != '\0')
	    fprintf(stdout, "%s\n", result);
    }
    rc = 0;
#else
    result = NULL;
    if (rpmperlRun(perl, "print \"Hello, world!\n\";", &result) != RPMRC_OK)
	goto exit;
    if (result && *result)
	fprintf(stdout, "%s\n", result);
    rc = 0;
#endif

exit:
    perl = rpmperlFree(perl);
    optCon = rpmioFini(optCon);

    return rc;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:45,代码来源:tperl.c


示例11: air_option_context_parse

void air_option_context_parse(
    AirOptionCtx *aoctx)
{
#if USE_GOPTION
    GError          *oerr = NULL;

    g_option_context_parse(aoctx->octx, aoctx->argc, aoctx->argv, &oerr);
    if (oerr) {
        air_opterr("%s", oerr->message);
    }
#elif USE_POPT
    {
        int argcount = 0;
        char **rest     = 0;
        int rc;

        GPtrArray *new_argv = NULL;

        rc = poptGetNextOpt(aoctx->octx);
        if (rc != -1) {
            air_opterr("%s", poptStrerror(rc));
        }

        /* We have to manually construct the argv here because GLib keeps the
         * program name in argv[0] and popt doesn't. */
        new_argv = g_ptr_array_sized_new(64);
        g_ptr_array_add(new_argv, g_strdup(*(aoctx->argv)[0]));

        /* Do the actual parsing, returning non-switch args */
        rest = (char **) poptGetArgs(aoctx->octx);

        /* Walk through the remaining args, adding them to the new argv and
         * counting them for argc */
        while ( (rest != NULL) && rest[argcount] != NULL) {
            g_ptr_array_add(new_argv, g_strdup(rest[argcount]));
            argcount++;
        }
        g_ptr_array_add(new_argv, NULL);
        /* Now replace the original argc and argv with post-parse values */
        *(aoctx->argc) = argcount;
        *(aoctx->argv) = (char **) g_ptr_array_free(new_argv, FALSE);
    }
#endif
}
开发者ID:aming2007,项目名称:dpi-test-suite,代码行数:44,代码来源:airopt.c


示例12: main

/*
  main program
*/
int main(int argc, const char *argv[])
{
	struct ctdb_context *ctdb;

	struct poptOption popt_options[] = {
		POPT_AUTOHELP
		POPT_CTDB_CMDLINE
		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(5, 0));
	if (ctdb == NULL) {
		exit(1);
	}

	trackdb_test(ctdb);

	return 0;
}
开发者ID:Gazzonyx,项目名称:samba,代码行数:47,代码来源:ctdb_trackingdb_test.c


示例13: main

int main(int argc, char **argv) {
    int rc;
    char *errstr;
    const char **args;

    int forceit=0;
    int supported=0;
    int help=0;

    poptContext optCon;
    struct poptOption options[] = {
        { "force", 'f', POPT_ARG_NONE, &forceit, 0 },
        { "supported-iso", 'S', POPT_ARG_NONE, &supported, 0 },
        { "help", 'h', POPT_ARG_NONE, &help, 0},
        { 0, 0, 0, 0, 0}
    };


    optCon = poptGetContext("implantisomd5", argc, (const char **)argv, options, 0);

    if ((rc = poptGetNextOpt(optCon)) < -1) {
        fprintf(stderr, "bad option %s: %s\n",
                poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
                poptStrerror(rc));
        exit(1);
    }

    if (help)
        usage();

    args = poptGetArgs(optCon);
    if (!args || !args[0] || !args[0][0])
        usage();

    rc = implantISOFile((char *)args[0], supported, forceit, 0, &errstr);
    if (rc) {
        fprintf(stderr, "ERROR: ");
        fprintf(stderr, errstr, (char *)args[0]);
        exit(1);
    } else {
        exit(0);
    }
}
开发者ID:frafra,项目名称:isomd5sum,代码行数:43,代码来源:implantisomd5.c


示例14: main

int
main(int argc, char *argv[])
{
    poptContext optCon = rpmioInit(argc, argv, optionsTable);
    ARGV_t av = NULL;
    int ac;
    const char * dn;
    int rc = 0;

    if (__debug) {
_av_debug = -1;
_dav_debug = -1;
_ftp_debug = -1;
_url_debug = -1;
_rpmio_debug = -1;
    }

    av = poptGetArgs(optCon);
    ac = argvCount(av);
    if (ac < 1) {
	poptPrintUsage(optCon, stderr, 0);
	goto exit;
    }

    while (rc == 0 && (dn = *av++) != NULL) {
#ifdef	DYING	/* XXX davOpendir() is adding pesky trailing '/'. */
	/* XXX Add pesky trailing '/' to http:// URI's */
	size_t nb = strlen(dn);
	dn = rpmExpand(dn, (dn[nb-1] != '/' ? "/" : NULL), NULL);
	rc = dirWalk(dn);
	dn = _free(dn);
#else
	rc = dirWalk(dn);
#endif
    }

exit:

    optCon = rpmioFini(optCon);

    return rc;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:42,代码来源:tdir.c


示例15: main

int
main(int argc, char *argv[])
{
    poptContext optCon = rpmioInit(argc, argv, optionsTable);
    rpmtget tget = xcalloc(1, sizeof(*tget));
    ARGV_t av = NULL;
    int ac;
    int rc = 0;
    int xx;

    if (__debug) {
_av_debug = -1;
_dav_debug = -1;
_ftp_debug = -1;
_url_debug = -1;
_rpmio_debug = -1;
    }

    av = poptGetArgs(optCon);
    ac = argvCount(av);
    if (ac < 1) {
	poptPrintUsage(optCon, stderr, 0);
	goto exit;
    }

    tget->pattern = hrefpat;
    xx = mireAppend(RPMMIRE_PCRE, 0, tget->pattern, NULL, &tget->mires, &tget->nmires);

    while (rc == 0 && (tget->uri = *av++) != NULL)
	rc = readFile(tget);

    tget->mires = mireFreeAll(tget->mires, tget->nmires);
    tget->nmires = 0;

exit:

    optCon = rpmioFini(optCon);

    return rc;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:40,代码来源:tget.c


示例16: main

int main(int argc, char *argv[])
{
    int ec = EXIT_FAILURE;
    poptContext optCon = rpmcliInit(argc, argv, optionsTable);
    rpmts ts = rpmtsCreate();
    ARGV_const_t args = NULL;
    
    if (argc < 2) {
	printUsage(optCon, stderr, 0);
	goto exit;
    }

    args = (ARGV_const_t) poptGetArgs(optCon);

    if (mode != MODE_LISTKEY && args == NULL)
	argerror(_("no arguments given"));

    rpmtsSetRootDir(ts, rpmcliRootDir);

    switch (mode) {
    case MODE_CHECKSIG:
	ec = rpmcliVerifySignatures(ts, args);
	break;
    case MODE_IMPORTKEY:
	ec = rpmcliImportPubkeys(ts, args);
	break;
    /* XXX TODO: actually implement these... */
    case MODE_DELKEY:
    case MODE_LISTKEY:
	break;
    default:
	argerror(_("only one major mode may be specified"));
    }

exit:
    rpmtsFree(ts);
    rpmcliFini(optCon);
    return ec;
}
开发者ID:akozumpl,项目名称:rpm,代码行数:39,代码来源:rpmkeys.c


示例17: get_args

int get_args(int argc, const char* argv[], const char **&params)
{
	int rc;	
	poptContext opt_context = 
		poptGetContext(argv[0], argc, argv, opt_table, 0);
	while ((rc = poptGetNextOpt(opt_context)) > 0){
		switch(rc){
		case 'S':
		case 's':
			err("Sorry, option no available yet");
			break;
		case 'v':
			fprintf(stderr, "mdsPutCh " BUILD "\n");
			exit(1);
		case 'r':
			repeat_mode = 1;
			break;
		case 'l':
			RootExpression::create();
			RootExpression::listAll();
			exit(0);
		default:
			;
		}
	}
	int argc2;
	const char ** argv2 = poptGetArgs(opt_context);

	for (argc2 = 0; argv2 && argv2[argc2] != 0; ++argc2){

	}
	if (argc2){
		params = argv2;
	}
	return argc2;	
}  
开发者ID:petermilne,项目名称:mdsshell,代码行数:36,代码来源:mdsPutCh.cpp


示例18: main


//.........这里部分代码省略.........
  }
  // XXX - customize here
  poptSetOtherOptionHelp(optCon, _("[NON-FLAG ARGUMENTS]"));

  while ((c = poptGetNextOpt(optCon)) >= 0)
  {
    switch (c)
    {
    case 'd':					// debug
      if (!debug_level)
      {
	// Set up debugging, from config file
	bk_general_debug_config(B, stderr, BK_ERR_NONE, 0);
	bk_debug_printf(B, "Debugging on\n");
	debug_level++;
      }
      else if (debug_level == 1)
      {
	/*
	 * Enable output of error and higher error logs (this can be
	 * annoying so require -dd)
	 */
	bk_error_config(B, BK_GENERAL_ERROR(B), 0, stderr, BK_ERR_NONE, BK_ERR_ERR, BK_ERROR_CONFIG_FH | BK_ERROR_CONFIG_HILO_PIVOT | BK_ERROR_CONFIG_SYSLOGTHRESHOLD);
	bk_debug_printf(B, "Extra debugging on\n");
	debug_level++;
      }
      else if (debug_level == 2)
      {
	/*
	 * Enable output of all levels of bk_error logs (this can be
	 * very annoying so require -ddd)
	 */
	bk_error_config(B, BK_GENERAL_ERROR(B), 0, stderr, BK_ERR_NONE, BK_ERR_DEBUG, BK_ERROR_CONFIG_FH | BK_ERROR_CONFIG_HILO_PIVOT | BK_ERROR_CONFIG_SYSLOGTHRESHOLD);
	bk_debug_printf(B, "Super-extra debugging on\n");
	debug_level++;
      }
      break;
    case 'v':					// verbose
      BK_FLAG_SET(pc->pc_flags, PC_VERBOSE);
      bk_error_config(B, BK_GENERAL_ERROR(B), ERRORQUEUE_DEPTH, stderr, BK_ERR_NONE, BK_ERR_ERR, 0);
      break;
    case 0x1000:				// no-seatbelts
      BK_FLAG_CLEAR(BK_GENERAL_FLAGS(B), BK_BGFLAGS_FUNON);
      break;
    case 0x1001:				// seatbelts
      BK_FLAG_SET(BK_GENERAL_FLAGS(B), BK_BGFLAGS_FUNON);
      break;
    case 0x1002:				// profiling
      bk_general_funstat_init(B, (char *)poptGetOptArg(optCon), 0);
      break;
    default:
      getopterr++;
      break;

    // XXX - customize here
    case 'p':					// person
      pc->pc_person = poptGetOptArg(optCon);
      break;
    case 1:					// long-arg-only
      printf("You specificed the long-arg-only option\n");
      break;
    case 2:					// s
      printf("You specificed the short only option\n");
      break;
    }
  }

  /*
   * Reprocess so that argc and argv contain the remaining command
   * line arguments (note argv[0] is an argument, not the program
   * name).  argc remains the number of elements in the argv array.
   */
  argv = (char **)poptGetArgs(optCon);
  argc = 0;
  if (argv)
    for (; argv[argc]; argc++)
      ; // Void

  // XXX - customize here (argv test)
  if (c < -1 || getopterr)
  {
    if (c < -1)
    {
      fprintf(stderr, "%s\n", poptStrerror(c));
    }
    poptPrintUsage(optCon, stderr, 0);
    bk_exit(B, 254);
  }

  if (proginit(B, pc) < 0)
  {
    bk_die(B, 254, stderr, _("Could not perform program initialization\n"), BK_FLAG_ISSET(pc->pc_flags, PC_VERBOSE)?BK_WARNDIE_WANTDETAILS:0);
  }

  progrun(B, pc);

  poptFreeContext(optCon);
  bk_exit(B, 0);
  return(255);					// Stupid INSIGHT stuff.
}
开发者ID:SethRobertson,项目名称:libbk,代码行数:101,代码来源:test_ringdir.c


示例19: nbReadParameters


//.........这里部分代码省略.........
        {
            "no-clean-checkpoint", 'k',
            POPT_ARG_NONE, &nbf.noCleanCheckpoint,
            0, "Do not delete checkpoint on finish", NULL
        },

        {
            "verbose", '\0',
            POPT_ARG_NONE, &nbf.verbose,
            0, "Print some extra debugging information", NULL
        },

        {
            "version", 'v',
            POPT_ARG_NONE, &version,
            0, "Print version information", NULL
        },

        {
            "copyright", '\0',
            POPT_ARG_NONE, &copyright,
            0, "Print copyright information and exit", NULL
        },

        POPT_AUTOHELP
        POPT_TABLEEND
    };

    context = poptGetContext(argv[0], argc, argv, options, POPT_CONTEXT_POSIXMEHARDER);
    if (!context)
    {
        mw_printf("Failed to get popt context\n");
        exit(EXIT_FAILURE);
    }

    if (argc < 2)
    {
        poptPrintUsage(context, stderr, 0);
        poptFreeContext(context);
        return TRUE;
    }

    /* Check for invalid options, and must have the input file or a
     * checkpoint to resume from */
    argRead = mwReadArguments(context);
    if (argRead < 0)
    {
        mw_printf("Failed to read arguments\n");
        poptFreeContext(context);
        return TRUE;
    }

    if (version)
    {
        nbPrintVersion(FALSE, nbf.verbose);
    }

    if (copyright)
    {
        nbPrintCopyright();
    }

    if (version || copyright)
    {
        poptFreeContext(context);
        exit(EXIT_SUCCESS);
    }

    if (!nbf.inputFile && !nbf.checkpointFileName && !nbf.matchHistogram)
    {
        mw_printf("An input file, checkpoint, or matching histogram argument is required\n");
        poptFreeContext(context);
        return TRUE;
    }

    if (nbf.matchHistogram && !nbf.histogramFileName)
    {
        mw_printf("--match-histogram argument requires --histogram-file\n");
        poptFreeContext(context);
        return TRUE;
    }

    nbf.setSeed = !!(argRead & SEED_ARGUMENT);

    rest = poptGetArgs(context);
    if ((params || numParams) && !rest)
    {
        mw_printf("Expected arguments to follow, got 0\n");
    }
    else
    {
        nbSetForwardedArguments(&nbf, rest);
    }

    poptFreeContext(context);

    *nbfOut = nbf;

    return FALSE;
}
开发者ID:MarchM4,项目名称:Milkyway-home-server-expansion,代码行数:101,代码来源:main.c


示例20: main

int main(int argc, const char ** argv)
{
	int i;
	const char ** dd_args;
	struct tevent_context *ev;

	poptContext pctx;
	struct poptOption poptions[] = {
		/* POPT_AUTOHELP */
		{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, cifsddHelpOptions,
			0, "Help options:", NULL },
		POPT_COMMON_SAMBA
		POPT_COMMON_CONNECTION
		POPT_COMMON_CREDENTIALS
		POPT_COMMON_VERSION
		{ NULL }
	};

	/* Block sizes. */
	set_arg_val("bs", (uint64_t)4096);
	set_arg_val("ibs", (uint64_t)4096);
	set_arg_val("obs", (uint64_t)4096);
	/* Block counts. */
	set_arg_val("count", (uint64_t)-1);
	set_arg_val("seek", (uint64_t)0);
	set_arg_val("seek", (uint64_t)0);
	/* Files. */
	set_arg_val("if", NULL);
	set_arg_val("of", NULL);
	/* Options. */
	set_arg_val("direct", false);
	set_arg_val("sync", false);
	set_arg_val("oplock", false);

	pctx = poptGetContext(PROGNAME, argc, argv, poptions, 0);
	while ((i = poptGetNextOpt(pctx)) != -1) {
		;
	}

	for (dd_args = poptGetArgs(pctx); dd_args && *dd_args; ++dd_args) {

		if (!set_arg_argv(*dd_args)) {
			fprintf(stderr, "%s: invalid option: %s\n",
					PROGNAME, *dd_args);
			exit(SYNTAX_EXIT_CODE);
		}

		/* "bs" has the side-effect of setting "ibs" and "obs". */
		if (strncmp(*dd_args, "bs=", 3) == 0) {
			uint64_t bs = check_arg_numeric("bs");
			set_arg_val("ibs", bs);
			set_arg_val("obs", bs);
		}
	}

	ev = s4_event_context_init(talloc_autofree_context());

	gensec_init(cmdline_lp_ctx);
	dump_args();

	if (check_arg_numeric("ibs") == 0 || check_arg_numeric("ibs") == 0) {
		fprintf(stderr, "%s: block sizes must be greater that zero\n",
				PROGNAME);
		exit(SYNTAX_EXIT_CODE);
	}

	if (check_arg_pathname("if") == NULL) {
		fprintf(stderr, "%s: missing input filename\n", PROGNAME);
		exit(SYNTAX_EXIT_CODE);
	}

	if (check_arg_pathname("of") == NULL) {
		fprintf(stderr, "%s: missing output filename\n", PROGNAME);
		exit(SYNTAX_EXIT_CODE);
	}

	CatchSignal(SIGINT, dd_handle_signal);
	CatchSignal(SIGUSR1, dd_handle_signal);
	return(copy_files(ev, cmdline_lp_ctx));
}
开发者ID:Alexandr-Galko,项目名称:samba,代码行数:80,代码来源:cifsdd.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ poptGetOptArg函数代码示例发布时间:2022-05-30
下一篇:
C++ poptGetArg函数代码示例发布时间: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