1 /* $Id: sgmlread.c,v 1.11 2002-08-02 19:26:56 adam Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
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
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(void)
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_destroy_sgml(void *clientData)
94 struct sgml_getc_info *p = (struct sgml_getc_info *) clientData;
96 wrbuf_free(p->wrbuf, 1);
101 static struct recTypeGrs sgml_type = {
108 RecTypeGrs recTypeGrs_sgml = &sgml_type;