X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=util%2Fcql2pqf.c;h=edf99315cd9c3ef5c3d59647427b639513a09fe8;hp=3c5df41d8414b1cd6d9af2a55a386e7d811cf17c;hb=8007b02f1f71539935da4895cea16fac3422e64c;hpb=fb6d99a0c7e07d9cc4a315c447deaf6564a85505 diff --git a/util/cql2pqf.c b/util/cql2pqf.c index 3c5df41..edf9931 100644 --- a/util/cql2pqf.c +++ b/util/cql2pqf.c @@ -1,37 +1,33 @@ -/* $Id: cql2pqf.c,v 1.7 2005-06-25 15:46:07 adam Exp $ - Copyright (C) 1995-2005, Index Data ApS - 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-2009 Index Data + * See the file LICENSE for details. + */ #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] []\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 ret; char *arg; - while ((ret = options("n:", argv, argc, &arg)) != -2) + while ((ret = options("n:r", argv, argc, &arg)) != -2) { switch (ret) { @@ -41,6 +37,9 @@ int main(int argc, char **argv) else query = arg; break; + case 'r': + reverse = 1; + break; case 'n': iterations = atoi(arg); break; @@ -50,48 +49,89 @@ int main(int argc, char **argv) } if (!fname) usage(); - ct = cql_transform_open_fname(fname); + 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