-/* $Id: xmlread.c,v 1.15 2004-09-28 10:15:03 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
- Index Data Aps
+/* $Id: xmlread.c,v 1.19 2005-03-31 12:42:07 adam Exp $
+ Copyright (C) 1995-2005
+ Index Data ApS
This file is part of the Zebra server.
#include <idzebra/recgrs.h>
-#include <yaz/xmalloc.h>
#include <yaz/log.h>
+#include <yaz/xmalloc.h>
#include <expat.h>
data1_mk_preprocess (ui->dh, ui->nmem, "xml", attr_list,
ui->d1_stack[ui->level-1]);
#if 0
- yaz_log (LOG_LOG, "decl version=%s encoding=%s",
+ yaz_log (YLOG_LOG, "decl version=%s encoding=%s",
version ? version : "null",
encoding ? encoding : "null");
#endif
if (!(inf = fopen (systemId, "rb")))
{
- yaz_log (LOG_WARN|LOG_ERRNO, "fopen %s", systemId);
+ yaz_log (YLOG_WARN|YLOG_ERRNO, "fopen %s", systemId);
return 0;
}
void *buf = XML_GetBuffer (parser, XML_CHUNK);
if (!buf)
{
- yaz_log (LOG_WARN, "XML_GetBuffer fail");
+ yaz_log (YLOG_WARN, "XML_GetBuffer fail");
break;
}
r = fread (buf, 1, XML_CHUNK, inf);
{
if (ferror(inf))
{
- yaz_log (LOG_WARN|LOG_ERRNO, "fread %s", systemId);
+ yaz_log (YLOG_WARN|YLOG_ERRNO, "fread %s", systemId);
break;
}
done = 1;
if (!XML_ParseBuffer (parser, r, done))
{
done = 1;
- yaz_log (LOG_WARN, "%s:%d:%d:XML error: %s",
+ yaz_log (YLOG_WARN, "%s:%d:%d:XML error: %s",
systemId,
XML_GetCurrentLineNumber(parser),
XML_GetCurrentColumnNumber(parser),
unsigned short code;
#if 1
- yaz_log(LOG_LOG, "------------------------- cb_encoding_convert --- ");
+ yaz_log(YLOG_LOG, "------------------------- cb_encoding_convert --- ");
#endif
ret = iconv (t, &inbuf, &inleft, &outbuf, &outleft);
if (ret == (size_t) (-1) && errno != E2BIG)
{
info->map[i] = -1; /* no room for output */
if (i != 0)
- yaz_log (LOG_WARN, "Encoding %d: no room for output",
+ yaz_log (YLOG_WARN, "Encoding %d: no room for output",
i);
}
}
else
{ /* should never happen */
info->map[i] = -1;
- yaz_log (LOG_DEBUG, "Encoding %d: bad state", i);
+ yaz_log (YLOG_DEBUG, "Encoding %d: bad state", i);
}
}
if (info->data)
int done = 0;
data1_node *first_node;
- uinfo.loglevel = LOG_DEBUG;
+ uinfo.loglevel = YLOG_DEBUG;
uinfo.level = 1;
uinfo.dh = dh;
uinfo.nmem = m;
if (!buf)
{
/* error */
- yaz_log (LOG_WARN, "XML_GetBuffer fail");
+ yaz_log (YLOG_WARN, "XML_GetBuffer fail");
break;
}
r = (*rf)(fh, buf, XML_CHUNK);
if (r < 0)
{
/* error */
- yaz_log (LOG_WARN, "XML read fail");
+ yaz_log (YLOG_WARN, "XML read fail");
break;
}
else if (r == 0)
if (!XML_ParseBuffer (parser, r, done))
{
done = 1;
- yaz_log (LOG_WARN, "%d:%d:XML error: %s",
+ yaz_log (YLOG_WARN, "%d:%d:XML error: %s",
XML_GetCurrentLineNumber(parser),
XML_GetCurrentColumnNumber(parser),
XML_ErrorString(XML_GetErrorCode(parser)));
return zebra_read_xml (p->dh, p->readf, p->fh, p->mem);
}
-static void *init_xml(Res res, RecType recType)
+static void *filter_init(Res res, RecType recType)
{
struct xml_info *p = (struct xml_info *) xmalloc (sizeof(*p));
return p;
}
-static void destroy_xml(void *clientData)
+static void filter_destroy(void *clientData)
{
struct xml_info *p = (struct xml_info *) clientData;
xfree (p);
}
-static int extract_xml(void *clientData, struct recExtractCtrl *ctrl)
+static int filter_extract(void *clientData, struct recExtractCtrl *ctrl)
{
return zebra_grs_extract(clientData, ctrl, grs_read_xml);
}
-static int retrieve_xml(void *clientData, struct recRetrieveCtrl *ctrl)
+static int filter_retrieve(void *clientData, struct recRetrieveCtrl *ctrl)
{
return zebra_grs_retrieve(clientData, ctrl, grs_read_xml);
}
-static struct recType xml_type = {
+static struct recType filter_type = {
+ 0,
"grs.xml",
- init_xml,
+ filter_init,
0,
- destroy_xml,
- extract_xml,
- retrieve_xml,
+ filter_destroy,
+ filter_extract,
+ filter_retrieve,
};
RecType
#endif
[] = {
- &xml_type,
+ &filter_type,
0,
};