00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _HTTP_H_
00027 #define _HTTP_H_
00028
00029
00030
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>
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
00067 #if defined( WIN32 ) && !defined( UNDER_CE )
00068 # define stat _stati64
00069 #endif
00070
00082
00083
00084
00085 #define MAX_DIR_SIZE 2560
00086 #define STACK_MAX 100 //< Maximum RPN stack size
00087
00088
00089
00090
00091
00092
00099
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
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
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
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
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
00257 void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t *vars,
00258 rpn_stack_t *st, char *exp );
00259
00260
00261 void E_(SSPush) ( rpn_stack_t *, const char * );
00262
00263 char *E_(SSPop) ( rpn_stack_t * );
00264
00265 void E_(SSPushN) ( rpn_stack_t *, int );
00266
00267 int E_(SSPopN) ( rpn_stack_t *, mvar_t * );
00268
00272
00273
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
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
00362
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