popt
1.16
|
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_POPTINT 00010 #define H_POPTINT 00011 00012 #include <stdint.h> 00013 00019 /*@unused@*/ static inline /*@null@*/ void * 00020 _free(/*@only@*/ /*@null@*/ const void * p) 00021 /*@modifies p @*/ 00022 { 00023 if (p != NULL) free((void *)p); 00024 return NULL; 00025 } 00026 00027 /* Bit mask macros. */ 00028 /*@-exporttype -redef @*/ 00029 typedef unsigned int __pbm_bits; 00030 /*@=exporttype =redef @*/ 00031 #define __PBM_NBITS (8 * sizeof (__pbm_bits)) 00032 #define __PBM_IX(d) ((d) / __PBM_NBITS) 00033 #define __PBM_MASK(d) ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS)) 00034 /*@-exporttype -redef @*/ 00035 typedef struct { 00036 __pbm_bits bits[1]; 00037 } pbm_set; 00038 /*@=exporttype =redef @*/ 00039 #define __PBM_BITS(set) ((set)->bits) 00040 00041 #define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits)) 00042 #define PBM_FREE(s) _free(s); 00043 #define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d)) 00044 #define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d)) 00045 #define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0) 00046 00047 extern void poptJlu32lpair(/*@null@*/ const void *key, size_t size, 00048 uint32_t *pc, uint32_t *pb) 00049 /*@modifies *pc, *pb@*/; 00050 00054 /*@-exporttype@*/ 00055 typedef const char * poptString; 00056 typedef poptString * poptArgv; 00057 /*@=exporttype@*/ 00058 00062 /*@-exporttype -fielduse@*/ 00063 typedef union poptArg_u { 00064 /*@shared@*/ 00065 void * ptr; 00066 int * intp; 00067 short * shortp; 00068 long * longp; 00069 long long * longlongp; 00070 float * floatp; 00071 double * doublep; 00072 const char ** argv; 00073 poptCallbackType cb; 00074 /*@shared@*/ 00075 poptOption opt; 00076 } poptArg; 00077 /*@=exporttype =fielduse@*/ 00078 00079 /*@-exportvar@*/ 00080 /*@unchecked@*/ 00081 extern unsigned int _poptArgMask; 00082 /*@unchecked@*/ 00083 extern unsigned int _poptGroupMask; 00084 /*@=exportvar@*/ 00085 00086 #define poptArgType(_opt) ((_opt)->argInfo & _poptArgMask) 00087 #define poptGroup(_opt) ((_opt)->argInfo & _poptGroupMask) 00088 00089 #define F_ISSET(_opt, _FLAG) ((_opt)->argInfo & POPT_ARGFLAG_##_FLAG) 00090 #define LF_ISSET(_FLAG) (argInfo & POPT_ARGFLAG_##_FLAG) 00091 #define CBF_ISSET(_opt, _FLAG) ((_opt)->argInfo & POPT_CBFLAG_##_FLAG) 00092 00093 /* XXX sick hack to preserve pretense of a popt-1.x ABI. */ 00094 #define poptSubstituteHelpI18N(opt) \ 00095 { /*@-observertrans@*/ \ 00096 if ((opt) == poptHelpOptions) (opt) = poptHelpOptionsI18N; \ 00097 /*@=observertrans@*/ } 00098 00099 struct optionStackEntry { 00100 int argc; 00101 /*@only@*/ /*@null@*/ 00102 poptArgv argv; 00103 /*@only@*/ /*@null@*/ 00104 pbm_set * argb; 00105 int next; 00106 /*@only@*/ /*@null@*/ 00107 char * nextArg; 00108 /*@observer@*/ /*@null@*/ 00109 const char * nextCharArg; 00110 /*@dependent@*/ /*@null@*/ 00111 poptItem currAlias; 00112 int stuffed; 00113 }; 00114 00115 struct poptContext_s { 00116 struct optionStackEntry optionStack[POPT_OPTION_DEPTH]; 00117 /*@dependent@*/ 00118 struct optionStackEntry * os; 00119 /*@owned@*/ /*@null@*/ 00120 poptArgv leftovers; 00121 int numLeftovers; 00122 int nextLeftover; 00123 /*@keep@*/ 00124 const struct poptOption * options; 00125 int restLeftover; 00126 /*@only@*/ /*@null@*/ 00127 const char * appName; 00128 /*@only@*/ /*@null@*/ 00129 poptItem aliases; 00130 int numAliases; 00131 unsigned int flags; 00132 /*@owned@*/ /*@null@*/ 00133 poptItem execs; 00134 int numExecs; 00135 /*@only@*/ /*@null@*/ 00136 poptArgv finalArgv; 00137 int finalArgvCount; 00138 int finalArgvAlloced; 00139 /*@null@*/ 00140 int (*maincall) (int argc, const char **argv); 00141 /*@dependent@*/ /*@null@*/ 00142 poptItem doExec; 00143 /*@only@*/ /*@null@*/ 00144 const char * execPath; 00145 int execAbsolute; 00146 /*@only@*/ /*@relnull@*/ 00147 const char * otherHelp; 00148 /*@null@*/ 00149 pbm_set * arg_strip; 00150 }; 00151 00152 #if defined(POPT_fprintf) 00153 #define POPT_dgettext dgettext 00154 #else 00155 #ifdef HAVE_ICONV 00156 #include <iconv.h> 00157 #if defined(__LCLINT__) 00158 /*@-declundef -incondefs @*/ 00159 extern /*@only@*/ iconv_t iconv_open(const char *__tocode, const char *__fromcode) 00160 /*@*/; 00161 00162 extern size_t iconv(iconv_t __cd, /*@null@*/ char ** __inbuf, 00163 /*@null@*/ /*@out@*/ size_t * __inbytesleft, 00164 /*@null@*/ /*@out@*/ char ** __outbuf, 00165 /*@null@*/ /*@out@*/ size_t * __outbytesleft) 00166 /*@modifies __cd, 00167 *__inbuf, *__inbytesleft, *__outbuf, *__outbytesleft @*/; 00168 00169 extern int iconv_close(/*@only@*/ iconv_t __cd) 00170 /*@modifies __cd @*/; 00171 /*@=declundef =incondefs @*/ 00172 #endif 00173 #endif 00174 00175 #ifdef HAVE_LANGINFO_H 00176 #include <langinfo.h> 00177 #if defined(__LCLINT__) 00178 /*@-declundef -incondefs @*/ 00179 extern char *nl_langinfo (nl_item __item) 00180 /*@*/; 00181 /*@=declundef =incondefs @*/ 00182 #endif 00183 #endif 00184 00185 #if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__) 00186 char *POPT_dgettext(const char * dom, const char * str) 00187 /*@*/; 00188 #endif 00189 00190 int POPT_fprintf (FILE* stream, const char *format, ...) 00191 /*@globals fileSystem @*/ 00192 /*@modifies stream, fileSystem @*/; 00193 #endif /* !defined(POPT_fprintf) */ 00194 00195 const char *POPT_prev_char (/*@returned@*/ const char *str) 00196 /*@*/; 00197 00198 const char *POPT_next_char (/*@returned@*/ const char *str) 00199 /*@*/; 00200 00201 #endif 00202 00203 #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H) 00204 #include <libintl.h> 00205 #endif 00206 00207 #if defined(ENABLE_NLS) && defined(HAVE_GETTEXT) && !defined(__LCLINT__) 00208 #define _(foo) gettext(foo) 00209 #else 00210 #define _(foo) foo 00211 #endif 00212 00213 #if defined(ENABLE_NLS) && defined(HAVE_DCGETTEXT) && !defined(__LCLINT__) 00214 #define D_(dom, str) POPT_dgettext(dom, str) 00215 #define POPT_(foo) D_("popt", foo) 00216 #else 00217 #define D_(dom, str) str 00218 #define POPT_(foo) foo 00219 #endif 00220 00221 #define N_(foo) foo 00222