summaryrefslogtreecommitdiff
path: root/zend
diff options
context:
space:
mode:
authorvalmat <ufabiz@gmail.com>2014-04-09 12:00:33 +0600
committervalmat <ufabiz@gmail.com>2014-04-09 12:00:33 +0600
commit21ba3f0aae94206457327552666d75dd2cf0a8f2 (patch)
tree266b24a9d549189d4a20f1db45d8edc771e32fca /zend
parent6c7c846edd5b74450b76532da33c25e6cc6a10a4 (diff)
Made compatible. Now works in the new structure of the library.
Diffstat (limited to 'zend')
-rw-r--r--zend/extensionimpl.cpp13
-rw-r--r--zend/ini.cpp57
-rw-r--r--zend/namespace.cpp15
3 files changed, 76 insertions, 9 deletions
diff --git a/zend/extensionimpl.cpp b/zend/extensionimpl.cpp
index 3534cdb..545b590 100644
--- a/zend/extensionimpl.cpp
+++ b/zend/extensionimpl.cpp
@@ -116,17 +116,12 @@ int ExtensionImpl::processStartup(int type, int module_number TSRMLS_DC)
auto *extension = find(module_number TSRMLS_CC);
// array contains ini settings
- static zend_ini_entry *ini_entries = new zend_ini_entry[ extension->_ini_entries.size()+1 ];
+ static zend_ini_entry *ini_entries = new zend_ini_entry[ extension->_data->ini_size()+1 ];
- // Filling ini_entries
- unsigned int Ind = 0;
- for (auto &ini : extension->_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;
+ // Filling ini entries
+ extension->_data->fill_ini(ini_entries, module_number);
- // register
+ // register ini entries in Zend core
REGISTER_INI_ENTRIES();
// initialize the extension
diff --git a/zend/ini.cpp b/zend/ini.cpp
new file mode 100644
index 0000000..e6a9888
--- /dev/null
+++ b/zend/ini.cpp
@@ -0,0 +1,57 @@
+/**
+ * Ini.cpp
+ *
+ * Implementation for ....
+ *
+ * @copyright 2013 Copernica BV
+ */
+#include "includes.h"
+
+/**
+ * Set up namespace
+ */
+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)
+ {
+ ini_entry->module_number = module_number;
+ ini_entry->modifiable = static_cast<int>(this->_place);
+ ini_entry->name = const_cast<char*>(this->_name);
+ ini_entry->name_length = strlen(this->_name)+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;
+ }
+
+
+/**
+ * End of namespace
+ */
+}
+
+
diff --git a/zend/namespace.cpp b/zend/namespace.cpp
index bea31a1..e9ec631 100644
--- a/zend/namespace.cpp
+++ b/zend/namespace.cpp
@@ -128,6 +128,21 @@ void Namespace::apply(const std::function<void(const std::string &ns, ClassBase
}
/**
+ * 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
*/
}