isl_cat: allow specification of output format on command line
authorSven Verdoolaege <skimo@kotnet.org>
Mon, 15 Feb 2010 21:25:23 +0000 (22:25 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Wed, 17 Feb 2010 18:21:19 +0000 (19:21 +0100)
cat.c

diff --git a/cat.c b/cat.c
index 09a4a10..bfa1021 100644 (file)
--- a/cat.c
+++ b/cat.c
@@ -1,17 +1,44 @@
 #include <isl_map.h>
 
+struct isl_arg_choice cat_format[] = {
+       {"isl",         ISL_FORMAT_ISL},
+       {"omega",       ISL_FORMAT_OMEGA},
+       {"polylib",     ISL_FORMAT_POLYLIB},
+       {0}
+};
+
+struct cat_options {
+       struct isl_options      *isl;
+       unsigned                 format;
+};
+
+struct isl_arg cat_options_arg[] = {
+ISL_ARG_CHILD(struct cat_options, isl, "isl", isl_options_arg)
+ISL_ARG_CHOICE(struct cat_options, format, 0, "format", \
+       cat_format,     ISL_FORMAT_ISL)
+};
+
+ISL_ARG_DEF(cat_options, struct cat_options, cat_options_arg)
+
 int main(int argc, char **argv)
 {
        struct isl_ctx *ctx;
        struct isl_map *map;
+       struct cat_options *options;
+
+       options = cat_options_new_with_defaults();
+       assert(options);
+       argc = cat_options_parse(options, argc, argv);
 
-       ctx = isl_ctx_alloc();
+       ctx = isl_ctx_alloc_with_options(options->isl);
+       options->isl = NULL;
 
        map = isl_map_read_from_file(ctx, stdin, -1);
-       isl_map_print(map, stdout, 0, ISL_FORMAT_ISL);
+       isl_map_print(map, stdout, 0, options->format);
        isl_map_free(map);
 
        isl_ctx_free(ctx);
+       free(options);
 
        return 0;
 }