2000-10-29 19:38:26 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2018-01-02 12:57:58 +08:00
|
|
|
| Copyright (c) 1998-2018 Zend Technologies Ltd. (http://www.zend.com) |
|
2000-10-29 19:38:26 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2001-12-11 23:16:21 +08:00
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
2000-10-29 19:38:26 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-11 04:04:29 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
2001-12-11 23:16:21 +08:00
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
2000-10-29 19:38:26 +08:00
|
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@zend.com so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Author: Zeev Suraski <zeev@zend.com> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2003-02-01 09:49:15 +08:00
|
|
|
/* $Id$ */
|
|
|
|
|
2000-10-29 19:38:26 +08:00
|
|
|
#include "zend.h"
|
2015-01-14 17:22:58 +08:00
|
|
|
#include "zend_sort.h"
|
2000-10-29 19:38:26 +08:00
|
|
|
#include "zend_API.h"
|
|
|
|
#include "zend_ini.h"
|
|
|
|
#include "zend_alloc.h"
|
|
|
|
#include "zend_operators.h"
|
2004-11-04 07:13:32 +08:00
|
|
|
#include "zend_strtod.h"
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2007-09-27 23:53:28 +08:00
|
|
|
static HashTable *registered_zend_ini_directives;
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2002-09-03 18:06:13 +08:00
|
|
|
#define NO_VALUE_PLAINTEXT "no value"
|
|
|
|
#define NO_VALUE_HTML "<i>no value</i>"
|
2000-10-29 19:38:26 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* hash_apply functions
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
static int zend_remove_ini_entries(zval *el, void *arg) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2014-05-25 19:56:51 +08:00
|
|
|
zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
|
2014-05-26 11:05:04 +08:00
|
|
|
int module_number = *(int *)arg;
|
|
|
|
if (ini_entry->module_number == module_number) {
|
2000-10-29 19:38:26 +08:00
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2009-07-16 08:02:19 +08:00
|
|
|
int result = FAILURE;
|
2009-07-16 20:25:17 +08:00
|
|
|
|
2000-10-29 19:38:26 +08:00
|
|
|
if (ini_entry->modified) {
|
|
|
|
if (ini_entry->on_modify) {
|
2005-04-12 21:06:39 +08:00
|
|
|
zend_try {
|
|
|
|
/* even if on_modify bails out, we have to continue on with restoring,
|
|
|
|
since there can be allocated variables that would be freed on MM shutdown
|
2007-09-27 23:53:28 +08:00
|
|
|
and would lead to memory corruption later ini entry is modified again */
|
2014-12-14 06:06:14 +08:00
|
|
|
result = ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage);
|
2005-04-12 21:06:39 +08:00
|
|
|
} zend_end_try();
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
2009-07-16 20:25:17 +08:00
|
|
|
if (stage == ZEND_INI_STAGE_RUNTIME && result == FAILURE) {
|
2009-07-16 08:02:19 +08:00
|
|
|
/* runtime failure is OK */
|
|
|
|
return 1;
|
|
|
|
}
|
2007-06-17 22:31:12 +08:00
|
|
|
if (ini_entry->value != ini_entry->orig_value) {
|
2014-09-02 00:57:33 +08:00
|
|
|
zend_string_release(ini_entry->value);
|
2007-06-17 22:31:12 +08:00
|
|
|
}
|
2000-10-29 19:38:26 +08:00
|
|
|
ini_entry->value = ini_entry->orig_value;
|
2008-03-14 00:01:31 +08:00
|
|
|
ini_entry->modifiable = ini_entry->orig_modifiable;
|
2000-10-29 19:38:26 +08:00
|
|
|
ini_entry->modified = 0;
|
|
|
|
ini_entry->orig_value = NULL;
|
2008-03-14 00:01:31 +08:00
|
|
|
ini_entry->orig_modifiable = 0;
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static int zend_restore_ini_entry_wrapper(zval *el) /* {{{ */
|
2006-05-15 22:52:35 +08:00
|
|
|
{
|
2014-05-25 18:32:35 +08:00
|
|
|
zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_restore_ini_entry_cb(ini_entry, ZEND_INI_STAGE_DEACTIVATE);
|
2006-05-15 22:52:35 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2006-05-15 22:52:35 +08:00
|
|
|
|
2014-09-02 18:11:22 +08:00
|
|
|
static void free_ini_entry(zval *zv) /* {{{ */
|
2014-02-17 21:59:18 +08:00
|
|
|
{
|
2014-09-02 18:11:22 +08:00
|
|
|
zend_ini_entry *entry = (zend_ini_entry*)Z_PTR_P(zv);
|
|
|
|
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(entry->name, 1);
|
2014-09-02 18:11:22 +08:00
|
|
|
if (entry->value) {
|
|
|
|
zend_string_release(entry->value);
|
|
|
|
}
|
|
|
|
if (entry->orig_value) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(entry->orig_value, 1);
|
2014-09-02 18:11:22 +08:00
|
|
|
}
|
|
|
|
free(entry);
|
2014-02-17 21:59:18 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2000-10-29 19:38:26 +08:00
|
|
|
/*
|
|
|
|
* Startup / shutdown
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API int zend_ini_startup(void) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2002-09-24 01:20:59 +08:00
|
|
|
registered_zend_ini_directives = (HashTable *) malloc(sizeof(HashTable));
|
|
|
|
|
|
|
|
EG(ini_directives) = registered_zend_ini_directives;
|
2006-05-15 22:52:35 +08:00
|
|
|
EG(modified_ini_directives) = NULL;
|
2010-08-18 21:58:13 +08:00
|
|
|
EG(error_reporting_ini_entry) = NULL;
|
2014-09-02 18:11:22 +08:00
|
|
|
zend_hash_init_ex(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1, 0);
|
2000-10-29 19:38:26 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-12-16 17:15:02 +08:00
|
|
|
ZEND_API int zend_ini_shutdown(void) /* {{{ */
|
|
|
|
{
|
|
|
|
zend_ini_dtor(EG(ini_directives));
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
ZEND_API void zend_ini_dtor(HashTable *ini_directives) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2014-12-16 16:12:09 +08:00
|
|
|
zend_hash_destroy(ini_directives);
|
|
|
|
free(ini_directives);
|
2003-01-12 20:39:06 +08:00
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2003-01-12 20:39:06 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API int zend_ini_global_shutdown(void) /* {{{ */
|
2003-01-12 20:39:06 +08:00
|
|
|
{
|
|
|
|
zend_hash_destroy(registered_zend_ini_directives);
|
|
|
|
free(registered_zend_ini_directives);
|
2000-10-29 19:38:26 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API int zend_ini_deactivate(void) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2006-05-15 22:52:35 +08:00
|
|
|
if (EG(modified_ini_directives)) {
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_hash_apply(EG(modified_ini_directives), zend_restore_ini_entry_wrapper);
|
2006-05-15 22:52:35 +08:00
|
|
|
zend_hash_destroy(EG(modified_ini_directives));
|
|
|
|
FREE_HASHTABLE(EG(modified_ini_directives));
|
|
|
|
EG(modified_ini_directives) = NULL;
|
|
|
|
}
|
2000-12-27 23:43:15 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-12-27 23:43:15 +08:00
|
|
|
|
2002-09-24 01:20:59 +08:00
|
|
|
#ifdef ZTS
|
2014-09-02 18:11:22 +08:00
|
|
|
static void copy_ini_entry(zval *zv) /* {{{ */
|
|
|
|
{
|
|
|
|
zend_ini_entry *old_entry = (zend_ini_entry*)Z_PTR_P(zv);
|
|
|
|
zend_ini_entry *new_entry = pemalloc(sizeof(zend_ini_entry), 1);
|
|
|
|
|
|
|
|
Z_PTR_P(zv) = new_entry;
|
|
|
|
memcpy(new_entry, old_entry, sizeof(zend_ini_entry));
|
|
|
|
if (old_entry->name) {
|
2017-10-31 07:16:46 +08:00
|
|
|
new_entry->name = zend_string_dup(old_entry->name, 1);
|
2014-09-02 18:11:22 +08:00
|
|
|
}
|
|
|
|
if (old_entry->value) {
|
2017-10-31 07:16:46 +08:00
|
|
|
new_entry->value = zend_string_dup(old_entry->value, 1);
|
2014-09-02 18:11:22 +08:00
|
|
|
}
|
|
|
|
if (old_entry->orig_value) {
|
2017-10-31 07:16:46 +08:00
|
|
|
new_entry->orig_value = zend_string_dup(old_entry->orig_value, 1);
|
2014-09-02 18:11:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API int zend_copy_ini_directives(void) /* {{{ */
|
2000-12-27 23:43:15 +08:00
|
|
|
{
|
2006-05-19 23:31:25 +08:00
|
|
|
EG(modified_ini_directives) = NULL;
|
2010-08-18 21:58:13 +08:00
|
|
|
EG(error_reporting_ini_entry) = NULL;
|
2002-09-24 01:20:59 +08:00
|
|
|
EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
|
2014-09-02 18:11:22 +08:00
|
|
|
zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1, 0);
|
|
|
|
zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, copy_ini_entry);
|
2000-10-29 19:38:26 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2002-09-24 01:20:59 +08:00
|
|
|
#endif
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static int ini_key_compare(const void *a, const void *b) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2010-10-15 05:33:10 +08:00
|
|
|
const Bucket *f;
|
|
|
|
const Bucket *s;
|
2007-09-27 23:53:28 +08:00
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
f = (const Bucket *) a;
|
|
|
|
s = (const Bucket *) b;
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
if (!f->key && !s->key) { /* both numeric */
|
2017-11-18 04:35:22 +08:00
|
|
|
if (f->h > s->h) {
|
|
|
|
return -1;
|
|
|
|
} else if (f->h < s->h) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2014-02-10 14:04:30 +08:00
|
|
|
} else if (!f->key) { /* f is numeric, s is not */
|
2000-10-29 19:38:26 +08:00
|
|
|
return -1;
|
2014-02-10 14:04:30 +08:00
|
|
|
} else if (!s->key) { /* s is numeric, f is not */
|
2000-10-29 19:38:26 +08:00
|
|
|
return 1;
|
|
|
|
} else { /* both strings */
|
2015-06-30 18:59:27 +08:00
|
|
|
return zend_binary_strcasecmp(ZSTR_VAL(f->key), ZSTR_LEN(f->key), ZSTR_VAL(s->key), ZSTR_LEN(s->key));
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API void zend_ini_sort_entries(void) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2015-01-14 17:22:58 +08:00
|
|
|
zend_hash_sort(EG(ini_directives), ini_key_compare, 0);
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Registration / unregistration
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2014-09-02 00:57:33 +08:00
|
|
|
zend_ini_entry *p;
|
|
|
|
zval *default_value;
|
2004-07-29 06:56:01 +08:00
|
|
|
HashTable *directives = registered_zend_ini_directives;
|
|
|
|
|
|
|
|
#ifdef ZTS
|
|
|
|
/* if we are called during the request, eg: from dl(),
|
|
|
|
* then we should not touch the global directives table,
|
|
|
|
* and should update the per-(request|thread) version instead.
|
|
|
|
* This solves two problems: one is that ini entries for dl()'d
|
|
|
|
* extensions will now work, and the second is that updating the
|
|
|
|
* global hash here from dl() is not mutex protected and can
|
|
|
|
* lead to death.
|
|
|
|
*/
|
|
|
|
if (directives != EG(ini_directives)) {
|
|
|
|
directives = EG(ini_directives);
|
|
|
|
}
|
|
|
|
#endif
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-09-02 00:57:33 +08:00
|
|
|
while (ini_entry->name) {
|
|
|
|
p = pemalloc(sizeof(zend_ini_entry), 1);
|
2017-10-31 07:16:46 +08:00
|
|
|
p->name = zend_string_init_interned(ini_entry->name, ini_entry->name_length, 1);
|
2014-09-02 00:57:33 +08:00
|
|
|
p->on_modify = ini_entry->on_modify;
|
|
|
|
p->mh_arg1 = ini_entry->mh_arg1;
|
|
|
|
p->mh_arg2 = ini_entry->mh_arg2;
|
|
|
|
p->mh_arg3 = ini_entry->mh_arg3;
|
2014-09-02 18:11:22 +08:00
|
|
|
p->value = NULL;
|
2014-09-02 00:57:33 +08:00
|
|
|
p->orig_value = NULL;
|
|
|
|
p->displayer = ini_entry->displayer;
|
|
|
|
p->modifiable = ini_entry->modifiable;
|
|
|
|
|
|
|
|
p->orig_modifiable = 0;
|
|
|
|
p->modified = 0;
|
|
|
|
p->module_number = module_number;
|
|
|
|
|
|
|
|
if (zend_hash_add_ptr(directives, p->name, (void*)p) == NULL) {
|
2014-09-02 13:46:27 +08:00
|
|
|
if (p->name) {
|
2018-05-28 21:27:12 +08:00
|
|
|
zend_string_release_ex(p->name, 1);
|
2014-09-02 13:46:27 +08:00
|
|
|
}
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_unregister_ini_entries(module_number);
|
2000-10-29 19:38:26 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
2014-09-02 18:11:22 +08:00
|
|
|
if (((default_value = zend_get_configuration_directive(p->name)) != NULL) &&
|
2014-12-14 06:06:14 +08:00
|
|
|
(!p->on_modify || p->on_modify(p, Z_STR_P(default_value), p->mh_arg1, p->mh_arg2, p->mh_arg3, ZEND_INI_STAGE_STARTUP) == SUCCESS)) {
|
2015-01-03 17:22:58 +08:00
|
|
|
|
2017-10-31 07:16:46 +08:00
|
|
|
p->value = zend_new_interned_string(zend_string_copy(Z_STR_P(default_value)));
|
2014-09-02 18:11:22 +08:00
|
|
|
} else {
|
|
|
|
p->value = ini_entry->value ?
|
2017-10-31 07:16:46 +08:00
|
|
|
zend_string_init_interned(ini_entry->value, ini_entry->value_length, 1) : NULL;
|
2005-09-03 04:51:15 +08:00
|
|
|
|
2014-09-02 18:11:22 +08:00
|
|
|
if (p->on_modify) {
|
2014-12-14 06:06:14 +08:00
|
|
|
p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, ZEND_INI_STAGE_STARTUP);
|
2014-09-02 18:11:22 +08:00
|
|
|
}
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
2014-09-02 00:57:33 +08:00
|
|
|
ini_entry++;
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API void zend_unregister_ini_entries(int module_number) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_hash_apply_with_argument(registered_zend_ini_directives, zend_remove_ini_entries, (void *) &module_number);
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2006-11-08 19:04:27 +08:00
|
|
|
#ifdef ZTS
|
2014-12-14 06:06:14 +08:00
|
|
|
static int zend_ini_refresh_cache(zval *el, void *arg) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2014-05-25 19:56:51 +08:00
|
|
|
zend_ini_entry *p = (zend_ini_entry *)Z_PTR_P(el);
|
2014-08-15 03:53:27 +08:00
|
|
|
int stage = (int)(zend_intptr_t)arg;
|
|
|
|
|
2000-10-29 19:38:26 +08:00
|
|
|
if (p->on_modify) {
|
2014-12-14 06:06:14 +08:00
|
|
|
p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage);
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API void zend_ini_refresh_caches(int stage) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_hash_apply_with_argument(EG(ini_directives), zend_ini_refresh_cache, (void *)(zend_intptr_t) stage);
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2006-11-08 19:04:27 +08:00
|
|
|
#endif
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-09-02 00:57:33 +08:00
|
|
|
ZEND_API int zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */
|
2007-09-07 17:59:50 +08:00
|
|
|
{
|
2007-09-28 01:05:23 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
return zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0);
|
2014-09-02 00:57:33 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
ZEND_API int zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage) /* {{{ */
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
zend_string *new_value;
|
|
|
|
|
2017-11-08 17:01:59 +08:00
|
|
|
new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST));
|
2014-12-14 06:06:14 +08:00
|
|
|
ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0);
|
2014-09-02 00:57:33 +08:00
|
|
|
zend_string_release(new_value);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */
|
2014-09-02 00:57:33 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
zend_string *new_value;
|
|
|
|
|
2017-11-08 17:01:59 +08:00
|
|
|
new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST));
|
2014-12-14 06:06:14 +08:00
|
|
|
ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, force_change);
|
2014-09-02 00:57:33 +08:00
|
|
|
zend_string_release(new_value);
|
|
|
|
return ret;
|
2007-09-07 17:59:50 +08:00
|
|
|
}
|
2007-09-07 18:00:45 +08:00
|
|
|
/* }}} */
|
2007-09-07 17:59:50 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, int force_change) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
zend_ini_entry *ini_entry;
|
2014-09-02 00:57:33 +08:00
|
|
|
zend_string *duplicate;
|
2008-03-14 00:01:31 +08:00
|
|
|
zend_bool modifiable;
|
2007-06-17 22:31:12 +08:00
|
|
|
zend_bool modified;
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
if ((ini_entry = zend_hash_find_ptr(EG(ini_directives), name)) == NULL) {
|
2000-10-29 19:38:26 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2008-03-14 00:01:31 +08:00
|
|
|
modifiable = ini_entry->modifiable;
|
|
|
|
modified = ini_entry->modified;
|
|
|
|
|
2007-08-31 15:52:29 +08:00
|
|
|
if (stage == ZEND_INI_STAGE_ACTIVATE && modify_type == ZEND_INI_SYSTEM) {
|
|
|
|
ini_entry->modifiable = ZEND_INI_SYSTEM;
|
|
|
|
}
|
|
|
|
|
2007-09-07 17:37:38 +08:00
|
|
|
if (!force_change) {
|
|
|
|
if (!(ini_entry->modifiable & modify_type)) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
|
2007-06-17 22:31:12 +08:00
|
|
|
if (!EG(modified_ini_directives)) {
|
|
|
|
ALLOC_HASHTABLE(EG(modified_ini_directives));
|
|
|
|
zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
|
|
|
|
}
|
|
|
|
if (!modified) {
|
|
|
|
ini_entry->orig_value = ini_entry->value;
|
2008-03-14 00:01:31 +08:00
|
|
|
ini_entry->orig_modifiable = modifiable;
|
2007-06-17 22:31:12 +08:00
|
|
|
ini_entry->modified = 1;
|
2017-03-04 17:39:13 +08:00
|
|
|
zend_hash_add_ptr(EG(modified_ini_directives), ini_entry->name, ini_entry);
|
2007-06-08 22:47:45 +08:00
|
|
|
}
|
|
|
|
|
2014-09-02 00:57:33 +08:00
|
|
|
duplicate = zend_string_copy(new_value);
|
2007-06-17 22:31:12 +08:00
|
|
|
|
2000-10-29 19:38:26 +08:00
|
|
|
if (!ini_entry->on_modify
|
2014-12-14 06:06:14 +08:00
|
|
|
|| ini_entry->on_modify(ini_entry, duplicate, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage) == SUCCESS) {
|
2007-06-17 22:31:12 +08:00
|
|
|
if (modified && ini_entry->orig_value != ini_entry->value) { /* we already changed the value, free the changed value */
|
2014-09-02 00:57:33 +08:00
|
|
|
zend_string_release(ini_entry->value);
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
ini_entry->value = duplicate;
|
|
|
|
} else {
|
2014-09-02 00:57:33 +08:00
|
|
|
zend_string_release(duplicate);
|
2008-12-09 18:11:21 +08:00
|
|
|
return FAILURE;
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
ZEND_API int zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
zend_ini_entry *ini_entry;
|
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
if ((ini_entry = zend_hash_find_ptr(EG(ini_directives), name)) == NULL ||
|
2007-09-27 23:53:28 +08:00
|
|
|
(stage == ZEND_INI_STAGE_RUNTIME && (ini_entry->modifiable & ZEND_INI_USER) == 0)) {
|
2000-10-29 19:38:26 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2006-05-15 22:52:35 +08:00
|
|
|
if (EG(modified_ini_directives)) {
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_restore_ini_entry_cb(ini_entry, stage) == 0) {
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_hash_del(EG(modified_ini_directives), name);
|
2009-07-17 08:48:59 +08:00
|
|
|
} else {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
2006-05-15 22:52:35 +08:00
|
|
|
}
|
2007-09-27 23:53:28 +08:00
|
|
|
|
2000-10-29 19:38:26 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2016-11-26 22:18:42 +08:00
|
|
|
ZEND_API int zend_ini_register_displayer(char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
zend_ini_entry *ini_entry;
|
|
|
|
|
2015-01-03 17:22:58 +08:00
|
|
|
ini_entry = zend_hash_str_find_ptr(registered_zend_ini_directives, name, name_length);
|
2014-02-10 14:04:30 +08:00
|
|
|
if (ini_entry == NULL) {
|
2000-10-29 19:38:26 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ini_entry->displayer = displayer;
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Data retrieval
|
|
|
|
*/
|
|
|
|
|
2017-10-23 01:58:42 +08:00
|
|
|
ZEND_API zend_long zend_ini_long(char *name, size_t name_length, int orig) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
zend_ini_entry *ini_entry;
|
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
|
|
|
|
if (ini_entry) {
|
2000-10-29 19:38:26 +08:00
|
|
|
if (orig && ini_entry->modified) {
|
2015-06-30 18:59:27 +08:00
|
|
|
return (ini_entry->orig_value ? ZEND_STRTOL(ZSTR_VAL(ini_entry->orig_value), NULL, 0) : 0);
|
2007-09-28 01:05:23 +08:00
|
|
|
} else {
|
2015-06-30 18:59:27 +08:00
|
|
|
return (ini_entry->value ? ZEND_STRTOL(ZSTR_VAL(ini_entry->value), NULL, 0) : 0);
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2017-10-23 01:58:42 +08:00
|
|
|
ZEND_API double zend_ini_double(char *name, size_t name_length, int orig) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
zend_ini_entry *ini_entry;
|
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
|
|
|
|
if (ini_entry) {
|
2000-10-29 19:38:26 +08:00
|
|
|
if (orig && ini_entry->modified) {
|
2015-06-30 18:59:27 +08:00
|
|
|
return (double) (ini_entry->orig_value ? zend_strtod(ZSTR_VAL(ini_entry->orig_value), NULL) : 0.0);
|
2007-09-28 01:05:23 +08:00
|
|
|
} else {
|
2015-06-30 18:59:27 +08:00
|
|
|
return (double) (ini_entry->value ? zend_strtod(ZSTR_VAL(ini_entry->value), NULL) : 0.0);
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2017-10-23 01:58:42 +08:00
|
|
|
ZEND_API char *zend_ini_string_ex(char *name, size_t name_length, int orig, zend_bool *exists) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
zend_ini_entry *ini_entry;
|
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
|
|
|
|
if (ini_entry) {
|
2008-07-08 05:37:46 +08:00
|
|
|
if (exists) {
|
|
|
|
*exists = 1;
|
|
|
|
}
|
|
|
|
|
2000-10-29 19:38:26 +08:00
|
|
|
if (orig && ini_entry->modified) {
|
2015-06-30 18:59:27 +08:00
|
|
|
return ini_entry->orig_value ? ZSTR_VAL(ini_entry->orig_value) : NULL;
|
2000-10-29 19:38:26 +08:00
|
|
|
} else {
|
2015-06-30 18:59:27 +08:00
|
|
|
return ini_entry->value ? ZSTR_VAL(ini_entry->value) : NULL;
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
2008-07-08 05:50:56 +08:00
|
|
|
} else {
|
|
|
|
if (exists) {
|
|
|
|
*exists = 0;
|
|
|
|
}
|
2007-09-28 01:05:23 +08:00
|
|
|
return NULL;
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2017-10-23 01:58:42 +08:00
|
|
|
ZEND_API char *zend_ini_string(char *name, size_t name_length, int orig) /* {{{ */
|
2008-07-08 05:37:46 +08:00
|
|
|
{
|
|
|
|
zend_bool exists = 1;
|
|
|
|
char *return_value;
|
|
|
|
|
|
|
|
return_value = zend_ini_string_ex(name, name_length, orig, &exists);
|
|
|
|
if (!exists) {
|
|
|
|
return NULL;
|
|
|
|
} else if (!return_value) {
|
|
|
|
return_value = "";
|
|
|
|
}
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2017-12-11 23:18:30 +08:00
|
|
|
ZEND_API zend_string *zend_ini_get_value(zend_string *name) /* {{{ */
|
|
|
|
{
|
|
|
|
zend_ini_entry *ini_entry;
|
|
|
|
|
|
|
|
ini_entry = zend_hash_find_ptr(EG(ini_directives), name);
|
|
|
|
if (ini_entry) {
|
|
|
|
return ini_entry->value ? ini_entry->value : ZSTR_EMPTY_ALLOC();
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2018-03-05 16:51:58 +08:00
|
|
|
ZEND_API zend_bool zend_ini_parse_bool(zend_string *str)
|
|
|
|
{
|
|
|
|
if ((ZSTR_LEN(str) == 4 && strcasecmp(ZSTR_VAL(str), "true") == 0)
|
|
|
|
|| (ZSTR_LEN(str) == 3 && strcasecmp(ZSTR_VAL(str), "yes") == 0)
|
|
|
|
|| (ZSTR_LEN(str) == 2 && strcasecmp(ZSTR_VAL(str), "on") == 0)) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return atoi(ZSTR_VAL(str)) != 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-27 23:53:28 +08:00
|
|
|
#if TONY_20070307
|
2007-09-07 17:35:06 +08:00
|
|
|
static void zend_ini_displayer_cb(zend_ini_entry *ini_entry, int type) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
if (ini_entry->displayer) {
|
|
|
|
ini_entry->displayer(ini_entry, type);
|
|
|
|
} else {
|
|
|
|
char *display_string;
|
2016-11-26 22:18:42 +08:00
|
|
|
uint32_t display_string_length;
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2007-09-27 23:56:49 +08:00
|
|
|
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
|
2000-10-29 19:38:26 +08:00
|
|
|
if (ini_entry->orig_value) {
|
|
|
|
display_string = ini_entry->orig_value;
|
|
|
|
display_string_length = ini_entry->orig_value_length;
|
|
|
|
} else {
|
2002-09-15 15:45:26 +08:00
|
|
|
if (zend_uv.html_errors) {
|
2002-09-03 18:06:13 +08:00
|
|
|
display_string = NO_VALUE_HTML;
|
2007-09-27 23:59:42 +08:00
|
|
|
display_string_length = sizeof(NO_VALUE_HTML) - 1;
|
2002-09-03 18:06:13 +08:00
|
|
|
} else {
|
|
|
|
display_string = NO_VALUE_PLAINTEXT;
|
2007-09-27 23:59:42 +08:00
|
|
|
display_string_length = sizeof(NO_VALUE_PLAINTEXT) - 1;
|
2007-09-27 23:53:28 +08:00
|
|
|
}
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
} else if (ini_entry->value && ini_entry->value[0]) {
|
|
|
|
display_string = ini_entry->value;
|
|
|
|
display_string_length = ini_entry->value_length;
|
|
|
|
} else {
|
2002-09-15 15:45:26 +08:00
|
|
|
if (zend_uv.html_errors) {
|
2002-09-03 18:06:13 +08:00
|
|
|
display_string = NO_VALUE_HTML;
|
2007-09-27 23:59:42 +08:00
|
|
|
display_string_length = sizeof(NO_VALUE_HTML) - 1;
|
2002-09-03 18:06:13 +08:00
|
|
|
} else {
|
|
|
|
display_string = NO_VALUE_PLAINTEXT;
|
2007-09-27 23:59:42 +08:00
|
|
|
display_string_length = sizeof(NO_VALUE_PLAINTEXT) - 1;
|
2007-09-27 23:53:28 +08:00
|
|
|
}
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
ZEND_WRITE(display_string, display_string_length);
|
|
|
|
}
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2007-03-07 05:08:05 +08:00
|
|
|
#endif
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2007-09-07 17:35:06 +08:00
|
|
|
ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2014-09-02 00:57:33 +08:00
|
|
|
int value;
|
|
|
|
zend_string *tmp_value;
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2007-09-27 23:53:28 +08:00
|
|
|
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
|
2005-06-22 20:02:47 +08:00
|
|
|
tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
|
2000-10-29 19:38:26 +08:00
|
|
|
} else if (ini_entry->value) {
|
2005-06-22 20:02:47 +08:00
|
|
|
tmp_value = ini_entry->value;
|
2000-10-29 19:38:26 +08:00
|
|
|
} else {
|
2005-06-22 20:02:47 +08:00
|
|
|
tmp_value = NULL;
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
2005-06-22 20:02:47 +08:00
|
|
|
|
2007-10-01 22:51:11 +08:00
|
|
|
if (tmp_value) {
|
2018-03-05 16:51:58 +08:00
|
|
|
value = zend_ini_parse_bool(tmp_value);
|
2007-09-21 22:17:06 +08:00
|
|
|
} else {
|
|
|
|
value = 0;
|
2005-06-22 20:02:47 +08:00
|
|
|
}
|
2007-09-27 23:53:28 +08:00
|
|
|
|
2000-10-29 19:38:26 +08:00
|
|
|
if (value) {
|
|
|
|
ZEND_PUTS("On");
|
|
|
|
} else {
|
|
|
|
ZEND_PUTS("Off");
|
|
|
|
}
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2007-09-07 17:35:06 +08:00
|
|
|
ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
char *value;
|
|
|
|
|
2007-09-27 23:53:28 +08:00
|
|
|
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
|
2015-06-30 18:59:27 +08:00
|
|
|
value = ZSTR_VAL(ini_entry->orig_value);
|
2000-10-29 19:38:26 +08:00
|
|
|
} else if (ini_entry->value) {
|
2015-06-30 18:59:27 +08:00
|
|
|
value = ZSTR_VAL(ini_entry->value);
|
2000-10-29 19:38:26 +08:00
|
|
|
} else {
|
|
|
|
value = NULL;
|
|
|
|
}
|
|
|
|
if (value) {
|
2002-09-03 18:06:13 +08:00
|
|
|
if (zend_uv.html_errors) {
|
2002-09-20 06:23:56 +08:00
|
|
|
zend_printf("<font style=\"color: %s\">%s</font>", value, value);
|
2002-09-03 18:06:13 +08:00
|
|
|
} else {
|
|
|
|
ZEND_PUTS(value);
|
2007-09-27 23:53:28 +08:00
|
|
|
}
|
2000-10-29 19:38:26 +08:00
|
|
|
} else {
|
2002-09-03 18:06:13 +08:00
|
|
|
if (zend_uv.html_errors) {
|
|
|
|
ZEND_PUTS(NO_VALUE_HTML);
|
|
|
|
} else {
|
|
|
|
ZEND_PUTS(NO_VALUE_PLAINTEXT);
|
2007-09-27 23:53:28 +08:00
|
|
|
}
|
2000-10-29 19:38:26 +08:00
|
|
|
}
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2007-09-07 17:35:06 +08:00
|
|
|
ZEND_INI_DISP(display_link_numbers) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
char *value;
|
|
|
|
|
2007-09-27 23:53:28 +08:00
|
|
|
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
|
2015-06-30 18:59:27 +08:00
|
|
|
value = ZSTR_VAL(ini_entry->orig_value);
|
2000-10-29 19:38:26 +08:00
|
|
|
} else if (ini_entry->value) {
|
2015-06-30 18:59:27 +08:00
|
|
|
value = ZSTR_VAL(ini_entry->value);
|
2000-10-29 19:38:26 +08:00
|
|
|
} else {
|
|
|
|
value = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value) {
|
2007-09-27 23:53:28 +08:00
|
|
|
if (atoi(value) == -1) {
|
2000-10-29 19:38:26 +08:00
|
|
|
ZEND_PUTS("Unlimited");
|
|
|
|
} else {
|
|
|
|
zend_printf("%s", value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
|
|
|
/* Standard message handlers */
|
2007-09-07 17:35:06 +08:00
|
|
|
ZEND_API ZEND_INI_MH(OnUpdateBool) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
zend_bool *p;
|
|
|
|
#ifndef ZTS
|
|
|
|
char *base = (char *) mh_arg2;
|
|
|
|
#else
|
|
|
|
char *base;
|
|
|
|
|
|
|
|
base = (char *) ts_resource(*((int *) mh_arg2));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
p = (zend_bool *) (base+(size_t) mh_arg1);
|
|
|
|
|
2018-03-05 16:51:58 +08:00
|
|
|
*p = zend_ini_parse_bool(new_value);
|
2000-10-29 19:38:26 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2007-09-07 17:35:06 +08:00
|
|
|
ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_long *p;
|
2000-10-29 19:38:26 +08:00
|
|
|
#ifndef ZTS
|
|
|
|
char *base = (char *) mh_arg2;
|
|
|
|
#else
|
|
|
|
char *base;
|
|
|
|
|
|
|
|
base = (char *) ts_resource(*((int *) mh_arg2));
|
|
|
|
#endif
|
|
|
|
|
2014-08-26 01:24:55 +08:00
|
|
|
p = (zend_long *) (base+(size_t) mh_arg1);
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2017-07-28 20:54:01 +08:00
|
|
|
*p = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
|
2000-10-29 19:38:26 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-28 00:44:27 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2007-09-28 00:44:27 +08:00
|
|
|
ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */
|
2006-12-26 07:55:59 +08:00
|
|
|
{
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_long *p, tmp;
|
2006-12-26 07:55:59 +08:00
|
|
|
#ifndef ZTS
|
|
|
|
char *base = (char *) mh_arg2;
|
|
|
|
#else
|
|
|
|
char *base;
|
|
|
|
|
|
|
|
base = (char *) ts_resource(*((int *) mh_arg2));
|
|
|
|
#endif
|
|
|
|
|
2017-07-28 20:54:01 +08:00
|
|
|
tmp = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
|
2006-12-26 07:55:59 +08:00
|
|
|
if (tmp < 0) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-08-26 01:24:55 +08:00
|
|
|
p = (zend_long *) (base+(size_t) mh_arg1);
|
2006-12-26 07:55:59 +08:00
|
|
|
*p = tmp;
|
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2006-12-26 07:55:59 +08:00
|
|
|
|
2007-09-07 17:35:06 +08:00
|
|
|
ZEND_API ZEND_INI_MH(OnUpdateReal) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
double *p;
|
|
|
|
#ifndef ZTS
|
|
|
|
char *base = (char *) mh_arg2;
|
|
|
|
#else
|
|
|
|
char *base;
|
|
|
|
|
|
|
|
base = (char *) ts_resource(*((int *) mh_arg2));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
p = (double *) (base+(size_t) mh_arg1);
|
|
|
|
|
2015-06-30 18:59:27 +08:00
|
|
|
*p = zend_strtod(ZSTR_VAL(new_value), NULL);
|
2000-10-29 19:38:26 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2007-09-07 17:35:06 +08:00
|
|
|
ZEND_API ZEND_INI_MH(OnUpdateString) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
char **p;
|
|
|
|
#ifndef ZTS
|
|
|
|
char *base = (char *) mh_arg2;
|
|
|
|
#else
|
|
|
|
char *base;
|
|
|
|
|
|
|
|
base = (char *) ts_resource(*((int *) mh_arg2));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
p = (char **) (base+(size_t) mh_arg1);
|
|
|
|
|
2015-06-30 18:59:27 +08:00
|
|
|
*p = new_value ? ZSTR_VAL(new_value) : NULL;
|
2000-10-29 19:38:26 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
2007-09-07 17:35:06 +08:00
|
|
|
ZEND_API ZEND_INI_MH(OnUpdateStringUnempty) /* {{{ */
|
2000-10-29 19:38:26 +08:00
|
|
|
{
|
|
|
|
char **p;
|
|
|
|
#ifndef ZTS
|
|
|
|
char *base = (char *) mh_arg2;
|
|
|
|
#else
|
|
|
|
char *base;
|
|
|
|
|
|
|
|
base = (char *) ts_resource(*((int *) mh_arg2));
|
|
|
|
#endif
|
|
|
|
|
2015-06-30 18:59:27 +08:00
|
|
|
if (new_value && !ZSTR_VAL(new_value)[0]) {
|
2000-10-29 19:38:26 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = (char **) (base+(size_t) mh_arg1);
|
|
|
|
|
2015-06-30 18:59:27 +08:00
|
|
|
*p = new_value ? ZSTR_VAL(new_value) : NULL;
|
2000-10-29 19:38:26 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-09-07 17:35:06 +08:00
|
|
|
/* }}} */
|
2000-10-29 19:38:26 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
2003-02-01 09:49:15 +08:00
|
|
|
* indent-tabs-mode: t
|
2000-10-29 19:38:26 +08:00
|
|
|
* End:
|
2017-07-05 00:12:45 +08:00
|
|
|
* vim600: sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: sw=4 ts=4
|
2000-10-29 19:38:26 +08:00
|
|
|
*/
|