+
+static data1_node *grs_read_sgml (struct grs_read_info *p)
+{
+ struct sgml_getc_info *sgi = (struct sgml_getc_info *) p->clientData;
+ data1_node *node;
+ int res;
+
+ sgi->moffset = p->offset;
+ sgi->fh = p->fh;
+ sgi->readf = p->readf;
+ sgi->off = 0;
+ sgi->size = 0;
+ res = (*sgi->readf)(sgi->fh, 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);
+ return node;
+}
+
+static void *grs_init_sgml(void)
+{
+ struct sgml_getc_info *p = (struct sgml_getc_info *) xmalloc (sizeof(*p));
+ p->buf_size = 512;
+ p->buf = xmalloc (p->buf_size);
+ p->wrbuf = wrbuf_alloc();
+ return p;
+}
+
+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);
+}
+
+static struct recTypeGrs sgml_type = {
+ "sgml",
+ grs_init_sgml,
+ grs_destroy_sgml,
+ grs_read_sgml
+};
+
+RecTypeGrs recTypeGrs_sgml = &sgml_type;
+