1 /* $Id: sgmlread.c,v 1.18 2005-11-16 04:33:22 adam Exp $
2 Copyright (C) 1995-2005
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
27 #include <idzebra/recgrs.h>
29 struct sgml_getc_info {
36 int (*readf)(void *, char *, size_t);
40 int sgml_getc (void *clientData)
42 struct sgml_getc_info *p = (struct sgml_getc_info *) clientData;
46 return p->buf[(p->off)++];
47 if (p->size < p->buf_size)
52 res = (*p->readf)(p->fh, p->buf, p->buf_size);
56 return p->buf[(p->off)++];
61 static data1_node *grs_read_sgml (struct grs_read_info *p)
63 struct sgml_getc_info *sgi = (struct sgml_getc_info *) p->clientData;
67 sgi->moffset = p->offset;
69 sgi->readf = p->readf;
72 res = (*sgi->readf)(sgi->fh, sgi->buf, sgi->buf_size);
77 node = data1_read_nodex (p->dh, p->mem, sgml_getc, sgi, sgi->wrbuf);
79 (*p->endf)(sgi->fh, sgi->moffset + sgi->off);
83 static void *grs_init_sgml(Res res, RecType recType)
85 struct sgml_getc_info *p = (struct sgml_getc_info *) xmalloc (sizeof(*p));
87 p->buf = xmalloc (p->buf_size);
88 p->wrbuf = wrbuf_alloc();
92 static void grs_config_sgml(void *clientData, Res res, const char *args)
97 static void grs_destroy_sgml(void *clientData)
99 struct sgml_getc_info *p = (struct sgml_getc_info *) clientData;
101 wrbuf_free(p->wrbuf, 1);
106 static int grs_extract_sgml(void *clientData, struct recExtractCtrl *ctrl)
108 return zebra_grs_extract(clientData, ctrl, grs_read_sgml);
111 static int grs_retrieve_sgml(void *clientData, struct recRetrieveCtrl *ctrl)
113 return zebra_grs_retrieve(clientData, ctrl, grs_read_sgml);
116 static struct recType grs_type_sgml =
128 #ifdef IDZEBRA_STATIC_GRS_SGML
129 idzebra_filter_grs_sgml