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