X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=ztest%2Fread-marc.c;h=850b7060322fb541dbcf8368e9fb3f7c8fa29274;hp=8b9fb4ecb799b22efb33105019f3acaefb391f93;hb=2b3dd45defce5c722aea0d5cecfbd8db7df55818;hpb=eb14cf14b5b176a8e2b73ca251d625e47223f116 diff --git a/ztest/read-marc.c b/ztest/read-marc.c index 8b9fb4e..850b706 100644 --- a/ztest/read-marc.c +++ b/ztest/read-marc.c @@ -2,15 +2,16 @@ * Copyright (c) 2002, Index Data. * See the file LICENSE for details. * - * $Id: read-marc.c,v 1.1 2002-03-18 21:33:48 adam Exp $ + * $Id: read-marc.c,v 1.5 2004-12-30 00:18:04 adam Exp $ */ /* * Little toy-thing to read a MARC records from a fixed array. */ - -#include +#include #include +#include +#include char *marc_records[] = { @@ -1536,7 +1537,7 @@ static int atoin (const char *buf, int n) int val = 0; while (--n >= 0) { - if (isdigit(*buf)) + if (isdigit(*(const unsigned char *) buf)) val = val*10 + (*buf - '0'); buf++; } @@ -1600,20 +1601,19 @@ char *dummy_marc_record (int num, ODR odr) /* read MARC record and convert to XML */ char *dummy_xml_record (int num, ODR odr) { - WRBUF wr = wrbuf_alloc (); + yaz_marc_t mt = yaz_marc_create(); + char *result; + int rlen; char *rec = dummy_marc_record (num, odr); int len; + if (!rec) return 0; - len = yaz_marc_decode (rec, wr, 0, -1, 1); + yaz_marc_xml(mt, YAZ_MARC_MARCXML); + len = yaz_marc_decode_buf (mt, rec, -1, &result, &rlen); if (len > 1) - { - len = wrbuf_len(wr); - rec = odr_malloc (odr, len+1); - memcpy (rec, wrbuf_buf(wr), len+1); - rec[len] = 0; - } - wrbuf_free (wr, 1); + rec = (char *) odr_strdup(odr, result); + yaz_marc_destroy(mt); return rec; }