#include <yaz/cql.h>
#include <yaz/options.h>
+static void usage(const char *prog)
+{
+ fprintf(stderr, "%s: [-c] [-n iterations] [infile]\n", prog);
+ exit(1);
+}
+
int main(int argc, char **argv)
{
CQL_parser cp;
const char *fname = 0;
int iterations = 1;
int ret;
+ int convert_to_ccl = 0;
char *arg;
+ char *prog = argv[0];
- while ((ret = options("n:", argv, argc, &arg)) != -2)
+ while ((ret = options("cn:", argv, argc, &arg)) != -2)
{
switch (ret)
{
case 0:
fname = arg;
break;
+ case 'c':
+ convert_to_ccl = 1;
+ break;
case 'n':
iterations = atoi(arg);
break;
+ default:
+ usage(prog);
}
}
if (r)
fprintf (stderr, "Syntax error\n");
else
- cql_to_xml_stdio(cql_parser_result(cp), stdout);
+ {
+ if (convert_to_ccl)
+ {
+ cql_to_ccl_stdio(cql_parser_result(cp), stdout);
+ putchar('\n');
+ }
+ else
+ cql_to_xml_stdio(cql_parser_result(cp), stdout);
+ }
cql_parser_destroy(cp);
return 0;
}