cvs: php4 /ext/standard basic_functions.c basic_functions.h config.m4 php_string.h string.c

From: Date: Tue, 09 Jan 2001 15:11:23 +0000
Subject: cvs: php4 /ext/standard basic_functions.c basic_functions.h config.m4 php_string.h string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-3511@lists.php.net to get a copy of this message
hirokawa Tue Jan 9 07:11:23 2001 EDT Modified files: /php4/ext/standard basic_functions.c basic_functions.h config.m4 php_string.h string.c Log: added iconv extension.

Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.294 php4/ext/standard/basic_functions.c:1.295 --- php4/ext/standard/basic_functions.c:1.294 Tue Jan 9 01:02:21 2001 +++ php4/ext/standard/basic_functions.c Tue Jan 9 07:11:23 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.294 2001/01/09 09:02:21 sniper Exp $ */ +/* $Id: basic_functions.c,v 1.295 2001/01/09 15:11:23 hirokawa Exp $ */ #include "php.h" #include "php_main.h" @@ -194,11 +194,6 @@ PHP_NAMED_FE(printf, PHP_FN(user_printf), NULL) PHP_FE(sscanf, third_and_rest_force_ref) PHP_FE(fscanf, third_and_rest_force_ref) -#ifdef HAVE_ICONV - PHP_FE(iconv, NULL) - PHP_FE(ob_iconv_handler, NULL) - PHP_FE(iconv_set_encoding, NULL) -#endif PHP_FE(parse_url, NULL) PHP_FE(urlencode, NULL) PHP_FE(urldecode, NULL) @@ -602,38 +597,9 @@ return SUCCESS; } -#ifdef HAVE_ICONV -static PHP_INI_MH(OnUpdateIconvOutputEncoding) -{ - BLS_FETCH(); - - if (BG(iconv_output_encoding)) { - free(BG(iconv_output_encoding)); - } - BG(iconv_output_encoding) = zend_strndup(new_value, new_value_length); - return SUCCESS; -} - -static PHP_INI_MH(OnUpdateIconvInternalEncoding) -{ - BLS_FETCH(); - - if (BG(iconv_internal_encoding)) { - free(BG(iconv_internal_encoding)); - } - BG(iconv_internal_encoding) = zend_strndup(new_value, new_value_length); - return SUCCESS; -} - -#endif - PHP_INI_BEGIN() PHP_INI_ENTRY_EX("safe_mode_protected_env_vars", SAFE_MODE_PROTECTED_ENV_VARS, PHP_INI_SYSTEM, OnUpdateSafeModeProtectedEnvVars, NULL) PHP_INI_ENTRY_EX("safe_mode_allowed_env_vars", SAFE_MODE_ALLOWED_ENV_VARS, PHP_INI_SYSTEM, OnUpdateSafeModeAllowedEnvVars, NULL) -#ifdef HAVE_ICONV - PHP_INI_ENTRY_EX("iconv.output_encoding", ICONV_OUTPUT_ENCODING, PHP_INI_SYSTEM, OnUpdateIconvOutputEncoding, NULL) - PHP_INI_ENTRY_EX("iconv.internal_encoding", ICONV_INTERNAL_ENCODING, PHP_INI_SYSTEM, OnUpdateIconvInternalEncoding, NULL) -#endif STD_PHP_INI_ENTRY("session.use_trans_sid", "1", PHP_INI_ALL, OnUpdateBool, use_trans_sid, php_basic_globals, basic_globals) PHP_INI_END() Index: php4/ext/standard/basic_functions.h diff -u php4/ext/standard/basic_functions.h:1.72 php4/ext/standard/basic_functions.h:1.73 --- php4/ext/standard/basic_functions.h:1.72 Sun Jan 7 17:40:33 2001 +++ php4/ext/standard/basic_functions.h Tue Jan 9 07:11:23 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.h,v 1.72 2001/01/08 01:40:33 hirokawa Exp $ */ +/* $Id: basic_functions.h,v 1.73 2001/01/09 15:11:23 hirokawa Exp $ */ #ifndef BASIC_FUNCTIONS_H #define BASIC_FUNCTIONS_H @@ -157,11 +157,6 @@ HashTable sm_protected_env_vars; char *sm_allowed_env_vars; - -#ifdef HAVE_ICONV - char *iconv_internal_encoding; - char *iconv_output_encoding; -#endif /* pageinfo.c */ long page_uid; @@ -226,8 +221,5 @@ */ #define SAFE_MODE_PROTECTED_ENV_VARS "LD_LIBRARY_PATH" #define SAFE_MODE_ALLOWED_ENV_VARS "PHP_" - -#define ICONV_OUTPUT_ENCODING "ISO-8859-1" -#define ICONV_INTERNAL_ENCODING "ISO-8859-1" #endif /* BASIC_FUNCTIONS_H */ Index: php4/ext/standard/config.m4 diff -u php4/ext/standard/config.m4:1.25 php4/ext/standard/config.m4:1.26 --- php4/ext/standard/config.m4:1.25 Thu Dec 14 17:01:13 2000 +++ php4/ext/standard/config.m4 Tue Jan 9 07:11:23 2001 @@ -1,4 +1,4 @@ -dnl $Id: config.m4,v 1.25 2000/12/15 01:01:13 ssb Exp $ -*- sh -*- +dnl $Id: config.m4,v 1.26 2001/01/09 15:11:23 hirokawa Exp $ -*- sh -*- divert(3)dnl @@ -160,15 +160,6 @@ else REGEX_TYPE=php fi -]) - -AC_CHECK_LIB(c, iconv_open, [ - AC_DEFINE(HAVE_ICONV, 1, [ ]) -], [ - AC_CHECK_LIB(iconv, iconv_open, [ - EXTRA_LIBS="$EXTRA_LIBS -liconv" - AC_DEFINE(HAVE_ICONV, 1, [ ]) - ]) ]) PHP_EXTENSION(standard) Index: php4/ext/standard/php_string.h diff -u php4/ext/standard/php_string.h:1.30 php4/ext/standard/php_string.h:1.31 --- php4/ext/standard/php_string.h:1.30 Sun Jan 7 18:39:52 2001 +++ php4/ext/standard/php_string.h Tue Jan 9 07:11:23 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_string.h,v 1.30 2001/01/08 02:39:52 hirokawa Exp $ */ +/* $Id: php_string.h,v 1.31 2001/01/09 15:11:23 hirokawa Exp $ */ /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */ @@ -78,9 +78,6 @@ PHP_FUNCTION(substr_count); PHP_FUNCTION(str_pad); PHP_FUNCTION(sscanf); -PHP_FUNCTION(iconv); -PHP_FUNCTION(ob_iconv_handler); -PHP_FUNCTION(iconv_set_encoding); #define strnatcmp(a, b) \ strnatcmp_ex(a, strlen(a), b, strlen(b), 0) Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.181 php4/ext/standard/string.c:1.182 --- php4/ext/standard/string.c:1.181 Mon Jan 8 15:18:07 2001 +++ php4/ext/standard/string.c Tue Jan 9 07:11:23 2001 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.181 2001/01/08 23:18:07 sas Exp $ */ +/* $Id: string.c,v 1.182 2001/01/09 15:11:23 hirokawa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -30,10 +30,6 @@ #ifdef HAVE_LOCALE_H # include <locale.h> #endif -#ifdef HAVE_ICONV -# include <iconv.h> -# include "SAPI.h" -#endif #include "scanf.h" #include "zend_API.h" #include "zend_execute.h" @@ -72,7 +68,6 @@ } int php_tag_find(char *tag, int len, char *set); -int php_iconv_string(char *, char **, char *, char *); /* this is read-only, so it's ok */ static char hexconvtab[] = "0123456789abcdef"; @@ -3003,128 +2998,6 @@ } /* }}} */ - -#ifdef HAVE_ICONV - -int php_iconv_string(char *in_p, char **out, char *in_charset, char *out_charset) { - unsigned int in_size, out_size; - char *out_buffer, *out_p; - iconv_t cd; - size_t result; - typedef unsigned int ucs4_t; - - in_size = strlen(in_p) * sizeof(char) + 1; - out_size = strlen(in_p) * sizeof(ucs4_t) + 1; - - out_buffer = (char *) emalloc(out_size); - *out = out_buffer; - out_p = out_buffer; - - cd = iconv_open(out_charset, in_charset); - - if (cd == (iconv_t)(-1)) { - php_error(E_WARNING, "iconv: cannot convert from `%s' to `%s'", - in_charset, out_charset); - efree(out_buffer); - return -1; - } - - result = iconv(cd, (const char **) &in_p, &in_size, (char **) - &out_p, &out_size); - - if (result == (size_t)(-1)) { - sprintf(out_buffer, "???") ; - return -1; - } - - iconv_close(cd); - - return SUCCESS; -} - -/* {{{ proto string iconv(string in_charset, string out_charset, string str) - Returns str converted to the out_charset character set. -*/ -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; - - if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &in_charset, &out_charset, &in_buffer) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(in_charset); - 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) { - RETVAL_STRING(out_buffer, 0); - } else { - RETURN_FALSE; - } -} - -/* {{{ proto string ob_iconv_handler(string contents) - 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; - BLS_FETCH(); - - if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &zv_string)==FAILURE) { - ZEND_WRONG_PARAM_COUNT(); - } - - if (php_iconv_string(Z_STRVAL_PP(zv_string), &out_buffer, - BG(iconv_internal_encoding), - BG(iconv_output_encoding))==SUCCESS) { - RETVAL_STRING(out_buffer, 0); - } else { - zval_dtor(return_value); - *return_value = **zv_string; - zval_copy_ctor(return_value); - } - -} - -/* {{{ proto bool iconv_set_encoding(string int_charset, string out_charset) - set internal encoding and output encoding for ob_iconv_handler(). -*/ -PHP_FUNCTION(iconv_set_encoding) -{ - zval **int_charset, **out_charset; - BLS_FETCH(); - - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &int_charset, &out_charset) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(int_charset); - convert_to_string_ex(out_charset); - - if (BG(iconv_internal_encoding)) { - free(BG(iconv_internal_encoding)); - } - BG(iconv_internal_encoding) = estrndup(Z_STRVAL_PP(int_charset), Z_STRLEN_PP(int_charset)); - - if (BG(iconv_output_encoding)) { - free(BG(iconv_output_encoding)); - } - BG(iconv_output_encoding) = estrndup(Z_STRVAL_PP(out_charset),Z_STRLEN_PP(out_charset)); - - RETURN_TRUE; -} - -#endif /* * Local variables:
« previous php.cvs (#3511) next »