-
-const struct mdoc_node *
-mdoc_node(const struct mdoc *mdoc)
-{
-
- return(mdoc->first);
-}
-
-
-const struct mdoc_meta *
-mdoc_meta(const struct mdoc *mdoc)
-{
-
- return(&mdoc->meta);
-}
-
-
-void
-mdoc_reset(struct mdoc *mdoc)
-{
-
- if (mdoc->first)
- mdoc_node_freelist(mdoc->first);
- if (mdoc->meta.title)
- free(mdoc->meta.title);
- if (mdoc->meta.os)
- free(mdoc->meta.os);
- if (mdoc->meta.name)
- free(mdoc->meta.name);
- if (mdoc->meta.arch)
- free(mdoc->meta.arch);
- if (mdoc->meta.vol)
- free(mdoc->meta.vol);
-
- bzero(&mdoc->meta, sizeof(struct mdoc_meta));
- mdoc->flags = 0;
- mdoc->lastnamed = mdoc->lastsec = 0;
-
- mdoc->first = mdoc->last =
- xcalloc(1, sizeof(struct mdoc_node));
- mdoc->last->type = MDOC_ROOT;
- mdoc->next = MDOC_NEXT_CHILD;
-}
-
-
-void
-mdoc_free(struct mdoc *mdoc)
-{
-
- if (mdoc->first)
- mdoc_node_freelist(mdoc->first);
- if (mdoc->htab)
- mdoc_tokhash_free(mdoc->htab);
- if (mdoc->meta.title)
- free(mdoc->meta.title);
- if (mdoc->meta.os)
- free(mdoc->meta.os);
- if (mdoc->meta.name)
- free(mdoc->meta.name);
- if (mdoc->meta.arch)
- free(mdoc->meta.arch);
- if (mdoc->meta.vol)
- free(mdoc->meta.vol);
-
- free(mdoc);
-}
-
-
-struct mdoc *
-mdoc_alloc(void *data, int pflags, const struct mdoc_cb *cb)
-{
- struct mdoc *p;
-
- p = xcalloc(1, sizeof(struct mdoc));
-
- p->data = data;
- if (cb)
- (void)memcpy(&p->cb, cb, sizeof(struct mdoc_cb));
-
- p->last = p->first =
- xcalloc(1, sizeof(struct mdoc_node));
- p->last->type = MDOC_ROOT;
- p->pflags = pflags;
- p->next = MDOC_NEXT_CHILD;
- p->htab = mdoc_tokhash_alloc();
- return(p);
-}
-
-
-int
-mdoc_endparse(struct mdoc *mdoc)
-{
-
- if (MDOC_HALT & mdoc->flags)
- return(0);
- if (NULL == mdoc->first)
- return(1);
-
- assert(mdoc->last);
- if ( ! macro_end(mdoc)) {
- mdoc->flags |= MDOC_HALT;
- return(0);
- }
- return(1);
-}
+static int mdoc_ptext(struct roff_man *, int, char *, int);
+static int mdoc_pmacro(struct roff_man *, int, char *, int);