zend_cgibin_ub_write, /* unbuffered write */
+ php3_error, /* error handler */
+
NULL, /* header handler */
NULL, /* send headers handler */
sapi_cgi_send_header, /* send header handler */
+/*
+ +----------------------------------------------------------------------+
+ | Server API Abstraction Layer |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1998, 1999 SAPI Development Team |
+ +----------------------------------------------------------------------+
+ | This source file is subject to the Zend license, that is bundled |
+ | with this package in the file LICENSE. If you did not receive a |
+ | copy of the Zend license, please mail us at zend@zend.com so we can |
+ | send you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Design: Shane Caraveo <shane@caraveo.com> |
+ | Authors: Andi Gutmans <andi@zend.com> |
+ | Zeev Suraski <zeev@zend.com> |
+ +----------------------------------------------------------------------+
+*/
+
+
#include "SAPI.h"
#ifdef ZTS
#include "TSRM.h"
#endif
+SAPI_API void (*sapi_error)(int error_type, const char *message, ...);
+
+
#ifdef ZTS
SAPI_API int sapi_globals_id;
#else
#endif
-/* A true global (no need for thread safety) */
+/* True globals (no need for thread safety) */
sapi_module_struct sapi_module;
+SAPI_API void (*sapi_error)(int error_type, const char *message, ...);
SAPI_API void sapi_startup(sapi_module_struct *sf)
/* This function expects a *duplicated* string, that was previously emalloc()'d.
* Pointers sent to this functions will be automatically freed by the framework.
*/
-SAPI_API int sapi_add_header(const char *header_line, uint header_line_len)
+SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
{
int retval;
sapi_header_struct sapi_header;
SLS_FETCH();
- sapi_header.header = (char *) header_line;
+ if (SG(headers_sent)) {
+ sapi_module.sapi_error(E_WARNING, "Cannot add header information - headers already sent");
+ efree(header_line);
+ return FAILURE;
+ }
+
+ sapi_header.header = header_line;
sapi_header.header_len = header_line_len;
if (sapi_module.header_handler) {
SAPI_API void sapi_activate(SLS_D);
SAPI_API void sapi_deactivate(SLS_D);
-SAPI_API int sapi_add_header(const char *header_line, uint header_line_len);
+SAPI_API int sapi_add_header(char *header_line, uint header_line_len);
SAPI_API int sapi_send_headers();
-
struct _sapi_module_struct {
char *name;
int (*ub_write)(const char *str, unsigned int str_length);
+ void (*sapi_error)(int type, const char *error_msg, ...);
+
int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers);
int (*send_headers)(sapi_headers_struct *sapi_headers SLS_DC);
void (*send_header)(sapi_header_struct *sapi_header, void *server_context);
#endif
+static int zend_body_write_wrapper(const char *str, uint str_length)
+{
+ return zend_body_write(str, str_length);
+}
+
+
int php_module_startup(sapi_module_struct *sf)
{
zend_utility_functions zuf;
zuf.error_function = php3_error;
zuf.printf_function = php3_printf;
- zuf.write_function = zend_body_write;
+ zuf.write_function = zend_body_write_wrapper;
zuf.fopen_function = php_fopen_wrapper_for_zend;
zuf.message_handler = php_message_handler_for_zend;
zuf.block_interruptions = BLOCK_INTERRUPTIONS;