From 17200e8cfe4248d343041130581bc5d6eefd5a98 Mon Sep 17 00:00:00 2001
From: Michael R Sweet
Date: Sun, 28 Sep 2003 21:09:04 +0000
Subject: [PATCH] Move "set" methods in a separate file.
Add standard callback methods in a separate file.
Fix some bugs in mxmldoc...
---
CHANGES | 2 +
Makefile.in | 13 ++-
documentation.html | 266 +++++++++++++++++++++++----------------------
mxml-file.c | 12 +-
mxml-node.c | 196 +--------------------------------
mxml-private.c | 73 +++++++++++++
mxml-set.c | 224 ++++++++++++++++++++++++++++++++++++++
mxml.h | 28 +++--
mxml.xml | 156 +++++++++++++++-----------
mxmldoc.c | 42 ++++---
10 files changed, 586 insertions(+), 426 deletions(-)
create mode 100644 mxml-private.c
create mode 100644 mxml-set.c
diff --git a/CHANGES b/CHANGES
index 5f48d9a..8c994a3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,8 @@ CHANGES IN Mini-XML 1.2
- Added new formatted text methods mxmlNewTextf() and
mxmlSetTextf() to create/set a text node value using
printf-style formats.
+ - Added new standard callbacks for use with the mxmlLoad
+ functions.
- Updated the HTML documentation to include examples of
the walk and load function output.
- Added --with/without-ansi configure option to control
diff --git a/Makefile.in b/Makefile.in
index 53b7346..e276e5f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile.in,v 1.12 2003/09/28 12:44:39 mike Exp $"
+# "$Id: Makefile.in,v 1.13 2003/09/28 21:09:03 mike Exp $"
#
# Makefile for mini-XML, a small XML-like file parsing library.
#
@@ -75,8 +75,9 @@ MAN3EXT = @MAN3EXT@
#
DOCFILES = documentation.html README COPYING CHANGES
-LIBOBJS = mxml-attr.o mxml-file.o mxml-node.o mxml-search.o \
- mxml-string.o
+PUBLIBOBJS = mxml-attr.o mxml-file.o mxml-node.o mxml-search.o \
+ mxml-set.o
+LIBOBJS = $(PUBLIBOBJS) mxml-private.o mxml-string.o
OBJS = mxmldoc.o testmxml.o $(LIBOBJS)
TARGETS = libmxml.a mxmldoc mxml.$(CAT3EXT) mxmldoc.$(CAT1EXT) \
testmxml mxml.xml
@@ -225,9 +226,9 @@ testmxml.o: mxml.h
# mxml.xml
#
-mxml.xml: mxmldoc mxml.h $(LIBOBJS:.o=.c)
+mxml.xml: mxmldoc mxml.h $(PUBLIBOBJS:.o=.c)
$(RM) mxml.xml
- ./mxmldoc mxml.xml mxml.h $(LIBOBJS:.o=.c) >documentation.html
+ ./mxmldoc mxml.xml mxml.h $(PUBLIBOBJS:.o=.c) >documentation.html
#
@@ -238,5 +239,5 @@ $(OBJS): Makefile config.h
#
-# End of "$Id: Makefile.in,v 1.12 2003/09/28 12:44:39 mike Exp $".
+# End of "$Id: Makefile.in,v 1.13 2003/09/28 21:09:03 mike Exp $".
#
diff --git a/documentation.html b/documentation.html
index ebe22d4..092c82b 100644
--- a/documentation.html
+++ b/documentation.html
@@ -17,11 +17,11 @@
Types
Unions
+
-
The XML node type.
Values
@@ -34,6 +34,7 @@
MXML_REAL | Real value |
MXML_TEXT | Text fragment |
+
-
Add a node to a tree.
@@ -79,17 +76,22 @@ MXML_ADD_TO_PARENT can be used to specify a NULL child pointer.
void
mxmlAdd(
- mxml_node_t *parent, int where, mxml_node_t *child, mxml_node_t * node);
+ mxml_node_t * parent,
+ int where,
+ mxml_node_t * child,
+ mxml_node_t * node);
Arguments
Name | Description |
+parent | Parent node |
+where | Where to add, MXML_ADD_BEFORE or MXML_ADD_AFTER |
+child | Child node for where or MXML_ADD_TO_PARENT |
node | Node to add |
Returns
Nothing.
-
Delete a node and all of its children.
@@ -109,7 +111,6 @@ mxmlDelete(
Returns
Nothing.
-
Get an attribute.
@@ -119,17 +120,18 @@ named attribute does not exist.
const char *
mxmlElementGetAttr(
- mxml_node_t *node, const char * name);
+ mxml_node_t * node,
+ const char * name);
Arguments
Name | Description |
+node | Element node |
name | Name of attribute |
Returns
Attribute value or NULL
-
Set an attribute.
@@ -141,17 +143,20 @@ not an element.
void
mxmlElementSetAttr(
- mxml_node_t *node, const char *name, const char * value);
+ mxml_node_t * node,
+ const char * name,
+ const char * value);
Arguments
Name | Description |
+node | Element node |
+name | Name of attribute |
value | Attribute value |
Returns
Nothing.
-
Find the named element.
@@ -167,17 +172,26 @@ constrains the search to a particular node's children.
mxml_node_t *
mxmlFindElement(
- mxml_node_t *node, mxml_node_t *top, const char *name, const char *attr, const char *value, int descend);
+ mxml_node_t * node,
+ mxml_node_t * top,
+ const char * name,
+ const char * attr,
+ const char * value,
+ int descend);
Arguments
Name | Description |
+node | Current node |
+top | Top node |
+name | Element name or NULL for any |
+attr | Attribute name, or NULL for none |
+value | Attribute value, or NULL for any |
descend | Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST |
Returns
Element node or NULL
-
Load a file into an XML node tree.
@@ -186,22 +200,29 @@ 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_ELEMENT or MXML_TEXT nodes.
+
+The constants MXML_INTEGER_CALLBACK, MXML_OPAQUE_CALLBACK,
+MXML_REAL_CALLBACK, and MXML_TEXT_CALLBACK are defined for loading
+child nodes of the specified type.
Syntax
mxml_node_t *
mxmlLoadFile(
- mxml_node_t *top, FILE *fp, mxml_type_t (*cb)(mxml_node_t *node));
+ mxml_node_t * top,
+ FILE * fp,
+ mxml_type_t (*cb)(mxml_node_t *node));
Arguments
Name | Description |
+top | Top node |
+fp | File to read from |
(*cb)(mxml_node_t *node) | Callback function or MXML_NO_CALLBACK |
Returns
First node or NULL if the file could not be read.
-
Load a string into an XML node tree.
@@ -210,22 +231,29 @@ If no top node is provided, the XML string MUST be well-formed with a
single parent node like <?xml> for the entire string. 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_ELEMENT or MXML_TEXT nodes.
+
+The constants MXML_INTEGER_CALLBACK, MXML_OPAQUE_CALLBACK,
+MXML_REAL_CALLBACK, and MXML_TEXT_CALLBACK are defined for loading
+child nodes of the specified type.
Syntax
mxml_node_t *
mxmlLoadString(
- mxml_node_t *top, const char *s, mxml_type_t (*cb)(mxml_node_t *node));
+ mxml_node_t * top,
+ const char * s,
+ mxml_type_t (*cb)(mxml_node_t *node));
Arguments
Name | Description |
+top | Top node |
+s | String to load |
(*cb)(mxml_node_t *node) | Callback function or MXML_NO_CALLBACK |
Returns
First node or NULL if the string has errors.
-
Create a new element node.
@@ -236,17 +264,18 @@ element node has no parent.
mxml_node_t *
mxmlNewElement(
- mxml_node_t *parent, const char * name);
+ mxml_node_t * parent,
+ const char * name);
Arguments
Name | Description |
+parent | Parent node or MXML_NO_PARENT |
name | Name of element |
Returns
New node
-
Create a new integer node.
@@ -257,17 +286,18 @@ integer node has no parent.
mxml_node_t *
mxmlNewInteger(
- mxml_node_t *parent, int integer);
+ mxml_node_t * parent,
+ int integer);
Arguments
Name | Description |
+parent | Parent node or MXML_NO_PARENT |
integer | Integer value |
Returns
New node
-
Create a new opaque string.
@@ -279,17 +309,18 @@ is copied into the new node.
mxml_node_t *
mxmlNewOpaque(
- mxml_node_t *parent, const char * opaque);
+ mxml_node_t * parent,
+ const char * opaque);
Arguments
Name | Description |
+parent | Parent node or MXML_NO_PARENT |
opaque | Opaque string |
Returns
New node
-
Create a new real number node.
@@ -300,17 +331,18 @@ the new real number node has no parent.
mxml_node_t *
mxmlNewReal(
- mxml_node_t *parent, double real);
+ mxml_node_t * parent,
+ double real);
Arguments
Name | Description |
+parent | Parent node or MXML_NO_PARENT |
real | Real number value |
Returns
New node
-
Create a new text fragment node.
@@ -323,17 +355,20 @@ string must be nul-terminated and is copied into the new node.
mxml_node_t *
mxmlNewText(
- mxml_node_t *parent, int whitespace, const char * string);
+ mxml_node_t * parent,
+ int whitespace,
+ const char * string);
Arguments
Name | Description |
+parent | Parent node or MXML_NO_PARENT |
+whitespace | 1 = leading whitespace, 0 = no whitespace |
string | String |
Returns
New node
-
Create a new formatted text fragment node.
@@ -346,17 +381,22 @@ string must be nul-terminated and is formatted into the new node.
mxml_node_t *
mxmlNewTextf(
- mxml_node_t *parent, int whitespace, const char * format,);
+ mxml_node_t * parent,
+ int whitespace,
+ const char * format,
+ ...);
Arguments
Name | Description |
-format, | Additional args as needed |
+parent | Parent node or MXML_NO_PARENT |
+whitespace | 1 = leading whitespace, 0 = no whitespace |
+format | Printf-style frmat string |
+... | Additional args as needed |
Returns
New node
-
Remove a node from its parent.
@@ -376,7 +416,6 @@ mxmlRemove(
Returns
Nothing.
-
Save an XML node tree to an allocated string.
@@ -389,17 +428,18 @@ allocated.
char *
mxmlSaveAllocString(
- mxml_node_t *node, int (*cb)(mxml_node_t *node, int ws));
+ mxml_node_t * node,
+ int (*cb)(mxml_node_t *node, int ws));
Arguments
Name | Description |
+node | Node to write |
(*cb)(mxml_node_t *node, int ws) | Whitespace callback or MXML_NO_CALLBACK |
Returns
Allocated string or NULL
-
Save an XML tree to a file.
@@ -412,17 +452,20 @@ element tags.
int
mxmlSaveFile(
- mxml_node_t *node, FILE *fp, int (*cb)(mxml_node_t *node, int ws));
+ mxml_node_t * node,
+ FILE * fp,
+ int (*cb)(mxml_node_t *node, int ws));
Arguments
Name | Description |
+node | Node to write |
+fp | File to write to |
(*cb)(mxml_node_t *node, int ws) | Whitespace callback or MXML_NO_CALLBACK |
Returns
0 on success, -1 on error.
-
Save an XML node tree to a string.
@@ -433,131 +476,148 @@ into the specified buffer.
int
mxmlSaveString(
- mxml_node_t *node, char *buffer, int bufsize, int (*cb)(mxml_node_t *node, int ws));
+ mxml_node_t * node,
+ char * buffer,
+ int bufsize,
+ int (*cb)(mxml_node_t *node, int ws));
Arguments
Name | Description |
+node | Node to write |
+buffer | String buffer |
+bufsize | Size of string buffer |
(*cb)(mxml_node_t *node, int ws) | Whitespace callback or MXML_NO_CALLBACK |
Returns
Size of string
-
Set the name of an element node.
-If the node is not changed if it is not an element node.
+The node is not changed if it is not an element node.
Syntax
int
mxmlSetElement(
- mxml_node_t *node, const char * name);
+ mxml_node_t * node,
+ const char * name);
Arguments
Name | Description |
+node | Node to set |
name | New name string |
Returns
0 on success, -1 on failure
-
Set the value of an integer node.
-If the node is not changed if it is not an integer node.
+The node is not changed if it is not an integer node.
Syntax
int
mxmlSetInteger(
- mxml_node_t *node, int integer);
+ mxml_node_t * node,
+ int integer);
Arguments
Name | Description |
+node | Node to set |
integer | Integer value |
Returns
0 on success, -1 on failure
-
Set the value of an opaque node.
-If the node is not changed if it is not an opaque node.
+The node is not changed if it is not an opaque node.
Syntax
int
mxmlSetOpaque(
- mxml_node_t *node, const char * opaque);
+ mxml_node_t * node,
+ const char * opaque);
Arguments
Name | Description |
+node | Node to set |
opaque | Opaque string |
Returns
0 on success, -1 on failure
-
Set the value of a real number node.
-If the node is not changed if it is not a real number node.
+The node is not changed if it is not a real number node.
Syntax
int
mxmlSetReal(
- mxml_node_t *node, double real);
+ mxml_node_t * node,
+ double real);
Arguments
Name | Description |
+node | Node to set |
real | Real number value |
Returns
0 on success, -1 on failure
-
Set the value of a text node.
-If the node is not changed if it is not a text node.
+The node is not changed if it is not a text node.
Syntax
int
mxmlSetText(
- mxml_node_t *node, int whitespace, const char * string);
+ mxml_node_t * node,
+ int whitespace,
+ const char * string);
Arguments
Name | Description |
+node | Node to set |
+whitespace | 1 = leading whitespace, 0 = no whitespace |
string | String |
Returns
0 on success, -1 on failure
-
Set the value of a text node to a formatted string.
-If the node is not changed if it is not a text node.
+The node is not changed if it is not a text node.
Syntax
int
mxmlSetTextf(
- mxml_node_t *node, int whitespace, const char * format,);
+ mxml_node_t * node,
+ int whitespace,
+ const char * format,
+ ...);
Arguments
Name | Description |
-format, | Additional arguments as needed |
+node | Node to set |
+whitespace | 1 = leading whitespace, 0 = no whitespace |
+format | Printf-style format string |
+... | Additional arguments as needed |
Returns
0 on success, -1 on failure
-
Walk to the next logical node in the tree.
@@ -568,17 +628,20 @@ the node's children.
mxml_node_t *
mxmlWalkNext(
- mxml_node_t *node, mxml_node_t *top, int descend);
+ mxml_node_t * node,
+ mxml_node_t * top,
+ int descend);
Arguments
Name | Description |
+node | Current node |
+top | Top node |
descend | Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST |
Returns
Next node or NULL
-
Walk to the previous logical node in the tree.
@@ -589,67 +652,21 @@ the walk to the node's children.
mxml_node_t *
mxmlWalkPrev(
- mxml_node_t *node, mxml_node_t *top, int descend);
+ mxml_node_t * node,
+ mxml_node_t * top,
+ int descend);
Arguments
Name | Description |
+node | Current node |
+top | Top node |
descend | Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST |
Returns
Previous node or NULL
-
-Duplicate a string.
-Syntax
-
-char *
-mxml_strdup(
- const char * s);
-
-Arguments
-
-Name | Description |
-
-s | String to duplicate |
-
-Returns
-New string pointer
-
-
-Format and duplicate a string.
-Syntax
-
-char *
-mxml_strdupf(
- const char *format, va_list ap);
-
-Arguments
-
-Name | Description |
-
-ap | Pointer to additional arguments |
-
-Returns
-New string pointer
-
-
-Format a string into a fixed size buffer.
-Syntax
-
-int
-mxml_vsnprintf(
- char *buffer, size_t bufsize, const char *format, va_list ap);
-
-Arguments
-
-Name | Description |
-
-ap | Pointer to additional arguments |
-
-Returns
-Number of bytes formatted
-
An XML element attribute value.
Definition
@@ -675,18 +691,17 @@ struct mxml_attr_s
name | Attribute name |
value | Attribute value |
-
-Data types...
+An XML node.
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;
+ struct mxml_node_s * child;
+ struct mxml_node_s * last_child;
+ struct mxml_node_s * next;
+ struct mxml_node_s * parent;
+ struct mxml_node_s * prev;
mxml_type_t type;
mxml_value_t value;
};
@@ -703,7 +718,6 @@ struct mxml_node_s
type | Node type |
value | Node value |
-
An XML text value.
Definition
@@ -721,7 +735,6 @@ struct mxml_text_s
string | Fragment string |
whitespace | Leading whitespace? |
-
An XML element value.
Definition
@@ -741,6 +754,7 @@ struct mxml_value_s
name | Name of element |
num_attrs | Number of attributes |
+
-
An XML element attribute value.
Definition
typedef struct mxml_attr_s mxml_attr_t;
-
An XML element value.
Definition
typedef struct mxml_value_s mxml_element_t;
-
An XML node.
Definition
typedef struct mxml_node_s mxml_node_t;
-
An XML text value.
Definition
typedef struct mxml_text_s mxml_text_t;
-
The XML node type.
Definition
typedef enum mxml_type_e mxml_type_t;
-
An XML node value.
Definition
typedef union mxml_value_u mxml_value_t;
+
-
An XML node value.
Definition
diff --git a/mxml-file.c b/mxml-file.c
index 0bf0bbb..75124b1 100644
--- a/mxml-file.c
+++ b/mxml-file.c
@@ -1,5 +1,5 @@
/*
- * "$Id: mxml-file.c,v 1.20 2003/07/27 23:11:40 mike Exp $"
+ * "$Id: mxml-file.c,v 1.21 2003/09/28 21:09:04 mike Exp $"
*
* File loading code for mini-XML, a small XML-like file parsing library.
*
@@ -75,6 +75,10 @@ static int mxml_write_ws(mxml_node_t *node, void *p,
* 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.
+ *
+ * The constants MXML_INTEGER_CALLBACK, MXML_OPAQUE_CALLBACK,
+ * MXML_REAL_CALLBACK, and MXML_TEXT_CALLBACK are defined for loading
+ * child nodes of the specified type.
*/
mxml_node_t * /* O - First node or NULL if the file could not be read. */
@@ -96,6 +100,10 @@ mxmlLoadFile(mxml_node_t *top, /* I - Top node */
* 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.
+ *
+ * The constants MXML_INTEGER_CALLBACK, MXML_OPAQUE_CALLBACK,
+ * MXML_REAL_CALLBACK, and MXML_TEXT_CALLBACK are defined for loading
+ * child nodes of the specified type.
*/
mxml_node_t * /* O - First node or NULL if the string has errors. */
@@ -1432,5 +1440,5 @@ mxml_write_ws(mxml_node_t *node, /* I - Current node */
/*
- * End of "$Id: mxml-file.c,v 1.20 2003/07/27 23:11:40 mike Exp $".
+ * End of "$Id: mxml-file.c,v 1.21 2003/09/28 21:09:04 mike Exp $".
*/
diff --git a/mxml-node.c b/mxml-node.c
index 9e40a2e..dba6552 100644
--- a/mxml-node.c
+++ b/mxml-node.c
@@ -1,5 +1,5 @@
/*
- * "$Id: mxml-node.c,v 1.8 2003/09/28 12:44:39 mike Exp $"
+ * "$Id: mxml-node.c,v 1.9 2003/09/28 21:09:04 mike Exp $"
*
* Node support code for mini-XML, a small XML-like file parsing library.
*
@@ -26,12 +26,6 @@
* mxmlNewText() - Create a new text fragment node.
* mxmlNewTextf() - Create a new formatted text fragment node.
* mxmlRemove() - Remove a node from its parent.
- * mxmlSetElement() - Set the name of an element node.
- * mxmlSetInteger() - Set the value of an integer node.
- * mxmlSetOpaque() - Set the value of an opaque node.
- * mxmlSetReal() - Set the value of a real number node.
- * mxmlSetText() - Set the value of a text node.
- * mxmlSetTextf() - Set the value of a text node to a formatted string.
* mxml_new() - Create a new node.
*/
@@ -502,192 +496,6 @@ mxmlRemove(mxml_node_t *node) /* I - Node to remove */
}
-/*
- * 'mxmlSetElement()' - Set the name of an element node.
- *
- * If the node is not changed if it is not an element node.
- */
-
-int /* O - 0 on success, -1 on failure */
-mxmlSetElement(mxml_node_t *node, /* I - Node to set */
- const char *name) /* I - New name string */
-{
- /*
- * Range check input...
- */
-
- if (!node || node->type != MXML_ELEMENT || !name)
- return (-1);
-
- /*
- * Free any old element value and set the new value...
- */
-
- if (node->value.element.name)
- free(node->value.element.name);
-
- node->value.element.name = strdup(name);
-
- return (0);
-}
-
-
-/*
- * 'mxmlSetInteger()' - Set the value of an integer node.
- *
- * If the node is not changed if it is not an integer node.
- */
-
-int /* O - 0 on success, -1 on failure */
-mxmlSetInteger(mxml_node_t *node, /* I - Node to set */
- int integer) /* I - Integer value */
-{
- /*
- * Range check input...
- */
-
- if (!node || node->type != MXML_INTEGER)
- return (-1);
-
- /*
- * Set the new value and return...
- */
-
- node->value.integer = integer;
-
- return (0);
-}
-
-
-/*
- * 'mxmlSetOpaque()' - Set the value of an opaque node.
- *
- * If the node is not changed if it is not an opaque node.
- */
-
-int /* O - 0 on success, -1 on failure */
-mxmlSetOpaque(mxml_node_t *node, /* I - Node to set */
- const char *opaque) /* I - Opaque string */
-{
- /*
- * Range check input...
- */
-
- if (!node || node->type != MXML_OPAQUE || !opaque)
- return (-1);
-
- /*
- * Free any old opaque value and set the new value...
- */
-
- if (node->value.opaque)
- free(node->value.opaque);
-
- node->value.opaque = strdup(opaque);
-
- return (0);
-}
-
-
-/*
- * 'mxmlSetReal()' - Set the value of a real number node.
- *
- * If the node is not changed if it is not a real number node.
- */
-
-int /* O - 0 on success, -1 on failure */
-mxmlSetReal(mxml_node_t *node, /* I - Node to set */
- double real) /* I - Real number value */
-{
- /*
- * Range check input...
- */
-
- if (!node || node->type != MXML_REAL)
- return (-1);
-
- /*
- * Set the new value and return...
- */
-
- node->value.real = real;
-
- return (0);
-}
-
-
-/*
- * 'mxmlSetText()' - Set the value of a text node.
- *
- * If the node is not changed if it is not a text node.
- */
-
-int /* O - 0 on success, -1 on failure */
-mxmlSetText(mxml_node_t *node, /* I - Node to set */
- int whitespace, /* I - 1 = leading whitespace, 0 = no whitespace */
- const char *string) /* I - String */
-{
- /*
- * Range check input...
- */
-
- if (!node || node->type != MXML_TEXT || !string)
- return (-1);
-
- /*
- * Free any old string value and set the new value...
- */
-
- if (node->value.text.string)
- free(node->value.text.string);
-
- node->value.text.whitespace = whitespace;
- node->value.text.string = strdup(string);
-
- return (0);
-}
-
-
-/*
- * 'mxmlSetTextf()' - Set the value of a text node to a formatted string.
- *
- * If the node is not changed if it is not a text node.
- */
-
-int /* O - 0 on success, -1 on failure */
-mxmlSetTextf(mxml_node_t *node, /* I - Node to set */
- int whitespace, /* I - 1 = leading whitespace, 0 = no whitespace */
- const char *format, /* I - Printf-style format string */
- ...) /* I - Additional arguments as needed */
-{
- va_list ap; /* Pointer to arguments */
-
-
- /*
- * Range check input...
- */
-
- if (!node || node->type != MXML_TEXT || !format)
- return (-1);
-
- /*
- * Free any old string value and set the new value...
- */
-
- if (node->value.text.string)
- free(node->value.text.string);
-
- va_start(ap, format);
-
- node->value.text.whitespace = whitespace;
- node->value.text.string = mxml_strdupf(format, ap);
-
- va_end(ap);
-
- return (0);
-}
-
-
/*
* 'mxml_new()' - Create a new node.
*/
@@ -728,5 +536,5 @@ mxml_new(mxml_node_t *parent, /* I - Parent node */
/*
- * End of "$Id: mxml-node.c,v 1.8 2003/09/28 12:44:39 mike Exp $".
+ * End of "$Id: mxml-node.c,v 1.9 2003/09/28 21:09:04 mike Exp $".
*/
diff --git a/mxml-private.c b/mxml-private.c
new file mode 100644
index 0000000..3428878
--- /dev/null
+++ b/mxml-private.c
@@ -0,0 +1,73 @@
+/*
+ * "$Id: mxml-private.c,v 1.1 2003/09/28 21:09:04 mike Exp $"
+ *
+ * Private functions for mini-XML, a small XML-like file parsing library.
+ *
+ * Copyright 2003 by Michael Sweet.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Contents:
+ *
+ * mxml_integer_cb() - Default callback for integer values.
+ * mxml_opaque_cb() - Default callback for opaque values.
+ * mxml_real_cb() - Default callback for real number values.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "mxml.h"
+
+
+/*
+ * 'mxml_integer_cb()' - Default callback for integer values.
+ */
+
+mxml_type_t /* O - Node type */
+mxml_integer_cb(mxml_node_t *node) /* I - Current node */
+{
+ (void)node;
+
+ return (MXML_INTEGER);
+}
+
+
+/*
+ * 'mxml_opaque_cb()' - Default callback for opaque values.
+ */
+
+mxml_type_t /* O - Node type */
+mxml_opaque_cb(mxml_node_t *node) /* I - Current node */
+{
+ (void)node;
+
+ return (MXML_OPAQUE);
+}
+
+
+/*
+ * 'mxml_real_cb()' - Default callback for real number values.
+ */
+
+mxml_type_t /* O - Node type */
+mxml_real_cb(mxml_node_t *node) /* I - Current node */
+{
+ (void)node;
+
+ return (MXML_REAL);
+}
+
+
+/*
+ * End of "$Id: mxml-private.c,v 1.1 2003/09/28 21:09:04 mike Exp $".
+ */
diff --git a/mxml-set.c b/mxml-set.c
new file mode 100644
index 0000000..f7335fb
--- /dev/null
+++ b/mxml-set.c
@@ -0,0 +1,224 @@
+/*
+ * "$Id: mxml-set.c,v 1.1 2003/09/28 21:09:04 mike Exp $"
+ *
+ * Node set functions for mini-XML, a small XML-like file parsing library.
+ *
+ * Copyright 2003 by Michael Sweet.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Contents:
+ *
+ * mxmlSetElement() - Set the name of an element node.
+ * mxmlSetInteger() - Set the value of an integer node.
+ * mxmlSetOpaque() - Set the value of an opaque node.
+ * mxmlSetReal() - Set the value of a real number node.
+ * mxmlSetText() - Set the value of a text node.
+ * mxmlSetTextf() - Set the value of a text node to a formatted string.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "config.h"
+#include "mxml.h"
+
+
+/*
+ * 'mxmlSetElement()' - Set the name of an element node.
+ *
+ * The node is not changed if it is not an element node.
+ */
+
+int /* O - 0 on success, -1 on failure */
+mxmlSetElement(mxml_node_t *node, /* I - Node to set */
+ const char *name) /* I - New name string */
+{
+ /*
+ * Range check input...
+ */
+
+ if (!node || node->type != MXML_ELEMENT || !name)
+ return (-1);
+
+ /*
+ * Free any old element value and set the new value...
+ */
+
+ if (node->value.element.name)
+ free(node->value.element.name);
+
+ node->value.element.name = strdup(name);
+
+ return (0);
+}
+
+
+/*
+ * 'mxmlSetInteger()' - Set the value of an integer node.
+ *
+ * The node is not changed if it is not an integer node.
+ */
+
+int /* O - 0 on success, -1 on failure */
+mxmlSetInteger(mxml_node_t *node, /* I - Node to set */
+ int integer) /* I - Integer value */
+{
+ /*
+ * Range check input...
+ */
+
+ if (!node || node->type != MXML_INTEGER)
+ return (-1);
+
+ /*
+ * Set the new value and return...
+ */
+
+ node->value.integer = integer;
+
+ return (0);
+}
+
+
+/*
+ * 'mxmlSetOpaque()' - Set the value of an opaque node.
+ *
+ * The node is not changed if it is not an opaque node.
+ */
+
+int /* O - 0 on success, -1 on failure */
+mxmlSetOpaque(mxml_node_t *node, /* I - Node to set */
+ const char *opaque) /* I - Opaque string */
+{
+ /*
+ * Range check input...
+ */
+
+ if (!node || node->type != MXML_OPAQUE || !opaque)
+ return (-1);
+
+ /*
+ * Free any old opaque value and set the new value...
+ */
+
+ if (node->value.opaque)
+ free(node->value.opaque);
+
+ node->value.opaque = strdup(opaque);
+
+ return (0);
+}
+
+
+/*
+ * 'mxmlSetReal()' - Set the value of a real number node.
+ *
+ * The node is not changed if it is not a real number node.
+ */
+
+int /* O - 0 on success, -1 on failure */
+mxmlSetReal(mxml_node_t *node, /* I - Node to set */
+ double real) /* I - Real number value */
+{
+ /*
+ * Range check input...
+ */
+
+ if (!node || node->type != MXML_REAL)
+ return (-1);
+
+ /*
+ * Set the new value and return...
+ */
+
+ node->value.real = real;
+
+ return (0);
+}
+
+
+/*
+ * 'mxmlSetText()' - Set the value of a text node.
+ *
+ * The node is not changed if it is not a text node.
+ */
+
+int /* O - 0 on success, -1 on failure */
+mxmlSetText(mxml_node_t *node, /* I - Node to set */
+ int whitespace, /* I - 1 = leading whitespace, 0 = no whitespace */
+ const char *string) /* I - String */
+{
+ /*
+ * Range check input...
+ */
+
+ if (!node || node->type != MXML_TEXT || !string)
+ return (-1);
+
+ /*
+ * Free any old string value and set the new value...
+ */
+
+ if (node->value.text.string)
+ free(node->value.text.string);
+
+ node->value.text.whitespace = whitespace;
+ node->value.text.string = strdup(string);
+
+ return (0);
+}
+
+
+/*
+ * 'mxmlSetTextf()' - Set the value of a text node to a formatted string.
+ *
+ * The node is not changed if it is not a text node.
+ */
+
+int /* O - 0 on success, -1 on failure */
+mxmlSetTextf(mxml_node_t *node, /* I - Node to set */
+ int whitespace, /* I - 1 = leading whitespace, 0 = no whitespace */
+ const char *format, /* I - Printf-style format string */
+ ...) /* I - Additional arguments as needed */
+{
+ va_list ap; /* Pointer to arguments */
+
+
+ /*
+ * Range check input...
+ */
+
+ if (!node || node->type != MXML_TEXT || !format)
+ return (-1);
+
+ /*
+ * Free any old string value and set the new value...
+ */
+
+ if (node->value.text.string)
+ free(node->value.text.string);
+
+ va_start(ap, format);
+
+ node->value.text.whitespace = whitespace;
+ node->value.text.string = mxml_strdupf(format, ap);
+
+ va_end(ap);
+
+ return (0);
+}
+
+
+/*
+ * End of "$Id: mxml-set.c,v 1.1 2003/09/28 21:09:04 mike Exp $".
+ */
diff --git a/mxml.h b/mxml.h
index e04dfb5..722dcfb 100644
--- a/mxml.h
+++ b/mxml.h
@@ -1,5 +1,5 @@
/*
- * "$Id: mxml.h,v 1.13 2003/09/28 12:44:39 mike Exp $"
+ * "$Id: mxml.h,v 1.14 2003/09/28 21:09:04 mike Exp $"
*
* Header file for mini-XML, a small XML-like file parsing library.
*
@@ -42,8 +42,14 @@
# define MXML_TAB 8 /* Tabs every N columns */
# define MXML_NO_CALLBACK 0 /* Don't use a type callback */
-# define MXML_OPAQUE_CALLBACK _mxml_opaque_cb
+# define MXML_INTEGER_CALLBACK mxml_integer_cb
+ /* Treat all data as integers */
+# define MXML_OPAQUE_CALLBACK mxml_opaque_cb
/* Treat all data as opaque */
+# define MXML_REAL_CALLBACK mxml_real_cb
+ /* Treat all data as real numbers */
+# define MXML_TEXT_CALLBACK 0 /* Treat all data as text */
+
# define MXML_NO_PARENT 0 /* No parent for the node */
# define MXML_DESCEND 1 /* Descend when finding/walking */
@@ -101,18 +107,16 @@ typedef union mxml_value_u /**** An XML node value. ****/
mxml_text_t text; /* Text fragment */
} mxml_value_t;
-typedef struct mxml_node_s mxml_node_t; /**** An XML node. ****/
-
-struct mxml_node_s /**** An XML node. ****/
+typedef struct mxml_node_s /**** An XML node. ****/
{
mxml_type_t type; /* Node type */
- mxml_node_t *next; /* Next node under same parent */
- mxml_node_t *prev; /* Previous node under same parent */
- mxml_node_t *parent; /* Parent node */
- mxml_node_t *child; /* First child node */
- mxml_node_t *last_child; /* Last child node */
+ struct mxml_node_s *next; /* Next node under same parent */
+ struct mxml_node_s *prev; /* Previous node under same parent */
+ struct mxml_node_s *parent; /* Parent node */
+ struct mxml_node_s *child; /* First child node */
+ struct mxml_node_s *last_child; /* Last child node */
mxml_value_t value; /* Node value */
-};
+} mxml_node_t;
/*
@@ -196,5 +200,5 @@ extern mxml_type_t _mxml_opaque_cb(mxml_node_t *node);
/*
- * End of "$Id: mxml.h,v 1.13 2003/09/28 12:44:39 mike Exp $".
+ * End of "$Id: mxml.h,v 1.14 2003/09/28 21:09:04 mike Exp $".
*/
diff --git a/mxml.xml b/mxml.xml
index a75a313..0f0315f 100644
--- a/mxml.xml
+++ b/mxml.xml
@@ -7,8 +7,10 @@ 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, int where, mxml_node_t
-*child, mxml_node_t *Node to add
+name="parent" direction="I">mxml_node_t *Parent node
+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.
@@ -22,7 +24,8 @@ char *
This function returns NULL if the node is not an element or the
named attribute does not exist.mxml_node_t *node, const char *Name of attribute
+name="node" direction="I">mxml_node_t *Element node
+const char *Name of attribute
Set an attribute.
@@ -30,8 +33,9 @@ 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 *node, const char *name, const
-char *Attribute value
+name="node" direction="I">mxml_node_t *Element node
+const char *Name of attribute
+const char *Attribute value
Element node or NULLmxml_node_t
*
@@ -45,8 +49,12 @@ 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 *node, mxml_node_t *top, const
-char *name, const char *attr, const char *value, intDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
+name="node" direction="I">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 - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
First node or NULL if the file could not be read.mxml_node_t
*
@@ -57,9 +65,14 @@ 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, FILE
-*fp, mxml_type_tCallback function or MXML_NO_CALLBACK
+MXML_ELEMENT or MXML_TEXT nodes.
+
+The constants MXML_INTEGER_CALLBACK, MXML_OPAQUE_CALLBACK,
+MXML_REAL_CALLBACK, and MXML_TEXT_CALLBACK are defined for loading
+child nodes of the specified type.mxml_node_t *Top node
+FILE *File to read from
+mxml_type_tCallback function or MXML_NO_CALLBACK
First node or NULL if the string has errors.mxml_node_t
*
@@ -70,9 +83,14 @@ If no top node is provided, the XML string MUST be well-formed with a
single parent node like <?xml> for the entire string. 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, const
-char *s, mxml_type_tCallback function or MXML_NO_CALLBACK
+MXML_ELEMENT or MXML_TEXT nodes.
+
+The constants MXML_INTEGER_CALLBACK, MXML_OPAQUE_CALLBACK,
+MXML_REAL_CALLBACK, and MXML_TEXT_CALLBACK are defined for loading
+child nodes of the specified type.mxml_node_t *Top node
+const char *String to load
+mxml_type_tCallback function or MXML_NO_CALLBACK
New nodemxml_node_t
*
@@ -81,7 +99,8 @@ char *s, mxml_type_tCallback function or MXML_NO_CALLBACKmxml_node_t *parent, const char *Name of element
+name="parent" direction="I">mxml_node_t *Parent node or MXML_NO_PARENT
+const char *Name of element
New nodemxml_node_t
*
@@ -90,7 +109,8 @@ name="name" direction="I">mxml_node_t *parent, const char *mxml_node_t *parent, intInteger value
+name="parent" direction="I">mxml_node_t *Parent node or MXML_NO_PARENT
+intInteger value
New nodemxml_node_t
*
@@ -100,7 +120,8 @@ 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, const char *Opaque string
+name="parent" direction="I">mxml_node_t *Parent node or MXML_NO_PARENT
+const char *Opaque string
New nodemxml_node_t
*
@@ -109,7 +130,8 @@ name="opaque" direction="I">mxml_node_t *parent, const char *mxml_node_t *parent, doubleReal number value
+name="parent" direction="I">mxml_node_t *Parent node or MXML_NO_PARENT
+doubleReal number value
New nodemxml_node_t
*
@@ -120,8 +142,9 @@ 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, int whitespace, const
-char *String
+name="parent" direction="I">mxml_node_t *Parent node or MXML_NO_PARENT
+int1 = leading whitespace, 0 = no whitespace
+const char *String
New nodemxml_node_t
*
@@ -132,8 +155,10 @@ 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 format
string must be nul-terminated and is formatted into the new node.mxml_node_t *parent, int whitespace, const
-char *Additional args as needed
+name="parent" direction="I">mxml_node_t *Parent node or MXML_NO_PARENT
+int1 = leading whitespace, 0 = no whitespace
+const char *Printf-style frmat string
+Additional args as needed
Remove a node from its parent.
@@ -150,8 +175,8 @@ representation of the XML node tree. The string should be freed
using the free() function when you are done with it. NULL is returned
if the node would produce an empty string or if the string cannot be
allocated.mxml_node_t *node,
-intWhitespace callback or MXML_NO_CALLBACK
+name="node" direction="I">mxml_node_t *Node to write
+intWhitespace callback or MXML_NO_CALLBACK
0 on success, -1 on error.int
Save an XML tree to a file.
@@ -161,8 +186,9 @@ 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,
-FILE *fp, intWhitespace callback or MXML_NO_CALLBACK
+name="node" direction="I">mxml_node_t *Node to write
+FILE *File to write to
+intWhitespace callback or MXML_NO_CALLBACK
Size of stringint
Save an XML node tree to a string.
@@ -170,46 +196,55 @@ FILE *fp, intWhitespace callback or MXML_NO_CALLBACKmxml_node_t *node,
-char *buffer, int bufsize, intWhitespace callback or MXML_NO_CALLBACK
+name="node" direction="I">mxml_node_t *Node to write
+char *String buffer
+intSize of string buffer
+intWhitespace callback or MXML_NO_CALLBACK
0 on success, -1 on failureint
Set the name of an element node.
-If the node is not changed if it is not an element node.mxml_node_t *node, const char *New name string
+The node is not changed if it is not an element node.mxml_node_t *Node to set
+const char *New name string
0 on success, -1 on failureint
Set the value of an integer node.
-If the node is not changed if it is not an integer node.mxml_node_t *node, intInteger value
+The node is not changed if it is not an integer node.mxml_node_t *Node to set
+intInteger value
0 on success, -1 on failureint
Set the value of an opaque node.
-If the node is not changed if it is not an opaque node.mxml_node_t *node, const char *Opaque string
+The node is not changed if it is not an opaque node.mxml_node_t *Node to set
+const char *Opaque string
0 on success, -1 on failureint
Set the value of a real number node.
-If the node is not changed if it is not a real number node.mxml_node_t *node, doubleReal number value
+The node is not changed if it is not a real number node.mxml_node_t *Node to set
+doubleReal number value
0 on success, -1 on failureint
Set the value of a text node.
-If the node is not changed if it is not a text node.mxml_node_t *node, int whitespace, const
-char *String
+The node is not changed if it is not a text node.mxml_node_t *Node to set
+int1 = leading whitespace, 0 = no whitespace
+const char *String
0 on success, -1 on failureint
Set the value of a text node to a formatted string.
-If the node is not changed if it is not a text node.mxml_node_t *node, int whitespace, const
-char *Additional arguments as needed
+The node is not changed if it is not a text node.mxml_node_t *Node to set
+int1 = leading whitespace, 0 = no whitespace
+const char *Printf-style format string
+Additional arguments as needed
Next node or NULLmxml_node_t
*
@@ -218,7 +253,9 @@ char *Additional arguments as neededmxml_node_t *node, mxml_node_t *top, intDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
+name="node" direction="I">mxml_node_t *Current node
+mxml_node_t *Top node
+intDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
Previous node or NULLmxml_node_t
*
@@ -227,7 +264,9 @@ name="descend" direction="I">mxml_node_t *node, mxml_node_t *top, intmxml_node_t *node, mxml_node_t *top, intDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
+name="node" direction="I">mxml_node_t *Current node
+mxml_node_t *Top node
+intDescend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
An XML element attribute value.char *Attribute name
@@ -237,26 +276,17 @@ name="name">char *Attribute name
An XML element value.struct
mxml_value_s
-Data types...mxml_node_t *First child node
-mxml_node_t *Last child node
-mxml_node_t *Next node under same parent
-mxml_node_t *Parent node
-mxml_node_t *Previous node under same parent
+An XML node.struct mxml_node_s *First child node
+struct mxml_node_s *Last child node
+struct mxml_node_s *Next node under same parent
+struct mxml_node_s *Parent node
+struct mxml_node_s *Previous node under same parent
mxml_type_tNode type
mxml_value_tNode value
-struct mxml_node_sAn XML node.An XML node.
-New string pointerchar
-*
-Duplicate a string.const char *String to duplicate
-
-New string pointerchar
-*
-Format and duplicate a string.const char *format, va_listPointer to additional arguments
-
+An XML node.struct
+mxml_node_s
An XML text value.char *Fragment string
intLeading whitespace?
@@ -285,8 +315,4 @@ name="element">mxml_element_tElementchar *Opaque string
doubleReal number
mxml_text_tText fragment
-Number of bytes formattedint
-Format a string into a fixed size buffer.char *buffer, size_t bufsize, const char *format,
-va_listPointer to additional arguments
-
+
diff --git a/mxmldoc.c b/mxmldoc.c
index be35f40..c0c5baf 100644
--- a/mxmldoc.c
+++ b/mxmldoc.c
@@ -1,5 +1,5 @@
/*
- * "$Id: mxmldoc.c,v 1.16 2003/07/27 23:11:40 mike Exp $"
+ * "$Id: mxmldoc.c,v 1.17 2003/09/28 21:09:04 mike Exp $"
*
* Documentation generator using mini-XML, a small XML-like file parsing
* library.
@@ -673,7 +673,7 @@ scan_file(const char *filename, /* I - Filename */
break;
default : /* Other */
- if (isalpha(ch) || ch == '_')
+ if (isalpha(ch) || ch == '_' || ch == '.')
{
state = STATE_IDENTIFIER;
bufptr = buffer;
@@ -961,8 +961,8 @@ scan_file(const char *filename, /* I - Filename */
break;
case STATE_IDENTIFIER : /* Inside a keyword or identifier */
- if (isalnum(ch) || ch == '_' || ch == '[' || ch == ']' || ch == ':' ||
- (parens && ch == ','))
+ if (isalnum(ch) || ch == '_' || ch == '[' || ch == ']' ||
+ (ch == ',' && parens > 1) || ch == ':' || ch == '.')
{
if (bufptr < (buffer + sizeof(buffer) - 1))
*bufptr++ = ch;
@@ -1376,7 +1376,8 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
mxml_node_t *function, /* Current function */
*scut, /* Struct/class/union/typedef */
*arg, /* Current argument */
- *description; /* Description of function/var */
+ *description, /* Description of function/var */
+ *type; /* Type for argument */
const char *name; /* Name of function/type */
char prefix; /* Prefix character */
@@ -1427,6 +1428,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "class", NULL, NULL, MXML_DESCEND_FIRST))
{
+ puts("
");
puts("");
puts("");
@@ -1449,7 +1451,6 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(scut, "name");
- puts("
");
printf("\n", name, name);
description = mxmlFindElement(scut, scut, "description", NULL,
@@ -1509,6 +1510,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "enumeration", NULL, NULL, MXML_DESCEND_FIRST))
{
+ puts("
");
puts("");
puts("");
@@ -1531,7 +1533,6 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(scut, "name");
- puts("
");
printf("\n", name, name);
description = mxmlFindElement(scut, scut, "description", NULL,
@@ -1573,6 +1574,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "function", NULL, NULL, MXML_DESCEND_FIRST))
{
+ puts("
");
puts("");
puts("");
@@ -1595,7 +1597,6 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(function, "name");
- puts("
");
printf("\n", name, name);
description = mxmlFindElement(function, function, "description", NULL,
@@ -1626,10 +1627,12 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
arg = mxmlFindElement(arg, function, "argument", NULL, NULL,
MXML_NO_DESCEND), prefix = ',')
{
+ type = mxmlFindElement(arg, arg, "type", NULL, NULL,
+ MXML_DESCEND_FIRST);
+
printf("%c\n ", prefix);
- write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
- NULL, MXML_DESCEND_FIRST));
- printf(" %s", mxmlElementGetAttr(arg, "name"));
+ write_element(doc, type);
+ printf("%s%s", type->child ? " " : "", mxmlElementGetAttr(arg, "name"));
}
if (prefix == '(')
@@ -1687,6 +1690,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "struct", NULL, NULL, MXML_DESCEND_FIRST))
{
+ puts("
");
puts("");
puts("");
@@ -1709,7 +1713,6 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(scut, "name");
- puts("
");
printf("\n", name, name);
description = mxmlFindElement(scut, scut, "description", NULL,
@@ -1769,6 +1772,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "typedef", NULL, NULL, MXML_DESCEND_FIRST))
{
+ puts("
");
puts("");
puts("");
@@ -1791,7 +1795,6 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(scut, "name");
- puts("
");
printf("\n", name, name);
description = mxmlFindElement(scut, scut, "description", NULL,
@@ -1819,6 +1822,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "union", NULL, NULL, MXML_DESCEND_FIRST))
{
+ puts("
");
puts("");
puts("");
@@ -1841,7 +1845,6 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(scut, "name");
- puts("
");
printf("\n", name, name);
description = mxmlFindElement(scut, scut, "description", NULL,
@@ -1901,6 +1904,7 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if (mxmlFindElement(doc, doc, "variable", NULL, NULL, MXML_DESCEND_FIRST))
{
+ puts("
");
puts("");
puts("");
@@ -1923,7 +1927,6 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
MXML_NO_DESCEND))
{
name = mxmlElementGetAttr(arg, "name");
- puts("
");
printf("\n", name, name);
description = mxmlFindElement(arg, arg, "description", NULL,
@@ -1966,9 +1969,12 @@ write_element(mxml_node_t *doc, /* I - Document tree */
mxml_node_t *node; /* Current node */
- for (node = mxmlWalkNext(element, element, MXML_DESCEND);
+ if (!element)
+ return;
+
+ for (node = element->child;
node;
- node = mxmlWalkNext(node, element, MXML_DESCEND))
+ node = mxmlWalkNext(node, element, MXML_NO_DESCEND))
if (node->type == MXML_TEXT)
{
if (node->value.text.whitespace)
@@ -2081,5 +2087,5 @@ ws_cb(mxml_node_t *node, /* I - Element node */
/*
- * End of "$Id: mxmldoc.c,v 1.16 2003/07/27 23:11:40 mike Exp $".
+ * End of "$Id: mxmldoc.c,v 1.17 2003/09/28 21:09:04 mike Exp $".
*/