More consistent ICU info. Update URLs to ICU info
[yaz-moved-to-github.git] / util / cql2xcql.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2010 Index Data
3  * See the file LICENSE for details.
4  */
5 #if HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 #include <yaz/cql.h>
13 #include <yaz/options.h>
14
15 int main(int argc, char **argv)
16 {
17     CQL_parser cp;
18     int r = 0;
19     const char *fname = 0;
20     int iterations = 1;
21     int ret;
22     char *arg;
23
24     while ((ret = options("n:", argv, argc, &arg)) != -2)
25     {
26         switch (ret)
27         {
28         case 0:
29             fname = arg;
30             break;
31         case 'n':
32             iterations = atoi(arg);
33             break;
34         }
35     }
36
37     cp = cql_parser_create();
38     if (fname)
39     {
40         int i;
41         for (i = 0; i<iterations; i++)
42             r = cql_parser_string(cp, fname);
43     }
44     else
45         r = cql_parser_stdio(cp, stdin);
46     if (r)
47         fprintf (stderr, "Syntax error\n");
48     else
49         cql_to_xml_stdio(cql_parser_result(cp), stdout);
50     cql_parser_destroy(cp);
51     return 0;
52 }
53 /*
54  * Local variables:
55  * c-basic-offset: 4
56  * c-file-style: "Stroustrup"
57  * indent-tabs-mode: nil
58  * End:
59  * vim: shiftwidth=4 tabstop=8 expandtab
60  */
61