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 CHANGES IN Mini-XML 2.0
- New programmers manual. - 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 UTF-16 support (input only; all output is UTF-8)
- Added index functions to build a searchable index of - Added index functions to build a searchable index of
XML nodes. XML nodes.

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

@ -9,6 +9,12 @@
<li>New programmers manual.</li> <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 <li>Added UTF-16 support (input only; all output is
UTF-8)</li> 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. * 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... * Replace the attribute value and return...
*/ */
free(attr->value); if (attr->value)
free(attr->value);
if (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 else
attr->value = NULL; 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 * Character entity support code for Mini-XML, a small XML-like
* file parsing library. * file parsing library.
@ -58,7 +58,7 @@ static int (*callbacks[100])(const char *name) =
* 'mxmlEntityAddCallback()' - Add a callback to convert entities to Unicode. * 'mxmlEntityAddCallback()' - Add a callback to convert entities to Unicode.
*/ */
void int /* O - 0 on success, -1 on failure */
mxmlEntityAddCallback(int (*cb)(const char *name)) mxmlEntityAddCallback(int (*cb)(const char *name))
/* I - Callback function to add */ /* I - Callback function to add */
{ {
@ -66,6 +66,14 @@ mxmlEntityAddCallback(int (*cb)(const char *name))
{ {
callbacks[num_callbacks] = cb; callbacks[num_callbacks] = cb;
num_callbacks ++; 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. * 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 */ mxml_file_putc(int ch, /* I - Character to write */
void *p) /* I - Pointer to file */ 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) if (ch < 128)
return (putc(ch, (FILE *)p)); return (putc(ch, (FILE *)p) == EOF ? -1 : 0);
else if (ch < 2048)
bufptr = buffer;
if (ch < 2048)
{ {
/* /*
* Two-byte UTF-8 character... * Two-byte UTF-8 character...
*/ */
if (putc(0xc0 | (ch >> 6), (FILE *)p) < 0) *bufptr++ = 0xc0 | (ch >> 6);
return (-1); *bufptr++ = 0x80 | (ch & 0x3f);
else
return (putc(0x80 | (ch & 0x3f), (FILE *)p));
} }
else if (ch < 65536) else if (ch < 65536)
{ {
@ -620,12 +626,9 @@ mxml_file_putc(int ch, /* I - Character to write */
* Three-byte UTF-8 character... * Three-byte UTF-8 character...
*/ */
if (putc(0xe0 | (ch >> 12), (FILE *)p) < 0) *bufptr++ = 0xe0 | (ch >> 12);
return (-1); *bufptr++ = 0x80 | ((ch >> 6) & 0x3f);
else if (putc(0x80 | ((ch >> 6) & 0x3f), (FILE *)p) < 0) *bufptr++ = 0x80 | (ch & 0x3f);
return (-1);
else
return (putc(0x80 | (ch & 0x3f), (FILE *)p));
} }
else else
{ {
@ -633,15 +636,15 @@ mxml_file_putc(int ch, /* I - Character to write */
* Four-byte UTF-8 character... * Four-byte UTF-8 character...
*/ */
if (putc(0xf0 | (ch >> 18), (FILE *)p) < 0) *bufptr++ = 0xf0 | (ch >> 18);
return (-1); *bufptr++ = 0x80 | ((ch >> 12) & 0x3f);
else if (putc(0x80 | ((ch >> 12) & 0x3f), (FILE *)p) < 0) *bufptr++ = 0x80 | ((ch >> 6) & 0x3f);
return (-1); *bufptr++ = 0x80 | (ch & 0x3f);
else if (putc(0x80 | ((ch >> 6) & 0x3f), (FILE *)p) < 0)
return (-1);
else
return (putc(0x80 | (ch & 0x3f), (FILE *)p));
} }
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 */ width; /* Width of attr + value */
mxml_attr_t *attr; /* Current attribute */ mxml_attr_t *attr; /* Current attribute */
char s[255]; /* Temporary string */ char s[255]; /* Temporary string */
int slen; /* Length of temporary string */
while (node != NULL) while (node != NULL)
@ -1779,11 +1783,11 @@ mxml_write_node(mxml_node_t *node, /* I - Node to write */
col ++; 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) if (mxml_write_string(s, p, putc_cb) < 0)
return (-1); return (-1);
col += strlen(s); col += slen;
break; break;
case MXML_OPAQUE : case MXML_OPAQUE :
@ -1809,11 +1813,11 @@ mxml_write_node(mxml_node_t *node, /* I - Node to write */
col ++; 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) if (mxml_write_string(s, p, putc_cb) < 0)
return (-1); return (-1);
col += strlen(s); col += slen;
break; break;
case MXML_TEXT : 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. * 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]; do
for (templ = left, tempr = right; templ < tempr;)
{ {
/* /*
* Move left while left node <= pivot node... * Sort the pivot in the current partition...
*/ */
while ((templ < right) && pivot = ind->nodes[left];
index_compare(ind, ind->nodes[templ], pivot) <= 0)
templ ++;
/* for (templ = left, tempr = right; templ < tempr;)
* Move right while right node > pivot node... {
*/ /*
* 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) && while ((tempr > left) &&
index_compare(ind, ind->nodes[tempr], pivot) > 0) index_compare(ind, ind->nodes[tempr], pivot) > 0)
tempr --; 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[left] = ind->nodes[tempr];
ind->nodes[templ] = ind->nodes[tempr]; ind->nodes[tempr] = pivot;
ind->nodes[tempr] = temp;
} }
}
/* /*
* When we get here, the right (tempr) node is the new position for the * Recursively sort the left partition as needed...
* pivot node... */
*/
if (index_compare(ind, pivot, ind->nodes[tempr]) > 0) if (left < (tempr - 1))
{ index_sort(ind, left, tempr - 1);
ind->nodes[left] = ind->nodes[tempr];
ind->nodes[tempr] = pivot;
} }
while (right > (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);
} }
/* /*
* 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. * 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) if (mxml_error_cb)
(*mxml_error_cb)(s); (*mxml_error_cb)(s);
else else
{ fprintf(stderr, "mxml: %s\n", s);
fputs("mxml: ", stderr);
fputs(s, stderr);
putc('\n', stderr);
}
/* /*
* Free the string... * 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. * 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 const char *mxmlElementGetAttr(mxml_node_t *node, const char *name);
extern void mxmlElementSetAttr(mxml_node_t *node, const char *name, extern void mxmlElementSetAttr(mxml_node_t *node, const char *name,
const char *value); 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 const char *mxmlEntityGetName(int val);
extern int mxmlEntityGetValue(const char *name); extern int mxmlEntityGetValue(const char *name);
extern void mxmlEntityRemoveCallback(int (*cb)(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> </argument>
</function> </function>
<function name="mxmlEntityAddCallback"> <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> <description>Add a callback to convert entities to Unicode.</description>
<argument name="(*cb)(const char *name)" direction="I"> <argument name="(*cb)(const char *name)" direction="I">
<type>int</type> <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 * Documentation generator using Mini-XML, a small XML-like file parsing
* library. * 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\" " puts("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"); "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
puts("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>"); "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"
puts("<head>"); "<head>\n"
puts("\t<title>Documentation</title>"); "\t<title>Documentation</title>\n"
puts("\t<meta name='creator' content='" MXML_VERSION "'/>"); "\t<meta name='creator' content='" MXML_VERSION "'/>\n"
puts("\t<style><!--"); "\t<style><!--\n"
puts("\th1, h2, h3, p { font-family: sans-serif; text-align: justify; }"); "\th1, h2, h3, p { font-family: sans-serif; text-align: justify; }\n"
puts("\ttt, pre a:link, pre a:visited, tt a:link, tt a:visited { font-weight: bold; color: #7f0000; }"); "\ttt, pre a:link, pre a:visited, tt a:link, tt a:visited { font-weight: bold; color: #7f0000; }\n"
puts("\tpre { font-weight: bold; color: #7f0000; margin-left: 2em; }"); "\tpre { font-weight: bold; color: #7f0000; margin-left: 2em; }\n"
puts("\t--></style>"); "\t--></style>\n"
puts("</head>"); "</head>\n"
puts("<body>"); "<body>");
/* /*
* Table of contents... * 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)) if (mxmlFindElement(doc, doc, "class", NULL, NULL, MXML_DESCEND_FIRST))
{ {
puts("<!-- NEW PAGE -->"); puts("<!-- NEW PAGE -->\n"
puts("<h2><a name='_classes'>Classes</a></h2>"); "<h2><a name='_classes'>Classes</a></h2>\n"
puts("<ul>"); "<ul>");
for (scut = mxmlFindElement(doc, doc, "class", NULL, NULL, for (scut = mxmlFindElement(doc, doc, "class", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
@ -1844,24 +1843,23 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND)) MXML_NO_DESCEND))
{ {
cname = mxmlElementGetAttr(scut, "name"); cname = mxmlElementGetAttr(scut, "name");
puts("<!-- NEW PAGE -->"); printf("<!-- NEW PAGE -->\n"
printf("<h3><a name='%s'>%s</a></h3>\n", cname, cname); "<h3><a name='%s'>%s</a></h3>\n"
puts("<hr noshade/>"); "<hr noshade/>\n", cname, cname);
description = mxmlFindElement(scut, scut, "description", NULL, description = mxmlFindElement(scut, scut, "description", NULL,
NULL, MXML_DESCEND_FIRST); NULL, MXML_DESCEND_FIRST);
if (description) if (description)
{ {
puts("<h4>Description</h4>"); fputs("<h4>Description</h4>\n"
fputs("<p>", stdout); "<p>", stdout);
write_element(NULL, description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
puts("<h4>Definition</h4>"); printf("<h4>Definition</h4>\n"
puts("<pre>"); "<pre>\n"
"class %s", cname);
printf("class %s", cname);
if ((parent = mxmlElementGetAttr(scut, "parent")) != NULL) if ((parent = mxmlElementGetAttr(scut, "parent")) != NULL)
printf(" %s", parent); printf(" %s", parent);
puts("\n{"); puts("\n{");
@ -1948,14 +1946,12 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
} }
} }
puts("};\n</pre>"); puts("};\n</pre>\n"
"<h4>Members</h4>\n"
puts("<h4>Members</h4>"); "<p class='table'><table align='center' border='1' "
"cellpadding='5' cellspacing='0' width='80%'>\n"
puts("<p class='table'><table align='center' border='1' " "<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>\n"
"cellpadding='5' cellspacing='0' width='80%'>"); "<tbody>");
puts("<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>");
puts("<tbody>");
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
@ -2001,7 +1997,6 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
} }
puts("</tbody></table></p>"); 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)) if (mxmlFindElement(doc, doc, "enumeration", NULL, NULL, MXML_DESCEND_FIRST))
{ {
puts("<!-- NEW PAGE -->"); puts("<!-- NEW PAGE -->\n"
puts("<h2><a name='_enumerations'>Enumerations</a></h2>"); "<h2><a name='_enumerations'>Enumerations</a></h2>\n"
puts("<ul>"); "<ul>");
for (scut = mxmlFindElement(doc, doc, "enumeration", NULL, NULL, for (scut = mxmlFindElement(doc, doc, "enumeration", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
@ -2034,26 +2029,25 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND)) MXML_NO_DESCEND))
{ {
name = mxmlElementGetAttr(scut, "name"); name = mxmlElementGetAttr(scut, "name");
puts("<!-- NEW PAGE -->"); printf("<!-- NEW PAGE -->\n"
printf("<h3><a name='%s'>%s</a></h3>\n", name, name); "<h3><a name='%s'>%s</a></h3>\n"
puts("<hr noshade/>"); "<hr noshade/>\n", name, name);
description = mxmlFindElement(scut, scut, "description", NULL, description = mxmlFindElement(scut, scut, "description", NULL,
NULL, MXML_DESCEND_FIRST); NULL, MXML_DESCEND_FIRST);
if (description) if (description)
{ {
puts("<h4>Description</h4>"); fputs("<h4>Description</h4>\n"
fputs("<p>", stdout); "<p>", stdout);
write_element(NULL, description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
puts("<h4>Values</h4>"); puts("<h4>Values</h4>\n"
"<p class='table'><table align='center' border='1' width='80%' "
puts("<p class='table'><table align='center' border='1' width='80%' " "cellpadding='5' cellspacing='0' width='80%'>\n"
"cellpadding='5' cellspacing='0' width='80%'>"); "<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>\n"
puts("<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>"); "<tbody>");
puts("<tbody>");
for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL, for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL,
MXML_DESCEND_FIRST); 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)) if (mxmlFindElement(doc, doc, "function", NULL, NULL, MXML_DESCEND_FIRST))
{ {
puts("<!-- NEW PAGE -->"); puts("<!-- NEW PAGE -->\n"
puts("<h2><a name='_functions'>Functions</a></h2>"); "<h2><a name='_functions'>Functions</a></h2>\n"
puts("<ul>"); "<ul>");
for (function = mxmlFindElement(doc, doc, "function", NULL, NULL, for (function = mxmlFindElement(doc, doc, "function", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
@ -2102,22 +2096,22 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND)) MXML_NO_DESCEND))
{ {
name = mxmlElementGetAttr(function, "name"); name = mxmlElementGetAttr(function, "name");
puts("<!-- NEW PAGE -->"); printf("<!-- NEW PAGE -->\n"
printf("<h3><a name='%s'>%s()</a></h3>\n", name, name); "<h3><a name='%s'>%s()</a></h3>\n"
puts("<hr noshade/>"); "<hr noshade/>\n", name, name);
description = mxmlFindElement(function, function, "description", NULL, description = mxmlFindElement(function, function, "description", NULL,
NULL, MXML_DESCEND_FIRST); NULL, MXML_DESCEND_FIRST);
if (description) if (description)
{ {
puts("<h4>Description</h4>"); fputs("<h4>Description</h4>\n"
fputs("<p>", stdout); "<p>", stdout);
write_element(NULL, description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
puts("<h4>Syntax</h4>"); puts("<h4>Syntax</h4>\n"
puts("<pre>"); "<pre>");
arg = mxmlFindElement(function, function, "returnvalue", NULL, arg = mxmlFindElement(function, function, "returnvalue", NULL,
NULL, MXML_DESCEND_FIRST); NULL, MXML_DESCEND_FIRST);
@ -2161,9 +2155,9 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
else else
{ {
puts("<p class='table'><table align='center' border='1' width='80%' " puts("<p class='table'><table align='center' border='1' width='80%' "
"cellpadding='5' cellspacing='0' width='80%'>"); "cellpadding='5' cellspacing='0' width='80%'>\n"
puts("<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>"); "<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>\n"
puts("<tbody>"); "<tbody>");
for (arg = mxmlFindElement(function, function, "argument", NULL, NULL, for (arg = mxmlFindElement(function, function, "argument", NULL, NULL,
MXML_DESCEND_FIRST); 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)) if (mxmlFindElement(doc, doc, "struct", NULL, NULL, MXML_DESCEND_FIRST))
{ {
puts("<!-- NEW PAGE -->"); puts("<!-- NEW PAGE -->\n"
puts("<h2><a name='_structures'>Structures</a></h2>"); "<h2><a name='_structures'>Structures</a></h2>\n"
puts("<ul>"); "<ul>");
for (scut = mxmlFindElement(doc, doc, "struct", NULL, NULL, for (scut = mxmlFindElement(doc, doc, "struct", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
@ -2228,24 +2222,23 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND)) MXML_NO_DESCEND))
{ {
cname = mxmlElementGetAttr(scut, "name"); cname = mxmlElementGetAttr(scut, "name");
puts("<!-- NEW PAGE -->"); printf("<!-- NEW PAGE -->\n"
printf("<h3><a name='%s'>%s</a></h3>\n", cname, cname); "<h3><a name='%s'>%s</a></h3>\n"
puts("<hr noshade/>"); "<hr noshade/>\n", cname, cname);
description = mxmlFindElement(scut, scut, "description", NULL, description = mxmlFindElement(scut, scut, "description", NULL,
NULL, MXML_DESCEND_FIRST); NULL, MXML_DESCEND_FIRST);
if (description) if (description)
{ {
puts("<h4>Description</h4>"); fputs("<h4>Description</h4>\n"
fputs("<p>", stdout); "<p>", stdout);
write_element(NULL, description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
puts("<h4>Definition</h4>"); printf("<h4>Definition</h4>\n"
puts("<pre>"); "<pre>\n"
"struct %s\n{\n", cname);
printf("struct %s\n{\n", cname);
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
arg; arg;
@ -2311,14 +2304,12 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
puts(");"); puts(");");
} }
puts("};\n</pre>"); puts("};\n</pre>\n"
"<h4>Members</h4>\n"
puts("<h4>Members</h4>"); "<p class='table'><table align='center' border='1' width='80%' "
"cellpadding='5' cellspacing='0' width='80%'>\n"
puts("<p class='table'><table align='center' border='1' width='80%' " "<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>\n"
"cellpadding='5' cellspacing='0' width='80%'>"); "<tbody>");
puts("<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>");
puts("<tbody>");
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST); 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)) if (mxmlFindElement(doc, doc, "typedef", NULL, NULL, MXML_DESCEND_FIRST))
{ {
puts("<!-- NEW PAGE -->"); puts("<!-- NEW PAGE -->\n"
puts("<h2><a name='_types'>Types</a></h2>"); "<h2><a name='_types'>Types</a></h2>\n"
puts("<ul>"); "<ul>");
for (scut = mxmlFindElement(doc, doc, "typedef", NULL, NULL, for (scut = mxmlFindElement(doc, doc, "typedef", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
@ -2396,24 +2387,23 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND)) MXML_NO_DESCEND))
{ {
name = mxmlElementGetAttr(scut, "name"); name = mxmlElementGetAttr(scut, "name");
puts("<!-- NEW PAGE -->"); printf("<!-- NEW PAGE -->\n"
printf("<h3><a name='%s'>%s</a></h3>\n", name, name); "<h3><a name='%s'>%s</a></h3>\n"
puts("<hr noshade/>"); "<hr noshade/>\n", name, name);
description = mxmlFindElement(scut, scut, "description", NULL, description = mxmlFindElement(scut, scut, "description", NULL,
NULL, MXML_DESCEND_FIRST); NULL, MXML_DESCEND_FIRST);
if (description) if (description)
{ {
puts("<h4>Description</h4>"); fputs("<h4>Description</h4>\n"
fputs("<p>", stdout); "<p>", stdout);
write_element(NULL, description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
puts("<h4>Definition</h4>"); fputs("<h4>Definition</h4>\n"
puts("<pre>"); "<pre>\n"
"typedef ", stdout);
printf("typedef ");
write_element(doc, mxmlFindElement(scut, scut, "type", NULL, write_element(doc, mxmlFindElement(scut, scut, "type", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
printf(" %s;\n</pre>\n", name); 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)) if (mxmlFindElement(doc, doc, "union", NULL, NULL, MXML_DESCEND_FIRST))
{ {
puts("<!-- NEW PAGE -->"); puts("<!-- NEW PAGE -->\n"
puts("<h2><a name='_unions'>Unions</a></h2>"); "<h2><a name='_unions'>Unions</a></h2>\n"
puts("<ul>"); "<ul>");
for (scut = mxmlFindElement(doc, doc, "union", NULL, NULL, for (scut = mxmlFindElement(doc, doc, "union", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
@ -2449,24 +2439,23 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND)) MXML_NO_DESCEND))
{ {
name = mxmlElementGetAttr(scut, "name"); name = mxmlElementGetAttr(scut, "name");
puts("<!-- NEW PAGE -->"); printf("<!-- NEW PAGE -->\n"
printf("<h3><a name='%s'>%s</a></h3>\n", name, name); "<h3><a name='%s'>%s</a></h3>\n"
puts("<hr noshade/>"); "<hr noshade/>\n", name, name);
description = mxmlFindElement(scut, scut, "description", NULL, description = mxmlFindElement(scut, scut, "description", NULL,
NULL, MXML_DESCEND_FIRST); NULL, MXML_DESCEND_FIRST);
if (description) if (description)
{ {
puts("<h4>Description</h4>"); fputs("<h4>Description</h4>\n"
fputs("<p>", stdout); "<p>", stdout);
write_element(NULL, description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
puts("<h4>Definition</h4>"); printf("<h4>Definition</h4>\n"
puts("<pre>"); "<pre>\n"
"union %s\n{\n", name);
printf("union %s\n{\n", name);
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
arg; arg;
@ -2479,14 +2468,12 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
printf(" %s;\n", mxmlElementGetAttr(arg, "name")); printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
} }
puts("};\n</pre>"); puts("};\n</pre>\n"
"<h4>Members</h4>\n"
puts("<h4>Members</h4>"); "<p class='table'><table align='center' border='1' width='80%' "
"cellpadding='5' cellspacing='0' width='80%'>\n"
puts("<p class='table'><table align='center' border='1' width='80%' " "<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>\n"
"cellpadding='5' cellspacing='0' width='80%'>"); "<tbody>");
puts("<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>");
puts("<tbody>");
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST); 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)) if (mxmlFindElement(doc, doc, "variable", NULL, NULL, MXML_DESCEND_FIRST))
{ {
puts("<!-- NEW PAGE -->"); puts("<!-- NEW PAGE -->\n"
puts("<h2><a name='_variables'>Variables</a></h2>"); "<h2><a name='_variables'>Variables</a></h2>\n"
puts("<ul>"); "<ul>");
for (arg = mxmlFindElement(doc, doc, "variable", NULL, NULL, for (arg = mxmlFindElement(doc, doc, "variable", NULL, NULL,
MXML_DESCEND_FIRST); MXML_DESCEND_FIRST);
@ -2535,22 +2522,22 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND)) MXML_NO_DESCEND))
{ {
name = mxmlElementGetAttr(arg, "name"); name = mxmlElementGetAttr(arg, "name");
puts("<!-- NEW PAGE -->"); printf("<!-- NEW PAGE -->\n"
printf("<h3><a name='%s'>%s</a></h3>\n", name, name); "<h3><a name='%s'>%s</a></h3>\n"
puts("<hr noshade/>"); "<hr noshade/>", name, name);
description = mxmlFindElement(arg, arg, "description", NULL, description = mxmlFindElement(arg, arg, "description", NULL,
NULL, MXML_DESCEND_FIRST); NULL, MXML_DESCEND_FIRST);
if (description) if (description)
{ {
puts("<h4>Description</h4>"); fputs("<h4>Description</h4>\n"
fputs("<p>", stdout); "<p>", stdout);
write_element(NULL, description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
puts("<h4>Definition</h4>"); puts("<h4>Definition</h4>\n"
puts("<pre>"); "<pre>");
write_element(doc, mxmlFindElement(arg, arg, "type", NULL, write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
@ -2565,8 +2552,8 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
* Standard footer... * Standard footer...
*/ */
puts("</body>"); puts("</body>\n"
puts("</html>"); "</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