xref: /PHP-7.1/ext/skeleton/skeleton.c (revision 1ac15293)
1 /* __header_here__ */
2 
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
6 
7 #include "php.h"
8 #include "php_ini.h"
9 #include "ext/standard/info.h"
10 #include "php_extname.h"
11 
12 /* If you declare any globals in php_extname.h uncomment this:
13 ZEND_DECLARE_MODULE_GLOBALS(extname)
14 */
15 
16 /* True global resources - no need for thread safety here */
17 static int le_extname;
18 
19 /* {{{ PHP_INI
20  */
21 /* Remove comments and fill if you need to have entries in php.ini
22 PHP_INI_BEGIN()
23     STD_PHP_INI_ENTRY("extname.global_value",      "42", PHP_INI_ALL, OnUpdateLong, global_value, zend_extname_globals, extname_globals)
24     STD_PHP_INI_ENTRY("extname.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_extname_globals, extname_globals)
25 PHP_INI_END()
26 */
27 /* }}} */
28 
29 /* Remove the following function when you have successfully modified config.m4
30    so that your module can be compiled into PHP, it exists only for testing
31    purposes. */
32 
33 /* Every user-visible function in PHP should document itself in the source */
34 /* {{{ proto string confirm_extname_compiled(string arg)
35    Return a string to confirm that the module is compiled in */
PHP_FUNCTION(confirm_extname_compiled)36 PHP_FUNCTION(confirm_extname_compiled)
37 {
38 	char *arg = NULL;
39 	size_t arg_len, len;
40 	zend_string *strg;
41 
42 	if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &arg, &arg_len) == FAILURE) {
43 		return;
44 	}
45 
46 	strg = strpprintf(0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "extname", arg);
47 
48 	RETURN_STR(strg);
49 }
50 /* }}} */
51 /* The previous line is meant for vim and emacs, so it can correctly fold and
52    unfold functions in source code. See the corresponding marks just before
53    function definition, where the functions purpose is also documented. Please
54    follow this convention for the convenience of others editing your code.
55 */
56 
57 /* __function_stubs_here__ */
58 
59 /* {{{ php_extname_init_globals
60  */
61 /* Uncomment this function if you have INI entries
62 static void php_extname_init_globals(zend_extname_globals *extname_globals)
63 {
64 	extname_globals->global_value = 0;
65 	extname_globals->global_string = NULL;
66 }
67 */
68 /* }}} */
69 
70 /* {{{ PHP_MINIT_FUNCTION
71  */
PHP_MINIT_FUNCTION(extname)72 PHP_MINIT_FUNCTION(extname)
73 {
74 	/* If you have INI entries, uncomment these lines
75 	REGISTER_INI_ENTRIES();
76 	*/
77 	return SUCCESS;
78 }
79 /* }}} */
80 
81 /* {{{ PHP_MSHUTDOWN_FUNCTION
82  */
PHP_MSHUTDOWN_FUNCTION(extname)83 PHP_MSHUTDOWN_FUNCTION(extname)
84 {
85 	/* uncomment this line if you have INI entries
86 	UNREGISTER_INI_ENTRIES();
87 	*/
88 	return SUCCESS;
89 }
90 /* }}} */
91 
92 /* Remove if there's nothing to do at request start */
93 /* {{{ PHP_RINIT_FUNCTION
94  */
PHP_RINIT_FUNCTION(extname)95 PHP_RINIT_FUNCTION(extname)
96 {
97 #if defined(COMPILE_DL_EXTNAME) && defined(ZTS)
98 	ZEND_TSRMLS_CACHE_UPDATE();
99 #endif
100 	return SUCCESS;
101 }
102 /* }}} */
103 
104 /* Remove if there's nothing to do at request end */
105 /* {{{ PHP_RSHUTDOWN_FUNCTION
106  */
PHP_RSHUTDOWN_FUNCTION(extname)107 PHP_RSHUTDOWN_FUNCTION(extname)
108 {
109 	return SUCCESS;
110 }
111 /* }}} */
112 
113 /* {{{ PHP_MINFO_FUNCTION
114  */
PHP_MINFO_FUNCTION(extname)115 PHP_MINFO_FUNCTION(extname)
116 {
117 	php_info_print_table_start();
118 	php_info_print_table_header(2, "extname support", "enabled");
119 	php_info_print_table_end();
120 
121 	/* Remove comments if you have entries in php.ini
122 	DISPLAY_INI_ENTRIES();
123 	*/
124 }
125 /* }}} */
126 
127 /* {{{ extname_functions[]
128  *
129  * Every user visible function must have an entry in extname_functions[].
130  */
131 const zend_function_entry extname_functions[] = {
132 	PHP_FE(confirm_extname_compiled,	NULL)		/* For testing, remove later. */
133 	/* __function_entries_here__ */
134 	PHP_FE_END	/* Must be the last line in extname_functions[] */
135 };
136 /* }}} */
137 
138 /* {{{ extname_module_entry
139  */
140 zend_module_entry extname_module_entry = {
141 	STANDARD_MODULE_HEADER,
142 	"extname",
143 	extname_functions,
144 	PHP_MINIT(extname),
145 	PHP_MSHUTDOWN(extname),
146 	PHP_RINIT(extname),		/* Replace with NULL if there's nothing to do at request start */
147 	PHP_RSHUTDOWN(extname),	/* Replace with NULL if there's nothing to do at request end */
148 	PHP_MINFO(extname),
149 	PHP_EXTNAME_VERSION,
150 	STANDARD_MODULE_PROPERTIES
151 };
152 /* }}} */
153 
154 #ifdef COMPILE_DL_EXTNAME
155 #ifdef ZTS
156 ZEND_TSRMLS_CACHE_DEFINE()
157 #endif
158 ZEND_GET_MODULE(extname)
159 #endif
160 
161 /*
162  * Local variables:
163  * tab-width: 4
164  * c-basic-offset: 4
165  * End:
166  * vim600: noet sw=4 ts=4 fdm=marker
167  * vim<600: noet sw=4 ts=4
168  */
169