sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description: Contains the source for all the system calls in libc
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <limits.h>
|
sl@0
|
21 |
#include <stdlib.h>
|
sl@0
|
22 |
#include <sys/cdefs.h>
|
sl@0
|
23 |
#include "localeinfo.h"
|
sl@0
|
24 |
#include "lmonetary.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
#if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__)))
|
sl@0
|
27 |
#include "libc_wsd_defs.h"
|
sl@0
|
28 |
#endif
|
sl@0
|
29 |
|
sl@0
|
30 |
// Muzibour : Include #include <sys/cdefs.h> and then use the macro __BEGIN_DECLS
|
sl@0
|
31 |
__BEGIN_DECLS
|
sl@0
|
32 |
extern int __mlocale_changed;
|
sl@0
|
33 |
#ifdef EMULATOR
|
sl@0
|
34 |
int *GET_WSD_VAR_NAME(__mlocale_changed, g)();
|
sl@0
|
35 |
#define __mlocale_changed (*GET_WSD_VAR_NAME(__mlocale_changed, g)())
|
sl@0
|
36 |
#endif //EMULATOR
|
sl@0
|
37 |
__END_DECLS
|
sl@0
|
38 |
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
|
sl@0
|
39 |
__BEGIN_DECLS
|
sl@0
|
40 |
extern unsigned char __clocale_set;
|
sl@0
|
41 |
#ifdef EMULATOR
|
sl@0
|
42 |
unsigned char *GET_WSD_VAR_NAME(__clocale_set, g)();
|
sl@0
|
43 |
#define __clocale_set (*GET_WSD_VAR_NAME(__clocale_set, g)())
|
sl@0
|
44 |
#endif //EMULATOR
|
sl@0
|
45 |
__END_DECLS
|
sl@0
|
46 |
#endif
|
sl@0
|
47 |
#ifndef EMULATOR
|
sl@0
|
48 |
int _monetary_using_locale;
|
sl@0
|
49 |
#else //EMULATOR
|
sl@0
|
50 |
|
sl@0
|
51 |
GET_GLOBAL_VAR_FROM_TLS(_monetary_using_locale, int)
|
sl@0
|
52 |
#define _monetary_using_locale (*GET_WSD_VAR_NAME(_monetary_using_locale, g)())
|
sl@0
|
53 |
#endif //EMULATOR
|
sl@0
|
54 |
|
sl@0
|
55 |
#ifndef EMULATOR
|
sl@0
|
56 |
static char empty[] = "";
|
sl@0
|
57 |
static char numempty[] = { CHAR_MAX, '\0'};
|
sl@0
|
58 |
#else //EMULATOR
|
sl@0
|
59 |
static const char empty[] = "";
|
sl@0
|
60 |
static const char numempty[] = { CHAR_MAX, '\0'};
|
sl@0
|
61 |
|
sl@0
|
62 |
#endif //EMULATOR
|
sl@0
|
63 |
|
sl@0
|
64 |
static const struct lc_monetary_T _C_monetary_locale = {
|
sl@0
|
65 |
empty, /* int_curr_symbol */
|
sl@0
|
66 |
empty, /* currency_symbol */
|
sl@0
|
67 |
empty, /* mon_decimal_point */
|
sl@0
|
68 |
empty, /* mon_thousands_sep */
|
sl@0
|
69 |
numempty, /* mon_grouping */
|
sl@0
|
70 |
empty, /* positive_sign */
|
sl@0
|
71 |
empty, /* negative_sign */
|
sl@0
|
72 |
numempty, /* int_frac_digits */
|
sl@0
|
73 |
numempty, /* frac_digits */
|
sl@0
|
74 |
numempty, /* p_cs_precedes */
|
sl@0
|
75 |
numempty, /* p_sep_by_space */
|
sl@0
|
76 |
numempty, /* n_cs_precedes */
|
sl@0
|
77 |
numempty, /* n_sep_by_space */
|
sl@0
|
78 |
numempty, /* p_sign_posn */
|
sl@0
|
79 |
numempty, /* n_sign_posn */
|
sl@0
|
80 |
numempty, /* int_p_cs_precedes */
|
sl@0
|
81 |
numempty, /* int_n_cs_precedes */
|
sl@0
|
82 |
numempty, /* int_p_sep_by_space */
|
sl@0
|
83 |
numempty, /* int_n_sep_by_space */
|
sl@0
|
84 |
numempty, /* int_p_sign_posn */
|
sl@0
|
85 |
numempty /* int_n_sign_posn */
|
sl@0
|
86 |
};
|
sl@0
|
87 |
|
sl@0
|
88 |
|
sl@0
|
89 |
|
sl@0
|
90 |
int
|
sl@0
|
91 |
__monetary_load_locale(const char* localeName)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
//Get an instance of locale object
|
sl@0
|
94 |
CLocale* locale = CLocale::GetInstance();
|
sl@0
|
95 |
//Load the monetary(LC_MONETARY category) information
|
sl@0
|
96 |
TInt ret = KErrNone;
|
sl@0
|
97 |
TRAPD(result,ret = locale->MonetaryLoadLocaleL(localeName));
|
sl@0
|
98 |
if ((result != KErrNone) || (ret == -1))
|
sl@0
|
99 |
{
|
sl@0
|
100 |
return -1;
|
sl@0
|
101 |
}
|
sl@0
|
102 |
__mlocale_changed = 1;
|
sl@0
|
103 |
_monetary_using_locale = 1;
|
sl@0
|
104 |
|
sl@0
|
105 |
return 0;
|
sl@0
|
106 |
}
|
sl@0
|
107 |
|
sl@0
|
108 |
struct lc_monetary_T *
|
sl@0
|
109 |
__get_current_monetary_locale(void)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
//Retreive the monetary(LC_MONETARY category) information
|
sl@0
|
112 |
if(_monetary_using_locale)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
return (CLocale::GetCurrentMonetaryLocale());
|
sl@0
|
115 |
}
|
sl@0
|
116 |
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
|
sl@0
|
117 |
else if(__clocale_set)
|
sl@0
|
118 |
#endif
|
sl@0
|
119 |
//return POSIX C locale monetary(LC_MONETARY category) information
|
sl@0
|
120 |
return ((struct lc_monetary_T *)&_C_monetary_locale);
|
sl@0
|
121 |
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
|
sl@0
|
122 |
else
|
sl@0
|
123 |
{
|
sl@0
|
124 |
CLocale *l=CLocale::GetInstance();
|
sl@0
|
125 |
TRAPD(result,l->MonetaryLoadLocaleL(NULL));
|
sl@0
|
126 |
if (result != KErrNone)
|
sl@0
|
127 |
{
|
sl@0
|
128 |
return NULL;
|
sl@0
|
129 |
}
|
sl@0
|
130 |
return (CLocale::GetCurrentMonetaryLocale());
|
sl@0
|
131 |
}
|
sl@0
|
132 |
#endif
|
sl@0
|
133 |
}
|
sl@0
|
134 |
|
sl@0
|
135 |
#ifdef LOCALE_DEBUG
|
sl@0
|
136 |
void
|
sl@0
|
137 |
monetdebug() {
|
sl@0
|
138 |
printf( "int_curr_symbol = %s\n"
|
sl@0
|
139 |
"currency_symbol = %s\n"
|
sl@0
|
140 |
"mon_decimal_point = %s\n"
|
sl@0
|
141 |
"mon_thousands_sep = %s\n"
|
sl@0
|
142 |
"mon_grouping = %s\n"
|
sl@0
|
143 |
"positive_sign = %s\n"
|
sl@0
|
144 |
"negative_sign = %s\n"
|
sl@0
|
145 |
"int_frac_digits = %d\n"
|
sl@0
|
146 |
"frac_digits = %d\n"
|
sl@0
|
147 |
"p_cs_precedes = %d\n"
|
sl@0
|
148 |
"p_sep_by_space = %d\n"
|
sl@0
|
149 |
"n_cs_precedes = %d\n"
|
sl@0
|
150 |
"n_sep_by_space = %d\n"
|
sl@0
|
151 |
"p_sign_posn = %d\n"
|
sl@0
|
152 |
"n_sign_posn = %d\n",
|
sl@0
|
153 |
"int_p_cs_precedes = %d\n"
|
sl@0
|
154 |
"int_p_sep_by_space = %d\n"
|
sl@0
|
155 |
"int_n_cs_precedes = %d\n"
|
sl@0
|
156 |
"int_n_sep_by_space = %d\n"
|
sl@0
|
157 |
"int_p_sign_posn = %d\n"
|
sl@0
|
158 |
"int_n_sign_posn = %d\n",
|
sl@0
|
159 |
_monetary_locale.int_curr_symbol,
|
sl@0
|
160 |
_monetary_locale.currency_symbol,
|
sl@0
|
161 |
_monetary_locale.mon_decimal_point,
|
sl@0
|
162 |
_monetary_locale.mon_thousands_sep,
|
sl@0
|
163 |
_monetary_locale.mon_grouping,
|
sl@0
|
164 |
_monetary_locale.positive_sign,
|
sl@0
|
165 |
_monetary_locale.negative_sign,
|
sl@0
|
166 |
_monetary_locale.int_frac_digits[0],
|
sl@0
|
167 |
_monetary_locale.frac_digits[0],
|
sl@0
|
168 |
_monetary_locale.p_cs_precedes[0],
|
sl@0
|
169 |
_monetary_locale.p_sep_by_space[0],
|
sl@0
|
170 |
_monetary_locale.n_cs_precedes[0],
|
sl@0
|
171 |
_monetary_locale.n_sep_by_space[0],
|
sl@0
|
172 |
_monetary_locale.p_sign_posn[0],
|
sl@0
|
173 |
_monetary_locale.n_sign_posn[0],
|
sl@0
|
174 |
_monetary_locale.int_p_cs_precedes[0],
|
sl@0
|
175 |
_monetary_locale.int_p_sep_by_space[0],
|
sl@0
|
176 |
_monetary_locale.int_n_cs_precedes[0],
|
sl@0
|
177 |
_monetary_locale.int_n_sep_by_space[0],
|
sl@0
|
178 |
_monetary_locale.int_p_sign_posn[0],
|
sl@0
|
179 |
_monetary_locale.int_n_sign_posn[0]
|
sl@0
|
180 |
);
|
sl@0
|
181 |
}
|
sl@0
|
182 |
#endif /* LOCALE_DEBUG */
|