home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Magazine / HomeAutomation / Apache / include / php / main / SAPI.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-26  |  6.1 KB  |  219 lines

  1. /*
  2.    +----------------------------------------------------------------------+
  3.    | PHP version 4.0                                                      |
  4.    +----------------------------------------------------------------------+
  5.    | Copyright (c) 1997, 1998, 1999, 2000 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 _NEW_SAPI_H
  21. #define _NEW_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. } sapi_header_struct;
  45.  
  46.  
  47. typedef struct {
  48.     zend_llist headers;
  49.     int http_response_code;
  50.     unsigned char send_default_content_type;
  51.     char *http_status_line;
  52. } sapi_headers_struct;
  53.  
  54.  
  55. typedef struct _sapi_post_entry sapi_post_entry;
  56. typedef struct _sapi_module_struct sapi_module_struct;
  57.  
  58.  
  59. extern sapi_module_struct sapi_module;  /* true global */
  60.  
  61.  
  62. typedef struct {
  63.     char *request_method;
  64.     char *query_string;
  65.     char *post_data;
  66.     char *cookie_data;
  67.     uint content_length;
  68.     uint post_data_length;
  69.  
  70.     char *path_translated;
  71.     char *request_uri;
  72.  
  73.     char *content_type;
  74.  
  75.     unsigned char headers_only;
  76.  
  77.     sapi_post_entry *post_entry;
  78.  
  79.     char *content_type_dup;
  80.  
  81.     /* for HTTP authentication */
  82.     char *auth_user;
  83.     char *auth_password;
  84.  
  85.     /* this is necessary for the CGI SAPI module */
  86.     char *argv0;
  87.  
  88.     /* this is necessary for Safe Mode */
  89.     char *current_user;
  90.     int current_user_length;
  91. } sapi_request_info;
  92.  
  93.  
  94. typedef struct {
  95.     void *server_context;
  96.     sapi_request_info request_info;
  97.     sapi_headers_struct sapi_headers;
  98.     int read_post_bytes;
  99.     unsigned char headers_sent;
  100.     struct stat global_stat;
  101.     char *default_mimetype;
  102.     char *default_charset;
  103. } sapi_globals_struct;
  104.  
  105.  
  106. #ifdef ZTS
  107. # define SLS_D    sapi_globals_struct *sapi_globals
  108. # define SLS_DC    , SLS_D
  109. # define SLS_C    sapi_globals
  110. # define SLS_CC , SLS_C
  111. # define SG(v) (sapi_globals->v)
  112. # define SLS_FETCH()    sapi_globals_struct *sapi_globals = ts_resource(sapi_globals_id)
  113. SAPI_API extern int sapi_globals_id;
  114. #else
  115. # define SLS_D    void
  116. # define SLS_DC
  117. # define SLS_C
  118. # define SLS_CC
  119. # define SG(v) (sapi_globals.v)
  120. # define SLS_FETCH()
  121. extern SAPI_API sapi_globals_struct sapi_globals;
  122. #endif
  123.  
  124.  
  125. SAPI_API void sapi_startup(sapi_module_struct *sf);
  126. SAPI_API void sapi_shutdown(void);
  127. SAPI_API void sapi_activate(SLS_D);
  128. SAPI_API void sapi_deactivate(SLS_D);
  129. SAPI_API void sapi_initialize_empty_request(SLS_D);
  130.  
  131. SAPI_API int sapi_add_header(char *header_line, uint header_line_len, zend_bool duplicate);
  132. SAPI_API int sapi_send_headers(void);
  133. SAPI_API void sapi_free_header(sapi_header_struct *sapi_header);
  134. SAPI_API void sapi_handle_post(void *arg SLS_DC);
  135.  
  136. SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entry);
  137. SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry);
  138. SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry);
  139. SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(SLS_D));
  140.  
  141. SAPI_API int sapi_flush(void);
  142. SAPI_API struct stat *sapi_get_stat(void);
  143. SAPI_API char *sapi_getenv(char *name, int name_len);
  144.  
  145. SAPI_API char *sapi_get_default_content_type(SLS_D);
  146. SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header SLS_DC);
  147. SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len SLS_DC);
  148.  
  149. struct _sapi_module_struct {
  150.     char *name;
  151.     char *pretty_name;
  152.  
  153.     int (*startup)(struct _sapi_module_struct *sapi_module);
  154.     int (*shutdown)(struct _sapi_module_struct *sapi_module);
  155.  
  156.     int (*activate)(SLS_D);
  157.     int (*deactivate)(SLS_D);
  158.  
  159.     int (*ub_write)(const char *str, unsigned int str_length);
  160.     void (*flush)(void *server_context);
  161.     struct stat *(*get_stat)(SLS_D);
  162.     char *(*getenv)(char *name, int name_len SLS_DC);
  163.  
  164.     void (*sapi_error)(int type, const char *error_msg, ...);
  165.  
  166.     int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC);
  167.     int (*send_headers)(sapi_headers_struct *sapi_headers SLS_DC);
  168.     void (*send_header)(sapi_header_struct *sapi_header, void *server_context);
  169.  
  170.     int (*read_post)(char *buffer, uint count_bytes SLS_DC);
  171.     char *(*read_cookies)(SLS_D);
  172.  
  173.     void (*register_server_variables)(zval *track_vars_array ELS_DC SLS_DC PLS_DC);
  174.     void (*log_message)(char *message);
  175.  
  176.     void (*block_interruptions)(void);
  177.     void (*unblock_interruptions)(void);
  178.  
  179.     void (*default_post_reader)(SLS_D);
  180. };
  181.  
  182.  
  183. struct _sapi_post_entry {
  184.     char *content_type;
  185.     uint content_type_len;
  186.     void (*post_reader)(SLS_D);
  187.     void (*post_handler)(char *content_type_dup, void *arg SLS_DC);
  188. };
  189.  
  190. /* header_handler() constants */
  191. #define SAPI_HEADER_ADD            (1<<0)
  192. #define SAPI_HEADER_DELETE_ALL    (1<<1)
  193. #define SAPI_HEADER_SEND_NOW    (1<<2)
  194.  
  195.  
  196. #define SAPI_HEADER_SENT_SUCCESSFULLY    1
  197. #define SAPI_HEADER_DO_SEND                2
  198. #define SAPI_HEADER_SEND_FAILED            3
  199.  
  200. #define SAPI_DEFAULT_MIMETYPE        "text/html"
  201. #define SAPI_DEFAULT_CHARSET        ""
  202. #define SAPI_PHP_VERSION_HEADER        "X-Powered-By: PHP/" PHP_VERSION
  203.  
  204. #define SAPI_POST_READER_FUNC(post_reader) void post_reader(SLS_D)
  205. #define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg SLS_DC)
  206.  
  207. SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
  208.  
  209. #define STANDARD_SAPI_MODULE_PROPERTIES NULL
  210.  
  211. #endif /* _NEW_SAPI_H */
  212.  
  213. /*
  214.  * Local variables:
  215.  * tab-width: 4
  216.  * c-basic-offset: 4
  217.  * End:
  218.  */
  219.