summaryrefslogtreecommitdiff
path: root/src/snuffleupagus.c
diff options
context:
space:
mode:
authorThibault "bui" Koechlin2017-12-28 17:04:06 +0100
committerjvoisin2017-12-28 17:04:06 +0100
commit9f5e8d12f05fb24c915a5266a1e908a75c8aed08 (patch)
tree9160075ea943c7fd29a3923f844a0ac0d6b8b457 /src/snuffleupagus.c
parent62c48bf9a85e0294b7b32cea438e904e1cd50669 (diff)
Clang-format pass
- `clang-format --style="{BasedOnStyle: google, SortIncludes: false}" -i snuffleu*.c sp_*.c sp_*.h` - Update the documentation accordingly
Diffstat (limited to 'src/snuffleupagus.c')
-rw-r--r--src/snuffleupagus.c91
1 files changed, 48 insertions, 43 deletions
diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c
index b823a87..dd2d941 100644
--- a/src/snuffleupagus.c
+++ b/src/snuffleupagus.c
@@ -30,7 +30,7 @@ ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
30 30
31PHP_INI_BEGIN() 31PHP_INI_BEGIN()
32PHP_INI_ENTRY("sp.configuration_file", "", PHP_INI_SYSTEM, 32PHP_INI_ENTRY("sp.configuration_file", "", PHP_INI_SYSTEM,
33 OnUpdateConfiguration) 33 OnUpdateConfiguration)
34PHP_INI_END() 34PHP_INI_END()
35 35
36ZEND_DLEXPORT zend_extension zend_extension_entry = { 36ZEND_DLEXPORT zend_extension zend_extension_entry = {
@@ -41,22 +41,22 @@ ZEND_DLEXPORT zend_extension zend_extension_entry = {
41 PHP_SNUFFLEUPAGUS_COPYRIGHT, 41 PHP_SNUFFLEUPAGUS_COPYRIGHT,
42 sp_zend_startup, 42 sp_zend_startup,
43 NULL, 43 NULL,
44 NULL, /* activate_func_t */ 44 NULL, /* activate_func_t */
45 NULL, /* deactivate_func_t */ 45 NULL, /* deactivate_func_t */
46 NULL, /* message_handler_func_t */ 46 NULL, /* message_handler_func_t */
47 sp_op_array_handler,//zend_global_strict, /* op_array_handler_func_t */ 47 sp_op_array_handler, // zend_global_strict, /* op_array_handler_func_t */
48 NULL, /* statement_handler_func_t */ 48 NULL, /* statement_handler_func_t */
49 NULL, /* fcall_begin_handler_func_t */ 49 NULL, /* fcall_begin_handler_func_t */
50 NULL, /* fcall_end_handler_func_t */ 50 NULL, /* fcall_end_handler_func_t */
51 NULL, /* op_array_ctor_func_t */ 51 NULL, /* op_array_ctor_func_t */
52 NULL, /* op_array_dtor_func_t */ 52 NULL, /* op_array_dtor_func_t */
53 STANDARD_ZEND_EXTENSION_PROPERTIES}; 53 STANDARD_ZEND_EXTENSION_PROPERTIES};
54 54
55PHP_GINIT_FUNCTION(snuffleupagus) { 55PHP_GINIT_FUNCTION(snuffleupagus) {
56#define SP_INIT(F) F = pecalloc(sizeof(*F), 1, 1); 56#define SP_INIT(F) F = pecalloc(sizeof(*F), 1, 1);
57#define SP_INIT_HT(F) \ 57#define SP_INIT_HT(F) \
58 F = pemalloc(sizeof(*F), 1); \ 58 F = pemalloc(sizeof(*F), 1); \
59 zend_hash_init(F, 10, NULL, NULL, 1); 59 zend_hash_init(F, 10, NULL, NULL, 1);
60 60
61 SP_INIT_HT(snuffleupagus_globals->disabled_functions_hook); 61 SP_INIT_HT(snuffleupagus_globals->disabled_functions_hook);
62 SP_INIT_HT(snuffleupagus_globals->sp_internal_functions_hook); 62 SP_INIT_HT(snuffleupagus_globals->sp_internal_functions_hook);
@@ -74,10 +74,14 @@ PHP_GINIT_FUNCTION(snuffleupagus) {
74 SP_INIT(snuffleupagus_globals->config.config_cookie); 74 SP_INIT(snuffleupagus_globals->config.config_cookie);
75 SP_INIT(snuffleupagus_globals->config.config_disabled_constructs); 75 SP_INIT(snuffleupagus_globals->config.config_disabled_constructs);
76 76
77 snuffleupagus_globals->config.config_disabled_constructs->construct_include = sp_list_new(); 77 snuffleupagus_globals->config.config_disabled_constructs->construct_include =
78 snuffleupagus_globals->config.config_disabled_constructs->construct_eval = sp_list_new(); 78 sp_list_new();
79 snuffleupagus_globals->config.config_disabled_functions->disabled_functions = sp_list_new(); 79 snuffleupagus_globals->config.config_disabled_constructs->construct_eval =
80 snuffleupagus_globals->config.config_disabled_functions_ret->disabled_functions = sp_list_new(); 80 sp_list_new();
81 snuffleupagus_globals->config.config_disabled_functions->disabled_functions =
82 sp_list_new();
83 snuffleupagus_globals->config.config_disabled_functions_ret
84 ->disabled_functions = sp_list_new();
81 snuffleupagus_globals->config.config_cookie->cookies = sp_list_new(); 85 snuffleupagus_globals->config.config_cookie->cookies = sp_list_new();
82 86
83#undef SP_INIT 87#undef SP_INIT
@@ -91,7 +95,7 @@ PHP_MINIT_FUNCTION(snuffleupagus) {
91} 95}
92 96
93PHP_MSHUTDOWN_FUNCTION(snuffleupagus) { 97PHP_MSHUTDOWN_FUNCTION(snuffleupagus) {
94#define FREE_HT(F) \ 98#define FREE_HT(F) \
95 zend_hash_destroy(SNUFFLEUPAGUS_G(F)); \ 99 zend_hash_destroy(SNUFFLEUPAGUS_G(F)); \
96 pefree(SNUFFLEUPAGUS_G(F), 1); 100 pefree(SNUFFLEUPAGUS_G(F), 1);
97 101
@@ -108,12 +112,12 @@ PHP_MSHUTDOWN_FUNCTION(snuffleupagus) {
108 pefree(SNUFFLEUPAGUS_G(config.config_disable_xxe), 1); 112 pefree(SNUFFLEUPAGUS_G(config.config_disable_xxe), 1);
109 pefree(SNUFFLEUPAGUS_G(config.config_upload_validation), 1); 113 pefree(SNUFFLEUPAGUS_G(config.config_upload_validation), 1);
110 114
111#define FREE_LST_DISABLE(L) \ 115#define FREE_LST_DISABLE(L) \
112 do { \ 116 do { \
113 sp_list_node* _n = SNUFFLEUPAGUS_G(L); \ 117 sp_list_node *_n = SNUFFLEUPAGUS_G(L); \
114 sp_disabled_function_list_free(_n); \ 118 sp_disabled_function_list_free(_n); \
115 sp_list_free(_n); \ 119 sp_list_free(_n); \
116 } while(0) 120 } while (0)
117 121
118 FREE_LST_DISABLE(config.config_disabled_functions->disabled_functions); 122 FREE_LST_DISABLE(config.config_disabled_functions->disabled_functions);
119 FREE_LST_DISABLE(config.config_disabled_functions_ret->disabled_functions); 123 FREE_LST_DISABLE(config.config_disabled_functions_ret->disabled_functions);
@@ -140,7 +144,7 @@ PHP_RINIT_FUNCTION(snuffleupagus) {
140 if (NULL != SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key) { 144 if (NULL != SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key) {
141 if (NULL != SNUFFLEUPAGUS_G(config).config_cookie->cookies) { 145 if (NULL != SNUFFLEUPAGUS_G(config).config_cookie->cookies) {
142 zend_hash_apply_with_arguments( 146 zend_hash_apply_with_arguments(
143 Z_ARRVAL(PG(http_globals)[TRACK_VARS_COOKIE]), decrypt_cookie, 0); 147 Z_ARRVAL(PG(http_globals)[TRACK_VARS_COOKIE]), decrypt_cookie, 0);
144 } 148 }
145 } 149 }
146 return SUCCESS; 150 return SUCCESS;
@@ -152,8 +156,9 @@ PHP_MINFO_FUNCTION(snuffleupagus) {
152 php_info_print_table_start(); 156 php_info_print_table_start();
153 php_info_print_table_row(2, "snuffleupagus support", "enabled"); 157 php_info_print_table_row(2, "snuffleupagus support", "enabled");
154 php_info_print_table_row(2, "Version", PHP_SNUFFLEUPAGUS_VERSION); 158 php_info_print_table_row(2, "Version", PHP_SNUFFLEUPAGUS_VERSION);
155 php_info_print_table_row(2, "Valid config", 159 php_info_print_table_row(
156 (SNUFFLEUPAGUS_G(is_config_valid) == true)?"yes":"no"); 160 2, "Valid config",
161 (SNUFFLEUPAGUS_G(is_config_valid) == true) ? "yes" : "no");
157 php_info_print_table_end(); 162 php_info_print_table_end();
158 DISPLAY_INI_ENTRIES(); 163 DISPLAY_INI_ENTRIES();
159} 164}
@@ -169,7 +174,7 @@ static PHP_INI_MH(OnUpdateConfiguration) {
169 174
170 config_file = strtok(new_value->val, ","); 175 config_file = strtok(new_value->val, ",");
171 if (sp_parse_config(config_file) != SUCCESS) { 176 if (sp_parse_config(config_file) != SUCCESS) {
172 SNUFFLEUPAGUS_G(is_config_valid) = false; 177 SNUFFLEUPAGUS_G(is_config_valid) = false;
173 return FAILURE; 178 return FAILURE;
174 } 179 }
175 while ((config_file = strtok(NULL, ","))) { 180 while ((config_file = strtok(NULL, ","))) {
@@ -214,21 +219,21 @@ static PHP_INI_MH(OnUpdateConfiguration) {
214 219
215const zend_function_entry snuffleupagus_functions[] = {PHP_FE_END}; 220const zend_function_entry snuffleupagus_functions[] = {PHP_FE_END};
216 221
217zend_module_entry snuffleupagus_module_entry = 222zend_module_entry snuffleupagus_module_entry = {
218 {STANDARD_MODULE_HEADER, 223 STANDARD_MODULE_HEADER,
219 PHP_SNUFFLEUPAGUS_EXTNAME, 224 PHP_SNUFFLEUPAGUS_EXTNAME,
220 snuffleupagus_functions, 225 snuffleupagus_functions,
221 PHP_MINIT(snuffleupagus), 226 PHP_MINIT(snuffleupagus),
222 PHP_MSHUTDOWN(snuffleupagus), 227 PHP_MSHUTDOWN(snuffleupagus),
223 PHP_RINIT(snuffleupagus), 228 PHP_RINIT(snuffleupagus),
224 PHP_RSHUTDOWN(snuffleupagus), 229 PHP_RSHUTDOWN(snuffleupagus),
225 PHP_MINFO(snuffleupagus), 230 PHP_MINFO(snuffleupagus),
226 PHP_SNUFFLEUPAGUS_VERSION, 231 PHP_SNUFFLEUPAGUS_VERSION,
227 PHP_MODULE_GLOBALS(snuffleupagus), 232 PHP_MODULE_GLOBALS(snuffleupagus),
228 PHP_GINIT(snuffleupagus), 233 PHP_GINIT(snuffleupagus),
229 NULL, 234 NULL,
230 NULL, 235 NULL,
231 STANDARD_MODULE_PROPERTIES_EX}; 236 STANDARD_MODULE_PROPERTIES_EX};
232 237
233#ifdef COMPILE_DL_SNUFFLEUPAGUS 238#ifdef COMPILE_DL_SNUFFLEUPAGUS
234#ifdef ZTS 239#ifdef ZTS