Added walon language support (I also moved Cz -> Cs, Sw -> Sv, and Po
[wine] / misc / main.c
1 /*
2  * Main function.
3  *
4  * Copyright 1994 Alexandre Julliard
5  */
6
7 #include "config.h"
8
9 #ifndef X_DISPLAY_MISSING
10 #include "x11drv.h"
11 #else /* !defined(X_DISPLAY_MISSING) */
12 #include "ttydrv.h"
13 #endif /* !defined(X_DISPLAY_MISSING) */
14
15 #include <locale.h>
16 #include <ctype.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <unistd.h>
20 #ifdef MALLOC_DEBUGGING
21 # include <malloc.h>
22 #endif
23
24 #include "winbase.h"
25 #include "winsock.h"
26 #include "heap.h"
27 #include "message.h"
28 #include "msdos.h"
29 #include "color.h"
30 #include "options.h"
31 #include "desktop.h"
32 #include "builtin32.h"
33 #include "debug.h"
34 #include "debugdefs.h"
35 #include "xmalloc.h"
36 #include "module.h"
37 #include "version.h"
38 #include "winnls.h"
39 #include "console.h"
40 #include "monitor.h"
41 #include "keyboard.h"
42 #include "gdi.h"
43 #include "user.h"
44 #include "wine/winuser16.h"
45
46 /**********************************************************************/
47
48 USER_DRIVER *USER_Driver = NULL;
49
50 /* when adding new languages look at ole/ole2nls.c 
51  * for proper iso name and Windows code (add 0x0400 
52  * to the code listed there)
53  */
54 const WINE_LANGUAGE_DEF Languages[] =
55 {
56     {"En",0x0409},      /* LANG_En */
57     {"Es",0x040A},      /* LANG_Es */
58     {"De",0x0407},      /* LANG_De */
59     {"No",0x0414},      /* LANG_No */
60     {"Fr",0x040C},      /* LANG_Fr */
61     {"Fi",0x040B},      /* LANG_Fi */
62     {"Da",0x0406},      /* LANG_Da */
63     {"Cs",0x0405},      /* LANG_Cs */
64     {"Eo",0x048f},      /* LANG_Eo */
65     {"It",0x0410},      /* LANG_It */
66     {"Ko",0x0412},      /* LANG_Ko */
67     {"Hu",0x040e},      /* LANG_Hu */
68     {"Pl",0x0415},      /* LANG_Pl */
69     {"Pt",0x0416},      /* LANG_Pt */
70     {"Sv",0x041d},      /* LANG_Sv */
71     {"Ca",0x0403},      /* LANG_Ca */
72     {"Nl",0x0413},      /* LANG_Nl */
73     {"Ru",0x0419},      /* LANG_Ru */
74     {"Wa",0x0490},      /* LANG_Wa */
75     {NULL,0}
76 };
77
78 WORD WINE_LanguageId = 0x409;   /* english as default */
79
80 struct options Options =
81 {  /* default options */
82     0,              /* argc */
83     NULL,           /* argv */
84     NULL,           /* desktopGeometry */
85     NULL,           /* programName */
86     NULL,           /* argv0 */
87     NULL,           /* dllFlags */
88     FALSE,          /* usePrivateMap */
89     FALSE,          /* useFixedMap */
90     FALSE,          /* synchronous */
91     FALSE,          /* backing store */
92     SW_SHOWNORMAL,  /* cmdShow */
93     FALSE,
94     FALSE,          /* failReadOnly */
95     MODE_ENHANCED,  /* Enhanced mode */
96 #ifdef DEFAULT_LANG
97     DEFAULT_LANG,   /* Default language */
98 #else
99     LANG_En,
100 #endif
101     FALSE,          /* Managed windows */
102     FALSE,          /* Perfect graphics */
103     FALSE,          /* No DGA */
104     NULL,           /* Alternate config file name */
105     0               /* screenDepth */
106 };
107
108 static char szUsage[] =
109   "%s\n"
110   "Usage:  %s [options] \"program_name [arguments]\"\n"
111   "\n"
112   "Options:\n"
113   "    -backingstore   Turn on backing store\n"
114   "    -config name    Specify config file to use\n"
115   "    -console driver Select which driver(s) to use for the console\n"
116   "    -debug          Enter debugger before starting application\n"
117   "    -debugmsg name  Turn debugging-messages on or off\n"
118   "    -depth n        Change the depth to use for multiple-depth screens\n"
119   "    -desktop geom   Use a desktop window of the given geometry\n"
120   "    -display name   Use the specified display\n"
121   "    -dll name       Enable or disable built-in DLLs\n"
122   "    -failreadonly   Read only files may not be opened in write mode\n"
123   "    -fixedmap       Use a \"standard\" color map\n"
124   "    -help           Show this help message\n"
125   "    -iconic         Start as an icon\n"
126   "    -language xx    Set the language (one of Ca,Cs,Da,De,En,Eo,Es,Fi,Fr,Hu,It,\n"
127   "                    Ko,Nl,No,Pl,Pt,Sv,Ru,Wa)\n"
128   "    -managed        Allow the window manager to manage created windows\n"
129   "    -mode mode      Start Wine in a particular mode (standard or enhanced)\n"
130   "    -name name      Set the application name\n"
131   "    -nodga          Disable XFree86 DGA extensions\n"
132   "    -perfect        Favor correctness over speed for graphical operations\n"
133   "    -privatemap     Use a private color map\n"
134   "    -synchronous    Turn on synchronous display mode\n"
135   "    -version        Display the Wine version\n"
136   "    -winver         Version to imitate (one of win31,win95,nt351,nt40)\n"
137   "    -dosver         DOS version to imitate (x.xx, e.g. 6.22). Only valid with -winver win31\n"
138   ;
139
140 /***********************************************************************
141  *           MAIN_Usage
142  */
143 void MAIN_Usage( char *name )
144 {
145     MSG( szUsage, WINE_RELEASE_INFO, name );
146     exit(1);
147 }
148
149 /***********************************************************************
150  *           MAIN_GetProgramName
151  *
152  * Get the program name. The name is specified by (in order of precedence):
153  * - the option '-name'.
154  * - the environment variable 'WINE_NAME'.
155  * - the last component of argv[0].
156  */
157 static char *MAIN_GetProgramName( int argc, char *argv[] )
158 {
159     int i;
160     char *p;
161
162     for (i = 1; i < argc-1; i++)
163         if (!strcmp( argv[i], "-name" )) return argv[i+1];
164     if ((p = getenv( "WINE_NAME" )) != NULL) return p;
165     if ((p = strrchr( argv[0], '/' )) != NULL) return p+1;
166     return argv[0];
167 }
168
169 /***********************************************************************
170  *          MAIN_ParseDebugOptions
171  *
172  *  Turns specific debug messages on or off, according to "options".
173  *  
174  *  RETURNS
175  *    TRUE if parsing was successful
176  */
177 BOOL MAIN_ParseDebugOptions(char *options)
178 {
179   /* defined in relay32/relay386.c */
180   extern char **debug_relay_includelist;
181   extern char **debug_relay_excludelist;
182   /* defined in relay32/snoop.c */
183   extern char **debug_snoop_includelist;
184   extern char **debug_snoop_excludelist;
185
186   int i;
187   int l, cls, dotracerelay = TRACE_ON(relay);
188
189   l = strlen(options);
190   if (l<3)
191     return FALSE;
192   if (options[l-1]=='\n') options[l-1]='\0';
193   do
194   {
195     if ((*options!='+')&&(*options!='-')){
196       int j;
197
198       for(j=0; j<DEBUG_CLASS_COUNT; j++)
199         if(!lstrncmpiA(options, debug_cl_name[j], strlen(debug_cl_name[j])))
200           break;
201       if(j==DEBUG_CLASS_COUNT)
202         goto error;
203       options += strlen(debug_cl_name[j]);
204       if ((*options!='+')&&(*options!='-'))
205         goto error;
206       cls = j;
207     }
208     else
209       cls = -1; /* all classes */
210
211     if (strchr(options,','))
212       l=strchr(options,',')-options;
213     else
214       l=strlen(options);
215
216     if (!lstrncmpiA(options+1,"all",l-1))
217       {
218         int i, j;
219         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
220           for(j=0; j<DEBUG_CLASS_COUNT; j++)
221             if(cls == -1 || cls == j)
222               debug_msg_enabled[i][j]=(*options=='+');
223       }
224     else if (!lstrncmpiA(options+1, "relay=", 6) ||
225              !lstrncmpiA(options+1, "snoop=", 6))
226       {
227         int i, j;
228         char *s, *s2, ***output, c;
229
230         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
231           if (debug_ch_name && (!lstrncmpiA(debug_ch_name[i],options+1,5))){
232             for(j=0; j<DEBUG_CLASS_COUNT; j++)
233               if(cls == -1 || cls == j)
234                 debug_msg_enabled[i][j]=TRUE;
235             break;
236           }
237         /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
238         if (i==DEBUG_CHANNEL_COUNT)
239           goto error;
240         output = (*options == '+') ?
241                         ((*(options+1) == 'r') ?
242                                 &debug_relay_includelist :
243                                 &debug_snoop_includelist) :
244                         ((*(options+1) == 'r') ?
245                                 &debug_relay_excludelist :
246                                 &debug_snoop_excludelist);
247         s = options + 7;
248         i = 1;
249         while((s = strchr(s, ':'))) i++, s++;
250         *output = malloc(sizeof(char **) * i + 1);
251         i = 0;
252         s = options + 7;
253         while((s2 = strchr(s, ':'))) {
254           c = *s2;
255           *s2 = '\0';
256           *((*output)+i) = strdup(s);
257           *s2 = c;
258           s = s2 + 1;
259           i++;
260         }
261         c = *(options + l);
262         *(options + l) = '\0';
263         *((*output)+i) = strdup(s);
264         *(options + l) = c;
265         *((*output)+i+1) = NULL;
266       }
267     else
268       {
269         int i, j;
270         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
271           if (debug_ch_name && (!lstrncmpiA(options+1,debug_ch_name[i],l-1))){
272             for(j=0; j<DEBUG_CLASS_COUNT; j++)
273               if(cls == -1 || cls == j)
274                 debug_msg_enabled[i][j]=(*options=='+');
275             break;
276           }
277         if (i==DEBUG_CHANNEL_COUNT)
278           goto error;
279       }
280     options+=l;
281   }
282   while((*options==',')&&(*(++options)));
283
284   /* special handling for relay debugging */
285   if (dotracerelay != TRACE_ON(relay))
286         BUILTIN32_SwitchRelayDebug( TRACE_ON(relay) );
287
288   if (!*options)
289     return TRUE;
290
291  error:  
292   MSG("%s: Syntax: -debugmsg [class]+xxx,...  or "
293       "-debugmsg [class]-xxx,...\n",Options.argv[0]);
294   MSG("Example: -debugmsg +all,warn-heap\n"
295       "  turn on all messages except warning heap messages\n");
296   MSG("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
297       "  turn on -debugmsg +relay only as specified\n"
298       "Special case: -debugmsg -relay=DLL:DLL.###:FuncName\n"
299       "  turn on -debugmsg +relay except as specified\n"
300       "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
301   
302   MSG("Available message classes:\n");
303   for(i=0;i<DEBUG_CLASS_COUNT;i++)
304     MSG( "%-9s", debug_cl_name[i]);
305   MSG("\n\n");
306   
307   MSG("Available message types:\n");
308   MSG("%-9s ","all");
309   for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
310     if(debug_ch_name[i])
311       MSG("%-9s%c",debug_ch_name[i],
312           (((i+2)%8==0)?'\n':' '));
313   MSG("\n\n");
314   exit(1);
315 }
316
317 /***********************************************************************
318  *           MAIN_GetLanguageID
319  *
320  * INPUT:
321  *      Lang: a string whose two first chars are the iso name of a language.
322  *      Country: a string whose two first chars are the iso name of country
323  *      Charset: a string defining the chossen charset encoding
324  *      Dialect: a string defining a variation of the locale
325  *
326  *      all those values are from the standardized format of locale
327  *      name in unix which is: Lang[_Country][.Charset][@Dialect]
328  *
329  * RETURNS:
330  *      the numeric code of the language used by Windows (or 0x00)
331  */
332 int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
333 {
334     char lang[3]="??", country[3]={0,0,0};
335     char *charset=NULL, *dialect=NULL;
336     int i,j,ret=0;
337
338     if (Lang==NULL) return 0x00;
339     if (Lang[0]) lang[0]=tolower(Lang[0]);
340     if (Lang[1]) lang[1]=tolower(Lang[1]);
341
342     if (Country!=NULL) {
343         if (Country[0]) country[0]=toupper(Country[0]);
344         if (Country[1]) country[1]=toupper(Country[1]);
345     }
346
347     if (Charset!=NULL) {
348         j=strlen(Charset);
349         charset=(char*)malloc(j+1);
350         for (i=0;i<j;i++)
351             charset[i]=toupper(Charset[i]);
352         charset[i]='\0';
353     }
354
355     if (Dialect!=NULL) {
356         j=strlen(Dialect);
357         dialect=(char*)malloc(j+1);
358         for (i=0;i<j;i++)
359             dialect[i]=tolower(Dialect[i]);
360         dialect[i]='\0';
361     } else {
362         dialect = malloc(1);
363         dialect[0] = '\0';
364     }
365
366 #define LANG_ENTRY_BEGIN(x,y)   if(!strcmp(lang, x )) { \
367                                     if (!country[0]) { \
368                                         ret=LANG_##y ; \
369                                         goto end_MAIN_GetLanguageID; \
370                                     }
371 #define LANG_SUB_ENTRY(x,y,z)       if (!strcmp(country, x )) \
372                                         ret = MAKELANGID( LANG_##y , SUBLANG_##z ); \
373                                         goto end_MAIN_GetLanguageID;
374 #define LANG_DIALECT_ENTRY(x,y)     { ret = MAKELANGID(LANG_##x , SUBLANG_##y ); \
375                                     goto end_MAIN_GetLanguageID; }
376 #define LANG_ENTRY_END(x)           ret = MAKELANGID(LANG_##x , SUBLANG_DEFAULT); \
377                                     goto end_MAIN_GetLanguageID; \
378                                 }
379
380 /*x01*/ LANG_ENTRY_BEGIN( "ar", ARABIC )
381         LANG_SUB_ENTRY( "SA", ARABIC, ARABIC)
382         LANG_SUB_ENTRY( "IQ", ARABIC, ARABIC_IRAQ )
383         LANG_SUB_ENTRY( "EG", ARABIC, ARABIC_EGYPT )
384         LANG_SUB_ENTRY( "LY", ARABIC, ARABIC_LIBYA )
385         LANG_SUB_ENTRY( "DZ", ARABIC, ARABIC_ALGERIA )
386         LANG_SUB_ENTRY( "MA", ARABIC, ARABIC_MOROCCO )
387         LANG_SUB_ENTRY( "TN", ARABIC, ARABIC_TUNISIA )
388         LANG_SUB_ENTRY( "OM", ARABIC, ARABIC_OMAN )
389         LANG_SUB_ENTRY( "YE", ARABIC, ARABIC_YEMEN )
390         LANG_SUB_ENTRY( "SY", ARABIC, ARABIC_SYRIA )
391         LANG_SUB_ENTRY( "JO", ARABIC, ARABIC_JORDAN )
392         LANG_SUB_ENTRY( "LB", ARABIC, ARABIC_LEBANON )
393         LANG_SUB_ENTRY( "KW", ARABIC, ARABIC_KUWAIT )
394         LANG_SUB_ENTRY( "AE", ARABIC, ARABIC_UAE )
395         LANG_SUB_ENTRY( "BH", ARABIC, ARABIC_BAHRAIN )
396         LANG_SUB_ENTRY( "QA", ARABIC, ARABIC_QATAR )
397         LANG_ENTRY_END( ARABIC )
398 /*x02*/ LANG_ENTRY_BEGIN( "bu", BULGARIAN )
399         LANG_ENTRY_END( BULGARIAN )
400 /*x03*/ LANG_ENTRY_BEGIN( "ca", CATALAN )
401         LANG_ENTRY_END( CATALAN )
402 /*x04*/ LANG_ENTRY_BEGIN( "zh", CHINESE )
403         LANG_SUB_ENTRY( "TW", CHINESE, CHINESE_TRADITIONAL )
404         LANG_SUB_ENTRY( "CN", CHINESE, CHINESE_SIMPLIFIED )
405         LANG_SUB_ENTRY( "HK", CHINESE, CHINESE_HONGKONG )
406         LANG_SUB_ENTRY( "SG", CHINESE, CHINESE_SINGAPORE )
407         LANG_SUB_ENTRY( "MO", CHINESE, CHINESE_MACAU )
408         LANG_ENTRY_END( CHINESE )
409 /*x05*/ LANG_ENTRY_BEGIN( "cs", CZECH )
410         LANG_ENTRY_END( CZECH )
411 /*x06*/ LANG_ENTRY_BEGIN( "da", DANISH )
412         LANG_ENTRY_END( DANISH )
413 /*x07*/ LANG_ENTRY_BEGIN( "de", GERMAN )
414         LANG_SUB_ENTRY( "DE", GERMAN, GERMAN )
415         LANG_SUB_ENTRY( "CH", GERMAN, GERMAN_SWISS )
416         LANG_SUB_ENTRY( "AT", GERMAN, GERMAN_AUSTRIAN )
417         LANG_SUB_ENTRY( "LU", GERMAN, GERMAN_LUXEMBOURG )
418         LANG_SUB_ENTRY( "LI", GERMAN, GERMAN_LIECHTENSTEIN )
419         LANG_ENTRY_END( GERMAN )
420 /*x08*/ LANG_ENTRY_BEGIN( "el", GREEK )
421         LANG_ENTRY_END( GREEK )
422 /*x09*/ LANG_ENTRY_BEGIN( "en", ENGLISH )
423         LANG_SUB_ENTRY( "US", ENGLISH, ENGLISH_US )
424         LANG_SUB_ENTRY( "UK", ENGLISH, ENGLISH_UK )
425         LANG_SUB_ENTRY( "AU", ENGLISH, ENGLISH_AUS )
426         LANG_SUB_ENTRY( "CA", ENGLISH, ENGLISH_CAN )
427         LANG_SUB_ENTRY( "NZ", ENGLISH, ENGLISH_NZ )
428         LANG_SUB_ENTRY( "EI", ENGLISH, ENGLISH_EIRE )
429         LANG_SUB_ENTRY( "ZA", ENGLISH, ENGLISH_SAFRICA )
430         LANG_SUB_ENTRY( "JM", ENGLISH, ENGLISH_JAMAICA )
431      /* LANG_SUB_ENTRY( "AG", ENGLISH, ENGLISH_CARIBBEAN ) */
432         LANG_SUB_ENTRY( "BZ", ENGLISH, ENGLISH_BELIZE )
433         LANG_SUB_ENTRY( "TT", ENGLISH, ENGLISH_TRINIDAD )
434         LANG_SUB_ENTRY( "ZW", ENGLISH, ENGLISH_ZIMBABWE )
435         LANG_SUB_ENTRY( "PH", ENGLISH, ENGLISH_PHILIPPINES )
436         LANG_ENTRY_END( ENGLISH )
437 /*x0a*/ LANG_ENTRY_BEGIN( "es", SPANISH )
438         /* traditional sorting */
439         if (!strcmp(dialect,"tradicional"))
440                 LANG_DIALECT_ENTRY( SPANISH, SPANISH )
441         LANG_SUB_ENTRY( "MX", SPANISH, SPANISH_MEXICAN )
442         LANG_SUB_ENTRY( "ES", SPANISH, SPANISH_MODERN )
443         LANG_SUB_ENTRY( "GT", SPANISH, SPANISH_GUATEMALA )
444         LANG_SUB_ENTRY( "CR", SPANISH, SPANISH_COSTARICA )
445         LANG_SUB_ENTRY( "PA", SPANISH, SPANISH_PANAMA )
446         LANG_SUB_ENTRY( "DO", SPANISH, SPANISH_DOMINICAN )
447         LANG_SUB_ENTRY( "VE", SPANISH, SPANISH_VENEZUELA )
448         LANG_SUB_ENTRY( "CO", SPANISH, SPANISH_COLOMBIA )
449         LANG_SUB_ENTRY( "PE", SPANISH, SPANISH_PERU )
450         LANG_SUB_ENTRY( "AR", SPANISH, SPANISH_ARGENTINA )
451         LANG_SUB_ENTRY( "EC", SPANISH, SPANISH_ECUADOR )
452         LANG_SUB_ENTRY( "CL", SPANISH, SPANISH_CHILE )
453         LANG_SUB_ENTRY( "UY", SPANISH, SPANISH_URUGUAY )
454         LANG_SUB_ENTRY( "PY", SPANISH, SPANISH_PARAGUAY )
455         LANG_SUB_ENTRY( "BO", SPANISH, SPANISH_BOLIVIA )
456         LANG_SUB_ENTRY( "HN", SPANISH, SPANISH_HONDURAS )
457         LANG_SUB_ENTRY( "NI", SPANISH, SPANISH_NICARAGUA )
458         LANG_SUB_ENTRY( "PR", SPANISH, SPANISH_PUERTO_RICO )
459         LANG_ENTRY_END( SPANISH )
460 /*x0b*/ LANG_ENTRY_BEGIN( "fi", FINNISH )
461         LANG_ENTRY_END( FINNISH )
462 /*x0c*/ LANG_ENTRY_BEGIN( "fr", FRENCH )
463         LANG_SUB_ENTRY( "FR", FRENCH, FRENCH )
464         LANG_SUB_ENTRY( "BE", FRENCH, FRENCH_BELGIAN )
465         LANG_SUB_ENTRY( "CA", FRENCH, FRENCH_CANADIAN )
466         LANG_SUB_ENTRY( "CH", FRENCH, FRENCH_SWISS )
467         LANG_SUB_ENTRY( "LU", FRENCH, FRENCH_LUXEMBOURG )
468         LANG_SUB_ENTRY( "MC", FRENCH, FRENCH_MONACO )
469         LANG_ENTRY_END( FRENCH )
470 /*x0d*/ LANG_ENTRY_BEGIN( "iw", HEBREW )
471         LANG_ENTRY_END( HEBREW )
472 /*x0e*/ LANG_ENTRY_BEGIN( "hu", HUNGARIAN )
473         LANG_ENTRY_END( HUNGARIAN )
474 /*x0f*/ LANG_ENTRY_BEGIN( "ic", ICELANDIC )
475         LANG_ENTRY_END( ICELANDIC )
476 /*x10*/ LANG_ENTRY_BEGIN( "it", ITALIAN )
477         LANG_SUB_ENTRY( "IT", ITALIAN, ITALIAN )
478         LANG_SUB_ENTRY( "CH", ITALIAN, ITALIAN_SWISS )
479         LANG_ENTRY_END( ITALIAN )
480 /*x11*/ LANG_ENTRY_BEGIN( "ja", JAPANESE )
481         LANG_ENTRY_END( JAPANESE )
482 /*x12*/ LANG_ENTRY_BEGIN( "ko", KOREAN )
483         /* JOHAB encoding */
484         if (!strcmp(charset,"JOHAB"))
485                 LANG_DIALECT_ENTRY( KOREAN, KOREAN_JOHAB )
486         else
487                 LANG_DIALECT_ENTRY( KOREAN, KOREAN )
488         LANG_ENTRY_END( KOREAN )
489 /*x13*/ LANG_ENTRY_BEGIN( "nl", DUTCH )
490         LANG_SUB_ENTRY( "NL", DUTCH, DUTCH )
491         LANG_SUB_ENTRY( "BE", DUTCH, DUTCH_BELGIAN )
492         LANG_SUB_ENTRY( "SR", DUTCH, DUTCH_SURINAM )
493         LANG_ENTRY_END( DUTCH )
494 /*x14*/ LANG_ENTRY_BEGIN( "no", NORWEGIAN )
495         /* nynorsk */
496         if (!strcmp(dialect,"nynorsk"))
497                 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_NYNORSK )
498         else
499                 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_BOKMAL )
500         LANG_ENTRY_END( NORWEGIAN )
501 /*x15*/ LANG_ENTRY_BEGIN( "pl", POLISH )
502         LANG_ENTRY_END( POLISH )
503 /*x16*/ LANG_ENTRY_BEGIN( "pt", PORTUGUESE )
504         LANG_SUB_ENTRY( "BR", PORTUGUESE, PORTUGUESE_BRAZILIAN )
505         LANG_SUB_ENTRY( "PT", PORTUGUESE, PORTUGUESE )
506         LANG_ENTRY_END( PORTUGUESE )
507 /*x17*/ LANG_ENTRY_BEGIN( "rm", RHAETO_ROMANCE )
508         LANG_ENTRY_END( RHAETO_ROMANCE )
509 /*x18*/ LANG_ENTRY_BEGIN( "ro", ROMANIAN )
510         LANG_SUB_ENTRY( "RO", ROMANIAN, ROMANIAN )
511         LANG_SUB_ENTRY( "MD", ROMANIAN, ROMANIAN_MOLDAVIA )
512         LANG_ENTRY_END( ROMANIAN )
513 /*x19*/ LANG_ENTRY_BEGIN( "ru", RUSSIAN )
514         LANG_SUB_ENTRY( "RU", RUSSIAN, RUSSIAN )
515         LANG_SUB_ENTRY( "MD", RUSSIAN, RUSSIAN_MOLDAVIA )
516         LANG_ENTRY_END( RUSSIAN )
517 /*x1a*/ if (!strcmp(lang,"sh") || !strcmp(lang,"hr") || !strcmp(lang,"sr")) {
518             if (!country[0]) 
519                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, NEUTRAL)
520             if (!strcmp(charset,"ISO-8859-5"))
521                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN )
522             LANG_SUB_ENTRY( "HR", SERBO_CROATIAN, CROATIAN )
523             if (!strcmp(country,"YU") && !strcmp(charset,"ISO-8859-2"))
524                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
525             LANG_SUB_ENTRY( "YU", SERBO_CROATIAN, SERBIAN )
526             LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
527         }
528 /*x1b*/ LANG_ENTRY_BEGIN( "sk", SLOVAK )
529         LANG_ENTRY_END( SLOVAK )
530 /*x1c*/ LANG_ENTRY_BEGIN( "sq", ALBANIAN )
531         LANG_ENTRY_END( ALBANIAN )
532 /*x1d*/ LANG_ENTRY_BEGIN( "sv", SWEDISH )
533         LANG_SUB_ENTRY( "SE", SWEDISH, SWEDISH )
534         LANG_SUB_ENTRY( "FI", SWEDISH, SWEDISH_FINLAND )
535         LANG_ENTRY_END( SWEDISH )
536 /*x1e*/ LANG_ENTRY_BEGIN( "th", THAI )
537         LANG_ENTRY_END( THAI )
538 /*x1f*/ LANG_ENTRY_BEGIN( "tr", TURKISH )
539         LANG_ENTRY_END( TURKISH )
540 /*x20*/ LANG_ENTRY_BEGIN( "ur", URDU )
541         LANG_ENTRY_END( URDU )
542 /*x21*/ LANG_ENTRY_BEGIN( "in", INDONESIAN )
543         LANG_ENTRY_END( INDONESIAN )
544 /*x22*/ LANG_ENTRY_BEGIN( "uk", UKRAINIAN )
545         LANG_ENTRY_END( UKRAINIAN )
546 /*x23*/ LANG_ENTRY_BEGIN( "be", BYELORUSSIAN )
547         LANG_ENTRY_END( BYELORUSSIAN )
548 /*x24*/ LANG_ENTRY_BEGIN( "sl", SLOVENIAN )
549         LANG_ENTRY_END( SLOVENIAN )
550 /*x25*/ LANG_ENTRY_BEGIN( "et", ESTONIAN )
551         LANG_ENTRY_END( ESTONIAN )
552 /*x26*/ LANG_ENTRY_BEGIN( "lv", LATVIAN )
553         LANG_ENTRY_END( LATVIAN )
554 /*x27*/ LANG_ENTRY_BEGIN( "lt", LITHUANIAN )
555         /* traditional sorting ? */
556         if (!strcmp(dialect,"classic") || !strcmp(dialect,"traditional"))
557                 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN_CLASSIC )
558         else
559                 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN )
560         LANG_ENTRY_END( LITHUANIAN )
561 /*x28*/ LANG_ENTRY_BEGIN( "mi", MAORI )
562         LANG_ENTRY_END( MAORI )
563 /*x29*/ LANG_ENTRY_BEGIN( "fa", FARSI )
564         LANG_ENTRY_END( FARSI )
565 /*x2a*/ LANG_ENTRY_BEGIN( "vi", VIETNAMESE )
566         LANG_ENTRY_END( VIETNAMESE )
567 /*x2b*/ LANG_ENTRY_BEGIN( "hy", ARMENIAN )
568         LANG_ENTRY_END( ARMENIAN )
569 /*x2c*/ LANG_ENTRY_BEGIN( "az", AZERI )
570         /* Cyrillic */
571         if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
572                 LANG_DIALECT_ENTRY( AZERI, AZERI_CYRILLIC )
573         else
574                 LANG_DIALECT_ENTRY( AZERI, AZERI )
575         LANG_ENTRY_END( AZERI )
576 /*x2d*/ LANG_ENTRY_BEGIN( "eu", BASQUE )
577         LANG_ENTRY_END( BASQUE )
578 /*x2e*/ /*LANG_ENTRY_BEGIN( "??", SORBIAN )
579         LANG_ENTRY_END( SORBIAN ) */
580 /*x2f*/ LANG_ENTRY_BEGIN( "mk", MACEDONIAN )
581         LANG_ENTRY_END( MACEDONIAN )
582 /*x30*/ /*LANG_ENTRY_BEGIN( "??", SUTU )
583         LANG_ENTRY_END( SUTU ) */
584 /*x31*/ LANG_ENTRY_BEGIN( "ts", TSONGA )
585         LANG_ENTRY_END( TSONGA )
586 /*x32*/ /*LANG_ENTRY_BEGIN( "??", TSWANA )
587         LANG_ENTRY_END( TSWANA ) */
588 /*x33*/ /*LANG_ENTRY_BEGIN( "??", VENDA )
589         LANG_ENTRY_END( VENDA ) */
590 /*x34*/ LANG_ENTRY_BEGIN( "xh", XHOSA )
591         LANG_ENTRY_END( XHOSA )
592 /*x35*/ LANG_ENTRY_BEGIN( "zu", ZULU )
593         LANG_ENTRY_END( ZULU )
594 /*x36*/ LANG_ENTRY_BEGIN( "af", AFRIKAANS )
595         LANG_ENTRY_END( AFRIKAANS )
596 /*x37*/ LANG_ENTRY_BEGIN( "ka", GEORGIAN )
597         LANG_ENTRY_END( GEORGIAN )
598 /*x38*/ LANG_ENTRY_BEGIN( "fo", FAEROESE )
599         LANG_ENTRY_END( FAEROESE )
600 /*x39*/ LANG_ENTRY_BEGIN( "hi", HINDI )
601         LANG_ENTRY_END( HINDI )
602 /*x3a*/ LANG_ENTRY_BEGIN( "mt", MALTESE )
603         LANG_ENTRY_END( MALTESE )
604 /*x3b*/ /*LANG_ENTRY_BEGIN( "??", SAAMI )
605         LANG_ENTRY_END( SAAMI ) */
606 /*x3c*/ LANG_ENTRY_BEGIN( "ga", GAELIC )
607         LANG_DIALECT_ENTRY( GAELIC, GAELIC )
608         LANG_ENTRY_END( GAELIC )
609 /*x3c*/ LANG_ENTRY_BEGIN( "gd", GAELIC )
610         LANG_DIALECT_ENTRY( GAELIC, GAELIC_SCOTTISH )
611         LANG_ENTRY_END( GAELIC )
612 /* 0x3d */
613 /*x3e*/ LANG_ENTRY_BEGIN( "ms", MALAY )
614         LANG_SUB_ENTRY( "MY", MALAY, MALAY )
615         LANG_SUB_ENTRY( "BN", MALAY, MALAY_BRUNEI_DARUSSALAM )
616         LANG_ENTRY_END( MALAY )
617 /*x3f*/ LANG_ENTRY_BEGIN( "kk", KAZAKH )
618         LANG_ENTRY_END( KAZAKH )
619 /* 0x40 */
620 /*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI )
621         LANG_ENTRY_END( SWAHILI )
622 /* 0x42 */
623 /*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK )
624         /* Cyrillic */
625         if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
626                 LANG_DIALECT_ENTRY( UZBEK, UZBEK_CYRILLIC )
627         else
628                 LANG_DIALECT_ENTRY( UZBEK, UZBEK )
629         LANG_ENTRY_END( UZBEK )
630 /*x44*/ LANG_ENTRY_BEGIN( "tt", TATAR )
631         LANG_ENTRY_END( TATAR )
632 /*x45*/ LANG_ENTRY_BEGIN( "bn", BENGALI )
633         LANG_ENTRY_END( BENGALI )
634 /*x46*/ LANG_ENTRY_BEGIN( "pa", PUNJABI )
635         LANG_ENTRY_END( PUNJABI )
636 /*x47*/ LANG_ENTRY_BEGIN( "gu", GUJARATI )
637         LANG_ENTRY_END( GUJARATI )
638 /*x48*/ LANG_ENTRY_BEGIN( "or", ORIYA )
639         LANG_ENTRY_END( ORIYA )
640 /*x49*/ LANG_ENTRY_BEGIN( "ta", TAMIL )
641         LANG_ENTRY_END( TAMIL )
642 /*x4a*/ LANG_ENTRY_BEGIN( "te", TELUGU )
643         LANG_ENTRY_END( TELUGU )
644 /*x4b*/ LANG_ENTRY_BEGIN( "kn", KANNADA )
645         LANG_ENTRY_END( KANNADA )
646 /*x4c*/ LANG_ENTRY_BEGIN( "ml", MALAYALAM )
647         LANG_ENTRY_END( MALAYALAM )
648 /*x4d*/ LANG_ENTRY_BEGIN( "as", ASSAMESE )
649         LANG_ENTRY_END( ASSAMESE )
650 /*x4e*/ LANG_ENTRY_BEGIN( "mr", MARATHI )
651         LANG_ENTRY_END( MARATHI )
652 /*x4f*/ LANG_ENTRY_BEGIN( "sa", SANSKRIT )
653         LANG_ENTRY_END( SANSKRIT )
654 /* 0x50 -> 0x56 */
655 /*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
656         LANG_ENTRY_END( KONKANI ) */
657 /* 0x58 -> ... */
658         LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */
659         LANG_ENTRY_END( ESPERANTO )
660         LANG_ENTRY_BEGIN( "wa", WALON ) /* not official */ 
661         LANG_ENTRY_END( WALON )
662
663         ret = LANG_ENGLISH;
664
665 end_MAIN_GetLanguageID:
666         if (Charset) free(charset);
667         free(dialect);
668
669         return ret;
670 }
671
672 /***********************************************************************
673  *           MAIN_ParseLanguageOption
674  *
675  * Parse -language option.
676  */
677 void MAIN_ParseLanguageOption( char *arg )
678 {
679     const WINE_LANGUAGE_DEF *p = Languages;
680
681 /* for compatibility whith non-iso names previously used */
682     if (!strcmp("Sw",arg)) { strcpy(arg,"Sv"); FIXME(system,"use 'Sv' instead of 'Sw'\n");}
683     if (!strcmp("Cz",arg)) { strcpy(arg,"Cs"); FIXME(system,"use 'Cs' instead of 'Cz'\n");}
684     if (!strcmp("Po",arg)) { strcpy(arg,"Pt"); FIXME(system,"use 'Pt' instead of 'Po'\n");}
685
686     Options.language = LANG_Xx;  /* First (dummy) language */
687     for (;p->name;p++)
688     {
689         if (!lstrcmpiA( p->name, arg ))
690         {
691             WINE_LanguageId = p->langid;
692             return;
693         }
694         Options.language++;
695     }
696     MSG( "Invalid language specified '%s'. Supported languages are: ", arg );
697     for (p = Languages; p->name; p++) MSG( "%s ", p->name );
698     MSG( "\n" );
699     exit(1);
700 }
701
702
703 /***********************************************************************
704  *           MAIN_ParseModeOption
705  *
706  * Parse -mode option.
707  */
708 void MAIN_ParseModeOption( char *arg )
709 {
710     if (!lstrcmpiA("enhanced", arg)) Options.mode = MODE_ENHANCED;
711     else if (!lstrcmpiA("standard", arg)) Options.mode = MODE_STANDARD;
712     else
713     {
714         MSG( "Invalid mode '%s' specified.\n", arg);
715         MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
716         exit(1);
717     }
718 }
719
720 /***********************************************************************
721  *           MAIN_ParseOptions
722  *
723  * Parse command line options and open display.
724  */
725 static void MAIN_ParseOptions( int *argc, char *argv[] )
726 {
727     int i;
728     char *pcDot;
729
730     Options.argc = argc;
731     Options.argv = argv;
732     Options.programName = MAIN_GetProgramName( *argc, argv );
733     Options.argv0 = argv[0];
734
735     /* initialise Options.language to 0 to tell "no language choosen yet" */
736     Options.language = 0;
737   
738     /* make sure there is no "." in Options.programName to confuse the X
739        resource database lookups */
740     if ((pcDot = strchr(Options.programName, '.'))) *pcDot = '\0';
741
742     for (i = 1; i < *argc; i++)
743     {
744         if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
745         {
746             MSG( "%s\n", WINE_RELEASE_INFO );
747             exit(0);
748         }
749         if (!strcmp( argv[i], "-h" ) || !strcmp( argv[i], "-help" ))
750         {
751             MAIN_Usage(argv[0]);
752             exit(0);
753         }
754     }
755 }
756
757 /***********************************************************************
758  *           called_at_exit
759  */
760 static void called_at_exit(void)
761 {
762     if (GDI_Driver)
763         GDI_Driver->pFinalize();
764     if (USER_Driver)
765         USER_Driver->pFinalize();
766
767     WINSOCK_Shutdown();
768     CONSOLE_Close();
769 }
770
771 /***********************************************************************
772  *           MAIN_WineInit
773  *
774  * Wine initialisation and command-line parsing
775  */
776 BOOL MAIN_WineInit( int *argc, char *argv[] )
777 {    
778     struct timeval tv;
779
780 #ifdef MALLOC_DEBUGGING
781     char *trace;
782
783     mcheck(NULL);
784     if (!(trace = getenv("MALLOC_TRACE")))
785     {       
786         MSG( "MALLOC_TRACE not set. No trace generated\n" );
787     }
788     else
789     {
790         MSG( "malloc trace goes to %s\n", trace );
791         mtrace();
792     }
793 #endif
794
795     setbuf(stdout,NULL);
796     setbuf(stderr,NULL);
797
798     setlocale(LC_CTYPE,"");
799     gettimeofday( &tv, NULL);
800     MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
801     
802     MAIN_ParseOptions(argc, argv);
803
804 #ifndef X_DISPLAY_MISSING
805     USER_Driver = &X11DRV_USER_Driver;
806 #else /* !defined(X_DISPLAY_MISSING) */
807     USER_Driver = &TTYDRV_USER_Driver;
808 #endif /* !defined(X_DISPLAY_MISSING) */
809
810     USER_Driver->pInitialize();
811
812     MONITOR_Initialize(&MONITOR_PrimaryMonitor);
813
814     if (Options.dllFlags)
815         BUILTIN32_ParseDLLOptions( Options.dllFlags );
816         /* if (__winelib && errors ) print_error_message_like_misc_main(); */
817
818     atexit(called_at_exit);
819     return TRUE;
820 }
821
822 /***********************************************************************
823  *           MessageBeep16   (USER.104)
824  */
825 void WINAPI MessageBeep16( UINT16 i )
826 {
827     MessageBeep( i );
828 }
829
830
831 /***********************************************************************
832  *           MessageBeep32   (USER32.390)
833  */
834 BOOL WINAPI MessageBeep( UINT i )
835 {
836     KEYBOARD_Beep();
837     return TRUE;
838 }
839
840
841 /***********************************************************************
842  *           Beep   (KERNEL32.11)
843  */
844 BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur )
845 {
846     /* dwFreq and dwDur are ignored by Win95 */
847     KEYBOARD_Beep();
848     return TRUE;
849 }
850
851
852 /***********************************************************************
853  *      GetTimerResolution (USER.14)
854  */
855 LONG WINAPI GetTimerResolution16(void)
856 {
857         return (1000);
858 }
859
860 /***********************************************************************
861  *      SystemParametersInfo32A   (USER32.540)
862  */
863 BOOL WINAPI SystemParametersInfoA( UINT uAction, UINT uParam,
864                                        LPVOID lpvParam, UINT fuWinIni )
865 {
866         int timeout;
867
868         switch (uAction) {
869         case SPI_GETBEEP:
870                 *(BOOL *) lpvParam = KEYBOARD_GetBeepActive();
871                 break;
872         case SPI_SETBEEP:
873                KEYBOARD_SetBeepActive(uParam);
874                break;
875
876         case SPI_GETBORDER:
877                 *(INT *)lpvParam = GetSystemMetrics( SM_CXFRAME );
878                 break;
879
880         case SPI_GETDRAGFULLWINDOWS:
881                 *(BOOL *) lpvParam = FALSE;
882                 break;
883
884         case SPI_SETDRAGFULLWINDOWS:
885                 break;
886
887         case SPI_GETFASTTASKSWITCH:
888                 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
889                         *(BOOL *) lpvParam = TRUE;
890                 else
891                         *(BOOL *) lpvParam = FALSE;
892                 break;
893                 
894         case SPI_GETGRIDGRANULARITY:
895                 *(INT*)lpvParam=GetProfileIntA("desktop","GridGranularity",1);
896                 break;
897
898         case SPI_GETICONTITLEWRAP:
899                 *(BOOL*)lpvParam=GetProfileIntA("desktop","IconTitleWrap",TRUE);
900                 break;
901
902         case SPI_GETKEYBOARDDELAY:
903                 *(INT*)lpvParam=GetProfileIntA("keyboard","KeyboardDelay",1);
904                 break;
905
906         case SPI_GETKEYBOARDSPEED:
907                 *(DWORD*)lpvParam=GetProfileIntA("keyboard","KeyboardSpeed",30);
908                 break;
909
910         case SPI_GETMENUDROPALIGNMENT:
911                 *(BOOL*)lpvParam=GetSystemMetrics(SM_MENUDROPALIGNMENT); /* XXX check this */
912                 break;
913
914         case SPI_GETSCREENSAVEACTIVE:           
915                if(MONITOR_GetScreenSaveActive(&MONITOR_PrimaryMonitor) || 
916                   GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
917                         *(BOOL*)lpvParam = TRUE;
918                 else
919                         *(BOOL*)lpvParam = FALSE;
920                 break;
921
922         case SPI_GETSCREENSAVETIMEOUT:
923                 timeout = MONITOR_GetScreenSaveTimeout(&MONITOR_PrimaryMonitor);
924                 if(!timeout)
925                         timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
926                 *(INT *) lpvParam = timeout * 1000;
927                 break;
928
929         case SPI_ICONHORIZONTALSPACING:
930                 /* FIXME Get/SetProfileInt */
931                 if (lpvParam == NULL)
932                         /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
933                 else
934                         *(INT*)lpvParam=GetSystemMetrics(SM_CXICONSPACING);
935                 break;
936
937         case SPI_ICONVERTICALSPACING:
938                 /* FIXME Get/SetProfileInt */
939                 if (lpvParam == NULL)
940                         /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
941                 else
942                         *(INT*)lpvParam=GetSystemMetrics(SM_CYICONSPACING);
943                 break;
944
945         case SPI_GETICONTITLELOGFONT: {
946                 LPLOGFONTA lpLogFont = (LPLOGFONTA)lpvParam;
947
948                 /* from now on we always have an alias for MS Sans Serif */
949
950                 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif", 
951                         lpLogFont->lfFaceName, LF_FACESIZE );
952                 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 8);
953                 lpLogFont->lfWidth = 0;
954                 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
955                 lpLogFont->lfWeight = FW_NORMAL;
956                 lpLogFont->lfItalic = FALSE;
957                 lpLogFont->lfStrikeOut = FALSE;
958                 lpLogFont->lfUnderline = FALSE;
959                 lpLogFont->lfCharSet = ANSI_CHARSET;
960                 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
961                 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
962                 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
963                 break;
964         }
965         case SPI_GETWORKAREA:
966                 SetRect( (RECT *)lpvParam, 0, 0,
967                         GetSystemMetrics( SM_CXSCREEN ),
968                         GetSystemMetrics( SM_CYSCREEN )
969                 );
970                 break;
971         case SPI_GETNONCLIENTMETRICS: 
972
973 #define lpnm ((LPNONCLIENTMETRICSA)lpvParam)
974                 
975                 if( lpnm->cbSize == sizeof(NONCLIENTMETRICSA) )
976                 {
977                     /* FIXME: initialize geometry entries */
978
979                     SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
980                                                         (LPVOID)&(lpnm->lfCaptionFont),0);
981                     lpnm->lfCaptionFont.lfWeight = FW_BOLD;
982                     SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
983                                                         (LPVOID)&(lpnm->lfSmCaptionFont),0);
984                     SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
985                                                         (LPVOID)&(lpnm->lfMenuFont),0);
986                     SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
987                                                         (LPVOID)&(lpnm->lfStatusFont),0);
988                     SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
989                                                         (LPVOID)&(lpnm->lfMessageFont),0);
990                 }
991 #undef lpnm
992                 break;
993
994         case SPI_GETANIMATION: {
995                 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
996  
997                 /* Tell it "disabled" */
998                 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
999                 uParam = sizeof(ANIMATIONINFO);
1000                 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
1001                 break;
1002         }
1003  
1004         case SPI_SETANIMATION: {
1005                 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1006  
1007                 /* Do nothing */
1008                 WARN(system, "SPI_SETANIMATION ignored.\n");
1009                 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1010                 uParam = sizeof(ANIMATIONINFO);
1011                 break;
1012         }
1013
1014         case SPI_GETHIGHCONTRAST:
1015         {
1016                 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
1017
1018                 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1019
1020                 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
1021                 {
1022                         /* Indicate that there is no high contrast available */
1023                         lpHighContrastA->dwFlags = 0;
1024                         lpHighContrastA->lpszDefaultScheme = NULL;
1025                 }
1026                 else
1027                 {
1028                         return FALSE;
1029                 }
1030
1031                 break;
1032         }
1033
1034         default:
1035                 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
1036         }
1037         return TRUE;
1038 }
1039
1040
1041 /***********************************************************************
1042  *      SystemParametersInfo16   (USER.483)
1043  */
1044 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
1045                                       LPVOID lpvParam, UINT16 fuWinIni )
1046 {
1047         int timeout; 
1048         char buffer[256];
1049
1050         switch (uAction)
1051         {
1052                 case SPI_GETBEEP:
1053                         *(BOOL *) lpvParam = KEYBOARD_GetBeepActive();
1054                         break;
1055                 
1056                 case SPI_GETBORDER:
1057                         *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME );
1058                         break;
1059
1060                 case SPI_GETFASTTASKSWITCH:
1061                     if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
1062                           *(BOOL16 *) lpvParam = TRUE;
1063                         else
1064                           *(BOOL16 *) lpvParam = FALSE;
1065                         break;
1066
1067                 case SPI_GETGRIDGRANULARITY:
1068                     *(INT16 *) lpvParam = GetProfileIntA( "desktop", 
1069                                                           "GridGranularity",
1070                                                           1 );
1071                     break;
1072
1073                 case SPI_GETICONTITLEWRAP:
1074                     *(BOOL16 *) lpvParam = GetProfileIntA( "desktop",
1075                                                            "IconTitleWrap",
1076                                                            TRUE );
1077                     break;
1078
1079                 case SPI_GETKEYBOARDDELAY:
1080                     *(INT16 *) lpvParam = GetProfileIntA( "keyboard",
1081                                                           "KeyboardDelay", 1 );
1082                     break;
1083
1084                 case SPI_GETKEYBOARDSPEED:
1085                     *(WORD *) lpvParam = GetProfileIntA( "keyboard",
1086                                                            "KeyboardSpeed",
1087                                                            30 );
1088                     break;
1089
1090                 case SPI_GETMENUDROPALIGNMENT:
1091                         *(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */
1092                         break;
1093
1094                 case SPI_GETSCREENSAVEACTIVE:
1095                   if(MONITOR_GetScreenSaveActive(&MONITOR_PrimaryMonitor) ||
1096                      GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
1097                         *(BOOL16 *) lpvParam = TRUE;
1098                     else
1099                         *(BOOL16 *) lpvParam = FALSE;
1100                     break;
1101
1102                 case SPI_GETSCREENSAVETIMEOUT:
1103                         timeout = MONITOR_GetScreenSaveTimeout(&MONITOR_PrimaryMonitor);
1104                         if(!timeout)
1105                             timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
1106                         *(INT16 *) lpvParam = timeout;
1107                         break;
1108
1109                 case SPI_ICONHORIZONTALSPACING:
1110                     /* FIXME Get/SetProfileInt */
1111                         if (lpvParam == NULL)
1112                             /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1113                         else
1114                             *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING );
1115                         break;
1116
1117                 case SPI_ICONVERTICALSPACING:
1118                     /* FIXME Get/SetProfileInt */
1119                     if (lpvParam == NULL)
1120                         /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1121                     else
1122                         *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING);
1123                     break;
1124
1125                 case SPI_SETBEEP:
1126                         KEYBOARD_SetBeepActive(uParam);
1127                         break;
1128
1129                 case SPI_SETSCREENSAVEACTIVE:
1130                         MONITOR_SetScreenSaveActive(&MONITOR_PrimaryMonitor, uParam);
1131                         break;
1132
1133                 case SPI_SETSCREENSAVETIMEOUT:
1134                         MONITOR_SetScreenSaveTimeout(&MONITOR_PrimaryMonitor, uParam);
1135                         break;
1136
1137                 case SPI_SETDESKWALLPAPER:
1138                         return (SetDeskWallPaper((LPSTR) lpvParam));
1139                         break;
1140
1141                 case SPI_SETDESKPATTERN:
1142                         if ((INT16)uParam == -1) {
1143                                 GetProfileStringA("Desktop", "Pattern", 
1144                                                 "170 85 170 85 170 85 170 85", 
1145                                                 buffer, sizeof(buffer) );
1146                                 return (DESKTOP_SetPattern((LPSTR) buffer));
1147                         } else
1148                                 return (DESKTOP_SetPattern((LPSTR) lpvParam));
1149                         break;
1150
1151                 case SPI_GETICONTITLELOGFONT: 
1152                 {
1153                     LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
1154
1155                     GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif", 
1156                                         lpLogFont->lfFaceName, LF_FACESIZE );
1157                     lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 8);
1158                     lpLogFont->lfWidth = 0;
1159                     lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1160                     lpLogFont->lfWeight = FW_NORMAL;
1161                     lpLogFont->lfItalic = FALSE;
1162                     lpLogFont->lfStrikeOut = FALSE;
1163                     lpLogFont->lfUnderline = FALSE;
1164                     lpLogFont->lfCharSet = ANSI_CHARSET;
1165                     lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1166                     lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1167                     lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1168                     break;
1169                 }
1170                 case SPI_GETNONCLIENTMETRICS:
1171
1172 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
1173                     if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
1174                     {
1175                         /* FIXME: initialize geometry entries */
1176                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, 
1177                                                         (LPVOID)&(lpnm->lfCaptionFont),0);
1178                         lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1179                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1180                                                         (LPVOID)&(lpnm->lfSmCaptionFont),0);
1181                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1182                                                         (LPVOID)&(lpnm->lfMenuFont),0);
1183                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1184                                                         (LPVOID)&(lpnm->lfStatusFont),0);
1185                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1186                                                         (LPVOID)&(lpnm->lfMessageFont),0);
1187                     }
1188                     else /* winfile 95 sets sbSize to 340 */
1189                         SystemParametersInfoA( uAction, uParam, lpvParam, fuWinIni );
1190 #undef lpnm
1191                     break;
1192
1193                 case SPI_LANGDRIVER:
1194                 case SPI_SETBORDER:
1195                 case SPI_SETDOUBLECLKHEIGHT:
1196                 case SPI_SETDOUBLECLICKTIME:
1197                 case SPI_SETDOUBLECLKWIDTH:
1198                 case SPI_SETFASTTASKSWITCH:
1199                 case SPI_SETKEYBOARDDELAY:
1200                 case SPI_SETKEYBOARDSPEED:
1201                         WARN(system, "Option %d ignored.\n", uAction);
1202                         break;
1203
1204                 case SPI_GETWORKAREA:
1205                     SetRect16( (RECT16 *)lpvParam, 0, 0,
1206                                GetSystemMetrics16( SM_CXSCREEN ),
1207                                GetSystemMetrics16( SM_CYSCREEN ) );
1208                     break;
1209
1210                 default:
1211                         WARN(system, "Unknown option %d.\n", uAction);
1212                         break;
1213         }
1214         return 1;
1215 }
1216
1217 /***********************************************************************
1218  *      SystemParametersInfo32W   (USER32.541)
1219  */
1220 BOOL WINAPI SystemParametersInfoW( UINT uAction, UINT uParam,
1221                                        LPVOID lpvParam, UINT fuWinIni )
1222 {
1223     char buffer[256];
1224
1225     switch (uAction)
1226     {
1227     case SPI_SETDESKWALLPAPER:
1228         if (lpvParam)
1229         {
1230             lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1231             return SetDeskWallPaper(buffer);
1232         }
1233         return SetDeskWallPaper(NULL);
1234
1235     case SPI_SETDESKPATTERN:
1236         if ((INT) uParam == -1)
1237         {
1238             GetProfileStringA("Desktop", "Pattern", 
1239                                 "170 85 170 85 170 85 170 85", 
1240                                 buffer, sizeof(buffer) );
1241             return (DESKTOP_SetPattern((LPSTR) buffer));
1242         }
1243         if (lpvParam)
1244         {
1245             lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1246             return DESKTOP_SetPattern(buffer);
1247         }
1248         return DESKTOP_SetPattern(NULL);
1249
1250     case SPI_GETICONTITLELOGFONT:
1251         {
1252             LPLOGFONTW lpLogFont = (LPLOGFONTW)lpvParam;
1253             GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif", 
1254                          buffer, sizeof(buffer) );
1255             lstrcpynAtoW(lpLogFont->lfFaceName, buffer ,LF_FACESIZE);
1256             lpLogFont->lfHeight = 10;
1257             lpLogFont->lfWidth = 0;
1258             lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1259             lpLogFont->lfWeight = FW_NORMAL;
1260             lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE;
1261             lpLogFont->lfCharSet = ANSI_CHARSET;
1262             lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1263             lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1264             lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1265         }
1266         break;
1267     case SPI_GETNONCLIENTMETRICS: {
1268         /* FIXME: implement correctly */
1269         LPNONCLIENTMETRICSW     lpnm=(LPNONCLIENTMETRICSW)lpvParam;
1270
1271         SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0);
1272         lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1273         SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfSmCaptionFont),0);
1274         SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0);
1275         SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0);
1276         SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0);
1277         break;
1278     }
1279
1280     case SPI_GETHIGHCONTRAST:
1281     {
1282        LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
1283
1284        FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1285
1286        if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
1287        {
1288           /* Indicate that there is no high contrast available */
1289           lpHighContrastW->dwFlags = 0;
1290           lpHighContrastW->lpszDefaultScheme = NULL;
1291        }
1292        else
1293        {
1294           return FALSE;
1295        }
1296
1297        break;
1298     }
1299
1300     default:
1301         return SystemParametersInfoA(uAction,uParam,lpvParam,fuWinIni);
1302         
1303     }
1304     return TRUE;
1305 }
1306
1307
1308 /***********************************************************************
1309 *       FileCDR (KERNEL.130)
1310 */
1311 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
1312 {
1313         FIXME(file,"(0x%8x): stub\n", (int) x);
1314         return (FARPROC16)TRUE;
1315 }