cvs: php4(PHP_4_3) /ext/standard php_fopen_wrapper.c

From: Date: Tue, 13 May 2003 23:44:35 +0000
Subject: cvs: php4(PHP_4_3) /ext/standard php_fopen_wrapper.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-20877@lists.php.net to get a copy of this message
sas Tue May 13 19:44:35 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard php_fopen_wrapper.c Log: Supply STDIN/OUT/ERR_FILENO directly, instead of opening them through stdio's fdopen. Index: php4/ext/standard/php_fopen_wrapper.c diff -u php4/ext/standard/php_fopen_wrapper.c:1.29.2.2 php4/ext/standard/php_fopen_wrapper.c:1.29.2.3 --- php4/ext/standard/php_fopen_wrapper.c:1.29.2.2 Tue Dec 31 11:35:33 2002 +++ php4/ext/standard/php_fopen_wrapper.c Tue May 13 19:44:35 2003 @@ -17,7 +17,7 @@ | Hartmut Holzgraefe <hholzgra@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: php_fopen_wrapper.c,v 1.29.2.2 2002/12/31 16:35:33 sebastian Exp $ */ +/* $Id: php_fopen_wrapper.c,v 1.29.2.3 2003/05/13 23:44:35 sas Exp $ */ #include <stdio.h> #include <stdlib.h> @@ -123,8 +123,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) { - FILE * fp = NULL; - php_stream * stream = NULL; + int fd = -1; if (!strncasecmp(path, "php://", 6)) path += 6; @@ -138,19 +137,17 @@ } if (!strcasecmp(path, "stdin")) { - fp = fdopen(dup(STDIN_FILENO), mode); + fd = STDIN_FILENO; } else if (!strcasecmp(path, "stdout")) { - fp = fdopen(dup(STDOUT_FILENO), mode); + fd = STDOUT_FILENO; } else if (!strcasecmp(path, "stderr")) { - fp = fdopen(dup(STDERR_FILENO), mode); + fd = STDERR_FILENO; } - if (fp) { - stream = php_stream_fopen_from_file(fp, mode); - if (stream == NULL) - fclose(fp); + if (fd != -1) { + return php_stream_fopen_from_fd(fd, mode, NULL); } - return stream; + return NULL; } static php_stream_wrapper_ops php_stdio_wops = {

« previous php.cvs (#20877) next »