Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
59f0684a
Commit
59f0684a
authored
Jan 19, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XML: merge read and node_type operations, skip unknown nodes
parent
19ae84b4
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
117 additions
and
253 deletions
+117
-253
include/vlc_xml.h
include/vlc_xml.h
+3
-9
modules/codec/subsusf.c
modules/codec/subsusf.c
+5
-7
modules/demux/playlist/b4s.c
modules/demux/playlist/b4s.c
+12
-19
modules/demux/playlist/itml.c
modules/demux/playlist/itml.c
+9
-15
modules/demux/playlist/podcast.c
modules/demux/playlist/podcast.c
+6
-24
modules/demux/playlist/qtl.c
modules/demux/playlist/qtl.c
+4
-13
modules/demux/playlist/shoutcast.c
modules/demux/playlist/shoutcast.c
+9
-25
modules/demux/playlist/xspf.c
modules/demux/playlist/xspf.c
+25
-70
modules/gui/skins2/parser/xmlparser.cpp
modules/gui/skins2/parser/xmlparser.cpp
+4
-11
modules/misc/freetype.c
modules/misc/freetype.c
+1
-1
modules/misc/lua/libs/xml.c
modules/misc/lua/libs/xml.c
+4
-14
modules/misc/text_renderer.h
modules/misc/text_renderer.h
+4
-4
modules/misc/xml/libxml.c
modules/misc/xml/libxml.c
+20
-28
modules/video_filter/rss.c
modules/video_filter/rss.c
+3
-6
share/lua/README.txt
share/lua/README.txt
+2
-2
share/lua/modules/simplexml.lua
share/lua/modules/simplexml.lua
+6
-5
No files found.
include/vlc_xml.h
View file @
59f0684a
...
...
@@ -70,8 +70,7 @@ struct xml_reader_t
stream_t
*
p_stream
;
module_t
*
p_module
;
int
(
*
pf_read
)
(
xml_reader_t
*
);
int
(
*
pf_node_type
)
(
xml_reader_t
*
);
int
(
*
pf_next_node
)
(
xml_reader_t
*
);
char
*
(
*
pf_name
)
(
xml_reader_t
*
);
char
*
(
*
pf_value
)
(
xml_reader_t
*
);
int
(
*
pf_next_attr
)
(
xml_reader_t
*
);
...
...
@@ -84,14 +83,9 @@ VLC_EXPORT( xml_reader_t *, xml_ReaderCreate, (vlc_object_t *, stream_t *) LIBVL
VLC_EXPORT
(
void
,
xml_ReaderDelete
,
(
xml_reader_t
*
)
);
VLC_EXPORT
(
xml_reader_t
*
,
xml_ReaderReset
,
(
xml_reader_t
*
,
stream_t
*
)
LIBVLC_USED
);
static
inline
int
xml_Reader
Read
(
xml_reader_t
*
reader
)
static
inline
int
xml_Reader
NextNode
(
xml_reader_t
*
reader
)
{
return
reader
->
pf_read
(
reader
);
}
static
inline
int
xml_ReaderNodeType
(
xml_reader_t
*
reader
)
{
return
reader
->
pf_node_type
(
reader
);
return
reader
->
pf_next_node
(
reader
);
}
static
inline
char
*
xml_ReaderName
(
xml_reader_t
*
reader
)
...
...
modules/codec/subsusf.c
View file @
59f0684a
...
...
@@ -532,14 +532,12 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
ssa_style_t
*
p_ssa_style
=
NULL
;
int
i_style_level
=
0
;
int
i_metadata_level
=
0
;
int
type
;
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
while
(
(
type
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
switch
(
xml_ReaderNodeType
(
p_xml_reader
)
)
switch
(
type
)
{
case
XML_READER_TEXT
:
case
XML_READER_NONE
:
break
;
case
XML_READER_ENDELEM
:
psz_node
=
xml_ReaderName
(
p_xml_reader
);
...
...
@@ -996,10 +994,10 @@ static void ParseUSFHeader( decoder_t *p_dec )
return
;
p_xml_reader
=
xml_ReaderCreate
(
p_dec
,
p_sub
);
if
(
p_xml_reader
)
if
(
likely
(
p_xml_reader
)
)
{
/* Look for Root Node */
if
(
xml_Reader
Read
(
p_xml_reader
)
==
1
)
if
(
xml_Reader
NextNode
(
p_xml_reader
)
==
XML_READER_STARTELEM
)
{
char
*
psz_node
=
xml_ReaderName
(
p_xml_reader
);
...
...
modules/demux/playlist/b4s.c
View file @
59f0684a
...
...
@@ -88,18 +88,16 @@ static int Demux( demux_t *p_demux )
/* xml */
/* check root node */
if
(
xml_Reader
Read
(
p_xml_reader
)
!=
1
)
if
(
xml_Reader
NextNode
(
p_xml_reader
)
!=
XML_READER_STARTELEM
)
{
msg_Err
(
p_demux
,
"invalid file (no root node)"
);
goto
end
;
}
if
(
xml_ReaderNodeType
(
p_xml_reader
)
!=
XML_READER_STARTELEM
||
(
psz_elname
=
xml_ReaderName
(
p_xml_reader
)
)
==
NULL
||
if
(
(
psz_elname
=
xml_ReaderName
(
p_xml_reader
)
)
==
NULL
||
strcmp
(
psz_elname
,
"WinampXML"
)
)
{
msg_Err
(
p_demux
,
"invalid root node %i, %s"
,
xml_ReaderNodeType
(
p_xml_reader
),
psz_elname
);
msg_Err
(
p_demux
,
"invalid root node: %s"
,
psz_elname
);
goto
end
;
}
FREENULL
(
psz_elname
);
...
...
@@ -108,13 +106,12 @@ static int Demux( demux_t *p_demux )
* contain the "playlist node */
/* Skip until 1st child node */
while
(
(
i_ret
=
xml_ReaderRead
(
p_xml_reader
))
==
1
&&
xml_ReaderNodeType
(
p_xml_reader
)
!=
XML_READER_STARTELEM
);
if
(
i_ret
!=
1
)
{
msg_Err
(
p_demux
,
"invalid file (no child node)"
);
goto
end
;
}
while
(
(
i_ret
=
xml_ReaderNextNode
(
p_xml_reader
))
!=
XML_READER_STARTELEM
)
if
(
i_ret
<=
0
)
{
msg_Err
(
p_demux
,
"invalid file (no child node)"
);
goto
end
;
}
if
(
(
psz_elname
=
xml_ReaderName
(
p_xml_reader
)
)
==
NULL
||
strcmp
(
psz_elname
,
"playlist"
)
)
...
...
@@ -154,15 +151,11 @@ static int Demux( demux_t *p_demux )
p_subitems
=
input_item_node_Create
(
p_current_input
);
while
(
(
i_ret
=
xml_Reader
Read
(
p_xml_reader
))
==
1
)
while
(
(
i_ret
=
xml_Reader
NextNode
(
p_xml_reader
))
>
0
)
{
// Get the node type
switch
(
xml_ReaderNodeType
(
p_xml_reader
)
)
switch
(
i_ret
)
{
// Error
case
-
1
:
goto
end
;
case
XML_READER_STARTELEM
:
{
// Read the element name
...
...
@@ -274,7 +267,7 @@ static int Demux( demux_t *p_demux )
}
}
if
(
i_ret
!=
0
)
if
(
i_ret
<
0
)
{
msg_Warn
(
p_demux
,
"error while parsing data"
);
i_ret
=
0
;
/* Needed for correct operation of go back */
...
...
modules/demux/playlist/itml.c
View file @
59f0684a
...
...
@@ -79,14 +79,16 @@ int Demux( demux_t *p_demux )
goto
end
;
/* locating the root node */
int
type
;
do
{
if
(
xml_ReaderRead
(
p_xml_reader
)
!=
1
)
type
=
xml_ReaderNextNode
(
p_xml_reader
);
if
(
type
<=
0
)
{
msg_Err
(
p_demux
,
"can't read xml stream"
);
goto
end
;
}
}
while
(
xml_ReaderNodeType
(
p_xml_reader
)
!=
XML_READER_STARTELEM
);
}
while
(
type
!=
XML_READER_STARTELEM
);
/* checking root node name */
psz_name
=
xml_ReaderName
(
p_xml_reader
);
...
...
@@ -184,14 +186,10 @@ static bool parse_dict( demux_t *p_demux, input_item_node_t *p_input_node,
xml_elem_hnd_t
*
p_handler
=
NULL
;
bool
b_ret
=
false
;
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
while
(
(
i_node
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
i_node
=
xml_ReaderNodeType
(
p_xml_reader
);
switch
(
i_node
)
{
case
XML_READER_NONE
:
break
;
case
XML_READER_STARTELEM
:
/* element start tag */
psz_name
=
xml_ReaderName
(
p_xml_reader
);
...
...
@@ -272,15 +270,10 @@ static bool parse_dict( demux_t *p_demux, input_item_node_t *p_input_node,
FREE_ATT
();
p_handler
=
NULL
;
break
;
default:
/* unknown/unexpected xml node */
msg_Err
(
p_demux
,
"unexpected xml node %i"
,
i_node
);
goto
end
;
}
FREE_NAME
();
}
msg_Err
(
p_demux
,
"unexpected end of
xml
data"
);
msg_Err
(
p_demux
,
"unexpected end of
XML
data"
);
end:
free
(
psz_name
);
...
...
@@ -472,10 +465,11 @@ static bool skip_element( demux_t *p_demux, input_item_node_t *p_input_node,
VLC_UNUSED
(
p_demux
);
VLC_UNUSED
(
p_input_node
);
VLC_UNUSED
(
p_track
);
VLC_UNUSED
(
p_handlers
);
char
*
psz_endname
;
int
type
;
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
while
(
(
type
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
if
(
xml_ReaderNodeType
(
p_xml_reader
)
==
XML_READER_ENDELEM
)
if
(
type
==
XML_READER_ENDELEM
)
{
psz_endname
=
xml_ReaderName
(
p_xml_reader
);
if
(
!
psz_endname
)
...
...
modules/demux/playlist/podcast.c
View file @
59f0684a
...
...
@@ -71,7 +71,6 @@ static int Demux( demux_t *p_demux )
{
bool
b_item
=
false
;
bool
b_image
=
false
;
int
i_ret
;
xml_reader_t
*
p_xml_reader
;
char
*
psz_elname
=
NULL
;
...
...
@@ -99,43 +98,26 @@ static int Demux( demux_t *p_demux )
/* xml */
/* check root node */
if
(
xml_ReaderRead
(
p_xml_reader
)
!=
1
)
if
(
xml_ReaderNextNode
(
p_xml_reader
)
!=
XML_READER_STARTELEM
||
(
psz_elname
=
xml_ReaderName
(
p_xml_reader
)
)
==
NULL
)
{
msg_Err
(
p_demux
,
"invalid file (no root node)"
);
goto
error
;
}
while
(
xml_ReaderNodeType
(
p_xml_reader
)
==
XML_READER_NONE
)
if
(
strcmp
(
psz_elname
,
"rss"
)
)
{
if
(
xml_ReaderRead
(
p_xml_reader
)
!=
1
)
{
msg_Err
(
p_demux
,
"invalid file (no root node)"
);
goto
error
;
}
}
if
(
xml_ReaderNodeType
(
p_xml_reader
)
!=
XML_READER_STARTELEM
||
(
psz_elname
=
xml_ReaderName
(
p_xml_reader
)
)
==
NULL
||
strcmp
(
psz_elname
,
"rss"
)
)
{
msg_Err
(
p_demux
,
"invalid root node %i, %s"
,
xml_ReaderNodeType
(
p_xml_reader
),
psz_elname
);
msg_Err
(
p_demux
,
"invalid root node: %s"
,
psz_elname
);
goto
error
;
}
FREENULL
(
psz_elname
);
p_subitems
=
input_item_node_Create
(
p_current_input
);
while
(
(
i_
ret
=
xml_ReaderRead
(
p_xml_reader
))
==
1
)
while
(
(
i_
type
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
// Get the node type
i_type
=
xml_ReaderNodeType
(
p_xml_reader
);
switch
(
i_type
)
{
// Error
case
-
1
:
goto
error
;
case
XML_READER_STARTELEM
:
{
// Read the element name
...
...
@@ -351,7 +333,7 @@ static int Demux( demux_t *p_demux )
}
}
if
(
i_
ret
!=
0
)
if
(
i_
type
<
0
)
{
msg_Warn
(
p_demux
,
"error while parsing data"
);
}
...
...
modules/demux/playlist/qtl.c
View file @
59f0684a
...
...
@@ -130,30 +130,21 @@ static int Demux( demux_t *p_demux )
goto
error
;
/* check root node */
if
(
xml_ReaderRead
(
p_xml_reader
)
!=
1
)
{
msg_Err
(
p_demux
,
"invalid file (no root node)"
);
goto
error
;
}
if
(
xml_ReaderNodeType
(
p_xml_reader
)
!=
XML_READER_STARTELEM
||
if
(
xml_ReaderNextNode
(
p_xml_reader
)
!=
XML_READER_STARTELEM
||
(
psz_eltname
=
xml_ReaderName
(
p_xml_reader
)
)
==
NULL
||
strcmp
(
psz_eltname
,
"embed"
)
)
{
msg_Err
(
p_demux
,
"invalid root node %i, %s"
,
xml_ReaderNodeType
(
p_xml_reader
),
psz_eltname
);
msg_Err
(
p_demux
,
"invalid root node: %s"
,
psz_eltname
);
free
(
psz_eltname
);
psz_eltname
=
NULL
;
/* second line has <?quicktime tag ... so we try to skip it */
msg_Dbg
(
p_demux
,
"trying to read one more node"
);
xml_ReaderRead
(
p_xml_reader
);
if
(
xml_ReaderNodeType
(
p_xml_reader
)
!=
XML_READER_STARTELEM
||
if
(
xml_ReaderNextNode
(
p_xml_reader
)
!=
XML_READER_STARTELEM
||
(
psz_eltname
=
xml_ReaderName
(
p_xml_reader
)
)
==
NULL
||
strcmp
(
psz_eltname
,
"embed"
)
)
{
msg_Err
(
p_demux
,
"invalid root node %i, %s"
,
xml_ReaderNodeType
(
p_xml_reader
),
psz_eltname
);
msg_Err
(
p_demux
,
"invalid root node: %s"
,
psz_eltname
);
free
(
psz_eltname
);
goto
error
;
}
...
...
modules/demux/playlist/shoutcast.c
View file @
59f0684a
...
...
@@ -90,19 +90,17 @@ static int Demux( demux_t *p_demux )
goto
error
;
/* check root node */
if
(
xml_Reader
Read
(
p_xml_reader
)
!=
1
)
if
(
xml_Reader
NextNode
(
p_xml_reader
)
!=
XML_READER_STARTELEM
)
{
msg_Err
(
p_demux
,
"invalid file (no root node)"
);
goto
error
;
}
if
(
xml_ReaderNodeType
(
p_xml_reader
)
!=
XML_READER_STARTELEM
||
(
psz_eltname
=
xml_ReaderName
(
p_xml_reader
)
)
==
NULL
||
if
(
(
psz_eltname
=
xml_ReaderName
(
p_xml_reader
)
)
==
NULL
||
(
strcmp
(
psz_eltname
,
"genrelist"
)
&&
strcmp
(
psz_eltname
,
"stationlist"
)
)
)
{
msg_Err
(
p_demux
,
"invalid root node %i, %s"
,
xml_ReaderNodeType
(
p_xml_reader
),
psz_eltname
);
msg_Err
(
p_demux
,
"invalid root node: %s"
,
psz_eltname
);
goto
error
;
}
...
...
@@ -151,17 +149,12 @@ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader,
input_item_node_t
*
p_input_node
)
{
char
*
psz_name
=
NULL
;
/* genre name */
int
i_ret
=
-
1
;
int
type
;
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
while
(
(
type
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
// Get the node type
switch
(
xml_ReaderNodeType
(
p_xml_reader
)
)
switch
(
type
)
{
// Error
case
-
1
:
goto
error
;
case
XML_READER_STARTELEM
:
{
// Read the element name
...
...
@@ -230,11 +223,10 @@ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader,
}
}
}
i_ret
=
0
;
error:
free
(
psz_name
);
return
i_ret
;
return
0
;
}
/* radio stations:
...
...
@@ -280,20 +272,12 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader,
char
*
psz_load
=
NULL
;
/* load for shoutcast TV */
char
*
psz_eltname
=
NULL
;
/* tag name */
int
i_type
;
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
while
(
(
i_type
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
int
i_type
;
// Get the node type
i_type
=
xml_ReaderNodeType
(
p_xml_reader
);
switch
(
i_type
)
{
// Error
case
-
1
:
return
-
1
;
break
;
case
XML_READER_STARTELEM
:
// Read the element name
psz_eltname
=
xml_ReaderName
(
p_xml_reader
);
...
...
modules/demux/playlist/xspf.c
View file @
59f0684a
...
...
@@ -94,14 +94,11 @@ int Demux( demux_t *p_demux )
goto
end
;
/* locating the root node */
do
if
(
xml_ReaderNextNode
(
p_xml_reader
)
!=
XML_READER_STARTELEM
)
{
if
(
xml_ReaderRead
(
p_xml_reader
)
!=
1
)
{
msg_Err
(
p_demux
,
"can't read xml stream"
);
goto
end
;
}
}
while
(
xml_ReaderNodeType
(
p_xml_reader
)
!=
XML_READER_STARTELEM
);
msg_Err
(
p_demux
,
"can't read xml stream"
);
goto
end
;
}
/* checking root node name */
psz_name
=
xml_ReaderName
(
p_xml_reader
);
...
...
@@ -217,13 +214,10 @@ static bool parse_playlist_node COMPLEX_INTERFACE
/* parse the child elements - we only take care of <trackList> */
psz_name
=
NULL
;
psz_value
=
NULL
;
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
while
(
(
i_node
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
i_node
=
xml_ReaderNodeType
(
p_xml_reader
);
switch
(
i_node
)
{
case
XML_READER_NONE
:
break
;
case
XML_READER_STARTELEM
:
/* element start tag */
psz_name
=
xml_ReaderName
(
p_xml_reader
);
...
...
@@ -302,11 +296,6 @@ static bool parse_playlist_node COMPLEX_INTERFACE
FREE_ATT
();
p_handler
=
NULL
;
break
;
default:
/* unknown/unexpected xml node */
msg_Err
(
p_demux
,
"unexpected xml node %i"
,
i_node
);
goto
end
;
}
}
...
...
@@ -324,11 +313,11 @@ static bool parse_tracklist_node COMPLEX_INTERFACE
VLC_UNUSED
(
psz_element
);
char
*
psz_name
;
int
i_ntracks
=
0
;
int
i_node
;
/* now parse the <track>s */
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
while
(
(
i_node
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
int
i_node
=
xml_ReaderNodeType
(
p_xml_reader
);
if
(
i_node
==
XML_READER_STARTELEM
)
{
char
*
psz_eltname
=
xml_ReaderName
(
p_xml_reader
);
...
...
@@ -357,7 +346,7 @@ static bool parse_tracklist_node COMPLEX_INTERFACE
}
/* the <trackList> has to be terminated */
if
(
xml_ReaderNodeType
(
p_xml_reader
)
!=
XML_READER_ENDELEM
)
if
(
i_node
!=
XML_READER_ENDELEM
)
{
msg_Err
(
p_demux
,
"there's a missing </trackList>"
);
return
false
;
...
...
@@ -386,6 +375,7 @@ static bool parse_track_node COMPLEX_INTERFACE
char
*
psz_value
=
NULL
;
xml_elem_hnd_t
*
p_handler
=
NULL
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
int
i_node
;
bool
b_ret
=
false
;
xml_elem_hnd_t
track_elements
[]
=
...
...
@@ -417,14 +407,10 @@ static bool parse_track_node COMPLEX_INTERFACE
/* reset i_track_id */
p_sys
->
i_track_id
=
-
1
;
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
while
(
(
i_node
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
int
i_node
=
xml_ReaderNodeType
(
p_xml_reader
);
switch
(
i_node
)
{
case
XML_READER_NONE
:
break
;
case
XML_READER_STARTELEM
:
/* element start tag */
psz_name
=
xml_ReaderName
(
p_xml_reader
);
...
...
@@ -570,11 +556,6 @@ static bool parse_track_node COMPLEX_INTERFACE
FREE_ATT
();
p_handler
=
NULL
;
break
;
default:
/* unknown/unexpected xml node */
msg_Err
(
p_demux
,
"unexpected xml node %i"
,
i_node
);
goto
end
;
}
}
msg_Err
(
p_demux
,
"unexpected end of xml data"
);
...
...
@@ -738,20 +719,13 @@ static bool parse_extension_node COMPLEX_INTERFACE
msg_Dbg
(
p_demux
,
"Skipping
\"
%s
\"
extension tag"
,
psz_application
);
free
(
psz_application
);
/* Skip all children */
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
{
if
(
xml_ReaderNodeType
(
p_xml_reader
)
==
XML_READER_ENDELEM
)
for
(
unsigned
lvl
=
1
;
lvl
;
)
switch
(
xml_ReaderNextNode
(
p_xml_reader
)
)
{
char
*
psz_name
=
xml_ReaderName
(
p_xml_reader
);
if
(
!
strcmp
(
psz_name
,
"extension"
)
)
{
free
(
psz_name
);
break
;
}
msg_Dbg
(
p_demux
,
"
\t
skipping
\"
%s
\"
extension child"
,
psz_name
);
free
(
psz_name
);
case
XML_READER_STARTELEM
:
lvl
++
;
break
;
case
XML_READER_ENDELEM
:
lvl
--
;
break
;
case
0
:
case
-
1
:
return
-
1
;
}
}
return
true
;
}
}
...
...
@@ -759,13 +733,10 @@ static bool parse_extension_node COMPLEX_INTERFACE
/* parse the child elements */
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
while
(
(
i_node
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
i_node
=
xml_ReaderNodeType
(
p_xml_reader
);
switch
(
i_node
)
{
case
XML_READER_NONE
:
break
;
case
XML_READER_STARTELEM
:
/* element start tag */
psz_name
=
xml_ReaderName
(
p_xml_reader
);
...
...
@@ -862,13 +833,6 @@ static bool parse_extension_node COMPLEX_INTERFACE
FREE_ATT
();
p_handler
=
NULL
;
break
;
default:
/* unknown/unexpected xml node */
msg_Err
(
p_demux
,
"unexpected xml node %i"
,
i_node
);
FREE_ATT
();
if
(
b_release_input_item
)
vlc_gc_decref
(
p_new_input
);
return
false
;
}
FREE_NAME
();
}
...
...
@@ -931,9 +895,7 @@ static bool parse_extitem_node COMPLEX_INTERFACE
p_demux
->
p_sys
->
pp_tracklist
[
i_tid
]
=
NULL
;
}
/* kludge for #1293 - XTAG sends ENDELEM for self closing tag */
/* (libxml sends NONE) */
xml_ReaderRead
(
p_xml_reader
);
xml_ReaderNextNode
(
p_xml_reader
);
return
true
;
}
...
...
@@ -944,22 +906,15 @@ static bool parse_extitem_node COMPLEX_INTERFACE
static
bool
skip_element
COMPLEX_INTERFACE
{
VLC_UNUSED
(
p_demux
);
VLC_UNUSED
(
p_input_node
);
VLC_UNUSED
(
psz_element
);
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
{
if
(
xml_ReaderNodeType
(
p_xml_reader
)
==
XML_READER_ENDELEM
)
for
(
unsigned
lvl
=
1
;
lvl
;
)
switch
(
xml_ReaderNextNode
(
p_xml_reader
)
)
{
char
*
psz_endname
=
xml_ReaderName
(
p_xml_reader
);
if
(
!
psz_endname
)
return
false
;
if
(
!
strcmp
(
psz_element
,
psz_endname
)
)
{
free
(
psz_endname
);
return
true
;
}
else
free
(
psz_endname
);
case
XML_READER_STARTELEM
:
lvl
++
;
break
;
case
XML_READER_ENDELEM
:
lvl
--
;
break
;
case
0
:
case
-
1
:
return
false
;
}
}
return
fals
e
;
return
tru
e
;
}
modules/gui/skins2/parser/xmlparser.cpp
View file @
59f0684a
...
...
@@ -132,24 +132,18 @@ void XMLParser::LoadCatalog()
bool
XMLParser
::
parse
()
{
int
type
;
if
(
!
m_pReader
)
return
false
;
m_errors
=
false
;
int
ret
=
xml_ReaderRead
(
m_pReader
);
while
(
ret
==
1
)
while
(
(
ret
=
xml_ReaderNextNode
(
m_pReader
))
>
0
)
{
if
(
m_errors
)
return
false
;
// Get the node type
int
type
=
xml_ReaderNodeType
(
m_pReader
);
switch
(
type
)
{
// Error
case
-
1
:
return
false
;
break
;
case
XML_READER_STARTELEM
:
{
// Read the element name
...
...
@@ -197,7 +191,6 @@ bool XMLParser::parse()
break
;
}
}
ret
=
xml_ReaderRead
(
m_pReader
);
}
return
(
ret
==
0
&&
!
m_errors
);
return
(
type
==
0
&&
!
m_errors
);
}
modules/misc/freetype.c
View file @
59f0684a
...
...
@@ -2160,7 +2160,7 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
if
(
p_xml_reader
)
{
/* Look for Root Node */
if
(
xml_Reader
Read
(
p_xml_reader
)
==
1
)
if
(
xml_Reader
NextNode
(
p_xml_reader
)
==
XML_READER_STARTELEM
)
{
char
*
psz_node
=
xml_ReaderName
(
p_xml_reader
);
...
...
modules/misc/lua/libs/xml.c
View file @
59f0684a
...
...
@@ -83,15 +83,13 @@ static int vlclua_xml_create( lua_State *L )
/*****************************************************************************
* XML Reader
*****************************************************************************/
static
int
vlclua_xml_reader_read
(
lua_State
*
);
static
int
vlclua_xml_reader_node_type
(
lua_State
*
);
static
int
vlclua_xml_reader_next_node
(
lua_State
*
);
static
int
vlclua_xml_reader_name
(
lua_State
*
);
static
int
vlclua_xml_reader_value
(
lua_State
*
);
static
int
vlclua_xml_reader_next_attr
(
lua_State
*
);
static
const
luaL_Reg
vlclua_xml_reader_reg
[]
=
{
{
"read"
,
vlclua_xml_reader_read
},
{
"node_type"
,
vlclua_xml_reader_node_type
},
{
"next_node"
,
vlclua_xml_reader_next_node
},
{
"name"
,
vlclua_xml_reader_name
},
{
"value"
,
vlclua_xml_reader_value
},
{
"next_attr"
,
vlclua_xml_reader_next_attr
},
...
...
@@ -130,18 +128,10 @@ static int vlclua_xml_create_reader( lua_State *L )
return
1
;
}
static
int
vlclua_xml_reader_
read
(
lua_State
*
L
)
static
int
vlclua_xml_reader_
next_node
(
lua_State
*
L
)
{
xml_reader_t
*
p_reader
=
*
(
xml_reader_t
**
)
luaL_checkudata
(
L
,
1
,
"xml_reader"
);
lua_pushinteger
(
L
,
xml_ReaderRead
(
p_reader
)
);
return
1
;
}
static
int
vlclua_xml_reader_node_type
(
lua_State
*
L
)
{
xml_reader_t
*
p_reader
=
*
(
xml_reader_t
**
)
luaL_checkudata
(
L
,
1
,
"xml_reader"
);
static
const
char
*
ppsz_type
[]
=
{
"none"
,
"startelem"
,
"endelem"
,
"text"
};
lua_pushstring
(
L
,
ppsz_type
[
xml_ReaderNodeType
(
p_reader
)]
);
lua_pushinteger
(
L
,
xml_ReaderNextNode
(
p_reader
)
);
return
1
;
}
...
...
modules/misc/text_renderer.h
View file @
59f0684a
...
...
@@ -560,12 +560,12 @@ static int ProcessNodes( filter_t *p_filter,
if
(
rv
!=
VLC_SUCCESS
)
return
rv
;
while
(
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
)
int
type
;
while
(
(
type
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
switch
(
xml_ReaderNodeType
(
p_xml_reader
)
)
switch
(
type
)
{
case
XML_READER_NONE
:
break
;
case
XML_READER_ENDELEM
:
psz_node
=
xml_ReaderName
(
p_xml_reader
);
if
(
psz_node
)
...
...
modules/misc/xml/libxml.c
View file @
59f0684a
...
...
@@ -60,8 +60,7 @@ vlc_module_begin ()
vlc_module_end
()
static
int
ReaderRead
(
xml_reader_t
*
);
static
int
ReaderNodeType
(
xml_reader_t
*
);
static
int
ReaderNextNode
(
xml_reader_t
*
);
static
char
*
ReaderName
(
xml_reader_t
*
);
static
char
*
ReaderValue
(
xml_reader_t
*
);
static
int
ReaderNextAttr
(
xml_reader_t
*
);
...
...
@@ -165,8 +164,7 @@ static int ReaderOpen( vlc_object_t *p_this )
xmlTextReaderSetErrorHandler
(
p_libxml_reader
,
ReaderErrorHandler
,
p_reader
);
p_reader
->
pf_read
=
ReaderRead
;
p_reader
->
pf_node_type
=
ReaderNodeType
;
p_reader
->
pf_next_node
=
ReaderNextNode
;
p_reader
->
pf_name
=
ReaderName
;
p_reader
->
pf_value
=
ReaderValue
;
p_reader
->
pf_next_attr
=
ReaderNextAttr
;
...
...
@@ -198,37 +196,31 @@ static int ReaderUseDTD ( xml_reader_t *p_reader )
return
VLC_SUCCESS
;
}
static
int
Reader
Read
(
xml_reader_t
*
p_reader
)
static
int
Reader
NextNode
(
xml_reader_t
*
p_reader
)
{
int
i_ret
=
xmlTextReaderRead
(
(
void
*
)
p_reader
->
p_sys
);
#if 0
switch( i_ret )
skip:
switch
(
xmlTextReaderRead
(
(
void
*
)
p_reader
->
p_sys
)
)
{
default:
case
0
:
/* EOF */
return
0
;
case
-
1
:
/* error */
return
-
1
;
}
#endif
return
i_ret
;
}
static
int
ReaderNodeType
(
xml_reader_t
*
p_reader
)
{
switch
(
xmlTextReaderNodeType
(
(
void
*
)
p_reader
->
p_sys
)
)
{
case
XML_READER_TYPE_ELEMENT
:
return
XML_READER_STARTELEM
;
case
XML_READER_TYPE_END_ELEMENT
:
return
XML_READER_ENDELEM
;
case
XML_READER_TYPE_CDATA
:
case
XML_READER_TYPE_TEXT
:
return
XML_READER_TEXT
;
case
-
1
:
return
-
1
;
case
XML_READER_TYPE_ELEMENT
:
return
XML_READER_STARTELEM
;
case
XML_READER_TYPE_END_ELEMENT
:
return
XML_READER_ENDELEM
;
case
XML_READER_TYPE_CDATA
:
case
XML_READER_TYPE_TEXT
:
return
XML_READER_TEXT
;
case
-
1
:
return
-
1
;
default:
goto
skip
;
}
return
XML_READER_NONE
;
}
static
char
*
ReaderName
(
xml_reader_t
*
p_reader
)
...
...
modules/video_filter/rss.c
View file @
59f0684a
...
...
@@ -685,15 +685,12 @@ static bool ParseFeed( filter_t *p_filter, xml_reader_t *p_xml_reader,
bool
b_is_image
=
false
;
int
i_item
=
0
;
int
type
;
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
while
(
(
type
=
xml_ReaderNextNode
(
p_xml_reader
))
>
0
)
{
switch
(
xml_ReaderNodeType
(
p_xml_reader
)
)
switch
(
type
)
{
// Error
case
-
1
:
goto
end
;
case
XML_READER_STARTELEM
:
free
(
psz_eltname
);
psz_eltname
=
xml_ReaderName
(
p_xml_reader
);
...
...
share/lua/README.txt
View file @
59f0684a
...
...
@@ -439,8 +439,8 @@ XML
---
xml = vlc.xml(): Create an xml object.
reader = xml:create_reader( stream ): create an xml reader that use the given stream.
reader:read(): read some data
reader:node_type(): return the type of the curret node: 'none', 'startelem', 'endelem' or 'text'.
reader:read(): read some data
, return -1 on error, 0 on EOF, 1 on start of XML
element, 2 on end of XML element, 3 on text
reader:name(): name of the element
reader:value(): value of the element
reader:next_attr(): next attribute of the element
...
...
share/lua/modules/simplexml.lua
View file @
59f0684a
...
...
@@ -36,10 +36,11 @@ local function parsexml(stream, errormsg)
local
tree
local
parents
=
{}
while
reader
:
read
()
>
0
do
local
nodetype
=
reader
:
node_type
()
local
nodetype
=
reader
:
next_node
()
while
nodetype
>
0
do
--print(nodetype, reader:name())
if
nodetype
==
'startelem'
then
if
nodetype
==
1
then
local
name
=
reader
:
name
()
local
node
=
{
name
=
''
,
attributes
=
{},
children
=
{}
}
node
.
name
=
name
...
...
@@ -51,7 +52,7 @@ local function parsexml(stream, errormsg)
table.insert
(
parents
,
tree
)
end
tree
=
node
elseif
nodetype
==
'endelem'
then
elseif
nodetype
==
2
then
if
#
parents
>
0
then
local
name
=
reader
:
name
()
local
tmp
=
{}
...
...
@@ -76,7 +77,7 @@ local function parsexml(stream, errormsg)
tree
=
parents
[
#
parents
]
table.remove
(
parents
)
end
elseif
nodetype
==
'text'
then
elseif
nodetype
==
3
then
table.insert
(
tree
.
children
,
reader
:
value
())
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment