Put local variables footer in all c, h files.
[idzebra-moved-to-github.git] / recctrl / xmlread.c
index aef219b..6311668 100644 (file)
@@ -1,6 +1,6 @@
-/* $Id: xmlread.c,v 1.16 2004-11-19 10:27:13 heikki Exp $
-   Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
-   Index Data Aps
+/* $Id: xmlread.c,v 1.21 2006-05-10 08:13:31 adam Exp $
+   Copyright (C) 1995-2005
+   Index Data ApS
 
 This file is part of the Zebra server.
 
@@ -30,12 +30,12 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <iconv.h>
 #endif
 
-#include <yaz/ylog.h>
+#include <yaz/log.h>
 
 #include <idzebra/recgrs.h>
 
+#include <yaz/log.h>
 #include <yaz/xmalloc.h>
-#include <yaz/ylog.h>
 
 #include <expat.h>
 
@@ -400,6 +400,7 @@ data1_node *zebra_read_xml (data1_handle dh,
     struct user_info uinfo;
     int done = 0;
     data1_node *first_node;
+    int no_read = 0;
 
     uinfo.loglevel = YLOG_DEBUG;
     uinfo.level = 1;
@@ -442,7 +443,9 @@ data1_node *zebra_read_xml (data1_handle dh,
         }
         else if (r == 0)
             done = 1;
-        if (!XML_ParseBuffer (parser, r, done))
+       else
+           no_read += r;
+        if (no_read && !XML_ParseBuffer (parser, r, done))
         {
            done = 1;
            yaz_log (YLOG_WARN, "%d:%d:XML error: %s",
@@ -452,6 +455,8 @@ data1_node *zebra_read_xml (data1_handle dh,
        }
     }
     XML_ParserFree (parser);
+    if (no_read == 0)
+       return 0;
     if (!uinfo.d1_stack[1] || !done)
         return 0;
     /* insert XML header if not present .. */
@@ -484,7 +489,7 @@ static data1_node *grs_read_xml (struct grs_read_info *p)
     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));
 
@@ -493,30 +498,31 @@ static void *init_xml(Res res, RecType recType)
     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
@@ -527,9 +533,17 @@ idzebra_filter
 #endif
 
 [] = {
-    &xml_type,
+    &filter_type,
     0,
 };
     
 #endif
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+