25
25
#include "ext/standard/info.h"
26
26
#include "main/php_output.h"
27
27
#include "SAPI.h"
28
- #include "php_ini.h"
29
28
30
29
#include <stdlib.h>
31
30
#include <errno.h>
56
55
#define _php_iconv_memequal (a , b , c ) \
57
56
(memcmp(a, b, c) == 0)
58
57
59
- ZEND_DECLARE_MODULE_GLOBALS (iconv )
60
- static PHP_GINIT_FUNCTION (iconv );
61
-
62
58
/* {{{ iconv_module_entry */
63
59
zend_module_entry iconv_module_entry = {
64
60
STANDARD_MODULE_HEADER ,
@@ -70,11 +66,7 @@ zend_module_entry iconv_module_entry = {
70
66
NULL ,
71
67
PHP_MINFO (miconv ),
72
68
PHP_ICONV_VERSION ,
73
- PHP_MODULE_GLOBALS (iconv ),
74
- PHP_GINIT (iconv ),
75
- NULL ,
76
- NULL ,
77
- STANDARD_MODULE_PROPERTIES_EX
69
+ STANDARD_MODULE_PROPERTIES ,
78
70
};
79
71
/* }}} */
80
72
@@ -85,18 +77,6 @@ ZEND_TSRMLS_CACHE_DEFINE()
85
77
ZEND_GET_MODULE (iconv )
86
78
#endif
87
79
88
- /* {{{ PHP_GINIT_FUNCTION */
89
- static PHP_GINIT_FUNCTION (iconv )
90
- {
91
- #if defined(COMPILE_DL_ICONV ) && defined(ZTS )
92
- ZEND_TSRMLS_CACHE_UPDATE ();
93
- #endif
94
- iconv_globals -> input_encoding = NULL ;
95
- iconv_globals -> output_encoding = NULL ;
96
- iconv_globals -> internal_encoding = NULL ;
97
- }
98
- /* }}} */
99
-
100
80
#if defined(HAVE_LIBICONV ) && defined(ICONV_ALIASED_LIBICONV )
101
81
#define iconv libiconv
102
82
#endif
@@ -141,61 +121,11 @@ static const char _generic_superset_name[] = ICONV_UCS4_ENCODING;
141
121
#define GENERIC_SUPERSET_NBYTES 4
142
122
/* }}} */
143
123
144
-
145
- static PHP_INI_MH (OnUpdateInputEncoding )
146
- {
147
- if (ZSTR_LEN (new_value ) >= ICONV_CSNMAXLEN ) {
148
- return FAILURE ;
149
- }
150
- if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME )) {
151
- php_error_docref ("ref.iconv" , E_DEPRECATED , "Use of iconv.input_encoding is deprecated" );
152
- }
153
- OnUpdateString (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage );
154
- return SUCCESS ;
155
- }
156
-
157
-
158
- static PHP_INI_MH (OnUpdateOutputEncoding )
159
- {
160
- if (ZSTR_LEN (new_value ) >= ICONV_CSNMAXLEN ) {
161
- return FAILURE ;
162
- }
163
- if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME )) {
164
- php_error_docref ("ref.iconv" , E_DEPRECATED , "Use of iconv.output_encoding is deprecated" );
165
- }
166
- OnUpdateString (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage );
167
- return SUCCESS ;
168
- }
169
-
170
-
171
- static PHP_INI_MH (OnUpdateInternalEncoding )
172
- {
173
- if (ZSTR_LEN (new_value ) >= ICONV_CSNMAXLEN ) {
174
- return FAILURE ;
175
- }
176
- if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME )) {
177
- php_error_docref ("ref.iconv" , E_DEPRECATED , "Use of iconv.internal_encoding is deprecated" );
178
- }
179
- OnUpdateString (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage );
180
- return SUCCESS ;
181
- }
182
-
183
-
184
- /* {{{ PHP_INI */
185
- PHP_INI_BEGIN ()
186
- STD_PHP_INI_ENTRY ("iconv.input_encoding" , "" , PHP_INI_ALL , OnUpdateInputEncoding , input_encoding , zend_iconv_globals , iconv_globals )
187
- STD_PHP_INI_ENTRY ("iconv.output_encoding" , "" , PHP_INI_ALL , OnUpdateOutputEncoding , output_encoding , zend_iconv_globals , iconv_globals )
188
- STD_PHP_INI_ENTRY ("iconv.internal_encoding" , "" , PHP_INI_ALL , OnUpdateInternalEncoding , internal_encoding , zend_iconv_globals , iconv_globals )
189
- PHP_INI_END ()
190
- /* }}} */
191
-
192
124
/* {{{ PHP_MINIT_FUNCTION */
193
125
PHP_MINIT_FUNCTION (miconv )
194
126
{
195
127
char * version = "unknown" ;
196
128
197
- REGISTER_INI_ENTRIES ();
198
-
199
129
#ifdef HAVE_LIBICONV
200
130
{
201
131
static char buf [16 ];
@@ -234,7 +164,6 @@ PHP_MINIT_FUNCTION(miconv)
234
164
PHP_MSHUTDOWN_FUNCTION (miconv )
235
165
{
236
166
php_iconv_stream_filter_unregister_factory ();
237
- UNREGISTER_INI_ENTRIES ();
238
167
return SUCCESS ;
239
168
}
240
169
/* }}} */
@@ -252,33 +181,9 @@ PHP_MINFO_FUNCTION(miconv)
252
181
php_info_print_table_row (2 , "iconv implementation" , Z_STRVAL_P (iconv_impl ));
253
182
php_info_print_table_row (2 , "iconv library version" , Z_STRVAL_P (iconv_ver ));
254
183
php_info_print_table_end ();
255
-
256
- DISPLAY_INI_ENTRIES ();
257
184
}
258
185
/* }}} */
259
186
260
- static const char * get_internal_encoding (void ) {
261
- if (ICONVG (internal_encoding ) && ICONVG (internal_encoding )[0 ]) {
262
- return ICONVG (internal_encoding );
263
- }
264
- return php_get_internal_encoding ();
265
- }
266
-
267
- static const char * get_input_encoding (void ) {
268
- if (ICONVG (input_encoding ) && ICONVG (input_encoding )[0 ]) {
269
- return ICONVG (input_encoding );
270
- }
271
- return php_get_input_encoding ();
272
- }
273
-
274
- static const char * get_output_encoding (void ) {
275
- if (ICONVG (output_encoding ) && ICONVG (output_encoding )[0 ]) {
276
- return ICONVG (output_encoding );
277
- }
278
- return php_get_output_encoding ();
279
- }
280
-
281
-
282
187
static int php_iconv_output_conflict (const char * handler_name , size_t handler_name_len )
283
188
{
284
189
if (php_output_get_level ()) {
@@ -319,12 +224,16 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
319
224
320
225
if (mimetype != NULL && !(output_context -> op & PHP_OUTPUT_HANDLER_CLEAN )) {
321
226
size_t len ;
322
- char * p = strstr (get_output_encoding (), "//" );
227
+ char * p = strstr (php_get_output_encoding (), "//" );
323
228
324
229
if (p ) {
325
- len = spprintf (& content_type , 0 , "Content-Type:%.*s; charset=%.*s" , mimetype_len ? mimetype_len : (int ) strlen (mimetype ), mimetype , (int ) (p - get_output_encoding ()), get_output_encoding ());
230
+ len = spprintf (& content_type , 0 , "Content-Type:%.*s; charset=%.*s" ,
231
+ mimetype_len ? mimetype_len : (int ) strlen (mimetype ), mimetype ,
232
+ (int ) (p - php_get_output_encoding ()), php_get_output_encoding ());
326
233
} else {
327
- len = spprintf (& content_type , 0 , "Content-Type:%.*s; charset=%s" , mimetype_len ? mimetype_len : (int ) strlen (mimetype ), mimetype , get_output_encoding ());
234
+ len = spprintf (& content_type , 0 , "Content-Type:%.*s; charset=%s" ,
235
+ mimetype_len ? mimetype_len : (int ) strlen (mimetype ),
236
+ mimetype , php_get_output_encoding ());
328
237
}
329
238
if (content_type && SUCCESS == sapi_add_header (content_type , len , 0 )) {
330
239
SG (sapi_headers ).send_default_content_type = 0 ;
@@ -336,7 +245,9 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
336
245
if (output_context -> in .used ) {
337
246
zend_string * out ;
338
247
output_context -> out .free = 1 ;
339
- _php_iconv_show_error (php_iconv_string (output_context -> in .data , output_context -> in .used , & out , get_output_encoding (), get_internal_encoding ()), get_output_encoding (), get_internal_encoding ());
248
+ _php_iconv_show_error (php_iconv_string (output_context -> in .data , output_context -> in .used , & out ,
249
+ php_get_output_encoding (), php_get_internal_encoding ()), php_get_output_encoding (),
250
+ php_get_internal_encoding ());
340
251
if (out ) {
341
252
output_context -> out .data = estrndup (ZSTR_VAL (out ), ZSTR_LEN (out ));
342
253
output_context -> out .used = ZSTR_LEN (out );
@@ -1836,7 +1747,7 @@ PHP_FUNCTION(iconv_strlen)
1836
1747
}
1837
1748
1838
1749
if (charset == NULL ) {
1839
- charset = get_internal_encoding ();
1750
+ charset = php_get_internal_encoding ();
1840
1751
} else if (charset_len >= ICONV_CSNMAXLEN ) {
1841
1752
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
1842
1753
RETURN_FALSE ;
@@ -1872,7 +1783,7 @@ PHP_FUNCTION(iconv_substr)
1872
1783
}
1873
1784
1874
1785
if (charset == NULL ) {
1875
- charset = get_internal_encoding ();
1786
+ charset = php_get_internal_encoding ();
1876
1787
} else if (charset_len >= ICONV_CSNMAXLEN ) {
1877
1788
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
1878
1789
RETURN_FALSE ;
@@ -1913,7 +1824,7 @@ PHP_FUNCTION(iconv_strpos)
1913
1824
}
1914
1825
1915
1826
if (charset == NULL ) {
1916
- charset = get_internal_encoding ();
1827
+ charset = php_get_internal_encoding ();
1917
1828
} else if (charset_len >= ICONV_CSNMAXLEN ) {
1918
1829
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
1919
1830
RETURN_FALSE ;
@@ -1972,7 +1883,7 @@ PHP_FUNCTION(iconv_strrpos)
1972
1883
}
1973
1884
1974
1885
if (charset == NULL ) {
1975
- charset = get_internal_encoding ();
1886
+ charset = php_get_internal_encoding ();
1976
1887
} else if (charset_len >= ICONV_CSNMAXLEN ) {
1977
1888
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
1978
1889
RETURN_FALSE ;
@@ -2000,7 +1911,7 @@ PHP_FUNCTION(iconv_mime_encode)
2000
1911
smart_str retval = {0 };
2001
1912
php_iconv_err_t err ;
2002
1913
2003
- const char * in_charset = get_internal_encoding ();
1914
+ const char * in_charset = php_get_internal_encoding ();
2004
1915
const char * out_charset = in_charset ;
2005
1916
zend_long line_len = 76 ;
2006
1917
const char * lfchars = "\r\n" ;
@@ -2111,7 +2022,7 @@ PHP_FUNCTION(iconv_mime_decode)
2111
2022
}
2112
2023
2113
2024
if (charset == NULL ) {
2114
- charset = get_internal_encoding ();
2025
+ charset = php_get_internal_encoding ();
2115
2026
} else if (charset_len >= ICONV_CSNMAXLEN ) {
2116
2027
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
2117
2028
RETURN_FALSE ;
@@ -2152,7 +2063,7 @@ PHP_FUNCTION(iconv_mime_decode_headers)
2152
2063
}
2153
2064
2154
2065
if (charset == NULL ) {
2155
- charset = get_internal_encoding ();
2066
+ charset = php_get_internal_encoding ();
2156
2067
} else if (charset_len >= ICONV_CSNMAXLEN ) {
2157
2068
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
2158
2069
RETURN_FALSE ;
@@ -2269,8 +2180,7 @@ PHP_FUNCTION(iconv_set_encoding)
2269
2180
{
2270
2181
char * type ;
2271
2182
zend_string * charset ;
2272
- size_t type_len , retval ;
2273
- zend_string * name ;
2183
+ size_t type_len ;
2274
2184
2275
2185
if (zend_parse_parameters (ZEND_NUM_ARGS (), "sS" , & type , & type_len , & charset ) == FAILURE ) {
2276
2186
RETURN_THROWS ();
@@ -2281,24 +2191,7 @@ PHP_FUNCTION(iconv_set_encoding)
2281
2191
RETURN_FALSE ;
2282
2192
}
2283
2193
2284
- if (!strcasecmp ("input_encoding" , type )) {
2285
- name = zend_string_init ("iconv.input_encoding" , sizeof ("iconv.input_encoding" ) - 1 , 0 );
2286
- } else if (!strcasecmp ("output_encoding" , type )) {
2287
- name = zend_string_init ("iconv.output_encoding" , sizeof ("iconv.output_encoding" ) - 1 , 0 );
2288
- } else if (!strcasecmp ("internal_encoding" , type )) {
2289
- name = zend_string_init ("iconv.internal_encoding" , sizeof ("iconv.internal_encoding" ) - 1 , 0 );
2290
- } else {
2291
- RETURN_FALSE ;
2292
- }
2293
-
2294
- retval = zend_alter_ini_entry (name , charset , PHP_INI_USER , PHP_INI_STAGE_RUNTIME );
2295
- zend_string_release_ex (name , 0 );
2296
-
2297
- if (retval == SUCCESS ) {
2298
- RETURN_TRUE ;
2299
- } else {
2300
- RETURN_FALSE ;
2301
- }
2194
+ RETURN_FALSE ;
2302
2195
}
2303
2196
/* }}} */
2304
2197
@@ -2314,15 +2207,15 @@ PHP_FUNCTION(iconv_get_encoding)
2314
2207
2315
2208
if (!strcasecmp ("all" , type )) {
2316
2209
array_init (return_value );
2317
- add_assoc_string (return_value , "input_encoding" , get_input_encoding ());
2318
- add_assoc_string (return_value , "output_encoding" , get_output_encoding ());
2319
- add_assoc_string (return_value , "internal_encoding" , get_internal_encoding ());
2210
+ add_assoc_string (return_value , "input_encoding" , php_get_input_encoding ());
2211
+ add_assoc_string (return_value , "output_encoding" , php_get_output_encoding ());
2212
+ add_assoc_string (return_value , "internal_encoding" , php_get_internal_encoding ());
2320
2213
} else if (!strcasecmp ("input_encoding" , type )) {
2321
- RETVAL_STRING (get_input_encoding ());
2214
+ RETVAL_STRING (php_get_input_encoding ());
2322
2215
} else if (!strcasecmp ("output_encoding" , type )) {
2323
- RETVAL_STRING (get_output_encoding ());
2216
+ RETVAL_STRING (php_get_output_encoding ());
2324
2217
} else if (!strcasecmp ("internal_encoding" , type )) {
2325
- RETVAL_STRING (get_internal_encoding ());
2218
+ RETVAL_STRING (php_get_internal_encoding ());
2326
2219
} else {
2327
2220
RETURN_FALSE ;
2328
2221
}
0 commit comments