php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
com_extension.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Wez Furlong <wez@thebrainroom.com> |
14 +----------------------------------------------------------------------+
15 */
16
17#ifdef HAVE_CONFIG_H
18#include <config.h>
19#endif
20
21#include <intsafe.h>
22
23#include "php.h"
24#include "php_ini.h"
25#include "ext/standard/info.h"
26#include "php_com_dotnet.h"
30
31#if SIZEOF_ZEND_LONG == 8
32#define PHP_DISP_E_DIVBYZERO ((zend_long) (ULONG) DISP_E_DIVBYZERO)
33#define PHP_DISP_E_OVERFLOW ((zend_long) (ULONG) DISP_E_OVERFLOW)
34#define PHP_DISP_E_BADINDEX ((zend_long) (ULONG) DISP_E_BADINDEX)
35#define PHP_DISP_E_PARAMNOTFOUND ((zend_long) (ULONG) DISP_E_PARAMNOTFOUND)
36#define PHP_MK_E_UNAVAILABLE ((zend_long) (ULONG) MK_E_UNAVAILABLE)
37#else
38#define PHP_DISP_E_DIVBYZERO DISP_E_DIVBYZERO
39#define PHP_DISP_E_OVERFLOW DISP_E_OVERFLOW
40#define PHP_DISP_E_BADINDEX DISP_E_BADINDEX
41#define PHP_DISP_E_PARAMNOTFOUND DISP_E_PARAMNOTFOUND
42#define PHP_MK_E_UNAVAILABLE MK_E_UNAVAILABLE
43#endif
44
46
48static PHP_GINIT_FUNCTION(com_dotnet);
49
54
55/* {{{ com_dotnet_module_entry */
58 "com_dotnet",
59 ext_functions,
60 PHP_MINIT(com_dotnet),
61 PHP_MSHUTDOWN(com_dotnet),
62 PHP_RINIT(com_dotnet),
63 PHP_RSHUTDOWN(com_dotnet),
64 PHP_MINFO(com_dotnet),
66 PHP_MODULE_GLOBALS(com_dotnet),
67 PHP_GINIT(com_dotnet),
68 NULL,
69 NULL,
71};
72/* }}} */
73
74#ifdef COMPILE_DL_COM_DOTNET
75#ifdef ZTS
77#endif
78ZEND_GET_MODULE(com_dotnet)
79#endif
80
81/* {{{ PHP_INI */
82
83/* com.typelib_file is the path to a file containing a
84 * list of typelibraries to register *persistently*.
85 * lines starting with ; are comments
86 * append #cis to end of typelib name to cause its constants
87 * to be loaded case insensitively */
88static PHP_INI_MH(OnTypeLibFileUpdate)
89{
90 FILE *typelib_file;
91 char *typelib_name_buffer;
92 char *strtok_buf = NULL;
93
94 if (NULL == new_value || !new_value->val[0] || (typelib_file = VCWD_FOPEN(new_value->val, "r"))==NULL) {
95 return FAILURE;
96 }
97
98 typelib_name_buffer = (char *) emalloc(sizeof(char)*1024);
99
100 while (fgets(typelib_name_buffer, 1024, typelib_file)) {
101 ITypeLib *pTL;
102 char *typelib_name;
103 char *modifier, *ptr;
104
105 if (typelib_name_buffer[0]==';') {
106 continue;
107 }
108 typelib_name = php_strtok_r(typelib_name_buffer, "\r\n", &strtok_buf); /* get rid of newlines */
109 if (typelib_name == NULL) {
110 continue;
111 }
112 typelib_name = php_strtok_r(typelib_name, "#", &strtok_buf);
113 modifier = php_strtok_r(NULL, "#", &strtok_buf);
114 if (modifier != NULL) {
115 if (!strcmp(modifier, "cis") || !strcmp(modifier, "case_insensitive")) {
116 php_error_docref("com.configuration", E_WARNING, "Declaration of case-insensitive constants is no longer supported; #cis modifier ignored");
117 }
118 }
119
120 /* Remove leading/training white spaces on search_string */
121 while (isspace(*typelib_name)) {/* Ends on '\0' in worst case */
122 typelib_name ++;
123 }
124 ptr = typelib_name + strlen(typelib_name) - 1;
125 while ((ptr != typelib_name) && isspace(*ptr)) {
126 *ptr = '\0';
127 ptr--;
128 }
129
130 if ((pTL = php_com_load_typelib_via_cache(typelib_name, COMG(code_page))) != NULL) {
132 ITypeLib_Release(pTL);
133 }
134 }
135
136 efree(typelib_name_buffer);
137 fclose(typelib_file);
138
139 return SUCCESS;
140}
141
142static ZEND_INI_MH(OnAutoregisterCasesensitive)
143{
144 if (!zend_ini_parse_bool(new_value)) {
145 php_error_docref("com.configuration", E_WARNING, "Declaration of case-insensitive constants is no longer supported");
146 return FAILURE;
147 }
148 return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
149}
150
152 STD_PHP_INI_BOOLEAN("com.allow_dcom", "0", PHP_INI_SYSTEM, OnUpdateBool, allow_dcom, zend_com_dotnet_globals, com_dotnet_globals)
153 STD_PHP_INI_BOOLEAN("com.autoregister_verbose", "0", PHP_INI_ALL, OnUpdateBool, autoreg_verbose, zend_com_dotnet_globals, com_dotnet_globals)
154 STD_PHP_INI_BOOLEAN("com.autoregister_typelib", "0", PHP_INI_ALL, OnUpdateBool, autoreg_on, zend_com_dotnet_globals, com_dotnet_globals)
155 STD_PHP_INI_ENTRY("com.autoregister_casesensitive", "1", PHP_INI_ALL, OnAutoregisterCasesensitive, autoreg_case_sensitive, zend_com_dotnet_globals, com_dotnet_globals)
156 STD_PHP_INI_ENTRY("com.code_page", "", PHP_INI_ALL, OnUpdateLong, code_page, zend_com_dotnet_globals, com_dotnet_globals)
157 PHP_INI_ENTRY("com.typelib_file", "", PHP_INI_SYSTEM, OnTypeLibFileUpdate)
158 PHP_INI_ENTRY("com.dotnet_version", NULL, PHP_INI_SYSTEM, NULL)
160/* }}} */
161
162/* {{{ PHP_GINIT_FUNCTION */
163static PHP_GINIT_FUNCTION(com_dotnet)
164{
165#if defined(COMPILE_DL_COM_DOTNET) && defined(ZTS)
167#endif
168 memset(com_dotnet_globals, 0, sizeof(*com_dotnet_globals));
169 com_dotnet_globals->code_page = CP_ACP;
170}
171/* }}} */
172
173/* {{{ PHP_MINIT_FUNCTION */
175{
176 zend_class_entry *tmp;
177
179
180 php_com_exception_class_entry = register_class_com_exception(zend_ce_exception);
181/* php_com_exception_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED; */
182
183 php_com_saproxy_class_entry = register_class_com_safearray_proxy();
184/* php_com_saproxy_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED; */
185 php_com_saproxy_class_entry->default_object_handlers = &php_com_saproxy_handlers;
187
188 php_com_variant_class_entry = register_class_variant();
189 php_com_variant_class_entry->default_object_handlers = &php_com_object_handlers;
192
193 tmp = register_class_com(php_com_variant_class_entry);
197
198#ifdef HAVE_MSCOREE_H
199 tmp = register_class_dotnet(php_com_variant_class_entry);
203#endif
204
206
207 register_com_extension_symbols(module_number);
208
209 PHP_MINIT(com_typeinfo)(INIT_FUNC_ARGS_PASSTHRU);
210
211 return SUCCESS;
212}
213/* }}} */
214
215/* {{{ PHP_MSHUTDOWN_FUNCTION */
217{
219#ifdef HAVE_MSCOREE_H
222 }
223#endif
224
226
227 return SUCCESS;
228}
229/* }}} */
230
231/* {{{ PHP_RINIT_FUNCTION */
233{
235 return SUCCESS;
236}
237/* }}} */
238
239/* {{{ PHP_RSHUTDOWN_FUNCTION */
241{
242#ifdef HAVE_MSCOREE_H
245 }
246#endif
248 return SUCCESS;
249}
250/* }}} */
251
252/* {{{ PHP_MINFO_FUNCTION */
254{
256
257 php_info_print_table_row(2, "COM support", "enabled");
258 php_info_print_table_row(2, "DCOM support", COMG(allow_dcom) ? "enabled" : "disabled");
259
260#ifdef HAVE_MSCOREE_H
261 php_info_print_table_row(2, ".Net support", "enabled");
262#else
263 php_info_print_table_row(2, ".Net support", "not present in this build");
264#endif
265
267
269}
270/* }}} */
fclose($stream)
fgets($stream, ?int $length=null)
zend_module_entry com_dotnet_module_entry
zend_class_entry * php_com_exception_class_entry
zend_class_entry * php_com_variant_class_entry
zend_class_entry * php_com_saproxy_class_entry
const CP_ACP
zend_object_handlers php_com_object_handlers
zend_object * php_com_object_new(zend_class_entry *ce)
zend_object_iterator * php_com_iter_get(zend_class_entry *ce, zval *object, int by_ref)
void php_com_persist_minit(INIT_FUNC_ARGS)
zend_object_iterator * php_com_saproxy_iter_get(zend_class_entry *ce, zval *object, int by_ref)
zend_object_handlers php_com_saproxy_handlers
PHP_COM_DOTNET_API ITypeLib * php_com_load_typelib_via_cache(const char *search_string, int codepage)
PHP_COM_DOTNET_API zend_result php_com_import_typelib(ITypeLib *TL, int mode, int codepage)
void * ptr
Definition ffi.c:3814
memset(ptr, 0, type->size)
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
Definition main.c:1173
php_info_print_table_start()
Definition info.c:1064
php_info_print_table_row(2, "PDO Driver for Firebird", "enabled")
php_info_print_table_end()
Definition info.c:1074
#define PHP_GINIT
Definition php.h:397
#define PHP_MSHUTDOWN_FUNCTION
Definition php.h:401
#define PHP_MINFO
Definition php.h:396
#define PHP_MINIT_FUNCTION
Definition php.h:400
#define PHP_RINIT
Definition php.h:394
#define PHP_MSHUTDOWN
Definition php.h:393
#define PHP_MINFO_FUNCTION
Definition php.h:404
#define PHP_GINIT_FUNCTION
Definition php.h:405
#define PHP_RSHUTDOWN
Definition php.h:395
#define PHP_RINIT_FUNCTION
Definition php.h:402
#define PHP_RSHUTDOWN_FUNCTION
Definition php.h:403
#define PHP_MINIT
Definition php.h:392
#define PHP_MODULE_GLOBALS
Definition php.h:408
#define COMG(v)
void * dotnet_runtime_stuff
int code_page
bool autoreg_on
bool autoreg_case_sensitive
bool allow_dcom
bool rshutdown_started
#define PHP_COM_DOTNET_VERSION
bool autoreg_verbose
void php_com_dotnet_rshutdown(void)
void php_com_dotnet_mshutdown(void)
#define PHP_INI_ALL
Definition php_ini.h:45
#define PHP_INI_BEGIN
Definition php_ini.h:52
#define STD_PHP_INI_ENTRY
Definition php_ini.h:64
#define PHP_INI_ENTRY
Definition php_ini.h:62
#define STD_PHP_INI_BOOLEAN
Definition php_ini.h:66
#define PHP_INI_MH
Definition php_ini.h:49
#define PHP_INI_SYSTEM
Definition php_ini.h:43
#define PHP_INI_END
Definition php_ini.h:53
PHPAPI char * php_strtok_r(char *s, const char *delim, char **last)
Definition reentrancy.c:263
zend_object *(* create_object)(zend_class_entry *class_type)
Definition zend.h:195
zend_object_iterator *(* get_iterator)(zend_class_entry *ce, zval *object, int by_ref)
Definition zend.h:198
const zend_object_handlers * default_object_handlers
Definition zend.h:186
#define ZEND_TSRMLS_CACHE_UPDATE()
Definition zend.h:69
#define ZEND_TSRMLS_CACHE_DEFINE()
Definition zend.h:68
#define ZEND_DECLARE_MODULE_GLOBALS(module_name)
Definition zend_API.h:268
#define ZEND_GET_MODULE(name)
Definition zend_API.h:241
#define efree(ptr)
Definition zend_alloc.h:155
#define emalloc(size)
Definition zend_alloc.h:151
strlen(string $string)
strcmp(string $string1, string $string2)
#define CONST_PERSISTENT
#define E_WARNING
Definition zend_errors.h:24
ZEND_API zend_class_entry * zend_ce_exception
ZEND_API bool zend_ini_parse_bool(zend_string *str)
Definition zend_ini.c:573
#define UNREGISTER_INI_ENTRIES()
Definition zend_ini.h:204
#define REGISTER_INI_ENTRIES()
Definition zend_ini.h:203
#define DISPLAY_INI_ENTRIES()
Definition zend_ini.h:205
#define ZEND_INI_MH(name)
Definition zend_ini.h:30
#define STANDARD_MODULE_HEADER
#define INIT_FUNC_ARGS_PASSTHRU
struct _zend_module_entry zend_module_entry
#define STANDARD_MODULE_PROPERTIES_EX
struct _zend_class_entry zend_class_entry
@ FAILURE
Definition zend_types.h:61
#define VCWD_FOPEN(path, mode)