diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-04-10 12:36:50 +0200 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-04-10 12:36:50 +0200 |
commit | ec18c8779c6a806c6cbeb5fe12446955cd688221 (patch) | |
tree | ddc704bac5574d4727560469874019ecc07aed9e /zend | |
parent | f0dec5907bd49bb468089b0fe50d8cbf2979272e (diff) |
refactored ini settings
Diffstat (limited to 'zend')
-rw-r--r-- | zend/extensionimpl.cpp | 23 | ||||
-rw-r--r-- | zend/ini.cpp | 67 | ||||
-rw-r--r-- | zend/namespace.cpp | 15 |
3 files changed, 52 insertions, 53 deletions
diff --git a/zend/extensionimpl.cpp b/zend/extensionimpl.cpp index 0308c63..5e03736 100644 --- a/zend/extensionimpl.cpp +++ b/zend/extensionimpl.cpp @@ -111,16 +111,31 @@ int ExtensionImpl::processStartup(int type, int module_number TSRMLS_DC) // initialize and allocate the "global" variables ZEND_INIT_MODULE_GLOBALS(phpcpp, init_globals, NULL); - // get the extension auto *extension = find(module_number TSRMLS_CC); // array contains ini settings - static zend_ini_entry *ini_entries = new zend_ini_entry[ extension->_data->ini_size()+1 ]; + zend_ini_entry *ini_entries = new zend_ini_entry[extension->_data->iniVariables()+1]; + + // the entry that we're filling + int i=0; - // Filling ini entries - extension->_data->fill_ini(ini_entries, module_number); + // Fill the php.ini entries + extension->_data->iniVariables([ini_entries, &i, module_number](Ini &ini) { + // initialize the function + zend_ini_entry *entry = &ini_entries[i]; + + // fill the property + ini.fill(entry, module_number); + + // move on to the next iteration + i++; + }); + + // last entry should be set to all zero's + memset(&ini_entries[i], 0, sizeof(zend_ini_entry)); + // register ini entries in Zend core REGISTER_INI_ENTRIES(); diff --git a/zend/ini.cpp b/zend/ini.cpp index 0c04d6a..25f081a 100644 --- a/zend/ini.cpp +++ b/zend/ini.cpp @@ -12,42 +12,41 @@ */ namespace Php { - /** - * Filling ini_entries - * @param zend_ini_entry *ini_entry, int module_number - * @param int module_number - */ - void Ini::fill(zend_ini_entry *ini_entry, int module_number) +/** + * Filling ini_entries + * @param zend_ini_entry *ini_entry, int module_number + * @param int module_number + */ +void Ini::fill(zend_ini_entry *ini_entry, int module_number) +{ + ini_entry->module_number = module_number; + ini_entry->modifiable = static_cast<int>(this->_place); + ini_entry->name = const_cast<char*>(this->_name.c_str()); + ini_entry->name_length = this->_name.size()+1; + ini_entry->on_modify = OnUpdateString; + ini_entry->mh_arg1 = nullptr; + #ifdef ZTS + ini_entry->mh_arg2 = (void *) &phpcpp_globals_id; + #else + ini_entry->mh_arg2 = (void *) &phpcpp_globals; + #endif + ini_entry->mh_arg3 = nullptr; + ini_entry->value = const_cast<char*>(this->_value.c_str()); + ini_entry->value_length = this->_value.size(); + if( this->_orig_empty) + { + ini_entry->orig_value = nullptr; + ini_entry->orig_value_length = 0; + } + else { - ini_entry->module_number = module_number; - ini_entry->modifiable = static_cast<int>(this->_place); - ini_entry->name = const_cast<char*>(this->_name.c_str()); - ini_entry->name_length = this->_name.size()+1; - ini_entry->on_modify = OnUpdateString; - ini_entry->mh_arg1 = nullptr; - #ifdef ZTS - ini_entry->mh_arg2 = (void *) &phpcpp_globals_id; - #else - ini_entry->mh_arg2 = (void *) &phpcpp_globals; - #endif - ini_entry->mh_arg3 = nullptr; - ini_entry->value = const_cast<char*>(this->_value.c_str()); - ini_entry->value_length = this->_value.size(); - if( this->_orig_empty) - { - ini_entry->orig_value = nullptr; - ini_entry->orig_value_length = 0; - } - else - { - ini_entry->orig_value = const_cast<char*>(this->_orig_value.c_str()); - ini_entry->orig_value_length = this->_orig_value.size(); - } - ini_entry->orig_modifiable = 0; - ini_entry->modified = 0; - ini_entry->displayer = nullptr; + ini_entry->orig_value = const_cast<char*>(this->_orig.c_str()); + ini_entry->orig_value_length = this->_orig.size(); } - + ini_entry->orig_modifiable = 0; + ini_entry->modified = 0; + ini_entry->displayer = nullptr; +} /** * End of namespace diff --git a/zend/namespace.cpp b/zend/namespace.cpp index 8b97c52..2b4b62a 100644 --- a/zend/namespace.cpp +++ b/zend/namespace.cpp @@ -128,21 +128,6 @@ void Namespace::classes(const std::function<void(const std::string &ns, ClassBas } /** - * Filling ini entries into external zend_ini_entry array - * @param zend_ini_entry* - */ -void Namespace::fill_ini(zend_ini_entry *ini_entries, int module_number) -{ - // loop through the ini entries - unsigned int Ind = 0; - for (auto &ini : _ini_entries) ini->fill(&ini_entries[Ind++], module_number); - - // add last empty ini entry (Zend, for some reason, it requires) - zend_ini_entry empty_entry { 0, 0, nullptr, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0, nullptr, 0, 0, 0, nullptr }; - ini_entries[Ind] = empty_entry; -} - -/** * End namespace */ } |