[vlc-commits] Xml: added empty element detection

Christopher Mueller git at videolan.org
Tue Aug 30 21:44:31 CEST 2011


vlc | branch: master | Christopher Mueller <christopher.mueller at itec.aau.at> | Tue Aug 30 11:35:12 2011 -0700| [5e107d194baceea426f89aa5b130d2aefa536216] | committer: Rémi Denis-Courmont

Xml: added empty element detection

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5e107d194baceea426f89aa5b130d2aefa536216
---

 include/vlc_xml.h         |    9 +++++++++
 modules/misc/xml/libxml.c |    7 +++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/include/vlc_xml.h b/include/vlc_xml.h
index df11ba5..e8b846d 100644
--- a/include/vlc_xml.h
+++ b/include/vlc_xml.h
@@ -74,6 +74,7 @@ struct xml_reader_t
     const char *(*pf_next_attr) ( xml_reader_t *, const char ** );
 
     int (*pf_use_dtd) ( xml_reader_t * );
+    int (*pf_is_empty) ( xml_reader_t * );
 };
 
 VLC_API xml_reader_t * xml_ReaderCreate(vlc_object_t *, stream_t *) VLC_USED;
@@ -97,6 +98,14 @@ static inline int xml_ReaderUseDTD( xml_reader_t *reader )
   return reader->pf_use_dtd( reader );
 }
 
+static inline int xml_ReaderIsEmptyElement( xml_reader_t *reader )
+{
+    if(reader->pf_is_empty == NULL)
+        return -2;
+
+    return reader->pf_is_empty( reader );
+}
+
 enum {
     XML_READER_NONE=0,
     XML_READER_STARTELEM,
diff --git a/modules/misc/xml/libxml.c b/modules/misc/xml/libxml.c
index da9d065..50e592e 100644
--- a/modules/misc/xml/libxml.c
+++ b/modules/misc/xml/libxml.c
@@ -62,6 +62,7 @@ vlc_module_end ()
 
 static int ReaderNextNode( xml_reader_t *, const char ** );
 static const char *ReaderNextAttr( xml_reader_t *, const char ** );
+static int ReaderIsEmptyElement( xml_reader_t *);
 
 static int ReaderUseDTD ( xml_reader_t * );
 
@@ -175,6 +176,7 @@ static int ReaderOpen( vlc_object_t *p_this )
     p_reader->p_sys = p_sys;
     p_reader->pf_next_node = ReaderNextNode;
     p_reader->pf_next_attr = ReaderNextAttr;
+    p_reader->pf_is_empty = ReaderIsEmptyElement;
     p_reader->pf_use_dtd = ReaderUseDTD;
 
     return VLC_SUCCESS;
@@ -287,3 +289,8 @@ static int StreamRead( void *p_context, char *p_buffer, int i_buffer )
     stream_t *s = (stream_t*)p_context;
     return stream_Read( s, p_buffer, i_buffer );
 }
+
+static int ReaderIsEmptyElement( xml_reader_t *p_reader )
+{
+    return xmlTextReaderIsEmptyElement( p_reader->p_sys->xml );
+}



More information about the vlc-commits mailing list