cvs: php4 /ext/standard head.c head.h
| From: | Frank M. Kromann | Date: | Mon, 03 Dec 2001 05:10:10 +0000 |
| Subject: | cvs: php4 /ext/standard head.c head.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-8396@lists.php.net to get a copy of this message | ||
fmk Mon Dec 3 00:10:10 2001 EDT
Modified files:
/php4/ext/standard head.c head.h
Log:
Make php_setcookie available from shared extensions
Index: php4/ext/standard/head.c
diff -u php4/ext/standard/head.c:1.52 php4/ext/standard/head.c:1.53
--- php4/ext/standard/head.c:1.52 Fri Oct 19 15:48:35 2001
+++ php4/ext/standard/head.c Mon Dec 3 00:10:10 2001
@@ -15,7 +15,7 @@
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
-/* $Id: head.c,v 1.52 2001/10/19 19:48:35 andrei Exp $ */
+/* $Id: head.c,v 1.53 2001/12/03 05:10:10 fmk Exp $ */
#include <stdio.h>
#include "php.h"
@@ -63,26 +63,12 @@
}
-
-/* php_set_cookie(name, value, expires, path, domain, secure) */
-/* {{{ proto bool setcookie(string name [, string value [, int expires [, string path [, string
domain [, bool secure]]]]])
- Send a cookie */
-PHP_FUNCTION(setcookie)
+PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, time_t expires, char
*path, int path_len, char *domain, int domain_len, int secure TSRMLS_DC)
{
char *cookie, *encoded_value = NULL;
- char *name, *value = NULL, *path = NULL, *domain = NULL;
int len=sizeof("Set-Cookie: ");
time_t t;
char *dt;
- time_t expires = 0;
- zend_bool secure = 0;
- int name_len, value_len, path_len, domain_len;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|slssb", &name,
- &name_len, &value, &value_len, &expires, &path,
- &path_len, &domain, &domain_len, &secure) == FAILURE) {
- return;
- }
len += name_len;
if (value) {
@@ -98,6 +84,7 @@
len += domain_len;
}
cookie = emalloc(len + 100);
+
if (value && value_len == 0) {
/*
* MSIE doesn't delete a cookie when you set it to a null value
@@ -134,7 +121,27 @@
strcat(cookie, "; secure");
}
- if (sapi_add_header(cookie, strlen(cookie), 0)==SUCCESS) {
+ return sapi_add_header(cookie, strlen(cookie), 0);
+}
+
+
+/* php_set_cookie(name, value, expires, path, domain, secure) */
+/* {{{ proto bool setcookie(string name [, string value [, int expires [, string path [, string
domain [, bool secure]]]]])
+ Send a cookie */
+PHP_FUNCTION(setcookie)
+{
+ char *name, *value = NULL, *path = NULL, *domain = NULL;
+ time_t expires = 0;
+ zend_bool secure = 0;
+ int name_len, value_len, path_len, domain_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|slssb", &name,
+ &name_len, &value, &value_len, &expires, &path,
+ &path_len, &domain, &domain_len, &secure) == FAILURE) {
+ return;
+ }
+
+ if (php_setcookie(name, name_len, value, value_len, expires, path, path_len, domain, domain_len,
secure TSRMLS_CC) == SUCCESS) {
RETVAL_TRUE;
} else {
RETVAL_FALSE;
Index: php4/ext/standard/head.h
diff -u php4/ext/standard/head.h:1.18 php4/ext/standard/head.h:1.19
--- php4/ext/standard/head.h:1.18 Wed Jun 13 13:04:36 2001
+++ php4/ext/standard/head.h Mon Dec 3 00:10:10 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: head.h,v 1.18 2001/06/13 17:04:36 zeev Exp $ */
+/* $Id: head.h,v 1.19 2001/12/03 05:10:10 fmk Exp $ */
#ifndef HEAD_H
#define HEAD_H
@@ -27,5 +27,6 @@
PHP_FUNCTION(headers_sent);
PHPAPI int php_header(void);
+PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, time_t expires, char
*path, int path_len, char *domain, int domain_len, int secure TSRMLS_DC);
#endif