Update CQL parser to use CQL 1.1 modifiers for booleans and
[yaz-moved-to-github.git] / util / cql2xcql.c
1 /* $Id: cql2xcql.c,v 1.2 2004-03-10 16:34:31 adam Exp $
2    Copyright (C) 2002-2003
3    Index Data Aps
4
5 This file is part of the YAZ toolkit.
6
7 See the file LICENSE.
8 */
9
10 #include <stdio.h>
11
12 #include <yaz/cql.h>
13
14 int main(int argc, char **argv)
15 {
16     CQL_parser cp;
17     int r;
18     const char *fname = 0;
19     int iterations = 1;
20     int ret;
21     char *arg;
22
23     while ((ret = options("n:", argv, argc, &arg)) != -2)
24     {
25         switch (ret)
26         {
27         case 0:
28             fname = arg;
29             break;
30         case 'n':
31             iterations = atoi(arg);
32             break;
33         }
34     }
35
36     cp = cql_parser_create();
37     if (fname)
38     {
39         int i;
40         for (i = 0; i<iterations; i++)
41             r = cql_parser_string(cp, fname);
42     }
43     else
44         r = cql_parser_stdio(cp, stdin);
45     if (r)
46         fprintf (stderr, "Syntax error\n");
47     else
48         cql_to_xml_stdio(cql_parser_result(cp), stdout);
49     cql_parser_destroy(cp);
50     return 0;
51 }