Fixed bug #395: ZOOM_record / OPAC record encoding problems.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 30 Jan 2008 20:00:55 +0000 (20:00 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 30 Jan 2008 20:00:55 +0000 (20:00 +0000)
The function yaz_opac_decode_wrbuf now uses the iconv handle as
used by the yaz_mart_t handle to char convert the strings in the
OPAC records (ASN.1). Presumaby this string data has same encoding
as the embedded ISO2709 record.

NEWS
src/opacdisp.c

diff --git a/NEWS b/NEWS
index 77aef8c..d7a00a3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+Fixed bug #395: ZOOM_record / OPAC record encoding problems.
+
 --- 3.0.24 2008/01/28
 
 Document --with-xml2 option.
index e8b4b04..f8e89ca 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (C) 1995-2007, Index Data ApS
+ * Copyright (C) 1995-2008, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: opacdisp.c,v 1.9 2007-01-03 08:42:15 adam Exp $
+ * $Id: opacdisp.c,v 1.10 2008-01-30 20:00:55 adam Exp $
  */
 /**
  * \file opacdisp.c
@@ -17,7 +17,8 @@
 #include <yaz/proto.h>
 #include <yaz/marcdisp.h>
 
-static void opac_element_str(WRBUF wrbuf, int l, const char *elem,
+static void opac_element_str(WRBUF wrbuf, yaz_iconv_t cd, 
+                             int l, const char *elem,
                              const char *data)
 {
     if (data)
@@ -27,7 +28,7 @@ static void opac_element_str(WRBUF wrbuf, int l, const char *elem,
         wrbuf_puts(wrbuf, "<");
         wrbuf_puts(wrbuf, elem);
         wrbuf_puts(wrbuf, ">");
-        wrbuf_xmlputs(wrbuf, data);
+        wrbuf_iconv_puts_cdata(wrbuf, cd, data);
         wrbuf_puts(wrbuf, "</");
         wrbuf_puts(wrbuf, elem);
         wrbuf_puts(wrbuf, ">\n");
@@ -53,17 +54,18 @@ static void opac_element_bool(WRBUF wrbuf, int l, const char *elem, int *data)
 void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
 {
     int i;
+    yaz_iconv_t cd = yaz_marc_get_iconv(mt);
 
     wrbuf_puts(wrbuf, "<opacRecord>\n");
     if (r->bibliographicRecord)
     {
         Z_External *ext = r->bibliographicRecord;
         
-        wrbuf_puts (wrbuf, "  <bibliographicRecord>\n");
+        wrbuf_puts(wrbuf, "  <bibliographicRecord>\n");
         if (ext->which == Z_External_octet)
             yaz_marc_decode_wrbuf(mt, (const char *) ext->u.octet_aligned->buf,
                                   ext->u.octet_aligned->len, wrbuf);
-        wrbuf_puts (wrbuf, "  </bibliographicRecord>\n");
+        wrbuf_puts(wrbuf, "  </bibliographicRecord>\n");
     }
     wrbuf_puts(wrbuf, "<holdings>\n");
 
@@ -76,12 +78,12 @@ void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
         {
             Z_External *ext = h->u.marcHoldingsRecord;
 
-            wrbuf_puts (wrbuf, "  <marcHoldingsRecord>\n");
+            wrbuf_puts(wrbuf, "  <marcHoldingsRecord>\n");
             if (ext->which == Z_External_octet)
                 yaz_marc_decode_wrbuf(mt, (const char *)
                                       ext->u.octet_aligned->buf,
                                       ext->u.octet_aligned->len, wrbuf);
-            wrbuf_puts (wrbuf, "  </marcHoldingsRecord>\n");
+            wrbuf_puts(wrbuf, "  </marcHoldingsRecord>\n");
         }
         else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
         {
@@ -89,69 +91,69 @@ void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
             
             Z_HoldingsAndCircData *d = h->u.holdingsAndCirc;
         
-            opac_element_str(wrbuf, 2, "typeOfRecord", d->typeOfRecord);
-            opac_element_str(wrbuf, 2, "encodingLevel", d->encodingLevel);
-            opac_element_str(wrbuf, 2, "format", d->format);
-            opac_element_str(wrbuf, 2, "receiptAcqStatus", d->receiptAcqStatus);
-            opac_element_str (wrbuf, 2, "generalRetention", d->generalRetention);
-            opac_element_str (wrbuf, 2, "completeness", d->completeness);
-            opac_element_str (wrbuf, 2, "dateOfReport", d->dateOfReport);
-            opac_element_str (wrbuf, 2, "nucCode", d->nucCode);
-            opac_element_str (wrbuf, 2, "localLocation", d->localLocation);
-            opac_element_str (wrbuf, 2, "shelvingLocation", d->shelvingLocation);
-            opac_element_str (wrbuf, 2, "callNumber", d->callNumber);
-            opac_element_str (wrbuf, 2, "shelvingData", d->shelvingData);
+            opac_element_str(wrbuf, cd, 2, "typeOfRecord", d->typeOfRecord);
+            opac_element_str(wrbuf, cd, 2, "encodingLevel", d->encodingLevel);
+            opac_element_str(wrbuf, cd, 2, "format", d->format);
+            opac_element_str(wrbuf, cd, 2, "receiptAcqStatus", d->receiptAcqStatus);
+            opac_element_str(wrbuf, cd, 2, "generalRetention", d->generalRetention);
+            opac_element_str(wrbuf, cd, 2, "completeness", d->completeness);
+            opac_element_str(wrbuf, cd, 2, "dateOfReport", d->dateOfReport);
+            opac_element_str(wrbuf, cd, 2, "nucCode", d->nucCode);
+            opac_element_str(wrbuf, cd, 2, "localLocation", d->localLocation);
+            opac_element_str(wrbuf, cd, 2, "shelvingLocation", d->shelvingLocation);
+            opac_element_str(wrbuf, cd, 2, "callNumber", d->callNumber);
+            opac_element_str(wrbuf, cd, 2, "shelvingData", d->shelvingData);
             
-            opac_element_str (wrbuf, 2, "copyNumber", d->copyNumber);
-            opac_element_str (wrbuf, 2, "publicNote", d->publicNote);
-            opac_element_str (wrbuf, 2, "reproductionNote", d->reproductionNote);
-            opac_element_str (wrbuf, 2, "termsUseRepro", d->termsUseRepro);
-            opac_element_str (wrbuf, 2, "enumAndChron", d->enumAndChron);
+            opac_element_str(wrbuf, cd, 2, "copyNumber", d->copyNumber);
+            opac_element_str(wrbuf, cd, 2, "publicNote", d->publicNote);
+            opac_element_str(wrbuf, cd, 2, "reproductionNote", d->reproductionNote);
+            opac_element_str(wrbuf, cd, 2, "termsUseRepro", d->termsUseRepro);
+            opac_element_str(wrbuf, cd, 2, "enumAndChron", d->enumAndChron);
             if (d->num_volumes)
             {
                 wrbuf_puts (wrbuf, "  <volumes>\n");
                 for (j = 0; j<d->num_volumes; j++)
                 {
                     wrbuf_puts (wrbuf, "   <volume>\n");
-                    opac_element_str (wrbuf, 4, "enumeration",
-                                      d->volumes[j]->enumeration);
-                    opac_element_str (wrbuf, 4, "chronology",
-                                      d->volumes[j]->chronology);
-                    opac_element_str (wrbuf, 4, "enumAndChron",
-                                      d->volumes[j]->enumAndChron);
-                    wrbuf_puts (wrbuf, "   </volume>\n");
+                    opac_element_str(wrbuf, cd, 4, "enumeration",
+                                     d->volumes[j]->enumeration);
+                    opac_element_str(wrbuf, cd, 4, "chronology",
+                                     d->volumes[j]->chronology);
+                    opac_element_str(wrbuf, cd, 4, "enumAndChron",
+                                     d->volumes[j]->enumAndChron);
+                    wrbuf_puts(wrbuf, "   </volume>\n");
                 }
-                wrbuf_puts (wrbuf, "  </volumes>\n");
+                wrbuf_puts(wrbuf, "  </volumes>\n");
             }
             if (d->num_circulationData)
             {
                 wrbuf_puts (wrbuf, "  <circulations>\n");
                 for (j = 0; j<d->num_circulationData; j++)
                 {
-                    wrbuf_puts (wrbuf,"   <circulation>\n");
-                    opac_element_bool (wrbuf, 4, "availableNow",
-                                       d->circulationData[j]->availableNow);
-                    opac_element_str (wrbuf, 4, "availabiltyDate",
-                                      d->circulationData[j]->availablityDate);
-                    opac_element_str (wrbuf, 4, "availableThru",
+                    wrbuf_puts(wrbuf,"   <circulation>\n");
+                    opac_element_bool(wrbuf, 4, "availableNow",
+                                      d->circulationData[j]->availableNow);
+                    opac_element_str(wrbuf, cd, 4, "availabiltyDate",
+                                     d->circulationData[j]->availablityDate);
+                    opac_element_str(wrbuf, cd, 4, "availableThru",
                                       d->circulationData[j]->availableThru);
-                    opac_element_str (wrbuf, 4, "restrictions",
+                    opac_element_str(wrbuf, cd, 4, "restrictions",
                                       d->circulationData[j]->restrictions);
-                    opac_element_str (wrbuf, 4, "itemId",
+                    opac_element_str(wrbuf, cd, 4, "itemId",
                                       d->circulationData[j]->itemId);
-                    opac_element_bool (wrbuf, 4, "renewable",
-                                       d->circulationData[j]->renewable);
-                    opac_element_bool (wrbuf, 4, "onHold",
-                                       d->circulationData[j]->onHold);
-                    opac_element_str (wrbuf, 4, "enumAndChron",
+                    opac_element_bool(wrbuf, 4, "renewable",
+                                      d->circulationData[j]->renewable);
+                    opac_element_bool(wrbuf, 4, "onHold",
+                                      d->circulationData[j]->onHold);
+                    opac_element_str(wrbuf, cd, 4, "enumAndChron",
                                       d->circulationData[j]->enumAndChron);
-                    opac_element_str (wrbuf, 4, "midspine",
+                    opac_element_str(wrbuf, cd, 4, "midspine",
                                       d->circulationData[j]->midspine);
-                    opac_element_str (wrbuf, 4, "temporaryLocation",
+                    opac_element_str(wrbuf, cd, 4, "temporaryLocation",
                                       d->circulationData[j]->temporaryLocation);
-                    wrbuf_puts (wrbuf, "   </circulation>\n");
+                    wrbuf_puts(wrbuf, "   </circulation>\n");
                 }
-                wrbuf_puts (wrbuf, "  </circulations>\n");
+                wrbuf_puts(wrbuf, "  </circulations>\n");
             }
         }
         wrbuf_puts(wrbuf, " </holding>\n");