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