X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fcql2pqf.c;h=ac2a4577091f2a928c082114873d469ffe6172e3;hb=1015e59c397c0421df1be835e1418ef95531ad98;hp=a63d30db898527ed5ac47cc89d2561d98a510734;hpb=c6e47cbbff56f39f6d81b079ebaeac41d793d4d9;p=yaz-moved-to-github.git diff --git a/util/cql2pqf.c b/util/cql2pqf.c index a63d30d..ac2a457 100644 --- a/util/cql2pqf.c +++ b/util/cql2pqf.c @@ -1,42 +1,63 @@ -/* $Id: cql2pqf.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-2008 Index Data + * See the file LICENSE for details. + */ #include #include #include +#include + +static void usage(void) +{ + fprintf (stderr, "usage\n cql2pqf [-n ] []\n"); + exit (1); +} int main(int argc, char **argv) { cql_transform_t ct; - int r; - int i, it = 1; + int r = 0; + int i, iterations = 1; CQL_parser cp = cql_parser_create(); + char *query = 0; + char *fname = 0; + + int ret; + char *arg; - if (argc < 2) + while ((ret = options("n:", argv, argc, &arg)) != -2) { - fprintf (stderr, "usage\n cqltransform [] [interations]\n"); - exit (1); + switch (ret) + { + case 0: + if (!fname) + fname = arg; + else + query = arg; + break; + case 'n': + iterations = atoi(arg); + break; + default: + usage(); + } } - ct = cql_transform_open_fname(argv[1]); + if (!fname) + usage(); + ct = cql_transform_open_fname(fname); if (!ct) { - fprintf (stderr, "failed to read properties %s\n", argv[1]); + fprintf (stderr, "failed to read properties %s\n", fname); exit (1); } - if (argc >= 4) - it = atoi(argv[3]); - for (i = 0; i= 3) - r = cql_parser_string(cp, argv[2]); + for (i = 0; i