Commit 3dbfa99f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Return XML attribute as const from NextAttr

The attribute name is valid until the next attribute or next node.
This simplifies the code a bit: fewer error paths, and free() calls.

A few potential memory leaks were fixed too.
parent 4bea014b
...@@ -73,7 +73,7 @@ struct xml_reader_t ...@@ -73,7 +73,7 @@ struct xml_reader_t
int (*pf_next_node) ( xml_reader_t * ); int (*pf_next_node) ( xml_reader_t * );
char * (*pf_name) ( xml_reader_t * ); char * (*pf_name) ( xml_reader_t * );
char * (*pf_value) ( xml_reader_t * ); char * (*pf_value) ( xml_reader_t * );
int (*pf_next_attr) ( xml_reader_t * ); const char *(*pf_next_attr) ( xml_reader_t * );
int (*pf_use_dtd) ( xml_reader_t * ); int (*pf_use_dtd) ( xml_reader_t * );
}; };
...@@ -98,7 +98,7 @@ static inline char *xml_ReaderValue( xml_reader_t *reader ) ...@@ -98,7 +98,7 @@ static inline char *xml_ReaderValue( xml_reader_t *reader )
return reader->pf_value( reader ); return reader->pf_value( reader );
} }
static inline int xml_ReaderNextAttr( xml_reader_t *reader ) static inline const char *xml_ReaderNextAttr( xml_reader_t *reader )
{ {
return reader->pf_next_attr( reader ); return reader->pf_next_attr( reader );
} }
......
...@@ -583,19 +583,17 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader ) ...@@ -583,19 +583,17 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
else if( !strcasecmp( "resolution", psz_node ) && else if( !strcasecmp( "resolution", psz_node ) &&
( i_metadata_level == 1) ) ( i_metadata_level == 1) )
{ {
while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{ {
char *psz_name = xml_ReaderName ( p_xml_reader );
char *psz_value = xml_ReaderValue ( p_xml_reader ); char *psz_value = xml_ReaderValue ( p_xml_reader );
if( !psz_value )
continue;
if( psz_name && psz_value ) if( !strcasecmp( "x", attr ) )
{ p_sys->i_original_width = atoi( psz_value );
if( !strcasecmp( "x", psz_name ) ) else if( !strcasecmp( "y", attr ) )
p_sys->i_original_width = atoi( psz_value ); p_sys->i_original_height = atoi( psz_value );
else if( !strcasecmp( "y", psz_name ) )
p_sys->i_original_height = atoi( psz_value );
}
free( psz_name );
free( psz_value ); free( psz_value );
} }
} }
...@@ -633,183 +631,180 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader ) ...@@ -633,183 +631,180 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
} }
} }
while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{ {
char *psz_name = xml_ReaderName ( p_xml_reader );
char *psz_value = xml_ReaderValue ( p_xml_reader ); char *psz_value = xml_ReaderValue ( p_xml_reader );
if( !psz_value )
continue;
if( psz_name && psz_value ) if( !strcasecmp( "name", attr ) )
{ {
if( !strcasecmp( "name", psz_name ) ) free( p_ssa_style->psz_stylename );
p_ssa_style->psz_stylename = strdup( psz_value ); p_ssa_style->psz_stylename = strdup( psz_value );
} }
free( psz_name );
free( psz_value ); free( psz_value );
} }
} }
else if( !strcasecmp( "fontstyle", psz_node ) && (i_style_level == 2) ) else if( !strcasecmp( "fontstyle", psz_node ) && (i_style_level == 2) )
{ {
while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{ {
char *psz_name = xml_ReaderName ( p_xml_reader );
char *psz_value = xml_ReaderValue ( p_xml_reader ); char *psz_value = xml_ReaderValue ( p_xml_reader );
if( !psz_value )
continue;
if( psz_name && psz_value ) if( !strcasecmp( "face", attr ) )
{ {
if( !strcasecmp( "face", psz_name ) ) free( p_ssa_style->font_style.psz_fontname );
{ p_ssa_style->font_style.psz_fontname = strdup( psz_value );
free( p_ssa_style->font_style.psz_fontname ); }
p_ssa_style->font_style.psz_fontname = strdup( psz_value ); else if( !strcasecmp( "size", attr ) )
} {
else if( !strcasecmp( "size", psz_name ) ) if( ( *psz_value == '+' ) || ( *psz_value == '-' ) )
{
if( ( *psz_value == '+' ) || ( *psz_value == '-' ) )
{
int i_value = atoi( psz_value );
if( ( i_value >= -5 ) && ( i_value <= 5 ) )
p_ssa_style->font_style.i_font_size +=
( i_value * p_ssa_style->font_style.i_font_size ) / 10;
else if( i_value < -5 )
p_ssa_style->font_style.i_font_size = - i_value;
else if( i_value > 5 )
p_ssa_style->font_style.i_font_size = i_value;
}
else
p_ssa_style->font_style.i_font_size = atoi( psz_value );
}
else if( !strcasecmp( "italic", psz_name ) )
{
if( !strcasecmp( "yes", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_ITALIC;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_ITALIC;
}
else if( !strcasecmp( "weight", psz_name ) )
{
if( !strcasecmp( "bold", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_BOLD;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_BOLD;
}
else if( !strcasecmp( "underline", psz_name ) )
{
if( !strcasecmp( "yes", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_UNDERLINE;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_UNDERLINE;
}
else if( !strcasecmp( "color", psz_name ) )
{
if( *psz_value == '#' )
{
unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_font_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_font_alpha = (col >> 24) & 0xff;
}
}
else if( !strcasecmp( "outline-color", psz_name ) )
{
if( *psz_value == '#' )
{
unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_outline_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_outline_alpha = (col >> 24) & 0xff;
}
}
else if( !strcasecmp( "outline-level", psz_name ) )
{ {
p_ssa_style->font_style.i_outline_width = atoi( psz_value ); int i_value = atoi( psz_value );
if( ( i_value >= -5 ) && ( i_value <= 5 ) )
p_ssa_style->font_style.i_font_size +=
( i_value * p_ssa_style->font_style.i_font_size ) / 10;
else if( i_value < -5 )
p_ssa_style->font_style.i_font_size = - i_value;
else if( i_value > 5 )
p_ssa_style->font_style.i_font_size = i_value;
} }
else if( !strcasecmp( "shadow-color", psz_name ) ) else
p_ssa_style->font_style.i_font_size = atoi( psz_value );
}
else if( !strcasecmp( "italic", attr ) )
{
if( !strcasecmp( "yes", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_ITALIC;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_ITALIC;
}
else if( !strcasecmp( "weight", attr ) )
{
if( !strcasecmp( "bold", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_BOLD;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_BOLD;
}
else if( !strcasecmp( "underline", attr ) )
{
if( !strcasecmp( "yes", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_UNDERLINE;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_UNDERLINE;
}
else if( !strcasecmp( "color", attr ) )
{
if( *psz_value == '#' )
{ {
if( *psz_value == '#' ) unsigned long col = strtol(psz_value+1, NULL, 16);
{ p_ssa_style->font_style.i_font_color = (col & 0x00ffffff);
unsigned long col = strtol(psz_value+1, NULL, 16); p_ssa_style->font_style.i_font_alpha = (col >> 24) & 0xff;
p_ssa_style->font_style.i_shadow_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_shadow_alpha = (col >> 24) & 0xff;
}
} }
else if( !strcasecmp( "shadow-level", psz_name ) ) }
else if( !strcasecmp( "outline-color", attr ) )
{
if( *psz_value == '#' )
{ {
p_ssa_style->font_style.i_shadow_width = atoi( psz_value ); unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_outline_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_outline_alpha = (col >> 24) & 0xff;
} }
else if( !strcasecmp( "back-color", psz_name ) ) }
else if( !strcasecmp( "outline-level", attr ) )
{
p_ssa_style->font_style.i_outline_width = atoi( psz_value );
}
else if( !strcasecmp( "shadow-color", attr ) )
{
if( *psz_value == '#' )
{ {
if( *psz_value == '#' ) unsigned long col = strtol(psz_value+1, NULL, 16);
{ p_ssa_style->font_style.i_shadow_color = (col & 0x00ffffff);
unsigned long col = strtol(psz_value+1, NULL, 16); p_ssa_style->font_style.i_shadow_alpha = (col >> 24) & 0xff;
p_ssa_style->font_style.i_karaoke_background_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_karaoke_background_alpha = (col >> 24) & 0xff;
}
} }
else if( !strcasecmp( "spacing", psz_name ) ) }
else if( !strcasecmp( "shadow-level", attr ) )
{
p_ssa_style->font_style.i_shadow_width = atoi( psz_value );
}
else if( !strcasecmp( "back-color", attr ) )
{
if( *psz_value == '#' )
{ {
p_ssa_style->font_style.i_spacing = atoi( psz_value ); unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_karaoke_background_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_karaoke_background_alpha = (col >> 24) & 0xff;
} }
} }
free( psz_name ); else if( !strcasecmp( "spacing", attr ) )
{
p_ssa_style->font_style.i_spacing = atoi( psz_value );
}
free( psz_value ); free( psz_value );
} }
} }
else if( !strcasecmp( "position", psz_node ) && (i_style_level == 2) ) else if( !strcasecmp( "position", psz_node ) && (i_style_level == 2) )
{ {
while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{ {
char *psz_name = xml_ReaderName ( p_xml_reader );
char *psz_value = xml_ReaderValue ( p_xml_reader ); char *psz_value = xml_ReaderValue ( p_xml_reader );
if( !psz_value )
continue;
if( psz_name && psz_value ) if( !strcasecmp( "alignment", attr ) )
{ {
if( !strcasecmp( "alignment", psz_name ) ) if( !strcasecmp( "TopLeft", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "TopCenter", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP;
else if( !strcasecmp( "TopRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_RIGHT;
else if( !strcasecmp( "MiddleLeft", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "MiddleCenter", psz_value ) )
p_ssa_style->i_align = 0;
else if( !strcasecmp( "MiddleRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_RIGHT;
else if( !strcasecmp( "BottomLeft", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "BottomCenter", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM;
else if( !strcasecmp( "BottomRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_RIGHT;
}
else if( !strcasecmp( "horizontal-margin", attr ) )
{
if( strchr( psz_value, '%' ) )
{
p_ssa_style->i_margin_h = 0;
p_ssa_style->i_margin_percent_h = atoi( psz_value );
}
else
{ {
if( !strcasecmp( "TopLeft", psz_value ) ) p_ssa_style->i_margin_h = atoi( psz_value );
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT; p_ssa_style->i_margin_percent_h = 0;
else if( !strcasecmp( "TopCenter", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP;
else if( !strcasecmp( "TopRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_RIGHT;
else if( !strcasecmp( "MiddleLeft", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "MiddleCenter", psz_value ) )
p_ssa_style->i_align = 0;
else if( !strcasecmp( "MiddleRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_RIGHT;
else if( !strcasecmp( "BottomLeft", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "BottomCenter", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM;
else if( !strcasecmp( "BottomRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_RIGHT;
} }
else if( !strcasecmp( "horizontal-margin", psz_name ) ) }
else if( !strcasecmp( "vertical-margin", attr ) )
{
if( strchr( psz_value, '%' ) )
{ {
if( strchr( psz_value, '%' ) ) p_ssa_style->i_margin_v = 0;
{ p_ssa_style->i_margin_percent_v = atoi( psz_value );
p_ssa_style->i_margin_h = 0;
p_ssa_style->i_margin_percent_h = atoi( psz_value );
}
else
{
p_ssa_style->i_margin_h = atoi( psz_value );
p_ssa_style->i_margin_percent_h = 0;
}
} }
else if( !strcasecmp( "vertical-margin", psz_name ) ) else
{ {
if( strchr( psz_value, '%' ) ) p_ssa_style->i_margin_v = atoi( psz_value );
{ p_ssa_style->i_margin_percent_v = 0;
p_ssa_style->i_margin_v = 0;
p_ssa_style->i_margin_percent_v = atoi( psz_value );
}
else
{
p_ssa_style->i_margin_v = atoi( psz_value );
p_ssa_style->i_margin_percent_v = 0;
}
} }
} }
free( psz_name );
free( psz_value ); free( psz_value );
} }
} }
......
...@@ -122,30 +122,23 @@ static int Demux( demux_t *p_demux ) ...@@ -122,30 +122,23 @@ static int Demux( demux_t *p_demux )
FREENULL( psz_elname ); FREENULL( psz_elname );
// Read the attributes // Read the attributes
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) != NULL )
{ {
char *psz_name = xml_ReaderName( p_xml_reader );
char *psz_value = xml_ReaderValue( p_xml_reader ); char *psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_name || !psz_value ) if( !psz_value )
{ {
free( psz_name );
free( psz_value ); free( psz_value );
goto end; goto end;
} }
if( !strcmp( psz_name, "num_entries" ) )
{ if( !strcmp( attr, "num_entries" ) )
msg_Dbg( p_demux, "playlist has %d entries", atoi(psz_value) ); msg_Dbg( p_demux, "playlist has %d entries", atoi(psz_value) );
} else if( !strcmp( attr, "label" ) )
else if( !strcmp( psz_name, "label" ) )
{
input_item_SetName( p_current_input, psz_value ); input_item_SetName( p_current_input, psz_value );
}
else else
{
msg_Warn( p_demux, "stray attribute %s with value %s in element" msg_Warn( p_demux, "stray attribute %s with value %s in element"
" 'playlist'", psz_name, psz_value ); " 'playlist'", attr, psz_value );
}
free( psz_name );
free( psz_value ); free( psz_value );
} }
...@@ -165,28 +158,25 @@ static int Demux( demux_t *p_demux ) ...@@ -165,28 +158,25 @@ static int Demux( demux_t *p_demux )
goto end; goto end;
// Read the attributes // Read the attributes
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{ {
char *psz_name = xml_ReaderName( p_xml_reader );
char *psz_value = xml_ReaderValue( p_xml_reader ); char *psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_name || !psz_value ) if( !psz_value )
{ {
free( psz_name );
free( psz_value ); free( psz_value );
goto end; goto end;
} }
if( !strcmp( psz_elname, "entry" ) && if( !strcmp( psz_elname, "entry" ) &&
!strcmp( psz_name, "Playstring" ) ) !strcmp( attr, "Playstring" ) )
{ {
psz_mrl = psz_value; psz_mrl = psz_value;
} }
else else
{ {
msg_Warn( p_demux, "unexpected attribute %s in element %s", msg_Warn( p_demux, "unexpected attribute %s in element %s",
psz_name, psz_elname ); attr, psz_elname );
free( psz_value ); free( psz_value );
} }
free( psz_name );
} }
break; break;
} }
......
...@@ -132,24 +132,22 @@ static bool parse_plist_node( demux_t *p_demux, input_item_node_t *p_input_node, ...@@ -132,24 +132,22 @@ static bool parse_plist_node( demux_t *p_demux, input_item_node_t *p_input_node,
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; const char *attr;
char *psz_value; char *psz_value;
bool b_version_found = false; bool b_version_found = false;
/* read all playlist attributes */ /* read all playlist attributes */
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{ {
psz_name = xml_ReaderName( p_xml_reader );
psz_value = xml_ReaderValue( p_xml_reader ); psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_name || !psz_value ) if( !psz_value )
{ {
msg_Err( p_demux, "invalid xml stream @ <plist>" ); msg_Err( p_demux, "invalid xml stream @ <plist>" );
free( psz_name );
free( psz_value ); free( psz_value );
return false; return false;
} }
/* attribute: version */ /* attribute: version */
if( !strcmp( psz_name, "version" ) ) if( !strcmp( attr, "version" ) )
{ {
b_version_found = true; b_version_found = true;
if( strcmp( psz_value, "1.0" ) ) if( strcmp( psz_value, "1.0" ) )
...@@ -157,9 +155,8 @@ static bool parse_plist_node( demux_t *p_demux, input_item_node_t *p_input_node, ...@@ -157,9 +155,8 @@ static bool parse_plist_node( demux_t *p_demux, input_item_node_t *p_input_node,
} }
/* unknown attribute */ /* unknown attribute */
else else
msg_Warn( p_demux, "invalid <plist> attribute:\"%s\"", psz_name); msg_Warn( p_demux, "invalid <plist> attribute:\"%s\"", attr );
free( psz_name );
free( psz_value ); free( psz_value );
} }
......
...@@ -136,30 +136,29 @@ static int Demux( demux_t *p_demux ) ...@@ -136,30 +136,29 @@ static int Demux( demux_t *p_demux )
} }
// Read the attributes // Read the attributes
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{ {
char *psz_name = xml_ReaderName( p_xml_reader );
char *psz_value = xml_ReaderValue( p_xml_reader ); char *psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_name || !psz_value ) if( !psz_value )
{ {
free( psz_name );
free( psz_value ); free( psz_value );
goto error; goto error;
} }
if( !strcmp( psz_elname, "enclosure" ) ) if( !strcmp( psz_elname, "enclosure" ) )
{ {
if( !strcmp( psz_name, "url" ) ) if( !strcmp( attr, "url" ) )
{ {
free( psz_item_mrl ); free( psz_item_mrl );
psz_item_mrl = psz_value; psz_item_mrl = psz_value;
} }
else if( !strcmp( psz_name, "length" ) ) else if( !strcmp( attr, "length" ) )
{ {
free( psz_item_size ); free( psz_item_size );
psz_item_size = psz_value; psz_item_size = psz_value;
} }
else if( !strcmp( psz_name, "type" ) ) else if( !strcmp( attr, "type" ) )
{ {
free( psz_item_type ); free( psz_item_type );
psz_item_type = psz_value; psz_item_type = psz_value;
...@@ -167,17 +166,16 @@ static int Demux( demux_t *p_demux ) ...@@ -167,17 +166,16 @@ static int Demux( demux_t *p_demux )
else else
{ {
msg_Dbg( p_demux,"unhandled attribute %s in element %s", msg_Dbg( p_demux,"unhandled attribute %s in element %s",
psz_name, psz_elname ); attr, psz_elname );
free( psz_value ); free( psz_value );
} }
} }
else else
{ {
msg_Dbg( p_demux,"unhandled attribute %s in element %s", msg_Dbg( p_demux,"unhandled attribute %s in element %s",
psz_name, psz_elname ); attr, psz_elname );
free( psz_value ); free( psz_value );
} }
free( psz_name );
} }
break; break;
} }
......
...@@ -151,115 +151,81 @@ static int Demux( demux_t *p_demux ) ...@@ -151,115 +151,81 @@ static int Demux( demux_t *p_demux )
} }
free( psz_eltname ); free( psz_eltname );
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *attrname;
while( (attrname = xml_ReaderNextAttr( p_xml_reader )) != NULL )
{ {
char *psz_attrname = xml_ReaderName( p_xml_reader );
char *psz_attrvalue = xml_ReaderValue( p_xml_reader ); char *psz_attrvalue = xml_ReaderValue( p_xml_reader );
if( !psz_attrname || !psz_attrvalue ) if( !psz_attrvalue )
{ {
free( psz_attrname );
free( psz_attrvalue ); free( psz_attrvalue );
goto error; goto error;
} }
if( !strcmp( psz_attrname, "autoplay" ) ) if( !strcmp( attrname, "autoplay" ) )
{
b_autoplay = !strcmp( psz_attrvalue, "true" ); b_autoplay = !strcmp( psz_attrvalue, "true" );
} else if( !strcmp( attrname, "controler" ) )
else if( !strcmp( psz_attrname, "controler" ) )
{
b_controler = !strcmp( psz_attrvalue, "false" ); b_controler = !strcmp( psz_attrvalue, "false" );
} else if( !strcmp( attrname, "fullscreen" ) )
else if( !strcmp( psz_attrname, "fullscreen" ) )
{ {
if( !strcmp( psz_attrvalue, "double" ) ) if( !strcmp( psz_attrvalue, "double" ) )
{
fullscreen = FULLSCREEN_DOUBLE; fullscreen = FULLSCREEN_DOUBLE;
}
else if( !strcmp( psz_attrvalue, "half" ) ) else if( !strcmp( psz_attrvalue, "half" ) )
{
fullscreen = FULLSCREEN_HALF; fullscreen = FULLSCREEN_HALF;
}
else if( !strcmp( psz_attrvalue, "current" ) ) else if( !strcmp( psz_attrvalue, "current" ) )
{
fullscreen = FULLSCREEN_CURRENT; fullscreen = FULLSCREEN_CURRENT;
}
else if( !strcmp( psz_attrvalue, "full" ) ) else if( !strcmp( psz_attrvalue, "full" ) )
{
fullscreen = FULLSCREEN_FULL; fullscreen = FULLSCREEN_FULL;
}
else else
{
fullscreen = FULLSCREEN_NORMAL; fullscreen = FULLSCREEN_NORMAL;
}
} }
else if( !strcmp( psz_attrname, "href" ) ) else if( !strcmp( attrname, "href" ) )
{ {
psz_href = psz_attrvalue; psz_href = psz_attrvalue;
psz_attrvalue = NULL; psz_attrvalue = NULL;
} }
else if( !strcmp( psz_attrname, "kioskmode" ) ) else if( !strcmp( attrname, "kioskmode" ) )
{
b_kioskmode = !strcmp( psz_attrvalue, "true" ); b_kioskmode = !strcmp( psz_attrvalue, "true" );
} else if( !strcmp( attrname, "loop" ) )
else if( !strcmp( psz_attrname, "loop" ) )
{ {
if( !strcmp( psz_attrvalue, "true" ) ) if( !strcmp( psz_attrvalue, "true" ) )
{
loop = LOOP_TRUE; loop = LOOP_TRUE;
}
else if( !strcmp( psz_attrvalue, "palindrome" ) ) else if( !strcmp( psz_attrvalue, "palindrome" ) )
{
loop = LOOP_PALINDROME; loop = LOOP_PALINDROME;
}
else else
{
loop = LOOP_FALSE; loop = LOOP_FALSE;
}
} }
else if( !strcmp( psz_attrname, "movieid" ) ) else if( !strcmp( attrname, "movieid" ) )
{
i_movieid = atoi( psz_attrvalue ); i_movieid = atoi( psz_attrvalue );
} else if( !strcmp( attrname, "moviename" ) )
else if( !strcmp( psz_attrname, "moviename" ) )
{ {
psz_moviename = psz_attrvalue; psz_moviename = psz_attrvalue;
psz_attrvalue = NULL; psz_attrvalue = NULL;
} }
else if( !strcmp( psz_attrname, "playeveryframe" ) ) else if( !strcmp( attrname, "playeveryframe" ) )
{
b_playeveryframe = !strcmp( psz_attrvalue, "true" ); b_playeveryframe = !strcmp( psz_attrvalue, "true" );
} else if( !strcmp( attrname, "qtnext" ) )
else if( !strcmp( psz_attrname, "qtnext" ) )
{ {
psz_qtnext = psz_attrvalue; psz_qtnext = psz_attrvalue;
psz_attrvalue = NULL; psz_attrvalue = NULL;
} }
else if( !strcmp( psz_attrname, "quitwhendone" ) ) else if( !strcmp( attrname, "quitwhendone" ) )
{
b_quitwhendone = !strcmp( psz_attrvalue, "true" ); b_quitwhendone = !strcmp( psz_attrvalue, "true" );
} else if( !strcmp( attrname, "src" ) )
else if( !strcmp( psz_attrname, "src" ) )
{ {
psz_src = psz_attrvalue; psz_src = psz_attrvalue;
psz_attrvalue = NULL; psz_attrvalue = NULL;
} }
else if( !strcmp( psz_attrname, "mimetype" ) ) else if( !strcmp( attrname, "mimetype" ) )
{ {
psz_mimetype = psz_attrvalue; psz_mimetype = psz_attrvalue;
psz_attrvalue = NULL; psz_attrvalue = NULL;
} }
else if( !strcmp( psz_attrname, "volume" ) ) else if( !strcmp( attrname, "volume" ) )
{
i_volume = atoi( psz_attrvalue ); i_volume = atoi( psz_attrvalue );
}
else else
{
msg_Dbg( p_demux, "Attribute %s with value %s isn't valid", msg_Dbg( p_demux, "Attribute %s with value %s isn't valid",
psz_attrname, psz_attrvalue ); attrname, psz_attrvalue );
}
free( psz_attrname );
free( psz_attrvalue ); free( psz_attrvalue );
} }
......
...@@ -135,7 +135,7 @@ error: ...@@ -135,7 +135,7 @@ error:
} }
#define GET_VALUE( a ) \ #define GET_VALUE( a ) \
if( !strcmp( psz_attrname, #a ) ) \ if( !strcmp( attrname, #a ) ) \
{ \ { \
free(psz_ ## a); \ free(psz_ ## a); \
psz_ ## a = psz_attrvalue; \ psz_ ## a = psz_attrvalue; \
...@@ -165,14 +165,12 @@ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader, ...@@ -165,14 +165,12 @@ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader,
if( !strcmp( psz_eltname, "genre" ) ) if( !strcmp( psz_eltname, "genre" ) )
{ {
// Read the attributes // Read the attributes
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *attrname;
while( (attrname = xml_ReaderNextAttr( p_xml_reader )) )
{ {
char *psz_attrname = xml_ReaderName( p_xml_reader ); char *psz_attrvalue = xml_ReaderValue( p_xml_reader );
char *psz_attrvalue = if( !psz_attrvalue )
xml_ReaderValue( p_xml_reader );
if( !psz_attrname || !psz_attrvalue )
{ {
free( psz_attrname );
free( psz_attrvalue ); free( psz_attrvalue );
break; break;
} }
...@@ -182,10 +180,9 @@ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader, ...@@ -182,10 +180,9 @@ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader,
{ {
msg_Warn( p_demux, msg_Warn( p_demux,
"unexpected attribute %s in element %s", "unexpected attribute %s in element %s",
psz_attrname, psz_eltname ); attrname, psz_eltname );
free( psz_attrvalue ); free( psz_attrvalue );
} }
free( psz_attrname );
} }
} }
free( psz_eltname ); free( psz_eltname );
...@@ -286,15 +283,13 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader, ...@@ -286,15 +283,13 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader,
// Read the attributes // Read the attributes
if( !strcmp( psz_eltname, "tunein" ) ) if( !strcmp( psz_eltname, "tunein" ) )
{ {
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *attrname;
while( (attrname = xml_ReaderNextAttr( p_xml_reader )) )
{ {
char *psz_attrname = xml_ReaderName( p_xml_reader ); char *psz_attrvalue = xml_ReaderValue( p_xml_reader );
char *psz_attrvalue = if( !psz_attrvalue )
xml_ReaderValue( p_xml_reader );
if( !psz_attrname || !psz_attrvalue )
{ {
free( psz_eltname ); free( psz_eltname );
free( psz_attrname );
free( psz_attrvalue ); free( psz_attrvalue );
return -1; return -1;
} }
...@@ -304,23 +299,20 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader, ...@@ -304,23 +299,20 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader,
{ {
msg_Warn( p_demux, msg_Warn( p_demux,
"unexpected attribute %s in element %s", "unexpected attribute %s in element %s",
psz_attrname, psz_eltname ); attrname, psz_eltname );
free( psz_attrvalue ); free( psz_attrvalue );
} }
free( psz_attrname );
} }
} }
else if( !strcmp( psz_eltname, "station" ) ) else if( !strcmp( psz_eltname, "station" ) )
{ {
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *attrname;
while( (attrname = xml_ReaderNextAttr( p_xml_reader )) )
{ {
char *psz_attrname = xml_ReaderName( p_xml_reader ); char *psz_attrvalue = xml_ReaderValue( p_xml_reader );
char *psz_attrvalue = if( !psz_attrvalue )
xml_ReaderValue( p_xml_reader );
if( !psz_attrname || !psz_attrvalue )
{ {
free( psz_eltname ); free( psz_eltname );
free( psz_attrname );
free( psz_attrvalue ); free( psz_attrvalue );
return -1; return -1;
} }
...@@ -338,10 +330,9 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader, ...@@ -338,10 +330,9 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader,
{ {
msg_Warn( p_demux, msg_Warn( p_demux,
"unexpected attribute %s in element %s", "unexpected attribute %s in element %s",
psz_attrname, psz_eltname ); attrname, psz_eltname );
free( psz_attrvalue ); free( psz_attrvalue );
} }
free( psz_attrname );
} }
} }
free( psz_eltname ); free( psz_eltname );
......
...@@ -177,34 +177,34 @@ static bool parse_playlist_node COMPLEX_INTERFACE ...@@ -177,34 +177,34 @@ static bool parse_playlist_node COMPLEX_INTERFACE
}; };
/* read all playlist attributes */ /* read all playlist attributes */
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *name;
while( (name = xml_ReaderNextAttr( p_xml_reader )) != NULL )
{ {
psz_name = xml_ReaderName( p_xml_reader );
psz_value = xml_ReaderValue( p_xml_reader ); psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_name || !psz_value ) if( !psz_value )
{ {
msg_Err( p_demux, "invalid xml stream @ <playlist>" ); msg_Err( p_demux, "invalid xml stream @ <playlist>" );
goto end; goto end;
} }
/* attribute: version */ /* attribute: version */
if( !strcmp( psz_name, "version" ) ) if( !strcmp( name, "version" ) )
{ {
b_version_found = true; b_version_found = true;
if( strcmp( psz_value, "0" ) && strcmp( psz_value, "1" ) ) if( strcmp( psz_value, "0" ) && strcmp( psz_value, "1" ) )
msg_Warn( p_demux, "unsupported XSPF version" ); msg_Warn( p_demux, "unsupported XSPF version" );
} }
/* attribute: xmlns */ /* attribute: xmlns */
else if( !strcmp( psz_name, "xmlns" ) || !strcmp( psz_name, "xmlns:vlc" ) ) else if( !strcmp( name, "xmlns" ) || !strcmp( name, "xmlns:vlc" ) )
; ;
else if( !strcmp( psz_name, "xml:base" ) ) else if( !strcmp( name, "xml:base" ) )
{ {
free( p_demux->p_sys->psz_base );
p_demux->p_sys->psz_base = strdup( psz_value ); p_demux->p_sys->psz_base = strdup( psz_value );
} }
/* unknown attribute */ /* unknown attribute */
else else
msg_Warn( p_demux, "invalid <playlist> attribute:\"%s\"", psz_name); msg_Warn( p_demux, "invalid <playlist> attribute: \"%s\"", name);
free( psz_name );
free( psz_value ); free( psz_value );
} }
/* attribute version is mandatory !!! */ /* attribute version is mandatory !!! */
...@@ -235,7 +235,6 @@ static bool parse_playlist_node COMPLEX_INTERFACE ...@@ -235,7 +235,6 @@ static bool parse_playlist_node COMPLEX_INTERFACE
msg_Err( p_demux, "unexpected element <%s>", psz_name ); msg_Err( p_demux, "unexpected element <%s>", psz_name );
goto end; goto end;
} }
FREE_NAME();
/* complex content is parsed in a separate function */ /* complex content is parsed in a separate function */
if( p_handler->type == COMPLEX_CONTENT ) if( p_handler->type == COMPLEX_CONTENT )
{ {
...@@ -428,7 +427,6 @@ static bool parse_track_node COMPLEX_INTERFACE ...@@ -428,7 +427,6 @@ static bool parse_track_node COMPLEX_INTERFACE
msg_Err( p_demux, "unexpected element <%s>", psz_name ); msg_Err( p_demux, "unexpected element <%s>", psz_name );
goto end; goto end;
} }
FREE_NAME();
/* complex content is parsed in a separate function */ /* complex content is parsed in a separate function */
if( p_handler->type == COMPLEX_CONTENT ) if( p_handler->type == COMPLEX_CONTENT )
{ {
...@@ -653,35 +651,36 @@ static bool parse_extension_node COMPLEX_INTERFACE ...@@ -653,35 +651,36 @@ static bool parse_extension_node COMPLEX_INTERFACE
}; };
/* read all extension node attributes */ /* read all extension node attributes */
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *name;
while( (name = xml_ReaderNextAttr( p_xml_reader )) != NULL )
{ {
psz_name = xml_ReaderName( p_xml_reader );
psz_value = xml_ReaderValue( p_xml_reader ); psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_name || !psz_value ) if( !psz_value )
{ {
msg_Err( p_demux, "invalid xml stream @ <vlc:node>" ); msg_Err( p_demux, "invalid xml stream @ <vlc:node>" );
FREE_ATT(); FREE_ATT();
return false; return false;
} }
/* attribute: title */ /* attribute: title */
if( !strcmp( psz_name, "title" ) ) if( !strcmp( name, "title" ) )
{ {
resolve_xml_special_chars( psz_value ); resolve_xml_special_chars( psz_value );
free( psz_title );
psz_title = psz_value; psz_title = psz_value;
} }
/* extension attribute: application */ /* extension attribute: application */
else if( !strcmp( psz_name, "application" ) ) else if( !strcmp( name, "application" ) )
{ {
free( psz_application );
psz_application = psz_value; psz_application = psz_value;
} }
/* unknown attribute */ /* unknown attribute */
else else
{ {
msg_Warn( p_demux, "invalid <%s> attribute:\"%s\"", psz_element, msg_Warn( p_demux, "invalid <%s> attribute:\"%s\"", psz_element,
psz_name ); name );
FREE_VALUE(); FREE_VALUE();
} }
FREE_NAME();
psz_value = NULL; psz_value = NULL;
} }
...@@ -758,7 +757,6 @@ static bool parse_extension_node COMPLEX_INTERFACE ...@@ -758,7 +757,6 @@ static bool parse_extension_node COMPLEX_INTERFACE
if( b_release_input_item ) vlc_gc_decref( p_new_input ); if( b_release_input_item ) vlc_gc_decref( p_new_input );
return false; return false;
} }
FREE_NAME();
/* complex content is parsed in a separate function */ /* complex content is parsed in a separate function */
if( p_handler->type == COMPLEX_CONTENT ) if( p_handler->type == COMPLEX_CONTENT )
{ {
...@@ -834,7 +832,6 @@ static bool parse_extension_node COMPLEX_INTERFACE ...@@ -834,7 +832,6 @@ static bool parse_extension_node COMPLEX_INTERFACE
p_handler = NULL; p_handler = NULL;
break; break;
} }
FREE_NAME();
} }
if( b_release_input_item ) vlc_gc_decref( p_new_input ); if( b_release_input_item ) vlc_gc_decref( p_new_input );
return false; return false;
...@@ -850,27 +847,23 @@ static bool parse_extitem_node COMPLEX_INTERFACE ...@@ -850,27 +847,23 @@ static bool parse_extitem_node COMPLEX_INTERFACE
int i_tid = -1; int i_tid = -1;
/* read all extension item attributes */ /* read all extension item attributes */
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *name;
while( (name = xml_ReaderNextAttr( p_xml_reader )) != NULL )
{ {
char *psz_name = xml_ReaderName( p_xml_reader );
char *psz_value = xml_ReaderValue( p_xml_reader ); char *psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_name || !psz_value ) if( !psz_value )
{ {
msg_Err( p_demux, "invalid xml stream @ <vlc:item>" ); msg_Err( p_demux, "invalid xml stream @ <vlc:item>" );
free( psz_name );
free( psz_value ); free( psz_value );
return false; return false;
} }
/* attribute: href */ /* attribute: href */
if( !strcmp( psz_name, "tid" ) ) if( !strcmp( name, "tid" ) )
{
i_tid = atoi( psz_value ); i_tid = atoi( psz_value );
}
/* unknown attribute */ /* unknown attribute */
else else
msg_Warn( p_demux, "invalid <vlc:item> attribute:\"%s\"", psz_name); msg_Warn( p_demux, "invalid <vlc:item> attribute: \"%s\"", name);
free( psz_name );
free( psz_value ); free( psz_value );
} }
......
...@@ -21,9 +21,8 @@ ...@@ -21,9 +21,8 @@
*/ */
/* defines */ /* defines */
#define FREE_NAME() free(psz_name);psz_name=NULL;
#define FREE_VALUE() free(psz_value);psz_value=NULL; #define FREE_VALUE() free(psz_value);psz_value=NULL;
#define FREE_ATT() FREE_NAME();FREE_VALUE() #define FREE_ATT() FREE_VALUE()
enum { enum {
UNKNOWN_CONTENT, UNKNOWN_CONTENT,
......
...@@ -153,17 +153,16 @@ bool XMLParser::parse() ...@@ -153,17 +153,16 @@ bool XMLParser::parse()
// Read the attributes // Read the attributes
AttrList_t attributes; AttrList_t attributes;
while( xml_ReaderNextAttr( m_pReader ) == VLC_SUCCESS ) const char *name;
while( (name = xml_ReaderNextAttr( m_pReader )) != NULL )
{ {
char *name = xml_ReaderName( m_pReader );
char *value = xml_ReaderValue( m_pReader ); char *value = xml_ReaderValue( m_pReader );
if( !name || !value ) if( !value )
{ {
free( name );
free( value ); free( value );
return false; return false;
} }
attributes[name] = value; attributes[strdup(name)] = value;
} }
handleBeginElement( eltName, attributes ); handleBeginElement( eltName, attributes );
......
...@@ -152,7 +152,7 @@ static int vlclua_xml_reader_value( lua_State *L ) ...@@ -152,7 +152,7 @@ static int vlclua_xml_reader_value( lua_State *L )
static int vlclua_xml_reader_next_attr( lua_State *L ) static int vlclua_xml_reader_next_attr( lua_State *L )
{ {
xml_reader_t *p_reader = *(xml_reader_t**)luaL_checkudata( L, 1, "xml_reader" ); xml_reader_t *p_reader = *(xml_reader_t**)luaL_checkudata( L, 1, "xml_reader" );
lua_pushinteger( L, xml_ReaderNextAttr( p_reader ) ); lua_pushstring( L, xml_ReaderNextAttr( p_reader ) );
return 1; return 1;
} }
......
...@@ -331,61 +331,58 @@ static int HandleFontAttributes( xml_reader_t *p_xml_reader, ...@@ -331,61 +331,58 @@ static int HandleFontAttributes( xml_reader_t *p_xml_reader,
i_font_alpha = (i_font_color >> 24) & 0xff; i_font_alpha = (i_font_color >> 24) & 0xff;
i_font_color &= 0x00ffffff; i_font_color &= 0x00ffffff;
while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *name;
while( (name = xml_ReaderNextAttr( p_xml_reader )) != NULL )
{ {
char *psz_name = xml_ReaderName( p_xml_reader );
char *psz_value = xml_ReaderValue( p_xml_reader ); char *psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_value )
continue;
if( psz_name && psz_value ) if( !strcasecmp( "face", name ) )
{ {
if( !strcasecmp( "face", psz_name ) ) free( psz_fontname );
psz_fontname = strdup( psz_value );
}
else if( !strcasecmp( "size", name ) )
{
if( ( *psz_value == '+' ) || ( *psz_value == '-' ) )
{ {
free( psz_fontname ); int i_value = atoi( psz_value );
psz_fontname = strdup( psz_value );
if( ( i_value >= -5 ) && ( i_value <= 5 ) )
i_font_size += ( i_value * i_font_size ) / 10;
else if( i_value < -5 )
i_font_size = - i_value;
else if( i_value > 5 )
i_font_size = i_value;
} }
else if( !strcasecmp( "size", psz_name ) ) else
i_font_size = atoi( psz_value );
}
else if( !strcasecmp( "color", name ) )
{
if( psz_value[0] == '#' )
{ {
if( ( *psz_value == '+' ) || ( *psz_value == '-' ) ) i_font_color = strtol( psz_value + 1, NULL, 16 );
{ i_font_color &= 0x00ffffff;
int i_value = atoi( psz_value );
if( ( i_value >= -5 ) && ( i_value <= 5 ) )
i_font_size += ( i_value * i_font_size ) / 10;
else if( i_value < -5 )
i_font_size = - i_value;
else if( i_value > 5 )
i_font_size = i_value;
}
else
i_font_size = atoi( psz_value );
} }
else if( !strcasecmp( "color", psz_name ) ) else
{ {
if( psz_value[0] == '#' ) for( int i = 0; p_html_colors[i].psz_name != NULL; i++ )
{
i_font_color = strtol( psz_value + 1, NULL, 16 );
i_font_color &= 0x00ffffff;
}
else
{ {
for( int i = 0; p_html_colors[i].psz_name != NULL; i++ ) if( !strncasecmp( psz_value, p_html_colors[i].psz_name, strlen(p_html_colors[i].psz_name) ) )
{ {
if( !strncasecmp( psz_value, p_html_colors[i].psz_name, strlen(p_html_colors[i].psz_name) ) ) i_font_color = p_html_colors[i].i_value;
{ break;
i_font_color = p_html_colors[i].i_value;
break;
}
} }
} }
} }
else if( !strcasecmp( "alpha", psz_name ) &&
( psz_value[0] == '#' ) )
{
i_font_alpha = strtol( psz_value + 1, NULL, 16 );
i_font_alpha &= 0xff;
}
} }
free( psz_name ); else if( !strcasecmp( "alpha", name ) && ( psz_value[0] == '#' ) )
{
i_font_alpha = strtol( psz_value + 1, NULL, 16 );
i_font_alpha &= 0xff;
}
free( psz_value ); free( psz_value );
} }
rv = PushFont( p_fonts, rv = PushFont( p_fonts,
...@@ -430,13 +427,15 @@ static void SetupKaraoke( xml_reader_t *p_xml_reader, uint32_t *pi_k_runs, ...@@ -430,13 +427,15 @@ static void SetupKaraoke( xml_reader_t *p_xml_reader, uint32_t *pi_k_runs,
uint32_t **ppi_k_run_lengths, uint32_t **ppi_k_run_lengths,
uint32_t **ppi_k_durations ) uint32_t **ppi_k_durations )
{ {
while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) const char *name;
while( (name = xml_ReaderNextAttr( p_xml_reader )) != NULL )
{ {
char *psz_name = xml_ReaderName( p_xml_reader );
char *psz_value = xml_ReaderValue( p_xml_reader ); char *psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_value )
continue;
if( psz_name && psz_value && if( !strcasecmp( "t", name ) )
!strcasecmp( "t", psz_name ) )
{ {
if( ppi_k_durations && ppi_k_run_lengths ) if( ppi_k_durations && ppi_k_run_lengths )
{ {
...@@ -470,7 +469,6 @@ static void SetupKaraoke( xml_reader_t *p_xml_reader, uint32_t *pi_k_runs, ...@@ -470,7 +469,6 @@ static void SetupKaraoke( xml_reader_t *p_xml_reader, uint32_t *pi_k_runs,
(*ppi_k_run_lengths)[ *pi_k_runs - 1 ] = 0; (*ppi_k_run_lengths)[ *pi_k_runs - 1 ] = 0;
} }
} }
free( psz_name );
free( psz_value ); free( psz_value );
} }
} }
......
...@@ -63,7 +63,7 @@ vlc_module_end () ...@@ -63,7 +63,7 @@ vlc_module_end ()
static int ReaderNextNode( xml_reader_t * ); static int ReaderNextNode( xml_reader_t * );
static char *ReaderName( xml_reader_t * ); static char *ReaderName( xml_reader_t * );
static char *ReaderValue( xml_reader_t * ); static char *ReaderValue( xml_reader_t * );
static int ReaderNextAttr( xml_reader_t * ); static const char *ReaderNextAttr( xml_reader_t * );
static int ReaderUseDTD ( xml_reader_t * ); static int ReaderUseDTD ( xml_reader_t * );
...@@ -239,10 +239,11 @@ static char *ReaderValue( xml_reader_t *p_reader ) ...@@ -239,10 +239,11 @@ static char *ReaderValue( xml_reader_t *p_reader )
return psz_value ? strdup( (const char *)psz_value ) : NULL; return psz_value ? strdup( (const char *)psz_value ) : NULL;
} }
static int ReaderNextAttr( xml_reader_t *p_reader ) static const char *ReaderNextAttr( xml_reader_t *p_reader )
{ {
return ( xmlTextReaderMoveToNextAttribute( (void *)p_reader->p_sys ) if( xmlTextReaderMoveToNextAttribute( (void *)p_reader->p_sys ) != 1 )
== 1 ) ? VLC_SUCCESS : VLC_EGENERIC; return NULL;
return (const char *)xmlTextReaderConstValue( (void *)p_reader->p_sys );
} }
static int StreamRead( void *p_context, char *p_buffer, int i_buffer ) static int StreamRead( void *p_context, char *p_buffer, int i_buffer )
......
...@@ -719,27 +719,27 @@ static bool ParseFeed( filter_t *p_filter, xml_reader_t *p_xml_reader, ...@@ -719,27 +719,27 @@ static bool ParseFeed( filter_t *p_filter, xml_reader_t *p_xml_reader,
/* atom */ /* atom */
else if( !strcmp( psz_eltname, "link" ) ) else if( !strcmp( psz_eltname, "link" ) )
{ {
const char *name;
char *psz_href = NULL; char *psz_href = NULL;
char *psz_rel = NULL; char *psz_rel = NULL;
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
while( (name = xml_ReaderNextAttr( p_xml_reader )) != NULL )
{ {
char *psz_name = xml_ReaderName( p_xml_reader );
char *psz_value = xml_ReaderValue( p_xml_reader ); char *psz_value = xml_ReaderValue( p_xml_reader );
if( !strcmp( psz_name, "rel" ) ) if( !psz_value )
continue;
if( !strcmp( name, "rel" ) )
{ {
free( psz_rel ); free( psz_rel );
psz_rel = psz_value; psz_rel = psz_value;
} }
else if( !strcmp( psz_name, "href" ) ) else if( !strcmp( name, "href" ) )
{ {
free( psz_href ); free( psz_href );
psz_href = psz_value; psz_href = psz_value;
} }
else else
{
free( psz_value ); free( psz_value );
}
free( psz_name );
} }
/* "rel" and "href" must be defined */ /* "rel" and "href" must be defined */
......
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