From: Adam Dickmeiss Date: Mon, 19 Aug 2013 08:54:03 +0000 (+0200) Subject: Attempt ISO2709 decoding of any octet aligned record X-Git-Tag: v4.2.64~4 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=1533023386c841cac9832a246e871795a2b217fc;p=yaz-moved-to-github.git Attempt ISO2709 decoding of any octet aligned record Until this point only certain OIDs would trigger ISO2709 decoding. With this change all octet aligned records will be run though the MARC parser. If it's not MARC, an error will only occur if it is a known MARC OID. If not, all bets are off. It's probably not MARC if it doesn't parse. --- diff --git a/client/client.c b/client/client.c index 0a36651..f354979 100644 --- a/client/client.c +++ b/client/client.c @@ -929,7 +929,7 @@ static void display_record(Z_External *r) print_xml_record(octet_buf, octet_len); } - else if (yaz_oid_is_iso2709(oid)) + else { const char *result; size_t rlen; @@ -975,17 +975,14 @@ static void display_record(Z_External *r) } else { - printf("bad MARC. Dumping as it is:\n"); + if (yaz_oid_is_iso2709(oid)) + printf("bad MARC. Dumping as it is:\n"); print_record(octet_buf, octet_len); } yaz_marc_destroy(mt); if (cd) yaz_iconv_close(cd); } - else - { - print_record(octet_buf, octet_len); - } marc_file_write(octet_buf, r->u.octet_aligned->len); } else if (oid && !oid_oidcmp(oid, yaz_oid_recsyn_sutrs)) diff --git a/src/record_render.c b/src/record_render.c index 248abe1..6acb1d7 100644 --- a/src/record_render.c +++ b/src/record_render.c @@ -167,19 +167,16 @@ static const char *return_record_wrbuf(WRBUF wrbuf, int *len, charset); else if (r->which == Z_External_octet) { - if (yaz_oid_is_iso2709(oid)) - { - const char *ret_buf = return_marc_record( - wrbuf, marctype, len, - (const char *) r->u.octet_aligned->buf, - r->u.octet_aligned->len, - charset); - if (ret_buf) - return ret_buf; - /* bad ISO2709. Return fail unless raw (ISO2709) is wanted */ - if (marctype != YAZ_MARC_ISO2709) - return 0; - } + const char *ret_buf = return_marc_record( + wrbuf, marctype, len, + (const char *) r->u.octet_aligned->buf, + r->u.octet_aligned->len, + charset); + if (ret_buf) + return ret_buf; + /* not ISO2709. Return fail unless raw (ISO2709) is wanted */ + if (yaz_oid_is_iso2709(oid) && marctype != YAZ_MARC_ISO2709) + return 0; return return_string_record(wrbuf, len, (const char *) r->u.octet_aligned->buf, r->u.octet_aligned->len,