X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fsgmlread.c;h=5c18872edf7ffc6346983f9b01011e20765b022b;hb=527dab66d9847bb7f8a931c558306a070064bf25;hp=6ab7be3abc6550f9376f4ba9dc97681c4cbeabc9;hpb=7415d28c149c1bab51fe93aeaccdd14085b69bd9;p=idzebra-moved-to-github.git diff --git a/index/sgmlread.c b/index/sgmlread.c index 6ab7be3..5c18872 100644 --- a/index/sgmlread.c +++ b/index/sgmlread.c @@ -1,5 +1,5 @@ -/* $Id: sgmlread.c,v 1.1 2006-07-03 14:27:09 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: sgmlread.c,v 1.5 2007-03-19 21:50:39 adam Exp $ + Copyright (C) 1995-2007 Index Data ApS This file is part of the Zebra server. @@ -15,9 +15,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 +31,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 +48,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 +63,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 +99,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)