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