From: Adam Dickmeiss Date: Sat, 24 May 2003 19:20:14 +0000 (+0000) Subject: odr_getelement / odr_setelement X-Git-Tag: YAZ.2.0.3~42 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=39fc6d5c771c134df959cdd44b2ad62d07b9576f odr_getelement / odr_setelement --- diff --git a/CHANGELOG b/CHANGELOG index dcf97c0..4242cef 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,11 @@ Possible compatibility problems with earlier versions marked with '*'. +New ODR utility, odr_getelement, which returns name element for +which encoding/decoding failed. + +Fixed ODR so that it returns error code OREQUIRED rather than ONONE +in cases where a required element was omitted. + Bug fix: some MARC8 sequences were not converted. New ZOOM option "step" which specifies number of records to be diff --git a/include/yaz/odr.h b/include/yaz/odr.h index f4a0c26..40a458f 100644 --- a/include/yaz/odr.h +++ b/include/yaz/odr.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: odr.h,v 1.11 2003-05-20 19:55:29 adam Exp $ + * $Id: odr.h,v 1.12 2003-05-24 19:20:14 adam Exp $ */ #ifndef ODR_H @@ -185,8 +185,8 @@ extern char *odr_errlist[]; YAZ_EXPORT int odr_geterror(ODR o); YAZ_EXPORT int odr_geterrorx(ODR o, int *x); YAZ_EXPORT void odr_seterror(ODR o, int errorno, int errorid); -YAZ_EXPORT void odr_setaddinfo(ODR o, const char *addinfo); -YAZ_EXPORT char *odr_getaddinfo(ODR o); +YAZ_EXPORT void odr_setelement(ODR o, const char *addinfo); +YAZ_EXPORT char *odr_getelement(ODR o); YAZ_EXPORT void odr_perror(ODR o, char *message); YAZ_EXPORT void odr_setprint(ODR o, FILE *file); YAZ_EXPORT ODR odr_createmem(int direction); diff --git a/odr/ber_tag.c b/odr/ber_tag.c index 8c3e186..98b8a95 100644 --- a/odr/ber_tag.c +++ b/odr/ber_tag.c @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: ber_tag.c,v 1.26 2003-05-20 19:55:29 adam Exp $ + * $Id: ber_tag.c,v 1.27 2003-05-24 19:20:14 adam Exp $ */ #if HAVE_CONFIG_H #include @@ -47,7 +47,7 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt, if (!opt) { odr_seterror(o, OREQUIRED, 24); - odr_setaddinfo (o, name); + odr_setelement (o, name); } return 0; } @@ -65,7 +65,7 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt, if (!opt) { odr_seterror(o, OREQUIRED, 25); - odr_setaddinfo(o, name); + odr_setelement(o, name); } return 0; } @@ -77,7 +77,7 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt, odr_max(o))) <= 0) { odr_seterror(o, OPROTO, 26); - odr_setaddinfo(o, name); + odr_setelement(o, name); return 0; } #ifdef ODR_DEBUG @@ -99,7 +99,7 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt, if (!opt) { odr_seterror(o, OREQUIRED, 27); - odr_setaddinfo(o, name); + odr_setelement(o, name); } return 0; } @@ -107,12 +107,12 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt, if (!*pp && !opt) { odr_seterror(o,OREQUIRED, 28); - odr_setaddinfo(o, name); + odr_setelement(o, name); } return *pp != 0; default: odr_seterror(o, OOTHER, 29); - odr_setaddinfo(o, name); + odr_setelement(o, name); return 0; } } diff --git a/odr/odr-priv.h b/odr/odr-priv.h index fef7455..80366c3 100644 --- a/odr/odr-priv.h +++ b/odr/odr-priv.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: odr-priv.h,v 1.5 2003-05-20 19:55:29 adam Exp $ + * $Id: odr-priv.h,v 1.6 2003-05-24 19:20:14 adam Exp $ */ #ifndef ODR_PRIV_H @@ -52,7 +52,7 @@ struct Odr_private { struct Odr_ber_tag odr_ber_tag; yaz_iconv_t iconv_handle; int error_id; - char addinfo[80]; + char element[80]; }; /* Private macro. diff --git a/odr/odr.c b/odr/odr.c index a29f720..b772b60 100644 --- a/odr/odr.c +++ b/odr/odr.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: odr.c,v 1.43 2003-05-20 19:55:29 adam Exp $ + * $Id: odr.c,v 1.44 2003-05-24 19:20:14 adam Exp $ * */ #if HAVE_CONFIG_H @@ -46,8 +46,12 @@ char *odr_errmsg(int n) void odr_perror(ODR o, char *message) { - fprintf(stderr, "%s: %s: %s\n", message, odr_errlist[o->error], - odr_getaddinfo(o)); + const char *e = odr_getelement(o); + + fprintf(stderr, "%s: %s", message, odr_errlist[o->error]); + if (e && *e) + fprintf (stderr, " element %s", e); + fprintf(stderr, "\n"); } int odr_geterror(ODR o) @@ -62,24 +66,24 @@ int odr_geterrorx(ODR o, int *x) return o->error; } -char *odr_getaddinfo(ODR o) +char *odr_getelement(ODR o) { - return o->op->addinfo; + return o->op->element; } void odr_seterror(ODR o, int error, int id) { o->error = error; o->op->error_id = id; - o->op->addinfo[0] = '\0'; + o->op->element[0] = '\0'; } -void odr_setaddinfo(ODR o, const char *addinfo) +void odr_setelement(ODR o, const char *element) { - if (addinfo) + if (element) { - strncpy(o->op->addinfo, addinfo, sizeof(o->op->addinfo)-1); - o->op->addinfo[sizeof(o->op->addinfo)-1] = '\0'; + strncpy(o->op->element, element, sizeof(o->op->element)-1); + o->op->element[sizeof(o->op->element)-1] = '\0'; } } diff --git a/odr/odr_util.c b/odr/odr_util.c index c8b35b8..5da4088 100644 --- a/odr/odr_util.c +++ b/odr/odr_util.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: odr_util.c,v 1.24 2003-05-20 20:21:34 adam Exp $ + * $Id: odr_util.c,v 1.25 2003-05-24 19:20:14 adam Exp $ */ #if HAVE_CONFIG_H #include @@ -88,7 +88,7 @@ int odr_missing(ODR o, int opt, const char *name) if (!opt) { odr_seterror(o, OREQUIRED, 53); - odr_setaddinfo(o, name); + odr_setelement(o, name); } return opt; } diff --git a/server/seshigh.c b/server/seshigh.c index 634bc4e..fb4abe0 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.157 2003-05-20 20:22:11 adam Exp $ + * $Id: seshigh.c,v 1.158 2003-05-24 19:20:14 adam Exp $ */ /* @@ -326,10 +326,10 @@ void ir_session(IOCHAN h, int event) odr_setbuf(assoc->decode, assoc->input_buffer, res, 0); if (!z_GDU(assoc->decode, &req->gdu_request, 0, 0)) { - yaz_log(LOG_LOG, "ODR error on incoming PDU: %s [addinfo %s] " + yaz_log(LOG_LOG, "ODR error on incoming PDU: %s [element %s] " "[near byte %d] ", odr_errmsg(odr_geterror(assoc->decode)), - odr_getaddinfo(assoc->decode), + odr_getelement(assoc->decode), odr_offset(assoc->decode)); if (assoc->decode->error != OHTTP) { @@ -1383,9 +1383,9 @@ static int process_gdu_response(association *assoc, request *req, Z_GDU *res) } if (!z_GDU(assoc->encode, &res, 0, 0)) { - yaz_log(LOG_WARN, "ODR error when decoding PDU: %s [addinfo %s]", + yaz_log(LOG_WARN, "ODR error when decoding PDU: %s [element %s]", odr_errmsg(odr_geterror(assoc->decode)), - odr_getaddinfo(assoc->decode)); + odr_getelement(assoc->decode)); return -1; } req->response = odr_getbuf(assoc->encode, &req->len_response,