yaz-ztest: return unique MARC dummy records
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 3 Apr 2013 10:48:35 +0000 (12:48 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 3 Apr 2013 10:48:35 +0000 (12:48 +0200)
Beyond record offset 24, the author surname is patched
with offset to make all records unique.

ztest/read-marc.c

index bf60296..c31eab3 100644 (file)
@@ -1536,12 +1536,48 @@ char *marc_records[NO_MARC_RECORDS] = {
   "\x44\x42\x46\x38\x38\x34\x32\x1E\x1D"
 };
 
+static char *marc_record0 =
+  "00366nam  220016"
+  "98a 450000100130"
+  "0000003000400013"
+  "0050017000170080"
+  "0410003401000170"
+  "0179040001300075"
+  "0500012000881000"
+  "0170010024500300"
+  "0117260001200147"
+  "2630009001593000"
+  "01100168" "\x1E" "   1122"
+  "4466 " "\x1E" "DLC" "\x1E" "000000"
+  "00000000.0" "\x1E" "91071"
+  "0c19910701nju   "
+  "        00010 en"
+  "g  " "\x1E" "  " "\x1F" "aDLC" "\x1F" "cDLC"
+  "" "\x1E" "00" "\x1F" "a123-xyz" "\x1E" "10" "\x1F" ""
+  "aJack Collins" "\x1E" "10"
+  "" "\x1F" "aHow to program"
+  " a computer" "\x1E" "1 " "\x1F" "a"
+  "Penguin" "\x1E" "  " "\x1F" "a8710"
+  "" "\x1E" "  " "\x1F" "ap. cm." "\x1E" "  " "\x1F" "a"
+  "   11224466 " "\x1E" "" "\x1D" ""
+;
+
 /* read MARC record from offset 'num' */
 char *dummy_marc_record(int num, ODR odr)
 {
     if (num < 1)
         return 0;
-    return marc_records[(num-1) % NO_MARC_RECORDS];
+    if (num >= NO_MARC_RECORDS)
+    {
+        char *p = odr_strdup(odr, marc_record0);
+        sprintf(p + 279, "%-5d", num);
+        p[284] = ' ';
+        return p;
+    }
+    else
+    {
+        return marc_records[(num-1) % NO_MARC_RECORDS];
+    }
 }
 
 /* read MARC record and convert to XML */