wez Thu Sep 26 06:14:42 2002 EDT Modified files: /php4/ext/standard basic_functions.c file.c file.h ftp_fopen_wrapper.c http_fopen_wrapper.c php_fopen_wrapper.c /php4/ext/zlib zlib_fopen_wrapper.c /php4/ext/bz2 bz2.c /php4/main php_streams.h Log: Rename file_get_wrapper_data -> file_get_meta_data. It now always returns useful information for all streams. Unified that data with socket_get_status and made socket_get_status an alias for file_get_meta_data. Fix Location header following which was broken in this commit: http://cvs.php.net/diff.php/php4/ext/standard/http_fopen_wrapper.c?r1=1.41&r2=1.42&ty=h
Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.512 php4/ext/standard/basic_functions.c:1.513 --- php4/ext/standard/basic_functions.c:1.512 Wed Sep 25 14:06:05 2002 +++ php4/ext/standard/basic_functions.c Thu Sep 26 06:14:40 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.512 2002/09/25 18:06:05 andrey Exp $ */ +/* $Id: basic_functions.c,v 1.513 2002/09/26 10:14:40 wez Exp $ */ #include "php.h" #include "php_streams.h" @@ -634,14 +634,14 @@ PHP_FE(set_socket_blocking, NULL) PHP_FE(socket_set_blocking, NULL) - PHP_FE(file_get_wrapper_data, NULL) + PHP_FE(file_get_meta_data, + NULL) PHP_FE(file_register_wrapper, NULL) #if HAVE_SYS_TIME_H || defined(PHP_WIN32) PHP_FE(socket_set_timeout, NULL) #endif - PHP_FE(socket_get_status, NULL) + PHP_FALIAS(socket_get_status, file_get_meta_data, + NULL) #if (!defined(PHP_WIN32) && !defined(__BEOS__) && !defined(NETWARE) && HAVE_REALPATH) || defined(ZTS) PHP_FE(realpath, NULL) Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.260 php4/ext/standard/file.c:1.261 --- php4/ext/standard/file.c:1.260 Wed Sep 25 20:27:13 2002 +++ php4/ext/standard/file.c Thu Sep 26 06:14:40 2002 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.260 2002/09/26 00:27:13 hholzgra Exp $ */ +/* $Id: file.c,v 1.261 2002/09/26 10:14:40 wez Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -581,24 +581,59 @@ } /* }}} */ -/* {{{ proto resource file_get_wrapper_data(resource fp) - Retrieves header/meta data from "wrapped" file pointers */ -PHP_FUNCTION(file_get_wrapper_data) +/* {{{ proto resource file_get_meta_data(resource fp) + Retrieves header/meta data from streams/file pointers */ +PHP_FUNCTION(file_get_meta_data) { zval **arg1; php_stream *stream; + zval *newval; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { WRONG_PARAM_COUNT; } php_stream_from_zval(stream, arg1); - if (stream->wrapperdata) { - *return_value = *(stream->wrapperdata); - zval_copy_ctor(return_value); + array_init(return_value); + + if (stream->wrapperdata) { + MAKE_STD_ZVAL(newval); + *newval = *(stream->wrapperdata); + zval_copy_ctor(newval); + + add_assoc_zval(return_value, "wrapper_data", newval); + } + if (stream->wrapper) { + add_assoc_string(return_value, "wrapper_type", (char +*)stream->wrapper->wops->label, 1); + } + add_assoc_string(return_value, "stream_type", (char *)stream->ops->label, 1); + + if (stream->filterhead) { + php_stream_filter *filter; + + MAKE_STD_ZVAL(newval); + array_init(newval); + + for (filter = stream->filterhead; filter != NULL; filter = +filter->next) { + add_next_index_string(newval, (char *)filter->fops->label, 1); + } + + add_assoc_zval(return_value, "filters", newval); + } + + add_assoc_long(return_value, "unread_bytes", stream->writepos - +stream->readpos); + + if (php_stream_is(stream, PHP_STREAM_IS_SOCKET)) { + php_netstream_data_t *sock = PHP_NETSTREAM_DATA_FROM_STREAM(stream); + + add_assoc_bool(return_value, "timed_out", sock->timeout_event); + add_assoc_bool(return_value, "blocked", sock->is_blocked); + add_assoc_bool(return_value, "eof", sock->eof); + } else { + add_assoc_bool(return_value, "timed_out", 0); + add_assoc_bool(return_value, "blocked", 1); + add_assoc_bool(return_value, "eof", php_stream_eof(stream)); } - else - RETURN_FALSE; } /* }}} */ Index: php4/ext/standard/file.h diff -u php4/ext/standard/file.h:1.65 php4/ext/standard/file.h:1.66 --- php4/ext/standard/file.h:1.65 Wed Sep 25 11:25:11 2002 +++ php4/ext/standard/file.h Thu Sep 26 06:14:41 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.h,v 1.65 2002/09/25 15:25:11 wez Exp $ */ +/* $Id: file.h,v 1.66 2002/09/26 10:14:41 wez Exp $ */ /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */ @@ -71,7 +71,7 @@ PHP_NAMED_FUNCTION(php_if_ftruncate); PHP_NAMED_FUNCTION(php_if_fstat); -PHP_FUNCTION(file_get_wrapper_data); +PHP_FUNCTION(file_get_meta_data); PHP_FUNCTION(file_register_wrapper); PHP_FUNCTION(stream_context_create); PHP_FUNCTION(stream_context_set_params); Index: php4/ext/standard/ftp_fopen_wrapper.c diff -u php4/ext/standard/ftp_fopen_wrapper.c:1.34 php4/ext/standard/ftp_fopen_wrapper.c:1.35 --- php4/ext/standard/ftp_fopen_wrapper.c:1.34 Sat Sep 21 14:25:04 2002 +++ php4/ext/standard/ftp_fopen_wrapper.c Thu Sep 26 06:14:41 2002 @@ -17,7 +17,7 @@ | Hartmut Holzgraefe <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.34 2002/09/21 18:25:04 derick Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.35 2002/09/26 10:14:41 wez Exp $ */ #include "php.h" #include "php_globals.h" @@ -120,7 +120,8 @@ php_stream_ftp_stream_close, /* stream_close */ php_stream_ftp_stream_stat, NULL, /* stat_url */ - NULL /* opendir */ + NULL, /* opendir */ + "FTP" }; php_stream_wrapper php_stream_ftp_wrapper = { Index: php4/ext/standard/http_fopen_wrapper.c diff -u php4/ext/standard/http_fopen_wrapper.c:1.49 php4/ext/standard/http_fopen_wrapper.c:1.50 --- php4/ext/standard/http_fopen_wrapper.c:1.49 Mon Sep 23 14:12:38 2002 +++ php4/ext/standard/http_fopen_wrapper.c Thu Sep 26 06:14:41 2002 @@ -18,7 +18,7 @@ | Wez Furlong <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: http_fopen_wrapper.c,v 1.49 2002/09/23 18:12:38 wez Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.50 2002/09/26 10:14:41 wez Exp $ */ #include "php.h" #include "php_globals.h" @@ -246,18 +246,18 @@ MAKE_STD_ZVAL(http_response); response_code = atoi(tmp_line + 9); - if (response_code == 200) { - reqok = 1; - } else { - switch(response_code) { - case 403: - php_stream_notify_error(context, PHP_STREAM_NOTIFY_AUTH_RESULT, - tmp_line, response_code); - break; - default: - php_stream_notify_error(context, PHP_STREAM_NOTIFY_FAILURE, - tmp_line, response_code); - } + switch(response_code) { + case 200: + case 302: + reqok = 1; + break; + case 403: + php_stream_notify_error(context, +PHP_STREAM_NOTIFY_AUTH_RESULT, + tmp_line, response_code); + break; + default: + php_stream_notify_error(context, +PHP_STREAM_NOTIFY_FAILURE, + tmp_line, response_code); } Z_STRLEN_P(http_response) = strlen(tmp_line); @@ -283,7 +283,7 @@ while (!body && !php_stream_eof(stream)) { if (php_stream_gets(stream, http_header_line, HTTP_HEADER_BLOCK_SIZE-1) != NULL) { - char *p; + char *p, *ws; int found_eol = 0; int http_header_line_length; @@ -309,7 +309,7 @@ file_size = atoi(http_header_line + 16); php_stream_notify_file_size(context, file_size, http_header_line, 0); } - + if (http_header_line[0] == '\0') body = 1; else { @@ -327,14 +327,12 @@ } } - if (!reqok) { + if (!reqok || location[0] != '\0') { if (location[0] != '\0') php_stream_notify_info(context, PHP_STREAM_NOTIFY_REDIRECTED, location, 0); php_stream_close(stream); stream = NULL; - zval_dtor(response_header); - FREE_ZVAL(response_header); if (location[0] != '\0') { @@ -373,6 +371,10 @@ FREE_ZVAL(stream->wrapperdata); } } else { + + zval_dtor(response_header); + FREE_ZVAL(response_header); + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP request failed! %s", tmp_line); } } @@ -420,7 +422,8 @@ NULL, /* stream_close */ php_stream_http_stream_stat, NULL, /* stat_url */ - NULL /* opendir */ + NULL, /* opendir */ + "HTTP" }; php_stream_wrapper php_stream_http_wrapper = { Index: php4/ext/standard/php_fopen_wrapper.c diff -u php4/ext/standard/php_fopen_wrapper.c:1.24 php4/ext/standard/php_fopen_wrapper.c:1.25 --- php4/ext/standard/php_fopen_wrapper.c:1.24 Sun Sep 22 21:47:01 2002 +++ php4/ext/standard/php_fopen_wrapper.c Thu Sep 26 06:14:41 2002 @@ -17,7 +17,7 @@ | Hartmut Holzgraefe <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: php_fopen_wrapper.c,v 1.24 2002/09/23 01:47:01 wez Exp $ */ +/* $Id: php_fopen_wrapper.c,v 1.25 2002/09/26 10:14:41 wez Exp $ */ #include <stdio.h> #include <stdlib.h> @@ -95,9 +95,11 @@ static php_stream_wrapper_ops php_stdio_wops = { php_stream_url_wrap_php, - NULL, - NULL, - NULL + NULL, /* close */ + NULL, /* fstat */ + NULL, /* stat */ + NULL, /* opendir */ + "PHP" }; php_stream_wrapper php_stream_php_wrapper = { Index: php4/ext/zlib/zlib_fopen_wrapper.c diff -u php4/ext/zlib/zlib_fopen_wrapper.c:1.29 php4/ext/zlib/zlib_fopen_wrapper.c:1.30 --- php4/ext/zlib/zlib_fopen_wrapper.c:1.29 Sun Sep 22 21:47:01 2002 +++ php4/ext/zlib/zlib_fopen_wrapper.c Thu Sep 26 06:14:41 2002 @@ -16,7 +16,7 @@ | Hartmut Holzgraefe <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: zlib_fopen_wrapper.c,v 1.29 2002/09/23 01:47:01 wez Exp $ */ +/* $Id: zlib_fopen_wrapper.c,v 1.30 2002/09/26 10:14:41 wez Exp $ */ #define IS_EXT_MODULE #define _GNU_SOURCE @@ -131,9 +131,11 @@ static php_stream_wrapper_ops gzip_stream_wops = { php_stream_gzopen, - NULL, - NULL, - NULL + NULL, /* close */ + NULL, /* stat */ + NULL, /* stat_url */ + NULL, /* opendir */ + "ZLIB" }; php_stream_wrapper php_stream_gzip_wrapper = { Index: php4/ext/bz2/bz2.c diff -u php4/ext/bz2/bz2.c:1.59 php4/ext/bz2/bz2.c:1.60 --- php4/ext/bz2/bz2.c:1.59 Wed Sep 25 11:46:43 2002 +++ php4/ext/bz2/bz2.c Thu Sep 26 06:14:41 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: bz2.c,v 1.59 2002/09/25 15:46:43 wez Exp $ */ +/* $Id: bz2.c,v 1.60 2002/09/26 10:14:41 wez Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -212,9 +212,11 @@ static php_stream_wrapper_ops bzip2_stream_wops = { _php_stream_bz2open, - NULL, - NULL, - NULL + NULL, /* close */ + NULL, /* fstat */ + NULL, /* stat */ + NULL, /* opendir */ + "BZip2" }; php_stream_wrapper php_stream_bzip2_wrapper = { Index: php4/main/php_streams.h diff -u php4/main/php_streams.h:1.48 php4/main/php_streams.h:1.49 --- php4/main/php_streams.h:1.48 Wed Sep 25 11:25:12 2002 +++ php4/main/php_streams.h Thu Sep 26 06:14:41 2002 @@ -168,7 +168,8 @@ /* open a "directory" stream */ php_stream *(*dir_opener)(php_stream_wrapper *wrapper, char *filename, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); - + + const char *label; } php_stream_wrapper_ops; struct _php_stream_wrapper {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php