cvs: /php4 ChangeLog fopen-wrappers.c main.c /php4/ext/standard fsock.c fsock.h
| From: | Andi Gutmans | Date: | Wed, 25 Aug 1999 16:24:14 +0000 |
| Subject: | cvs: /php4 ChangeLog fopen-wrappers.c main.c /php4/ext/standard fsock.c fsock.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-3721@lists.php.net to get a copy of this message | ||
andi Wed Aug 25 12:24:14 1999 EDT
Modified files:
/php4 ChangeLog fopen-wrappers.c main.c
/php4/ext/standard fsock.c fsock.h
Log:
Make fopen() work with URL's in Win32
Index: php4/ChangeLog
diff -u php4/ChangeLog:1.68 php4/ChangeLog:1.69
--- php4/ChangeLog:1.68 Wed Aug 25 08:22:45 1999
+++ php4/ChangeLog Wed Aug 25 12:24:12 1999
@@ -2,6 +2,7 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ?? 1999, Version 4.0 Beta 3
+- Make fopen() work with URL's in Win32 (Andi & Zeev)
- Fix for include_path for Win32 (Andi, Zend library)
- Fixed bug in ISAPI header sending function (Charles)
- Fixed memory leak when using undefined values (Andi & Zeev, Zend library)
Index: php4/fopen-wrappers.c
diff -u php4/fopen-wrappers.c:1.26 php4/fopen-wrappers.c:1.27
--- php4/fopen-wrappers.c:1.26 Mon Aug 2 15:16:34 1999
+++ php4/fopen-wrappers.c Wed Aug 25 12:24:13 1999
@@ -16,7 +16,7 @@
| Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: fopen-wrappers.c,v 1.26 1999/08/02 19:16:34 zeev Exp $ */
+/* $Id: fopen-wrappers.c,v 1.27 1999/08/25 16:24:13 andi Exp $ */
/* Synced with php3 revision 1.66 1999-06-18 [ssb] */
@@ -561,7 +561,7 @@
location[0] = '\0';
if (!SOCK_FEOF(*socketd)) {
/* get response header */
- if (SOCK_FGETS(tmp_line, sizeof(tmp_line), *socketd) != NULL) {
+ if (SOCK_FGETS(tmp_line, sizeof(tmp_line)-1, *socketd) != NULL) {
if (strncmp(tmp_line + 8, " 200 ", 5) == 0) {
reqok = 1;
}
@@ -569,7 +569,7 @@
}
/* Read past HTTP headers */
while (!body && !SOCK_FEOF(*socketd)) {
- if (SOCK_FGETS(tmp_line, sizeof(tmp_line), *socketd) != NULL) {
+ if (SOCK_FGETS(tmp_line, sizeof(tmp_line)-1, *socketd) != NULL) {
char *p = tmp_line;
tmp_line[sizeof(tmp_line)-1] = '\0';
@@ -760,7 +760,7 @@
/* set up the passive connection */
SOCK_WRITE("PASV\n", *socketd);
- while (SOCK_FGETS(tmp_line, sizeof(tmp_line), *socketd) &&
+ while (SOCK_FGETS(tmp_line, sizeof(tmp_line)-1, *socketd) &&
!(isdigit((int) tmp_line[0]) && isdigit((int) tmp_line[1]) &&
isdigit((int) tmp_line[2]) && tmp_line[3] == ' '));
@@ -923,7 +923,7 @@
{
char tmp_line[513];
- while (SOCK_FGETS(tmp_line, sizeof(tmp_line), socketd) &&
+ while (SOCK_FGETS(tmp_line, sizeof(tmp_line)-1, socketd) &&
!(isdigit((int) tmp_line[0]) && isdigit((int) tmp_line[1]) &&
isdigit((int) tmp_line[2]) && tmp_line[3] == ' '));
Index: php4/main.c
diff -u php4/main.c:1.99 php4/main.c:1.100
--- php4/main.c:1.99 Tue Aug 24 19:12:49 1999
+++ php4/main.c Wed Aug 25 12:24:13 1999
@@ -19,7 +19,7 @@
*/
-/* $Id: main.c,v 1.99 1999/08/24 23:12:49 zeev Exp $ */
+/* $Id: main.c,v 1.100 1999/08/25 16:24:13 andi Exp $ */
#include <stdio.h>
@@ -769,6 +769,22 @@
#endif
+#ifdef ZTS
+static void core_globals_ctor(php_core_globals *core_globals)
+{
+ zend_hash_init(&core_globals->ht_fsock_keys, 0, NULL, NULL, 1);
+ zend_hash_init(&core_globals->ht_fsock_socks, 0, NULL, (int (*)(void *))php_msock_destroy,
1);
+}
+
+
+static void core_globals_dtor(php_core_globals *core_globals)
+{
+ zend_hash_destroy(&core_globals->ht_fsock_keys);
+ zend_hash_destroy(&core_globals->ht_fsock_socks);
+}
+#endif
+
+
int php_module_startup(sapi_module_struct *sf)
{
zend_utility_functions zuf;
@@ -809,7 +825,7 @@
#ifdef ZTS
tsrm_set_new_thread_end_handler(php_new_thread_end_handler);
executor_globals = ts_resource(executor_globals_id);
- core_globals_id = ts_allocate_id(sizeof(php_core_globals), NULL, NULL);
+ core_globals_id = ts_allocate_id(sizeof(php_core_globals), core_globals_ctor, core_globals_dtor);
core_globals = ts_resource(core_globals_id);
#endif
EG(error_reporting) = E_ALL & ~E_NOTICE;
Index: php4/ext/standard/fsock.c
diff -u php4/ext/standard/fsock.c:1.21 php4/ext/standard/fsock.c:1.22
--- php4/ext/standard/fsock.c:1.21 Mon Aug 2 15:59:04 1999
+++ php4/ext/standard/fsock.c Wed Aug 25 12:24:13 1999
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: fsock.c,v 1.21 1999/08/02 19:59:04 zeev Exp $ */
+/* $Id: fsock.c,v 1.22 1999/08/25 16:24:13 andi Exp $ */
/* Synced with php3 revision 1.121 1999-06-18 [ssb] */
/* Synced with php3 revision 1.133 1999-07-21 [sas] */
@@ -74,8 +74,8 @@
#define FREE_SOCK if(socketd >= 0) close(socketd); efree(sock); if (key) efree(key)
-#define SEARCHCR \
- p = memchr(READPTR(sock), '\n', MIN(TOREAD(sock), maxlen - 1));
+#define SEARCHCR() \
+ p = memchr(READPTR(sock), '\n', MIN(TOREAD(sock), maxlen));
#if WIN32|WINNT
#define EWOULDBLOCK WSAEWOULDBLOCK
@@ -598,17 +598,22 @@
size_t amount = 0;
SOCK_FIND(sock, socket);
- SEARCHCR;
+ if (maxlen==0) {
+ buf[0] = 0;
+ return buf;
+ }
+
+ SEARCHCR();
if(!p) {
if(sock->is_blocked) {
- while(!p && !sock->eof && TOREAD(sock) < maxlen - 1) {
+ while(!p && !sock->eof && TOREAD(sock) < maxlen) {
_php3_sock_read_internal(sock);
- SEARCHCR;
+ SEARCHCR();
}
} else {
_php3_sock_read(sock);
- SEARCHCR;
+ SEARCHCR();
}
}
@@ -619,7 +624,7 @@
amount = TOREAD(sock);
}
- amount = MIN(amount, maxlen - 1);
+ amount = MIN(amount, maxlen);
if(amount > 0) {
memcpy(buf, READPTR(sock), amount);
@@ -693,14 +698,12 @@
/* }}} */
/* {{{ module start/shutdown functions */
- /* {{{ _php3_sock_destroy */
-#ifndef ZTS
-static int _php3_msock_destroy(int *data)
+ /* {{{ php_msock_destroy */
+int php_msock_destroy(int *data)
{
close(*data);
return 1;
}
-#endif
/* }}} */
/* {{{ php3_minit_fsock */
@@ -708,7 +711,7 @@
{
#ifndef ZTS
zend_hash_init(&PG(ht_fsock_keys), 0, NULL, NULL, 1);
- zend_hash_init(&PG(ht_fsock_socks), 0, NULL, (int (*)(void *))_php3_msock_destroy, 1);
+ zend_hash_init(&PG(ht_fsock_socks), 0, NULL, (int (*)(void *))php_msock_destroy, 1);
#endif
return SUCCESS;
}
Index: php4/ext/standard/fsock.h
diff -u php4/ext/standard/fsock.h:1.12 php4/ext/standard/fsock.h:1.13
--- php4/ext/standard/fsock.h:1.12 Mon Jul 26 16:09:08 1999
+++ php4/ext/standard/fsock.h Wed Aug 25 12:24:14 1999
@@ -27,7 +27,7 @@
| Jim Winstead (jimw@php.net) |
+----------------------------------------------------------------------+
*/
-/* $Id: fsock.h,v 1.12 1999/07/26 20:09:08 andrey Exp $ */
+/* $Id: fsock.h,v 1.13 1999/08/25 16:24:14 andi Exp $ */
/* Synced with php3 revision 1.24 1999-06-18 [ssb] */
@@ -59,16 +59,17 @@
PHP_FUNCTION(fsockopen);
PHP_FUNCTION(pfsockopen);
-extern int lookup_hostname(const char *addr, struct in_addr *in);
-extern char *_php3_sock_fgets(char *buf, size_t maxlen, int socket);
-extern size_t _php3_sock_fread(char *buf, size_t maxlen, int socket);
-extern int _php3_sock_feof(int socket);
-extern int _php3_sock_fgetc(int socket);
-extern int _php3_is_persistent_sock(int);
-extern int _php3_sock_set_blocking(int socket, int mode);
-extern int _php3_sock_destroy(int socket);
-extern int _php3_sock_close(int socket);
+int lookup_hostname(const char *addr, struct in_addr *in);
+char *_php3_sock_fgets(char *buf, size_t maxlen, int socket);
+size_t _php3_sock_fread(char *buf, size_t maxlen, int socket);
+int _php3_sock_feof(int socket);
+int _php3_sock_fgetc(int socket);
+int _php3_is_persistent_sock(int);
+int _php3_sock_set_blocking(int socket, int mode);
+int _php3_sock_destroy(int socket);
+int _php3_sock_close(int socket);
size_t _php3_sock_set_def_chunk_size(size_t size);
+int php_msock_destroy(int *data);
PHPAPI int connect_nonb(int sockfd, struct sockaddr *addr, int addrlen, struct timeval *timeout);