cvs: php4 /ext/standard basic_functions.c basic_functions.h
| From: | Jani Taskinen | Date: | Thu, 30 Aug 2001 17:47:05 +0000 |
| Subject: | cvs: php4 /ext/standard basic_functions.c basic_functions.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-7131@lists.php.net to get a copy of this message | ||
sniper Thu Aug 30 13:47:05 2001 EDT
Modified files:
/php4/ext/standard basic_functions.c basic_functions.h
Log:
@- Added ini_get_all() function which returns all registered ini entries
or the entries for the specified extension. (Jani)
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.391 php4/ext/standard/basic_functions.c:1.392
--- php4/ext/standard/basic_functions.c:1.391 Wed Aug 29 19:53:22 2001
+++ php4/ext/standard/basic_functions.c Thu Aug 30 13:47:03 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.391 2001/08/29 23:53:22 sniper Exp $ */
+/* $Id: basic_functions.c,v 1.392 2001/08/30 17:47:03 sniper Exp $ */
#include "php.h"
#include "php_main.h"
@@ -542,6 +542,7 @@
PHP_FE(highlight_string, NULL)
PHP_FE(ini_get, NULL)
+ PHP_FE(ini_get_all, NULL)
PHP_FE(ini_set, NULL)
PHP_FALIAS(ini_alter, ini_set, NULL)
PHP_FE(ini_restore, NULL)
@@ -903,6 +904,11 @@
REGISTER_LONG_CONSTANT("CONNECTION_NORMAL", PHP_CONNECTION_NORMAL, CONST_CS |
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CONNECTION_TIMEOUT", PHP_CONNECTION_TIMEOUT, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("INI_USER", ZEND_INI_USER, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("INI_PERDIR", ZEND_INI_PERDIR, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("INI_SYSTEM", ZEND_INI_SYSTEM, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("INI_ALL", ZEND_INI_ALL, CONST_CS | CONST_PERSISTENT);
+
#define REGISTER_MATH_CONSTANT(x) REGISTER_DOUBLE_CONSTANT(#x, x, CONST_CS | CONST_PERSISTENT)
REGISTER_MATH_CONSTANT(M_E);
REGISTER_MATH_CONSTANT(M_LOG2E);
@@ -2191,6 +2197,68 @@
}
RETURN_STRING(str, 1);
+}
+/* }}} */
+
+
+static int php_ini_get_option(zend_ini_entry *ini_entry, int num_args, va_list args, zend_hash_key
*hash_key)
+{
+ zval *ini_array = va_arg(args, zval *);
+ int module_number = va_arg(args, int);
+ zval *option;
+
+ if(module_number != 0 && ini_entry->module_number != module_number) {
+ return 0;
+ }
+
+ if (hash_key->nKeyLength == 0 || hash_key->arKey[0] != 0) {
+
+ MAKE_STD_ZVAL(option);
+ array_init(option);
+
+ if(ini_entry->value) {
+ add_assoc_stringl(option, "global_value", ini_entry->value,
ini_entry->value_length, 1);
+ } else {
+ add_assoc_null(option, "global_value");
+ }
+
+ if(ini_entry->orig_value) {
+ add_assoc_stringl(option, "local_value", ini_entry->orig_value,
ini_entry->orig_value_length, 1);
+ } else {
+ add_assoc_null(option, "local_value");
+ }
+
+ add_assoc_long(option, "access", ini_entry->modifyable);
+
+ add_assoc_zval_ex(ini_array, ini_entry->name, ini_entry->name_length, option);
+ }
+ return 0;
+}
+
+/* {{{ proto array ini_get_all([string extension])
+ Get all configuration options */
+PHP_FUNCTION(ini_get_all)
+{
+ char *extname = NULL;
+ int extname_len = 0, extnumber = 0;
+ zend_module_entry *module;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &extname,
&extname_len) == FAILURE) {
+ return;
+ }
+
+ zend_ini_sort_entries(TSRMLS_C);
+
+ if(extname) {
+ if (zend_hash_find(&module_registry, extname, extname_len + 1, (void **) &module) ==
FAILURE) {
+ php_error(E_WARNING, "Unable to find extension '%s'", extname);
+ RETURN_FALSE;
+ }
+ extnumber = module->module_number;
+ }
+
+ array_init(return_value);
+ zend_hash_apply_with_arguments(&EG(ini_directives), (apply_func_args_t) php_ini_get_option, 2,
return_value, extnumber TSRMLS_CC);
}
/* }}} */
Index: php4/ext/standard/basic_functions.h
diff -u php4/ext/standard/basic_functions.h:1.90 php4/ext/standard/basic_functions.h:1.91
--- php4/ext/standard/basic_functions.h:1.90 Sat Aug 25 21:09:20 2001
+++ php4/ext/standard/basic_functions.h Thu Aug 30 13:47:04 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.h,v 1.90 2001/08/26 01:09:20 zeev Exp $ */
+/* $Id: basic_functions.h,v 1.91 2001/08/30 17:47:04 sniper Exp $ */
#ifndef BASIC_FUNCTIONS_H
#define BASIC_FUNCTIONS_H
@@ -90,6 +90,7 @@
ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini);
PHP_FUNCTION(ini_get);
+PHP_FUNCTION(ini_get_all);
PHP_FUNCTION(ini_set);
PHP_FUNCTION(ini_restore);