#!/bin/sh
-# $Id: buildconf.sh,v 1.21 2005-07-18 10:06:36 marc Exp $
+# $Id: buildconf.sh,v 1.22 2006-01-20 10:34:50 adam Exp $
set -x
aclocal -I .
libtoolize --automake --force
conf_flags=""
case $1 in
-d)
- sh_flags="-g -Wall"
+ sh_flags="-g -Wall -ansi"
enable_configure=true
enable_help=false
shift
-## $Id: Makefile.am,v 1.25 2005-04-22 08:27:57 adam Exp $
+## $Id: Makefile.am,v 1.26 2006-01-20 10:34:51 adam Exp $
pkginclude_HEADERS= backend.h ccl.h cql.h comstack.h \
diagbib1.h diagsrw.h sortspec.h log.h logrpn.h marcdisp.h nmem.h odr.h \
- oid.h options.h otherinfo.h pquery.h prt-ext.h readconf.h statserv.h \
+ oid.h options.h otherinfo.h pquery.h prt-ext.h querytowrbuf.h \
+ readconf.h statserv.h \
tcpip.h unix.h tpath.h wrbuf.h xmalloc.h \
yaz-ccl.h yaz-iconv.h yaz-util.h yaz-version.h yconfig.h proto.h \
\
* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: logrpn.h,v 1.8 2005-06-25 15:46:03 adam Exp $
+ * $Id: logrpn.h,v 1.9 2006-01-20 10:34:51 adam Exp $
*/
/**
* \brief Header for Z39.50 Query Printing
*/
-#ifndef LOG_RPN_H
-#define LOG_RPN_H
+#ifndef YAZ_LOGRPN_H
+#define YAZ_LOGRPN_H
#include <yaz/yconfig.h>
#include <yaz/proto.h>
YAZ_BEGIN_CDECL
-YAZ_EXPORT void log_rpn_query (Z_RPNQuery *rpn);
-YAZ_EXPORT void log_rpn_query_level (int loglevel, Z_RPNQuery *rpn);
+YAZ_EXPORT void log_rpn_query(Z_RPNQuery *rpn);
+YAZ_EXPORT void log_rpn_query_level(int loglevel, Z_RPNQuery *rpn);
-YAZ_EXPORT void log_scan_term (Z_AttributesPlusTerm *zapt, oid_value ast);
-YAZ_EXPORT void log_scan_term_level (int loglevel,
- Z_AttributesPlusTerm *zapt, oid_value ast);
+YAZ_EXPORT void log_scan_term(Z_AttributesPlusTerm *zapt, oid_value ast);
+YAZ_EXPORT void log_scan_term_level(int loglevel,
+ Z_AttributesPlusTerm *zapt, oid_value ast);
-YAZ_EXPORT void yaz_log_zquery (Z_Query *q);
-YAZ_EXPORT void yaz_log_zquery_level (int loglevel, Z_Query *q);
+YAZ_EXPORT void yaz_log_zquery(Z_Query *q);
+YAZ_EXPORT void yaz_log_zquery_level(int loglevel, Z_Query *q);
-YAZ_EXPORT void wrbuf_put_zquery(WRBUF b, Z_Query *q);
-YAZ_EXPORT void wrbuf_scan_term (WRBUF b,
- Z_AttributesPlusTerm *zapt, oid_value ast);
YAZ_EXPORT void wrbuf_diags(WRBUF b, int num_diagnostics,Z_DiagRec **diags);
YAZ_END_CDECL
--- /dev/null
+/*
+ * Copyright (C) 1995-2005, Index Data ApS
+ * See the file LICENSE for details.
+ *
+ * $Id: querytowrbuf.h,v 1.1 2006-01-20 10:34:51 adam Exp $
+ */
+
+/**
+ * \file querytowrbuf.h
+ * \brief Query to WRBUF (to strings)
+ */
+
+#ifndef YAZ_QUERYTOWRBUF_H
+#define YAZ_QUERYTOWRBUF_H
+
+#include <yaz/yconfig.h>
+#include <yaz/proto.h>
+#include <yaz/wrbuf.h>
+
+YAZ_BEGIN_CDECL
+
+YAZ_EXPORT void yaz_query_to_wrbuf(WRBUF b, const Z_Query *q);
+YAZ_EXPORT void yaz_scan_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *zapt,
+ oid_value ast);
+YAZ_EXPORT void yaz_rpnquery_to_wrbuf(WRBUF b, const Z_RPNQuery *rpn);
+
+YAZ_END_CDECL
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
## This file is part of the YAZ toolkit.
## Copyright (C) 1994-2005, Index Data, All rights reserved.
-## $Id: Makefile.am,v 1.24 2005-11-29 20:25:38 adam Exp $
+## $Id: Makefile.am,v 1.25 2006-01-20 10:34:51 adam Exp $
YAZ_VERSION_INFO=2:0:0
opacdisp.c cclfind.c ccltoken.c cclerrms.c cclqual.c cclptree.c \
cclqfile.c cclstr.c \
cql.y cqlstdio.c cqltransform.c cqlutil.c xcqlutil.c cqlstring.c \
- cqlstrer.c \
+ cqlstrer.c querytowrbuf.c \
eventl.c seshigh.c statserv.c requestq.c tcpdchk.c \
eventl.h service.c service.h session.h
libyaz_la_LDFLAGS=-version-info $(YAZ_VERSION_INFO)
* Copyright (C) 1995-2005, Index Data ApS
* All rights reserved.
*
- * $Id: logrpn.c,v 1.13 2005-09-27 17:52:46 adam Exp $
+ * $Id: logrpn.c,v 1.14 2006-01-20 10:34:51 adam Exp $
*/
/**
#include <yaz/log.h>
#include <yaz/logrpn.h>
-
static const char *relToStr(int v)
{
const char *str = 0;
sprintf(str, "%d=%d", type, value);
}
-static void wrbuf_term(WRBUF b, const char *term, int len)
-{
- int i;
- for (i = 0; i < len; i++)
- if (strchr(" \"{", term[i]))
- break;
- if (i == len && i)
- wrbuf_printf(b, "%.*s ", len, term);
- else
- {
- wrbuf_putc(b, '"');
- for (i = 0; i<len; i++)
- {
- if (term[i] == '"')
- wrbuf_putc(b, '\\');
- wrbuf_putc(b, term[i]);
- }
- wrbuf_printf(b, "\" ");
- }
-}
-
-static void wrbuf_attr(WRBUF b, Z_AttributeElement *element)
-{
- int i;
- char *setname="";
- char *sep = ""; /* optional space after attrset name */
- if (element->attributeSet)
- {
- oident *attrset;
- attrset = oid_getentbyoid (element->attributeSet);
- setname = attrset->desc;
- sep = " ";
- }
- switch (element->which)
- {
- case Z_AttributeValue_numeric:
- wrbuf_printf(b,"@attr %s%s%d=%d ", setname, sep,
- *element->attributeType, *element->value.numeric);
- break;
- case Z_AttributeValue_complex:
- wrbuf_printf(b,"@attr %s%s\"%d=", setname, sep,
- *element->attributeType);
- for (i = 0; i<element->value.complex->num_list; i++)
- {
- if (i)
- wrbuf_printf(b,",");
- if (element->value.complex->list[i]->which ==
- Z_StringOrNumeric_string)
- wrbuf_printf (b, "%s",
- element->value.complex->list[i]->u.string);
- else if (element->value.complex->list[i]->which ==
- Z_StringOrNumeric_numeric)
- wrbuf_printf (b, "%d",
- *element->value.complex->list[i]->u.numeric);
- }
- wrbuf_printf(b, "\" ");
- break;
- default:
- wrbuf_printf (b, "@attr 1=unknown ");
- }
-}
-
/*
* zlog_attributes: print attributes of term
*/
yaz_log (loglevel, "%*.0s unknown structure", depth, "");
}
-static void wrbuf_apt(WRBUF b, Z_AttributesPlusTerm *zapt)
-{
- int num_attributes = zapt->attributes->num_attributes;
- int i;
- for (i = 0; i<num_attributes; i++)
- wrbuf_attr(b,zapt->attributes->attributes[i]);
-
- switch (zapt->term->which)
- {
- case Z_Term_general:
- wrbuf_term(b, (const char *)zapt->term->u.general->buf,
- zapt->term->u.general->len);
- break;
- case Z_Term_characterString:
- wrbuf_printf(b, "@term string ");
- wrbuf_term (b, zapt->term->u.characterString,
- strlen(zapt->term->u.characterString));
- break;
- case Z_Term_numeric:
- wrbuf_printf(b, "@term numeric %d ", *zapt->term->u.numeric);
- break;
- case Z_Term_null:
- wrbuf_printf(b, "@term null x");
- break;
- default:
- wrbuf_printf(b, "@term null unknown%d ", zapt->term->which);
- }
-}
-
-static void wrbuf_structure (WRBUF b, Z_RPNStructure *zs, enum oid_value ast)
-{
- if (zs->which == Z_RPNStructure_complex)
- {
- Z_Operator *op = zs->u.complex->roperator;
- wrbuf_printf(b, "@%s ", complex_op_name(op) );
- if (op->which== Z_Operator_prox)
- {
- if (!op->u.prox->exclusion)
- wrbuf_putc(b, 'n');
- else if (*op->u.prox->exclusion)
- wrbuf_putc(b, '1');
- else
- wrbuf_putc(b, '0');
-
- wrbuf_printf(b, " %d %d %d ", *op->u.prox->distance,
- *op->u.prox->ordered,
- *op->u.prox->relationType);
-
- switch(op->u.prox->which)
- {
- case Z_ProximityOperator_known:
- wrbuf_putc(b, 'k');
- break;
- case Z_ProximityOperator_private:
- wrbuf_putc(b, 'p');
- break;
- default:
- wrbuf_printf(b, "%d", op->u.prox->which);
- }
- if (op->u.prox->u.known)
- wrbuf_printf(b, " %d ", *op->u.prox->u.known);
- else
- wrbuf_printf(b, " 0 ");
- }
- wrbuf_structure (b,zs->u.complex->s1, ast);
- wrbuf_structure (b,zs->u.complex->s2, ast);
- }
- else if (zs->which == Z_RPNStructure_simple)
- {
- if (zs->u.simple->which == Z_Operand_APT)
- wrbuf_apt(b, zs->u.simple->u.attributesPlusTerm);
- else if (zs->u.simple->which == Z_Operand_resultSetId)
- {
- wrbuf_printf(b, "@set ");
- wrbuf_term(b, zs->u.simple->u.resultSetId,
- strlen(zs->u.simple->u.resultSetId));
- }
- else
- wrbuf_printf (b, "(unknown simple structure)");
- }
- else
- wrbuf_puts(b, "(unknown structure)");
-}
-
void log_rpn_query_level (int loglevel, Z_RPNQuery *rpn)
{
oident *attrset;
zlog_structure (rpn->RPNStructure, 0, ast, loglevel);
}
-static void wrbuf_rpn_query(WRBUF b, Z_RPNQuery *rpn)
-{
- oident *attrset;
- enum oid_value ast;
-
- attrset = oid_getentbyoid (rpn->attributeSetId);
- if (attrset)
- {
- ast = attrset->value;
- wrbuf_printf(b, " @attrset %s ", attrset->desc);
- }
- wrbuf_structure (b, rpn->RPNStructure, ast);
- wrbuf_chop_right(b);
-}
-
void log_rpn_query(Z_RPNQuery *rpn)
{
log_rpn_query_level(YLOG_LOG, rpn);
log_scan_term_level (YLOG_LOG, zapt, ast);
}
-void wrbuf_scan_term(WRBUF b, Z_AttributesPlusTerm *zapt, oid_value ast)
-{
- wrbuf_apt(b, zapt);
-}
-
void yaz_log_zquery_level (int loglevel, Z_Query *q)
{
if (!loglevel)
yaz_log_zquery_level(YLOG_LOG, q);
}
-void wrbuf_put_zquery(WRBUF b, Z_Query *q)
-{
- assert(q);
- assert(b);
- switch (q->which)
- {
- case Z_Query_type_1:
- case Z_Query_type_101:
- wrbuf_printf(b,"RPN:");
- wrbuf_rpn_query(b, q->u.type_1);
- break;
- case Z_Query_type_2:
- wrbuf_printf(b, "CCL: %.*s", q->u.type_2->len, q->u.type_2->buf);
- break;
- case Z_Query_type_100:
- wrbuf_printf(b, "Z39.58: %.*s", q->u.type_100->len,
- q->u.type_100->buf);
- break;
- case Z_Query_type_104:
- if (q->u.type_104->which == Z_External_CQL)
- wrbuf_printf(b, "CQL: %s", q->u.type_104->u.cql);
- else
- wrbuf_printf(b,"Unknown type 104 query %d", q->u.type_104->which);
- }
-}
-
void wrbuf_diags(WRBUF b, int num_diagnostics,Z_DiagRec **diags)
{
/* we only dump the first diag - that keeps the log cleaner. */
--- /dev/null
+/*
+ * Copyright (C) 1995-2005, Index Data ApS
+ * All rights reserved.
+ *
+ * $Id: querytowrbuf.c,v 1.1 2006-01-20 10:34:51 adam Exp $
+ */
+
+/**
+ * \file querytostr.c
+ * \brief Query to WRBUF (to strings)
+ */
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <yaz/querytowrbuf.h>
+
+static void yaz_term_to_wrbuf(WRBUF b, const char *term, int len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ if (strchr(" \"{", term[i]))
+ break;
+ if (i == len && i)
+ wrbuf_printf(b, "%.*s ", len, term);
+ else
+ {
+ wrbuf_putc(b, '"');
+ for (i = 0; i<len; i++)
+ {
+ if (term[i] == '"')
+ wrbuf_putc(b, '\\');
+ wrbuf_putc(b, term[i]);
+ }
+ wrbuf_printf(b, "\" ");
+ }
+}
+
+static void yaz_attribute_element_to_wrbuf(WRBUF b,
+ const Z_AttributeElement *element)
+{
+ int i;
+ char *setname="";
+ char *sep = ""; /* optional space after attrset name */
+ if (element->attributeSet)
+ {
+ oident *attrset;
+ attrset = oid_getentbyoid (element->attributeSet);
+ setname = attrset->desc;
+ sep = " ";
+ }
+ switch (element->which)
+ {
+ case Z_AttributeValue_numeric:
+ wrbuf_printf(b,"@attr %s%s%d=%d ", setname, sep,
+ *element->attributeType, *element->value.numeric);
+ break;
+ case Z_AttributeValue_complex:
+ wrbuf_printf(b,"@attr %s%s\"%d=", setname, sep,
+ *element->attributeType);
+ for (i = 0; i<element->value.complex->num_list; i++)
+ {
+ if (i)
+ wrbuf_printf(b,",");
+ if (element->value.complex->list[i]->which ==
+ Z_StringOrNumeric_string)
+ wrbuf_printf (b, "%s",
+ element->value.complex->list[i]->u.string);
+ else if (element->value.complex->list[i]->which ==
+ Z_StringOrNumeric_numeric)
+ wrbuf_printf (b, "%d",
+ *element->value.complex->list[i]->u.numeric);
+ }
+ wrbuf_printf(b, "\" ");
+ break;
+ default:
+ wrbuf_printf (b, "@attr 1=unknown ");
+ }
+}
+
+static const char *complex_op_name(const Z_Operator *op)
+{
+ switch (op->which)
+ {
+ case Z_Operator_and:
+ return "and";
+ case Z_Operator_or:
+ return "or";
+ case Z_Operator_and_not:
+ return "not";
+ case Z_Operator_prox:
+ return "prox";
+ default:
+ return "unknown complex operator";
+ }
+}
+
+static void yaz_apt_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *zapt)
+{
+ int num_attributes = zapt->attributes->num_attributes;
+ int i;
+ for (i = 0; i<num_attributes; i++)
+ yaz_attribute_element_to_wrbuf(b,zapt->attributes->attributes[i]);
+
+ switch (zapt->term->which)
+ {
+ case Z_Term_general:
+ yaz_term_to_wrbuf(b, (const char *)zapt->term->u.general->buf,
+ zapt->term->u.general->len);
+ break;
+ case Z_Term_characterString:
+ wrbuf_printf(b, "@term string ");
+ yaz_term_to_wrbuf(b, zapt->term->u.characterString,
+ strlen(zapt->term->u.characterString));
+ break;
+ case Z_Term_numeric:
+ wrbuf_printf(b, "@term numeric %d ", *zapt->term->u.numeric);
+ break;
+ case Z_Term_null:
+ wrbuf_printf(b, "@term null x");
+ break;
+ default:
+ wrbuf_printf(b, "@term null unknown%d ", zapt->term->which);
+ }
+}
+
+static void yaz_rpnstructure_to_wrbuf(WRBUF b, const Z_RPNStructure *zs)
+{
+ if (zs->which == Z_RPNStructure_complex)
+ {
+ Z_Operator *op = zs->u.complex->roperator;
+ wrbuf_printf(b, "@%s ", complex_op_name(op) );
+ if (op->which== Z_Operator_prox)
+ {
+ if (!op->u.prox->exclusion)
+ wrbuf_putc(b, 'n');
+ else if (*op->u.prox->exclusion)
+ wrbuf_putc(b, '1');
+ else
+ wrbuf_putc(b, '0');
+
+ wrbuf_printf(b, " %d %d %d ", *op->u.prox->distance,
+ *op->u.prox->ordered,
+ *op->u.prox->relationType);
+
+ switch(op->u.prox->which)
+ {
+ case Z_ProximityOperator_known:
+ wrbuf_putc(b, 'k');
+ break;
+ case Z_ProximityOperator_private:
+ wrbuf_putc(b, 'p');
+ break;
+ default:
+ wrbuf_printf(b, "%d", op->u.prox->which);
+ }
+ if (op->u.prox->u.known)
+ wrbuf_printf(b, " %d ", *op->u.prox->u.known);
+ else
+ wrbuf_printf(b, " 0 ");
+ }
+ yaz_rpnstructure_to_wrbuf(b,zs->u.complex->s1);
+ yaz_rpnstructure_to_wrbuf(b,zs->u.complex->s2);
+ }
+ else if (zs->which == Z_RPNStructure_simple)
+ {
+ if (zs->u.simple->which == Z_Operand_APT)
+ yaz_apt_to_wrbuf(b, zs->u.simple->u.attributesPlusTerm);
+ else if (zs->u.simple->which == Z_Operand_resultSetId)
+ {
+ wrbuf_printf(b, "@set ");
+ yaz_term_to_wrbuf(b, zs->u.simple->u.resultSetId,
+ strlen(zs->u.simple->u.resultSetId));
+ }
+ else
+ wrbuf_printf (b, "(unknown simple structure)");
+ }
+ else
+ wrbuf_puts(b, "(unknown structure)");
+}
+
+void yaz_rpnquery_to_wrbuf(WRBUF b, const Z_RPNQuery *rpn)
+{
+ oident *attrset;
+ enum oid_value ast;
+
+ attrset = oid_getentbyoid (rpn->attributeSetId);
+ if (attrset)
+ {
+ ast = attrset->value;
+ wrbuf_printf(b, " @attrset %s ", attrset->desc);
+ }
+ yaz_rpnstructure_to_wrbuf(b, rpn->RPNStructure);
+ wrbuf_chop_right(b);
+}
+
+void yaz_query_to_wrbuf(WRBUF b, const Z_Query *q)
+{
+ assert(q);
+ assert(b);
+ switch (q->which)
+ {
+ case Z_Query_type_1:
+ case Z_Query_type_101:
+ wrbuf_printf(b,"RPN:");
+ yaz_rpnquery_to_wrbuf(b, q->u.type_1);
+ break;
+ case Z_Query_type_2:
+ wrbuf_printf(b, "CCL: %.*s", q->u.type_2->len, q->u.type_2->buf);
+ break;
+ case Z_Query_type_100:
+ wrbuf_printf(b, "Z39.58: %.*s", q->u.type_100->len,
+ q->u.type_100->buf);
+ break;
+ case Z_Query_type_104:
+ if (q->u.type_104->which == Z_External_CQL)
+ wrbuf_printf(b, "CQL: %s", q->u.type_104->u.cql);
+ else
+ wrbuf_printf(b,"Unknown type 104 query %d", q->u.type_104->which);
+ }
+}
+
+void yaz_scan_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *zapt,
+ oid_value ast)
+{
+ /* should print attr set here */
+ yaz_apt_to_wrbuf(b, zapt);
+}
+
+/* obsolete */
+void wrbuf_scan_term(WRBUF b, const Z_AttributesPlusTerm *zapt, oid_value ast)
+{
+ yaz_apt_to_wrbuf(b, zapt);
+}
+
+/* obsolete */
+void wrbuf_put_zquery(WRBUF b, const Z_Query *q)
+{
+ yaz_query_to_wrbuf(b, q);
+}
+
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: seshigh.c,v 1.65 2005-11-09 17:47:11 adam Exp $
+ * $Id: seshigh.c,v 1.66 2006-01-20 10:34:51 adam Exp $
*/
/**
* \file seshigh.c
#include <yaz/oid.h>
#include <yaz/log.h>
#include <yaz/logrpn.h>
+#include <yaz/querytowrbuf.h>
#include <yaz/statserv.h>
#include <yaz/diagbib1.h>
#include <yaz/charneg.h>
assoc->init->implementation_name,
odr_prepend(assoc->encode, "GFS", resp->implementationName));
- version = odr_strdup(assoc->encode, "$Revision: 1.65 $");
+ version = odr_strdup(assoc->encode, "$Revision: 1.66 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
resp->implementationVersion = odr_prepend(assoc->encode,
wrbuf_printf(wr, "OK %d", bsrt->hits);
wrbuf_printf(wr, " %s 1+%d ",
req->resultSetName, returnedrecs);
- wrbuf_put_zquery(wr, req->query);
+ yaz_query_to_wrbuf(wr, req->query);
yaz_log(log_request, "Search %s", wrbuf_buf(wr));
wrbuf_free(wr, 1);
*req->preferredPositionInResponse : 1),
*req->numberOfTermsRequested,
(res->stepSize ? *res->stepSize : 0));
- wrbuf_scan_term(wr, req->termListAndStartPoint,
- bsrr->attributeset);
-
+ yaz_scan_to_wrbuf(wr, req->termListAndStartPoint,
+ bsrr->attributeset);
yaz_log(log_request, "Scan %s", wrbuf_buf(wr) );
wrbuf_free(wr, 1);
}
* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: srw.c,v 1.41 2005-11-28 13:21:38 adam Exp $
+ * $Id: srw.c,v 1.42 2006-01-20 10:34:52 adam Exp $
*/
/**
* \file srw.c
else if ((*p)->which == Z_SRW_update_response)
{
Z_SRW_updateResponse *res = (*p)->u.update_response;
- xmlNodePtr ptr = xmlNewChild(pptr, 0, "updateResponse", 0);
+ xmlNodePtr ptr = xmlNewChild(pptr, 0, (xmlChar *)
+ "updateResponse", 0);
ns_srw = xmlNewNs(ptr, ns, "zu");
xmlSetNs(ptr, ns_srw);
# Copyright (C) 1994-2005, Index Data ApS
# All rights reserved.
-# $Id: makefile,v 1.97 2005-11-29 20:40:33 adam Exp $
+# $Id: makefile,v 1.98 2006-01-20 10:34:52 adam Exp $
#
# Programmed by
# Heikki Levanto & Adam Dickmeiss
$(OBJDIR)\diag-entry.obj \
$(OBJDIR)\zget.obj \
$(OBJDIR)\logrpn.obj \
+ $(OBJDIR)\querytowrbuf.obj \
$(OBJDIR)\pquery.obj \
$(OBJDIR)\yaz-ccl.obj \
$(OBJDIR)\otherinfo.obj \