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