projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
yaz-iconv: fix typos
[yaz-moved-to-github.git]
/
util
/
cql2pqf.c
diff --git
a/util/cql2pqf.c
b/util/cql2pqf.c
index
1073abf
..
0baa175
100644
(file)
--- a/
util/cql2pqf.c
+++ b/
util/cql2pqf.c
@@
-1,5
+1,5
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2013 Index Data
+ * Copyright (C) Index Data
* See the file LICENSE for details.
*/
#if HAVE_CONFIG_H
* See the file LICENSE for details.
*/
#if HAVE_CONFIG_H
@@
-10,13
+10,17
@@
#include <stdio.h>
#include <yaz/rpn2cql.h>
#include <stdio.h>
#include <yaz/rpn2cql.h>
+#include <yaz/rpn2solr.h>
#include <yaz/pquery.h>
#include <yaz/options.h>
static void usage(void)
{
#include <yaz/pquery.h>
#include <yaz/options.h>
static void usage(void)
{
- fprintf(stderr, "usage\n cql2pqf [-n <n>] [-r] [-S] <properties> "
+ fprintf(stderr, "usage\n cql2pqf [-n <n>] [-r] [-s] [-S] <properties> "
"[<query>]\n");
"[<query>]\n");
+ fprintf(stderr, " -r reverse conversion (RPN to Solr/CQL)\n");
+ fprintf(stderr, " -s Solr instead of CQL\n");
+ fprintf(stderr, " -S strict CQL 2.0\n");
exit(1);
}
exit(1);
}
@@
-27,13
+31,14
@@
int main(int argc, char **argv)
char *query = 0;
char *fname = 0;
int reverse = 0;
char *query = 0;
char *fname = 0;
int reverse = 0;
- int verbose = 0
+ int solr = 0;
+ int verbose = 0;
int do_strict = 0;
int ret;
char *arg;
int do_strict = 0;
int ret;
char *arg;
- while ((ret = options("n:rSv", argv, argc, &arg)) != -2)
+ while ((ret = options("n:rsSv", argv, argc, &arg)) != -2)
{
switch (ret)
{
{
switch (ret)
{
@@
-52,6
+57,9
@@
int main(int argc, char **argv)
case 'S':
do_strict = 1;
break;
case 'S':
do_strict = 1;
break;
+ case 's':
+ solr = 1;
+ break;
case 'v':
verbose = 1;
break;
case 'v':
verbose = 1;
break;
@@
-59,17
+67,17
@@
int main(int argc, char **argv)
usage();
}
}
usage();
}
}
- if (!fname)
- usage();
- if (!strcmp(fname, "-"))
- ct = cql_transform_create();
- else
- ct = cql_transform_open_fname(fname);
- if (!ct)
+ if (fname)
{
{
- fprintf(stderr, "failed to read properties %s\n", fname);
- exit(1);
+ ct = cql_transform_open_fname(fname);
+ if (!ct)
+ {
+ fprintf(stderr, "failed to read properties %s\n", fname);
+ exit(1);
+ }
}
}
+ else
+ ct = cql_transform_create();
if (reverse)
{
if (reverse)
{
@@
-78,7
+86,11
@@
int main(int argc, char **argv)
if (!query)
{
if (fgets(buf, sizeof buf, stdin))
if (!query)
{
if (fgets(buf, sizeof buf, stdin))
+ {
+ if (*buf && buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
query = buf;
query = buf;
+ }
}
if (query)
{
}
if (query)
{
@@
-91,9
+103,13
@@
int main(int argc, char **argv)
}
else
{
}
else
{
- int ret = cql_transform_rpn2cql_stream(ct, cql_fputs,
+ int ret = 0;
+ if (solr)
+ ret = solr_transform_rpn2solr_stream(ct, cql_fputs,
+ stdout, rpn);
+ else
+ ret = cql_transform_rpn2cql_stream(ct, cql_fputs,
stdout, rpn);
stdout, rpn);
-
if (ret)
{
const char *addinfo;
if (ret)
{
const char *addinfo;
@@
-125,6
+141,10
@@
int main(int argc, char **argv)
if (r)
fprintf(stderr, "Syntax error\n");
if (r)
fprintf(stderr, "Syntax error\n");
+ else if (solr)
+ {
+ printf("CQL to Solr not supported (supported is reverse -r)\n");
+ }
else
{
r = cql_transform_FILE(ct, cql_parser_result(cp), stdout);
else
{
r = cql_transform_FILE(ct, cql_parser_result(cp), stdout);