X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fcql2pqf.c;h=ac2a4577091f2a928c082114873d469ffe6172e3;hb=dedba382ec4773d8abdf244290020f3da42113b6;hp=516391f8b786d3ee8109fc6fc8b4ca2b5c6c3a4f;hpb=9691e3376fe3f178ac95e707610b83b36e8635c5;p=yaz-moved-to-github.git diff --git a/util/cql2pqf.c b/util/cql2pqf.c index 516391f..ac2a457 100644 --- a/util/cql2pqf.c +++ b/util/cql2pqf.c @@ -1,42 +1,63 @@ -/* $Id: cql2pqf.c,v 1.2 2003-12-18 16:45:19 mike 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 [] [iterations]\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