Possible compatibility problems with earlier versions marked with '*'.
---- IN PROGRESS
+Added support for SRW scan in yaz-client.
+
+* Changed Z_SRW_scanRequest to be able to carry both CCL and PQF.
Fixed NMEM system to return aligned blocks on the smallest boundaries
that are suitably aligned for all possible types on the particular
* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.264 2005-01-02 20:31:39 adam Exp $
+ * $Id: client.c,v 1.265 2005-01-08 01:20:18 adam Exp $
*/
#include <stdio.h>
#endif
#if HAVE_XML2
+static int send_SRW_scanRequest(const char *arg, int num, int pos)
+{
+ Z_SRW_PDU *sr = 0;
+
+ /* regular request .. */
+ sr = yaz_srw_get(out, Z_SRW_scan_request);
+
+ switch(queryType)
+ {
+ case QueryType_CQL:
+ sr->u.scan_request->query_type = Z_SRW_query_type_cql;
+ sr->u.scan_request->scanClause.cql = odr_strdup(out, arg);
+ break;
+ case QueryType_Prefix:
+ sr->u.scan_request->query_type = Z_SRW_query_type_pqf;
+ sr->u.scan_request->scanClause.pqf = odr_strdup(out, arg);
+ break;
+ default:
+ printf ("Only CQL and PQF supported in SRW\n");
+ return 0;
+ }
+ sr->u.scan_request->responsePosition = odr_intdup(out, pos);
+ sr->u.scan_request->maximumTerms = odr_intdup(out, num);
+ return send_srw(sr);
+}
+
static int send_SRW_searchRequest(const char *arg)
{
Z_SRW_PDU *sr = 0;
int cmd_scan(const char *arg)
{
- if (only_z3950())
- return 0;
- if (!conn)
+ if (protocol == PROTO_HTTP)
{
- try_reconnect();
-
- if (!conn) {
- printf("Session not initialized yet\n");
+#if HAVE_XML2
+ if (!conn)
+ cmd_open(0);
+ if (!conn)
+ return 0;
+ if (send_SRW_scanRequest(arg, 20, 0) < 0)
return 0;
- }
- }
- if (!ODR_MASK_GET(session->options, Z_Options_scan))
- {
- printf("Target doesn't support scan\n");
+ return 2;
+#else
return 0;
- }
- if (*arg)
- {
- strcpy (last_scan_query, arg);
- if (send_scanrequest(arg, scan_position, 20, 0) < 0)
- return 0;
+#endif
}
else
{
- if (send_scanrequest(last_scan_query, 1, 20, last_scan_line) < 0)
- return 0;
+ if (!conn)
+ {
+ try_reconnect();
+
+ if (!conn) {
+ printf("Session not initialized yet\n");
+ return 0;
+ }
+ }
+ if (!ODR_MASK_GET(session->options, Z_Options_scan))
+ {
+ printf("Target doesn't support scan\n");
+ return 0;
+ }
+ if (*arg)
+ {
+ strcpy (last_scan_query, arg);
+ if (send_scanrequest(arg, scan_position, 20, 0) < 0)
+ return 0;
+ }
+ else
+ {
+ if (send_scanrequest(last_scan_query, 1, 20, last_scan_line) < 0)
+ return 0;
+ }
+ return 2;
}
- return 2;
}
int cmd_schema(const char *arg)
handle_srw_record(res->records + i);
}
+static void handle_srw_scan_term(Z_SRW_scanTerm *term)
+{
+ if (term->displayTerm)
+ printf ("%s: ", term->displayTerm);
+ if (term->value)
+ printf ("%s: ", term->value);
+ if (term->numberOfRecords)
+ printf ("%d", *term->numberOfRecords);
+ printf("\n");
+}
+
+static void handle_srw_scan_response(Z_SRW_scanResponse *res)
+{
+ int i;
+
+ printf ("Received SRW Scan Response\n");
+
+ for (i = 0; i<res->num_diagnostics; i++)
+ {
+ if (res->diagnostics[i].uri)
+ printf ("SRW diagnostic %s\n",
+ res->diagnostics[i].uri);
+ else
+ printf ("SRW diagnostic missing or could not be decoded\n");
+ if (res->diagnostics[i].message)
+ printf ("Message: %s\n", res->diagnostics[i].message);
+ if (res->diagnostics[i].details)
+ printf ("Details: %s\n", res->diagnostics[i].details);
+ }
+ if (res->terms)
+ for (i = 0; i<res->num_terms; i++)
+ handle_srw_scan_term(res->terms + i);
+}
+
static void http_response(Z_HTTP_Response *hres)
{
int ret = -1;
handle_srw_response(sr->u.response);
else if (sr->which == Z_SRW_explain_response)
handle_srw_explain_response(sr->u.explain_response);
+ else if (sr->which == Z_SRW_scan_response)
+ handle_srw_scan_response(sr->u.scan_response);
else
ret = -1;
}
dnl YAZ Toolkit, Index Data 1994-2004
dnl See the file LICENSE for details.
-dnl $Id: configure.in,v 1.165 2005-01-05 10:23:41 adam Exp $
+dnl $Id: configure.in,v 1.166 2005-01-08 01:20:18 adam Exp $
AC_INIT(include/yaz/yaz-version.h)
AM_INIT_AUTOMAKE(yaz, 2.0.31)
AM_MAINTAINER_MODE
dnl
YAZ_DOC
dnl
+dnl
+dnl ------ Headers
+AC_CHECK_HEADERS(fnmatch.h wchar.h locale.h langinfo.h)
+AC_HEADER_STDC
+if test "$ac_cv_header_stdc" = "no"; then
+ AC_MSG_WARN(Your system doesn't seem to support ANSI C)
+fi
dnl ----- Types
AC_CHECK_TYPES([long long])
dnl
fi
fi
dnl
-dnl ------ Headers
-AC_CHECK_HEADERS(fnmatch.h wchar.h locale.h langinfo.h)
-AC_STDC_HEADERS
-if test "$ac_cv_header_stdc" = "no"; then
- AC_MSG_WARN(Your system doesn't seem to support ANSI C)
-fi
-dnl
AC_SUBST(LIBTHREAD)
AC_SUBST(CFLAGSTHREADS)
HAVETHREADS=0
* Copyright (c) 2002-2004, Index Data.
* See the file LICENSE for details.
*
- * $Id: srw.h,v 1.17 2004-10-15 00:18:59 adam Exp $
+ * $Id: srw.h,v 1.18 2005-01-08 01:20:18 adam Exp $
*/
/**
* \file srw.h
} Z_SRW_explainResponse;
typedef struct {
- char *scanClause;
+ int query_type;
+ union {
+ char *cql;
+ char *xcql;
+ char *pqf;
+ } scanClause;
int *responsePosition;
int *maximumTerms;
char *stylesheet;
* Copyright (c) 2002-2004, Index Data.
* See the file LICENSE for details.
*
- * $Id: srw.c,v 1.28 2004-10-31 19:23:22 adam Exp $
+ * $Id: srw.c,v 1.29 2005-01-08 01:20:19 adam Exp $
*/
/**
* \file srw.c
(*p)->which = Z_SRW_scan_request;
req = (*p)->u.scan_request = (Z_SRW_scanRequest *)
odr_malloc(o, sizeof(*req));
- req->database = 0;
- req->scanClause = 0;
- req->stylesheet = 0;
+ req->query_type = Z_SRW_query_type_cql;
+ req->scanClause.cql = 0;
req->responsePosition = 0;
req->maximumTerms = 0;
+ req->stylesheet = 0;
+ req->database = 0;
for (; ptr; ptr = ptr->next)
{
&(*p)->srw_version))
;
else if (match_xsd_string(ptr, "scanClause", o,
- &req->scanClause))
+ &req->scanClause.cql))
;
else if (match_xsd_integer(ptr, "responsePosition", o,
&req->responsePosition))
xmlSetNs(ptr, ns_srw);
add_xsd_string(ptr, "version", (*p)->srw_version);
- add_xsd_string(ptr, "scanClause", req->scanClause);
+ switch(req->query_type)
+ {
+ case Z_SRW_query_type_cql:
+ add_xsd_string(ptr, "scanClause", req->scanClause.cql);
+ break;
+ case Z_SRW_query_type_pqf:
+ add_xsd_string(ptr, "pScanClause", req->scanClause.pqf);
+ break;
+ }
add_xsd_integer(ptr, "responsePosition", req->responsePosition);
add_xsd_integer(ptr, "maximumTerms", req->maximumTerms);
add_xsd_string(ptr, "stylesheet", req->stylesheet);
* Copyright (c) 2002-2004, Index Data.
* See the file LICENSE for details.
*
- * $Id: srwutil.c,v 1.19 2004-11-21 21:56:28 adam Exp $
+ * $Id: srwutil.c,v 1.20 2005-01-08 01:20:19 adam Exp $
*/
/**
* \file srwutil.c
char *sortKeys = 0;
char *stylesheet = 0;
char *scanClause = 0;
+ char *pScanClause = 0;
char *recordXPath = 0;
char *recordSchema = 0;
char *recordPacking = "xml"; /* xml packing is default for SRU */
version = v;
else if (!strcmp(n, "scanClause"))
scanClause = v;
+ else if (!strcmp(n, "x-ScanClause"))
+ pScanClause = v;
else if (!strcmp(n, "maximumRecords"))
maximumRecords = v;
else if (!strcmp(n, "startRecord"))
{
Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_scan_request);
- if (!scanClause)
+ if (scanClause)
+ {
+ sr->u.scan_request->query_type = Z_SRW_query_type_cql;
+ sr->u.scan_request->scanClause.cql = scanClause;
+ }
+ else if (pScanClause)
+ {
+ sr->u.scan_request->query_type = Z_SRW_query_type_pqf;
+ sr->u.scan_request->scanClause.pqf = pScanClause;
+ }
+ else
yaz_add_srw_diagnostic(decode, diag, num_diag, 7,
"scanClause");
sr->srw_version = version;
*srw_pdu = sr;
- sr->u.scan_request->scanClause = scanClause;
sr->u.scan_request->database = db;
sr->u.scan_request->stylesheet = stylesheet;
sr->u.scan_request->stylesheet = 0;
sr->u.scan_request->maximumTerms = 0;
sr->u.scan_request->responsePosition = 0;
- sr->u.scan_request->scanClause = 0;
+ sr->u.scan_request->query_type = Z_SRW_query_type_cql;
+ sr->u.scan_request->scanClause.cql = 0;
break;
case Z_SRW_scan_response:
sr->u.scan_response = (Z_SRW_scanResponse *)