X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=ztest%2Fread-marc.c;h=585b1ef8538e8db220e8f79aae3ff7c59225f70b;hb=refs%2Ftags%2Fv5.0.7;hp=487d9abe108f9b2a51ab4458dd370d4df34f4af0;hpb=2a7d35ce3d1bad977c9cf4f8d586e3699b4d20b3;p=yaz-moved-to-github.git diff --git a/ztest/read-marc.c b/ztest/read-marc.c index 487d9ab..585b1ef 100644 --- a/ztest/read-marc.c +++ b/ztest/read-marc.c @@ -12,9 +12,24 @@ #include #include #include +#include #include "ztest.h" +#if HAVE_SYS_TYPES_H +#include +#endif +#if HAVE_SYS_STAT_H +#include +#endif +#ifdef WIN32 +#include +#endif + +#if HAVE_UNISTD_H +#include +#endif + #define NO_MARC_RECORDS 24 char *marc_records[NO_MARC_RECORDS] = { @@ -1680,6 +1695,29 @@ char *dummy_xml_record(int num, ODR odr, const char *esn) 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, 1 + sbuf.st_size); + fread(buf, 1, sbuf.st_size, file); + buf[sbuf.st_size] = '\0'; + } + if (file) + fclose(file); + } + return buf; + } return 0; }