-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwordcompression.c
More file actions
183 lines (141 loc) · 3.4 KB
/
Copy pathwordcompression.c
File metadata and controls
183 lines (141 loc) · 3.4 KB
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
#include <stdio.h>
#include <time.h>
#include <libwordcompression.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "php.h"
#include "ext/standard/info.h"
#include "php_wordcompression.h"
#include "zend_exceptions.h"
/* {{{ string wordcompression_decode( [ string $var ] )
*/
PHP_FUNCTION(wordcompression_decode)
{
char *dictionary_var;
size_t dictionary_len;
char *file_var;
size_t file_len;
char *ret;
short error = 0;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_STRING(dictionary_var, dictionary_len)
Z_PARAM_STRING(file_var, file_len)
ZEND_PARSE_PARAMETERS_END();
ret = word_decompressor_string(dictionary_var, file_var, &error);
if (error) {
RETURN_NULL();
return;
}
RETURN_STRING(ret);
}
/* }}}*/
/* {{{ string wordcompression_encode( [ string $var ] )
*/
PHP_FUNCTION(wordcompression_encode)
{
char *dictionary_var;
size_t dictionary_len;
char *file_var;
size_t file_len;
char *ret;
short error = 0;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_STRING(dictionary_var, dictionary_len)
Z_PARAM_STRING(file_var, file_len)
ZEND_PARSE_PARAMETERS_END();
ret = word_compressor_string(dictionary_var, file_var, &error);
if (error) {
RETURN_NULL();
return;
}
RETURN_STRING(ret);
}
/* }}}*/
/* {{{ string wordcompression_error( [ string $var ] )
*/
PHP_FUNCTION(wordcompression_error)
{
RETURN_STRING(word_compression_last_error());
}
/* }}}*/
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(wordcompression)
{
#if defined(ZTS) && defined(COMPILE_DL_WORDCOMPRESSION)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(wordcompression)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(wordcompression)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(wordcompression)
{
php_info_print_table_start();
php_info_print_table_header(2, "wordcompression support", "enabled");
php_info_print_table_end();
}
/* }}} */
/* {{{ arginfo
*/
ZEND_BEGIN_ARG_INFO(arginfo_wordcompression_decode, 0)
ZEND_ARG_INFO(0, _dictionary)
ZEND_ARG_INFO(0, _file)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_wordcompression_encode, 0)
ZEND_ARG_INFO(0, _dictionary)
ZEND_ARG_INFO(0, _file)
ZEND_END_ARG_INFO()
/* }}} */
/* {{{ wordcompression_functions[]
*/
const zend_function_entry wordcompression_functions[] = {
PHP_FE(wordcompression_decode, arginfo_wordcompression_decode)
PHP_FE(wordcompression_encode, arginfo_wordcompression_encode)
PHP_FE(wordcompression_error, NULL)
PHP_FE_END
};
/* }}} */
/* {{{ wordcompression_module_entry
*/
zend_module_entry wordcompression_module_entry = {
STANDARD_MODULE_HEADER,
"wordcompression", /* Extension name */
wordcompression_functions, /* zend_function_entry */
PHP_MINIT(wordcompression), /* PHP_MINIT - Module initialization */
PHP_MSHUTDOWN(wordcompression), /* PHP_MSHUTDOWN - Module shutdown */
PHP_RINIT(wordcompression), /* PHP_RINIT - Request initialization */
NULL, /* PHP_RSHUTDOWN - Request shutdown */
PHP_MINFO(wordcompression), /* PHP_MINFO - Module info */
PHP_WORDCOMPRESSION_VERSION, /* Version */
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_WORDCOMPRESSION
# ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
# endif
ZEND_GET_MODULE(wordcompression)
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
*/