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
22 if (p
!= NULL
) free((void *)p
);
26 /* Bit mask macros. */
27 typedef unsigned int __pbm_bits
;
28 #define __PBM_NBITS (8 * sizeof (__pbm_bits))
29 #define __PBM_IX(d) ((d) / __PBM_NBITS)
30 #define __PBM_MASK(d) ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS))
34 #define __PBM_BITS(set) ((set)->bits)
36 #define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(pbm_set))
37 #define PBM_FREE(s) _free(s);
38 #define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d))
39 #define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d))
40 #define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0)
42 extern void poptJlu32lpair(const void *key
, size_t size
,
43 uint32_t *pc
, uint32_t *pb
);
46 * Typedef's for string and array of strings.
48 typedef const char * poptString
;
49 typedef poptString
* poptArgv
;
52 * A union to simplify opt->arg access without casting.
54 typedef union poptArg_u
{
59 long long * longlongp
;
67 extern unsigned int _poptArgMask
;
68 extern unsigned int _poptGroupMask
;
70 #define poptArgType(_opt) ((_opt)->argInfo & _poptArgMask)
71 #define poptGroup(_opt) ((_opt)->argInfo & _poptGroupMask)
73 #define F_ISSET(_opt, _FLAG) ((_opt)->argInfo & POPT_ARGFLAG_##_FLAG)
74 #define LF_ISSET(_FLAG) (argInfo & POPT_ARGFLAG_##_FLAG)
75 #define CBF_ISSET(_opt, _FLAG) ((_opt)->argInfo & POPT_CBFLAG_##_FLAG)
77 /* XXX sick hack to preserve pretense of a popt-1.x ABI. */
78 #define poptSubstituteHelpI18N(opt) \
79 { if ((opt) == poptHelpOptions) (opt) = poptHelpOptionsI18N; }
81 struct optionStackEntry
{
87 const char * nextCharArg
;
92 struct poptContext_s
{
93 struct optionStackEntry optionStack
[POPT_OPTION_DEPTH
];
94 struct optionStackEntry
* os
;
99 const struct poptOption
* options
;
101 const char * appName
;
110 int finalArgvAlloced
;
111 int (*maincall
) (int argc
, const char **argv
);
113 const char * execPath
;
115 const char * otherHelp
;
119 #if defined(POPT_fprintf)
120 #define POPT_dgettext dgettext
126 #if defined(HAVE_DCGETTEXT)
127 char *POPT_dgettext(const char * dom
, const char * str
);
131 int POPT_fprintf (FILE* stream
, const char *format
, ...);
132 #endif /* !defined(POPT_fprintf) */
134 const char *POPT_prev_char (const char *str
);
135 const char *POPT_next_char (const char *str
);
139 #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
143 #if defined(ENABLE_NLS) && defined(HAVE_GETTEXT)
144 #define _(foo) gettext(foo)
149 #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H) && defined(HAVE_DCGETTEXT)
150 #define D_(dom, str) POPT_dgettext(dom, str)
151 #define POPT_(foo) D_("popt", foo)
153 #define D_(dom, str) str
154 #define POPT_(foo) foo