X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=cat.c;h=f278e9c5af460d1b9bb942c2164d6e6ec0c3ef3a;hb=401775104e7d62116e6b8521d3ba1b789764732f;hp=09a4a10d4c3dc58d3b781523683d0b23881ecead;hpb=e46a6ece602f0a9c3aa33943e5de11d03a362610;p=platform%2Fupstream%2Fisl.git diff --git a/cat.c b/cat.c index 09a4a10..f278e9c 100644 --- a/cat.c +++ b/cat.c @@ -1,15 +1,56 @@ -#include +#include +#include +#include +#include + +struct isl_arg_choice cat_format[] = { + {"isl", ISL_FORMAT_ISL}, + {"omega", ISL_FORMAT_OMEGA}, + {"polylib", ISL_FORMAT_POLYLIB}, + {"ext-polylib", ISL_FORMAT_EXT_POLYLIB}, + {"latex", ISL_FORMAT_LATEX}, + {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 options") +ISL_ARG_CHOICE(struct cat_options, format, 0, "format", \ + cat_format, ISL_FORMAT_ISL, "output format") +ISL_ARG_END +}; + +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 isl_stream *s; + struct isl_obj obj; + struct cat_options *options; + isl_printer *p; + + options = cat_options_new_with_defaults(); + assert(options); + argc = cat_options_parse(options, argc, argv, ISL_ARG_ALL); + + ctx = isl_ctx_alloc_with_options(cat_options_arg, options); + + s = isl_stream_new_file(ctx, stdin); + obj = isl_stream_read_obj(s); + isl_stream_free(s); - ctx = isl_ctx_alloc(); + p = isl_printer_to_file(ctx, stdout); + p = isl_printer_set_output_format(p, options->format); + p = obj.type->print(p, obj.v); + p = isl_printer_end_line(p); + isl_printer_free(p); - map = isl_map_read_from_file(ctx, stdin, -1); - isl_map_print(map, stdout, 0, ISL_FORMAT_ISL); - isl_map_free(map); + obj.type->free(obj.v); isl_ctx_free(ctx);