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 #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@*/ const char * longName; 
00116     char shortName;                     
00117     int argInfo;
00118 /*@shared@*/ /*@null@*/ void * arg;     
00119     int val;                    
00120 /*@observer@*/ /*@null@*/ const char * descrip; 
00121 /*@observer@*/ /*@null@*/ const char * argDescrip; 
00122 };
00123 
00127 struct poptAlias {
00128 /*@owned@*/ /*@null@*/ const char * longName;   
00129     char shortName;             
00130     int argc;
00131 /*@owned@*/ const char ** argv; 
00132 };
00133 
00137 /*@-exporttype@*/
00138 typedef struct poptItem_s {
00139     struct poptOption option;   
00140     int argc;                   
00141 /*@owned@*/ const char ** argv; 
00142 } * poptItem;
00143 /*@=exporttype@*/
00144 
00149 
00153 /*@-exportvar@*/
00154 /*@unchecked@*/ /*@observer@*/
00155 extern struct poptOption poptAliasOptions[];
00156 /*@=exportvar@*/
00157 #define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
00158                         0, "Options implemented via popt alias/exec:", NULL },
00159 
00163 /*@-exportvar@*/
00164 /*@unchecked@*/ /*@observer@*/
00165 extern struct poptOption poptHelpOptions[];
00166 /*@=exportvar@*/
00167 #define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
00168                         0, "Help options:", NULL },
00169 
00170 #define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL }
00171 
00175 /*@-exporttype@*/
00176 typedef /*@abstract@*/ struct poptContext_s * poptContext;
00177 /*@=exporttype@*/
00178 
00181 #ifndef __cplusplus
00182 /*@-exporttype -typeuse@*/
00183 typedef struct poptOption * poptOption;
00184 /*@=exporttype =typeuse@*/
00185 #endif
00186 
00187 /*@-exportconst@*/
00188 enum poptCallbackReason {
00189     POPT_CALLBACK_REASON_PRE    = 0, 
00190     POPT_CALLBACK_REASON_POST   = 1,
00191     POPT_CALLBACK_REASON_OPTION = 2
00192 };
00193 /*@=exportconst@*/
00194 
00195 #ifdef __cplusplus
00196 extern "C" {
00197 #endif
00198 /*@-type@*/
00199 
00208 typedef void (*poptCallbackType) (poptContext con, 
00209                 enum poptCallbackReason reason,
00210                 /*@null@*/ const struct poptOption * opt,
00211                 /*@null@*/ const char * arg,
00212                 /*@null@*/ const void * data)
00213         /*@*/;
00214 
00224 /*@only@*/ /*@null@*/ poptContext poptGetContext(
00225                 /*@dependent@*/ /*@keep@*/ const char * name,
00226                 int argc, /*@dependent@*/ /*@keep@*/ const char ** argv,
00227                 /*@dependent@*/ /*@keep@*/ const struct poptOption * options,
00228                 int flags)
00229         /*@*/;
00230 
00235 /*@-exportlocal@*/
00236 void poptResetContext(/*@null@*/poptContext con)
00237         /*@modifies con @*/;
00238 /*@=exportlocal@*/
00239 
00245 int poptGetNextOpt(/*@null@*/poptContext con)
00246         /*@globals fileSystem, internalState @*/
00247         /*@modifies con, fileSystem, internalState @*/;
00248 
00249 /*@-redecl@*/
00255 /*@observer@*/ /*@null@*/ const char * poptGetOptArg(/*@null@*/poptContext con)
00256         /*@modifies con @*/;
00257 
00263 /*@observer@*/ /*@null@*/ const char * poptGetArg(/*@null@*/poptContext con)
00264         /*@modifies con @*/;
00265 
00271 /*@observer@*/ /*@null@*/ const char * poptPeekArg(/*@null@*/poptContext con)
00272         /*@*/;
00273 
00279 /*@observer@*/ /*@null@*/ const char ** poptGetArgs(/*@null@*/poptContext con)
00280         /*@modifies con @*/;
00281 
00288 /*@observer@*/ const char * poptBadOption(/*@null@*/poptContext con, int flags)
00289         /*@*/;
00290 /*@=redecl@*/
00291 
00297 /*@null@*/ poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con)
00298         /*@modifies con @*/;
00299 
00306 int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv)
00307         /*@modifies con @*/;
00308 
00318 /*@unused@*/
00319 int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
00320         /*@modifies con @*/;
00321 
00329 int poptAddItem(poptContext con, poptItem newItem, int flags)
00330         /*@modifies con @*/;
00331 
00338 int poptReadConfigFile(poptContext con, const char * fn)
00339         /*@globals fileSystem, internalState @*/
00340         /*@modifies con->execs, con->numExecs,
00341                 fileSystem, internalState @*/;
00342 
00349 int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
00350         /*@globals fileSystem, internalState @*/
00351         /*@modifies con->execs, con->numExecs,
00352                 fileSystem, internalState @*/;
00353 
00365 int poptDupArgv(int argc, /*@null@*/ const char **argv,
00366                 /*@null@*/ /*@out@*/ int * argcPtr,
00367                 /*@null@*/ /*@out@*/ const char *** argvPtr)
00368         /*@modifies *argcPtr, *argvPtr @*/;
00369 
00381 int poptParseArgvString(const char * s,
00382                 /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr)
00383         /*@modifies *argcPtr, *argvPtr @*/;
00384 
00431 /*@-fcnuse@*/
00432 int poptConfigFileToString(FILE *fp, /*@out@*/ char ** argstrp, int flags)
00433         /*@globals fileSystem @*/
00434         /*@modifies *fp, *argstrp, fileSystem @*/;
00435 /*@=fcnuse@*/
00436 
00442 /*@-redecl@*/
00443 /*@observer@*/ const char *const poptStrerror(const int error)
00444         /*@*/;
00445 /*@=redecl@*/
00446 
00453 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
00454         /*@modifies con @*/;
00455 
00462 void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags)
00463         /*@globals fileSystem @*/
00464         /*@modifies *fp, fileSystem @*/;
00465 
00472 void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
00473         /*@globals fileSystem @*/
00474         /*@modifies *fp, fileSystem @*/;
00475 
00481 /*@-fcnuse@*/
00482 void poptSetOtherOptionHelp(poptContext con, const char * text)
00483         /*@modifies con @*/;
00484 /*@=fcnuse@*/
00485 
00491 /*@-redecl -fcnuse@*/
00492 /*@observer@*/ const char * poptGetInvocationName(poptContext con)
00493         /*@*/;
00494 /*@=redecl =fcnuse@*/
00495 
00503 /*@-fcnuse@*/
00504 int poptStrippedArgv(poptContext con, int argc, char ** argv)
00505         /*@modifies *argv @*/;
00506 /*@=fcnuse@*/
00507 
00516 /*@-incondefs@*/
00517 int poptSaveLong(/*@null@*/ long * arg, int argInfo, long aLong)
00518         /*@modifies *arg @*/
00519         /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/;
00520 /*@=incondefs@*/
00521 
00530 /*@-incondefs@*/
00531 int poptSaveInt(/*@null@*/ int * arg, int argInfo, long aLong)
00532         /*@modifies *arg @*/
00533         /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/;
00534 /*@=incondefs@*/
00535 
00536 /*@=type@*/
00537 #ifdef  __cplusplus
00538 }
00539 #endif
00540 
00541 #endif

Generated on Tue Sep 17 15:56:42 2002 for rpm by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002