Introduce new INI API to get zend_string* value for an INI setting

This commit is contained in:
George Peter Banyard 2023-01-08 17:03:06 +00:00
parent 20a6638e22
commit 098a43dbd0
No known key found for this signature in database
GPG key ID: 3306078E3194AEBD
2 changed files with 42 additions and 0 deletions

View file

@ -519,6 +519,46 @@ ZEND_API char *zend_ini_string(const char *name, size_t name_length, int orig) /
} }
/* }}} */ /* }}} */
ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool orig, bool *exists) /* {{{ */
{
zend_ini_entry *ini_entry;
ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
if (ini_entry) {
if (exists) {
*exists = 1;
}
if (orig && ini_entry->modified) {
return ini_entry->orig_value ? ini_entry->orig_value : NULL;
} else {
return ini_entry->value ? ini_entry->value : NULL;
}
} else {
if (exists) {
*exists = 0;
}
return NULL;
}
}
/* }}} */
ZEND_API zend_string *zend_ini_str(const char *name, size_t name_length, bool orig) /* {{{ */
{
bool exists = 1;
zend_string *return_value;
return_value = zend_ini_str_ex(name, name_length, orig, &exists);
if (!exists) {
return NULL;
} else if (!return_value) {
return_value = ZSTR_EMPTY_ALLOC();
}
return return_value;
}
/* }}} */
ZEND_API zend_string *zend_ini_get_value(zend_string *name) /* {{{ */ ZEND_API zend_string *zend_ini_get_value(zend_string *name) /* {{{ */
{ {
zend_ini_entry *ini_entry; zend_ini_entry *ini_entry;

View file

@ -99,6 +99,8 @@ ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig)
ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig); ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig);
ZEND_API char *zend_ini_string(const char *name, size_t name_length, int orig); ZEND_API char *zend_ini_string(const char *name, size_t name_length, int orig);
ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig, bool *exists); ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig, bool *exists);
ZEND_API zend_string *zend_ini_str(const char *name, size_t name_length, bool orig);
ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool orig, bool *exists);
ZEND_API zend_string *zend_ini_get_value(zend_string *name); ZEND_API zend_string *zend_ini_get_value(zend_string *name);
ZEND_API bool zend_ini_parse_bool(zend_string *str); ZEND_API bool zend_ini_parse_bool(zend_string *str);