From 2f1e57787d8f6bb81d6220bca7522894a784c0a1 Mon Sep 17 00:00:00 2001 From: Michael Sweet Date: Fri, 31 Mar 2017 22:46:05 -0400 Subject: [PATCH] Save work - some more validation fixes. --- doc/docset.intro | 2 +- doc/reference.html | 356 ++++++++++++++++++++++----------------------- mxmldoc.c | 121 ++++++++------- 3 files changed, 251 insertions(+), 228 deletions(-) diff --git a/doc/docset.intro b/doc/docset.intro index 731ba66..fa11c99 100644 --- a/doc/docset.intro +++ b/doc/docset.intro @@ -23,7 +23,7 @@ #include <mxml.h> -

Nodes are defined by the "mxml_node_t" structure; +

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 diff --git a/doc/reference.html b/doc/reference.html index 9b24f99..dc477d9 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -241,10 +241,10 @@ using a SAX callback.">mxmlSAXLoadString

Add a node to a tree.

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

Parameters

@@ -268,7 +268,7 @@ MXML_ADD_TO_PARENT can be used to specify a NULL child pointer.

Delete a node and all of its children.

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

Parameters

@@ -278,12 +278,12 @@ void mxmlDelete (

Discussion

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

+

 Mini-XML 2.4 mxmlElementDeleteAttr

Delete an attribute.

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

Parameters

@@ -296,8 +296,8 @@ void mxmlElementDeleteAttr (

Get an attribute.

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

Parameters

@@ -315,9 +315,9 @@ named attribute does not exist.

Set an attribute.

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

Parameters

@@ -333,14 +333,14 @@ void mxmlElementSetAttr (
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

+

 Mini-XML 2.3 mxmlElementSetAttrf

Set an attribute with a formatted value.

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

Parameters

@@ -364,7 +364,7 @@ is not an element.

Add a callback to convert entities to Unicode.

int mxmlEntityAddCallback (
-    mxml_entity_cb_t cb
+    mxml_entity_cb_t cb
);

Parameters

@@ -377,7 +377,7 @@ int mxmlEntityAddCallback (

Get the name that corresponds to the character value.

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

Parameters

@@ -392,7 +392,7 @@ const char *mxmlEntityGetName (

Get the character corresponding to a named entity.

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

Parameters

@@ -408,7 +408,7 @@ name is not known.

Remove a callback.

void mxmlEntityRemoveCallback (
-    mxml_entity_cb_t cb
+    mxml_entity_cb_t cb
);

Parameters

@@ -419,12 +419,12 @@ void mxmlEntityRemoveCallback (

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

Parameters

@@ -452,12 +452,12 @@ whether the search descends into child nodes; normally you will use MXML_DESCEND_FIRST for the initial search and MXML_NO_DESCEND to find additional direct descendents of the node. The top node argument constrains the search to a particular node's children.

-

 Mini-XML 2.7 mxmlFindPath

+

 Mini-XML 2.7 mxmlFindPath

Find a node with the given path.

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

Parameters

@@ -477,11 +477,11 @@ The first child node of the found node is returned if the given node has children and the first child is a value node.

-

 Mini-XML 2.7 mxmlGetCDATA

+

 Mini-XML 2.7 mxmlGetCDATA

Get the value for a CDATA node.

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

Parameters

@@ -494,11 +494,11 @@ const char *mxmlGetCDATA (

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

-

 Mini-XML 2.7 mxmlGetCustom

+

 Mini-XML 2.7 mxmlGetCustom

Get the value for a custom node.

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

Parameters

@@ -512,11 +512,11 @@ const void *mxmlGetCustom (
value node.

-

 Mini-XML 2.7 mxmlGetElement

+

 Mini-XML 2.7 mxmlGetElement

Get the name for an element node.

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

Parameters

@@ -529,11 +529,11 @@ const char *mxmlGetElement (

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

-

 Mini-XML 2.7 mxmlGetFirstChild

+

 Mini-XML 2.7 mxmlGetFirstChild

Get the first child of an element node.

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

Parameters

@@ -547,12 +547,12 @@ const char *mxmlGetElement (
has no children.

-

 Mini-XML 2.7 mxmlGetInteger

+

 Mini-XML 2.7 mxmlGetInteger

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

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

Parameters

@@ -565,11 +565,11 @@ int mxmlGetInteger (

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

-

 Mini-XML 2.7 mxmlGetLastChild

+

 Mini-XML 2.7 mxmlGetLastChild

Get the last child of an element node.

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

Parameters

@@ -587,7 +587,7 @@ has no children.

Return the node type...

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

Parameters

@@ -599,11 +599,11 @@ has no children.

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

-

 Mini-XML 2.7 mxmlGetOpaque

+

 Mini-XML 2.7 mxmlGetOpaque

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

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

Parameters

@@ -617,11 +617,11 @@ const char *mxmlGetOpaque (
value node.

-

 Mini-XML 2.7 mxmlGetParent

+

 Mini-XML 2.7 mxmlGetParent

Get the parent node.

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

Parameters

@@ -634,11 +634,11 @@ value node.

NULL is returned for a root node.

-

 Mini-XML 2.7 mxmlGetPrevSibling

+

 Mini-XML 2.7 mxmlGetPrevSibling

Get the previous node for the current parent.

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

Parameters

@@ -651,11 +651,11 @@ value node.

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

-

 Mini-XML 2.7 mxmlGetReal

+

 Mini-XML 2.7 mxmlGetReal

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

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

Parameters

@@ -668,11 +668,11 @@ double mxmlGetReal (

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

-

 Mini-XML 2.7 mxmlGetRefCount

+

 Mini-XML 2.7 mxmlGetRefCount

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

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

Parameters

@@ -687,12 +687,12 @@ and mxmlRelease functions to increment a reference count. .

-

 Mini-XML 2.7 mxmlGetText

+

 Mini-XML 2.7 mxmlGetText

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

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

Parameters

@@ -708,11 +708,11 @@ const char *mxmlGetText (
The "whitespace" argument can be NULL.

-

 Mini-XML 2.7 mxmlGetType

+

 Mini-XML 2.7 mxmlGetType

Get the node type.

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

Parameters

@@ -725,11 +725,11 @@ The "whitespace" argument can be NULL.

MXML_IGNORE is returned if "node" is NULL.

-

 Mini-XML 2.7 mxmlGetUserData

+

 Mini-XML 2.7 mxmlGetUserData

Get the user data pointer for a node.

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

Parameters

@@ -742,7 +742,7 @@ void *mxmlGetUserData (

Delete an index.

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

Parameters

@@ -753,7 +753,7 @@ void mxmlIndexDelete (

Return the next node in the index.

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

Parameters

@@ -768,9 +768,9 @@ void mxmlIndexDelete (

Find the next matching node.

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

Parameters

@@ -788,11 +788,11 @@ void mxmlIndexDelete (
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

+

 Mini-XML 2.7 mxmlIndexGetCount

Get the number of nodes in an index.

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

Parameters

@@ -805,9 +805,9 @@ int mxmlIndexGetCount (

Create a new index.

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

Parameters

@@ -831,7 +831,7 @@ argument is not NULL.

return the first node in the index.

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

Parameters

@@ -847,9 +847,9 @@ mxmlIndexFind() for the first time.

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 *top,
+    int fd,
+    mxml_load_cb_t cb
);

Parameters

@@ -877,9 +877,9 @@ child nodes of the specified type.

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 *top,
+    FILE *fp,
+    mxml_load_cb_t cb
);

Parameters

@@ -907,9 +907,9 @@ child nodes of the specified type.

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 *top,
+    const char *s,
+    mxml_load_cb_t cb
);

Parameters

@@ -933,12 +933,12 @@ MXML_ELEMENT or MXML_TEXT nodes.
The constants MXML_INTEGER_CALLBACK, MXML_OPAQUE_CALLBACK, MXML_REAL_CALLBACK, and MXML_TEXT_CALLBACK are defined for loading child nodes of the specified type.

-

 Mini-XML 2.3 mxmlNewCDATA

+

 Mini-XML 2.3 mxmlNewCDATA

Create a new CDATA node.

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

Parameters

@@ -956,13 +956,13 @@ 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

+

 Mini-XML 2.1 mxmlNewCustom

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 *parent,
+    void *data,
+    mxml_custom_destroy_cb_t destroy
);

Parameters

@@ -986,8 +986,8 @@ node is not dynamically allocated or is separately managed.

Create a new element node.

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

Parameters

@@ -1006,8 +1006,8 @@ element node has no parent.

Create a new integer node.

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

Parameters

@@ -1026,8 +1026,8 @@ integer node has no parent.

Create a new opaque string.

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

Parameters

@@ -1047,8 +1047,8 @@ is copied into the new node.

Create a new real number node.

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

Parameters

@@ -1067,9 +1067,9 @@ the new real number node has no parent.

Create a new text fragment node.

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

Parameters

@@ -1092,10 +1092,10 @@ string must be nul-terminated and is copied into the new node.

Create a new formatted text fragment node.

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

Parameters

@@ -1116,11 +1116,11 @@ 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

+

 Mini-XML 2.3 mxmlNewXML

Create a new XML document tree.

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

Parameters

@@ -1134,11 +1134,11 @@ string must be nul-terminated and is formatted into the new node.

?xml element node. If NULL, version 1.0 is assumed.

-

 Mini-XML 2.3 mxmlRelease

+

 Mini-XML 2.3 mxmlRelease

Release a node.

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

Parameters

@@ -1156,7 +1156,7 @@ is deleted via mxmlDelete().

Remove a node from its parent.

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

Parameters

@@ -1166,11 +1166,11 @@ void mxmlRemove (

Discussion

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

+

 Mini-XML 2.3 mxmlRetain

Retain a node.

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

Parameters

@@ -1179,16 +1179,16 @@ int mxmlRetain (

Return Value

New reference count

-

 Mini-XML 2.3 mxmlSAXLoadFd

+

 Mini-XML 2.3 mxmlSAXLoadFd

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 *top,
+    int fd,
+    mxml_load_cb_t cb,
+    mxml_sax_cb_t sax_cb,
+    void *sax_data
);

Parameters

@@ -1222,16 +1222,16 @@ be kept for later use. Otherwise, nodes are deleted when the parent node is closed or after each data, comment, CDATA, or directive node.

-

 Mini-XML 2.3 mxmlSAXLoadFile

+

 Mini-XML 2.3 mxmlSAXLoadFile

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 *top,
+    FILE *fp,
+    mxml_load_cb_t cb,
+    mxml_sax_cb_t sax_cb,
+    void *sax_data
);

Parameters

@@ -1265,16 +1265,16 @@ be kept for later use. Otherwise, nodes are deleted when the parent node is closed or after each data, comment, CDATA, or directive node.

-

 Mini-XML 2.3 mxmlSAXLoadString

+

 Mini-XML 2.3 mxmlSAXLoadString

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 *top,
+    const char *s,
+    mxml_load_cb_t cb,
+    mxml_sax_cb_t sax_cb,
+    void *sax_data
);

Parameters

@@ -1312,8 +1312,8 @@ node is closed or after each data, comment, CDATA, or directive node.

Save an XML tree to an allocated string.

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

Parameters

@@ -1340,9 +1340,9 @@ element tags.

Save an XML tree to a file descriptor.

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

Parameters

@@ -1365,9 +1365,9 @@ element tags.

Save an XML tree to a file.

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

Parameters

@@ -1390,10 +1390,10 @@ element tags.

Save an XML node tree to a string.

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

Parameters

@@ -1418,12 +1418,12 @@ 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.

-

 Mini-XML 2.3 mxmlSetCDATA

+

 Mini-XML 2.3 mxmlSetCDATA

Set the element name of a CDATA node.

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

Parameters

@@ -1438,13 +1438,13 @@ int mxmlSetCDATA (

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

-

 Mini-XML 2.1 mxmlSetCustom

+

 Mini-XML 2.1 mxmlSetCustom

Set the data and destructor of a custom data node.

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

Parameters

@@ -1465,8 +1465,8 @@ int mxmlSetCustom (

Set the handling functions for custom data.

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

Parameters

@@ -1485,8 +1485,8 @@ string on success and NULL on error.

Set the name of an element node.

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

Parameters

@@ -1503,7 +1503,7 @@ int mxmlSetElement (

Set the error message callback.

void mxmlSetErrorCallback (
-    mxml_error_cb_t cb
+    mxml_error_cb_t cb
);

Parameters

@@ -1514,8 +1514,8 @@ void mxmlSetErrorCallback (

Set the value of an integer node.

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

Parameters

@@ -1532,8 +1532,8 @@ int mxmlSetInteger (

Set the value of an opaque node.

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

Parameters

@@ -1550,8 +1550,8 @@ int mxmlSetOpaque (

Set the value of a real number node.

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

Parameters

@@ -1568,9 +1568,9 @@ int mxmlSetReal (

Set the value of a text node.

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

Parameters

@@ -1589,10 +1589,10 @@ int mxmlSetText (

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

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

Parameters

@@ -1609,12 +1609,12 @@ int mxmlSetTextf (

0 on success, -1 on failure

Discussion

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

-

 Mini-XML 2.7 mxmlSetUserData

+

 Mini-XML 2.7 mxmlSetUserData

Set the user data pointer for a node.

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

Parameters

@@ -1625,11 +1625,11 @@ int mxmlSetUserData (

Return Value

0 on success, -1 on failure

-

 Mini-XML 2.3 mxmlSetWrapMargin

+

 Mini-XML 2.3 mxmlSetWrapMargin

Set the wrap margin when saving XML data.

void mxmlSetWrapMargin (
-    int column
+    int column
);

Parameters

@@ -1644,9 +1644,9 @@ void mxmlSetWrapMargin (

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 *node,
+    mxml_node_t *top,
+    int descend
);

Parameters

@@ -1667,9 +1667,9 @@ the node's children.

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 *node,
+    mxml_node_t *top,
+    int descend
);

Parameters

@@ -1769,11 +1769,11 @@ typedef enum mxml_type_e mxml_type_t;

The XML node type.

Constants

-
MXML_CUSTOM  Mini-XML 2.1 
+
MXML_CUSTOM  Mini-XML 2.1 
Custom data
MXML_ELEMENT
XML element with attributes
-
MXML_IGNORE  Mini-XML 2.3 
+
MXML_IGNORE  Mini-XML 2.3 
Ignore/throw away node
MXML_INTEGER
Integer value
diff --git a/mxmldoc.c b/mxmldoc.c index 101f8ea..a39748d 100644 --- a/mxmldoc.c +++ b/mxmldoc.c @@ -188,7 +188,7 @@ static void write_description(FILE *out, mxml_node_t *description, 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_file(FILE *out, const char *file); +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, @@ -1206,7 +1206,7 @@ get_comment_info( for (ptr = strchr(text, '@'); ptr; ptr = strchr(ptr + 1, '@')) { if (!strncmp(ptr, "@deprecated@", 12)) - return (" DEPRECATED "); + return (" DEPRECATED "); else if (!strncmp(ptr, "@since ", 7)) { strlcpy(since, ptr + 7, sizeof(since)); @@ -1214,7 +1214,7 @@ get_comment_info( if ((ptr = strchr(since, '@')) != NULL) *ptr = '\0'; - snprintf(info, sizeof(info), " %s ", since); + snprintf(info, sizeof(info), " %s ", since); return (info); } } @@ -3300,7 +3300,7 @@ write_description( * Handle non-breaking space as-is... */ - fputs(" ", out); + fputs(" ", out); } else fprintf(out, "&#x%x;", ch); @@ -3448,7 +3448,7 @@ write_epub(const char *section, /* I - Section */ struct stat toc_xhtmlinfo; /* XHTML file info */ int toc_level; /* Current table-of-contents level */ static const char *mimetype = /* mimetype file as a string */ - "application/epub+zip\n"; + "application/epub+zip"; static const char *container_xml = /* container.xml file as a string */ "\n" "\n" @@ -3488,7 +3488,7 @@ write_epub(const char *section, /* I - Section */ * Use custom header... */ - write_file(fp, headerfile); + write_file(fp, headerfile, OUTPUT_EPUB); } else { @@ -3497,7 +3497,7 @@ write_epub(const char *section, /* I - Section */ */ fputs("

", fp); - write_string(fp, title, OUTPUT_HTML); + write_string(fp, title, OUTPUT_EPUB); fputs("

\n", fp); } @@ -3506,7 +3506,7 @@ write_epub(const char *section, /* I - Section */ */ if (introfile) - write_file(fp, introfile); + write_file(fp, introfile, OUTPUT_EPUB); /* * List of classes... @@ -3584,13 +3584,13 @@ write_epub(const char *section, /* I - Section */ type->value.text.string, MXML_DESCEND)) { fputs("value.text.string, OUTPUT_HTML); + write_string(fp, type->value.text.string, OUTPUT_EPUB); fputs("\">", fp); - write_string(fp, type->value.text.string, OUTPUT_HTML); + write_string(fp, type->value.text.string, OUTPUT_EPUB); fputs("", fp); } else - write_string(fp, type->value.text.string, OUTPUT_HTML); + write_string(fp, type->value.text.string, OUTPUT_EPUB); } if (type) @@ -3621,13 +3621,13 @@ write_epub(const char *section, /* I - Section */ type->value.text.string, MXML_DESCEND)) { fputs("value.text.string, OUTPUT_HTML); + write_string(fp, type->value.text.string, OUTPUT_EPUB); fputs("\">", fp); - write_string(fp, type->value.text.string, OUTPUT_HTML); + write_string(fp, type->value.text.string, OUTPUT_EPUB); fputs("", fp); } else - write_string(fp, type->value.text.string, OUTPUT_HTML); + write_string(fp, type->value.text.string, OUTPUT_EPUB); } fputs(";\n", fp); @@ -3764,7 +3764,7 @@ write_epub(const char *section, /* I - Section */ * Use custom footer... */ - write_file(fp, footerfile); + write_file(fp, footerfile, OUTPUT_EPUB); } fputs("\n" @@ -3917,15 +3917,15 @@ write_epub(const char *section, /* I - Section */ fputs("
\n", fp); fputs("

", fp); - write_string(fp, title, OUTPUT_HTML); + write_string(fp, title, OUTPUT_EPUB); fputs("

\n", fp); fputs("

", fp); - write_string(fp, author, OUTPUT_HTML); + write_string(fp, author, OUTPUT_EPUB); fputs("

\n", fp); fputs("

", fp); - write_string(fp, copyright, OUTPUT_HTML); + write_string(fp, copyright, OUTPUT_EPUB); fputs("

\n", fp); fputs("

Contents

\n", fp); @@ -3945,7 +3945,7 @@ write_epub(const char *section, /* I - Section */ } fprintf(fp, " %s", toc_level == 1 ? "
  • " : "
  • ", tentry->anchor); - write_string(fp, tentry->title, OUTPUT_HTML); + write_string(fp, tentry->title, OUTPUT_EPUB); if ((i + 1) < toc->num_entries && tentry[1].level > toc_level) fputs("\n", fp); else @@ -3955,9 +3955,10 @@ write_epub(const char *section, /* I - Section */ if (toc_level == 2) fputs("
  • \n", fp); - fputs("\n", fp); - fputs("\n", fp); - fputs("\n", fp); + fputs("\n" + "
    \n" + "\n" + "\n", fp); fclose(fp); @@ -3970,6 +3971,7 @@ write_epub(const char *section, /* I - Section */ epub = archive_write_new(); archive_write_set_format_zip(epub); + archive_write_set_options(epub, "!experimental,!zip64"); archive_write_open_filename(epub, epubfile); /* mimetype file */ @@ -3977,7 +3979,7 @@ write_epub(const char *section, /* I - Section */ archive_entry_set_pathname(entry, "mimetype"); archive_entry_set_size(entry, strlen(mimetype)); archive_entry_set_filetype(entry, AE_IFREG); - archive_entry_set_perm(entry, 0644); +// archive_entry_set_perm(entry, 0644); archive_write_header(epub, entry); archive_write_data(epub, mimetype, strlen(mimetype)); archive_entry_free(entry); @@ -3987,7 +3989,7 @@ write_epub(const char *section, /* I - Section */ archive_entry_set_pathname(entry, "META-INF"); archive_entry_set_size(entry, 0); archive_entry_set_filetype(entry, AE_IFDIR); - archive_entry_set_perm(entry, 0755); +// archive_entry_set_perm(entry, 0755); archive_write_header(epub, entry); archive_entry_free(entry); @@ -3996,7 +3998,7 @@ write_epub(const char *section, /* I - Section */ archive_entry_set_pathname(entry, "META-INF/container.xml"); archive_entry_set_size(entry, strlen(container_xml)); archive_entry_set_filetype(entry, AE_IFREG); - archive_entry_set_perm(entry, 0644); +// archive_entry_set_perm(entry, 0644); archive_write_header(epub, entry); archive_write_data(epub, container_xml, strlen(container_xml)); archive_entry_free(entry); @@ -4006,7 +4008,7 @@ write_epub(const char *section, /* I - Section */ archive_entry_set_pathname(entry, "OEBPS"); archive_entry_set_size(entry, 0); archive_entry_set_filetype(entry, AE_IFDIR); - archive_entry_set_perm(entry, 0755); +// archive_entry_set_perm(entry, 0755); archive_write_header(epub, entry); archive_entry_free(entry); @@ -4017,7 +4019,7 @@ write_epub(const char *section, /* I - Section */ archive_entry_set_pathname(entry, "OEBPS/body.xhtml"); archive_entry_set_size(entry, xhtmlinfo.st_size); archive_entry_set_filetype(entry, AE_IFREG); - archive_entry_set_perm(entry, 0644); +// archive_entry_set_perm(entry, 0644); archive_write_header(epub, entry); if ((fp = fopen(xhtmlfile, "r")) != NULL) { @@ -4037,7 +4039,7 @@ write_epub(const char *section, /* I - Section */ archive_entry_set_pathname(entry, "OEBPS/content.opf"); archive_entry_set_size(entry, strlen(content_opf_string)); archive_entry_set_filetype(entry, AE_IFREG); - archive_entry_set_perm(entry, 0644); +// archive_entry_set_perm(entry, 0644); archive_write_header(epub, entry); archive_write_data(epub, content_opf_string, strlen(content_opf_string)); archive_entry_free(entry); @@ -4047,7 +4049,7 @@ write_epub(const char *section, /* I - Section */ archive_entry_set_pathname(entry, "OEBPS/toc.ncx"); archive_entry_set_size(entry, strlen(toc_ncx_string)); archive_entry_set_filetype(entry, AE_IFREG); - archive_entry_set_perm(entry, 0644); +// archive_entry_set_perm(entry, 0644); archive_write_header(epub, entry); archive_write_data(epub, toc_ncx_string, strlen(toc_ncx_string)); archive_entry_free(entry); @@ -4059,7 +4061,7 @@ write_epub(const char *section, /* I - Section */ archive_entry_set_pathname(entry, "OEBPS/toc.xhtml"); archive_entry_set_size(entry, toc_xhtmlinfo.st_size); archive_entry_set_filetype(entry, AE_IFREG); - archive_entry_set_perm(entry, 0644); +// archive_entry_set_perm(entry, 0644); archive_write_header(epub, entry); if ((fp = fopen(toc_xhtmlfile, "r")) != NULL) { @@ -4085,7 +4087,8 @@ write_epub(const char *section, /* I - Section */ static void write_file(FILE *out, /* I - Output file */ - const char *file) /* I - File to copy */ + const char *file, /* I - File to copy */ + int mode) /* I - Output mode */ { FILE *fp; /* Copy file */ char line[8192]; /* Line from file */ @@ -4098,8 +4101,29 @@ write_file(FILE *out, /* I - Output file */ return; } - while (fgets(line, sizeof(line), fp)) - fputs(line, out); + if (mode == OUTPUT_EPUB) + { + char *ptr; /* Pointer into line */ + + while (fgets(line, sizeof(line), fp)) + { + for (ptr = line; *ptr; ptr ++) + { + if (*ptr == '&' && !strncmp(ptr + 1, "nbsp;", 5)) + { + ptr += 5; + fputs(" ", out); + } + else + fputc(*ptr, out); + } + } + } + else + { + while (fgets(line, sizeof(line), fp)) + fputs(line, out); + } fclose(fp); } @@ -4160,7 +4184,7 @@ write_function(FILE *out, /* I - Output file */ type = mxmlFindElement(arg, arg, "type", NULL, NULL, MXML_DESCEND_FIRST); - fprintf(out, "%c%s\n    ", prefix, br); + fprintf(out, "%c%s\n    ", prefix, br); if (type->child) write_element(out, doc, type, OUTPUT_HTML); @@ -4568,7 +4592,7 @@ write_html(const char *section, /* I - Section */ * Use custom header... */ - write_file(out, headerfile); + write_file(out, headerfile, OUTPUT_HTML); } else { @@ -4593,7 +4617,7 @@ write_html(const char *section, /* I - Section */ */ if (introfile) - write_file(out, introfile); + write_file(out, introfile, OUTPUT_HTML); /* * List of classes... @@ -4857,7 +4881,7 @@ write_html(const char *section, /* I - Section */ * Use custom footer... */ - write_file(out, footerfile); + write_file(out, footerfile, OUTPUT_HTML); } fputs("\n" @@ -4941,8 +4965,7 @@ write_html_head(FILE *out, /* I - Output file */ { if (xhtml) fputs("\n" - "\n" + "\n" "\n", out); else @@ -4978,7 +5001,7 @@ write_html_head(FILE *out, /* I - Output file */ * Use custom stylesheet file... */ - write_file(out, cssfile); + write_file(out, cssfile, OUTPUT_HTML); } else { @@ -5185,7 +5208,7 @@ write_man(const char *man_name, /* I - Name of manpage */ * Use custom header... */ - write_file(stdout, headerfile); + write_file(stdout, headerfile, OUTPUT_MAN); } else { @@ -5202,7 +5225,7 @@ write_man(const char *man_name, /* I - Name of manpage */ */ if (introfile) - write_file(stdout, introfile); + write_file(stdout, introfile, OUTPUT_MAN); /* * List of classes... @@ -5647,7 +5670,7 @@ write_man(const char *man_name, /* I - Name of manpage */ * Use custom footer... */ - write_file(stdout, footerfile); + write_file(stdout, footerfile, OUTPUT_MAN); } } @@ -5719,10 +5742,10 @@ write_scu(FILE *out, /* I - Output file */ if (!inscope) { inscope = 1; - fprintf(out, "  %s:
    \n", scopes[i]); + fprintf(out, "  %s:
    \n", scopes[i]); } - fputs("    ", out); + fputs("    ", out); write_element(out, doc, mxmlFindElement(arg, arg, "type", NULL, NULL, MXML_DESCEND_FIRST), OUTPUT_HTML); @@ -5743,12 +5766,12 @@ write_scu(FILE *out, /* I - Output file */ if (!inscope) { inscope = 1; - fprintf(out, "  %s:%s\n", scopes[i], br); + fprintf(out, "  %s:%s\n", scopes[i], br); } name = mxmlElementGetAttr(function, "name"); - fputs("    ", out); + fputs("    ", out); arg = mxmlFindElement(function, function, "returnvalue", NULL, NULL, MXML_DESCEND_FIRST); @@ -5869,13 +5892,13 @@ write_string(FILE *out, /* I - Output file */ s += 2; } - if (ch == 0xa0) + if (ch == 0xa0 && mode != OUTPUT_EPUB) { /* * Handle non-breaking space as-is... */ - fputs(" ", out); + fputs(" ", out); } else fprintf(out, "&#x%x;", ch);