From bcc99b153aef0a3fa8e91f2a5ac8bf646f8e29ff Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Sat, 14 Jun 2003 23:56:47 +0000 Subject: [PATCH] Fix some more documentation generator bugs. Add detailed docos to the file. --- documentation.html | 260 ++++++++----- mxml-attr.c | 12 +- mxml-file.c | 25 +- mxml-node.c | 58 ++- mxml-search.c | 27 +- mxml.h | 18 +- mxml.xml | 163 +++++--- mxmldoc.c | 903 ++++++++++++++++++++++++++------------------- 8 files changed, 923 insertions(+), 543 deletions(-) diff --git a/documentation.html b/documentation.html index b141ea4..4af344e 100644 --- a/documentation.html +++ b/documentation.html @@ -11,23 +11,19 @@

Contents

-

Classes

-

Enumerations


mxml_type_e

-

Node Type

+

The XML node type.

Values

@@ -58,52 +54,65 @@

mxmlAdd()

-

Add a node to a tree.

+

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.

Syntax

 void
 mxmlAdd(
-    mxml_node_t * parent,
+    mxml_node_t * parent,
     int where,
-    mxml_node_t * child,
-    mxml_node_t * node);
+    mxml_node_t * child,
+    mxml_node_t * node);
 

Arguments

NameDescription
- - + +
NameDescription
parentParent node
whereWhere to add
childChild node for where
whereWhere to add, MXML_ADD_BEFORE or MXML_ADD_AFTER
childChild node for where or MXML_ADD_TO_PARENT
nodeNode to add

Returns

Nothing.


mxmlDelete()

-

Delete a node and all of its children.

+

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.

Syntax

 void
 mxmlDelete(
-    mxml_node_t * node);
+    mxml_node_t * node);
 

Arguments

- +
NameDescription
nodeNode
nodeNode to delete

Returns

Nothing.


mxmlElementGetAttr()

-

Get an attribute.

+

Get an attribute. + +This function returns NULL if the node is not an element or the +named attribute does not exist.

Syntax

 const char *
 mxmlElementGetAttr(
-    mxml_node_t * node,
+    mxml_node_t * node,
     const char * name);
 

Arguments

