You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
6.1 KiB

27 years ago
27 years ago
27 years ago
27 years ago
28 years ago
27 years ago
28 years ago
28 years ago
28 years ago
27 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
27 years ago
28 years ago
28 years ago
28 years ago
27 years ago
27 years ago
27 years ago
  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. #ifndef SAPI_H
  19. #define SAPI_H
  20. #include "zend.h"
  21. #include "zend_llist.h"
  22. #include "zend_operators.h"
  23. #include <sys/stat.h>
  24. #define SAPI_POST_BLOCK_SIZE 4000
  25. #ifdef PHP_WIN32
  26. # ifdef SAPI_EXPORTS
  27. # define SAPI_API __declspec(dllexport)
  28. # else
  29. # define SAPI_API __declspec(dllimport)
  30. # endif
  31. #else
  32. #define SAPI_API
  33. #endif
  34. typedef struct {
  35. char *header;
  36. uint header_len;
  37. } sapi_header_struct;
  38. typedef struct {
  39. zend_llist headers;
  40. int http_response_code;
  41. unsigned char send_default_content_type;
  42. char *http_status_line;
  43. } sapi_headers_struct;
  44. typedef struct _sapi_post_entry sapi_post_entry;
  45. typedef struct _sapi_module_struct sapi_module_struct;
  46. extern sapi_module_struct sapi_module; /* true global */
  47. typedef struct {
  48. char *request_method;
  49. char *query_string;
  50. char *post_data;
  51. char *cookie_data;
  52. uint content_length;
  53. uint post_data_length;
  54. char *path_translated;
  55. char *request_uri;
  56. char *content_type;
  57. unsigned char headers_only;
  58. sapi_post_entry *post_entry;
  59. char *content_type_dup;
  60. /* for HTTP authentication */
  61. char *auth_user;
  62. char *auth_password;
  63. /* this is necessary for the CGI SAPI module */
  64. char *argv0;
  65. /* this is necessary for Safe Mode */
  66. char *current_user;
  67. int current_user_length;
  68. } sapi_request_info;
  69. typedef struct {
  70. void *server_context;
  71. sapi_request_info request_info;
  72. sapi_headers_struct sapi_headers;
  73. int read_post_bytes;
  74. unsigned char headers_sent;
  75. struct stat global_stat;
  76. char *default_mimetype;
  77. char *default_charset;
  78. } sapi_globals_struct;
  79. #ifdef ZTS
  80. # define SLS_D sapi_globals_struct *sapi_globals
  81. # define SLS_DC , SLS_D
  82. # define SLS_C sapi_globals
  83. # define SLS_CC , SLS_C
  84. # define SG(v) (sapi_globals->v)
  85. # define SLS_FETCH() sapi_globals_struct *sapi_globals = ts_resource(sapi_globals_id)
  86. SAPI_API extern int sapi_globals_id;
  87. #else
  88. # define SLS_D void
  89. # define SLS_DC
  90. # define SLS_C
  91. # define SLS_CC
  92. # define SG(v) (sapi_globals.v)
  93. # define SLS_FETCH()
  94. extern SAPI_API sapi_globals_struct sapi_globals;
  95. #endif
  96. SAPI_API void sapi_startup(sapi_module_struct *sf);
  97. SAPI_API void sapi_shutdown(void);
  98. SAPI_API void sapi_activate(SLS_D);
  99. SAPI_API void sapi_deactivate(SLS_D);
  100. SAPI_API void sapi_initialize_empty_request(SLS_D);
  101. SAPI_API int sapi_add_header(char *header_line, uint header_line_len, zend_bool duplicate);
  102. SAPI_API int sapi_send_headers(void);
  103. SAPI_API void sapi_free_header(sapi_header_struct *sapi_header);
  104. SAPI_API void sapi_handle_post(void *arg SLS_DC);
  105. SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entry);
  106. SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry);
  107. SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry);
  108. SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(SLS_D));
  109. SAPI_API int sapi_flush(void);
  110. SAPI_API struct stat *sapi_get_stat(void);
  111. SAPI_API char *sapi_getenv(char *name, int name_len);
  112. SAPI_API char *sapi_get_default_content_type(SLS_D);
  113. SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header SLS_DC);
  114. SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len SLS_DC);
  115. struct _sapi_module_struct {
  116. char *name;
  117. char *pretty_name;
  118. int (*startup)(struct _sapi_module_struct *sapi_module);
  119. int (*shutdown)(struct _sapi_module_struct *sapi_module);
  120. int (*activate)(SLS_D);
  121. int (*deactivate)(SLS_D);
  122. int (*ub_write)(const char *str, unsigned int str_length);
  123. void (*flush)(void *server_context);
  124. struct stat *(*get_stat)(SLS_D);
  125. char *(*getenv)(char *name, int name_len SLS_DC);
  126. void (*sapi_error)(int type, const char *error_msg, ...);
  127. int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC);
  128. int (*send_headers)(sapi_headers_struct *sapi_headers SLS_DC);
  129. void (*send_header)(sapi_header_struct *sapi_header, void *server_context);
  130. int (*read_post)(char *buffer, uint count_bytes SLS_DC);
  131. char *(*read_cookies)(SLS_D);
  132. void (*register_server_variables)(zval *track_vars_array ELS_DC SLS_DC PLS_DC);
  133. void (*log_message)(char *message);
  134. void (*block_interruptions)(void);
  135. void (*unblock_interruptions)(void);
  136. void (*default_post_reader)(SLS_D);
  137. };
  138. struct _sapi_post_entry {
  139. char *content_type;
  140. uint content_type_len;
  141. void (*post_reader)(SLS_D);
  142. void (*post_handler)(char *content_type_dup, void *arg SLS_DC);
  143. };
  144. /* header_handler() constants */
  145. #define SAPI_HEADER_ADD (1<<0)
  146. #define SAPI_HEADER_DELETE_ALL (1<<1)
  147. #define SAPI_HEADER_SEND_NOW (1<<2)
  148. #define SAPI_HEADER_SENT_SUCCESSFULLY 1
  149. #define SAPI_HEADER_DO_SEND 2
  150. #define SAPI_HEADER_SEND_FAILED 3
  151. #define SAPI_DEFAULT_MIMETYPE "text/html"
  152. #define SAPI_DEFAULT_CHARSET ""
  153. #define SAPI_PHP_VERSION_HEADER "X-Powered-By: PHP/" PHP_VERSION
  154. #define SAPI_POST_READER_FUNC(post_reader) void post_reader(SLS_D)
  155. #define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg SLS_DC)
  156. SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
  157. #define STANDARD_SAPI_MODULE_PROPERTIES NULL
  158. #endif /* SAPI_H */
  159. /*
  160. * Local variables:
  161. * tab-width: 4
  162. * c-basic-offset: 4
  163. * End:
  164. */