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
00098 #define POPT_ERROR_NOCONTEXT -22
00100
00101
00105 #define POPT_BADOPTION_NOALIAS (1U << 0)
00107
00108
00112 #define POPT_CONTEXT_NO_EXEC (1U << 0)
00113 #define POPT_CONTEXT_KEEP_FIRST (1U << 1)
00114 #define POPT_CONTEXT_POSIXMEHARDER (1U << 2)
00115 #define POPT_CONTEXT_ARG_OPTS (1U << 4)
00117
00118
00120 struct poptOption {
00121
00122 const char * longName;
00123 char shortName;
00124 unsigned int argInfo;
00125
00126 void * arg;
00127 int val;
00128
00129 const char * descrip;
00130
00131 const char * argDescrip;
00132 };
00133
00137 struct poptAlias {
00138
00139 const char * longName;
00140 char shortName;
00141 int argc;
00142
00143 const char ** argv;
00144 };
00145
00149
00150 typedef struct poptItem_s {
00151 struct poptOption option;
00152 int argc;
00153
00154 const char ** argv;
00155 } * poptItem;
00156
00157
00162
00166
00167
00168 extern struct poptOption poptAliasOptions[];
00169
00170 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
00171 0, "Options implemented via popt alias/exec:", NULL },
00172
00176
00177
00178 extern struct poptOption poptHelpOptions[];
00179
00180
00181
00182
00183 extern struct poptOption * poptHelpOptionsI18N;
00184
00185
00186 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
00187 0, "Help options:", NULL },
00188
00189 #define POPT_TABLEEND { NULL, '\0', 0, NULL, 0, NULL, NULL }
00190
00194
00195 typedef struct poptContext_s * poptContext;
00196
00197
00200 #ifndef __cplusplus
00201
00202 typedef struct poptOption * poptOption;
00203
00204 #endif
00205
00208
00209 enum poptCallbackReason {
00210 POPT_CALLBACK_REASON_PRE = 0,
00211 POPT_CALLBACK_REASON_POST = 1,
00212 POPT_CALLBACK_REASON_OPTION = 2
00213 };
00214
00215
00216 #ifdef __cplusplus
00217 extern "C" {
00218 #endif
00219
00220
00229 typedef void (*poptCallbackType) (poptContext con,
00230 enum poptCallbackReason reason,
00231 const struct poptOption * opt,
00232 const char * arg,
00233 const void * data)
00234
00235 ;
00236
00246
00247 poptContext poptGetContext(
00248 const char * name,
00249 int argc, const char ** argv,
00250 const struct poptOption * options,
00251 unsigned int flags)
00252
00253 ;
00254
00259
00260 void poptResetContext(poptContext con)
00261 ;
00262
00268 int poptGetNextOpt(poptContext con)
00269
00270 ;
00271
00277
00278 char * poptGetOptArg(poptContext con)
00279 ;
00280
00286
00287 const char * poptGetArg(poptContext con)
00288 ;
00289
00295
00296 const char * poptPeekArg(poptContext con)
00297 ;
00298
00304
00305 const char ** poptGetArgs(poptContext con)
00306 ;
00307
00314
00315 const char * poptBadOption(poptContext con, unsigned int flags)
00316 ;
00317
00323
00324 poptContext poptFreeContext( poptContext con)
00325 ;
00326
00333
00334 int poptStuffArgs(poptContext con, const char ** argv)
00335 ;
00336
00346
00347 int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
00348 ;
00349
00357 int poptAddItem(poptContext con, poptItem newItem, int flags)
00358 ;
00359
00366 int poptReadConfigFile(poptContext con, const char * fn)
00367
00368
00369 ;
00370
00377
00378 int poptReadDefaultConfig(poptContext con, int useEnv)
00379
00380
00381 ;
00382
00394 int poptDupArgv(int argc, const char **argv,
00395 int * argcPtr,
00396 const char *** argvPtr)
00397 ;
00398
00410 int poptParseArgvString(const char * s,
00411 int * argcPtr, const char *** argvPtr)
00412 ;
00413
00460
00461 int poptConfigFileToString(FILE *fp, char ** argstrp, int flags)
00462
00463 ;
00464
00465
00471
00472 const char * poptStrerror(const int error)
00473 ;
00474
00481
00482 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
00483 ;
00484
00491 void poptPrintHelp(poptContext con, FILE * fp, int flags)
00492
00493 ;
00494
00501 void poptPrintUsage(poptContext con, FILE * fp, int flags)
00502
00503 ;
00504
00510
00511 void poptSetOtherOptionHelp(poptContext con, const char * text)
00512 ;
00513
00514
00520
00521
00522 const char * poptGetInvocationName(poptContext con)
00523 ;
00524
00525
00533
00534 int poptStrippedArgv(poptContext con, int argc, char ** argv)
00535 ;
00536
00537
00545
00546 int poptSaveString( const char *** argvp, unsigned int argInfo,
00547 const char * val)
00548 ;
00549
00558
00559
00560 int poptSaveLongLong( long long * arg, unsigned int argInfo,
00561 long long aLongLong)
00562
00563
00564 ;
00565
00566
00575
00576
00577 int poptSaveLong( long * arg, unsigned int argInfo, long aLong)
00578
00579
00580 ;
00581
00582
00591
00592
00593 int poptSaveInt( int * arg, unsigned int argInfo, long aLong)
00594
00595
00596 ;
00597
00598
00599
00600 #ifdef __cplusplus
00601 }
00602 #endif
00603
00604 #endif