-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkhttp.c
190 lines (139 loc) · 3.5 KB
/
khttp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/* This file was generated automatically by Zephir do not modify it! */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <php.h>
#if PHP_VERSION_ID < 50500
#include <locale.h>
#endif
#include "php_ext.h"
#include "khttp.h"
#include <ext/standard/info.h>
#include <Zend/zend_operators.h>
#include <Zend/zend_exceptions.h>
#include <Zend/zend_interfaces.h>
#include "kernel/globals.h"
#include "kernel/main.h"
#include "kernel/fcall.h"
#include "kernel/memory.h"
zend_class_entry *khttp_request_ce;
ZEND_DECLARE_MODULE_GLOBALS(khttp)
PHP_INI_BEGIN()
PHP_INI_END()
static PHP_MINIT_FUNCTION(khttp)
{
#if PHP_VERSION_ID < 50500
char* old_lc_all = setlocale(LC_ALL, NULL);
if (old_lc_all) {
size_t len = strlen(old_lc_all);
char *tmp = calloc(len+1, 1);
if (UNEXPECTED(!tmp)) {
return FAILURE;
}
memcpy(tmp, old_lc_all, len);
old_lc_all = tmp;
}
setlocale(LC_ALL, "C");
#endif
REGISTER_INI_ENTRIES();
ZEPHIR_INIT(Khttp_Request);
#if PHP_VERSION_ID < 50500
setlocale(LC_ALL, old_lc_all);
free(old_lc_all);
#endif
return SUCCESS;
}
#ifndef ZEPHIR_RELEASE
static PHP_MSHUTDOWN_FUNCTION(khttp)
{
zephir_deinitialize_memory(TSRMLS_C);
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
#endif
/**
* Initialize globals on each request or each thread started
*/
static void php_zephir_init_globals(zend_khttp_globals *khttp_globals TSRMLS_DC)
{
khttp_globals->initialized = 0;
/* Memory options */
khttp_globals->active_memory = NULL;
/* Virtual Symbol Tables */
khttp_globals->active_symbol_table = NULL;
/* Cache Enabled */
khttp_globals->cache_enabled = 1;
/* Recursive Lock */
khttp_globals->recursive_lock = 0;
/* Static cache */
memset(khttp_globals->scache, '\0', sizeof(zephir_fcall_cache_entry*) * ZEPHIR_MAX_CACHE_SLOTS);
}
/**
* Initialize globals only on each thread started
*/
static void php_zephir_init_module_globals(zend_khttp_globals *khttp_globals TSRMLS_DC)
{
}
static PHP_RINIT_FUNCTION(khttp)
{
zend_khttp_globals *khttp_globals_ptr = ZEPHIR_VGLOBAL;
php_zephir_init_globals(khttp_globals_ptr TSRMLS_CC);
//zephir_init_interned_strings(TSRMLS_C);
zephir_initialize_memory(khttp_globals_ptr TSRMLS_CC);
return SUCCESS;
}
static PHP_RSHUTDOWN_FUNCTION(khttp)
{
zephir_deinitialize_memory(TSRMLS_C);
return SUCCESS;
}
static PHP_MINFO_FUNCTION(khttp)
{
php_info_print_box_start(0);
php_printf("%s", PHP_KHTTP_DESCRIPTION);
php_info_print_box_end();
php_info_print_table_start();
php_info_print_table_header(2, PHP_KHTTP_NAME, "enabled");
php_info_print_table_row(2, "Author", PHP_KHTTP_AUTHOR);
php_info_print_table_row(2, "Version", PHP_KHTTP_VERSION);
php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__ );
php_info_print_table_row(2, "Powered by Zephir", "Version " PHP_KHTTP_ZEPVERSION);
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
}
static PHP_GINIT_FUNCTION(khttp)
{
php_zephir_init_globals(khttp_globals TSRMLS_CC);
php_zephir_init_module_globals(khttp_globals TSRMLS_CC);
}
static PHP_GSHUTDOWN_FUNCTION(khttp)
{
}
zend_function_entry php_khttp_functions[] = {
ZEND_FE_END
};
zend_module_entry khttp_module_entry = {
STANDARD_MODULE_HEADER_EX,
NULL,
NULL,
PHP_KHTTP_EXTNAME,
php_khttp_functions,
PHP_MINIT(khttp),
#ifndef ZEPHIR_RELEASE
PHP_MSHUTDOWN(khttp),
#else
NULL,
#endif
PHP_RINIT(khttp),
PHP_RSHUTDOWN(khttp),
PHP_MINFO(khttp),
PHP_KHTTP_VERSION,
ZEND_MODULE_GLOBALS(khttp),
PHP_GINIT(khttp),
PHP_GSHUTDOWN(khttp),
NULL,
STANDARD_MODULE_PROPERTIES_EX
};
#ifdef COMPILE_DL_KHTTP
ZEND_GET_MODULE(khttp)
#endif