version 1.11, 2014/03/29 11:13:49 |
version 1.22, 2014/03/30 17:22:01 |
|
|
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
/* |
#include "extern.h" |
* All recognised node types. |
|
*/ |
|
enum nodeid { |
|
NODE_ROOT = 0, /* Must comes first. */ |
|
/* Alpha-ordered hereafter. */ |
|
NODE_ARG, |
|
NODE_CITEREFENTRY, |
|
NODE_CMDSYNOPSIS, |
|
NODE_CODE, |
|
NODE_COMMAND, |
|
NODE_FUNCDEF, |
|
NODE_FUNCPROTOTYPE, |
|
NODE_FUNCSYNOPSIS, |
|
NODE_FUNCSYNOPSISINFO, |
|
NODE_FUNCTION, |
|
NODE_MANVOLNUM, |
|
NODE_OPTION, |
|
NODE_PARA, |
|
NODE_PARAMDEF, |
|
NODE_PARAMETER, |
|
NODE_PROGRAMLISTING, |
|
NODE_REFCLASS, |
|
NODE_REFDESCRIPTOR, |
|
NODE_REFENTRY, |
|
NODE_REFENTRYTITLE, |
|
NODE_REFMETA, |
|
NODE_REFMISCINFO, |
|
NODE_REFNAME, |
|
NODE_REFNAMEDIV, |
|
NODE_REFPURPOSE, |
|
NODE_REFSECT1, |
|
NODE_REFSYNOPSISDIV, |
|
NODE_STRUCTNAME, |
|
NODE_SYNOPSIS, |
|
NODE_TEXT, |
|
NODE_TITLE, |
|
NODE__MAX |
|
}; |
|
|
|
/* |
/* |
* Global parse state. |
* Global parse state. |
* Keep this as simple and small as possible. |
* Keep this as simple and small as possible. |
*/ |
*/ |
struct parse { |
struct parse { |
|
XML_Parser xml; |
enum nodeid node; /* current (NODE_ROOT if pre-tree) */ |
enum nodeid node; /* current (NODE_ROOT if pre-tree) */ |
|
const char *fname; /* filename */ |
int stop; /* should we stop now? */ |
int stop; /* should we stop now? */ |
struct pnode *root; /* root of parse tree */ |
struct pnode *root; /* root of parse tree */ |
struct pnode *cur; /* current node in tree */ |
struct pnode *cur; /* current node in tree */ |
|
|
}; |
}; |
|
|
TAILQ_HEAD(pnodeq, pnode); |
TAILQ_HEAD(pnodeq, pnode); |
|
TAILQ_HEAD(pattrq, pattr); |
|
|
|
struct pattr { |
|
enum attrkey key; |
|
enum attrval val; |
|
char *rawval; |
|
TAILQ_ENTRY(pattr) child; |
|
}; |
|
|
struct pnode { |
struct pnode { |
enum nodeid node; /* node type */ |
enum nodeid node; /* node type */ |
char *b; /* binary data buffer */ |
char *b; /* binary data buffer */ |
size_t bsz; /* data buffer size */ |
size_t bsz; /* data buffer size */ |
struct pnode *parent; /* parent (or NULL if top) */ |
struct pnode *parent; /* parent (or NULL if top) */ |
struct pnodeq childq; /* queue of children */ |
struct pnodeq childq; /* queue of children */ |
|
struct pattrq attrq; /* attributes of node */ |
TAILQ_ENTRY(pnode) child; |
TAILQ_ENTRY(pnode) child; |
}; |
}; |
|
|
|
static const char *attrkeys[ATTRKEY__MAX] = { |
|
"choice", |
|
"id", |
|
"rep" |
|
}; |
|
|
|
static const char *attrvals[ATTRVAL__MAX] = { |
|
"norepeat", |
|
"opt", |
|
"plain", |
|
"repeat", |
|
"req" |
|
}; |
|
|
static const struct node nodes[NODE__MAX] = { |
static const struct node nodes[NODE__MAX] = { |
{ NULL, 0 }, |
{ NULL, 0 }, |
|
{ "acronym", 0 }, |
{ "arg", 0 }, |
{ "arg", 0 }, |
{ "citerefentry", NODE_IGNTEXT }, |
{ "citerefentry", NODE_IGNTEXT }, |
{ "cmdsynopsis", NODE_IGNTEXT }, |
{ "cmdsynopsis", NODE_IGNTEXT }, |
{ "code", 0 }, |
{ "code", 0 }, |
{ "command", 0 }, |
{ "command", 0 }, |
|
{ "date", 0 }, |
|
{ "emphasis", 0 }, |
|
{ "envar", 0 }, |
|
{ "filename", 0 }, |
{ "funcdef", 0 }, |
{ "funcdef", 0 }, |
{ "funcprototype", NODE_IGNTEXT }, |
{ "funcprototype", NODE_IGNTEXT }, |
{ "funcsynopsis", NODE_IGNTEXT }, |
{ "funcsynopsis", NODE_IGNTEXT }, |
{ "funcsynopsisinfo", 0 }, |
{ "funcsynopsisinfo", 0 }, |
{ "function", 0 }, |
{ "function", 0 }, |
|
{ "itemizedlist", NODE_IGNTEXT }, |
|
{ "link", 0 }, |
|
{ "listitem", NODE_IGNTEXT }, |
|
{ "literal", 0 }, |
{ "manvolnum", 0 }, |
{ "manvolnum", 0 }, |
{ "option", 0 }, |
{ "option", 0 }, |
|
{ "orderedlist", NODE_IGNTEXT }, |
{ "para", 0 }, |
{ "para", 0 }, |
{ "paramdef", 0 }, |
{ "paramdef", 0 }, |
{ "parameter", 0 }, |
{ "parameter", 0 }, |
{ "programlisting", 0 }, |
{ "programlisting", 0 }, |
|
{ "prompt", 0 }, |
{ "refclass", NODE_IGNTEXT }, |
{ "refclass", NODE_IGNTEXT }, |
{ "refdescriptor", NODE_IGNTEXT }, |
{ "refdescriptor", NODE_IGNTEXT }, |
{ "refentry", NODE_IGNTEXT }, |
{ "refentry", NODE_IGNTEXT }, |
|
{ "refentryinfo", NODE_IGNTEXT }, |
{ "refentrytitle", 0 }, |
{ "refentrytitle", 0 }, |
{ "refmeta", NODE_IGNTEXT }, |
{ "refmeta", NODE_IGNTEXT }, |
{ "refmiscinfo", NODE_IGNTEXT }, |
{ "refmiscinfo", NODE_IGNTEXT }, |
{ "refname", 0 }, |
{ "refname", 0 }, |
{ "refnamediv", NODE_IGNTEXT }, |
{ "refnamediv", NODE_IGNTEXT }, |
{ "refpurpose", 0 }, |
{ "refpurpose", 0 }, |
{ "refsect1", 0 }, |
{ "refsect1", NODE_IGNTEXT }, |
|
{ "refsect2", NODE_IGNTEXT }, |
{ "refsynopsisdiv", NODE_IGNTEXT }, |
{ "refsynopsisdiv", NODE_IGNTEXT }, |
|
{ "replaceable", 0 }, |
|
{ "sbr", NODE_IGNTEXT }, |
|
{ "screen", NODE_IGNTEXT }, |
{ "structname", 0 }, |
{ "structname", 0 }, |
{ "synopsis", 0 }, |
{ "synopsis", 0 }, |
|
{ "term", 0 }, |
{ NULL, 0 }, |
{ NULL, 0 }, |
{ "title", 0 }, |
{ "title", 0 }, |
|
{ "ulink", 0 }, |
|
{ "variablelist", NODE_IGNTEXT }, |
|
{ "varlistentry", NODE_IGNTEXT }, |
}; |
}; |
|
|
static void |
static void |
pnode_print(struct parse *p, struct pnode *pn); |
pnode_print(struct parse *p, struct pnode *pn); |
|
|
/* |
/* |
* Look up whether "parent" is a valid parent for "node". |
|
* This is sucked directly from the DocBook specification: look at the |
|
* "children" and "parent" sections of each node. |
|
*/ |
|
static int |
|
isparent(enum nodeid node, enum nodeid parent) |
|
{ |
|
|
|
switch (node) { |
|
case (NODE_ROOT): |
|
return(0); |
|
case (NODE_ARG): |
|
switch (parent) { |
|
case (NODE_ARG): |
|
case (NODE_CMDSYNOPSIS): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_CITEREFENTRY): |
|
switch (parent) { |
|
case (NODE_FUNCSYNOPSISINFO): |
|
case (NODE_PARA): |
|
case (NODE_PROGRAMLISTING): |
|
case (NODE_REFDESCRIPTOR): |
|
case (NODE_REFENTRYTITLE): |
|
case (NODE_REFNAME): |
|
case (NODE_REFPURPOSE): |
|
case (NODE_SYNOPSIS): |
|
case (NODE_TITLE): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_CMDSYNOPSIS): |
|
switch (parent) { |
|
case (NODE_PARA): |
|
case (NODE_REFSECT1): |
|
case (NODE_REFSYNOPSISDIV): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_CODE): |
|
switch (parent) { |
|
case (NODE_FUNCSYNOPSISINFO): |
|
case (NODE_PARA): |
|
case (NODE_PROGRAMLISTING): |
|
case (NODE_REFDESCRIPTOR): |
|
case (NODE_REFENTRYTITLE): |
|
case (NODE_REFNAME): |
|
case (NODE_REFPURPOSE): |
|
case (NODE_SYNOPSIS): |
|
case (NODE_TITLE): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_COMMAND): |
|
switch (parent) { |
|
case (NODE_CMDSYNOPSIS): |
|
case (NODE_FUNCSYNOPSISINFO): |
|
case (NODE_PARA): |
|
case (NODE_PROGRAMLISTING): |
|
case (NODE_REFDESCRIPTOR): |
|
case (NODE_REFENTRYTITLE): |
|
case (NODE_REFNAME): |
|
case (NODE_REFPURPOSE): |
|
case (NODE_SYNOPSIS): |
|
case (NODE_TITLE): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_FUNCDEF): |
|
return(NODE_FUNCPROTOTYPE == parent); |
|
case (NODE_FUNCPROTOTYPE): |
|
return(NODE_FUNCSYNOPSIS == parent); |
|
case (NODE_FUNCSYNOPSIS): |
|
switch (parent) { |
|
case (NODE_PARA): |
|
case (NODE_REFSECT1): |
|
case (NODE_REFSYNOPSISDIV): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_FUNCSYNOPSISINFO): |
|
return(NODE_FUNCSYNOPSIS == parent); |
|
case (NODE_FUNCTION): |
|
switch (parent) { |
|
case (NODE_CODE): |
|
case (NODE_FUNCDEF): |
|
case (NODE_FUNCSYNOPSISINFO): |
|
case (NODE_PARA): |
|
case (NODE_PROGRAMLISTING): |
|
case (NODE_REFDESCRIPTOR): |
|
case (NODE_REFENTRYTITLE): |
|
case (NODE_REFNAME): |
|
case (NODE_REFPURPOSE): |
|
case (NODE_SYNOPSIS): |
|
case (NODE_TITLE): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_MANVOLNUM): |
|
switch (parent) { |
|
case (NODE_CITEREFENTRY): |
|
case (NODE_REFMETA): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_OPTION): |
|
switch (parent) { |
|
case (NODE_ARG): |
|
case (NODE_FUNCSYNOPSISINFO): |
|
case (NODE_PARA): |
|
case (NODE_PROGRAMLISTING): |
|
case (NODE_REFDESCRIPTOR): |
|
case (NODE_REFENTRYTITLE): |
|
case (NODE_REFNAME): |
|
case (NODE_REFPURPOSE): |
|
case (NODE_SYNOPSIS): |
|
case (NODE_TITLE): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_PARA): |
|
switch (parent) { |
|
case (NODE_REFSECT1): |
|
case (NODE_REFSYNOPSISDIV): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_PARAMDEF): |
|
return(NODE_FUNCPROTOTYPE == parent); |
|
case (NODE_PARAMETER): |
|
switch (parent) { |
|
case (NODE_CODE): |
|
case (NODE_FUNCSYNOPSISINFO): |
|
case (NODE_PARA): |
|
case (NODE_PARAMDEF): |
|
case (NODE_PROGRAMLISTING): |
|
case (NODE_REFDESCRIPTOR): |
|
case (NODE_REFENTRYTITLE): |
|
case (NODE_REFNAME): |
|
case (NODE_REFPURPOSE): |
|
case (NODE_SYNOPSIS): |
|
case (NODE_TITLE): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_PROGRAMLISTING): |
|
switch (parent) { |
|
case (NODE_PARA): |
|
case (NODE_REFSECT1): |
|
case (NODE_REFSYNOPSISDIV): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_REFCLASS): |
|
return(parent == NODE_REFNAMEDIV); |
|
case (NODE_REFDESCRIPTOR): |
|
return(parent == NODE_REFNAMEDIV); |
|
case (NODE_REFENTRY): |
|
return(parent == NODE_ROOT); |
|
case (NODE_REFENTRYTITLE): |
|
switch (parent) { |
|
case (NODE_CITEREFENTRY): |
|
case (NODE_REFMETA): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
case (NODE_REFMETA): |
|
return(parent == NODE_REFENTRY); |
|
case (NODE_REFMISCINFO): |
|
return(parent == NODE_REFMETA); |
|
case (NODE_REFNAME): |
|
return(parent == NODE_REFNAMEDIV); |
|
case (NODE_REFNAMEDIV): |
|
return(parent == NODE_REFENTRY); |
|
case (NODE_REFPURPOSE): |
|
return(parent == NODE_REFNAMEDIV); |
|
case (NODE_REFSECT1): |
|
return(parent == NODE_REFENTRY); |
|
case (NODE_REFSYNOPSISDIV): |
|
return(parent == NODE_REFENTRY); |
|
case (NODE_STRUCTNAME): |
|
switch (parent) { |
|
case (NODE_CODE): |
|
case (NODE_FUNCSYNOPSISINFO): |
|
case (NODE_FUNCTION): |
|
case (NODE_OPTION): |
|
case (NODE_PARA): |
|
case (NODE_PARAMETER): |
|
case (NODE_PROGRAMLISTING): |
|
case (NODE_REFDESCRIPTOR): |
|
case (NODE_REFENTRYTITLE): |
|
case (NODE_REFNAME): |
|
case (NODE_REFPURPOSE): |
|
case (NODE_SYNOPSIS): |
|
case (NODE_TITLE): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_SYNOPSIS): |
|
switch (parent) { |
|
case (NODE_REFSYNOPSISDIV): |
|
case (NODE_REFSECT1): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_TITLE): |
|
switch (parent) { |
|
case (NODE_REFSECT1): |
|
case (NODE_REFSYNOPSISDIV): |
|
return(1); |
|
default: |
|
break; |
|
} |
|
return(0); |
|
case (NODE_TEXT): |
|
return(1); |
|
case (NODE__MAX): |
|
break; |
|
} |
|
|
|
abort(); |
|
return(0); |
|
} |
|
|
|
/* |
|
* Process a stream of characters. |
* Process a stream of characters. |
* We store text as nodes in and of themselves. |
* We store text as nodes in and of themselves. |
* If a text node is already open, append to it. |
* If a text node is already open, append to it. |
Line 437 xml_char(void *arg, const XML_Char *p, int sz) |
|
Line 189 xml_char(void *arg, const XML_Char *p, int sz) |
|
dat->node = ps->node = NODE_TEXT; |
dat->node = ps->node = NODE_TEXT; |
dat->parent = ps->cur; |
dat->parent = ps->cur; |
TAILQ_INIT(&dat->childq); |
TAILQ_INIT(&dat->childq); |
|
TAILQ_INIT(&dat->attrq); |
TAILQ_INSERT_TAIL(&ps->cur->childq, dat, child); |
TAILQ_INSERT_TAIL(&ps->cur->childq, dat, child); |
ps->cur = dat; |
ps->cur = dat; |
assert(NULL != ps->root); |
assert(NULL != ps->root); |
Line 481 pnode_trim(struct pnode *pn) |
|
Line 234 pnode_trim(struct pnode *pn) |
|
static void |
static void |
xml_elem_start(void *arg, const XML_Char *name, const XML_Char **atts) |
xml_elem_start(void *arg, const XML_Char *name, const XML_Char **atts) |
{ |
{ |
struct parse *ps = arg; |
struct parse *ps = arg; |
enum nodeid node; |
enum nodeid node; |
struct pnode *dat; |
enum attrkey key; |
|
enum attrval val; |
|
struct pnode *dat; |
|
struct pattr *pattr; |
|
const XML_Char **att; |
|
|
if (ps->stop) |
if (ps->stop) |
return; |
return; |
Line 503 xml_elem_start(void *arg, const XML_Char *name, const |
|
Line 260 xml_elem_start(void *arg, const XML_Char *name, const |
|
else if (0 == strcmp(nodes[node].name, name)) |
else if (0 == strcmp(nodes[node].name, name)) |
break; |
break; |
|
|
/* FIXME: do more with these error messages... */ |
|
if (NODE__MAX == node && NODE_ROOT == ps->node) { |
if (NODE__MAX == node && NODE_ROOT == ps->node) { |
fprintf(stderr, "%s: ignoring node\n", name); |
|
return; |
return; |
} else if (NODE__MAX == node) { |
} else if (NODE__MAX == node) { |
fprintf(stderr, "%s: unknown node\n", name); |
fprintf(stderr, "%s:%zu:%zu: unknown node \"%s\"\n", |
|
ps->fname, XML_GetCurrentLineNumber(ps->xml), |
|
XML_GetCurrentColumnNumber(ps->xml), name); |
ps->stop = 1; |
ps->stop = 1; |
return; |
return; |
} else if (NODE_ROOT == ps->node && NULL != ps->root) { |
} else if (NODE_ROOT == ps->node && NULL != ps->root) { |
fprintf(stderr, "%s: reentering?\n", name); |
fprintf(stderr, "%s:%zu:%zu: multiple refentries\n", |
|
ps->fname, XML_GetCurrentLineNumber(ps->xml), |
|
XML_GetCurrentColumnNumber(ps->xml)); |
ps->stop = 1; |
ps->stop = 1; |
return; |
return; |
} else if (NODE_ROOT == ps->node && NODE_REFENTRY != node) { |
} else if (NODE_ROOT == ps->node && NODE_REFENTRY != node) { |
fprintf(stderr, "%s: known node w/o context\n", name); |
|
return; |
return; |
} else if ( ! isparent(node, ps->node)) { |
} else if ( ! isparent(node, ps->node)) { |
fprintf(stderr, "%s: bad parent\n", name); |
fprintf(stderr, "%s:%zu:%zu: bad parent \"%s\" " |
|
"of node \"%s\"\n", |
|
ps->fname, XML_GetCurrentLineNumber(ps->xml), |
|
XML_GetCurrentColumnNumber(ps->xml), |
|
NULL == nodes[ps->node].name ? |
|
"(none)" : nodes[ps->node].name, |
|
NULL == nodes[node].name ? |
|
"(none)" : nodes[node].name); |
ps->stop = 1; |
ps->stop = 1; |
return; |
return; |
} |
} |
Line 532 xml_elem_start(void *arg, const XML_Char *name, const |
|
Line 297 xml_elem_start(void *arg, const XML_Char *name, const |
|
dat->node = ps->node = node; |
dat->node = ps->node = node; |
dat->parent = ps->cur; |
dat->parent = ps->cur; |
TAILQ_INIT(&dat->childq); |
TAILQ_INIT(&dat->childq); |
|
TAILQ_INIT(&dat->attrq); |
|
|
if (NULL != ps->cur) |
if (NULL != ps->cur) |
TAILQ_INSERT_TAIL(&ps->cur->childq, dat, child); |
TAILQ_INSERT_TAIL(&ps->cur->childq, dat, child); |
Line 539 xml_elem_start(void *arg, const XML_Char *name, const |
|
Line 305 xml_elem_start(void *arg, const XML_Char *name, const |
|
ps->cur = dat; |
ps->cur = dat; |
if (NULL == ps->root) |
if (NULL == ps->root) |
ps->root = dat; |
ps->root = dat; |
|
|
|
/* |
|
* Process attributes. |
|
*/ |
|
for (att = atts; NULL != *att; att += 2) { |
|
for (key = 0; key < ATTRKEY__MAX; key++) |
|
if (0 == strcmp(*att, attrkeys[key])) |
|
break; |
|
if (ATTRKEY__MAX == key) { |
|
fprintf(stderr, "%s:%zu:%zu: unknown " |
|
"attribute \"%s\"\n", ps->fname, |
|
XML_GetCurrentLineNumber(ps->xml), |
|
XML_GetCurrentColumnNumber(ps->xml), |
|
*att); |
|
continue; |
|
} else if ( ! isattrkey(node, key)) { |
|
fprintf(stderr, "%s:%zu:%zu: bad " |
|
"attribute \"%s\"\n", ps->fname, |
|
XML_GetCurrentLineNumber(ps->xml), |
|
XML_GetCurrentColumnNumber(ps->xml), |
|
*att); |
|
continue; |
|
} |
|
for (val = 0; val < ATTRVAL__MAX; val++) |
|
if (0 == strcmp(*(att + 1), attrvals[val])) |
|
break; |
|
if (ATTRVAL__MAX != val && ! isattrval(key, val)) { |
|
fprintf(stderr, "%s:%zu:%zu: bad " |
|
"value \"%s\"\n", ps->fname, |
|
XML_GetCurrentLineNumber(ps->xml), |
|
XML_GetCurrentColumnNumber(ps->xml), |
|
*(att + 1)); |
|
continue; |
|
} |
|
pattr = calloc(1, sizeof(struct pattr)); |
|
pattr->key = key; |
|
pattr->val = val; |
|
if (ATTRVAL__MAX == val) |
|
pattr->rawval = strdup(*(att + 1)); |
|
TAILQ_INSERT_TAIL(&dat->attrq, pattr, child); |
|
} |
|
|
} |
} |
|
|
/* |
/* |
|
|
pnode_free(struct pnode *pn) |
pnode_free(struct pnode *pn) |
{ |
{ |
struct pnode *pp; |
struct pnode *pp; |
|
struct pattr *ap; |
|
|
if (NULL == pn) |
if (NULL == pn) |
return; |
return; |
Line 585 pnode_free(struct pnode *pn) |
|
Line 394 pnode_free(struct pnode *pn) |
|
pnode_free(pp); |
pnode_free(pp); |
} |
} |
|
|
|
while (NULL != (ap = TAILQ_FIRST(&pn->attrq))) { |
|
TAILQ_REMOVE(&pn->attrq, ap, child); |
|
free(ap->rawval); |
|
free(ap); |
|
} |
|
|
free(pn->b); |
free(pn->b); |
free(pn); |
free(pn); |
} |
} |
Line 661 bufappend_r(struct parse *p, struct pnode *pn) |
|
Line 476 bufappend_r(struct parse *p, struct pnode *pn) |
|
bufappend_r(p, pp); |
bufappend_r(p, pp); |
} |
} |
|
|
|
#define MACROLINE_NORM 0 |
|
#define MACROLINE_UPPER 1 |
/* |
/* |
* Recursively print text presumably on a macro line. |
* Recursively print text presumably on a macro line. |
* Convert all whitespace to regular spaces. |
* Convert all whitespace to regular spaces. |
*/ |
*/ |
static void |
static void |
pnode_printmacrolinepart(struct parse *p, struct pnode *pn) |
pnode_printmacrolinetext(struct parse *p, struct pnode *pn, int fl) |
{ |
{ |
char *cp; |
char *cp; |
|
|
|
if (0 == p->newln) |
|
putchar(' '); |
|
|
bufclear(p); |
bufclear(p); |
bufappend_r(p, pn); |
bufappend_r(p, pn); |
|
|
Line 692 pnode_printmacrolinepart(struct parse *p, struct pnode |
|
Line 512 pnode_printmacrolinepart(struct parse *p, struct pnode |
|
('\0' == *(cp + 3) || |
('\0' == *(cp + 3) || |
' ' == *(cp + 3))))) |
' ' == *(cp + 3))))) |
fputs("\\&", stdout); |
fputs("\\&", stdout); |
putchar(*cp); |
if (MACROLINE_UPPER & fl) |
|
putchar(toupper((int)*cp)); |
|
else |
|
putchar((int)*cp); |
/* If we're a character escape, escape us. */ |
/* If we're a character escape, escape us. */ |
if ('\\' == *cp) |
if ('\\' == *cp) |
putchar('e'); |
putchar('e'); |
} |
} |
} |
} |
|
|
|
static void |
|
pnode_printmacrolinepart(struct parse *p, struct pnode *pn) |
|
{ |
|
|
|
pnode_printmacrolinetext(p, pn, 0); |
|
} |
|
|
/* |
/* |
* Just pnode_printmacrolinepart() but with a newline. |
* Just pnode_printmacrolinepart() but with a newline. |
* If no text, just the newline. |
* If no text, just the newline. |
|
|
pnode_printmacroline(struct parse *p, struct pnode *pn) |
pnode_printmacroline(struct parse *p, struct pnode *pn) |
{ |
{ |
|
|
pnode_printmacrolinepart(p, pn); |
assert(0 == p->newln); |
|
pnode_printmacrolinetext(p, pn, 0); |
putchar('\n'); |
putchar('\n'); |
|
p->newln = 1; |
} |
} |
|
|
static void |
static void |
Line 758 pnode_printrefsect(struct parse *p, struct pnode *pn) |
|
Line 590 pnode_printrefsect(struct parse *p, struct pnode *pn) |
|
if (NODE_TITLE == pp->node) |
if (NODE_TITLE == pp->node) |
break; |
break; |
|
|
fputs(".Sh ", stdout); |
if (NODE_REFSECT1 == pn->node) |
|
fputs(".Sh", stdout); |
|
else |
|
fputs(".Ss", stdout); |
|
|
|
p->newln = 0; |
|
|
if (NULL != pp) { |
if (NULL != pp) { |
pnode_printmacroline(p, pp); |
pnode_printmacrolinetext(p, pp, |
|
NODE_REFSECT1 == pn->node ? |
|
MACROLINE_UPPER : 0); |
|
pnode_printmclose(p, 1); |
pnode_unlink(pp); |
pnode_unlink(pp); |
} else |
} else { |
puts("UNKNOWN"); |
puts("UNKNOWN"); |
|
p->newln = 1; |
|
} |
} |
} |
|
|
/* |
/* |
Line 776 pnode_printciterefentry(struct parse *p, struct pnode |
|
Line 618 pnode_printciterefentry(struct parse *p, struct pnode |
|
struct pnode *pp, *title, *manvol; |
struct pnode *pp, *title, *manvol; |
|
|
title = manvol = NULL; |
title = manvol = NULL; |
|
assert(p->newln); |
TAILQ_FOREACH(pp, &pn->childq, child) |
TAILQ_FOREACH(pp, &pn->childq, child) |
if (NODE_MANVOLNUM == pp->node) |
if (NODE_MANVOLNUM == pp->node) |
manvol = pp; |
manvol = pp; |
else if (NODE_REFENTRYTITLE == pp->node) |
else if (NODE_REFENTRYTITLE == pp->node) |
title = pp; |
title = pp; |
|
|
fputs(".Xr ", stdout); |
fputs(".Xr", stdout); |
|
p->newln = 0; |
|
|
if (NULL != title) { |
if (NULL != title) { |
pnode_printmacrolinepart(p, title); |
pnode_printmacrolinepart(p, title); |
putchar(' '); |
|
} else |
} else |
fputs("unknown ", stdout); |
fputs(" unknown ", stdout); |
|
|
if (NULL != manvol) |
if (NULL == manvol) { |
|
puts(" 1"); |
|
p->newln = 1; |
|
} else |
pnode_printmacroline(p, manvol); |
pnode_printmacroline(p, manvol); |
else |
|
puts("1"); |
|
} |
} |
|
|
static void |
static void |
Line 802 pnode_printrefmeta(struct parse *p, struct pnode *pn) |
|
Line 646 pnode_printrefmeta(struct parse *p, struct pnode *pn) |
|
struct pnode *pp, *title, *manvol; |
struct pnode *pp, *title, *manvol; |
|
|
title = manvol = NULL; |
title = manvol = NULL; |
|
assert(p->newln); |
TAILQ_FOREACH(pp, &pn->childq, child) |
TAILQ_FOREACH(pp, &pn->childq, child) |
if (NODE_MANVOLNUM == pp->node) |
if (NODE_MANVOLNUM == pp->node) |
manvol = pp; |
manvol = pp; |
Line 809 pnode_printrefmeta(struct parse *p, struct pnode *pn) |
|
Line 654 pnode_printrefmeta(struct parse *p, struct pnode *pn) |
|
title = pp; |
title = pp; |
|
|
puts(".Dd $Mdocdate" "$"); |
puts(".Dd $Mdocdate" "$"); |
fputs(".Dt ", stdout); |
fputs(".Dt", stdout); |
|
p->newln = 0; |
|
|
if (NULL != title) { |
if (NULL != title) |
/* FIXME: uppercase. */ |
pnode_printmacrolinetext(p, title, MACROLINE_UPPER); |
pnode_printmacrolinepart(p, title); |
else |
putchar(' '); |
fputs(" UNKNOWN ", stdout); |
} else |
|
fputs("UNKNOWN ", stdout); |
|
|
|
if (NULL != manvol) |
if (NULL == manvol) { |
|
puts(" 1"); |
|
p->newln = 1; |
|
} else |
pnode_printmacroline(p, manvol); |
pnode_printmacroline(p, manvol); |
else |
|
puts("1"); |
|
|
|
puts(".Os"); |
puts(".Os"); |
} |
} |
Line 831 pnode_printfuncdef(struct parse *p, struct pnode *pn) |
|
Line 676 pnode_printfuncdef(struct parse *p, struct pnode *pn) |
|
{ |
{ |
struct pnode *pp, *ftype, *func; |
struct pnode *pp, *ftype, *func; |
|
|
|
assert(p->newln); |
ftype = func = NULL; |
ftype = func = NULL; |
TAILQ_FOREACH(pp, &pn->childq, child) |
TAILQ_FOREACH(pp, &pn->childq, child) |
if (NODE_TEXT == pp->node) |
if (NODE_TEXT == pp->node) |
Line 839 pnode_printfuncdef(struct parse *p, struct pnode *pn) |
|
Line 685 pnode_printfuncdef(struct parse *p, struct pnode *pn) |
|
func = pp; |
func = pp; |
|
|
if (NULL != ftype) { |
if (NULL != ftype) { |
fputs(".Ft ", stdout); |
fputs(".Ft", stdout); |
|
p->newln = 0; |
pnode_printmacroline(p, ftype); |
pnode_printmacroline(p, ftype); |
} |
} |
|
|
if (NULL != func) { |
if (NULL != func) { |
fputs(".Fo ", stdout); |
fputs(".Fo", stdout); |
|
p->newln = 0; |
pnode_printmacroline(p, func); |
pnode_printmacroline(p, func); |
} else |
} else { |
puts(".Fo UNKNOWN"); |
puts(".Fo UNKNOWN"); |
|
p->newln = 1; |
|
} |
} |
} |
|
|
static void |
static void |
Line 855 pnode_printparamdef(struct parse *p, struct pnode *pn) |
|
Line 705 pnode_printparamdef(struct parse *p, struct pnode *pn) |
|
{ |
{ |
struct pnode *pp, *ptype, *param; |
struct pnode *pp, *ptype, *param; |
|
|
|
assert(p->newln); |
ptype = param = NULL; |
ptype = param = NULL; |
TAILQ_FOREACH(pp, &pn->childq, child) |
TAILQ_FOREACH(pp, &pn->childq, child) |
if (NODE_TEXT == pp->node) |
if (NODE_TEXT == pp->node) |
Line 863 pnode_printparamdef(struct parse *p, struct pnode *pn) |
|
Line 714 pnode_printparamdef(struct parse *p, struct pnode *pn) |
|
param = pp; |
param = pp; |
|
|
fputs(".Fa \"", stdout); |
fputs(".Fa \"", stdout); |
|
p->newln = 0; |
if (NULL != ptype) { |
if (NULL != ptype) { |
pnode_printmacrolinepart(p, ptype); |
pnode_printmacrolinepart(p, ptype); |
putchar(' '); |
putchar(' '); |
Line 872 pnode_printparamdef(struct parse *p, struct pnode *pn) |
|
Line 724 pnode_printparamdef(struct parse *p, struct pnode *pn) |
|
pnode_printmacrolinepart(p, param); |
pnode_printmacrolinepart(p, param); |
|
|
puts("\""); |
puts("\""); |
|
p->newln = 1; |
} |
} |
|
|
static void |
static void |
Line 879 pnode_printfuncprototype(struct parse *p, struct pnode |
|
Line 732 pnode_printfuncprototype(struct parse *p, struct pnode |
|
{ |
{ |
struct pnode *pp, *fdef; |
struct pnode *pp, *fdef; |
|
|
|
assert(p->newln); |
TAILQ_FOREACH(fdef, &pn->childq, child) |
TAILQ_FOREACH(fdef, &pn->childq, child) |
if (NODE_FUNCDEF == fdef->node) |
if (NODE_FUNCDEF == fdef->node) |
break; |
break; |
Line 893 pnode_printfuncprototype(struct parse *p, struct pnode |
|
Line 747 pnode_printfuncprototype(struct parse *p, struct pnode |
|
pnode_printparamdef(p, pp); |
pnode_printparamdef(p, pp); |
|
|
puts(".Fc"); |
puts(".Fc"); |
|
p->newln = 1; |
} |
} |
|
|
/* |
/* |
* The <arg> element is more complicated than it should be because text |
* The <arg> element is more complicated than it should be because text |
* nodes are treated like ".Ar foo", but non-text nodes need to be |
* nodes are treated like ".Ar foo", but non-text nodes need to be |
* re-sent into the printer (i.e., without the preceding ".Ar"). |
* re-sent into the printer (i.e., without the preceding ".Ar"). |
* TODO: handle "optional" attribute. |
* This also handles the case of "repetition" (or in other words, the |
|
* ellipsis following an argument) and optionality. |
*/ |
*/ |
static void |
static void |
pnode_printarg(struct parse *p, struct pnode *pn) |
pnode_printarg(struct parse *p, struct pnode *pn) |
{ |
{ |
struct pnode *pp; |
struct pnode *pp; |
|
struct pattr *ap; |
|
int isop, isrep; |
|
|
|
isop = 1; |
|
isrep = 0; |
|
TAILQ_FOREACH(ap, &pn->attrq, child) |
|
if (ATTRKEY_CHOICE == ap->key && |
|
(ATTRVAL_PLAIN == ap->val || |
|
ATTRVAL_REQ == ap->val)) |
|
isop = 0; |
|
else if (ATTRKEY_REP == ap->key && |
|
(ATTRVAL_REPEAT == ap->val)) |
|
isrep = 1; |
|
|
|
if (isop) { |
|
pnode_printmopen(p); |
|
fputs("Op", stdout); |
|
} |
|
|
TAILQ_FOREACH(pp, &pn->childq, child) { |
TAILQ_FOREACH(pp, &pn->childq, child) { |
if (NODE_TEXT == pp->node) { |
if (NODE_TEXT == pp->node) { |
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Ar ", stdout); |
fputs("Ar", stdout); |
} |
} |
pnode_print(p, pp); |
pnode_print(p, pp); |
|
if (NODE_TEXT == pp->node && isrep) |
|
fputs("...", stdout); |
} |
} |
} |
} |
|
|
Line 953 pnode_printprologue(struct parse *p, struct pnode *pn) |
|
Line 829 pnode_printprologue(struct parse *p, struct pnode *pn) |
|
} |
} |
} |
} |
|
|
|
static void |
|
pnode_printvarlistentry(struct parse *p, struct pnode *pn) |
|
{ |
|
struct pnode *pp; |
|
|
|
assert(p->newln); |
|
TAILQ_FOREACH(pp, &pn->childq, child) |
|
if (NODE_TERM == pp->node) { |
|
fputs(".It", stdout); |
|
p->newln = 0; |
|
pnode_print(p, pp); |
|
pnode_unlink(pp); |
|
pnode_printmclose(p, 1); |
|
return; |
|
} |
|
|
|
puts(".It"); |
|
p->newln = 1; |
|
} |
|
|
|
static void |
|
pnode_printitemizedlist(struct parse *p, struct pnode *pn) |
|
{ |
|
struct pnode *pp; |
|
|
|
assert(p->newln); |
|
TAILQ_FOREACH(pp, &pn->childq, child) |
|
if (NODE_TITLE == pp->node) { |
|
puts(".Pp"); |
|
pnode_print(p, pp); |
|
pnode_unlink(pp); |
|
} |
|
|
|
assert(p->newln); |
|
|
|
if (NODE_ORDEREDLIST == pn->node) |
|
puts(".Bl -enum"); |
|
else |
|
puts(".Bl -item"); |
|
|
|
TAILQ_FOREACH(pp, &pn->childq, child) { |
|
assert(p->newln); |
|
puts(".It"); |
|
pnode_print(p, pp); |
|
pnode_printmclose(p, 1); |
|
} |
|
assert(p->newln); |
|
puts(".El"); |
|
} |
|
|
|
static void |
|
pnode_printvariablelist(struct parse *p, struct pnode *pn) |
|
{ |
|
struct pnode *pp; |
|
|
|
assert(p->newln); |
|
TAILQ_FOREACH(pp, &pn->childq, child) |
|
if (NODE_TITLE == pp->node) { |
|
puts(".Pp"); |
|
pnode_print(p, pp); |
|
pnode_unlink(pp); |
|
} |
|
|
|
assert(p->newln); |
|
puts(".Bl -tag -width Ds"); |
|
TAILQ_FOREACH(pp, &pn->childq, child) |
|
if (NODE_VARLISTENTRY != pp->node) { |
|
assert(p->newln); |
|
fputs(".It", stdout); |
|
pnode_printmacroline(p, pp); |
|
} else { |
|
assert(p->newln); |
|
pnode_print(p, pp); |
|
} |
|
assert(p->newln); |
|
puts(".El"); |
|
} |
|
|
/* |
/* |
* Print a parsed node (or ignore it--whatever). |
* Print a parsed node (or ignore it--whatever). |
* This is a recursive function. |
* This is a recursive function. |
Line 982 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 936 pnode_print(struct parse *p, struct pnode *pn) |
|
break; |
break; |
case (NODE_CODE): |
case (NODE_CODE): |
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Li ", stdout); |
fputs("Li", stdout); |
break; |
break; |
case (NODE_COMMAND): |
case (NODE_COMMAND): |
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Nm ", stdout); |
fputs("Nm", stdout); |
break; |
break; |
|
case (NODE_EMPHASIS): |
|
pnode_printmopen(p); |
|
fputs("Em", stdout); |
|
break; |
|
case (NODE_ENVAR): |
|
pnode_printmopen(p); |
|
fputs("Ev", stdout); |
|
break; |
|
case (NODE_FILENAME): |
|
pnode_printmopen(p); |
|
fputs("Pa", stdout); |
|
break; |
case (NODE_FUNCTION): |
case (NODE_FUNCTION): |
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Fn ", stdout); |
fputs("Fn", stdout); |
break; |
break; |
case (NODE_FUNCPROTOTYPE): |
case (NODE_FUNCPROTOTYPE): |
assert(p->newln); |
assert(p->newln); |
Line 999 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 965 pnode_print(struct parse *p, struct pnode *pn) |
|
break; |
break; |
case (NODE_FUNCSYNOPSISINFO): |
case (NODE_FUNCSYNOPSISINFO): |
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Fd ", stdout); |
fputs("Fd", stdout); |
break; |
break; |
|
case (NODE_ITEMIZEDLIST): |
|
/* FALLTHROUGH */ |
|
case (NODE_ORDEREDLIST): |
|
assert(p->newln); |
|
pnode_printitemizedlist(p, pn); |
|
break; |
|
case (NODE_LITERAL): |
|
pnode_printmopen(p); |
|
fputs("Li", stdout); |
|
break; |
case (NODE_OPTION): |
case (NODE_OPTION): |
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Fl ", stdout); |
fputs("Fl", stdout); |
break; |
break; |
case (NODE_PARA): |
case (NODE_PARA): |
assert(p->newln); |
assert(p->newln); |
|
if (NULL != pn->parent && |
|
NODE_LISTITEM == pn->parent->node) |
|
break; |
puts(".Pp"); |
puts(".Pp"); |
break; |
break; |
case (NODE_PARAMETER): |
case (NODE_PARAMETER): |
Line 1018 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 997 pnode_print(struct parse *p, struct pnode *pn) |
|
pnode_unlinksub(pn); |
pnode_unlinksub(pn); |
break; |
break; |
case (NODE_PROGRAMLISTING): |
case (NODE_PROGRAMLISTING): |
|
/* FALLTHROUGH */ |
|
case (NODE_SCREEN): |
assert(p->newln); |
assert(p->newln); |
puts(".Bd -literal"); |
puts(".Bd -literal"); |
break; |
break; |
|
case (NODE_REFENTRYINFO): |
|
/* Suppress. */ |
|
pnode_unlinksub(pn); |
|
break; |
case (NODE_REFMETA): |
case (NODE_REFMETA): |
abort(); |
abort(); |
break; |
break; |
case (NODE_REFNAME): |
case (NODE_REFNAME): |
/* Suppress non-text children... */ |
/* Suppress non-text children... */ |
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Nm ", stdout); |
fputs("Nm", stdout); |
|
p->newln = 0; |
pnode_printmacrolinepart(p, pn); |
pnode_printmacrolinepart(p, pn); |
pnode_unlinksub(pn); |
pnode_unlinksub(pn); |
break; |
break; |
Line 1037 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1023 pnode_print(struct parse *p, struct pnode *pn) |
|
break; |
break; |
case (NODE_REFPURPOSE): |
case (NODE_REFPURPOSE): |
assert(p->newln); |
assert(p->newln); |
fputs(".Nd ", stdout); |
pnode_printmopen(p); |
|
fputs("Nd", stdout); |
break; |
break; |
case (NODE_REFSYNOPSISDIV): |
case (NODE_REFSYNOPSISDIV): |
assert(p->newln); |
assert(p->newln); |
Line 1045 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1032 pnode_print(struct parse *p, struct pnode *pn) |
|
puts(".Sh SYNOPSIS"); |
puts(".Sh SYNOPSIS"); |
break; |
break; |
case (NODE_REFSECT1): |
case (NODE_REFSECT1): |
|
/* FALLTHROUGH */ |
|
case (NODE_REFSECT2): |
assert(p->newln); |
assert(p->newln); |
pnode_printrefsect(p, pn); |
pnode_printrefsect(p, pn); |
break; |
break; |
|
case (NODE_REPLACEABLE): |
|
pnode_printmopen(p); |
|
fputs("Ar", stdout); |
|
break; |
|
case (NODE_SBR): |
|
assert(p->newln); |
|
puts(".br"); |
|
break; |
case (NODE_STRUCTNAME): |
case (NODE_STRUCTNAME): |
pnode_printmopen(p); |
pnode_printmopen(p); |
fputs("Vt ", stdout); |
fputs("Vt", stdout); |
break; |
break; |
case (NODE_TEXT): |
case (NODE_TEXT): |
|
if (0 == p->newln) |
|
putchar(' '); |
bufclear(p); |
bufclear(p); |
bufappend(p, pn); |
bufappend(p, pn); |
/* |
/* |
Line 1062 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1061 pnode_print(struct parse *p, struct pnode *pn) |
|
* Remember to escape control characters and escapes. |
* Remember to escape control characters and escapes. |
*/ |
*/ |
assert(p->bsz); |
assert(p->bsz); |
for (last = '\n', cp = p->b; '\0' != *cp; ) { |
cp = p->b; |
|
/* |
|
* There's often a superfluous "-" in its <option> tags |
|
* before the actual flags themselves. |
|
* "Fl" does this for us, so remove it. |
|
*/ |
|
if (NULL != pn->parent && |
|
NODE_OPTION == pn->parent->node && |
|
'-' == *cp) |
|
cp++; |
|
for (last = '\n'; '\0' != *cp; ) { |
if ('\n' == last) { |
if ('\n' == last) { |
/* Consume all whitespace. */ |
/* Consume all whitespace. */ |
if (isspace((int)*cp)) { |
if (isspace((int)*cp)) { |
Line 1079 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1088 pnode_print(struct parse *p, struct pnode *pn) |
|
} |
} |
p->newln = 0; |
p->newln = 0; |
break; |
break; |
|
case (NODE_VARIABLELIST): |
|
assert(p->newln); |
|
pnode_printvariablelist(p, pn); |
|
pnode_unlinksub(pn); |
|
break; |
|
case (NODE_VARLISTENTRY): |
|
assert(p->newln); |
|
pnode_printvarlistentry(p, pn); |
|
break; |
default: |
default: |
break; |
break; |
} |
} |
Line 1090 pnode_print(struct parse *p, struct pnode *pn) |
|
Line 1108 pnode_print(struct parse *p, struct pnode *pn) |
|
case (NODE_ARG): |
case (NODE_ARG): |
case (NODE_CODE): |
case (NODE_CODE): |
case (NODE_COMMAND): |
case (NODE_COMMAND): |
|
case (NODE_EMPHASIS): |
|
case (NODE_ENVAR): |
|
case (NODE_FILENAME): |
case (NODE_FUNCTION): |
case (NODE_FUNCTION): |
case (NODE_FUNCSYNOPSISINFO): |
case (NODE_FUNCSYNOPSISINFO): |
|
case (NODE_LITERAL): |
case (NODE_OPTION): |
case (NODE_OPTION): |
case (NODE_PARAMETER): |
case (NODE_PARAMETER): |
case (NODE_REFNAME): |
case (NODE_REPLACEABLE): |
|
case (NODE_REFPURPOSE): |
case (NODE_STRUCTNAME): |
case (NODE_STRUCTNAME): |
case (NODE_TEXT): |
case (NODE_TEXT): |
pnode_printmclose(p, sv); |
pnode_printmclose(p, sv); |
break; |
break; |
|
case (NODE_REFNAME): |
|
/* |
|
* If we're in the NAME macro and we have multiple |
|
* <refname> macros in sequence, then print out a |
|
* trailing comma before the newline. |
|
*/ |
|
if (NULL != pn->parent && |
|
NODE_REFNAMEDIV == pn->parent->node && |
|
NULL != TAILQ_NEXT(pn, child) && |
|
NODE_REFNAME == TAILQ_NEXT(pn, child)->node) |
|
fputs(" ,", stdout); |
|
pnode_printmclose(p, sv); |
|
break; |
case (NODE_PROGRAMLISTING): |
case (NODE_PROGRAMLISTING): |
|
/* FALLTHROUGH */ |
|
case (NODE_SCREEN): |
assert(p->newln); |
assert(p->newln); |
puts(".Ed"); |
puts(".Ed"); |
p->newln = 1; |
p->newln = 1; |
Line 1124 readfile(XML_Parser xp, int fd, |
|
Line 1162 readfile(XML_Parser xp, int fd, |
|
memset(&p, 0, sizeof(struct parse)); |
memset(&p, 0, sizeof(struct parse)); |
|
|
p.b = malloc(p.bsz = p.mbsz = 1024); |
p.b = malloc(p.bsz = p.mbsz = 1024); |
|
p.fname = fn; |
|
p.xml = xp; |
|
|
XML_SetCharacterDataHandler(xp, xml_char); |
XML_SetCharacterDataHandler(xp, xml_char); |
XML_SetElementHandler(xp, xml_elem_start, xml_elem_end); |
XML_SetElementHandler(xp, xml_elem_start, xml_elem_end); |