X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fseshigh.c;h=f0b2ef9e54f5c6793c1327ac8f4f051e69d046be;hb=7c5d526290c4d003ce685a8a988934c0b7e631cc;hp=c307ff2abcf270f9459c0650f95e92408a3f786f;hpb=012ebe86693784419f1ab4c62a727d8c3a7aabf0;p=yaz-moved-to-github.git diff --git a/src/seshigh.c b/src/seshigh.c index c307ff2..f0b2ef9 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.26 2004-08-02 10:06:34 adam Exp $ + * $Id: seshigh.c,v 1.32 2004-10-09 08:21:38 adam Exp $ */ /* @@ -510,9 +510,22 @@ static int srw_bend_fetch(association *assoc, int pos, rr.comp->u.complex->generic = (Z_Specification *) odr_malloc(assoc->decode, sizeof(Z_Specification)); + + /* schema uri = recordSchema (or NULL if recordSchema is not given) */ rr.comp->u.complex->generic->which = Z_Schema_uri; rr.comp->u.complex->generic->schema.uri = srw_req->recordSchema; + + /* ESN = recordSchema if recordSchema is present */ rr.comp->u.complex->generic->elementSpec = 0; + if (srw_req->recordSchema) + { + rr.comp->u.complex->generic->elementSpec = + (Z_ElementSpec *) odr_malloc(assoc->encode, sizeof(Z_ElementSpec)); + rr.comp->u.complex->generic->elementSpec->which = + Z_ElementSpec_elementSetName; + rr.comp->u.complex->generic->elementSpec->u.elementSetName = + srw_req->recordSchema; + } rr.stream = assoc->encode; rr.print = assoc->print; @@ -533,7 +546,35 @@ static int srw_bend_fetch(association *assoc, int pos, (*assoc->init->bend_fetch)(assoc->backend, &rr); - if (rr.len >= 0) + if (rr.errcode && rr.surrogate_flag) + { + int code = yaz_diag_bib1_to_srw(rr.errcode); + const char *message = yaz_diag_srw_str(code); + int len = 200; + if (message) + len += strlen(message); + if (rr.errstring) + len += strlen(rr.errstring); + + record->recordData_buf = odr_malloc(o, len); + + sprintf(record->recordData_buf, "\n" + " info:srw/diagnostic/1/%d\n", code); + if (rr.errstring) + sprintf(record->recordData_buf + strlen(record->recordData_buf), + "
%s
\n", rr.errstring); + if (message) + sprintf(record->recordData_buf + strlen(record->recordData_buf), + " %s\n", message); + sprintf(record->recordData_buf + strlen(record->recordData_buf), + "
\n"); + record->recordData_len = strlen(record->recordData_buf); + record->recordPosition = odr_intdup(o, pos); + record->recordSchema = "info:srw/schema/1/diagnostics-v1.1"; + return 0; + } + else if (rr.len >= 0) { record->recordData_buf = rr.record; record->recordData_len = rr.len; @@ -650,7 +691,6 @@ static void srw_bend_search(association *assoc, request *req, rr.search_info = 0; yaz_log_zquery(rr.query); (assoc->init->bend_search)(assoc->backend, &rr); - srw_res->numberOfRecords = odr_intdup(assoc->encode, rr.hits); if (rr.errcode) { yaz_log(LOG_DEBUG, "bend_search returned Bib-1 code %d", rr.errcode); @@ -683,7 +723,12 @@ static void srw_bend_search(association *assoc, request *req, if (start > rr.hits) { - yaz_log(LOG_LOG, "Request out or range"); + srw_res->num_diagnostics = 1; + srw_res->diagnostics = (Z_SRW_diagnostic *) + odr_malloc(assoc->encode, + sizeof(*srw_res->diagnostics)); + yaz_mk_std_diagnostic(assoc->encode, srw_res->diagnostics, + 61, 0); } else { @@ -762,7 +807,7 @@ static void srw_bend_explain(association *assoc, request *req, if (srw_req->recordPacking && !strcmp(srw_req->recordPacking, "xml")) packing = Z_SRW_recordPacking_XML; - srw_res->record.recordSchema = 0; + srw_res->record.recordSchema = rr.schema; srw_res->record.recordPacking = packing; srw_res->record.recordData_buf = rr.explain_buf; srw_res->record.recordData_len = strlen(rr.explain_buf); @@ -1326,7 +1371,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) assoc->init->implementation_name, odr_prepend(assoc->encode, "GFS", resp->implementationName)); - version = odr_strdup(assoc->encode, "$Revision: 1.26 $"); + version = odr_strdup(assoc->encode, "$Revision: 1.32 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; resp->implementationVersion = odr_prepend(assoc->encode,