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