]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/b4s.c
Add a bunch of helper functions/macros and start using them:
[vlc] / modules / demux / playlist / b4s.c
index 30fc35bf3db324abb490d04a60e0faf37e6ac98a..e975bb04f8f61d6d07e27c442c24ecbb1ba1d31a 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
 #include <ctype.h>                                              /* isspace() */
 
 #include <vlc/vlc.h>
 #include <vlc/input.h>
 #include <vlc/intf.h>
 
-#include <errno.h>                                                 /* ENOMEM */
 #include "playlist.h"
 #include "vlc_xml.h"
 
@@ -55,36 +53,11 @@ static int IsWhitespace( char *psz_string );
  *****************************************************************************/
 int E_(Import_B4S)( 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( ( psz_ext && !strcasecmp( psz_ext, ".b4s") ) ||
-        ( p_demux->psz_demux && !strcmp(p_demux->psz_demux, "b4s-open") ) )
-    {
-        ;
-    }
-    else
-    {
-        return VLC_EGENERIC;
-    }
-    msg_Dbg( p_demux, "using b4s 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->psz_prefix = E_(FindPrefix)( p_demux );
-    p_sys->p_xml = NULL;
-    p_sys->p_xml_reader = NULL;
-
+    DEMUX_BY_EXTENSION_OR_FORCED_MSG( ".b4s", "b4s-open", 
+                                      "using B4S playlist reader" );
+    p_demux->p_sys->psz_prefix = E_(FindPrefix)( p_demux );
+    p_demux->p_sys->p_xml = NULL;
+    p_demux->p_sys->p_xml_reader = NULL;
     return VLC_SUCCESS;
 }