5 /* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
6 file accompanying popt source distributions, available from
7 ftp://ftp.rpm.org/pub/rpm/dist. */
15 * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
16 * @param p memory to free
19 /*@unused@*/ static inline /*@null@*/ void *
20 _free(/*@only@*/ /*@null@*/ const void * p
)
23 if (p
!= NULL
) free((void *)p
);
27 /* Bit mask macros. */
28 /*@-exporttype -redef @*/
29 typedef unsigned int __pbm_bits
;
30 /*@=exporttype =redef @*/
31 #define __PBM_NBITS (8 * sizeof (__pbm_bits))
32 #define __PBM_IX(d) ((d) / __PBM_NBITS)
33 #define __PBM_MASK(d) ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS))
34 /*@-exporttype -redef @*/
38 /*@=exporttype =redef @*/
39 #define __PBM_BITS(set) ((set)->bits)
41 #define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))
42 #define PBM_FREE(s) _free(s);
43 #define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d))
44 #define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d))
45 #define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0)
47 extern void poptJlu32lpair(/*@null@*/ const void *key
, size_t size
,
48 uint32_t *pc
, uint32_t *pb
)
49 /*@modifies *pc, *pb@*/;
52 * Typedef's for string and array of strings.
55 typedef const char * poptString
;
56 typedef poptString
* poptArgv
;
60 * A union to simplify opt->arg access without casting.
62 /*@-exporttype -fielduse@*/
63 typedef union poptArg_u
{
69 long long * longlongp
;
77 /*@=exporttype =fielduse@*/
81 extern unsigned int _poptArgMask
;
83 extern unsigned int _poptGroupMask
;
86 #define poptArgType(_opt) ((_opt)->argInfo & _poptArgMask)
87 #define poptGroup(_opt) ((_opt)->argInfo & _poptGroupMask)
89 #define F_ISSET(_opt, _FLAG) ((_opt)->argInfo & POPT_ARGFLAG_##_FLAG)
90 #define LF_ISSET(_FLAG) (argInfo & POPT_ARGFLAG_##_FLAG)
91 #define CBF_ISSET(_opt, _FLAG) ((_opt)->argInfo & POPT_CBFLAG_##_FLAG)
93 /* XXX sick hack to preserve pretense of a popt-1.x ABI. */
94 #define poptSubstituteHelpI18N(opt) \
95 { /*@-observertrans@*/ \
96 if ((opt) == poptHelpOptions) (opt) = poptHelpOptionsI18N; \
97 /*@=observertrans@*/ }
99 struct optionStackEntry
{
101 /*@only@*/ /*@null@*/
103 /*@only@*/ /*@null@*/
106 /*@only@*/ /*@null@*/
108 /*@observer@*/ /*@null@*/
109 const char * nextCharArg
;
110 /*@dependent@*/ /*@null@*/
115 struct poptContext_s
{
116 struct optionStackEntry optionStack
[POPT_OPTION_DEPTH
];
118 struct optionStackEntry
* os
;
119 /*@owned@*/ /*@null@*/
124 const struct poptOption
* options
;
126 /*@only@*/ /*@null@*/
127 const char * appName
;
128 /*@only@*/ /*@null@*/
132 /*@owned@*/ /*@null@*/
135 /*@only@*/ /*@null@*/
138 int finalArgvAlloced
;
140 int (*maincall
) (int argc
, const char **argv
);
141 /*@dependent@*/ /*@null@*/
143 /*@only@*/ /*@null@*/
144 const char * execPath
;
146 /*@only@*/ /*@relnull@*/
147 const char * otherHelp
;
152 #if defined(POPT_fprintf)
153 #define POPT_dgettext dgettext
157 #if defined(__LCLINT__)
158 /*@-declundef -incondefs @*/
159 extern /*@only@*/ iconv_t
iconv_open(const char *__tocode
, const char *__fromcode
)
162 extern size_t iconv(iconv_t __cd
, /*@null@*/ char ** __inbuf
,
163 /*@null@*/ /*@out@*/ size_t * __inbytesleft
,
164 /*@null@*/ /*@out@*/ char ** __outbuf
,
165 /*@null@*/ /*@out@*/ size_t * __outbytesleft
)
167 *__inbuf, *__inbytesleft, *__outbuf, *__outbytesleft @*/;
169 extern int iconv_close(/*@only@*/ iconv_t __cd
)
170 /*@modifies __cd @*/;
171 /*@=declundef =incondefs @*/
175 #ifdef HAVE_LANGINFO_H
176 #include <langinfo.h>
177 #if defined(__LCLINT__)
178 /*@-declundef -incondefs @*/
179 extern char *nl_langinfo (nl_item __item
)
181 /*@=declundef =incondefs @*/
185 #if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__)
186 char *POPT_dgettext(const char * dom
, const char * str
)
190 int POPT_fprintf (FILE* stream
, const char *format
, ...)
191 /*@globals fileSystem @*/
192 /*@modifies stream, fileSystem @*/;
193 #endif /* !defined(POPT_fprintf) */
195 const char *POPT_prev_char (/*@returned@*/ const char *str
)
198 const char *POPT_next_char (/*@returned@*/ const char *str
)
203 #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
207 #if defined(ENABLE_NLS) && defined(HAVE_GETTEXT) && !defined(__LCLINT__)
208 #define _(foo) gettext(foo)
213 #if defined(ENABLE_NLS) && defined(HAVE_DCGETTEXT) && !defined(__LCLINT__)
214 #define D_(dom, str) POPT_dgettext(dom, str)
215 #define POPT_(foo) D_("popt", foo)
217 #define D_(dom, str) str
218 #define POPT_(foo) foo