Do not assume that double byte font == unicode font.
[wine.git] / misc / main.c
blob1f0488b85b4701dba500d0ad9475306564de1f98
1 /*
2 * Main function.
4 * Copyright 1994 Alexandre Julliard
5 */
7 #include "config.h"
9 #include <locale.h>
10 #include <ctype.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <unistd.h>
14 #ifdef MALLOC_DEBUGGING
15 # include <malloc.h>
16 #endif
18 #include "winbase.h"
19 #include "winsock.h"
20 #include "heap.h"
21 #include "message.h"
22 #include "msdos.h"
23 #include "color.h"
24 #include "options.h"
25 #include "debugtools.h"
26 #include "debugdefs.h"
27 #include "module.h"
28 #include "version.h"
29 #include "winnls.h"
30 #include "console.h"
31 #include "monitor.h"
32 #include "keyboard.h"
33 #include "gdi.h"
34 #include "user.h"
35 #include "windef.h"
36 #include "wingdi.h"
37 #include "wine/winuser16.h"
38 #include "tweak.h"
39 #include "winerror.h"
41 /**********************************************************************/
43 USER_DRIVER *USER_Driver = NULL;
45 /* when adding new languages look at ole/ole2nls.c
46 * for proper iso name and Windows code (add 0x0400
47 * to the code listed there)
49 const WINE_LANGUAGE_DEF Languages[] =
51 {"En",0x0409}, /* LANG_En */
52 {"Es",0x040A}, /* LANG_Es */
53 {"De",0x0407}, /* LANG_De */
54 {"No",0x0414}, /* LANG_No */
55 {"Fr",0x040C}, /* LANG_Fr */
56 {"Fi",0x040B}, /* LANG_Fi */
57 {"Da",0x0406}, /* LANG_Da */
58 {"Cs",0x0405}, /* LANG_Cs */
59 {"Eo",0x048f}, /* LANG_Eo */
60 {"It",0x0410}, /* LANG_It */
61 {"Ko",0x0412}, /* LANG_Ko */
62 {"Hu",0x040e}, /* LANG_Hu */
63 {"Pl",0x0415}, /* LANG_Pl */
64 {"Pt",0x0416}, /* LANG_Pt */
65 {"Sk",0x041b}, /* LANG_Sk */
66 {"Sv",0x041d}, /* LANG_Sv */
67 {"Ca",0x0403}, /* LANG_Ca */
68 {"Nl",0x0413}, /* LANG_Nl */
69 {"Ru",0x0419}, /* LANG_Ru */
70 {"Wa",0x0490}, /* LANG_Wa */
71 {"Ga",0x043c}, /* LANG_Ga */
72 {"Gd",0x083c}, /* LANG_Gd */
73 {"Gv",0x0c3c}, /* LANG_Gv */
74 {"Kw",0x0491}, /* LANG_Kw */
75 {"Cy",0x0492}, /* LANG_Cy */
76 {"Br",0x0493}, /* LANG_Br */
77 {"Ja",0x0411}, /* LANG_Ja */
78 {"Hr",0x041A}, /* LANG_Hr */
79 {NULL,0}
82 WORD WINE_LanguageId = 0x409; /* english as default */
84 /***********************************************************************
85 * MAIN_ParseDebugOptions
87 * Turns specific debug messages on or off, according to "options".
89 void MAIN_ParseDebugOptions( const char *arg )
91 /* defined in relay32/relay386.c */
92 extern char **debug_relay_includelist;
93 extern char **debug_relay_excludelist;
94 /* defined in relay32/snoop.c */
95 extern char **debug_snoop_includelist;
96 extern char **debug_snoop_excludelist;
98 int i;
99 int l, cls;
101 char *options = strdup(arg);
103 l = strlen(options);
104 if (l<2) goto error;
106 if (options[l-1]=='\n') options[l-1]='\0';
109 if ((*options!='+')&&(*options!='-')){
110 int j;
112 for(j=0; j<DEBUG_CLASS_COUNT; j++)
113 if(!lstrncmpiA(options, debug_cl_name[j], strlen(debug_cl_name[j])))
114 break;
115 if(j==DEBUG_CLASS_COUNT)
116 goto error;
117 options += strlen(debug_cl_name[j]);
118 if ((*options!='+')&&(*options!='-'))
119 goto error;
120 cls = j;
122 else
123 cls = -1; /* all classes */
125 if (strchr(options,','))
126 l=strchr(options,',')-options;
127 else
128 l=strlen(options);
130 if (!lstrncmpiA(options+1,"all",l-1))
132 int i, j;
133 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
134 for(j=0; j<DEBUG_CLASS_COUNT; j++)
135 if(cls == -1 || cls == j)
136 __SET_DEBUGGING( j, debug_channels[i], (*options=='+') );
138 else if (!lstrncmpiA(options+1, "relay=", 6) ||
139 !lstrncmpiA(options+1, "snoop=", 6))
141 int i, j;
142 char *s, *s2, ***output, c;
144 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
145 if (!strncasecmp( debug_channels[i] + 1, options + 1, 5))
147 for(j=0; j<DEBUG_CLASS_COUNT; j++)
148 if(cls == -1 || cls == j)
149 __SET_DEBUGGING( j, debug_channels[i], 1 );
150 break;
152 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
153 if (i==DEBUG_CHANNEL_COUNT)
154 goto error;
155 output = (*options == '+') ?
156 ((*(options+1) == 'r') ?
157 &debug_relay_includelist :
158 &debug_snoop_includelist) :
159 ((*(options+1) == 'r') ?
160 &debug_relay_excludelist :
161 &debug_snoop_excludelist);
162 s = options + 7;
163 /* if there are n ':', there are n+1 modules, and we need n+2 slots
164 * last one being for the sentinel (NULL) */
165 i = 2;
166 while((s = strchr(s, ':'))) i++, s++;
167 *output = malloc(sizeof(char **) * i);
168 i = 0;
169 s = options + 7;
170 while((s2 = strchr(s, ':'))) {
171 c = *s2;
172 *s2 = '\0';
173 *((*output)+i) = CharUpperA(strdup(s));
174 *s2 = c;
175 s = s2 + 1;
176 i++;
178 c = *(options + l);
179 *(options + l) = '\0';
180 *((*output)+i) = CharUpperA(strdup(s));
181 *(options + l) = c;
182 *((*output)+i+1) = NULL;
184 else
186 int i, j;
187 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
188 if (!strncasecmp( debug_channels[i] + 1, options + 1, l - 1) && !debug_channels[i][l])
190 for(j=0; j<DEBUG_CLASS_COUNT; j++)
191 if(cls == -1 || cls == j)
192 __SET_DEBUGGING( j, debug_channels[i], (*options=='+') );
193 break;
195 if (i==DEBUG_CHANNEL_COUNT)
196 goto error;
198 options+=l;
200 while((*options==',')&&(*(++options)));
202 if (!*options) return;
204 error:
205 MESSAGE("%s: Syntax: -debugmsg [class]+xxx,... or "
206 "-debugmsg [class]-xxx,...\n",argv0);
207 MESSAGE("Example: -debugmsg +all,warn-heap\n"
208 " turn on all messages except warning heap messages\n");
209 MESSAGE("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
210 " turn on -debugmsg +relay only as specified\n"
211 "Special case: -debugmsg -relay=DLL:DLL.###:FuncName\n"
212 " turn on -debugmsg +relay except as specified\n"
213 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
215 MESSAGE("Available message classes:\n");
216 for(i=0;i<DEBUG_CLASS_COUNT;i++)
217 MESSAGE( "%-9s", debug_cl_name[i]);
218 MESSAGE("\n\n");
220 MESSAGE("Available message types:\n");
221 MESSAGE("%-9s ","all");
222 for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
223 MESSAGE("%-9s%c",debug_channels[i] + 1,
224 (((i+2)%8==0)?'\n':' '));
225 MESSAGE("\n\n");
226 ExitProcess(1);
229 /***********************************************************************
230 * MAIN_GetLanguageID
232 * INPUT:
233 * Lang: a string whose two first chars are the iso name of a language.
234 * Country: a string whose two first chars are the iso name of country
235 * Charset: a string defining the chossen charset encoding
236 * Dialect: a string defining a variation of the locale
238 * all those values are from the standardized format of locale
239 * name in unix which is: Lang[_Country][.Charset][@Dialect]
241 * RETURNS:
242 * the numeric code of the language used by Windows (or 0x00)
244 int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
246 char lang[3]="??", country[3]={0,0,0};
247 char *charset=NULL, *dialect=NULL;
248 int i,j,ret=0;
250 if (Lang==NULL) return 0x00;
251 if (Lang[0]) lang[0]=tolower(Lang[0]);
252 if (Lang[1]) lang[1]=tolower(Lang[1]);
254 if (Country!=NULL) {
255 if (Country[0]) country[0]=toupper(Country[0]);
256 if (Country[1]) country[1]=toupper(Country[1]);
259 if (Charset!=NULL) {
260 j=strlen(Charset);
261 charset=(char*)malloc(j+1);
262 for (i=0;i<j;i++)
263 charset[i]=toupper(Charset[i]);
264 charset[i]='\0';
267 if (Dialect!=NULL) {
268 j=strlen(Dialect);
269 dialect=(char*)malloc(j+1);
270 for (i=0;i<j;i++)
271 dialect[i]=tolower(Dialect[i]);
272 dialect[i]='\0';
273 } else {
274 dialect = malloc(1);
275 dialect[0] = '\0';
278 #define LANG_ENTRY_BEGIN(x,y) if(!strcmp(lang, x )) { \
279 if (!country[0]) { \
280 ret=LANG_##y ; \
281 goto end_MAIN_GetLanguageID; \
283 #define LANG_SUB_ENTRY(x,y,z) if (!strcmp(country, x )) { \
284 ret = MAKELANGID( LANG_##y , SUBLANG_##z ); \
285 goto end_MAIN_GetLanguageID; \
287 #define LANG_DIALECT_ENTRY(x,y) { ret = MAKELANGID(LANG_##x , SUBLANG_##y ); \
288 goto end_MAIN_GetLanguageID; }
289 #define LANG_ENTRY_END(x) ret = MAKELANGID(LANG_##x , SUBLANG_DEFAULT); \
290 goto end_MAIN_GetLanguageID; \
293 /*x01*/ LANG_ENTRY_BEGIN( "ar", ARABIC )
294 LANG_SUB_ENTRY( "SA", ARABIC, ARABIC)
295 LANG_SUB_ENTRY( "IQ", ARABIC, ARABIC_IRAQ )
296 LANG_SUB_ENTRY( "EG", ARABIC, ARABIC_EGYPT )
297 LANG_SUB_ENTRY( "LY", ARABIC, ARABIC_LIBYA )
298 LANG_SUB_ENTRY( "DZ", ARABIC, ARABIC_ALGERIA )
299 LANG_SUB_ENTRY( "MA", ARABIC, ARABIC_MOROCCO )
300 LANG_SUB_ENTRY( "TN", ARABIC, ARABIC_TUNISIA )
301 LANG_SUB_ENTRY( "OM", ARABIC, ARABIC_OMAN )
302 LANG_SUB_ENTRY( "YE", ARABIC, ARABIC_YEMEN )
303 LANG_SUB_ENTRY( "SY", ARABIC, ARABIC_SYRIA )
304 LANG_SUB_ENTRY( "JO", ARABIC, ARABIC_JORDAN )
305 LANG_SUB_ENTRY( "LB", ARABIC, ARABIC_LEBANON )
306 LANG_SUB_ENTRY( "KW", ARABIC, ARABIC_KUWAIT )
307 LANG_SUB_ENTRY( "AE", ARABIC, ARABIC_UAE )
308 LANG_SUB_ENTRY( "BH", ARABIC, ARABIC_BAHRAIN )
309 LANG_SUB_ENTRY( "QA", ARABIC, ARABIC_QATAR )
310 LANG_ENTRY_END( ARABIC )
311 /*x02*/ LANG_ENTRY_BEGIN( "bu", BULGARIAN )
312 LANG_ENTRY_END( BULGARIAN )
313 /*x03*/ LANG_ENTRY_BEGIN( "ca", CATALAN )
314 LANG_ENTRY_END( CATALAN )
315 /*x04*/ LANG_ENTRY_BEGIN( "zh", CHINESE )
316 LANG_SUB_ENTRY( "TW", CHINESE, CHINESE_TRADITIONAL )
317 LANG_SUB_ENTRY( "CN", CHINESE, CHINESE_SIMPLIFIED )
318 LANG_SUB_ENTRY( "HK", CHINESE, CHINESE_HONGKONG )
319 LANG_SUB_ENTRY( "SG", CHINESE, CHINESE_SINGAPORE )
320 LANG_SUB_ENTRY( "MO", CHINESE, CHINESE_MACAU )
321 LANG_ENTRY_END( CHINESE )
322 /*x05*/ LANG_ENTRY_BEGIN( "cs", CZECH )
323 LANG_ENTRY_END( CZECH )
324 /*x06*/ LANG_ENTRY_BEGIN( "da", DANISH )
325 LANG_ENTRY_END( DANISH )
326 /*x07*/ LANG_ENTRY_BEGIN( "de", GERMAN )
327 LANG_SUB_ENTRY( "DE", GERMAN, GERMAN )
328 LANG_SUB_ENTRY( "CH", GERMAN, GERMAN_SWISS )
329 LANG_SUB_ENTRY( "AT", GERMAN, GERMAN_AUSTRIAN )
330 LANG_SUB_ENTRY( "LU", GERMAN, GERMAN_LUXEMBOURG )
331 LANG_SUB_ENTRY( "LI", GERMAN, GERMAN_LIECHTENSTEIN )
332 LANG_ENTRY_END( GERMAN )
333 /*x08*/ LANG_ENTRY_BEGIN( "el", GREEK )
334 LANG_ENTRY_END( GREEK )
335 /*x09*/ LANG_ENTRY_BEGIN( "en", ENGLISH )
336 LANG_SUB_ENTRY( "US", ENGLISH, ENGLISH_US )
337 LANG_SUB_ENTRY( "UK", ENGLISH, ENGLISH_UK )
338 LANG_SUB_ENTRY( "GB", ENGLISH, ENGLISH_UK )
339 LANG_SUB_ENTRY( "AU", ENGLISH, ENGLISH_AUS )
340 LANG_SUB_ENTRY( "CA", ENGLISH, ENGLISH_CAN )
341 LANG_SUB_ENTRY( "NZ", ENGLISH, ENGLISH_NZ )
342 LANG_SUB_ENTRY( "EI", ENGLISH, ENGLISH_EIRE )
343 LANG_SUB_ENTRY( "ZA", ENGLISH, ENGLISH_SAFRICA )
344 LANG_SUB_ENTRY( "JM", ENGLISH, ENGLISH_JAMAICA )
345 /* LANG_SUB_ENTRY( "AG", ENGLISH, ENGLISH_CARIBBEAN ) */
346 LANG_SUB_ENTRY( "BZ", ENGLISH, ENGLISH_BELIZE )
347 LANG_SUB_ENTRY( "TT", ENGLISH, ENGLISH_TRINIDAD )
348 LANG_SUB_ENTRY( "ZW", ENGLISH, ENGLISH_ZIMBABWE )
349 LANG_SUB_ENTRY( "PH", ENGLISH, ENGLISH_PHILIPPINES )
350 LANG_ENTRY_END( ENGLISH )
351 /*x0a*/ LANG_ENTRY_BEGIN( "es", SPANISH )
352 /* traditional sorting */
353 if (!strcmp(dialect,"tradicional"))
354 LANG_DIALECT_ENTRY( SPANISH, SPANISH )
355 LANG_SUB_ENTRY( "MX", SPANISH, SPANISH_MEXICAN )
356 LANG_SUB_ENTRY( "ES", SPANISH, SPANISH_MODERN )
357 LANG_SUB_ENTRY( "GT", SPANISH, SPANISH_GUATEMALA )
358 LANG_SUB_ENTRY( "CR", SPANISH, SPANISH_COSTARICA )
359 LANG_SUB_ENTRY( "PA", SPANISH, SPANISH_PANAMA )
360 LANG_SUB_ENTRY( "DO", SPANISH, SPANISH_DOMINICAN )
361 LANG_SUB_ENTRY( "VE", SPANISH, SPANISH_VENEZUELA )
362 LANG_SUB_ENTRY( "CO", SPANISH, SPANISH_COLOMBIA )
363 LANG_SUB_ENTRY( "PE", SPANISH, SPANISH_PERU )
364 LANG_SUB_ENTRY( "AR", SPANISH, SPANISH_ARGENTINA )
365 LANG_SUB_ENTRY( "EC", SPANISH, SPANISH_ECUADOR )
366 LANG_SUB_ENTRY( "CL", SPANISH, SPANISH_CHILE )
367 LANG_SUB_ENTRY( "UY", SPANISH, SPANISH_URUGUAY )
368 LANG_SUB_ENTRY( "PY", SPANISH, SPANISH_PARAGUAY )
369 LANG_SUB_ENTRY( "BO", SPANISH, SPANISH_BOLIVIA )
370 LANG_SUB_ENTRY( "HN", SPANISH, SPANISH_HONDURAS )
371 LANG_SUB_ENTRY( "NI", SPANISH, SPANISH_NICARAGUA )
372 LANG_SUB_ENTRY( "PR", SPANISH, SPANISH_PUERTO_RICO )
373 LANG_ENTRY_END( SPANISH )
374 /*x0b*/ LANG_ENTRY_BEGIN( "fi", FINNISH )
375 LANG_ENTRY_END( FINNISH )
376 /*x0c*/ LANG_ENTRY_BEGIN( "fr", FRENCH )
377 LANG_SUB_ENTRY( "FR", FRENCH, FRENCH )
378 LANG_SUB_ENTRY( "BE", FRENCH, FRENCH_BELGIAN )
379 LANG_SUB_ENTRY( "CA", FRENCH, FRENCH_CANADIAN )
380 LANG_SUB_ENTRY( "CH", FRENCH, FRENCH_SWISS )
381 LANG_SUB_ENTRY( "LU", FRENCH, FRENCH_LUXEMBOURG )
382 LANG_SUB_ENTRY( "MC", FRENCH, FRENCH_MONACO )
383 LANG_ENTRY_END( FRENCH )
384 /*x0d*/ LANG_ENTRY_BEGIN( "iw", HEBREW )
385 LANG_ENTRY_END( HEBREW )
386 /*x0e*/ LANG_ENTRY_BEGIN( "hu", HUNGARIAN )
387 LANG_ENTRY_END( HUNGARIAN )
388 /*x0f*/ LANG_ENTRY_BEGIN( "ic", ICELANDIC )
389 LANG_ENTRY_END( ICELANDIC )
390 /*x10*/ LANG_ENTRY_BEGIN( "it", ITALIAN )
391 LANG_SUB_ENTRY( "IT", ITALIAN, ITALIAN )
392 LANG_SUB_ENTRY( "CH", ITALIAN, ITALIAN_SWISS )
393 LANG_ENTRY_END( ITALIAN )
394 /*x11*/ LANG_ENTRY_BEGIN( "ja", JAPANESE )
395 LANG_ENTRY_END( JAPANESE )
396 /*x12*/ LANG_ENTRY_BEGIN( "ko", KOREAN )
397 /* JOHAB encoding */
398 if (!strcmp(charset,"JOHAB"))
399 LANG_DIALECT_ENTRY( KOREAN, KOREAN_JOHAB )
400 else
401 LANG_DIALECT_ENTRY( KOREAN, KOREAN )
402 LANG_ENTRY_END( KOREAN )
403 /*x13*/ LANG_ENTRY_BEGIN( "nl", DUTCH )
404 LANG_SUB_ENTRY( "NL", DUTCH, DUTCH )
405 LANG_SUB_ENTRY( "BE", DUTCH, DUTCH_BELGIAN )
406 LANG_SUB_ENTRY( "SR", DUTCH, DUTCH_SURINAM )
407 LANG_ENTRY_END( DUTCH )
408 /*x14*/ LANG_ENTRY_BEGIN( "no", NORWEGIAN )
409 /* nynorsk */
410 if (!strcmp(dialect,"nynorsk"))
411 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_NYNORSK )
412 else
413 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_BOKMAL )
414 LANG_ENTRY_END( NORWEGIAN )
415 /*x15*/ LANG_ENTRY_BEGIN( "pl", POLISH )
416 LANG_ENTRY_END( POLISH )
417 /*x16*/ LANG_ENTRY_BEGIN( "pt", PORTUGUESE )
418 LANG_SUB_ENTRY( "BR", PORTUGUESE, PORTUGUESE_BRAZILIAN )
419 LANG_SUB_ENTRY( "PT", PORTUGUESE, PORTUGUESE )
420 LANG_ENTRY_END( PORTUGUESE )
421 /*x17*/ LANG_ENTRY_BEGIN( "rm", RHAETO_ROMANCE )
422 LANG_ENTRY_END( RHAETO_ROMANCE )
423 /*x18*/ LANG_ENTRY_BEGIN( "ro", ROMANIAN )
424 LANG_SUB_ENTRY( "RO", ROMANIAN, ROMANIAN )
425 LANG_SUB_ENTRY( "MD", ROMANIAN, ROMANIAN_MOLDAVIA )
426 LANG_ENTRY_END( ROMANIAN )
427 /*x19*/ LANG_ENTRY_BEGIN( "ru", RUSSIAN )
428 LANG_SUB_ENTRY( "RU", RUSSIAN, RUSSIAN )
429 LANG_SUB_ENTRY( "MD", RUSSIAN, RUSSIAN_MOLDAVIA )
430 LANG_ENTRY_END( RUSSIAN )
431 /*x1a*/ if (!strcmp(lang,"sh") || !strcmp(lang,"hr") || !strcmp(lang,"sr")) {
432 if (!country[0])
433 LANG_DIALECT_ENTRY( SERBO_CROATIAN, NEUTRAL)
434 if (!strcmp(charset,"ISO-8859-5"))
435 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN )
436 LANG_SUB_ENTRY( "HR", SERBO_CROATIAN, CROATIAN )
437 if (!strcmp(country,"YU") && !strcmp(charset,"ISO-8859-2"))
438 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
439 LANG_SUB_ENTRY( "YU", SERBO_CROATIAN, SERBIAN )
440 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
442 /*x1b*/ LANG_ENTRY_BEGIN( "sk", SLOVAK )
443 LANG_ENTRY_END( SLOVAK )
444 /*x1c*/ LANG_ENTRY_BEGIN( "sq", ALBANIAN )
445 LANG_ENTRY_END( ALBANIAN )
446 /*x1d*/ LANG_ENTRY_BEGIN( "sv", SWEDISH )
447 LANG_SUB_ENTRY( "SE", SWEDISH, SWEDISH )
448 LANG_SUB_ENTRY( "FI", SWEDISH, SWEDISH_FINLAND )
449 LANG_ENTRY_END( SWEDISH )
450 /*x1e*/ LANG_ENTRY_BEGIN( "th", THAI )
451 LANG_ENTRY_END( THAI )
452 /*x1f*/ LANG_ENTRY_BEGIN( "tr", TURKISH )
453 LANG_ENTRY_END( TURKISH )
454 /*x20*/ LANG_ENTRY_BEGIN( "ur", URDU )
455 LANG_ENTRY_END( URDU )
456 /*x21*/ LANG_ENTRY_BEGIN( "in", INDONESIAN )
457 LANG_ENTRY_END( INDONESIAN )
458 /*x22*/ LANG_ENTRY_BEGIN( "uk", UKRAINIAN )
459 LANG_ENTRY_END( UKRAINIAN )
460 /*x23*/ LANG_ENTRY_BEGIN( "be", BYELORUSSIAN )
461 LANG_ENTRY_END( BYELORUSSIAN )
462 /*x24*/ LANG_ENTRY_BEGIN( "sl", SLOVENIAN )
463 LANG_ENTRY_END( SLOVENIAN )
464 /*x25*/ LANG_ENTRY_BEGIN( "et", ESTONIAN )
465 LANG_ENTRY_END( ESTONIAN )
466 /*x26*/ LANG_ENTRY_BEGIN( "lv", LATVIAN )
467 LANG_ENTRY_END( LATVIAN )
468 /*x27*/ LANG_ENTRY_BEGIN( "lt", LITHUANIAN )
469 /* traditional sorting ? */
470 if (!strcmp(dialect,"classic") || !strcmp(dialect,"traditional"))
471 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN_CLASSIC )
472 else
473 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN )
474 LANG_ENTRY_END( LITHUANIAN )
475 /*x28*/ LANG_ENTRY_BEGIN( "mi", MAORI )
476 LANG_ENTRY_END( MAORI )
477 /*x29*/ LANG_ENTRY_BEGIN( "fa", FARSI )
478 LANG_ENTRY_END( FARSI )
479 /*x2a*/ LANG_ENTRY_BEGIN( "vi", VIETNAMESE )
480 LANG_ENTRY_END( VIETNAMESE )
481 /*x2b*/ LANG_ENTRY_BEGIN( "hy", ARMENIAN )
482 LANG_ENTRY_END( ARMENIAN )
483 /*x2c*/ LANG_ENTRY_BEGIN( "az", AZERI )
484 /* Cyrillic */
485 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
486 LANG_DIALECT_ENTRY( AZERI, AZERI_CYRILLIC )
487 else
488 LANG_DIALECT_ENTRY( AZERI, AZERI )
489 LANG_ENTRY_END( AZERI )
490 /*x2d*/ LANG_ENTRY_BEGIN( "eu", BASQUE )
491 LANG_ENTRY_END( BASQUE )
492 /*x2e*/ /*LANG_ENTRY_BEGIN( "??", SORBIAN )
493 LANG_ENTRY_END( SORBIAN ) */
494 /*x2f*/ LANG_ENTRY_BEGIN( "mk", MACEDONIAN )
495 LANG_ENTRY_END( MACEDONIAN )
496 /*x30*/ /*LANG_ENTRY_BEGIN( "??", SUTU )
497 LANG_ENTRY_END( SUTU ) */
498 /*x31*/ LANG_ENTRY_BEGIN( "ts", TSONGA )
499 LANG_ENTRY_END( TSONGA )
500 /*x32*/ /*LANG_ENTRY_BEGIN( "??", TSWANA )
501 LANG_ENTRY_END( TSWANA ) */
502 /*x33*/ /*LANG_ENTRY_BEGIN( "??", VENDA )
503 LANG_ENTRY_END( VENDA ) */
504 /*x34*/ LANG_ENTRY_BEGIN( "xh", XHOSA )
505 LANG_ENTRY_END( XHOSA )
506 /*x35*/ LANG_ENTRY_BEGIN( "zu", ZULU )
507 LANG_ENTRY_END( ZULU )
508 /*x36*/ LANG_ENTRY_BEGIN( "af", AFRIKAANS )
509 LANG_ENTRY_END( AFRIKAANS )
510 /*x37*/ LANG_ENTRY_BEGIN( "ka", GEORGIAN )
511 LANG_ENTRY_END( GEORGIAN )
512 /*x38*/ LANG_ENTRY_BEGIN( "fo", FAEROESE )
513 LANG_ENTRY_END( FAEROESE )
514 /*x39*/ LANG_ENTRY_BEGIN( "hi", HINDI )
515 LANG_ENTRY_END( HINDI )
516 /*x3a*/ LANG_ENTRY_BEGIN( "mt", MALTESE )
517 LANG_ENTRY_END( MALTESE )
518 /*x3b*/ /*LANG_ENTRY_BEGIN( "??", SAAMI )
519 LANG_ENTRY_END( SAAMI ) */
520 /*x3c*/ LANG_ENTRY_BEGIN( "ga", GAELIC )
521 LANG_DIALECT_ENTRY( GAELIC, GAELIC )
522 LANG_ENTRY_END( GAELIC )
523 /*x3c*/ LANG_ENTRY_BEGIN( "gd", GAELIC )
524 LANG_DIALECT_ENTRY( GAELIC, GAELIC_SCOTTISH )
525 LANG_ENTRY_END( GAELIC )
526 /* 0x3d */
527 /*x3e*/ LANG_ENTRY_BEGIN( "ms", MALAY )
528 LANG_SUB_ENTRY( "MY", MALAY, MALAY )
529 LANG_SUB_ENTRY( "BN", MALAY, MALAY_BRUNEI_DARUSSALAM )
530 LANG_ENTRY_END( MALAY )
531 /*x3f*/ LANG_ENTRY_BEGIN( "kk", KAZAKH )
532 LANG_ENTRY_END( KAZAKH )
533 /* 0x40 */
534 /*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI )
535 LANG_ENTRY_END( SWAHILI )
536 /* 0x42 */
537 /*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK )
538 /* Cyrillic */
539 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
540 LANG_DIALECT_ENTRY( UZBEK, UZBEK_CYRILLIC )
541 else
542 LANG_DIALECT_ENTRY( UZBEK, UZBEK )
543 LANG_ENTRY_END( UZBEK )
544 /*x44*/ LANG_ENTRY_BEGIN( "tt", TATAR )
545 LANG_ENTRY_END( TATAR )
546 /*x45*/ LANG_ENTRY_BEGIN( "bn", BENGALI )
547 LANG_ENTRY_END( BENGALI )
548 /*x46*/ LANG_ENTRY_BEGIN( "pa", PUNJABI )
549 LANG_ENTRY_END( PUNJABI )
550 /*x47*/ LANG_ENTRY_BEGIN( "gu", GUJARATI )
551 LANG_ENTRY_END( GUJARATI )
552 /*x48*/ LANG_ENTRY_BEGIN( "or", ORIYA )
553 LANG_ENTRY_END( ORIYA )
554 /*x49*/ LANG_ENTRY_BEGIN( "ta", TAMIL )
555 LANG_ENTRY_END( TAMIL )
556 /*x4a*/ LANG_ENTRY_BEGIN( "te", TELUGU )
557 LANG_ENTRY_END( TELUGU )
558 /*x4b*/ LANG_ENTRY_BEGIN( "kn", KANNADA )
559 LANG_ENTRY_END( KANNADA )
560 /*x4c*/ LANG_ENTRY_BEGIN( "ml", MALAYALAM )
561 LANG_ENTRY_END( MALAYALAM )
562 /*x4d*/ LANG_ENTRY_BEGIN( "as", ASSAMESE )
563 LANG_ENTRY_END( ASSAMESE )
564 /*x4e*/ LANG_ENTRY_BEGIN( "mr", MARATHI )
565 LANG_ENTRY_END( MARATHI )
566 /*x4f*/ LANG_ENTRY_BEGIN( "sa", SANSKRIT )
567 LANG_ENTRY_END( SANSKRIT )
568 /* 0x50 -> 0x56 */
569 /*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
570 LANG_ENTRY_END( KONKANI ) */
571 /* 0x58 -> ... */
572 LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */
573 LANG_ENTRY_END( ESPERANTO )
574 LANG_ENTRY_BEGIN( "wa", WALON ) /* not official */
575 LANG_ENTRY_END( WALON )
577 ret = LANG_ENGLISH;
579 end_MAIN_GetLanguageID:
580 if (Charset) free(charset);
581 free(dialect);
583 return ret;
586 /***********************************************************************
587 * MAIN_ParseLanguageOption
589 * Parse -language option.
591 void MAIN_ParseLanguageOption( const char *arg )
593 const WINE_LANGUAGE_DEF *p = Languages;
595 Options.language = LANG_Xx; /* First (dummy) language */
596 for (;p->name;p++)
598 if (!lstrcmpiA( p->name, arg ))
600 WINE_LanguageId = p->langid;
601 return;
603 Options.language++;
605 MESSAGE( "Invalid language specified '%s'. Supported languages are: ", arg );
606 for (p = Languages; p->name; p++) MESSAGE( "%s ", p->name );
607 MESSAGE( "\n" );
608 ExitProcess(1);
612 /***********************************************************************
613 * called_at_exit
615 static void called_at_exit(void)
617 CONSOLE_Close();
620 /***********************************************************************
621 * MAIN_WineInit
623 * Wine initialisation and command-line parsing
625 void MAIN_WineInit(void)
627 struct timeval tv;
629 #ifdef MALLOC_DEBUGGING
630 char *trace;
632 mcheck(NULL);
633 if (!(trace = getenv("MALLOC_TRACE")))
635 MESSAGE( "MALLOC_TRACE not set. No trace generated\n" );
637 else
639 MESSAGE( "malloc trace goes to %s\n", trace );
640 mtrace();
642 #endif
644 setbuf(stdout,NULL);
645 setbuf(stderr,NULL);
647 setlocale(LC_CTYPE,"");
648 gettimeofday( &tv, NULL);
649 atexit(called_at_exit);
652 /***********************************************************************
653 * MessageBeep16 (USER.104)
655 void WINAPI MessageBeep16( UINT16 i )
657 MessageBeep( i );
661 /***********************************************************************
662 * MessageBeep (USER32.390)
664 BOOL WINAPI MessageBeep( UINT i )
666 KEYBOARD_Beep();
667 return TRUE;
671 /***********************************************************************
672 * Beep (KERNEL32.11)
674 BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur )
676 /* dwFreq and dwDur are ignored by Win95 */
677 KEYBOARD_Beep();
678 return TRUE;
682 /***********************************************************************
683 * FileCDR (KERNEL.130)
685 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
687 FIXME_(file)("(0x%8x): stub\n", (int) x);
688 return (FARPROC16)TRUE;
691 /***********************************************************************
692 * GetTickCount (USER.13) (KERNEL32.299)
694 * Returns the number of milliseconds, modulo 2^32, since the start
695 * of the current session.
697 DWORD WINAPI GetTickCount(void)
699 struct timeval t;
700 gettimeofday( &t, NULL );
701 return (t.tv_sec * 1000) + (t.tv_usec / 1000);