php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
dl_test.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: Arnaud Le Blanc <arnaud.lb@gmail.com> |
14 +----------------------------------------------------------------------+
15*/
16
17#ifdef HAVE_CONFIG_H
18# include "config.h"
19#endif
20
21#include "php.h"
22#include "ext/standard/info.h"
23#include "php_dl_test.h"
24#include "dl_test_arginfo.h"
25
27
28/* {{{ void dl_test_test1() */
30{
32
33 php_printf("The extension %s is loaded and working!\r\n", "dl_test");
34}
35/* }}} */
36
37/* {{{ string dl_test_test2( [ string $var ] ) */
39{
40 char *var = "World";
41 size_t var_len = sizeof("World") - 1;
43
46 Z_PARAM_STRING(var, var_len)
48
49 retval = strpprintf(0, "Hello %s", var);
50
52}
53/* }}}*/
54
55/* {{{ PHP_DL_TEST_USE_REGISTER_FUNCTIONS_DIRECTLY */
56ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dl_test_use_register_functions_directly, 0, 0, IS_STRING, 0)
58
59PHP_FUNCTION(dl_test_use_register_functions_directly)
60{
62
63 RETURN_STRING("OK");
64}
65
66static const zend_function_entry php_dl_test_use_register_functions_directly_functions[] = {
67 ZEND_FENTRY(dl_test_use_register_functions_directly, ZEND_FN(dl_test_use_register_functions_directly), arginfo_dl_test_use_register_functions_directly, 0)
69};
70/* }}} */
71
72/* {{{ INI */
74 STD_PHP_INI_ENTRY("dl_test.long", "0", PHP_INI_ALL, OnUpdateLong, long_value, zend_dl_test_globals, dl_test_globals)
75 STD_PHP_INI_ENTRY("dl_test.string", "hello", PHP_INI_ALL, OnUpdateString, string_value, zend_dl_test_globals, dl_test_globals)
77/* }}} */
78
80{
81 char *var = "World";
82 size_t var_len = sizeof("World") - 1;
84
87 Z_PARAM_STRING(var, var_len)
89
90 retval = strpprintf(0, "Hello %s", var);
91
93}
94
101
102/* {{{ PHP_MINIT_FUNCTION */
104{
106
107 register_class_DlTest();
108 ce = register_class_DlTestSuperClass();
109 register_class_DlTestSubClass(ce);
110 register_class_DlTestAliasedClass();
111
112 /* Test backwards compatibility */
113 if (getenv("PHP_DL_TEST_USE_OLD_REGISTER_INI_ENTRIES")) {
114 zend_register_ini_entries(ini_entries, module_number);
115 } else {
117 }
118
119 if (getenv("PHP_DL_TEST_USE_REGISTER_FUNCTIONS_DIRECTLY")) {
120 zend_register_functions(NULL, php_dl_test_use_register_functions_directly_functions, NULL, type);
121 }
122
123 if (getenv("PHP_DL_TEST_MODULE_DEBUG")) {
124 fprintf(stderr, "DL TEST MINIT\n");
125 }
126
127 return SUCCESS;
128}
129/* }}} */
130
131/* {{{ PHP_MSHUTDOWN_FUNCTION */
132static PHP_MSHUTDOWN_FUNCTION(dl_test)
133{
134 /* Test backwards compatibility */
135 if (getenv("PHP_DL_TEST_USE_OLD_REGISTER_INI_ENTRIES")) {
136 zend_unregister_ini_entries(module_number);
137 } else {
139 }
140
141 if (getenv("PHP_DL_TEST_MODULE_DEBUG")) {
142 fprintf(stderr, "DL TEST MSHUTDOWN\n");
143 }
144
145 return SUCCESS;
146}
147/* }}} */
148
149/* {{{ PHP_RINIT_FUNCTION */
151{
152#if defined(ZTS) && defined(COMPILE_DL_DL_TEST)
154#endif
155
156 if (getenv("PHP_DL_TEST_MODULE_DEBUG")) {
157 fprintf(stderr, "DL TEST RINIT\n");
158 }
159
160 return SUCCESS;
161}
162/* }}} */
163
164/* {{{ PHP_RSHUTDOWN_FUNCTION */
166{
167 if (getenv("PHP_DL_TEST_MODULE_DEBUG")) {
168 fprintf(stderr, "DL TEST RSHUTDOWN\n");
169 }
170
171 return SUCCESS;
172}
173/* }}} */
174
175/* {{{ PHP_MINFO_FUNCTION */
177{
179 php_info_print_table_row(2, "dl_test support", "enabled");
181
183}
184/* }}} */
185
186/* {{{ PHP_GINIT_FUNCTION */
187static PHP_GINIT_FUNCTION(dl_test)
188{
189#if defined(COMPILE_DL_DL_TEST) && defined(ZTS)
191#endif
192 memset(dl_test_globals, 0, sizeof(*dl_test_globals));
193}
194/* }}} */
195
196/* {{{ dl_test_module_entry */
199 "dl_test",
200 ext_functions,
201 PHP_MINIT(dl_test),
202 PHP_MSHUTDOWN(dl_test),
203 PHP_RINIT(dl_test),
204 PHP_RSHUTDOWN(dl_test),
205 PHP_MINFO(dl_test),
207 PHP_MODULE_GLOBALS(dl_test),
208 PHP_GINIT(dl_test),
209 NULL,
210 NULL,
212};
213/* }}} */
214
215#ifdef COMPILE_DL_DL_TEST
216# ifdef ZTS
218# endif
219ZEND_GET_MODULE(dl_test)
220#endif
fprintf($stream, string $format, mixed ... $values)
getenv(?string $name=null, bool $local_only=false)
zend_module_entry dl_test_module_entry
Definition dl_test.c:197
dl_test_test2(string $str="")
dl_test_test1()
zend_ffi_type * type
Definition ffi.c:3812
memset(ptr, 0, type->size)
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
PHPAPI size_t php_printf(const char *format,...)
Definition main.c:938
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_FUNCTION
Definition php.h:364
#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_METHOD
Definition php.h:365
#define PHP_MODULE_GLOBALS
Definition php.h:408
zend_long long_value
Definition php_dl_test.h:30
char * string_value
Definition php_dl_test.h:31
#define PHP_DL_TEST_VERSION
Definition php_dl_test.h:23
#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_END
Definition php_ini.h:53
#define strpprintf
Definition spprintf.h:30
test($x, $y=0)
Definition test.php:21
#define ZEND_TSRMLS_CACHE_UPDATE()
Definition zend.h:69
#define ZEND_TSRMLS_CACHE_DEFINE()
Definition zend.h:68
ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type)
Definition zend_API.c:2927
#define ZEND_FE_END
Definition zend_API.h:124
#define RETURN_STRING(s)
Definition zend_API.h:1043
#define ZEND_PARSE_PARAMETERS_END()
Definition zend_API.h:1641
struct _zend_function_entry zend_function_entry
#define ZEND_PARSE_PARAMETERS_NONE()
Definition zend_API.h:1623
#define RETURN_NULL()
Definition zend_API.h:1036
#define ZEND_FN(name)
Definition zend_API.h:71
#define ZEND_DECLARE_MODULE_GLOBALS(module_name)
Definition zend_API.h:268
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null)
Definition zend_API.h:205
#define Z_PARAM_OPTIONAL
Definition zend_API.h:1667
#define ZEND_GET_MODULE(name)
Definition zend_API.h:241
#define Z_PARAM_STRING(dest, dest_len)
Definition zend_API.h:2071
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
Definition zend_API.h:1620
#define ZEND_END_ARG_INFO()
Definition zend_API.h:219
#define RETURN_STR(s)
Definition zend_API.h:1039
#define ZEND_FENTRY(zend_name, name, arg_info, flags)
Definition zend_API.h:78
ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number)
Definition zend_ini.c:268
ZEND_API void zend_unregister_ini_entries(int module_number)
Definition zend_ini.c:297
#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
struct _zend_string zend_string
#define STANDARD_MODULE_HEADER
struct _zend_module_entry zend_module_entry
#define STANDARD_MODULE_PROPERTIES_EX
struct _zend_class_entry zend_class_entry
#define IS_STRING
Definition zend_types.h:606
zval retval