Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

popt/popt.h

Go to the documentation of this file.
00001 
00005 /* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
00006    file accompanying popt source distributions, available from 
00007    ftp://ftp.rpm.org/pub/rpm/dist. */
00008 
00009 #ifndef H_POPT
00010 #define H_POPT
00011 
00012 #ifdef __cplusplus
00013 extern "C" {
00014 #endif
00015 
00016 #include <stdio.h>                      /* for FILE * */
00017 
00018 #define POPT_OPTION_DEPTH       10
00019 
00024 #define POPT_ARG_NONE           0       
00025 #define POPT_ARG_STRING         1       
00026 #define POPT_ARG_INT            2       
00027 #define POPT_ARG_LONG           3       
00028 #define POPT_ARG_INCLUDE_TABLE  4       
00029 #define POPT_ARG_CALLBACK       5       
00033 #define POPT_ARG_INTL_DOMAIN    6       
00037 #define POPT_ARG_VAL            7       
00038 #define POPT_ARG_FLOAT          8       
00039 #define POPT_ARG_DOUBLE         9       
00041 #define POPT_ARG_MASK           0x0000FFFF
00042 
00048 #define POPT_ARGFLAG_ONEDASH    0x80000000  
00049 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000  
00050 #define POPT_ARGFLAG_STRIP      0x20000000  
00051 #define POPT_ARGFLAG_OPTIONAL   0x10000000  
00053 #define POPT_ARGFLAG_OR         0x08000000  
00054 #define POPT_ARGFLAG_NOR        0x09000000  
00055 #define POPT_ARGFLAG_AND        0x04000000  
00056 #define POPT_ARGFLAG_NAND       0x05000000  
00057 #define POPT_ARGFLAG_XOR        0x02000000  
00058 #define POPT_ARGFLAG_NOT        0x01000000  
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 0x00800000 
00070 
00071 
00075 #define POPT_CBFLAG_PRE         0x80000000  
00076 #define POPT_CBFLAG_POST        0x40000000  
00077 #define POPT_CBFLAG_INC_DATA    0x20000000  
00079 #define POPT_CBFLAG_SKIPOPTION  0x10000000  
00080 #define POPT_CBFLAG_CONTINUE    0x08000000  
00082 
00083 
00087 #define POPT_ERROR_NOARG        -10     
00088 #define POPT_ERROR_BADOPT       -11     
00089 #define POPT_ERROR_OPTSTOODEEP  -13     
00090 #define POPT_ERROR_BADQUOTE     -15     
00091 #define POPT_ERROR_ERRNO        -16     
00092 #define POPT_ERROR_BADNUMBER    -17     
00093 #define POPT_ERROR_OVERFLOW     -18     
00094 #define POPT_ERROR_BADOPERATION -19     
00095 #define POPT_ERROR_NULLARG      -20     
00096 #define POPT_ERROR_MALLOC       -21     
00098 
00099 
00103 #define POPT_BADOPTION_NOALIAS  (1 << 0)  
00105 
00106 
00110 #define POPT_CONTEXT_NO_EXEC    (1 << 0)  
00111 #define POPT_CONTEXT_KEEP_FIRST (1 << 1)  
00112 #define POPT_CONTEXT_POSIXMEHARDER (1 << 2) 
00113 #define POPT_CONTEXT_ARG_OPTS   (1 << 4) 
00115 
00116 
00118 struct poptOption {
00119 /*@observer@*/ /*@null@*/ const char * longName; 
00120     char shortName;                     
00121     int argInfo;
00122 /*@shared@*/ /*@null@*/ void * arg;     
00123     int val;                    
00124 /*@observer@*/ /*@null@*/ const char * descrip; 
00125 /*@observer@*/ /*@null@*/ const char * argDescrip; 
00126 };
00127 
00131 struct poptAlias {
00132 /*@owned@*/ /*@null@*/ const char * longName;   
00133     char shortName;             
00134     int argc;
00135 /*@owned@*/ const char ** argv; 
00136 };
00137 
00141 typedef struct poptItem_s {
00142     struct poptOption option;   
00143     int argc;                   
00144 /*@owned@*/ const char ** argv; 
00145 } * poptItem;
00146 
00151 
00155 extern struct poptOption poptAliasOptions[];
00156 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
00157                         0, "Options implemented via popt alias/exec:", NULL },
00158 
00162 extern struct poptOption poptHelpOptions[];
00163 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
00164                         0, "Help options:", NULL },
00165 
00166 #define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL }
00167 
00171 typedef /*@abstract@*/ struct poptContext_s * poptContext;
00172 
00175 #ifndef __cplusplus
00176 /*@-typeuse@*/
00177 typedef struct poptOption * poptOption;
00178 /*@=typeuse@*/
00179 #endif
00180 
00181 enum poptCallbackReason { POPT_CALLBACK_REASON_PRE, 
00182                           POPT_CALLBACK_REASON_POST,
00183                           POPT_CALLBACK_REASON_OPTION };
00184 
00193 typedef void (*poptCallbackType) (poptContext con, 
00194                 enum poptCallbackReason reason,
00195                 /*@null@*/ const struct poptOption * opt,
00196                 /*@null@*/ const char * arg,
00197                 /*@null@*/ const void * data)
00198         /*@*/;
00199 
00209 /*@only@*/ /*@null@*/ poptContext poptGetContext(
00210                 /*@dependent@*/ /*@keep@*/ const char * name,
00211                 int argc, /*@dependent@*/ /*@keep@*/ const char ** argv,
00212                 /*@dependent@*/ /*@keep@*/ const struct poptOption * options,
00213                 int flags)
00214         /*@*/;
00215 
00220 void poptResetContext(/*@null@*/poptContext con)
00221         /*@modifies con @*/;
00222 
00228 int poptGetNextOpt(/*@null@*/poptContext con)
00229         /*@modifies con, fileSystem @*/;
00230 
00231 /*@-redecl@*/
00237 /*@observer@*/ /*@null@*/ const char * poptGetOptArg(/*@null@*/poptContext con)
00238         /*@modifies con @*/;
00239 
00245 /*@observer@*/ /*@null@*/ const char * poptGetArg(/*@null@*/poptContext con)
00246         /*@modifies con @*/;
00247 
00253 /*@observer@*/ /*@null@*/ const char * poptPeekArg(/*@null@*/poptContext con)
00254         /*@*/;
00255 
00261 /*@observer@*/ /*@null@*/ const char ** poptGetArgs(/*@null@*/poptContext con)
00262         /*@modifies con @*/;
00263 
00269 /*@observer@*/ const char * poptBadOption(/*@null@*/poptContext con, int flags)
00270         /*@*/;
00271 /*@=redecl@*/
00272 
00278 /*@null@*/ poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con)
00279         /*@modifies con @*/;
00280 
00287 int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv)
00288         /*@modifies con @*/;
00289 
00299 /*@unused@*/
00300 int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
00301         /*@modifies con @*/;
00302 
00310 int poptAddItem(poptContext con, poptItem newItem, int flags)
00311         /*@modifies con @*/;
00312 
00319 int poptReadConfigFile(poptContext con, const char * fn)
00320         /*@modifies fileSystem,
00321                 con->execs, con->numExecs @*/;
00322 
00329 int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
00330         /*@modifies fileSystem,
00331                 con->execs, con->numExecs @*/;
00332 
00344 int poptDupArgv(int argc, /*@null@*/ const char **argv,
00345                 /*@null@*/ /*@out@*/ int * argcPtr,
00346                 /*@null@*/ /*@out@*/ const char *** argvPtr)
00347         /*@modifies *argcPtr, *argvPtr @*/;
00348 
00360 int poptParseArgvString(const char * s,
00361                 /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr)
00362         /*@modifies *argcPtr, *argvPtr @*/;
00363 
00369 /*@-redecl@*/
00370 /*@observer@*/ const char *const poptStrerror(const int error)
00371         /*@*/;
00372 /*@=redecl@*/
00373 
00380 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
00381         /*@modifies con @*/;
00382 
00389 void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags)
00390         /*@modifies *fp, fileSystem @*/;
00391 
00398 void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
00399         /*@modifies *fp, fileSystem @*/;
00400 
00406 /*@-fcnuse@*/
00407 void poptSetOtherOptionHelp(poptContext con, const char * text)
00408         /*@modifies con @*/;
00409 /*@=fcnuse@*/
00410 
00416 /*@-redecl -fcnuse@*/
00417 /*@observer@*/ const char * poptGetInvocationName(poptContext con)
00418         /*@*/;
00419 /*@=redecl =fcnuse@*/
00420 
00428 /*@-fcnuse@*/
00429 int poptStrippedArgv(poptContext con, int argc, char ** argv)
00430         /*@modifies *argv @*/;
00431 /*@=fcnuse@*/
00432 
00433 #ifdef  __cplusplus
00434 }
00435 #endif
00436 
00437 #endif

Generated on Wed Mar 13 15:34:49 2002 for rpm by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002