1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2008 Index Data
3 * See the file LICENSE for details.
9 #include <yaz/rpn2cql.h>
10 #include <yaz/pquery.h>
11 #include <yaz/options.h>
13 static void usage(void)
15 fprintf(stderr, "usage\n cql2pqf [-n <n>] [-r] <properties> [<query>]\n");
19 int main(int argc, char **argv)
22 int i, iterations = 1;
30 while ((ret = options("n:r", argv, argc, &arg)) != -2)
43 iterations = atoi(arg);
51 ct = cql_transform_open_fname(fname);
54 fprintf(stderr, "failed to read properties %s\n", fname);
64 ODR odr = odr_createmem(ODR_ENCODE);
65 YAZ_PQF_Parser pp = yaz_pqf_create();
66 Z_RPNQuery *rpn = yaz_pqf_parse(pp, odr, query);
69 fprintf(stderr, "PQF syntax error\n");
73 int ret = cql_transform_rpn2cql_stream(ct, cql_fputs,
79 int r = cql_transform_error(ct, &addinfo);
80 printf("Transform error %d %s\n", r, addinfo ? addinfo : "");
91 CQL_parser cp = cql_parser_create();
96 for (i = 0; i<iterations; i++)
97 r = cql_parser_string(cp, query);
100 r = cql_parser_stdio(cp, stdin);
103 fprintf(stderr, "Syntax error\n");
106 r = cql_transform_FILE(ct, cql_parser_result(cp), stdout);
111 r = cql_transform_error(ct, &addinfo);
112 printf("Transform error %d %s\n", r, addinfo ? addinfo : "");
116 FILE *null = fopen("/dev/null", "w");
117 for (i = 1; i<iterations; i++)
118 cql_transform_FILE(ct, cql_parser_result(cp), null);
122 cql_parser_destroy(cp);
124 cql_transform_close(ct);
130 * indent-tabs-mode: nil
132 * vim: shiftwidth=4 tabstop=8 expandtab