14#define POPT_OPTION_DEPTH 10
20#define POPT_ARG_NONE 0U
21#define POPT_ARG_STRING 1U
22#define POPT_ARG_INT 2U
23#define POPT_ARG_LONG 3U
24#define POPT_ARG_INCLUDE_TABLE 4U
25#define POPT_ARG_CALLBACK 5U
29#define POPT_ARG_INTL_DOMAIN 6U
33#define POPT_ARG_VAL 7U
34#define POPT_ARG_FLOAT 8U
35#define POPT_ARG_DOUBLE 9U
36#define POPT_ARG_LONGLONG 10U
38#define POPT_ARG_MAINCALL (16U+11U)
39#define POPT_ARG_ARGV 12U
40#define POPT_ARG_SHORT 13U
41#define POPT_ARG_BITSET (16U+14U)
43#define POPT_ARG_MASK 0x000000FFU
44#define POPT_GROUP_MASK 0x0000FF00U
52#define POPT_ARGFLAG_ONEDASH 0x80000000U
53#define POPT_ARGFLAG_DOC_HIDDEN 0x40000000U
54#define POPT_ARGFLAG_STRIP 0x20000000U
55#define POPT_ARGFLAG_OPTIONAL 0x10000000U
57#define POPT_ARGFLAG_OR 0x08000000U
58#define POPT_ARGFLAG_NOR 0x09000000U
59#define POPT_ARGFLAG_AND 0x04000000U
60#define POPT_ARGFLAG_NAND 0x05000000U
61#define POPT_ARGFLAG_XOR 0x02000000U
62#define POPT_ARGFLAG_NOT 0x01000000U
63#define POPT_ARGFLAG_LOGICALOPS \
64 (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
66#define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR)
68#define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
71#define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000U
72#define POPT_ARGFLAG_RANDOM 0x00400000U
73#define POPT_ARGFLAG_TOGGLE 0x00200000U
81#define POPT_CBFLAG_PRE 0x80000000U
82#define POPT_CBFLAG_POST 0x40000000U
83#define POPT_CBFLAG_INC_DATA 0x20000000U
85#define POPT_CBFLAG_SKIPOPTION 0x10000000U
86#define POPT_CBFLAG_CONTINUE 0x08000000U
93#define POPT_ERROR_NOARG -10
94#define POPT_ERROR_BADOPT -11
95#define POPT_ERROR_OPTSTOODEEP -13
96#define POPT_ERROR_BADQUOTE -15
97#define POPT_ERROR_ERRNO -16
98#define POPT_ERROR_BADNUMBER -17
99#define POPT_ERROR_OVERFLOW -18
100#define POPT_ERROR_BADOPERATION -19
101#define POPT_ERROR_NULLARG -20
102#define POPT_ERROR_MALLOC -21
103#define POPT_ERROR_NOCONTEXT -22
104#define POPT_ERROR_BADCONFIG -23
112#define POPT_BADOPTION_NOALIAS (1U << 0)
119#define POPT_CONTEXT_NO_EXEC (1U << 0)
120#define POPT_CONTEXT_KEEP_FIRST (1U << 1)
121#define POPT_CONTEXT_POSIXMEHARDER (1U << 2)
122#define POPT_CONTEXT_ARG_OPTS (1U << 4)
165#define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
166 0, "Options implemented via popt alias/exec:", NULL },
175#define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
176 0, "Help options:", NULL },
178#define POPT_TABLEEND { NULL, '\0', 0, NULL, 0, NULL, NULL }
235 int argc,
const char ** argv,
257 const char * configPaths);
354 size_t * nbp,
int flags);
355#define POPT_READFILE_TRIMNEWLINES 1
397 const char *** argvPtr);
411 int * argcPtr,
const char *** argvPtr);
535 long long aLongLong);
572#define _POPT_BITS_N 1024U
573#define _POPT_BITS_M ((3U * _POPT_BITS_N) / 2U)
574#define _POPT_BITS_K 16U
int poptConfigFileToString(FILE *fp, char **argstrp, int flags)
Parses an input configuration file and returns an string that is a command line.
int poptReadFile(const char *fn, char **bp, size_t *nbp, int flags)
Read a file into a buffer.
struct poptOption poptHelpOptions[]
Auto help table options.
char * poptGetOptArg(poptContext con)
Return next option argument (if any).
void poptSetExecPath(poptContext con, const char *path, int allowAbsolute)
Limit search for executables.
const char ** poptGetArgs(poptContext con)
Return remaining arguments.
void(* poptCallbackType)(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data)
Table callback prototype.
const char * poptBadOption(poptContext con, unsigned int flags)
Return the option which caused the most recent error.
struct poptOption * poptOption
int poptSaveInt(int *arg, unsigned int argInfo, long aLong)
Save an integer, performing logical operation with value.
int poptReadConfigFiles(poptContext con, const char *paths)
Read configuration file(s).
int poptStuffArgs(poptContext con, const char **argv)
Add arguments to context.
const char * poptStrerror(const int error)
Return formatted error string for popt failure.
int poptBitsUnion(poptBits *ap, const poptBits b)
int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
Add alias to context.
int poptStrippedArgv(poptContext con, int argc, char **argv)
Shuffle argv pointers to remove stripped args, returns new argc.
const char * poptPeekArg(poptContext con)
Peek at current argument.
int poptAddItem(poptContext con, poptItem newItem, int flags)
Add alias/exec item to context.
void poptPrintHelp(poptContext con, FILE *fp, int flags)
Print detailed description of options.
int poptDupArgv(int argc, const char **argv, int *argcPtr, const char ***argvPtr)
Duplicate an argument array.
void poptResetContext(poptContext con)
Reinitialize popt context.
int poptBitsClr(poptBits bits)
int poptBitsChk(poptBits bits, const char *s)
const char * poptGetArg(poptContext con)
Return next argument.
int poptGetNextOpt(poptContext con)
Return value of next option found.
int poptBitsIntersect(poptBits *ap, const poptBits b)
int poptBitsArgs(poptContext con, poptBits *ap)
int poptReadConfigFile(poptContext con, const char *fn)
Read configuration file.
struct poptOption * poptHelpOptionsI18N
struct poptOption poptAliasOptions[]
Empty table marker to enable displaying popt alias/exec options.
int poptSaveLongLong(long long *arg, unsigned int argInfo, long long aLongLong)
Save a long long, performing logical operation with value.
const char * poptGetInvocationName(poptContext con)
Return argv[0] from context.
int poptParseArgvString(const char *s, int *argcPtr, const char ***argvPtr)
Parse a string into an argument array.
int poptSaveString(const char ***argvp, unsigned int argInfo, const char *val)
Add a string to an argv array.
struct poptBits_s * poptBits
poptContext poptGetContext(const char *name, int argc, const char **argv, const struct poptOption *options, unsigned int flags)
Initialize popt context.
void poptSetOtherOptionHelp(poptContext con, const char *text)
Provide text to replace default "[OPTION...]" in help/usage output.
poptContext poptFini(poptContext con)
Destroy context (alternative implementation).
int poptBitsAdd(poptBits bits, const char *s)
struct poptItem_s * poptItem
A popt alias or exec argument for poptAddItem().
poptContext poptFreeContext(poptContext con)
Destroy context.
struct poptContext_s * poptContext
int poptSaveLong(long *arg, unsigned int argInfo, long aLong)
Save a long, performing logical operation with value.
int poptSaveBits(poptBits *bitsp, unsigned int argInfo, const char *s)
Save a string into a bit set (experimental).
int poptBitsDel(poptBits bits, const char *s)
int poptSaveShort(short *arg, unsigned int argInfo, long aLong)
Save a short integer, performing logical operation with value.
poptContext poptInit(int argc, const char **argv, const struct poptOption *options, const char *configPaths)
Initialize popt context (alternative implementation).
void poptPrintUsage(poptContext con, FILE *fp, int flags)
Print terse description of options.
int poptSaneFile(const char *fn)
Test path/file for config file sanity (regular file, permissions etc)
@ POPT_CALLBACK_REASON_PRE
@ POPT_CALLBACK_REASON_OPTION
@ POPT_CALLBACK_REASON_POST
int poptReadDefaultConfig(poptContext con, int useEnv)
Read default configuration from /etc/popt and $HOME/.popt.
A popt alias argument for poptAddAlias().
A popt alias or exec argument for poptAddItem().