wez             Thu Jul 22 08:12:28 2004 EDT

  Modified files:              
    /php-src/ext/standard       basic_functions.c file.c streamsfuncs.c 
                                streamsfuncs.h 
  Log:
  Added stream_context_get_default() which returns the default context option.
  You may then set options that affect streams operations for the whole script.
  
  Added stream_socket_enable_crypto() which allows you to turn on or off a crypto
  layer (eg: SSL/TLS) on stream, if supported by the underlying transport.
  
  Registered a bunch of constants for that.
  
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.675&r2=1.676&ty=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.675 
php-src/ext/standard/basic_functions.c:1.676
--- php-src/ext/standard/basic_functions.c:1.675        Wed Jul 21 17:17:56 2004
+++ php-src/ext/standard/basic_functions.c      Thu Jul 22 08:12:28 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.675 2004/07/21 21:17:56 andrey Exp $ */
+/* $Id: basic_functions.c,v 1.676 2004/07/22 12:12:28 wez Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -587,6 +587,7 @@
        PHP_FE(stream_context_set_params,                                              
                                 NULL)
        PHP_FE(stream_context_set_option,                                              
                                 NULL)
        PHP_FE(stream_context_get_options,                                             
                                 NULL)
+       PHP_FE(stream_context_get_default,                                             
                                 NULL)
        PHP_FE(stream_filter_prepend,                                                  
                                 NULL)
        PHP_FE(stream_filter_append,                                                   
                                 NULL)
        PHP_FE(stream_socket_client,                             
second_and_third_args_force_ref)
@@ -595,6 +596,7 @@
        PHP_FE(stream_socket_get_name,                                                 
                                 NULL)
        PHP_FE(stream_socket_recvfrom,                                                 
 fourth_arg_force_ref)
        PHP_FE(stream_socket_sendto,                                                   
                                 NULL)
+       PHP_FE(stream_socket_enable_crypto,                                            
                                 NULL)
        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.383&r2=1.384&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.383 php-src/ext/standard/file.c:1.384
--- php-src/ext/standard/file.c:1.383   Mon Jul 19 03:19:44 2004
+++ php-src/ext/standard/file.c Thu Jul 22 08:12:28 2004
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: file.c,v 1.383 2004/07/19 07:19:44 andi Exp $ */
+/* $Id: file.c,v 1.384 2004/07/22 12:12:28 wez Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -213,6 +213,15 @@
        REGISTER_LONG_CONSTANT("STREAM_CLIENT_PERSISTENT",              
PHP_STREAM_CLIENT_PERSISTENT,           CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("STREAM_CLIENT_ASYNC_CONNECT",   
PHP_STREAM_CLIENT_ASYNC_CONNECT,        CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("STREAM_CLIENT_CONNECT",                 
PHP_STREAM_CLIENT_CONNECT,      CONST_CS | CONST_PERSISTENT);
+
+       REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv2_CLIENT",             
STREAM_CRYPTO_METHOD_SSLv2_CLIENT,      CONST_CS|CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv3_CLIENT",             
STREAM_CRYPTO_METHOD_SSLv3_CLIENT,      CONST_CS|CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv23_CLIENT",    
STREAM_CRYPTO_METHOD_SSLv23_CLIENT,     CONST_CS|CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLS_CLIENT",               
STREAM_CRYPTO_METHOD_TLS_CLIENT,        CONST_CS|CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv2_SERVER",             
STREAM_CRYPTO_METHOD_SSLv2_SERVER,      CONST_CS|CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv3_SERVER",             
STREAM_CRYPTO_METHOD_SSLv3_SERVER,      CONST_CS|CONST_PERSISTENT);
+       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_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.35&r2=1.36&ty=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.35 
php-src/ext/standard/streamsfuncs.c:1.36
--- php-src/ext/standard/streamsfuncs.c:1.35    Wed Jun 16 19:57:25 2004
+++ php-src/ext/standard/streamsfuncs.c Thu Jul 22 08:12:28 2004
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.c,v 1.35 2004/06/16 23:57:25 abies Exp $ */
+/* $Id: streamsfuncs.c,v 1.36 2004/07/22 12:12:28 wez Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -928,6 +928,30 @@
 }
 /* }}} */
 
+/* {{{ proto resource stream_context_get_default([array options])
+   Get a handle on the default file/stream context and optionally set parameters */
+PHP_FUNCTION(stream_context_get_default)
+{
+       zval *params = NULL;
+       php_stream_context *context;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a", &params) == 
FAILURE) {
+               RETURN_FALSE;
+       }
+       
+       if (FG(default_context) == NULL) {
+               FG(default_context) = php_stream_context_alloc();
+       }
+       context = FG(default_context);
+       
+       if (params) {
+               parse_context_options(context, params);
+       }
+       
+       php_stream_context_to_zval(context, return_value);
+}
+/* }}} */
+
 /* {{{ proto resource stream_context_create([array options])
    Create a file context and optionally set parameters */
 PHP_FUNCTION(stream_context_create)
@@ -1163,6 +1187,35 @@
        }
 
        RETURN_LONG(ret == 0 ? 0 : EOF);
+}
+/* }}} */
+
+/* {{{ proto bool stream_socket_enable_crypto(resource stream, bool enable [, int 
cryptokind, resource sessionstream])
+   Enable or disable a specific kind of crypto on the stream */
+PHP_FUNCTION(stream_socket_enable_crypto)
+{
+       long cryptokind;
+       zval *zstream, *zsessstream = NULL;
+       php_stream *stream, *sessstream = NULL;
+       zend_bool enable;
+       
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rb|lr", &zstream, 
&enable, &cryptokind, &zsessstream) == FAILURE) {
+               RETURN_FALSE;
+       }
+       
+       php_stream_from_zval(stream, &zstream);
+
+       if (ZEND_NUM_ARGS() >= 3) {
+               if (zsessstream) {
+                       php_stream_from_zval(sessstream, zsessstream);
+               }
+               
+               if (php_stream_xport_crypto_setup(stream, cryptokind, sessstream 
TSRMLS_CC) < 0) {
+                       RETURN_FALSE;
+               }
+       }
+
+       RETURN_BOOL(php_stream_xport_crypto_enable(stream, enable TSRMLS_CC) < 0 ? 0 : 
1);
 }
 /* }}} */
 
http://cvs.php.net/diff.php/php-src/ext/standard/streamsfuncs.h?r1=1.8&r2=1.9&ty=u
Index: php-src/ext/standard/streamsfuncs.h
diff -u php-src/ext/standard/streamsfuncs.h:1.8 php-src/ext/standard/streamsfuncs.h:1.9
--- php-src/ext/standard/streamsfuncs.h:1.8     Thu Jan  8 12:32:52 2004
+++ php-src/ext/standard/streamsfuncs.h Thu Jul 22 08:12:28 2004
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.h,v 1.8 2004/01/08 17:32:52 sniper Exp $ */
+/* $Id: streamsfuncs.h,v 1.9 2004/07/22 12:12:28 wez Exp $ */
 
 /* Flags for stream_socket_client */
 #define PHP_STREAM_CLIENT_PERSISTENT   1
@@ -47,8 +47,10 @@
 PHP_FUNCTION(stream_context_set_params);
 PHP_FUNCTION(stream_context_set_option);
 PHP_FUNCTION(stream_context_get_options);
+PHP_FUNCTION(stream_context_get_default);
 PHP_FUNCTION(stream_filter_prepend);
 PHP_FUNCTION(stream_filter_append);
+PHP_FUNCTION(stream_socket_enable_crypto);
 
 /*
  * Local variables:

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

Reply via email to