Commit cc95be7b authored by Michael R Sweet's avatar Michael R Sweet

Add mxmlNewCDATA() and mxmlSetCDATA() functions.

Bump version to 2.2.3.

Update docos.
parent 35b7bc18
CHANGES - 06/07/2005
CHANGES - 08/05/2005
--------------------
CHANGES IN Mini-XML 2.2.4
- Added new mxmlNewCDATA() and mxmlSetCDATA() functions
to create and set CDATA nodes, which are really just
special element nodes.
CHANGES IN Mini-XML 2.2.3
- Added new MXML_IGNORE type and MXML_IGNORE_CB callback
......
......@@ -57,7 +57,8 @@ extern char *mxml_strdup(const char *);
# define strdup mxml_strdup
# endif /* !HAVE_STRDUP */
extern char *mxml_strdupf(const char *, va_list);
extern char *mxml_strdupf(const char *, ...);
extern char *mxml_vstrdupf(const char *, va_list);
# ifndef HAVE_VSNPRINTF
extern int mxml_vsnprintf(char *, size_t, const char *, va_list);
......
This diff is collapsed.
......@@ -23,7 +23,7 @@ dnl Set the name of the config header file...
AC_CONFIG_HEADER(config.h)
dnl Version number...
VERSION=2.2.3
VERSION=2.2.4
AC_SUBST(VERSION)
AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION")
......
<html>
<head>
<title>Mini-XML Programmers Manual, Version 2.2.1</title>
<title>Mini-XML Programmers Manual, Version 2.2.3</title>
<meta name='copyright' content='Copyright 2003-2005'/>
<meta name='author' content='Michael Sweet'/>
<meta name='keywords' content='XML, C, C++, library'/>
......@@ -9,7 +9,7 @@
<h1 align='right'><a name='INTRO'>Introduction</a></h1>
<p>This programmers manual describes Mini-XML version 2.2.1, a
<p>This programmers manual describes Mini-XML version 2.2.3, a
small XML parsing library that you can use to read and write XML
and XML-like data files in your application without requiring
large non-standard libraries. Mini-XML only requires an ANSI C
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<title>Documentation</title>
<meta name='creator' content='Mini-XML v2.2.3'/>
<meta name='creator' content='Mini-XML v2.2.4'/>
<style><!--
h1, h2, h3, p { font-family: sans-serif; text-align: justify; }
tt, pre a:link, pre a:visited, tt a:link, tt a:visited { font-weight: bold; color: #7f0000; }
......@@ -60,6 +60,7 @@
<li><a href='#mxmlLoadFd'><tt>mxmlLoadFd()</tt></a></li>
<li><a href='#mxmlLoadFile'><tt>mxmlLoadFile()</tt></a></li>
<li><a href='#mxmlLoadString'><tt>mxmlLoadString()</tt></a></li>
<li><a href='#mxmlNewCDATA'><tt>mxmlNewCDATA()</tt></a></li>
<li><a href='#mxmlNewCustom'><tt>mxmlNewCustom()</tt></a></li>
<li><a href='#mxmlNewElement'><tt>mxmlNewElement()</tt></a></li>
<li><a href='#mxmlNewInteger'><tt>mxmlNewInteger()</tt></a></li>
......@@ -72,6 +73,7 @@
<li><a href='#mxmlSaveFd'><tt>mxmlSaveFd()</tt></a></li>
<li><a href='#mxmlSaveFile'><tt>mxmlSaveFile()</tt></a></li>
<li><a href='#mxmlSaveString'><tt>mxmlSaveString()</tt></a></li>
<li><a href='#mxmlSetCDATA'><tt>mxmlSetCDATA()</tt></a></li>
<li><a href='#mxmlSetCustom'><tt>mxmlSetCustom()</tt></a></li>
<li><a href='#mxmlSetCustomHandlers'><tt>mxmlSetCustomHandlers()</tt></a></li>
<li><a href='#mxmlSetElement'><tt>mxmlSetElement()</tt></a></li>
......@@ -532,6 +534,32 @@ mxmlLoadString(
<h4>Returns</h4>
<p>First node or NULL if the string has errors.</p>
<!-- NEW PAGE -->
<h3><a name='mxmlNewCDATA'>mxmlNewCDATA()</a></h3>
<hr noshade/>
<h4>Description</h4>
<p>Create a new CDATA node.
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.</p>
<h4>Syntax</h4>
<pre>
<a href='#mxml_node_t'>mxml_node_t</a> *
mxmlNewCDATA(
<a href='#mxml_node_t'>mxml_node_t</a> * parent,
const char * data);
</pre>
<h4>Arguments</h4>
<p class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0' width='80%'>
<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>
<tbody>
<tr><td><tt>parent</tt></td><td>Parent node or MXML_NO_PARENT</td></tr>
<tr><td><tt>data</tt></td><td>Data string</td></tr>
</tbody></table></p>
<h4>Returns</h4>
<p>New node</p>
<!-- NEW PAGE -->
<h3><a name='mxmlNewCustom'>mxmlNewCustom()</a></h3>
<hr noshade/>
<h4>Description</h4>
......@@ -869,6 +897,29 @@ mxmlSaveString(
<h4>Returns</h4>
<p>Size of string</p>
<!-- NEW PAGE -->
<h3><a name='mxmlSetCDATA'>mxmlSetCDATA()</a></h3>
<hr noshade/>
<h4>Description</h4>
<p>Set the element name of a CDATA node.
The node is not changed if it is not a CDATA element node.</p>
<h4>Syntax</h4>
<pre>
int
mxmlSetCDATA(
<a href='#mxml_node_t'>mxml_node_t</a> * node,
const char * data);
</pre>
<h4>Arguments</h4>
<p class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0' width='80%'>
<thead><tr bgcolor='#cccccc'><th>Name</th><th>Description</th></tr></thead>
<tbody>
<tr><td><tt>node</tt></td><td>Node to set</td></tr>
<tr><td><tt>data</tt></td><td>New data string</td></tr>
</tbody></table></p>
<h4>Returns</h4>
<p>0 on success, -1 on failure</p>
<!-- NEW PAGE -->
<h3><a name='mxmlSetCustom'>mxmlSetCustom()</a></h3>
<hr noshade/>
<h4>Description</h4>
......
......@@ -3,10 +3,25 @@
<h1 align='right'><a name='RELNOTES'>B - Release Notes</a></h1>
<h2>Changes in Mini-XML 2.2.3</h2>
<ul>
<li>Added new mxmlNewCDATA() and mxmlSetCDATA() functions
to create and set CDATA nodes, which are really just
special element nodes.</li>
</ul>
<h2>Changes in Mini-XML 2.2.2</h2>
<ul>
<li>Added new MXML_IGNORE type and MXML_IGNORE_CB
callback to ignore non-element nodes (i.e.
whitespace)</li>
<li>mxmlLoad*() did not treat custom data as opaque, so
whitespace characters would be lost.</li>
......
......@@ -273,6 +273,45 @@ mxmlDelete(mxml_node_t *node) /* I - Node to delete */
}
/*
* 'mxmlNewCDATA()' - Create a new CDATA node.
*
* 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.
*/
mxml_node_t * /* O - New node */
mxmlNewCDATA(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
const char *data) /* I - Data string */
{
mxml_node_t *node; /* New node */
#ifdef DEBUG
fprintf(stderr, "mxmlNewCDATA(parent=%p, data=\"%s\")\n",
parent, data ? data : "(null)");
#endif /* DEBUG */
/*
* Range check input...
*/
if (!data)
return (NULL);
/*
* Create the node and set the name value...
*/
if ((node = mxml_new(parent, MXML_ELEMENT)) != NULL)
node->value.element.name = mxml_strdupf("![CDATA[%s]]", data);
return (node);
}
/*
* 'mxmlNewCustom()' - Create a new custom data node.
*
......@@ -532,7 +571,7 @@ mxmlNewTextf(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */
va_start(ap, format);
node->value.text.whitespace = whitespace;
node->value.text.string = mxml_strdupf(format, ap);
node->value.text.string = mxml_vstrdupf(format, ap);
va_end(ap);
}
......
......@@ -17,6 +17,8 @@
*
* Contents:
*
* mxmlSetCustom() - Set the data and destructor of a custom data node.
* mxmlSetCDATA() - Set the element name of a CDATA node.
* mxmlSetElement() - Set the name of an element node.
* mxmlSetInteger() - Set the value of an integer node.
* mxmlSetOpaque() - Set the value of an opaque node.
......@@ -66,6 +68,37 @@ mxmlSetCustom(mxml_node_t *node, /* I - Node to set */
}
/*
* 'mxmlSetCDATA()' - Set the element name of a CDATA node.
*
* The node is not changed if it is not a CDATA element node.
*/
int /* O - 0 on success, -1 on failure */
mxmlSetCDATA(mxml_node_t *node, /* I - Node to set */
const char *data) /* I - New data string */
{
/*
* Range check input...
*/
if (!node || node->type != MXML_ELEMENT || !data ||
strncmp(node->value.element.name, "![CDATA[", 8))
return (-1);
/*
* Free any old element value and set the new value...
*/
if (node->value.element.name)
free(node->value.element.name);
node->value.element.name = mxml_strdupf("![CDATA[%s]]", data);
return (0);
}
/*
* 'mxmlSetElement()' - Set the name of an element node.
*
......
......@@ -19,6 +19,7 @@
*
* mxml_strdup() - Duplicate a string.
* mxml_strdupf() - Format and duplicate a string.
* mxml_vstrdupf() - Format and duplicate a string.
* mxml_vsnprintf() - Format a string into a fixed size buffer.
*/
......@@ -57,7 +58,32 @@ mxml_strdup(const char *s) /* I - String to duplicate */
char * /* O - New string pointer */
mxml_strdupf(const char *format, /* I - Printf-style format string */
va_list ap) /* I - Pointer to additional arguments */
...) /* I - Additional arguments as needed */
{
va_list ap; /* Pointer to additional arguments */
char *s; /* Pointer to formatted string */
/*
* Get a pointer to the additional arguments, format the string,
* and return it...
*/
va_start(ap, format);
s = mxml_vstrdupf(format, ap);
va_end(ap);
return (s);
}
/*
* 'mxml_vstrdupf()' - Format and duplicate a string.
*/
char * /* O - New string pointer */
mxml_vstrdupf(const char *format, /* I - Printf-style format string */
va_list ap) /* I - Pointer to additional arguments */
{
int bytes; /* Number of bytes required */
char *buffer, /* String buffer */
......
......@@ -185,6 +185,7 @@ extern mxml_node_t *mxmlLoadFile(mxml_node_t *top, FILE *fp,
mxml_type_t (*cb)(mxml_node_t *));
extern mxml_node_t *mxmlLoadString(mxml_node_t *top, const char *s,
mxml_type_t (*cb)(mxml_node_t *));
extern mxml_node_t *mxmlNewCDATA(mxml_node_t *parent, const char *string);
extern mxml_node_t *mxmlNewCustom(mxml_node_t *parent, void *data,
void (*destroy)(void *));
extern mxml_node_t *mxmlNewElement(mxml_node_t *parent, const char *name);
......@@ -209,6 +210,7 @@ extern int mxmlSaveFile(mxml_node_t *node, FILE *fp,
extern int mxmlSaveString(mxml_node_t *node, char *buffer,
int bufsize,
const char *(*cb)(mxml_node_t *, int));
extern int mxmlSetCDATA(mxml_node_t *node, const char *data);
extern int mxmlSetCustom(mxml_node_t *node, void *data,
void (*destroy)(void *));
extern void mxmlSetCustomHandlers(mxml_custom_load_cb_t load,
......
......@@ -332,6 +332,26 @@ child nodes of the specified type.</description>
<description>Callback function or MXML_NO_CALLBACK</description>
</argument>
</function>
<function name="mxmlNewCDATA">
<returnvalue>
<type>mxml_node_t *</type>
<description>New node</description>
</returnvalue>
<description>Create a new CDATA node.
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.</description>
<argument name="parent" direction="I">
<type>mxml_node_t *</type>
<description>Parent node or MXML_NO_PARENT</description>
</argument>
<argument name="data" direction="I">
<type>const char *</type>
<description>Data string</description>
</argument>
</function>
<function name="mxmlNewCustom">
<returnvalue>
<type>mxml_node_t *</type>
......@@ -606,6 +626,23 @@ element tags.</description>
<description>Whitespace callback or MXML_NO_CALLBACK</description>
</argument>
</function>
<function name="mxmlSetCDATA">
<returnvalue>
<type>int</type>
<description>0 on success, -1 on failure</description>
</returnvalue>
<description>Set the element name of a CDATA node.
The node is not changed if it is not a CDATA element node.</description>
<argument name="node" direction="I">
<type>mxml_node_t *</type>
<description>Node to set</description>
</argument>
<argument name="data" direction="I">
<type>const char *</type>
<description>New data string</description>
</argument>
</function>
<function name="mxmlSetCustom">
<returnvalue>
<type>int</type>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment