#include "http.h"
#include <vlc_plugin.h>
+#include <vlc_url.h>
#include <assert.h>
#define CRL_TEXT N_( "CRL file" )
#define CRL_LONGTEXT N_( "HTTP interace Certificates Revocation List file." )
-vlc_module_begin();
- 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, true );
- add_string ( "http-src", NULL, NULL, SRC_TEXT, SRC_LONGTEXT, true );
- add_obsolete_string ( "http-charset" );
+vlc_module_begin ()
+ 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, 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, true );
+ add_string ( "http-handlers", NULL, NULL, HANDLERS_TEXT, HANDLERS_LONGTEXT, true )
#endif
- 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, 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();
+ 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, 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 ()
/*****************************************************************************
/* FIXME: we're leaking h */
httpd_handler_sys_t *h = malloc( sizeof( httpd_handler_sys_t ) );
if( !h )
- {
- msg_Err( p_intf, "not enough memory to allocate album art handler" );
goto failed;
- }
h->file.p_intf = p_intf;
h->file.file = NULL;
h->file.name = NULL;
{
state = "opening/connecting";
}
- else if( val.i_int == BUFFERING_S )
- {
- state = "buffering";
- }
else if( val.i_int == PAUSE_S )
{
state = "paused";
state = "stop";
}
- aout_VolumeGet( p_args->p_intf, &i_volume );
+ aout_VolumeGet( p_sys->p_playlist, &i_volume );
sprintf( volume, "%d", (int)i_volume );
p_args->vars = mvar_New( "variables", "" );
mvar_AppendNewVar( p_args->vars, "vlc_compile_domain",
VLC_CompileDomain() );
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 );
int i_env = 0;
char **ppsz_env = NULL;
char *psz_tmp;
- char sep;
size_t i_buffer;
char *p_buffer;
char *psz_cwd, *psz_file = NULL;
int i_ret;
-#ifdef WIN32
- sep = '\\';
-#else
- sep = '/';
-#endif
-
/* Create environment for the CGI */
TAB_APPEND( i_env, ppsz_env, strdup("GATEWAY_INTERFACE=CGI/1.1") );
TAB_APPEND( i_env, ppsz_env, strdup("SERVER_PROTOCOL=HTTP/1.1") );
if( i_request )
{
- asprintf( &psz_tmp, "QUERY_STRING=%s", p_request );
+ if( -1==asprintf( &psz_tmp, "QUERY_STRING=%s", p_request ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
- asprintf( &psz_tmp, "REQUEST_URI=%s?%s", p_url, p_request );
+ if( -1==asprintf( &psz_tmp, "REQUEST_URI=%s?%s", p_url, p_request ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
else
{
- asprintf( &psz_tmp, "REQUEST_URI=%s", p_url );
+ if( -1==asprintf( &psz_tmp, "REQUEST_URI=%s", p_url ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
- asprintf( psz_tmp, "SCRIPT_NAME=%s", p_url );
+ if( -1==asprintf( &psz_tmp, "SCRIPT_NAME=%s", p_url ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
#define p_sys p_args->file.p_intf->p_sys
- asprintf( &psz_tmp, "SERVER_NAME=%s", p_sys->psz_address );
+ if( -1==asprintf( &psz_tmp, "SERVER_NAME=%s", p_sys->psz_address ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
- asprintf( &psz_tmp, "SERVER_PORT=%u", p_sys->i_port );
+ if( -1==asprintf( &psz_tmp, "SERVER_PORT=%u", p_sys->i_port ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
#undef p_sys
p = getenv( "PATH" );
if( p != NULL )
{
- asprintf( &psz_tmp, "PATH=%s", p );
+ if( -1==asprintf( &psz_tmp, "PATH=%s", p ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
p = getenv( "windir" );
if( p != NULL )
{
- asprintf( &psz_tmp, "SYSTEMROOT=%s", p );
+ if( -1==asprintf( &psz_tmp, "SYSTEMROOT=%s", p ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
#endif
if( psz_remote_addr != NULL && *psz_remote_addr )
{
- asprintf( &psz_tmp, "REMOTE_ADDR=%s", psz_remote_addr );
+ if( -1==asprintf( &psz_tmp, "REMOTE_ADDR=%s", psz_remote_addr ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
if( psz_remote_host != NULL && *psz_remote_host )
{
- asprintf( &psz_tmp, "REMOTE_HOST=%s", psz_remote_host );
+ if( -1==asprintf( &psz_tmp, "REMOTE_HOST=%s", psz_remote_host ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
if( end == NULL )
break;
*end = '\0';
- asprintf( &psz_tmp, "CONTENT_TYPE=%s", p );
+ if( -1==asprintf( &psz_tmp, "CONTENT_TYPE=%s", p ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
*end = '\r';
}
if( end == NULL )
break;
*end = '\0';
- asprintf( &psz_tmp, "CONTENT_LENGTH=%s", p );
+ if( -1==asprintf( &psz_tmp, "CONTENT_LENGTH=%s", p ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
*end = '\r';
}
}
}
- psz_file = strrchr( p_args->file.file, sep );
+ psz_file = strrchr( p_args->file.file, DIR_SEP_CHAR );
if( psz_file != NULL )
{
psz_file++;
- asprintf( &psz_tmp, "SCRIPT_FILENAME=%s", psz_file );
+ if( -1==asprintf( &psz_tmp, "SCRIPT_FILENAME=%s", psz_file ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
TAB_APPEND( p_args->p_association->i_argc,
NULL );
psz_tmp = strdup( p_args->file.file );
- p = strrchr( psz_tmp, sep );
+ p = strrchr( psz_tmp, DIR_SEP_CHAR );
if( p != NULL )
{
*p = '\0';
i_id = atoi( psz_id );
if( i_id )
{
+ playlist_Lock( p_sys->p_playlist );
playlist_item_t *p_pl_item = playlist_ItemGetById( p_sys->p_playlist,
- i_id, false );
+ i_id );
if( p_pl_item )
p_item = p_pl_item->p_input;
+ playlist_Unlock( p_sys->p_playlist );
}
else
{
psz_art = input_item_GetArtURL( p_item );
}
- if( psz_art && !strncmp( psz_art, "file://", strlen( "file://" ) ) )
+ if( psz_art && !strncmp( psz_art, "file://", strlen( "file://" ) ) &&
+ decode_URI( psz_art + 7 ) )
{
FILE *f;
char *psz_ext;
i_header_size = asprintf( &psz_header, HEADER, psz_ext, i_data );
#undef HEADER
+ assert( i_header_size != -1 );
+
*pi_data = i_header_size + i_data;
*pp_data = (uint8_t*)malloc( *pi_data );
memcpy( *pp_data, psz_header, i_header_size );