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