]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/shoutcast.c
People might perhaps maybe want to right-click anywhere
[vlc] / modules / demux / playlist / shoutcast.c
index 56d85961f277ff55724a53f0cf54587beb85c6a1..ca7caebbf7bf82393bf7beba7be87f441247bb34 100644 (file)
@@ -25,7 +25,6 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
 #include <ctype.h>                                              /* isspace() */
 
 #include <vlc/vlc.h>
@@ -69,35 +68,19 @@ static int DemuxStation( demux_t *p_demux );
 int E_(Import_Shoutcast)( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
-    demux_sys_t *p_sys;
 
-    char    *psz_ext;
-
-    psz_ext = strrchr ( p_demux->psz_path, '.' );
-
-    if( !p_demux->psz_demux || strcmp(p_demux->psz_demux, "shout-winamp") )
-    {
+    if( !isDemux( p_demux, "shout-winamp" ) )
         return VLC_EGENERIC;
-    }
-    msg_Dbg( p_demux, "using shoutcast playlist import");
 
-    p_demux->pf_control = Control;
-    p_demux->pf_demux = Demux;
-    p_demux->p_sys = p_sys = malloc( sizeof(demux_sys_t) );
-    if( p_sys == NULL )
-    {
-        msg_Err( p_demux, "out of memory" );
-        return VLC_ENOMEM;
-    }
-
-    p_sys->p_playlist = NULL;
-    p_sys->p_xml = NULL;
-    p_sys->p_xml_reader = NULL;
+    STANDARD_DEMUX_INIT_MSG( "using shoutcast playlist reader" );
+    p_demux->p_sys->p_playlist = NULL;
+    p_demux->p_sys->p_xml = NULL;
+    p_demux->p_sys->p_xml_reader = NULL;
 
     /* Do we want to list adult content ? */
     var_Create( p_demux, "shoutcast-show-adult",
                 VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-    p_sys->b_adult = var_GetBool( p_demux, "shoutcast-show-adult" );
+    p_demux->p_sys->b_adult = var_GetBool( p_demux, "shoutcast-show-adult" );
 
     return VLC_SUCCESS;
 }
@@ -191,7 +174,6 @@ static int DemuxGenre( demux_t *p_demux )
     char *psz_eltname = NULL; /* tag name */
     input_item_t *p_input;
 
-#define FREE(a) if( a ) free( a ); a = NULL;
     while( xml_ReaderRead( p_sys->p_xml_reader ) == 1 )
     {
         int i_type;
@@ -220,8 +202,8 @@ static int DemuxGenre( demux_t *p_demux )
                             xml_ReaderValue( p_sys->p_xml_reader );
                         if( !psz_attrname || !psz_attrvalue )
                         {
-                            FREE(psz_attrname);
-                            FREE(psz_attrvalue);
+                            FREENULL(psz_attrname);
+                            FREENULL(psz_attrvalue);
                             free(psz_eltname);
                             /*FIXME: isn't return a bit too much. what about break*/
                             return -1;
@@ -264,9 +246,9 @@ static int DemuxGenre( demux_t *p_demux )
                              p_sys->p_current, p_sys->p_item_in_category,
                              (p_sys->i_parent_id > 0 ) ? VLC_TRUE: VLC_FALSE,
                              PLAYLIST_APPEND );
-                    FREE( psz_name );
+                    FREENULL( psz_name );
                 }
-                FREE( psz_eltname );
+                FREENULL( psz_eltname );
                 break;
         }
     }
@@ -348,8 +330,8 @@ static int DemuxStation( demux_t *p_demux )
                         if( !psz_attrname || !psz_attrvalue )
                         {
                             free(psz_eltname);
-                            FREE(psz_attrname);
-                            FREE(psz_attrvalue);
+                            FREENULL(psz_attrname);
+                            FREENULL(psz_attrvalue);
                             return -1;
                         }
 
@@ -374,8 +356,8 @@ static int DemuxStation( demux_t *p_demux )
                         if( !psz_attrname || !psz_attrvalue )
                         {
                             free(psz_eltname);
-                            FREE(psz_attrname);
-                            FREE(psz_attrvalue);
+                            FREENULL(psz_attrname);
+                            FREENULL(psz_attrvalue);
                             return -1;
                         }
 
@@ -413,7 +395,6 @@ static int DemuxStation( demux_t *p_demux )
                     ( psz_base || ( psz_rt && psz_load &&
                     ( p_sys->b_adult || strcmp( psz_rt, "NC17" ) ) ) ) )
                 {
-                    playlist_item_t *p_item;
                     char *psz_mrl = NULL;
                     if( psz_rt || psz_load )
                     {
@@ -458,14 +439,14 @@ static int DemuxStation( demux_t *p_demux )
                              (p_sys->i_parent_id > 0 ) ? VLC_TRUE: VLC_FALSE,
                              PLAYLIST_APPEND );
 
-                    FREE( psz_name );
-                    FREE( psz_mt )
-                    FREE( psz_id )
-                    FREE( psz_br )
-                    FREE( psz_genre )
-                    FREE( psz_ct )
-                    FREE( psz_lc )
-                    FREE( psz_rt )
+                    FREENULL( psz_name );
+                    FREENULL( psz_mt )
+                    FREENULL( psz_id )
+                    FREENULL( psz_br )
+                    FREENULL( psz_genre )
+                    FREENULL( psz_ct )
+                    FREENULL( psz_lc )
+                    FREENULL( psz_rt )
                 }
                 free( psz_eltname );
                 break;
@@ -473,7 +454,6 @@ static int DemuxStation( demux_t *p_demux )
     }
     return 0;
 }
-#undef FREE
 
 static int Control( demux_t *p_demux, int i_query, va_list args )
 {