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