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 #define poptArgType(_opt) ((_opt)->argInfo & POPT_ARG_MASK)
00073 #define F_ISSET(_opt, _FLAG) ((_opt)->argInfo & POPT_ARGFLAG_##_FLAG)
00074 #define LF_ISSET(_FLAG) (argInfo & POPT_ARGFLAG_##_FLAG)
00075 #define CBF_ISSET(_opt, _FLAG) ((_opt)->argInfo & POPT_CBFLAG_##_FLAG)
00076
00077
00078 #define poptSubstituteHelpI18N(opt) \
00079 { \
00080 if ((opt) == poptHelpOptions) (opt) = poptHelpOptionsI18N; \
00081 }
00082
00083 struct optionStackEntry {
00084 int argc;
00085
00086 poptArgv argv;
00087
00088 pbm_set * argb;
00089 int next;
00090
00091 char * nextArg;
00092
00093 const char * nextCharArg;
00094
00095 poptItem currAlias;
00096 int stuffed;
00097 };
00098
00099 struct poptContext_s {
00100 struct optionStackEntry optionStack[POPT_OPTION_DEPTH];
00101
00102 struct optionStackEntry * os;
00103
00104 poptArgv leftovers;
00105 int numLeftovers;
00106 int nextLeftover;
00107
00108 const struct poptOption * options;
00109 int restLeftover;
00110
00111 const char * appName;
00112
00113 poptItem aliases;
00114 int numAliases;
00115 unsigned int flags;
00116
00117 poptItem execs;
00118 int numExecs;
00119
00120 poptArgv finalArgv;
00121 int finalArgvCount;
00122 int finalArgvAlloced;
00123
00124 int (*maincall) (int argc, const char **argv);
00125
00126 poptItem doExec;
00127
00128 const char * execPath;
00129 int execAbsolute;
00130
00131 const char * otherHelp;
00132
00133 pbm_set * arg_strip;
00134 };
00135
00136 #if defined(POPT_fprintf)
00137 #define POPT_dgettext dgettext
00138 #else
00139 #ifdef HAVE_ICONV
00140 #include <iconv.h>
00141 #if defined(__LCLINT__)
00142
00143 extern iconv_t iconv_open(const char *__tocode, const char *__fromcode)
00144 ;
00145
00146 extern size_t iconv(iconv_t __cd, char ** __inbuf,
00147 size_t * __inbytesleft,
00148 char ** __outbuf,
00149 size_t * __outbytesleft)
00150
00151 ;
00152
00153 extern int iconv_close( iconv_t __cd)
00154 ;
00155
00156 #endif
00157 #endif
00158
00159 #ifdef HAVE_LANGINFO_H
00160 #include <langinfo.h>
00161 #if defined(__LCLINT__)
00162
00163 extern char *nl_langinfo (nl_item __item)
00164 ;
00165
00166 #endif
00167 #endif
00168
00169 #if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__)
00170 char *POPT_dgettext(const char * dom, const char * str)
00171 ;
00172 #endif
00173
00174 int POPT_fprintf (FILE* stream, const char *format, ...)
00175
00176 ;
00177 #endif
00178
00179 const char *POPT_prev_char ( const char *str)
00180 ;
00181
00182 const char *POPT_next_char ( const char *str)
00183 ;
00184
00185 #endif
00186
00187 #ifdef HAVE_LIBINTL_H
00188 #include <libintl.h>
00189 #endif
00190
00191 #if defined(HAVE_GETTEXT) && !defined(__LCLINT__)
00192 #define _(foo) gettext(foo)
00193 #else
00194 #define _(foo) foo
00195 #endif
00196
00197 #if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__)
00198 #define D_(dom, str) POPT_dgettext(dom, str)
00199 #define POPT_(foo) D_("popt", foo)
00200 #else
00201 #define D_(dom, str) str
00202 #define POPT_(foo) foo
00203 #endif
00204
00205 #define N_(foo) foo
00206