]> git.sesse.net Git - vlc/blobdiff - modules/control/http/mvar.c
playlist: add real functions for locking
[vlc] / modules / control / http / mvar.c
index e1a3024e1c36a7c656ff5f3e5b92fc333ccd397e..c25dd34d29cd6b2c9ae17b55d7003ffdcafd4a27 100644 (file)
@@ -182,7 +182,7 @@ mvar_t *mvar_GetVar( mvar_t *s, const char *name )
     return NULL;
 }
 
-char *mvar_GetValue( mvar_t *v, char *field )
+const char *mvar_GetValue( mvar_t *v, const char *field )
 {
     if( *field == '\0' )
     {
@@ -287,9 +287,9 @@ mvar_t *mvar_PlaylistSetNew( intf_thread_t *p_intf, char *name,
                                  playlist_t *p_pl )
 {
     mvar_t *s = mvar_New( name, "set" );
-    vlc_mutex_lock( &p_pl->object_lock );
+    playlist_Lock( p_pl );
     PlaylistListNode( p_intf, p_pl, p_pl->p_root_category , name, s, 0 );
-    vlc_mutex_unlock( &p_pl->object_lock );
+    playlist_Unlock( p_pl );
     return s;
 }
 
@@ -336,24 +336,23 @@ mvar_t *mvar_ObjectSetNew( intf_thread_t *p_intf, char *psz_name,
                                const char *psz_capability )
 {
     mvar_t *s = mvar_New( psz_name, "set" );
-    int i;
+    size_t i;
 
-    vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE,
-                                        FIND_ANYWHERE );
+    module_t **p_list = module_list_get( NULL );
 
-    for( i = 0; i < p_list->i_count; i++ )
+    for( i = 0; p_list[i]; i++ )
     {
-        module_t *p_parser = (module_t *)p_list->p_values[i].p_object;
-        if( module_IsCapable( p_parser, psz_capability ) )
+        module_t *p_parser = p_list[i];
+        if( module_provides( p_parser, psz_capability ) )
         {
-            mvar_t *sd = mvar_New( "sd", module_GetObjName( p_parser ) );
+            mvar_t *sd = mvar_New( "sd", module_get_object( p_parser ) );
             mvar_AppendNewVar( sd, "name",
-                                   module_GetName( p_parser, true ) );
+                                   module_get_name( p_parser, true ) );
             mvar_AppendVar( s, sd );
         }
     }
 
-    vlc_list_release( p_list );
+    module_list_free( p_list );
 
     return s;
 }
@@ -415,16 +414,14 @@ mvar_t *mvar_InputVarSetNew( intf_thread_t *p_intf, char *name,
 
     for( i = 0; i < val_list.p_list->i_count; i++ )
     {
-        char *psz, psz_int[16];
+        char psz_int[16];
         mvar_t *itm;
 
         switch( i_type & VLC_VAR_TYPE )
         {
         case VLC_VAR_STRING:
             itm = mvar_New( name, "set" );
-            /* FIXME: Memory leak here?? (remove strdup?) */
-            psz = strdup( text_list.p_list->p_values[i].psz_string );
-            mvar_AppendNewVar( itm, "name", psz );
+            mvar_AppendNewVar( itm, "name", text_list.p_list->p_values[i].psz_string );
             mvar_AppendNewVar( itm, "id", val_list.p_list->p_values[i].psz_string );
             snprintf( psz_int, sizeof(psz_int), "%d",
                       ( !strcmp( val.psz_string,
@@ -436,8 +433,7 @@ mvar_t *mvar_InputVarSetNew( intf_thread_t *p_intf, char *name,
 
         case VLC_VAR_INTEGER:
             itm = mvar_New( name, "set" );
-            psz = strdup( text_list.p_list->p_values[i].psz_string );
-            mvar_AppendNewVar( itm, "name", psz );
+            mvar_AppendNewVar( itm, "name", text_list.p_list->p_values[i].psz_string );
             snprintf( psz_int, sizeof(psz_int), "%d",
                       val_list.p_list->p_values[i].i_int );
             mvar_AppendNewVar( itm, "id", psz_int );
@@ -507,15 +503,7 @@ mvar_t *mvar_FileSetNew( intf_thread_t *p_intf, char *name,
     mvar_t *s = mvar_New( name, "set" );
     char        **ppsz_dir_content;
     int           i_dir_content, i;
-    psz_dir = RealPath( p_intf, psz_dir );
-
-#if defined( WIN32 )
-    if( psz_dir[0] != '\0' && (psz_dir[0] != '\\' || psz_dir[1] != '\0') )
-    {
-        free( psz_dir );
-        return s;
-    }
-#endif
+    psz_dir = RealPath( psz_dir );
 
     /* parse psz_src dir */
     if( ( i_dir_content = utf8_scandir( psz_dir, &ppsz_dir_content, Filter,
@@ -579,7 +567,7 @@ mvar_t *mvar_FileSetNew( intf_thread_t *p_intf, char *name,
         else
 #endif
         {
-            char psz_ctime[26];
+            char psz_buf[26];
             char psz_tmp[strlen( psz_dir ) + 1 + strlen( psz_name ) + 1];
 
             sprintf( psz_tmp, "%s"DIR_SEP"%s", psz_dir, psz_name );
@@ -600,13 +588,14 @@ mvar_t *mvar_FileSetNew( intf_thread_t *p_intf, char *name,
                 mvar_AppendNewVar( f, "type", "unknown" );
             }
 
-            sprintf( psz_ctime, "%"PRId64, (int64_t)stat_info.st_size );
-            mvar_AppendNewVar( f, "size", psz_ctime );
+            snprintf( psz_buf, sizeof( psz_buf ), "%"PRId64,
+                      (int64_t)stat_info.st_size );
+            mvar_AppendNewVar( f, "size", psz_buf );
 
             /* FIXME memory leak FIXME */
 #   ifdef HAVE_CTIME_R
-            ctime_r( &stat_info.st_mtime, psz_ctime );
-            mvar_AppendNewVar( f, "date", psz_ctime );
+            ctime_r( &stat_info.st_mtime, psz_buf );
+            mvar_AppendNewVar( f, "date", psz_buf );
 #   else
             mvar_AppendNewVar( f, "date", ctime( &stat_info.st_mtime ) );
 #   endif