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 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
00036 #define POPT_ARG_LONGLONG 10U
00038 #define POPT_ARG_MAINCALL 16U+11U
00039 #define POPT_ARG_ARGV 12U
00041 #define POPT_ARG_MASK 0x0000FFFFU
00042
00048 #define POPT_ARGFLAG_ONEDASH 0x80000000U
00049 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000U
00050 #define POPT_ARGFLAG_STRIP 0x20000000U
00051 #define POPT_ARGFLAG_OPTIONAL 0x10000000U
00053 #define POPT_ARGFLAG_OR 0x08000000U
00054 #define POPT_ARGFLAG_NOR 0x09000000U
00055 #define POPT_ARGFLAG_AND 0x04000000U
00056 #define POPT_ARGFLAG_NAND 0x05000000U
00057 #define POPT_ARGFLAG_XOR 0x02000000U
00058 #define POPT_ARGFLAG_NOT 0x01000000U
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 0x00800000U
00068 #define POPT_ARGFLAG_RANDOM 0x00400000U
00069
00076 #define POPT_CBFLAG_PRE 0x80000000U
00077 #define POPT_CBFLAG_POST 0x40000000U
00078 #define POPT_CBFLAG_INC_DATA 0x20000000U
00080 #define POPT_CBFLAG_SKIPOPTION 0x10000000U
00081 #define POPT_CBFLAG_CONTINUE 0x08000000U
00083
00084
00088 #define POPT_ERROR_NOARG -10
00089 #define POPT_ERROR_BADOPT -11
00090 #define POPT_ERROR_OPTSTOODEEP -13
00091 #define POPT_ERROR_BADQUOTE -15
00092 #define POPT_ERROR_ERRNO -16
00093 #define POPT_ERROR_BADNUMBER -17
00094 #define POPT_ERROR_OVERFLOW -18
00095 #define POPT_ERROR_BADOPERATION -19
00096 #define POPT_ERROR_NULLARG -20
00097 #define POPT_ERROR_MALLOC -21
00099
00100
00104 #define POPT_BADOPTION_NOALIAS (1U << 0)
00106
00107
00111 #define POPT_CONTEXT_NO_EXEC (1U << 0)
00112 #define POPT_CONTEXT_KEEP_FIRST (1U << 1)
00113 #define POPT_CONTEXT_POSIXMEHARDER (1U << 2)
00114 #define POPT_CONTEXT_ARG_OPTS (1U << 4)
00116
00117
00119 struct poptOption {
00120
00121 const char * longName;
00122 char shortName;
00123 unsigned int argInfo;
00124
00125 void * arg;
00126 int val;
00127
00128 const char * descrip;
00129
00130 const char * argDescrip;
00131 };
00132
00136 struct poptAlias {
00137
00138 const char * longName;
00139 char shortName;
00140 int argc;
00141
00142 const char ** argv;
00143 };
00144
00148
00149 typedef struct poptItem_s {
00150 struct poptOption option;
00151 int argc;
00152
00153 const char ** argv;
00154 } * poptItem;
00155
00156
00161
00165
00166
00167 extern struct poptOption poptAliasOptions[];
00168
00169 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
00170 0, "Options implemented via popt alias/exec:", NULL },
00171
00175
00176
00177 extern struct poptOption poptHelpOptions[];
00178
00179
00180
00181
00182 extern struct poptOption * poptHelpOptionsI18N;
00183
00184
00185 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
00186 0, "Help options:", NULL },
00187
00188 #define POPT_TABLEEND { NULL, '\0', 0, NULL, 0, NULL, NULL }
00189
00193
00194 typedef struct poptContext_s * poptContext;
00195
00196
00199 #ifndef __cplusplus
00200
00201 typedef struct poptOption * poptOption;
00202
00203 #endif
00204
00207
00208 enum poptCallbackReason {
00209 POPT_CALLBACK_REASON_PRE = 0,
00210 POPT_CALLBACK_REASON_POST = 1,
00211 POPT_CALLBACK_REASON_OPTION = 2
00212 };
00213
00214
00215 #ifdef __cplusplus
00216 extern "C" {
00217 #endif
00218
00219
00228 typedef void (*poptCallbackType) (poptContext con,
00229 enum poptCallbackReason reason,
00230 const struct poptOption * opt,
00231 const char * arg,
00232 const void * data)
00233
00234 ;
00235
00245
00246 poptContext poptGetContext(
00247 const char * name,
00248 int argc, const char ** argv,
00249 const struct poptOption * options,
00250 unsigned int flags)
00251
00252 ;
00253
00258
00259 void poptResetContext(poptContext con)
00260 ;
00261
00267 int poptGetNextOpt(poptContext con)
00268
00269 ;
00270
00276
00277 char * poptGetOptArg(poptContext con)
00278 ;
00279
00285
00286 const char * poptGetArg(poptContext con)
00287 ;
00288
00294
00295 const char * poptPeekArg(poptContext con)
00296 ;
00297
00303
00304 const char ** poptGetArgs(poptContext con)
00305 ;
00306
00313
00314 const char * poptBadOption(poptContext con, unsigned int flags)
00315 ;
00316
00322
00323 poptContext poptFreeContext( poptContext con)
00324 ;
00325
00332
00333 int poptStuffArgs(poptContext con, const char ** argv)
00334 ;
00335
00345
00346 int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
00347 ;
00348
00356 int poptAddItem(poptContext con, poptItem newItem, int flags)
00357 ;
00358
00365 int poptReadConfigFile(poptContext con, const char * fn)
00366
00367
00368 ;
00369
00376
00377 int poptReadDefaultConfig(poptContext con, int useEnv)
00378
00379
00380 ;
00381
00393 int poptDupArgv(int argc, const char **argv,
00394 int * argcPtr,
00395 const char *** argvPtr)
00396 ;
00397
00409 int poptParseArgvString(const char * s,
00410 int * argcPtr, const char *** argvPtr)
00411 ;
00412
00459
00460 int poptConfigFileToString(FILE *fp, char ** argstrp, int flags)
00461
00462 ;
00463
00464
00470
00471 const char * poptStrerror(const int error)
00472 ;
00473
00480
00481 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
00482 ;
00483
00490 void poptPrintHelp(poptContext con, FILE * fp, int flags)
00491
00492 ;
00493
00500 void poptPrintUsage(poptContext con, FILE * fp, int flags)
00501
00502 ;
00503
00509
00510 void poptSetOtherOptionHelp(poptContext con, const char * text)
00511 ;
00512
00513
00519
00520
00521 const char * poptGetInvocationName(poptContext con)
00522 ;
00523
00524
00532
00533 int poptStrippedArgv(poptContext con, int argc, char ** argv)
00534 ;
00535
00536
00544
00545 int poptSaveString( const char *** argvp, unsigned int argInfo,
00546 const char * val)
00547 ;
00548
00557
00558
00559 int poptSaveLongLong( long long * arg, unsigned int argInfo,
00560 long long aLongLong)
00561
00562
00563 ;
00564
00565
00574
00575
00576 int poptSaveLong( long * arg, unsigned int argInfo, long aLong)
00577
00578
00579 ;
00580
00581
00590
00591
00592 int poptSaveInt( int * arg, unsigned int argInfo, long aLong)
00593
00594
00595 ;
00596
00597
00598
00599 #ifdef __cplusplus
00600 }
00601 #endif
00602
00603 #endif