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