+struct sgml_getc_info {
+ char *buf;
+ int buf_size;
+ int size;
+ int off;
+ int moffset;
+ void *fh;
+ int (*readf)(void *, char *, size_t);
+ WRBUF wrbuf;
+};
+
+int sgml_getc (void *clientData)
+{
+ struct sgml_getc_info *p = (struct sgml_getc_info *) clientData;
+ int res;
+
+ if (p->off < p->size)
+ return p->buf[(p->off)++];
+ if (p->size < p->buf_size)
+ return 0;
+ p->moffset += p->off;
+ p->off = 0;
+ p->size = 0;
+ res = (*p->readf)(p->fh, p->buf, p->buf_size);
+ if (res > 0)
+ {
+ p->size += res;
+ return p->buf[(p->off)++];
+ }
+ return 0;
+}
+