|
| 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 | + | [email protected] so we can mail you a copy immediately. | |
| 12 | + +----------------------------------------------------------------------+ |
| 13 | + | Author: Arnaud Le Blanc <[email protected]> | |
| 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 | + |
| 26 | +ZEND_DECLARE_MODULE_GLOBALS(dl_test) |
| 27 | + |
| 28 | +/* {{{ void dl_test_test1() */ |
| 29 | +PHP_FUNCTION(dl_test_test1) |
| 30 | +{ |
| 31 | + ZEND_PARSE_PARAMETERS_NONE(); |
| 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 ] ) */ |
| 38 | +PHP_FUNCTION(dl_test_test2) |
| 39 | +{ |
| 40 | + char *var = "World"; |
| 41 | + size_t var_len = sizeof("World") - 1; |
| 42 | + zend_string *retval; |
| 43 | + |
| 44 | + ZEND_PARSE_PARAMETERS_START(0, 1) |
| 45 | + Z_PARAM_OPTIONAL |
| 46 | + Z_PARAM_STRING(var, var_len) |
| 47 | + ZEND_PARSE_PARAMETERS_END(); |
| 48 | + |
| 49 | + retval = strpprintf(0, "Hello %s", var); |
| 50 | + |
| 51 | + RETURN_STR(retval); |
| 52 | +} |
| 53 | +/* }}}*/ |
| 54 | + |
| 55 | +/* {{{ INI */ |
| 56 | +PHP_INI_BEGIN() |
| 57 | + STD_PHP_INI_BOOLEAN("dl_test.long", "0", PHP_INI_ALL, OnUpdateLong, long_value, zend_dl_test_globals, dl_test_globals) |
| 58 | + STD_PHP_INI_ENTRY("dl_test.string", "hello", PHP_INI_ALL, OnUpdateString, string_value, zend_dl_test_globals, dl_test_globals) |
| 59 | +PHP_INI_END() |
| 60 | +/* }}} */ |
| 61 | + |
| 62 | +/* {{{ PHP_MINIT_FUNCTION */ |
| 63 | +PHP_MINIT_FUNCTION(dl_test) |
| 64 | +{ |
| 65 | + /* Test backwards compatibility */ |
| 66 | + if (getenv("PHP_DL_TEST_USE_OLD_REGISTER_INI_ENTRIES")) { |
| 67 | + zend_register_ini_entries(ini_entries, module_number); |
| 68 | + } else { |
| 69 | + REGISTER_INI_ENTRIES(); |
| 70 | + } |
| 71 | + |
| 72 | + return SUCCESS; |
| 73 | +} |
| 74 | +/* }}} */ |
| 75 | + |
| 76 | +/* {{{ PHP_MSHUTDOWN_FUNCTION */ |
| 77 | +static PHP_MSHUTDOWN_FUNCTION(dl_test) |
| 78 | +{ |
| 79 | + /* Test backwards compatibility */ |
| 80 | + if (getenv("PHP_DL_TEST_USE_OLD_REGISTER_INI_ENTRIES")) { |
| 81 | + zend_unregister_ini_entries(module_number); |
| 82 | + } else { |
| 83 | + UNREGISTER_INI_ENTRIES(); |
| 84 | + } |
| 85 | + |
| 86 | + return SUCCESS; |
| 87 | +} |
| 88 | +/* }}} */ |
| 89 | + |
| 90 | +/* {{{ PHP_RINIT_FUNCTION */ |
| 91 | +PHP_RINIT_FUNCTION(dl_test) |
| 92 | +{ |
| 93 | +#if defined(ZTS) && defined(COMPILE_DL_DL_TEST) |
| 94 | + ZEND_TSRMLS_CACHE_UPDATE(); |
| 95 | +#endif |
| 96 | + |
| 97 | + return SUCCESS; |
| 98 | +} |
| 99 | +/* }}} */ |
| 100 | + |
| 101 | +/* {{{ PHP_MINFO_FUNCTION */ |
| 102 | +PHP_MINFO_FUNCTION(dl_test) |
| 103 | +{ |
| 104 | + php_info_print_table_start(); |
| 105 | + php_info_print_table_header(2, "dl_test support", "enabled"); |
| 106 | + php_info_print_table_end(); |
| 107 | + |
| 108 | + DISPLAY_INI_ENTRIES(); |
| 109 | +} |
| 110 | +/* }}} */ |
| 111 | + |
| 112 | +/* {{{ PHP_GINIT_FUNCTION */ |
| 113 | +static PHP_GINIT_FUNCTION(dl_test) |
| 114 | +{ |
| 115 | +#if defined(COMPILE_DL_DL_TEST) && defined(ZTS) |
| 116 | + ZEND_TSRMLS_CACHE_UPDATE(); |
| 117 | +#endif |
| 118 | + memset(dl_test_globals, 0, sizeof(*dl_test_globals)); |
| 119 | +} |
| 120 | +/* }}} */ |
| 121 | + |
| 122 | +/* {{{ dl_test_module_entry */ |
| 123 | +zend_module_entry dl_test_module_entry = { |
| 124 | + STANDARD_MODULE_HEADER, |
| 125 | + "dl_test", |
| 126 | + ext_functions, |
| 127 | + PHP_MINIT(dl_test), |
| 128 | + PHP_MSHUTDOWN(dl_test), |
| 129 | + PHP_RINIT(dl_test), |
| 130 | + NULL, |
| 131 | + PHP_MINFO(dl_test), |
| 132 | + PHP_DL_TEST_VERSION, |
| 133 | + PHP_MODULE_GLOBALS(dl_test), |
| 134 | + PHP_GINIT(dl_test), |
| 135 | + NULL, |
| 136 | + NULL, |
| 137 | + STANDARD_MODULE_PROPERTIES_EX |
| 138 | +}; |
| 139 | +/* }}} */ |
| 140 | + |
| 141 | +#ifdef COMPILE_DL_DL_TEST |
| 142 | +# ifdef ZTS |
| 143 | +ZEND_TSRMLS_CACHE_DEFINE() |
| 144 | +# endif |
| 145 | +ZEND_GET_MODULE(dl_test) |
| 146 | +#endif |
0 commit comments