/*****************************************************************************
* http.c : http mini-server ;)
*****************************************************************************
- * Copyright (C) 2001-2004 VideoLAN
+ * Copyright (C) 2001-2005 VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
#include "vlc_httpd.h"
#include "vlc_vlm.h"
#include "vlc_tls.h"
+#include "charset.h"
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
set_subcategory( SUBCAT_INTERFACE_GENERAL );
add_string ( "http-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT, VLC_TRUE );
add_string ( "http-src", NULL, NULL, SRC_TEXT, SRC_LONGTEXT, VLC_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 );
static void uri_decode_url_encoded( char *psz );
static char *Find_end_MRL( char *psz );
-
-static playlist_item_t * parse_MRL( intf_thread_t * , char *psz );
+static playlist_item_t *parse_MRL( intf_thread_t * , char *psz );
/*****************************************************************************
*
playlist_t *p_playlist;
input_thread_t *p_input;
vlm_t *p_vlm;
+ char *psz_html_type;
};
p_sys->p_input = NULL;
p_sys->p_vlm = NULL;
+ /* determine Content-Type value for HTML pages */
+ vlc_current_charset(&psz_src);
+ if( psz_src == NULL )
+ {
+ free( p_sys );
+ return VLC_ENOMEM;
+ }
+ p_sys->psz_html_type = malloc( 20 + strlen( psz_src ) );
+ if( p_sys->psz_html_type == NULL )
+ {
+ free( p_sys );
+ free( psz_src );
+ return VLC_ENOMEM ;
+ }
+ sprintf( p_sys->psz_html_type, "text/html; charset=%s", psz_src );
+ free( psz_src );
+
+ /* determine SSL configuration */
psz_cert = config_GetPsz( p_intf, "http-intf-cert" );
if ( psz_cert != NULL )
{
if ( p_tls == NULL )
{
msg_Err( p_intf, "TLS initialization error" );
+ free( p_sys->psz_html_type );
free( p_sys );
return VLC_EGENERIC;
}
{
msg_Err( p_intf, "TLS CA error" );
tls_ServerDelete( p_tls );
+ free( p_sys->psz_html_type );
free( p_sys );
return VLC_EGENERIC;
}
{
msg_Err( p_intf, "TLS CRL error" );
tls_ServerDelete( p_tls );
+ free( p_sys->psz_html_type );
free( p_sys );
return VLC_EGENERIC;
}
msg_Err( p_intf, "cannot listen on %s:%d", psz_address, i_port );
if ( p_tls != NULL )
tls_ServerDelete( p_tls );
+
+ free( p_sys->psz_html_type );
free( p_sys );
return VLC_EGENERIC;
}
free( p_sys->pp_files );
}
httpd_HostDelete( p_sys->p_httpd_host );
+ free( p_sys->psz_html_type );
free( p_sys );
return VLC_EGENERIC;
}
}
httpd_HostDelete( p_sys->p_httpd_host );
+ free( p_sys->psz_html_type );
free( p_sys );
}
f->file, f->name );
f->p_file = httpd_FileNew( p_sys->p_httpd_host,
- f->name, f->b_html ? "text/html" : NULL,
+ f->name,
+ f->b_html ? p_sys->psz_html_type : NULL,
user, password,
HttpCallback, f );
char *str = dup;
mvar_t *s = mvar_New( name, "set" );
- fprintf( stderr," mvar_IntegerSetNew: name=`%s' arg=`%s'\n", name, str );
while( str )
{
i_step = 0;
i_match = sscanf( str, "%d:%d:%d", &i_start, &i_stop, &i_step );
- fprintf( stderr," mvar_IntegerSetNew: m=%d start=%d stop=%d step=%d\n", i_match, i_start, i_stop, i_step );
if( i_match == 1 )
{
break;
}
- fprintf( stderr," mvar_IntegerSetNew: adding %d\n", i );
sprintf( value, "%d", i );
mvar_PushNewVar( s, name, value );
char value[512];
int i_child;
mvar_t *itm = mvar_New( name, "set" );
- mvar_t *itm_end = mvar_New( name, "set" );
mvar_AppendNewVar( itm, "name", p_node->input.psz_name );
mvar_AppendNewVar( itm, "uri", p_node->input.psz_name );
playlist_view_t *p_view;
mvar_t *s = mvar_New( name, "set" );
- fprintf( stderr," mvar_PlaylistSetNew: name=`%s'\n", name );
vlc_mutex_lock( &p_pl->object_lock );
mvar_t *s = mvar_New( name, "set" );
int i, j;
- fprintf( stderr," mvar_InfoSetNew: name=`%s'\n", name );
if( p_input == NULL )
{
return s;
httpd_info_t info;
int i;
- fprintf( stderr," mvar_HttpdInfoSetNew: name=`%s'\n", name );
if( !p_httpd->pf_control( p_httpd, i_type, &info, NULL ) )
{
for( i= 0; i < info.i_count; )
}
*p = '\0';
- fprintf( stderr," mvar_FileSetNew: name=`%s' dir=`%s'\n", name, psz_dir );
#ifdef HAVE_SYS_STAT_H
if( stat( psz_dir, &stat_info ) == -1 || !S_ISDIR( stat_info.st_mode ) )
vlm_message_t *msg;
int i;
- /* fprintf( stderr," mvar_VlmSetNew: name=`%s'\n", name ); */
if( vlm == NULL ) return s;
if( vlm_ExecuteCommand( vlm, "show", &msg ) )
set = mvar_New( name, "set" );
mvar_AppendNewVar( set, "name", el->psz_name );
- /* fprintf( stderr, "#### name=%s\n", el->psz_name ); */
-
for( k = 0; k < desc->i_child; k++ )
{
vlm_message_t *ch = desc->child[k];
int c;
mvar_t *n = mvar_New( ch->psz_name, "set" );
- /* fprintf( stderr, " child=%s [%d]\n", ch->psz_name, ch->i_child ); */
for( c = 0; c < ch->i_child; c++ )
{
- mvar_t *in = mvar_New( ch->psz_name, ch->child[c]->psz_name );
- mvar_AppendVar( n, in );
-
- /* fprintf( stderr, " sub=%s\n", ch->child[c]->psz_name );*/
+ if( ch->child[c]->psz_value )
+ {
+ mvar_AppendNewVar( n, ch->child[c]->psz_name, ch->child[c]->psz_value );
+ }
+ else
+ {
+ mvar_t *in = mvar_New( ch->psz_name, ch->child[c]->psz_name );
+ mvar_AppendVar( n, in );
+ }
}
mvar_AppendVar( set, n );
}
else
{
- /* fprintf( stderr, " child=%s->%s\n", ch->psz_name, ch->psz_value ); */
mvar_AppendNewVar( set, ch->psz_name, ch->psz_value );
}
}
p += sprintf( p, " %s", vlm_properties[i] );
}
}
- fprintf( stderr, "vlm_ExecuteCommand: %s\n", psz );
vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
if( vlm_answer->psz_value == NULL ) /* there is no error */
{
* create an item with all information in it, and return the item.
* return NULL if there is an error.
**********************************************************************/
-playlist_item_t * parse_MRL( intf_thread_t *p_intf, char *psz )
+static playlist_item_t *parse_MRL( intf_thread_t *p_intf, char *psz )
{
char **ppsz_options = NULL;
char *mrl;
}
}
- for( i = 0 ; i < i_options ; i++ )
- {
- free( ppsz_options[i] );
- }
- free( ppsz_options );
+ for( i = 0; i < i_options; i++ ) free( ppsz_options[i] );
+ if( i_options ) free( ppsz_options );
return p_item;
}