* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: srw.c,v 1.2 2003-02-14 18:49:24 adam Exp $
+ * $Id: srw.c,v 1.3 2003-02-17 14:35:42 adam Exp $
*/
#include <yaz/srw.h>
struct _xmlAttr *attr;
if (!match_element(ptr, elem))
return 0;
+#if 0
for (attr = ptr->properties; attr; attr = attr->next)
if (!strcmp(attr->name, "type") &&
attr->children && attr->children->type == XML_TEXT_NODE)
}
if (!attr)
return 0;
+#endif
ptr = ptr->children;
if (!ptr || ptr->type != XML_TEXT_NODE)
return 0;
struct _xmlAttr *attr;
if (!match_element(ptr, elem))
return 0;
+#if 0
for (attr = ptr->properties; attr; attr = attr->next)
if (!strcmp(attr->name, "type") &&
attr->children && attr->children->type == XML_TEXT_NODE)
}
if (!attr)
return 0;
+#endif
ptr = ptr->children;
if (!ptr || ptr->type != XML_TEXT_NODE)
return 0;
req->maximumRecords = 0;
req->recordSchema = 0;
req->recordPacking = 0;
+ req->database = 0;
for (; ptr; ptr = ptr->next)
{
else if (match_xsd_integer(ptr, "maximumRecords", o,
&req->maximumRecords))
;
+ else if (match_xsd_string(ptr, "database", o,
+ &req->database))
+ ;
/* missing is xQuery, xSortKeys .. */
}
}
add_xsd_integer(ptr, "maximumRecords", req->maximumRecords);
add_xsd_string(ptr, "recordSchema", req->recordSchema);
add_xsd_string(ptr, "recordPacking", req->recordPacking);
+ add_xsd_string(ptr, "database", req->database);
}
else if ((*p)->which == Z_SRW_searchRetrieve_response)
{
sr->u.request->maximumRecords = 0;
sr->u.request->recordSchema = 0;
sr->u.request->recordPacking = 0;
+ sr->u.request->database = 0;
break;
case Z_SRW_searchRetrieve_response:
sr->u.response = odr_malloc(o, sizeof(*sr->u.response));
}
return sr;
}
+
+#endif
+
+
+const char *yaz_srw_error_str (int code)
+{
+ return "SRW error";
+}
+
+#if 0
+
+1 Permanent system error
+2 System temporarily unavailable
+3 Authentication error
+ /* Diagnostics Relating to CQL */
+Number Description
+10 Illegal query
+11 Unsupported query type (XCQL vs CQL)
+12 Too many characters in query
+13 Unbalanced or illegal use of parentheses
+14 Unbalanced or illegal use of quotes
+15 Illegal or unsupported index set
+16 Illegal or unsupported index
+17 Illegal or unsupported combination of index and index set
+18 Illegal or unsupported combination of indexes
+19 Illegal or unsupported relation
+20 Illegal or unsupported relation modifier
+21 Illegal or unsupported combination of relation modifers
+22 Illegal or unsupported combination of relation and index
+23 Too many characters in term
+24 Illegal combination of relation and term
+25 Special characters not quoted in term
+26 Non special character escaped in term
+27 Empty term unsupported
+28 Masking character not supported
+29 Masked words too short
+30 Too many masking characters in term
+31 Anchoring character not supported
+32 Anchoring character in illegal or unsupported position
+33 Combination of proximity/adjacency and masking characters not supported
+34 Combination of proximity/adjacency and anchoring characters not supported
+35 Terms only exclusion (stop) words
+36 Term in invalid format for index or relation
+37 Illegal or unsupported boolean operator
+38 Too many boolean operators in query
+39 Proximity not supported
+40 Illegal or unsupported proximity relation
+41 Illegal or unsupported proximity distance
+42 Illegal or unsupported proximity unit
+43 Illegal or unsupported proximity ordering
+44 Illegal or unsupported combination of proximity modifiers
+45 Index set name (prefix) assigned to multiple identifiers
+/* Diagnostics Relating to Result Sets */
+Number Description
+50 Result sets not supported
+51 Result set does not exist
+52 Result set temporarily unavailable
+53 Result sets only supported for retrieval
+54 Retrieval may only occur from an existing result set
+55 Combination of result sets with search terms not supported
+56 Only combination of single result set with search terms supported
+57 Result set created but no records available
+58 Result set created with unpredictable partial results available
+59 Result set created with valid partial results available
+/* Diagnostics Relating to Records */
+Number Description
+60 Too many records retrieved
+61 First record position out of range
+62 Negative number of records requested
+63 System error in retrieving records
+64 Record temporarily unavailable
+65 Record does not exist
+66 Unknown schema for retrieval
+67 Record not available in this schema
+68 Not authorised to send record
+69 Not authorised to send record in this schema
+70 Record too large to send
+/* Diagnostics Relating to Sorting */
+Number Description
+80 Sort not supported
+81 Unsupported sort type (sortKeys vs xSortKeys)
+82 Illegal or unsupported sort sequence
+83 Too many records
+84 Too many sort keys
+85 Duplicate sort keys
+86 Incompatible record formats
+87 Unsupported schema for sort
+88 Unsupported tag path for sort
+89 Tag path illegal or unsupported for schema
+90 Illegal or unsupported direction value
+91 Illegal or unsupported case value
+92 Illegal or unsupported missing value action
+/* Diagnostics Relating to Explain */
+Number Description
+100 Explain not supported
+101 Explain request type not supported (SOAP vs GET)
+102 Explain record temporarily unavailable
+
#endif
* Copyright (c) 2000-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.19 2003-02-14 19:10:00 adam Exp $
+ * $Id: zoom-c.c,v 1.20 2003-02-17 14:35:42 adam Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
#include <string.h>
#include "zoom-p.h"
+#include <yaz/yaz-util.h>
#include <yaz/xmalloc.h>
#include <yaz/otherinfo.h>
#include <yaz/log.h>
return event;
}
-static void set_bib1_error (ZOOM_connection c, int error)
+
+static void set_dset_error (ZOOM_connection c, int error,
+ const char *dset,
+ const char *addinfo, const char *addinfo2)
{
xfree (c->addinfo);
c->addinfo = 0;
c->error = error;
- c->diagset = "Bib-1";
+ c->diagset = dset;
+ if (addinfo && addinfo2)
+ {
+ c->addinfo = xmalloc(strlen(addinfo) + strlen(addinfo2) + 2);
+ strcpy(c->addinfo, addinfo);
+ strcat(c->addinfo, addinfo2);
+ }
+ else if (addinfo)
+ c->addinfo = xstrdup(addinfo);
+ if (error)
+ yaz_log(LOG_LOG, "Error %s %s:%d %s %s",
+ c->host_port ? c->host_port : "<>", dset, error,
+ addinfo ? addinfo : "",
+ addinfo2 ? 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);
}
static void set_ZOOM_error (ZOOM_connection c, int error,
const char *addinfo)
{
- xfree (c->addinfo);
- c->addinfo = 0;
- c->error = error;
- c->diagset = "ZOOM";
- if (addinfo)
- c->addinfo = xstrdup(addinfo);
+ return set_dset_error(c, error, "ZOOM", addinfo, 0);
}
static void clear_error (ZOOM_connection c)
r->start = 0;
r->piggyback = 1;
r->setname = 0;
+ r->schema = 0;
r->count = 0;
r->record_cache = 0;
r->r_sort_spec = 0;
r->piggyback = ZOOM_options_get_bool (r->options, "piggyback", 1);
cp = ZOOM_options_get (r->options, "setname");
if (cp)
- r->setname = xstrdup (cp);
+ r->setname = xstrdup(cp);
+ cp = ZOOM_options_get (r->options, "schema");
+ if (cp)
+ r->schema = xstrdup(cp);
r->connection = c;
r->next = c->resultsets;
c->resultsets = r;
+ 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_SEARCH);
task->u.search.resultset = r;
ZOOM_resultset_addref (r);
ZOOM_options_destroy (r->options);
odr_destroy (r->odr);
xfree (r->setname);
+ xfree (r->schema);
xfree (r);
}
}
{
ZOOM_task task;
ZOOM_connection c;
+ const char *cp;
if (!r)
return;
task->u.retrieve.start = start;
task->u.retrieve.count = count;
+ cp = ZOOM_options_get (r->options, "schema");
+ if (cp)
+ {
+ if (!r->schema || strcmp(r->schema, cp))
+ {
+ xfree(r->schema);
+ r->schema = xstrdup(cp);
+ }
+ }
+
ZOOM_resultset_addref (r);
if (!r->connection->async || force_sync)
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;
#if HAVE_XSLT
static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
{
- ZOOM_resultset resultset;
- Z_SRW_searchRetrieve *sr = yaz_srw_get(c->odr_out,
- Z_SRW_searchRetrieve_request);
+ int i;
+ ZOOM_resultset resultset = 0;
+ Z_SRW_searchRetrieve *sr = 0;
+ if (c->error) /* don't continue on error */
+ return zoom_complete;
assert (c->tasks);
- assert (c->tasks->which == ZOOM_TASK_SEARCH);
-
- resultset = c->tasks->u.search.resultset;
- assert(resultset);
- assert (resultset->z_query);
+ if (c->tasks->which == ZOOM_TASK_SEARCH)
+ resultset = c->tasks->u.search.resultset;
+ else if(c->tasks->which == ZOOM_TASK_RETRIEVE)
+ {
+ resultset = c->tasks->u.retrieve.resultset;
+
+ resultset->start = c->tasks->u.retrieve.start;
+ resultset->count = c->tasks->u.retrieve.count;
+
+ if (resultset->start >= resultset->size)
+ return zoom_complete;
+ if (resultset->start + resultset->count > resultset->size)
+ resultset->count = resultset->size - resultset->start;
+
+ for (i = 0; i<resultset->count; i++)
+ {
+ ZOOM_record rec =
+ record_cache_lookup (resultset, i + resultset->start);
+ if (!rec)
+ break;
+ }
+ if (i == resultset->count)
+ return zoom_complete;
+ }
+ assert(resultset->z_query);
+
+ sr = yaz_srw_get(c->odr_out, Z_SRW_searchRetrieve_request);
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");
+ return zoom_complete;
+ }
else
- sr->u.request->query = "dc.title = computer";
-
+ {
+ set_ZOOM_error(c, ZOOM_ERROR_UNSUPPORTED_QUERY, 0);
+ return zoom_complete;
+ }
sr->u.request->startRecord = odr_intdup (c->odr_out, resultset->start + 1);
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);
}
const char *elementSetName;
const char *smallSetElementSetName;
const char *mediumSetElementSetName;
- const char *schema;
assert (c->tasks);
assert (c->tasks->which == ZOOM_TASK_SEARCH);
ZOOM_options_get (r->options, "smallSetElementSetName");
mediumSetElementSetName =
ZOOM_options_get (r->options, "mediumSetElementSetName");
- schema =
- ZOOM_options_get (r->options, "schema");
if (!smallSetElementSetName)
smallSetElementSetName = elementSetName;
*search_req->mediumSetPresentNumber = mspn;
}
else if (r->start == 0 && r->count > 0
- && r->piggyback && !r->r_sort_spec && !schema)
+ && r->piggyback && !r->r_sort_spec && !r->schema)
{
/* Regular piggyback - do it unless we're going to do sort */
*search_req->largeSetLowerBound = 2000000000;
return;
}
r = p->u.defaultFormat;
- c->diagset = yaz_z3950oid_to_str(r->diagnosticSetId, &oclass);
-
switch (r->which)
{
case Z_DefaultDiagFormat_v2Addinfo:
addinfo = r->u.v3Addinfo;
break;
}
- if (addinfo)
- c->addinfo = xstrdup (addinfo);
- c->error = *r->condition;
+ set_dset_error(c, *r->condition,
+ yaz_z3950oid_to_str(r->diagnosticSetId, &oclass),
+ addinfo, 0);
}
ZOOM_API(ZOOM_record)
return 0;
}
-static void record_cache_add (ZOOM_resultset r, Z_NamePlusRecord *npr, int pos)
+static int strcmp_null(const char *v1, const char *v2)
+{
+ if (!v1 && !v2)
+ return 0;
+ if (!v1 || !v2)
+ return -1;
+ return strcmp(v1, v2);
+}
+
+static void record_cache_add (ZOOM_resultset r, Z_NamePlusRecord *npr,
+ int pos)
{
ZOOM_record_cache rc;
const char *elementSetName =
{
if (pos == rc->pos)
{
- if ((!elementSetName && !rc->elementSetName)
- || (elementSetName && rc->elementSetName &&
- !strcmp (elementSetName, rc->elementSetName)))
- {
- if ((!syntax && !rc->syntax)
- || (syntax && rc->syntax &&
- !strcmp (syntax, rc->syntax)))
- {
- /* not destroying rc->npr (it's handled by nmem )*/
- rc->rec.npr = npr;
- /* keeping wrbuf_marc too */
- return;
- }
- }
+ if (strcmp_null(r->schema, rc->schema))
+ continue;
+ if (strcmp_null(elementSetName,rc->elementSetName))
+ continue;
+ if (strcmp_null(syntax, rc->syntax))
+ continue;
+ /* not destroying rc->npr (it's handled by nmem )*/
+ rc->rec.npr = npr;
+ /* keeping wrbuf_marc too */
+ return;
}
}
rc = (ZOOM_record_cache) odr_malloc (r->odr, sizeof(*rc));
else
rc->syntax = 0;
+ if (r->schema)
+ rc->schema = odr_strdup (r->odr, r->schema);
+ else
+ rc->schema = 0;
+
rc->pos = pos;
rc->next = r->record_cache;
r->record_cache = rc;
{
if (pos == rc->pos)
{
- if ((!elementSetName && !rc->elementSetName)
- || (elementSetName && rc->elementSetName &&
- !strcmp (elementSetName, rc->elementSetName)))
- {
- if ((!syntax && !rc->syntax)
- || (syntax && rc->syntax &&
- !strcmp (syntax, rc->syntax)))
- return &rc->rec;
- }
+ if (strcmp_null(r->schema, rc->schema))
+ continue;
+ if (strcmp_null(elementSetName,rc->elementSetName))
+ continue;
+ if (strcmp_null(syntax, rc->syntax))
+ continue;
+ return &rc->rec;
}
}
return 0;
int i = 0;
const char *syntax = 0;
const char *elementSetName = 0;
- const char *schema = 0;
ZOOM_resultset resultset;
if (!c->tasks)
syntax = ZOOM_resultset_option_get (resultset, "preferredRecordSyntax");
elementSetName = ZOOM_resultset_option_get (resultset, "elementSetName");
- schema = ZOOM_resultset_option_get (resultset, "schema");
if (c->error) /* don't continue on error */
return zoom_complete;
req->preferredRecordSyntax =
yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, syntax);
- if (schema && *schema)
+ if (resultset->schema && *resultset->schema)
{
Z_RecordComposition *compo = (Z_RecordComposition *)
odr_malloc (c->odr_out, sizeof(*compo));
compo->u.complex->generic->which = Z_Specification_oid;
compo->u.complex->generic->u.oid = (Odr_oid *)
- yaz_str_to_z3950oid (c->odr_out, CLASS_SCHEMA, schema);
+ yaz_str_to_z3950oid (c->odr_out, CLASS_SCHEMA, resultset->schema);
if (!compo->u.complex->generic->u.oid)
{
/* OID wasn't a schema! Try record syntax instead. */
compo->u.complex->generic->u.oid = (Odr_oid *)
- yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, schema);
+ yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, resultset->schema);
}
if (elementSetName && *elementSetName)
{
return ZOOM_options_get (p->options, key);
}
-#if HAVE_GSOAP
-static zoom_ret ZOOM_srw_search(ZOOM_connection c, ZOOM_resultset r,
- const char *cql)
-{
- int ret;
- struct xcql__operandType *xQuery = 0;
- char *action = 0;
- xsd__integer startRecord = r->start + 1;
- xsd__integer maximumRecord = r->count;
- const char *schema = ZOOM_resultset_option_get (r, "schema");
- struct zs__searchRetrieveResponse res;
- xsd__string recordPacking = 0;
-
-
- if (!schema)
- schema = "http://www.loc.gov/marcxml/";
-
- ret = soap_call_zs__searchRetrieveRequest(c->soap, c->host_port,
- action,
- &r->z_query->u.type_104->u.cql,
- xQuery,
- 0, 0,
- &startRecord, &maximumRecord,
- (char **) &schema,
- &recordPacking,
- &res);
- if (ret != SOAP_OK)
- {
- const char **s = soap_faultdetail(c->soap);
- xfree (c->addinfo);
- c->addinfo = 0;
- if (s && *s)
- c->addinfo = xstrdup(*s);
- c->diagset = "SOAP";
- c->error = ret;
- }
- else
- {
- if (res.diagnostics.__sizeDiagnostics > 0)
- {
- int i = 0;
- xfree (c->addinfo);
- c->addinfo = 0;
- c->diagset = "SRW";
- c->error = res.diagnostics.diagnostic[i]->code;
- if (res.diagnostics.diagnostic[i]->details)
- c->addinfo =
- xstrdup(res.diagnostics.diagnostic[i]->details);
-
- }
- else
- {
- int i;
- r->size = res.numberOfRecords;
- if (res.resultSetId)
- r->setname = xstrdup(res.resultSetId);
- for (i = 0; i < res.records.__sizeRecords; i++)
- {
- char *rdata = res.records.record[i]->recordData;
- if (rdata)
- {
- Z_NamePlusRecord *npr =
- odr_malloc(r->odr, sizeof(*npr));
- Z_External *ext =
- z_ext_record(r->odr, VAL_TEXT_XML,
- rdata, strlen(rdata));
- npr->databaseName = 0;
- npr->which = Z_NamePlusRecord_databaseRecord;
- npr->u.databaseRecord = ext;
- record_cache_add (r, npr, r->start + i);
- }
- }
- }
- }
- return zoom_complete;
-}
-#endif
ZOOM_API(void)
ZOOM_package_option_set (ZOOM_package p, const char *key,
}
task->running = 1;
ret = zoom_complete;
-#if 0
- if (c->proto == PROTO_SRW)
- {
- ZOOM_resultset resultset;
- switch (task->which)
- {
- case ZOOM_TASK_SEARCH:
- resultset = c->tasks->u.search.resultset;
- if (resultset->z_query &&
- resultset->z_query->which == Z_Query_type_104
- && resultset->z_query->u.type_104->which == Z_External_CQL)
- ret = ZOOM_srw_search(c, resultset,
- resultset->z_query->u.type_104->u.cql);
- break;
- case ZOOM_TASK_RETRIEVE:
- resultset = c->tasks->u.retrieve.resultset;
- resultset->start = c->tasks->u.retrieve.start;
- resultset->count = c->tasks->u.retrieve.count;
-
- if (resultset->start >= resultset->size)
- return zoom_complete;
- if (resultset->start + resultset->count > resultset->size)
- resultset->count = resultset->size - resultset->start;
-
- if (resultset->z_query &&
- resultset->z_query->which == Z_Query_type_104
- && resultset->z_query->u.type_104->which == Z_External_CQL)
- ret = ZOOM_srw_search(c, resultset,
- resultset->z_query->u.type_104->u.cql);
- break;
- }
-#endif
if (c->cs || task->which == ZOOM_TASK_CONNECT)
{
switch (task->which)
ret = ZOOM_connection_send_search(c);
break;
case ZOOM_TASK_RETRIEVE:
- ret = send_present (c);
+ if (c->proto == PROTO_SRW)
+ ret = ZOOM_connection_srw_send_search(c);
+ else
+ ret = send_present (c);
break;
case ZOOM_TASK_CONNECT:
ret = do_connect(c);
}
}
+#if HAVE_XSLT
+static void handle_srw_response(ZOOM_connection c,
+ Z_SRW_searchRetrieveResponse *res)
+{
+ ZOOM_resultset resultset = 0;
+ int i;
+ NMEM nmem;
+
+ if (!c->tasks)
+ return;
+
+ if (c->tasks->which == ZOOM_TASK_SEARCH)
+ resultset = c->tasks->u.search.resultset;
+ else if (c->tasks->which == ZOOM_TASK_RETRIEVE)
+ resultset = c->tasks->u.retrieve.resultset;
+ else
+ return ;
+
+ resultset->size = 0;
+
+ yaz_log(LOG_LOG, "got SRW response OK");
+
+ if (res->numberOfRecords)
+ resultset->size = *res->numberOfRecords;
+
+ for (i = 0; i<res->num_records; i++)
+ {
+ int pos;
+
+ Z_NamePlusRecord *npr = (Z_NamePlusRecord *)
+ odr_malloc(c->odr_in, sizeof(Z_NamePlusRecord));
+
+ if (res->records[i].recordPosition &&
+ *res->records[i].recordPosition > 0)
+ pos = *res->records[i].recordPosition - 1;
+ else
+ pos = resultset->start + i;
+
+ npr->databaseName = 0;
+ npr->which = Z_NamePlusRecord_databaseRecord;
+ npr->u.databaseRecord = (Z_External *)
+ odr_malloc(c->odr_in, sizeof(Z_External));
+ npr->u.databaseRecord->descriptor = 0;
+ npr->u.databaseRecord->direct_reference =
+ yaz_oidval_to_z3950oid(c->odr_in, CLASS_RECSYN, VAL_TEXT_XML);
+ npr->u.databaseRecord->which = Z_External_octet;
+ npr->u.databaseRecord->u.octet_aligned = (Odr_oct *)
+ odr_malloc(c->odr_in, sizeof(Odr_oct));
+ npr->u.databaseRecord->u.octet_aligned->buf =
+ res->records[i].recordData_buf;
+ npr->u.databaseRecord->u.octet_aligned->len =
+ 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)
+ {
+ set_dset_error(c, *res->diagnostics[0].code, "SRW",
+ res->diagnostics[0].details, 0);
+ }
+ nmem = odr_extract_mem(c->odr_in);
+ nmem_transfer(resultset->odr->mem, nmem);
+ nmem_destroy(nmem);
+}
+#endif
+
+#if HAVE_XSLT
static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres)
{
+ int ret = -1;
+ const char *content_type = z_HTTP_header_lookup(hres->headers,
+ "Content-Type");
+ const char *connection_head = z_HTTP_header_lookup(hres->headers,
+ "Connection");
c->mask = 0;
yaz_log (LOG_DEBUG, "handle_http");
+
+ if (content_type && !yaz_strcmp_del("text/xml", content_type, "; "))
+ {
+ Z_SOAP *soap_package = 0;
+ ODR o = odr_createmem(ODR_DECODE);
+ Z_SOAP_Handler soap_handlers[2] = {
+ {"http://www.loc.gov/zing/srw/v1.0/", 0,
+ (Z_SOAP_fun) yaz_srw_codec},
+ {0, 0, 0}
+ };
+ ret = z_soap_codec(o, &soap_package,
+ &hres->content_buf, &hres->content_len,
+ soap_handlers);
+ if (!ret && soap_package->which == Z_SOAP_generic &&
+ soap_package->u.generic->no == 0)
+ {
+ Z_SRW_searchRetrieve *sr = soap_package->u.generic->p;
+ if (sr->which == Z_SRW_searchRetrieve_response)
+ handle_srw_response(c, sr->u.response);
+ else
+ ret = -1;
+ }
+ else if (!ret && (soap_package->which == Z_SOAP_fault
+ || soap_package->which == Z_SOAP_error))
+ {
+ set_HTTP_error(c, hres->code,
+ soap_package->u.fault->fault_code,
+ soap_package->u.fault->fault_string);
+ }
+ else
+ ret = -1;
+ odr_destroy(o);
+ }
+ if (ret)
+ {
+ if (hres->code != 200)
+ set_HTTP_error(c, hres->code, 0, 0);
+ else
+ set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0);
+ do_close (c);
+ }
ZOOM_connection_remove_task(c);
+ if (!strcmp(hres->version, "1.0"))
+ {
+ /* HTTP 1.0: only if Keep-Alive we stay alive.. */
+ if (!connection_head || strcmp(connection_head, "Keep-Alive"))
+ do_close(c);
+ }
+ else
+ {
+ /* HTTP 1.1: only if no close we stay alive .. */
+ if (connection_head && !strcmp(connection_head, "close"))
+ do_close(c);
+ }
}
+#endif
static int do_read (ZOOM_connection c)
{
else if (gdu->which == Z_GDU_Z3950)
handle_apdu (c, gdu->u.z3950);
else if (gdu->which == Z_GDU_HTTP_Response)
+ {
+#if HAVE_XSLT
handle_http (c, gdu->u.HTTP_Response);
+#else
+ set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0);
+ do_close (c);
+#endif
+ }
c->reconnect_ok = 0;
}
return 1;
return "Timeout";
case ZOOM_ERROR_UNSUPPORTED_PROTOCOL:
return "Unsupported protocol";
+ case ZOOM_ERROR_UNSUPPORTED_QUERY:
+ return "Unsupported query type";
default:
return diagbib1_str (error);
}
int error = c->error;
if (cp)
{
- if (!c->diagset)
+ if (!c->diagset || !strcmp(c->diagset, "ZOOM"))
+ *cp = ZOOM_diag_str(error);
+ else if (!strcmp(c->diagset, "HTTP"))
+ *cp = z_HTTP_errmsg(c->error);
+ else if (!strcmp(c->diagset, "Bib-1"))
*cp = ZOOM_diag_str(error);
-#if HAVE_GSOAP
else if (!strcmp(c->diagset, "SRW"))
- *cp = yaz_srw_diag_str(error);
- else if (c->soap && !strcmp(c->diagset, "SOAP"))
- {
- const char **s = soap_faultstring(c->soap);
- if (s && *s)
- *cp = *s;
- else
- *cp = "unknown";
- }
-#endif
+ *cp = yaz_srw_error_str(c->error);
else
- *cp = ZOOM_diag_str(error);
+ *cp = "Unknown error and diagnostic set";
}
if (addinfo)
*addinfo = c->addinfo ? c->addinfo : "";