]> git.sesse.net Git - vlc/blobdiff - modules/control/http/mvar.c
Remove useless <fcntl.h> inclusions
[vlc] / modules / control / http / mvar.c
index e5252fffba260ba728abe4ecaabf3da79cd508b9..28862cd5e7847671d6d75b925991c00ecfe87e50 100644 (file)
@@ -28,8 +28,9 @@
 
 #include "http.h"
 #include <limits.h>
-
-#include <assert.h>
+#include <errno.h>
+#include <ctype.h>
+#include <fcntl.h>
 
 /* Utility function for scandir */
 static int Filter( const char *foo )
@@ -54,7 +55,7 @@ mvar_t *mvar_New( const char *name, const char *value )
     v->value = strdup( value ? value : "" );
 
     v->i_field = 0;
-    v->field = malloc( sizeof( mvar_t * ) );
+    v->field = xmalloc( sizeof( mvar_t * ) );
     v->field[0] = NULL;
 
     return v;
@@ -77,7 +78,7 @@ void mvar_Delete( mvar_t *v )
 
 void mvar_AppendVar( mvar_t *v, mvar_t *f )
 {
-    v->field = realloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+    v->field = xrealloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
     v->field[v->i_field] = f;
     v->i_field++;
 }
@@ -98,7 +99,7 @@ mvar_t *mvar_Duplicate( const mvar_t *v )
 
 void mvar_PushVar( mvar_t *v, mvar_t *f )
 {
-    v->field = realloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+    v->field = xrealloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
     if( v->i_field > 0 )
     {
         memmove( &v->field[1], &v->field[0], sizeof( mvar_t * ) * v->i_field );
@@ -182,7 +183,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 +288,9 @@ mvar_t *mvar_PlaylistSetNew( intf_thread_t *p_intf, char *name,
                                  playlist_t *p_pl )
 {
     mvar_t *s = mvar_New( name, "set" );
-    vlc_object_lock( p_pl );
+    playlist_Lock( p_pl );
     PlaylistListNode( p_intf, p_pl, p_pl->p_root_category , name, s, 0 );
-    vlc_object_unlock( p_pl );
+    playlist_Unlock( p_pl );
     return s;
 }
 
@@ -335,25 +336,25 @@ mvar_t *mvar_InfoSetNew( char *name, input_thread_t *p_input )
 mvar_t *mvar_ObjectSetNew( intf_thread_t *p_intf, char *psz_name,
                                const char *psz_capability )
 {
+    VLC_UNUSED(p_intf);
     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 +416,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 +435,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 );
@@ -454,8 +452,7 @@ mvar_t *mvar_InputVarSetNew( intf_thread_t *p_intf, char *name,
     }
     /* clean up everything */
     if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
-    var_Change( p_sys->p_input, psz_variable, VLC_VAR_FREELIST, &val_list,
-                &text_list );
+    var_FreeList( &val_list, &text_list );
     return s;
 }