From 003eea7429190ebacf58d8d7fa79c4a543a36ae9 Mon Sep 17 00:00:00 2001 From: Michael Sweet Date: Thu, 6 Apr 2017 14:25:19 -0400 Subject: [PATCH] Clean up mxmldoc and refactor a bunch of the code. --- Makefile.in | 3 +- doc/docset.header | 32 +- doc/docset.intro | 87 +- doc/reference.header | 1 + doc/reference.heading | 1 - doc/reference.html | 1457 ++++++++++++++++--------------- mxmldoc.c | 1895 +++++++++++++---------------------------- 7 files changed, 1375 insertions(+), 2101 deletions(-) create mode 100644 doc/reference.header delete mode 100644 doc/reference.heading diff --git a/Makefile.in b/Makefile.in index 38b4f60..7ae8f8f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -348,9 +348,10 @@ testmxml.o: mxml.h mxml.xml: mxmldoc-static mxml.h $(PUBLIBOBJS:.o=.c) echo Generating API documentation... $(RM) mxml.xml - ./mxmldoc-static --header doc/reference.heading \ + ./mxmldoc-static --header doc/reference.header \ --docversion @VERSION@ --author "Michael R Sweet" \ --copyright "Copyright 2003-2017, All Rights Reserved." \ + --title "Mini-XML API Reference" \ mxml.xml mxml.h $(PUBLIBOBJS:.o=.c) >doc/reference.html ./mxmldoc-static --man mxml --title "Mini-XML API" \ --intro doc/intro.man --footer doc/footer.man \ diff --git a/doc/docset.header b/doc/docset.header index 10d5173..37dc00e 100644 --- a/doc/docset.header +++ b/doc/docset.header @@ -1,16 +1,18 @@ -

Mini-XML API Reference

+

Mini-XML API Reference

-
- - - - - - - - - - - - -
Headermxml.h
Library-lmxml
+
+ + + + + + + + + + + + + +
Headermxml.h
Library-lmxml
+
diff --git a/doc/docset.intro b/doc/docset.intro index fa11c99..d1fa0eb 100644 --- a/doc/docset.intro +++ b/doc/docset.intro @@ -1,42 +1,33 @@ -

Introduction

+

Introduction

-

Mini-XML is a small XML parsing library that you can use to read XML data files or strings in your application without requiring large non-standard libraries. Mini-XML provides the following functionality:

+

Mini-XML is a small XML parsing library that you can use to read XML data files or strings in your application without requiring large non-standard libraries. Mini-XML provides the following functionality:

- + -

Mini-XML doesn't do validation or other types of processing on the data based upon schema files or other sources of definition information.

+

Mini-XML doesn't do validation or other types of processing on the data based upon schema files or other sources of definition information.

-

Using Mini-XML

+

Using Mini-XML

-

Mini-XML provides a single header file which you include:

+

Mini-XML provides a single header file which you include:

-
+      
 #include <mxml.h>
 
-

Nodes are defined by the "mxml_node_t" structure; -the "type" member defines the node type (element, integer, opaque, real, or -text) which determines which value you want to look at in the "value" union. -New nodes can be created using the -"mxmlNewElement()", -"mxmlNewInteger()", -"mxmlNewOpaque()", -"mxmlNewReal()", and -"mxmlNewText()" functions. Only elements can have -child nodes, and the top node must be an element, usually "?xml".

+

Nodes are defined by the "mxml_node_t" structure; the "type" member defines the node type (element, integer, opaque, real, or text) which determines which value you want to look at in the "value" union. New nodes can be created using the "mxmlNewElement()", "mxmlNewInteger()", "mxmlNewOpaque()", "mxmlNewReal()", and "mxmlNewText()" functions. Only elements can have child nodes, and the top node must be an element, usually "?xml".

-

You load an XML file using the "mxmlLoadFile()" function:

+

You load an XML file using the "mxmlLoadFile()" function:

-
+      
 FILE *fp;
 mxml_node_t *tree;
 
@@ -45,10 +36,9 @@ tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);
 fclose(fp);
 
-

Similarly, you save an XML file using the -"mxmlSaveFile()" function:

+

Similarly, you save an XML file using the "mxmlSaveFile()" function:

-
+      
 FILE *fp;
 mxml_node_t *tree;
 
@@ -57,12 +47,9 @@ mxmlSaveFile(tree, fp, MXML_NO_CALLBACK);
 fclose(fp);
 
-

The "mxmlLoadString()", -"mxmlSaveAllocString()", and -"mxmlSaveString()" functions load XML node trees -from and save XML node trees to strings:

+

The "mxmlLoadString()", "mxmlSaveAllocString()", and "mxmlSaveString()" functions load XML node trees from and save XML node trees to strings:

-
+      
 char buffer[8192];
 char *ptr;
 mxml_node_t *tree;
