From fccc0e1dbb7cc7937abb742071d55ab36df96aaa Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 10 Jun 2011 13:41:43 +0200 Subject: [PATCH] cql2xcql: option -c makes conversion to CCL. By default cql2xcql converts to XCQL (XML). --- util/cql2xcql.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/util/cql2xcql.c b/util/cql2xcql.c index 55d824d..5c70d7a 100644 --- a/util/cql2xcql.c +++ b/util/cql2xcql.c @@ -12,6 +12,12 @@ #include #include +static void usage(const char *prog) +{ + fprintf(stderr, "%s: [-c] [-n iterations] [infile]\n", prog); + exit(1); +} + int main(int argc, char **argv) { CQL_parser cp; @@ -19,18 +25,25 @@ int main(int argc, char **argv) const char *fname = 0; int iterations = 1; int ret; + int convert_to_ccl = 0; char *arg; + char *prog = argv[0]; - while ((ret = options("n:", argv, argc, &arg)) != -2) + while ((ret = options("cn:", argv, argc, &arg)) != -2) { switch (ret) { case 0: fname = arg; break; + case 'c': + convert_to_ccl = 1; + break; case 'n': iterations = atoi(arg); break; + default: + usage(prog); } } @@ -46,7 +59,15 @@ int main(int argc, char **argv) if (r) fprintf (stderr, "Syntax error\n"); else - cql_to_xml_stdio(cql_parser_result(cp), stdout); + { + if (convert_to_ccl) + { + cql_to_ccl_stdio(cql_parser_result(cp), stdout); + putchar('\n'); + } + else + cql_to_xml_stdio(cql_parser_result(cp), stdout); + } cql_parser_destroy(cp); return 0; } -- 1.7.10.4