diff options
Diffstat (limited to 'poptint.h')
-rw-r--r--[-rwxr-xr-x] | poptint.h | 130 |
1 files changed, 118 insertions, 12 deletions
diff --git a/poptint.h b/poptint.h index 5d308ef..80cbaca 100755..100644 --- a/poptint.h +++ b/poptint.h @@ -9,6 +9,8 @@ #ifndef H_POPTINT #define H_POPTINT +#include <stdint.h> + /** * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. * @param p memory to free @@ -42,15 +44,67 @@ typedef struct { #define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d)) #define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0) +extern void poptJlu32lpair(/*@null@*/ const void *key, size_t size, + uint32_t *pc, uint32_t *pb) + /*@modifies *pc, *pb@*/; + +/** \ingroup popt + * Typedef's for string and array of strings. + */ +/*@-exporttype@*/ +typedef const char * poptString; +typedef poptString * poptArgv; +/*@=exporttype@*/ + +/** \ingroup popt + * A union to simplify opt->arg access without casting. + */ +/*@-exporttype -fielduse@*/ +typedef union poptArg_u { +/*@shared@*/ + void * ptr; + int * intp; + short * shortp; + long * longp; + long long * longlongp; + float * floatp; + double * doublep; + const char ** argv; + poptCallbackType cb; +/*@shared@*/ + poptOption opt; +} poptArg; +/*@=exporttype =fielduse@*/ + +/*@-exportvar@*/ +/*@unchecked@*/ +extern unsigned int _poptArgMask; +/*@unchecked@*/ +extern unsigned int _poptGroupMask; +/*@=exportvar@*/ + +#define poptArgType(_opt) ((_opt)->argInfo & _poptArgMask) +#define poptGroup(_opt) ((_opt)->argInfo & _poptGroupMask) + +#define F_ISSET(_opt, _FLAG) ((_opt)->argInfo & POPT_ARGFLAG_##_FLAG) +#define LF_ISSET(_FLAG) (argInfo & POPT_ARGFLAG_##_FLAG) +#define CBF_ISSET(_opt, _FLAG) ((_opt)->argInfo & POPT_CBFLAG_##_FLAG) + +/* XXX sick hack to preserve pretense of a popt-1.x ABI. */ +#define poptSubstituteHelpI18N(opt) \ + { /*@-observertrans@*/ \ + if ((opt) == poptHelpOptions) (opt) = poptHelpOptionsI18N; \ + /*@=observertrans@*/ } + struct optionStackEntry { int argc; /*@only@*/ /*@null@*/ - const char ** argv; + poptArgv argv; /*@only@*/ /*@null@*/ pbm_set * argb; int next; /*@only@*/ /*@null@*/ - const char * nextArg; + char * nextArg; /*@observer@*/ /*@null@*/ const char * nextCharArg; /*@dependent@*/ /*@null@*/ @@ -63,7 +117,7 @@ struct poptContext_s { /*@dependent@*/ struct optionStackEntry * os; /*@owned@*/ /*@null@*/ - const char ** leftovers; + poptArgv leftovers; int numLeftovers; int nextLeftover; /*@keep@*/ @@ -74,37 +128,90 @@ struct poptContext_s { /*@only@*/ /*@null@*/ poptItem aliases; int numAliases; - int flags; + unsigned int flags; /*@owned@*/ /*@null@*/ poptItem execs; int numExecs; /*@only@*/ /*@null@*/ - const char ** finalArgv; + poptArgv finalArgv; int finalArgvCount; int finalArgvAlloced; +/*@null@*/ + int (*maincall) (int argc, const char **argv); /*@dependent@*/ /*@null@*/ poptItem doExec; -/*@only@*/ +/*@only@*/ /*@null@*/ const char * execPath; int execAbsolute; -/*@only@*/ +/*@only@*/ /*@relnull@*/ const char * otherHelp; /*@null@*/ pbm_set * arg_strip; }; -#ifdef HAVE_LIBINTL_H +#if defined(POPT_fprintf) +#define POPT_dgettext dgettext +#else +#ifdef HAVE_ICONV +#include <iconv.h> +#if defined(__LCLINT__) +/*@-declundef -incondefs @*/ +extern /*@only@*/ iconv_t iconv_open(const char *__tocode, const char *__fromcode) + /*@*/; + +extern size_t iconv(iconv_t __cd, /*@null@*/ char ** __inbuf, + /*@null@*/ /*@out@*/ size_t * __inbytesleft, + /*@null@*/ /*@out@*/ char ** __outbuf, + /*@null@*/ /*@out@*/ size_t * __outbytesleft) + /*@modifies __cd, + *__inbuf, *__inbytesleft, *__outbuf, *__outbytesleft @*/; + +extern int iconv_close(/*@only@*/ iconv_t __cd) + /*@modifies __cd @*/; +/*@=declundef =incondefs @*/ +#endif +#endif + +#ifdef HAVE_LANGINFO_H +#include <langinfo.h> +#if defined(__LCLINT__) +/*@-declundef -incondefs @*/ +extern char *nl_langinfo (nl_item __item) + /*@*/; +/*@=declundef =incondefs @*/ +#endif +#endif + +#if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__) +char *POPT_dgettext(const char * dom, const char * str) + /*@*/; +#endif + +int POPT_fprintf (FILE* stream, const char *format, ...) + /*@globals fileSystem @*/ + /*@modifies stream, fileSystem @*/; +#endif /* !defined(POPT_fprintf) */ + +const char *POPT_prev_char (/*@returned@*/ const char *str) + /*@*/; + +const char *POPT_next_char (/*@returned@*/ const char *str) + /*@*/; + +#endif + +#if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H) #include <libintl.h> #endif -#if defined(HAVE_GETTEXT) && !defined(__LCLINT__) +#if defined(ENABLE_NLS) && defined(HAVE_GETTEXT) && !defined(__LCLINT__) #define _(foo) gettext(foo) #else #define _(foo) foo #endif -#if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__) -#define D_(dom, str) dgettext(dom, str) +#if defined(ENABLE_NLS) && defined(HAVE_DCGETTEXT) && !defined(__LCLINT__) +#define D_(dom, str) POPT_dgettext(dom, str) #define POPT_(foo) D_("popt", foo) #else #define D_(dom, str) str @@ -113,4 +220,3 @@ struct poptContext_s { #define N_(foo) foo -#endif |