home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Online / PHP / include / php / main / SAPI.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-18  |  6.7 KB  |  233 lines

  1. /*
  2.    +----------------------------------------------------------------------+
  3.    | PHP version 4.0                                                      |
  4.    +----------------------------------------------------------------------+
  5.    | Copyright (c) 1997-2001 The PHP Group                                |
  6.    +----------------------------------------------------------------------+
  7.    | This source file is subject to version 2.02 of the PHP license,      |
  8.    | that is bundled with this package in the file LICENSE, and is        |
  9.    | available at through the world-wide-web at                           |
  10.    | http://www.php.net/license/2_02.txt.                                 |
  11.    | If you did not receive a copy of the PHP license and are unable to   |
  12.    | obtain it through the world-wide-web, please send a note to          |
  13.    | license@php.net so we can mail you a copy immediately.               |
  14.    +----------------------------------------------------------------------+
  15.    | Authors:  Zeev Suraski <zeev@zend.com>                               |
  16.    +----------------------------------------------------------------------+
  17. */
  18.  
  19.  
  20. #ifndef SAPI_H
  21. #define SAPI_H
  22.  
  23. #include "zend.h"
  24. #include "zend_llist.h"
  25. #include "zend_operators.h"
  26. #include <sys/stat.h>
  27.  
  28. #define SAPI_POST_BLOCK_SIZE 4000
  29.  
  30. #ifdef PHP_WIN32
  31. #    ifdef SAPI_EXPORTS
  32. #    define SAPI_API __declspec(dllexport) 
  33. #    else
  34. #    define SAPI_API __declspec(dllimport) 
  35. #    endif
  36. #else
  37. #define SAPI_API
  38. #endif
  39.  
  40.  
  41. typedef struct {
  42.     char *header;
  43.     uint header_len;
  44.     zend_bool replace;
  45. } sapi_header_struct;
  46.  
  47.  
  48. typedef struct {
  49.     zend_llist headers;
  50.     int http_response_code;
  51.     unsigned char send_default_content_type;
  52.     char *http_status_line;
  53. } sapi_headers_struct;
  54.  
  55.  
  56. typedef struct _sapi_post_entry sapi_post_entry;
  57. typedef struct _sapi_module_struct sapi_module_struct;
  58.  
  59.  
  60. extern SAPI_API sapi_module_struct sapi_module;  /* true global */
  61.  
  62. /* Some values in this structure needs to be filled in before
  63.  * calling sapi_activate(). We WILL change the `char *' entries,
  64.  * so make sure that you allocate a separate buffer for them
  65.  * and that you free them after sapi_deactivate().
  66.  */
  67.  
  68. typedef struct {
  69.     const char *request_method;
  70.     char *query_string;
  71.     char *post_data;
  72.     char *cookie_data;
  73.     long content_length;
  74.     uint post_data_length;
  75.  
  76.     char *path_translated;
  77.     char *request_uri;
  78.  
  79.     const char *content_type;
  80.  
  81.     zend_bool headers_only;
  82.     zend_bool no_headers;
  83.  
  84.     sapi_post_entry *post_entry;
  85.  
  86.     char *content_type_dup;
  87.  
  88.     /* for HTTP authentication */
  89.     char *auth_user;
  90.     char *auth_password;
  91.  
  92.     /* this is necessary for the CGI SAPI module */
  93.     char *argv0;
  94.  
  95.     /* this is necessary for Safe Mode */
  96.     char *current_user;
  97.     int current_user_length;
  98. } sapi_request_info;
  99.  
  100.  
  101. typedef struct {
  102.     void *server_context;
  103.     sapi_request_info request_info;
  104.     sapi_headers_struct sapi_headers;
  105.     int read_post_bytes;
  106.     unsigned char headers_sent;
  107.     struct stat global_stat;
  108.     char *default_mimetype;
  109.     char *default_charset;
  110.     HashTable *rfc1867_uploaded_files;
  111.     long post_max_size;
  112. } sapi_globals_struct;
  113.  
  114.  
  115. #ifdef ZTS
  116. # define SLS_D    sapi_globals_struct *sapi_globals
  117. # define SLS_DC    , SLS_D
  118. # define SLS_C    sapi_globals
  119. # define SLS_CC , SLS_C
  120. # define SG(v) (sapi_globals->v)
  121. # define SLS_FETCH()    sapi_globals_struct *sapi_globals = ts_resource(sapi_globals_id)
  122. SAPI_API extern int sapi_globals_id;
  123. #else
  124. # define SLS_D    void
  125. # define SLS_DC
  126. # define SLS_C
  127. # define SLS_CC
  128. # define SG(v) (sapi_globals.v)
  129. # define SLS_FETCH()
  130. extern SAPI_API sapi_globals_struct sapi_globals;
  131. #endif
  132.  
  133.  
  134. SAPI_API void sapi_startup(sapi_module_struct *sf);
  135. SAPI_API void sapi_shutdown(void);
  136. SAPI_API void sapi_activate(SLS_D);
  137. SAPI_API void sapi_deactivate(SLS_D);
  138. SAPI_API void sapi_initialize_empty_request(SLS_D);
  139.  
  140. SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace);
  141. #define sapi_add_header(header_line, header_line_len, duplicate) \
  142.     sapi_add_header_ex((header_line), (header_line_len), (duplicate), 1)
  143. SAPI_API int sapi_send_headers(void);
  144. SAPI_API void sapi_free_header(sapi_header_struct *sapi_header);
  145. SAPI_API void sapi_handle_post(void *arg SLS_DC);
  146.  
  147. SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entry);
  148. SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry);
  149. SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry);
  150. SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(SLS_D));
  151.  
  152. SAPI_API int sapi_flush(void);
  153. SAPI_API struct stat *sapi_get_stat(void);
  154. SAPI_API char *sapi_getenv(char *name, size_t name_len);
  155.  
  156. SAPI_API char *sapi_get_default_content_type(SLS_D);
  157. SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header SLS_DC);
  158. SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len SLS_DC);
  159.  
  160. struct _sapi_module_struct {
  161.     char *name;
  162.     char *pretty_name;
  163.  
  164.     int (*startup)(struct _sapi_module_struct *sapi_module);
  165.     int (*shutdown)(struct _sapi_module_struct *sapi_module);
  166.  
  167.     int (*activate)(SLS_D);
  168.     int (*deactivate)(SLS_D);
  169.  
  170.     int (*ub_write)(const char *str, unsigned int str_length);
  171.     void (*flush)(void *server_context);
  172.     struct stat *(*get_stat)(SLS_D);
  173.     char *(*getenv)(char *name, size_t name_len SLS_DC);
  174.  
  175.     void (*sapi_error)(int type, const char *error_msg, ...);
  176.  
  177.     int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC);
  178.     int (*send_headers)(sapi_headers_struct *sapi_headers SLS_DC);
  179.     void (*send_header)(sapi_header_struct *sapi_header, void *server_context);
  180.  
  181.     int (*read_post)(char *buffer, uint count_bytes SLS_DC);
  182.     char *(*read_cookies)(SLS_D);
  183.  
  184.     void (*register_server_variables)(zval *track_vars_array ELS_DC SLS_DC PLS_DC);
  185.     void (*log_message)(char *message);
  186.  
  187.     char *php_ini_path_override;
  188.  
  189.     void (*block_interruptions)(void);
  190.     void (*unblock_interruptions)(void);
  191.  
  192.     void (*default_post_reader)(SLS_D);
  193. };
  194.  
  195.  
  196. struct _sapi_post_entry {
  197.     char *content_type;
  198.     uint content_type_len;
  199.     void (*post_reader)(SLS_D);
  200.     void (*post_handler)(char *content_type_dup, void *arg SLS_DC);
  201. };
  202.  
  203. /* header_handler() constants */
  204. #define SAPI_HEADER_ADD            (1<<0)
  205. #define SAPI_HEADER_DELETE_ALL    (1<<1)
  206. #define SAPI_HEADER_SEND_NOW    (1<<2)
  207.  
  208.  
  209. #define SAPI_HEADER_SENT_SUCCESSFULLY    1
  210. #define SAPI_HEADER_DO_SEND                2
  211. #define SAPI_HEADER_SEND_FAILED            3
  212.  
  213. #define SAPI_DEFAULT_MIMETYPE        "text/html"
  214. #define SAPI_DEFAULT_CHARSET        ""
  215. #define SAPI_PHP_VERSION_HEADER        "X-Powered-By: PHP/" PHP_VERSION
  216.  
  217. #define SAPI_POST_READER_FUNC(post_reader) SAPI_API void post_reader(SLS_D)
  218. #define SAPI_POST_HANDLER_FUNC(post_handler) SAPI_API void post_handler(char *content_type_dup, void *arg SLS_DC)
  219.  
  220. SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
  221. SAPI_POST_READER_FUNC(php_default_post_reader);
  222.  
  223. #define STANDARD_SAPI_MODULE_PROPERTIES NULL
  224.  
  225. #endif /* SAPI_H */
  226.  
  227. /*
  228.  * Local variables:
  229.  * tab-width: 4
  230.  * c-basic-offset: 4
  231.  * End:
  232.  */
  233.