isl_cat: allow specification of output format on command line
[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         {0}
8 };
9
10 struct cat_options {
11         struct isl_options      *isl;
12         unsigned                 format;
13 };
14
15 struct isl_arg cat_options_arg[] = {
16 ISL_ARG_CHILD(struct cat_options, isl, "isl", isl_options_arg)
17 ISL_ARG_CHOICE(struct cat_options, format, 0, "format", \
18         cat_format,     ISL_FORMAT_ISL)
19 };
20
21 ISL_ARG_DEF(cat_options, struct cat_options, cat_options_arg)
22
23 int main(int argc, char **argv)
24 {
25         struct isl_ctx *ctx;
26         struct isl_map *map;
27         struct cat_options *options;
28
29         options = cat_options_new_with_defaults();
30         assert(options);
31         argc = cat_options_parse(options, argc, argv);
32
33         ctx = isl_ctx_alloc_with_options(options->isl);
34         options->isl = NULL;
35
36         map = isl_map_read_from_file(ctx, stdin, -1);
37         isl_map_print(map, stdout, 0, options->format);
38         isl_map_free(map);
39
40         isl_ctx_free(ctx);
41         free(options);
42
43         return 0;
44 }