wez Mon Sep 23 14:12:39 2002 EDT Modified files: /php4 php.ini-dist php.ini-recommended /php4/ext/standard basic_functions.h file.c file.h http_fopen_wrapper.c /php4/main network.c streams.c Log: Implement a default_socket_timeout and auto_detect_line_endings ini options. Also move user_agent from BG to FG. Index: php4/php.ini-dist diff -u php4/php.ini-dist:1.154 php4/php.ini-dist:1.155 --- php4/php.ini-dist:1.154 Sat Sep 7 11:43:08 2002 +++ php4/php.ini-dist Mon Sep 23 14:12:38 2002 @@ -215,7 +215,6 @@ max_execution_time = 30 ; Maximum execution time of each script, in seconds memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Error handling and logging ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -468,6 +467,16 @@ ; Define the User-Agent string ; user_agent="PHP" + +; Default timeout for socket based streams (seconds) +default_socket_timeout = 60 + +; If your scripts have to deal with files from Macintosh systems, +; or you are running on a Mac and need to deal with files from +; unix or win32 systems, setting this flag will cause PHP to +; automatically detect the EOL character in those files so that +; fgets() and file() will work regardless of the source of the file. +; auto_detect_line_endings = Off ;;;;;;;;;;;;;;;;;;;;;; Index: php4/php.ini-recommended diff -u php4/php.ini-recommended:1.106 php4/php.ini-recommended:1.107 --- php4/php.ini-recommended:1.106 Sat Sep 7 11:43:08 2002 +++ php4/php.ini-recommended Mon Sep 23 14:12:38 2002 @@ -483,6 +483,17 @@ ; Define the user agent for php to send ;user_agent="PHP" +; Default timeout for socket based streams (seconds) +default_socket_timeout = 60 + +; If your scripts have to deal with files from Macintosh systems, +; or you are running on a Mac and need to deal with files from +; unix or win32 systems, setting this flag will cause PHP to +; automatically detect the EOL character in those files so that +; fgets() and file() will work regardless of the source of the file. +; auto_detect_line_endings = Off + + ;;;;;;;;;;;;;;;;;;;;;; ; Dynamic Extensions ; ;;;;;;;;;;;;;;;;;;;;;; Index: php4/ext/standard/basic_functions.h diff -u php4/ext/standard/basic_functions.h:1.106 php4/ext/standard/basic_functions.h:1.107 --- php4/ext/standard/basic_functions.h:1.106 Sat Sep 7 11:45:29 2002 +++ php4/ext/standard/basic_functions.h Mon Sep 23 14:12:38 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.h,v 1.106 2002/09/07 15:45:29 sterling Exp $ */ +/* $Id: basic_functions.h,v 1.107 2002/09/23 18:12:38 wez Exp $ */ #ifndef BASIC_FUNCTIONS_H #define BASIC_FUNCTIONS_H @@ -141,9 +141,6 @@ HashTable sm_protected_env_vars; char *sm_allowed_env_vars; - - /* file.c */ - char *user_agent; /* pageinfo.c */ long page_uid; Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.255 php4/ext/standard/file.c:1.256 --- php4/ext/standard/file.c:1.255 Sun Sep 22 21:47:01 2002 +++ php4/ext/standard/file.c Mon Sep 23 14:12:38 2002 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.255 2002/09/23 01:47:01 wez Exp $ */ +/* $Id: file.c,v 1.256 2002/09/23 18:12:38 wez Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -157,7 +157,9 @@ PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("user_agent", NULL, PHP_INI_ALL, OnUpdateString, user_agent, php_basic_globals, basic_globals) + STD_PHP_INI_ENTRY("user_agent", NULL, PHP_INI_ALL, OnUpdateString, user_agent, +php_file_globals, file_globals) + STD_PHP_INI_ENTRY("default_socket_timeout", "60", PHP_INI_ALL, OnUpdateInt, +default_socket_timeout, php_file_globals, file_globals) + STD_PHP_INI_ENTRY("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateInt, +auto_detect_line_endings, php_file_globals, file_globals) PHP_INI_END() PHP_MINIT_FUNCTION(file) Index: php4/ext/standard/file.h diff -u php4/ext/standard/file.h:1.62 php4/ext/standard/file.h:1.63 --- php4/ext/standard/file.h:1.62 Tue Aug 20 16:47:47 2002 +++ php4/ext/standard/file.h Mon Sep 23 14:12:38 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.h,v 1.62 2002/08/20 20:47:47 wez Exp $ */ +/* $Id: file.h,v 1.63 2002/09/23 18:12:38 wez Exp $ */ /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */ @@ -115,6 +115,9 @@ int pclose_ret; HashTable ht_persistent_socks; size_t def_chunk_size; + int auto_detect_line_endings; + int default_socket_timeout; + char *user_agent; } php_file_globals; #ifdef ZTS Index: php4/ext/standard/http_fopen_wrapper.c diff -u php4/ext/standard/http_fopen_wrapper.c:1.48 php4/ext/standard/http_fopen_wrapper.c:1.49 --- php4/ext/standard/http_fopen_wrapper.c:1.48 Sun Sep 22 21:47:01 2002 +++ php4/ext/standard/http_fopen_wrapper.c Mon Sep 23 14:12:38 2002 @@ -18,7 +18,7 @@ | Wez Furlong <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: http_fopen_wrapper.c,v 1.48 2002/09/23 01:47:01 wez Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.49 2002/09/23 18:12:38 wez Exp $ */ #include "php.h" #include "php_globals.h" @@ -203,8 +203,8 @@ if (context && php_stream_context_get_option(context, "http", "user_agent", &ua_zval) == SUCCESS) { ua_str = Z_STRVAL_PP(ua_zval); - } else if (BG(user_agent)) { - ua_str = BG(user_agent); + } else if (FG(user_agent)) { + ua_str = FG(user_agent); } if (ua_str) { Index: php4/main/network.c diff -u php4/main/network.c:1.67 php4/main/network.c:1.68 --- php4/main/network.c:1.67 Sun Sep 22 21:47:04 2002 +++ php4/main/network.c Mon Sep 23 14:12:38 2002 @@ -16,11 +16,9 @@ | Streams work by Wez Furlong <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: network.c,v 1.67 2002/09/23 01:47:04 wez Exp $ */ +/* $Id: network.c,v 1.68 2002/09/23 18:12:38 wez Exp $ */ /*#define DEBUG_MAIN_NETWORK 1*/ -#define MAX_CHUNKS_PER_READ 10 -#define SOCKET_DEFAULT_TIMEOUT 60 #include "php.h" @@ -540,7 +538,7 @@ memset(sock, 0, sizeof(php_netstream_data_t)); sock->is_blocked = 1; - sock->timeout.tv_sec = SOCKET_DEFAULT_TIMEOUT; + sock->timeout.tv_sec = FG(default_socket_timeout); sock->socket = socket; stream = php_stream_alloc_rel(&php_stream_socket_ops, sock, persistent, "r+"); Index: php4/main/streams.c diff -u php4/main/streams.c:1.78 php4/main/streams.c:1.79 --- php4/main/streams.c:1.78 Mon Sep 23 11:21:16 2002 +++ php4/main/streams.c Mon Sep 23 14:12:39 2002 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.78 2002/09/23 15:21:16 wez Exp $ */ +/* $Id: streams.c,v 1.79 2002/09/23 18:12:39 wez Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -95,6 +95,10 @@ ret->abstract = abstract; ret->is_persistent = persistent; ret->chunk_size = FG(def_chunk_size); + + if (FG(auto_detect_line_endings)) + ret->flags |= PHP_STREAM_FLAG_DETECT_EOL; + ret->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, ret, php_file_le_stream()); strlcpy(ret->mode, mode, sizeof(ret->mode)); @@ -514,7 +518,7 @@ eol = memchr(readptr, '\n', avail); } - if (eol && ((ptrdiff_t)eol + 1 - (ptrdiff_t)readptr) <= maxlen - 1) { + if (eol && (size_t)((ptrdiff_t)eol + 1 - (ptrdiff_t)readptr) <= maxlen +- 1) { justread = eol + 1 - readptr; } else { eol = NULL;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php