Expanded tabs in all source files. Added vim/emacs local variables
[yaz-moved-to-github.git] / util / cql2xcql.c
1 /* $Id: cql2xcql.c,v 1.7 2005-06-25 15:46:07 adam Exp $
2    Copyright (C) 1995-2005, Index Data ApS
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 #include <stdlib.h>
12
13 #include <yaz/cql.h>
14 #include <yaz/options.h>
15
16 int main(int argc, char **argv)
17 {
18     CQL_parser cp;
19     int r = 0;
20     const char *fname = 0;
21     int iterations = 1;
22     int ret;
23     char *arg;
24
25     while ((ret = options("n:", argv, argc, &arg)) != -2)
26     {
27         switch (ret)
28         {
29         case 0:
30             fname = arg;
31             break;
32         case 'n':
33             iterations = atoi(arg);
34             break;
35         }
36     }
37
38     cp = cql_parser_create();
39     if (fname)
40     {
41         int i;
42         for (i = 0; i<iterations; i++)
43             r = cql_parser_string(cp, fname);
44     }
45     else
46         r = cql_parser_stdio(cp, stdin);
47     if (r)
48         fprintf (stderr, "Syntax error\n");
49     else
50         cql_to_xml_stdio(cql_parser_result(cp), stdout);
51     cql_parser_destroy(cp);
52     return 0;
53 }
54 /*
55  * Local variables:
56  * c-basic-offset: 4
57  * indent-tabs-mode: nil
58  * End:
59  * vim: shiftwidth=4 tabstop=8 expandtab
60  */
61