[PHP4BETA] CVS update: php4
| From: | zeev | Date: | Thu, 06 May 1999 21:58:49 +0000 |
| Subject: | [PHP4BETA] CVS update: php4 | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-678@lists.php.net to get a copy of this message | ||
Date: Thursday May 6, 1999 @ 17:58
Author: zeev
Update of /repository/php4
In directory php:/tmp/cvs-serv10331
Modified Files:
SAPI.c SAPI.h cgi_main.c main.c
Log Message:
* Get output buffering to work again
* Warn about adding header information after headers are sent
* Several fixes
Index: php4/SAPI.c
diff -u php4/SAPI.c:1.9 php4/SAPI.c:1.10
--- php4/SAPI.c:1.9 Wed May 5 17:47:04 1999
+++ php4/SAPI.c Thu May 6 17:58:49 1999
@@ -1,3 +1,21 @@
+/*
+ +----------------------------------------------------------------------+
+ | 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"
@@ -10,6 +28,9 @@
#endif
+SAPI_API void (*sapi_error)(int error_type, const char *message, ...);
+
+
#ifdef ZTS
SAPI_API int sapi_globals_id;
#else
@@ -17,8 +38,9 @@
#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)
@@ -57,13 +79,19 @@
/* 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();
+
+ 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 = (char *) header_line;
+ sapi_header.header = header_line;
sapi_header.header_len = header_line_len;
if (sapi_module.header_handler) {
Index: php4/SAPI.h
diff -u php4/SAPI.h:1.9 php4/SAPI.h:1.10
--- php4/SAPI.h:1.9 Wed May 5 17:47:04 1999
+++ php4/SAPI.h Thu May 6 17:58:49 1999
@@ -76,10 +76,9 @@
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;
@@ -87,6 +86,8 @@
int (*shutdown)(struct _sapi_module_struct *sapi_module);
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);
Index: php4/cgi_main.c
diff -u php4/cgi_main.c:1.7 php4/cgi_main.c:1.8
--- php4/cgi_main.c:1.7 Wed May 5 17:05:43 1999
+++ php4/cgi_main.c Thu May 6 17:58:49 1999
@@ -93,6 +93,8 @@
zend_cgibin_ub_write, /* unbuffered write */
+ php3_error, /* error handler */
+
NULL, /* header handler */
NULL, /* send headers handler */
sapi_cgi_send_header, /* send header handler */
Index: php4/main.c
diff -u php4/main.c:1.47 php4/main.c:1.48
--- php4/main.c:1.47 Wed May 5 17:29:26 1999
+++ php4/main.c Thu May 6 17:58:49 1999
@@ -29,7 +29,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.47 1999/05/05 21:29:26 zeev Exp $ */
+/* $Id: main.c,v 1.48 1999/05/06 21:58:49 zeev Exp $ */
#include <stdio.h>
@@ -758,6 +758,12 @@
#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;
@@ -784,7 +790,7 @@
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;
--
PHP 4 Beta