4 #define POPT_OPTION_DEPTH 10
6 #define POPT_ARG_NONE 0
7 #define POPT_ARG_STRING 1
9 #define POPT_ARG_LONG 3
11 #define POPT_ERROR_NOARG -10
12 #define POPT_ERROR_BADOPT -11
13 #define POPT_ERROR_OPTSTOODEEP -13
14 #define POPT_ERROR_BADQUOTE -15 /* only from poptParseArgString() */
15 #define POPT_ERROR_ERRNO -16 /* only from poptParseArgString() */
16 #define POPT_ERROR_BADNUMBER -17
17 #define POPT_ERROR_OVERFLOW -18
19 /* context creation flags */
20 #define POPT_BADOPTION_NOALIAS (1 << 0) /* don't go into an alias */
21 #define POPT_KEEP_FIRST (1 << 1) /* pay attention to argv[0] */
24 const char * longName
; /* may be NULL */
25 char shortName
; /* may be '\0' */
27 void * arg
; /* depends on argInfo */
28 int val
; /* 0 means don't return, just update flag */
32 char * longName
; /* may be NULL */
33 char shortName
; /* may be '\0' */
35 char ** argv
; /* must be free()able */
38 typedef struct poptContext_s
* poptContext
;
40 poptContext
poptGetContext(char * name
, int argc
, char ** argv
,
41 struct poptOption
* options
, int flags
);
42 void poptResetContext(poptContext con
);
44 /* returns 'val' element, -1 on last item, POPT_ERROR_* on error */
45 int poptGetNextOpt(poptContext con
);
46 /* returns NULL if no argument is available */
47 char * poptGetOptArg(poptContext con
);
48 /* returns NULL if no more options are available */
49 char * poptGetArg(poptContext con
);
50 char * poptPeekArg(poptContext con
);
51 char ** poptGetArgs(poptContext con
);
52 /* returns the option which caused the most recent error */
53 char * poptBadOption(poptContext con
, int flags
);
54 void poptFreeContext(poptContext con
);
55 int poptStuffArgs(poptContext con
, char ** argv
);
56 int poptAddAlias(poptContext con
, struct poptAlias alias
, int flags
);
57 int poptReadConfigFile(poptContext con
, char * fn
);
58 /* like above, but reads /etc/popt and $HOME/.popt along with environment
60 int poptReadDefaultConfig(poptContext con
, int useEnv
);
61 /* argv should be freed -- this allows ', ", and \ quoting, but ' is treated
62 the same as " and both may include \ quotes */
63 int poptParseArgvString(char * s
, int * argcPtr
, char *** argvPtr
);
64 const char * poptStrerror(const int error
);