Fix some more documentation generator bugs.

Add detailed docos to the file.
This commit is contained in:
Michael R Sweet 2003-06-14 23:56:47 +00:00
parent 0cc4b9e665
commit bcc99b153a
8 changed files with 923 additions and 543 deletions

View File

@ -11,23 +11,19 @@
<body> <body>
<h1>Contents</h1> <h1>Contents</h1>
<ul> <ul>
<li><a href="#_classes">Classes</a></li>
<li><a href="#_enumerations">Enumeration</a></li> <li><a href="#_enumerations">Enumeration</a></li>
<li><a href="#_functions">Functions</a></li> <li><a href="#_functions">Functions</a></li>
<li><a href="#_structures">Structures</a></li> <li><a href="#_structures">Structures</a></li>
<li><a href="#_types">Types</a></li> <li><a href="#_types">Types</a></li>
<li><a href="#_unions">Unions</a></li> <li><a href="#_unions">Unions</a></li>
</ul> </ul>
<h1><a name="_classes">Classes</a></h1>
<ul>
</ul>
<h1><a name="_enumerations">Enumerations</a></h1> <h1><a name="_enumerations">Enumerations</a></h1>
<ul> <ul>
<li><a href="#mxml_type_e"><tt>mxml_type_e</tt></a></li> <li><a href="#mxml_type_e"><tt>mxml_type_e</tt></a></li>
</ul> </ul>
<hr noshade/> <hr noshade/>
<h2><a name="mxml_type_e">mxml_type_e</a></h2> <h2><a name="mxml_type_e">mxml_type_e</a></h2>
<p>Node Type</p> <p>The XML node type.</p>
<h3>Values</h3> <h3>Values</h3>
<p class="table"><table align="center" border="1" width="80%"> <p class="table"><table align="center" border="1" width="80%">
<thead><tr><th>Name</th><th>Description</th></tr></thead> <thead><tr><th>Name</th><th>Description</th></tr></thead>
@ -58,52 +54,65 @@
</ul> </ul>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlAdd">mxmlAdd()</a></h2> <h2><a name="mxmlAdd">mxmlAdd()</a></h2>
<p>Add a node to a tree.</p> <p>Add a node to a tree.
Adds the specified node to the parent. If the child argument is not
NULL, puts the new node before or after the specified child depending
on the value of the where argument. If the child argument is NULL,
puts the new node at the beginning of the child list (MXML_ADD_BEFORE)
or at the end of the child list (MXML_ADD_AFTER). The constant
MXML_ADD_TO_PARENT can be used to specify a NULL child pointer.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
void void
mxmlAdd( mxmlAdd(
mxml_node_t * parent, <a href="#mxml_node_t">mxml_node_t</a> * parent,
int where, int where,
mxml_node_t * child, <a href="#mxml_node_t">mxml_node_t</a> * child,
mxml_node_t * node); <a href="#mxml_node_t">mxml_node_t</a> * node);
</pre> </pre>
<h3>Arguments</h3> <h3>Arguments</h3>
<p class="table"><table align="center" border="1" width="80%"> <p class="table"><table align="center" border="1" width="80%">
<thead><tr><th>Name</th><th>Description</th></tr></thead> <thead><tr><th>Name</th><th>Description</th></tr></thead>
<tbody> <tbody>
<tr><td><tt>parent</tt></td><td>Parent node</td></tr> <tr><td><tt>parent</tt></td><td>Parent node</td></tr>
<tr><td><tt>where</tt></td><td>Where to add</td></tr> <tr><td><tt>where</tt></td><td>Where to add, MXML_ADD_BEFORE or MXML_ADD_AFTER</td></tr>
<tr><td><tt>child</tt></td><td>Child node for where</td></tr> <tr><td><tt>child</tt></td><td>Child node for where or MXML_ADD_TO_PARENT</td></tr>
<tr><td><tt>node</tt></td><td>Node to add</td></tr> <tr><td><tt>node</tt></td><td>Node to add</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>Nothing.</p> <p>Nothing.</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlDelete">mxmlDelete()</a></h2> <h2><a name="mxmlDelete">mxmlDelete()</a></h2>
<p>Delete a node and all of its children.</p> <p>Delete a node and all of its children.
If the specified node has a parent, this function first removes the
node from its parent using the mxmlRemove() function.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
void void
mxmlDelete( mxmlDelete(
mxml_node_t * node); <a href="#mxml_node_t">mxml_node_t</a> * node);
</pre> </pre>
<h3>Arguments</h3> <h3>Arguments</h3>
<p class="table"><table align="center" border="1" width="80%"> <p class="table"><table align="center" border="1" width="80%">
<thead><tr><th>Name</th><th>Description</th></tr></thead> <thead><tr><th>Name</th><th>Description</th></tr></thead>
<tbody> <tbody>
<tr><td><tt>node</tt></td><td>Node</td></tr> <tr><td><tt>node</tt></td><td>Node to delete</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>Nothing.</p> <p>Nothing.</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlElementGetAttr">mxmlElementGetAttr()</a></h2> <h2><a name="mxmlElementGetAttr">mxmlElementGetAttr()</a></h2>
<p>Get an attribute.</p> <p>Get an attribute.
This function returns NULL if the node is not an element or the
named attribute does not exist.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
const char * const char *
mxmlElementGetAttr( mxmlElementGetAttr(
mxml_node_t * node, <a href="#mxml_node_t">mxml_node_t</a> * node,
const char * name); const char * name);
</pre> </pre>
<h3>Arguments</h3> <h3>Arguments</h3>
@ -117,12 +126,17 @@ mxmlElementGetAttr(
<p>Attribute value or NULL</p> <p>Attribute value or NULL</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlElementSetAttr">mxmlElementSetAttr()</a></h2> <h2><a name="mxmlElementSetAttr">mxmlElementSetAttr()</a></h2>
<p>Set an attribute.</p> <p>Set an attribute.
If the named attribute already exists, the value of the attribute
is replaced by the new string value. The string value is copied
into the element node. This function does nothing if the node is
not an element.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
void void
mxmlElementSetAttr( mxmlElementSetAttr(
mxml_node_t * node, <a href="#mxml_node_t">mxml_node_t</a> * node,
const char * name, const char * name,
const char * value); const char * value);
</pre> </pre>
@ -138,13 +152,22 @@ mxmlElementSetAttr(
<p>Nothing.</p> <p>Nothing.</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlFindElement">mxmlFindElement()</a></h2> <h2><a name="mxmlFindElement">mxmlFindElement()</a></h2>
<p>Find the named element.</p> <p>Find the named element.
The search is constrained by the name, attribute name, and value; any
NULL names or values are treated as wildcards, so different kinds of
searches can be implemented by looking for all elements of a given name
or all elements with a specific attribute. The descend argument determines
whether the search descends into child nodes; normally you will use
MXML_DESCEND_FIRST for the initial search and MXML_NO_DESCEND to find
additional direct descendents of the node. The top node argument
constrains the search to a particular node's children.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
mxml_node_t * <a href="#mxml_node_t">mxml_node_t</a> *
mxmlFindElement( mxmlFindElement(
mxml_node_t * node, <a href="#mxml_node_t">mxml_node_t</a> * node,
mxml_node_t * top, <a href="#mxml_node_t">mxml_node_t</a> * top,
const char * name, const char * name,
const char * attr, const char * attr,
const char * value, const char * value,
@ -159,20 +182,27 @@ mxmlFindElement(
<tr><td><tt>name</tt></td><td>Element name or NULL for any</td></tr> <tr><td><tt>name</tt></td><td>Element name or NULL for any</td></tr>
<tr><td><tt>attr</tt></td><td>Attribute name, or NULL for none</td></tr> <tr><td><tt>attr</tt></td><td>Attribute name, or NULL for none</td></tr>
<tr><td><tt>value</tt></td><td>Attribute value, or NULL for any</td></tr> <tr><td><tt>value</tt></td><td>Attribute value, or NULL for any</td></tr>
<tr><td><tt>descend</tt></td><td>Descend into tree?</td></tr> <tr><td><tt>descend</tt></td><td>Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>Element node or NULL</p> <p>Element node or NULL</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlLoadFile">mxmlLoadFile()</a></h2> <h2><a name="mxmlLoadFile">mxmlLoadFile()</a></h2>
<p>Load a file into an XML node tree.</p> <p>Load a file into an XML node tree.
The nodes in the specified file are added to the specified top node.
If no top node is provided, the XML file MUST be well-formed with a
single parent node like &lt;?xml&gt; for the entire file. The callback
function returns the value type that should be used for child nodes.
If MXML_NO_CALLBACK is specified then all child nodes will be either
MXML_ELEMENT or MXML_TEXT nodes.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
mxml_node_t * <a href="#mxml_node_t">mxml_node_t</a> *
mxmlLoadFile( mxmlLoadFile(
mxml_node_t * top, <a href="#mxml_node_t">mxml_node_t</a> * top,
FILE * fp, FILE * fp,
mxml_type_t (*cb)(mxml_node_t *)); <a href="#mxml_type_t">mxml_type_t</a> (*cb)(mxml_node_t *));
</pre> </pre>
<h3>Arguments</h3> <h3>Arguments</h3>
<p class="table"><table align="center" border="1" width="80%"> <p class="table"><table align="center" border="1" width="80%">
@ -180,94 +210,117 @@ mxmlLoadFile(
<tbody> <tbody>
<tr><td><tt>top</tt></td><td>Top node</td></tr> <tr><td><tt>top</tt></td><td>Top node</td></tr>
<tr><td><tt>fp</tt></td><td>File to read from</td></tr> <tr><td><tt>fp</tt></td><td>File to read from</td></tr>
<tr><td><tt>(*cb)(mxml_node_t *)</tt></td><td>Callback function</td></tr> <tr><td><tt>(*cb)(mxml_node_t *)</tt></td><td>Callback function or MXML_NO_CALLBACK</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>First node</p> <p>First node or NULL if the file could not be read.</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlNewElement">mxmlNewElement()</a></h2> <h2><a name="mxmlNewElement">mxmlNewElement()</a></h2>
<p>Create a new element node.</p> <p>Create a new element node.
The new element node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
element node has no parent.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
mxml_node_t * <a href="#mxml_node_t">mxml_node_t</a> *
mxmlNewElement( mxmlNewElement(
mxml_node_t * parent, <a href="#mxml_node_t">mxml_node_t</a> * parent,
const char * name); const char * name);
</pre> </pre>
<h3>Arguments</h3> <h3>Arguments</h3>
<p class="table"><table align="center" border="1" width="80%"> <p class="table"><table align="center" border="1" width="80%">
<thead><tr><th>Name</th><th>Description</th></tr></thead> <thead><tr><th>Name</th><th>Description</th></tr></thead>
<tbody> <tbody>
<tr><td><tt>parent</tt></td><td>Parent node</td></tr> <tr><td><tt>parent</tt></td><td>Parent node or MXML_NO_PARENT</td></tr>
<tr><td><tt>name</tt></td><td>Name of element</td></tr> <tr><td><tt>name</tt></td><td>Name of element</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>New node</p> <p>New node</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlNewInteger">mxmlNewInteger()</a></h2> <h2><a name="mxmlNewInteger">mxmlNewInteger()</a></h2>
<p>Create a new integer node.</p> <p>Create a new integer node.
The new integer node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
integer node has no parent.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
mxml_node_t * <a href="#mxml_node_t">mxml_node_t</a> *
mxmlNewInteger( mxmlNewInteger(
mxml_node_t * parent, <a href="#mxml_node_t">mxml_node_t</a> * parent,
int integer); int integer);
</pre> </pre>
<h3>Arguments</h3> <h3>Arguments</h3>
<p class="table"><table align="center" border="1" width="80%"> <p class="table"><table align="center" border="1" width="80%">
<thead><tr><th>Name</th><th>Description</th></tr></thead> <thead><tr><th>Name</th><th>Description</th></tr></thead>
<tbody> <tbody>
<tr><td><tt>parent</tt></td><td>Parent node</td></tr> <tr><td><tt>parent</tt></td><td>Parent node or MXML_NO_PARENT</td></tr>
<tr><td><tt>integer</tt></td><td>Integer value</td></tr> <tr><td><tt>integer</tt></td><td>Integer value</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>New node</p> <p>New node</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlNewOpaque">mxmlNewOpaque()</a></h2> <h2><a name="mxmlNewOpaque">mxmlNewOpaque()</a></h2>
<p>Create a new opaque string.</p> <p>Create a new opaque string.
The new opaque node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
opaque node has no parent. The opaque string must be nul-terminated and
is copied into the new node.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
mxml_node_t * <a href="#mxml_node_t">mxml_node_t</a> *
mxmlNewOpaque( mxmlNewOpaque(
mxml_node_t * parent, <a href="#mxml_node_t">mxml_node_t</a> * parent,
const char * opaque); const char * opaque);
</pre> </pre>
<h3>Arguments</h3> <h3>Arguments</h3>
<p class="table"><table align="center" border="1" width="80%"> <p class="table"><table align="center" border="1" width="80%">
<thead><tr><th>Name</th><th>Description</th></tr></thead> <thead><tr><th>Name</th><th>Description</th></tr></thead>
<tbody> <tbody>
<tr><td><tt>parent</tt></td><td>Parent node</td></tr> <tr><td><tt>parent</tt></td><td>Parent node or MXML_NO_PARENT</td></tr>
<tr><td><tt>opaque</tt></td><td>Opaque string</td></tr> <tr><td><tt>opaque</tt></td><td>Opaque string</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>New node</p> <p>New node</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlNewReal">mxmlNewReal()</a></h2> <h2><a name="mxmlNewReal">mxmlNewReal()</a></h2>
<p>Create a new real number node.</p> <p>Create a new real number node.
The new real number node is added to the end of the specified parent's
child list. The constant MXML_NO_PARENT can be used to specify that
the new real number node has no parent.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
mxml_node_t * <a href="#mxml_node_t">mxml_node_t</a> *
mxmlNewReal( mxmlNewReal(
mxml_node_t * parent, <a href="#mxml_node_t">mxml_node_t</a> * parent,
double real); double real);
</pre> </pre>
<h3>Arguments</h3> <h3>Arguments</h3>
<p class="table"><table align="center" border="1" width="80%"> <p class="table"><table align="center" border="1" width="80%">
<thead><tr><th>Name</th><th>Description</th></tr></thead> <thead><tr><th>Name</th><th>Description</th></tr></thead>
<tbody> <tbody>
<tr><td><tt>parent</tt></td><td>Parent node</td></tr> <tr><td><tt>parent</tt></td><td>Parent node or MXML_NO_PARENT</td></tr>
<tr><td><tt>real</tt></td><td>Real number value</td></tr> <tr><td><tt>real</tt></td><td>Real number value</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>New node</p> <p>New node</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlNewText">mxmlNewText()</a></h2> <h2><a name="mxmlNewText">mxmlNewText()</a></h2>
<p>Create a new text fragment node.</p> <p>Create a new text fragment node.
The new text node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
text node has no parent. The whitespace parameter is used to specify
whether leading whitespace is present before the node. The text
string must be nul-terminated and is copied into the new node.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
mxml_node_t * <a href="#mxml_node_t">mxml_node_t</a> *
mxmlNewText( mxmlNewText(
mxml_node_t * parent, <a href="#mxml_node_t">mxml_node_t</a> * parent,
int whitespace, int whitespace,
const char * string); const char * string);
</pre> </pre>
@ -275,20 +328,23 @@ mxmlNewText(
<p class="table"><table align="center" border="1" width="80%"> <p class="table"><table align="center" border="1" width="80%">
<thead><tr><th>Name</th><th>Description</th></tr></thead> <thead><tr><th>Name</th><th>Description</th></tr></thead>
<tbody> <tbody>
<tr><td><tt>parent</tt></td><td>Parent node</td></tr> <tr><td><tt>parent</tt></td><td>Parent node or MXML_NO_PARENT</td></tr>
<tr><td><tt>whitespace</tt></td><td>Leading whitespace?</td></tr> <tr><td><tt>whitespace</tt></td><td>1 = leading whitespace, 0 = no whitespace</td></tr>
<tr><td><tt>string</tt></td><td>String</td></tr> <tr><td><tt>string</tt></td><td>String</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>New node</p> <p>New node</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlRemove">mxmlRemove()</a></h2> <h2><a name="mxmlRemove">mxmlRemove()</a></h2>
<p>Remove a node from its parent.</p> <p>Remove a node from its parent.
Does not free memory used by the node - use mxmlDelete() for that.
This function does nothing if the node has no parent.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
void void
mxmlRemove( mxmlRemove(
mxml_node_t * node); <a href="#mxml_node_t">mxml_node_t</a> * node);
</pre> </pre>
<h3>Arguments</h3> <h3>Arguments</h3>
<p class="table"><table align="center" border="1" width="80%"> <p class="table"><table align="center" border="1" width="80%">
@ -300,12 +356,18 @@ mxmlRemove(
<p>Nothing.</p> <p>Nothing.</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlSaveFile">mxmlSaveFile()</a></h2> <h2><a name="mxmlSaveFile">mxmlSaveFile()</a></h2>
<p>Save an XML tree to a file.</p> <p>Save an XML tree to a file.
The callback argument specifies a function that returns a whitespace
character or nul (0) before and after each element. If MXML_NO_CALLBACK
is specified, whitespace will only be added before MXML_TEXT nodes
with leading whitespace and before attribute names inside opening
element tags.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
int int
mxmlSaveFile( mxmlSaveFile(
mxml_node_t * node, <a href="#mxml_node_t">mxml_node_t</a> * node,
FILE * fp, FILE * fp,
int (*cb)(mxml_node_t *int)); int (*cb)(mxml_node_t *int));
</pre> </pre>
@ -315,19 +377,23 @@ mxmlSaveFile(
<tbody> <tbody>
<tr><td><tt>node</tt></td><td>Node to write</td></tr> <tr><td><tt>node</tt></td><td>Node to write</td></tr>
<tr><td><tt>fp</tt></td><td>File to write to</td></tr> <tr><td><tt>fp</tt></td><td>File to write to</td></tr>
<tr><td><tt>(*cb)(mxml_node_t *int)</tt></td><td>Whitespace callback</td></tr> <tr><td><tt>(*cb)(mxml_node_t *int)</tt></td><td>Whitespace callback or MXML_NO_CALLBACK</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>0 on success, -1 on error</p> <p>0 on success, -1 on error.</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlWalkNext">mxmlWalkNext()</a></h2> <h2><a name="mxmlWalkNext">mxmlWalkNext()</a></h2>
<p>Walk to the next logical node in the tree.</p> <p>Walk to the next logical node in the tree.
The descend argument controls whether the first child is considered
to be the next node. The top node argument constrains the walk to
the node's children.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
mxml_node_t * <a href="#mxml_node_t">mxml_node_t</a> *
mxmlWalkNext( mxmlWalkNext(
mxml_node_t * node, <a href="#mxml_node_t">mxml_node_t</a> * node,
mxml_node_t * top, <a href="#mxml_node_t">mxml_node_t</a> * top,
int descend); int descend);
</pre> </pre>
<h3>Arguments</h3> <h3>Arguments</h3>
@ -336,19 +402,23 @@ mxmlWalkNext(
<tbody> <tbody>
<tr><td><tt>node</tt></td><td>Current node</td></tr> <tr><td><tt>node</tt></td><td>Current node</td></tr>
<tr><td><tt>top</tt></td><td>Top node</td></tr> <tr><td><tt>top</tt></td><td>Top node</td></tr>
<tr><td><tt>descend</tt></td><td>Descend into tree?</td></tr> <tr><td><tt>descend</tt></td><td>Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>Next node or NULL</p> <p>Next node or NULL</p>
<hr noshade/> <hr noshade/>
<h2><a name="mxmlWalkPrev">mxmlWalkPrev()</a></h2> <h2><a name="mxmlWalkPrev">mxmlWalkPrev()</a></h2>
<p>Walk to the previous logical node in the tree.</p> <p>Walk to the previous logical node in the tree.
The descend argument controls whether the previous node's last child
is considered to be the previous node. The top node argument constrains
the walk to the node's children.</p>
<h3>Syntax</h3> <h3>Syntax</h3>
<pre> <pre>
mxml_node_t * <a href="#mxml_node_t">mxml_node_t</a> *
mxmlWalkPrev( mxmlWalkPrev(
mxml_node_t * node, <a href="#mxml_node_t">mxml_node_t</a> * node,
mxml_node_t * top, <a href="#mxml_node_t">mxml_node_t</a> * top,
int descend); int descend);
</pre> </pre>
<h3>Arguments</h3> <h3>Arguments</h3>
@ -357,7 +427,7 @@ mxmlWalkPrev(
<tbody> <tbody>
<tr><td><tt>node</tt></td><td>Current node</td></tr> <tr><td><tt>node</tt></td><td>Current node</td></tr>
<tr><td><tt>top</tt></td><td>Top node</td></tr> <tr><td><tt>top</tt></td><td>Top node</td></tr>
<tr><td><tt>descend</tt></td><td>Descend into tree?</td></tr> <tr><td><tt>descend</tt></td><td>Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST</td></tr>
</tbody></table></p> </tbody></table></p>
<h3>Returns</h3> <h3>Returns</h3>
<p>Previous node or NULL</p> <p>Previous node or NULL</p>
@ -370,7 +440,7 @@ mxmlWalkPrev(
</ul> </ul>
<hr noshade/> <hr noshade/>
<h2><a name="mxml_attr_s">mxml_attr_s</a></h2> <h2><a name="mxml_attr_s">mxml_attr_s</a></h2>
<p>Attribute Value</p> <p>An XML element attribute value.</p>
<h3>Definition</h3> <h3>Definition</h3>
<pre> <pre>
struct mxml_attr_s struct mxml_attr_s
@ -388,18 +458,18 @@ struct mxml_attr_s
</tbody></table></p> </tbody></table></p>
<hr noshade/> <hr noshade/>
<h2><a name="mxml_node_s">mxml_node_s</a></h2> <h2><a name="mxml_node_s">mxml_node_s</a></h2>
<p>Node</p> <p>Data types...</p>
<h3>Definition</h3> <h3>Definition</h3>
<pre> <pre>
struct mxml_node_s struct mxml_node_s
{ {
mxml_node_t * child; <a href="#mxml_node_t">mxml_node_t</a> * child;
mxml_node_t * last_child; <a href="#mxml_node_t">mxml_node_t</a> * last_child;
mxml_node_t * next; <a href="#mxml_node_t">mxml_node_t</a> * next;
mxml_node_t * parent; <a href="#mxml_node_t">mxml_node_t</a> * parent;
mxml_node_t * prev; <a href="#mxml_node_t">mxml_node_t</a> * prev;
mxml_type_t type; <a href="#mxml_type_t">mxml_type_t</a> type;
mxml_value_t value; <a href="#mxml_value_t">mxml_value_t</a> value;
}; };
</pre> </pre>
<h3>Members</h3> <h3>Members</h3>
@ -416,7 +486,7 @@ struct mxml_node_s
</tbody></table></p> </tbody></table></p>
<hr noshade/> <hr noshade/>
<h2><a name="mxml_text_s">mxml_text_s</a></h2> <h2><a name="mxml_text_s">mxml_text_s</a></h2>
<p>Text Value</p> <p>An XML text value.</p>
<h3>Definition</h3> <h3>Definition</h3>
<pre> <pre>
struct mxml_text_s struct mxml_text_s
@ -434,12 +504,12 @@ struct mxml_text_s
</tbody></table></p> </tbody></table></p>
<hr noshade/> <hr noshade/>
<h2><a name="mxml_value_s">mxml_value_s</a></h2> <h2><a name="mxml_value_s">mxml_value_s</a></h2>
<p>Element Value</p> <p>An XML element value.</p>
<h3>Definition</h3> <h3>Definition</h3>
<pre> <pre>
struct mxml_value_s struct mxml_value_s
{ {
mxml_attr_t * attrs; <a href="#mxml_attr_t">mxml_attr_t</a> * attrs;
char * name; char * name;
int num_attrs; int num_attrs;
}; };
@ -456,44 +526,52 @@ struct mxml_value_s
<ul> <ul>
<li><a href="#mxml_attr_t"><tt>mxml_attr_t</tt></a></li> <li><a href="#mxml_attr_t"><tt>mxml_attr_t</tt></a></li>
<li><a href="#mxml_element_t"><tt>mxml_element_t</tt></a></li> <li><a href="#mxml_element_t"><tt>mxml_element_t</tt></a></li>
<li><a href="#mxml_node_t"><tt>mxml_node_t</tt></a></li>
<li><a href="#mxml_text_t"><tt>mxml_text_t</tt></a></li> <li><a href="#mxml_text_t"><tt>mxml_text_t</tt></a></li>
<li><a href="#mxml_type_t"><tt>mxml_type_t</tt></a></li> <li><a href="#mxml_type_t"><tt>mxml_type_t</tt></a></li>
<li><a href="#mxml_value_t"><tt>mxml_value_t</tt></a></li> <li><a href="#mxml_value_t"><tt>mxml_value_t</tt></a></li>
</ul> </ul>
<hr noshade/> <hr noshade/>
<h2><a name="mxml_attr_t">mxml_attr_t</a></h2> <h2><a name="mxml_attr_t">mxml_attr_t</a></h2>
<p>Attribute Value</p> <p>An XML element attribute value.</p>
<h3>Definition</h3> <h3>Definition</h3>
<pre> <pre>
typedef struct mxml_attr_s mxml_attr_t; typedef struct <a href="#mxml_attr_s">mxml_attr_s</a> mxml_attr_t;
</pre> </pre>
<hr noshade/> <hr noshade/>
<h2><a name="mxml_element_t">mxml_element_t</a></h2> <h2><a name="mxml_element_t">mxml_element_t</a></h2>
<p>Element Value</p> <p>An XML element value.</p>
<h3>Definition</h3> <h3>Definition</h3>
<pre> <pre>
typedef struct mxml_value_s mxml_element_t; typedef struct <a href="#mxml_value_s">mxml_value_s</a> mxml_element_t;
</pre>
<hr noshade/>
<h2><a name="mxml_node_t">mxml_node_t</a></h2>
<p>An XML node.</p>
<h3>Definition</h3>
<pre>
typedef struct <a href="#mxml_node_s">mxml_node_s</a> mxml_node_t;
</pre> </pre>
<hr noshade/> <hr noshade/>
<h2><a name="mxml_text_t">mxml_text_t</a></h2> <h2><a name="mxml_text_t">mxml_text_t</a></h2>
<p>Text Value</p> <p>An XML text value.</p>
<h3>Definition</h3> <h3>Definition</h3>
<pre> <pre>
typedef struct mxml_text_s mxml_text_t; typedef struct <a href="#mxml_text_s">mxml_text_s</a> mxml_text_t;
</pre> </pre>
<hr noshade/> <hr noshade/>
<h2><a name="mxml_type_t">mxml_type_t</a></h2> <h2><a name="mxml_type_t">mxml_type_t</a></h2>
<p>Node Type</p> <p>The XML node type.</p>
<h3>Definition</h3> <h3>Definition</h3>
<pre> <pre>
typedef enum mxml_type_e mxml_type_t; typedef enum <a href="#mxml_type_e">mxml_type_e</a> mxml_type_t;
</pre> </pre>
<hr noshade/> <hr noshade/>
<h2><a name="mxml_value_t">mxml_value_t</a></h2> <h2><a name="mxml_value_t">mxml_value_t</a></h2>
<p>Node Value</p> <p>An XML node value.</p>
<h3>Definition</h3> <h3>Definition</h3>
<pre> <pre>
typedef union mxml_value_u mxml_value_t; typedef union <a href="#mxml_value_u">mxml_value_u</a> mxml_value_t;
</pre> </pre>
<h1><a name="_unions">Unions</a></h1> <h1><a name="_unions">Unions</a></h1>
<ul> <ul>
@ -501,16 +579,16 @@ typedef union mxml_value_u mxml_value_t;
</ul> </ul>
<hr noshade/> <hr noshade/>
<h2><a name="mxml_value_u">mxml_value_u</a></h2> <h2><a name="mxml_value_u">mxml_value_u</a></h2>
<p>Node Value</p> <p>An XML node value.</p>
<h3>Definition</h3> <h3>Definition</h3>
<pre> <pre>
struct mxml_value_u struct mxml_value_u
{ {
mxml_element_t element; <a href="#mxml_element_t">mxml_element_t</a> element;
int integer; int integer;
char * opaque; char * opaque;
double real; double real;
mxml_text_t text; <a href="#mxml_text_t">mxml_text_t</a> text;
}; };
</pre> </pre>
<h3>Members</h3> <h3>Members</h3>

View File

@ -1,5 +1,5 @@
/* /*
* "$Id: mxml-attr.c,v 1.1 2003/06/03 19:46:30 mike Exp $" * "$Id: mxml-attr.c,v 1.2 2003/06/14 23:56:47 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.
* *
@ -30,6 +30,9 @@
/* /*
* 'mxmlElementGetAttr()' - Get an attribute. * 'mxmlElementGetAttr()' - Get an attribute.
*
* This function returns NULL if the node is not an element or the
* named attribute does not exist.
*/ */
const char * /* O - Attribute value or NULL */ const char * /* O - Attribute value or NULL */
@ -67,6 +70,11 @@ mxmlElementGetAttr(mxml_node_t *node, /* I - Element node */
/* /*
* 'mxmlElementSetAttr()' - Set an attribute. * 'mxmlElementSetAttr()' - Set an attribute.
*
* If the named attribute already exists, the value of the attribute
* is replaced by the new string value. The string value is copied
* into the element node. This function does nothing if the node is
* not an element.
*/ */
void void
@ -147,5 +155,5 @@ mxmlElementSetAttr(mxml_node_t *node, /* I - Element node */
/* /*
* End of "$Id: mxml-attr.c,v 1.1 2003/06/03 19:46:30 mike Exp $". * End of "$Id: mxml-attr.c,v 1.2 2003/06/14 23:56:47 mike Exp $".
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* "$Id: mxml-file.c,v 1.9 2003/06/04 23:20:31 mike Exp $" * "$Id: mxml-file.c,v 1.10 2003/06/14 23:56:47 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.
* *
@ -46,13 +46,20 @@ static int mxml_write_ws(mxml_node_t *node, FILE *fp,
/* /*
* 'mxmlLoadFile()' - Load a file into an XML node tree. * 'mxmlLoadFile()' - Load a file into an XML node tree.
*
* The nodes in the specified file are added to the specified top node.
* If no top node is provided, the XML file MUST be well-formed with a
* single parent node like <?xml> for the entire file. The callback
* function returns the value type that should be used for child nodes.
* If MXML_NO_CALLBACK is specified then all child nodes will be either
* MXML_ELEMENT or MXML_TEXT nodes.
*/ */
mxml_node_t * /* O - First node */ mxml_node_t * /* O - First node or NULL if the file could not be read. */
mxmlLoadFile(mxml_node_t *top, /* I - Top node */ mxmlLoadFile(mxml_node_t *top, /* I - Top node */
FILE *fp, /* I - File to read from */ FILE *fp, /* I - File to read from */
mxml_type_t (*cb)(mxml_node_t *)) mxml_type_t (*cb)(mxml_node_t *))
/* I - Callback function */ /* I - Callback function or MXML_NO_CALLBACK */
{ {
mxml_node_t *node, /* Current node */ mxml_node_t *node, /* Current node */
*parent; /* Current parent node */ *parent; /* Current parent node */
@ -509,13 +516,19 @@ mxmlLoadFile(mxml_node_t *top, /* I - Top node */
/* /*
* 'mxmlSaveFile()' - Save an XML tree to a file. * 'mxmlSaveFile()' - Save an XML tree to a file.
*
* The callback argument specifies a function that returns a whitespace
* character or nul (0) before and after each element. If MXML_NO_CALLBACK
* is specified, whitespace will only be added before MXML_TEXT nodes
* with leading whitespace and before attribute names inside opening
* element tags.
*/ */
int /* O - 0 on success, -1 on error */ int /* O - 0 on success, -1 on error. */
mxmlSaveFile(mxml_node_t *node, /* I - Node to write */ mxmlSaveFile(mxml_node_t *node, /* I - Node to write */
FILE *fp, /* I - File to write to */ FILE *fp, /* I - File to write to */
int (*cb)(mxml_node_t *, int)) int (*cb)(mxml_node_t *, int))
/* I - Whitespace callback */ /* I - Whitespace callback or MXML_NO_CALLBACK */
{ {
int col; /* Final column */ int col; /* Final column */
@ -999,5 +1012,5 @@ mxml_write_ws(mxml_node_t *node, /* I - Current node */
/* /*
* End of "$Id: mxml-file.c,v 1.9 2003/06/04 23:20:31 mike Exp $". * End of "$Id: mxml-file.c,v 1.10 2003/06/14 23:56:47 mike Exp $".
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* "$Id: mxml-node.c,v 1.4 2003/06/05 03:06:20 mike Exp $" * "$Id: mxml-node.c,v 1.5 2003/06/14 23:56:47 mike Exp $"
* *
* Node support code for mini-XML, a small XML-like file parsing library. * Node support code for mini-XML, a small XML-like file parsing library.
* *
@ -44,12 +44,19 @@ static mxml_node_t *mxml_new(mxml_node_t *parent, mxml_type_t type);
/* /*
* 'mxmlAdd()' - Add a node to a tree. * 'mxmlAdd()' - Add a node to a tree.
*
* Adds the specified node to the parent. If the child argument is not
* NULL, puts the new node before or after the specified child depending
* on the value of the where argument. If the child argument is NULL,
* puts the new node at the beginning of the child list (MXML_ADD_BEFORE)
* or at the end of the child list (MXML_ADD_AFTER). The constant
* MXML_ADD_TO_PARENT can be used to specify a NULL child pointer.
*/ */
void void
mxmlAdd(mxml_node_t *parent, /* I - Parent node */ mxmlAdd(mxml_node_t *parent, /* I - Parent node */
int where, /* I - Where to add */ int where, /* I - Where to add, MXML_ADD_BEFORE or MXML_ADD_AFTER */
mxml_node_t *child, /* I - Child node for where */ mxml_node_t *child, /* I - Child node for where or MXML_ADD_TO_PARENT */
mxml_node_t *node) /* I - Node to add */ mxml_node_t *node) /* I - Node to add */
{ {
/* fprintf(stderr, "mxmlAdd(parent=%p, where=%d, child=%p, node=%p)\n", parent, /* fprintf(stderr, "mxmlAdd(parent=%p, where=%d, child=%p, node=%p)\n", parent,
@ -151,10 +158,13 @@ mxmlAdd(mxml_node_t *parent, /* I - Parent node */
/* /*
* 'mxmlDelete()' - Delete a node and all of its children. * 'mxmlDelete()' - Delete a node and all of its children.
*
* If the specified node has a parent, this function first removes the
* node from its parent using the mxmlRemove() function.
*/ */
void void
mxmlDelete(mxml_node_t *node) /* I - Node */ mxmlDelete(mxml_node_t *node) /* I - Node to delete */
{ {
int i; /* Looping var */ int i; /* Looping var */
@ -230,10 +240,14 @@ mxmlDelete(mxml_node_t *node) /* I - Node */
/* /*
* 'mxmlNewElement()' - Create a new element node. * 'mxmlNewElement()' - Create a new element node.
*
* The new element node is added to the end of the specified parent's child
* list. The constant MXML_NO_PARENT can be used to specify that the new
* element node has no parent.
*/ */
mxml_node_t * /* O - New node */ mxml_node_t * /* O - New node */
mxmlNewElement(mxml_node_t *parent, /* I - Parent node */ mxmlNewElement(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
const char *name) /* I - Name of element */ const char *name) /* I - Name of element */
{ {
mxml_node_t *node; /* New node */ mxml_node_t *node; /* New node */
@ -259,10 +273,14 @@ mxmlNewElement(mxml_node_t *parent, /* I - Parent node */
/* /*
* 'mxmlNewInteger()' - Create a new integer node. * 'mxmlNewInteger()' - Create a new integer node.
*
* The new integer node is added to the end of the specified parent's child
* list. The constant MXML_NO_PARENT can be used to specify that the new
* integer node has no parent.
*/ */
mxml_node_t * /* O - New node */ mxml_node_t * /* O - New node */
mxmlNewInteger(mxml_node_t *parent, /* I - Parent node */ mxmlNewInteger(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
int integer) /* I - Integer value */ int integer) /* I - Integer value */
{ {
mxml_node_t *node; /* New node */ mxml_node_t *node; /* New node */
@ -288,10 +306,15 @@ mxmlNewInteger(mxml_node_t *parent, /* I - Parent node */
/* /*
* 'mxmlNewOpaque()' - Create a new opaque string. * 'mxmlNewOpaque()' - Create a new opaque string.
*
* The new opaque node is added to the end of the specified parent's child
* list. The constant MXML_NO_PARENT can be used to specify that the new
* opaque node has no parent. The opaque string must be nul-terminated and
* is copied into the new node.
*/ */
mxml_node_t * /* O - New node */ mxml_node_t * /* O - New node */
mxmlNewOpaque(mxml_node_t *parent, /* I - Parent node */ mxmlNewOpaque(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
const char *opaque) /* I - Opaque string */ const char *opaque) /* I - Opaque string */
{ {
mxml_node_t *node; /* New node */ mxml_node_t *node; /* New node */
@ -317,10 +340,14 @@ mxmlNewOpaque(mxml_node_t *parent, /* I - Parent node */
/* /*
* 'mxmlNewReal()' - Create a new real number node. * 'mxmlNewReal()' - Create a new real number node.
*
* The new real number node is added to the end of the specified parent's
* child list. The constant MXML_NO_PARENT can be used to specify that
* the new real number node has no parent.
*/ */
mxml_node_t * /* O - New node */ mxml_node_t * /* O - New node */
mxmlNewReal(mxml_node_t *parent, /* I - Parent node */ mxmlNewReal(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
double real) /* I - Real number value */ double real) /* I - Real number value */
{ {
mxml_node_t *node; /* New node */ mxml_node_t *node; /* New node */
@ -346,11 +373,17 @@ mxmlNewReal(mxml_node_t *parent, /* I - Parent node */
/* /*
* 'mxmlNewText()' - Create a new text fragment node. * 'mxmlNewText()' - Create a new text fragment node.
*
* The new text node is added to the end of the specified parent's child
* list. The constant MXML_NO_PARENT can be used to specify that the new
* text node has no parent. The whitespace parameter is used to specify
* whether leading whitespace is present before the node. The text
* string must be nul-terminated and is copied into the new node.
*/ */
mxml_node_t * /* O - New node */ mxml_node_t * /* O - New node */
mxmlNewText(mxml_node_t *parent, /* I - Parent node */ mxmlNewText(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
int whitespace, /* I - Leading whitespace? */ int whitespace, /* I - 1 = leading whitespace, 0 = no whitespace */
const char *string) /* I - String */ const char *string) /* I - String */
{ {
mxml_node_t *node; /* New node */ mxml_node_t *node; /* New node */
@ -379,6 +412,9 @@ mxmlNewText(mxml_node_t *parent, /* I - Parent node */
/* /*
* 'mxmlRemove()' - Remove a node from its parent. * 'mxmlRemove()' - Remove a node from its parent.
*
* Does not free memory used by the node - use mxmlDelete() for that.
* This function does nothing if the node has no parent.
*/ */
void void
@ -453,5 +489,5 @@ mxml_new(mxml_node_t *parent, /* I - Parent node */
/* /*
* End of "$Id: mxml-node.c,v 1.4 2003/06/05 03:06:20 mike Exp $". * End of "$Id: mxml-node.c,v 1.5 2003/06/14 23:56:47 mike Exp $".
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* "$Id: mxml-search.c,v 1.5 2003/06/06 03:09:31 mike Exp $" * "$Id: mxml-search.c,v 1.6 2003/06/14 23:56:47 mike Exp $"
* *
* Search/navigation functions for mini-XML, a small XML-like file * Search/navigation functions for mini-XML, a small XML-like file
* parsing library. * parsing library.
@ -32,6 +32,15 @@
/* /*
* 'mxmlFindElement()' - Find the named element. * 'mxmlFindElement()' - Find the named element.
*
* The search is constrained by the name, attribute name, and value; any
* NULL names or values are treated as wildcards, so different kinds of
* searches can be implemented by looking for all elements of a given name
* or all elements with a specific attribute. The descend argument determines
* whether the search descends into child nodes; normally you will use
* MXML_DESCEND_FIRST for the initial search and MXML_NO_DESCEND to find
* additional direct descendents of the node. The top node argument
* constrains the search to a particular node's children.
*/ */
mxml_node_t * /* O - Element node or NULL */ mxml_node_t * /* O - Element node or NULL */
@ -40,7 +49,7 @@ mxmlFindElement(mxml_node_t *node, /* I - Current node */
const char *name, /* I - Element name or NULL for any */ const char *name, /* I - Element name or NULL for any */
const char *attr, /* I - Attribute name, or NULL for none */ const char *attr, /* I - Attribute name, or NULL for none */
const char *value, /* I - Attribute value, or NULL for any */ const char *value, /* I - Attribute value, or NULL for any */
int descend) /* I - Descend into tree? */ int descend) /* I - Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST */
{ {
const char *temp; /* Current attribute value */ const char *temp; /* Current attribute value */
@ -110,12 +119,16 @@ mxmlFindElement(mxml_node_t *node, /* I - Current node */
/* /*
* 'mxmlWalkNext()' - Walk to the next logical node in the tree. * 'mxmlWalkNext()' - Walk to the next logical node in the tree.
*
* The descend argument controls whether the first child is considered
* to be the next node. The top node argument constrains the walk to
* the node's children.
*/ */
mxml_node_t * /* O - Next node or NULL */ mxml_node_t * /* O - Next node or NULL */
mxmlWalkNext(mxml_node_t *node, /* I - Current node */ mxmlWalkNext(mxml_node_t *node, /* I - Current node */
mxml_node_t *top, /* I - Top node */ mxml_node_t *top, /* I - Top node */
int descend) /* I - Descend into tree? */ int descend) /* I - Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST */
{ {
if (!node) if (!node)
return (NULL); return (NULL);
@ -142,12 +155,16 @@ mxmlWalkNext(mxml_node_t *node, /* I - Current node */
/* /*
* 'mxmlWalkPrev()' - Walk to the previous logical node in the tree. * 'mxmlWalkPrev()' - Walk to the previous logical node in the tree.
*
* The descend argument controls whether the previous node's last child
* is considered to be the previous node. The top node argument constrains
* the walk to the node's children.
*/ */
mxml_node_t * /* O - Previous node or NULL */ mxml_node_t * /* O - Previous node or NULL */
mxmlWalkPrev(mxml_node_t *node, /* I - Current node */ mxmlWalkPrev(mxml_node_t *node, /* I - Current node */
mxml_node_t *top, /* I - Top node */ mxml_node_t *top, /* I - Top node */
int descend) /* I - Descend into tree? */ int descend) /* I - Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST */
{ {
if (!node) if (!node)
return (NULL); return (NULL);
@ -177,5 +194,5 @@ mxmlWalkPrev(mxml_node_t *node, /* I - Current node */
/* /*
* End of "$Id: mxml-search.c,v 1.5 2003/06/06 03:09:31 mike Exp $". * End of "$Id: mxml-search.c,v 1.6 2003/06/14 23:56:47 mike Exp $".
*/ */

18
mxml.h
View File

@ -1,5 +1,5 @@
/* /*
* "$Id: mxml.h,v 1.8 2003/06/07 21:27:05 mike Exp $" * "$Id: mxml.h,v 1.9 2003/06/14 23:56:47 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.
* *
@ -62,7 +62,7 @@
* Data types... * Data types...
*/ */
typedef enum mxml_type_e /**** Node Type ****/ typedef enum mxml_type_e /**** The XML node type. ****/
{ {
MXML_ELEMENT, /* XML element with attributes */ MXML_ELEMENT, /* XML element with attributes */
MXML_INTEGER, /* Integer value */ MXML_INTEGER, /* Integer value */
@ -71,26 +71,26 @@ typedef enum mxml_type_e /**** Node Type ****/
MXML_TEXT /* Text fragment */ MXML_TEXT /* Text fragment */
} mxml_type_t; } mxml_type_t;
typedef struct mxml_attr_s /**** Attribute Value ****/ typedef struct mxml_attr_s /**** An XML element attribute value. ****/
{ {
char *name; /* Attribute name */ char *name; /* Attribute name */
char *value; /* Attribute value */ char *value; /* Attribute value */
} mxml_attr_t; } mxml_attr_t;
typedef struct mxml_value_s /**** Element Value ****/ typedef struct mxml_value_s /**** An XML element value. ****/
{ {
char *name; /* Name of element */ char *name; /* Name of element */
int num_attrs; /* Number of attributes */ int num_attrs; /* Number of attributes */
mxml_attr_t *attrs; /* Attributes */ mxml_attr_t *attrs; /* Attributes */
} mxml_element_t; } mxml_element_t;
typedef struct mxml_text_s /**** Text Value ****/ typedef struct mxml_text_s /**** An XML text value. ****/
{ {
int whitespace; /* Leading whitespace? */ int whitespace; /* Leading whitespace? */
char *string; /* Fragment string */ char *string; /* Fragment string */
} mxml_text_t; } mxml_text_t;
typedef union mxml_value_u /**** Node Value ****/ typedef union mxml_value_u /**** An XML node value. ****/
{ {
mxml_element_t element; /* Element */ mxml_element_t element; /* Element */
int integer; /* Integer number */ int integer; /* Integer number */
@ -99,9 +99,9 @@ typedef union mxml_value_u /**** Node Value ****/
mxml_text_t text; /* Text fragment */ mxml_text_t text; /* Text fragment */
} mxml_value_t; } mxml_value_t;
typedef struct mxml_node_s mxml_node_t; typedef struct mxml_node_s mxml_node_t; /**** An XML node. ****/
struct mxml_node_s /**** Node ****/ struct mxml_node_s /**** An XML node. ****/
{ {
mxml_type_t type; /* Node type */ mxml_type_t type; /* Node type */
mxml_node_t *next; /* Next node under same parent */ mxml_node_t *next; /* Next node under same parent */
@ -162,5 +162,5 @@ extern mxml_node_t *mxmlWalkPrev(mxml_node_t *node, mxml_node_t *top,
/* /*
* End of "$Id: mxml.h,v 1.8 2003/06/07 21:27:05 mike Exp $". * End of "$Id: mxml.h,v 1.9 2003/06/14 23:56:47 mike Exp $".
*/ */

163
mxml.xml
View File

@ -1,104 +1,178 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<function name="mxmlAdd"><description>Add a node to a tree.</description><argument <function name="mxmlAdd"><description>Add a node to a tree.
Adds the specified node to the parent. If the child argument is not
NULL, puts the new node before or after the specified child depending
on the value of the where argument. If the child argument is NULL,
puts the new node at the beginning of the child list (MXML_ADD_BEFORE)
or at the end of the child list (MXML_ADD_AFTER). The constant
MXML_ADD_TO_PARENT can be used to specify a NULL child pointer.</description><argument
name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node</description></argument> name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node</description></argument>
<argument name="where" direction="I"><type>int</type><description>Where to add</description></argument> <argument name="where" direction="I"><type>int</type><description>Where to add, MXML_ADD_BEFORE or MXML_ADD_AFTER</description></argument>
<argument name="child" direction="I"><type>mxml_node_t *</type><description>Child node for where</description></argument> <argument name="child" direction="I"><type>mxml_node_t *</type><description>Child node for where or MXML_ADD_TO_PARENT</description></argument>
<argument name="node" direction="I"><type>mxml_node_t *</type><description>Node to add</description></argument> <argument name="node" direction="I"><type>mxml_node_t *</type><description>Node to add</description></argument>
</function> </function>
<function name="mxmlDelete"><description>Delete a node and all of its children.</description><argument <function name="mxmlDelete"><description>Delete a node and all of its children.
name="node" direction="I"><type>mxml_node_t *</type><description>Node</description></argument>
If the specified node has a parent, this function first removes the
node from its parent using the mxmlRemove() function.</description><argument
name="node" direction="I"><type>mxml_node_t *</type><description>Node to delete</description></argument>
</function> </function>
<function name="mxmlElementGetAttr"><returnvalue><description>Attribute value or NULL</description><type>const <function name="mxmlElementGetAttr"><returnvalue><description>Attribute value or NULL</description><type>const
char *</type></returnvalue> char *</type></returnvalue>
<description>Get an attribute.</description><argument name="node" <description>Get an attribute.
direction="I"><type>mxml_node_t *</type><description>Element node</description></argument>
This function returns NULL if the node is not an element or the
named attribute does not exist.</description><argument
name="node" direction="I"><type>mxml_node_t *</type><description>Element node</description></argument>
<argument name="name" direction="I"><type>const char *</type><description>Name of attribute</description></argument> <argument name="name" direction="I"><type>const char *</type><description>Name of attribute</description></argument>
</function> </function>
<function name="mxmlElementSetAttr"><description>Set an attribute.</description><argument <function name="mxmlElementSetAttr"><description>Set an attribute.
If the named attribute already exists, the value of the attribute
is replaced by the new string value. The string value is copied
into the element node. This function does nothing if the node is
not an element.</description><argument
name="node" direction="I"><type>mxml_node_t *</type><description>Element node</description></argument> name="node" direction="I"><type>mxml_node_t *</type><description>Element node</description></argument>
<argument name="name" direction="I"><type>const char *</type><description>Name of attribute</description></argument> <argument name="name" direction="I"><type>const char *</type><description>Name of attribute</description></argument>
<argument name="value" direction="I"><type>const char *</type><description>Attribute value</description></argument> <argument name="value" direction="I"><type>const char *</type><description>Attribute value</description></argument>
</function> </function>
<function name="mxmlFindElement"><returnvalue><description>Element node or NULL</description><type>mxml_node_t <function name="mxmlFindElement"><returnvalue><description>Element node or NULL</description><type>mxml_node_t
*</type></returnvalue> *</type></returnvalue>
<description>Find the named element.</description><argument name="node" <description>Find the named element.
direction="I"><type>mxml_node_t *</type><description>Current node</description></argument>
The search is constrained by the name, attribute name, and value; any
NULL names or values are treated as wildcards, so different kinds of
searches can be implemented by looking for all elements of a given name
or all elements with a specific attribute. The descend argument determines
whether the search descends into child nodes; normally you will use
MXML_DESCEND_FIRST for the initial search and MXML_NO_DESCEND to find
additional direct descendents of the node. The top node argument
constrains the search to a particular node's children.</description><argument
name="node" direction="I"><type>mxml_node_t *</type><description>Current node</description></argument>
<argument name="top" direction="I"><type>mxml_node_t *</type><description>Top node</description></argument> <argument name="top" direction="I"><type>mxml_node_t *</type><description>Top node</description></argument>
<argument name="name" direction="I"><type>const char *</type><description>Element name or NULL for any</description></argument> <argument name="name" direction="I"><type>const char *</type><description>Element name or NULL for any</description></argument>
<argument name="attr" direction="I"><type>const char *</type><description>Attribute name, or NULL for none</description></argument> <argument name="attr" direction="I"><type>const char *</type><description>Attribute name, or NULL for none</description></argument>
<argument name="value" direction="I"><type>const char *</type><description>Attribute value, or NULL for any</description></argument> <argument name="value" direction="I"><type>const char *</type><description>Attribute value, or NULL for any</description></argument>
<argument name="descend" direction="I"><type>int</type><description>Descend into tree?</description></argument> <argument name="descend" direction="I"><type>int</type><description>Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST</description></argument>
</function> </function>
<function name="mxmlLoadFile"><returnvalue><description>First node</description><type>mxml_node_t <function name="mxmlLoadFile"><returnvalue><description>First node or NULL if the file could not be read.</description><type>mxml_node_t
*</type></returnvalue> *</type></returnvalue>
<description>Load a file into an XML node tree.</description><argument <description>Load a file into an XML node tree.
The nodes in the specified file are added to the specified top node.
If no top node is provided, the XML file MUST be well-formed with a
single parent node like &lt;?xml&gt; for the entire file. The callback
function returns the value type that should be used for child nodes.
If MXML_NO_CALLBACK is specified then all child nodes will be either
MXML_ELEMENT or MXML_TEXT nodes.</description><argument
name="top" direction="I"><type>mxml_node_t *</type><description>Top node</description></argument> name="top" direction="I"><type>mxml_node_t *</type><description>Top node</description></argument>
<argument name="fp" direction="I"><type>FILE *</type><description>File to read from</description></argument> <argument name="fp" direction="I"><type>FILE *</type><description>File to read from</description></argument>
<argument name="(*cb)(mxml_node_t *)" direction="I"><type>mxml_type_t</type><description>Callback function</description></argument> <argument name="(*cb)(mxml_node_t *)" direction="I"><type>mxml_type_t</type><description>Callback function or MXML_NO_CALLBACK</description></argument>
</function> </function>
<function name="mxmlNewElement"><returnvalue><description>New node</description><type>mxml_node_t <function name="mxmlNewElement"><returnvalue><description>New node</description><type>mxml_node_t
*</type></returnvalue> *</type></returnvalue>
<description>Create a new element node.</description><argument <description>Create a new element node.
name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node</description></argument>
The new element node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
element node has no parent.</description><argument
name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node or MXML_NO_PARENT</description></argument>
<argument name="name" direction="I"><type>const char *</type><description>Name of element</description></argument> <argument name="name" direction="I"><type>const char *</type><description>Name of element</description></argument>
</function> </function>
<function name="mxmlNewInteger"><returnvalue><description>New node</description><type>mxml_node_t <function name="mxmlNewInteger"><returnvalue><description>New node</description><type>mxml_node_t
*</type></returnvalue> *</type></returnvalue>
<description>Create a new integer node.</description><argument <description>Create a new integer node.
name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node</description></argument>
The new integer node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
integer node has no parent.</description><argument
name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node or MXML_NO_PARENT</description></argument>
<argument name="integer" direction="I"><type>int</type><description>Integer value</description></argument> <argument name="integer" direction="I"><type>int</type><description>Integer value</description></argument>
</function> </function>
<function name="mxmlNewOpaque"><returnvalue><description>New node</description><type>mxml_node_t <function name="mxmlNewOpaque"><returnvalue><description>New node</description><type>mxml_node_t
*</type></returnvalue> *</type></returnvalue>
<description>Create a new opaque string.</description><argument <description>Create a new opaque string.
name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node</description></argument>
The new opaque node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
opaque node has no parent. The opaque string must be nul-terminated and
is copied into the new node.</description><argument
name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node or MXML_NO_PARENT</description></argument>
<argument name="opaque" direction="I"><type>const char *</type><description>Opaque string</description></argument> <argument name="opaque" direction="I"><type>const char *</type><description>Opaque string</description></argument>
</function> </function>
<function name="mxmlNewReal"><returnvalue><description>New node</description><type>mxml_node_t <function name="mxmlNewReal"><returnvalue><description>New node</description><type>mxml_node_t
*</type></returnvalue> *</type></returnvalue>
<description>Create a new real number node.</description><argument <description>Create a new real number node.
name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node</description></argument>
The new real number node is added to the end of the specified parent's
child list. The constant MXML_NO_PARENT can be used to specify that
the new real number node has no parent.</description><argument
name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node or MXML_NO_PARENT</description></argument>
<argument name="real" direction="I"><type>double</type><description>Real number value</description></argument> <argument name="real" direction="I"><type>double</type><description>Real number value</description></argument>
</function> </function>
<function name="mxmlNewText"><returnvalue><description>New node</description><type>mxml_node_t <function name="mxmlNewText"><returnvalue><description>New node</description><type>mxml_node_t
*</type></returnvalue> *</type></returnvalue>
<description>Create a new text fragment node.</description><argument <description>Create a new text fragment node.
name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node</description></argument>
<argument name="whitespace" direction="I"><type>int</type><description>Leading whitespace?</description></argument> The new text node is added to the end of the specified parent's child
list. The constant MXML_NO_PARENT can be used to specify that the new
text node has no parent. The whitespace parameter is used to specify
whether leading whitespace is present before the node. The text
string must be nul-terminated and is copied into the new node.</description><argument
name="parent" direction="I"><type>mxml_node_t *</type><description>Parent node or MXML_NO_PARENT</description></argument>
<argument name="whitespace" direction="I"><type>int</type><description>1 = leading whitespace, 0 = no whitespace</description></argument>
<argument name="string" direction="I"><type>const char *</type><description>String</description></argument> <argument name="string" direction="I"><type>const char *</type><description>String</description></argument>
</function> </function>
<function name="mxmlRemove"><description>Remove a node from its parent.</description><argument <function name="mxmlRemove"><description>Remove a node from its parent.
Does not free memory used by the node - use mxmlDelete() for that.
This function does nothing if the node has no parent.</description><argument
name="node" direction="I"><type>mxml_node_t *</type><description>Node to remove</description></argument> name="node" direction="I"><type>mxml_node_t *</type><description>Node to remove</description></argument>
</function> </function>
<function name="mxmlSaveFile"><returnvalue><description>0 on success, -1 on error</description><type>int</type></returnvalue> <function name="mxmlSaveFile"><returnvalue><description>0 on success, -1 on error.</description><type>int</type></returnvalue>
<description>Save an XML tree to a file.</description><argument <description>Save an XML tree to a file.
The callback argument specifies a function that returns a whitespace
character or nul (0) before and after each element. If MXML_NO_CALLBACK
is specified, whitespace will only be added before MXML_TEXT nodes
with leading whitespace and before attribute names inside opening
element tags.</description><argument
name="node" direction="I"><type>mxml_node_t *</type><description>Node to write</description></argument> name="node" direction="I"><type>mxml_node_t *</type><description>Node to write</description></argument>
<argument name="fp" direction="I"><type>FILE *</type><description>File to write to</description></argument> <argument name="fp" direction="I"><type>FILE *</type><description>File to write to</description></argument>
<argument name="(*cb)(mxml_node_t *int)" direction="I"><type>int</type><description>Whitespace callback</description></argument> <argument name="(*cb)(mxml_node_t *int)" direction="I"><type>int</type><description>Whitespace callback or MXML_NO_CALLBACK</description></argument>
</function> </function>
<function name="mxmlWalkNext"><returnvalue><description>Next node or NULL</description><type>mxml_node_t <function name="mxmlWalkNext"><returnvalue><description>Next node or NULL</description><type>mxml_node_t
*</type></returnvalue> *</type></returnvalue>
<description>Walk to the next logical node in the tree.</description><argument <description>Walk to the next logical node in the tree.
The descend argument controls whether the first child is considered
to be the next node. The top node argument constrains the walk to
the node's children.</description><argument
name="node" direction="I"><type>mxml_node_t *</type><description>Current node</description></argument> name="node" direction="I"><type>mxml_node_t *</type><description>Current node</description></argument>
<argument name="top" direction="I"><type>mxml_node_t *</type><description>Top node</description></argument> <argument name="top" direction="I"><type>mxml_node_t *</type><description>Top node</description></argument>
<argument name="descend" direction="I"><type>int</type><description>Descend into tree?</description></argument> <argument name="descend" direction="I"><type>int</type><description>Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST</description></argument>
</function> </function>
<function name="mxmlWalkPrev"><returnvalue><description>Previous node or NULL</description><type>mxml_node_t <function name="mxmlWalkPrev"><returnvalue><description>Previous node or NULL</description><type>mxml_node_t
*</type></returnvalue> *</type></returnvalue>
<description>Walk to the previous logical node in the tree.</description><argument <description>Walk to the previous logical node in the tree.
The descend argument controls whether the previous node's last child
is considered to be the previous node. The top node argument constrains
the walk to the node's children.</description><argument
name="node" direction="I"><type>mxml_node_t *</type><description>Current node</description></argument> name="node" direction="I"><type>mxml_node_t *</type><description>Current node</description></argument>
<argument name="top" direction="I"><type>mxml_node_t *</type><description>Top node</description></argument> <argument name="top" direction="I"><type>mxml_node_t *</type><description>Top node</description></argument>
<argument name="descend" direction="I"><type>int</type><description>Descend into tree?</description></argument> <argument name="descend" direction="I"><type>int</type><description>Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST</description></argument>
</function> </function>
<struct name="mxml_attr_s"><description>Attribute Value</description><variable <struct name="mxml_attr_s"><description>An XML element attribute value.</description><variable
name="name"><type>char *</type><description>Attribute name</description></variable> name="name"><type>char *</type><description>Attribute name</description></variable>
<variable name="value"><type>char *</type><description>Attribute value</description></variable> <variable name="value"><type>char *</type><description>Attribute value</description></variable>
</struct> </struct>
<typedef name="mxml_attr_t"><description>Attribute Value</description><type>struct <typedef name="mxml_attr_t"><description>An XML element attribute value.</description><type>struct
mxml_attr_s</type></typedef> mxml_attr_s</type></typedef>
<typedef name="mxml_element_t"><description>Element Value</description><type>struct <typedef name="mxml_element_t"><description>An XML element value.</description><type>struct
mxml_value_s</type></typedef> mxml_value_s</type></typedef>
<struct name="mxml_node_s"><description>Node</description><variable <struct name="mxml_node_s"><description>Data types...</description><variable
name="child"><type>mxml_node_t *</type><description>First child node</description></variable> name="child"><type>mxml_node_t *</type><description>First child node</description></variable>
<variable name="last_child"><type>mxml_node_t *</type><description>Last child node</description></variable> <variable name="last_child"><type>mxml_node_t *</type><description>Last child node</description></variable>
<variable name="next"><type>mxml_node_t *</type><description>Next node under same parent</description></variable> <variable name="next"><type>mxml_node_t *</type><description>Next node under same parent</description></variable>
@ -107,29 +181,30 @@ name="child"><type>mxml_node_t *</type><description>First child node</descriptio
<variable name="type"><type>mxml_type_t</type><description>Node type</description></variable> <variable name="type"><type>mxml_type_t</type><description>Node type</description></variable>
<variable name="value"><type>mxml_value_t</type><description>Node value</description></variable> <variable name="value"><type>mxml_value_t</type><description>Node value</description></variable>
</struct> </struct>
<struct name="mxml_text_s"><description>Text Value</description><variable <typedef name="mxml_node_t"><type>struct mxml_node_s</type><description>An XML node.</description><description>An XML node.</description></typedef>
<struct name="mxml_text_s"><description>An XML text value.</description><variable
name="string"><type>char *</type><description>Fragment string</description></variable> name="string"><type>char *</type><description>Fragment string</description></variable>
<variable name="whitespace"><type>int</type><description>Leading whitespace?</description></variable> <variable name="whitespace"><type>int</type><description>Leading whitespace?</description></variable>
</struct> </struct>
<typedef name="mxml_text_t"><description>Text Value</description><type>struct <typedef name="mxml_text_t"><description>An XML text value.</description><type>struct
mxml_text_s</type></typedef> mxml_text_s</type></typedef>
<enumeration name="mxml_type_e"><description>Node Type</description><constant <enumeration name="mxml_type_e"><description>The XML node type.</description><constant
name="MXML_ELEMENT"><description>XML element with attributes</description></constant> name="MXML_ELEMENT"><description>XML element with attributes</description></constant>
<constant name="MXML_INTEGER"><description>Integer value</description></constant> <constant name="MXML_INTEGER"><description>Integer value</description></constant>
<constant name="MXML_OPAQUE"><description>Opaque string</description></constant> <constant name="MXML_OPAQUE"><description>Opaque string</description></constant>
<constant name="MXML_REAL"><description>Real value</description></constant> <constant name="MXML_REAL"><description>Real value</description></constant>
<constant name="MXML_TEXT"><description>Text fragment</description></constant> <constant name="MXML_TEXT"><description>Text fragment</description></constant>
</enumeration> </enumeration>
<typedef name="mxml_type_t"><description>Node Type</description><type>enum <typedef name="mxml_type_t"><description>The XML node type.</description><type>enum
mxml_type_e</type></typedef> mxml_type_e</type></typedef>
<struct name="mxml_value_s"><description>Element Value</description><variable <struct name="mxml_value_s"><description>An XML element value.</description><variable
name="attrs"><type>mxml_attr_t *</type><description>Attributes</description></variable> name="attrs"><type>mxml_attr_t *</type><description>Attributes</description></variable>
<variable name="name"><type>char *</type><description>Name of element</description></variable> <variable name="name"><type>char *</type><description>Name of element</description></variable>
<variable name="num_attrs"><type>int</type><description>Number of attributes</description></variable> <variable name="num_attrs"><type>int</type><description>Number of attributes</description></variable>
</struct> </struct>
<typedef name="mxml_value_t"><description>Node Value</description><type>union <typedef name="mxml_value_t"><description>An XML node value.</description><type>union
mxml_value_u</type></typedef> mxml_value_u</type></typedef>
<union name="mxml_value_u"><description>Node Value</description><variable <union name="mxml_value_u"><description>An XML node value.</description><variable
name="element"><type>mxml_element_t</type><description>Element</description></variable> name="element"><type>mxml_element_t</type><description>Element</description></variable>
<variable name="integer"><type>int</type><description>Integer number</description></variable> <variable name="integer"><type>int</type><description>Integer number</description></variable>
<variable name="opaque"><type>char *</type><description>Opaque string</description></variable> <variable name="opaque"><type>char *</type><description>Opaque string</description></variable>

203
mxmldoc.c
View File

@ -1,5 +1,5 @@
/* /*
* "$Id: mxmldoc.c,v 1.11 2003/06/14 22:14:17 mike Exp $" * "$Id: mxmldoc.c,v 1.12 2003/06/14 23:56:47 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.
@ -112,7 +112,7 @@ static void sort_node(mxml_node_t *tree, mxml_node_t *func);
static void update_comment(mxml_node_t *parent, static void update_comment(mxml_node_t *parent,
mxml_node_t *comment); mxml_node_t *comment);
static void write_documentation(mxml_node_t *doc); static void write_documentation(mxml_node_t *doc);
static void write_element(mxml_node_t *element); static void write_element(mxml_node_t *doc, mxml_node_t *element);
static void write_string(const char *s); static void write_string(const char *s);
static int ws_cb(mxml_node_t *node, int where); static int ws_cb(mxml_node_t *node, int where);
@ -475,7 +475,7 @@ scan_file(const char *filename, /* I - Filename */
type = NULL; type = NULL;
} }
if (typedefnode) if (typedefnode && comment->last_child)
{ {
/* /*
* Copy comment for typedef as well as class/struct/union... * Copy comment for typedef as well as class/struct/union...
@ -507,6 +507,7 @@ scan_file(const char *filename, /* I - Filename */
#ifdef DEBUG #ifdef DEBUG
fputs(" ended typedef...\n", stderr); fputs(" ended typedef...\n", stderr);
#endif /* DEBUG */ #endif /* DEBUG */
structclass = NULL;
break; break;
} }
else if (type && type->child && type->child->next && else if (type && type->child && type->child->next &&
@ -553,7 +554,7 @@ scan_file(const char *filename, /* I - Filename */
type = NULL; type = NULL;
} }
if (typedefnode) if (typedefnode && comment->last_child)
{ {
/* /*
* Copy comment for typedef as well as class/struct/union... * Copy comment for typedef as well as class/struct/union...
@ -596,6 +597,7 @@ scan_file(const char *filename, /* I - Filename */
enumeration = NULL; enumeration = NULL;
constant = NULL; constant = NULL;
structclass = NULL;
if (braces > 0) if (braces > 0)
braces --; braces --;
@ -736,6 +738,16 @@ scan_file(const char *filename, /* I - Filename */
update_comment(constant, update_comment(constant,
mxmlNewText(description, 0, buffer)); mxmlNewText(description, 0, buffer));
} }
else if (typedefnode)
{
description = mxmlNewElement(typedefnode, "description");
#ifdef DEBUG
fprintf(stderr, " adding comment to typedef %s...\n",
mxmlElementGetAttr(typedefnode, "name"));
#endif /* DEBUG */
update_comment(typedefnode,
mxmlNewText(description, 0, buffer));
}
else if (strcmp(tree->value.element.name, "?xml") && else if (strcmp(tree->value.element.name, "?xml") &&
!mxmlFindElement(tree, tree, "description", !mxmlFindElement(tree, tree, "description",
NULL, NULL, MXML_DESCEND_FIRST)) NULL, NULL, MXML_DESCEND_FIRST))
@ -821,6 +833,16 @@ scan_file(const char *filename, /* I - Filename */
update_comment(constant, update_comment(constant,
mxmlNewText(description, 0, buffer)); mxmlNewText(description, 0, buffer));
} }
else if (typedefnode)
{
description = mxmlNewElement(typedefnode, "description");
#ifdef DEBUG
fprintf(stderr, " adding comment to typedef %s...\n",
mxmlElementGetAttr(typedefnode, "name"));
#endif /* DEBUG */
update_comment(typedefnode,
mxmlNewText(description, 0, buffer));
}
else if (strcmp(tree->value.element.name, "?xml") && else if (strcmp(tree->value.element.name, "?xml") &&
!mxmlFindElement(tree, tree, "description", !mxmlFindElement(tree, tree, "description",
NULL, NULL, MXML_DESCEND_FIRST)) NULL, NULL, MXML_DESCEND_FIRST))
@ -889,6 +911,16 @@ scan_file(const char *filename, /* I - Filename */
update_comment(constant, update_comment(constant,
mxmlNewText(description, 0, buffer)); mxmlNewText(description, 0, buffer));
} }
else if (typedefnode)
{
description = mxmlNewElement(typedefnode, "description");
#ifdef DEBUG
fprintf(stderr, " adding comment to typedef %s...\n",
mxmlElementGetAttr(typedefnode, "name"));
#endif /* DEBUG */
update_comment(typedefnode,
mxmlNewText(description, 0, buffer));
}
else if (strcmp(tree->value.element.name, "?xml") && else if (strcmp(tree->value.element.name, "?xml") &&
!mxmlFindElement(tree, tree, "description", !mxmlFindElement(tree, tree, "description",
NULL, NULL, MXML_DESCEND_FIRST)) NULL, NULL, MXML_DESCEND_FIRST))
@ -1058,8 +1090,10 @@ scan_file(const char *filename, /* I - Filename */
if (structclass && !mxmlElementGetAttr(structclass, "name")) if (structclass && !mxmlElementGetAttr(structclass, "name"))
{ {
#ifdef DEBUG
fprintf(stderr, "setting struct/class name to %s!\n", fprintf(stderr, "setting struct/class name to %s!\n",
type->last_child->value.text.string); type->last_child->value.text.string);
#endif /* DEBUG */
mxmlElementSetAttr(structclass, "name", buffer); mxmlElementSetAttr(structclass, "name", buffer);
sort_node(tree, structclass); sort_node(tree, structclass);
@ -1075,6 +1109,29 @@ scan_file(const char *filename, /* I - Filename */
type = NULL; type = NULL;
typedefnode = NULL; typedefnode = NULL;
} }
else if (type->child &&
!strcmp(type->child->value.text.string, "typedef"))
{
/*
* Simple typedef...
*/
#ifdef DEBUG
fprintf(stderr, "Typedef: <<< %s >>>\n", buffer);
#endif /* DEBUG */
typedefnode = mxmlNewElement(MXML_NO_PARENT, "typedef");
mxmlElementSetAttr(typedefnode, "name", buffer);
mxmlDelete(type->child);
sort_node(tree, typedefnode);
if (type->child)
type->child->value.text.whitespace = 0;
mxmlAdd(typedefnode, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, type);
type = NULL;
}
else if (!parens) else if (!parens)
{ {
/* /*
@ -1346,18 +1403,28 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
puts("<h1>Contents</h1>"); puts("<h1>Contents</h1>");
puts("<ul>"); puts("<ul>");
if (mxmlFindElement(doc, doc, "class", NULL, NULL, MXML_DESCEND_FIRST))
puts("\t<li><a href=\"#_classes\">Classes</a></li>"); puts("\t<li><a href=\"#_classes\">Classes</a></li>");
if (mxmlFindElement(doc, doc, "enumeration", NULL, NULL, MXML_DESCEND_FIRST))
puts("\t<li><a href=\"#_enumerations\">Enumeration</a></li>"); puts("\t<li><a href=\"#_enumerations\">Enumeration</a></li>");
if (mxmlFindElement(doc, doc, "function", NULL, NULL, MXML_DESCEND_FIRST))
puts("\t<li><a href=\"#_functions\">Functions</a></li>"); puts("\t<li><a href=\"#_functions\">Functions</a></li>");
if (mxmlFindElement(doc, doc, "struct", NULL, NULL, MXML_DESCEND_FIRST))
puts("\t<li><a href=\"#_structures\">Structures</a></li>"); puts("\t<li><a href=\"#_structures\">Structures</a></li>");
if (mxmlFindElement(doc, doc, "typedef", NULL, NULL, MXML_DESCEND_FIRST))
puts("\t<li><a href=\"#_types\">Types</a></li>"); puts("\t<li><a href=\"#_types\">Types</a></li>");
if (mxmlFindElement(doc, doc, "union", NULL, NULL, MXML_DESCEND_FIRST))
puts("\t<li><a href=\"#_unions\">Unions</a></li>"); puts("\t<li><a href=\"#_unions\">Unions</a></li>");
if (mxmlFindElement(doc, doc, "variable", NULL, NULL, MXML_DESCEND_FIRST))
puts("\t<li><a href=\"#_variables\">Variables</a></li>");
puts("</ul>"); puts("</ul>");
/* /*
* List of classes... * List of classes...
*/ */
if (mxmlFindElement(doc, doc, "class", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<h1><a name=\"_classes\">Classes</a></h1>"); puts("<h1><a name=\"_classes\">Classes</a></h1>");
puts("<ul>"); puts("<ul>");
@ -1388,7 +1455,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (description) if (description)
{ {
fputs("<p>", stdout); fputs("<p>", stdout);
write_element(description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
@ -1403,7 +1470,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND)) MXML_NO_DESCEND))
{ {
printf(" "); printf(" ");
write_element(mxmlFindElement(arg, arg, "type", NULL, write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
printf(" %s;\n", mxmlElementGetAttr(arg, "name")); printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
} }
@ -1424,7 +1491,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
{ {
printf("<tr><td><tt>%s</tt></td><td>", mxmlElementGetAttr(arg, "name")); printf("<tr><td><tt>%s</tt></td><td>", mxmlElementGetAttr(arg, "name"));
write_element(mxmlFindElement(arg, arg, "description", NULL, write_element(NULL, mxmlFindElement(arg, arg, "description", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
puts("</td></tr>"); puts("</td></tr>");
@ -1432,11 +1499,14 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
puts("</tbody></table></p>"); puts("</tbody></table></p>");
} }
}
/* /*
* List of enumerations... * List of enumerations...
*/ */
if (mxmlFindElement(doc, doc, "enumeration", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<h1><a name=\"_enumerations\">Enumerations</a></h1>"); puts("<h1><a name=\"_enumerations\">Enumerations</a></h1>");
puts("<ul>"); puts("<ul>");
@ -1467,7 +1537,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (description) if (description)
{ {
fputs("<p>", stdout); fputs("<p>", stdout);
write_element(description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
@ -1485,7 +1555,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
{ {
printf("<tr><td><tt>%s</tt></td><td>", mxmlElementGetAttr(arg, "name")); printf("<tr><td><tt>%s</tt></td><td>", mxmlElementGetAttr(arg, "name"));
write_element(mxmlFindElement(arg, arg, "description", NULL, write_element(doc, mxmlFindElement(arg, arg, "description", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
puts("</td></tr>"); puts("</td></tr>");
@ -1493,10 +1563,14 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
puts("</tbody></table></p>"); puts("</tbody></table></p>");
} }
}
/* /*
* List of functions... * List of functions...
*/ */
if (mxmlFindElement(doc, doc, "function", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<h1><a name=\"_functions\">Functions</a></h1>"); puts("<h1><a name=\"_functions\">Functions</a></h1>");
puts("<ul>"); puts("<ul>");
@ -1527,7 +1601,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (description) if (description)
{ {
fputs("<p>", stdout); fputs("<p>", stdout);
write_element(description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
@ -1538,7 +1612,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
NULL, MXML_DESCEND_FIRST); NULL, MXML_DESCEND_FIRST);
if (arg) if (arg)
write_element(mxmlFindElement(arg, arg, "type", NULL, write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
else else
fputs("void", stdout); fputs("void", stdout);
@ -1551,7 +1625,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND), prefix = ',') MXML_NO_DESCEND), prefix = ',')
{ {
printf("%c\n ", prefix); printf("%c\n ", prefix);
write_element(mxmlFindElement(arg, arg, "type", NULL, write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
printf(" %s", mxmlElementGetAttr(arg, "name")); printf(" %s", mxmlElementGetAttr(arg, "name"));
} }
@ -1579,7 +1653,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
{ {
printf("<tr><td><tt>%s</tt></td><td>", mxmlElementGetAttr(arg, "name")); printf("<tr><td><tt>%s</tt></td><td>", mxmlElementGetAttr(arg, "name"));
write_element(mxmlFindElement(arg, arg, "description", NULL, write_element(NULL, mxmlFindElement(arg, arg, "description", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
puts("</td></tr>"); puts("</td></tr>");
@ -1598,16 +1672,19 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
else else
{ {
fputs("<p>", stdout); fputs("<p>", stdout);
write_element(mxmlFindElement(arg, arg, "description", NULL, write_element(NULL, mxmlFindElement(arg, arg, "description", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
puts("</p>"); puts("</p>");
} }
} }
}
/* /*
* List of structures... * List of structures...
*/ */
if (mxmlFindElement(doc, doc, "struct", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<h1><a name=\"_structures\">Structures</a></h1>"); puts("<h1><a name=\"_structures\">Structures</a></h1>");
puts("<ul>"); puts("<ul>");
@ -1638,7 +1715,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (description) if (description)
{ {
fputs("<p>", stdout); fputs("<p>", stdout);
write_element(description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
@ -1653,7 +1730,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND)) MXML_NO_DESCEND))
{ {
printf(" "); printf(" ");
write_element(mxmlFindElement(arg, arg, "type", NULL, write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
printf(" %s;\n", mxmlElementGetAttr(arg, "name")); printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
} }
@ -1674,7 +1751,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
{ {
printf("<tr><td><tt>%s</tt></td><td>", mxmlElementGetAttr(arg, "name")); printf("<tr><td><tt>%s</tt></td><td>", mxmlElementGetAttr(arg, "name"));
write_element(mxmlFindElement(arg, arg, "description", NULL, write_element(NULL, mxmlFindElement(arg, arg, "description", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
puts("</td></tr>"); puts("</td></tr>");
@ -1682,11 +1759,14 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
puts("</tbody></table></p>"); puts("</tbody></table></p>");
} }
}
/* /*
* List of types... * List of types...
*/ */
if (mxmlFindElement(doc, doc, "typedef", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<h1><a name=\"_types\">Types</a></h1>"); puts("<h1><a name=\"_types\">Types</a></h1>");
puts("<ul>"); puts("<ul>");
@ -1717,7 +1797,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (description) if (description)
{ {
fputs("<p>", stdout); fputs("<p>", stdout);
write_element(description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
@ -1725,15 +1805,18 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
puts("<pre>"); puts("<pre>");
printf("typedef "); printf("typedef ");
write_element(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);
} }
}
/* /*
* List of unions... * List of unions...
*/ */
if (mxmlFindElement(doc, doc, "union", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<h1><a name=\"_unions\">Unions</a></h1>"); puts("<h1><a name=\"_unions\">Unions</a></h1>");
puts("<ul>"); puts("<ul>");
@ -1764,7 +1847,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (description) if (description)
{ {
fputs("<p>", stdout); fputs("<p>", stdout);
write_element(description); write_element(NULL, description);
puts("</p>"); puts("</p>");
} }
@ -1779,7 +1862,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND)) MXML_NO_DESCEND))
{ {
printf(" "); printf(" ");
write_element(mxmlFindElement(arg, arg, "type", NULL, write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
printf(" %s;\n", mxmlElementGetAttr(arg, "name")); printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
} }
@ -1800,7 +1883,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
{ {
printf("<tr><td><tt>%s</tt></td><td>", mxmlElementGetAttr(arg, "name")); printf("<tr><td><tt>%s</tt></td><td>", mxmlElementGetAttr(arg, "name"));
write_element(mxmlFindElement(arg, arg, "description", NULL, write_element(NULL, mxmlFindElement(arg, arg, "description", NULL,
NULL, MXML_DESCEND_FIRST)); NULL, MXML_DESCEND_FIRST));
puts("</td></tr>"); puts("</td></tr>");
@ -1808,6 +1891,58 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
puts("</tbody></table></p>"); puts("</tbody></table></p>");
} }
}
/*
* Variables...
*/
if (mxmlFindElement(doc, doc, "variable", NULL, NULL, MXML_DESCEND_FIRST))
{
puts("<h1><a name=\"_variables\">Variables</a></h1>");
puts("<ul>");
for (arg = mxmlFindElement(doc, doc, "variable", NULL, NULL,
MXML_DESCEND_FIRST);
arg;
arg = mxmlFindElement(arg, doc, "variable", NULL, NULL,
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(arg, "name");
printf("\t<li><a href=\"#%s\"><tt>%s</tt></a></li>\n", name, name);
}
puts("</ul>");
for (arg = mxmlFindElement(doc, doc, "variable", NULL, NULL,
MXML_DESCEND_FIRST);
arg;
arg = mxmlFindElement(arg, doc, "variable", NULL, NULL,
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(arg, "name");
puts("<hr noshade/>");
printf("<h2><a name=\"%s\">%s</a></h2>\n", name, name);
description = mxmlFindElement(arg, arg, "description", NULL,
NULL, MXML_DESCEND_FIRST);
if (description)
{
fputs("<p>", stdout);
write_element(NULL, description);
puts("</p>");
}
puts("<h3>Definition</h3>");
puts("<pre>");
write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
NULL, MXML_DESCEND_FIRST));
printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
puts("</pre>");
}
}
/* /*
* Standard footer... * Standard footer...
@ -1815,7 +1950,6 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
puts("</body>"); puts("</body>");
puts("</html>"); puts("</html>");
} }
@ -1824,7 +1958,8 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
*/ */
static void static void
write_element(mxml_node_t *element) /* I - Element to write */ write_element(mxml_node_t *doc, /* I - Document tree */
mxml_node_t *element) /* I - Element to write */
{ {
mxml_node_t *node; /* Current node */ mxml_node_t *node; /* Current node */
@ -1837,6 +1972,24 @@ write_element(mxml_node_t *element) /* I - Element to write */
if (node->value.text.whitespace) if (node->value.text.whitespace)
putchar(' '); putchar(' ');
if (mxmlFindElement(doc, doc, "class", "name", node->value.text.string,
MXML_DESCEND) ||
mxmlFindElement(doc, doc, "enumeration", "name",
node->value.text.string, MXML_DESCEND) ||
mxmlFindElement(doc, doc, "struct", "name", node->value.text.string,
MXML_DESCEND) ||
mxmlFindElement(doc, doc, "typedef", "name", node->value.text.string,
MXML_DESCEND) ||
mxmlFindElement(doc, doc, "union", "name", node->value.text.string,
MXML_DESCEND))
{
printf("<a href=\"#");
write_string(node->value.text.string);
printf("\">");
write_string(node->value.text.string);
printf("</a>");
}
else
write_string(node->value.text.string); write_string(node->value.text.string);
} }
} }
@ -1926,5 +2079,5 @@ ws_cb(mxml_node_t *node, /* I - Element node */
/* /*
* End of "$Id: mxmldoc.c,v 1.11 2003/06/14 22:14:17 mike Exp $". * End of "$Id: mxmldoc.c,v 1.12 2003/06/14 23:56:47 mike Exp $".
*/ */