cvs: php4(PHP_4_3) /main main.c php_streams.h streams.c
| From: | Sascha Schumann | Date: | Tue, 13 May 2003 23:09:28 +0000 |
| Subject: | cvs: php4(PHP_4_3) /main main.c php_streams.h streams.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-20875@lists.php.net to get a copy of this message | ||
sas Tue May 13 19:09:28 2003 EDT
Modified files: (Branch: PHP_4_3)
/php4/main main.c php_streams.h streams.c
Log:
Use and supply zend_open func
Index: php4/main/main.c
diff -u php4/main/main.c:1.512.2.31 php4/main/main.c:1.512.2.32
--- php4/main/main.c:1.512.2.31 Tue May 13 18:09:30 2003
+++ php4/main/main.c Tue May 13 19:09:27 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.512.2.31 2003/05/13 22:09:30 iliaa Exp $ */
+/* $Id: main.c,v 1.512.2.32 2003/05/13 23:09:27 sas Exp $ */
/* {{{ includes
*/
@@ -767,6 +767,17 @@
}
/* }}} */
+
+/* {{{ php_open_wrapper_for_zend
+ */
+static zend_bool php_open_wrapper_for_zend(const char *filename, struct _zend_file_handle *fh)
+{
+ TSRMLS_FETCH();
+
+ return php_stream_open_wrapper_as_file_handle((char *)filename, "rb",
ENFORCE_SAFE_MODE|USE_PATH|IGNORE_URL_WIN|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE, fh);
+}
+/* }}} */
+
/* {{{ php_get_configuration_directive_for_zend
*/
static int php_get_configuration_directive_for_zend(char *name, uint name_length, zval *contents)
@@ -1100,6 +1111,7 @@
zuf.printf_function = php_printf;
zuf.write_function = php_body_write_wrapper;
zuf.fopen_function = php_fopen_wrapper_for_zend;
+ zuf.open_function = php_open_wrapper_for_zend;
zuf.message_handler = php_message_handler_for_zend;
zuf.block_interruptions = sapi_module.block_interruptions;
zuf.unblock_interruptions = sapi_module.unblock_interruptions;
Index: php4/main/php_streams.h
diff -u php4/main/php_streams.h:1.61.2.11 php4/main/php_streams.h:1.61.2.12
--- php4/main/php_streams.h:1.61.2.11 Mon May 12 20:18:27 2003
+++ php4/main/php_streams.h Tue May 13 19:09:27 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_streams.h,v 1.61.2.11 2003/05/13 00:18:27 wez Exp $ */
+/* $Id: php_streams.h,v 1.61.2.12 2003/05/13 23:09:27 sas Exp $ */
#ifndef PHP_STREAMS_H
#define PHP_STREAMS_H
@@ -552,6 +552,10 @@
* will most likely fail on systems with fopencookie. */
PHPAPI FILE * _php_stream_open_wrapper_as_file(char * path, char * mode, int options, char
**opened_path STREAMS_DC TSRMLS_DC);
#define php_stream_open_wrapper_as_file(path, mode, options, opened_path)
_php_stream_open_wrapper_as_file((path), (mode), (options), (opened_path) STREAMS_CC TSRMLS_CC)
+
+
+PHPAPI zend_bool _php_stream_open_wrapper_as_file_handle(char * path, char * mode, int options,
zend_file_handle * STREAMS_DC TSRMLS_DC);
+#define php_stream_open_wrapper_as_file_handle(path, mode, options, fh)
_php_stream_open_wrapper_as_file_handle((path), (mode), (options), (fh) STREAMS_CC TSRMLS_CC)
/* for user-space streams */
PHPAPI extern php_stream_ops php_stream_userspace_ops;
Index: php4/main/streams.c
diff -u php4/main/streams.c:1.125.2.54 php4/main/streams.c:1.125.2.55
--- php4/main/streams.c:1.125.2.54 Mon May 12 20:18:27 2003
+++ php4/main/streams.c Tue May 13 19:09:27 2003
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streams.c,v 1.125.2.54 2003/05/13 00:18:27 wez Exp $ */
+/* $Id: streams.c,v 1.125.2.55 2003/05/13 23:09:27 sas Exp $ */
#define _GNU_SOURCE
#include "php.h"
@@ -2701,6 +2701,42 @@
return NULL;
}
return fp;
+}
+/* }}} */
+
+
+
+/* {{{ php_stream_open_wrapper_as_file_handle */
+PHPAPI zend_bool _php_stream_open_wrapper_as_file_handle(char *path, char *mode, int options,
zend_file_handle *fh STREAMS_DC TSRMLS_DC)
+{
+ php_stream *stream = NULL;
+
+ stream = php_stream_open_wrapper_rel(path, mode, options|STREAM_WILL_CAST,
&fh->opened_path);
+
+ if (stream == NULL)
+ return FAILURE;
+
+ if (php_stream_cast(stream, PHP_STREAM_AS_FD | PHP_STREAM_CAST_TRY_HARD
+ | PHP_STREAM_CAST_RELEASE, (void **) &fh->handle.fd,
+ REPORT_ERRORS) == SUCCESS) {
+ if ((options & STREAM_OPEN_FOR_INCLUDE)
+ && php_stream_is(stream, PHP_STREAM_IS_SOCKET)) {
+ fh->type = ZEND_HANDLE_SOCKET_FD;
+ } else {
+ fh->type = ZEND_HANDLE_FD;
+ }
+ } else if (php_stream_cast(stream, PHP_STREAM_AS_STDIO
+ |PHP_STREAM_CAST_TRY_HARD | PHP_STREAM_CAST_RELEASE,
+ (void**) &fh->handle.fp, REPORT_ERRORS) == SUCCESS) {
+ fh->type = ZEND_HANDLE_FP;
+ } else {
+ php_stream_close(stream);
+ if (fh->opened_path)
+ efree(fh->opened_path);
+ fh->opened_path = NULL;
+ return FAILURE;
+ }
+ return SUCCESS;
}
/* }}} */