Commit d80344c3 authored by Rémi Duraffort's avatar Rémi Duraffort

itml: cleaning and factorize.

parent 854946f1
...@@ -31,12 +31,12 @@ ...@@ -31,12 +31,12 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_xml.h>
#include <vlc_strings.h>
#include <vlc_url.h>
#include "playlist.h"
#include "vlc_xml.h"
#include "vlc_strings.h"
#include "vlc_url.h"
#include "itml.h" #include "itml.h"
#include "playlist.h"
struct demux_sys_t struct demux_sys_t
{ {
...@@ -135,8 +135,8 @@ static bool parse_plist_node( demux_t *p_demux, input_item_t *p_input_item, ...@@ -135,8 +135,8 @@ static bool parse_plist_node( demux_t *p_demux, input_item_t *p_input_item,
xml_elem_hnd_t *p_handlers ) xml_elem_hnd_t *p_handlers )
{ {
VLC_UNUSED(p_track); VLC_UNUSED(psz_element); VLC_UNUSED(p_track); VLC_UNUSED(psz_element);
char *psz_name = NULL; char *psz_name;
char *psz_value = NULL; char *psz_value;
bool b_version_found = false; bool b_version_found = false;
/* read all playlist attributes */ /* read all playlist attributes */
...@@ -187,6 +187,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item, ...@@ -187,6 +187,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item,
char *psz_value = NULL; char *psz_value = NULL;
char *psz_key = NULL; char *psz_key = NULL;
xml_elem_hnd_t *p_handler = NULL; xml_elem_hnd_t *p_handler = NULL;
bool b_ret = false;
while( xml_ReaderRead( p_xml_reader ) == 1 ) while( xml_ReaderRead( p_xml_reader ) == 1 )
{ {
...@@ -202,8 +203,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item, ...@@ -202,8 +203,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item,
if( !psz_name || !*psz_name ) if( !psz_name || !*psz_name )
{ {
msg_Err( p_demux, "invalid xml stream" ); msg_Err( p_demux, "invalid xml stream" );
FREE_ATT_KEY(); goto end;
return false;
} }
/* choose handler */ /* choose handler */
for( p_handler = p_handlers; for( p_handler = p_handlers;
...@@ -212,8 +212,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item, ...@@ -212,8 +212,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item,
if( !p_handler->name ) if( !p_handler->name )
{ {
msg_Err( p_demux, "unexpected element <%s>", psz_name ); msg_Err( p_demux, "unexpected element <%s>", psz_name );
FREE_ATT_KEY(); goto end;
return false;
} }
FREE_NAME(); FREE_NAME();
/* complex content is parsed in a separate function */ /* complex content is parsed in a separate function */
...@@ -231,8 +230,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item, ...@@ -231,8 +230,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item,
} }
else else
{ {
FREE_ATT_KEY(); goto end;
return false;
} }
} }
break; break;
...@@ -244,8 +242,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item, ...@@ -244,8 +242,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item,
if( !psz_value ) if( !psz_value )
{ {
msg_Err( p_demux, "invalid xml stream" ); msg_Err( p_demux, "invalid xml stream" );
FREE_ATT_KEY(); goto end;
return false;
} }
break; break;
...@@ -255,14 +252,13 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item, ...@@ -255,14 +252,13 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item,
if( !psz_name ) if( !psz_name )
{ {
msg_Err( p_demux, "invalid xml stream" ); msg_Err( p_demux, "invalid xml stream" );
FREE_ATT_KEY(); goto end;
return false;
} }
/* leave if the current parent node <track> is terminated */ /* leave if the current parent node <track> is terminated */
if( !strcmp( psz_name, psz_element ) ) if( !strcmp( psz_name, psz_element ) )
{ {
FREE_ATT_KEY(); b_ret = true;
return true; goto end;
} }
/* there MUST have been a start tag for that element name */ /* there MUST have been a start tag for that element name */
if( !p_handler || !p_handler->name if( !p_handler || !p_handler->name
...@@ -270,8 +266,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item, ...@@ -270,8 +266,7 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item,
{ {
msg_Err( p_demux, "there's no open element left for <%s>", msg_Err( p_demux, "there's no open element left for <%s>",
psz_name ); psz_name );
FREE_ATT_KEY(); goto end;
return false;
} }
/* special case: key */ /* special case: key */
if( !strcmp( p_handler->name, "key" ) ) if( !strcmp( p_handler->name, "key" ) )
...@@ -290,14 +285,15 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item, ...@@ -290,14 +285,15 @@ static bool parse_dict( demux_t *p_demux, input_item_t *p_input_item,
default: default:
/* unknown/unexpected xml node */ /* unknown/unexpected xml node */
msg_Err( p_demux, "unexpected xml node %i", i_node ); msg_Err( p_demux, "unexpected xml node %i", i_node );
FREE_ATT_KEY(); goto end;
return false;
} }
FREE_NAME(); FREE_NAME();
} }
msg_Err( p_demux, "unexpected end of xml data" ); msg_Err( p_demux, "unexpected end of xml data" );
end:
FREE_ATT_KEY(); FREE_ATT_KEY();
return false; return b_ret;
} }
static bool parse_plist_dict( demux_t *p_demux, input_item_t *p_input_item, static bool parse_plist_dict( demux_t *p_demux, input_item_t *p_input_item,
......
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