updated Deb control description so that IDZebra is not mentioned
[idzebra-moved-to-github.git] / index / sgmlread.c
index 6ab7be3..38fcbe3 100644 (file)
@@ -1,8 +1,5 @@
-/* $Id: sgmlread.c,v 1.1 2006-07-03 14:27:09 adam Exp $
-   Copyright (C) 1995-2005
-   Index Data ApS
-
-This file is part of the Zebra server.
+/* This file is part of the Zebra server.
+   Copyright (C) 1995-2008 Index Data
 
 Zebra is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
@@ -15,9 +12,9 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra.  If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
 */
 
 
@@ -31,9 +28,8 @@ struct sgml_getc_info {
     int buf_size;
     int size;
     int off;
+    struct ZebraRecStream *stream;
     off_t moffset;
-    void *fh;
-    int (*readf)(void *, char *, size_t);
     WRBUF wrbuf;
 };
 
@@ -49,7 +45,7 @@ int sgml_getc (void *clientData)
     p->moffset += p->off;
     p->off = 0;
     p->size = 0;
-    res = (*p->readf)(p->fh, p->buf, p->buf_size);
+    res = p->stream->readf(p->stream, p->buf, p->buf_size);
     if (res > 0)
     {
        p->size += res;
@@ -64,19 +60,21 @@ static data1_node *grs_read_sgml (struct grs_read_info *p)
     data1_node *node;
     int res;
     
-    sgi->moffset = p->offset;
-    sgi->fh = p->fh;
-    sgi->readf = p->readf;
+    sgi->moffset = p->stream->tellf(p->stream);
+    sgi->stream = p->stream;
     sgi->off = 0;
     sgi->size = 0;
-    res = (*sgi->readf)(sgi->fh, sgi->buf, sgi->buf_size);
+    res = sgi->stream->readf(sgi->stream, sgi->buf, sgi->buf_size);
     if (res > 0)
        sgi->size += res;
     else
        return 0;
-    node = data1_read_nodex (p->dh, p->mem, sgml_getc, sgi, sgi->wrbuf);
-    if (node && p->endf)
-       (*p->endf)(sgi->fh, sgi->moffset + sgi->off);
+    node = data1_read_nodex(p->dh, p->mem, sgml_getc, sgi, sgi->wrbuf);
+    if (node && p->stream->endf)
+    {
+        off_t end_offset = sgi->moffset + sgi->off;
+       p->stream->endf(sgi->stream, &end_offset);
+    }
     return node;
 }
 
@@ -98,9 +96,9 @@ static void grs_destroy_sgml(void *clientData)
 {
     struct sgml_getc_info *p = (struct sgml_getc_info *) clientData;
 
-    wrbuf_free(p->wrbuf, 1);
-    xfree (p->buf);
-    xfree (p);
+    wrbuf_destroy(p->wrbuf);
+    xfree(p->buf);
+    xfree(p);
 }
 
 static int grs_extract_sgml(void *clientData, struct recExtractCtrl *ctrl)