Attempt ISO2709 decoding of any octet aligned record
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 19 Aug 2013 08:54:03 +0000 (10:54 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 19 Aug 2013 08:54:03 +0000 (10:54 +0200)
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.

client/client.c
src/record_render.c

index 0a36651..f354979 100644 (file)
@@ -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))
index 248abe1..6acb1d7 100644 (file)
@@ -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,