cvs: /php4 SAPI.c SAPI.h main.c /php4/ext/session session.c /php4/ext/standard head.c head.h
| From: | Zeev Suraski | Date: | Fri, 28 Apr 2000 13:03:43 +0000 |
| Subject: | cvs: /php4 SAPI.c SAPI.h main.c /php4/ext/session session.c /php4/ext/standard head.c head.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-14146@lists.php.net to get a copy of this message | ||
zeev Fri Apr 28 06:03:43 2000 EDT
Modified files:
/php4 SAPI.c SAPI.h main.c
/php4/ext/session session.c
/php4/ext/standard head.c head.h
Log:
- Fix an invalid trick (it was valid when header() was using
zend_get_parameters(), but it became invalid when someone switched it
to zend_get_parameters_ex(), and I decided to remove it anyway).
- Remove a redundant function call
Index: php4/SAPI.c
diff -u php4/SAPI.c:1.72 php4/SAPI.c:1.73
--- php4/SAPI.c:1.72 Thu Apr 20 09:38:08 2000
+++ php4/SAPI.c Fri Apr 28 06:03:12 2000
@@ -345,7 +345,7 @@
/* 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(char *header_line, uint header_line_len)
+SAPI_API int sapi_add_header(char *header_line, uint header_line_len, zend_bool duplicate)
{
int retval, free_header = 0;
sapi_header_struct sapi_header;
@@ -362,10 +362,15 @@
} else {
sapi_module.sapi_error(E_WARNING, "Cannot add header information - headers already
sent");
}
- efree(header_line);
+ if (!duplicate) {
+ efree(header_line);
+ }
return FAILURE;
}
+ if (duplicate) {
+ header_line = estrndup(header_line, header_line_len);
+ }
sapi_header.header = header_line;
sapi_header.header_len = header_line_len;
Index: php4/SAPI.h
diff -u php4/SAPI.h:1.45 php4/SAPI.h:1.46
--- php4/SAPI.h:1.45 Fri Mar 31 17:11:39 2000
+++ php4/SAPI.h Fri Apr 28 06:03:12 2000
@@ -128,7 +128,7 @@
SAPI_API void sapi_deactivate(SLS_D);
SAPI_API void sapi_initialize_empty_request(SLS_D);
-SAPI_API int sapi_add_header(char *header_line, uint header_line_len);
+SAPI_API int sapi_add_header(char *header_line, uint header_line_len, zend_bool duplicate);
SAPI_API int sapi_send_headers(void);
SAPI_API void sapi_free_header(sapi_header_struct *sapi_header);
SAPI_API void sapi_handle_post(void *arg SLS_DC);
Index: php4/main.c
diff -u php4/main.c:1.240 php4/main.c:1.241
--- php4/main.c:1.240 Fri Apr 28 04:09:57 2000
+++ php4/main.c Fri Apr 28 06:03:12 2000
@@ -19,7 +19,7 @@
*/
-/* $Id: main.c,v 1.240 2000/04/28 11:09:57 thies Exp $ */
+/* $Id: main.c,v 1.241 2000/04/28 13:03:12 zeev Exp $ */
#include <stdio.h>
@@ -656,7 +656,7 @@
php_set_timeout(PG(max_execution_time));
if (PG(expose_php)) {
- sapi_add_header(estrdup(SAPI_PHP_VERSION_HEADER), sizeof(SAPI_PHP_VERSION_HEADER) - 1);
+ sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1);
}
if (PG(output_buffering)) {
@@ -1131,21 +1131,15 @@
if (SG(request_info).query_string && SG(request_info).query_string[0]=='='
&& PG(expose_php)) {
if (!strcmp(SG(request_info).query_string+1, PHP_LOGO_GUID)) {
- char *header_line = estrndup(CONTEXT_TYPE_IMAGE_GIF, sizeof(CONTEXT_TYPE_IMAGE_GIF));
-
- php4i_add_header_information(header_line, sizeof(CONTEXT_TYPE_IMAGE_GIF)-1);
+ sapi_add_header(CONTEXT_TYPE_IMAGE_GIF, sizeof(CONTEXT_TYPE_IMAGE_GIF)-1, 1);
PHPWRITE(php_logo, sizeof(php_logo));
return;
} else if (!strcmp(SG(request_info).query_string+1, PHP_EGG_LOGO_GUID)) {
- char *header_line = estrndup(CONTEXT_TYPE_IMAGE_GIF, sizeof(CONTEXT_TYPE_IMAGE_GIF));
-
- php4i_add_header_information(header_line, sizeof(CONTEXT_TYPE_IMAGE_GIF)-1);
+ sapi_add_header(CONTEXT_TYPE_IMAGE_GIF, sizeof(CONTEXT_TYPE_IMAGE_GIF)-1, 1);
PHPWRITE(php_egg_logo, sizeof(php_egg_logo));
return;
} else if (!strcmp(SG(request_info).query_string+1, ZEND_LOGO_GUID)) {
- char *header_line = estrndup(CONTEXT_TYPE_IMAGE_GIF, sizeof(CONTEXT_TYPE_IMAGE_GIF));
-
- php4i_add_header_information(header_line, sizeof(CONTEXT_TYPE_IMAGE_GIF)-1);
+ sapi_add_header(CONTEXT_TYPE_IMAGE_GIF, sizeof(CONTEXT_TYPE_IMAGE_GIF)-1, 1);
PHPWRITE(zend_logo, sizeof(zend_logo));
return;
} else if (!strcmp(SG(request_info).query_string+1,
"PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000")) {
Index: php4/ext/session/session.c
diff -u php4/ext/session/session.c:1.128 php4/ext/session/session.c:1.129
--- php4/ext/session/session.c:1.128 Thu Apr 20 10:24:00 2000
+++ php4/ext/session/session.c Fri Apr 28 06:03:12 2000
@@ -128,7 +128,7 @@
#define CACHE_LIMITER_FUNC(name) static void _php_cache_limiter_##name(PSLS_D)
#define CACHE_LIMITER(name) { #name, _php_cache_limiter_##name },
-#define ADD_COOKIE(a) sapi_add_header(estrdup(a), strlen(a));
+#define ADD_COOKIE(a) sapi_add_header(a, strlen(a), 1);
#define STR_CAT(P,S,I) {\
pval *__p = (P);\
@@ -638,7 +638,7 @@
strcat(cookie, PS(cookie_domain));
}
- sapi_add_header(cookie, len);
+ sapi_add_header(cookie, len, 0);
}
static ps_module *_php_find_ps_module(char *name PSLS_DC)
Index: php4/ext/standard/head.c
diff -u php4/ext/standard/head.c:1.30 php4/ext/standard/head.c:1.31
--- php4/ext/standard/head.c:1.30 Mon Mar 6 12:37:11 2000
+++ php4/ext/standard/head.c Fri Apr 28 06:03:13 2000
@@ -15,7 +15,7 @@
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
-/* $Id: head.c,v 1.30 2000/03/06 20:37:11 ssb Exp $ */
+/* $Id: head.c,v 1.31 2000/04/28 13:03:13 zeev Exp $ */
#include <stdio.h>
#include "php.h"
@@ -58,12 +58,6 @@
}
-void php4i_add_header_information(char *header_information, uint header_length)
-{
- sapi_add_header(header_information, header_length);
-}
-
-
/* Implementation of the language Header() function */
PHP_FUNCTION(Header)
{
@@ -73,9 +67,7 @@
WRONG_PARAM_COUNT;
}
convert_to_string_ex(arg1);
- php4i_add_header_information((*arg1)->value.str.val,(*arg1)->value.str.len);
- (*arg1)->type = IS_LONG; /* change arg1's type so that it doesn't get freed */
- (*arg1)->value.lval = 0;
+ sapi_add_header(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1), 1);
}
@@ -224,9 +216,8 @@
if (secure) {
strcat(cookie, "; secure");
}
-
- if (sapi_add_header(cookie, strlen(cookie))==SUCCESS) {
+ if (sapi_add_header(cookie, strlen(cookie), 0)==SUCCESS) {
RETVAL_TRUE;
} else {
RETVAL_FALSE;
Index: php4/ext/standard/head.h
diff -u php4/ext/standard/head.h:1.13 php4/ext/standard/head.h:1.14
--- php4/ext/standard/head.h:1.13 Mon Mar 6 12:37:11 2000
+++ php4/ext/standard/head.h Fri Apr 28 06:03:13 2000
@@ -54,8 +54,6 @@
PHP_FUNCTION(setcookie);
PHP_FUNCTION(headers_sent);
-void php4i_add_header_information(char *header_information, uint header_length);
-
PHPAPI int php_header(void);
int php_headers_unsent(void);