isl_ctx: keep track of user options
[platform/upstream/isl.git] / cat.c
1 #include <isl_map.h>
2
3 struct isl_arg_choice cat_format[] = {
4         {"isl",         ISL_FORMAT_ISL},
5         {"omega",       ISL_FORMAT_OMEGA},
6         {"polylib",     ISL_FORMAT_POLYLIB},
7         {"latex",       ISL_FORMAT_LATEX},
8         {0}
9 };
10
11 struct cat_options {
12         struct isl_options      *isl;
13         unsigned                 format;
14 };
15
16 struct isl_arg cat_options_arg[] = {
17 ISL_ARG_CHILD(struct cat_options, isl, "isl", isl_options_arg, "isl options")
18 ISL_ARG_CHOICE(struct cat_options, format, 0, "format", \
19         cat_format,     ISL_FORMAT_ISL, "output format")
20 ISL_ARG_END
21 };
22
23 ISL_ARG_DEF(cat_options, struct cat_options, cat_options_arg)
24
25 int main(int argc, char **argv)
26 {
27         struct isl_ctx *ctx;
28         struct isl_map *map;
29         struct cat_options *options;
30
31         options = cat_options_new_with_defaults();
32         assert(options);
33         argc = cat_options_parse(options, argc, argv, ISL_ARG_ALL);
34
35         ctx = isl_ctx_alloc_with_options(cat_options_arg, options);
36
37         map = isl_map_read_from_file(ctx, stdin, -1);
38         isl_map_print(map, stdout, 0, options->format);
39         if (options->format == ISL_FORMAT_ISL)
40                 printf("\n");
41         isl_map_free(map);
42
43         isl_ctx_free(ctx);
44
45         return 0;
46 }