kalle Fri Jan 23 15:48:59 2009 UTC
Added files:
/php-src/win32 sockets.c sockets.h
Removed files:
/php-src/ext/sockets php_sockets_win.c php_sockets_win.h
Modified files:
/php-src/ext/sockets config.w32 php_sockets.h sockets.c
/php-src/ext/standard streamsfuncs.c streamsfuncs.h
/php-src/ext/standard/tests/streams stream_socket_pair.phpt
/php-src/win32/build config.w32 config.w32.h.in
Log:
Windows support for stream_socket_pair(), by moving the socketpair()
implementation from ext/sockets to win32/
http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/config.w32?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/sockets/config.w32
diff -u php-src/ext/sockets/config.w32:1.1 php-src/ext/sockets/config.w32:1.2
--- php-src/ext/sockets/config.w32:1.1 Fri Dec 19 17:00:12 2003
+++ php-src/ext/sockets/config.w32 Fri Jan 23 15:48:53 2009
@@ -1,4 +1,4 @@
-// $Id: config.w32,v 1.1 2003/12/19 17:00:12 wez Exp $
+// $Id: config.w32,v 1.2 2009/01/23 15:48:53 kalle Exp $
// vim:ft=javascript
ARG_ENABLE("sockets", "SOCKETS support", "no");
@@ -6,7 +6,7 @@
if (PHP_SOCKETS != "no") {
if (CHECK_LIB("ws2_32.lib", "sockets", PHP_SOCKETS)) {
- EXTENSION('sockets', 'sockets.c php_sockets_win.c');
+ EXTENSION('sockets', 'sockets.c');
AC_DEFINE('HAVE_SOCKETS', 1);
} else {
WARNING("sockets not enabled; libraries and headers not found");
http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/php_sockets.h?r1=1.46&r2=1.47&diff_format=u
Index: php-src/ext/sockets/php_sockets.h
diff -u php-src/ext/sockets/php_sockets.h:1.46
php-src/ext/sockets/php_sockets.h:1.47
--- php-src/ext/sockets/php_sockets.h:1.46 Thu Jan 1 05:22:54 2009
+++ php-src/ext/sockets/php_sockets.h Fri Jan 23 15:48:54 2009
@@ -22,7 +22,7 @@
#ifndef PHP_SOCKETS_H
#define PHP_SOCKETS_H
-/* $Id: php_sockets.h,v 1.46 2009/01/01 05:22:54 kalle Exp $ */
+/* $Id: php_sockets.h,v 1.47 2009/01/23 15:48:54 kalle Exp $ */
#if HAVE_SOCKETS
@@ -43,7 +43,7 @@
PHP_FUNCTION(socket_select);
PHP_FUNCTION(socket_create_listen);
-#if defined(HAVE_SOCKETPAIR) || defined(PHP_WIN32)
+#ifdef HAVE_SOCKETPAIR
PHP_FUNCTION(socket_create_pair);
#endif
PHP_FUNCTION(socket_accept);
@@ -84,6 +84,13 @@
int blocking;
} php_socket;
+#ifdef PHP_WIN32
+struct sockaddr_un {
+ short sun_family;
+ char sun_path[108];
+};
+#endif
+
/* Prototypes */
#ifdef ilia_0 /* not needed, only causes a compiler warning */
static int php_open_listen_sock(php_socket **php_sock, int port, int backlog
TSRMLS_DC);
http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.207&r2=1.208&diff_format=u
Index: php-src/ext/sockets/sockets.c
diff -u php-src/ext/sockets/sockets.c:1.207 php-src/ext/sockets/sockets.c:1.208
--- php-src/ext/sockets/sockets.c:1.207 Thu Jan 1 05:22:54 2009
+++ php-src/ext/sockets/sockets.c Fri Jan 23 15:48:55 2009
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sockets.c,v 1.207 2009/01/01 05:22:54 kalle Exp $ */
+/* $Id: sockets.c,v 1.208 2009/01/23 15:48:55 kalle Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -39,8 +39,17 @@
# include <windows.h>
# include <Ws2tcpip.h>
# include "php_sockets.h"
-# include "php_sockets_win.h"
+# include "win32/sockets.h"
# define IS_INVALID_SOCKET(a) (a->bsd_socket == INVALID_SOCKET)
+# define EPROTONOSUPPORT WSAEPROTONOSUPPORT
+# define ECONNRESET WSAECONNRESET
+# ifdef errno
+# undef errno
+# endif
+# define errno WSAGetLastError()
+# define h_errno WSAGetLastError()
+# define set_errno(a) WSASetLastError(a)
+# define close(a) closesocket(a)
#else
# include "php_sockets.h"
# include <sys/types.h>
@@ -223,7 +232,7 @@
ZEND_ARG_INFO(0, optval)
ZEND_END_ARG_INFO()
-#if defined(HAVE_SOCKETPAIR) || defined(PHP_WIN32)
+#ifdef HAVE_SOCKETPAIR
ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_create_pair, 0, 0, 4)
ZEND_ARG_INFO(0, domain)
ZEND_ARG_INFO(0, type)
@@ -254,7 +263,7 @@
PHP_FE(socket_select, arginfo_socket_select)
PHP_FE(socket_create, arginfo_socket_create)
PHP_FE(socket_create_listen, arginfo_socket_create_listen)
-#if defined(HAVE_SOCKETPAIR) || defined(PHP_WIN32)
+#ifdef HAVE_SOCKETPAIR
PHP_FE(socket_create_pair, arginfo_socket_create_pair)
#endif
PHP_FE(socket_accept, arginfo_socket_accept)
@@ -1857,7 +1866,7 @@
}
/* }}} */
-#if defined(HAVE_SOCKETPAIR) || defined(PHP_WIN32)
+#ifdef HAVE_SOCKETPAIR
/* {{{ proto bool socket_create_pair(int domain, int type, int protocol, array
&fd) U
Creates a pair of indistinguishable sockets and stores them in fds. */
PHP_FUNCTION(socket_create_pair)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.133&r2=1.134&diff_format=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.133
php-src/ext/standard/streamsfuncs.c:1.134
--- php-src/ext/standard/streamsfuncs.c:1.133 Thu Jan 8 17:01:11 2009
+++ php-src/ext/standard/streamsfuncs.c Fri Jan 23 15:48:57 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streamsfuncs.c,v 1.133 2009/01/08 17:01:11 lbarnaud Exp $ */
+/* $Id: streamsfuncs.c,v 1.134 2009/01/23 15:48:57 kalle Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -36,6 +36,7 @@
typedef unsigned long long php_timeout_ull;
#else
#include "win32/select.h"
+#include "win32/sockets.h"
typedef unsigned __int64 php_timeout_ull;
#endif
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.h?r1=1.25&r2=1.26&diff_format=u
Index: php-src/ext/standard/streamsfuncs.h
diff -u php-src/ext/standard/streamsfuncs.h:1.25
php-src/ext/standard/streamsfuncs.h:1.26
--- php-src/ext/standard/streamsfuncs.h:1.25 Wed Dec 31 11:12:37 2008
+++ php-src/ext/standard/streamsfuncs.h Fri Jan 23 15:48:57 2009
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streamsfuncs.h,v 1.25 2008/12/31 11:12:37 sebastian Exp $ */
+/* $Id: streamsfuncs.h,v 1.26 2009/01/23 15:48:57 kalle Exp $ */
/* Flags for stream_socket_client */
#define PHP_STREAM_CLIENT_PERSISTENT 1
@@ -57,11 +57,14 @@
PHP_FUNCTION(stream_encoding);
PHP_FUNCTION(stream_socket_enable_crypto);
PHP_FUNCTION(stream_socket_shutdown);
-PHP_FUNCTION(stream_socket_pair);
PHP_FUNCTION(stream_resolve_include_path);
PHP_FUNCTION(stream_is_local);
PHP_FUNCTION(stream_supports_lock);
+#if HAVE_SOCKETPAIR
+PHP_FUNCTION(stream_socket_pair);
+#endif
+
/*
* Local variables:
* tab-width: 4
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/streams/stream_socket_pair.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/streams/stream_socket_pair.phpt
diff -u php-src/ext/standard/tests/streams/stream_socket_pair.phpt:1.1
php-src/ext/standard/tests/streams/stream_socket_pair.phpt:1.2
--- php-src/ext/standard/tests/streams/stream_socket_pair.phpt:1.1 Tue Nov
4 16:45:42 2008
+++ php-src/ext/standard/tests/streams/stream_socket_pair.phpt Fri Jan 23
15:48:58 2009
@@ -1,12 +1,9 @@
--TEST--
stream_socket_pair()
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip: non windows test");
-?>
--FILE--
<?php
-$sockets = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, 0);
+$domain = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' ? STREAM_PF_INET :
STREAM_PF_UNIX);
+$sockets = stream_socket_pair($domain, STREAM_SOCK_STREAM, 0);
var_dump($sockets);
fwrite($sockets[0], b"foo");
var_dump(fread($sockets[1], strlen(b"foo")));
http://cvs.php.net/viewvc.cgi/php-src/win32/build/config.w32?r1=1.97&r2=1.98&diff_format=u
Index: php-src/win32/build/config.w32
diff -u php-src/win32/build/config.w32:1.97 php-src/win32/build/config.w32:1.98
--- php-src/win32/build/config.w32:1.97 Tue Jan 20 01:37:17 2009
+++ php-src/win32/build/config.w32 Fri Jan 23 15:48:58 2009
@@ -1,5 +1,5 @@
// vim:ft=javascript
-// $Id: config.w32,v 1.97 2009/01/20 01:37:17 pajoye Exp $
+// $Id: config.w32,v 1.98 2009/01/23 15:48:58 kalle Exp $
// "Master" config file; think of it as a configure.in
// equivalent.
@@ -351,7 +351,7 @@
php_open_temporary_file.c php_logos.c output.c internal_functions.c
php_sprintf.c \
getopt.c");
-ADD_SOURCES("win32", "inet.c fnmatch.c");
+ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c");
// Newer versions have it
if (VCVERS <= 1300) {
http://cvs.php.net/viewvc.cgi/php-src/win32/build/config.w32.h.in?r1=1.23&r2=1.24&diff_format=u
Index: php-src/win32/build/config.w32.h.in
diff -u php-src/win32/build/config.w32.h.in:1.23
php-src/win32/build/config.w32.h.in:1.24
--- php-src/win32/build/config.w32.h.in:1.23 Tue Jan 20 01:37:17 2009
+++ php-src/win32/build/config.w32.h.in Fri Jan 23 15:48:58 2009
@@ -1,6 +1,6 @@
/*
Build Configuration Template for Win32.
- $Id: config.w32.h.in,v 1.23 2009/01/20 01:37:17 pajoye Exp $
+ $Id: config.w32.h.in,v 1.24 2009/01/23 15:48:58 kalle Exp $
*/
/* Define the minimum supported version */
@@ -146,6 +146,9 @@
/* Win32 supports strcoll */
#define HAVE_STRCOLL 1
+/* Win32 supports socketpair by the emulation in win32/sockets.c */
+#define HAVE_SOCKETPAIR 1
+
/* Win32 support proc_open */
#define PHP_CAN_SUPPORT_PROC_OPEN 1
http://cvs.php.net/viewvc.cgi/php-src/win32/sockets.c?view=markup&rev=1.1
Index: php-src/win32/sockets.c
+++ php-src/win32/sockets.c
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Chris Vandomelen <[email protected]> |
| Sterling Hughes <[email protected]> |
| |
| WinSock: Daniel Beulshausen <[email protected]> |
+----------------------------------------------------------------------+
*/
/* $Id: sockets.c,v 1.1 2009/01/23 15:48:58 kalle Exp $ */
/* Code originally from ext/sockets */
#include <stdio.h>
#include <fcntl.h>
#include "php.h"
PHPAPI int socketpair(int domain, int type, int protocol, SOCKET sock[2])
{
struct sockaddr_in address;
SOCKET redirect;
int size = sizeof(address);
if(domain != AF_INET) {
WSASetLastError(WSAENOPROTOOPT);
return -1;
}
sock[0] = socket(domain, type, protocol);
address.sin_addr.s_addr = INADDR_ANY;
address.sin_family = AF_INET;
address.sin_port = 0;
bind(sock[0], (struct sockaddr*)&address, sizeof(address));
if(getsockname(sock[0], (struct sockaddr *)&address, &size) != 0) {
}
listen(sock[0], 2);
sock[1] = socket(domain, type, protocol);
address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
connect(sock[1], (struct sockaddr*)&address, sizeof(address));
redirect = accept(sock[0],(struct sockaddr*)&address, &size);
closesocket(sock[0]);
sock[0] = redirect;
if(sock[0] == INVALID_SOCKET ) {
closesocket(sock[0]);
closesocket(sock[1]);
WSASetLastError(WSAECONNABORTED);
return -1;
}
return 0;
}
http://cvs.php.net/viewvc.cgi/php-src/win32/sockets.h?view=markup&rev=1.1
Index: php-src/win32/sockets.h
+++ php-src/win32/sockets.h
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Chris Vandomelen <[email protected]> |
| Sterling Hughes <[email protected]> |
| |
| WinSock: Daniel Beulshausen <[email protected]> |
+----------------------------------------------------------------------+
*/
/* $Id: sockets.h,v 1.1 2009/01/23 15:48:58 kalle Exp $ */
/* Code originally from ext/sockets */
PHPAPI int socketpair(int domain, int type, int protocol, SOCKET sock[2]);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php