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