genfun.cc: move lex_cmp to mat_util.cc
[barvinok.git] / barvinok_count.c
blob15a84f09ac4414e63af3a0f55b28836d6fe80732
1 #include <unistd.h>
2 #include <stdlib.h>
3 #include <strings.h>
4 #include <barvinok/util.h>
5 #include <barvinok/barvinok.h>
6 #include "config.h"
8 int print_stats = 0;
10 #ifndef HAVE_GETOPT_H
11 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
12 #else
13 #include <getopt.h>
14 #define PRINT_STATS 256
15 struct option options[] = {
16 { "print-stats", no_argument, &print_stats, PRINT_STATS },
17 { "version", no_argument, 0, 'V' },
18 { 0, 0, 0, 0 }
20 #endif
22 int main(int argc, char **argv)
24 Value cb;
25 Polyhedron *A;
26 int c, ind = 0;
27 struct barvinok_options *bv_options = barvinok_options_new_with_defaults();
29 while ((c = getopt_long(argc, argv, "V", options, &ind)) != -1) {
30 switch (c) {
31 case 'V':
32 printf(barvinok_version());
33 exit(0);
34 break;
38 A = Polyhedron_Read(bv_options->MaxRays);
39 value_init(cb);
40 Polyhedron_Print(stdout, P_VALUE_FMT, A);
41 barvinok_count_with_options(A, &cb, bv_options);
42 value_print(stdout, P_VALUE_FMT, cb);
43 puts("");
44 if (print_stats)
45 barvinok_stats_print(&bv_options->stats, stdout);
46 value_clear(cb);
47 Polyhedron_Free(A);
48 free(bv_options);
49 return 0;