cvs: /php4 configuration-parser.y main.c php_ini.c php_ini.h /php4/ext/standard basic_functions.c /php4/sapi/cgi cgi_main.c /php4/win32 registry.c
| From: | Zeev Suraski | Date: | Sat, 26 Feb 2000 15:36:54 +0000 |
| Subject: | cvs: /php4 configuration-parser.y main.c php_ini.c php_ini.h /php4/ext/standard basic_functions.c /php4/sapi/cgi cgi_main.c /php4/win32 registry.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11043@lists.php.net to get a copy of this message | ||
zeev Sat Feb 26 07:36:54 2000 EDT
Modified files:
/php4 configuration-parser.y main.c php_ini.c php_ini.h
/php4/ext/standard basic_functions.c
/php4/sapi/cgi cgi_main.c
/php4/win32 registry.c
Log:
Allow the INI callbacks to know at what stage PHP is
Index: php4/configuration-parser.y
diff -u php4/configuration-parser.y:1.35 php4/configuration-parser.y:1.36
--- php4/configuration-parser.y:1.35 Thu Feb 24 05:39:36 2000
+++ php4/configuration-parser.y Sat Feb 26 07:36:23 2000
@@ -19,7 +19,7 @@
-/* $Id: configuration-parser.y,v 1.35 2000/02/24 13:39:36 thies Exp $ */
+/* $Id: configuration-parser.y,v 1.36 2000/02/26 15:36:23 zeev Exp $ */
#define DEBUG_CFG_PARSER 0
#include "php.h"
@@ -410,7 +410,7 @@
if (parsing_mode==PARSING_MODE_CFG) {
zend_hash_update(active_hash_table, $1.value.str.val, $1.value.str.len+1, &$3,
sizeof(zval), NULL);
if (active_hash_table == &configuration_hash) {
- php_alter_ini_entry($1.value.str.val, $1.value.str.len+1, $3.value.str.val,
$3.value.str.len+1, PHP_INI_SYSTEM);
+ php_alter_ini_entry($1.value.str.val, $1.value.str.len+1, $3.value.str.val,
$3.value.str.len+1, PHP_INI_SYSTEM, PHP_INI_STAGE_STARTUP);
}
} else if (parsing_mode==PARSING_MODE_BROWSCAP) {
if (current_section) {
Index: php4/main.c
diff -u php4/main.c:1.218 php4/main.c:1.219
--- php4/main.c:1.218 Sat Feb 26 06:29:27 2000
+++ php4/main.c Sat Feb 26 07:36:23 2000
@@ -19,7 +19,7 @@
*/
-/* $Id: main.c,v 1.218 2000/02/26 14:29:27 zeev Exp $ */
+/* $Id: main.c,v 1.219 2000/02/26 15:36:23 zeev Exp $ */
#include <stdio.h>
@@ -690,7 +690,7 @@
#ifdef ZTS
static void php_new_thread_end_handler(THREAD_T thread_id)
{
- php_ini_refresh_caches();
+ php_ini_refresh_caches(PHP_INI_STAGE_STARTUP);
}
#endif
Index: php4/php_ini.c
diff -u php4/php_ini.c:1.32 php4/php_ini.c:1.33
--- php4/php_ini.c:1.32 Thu Feb 24 14:00:47 2000
+++ php4/php_ini.c Sat Feb 26 07:36:23 2000
@@ -41,11 +41,11 @@
}
-static int php_restore_ini_entry_cb(php_ini_entry *ini_entry)
+static int php_restore_ini_entry_cb(php_ini_entry *ini_entry, int stage)
{
if (ini_entry->modified) {
if (ini_entry->on_modify) {
- ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->orig_value_length,
ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3);
+ ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->orig_value_length,
ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage);
}
efree(ini_entry->value);
ini_entry->value = ini_entry->orig_value;
@@ -78,7 +78,7 @@
int php_ini_rshutdown()
{
- zend_hash_apply(&known_directives, (int (*)(void *)) php_restore_ini_entry_cb);
+ zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *))
php_restore_ini_entry_cb, (void *) PHP_INI_STAGE_DEACTIVATE);
return SUCCESS;
}
@@ -99,17 +99,17 @@
return FAILURE;
}
if (hashed_ini_entry->on_modify) {
- hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value,
hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2,
hashed_ini_entry->mh_arg3);
+ hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value,
hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2,
hashed_ini_entry->mh_arg3, PHP_INI_STAGE_STARTUP);
}
if ((default_value=cfg_get_entry(p->name, p->name_length))) {
if (!hashed_ini_entry->on_modify
- || hashed_ini_entry->on_modify(hashed_ini_entry, default_value->value.str.val,
default_value->value.str.len, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2,
hashed_ini_entry->mh_arg3)==SUCCESS) {
+ || hashed_ini_entry->on_modify(hashed_ini_entry, default_value->value.str.val,
default_value->value.str.len, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2,
hashed_ini_entry->mh_arg3, PHP_INI_STAGE_STARTUP)==SUCCESS) {
hashed_ini_entry->value = default_value->value.str.val;
hashed_ini_entry->value_length = default_value->value.str.len;
}
} else {
if (hashed_ini_entry->on_modify) {
- hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value,
hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2,
hashed_ini_entry->mh_arg3);
+ hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value,
hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2,
hashed_ini_entry->mh_arg3, PHP_INI_STAGE_STARTUP);
}
}
hashed_ini_entry->modified = 0;
@@ -125,22 +125,22 @@
}
-static int php_ini_refresh_cache(php_ini_entry *p)
+static int php_ini_refresh_cache(php_ini_entry *p, int stage)
{
if (p->on_modify) {
- p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3);
+ p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3,
stage);
}
return 0;
}
-PHPAPI void php_ini_refresh_caches()
+PHPAPI void php_ini_refresh_caches(int stage)
{
- zend_hash_apply(&known_directives, (int (*)(void *)) php_ini_refresh_cache);
+ zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *))
php_ini_refresh_cache, (void *) stage);
}
-PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint
new_value_length, int modify_type)
+PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint
new_value_length, int modify_type, int stage)
{
php_ini_entry *ini_entry;
char *duplicate;
@@ -156,7 +156,7 @@
duplicate = estrndup(new_value, new_value_length);
if (!ini_entry->on_modify
- || ini_entry->on_modify(ini_entry, duplicate, new_value_length, ini_entry->mh_arg1,
ini_entry->mh_arg2, ini_entry->mh_arg3)==SUCCESS) {
+ || ini_entry->on_modify(ini_entry, duplicate, new_value_length, ini_entry->mh_arg1,
ini_entry->mh_arg2, ini_entry->mh_arg3, stage)==SUCCESS) {
if (!ini_entry->modified) {
ini_entry->orig_value = ini_entry->value;
ini_entry->orig_value_length = ini_entry->value_length;
@@ -174,7 +174,7 @@
}
-PHPAPI int php_restore_ini_entry(char *name, uint name_length)
+PHPAPI int php_restore_ini_entry(char *name, uint name_length, int stage)
{
php_ini_entry *ini_entry;
@@ -182,7 +182,7 @@
return FAILURE;
}
- php_restore_ini_entry_cb(ini_entry);
+ php_restore_ini_entry_cb(ini_entry, stage);
return SUCCESS;
}
Index: php4/php_ini.h
diff -u php4/php_ini.h:1.20 php4/php_ini.h:1.21
--- php4/php_ini.h:1.20 Sat Feb 19 15:21:25 2000
+++ php4/php_ini.h Sat Feb 26 07:36:23 2000
@@ -27,7 +27,7 @@
typedef struct _php_ini_entry php_ini_entry;
-#define PHP_INI_MH(name) int name(php_ini_entry *entry, char *new_value, uint new_value_length,
void *mh_arg1, void *mh_arg2, void *mh_arg3)
+#define PHP_INI_MH(name) int name(php_ini_entry *entry, char *new_value, uint new_value_length,
void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage)
#define PHP_INI_DISP(name) void name(php_ini_entry *ini_entry, int type)
struct _php_ini_entry {
@@ -57,9 +57,9 @@
PHPAPI int php_register_ini_entries(php_ini_entry *ini_entry, int module_number);
PHPAPI void php_unregister_ini_entries(int module_number);
-PHPAPI void php_ini_refresh_caches(void);
-PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint
new_value_length, int modify_type);
-PHPAPI int php_restore_ini_entry(char *name, uint name_length);
+PHPAPI void php_ini_refresh_caches(int stage);
+PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint
new_value_length, int modify_type, int stage);
+PHPAPI int php_restore_ini_entry(char *name, uint name_length, int stage);
PHPAPI void display_ini_entries(zend_module_entry *module);
PHPAPI long php_ini_long(char *name, uint name_length, int orig);
@@ -146,5 +146,11 @@
#define PHP_INI_DISPLAY_ORIG 1
#define PHP_INI_DISPLAY_ACTIVE 2
+
+#define PHP_INI_STAGE_STARTUP (1<<0)
+#define PHP_INI_STAGE_SHUTDOWN (1<<1)
+#define PHP_INI_STAGE_ACTIVATE (1<<2)
+#define PHP_INI_STAGE_DEACTIVATE (1<<3)
+#define PHP_INI_STAGE_RUNTIME (1<<4)
#endif /* _PHP_INI_H */
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.167 php4/ext/standard/basic_functions.c:1.168
--- php4/ext/standard/basic_functions.c:1.167 Sat Feb 26 06:53:18 2000
+++ php4/ext/standard/basic_functions.c Sat Feb 26 07:36:23 2000
@@ -1338,7 +1338,7 @@
old_value = php_ini_string((*varname)->value.str.val, (*varname)->value.str.len+1, 0);
- if (php_alter_ini_entry((*varname)->value.str.val, (*varname)->value.str.len+1,
(*new_value)->value.str.val, (*new_value)->value.str.len, PHP_INI_USER)==FAILURE) {
+ if (php_alter_ini_entry((*varname)->value.str.val, (*varname)->value.str.len+1,
(*new_value)->value.str.val, (*new_value)->value.str.len, PHP_INI_USER,
PHP_INI_STAGE_RUNTIME)==FAILURE) {
RETURN_FALSE;
}
if (old_value) {
@@ -1360,7 +1360,7 @@
convert_to_string_ex(varname);
- php_restore_ini_entry((*varname)->value.str.val, (*varname)->value.str.len);
+ php_restore_ini_entry((*varname)->value.str.val, (*varname)->value.str.len,
PHP_INI_STAGE_RUNTIME);
}
Index: php4/sapi/cgi/cgi_main.c
diff -u php4/sapi/cgi/cgi_main.c:1.31 php4/sapi/cgi/cgi_main.c:1.32
--- php4/sapi/cgi/cgi_main.c:1.31 Mon Feb 21 06:01:19 2000
+++ php4/sapi/cgi/cgi_main.c Sat Feb 26 07:36:23 2000
@@ -306,7 +306,7 @@
} else {
value = "1";
}
- php_alter_ini_entry(name, strlen(name), value, strlen(value), PHP_INI_SYSTEM);
+ php_alter_ini_entry(name, strlen(name), value, strlen(value), PHP_INI_SYSTEM,
PHP_INI_STAGE_ACTIVATE);
}
Index: php4/win32/registry.c
diff -u php4/win32/registry.c:1.2 php4/win32/registry.c:1.3
--- php4/win32/registry.c:1.2 Fri Nov 26 08:51:57 1999
+++ php4/win32/registry.c Sat Feb 26 07:36:23 2000
@@ -63,7 +63,7 @@
continue;
}
printf("%s -> %s\n", namebuf, valuebuf);
- php_alter_ini_entry(namebuf, namebuf_length+1, valuebuf, valuebuf_length+1, PHP_INI_PERDIR);
+ php_alter_ini_entry(namebuf, namebuf_length+1, valuebuf, valuebuf_length+1, PHP_INI_PERDIR,
PHP_INI_STAGE_ACTIVATE);
}
RegCloseKey(hKey);