bad record on position 98 (for testing).
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
* 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 <stdio.h>
#include <stdlib.h>
#include <time.h>
}
}
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;
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,
* 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
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
* 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
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)
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);
* 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
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;
}