popt  1.13
popt.h
Go to the documentation of this file.
1 
5 /* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
6  file accompanying popt source distributions, available from
7  ftp://ftp.rpm.org/pub/rpm/dist. */
8 
9 #ifndef H_POPT
10 #define H_POPT
11 
12 #include <stdio.h> /* for FILE * */
13 
14 #define POPT_OPTION_DEPTH 10
15 
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
37 #define POPT_ARG_MAINCALL 10U
39 #define POPT_ARG_MASK 0x0000FFFFU
40 
46 #define POPT_ARGFLAG_ONEDASH 0x80000000U
47 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000U
48 #define POPT_ARGFLAG_STRIP 0x20000000U
49 #define POPT_ARGFLAG_OPTIONAL 0x10000000U
51 #define POPT_ARGFLAG_OR 0x08000000U
52 #define POPT_ARGFLAG_NOR 0x09000000U
53 #define POPT_ARGFLAG_AND 0x04000000U
54 #define POPT_ARGFLAG_NAND 0x05000000U
55 #define POPT_ARGFLAG_XOR 0x02000000U
56 #define POPT_ARGFLAG_NOT 0x01000000U
57 #define POPT_ARGFLAG_LOGICALOPS \
58  (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
59 
60 #define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR)
61 
62 #define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
63 
65 #define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000U
66 #define POPT_ARGFLAG_RANDOM 0x00400000U /*<! random value in [1,arg] */
67 
74 #define POPT_CBFLAG_PRE 0x80000000U
75 #define POPT_CBFLAG_POST 0x40000000U
76 #define POPT_CBFLAG_INC_DATA 0x20000000U
78 #define POPT_CBFLAG_SKIPOPTION 0x10000000U
79 #define POPT_CBFLAG_CONTINUE 0x08000000U
81 
82 
86 #define POPT_ERROR_NOARG -10
87 #define POPT_ERROR_BADOPT -11
88 #define POPT_ERROR_OPTSTOODEEP -13
89 #define POPT_ERROR_BADQUOTE -15
90 #define POPT_ERROR_ERRNO -16
91 #define POPT_ERROR_BADNUMBER -17
92 #define POPT_ERROR_OVERFLOW -18
93 #define POPT_ERROR_BADOPERATION -19
94 #define POPT_ERROR_NULLARG -20
95 #define POPT_ERROR_MALLOC -21
97 
98 
102 #define POPT_BADOPTION_NOALIAS (1U << 0)
104 
105 
109 #define POPT_CONTEXT_NO_EXEC (1U << 0)
110 #define POPT_CONTEXT_KEEP_FIRST (1U << 1)
111 #define POPT_CONTEXT_POSIXMEHARDER (1U << 2)
112 #define POPT_CONTEXT_ARG_OPTS (1U << 4)
114 
115 
117 struct poptOption {
118 /*@observer@*/ /*@null@*/
119  const char * longName;
120  char shortName;
121  unsigned int argInfo;
122 /*@shared@*/ /*@null@*/
123  void * arg;
124  int val;
125 /*@observer@*/ /*@null@*/
126  const char * descrip;
127 /*@observer@*/ /*@null@*/
128  const char * argDescrip;
129 };
130 
134 struct poptAlias {
135 /*@owned@*/ /*@null@*/
136  const char * longName;
137  char shortName;
138  int argc;
139 /*@owned@*/
140  const char ** argv;
141 };
142 
146 /*@-exporttype@*/
147 typedef struct poptItem_s {
149  int argc;
150 /*@owned@*/
151  const char ** argv;
152 } * poptItem;
153 /*@=exporttype@*/
154 
159 
163 /*@-exportvar@*/
164 /*@unchecked@*/ /*@observer@*/
165 extern struct poptOption poptAliasOptions[];
166 /*@=exportvar@*/
167 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
168  0, "Options implemented via popt alias/exec:", NULL },
169 
173 /*@-exportvar@*/
174 /*@unchecked@*/ /*@observer@*/
175 extern struct poptOption poptHelpOptions[];
176 /*@=exportvar@*/
177 
178 /*@-exportvar@*/
179 /*@unchecked@*/ /*@observer@*/
180 extern struct poptOption * poptHelpOptionsI18N;
181 /*@=exportvar@*/
182 
183 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
184  0, "Help options:", NULL },
185 
186 #define POPT_TABLEEND { NULL, '\0', 0, NULL, 0, NULL, NULL }
187 
191 /*@-exporttype@*/
192 typedef /*@abstract@*/ struct poptContext_s * poptContext;
193 /*@=exporttype@*/
194 
197 #ifndef __cplusplus
198 /*@-exporttype -typeuse@*/
199 typedef struct poptOption * poptOption;
200 /*@=exporttype =typeuse@*/
201 #endif
202 
205 /*@-exportconst@*/
210 };
211 /*@=exportconst@*/
212 
213 #ifdef __cplusplus
214 extern "C" {
215 #endif
216 /*@-type@*/
217 
226 typedef void (*poptCallbackType) (poptContext con,
227  enum poptCallbackReason reason,
228  /*@null@*/ const struct poptOption * opt,
229  /*@null@*/ const char * arg,
230  /*@null@*/ const void * data)
231  /*@globals internalState @*/
232  /*@modifies internalState @*/;
233 
243 /*@only@*/ /*@null@*/
244 poptContext poptGetContext(
245  /*@dependent@*/ /*@keep@*/ const char * name,
246  int argc, /*@dependent@*/ /*@keep@*/ const char ** argv,
247  /*@dependent@*/ /*@keep@*/ const struct poptOption * options,
248  unsigned int flags)
249  /*@*/;
250 
255 /*@unused@*/
256 void poptResetContext(/*@null@*/poptContext con)
257  /*@modifies con @*/;
258 
264 int poptGetNextOpt(/*@null@*/poptContext con)
265  /*@globals fileSystem, internalState @*/
266  /*@modifies con, fileSystem, internalState @*/;
267 
273 /*@observer@*/ /*@null@*/ /*@unused@*/
274 char * poptGetOptArg(/*@null@*/poptContext con)
275  /*@modifies con @*/;
276 
282 /*@observer@*/ /*@null@*/ /*@unused@*/
283 const char * poptGetArg(/*@null@*/poptContext con)
284  /*@modifies con @*/;
285 
291 /*@observer@*/ /*@null@*/ /*@unused@*/
292 const char * poptPeekArg(/*@null@*/poptContext con)
293  /*@*/;
294 
300 /*@observer@*/ /*@null@*/
301 const char ** poptGetArgs(/*@null@*/poptContext con)
302  /*@modifies con @*/;
303 
310 /*@observer@*/
311 const char * poptBadOption(/*@null@*/poptContext con, unsigned int flags)
312  /*@*/;
313 
319 /*@null@*/
320 poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con)
321  /*@modifies con @*/;
322 
329 /*@unused@*/
330 int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv)
331  /*@modifies con @*/;
332 
342 /*@unused@*/
343 int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
344  /*@modifies con @*/;
345 
353 int poptAddItem(poptContext con, poptItem newItem, int flags)
354  /*@modifies con @*/;
355 
362 int poptReadConfigFile(poptContext con, const char * fn)
363  /*@globals errno, fileSystem, internalState @*/
364  /*@modifies con->execs, con->numExecs,
365  errno, fileSystem, internalState @*/;
366 
373 /*@unused@*/
374 int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
375  /*@globals fileSystem, internalState @*/
376  /*@modifies con->execs, con->numExecs,
377  fileSystem, internalState @*/;
378 
390 int poptDupArgv(int argc, /*@null@*/ const char **argv,
391  /*@null@*/ /*@out@*/ int * argcPtr,
392  /*@null@*/ /*@out@*/ const char *** argvPtr)
393  /*@modifies *argcPtr, *argvPtr @*/;
394 
406 int poptParseArgvString(const char * s,
407  /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr)
408  /*@modifies *argcPtr, *argvPtr @*/;
409 
456 /*@-fcnuse@*/
457 int poptConfigFileToString(FILE *fp, /*@out@*/ char ** argstrp, int flags)
458  /*@globals fileSystem @*/
459  /*@modifies *fp, *argstrp, fileSystem @*/;
460 /*@=fcnuse@*/
461 
467 /*@observer@*/
468 const char * poptStrerror(const int error)
469  /*@*/;
470 
477 /*@unused@*/
478 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
479  /*@modifies con @*/;
480 
487 void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags)
488  /*@globals fileSystem @*/
489  /*@modifies fp, fileSystem @*/;
490 
497 void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
498  /*@globals fileSystem @*/
499  /*@modifies fp, fileSystem @*/;
500 
506 /*@-fcnuse@*/
507 void poptSetOtherOptionHelp(poptContext con, const char * text)
508  /*@modifies con @*/;
509 /*@=fcnuse@*/
510 
516 /*@-fcnuse@*/
517 /*@observer@*/
518 const char * poptGetInvocationName(poptContext con)
519  /*@*/;
520 /*@=fcnuse@*/
521 
529 /*@-fcnuse@*/
530 int poptStrippedArgv(poptContext con, int argc, char ** argv)
531  /*@modifies *argv @*/;
532 /*@=fcnuse@*/
533 
542 /*@-incondefs@*/
543 /*@unused@*/
544 int poptSaveLong(/*@null@*/ long * arg, unsigned int argInfo, long aLong)
545  /*@globals internalState @*/
546  /*@modifies *arg, internalState @*/
547  /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/;
548 /*@=incondefs@*/
549 
558 /*@-incondefs@*/
559 /*@unused@*/
560 int poptSaveInt(/*@null@*/ int * arg, unsigned int argInfo, long aLong)
561  /*@globals internalState @*/
562  /*@modifies *arg, internalState @*/
563  /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/;
564 /*@=incondefs@*/
565 
566 /*@=type@*/
567 #ifdef __cplusplus
568 }
569 #endif
570 
571 #endif

Generated for popt by  doxygen 1.8.1.2