16#if defined(__cplusplus)
56#define ISL_ARG_OFFSET_NONE ((size_t) -1)
59#define ISL_ARG_SINGLE_DASH (1 << 0)
60#define ISL_ARG_BOOL_ARG (1 << 1)
61#define ISL_ARG_HIDDEN (1 << 2)
72 unsigned default_value;
75 unsigned default_value;
76 int (*
set)(
void *opt,
unsigned val);
84 int (*
set)(
void *opt,
long val);
113#define ISL_ARGS_START(s,name) \
114 struct isl_arg name ## LIST[]; \
115 struct isl_args name = { sizeof(s), name ## LIST }; \
116 struct isl_arg name ## LIST[] = {
117#define ISL_ARGS_END \
120#define ISL_ARG_ALIAS(l) { \
121 .type = isl_arg_alias, \
124#define ISL_ARG_ARG(st,f,a,d) { \
125 .type = isl_arg_arg, \
126 .argument_name = a, \
127 .offset = offsetof(st, f), \
128 .u = { .str = { .default_value = d } } \
130#define ISL_ARG_FOOTER(h) { \
131 .type = isl_arg_footer, \
134#define ISL_ARG_CHOICE(st,f,s,l,c,d,h) { \
135 .type = isl_arg_choice, \
138 .offset = offsetof(st, f), \
140 .u = { .choice = { .choice = c, .default_value = d, \
141 .default_selected = d, .set = NULL } } \
143#define ISL_ARG_OPT_CHOICE(st,f,s,l,c,d,ds,h) { \
144 .type = isl_arg_choice, \
147 .offset = offsetof(st, f), \
149 .u = { .choice = { .choice = c, .default_value = d, \
150 .default_selected = ds, .set = NULL } } \
152#define ISL_ARG_PHANTOM_USER_CHOICE_F(s,l,c,setter,d,h,fl) { \
153 .type = isl_arg_choice, \
156 .offset = ISL_ARG_OFFSET_NONE, \
159 .u = { .choice = { .choice = c, .default_value = d, \
160 .default_selected = d, .set = setter } } \
162#define ISL_ARG_USER_OPT_CHOICE(st,f,s,l,c,setter,d,ds,h) { \
163 .type = isl_arg_choice, \
166 .offset = offsetof(st, f), \
168 .u = { .choice = { .choice = c, .default_value = d, \
169 .default_selected = ds, .set = setter } } \
171#define _ISL_ARG_BOOL_F(o,s,l,setter,d,h,fl) { \
172 .type = isl_arg_bool, \
178 .u = { .b = { .default_value = d, .set = setter } } \
180#define ISL_ARG_BOOL_F(st,f,s,l,d,h,fl) \
181 _ISL_ARG_BOOL_F(offsetof(st, f),s,l,NULL,d,h,fl)
182#define ISL_ARG_BOOL(st,f,s,l,d,h) \
183 ISL_ARG_BOOL_F(st,f,s,l,d,h,0)
184#define ISL_ARG_PHANTOM_BOOL_F(s,l,setter,h,fl) \
185 _ISL_ARG_BOOL_F(ISL_ARG_OFFSET_NONE,s,l,setter,0,h,fl)
186#define ISL_ARG_PHANTOM_BOOL(s,l,setter,h) \
187 ISL_ARG_PHANTOM_BOOL_F(s,l,setter,h,0)
188#define ISL_ARG_INT_F(st,f,s,l,a,d,h,fl) { \
189 .type = isl_arg_int, \
192 .argument_name = a, \
193 .offset = offsetof(st, f), \
196 .u = { .i = { .default_value = d } } \
198#define ISL_ARG_INT(st,f,s,l,a,d,h) \
199 ISL_ARG_INT_F(st,f,s,l,a,d,h,0)
200#define ISL_ARG_LONG(st,f,s,lo,d,h) { \
201 .type = isl_arg_long, \
204 .offset = offsetof(st, f), \
206 .u = { .l = { .default_value = d, .default_selected = d, \
209#define ISL_ARG_USER_LONG(st,f,s,lo,setter,d,h) { \
210 .type = isl_arg_long, \
213 .offset = offsetof(st, f), \
215 .u = { .l = { .default_value = d, .default_selected = d, \
218#define ISL_ARG_OPT_LONG(st,f,s,lo,d,ds,h) { \
219 .type = isl_arg_long, \
222 .offset = offsetof(st, f), \
224 .u = { .l = { .default_value = d, .default_selected = ds, \
227#define ISL_ARG_ULONG(st,f,s,l,d,h) { \
228 .type = isl_arg_ulong, \
231 .offset = offsetof(st, f), \
233 .u = { .ul = { .default_value = d } } \
235#define ISL_ARG_STR_F(st,f,s,l,a,d,h,fl) { \
236 .type = isl_arg_str, \
239 .argument_name = a, \
240 .offset = offsetof(st, f), \
243 .u = { .str = { .default_value = d } } \
245#define ISL_ARG_STR(st,f,s,l,a,d,h) \
246 ISL_ARG_STR_F(st,f,s,l,a,d,h,0)
247#define ISL_ARG_STR_LIST(st,f_n,f_l,s,l,a,h) { \
248 .type = isl_arg_str_list, \
251 .argument_name = a, \
252 .offset = offsetof(st, f_l), \
254 .u = { .str_list = { .offset_n = offsetof(st, f_n) } } \
256#define _ISL_ARG_CHILD(o,l,c,h,fl) { \
257 .type = isl_arg_child, \
262 .u = { .child = { .child = c } } \
264#define ISL_ARG_CHILD(st,f,l,c,h) \
265 _ISL_ARG_CHILD(offsetof(st, f),l,c,h,0)
266#define ISL_ARG_GROUP_F(l,c,h,fl) \
267 _ISL_ARG_CHILD(ISL_ARG_OFFSET_NONE,l,c,h,fl)
268#define ISL_ARG_GROUP(l,c,h) \
269 ISL_ARG_GROUP_F(l,c,h,0)
270#define ISL_ARG_FLAGS(st,f,s,l,c,d,h) { \
271 .type = isl_arg_flags, \
274 .offset = offsetof(st, f), \
276 .u = { .flags = { .flags = c, .default_value = d } } \
278#define ISL_ARG_USER(st,f,i,c) { \
279 .type = isl_arg_user, \
280 .offset = offsetof(st, f), \
281 .u = { .user = { .init = i, .clear = c} } \
283#define ISL_ARG_VERSION(print) { \
284 .type = isl_arg_version, \
285 .u = { .version = { .print_version = print } } \
288#define ISL_ARG_ALL (1 << 0)
289#define ISL_ARG_SKIP_HELP (1 << 1)
296#define ISL_ARG_DECL(prefix,st,args) \
297extern struct isl_args args; \
298st *prefix ## _new_with_defaults(void); \
299void prefix ## _free(st *opt); \
300int prefix ## _parse(st *opt, int argc, char **argv, unsigned flags);
302#define ISL_ARG_DEF(prefix,st,args) \
303st *prefix ## _new_with_defaults() \
305 st *opt = (st *)calloc(1, sizeof(st)); \
307 isl_args_set_defaults(&(args), opt); \
311void prefix ## _free(st *opt) \
313 isl_args_free(&(args), opt); \
316int prefix ## _parse(st *opt, int argc, char **argv, unsigned flags) \
318 return isl_args_parse(&(args), argc, argv, opt, flags); \
321#if defined(__cplusplus)
void isl_args_set_defaults(struct isl_args *args, void *opt)
void isl_args_free(struct isl_args *args, void *opt)
int isl_args_parse(struct isl_args *args, int argc, char **argv, void *opt, unsigned flags)
__isl_export __isl_give ISL_HMAP __isl_take ISL_KEY __isl_take ISL_VAL * val
static void print_version(void)
const char * default_value
int(* set)(void *opt, unsigned val)
unsigned default_selected
struct isl_arg::@0::@6 ul
struct isl_arg::@0::@7 str
const char * argument_name
unsigned long default_value
struct isl_arg::@0::@11 user
struct isl_arg_choice * choice
struct isl_arg::@0::@10 version
struct isl_arg_flags * flags
struct isl_arg::@0::@8 str_list