Example #1
0
int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
{
    char * fn, * home;
    int rc;

    if (useEnv) {}
    /*@-type@*/
    if (!con->appName) return 0;
    /*@=type@*/

    rc = poptReadConfigFile(con, "/etc/popt");
    if (rc) return rc;
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
    if (getuid() != geteuid()) return 0;
#endif

    if ((home = getenv("HOME"))) {
	fn = alloca(strlen(home) + 20);
	strcpy(fn, home);
	strcat(fn, "/.popt");
	rc = poptReadConfigFile(con, fn);
	if (rc) return rc;
    }

    return 0;
}
Example #2
0
int poptReadDefaultConfig(poptContext con, /*@unused@*/ UNUSED(int useEnv))
{
    static const char _popt_sysconfdir[] = POPT_SYSCONFDIR "/popt";
    static const char _popt_etc[] = "/etc/popt";
    char * home;
    struct stat sb;
    int rc = 0;		/* assume success */

    if (con->appName == NULL) goto exit;

    if (strcmp(_popt_sysconfdir, _popt_etc)) {
	rc = poptReadConfigFile(con, _popt_sysconfdir);
	if (rc) goto exit;
    }

    rc = poptReadConfigFile(con, _popt_etc);
    if (rc) goto exit;

#if defined(HAVE_GLOB_H)
    if (!stat("/etc/popt.d", &sb) && S_ISDIR(sb.st_mode)) {
	const char ** av = NULL;
	int ac = 0;
	int i;

	if ((rc = poptGlob(con, "/etc/popt.d/*", &ac, &av)) == 0) {
	    for (i = 0; rc == 0 && i < ac; i++) {
		const char * fn = av[i];
		if (fn == NULL || strstr(fn, ".rpmnew") || strstr(fn, ".rpmsave"))
		    continue;
		if (!stat(fn, &sb)) {
		    if (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))
			continue;
		}
		rc = poptReadConfigFile(con, fn);
		free((void *)av[i]);
		av[i] = NULL;
	    }
	    free(av);
	    av = NULL;
	}
    }
    if (rc) goto exit;
#endif

    if ((home = getenv("HOME"))) {
	char * fn = malloc(strlen(home) + 20);
	if (fn != NULL) {
	    (void) stpcpy(stpcpy(fn, home), "/.popt");
	    rc = poptReadConfigFile(con, fn);
	    free(fn);
	} else
	    rc = POPT_ERROR_ERRNO;
	if (rc) goto exit;
    }

