Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

http.h

00001 /*****************************************************************************
00002  * http.h: Headers for the HTTP interface
00003  *****************************************************************************
00004  * Copyright (C) 2001-2005 the VideoLAN team
00005  * $Id: http.c 12225 2005-08-18 10:01:30Z massiot $
00006  *
00007  * Authors: Gildas Bazin <[email protected]>
00008  *          Laurent Aimar <[email protected]>
00009  *          Christophe Massiot <[email protected]>
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00024  *****************************************************************************/
00025 
00026 #ifndef _HTTP_H_
00027 #define _HTTP_H_
00028 
00029 /*****************************************************************************
00030  * Preamble
00031  *****************************************************************************/
00032 #include <stdlib.h>
00033 #include <ctype.h>
00034 #include <vlc/vlc.h>
00035 #include <vlc/intf.h>
00036 
00037 #include <vlc/aout.h>
00038 #include <vlc/vout.h> /* for fullscreen */
00039 
00040 #include "vlc_httpd.h"
00041 #include "vlc_vlm.h"
00042 #include "vlc_tls.h"
00043 #include "vlc_acl.h"
00044 #include "charset.h"
00045 
00046 #ifdef HAVE_SYS_STAT_H
00047 #   include <sys/stat.h>
00048 #endif
00049 #ifdef HAVE_ERRNO_H
00050 #   include <errno.h>
00051 #endif
00052 #ifdef HAVE_FCNTL_H
00053 #   include <fcntl.h>
00054 #endif
00055 
00056 #ifdef HAVE_UNISTD_H
00057 #   include <unistd.h>
00058 #elif defined( WIN32 ) && !defined( UNDER_CE )
00059 #   include <io.h>
00060 #endif
00061 
00062 #ifdef HAVE_DIRENT_H
00063 #   include <dirent.h>
00064 #endif
00065 
00066 /* stat() support for large files on win32 */
00067 #if defined( WIN32 ) && !defined( UNDER_CE )
00068 #   define stat _stati64
00069 #endif
00070 
00082 /*****************************************************************************
00083  * Local defines
00084  *****************************************************************************/
00085 #define MAX_DIR_SIZE 2560
00086 #define STACK_MAX 100        //< Maximum RPN stack size
00087 
00088 
00089 /*****************************************************************************
00090  * Utility functions
00091  *****************************************************************************/
00092 
00099 /* File and directory functions */
00100 
00102 int E_(ParseDirectory)( intf_thread_t *p_intf, char *psz_root,
00103                         char *psz_dir );
00105 int E_(FileLoad)( FILE *f, char **pp_data, int *pi_data );
00107 char *E_(FileToUrl)( char *name, vlc_bool_t *pb_index );
00109 char *E_(RealPath)( intf_thread_t *p_intf, const char *psz_src );
00110 
00111 /* Locale handling functions */
00112 
00114 char *E_(FromUTF8)( intf_thread_t *p_intf, char *psz_utf8 );
00116 char *E_(ToUTF8)( intf_thread_t *p_intf, char *psz_local );
00117 
00120 void E_(HandleSeek)( intf_thread_t *p_intf, char *p_value );
00121 
00122 /* URI Handling functions */
00123 
00126 char *E_(ExtractURIValue)( char *psz_uri, const char *psz_name,
00127                              char *psz_value, int i_value_max );
00129 int E_(TestURIParam)( char *psz_uri, const char *psz_name );
00131 void E_(DecodeEncodedURI)( char *psz );
00132 
00134 playlist_item_t *E_(MRLParse)( intf_thread_t *, char *psz, char *psz_name );
00135 
00137 char *E_(FirstWord)( char *psz, char *new );
00138 
00141 /****************************************************************************
00142  * Variable handling functions
00143  ****************************************************************************/
00144 
00159 typedef struct mvar_s
00160 {
00161     char *name;                 
00162     char *value;                
00163 
00164     int           i_field;      
00165     struct mvar_s **field;      
00166 } mvar_t;
00167 
00168 
00170 mvar_t  *E_(mvar_New)( const char *name, const char *value );
00172 void     E_(mvar_Delete)( mvar_t *v );
00174 void     E_(mvar_AppendVar)( mvar_t *v, mvar_t *f );
00176 mvar_t  *E_(mvar_Duplicate)( const mvar_t *v );
00178 void     E_(mvar_PushVar)( mvar_t *v, mvar_t *f );
00180 void     E_(mvar_RemoveVar)( mvar_t *v, mvar_t *f );
00182 mvar_t  *E_(mvar_GetVar)( mvar_t *s, const char *name );
00184 char    *E_(mvar_GetValue)( mvar_t *v, char *field );
00187 void     E_(mvar_PushNewVar)( mvar_t *vars, const char *name,
00188                               const char *value );
00191 void     E_(mvar_AppendNewVar)( mvar_t *vars, const char *name,
00192                                 const char *value );
00205 mvar_t *E_(mvar_IntegerSetNew)( const char *name, const char *arg );
00206 
00208 mvar_t *E_(mvar_PlaylistSetNew)( intf_thread_t *p_intf, char *name,
00209                                  playlist_t *p_pl );
00212 mvar_t *E_(mvar_InfoSetNew)( intf_thread_t *p_intf, char *name,
00213                              input_thread_t *p_input );
00215 mvar_t *E_(mvar_InputVarSetNew)( intf_thread_t *p_intf, char *name,
00216                                  input_thread_t *p_input,
00217                                  const char *psz_variable );
00220 mvar_t *E_(mvar_FileSetNew)( intf_thread_t *p_intf, char *name,
00221                              char *psz_dir );
00223 mvar_t *E_(mvar_VlmSetNew)( char *name, vlm_t *vlm );
00224 
00226 void E_(PlaylistListNode)( intf_thread_t *p_intf, playlist_t *p_pl,
00227                            playlist_item_t *p_node, char *name, mvar_t *s,
00228                            int i_depth );
00229 
00232 /*****************************************************************************
00233  * RPN Evaluator
00234  *****************************************************************************/
00235 
00246 typedef struct
00247 {
00248     char *stack[STACK_MAX];
00249     int  i_stack;
00250 } rpn_stack_t;
00251 
00253 void E_(SSInit)( rpn_stack_t * );
00255 void E_(SSClean)( rpn_stack_t * );
00256 /* Evaluate and execute the RPN Stack */
00257 void  E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t  *vars,
00258                        rpn_stack_t *st, char *exp );
00259 
00260 /* Push an operand on top of the RPN stack */
00261 void E_(SSPush)  ( rpn_stack_t *, const char * );
00262 /* Remove the first operand from the RPN Stack */
00263 char *E_(SSPop)  ( rpn_stack_t * );
00264 /* Pushes an operand at a given position in the stack */
00265 void E_(SSPushN) ( rpn_stack_t *, int );
00266 /* Removes an operand at the given position in the stack */
00267 int  E_(SSPopN)  ( rpn_stack_t *, mvar_t  * );
00268 
00272 /****************************************************************************
00273  * Macro handling (<vlc ... stuff)
00274  ****************************************************************************/
00275 
00289 typedef struct
00290 {
00291     char *id;           
00292     char *param1;       
00293     char *param2;       
00294 } macro_t;
00295 
00297 int E_(MacroParse)( macro_t *m, char *psz_src );
00299 void E_(MacroClean)( macro_t *m );
00300 
00303 int E_(StrToMacroType)( char *name );
00305 void E_(MacroDo)( httpd_file_sys_t *p_args, macro_t *m,
00306                   char *p_request, int i_request, char **pp_data,
00307                   int *pi_data, char **pp_dst );
00309 char *E_(MacroSearch)( char *src, char *end,
00310                    int i_mvlc, vlc_bool_t b_after );
00311 
00313 void E_(Execute)( httpd_file_sys_t *p_args,
00314                   char *p_request, int i_request,
00315                   char **pp_data, int *pi_data,
00316                   char **pp_dst,
00317                   char *_src, char *_end );
00318 
00327 struct httpd_file_sys_t
00328 {
00329     intf_thread_t    *p_intf;
00330     httpd_file_t     *p_file;
00331     httpd_redirect_t *p_redir;
00332     httpd_redirect_t *p_redir2;
00333 
00334     char          *file;
00335     char          *name;
00336 
00337     vlc_bool_t    b_html, b_handler;
00338 
00339     /* inited for each access */
00340     rpn_stack_t   stack;
00341     mvar_t        *vars;
00342 };
00343 
00347 typedef struct http_association_t
00348 {
00349     char                *psz_ext;
00350     int                 i_argc;
00351     char                **ppsz_argv;
00352 } http_association_t;
00353 
00357 struct httpd_handler_sys_t
00358 {
00359     httpd_file_sys_t file;
00360 
00361     /* HACK ALERT: this is added below so that casting httpd_handler_sys_t
00362      * to httpd_file_sys_t works */
00363     httpd_handler_t  *p_handler;
00364     http_association_t *p_association;
00365 };
00366 
00370 struct intf_sys_t
00371 {
00372     httpd_host_t        *p_httpd_host;
00373 
00374     int                 i_files;
00375     httpd_file_sys_t    **pp_files;
00376 
00377     int                 i_handlers;
00378     http_association_t  **pp_handlers;
00379 
00380     playlist_t          *p_playlist;
00381     input_thread_t      *p_input;
00382     vlm_t               *p_vlm;
00383     char                *psz_html_type;
00384     vlc_iconv_t         iconv_from_utf8, iconv_to_utf8;
00385 
00386     char                *psz_address;
00387     unsigned short      i_port;
00388 };
00389 
00391 int E_(HttpCallback)( httpd_file_sys_t *p_args,
00392                       httpd_file_t *,
00393                       uint8_t *p_request,
00394                       uint8_t **pp_data, int *pi_data );
00396 int  E_(HandlerCallback)( httpd_handler_sys_t *p_args,
00397                           httpd_handler_t *p_handler, uint8_t *_p_url,
00398                           uint8_t *_p_request, int i_type,
00399                           uint8_t *_p_in, int i_in,
00400                           char *psz_remote_addr, char *psz_remote_host,
00401                           uint8_t **_pp_data, int *pi_data );
00404 #endif
00405 

Generated on Tue Dec 20 10:14:30 2005 for vlc-0.8.4a by  doxygen 1.4.2