polysign.h: remove dependency on lexmin.h
[barvinok.git] / barvinok_count.c
blobaee79d4505d3f6421cdcda3c866460a27e353aee
1 #include <unistd.h>
2 #include <stdlib.h>
3 #include <strings.h>
4 #include <barvinok/util.h>
5 #include <barvinok/barvinok.h>
6 #include "argp.h"
7 #include "progname.h"
9 #define PRINT_STATS (BV_OPT_LAST+1)
11 struct argp_option argp_options[] = {
12 { "print-stats", PRINT_STATS, 0, 0 },
13 { 0 }
16 struct arguments {
17 struct barvinok_options *options;
18 int print_stats;
21 error_t parse_opt(int key, char *arg, struct argp_state *state)
23 struct arguments *arguments = state->input;
25 switch (key) {
26 case ARGP_KEY_INIT:
27 state->child_inputs[0] = arguments->options;
28 break;
29 case PRINT_STATS:
30 arguments->print_stats = 1;
31 break;
32 default:
33 return ARGP_ERR_UNKNOWN;
35 return 0;
38 int main(int argc, char **argv)
40 Value cb;
41 Polyhedron *A;
42 struct arguments arguments;
43 static struct argp_child argp_children[] = {
44 { &barvinok_argp, 0, 0, 0 },
45 { 0 }
47 static struct argp argp = { argp_options, parse_opt, 0, 0, argp_children };
48 struct barvinok_options *options = barvinok_options_new_with_defaults();
50 arguments.print_stats = 0;
51 arguments.options = options;
53 set_program_name(argv[0]);
54 argp_parse(&argp, argc, argv, 0, 0, &arguments);
56 A = Polyhedron_Read(options->MaxRays);
57 value_init(cb);
58 Polyhedron_Print(stdout, P_VALUE_FMT, A);
59 barvinok_count_with_options(A, &cb, options);
60 value_print(stdout, P_VALUE_FMT, cb);
61 puts("");
62 if (arguments.print_stats)
63 barvinok_stats_print(options->stats, stdout);
64 value_clear(cb);
65 Polyhedron_Free(A);
66 barvinok_options_free(options);
67 return 0;