popt  1.18
poptint.h
Go to the documentation of this file.
1 
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. */
8 
9 #ifndef H_POPTINT
10 #define H_POPTINT
11 
12 #include <stdint.h>
13 
19 static inline void *
20 _free(const void * p)
21 {
22  if (p != NULL) free((void *)p);
23  return NULL;
24 }
25 
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)
35 
36 #define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))
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)
41 
42 extern void poptJlu32lpair(const void *key, size_t size,
43  uint32_t *pc, uint32_t *pb);
44 
48 typedef const char * poptString;
49 typedef poptString * poptArgv;
50 
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;
65 } poptArg;
66 
67 extern unsigned int _poptArgMask;
68 extern unsigned int _poptGroupMask;
69 
70 #define poptArgType(_opt) ((_opt)->argInfo & _poptArgMask)
71 #define poptGroup(_opt) ((_opt)->argInfo & _poptGroupMask)
72 
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)
76 
77 /* XXX sick hack to preserve pretense of a popt-1.x ABI. */
78 #define poptSubstituteHelpI18N(opt) \
79  { if ((opt) == poptHelpOptions) (opt) = poptHelpOptionsI18N; }
80 
82  int argc;
85  int next;
86  char * nextArg;
87  const char * nextCharArg;
89  int stuffed;
90 };
91 
92 struct poptContext_s {
94  struct optionStackEntry * os;
98  const struct poptOption * options;
100  const char * appName;
103  unsigned int flags;
105  int numExecs;
106  char * execFail;
110  int (*maincall) (int argc, const char **argv);
112  const char * execPath;
114  const char * otherHelp;
116 };
117 
118 #if defined(POPT_fprintf)
119 #define POPT_dgettext dgettext
120 #else
121 #ifdef HAVE_ICONV
122 #include <iconv.h>
123 #endif
124 
125 #if defined(HAVE_DCGETTEXT)
126 char *POPT_dgettext(const char * dom, const char * str);
127 #endif
128 
129 int POPT_fprintf (FILE* stream, const char *format, ...);
130 #endif /* !defined(POPT_fprintf) */
131 
132 const char *POPT_prev_char (const char *str);
133 const char *POPT_next_char (const char *str);
134 
135 #endif
136 
137 #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
138 #include <libintl.h>
139 #endif
140 
141 #if defined(ENABLE_NLS) && defined(HAVE_GETTEXT)
142 #define _(foo) gettext(foo)
143 #else
144 #define _(foo) foo
145 #endif
146 
147 #if defined(ENABLE_NLS) && defined(HAVE_DCGETTEXT)
148 #define D_(dom, str) POPT_dgettext(dom, str)
149 #define POPT_(foo) D_("popt", foo)
150 #else
151 #define D_(dom, str) str
152 #define POPT_(foo) foo
153 #endif
154 
155 #define N_(foo) foo
156 
poptArg_u::intp
int * intp
Definition: poptint.h:56
poptArg_u::shortp
short * shortp
Definition: poptint.h:57
poptArg_u::doublep
double * doublep
Definition: poptint.h:61
POPT_OPTION_DEPTH
#define POPT_OPTION_DEPTH
Definition: popt.h:14
__pbm_bits
unsigned int __pbm_bits
Definition: poptint.h:27
optionStackEntry::nextCharArg
const char * nextCharArg
Definition: poptint.h:87
POPT_prev_char
const char * POPT_prev_char(const char *str)
Definition: poptint.c:15
_free
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
Definition: poptint.h:20
_poptGroupMask
unsigned int _poptGroupMask
Definition: popt.c:35
poptContext_s
Definition: poptint.h:92
poptArg_u::ptr
void * ptr
Definition: poptint.h:55
poptContext_s::nextLeftover
int nextLeftover
Definition: poptint.h:97
optionStackEntry::nextArg
char * nextArg
Definition: poptint.h:86
optionStackEntry::stuffed
int stuffed
Definition: poptint.h:89
poptCallbackType
void(* poptCallbackType)(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data)
Definition: popt.h:211
poptContext_s::flags
unsigned int flags
Definition: poptint.h:103
_poptArgMask
unsigned int _poptArgMask
Definition: popt.c:34
optionStackEntry::argb
pbm_set * argb
Definition: poptint.h:84
poptArg_u::cb
poptCallbackType cb
Definition: poptint.h:63
optionStackEntry::next
int next
Definition: poptint.h:85
poptString
const typedef char * poptString
Definition: poptint.h:48
poptContext_s::aliases
poptItem aliases
Definition: poptint.h:101
poptArg_u::floatp
float * floatp
Definition: poptint.h:60
poptArg_u::argv
const char ** argv
Definition: poptint.h:62
poptArg
union poptArg_u poptArg
poptContext_s::numExecs
int numExecs
Definition: poptint.h:105
poptContext_s::appName
const char * appName
Definition: poptint.h:100
poptContext_s::arg_strip
pbm_set * arg_strip
Definition: poptint.h:115
poptArg_u::opt
poptOption opt
Definition: poptint.h:64
poptContext_s::execFail
char * execFail
Definition: poptint.h:106
optionStackEntry::argc
int argc
Definition: poptint.h:82
poptArg_u::longlongp
long long * longlongp
Definition: poptint.h:59
poptContext_s::maincall
int(* maincall)(int argc, const char **argv)
Definition: poptint.h:110
pbm_set
Definition: poptint.h:31
poptContext_s::finalArgvAlloced
int finalArgvAlloced
Definition: poptint.h:109
poptContext_s::os
struct optionStackEntry * os
Definition: poptint.h:94
optionStackEntry::currAlias
poptItem currAlias
Definition: poptint.h:88
poptContext_s::restLeftover
int restLeftover
Definition: poptint.h:99
poptContext_s::numAliases
int numAliases
Definition: poptint.h:102
poptArg_u
Definition: poptint.h:54
POPT_fprintf
int POPT_fprintf(FILE *stream, const char *format,...)
Definition: poptint.c:138
optionStackEntry::argv
poptArgv argv
Definition: poptint.h:83
poptContext_s::execPath
const char * execPath
Definition: poptint.h:112
poptArgv
poptString * poptArgv
Definition: poptint.h:49
poptJlu32lpair
void poptJlu32lpair(const void *key, size_t size, uint32_t *pc, uint32_t *pb)
poptContext_s::optionStack
struct optionStackEntry optionStack[POPT_OPTION_DEPTH]
Definition: poptint.h:93
poptContext_s::finalArgvCount
int finalArgvCount
Definition: poptint.h:108
poptItem_s
Definition: popt.h:150
poptContext_s::leftovers
poptArgv leftovers
Definition: poptint.h:95
poptContext_s::finalArgv
poptArgv finalArgv
Definition: poptint.h:107
poptContext_s::execs
poptItem execs
Definition: poptint.h:104
poptContext_s::options
const struct poptOption * options
Definition: poptint.h:98
poptContext_s::doExec
poptItem doExec
Definition: poptint.h:111
poptContext_s::otherHelp
const char * otherHelp
Definition: poptint.h:114
poptArg_u::longp
long * longp
Definition: poptint.h:58
poptContext_s::execAbsolute
int execAbsolute
Definition: poptint.h:113
poptOption
Definition: popt.h:127
poptContext_s::numLeftovers
int numLeftovers
Definition: poptint.h:96
POPT_next_char
const char * POPT_next_char(const char *str)
Definition: poptint.c:27
optionStackEntry
Definition: poptint.h:81