popt 1.13
|
00001 00005 /* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING 00006 file accompanying popt source distributions, available from 00007 ftp://ftp.rpm.org/pub/rpm/dist. */ 00008 00009 #ifndef H_POPT 00010 #define H_POPT 00011 00012 #include <stdio.h> /* for FILE * */ 00013 00014 #define POPT_OPTION_DEPTH 10 00015 00020 #define POPT_ARG_NONE 0U 00021 #define POPT_ARG_STRING 1U 00022 #define POPT_ARG_INT 2U 00023 #define POPT_ARG_LONG 3U 00024 #define POPT_ARG_INCLUDE_TABLE 4U 00025 #define POPT_ARG_CALLBACK 5U 00029 #define POPT_ARG_INTL_DOMAIN 6U 00033 #define POPT_ARG_VAL 7U 00034 #define POPT_ARG_FLOAT 8U 00035 #define POPT_ARG_DOUBLE 9U 00037 #define POPT_ARG_MAINCALL 10U 00039 #define POPT_ARG_MASK 0x0000FFFFU 00040 00046 #define POPT_ARGFLAG_ONEDASH 0x80000000U 00047 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000U 00048 #define POPT_ARGFLAG_STRIP 0x20000000U 00049 #define POPT_ARGFLAG_OPTIONAL 0x10000000U 00051 #define POPT_ARGFLAG_OR 0x08000000U 00052 #define POPT_ARGFLAG_NOR 0x09000000U 00053 #define POPT_ARGFLAG_AND 0x04000000U 00054 #define POPT_ARGFLAG_NAND 0x05000000U 00055 #define POPT_ARGFLAG_XOR 0x02000000U 00056 #define POPT_ARGFLAG_NOT 0x01000000U 00057 #define POPT_ARGFLAG_LOGICALOPS \ 00058 (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR) 00059 00060 #define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR) 00061 00062 #define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND) 00063 00065 #define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000U 00066 #define POPT_ARGFLAG_RANDOM 0x00400000U /*<! random value in [1,arg] */ 00067 00074 #define POPT_CBFLAG_PRE 0x80000000U 00075 #define POPT_CBFLAG_POST 0x40000000U 00076 #define POPT_CBFLAG_INC_DATA 0x20000000U 00078 #define POPT_CBFLAG_SKIPOPTION 0x10000000U 00079 #define POPT_CBFLAG_CONTINUE 0x08000000U 00081 00082 00086 #define POPT_ERROR_NOARG -10 00087 #define POPT_ERROR_BADOPT -11 00088 #define POPT_ERROR_OPTSTOODEEP -13 00089 #define POPT_ERROR_BADQUOTE -15 00090 #define POPT_ERROR_ERRNO -16 00091 #define POPT_ERROR_BADNUMBER -17 00092 #define POPT_ERROR_OVERFLOW -18 00093 #define POPT_ERROR_BADOPERATION -19 00094 #define POPT_ERROR_NULLARG -20 00095 #define POPT_ERROR_MALLOC -21 00097 00098 00102 #define POPT_BADOPTION_NOALIAS (1U << 0) 00104 00105 00109 #define POPT_CONTEXT_NO_EXEC (1U << 0) 00110 #define POPT_CONTEXT_KEEP_FIRST (1U << 1) 00111 #define POPT_CONTEXT_POSIXMEHARDER (1U << 2) 00112 #define POPT_CONTEXT_ARG_OPTS (1U << 4) 00114 00115 00117 struct poptOption { 00118 /*@observer@*/ /*@null@*/ 00119 const char * longName; 00120 char shortName; 00121 unsigned int argInfo; 00122 /*@shared@*/ /*@null@*/ 00123 void * arg; 00124 int val; 00125 /*@observer@*/ /*@null@*/ 00126 const char * descrip; 00127 /*@observer@*/ /*@null@*/ 00128 const char * argDescrip; 00129 }; 00130 00134 struct poptAlias { 00135 /*@owned@*/ /*@null@*/ 00136 const char * longName; 00137 char shortName; 00138 int argc; 00139 /*@owned@*/ 00140 const char ** argv; 00141 }; 00142 00146 /*@-exporttype@*/ 00147 typedef struct poptItem_s { 00148 struct poptOption option; 00149 int argc; 00150 /*@owned@*/ 00151 const char ** argv; 00152 } * poptItem; 00153 /*@=exporttype@*/ 00154 00159 00163 /*@-exportvar@*/ 00164 /*@unchecked@*/ /*@observer@*/ 00165 extern struct poptOption poptAliasOptions[]; 00166 /*@=exportvar@*/ 00167 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \ 00168 0, "Options implemented via popt alias/exec:", NULL }, 00169 00173 /*@-exportvar@*/ 00174 /*@unchecked@*/ /*@observer@*/ 00175 extern struct poptOption poptHelpOptions[]; 00176 /*@=exportvar@*/ 00177 00178 /*@-exportvar@*/ 00179 /*@unchecked@*/ /*@observer@*/ 00180 extern struct poptOption * poptHelpOptionsI18N; 00181 /*@=exportvar@*/ 00182 00183 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \ 00184 0, "Help options:", NULL }, 00185 00186 #define POPT_TABLEEND { NULL, '\0', 0, NULL, 0, NULL, NULL } 00187 00191 /*@-exporttype@*/ 00192 typedef /*@abstract@*/ struct poptContext_s * poptContext; 00193 /*@=exporttype@*/ 00194 00197 #ifndef __cplusplus 00198 /*@-exporttype -typeuse@*/ 00199 typedef struct poptOption * poptOption; 00200 /*@=exporttype =typeuse@*/ 00201 #endif 00202 00205 /*@-exportconst@*/ 00206 enum poptCallbackReason { 00207 POPT_CALLBACK_REASON_PRE = 0, 00208 POPT_CALLBACK_REASON_POST = 1, 00209 POPT_CALLBACK_REASON_OPTION = 2 00210 }; 00211 /*@=exportconst@*/ 00212 00213 #ifdef __cplusplus 00214 extern "C" { 00215 #endif 00216 /*@-type@*/ 00217 00226 typedef void (*poptCallbackType) (poptContext con, 00227 enum poptCallbackReason reason, 00228 /*@null@*/ const struct poptOption * opt, 00229 /*@null@*/ const char * arg, 00230 /*@null@*/ const void * data) 00231 /*@globals internalState @*/ 00232 /*@modifies internalState @*/; 00233 00243 /*@only@*/ /*@null@*/ 00244 poptContext poptGetContext( 00245 /*@dependent@*/ /*@keep@*/ const char * name, 00246 int argc, /*@dependent@*/ /*@keep@*/ const char ** argv, 00247 /*@dependent@*/ /*@keep@*/ const struct poptOption * options, 00248 unsigned int flags) 00249 /*@*/; 00250 00255 /*@unused@*/ 00256 void poptResetContext(/*@null@*/poptContext con) 00257 /*@modifies con @*/; 00258 00264 int poptGetNextOpt(/*@null@*/poptContext con) 00265 /*@globals fileSystem, internalState @*/ 00266 /*@modifies con, fileSystem, internalState @*/; 00267 00273 /*@observer@*/ /*@null@*/ /*@unused@*/ 00274 char * poptGetOptArg(/*@null@*/poptContext con) 00275 /*@modifies con @*/; 00276 00282 /*@observer@*/ /*@null@*/ /*@unused@*/ 00283 const char * poptGetArg(/*@null@*/poptContext con) 00284 /*@modifies con @*/; 00285 00291 /*@observer@*/ /*@null@*/ /*@unused@*/ 00292 const char * poptPeekArg(/*@null@*/poptContext con) 00293 /*@*/; 00294 00300 /*@observer@*/ /*@null@*/ 00301 const char ** poptGetArgs(/*@null@*/poptContext con) 00302 /*@modifies con @*/; 00303 00310 /*@observer@*/ 00311 const char * poptBadOption(/*@null@*/poptContext con, unsigned int flags) 00312 /*@*/; 00313 00319 /*@null@*/ 00320 poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con) 00321 /*@modifies con @*/; 00322 00329 /*@unused@*/ 00330 int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv) 00331 /*@modifies con @*/; 00332 00342 /*@unused@*/ 00343 int poptAddAlias(poptContext con, struct poptAlias alias, int flags) 00344 /*@modifies con @*/; 00345 00353 int poptAddItem(poptContext con, poptItem newItem, int flags) 00354 /*@modifies con @*/; 00355 00362 int poptReadConfigFile(poptContext con, const char * fn) 00363 /*@globals errno, fileSystem, internalState @*/ 00364 /*@modifies con->execs, con->numExecs, 00365 errno, fileSystem, internalState @*/; 00366 00373 /*@unused@*/ 00374 int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv) 00375 /*@globals fileSystem, internalState @*/ 00376 /*@modifies con->execs, con->numExecs, 00377 fileSystem, internalState @*/; 00378 00390 int poptDupArgv(int argc, /*@null@*/ const char **argv, 00391 /*@null@*/ /*@out@*/ int * argcPtr, 00392 /*@null@*/ /*@out@*/ const char *** argvPtr) 00393 /*@modifies *argcPtr, *argvPtr @*/; 00394 00406 int poptParseArgvString(const char * s, 00407 /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr) 00408 /*@modifies *argcPtr, *argvPtr @*/; 00409 00456 /*@-fcnuse@*/ 00457 int poptConfigFileToString(FILE *fp, /*@out@*/ char ** argstrp, int flags) 00458 /*@globals fileSystem @*/ 00459 /*@modifies *fp, *argstrp, fileSystem @*/; 00460 /*@=fcnuse@*/ 00461 00467 /*@observer@*/ 00468 const char * poptStrerror(const int error) 00469 /*@*/; 00470 00477 /*@unused@*/ 00478 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute) 00479 /*@modifies con @*/; 00480 00487 void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags) 00488 /*@globals fileSystem @*/ 00489 /*@modifies fp, fileSystem @*/; 00490 00497 void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags) 00498 /*@globals fileSystem @*/ 00499 /*@modifies fp, fileSystem @*/; 00500 00506 /*@-fcnuse@*/ 00507 void poptSetOtherOptionHelp(poptContext con, const char * text) 00508 /*@modifies con @*/; 00509 /*@=fcnuse@*/ 00510 00516 /*@-fcnuse@*/ 00517 /*@observer@*/ 00518 const char * poptGetInvocationName(poptContext con) 00519 /*@*/; 00520 /*@=fcnuse@*/ 00521 00529 /*@-fcnuse@*/ 00530 int poptStrippedArgv(poptContext con, int argc, char ** argv) 00531 /*@modifies *argv @*/; 00532 /*@=fcnuse@*/ 00533 00542 /*@-incondefs@*/ 00543 /*@unused@*/ 00544 int poptSaveLong(/*@null@*/ long * arg, unsigned int argInfo, long aLong) 00545 /*@globals internalState @*/ 00546 /*@modifies *arg, internalState @*/ 00547 /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/; 00548 /*@=incondefs@*/ 00549 00558 /*@-incondefs@*/ 00559 /*@unused@*/ 00560 int poptSaveInt(/*@null@*/ int * arg, unsigned int argInfo, long aLong) 00561 /*@globals internalState @*/ 00562 /*@modifies *arg, internalState @*/ 00563 /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/; 00564 /*@=incondefs@*/ 00565 00566 /*@=type@*/ 00567 #ifdef __cplusplus 00568 } 00569 #endif 00570 00571 #endif