sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: Contains the source for all the system calls in libc sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "localeinfo.h" sl@0: #include "lmonetary.h" sl@0: sl@0: #if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__))) sl@0: #include "libc_wsd_defs.h" sl@0: #endif sl@0: sl@0: // Muzibour : Include #include and then use the macro __BEGIN_DECLS sl@0: __BEGIN_DECLS sl@0: extern int __mlocale_changed; sl@0: #ifdef EMULATOR sl@0: int *GET_WSD_VAR_NAME(__mlocale_changed, g)(); sl@0: #define __mlocale_changed (*GET_WSD_VAR_NAME(__mlocale_changed, g)()) sl@0: #endif //EMULATOR sl@0: __END_DECLS sl@0: #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT sl@0: __BEGIN_DECLS sl@0: extern unsigned char __clocale_set; sl@0: #ifdef EMULATOR sl@0: unsigned char *GET_WSD_VAR_NAME(__clocale_set, g)(); sl@0: #define __clocale_set (*GET_WSD_VAR_NAME(__clocale_set, g)()) sl@0: #endif //EMULATOR sl@0: __END_DECLS sl@0: #endif sl@0: #ifndef EMULATOR sl@0: int _monetary_using_locale; sl@0: #else //EMULATOR sl@0: sl@0: GET_GLOBAL_VAR_FROM_TLS(_monetary_using_locale, int) sl@0: #define _monetary_using_locale (*GET_WSD_VAR_NAME(_monetary_using_locale, g)()) sl@0: #endif //EMULATOR sl@0: sl@0: #ifndef EMULATOR sl@0: static char empty[] = ""; sl@0: static char numempty[] = { CHAR_MAX, '\0'}; sl@0: #else //EMULATOR sl@0: static const char empty[] = ""; sl@0: static const char numempty[] = { CHAR_MAX, '\0'}; sl@0: sl@0: #endif //EMULATOR sl@0: sl@0: static const struct lc_monetary_T _C_monetary_locale = { sl@0: empty, /* int_curr_symbol */ sl@0: empty, /* currency_symbol */ sl@0: empty, /* mon_decimal_point */ sl@0: empty, /* mon_thousands_sep */ sl@0: numempty, /* mon_grouping */ sl@0: empty, /* positive_sign */ sl@0: empty, /* negative_sign */ sl@0: numempty, /* int_frac_digits */ sl@0: numempty, /* frac_digits */ sl@0: numempty, /* p_cs_precedes */ sl@0: numempty, /* p_sep_by_space */ sl@0: numempty, /* n_cs_precedes */ sl@0: numempty, /* n_sep_by_space */ sl@0: numempty, /* p_sign_posn */ sl@0: numempty, /* n_sign_posn */ sl@0: numempty, /* int_p_cs_precedes */ sl@0: numempty, /* int_n_cs_precedes */ sl@0: numempty, /* int_p_sep_by_space */ sl@0: numempty, /* int_n_sep_by_space */ sl@0: numempty, /* int_p_sign_posn */ sl@0: numempty /* int_n_sign_posn */ sl@0: }; sl@0: sl@0: sl@0: sl@0: int sl@0: __monetary_load_locale(const char* localeName) sl@0: { sl@0: //Get an instance of locale object sl@0: CLocale* locale = CLocale::GetInstance(); sl@0: //Load the monetary(LC_MONETARY category) information sl@0: TInt ret = KErrNone; sl@0: TRAPD(result,ret = locale->MonetaryLoadLocaleL(localeName)); sl@0: if ((result != KErrNone) || (ret == -1)) sl@0: { sl@0: return -1; sl@0: } sl@0: __mlocale_changed = 1; sl@0: _monetary_using_locale = 1; sl@0: sl@0: return 0; sl@0: } sl@0: sl@0: struct lc_monetary_T * sl@0: __get_current_monetary_locale(void) sl@0: { sl@0: //Retreive the monetary(LC_MONETARY category) information sl@0: if(_monetary_using_locale) sl@0: { sl@0: return (CLocale::GetCurrentMonetaryLocale()); sl@0: } sl@0: #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT sl@0: else if(__clocale_set) sl@0: #endif sl@0: //return POSIX C locale monetary(LC_MONETARY category) information sl@0: return ((struct lc_monetary_T *)&_C_monetary_locale); sl@0: #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT sl@0: else sl@0: { sl@0: CLocale *l=CLocale::GetInstance(); sl@0: TRAPD(result,l->MonetaryLoadLocaleL(NULL)); sl@0: if (result != KErrNone) sl@0: { sl@0: return NULL; sl@0: } sl@0: return (CLocale::GetCurrentMonetaryLocale()); sl@0: } sl@0: #endif sl@0: } sl@0: sl@0: #ifdef LOCALE_DEBUG sl@0: void sl@0: monetdebug() { sl@0: printf( "int_curr_symbol = %s\n" sl@0: "currency_symbol = %s\n" sl@0: "mon_decimal_point = %s\n" sl@0: "mon_thousands_sep = %s\n" sl@0: "mon_grouping = %s\n" sl@0: "positive_sign = %s\n" sl@0: "negative_sign = %s\n" sl@0: "int_frac_digits = %d\n" sl@0: "frac_digits = %d\n" sl@0: "p_cs_precedes = %d\n" sl@0: "p_sep_by_space = %d\n" sl@0: "n_cs_precedes = %d\n" sl@0: "n_sep_by_space = %d\n" sl@0: "p_sign_posn = %d\n" sl@0: "n_sign_posn = %d\n", sl@0: "int_p_cs_precedes = %d\n" sl@0: "int_p_sep_by_space = %d\n" sl@0: "int_n_cs_precedes = %d\n" sl@0: "int_n_sep_by_space = %d\n" sl@0: "int_p_sign_posn = %d\n" sl@0: "int_n_sign_posn = %d\n", sl@0: _monetary_locale.int_curr_symbol, sl@0: _monetary_locale.currency_symbol, sl@0: _monetary_locale.mon_decimal_point, sl@0: _monetary_locale.mon_thousands_sep, sl@0: _monetary_locale.mon_grouping, sl@0: _monetary_locale.positive_sign, sl@0: _monetary_locale.negative_sign, sl@0: _monetary_locale.int_frac_digits[0], sl@0: _monetary_locale.frac_digits[0], sl@0: _monetary_locale.p_cs_precedes[0], sl@0: _monetary_locale.p_sep_by_space[0], sl@0: _monetary_locale.n_cs_precedes[0], sl@0: _monetary_locale.n_sep_by_space[0], sl@0: _monetary_locale.p_sign_posn[0], sl@0: _monetary_locale.n_sign_posn[0], sl@0: _monetary_locale.int_p_cs_precedes[0], sl@0: _monetary_locale.int_p_sep_by_space[0], sl@0: _monetary_locale.int_n_cs_precedes[0], sl@0: _monetary_locale.int_n_sep_by_space[0], sl@0: _monetary_locale.int_p_sign_posn[0], sl@0: _monetary_locale.int_n_sign_posn[0] sl@0: ); sl@0: } sl@0: #endif /* LOCALE_DEBUG */