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 ODR odr = odr_createmem(ODR_ENCODE);
81 YAZ_PQF_Parser pp = yaz_pqf_create();
82 Z_RPNQuery *rpn = yaz_pqf_parse(pp, odr, query);
85 fprintf(stderr, "PQF syntax error\n");
89 int ret = cql_transform_rpn2cql_stream(ct, cql_fputs,
95 int r = cql_transform_error(ct, &addinfo);
96 printf("Transform error %d %s\n", r, addinfo ? addinfo : "");
107 CQL_parser cp = cql_parser_create();
110 cql_parser_strict(cp, do_strict);
114 printf("Parsing CQL %s\n", query);
115 for (i = 0; i<iterations; i++)
116 r = cql_parser_string(cp, query);
119 r = cql_parser_stdio(cp, stdin);
122 fprintf(stderr, "Syntax error\n");
125 r = cql_transform_FILE(ct, cql_parser_result(cp), stdout);
130 r = cql_transform_error(ct, &addinfo);
131 printf("Transform error %d %s\n", r, addinfo ? addinfo : "");
135 FILE *null = fopen("/dev/null", "w");
136 for (i = 1; i<iterations; i++)
137 cql_transform_FILE(ct, cql_parser_result(cp), null);
141 cql_parser_destroy(cp);
143 cql_transform_close(ct);
149 * c-file-style: "Stroustrup"
150 * indent-tabs-mode: nil
152 * vim: shiftwidth=4 tabstop=8 expandtab