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 #include <stdio.h>                      /* for FILE * */
00013 
00014 #define POPT_OPTION_DEPTH       10
00015 
00020 #define POPT_ARG_NONE           0       
00021 #define POPT_ARG_STRING         1       
00022 #define POPT_ARG_INT            2       
00023 #define POPT_ARG_LONG           3       
00024 #define POPT_ARG_INCLUDE_TABLE  4       
00025 #define POPT_ARG_CALLBACK       5       
00029 #define POPT_ARG_INTL_DOMAIN    6       
00033 #define POPT_ARG_VAL            7       
00034 #define POPT_ARG_FLOAT          8       
00035 #define POPT_ARG_DOUBLE         9       
00037 #define POPT_ARG_MASK           0x0000FFFF
00038 
00044 #define POPT_ARGFLAG_ONEDASH    0x80000000  
00045 #define POPT_ARGFLAG_DOC_HIDDEN 0x40000000  
00046 #define POPT_ARGFLAG_STRIP      0x20000000  
00047 #define POPT_ARGFLAG_OPTIONAL   0x10000000  
00049 #define POPT_ARGFLAG_OR         0x08000000  
00050 #define POPT_ARGFLAG_NOR        0x09000000  
00051 #define POPT_ARGFLAG_AND        0x04000000  
00052 #define POPT_ARGFLAG_NAND       0x05000000  
00053 #define POPT_ARGFLAG_XOR        0x02000000  
00054 #define POPT_ARGFLAG_NOT        0x01000000  
00055 #define POPT_ARGFLAG_LOGICALOPS \
00056         (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
00057 
00058 #define POPT_BIT_SET    (POPT_ARG_VAL|POPT_ARGFLAG_OR)
00059 
00060 #define POPT_BIT_CLR    (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
00061 
00063 #define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000 
00066 
00067 
00071 #define POPT_CBFLAG_PRE         0x80000000  
00072 #define POPT_CBFLAG_POST        0x40000000  
00073 #define POPT_CBFLAG_INC_DATA    0x20000000  
00075 #define POPT_CBFLAG_SKIPOPTION  0x10000000  
00076 #define POPT_CBFLAG_CONTINUE    0x08000000  
00078 
00079 
00083 #define POPT_ERROR_NOARG        -10     
00084 #define POPT_ERROR_BADOPT       -11     
00085 #define POPT_ERROR_OPTSTOODEEP  -13     
00086 #define POPT_ERROR_BADQUOTE     -15     
00087 #define POPT_ERROR_ERRNO        -16     
00088 #define POPT_ERROR_BADNUMBER    -17     
00089 #define POPT_ERROR_OVERFLOW     -18     
00090 #define POPT_ERROR_BADOPERATION -19     
00091 #define POPT_ERROR_NULLARG      -20     
00092 #define POPT_ERROR_MALLOC       -21     
00094 
00095 
00099 #define POPT_BADOPTION_NOALIAS  (1 << 0)  
00101 
00102 
00106 #define POPT_CONTEXT_NO_EXEC    (1 << 0)  
00107 #define POPT_CONTEXT_KEEP_FIRST (1 << 1)  
00108 #define POPT_CONTEXT_POSIXMEHARDER (1 << 2) 
00109 #define POPT_CONTEXT_ARG_OPTS   (1 << 4) 
00111 
00112 
00114 struct poptOption {
00115 /*@observer@*/ /*@null@*/
00116     const char * longName;      
00117     char shortName;             
00118     int argInfo;
00119 /*@shared@*/ /*@null@*/
00120     void * arg;                 
00121     int val;                    
00122 /*@observer@*/ /*@null@*/
00123     const char * descrip;       
00124 /*@observer@*/ /*@null@*/
00125     const char * argDescrip;    
00126 };
00127 
00131 struct poptAlias {
00132 /*@owned@*/ /*@null@*/
00133     const char * longName;      
00134     char shortName;             
00135     int argc;
00136 /*@owned@*/
00137     const char ** argv;         
00138 };
00139 
00143 /*@-exporttype@*/
00144 typedef struct poptItem_s {
00145     struct poptOption option;   
00146     int argc;                   
00147 /*@owned@*/
00148     const char ** argv;         
00149 } * poptItem;
00150 /*@=exporttype@*/
00151 
00156 
00160 /*@-exportvar@*/
00161 /*@unchecked@*/ /*@observer@*/
00162 extern struct poptOption poptAliasOptions[];
00163 /*@=exportvar@*/
00164 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
00165                         0, "Options implemented via popt alias/exec:", NULL },
00166 
00170 /*@-exportvar@*/
00171 /*@unchecked@*/ /*@observer@*/
00172 extern struct poptOption poptHelpOptions[];
00173 /*@=exportvar@*/
00174 
00175 /*@-exportvar@*/
00176 /*@unchecked@*/ /*@observer@*/
00177 extern struct poptOption * poptHelpOptionsI18N;
00178 /*@=exportvar@*/
00179 
00180 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
00181                         0, "Help options:", NULL },
00182 
00183 #define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL }
00184 
00188 /*@-exporttype@*/
00189 typedef /*@abstract@*/ struct poptContext_s * poptContext;
00190 /*@=exporttype@*/
00191 
00194 #ifndef __cplusplus
00195 /*@-exporttype -typeuse@*/
00196 typedef struct poptOption * poptOption;
00197 /*@=exporttype =typeuse@*/
00198 #endif
00199 
00200 /*@-exportconst@*/
00201 enum poptCallbackReason {
00202     POPT_CALLBACK_REASON_PRE    = 0, 
00203     POPT_CALLBACK_REASON_POST   = 1,
00204     POPT_CALLBACK_REASON_OPTION = 2
00205 };
00206 /*@=exportconst@*/
00207 
00208 #ifdef __cplusplus
00209 extern "C" {
00210 #endif
00211 /*@-type@*/
00212 
00221 typedef void (*poptCallbackType) (poptContext con, 
00222                 enum poptCallbackReason reason,
00223                 /*@null@*/ const struct poptOption * opt,
00224                 /*@null@*/ const char * arg,
00225                 /*@null@*/ const void * data)
00226         /*@globals internalState @*/
00227         /*@modifies internalState @*/;
00228 
00238 /*@only@*/ /*@null@*/
00239 poptContext poptGetContext(
00240                 /*@dependent@*/ /*@keep@*/ const char * name,
00241                 int argc, /*@dependent@*/ /*@keep@*/ const char ** argv,
00242                 /*@dependent@*/ /*@keep@*/ const struct poptOption * options,
00243                 int flags)
00244         /*@*/;
00245 
00250 /*@unused@*/
00251 void poptResetContext(/*@null@*/poptContext con)
00252         /*@modifies con @*/;
00253 
00259 int poptGetNextOpt(/*@null@*/poptContext con)
00260         /*@globals fileSystem, internalState @*/
00261         /*@modifies con, fileSystem, internalState @*/;
00262 
00268 /*@observer@*/ /*@null@*/ /*@unused@*/
00269 const char * poptGetOptArg(/*@null@*/poptContext con)
00270         /*@modifies con @*/;
00271 
00277 /*@observer@*/ /*@null@*/ /*@unused@*/
00278 const char * poptGetArg(/*@null@*/poptContext con)
00279         /*@modifies con @*/;
00280 
00286 /*@observer@*/ /*@null@*/ /*@unused@*/
00287 const char * poptPeekArg(/*@null@*/poptContext con)
00288         /*@*/;
00289 
00295 /*@observer@*/ /*@null@*/
00296 const char ** poptGetArgs(/*@null@*/poptContext con)
00297         /*@modifies con @*/;
00298 
00305 /*@observer@*/
00306 const char * poptBadOption(/*@null@*/poptContext con, int flags)
00307         /*@*/;
00308 
00314 /*@null@*/
00315 poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con)
00316         /*@modifies con @*/;
00317 
00324 /*@unused@*/
00325 int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv)
00326         /*@modifies con @*/;
00327 
00337 /*@unused@*/
00338 int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
00339         /*@modifies con @*/;
00340 
00348 int poptAddItem(poptContext con, poptItem newItem, int flags)
00349         /*@modifies con @*/;
00350 
00357 int poptReadConfigFile(poptContext con, const char * fn)
00358         /*@globals errno, fileSystem, internalState @*/
00359         /*@modifies con->execs, con->numExecs,
00360                 errno, fileSystem, internalState @*/;
00361 
00368 /*@unused@*/
00369 int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
00370         /*@globals fileSystem, internalState @*/
00371         /*@modifies con->execs, con->numExecs,
00372                 fileSystem, internalState @*/;
00373 
00385 int poptDupArgv(int argc, /*@null@*/ const char **argv,
00386                 /*@null@*/ /*@out@*/ int * argcPtr,
00387                 /*@null@*/ /*@out@*/ const char *** argvPtr)
00388         /*@modifies *argcPtr, *argvPtr @*/;
00389 
00401 int poptParseArgvString(const char * s,
00402                 /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr)
00403         /*@modifies *argcPtr, *argvPtr @*/;
00404 
00451 /*@-fcnuse@*/
00452 int poptConfigFileToString(FILE *fp, /*@out@*/ char ** argstrp, int flags)
00453         /*@globals fileSystem @*/
00454         /*@modifies *fp, *argstrp, fileSystem @*/;
00455 /*@=fcnuse@*/
00456 
00462 /*@observer@*/
00463 const char *const poptStrerror(const int error)
00464         /*@*/;
00465 
00472 /*@unused@*/
00473 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
00474         /*@modifies con @*/;
00475 
00482 void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags)
00483         /*@globals fileSystem @*/
00484         /*@modifies *fp, fileSystem @*/;
00485 
00492 void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
00493         /*@globals fileSystem @*/
00494         /*@modifies *fp, fileSystem @*/;
00495 
00501 /*@-fcnuse@*/
00502 void poptSetOtherOptionHelp(poptContext con, const char * text)
00503         /*@modifies con @*/;
00504 /*@=fcnuse@*/
00505 
00511 /*@-fcnuse@*/
00512 /*@observer@*/
00513 const char * poptGetInvocationName(poptContext con)
00514         /*@*/;
00515 /*@=fcnuse@*/
00516 
00524 /*@-fcnuse@*/
00525 int poptStrippedArgv(poptContext con, int argc, char ** argv)
00526         /*@modifies *argv @*/;
00527 /*@=fcnuse@*/
00528 
00537 /*@-incondefs@*/
00538 /*@unused@*/
00539 int poptSaveLong(/*@null@*/ long * arg, int argInfo, long aLong)
00540         /*@modifies *arg @*/
00541         /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/;
00542 /*@=incondefs@*/
00543 
00552 /*@-incondefs@*/
00553 /*@unused@*/
00554 int poptSaveInt(/*@null@*/ int * arg, int argInfo, long aLong)
00555         /*@modifies *arg @*/
00556         /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/;
00557 /*@=incondefs@*/
00558 
00559 /*@=type@*/
00560 #ifdef  __cplusplus
00561 }
00562 #endif
00563 
00564 #endif

Generated on Wed Jan 28 12:45:25 2009 for rpm by  doxygen 1.4.7