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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
|
/*
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Vadim Savchuk <vsavchuk@productengine.com> |
| Dmitry Lakhtyuk <dlakhtyuk@productengine.com> |
| Stanislav Malyshev <stas@zend.com> |
| Kirti Velankar <kirtig@yahoo-inc.com> |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "php_intl.h"
#include "intl_error.h"
#include "collator/collator_class.h"
#include "collator/collator.h"
#include "collator/collator_sort.h"
#include "collator/collator_convert.h"
#include "converter/converter.h"
#include "formatter/formatter_class.h"
#include "formatter/formatter_format.h"
#include "grapheme/grapheme.h"
#include "msgformat/msgformat_class.h"
#include "normalizer/normalizer_class.h"
#include "locale/locale.h"
#include "locale/locale_class.h"
#include "dateformat/dateformat.h"
#include "dateformat/dateformat_class.h"
#include "dateformat/dateformat_data.h"
#include "dateformat/datepatterngenerator_class.h"
#include "resourcebundle/resourcebundle_class.h"
#include "transliterator/transliterator.h"
#include "transliterator/transliterator_class.h"
#include "timezone/timezone_class.h"
#include "calendar/calendar_class.h"
#include "breakiterator/breakiterator_class.h"
#include "breakiterator/breakiterator_iterators.h"
#include <unicode/uidna.h>
#include "idn/idn.h"
#include "uchar/uchar.h"
# include "spoofchecker/spoofchecker_class.h"
#include "common/common_enum.h"
#include <unicode/uloc.h>
#include <unicode/uclean.h>
#include <ext/standard/info.h>
#include "php_ini.h"
#include "zend_attributes.h"
#include "php_intl_arginfo.h"
/*
* locale_get_default has a conflict since ICU also has
* a function with the same name
* in fact ICU appends the version no. to it also
* Hence the following undef for ICU version
* Same true for the locale_set_default function
*/
#undef locale_get_default
#undef locale_set_default
ZEND_DECLARE_MODULE_GLOBALS( intl )
const char *intl_locale_get_default( void )
{
if( INTL_G(default_locale) == NULL ) {
return uloc_getDefault();
}
return INTL_G(default_locale);
}
/* {{{ INI Settings */
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY(LOCALE_INI_NAME, NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_locale, zend_intl_globals, intl_globals)
STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateLong, error_level, zend_intl_globals, intl_globals)
STD_PHP_INI_BOOLEAN("intl.use_exceptions", "0", PHP_INI_ALL, OnUpdateBool, use_exceptions, zend_intl_globals, intl_globals)
PHP_INI_END()
/* }}} */
static PHP_GINIT_FUNCTION(intl);
/* {{{ intl_module_entry */
zend_module_entry intl_module_entry = {
STANDARD_MODULE_HEADER,
"intl",
ext_functions,
PHP_MINIT( intl ),
PHP_MSHUTDOWN( intl ),
PHP_RINIT( intl ),
PHP_RSHUTDOWN( intl ),
PHP_MINFO( intl ),
PHP_INTL_VERSION,
PHP_MODULE_GLOBALS(intl), /* globals descriptor */
PHP_GINIT(intl), /* globals ctor */
NULL, /* globals dtor */
NULL, /* post deactivate */
STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
#ifdef COMPILE_DL_INTL
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE( intl )
#endif
/* {{{ intl_init_globals */
static PHP_GINIT_FUNCTION(intl)
{
#if defined(COMPILE_DL_INTL) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
memset( intl_globals, 0, sizeof(zend_intl_globals) );
}
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION( intl )
{
/* For the default locale php.ini setting */
REGISTER_INI_ENTRIES();
register_php_intl_symbols(module_number);
/* Register collator symbols and classes */
collator_register_Collator_symbols(module_number);
/* Register 'NumberFormatter' PHP class */
formatter_register_class( );
/* Register 'Normalizer' PHP class */
normalizer_register_Normalizer_class( );
/* Register 'Locale' PHP class */
locale_register_Locale_class( );
msgformat_register_class();
/* Register 'DateFormat' PHP class */
dateformat_register_IntlDateFormatter_class( );
/* Register 'IntlDateTimeFormatter' PHP class */
dateformat_register_IntlDatePatternGenerator_class( );
/* Register 'ResourceBundle' PHP class */
resourcebundle_register_class( );
/* Register 'Transliterator' PHP class */
transliterator_register_Transliterator_class( );
/* Register 'IntlTimeZone' PHP class */
timezone_register_IntlTimeZone_class( );
/* Register 'IntlCalendar' PHP class */
calendar_register_IntlCalendar_class( );
/* Register 'Spoofchecker' PHP class */
spoofchecker_register_Spoofchecker_class( );
/* Register 'IntlException' PHP class */
IntlException_ce_ptr = register_class_IntlException(zend_ce_exception);
IntlException_ce_ptr->create_object = zend_ce_exception->create_object;
/* Register common symbols and classes */
intl_register_common_symbols(module_number);
/* Register 'BreakIterator' class */
breakiterator_register_BreakIterator_class( );
/* Register 'IntlPartsIterator' class */
breakiterator_register_IntlPartsIterator_class();
/* Global error handling. */
intl_error_init( NULL );
/* 'Converter' class for codepage conversions */
php_converter_minit(INIT_FUNC_ARGS_PASSTHRU);
/* IntlChar class */
php_uchar_minit(INIT_FUNC_ARGS_PASSTHRU);
return SUCCESS;
}
/* }}} */
#define EXPLICIT_CLEANUP_ENV_VAR "INTL_EXPLICIT_CLEANUP"
/* {{{ PHP_MSHUTDOWN_FUNCTION */
PHP_MSHUTDOWN_FUNCTION( intl )
{
const char *cleanup;
/* For the default locale php.ini setting */
UNREGISTER_INI_ENTRIES();
cleanup = getenv(EXPLICIT_CLEANUP_ENV_VAR);
if (cleanup != NULL && !(cleanup[0] == '0' && cleanup[1] == '\0')) {
u_cleanup();
}
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RINIT_FUNCTION */
PHP_RINIT_FUNCTION( intl )
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RSHUTDOWN_FUNCTION */
PHP_RSHUTDOWN_FUNCTION( intl )
{
INTL_G(current_collator) = NULL;
if (INTL_G(grapheme_iterator)) {
grapheme_close_global_iterator( );
INTL_G(grapheme_iterator) = NULL;
}
intl_error_reset( NULL);
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION( intl )
{
#if !UCONFIG_NO_FORMATTING
UErrorCode status = U_ZERO_ERROR;
const char *tzdata_ver = NULL;
#endif
php_info_print_table_start();
php_info_print_table_row( 2, "Internationalization support", "enabled" );
php_info_print_table_row( 2, "ICU version", U_ICU_VERSION );
#ifdef U_ICU_DATA_VERSION
php_info_print_table_row( 2, "ICU Data version", U_ICU_DATA_VERSION );
#endif
#if !UCONFIG_NO_FORMATTING
tzdata_ver = ucal_getTZDataVersion(&status);
if (U_ZERO_ERROR == status) {
php_info_print_table_row( 2, "ICU TZData version", tzdata_ver);
}
#endif
php_info_print_table_row( 2, "ICU Unicode version", U_UNICODE_VERSION );
php_info_print_table_end();
/* For the default locale php.ini setting */
DISPLAY_INI_ENTRIES() ;
}
/* }}} */
|