Files | |
file | findme.c |
file | findme.h |
file | popt.c |
file | popt.h |
file | poptconfig.c |
file | popthelp.c |
file | poptint.h |
file | poptparse.c |
Data Structures | |
struct | poptOption |
struct | poptAlias |
struct | poptItem_s |
Arg type identifiers | |
#define | POPT_ARG_NONE 0 /*!< no arg */ |
#define | POPT_ARG_STRING 1 /*!< arg will be saved as string */ |
#define | POPT_ARG_INT 2 /*!< arg will be converted to int */ |
#define | POPT_ARG_LONG 3 /*!< arg will be converted to long */ |
#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_FLOAT 8 /*!< arg will be converted to float */ |
#define | POPT_ARG_DOUBLE 9 /*!< arg will be converted to double */ |
#define | POPT_ARG_MASK 0x0000FFFF |
Arg modifiers | |
#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_ARGFLAG_OPTIONAL 0x10000000 /*!< arg may be missing */ |
#define | POPT_ARGFLAG_OR 0x08000000 /*!< arg will be or'ed */ |
#define | POPT_ARGFLAG_NOR 0x09000000 /*!< arg will be nor'ed */ |
#define | POPT_ARGFLAG_AND 0x04000000 /*!< arg will be and'ed */ |
#define | POPT_ARGFLAG_NAND 0x05000000 /*!< arg will be nand'ed */ |
#define | POPT_ARGFLAG_XOR 0x02000000 /*!< arg will be xor'ed */ |
#define | POPT_ARGFLAG_NOT 0x01000000 /*!< arg will be negated */ |
#define | POPT_ARGFLAG_LOGICALOPS (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR) |
#define | POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR) |
#define | POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND) |
#define | POPT_ARGFLAG_SHOW_DEFAULT 0x00800000 /*!< show default value in --help */ |
Callback modifiers | |
#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_CBFLAG_SKIPOPTION 0x10000000 /*!< don't callback with option */ |
#define | POPT_CBFLAG_CONTINUE 0x08000000 /*!< continue callbacks with option */ |
Error return values | |
#define | POPT_ERROR_NOARG -10 /*!< missing argument */ |
#define | POPT_ERROR_BADOPT -11 /*!< unknown option */ |
#define | POPT_ERROR_OPTSTOODEEP -13 /*!< aliases nested too deeply */ |
#define | POPT_ERROR_BADQUOTE -15 /*!< error in paramter quoting */ |
#define | POPT_ERROR_ERRNO -16 /*!< errno set, use strerror(errno) */ |
#define | POPT_ERROR_BADNUMBER -17 /*!< invalid numeric value */ |
#define | POPT_ERROR_OVERFLOW -18 /*!< number too large or too small */ |
#define | POPT_ERROR_BADOPERATION -19 /*!< mutually exclusive logical operations requested */ |
#define | POPT_ERROR_NULLARG -20 /*!< opt->arg should not be NULL */ |
#define | POPT_ERROR_MALLOC -21 /*!< memory allocation failed */ |
poptBadOption() flags | |
#define | POPT_BADOPTION_NOALIAS (1 << 0) /*!< don't go into an alias */ |
poptGetContext() flags | |
#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_CONTEXT_ARG_OPTS (1 << 4) /*!< return args as options with value 0 */ |
Auto-generated help/usage | |
poptOption | poptAliasOptions [] |
Empty table marker to enable displaying popt alias/exec options. | |
Typedefs | |
typedef poptItem_s * | poptItem |
typedef poptContext_s * | poptContext |
typedef poptOption * | poptOption |
typedef void(* | poptCallbackType )(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data) |
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) |
poptContext | poptFreeContext (poptContext con) |
int | poptStuffArgs (poptContext con, const char **argv) |
int | poptAddAlias (poptContext con, struct poptAlias alias, int flags) |
int | poptAddItem (poptContext con, poptItem newItem, 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) |
int | poptConfigFileToString (FILE *fp, char **argstrp, int flags) |
const char *const | poptStrerror (const int error) |
void | poptSetExecPath (poptContext con, const char *path, int allowAbsolute) |
void | poptPrintHelp (poptContext con, FILE *fp, int flags) |
void | poptPrintUsage (poptContext con, FILE *fp, int flags) |
void | poptSetOtherOptionHelp (poptContext con, const char *text) |
const char * | poptGetInvocationName (poptContext con) |
int | poptStrippedArgv (poptContext con, int argc, char **argv) |
|
Value: 5 Definition at line 30 of file popt.h. Referenced by findOption(), invokeCallbacksOPTION(), invokeCallbacksPOST(), and invokeCallbacksPRE(). |
|
arg will be converted to double Definition at line 44 of file popt.h. Referenced by getArgDescrip(), poptGetNextOpt(), singleOptionDefaultValue(), and singleOptionHelp(). |
|
arg will be converted to float Definition at line 42 of file popt.h. Referenced by getArgDescrip(), poptGetNextOpt(), singleOptionDefaultValue(), and singleOptionHelp(). |
|
arg points to table Definition at line 28 of file popt.h. Referenced by findOption(), invokeCallbacksOPTION(), invokeCallbacksPOST(), invokeCallbacksPRE(), maxArgWidth(), showShortOptions(), singleTableHelp(), and singleTableUsage(). |
|
arg will be converted to int Definition at line 24 of file popt.h. Referenced by db3New(), getArgDescrip(), poptGetNextOpt(), singleOptionDefaultValue(), and singleOptionHelp(). |
|
Value: 6 Definition at line 35 of file popt.h. Referenced by getTableTranslationDomain(), itemUsage(), and singleTableUsage(). |
|
arg will be converted to long Definition at line 26 of file popt.h. Referenced by db3New(), getArgDescrip(), poptGetNextOpt(), singleOptionDefaultValue(), and singleOptionHelp(). |
|
Definition at line 47 of file popt.h. Referenced by db3New(), findOption(), getArgDescrip(), invokeCallbacksOPTION(), invokeCallbacksPOST(), invokeCallbacksPRE(), itemUsage(), maxArgWidth(), poptGetNextOpt(), showShortOptions(), singleOptionDefaultValue(), singleOptionHelp(), singleTableHelp(), and singleTableUsage(). |
|
no arg Definition at line 20 of file popt.h. Referenced by db3New(), getArgDescrip(), poptGetNextOpt(), singleOptionDefaultValue(), and singleOptionHelp(). |
|
arg will be saved as string Definition at line 22 of file popt.h. Referenced by configLine(), db3New(), getArgDescrip(), poptGetNextOpt(), singleOptionDefaultValue(), and singleOptionHelp(). |
|
arg should take value val Definition at line 40 of file popt.h. Referenced by db3New(), getArgDescrip(), poptGetNextOpt(), singleOptionDefaultValue(), and singleOptionHelp(). |
|
arg will be and'ed Definition at line 67 of file popt.h. Referenced by poptSaveInt(), poptSaveLong(), and singleOptionHelp(). |
|
don't show in help/usage Definition at line 56 of file popt.h. Referenced by configLine(), itemHelp(), itemUsage(), maxArgWidth(), poptAddAlias(), singleTableHelp(), and singleTableUsage(). |
|
Definition at line 75 of file popt.h. Referenced by poptSaveInt(), poptSaveLong(), and singleOptionHelp(). |
|
arg will be nand'ed |
|
arg will be nor'ed |
|
arg will be negated Definition at line 73 of file popt.h. Referenced by poptSaveInt(), poptSaveLong(), and singleOptionHelp(). |
|
allow -longoption Definition at line 54 of file popt.h. Referenced by findOption(), maxArgWidth(), poptGetNextOpt(), singleOptionHelp(), and singleOptionUsage(). |
|
arg may be missing Definition at line 60 of file popt.h. Referenced by maxArgWidth(), poptGetNextOpt(), and singleOptionHelp(). |
|
arg will be or'ed Definition at line 63 of file popt.h. Referenced by poptSaveInt(), poptSaveLong(), and singleOptionHelp(). |
|
show default value in --help Definition at line 83 of file popt.h. Referenced by singleOptionHelp(). |
|
strip this arg from argv(only applies to long args) Definition at line 58 of file popt.h. Referenced by poptGetNextOpt(). |
|
arg will be xor'ed Definition at line 71 of file popt.h. Referenced by poptSaveInt(), poptSaveLong(), and singleOptionHelp(). |
|
don't go into an alias Definition at line 135 of file popt.h. Referenced by doSetupMacro(), main(), parseDescription(), parseFiles(), parseScript(), poptBadOption(), and rpmcliInit(). |
|
clear arg bit(s) Definition at line 80 of file popt.h. Referenced by db3New(). |
|
set arg bit(s) Definition at line 78 of file popt.h. Referenced by db3New(), and prDbiOpenFlags(). |
|
continue callbacks with option Definition at line 101 of file popt.h. Referenced by invokeCallbacksOPTION(). |
|
Value: 0x20000000 Definition at line 96 of file popt.h. Referenced by findOption(). |
|
call the callback after parse Definition at line 94 of file popt.h. Referenced by invokeCallbacksPOST(). |
|
call the callback before parse Definition at line 92 of file popt.h. Referenced by invokeCallbacksPRE(). |
|
don't callback with option Definition at line 99 of file popt.h. Referenced by invokeCallbacksOPTION(). |
|
return args as options with value 0 Definition at line 149 of file popt.h. Referenced by poptGetNextOpt(). |
|
pay attention to argv[0] Definition at line 145 of file popt.h. Referenced by poptGetContext(), and showHelpIntro(). |
|
ignore exec expansions Definition at line 143 of file popt.h. Referenced by handleExec(). |
|
options can't follow args Definition at line 147 of file popt.h. Referenced by poptGetContext(), and poptGetNextOpt(). |
|
invalid numeric value Definition at line 119 of file popt.h. Referenced by poptGetNextOpt(), and poptStrerror(). |
|
mutually exclusive logical operations requested Definition at line 123 of file popt.h. Referenced by poptGetNextOpt(), poptSaveInt(), poptSaveLong(), and poptStrerror(). |
|
unknown option Definition at line 111 of file popt.h. Referenced by poptGetNextOpt(), and poptStrerror(). |
|
error in paramter quoting |
|
errno set, use strerror(errno) Definition at line 117 of file popt.h. Referenced by execCommand(), poptReadConfigFile(), and poptStrerror(). |
|
memory allocation failed |
|
missing argument |
|
opt->arg should not be NULL Definition at line 125 of file popt.h. Referenced by poptConfigFileToString(), poptSaveInt(), poptSaveLong(), and poptStrerror(). |
|
aliases nested too deeply Definition at line 113 of file popt.h. Referenced by handleAlias(), poptStrerror(), and poptStuffArgs(). |
|
number too large or too small Definition at line 121 of file popt.h. Referenced by poptConfigFileToString(), poptGetNextOpt(), and poptStrerror(). |
|
Table callback prototype.
Definition at line 262 of file popt.h. Referenced by findOption(), invokeCallbacksOPTION(), invokeCallbacksPOST(), invokeCallbacksPRE(), and poptGetNextOpt(). |
|
|
A popt alias or exec argument for poptAddItem(). Referenced by configLine(), execCommand(), handleAlias(), handleExec(), itemHelp(), itemUsage(), poptAddAlias(), poptAddItem(), and poptFreeContext(). |
|
|
|
Add alias to context.
Definition at line 1104 of file popt.c. References alloca(), poptAlias::argc, poptAlias::argv, poptAlias::longName, POPT_ARGFLAG_DOC_HIDDEN, poptAddItem(), poptContext, poptItem, and poptAlias::shortName. |
|
Add alias/exec item to context.
Definition at line 1123 of file popt.c. References poptContext_s::aliases, poptOption::arg, poptItem_s::argc, poptOption::argDescrip, poptOption::argInfo, poptItem_s::argv, poptOption::descrip, poptContext_s::execs, poptOption::longName, poptContext_s::numAliases, poptContext_s::numExecs, poptItem_s::option, poptContext, poptItem, poptOption::shortName, poptOption::val, and xstrdup(). Referenced by configLine(), and poptAddAlias(). |
|
Return the option which caused the most recent error.
Definition at line 1168 of file popt.c. References poptContext_s::optionStack, poptContext_s::os, POPT_BADOPTION_NOALIAS, and poptContext. Referenced by doSetupMacro(), main(), parseDescription(), parseFiles(), parseScript(), and rpmcliInit(). |
|
Parses an input configuration file and returns an string that is a command line. For use with popt. You must free the return value when done. Given the file:
The result is:
Passing this to poptParseArgvString() yields an argv of:
Definition at line 129 of file poptparse.c. References POPT_ERROR_MALLOC, POPT_ERROR_NULLARG, and POPT_ERROR_OVERFLOW. |
|
Duplicate an argument array.
Definition at line 14 of file poptparse.c. References POPT_ERROR_MALLOC, and POPT_ERROR_NOARG. Referenced by handleAlias(), poptParseArgvString(), and poptStuffArgs(). |
|
Destroy context.
Definition at line 1060 of file popt.c. References _free(), poptContext_s::aliases, poptContext_s::appName, poptContext_s::arg_strip, optionStackEntry::argb, poptOption::argDescrip, poptItem_s::argv, poptOption::descrip, poptContext_s::execPath, poptContext_s::execs, poptContext_s::finalArgv, poptContext_s::leftovers, poptOption::longName, poptContext_s::numAliases, poptContext_s::numExecs, poptItem_s::option, poptContext_s::os, poptContext_s::otherHelp, PBM_FREE, poptContext, poptItem, and poptResetContext(). Referenced by doSetupMacro(), main(), parseDescription(), parseFiles(), parseScript(), and rpmcliFini(). |
|
Return next argument.
Definition at line 1028 of file popt.c. References poptContext_s::leftovers, poptContext_s::nextLeftover, poptContext_s::numLeftovers, and poptContext. Referenced by main(), parseDescription(), parseFiles(), and parseScript(). |
|
Return remaining arguments.
Definition at line 1045 of file popt.c. References poptContext_s::leftovers, poptContext_s::nextLeftover, poptContext_s::numLeftovers, and poptContext. Referenced by main(). |
|
Initialize popt context.
Definition at line 170 of file popt.c. References getenv(), invokeCallbacksPRE(), POPT_CONTEXT_KEEP_FIRST, POPT_CONTEXT_POSIXMEHARDER, and poptContext. Referenced by doSetupMacro(), main(), parseDescription(), parseFiles(), parseScript(), and rpmcliInit(). |
|
Return argv[0] from context.
Definition at line 1231 of file popt.c. References optionStackEntry::argv, poptContext_s::os, and poptContext. |
|
|
Return next option argument (if any).
Definition at line 1016 of file popt.c. References optionStackEntry::nextArg, poptContext_s::os, and poptContext. Referenced by doSetupMacro(), main(), and rpmcliInit(). |
|
Parse a string into an argument array. The parse allows ', ", and \ quoting, but ' is treated the same as " and both may include \ quotes.
Definition at line 57 of file poptparse.c. References alloca(), POPT_ARGV_ARRAY_GROW_DELTA, POPT_ERROR_BADQUOTE, POPT_ERROR_MALLOC, and poptDupArgv(). Referenced by addOrAppendListEntry(), checkPassPhrase(), configLine(), doScript(), doSetupMacro(), handlePreambleTag(), ignoreDep(), makeGPGSignature(), makePGPSignature(), open_dso(), parseDescription(), parseFiles(), parseScript(), and rpmfcExec(). |
|
Peek at current argument.
Definition at line 1036 of file popt.c. References poptContext_s::leftovers, poptContext_s::nextLeftover, poptContext_s::numLeftovers, and poptContext. Referenced by main(), parseDescription(), parseFiles(), and parseScript(). |
|
Print detailed description of options.
Definition at line 561 of file popthelp.c. References maxArgWidth(), poptContext_s::options, poptContext_s::otherHelp, POPT_, poptContext, showHelpIntro(), and singleTableHelp(). Referenced by displayArgs(), and printUsage(). |
|
Print terse description of options.
Definition at line 780 of file popthelp.c. References poptContext_s::aliases, alloca(), poptContext_s::execs, itemUsage(), poptContext_s::numAliases, poptContext_s::numExecs, poptContext_s::options, poptContext_s::otherHelp, poptContext, poptDone, showHelpIntro(), showShortOptions(), and singleTableUsage(). Referenced by displayArgs(), and printUsage(). |
|
Read configuration file.
Definition at line 96 of file poptconfig.c. References alloca(), configLine(), errno, POPT_ERROR_ERRNO, poptContext, and SEEK_END. Referenced by main(), poptReadDefaultConfig(), and rpmcliInit(). |
|
Read default configuration from /etc/popt and $HOME/.popt.
Definition at line 163 of file poptconfig.c. References alloca(), poptContext_s::appName, getenv(), poptContext, and poptReadConfigFile(). Referenced by main(), and rpmcliInit(). |
|
Reinitialize popt context.
Definition at line 228 of file popt.c. References _free(), poptContext_s::arg_strip, optionStackEntry::argb, cleanOSE(), 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, and poptContext_s::restLeftover. Referenced by poptFreeContext(). |
|
Limit search for executables.
Definition at line 54 of file popt.c. References _free(), poptContext_s::execAbsolute, poptContext_s::execPath, poptContext, and xstrdup(). Referenced by main(), and rpmcliInit(). |
|
Provide text to replace default "[OPTION...]" in help/usage output.
Definition at line 810 of file popthelp.c. References _free(), poptContext_s::otherHelp, poptContext, and xstrdup(). |
|
Return formatted error string for popt failure.
Definition at line 1180 of file popt.c. References errno, error(), POPT_, POPT_ERROR_BADNUMBER, POPT_ERROR_BADOPERATION, POPT_ERROR_BADOPT, POPT_ERROR_BADQUOTE, POPT_ERROR_ERRNO, POPT_ERROR_MALLOC, POPT_ERROR_NOARG, POPT_ERROR_NULLARG, POPT_ERROR_OPTSTOODEEP, POPT_ERROR_OVERFLOW, and strerror(). Referenced by doSetupMacro(), main(), parseDescription(), parseFiles(), parseScript(), and rpmcliInit(). |
|
Shuffle argv pointers to remove stripped args, returns new argc.
Definition at line 1237 of file popt.c. References poptContext_s::arg_strip, PBM_ISSET, and poptContext. |
|
Add arguments to context.
Definition at line 1208 of file popt.c. 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, poptContext, poptDupArgv(), and optionStackEntry::stuffed. Referenced by queryArgCallback(). |
|
Empty table marker to enable displaying popt alias/exec options.
Definition at line 203 of file popt.h. Referenced by singleTableHelp(). |