wez             Sun Dec 12 11:10:35 2004 EDT

  Modified files:              
    /php-src    configure.in 
    /php-src/ext/standard       basic_functions.c file.c streamsfuncs.c 
                                streamsfuncs.h 
  Log:
  Add stream_socket_pair(), a streams based version of socketpair().
  Modified patch from Vincent [six at t0x dot net]
  
  
  
http://cvs.php.net/diff.php/php-src/configure.in?r1=1.527&r2=1.528&ty=u
Index: php-src/configure.in
diff -u php-src/configure.in:1.527 php-src/configure.in:1.528
--- php-src/configure.in:1.527  Mon Dec  6 15:39:20 2004
+++ php-src/configure.in        Sun Dec 12 11:10:34 2004
@@ -1,4 +1,4 @@
-dnl ## $Id: configure.in,v 1.527 2004/12/06 20:39:20 derick Exp $ -*- autoconf 
-*-
+dnl ## $Id: configure.in,v 1.528 2004/12/12 16:10:34 wez Exp $ -*- autoconf -*-
 dnl ## Process this file with autoconf to produce a configure script.
 
 divert(1)
@@ -322,6 +322,7 @@
 dnl Also, uClibc will bark at linking with glibc's libnsl.
 
 PHP_CHECK_FUNC(socket, socket)
+PHP_CHECK_FUNC(socketpair, socket)
 PHP_CHECK_FUNC(htonl, socket)
 PHP_CHECK_FUNC(gethostname, nsl)
 PHP_CHECK_FUNC(gethostbyaddr, nsl)
http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.698&r2=1.699&ty=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.698 
php-src/ext/standard/basic_functions.c:1.699
--- php-src/ext/standard/basic_functions.c:1.698        Mon Nov 15 16:13:25 2004
+++ php-src/ext/standard/basic_functions.c      Sun Dec 12 11:10:34 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.698 2004/11/15 21:13:25 fmk Exp $ */
+/* $Id: basic_functions.c,v 1.699 2004/12/12 16:10:34 wez Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -602,6 +602,9 @@
        PHP_FE(stream_socket_recvfrom,                                          
        fourth_arg_force_ref)
        PHP_FE(stream_socket_sendto,                                            
                                        NULL)
        PHP_FE(stream_socket_enable_crypto,                                     
                                        NULL)
+#if HAVE_SOCKETPAIR
+       PHP_FE(stream_socket_pair,                                              
                                                NULL)
+#endif
        PHP_FE(stream_copy_to_stream,                                           
                                        NULL)
        PHP_FE(stream_get_contents,                                             
                                                NULL)
        PHP_FE(fgetcsv,                                                         
                                                        NULL)
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.393&r2=1.394&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.393 php-src/ext/standard/file.c:1.394
--- php-src/ext/standard/file.c:1.393   Fri Dec 10 05:30:01 2004
+++ php-src/ext/standard/file.c Sun Dec 12 11:10:35 2004
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: file.c,v 1.393 2004/12/10 10:30:01 tony2001 Exp $ */
+/* $Id: file.c,v 1.394 2004/12/12 16:10:35 wez Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -230,6 +230,17 @@
        REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv23_SERVER",    
STREAM_CRYPTO_METHOD_SSLv23_SERVER,     CONST_CS|CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLS_SERVER",               
STREAM_CRYPTO_METHOD_TLS_SERVER,        CONST_CS|CONST_PERSISTENT);
 
+       REGISTER_LONG_CONSTANT("STREAM_SOCK_STREAM", SOCK_STREAM, 
CONST_CS|CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("STREAM_SOCK_DGRAM", SOCK_DGRAM, 
CONST_CS|CONST_PERSISTENT);
+#ifdef SOCK_RAW
+       REGISTER_LONG_CONSTANT("STREAM_SOCK_RAW", SOCK_RAW, 
CONST_CS|CONST_PERSISTENT);
+#endif
+#ifdef SOCK_SEQPACKET
+       REGISTER_LONG_CONSTANT("STREAM_SOCK_SEQPACKET", SOCK_SEQPACKET, 
CONST_CS|CONST_PERSISTENT);
+#endif
+#ifdef SOCK_RDM
+       REGISTER_LONG_CONSTANT("STREAM_SOCK_RDM", SOCK_RDM, 
CONST_CS|CONST_PERSISTENT);
+#endif
        REGISTER_LONG_CONSTANT("STREAM_PEEK", STREAM_PEEK, CONST_CS | 
CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("STREAM_OOB",  STREAM_OOB, CONST_CS | 
CONST_PERSISTENT);
 
http://cvs.php.net/diff.php/php-src/ext/standard/streamsfuncs.c?r1=1.44&r2=1.45&ty=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.44 
php-src/ext/standard/streamsfuncs.c:1.45
--- php-src/ext/standard/streamsfuncs.c:1.44    Tue Oct 12 19:25:24 2004
+++ php-src/ext/standard/streamsfuncs.c Sun Dec 12 11:10:35 2004
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.c,v 1.44 2004/10/12 23:25:24 iliaa Exp $ */
+/* $Id: streamsfuncs.c,v 1.45 2004/12/12 16:10:35 wez Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -41,6 +41,38 @@
 
 /* Streams based network functions */
 
