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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
// **********************************************************************
//
// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#include <Communicator.h>
#include <Marshal.h>
#include <Profile.h>
#include <Proxy.h>
#include <Util.h>
using namespace std;
using namespace IcePHP;
ZEND_DECLARE_MODULE_GLOBALS(ice)
//
// Entries for all object methods and global functions.
//
function_entry ice_functions[] =
{
ICE_PHP_COMMUNICATOR_FUNCTIONS
ICE_PHP_IDENTITY_FUNCTIONS
ICE_PHP_PROXY_FUNCTIONS
ICE_PHP_PROFILE_FUNCTIONS
{NULL, NULL, NULL}
};
zend_module_entry ice_module_entry =
{
STANDARD_MODULE_HEADER,
"ice",
ice_functions,
ZEND_MINIT(ice),
ZEND_MSHUTDOWN(ice),
ZEND_RINIT(ice),
ZEND_RSHUTDOWN(ice),
ZEND_MINFO(ice),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
ZEND_GET_MODULE(ice)
//
// Declare initialization file entries.
//
PHP_INI_BEGIN()
PHP_INI_ENTRY("ice.config", "", PHP_INI_SYSTEM, NULL)
PHP_INI_ENTRY("ice.options", "", PHP_INI_SYSTEM, NULL)
PHP_INI_ENTRY("ice.profiles", "", PHP_INI_SYSTEM, NULL)
PHP_INI_ENTRY("ice.slice", "", PHP_INI_SYSTEM, NULL)
PHP_INI_END()
extern "C"
int initIceGlobals(zend_ice_globals* g)
{
g->communicator = NULL;
g->marshalerMap = 0;
g->profile = 0;
g->properties = 0;
return SUCCESS;
}
ZEND_MINIT_FUNCTION(ice)
{
REGISTER_INI_ENTRIES();
ZEND_INIT_MODULE_GLOBALS(ice, initIceGlobals, NULL);
if(!profileInit(TSRMLS_C))
{
return FAILURE;
}
if(!communicatorInit(TSRMLS_C))
{
return FAILURE;
}
if(!proxyInit(TSRMLS_C))
{
return FAILURE;
}
return SUCCESS;
}
ZEND_MSHUTDOWN_FUNCTION(ice)
{
UNREGISTER_INI_ENTRIES();
int status = SUCCESS;
if(!profileShutdown(TSRMLS_C))
{
status = FAILURE;
}
return status;
}
ZEND_RINIT_FUNCTION(ice)
{
ICE_G(communicator) = NULL;
ICE_G(marshalerMap) = new MarshalerMap;
ICE_G(profile) = 0;
ICE_G(properties) = 0;
ICE_G(objectFactoryMap) = new ObjectFactoryMap;
//
// Create the global variable "ICE" to hold the communicator for this request. The
// communicator won't actually be created until the script uses this global variable
// for the first time.
//
if(!createCommunicator(TSRMLS_C))
{
return FAILURE;
}
return SUCCESS;
}
ZEND_RSHUTDOWN_FUNCTION(ice)
{
//
// Invoke destroy() on each registered factory.
//
ObjectFactoryMap* ofm = static_cast<ObjectFactoryMap*>(ICE_G(objectFactoryMap));
for(ObjectFactoryMap::iterator p = ofm->begin(); p != ofm->end(); ++p)
{
zval* factory = p->second;
zend_call_method_with_0_params(&factory, NULL, NULL, "destroy", NULL);
zval_ptr_dtor(&factory);
}
delete ofm;
delete static_cast<MarshalerMap*>(ICE_G(marshalerMap));
delete static_cast<Ice::PropertiesPtr*>(ICE_G(properties));
return SUCCESS;
}
ZEND_MINFO_FUNCTION(ice)
{
php_info_print_table_start();
php_info_print_table_header(2, "Ice support", "enabled");
php_info_print_table_row(2, "Ice version", ICE_STRING_VERSION);
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
}
|