summaryrefslogtreecommitdiff
path: root/zend/ini.cpp
blob: e7d9292a696e2f72c12a9525ac4da59f5a45131e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
 *  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.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.c_str());
        ini_entry->orig_value_length = this->_orig.size();
    }
    ini_entry->orig_modifiable   = 0;
    ini_entry->modified          = 0;
    ini_entry->displayer         = nullptr;
}


/**
 *  Cast to a number
 *  @return uint64_t
 */
int64_t IniValue::numericValue() const
{
    return zend_ini_long(const_cast<char*>(_name.c_str()), _name.size()+1, _isorig);

}

/**
 *  Get access to the raw buffer for read operationrs.
 *  @return const char *
 */
const char* IniValue::rawValue() const
{
    return zend_ini_string(const_cast<char*>(_name.c_str()), _name.size()+1, _isorig);
}

/**
 *  Cast to a floating point
 *  @return double
 */
IniValue::operator double() const
{
    return zend_ini_double(const_cast<char*>(_name.c_str()), _name.size()+1, _isorig);
}

/**
 *  End of namespace
 */
}