|
Mixe for Privacy and Anonymity in the Internet
|
#include <stdio.h>Go to the source code of this file.
Classes | |
| struct | poptOption |
| struct | poptAlias |
Defines | |
| #define | POPT_OPTION_DEPTH 10 |
| #define | POPT_ARG_NONE 0 |
| #define | POPT_ARG_STRING 1 |
| #define | POPT_ARG_INT 2 |
| #define | POPT_ARG_LONG 3 |
| #define | POPT_ARG_INCLUDE_TABLE 4 /* arg points to table */ |
| #define | POPT_ARG_CALLBACK |
| #define | POPT_ARG_INTL_DOMAIN |
| #define | POPT_ARG_VAL 7 /* arg should take value val */ |
| #define | POPT_ARG_MASK 0x0000FFFF |
| #define | POPT_ARGFLAG_ONEDASH 0x80000000 /* allow -longoption */ |
| #define | POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /* don't show in help/usage */ |
| #define | POPT_ARGFLAG_STRIP 0x20000000 /* strip this arg from argv (only applies to long args) */ |
| #define | POPT_CBFLAG_PRE 0x80000000 /* call the callback before parse */ |
| #define | POPT_CBFLAG_POST 0x40000000 /* call the callback after parse */ |
| #define | POPT_CBFLAG_INC_DATA |
| #define | POPT_ERROR_NOARG -10 |
| #define | POPT_ERROR_BADOPT -11 |
| #define | POPT_ERROR_OPTSTOODEEP -13 |
| #define | POPT_ERROR_BADQUOTE -15 /* only from poptParseArgString() */ |
| #define | POPT_ERROR_ERRNO -16 /* only from poptParseArgString() */ |
| #define | POPT_ERROR_BADNUMBER -17 |
| #define | POPT_ERROR_OVERFLOW -18 |
| #define | POPT_BADOPTION_NOALIAS (1 << 0) /* don't go into an alias */ |
| #define | POPT_CONTEXT_NO_EXEC (1 << 0) /* ignore exec expansions */ |
| #define | POPT_CONTEXT_KEEP_FIRST (1 << 1) /* pay attention to argv[0] */ |
| #define | POPT_CONTEXT_POSIXMEHARDER (1 << 2) /* options can't follow args */ |
| #define | POPT_AUTOHELP |
Typedefs | |
| typedef struct poptContext_s * | poptContext |
| typedef struct poptOption * | poptOption |
| typedef void(* | poptCallbackType )(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data) |
Enumerations | |
| enum | poptCallbackReason { POPT_CALLBACK_REASON_PRE, POPT_CALLBACK_REASON_POST, POPT_CALLBACK_REASON_OPTION } |
Functions | |
| poptContext | poptGetContext (const char *name, int argc, const char **argv, const struct poptOption *options, int flags) |
| void | poptResetContext (poptContext con) |
| int | poptGetNextOpt (poptContext con) |
| const char * | poptGetOptArg (poptContext con) |
| const char * | poptGetArg (poptContext con) |
| const char * | poptPeekArg (poptContext con) |
| const char ** | poptGetArgs (poptContext con) |
| const char * | poptBadOption (poptContext con, int flags) |
| void | poptFreeContext (poptContext con) |
| int | poptStuffArgs (poptContext con, const char **argv) |
| int | poptAddAlias (poptContext con, struct poptAlias alias, int flags) |
| int | poptReadConfigFile (poptContext con, const char *fn) |
| int | poptReadDefaultConfig (poptContext con, int useEnv) |
| int | poptDupArgv (int argc, const char **argv, int *argcPtr, const char ***argvPtr) |
| int | poptParseArgvString (const char *s, int *argcPtr, const char ***argvPtr) |
| const char * | poptStrerror (const int error) |
| void | poptSetExecPath (poptContext con, const char *path, int allowAbsolute) |
| void | poptPrintHelp (poptContext con, FILE *f, int flags) |
| void | poptPrintUsage (poptContext con, FILE *f, int flags) |
| void | poptSetOtherOptionHelp (poptContext con, const char *text) |
| const char * | poptGetInvocationName (poptContext con) |
| int | poptStrippedArgv (poptContext con, int argc, char **argv) |
Variables | |
| struct poptOption | poptHelpOptions [] |
| #define POPT_ARG_CALLBACK |
| #define POPT_ARG_INCLUDE_TABLE 4 /* arg points to table */ |
| #define POPT_ARG_INT 2 |
Definition at line 18 of file popt.h.
Referenced by CACmdLnOptions::parse(), and poptGetNextOpt().
| #define POPT_ARG_INTL_DOMAIN |
| #define POPT_ARG_LONG 3 |
Definition at line 19 of file popt.h.
Referenced by poptGetNextOpt().
| #define POPT_ARG_MASK 0x0000FFFF |
Definition at line 24 of file popt.h.
Referenced by poptGetNextOpt().
| #define POPT_ARG_NONE 0 |
Definition at line 16 of file popt.h.
Referenced by CACmdLnOptions::parse(), and poptGetNextOpt().
| #define POPT_ARG_STRING 1 |
Definition at line 17 of file popt.h.
Referenced by CACmdLnOptions::parse(), and poptGetNextOpt().
| #define POPT_ARG_VAL 7 /* arg should take value val */ |
Definition at line 23 of file popt.h.
Referenced by poptGetNextOpt().
| #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /* don't show in help/usage */ |
| #define POPT_ARGFLAG_ONEDASH 0x80000000 /* allow -longoption */ |
| #define POPT_ARGFLAG_STRIP 0x20000000 /* strip this arg from argv (only applies to long args) */ |
Definition at line 27 of file popt.h.
Referenced by poptGetNextOpt().
| #define POPT_AUTOHELP |
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
0, "Help options", NULL },
Definition at line 66 of file popt.h.
Referenced by CACmdLnOptions::parse().
| #define POPT_BADOPTION_NOALIAS (1 << 0) /* don't go into an alias */ |
Definition at line 41 of file popt.h.
Referenced by poptBadOption().
| #define POPT_CBFLAG_INC_DATA |
| #define POPT_CBFLAG_POST 0x40000000 /* call the callback after parse */ |
| #define POPT_CBFLAG_PRE 0x80000000 /* call the callback before parse */ |
| #define POPT_CONTEXT_KEEP_FIRST (1 << 1) /* pay attention to argv[0] */ |
Definition at line 45 of file popt.h.
Referenced by poptGetContext().
| #define POPT_CONTEXT_NO_EXEC (1 << 0) /* ignore exec expansions */ |
| #define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /* options can't follow args */ |
Definition at line 46 of file popt.h.
Referenced by poptGetContext(), and poptGetNextOpt().
| #define POPT_ERROR_BADNUMBER -17 |
Definition at line 37 of file popt.h.
Referenced by poptGetNextOpt(), and poptStrerror().
| #define POPT_ERROR_BADOPT -11 |
| #define POPT_ERROR_BADQUOTE -15 /* only from poptParseArgString() */ |
| #define POPT_ERROR_ERRNO -16 /* only from poptParseArgString() */ |
| #define POPT_ERROR_NOARG -10 |
| #define POPT_ERROR_OPTSTOODEEP -13 |
| #define POPT_ERROR_OVERFLOW -18 |
Definition at line 38 of file popt.h.
Referenced by poptGetNextOpt(), and poptStrerror().
| #define POPT_OPTION_DEPTH 10 |
Definition at line 14 of file popt.h.
Referenced by poptStuffArgs().
| typedef void(* poptCallbackType)(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data) |
| typedef struct poptContext_s* poptContext |
| typedef struct poptOption* poptOption |
| enum poptCallbackReason |
| int poptAddAlias | ( | poptContext | con, |
| struct poptAlias | alias, | ||
| int | flags | ||
| ) |
Definition at line 669 of file popt.cpp.
References poptContext_s::aliases, poptAlias::argc, poptAlias::argv, poptAlias::longName, poptContext_s::numAliases, and poptAlias::shortName.
{
int aliasNum = con->numAliases++;
struct poptAlias * alias;
/* SunOS won't realloc(NULL, ...) */
if (!con->aliases)
con->aliases = (struct poptAlias*)malloc(sizeof(newAlias) * con->numAliases);
else
con->aliases = (struct poptAlias*)realloc(con->aliases,
sizeof(newAlias) * con->numAliases);
alias = con->aliases + aliasNum;
alias->longName = (newAlias.longName)
? strcpy((char*)malloc(strlen(newAlias.longName) + 1), newAlias.longName)
: NULL;
alias->shortName = newAlias.shortName;
alias->argc = newAlias.argc;
alias->argv = newAlias.argv;
return 0;
}
| const char* poptBadOption | ( | poptContext | con, |
| int | flags | ||
| ) |
Definition at line 693 of file popt.cpp.
References optionStackEntry::argv, optionStackEntry::next, poptContext_s::optionStack, poptContext_s::os, and POPT_BADOPTION_NOALIAS.
{
struct optionStackEntry * os;
if (flags & POPT_BADOPTION_NOALIAS)
os = con->optionStack;
else
os = con->os;
return os->argv[os->next - 1];
}
| int poptDupArgv | ( | int | argc, |
| const char ** | argv, | ||
| int * | argcPtr, | ||
| const char *** | argvPtr | ||
| ) |
Definition at line 10 of file poptparse.cpp.
References POPT_ERROR_NOARG.
Referenced by poptParseArgvString(), and poptStuffArgs().
{
size_t nb = (argc + 1) * sizeof(*argv);
const char ** argv2;
char * dst;
int i;
for (i = 0; i < argc; i++) {
if (argv[i] == NULL)
return POPT_ERROR_NOARG;
nb += strlen(argv[i]) + 1;
}
dst = (char *)malloc(nb);
argv2 = (const char**) dst;
dst += (argc + 1) * sizeof(*argv);
for (i = 0; i < argc; i++) {
argv2[i] = dst;
dst += strlen(strcpy(dst, argv[i])) + 1;
}
argv2[argc] = NULL;
*argvPtr = argv2;
*argcPtr = argc;
return 0;
}
| void poptFreeContext | ( | poptContext | con | ) |
Definition at line 641 of file popt.cpp.
References poptContext_s::aliases, poptContext_s::appName, poptContext_s::arg_strip, optionStackEntry::argb, poptAlias::argv, poptContext_s::execPath, poptContext_s::execs, poptContext_s::finalArgv, poptContext_s::leftovers, execEntry::longName, poptAlias::longName, poptContext_s::numAliases, poptContext_s::numExecs, poptContext_s::os, poptContext_s::otherHelp, PBM_FREE, poptResetContext(), execEntry::script, and xfree.
Referenced by CACmdLnOptions::parse().
{
int i;
poptResetContext(con);
if (con->os->argb) free(con->os->argb);
for (i = 0; i < con->numAliases; i++) {
if (con->aliases[i].longName) xfree(con->aliases[i].longName);
free((void*)con->aliases[i].argv);
}
for (i = 0; i < con->numExecs; i++) {
if (con->execs[i].longName) xfree(con->execs[i].longName);
xfree(con->execs[i].script);
}
if (con->execs) xfree(con->execs);
free((void*)con->leftovers);
free((void*)con->finalArgv);
if (con->appName) xfree(con->appName);
if (con->aliases) free(con->aliases);
if (con->otherHelp) xfree(con->otherHelp);
if (con->execPath) xfree(con->execPath);
if (con->arg_strip) PBM_FREE(con->arg_strip);
free(con);
}
| const char* poptGetArg | ( | poptContext | con | ) |
Definition at line 622 of file popt.cpp.
References poptContext_s::leftovers, poptContext_s::nextLeftover, and poptContext_s::numLeftovers.
{
if (con->numLeftovers == con->nextLeftover) return NULL;
return con->leftovers[con->nextLeftover++];
}
| const char** poptGetArgs | ( | poptContext | con | ) |
Definition at line 632 of file popt.cpp.
References poptContext_s::leftovers, poptContext_s::nextLeftover, and poptContext_s::numLeftovers.
{
if (con->numLeftovers == con->nextLeftover) return NULL;
/* some apps like [like RPM ;-) ] need this NULL terminated */
con->leftovers[con->numLeftovers] = NULL;
return (con->leftovers + con->nextLeftover);
}
| poptContext poptGetContext | ( | const char * | name, |
| int | argc, | ||
| const char ** | argv, | ||
| const struct poptOption * | options, | ||
| int | flags | ||
| ) |
Definition at line 50 of file popt.cpp.
References poptContext_s::aliases, poptContext_s::appName, poptContext_s::arg_strip, optionStackEntry::argb, optionStackEntry::argc, optionStackEntry::argv, poptContext_s::execAbsolute, poptContext_s::execs, poptContext_s::finalArgv, poptContext_s::finalArgvAlloced, poptContext_s::flags, flags, poptContext_s::leftovers, optionStackEntry::next, poptContext_s::numAliases, poptContext_s::numExecs, poptContext_s::options, poptContext_s::optionStack, poptContext_s::os, POPT_CONTEXT_KEEP_FIRST, and POPT_CONTEXT_POSIXMEHARDER.
Referenced by CACmdLnOptions::parse().
{
poptContext con = (poptContext)malloc(sizeof(*con));
memset(con, 0, sizeof(*con));
con->os = con->optionStack;
con->os->argc = argc;
con->os->argv = argv;
con->os->argb = NULL;
if (!(flags & POPT_CONTEXT_KEEP_FIRST))
con->os->next = 1; /* skip argv[0] */
con->leftovers = (const char**)calloc( (argc + 1), sizeof(char *) );
con->options = options;
con->aliases = NULL;
con->numAliases = 0;
con->flags = flags;
con->execs = NULL;
con->numExecs = 0;
con->finalArgvAlloced = argc * 2;
con->finalArgv = (const char**)calloc( con->finalArgvAlloced, sizeof(*con->finalArgv) );
con->execAbsolute = 1;
con->arg_strip = NULL;
if (getenv("POSIXLY_CORRECT") || getenv("POSIX_ME_HARDER"))
con->flags |= POPT_CONTEXT_POSIXMEHARDER;
if (name)
con->appName = strcpy((char*)malloc(strlen(name) + 1), name);
invokeCallbacks(con, con->options, 0);
return con;
}
| const char* poptGetInvocationName | ( | poptContext | con | ) |
Definition at line 752 of file popt.cpp.
References optionStackEntry::argv, and poptContext_s::os.
| int poptGetNextOpt | ( | poptContext | con | ) |
Definition at line 401 of file popt.cpp.
References alloca(), poptOption::arg, optionStackEntry::argb, optionStackEntry::argc, poptOption::argInfo, optionStackEntry::argv, poptContext_s::finalArgv, poptContext_s::finalArgvAlloced, poptContext_s::finalArgvCount, poptContext_s::flags, poptContext_s::leftovers, poptOption::longName, optionStackEntry::next, optionStackEntry::nextArg, optionStackEntry::nextCharArg, poptContext_s::numLeftovers, poptContext_s::options, poptContext_s::optionStack, poptContext_s::os, PBM_ISSET, POPT_, POPT_ARG_INT, POPT_ARG_LONG, POPT_ARG_MASK, POPT_ARG_NONE, POPT_ARG_STRING, POPT_ARG_VAL, POPT_ARGFLAG_STRIP, POPT_CALLBACK_REASON_OPTION, POPT_CONTEXT_POSIXMEHARDER, POPT_ERROR_BADNUMBER, POPT_ERROR_BADOPT, POPT_ERROR_NOARG, POPT_ERROR_OVERFLOW, poptContext_s::restLeftover, poptOption::shortName, poptOption::val, xfree, and xstrdup().
Referenced by CACmdLnOptions::parse().
{
const struct poptOption * opt = NULL;
int done = 0;
while (!done) {
const char * origOptString = NULL;
poptCallbackType cb = NULL;
const void * cbData = NULL;
const char * longArg = NULL;
int canstrip = 0;
while (!con->os->nextCharArg && con->os->next == con->os->argc
&& con->os > con->optionStack) {
cleanOSE(con->os--);
}
if (!con->os->nextCharArg && con->os->next == con->os->argc) {
invokeCallbacks(con, con->options, 1);
//if (con->doExec) execCommand(con);
return -1;
}
/* Process next long option */
if (!con->os->nextCharArg) {
char * localOptString, * optString;
int thisopt;
if (con->os->argb && PBM_ISSET(con->os->next, con->os->argb)) {
con->os->next++;
continue;
}
thisopt=con->os->next;
origOptString = con->os->argv[con->os->next++];
if (con->restLeftover || *origOptString != '-') {
con->leftovers[con->numLeftovers++] = origOptString;
if (con->flags & POPT_CONTEXT_POSIXMEHARDER)
con->restLeftover = 1;
continue;
}
/* Make a copy we can hack at */
localOptString = optString =
strcpy((char*)alloca(strlen(origOptString) + 1),
origOptString);
if (!optString[0])
return POPT_ERROR_BADOPT;
if (optString[1] == '-' && !optString[2]) {
con->restLeftover = 1;
continue;
} else {
char *oe;
int singleDash;
optString++;
if (*optString == '-')
singleDash = 0, optString++;
else
singleDash = 1;
/* XXX aliases with arg substitution need "--alias=arg" */
if (handleAlias(con, optString, '\0', NULL))
continue;
if (handleExec(con, optString, '\0'))
continue;
/* Check for "--long=arg" option. */
for (oe = optString; *oe && *oe != '='; oe++)
;
if (*oe == '=') {
*oe++ = '\0';
/* XXX longArg is mapped back to persistent storage. */
longArg = origOptString + (oe - localOptString);
}
opt = findOption(con->options, optString, '\0', &cb, &cbData,
singleDash);
if (!opt && !singleDash)
return POPT_ERROR_BADOPT;
}
if (!opt) {
con->os->nextCharArg = origOptString + 1;
} else {
if(con->os == con->optionStack &&
opt->argInfo & POPT_ARGFLAG_STRIP) {
canstrip = 1;
poptStripArg(con, thisopt);
}
}
}
/* Process next short option */
if (con->os->nextCharArg) {
origOptString = con->os->nextCharArg;
con->os->nextCharArg = NULL;
if (handleAlias(con, NULL, *origOptString,
origOptString + 1)) {
origOptString++;
continue;
}
if (handleExec(con, NULL, *origOptString))
continue;
opt = findOption(con->options, NULL, *origOptString, &cb,
&cbData, 0);
if (!opt)
return POPT_ERROR_BADOPT;
origOptString++;
if (*origOptString)
con->os->nextCharArg = origOptString;
}
if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE) {
*((int *)opt->arg) = 1;
} else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_VAL) {
if (opt->arg)
*((int *) opt->arg) = opt->val;
} else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) {
if (con->os->nextArg) {
xfree(con->os->nextArg);
con->os->nextArg = NULL;
}
if (longArg) {
con->os->nextArg = expandNextArg(con, longArg);
} else if (con->os->nextCharArg) {
con->os->nextArg = expandNextArg(con, con->os->nextCharArg);
con->os->nextCharArg = NULL;
} else {
while (con->os->next == con->os->argc &&
con->os > con->optionStack) {
cleanOSE(con->os--);
}
if (con->os->next == con->os->argc)
return POPT_ERROR_NOARG;
/* make sure this isn't part of a short arg or the
result of an alias expansion */
if(con->os == con->optionStack &&
opt->argInfo & POPT_ARGFLAG_STRIP &&
canstrip) {
poptStripArg(con, con->os->next);
}
con->os->nextArg = expandNextArg(con, con->os->argv[con->os->next++]);
}
if (opt->arg) {
long aLong;
char *end;
switch (opt->argInfo & POPT_ARG_MASK) {
case POPT_ARG_STRING:
/* XXX memory leak, hard to plug */
*((const char **) opt->arg) = xstrdup(con->os->nextArg);
break;
case POPT_ARG_INT:
case POPT_ARG_LONG:
aLong = strtol(con->os->nextArg, &end, 0);
if (!(end && *end == '\0'))
return POPT_ERROR_BADNUMBER;
if (aLong == LONG_MIN || aLong == LONG_MAX)
return POPT_ERROR_OVERFLOW;
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_LONG) {
*((long *) opt->arg) = aLong;
} else {
if (aLong > INT_MAX || aLong < INT_MIN)
return POPT_ERROR_OVERFLOW;
*((int *) opt->arg) = aLong;
}
break;
default:
fprintf(stdout, POPT_("option type (%d) not implemented in popt\n"),
opt->argInfo & POPT_ARG_MASK);
exit(EXIT_FAILURE);
}
}
}
if (cb)
cb(con, POPT_CALLBACK_REASON_OPTION, opt, con->os->nextArg, cbData);
else if (opt->val && ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_VAL))
done = 1;
if ((con->finalArgvCount + 2) >= (con->finalArgvAlloced)) {
con->finalArgvAlloced += 10;
con->finalArgv = (const char**)realloc((void*)con->finalArgv,
sizeof(*con->finalArgv) * con->finalArgvAlloced);
}
{ char *s = (char*)malloc((opt->longName ? strlen(opt->longName) : 0) + 3);
if (opt->longName)
sprintf(s, "--%s", opt->longName);
else
sprintf(s, "-%c", opt->shortName);
con->finalArgv[con->finalArgvCount++] = s;
}
if (opt->arg && (opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE
&& (opt->argInfo & POPT_ARG_MASK) != POPT_ARG_VAL) {
con->finalArgv[con->finalArgvCount++] = xstrdup(con->os->nextArg);
}
}
return opt->val;
}
| const char* poptGetOptArg | ( | poptContext | con | ) |
Definition at line 616 of file popt.cpp.
References optionStackEntry::nextArg, and poptContext_s::os.
| int poptParseArgvString | ( | const char * | s, |
| int * | argcPtr, | ||
| const char *** | argvPtr | ||
| ) |
Definition at line 39 of file poptparse.cpp.
References alloca(), POPT_ARGV_ARRAY_GROW_DELTA, POPT_ERROR_BADQUOTE, and poptDupArgv().
{
const char * src;
char quote = '\0';
int argvAlloced = POPT_ARGV_ARRAY_GROW_DELTA;
const char ** argv = (const char **)malloc(sizeof(*argv) * argvAlloced);
int argc = 0;
int buflen = strlen(s) + 1;
char * buf = (char*)memset(alloca(buflen), 0, buflen);
argv[argc] = buf;
for (src = s; *src; src++) {
if (quote == *src) {
quote = '\0';
} else if (quote) {
if (*src == '\\') {
src++;
if (!*src) {
free((void*)argv);
return POPT_ERROR_BADQUOTE;
}
if (*src != quote) *buf++ = '\\';
}
*buf++ = *src;
} else if (isspace(*src)) {
if (*argv[argc]) {
buf++, argc++;
if (argc == argvAlloced) {
argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA;
argv = (const char**)realloc((void*)argv, sizeof(*argv) * argvAlloced);
}
argv[argc] = buf;
}
} else switch (*src) {
case '"':
case '\'':
quote = *src;
break;
case '\\':
src++;
if (!*src) {
free((void*)argv);
return POPT_ERROR_BADQUOTE;
}
/*@fallthrough@*/
default:
*buf++ = *src;
break;
}
}
if (strlen(argv[argc])) {
argc++, buf++;
}
(void) poptDupArgv(argc, argv, argcPtr, argvPtr);
free((void*)argv);
return 0;
}
| const char* poptPeekArg | ( | poptContext | con | ) |
Definition at line 627 of file popt.cpp.
References poptContext_s::leftovers, poptContext_s::nextLeftover, and poptContext_s::numLeftovers.
{
if (con->numLeftovers == con->nextLeftover) return NULL;
return con->leftovers[con->nextLeftover];
}
| void poptPrintHelp | ( | poptContext | con, |
| FILE * | f, | ||
| int | flags | ||
| ) |
Definition at line 186 of file popthelp.cpp.
References poptContext_s::options, poptContext_s::otherHelp, and POPT_.
| void poptPrintUsage | ( | poptContext | con, |
| FILE * | f, | ||
| int | flags | ||
| ) |
Definition at line 283 of file popthelp.cpp.
References poptContext_s::options, and poptContext_s::otherHelp.
| int poptReadConfigFile | ( | poptContext | con, |
| const char * | fn | ||
| ) |
| int poptReadDefaultConfig | ( | poptContext | con, |
| int | useEnv | ||
| ) |
| void poptResetContext | ( | poptContext | con | ) |
Definition at line 103 of file popt.cpp.
References poptContext_s::arg_strip, optionStackEntry::argb, optionStackEntry::currAlias, poptContext_s::doExec, poptContext_s::finalArgv, poptContext_s::finalArgvCount, optionStackEntry::next, optionStackEntry::nextArg, optionStackEntry::nextCharArg, poptContext_s::nextLeftover, poptContext_s::numLeftovers, poptContext_s::optionStack, poptContext_s::os, PBM_FREE, poptContext_s::restLeftover, and xfree.
Referenced by poptFreeContext().
{
int i;
while (con->os > con->optionStack) {
cleanOSE(con->os--);
}
if (con->os->argb) {
PBM_FREE(con->os->argb);
con->os->argb = NULL;
}
con->os->currAlias = NULL;
con->os->nextCharArg = NULL;
con->os->nextArg = NULL;
con->os->next = 1; /* skip argv[0] */
con->numLeftovers = 0;
con->nextLeftover = 0;
con->restLeftover = 0;
con->doExec = NULL;
for (i = 0; i < con->finalArgvCount; i++) {
if (con->finalArgv[i]) {
xfree(con->finalArgv[i]);
con->finalArgv[i] = NULL;
}
}
con->finalArgvCount = 0;
if (con->arg_strip) {
PBM_FREE(con->arg_strip);
con->arg_strip = NULL;
}
}
| void poptSetExecPath | ( | poptContext | con, |
| const char * | path, | ||
| int | allowAbsolute | ||
| ) |
Definition at line 25 of file popt.cpp.
References poptContext_s::execAbsolute, poptContext_s::execPath, xfree, and xstrdup().
{
if (con->execPath) xfree(con->execPath);
con->execPath = xstrdup(path);
con->execAbsolute = allowAbsolute;
}
| void poptSetOtherOptionHelp | ( | poptContext | con, |
| const char * | text | ||
| ) |
Definition at line 299 of file popthelp.cpp.
References poptContext_s::otherHelp, xfree, and xstrdup().
| const char* poptStrerror | ( | const int | error | ) |
Definition at line 710 of file popt.cpp.
References POPT_, POPT_ERROR_BADNUMBER, POPT_ERROR_BADOPT, POPT_ERROR_BADQUOTE, POPT_ERROR_ERRNO, POPT_ERROR_NOARG, POPT_ERROR_OPTSTOODEEP, and POPT_ERROR_OVERFLOW.
{
switch (error) {
case POPT_ERROR_NOARG:
return POPT_("missing argument");
case POPT_ERROR_BADOPT:
return POPT_("unknown option");
case POPT_ERROR_OPTSTOODEEP:
return POPT_("aliases nested too deeply");
case POPT_ERROR_BADQUOTE:
return POPT_("error in paramter quoting");
case POPT_ERROR_BADNUMBER:
return POPT_("invalid numeric value");
case POPT_ERROR_OVERFLOW:
return POPT_("number too large or too small");
case POPT_ERROR_ERRNO:
return strerror(errno);
default:
return POPT_("unknown error");
}
}
| int poptStrippedArgv | ( | poptContext | con, |
| int | argc, | ||
| char ** | argv | ||
| ) |
Definition at line 756 of file popt.cpp.
References poptContext_s::arg_strip, optionStackEntry::argc, and PBM_ISSET.
| int poptStuffArgs | ( | poptContext | con, |
| const char ** | argv | ||
| ) |
Definition at line 731 of file popt.cpp.
References optionStackEntry::argb, optionStackEntry::argc, optionStackEntry::argv, optionStackEntry::currAlias, optionStackEntry::next, optionStackEntry::nextArg, optionStackEntry::nextCharArg, poptContext_s::optionStack, poptContext_s::os, POPT_ERROR_OPTSTOODEEP, POPT_OPTION_DEPTH, poptDupArgv(), and optionStackEntry::stuffed.
{
int argc;
if ((con->os - con->optionStack) == POPT_OPTION_DEPTH)
return POPT_ERROR_OPTSTOODEEP;
for (argc = 0; argv[argc]; argc++)
;
con->os++;
con->os->next = 0;
con->os->nextArg = NULL;
con->os->nextCharArg = NULL;
con->os->currAlias = NULL;
poptDupArgv(argc, argv, &con->os->argc, &con->os->argv);
con->os->argb = NULL;
con->os->stuffed = 1;
return 0;
}
| struct poptOption poptHelpOptions[] |
Definition at line 21 of file popthelp.cpp.
1.7.6.1