From: foobar Date: Sun, 27 May 2001 19:43:16 +0000 (+0000) Subject: Per Sterling's request I'm committing this. X-Git-Tag: PRE_GRANULAR_GARBAGE_FIX~222 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67f2331d171ca0f5a145730f9b9f8de7c312e8ec;p=php Per Sterling's request I'm committing this. This works fine for me now. (I'm using external iconv libs) --- diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 7067bab1ac..77a3bc7960 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -22,15 +22,18 @@ #endif #include "php.h" -#include "php_ini.h" #if HAVE_ICONV +#include + +#include "php_globals.h" #include "php_iconv.h" #include "ext/standard/info.h" #include "ext/standard/php_output.h" +#include "SAPI.h" +#include "php_ini.h" -ZEND_DECLARE_MODULE_GLOBALS(iconv) #if HAVE_LIBICONV #define icv_open(a,b) libiconv_open(a,b) @@ -43,9 +46,6 @@ ZEND_DECLARE_MODULE_GLOBALS(iconv) #endif -/* True global resources - no need for thread safety here */ -static int le_iconv; - /* Every user visible function must have an entry in iconv_functions[]. */ function_entry iconv_functions[] = { @@ -59,28 +59,29 @@ function_entry iconv_functions[] = { zend_module_entry iconv_module_entry = { "iconv", iconv_functions, - PHP_MINIT(iconv), - PHP_MSHUTDOWN(iconv), + PHP_MINIT(miconv), + PHP_MSHUTDOWN(miconv), NULL, NULL, - PHP_MINFO(iconv), + PHP_MINFO(miconv), STANDARD_MODULE_PROPERTIES }; +ZEND_DECLARE_MODULE_GLOBALS(iconv) + #ifdef COMPILE_DL_ICONV ZEND_GET_MODULE(iconv) #endif int php_iconv_string(char *, char **, char *, char *); - PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("iconv.input_encoding", ICONV_INPUT_ENCODING, PHP_INI_ALL, OnUpdateString, input_encoding, zend_iconv_globals, iconv_globals) - STD_PHP_INI_ENTRY("iconv.output_encoding", ICONV_OUTPUT_ENCODING, PHP_INI_ALL, OnUpdateString, output_encoding, zend_iconv_globals, iconv_globals) - STD_PHP_INI_ENTRY("iconv.internal_encoding", ICONV_INTERNAL_ENCODING, PHP_INI_ALL, OnUpdateString, internal_encoding, zend_iconv_globals, iconv_globals) + STD_PHP_INI_ENTRY("iconv.input_encoding", ICONV_INPUT_ENCODING, PHP_INI_ALL, OnUpdateString, input_encoding, zend_iconv_globals, iconv_globals) + STD_PHP_INI_ENTRY("iconv.output_encoding", ICONV_OUTPUT_ENCODING, PHP_INI_ALL, OnUpdateString, output_encoding, zend_iconv_globals, iconv_globals) + STD_PHP_INI_ENTRY("iconv.internal_encoding", ICONV_INTERNAL_ENCODING, PHP_INI_ALL, OnUpdateString, internal_encoding, zend_iconv_globals, iconv_globals) PHP_INI_END() -static void +static void php_iconv_init_globals(zend_iconv_globals *iconv_globals) { iconv_globals->input_encoding = NULL; @@ -88,20 +89,20 @@ php_iconv_init_globals(zend_iconv_globals *iconv_globals) iconv_globals->internal_encoding = NULL; } -PHP_MINIT_FUNCTION(iconv) +PHP_MINIT_FUNCTION(miconv) { ZEND_INIT_MODULE_GLOBALS(iconv, php_iconv_init_globals, NULL); REGISTER_INI_ENTRIES(); return SUCCESS; } -PHP_MSHUTDOWN_FUNCTION(iconv) +PHP_MSHUTDOWN_FUNCTION(miconv) { UNREGISTER_INI_ENTRIES(); return SUCCESS; } -PHP_MINFO_FUNCTION(iconv) +PHP_MINFO_FUNCTION(miconv) { php_info_print_table_start(); php_info_print_table_header(2, "iconv support", "enabled"); @@ -153,11 +154,8 @@ int php_iconv_string(char *in_p, char **out, char *in_charset, char *out_charset PHP_FUNCTION(iconv) { zval **in_charset, **out_charset, **in_buffer; - unsigned int in_size, out_size; - char *out_buffer, *in_p, *out_p; - size_t result; - typedef unsigned int ucs4_t; - + char *out_buffer; + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &in_charset, &out_charset, &in_buffer) == FAILURE) { WRONG_PARAM_COUNT; } @@ -166,8 +164,7 @@ PHP_FUNCTION(iconv) convert_to_string_ex(out_charset); convert_to_string_ex(in_buffer); - if (php_iconv_string(Z_STRVAL_PP(in_buffer), &out_buffer, - Z_STRVAL_PP(in_charset), Z_STRVAL_PP(out_charset)) == SUCCESS) { + if (php_iconv_string(Z_STRVAL_PP(in_buffer), &out_buffer, Z_STRVAL_PP(in_charset), Z_STRVAL_PP(out_charset)) == SUCCESS) { RETVAL_STRING(out_buffer, 0); } else { RETURN_FALSE; @@ -179,7 +176,6 @@ PHP_FUNCTION(iconv) Returns str in output buffer converted to the iconv.output_encoding character set */ PHP_FUNCTION(ob_iconv_handler) { - int coding; char *out_buffer; zval **zv_string, **zv_status; SLS_FETCH(); diff --git a/ext/iconv/php_iconv.h b/ext/iconv/php_iconv.h index 0f9e36204d..2178fa2e4e 100644 --- a/ext/iconv/php_iconv.h +++ b/ext/iconv/php_iconv.h @@ -20,24 +20,18 @@ #ifndef PHP_ICONV_H #define PHP_ICONV_H -#include -#include "php.h" -#include "SAPI.h" - -extern zend_module_entry iconv_module_entry; -#define phpext_iconv_ptr &iconv_module_entry - #ifdef PHP_WIN32 #define PHP_ICONV_API __declspec(dllexport) #else #define PHP_ICONV_API #endif -PHP_MINIT_FUNCTION(iconv); -PHP_MSHUTDOWN_FUNCTION(iconv); -PHP_RINIT_FUNCTION(iconv); -PHP_RSHUTDOWN_FUNCTION(iconv); -PHP_MINFO_FUNCTION(iconv); +extern zend_module_entry iconv_module_entry; +#define phpext_iconv_ptr &iconv_module_entry + +PHP_MINIT_FUNCTION(miconv); +PHP_MSHUTDOWN_FUNCTION(miconv); +PHP_MINFO_FUNCTION(miconv); PHP_FUNCTION(iconv); PHP_FUNCTION(ob_iconv_handler);