From: Adam Dickmeiss Date: Tue, 31 Oct 2006 14:08:01 +0000 (+0000) Subject: Implemented ZOOM_record_error which returns error information for X-Git-Tag: YAZ.2.1.40~12 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=17eb2fd28b9e01e9c80c55a0fcc48fd866082bfc;p=yaz-moved-to-github.git Implemented ZOOM_record_error which returns error information for record (surrogate diagnostic). Bug #715. --- diff --git a/NEWS b/NEWS index 7d1f8c8..6ab9b6d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +Implemented ZOOM_record_error which returns error information for +record (surrogate diagnostic). + --- 2.1.38 2006/10/31 Updates for SRU Update by Ko van der Sloot: diff --git a/configure.ac b/configure.ac index d38c99a..569e24a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl YAZ Toolkit, Index Data 1994-2006 dnl See the file LICENSE for details. -dnl $Id: configure.ac,v 1.45 2006-10-31 10:07:22 adam Exp $ +dnl $Id: configure.ac,v 1.46 2006-10-31 14:08:01 adam Exp $ AC_PREREQ(2.59) -AC_INIT([yaz],[2.1.38],[yaz-help@indexdata.dk]) +AC_INIT([yaz],[2.1.39],[yaz-help@indexdata.dk]) AC_CONFIG_SRCDIR(configure.ac) AC_CONFIG_AUX_DIR([config]) AM_INIT_AUTOMAKE([1.8]) diff --git a/debian/rules b/debian/rules index 2bc7abb..23d9749 100755 --- a/debian/rules +++ b/debian/rules @@ -98,7 +98,7 @@ binary-arch: build install dh_fixperms # dh_perl # dh_python - dh_makeshlibs -V 'libyaz (>= 2.1.36)' + dh_makeshlibs -V 'libyaz (>= 2.1.39)' dh_installdeb dh_shlibdeps -l debian/libyaz/usr/lib dh_gencontrol diff --git a/doc/zoom.xml b/doc/zoom.xml index 74aed36..0085b3d 100644 --- a/doc/zoom.xml +++ b/doc/zoom.xml @@ -20,7 +20,7 @@ ZOOM_options_set_int(opt, name, value) ZOOM_connection_scan1 (ZOOM_connection c, ZOOM_query startterm) ZOOM_query_cql2rpn(ZOOM_query s, const char *str, ZOOM_connection conn) --> - + ZOOM &zoom; is an acronym for 'Z39.50 Object-Orientation Model' and is @@ -632,13 +632,16 @@ ZOOM_query_cql2rpn(ZOOM_query s, const char *str, ZOOM_connection conn) created from result sets. - void ZOOM_resultset_records (ZOOM_resultset r, - ZOOM_record *recs, - size_t start, size_t count); - ZOOM_record ZOOM_resultset_record (ZOOM_resultset s, size_t pos); + void ZOOM_resultset_records(ZOOM_resultset r, + ZOOM_record *recs, + size_t start, size_t count); + ZOOM_record ZOOM_resultset_record(ZOOM_resultset s, size_t pos); - const char *ZOOM_record_get (ZOOM_record rec, const char *type, - size_t *len); + const char *ZOOM_record_get(ZOOM_record rec, const char *type, + size_t *len); + + int ZOOM_record_error(ZOOM_record rec, const char **msg, + const char **addinfo, const char **diagset); ZOOM_record ZOOM_record_clone (ZOOM_record rec); @@ -662,6 +665,12 @@ ZOOM_query_cql2rpn(ZOOM_query s, const char *str, ZOOM_connection conn) If no record could be obtained NULL is returned. + Error information for a record can be checked with + ZOOM_record_error which returns non-zero + (error code) if record is in error, called Surrogate + Diagnostics in Z39.50. + + Function ZOOM_resultset_records retrieves a number of records from a result set. Parameter start and count specifies the range of records to diff --git a/include/yaz/yaz-version.h b/include/yaz/yaz-version.h index cf67a18..c7cd786 100644 --- a/include/yaz/yaz-version.h +++ b/include/yaz/yaz-version.h @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: yaz-version.h,v 1.102 2006-10-31 10:07:23 adam Exp $ */ +/* $Id: yaz-version.h,v 1.103 2006-10-31 14:08:02 adam Exp $ */ /** * \file yaz-version.h * \brief Defines YAZ version. @@ -33,8 +33,8 @@ #include -#define YAZ_VERSION "2.1.38" -#define YAZ_VERSIONL 0x020126 +#define YAZ_VERSION "2.1.39" +#define YAZ_VERSIONL 0x020127 #define YAZ_DATE 1 diff --git a/include/yaz/zoom.h b/include/yaz/zoom.h index 9d4451c..4f3e479 100644 --- a/include/yaz/zoom.h +++ b/include/yaz/zoom.h @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: zoom.h,v 1.39 2006-10-13 11:30:37 adam Exp $ */ +/* $Id: zoom.h,v 1.40 2006-10-31 14:08:02 adam Exp $ */ /** * \file zoom.h @@ -209,6 +209,11 @@ ZOOM_record_destroy (ZOOM_record rec); ZOOM_API(ZOOM_record) ZOOM_record_clone (ZOOM_record srec); +/* return error info (surrogate diagnostic) for record */ +ZOOM_API(int) + ZOOM_record_error(ZOOM_record rec, const char **msg, + const char **addinfo, const char **diagset); + /* ----------------------------------------------------------- */ /* queries */ diff --git a/src/zoom-c.c b/src/zoom-c.c index 0235bd4..da0a4c6 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.93 2006-10-26 15:34:46 adam Exp $ + * $Id: zoom-c.c,v 1.94 2006-10-31 14:08:03 adam Exp $ */ /** * \file zoom-c.c @@ -1242,7 +1242,7 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c) odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.93 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.94 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = @@ -1802,6 +1802,53 @@ static const char *record_iconv_return(ZOOM_record rec, int *len, return buf; } +ZOOM_API(int) + ZOOM_record_error(ZOOM_record rec, const char **cp, + const char **addinfo, const char **diagset) +{ + Z_NamePlusRecord *npr; + + if (!rec) + return 0; + npr = rec->npr; + if (npr && npr->which == Z_NamePlusRecord_surrogateDiagnostic) + { + Z_DiagRec *diag_rec = npr->u.surrogateDiagnostic; + int error = YAZ_BIB1_UNSPECIFIED_ERROR; + const char *add = 0; + + if (diag_rec->which == Z_DiagRec_defaultFormat) + { + Z_DefaultDiagFormat *ddf = diag_rec->u.defaultFormat; + int oclass; + + error = *ddf->condition; + switch (ddf->which) + { + case Z_DefaultDiagFormat_v2Addinfo: + add = ddf->u.v2Addinfo; + break; + case Z_DefaultDiagFormat_v3Addinfo: + add = ddf->u.v3Addinfo; + break; + } + if (diagset) + *diagset = yaz_z3950oid_to_str(ddf->diagnosticSetId, &oclass); + } + else + { + if (diagset) + *diagset = "Bib-1"; + } + if (addinfo) + *addinfo = add ? add : ""; + if (cp) + *cp = diagbib1_str(error); + return error; + } + return 0; +} + ZOOM_API(const char *) ZOOM_record_get(ZOOM_record rec, const char *type_spec, int *len) { diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index ad82948..5f99d66 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: zoomsh.c,v 1.41 2006-04-24 10:30:44 adam Exp $ + * $Id: zoomsh.c,v 1.42 2006-10-31 14:08:03 adam Exp $ */ /** \file zoomsh.c @@ -184,22 +184,36 @@ static void display_records (ZOOM_connection c, int pos = i + start; ZOOM_record rec = ZOOM_resultset_record (r, pos); const char *db = ZOOM_record_get (rec, "database", 0); - int len, opac_len; - const char *render = ZOOM_record_get (rec, "render", &len); - const char *opac_render = ZOOM_record_get (rec, "opac", &opac_len); - const char *syntax = ZOOM_record_get (rec, "syntax", 0); - /* if rec is non-null, we got a record for display */ - if (rec) + + if (ZOOM_record_error(rec, 0, 0, 0)) + { + const char *msg; + const char *addinfo; + const char *diagset; + int error = ZOOM_record_error(rec, &msg, &addinfo, &diagset); + + printf("%d %s: %s (%s:%d) %s\n", pos, (db ? db : "unknown"), + msg, diagset, error, addinfo); + } + else { - char oidbuf[100]; - (void) oid_name_to_dotstring(CLASS_RECSYN, syntax, oidbuf); - printf ("%d %s %s (%s)\n", - pos+1, (db ? db : "unknown"), syntax, oidbuf); - if (render) - fwrite (render, 1, len, stdout); - printf ("\n"); - if (opac_render) - fwrite (opac_render, 1, opac_len, stdout); + int len, opac_len; + const char *render = ZOOM_record_get (rec, "render", &len); + const char *opac_render = ZOOM_record_get (rec, "opac", &opac_len); + const char *syntax = ZOOM_record_get (rec, "syntax", 0); + /* if rec is non-null, we got a record for display */ + if (rec) + { + char oidbuf[100]; + (void) oid_name_to_dotstring(CLASS_RECSYN, syntax, oidbuf); + printf ("%d %s %s (%s)\n", + pos, (db ? db : "unknown"), syntax, oidbuf); + if (render) + fwrite (render, 1, len, stdout); + printf ("\n"); + if (opac_render) + fwrite (opac_render, 1, opac_len, stdout); + } } }