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 0x000000FFU
00042 #define POPT_GROUP_MASK 0x0000FF00U
00043
00050 #define POPT_ARGFLAG_ONEDASH 0x80000000U
00051 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000U
00052 #define POPT_ARGFLAG_STRIP 0x20000000U
00053 #define POPT_ARGFLAG_OPTIONAL 0x10000000U
00055 #define POPT_ARGFLAG_OR 0x08000000U
00056 #define POPT_ARGFLAG_NOR 0x09000000U
00057 #define POPT_ARGFLAG_AND 0x04000000U
00058 #define POPT_ARGFLAG_NAND 0x05000000U
00059 #define POPT_ARGFLAG_XOR 0x02000000U
00060 #define POPT_ARGFLAG_NOT 0x01000000U
00061 #define POPT_ARGFLAG_LOGICALOPS \
00062 (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
00063
00064 #define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR)
00065
00066 #define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
00067
00069 #define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000U
00070 #define POPT_ARGFLAG_RANDOM 0x00400000U
00071 #define POPT_ARGFLAG_TOGGLE 0x00200000U
00074
00075
00079 #define POPT_CBFLAG_PRE 0x80000000U
00080 #define POPT_CBFLAG_POST 0x40000000U
00081 #define POPT_CBFLAG_INC_DATA 0x20000000U
00083 #define POPT_CBFLAG_SKIPOPTION 0x10000000U
00084 #define POPT_CBFLAG_CONTINUE 0x08000000U
00086
00087
00091 #define POPT_ERROR_NOARG -10
00092 #define POPT_ERROR_BADOPT -11
00093 #define POPT_ERROR_OPTSTOODEEP -13
00094 #define POPT_ERROR_BADQUOTE -15
00095 #define POPT_ERROR_ERRNO -16
00096 #define POPT_ERROR_BADNUMBER -17
00097 #define POPT_ERROR_OVERFLOW -18
00098 #define POPT_ERROR_BADOPERATION -19
00099 #define POPT_ERROR_NULLARG -20
00100 #define POPT_ERROR_MALLOC -21
00101 #define POPT_ERROR_BADCONFIG -22
00103
00104
00108 #define POPT_BADOPTION_NOALIAS (1U << 0)
00110
00111
00115 #define POPT_CONTEXT_NO_EXEC (1U << 0)
00116 #define POPT_CONTEXT_KEEP_FIRST (1U << 1)
00117 #define POPT_CONTEXT_POSIXMEHARDER (1U << 2)
00118 #define POPT_CONTEXT_ARG_OPTS (1U << 4)
00120
00121
00123 struct poptOption {
00124
00125 const char * longName;
00126 char shortName;
00127 unsigned int argInfo;
00128
00129 void * arg;
00130 int val;
00131
00132 const char * descrip;
00133
00134 const char * argDescrip;
00135 };
00136
00140 struct poptAlias {
00141
00142 const char * longName;
00143 char shortName;
00144 int argc;
00145
00146 const char ** argv;
00147 };
00148
00152
00153 typedef struct poptItem_s {
00154 struct poptOption option;
00155 int argc;
00156
00157 const char ** argv;
00158 } * poptItem;
00159
00160
00165
00169
00170
00171 extern struct poptOption poptAliasOptions[];
00172
00173 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
00174 0, "Options implemented via popt alias/exec:", NULL },
00175
00179
00180
00181 extern struct poptOption poptHelpOptions[];
00182
00183
00184
00185
00186 extern struct poptOption * poptHelpOptionsI18N;
00187
00188
00189 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
00190 0, "Help options:", NULL },
00191
00192 #define POPT_TABLEEND { NULL, '\0', 0, NULL, 0, NULL, NULL }
00193
00197
00198 typedef struct poptContext_s * poptContext;
00199
00200
00203 #ifndef __cplusplus
00204
00205 typedef struct poptOption * poptOption;
00206
00207 #endif
00208
00211
00212 enum poptCallbackReason {
00213 POPT_CALLBACK_REASON_PRE = 0,
00214 POPT_CALLBACK_REASON_POST = 1,
00215 POPT_CALLBACK_REASON_OPTION = 2
00216 };
00217
00218
00219 #ifdef __cplusplus
00220 extern "C" {
00221 #endif
00222
00223
00232 typedef void (*poptCallbackType) (poptContext con,
00233 enum poptCallbackReason reason,
00234 const struct poptOption * opt,
00235 const char * arg,
00236 const void * data)
00237
00238 ;
00239
00245
00246 poptContext poptFreeContext( poptContext con)
00247 ;
00248
00258
00259 poptContext poptGetContext(
00260 const char * name,
00261 int argc, const char ** argv,
00262 const struct poptOption * options,
00263 unsigned int flags)
00264
00265 ;
00266
00272
00273 poptContext poptFini( poptContext con)
00274 ;
00275
00285
00286 poptContext poptInit(int argc, const char ** argv,
00287 const struct poptOption * options,
00288 const char * configPaths)
00289
00290 ;
00291
00296
00297 void poptResetContext(poptContext con)
00298 ;
00299
00305 int poptGetNextOpt(poptContext con)
00306
00307 ;
00308
00314
00315 char * poptGetOptArg(poptContext con)
00316 ;
00317
00323
00324 const char * poptGetArg(poptContext con)
00325 ;
00326
00332
00333 const char * poptPeekArg(poptContext con)
00334 ;
00335
00341
00342 const char ** poptGetArgs(poptContext con)
00343 ;
00344
00351
00352 const char * poptBadOption(poptContext con, unsigned int flags)
00353 ;
00354
00361
00362 int poptStuffArgs(poptContext con, const char ** argv)
00363 ;
00364
00374
00375 int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
00376 ;
00377
00385 int poptAddItem(poptContext con, poptItem newItem, int flags)
00386 ;
00387
00393 int poptSaneFile(const char * fn)
00394
00395 ;
00396
00405 int poptReadFile(const char * fn, char ** bp,
00406 size_t * nbp, int flags)
00407
00408 ;
00409 #define POPT_READFILE_TRIMNEWLINES 1
00410
00417 int poptReadConfigFile(poptContext con, const char * fn)
00418
00419
00420 ;
00421
00431 int poptReadConfigFiles(poptContext con, const char * paths)
00432
00433
00434 ;
00435
00442
00443 int poptReadDefaultConfig(poptContext con, int useEnv)
00444
00445
00446 ;
00447
00459 int poptDupArgv(int argc, const char **argv,
00460 int * argcPtr,
00461 const char *** argvPtr)
00462 ;
00463
00475 int poptParseArgvString(const char * s,
00476 int * argcPtr, const char *** argvPtr)
00477 ;
00478
00525
00526 int poptConfigFileToString(FILE *fp, char ** argstrp, int flags)
00527
00528 ;
00529
00530
00536
00537 const char * poptStrerror(const int error)
00538 ;
00539
00546
00547 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
00548 ;
00549
00556 void poptPrintHelp(poptContext con, FILE * fp, int flags)
00557
00558 ;
00559
00566 void poptPrintUsage(poptContext con, FILE * fp, int flags)
00567
00568 ;
00569
00575
00576 void poptSetOtherOptionHelp(poptContext con, const char * text)
00577 ;
00578
00579
00585
00586
00587 const char * poptGetInvocationName(poptContext con)
00588 ;
00589
00590
00598
00599 int poptStrippedArgv(poptContext con, int argc, char ** argv)
00600 ;
00601
00602
00610
00611 int poptSaveString( const char *** argvp, unsigned int argInfo,
00612 const char * val)
00613 ;
00614
00623
00624
00625 int poptSaveLongLong( long long * arg, unsigned int argInfo,
00626 long long aLongLong)
00627
00628
00629 ;
00630
00631
00640
00641
00642 int poptSaveLong( long * arg, unsigned int argInfo, long aLong)
00643
00644
00645 ;
00646
00647
00656
00657
00658 int poptSaveInt( int * arg, unsigned int argInfo, long aLong)
00659
00660
00661 ;
00662
00663
00664
00665 #ifdef __cplusplus
00666 }
00667 #endif
00668
00669 #endif