2 * Copyright 2008-2009 Katholieke Universiteit Leuven
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
15 struct isl_arg_choice
{
28 enum isl_arg_type type
;
30 const char *long_name
;
34 struct isl_arg_choice
*choice
;
35 unsigned default_value
;
38 unsigned default_value
;
41 struct isl_arg
*child
;
47 #define ISL_ARG_CHOICE(st,f,s,l,c,d) { \
48 .type = isl_arg_choice, \
51 .offset = offsetof(st, f), \
52 .u = { .choice = { .choice = c, .default_value = d } } \
54 #define ISL_ARG_BOOL(st,f,s,l,d) { \
55 .type = isl_arg_bool, \
58 .offset = offsetof(st, f), \
59 .u = { .b = { .default_value = d } } \
61 #define ISL_ARG_CHILD(st,f,l,c) { \
62 .type = isl_arg_child, \
64 .offset = offsetof(st, f), \
65 .u = { .child = { .child = c, .size = sizeof(*((st *)NULL)->f) } }\
67 #define ISL_ARG_END { isl_arg_end }
69 void isl_arg_set_defaults(struct isl_arg
*arg
, void *opt
);
70 int isl_arg_parse(struct isl_arg
*arg
, int argc
, char **argv
, void *opt
);
72 #define ISL_ARG_DECL(prefix,st,arg) \
73 st *prefix ## _new_with_defaults(); \
74 int prefix ## _parse(st *opt, int argc, char **argv);
76 #define ISL_ARG_DEF(prefix,st,arg) \
77 st *prefix ## _new_with_defaults() \
79 st *opt = (st *)calloc(1, sizeof(st)); \
81 isl_arg_set_defaults(arg, opt); \
85 int prefix ## _parse(st *opt, int argc, char **argv) \
87 return isl_arg_parse(arg, argc, argv, opt); \