Small fixes to get the default language to a sensible value.
[wine] / misc / main.c
1 /*
2  * Main function.
3  *
4  * Copyright 1994 Alexandre Julliard
5  */
6
7 #include <signal.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <ctype.h>
12 /* #include <locale.h> */
13 #ifdef MALLOC_DEBUGGING
14 #include <malloc.h>
15 #endif
16 #include "ts_xlib.h"
17 #include "ts_xresource.h"
18 #include "ts_xutil.h"
19 #include <X11/Xlocale.h>
20 #include <X11/cursorfont.h>
21 #include "winsock.h"
22 #include "heap.h"
23 #include "message.h"
24 #include "msdos.h"
25 #include "windows.h"
26 #include "color.h"
27 #include "options.h"
28 #include "desktop.h"
29 #include "process.h"
30 #include "shell.h"
31 #include "winbase.h"
32 #include "debug.h"
33 #include "debugdefs.h"
34 #include "xmalloc.h"
35 #include "version.h"
36 #include "winnls.h"
37
38 /* when adding new languages look at ole/ole2nls.c 
39  * for proper iso name and Windows code (add 0x0400 
40  * to the code listed there)
41  */
42 const WINE_LANGUAGE_DEF Languages[] =
43 {
44     {"En",0x0409},      /* LANG_En */
45     {"Es",0x040A},      /* LANG_Es */
46     {"De",0x0407},      /* LANG_De */
47     {"No",0x0414},      /* LANG_No */
48     {"Fr",0x040C},      /* LANG_Fr */
49     {"Fi",0x040B},      /* LANG_Fi */
50     {"Da",0x0406},      /* LANG_Da */
51     {"Cs",0x0405},      /* LANG_Cs */
52     {"Eo",0x048f},      /* LANG_Eo */
53     {"It",0x0410},      /* LANG_It */
54     {"Ko",0x0412},      /* LANG_Ko */
55     {"Hu",0x040e},      /* LANG_Hu */
56     {"Pl",0x0415},      /* LANG_Pl */
57     {"Pt",0x0416},      /* LANG_Pt */
58     {"Sv",0x041d},      /* LANG_Sv */
59     {"Ca",0x0403},      /* LANG_Ca */
60 /* for compatibility whith non-iso names previously used */
61     {"Sw",0x041d},      /* LANG_Sv */
62     {"Cz",0x0405},      /* LANG_Cs */
63     {"Po",0x0416},      /* LANG_Pt */
64     {NULL,0}
65 };
66
67 WORD WINE_LanguageId = 0x409;   /* english as default */
68
69 #define WINE_CLASS    "Wine"    /* Class name for resources */
70
71 #define WINE_APP_DEFAULTS "/usr/lib/X11/app-defaults/Wine"
72
73 Display *display;
74 Screen *screen;
75 Window rootWindow;
76 int screenWidth = 0, screenHeight = 0;  /* Desktop window dimensions */
77 int screenDepth = 0;  /* Screen depth to use */
78
79 struct options Options =
80 {  /* default options */
81     NULL,           /* desktopGeometry */
82     NULL,           /* programName */
83     NULL,           /* argv0 */
84     NULL,           /* dllFlags */
85     FALSE,          /* usePrivateMap */
86     FALSE,          /* useFixedMap */
87     FALSE,          /* synchronous */
88     FALSE,          /* backing store */
89     SW_SHOWNORMAL,  /* cmdShow */
90     FALSE,
91     FALSE,          /* failReadOnly */
92     MODE_ENHANCED,  /* Enhanced mode */
93 #ifdef DEFAULT_LANG
94     DEFAULT_LANG,   /* Default language */
95 #else
96     LANG_En,
97 #endif
98     FALSE,          /* Managed windows */
99     FALSE,          /* Perfect graphics */
100     NULL            /* Alternate config file name */
101 };
102
103
104 static XrmOptionDescRec optionsTable[] =
105 {
106     { "-backingstore",  ".backingstore",    XrmoptionNoArg,  (caddr_t)"on" },
107     { "-desktop",       ".desktop",         XrmoptionSepArg, (caddr_t)NULL },
108     { "-depth",         ".depth",           XrmoptionSepArg, (caddr_t)NULL },
109     { "-display",       ".display",         XrmoptionSepArg, (caddr_t)NULL },
110     { "-iconic",        ".iconic",          XrmoptionNoArg,  (caddr_t)"on" },
111     { "-language",      ".language",        XrmoptionSepArg, (caddr_t)"En" },
112     { "-name",          ".name",            XrmoptionSepArg, (caddr_t)NULL },
113     { "-perfect",       ".perfect",         XrmoptionNoArg,  (caddr_t)"on" },
114     { "-privatemap",    ".privatemap",      XrmoptionNoArg,  (caddr_t)"on" },
115     { "-fixedmap",      ".fixedmap",        XrmoptionNoArg,  (caddr_t)"on" },
116     { "-synchronous",   ".synchronous",     XrmoptionNoArg,  (caddr_t)"on" },
117     { "-debug",         ".debug",           XrmoptionNoArg,  (caddr_t)"on" },
118     { "-debugmsg",      ".debugmsg",        XrmoptionSepArg, (caddr_t)NULL },
119     { "-dll",           ".dll",             XrmoptionSepArg, (caddr_t)NULL },
120     { "-failreadonly",  ".failreadonly",    XrmoptionNoArg,  (caddr_t)"on" },
121     { "-mode",          ".mode",            XrmoptionSepArg, (caddr_t)NULL },
122     { "-managed",       ".managed",         XrmoptionNoArg,  (caddr_t)"off"},
123     { "-winver",        ".winver",          XrmoptionSepArg, (caddr_t)NULL },
124     { "-config",        ".config",          XrmoptionSepArg, (caddr_t)NULL }
125 };
126
127 #define NB_OPTIONS  (sizeof(optionsTable) / sizeof(optionsTable[0]))
128
129 #define USAGE \
130   "%s\n" \
131   "Usage:  %s [options] \"program_name [arguments]\"\n" \
132   "\n" \
133   "Options:\n" \
134   "    -backingstore   Turn on backing store\n" \
135   "    -config name    Specify config file to use\n" \
136   "    -debug          Enter debugger before starting application\n" \
137   "    -debugmsg name  Turn debugging-messages on or off\n" \
138   "    -depth n        Change the depth to use for multiple-depth screens\n" \
139   "    -desktop geom   Use a desktop window of the given geometry\n" \
140   "    -display name   Use the specified display\n" \
141   "    -dll name       Enable or disable built-in DLLs\n" \
142   "    -failreadonly   Read only files may not be opened in write mode\n" \
143   "    -fixedmap       Use a \"standard\" color map\n" \
144   "    -help           Show this help message\n" \
145   "    -iconic         Start as an icon\n" \
146   "    -language xx    Set the language (one of Ca,Cs,Da,De,En,Eo,Es,Fi,Fr,Hu,It,\n                    Ko,No,Pl,Pt,Sv)\n" \
147   "    -managed        Allow the window manager to manage created windows\n" \
148   "    -mode mode      Start Wine in a particular mode (standard or enhanced)\n" \
149   "    -name name      Set the application name\n" \
150   "    -perfect        Favor correctness over speed for graphical operations\n" \
151   "    -privatemap     Use a private color map\n" \
152   "    -synchronous    Turn on synchronous display mode\n" \
153   "    -version        Display the Wine version\n" \
154   "    -winver         Version to imitate (one of win31,win95,nt351,nt40)\n"
155
156
157
158 /***********************************************************************
159  *           MAIN_Usage
160  */
161 void MAIN_Usage( char *name )
162 {
163     MSG( USAGE, WINE_RELEASE_INFO, name );
164     exit(1);
165 }
166
167
168 /***********************************************************************
169  *           MAIN_GetProgramName
170  *
171  * Get the program name. The name is specified by (in order of precedence):
172  * - the option '-name'.
173  * - the environment variable 'WINE_NAME'.
174  * - the last component of argv[0].
175  */
176 static char *MAIN_GetProgramName( int argc, char *argv[] )
177 {
178     int i;
179     char *p;
180
181     for (i = 1; i < argc-1; i++)
182         if (!strcmp( argv[i], "-name" )) return argv[i+1];
183     if ((p = getenv( "WINE_NAME" )) != NULL) return p;
184     if ((p = strrchr( argv[0], '/' )) != NULL) return p+1;
185     return argv[0];
186 }
187
188
189 /***********************************************************************
190  *           MAIN_GetResource
191  *
192  * Fetch the value of resource 'name' using the correct instance name.
193  * 'name' must begin with '.' or '*'
194  */
195 static int MAIN_GetResource( XrmDatabase db, char *name, XrmValue *value )
196 {
197     char *buff_instance, *buff_class;
198     char *dummy;
199     int retval;
200
201     buff_instance = (char *)xmalloc(strlen(Options.programName)+strlen(name)+1);
202     buff_class    = (char *)xmalloc( strlen(WINE_CLASS) + strlen(name) + 1 );
203
204     strcpy( buff_instance, Options.programName );
205     strcat( buff_instance, name );
206     strcpy( buff_class, WINE_CLASS );
207     strcat( buff_class, name );
208     retval = TSXrmGetResource( db, buff_instance, buff_class, &dummy, value );
209     free( buff_instance );
210     free( buff_class );
211     return retval;
212 }
213
214
215 /***********************************************************************
216  *          MAIN_ParseDebugOptions
217  *
218  *  Turns specific debug messages on or off, according to "options".
219  *  
220  *  RETURNS
221  *    TRUE if parsing was successful
222  */
223 static BOOL32 MAIN_ParseDebugOptions(char *options)
224 {
225   /* defined in relay32/relay386.c */
226   extern char **debug_relay_includelist;
227   extern char **debug_relay_excludelist;
228   /* defined in relay32/snoop.c */
229   extern char **debug_snoop_includelist;
230   extern char **debug_snoop_excludelist;
231
232   int l, cls;
233   if (strlen(options)<3)
234     return FALSE;
235   do
236   {
237     if ((*options!='+')&&(*options!='-')){
238       int j;
239
240       for(j=0; j<DEBUG_CLASS_COUNT; j++)
241         if(!lstrncmpi32A(options, debug_cl_name[j], strlen(debug_cl_name[j])))
242           break;
243       if(j==DEBUG_CLASS_COUNT)
244         return FALSE;
245       options += strlen(debug_cl_name[j]);
246       if ((*options!='+')&&(*options!='-'))
247         return FALSE;
248       cls = j;
249     }
250     else
251       cls = -1; /* all classes */
252
253     if (strchr(options,','))
254       l=strchr(options,',')-options;
255     else
256       l=strlen(options);
257
258     if (!lstrncmpi32A(options+1,"all",l-1))
259       {
260         int i, j;
261         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
262           for(j=0; j<DEBUG_CLASS_COUNT; j++)
263             if(cls == -1 || cls == j)
264               debug_msg_enabled[i][j]=(*options=='+');
265       }
266     else if (!lstrncmpi32A(options+1, "relay=", 6) ||
267              !lstrncmpi32A(options+1, "snoop=", 6))
268       {
269         int i, j;
270         char *s, *s2, ***output, c;
271
272         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
273           if (debug_ch_name && (!lstrncmpi32A(debug_ch_name[i],options+1,5))){
274             for(j=0; j<DEBUG_CLASS_COUNT; j++)
275               if(cls == -1 || cls == j)
276                 debug_msg_enabled[i][j]=TRUE;
277             break;
278           }
279         /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
280         if (i==DEBUG_CHANNEL_COUNT)
281           return FALSE;
282         output = (*options == '+') ?
283                         ((*(options+1) == 'r') ?
284                                 &debug_relay_includelist :
285                                 &debug_snoop_includelist) :
286                         ((*(options+1) == 'r') ?
287                                 &debug_relay_excludelist :
288                                 &debug_snoop_excludelist);
289         s = options + 7;
290         i = 1;
291         while((s = strchr(s, ':'))) i++, s++;
292         *output = malloc(sizeof(char **) * i + 1);
293         i = 0;
294         s = options + 7;
295         while((s2 = strchr(s, ':'))) {
296           c = *s2;
297           *s2 = '\0';
298           *((*output)+i) = strdup(s);
299           *s2 = c;
300           s = s2 + 1;
301           i++;
302         }
303         c = *(options + l);
304         *(options + l) = '\0';
305         *((*output)+i) = strdup(s);
306         *(options + l) = c;
307         *((*output)+i+1) = NULL;
308       }
309     else
310       {
311         int i, j;
312         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
313           if (debug_ch_name && (!lstrncmpi32A(options+1,debug_ch_name[i],l-1))){
314             for(j=0; j<DEBUG_CLASS_COUNT; j++)
315               if(cls == -1 || cls == j)
316                 debug_msg_enabled[i][j]=(*options=='+');
317             break;
318           }
319         if (i==DEBUG_CHANNEL_COUNT)
320           return FALSE;
321       }
322     options+=l;
323   }
324   while((*options==',')&&(*(++options)));
325   if (*options)
326     return FALSE;
327   else
328     return TRUE;
329 }
330
331 /***********************************************************************
332  *           MAIN_GetLanguageID
333  *
334  * INPUT:
335  *      Lang: a string whose two first chars are the iso name of a language.
336  *      Country: a string whose two first chars are the iso name of country
337  *      Charset: a string defining the chossen charset encoding
338  *      Dialect: a string defining a variation of the locale
339  *
340  *      all those values are from the standardized format of locale
341  *      name in unix which is: Lang[_Country][.Charset][@Dialect]
342  *
343  * RETURNS:
344  *      the numeric code of the language used by Windows (or 0x00)
345  */
346 int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
347 {
348     char lang[3]="??", country[3]={0,0,0};
349     char *charset=NULL, *dialect=NULL;
350     int i,j,ret=0;
351
352     if (Lang==NULL) return 0x00;
353     if (Lang[0]) lang[0]=tolower(Lang[0]);
354     if (Lang[1]) lang[1]=tolower(Lang[1]);
355
356     if (Country!=NULL) {
357         if (Country[0]) country[0]=toupper(Country[0]);
358         if (Country[1]) country[1]=toupper(Country[1]);
359     }
360
361     if (Charset!=NULL) {
362         j=strlen(Charset);
363         charset=(char*)malloc(j+1);
364         for (i=0;i<j;i++)
365             charset[i]=toupper(Charset[i]);
366         charset[i]='\0';
367     }
368
369     if (Dialect!=NULL) {
370         j=strlen(Dialect);
371         dialect=(char*)malloc(j+1);
372         for (i=0;i<j;i++)
373             dialect[i]=tolower(Dialect[i]);
374         dialect[i]='\0';
375     }
376
377 #define LANG_ENTRY_BEGIN(x,y)   if(!strcmp(lang, x )) { \
378                                     if (!country[0]) { \
379                                         ret=LANG_##y ; \
380                                         goto end_MAIN_GetLanguageID; \
381                                     }
382 #define LANG_SUB_ENTRY(x,y,z)       if (!strcmp(country, x )) \
383                                         ret = MAKELANGID( LANG_##y , SUBLANG_##z ); \
384                                         goto end_MAIN_GetLanguageID;
385 #define LANG_DIALECT_ENTRY(x,y)     { ret = MAKELANGID(LANG_##x , SUBLANG_##y ); \
386                                     goto end_MAIN_GetLanguageID; }
387 #define LANG_ENTRY_END(x)           ret = MAKELANGID(LANG_##x , SUBLANG_DEFAULT); \
388                                     goto end_MAIN_GetLanguageID; \
389                                 }
390
391 /*x01*/ LANG_ENTRY_BEGIN( "ar", ARABIC )
392         LANG_SUB_ENTRY( "SA", ARABIC, ARABIC)
393         LANG_SUB_ENTRY( "IQ", ARABIC, ARABIC_IRAQ )
394         LANG_SUB_ENTRY( "EG", ARABIC, ARABIC_EGYPT )
395         LANG_SUB_ENTRY( "LY", ARABIC, ARABIC_LIBYA )
396         LANG_SUB_ENTRY( "DZ", ARABIC, ARABIC_ALGERIA )
397         LANG_SUB_ENTRY( "MA", ARABIC, ARABIC_MOROCCO )
398         LANG_SUB_ENTRY( "TN", ARABIC, ARABIC_TUNISIA )
399         LANG_SUB_ENTRY( "OM", ARABIC, ARABIC_OMAN )
400         LANG_SUB_ENTRY( "YE", ARABIC, ARABIC_YEMEN )
401         LANG_SUB_ENTRY( "SY", ARABIC, ARABIC_SYRIA )
402         LANG_SUB_ENTRY( "JO", ARABIC, ARABIC_JORDAN )
403         LANG_SUB_ENTRY( "LB", ARABIC, ARABIC_LEBANON )
404         LANG_SUB_ENTRY( "KW", ARABIC, ARABIC_KUWAIT )
405         LANG_SUB_ENTRY( "AE", ARABIC, ARABIC_UAE )
406         LANG_SUB_ENTRY( "BH", ARABIC, ARABIC_BAHRAIN )
407         LANG_SUB_ENTRY( "QA", ARABIC, ARABIC_QATAR )
408         LANG_ENTRY_END( ARABIC )
409 /*x02*/ LANG_ENTRY_BEGIN( "bu", BULGARIAN )
410         LANG_ENTRY_END( BULGARIAN )
411 /*x03*/ LANG_ENTRY_BEGIN( "ca", CATALAN )
412         LANG_ENTRY_END( CATALAN )
413 /*x04*/ LANG_ENTRY_BEGIN( "zh", CHINESE )
414         LANG_SUB_ENTRY( "TW", CHINESE, CHINESE_TRADITIONAL )
415         LANG_SUB_ENTRY( "CN", CHINESE, CHINESE_SIMPLIFIED )
416         LANG_SUB_ENTRY( "HK", CHINESE, CHINESE_HONGKONG )
417         LANG_SUB_ENTRY( "SG", CHINESE, CHINESE_SINGAPORE )
418         LANG_SUB_ENTRY( "MO", CHINESE, CHINESE_MACAU )
419         LANG_ENTRY_END( CHINESE )
420 /*x05*/ LANG_ENTRY_BEGIN( "cs", CZECH )
421         LANG_ENTRY_END( CZECH )
422 /*x06*/ LANG_ENTRY_BEGIN( "da", DANISH )
423         LANG_ENTRY_END( DANISH )
424 /*x07*/ LANG_ENTRY_BEGIN( "de", GERMAN )
425         LANG_SUB_ENTRY( "DE", GERMAN, GERMAN )
426         LANG_SUB_ENTRY( "CH", GERMAN, GERMAN_SWISS )
427         LANG_SUB_ENTRY( "AT", GERMAN, GERMAN_AUSTRIAN )
428         LANG_SUB_ENTRY( "LU", GERMAN, GERMAN_LUXEMBOURG )
429         LANG_SUB_ENTRY( "LI", GERMAN, GERMAN_LIECHTENSTEIN )
430         LANG_ENTRY_END( GERMAN )
431 /*x08*/ LANG_ENTRY_BEGIN( "el", GREEK )
432         LANG_ENTRY_END( GREEK )
433 /*x09*/ LANG_ENTRY_BEGIN( "en", ENGLISH )
434         LANG_SUB_ENTRY( "US", ENGLISH, ENGLISH_US )
435         LANG_SUB_ENTRY( "UK", ENGLISH, ENGLISH_UK )
436         LANG_SUB_ENTRY( "AU", ENGLISH, ENGLISH_AUS )
437         LANG_SUB_ENTRY( "CA", ENGLISH, ENGLISH_CAN )
438         LANG_SUB_ENTRY( "NZ", ENGLISH, ENGLISH_NZ )
439         LANG_SUB_ENTRY( "EI", ENGLISH, ENGLISH_EIRE )
440         LANG_SUB_ENTRY( "ZA", ENGLISH, ENGLISH_SAFRICA )
441         LANG_SUB_ENTRY( "JM", ENGLISH, ENGLISH_JAMAICA )
442      /* LANG_SUB_ENTRY( "AG", ENGLISH, ENGLISH_CARIBBEAN ) */
443         LANG_SUB_ENTRY( "BZ", ENGLISH, ENGLISH_BELIZE )
444         LANG_SUB_ENTRY( "TT", ENGLISH, ENGLISH_TRINIDAD )
445         LANG_SUB_ENTRY( "ZW", ENGLISH, ENGLISH_ZIMBABWE )
446         LANG_SUB_ENTRY( "PH", ENGLISH, ENGLISH_PHILIPPINES )
447         LANG_ENTRY_END( ENGLISH )
448 /*x0a*/ LANG_ENTRY_BEGIN( "es", SPANISH )
449         /* traditional sorting */
450         if (!strcmp(dialect,"tradicional"))
451                 LANG_DIALECT_ENTRY( SPANISH, SPANISH )
452         LANG_SUB_ENTRY( "MX", SPANISH, SPANISH_MEXICAN )
453         LANG_SUB_ENTRY( "ES", SPANISH, SPANISH_MODERN )
454         LANG_SUB_ENTRY( "GT", SPANISH, SPANISH_GUATEMALA )
455         LANG_SUB_ENTRY( "CR", SPANISH, SPANISH_COSTARICA )
456         LANG_SUB_ENTRY( "PA", SPANISH, SPANISH_PANAMA )
457         LANG_SUB_ENTRY( "DO", SPANISH, SPANISH_DOMINICAN )
458         LANG_SUB_ENTRY( "VE", SPANISH, SPANISH_VENEZUELA )
459         LANG_SUB_ENTRY( "CO", SPANISH, SPANISH_COLOMBIA )
460         LANG_SUB_ENTRY( "PE", SPANISH, SPANISH_PERU )
461         LANG_SUB_ENTRY( "AR", SPANISH, SPANISH_ARGENTINA )
462         LANG_SUB_ENTRY( "EC", SPANISH, SPANISH_ECUADOR )
463         LANG_SUB_ENTRY( "CL", SPANISH, SPANISH_CHILE )
464         LANG_SUB_ENTRY( "UY", SPANISH, SPANISH_URUGUAY )
465         LANG_SUB_ENTRY( "PY", SPANISH, SPANISH_PARAGUAY )
466         LANG_SUB_ENTRY( "BO", SPANISH, SPANISH_BOLIVIA )
467         LANG_SUB_ENTRY( "HN", SPANISH, SPANISH_HONDURAS )
468         LANG_SUB_ENTRY( "NI", SPANISH, SPANISH_NICARAGUA )
469         LANG_SUB_ENTRY( "PR", SPANISH, SPANISH_PUERTO_RICO )
470         LANG_ENTRY_END( SPANISH )
471 /*x0b*/ LANG_ENTRY_BEGIN( "fi", FINNISH )
472         LANG_ENTRY_END( FINNISH )
473 /*x0c*/ LANG_ENTRY_BEGIN( "fr", FRENCH )
474         LANG_SUB_ENTRY( "FR", FRENCH, FRENCH )
475         LANG_SUB_ENTRY( "BE", FRENCH, FRENCH_BELGIAN )
476         LANG_SUB_ENTRY( "CA", FRENCH, FRENCH_CANADIAN )
477         LANG_SUB_ENTRY( "CH", FRENCH, FRENCH_SWISS )
478         LANG_SUB_ENTRY( "LU", FRENCH, FRENCH_LUXEMBOURG )
479         LANG_SUB_ENTRY( "MC", FRENCH, FRENCH_MONACO )
480         LANG_ENTRY_END( FRENCH )
481 /*x0d*/ LANG_ENTRY_BEGIN( "iw", HEBREW )
482         LANG_ENTRY_END( HEBREW )
483 /*x0e*/ LANG_ENTRY_BEGIN( "hu", HUNGARIAN )
484         LANG_ENTRY_END( HUNGARIAN )
485 /*x0f*/ LANG_ENTRY_BEGIN( "ic", ICELANDIC )
486         LANG_ENTRY_END( ICELANDIC )
487 /*x10*/ LANG_ENTRY_BEGIN( "it", ITALIAN )
488         LANG_SUB_ENTRY( "IT", ITALIAN, ITALIAN )
489         LANG_SUB_ENTRY( "CH", ITALIAN, ITALIAN_SWISS )
490         LANG_ENTRY_END( ITALIAN )
491 /*x11*/ LANG_ENTRY_BEGIN( "ja", JAPANESE )
492         LANG_ENTRY_END( JAPANESE )
493 /*x12*/ LANG_ENTRY_BEGIN( "ko", KOREAN )
494         /* JOHAB encoding */
495         if (!strcmp(charset,"JOHAB"))
496                 LANG_DIALECT_ENTRY( KOREAN, KOREAN_JOHAB )
497         else
498                 LANG_DIALECT_ENTRY( KOREAN, KOREAN )
499         LANG_ENTRY_END( KOREAN )
500 /*x13*/ LANG_ENTRY_BEGIN( "nl", DUTCH )
501         LANG_SUB_ENTRY( "NL", DUTCH, DUTCH )
502         LANG_SUB_ENTRY( "BE", DUTCH, DUTCH_BELGIAN )
503         LANG_SUB_ENTRY( "SR", DUTCH, DUTCH_SURINAM )
504         LANG_ENTRY_END( DUTCH )
505 /*x14*/ LANG_ENTRY_BEGIN( "no", NORWEGIAN )
506         /* nynorsk */
507         if (!strcmp(dialect,"nynorsk"))
508                 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_NYNORSK )
509         else
510                 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_BOKMAL )
511         LANG_ENTRY_END( NORWEGIAN )
512 /*x15*/ LANG_ENTRY_BEGIN( "pl", POLISH )
513         LANG_ENTRY_END( POLISH )
514 /*x16*/ LANG_ENTRY_BEGIN( "pt", PORTUGUESE )
515         LANG_SUB_ENTRY( "BR", PORTUGUESE, PORTUGUESE_BRAZILIAN )
516         LANG_SUB_ENTRY( "PT", PORTUGUESE, PORTUGUESE )
517         LANG_ENTRY_END( PORTUGUESE )
518 /*x17*/ LANG_ENTRY_BEGIN( "rm", RHAETO_ROMANCE )
519         LANG_ENTRY_END( RHAETO_ROMANCE )
520 /*x18*/ LANG_ENTRY_BEGIN( "ro", ROMANIAN )
521         LANG_SUB_ENTRY( "RO", ROMANIAN, ROMANIAN )
522         LANG_SUB_ENTRY( "MD", ROMANIAN, ROMANIAN_MOLDAVIA )
523         LANG_ENTRY_END( ROMANIAN )
524 /*x19*/ LANG_ENTRY_BEGIN( "ru", RUSSIAN )
525         LANG_SUB_ENTRY( "RU", RUSSIAN, RUSSIAN )
526         LANG_SUB_ENTRY( "MD", RUSSIAN, RUSSIAN_MOLDAVIA )
527         LANG_ENTRY_END( RUSSIAN )
528 /*x1a*/ if (!strcmp(lang,"sh") || !strcmp(lang,"hr") || !strcmp(lang,"sr")) {
529             if (!country[0]) 
530                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, NEUTRAL)
531             if (!strcmp(charset,"ISO-8859-5"))
532                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN )
533             LANG_SUB_ENTRY( "HR", SERBO_CROATIAN, CROATIAN )
534             if (!strcmp(country,"YU") && !strcmp(charset,"ISO-8859-2"))
535                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
536             LANG_SUB_ENTRY( "YU", SERBO_CROATIAN, SERBIAN )
537             LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
538         }
539 /*x1b*/ LANG_ENTRY_BEGIN( "sk", SLOVAK )
540         LANG_ENTRY_END( SLOVAK )
541 /*x1c*/ LANG_ENTRY_BEGIN( "sq", ALBANIAN )
542         LANG_ENTRY_END( ALBANIAN )
543 /*x1d*/ LANG_ENTRY_BEGIN( "sv", SWEDISH )
544         LANG_SUB_ENTRY( "SE", SWEDISH, SWEDISH )
545         LANG_SUB_ENTRY( "FI", SWEDISH, SWEDISH_FINLAND )
546         LANG_ENTRY_END( SWEDISH )
547 /*x1e*/ LANG_ENTRY_BEGIN( "th", THAI )
548         LANG_ENTRY_END( THAI )
549 /*x1f*/ LANG_ENTRY_BEGIN( "tr", TURKISH )
550         LANG_ENTRY_END( TURKISH )
551 /*x20*/ LANG_ENTRY_BEGIN( "ur", URDU )
552         LANG_ENTRY_END( URDU )
553 /*x21*/ LANG_ENTRY_BEGIN( "in", INDONESIAN )
554         LANG_ENTRY_END( INDONESIAN )
555 /*x22*/ LANG_ENTRY_BEGIN( "uk", UKRAINIAN )
556         LANG_ENTRY_END( UKRAINIAN )
557 /*x23*/ LANG_ENTRY_BEGIN( "be", BYELORUSSIAN )
558         LANG_ENTRY_END( BYELORUSSIAN )
559 /*x24*/ LANG_ENTRY_BEGIN( "sl", SLOVENIAN )
560         LANG_ENTRY_END( SLOVENIAN )
561 /*x25*/ LANG_ENTRY_BEGIN( "et", ESTONIAN )
562         LANG_ENTRY_END( ESTONIAN )
563 /*x26*/ LANG_ENTRY_BEGIN( "lv", LATVIAN )
564         LANG_ENTRY_END( LATVIAN )
565 /*x27*/ LANG_ENTRY_BEGIN( "lt", LITHUANIAN )
566         /* traditional sorting ? */
567         if (!strcmp(dialect,"classic") || !strcmp(dialect,"traditional"))
568                 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN_CLASSIC )
569         else
570                 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN )
571         LANG_ENTRY_END( LITHUANIAN )
572 /*x28*/ LANG_ENTRY_BEGIN( "mi", MAORI )
573         LANG_ENTRY_END( MAORI )
574 /*x29*/ LANG_ENTRY_BEGIN( "fa", FARSI )
575         LANG_ENTRY_END( FARSI )
576 /*x2a*/ LANG_ENTRY_BEGIN( "vi", VIETNAMESE )
577         LANG_ENTRY_END( VIETNAMESE )
578 /*x2b*/ LANG_ENTRY_BEGIN( "hy", ARMENIAN )
579         LANG_ENTRY_END( ARMENIAN )
580 /*x2c*/ LANG_ENTRY_BEGIN( "az", AZERI )
581         /* Cyrillic */
582         if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
583                 LANG_DIALECT_ENTRY( AZERI, AZERI_CYRILLIC )
584         else
585                 LANG_DIALECT_ENTRY( AZERI, AZERI )
586         LANG_ENTRY_END( AZERI )
587 /*x2d*/ LANG_ENTRY_BEGIN( "eu", BASQUE )
588         LANG_ENTRY_END( BASQUE )
589 /*x2e*/ /*LANG_ENTRY_BEGIN( "??", SORBIAN )
590         LANG_ENTRY_END( SORBIAN ) */
591 /*x2f*/ LANG_ENTRY_BEGIN( "mk", MACEDONIAN )
592         LANG_ENTRY_END( MACEDONIAN )
593 /*x30*/ /*LANG_ENTRY_BEGIN( "??", SUTU )
594         LANG_ENTRY_END( SUTU ) */
595 /*x31*/ LANG_ENTRY_BEGIN( "ts", TSONGA )
596         LANG_ENTRY_END( TSONGA )
597 /*x32*/ /*LANG_ENTRY_BEGIN( "??", TSWANA )
598         LANG_ENTRY_END( TSWANA ) */
599 /*x33*/ /*LANG_ENTRY_BEGIN( "??", VENDA )
600         LANG_ENTRY_END( VENDA ) */
601 /*x34*/ LANG_ENTRY_BEGIN( "xh", XHOSA )
602         LANG_ENTRY_END( XHOSA )
603 /*x35*/ LANG_ENTRY_BEGIN( "zu", ZULU )
604         LANG_ENTRY_END( ZULU )
605 /*x36*/ LANG_ENTRY_BEGIN( "af", AFRIKAANS )
606         LANG_ENTRY_END( AFRIKAANS )
607 /*x37*/ LANG_ENTRY_BEGIN( "ka", GEORGIAN )
608         LANG_ENTRY_END( GEORGIAN )
609 /*x38*/ LANG_ENTRY_BEGIN( "fo", FAEROESE )
610         LANG_ENTRY_END( FAEROESE )
611 /*x39*/ LANG_ENTRY_BEGIN( "hi", HINDI )
612         LANG_ENTRY_END( HINDI )
613 /*x3a*/ LANG_ENTRY_BEGIN( "mt", MALTESE )
614         LANG_ENTRY_END( MALTESE )
615 /*x3b*/ /*LANG_ENTRY_BEGIN( "??", SAAMI )
616         LANG_ENTRY_END( SAAMI ) */
617 /*x3c*/ LANG_ENTRY_BEGIN( "ga", GAELIC )
618         LANG_DIALECT_ENTRY( GAELIC, GAELIC )
619         LANG_ENTRY_END( GAELIC )
620 /*x3c*/ LANG_ENTRY_BEGIN( "gd", GAELIC )
621         LANG_DIALECT_ENTRY( GAELIC, GAELIC_SCOTTISH )
622         LANG_ENTRY_END( GAELIC )
623 // 0x3d
624 /*x3e*/ LANG_ENTRY_BEGIN( "ms", MALAY )
625         LANG_SUB_ENTRY( "MY", MALAY, MALAY )
626         LANG_SUB_ENTRY( "BN", MALAY, MALAY_BRUNEI_DARUSSALAM )
627         LANG_ENTRY_END( MALAY )
628 /*x3f*/ LANG_ENTRY_BEGIN( "kk", KAZAKH )
629         LANG_ENTRY_END( KAZAKH )
630 // 0x40
631 /*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI )
632         LANG_ENTRY_END( SWAHILI )
633 // 0x42
634 /*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK )
635         /* Cyrillic */
636         if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
637                 LANG_DIALECT_ENTRY( UZBEK, UZBEK_CYRILLIC )
638         else
639                 LANG_DIALECT_ENTRY( UZBEK, UZBEK )
640         LANG_ENTRY_END( UZBEK )
641 /*x44*/ LANG_ENTRY_BEGIN( "tt", TATAR )
642         LANG_ENTRY_END( TATAR )
643 /*x45*/ LANG_ENTRY_BEGIN( "bn", BENGALI )
644         LANG_ENTRY_END( BENGALI )
645 /*x46*/ LANG_ENTRY_BEGIN( "pa", PUNJABI )
646         LANG_ENTRY_END( PUNJABI )
647 /*x47*/ LANG_ENTRY_BEGIN( "gu", GUJARATI )
648         LANG_ENTRY_END( GUJARATI )
649 /*x48*/ LANG_ENTRY_BEGIN( "or", ORIYA )
650         LANG_ENTRY_END( ORIYA )
651 /*x49*/ LANG_ENTRY_BEGIN( "ta", TAMIL )
652         LANG_ENTRY_END( TAMIL )
653 /*x4a*/ LANG_ENTRY_BEGIN( "te", TELUGU )
654         LANG_ENTRY_END( TELUGU )
655 /*x4b*/ LANG_ENTRY_BEGIN( "kn", KANNADA )
656         LANG_ENTRY_END( KANNADA )
657 /*x4c*/ LANG_ENTRY_BEGIN( "ml", MALAYALAM )
658         LANG_ENTRY_END( MALAYALAM )
659 /*x4d*/ LANG_ENTRY_BEGIN( "as", ASSAMESE )
660         LANG_ENTRY_END( ASSAMESE )
661 /*x4e*/ LANG_ENTRY_BEGIN( "mr", MARATHI )
662         LANG_ENTRY_END( MARATHI )
663 /*x4f*/ LANG_ENTRY_BEGIN( "sa", SANSKRIT )
664         LANG_ENTRY_END( SANSKRIT )
665 // 0x50 -> 0x56
666 /*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
667         LANG_ENTRY_END( KONKANI ) */
668 // 0x58 -> ...
669         LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */
670         LANG_ENTRY_END( ESPERANTO )
671
672         ret = LANG_ENGLISH;
673
674 end_MAIN_GetLanguageID:
675         if (Charset) free(charset);
676         if (Dialect) free(dialect);
677
678         return ret;
679 }
680
681 /***********************************************************************
682  *           MAIN_ParseLanguageOption
683  *
684  * Parse -language option.
685  */
686 static void MAIN_ParseLanguageOption( char *arg )
687 {
688     const WINE_LANGUAGE_DEF *p = Languages;
689
690     Options.language = LANG_En;  /* First language */
691     for (;p->name;p++)
692     {
693         if (!lstrcmpi32A( p->name, arg ))
694         {
695             WINE_LanguageId = p->langid;
696             return;
697         }
698         Options.language++;
699     }
700     MSG( "Invalid language specified '%s'. Supported languages are: ", arg );
701     for (p = Languages; p->name; p++) MSG( "%s ", p->name );
702     MSG( "\n" );
703     exit(1);
704 }
705
706
707 /***********************************************************************
708  *           MAIN_ParseModeOption
709  *
710  * Parse -mode option.
711  */
712 static void MAIN_ParseModeOption( char *arg )
713 {
714     if (!lstrcmpi32A("enhanced", arg)) Options.mode = MODE_ENHANCED;
715     else if (!lstrcmpi32A("standard", arg)) Options.mode = MODE_STANDARD;
716     else
717     {
718         MSG( "Invalid mode '%s' specified.\n", arg);
719         MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
720         exit(1);
721     }
722 }
723
724 /***********************************************************************
725  *           MAIN_ParseOptions
726  *
727  * Parse command line options and open display.
728  */
729 static void MAIN_ParseOptions( int *argc, char *argv[] )
730 {
731     char *display_name = NULL;
732     XrmValue value;
733     XrmDatabase db = TSXrmGetFileDatabase(WINE_APP_DEFAULTS);
734     int i;
735     char *xrm_string;
736
737     Options.programName = MAIN_GetProgramName( *argc, argv );
738     Options.argv0 = argv[0];
739
740     /* initialise Options.language to 0 to tell "no language choosen yet" */
741     Options.language = 0;
742   
743       /* Get display name from command line */
744     for (i = 1; i < *argc; i++)
745     {
746         if (!strcmp( argv[i], "-display" )) display_name = argv[i+1];
747         if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
748         {
749             MSG( "%s\n", WINE_RELEASE_INFO );
750             exit(0);
751         }
752         if (!strcmp( argv[i], "-h" ) || !strcmp( argv[i], "-help" ))
753         {
754             MAIN_Usage(argv[0]);
755             exit(0);
756         }
757     }
758
759       /* Open display */
760
761     if (display_name == NULL &&
762         MAIN_GetResource( db, ".display", &value )) display_name = value.addr;
763
764     if (!(display = TSXOpenDisplay( display_name )))
765     {
766         MSG( "%s: Can't open display: %s\n",
767                  argv[0], display_name ? display_name : "(none specified)" );
768         exit(1);
769     }
770
771     /* tell the libX11 that we will do input method handling ourselves
772      * that keep libX11 from doing anything whith dead keys, allowing Wine
773      * to have total control over dead keys, that is this line allows
774      * them to work in Wine, even whith a libX11 including the dead key
775      * patches from Th.Quinot (http://Web.FdN.FR/~tquinot/dead-keys.en.html)
776      */
777     TSXOpenIM(display,NULL,NULL,NULL);
778
779       /* Merge file and screen databases */
780     if ((xrm_string = TSXResourceManagerString( display )) != NULL)
781     {
782         XrmDatabase display_db = TSXrmGetStringDatabase( xrm_string );
783         TSXrmMergeDatabases( display_db, &db );
784     }
785
786       /* Parse command line */
787     TSXrmParseCommand( &db, optionsTable, NB_OPTIONS,
788                      Options.programName, argc, argv );
789
790       /* Get all options */
791     if (MAIN_GetResource( db, ".iconic", &value ))
792         Options.cmdShow = SW_SHOWMINIMIZED;
793     if (MAIN_GetResource( db, ".privatemap", &value ))
794         Options.usePrivateMap = TRUE;
795     if (MAIN_GetResource( db, ".fixedmap", &value ))
796         Options.useFixedMap = TRUE;
797     if (MAIN_GetResource( db, ".synchronous", &value ))
798         Options.synchronous = TRUE;
799     if (MAIN_GetResource( db, ".backingstore", &value ))
800         Options.backingstore = TRUE;    
801     if (MAIN_GetResource( db, ".debug", &value ))
802         Options.debug = TRUE;
803     if (MAIN_GetResource( db, ".failreadonly", &value ))
804         Options.failReadOnly = TRUE;
805     if (MAIN_GetResource( db, ".perfect", &value ))
806         Options.perfectGraphics = TRUE;
807     if (MAIN_GetResource( db, ".depth", &value))
808         screenDepth = atoi( value.addr );
809     if (MAIN_GetResource( db, ".desktop", &value))
810         Options.desktopGeometry = value.addr;
811     if (MAIN_GetResource( db, ".language", &value))
812         MAIN_ParseLanguageOption( (char *)value.addr );
813     if (MAIN_GetResource( db, ".managed", &value))
814         Options.managed = TRUE;
815     if (MAIN_GetResource( db, ".mode", &value))
816         MAIN_ParseModeOption( (char *)value.addr );
817     if (MAIN_GetResource( db, ".debugoptions", &value))
818         MAIN_ParseDebugOptions((char*)value.addr);
819     if (MAIN_GetResource( db, ".debugmsg", &value))
820       {
821 #ifndef DEBUG_RUNTIME
822         MSG("%s: Option \"-debugmsg\" not implemented.\n" \
823           "    Recompile with DEBUG_RUNTIME in include/debugtools.h defined.\n",
824           argv[0]);
825         exit(1);
826 #else
827         if (MAIN_ParseDebugOptions((char*)value.addr)==FALSE)
828           {
829             int i;
830             MSG("%s: Syntax: -debugmsg [class]+xxx,...  or "
831                     "-debugmsg [class]-xxx,...\n",argv[0]);
832             MSG("Example: -debugmsg +all,warn-heap\n"
833                     "  turn on all messages except warning heap messages\n");
834             MSG("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
835                 "  turn on -debugmsg +relay only as specified\n"
836                 "Special case: -debugmsg -relay=DLL:DLL.###:FuncName\n"
837                 "  turn on -debugmsg +relay except as specified\n"
838                 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
839
840             MSG("Available message classes:\n");
841             for(i=0;i<DEBUG_CLASS_COUNT;i++)
842               MSG( "%-9s", debug_cl_name[i]);
843             MSG("\n\n");
844
845             MSG("Available message types:\n");
846             MSG("%-9s ","all");
847             for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
848               if(debug_ch_name[i])
849                 MSG("%-9s%c",debug_ch_name[i],
850                         (((i+2)%8==0)?'\n':' '));
851             MSG("\n\n");
852             exit(1);
853           }
854 #endif
855       }
856
857       if (MAIN_GetResource( db, ".dll", &value))
858       {
859           /* Hack: store option value in Options to be retrieved */
860           /* later on inside the emulator code. */
861           if (!__winelib) Options.dllFlags = xstrdup((char *)value.addr);
862           else
863           {
864               MSG("-dll not supported in Winelib\n" );
865               exit(1);
866           }
867       }
868
869       if (MAIN_GetResource( db, ".winver", &value))
870           VERSION_ParseVersion( (char*)value.addr );
871       if (MAIN_GetResource( db, ".config", &value))
872          Options.configFileName = xstrdup((char *)value.addr);
873 }
874
875
876 /***********************************************************************
877  *           MAIN_CreateDesktop
878  */
879 static void MAIN_CreateDesktop( int argc, char *argv[] )
880 {
881     int x, y, flags;
882     unsigned int width = 640, height = 480;  /* Default size = 640x480 */
883     char *name = "Wine desktop";
884     XSizeHints *size_hints;
885     XWMHints   *wm_hints;
886     XClassHint *class_hints;
887     XSetWindowAttributes win_attr;
888     XTextProperty window_name;
889     Atom XA_WM_DELETE_WINDOW;
890
891     flags = TSXParseGeometry( Options.desktopGeometry, &x, &y, &width, &height );
892     screenWidth  = width;
893     screenHeight = height;
894
895       /* Create window */
896
897     win_attr.background_pixel = BlackPixel(display,0);
898     win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
899                          PointerMotionMask | ButtonPressMask |
900                          ButtonReleaseMask | EnterWindowMask;
901     win_attr.cursor = TSXCreateFontCursor( display, XC_top_left_arrow );
902
903     rootWindow = TSXCreateWindow( display, DefaultRootWindow(display),
904                                 x, y, width, height, 0,
905                                 CopyFromParent, InputOutput, CopyFromParent,
906                                 CWBackPixel | CWEventMask | CWCursor, &win_attr );
907
908       /* Set window manager properties */
909
910     size_hints  = TSXAllocSizeHints();
911     wm_hints    = TSXAllocWMHints();
912     class_hints = TSXAllocClassHint();
913     if (!size_hints || !wm_hints || !class_hints)
914     {
915         MSG("Not enough memory for window manager hints.\n" );
916         exit(1);
917     }
918     size_hints->min_width = size_hints->max_width = width;
919     size_hints->min_height = size_hints->max_height = height;
920     size_hints->flags = PMinSize | PMaxSize;
921     if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
922     if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
923     else size_hints->flags |= PSize;
924
925     wm_hints->flags = InputHint | StateHint;
926     wm_hints->input = True;
927     wm_hints->initial_state = NormalState;
928     class_hints->res_name = argv[0];
929     class_hints->res_class = "Wine";
930
931     TSXStringListToTextProperty( &name, 1, &window_name );
932     TSXSetWMProperties( display, rootWindow, &window_name, &window_name,
933                       argv, argc, size_hints, wm_hints, class_hints );
934     XA_WM_DELETE_WINDOW = TSXInternAtom( display, "WM_DELETE_WINDOW", False );
935     TSXSetWMProtocols( display, rootWindow, &XA_WM_DELETE_WINDOW, 1 );
936     TSXFree( size_hints );
937     TSXFree( wm_hints );
938     TSXFree( class_hints );
939
940       /* Map window */
941
942     TSXMapWindow( display, rootWindow );
943 }
944
945
946 XKeyboardState keyboard_state;
947
948 /***********************************************************************
949  *           MAIN_SaveSetup
950  */
951 static void MAIN_SaveSetup(void)
952 {
953     TSXGetKeyboardControl(display, &keyboard_state);
954 }
955
956 /***********************************************************************
957  *           MAIN_RestoreSetup
958  */
959 static void MAIN_RestoreSetup(void)
960 {
961     XKeyboardControl keyboard_value;
962
963     keyboard_value.key_click_percent    = keyboard_state.key_click_percent;
964     keyboard_value.bell_percent         = keyboard_state.bell_percent;
965     keyboard_value.bell_pitch           = keyboard_state.bell_pitch;
966     keyboard_value.bell_duration        = keyboard_state.bell_duration;
967     keyboard_value.auto_repeat_mode     = keyboard_state.global_auto_repeat;
968
969     XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent | 
970         KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value);
971 }
972
973
974 /***********************************************************************
975  *           called_at_exit
976  */
977 static void called_at_exit(void)
978 {
979     MAIN_RestoreSetup();
980     COLOR_Cleanup();
981     WINSOCK_Shutdown();
982     /* FIXME: should check for other processes or threads */
983     DeleteCriticalSection( HEAP_SystemLock );
984 }
985
986 static int WINE_X11_ErrorHandler(Display *display,XErrorEvent *error_evt)
987 {
988     kill( getpid(), SIGHUP ); /* force an entry in the debugger */
989     return 0;
990 }
991
992 /***********************************************************************
993  *           MAIN_WineInit
994  *
995  * Wine initialisation and command-line parsing
996  */
997 BOOL32 MAIN_WineInit( int *argc, char *argv[] )
998 {    
999     int depth_count, i;
1000     int *depth_list;
1001     struct timeval tv;
1002
1003 #ifdef MALLOC_DEBUGGING
1004     char *trace;
1005
1006     mcheck(NULL);
1007     if (!(trace = getenv("MALLOC_TRACE")))
1008     {       
1009         MSG( "MALLOC_TRACE not set. No trace generated\n" );
1010     }
1011     else
1012     {
1013         MSG( "malloc trace goes to %s\n", trace );
1014         mtrace();
1015     }
1016 #endif
1017
1018     setbuf(stdout,NULL);
1019     setbuf(stderr,NULL);
1020
1021     setlocale(LC_CTYPE,"");
1022     gettimeofday( &tv, NULL);
1023     MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
1024
1025     /* We need this before calling any Xlib function */
1026     InitializeCriticalSection( &X11DRV_CritSection );
1027
1028     TSXrmInitialize();
1029
1030     putenv("XKB_DISABLE="); /* Disable XKB extension if present. */
1031
1032     MAIN_ParseOptions( argc, argv );
1033
1034     if (Options.synchronous) XSetErrorHandler( WINE_X11_ErrorHandler );
1035
1036     if (Options.desktopGeometry && Options.managed)
1037     {
1038 #if 0
1039         MSG( "%s: -managed and -desktop options cannot be used together\n",
1040                  Options.programName );
1041         exit(1);
1042 #else
1043         Options.managed = FALSE;
1044 #endif
1045     }
1046
1047     screen       = DefaultScreenOfDisplay( display );
1048     screenWidth  = WidthOfScreen( screen );
1049     screenHeight = HeightOfScreen( screen );
1050     if (screenDepth)  /* -depth option specified */
1051     {
1052         depth_list = TSXListDepths(display,DefaultScreen(display),&depth_count);
1053         for (i = 0; i < depth_count; i++)
1054             if (depth_list[i] == screenDepth) break;
1055         TSXFree( depth_list );
1056         if (i >= depth_count)
1057         {
1058             MSG( "%s: Depth %d not supported on this screen.\n",
1059                               Options.programName, screenDepth );
1060             exit(1);
1061         }
1062     }
1063     else screenDepth  = DefaultDepthOfScreen( screen );
1064     if (Options.synchronous) TSXSynchronize( display, True );
1065     if (Options.desktopGeometry) MAIN_CreateDesktop( *argc, argv );
1066     else rootWindow = DefaultRootWindow( display );
1067
1068     MAIN_SaveSetup();
1069     atexit(called_at_exit);
1070     return TRUE;
1071 }
1072
1073
1074 /***********************************************************************
1075  *           MessageBeep16   (USER.104)
1076  */
1077 void WINAPI MessageBeep16( UINT16 i )
1078 {
1079     MessageBeep32( i );
1080 }
1081
1082
1083 /***********************************************************************
1084  *           MessageBeep32   (USER32.390)
1085  */
1086 BOOL32 WINAPI MessageBeep32( UINT32 i )
1087 {
1088     TSXBell( display, 0 );
1089     return TRUE;
1090 }
1091
1092
1093 /***********************************************************************
1094  *           Beep   (KERNEL32.11)
1095  */
1096 BOOL32 WINAPI Beep( DWORD dwFreq, DWORD dwDur )
1097 {
1098     /* dwFreq and dwDur are ignored by Win95 */
1099     TSXBell(display, 0);
1100     return TRUE;
1101 }
1102
1103
1104 /***********************************************************************
1105  *      GetTimerResolution (USER.14)
1106  */
1107 LONG WINAPI GetTimerResolution(void)
1108 {
1109         return (1000);
1110 }
1111
1112 /***********************************************************************
1113  *      SystemParametersInfo32A   (USER32.540)
1114  */
1115 BOOL32 WINAPI SystemParametersInfo32A( UINT32 uAction, UINT32 uParam,
1116                                        LPVOID lpvParam, UINT32 fuWinIni )
1117 {
1118         int timeout, temp;
1119         XKeyboardState          keyboard_state;
1120
1121         switch (uAction) {
1122         case SPI_GETBEEP:
1123                 TSXGetKeyboardControl(display, &keyboard_state);
1124                 if (keyboard_state.bell_percent == 0)
1125                         *(BOOL32 *) lpvParam = FALSE;
1126                 else
1127                         *(BOOL32 *) lpvParam = TRUE;
1128                 break;
1129
1130         case SPI_GETBORDER:
1131                 *(INT32 *)lpvParam = GetSystemMetrics32( SM_CXFRAME );
1132                 break;
1133
1134         case SPI_GETFASTTASKSWITCH:
1135                 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
1136                         *(BOOL32 *) lpvParam = TRUE;
1137                 else
1138                         *(BOOL32 *) lpvParam = FALSE;
1139                 break;
1140
1141         case SPI_GETDRAGFULLWINDOWS:
1142           *(BOOL32 *) lpvParam = FALSE;
1143                 
1144         case SPI_GETGRIDGRANULARITY:
1145                 *(INT32*)lpvParam=GetProfileInt32A("desktop","GridGranularity",1);
1146                 break;
1147
1148         case SPI_GETICONTITLEWRAP:
1149                 *(BOOL32*)lpvParam=GetProfileInt32A("desktop","IconTitleWrap",TRUE);
1150                 break;
1151
1152         case SPI_GETKEYBOARDDELAY:
1153                 *(INT32*)lpvParam=GetProfileInt32A("keyboard","KeyboardDelay",1);
1154                 break;
1155
1156         case SPI_GETKEYBOARDSPEED:
1157                 *(DWORD*)lpvParam=GetProfileInt32A("keyboard","KeyboardSpeed",30);
1158                 break;
1159
1160         case SPI_GETMENUDROPALIGNMENT:
1161                 *(BOOL32*)lpvParam=GetSystemMetrics32(SM_MENUDROPALIGNMENT); /* XXX check this */
1162                 break;
1163
1164         case SPI_GETSCREENSAVEACTIVE:
1165                 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
1166                         *(BOOL32*)lpvParam = TRUE;
1167                 else
1168                         *(BOOL32*)lpvParam = FALSE;
1169                 break;
1170
1171         case SPI_GETSCREENSAVETIMEOUT:
1172         /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
1173                 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
1174                 *(INT32 *) lpvParam = timeout * 1000;
1175                 break;
1176
1177         case SPI_ICONHORIZONTALSPACING:
1178                 /* FIXME Get/SetProfileInt */
1179                 if (lpvParam == NULL)
1180                         /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1181                 else
1182                         *(INT32*)lpvParam=GetSystemMetrics32(SM_CXICONSPACING);
1183                 break;
1184
1185         case SPI_ICONVERTICALSPACING:
1186                 /* FIXME Get/SetProfileInt */
1187                 if (lpvParam == NULL)
1188                         /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1189                 else
1190                         *(INT32*)lpvParam=GetSystemMetrics32(SM_CYICONSPACING);
1191                 break;
1192
1193         case SPI_GETICONTITLELOGFONT: {
1194                 LPLOGFONT32A lpLogFont = (LPLOGFONT32A)lpvParam;
1195
1196                 /* from now on we always have an alias for MS Sans Serif */
1197
1198                 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif", 
1199                         lpLogFont->lfFaceName, LF_FACESIZE );
1200                 lpLogFont->lfHeight = -GetProfileInt32A("Desktop","IconTitleSize", 8);
1201                 lpLogFont->lfWidth = 0;
1202                 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1203                 lpLogFont->lfWeight = FW_NORMAL;
1204                 lpLogFont->lfItalic = FALSE;
1205                 lpLogFont->lfStrikeOut = FALSE;
1206                 lpLogFont->lfUnderline = FALSE;
1207                 lpLogFont->lfCharSet = ANSI_CHARSET;
1208                 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1209                 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1210                 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1211                 break;
1212         }
1213         case SPI_GETWORKAREA:
1214                 SetRect32( (RECT32 *)lpvParam, 0, 0,
1215                         GetSystemMetrics32( SM_CXSCREEN ),
1216                         GetSystemMetrics32( SM_CYSCREEN )
1217                 );
1218                 break;
1219         case SPI_GETNONCLIENTMETRICS: 
1220
1221 #define lpnm ((LPNONCLIENTMETRICS32A)lpvParam)
1222                 
1223                 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS32A) )
1224                 {
1225                     /* FIXME: initialize geometry entries */
1226
1227                     SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
1228                                                         (LPVOID)&(lpnm->lfCaptionFont),0);
1229                     lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1230                     SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
1231                                                         (LPVOID)&(lpnm->lfSmCaptionFont),0);
1232                     SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
1233                                                         (LPVOID)&(lpnm->lfMenuFont),0);
1234                     SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
1235                                                         (LPVOID)&(lpnm->lfStatusFont),0);
1236                     SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
1237                                                         (LPVOID)&(lpnm->lfMessageFont),0);
1238                 }
1239 #undef lpnm
1240                 break;
1241
1242         case SPI_GETANIMATION: {
1243                 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1244  
1245                 /* Tell it "disabled" */
1246                 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1247                 uParam = sizeof(ANIMATIONINFO);
1248                 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
1249                 break;
1250         }
1251  
1252         case SPI_SETANIMATION: {
1253                 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1254  
1255                 /* Do nothing */
1256                 WARN(system, "SPI_SETANIMATION ignored.\n");
1257                 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1258                 uParam = sizeof(ANIMATIONINFO);
1259                 break;
1260         }
1261
1262         case SPI_GETHIGHCONTRAST:
1263         {
1264                 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
1265
1266                 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1267
1268                 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
1269                 {
1270                         /* Indicate that there is no high contrast available */
1271                         lpHighContrastA->dwFlags = 0;
1272                         lpHighContrastA->lpszDefaultScheme = NULL;
1273                 }
1274                 else
1275                 {
1276                         return FALSE;
1277                 }
1278
1279                 break;
1280         }
1281
1282         default:
1283                 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
1284         }
1285         return TRUE;
1286 }
1287
1288
1289 /***********************************************************************
1290  *      SystemParametersInfo16   (USER.483)
1291  */
1292 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
1293                                       LPVOID lpvParam, UINT16 fuWinIni )
1294 {
1295         int timeout, temp;
1296         char buffer[256];
1297         XKeyboardState          keyboard_state;
1298         XKeyboardControl        keyboard_value;
1299
1300
1301         switch (uAction)
1302         {
1303                 case SPI_GETBEEP:
1304                         TSXGetKeyboardControl(display, &keyboard_state);
1305                         if (keyboard_state.bell_percent == 0)
1306                                 *(BOOL16 *) lpvParam = FALSE;
1307                         else
1308                                 *(BOOL16 *) lpvParam = TRUE;
1309                         break;
1310                 
1311                 case SPI_GETBORDER:
1312                         *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME );
1313                         break;
1314
1315                 case SPI_GETFASTTASKSWITCH:
1316                     if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
1317                           *(BOOL16 *) lpvParam = TRUE;
1318                         else
1319                           *(BOOL16 *) lpvParam = FALSE;
1320                         break;
1321
1322                 case SPI_GETGRIDGRANULARITY:
1323                     *(INT16 *) lpvParam = GetProfileInt32A( "desktop", 
1324                                                           "GridGranularity",
1325                                                           1 );
1326                     break;
1327
1328                 case SPI_GETICONTITLEWRAP:
1329                     *(BOOL16 *) lpvParam = GetProfileInt32A( "desktop",
1330                                                            "IconTitleWrap",
1331                                                            TRUE );
1332                     break;
1333
1334                 case SPI_GETKEYBOARDDELAY:
1335                     *(INT16 *) lpvParam = GetProfileInt32A( "keyboard",
1336                                                           "KeyboardDelay", 1 );
1337                     break;
1338
1339                 case SPI_GETKEYBOARDSPEED:
1340                     *(WORD *) lpvParam = GetProfileInt32A( "keyboard",
1341                                                            "KeyboardSpeed",
1342                                                            30 );
1343                     break;
1344
1345                 case SPI_GETMENUDROPALIGNMENT:
1346                         *(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */
1347                         break;
1348
1349                 case SPI_GETSCREENSAVEACTIVE:
1350                     if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
1351                         *(BOOL16 *) lpvParam = TRUE;
1352                     else
1353                         *(BOOL16 *) lpvParam = FALSE;
1354                     break;
1355
1356                 case SPI_GETSCREENSAVETIMEOUT:
1357                         /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
1358                         TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
1359                         *(INT16 *) lpvParam = timeout;
1360                         break;
1361
1362                 case SPI_ICONHORIZONTALSPACING:
1363                     /* FIXME Get/SetProfileInt */
1364                         if (lpvParam == NULL)
1365                             /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1366                         else
1367                             *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING );
1368                         break;
1369
1370                 case SPI_ICONVERTICALSPACING:
1371                     /* FIXME Get/SetProfileInt */
1372                     if (lpvParam == NULL)
1373                         /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1374                     else
1375                         *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING);
1376                     break;
1377
1378                 case SPI_SETBEEP:
1379                         if (uParam == TRUE)
1380                                 keyboard_value.bell_percent = -1;
1381                         else
1382                                 keyboard_value.bell_percent = 0;                        
1383                         TSXChangeKeyboardControl(display, KBBellPercent, 
1384                                                         &keyboard_value);
1385                         break;
1386
1387                 case SPI_SETSCREENSAVEACTIVE:
1388                         if (uParam == TRUE)
1389                                 TSXActivateScreenSaver(display);
1390                         else
1391                                 TSXResetScreenSaver(display);
1392                         break;
1393
1394                 case SPI_SETSCREENSAVETIMEOUT:
1395                         TSXSetScreenSaver(display, uParam, 60, DefaultBlanking, 
1396                                                         DefaultExposures);
1397                         break;
1398
1399                 case SPI_SETDESKWALLPAPER:
1400                         return (SetDeskWallPaper32((LPSTR) lpvParam));
1401                         break;
1402
1403                 case SPI_SETDESKPATTERN:
1404                         if ((INT16)uParam == -1) {
1405                                 GetProfileString32A("Desktop", "Pattern", 
1406                                                 "170 85 170 85 170 85 170 85", 
1407                                                 buffer, sizeof(buffer) );
1408                                 return (DESKTOP_SetPattern((LPSTR) buffer));
1409                         } else
1410                                 return (DESKTOP_SetPattern((LPSTR) lpvParam));
1411                         break;
1412
1413                 case SPI_GETICONTITLELOGFONT: 
1414                 {
1415                     LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
1416
1417                     GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif", 
1418                                         lpLogFont->lfFaceName, LF_FACESIZE );
1419                     lpLogFont->lfHeight = -GetProfileInt32A("Desktop","IconTitleSize", 8);
1420                     lpLogFont->lfWidth = 0;
1421                     lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1422                     lpLogFont->lfWeight = FW_NORMAL;
1423                     lpLogFont->lfItalic = FALSE;
1424                     lpLogFont->lfStrikeOut = FALSE;
1425                     lpLogFont->lfUnderline = FALSE;
1426                     lpLogFont->lfCharSet = ANSI_CHARSET;
1427                     lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1428                     lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1429                     lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1430                     break;
1431                 }
1432                 case SPI_GETNONCLIENTMETRICS:
1433
1434 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
1435                     if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
1436                     {
1437                         /* FIXME: initialize geometry entries */
1438                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, 
1439                                                         (LPVOID)&(lpnm->lfCaptionFont),0);
1440                         lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1441                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1442                                                         (LPVOID)&(lpnm->lfSmCaptionFont),0);
1443                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1444                                                         (LPVOID)&(lpnm->lfMenuFont),0);
1445                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1446                                                         (LPVOID)&(lpnm->lfStatusFont),0);
1447                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1448                                                         (LPVOID)&(lpnm->lfMessageFont),0);
1449                     }
1450                     else /* winfile 95 sets sbSize to 340 */
1451                         SystemParametersInfo32A( uAction, uParam, lpvParam, fuWinIni );
1452 #undef lpnm
1453                     break;
1454
1455                 case SPI_LANGDRIVER:
1456                 case SPI_SETBORDER:
1457                 case SPI_SETDOUBLECLKHEIGHT:
1458                 case SPI_SETDOUBLECLICKTIME:
1459                 case SPI_SETDOUBLECLKWIDTH:
1460                 case SPI_SETFASTTASKSWITCH:
1461                 case SPI_SETKEYBOARDDELAY:
1462                 case SPI_SETKEYBOARDSPEED:
1463                         WARN(system, "Option %d ignored.\n", uAction);
1464                         break;
1465
1466                 case SPI_GETWORKAREA:
1467                     SetRect16( (RECT16 *)lpvParam, 0, 0,
1468                                GetSystemMetrics16( SM_CXSCREEN ),
1469                                GetSystemMetrics16( SM_CYSCREEN ) );
1470                     break;
1471
1472                 default:
1473                         WARN(system, "Unknown option %d.\n", uAction);
1474                         break;
1475         }
1476         return 1;
1477 }
1478
1479 /***********************************************************************
1480  *      SystemParametersInfo32W   (USER32.541)
1481  */
1482 BOOL32 WINAPI SystemParametersInfo32W( UINT32 uAction, UINT32 uParam,
1483                                        LPVOID lpvParam, UINT32 fuWinIni )
1484 {
1485     char buffer[256];
1486
1487     switch (uAction)
1488     {
1489     case SPI_SETDESKWALLPAPER:
1490         if (lpvParam)
1491         {
1492             lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1493             return SetDeskWallPaper32(buffer);
1494         }
1495         return SetDeskWallPaper32(NULL);
1496
1497     case SPI_SETDESKPATTERN:
1498         if ((INT32) uParam == -1)
1499         {
1500             GetProfileString32A("Desktop", "Pattern", 
1501                                 "170 85 170 85 170 85 170 85", 
1502                                 buffer, sizeof(buffer) );
1503             return (DESKTOP_SetPattern((LPSTR) buffer));
1504         }
1505         if (lpvParam)
1506         {
1507             lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1508             return DESKTOP_SetPattern(buffer);
1509         }
1510         return DESKTOP_SetPattern(NULL);
1511
1512     case SPI_GETICONTITLELOGFONT:
1513         {
1514             LPLOGFONT32W lpLogFont = (LPLOGFONT32W)lpvParam;
1515             GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif", 
1516                          buffer, sizeof(buffer) );
1517             lstrcpynAtoW(lpLogFont->lfFaceName, buffer ,LF_FACESIZE);
1518             lpLogFont->lfHeight = 10;
1519             lpLogFont->lfWidth = 0;
1520             lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1521             lpLogFont->lfWeight = FW_NORMAL;
1522             lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE;
1523             lpLogFont->lfCharSet = ANSI_CHARSET;
1524             lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1525             lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1526             lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1527         }
1528         break;
1529     case SPI_GETNONCLIENTMETRICS: {
1530         /* FIXME: implement correctly */
1531         LPNONCLIENTMETRICS32W   lpnm=(LPNONCLIENTMETRICS32W)lpvParam;
1532
1533         SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0);
1534         lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1535         SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfSmCaptionFont),0);
1536         SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0);
1537         SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0);
1538         SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0);
1539         break;
1540     }
1541
1542     case SPI_GETHIGHCONTRAST:
1543     {
1544        LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
1545
1546        FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1547
1548        if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
1549        {
1550           /* Indicate that there is no high contrast available */
1551           lpHighContrastW->dwFlags = 0;
1552           lpHighContrastW->lpszDefaultScheme = NULL;
1553        }
1554        else
1555        {
1556           return FALSE;
1557        }
1558
1559        break;
1560     }
1561
1562     default:
1563         return SystemParametersInfo32A(uAction,uParam,lpvParam,fuWinIni);
1564         
1565     }
1566     return TRUE;
1567 }
1568
1569
1570 /***********************************************************************
1571 *       FileCDR (KERNEL.130)
1572 */
1573 FARPROC16 WINAPI FileCDR(FARPROC16 x)
1574 {
1575         FIXME(file,"(0x%8x): stub\n", (int) x);
1576         return (FARPROC16)TRUE;
1577 }