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
Utility to map between Bib-1 and SRW diagnostics.
[yaz-moved-to-github.git]
/
zutil
/
zoom-c.c
diff --git
a/zutil/zoom-c.c
b/zutil/zoom-c.c
index
9a9e9da
..
72e7354
100644
(file)
--- a/
zutil/zoom-c.c
+++ b/
zutil/zoom-c.c
@@
-2,7
+2,7
@@
* Copyright (c) 2000-2003, Index Data
* See the file LICENSE for details.
*
* Copyright (c) 2000-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.20 2003-02-17 14:35:42 adam Exp $
+ * $Id: zoom-c.c,v 1.25 2003-02-19 15:22:11 adam Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
*
* ZOOM layer for C, connections, result sets, queries.
*/
@@
-100,7
+100,7
@@
static void set_dset_error (ZOOM_connection c, int error,
else if (addinfo)
c->addinfo = xstrdup(addinfo);
if (error)
else if (addinfo)
c->addinfo = xstrdup(addinfo);
if (error)
- yaz_log(LOG_LOG, "Error %s %s:%d %s %s",
+ yaz_log(LOG_DEBUG, "Error %s %s:%d %s %s",
c->host_port ? c->host_port : "<>", dset, error,
addinfo ? addinfo : "",
addinfo2 ? addinfo2 : "");
c->host_port ? c->host_port : "<>", dset, error,
addinfo ? addinfo : "",
addinfo2 ? addinfo2 : "");
@@
-109,13
+109,13
@@
static void set_dset_error (ZOOM_connection c, int error,
static void set_HTTP_error (ZOOM_connection c, int error,
const char *addinfo, const char *addinfo2)
{
static void set_HTTP_error (ZOOM_connection c, int error,
const char *addinfo, const char *addinfo2)
{
- return set_dset_error(c, error, "HTTP", addinfo, addinfo2);
+ set_dset_error(c, error, "HTTP", addinfo, addinfo2);
}
static void set_ZOOM_error (ZOOM_connection c, int error,
const char *addinfo)
{
}
static void set_ZOOM_error (ZOOM_connection c, int error,
const char *addinfo)
{
- return set_dset_error(c, error, "ZOOM", addinfo, 0);
+ set_dset_error(c, error, "ZOOM", addinfo, 0);
}
static void clear_error (ZOOM_connection c)
}
static void clear_error (ZOOM_connection c)
@@
-347,7
+347,6
@@
ZOOM_connection_connect(ZOOM_connection c,
c->lang = 0;
xfree (c->host_port);
c->lang = 0;
xfree (c->host_port);
- xfree (c->path);
if (portnum)
{
char hostn[128];
if (portnum)
{
char hostn[128];
@@
-466,6
+465,7
@@
ZOOM_connection_destroy(ZOOM_connection c)
ZOOM_options_destroy (c->options);
ZOOM_connection_remove_tasks (c);
xfree (c->host_port);
ZOOM_options_destroy (c->options);
ZOOM_connection_remove_tasks (c);
xfree (c->host_port);
+ xfree (c->path);
xfree (c->proxy);
xfree (c->charset);
xfree (c->lang);
xfree (c->proxy);
xfree (c->charset);
xfree (c->lang);
@@
-641,6
+641,20
@@
static void ZOOM_resultset_retrieve (ZOOM_resultset r,
c = r->connection;
if (!c)
return;
c = r->connection;
if (!c)
return;
+
+ if (c->host_port && c->proto == PROTO_SRW)
+ {
+ if (!c->cs)
+ {
+ yaz_log(LOG_DEBUG, "NO COMSTACK");
+ ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
+ }
+ else
+ {
+ yaz_log(LOG_DEBUG, "PREPARE FOR RECONNECT");
+ c->reconnect_ok = 1;
+ }
+ }
task = ZOOM_connection_add_task (c, ZOOM_TASK_RETRIEVE);
task->u.retrieve.resultset = r;
task->u.retrieve.start = start;
task = ZOOM_connection_add_task (c, ZOOM_TASK_RETRIEVE);
task->u.retrieve.resultset = r;
task->u.retrieve.start = start;
@@
-698,7
+712,7
@@
static zoom_ret do_connect (ZOOM_connection c)
if (memcmp(c->host_port, "http:", 5) == 0)
{
if (memcmp(c->host_port, "http:", 5) == 0)
{
-#if HAVE_XSLT
+#if HAVE_XML2
const char *path;
c->proto = PROTO_SRW;
effective_host = c->host_port + 5;
const char *path;
c->proto = PROTO_SRW;
effective_host = c->host_port + 5;
@@
-840,7
+854,6
@@
static int encode_APDU(ZOOM_connection c, Z_APDU *a, ODR out)
static zoom_ret send_APDU (ZOOM_connection c, Z_APDU *a)
{
ZOOM_Event event;
static zoom_ret send_APDU (ZOOM_connection c, Z_APDU *a)
{
ZOOM_Event event;
- yaz_log(LOG_LOG, "sending Z39.50 APDU");
assert (a);
if (encode_APDU(c, a, c->odr_out))
return zoom_complete;
assert (a);
if (encode_APDU(c, a, c->odr_out))
return zoom_complete;
@@
-962,7
+975,7
@@
static zoom_ret ZOOM_connection_send_init (ZOOM_connection c)
return send_APDU (c, apdu);
}
return send_APDU (c, apdu);
}
-#if HAVE_XSLT
+#if HAVE_XML2
static zoom_ret send_srw (ZOOM_connection c, Z_SRW_searchRetrieve *sr)
{
Z_SOAP_Handler h[2] = {
static zoom_ret send_srw (ZOOM_connection c, Z_SRW_searchRetrieve *sr)
{
Z_SOAP_Handler h[2] = {
@@
-1005,7
+1018,7
@@
static zoom_ret send_srw (ZOOM_connection c, Z_SRW_searchRetrieve *sr)
}
#endif
}
#endif
-#if HAVE_XSLT
+#if HAVE_XML2
static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
{
int i;
static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
{
int i;
@@
-1016,7
+1029,11
@@
static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
return zoom_complete;
assert (c->tasks);
if (c->tasks->which == ZOOM_TASK_SEARCH)
return zoom_complete;
assert (c->tasks);
if (c->tasks->which == ZOOM_TASK_SEARCH)
+ {
resultset = c->tasks->u.search.resultset;
resultset = c->tasks->u.search.resultset;
+ resultset->setname = xstrdup ("default");
+ ZOOM_options_set (resultset->options, "setname", resultset->setname);
+ }
else if(c->tasks->which == ZOOM_TASK_RETRIEVE)
{
resultset = c->tasks->u.retrieve.resultset;
else if(c->tasks->which == ZOOM_TASK_RETRIEVE)
{
resultset = c->tasks->u.retrieve.resultset;
@@
-1046,9
+1063,10
@@
static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
if (resultset->z_query->which == Z_Query_type_104
&& resultset->z_query->u.type_104->which == Z_External_CQL)
sr->u.request->query = resultset->z_query->u.type_104->u.cql;
if (resultset->z_query->which == Z_Query_type_104
&& resultset->z_query->u.type_104->which == Z_External_CQL)
sr->u.request->query = resultset->z_query->u.type_104->u.cql;
- else if (resultset->z_query->which == Z_Query_type_1)
- {
- set_ZOOM_error(c, ZOOM_ERROR_UNSUPPORTED_QUERY, "Type-1");
+ else if (resultset->z_query->which == Z_Query_type_1 &&
+ resultset->z_query->u.type_1)
+ {
+ set_ZOOM_error(c, ZOOM_ERROR_UNSUPPORTED_QUERY, 0);
return zoom_complete;
}
else
return zoom_complete;
}
else
@@
-1060,8
+1078,6
@@
static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
sr->u.request->maximumRecords = odr_intdup (c->odr_out, resultset->count);
sr->u.request->recordSchema = resultset->schema;
sr->u.request->maximumRecords = odr_intdup (c->odr_out, resultset->count);
sr->u.request->recordSchema = resultset->schema;
- resultset->setname = xstrdup ("default");
- ZOOM_options_set (resultset->options, "setname", resultset->setname);
return send_srw(c, sr);
}
return send_srw(c, sr);
}
@@
-1757,15
+1773,15
@@
static zoom_ret send_present (ZOOM_connection c)
compo->u.complex->generic = (Z_Specification *)
odr_malloc(c->odr_out, sizeof(*compo->u.complex->generic));
compo->u.complex->generic = (Z_Specification *)
odr_malloc(c->odr_out, sizeof(*compo->u.complex->generic));
- compo->u.complex->generic->which = Z_Specification_oid;
- compo->u.complex->generic->u.oid = (Odr_oid *)
+ compo->u.complex->generic->which = Z_Schema_oid;
+ compo->u.complex->generic->schema.oid = (Odr_oid *)
yaz_str_to_z3950oid (c->odr_out, CLASS_SCHEMA, resultset->schema);
yaz_str_to_z3950oid (c->odr_out, CLASS_SCHEMA, resultset->schema);
- if (!compo->u.complex->generic->u.oid)
+ if (!compo->u.complex->generic->schema.oid)
{
/* OID wasn't a schema! Try record syntax instead. */
{
/* OID wasn't a schema! Try record syntax instead. */
- compo->u.complex->generic->u.oid = (Odr_oid *)
+ compo->u.complex->generic->schema.oid = (Odr_oid *)
yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, resultset->schema);
}
if (elementSetName && *elementSetName)
yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, resultset->schema);
}
if (elementSetName && *elementSetName)
@@
-2376,7
+2392,7
@@
static void handle_apdu (ZOOM_connection c, Z_APDU *apdu)
}
}
}
}
-#if HAVE_XSLT
+#if HAVE_XML2
static void handle_srw_response(ZOOM_connection c,
Z_SRW_searchRetrieveResponse *res)
{
static void handle_srw_response(ZOOM_connection c,
Z_SRW_searchRetrieveResponse *res)
{
@@
-2396,7
+2412,7
@@
static void handle_srw_response(ZOOM_connection c,
resultset->size = 0;
resultset->size = 0;
- yaz_log(LOG_LOG, "got SRW response OK");
+ yaz_log(LOG_DEBUG, "got SRW response OK");
if (res->numberOfRecords)
resultset->size = *res->numberOfRecords;
if (res->numberOfRecords)
resultset->size = *res->numberOfRecords;
@@
-2430,7
+2446,6
@@
static void handle_srw_response(ZOOM_connection c,
npr->u.databaseRecord->u.octet_aligned->size =
res->records[i].recordData_len;
record_cache_add (resultset, npr, pos);
npr->u.databaseRecord->u.octet_aligned->size =
res->records[i].recordData_len;
record_cache_add (resultset, npr, pos);
- yaz_log(LOG_LOG, "add SRW record to cache to pos %d", pos);
}
if (res->num_diagnostics > 0)
{
}
if (res->num_diagnostics > 0)
{
@@
-2443,7
+2458,7
@@
static void handle_srw_response(ZOOM_connection c,
}
#endif
}
#endif
-#if HAVE_XSLT
+#if HAVE_XML2
static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres)
{
int ret = -1;
static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres)
{
int ret = -1;
@@
-2557,7
+2572,7
@@
static int do_read (ZOOM_connection c)
handle_apdu (c, gdu->u.z3950);
else if (gdu->which == Z_GDU_HTTP_Response)
{
handle_apdu (c, gdu->u.z3950);
else if (gdu->which == Z_GDU_HTTP_Response)
{
-#if HAVE_XSLT
+#if HAVE_XML2
handle_http (c, gdu->u.HTTP_Response);
#else
set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0);
handle_http (c, gdu->u.HTTP_Response);
#else
set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0);
@@
-2587,7
+2602,7
@@
static zoom_ret do_write_ex (ZOOM_connection c, char *buf_out, int len_out)
yaz_log (LOG_DEBUG, "reconnect write");
c->tasks->running = 0;
ZOOM_connection_insert_task (c, ZOOM_TASK_CONNECT);
yaz_log (LOG_DEBUG, "reconnect write");
c->tasks->running = 0;
ZOOM_connection_insert_task (c, ZOOM_TASK_CONNECT);
- return zoom_complete;
+ return zoom_pending;
}
if (c->state == STATE_CONNECTING)
set_ZOOM_error(c, ZOOM_ERROR_CONNECT, 0);
}
if (c->state == STATE_CONNECTING)
set_ZOOM_error(c, ZOOM_ERROR_CONNECT, 0);
@@
-2714,7
+2729,7
@@
ZOOM_connection_error_x (ZOOM_connection c, const char **cp,
else if (!strcmp(c->diagset, "Bib-1"))
*cp = ZOOM_diag_str(error);
else if (!strcmp(c->diagset, "SRW"))
else if (!strcmp(c->diagset, "Bib-1"))
*cp = ZOOM_diag_str(error);
else if (!strcmp(c->diagset, "SRW"))
- *cp = yaz_srw_error_str(c->error);
+ *cp = yaz_diag_srw_str(c->error);
else
*cp = "Unknown error and diagnostic set";
}
else
*cp = "Unknown error and diagnostic set";
}