30static HashTable *registered_zend_ini_directives;
32#define NO_VALUE_PLAINTEXT "no value"
33#define NO_VALUE_HTML "<i>no value</i>"
35static inline bool zend_is_whitespace(
char c) {
36 return c ==
' ' || c ==
'\t' || c ==
'\n' || c ==
'\r' || c ==
'\v' || c ==
'\f';
42static int zend_remove_ini_entries(
zval *el,
void *
arg)
45 int module_number = *(
int *)
arg;
56 if (ini_entry->on_modify) {
69 zend_string_release(ini_entry->
value);
81static void free_ini_entry(
zval *
zv)
87 zend_string_release(entry->
value);
103 EG(ini_directives) = registered_zend_ini_directives;
104 EG(modified_ini_directives) =
NULL;
105 EG(error_reporting_ini_entry) =
NULL;
119 free(ini_directives);
126 free(registered_zend_ini_directives);
132 if (
EG(modified_ini_directives)) {
140 EG(modified_ini_directives) =
NULL;
146static void copy_ini_entry(
zval *
zv)
153 if (old_entry->
name) {
154 new_entry->
name = zend_string_dup(old_entry->
name, 1);
156 if (old_entry->
value) {
157 new_entry->
value = zend_string_dup(old_entry->
value, 1);
167 EG(modified_ini_directives) =
NULL;
168 EG(error_reporting_ini_entry) =
NULL;
170 zend_hash_init(
EG(ini_directives), registered_zend_ini_directives->nNumOfElements,
NULL, free_ini_entry, 1);
171 zend_hash_copy(
EG(ini_directives), registered_zend_ini_directives, copy_ini_entry);
178 if (!f->
key && !
s->key) {
181 }
else if (f->
h <
s->h) {
185 }
else if (!f->
key) {
187 }
else if (!
s->key) {
197 zend_hash_sort(
EG(ini_directives), ini_key_compare, 0);
208 HashTable *directives = registered_zend_ini_directives;
219 if (directives !=
EG(ini_directives)) {
220 directives =
EG(ini_directives);
226 while (ini_entry->
name) {
229 p->on_modify = ini_entry->on_modify;
234 p->orig_value =
NULL;
238 p->orig_modifiable = 0;
240 p->module_number = module_number;
242 if (zend_hash_add_ptr(directives,
p->name, (
void*)
p) ==
NULL) {
255 p->value = ini_entry->
value ?
274 if (module->module_number == module_number) {
288 ini_directives =
EG(ini_directives);
290 ini_directives = registered_zend_ini_directives;
303 if (module->module_number == module_number) {
318 p->on_modify(
p,
p->value,
p->mh_arg1,
p->mh_arg2,
p->mh_arg3, stage);
339 zend_string_release(new_value);
351 zend_string_release(new_value);
363 if ((ini_entry = zend_hash_find_ptr(
EG(ini_directives),
name)) ==
NULL) {
380 if (!
EG(modified_ini_directives)) {
388 zend_hash_add_ptr(
EG(modified_ini_directives), ini_entry->
name, ini_entry);
391 duplicate = zend_string_copy(new_value);
393 if (!ini_entry->on_modify
396 zend_string_release(ini_entry->
value);
398 ini_entry->
value = duplicate;
400 zend_string_release(duplicate);
412 if ((ini_entry = zend_hash_find_ptr(
EG(ini_directives),
name)) ==
NULL ||
417 if (
EG(modified_ini_directives)) {
418 if (zend_restore_ini_entry_cb(ini_entry, stage) == 0) {
433 ini_entry = zend_hash_str_find_ptr(registered_zend_ini_directives,
name, name_length);
434 if (ini_entry ==
NULL) {
451 ini_entry = zend_hash_str_find_ptr(
EG(ini_directives),
name, name_length);
468 ini_entry = zend_hash_str_find_ptr(
EG(ini_directives),
name, name_length);
485 ini_entry = zend_hash_str_find_ptr(
EG(ini_directives),
name, name_length);
525 ini_entry = zend_hash_str_find_ptr(
EG(ini_directives),
name, name_length);
564 ini_entry = zend_hash_find_ptr(
EG(ini_directives),
name);
590static const char *zend_ini_consume_quantity_prefix(
const char *
const digits,
const char *
const str_end,
int base) {
591 const char *digits_consumed = digits;
593 while (digits_consumed < str_end && zend_is_whitespace(*digits_consumed)) {++digits_consumed;}
594 if (digits_consumed[0] ==
'+' || digits_consumed[0] ==
'-') {
598 if (digits_consumed[0] ==
'0' && !isdigit(digits_consumed[1])) {
600 if ((digits_consumed+1) == str_end) {
601 return digits_consumed;
604 switch (digits_consumed[1]) {
609 digits_consumed += 2;
615 digits_consumed += 2;
620 return digits_consumed;
625 char *digits_end =
NULL;
629 bool overflow =
false;
637 while (digits < str_end && zend_is_whitespace(*digits)) {++digits;}
640 while (digits < str_end && zend_is_whitespace(*(str_end-1))) {--str_end;}
642 if (digits == str_end) {
647 bool is_negative =
false;
648 if (digits[0] ==
'+') {
650 }
else if (digits[0] ==
'-') {
656 if (!isdigit(digits[0])) {
660 smart_str_0(&invalid);
662 *errstr =
zend_strpprintf(0,
"Invalid quantity \"%s\": no valid leading digits, interpreting as \"0\" for backwards compatibility",
665 smart_str_free(&invalid);
670 if (digits[0] ==
'0' && !isdigit(digits[1])) {
672 if ((digits+1) == str_end) {
699 *errstr =
zend_strpprintf(0,
"Invalid prefix \"0%c\", interpreting as \"0\" for backwards compatibility",
705 if (
UNEXPECTED(digits == str_end || digits != zend_ini_consume_quantity_prefix(digits, str_end, base))) {
709 smart_str_0(&invalid);
711 *errstr =
zend_strpprintf(0,
"Invalid quantity \"%s\": no digits after base prefix, interpreting as \"0\" for backwards compatibility",
714 smart_str_free(&invalid);
723 if (
errno == ERANGE) {
728 if (
retval == 1 && digits_end == str_end) {
740 }
else if (is_negative) {
751 smart_str_0(&invalid);
753 *errstr =
zend_strpprintf(0,
"Invalid quantity \"%s\": no valid leading digits, interpreting as \"0\" for backwards compatibility",
756 smart_str_free(&invalid);
761 while (digits_end < str_end && zend_is_whitespace(*digits_end)) ++digits_end;
764 if (digits_end == str_end) {
768 switch (*(str_end-1)) {
784 smart_str_0(&invalid);
786 smart_str_0(&interpreted);
790 *errstr =
zend_strpprintf(0,
"Invalid quantity \"%s\": unknown multiplier \"%s\", interpreting as \"%s\" for backwards compatibility",
793 smart_str_free(&invalid);
794 smart_str_free(&interpreted);
795 smart_str_free(&
chr);
818 smart_str_0(&invalid);
820 smart_str_0(&interpreted);
824 *errstr =
zend_strpprintf(0,
"Invalid quantity \"%s\", interpreting as \"%s%s\" for backwards compatibility",
827 smart_str_free(&invalid);
828 smart_str_free(&interpreted);
829 smart_str_free(&
chr);
837 smart_str_0(&invalid);
842 *errstr =
zend_strpprintf(0,
"Invalid quantity \"%s\": value is out of range, using overflow result for backwards compatibility",
845 smart_str_free(&invalid);
846 smart_str_free(&interpreted);
847 smart_str_free(&
chr);
876 zend_string_release(errstr);
890 zend_string_release(errstr);
930 }
else if (ini_entry->
value) {
957 }
else if (ini_entry->
value) {
964 if (atoi(
value) == -1) {
1022 if (new_value && !
ZSTR_VAL(new_value)[0]) {
1042 if (new_value &&
ZSTR_LEN(new_value) == 0) {
unsigned const char * end
void(* displayer)(zend_ini_entry *ini_entry, int type)
void(* displayer)(zend_ini_entry *ini_entry, int type)
ZEND_API zval * zend_get_configuration_directive(zend_string *name)
ZEND_API zend_utility_values zend_uv
ZEND_API zend_string * zend_strpprintf(size_t max_len, const char *format,...)
ZEND_API ZEND_COLD void zend_error(int type, const char *format,...)
ZEND_API size_t(* zend_printf)(const char *format,...)
ZEND_API HashTable module_registry
#define pefree(ptr, persistent)
#define pemalloc(size, persistent)
#define FREE_HASHTABLE(ht)
#define ALLOC_HASHTABLE(ht)
zend_string_release_ex(func->internal_function.function_name, 0)
struct _zend_ini_entry zend_ini_entry
ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht)
ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *argument)
ZEND_API void ZEND_FASTCALL zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor)
ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key)
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)
#define ZEND_HASH_MAP_FOREACH_PTR(ht, _ptr)
#define ZEND_HASH_REVERSE_FOREACH_PTR(ht, _ptr)
#define ZEND_HASH_FOREACH_END()
ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change)
ZEND_API zend_ulong zend_ini_parse_uquantity(zend_string *value, zend_string **errstr)
ZEND_API void zend_ini_dtor(HashTable *ini_directives)
ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage)
ZEND_API zend_string * zend_ini_get_value(zend_string *name)
ZEND_API void zend_ini_deactivate(void)
ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_string *setting)
ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number)
ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage)
ZEND_API zend_string * zend_ini_str_ex(const char *name, size_t name_length, bool orig, bool *exists)
ZEND_API char * zend_ini_string_ex(const char *name, size_t name_length, int orig, bool *exists)
ZEND_API void zend_unregister_ini_entries_ex(int module_number, int module_type)
ZEND_API zend_result zend_ini_register_displayer(const char *name, uint32_t name_length, void(*displayer)(zend_ini_entry *ini_entry, int type))
ZEND_API bool zend_ini_parse_bool(zend_string *str)
ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_entry, int module_number, int module_type)
ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string *setting)
ZEND_API char * zend_ini_string(const char *name, size_t name_length, int orig)
ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig)
ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage)
ZEND_API zend_long zend_ini_parse_quantity(zend_string *value, zend_string **errstr)
ZEND_API void zend_ini_shutdown(void)
ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change)
ZEND_API zend_string * zend_ini_str(const char *name, size_t name_length, bool orig)
ZEND_API void zend_unregister_ini_entries(int module_number)
ZEND_API void zend_ini_sort_entries(void)
ZEND_API void zend_ini_global_shutdown(void)
zend_ini_parse_quantity_signed_result_t
@ ZEND_INI_PARSE_QUANTITY_SIGNED
@ ZEND_INI_PARSE_QUANTITY_UNSIGNED
ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig)
ZEND_API void zend_ini_startup(void)
#define NO_VALUE_PLAINTEXT
#define ZEND_INI_STAGE_ACTIVATE
ZEND_API void zend_ini_refresh_caches(int stage)
struct _zend_ini_entry_def zend_ini_entry_def
ZEND_API void zend_copy_ini_directives(void)
#define ZEND_INI_STAGE_STARTUP
#define ZEND_INI_DISPLAY_ORIG
#define ZEND_INI_MH(name)
#define ZEND_INI_DISP(name)
#define ZEND_INI_STAGE_IN_REQUEST
#define ZEND_INI_STAGE_DEACTIVATE
#define ZEND_INI_GET_ADDR()
#define ZEND_INI_STAGE_RUNTIME
#define ZEND_STRTOL(s0, s1, base)
#define ZEND_STRTOUL(s0, s1, base)
struct _zend_string zend_string
struct _zend_module_entry zend_module_entry
#define MODULE_PERSISTENT
ZEND_API int ZEND_FASTCALL zend_binary_strcasecmp(const char *s1, size_t len1, const char *s2, size_t len2)
#define UNEXPECTED(condition)
ZEND_API void ZEND_FASTCALL smart_str_append_escaped(smart_str *str, const char *s, size_t l)
ZEND_API zend_string_init_interned_func_t zend_string_init_interned
ZEND_API zend_new_interned_string_func_t zend_new_interned_string
#define ZSTR_EMPTY_ALLOC()
#define zend_string_equals_literal_ci(str, c)
ZEND_API double zend_strtod(const char *s00, const char **se)
struct _zend_array HashTable
ZEND_RESULT_CODE zend_result