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