]> git.sesse.net Git - vlc/blobdiff - modules/control/http/http.c
video_chroma: a few SSE2 fixes
[vlc] / modules / control / http / http.c
index cdaef567d914bab3c6a939cdfc559a88be940fce..a20ce8f809b53e1c49c0647c2d84008a2037370b 100644 (file)
@@ -124,10 +124,9 @@ static int Open( vlc_object_t *p_this )
                   *psz_crl = NULL;
     int           i_port       = 0;
     char          *psz_src;
-    char          psz_tmp[10];
 
     var_Create(p_intf->p_libvlc, "http-host", VLC_VAR_STRING );
-    psz_address=var_GetString(p_intf->p_libvlc, "http-host");
+    psz_address = var_GetString(p_intf->p_libvlc, "http-host");
     if( !psz_address || !*psz_address )
     {
         psz_address = config_GetPsz( p_intf, "http-host" );
@@ -263,10 +262,6 @@ static int Open( vlc_object_t *p_this )
             i_port= 8080;
     }
 
-    /* Ugly hack to allow to run several HTTP servers on different ports. */
-    sprintf( psz_tmp, "%s:%d", psz_address, i_port + 1 );
-    var_SetString( p_intf->p_libvlc, "http-host", psz_tmp );
-
     msg_Dbg( p_intf, "base %s:%d", psz_address, i_port );
 
     p_sys->p_httpd_host = httpd_TLSHostNew( VLC_OBJECT(p_intf), psz_address,
@@ -280,6 +275,14 @@ static int Open( vlc_object_t *p_this )
         free( p_sys );
         return VLC_EGENERIC;
     }
+    else
+    {
+        char psz_tmp[NI_MAXHOST + 6];
+
+        /* Ugly hack to run several HTTP servers on different ports */
+        snprintf( psz_tmp, sizeof (psz_tmp), "%s:%d", psz_address, i_port + 1 );
+        var_SetString( p_intf->p_libvlc, "http-host", psz_tmp );
+    }
 
     p_sys->i_files  = 0;
     p_sys->pp_files = NULL;
@@ -287,14 +290,10 @@ static int Open( vlc_object_t *p_this )
 #if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
     if ( ( psz_src = config_GetPsz( p_intf, "http-src" )) == NULL )
     {
-        char * psz_vlcpath = p_intf->p_libvlc->psz_vlcpath;
-        psz_src = malloc( strlen(psz_vlcpath) + strlen("/share/http" ) + 1 );
+        char * psz_vlcpath = config_GetDataDir( p_intf );
+        psz_src = malloc( strlen(psz_vlcpath) + strlen("/http" ) + 1 );
         if( !psz_src ) return VLC_ENOMEM;
-#if defined(WIN32)
         sprintf( psz_src, "%s/http", psz_vlcpath );
-#else
-        sprintf( psz_src, "%s/share/http", psz_vlcpath );
-#endif
     }
 #else
     psz_src = config_GetPsz( p_intf, "http-src" );
@@ -431,7 +430,7 @@ static void Run( intf_thread_t *p_intf )
 {
     intf_sys_t     *p_sys = p_intf->p_sys;
 
-    while( !p_intf->b_die )
+    while( !intf_ShouldDie( p_intf ) )
     {
         /* get the playlist */
         if( p_sys->p_playlist == NULL )
@@ -518,9 +517,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, "%d" , (int)(val.i_time / 1000000) );
+        sprintf( time, I64Fi, (int64_t)val.i_time / I64C(1000000) );
         var_Get( p_sys->p_input, "length", &val);
-        sprintf( length, "%d" , (int)(val.i_time / 1000000) );
+        sprintf( length, I64Fi, (int64_t)val.i_time / I64C(1000000) );
 
         var_Get( p_sys->p_input, "state", &val );
         if( val.i_int == PLAYING_S )
@@ -582,7 +581,7 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
 #define p_sys p_args->p_intf->p_sys
     if( p_sys->p_input )
     {
-        input_item_t *p_item = p_sys->p_input->input.p_item;
+        input_item_t *p_item = input_GetItem( p_sys->p_input );
         if( p_item )
         {
             vlc_mutex_lock( &p_item->p_stats->lock );
@@ -636,8 +635,7 @@ int  E_(HttpCallback)( httpd_file_sys_t *p_args,
     char **pp_data = (char **)_pp_data;
     FILE *f;
 
-    /* FIXME: do we need character encoding translation here? */
-    if( ( f = fopen( p_args->file, "r" ) ) == NULL )
+    if( ( f = utf8_fopen( p_args->file, "r" ) ) == NULL )
     {
         Callback404( p_args, pp_data, pi_data );
         return VLC_SUCCESS;