+ return( VLC_SUCCESS );
+}
+
+static int _httpd_page_admin_get_success( httpd_file_callback_args_t *p_args,
+ uint8_t **pp_data, int *pi_data,
+ char *psz_msg )
+{
+ char *p;
+
+ p = *pp_data = malloc( 8096 );
+
+ p += sprintf( p, "<html>\n" );
+ p += sprintf( p, "<head>\n" );
+ p += sprintf( p, "<title>VideoLAN Client Stream Output</title>\n" );
+ p += sprintf( p, "</head>\n" );
+ p += sprintf( p, "<body>\n" );
+ p += sprintf( p, "<h1><center>VideoLAN Client Stream Output</center></h1>\n" );
+
+ p += sprintf( p, "<p>Success=`%s'</p>", psz_msg );
+
+ p += sprintf( p, "<hr />\n" );
+ p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" );
+ p += sprintf( p, "</body>\n" );
+ p += sprintf( p, "</html>\n" );
+
+ *pi_data = strlen( *pp_data ) + 1;
+
+ return( VLC_SUCCESS );
+}
+
+static int _httpd_page_admin_get_error( httpd_file_callback_args_t *p_args,
+ uint8_t **pp_data, int *pi_data,
+ char *psz_error )
+{
+ char *p;
+
+ p = *pp_data = malloc( 8096 );
+
+ p += sprintf( p, "<html>\n" );
+ p += sprintf( p, "<head>\n" );
+ p += sprintf( p, "<title>VideoLAN Client Stream Output</title>\n" );
+ p += sprintf( p, "</head>\n" );
+ p += sprintf( p, "<body>\n" );
+ p += sprintf( p, "<h1><center>VideoLAN Client Stream Output</center></h1>\n" );
+
+ p += sprintf( p, "<p>Error=`%s'</p>", psz_error );
+
+ p += sprintf( p, "<hr />\n" );
+ p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" );
+ p += sprintf( p, "</body>\n" );
+ p += sprintf( p, "</html>\n" );
+
+ *pi_data = strlen( *pp_data ) + 1;
+
+ return( VLC_SUCCESS );
+}
+
+static void _httpd_uri_extract_value( char *psz_uri, char *psz_name, char *psz_value, int i_value_max )
+{
+ char *p;
+
+ p = strstr( psz_uri, psz_name );
+ if( p )
+ {
+ int i_len;
+
+ p += strlen( psz_name );
+ if( *p == '=' ) p++;
+
+ if( strchr( p, '&' ) )
+ {
+ i_len = strchr( p, '&' ) - p;
+ }
+ else
+ {
+ i_len = strlen( p );
+ }
+ i_len = __MIN( i_value_max - 1, i_len );
+ if( i_len > 0 )
+ {
+ strncpy( psz_value, p, i_len );
+ psz_value[i_len] = '\0';
+ }
+ else
+ {
+ strncpy( psz_value, "", i_value_max );
+ }
+ }
+ else
+ {
+ strncpy( psz_value, "", i_value_max );
+ }
+}
+
+
+static int httpd_page_admin_get( httpd_file_callback_args_t *p_args,
+ uint8_t *p_request, int i_request,
+ uint8_t **pp_data, int *pi_data )
+{
+ httpd_sys_t *p_httpt = (httpd_sys_t*)p_args;
+ httpd_connection_t *p_con;
+ int i;
+
+ if( i_request > 0)
+ {
+ char action[512];
+
+ _httpd_uri_extract_value( p_request, "action", action, 512 );
+
+ if( !strcmp( action, "close_connection" ) )
+ {
+ char id[128];
+ void *i_id;
+
+ _httpd_uri_extract_value( p_request, "id", id, 512 );
+ i_id = (void*)strtol( id, NULL, 0 );
+ msg_Dbg( p_httpt, "requested closing connection id=%s %p", id, i_id );
+ for( p_con = p_httpt->p_first_connection;p_con != NULL; p_con = p_con->p_next )
+ {
+ if( (void*)p_con == i_id )
+ {
+ /* XXX don't free p_con as it could be the one that it is sending ... */
+ p_con->i_state = HTTPD_CONNECTION_TO_BE_CLOSED;
+ return( _httpd_page_admin_get_success( p_args, pp_data, pi_data, "connection closed" ) );
+ }
+ }
+ return( _httpd_page_admin_get_error( p_args, pp_data, pi_data, "invalid id" ) );
+ }
+ else if( !strcmp( action, "ban_ip" ) )
+ {
+ msg_Dbg( p_httpt, "requested banning ip" );
+ return( _httpd_page_admin_get_success( p_args, pp_data, pi_data, "ip banned" ) );
+ }
+ else
+ {
+ return( _httpd_page_admin_get_error( p_args, pp_data, pi_data, action ) );
+ }
+ }
+ else
+ {
+ return( _httpd_page_admin_get_status( p_args, pp_data, pi_data ) );
+ }
+