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;
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 
void(* poptCallbackType)(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data)
Table callback prototype.
Definition: popt.h:211
#define POPT_OPTION_DEPTH
Definition: popt.h:14
const char * POPT_prev_char(const char *str)
Definition: poptint.c:15
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
Definition: poptint.h:20
const char * POPT_next_char(const char *str)
Definition: poptint.c:27
union poptArg_u poptArg
A union to simplify opt->arg access without casting.
unsigned int _poptGroupMask
Definition: popt.c:35
unsigned int __pbm_bits
Definition: poptint.h:27
poptString * poptArgv
Definition: poptint.h:49
unsigned int _poptArgMask
Definition: popt.c:34
int POPT_fprintf(FILE *stream, const char *format,...)
Definition: poptint.c:138
const char * poptString
Typedef's for string and array of strings.
Definition: poptint.h:48
void poptJlu32lpair(const void *key, size_t size, uint32_t *pc, uint32_t *pb)
char * nextArg
Definition: poptint.h:86
poptItem currAlias
Definition: poptint.h:88
const char * nextCharArg
Definition: poptint.h:87
poptArgv argv
Definition: poptint.h:83
pbm_set * argb
Definition: poptint.h:84
poptItem aliases
Definition: poptint.h:101
int finalArgvCount
Definition: poptint.h:108
unsigned int flags
Definition: poptint.h:103
poptItem execs
Definition: poptint.h:104
int execAbsolute
Definition: poptint.h:113
int nextLeftover
Definition: poptint.h:97
int finalArgvAlloced
Definition: poptint.h:109
const char * execPath
Definition: poptint.h:112
const struct poptOption * options
Definition: poptint.h:98
int numExecs
Definition: poptint.h:105
struct optionStackEntry * os
Definition: poptint.h:94
pbm_set * arg_strip
Definition: poptint.h:115
const char * otherHelp
Definition: poptint.h:114
poptItem doExec
Definition: poptint.h:111
poptArgv finalArgv
Definition: poptint.h:107
int numLeftovers
Definition: poptint.h:96
const char * appName
Definition: poptint.h:100
poptArgv leftovers
Definition: poptint.h:95
int restLeftover
Definition: poptint.h:99
char * execFail
Definition: poptint.h:106
int(* maincall)(int argc, const char **argv)
Definition: poptint.h:110
int numAliases
Definition: poptint.h:102
struct optionStackEntry optionStack[POPT_OPTION_DEPTH]
Definition: poptint.h:93
A popt alias or exec argument for poptAddItem().
Definition: popt.h:150
A union to simplify opt->arg access without casting.
Definition: poptint.h:54
const char ** argv
Definition: poptint.h:62
long * longp
Definition: poptint.h:58
long long * longlongp
Definition: poptint.h:59
short * shortp
Definition: poptint.h:57
int * intp
Definition: poptint.h:56
poptCallbackType cb
Definition: poptint.h:63
void * ptr
Definition: poptint.h:55
poptOption opt
Definition: poptint.h:64
float * floatp
Definition: poptint.h:60
double * doublep
Definition: poptint.h:61