@@ -78,19 +65,17 @@ mxmlSaveString(tree, buffer, sizeof(buffer),
 ptr = mxmlSaveAllocString(tree, MXML_NO_CALLBACK);
 
-

You can find a named element/node using the -"mxmlFindElement()" function:

+

You can find a named element/node using the "mxmlFindElement()" function:

-
+      
 mxml_node_t *node = mxmlFindElement(tree, tree, "name",
 				    "attr", "value",
 				    MXML_DESCEND);
 
-

The "name", "attr", and "value" arguments can be passed as -NULL to act as wildcards, e.g.:

+

The "name", "attr", and "value" arguments can be passed as NULL to act as wildcards, e.g.:

-
+      
 /* Find the first "a" element */
 node = mxmlFindElement(tree, tree, "a", NULL, NULL,
 		       MXML_DESCEND);
@@ -113,9 +98,9 @@ node = mxmlFindElement(tree, tree, NULL, "src",
 		       "foo.jpg", MXML_DESCEND);
 
-

You can also iterate with the same function:

+

You can also iterate with the same function:

-
+      
 mxml_node_t *node;
 
 for (node = mxmlFindElement(tree, tree, "name", NULL,
@@ -128,17 +113,15 @@ for (node = mxmlFindElement(tree, tree, "name", NULL,
 }
 
-

The "mxmlFindPath()" function finds the (first) value node under a specific -element using a "path":

+

The "mxmlFindPath()" function finds the (first) value node under a specific element using a "path":

-
+      
 mxml_node_t *value = mxmlFindPath(tree, "path/to/*/foo/bar");
 
-

The "mxmlGetInteger()", "mxmlGetOpaque()", "mxmlGetReal()", and -"mxmlGetText()" functions retrieve the value from a node:

+

The "mxmlGetInteger()", "mxmlGetOpaque()", "mxmlGetReal()", and "mxmlGetText()" functions retrieve the value from a node:

-
+      
 mxml_node_t *node;
 
 int intvalue = mxmlGetInteger(node);
@@ -151,10 +134,8 @@ int whitespacevalue;
 const char *textvalue = mxmlGetText(node, &whitespacevalue);
 
-

Finally, once you are done with the XML data, use the -"mxmlDelete()" function to recursively free the -memory that is used for a particular node or the entire tree:

+

Finally, once you are done with the XML data, use the "mxmlDelete()" function to recursively free the memory that is used for a particular node or the entire tree:

-
+      
 mxmlDelete(tree);
 
diff --git a/doc/reference.header b/doc/reference.header new file mode 100644 index 0000000..07fdc2c --- /dev/null +++ b/doc/reference.header @@ -0,0 +1 @@ +

Appendix B - Library Reference

diff --git a/doc/reference.heading b/doc/reference.heading deleted file mode 100644 index ec06f5c..0000000 --- a/doc/reference.heading +++ /dev/null @@ -1 +0,0 @@ -

Appendix B - Library Reference

diff --git a/doc/reference.html b/doc/reference.html index 6ae8d5e..dbdd38e 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -1,10 +1,12 @@ - - Documentation - - - - - -
-

Appendix B - Library Reference

-

Contents

- -

Functions

+ + +

Appendix B - Library Reference

+ +
+

Functions

mxmlAdd

-

Add a node to a tree.

+

Add a node to a tree.

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

Parameters

parent
-
Parent node
+
Parent node
where
-
Where to add, MXML_ADD_BEFORE or MXML_ADD_AFTER
+
Where to add, MXML_ADD_BEFORE or MXML_ADD_AFTER
child
-
Child node for where or MXML_ADD_TO_PARENT
+
Child node for where or MXML_ADD_TO_PARENT
node
-
Node to add
+
Node to add

Discussion

-

Adds the specified node to the parent. If the child argument is not +

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.

mxmlDelete

-

Delete a node and all of its children.

+

Delete a node and all of its children.

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

Parameters

node
-
Node to delete
+
Node to delete

Discussion

-

If the specified node has a parent, this function first removes the +

If the specified node has a parent, this function first removes the node from its parent using the mxmlRemove() function.

 Mini-XML 2.4 mxmlElementDeleteAttr

-

Delete an attribute.

+

Delete an attribute.

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

Parameters

node
-
Element
+
Element
name
-
Attribute name
+
Attribute name

mxmlElementGetAttr

-

Get an attribute.

+

Get an attribute.

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

Parameters

node
-
Element node
+
Element node
name
-
Name of attribute
+
Name of attribute

Return Value

-

Attribute value or NULL

+

Attribute value or NULL

Discussion

-

This function returns NULL if the node is not an element or the +

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

mxmlElementSetAttr

-

Set an attribute.

+

Set an attribute.

-void mxmlElementSetAttr (
-    mxml_node_t *node,
-    const char *name,
-    const char *value
+void mxmlElementSetAttr (
+    mxml_node_t *node,
+    const char *name,
+    const char *value
);

Parameters

node
-
Element node
+
Element node
name
-
Name of attribute
+
Name of attribute
value
-
Attribute value
+
Attribute value

Discussion

-

If the named attribute already exists, the value of the 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.

 Mini-XML 2.3 mxmlElementSetAttrf

-

Set an attribute with a formatted value.

+

Set an attribute with a formatted value.

-void mxmlElementSetAttrf (
-    mxml_node_t *node,
-    const char *name,
-    const char *format,
-    ...
+void mxmlElementSetAttrf (
+    mxml_node_t *node,
+    const char *name,
+    const char *format,
+    ...
);

Parameters

node
-
Element node
+
Element node
name
-
Name of attribute
+
Name of attribute
format
-
Printf-style attribute value
+
Printf-style attribute value
...
-
Additional arguments as needed
+
Additional arguments as needed

Discussion

-

If the named attribute already exists, the value of the attribute +

If the named attribute already exists, the value of the attribute is replaced by the new formatted string. The formatted string value is copied into the element node. This function does nothing if the node is not an element.

mxmlEntityAddCallback

-

Add a callback to convert entities to Unicode.

+

Add a callback to convert entities to Unicode.

-int mxmlEntityAddCallback (
-    mxml_entity_cb_t cb
+int mxmlEntityAddCallback (
+    mxml_entity_cb_t cb
);

Parameters

cb
-
Callback function to add
+
Callback function to add

Return Value

-

0 on success, -1 on failure

+

0 on success, -1 on failure

mxmlEntityGetName

-

Get the name that corresponds to the character value.

+

Get the name that corresponds to the character value.

-const char *mxmlEntityGetName (
-    int val
+const char *mxmlEntityGetName (
+    int val
);

Parameters

val
-
Character value
+
Character value

Return Value

-

Entity name or NULL

+

Entity name or NULL

Discussion

-

If val does not need to be represented by a named entity, NULL is returned.

+

If val does not need to be represented by a named entity, NULL is returned.

mxmlEntityGetValue

-

Get the character corresponding to a named entity.

+

Get the character corresponding to a named entity.

-int mxmlEntityGetValue (
-    const char *name
+int mxmlEntityGetValue (
+    const char *name
);

Parameters

name
-
Entity name
+
Entity name

Return Value

-

Character value or -1 on error

+

Character value or -1 on error

Discussion

-

The entity name can also be a numeric constant. -1 is returned if the +

The entity name can also be a numeric constant. -1 is returned if the name is not known.

mxmlEntityRemoveCallback

-

Remove a callback.

+

Remove a callback.

-void mxmlEntityRemoveCallback (
-    mxml_entity_cb_t cb
+void mxmlEntityRemoveCallback (
+    mxml_entity_cb_t cb
);

Parameters

cb
-
Callback function to remove
+
Callback function to remove

mxmlFindElement

-

Find the named element.

+

Find the named element.

-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 *mxmlFindElement (
+    mxml_node_t *node,
+    mxml_node_t *top,
+    const char *name,
+    const char *attr,
+    const char *value,
+    int descend
);

Parameters

node
-
Current node
+
Current node
top
-
Top node
+
Top node
name
-
Element name or NULL for any
+
Element name or NULL for any
attr
-
Attribute name, or NULL for none
+
Attribute name, or NULL for none
value
-
Attribute value, or NULL for any
+
Attribute value, or NULL for any
descend
-
Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
+
Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST

Return Value

-

Element node or NULL

+

Element node or NULL

Discussion

-

The search is constrained by the name, attribute name, and value; any +

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 @@ -453,23 +452,23 @@ 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.

 Mini-XML 2.7 mxmlFindPath

-

Find a node with the given path.

+

Find a node with the given path.

-mxml_node_t *mxmlFindPath (
-    mxml_node_t *top,
-    const char *path
+mxml_node_t *mxmlFindPath (
+    mxml_node_t *top,
+    const char *path
);

Parameters

top
-
Top node
+
Top node
path
-
Path to element
+
Path to element

Return Value

-

Found node or NULL

+

Found node or NULL

Discussion

-

The "path" is a slash-separated list of element names. The name "*" is +

The "path" is a slash-separated list of element names. The name "*" is considered a wildcard for one or more levels of elements. For example, "foo/one/two", "bar/two/one", "*/one", and so forth.

@@ -478,392 +477,392 @@ children and the first child is a value node.

 Mini-XML 2.7 mxmlGetCDATA

-

Get the value for a CDATA node.

+

Get the value for a CDATA node.

-const char *mxmlGetCDATA (
-    mxml_node_t *node
+const char *mxmlGetCDATA (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

CDATA value or NULL

+

CDATA value or NULL

Discussion

-

NULL is returned if the node is not a CDATA element. +

NULL is returned if the node is not a CDATA element.

 Mini-XML 2.7 mxmlGetCustom

-

Get the value for a custom node.

+

Get the value for a custom node.

-const void *mxmlGetCustom (
-    mxml_node_t *node
+const void *mxmlGetCustom (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

Custom value or NULL

+

Custom value or NULL

Discussion

-

NULL is returned if the node (or its first child) is not a custom +

NULL is returned if the node (or its first child) is not a custom value node.

 Mini-XML 2.7 mxmlGetElement

-

Get the name for an element node.

+

Get the name for an element node.

-const char *mxmlGetElement (
-    mxml_node_t *node
+const char *mxmlGetElement (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

Element name or NULL

+

Element name or NULL

Discussion

-

NULL is returned if the node is not an element node. +

NULL is returned if the node is not an element node.

 Mini-XML 2.7 mxmlGetFirstChild

-

Get the first child of an element node.

+

Get the first child of an element node.

-mxml_node_t *mxmlGetFirstChild (
-    mxml_node_t *node
+mxml_node_t *mxmlGetFirstChild (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

First child or NULL

+

First child or NULL

Discussion

-

NULL is returned if the node is not an element node or if the node +

NULL is returned if the node is not an element node or if the node has no children.

 Mini-XML 2.7 mxmlGetInteger

-

Get the integer value from the specified node or its +

Get the integer value from the specified node or its first child.

-int mxmlGetInteger (
-    mxml_node_t *node
+int mxmlGetInteger (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

Integer value or 0

+

Integer value or 0

Discussion

-

0 is returned if the node (or its first child) is not an integer value node. +

0 is returned if the node (or its first child) is not an integer value node.

 Mini-XML 2.7 mxmlGetLastChild

-

Get the last child of an element node.

+

Get the last child of an element node.

-mxml_node_t *mxmlGetLastChild (
-    mxml_node_t *node
+mxml_node_t *mxmlGetLastChild (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

Last child or NULL

+

Last child or NULL

Discussion

-

NULL is returned if the node is not an element node or if the node +

NULL is returned if the node is not an element node or if the node has no children.

mxmlGetNextSibling

-

Return the node type...

+

Return the node type...

-mxml_node_t *mxmlGetNextSibling (
-    mxml_node_t *node
+mxml_node_t *mxmlGetNextSibling (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

Get the next node for the current parent.

-

NULL is returned if this is the last child for the current parent. +

Get the next node for the current parent.

+

NULL is returned if this is the last child for the current parent.

 Mini-XML 2.7 mxmlGetOpaque

-

Get an opaque string value for a node or its first child.

+

Get an opaque string value for a node or its first child.

-const char *mxmlGetOpaque (
-    mxml_node_t *node
+const char *mxmlGetOpaque (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

Opaque string or NULL

+

Opaque string or NULL

Discussion

-

NULL is returned if the node (or its first child) is not an opaque +

NULL is returned if the node (or its first child) is not an opaque value node.

 Mini-XML 2.7 mxmlGetParent

-

Get the parent node.

+

Get the parent node.

-mxml_node_t *mxmlGetParent (
-    mxml_node_t *node
+mxml_node_t *mxmlGetParent (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

Parent node or NULL

+

Parent node or NULL

Discussion

-

NULL is returned for a root node. +

NULL is returned for a root node.

 Mini-XML 2.7 mxmlGetPrevSibling

-

Get the previous node for the current parent.

+

Get the previous node for the current parent.

-mxml_node_t *mxmlGetPrevSibling (
-    mxml_node_t *node
+mxml_node_t *mxmlGetPrevSibling (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

Previous node or NULL

+

Previous node or NULL

Discussion

-

NULL is returned if this is the first child for the current parent. +

NULL is returned if this is the first child for the current parent.

 Mini-XML 2.7 mxmlGetReal

-

Get the real value for a node or its first child.

+

Get the real value for a node or its first child.

-double mxmlGetReal (
-    mxml_node_t *node
+double mxmlGetReal (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

Real value or 0.0

+

Real value or 0.0

Discussion

-

0.0 is returned if the node (or its first child) is not a real value node. +

0.0 is returned if the node (or its first child) is not a real value node.

 Mini-XML 2.7 mxmlGetRefCount

-

Get the current reference (use) count for a node.

+

Get the current reference (use) count for a node.

-int mxmlGetRefCount (
-    mxml_node_t *node
+int mxmlGetRefCount (
+    mxml_node_t *node
);

Parameters

node
-
Node
+
Node

Return Value

-

Reference count

+

Reference count

Discussion

-

The initial reference count of new nodes is 1. Use the mxmlRetain +

The initial reference count of new nodes is 1. Use the mxmlRetain and mxmlRelease functions to increment and decrement a node's reference count. .

 Mini-XML 2.7 mxmlGetText

-

Get the text value for a node or its first child.

+

Get the text value for a node or its first child.

-const char *mxmlGetText (
-    mxml_node_t *node,
-    int *whitespace
+const char *mxmlGetText (
+    mxml_node_t *node,
+    int *whitespace
);

Parameters

node
-
Node to get
+
Node to get
whitespace
-
1 if string is preceded by whitespace, 0 otherwise
+
1 if string is preceded by whitespace, 0 otherwise

Return Value

-

Text string or NULL

+

Text string or NULL

Discussion

-

NULL is returned if the node (or its first child) is not a text node. +

NULL is returned if the node (or its first child) is not a text node. The "whitespace" argument can be NULL.

 Mini-XML 2.7 mxmlGetType

-

Get the node type.

+

Get the node type.

-mxml_type_t mxmlGetType (
-    mxml_node_t *node
+mxml_type_t mxmlGetType (
+    mxml_node_t *node
);

Parameters

node
-
Node to get
+
Node to get

Return Value

-

Type of node

+

Type of node

Discussion

-

MXML_IGNORE is returned if "node" is NULL. +

MXML_IGNORE is returned if "node" is NULL.

 Mini-XML 2.7 mxmlGetUserData

-

Get the user data pointer for a node.

+

Get the user data pointer for a node.

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

Parameters

node
-
Node to get
+
Node to get

Return Value

-

User data pointer

+

User data pointer

mxmlIndexDelete

-

Delete an index.

+

Delete an index.

-void mxmlIndexDelete (
-    mxml_index_t *ind
+void mxmlIndexDelete (
+    mxml_index_t *ind
);

Parameters

ind
-
Index to delete
+
Index to delete

mxmlIndexEnum

-

Return the next node in the index.

+

Return the next node in the index.

-mxml_node_t *mxmlIndexEnum (
-    mxml_index_t *ind
+mxml_node_t *mxmlIndexEnum (
+    mxml_index_t *ind
);

Parameters

ind
-
Index to enumerate
+
Index to enumerate

Return Value

-

Next node or NULL if there is none

+

Next node or NULL if there is none

Discussion

-

Nodes are returned in the sorted order of the index.

+

Nodes are returned in the sorted order of the index.

mxmlIndexFind

-

Find the next matching node.

+

Find the next matching node.

-mxml_node_t *mxmlIndexFind (
-    mxml_index_t *ind,
-    const char *element,
-    const char *value
+mxml_node_t *mxmlIndexFind (
+    mxml_index_t *ind,
+    const char *element,
+    const char *value
);

Parameters

ind
-
Index to search
+
Index to search
element
-
Element name to find, if any
+
Element name to find, if any
value
-
Attribute value, if any
+
Attribute value, if any

Return Value

-

Node or NULL if none found

+

Node or NULL if none found

Discussion

-

You should call mxmlIndexReset() prior to using this function for +

You should call mxmlIndexReset() prior to using this function for the first time with a particular set of "element" and "value" strings. Passing NULL for both "element" and "value" is equivalent to calling mxmlIndexEnum().

 Mini-XML 2.7 mxmlIndexGetCount

-

Get the number of nodes in an index.

+

Get the number of nodes in an index.

-int mxmlIndexGetCount (
-    mxml_index_t *ind
+int mxmlIndexGetCount (
+    mxml_index_t *ind
);

Parameters

ind
-
Index of nodes
+
Index of nodes

Return Value

-

Number of nodes in index

+

Number of nodes in index

mxmlIndexNew

-

Create a new index.

+

Create a new index.

-mxml_index_t *mxmlIndexNew (
-    mxml_node_t *node,
-    const char *element,
-    const char *attr
+mxml_index_t *mxmlIndexNew (
+    mxml_node_t *node,
+    const char *element,
+    const char *attr
);

Parameters

node
-
XML node tree
+
XML node tree
element
-
Element to index or NULL for all
+
Element to index or NULL for all
attr
-
Attribute to index or NULL for none
+
Attribute to index or NULL for none

Return Value

-

New index

+

New index

Discussion

-

The index will contain all nodes that contain the named element and/or +

The index will contain all nodes that contain the named element and/or attribute. If both "element" and "attr" are NULL, then the index will contain a sorted list of the elements in the node tree. Nodes are sorted by element name and optionally by attribute value if the "attr" argument is not NULL.

mxmlIndexReset

-

Reset the enumeration/find pointer in the index and +

Reset the enumeration/find pointer in the index and return the first node in the index.

-mxml_node_t *mxmlIndexReset (
-    mxml_index_t *ind
+mxml_node_t *mxmlIndexReset (
+    mxml_index_t *ind
);

Parameters

ind
-
Index to reset
+
Index to reset

Return Value

-

First node or NULL if there is none

+

First node or NULL if there is none

Discussion

-

This function should be called prior to using mxmlIndexEnum() or +

This function should be called prior to using mxmlIndexEnum() or mxmlIndexFind() for the first time.

mxmlLoadFd

-

Load a file descriptor into an XML node tree.

+

Load a file descriptor into an XML node tree.

-mxml_node_t *mxmlLoadFd (
-    mxml_node_t *top,
-    int fd,
-    mxml_load_cb_t cb
+mxml_node_t *mxmlLoadFd (
+    mxml_node_t *top,
+    int fd,
+    mxml_load_cb_t cb
);

Parameters

top
-
Top node
+
Top node
fd
-
File descriptor to read from
+
File descriptor to read from
cb
-
Callback function or MXML_NO_CALLBACK
+
Callback function or MXML_NO_CALLBACK

Return Value

-

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

+

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

Discussion

-

The nodes in the specified file are added to the specified top node. +

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. @@ -874,26 +873,26 @@ 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.

mxmlLoadFile

-

Load a file into an XML node tree.

+

Load a file into an XML node tree.

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

Parameters

top
-
Top node
+
Top node
fp
-
File to read from
+
File to read from
cb
-
Callback function or MXML_NO_CALLBACK
+
Callback function or MXML_NO_CALLBACK

Return Value

-

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

+

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

Discussion

-

The nodes in the specified file are added to the specified top node. +

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. @@ -904,26 +903,26 @@ 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.

mxmlLoadString

-

Load a string into an XML node tree.

+

Load a string into an XML node tree.

-mxml_node_t *mxmlLoadString (
-    mxml_node_t *top,
-    const char *s,
-    mxml_load_cb_t cb
+mxml_node_t *mxmlLoadString (
+    mxml_node_t *top,
+    const char *s,
+    mxml_load_cb_t cb
);

Parameters

top
-
Top node
+
Top node
s
-
String to load
+
String to load
cb
-
Callback function or MXML_NO_CALLBACK
+
Callback function or MXML_NO_CALLBACK

Return Value

-

First node or NULL if the string has errors.

+

First node or NULL if the string has errors.

Discussion

-

The nodes in the specified string are added to the specified top node. +

The nodes in the specified string are added to the specified top node. 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. @@ -934,279 +933,279 @@ 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.

 Mini-XML 2.3 mxmlNewCDATA

-

Create a new CDATA node.

+

Create a new CDATA node.

-mxml_node_t *mxmlNewCDATA (
-    mxml_node_t *parent,
-    const char *data
+mxml_node_t *mxmlNewCDATA (
+    mxml_node_t *parent,
+    const char *data
);

Parameters

parent
-
Parent node or MXML_NO_PARENT
+
Parent node or MXML_NO_PARENT
data
-
Data string
+
Data string

Return Value

-

New node

+

New node

Discussion

-

The new CDATA node is added to the end of the specified parent's child +

The new CDATA 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 CDATA node has no parent. The data string must be nul-terminated and is copied into the new node. CDATA nodes use the MXML_ELEMENT type.

 Mini-XML 2.1 mxmlNewCustom

-

Create a new custom data node.

+

Create a new custom data node.

-mxml_node_t *mxmlNewCustom (
-    mxml_node_t *parent,
-    void *data,
-    mxml_custom_destroy_cb_t destroy
+mxml_node_t *mxmlNewCustom (
+    mxml_node_t *parent,
+    void *data,
+    mxml_custom_destroy_cb_t destroy
);

Parameters

parent
-
Parent node or MXML_NO_PARENT
+
Parent node or MXML_NO_PARENT
data
-
Pointer to data
+
Pointer to data
destroy
-
Function to destroy data
+
Function to destroy data

Return Value

-

New node

+

New node

Discussion

-

The new custom node is added to the end of the specified parent's child +

The new custom 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. NULL can be passed when the data in the node is not dynamically allocated or is separately managed.

mxmlNewElement

-

Create a new element node.

+

Create a new element node.

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

Parameters

parent
-
Parent node or MXML_NO_PARENT
+
Parent node or MXML_NO_PARENT
name
-
Name of element
+
Name of element

Return Value

-

New node

+

New node

Discussion

-

The new element node is added to the end of the specified parent's child +

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.

mxmlNewInteger

-

Create a new integer node.

+

Create a new integer node.

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

Parameters

parent
-
Parent node or MXML_NO_PARENT
+
Parent node or MXML_NO_PARENT
integer
-
Integer value
+
Integer value

Return Value

-

New node

+

New node

Discussion

-

The new integer node is added to the end of the specified parent's child +

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.

mxmlNewOpaque

-

Create a new opaque string.

+

Create a new opaque string.

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

Parameters

parent
-
Parent node or MXML_NO_PARENT
+
Parent node or MXML_NO_PARENT
opaque
-
Opaque string
+
Opaque string

Return Value

-

New node

+

New node

Discussion

-

The new opaque node is added to the end of the specified parent's child +

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.

mxmlNewReal

-

Create a new real number node.

+

Create a new real number node.

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

Parameters

parent
-
Parent node or MXML_NO_PARENT
+
Parent node or MXML_NO_PARENT
real
-
Real number value
+
Real number value

Return Value

-

New node

+

New node

Discussion

-

The new real number node is added to the end of the specified parent's +

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.

mxmlNewText

-

Create a new text fragment node.

+

Create a new text fragment node.

-mxml_node_t *mxmlNewText (
-    mxml_node_t *parent,
-    int whitespace,
-    const char *string
+mxml_node_t *mxmlNewText (
+    mxml_node_t *parent,
+    int whitespace,
+    const char *string
);

Parameters

parent
-
Parent node or MXML_NO_PARENT
+
Parent node or MXML_NO_PARENT
whitespace
-
1 = leading whitespace, 0 = no whitespace
+
1 = leading whitespace, 0 = no whitespace
string
-
String
+
String

Return Value

-

New node

+

New node

Discussion

-

The new text node is added to the end of the specified parent's child +

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.

mxmlNewTextf

-

Create a new formatted text fragment node.

+

Create a new formatted text fragment node.

-mxml_node_t *mxmlNewTextf (
-    mxml_node_t *parent,
-    int whitespace,
-    const char *format,
-    ...
+mxml_node_t *mxmlNewTextf (
+    mxml_node_t *parent,
+    int whitespace,
+    const char *format,
+    ...
);

Parameters

parent
-
Parent node or MXML_NO_PARENT
+
Parent node or MXML_NO_PARENT
whitespace
-
1 = leading whitespace, 0 = no whitespace
+
1 = leading whitespace, 0 = no whitespace
format
-
Printf-style frmat string
+
Printf-style frmat string
...
-
Additional args as needed
+
Additional args as needed

Return Value

-

New node

+

New node

Discussion

-

The new text node is added to the end of the specified parent's child +

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 format string must be nul-terminated and is formatted into the new node.

 Mini-XML 2.3 mxmlNewXML

-

Create a new XML document tree.

+

Create a new XML document tree.

-mxml_node_t *mxmlNewXML (
-    const char *version
+mxml_node_t *mxmlNewXML (
+    const char *version
);

Parameters

version
-
Version number to use
+
Version number to use

Return Value

-

New ?xml node

+

New ?xml node

Discussion

-

The "version" argument specifies the version number to put in the +

The "version" argument specifies the version number to put in the ?xml element node. If NULL, version 1.0 is assumed.

 Mini-XML 2.3 mxmlRelease

-

Release a node.

+

Release a node.

-int mxmlRelease (
-    mxml_node_t *node
+int mxmlRelease (
+    mxml_node_t *node
);

Parameters

node
-
Node
+
Node

Return Value

-

New reference count

+

New reference count

Discussion

-

When the reference count reaches zero, the node (and any children) +

When the reference count reaches zero, the node (and any children) is deleted via mxmlDelete().

mxmlRemove

-

Remove a node from its parent.

+

Remove a node from its parent.

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

Parameters

node
-
Node to remove
+
Node to remove

Discussion

-

Does not free memory used by the node - use mxmlDelete() for that. +

Does not free memory used by the node - use mxmlDelete() for that. This function does nothing if the node has no parent.

 Mini-XML 2.3 mxmlRetain

-

Retain a node.

+

Retain a node.

-int mxmlRetain (
-    mxml_node_t *node
+int mxmlRetain (
+    mxml_node_t *node
);

Parameters

node
-
Node
+
Node

Return Value

-

New reference count

+

New reference count

 Mini-XML 2.3 mxmlSAXLoadFd

-

Load a file descriptor into an XML node tree +

Load a file descriptor into an XML node tree using a SAX callback.

-mxml_node_t *mxmlSAXLoadFd (
-    mxml_node_t *top,
-    int fd,
-    mxml_load_cb_t cb,
-    mxml_sax_cb_t sax_cb,
-    void *sax_data
+mxml_node_t *mxmlSAXLoadFd (
+    mxml_node_t *top,
+    int fd,
+    mxml_load_cb_t cb,
+    mxml_sax_cb_t sax_cb,
+    void *sax_data
);

Parameters

top
-
Top node
+
Top node
fd
-
File descriptor to read from
+
File descriptor to read from
cb
-
Callback function or MXML_NO_CALLBACK
+
Callback function or MXML_NO_CALLBACK
sax_cb
-
SAX callback or MXML_NO_CALLBACK
+
SAX callback or MXML_NO_CALLBACK
sax_data
-
SAX user data
+
SAX user data

Return Value

-

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

+

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

Discussion

-

The nodes in the specified file are added to the specified top node. +

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. @@ -1223,33 +1222,33 @@ node is closed or after each data, comment, CDATA, or directive node.

 Mini-XML 2.3 mxmlSAXLoadFile

-

Load a file into an XML node tree +

Load a file into an XML node tree using a SAX callback.

-mxml_node_t *mxmlSAXLoadFile (
-    mxml_node_t *top,
-    FILE *fp,
-    mxml_load_cb_t cb,
-    mxml_sax_cb_t sax_cb,
-    void *sax_data
+mxml_node_t *mxmlSAXLoadFile (
+    mxml_node_t *top,
+    FILE *fp,
+    mxml_load_cb_t cb,
+    mxml_sax_cb_t sax_cb,
+    void *sax_data
);

Parameters

top
-
Top node
+
Top node
fp
-
File to read from
+
File to read from
cb
-
Callback function or MXML_NO_CALLBACK
+
Callback function or MXML_NO_CALLBACK
sax_cb
-
SAX callback or MXML_NO_CALLBACK
+
SAX callback or MXML_NO_CALLBACK
sax_data
-
SAX user data
+
SAX user data

Return Value

-

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

+

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

Discussion

-

The nodes in the specified file are added to the specified top node. +

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. @@ -1266,33 +1265,33 @@ node is closed or after each data, comment, CDATA, or directive node.

 Mini-XML 2.3 mxmlSAXLoadString

-

Load a string into an XML node tree +

Load a string into an XML node tree using a SAX callback.

-mxml_node_t *mxmlSAXLoadString (
-    mxml_node_t *top,
-    const char *s,
-    mxml_load_cb_t cb,
-    mxml_sax_cb_t sax_cb,
-    void *sax_data
+mxml_node_t *mxmlSAXLoadString (
+    mxml_node_t *top,
+    const char *s,
+    mxml_load_cb_t cb,
+    mxml_sax_cb_t sax_cb,
+    void *sax_data
);

Parameters

top
-
Top node
+
Top node
s
-
String to load
+
String to load
cb
-
Callback function or MXML_NO_CALLBACK
+
Callback function or MXML_NO_CALLBACK
sax_cb
-
SAX callback or MXML_NO_CALLBACK
+
SAX callback or MXML_NO_CALLBACK
sax_data
-
SAX user data
+
SAX user data

Return Value

-

First node or NULL if the string has errors.

+

First node or NULL if the string has errors.

Discussion

-

The nodes in the specified string are added to the specified top node. +

The nodes in the specified string are added to the specified top node. 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. @@ -1309,23 +1308,23 @@ node is closed or after each data, comment, CDATA, or directive node.

mxmlSaveAllocString

-

Save an XML tree to an allocated string.

+

Save an XML tree to an allocated string.

-char *mxmlSaveAllocString (
-    mxml_node_t *node,
-    mxml_save_cb_t cb
+char *mxmlSaveAllocString (
+    mxml_node_t *node,
+    mxml_save_cb_t cb
);

Parameters

node
-
Node to write
+
Node to write
cb
-
Whitespace callback or MXML_NO_CALLBACK
+
Whitespace callback or MXML_NO_CALLBACK

Return Value

-

Allocated string or NULL

+

Allocated string or NULL

Discussion

-

This function returns a pointer to a string containing the textual +

This function returns a pointer to a string containing the textual 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 @@ -1337,79 +1336,79 @@ is specified, whitespace will only be added before MXML_TEXT nodes with leading whitespace and before attribute names inside opening element tags.

mxmlSaveFd

-

Save an XML tree to a file descriptor.

+

Save an XML tree to a file descriptor.

-int mxmlSaveFd (
-    mxml_node_t *node,
-    int fd,
-    mxml_save_cb_t cb
+int mxmlSaveFd (
+    mxml_node_t *node,
+    int fd,
+    mxml_save_cb_t cb
);

Parameters

node
-
Node to write
+
Node to write
fd
-
File descriptor to write to
+
File descriptor to write to
cb
-
Whitespace callback or MXML_NO_CALLBACK
+
Whitespace callback or MXML_NO_CALLBACK

Return Value

-

0 on success, -1 on error.

+

0 on success, -1 on error.

Discussion

-

The callback argument specifies a function that returns a whitespace +

The callback argument specifies a function that returns a whitespace string or NULL 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.

mxmlSaveFile

-

Save an XML tree to a file.

+

Save an XML tree to a file.

-int mxmlSaveFile (
-    mxml_node_t *node,
-    FILE *fp,
-    mxml_save_cb_t cb
+int mxmlSaveFile (
+    mxml_node_t *node,
+    FILE *fp,
+    mxml_save_cb_t cb
);

Parameters

node
-
Node to write
+
Node to write
fp
-
File to write to
+
File to write to
cb
-
Whitespace callback or MXML_NO_CALLBACK
+
Whitespace callback or MXML_NO_CALLBACK

Return Value

-

0 on success, -1 on error.

+

0 on success, -1 on error.

Discussion

-

The callback argument specifies a function that returns a whitespace +

The callback argument specifies a function that returns a whitespace string or NULL 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.

mxmlSaveString

-

Save an XML node tree to a string.

+

Save an XML node tree to a string.

-int mxmlSaveString (
-    mxml_node_t *node,
-    char *buffer,
-    int bufsize,
-    mxml_save_cb_t cb
+int mxmlSaveString (
+    mxml_node_t *node,
+    char *buffer,
+    int bufsize,
+    mxml_save_cb_t cb
);

Parameters

node
-
Node to write
+
Node to write
buffer
-
String buffer
+
String buffer
bufsize
-
Size of string buffer
+
Size of string buffer
cb
-
Whitespace callback or MXML_NO_CALLBACK
+
Whitespace callback or MXML_NO_CALLBACK

Return Value

-

Size of string

+

Size of string

Discussion

-

This function returns the total number of bytes that would be +

This function returns the total number of bytes that would be required for the string but only copies (bufsize - 1) characters into the specified buffer.

@@ -1419,371 +1418,371 @@ is specified, whitespace will only be added before MXML_TEXT nodes with leading whitespace and before attribute names inside opening element tags.

 Mini-XML 2.3 mxmlSetCDATA

-

Set the element name of a CDATA node.

+

Set the element name of a CDATA node.

-int mxmlSetCDATA (
-    mxml_node_t *node,
-    const char *data
+int mxmlSetCDATA (
+    mxml_node_t *node,
+    const char *data
);

Parameters

node
-
Node to set
+
Node to set
data
-
New data string
+
New data string

Return Value

-

0 on success, -1 on failure

+

0 on success, -1 on failure

Discussion

-

The node is not changed if it (or its first child) is not a CDATA element node. +

The node is not changed if it (or its first child) is not a CDATA element node.

 Mini-XML 2.1 mxmlSetCustom

-

Set the data and destructor of a custom data node.

+

Set the data and destructor of a custom data node.

-int mxmlSetCustom (
-    mxml_node_t *node,
-    void *data,
-    mxml_custom_destroy_cb_t destroy
+int mxmlSetCustom (
+    mxml_node_t *node,
+    void *data,
+    mxml_custom_destroy_cb_t destroy
);

Parameters

node
-
Node to set
+
Node to set
data
-
New data pointer
+
New data pointer
destroy
-
New destructor function
+
New destructor function

Return Value

-

0 on success, -1 on failure

+

0 on success, -1 on failure

Discussion

-

The node is not changed if it (or its first child) is not a custom node. +

The node is not changed if it (or its first child) is not a custom node.

mxmlSetCustomHandlers

-

Set the handling functions for custom data.

+

Set the handling functions for custom data.

-void mxmlSetCustomHandlers (
-    mxml_custom_load_cb_t load,
-    mxml_custom_save_cb_t save
+void mxmlSetCustomHandlers (
+    mxml_custom_load_cb_t load,
+    mxml_custom_save_cb_t save
);

Parameters

load
-
Load function
+
Load function
save
-
Save function
+
Save function

Discussion

-

The load function accepts a node pointer and a data string and must +

The load function accepts a node pointer and a data string and must return 0 on success and non-zero on error.

The save function accepts a node pointer and must return a malloc'd string on success and NULL on error.

mxmlSetElement

-

Set the name of an element node.

+

Set the name of an element node.

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

Parameters

node
-
Node to set
+
Node to set
name
-
New name string
+
New name string

Return Value

-

0 on success, -1 on failure

+

0 on success, -1 on failure

Discussion

-

The node is not changed if it is not an element node.

+

The node is not changed if it is not an element node.

mxmlSetErrorCallback

-

Set the error message callback.

+

Set the error message callback.

-void mxmlSetErrorCallback (
-    mxml_error_cb_t cb
+void mxmlSetErrorCallback (
+    mxml_error_cb_t cb
);

Parameters

cb
-
Error callback function
+
Error callback function

mxmlSetInteger

-

Set the value of an integer node.

+

Set the value of an integer node.

-int mxmlSetInteger (
-    mxml_node_t *node,
-    int integer
+int mxmlSetInteger (
+    mxml_node_t *node,
+    int integer
);

Parameters

node
-
Node to set
+
Node to set
integer
-
Integer value
+
Integer value

Return Value

-

0 on success, -1 on failure

+

0 on success, -1 on failure

Discussion

-

The node is not changed if it (or its first child) is not an integer node.

+

The node is not changed if it (or its first child) is not an integer node.

mxmlSetOpaque

-

Set the value of an opaque node.

+

Set the value of an opaque node.

-int mxmlSetOpaque (
-    mxml_node_t *node,
-    const char *opaque
+int mxmlSetOpaque (
+    mxml_node_t *node,
+    const char *opaque
);

Parameters

node
-
Node to set
+
Node to set
opaque
-
Opaque string
+
Opaque string

Return Value

-

0 on success, -1 on failure

+

0 on success, -1 on failure

Discussion

-

The node is not changed if it (or its first child) is not an opaque node.

+

The node is not changed if it (or its first child) is not an opaque node.

mxmlSetReal

-

Set the value of a real number node.

+

Set the value of a real number node.

-int mxmlSetReal (
-    mxml_node_t *node,
-    double real
+int mxmlSetReal (
+    mxml_node_t *node,
+    double real
);

Parameters

node
-
Node to set
+
Node to set
real
-
Real number value
+
Real number value

Return Value

-

0 on success, -1 on failure

+

0 on success, -1 on failure

Discussion

-

The node is not changed if it (or its first child) is not a real number node.

+

The node is not changed if it (or its first child) is not a real number node.

mxmlSetText

-

Set the value of a text node.

+

Set the value of a text node.

-int mxmlSetText (
-    mxml_node_t *node,
-    int whitespace,
-    const char *string
+int mxmlSetText (
+    mxml_node_t *node,
+    int whitespace,
+    const char *string
);

Parameters

node
-
Node to set
+
Node to set
whitespace
-
1 = leading whitespace, 0 = no whitespace
+
1 = leading whitespace, 0 = no whitespace
string
-
String
+
String

Return Value

-

0 on success, -1 on failure

+

0 on success, -1 on failure

Discussion

-

The node is not changed if it (or its first child) is not a text node.

+

The node is not changed if it (or its first child) is not a text node.

mxmlSetTextf

-

Set the value of a text node to a formatted string.

+

Set the value of a text node to a formatted string.

-int mxmlSetTextf (
-    mxml_node_t *node,
-    int whitespace,
-    const char *format,
-    ...
+int mxmlSetTextf (
+    mxml_node_t *node,
+    int whitespace,
+    const char *format,
+    ...
);

Parameters

node
-
Node to set
+
Node to set
whitespace
-
1 = leading whitespace, 0 = no whitespace
+
1 = leading whitespace, 0 = no whitespace
format
-
Printf-style format string
+
Printf-style format string
...
-
Additional arguments as needed
+
Additional arguments as needed

Return Value

-

0 on success, -1 on failure

+

0 on success, -1 on failure

Discussion

-

The node is not changed if it (or its first child) is not a text node.

+

The node is not changed if it (or its first child) is not a text node.

 Mini-XML 2.7 mxmlSetUserData

-

Set the user data pointer for a node.

+

Set the user data pointer for a node.

-int mxmlSetUserData (
-    mxml_node_t *node,
-    void *data
+int mxmlSetUserData (
+    mxml_node_t *node,
+    void *data
);

Parameters

node
-
Node to set
+
Node to set
data
-
User data pointer
+
User data pointer

Return Value

-

0 on success, -1 on failure

+

0 on success, -1 on failure

 Mini-XML 2.3 mxmlSetWrapMargin

-

Set the wrap margin when saving XML data.

+

Set the wrap margin when saving XML data.

-void mxmlSetWrapMargin (
-    int column
+void mxmlSetWrapMargin (
+    int column
);

Parameters

column
-
Column for wrapping, 0 to disable wrapping
+
Column for wrapping, 0 to disable wrapping

Discussion

-

Wrapping is disabled when "column" is 0. +

Wrapping is disabled when "column" is 0.

mxmlWalkNext

-

Walk to the next logical node in the tree.

+

Walk to the next logical node in the tree.

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

Parameters

node
-
Current node
+
Current node
top
-
Top node
+
Top node
descend
-
Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
+
Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST

Return Value

-

Next node or NULL

+

Next node or NULL

Discussion

-

The descend argument controls whether the first child is considered +

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.

mxmlWalkPrev

-

Walk to the previous logical node in the tree.

+

Walk to the previous logical node in the tree.

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

Parameters

node
-
Current node
+
Current node
top
-
Top node
+
Top node
descend
-
Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
+
Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST

Return Value

-

Previous node or NULL

+

Previous node or NULL

Discussion

-

The descend argument controls whether the previous node's last child +

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.

-

Data Types

-

mxml_custom_destroy_cb_t

-

Custom data destructor

-

+

Data Types

+

mxml_custom_destroy_cb_t

+

Custom data destructor

+

typedef void (*mxml_custom_destroy_cb_t)(void *);

-

mxml_custom_load_cb_t

-

Custom data load callback function

-

+

mxml_custom_load_cb_t

+

Custom data load callback function

+

typedef int (*mxml_custom_load_cb_t)(mxml_node_t *, const char *);

-

mxml_custom_save_cb_t

-

Custom data save callback function

-

+

mxml_custom_save_cb_t

+

Custom data save callback function

+

typedef char *(*mxml_custom_save_cb_t)(mxml_node_t *);

-

mxml_entity_cb_t

-

Entity callback function

-

+

mxml_entity_cb_t

+

Entity callback function

+

typedef int (*mxml_entity_cb_t)(const char *);

-

mxml_error_cb_t

-

Error callback function

-

+

mxml_error_cb_t

+

Error callback function

+

typedef void (*mxml_error_cb_t)(const char *);

-

mxml_index_t

-

An XML node index.

-

+

mxml_index_t

+

An XML node index.

+

typedef struct mxml_index_s mxml_index_t;

-

mxml_load_cb_t

-

Load callback function

-

+

mxml_load_cb_t

+

Load callback function

+

typedef mxml_type_t (*mxml_load_cb_t)(mxml_node_t *);

-

mxml_node_t

-

An XML node.

-

+

mxml_node_t

+

An XML node.

+

typedef struct mxml_node_s mxml_node_t;

-

mxml_save_cb_t

-

Save callback function

-

+

mxml_save_cb_t

+

Save callback function

+

typedef const char *(*mxml_save_cb_t)(mxml_node_t *, int);

-

mxml_sax_cb_t

-

SAX callback function

-

+

mxml_sax_cb_t

+

SAX callback function

+

typedef void (*mxml_sax_cb_t)(mxml_node_t *, mxml_sax_event_t, void *);

-

mxml_sax_event_t

-

SAX event type.

-

+

mxml_sax_event_t

+

SAX event type.

+

typedef enum mxml_sax_event_e mxml_sax_event_t;

-

mxml_type_t

-

The XML node type.

-

+

mxml_type_t

+

The XML node type.

+

typedef enum mxml_type_e mxml_type_t;

-

Constants

-

mxml_sax_event_e

-

SAX event type.

-

Constants

-
-
MXML_SAX_CDATA
-
CDATA node
-
MXML_SAX_COMMENT
-
Comment node
-
MXML_SAX_DATA
-
Data node
-
MXML_SAX_DIRECTIVE
-
Processing directive node
-
MXML_SAX_ELEMENT_CLOSE
-
Element closed
-
MXML_SAX_ELEMENT_OPEN
-
Element opened
+

Constants

+

mxml_sax_event_e

+

SAX event type.

+

Constants

+
+
MXML_SAX_CDATA
+
CDATA node
+
MXML_SAX_COMMENT
+
Comment node
+
MXML_SAX_DATA
+
Data node
+
MXML_SAX_DIRECTIVE
+
Processing directive node
+
MXML_SAX_ELEMENT_CLOSE
+
Element closed
+
MXML_SAX_ELEMENT_OPEN
+
Element opened
-

mxml_type_e

-

The XML node type.

-

Constants

-
-
MXML_CUSTOM  Mini-XML 2.1 
-
Custom data
-
MXML_ELEMENT
-
XML element with attributes
-
MXML_IGNORE  Mini-XML 2.3 
-
Ignore/throw away node
-
MXML_INTEGER
-
Integer value
-
MXML_OPAQUE
-
Opaque string
-
MXML_REAL
-
Real value
-
MXML_TEXT
-
Text fragment
+

mxml_type_e

+

The XML node type.

+

Constants

+
+
MXML_CUSTOM  Mini-XML 2.1 
+
Custom data
+
MXML_ELEMENT
+
XML element with attributes
+
MXML_IGNORE  Mini-XML 2.3 
+
Ignore/throw away node
+
MXML_INTEGER
+
Integer value
+
MXML_OPAQUE
+
Opaque string
+
MXML_REAL
+
Real value
+
MXML_TEXT
+
Text fragment
-
- +
+ diff --git a/mxmldoc.c b/mxmldoc.c index 2d0de1c..0daffd1 100644 --- a/mxmldoc.c +++ b/mxmldoc.c @@ -160,8 +160,7 @@ typedef struct */ static void add_toc(toc_t *toc, int level, const char *anchor, const char *title); -static mxml_node_t *add_variable(mxml_node_t *parent, const char *name, - mxml_node_t *type); +static mxml_node_t *add_variable(mxml_node_t *parent, const char *name, mxml_node_t *type); static toc_t *build_toc(mxml_node_t *doc, const char *introfile); static mxml_node_t *find_public(mxml_node_t *node, mxml_node_t *top, const char *element, const char *name); static void free_toc(toc_t *toc); @@ -172,39 +171,23 @@ static mxml_type_t load_cb(mxml_node_t *node); static mxml_node_t *new_documentation(mxml_node_t **mxmldoc); static int remove_directory(const char *path); static void safe_strcpy(char *dst, const char *src); -static int scan_file(const char *filename, FILE *fp, - mxml_node_t *doc); +static int scan_file(const char *filename, FILE *fp, mxml_node_t *doc); 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 update_comment(mxml_node_t *parent, mxml_node_t *comment); static void usage(const char *option); -static void write_description(FILE *out, mxml_node_t *description, - const char *element, int summary); -static void write_element(FILE *out, mxml_node_t *doc, - mxml_node_t *element, int mode); -static void write_epub(const char *section, const char *title, const char *author, const char *copyright, const char *docversion, const char *footerfile, const char *headerfile, const char *introfile, const char *cssfile, const char *epubfile, mxml_node_t *doc); +static void write_description(FILE *out, mxml_node_t *description, const char *element, int summary); +static void write_element(FILE *out, mxml_node_t *doc, mxml_node_t *element, int mode); +static void write_epub(const char *epubfile, const char *section, const char *title, const char *author, const char *copyright, const char *docversion, const char *cssfile, const char *headerfile, const char *introfile, mxml_node_t *doc, const char *footerfile); static void write_file(FILE *out, const char *file, int mode); static void write_function(FILE *out, int xhtml, mxml_node_t *doc, mxml_node_t *function, int level); -static void write_html(const char *section, const char *title, - const char *footerfile, - const char *headerfile, - const char *introfile, const char *cssfile, - const char *framefile, - const char *docset, const char *docversion, - const char *feedname, const char *feedurl, - mxml_node_t *doc); -static void write_html_head(FILE *out, int xhtml, const char *section, const char *title, const char *cssfile); -static void write_man(const char *man_name, const char *section, - const char *title, const char *headerfile, - const char *footerfile, const char *introfile, - mxml_node_t *doc); +static void write_html(const char *framefile, const char *docset, const char *section, const char *title, const char *author, const char *copyright, const char *docversion, const char *feedname, const char *feedurl, const char *cssfile, const char *headerfile, const char *introfile, mxml_node_t *doc, const char *footerfile); +static void write_html_body(FILE *out, int mode, const char *introfile, mxml_node_t *doc); +static void write_html_head(FILE *out, int mode, const char *section, const char *title, const char *author, const char *copyright, const char *cssfile); +static void write_html_toc(FILE *out, const char *title, toc_t *toc, const char *filename, const char *target); +static void write_man(const char *man_name, const char *section, const char *title, const char *author, const char *copyright, const char *headerfile, const char *introfile, mxml_node_t *doc, const char *footerfile); static void write_scu(FILE *out, int xhtml, mxml_node_t *doc, mxml_node_t *scut); static void write_string(FILE *out, const char *s, int mode); -static void write_toc(FILE *out, mxml_node_t *doc, - const char *introfile, const char *target, - int xml); -static void write_tokens(FILE *out, mxml_node_t *doc, - const char *path); +static void write_tokens(FILE *out, mxml_node_t *doc, const char *path); static const char *ws_cb(mxml_node_t *node, int where); @@ -605,7 +588,7 @@ main(int argc, /* I - Number of command-line args */ */ #ifdef HAVE_ZLIB_H - write_epub(section, title ? title : "Documentation", author ? author : "Unknown", copyright ? copyright : "Unknown", docversion ? docversion : "0.0", footerfile, headerfile, introfile, cssfile, epubfile, mxmldoc); + write_epub(epubfile, section, title ? title : "Documentation", author ? author : "Unknown", copyright ? copyright : "Unknown", docversion ? docversion : "0.0", cssfile, headerfile, introfile, mxmldoc, footerfile); #else fputs("mxmldoc: Sorry, not compiled with EPUB support.\n", stderr); #endif /* HAVE_ZLIB_H */ @@ -616,7 +599,7 @@ main(int argc, /* I - Number of command-line args */ * Write HTML documentation... */ - write_html(section, title ? title : "Documentation", footerfile, headerfile, introfile, cssfile, framefile, docset, docversion ? docversion : "0.0", feedname, feedurl, mxmldoc); + write_html(framefile, docset, section, title ? title : "Documentation", author ? author : "Unknown", copyright ? copyright : "Unknown", docversion ? docversion : "0.0", feedname, feedurl, cssfile, headerfile, introfile, mxmldoc, footerfile); break; case OUTPUT_MAN : @@ -624,8 +607,7 @@ main(int argc, /* I - Number of command-line args */ * Write manpage documentation... */ - write_man(name, section, title, footerfile, headerfile, introfile, - mxmldoc); + write_man(name, section, title, author ? author : "Unknown", copyright ? copyright : "Unknown", headerfile, introfile, mxmldoc, footerfile); break; case OUTPUT_TOKENS : @@ -3200,7 +3182,7 @@ write_description( ptr += 2; if (element && *element) - fprintf(out, "<%s class=\"%s\">", element, + fprintf(out, " <%s class=\"%s\">", element, summary ? "description" : "discussion"); else if (!summary) fputs(".PP\n", out); @@ -3403,28 +3385,21 @@ write_element(FILE *out, /* I - Output file */ */ static void -write_epub(const char *section, /* I - Section */ +write_epub(const char *epubfile, /* I - EPUB file (output) */ + const char *section, /* I - Section */ const char *title, /* I - Title */ const char *author, /* I - Author */ const char *copyright, /* I - Copyright */ const char *docversion, /* I - Document version */ - const char *footerfile, /* I - Footer file */ + const char *cssfile, /* I - Stylesheet file */ const char *headerfile, /* I - Header file */ const char *introfile, /* I - Intro file */ - const char *cssfile, /* I - Stylesheet file */ - const char *epubfile, /* I - EPUB file (output) */ - mxml_node_t *doc) /* I - XML documentation */ + mxml_node_t *doc, /* I - XML documentation */ + const char *footerfile) /* I - Footer file */ { int status = 0; /* Write status */ size_t i; /* Looping var */ FILE *fp; /* Output file */ - mxml_node_t *function, /* Current function */ - *scut, /* Struct/class/union/typedef */ - *arg, /* Current argument */ - *description, /* Description of function/var */ - *type; /* Type for argument */ - const char *name, /* Name of function/type */ - *defval; /* Default value */ char epubbase[256], /* Base name of EPUB file (identifier) */ *epubptr; /* Pointer into base name */ zipc_t *epub; /* EPUB ZIP container */ @@ -3469,9 +3444,7 @@ write_epub(const char *section, /* I - Section */ * Standard header... */ - write_html_head(fp, 1, section, title, cssfile); - - fputs("
\n", fp); + write_html_head(fp, OUTPUT_EPUB, section, title, author, copyright, cssfile); /* * Header... @@ -3491,250 +3464,18 @@ write_epub(const char *section, /* I - Section */ * Use standard header... */ - fputs("

", fp); + fputs("

", fp); write_string(fp, title, OUTPUT_EPUB); fputs("

\n", fp); } /* - * Intro... + * Body... */ - if (introfile) - write_file(fp, introfile, OUTPUT_EPUB); + fputs("
\n", fp); - /* - * List of classes... - */ - - if ((scut = find_public(doc, doc, "class", NULL)) != NULL) - { - fputs("

Classes

\n", fp); - - while (scut) - { - write_scu(fp, 1, doc, scut); - - scut = find_public(scut, doc, "class", NULL); - } - } - - /* - * List of functions... - */ - - if ((function = find_public(doc, doc, "function", NULL)) != NULL) - { - fputs("

Functions

\n", fp); - - while (function) - { - write_function(fp, 1, doc, function, 3); - - function = find_public(function, doc, "function", NULL); - } - } - - /* - * List of types... - */ - - if ((scut = find_public(doc, doc, "typedef", NULL)) != NULL) - { - fputs("

Data Types

\n", fp); - - while (scut) - { - name = mxmlElementGetAttr(scut, "name"); - description = mxmlFindElement(scut, scut, "description", NULL, - NULL, MXML_DESCEND_FIRST); - fprintf(fp, "

%s%s

\n", name, get_comment_info(description), name); - - if (description) - write_description(fp, description, "p", 1); - - fputs("

\n" - "typedef ", fp); - - type = mxmlFindElement(scut, scut, "type", NULL, NULL, MXML_DESCEND_FIRST); - - for (type = type->child; type; type = type->next) - if (!strcmp(type->value.text.string, "(")) - break; - else - { - if (type->value.text.whitespace) - putc(' ', fp); - - if (find_public(doc, doc, "class", type->value.text.string) || - find_public(doc, doc, "enumeration", type->value.text.string) || - find_public(doc, doc, "struct", type->value.text.string) || - find_public(doc, doc, "typedef", type->value.text.string) || - find_public(doc, doc, "union", type->value.text.string)) - { - fputs("value.text.string, OUTPUT_EPUB); - fputs("\">", fp); - write_string(fp, type->value.text.string, OUTPUT_EPUB); - fputs("", fp); - } - else - write_string(fp, type->value.text.string, OUTPUT_EPUB); - } - - if (type) - { - /* - * Output function type... - */ - - if (type->prev && type->prev->value.text.string[0] != '*') - putc(' ', fp); - - fprintf(fp, "(*%s", name); - - for (type = type->next->next; type; type = type->next) - { - if (type->value.text.whitespace) - putc(' ', fp); - - if (find_public(doc, doc, "class", type->value.text.string) || - find_public(doc, doc, "enumeration", type->value.text.string) || - find_public(doc, doc, "struct", type->value.text.string) || - find_public(doc, doc, "typedef", type->value.text.string) || - find_public(doc, doc, "union", type->value.text.string)) - { - fputs("value.text.string, OUTPUT_EPUB); - fputs("\">", fp); - write_string(fp, type->value.text.string, OUTPUT_EPUB); - fputs("", fp); - } - else - write_string(fp, type->value.text.string, OUTPUT_EPUB); - } - - fputs(";\n", fp); - } - else - { - type = mxmlFindElement(scut, scut, "type", NULL, NULL, - MXML_DESCEND_FIRST); - if (type->last_child->value.text.string[0] != '*') - putc(' ', fp); - - fprintf(fp, "%s;\n", name); - } - - fputs("

\n", fp); - - scut = find_public(scut, doc, "typedef", NULL); - } - } - - /* - * List of structures... - */ - - if ((scut = find_public(doc, doc, "struct", NULL)) != NULL) - { - fputs("

Structures

\n", fp); - - while (scut) - { - write_scu(fp, 1, doc, scut); - - scut = find_public(scut, doc, "struct", NULL); - } - } - - /* - * List of unions... - */ - - if ((scut = find_public(doc, doc, "union", NULL)) != NULL) - { - fputs("

Unions

\n", fp); - - while (scut) - { - write_scu(fp, 1, doc, scut); - - scut = find_public(scut, doc, "union", NULL); - } - } - - /* - * Variables... - */ - - if ((arg = find_public(doc, doc, "variable", NULL)) != NULL) - { - fputs("

Variables

\n", fp); - - while (arg) - { - name = mxmlElementGetAttr(arg, "name"); - description = mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST); - fprintf(fp, "

%s%s

\n", name, get_comment_info(description), name); - - if (description) - write_description(fp, description, "p", 1); - - fputs("

", fp); - - write_element(fp, doc, mxmlFindElement(arg, arg, "type", NULL, NULL, MXML_DESCEND_FIRST), OUTPUT_EPUB); - fputs(mxmlElementGetAttr(arg, "name"), fp); - if ((defval = mxmlElementGetAttr(arg, "default")) != NULL) - fprintf(fp, " %s", defval); - fputs(";

\n", fp); - - arg = find_public(arg, doc, "variable", NULL); - } - } - - /* - * List of enumerations... - */ - - if ((scut = find_public(doc, doc, "enumeration", NULL)) != NULL) - { - fputs("

Constants

\n", fp); - - while (scut) - { - name = mxmlElementGetAttr(scut, "name"); - description = mxmlFindElement(scut, scut, "description", NULL, - NULL, MXML_DESCEND_FIRST); - fprintf(fp, "

%s%s

\n", name, get_comment_info(description), name); - - if (description) - write_description(fp, description, "p", 1); - - fputs("

Constants

\n" - "
\n", fp); - - for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "constant", NULL, NULL, - MXML_NO_DESCEND)) - { - description = mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST); - fprintf(fp, "
%s %s
\n", - mxmlElementGetAttr(arg, "name"), get_comment_info(description)); - - write_description(fp, description, "dd", 1); - write_description(fp, description, "dd", 0); - } - - fputs("
\n", fp); - - scut = find_public(scut, doc, "enumeration", NULL); - } - } + write_html_body(fp, OUTPUT_EPUB, introfile, doc); /* * Footer... @@ -3749,8 +3490,8 @@ write_epub(const char *section, /* I - Section */ write_file(fp, footerfile, OUTPUT_EPUB); } - fputs("
\n" - "\n" + fputs("
\n" + " \n" "\n", fp); /* @@ -4141,31 +3882,33 @@ write_function(FILE *out, /* I - Output file */ */ static void -write_html(const char *section, /* I - Section */ - const char *title, /* I - Title */ - const char *footerfile, /* I - Footer file */ - const char *headerfile, /* I - Header file */ - const char *introfile, /* I - Intro file */ - const char *cssfile, /* I - Stylesheet file */ - const char *framefile, /* I - Framed HTML basename */ +write_html(const char *framefile, /* I - Framed HTML basename */ const char *docset, /* I - Documentation set directory */ + const char *section, /* I - Section */ + const char *title, /* I - Title */ + const char *author, /* I - Author's name */ + const char *copyright, /* I - Copyright string */ const char *docversion, /* I - Documentation set version */ const char *feedname, /* I - Feed name for doc set */ const char *feedurl, /* I - Feed URL for doc set */ - mxml_node_t *doc) /* I - XML documentation */ + const char *cssfile, /* I - Stylesheet file */ + const char *headerfile, /* I - Header file */ + const char *introfile, /* I - Intro file */ + mxml_node_t *doc, /* I - XML documentation */ + const char *footerfile) /* I - Footer file */ { FILE *out; /* Output file */ - mxml_node_t *function, /* Current function */ - *scut, /* Struct/class/union/typedef */ - *arg, /* Current argument */ - *description, /* Description of function/var */ - *type; /* Type for argument */ - const char *name, /* Name of function/type */ - *defval, /* Default value */ - *basename; /* Base filename for framed output */ + const char *basename; /* Base filename for framed output */ char filename[1024]; /* Current output filename */ + toc_t *toc; /* Table of contents */ + /* + * Create the table-of-contents entries... + */ + + toc = build_toc(doc, introfile); + if (framefile) { /* @@ -4195,33 +3938,39 @@ write_html(const char *section, /* I - Section */ fputs("\n" "\n" - "\n" - "\t", out); + " <head>\n" + " <title>", out); write_string(out, title, OUTPUT_HTML); fputs("\n", out); if (section) - fprintf(out, "\t\n", section); + fprintf(out, " \n", section); - fputs("\t\n" "\t\n" - "\n", out); + "\t\n" + " \n" + " \n", out); - fputs("\n", out); - fprintf(out, "\n", basename); - fprintf(out, "\n", basename); - fputs("\n" - "\n" - "<h1>", out); + fputs(" <frameset cols=\"250,*\">\n", out); + fprintf(out, " <frame src=\"%s-toc.html\">\n", basename); + fprintf(out, " <frame name=\"body\" src=\"%s-body.html\">\n", basename); + fputs(" </frameset>\n" + " <noframes>\n" + " <h1>", out); write_string(out, title, OUTPUT_HTML); fprintf(out, "</h1>\n" - "<ul>\n" - "\t<li><a href=\"%s-toc.html\">Table of Contents</a></li>\n" - "\t<li><a href=\"%s-body.html\">Body</a></li>\n" - "</ul>\n", basename, basename); - fputs("\n" + " \n", basename, basename); + fputs(" \n" "\n", out); fclose(out); @@ -4238,20 +3987,13 @@ write_html(const char *section, /* I - Section */ return; } - write_html_head(out, 0, section, title, cssfile); + write_html_head(out, OUTPUT_HTML, section, title, author, copyright, cssfile); snprintf(filename, sizeof(filename), "%s-body.html", basename); - fputs("
\n", out); - fprintf(out, "

", - filename); - write_string(out, title, OUTPUT_HTML); - fputs("

\n", out); + write_html_toc(out, title, toc, filename, "body"); - write_toc(out, doc, introfile, filename, 0); - - fputs("
\n" - "\n" + fputs(" \n" "\n", out); fclose(out); @@ -4277,7 +4019,11 @@ write_html(const char *section, /* I - Section */ #ifdef __APPLE__ const char *id; /* Identifier */ - + size_t i; /* Looping var */ + toc_entry_t *tentry; /* Current table of contents */ + int toc_level; /* Current table-of-contents level */ + int xmlid = 1; /* Current XML node ID */ + const char *indent; /* Indentation */ if (!access(docset, 0) && !remove_directory(docset)) return; @@ -4338,41 +4084,41 @@ write_html(const char *section, /* I - Section */ fputs("\n" "\n" "\n" - "\n" - "\tCFBundleIdentifier\n" - "\t", out); + " \n" + " CFBundleIdentifier\n" + " ", out); write_string(out, id, OUTPUT_HTML); fputs("\n" - "\tCFBundleName\n" - "\t", out); + " CFBundleName\n" + " ", out); write_string(out, title, OUTPUT_HTML); fputs("\n" - "\tCFBundleVersion\n" - "\t", out); + " CFBundleVersion\n" + " ", out); write_string(out, docversion ? docversion : "0.0", OUTPUT_HTML); fputs("\n" - "\tCFBundleShortVersionString\n" - "\t", out); + " CFBundleShortVersionString\n" + " ", out); write_string(out, docversion ? docversion : "0.0", OUTPUT_HTML); fputs("\n", out); if (feedname) { - fputs("\tDocSetFeedName\n" - "\t", out); + fputs(" DocSetFeedName\n" + " ", out); write_string(out, feedname ? feedname : title, OUTPUT_HTML); fputs("\n", out); } if (feedurl) { - fputs("\tDocSetFeedURL\n" - "\t", out); + fputs(" DocSetFeedURL\n" + " ", out); write_string(out, feedurl, OUTPUT_HTML); fputs("\n", out); } - fputs("\n" + fputs(" \n" "\n", out); fclose(out); @@ -4392,19 +4138,50 @@ write_html(const char *section, /* I - Section */ fputs("\n" "\n" - "\n" - "\n" - "", out); + " \n" + " \n" + " ", out); write_string(out, title, OUTPUT_HTML); - fputs("\n" - "Documentation/index.html\n" - "\n", out); + fputs(" \n" + " Documentation/index.html\n" + " \n", out); - write_toc(out, doc, introfile, NULL, 1); + for (i = 0, tentry = toc->entries, toc_level = 1; i < toc->num_entries; i ++, tentry ++) + { + if (tentry->level > toc_level) + { + toc_level = tentry->level; + } + else if (tentry->level < toc_level) + { + fputs(" \n" + " \n", out); + toc_level = tentry->level; + } - fputs("\n" - "\n" - "\n" + indent = toc_level == 2 ? " " : " "; + + fprintf(out, "%s\n" + "%s Documentation/index.html\n" + "%s %s\n" + "%s ", indent, xmlid ++, indent, indent, tentry->anchor, indent); + write_string(out, tentry->title, OUTPUT_HTML); + + if ((i + 1) < toc->num_entries && tentry[1].level > toc_level) + fprintf(out, "\n" + "%s \n", indent); + else + fprintf(out, "\n" + "%s\n", indent); + } + + if (toc_level == 2) + fputs(" \n" + " \n", out); + + fputs(" \n" + " \n" + " \n" "\n", out); fclose(out); @@ -4457,9 +4234,7 @@ write_html(const char *section, /* I - Section */ * Standard header... */ - write_html_head(out, 0, section, title, cssfile); - - fputs("
\n", out); + write_html_head(out, OUTPUT_HTML, section, title, author, copyright, cssfile); /* * Header... @@ -4479,7 +4254,7 @@ write_html(const char *section, /* I - Section */ * Use standard header... */ - fputs("

", out); + fputs("

", out); write_string(out, title, OUTPUT_HTML); fputs("

\n", out); } @@ -4489,260 +4264,17 @@ write_html(const char *section, /* I - Section */ */ if (!framefile) - write_toc(out, doc, introfile, NULL, 0); + write_html_toc(out, title, toc, NULL, NULL); + + free_toc(toc); /* - * Intro... + * Body... */ - if (introfile) - write_file(out, introfile, OUTPUT_HTML); + fputs("
\n", out); - /* - * List of classes... - */ - - if ((scut = find_public(doc, doc, "class", NULL)) != NULL) - { - fputs("

Classes

\n", out); - - while (scut) - { - write_scu(out, 0, doc, scut); - - scut = find_public(scut, doc, "class", NULL); - } - } - - /* - * List of functions... - */ - - if ((function = find_public(doc, doc, "function", NULL)) != NULL) - { - fputs("

Functions

\n", out); - - while (function) - { - write_function(out, 0, doc, function, 3); - - function = find_public(function, doc, "function", NULL); - } - } - - /* - * List of types... - */ - - if ((scut = find_public(doc, doc, "typedef", NULL)) != NULL) - { - fputs("

Data Types

\n", out); - - while (scut) - { - name = mxmlElementGetAttr(scut, "name"); - description = mxmlFindElement(scut, scut, "description", NULL, - NULL, MXML_DESCEND_FIRST); - fprintf(out, "

%s%s

\n", - get_comment_info(description), name, name); - - if (description) - write_description(out, description, "p", 1); - - fputs("

\n" - "typedef ", out); - - type = mxmlFindElement(scut, scut, "type", NULL, NULL, - MXML_DESCEND_FIRST); - - for (type = type->child; type; type = type->next) - { - if (!strcmp(type->value.text.string, "(")) - { - break; - } - else - { - if (type->value.text.whitespace) - putc(' ', out); - - if (find_public(doc, doc, "class", type->value.text.string) || - find_public(doc, doc, "enumeration", type->value.text.string) || - find_public(doc, doc, "struct", type->value.text.string) || - find_public(doc, doc, "typedef", type->value.text.string) || - find_public(doc, doc, "union", type->value.text.string)) - { - fputs("value.text.string, OUTPUT_HTML); - fputs("\">", out); - write_string(out, type->value.text.string, OUTPUT_HTML); - fputs("", out); - } - else - write_string(out, type->value.text.string, OUTPUT_HTML); - } - } - - if (type) - { - /* - * Output function type... - */ - - if (type->prev && type->prev->value.text.string[0] != '*') - putc(' ', out); - - fprintf(out, "(*%s", name); - - for (type = type->next->next; type; type = type->next) - { - if (type->value.text.whitespace) - putc(' ', out); - - if (find_public(doc, doc, "class", type->value.text.string) || - find_public(doc, doc, "enumeration", type->value.text.string) || - find_public(doc, doc, "struct", type->value.text.string) || - find_public(doc, doc, "typedef", type->value.text.string) || - find_public(doc, doc, "union", type->value.text.string)) - { - fputs("value.text.string, OUTPUT_HTML); - fputs("\">", out); - write_string(out, type->value.text.string, OUTPUT_HTML); - fputs("", out); - } - else - write_string(out, type->value.text.string, OUTPUT_HTML); - } - - fputs(";\n", out); - } - else - { - type = mxmlFindElement(scut, scut, "type", NULL, NULL, - MXML_DESCEND_FIRST); - if (type->last_child->value.text.string[0] != '*') - putc(' ', out); - - fprintf(out, "%s;\n", name); - } - - fputs("

\n", out); - - scut = find_public(scut, doc, "typedef", NULL); - } - } - - /* - * List of structures... - */ - - if ((scut = find_public(doc, doc, "struct", NULL)) != NULL) - { - fputs("

Structures

\n", - out); - - while (scut) - { - write_scu(out, 0, doc, scut); - - scut = find_public(scut, doc, "struct", NULL); - } - } - - /* - * List of unions... - */ - - if ((scut = find_public(doc, doc, "union", NULL)) != NULL) - { - fputs("

Unions

\n", out); - - while (scut) - { - write_scu(out, 0, doc, scut); - - scut = find_public(scut, doc, "union", NULL); - } - } - - /* - * Variables... - */ - - if ((arg = find_public(doc, doc, "variable", NULL)) != NULL) - { - fputs("

Variables

\n", - out); - - while (arg) - { - name = mxmlElementGetAttr(arg, "name"); - description = mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST); - fprintf(out, "

%s%s

\n", - get_comment_info(description), name, name); - - if (description) - write_description(out, description, "p", 1); - - fputs("

", out); - - write_element(out, doc, mxmlFindElement(arg, arg, "type", NULL, - NULL, MXML_DESCEND_FIRST), - OUTPUT_HTML); - fputs(mxmlElementGetAttr(arg, "name"), out); - if ((defval = mxmlElementGetAttr(arg, "default")) != NULL) - fprintf(out, " %s", defval); - fputs(";

\n", out); - - arg = find_public(arg, doc, "variable", NULL); - } - } - - /* - * List of enumerations... - */ - - if ((scut = find_public(doc, doc, "enumeration", NULL)) != NULL) - { - fputs("

Constants

\n", - out); - - while (scut) - { - name = mxmlElementGetAttr(scut, "name"); - description = mxmlFindElement(scut, scut, "description", NULL, - NULL, MXML_DESCEND_FIRST); - fprintf(out, "

%s%s

\n", - get_comment_info(description), name, name); - - if (description) - write_description(out, description, "p", 1); - - fputs("

Constants

\n" - "
\n", out); - - for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "constant", NULL, NULL, - MXML_NO_DESCEND)) - { - description = mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST); - fprintf(out, "
%s %s
\n", - mxmlElementGetAttr(arg, "name"), get_comment_info(description)); - - write_description(out, description, "dd", 1); - write_description(out, description, "dd", 0); - } - - fputs("
\n", out); - - scut = find_public(scut, doc, "enumeration", NULL); - } - } + write_html_body(out, OUTPUT_HTML, introfile, doc); /* * Footer... @@ -4757,8 +4289,8 @@ write_html(const char *section, /* I - Section */ write_file(out, footerfile, OUTPUT_HTML); } - fputs("
\n" - "\n" + fputs("
\n" + " \n" "\n", out); /* @@ -4825,18 +4357,282 @@ write_html(const char *section, /* I - Section */ } +/* + * 'write_html_body()' - Write a HTML/XHTML body. + */ + +static void +write_html_body( + FILE *out, /* I - Output file */ + int mode, /* I - HTML or EPUB/XHTML output */ + const char *introfile, /* I - Intro file */ + 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 */ + *type; /* Type for argument */ + const char *name, /* Name of function/type */ + *defval; /* Default value */ + + + /* + * Intro... + */ + + if (introfile) + write_file(out, introfile, mode); + + /* + * List of classes... + */ + + if ((scut = find_public(doc, doc, "class", NULL)) != NULL) + { + fputs("

Classes

\n", out); + + while (scut) + { + write_scu(out, 1, doc, scut); + + scut = find_public(scut, doc, "class", NULL); + } + } + + /* + * List of functions... + */ + + if ((function = find_public(doc, doc, "function", NULL)) != NULL) + { + fputs("

Functions

\n", out); + + while (function) + { + write_function(out, 1, doc, function, 3); + + function = find_public(function, doc, "function", NULL); + } + } + + /* + * List of types... + */ + + if ((scut = find_public(doc, doc, "typedef", NULL)) != NULL) + { + fputs("

Data Types

\n", out); + + while (scut) + { + name = mxmlElementGetAttr(scut, "name"); + description = mxmlFindElement(scut, scut, "description", NULL, + NULL, MXML_DESCEND_FIRST); + fprintf(out, "

%s%s

\n", name, get_comment_info(description), name); + + if (description) + write_description(out, description, "p", 1); + + fputs("

\n" + "typedef ", out); + + type = mxmlFindElement(scut, scut, "type", NULL, NULL, MXML_DESCEND_FIRST); + + for (type = type->child; type; type = type->next) + if (!strcmp(type->value.text.string, "(")) + break; + else + { + if (type->value.text.whitespace) + putc(' ', out); + + if (find_public(doc, doc, "class", type->value.text.string) || + find_public(doc, doc, "enumeration", type->value.text.string) || + find_public(doc, doc, "struct", type->value.text.string) || + find_public(doc, doc, "typedef", type->value.text.string) || + find_public(doc, doc, "union", type->value.text.string)) + { + fputs("value.text.string, OUTPUT_HTML); + fputs("\">", out); + write_string(out, type->value.text.string, OUTPUT_HTML); + fputs("", out); + } + else + write_string(out, type->value.text.string, OUTPUT_HTML); + } + + if (type) + { + /* + * Output function type... + */ + + if (type->prev && type->prev->value.text.string[0] != '*') + putc(' ', out); + + fprintf(out, "(*%s", name); + + for (type = type->next->next; type; type = type->next) + { + if (type->value.text.whitespace) + putc(' ', out); + + if (find_public(doc, doc, "class", type->value.text.string) || + find_public(doc, doc, "enumeration", type->value.text.string) || + find_public(doc, doc, "struct", type->value.text.string) || + find_public(doc, doc, "typedef", type->value.text.string) || + find_public(doc, doc, "union", type->value.text.string)) + { + fputs("value.text.string, OUTPUT_HTML); + fputs("\">", out); + write_string(out, type->value.text.string, OUTPUT_HTML); + fputs("", out); + } + else + write_string(out, type->value.text.string, OUTPUT_HTML); + } + + fputs(";\n", out); + } + else + { + type = mxmlFindElement(scut, scut, "type", NULL, NULL, + MXML_DESCEND_FIRST); + if (type->last_child->value.text.string[0] != '*') + putc(' ', out); + + fprintf(out, "%s;\n", name); + } + + fputs("

\n", out); + + scut = find_public(scut, doc, "typedef", NULL); + } + } + + /* + * List of structures... + */ + + if ((scut = find_public(doc, doc, "struct", NULL)) != NULL) + { + fputs("

Structures

\n", out); + + while (scut) + { + write_scu(out, 1, doc, scut); + + scut = find_public(scut, doc, "struct", NULL); + } + } + + /* + * List of unions... + */ + + if ((scut = find_public(doc, doc, "union", NULL)) != NULL) + { + fputs("

Unions

\n", out); + + while (scut) + { + write_scu(out, 1, doc, scut); + + scut = find_public(scut, doc, "union", NULL); + } + } + + /* + * Variables... + */ + + if ((arg = find_public(doc, doc, "variable", NULL)) != NULL) + { + fputs("

Variables

\n", out); + + while (arg) + { + name = mxmlElementGetAttr(arg, "name"); + description = mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST); + fprintf(out, "

%s%s

\n", name, get_comment_info(description), name); + + if (description) + write_description(out, description, "p", 1); + + fputs("

", out); + + write_element(out, doc, mxmlFindElement(arg, arg, "type", NULL, NULL, MXML_DESCEND_FIRST), OUTPUT_HTML); + fputs(mxmlElementGetAttr(arg, "name"), out); + if ((defval = mxmlElementGetAttr(arg, "default")) != NULL) + fprintf(out, " %s", defval); + fputs(";

\n", out); + + arg = find_public(arg, doc, "variable", NULL); + } + } + + /* + * List of enumerations... + */ + + if ((scut = find_public(doc, doc, "enumeration", NULL)) != NULL) + { + fputs("

Constants

\n", out); + + while (scut) + { + name = mxmlElementGetAttr(scut, "name"); + description = mxmlFindElement(scut, scut, "description", NULL, + NULL, MXML_DESCEND_FIRST); + fprintf(out, "

%s%s

\n", name, get_comment_info(description), name); + + if (description) + write_description(out, description, "p", 1); + + fputs("

Constants

\n" + "
\n", out); + + for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL, + MXML_DESCEND_FIRST); + arg; + arg = mxmlFindElement(arg, scut, "constant", NULL, NULL, + MXML_NO_DESCEND)) + { + description = mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST); + fprintf(out, "
%s %s
\n", + mxmlElementGetAttr(arg, "name"), get_comment_info(description)); + + write_description(out, description, "dd", 1); + write_description(out, description, "dd", 0); + } + + fputs("
\n", out); + + scut = find_public(scut, doc, "enumeration", NULL); + } + } +} + + /* * 'write_html_head()' - Write the standard HTML header. */ static void write_html_head(FILE *out, /* I - Output file */ - int xhtml, /* I - XHTML output? */ + int mode, /* I - HTML or EPUB/XHTML */ const char *section, /* I - Section */ const char *title, /* I - Title */ + const char *author, /* I - Author's name */ + const char *copyright, /* I - Copyright string */ const char *cssfile) /* I - Stylesheet */ { - if (xhtml) + if (mode == OUTPUT_EPUB) fputs("\n" "\n" "\n", section); - fputs("\n" - "\t", out); - write_string(out, title, OUTPUT_HTML); - fputs("\t\n", out); + fputs(" \n" + " ", out); + write_string(out, title, mode); + fputs("\n", out); - if (xhtml) + if (mode == OUTPUT_EPUB) { - fputs("\t\n", out); + if (mode == OUTPUT_EPUB) + fputs("]]>\n" + " \n" + " \n", out); else - fputs("-->\n", out); + fputs("-->\n" + " \n" + " \n", out); +} - fputs("\n" - "\n", out); + +/* + * 'write_html_toc()' - Write a HTML table-of-contents. + */ + +static void +write_html_toc(FILE *out, /* I - Output file */ + const char *title, /* I - Title */ + toc_t *toc, /* I - Table of contents */ + const char *filename, /* I - Target filename, if any */ + const char *target) /* I - Target frame name, if any */ +{ + size_t i; /* Looping var */ + toc_entry_t *tentry; /* Current table of contents */ + int toc_level; /* Current table-of-contents level */ + char targetattr[1024]; /* Target attribute, if any */ + + + /* + * If target is set, it is the frame file that contains the body. + * Otherwise, we are creating a single-file... + */ + + if (target) + snprintf(targetattr, sizeof(targetattr), " target=\"%s\"", target); + else + targetattr[0] = '\0'; + + fputs("
\n", out); + + if (filename) + { + fprintf(out, "

", filename, targetattr); + write_string(out, title, OUTPUT_HTML); + fputs("

\n", out); + } + + fputs("

Contents

\n" + "
    \n", out); + + for (i = 0, tentry = toc->entries, toc_level = 1; i < toc->num_entries; i ++, tentry ++) + { + if (tentry->level > toc_level) + { + toc_level = tentry->level; + } + else if (tentry->level < toc_level) + { + fputs("
\n", out); + toc_level = tentry->level; + } + + fprintf(out, " %s
  • ", toc_level == 1 ? "" : " ", filename ? filename : "", tentry->anchor, targetattr); + write_string(out, tentry->title, OUTPUT_HTML); + + if ((i + 1) < toc->num_entries && tentry[1].level > toc_level) + fputs("
      \n", out); + else + fputs("\n", out); + } + + if (toc_level == 2) + fputs("
  • \n", out); + + fputs(" \n" + "
    \n", out); } @@ -5032,10 +4913,12 @@ static void write_man(const char *man_name, /* I - Name of manpage */ const char *section, /* I - Section */ const char *title, /* I - Title */ - const char *footerfile, /* I - Footer file */ + const char *author, /* I - Author's name */ + const char *copyright, /* I - Copyright string */ const char *headerfile, /* I - Header file */ const char *introfile, /* I - Intro file */ - mxml_node_t *doc) /* I - XML documentation */ + mxml_node_t *doc, /* I - XML documentation */ + const char *footerfile) /* I - Footer file */ { int i; /* Looping var */ mxml_node_t *function, /* Current function */ @@ -5545,6 +5428,20 @@ write_man(const char *man_name, /* I - Name of manpage */ write_file(stdout, footerfile, OUTPUT_MAN); } + else + { + /* + * Use standard footer... + */ + + puts(".SH AUTHOR"); + puts(".PP"); + puts(author); + + puts(".SH COPYRIGHT"); + puts(".PP"); + puts(copyright); + } } @@ -5796,612 +5693,6 @@ write_string(FILE *out, /* I - Output file */ } -/* - * 'write_toc()' - Write a table-of-contents. - */ - -static void -write_toc(FILE *out, /* I - Output file */ - mxml_node_t *doc, /* I - Document */ - const char *introfile, /* I - Introduction file */ - const char *target, /* I - Target name */ - int xml) /* I - Write XML nodes? */ -{ - FILE *fp; /* Intro file */ - mxml_node_t *function, /* Current function */ - *scut, /* Struct/class/union/typedef */ - *arg, /* Current argument */ - *description; /* Description of function/var */ - const char *name, /* Name of function/type */ - *targetattr; /* Target attribute, if any */ - int xmlid = 1; /* Current XML node ID */ - - - /* - * If target is set, it is the frame file that contains the body. - * Otherwise, we are creating a single-file... - */ - - if (target) - targetattr = " target=\"body\""; - else - targetattr = ""; - - /* - * The table-of-contents is a nested unordered list. Start by - * reading any intro file to see if there are any headings there. - */ - - if (!xml) - fputs("

    Contents

    \n" - "
      \n", out); - - if (introfile && (fp = fopen(introfile, "r")) != NULL) - { - char line[8192], /* Line from file */ - *ptr, /* Pointer in line */ - *end, /* End of line */ - *anchor, /* Anchor name */ - quote, /* Quote character for value */ - level = '2', /* Current heading level */ - newlevel; /* New heading level */ - int inelement; /* In an element? */ - - - while (fgets(line, sizeof(line), fp)) - { - /* - * See if this line has a heading... - */ - - if ((ptr = strstr(line, "') - inelement = 0; - - *ptr++ = '\0'; - } - - /* - * Write text until we see ""... - */ - - if (xml) - { - if (newlevel < level) - fputs("\n" - "\n", out); - else if (newlevel > level && newlevel == '3') - fputs("\n", out); - else if (xmlid > 1) - fputs("\n", out); - - level = newlevel; - - fprintf(out, "\n" - "Documentation/index.html\n" - "%s\n" - "", xmlid ++, anchor); - - quote = 0; - - while (*ptr) - { - if (inelement) - { - if (*ptr == quote) - quote = 0; - else if (*ptr == '>') - inelement = 0; - else if (*ptr == '\'' || *ptr == '\"') - quote = *ptr; - } - else if (*ptr == '<') - { - if (!strncmp(ptr, "", 4) || !strncmp(ptr, "", 4)) - break; - - inelement = 1; - } - else - putc(*ptr, out); - - ptr ++; - } - - fputs("\n", out); - } - else - { - if (newlevel < level) - fputs("\n" - "
    \n", out); - else if (newlevel > level) - fputs("\n", out); - } - } - - fprintf(out, "\n", xmlid); - fclose(fp); - } - - /* - * Next the classes... - */ - - if ((scut = find_public(doc, doc, "class", NULL)) != NULL) - { - if (xml) - fprintf(out, "\n" - "Documentation/index.html\n" - "CLASSES\n" - "Classes\n" - "\n", xmlid ++); - else - fprintf(out, "
  • Classes" - "
      \n", - target ? target : "", targetattr); - - while (scut) - { - name = mxmlElementGetAttr(scut, "name"); - description = mxmlFindElement(scut, scut, "description", - NULL, NULL, MXML_DESCEND_FIRST); - - if (xml) - { - fprintf(out, "\n" - "Documentation/index.html\n" - "%s\n" - "%s\n" - "\n", xmlid ++, name, name); - } - else - { - fprintf(out, "\t
    • %s
    • \n", name); - } - - scut = find_public(scut, doc, "class", NULL); - } - - if (xml) - fputs("\n", out); - else - fputs("
  • \n", out); - } - - /* - * Functions... - */ - - if ((function = find_public(doc, doc, "function", NULL)) != NULL) - { - if (xml) - fprintf(out, "\n" - "Documentation/index.html\n" - "FUNCTIONS\n" - "Functions\n" - "\n", xmlid ++); - else - fprintf(out, "
  • Functions" - "
      \n", target ? target : "", targetattr); - - while (function) - { - name = mxmlElementGetAttr(function, "name"); - description = mxmlFindElement(function, function, "description", - NULL, NULL, MXML_DESCEND_FIRST); - - if (xml) - { - fprintf(out, "\n" - "Documentation/index.html\n" - "%s\n" - "%s\n" - "\n", xmlid ++, name, name); - } - else - { - fprintf(out, "\t
    • %s
    • \n", name); - } - - function = find_public(function, doc, "function", NULL); - } - - if (xml) - fputs("\n", out); - else - fputs("
  • \n", out); - } - - /* - * Data types... - */ - - if ((scut = find_public(doc, doc, "typedef", NULL)) != NULL) - { - if (xml) - fprintf(out, "\n" - "Documentation/index.html\n" - "TYPES\n" - "Data Types\n" - "\n", xmlid ++); - else - fprintf(out, "
  • Data Types" - "
      \n", target ? target : "", targetattr); - - while (scut) - { - name = mxmlElementGetAttr(scut, "name"); - description = mxmlFindElement(scut, scut, "description", - NULL, NULL, MXML_DESCEND_FIRST); - - if (xml) - { - fprintf(out, "\n" - "Documentation/index.html\n" - "%s\n" - "%s\n" - "\n", xmlid ++, name, name); - } - else - { - fprintf(out, "\t
    • %s
    • \n", name); - } - - scut = find_public(scut, doc, "typedef", NULL); - } - - if (xml) - fputs("\n", out); - else - fputs("
  • \n", out); - } - - /* - * Structures... - */ - - if ((scut = find_public(doc, doc, "struct", NULL)) != NULL) - { - if (xml) - fprintf(out, "\n" - "Documentation/index.html\n" - "STRUCTURES\n" - "Structures\n" - "\n", xmlid ++); - else - fprintf(out, "
  • Structures" - "
      \n", target ? target : "", targetattr); - - while (scut) - { - name = mxmlElementGetAttr(scut, "name"); - description = mxmlFindElement(scut, scut, "description", - NULL, NULL, MXML_DESCEND_FIRST); - - if (xml) - { - fprintf(out, "\n" - "Documentation/index.html\n" - "%s\n" - "%s\n" - "\n", xmlid ++, name, name); - } - else - { - fprintf(out, "\t
    • %s
    • \n", name); - } - - scut = find_public(scut, doc, "struct", NULL); - } - - if (xml) - fputs("\n", out); - else - fputs("
  • \n", out); - } - - /* - * Unions... - */ - - if ((scut = find_public(doc, doc, "union", NULL)) != NULL) - { - if (xml) - fprintf(out, "\n" - "Documentation/index.html\n" - "UNIONS\n" - "Unions\n" - "\n", xmlid ++); - else - fprintf(out, - "
  • Unions
      \n", - target ? target : "", targetattr); - - while (scut) - { - name = mxmlElementGetAttr(scut, "name"); - description = mxmlFindElement(scut, scut, "description", - NULL, NULL, MXML_DESCEND_FIRST); - - if (xml) - { - fprintf(out, "\n" - "Documentation/index.html\n" - "%s\n" - "%s\n" - "\n", xmlid ++, name, name); - } - else - { - fprintf(out, "\t
    • %s
    • \n", name); - } - - scut = find_public(scut, doc, "union", NULL); - } - - if (xml) - fputs("\n", out); - else - fputs("
  • \n", out); - } - - /* - * Globals variables... - */ - - if ((arg = find_public(doc, doc, "variable", NULL)) != NULL) - { - if (xml) - fprintf(out, "\n" - "Documentation/index.html\n" - "VARIABLES\n" - "Variables\n" - "\n", xmlid ++); - else - fprintf(out, "
  • Variables" - "
      \n", target ? target : "", targetattr); - - while (arg) - { - name = mxmlElementGetAttr(arg, "name"); - description = mxmlFindElement(arg, arg, "description", - NULL, NULL, MXML_DESCEND_FIRST); - - if (xml) - { - fprintf(out, "\n" - "Documentation/index.html\n" - "%s\n" - "%s\n" - "\n", xmlid ++, name, name); - } - else - { - fprintf(out, "\t
    • %s
    • \n", name); - } - - arg = find_public(arg, doc, "variable", NULL); - } - - if (xml) - fputs("\n", out); - else - fputs("
  • \n", out); - } - - /* - * Enumerations/constants... - */ - - if ((scut = find_public(doc, doc, "enumeration", NULL)) != NULL) - { - if (xml) - fprintf(out, "\n" - "Documentation/index.html\n" - "ENUMERATIONS\n" - "Constants\n" - "\n", xmlid ++); - else - fprintf(out, "
  • Constants" - "
      \n", target ? target : "", targetattr); - - while (scut) - { - name = mxmlElementGetAttr(scut, "name"); - description = mxmlFindElement(scut, scut, "description", - NULL, NULL, MXML_DESCEND_FIRST); - - if (xml) - { - fprintf(out, "\n" - "Documentation/index.html\n" - "%s\n" - "%s\n" - "\n", xmlid ++, name, name); - } - else - { - fprintf(out, "\t
    • %s
    • \n", name); - } - - scut = find_public(scut, doc, "enumeration", NULL); - } - - if (xml) - fputs("\n", out); - else - fputs("
  • \n", out); - } - - /* - * Close out the HTML table-of-contents list as needed... - */ - - if (!xml) - fputs("\n", out); -} - - /* * 'write_tokens()' - Write nodes for all APIs. */ @@ -6435,14 +5726,14 @@ write_tokens(FILE *out, /* I - Output file */ description = mxmlFindElement(scut, scut, "description", NULL, NULL, MXML_DESCEND_FIRST); - fprintf(out, "\n" - "Documentation/%s\n" - "%s\n" - "//apple_ref/cpp/cl/%s\n" - "", path, cename, cename); + fprintf(out, " \n" + " Documentation/%s\n" + " %s\n" + " //apple_ref/cpp/cl/%s\n" + " ", path, cename, cename); write_description(out, description, "", 1); - fputs("\n" - "\n", out); + fputs(" \n" + " \n", out); if ((function = find_public(scut, scut, "function", NULL)) != NULL) { @@ -6452,10 +5743,10 @@ write_tokens(FILE *out, /* I - Output file */ description = mxmlFindElement(function, function, "description", NULL, NULL, MXML_DESCEND_FIRST); - fprintf(out, "\n" - "Documentation/%s\n" - "%s.%s\n" - "//apple_ref/cpp/clm/%s/%s", path, + fprintf(out, " \n" + " Documentation/%s\n" + " %s.%s\n" + " //apple_ref/cpp/clm/%s/%s", path, cename, name, cename, name); arg = mxmlFindElement(function, function, "returnvalue", NULL, @@ -6493,10 +5784,10 @@ write_tokens(FILE *out, /* I - Output file */ fputs("(void", out); fputs(")\n" - "", out); + " ", out); write_description(out, description, "", 1); - fputs("\n" - "", out); + fputs(" \n" + " ", out); arg = mxmlFindElement(function, function, "returnvalue", NULL, NULL, MXML_DESCEND_FIRST); @@ -6536,8 +5827,8 @@ write_tokens(FILE *out, /* I - Output file */ else fputs(");", out); - fputs("\n" - "\n", out); + fputs(" \n" + " \n", out); function = find_public(function, doc, "function", NULL); } @@ -6558,14 +5849,14 @@ write_tokens(FILE *out, /* I - Output file */ description = mxmlFindElement(function, function, "description", NULL, NULL, MXML_DESCEND_FIRST); - fprintf(out, "\n" - "Documentation/%s\n" - "%s\n" - "//apple_ref/c/func/%s\n" - "", path, name, name); + fprintf(out, " \n" + " Documentation/%s\n" + " %s\n" + " //apple_ref/c/func/%s\n" + " ", path, name, name); write_description(out, description, "", 1); - fputs("\n" - "", out); + fputs(" \n" + " ", out); arg = mxmlFindElement(function, function, "returnvalue", NULL, NULL, MXML_DESCEND_FIRST); @@ -6605,8 +5896,8 @@ write_tokens(FILE *out, /* I - Output file */ else fputs(");", out); - fputs("\n" - "\n", out); + fputs(" \n" + " \n", out); function = find_public(function, doc, "function", NULL); } @@ -6624,14 +5915,14 @@ write_tokens(FILE *out, /* I - Output file */ description = mxmlFindElement(scut, scut, "description", NULL, NULL, MXML_DESCEND_FIRST); - fprintf(out, "\n" - "Documentation/%s\n" - "%s\n" - "//apple_ref/c/tdef/%s\n" - "", path, name, name); + fprintf(out, " \n" + " Documentation/%s\n" + " %s\n" + " //apple_ref/c/tdef/%s\n" + " ", path, name, name); write_description(out, description, "", 1); - fputs("\n" - "\n", out); + fputs(" \n" + " \n", out); scut = find_public(scut, doc, "typedef", NULL); } @@ -6649,14 +5940,14 @@ write_tokens(FILE *out, /* I - Output file */ description = mxmlFindElement(scut, scut, "description", NULL, NULL, MXML_DESCEND_FIRST); - fprintf(out, "\n" - "Documentation/%s\n" - "%s\n" - "//apple_ref/c/tag/%s\n" - "", path, name, name); + fprintf(out, " \n" + " Documentation/%s\n" + " %s\n" + " //apple_ref/c/tag/%s\n" + " ", path, name, name); write_description(out, description, "", 1); - fputs("\n" - "\n", out); + fputs(" \n" + " \n", out); scut = find_public(scut, doc, "struct", NULL); } @@ -6674,14 +5965,14 @@ write_tokens(FILE *out, /* I - Output file */ description = mxmlFindElement(scut, scut, "description", NULL, NULL, MXML_DESCEND_FIRST); - fprintf(out, "\n" - "Documentation/%s\n" - "%s\n" - "//apple_ref/c/tag/%s\n" - "", path, name, name); + fprintf(out, " \n" + " Documentation/%s\n" + " %s\n" + " //apple_ref/c/tag/%s\n" + " ", path, name, name); write_description(out, description, "", 1); - fputs("\n" - "\n", out); + fputs(" \n" + " \n", out); scut = find_public(scut, doc, "union", NULL); } @@ -6699,14 +5990,14 @@ write_tokens(FILE *out, /* I - Output file */ description = mxmlFindElement(arg, arg, "description", NULL, NULL, MXML_DESCEND_FIRST); - fprintf(out, "\n" - "Documentation/%s\n" - "%s\n" - "//apple_ref/c/data/%s\n" - "", path, name, name); + fprintf(out, " \n" + " Documentation/%s\n" + " %s\n" + " //apple_ref/c/data/%s\n" + " ", path, name, name); write_description(out, description, "", 1); - fputs("\n" - "\n", out); + fputs(" \n" + " \n", out); arg = find_public(arg, doc, "variable", NULL); } @@ -6724,14 +6015,14 @@ write_tokens(FILE *out, /* I - Output file */ description = mxmlFindElement(scut, scut, "description", NULL, NULL, MXML_DESCEND_FIRST); - fprintf(out, "\n" - "Documentation/%s\n" - "%s\n" - "//apple_ref/c/tag/%s\n" - "", path, cename, cename); + fprintf(out, " \n" + " Documentation/%s\n" + " %s\n" + " //apple_ref/c/tag/%s\n" + " ", path, cename, cename); write_description(out, description, "", 1); - fputs("\n" - "\n", out); + fputs(" \n" + " \n", out); for (arg = mxmlFindElement(scut, scut, "constant", NULL, NULL, MXML_DESCEND_FIRST); @@ -6742,14 +6033,14 @@ write_tokens(FILE *out, /* I - Output file */ name = mxmlElementGetAttr(arg, "name"); description = mxmlFindElement(arg, arg, "description", NULL, NULL, MXML_DESCEND_FIRST); - fprintf(out, "\n" - "Documentation/%s\n" - "%s\n" - "//apple_ref/c/econst/%s\n" - "", path, cename, name); + fprintf(out, " \n" + " Documentation/%s\n" + " %s\n" + " //apple_ref/c/econst/%s\n" + " ", path, cename, name); write_description(out, description, "", 1); - fputs("\n" - "\n", out); + fputs(" \n" + " \n", out); } scut = find_public(scut, doc, "enumeration", NULL);