00001
00005
00006
00007
00008
00009 #ifndef H_POPT
00010 #define H_POPT
00011
00012 #include <stdio.h>
00013
00014 #define POPT_OPTION_DEPTH 10
00015
00020 #define POPT_ARG_NONE 0
00021 #define POPT_ARG_STRING 1
00022 #define POPT_ARG_INT 2
00023 #define POPT_ARG_LONG 3
00024 #define POPT_ARG_INCLUDE_TABLE 4
00025 #define POPT_ARG_CALLBACK 5
00029 #define POPT_ARG_INTL_DOMAIN 6
00033 #define POPT_ARG_VAL 7
00034 #define POPT_ARG_FLOAT 8
00035 #define POPT_ARG_DOUBLE 9
00037 #define POPT_ARG_MASK 0x0000FFFF
00038
00044 #define POPT_ARGFLAG_ONEDASH 0x80000000
00045 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000
00046 #define POPT_ARGFLAG_STRIP 0x20000000
00047 #define POPT_ARGFLAG_OPTIONAL 0x10000000
00049 #define POPT_ARGFLAG_OR 0x08000000
00050 #define POPT_ARGFLAG_NOR 0x09000000
00051 #define POPT_ARGFLAG_AND 0x04000000
00052 #define POPT_ARGFLAG_NAND 0x05000000
00053 #define POPT_ARGFLAG_XOR 0x02000000
00054 #define POPT_ARGFLAG_NOT 0x01000000
00055 #define POPT_ARGFLAG_LOGICALOPS \
00056 (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
00057
00058 #define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR)
00059
00060 #define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
00061
00063 #define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000
00066
00067
00071 #define POPT_CBFLAG_PRE 0x80000000
00072 #define POPT_CBFLAG_POST 0x40000000
00073 #define POPT_CBFLAG_INC_DATA 0x20000000
00075 #define POPT_CBFLAG_SKIPOPTION 0x10000000
00076 #define POPT_CBFLAG_CONTINUE 0x08000000
00078
00079
00083 #define POPT_ERROR_NOARG -10
00084 #define POPT_ERROR_BADOPT -11
00085 #define POPT_ERROR_OPTSTOODEEP -13
00086 #define POPT_ERROR_BADQUOTE -15
00087 #define POPT_ERROR_ERRNO -16
00088 #define POPT_ERROR_BADNUMBER -17
00089 #define POPT_ERROR_OVERFLOW -18
00090 #define POPT_ERROR_BADOPERATION -19
00091 #define POPT_ERROR_NULLARG -20
00092 #define POPT_ERROR_MALLOC -21
00094
00095
00099 #define POPT_BADOPTION_NOALIAS (1 << 0)
00101
00102
00106 #define POPT_CONTEXT_NO_EXEC (1 << 0)
00107 #define POPT_CONTEXT_KEEP_FIRST (1 << 1)
00108 #define POPT_CONTEXT_POSIXMEHARDER (1 << 2)
00109 #define POPT_CONTEXT_ARG_OPTS (1 << 4)
00111
00112
00114 struct poptOption {
00115 const char * longName;
00116 char shortName;
00117 int argInfo;
00118 void * arg;
00119 int val;
00120 const char * descrip;
00121 const char * argDescrip;
00122 };
00123
00127 struct poptAlias {
00128 const char * longName;
00129 char shortName;
00130 int argc;
00131 const char ** argv;
00132 };
00133
00137 typedef struct poptItem_s {
00138 struct poptOption option;
00139 int argc;
00140 const char ** argv;
00141 } * poptItem;
00142
00147
00151
00152 extern struct poptOption poptAliasOptions[];
00153 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
00154 0, "Options implemented via popt alias/exec:", NULL },
00155
00159
00160 extern struct poptOption poptHelpOptions[];
00161 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
00162 0, "Help options:", NULL },
00163
00164 #define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL }
00165
00169 typedef struct poptContext_s * poptContext;
00170
00173 #ifndef __cplusplus
00174
00175 typedef struct poptOption * poptOption;
00176
00177 #endif
00178
00179 enum poptCallbackReason { POPT_CALLBACK_REASON_PRE,
00180 POPT_CALLBACK_REASON_POST,
00181 POPT_CALLBACK_REASON_OPTION };
00182
00183 #ifdef __cplusplus
00184 extern "C" {
00185 #endif
00186
00187
00196 typedef void (*poptCallbackType) (poptContext con,
00197 enum poptCallbackReason reason,
00198 const struct poptOption * opt,
00199 const char * arg,
00200 const void * data)
00201 ;
00202
00212 poptContext poptGetContext(
00213 const char * name,
00214 int argc, const char ** argv,
00215 const struct poptOption * options,
00216 int flags)
00217 ;
00218
00223 void poptResetContext(poptContext con)
00224 ;
00225
00231 int poptGetNextOpt(poptContext con)
00232
00233 ;
00234
00235
00241 const char * poptGetOptArg(poptContext con)
00242 ;
00243
00249 const char * poptGetArg(poptContext con)
00250 ;
00251
00257 const char * poptPeekArg(poptContext con)
00258 ;
00259
00265 const char ** poptGetArgs(poptContext con)
00266 ;
00267
00273 const char * poptBadOption(poptContext con, int flags)
00274 ;
00275
00276
00282 poptContext poptFreeContext( poptContext con)
00283 ;
00284
00291 int poptStuffArgs(poptContext con, const char ** argv)
00292 ;
00293
00303
00304 int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
00305 ;
00306
00314 int poptAddItem(poptContext con, poptItem newItem, int flags)
00315 ;
00316
00323 int poptReadConfigFile(poptContext con, const char * fn)
00324
00325
00326 ;
00327
00334 int poptReadDefaultConfig(poptContext con, int useEnv)
00335
00336
00337 ;
00338
00350 int poptDupArgv(int argc, const char **argv,
00351 int * argcPtr,
00352 const char *** argvPtr)
00353 ;
00354
00366 int poptParseArgvString(const char * s,
00367 int * argcPtr, const char *** argvPtr)
00368 ;
00369
00375
00376 const char *const poptStrerror(const int error)
00377 ;
00378
00379
00386 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
00387 ;
00388
00395 void poptPrintHelp(poptContext con, FILE * fp, int flags)
00396
00397 ;
00398
00405 void poptPrintUsage(poptContext con, FILE * fp, int flags)
00406
00407 ;
00408
00414
00415 void poptSetOtherOptionHelp(poptContext con, const char * text)
00416 ;
00417
00418
00424
00425 const char * poptGetInvocationName(poptContext con)
00426 ;
00427
00428
00436
00437 int poptStrippedArgv(poptContext con, int argc, char ** argv)
00438 ;
00439
00440
00441
00442 #ifdef __cplusplus
00443 }
00444 #endif
00445
00446 #endif