From: Adam Dickmeiss Date: Mon, 29 Oct 2001 09:17:19 +0000 (+0000) Subject: New function marc_display_exl - used by YAZ client. Server returns X-Git-Tag: YAZ.1.8.2~17 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=b24d2d58cd28380a1969780e5e2d7c4f0719f81c;p=yaz-moved-to-github.git New function marc_display_exl - used by YAZ client. Server returns bad record on position 98 (for testing). --- diff --git a/CHANGELOG b/CHANGELOG index a89d773..fc7c75e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,11 @@ Possible compatibility problems with earlier versions marked with '*'. +New MARC decode/display function, marc_display_exl, which better rejects +bad ISO2709 records. YAZ client uses it. + --- 1.8.1 2001/10/29 -Fix bug: local attribute wasn't set correctly in PQF strings. +Fix bug: local attribute set wasn't set correctly in PQF strings. --- 1.8 2001/10/25 diff --git a/client/client.c b/client/client.c index 244ba5f..315b5b8 100644 --- a/client/client.c +++ b/client/client.c @@ -2,15 +2,10 @@ * Copyright (c) 1995-2001, Index Data * See the file LICENSE for details. * - * $Id: client.c,v 1.128 2001-10-24 12:24:43 adam Exp $ + * $Id: client.c,v 1.129 2001-10-29 09:17:19 adam Exp $ * */ -/* - * This is the obligatory little toy client, whose primary purpose is - * to illustrate the use of the YAZ service-level API. - */ - #include #include #include @@ -494,7 +489,8 @@ static void display_record(Z_DatabaseRecord *p) } } if (ent && ent->value == VAL_SOIF) - print_record((const unsigned char *) r->u.octet_aligned->buf, r->u.octet_aligned->len); + print_record((const unsigned char *) r->u.octet_aligned->buf, + r->u.octet_aligned->len); else if (r->which == Z_External_octet && p->u.octet_aligned->len) { const char *octet_buf = (char*)p->u.octet_aligned->buf; @@ -504,7 +500,9 @@ static void display_record(Z_DatabaseRecord *p) p->u.octet_aligned->len); else { - if (marc_display (octet_buf, NULL) <= 0) + if (marc_display_exl (octet_buf, NULL, 0 /* debug */, + p->u.octet_aligned->len) + <= 0) { printf ("ISO2709 decoding failed, dumping record as is:\n"); print_record((const unsigned char*) octet_buf, diff --git a/include/yaz/marcdisp.h b/include/yaz/marcdisp.h index 13b41b5..86abc0f 100644 --- a/include/yaz/marcdisp.h +++ b/include/yaz/marcdisp.h @@ -24,7 +24,11 @@ * OF THIS SOFTWARE. * * $Log: marcdisp.h,v $ - * Revision 1.3 2001-04-06 12:26:46 adam + * Revision 1.4 2001-10-29 09:17:19 adam + * New function marc_display_exl - used by YAZ client. Server returns + * bad record on position 98 (for testing). + * + * Revision 1.3 2001/04/06 12:26:46 adam * Optional CCL module. Moved atoi_n to marcdisp.h from yaz-util.h. * * Revision 1.2 2000/02/28 11:20:06 adam @@ -69,6 +73,8 @@ YAZ_BEGIN_CDECL YAZ_EXPORT int marc_display (const char *buf, FILE *outf); YAZ_EXPORT int marc_display_ex (const char *buf, FILE *outf, int debug); +YAZ_EXPORT int marc_display_exl (const char *buf, FILE *outf, int debug, + int length); YAZ_EXPORT int atoi_n (const char *buf, int len); #define ISO2709_RS 035 diff --git a/util/marcdisp.c b/util/marcdisp.c index ab2ef2f..3249b53 100644 --- a/util/marcdisp.c +++ b/util/marcdisp.c @@ -3,7 +3,11 @@ * See the file LICENSE for details. * * $Log: marcdisp.c,v $ - * Revision 1.14 2001-10-23 21:00:20 adam + * Revision 1.15 2001-10-29 09:17:19 adam + * New function marc_display_exl - used by YAZ client. Server returns + * bad record on position 98 (for testing). + * + * Revision 1.14 2001/10/23 21:00:20 adam * Old Z39.50 codecs gone. Added ZOOM. WRBUF MARC display util. * * Revision 1.13 2001/10/15 19:36:48 adam @@ -187,12 +191,12 @@ int marc_display_wrbuf (const char *buf, WRBUF wr, int debug, return record_length; } -int marc_display_ex (const char *buf, FILE *outf, int debug) +int marc_display_exl (const char *buf, FILE *outf, int debug, int length) { int record_length; WRBUF wrbuf = wrbuf_alloc (); - record_length = marc_display_wrbuf (buf, wrbuf, debug, -1); + record_length = marc_display_wrbuf (buf, wrbuf, debug, length); if (!outf) outf = stdout; if (record_length > 0) @@ -201,6 +205,12 @@ int marc_display_ex (const char *buf, FILE *outf, int debug) return record_length; } + +int marc_display_ex (const char *buf, FILE *outf, int debug) +{ + return marc_display_exl (buf, outf, debug, -1); +} + int marc_display (const char *buf, FILE *outf) { return marc_display_ex (buf, outf, 0); diff --git a/ztest/ztest.c b/ztest/ztest.c index b87258f..ba85739 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -6,7 +6,11 @@ * Chas Woodfield, Fretwell Downing Datasystems. * * $Log: ztest.c,v $ - * Revision 1.44 2001-07-19 19:51:42 adam + * Revision 1.45 2001-10-29 09:17:19 adam + * New function marc_display_exl - used by YAZ client. Server returns + * bad record on position 98 (for testing). + * + * Revision 1.44 2001/07/19 19:51:42 adam * Added typecasts to make C++ happy. * * Revision 1.43 2001/06/28 09:27:25 adam @@ -533,23 +537,23 @@ static char *dummy_database_record (int num, ODR odr) if (!inf) return NULL; - while (--num >= 0) + if (num == 98) + { /* this will generate a very bad MARC record (testing only) */ + buf = (char*) odr_malloc(odr, 2101); + memset(buf, '7', 2100); + buf[2100] = '\0'; + } + else { - if (num == 98) - { - buf = (char*) odr_malloc(odr, 2101); - memset(buf, 'A', 2100); - buf[2100] = '\0'; - break; - } - else - buf = marc_read (inf, odr); - if (!num || !buf) - break; + /* OK, try to get proper MARC records from the file */ + while (--num >= 0) + { + buf = marc_read (inf, odr); + if (!buf) + break; + } } fclose(inf); - if (num < 0) - return 0; return buf; }