@@ -117,12 +126,17 @@ mxmlElementGetAttr(

Attribute value or NULL


mxmlElementSetAttr()

-

Set an attribute.

+

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.

Syntax

 void
 mxmlElementSetAttr(
-    mxml_node_t * node,
+    mxml_node_t * node,
     const char * name,
     const char * value);
 
@@ -138,13 +152,22 @@ mxmlElementSetAttr(

Nothing.


mxmlFindElement()

-

Find the named element.

+

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.

Syntax

-mxml_node_t *
+mxml_node_t *
 mxmlFindElement(
-    mxml_node_t * node,
-    mxml_node_t * top,
+    mxml_node_t * node,
+    mxml_node_t * top,
     const char * name,
     const char * attr,
     const char * value,
@@ -159,20 +182,27 @@ mxmlFindElement(
 nameElement name or NULL for any
 attrAttribute name, or NULL for none
 valueAttribute value, or NULL for any
-descendDescend into tree?
+descendDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
 

Returns

Element node or NULL


mxmlLoadFile()

-

Load a file into an XML node tree.

+

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.

Syntax

-mxml_node_t *
+mxml_node_t *
 mxmlLoadFile(
-    mxml_node_t * top,
+    mxml_node_t * top,
     FILE * fp,
-    mxml_type_t (*cb)(mxml_node_t *));
+    mxml_type_t (*cb)(mxml_node_t *));
 

Arguments

@@ -180,94 +210,117 @@ mxmlLoadFile( - +
topTop node
fpFile to read from
(*cb)(mxml_node_t *)Callback function
(*cb)(mxml_node_t *)Callback function or MXML_NO_CALLBACK

Returns

-

First node

+

First node or NULL if the file could not be read.


mxmlNewElement()

-

Create a new element node.

+

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.

Syntax

-mxml_node_t *
+mxml_node_t *
 mxmlNewElement(
-    mxml_node_t * parent,
+    mxml_node_t * parent,
     const char * name);
 

Arguments

- +
NameDescription
parentParent node
parentParent node or MXML_NO_PARENT
nameName of element

Returns

New node


mxmlNewInteger()

-

Create a new integer node.

+

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.

Syntax

-mxml_node_t *
+mxml_node_t *
 mxmlNewInteger(
-    mxml_node_t * parent,
+    mxml_node_t * parent,
     int integer);
 

Arguments

- +
NameDescription
parentParent node
parentParent node or MXML_NO_PARENT
integerInteger value

Returns

New node


mxmlNewOpaque()

-

Create a new opaque string.

+

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.

Syntax

-mxml_node_t *
+mxml_node_t *
 mxmlNewOpaque(
-    mxml_node_t * parent,
+    mxml_node_t * parent,
     const char * opaque);
 

Arguments

- +
NameDescription
parentParent node
parentParent node or MXML_NO_PARENT
opaqueOpaque string

Returns

New node


mxmlNewReal()

-

Create a new real number node.

+

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.

Syntax

-mxml_node_t *
+mxml_node_t *
 mxmlNewReal(
-    mxml_node_t * parent,
+    mxml_node_t * parent,
     double real);
 

Arguments

- +
NameDescription
parentParent node
parentParent node or MXML_NO_PARENT
realReal number value

Returns

New node


mxmlNewText()

-

Create a new text fragment node.

+

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.

Syntax

-mxml_node_t *
+mxml_node_t *
 mxmlNewText(
-    mxml_node_t * parent,
+    mxml_node_t * parent,
     int whitespace,
     const char * string);
 
@@ -275,20 +328,23 @@ mxmlNewText(

- - + +
NameDescription
parentParent node
whitespaceLeading whitespace?
parentParent node or MXML_NO_PARENT
whitespace1 = leading whitespace, 0 = no whitespace
stringString

Returns

New node


mxmlRemove()

-

Remove a node from its parent.

+

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.

Syntax

 void
 mxmlRemove(
-    mxml_node_t * node);
+    mxml_node_t * node);
 

Arguments

@@ -300,12 +356,18 @@ mxmlRemove(

Nothing.


mxmlSaveFile()

-

Save an XML tree to a file.

+

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.

Syntax

 int
 mxmlSaveFile(
-    mxml_node_t * node,
+    mxml_node_t * node,
     FILE * fp,
     int (*cb)(mxml_node_t *int));
 
@@ -315,19 +377,23 @@ mxmlSaveFile( - +
nodeNode to write
fpFile to write to
(*cb)(mxml_node_t *int)Whitespace callback
(*cb)(mxml_node_t *int)Whitespace callback or MXML_NO_CALLBACK

Returns

-

0 on success, -1 on error

+

0 on success, -1 on error.


mxmlWalkNext()

-

Walk to the next logical node in the tree.

+

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.

Syntax

-mxml_node_t *
+mxml_node_t *
 mxmlWalkNext(
-    mxml_node_t * node,
-    mxml_node_t * top,
+    mxml_node_t * node,
+    mxml_node_t * top,
     int descend);
 

Arguments

@@ -336,19 +402,23 @@ mxmlWalkNext( nodeCurrent node topTop node -descendDescend into tree? +descendDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST

Returns

Next node or NULL


mxmlWalkPrev()

-

Walk to the previous logical node in the tree.

+

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.

Syntax

-mxml_node_t *
+mxml_node_t *
 mxmlWalkPrev(
-    mxml_node_t * node,
-    mxml_node_t * top,
+    mxml_node_t * node,
+    mxml_node_t * top,
     int descend);
 

Arguments

@@ -357,7 +427,7 @@ mxmlWalkPrev( nodeCurrent node topTop node -descendDescend into tree? +descendDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST

Returns

Previous node or NULL

@@ -370,7 +440,7 @@ mxmlWalkPrev(

mxml_attr_s

-

Attribute Value

+

An XML element attribute value.

Definition

 struct mxml_attr_s
@@ -388,18 +458,18 @@ struct mxml_attr_s
 


mxml_node_s

-

Node

+

Data types...

Definition

 struct mxml_node_s
 {
-  mxml_node_t * child;
-  mxml_node_t * last_child;
-  mxml_node_t * next;
-  mxml_node_t * parent;
-  mxml_node_t * prev;
-  mxml_type_t type;
-  mxml_value_t value;
+  mxml_node_t * child;
+  mxml_node_t * last_child;
+  mxml_node_t * next;
+  mxml_node_t * parent;
+  mxml_node_t * prev;
+  mxml_type_t type;
+  mxml_value_t value;
 };
 

Members

@@ -416,7 +486,7 @@ struct mxml_node_s


mxml_text_s

-

Text Value

+

An XML text value.

Definition

 struct mxml_text_s
@@ -434,12 +504,12 @@ struct mxml_text_s
 


mxml_value_s

-

Element Value

+

An XML element value.

Definition

 struct mxml_value_s
 {
-  mxml_attr_t * attrs;
+  mxml_attr_t * attrs;
   char * name;
   int num_attrs;
 };
@@ -456,44 +526,52 @@ struct mxml_value_s
 
 

mxml_attr_t

-

Attribute Value

+

An XML element attribute value.

Definition

-typedef struct mxml_attr_s mxml_attr_t;
+typedef struct mxml_attr_s mxml_attr_t;
 

mxml_element_t

-

Element Value

+

An XML element value.

Definition

-typedef struct mxml_value_s mxml_element_t;
+typedef struct mxml_value_s mxml_element_t;
+
+
+

mxml_node_t

+

An XML node.

+

Definition

+
+typedef struct mxml_node_s mxml_node_t;
 

mxml_text_t

-

Text Value

+

An XML text value.

Definition

-typedef struct mxml_text_s mxml_text_t;
+typedef struct mxml_text_s mxml_text_t;
 

mxml_type_t

-

Node Type

+

The XML node type.

Definition

-typedef enum mxml_type_e mxml_type_t;
+typedef enum mxml_type_e mxml_type_t;
 

mxml_value_t

-

Node Value

+

An XML node value.

Definition

-typedef union mxml_value_u mxml_value_t;
+typedef union mxml_value_u mxml_value_t;
 

Unions

    @@ -501,16 +579,16 @@ typedef union mxml_value_u mxml_value_t;

mxml_value_u

-

Node Value

+

An XML node value.

Definition

 struct mxml_value_u
 {
-  mxml_element_t element;
+  mxml_element_t element;
   int integer;
   char * opaque;
   double real;
-  mxml_text_t text;
+  mxml_text_t text;
 };
 

Members

diff --git a/mxml-attr.c b/mxml-attr.c index 661ab02..c8efcf1 100644 --- a/mxml-attr.c +++ b/mxml-attr.c @@ -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. * @@ -30,6 +30,9 @@ /* * '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 */ @@ -67,6 +70,11 @@ mxmlElementGetAttr(mxml_node_t *node, /* I - Element node */ /* * '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 @@ -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 $". */ diff --git a/mxml-file.c b/mxml-file.c index e99f516..5ef26ef 100644 --- a/mxml-file.c +++ b/mxml-file.c @@ -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. * @@ -46,13 +46,20 @@ static int mxml_write_ws(mxml_node_t *node, FILE *fp, /* * '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 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 */ FILE *fp, /* I - File to read from */ mxml_type_t (*cb)(mxml_node_t *)) - /* I - Callback function */ + /* I - Callback function or MXML_NO_CALLBACK */ { mxml_node_t *node, /* Current 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. + * + * 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 */ FILE *fp, /* I - File to write to */ int (*cb)(mxml_node_t *, int)) - /* I - Whitespace callback */ + /* I - Whitespace callback or MXML_NO_CALLBACK */ { 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 $". */ diff --git a/mxml-node.c b/mxml-node.c index 05f3995..7f974d9 100644 --- a/mxml-node.c +++ b/mxml-node.c @@ -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. * @@ -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. + * + * 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 mxmlAdd(mxml_node_t *parent, /* I - Parent node */ - int where, /* I - Where to add */ - mxml_node_t *child, /* I - Child node for where */ + int where, /* I - Where to add, MXML_ADD_BEFORE or MXML_ADD_AFTER */ + mxml_node_t *child, /* I - Child node for where or MXML_ADD_TO_PARENT */ mxml_node_t *node) /* I - Node to add */ { /* 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. + * + * If the specified node has a parent, this function first removes the + * node from its parent using the mxmlRemove() function. */ void -mxmlDelete(mxml_node_t *node) /* I - Node */ +mxmlDelete(mxml_node_t *node) /* I - Node to delete */ { int i; /* Looping var */ @@ -230,10 +240,14 @@ mxmlDelete(mxml_node_t *node) /* I - 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 */ -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 */ { mxml_node_t *node; /* New node */ @@ -259,10 +273,14 @@ mxmlNewElement(mxml_node_t *parent, /* I - Parent 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 */ -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 */ { mxml_node_t *node; /* New node */ @@ -288,10 +306,15 @@ mxmlNewInteger(mxml_node_t *parent, /* I - Parent node */ /* * '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 */ -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 */ { 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. + * + * 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 */ -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 */ { 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. + * + * 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 */ -mxmlNewText(mxml_node_t *parent, /* I - Parent node */ - int whitespace, /* I - Leading whitespace? */ +mxmlNewText(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */ + int whitespace, /* I - 1 = leading whitespace, 0 = no whitespace */ const char *string) /* I - String */ { 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. + * + * Does not free memory used by the node - use mxmlDelete() for that. + * This function does nothing if the node has no parent. */ 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 $". */ diff --git a/mxml-search.c b/mxml-search.c index 307724d..0d9ca6e 100644 --- a/mxml-search.c +++ b/mxml-search.c @@ -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 * parsing library. @@ -32,6 +32,15 @@ /* * '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 */ @@ -40,7 +49,7 @@ mxmlFindElement(mxml_node_t *node, /* I - Current node */ const char *name, /* I - Element name or NULL for any */ const char *attr, /* I - Attribute name, or NULL for none */ 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 */ @@ -110,12 +119,16 @@ mxmlFindElement(mxml_node_t *node, /* I - Current node */ /* * '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 */ mxmlWalkNext(mxml_node_t *node, /* I - Current 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) return (NULL); @@ -142,12 +155,16 @@ mxmlWalkNext(mxml_node_t *node, /* I - Current node */ /* * '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 */ mxmlWalkPrev(mxml_node_t *node, /* I - Current 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) 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 $". */ diff --git a/mxml.h b/mxml.h index d81a2c8..15ba7ba 100644 --- a/mxml.h +++ b/mxml.h @@ -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. * @@ -62,7 +62,7 @@ * 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_INTEGER, /* Integer value */ @@ -71,26 +71,26 @@ typedef enum mxml_type_e /**** Node Type ****/ MXML_TEXT /* Text fragment */ } 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 *value; /* Attribute value */ } mxml_attr_t; -typedef struct mxml_value_s /**** Element Value ****/ +typedef struct mxml_value_s /**** An XML element value. ****/ { char *name; /* Name of element */ int num_attrs; /* Number of attributes */ mxml_attr_t *attrs; /* Attributes */ } mxml_element_t; -typedef struct mxml_text_s /**** Text Value ****/ +typedef struct mxml_text_s /**** An XML text value. ****/ { int whitespace; /* Leading whitespace? */ char *string; /* Fragment string */ } mxml_text_t; -typedef union mxml_value_u /**** Node Value ****/ +typedef union mxml_value_u /**** An XML node value. ****/ { mxml_element_t element; /* Element */ int integer; /* Integer number */ @@ -99,9 +99,9 @@ typedef union mxml_value_u /**** Node Value ****/ mxml_text_t text; /* Text fragment */ } 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_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 $". */ diff --git a/mxml.xml b/mxml.xml index 499c8a7..9321dfa 100644 --- a/mxml.xml +++ b/mxml.xml @@ -1,104 +1,178 @@ -Add a node to a tree.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.mxml_node_t *Parent node -intWhere to add -mxml_node_t *Child node for where +intWhere to add, MXML_ADD_BEFORE or MXML_ADD_AFTER +mxml_node_t *Child node for where or MXML_ADD_TO_PARENT mxml_node_t *Node to add -Delete a node and all of its children.mxml_node_t *Node +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.mxml_node_t *Node to delete Attribute value or NULLconst char * -Get an attribute.mxml_node_t *Element node +Get an attribute. + +This function returns NULL if the node is not an element or the +named attribute does not exist.mxml_node_t *Element node const char *Name of attribute -Set an attribute.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.mxml_node_t *Element node const char *Name of attribute const char *Attribute value Element node or NULLmxml_node_t * -Find the named element.mxml_node_t *Current node +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 *Current node mxml_node_t *Top node const char *Element name or NULL for any const char *Attribute name, or NULL for none const char *Attribute value, or NULL for any -intDescend into tree? +intDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST -First nodemxml_node_t +First node or NULL if the file could not be read.mxml_node_t * -Load a file into an XML node tree.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 *Top node FILE *File to read from -mxml_type_tCallback function +mxml_type_tCallback function or MXML_NO_CALLBACK New nodemxml_node_t * -Create a new element node.mxml_node_t *Parent node +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 *Parent node or MXML_NO_PARENT const char *Name of element New nodemxml_node_t * -Create a new integer node.mxml_node_t *Parent node +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 *Parent node or MXML_NO_PARENT intInteger value New nodemxml_node_t * -Create a new opaque string.mxml_node_t *Parent node +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 *Parent node or MXML_NO_PARENT const char *Opaque string New nodemxml_node_t * -Create a new real number node.mxml_node_t *Parent node +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 *Parent node or MXML_NO_PARENT doubleReal number value New nodemxml_node_t * -Create a new text fragment node.mxml_node_t *Parent node -intLeading whitespace? +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 *Parent node or MXML_NO_PARENT +int1 = leading whitespace, 0 = no whitespace const char *String -Remove a node from its parent.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.mxml_node_t *Node to remove -0 on success, -1 on errorint -Save an XML tree to a file.0 on success, -1 on error.int +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.mxml_node_t *Node to write FILE *File to write to -intWhitespace callback +intWhitespace callback or MXML_NO_CALLBACK Next node or NULLmxml_node_t * -Walk to the next logical node in the tree.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 *Current node mxml_node_t *Top node -intDescend into tree? +intDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST Previous node or NULLmxml_node_t * -Walk to the previous logical node in the tree.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 *Current node mxml_node_t *Top node -intDescend into tree? +intDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST -Attribute ValueAn XML element attribute value.char *Attribute name char *Attribute value -Attribute Valuestruct +An XML element attribute value.struct mxml_attr_s -Element Valuestruct +An XML element value.struct mxml_value_s -NodeData types...mxml_node_t *First child node mxml_node_t *Last child node mxml_node_t *Next node under same parent @@ -107,29 +181,30 @@ name="child">mxml_node_t *First child nodemxml_type_tNode type mxml_value_tNode value -Text Valuestruct mxml_node_sAn XML node.An XML node. +An XML text value.char *Fragment string intLeading whitespace? -Text Valuestruct +An XML text value.struct mxml_text_s -Node TypeThe XML node type.XML element with attributes Integer value Opaque string Real value Text fragment -Node Typeenum +The XML node type.enum mxml_type_e -Element ValueAn XML element value.mxml_attr_t *Attributes char *Name of element intNumber of attributes -Node Valueunion +An XML node value.union mxml_value_u -Node ValueAn XML node value.mxml_element_tElement intInteger number char *Opaque string diff --git a/mxmldoc.c b/mxmldoc.c index 57d6cec..9093b09 100644 --- a/mxmldoc.c +++ b/mxmldoc.c @@ -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 * 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, mxml_node_t *comment); 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 int ws_cb(mxml_node_t *node, int where); @@ -475,7 +475,7 @@ scan_file(const char *filename, /* I - Filename */ type = NULL; } - if (typedefnode) + if (typedefnode && comment->last_child) { /* * Copy comment for typedef as well as class/struct/union... @@ -507,6 +507,7 @@ scan_file(const char *filename, /* I - Filename */ #ifdef DEBUG fputs(" ended typedef...\n", stderr); #endif /* DEBUG */ + structclass = NULL; break; } else if (type && type->child && type->child->next && @@ -553,7 +554,7 @@ scan_file(const char *filename, /* I - Filename */ type = NULL; } - if (typedefnode) + if (typedefnode && comment->last_child) { /* * Copy comment for typedef as well as class/struct/union... @@ -596,6 +597,7 @@ scan_file(const char *filename, /* I - Filename */ enumeration = NULL; constant = NULL; + structclass = NULL; if (braces > 0) braces --; @@ -736,6 +738,16 @@ scan_file(const char *filename, /* I - Filename */ update_comment(constant, 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") && !mxmlFindElement(tree, tree, "description", NULL, NULL, MXML_DESCEND_FIRST)) @@ -821,6 +833,16 @@ scan_file(const char *filename, /* I - Filename */ update_comment(constant, 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") && !mxmlFindElement(tree, tree, "description", NULL, NULL, MXML_DESCEND_FIRST)) @@ -889,6 +911,16 @@ scan_file(const char *filename, /* I - Filename */ update_comment(constant, 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") && !mxmlFindElement(tree, tree, "description", NULL, NULL, MXML_DESCEND_FIRST)) @@ -1058,8 +1090,10 @@ scan_file(const char *filename, /* I - Filename */ if (structclass && !mxmlElementGetAttr(structclass, "name")) { +#ifdef DEBUG fprintf(stderr, "setting struct/class name to %s!\n", type->last_child->value.text.string); +#endif /* DEBUG */ mxmlElementSetAttr(structclass, "name", buffer); sort_node(tree, structclass); @@ -1075,6 +1109,29 @@ scan_file(const char *filename, /* I - Filename */ type = 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) { /* @@ -1346,261 +1403,279 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */ puts("

Contents

"); puts("
    "); - puts("\t
  • Classes
  • "); - puts("\t
  • Enumeration
  • "); - puts("\t
  • Functions
  • "); - puts("\t
  • Structures
  • "); - puts("\t
  • Types
  • "); - puts("\t
  • Unions
  • "); + if (mxmlFindElement(doc, doc, "class", NULL, NULL, MXML_DESCEND_FIRST)) + puts("\t
  • Classes
  • "); + if (mxmlFindElement(doc, doc, "enumeration", NULL, NULL, MXML_DESCEND_FIRST)) + puts("\t
  • Enumeration
  • "); + if (mxmlFindElement(doc, doc, "function", NULL, NULL, MXML_DESCEND_FIRST)) + puts("\t
  • Functions
  • "); + if (mxmlFindElement(doc, doc, "struct", NULL, NULL, MXML_DESCEND_FIRST)) + puts("\t
  • Structures
  • "); + if (mxmlFindElement(doc, doc, "typedef", NULL, NULL, MXML_DESCEND_FIRST)) + puts("\t
  • Types
  • "); + if (mxmlFindElement(doc, doc, "union", NULL, NULL, MXML_DESCEND_FIRST)) + puts("\t
  • Unions
  • "); + if (mxmlFindElement(doc, doc, "variable", NULL, NULL, MXML_DESCEND_FIRST)) + puts("\t
  • Variables
  • "); puts("
"); /* * List of classes... */ - puts("

Classes

"); - puts("
    "); - - for (scut = mxmlFindElement(doc, doc, "class", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "class", NULL, NULL, - MXML_NO_DESCEND)) + if (mxmlFindElement(doc, doc, "class", NULL, NULL, MXML_DESCEND_FIRST)) { - name = mxmlElementGetAttr(scut, "name"); - printf("\t
  • %s
  • \n", name, name); - } + puts("

    Classes

    "); + puts("
      "); - puts("
    "); - - for (scut = mxmlFindElement(doc, doc, "class", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "class", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(scut, "name"); - puts("
    "); - printf("

    %s

    \n", name, name); - - description = mxmlFindElement(scut, scut, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) + for (scut = mxmlFindElement(doc, doc, "class", NULL, NULL, + MXML_DESCEND_FIRST); + scut; + scut = mxmlFindElement(scut, doc, "class", NULL, NULL, + MXML_NO_DESCEND)) { - fputs("

    ", stdout); - write_element(description); - puts("

    "); + name = mxmlElementGetAttr(scut, "name"); + printf("\t
  • %s
  • \n", name, name); } - puts("

    Definition

    "); - puts("
    ");
    +    puts("
"); - printf("struct %s\n{\n", name); - for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, - MXML_NO_DESCEND)) + for (scut = mxmlFindElement(doc, doc, "class", NULL, NULL, + MXML_DESCEND_FIRST); + scut; + scut = mxmlFindElement(scut, doc, "class", NULL, NULL, + MXML_NO_DESCEND)) { - printf(" "); - write_element(mxmlFindElement(arg, arg, "type", NULL, - NULL, MXML_DESCEND_FIRST)); - printf(" %s;\n", mxmlElementGetAttr(arg, "name")); + name = mxmlElementGetAttr(scut, "name"); + puts("
"); + printf("

%s

\n", name, name); + + description = mxmlFindElement(scut, scut, "description", NULL, + NULL, MXML_DESCEND_FIRST); + if (description) + { + fputs("

", stdout); + write_element(NULL, description); + puts("

"); + } + + puts("

Definition

"); + puts("
");
+
+      printf("struct %s\n{\n", name);
+      for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
+                        	 MXML_DESCEND_FIRST);
+	   arg;
+	   arg = mxmlFindElement(arg, scut, "variable", NULL, NULL,
+                        	 MXML_NO_DESCEND))
+      {
+	printf("  ");
+	write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
+                                           NULL, MXML_DESCEND_FIRST));
+	printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
+      }
+
+      puts("};\n
"); + + puts("

Members

"); + + puts("

"); + puts(""); + puts(""); + + for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, + MXML_DESCEND_FIRST); + arg; + arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, + MXML_NO_DESCEND)) + { + printf(""); + } + + puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); + + write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST)); + + puts("

"); } - - puts("};\n
"); - - puts("

Members

"); - - puts("

"); - puts(""); - puts(""); - - for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, - MXML_NO_DESCEND)) - { - printf(""); - } - - puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); - - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - - puts("

"); } /* * List of enumerations... */ - puts("

Enumerations

"); - puts("
    "); - - for (scut = mxmlFindElement(doc, doc, "enumeration", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "enumeration", NULL, NULL, - MXML_NO_DESCEND)) + if (mxmlFindElement(doc, doc, "enumeration", NULL, NULL, MXML_DESCEND_FIRST)) { - name = mxmlElementGetAttr(scut, "name"); - printf("\t
  • %s
  • \n", name, name); - } + puts("

    Enumerations

    "); + puts("
      "); - puts("
    "); - - for (scut = mxmlFindElement(doc, doc, "enumeration", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "enumeration", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(scut, "name"); - puts("
    "); - printf("

    %s

    \n", name, name); - - description = mxmlFindElement(scut, scut, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) + for (scut = mxmlFindElement(doc, doc, "enumeration", NULL, NULL, + MXML_DESCEND_FIRST); + scut; + scut = mxmlFindElement(scut, doc, "enumeration", NULL, NULL, + MXML_NO_DESCEND)) { - fputs("

    ", stdout); - write_element(description); - puts("

    "); + name = mxmlElementGetAttr(scut, "name"); + printf("\t
  • %s
  • \n", name, name); } - puts("

    Values

    "); + puts("
"); - puts("

"); - puts(""); - puts(""); - - for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "constant", NULL, NULL, - MXML_NO_DESCEND)) + for (scut = mxmlFindElement(doc, doc, "enumeration", NULL, NULL, + MXML_DESCEND_FIRST); + scut; + scut = mxmlFindElement(scut, doc, "enumeration", NULL, NULL, + MXML_NO_DESCEND)) { - printf(""); - } + puts("

Values

"); - puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); + name = mxmlElementGetAttr(scut, "name"); + puts("
"); + printf("

%s

\n", name, name); - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); + description = mxmlFindElement(scut, scut, "description", NULL, + NULL, MXML_DESCEND_FIRST); + if (description) + { + fputs("

", stdout); + write_element(NULL, description); + puts("

"); + } - puts("

"); - } - /* - * List of functions... - */ - - puts("

Functions

"); - puts("
    "); - - for (function = mxmlFindElement(doc, doc, "function", NULL, NULL, - MXML_DESCEND_FIRST); - function; - function = mxmlFindElement(function, doc, "function", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(function, "name"); - printf("\t
  • %s()
  • \n", name, name); - } - - puts("
"); - - for (function = mxmlFindElement(doc, doc, "function", NULL, NULL, - MXML_DESCEND_FIRST); - function; - function = mxmlFindElement(function, doc, "function", NULL, NULL, - MXML_NO_DESCEND)) - { - name = mxmlElementGetAttr(function, "name"); - puts("
"); - printf("

%s()

\n", name, name); - - description = mxmlFindElement(function, function, "description", NULL, - NULL, MXML_DESCEND_FIRST); - if (description) - { - fputs("

", stdout); - write_element(description); - puts("

"); - } - - puts("

Syntax

"); - puts("
");
-
-    arg = mxmlFindElement(function, function, "returnvalue", NULL,
-                          NULL, MXML_DESCEND_FIRST);
-
-    if (arg)
-      write_element(mxmlFindElement(arg, arg, "type", NULL,
-                                    NULL, MXML_DESCEND_FIRST));
-    else
-      fputs("void", stdout);
-
-    printf("\n%s", name);
-    for (arg = mxmlFindElement(function, function, "argument", NULL, NULL,
-                               MXML_DESCEND_FIRST), prefix = '(';
-	 arg;
-	 arg = mxmlFindElement(arg, function, "argument", NULL, NULL,
-                               MXML_NO_DESCEND), prefix = ',')
-    {
-      printf("%c\n    ", prefix);
-      write_element(mxmlFindElement(arg, arg, "type", NULL,
-                                    NULL, MXML_DESCEND_FIRST));
-      printf(" %s", mxmlElementGetAttr(arg, "name"));
-    }
-
-    if (prefix == '(')
-      puts("(void);\n
"); - else - puts(");\n
"); - - puts("

Arguments

"); - - if (prefix == '(') - puts("

None.

"); - else - { puts("

"); puts(""); puts(""); - for (arg = mxmlFindElement(function, function, "argument", NULL, NULL, + for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL, MXML_DESCEND_FIRST); arg; - arg = mxmlFindElement(arg, function, "argument", NULL, NULL, + arg = mxmlFindElement(arg, scut, "constant", NULL, NULL, MXML_NO_DESCEND)) { printf(""); + puts(""); } puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); + write_element(doc, mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST)); - puts("

"); } + } - puts("

Returns

"); + /* + * List of functions... + */ - arg = mxmlFindElement(function, function, "returnvalue", NULL, - NULL, MXML_DESCEND_FIRST); + if (mxmlFindElement(doc, doc, "function", NULL, NULL, MXML_DESCEND_FIRST)) + { + puts("

Functions

"); + puts("
    "); - if (!arg) - puts("

    Nothing.

    "); - else + for (function = mxmlFindElement(doc, doc, "function", NULL, NULL, + MXML_DESCEND_FIRST); + function; + function = mxmlFindElement(function, doc, "function", NULL, NULL, + MXML_NO_DESCEND)) { - fputs("

    ", stdout); - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - puts("

    "); + name = mxmlElementGetAttr(function, "name"); + printf("\t
  • %s()
  • \n", name, name); + } + + puts("
"); + + for (function = mxmlFindElement(doc, doc, "function", NULL, NULL, + MXML_DESCEND_FIRST); + function; + function = mxmlFindElement(function, doc, "function", NULL, NULL, + MXML_NO_DESCEND)) + { + name = mxmlElementGetAttr(function, "name"); + puts("
"); + printf("

%s()

\n", name, name); + + description = mxmlFindElement(function, function, "description", NULL, + NULL, MXML_DESCEND_FIRST); + if (description) + { + fputs("

", stdout); + write_element(NULL, description); + puts("

"); + } + + puts("

Syntax

"); + puts("
");
+
+      arg = mxmlFindElement(function, function, "returnvalue", NULL,
+                            NULL, MXML_DESCEND_FIRST);
+
+      if (arg)
+	write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
+                                           NULL, MXML_DESCEND_FIRST));
+      else
+	fputs("void", stdout);
+
+      printf("\n%s", name);
+      for (arg = mxmlFindElement(function, function, "argument", NULL, NULL,
+                        	 MXML_DESCEND_FIRST), prefix = '(';
+	   arg;
+	   arg = mxmlFindElement(arg, function, "argument", NULL, NULL,
+                        	 MXML_NO_DESCEND), prefix = ',')
+      {
+	printf("%c\n    ", prefix);
+	write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
+                                           NULL, MXML_DESCEND_FIRST));
+	printf(" %s", mxmlElementGetAttr(arg, "name"));
+      }
+
+      if (prefix == '(')
+	puts("(void);\n
"); + else + puts(");\n
"); + + puts("

Arguments

"); + + if (prefix == '(') + puts("

None.

"); + else + { + puts("

"); + puts(""); + puts(""); + + for (arg = mxmlFindElement(function, function, "argument", NULL, NULL, + MXML_DESCEND_FIRST); + arg; + arg = mxmlFindElement(arg, function, "argument", NULL, NULL, + MXML_NO_DESCEND)) + { + printf(""); + } + + puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); + + write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST)); + + puts("

"); + } + + puts("

Returns

"); + + arg = mxmlFindElement(function, function, "returnvalue", NULL, + NULL, MXML_DESCEND_FIRST); + + if (!arg) + puts("

Nothing.

"); + else + { + fputs("

", stdout); + write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST)); + puts("

"); + } } } @@ -1608,205 +1683,265 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */ * List of structures... */ - puts("

Structures

"); - puts(""); - printf("struct %s\n{\n", name); - for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, - MXML_NO_DESCEND)) + for (scut = mxmlFindElement(doc, doc, "struct", NULL, NULL, + MXML_DESCEND_FIRST); + scut; + scut = mxmlFindElement(scut, doc, "struct", NULL, NULL, + MXML_NO_DESCEND)) { - printf(" "); - write_element(mxmlFindElement(arg, arg, "type", NULL, - NULL, MXML_DESCEND_FIRST)); - printf(" %s;\n", mxmlElementGetAttr(arg, "name")); + name = mxmlElementGetAttr(scut, "name"); + puts("
"); + printf("

%s

\n", name, name); + + description = mxmlFindElement(scut, scut, "description", NULL, + NULL, MXML_DESCEND_FIRST); + if (description) + { + fputs("

", stdout); + write_element(NULL, description); + puts("

"); + } + + puts("

Definition

"); + puts("
");
+
+      printf("struct %s\n{\n", name);
+      for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
+                        	 MXML_DESCEND_FIRST);
+	   arg;
+	   arg = mxmlFindElement(arg, scut, "variable", NULL, NULL,
+                        	 MXML_NO_DESCEND))
+      {
+	printf("  ");
+	write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
+                                           NULL, MXML_DESCEND_FIRST));
+	printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
+      }
+
+      puts("};\n
"); + + puts("

Members

"); + + puts("

"); + puts(""); + puts(""); + + for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, + MXML_DESCEND_FIRST); + arg; + arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, + MXML_NO_DESCEND)) + { + printf(""); + } + + puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); + + write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST)); + + puts("

"); } - - puts("};\n
"); - - puts("

Members

"); - - puts("

"); - puts(""); - puts(""); - - for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, - MXML_NO_DESCEND)) - { - printf(""); - } - - puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); - - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - - puts("

"); } /* * List of types... */ - puts("

Types

"); - puts(""); - printf("typedef "); - write_element(mxmlFindElement(scut, scut, "type", NULL, - NULL, MXML_DESCEND_FIRST)); - printf(" %s;\n\n", name); + for (scut = mxmlFindElement(doc, doc, "typedef", NULL, NULL, + MXML_DESCEND_FIRST); + scut; + scut = mxmlFindElement(scut, doc, "typedef", NULL, NULL, + MXML_NO_DESCEND)) + { + name = mxmlElementGetAttr(scut, "name"); + puts("
"); + printf("

%s

\n", name, name); + + description = mxmlFindElement(scut, scut, "description", NULL, + NULL, MXML_DESCEND_FIRST); + if (description) + { + fputs("

", stdout); + write_element(NULL, description); + puts("

"); + } + + puts("

Definition

"); + puts("
");
+
+      printf("typedef ");
+      write_element(doc, mxmlFindElement(scut, scut, "type", NULL,
+                                         NULL, MXML_DESCEND_FIRST));
+      printf(" %s;\n
\n", name); + } } /* * List of unions... */ - puts("

Unions

"); - puts(""); + /* + * Variables... + */ - for (scut = mxmlFindElement(doc, doc, "union", NULL, NULL, - MXML_DESCEND_FIRST); - scut; - scut = mxmlFindElement(scut, doc, "union", NULL, NULL, - MXML_NO_DESCEND)) + if (mxmlFindElement(doc, doc, "variable", NULL, NULL, MXML_DESCEND_FIRST)) { - name = mxmlElementGetAttr(scut, "name"); - puts("
"); - printf("

%s

\n", name, name); + puts("

Variables

"); + puts(""); + + 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("
"); + printf("

%s

\n", name, name); + + description = mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST); + if (description) + { + fputs("

", stdout); + write_element(NULL, description); + puts("

"); + } + + puts("

Definition

"); + puts("
");
+
+      write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
+                                         NULL, MXML_DESCEND_FIRST));
       printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
+
+      puts("
"); } - - puts("};\n"); - - puts("

Members

"); - - puts("

"); - puts(""); - puts(""); - - for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, - MXML_NO_DESCEND)) - { - printf(""); - } - - puts("
NameDescription
%s", mxmlElementGetAttr(arg, "name")); - - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - - puts("

"); } /* @@ -1815,7 +1950,6 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */ puts(""); puts(""); - } @@ -1824,7 +1958,8 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */ */ 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 */ @@ -1837,7 +1972,25 @@ write_element(mxml_node_t *element) /* I - Element to write */ if (node->value.text.whitespace) putchar(' '); - write_string(node->value.text.string); + 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("value.text.string); + printf("\">"); + write_string(node->value.text.string); + printf(""); + } + else + 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 $". */