+#if HAVE_SOCKETPAIR
+/* {{{ proto array stream_socket_pair(int domain, int type, int protocol)
+   Creates a pair of indistinguishable socket streams */
+PHP_FUNCTION(stream_socket_pair)
+{
+       long domain, type, protocol;
+       php_stream *s1, *s2;
+       zval *zs1, *sz2;
+       int pair[2];
+
+       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
+                       &domain, &type, &protocol)) {
+               RETURN_FALSE;
+       }
+
+       if (0 != socketpair(domain, type, protocol, pair)) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to create 
sockets: [%d]: %s",
+                       php_socket_errno(), 
php_socket_strerror(php_socket_errno()));
+               RETURN_FALSE;
+       }
+
+       array_init(return_value);
+
+       s1 = php_stream_sock_open_from_socket(pair[0], 0);
+       s2 = php_stream_sock_open_from_socket(pair[1], 0);
+
+       add_next_index_zval(return_value, php_stream_get_resource_id(s1));
+       add_next_index_zval(return_value, php_stream_get_resource_id(s2));
+}
+/* }}} */
+#endif
+
 /* {{{ proto resource stream_socket_client(string remoteaddress [, long 
&errcode, string &errstring, double timeout, long flags, resource context])
    Open a client connection to a remote address */
 PHP_FUNCTION(stream_socket_client)
http://cvs.php.net/diff.php/php-src/ext/standard/streamsfuncs.h?r1=1.11&r2=1.12&ty=u
Index: php-src/ext/standard/streamsfuncs.h
diff -u php-src/ext/standard/streamsfuncs.h:1.11 
php-src/ext/standard/streamsfuncs.h:1.12
--- php-src/ext/standard/streamsfuncs.h:1.11    Mon Sep 13 23:48:16 2004
+++ php-src/ext/standard/streamsfuncs.h Sun Dec 12 11:10:35 2004
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.h,v 1.11 2004/09/14 03:48:16 pollita Exp $ */
+/* $Id: streamsfuncs.h,v 1.12 2004/12/12 16:10:35 wez Exp $ */
 
 /* Flags for stream_socket_client */
 #define PHP_STREAM_CLIENT_PERSISTENT   1
@@ -54,6 +54,7 @@
 PHP_FUNCTION(stream_filter_append);
 PHP_FUNCTION(stream_filter_remove);
 PHP_FUNCTION(stream_socket_enable_crypto);
+PHP_FUNCTION(stream_socket_pair);
 
 /*
  * Local variables:

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to