Go to the documentation of this file.00001
00005
00006
00007
00008
00009 #ifndef H_POPTINT
00010 #define H_POPTINT
00011
00012 #include <stdint.h>
00013
00019 static inline void *
00020 _free( const void * p)
00021
00022 {
00023 if (p != NULL) free((void *)p);
00024 return NULL;
00025 }
00026
00027
00028
00029 typedef unsigned int __pbm_bits;
00030
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
00035 typedef struct {
00036 __pbm_bits bits[1];
00037 } pbm_set;
00038
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( const void *key, size_t size,
00048 uint32_t *pc, uint32_t *pb)
00049 ;
00050
00054
00055 typedef const char * poptString;
00056 typedef poptString * poptArgv;
00057
00058
00062
00063 typedef union poptArg_u {
00064
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
00075 poptOption opt;
00076 } poptArg;
00077
00078
00079
00080
00081 extern unsigned int _poptArgMask;
00082
00083 extern unsigned int _poptGroupMask;
00084
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
00094 #define poptSubstituteHelpI18N(opt) \
00095 { \
00096 if ((opt) == poptHelpOptions) (opt) = poptHelpOptionsI18N; \
00097 }
00098
00099 struct optionStackEntry {
00100 int argc;
00101
00102 poptArgv argv;
00103
00104 pbm_set * argb;
00105 int next;
00106
00107 char * nextArg;
00108
00109 const char * nextCharArg;
00110
00111 poptItem currAlias;
00112 int stuffed;
00113 };
00114
00115 struct poptContext_s {
00116 struct optionStackEntry optionStack[POPT_OPTION_DEPTH];
00117
00118 struct optionStackEntry * os;
00119
00120 poptArgv leftovers;
00121 int numLeftovers;
00122 int nextLeftover;
00123
00124 const struct poptOption * options;
00125 int restLeftover;
00126
00127 const char * appName;
00128
00129 poptItem aliases;
00130 int numAliases;
00131 unsigned int flags;
00132
00133 poptItem execs;
00134 int numExecs;
00135
00136 poptArgv finalArgv;
00137 int finalArgvCount;
00138 int finalArgvAlloced;
00139
00140 int (*maincall) (int argc, const char **argv);
00141
00142 poptItem doExec;
00143
00144 const char * execPath;
00145 int execAbsolute;
00146
00147 const char * otherHelp;
00148
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
00159 extern iconv_t iconv_open(const char *__tocode, const char *__fromcode)
00160 ;
00161
00162 extern size_t iconv(iconv_t __cd, char ** __inbuf,
00163 size_t * __inbytesleft,
00164 char ** __outbuf,
00165 size_t * __outbytesleft)
00166
00167 ;
00168
00169 extern int iconv_close( iconv_t __cd)
00170 ;
00171
00172 #endif
00173 #endif
00174
00175 #ifdef HAVE_LANGINFO_H
00176 #include <langinfo.h>
00177 #if defined(__LCLINT__)
00178
00179 extern char *nl_langinfo (nl_item __item)
00180 ;
00181
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
00192 ;
00193 #endif
00194
00195 const char *POPT_prev_char ( const char *str)
00196 ;
00197
00198 const char *POPT_next_char ( 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