]> git.sesse.net Git - vlc/blobdiff - modules/control/http/http.c
Typo, uninit (CID #127)
[vlc] / modules / control / http / http.c
index 6a0e593de2a4e7c560262c8fd38c1eb08f1f9163..eed8ceabb0166da7e90163170120d62c8df6f22f 100644 (file)
@@ -2,7 +2,6 @@
  * http.c : HTTP/HTTPS Remote control interface
  *****************************************************************************
  * Copyright (C) 2001-2006 the VideoLAN team
- * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *          Laurent Aimar <fenrir@via.ecp.fr>
@@ -27,6 +26,9 @@
 #endif
 
 #include "http.h"
+#include <vlc_plugin.h>
+
+#include <assert.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -62,22 +64,22 @@ static void Close( vlc_object_t * );
 #define CRL_LONGTEXT N_( "HTTP interace Certificates Revocation List file." )
 
 vlc_module_begin();
-    set_shortname( _("HTTP"));
-    set_description( _("HTTP remote control interface") );
+    set_shortname( N_("HTTP"));
+    set_description( N_("HTTP remote control interface") );
     set_category( CAT_INTERFACE );
     set_subcategory( SUBCAT_INTERFACE_MAIN );
-        add_string ( "http-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT, VLC_TRUE );
-        add_string ( "http-src",  NULL, NULL, SRC_TEXT,  SRC_LONGTEXT,  VLC_TRUE );
+        add_string ( "http-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT, true );
+        add_string ( "http-src",  NULL, NULL, SRC_TEXT,  SRC_LONGTEXT,  true );
         add_obsolete_string ( "http-charset" );
 #if defined( HAVE_FORK ) || defined( WIN32 )
-        add_string ( "http-handlers", NULL, NULL, HANDLERS_TEXT, HANDLERS_LONGTEXT, VLC_TRUE );
+        add_string ( "http-handlers", NULL, NULL, HANDLERS_TEXT, HANDLERS_LONGTEXT, true );
 #endif
-        add_bool   ( "http-album-art", VLC_FALSE, NULL, ART_TEXT, ART_LONGTEXT, VLC_TRUE );
+        add_bool   ( "http-album-art", false, NULL, ART_TEXT, ART_LONGTEXT, true );
         set_section( N_("HTTP SSL" ), 0 );
-        add_string ( "http-intf-cert", NULL, NULL, CERT_TEXT, CERT_LONGTEXT, VLC_TRUE );
-        add_string ( "http-intf-key",  NULL, NULL, KEY_TEXT,  KEY_LONGTEXT,  VLC_TRUE );
-        add_string ( "http-intf-ca",   NULL, NULL, CA_TEXT,   CA_LONGTEXT,   VLC_TRUE );
-        add_string ( "http-intf-crl",  NULL, NULL, CRL_TEXT,  CRL_LONGTEXT,  VLC_TRUE );
+        add_string ( "http-intf-cert", NULL, NULL, CERT_TEXT, CERT_LONGTEXT, true );
+        add_string ( "http-intf-key",  NULL, NULL, KEY_TEXT,  KEY_LONGTEXT,  true );
+        add_string ( "http-intf-ca",   NULL, NULL, CA_TEXT,   CA_LONGTEXT,   true );
+        add_string ( "http-intf-crl",  NULL, NULL, CRL_TEXT,  CRL_LONGTEXT,  true );
     set_capability( "interface", 0 );
     set_callbacks( Open, Close );
 vlc_module_end();
@@ -86,7 +88,7 @@ vlc_module_end();
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-int  E_(ArtCallback)( httpd_handler_sys_t *p_args,
+int  ArtCallback( httpd_handler_sys_t *p_args,
                           httpd_handler_t *p_handler, char *_p_url,
                           uint8_t *_p_request, int i_type,
                           uint8_t *_p_in, int i_in,
@@ -99,9 +101,6 @@ int  E_(ArtCallback)( httpd_handler_sys_t *p_args,
 #if !defined(__APPLE__) && !defined(SYS_BEOS) && !defined(WIN32)
 static int DirectoryCheck( const char *psz_dir )
 {
-    DIR           *p_dir;
-
-#ifdef HAVE_SYS_STAT_H
     struct stat   stat_info;
 
     if( ( utf8_stat( psz_dir, &stat_info ) == -1 )
@@ -109,14 +108,6 @@ static int DirectoryCheck( const char *psz_dir )
     {
         return VLC_EGENERIC;
     }
-#endif
-
-    if( ( p_dir = utf8_opendir( psz_dir ) ) == NULL )
-    {
-        return VLC_EGENERIC;
-    }
-    closedir( p_dir );
-
     return VLC_SUCCESS;
 }
 #endif
@@ -184,14 +175,14 @@ static int Open( vlc_object_t *p_this )
 
             p_handler = malloc( sizeof( http_association_t ) );
             p_handler->psz_ext = strdup( psz_ext );
-            psz_options = E_(FirstWord)( psz_program, psz_program );
+            psz_options = FirstWord( psz_program, psz_program );
             p_handler->i_argc = 0;
             p_handler->ppsz_argv = NULL;
             TAB_APPEND( p_handler->i_argc, p_handler->ppsz_argv,
                         strdup( psz_program ) );
             while( psz_options != NULL && *psz_options )
             {
-                char *psz_next = E_(FirstWord)( psz_options, psz_options );
+                char *psz_next = FirstWord( psz_options, psz_options );
                 TAB_APPEND( p_handler->i_argc, p_handler->ppsz_argv,
                             strdup( psz_options ) );
                 psz_options = psz_next;
@@ -201,8 +192,7 @@ static int Open( vlc_object_t *p_this )
             TAB_APPEND( p_sys->i_handlers, p_sys->pp_handlers, p_handler );
         }
     }
-    if( psz_src != NULL )
-        free( psz_src );
+    free( psz_src );
 #endif
 
     /* determine SSL configuration */
@@ -275,11 +265,8 @@ static int Open( vlc_object_t *p_this )
         };
         unsigned i;
 
-        if( psz_src != NULL )
-        {
-            free( psz_src );
-            psz_src = NULL;
-        }
+        free( psz_src );
+        psz_src = NULL;
 
         for( i = 0; ppsz_paths[i] != NULL; i++ )
             if( !DirectoryCheck( ppsz_paths[i] ) )
@@ -303,7 +290,7 @@ static int Open( vlc_object_t *p_this )
         psz_src[strlen( psz_src ) - 1] = '\0';
     }
 
-    E_(ParseDirectory)( p_intf, psz_src, psz_src );
+    ParseDirectory( p_intf, psz_src, psz_src );
     if( p_sys->i_files <= 0 )
     {
         msg_Err( p_intf, "cannot find any file in directory %s", psz_src );
@@ -327,7 +314,7 @@ static int Open( vlc_object_t *p_this )
         /* TODO: use ACL and login/password stuff here too */
         h->p_handler = httpd_HandlerNew( p_sys->p_httpd_host,
                                          "/art", NULL, NULL, NULL,
-                                         E_(ArtCallback), h );
+                                         ArtCallback, h );
         p_sys->p_art_handler = h->p_handler;
     }
 
@@ -350,13 +337,12 @@ static void Close ( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
     intf_sys_t    *p_sys = p_intf->p_sys;
-
     int i;
 
+#ifdef ENABLE_VLM
     if( p_sys->p_vlm )
-    {
         vlm_Delete( p_sys->p_vlm );
-    }
+#endif
     for( i = 0; i < p_sys->i_files; i++ )
     {
         if( p_sys->pp_files[i]->b_handler )
@@ -372,10 +358,7 @@ static void Close ( vlc_object_t *p_this )
         free( p_sys->pp_files[i]->name );
         free( p_sys->pp_files[i] );
     }
-    if( p_sys->pp_files )
-    {
-        free( p_sys->pp_files );
-    }
+    free( p_sys->pp_files );
     for( i = 0; i < p_sys->i_handlers; i++ )
     {
         http_association_t *p_handler = p_sys->pp_handlers[i];
@@ -449,9 +432,9 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
         var_Get( p_sys->p_input, "position", &val);
         sprintf( position, "%d" , (int)((val.f_float) * 100.0));
         var_Get( p_sys->p_input, "time", &val);
-        sprintf( time, I64Fi, (int64_t)val.i_time / I64C(1000000) );
+        sprintf( time, "%"PRIi64, (int64_t)val.i_time / INT64_C(1000000) );
         var_Get( p_sys->p_input, "length", &val);
-        sprintf( length, I64Fi, (int64_t)val.i_time / I64C(1000000) );
+        sprintf( length, "%"PRIi64, (int64_t)val.i_time / INT64_C(1000000) );
 
         var_Get( p_sys->p_input, "state", &val );
         if( val.i_int == PLAYING_S )
@@ -486,25 +469,25 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
     aout_VolumeGet( p_args->p_intf, &i_volume );
     sprintf( volume, "%d", (int)i_volume );
 
-    p_args->vars = E_(mvar_New)( "variables", "" );
-    E_(mvar_AppendNewVar)( p_args->vars, "url_param",
+    p_args->vars = mvar_New( "variables", "" );
+    mvar_AppendNewVar( p_args->vars, "url_param",
                            i_request > 0 ? "1" : "0" );
-    E_(mvar_AppendNewVar)( p_args->vars, "url_value", p_request );
-    E_(mvar_AppendNewVar)( p_args->vars, "version", VLC_Version() );
-    E_(mvar_AppendNewVar)( p_args->vars, "copyright", COPYRIGHT_MESSAGE );
-    E_(mvar_AppendNewVar)( p_args->vars, "vlc_compile_by", VLC_CompileBy() );
-    E_(mvar_AppendNewVar)( p_args->vars, "vlc_compile_host",
+    mvar_AppendNewVar( p_args->vars, "url_value", p_request );
+    mvar_AppendNewVar( p_args->vars, "version", VLC_Version() );
+    mvar_AppendNewVar( p_args->vars, "copyright", COPYRIGHT_MESSAGE );
+    mvar_AppendNewVar( p_args->vars, "vlc_compile_by", VLC_CompileBy() );
+    mvar_AppendNewVar( p_args->vars, "vlc_compile_host",
                            VLC_CompileHost() );
-    E_(mvar_AppendNewVar)( p_args->vars, "vlc_compile_domain",
+    mvar_AppendNewVar( p_args->vars, "vlc_compile_domain",
                            VLC_CompileDomain() );
-    E_(mvar_AppendNewVar)( p_args->vars, "vlc_compiler", VLC_Compiler() );
-    E_(mvar_AppendNewVar)( p_args->vars, "vlc_changeset", VLC_Changeset() );
-    E_(mvar_AppendNewVar)( p_args->vars, "stream_position", position );
-    E_(mvar_AppendNewVar)( p_args->vars, "stream_time", time );
-    E_(mvar_AppendNewVar)( p_args->vars, "stream_length", length );
-    E_(mvar_AppendNewVar)( p_args->vars, "volume", volume );
-    E_(mvar_AppendNewVar)( p_args->vars, "stream_state", state );
-    E_(mvar_AppendNewVar)( p_args->vars, "charset", "UTF-8" );
+    mvar_AppendNewVar( p_args->vars, "vlc_compiler", VLC_Compiler() );
+    mvar_AppendNewVar( p_args->vars, "vlc_changeset", VLC_Changeset() );
+    mvar_AppendNewVar( p_args->vars, "stream_position", position );
+    mvar_AppendNewVar( p_args->vars, "stream_time", time );
+    mvar_AppendNewVar( p_args->vars, "stream_length", length );
+    mvar_AppendNewVar( p_args->vars, "volume", volume );
+    mvar_AppendNewVar( p_args->vars, "stream_state", state );
+    mvar_AppendNewVar( p_args->vars, "charset", "UTF-8" );
 
     /* Stats */
     if( p_sys->p_input )
@@ -518,9 +501,9 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
         {
             vlc_mutex_lock( &p_item->p_stats->lock );
 #define STATS_INT( n ) sprintf( stats, "%d", p_item->p_stats->i_ ## n ); \
-                       E_(mvar_AppendNewVar)( p_args->vars, #n, stats );
+                       mvar_AppendNewVar( p_args->vars, #n, stats );
 #define STATS_FLOAT( n ) sprintf( stats, "%f", p_item->p_stats->f_ ## n ); \
-                       E_(mvar_AppendNewVar)( p_args->vars, #n, stats );
+                       mvar_AppendNewVar( p_args->vars, #n, stats );
             STATS_INT( read_bytes )
             STATS_FLOAT( input_bitrate )
             STATS_INT( demux_read_bytes )
@@ -540,14 +523,14 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
         }
     }
 
-    E_(SSInit)( &p_args->stack );
+    SSInit( &p_args->stack );
 
     /* allocate output */
     *pi_data = i_buffer + 1000;
     dst = *pp_data = malloc( *pi_data );
 
     /* we parse executing all  <vlc /> macros */
-    E_(Execute)( p_args, p_request, i_request, pp_data, pi_data, &dst,
+    Execute( p_args, p_request, i_request, pp_data, pi_data, &dst,
                  &p_buffer[0], &p_buffer[i_buffer] );
 
     *dst     = '\0';
@@ -558,11 +541,11 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
         vlc_object_release( p_sys->p_input );
         p_sys->p_input = NULL;
     }
-    E_(SSClean)( &p_args->stack );
-    E_(mvar_Delete)( p_args->vars );
+    SSClean( &p_args->stack );
+    mvar_Delete( p_args->vars );
 }
 
-int  E_(HttpCallback)( httpd_file_sys_t *p_args,
+int  HttpCallback( httpd_file_sys_t *p_args,
                        httpd_file_t *p_file,
                        uint8_t *_p_request,
                        uint8_t **_pp_data, int *pi_data )
@@ -580,7 +563,7 @@ int  E_(HttpCallback)( httpd_file_sys_t *p_args,
 
     if( !p_args->b_html )
     {
-        E_(FileLoad)( f, pp_data, pi_data );
+        FileLoad( f, pp_data, pi_data );
     }
     else
     {
@@ -588,7 +571,7 @@ int  E_(HttpCallback)( httpd_file_sys_t *p_args,
         char *p_buffer;
 
         /* first we load in a temporary buffer */
-        E_(FileLoad)( f, &p_buffer, &i_buffer );
+        FileLoad( f, &p_buffer, &i_buffer );
 
         ParseExecute( p_args, p_buffer, i_buffer, p_request, pp_data, pi_data );
 
@@ -605,7 +588,7 @@ int  E_(HttpCallback)( httpd_file_sys_t *p_args,
  ****************************************************************************
  * call the external handler and parse vlc macros if Content-Type is HTML
  ****************************************************************************/
-int  E_(HandlerCallback)( httpd_handler_sys_t *p_args,
+int  HandlerCallback( httpd_handler_sys_t *p_args,
                           httpd_handler_t *p_handler, char *_p_url,
                           uint8_t *_p_request, int i_type,
                           uint8_t *_p_in, int i_in,
@@ -616,7 +599,7 @@ int  E_(HandlerCallback)( httpd_handler_sys_t *p_args,
     char *p_url = (char *)_p_url;
     char *p_request = (char *)_p_request;
     char **pp_data = (char **)_pp_data;
-    char *p_in = (char *)p_in;
+    char *p_in = (char *)_p_in;
     int i_request = p_request != NULL ? strlen( p_request ) : 0;
     char *p;
     int i_env = 0;
@@ -794,8 +777,7 @@ int  E_(HandlerCallback)( httpd_handler_sys_t *p_args,
                 NULL );
     TAB_REMOVE( p_args->p_association->i_argc, p_args->p_association->ppsz_argv,
                 psz_file );
-    if( psz_cwd != NULL )
-        free( psz_cwd );
+    free( psz_cwd );
     while( i_env )
         TAB_REMOVE( i_env, ppsz_env, ppsz_env[0] );
 
@@ -833,7 +815,7 @@ int  E_(HandlerCallback)( httpd_handler_sys_t *p_args,
     return VLC_SUCCESS;
 }
 
-int  E_(ArtCallback)( httpd_handler_sys_t *p_args,
+int  ArtCallback( httpd_handler_sys_t *p_args,
                           httpd_handler_t *p_handler, char *_p_url,
                           uint8_t *p_request, int i_type,
                           uint8_t *p_in, int i_in,
@@ -853,12 +835,12 @@ int  E_(ArtCallback)( httpd_handler_sys_t *p_args,
 
     psz_id[0] = '\0';
     if( p_request )
-        E_(ExtractURIValue)( (char *)p_request, "id", psz_id, 15 );
+        ExtractURIValue( (char *)p_request, "id", psz_id, 15 );
     i_id = atoi( psz_id );
     if( i_id )
     {
         playlist_item_t *p_pl_item = playlist_ItemGetById( p_sys->p_playlist,
-                                                           i_id, VLC_FALSE );
+                                                           i_id, false );
         if( p_pl_item )
             p_item = p_pl_item->p_input;
     }
@@ -891,7 +873,7 @@ int  E_(ArtCallback)( httpd_handler_sys_t *p_args,
             return VLC_SUCCESS;
         }
 
-        E_(FileLoad)( f, &p_data, &i_data );
+        FileLoad( f, &p_data, &i_data );
 
         fclose( f );