mirror of
https://github.com/michaelrsweet/mxml.git
synced 2024-11-24 11:25:30 +00:00
Add mxmlElementAttrGetByIndex and mxmlElementAttrGetCount (Issue #185)
This commit is contained in:
parent
b79d3e0f07
commit
48c3c62521
@ -2,8 +2,10 @@
|
||||
|
||||
- CDATA nodes now omit the trailing "]]" for convenience (Issue #170)
|
||||
- Fixed a memory leak in mxmlDelete (Issue #183)
|
||||
- mxmlElementSetAttrf did not work with some versions of Visual Studio
|
||||
- `mxmlElementSetAttrf` did not work with some versions of Visual Studio
|
||||
(Issue #184)
|
||||
- Added `mxmlElementGetAttrByIndex` and `mxmlELementGetAttrCount` functions
|
||||
(Issue #185)
|
||||
- The configure script now properly supports cross-compilation (Issue #188)
|
||||
- The mxmldoc utility now supports generation of EPUB files (Issue #189)
|
||||
- The mxmldoc utility now supports the `SOURCE_DATE_EPOCH` environment
|
||||
|
33
Makefile.in
33
Makefile.in
@ -102,7 +102,12 @@ all: $(TARGETS)
|
||||
clean:
|
||||
echo Cleaning build files...
|
||||
$(RM) $(OBJS) $(ALLTARGETS)
|
||||
$(RM) mxmldoc-static libmxml.a libmxml.so.1.5 libmxml.sl.1 libmxml.1.dylib
|
||||
$(RM) mxmldoc-static
|
||||
$(RM) mxml1.dll
|
||||
$(RM) libmxml.a
|
||||
$(RM) libmxml.so.1.6
|
||||
$(RM) libmxml.sl.1
|
||||
$(RM) libmxml.1.dylib
|
||||
|
||||
|
||||
#
|
||||
@ -163,14 +168,14 @@ install-libmxml.a:
|
||||
$(INSTALL_LIB) libmxml.a $(BUILDROOT)$(libdir)
|
||||
$(RANLIB) $(BUILDROOT)$(libdir)/libmxml.a
|
||||
|
||||
install-libmxml.so.1.5:
|
||||
install-libmxml.so.1.6:
|
||||
echo Installing libmxml.so to $(BUILDROOT)$(libdir)...
|
||||
$(INSTALL_DIR) $(BUILDROOT)$(libdir)
|
||||
$(INSTALL_LIB) libmxml.so.1.5 $(BUILDROOT)$(libdir)
|
||||
$(INSTALL_LIB) libmxml.so.1.6 $(BUILDROOT)$(libdir)
|
||||
$(RM) $(BUILDROOT)$(libdir)/libmxml.so
|
||||
$(LN) libmxml.so.1.5 $(BUILDROOT)$(libdir)/libmxml.so
|
||||
$(LN) libmxml.so.1.6 $(BUILDROOT)$(libdir)/libmxml.so
|
||||
$(RM) $(BUILDROOT)$(libdir)/libmxml.so.1
|
||||
$(LN) libmxml.so.1.5 $(BUILDROOT)$(libdir)/libmxml.so.1
|
||||
$(LN) libmxml.so.1.6 $(BUILDROOT)$(libdir)/libmxml.so.1
|
||||
|
||||
install-libmxml.sl.1:
|
||||
echo Installing libmxml.sl to $(BUILDROOT)$(libdir)...
|
||||
@ -208,7 +213,7 @@ uninstall-libmxml.a:
|
||||
echo Uninstalling libmxml.a from $(BUILDROOT)$(libdir)...
|
||||
$(RM) $(BUILDROOT)$(libdir)/libmxml.a
|
||||
|
||||
uninstall-libmxml.so.1.5:
|
||||
uninstall-libmxml.so.1.6:
|
||||
echo Uninstalling libmxml.so from $(BUILDROOT)$(libdir)...
|
||||
$(RM) $(BUILDROOT)$(libdir)/libmxml.so
|
||||
$(RM) $(BUILDROOT)$(libdir)/libmxml.so.1
|
||||
@ -252,24 +257,24 @@ mxml-entity.o mxml-file.o mxml-private.o: mxml-private.h
|
||||
|
||||
|
||||
#
|
||||
# libmxml1.dll
|
||||
# mxml1.dll
|
||||
#
|
||||
|
||||
libmxml1.dll: $(LIBOBJS)
|
||||
mxml1.dll: $(LIBOBJS)
|
||||
echo Creating $@...
|
||||
$(DSO) $(DSOFLAGS) -o $@ $(LIBOBJS)
|
||||
|
||||
|
||||
#
|
||||
# libmxml.so.1.5
|
||||
# libmxml.so.1.6
|
||||
#
|
||||
|
||||
libmxml.so.1.5: $(LIBOBJS)
|
||||
libmxml.so.1.6: $(LIBOBJS)
|
||||
echo Creating $@...
|
||||
$(DSO) $(DSOFLAGS) -o libmxml.so.1.5 $(LIBOBJS)
|
||||
$(DSO) $(DSOFLAGS) -o libmxml.so.1.6 $(LIBOBJS)
|
||||
$(RM) libmxml.so libmxml.so.1
|
||||
$(LN) libmxml.so.1.5 libmxml.so
|
||||
$(LN) libmxml.so.1.5 libmxml.so.1
|
||||
$(LN) libmxml.so.1.6 libmxml.so
|
||||
$(LN) libmxml.so.1.6 libmxml.so.1
|
||||
|
||||
|
||||
#
|
||||
@ -291,7 +296,7 @@ libmxml.1.dylib: $(LIBOBJS)
|
||||
echo Creating $@...
|
||||
$(DSO) $(DSOFLAGS) -o libmxml.1.dylib \
|
||||
-install_name $(libdir)/libmxml.dylib \
|
||||
-current_version 1.5.0 \
|
||||
-current_version 1.6.0 \
|
||||
-compatibility_version 1.0.0 \
|
||||
$(LIBOBJS)
|
||||
$(RM) libmxml.dylib
|
||||
|
10
configure
vendored
10
configure
vendored
@ -4511,7 +4511,7 @@ $as_echo_n "checking for shared library support... " >&6; }
|
||||
sunos | unix_s)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
LIBMXML="libmxml.so.1.5"
|
||||
LIBMXML="libmxml.so.1.6"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -Wl,-h,libmxml.so.1 -G -R\$(libdir) \$(OPTIM)"
|
||||
LDFLAGS="$LDFLAGS -R\$(libdir)"
|
||||
@ -4529,7 +4529,7 @@ $as_echo "yes" >&6; }
|
||||
irix)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
LIBMXML="libmxml.so.1.5"
|
||||
LIBMXML="libmxml.so.1.6"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -Wl,-rpath,\$(libdir),-set_version,sgi1.0,-soname,libmxml.so.1 -shared \$(OPTIM)"
|
||||
;;
|
||||
@ -4537,7 +4537,7 @@ $as_echo "yes" >&6; }
|
||||
osf | linux* | gnu)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
LIBMXML="libmxml.so.1.5"
|
||||
LIBMXML="libmxml.so.1.6"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-rpath,\$(libdir) -shared \$(OPTIM)"
|
||||
LDFLAGS="$LDFLAGS -Wl,-rpath,\$(libdir)"
|
||||
@ -4546,7 +4546,7 @@ $as_echo "yes" >&6; }
|
||||
*bsd)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
LIBMXML="libmxml.so.1.5"
|
||||
LIBMXML="libmxml.so.1.6"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-R\$(libdir) -shared \$(OPTIM)"
|
||||
LDFLAGS="$LDFLAGS -Wl,-R\$(libdir)"
|
||||
@ -4563,7 +4563,7 @@ $as_echo "yes" >&6; }
|
||||
mingw)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
LIBMXML="libmxml1.dll"
|
||||
LIBMXML="mxml1.dll"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -shared -Wl,--out-implib,libmxml1.a,--no-undefined,--enable-runtime-pseudo-reloc"
|
||||
;;
|
||||
|
10
configure.ac
10
configure.ac
@ -182,7 +182,7 @@ if test x$enable_shared != xno; then
|
||||
case "$host_os_name" in
|
||||
sunos | unix_s)
|
||||
AC_MSG_RESULT(yes)
|
||||
LIBMXML="libmxml.so.1.5"
|
||||
LIBMXML="libmxml.so.1.6"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -Wl,-h,libmxml.so.1 -G -R\$(libdir) \$(OPTIM)"
|
||||
LDFLAGS="$LDFLAGS -R\$(libdir)"
|
||||
@ -198,14 +198,14 @@ if test x$enable_shared != xno; then
|
||||
|
||||
irix)
|
||||
AC_MSG_RESULT(yes)
|
||||
LIBMXML="libmxml.so.1.5"
|
||||
LIBMXML="libmxml.so.1.6"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -Wl,-rpath,\$(libdir),-set_version,sgi1.0,-soname,libmxml.so.1 -shared \$(OPTIM)"
|
||||
;;
|
||||
|
||||
osf | linux* | gnu)
|
||||
AC_MSG_RESULT(yes)
|
||||
LIBMXML="libmxml.so.1.5"
|
||||
LIBMXML="libmxml.so.1.6"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-rpath,\$(libdir) -shared \$(OPTIM)"
|
||||
LDFLAGS="$LDFLAGS -Wl,-rpath,\$(libdir)"
|
||||
@ -213,7 +213,7 @@ if test x$enable_shared != xno; then
|
||||
|
||||
*bsd)
|
||||
AC_MSG_RESULT(yes)
|
||||
LIBMXML="libmxml.so.1.5"
|
||||
LIBMXML="libmxml.so.1.6"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-R\$(libdir) -shared \$(OPTIM)"
|
||||
LDFLAGS="$LDFLAGS -Wl,-R\$(libdir)"
|
||||
@ -228,7 +228,7 @@ if test x$enable_shared != xno; then
|
||||
|
||||
mingw)
|
||||
AC_MSG_RESULT(yes)
|
||||
LIBMXML="libmxml1.dll"
|
||||
LIBMXML="mxml1.dll"
|
||||
DSO="\$(CC)"
|
||||
DSOFLAGS="$DSOFLAGS -shared -Wl,--out-implib,libmxml1.a,--no-undefined,--enable-runtime-pseudo-reloc"
|
||||
;;
|
||||
|
25
doc/mxml.man
25
doc/mxml.man
@ -284,6 +284,31 @@ const char * mxmlElementGetAttr (
|
||||
.PP
|
||||
This function returns NULL if the node is not an element or the
|
||||
named attribute does not exist.
|
||||
.SS mxmlElementGetAttrByIndex
|
||||
Get an element attribute by index.
|
||||
.PP
|
||||
.nf
|
||||
const char * mxmlElementGetAttrByIndex (
|
||||
mxml_node_t *node,
|
||||
int idx,
|
||||
const char **name
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
The index ("idx") is 0-based. \fBNULL\fR is returned if the specified index
|
||||
is out of range.
|
||||
|
||||
|
||||
.SS mxmlElementGetAttrCount
|
||||
Get the number of element attributes.
|
||||
.PP
|
||||
.nf
|
||||
int mxmlElementGetAttrCount (
|
||||
mxml_node_t *node
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
|
||||
.SS mxmlElementSetAttr
|
||||
Set an attribute.
|
||||
.PP
|
||||
|
@ -157,6 +157,8 @@ h3.title {
|
||||
<li><a href="#mxmlDelete">mxmlDelete</a></li>
|
||||
<li><a href="#mxmlElementDeleteAttr">mxmlElementDeleteAttr</a></li>
|
||||
<li><a href="#mxmlElementGetAttr">mxmlElementGetAttr</a></li>
|
||||
<li><a href="#mxmlElementGetAttrByIndex">mxmlElementGetAttrByIndex</a></li>
|
||||
<li><a href="#mxmlElementGetAttrCount">mxmlElementGetAttrCount</a></li>
|
||||
<li><a href="#mxmlElementSetAttr">mxmlElementSetAttr</a></li>
|
||||
<li><a href="#mxmlElementSetAttrf">mxmlElementSetAttrf</a></li>
|
||||
<li><a href="#mxmlEntityAddCallback">mxmlEntityAddCallback</a></li>
|
||||
@ -319,6 +321,43 @@ const char *mxmlElementGetAttr (<br>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function returns NULL if the node is not an element or the
|
||||
named attribute does not exist.</p>
|
||||
<h3 class="function"><span class="info"> Mini-XML 2.11 </span><a id="mxmlElementGetAttrByIndex">mxmlElementGetAttrByIndex</a></h3>
|
||||
<p class="description">Get an element attribute by index.</p>
|
||||
<p class="code">
|
||||
const char *mxmlElementGetAttrByIndex (<br>
|
||||
    <a href="#mxml_node_t">mxml_node_t</a> *node,<br>
|
||||
    int idx,<br>
|
||||
    const char **name<br>
|
||||
);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<dl>
|
||||
<dt>node</dt>
|
||||
<dd class="description">Node</dd>
|
||||
<dt>idx</dt>
|
||||
<dd class="description">Attribute index, starting at 0</dd>
|
||||
<dt>name</dt>
|
||||
<dd class="description">Attribute name</dd>
|
||||
</dl>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Attribute value</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">The index ("idx") is 0-based. <code>NULL</code> is returned if the specified index
|
||||
is out of range.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><span class="info"> Mini-XML 2.11 </span><a id="mxmlElementGetAttrCount">mxmlElementGetAttrCount</a></h3>
|
||||
<p class="description">Get the number of element attributes.</p>
|
||||
<p class="code">
|
||||
int mxmlElementGetAttrCount (<br>
|
||||
    <a href="#mxml_node_t">mxml_node_t</a> *node<br>
|
||||
);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<dl>
|
||||
<dt>node</dt>
|
||||
<dd class="description">Node</dd>
|
||||
</dl>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Number of attributes</p>
|
||||
<h3 class="function"><a id="mxmlElementSetAttr">mxmlElementSetAttr</a></h3>
|
||||
<p class="description">Set an attribute.</p>
|
||||
<p class="code">
|
||||
|
42
mxml-attr.c
42
mxml-attr.c
@ -149,6 +149,48 @@ mxmlElementGetAttr(mxml_node_t *node, /* I - Element node */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'mxmlElementGetAttrByIndex()' - Get an element attribute by index.
|
||||
*
|
||||
* The index ("idx") is 0-based. @code NULL@ is returned if the specified index
|
||||
* is out of range.
|
||||
*
|
||||
* @since Mini-XML 2.11@
|
||||
*/
|
||||
|
||||
const char * /* O - Attribute value */
|
||||
mxmlElementGetAttrByIndex(
|
||||
mxml_node_t *node, /* I - Node */
|
||||
int idx, /* I - Attribute index, starting at 0 */
|
||||
const char **name) /* O - Attribute name */
|
||||
{
|
||||
if (!node || node->type != MXML_ELEMENT || idx < 0 || idx >= node->value.element.num_attrs)
|
||||
return (NULL);
|
||||
|
||||
if (name)
|
||||
*name = node->value.element.attrs[idx].name;
|
||||
|
||||
return (node->value.element.attrs[idx].value);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'mxmlElementGetAttrCount()' - Get the number of element attributes.
|
||||
*
|
||||
* @since Mini-XML 2.11@
|
||||
*/
|
||||
|
||||
int /* O - Number of attributes */
|
||||
mxmlElementGetAttrCount(
|
||||
mxml_node_t *node) /* I - Node */
|
||||
{
|
||||
if (node && node->type == MXML_ELEMENT)
|
||||
return (node->value.element.num_attrs);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'mxmlElementSetAttr()' - Set an attribute.
|
||||
*
|
||||
|
2
mxml.h
2
mxml.h
@ -196,6 +196,8 @@ extern void mxmlDelete(mxml_node_t *node);
|
||||
extern void mxmlElementDeleteAttr(mxml_node_t *node,
|
||||
const char *name);
|
||||
extern const char *mxmlElementGetAttr(mxml_node_t *node, const char *name);
|
||||
extern const char *mxmlElementGetAttrByIndex(mxml_node_t *node, int idx, const char **name);
|
||||
extern int mxmlElementGetAttrCount(mxml_node_t *node);
|
||||
extern void mxmlElementSetAttr(mxml_node_t *node, const char *name,
|
||||
const char *value);
|
||||
extern void mxmlElementSetAttrf(mxml_node_t *node, const char *name,
|
||||
|
@ -10,6 +10,8 @@ EXPORTS
|
||||
mxmlAdd
|
||||
mxmlDelete
|
||||
mxmlElementDeleteAttr
|
||||
mxmlElementGetAttrByIndex
|
||||
mxmlElementGetAttrCount
|
||||
mxmlElementGetAttr
|
||||
mxmlElementSetAttr
|
||||
mxmlElementSetAttrf
|
||||
|
Loading…
Reference in New Issue
Block a user