X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=util%2Fcql2xcql.c;h=bad3f3e7d704b930fea794419842b0641fa47f0b;hp=e389069c818f2d0846c1cddc181208e04fc8bc41;hb=5ae2f74ba9b27bb7e926d5908471ac79371f7823;hpb=c6e47cbbff56f39f6d81b079ebaeac41d793d4d9 diff --git a/util/cql2xcql.c b/util/cql2xcql.c index e389069..bad3f3e 100644 --- a/util/cql2xcql.c +++ b/util/cql2xcql.c @@ -1,28 +1,103 @@ -/* $Id: cql2xcql.c,v 1.1 2003-10-27 12:21:39 adam Exp $ - Copyright (C) 2002-2003 - Index Data Aps - -This file is part of the YAZ toolkit. - -See the file LICENSE. -*/ +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2013 Index Data + * See the file LICENSE for details. + */ +#if HAVE_CONFIG_H +#include +#endif #include +#include #include +#include +#include + +static void usage(const char *prog) +{ + fprintf(stderr, "%s: [-c] [-n iterations] [-s] [-S] [infile]\n", prog); + exit(1); +} int main(int argc, char **argv) { - int r; - CQL_parser cp = cql_parser_create(); - if (argc == 2) - r = cql_parser_string(cp, argv[1]); + CQL_parser cp; + int r = 0; + const char *fname = 0; + int iterations = 1; + int ret; + int convert_to_ccl = 0; + char *arg; + char *prog = argv[0]; + int do_sortkeys = 0; + int do_strict = 0; + + while ((ret = options("cn:sS", argv, argc, &arg)) != YAZ_OPTIONS_EOF) + { + switch (ret) + { + case 0: + fname = arg; + break; + case 'c': + convert_to_ccl = 1; + break; + case 'n': + iterations = atoi(arg); + break; + case 's': + do_sortkeys = 1; + break; + case 'S': + do_strict = 1; + break; + default: + usage(prog); + } + } + + cp = cql_parser_create(); + cql_parser_strict(cp, do_strict); + if (fname) + { + int i; + for (i = 0; i