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