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