Extended OPAC display utility. OPAC display utility renders
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 25 Feb 2005 17:05:09 +0000 (17:05 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 25 Feb 2005 17:05:09 +0000 (17:05 +0000)
bibliographic (MARC) record as well. Added yaz_opac_decode_wrbuf
to supplement yaz_marc_decode_wrbuf.

NEWS
include/yaz/proto.h
src/opacdisp.c

diff --git a/NEWS b/NEWS
index 74cf109..c5d1141 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
 Possible compatibility problems with earlier versions marked with '*'.
 
 Possible compatibility problems with earlier versions marked with '*'.
 
+Extended OPAC display utility. OPAC display utility renders
+bibliographic (MARC) record as well. Added yaz_opac_decode_wrbuf
+to supplement yaz_marc_decode_wrbuf.
+
 --- 2.0.34 2005/02/08 
 
 Fixes for UNIX domain sockets. Bug #261.
 --- 2.0.34 2005/02/08 
 
 Fixes for UNIX domain sockets. Bug #261.
index 243ac0a..2ba1770 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: proto.h,v 1.19 2005-01-27 09:06:51 adam Exp $
+ * $Id: proto.h,v 1.20 2005-02-25 17:05:09 adam Exp $
  */
 /**
  * \file proto.h
  */
 /**
  * \file proto.h
@@ -48,6 +48,7 @@
 #include <yaz/zgdu.h>
 #include <yaz/z-oclcui.h>
 
 #include <yaz/zgdu.h>
 #include <yaz/z-oclcui.h>
 
+#include <yaz/marcdisp.h>
 YAZ_BEGIN_CDECL
 
 #if 1
 YAZ_BEGIN_CDECL
 
 #if 1
@@ -121,6 +122,9 @@ YAZ_EXPORT void yaz_display_grs1(WRBUF wrbuf, Z_GenericRecord *r, int flags);
 /** \brief Performs "pretty" display of OPAC record to WRBUF */
 YAZ_EXPORT void yaz_display_OPAC(WRBUF wrbuf, Z_OPACRecord *r, int flags);
 
 /** \brief Performs "pretty" display of OPAC record to WRBUF */
 YAZ_EXPORT void yaz_display_OPAC(WRBUF wrbuf, Z_OPACRecord *r, int flags);
 
+/** \brief Performs "pretty" display of OPAC record to WRBUF using marc_t */
+void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf);
+
 /** \brief Encodes Z39.50 Init OPtions based on string mnemonics */
 YAZ_EXPORT int yaz_init_opt_encode(Z_Options *opt, const char *opt_str,
                                   int *error_pos);
 /** \brief Encodes Z39.50 Init OPtions based on string mnemonics */
 YAZ_EXPORT int yaz_init_opt_encode(Z_Options *opt, const char *opt_str,
                                   int *error_pos);
index 3ee7ff6..79c1dde 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: opacdisp.c,v 1.4 2005-01-15 19:47:14 adam Exp $
+ * $Id: opacdisp.c,v 1.5 2005-02-25 17:05:09 adam Exp $
  */
 /**
  * \file opacdisp.c
  */
 /**
  * \file opacdisp.c
@@ -15,6 +15,7 @@
 #include <ctype.h>
 
 #include <yaz/proto.h>
 #include <ctype.h>
 
 #include <yaz/proto.h>
+#include <yaz/marcdisp.h>
 
 static void opac_element_str(WRBUF wrbuf, int l, const char *elem,
                             const char *data)
 
 static void opac_element_str(WRBUF wrbuf, int l, const char *elem,
                             const char *data)
@@ -49,11 +50,22 @@ static void opac_element_bool(WRBUF wrbuf, int l, const char *elem, int *data)
     }
 }
 
     }
 }
 
-void yaz_display_OPAC(WRBUF wrbuf, Z_OPACRecord *r, int flags)
+void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
 {
     int i;
 {
     int i;
+
     wrbuf_puts(wrbuf, "<holdings>\n");
 
     wrbuf_puts(wrbuf, "<holdings>\n");
 
+    if (r->bibliographicRecord)
+    {
+       Z_External *ext = r->bibliographicRecord;
+       
+       wrbuf_puts (wrbuf, "  <bibliographicRecord>\n");
+       if (ext->which == Z_External_octet)
+           yaz_marc_decode_wrbuf(mt, ext->u.octet_aligned->buf,
+                                 ext->u.octet_aligned->len, wrbuf);
+       wrbuf_puts (wrbuf, "  </bibliographicRecord>\n");
+    }
     for (i = 0; i < r->num_holdingsData; i++)
     {
        Z_HoldingsRecord *h = r->holdingsData[i];
     for (i = 0; i < r->num_holdingsData; i++)
     {
        Z_HoldingsRecord *h = r->holdingsData[i];
@@ -61,8 +73,13 @@ void yaz_display_OPAC(WRBUF wrbuf, Z_OPACRecord *r, int flags)
 
        if (h->which == Z_HoldingsRecord_marcHoldingsRecord)
        {
 
        if (h->which == Z_HoldingsRecord_marcHoldingsRecord)
        {
-           wrbuf_puts (wrbuf, "  <marc/>\n");
-       /*  h->u.marcHoldingsRecord) */
+           Z_External *ext = h->u.marcHoldingsRecord;
+
+           wrbuf_puts (wrbuf, "  <marcHoldingsRecord>\n");
+           if (ext->which == Z_External_octet)
+               yaz_marc_decode_wrbuf(mt, ext->u.octet_aligned->buf,
+                                     ext->u.octet_aligned->len, wrbuf);
+           wrbuf_puts (wrbuf, "  </marcHoldingsRecord>\n");
        }
        else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
        {
        }
        else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
        {
@@ -139,3 +156,13 @@ void yaz_display_OPAC(WRBUF wrbuf, Z_OPACRecord *r, int flags)
     }
     wrbuf_puts(wrbuf, "</holdings>\n");
 }
     }
     wrbuf_puts(wrbuf, "</holdings>\n");
 }
+
+void yaz_display_OPAC(WRBUF wrbuf, Z_OPACRecord *opac_rec, int flags)
+{
+    yaz_marc_t mt = yaz_marc_create();
+
+    yaz_marc_xml(mt, YAZ_MARC_MARCXML);
+    yaz_opac_decode_wrbuf(mt, opac_rec, wrbuf);
+    yaz_marc_destroy(mt);
+}
+