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
00040 #define POPT_ARG_SHORT 13U
00041 #define POPT_ARG_BITSET 16U+14U
00043 #define POPT_ARG_MASK 0x000000FFU
00044 #define POPT_GROUP_MASK 0x0000FF00U
00045
00052 #define POPT_ARGFLAG_ONEDASH 0x80000000U
00053 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000U
00054 #define POPT_ARGFLAG_STRIP 0x20000000U
00055 #define POPT_ARGFLAG_OPTIONAL 0x10000000U
00057 #define POPT_ARGFLAG_OR 0x08000000U
00058 #define POPT_ARGFLAG_NOR 0x09000000U
00059 #define POPT_ARGFLAG_AND 0x04000000U
00060 #define POPT_ARGFLAG_NAND 0x05000000U
00061 #define POPT_ARGFLAG_XOR 0x02000000U
00062 #define POPT_ARGFLAG_NOT 0x01000000U
00063 #define POPT_ARGFLAG_LOGICALOPS \
00064 (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
00065
00066 #define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR)
00067
00068 #define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
00069
00071 #define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000U
00072 #define POPT_ARGFLAG_RANDOM 0x00400000U
00073 #define POPT_ARGFLAG_TOGGLE 0x00200000U
00076
00077
00081 #define POPT_CBFLAG_PRE 0x80000000U
00082 #define POPT_CBFLAG_POST 0x40000000U
00083 #define POPT_CBFLAG_INC_DATA 0x20000000U
00085 #define POPT_CBFLAG_SKIPOPTION 0x10000000U
00086 #define POPT_CBFLAG_CONTINUE 0x08000000U
00088
00089
00093 #define POPT_ERROR_NOARG -10
00094 #define POPT_ERROR_BADOPT -11
00095 #define POPT_ERROR_OPTSTOODEEP -13
00096 #define POPT_ERROR_BADQUOTE -15
00097 #define POPT_ERROR_ERRNO -16
00098 #define POPT_ERROR_BADNUMBER -17
00099 #define POPT_ERROR_OVERFLOW -18
00100 #define POPT_ERROR_BADOPERATION -19
00101 #define POPT_ERROR_NULLARG -20
00102 #define POPT_ERROR_MALLOC -21
00103 #define POPT_ERROR_BADCONFIG -22
00105
00106
00110 #define POPT_BADOPTION_NOALIAS (1U << 0)
00112
00113
00117 #define POPT_CONTEXT_NO_EXEC (1U << 0)
00118 #define POPT_CONTEXT_KEEP_FIRST (1U << 1)
00119 #define POPT_CONTEXT_POSIXMEHARDER (1U << 2)
00120 #define POPT_CONTEXT_ARG_OPTS (1U << 4)
00122
00123
00125 struct poptOption {
00126
00127 const char * longName;
00128 char shortName;
00129 unsigned int argInfo;
00130
00131 void * arg;
00132 int val;
00133
00134 const char * descrip;
00135
00136 const char * argDescrip;
00137 };
00138
00142 struct poptAlias {
00143
00144 const char * longName;
00145 char shortName;
00146 int argc;
00147
00148 const char ** argv;
00149 };
00150
00154
00155 typedef struct poptItem_s {
00156 struct poptOption option;
00157 int argc;
00158
00159 const char ** argv;
00160 } * poptItem;
00161
00162
00167
00171
00172
00173 extern struct poptOption poptAliasOptions[];
00174
00175 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
00176 0, "Options implemented via popt alias/exec:", NULL },
00177
00181
00182
00183 extern struct poptOption poptHelpOptions[];
00184
00185
00186
00187
00188 extern struct poptOption * poptHelpOptionsI18N;
00189
00190
00191 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
00192 0, "Help options:", NULL },
00193
00194 #define POPT_TABLEEND { NULL, '\0', 0, NULL, 0, NULL, NULL }
00195
00199
00200 typedef struct poptContext_s * poptContext;
00201
00202
00205 #ifndef __cplusplus
00206
00207 typedef struct poptOption * poptOption;
00208
00209 #endif
00210
00213
00214 enum poptCallbackReason {
00215 POPT_CALLBACK_REASON_PRE = 0,
00216 POPT_CALLBACK_REASON_POST = 1,
00217 POPT_CALLBACK_REASON_OPTION = 2
00218 };
00219
00220
00221 #ifdef __cplusplus
00222 extern "C" {
00223 #endif
00224
00225
00234 typedef void (*poptCallbackType) (poptContext con,
00235 enum poptCallbackReason reason,
00236 const struct poptOption * opt,
00237 const char * arg,
00238 const void * data)
00239
00240 ;
00241
00247
00248 poptContext poptFreeContext( poptContext con)
00249 ;
00250
00260
00261 poptContext poptGetContext(
00262 const char * name,
00263 int argc, const char ** argv,
00264 const struct poptOption * options,
00265 unsigned int flags)
00266
00267 ;
00268
00274
00275 poptContext poptFini( poptContext con)
00276 ;
00277
00287
00288 poptContext poptInit(int argc, const char ** argv,
00289 const struct poptOption * options,
00290 const char * configPaths)
00291
00292 ;
00293
00298
00299 void poptResetContext(poptContext con)
00300 ;
00301
00307 int poptGetNextOpt(poptContext con)
00308
00309 ;
00310
00316
00317 char * poptGetOptArg(poptContext con)
00318 ;
00319
00325
00326 const char * poptGetArg(poptContext con)
00327 ;
00328
00334
00335 const char * poptPeekArg(poptContext con)
00336 ;
00337
00343
00344 const char ** poptGetArgs(poptContext con)
00345 ;
00346
00353
00354 const char * poptBadOption(poptContext con, unsigned int flags)
00355 ;
00356
00363
00364 int poptStuffArgs(poptContext con, const char ** argv)
00365 ;
00366
00376
00377 int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
00378 ;
00379
00387 int poptAddItem(poptContext con, poptItem newItem, int flags)
00388 ;
00389
00395 int poptSaneFile(const char * fn)
00396
00397 ;
00398
00407 int poptReadFile(const char * fn, char ** bp,
00408 size_t * nbp, int flags)
00409
00410 ;
00411 #define POPT_READFILE_TRIMNEWLINES 1
00412
00419 int poptReadConfigFile(poptContext con, const char * fn)
00420
00421
00422 ;
00423
00433 int poptReadConfigFiles(poptContext con, const char * paths)
00434
00435
00436 ;
00437
00444
00445 int poptReadDefaultConfig(poptContext con, int useEnv)
00446
00447
00448 ;
00449
00461 int poptDupArgv(int argc, const char **argv,
00462 int * argcPtr,
00463 const char *** argvPtr)
00464 ;
00465
00477 int poptParseArgvString(const char * s,
00478 int * argcPtr, const char *** argvPtr)
00479 ;
00480
00527
00528 int poptConfigFileToString(FILE *fp, char ** argstrp, int flags)
00529
00530 ;
00531
00532
00538
00539 const char * poptStrerror(const int error)
00540 ;
00541
00548
00549 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
00550 ;
00551
00558 void poptPrintHelp(poptContext con, FILE * fp, int flags)
00559
00560 ;
00561
00568 void poptPrintUsage(poptContext con, FILE * fp, int flags)
00569
00570 ;
00571
00577
00578 void poptSetOtherOptionHelp(poptContext con, const char * text)
00579 ;
00580
00581
00587
00588
00589 const char * poptGetInvocationName(poptContext con)
00590 ;
00591
00592
00600
00601 int poptStrippedArgv(poptContext con, int argc, char ** argv)
00602 ;
00603
00604
00612
00613 int poptSaveString( const char *** argvp, unsigned int argInfo,
00614 const char * val)
00615 ;
00616
00625
00626
00627 int poptSaveLongLong( long long * arg, unsigned int argInfo,
00628 long long aLongLong)
00629
00630
00631 ;
00632
00633
00642
00643
00644 int poptSaveLong( long * arg, unsigned int argInfo, long aLong)
00645
00646
00647 ;
00648
00649
00658
00659
00660 int poptSaveShort( short * arg, unsigned int argInfo, long aLong)
00661
00662
00663 ;
00664
00665
00674
00675
00676 int poptSaveInt( int * arg, unsigned int argInfo, long aLong)
00677
00678
00679 ;
00680
00681
00682
00683
00684 typedef struct poptBits_s {
00685 unsigned int bits[1];
00686 } * poptBits;
00687
00688
00689 #define _POPT_BITS_N 1024U
00690 #define _POPT_BITS_M ((3U * _POPT_BITS_N) / 2U)
00691 #define _POPT_BITS_K 16U
00692
00693
00694
00695 extern unsigned int _poptBitsN;
00696
00697 extern unsigned int _poptBitsM;
00698
00699 extern unsigned int _poptBitsK;
00700
00701
00702
00703 int poptBitsAdd(poptBits bits, const char * s)
00704 ;
00705
00706 int poptBitsChk(poptBits bits, const char * s)
00707 ;
00708 int poptBitsClr(poptBits bits)
00709 ;
00710
00711 int poptBitsDel(poptBits bits, const char * s)
00712 ;
00713
00714 int poptBitsIntersect( poptBits * ap, const poptBits b)
00715 ;
00716 int poptBitsUnion( poptBits * ap, const poptBits b)
00717 ;
00718 int poptBitsArgs( poptContext con, poptBits * ap)
00719 ;
00720
00721
00722
00730
00731
00732 int poptSaveBits( poptBits * bitsp, unsigned int argInfo,
00733 const char * s)
00734
00735 ;
00736
00737
00738
00739
00740 #ifdef __cplusplus
00741 }
00742 #endif
00743
00744 #endif