Dummy OPAC records has a little more dummy data in it.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 2 Jun 2008 10:35:48 +0000 (12:35 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 2 Jun 2008 10:35:48 +0000 (12:35 +0200)
win/makefile
ztest/Makefile.am
ztest/dummy-opac.c [new file with mode: 0644]
ztest/ztest.c
ztest/ztest.h

index b4cd961..b170a1d 100644 (file)
@@ -330,6 +330,7 @@ YAZ_CLIENT_OBJS= \
 YAZ_ICU_OBJS= $(OBJDIR)\yaz-icu.obj 
 
 ZTEST_OBJS= \
 YAZ_ICU_OBJS= $(OBJDIR)\yaz-icu.obj 
 
 ZTEST_OBJS= \
+    $(OBJDIR)\dummy-opac.obj \
     $(OBJDIR)\read-marc.obj \
     $(OBJDIR)\read-grs.obj \
     $(OBJDIR)\ztest.obj 
     $(OBJDIR)\read-marc.obj \
     $(OBJDIR)\read-grs.obj \
     $(OBJDIR)\ztest.obj 
index 5a5297f..3028b57 100644 (file)
@@ -3,7 +3,7 @@
 
 bin_PROGRAMS=yaz-ztest
 
 
 bin_PROGRAMS=yaz-ztest
 
-yaz_ztest_SOURCES=ztest.c read-grs.c read-marc.c ztest.h
+yaz_ztest_SOURCES=ztest.c read-grs.c read-marc.c dummy-opac.c ztest.h
 
 EXTRA_DIST=dummy-records dummy-words dummy-grs ztest.pem config1.xml
 
 
 EXTRA_DIST=dummy-records dummy-words dummy-grs ztest.pem config1.xml
 
diff --git a/ztest/dummy-opac.c b/ztest/dummy-opac.c
new file mode 100644 (file)
index 0000000..e0ef278
--- /dev/null
@@ -0,0 +1,85 @@
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2008 Index Data
+ * See the file LICENSE for details.
+ */
+
+/** \file
+ * \brief Little toy-thing to genearate an OPAC record with some values
+ */
+
+#include <ctype.h>
+#include <yaz/wrbuf.h>
+#include <yaz/marcdisp.h>
+#include <yaz/odr.h>
+
+#include "ztest.h"
+
+Z_OPACRecord *dummy_opac(int num, ODR odr, const char *marc_input)
+{
+    Z_OPACRecord *rec;
+    int i;
+    rec = odr_malloc(odr, sizeof(*rec));
+    rec->bibliographicRecord =
+        z_ext_record_usmarc(odr, marc_input, strlen(marc_input));
+    rec->num_holdingsData = 1;
+    rec->holdingsData = odr_malloc(odr, sizeof(*rec->holdingsData));
+    for (i = 0; i < rec->num_holdingsData; i++)
+    {
+        Z_HoldingsRecord *hr = odr_malloc(odr, sizeof(*hr));
+        Z_HoldingsAndCircData *hc = odr_malloc(odr, sizeof(*hc));
+        
+        rec->holdingsData[i] = hr;
+        hr->which = Z_HoldingsRecord_holdingsAndCirc;
+        hr->u.holdingsAndCirc = hc;
+            
+        hc->typeOfRecord = "u";
+
+        hc->encodingLevel = "u";
+
+        hc->format = 0; /* OPT */
+        hc->receiptAcqStatus = "0";
+        hc->generalRetention = 0; /* OPT */
+        hc->completeness = 0; /* OPT */
+        hc->dateOfReport = "000000";
+        hc->nucCode = "s-FM/GC";
+        hc->localLocation = 
+            "Main or Science/Business Reading Rms - STORED OFFSITE";
+        hc->shelvingLocation = 0; /* OPT */
+        hc->callNumber = "MLCM 89/00602 (N)";
+        hc->shelvingData = "FT MEADE";
+        hc->copyNumber = "Copy 1";
+        hc->publicNote = 0; /* OPT */
+        hc->reproductionNote = 0; /* OPT */
+        hc->termsUseRepro = 0; /* OPT */
+        hc->enumAndChron = 0; /* OPT */
+
+        hc->num_volumes = 0;
+        hc->volumes = 0;
+
+        hc->num_circulationData = 1;
+        hc->circulationData = odr_malloc(odr, 
+                                         sizeof(*hc->circulationData));
+        hc->circulationData[0] = odr_malloc(odr, 
+                                            sizeof(**hc->circulationData));
+
+        hc->circulationData[0]->availableNow = odr_intdup(odr, 1);
+        hc->circulationData[0]->availablityDate = 0;
+        hc->circulationData[0]->availableThru = 0;
+        hc->circulationData[0]->restrictions = 0;
+        hc->circulationData[0]->itemId = "1226176";
+        hc->circulationData[0]->renewable = odr_intdup(odr, 0);
+        hc->circulationData[0]->onHold = odr_intdup(odr, 0);
+        hc->circulationData[0]->enumAndChron = 0;
+        hc->circulationData[0]->midspine = 0;
+        hc->circulationData[0]->temporaryLocation = 0;
+    }
+    return rec;
+}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 1a0579f..76dd459 100644 (file)
@@ -535,59 +535,14 @@ int ztest_fetch(void *handle, bend_fetch_rr *r)
     }
     else if (!oid_oidcmp(oid, yaz_oid_recsyn_opac))
     {
     }
     else if (!oid_oidcmp(oid, yaz_oid_recsyn_opac))
     {
-        Z_OPACRecord *rec;
-        int i;
         cp = dummy_marc_record(r->number, r->stream);
         if (!cp)
         {
             r->errcode = YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE;
             return 0;
         }
         cp = dummy_marc_record(r->number, r->stream);
         if (!cp)
         {
             r->errcode = YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE;
             return 0;
         }
-        rec = odr_malloc(r->stream, sizeof(*rec));
-        rec->bibliographicRecord =
-            z_ext_record_usmarc(r->stream, cp, strlen(cp));
-        rec->num_holdingsData = 1;
-        rec->holdingsData = odr_malloc(r->stream, sizeof(*rec->holdingsData));
-        for (i = 0; i < rec->num_holdingsData; i++)
-        {
-            Z_HoldingsRecord *hr = odr_malloc(r->stream, sizeof(*hr));
-            Z_HoldingsAndCircData *hc = odr_malloc(r->stream, sizeof(*hc));
-
-            rec->holdingsData[i] = hr;
-            hr->which = Z_HoldingsRecord_holdingsAndCirc;
-            hr->u.holdingsAndCirc = hc;
-            
-            hc->typeOfRecord = odr_strdup(r->stream, "x");
-            hc->typeOfRecord[0] = cp[5]; /* LDR 6 */
-
-            hc->encodingLevel = odr_strdup(r->stream, "x");
-            hc->encodingLevel[0] = cp[16]; /* LDR 17 */
-
-            hc->format = 0; /* OPT */
-            hc->receiptAcqStatus = 0; /* OPT */
-            hc->generalRetention = 0; /* OPT */
-            hc->completeness = 0; /* OPT */
-            hc->dateOfReport = 0; /* OPT */
-            hc->nucCode = 0; /* OPT */
-            hc->localLocation = 0; /* OPT */
-            hc->shelvingLocation = 0; /* OPT */
-            hc->callNumber = 0; /* OPT */
-            hc->shelvingData = 0; /* OPT */
-            hc->copyNumber = 0; /* OPT */
-            hc->publicNote = 0; /* OPT */
-            hc->reproductionNote = 0; /* OPT */
-            hc->termsUseRepro = 0; /* OPT */
-            hc->enumAndChron = 0; /* OPT */
-
-            hc->num_volumes = 0;
-            hc->volumes = 0;
-
-            hc->num_circulationData = 0;
-            hc->circulationData = 0;
-        }
-
+        r->record = (char *) dummy_opac(r->number, r->stream, cp);
         r->len = -1;
         r->len = -1;
-        r->record = (char*) rec;
     }
     else if (!oid_oidcmp(oid, yaz_oid_recsyn_sutrs))
     {
     }
     else if (!oid_oidcmp(oid, yaz_oid_recsyn_sutrs))
     {
index 5f7f2af..cee958a 100644 (file)
@@ -34,7 +34,7 @@
 Z_GenericRecord *dummy_grs_record (int num, ODR o);
 char *dummy_marc_record (int num, ODR odr);
 char *dummy_xml_record (int num, ODR odr);
 Z_GenericRecord *dummy_grs_record (int num, ODR o);
 char *dummy_marc_record (int num, ODR odr);
 char *dummy_xml_record (int num, ODR odr);
-
+Z_OPACRecord *dummy_opac(int num, ODR odr, const char *marc_input);
 
 /*
  * Local variables:
 
 /*
  * Local variables: