summaryrefslogtreecommitdiff
path: root/ext/standard/php_fopen_wrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/php_fopen_wrapper.c')
-rw-r--r--ext/standard/php_fopen_wrapper.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c
index 64e05e0c3..9140121c3 100644
--- a/ext/standard/php_fopen_wrapper.c
+++ b/ext/standard/php_fopen_wrapper.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
| Hartmut Holzgraefe <hholzgra@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_fopen_wrapper.c,v 1.45.2.4.2.9 2007/12/31 07:20:13 sebastian Exp $ */
+/* $Id: php_fopen_wrapper.c,v 1.45.2.4.2.13 2008/12/31 11:17:45 sebastian Exp $ */
#include <stdio.h>
#include <stdlib.h>
@@ -48,17 +48,11 @@ static int php_stream_output_close(php_stream *stream, int close_handle TSRMLS_D
return 0;
}
-static int php_stream_output_flush(php_stream *stream TSRMLS_DC)
-{
- sapi_flush(TSRMLS_C);
- return 0;
-}
-
php_stream_ops php_stream_output_ops = {
php_stream_output_write,
php_stream_output_read,
php_stream_output_close,
- php_stream_output_flush,
+ NULL, /* flush */
"Output",
NULL, /* seek */
NULL, /* cast */
@@ -176,11 +170,21 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch
return NULL;
}
}
- return php_stream_temp_create(TEMP_STREAM_DEFAULT, max_memory);
+ if (strpbrk(mode, "wa+")) {
+ mode_rw = TEMP_STREAM_DEFAULT;
+ } else {
+ mode_rw = TEMP_STREAM_READONLY;
+ }
+ return php_stream_temp_create(mode_rw, max_memory);
}
if (!strcasecmp(path, "memory")) {
- return php_stream_memory_create(TEMP_STREAM_DEFAULT);
+ if (strpbrk(mode, "wa+")) {
+ mode_rw = TEMP_STREAM_DEFAULT;
+ } else {
+ mode_rw = TEMP_STREAM_READONLY;
+ }
+ return php_stream_memory_create(mode_rw);
}
if (!strcasecmp(path, "output")) {
@@ -290,9 +294,23 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch
return NULL;
}
+#if defined(S_IFSOCK) && !defined(WIN32) && !defined(__BEOS__)
+ do {
+ struct stat st;
+ memset(&st, 0, sizeof(st));
+ if (fstat(fd, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
+ stream = php_stream_sock_open_from_socket(fd, NULL);
+ if (stream) {
+ stream->ops = &php_stream_socket_ops;
+ return stream;
+ }
+ }
+ } while (0);
+#endif
+
if (file) {
stream = php_stream_fopen_from_file(file, mode);
- } else {
+ } else {
stream = php_stream_fopen_from_fd(fd, mode, NULL);
if (stream == NULL) {
close(fd);