00001
00005
00006
00007
00008
00009 #ifndef H_POPT
00010 #define H_POPT
00011
00012 #ifdef __cplusplus
00013 extern "C" {
00014 #endif
00015
00016 #include <stdio.h>
00017
00018 #define POPT_OPTION_DEPTH 10
00019
00024 #define POPT_ARG_NONE 0
00025 #define POPT_ARG_STRING 1
00026 #define POPT_ARG_INT 2
00027 #define POPT_ARG_LONG 3
00028 #define POPT_ARG_INCLUDE_TABLE 4
00029 #define POPT_ARG_CALLBACK 5
00033 #define POPT_ARG_INTL_DOMAIN 6
00037 #define POPT_ARG_VAL 7
00038 #define POPT_ARG_FLOAT 8
00039 #define POPT_ARG_DOUBLE 9
00041 #define POPT_ARG_MASK 0x0000FFFF
00042
00048 #define POPT_ARGFLAG_ONEDASH 0x80000000
00049 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000
00050 #define POPT_ARGFLAG_STRIP 0x20000000
00051 #define POPT_ARGFLAG_OPTIONAL 0x10000000
00053 #define POPT_ARGFLAG_OR 0x08000000
00054 #define POPT_ARGFLAG_NOR 0x09000000
00055 #define POPT_ARGFLAG_AND 0x04000000
00056 #define POPT_ARGFLAG_NAND 0x05000000
00057 #define POPT_ARGFLAG_XOR 0x02000000
00058 #define POPT_ARGFLAG_NOT 0x01000000
00059 #define POPT_ARGFLAG_LOGICALOPS \
00060 (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
00061
00062 #define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR)
00063
00064 #define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
00065
00067 #define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000
00070
00071
00075 #define POPT_CBFLAG_PRE 0x80000000
00076 #define POPT_CBFLAG_POST 0x40000000
00077 #define POPT_CBFLAG_INC_DATA 0x20000000
00079 #define POPT_CBFLAG_SKIPOPTION 0x10000000
00080 #define POPT_CBFLAG_CONTINUE 0x08000000
00082
00083
00087 #define POPT_ERROR_NOARG -10
00088 #define POPT_ERROR_BADOPT -11
00089 #define POPT_ERROR_OPTSTOODEEP -13
00090 #define POPT_ERROR_BADQUOTE -15
00091 #define POPT_ERROR_ERRNO -16
00092 #define POPT_ERROR_BADNUMBER -17
00093 #define POPT_ERROR_OVERFLOW -18
00094 #define POPT_ERROR_BADOPERATION -19
00095 #define POPT_ERROR_NULLARG -20
00096 #define POPT_ERROR_MALLOC -21
00098
00099
00103 #define POPT_BADOPTION_NOALIAS (1 << 0)
00105
00106
00110 #define POPT_CONTEXT_NO_EXEC (1 << 0)
00111 #define POPT_CONTEXT_KEEP_FIRST (1 << 1)
00112 #define POPT_CONTEXT_POSIXMEHARDER (1 << 2)
00113 #define POPT_CONTEXT_ARG_OPTS (1 << 4)
00115
00116
00118 struct poptOption {
00119 const char * longName;
00120 char shortName;
00121 int argInfo;
00122 void * arg;
00123 int val;
00124 const char * descrip;
00125 const char * argDescrip;
00126 };
00127
00131 struct poptAlias {
00132 const char * longName;
00133 char shortName;
00134 int argc;
00135 const char ** argv;
00136 };
00137
00141 typedef struct poptItem_s {
00142 struct poptOption option;
00143 int argc;
00144 const char ** argv;
00145 } * poptItem;
00146
00151
00155 extern struct poptOption poptAliasOptions[];
00156 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
00157 0, "Options implemented via popt alias/exec:", NULL },
00158
00162 extern struct poptOption poptHelpOptions[];
00163 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
00164 0, "Help options:", NULL },
00165
00166 #define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL }
00167
00171 typedef struct poptContext_s * poptContext;
00172
00175 #ifndef __cplusplus
00176
00177 typedef struct poptOption * poptOption;
00178
00179 #endif
00180
00181 enum poptCallbackReason { POPT_CALLBACK_REASON_PRE,
00182 POPT_CALLBACK_REASON_POST,
00183 POPT_CALLBACK_REASON_OPTION };
00184
00193 typedef void (*poptCallbackType) (poptContext con,
00194 enum poptCallbackReason reason,
00195 const struct poptOption * opt,
00196 const char * arg,
00197 const void * data)
00198 ;
00199
00209 poptContext poptGetContext(
00210 const char * name,
00211 int argc, const char ** argv,
00212 const struct poptOption * options,
00213 int flags)
00214 ;
00215
00220 void poptResetContext(poptContext con)
00221 ;
00222
00228 int poptGetNextOpt(poptContext con)
00229 ;
00230
00231
00237 const char * poptGetOptArg(poptContext con)
00238 ;
00239
00245 const char * poptGetArg(poptContext con)
00246 ;
00247
00253 const char * poptPeekArg(poptContext con)
00254 ;
00255
00261 const char ** poptGetArgs(poptContext con)
00262 ;
00263
00269 const char * poptBadOption(poptContext con, int flags)
00270 ;
00271
00272
00278 poptContext poptFreeContext( poptContext con)
00279 ;
00280
00287 int poptStuffArgs(poptContext con, const char ** argv)
00288 ;
00289
00299
00300 int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
00301 ;
00302
00310 int poptAddItem(poptContext con, poptItem newItem, int flags)
00311 ;
00312
00319 int poptReadConfigFile(poptContext con, const char * fn)
00320
00321 ;
00322
00329 int poptReadDefaultConfig(poptContext con, int useEnv)
00330
00331 ;
00332
00344 int poptDupArgv(int argc, const char **argv,
00345 int * argcPtr,
00346 const char *** argvPtr)
00347 ;
00348
00360 int poptParseArgvString(const char * s,
00361 int * argcPtr, const char *** argvPtr)
00362 ;
00363
00369
00370 const char *const poptStrerror(const int error)
00371 ;
00372
00373
00380 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
00381 ;
00382
00389 void poptPrintHelp(poptContext con, FILE * fp, int flags)
00390 ;
00391
00398 void poptPrintUsage(poptContext con, FILE * fp, int flags)
00399 ;
00400
00406
00407 void poptSetOtherOptionHelp(poptContext con, const char * text)
00408 ;
00409
00410
00416
00417 const char * poptGetInvocationName(poptContext con)
00418 ;
00419
00420
00428
00429 int poptStrippedArgv(poptContext con, int argc, char ** argv)
00430 ;
00431
00432
00433 #ifdef __cplusplus
00434 }
00435 #endif
00436
00437 #endif