From: Mike Taylor Date: Wed, 21 Dec 2005 16:41:36 +0000 (+0000) Subject: Add ZOOM_query_cql2rpn() X-Git-Tag: YAZ.2.1.12~32 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=6202be57112ed26410889081bb0ab87a779ae0bf Add ZOOM_query_cql2rpn() --- diff --git a/include/yaz/zoom.h b/include/yaz/zoom.h index 185e315..70f7231 100644 --- a/include/yaz/zoom.h +++ b/include/yaz/zoom.h @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom.h,v 1.32 2005-12-20 22:23:04 mike Exp $ + * $Id: zoom.h,v 1.33 2005-12-21 16:43:13 mike Exp $ */ /** * \file zoom.h @@ -196,6 +196,9 @@ ZOOM_query_destroy(ZOOM_query s); /* CQL */ ZOOM_API(int) ZOOM_query_cql(ZOOM_query s, const char *str); +/* CQL translated client-side into RPN: `conn' is optional for diagnostics */ +ZOOM_API(int) +ZOOM_query_cql2rpn(ZOOM_query s, const char *str, ZOOM_connection conn); /* PQF */ ZOOM_API(int) ZOOM_query_prefix(ZOOM_query s, const char *str); diff --git a/src/zoom-c.c b/src/zoom-c.c index e5fbd38..cd13a01 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.61 2005-12-21 08:35:36 mike Exp $ + * $Id: zoom-c.c,v 1.62 2005-12-21 16:41:36 mike Exp $ */ /** * \file zoom-c.c @@ -530,6 +530,31 @@ ZOOM_query_cql(ZOOM_query s, const char *str) return 0; } +/* + * Translate the CQL string client-side into RPN which is passed to + * the server. This is useful for server's that don't themselves + * support CQL, for which ZOOM_query_cql() is useless. `conn' is used + * only as a place to stash diagnostics if compilation fails; if this + * information is not needed, a null pointer may be used. + */ +ZOOM_API(int) +ZOOM_query_cql2rpn(ZOOM_query s, const char *str, ZOOM_connection conn) +{ + char *rpn; + int ret; + + yaz_log(log_details, "%p ZOOM_query_cql2rpn str=%s conn=%p", s, str, conn); + if (conn == 0) + conn = ZOOM_connection_create(0); + + if ((rpn = cql2pqf(conn, str)) == 0) + return -1; + + ret = ZOOM_query_prefix(s, rpn); + xfree(rpn); + return ret; +} + ZOOM_API(int) ZOOM_query_sortby(ZOOM_query s, const char *criteria) { @@ -1104,7 +1129,7 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c) ZOOM_options_get(c->options, "implementationName"), odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.61 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.62 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = odr_prepend(c->odr_out,