X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=ztest%2Fread-marc.c;fp=ztest%2Fread-marc.c;h=fdcc174236e2877ed5c556f256f1c2082da06a4b;hp=c31eab3b9b7d78283b37a5e34ba83b3271e6f916;hb=810fd9221e5d34c4f3c4f8e2b4410f947cbc2504;hpb=cd7c85097df2b7ccd4728e5911348b6e78ccf7f2 diff --git a/ztest/read-marc.c b/ztest/read-marc.c index c31eab3..fdcc174 100644 --- a/ztest/read-marc.c +++ b/ztest/read-marc.c @@ -1581,25 +1581,31 @@ char *dummy_marc_record(int num, ODR odr) } /* read MARC record and convert to XML */ -char *dummy_xml_record(int num, ODR odr) +char *dummy_xml_record(int num, ODR odr, const char *esn) { char *rec = dummy_marc_record(num, odr); if (rec) { - const char *result; - size_t rlen; - int len; + WRBUF w = wrbuf_alloc(); yaz_marc_t mt = yaz_marc_create(); + yaz_marc_xml(mt, YAZ_MARC_MARCXML); - len = yaz_marc_decode_buf(mt, rec, -1, &result, &rlen); - if (len > 1) + if (esn && !strcmp(esn, "OP")) + { + /* generate OPACXML (OPAC in XML) */ + Z_OPACRecord *opac = dummy_opac(num, odr, rec); + yaz_opac_decode_wrbuf(mt, opac, w); + } + else { - rec = (char *) odr_malloc(odr, rlen+1); - memcpy(rec, result, rlen); - rec[rlen] = '\0'; + /* generate MARCXML */ + yaz_marc_decode_wrbuf(mt, rec, -1, w); } + rec = odr_strdup(odr, wrbuf_cstr(w)); yaz_marc_destroy(mt); + wrbuf_destroy(w); + } return rec; }