]> granicus.if.org Git - php/commitdiff
- Since streams are always enabled, instead of just printing 'enabled' we tell
authorMarkus Fischer <mfischer@php.net>
Sat, 8 Jun 2002 10:25:44 +0000 (10:25 +0000)
committerMarkus Fischer <mfischer@php.net>
Sat, 8 Jun 2002 10:25:44 +0000 (10:25 +0000)
  what streams are currently registered.

ext/standard/info.c
main/php_streams.h
main/streams.c

index 5cea723348406d9efb145721c32192dd09677a5e..1932b8ad77d7a24976de34e19aa723cb84ac5b1f 100644 (file)
@@ -211,6 +211,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
        char php_api_no[9];
        char mod_api_no[9];
        char ext_api_no[9];
+       
 
        the_time = time(NULL);
        ta = php_localtime_r(&the_time, &tmbuf);
@@ -277,7 +278,36 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
                php_info_print_table_row(2, "Thread Safety", "disabled" );
 #endif
 
-               php_info_print_table_row(2, "PHP Streams", "enabled");
+               {
+                       HashTable *url_stream_wrappers_hash;
+                       char *stream_protocol, *stream_protocols_buf = NULL;
+                       int stream_protocol_len, stream_protocols_buf_len = 0;
+
+                       if ((url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash())) {
+                               for (zend_hash_internal_pointer_reset(url_stream_wrappers_hash);
+                                               zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, NULL, 0, NULL) == HASH_KEY_IS_STRING;
+                                               zend_hash_move_forward(url_stream_wrappers_hash)) {
+                                       if (NULL == (stream_protocols_buf = erealloc(stream_protocols_buf,
+                                                                       stream_protocols_buf_len + stream_protocol_len + 1 /* "\n" */ + 1 /* 0 byte at end */))) {
+                                               break;
+                                       }
+                                       memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol, stream_protocol_len);
+                                       stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len] = '\n';
+                                       stream_protocols_buf_len += stream_protocol_len + 1;
+                               }
+                               if (stream_protocols_buf) {
+                                       stream_protocols_buf[stream_protocols_buf_len] = 0;
+                                       php_info_print_table_row(2, "Registered PHP Streams", stream_protocols_buf);
+                                       efree(stream_protocols_buf);
+                               } else {
+                                       // Any chances we will ever hit this?
+                                       php_info_print_table_row(2, "Registered PHP Streams", "no streams registered");
+                               }
+                       } else {
+                               // Any chances we will ever hit this?
+                               php_info_print_table_row(2, "PHP Streams", "disabled"); // ??
+                       }
+               }
                
                php_info_print_table_end();
 
index 815b0ea549ff6a1a262447846bc6503d9ad5ef31..e46dc5db3551c1330a9d08505f1424ed601c7060 100755 (executable)
@@ -452,6 +452,10 @@ PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream
        php_stream_notification_notify((context), (code), PHP_STREAM_NOTIFY_SEVERITY_ERR, \
                        (xmsg), (xcode), 0, 0, NULL TSRMLS_CC); } } while(0)
        
+
+/* Give other modules access to the url_stream_wrappers_hash */
+PHPAPI HashTable *php_stream_get_url_stream_wrappers_hash();
+
 #endif
 
 /*
index 5010fb7130a93b9511529f91755a69d71e05985f..b65f39feef15688c171a30473a283f0f3da049c2 100755 (executable)
@@ -1481,6 +1481,10 @@ PHPAPI int php_stream_context_set_option(php_stream_context *context,
        return zend_hash_update(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)&optionvalue, sizeof(zval *), NULL);
 }
 
+PHPAPI HashTable *php_stream_get_url_stream_wrappers_hash()
+{
+       return &url_stream_wrappers_hash;
+}
 
 /*
  * Local variables: