helly Thu Feb 8 16:55:34 2007 UTC Modified files: (Branch: PHP_5_2) /php-src NEWS /php-src/ext/standard info.c info.h /php-src/sapi/cli php.1.in php_cli.c Log: - MFH php --ri <extension>
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.523&r2=1.2027.2.547.2.524&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.523 php-src/NEWS:1.2027.2.547.2.524 --- php-src/NEWS:1.2027.2.547.2.523 Wed Feb 7 01:01:37 2007 +++ php-src/NEWS Thu Feb 8 16:55:34 2007 @@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2007, PHP 5.2.2 +- Add --ri switch to CLI which allows to check extension information. (Marcus) 08 Feb 2007, PHP 5.2.1 - Added read-timeout context option "timeout" for HTTP streams. (Hannes, Ilia). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/info.c?r1=1.249.2.10.2.9&r2=1.249.2.10.2.10&diff_format=u Index: php-src/ext/standard/info.c diff -u php-src/ext/standard/info.c:1.249.2.10.2.9 php-src/ext/standard/info.c:1.249.2.10.2.10 --- php-src/ext/standard/info.c:1.249.2.10.2.9 Fri Jan 26 15:33:18 2007 +++ php-src/ext/standard/info.c Thu Feb 8 16:55:34 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: info.c,v 1.249.2.10.2.9 2007/01/26 15:33:18 tony2001 Exp $ */ +/* $Id: info.c,v 1.249.2.10.2.10 2007/02/08 16:55:34 helly Exp $ */ #include "php.h" #include "php_ini.h" @@ -76,13 +76,9 @@ } -/* {{{ _display_module_info - */ -static int _display_module_info(zend_module_entry *module, void *arg TSRMLS_DC) +PHPAPI void php_info_print_module(zend_module_entry *module TSRMLS_DC) /* {{{ */ { - int show_info_func = *((int *) arg); - - if (show_info_func && module->info_func) { + if (module->info_func) { if (!sapi_module.phpinfo_as_text) { php_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", module->name, module->name); } else { @@ -91,7 +87,7 @@ php_info_print_table_end(); } module->info_func(module TSRMLS_CC); - } else if (!show_info_func && !module->info_func) { + } else { if (!sapi_module.phpinfo_as_text) { php_printf("<tr>"); php_printf("<td>"); @@ -102,7 +98,24 @@ php_printf("\n"); } } - return 0; +} +/* }}} */ + +static int _display_module_info_func(zend_module_entry *module TSRMLS_DC) /* {{{ */ +{ + if (module->info_func) { + php_info_print_module(module TSRMLS_CC); + } + return ZEND_HASH_APPLY_KEEP; +} +/* }}} */ + +static int _display_module_info_def(zend_module_entry *module TSRMLS_DC) /* {{{ */ +{ + if (!module->info_func) { + php_info_print_module(module TSRMLS_CC); + } + return ZEND_HASH_APPLY_KEEP; } /* }}} */ @@ -662,22 +675,19 @@ } if (flag & PHP_INFO_MODULES) { - int show_info_func; HashTable sorted_registry; zend_module_entry tmp; - zend_hash_init(&sorted_registry, 50, NULL, NULL, 1); + zend_hash_init(&sorted_registry, zend_hash_num_elements(&module_registry), NULL, NULL, 1); zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry)); zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC); - show_info_func = 1; - zend_hash_apply_with_argument(&sorted_registry, (apply_func_arg_t) _display_module_info, &show_info_func TSRMLS_CC); + zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_func TSRMLS_CC); SECTION("Additional Modules"); php_info_print_table_start(); php_info_print_table_header(1, "Module Name"); - show_info_func = 0; - zend_hash_apply_with_argument(&sorted_registry, (apply_func_arg_t) _display_module_info, &show_info_func TSRMLS_CC); + zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_def TSRMLS_CC); php_info_print_table_end(); zend_hash_destroy(&sorted_registry); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/info.h?r1=1.38.2.1.2.3&r2=1.38.2.1.2.4&diff_format=u Index: php-src/ext/standard/info.h diff -u php-src/ext/standard/info.h:1.38.2.1.2.3 php-src/ext/standard/info.h:1.38.2.1.2.4 --- php-src/ext/standard/info.h:1.38.2.1.2.3 Mon Jan 1 09:36:08 2007 +++ php-src/ext/standard/info.h Thu Feb 8 16:55:34 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: info.h,v 1.38.2.1.2.3 2007/01/01 09:36:08 sebastian Exp $ */ +/* $Id: info.h,v 1.38.2.1.2.4 2007/02/08 16:55:34 helly Exp $ */ #ifndef INFO_H #define INFO_H @@ -81,6 +81,7 @@ PHPAPI void php_info_print_box_start(int bg); PHPAPI void php_info_print_box_end(void); PHPAPI void php_info_print_hr(void); +PHPAPI void php_info_print_module(zend_module_entry *module TSRMLS_DC); PHPAPI char *php_logo_guid(void); PHPAPI char *php_get_uname(char mode); http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/php.1.in?r1=1.12.2.3.2.1&r2=1.12.2.3.2.2&diff_format=u Index: php-src/sapi/cli/php.1.in diff -u php-src/sapi/cli/php.1.in:1.12.2.3.2.1 php-src/sapi/cli/php.1.in:1.12.2.3.2.2 --- php-src/sapi/cli/php.1.in:1.12.2.3.2.1 Wed Jan 10 22:17:27 2007 +++ php-src/sapi/cli/php.1.in Thu Feb 8 16:55:34 2007 @@ -294,6 +294,16 @@ .IR name Shows information about extension .B name +.TP +.PD 0 +.B \-\-rextinfo +.IR name +.TP +.PD 1 +.B \-\-ri +.IR name +Shows configuration for extension +.B name .SH FILES .TP 15 .B php\-cli.ini http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/php_cli.c?r1=1.129.2.13.2.12&r2=1.129.2.13.2.13&diff_format=u Index: php-src/sapi/cli/php_cli.c diff -u php-src/sapi/cli/php_cli.c:1.129.2.13.2.12 php-src/sapi/cli/php_cli.c:1.129.2.13.2.13 --- php-src/sapi/cli/php_cli.c:1.129.2.13.2.12 Mon Jan 1 09:36:12 2007 +++ php-src/sapi/cli/php_cli.c Thu Feb 8 16:55:34 2007 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_cli.c,v 1.129.2.13.2.12 2007/01/01 09:36:12 sebastian Exp $ */ +/* $Id: php_cli.c,v 1.129.2.13.2.13 2007/02/08 16:55:34 helly Exp $ */ #include "php.h" #include "php_globals.h" @@ -105,16 +105,16 @@ #define PHP_MODE_REFLECTION_FUNCTION 8 #define PHP_MODE_REFLECTION_CLASS 9 #define PHP_MODE_REFLECTION_EXTENSION 10 +#define PHP_MODE_REFLECTION_EXT_INFO 11 #define HARDCODED_INI \ "html_errors=0\n" \ "register_argc_argv=1\n" \ "implicit_flush=1\n" \ "output_buffering=0\n" \ - "max_execution_time=0\n" \ + "max_execution_time=0\n" \ "max_input_time=-1\n" - static char *php_optarg = NULL; static int php_optind = 1; #if (HAVE_LIBREADLINE || HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE) @@ -153,6 +153,8 @@ {11, 1, "rclass"}, {12, 1, "re"}, {12, 1, "rextension"}, + {13, 1, "ri"}, + {13, 1, "rextinfo"}, #endif {'-', 0, NULL} /* end of args */ }; @@ -450,6 +452,7 @@ " --rf <name> Show information about function <name>.\n" " --rc <name> Show information about class <name>.\n" " --re <name> Show information about extension <name>.\n" + " --ri <name> Show configuration for extension <name>.\n" "\n" #endif , prog, prog, prog, prog, prog, prog); @@ -623,8 +626,8 @@ tsrm_startup(1, 1, 0, NULL); #endif - cli_sapi_module.php_ini_path_override = NULL; cli_sapi_module.ini_defaults = sapi_cli_ini_defaults; + cli_sapi_module.php_ini_path_override = NULL; cli_sapi_module.phpinfo_as_text = 1; sapi_startup(&cli_sapi_module); @@ -642,13 +645,13 @@ while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0))!=-1) { switch (c) { - case 'c': - cli_sapi_module.php_ini_path_override = strdup(php_optarg); - break; - case 'n': - cli_sapi_module.php_ini_ignore = 1; - break; - case 'd': { + case 'c': + cli_sapi_module.php_ini_path_override = strdup(php_optarg); + break; + case 'n': + cli_sapi_module.php_ini_ignore = 1; + break; + case 'd': { /* define ini entries on command line */ int len = strlen(php_optarg); char *val; @@ -947,6 +950,10 @@ behavior=PHP_MODE_REFLECTION_EXTENSION; reflection_what = php_optarg; break; + case 13: + behavior=PHP_MODE_REFLECTION_EXT_INFO; + reflection_what = php_optarg; + break; #endif default: break; @@ -1254,6 +1261,22 @@ break; } + case PHP_MODE_REFLECTION_EXT_INFO: + { + int len = strlen(reflection_what); + char *lcname = zend_str_tolower_dup(reflection_what, len); + zend_module_entry *module; + + if (zend_hash_find(&module_registry, lcname, len+1, (void**)&module) == FAILURE) { + zend_printf("Extension '%s' not present.\n", reflection_what); + exit_status = 1; + } else { + php_info_print_module(module TSRMLS_CC); + } + + efree(lcname); + break; + } #endif /* reflection */ } }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php