X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=util%2Fcql2pqf.c;h=203cdae736e6859af39c5ed8533d54d10d10eca0;hp=57575dbc7cafc517328ea0c2363af87818e42745;hb=fbd98e3ba1435882c6fa121e5dee6648ed295b60;hpb=c58035e31f65574542f72955007b1935c3669186 diff --git a/util/cql2pqf.c b/util/cql2pqf.c index 57575db..203cdae 100644 --- a/util/cql2pqf.c +++ b/util/cql2pqf.c @@ -1,91 +1,159 @@ -/* $Id: cql2pqf.c,v 1.5 2004-04-29 21:15:14 adam Exp $ - Copyright (C) 2002-2004 - 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 #include -static void usage() +static void usage(void) { - fprintf (stderr, "usage\n cql2pqf [-n ] []\n"); - exit (1); + fprintf(stderr, "usage\n cql2pqf [-n ] [-r] [-S] " + "[]\n"); + exit(1); } int main(int argc, char **argv) { cql_transform_t ct; - int r = 0; int i, iterations = 1; - CQL_parser cp = cql_parser_create(); char *query = 0; char *fname = 0; + int reverse = 0; + int verbose = 0; + int do_strict = 0; int ret; char *arg; - while ((ret = options("n:", argv, argc, &arg)) != -2) + while ((ret = options("n:rSv", argv, argc, &arg)) != -2) { switch (ret) { case 0: - if (!fname) - fname = arg; - else - query = arg; + if (!fname) + fname = arg; + else + query = arg; + break; + case 'n': + iterations = atoi(arg); + break; + case 'r': + reverse = 1; + break; + case 'S': + do_strict = 1; + break; + case 'v': + verbose = 1; break; - case 'n': - iterations = atoi(arg); - break; - default: - usage(); - } + default: + usage(); + } } if (!fname) - usage(); - ct = cql_transform_open_fname(fname); + usage(); + if (!strcmp(fname, "-")) + ct = cql_transform_create(); + else + ct = cql_transform_open_fname(fname); if (!ct) { - fprintf (stderr, "failed to read properties %s\n", fname); - exit (1); + fprintf(stderr, "failed to read properties %s\n", fname); + exit(1); } - if (query) + if (reverse) { - for (i = 0; i