X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fcql2xcql.c;h=5c70d7a2233294e8c4f874b1db14a6ba56c0c1f9;hb=301bd3892284e83875d90bd7a65f48366c81213d;hp=5abdb57524b26b1baf5b8cf1382892b6c8704ae0;hpb=379504a233e3e2cc85bca1e7b6d864f1395aec7c;p=yaz-moved-to-github.git diff --git a/util/cql2xcql.c b/util/cql2xcql.c index 5abdb57..5c70d7a 100644 --- a/util/cql2xcql.c +++ b/util/cql2xcql.c @@ -1,7 +1,10 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2009 Index Data + * Copyright (C) 1995-2011 Index Data * See the file LICENSE for details. */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -9,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; @@ -16,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); } } @@ -43,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; }