Allow basic connectivity check via rrsync
[rsync.git] / popt / poptint.h
blob001c5c35d66a7aefc486ed11bb28bbf12fd1aecb
1 /** \ingroup popt
2 * @file
3 */
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. */
9 #ifndef H_POPTINT
10 #define H_POPTINT
12 #include <stdint.h>
14 /**
15 * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
16 * @param p memory to free
17 * @retval NULL always
19 static inline void *
20 _free(const void * p)
22 if (p != NULL) free((void *)p);
23 return NULL;
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))
31 typedef struct {
32 __pbm_bits bits[1];
33 } pbm_set;
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);
45 /** \ingroup popt
46 * Typedef's for string and array of strings.
48 typedef const char * poptString;
49 typedef poptString * poptArgv;
51 /** \ingroup popt
52 * A union to simplify opt->arg access without casting.
54 typedef union poptArg_u {
55 void * ptr;
56 int * intp;
57 short * shortp;
58 long * longp;
59 long long * longlongp;
60 float * floatp;
61 double * doublep;
62 const char ** argv;
63 poptCallbackType cb;
64 poptOption opt;
65 } poptArg;
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 {
82 int argc;
83 poptArgv argv;
84 pbm_set * argb;
85 int next;
86 char * nextArg;
87 const char * nextCharArg;
88 poptItem currAlias;
89 int stuffed;
92 struct poptContext_s {
93 struct optionStackEntry optionStack[POPT_OPTION_DEPTH];
94 struct optionStackEntry * os;
95 poptArgv leftovers;
96 int numLeftovers;
97 int allocLeftovers;
98 int nextLeftover;
99 const struct poptOption * options;
100 int restLeftover;
101 const char * appName;
102 poptItem aliases;
103 int numAliases;
104 unsigned int flags;
105 poptItem execs;
106 int numExecs;
107 char * execFail;
108 poptArgv finalArgv;
109 int finalArgvCount;
110 int finalArgvAlloced;
111 int (*maincall) (int argc, const char **argv);
112 poptItem doExec;
113 const char * execPath;
114 int execAbsolute;
115 const char * otherHelp;
116 pbm_set * arg_strip;
119 #if defined(POPT_fprintf)
120 #define POPT_dgettext dgettext
121 #else
122 #ifdef HAVE_ICONV
123 #include <iconv.h>
124 #endif
126 #if defined(HAVE_DCGETTEXT)
127 char *POPT_dgettext(const char * dom, const char * str);
128 #endif
130 FORMAT(printf, 2, 3)
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);
137 #endif
139 #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
140 #include <libintl.h>
141 #endif
143 #if defined(ENABLE_NLS) && defined(HAVE_GETTEXT)
144 #define _(foo) gettext(foo)
145 #else
146 #define _(foo) foo
147 #endif
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)
152 #else
153 #define D_(dom, str) str
154 #define POPT_(foo) foo
155 #endif
157 #define N_(foo) foo