]> granicus.if.org Git - php/commitdiff
Implement a default_socket_timeout and auto_detect_line_endings ini options.
authorWez Furlong <wez@php.net>
Mon, 23 Sep 2002 18:12:39 +0000 (18:12 +0000)
committerWez Furlong <wez@php.net>
Mon, 23 Sep 2002 18:12:39 +0000 (18:12 +0000)
Also move user_agent from BG to FG.

ext/standard/basic_functions.h
ext/standard/file.c
ext/standard/file.h
ext/standard/http_fopen_wrapper.c
main/network.c
main/streams.c
php.ini-dist
php.ini-recommended

index 3135cf0e7a29a0bc0893bb772a659e87d5edcb5b..07bd240fdc9f9f155f04515eb23d730fa724176d 100644 (file)
@@ -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;
index 544cea3b4f1a5e62e3356fd3b080008be0bad11f..12d15a3b4583c1e7ac0cf8ac96d09b721f346476 100644 (file)
@@ -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)
index c2af1656791aa9a55ffb931e613df49895bcdc57..bb561da663525348428d1181ef58eef90d30c9dc 100644 (file)
@@ -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
index 5841cff75ca630985c6ea559a07ff70c191b4468..dc32f6377481536c5dfa9fd57b4b6e0d7b581ca9 100644 (file)
@@ -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) {
index 4f51d6cb1659d88ffd9caae525da51a40f071227..64ecd75cfb44a070bd0ee968f09c4f200668b042 100644 (file)
@@ -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+");
index 8453da767ecc1224919263d832b2b5418e9fd435..ea20c869af040e92efad97937a2f8c9378876fd6 100755 (executable)
@@ -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;
index 83cfc943510227f8567295cc0925a0c0bdfc5db9..fc2211be0c3f3521576161f0762fa95892a5b694 100644 (file)
@@ -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 ;
index 9f4d745f596fae65f8f176351bf3e5e5e52e6430..ecbc97291cce8d3cf7d3f2d195ba7e6e5ea4e4bb 100644 (file)
@@ -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 ;
 ;;;;;;;;;;;;;;;;;;;;;;