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
*/
64
60
zend_module_entry iconv_module_entry = {
@@ -71,11 +67,7 @@ zend_module_entry iconv_module_entry = {
71
67
NULL ,
72
68
PHP_MINFO (miconv ),
73
69
PHP_ICONV_VERSION ,
74
- PHP_MODULE_GLOBALS (iconv ),
75
- PHP_GINIT (iconv ),
76
- NULL ,
77
- NULL ,
78
- STANDARD_MODULE_PROPERTIES_EX
70
+ STANDARD_MODULE_PROPERTIES ,
79
71
};
80
72
/* }}} */
81
73
@@ -86,18 +78,6 @@ ZEND_TSRMLS_CACHE_DEFINE()
86
78
ZEND_GET_MODULE (iconv )
87
79
#endif
88
80
89
- /* {{{ PHP_GINIT_FUNCTION */
90
- static PHP_GINIT_FUNCTION (iconv )
91
- {
92
- #if defined(COMPILE_DL_ICONV ) && defined(ZTS )
93
- ZEND_TSRMLS_CACHE_UPDATE ();
94
- #endif
95
- iconv_globals -> input_encoding = NULL ;
96
- iconv_globals -> output_encoding = NULL ;
97
- iconv_globals -> internal_encoding = NULL ;
98
- }
99
- /* }}} */
100
-
101
81
#if defined(HAVE_LIBICONV ) && defined(ICONV_ALIASED_LIBICONV )
102
82
#define iconv libiconv
103
83
#endif
@@ -142,62 +122,11 @@ static const char _generic_superset_name[] = ICONV_UCS4_ENCODING;
142
122
#define GENERIC_SUPERSET_NBYTES 4
143
123
/* }}} */
144
124
145
-
146
- static PHP_INI_MH (OnUpdateInputEncoding )
147
- {
148
- if (ZSTR_LEN (new_value ) >= ICONV_CSNMAXLEN ) {
149
- return FAILURE ;
150
- }
151
- if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME )) {
152
- php_error_docref ("ref.iconv" , E_DEPRECATED , "Use of iconv.input_encoding is deprecated" );
153
- }
154
- OnUpdateString (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage );
155
- return SUCCESS ;
156
- }
157
-
158
-
159
- static PHP_INI_MH (OnUpdateOutputEncoding )
160
- {
161
- if (ZSTR_LEN (new_value ) >= ICONV_CSNMAXLEN ) {
162
- return FAILURE ;
163
- }
164
- if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME )) {
165
- php_error_docref ("ref.iconv" , E_DEPRECATED , "Use of iconv.output_encoding is deprecated" );
166
- }
167
- OnUpdateString (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage );
168
- return SUCCESS ;
169
- }
170
-
171
-
172
- static PHP_INI_MH (OnUpdateInternalEncoding )
173
- {
174
- if (ZSTR_LEN (new_value ) >= ICONV_CSNMAXLEN ) {
175
- return FAILURE ;
176
- }
177
- if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME )) {
178
- php_error_docref ("ref.iconv" , E_DEPRECATED , "Use of iconv.internal_encoding is deprecated" );
179
- }
180
- OnUpdateString (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage );
181
- return SUCCESS ;
182
- }
183
-
184
-
185
- /* {{{ PHP_INI
186
- */
187
- PHP_INI_BEGIN ()
188
- STD_PHP_INI_ENTRY ("iconv.input_encoding" , "" , PHP_INI_ALL , OnUpdateInputEncoding , input_encoding , zend_iconv_globals , iconv_globals )
189
- STD_PHP_INI_ENTRY ("iconv.output_encoding" , "" , PHP_INI_ALL , OnUpdateOutputEncoding , output_encoding , zend_iconv_globals , iconv_globals )
190
- STD_PHP_INI_ENTRY ("iconv.internal_encoding" , "" , PHP_INI_ALL , OnUpdateInternalEncoding , internal_encoding , zend_iconv_globals , iconv_globals )
191
- PHP_INI_END ()
192
- /* }}} */
193
-
194
125
/* {{{ PHP_MINIT_FUNCTION */
195
126
PHP_MINIT_FUNCTION (miconv )
196
127
{
197
128
char * version = "unknown" ;
198
129
199
- REGISTER_INI_ENTRIES ();
200
-
201
130
#if HAVE_LIBICONV
202
131
{
203
132
static char buf [16 ];
@@ -236,7 +165,6 @@ PHP_MINIT_FUNCTION(miconv)
236
165
PHP_MSHUTDOWN_FUNCTION (miconv )
237
166
{
238
167
php_iconv_stream_filter_unregister_factory ();
239
- UNREGISTER_INI_ENTRIES ();
240
168
return SUCCESS ;
241
169
}
242
170
/* }}} */
@@ -254,33 +182,9 @@ PHP_MINFO_FUNCTION(miconv)
254
182
php_info_print_table_row (2 , "iconv implementation" , Z_STRVAL_P (iconv_impl ));
255
183
php_info_print_table_row (2 , "iconv library version" , Z_STRVAL_P (iconv_ver ));
256
184
php_info_print_table_end ();
257
-
258
- DISPLAY_INI_ENTRIES ();
259
185
}
260
186
/* }}} */
261
187
262
- static const char * get_internal_encoding (void ) {
263
- if (ICONVG (internal_encoding ) && ICONVG (internal_encoding )[0 ]) {
264
- return ICONVG (internal_encoding );
265
- }
266
- return php_get_internal_encoding ();
267
- }
268
-
269
- static const char * get_input_encoding (void ) {
270
- if (ICONVG (input_encoding ) && ICONVG (input_encoding )[0 ]) {
271
- return ICONVG (input_encoding );
272
- }
273
- return php_get_input_encoding ();
274
- }
275
-
276
- static const char * get_output_encoding (void ) {
277
- if (ICONVG (output_encoding ) && ICONVG (output_encoding )[0 ]) {
278
- return ICONVG (output_encoding );
279
- }
280
- return php_get_output_encoding ();
281
- }
282
-
283
-
284
188
static int php_iconv_output_conflict (const char * handler_name , size_t handler_name_len )
285
189
{
286
190
if (php_output_get_level ()) {
@@ -321,12 +225,16 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
321
225
322
226
if (mimetype != NULL && !(output_context -> op & PHP_OUTPUT_HANDLER_CLEAN )) {
323
227
size_t len ;
324
- char * p = strstr (get_output_encoding (), "//" );
228
+ char * p = strstr (php_get_output_encoding (), "//" );
325
229
326
230
if (p ) {
327
- 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 ());
231
+ len = spprintf (& content_type , 0 , "Content-Type:%.*s; charset=%.*s" ,
232
+ mimetype_len ? mimetype_len : (int ) strlen (mimetype ), mimetype ,
233
+ (int ) (p - php_get_output_encoding ()), php_get_output_encoding ());
328
234
} else {
329
- len = spprintf (& content_type , 0 , "Content-Type:%.*s; charset=%s" , mimetype_len ? mimetype_len : (int ) strlen (mimetype ), mimetype , get_output_encoding ());
235
+ len = spprintf (& content_type , 0 , "Content-Type:%.*s; charset=%s" ,
236
+ mimetype_len ? mimetype_len : (int ) strlen (mimetype ),
237
+ mimetype , php_get_output_encoding ());
330
238
}
331
239
if (content_type && SUCCESS == sapi_add_header (content_type , len , 0 )) {
332
240
SG (sapi_headers ).send_default_content_type = 0 ;
@@ -338,7 +246,9 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
338
246
if (output_context -> in .used ) {
339
247
zend_string * out ;
340
248
output_context -> out .free = 1 ;
341
- _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 ());
249
+ _php_iconv_show_error (php_iconv_string (output_context -> in .data , output_context -> in .used , & out ,
250
+ php_get_output_encoding (), php_get_internal_encoding ()), php_get_output_encoding (),
251
+ php_get_internal_encoding ());
342
252
if (out ) {
343
253
output_context -> out .data = estrndup (ZSTR_VAL (out ), ZSTR_LEN (out ));
344
254
output_context -> out .used = ZSTR_LEN (out );
@@ -1840,7 +1750,7 @@ PHP_FUNCTION(iconv_strlen)
1840
1750
}
1841
1751
1842
1752
if (charset == NULL ) {
1843
- charset = get_internal_encoding ();
1753
+ charset = php_get_internal_encoding ();
1844
1754
} else if (charset_len >= ICONV_CSNMAXLEN ) {
1845
1755
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
1846
1756
RETURN_FALSE ;
@@ -1877,7 +1787,7 @@ PHP_FUNCTION(iconv_substr)
1877
1787
}
1878
1788
1879
1789
if (charset == NULL ) {
1880
- charset = get_internal_encoding ();
1790
+ charset = php_get_internal_encoding ();
1881
1791
} else if (charset_len >= ICONV_CSNMAXLEN ) {
1882
1792
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
1883
1793
RETURN_FALSE ;
@@ -1919,7 +1829,7 @@ PHP_FUNCTION(iconv_strpos)
1919
1829
}
1920
1830
1921
1831
if (charset == NULL ) {
1922
- charset = get_internal_encoding ();
1832
+ charset = php_get_internal_encoding ();
1923
1833
} else if (charset_len >= ICONV_CSNMAXLEN ) {
1924
1834
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
1925
1835
RETURN_FALSE ;
@@ -1979,7 +1889,7 @@ PHP_FUNCTION(iconv_strrpos)
1979
1889
}
1980
1890
1981
1891
if (charset == NULL ) {
1982
- charset = get_internal_encoding ();
1892
+ charset = php_get_internal_encoding ();
1983
1893
} else if (charset_len >= ICONV_CSNMAXLEN ) {
1984
1894
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
1985
1895
RETURN_FALSE ;
@@ -2008,7 +1918,7 @@ PHP_FUNCTION(iconv_mime_encode)
2008
1918
smart_str retval = {0 };
2009
1919
php_iconv_err_t err ;
2010
1920
2011
- const char * in_charset = get_internal_encoding ();
1921
+ const char * in_charset = php_get_internal_encoding ();
2012
1922
const char * out_charset = in_charset ;
2013
1923
zend_long line_len = 76 ;
2014
1924
const char * lfchars = "\r\n" ;
@@ -2120,7 +2030,7 @@ PHP_FUNCTION(iconv_mime_decode)
2120
2030
}
2121
2031
2122
2032
if (charset == NULL ) {
2123
- charset = get_internal_encoding ();
2033
+ charset = php_get_internal_encoding ();
2124
2034
} else if (charset_len >= ICONV_CSNMAXLEN ) {
2125
2035
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
2126
2036
RETURN_FALSE ;
@@ -2162,7 +2072,7 @@ PHP_FUNCTION(iconv_mime_decode_headers)
2162
2072
}
2163
2073
2164
2074
if (charset == NULL ) {
2165
- charset = get_internal_encoding ();
2075
+ charset = php_get_internal_encoding ();
2166
2076
} else if (charset_len >= ICONV_CSNMAXLEN ) {
2167
2077
php_error_docref (NULL , E_WARNING , "Charset parameter exceeds the maximum allowed length of %d characters" , ICONV_CSNMAXLEN );
2168
2078
RETURN_FALSE ;
@@ -2281,8 +2191,7 @@ PHP_FUNCTION(iconv_set_encoding)
2281
2191
{
2282
2192
char * type ;
2283
2193
zend_string * charset ;
2284
- size_t type_len , retval ;
2285
- zend_string * name ;
2194
+ size_t type_len ;
2286
2195
2287
2196
if (zend_parse_parameters (ZEND_NUM_ARGS (), "sS" , & type , & type_len , & charset ) == FAILURE ) {
2288
2197
RETURN_THROWS ();
@@ -2293,24 +2202,7 @@ PHP_FUNCTION(iconv_set_encoding)
2293
2202
RETURN_FALSE ;
2294
2203
}
2295
2204
2296
- if (!strcasecmp ("input_encoding" , type )) {
2297
- name = zend_string_init ("iconv.input_encoding" , sizeof ("iconv.input_encoding" ) - 1 , 0 );
2298
- } else if (!strcasecmp ("output_encoding" , type )) {
2299
- name = zend_string_init ("iconv.output_encoding" , sizeof ("iconv.output_encoding" ) - 1 , 0 );
2300
- } else if (!strcasecmp ("internal_encoding" , type )) {
2301
- name = zend_string_init ("iconv.internal_encoding" , sizeof ("iconv.internal_encoding" ) - 1 , 0 );
2302
- } else {
2303
- RETURN_FALSE ;
2304
- }
2305
-
2306
- retval = zend_alter_ini_entry (name , charset , PHP_INI_USER , PHP_INI_STAGE_RUNTIME );
2307
- zend_string_release_ex (name , 0 );
2308
-
2309
- if (retval == SUCCESS ) {
2310
- RETURN_TRUE ;
2311
- } else {
2312
- RETURN_FALSE ;
2313
- }
2205
+ RETURN_FALSE ;
2314
2206
}
2315
2207
/* }}} */
2316
2208
@@ -2327,15 +2219,15 @@ PHP_FUNCTION(iconv_get_encoding)
2327
2219
2328
2220
if (!strcasecmp ("all" , type )) {
2329
2221
array_init (return_value );
2330
- add_assoc_string (return_value , "input_encoding" , get_input_encoding ());
2331
- add_assoc_string (return_value , "output_encoding" , get_output_encoding ());
2332
- add_assoc_string (return_value , "internal_encoding" , get_internal_encoding ());
2222
+ add_assoc_string (return_value , "input_encoding" , php_get_input_encoding ());
2223
+ add_assoc_string (return_value , "output_encoding" , php_get_output_encoding ());
2224
+ add_assoc_string (return_value , "internal_encoding" , php_get_internal_encoding ());
2333
2225
} else if (!strcasecmp ("input_encoding" , type )) {
2334
- RETVAL_STRING (get_input_encoding ());
2226
+ RETVAL_STRING (php_get_input_encoding ());
2335
2227
} else if (!strcasecmp ("output_encoding" , type )) {
2336
- RETVAL_STRING (get_output_encoding ());
2228
+ RETVAL_STRING (php_get_output_encoding ());
2337
2229
} else if (!strcasecmp ("internal_encoding" , type )) {
2338
- RETVAL_STRING (get_internal_encoding ());
2230
+ RETVAL_STRING (php_get_internal_encoding ());
2339
2231
} else {
2340
2232
RETURN_FALSE ;
2341
2233
}
0 commit comments