From: Adam Dickmeiss Date: Mon, 8 May 2006 19:48:26 +0000 (+0000) Subject: Change return values for yaz_retrieval_request a bit and improve X-Git-Tag: YAZ.2.1.20~53 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=65f297c24c59e95f860f29928d3588c5dc98ba4c;p=yaz-moved-to-github.git Change return values for yaz_retrieval_request a bit and improve diagnostics in the case where retrieval match fails. --- diff --git a/include/yaz/retrieval.h b/include/yaz/retrieval.h index 9592bc0..46ab103 100644 --- a/include/yaz/retrieval.h +++ b/include/yaz/retrieval.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: retrieval.h,v 1.3 2006-05-07 14:48:24 adam Exp $ + * $Id: retrieval.h,v 1.4 2006-05-08 19:48:26 adam Exp $ */ /** * \file retrieval.h @@ -97,8 +97,7 @@ int yaz_retrieval_configure(yaz_retrieval_t p, const void *node); \retval -1 failure, use yaz_retrieval_get_error() for reason \retval 1 schema does not match \retval 2 syntax does not match - \retval 3 neither schema, nor syntax matches - \retval 4 both match but not together + \retval 3 both match but not together */ YAZ_EXPORT int yaz_retrieval_request(yaz_retrieval_t p, diff --git a/src/retrieval.c b/src/retrieval.c index d86b928..c433d61 100644 --- a/src/retrieval.c +++ b/src/retrieval.c @@ -2,7 +2,7 @@ * Copyright (C) 2005-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: retrieval.c,v 1.6 2006-05-08 11:58:37 adam Exp $ + * $Id: retrieval.c,v 1.7 2006-05-08 19:48:26 adam Exp $ */ /** * \file retrieval.c @@ -242,6 +242,7 @@ int yaz_retrieval_request(yaz_retrieval_t p, int syntax_matches = 0; int schema_matches = 0; + wrbuf_rewind(p->wr_error); if (!el) return 0; for(; el; el = el->next) @@ -255,6 +256,8 @@ int yaz_retrieval_request(yaz_retrieval_t p, schema_ok = 1; if (!schema) schema_ok = 1; + if (schema && !el->schema) + schema_ok = 1; if (syntax && el->syntax && !oid_oidcmp(syntax, el->syntax)) syntax_ok = 1; @@ -278,13 +281,16 @@ int yaz_retrieval_request(yaz_retrieval_t p, return 0; } } - if (syntax_matches && !schema_matches) - return 1; - if (!syntax_matches && schema_matches) + if (!syntax_matches && syntax) + { + wrbuf_printf(p->wr_error, "%s", syntax); return 2; - if (!syntax_matches && !schema_matches) - return 3; - return 4; + } + if (schema) + wrbuf_printf(p->wr_error, "%s", schema); + if (!schema_matches) + return 1; + return 3; } const char *yaz_retrieval_get_error(yaz_retrieval_t p) diff --git a/src/seshigh.c b/src/seshigh.c index d355260..f6dedb5 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.78 2006-05-08 10:16:47 adam Exp $ + * $Id: seshigh.c,v 1.79 2006-05-08 19:48:26 adam Exp $ */ /** * \file seshigh.c @@ -599,6 +599,7 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr) &rc, &backend_schema, &backend_syntax); + yaz_log(YLOG_LOG, "yaz_retrieval_request r=%d", r); if (r == -1) /* error ? */ { const char *details = yaz_retrieval_get_error( @@ -609,7 +610,7 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr) rr->errstring = odr_strdup(rr->stream, details); return -1; } - else if (r == 1) + else if (r == 1 || r == 3) { const char *details = input_schema; rr->errcode = YAZ_BIB1_ELEMENT_SET_NAMES_UNSUPP; @@ -620,19 +621,12 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr) else if (r == 2) { rr->errcode = YAZ_BIB1_RECORD_SYNTAX_UNSUPP; - return -1; - } - else if (r == 3) - { - const char *details = input_schema; - rr->errcode = YAZ_BIB1_ELEMENT_SET_NAMES_UNSUPP; - if (details) - rr->errstring = odr_strdup(rr->stream, details); - return -1; - } - else if (r == 4) - { - rr->errcode = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; + if (input_syntax_raw) + { + char oidbuf[OID_STR_MAX]; + oid_to_dotstring(input_syntax_raw, oidbuf); + rr->errstring = odr_strdup(rr->stream, oidbuf); + } return -1; } if (backend_schema) @@ -2241,7 +2235,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.78 $"); + version = odr_strdup(assoc->encode, "$Revision: 1.79 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; resp->implementationVersion = odr_prepend(assoc->encode,