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
00037 #define POPT_ARG_MAINCALL 10U
00039 #define POPT_ARG_MASK 0x0000FFFFU
00040
00046 #define POPT_ARGFLAG_ONEDASH 0x80000000U
00047 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000U
00048 #define POPT_ARGFLAG_STRIP 0x20000000U
00049 #define POPT_ARGFLAG_OPTIONAL 0x10000000U
00051 #define POPT_ARGFLAG_OR 0x08000000U
00052 #define POPT_ARGFLAG_NOR 0x09000000U
00053 #define POPT_ARGFLAG_AND 0x04000000U
00054 #define POPT_ARGFLAG_NAND 0x05000000U
00055 #define POPT_ARGFLAG_XOR 0x02000000U
00056 #define POPT_ARGFLAG_NOT 0x01000000U
00057 #define POPT_ARGFLAG_LOGICALOPS \
00058 (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
00059
00060 #define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR)
00061
00062 #define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
00063
00065 #define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000U
00066 #define POPT_ARGFLAG_RANDOM 0x00400000U
00067
00074 #define POPT_CBFLAG_PRE 0x80000000U
00075 #define POPT_CBFLAG_POST 0x40000000U
00076 #define POPT_CBFLAG_INC_DATA 0x20000000U
00078 #define POPT_CBFLAG_SKIPOPTION 0x10000000U
00079 #define POPT_CBFLAG_CONTINUE 0x08000000U
00081
00082
00086 #define POPT_ERROR_NOARG -10
00087 #define POPT_ERROR_BADOPT -11
00088 #define POPT_ERROR_OPTSTOODEEP -13
00089 #define POPT_ERROR_BADQUOTE -15
00090 #define POPT_ERROR_ERRNO -16
00091 #define POPT_ERROR_BADNUMBER -17
00092 #define POPT_ERROR_OVERFLOW -18
00093 #define POPT_ERROR_BADOPERATION -19
00094 #define POPT_ERROR_NULLARG -20
00095 #define POPT_ERROR_MALLOC -21
00097
00098
00102 #define POPT_BADOPTION_NOALIAS (1U << 0)
00104
00105
00109 #define POPT_CONTEXT_NO_EXEC (1U << 0)
00110 #define POPT_CONTEXT_KEEP_FIRST (1U << 1)
00111 #define POPT_CONTEXT_POSIXMEHARDER (1U << 2)
00112 #define POPT_CONTEXT_ARG_OPTS (1U << 4)
00114
00115
00117 struct poptOption {
00118
00119 const char * longName;
00120 char shortName;
00121 unsigned int argInfo;
00122
00123 void * arg;
00124 int val;
00125
00126 const char * descrip;
00127
00128 const char * argDescrip;
00129 };
00130
00134 struct poptAlias {
00135
00136 const char * longName;
00137 char shortName;
00138 int argc;
00139
00140 const char ** argv;
00141 };
00142
00146
00147 typedef struct poptItem_s {
00148 struct poptOption option;
00149 int argc;
00150
00151 const char ** argv;
00152 } * poptItem;
00153
00154
00159
00163
00164
00165 extern struct poptOption poptAliasOptions[];
00166
00167 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
00168 0, "Options implemented via popt alias/exec:", NULL },
00169
00173
00174
00175 extern struct poptOption poptHelpOptions[];
00176
00177
00178
00179
00180 extern struct poptOption * poptHelpOptionsI18N;
00181
00182
00183 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
00184 0, "Help options:", NULL },
00185
00186 #define POPT_TABLEEND { NULL, '\0', 0, NULL, 0, NULL, NULL }
00187
00191
00192 typedef struct poptContext_s * poptContext;
00193
00194
00197 #ifndef __cplusplus
00198
00199 typedef struct poptOption * poptOption;
00200
00201 #endif
00202
00205
00206 enum poptCallbackReason {
00207 POPT_CALLBACK_REASON_PRE = 0,
00208 POPT_CALLBACK_REASON_POST = 1,
00209 POPT_CALLBACK_REASON_OPTION = 2
00210 };
00211
00212
00213 #ifdef __cplusplus
00214 extern "C" {
00215 #endif
00216
00217
00226 typedef void (*poptCallbackType) (poptContext con,
00227 enum poptCallbackReason reason,
00228 const struct poptOption * opt,
00229 const char * arg,
00230 const void * data)
00231
00232 ;
00233
00243
00244 poptContext poptGetContext(
00245 const char * name,
00246 int argc, const char ** argv,
00247 const struct poptOption * options,
00248 unsigned int flags)
00249 ;
00250
00255
00256 void poptResetContext(poptContext con)
00257 ;
00258
00264 int poptGetNextOpt(poptContext con)
00265
00266 ;
00267
00273
00274 char * poptGetOptArg(poptContext con)
00275 ;
00276
00282
00283 const char * poptGetArg(poptContext con)
00284 ;
00285
00291
00292 const char * poptPeekArg(poptContext con)
00293 ;
00294
00300
00301 const char ** poptGetArgs(poptContext con)
00302 ;
00303
00310
00311 const char * poptBadOption(poptContext con, unsigned int flags)
00312 ;
00313
00319
00320 poptContext poptFreeContext( poptContext con)
00321 ;
00322
00329
00330 int poptStuffArgs(poptContext con, const char ** argv)
00331 ;
00332
00342
00343 int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
00344 ;
00345
00353 int poptAddItem(poptContext con, poptItem newItem, int flags)
00354 ;
00355
00362 int poptReadConfigFile(poptContext con, const char * fn)
00363
00364
00365 ;
00366
00373
00374 int poptReadDefaultConfig(poptContext con, int useEnv)
00375
00376
00377 ;
00378
00390 int poptDupArgv(int argc, const char **argv,
00391 int * argcPtr,
00392 const char *** argvPtr)
00393 ;
00394
00406 int poptParseArgvString(const char * s,
00407 int * argcPtr, const char *** argvPtr)
00408 ;
00409
00456
00457 int poptConfigFileToString(FILE *fp, char ** argstrp, int flags)
00458
00459 ;
00460
00461
00467
00468 const char * poptStrerror(const int error)
00469 ;
00470
00477
00478 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
00479 ;
00480
00487 void poptPrintHelp(poptContext con, FILE * fp, int flags)
00488
00489 ;
00490
00497 void poptPrintUsage(poptContext con, FILE * fp, int flags)
00498
00499 ;
00500
00506
00507 void poptSetOtherOptionHelp(poptContext con, const char * text)
00508 ;
00509
00510
00516
00517
00518 const char * poptGetInvocationName(poptContext con)
00519 ;
00520
00521
00529
00530 int poptStrippedArgv(poptContext con, int argc, char ** argv)
00531 ;
00532
00533
00542
00543
00544 int poptSaveLong( long * arg, unsigned int argInfo, long aLong)
00545
00546
00547 ;
00548
00549
00558
00559
00560 int poptSaveInt( int * arg, unsigned int argInfo, long aLong)
00561
00562
00563 ;
00564
00565
00566
00567 #ifdef __cplusplus
00568 }
00569 #endif
00570
00571 #endif