Optimizations and bug fixes from STR #2:

- mxmlIndexNew() sort algorithm update to eliminate unnecessary
      right-hand recursion.
    - Combine printf() and puts() calls in mxmldoc to reduce the number
      of calls and code size.
    - mxmlSaveFile() now writes Unicode chars with fwrite for potential
      speedup and modest size savings.
    - mxmlEntityAddCallback() now returns an integer status so an app
      knows when it was not possible to add an entity callback.
pull/193/head
Michael R Sweet 20 years ago
parent 777022657d
commit 0fd3bd7f33
  1. 6
      CHANGES
  2. 7
      doc/reference.html
  3. 6
      doc/relnotes.html
  4. 13
      mxml-attr.c
  5. 14
      mxml-entity.c
  6. 56
      mxml-file.c
  7. 85
      mxml-index.c
  8. 10
      mxml-private.c
  9. 6
      mxml.h
  10. 4
      mxml.xml
  11. 241
      mxmldoc.c

@ -1,9 +1,13 @@
README - 05/16/2004
README - 06/01/2004
-------------------
CHANGES IN Mini-XML 2.0
- New programmers manual.
- Added optimizations to mxmldoc, mxmlSaveFile(), and
mxmlIndexNew() (STR #2)
- mxmlEntityAddCallback() now returns an integer status
(STR #2)
- Added UTF-16 support (input only; all output is UTF-8)
- Added index functions to build a searchable index of
XML nodes.

@ -191,7 +191,7 @@ mxmlElementSetAttr(
<p>Add a callback to convert entities to Unicode.</p>
<h4>Syntax</h4>
<pre>
void
int
mxmlEntityAddCallback(
int (*cb)(const char *name));
</pre>
@ -202,7 +202,7 @@ mxmlEntityAddCallback(
<tr><td><tt>(*cb)(const char *name)</tt></td><td>Callback function to add</td></tr>
</tbody></table></p>
<h4>Returns</h4>
<p>Nothing.</p>
<p>0 on success, -1 on failure</p>
<!-- NEW PAGE -->
<h3><a name='mxmlEntityGetName'>mxmlEntityGetName()</a></h3>
<hr noshade/>
@ -1215,8 +1215,7 @@ union mxml_value_u
</ul>
<!-- NEW PAGE -->
<h3><a name='num_callbacks'>num_callbacks</a></h3>
<hr noshade/>
<h4>Definition</h4>
<hr noshade/><h4>Definition</h4>
<pre>
static int num_callbacks = 1;
</pre>

@ -9,6 +9,12 @@
<li>New programmers manual.</li>
<li>Added optimizations to mxmldoc, mxmlSaveFile(), and
mxmlIndexNew() (STR #2)</li>
<li>mxmlEntityAddCallback() now returns an integer
status (STR #2)</li>
<li>Added UTF-16 support (input only; all output is
UTF-8)</li>

@ -1,5 +1,5 @@
/*
* "$Id: mxml-attr.c,v 1.8 2004/05/02 16:04:40 mike Exp $"
* "$Id: mxml-attr.c,v 1.9 2004/06/01 20:19:34 mike Exp $"
*
* Attribute support code for Mini-XML, a small XML-like file parsing library.
*
@ -117,10 +117,15 @@ mxmlElementSetAttr(mxml_node_t *node, /* I - Element node */
* Replace the attribute value and return...
*/
free(attr->value);
if (attr->value)
free(attr->value);
if (value)
attr->value = strdup(value);
{
if ((attr->value = strdup(value)) == NULL)
mxml_error("Unable to allocate memory for attribute '%s' in element %s!",
name, node->value.element.name);
}
else
attr->value = NULL;
@ -172,5 +177,5 @@ mxmlElementSetAttr(mxml_node_t *node, /* I - Element node */
/*
* End of "$Id: mxml-attr.c,v 1.8 2004/05/02 16:04:40 mike Exp $".
* End of "$Id: mxml-attr.c,v 1.9 2004/06/01 20:19:34 mike Exp $".
*/

@ -1,5 +1,5 @@
/*
* "$Id: mxml-entity.c,v 1.4 2004/05/16 05:25:38 mike Exp $"
* "$Id: mxml-entity.c,v 1.5 2004/06/01 20:19:34 mike Exp $"
*
* Character entity support code for Mini-XML, a small XML-like
* file parsing library.
@ -58,7 +58,7 @@ static int (*callbacks[100])(const char *name) =
* 'mxmlEntityAddCallback()' - Add a callback to convert entities to Unicode.
*/
void
int /* O - 0 on success, -1 on failure */
mxmlEntityAddCallback(int (*cb)(const char *name))
/* I - Callback function to add */
{
@ -66,6 +66,14 @@ mxmlEntityAddCallback(int (*cb)(const char *name))
{
callbacks[num_callbacks] = cb;
num_callbacks ++;
return (0);
}
else
{
mxml_error("Unable to add entity callback!");
return (-1);
}
}
@ -451,5 +459,5 @@ default_callback(const char *name) /* I - Entity name */
/*
* End of "$Id: mxml-entity.c,v 1.4 2004/05/16 05:25:38 mike Exp $".
* End of "$Id: mxml-entity.c,v 1.5 2004/06/01 20:19:34 mike Exp $".
*/

@ -1,5 +1,5 @@
/*
* "$Id: mxml-file.c,v 1.31 2004/05/16 21:54:47 mike Exp $"
* "$Id: mxml-file.c,v 1.32 2004/06/01 20:19:34 mike Exp $"
*
* File loading code for Mini-XML, a small XML-like file parsing library.
*
@ -601,18 +601,24 @@ static int /* O - 0 on success, -1 on failure */
mxml_file_putc(int ch, /* I - Character to write */
void *p) /* I - Pointer to file */
{
char buffer[4], /* Buffer for character */
*bufptr; /* Pointer into buffer */
int buflen; /* Number of bytes to write */
if (ch < 128)
return (putc(ch, (FILE *)p));
else if (ch < 2048)
return (putc(ch, (FILE *)p) == EOF ? -1 : 0);
bufptr = buffer;
if (ch < 2048)
{
/*
* Two-byte UTF-8 character...
*/
if (putc(0xc0 | (ch >> 6), (FILE *)p) < 0)
return (-1);
else
return (putc(0x80 | (ch & 0x3f), (FILE *)p));
*bufptr++ = 0xc0 | (ch >> 6);
*bufptr++ = 0x80 | (ch & 0x3f);
}
else if (ch < 65536)
{
@ -620,12 +626,9 @@ mxml_file_putc(int ch, /* I - Character to write */
* Three-byte UTF-8 character...
*/
if (putc(0xe0 | (ch >> 12), (FILE *)p) < 0)
return (-1);
else if (putc(0x80 | ((ch >> 6) & 0x3f), (FILE *)p) < 0)
return (-1);
else
return (putc(0x80 | (ch & 0x3f), (FILE *)p));
*bufptr++ = 0xe0 | (ch >> 12);
*bufptr++ = 0x80 | ((ch >> 6) & 0x3f);
*bufptr++ = 0x80 | (ch & 0x3f);
}
else
{
@ -633,15 +636,15 @@ mxml_file_putc(int ch, /* I - Character to write */
* Four-byte UTF-8 character...
*/
if (putc(0xf0 | (ch >> 18), (FILE *)p) < 0)
return (-1);
else if (putc(0x80 | ((ch >> 12) & 0x3f), (FILE *)p) < 0)
return (-1);
else if (putc(0x80 | ((ch >> 6) & 0x3f), (FILE *)p) < 0)
return (-1);
else
return (putc(0x80 | (ch & 0x3f), (FILE *)p));
*bufptr++ = 0xf0 | (ch >> 18);
*bufptr++ = 0x80 | ((ch >> 12) & 0x3f);
*bufptr++ = 0x80 | ((ch >> 6) & 0x3f);
*bufptr++ = 0x80 | (ch & 0x3f);
}
buflen = bufptr - buffer;
return (fwrite(buffer, 1, buflen, (FILE *)p) < buflen ? -1 : 0);
}
@ -1633,6 +1636,7 @@ mxml_write_node(mxml_node_t *node, /* I - Node to write */
width; /* Width of attr + value */
mxml_attr_t *attr; /* Current attribute */
char s[255]; /* Temporary string */
int slen; /* Length of temporary string */
while (node != NULL)
@ -1779,11 +1783,11 @@ mxml_write_node(mxml_node_t *node, /* I - Node to write */
col ++;
}
sprintf(s, "%d", node->value.integer);
slen = snprintf(s, sizeof(s), "%d", node->value.integer);
if (mxml_write_string(s, p, putc_cb) < 0)
return (-1);
col += strlen(s);
col += slen;
break;
case MXML_OPAQUE :
@ -1809,11 +1813,11 @@ mxml_write_node(mxml_node_t *node, /* I - Node to write */
col ++;
}
sprintf(s, "%f", node->value.real);
slen = snprintf(s, sizeof(s), "%f", node->value.real);
if (mxml_write_string(s, p, putc_cb) < 0)
return (-1);
col += strlen(s);
col += slen;
break;
case MXML_TEXT :
@ -1932,5 +1936,5 @@ mxml_write_ws(mxml_node_t *node, /* I - Current node */
/*
* End of "$Id: mxml-file.c,v 1.31 2004/05/16 21:54:47 mike Exp $".
* End of "$Id: mxml-file.c,v 1.32 2004/06/01 20:19:34 mike Exp $".
*/

@ -1,5 +1,5 @@
/*
* "$Id: mxml-index.c,v 1.4 2004/05/16 18:25:20 mike Exp $"
* "$Id: mxml-index.c,v 1.5 2004/06/01 20:19:34 mike Exp $"
*
* Index support code for Mini-XML, a small XML-like file parsing library.
*
@ -581,64 +581,69 @@ index_sort(mxml_index_t *ind, /* I - Index to sort */
/*
* Sort the pivot in the current partition...
* Loop until we have sorted all the way to the right...
*/
pivot = ind->nodes[left];
for (templ = left, tempr = right; templ < tempr;)
do
{
/*
* Move left while left node <= pivot node...
* Sort the pivot in the current partition...
*/
while ((templ < right) &&
index_compare(ind, ind->nodes[templ], pivot) <= 0)
templ ++;
pivot = ind->nodes[left];
/*
* Move right while right node > pivot node...
*/
for (templ = left, tempr = right; templ < tempr;)
{
/*
* Move left while left node <= pivot node...
*/
while ((templ < right) &&
index_compare(ind, ind->nodes[templ], pivot) <= 0)
templ ++;
/*
* Move right while right node > pivot node...
*/
while ((tempr > left) &&
index_compare(ind, ind->nodes[tempr], pivot) > 0)
tempr --;
while ((tempr > left) &&
index_compare(ind, ind->nodes[tempr], pivot) > 0)
tempr --;
/*
* Swap nodes if needed...
*/
if (templ < tempr)
{
temp = ind->nodes[templ];
ind->nodes[templ] = ind->nodes[tempr];
ind->nodes[tempr] = temp;
}
}
/*
* Swap nodes if needed...
* When we get here, the right (tempr) node is the new position for the
* pivot node...
*/
if (templ < tempr)
if (index_compare(ind, pivot, ind->nodes[tempr]) > 0)
{
temp = ind->nodes[templ];
ind->nodes[templ] = ind->nodes[tempr];
ind->nodes[tempr] = temp;
ind->nodes[left] = ind->nodes[tempr];
ind->nodes[tempr] = pivot;
}
}
/*
* When we get here, the right (tempr) node is the new position for the
* pivot node...
*/
/*
* Recursively sort the left partition as needed...
*/
if (index_compare(ind, pivot, ind->nodes[tempr]) > 0)
{
ind->nodes[left] = ind->nodes[tempr];
ind->nodes[tempr] = pivot;
if (left < (tempr - 1))
index_sort(ind, left, tempr - 1);
}
/*
* Recursively sort the left and right partitions as needed...
*/
if (left < (tempr - 1))
index_sort(ind, left, tempr - 1);
if (right > (tempr + 1))
index_sort(ind, tempr + 1, right);
while (right > (left = tempr + 1));
}
/*
* End of "$Id: mxml-index.c,v 1.4 2004/05/16 18:25:20 mike Exp $".
* End of "$Id: mxml-index.c,v 1.5 2004/06/01 20:19:34 mike Exp $".
*/

@ -1,5 +1,5 @@
/*
* "$Id: mxml-private.c,v 1.4 2004/05/02 16:04:40 mike Exp $"
* "$Id: mxml-private.c,v 1.5 2004/06/01 20:19:34 mike Exp $"
*
* Private functions for Mini-XML, a small XML-like file parsing library.
*
@ -74,11 +74,7 @@ mxml_error(const char *format, /* I - Printf-style format string */
if (mxml_error_cb)
(*mxml_error_cb)(s);
else
{
fputs("mxml: ", stderr);
fputs(s, stderr);
putc('\n', stderr);
}
fprintf(stderr, "mxml: %s\n", s);
/*
* Free the string...
@ -128,5 +124,5 @@ mxml_real_cb(mxml_node_t *node) /* I - Current node */
/*
* End of "$Id: mxml-private.c,v 1.4 2004/05/02 16:04:40 mike Exp $".
* End of "$Id: mxml-private.c,v 1.5 2004/06/01 20:19:34 mike Exp $".
*/

@ -1,5 +1,5 @@
/*
* "$Id: mxml.h,v 1.20 2004/05/16 05:25:38 mike Exp $"
* "$Id: mxml.h,v 1.21 2004/06/01 20:19:34 mike Exp $"
*
* Header file for Mini-XML, a small XML-like file parsing library.
*
@ -146,7 +146,7 @@ extern void mxmlDelete(mxml_node_t *node);
extern const char *mxmlElementGetAttr(mxml_node_t *node, const char *name);
extern void mxmlElementSetAttr(mxml_node_t *node, const char *name,
const char *value);
extern void mxmlEntityAddCallback(int (*cb)(const char *name));
extern int mxmlEntityAddCallback(int (*cb)(const char *name));
extern const char *mxmlEntityGetName(int val);
extern int mxmlEntityGetValue(const char *name);
extern void mxmlEntityRemoveCallback(int (*cb)(const char *name));
@ -225,5 +225,5 @@ extern mxml_type_t mxml_real_cb(mxml_node_t *node);
/*
* End of "$Id: mxml.h,v 1.20 2004/05/16 05:25:38 mike Exp $".
* End of "$Id: mxml.h,v 1.21 2004/06/01 20:19:34 mike Exp $".
*/

@ -75,6 +75,10 @@ not an element.</description>
</argument>
</function>
<function name="mxmlEntityAddCallback">
<returnvalue>
<type>int</type>
<description>0 on success, -1 on failure</description>
</returnvalue>
<description>Add a callback to convert entities to Unicode.</description>
<argument name="(*cb)(const char *name)" direction="I">
<type>int</type>

@ -1,5 +1,5 @@
/*
* "$Id: mxmldoc.c,v 1.36 2004/05/02 22:02:36 mike Exp $"
* "$Id: mxmldoc.c,v 1.37 2004/06/01 20:19:34 mike Exp $"
*
* Documentation generator using Mini-XML, a small XML-like file parsing
* library.
@ -1779,19 +1779,18 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
*/
puts("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
puts("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>");
puts("<head>");
puts("\t<title>Documentation</title>");
puts("\t<meta name='creator' content='" MXML_VERSION "'/>");
puts("\t<style><!--");
puts("\th1, h2, h3, p { font-family: sans-serif; text-align: justify; }");
puts("\ttt, pre a:link, pre a:visited, tt a:link, tt a:visited { font-weight: bold; color: #7f0000; }");
puts("\tpre { font-weight: bold; color: #7f0000; margin-left: 2em; }");
puts("\t--></style>");
puts("</head>");
puts("<body>");
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
"<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"
"<head>\n"
"\t<title>Documentation</title>\n"
"\t<meta name='creator' content='" MXML_VERSION "'/>\n"
"\t<style><!--\n"
"\th1, h2, h3, p { font-family: sans-serif; text-align: justify; }\n"
"\ttt, pre a:link, pre a:visited, tt a:link, tt a:visited { font-weight: bold; color: #7f0000; }\n"
"\tpre { font-weight: bold; color: #7f0000; margin-left: 2em; }\n"
"\t--></style>\n"
"</head>\n"
"<body>");
/*
* Table of contents...
@ -1821,9 +1820,9 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "class", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<!-- NEW PAGE -->");
puts("<h2><a name='_classes'>Classes</a></h2>");
puts("<ul>");
puts("<!-- NEW PAGE -->\n"
"<h2><a name='_classes'>Classes</a></h2>\n"
"<ul>");
for (scut = mxmlFindElement(doc, doc, "class", NULL, NULL,
MXML_DESCEND_FIRST);
@ -1844,24 +1843,23 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
cname = mxmlElementGetAttr(scut, "name");
puts("<!-- NEW PAGE -->");
printf("<h3><a name='%s'>%s</a></h3>\n", cname, cname);
puts("<hr noshade/>");
printf("<!-- NEW PAGE -->\n"
"<h3><a name='%s'>%s</a></h3>\n"
"<hr noshade/>\n", cname, cname);
description = mxmlFindElement(scut, scut, "description", NULL,
NULL, MXML_DESCEND_FIRST);
if (description)
{
puts("<h4>Description</h4>");
fputs("<p>", stdout);
fputs("<h4>Description</h4>\n"
"<p>", stdout);
write_element(NULL, description);
puts("</p>");
}
puts("<h4>Definition</h4>");
puts("<pre>");
printf("class %s", cname);
printf("<h4>Definition</h4>\n"
"<pre>\n"
"class %s", cname);
if ((parent = mxmlElementGetAttr(scut, "parent")) != NULL)
printf(" %s", parent);
puts("\n{");
@ -1948,14 +1946,12 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
}
}
puts("};\n</pre>");
puts("<h4>Members</h4>");
puts("<p class='table'><table align='center' border='1' "
"cellpadding='5' cellspacing='0' width='80%'>");
puts("<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>");
puts("<tbody>");
puts("};\n</pre>\n"
"<h4>Members</h4>\n"
"<p class='table'><table align='center' border='1' "
"cellpadding='5' cellspacing='0' width='80%'>\n"
"<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>\n"
"<tbody>");
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST);
@ -2001,7 +1997,6 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
}
puts("</tbody></table></p>");
}
}
@ -2011,9 +2006,9 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "enumeration", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<!-- NEW PAGE -->");
puts("<h2><a name='_enumerations'>Enumerations</a></h2>");
puts("<ul>");
puts("<!-- NEW PAGE -->\n"
"<h2><a name='_enumerations'>Enumerations</a></h2>\n"
"<ul>");
for (scut = mxmlFindElement(doc, doc, "enumeration", NULL, NULL,
MXML_DESCEND_FIRST);
@ -2034,26 +2029,25 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(scut, "name");
puts("<!-- NEW PAGE -->");
printf("<h3><a name='%s'>%s</a></h3>\n", name, name);
puts("<hr noshade/>");
printf("<!-- NEW PAGE -->\n"
"<h3><a name='%s'>%s</a></h3>\n"
"<hr noshade/>\n", name, name);
description = mxmlFindElement(scut, scut, "description", NULL,
NULL, MXML_DESCEND_FIRST);
if (description)
{
puts("<h4>Description</h4>");
fputs("<p>", stdout);
fputs("<h4>Description</h4>\n"
"<p>", stdout);
write_element(NULL, description);
puts("</p>");
}
puts("<h4>Values</h4>");
puts("<p class='table'><table align='center' border='1' width='80%' "
"cellpadding='5' cellspacing='0' width='80%'>");
puts("<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>");
puts("<tbody>");
puts("<h4>Values</h4>\n"
"<p class='table'><table align='center' border='1' width='80%' "
"cellpadding='5' cellspacing='0' width='80%'>\n"
"<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>\n"
"<tbody>");
for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL,
MXML_DESCEND_FIRST);
@ -2079,9 +2073,9 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "function", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<!-- NEW PAGE -->");
puts("<h2><a name='_functions'>Functions</a></h2>");
puts("<ul>");
puts("<!-- NEW PAGE -->\n"
"<h2><a name='_functions'>Functions</a></h2>\n"
"<ul>");
for (function = mxmlFindElement(doc, doc, "function", NULL, NULL,
MXML_DESCEND_FIRST);
@ -2102,22 +2096,22 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(function, "name");
puts("<!-- NEW PAGE -->");
printf("<h3><a name='%s'>%s()</a></h3>\n", name, name);
puts("<hr noshade/>");
printf("<!-- NEW PAGE -->\n"
"<h3><a name='%s'>%s()</a></h3>\n"
"<hr noshade/>\n", name, name);
description = mxmlFindElement(function, function, "description", NULL,
NULL, MXML_DESCEND_FIRST);
if (description)
{
puts("<h4>Description</h4>");
fputs("<p>", stdout);
fputs("<h4>Description</h4>\n"
"<p>", stdout);
write_element(NULL, description);
puts("</p>");
}
puts("<h4>Syntax</h4>");
puts("<pre>");
puts("<h4>Syntax</h4>\n"
"<pre>");
arg = mxmlFindElement(function, function, "returnvalue", NULL,
NULL, MXML_DESCEND_FIRST);
@ -2161,9 +2155,9 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
else
{
puts("<p class='table'><table align='center' border='1' width='80%' "
"cellpadding='5' cellspacing='0' width='80%'>");
puts("<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>");
puts("<tbody>");
"cellpadding='5' cellspacing='0' width='80%'>\n"
"<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>\n"
"<tbody>");
for (arg = mxmlFindElement(function, function, "argument", NULL, NULL,
MXML_DESCEND_FIRST);
@ -2205,9 +2199,9 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "struct", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<!-- NEW PAGE -->");
puts("<h2><a name='_structures'>Structures</a></h2>");
puts("<ul>");
puts("<!-- NEW PAGE -->\n"
"<h2><a name='_structures'>Structures</a></h2>\n"
"<ul>");
for (scut = mxmlFindElement(doc, doc, "struct", NULL, NULL,
MXML_DESCEND_FIRST);
@ -2228,24 +2222,23 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
cname = mxmlElementGetAttr(scut, "name");
puts("<!-- NEW PAGE -->");
printf("<h3><a name='%s'>%s</a></h3>\n", cname, cname);
puts("<hr noshade/>");
printf("<!-- NEW PAGE -->\n"
"<h3><a name='%s'>%s</a></h3>\n"
"<hr noshade/>\n", cname, cname);
description = mxmlFindElement(scut, scut, "description", NULL,
NULL, MXML_DESCEND_FIRST);
if (description)
{
puts("<h4>Description</h4>");
fputs("<p>", stdout);
fputs("<h4>Description</h4>\n"
"<p>", stdout);
write_element(NULL, description);
puts("</p>");
}
puts("<h4>Definition</h4>");
puts("<pre>");
printf("struct %s\n{\n", cname);
printf("<h4>Definition</h4>\n"
"<pre>\n"
"struct %s\n{\n", cname);
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST);
arg;
@ -2311,14 +2304,12 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
puts(");");
}
puts("};\n</pre>");
puts("<h4>Members</h4>");
puts("<p class='table'><table align='center' border='1' width='80%' "
"cellpadding='5' cellspacing='0' width='80%'>");
puts("<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>");
puts("<tbody>");
puts("};\n</pre>\n"
"<h4>Members</h4>\n"
"<p class='table'><table align='center' border='1' width='80%' "
"cellpadding='5' cellspacing='0' width='80%'>\n"
"<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>\n"
"<tbody>");
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST);
@ -2373,9 +2364,9 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "typedef", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<!-- NEW PAGE -->");
puts("<h2><a name='_types'>Types</a></h2>");
puts("<ul>");
puts("<!-- NEW PAGE -->\n"
"<h2><a name='_types'>Types</a></h2>\n"
"<ul>");
for (scut = mxmlFindElement(doc, doc, "typedef", NULL, NULL,
MXML_DESCEND_FIRST);
@ -2396,24 +2387,23 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(scut, "name");
puts("<!-- NEW PAGE -->");
printf("<h3><a name='%s'>%s</a></h3>\n", name, name);
puts("<hr noshade/>");
printf("<!-- NEW PAGE -->\n"
"<h3><a name='%s'>%s</a></h3>\n"
"<hr noshade/>\n", name, name);
description = mxmlFindElement(scut, scut, "description", NULL,
NULL, MXML_DESCEND_FIRST);
if (description)
{
puts("<h4>Description</h4>");
fputs("<p>", stdout);
fputs("<h4>Description</h4>\n"
"<p>", stdout);
write_element(NULL, description);
puts("</p>");
}
puts("<h4>Definition</h4>");
puts("<pre>");
printf("typedef ");
fputs("<h4>Definition</h4>\n"
"<pre>\n"
"typedef ", stdout);
write_element(doc, mxmlFindElement(scut, scut, "type", NULL,
NULL, MXML_DESCEND_FIRST));
printf(" %s;\n</pre>\n", name);
@ -2426,9 +2416,9 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "union", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<!-- NEW PAGE -->");
puts("<h2><a name='_unions'>Unions</a></h2>");
puts("<ul>");
puts("<!-- NEW PAGE -->\n"
"<h2><a name='_unions'>Unions</a></h2>\n"
"<ul>");
for (scut = mxmlFindElement(doc, doc, "union", NULL, NULL,
MXML_DESCEND_FIRST);
@ -2449,24 +2439,23 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(scut, "name");
puts("<!-- NEW PAGE -->");
printf("<h3><a name='%s'>%s</a></h3>\n", name, name);
puts("<hr noshade/>");
printf("<!-- NEW PAGE -->\n"
"<h3><a name='%s'>%s</a></h3>\n"
"<hr noshade/>\n", name, name);
description = mxmlFindElement(scut, scut, "description", NULL,
NULL, MXML_DESCEND_FIRST);
if (description)
{
puts("<h4>Description</h4>");
fputs("<p>", stdout);
fputs("<h4>Description</h4>\n"
"<p>", stdout);
write_element(NULL, description);
puts("</p>");
}
puts("<h4>Definition</h4>");
puts("<pre>");
printf("union %s\n{\n", name);
printf("<h4>Definition</h4>\n"
"<pre>\n"
"union %s\n{\n", name);
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST);
arg;
@ -2479,14 +2468,12 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
}
puts("};\n</pre>");
puts("<h4>Members</h4>");
puts("<p class='table'><table align='center' border='1' width='80%' "
"cellpadding='5' cellspacing='0' width='80%'>");
puts("<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>");
puts("<tbody>");
puts("};\n</pre>\n"
"<h4>Members</h4>\n"
"<p class='table'><table align='center' border='1' width='80%' "
"cellpadding='5' cellspacing='0' width='80%'>\n"
"<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>\n"
"<tbody>");
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST);
@ -2512,9 +2499,9 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "variable", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<!-- NEW PAGE -->");
puts("<h2><a name='_variables'>Variables</a></h2>");
puts("<ul>");
puts("<!-- NEW PAGE -->\n"
"<h2><a name='_variables'>Variables</a></h2>\n"
"<ul>");
for (arg = mxmlFindElement(doc, doc, "variable", NULL, NULL,
MXML_DESCEND_FIRST);
@ -2535,22 +2522,22 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(arg, "name");
puts("<!-- NEW PAGE -->");
printf("<h3><a name='%s'>%s</a></h3>\n", name, name);
puts("<hr noshade/>");
printf("<!-- NEW PAGE -->\n"
"<h3><a name='%s'>%s</a></h3>\n"
"<hr noshade/>", name, name);
description = mxmlFindElement(arg, arg, "description", NULL,
NULL, MXML_DESCEND_FIRST);
if (description)
{
puts("<h4>Description</h4>");
fputs("<p>", stdout);
fputs("<h4>Description</h4>\n"
"<p>", stdout);
write_element(NULL, description);
puts("</p>");
}
puts("<h4>Definition</h4>");
puts("<pre>");
puts("<h4>Definition</h4>\n"
"<pre>");
write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
NULL, MXML_DESCEND_FIRST));
@ -2565,8 +2552,8 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
* Standard footer...
*/
puts("</body>");
puts("</html>");
puts("</body>\n"
"</html>");
}
@ -2748,5 +2735,5 @@ ws_cb(mxml_node_t *node, /* I - Element node */
/*
* End of "$Id: mxmldoc.c,v 1.36 2004/05/02 22:02:36 mike Exp $".
* End of "$Id: mxmldoc.c,v 1.37 2004/06/01 20:19:34 mike Exp $".
*/

Loading…
Cancel
Save