So record at position 1, 25, 49, etc .. are equivalent.
</para>
<para>
+ For XML if no element set is given or element has value "marcxml",
+ MARCXML is returned (each of the 24 dummy records converted from
+ ISO2709 to XML). For element set OP, OPAC XML is returned.
+ </para>
+ <para>
+ yaz-ztest may also return predefined XML records (for testing).
+ This is enabled if <literal>YAZ_ZTEST_XML_FETCH</literal> environment
+ variable is defined. A record is fetched form a file (one record per file).
+ The path for the filename is
+ <replaceable>F</replaceable><replaceable>E</replaceable><literal>.</literal><replaceable>d</replaceable><literal>.xml</literal>
+ where <replaceable>F</replaceable> is the YAZ_ZTEST_XML_FETCH value
+ (possibly
+ empty), <replaceable>E</replaceable> is element-set,
+ <replaceable>d</replaceable> is record position (starting from 1).
+ </para>
+ <para>
The following databases are honored by <command>yaz-ztest</command>:
<literal>Default</literal>, <literal>slow</literal>
and <literal>db.*</literal> (all databases with prefix "db"). Any
#include "ztest.h"
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef WIN32
+#include <sys/stat.h>
+#endif
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
#define NO_MARC_RECORDS 24
char *marc_records[NO_MARC_RECORDS] = {
return rec;
}
}
+ else
+ {
+ char *buf = 0;
+ const char *e = getenv("YAZ_ZTEST_XML_FETCH");
+ if (e)
+ {
+ WRBUF w = wrbuf_alloc();
+ struct stat sbuf;
+ FILE *file = 0;
+
+ wrbuf_printf(w, "%s%s.%d.xml", e, esn, num);
+ if (stat(wrbuf_cstr(w), &sbuf) == 0 &&
+ (file = fopen(wrbuf_cstr(w), "rb")))
+ {
+ buf = odr_malloc(odr, sbuf.st_size);
+ fread(buf, 1, sbuf.st_size, file);
+ }
+ if (file)
+ fclose(file);
+ }
+ return buf;
+ }
return 0;
}