exit:
    return rc;
}
Example #3
0
int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv) {
    char * fn, * home;
    int rc;

    if (!con->appName) return 0;

    rc = poptReadConfigFile(con, "/etc/popt");
    if (rc) return rc;
    if (getuid() != geteuid()) return 0;

    if ((home = getenv("HOME"))) {
	fn = alloca(strlen(home) + 20);
	strcpy(fn, home);
	strcat(fn, "/.popt");
	rc = poptReadConfigFile(con, fn);
	if (rc) return rc;
    }

    return 0;
}
Example #4
0
int poptReadConfigFiles(poptContext con, const char * paths)
{
    char * buf = (paths ? xstrdup(paths) : NULL);
    const char * p;
    char * pe;
    int rc = 0;		/* assume success */

    for (p = buf; p != NULL && *p != '\0'; p = pe) {
	const char ** av = NULL;
	int ac = 0;
	int i;
	int xx;

	/* locate start of next path element */
	pe = strchr(p, ':');
	if (pe != NULL && *pe == ':')
	    *pe++ = '\0';
	else
	    pe = (char *) (p + strlen(p));

	xx = poptGlob(con, p, &ac, &av);

	/* work-off each resulting file from the path element */
	for (i = 0; i < ac; i++) {
	    const char * fn = av[i];
	    if (av[i] == NULL)	/* XXX can't happen */
		/*@innercontinue@*/ continue;
	    /* XXX should '@' attention be pushed into poptReadConfigFile? */
	    if (p[0] == '@' && p[1] != '(') {
		if (fn[0] == '@' && fn[1] != '(')
		    fn++;
		xx = poptSaneFile(fn);
		if (!xx && rc == 0)
		    rc = POPT_ERROR_BADCONFIG;
		/*@innercontinue@*/ continue;
	    }
	    xx = poptReadConfigFile(con, fn);
	    if (xx && rc == 0)
		rc = xx;
	    free((void *)av[i]);
	    av[i] = NULL;
	}
	free(av);
	av = NULL;
    }

/*@-usedef@*/
    if (buf)
	free(buf);
/*@=usedef@*/

    return rc;
}
Example #5
0
int main(int argc, const char ** argv)
	/*@globals pass2, fileSystem, internalState @*/
	/*@modifies pass2, fileSystem, internalState @*/
{
    int rc;
    int ec = 0;
    poptContext optCon;
    const char ** rest;
    int help = 0;
    int usage = 0;

#if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE)
    /*@-moduncon -noeffectuncon@*/
    mtrace();   /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
    /*@=moduncon =noeffectuncon@*/
#endif

/*@-modobserver@*/
    resetVars();
/*@=modobserver@*/
/*@-temptrans@*/
    optCon = poptGetContext("test1", argc, argv, options, 0);
/*@=temptrans@*/
    (void) poptReadConfigFile(optCon, "./test-poptrc");

#if 1
    while ((rc = poptGetNextOpt(optCon)) > 0)	/* Read all the options ... */
	{};

    poptResetContext(optCon);			/* ... and then start over. */
/*@-modobserver@*/
    resetVars();
/*@=modobserver@*/
#endif

    pass2 = 1;
    if ((rc = poptGetNextOpt(optCon)) < -1) {
	fprintf(stderr, "test1: bad argument %s: %s\n",
		poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
		poptStrerror(rc));
	ec = 2;
	goto exit;
    }

    if (help) {
	poptPrintHelp(optCon, stdout, 0);
	goto exit;
    }
    if (usage) {
	poptPrintUsage(optCon, stdout, 0);
	goto exit;
    }

    fprintf(stdout, "arg1: %d arg2: %s", arg1, arg2);

    if (arg3)
	fprintf(stdout, " arg3: %d", arg3);
    if (inc)
	fprintf(stdout, " inc: %d", inc);
    if (shortopt)
	fprintf(stdout, " short: %d", shortopt);
    if (aVal != bVal)
	fprintf(stdout, " aVal: %d", aVal);
    if (aFlag != bFlag)
	fprintf(stdout, " aFlag: %d", aFlag);
    if (aInt != bInt)
	fprintf(stdout, " aInt: %d", aInt);
    if (aLong != bLong)
	fprintf(stdout, " aLong: %ld", aLong);
/*@-realcompare@*/
    if (aFloat != bFloat)
	fprintf(stdout, " aFloat: %g", (double)aFloat);
    if (aDouble != bDouble)
	fprintf(stdout, " aDouble: %g", aDouble);
/*@=realcompare@*/
    if (oStr != (char *)-1)
	fprintf(stdout, " oStr: %s", (oStr ? oStr : "(none)"));
    if (singleDash)
	fprintf(stdout, " -");

    rest = poptGetArgs(optCon);
    if (rest) {
	fprintf(stdout, " rest:");
	while (*rest) {
	    fprintf(stdout, " %s", *rest);
	    rest++;
	}
    }

    fprintf(stdout, "\n");

exit:
    optCon = poptFreeContext(optCon);
#if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE)
    /*@-moduncon -noeffectuncon@*/
    muntrace();   /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
    /*@=moduncon =noeffectuncon@*/
#endif
    return ec;
}
Example #6
0
int 
main(int argc, const char ** argv) {

    poptContext optCon;   /* context for parsing command-line options */
    struct poptOption userOptionsTable[] = {
        { "first", 'f', POPT_ARG_STRING, &firstname, 0,
            "user's first name", "first" },
        { "last", 'l', POPT_ARG_STRING, &lastname, 0,
            "user's last name", "last" },
        { "username", 'u', POPT_ARG_STRING, &username, 0,
            "system user name", "user" },
        { "password", 'p', POPT_ARG_STRING, &password, 0,
            "system password name", "password" },
        { "addr1", '1', POPT_ARG_STRING, &addr1, 0,
            "line 1 of address", "addr1" },
        { "addr2", '2', POPT_ARG_STRING, &addr2, 0,
            "line 2 of address", "addr2" },
        { "city", 'c', POPT_ARG_STRING, &city, 0,
            "city", "city" },
        { "state", 's', POPT_ARG_STRING, &state, 0,
            "state or province", "state" },
        { "postal", 'P', POPT_ARG_STRING, &postal, 0,
            "postal or zip code", "postal" },
        { "zip", 'z', POPT_ARG_STRING, &postal, 0,
            "postal or zip code", "postal" },
        { "country", 'C', POPT_ARG_STRING, &country, 0,
            "two letter ISO country code", "country" },
        { "email", 'e', POPT_ARG_STRING, &email, 0,
            "user's email address", "email" },
        { "dayphone", 'd', POPT_ARG_STRING, &dayphone, 0,
            "day time phone number", "dayphone" },
        { "fax", 'F', POPT_ARG_STRING, &fax, 0,
            "fax number", "fax" },
        { NULL, 0, 0, NULL, 0, NULL, NULL }
    };
    struct poptOption transactOptionsTable[] = {
        { "keyfile", '\0', POPT_ARG_STRING, &PathnameOfKeyFile, 0,
            "transact offer key file (flat_O.kf)", "key-file" },
        { "offerfile", '\0', POPT_ARG_STRING, &PathnameOfOfferFile, 0,
            "offer template file (osl.ofr)", "offer-file" },
        { "storeid", '\0', POPT_ARG_INT, &txStoreId, 0,
            "store id", "store-id" },
        { "rcfile", '\0', POPT_ARG_STRING, &rcfile, 0,
            "default command line options (in popt format)", "rcfile" },
        { "txhost", '\0', POPT_ARG_STRING, &txHost, 0,
            "transact host", "transact-host" },
        { "txsslport", '\0', POPT_ARG_INT, &txSslPort, 0,
            "transact server ssl port ", "transact ssl port" },
        { "cnhost", '\0', POPT_ARG_STRING, &contentHost, 0,
            "content host", "content-host" },
        { "cnpath", '\0', POPT_ARG_STRING, &contentPath, 0,
            "content url path", "content-path" },
        { NULL, 0, 0, NULL, 0, NULL, NULL }
    };

    struct poptOption databaseOptionsTable[] = {
        { "dbpassword", '\0', POPT_ARG_STRING, &dbPassword, 0,
            "Database password", "DB password" },
        { "dbusername", '\0', POPT_ARG_STRING, &dbUserName, 0,
            "Database user name", "DB UserName" },
        { NULL, 0, 0, NULL, 0, NULL, NULL }
    };

    struct poptOption optionsTable[] = {
	{ NULL, '\0', POPT_ARG_INCLUDE_TABLE,  NULL, 0,
            "Transact Options (not all will apply)", NULL },
	{ NULL, '\0', POPT_ARG_INCLUDE_TABLE,  NULL, 0,
            "Transact Database Names", NULL },
	{ NULL, '\0', POPT_ARG_INCLUDE_TABLE,  NULL, 0,
            "User Fields", NULL },
        POPT_AUTOHELP
        { NULL, 0, 0, NULL, 0, NULL, NULL }
    };

    optionsTable[0].arg = transactOptionsTable;
    optionsTable[1].arg = databaseOptionsTable;
    optionsTable[2].arg = userOptionsTable;

#if HAVE_MCHECK_H && HAVE_MTRACE
    mtrace();   /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
#endif

    optCon = poptGetContext("createuser", argc, argv, optionsTable, 0);
    poptReadConfigFile(optCon, rcfile );

    /* although there are no options to be parsed, check for --help */
    poptGetNextOpt(optCon);

    optCon = poptFreeContext(optCon);

    printf( "dbusername %s\tdbpassword %s\n"
            "txhost %s\ttxsslport %d\ttxstoreid %d\tpathofkeyfile %s\n"
	    "username %s\tpassword %s\tfirstname %s\tlastname %s\n"
	    "addr1 %s\taddr2 %s\tcity %s\tstate %s\tpostal %s\n"
	    "country %s\temail %s\tdayphone %s\tfax %s\n",
        dbUserName, dbPassword,
        txHost, txSslPort, txStoreId, PathnameOfKeyFile,
        username, password, firstname, lastname,
        addr1,addr2, city, state, postal,
        country, email, dayphone, fax);
    return 0;
}
Example #7
0
poptContext
rpmcliInit(int argc, char *const argv[], struct poptOption * optionsTable)
{
    poptContext optCon;
    int rc;
    const char *ctx, *execPath;

    setprogname(argv[0]);       /* Retrofit glibc __progname */

    /* XXX glibc churn sanity */
    if (__progname == NULL) {
	if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
	else __progname = argv[0];
    }

#if defined(ENABLE_NLS)
    (void) setlocale(LC_ALL, "" );

    (void) bindtextdomain(PACKAGE, LOCALEDIR);
    (void) textdomain(PACKAGE);
#endif

    rpmSetVerbosity(RPMLOG_NOTICE);

    if (optionsTable == NULL) {
	/* Read rpm configuration (if not already read). */
	rpmcliConfigured();
	return NULL;
    }

    /* XXX hack to get popt working from build tree wrt lt-foo names */
    ctx = rstreqn(__progname, "lt-", 3) ? __progname + 3 : __progname;

    optCon = poptGetContext(ctx, argc, (const char **)argv, optionsTable, 0);
    {
	char *poptfile = rpmGenPath(rpmConfigDir(), LIBRPMALIAS_FILENAME, NULL);
	(void) poptReadConfigFile(optCon, poptfile);
	free(poptfile);
    }
    (void) poptReadDefaultConfig(optCon, 1);

    if ((execPath = getenv("RPM_POPTEXEC_PATH")) == NULL)
	execPath = LIBRPMALIAS_EXECPATH;
    poptSetExecPath(optCon, execPath, 1);

    /* Process all options, whine if unknown. */
    while ((rc = poptGetNextOpt(optCon)) > 0) {
	fprintf(stderr, _("%s: option table misconfigured (%d)\n"),
		__progname, rc);
	exit(EXIT_FAILURE);
    }

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

    /* Read rpm configuration (if not already read). */
    rpmcliConfigured();

    if (_debug) {
	rpmIncreaseVerbosity();
	rpmIncreaseVerbosity();
    }

    return optCon;
}
Example #8
0
/*@-globstate@*/
poptContext
rpmcliInit(int argc, char *const argv[], struct poptOption * optionsTable)
	/*@globals rpmpoptfiles @*/
	/*@modifies rpmpoptfiles @*/
{
    poptContext optCon;
    int rc;
    int xx;
    int i;

#if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE)
    /*@-noeffect@*/
    mtrace();   /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
    /*@=noeffect@*/
#endif
/*@-globs -mods@*/
    setprogname(argv[0]);       /* Retrofit glibc __progname */

    /* XXX glibc churn sanity */
    if (__progname == NULL) {
	if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
	else __progname = argv[0];
    }
/*@=globs =mods@*/

    /* Insure that stdin/stdout/stderr are open, lest stderr end up in rpmdb. */
   {	static const char _devnull[] = "/dev/null";
#if defined(STDIN_FILENO)
	(void) checkfd(_devnull, STDIN_FILENO, O_RDONLY);
#endif
#if defined(STDOUT_FILENO)
	(void) checkfd(_devnull, STDOUT_FILENO, O_WRONLY);
#endif
#if defined(STDERR_FILENO)
	(void) checkfd(_devnull, STDERR_FILENO, O_WRONLY);
#endif
   }

#if defined(RPM_VENDOR_WINDRIVER)
    (void) setRuntimeRelocPaths();
#endif

#if defined(ENABLE_NLS) && !defined(__LCLINT__)
    (void) setlocale(LC_ALL, "" );
    (void) bindtextdomain(PACKAGE, __localedir);
    (void) textdomain(PACKAGE);
#endif

    rpmSetVerbosity(RPMLOG_NOTICE);

    if (optionsTable == NULL) {
	/* Read rpm configuration (if not already read). */
	rpmcliConfigured();
	return NULL;
    }

    /* read all RPM POPT configuration files */
    for (i = 1; i < argc; i++) {
	if (strcmp(argv[i], "--rpmpopt") == 0 && i+1 < argc) {
	    rpmpoptfiles = argv[i+1];
	    break;
	}
	else if (strncmp(argv[i], "--rpmpopt=", 10) == 0) {
	    rpmpoptfiles = argv[i]+10;
	    break;
	}
    }

    /* XXX strip off the "lt-" prefix so that rpmpopt aliases "work". */
{   static const char lt_[] = "lt-";
    const char * s = __progname;
    if (!strncmp(s, lt_, sizeof(lt_)-1))
	s += sizeof(lt_)-1;
/*@-nullpass -temptrans@*/
    optCon = poptGetContext(s, argc, (const char **)argv, optionsTable, 0);
/*@=nullpass =temptrans@*/
}

#if defined(RPM_VENDOR_OPENPKG) /* stick-with-rpm-file-sanity-checking */ || \
    !defined(POPT_ERROR_BADCONFIG)	/* XXX POPT 1.15 retrofit */
  { char * path_buf = xstrdup(rpmpoptfiles);
    char *path;
    char *path_next;

    for (path = path_buf; path != NULL && *path != '\0'; path = path_next) {
        const char **av;
        int ac;

        /* locate start of next path element */
        path_next = strchr(path, ':');
        if (path_next != NULL && *path_next == ':')
            *path_next++ = '\0';
        else
            path_next = path + strlen(path);

        /* glob-expand the path element */
        ac = 0;
        av = NULL;
        if ((xx = rpmGlob(path, &ac, &av)) != 0)
            continue;

        /* work-off each resulting file from the path element */
        for (i = 0; i < ac; i++) {
	    const char *fn = av[i];
	    if (fn[0] == '@' /* attention */) {
		fn++;
		if (!rpmSecuritySaneFile(fn)) {
		    rpmlog(RPMLOG_WARNING, "existing POPT configuration file \"%s\" considered INSECURE -- not loaded\n", fn);
		    /*@innercontinue@*/ continue;
		}
	    }
	    (void) poptReadConfigFile(optCon, fn);
            av[i] = _free(av[i]);
        }
        av = _free(av);
    }
    path_buf = _free(path_buf);
  }
#else
    /* XXX FIXME: better error message is needed. */
    if ((xx = poptReadConfigFiles(optCon, rpmpoptfiles)) != 0)
	rpmlog(RPMLOG_WARNING, "existing POPT configuration file \"%s\" considered INSECURE -- not loaded\n", rpmpoptfiles);
#endif

#if defined(RPM_VENDOR_WINDRIVER)
    {	const char * poptAliasFn = rpmGetPath(__usrlibrpm, "/rpmpopt", NULL);
	(void) poptReadConfigFile(optCon, poptAliasFn);
	poptAliasFn = _free(poptAliasFn);
    }
#endif

    /* read standard POPT configuration files */
    /* XXX FIXME: the 2nd arg useEnv flag is UNUSED. */
    (void) poptReadDefaultConfig(optCon, 1);

#if defined(RPM_VENDOR_WINDRIVER)
    {	const char * poptExecPath = rpmGetPath(__usrlibrpm, NULL);
	poptSetExecPath(optCon, poptExecPath, 1);
	poptExecPath = _free(poptExecPath);
    }
#else
    poptSetExecPath(optCon, USRLIBRPM, 1);
#endif

    /* Process all options, whine if unknown. */
    while ((rc = poptGetNextOpt(optCon)) > 0) {
	const char * optArg = poptGetOptArg(optCon);
/*@-dependenttrans -observertrans@*/	/* Avoid popt memory leaks. */
	optArg = _free(optArg);
/*@=dependenttrans =observertrans @*/
	switch (rc) {
	default:
/*@-nullpass@*/
	    fprintf(stderr, _("%s: option table misconfigured (%d)\n"),
		__progname, rc);
/*@=nullpass@*/
	    exit(EXIT_FAILURE);

	    /*@notreached@*/ /*@switchbreak@*/ break;
        }
    }

    if (rc < -1) {
/*@-nullpass@*/
	fprintf(stderr, "%s: %s: %s\n", __progname,
		poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
		poptStrerror(rc));
/*@=nullpass@*/
	exit(EXIT_FAILURE);
    }

    /* Read rpm configuration (if not already read). */
    rpmcliConfigured();

    if (_debug) {
	rpmIncreaseVerbosity();
	rpmIncreaseVerbosity();
    }

    /* Initialize header stat collection. */
/*@-mods@*/
    _hdr_stats = _rpmts_stats;
/*@=mods@*/

    return optCon;
}
Example #9
0
int poptReadDefaultConfig(poptContext con, int useEnv) {
	char * envName, * envValue;
	char * fn, * home, * chptr;
	int rc, skip;
	struct poptAlias alias;

	if (!con->appName) return 0;

	rc = poptReadConfigFile(con, "/etc/popt");
	if (rc) return rc;
	if (getuid() != geteuid()) return 0;

	if ((home = getenv("HOME"))) {
		fn = (char*)alloca(strlen(home) + 20);
		sprintf(fn, "%s/.popt", home);
		rc = poptReadConfigFile(con, fn);
		if (rc) return rc;
	}

	envName = (char*)alloca(strlen(con->appName) + 20);
	strcpy(envName, con->appName);
	chptr = envName;
	while (*chptr) {
		*chptr = toupper(*chptr);
		chptr++;
	}
	strcat(envName, "_POPT_ALIASES");

	if (useEnv && (envValue = getenv(envName))) {
		envValue = strcpy((char*)alloca(strlen(envValue) + 1), envValue);

		while (envValue && *envValue) {
			chptr = strchr(envValue, '=');
			if (!chptr) {
				envValue = strchr(envValue, '\n');
				if (envValue) envValue++;
				continue;
			}

			*chptr = '\0';

			skip = 0;
			if (!strncmp(envValue, "--", 2)) {
				alias.longName = envValue + 2;
				alias.shortName = '\0';
			} else if (*envValue == '-' && strlen(envValue) == 2) {
				alias.longName = NULL;	
				alias.shortName = envValue[1];
			} else {
				skip = 1;
			}

			envValue = chptr + 1;
			chptr = strchr(envValue, '\n');
			if (chptr) *chptr = '\0';

			if (!skip) {
				poptParseArgvString(envValue, &alias.argc, &alias.argv);
				poptAddAlias(con, alias, 0);
			}

			if (chptr)
				envValue = chptr + 1;
			else
				envValue = NULL;
		}
	}

	return 0;
}
Example #10
0
int main(int argc, const char ** argv)
	/*@globals pass2, fileSystem, internalState @*/
	/*@modifies pass2, fileSystem, internalState @*/
{
    int rc;
    int ec = 0;
    poptContext optCon;
    const char ** rest;
    int help = 0;
    int usage = 0;

#if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE)
    /*@-moduncon -noeffectuncon@*/
    mtrace();   /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
    /*@=moduncon =noeffectuncon@*/
#endif

/*@-modobserver@*/
    resetVars();
/*@=modobserver@*/
/*@-temptrans@*/
    optCon = poptGetContext("test1", argc, argv, options, 0);
/*@=temptrans@*/
    (void) poptReadConfigFile(optCon, "./test-poptrc");
    (void) poptReadDefaultConfig(optCon, 1);

    poptSetExecPath(optCon, ".", 1);

#if 1
    while ((rc = poptGetNextOpt(optCon)) > 0)	/* Read all the options ... */
	{};

    poptResetContext(optCon);			/* ... and then start over. */
/*@-modobserver@*/
    resetVars();
/*@=modobserver@*/
#endif

    pass2 = 1;
    if ((rc = poptGetNextOpt(optCon)) < -1) {
	fprintf(stderr, "test1: bad argument %s: %s\n",
		poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
		poptStrerror(rc));
	ec = 2;
	goto exit;
    }

    if (help) {
	poptPrintHelp(optCon, stdout, 0);
	goto exit;
    }
    if (usage) {
	poptPrintUsage(optCon, stdout, 0);
	goto exit;
    }

    fprintf(stdout, "arg1: %d arg2: %s", arg1, arg2);

    if (arg3)
	fprintf(stdout, " arg3: %d", arg3);
    if (inc)
	fprintf(stdout, " inc: %d", inc);
    if (shortopt)
	fprintf(stdout, " short: %d", shortopt);
    if (aVal != bVal)
	fprintf(stdout, " aVal: %d", aVal);
    if (aFlag != bFlag)
	fprintf(stdout, " aFlag: 0x%x", aFlag);
    if (aShort != bShort)
	fprintf(stdout, " aShort: %hd", aShort);
    if (aInt != bInt)
	fprintf(stdout, " aInt: %d", aInt);
    if (aLong != bLong)
	fprintf(stdout, " aLong: %ld", aLong);
    if (aLongLong != bLongLong)
	fprintf(stdout, " aLongLong: %lld", aLongLong);
/*@-realcompare@*/
    if (aFloat != bFloat)
	fprintf(stdout, " aFloat: %g", (double)aFloat);
    if (aDouble != bDouble)
	fprintf(stdout, " aDouble: %g", aDouble);
/*@=realcompare@*/
    if (aArgv != NULL) {
	const char **av = aArgv;
	const char * arg;
	fprintf(stdout, " aArgv:");
	while ((arg = *av++) != NULL)
	    fprintf(stdout, " %s", arg);
    }
    if (aBits) {
	const char * separator = " ";
	size_t i;
	fprintf(stdout, " aBits:");
 	for (i = 0; i < nattributes; i++) {
	    if (!poptBitsChk(aBits, attributes[i]))
		continue;
	    fprintf(stdout, "%s%s", separator, attributes[i]);
	    separator = ",";
	}
    }
/*@-nullpass@*/
    if (oStr != (char *)-1)
	fprintf(stdout, " oStr: %s", (oStr ? oStr : "(none)"));
/*@=nullpass@*/
    if (singleDash)
	fprintf(stdout, " -");

    if (poptPeekArg(optCon) != NULL) {
	rest = poptGetArgs(optCon);
	if (rest) {
	    fprintf(stdout, " rest:");
	    while (*rest) {
		fprintf(stdout, " %s", *rest);
		rest++;
	    }
	}
    }

    fprintf(stdout, "\n");

exit:
    optCon = poptFreeContext(optCon);
#if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE)
    /*@-moduncon -noeffectuncon@*/
    muntrace();   /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
    /*@=moduncon =noeffectuncon@*/
#endif
    return ec;
}