2 #include <barvinok/evalue.h>
3 #include <barvinok/options.h>
4 #include <barvinok/util.h>
7 #include "evalue_convert.h"
8 #include "evalue_read.h"
14 #define ALLOCN(type,n) (type*)malloc((n) * sizeof(type))
16 #define OPT_VARS (BV_OPT_LAST+1)
18 struct argp_option argp_options
[] = {
19 { "variables", OPT_VARS
, "list", 0,
20 "comma separated list of variables over which to maximize" },
21 { "verbose", 'v', 0, 0, },
26 struct convert_options convert
;
27 struct barvinok_options
*barvinok
;
32 static error_t
parse_opt(int key
, char *arg
, struct argp_state
*state
)
34 struct options
*options
= (struct options
*) state
->input
;
38 state
->child_inputs
[0] = &options
->convert
;
39 state
->child_inputs
[1] = &options
->barvinok
;
40 options
->var_list
= NULL
;
47 options
->var_list
= strdup(arg
);
50 return ARGP_ERR_UNKNOWN
;
55 int main(int argc
, char **argv
)
58 char **all_vars
= NULL
;
61 struct options options
;
62 struct barvinok_options
*bv_options
= barvinok_options_new_with_defaults();
63 static struct argp_child argp_children
[] = {
64 { &convert_argp
, 0, "input conversion", 1 },
65 { &barvinok_argp
, 0, "barvinok options", 3 },
68 static struct argp argp
= { argp_options
, parse_opt
, 0, 0, argp_children
};
71 options
.barvinok
= bv_options
;
72 set_program_name(argv
[0]);
73 argp_parse(&argp
, argc
, argv
, 0, 0, &options
);
75 EP
= evalue_read_from_file(stdin
, options
.var_list
, &all_vars
,
76 &nvar
, &nparam
, bv_options
->MaxRays
);
79 evalue_convert(EP
, &options
.convert
, options
.verbose
, nparam
, all_vars
);
81 if (EVALUE_IS_ZERO(*EP
))
82 print_evalue(stdout
, EP
, all_vars
);
84 evalue
*sum
= esum(EP
, nvar
);
85 print_evalue(stdout
, sum
, all_vars
+nvar
);
86 free_evalue_refs(sum
);
94 free(options
.var_list
);
95 Free_ParamNames(all_vars
, nvar
+nparam
);
96 barvinok_options_free(bv_options
);