1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2013 Index Data
3 * See the file LICENSE for details.
12 #include <yaz/rpn2cql.h>
13 #include <yaz/pquery.h>
14 #include <yaz/options.h>
16 static void usage(void)
18 fprintf(stderr, "usage\n cql2pqf [-n <n>] [-r] [-S] <properties> "
23 int main(int argc, char **argv)
26 int i, iterations = 1;
36 while ((ret = options("n:rSv", argv, argc, &arg)) != -2)
47 iterations = atoi(arg);
64 if (!strcmp(fname, "-"))
65 ct = cql_transform_create();
67 ct = cql_transform_open_fname(fname);
70 fprintf(stderr, "failed to read properties %s\n", fname);
80 if (fgets(buf, sizeof buf, stdin))
85 ODR odr = odr_createmem(ODR_ENCODE);
86 YAZ_PQF_Parser pp = yaz_pqf_create();
87 Z_RPNQuery *rpn = yaz_pqf_parse(pp, odr, query);
90 fprintf(stderr, "PQF syntax error\n");
94 int ret = cql_transform_rpn2cql_stream(ct, cql_fputs,
100 int r = cql_transform_error(ct, &addinfo);
101 printf("Transform error %d %s\n", r, addinfo ? addinfo : "");
112 CQL_parser cp = cql_parser_create();
115 cql_parser_strict(cp, do_strict);
119 printf("Parsing CQL %s\n", query);
120 for (i = 0; i<iterations; i++)
121 r = cql_parser_string(cp, query);
124 r = cql_parser_stdio(cp, stdin);
127 fprintf(stderr, "Syntax error\n");
130 r = cql_transform_FILE(ct, cql_parser_result(cp), stdout);
135 r = cql_transform_error(ct, &addinfo);
136 printf("Transform error %d %s\n", r, addinfo ? addinfo : "");
140 FILE *null = fopen("/dev/null", "w");
141 for (i = 1; i<iterations; i++)
142 cql_transform_FILE(ct, cql_parser_result(cp), null);
146 cql_parser_destroy(cp);
148 cql_transform_close(ct);
154 * c-file-style: "Stroustrup"
155 * indent-tabs-mode: nil
157 * vim: shiftwidth=4 tabstop=8 expandtab