summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2002-09-23 18:12:39 +0000
committerWez Furlong <wez@php.net>2002-09-23 18:12:39 +0000
commitc74b9faca5fbd00b0be1dc0ac9906eb5a85b6ef2 (patch)
treeec2d7fc126798f475afb9e8726343bbeea0f4d2e
parent8dde69004255a6f9696182f0f55423f9d09a2073 (diff)
downloadphp-git-c74b9faca5fbd00b0be1dc0ac9906eb5a85b6ef2.tar.gz
Implement a default_socket_timeout and auto_detect_line_endings ini options.
Also move user_agent from BG to FG.
-rw-r--r--ext/standard/basic_functions.h3
-rw-r--r--ext/standard/file.c4
-rw-r--r--ext/standard/file.h3
-rw-r--r--ext/standard/http_fopen_wrapper.c4
-rw-r--r--main/network.c4
-rwxr-xr-xmain/streams.c6
-rw-r--r--php.ini-dist11
-rw-r--r--php.ini-recommended11
8 files changed, 35 insertions, 11 deletions
diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h
index 3135cf0e7a..07bd240fdc 100644
--- a/ext/standard/basic_functions.h
+++ b/ext/standard/basic_functions.h
@@ -141,9 +141,6 @@ typedef struct {
HashTable sm_protected_env_vars;
char *sm_allowed_env_vars;
-
- /* file.c */
- char *user_agent;
/* pageinfo.c */
long page_uid;
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 544cea3b4f..12d15a3b45 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -157,7 +157,9 @@ static void file_globals_dtor(php_file_globals *file_globals_p TSRMLS_DC)
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)
diff --git a/ext/standard/file.h b/ext/standard/file.h
index c2af165679..bb561da663 100644
--- a/ext/standard/file.h
+++ b/ext/standard/file.h
@@ -115,6 +115,9 @@ typedef struct {
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
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index 5841cff75c..dc32f63774 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -203,8 +203,8 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
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) {
diff --git a/main/network.c b/main/network.c
index 4f51d6cb16..64ecd75cfb 100644
--- a/main/network.c
+++ b/main/network.c
@@ -19,8 +19,6 @@
/* $Id$ */
/*#define DEBUG_MAIN_NETWORK 1*/
-#define MAX_CHUNKS_PER_READ 10
-#define SOCKET_DEFAULT_TIMEOUT 60
#include "php.h"
@@ -540,7 +538,7 @@ PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, int persistent
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+");
diff --git a/main/streams.c b/main/streams.c
index 8453da767e..ea20c869af 100755
--- a/main/streams.c
+++ b/main/streams.c
@@ -95,6 +95,10 @@ fprintf(stderr, "stream_alloc: %s:%p\n", ops->label, ret);
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 @@ PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRML
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;
diff --git a/php.ini-dist b/php.ini-dist
index 83cfc94351..fc2211be0c 100644
--- a/php.ini-dist
+++ b/php.ini-dist
@@ -215,7 +215,6 @@ expose_php = On
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 ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -469,6 +468,16 @@ allow_url_fopen = On
; 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
+
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
diff --git a/php.ini-recommended b/php.ini-recommended
index 9f4d745f59..ecbc97291c 100644
--- a/php.ini-recommended
+++ b/php.ini-recommended
@@ -483,6 +483,17 @@ allow_url_fopen = On
; 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 ;
;;;;;;;;;;;;;;;;;;;;;;