FindResourceExA/W should search for the specified language resource only.
[wine] / misc / main.c
1 /*
2  * Main function.
3  *
4  * Copyright 1994 Alexandre Julliard
5  */
6
7 #include "config.h"
8
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
17
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"
40
41 /**********************************************************************/
42
43 USER_DRIVER *USER_Driver = NULL;
44
45
46
47 /***********************************************************************
48  *          MAIN_ParseDebugOptions
49  *
50  *  Turns specific debug messages on or off, according to "options".
51  */
52 void MAIN_ParseDebugOptions( const char *arg )
53 {
54   /* defined in relay32/relay386.c */
55   extern char **debug_relay_includelist;
56   extern char **debug_relay_excludelist;
57   /* defined in relay32/snoop.c */
58   extern char **debug_snoop_includelist;
59   extern char **debug_snoop_excludelist;
60
61   int i;
62   int l, cls;
63
64   char *options = strdup(arg);
65
66   l = strlen(options);
67   if (l<2) goto error;
68
69   if (options[l-1]=='\n') options[l-1]='\0';
70   do
71   {
72     if ((*options!='+')&&(*options!='-')){
73       int j;
74
75       for(j=0; j<DEBUG_CLASS_COUNT; j++)
76         if(!lstrncmpiA(options, debug_cl_name[j], strlen(debug_cl_name[j])))
77           break;
78       if(j==DEBUG_CLASS_COUNT)
79         goto error;
80       options += strlen(debug_cl_name[j]);
81       if ((*options!='+')&&(*options!='-'))
82         goto error;
83       cls = j;
84     }
85     else
86       cls = -1; /* all classes */
87
88     if (strchr(options,','))
89       l=strchr(options,',')-options;
90     else
91       l=strlen(options);
92
93     if (!lstrncmpiA(options+1,"all",l-1))
94       {
95         int i, j;
96         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
97           for(j=0; j<DEBUG_CLASS_COUNT; j++)
98             if(cls == -1 || cls == j)
99                 __SET_DEBUGGING( j, debug_channels[i], (*options=='+') );
100       }
101     else if (!lstrncmpiA(options+1, "relay=", 6) ||
102              !lstrncmpiA(options+1, "snoop=", 6))
103       {
104         int i, j;
105         char *s, *s2, ***output, c;
106
107         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
108           if (!strncasecmp( debug_channels[i] + 1, options + 1, 5))
109           {
110             for(j=0; j<DEBUG_CLASS_COUNT; j++)
111               if(cls == -1 || cls == j)
112                   __SET_DEBUGGING( j, debug_channels[i], 1 );
113             break;
114           }
115         /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
116         if (i==DEBUG_CHANNEL_COUNT)
117           goto error;
118         output = (*options == '+') ?
119                         ((*(options+1) == 'r') ?
120                                 &debug_relay_includelist :
121                                 &debug_snoop_includelist) :
122                         ((*(options+1) == 'r') ?
123                                 &debug_relay_excludelist :
124                                 &debug_snoop_excludelist);
125         s = options + 7;
126         /* if there are n ':', there are n+1 modules, and we need n+2 slots
127          * last one being for the sentinel (NULL) */
128         i = 2;  
129         while((s = strchr(s, ':'))) i++, s++;
130         *output = malloc(sizeof(char **) * i);
131         i = 0;
132         s = options + 7;
133         while((s2 = strchr(s, ':'))) {
134           c = *s2;
135           *s2 = '\0';
136           *((*output)+i) = CharUpperA(strdup(s));
137           *s2 = c;
138           s = s2 + 1;
139           i++;
140         }
141         c = *(options + l);
142         *(options + l) = '\0';
143         *((*output)+i) = CharUpperA(strdup(s));
144         *(options + l) = c;
145         *((*output)+i+1) = NULL;
146       }
147     else
148       {
149         int i, j;
150         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
151           if (!strncasecmp( debug_channels[i] + 1, options + 1, l - 1) && !debug_channels[i][l])
152           {
153             for(j=0; j<DEBUG_CLASS_COUNT; j++)
154               if(cls == -1 || cls == j)
155                   __SET_DEBUGGING( j, debug_channels[i], (*options=='+') );
156             break;
157           }
158         if (i==DEBUG_CHANNEL_COUNT)
159           goto error;
160       }
161     options+=l;
162   }
163   while((*options==',')&&(*(++options)));
164
165   if (!*options) return;
166
167  error:  
168   MESSAGE("%s: Syntax: --debugmsg [class]+xxx,...  or "
169       "-debugmsg [class]-xxx,...\n",argv0);
170   MESSAGE("Example: --debugmsg +all,warn-heap\n"
171       "  turn on all messages except warning heap messages\n");
172   MESSAGE("Special case: --debugmsg +relay=DLL:DLL.###:FuncName\n"
173       "  turn on -debugmsg +relay only as specified\n"
174       "Special case: --debugmsg -relay=DLL:DLL.###:FuncName\n"
175       "  turn on --debugmsg +relay except as specified\n"
176       "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
177   
178   MESSAGE("Available message classes:\n");
179   for(i=0;i<DEBUG_CLASS_COUNT;i++)
180     MESSAGE( "%-9s", debug_cl_name[i]);
181   MESSAGE("\n\n");
182   
183   MESSAGE("Available message types:\n");
184   MESSAGE("%-9s ","all");
185   for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
186       MESSAGE("%-9s%c",debug_channels[i] + 1,
187           (((i+2)%8==0)?'\n':' '));
188   MESSAGE("\n\n");
189   ExitProcess(1);
190 }
191
192 /***********************************************************************
193  *           MAIN_GetLanguageID
194  *
195  * INPUT:
196  *      Lang: a string whose two first chars are the iso name of a language.
197  *      Country: a string whose two first chars are the iso name of country
198  *      Charset: a string defining the chossen charset encoding
199  *      Dialect: a string defining a variation of the locale
200  *
201  *      all those values are from the standardized format of locale
202  *      name in unix which is: Lang[_Country][.Charset][@Dialect]
203  *
204  * RETURNS:
205  *      the numeric code of the language used by Windows (or 0x00)
206  */
207 int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
208 {
209     char lang[3]="??", country[3]={0,0,0};
210     char *charset=NULL, *dialect=NULL;
211     int i,j,ret=0;
212
213     if (Lang==NULL) return 0x00;
214     if (Lang[0]) lang[0]=tolower(Lang[0]);
215     if (Lang[1]) lang[1]=tolower(Lang[1]);
216
217     if (Country!=NULL) {
218         if (Country[0]) country[0]=toupper(Country[0]);
219         if (Country[1]) country[1]=toupper(Country[1]);
220     }
221
222     if (Charset!=NULL) {
223         j=strlen(Charset);
224         charset=(char*)malloc(j+1);
225         for (i=0;i<j;i++)
226             charset[i]=toupper(Charset[i]);
227         charset[i]='\0';
228     }
229
230     if (Dialect!=NULL) {
231         j=strlen(Dialect);
232         dialect=(char*)malloc(j+1);
233         for (i=0;i<j;i++)
234             dialect[i]=tolower(Dialect[i]);
235         dialect[i]='\0';
236     } else {
237         dialect = malloc(1);
238         dialect[0] = '\0';
239     }
240
241 #define LANG_ENTRY_BEGIN(x,y)   if(!strcmp(lang, x )) { \
242                                     if (!country[0]) { \
243                                         ret=MAKELANGID(LANG_##y, SUBLANG_DEFAULT); \
244                                         goto end_MAIN_GetLanguageID; \
245                                     }
246 #define LANG_SUB_ENTRY(x,y,z)       if (!strcmp(country, x )) { \
247                                         ret = MAKELANGID( LANG_##y , SUBLANG_##z ); \
248                                         goto end_MAIN_GetLanguageID; \
249                                     }
250 #define LANG_DIALECT_ENTRY(x,y)     { ret = MAKELANGID(LANG_##x , SUBLANG_##y ); \
251                                     goto end_MAIN_GetLanguageID; }
252 #define LANG_ENTRY_END(x)           ret = MAKELANGID(LANG_##x , SUBLANG_DEFAULT); \
253                                     goto end_MAIN_GetLanguageID; \
254                                 }
255
256 /*x01*/ LANG_ENTRY_BEGIN( "ar", ARABIC )
257         LANG_SUB_ENTRY( "SA", ARABIC, ARABIC)
258         LANG_SUB_ENTRY( "IQ", ARABIC, ARABIC_IRAQ )
259         LANG_SUB_ENTRY( "EG", ARABIC, ARABIC_EGYPT )
260         LANG_SUB_ENTRY( "LY", ARABIC, ARABIC_LIBYA )
261         LANG_SUB_ENTRY( "DZ", ARABIC, ARABIC_ALGERIA )
262         LANG_SUB_ENTRY( "MA", ARABIC, ARABIC_MOROCCO )
263         LANG_SUB_ENTRY( "TN", ARABIC, ARABIC_TUNISIA )
264         LANG_SUB_ENTRY( "OM", ARABIC, ARABIC_OMAN )
265         LANG_SUB_ENTRY( "YE", ARABIC, ARABIC_YEMEN )
266         LANG_SUB_ENTRY( "SY", ARABIC, ARABIC_SYRIA )
267         LANG_SUB_ENTRY( "JO", ARABIC, ARABIC_JORDAN )
268         LANG_SUB_ENTRY( "LB", ARABIC, ARABIC_LEBANON )
269         LANG_SUB_ENTRY( "KW", ARABIC, ARABIC_KUWAIT )
270         LANG_SUB_ENTRY( "AE", ARABIC, ARABIC_UAE )
271         LANG_SUB_ENTRY( "BH", ARABIC, ARABIC_BAHRAIN )
272         LANG_SUB_ENTRY( "QA", ARABIC, ARABIC_QATAR )
273         LANG_ENTRY_END( ARABIC )
274 /*x02*/ LANG_ENTRY_BEGIN( "bu", BULGARIAN )
275         LANG_ENTRY_END( BULGARIAN )
276 /*x03*/ LANG_ENTRY_BEGIN( "ca", CATALAN )
277         LANG_ENTRY_END( CATALAN )
278 /*x04*/ LANG_ENTRY_BEGIN( "zh", CHINESE )
279         LANG_SUB_ENTRY( "TW", CHINESE, CHINESE_TRADITIONAL )
280         LANG_SUB_ENTRY( "CN", CHINESE, CHINESE_SIMPLIFIED )
281         LANG_SUB_ENTRY( "HK", CHINESE, CHINESE_HONGKONG )
282         LANG_SUB_ENTRY( "SG", CHINESE, CHINESE_SINGAPORE )
283         LANG_SUB_ENTRY( "MO", CHINESE, CHINESE_MACAU )
284         LANG_ENTRY_END( CHINESE )
285 /*x05*/ LANG_ENTRY_BEGIN( "cs", CZECH )
286         LANG_ENTRY_END( CZECH )
287 /*x06*/ LANG_ENTRY_BEGIN( "da", DANISH )
288         LANG_ENTRY_END( DANISH )
289 /*x07*/ LANG_ENTRY_BEGIN( "de", GERMAN )
290         LANG_SUB_ENTRY( "DE", GERMAN, GERMAN )
291         LANG_SUB_ENTRY( "CH", GERMAN, GERMAN_SWISS )
292         LANG_SUB_ENTRY( "AT", GERMAN, GERMAN_AUSTRIAN )
293         LANG_SUB_ENTRY( "LU", GERMAN, GERMAN_LUXEMBOURG )
294         LANG_SUB_ENTRY( "LI", GERMAN, GERMAN_LIECHTENSTEIN )
295         LANG_ENTRY_END( GERMAN )
296 /*x08*/ LANG_ENTRY_BEGIN( "el", GREEK )
297         LANG_ENTRY_END( GREEK )
298 /*x09*/ LANG_ENTRY_BEGIN( "en", ENGLISH )
299         LANG_SUB_ENTRY( "US", ENGLISH, ENGLISH_US )
300         LANG_SUB_ENTRY( "UK", ENGLISH, ENGLISH_UK )
301         LANG_SUB_ENTRY( "GB", ENGLISH, ENGLISH_UK )
302         LANG_SUB_ENTRY( "AU", ENGLISH, ENGLISH_AUS )
303         LANG_SUB_ENTRY( "CA", ENGLISH, ENGLISH_CAN )
304         LANG_SUB_ENTRY( "NZ", ENGLISH, ENGLISH_NZ )
305         LANG_SUB_ENTRY( "EI", ENGLISH, ENGLISH_EIRE )
306         LANG_SUB_ENTRY( "ZA", ENGLISH, ENGLISH_SAFRICA )
307         LANG_SUB_ENTRY( "JM", ENGLISH, ENGLISH_JAMAICA )
308      /* LANG_SUB_ENTRY( "AG", ENGLISH, ENGLISH_CARIBBEAN ) */
309         LANG_SUB_ENTRY( "BZ", ENGLISH, ENGLISH_BELIZE )
310         LANG_SUB_ENTRY( "TT", ENGLISH, ENGLISH_TRINIDAD )
311         LANG_SUB_ENTRY( "ZW", ENGLISH, ENGLISH_ZIMBABWE )
312         LANG_SUB_ENTRY( "PH", ENGLISH, ENGLISH_PHILIPPINES )
313         LANG_ENTRY_END( ENGLISH )
314 /*x0a*/ LANG_ENTRY_BEGIN( "es", SPANISH )
315         /* traditional sorting */
316         if (!strcmp(dialect,"tradicional"))
317                 LANG_DIALECT_ENTRY( SPANISH, SPANISH )
318         LANG_SUB_ENTRY( "MX", SPANISH, SPANISH_MEXICAN )
319         LANG_SUB_ENTRY( "ES", SPANISH, SPANISH_MODERN )
320         LANG_SUB_ENTRY( "GT", SPANISH, SPANISH_GUATEMALA )
321         LANG_SUB_ENTRY( "CR", SPANISH, SPANISH_COSTARICA )
322         LANG_SUB_ENTRY( "PA", SPANISH, SPANISH_PANAMA )
323         LANG_SUB_ENTRY( "DO", SPANISH, SPANISH_DOMINICAN )
324         LANG_SUB_ENTRY( "VE", SPANISH, SPANISH_VENEZUELA )
325         LANG_SUB_ENTRY( "CO", SPANISH, SPANISH_COLOMBIA )
326         LANG_SUB_ENTRY( "PE", SPANISH, SPANISH_PERU )
327         LANG_SUB_ENTRY( "AR", SPANISH, SPANISH_ARGENTINA )
328         LANG_SUB_ENTRY( "EC", SPANISH, SPANISH_ECUADOR )
329         LANG_SUB_ENTRY( "CL", SPANISH, SPANISH_CHILE )
330         LANG_SUB_ENTRY( "UY", SPANISH, SPANISH_URUGUAY )
331         LANG_SUB_ENTRY( "PY", SPANISH, SPANISH_PARAGUAY )
332         LANG_SUB_ENTRY( "BO", SPANISH, SPANISH_BOLIVIA )
333         LANG_SUB_ENTRY( "HN", SPANISH, SPANISH_HONDURAS )
334         LANG_SUB_ENTRY( "NI", SPANISH, SPANISH_NICARAGUA )
335         LANG_SUB_ENTRY( "PR", SPANISH, SPANISH_PUERTO_RICO )
336         LANG_ENTRY_END( SPANISH )
337 /*x0b*/ LANG_ENTRY_BEGIN( "fi", FINNISH )
338         LANG_ENTRY_END( FINNISH )
339 /*x0c*/ LANG_ENTRY_BEGIN( "fr", FRENCH )
340         LANG_SUB_ENTRY( "FR", FRENCH, FRENCH )
341         LANG_SUB_ENTRY( "BE", FRENCH, FRENCH_BELGIAN )
342         LANG_SUB_ENTRY( "CA", FRENCH, FRENCH_CANADIAN )
343         LANG_SUB_ENTRY( "CH", FRENCH, FRENCH_SWISS )
344         LANG_SUB_ENTRY( "LU", FRENCH, FRENCH_LUXEMBOURG )
345         LANG_SUB_ENTRY( "MC", FRENCH, FRENCH_MONACO )
346         LANG_ENTRY_END( FRENCH )
347 /*x0d*/ LANG_ENTRY_BEGIN( "iw", HEBREW )
348         LANG_ENTRY_END( HEBREW )
349 /*x0e*/ LANG_ENTRY_BEGIN( "hu", HUNGARIAN )
350         LANG_ENTRY_END( HUNGARIAN )
351 /*x0f*/ LANG_ENTRY_BEGIN( "ic", ICELANDIC )
352         LANG_ENTRY_END( ICELANDIC )
353 /*x10*/ LANG_ENTRY_BEGIN( "it", ITALIAN )
354         LANG_SUB_ENTRY( "IT", ITALIAN, ITALIAN )
355         LANG_SUB_ENTRY( "CH", ITALIAN, ITALIAN_SWISS )
356         LANG_ENTRY_END( ITALIAN )
357 /*x11*/ LANG_ENTRY_BEGIN( "ja", JAPANESE )
358         LANG_ENTRY_END( JAPANESE )
359 /*x12*/ LANG_ENTRY_BEGIN( "ko", KOREAN )
360         /* JOHAB encoding */
361         if (!strcmp(charset,"JOHAB"))
362                 LANG_DIALECT_ENTRY( KOREAN, KOREAN_JOHAB )
363         else
364                 LANG_DIALECT_ENTRY( KOREAN, KOREAN )
365         LANG_ENTRY_END( KOREAN )
366 /*x13*/ LANG_ENTRY_BEGIN( "nl", DUTCH )
367         LANG_SUB_ENTRY( "NL", DUTCH, DUTCH )
368         LANG_SUB_ENTRY( "BE", DUTCH, DUTCH_BELGIAN )
369         LANG_SUB_ENTRY( "SR", DUTCH, DUTCH_SURINAM )
370         LANG_ENTRY_END( DUTCH )
371 /*x14*/ LANG_ENTRY_BEGIN( "no", NORWEGIAN )
372         /* nynorsk */
373         if (!strcmp(dialect,"nynorsk"))
374                 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_NYNORSK )
375         else
376                 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_BOKMAL )
377         LANG_ENTRY_END( NORWEGIAN )
378 /*x15*/ LANG_ENTRY_BEGIN( "pl", POLISH )
379         LANG_ENTRY_END( POLISH )
380 /*x16*/ LANG_ENTRY_BEGIN( "pt", PORTUGUESE )
381         LANG_SUB_ENTRY( "BR", PORTUGUESE, PORTUGUESE_BRAZILIAN )
382         LANG_SUB_ENTRY( "PT", PORTUGUESE, PORTUGUESE )
383         LANG_ENTRY_END( PORTUGUESE )
384 /*x17*/ LANG_ENTRY_BEGIN( "rm", RHAETO_ROMANCE )
385         LANG_ENTRY_END( RHAETO_ROMANCE )
386 /*x18*/ LANG_ENTRY_BEGIN( "ro", ROMANIAN )
387         LANG_SUB_ENTRY( "RO", ROMANIAN, ROMANIAN )
388         LANG_SUB_ENTRY( "MD", ROMANIAN, ROMANIAN_MOLDAVIA )
389         LANG_ENTRY_END( ROMANIAN )
390 /*x19*/ LANG_ENTRY_BEGIN( "ru", RUSSIAN )
391         LANG_SUB_ENTRY( "RU", RUSSIAN, RUSSIAN )
392         LANG_SUB_ENTRY( "MD", RUSSIAN, RUSSIAN_MOLDAVIA )
393         LANG_ENTRY_END( RUSSIAN )
394 /*x1a*/ if (!strcmp(lang,"sh") || !strcmp(lang,"hr") || !strcmp(lang,"sr")) {
395             if (!country[0]) 
396                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, NEUTRAL)
397             if (!strcmp(charset,"ISO-8859-5"))
398                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN )
399             LANG_SUB_ENTRY( "HR", SERBO_CROATIAN, CROATIAN )
400             if (!strcmp(country,"YU") && !strcmp(charset,"ISO-8859-2"))
401                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
402             LANG_SUB_ENTRY( "YU", SERBO_CROATIAN, SERBIAN )
403             LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
404         }
405 /*x1b*/ LANG_ENTRY_BEGIN( "sk", SLOVAK )
406         LANG_ENTRY_END( SLOVAK )
407 /*x1c*/ LANG_ENTRY_BEGIN( "sq", ALBANIAN )
408         LANG_ENTRY_END( ALBANIAN )
409 /*x1d*/ LANG_ENTRY_BEGIN( "sv", SWEDISH )
410         LANG_SUB_ENTRY( "SE", SWEDISH, SWEDISH )
411         LANG_SUB_ENTRY( "FI", SWEDISH, SWEDISH_FINLAND )
412         LANG_ENTRY_END( SWEDISH )
413 /*x1e*/ LANG_ENTRY_BEGIN( "th", THAI )
414         LANG_ENTRY_END( THAI )
415 /*x1f*/ LANG_ENTRY_BEGIN( "tr", TURKISH )
416         LANG_ENTRY_END( TURKISH )
417 /*x20*/ LANG_ENTRY_BEGIN( "ur", URDU )
418         LANG_ENTRY_END( URDU )
419 /*x21*/ LANG_ENTRY_BEGIN( "in", INDONESIAN )
420         LANG_ENTRY_END( INDONESIAN )
421 /*x22*/ LANG_ENTRY_BEGIN( "uk", UKRAINIAN )
422         LANG_ENTRY_END( UKRAINIAN )
423 /*x23*/ LANG_ENTRY_BEGIN( "be", BYELORUSSIAN )
424         LANG_ENTRY_END( BYELORUSSIAN )
425 /*x24*/ LANG_ENTRY_BEGIN( "sl", SLOVENIAN )
426         LANG_ENTRY_END( SLOVENIAN )
427 /*x25*/ LANG_ENTRY_BEGIN( "et", ESTONIAN )
428         LANG_ENTRY_END( ESTONIAN )
429 /*x26*/ LANG_ENTRY_BEGIN( "lv", LATVIAN )
430         LANG_ENTRY_END( LATVIAN )
431 /*x27*/ LANG_ENTRY_BEGIN( "lt", LITHUANIAN )
432         /* traditional sorting ? */
433         if (!strcmp(dialect,"classic") || !strcmp(dialect,"traditional"))
434                 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN_CLASSIC )
435         else
436                 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN )
437         LANG_ENTRY_END( LITHUANIAN )
438 /*x28*/ LANG_ENTRY_BEGIN( "mi", MAORI )
439         LANG_ENTRY_END( MAORI )
440 /*x29*/ LANG_ENTRY_BEGIN( "fa", FARSI )
441         LANG_ENTRY_END( FARSI )
442 /*x2a*/ LANG_ENTRY_BEGIN( "vi", VIETNAMESE )
443         LANG_ENTRY_END( VIETNAMESE )
444 /*x2b*/ LANG_ENTRY_BEGIN( "hy", ARMENIAN )
445         LANG_ENTRY_END( ARMENIAN )
446 /*x2c*/ LANG_ENTRY_BEGIN( "az", AZERI )
447         /* Cyrillic */
448         if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
449                 LANG_DIALECT_ENTRY( AZERI, AZERI_CYRILLIC )
450         else
451                 LANG_DIALECT_ENTRY( AZERI, AZERI )
452         LANG_ENTRY_END( AZERI )
453 /*x2d*/ LANG_ENTRY_BEGIN( "eu", BASQUE )
454         LANG_ENTRY_END( BASQUE )
455 /*x2e*/ /*LANG_ENTRY_BEGIN( "??", SORBIAN )
456         LANG_ENTRY_END( SORBIAN ) */
457 /*x2f*/ LANG_ENTRY_BEGIN( "mk", MACEDONIAN )
458         LANG_ENTRY_END( MACEDONIAN )
459 /*x30*/ /*LANG_ENTRY_BEGIN( "??", SUTU )
460         LANG_ENTRY_END( SUTU ) */
461 /*x31*/ LANG_ENTRY_BEGIN( "ts", TSONGA )
462         LANG_ENTRY_END( TSONGA )
463 /*x32*/ /*LANG_ENTRY_BEGIN( "??", TSWANA )
464         LANG_ENTRY_END( TSWANA ) */
465 /*x33*/ /*LANG_ENTRY_BEGIN( "??", VENDA )
466         LANG_ENTRY_END( VENDA ) */
467 /*x34*/ LANG_ENTRY_BEGIN( "xh", XHOSA )
468         LANG_ENTRY_END( XHOSA )
469 /*x35*/ LANG_ENTRY_BEGIN( "zu", ZULU )
470         LANG_ENTRY_END( ZULU )
471 /*x36*/ LANG_ENTRY_BEGIN( "af", AFRIKAANS )
472         LANG_ENTRY_END( AFRIKAANS )
473 /*x37*/ LANG_ENTRY_BEGIN( "ka", GEORGIAN )
474         LANG_ENTRY_END( GEORGIAN )
475 /*x38*/ LANG_ENTRY_BEGIN( "fo", FAEROESE )
476         LANG_ENTRY_END( FAEROESE )
477 /*x39*/ LANG_ENTRY_BEGIN( "hi", HINDI )
478         LANG_ENTRY_END( HINDI )
479 /*x3a*/ LANG_ENTRY_BEGIN( "mt", MALTESE )
480         LANG_ENTRY_END( MALTESE )
481 /*x3b*/ /*LANG_ENTRY_BEGIN( "??", SAAMI )
482         LANG_ENTRY_END( SAAMI ) */
483 /*x3c*/ LANG_ENTRY_BEGIN( "ga", GAELIC )
484         LANG_DIALECT_ENTRY( GAELIC, GAELIC )
485         LANG_ENTRY_END( GAELIC )
486 /*x3c*/ LANG_ENTRY_BEGIN( "gd", GAELIC )
487         LANG_DIALECT_ENTRY( GAELIC, GAELIC_SCOTTISH )
488         LANG_ENTRY_END( GAELIC )
489 /* 0x3d */
490 /*x3e*/ LANG_ENTRY_BEGIN( "ms", MALAY )
491         LANG_SUB_ENTRY( "MY", MALAY, MALAY )
492         LANG_SUB_ENTRY( "BN", MALAY, MALAY_BRUNEI_DARUSSALAM )
493         LANG_ENTRY_END( MALAY )
494 /*x3f*/ LANG_ENTRY_BEGIN( "kk", KAZAKH )
495         LANG_ENTRY_END( KAZAKH )
496 /* 0x40 */
497 /*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI )
498         LANG_ENTRY_END( SWAHILI )
499 /* 0x42 */
500 /*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK )
501         /* Cyrillic */
502         if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
503                 LANG_DIALECT_ENTRY( UZBEK, UZBEK_CYRILLIC )
504         else
505                 LANG_DIALECT_ENTRY( UZBEK, UZBEK )
506         LANG_ENTRY_END( UZBEK )
507 /*x44*/ LANG_ENTRY_BEGIN( "tt", TATAR )
508         LANG_ENTRY_END( TATAR )
509 /*x45*/ LANG_ENTRY_BEGIN( "bn", BENGALI )
510         LANG_ENTRY_END( BENGALI )
511 /*x46*/ LANG_ENTRY_BEGIN( "pa", PUNJABI )
512         LANG_ENTRY_END( PUNJABI )
513 /*x47*/ LANG_ENTRY_BEGIN( "gu", GUJARATI )
514         LANG_ENTRY_END( GUJARATI )
515 /*x48*/ LANG_ENTRY_BEGIN( "or", ORIYA )
516         LANG_ENTRY_END( ORIYA )
517 /*x49*/ LANG_ENTRY_BEGIN( "ta", TAMIL )
518         LANG_ENTRY_END( TAMIL )
519 /*x4a*/ LANG_ENTRY_BEGIN( "te", TELUGU )
520         LANG_ENTRY_END( TELUGU )
521 /*x4b*/ LANG_ENTRY_BEGIN( "kn", KANNADA )
522         LANG_ENTRY_END( KANNADA )
523 /*x4c*/ LANG_ENTRY_BEGIN( "ml", MALAYALAM )
524         LANG_ENTRY_END( MALAYALAM )
525 /*x4d*/ LANG_ENTRY_BEGIN( "as", ASSAMESE )
526         LANG_ENTRY_END( ASSAMESE )
527 /*x4e*/ LANG_ENTRY_BEGIN( "mr", MARATHI )
528         LANG_ENTRY_END( MARATHI )
529 /*x4f*/ LANG_ENTRY_BEGIN( "sa", SANSKRIT )
530         LANG_ENTRY_END( SANSKRIT )
531 /* 0x50 -> 0x56 */
532 /*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
533         LANG_ENTRY_END( KONKANI ) */
534 /* 0x58 -> ... */
535         LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */
536         LANG_ENTRY_END( ESPERANTO )
537         LANG_ENTRY_BEGIN( "wa", WALON ) /* not official */ 
538         LANG_ENTRY_END( WALON )
539
540 end_MAIN_GetLanguageID:
541         if (Charset) free(charset);
542         free(dialect);
543
544         return ret;
545 }
546
547
548 /***********************************************************************
549  *           called_at_exit
550  */
551 static void called_at_exit(void)
552 {
553     CONSOLE_Close();
554 }
555
556 /***********************************************************************
557  *           MAIN_WineInit
558  *
559  * Wine initialisation and command-line parsing
560  */
561 void MAIN_WineInit(void)
562 {
563     struct timeval tv;
564
565 #ifdef MALLOC_DEBUGGING
566     char *trace;
567
568     mcheck(NULL);
569     if (!(trace = getenv("MALLOC_TRACE")))
570     {       
571         MESSAGE( "MALLOC_TRACE not set. No trace generated\n" );
572     }
573     else
574     {
575         MESSAGE( "malloc trace goes to %s\n", trace );
576         mtrace();
577     }
578 #endif
579
580     setbuf(stdout,NULL);
581     setbuf(stderr,NULL);
582
583     setlocale(LC_CTYPE,"");
584     gettimeofday( &tv, NULL);
585     atexit(called_at_exit);
586 }
587
588 /***********************************************************************
589  *           MessageBeep16   (USER.104)
590  */
591 void WINAPI MessageBeep16( UINT16 i )
592 {
593     MessageBeep( i );
594 }
595
596
597 /***********************************************************************
598  *           MessageBeep   (USER32.390)
599  */
600 BOOL WINAPI MessageBeep( UINT i )
601 {
602     KEYBOARD_Beep();
603     return TRUE;
604 }
605
606
607 /***********************************************************************
608  *           Beep   (KERNEL32.11)
609  */
610 BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur )
611 {
612     /* dwFreq and dwDur are ignored by Win95 */
613     KEYBOARD_Beep();
614     return TRUE;
615 }
616
617
618 /***********************************************************************
619 *       FileCDR (KERNEL.130)
620 */
621 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
622 {
623         FIXME_(file)("(0x%8x): stub\n", (int) x);
624         return (FARPROC16)TRUE;
625 }
626
627 /***********************************************************************
628  *           GetTickCount   (USER.13) (KERNEL32.299)
629  *
630  * Returns the number of milliseconds, modulo 2^32, since the start
631  * of the current session.
632  */
633 DWORD WINAPI GetTickCount(void)
634 {
635     struct timeval t;
636     gettimeofday( &t, NULL );
637     return (t.tv_sec * 1000) + (t.tv_usec / 1000);
638 }