X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=ztest%2Fread-marc.c;h=938804857d9d4cd280bc796fd77e11fa1cafaf23;hb=a92ea4f2be422ed5f52f0fc1c8b6416aebfe0c5a;hp=6333a40a42a4661fa07f8996443b6eea23a6e765;hpb=165b231b0f6eaa0b2b5fbf438f5ddede630b10e3;p=yaz-moved-to-github.git diff --git a/ztest/read-marc.c b/ztest/read-marc.c index 6333a40..9388048 100644 --- a/ztest/read-marc.c +++ b/ztest/read-marc.c @@ -1,16 +1,17 @@ /* - * Copyright (c) 2002, Index Data. + * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: read-marc.c,v 1.3 2002-09-24 08:05:41 adam Exp $ + * $Id: read-marc.c,v 1.10 2007-05-06 20:12:22 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,31 @@ 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(); + const char *result; + size_t 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 = (char *) odr_malloc (odr, len+1); - memcpy (rec, wrbuf_buf(wr), len+1); - rec[len] = 0; + rec = (char *) odr_malloc(odr, rlen+1); + memcpy(rec, result, rlen); + rec[rlen] = '\0'; } - wrbuf_free (wr, 1); + yaz_marc_destroy(mt); return rec; } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +