d72fcb09715fd7bbcbbcb3e8c5ca71fe52637b03
[reactos.git] / reactos / lib / crtdll / locale / locale.c
1 #include <crtdll/stdio.h>
2 #include <crtdll/locale.h>
3 #include <crtdll/string.h>
4 #include <limits.h>
5
6
7 int _current_category; /* used by setlocale */
8 const char *_current_locale;
9 int __mb_cur_max_dll = 1;
10
11 int parse_locale(char *locale, char *lang, char *country, char *code_page);
12
13 char *setlocale(int category, const char *locale)
14 {
15 char lang[100];
16 char country[100];
17 char code_page[100];
18 parse_locale((char *)locale,lang,country,code_page);
19
20 //printf("%s %s %s %s\n",locale,lang,country,code_page);
21
22
23 switch ( category )
24 {
25 case LC_COLLATE:
26 break;
27 case LC_CTYPE:
28 break;
29 case LC_MONETARY:
30 break;
31 case LC_NUMERIC:
32 break;
33 case LC_TIME:
34 break;
35 case LC_ALL:
36 break;
37 default:
38 break;
39 }
40
41 return "C";
42
43 }
44
45 /*
46
47 locale "lang[_country[.code_page]]"
48 | ".code_page"
49 | ""
50 | NULL
51
52 */
53 int parse_locale(char *locale, char *lang, char *country, char *code_page)
54 {
55 while ( *locale != 0 && *locale != '.' && *locale != '_' )
56 {
57 *lang = *locale;
58 lang++;
59 locale++;
60 }
61 *lang = 0;
62 if ( *locale == '_' ) {
63 locale++;
64 while ( *locale != 0 && *locale != '.' )
65 {
66 *country = *locale;
67 country++;
68 locale++;
69 }
70 }
71 *country = 0;
72
73
74 if ( *locale == '.' ) {
75 locale++;
76 while ( *locale != 0 && *locale != '.' )
77 {
78 *code_page = *locale;
79 code_page++;
80 locale++;
81 }
82 }
83
84 *code_page = 0;
85 return 0;
86 }
87
88 const struct map_lcid2str {
89 short langid;
90 const char *langname;
91 const char *country;
92 } languages[]={
93 {0x0409,"English", "United States"},
94 {0x0809,"English", "United Kingdom"},
95 {0x0000,"Unknown", "Unknown"}
96
97 };
98
99 const struct map_cntr {
100 const char *abrev;
101 const char *country;
102 } abrev[] = {
103 {"britain", "united kingdom"},
104 {"england", "united kingdom"},
105 {"gbr", "united kingdom"},
106 {"great britain", "united kingdom"},
107 {"uk", "united kingdom"},
108 {"united kingdom", "united kingdom"},
109 {"united-kingdom", "united kingdom"},
110 {"america", "united states" },
111 {"united states", "united states"},
112 {"united-states", "united states"},
113 {"us", "united states"},
114 {"usa" "united states"}
115 };
116
117
118 struct lconv _lconv = {
119 ".", // decimal_point
120 ",", // thousands_sep
121 "", // grouping;
122 "DOL", // int_curr_symbol
123 "$", // currency_symbol
124 ".", // mon_decimal_point
125 ",", // mon_thousands_sep
126 "", // mon_grouping;
127 "+", // positive_sign
128 "-", // negative_sign
129 127, // int_frac_digits
130 127, // frac_digits
131 127, // p_cs_precedes
132 127, // p_sep_by_space
133 127, // n_cs_precedes
134 127, // n_sep_by_space
135 127, // p_sign_posn;
136 127 // n_sign_posn;
137 };
138
139 struct lconv *localeconv(void)
140 {
141 return (struct lconv *) &_lconv;
142 }
143