Fixed minor issues found by winapi_check.
[wine.git] / misc / main.c
bloba0254a773794d376158b9306f6ffe7fa96693aef
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, /* dllFlags */
88 FALSE, /* usePrivateMap */
89 FALSE, /* useFixedMap */
90 FALSE, /* synchronous */
91 FALSE, /* backing store */
92 SW_SHOWNORMAL, /* cmdShow */
93 FALSE,
94 FALSE, /* failReadOnly */
95 MODE_ENHANCED, /* Enhanced mode */
96 #ifdef DEFAULT_LANG
97 DEFAULT_LANG, /* Default language */
98 #else
99 LANG_En,
100 #endif
101 FALSE, /* Managed windows */
102 FALSE, /* Perfect graphics */
103 FALSE, /* No DGA */
104 FALSE, /* No XSHM */
105 NULL, /* Alternate config file name */
106 0 /* screenDepth */
109 const char *argv0;
111 static const char szUsage[] =
112 "%s\n"
113 "Usage: %s [options] \"program_name [arguments]\"\n"
114 "\n"
115 "Options:\n"
116 " -backingstore Turn on backing store\n"
117 " -config name Specify config file to use\n"
118 " -console driver Select which driver(s) to use for the console\n"
119 " -debug Enter debugger before starting application\n"
120 " -debugmsg name Turn debugging-messages on or off\n"
121 " -depth n Change the depth to use for multiple-depth screens\n"
122 " -desktop geom Use a desktop window of the given geometry\n"
123 " -display name Use the specified display\n"
124 " -dll name Enable or disable built-in DLLs\n"
125 " -failreadonly Read only files may not be opened in write mode\n"
126 " -fixedmap Use a \"standard\" color map\n"
127 " -help Show this help message\n"
128 " -iconic Start as an icon\n"
129 " -language xx Set the language (one of Ca,Cs,Da,De,En,Eo,Es,Fi,Fr,Hu,It,\n"
130 " Ko,Nl,No,Pl,Pt,Sv,Ru,Wa)\n"
131 " -managed Allow the window manager to manage created windows\n"
132 " -mode mode Start Wine in a particular mode (standard or enhanced)\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<3)
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, 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 (debug_ch_name && (!lstrncmpiA(debug_ch_name[i],options+1,5))){
237 for(j=0; j<DEBUG_CLASS_COUNT; j++)
238 if(cls == -1 || cls == j)
239 __SET_DEBUGGING( j, i, 1 );
240 break;
242 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
243 if (i==DEBUG_CHANNEL_COUNT)
244 goto error;
245 output = (*options == '+') ?
246 ((*(options+1) == 'r') ?
247 &debug_relay_includelist :
248 &debug_snoop_includelist) :
249 ((*(options+1) == 'r') ?
250 &debug_relay_excludelist :
251 &debug_snoop_excludelist);
252 s = options + 7;
253 /* if there are n ':', there are n+1 modules, and we need n+2 slots
254 * last one being for the sentinel (NULL) */
255 i = 2;
256 while((s = strchr(s, ':'))) i++, s++;
257 *output = malloc(sizeof(char **) * i);
258 i = 0;
259 s = options + 7;
260 while((s2 = strchr(s, ':'))) {
261 c = *s2;
262 *s2 = '\0';
263 *((*output)+i) = CharUpperA(strdup(s));
264 *s2 = c;
265 s = s2 + 1;
266 i++;
268 c = *(options + l);
269 *(options + l) = '\0';
270 *((*output)+i) = CharUpperA(strdup(s));
271 *(options + l) = c;
272 *((*output)+i+1) = NULL;
274 else
276 int i, j;
277 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
278 if (debug_ch_name && (!lstrncmpiA(options+1,debug_ch_name[i],l-1))){
279 for(j=0; j<DEBUG_CLASS_COUNT; j++)
280 if(cls == -1 || cls == j)
281 __SET_DEBUGGING( j, i, (*options=='+') );
282 break;
284 if (i==DEBUG_CHANNEL_COUNT)
285 goto error;
287 options+=l;
289 while((*options==',')&&(*(++options)));
291 /* special handling for relay debugging */
292 if (dotracerelay != TRACE_ON(relay))
293 BUILTIN32_SwitchRelayDebug( TRACE_ON(relay) );
295 if (!*options)
296 return TRUE;
298 error:
299 MESSAGE("%s: Syntax: -debugmsg [class]+xxx,... or "
300 "-debugmsg [class]-xxx,...\n",Options.argv[0]);
301 MESSAGE("Example: -debugmsg +all,warn-heap\n"
302 " turn on all messages except warning heap messages\n");
303 MESSAGE("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
304 " turn on -debugmsg +relay only as specified\n"
305 "Special case: -debugmsg -relay=DLL:DLL.###:FuncName\n"
306 " turn on -debugmsg +relay except as specified\n"
307 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
309 MESSAGE("Available message classes:\n");
310 for(i=0;i<DEBUG_CLASS_COUNT;i++)
311 MESSAGE( "%-9s", debug_cl_name[i]);
312 MESSAGE("\n\n");
314 MESSAGE("Available message types:\n");
315 MESSAGE("%-9s ","all");
316 for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
317 if(debug_ch_name[i])
318 MESSAGE("%-9s%c",debug_ch_name[i],
319 (((i+2)%8==0)?'\n':' '));
320 MESSAGE("\n\n");
321 ExitProcess(1);
322 return FALSE;
325 /***********************************************************************
326 * MAIN_GetLanguageID
328 * INPUT:
329 * Lang: a string whose two first chars are the iso name of a language.
330 * Country: a string whose two first chars are the iso name of country
331 * Charset: a string defining the chossen charset encoding
332 * Dialect: a string defining a variation of the locale
334 * all those values are from the standardized format of locale
335 * name in unix which is: Lang[_Country][.Charset][@Dialect]
337 * RETURNS:
338 * the numeric code of the language used by Windows (or 0x00)
340 int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
342 char lang[3]="??", country[3]={0,0,0};
343 char *charset=NULL, *dialect=NULL;
344 int i,j,ret=0;
346 if (Lang==NULL) return 0x00;
347 if (Lang[0]) lang[0]=tolower(Lang[0]);
348 if (Lang[1]) lang[1]=tolower(Lang[1]);
350 if (Country!=NULL) {
351 if (Country[0]) country[0]=toupper(Country[0]);
352 if (Country[1]) country[1]=toupper(Country[1]);
355 if (Charset!=NULL) {
356 j=strlen(Charset);
357 charset=(char*)malloc(j+1);
358 for (i=0;i<j;i++)
359 charset[i]=toupper(Charset[i]);
360 charset[i]='\0';
363 if (Dialect!=NULL) {
364 j=strlen(Dialect);
365 dialect=(char*)malloc(j+1);
366 for (i=0;i<j;i++)
367 dialect[i]=tolower(Dialect[i]);
368 dialect[i]='\0';
369 } else {
370 dialect = malloc(1);
371 dialect[0] = '\0';
374 #define LANG_ENTRY_BEGIN(x,y) if(!strcmp(lang, x )) { \
375 if (!country[0]) { \
376 ret=LANG_##y ; \
377 goto end_MAIN_GetLanguageID; \
379 #define LANG_SUB_ENTRY(x,y,z) if (!strcmp(country, x )) \
380 ret = MAKELANGID( LANG_##y , SUBLANG_##z ); \
381 goto end_MAIN_GetLanguageID;
382 #define LANG_DIALECT_ENTRY(x,y) { ret = MAKELANGID(LANG_##x , SUBLANG_##y ); \
383 goto end_MAIN_GetLanguageID; }
384 #define LANG_ENTRY_END(x) ret = MAKELANGID(LANG_##x , SUBLANG_DEFAULT); \
385 goto end_MAIN_GetLanguageID; \
388 /*x01*/ LANG_ENTRY_BEGIN( "ar", ARABIC )
389 LANG_SUB_ENTRY( "SA", ARABIC, ARABIC)
390 LANG_SUB_ENTRY( "IQ", ARABIC, ARABIC_IRAQ )
391 LANG_SUB_ENTRY( "EG", ARABIC, ARABIC_EGYPT )
392 LANG_SUB_ENTRY( "LY", ARABIC, ARABIC_LIBYA )
393 LANG_SUB_ENTRY( "DZ", ARABIC, ARABIC_ALGERIA )
394 LANG_SUB_ENTRY( "MA", ARABIC, ARABIC_MOROCCO )
395 LANG_SUB_ENTRY( "TN", ARABIC, ARABIC_TUNISIA )
396 LANG_SUB_ENTRY( "OM", ARABIC, ARABIC_OMAN )
397 LANG_SUB_ENTRY( "YE", ARABIC, ARABIC_YEMEN )
398 LANG_SUB_ENTRY( "SY", ARABIC, ARABIC_SYRIA )
399 LANG_SUB_ENTRY( "JO", ARABIC, ARABIC_JORDAN )
400 LANG_SUB_ENTRY( "LB", ARABIC, ARABIC_LEBANON )
401 LANG_SUB_ENTRY( "KW", ARABIC, ARABIC_KUWAIT )
402 LANG_SUB_ENTRY( "AE", ARABIC, ARABIC_UAE )
403 LANG_SUB_ENTRY( "BH", ARABIC, ARABIC_BAHRAIN )
404 LANG_SUB_ENTRY( "QA", ARABIC, ARABIC_QATAR )
405 LANG_ENTRY_END( ARABIC )
406 /*x02*/ LANG_ENTRY_BEGIN( "bu", BULGARIAN )
407 LANG_ENTRY_END( BULGARIAN )
408 /*x03*/ LANG_ENTRY_BEGIN( "ca", CATALAN )
409 LANG_ENTRY_END( CATALAN )
410 /*x04*/ LANG_ENTRY_BEGIN( "zh", CHINESE )
411 LANG_SUB_ENTRY( "TW", CHINESE, CHINESE_TRADITIONAL )
412 LANG_SUB_ENTRY( "CN", CHINESE, CHINESE_SIMPLIFIED )
413 LANG_SUB_ENTRY( "HK", CHINESE, CHINESE_HONGKONG )
414 LANG_SUB_ENTRY( "SG", CHINESE, CHINESE_SINGAPORE )
415 LANG_SUB_ENTRY( "MO", CHINESE, CHINESE_MACAU )
416 LANG_ENTRY_END( CHINESE )
417 /*x05*/ LANG_ENTRY_BEGIN( "cs", CZECH )
418 LANG_ENTRY_END( CZECH )
419 /*x06*/ LANG_ENTRY_BEGIN( "da", DANISH )
420 LANG_ENTRY_END( DANISH )
421 /*x07*/ LANG_ENTRY_BEGIN( "de", GERMAN )
422 LANG_SUB_ENTRY( "DE", GERMAN, GERMAN )
423 LANG_SUB_ENTRY( "CH", GERMAN, GERMAN_SWISS )
424 LANG_SUB_ENTRY( "AT", GERMAN, GERMAN_AUSTRIAN )
425 LANG_SUB_ENTRY( "LU", GERMAN, GERMAN_LUXEMBOURG )
426 LANG_SUB_ENTRY( "LI", GERMAN, GERMAN_LIECHTENSTEIN )
427 LANG_ENTRY_END( GERMAN )
428 /*x08*/ LANG_ENTRY_BEGIN( "el", GREEK )
429 LANG_ENTRY_END( GREEK )
430 /*x09*/ LANG_ENTRY_BEGIN( "en", ENGLISH )
431 LANG_SUB_ENTRY( "US", ENGLISH, ENGLISH_US )
432 LANG_SUB_ENTRY( "UK", ENGLISH, ENGLISH_UK )
433 LANG_SUB_ENTRY( "AU", ENGLISH, ENGLISH_AUS )
434 LANG_SUB_ENTRY( "CA", ENGLISH, ENGLISH_CAN )
435 LANG_SUB_ENTRY( "NZ", ENGLISH, ENGLISH_NZ )
436 LANG_SUB_ENTRY( "EI", ENGLISH, ENGLISH_EIRE )
437 LANG_SUB_ENTRY( "ZA", ENGLISH, ENGLISH_SAFRICA )
438 LANG_SUB_ENTRY( "JM", ENGLISH, ENGLISH_JAMAICA )
439 /* LANG_SUB_ENTRY( "AG", ENGLISH, ENGLISH_CARIBBEAN ) */
440 LANG_SUB_ENTRY( "BZ", ENGLISH, ENGLISH_BELIZE )
441 LANG_SUB_ENTRY( "TT", ENGLISH, ENGLISH_TRINIDAD )
442 LANG_SUB_ENTRY( "ZW", ENGLISH, ENGLISH_ZIMBABWE )
443 LANG_SUB_ENTRY( "PH", ENGLISH, ENGLISH_PHILIPPINES )
444 LANG_ENTRY_END( ENGLISH )
445 /*x0a*/ LANG_ENTRY_BEGIN( "es", SPANISH )
446 /* traditional sorting */
447 if (!strcmp(dialect,"tradicional"))
448 LANG_DIALECT_ENTRY( SPANISH, SPANISH )
449 LANG_SUB_ENTRY( "MX", SPANISH, SPANISH_MEXICAN )
450 LANG_SUB_ENTRY( "ES", SPANISH, SPANISH_MODERN )
451 LANG_SUB_ENTRY( "GT", SPANISH, SPANISH_GUATEMALA )
452 LANG_SUB_ENTRY( "CR", SPANISH, SPANISH_COSTARICA )
453 LANG_SUB_ENTRY( "PA", SPANISH, SPANISH_PANAMA )
454 LANG_SUB_ENTRY( "DO", SPANISH, SPANISH_DOMINICAN )
455 LANG_SUB_ENTRY( "VE", SPANISH, SPANISH_VENEZUELA )
456 LANG_SUB_ENTRY( "CO", SPANISH, SPANISH_COLOMBIA )
457 LANG_SUB_ENTRY( "PE", SPANISH, SPANISH_PERU )
458 LANG_SUB_ENTRY( "AR", SPANISH, SPANISH_ARGENTINA )
459 LANG_SUB_ENTRY( "EC", SPANISH, SPANISH_ECUADOR )
460 LANG_SUB_ENTRY( "CL", SPANISH, SPANISH_CHILE )
461 LANG_SUB_ENTRY( "UY", SPANISH, SPANISH_URUGUAY )
462 LANG_SUB_ENTRY( "PY", SPANISH, SPANISH_PARAGUAY )
463 LANG_SUB_ENTRY( "BO", SPANISH, SPANISH_BOLIVIA )
464 LANG_SUB_ENTRY( "HN", SPANISH, SPANISH_HONDURAS )
465 LANG_SUB_ENTRY( "NI", SPANISH, SPANISH_NICARAGUA )
466 LANG_SUB_ENTRY( "PR", SPANISH, SPANISH_PUERTO_RICO )
467 LANG_ENTRY_END( SPANISH )
468 /*x0b*/ LANG_ENTRY_BEGIN( "fi", FINNISH )
469 LANG_ENTRY_END( FINNISH )
470 /*x0c*/ LANG_ENTRY_BEGIN( "fr", FRENCH )
471 LANG_SUB_ENTRY( "FR", FRENCH, FRENCH )
472 LANG_SUB_ENTRY( "BE", FRENCH, FRENCH_BELGIAN )
473 LANG_SUB_ENTRY( "CA", FRENCH, FRENCH_CANADIAN )
474 LANG_SUB_ENTRY( "CH", FRENCH, FRENCH_SWISS )
475 LANG_SUB_ENTRY( "LU", FRENCH, FRENCH_LUXEMBOURG )
476 LANG_SUB_ENTRY( "MC", FRENCH, FRENCH_MONACO )
477 LANG_ENTRY_END( FRENCH )
478 /*x0d*/ LANG_ENTRY_BEGIN( "iw", HEBREW )
479 LANG_ENTRY_END( HEBREW )
480 /*x0e*/ LANG_ENTRY_BEGIN( "hu", HUNGARIAN )
481 LANG_ENTRY_END( HUNGARIAN )
482 /*x0f*/ LANG_ENTRY_BEGIN( "ic", ICELANDIC )
483 LANG_ENTRY_END( ICELANDIC )
484 /*x10*/ LANG_ENTRY_BEGIN( "it", ITALIAN )
485 LANG_SUB_ENTRY( "IT", ITALIAN, ITALIAN )
486 LANG_SUB_ENTRY( "CH", ITALIAN, ITALIAN_SWISS )
487 LANG_ENTRY_END( ITALIAN )
488 /*x11*/ LANG_ENTRY_BEGIN( "ja", JAPANESE )
489 LANG_ENTRY_END( JAPANESE )
490 /*x12*/ LANG_ENTRY_BEGIN( "ko", KOREAN )
491 /* JOHAB encoding */
492 if (!strcmp(charset,"JOHAB"))
493 LANG_DIALECT_ENTRY( KOREAN, KOREAN_JOHAB )
494 else
495 LANG_DIALECT_ENTRY( KOREAN, KOREAN )
496 LANG_ENTRY_END( KOREAN )
497 /*x13*/ LANG_ENTRY_BEGIN( "nl", DUTCH )
498 LANG_SUB_ENTRY( "NL", DUTCH, DUTCH )
499 LANG_SUB_ENTRY( "BE", DUTCH, DUTCH_BELGIAN )
500 LANG_SUB_ENTRY( "SR", DUTCH, DUTCH_SURINAM )
501 LANG_ENTRY_END( DUTCH )
502 /*x14*/ LANG_ENTRY_BEGIN( "no", NORWEGIAN )
503 /* nynorsk */
504 if (!strcmp(dialect,"nynorsk"))
505 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_NYNORSK )
506 else
507 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_BOKMAL )
508 LANG_ENTRY_END( NORWEGIAN )
509 /*x15*/ LANG_ENTRY_BEGIN( "pl", POLISH )
510 LANG_ENTRY_END( POLISH )
511 /*x16*/ LANG_ENTRY_BEGIN( "pt", PORTUGUESE )
512 LANG_SUB_ENTRY( "BR", PORTUGUESE, PORTUGUESE_BRAZILIAN )
513 LANG_SUB_ENTRY( "PT", PORTUGUESE, PORTUGUESE )
514 LANG_ENTRY_END( PORTUGUESE )
515 /*x17*/ LANG_ENTRY_BEGIN( "rm", RHAETO_ROMANCE )
516 LANG_ENTRY_END( RHAETO_ROMANCE )
517 /*x18*/ LANG_ENTRY_BEGIN( "ro", ROMANIAN )
518 LANG_SUB_ENTRY( "RO", ROMANIAN, ROMANIAN )
519 LANG_SUB_ENTRY( "MD", ROMANIAN, ROMANIAN_MOLDAVIA )
520 LANG_ENTRY_END( ROMANIAN )
521 /*x19*/ LANG_ENTRY_BEGIN( "ru", RUSSIAN )
522 LANG_SUB_ENTRY( "RU", RUSSIAN, RUSSIAN )
523 LANG_SUB_ENTRY( "MD", RUSSIAN, RUSSIAN_MOLDAVIA )
524 LANG_ENTRY_END( RUSSIAN )
525 /*x1a*/ if (!strcmp(lang,"sh") || !strcmp(lang,"hr") || !strcmp(lang,"sr")) {
526 if (!country[0])
527 LANG_DIALECT_ENTRY( SERBO_CROATIAN, NEUTRAL)
528 if (!strcmp(charset,"ISO-8859-5"))
529 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN )
530 LANG_SUB_ENTRY( "HR", SERBO_CROATIAN, CROATIAN )
531 if (!strcmp(country,"YU") && !strcmp(charset,"ISO-8859-2"))
532 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
533 LANG_SUB_ENTRY( "YU", SERBO_CROATIAN, SERBIAN )
534 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
536 /*x1b*/ LANG_ENTRY_BEGIN( "sk", SLOVAK )
537 LANG_ENTRY_END( SLOVAK )
538 /*x1c*/ LANG_ENTRY_BEGIN( "sq", ALBANIAN )
539 LANG_ENTRY_END( ALBANIAN )
540 /*x1d*/ LANG_ENTRY_BEGIN( "sv", SWEDISH )
541 LANG_SUB_ENTRY( "SE", SWEDISH, SWEDISH )
542 LANG_SUB_ENTRY( "FI", SWEDISH, SWEDISH_FINLAND )
543 LANG_ENTRY_END( SWEDISH )
544 /*x1e*/ LANG_ENTRY_BEGIN( "th", THAI )
545 LANG_ENTRY_END( THAI )
546 /*x1f*/ LANG_ENTRY_BEGIN( "tr", TURKISH )
547 LANG_ENTRY_END( TURKISH )
548 /*x20*/ LANG_ENTRY_BEGIN( "ur", URDU )
549 LANG_ENTRY_END( URDU )
550 /*x21*/ LANG_ENTRY_BEGIN( "in", INDONESIAN )
551 LANG_ENTRY_END( INDONESIAN )
552 /*x22*/ LANG_ENTRY_BEGIN( "uk", UKRAINIAN )
553 LANG_ENTRY_END( UKRAINIAN )
554 /*x23*/ LANG_ENTRY_BEGIN( "be", BYELORUSSIAN )
555 LANG_ENTRY_END( BYELORUSSIAN )
556 /*x24*/ LANG_ENTRY_BEGIN( "sl", SLOVENIAN )
557 LANG_ENTRY_END( SLOVENIAN )
558 /*x25*/ LANG_ENTRY_BEGIN( "et", ESTONIAN )
559 LANG_ENTRY_END( ESTONIAN )
560 /*x26*/ LANG_ENTRY_BEGIN( "lv", LATVIAN )
561 LANG_ENTRY_END( LATVIAN )
562 /*x27*/ LANG_ENTRY_BEGIN( "lt", LITHUANIAN )
563 /* traditional sorting ? */
564 if (!strcmp(dialect,"classic") || !strcmp(dialect,"traditional"))
565 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN_CLASSIC )
566 else
567 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN )
568 LANG_ENTRY_END( LITHUANIAN )
569 /*x28*/ LANG_ENTRY_BEGIN( "mi", MAORI )
570 LANG_ENTRY_END( MAORI )
571 /*x29*/ LANG_ENTRY_BEGIN( "fa", FARSI )
572 LANG_ENTRY_END( FARSI )
573 /*x2a*/ LANG_ENTRY_BEGIN( "vi", VIETNAMESE )
574 LANG_ENTRY_END( VIETNAMESE )
575 /*x2b*/ LANG_ENTRY_BEGIN( "hy", ARMENIAN )
576 LANG_ENTRY_END( ARMENIAN )
577 /*x2c*/ LANG_ENTRY_BEGIN( "az", AZERI )
578 /* Cyrillic */
579 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
580 LANG_DIALECT_ENTRY( AZERI, AZERI_CYRILLIC )
581 else
582 LANG_DIALECT_ENTRY( AZERI, AZERI )
583 LANG_ENTRY_END( AZERI )
584 /*x2d*/ LANG_ENTRY_BEGIN( "eu", BASQUE )
585 LANG_ENTRY_END( BASQUE )
586 /*x2e*/ /*LANG_ENTRY_BEGIN( "??", SORBIAN )
587 LANG_ENTRY_END( SORBIAN ) */
588 /*x2f*/ LANG_ENTRY_BEGIN( "mk", MACEDONIAN )
589 LANG_ENTRY_END( MACEDONIAN )
590 /*x30*/ /*LANG_ENTRY_BEGIN( "??", SUTU )
591 LANG_ENTRY_END( SUTU ) */
592 /*x31*/ LANG_ENTRY_BEGIN( "ts", TSONGA )
593 LANG_ENTRY_END( TSONGA )
594 /*x32*/ /*LANG_ENTRY_BEGIN( "??", TSWANA )
595 LANG_ENTRY_END( TSWANA ) */
596 /*x33*/ /*LANG_ENTRY_BEGIN( "??", VENDA )
597 LANG_ENTRY_END( VENDA ) */
598 /*x34*/ LANG_ENTRY_BEGIN( "xh", XHOSA )
599 LANG_ENTRY_END( XHOSA )
600 /*x35*/ LANG_ENTRY_BEGIN( "zu", ZULU )
601 LANG_ENTRY_END( ZULU )
602 /*x36*/ LANG_ENTRY_BEGIN( "af", AFRIKAANS )
603 LANG_ENTRY_END( AFRIKAANS )
604 /*x37*/ LANG_ENTRY_BEGIN( "ka", GEORGIAN )
605 LANG_ENTRY_END( GEORGIAN )
606 /*x38*/ LANG_ENTRY_BEGIN( "fo", FAEROESE )
607 LANG_ENTRY_END( FAEROESE )
608 /*x39*/ LANG_ENTRY_BEGIN( "hi", HINDI )
609 LANG_ENTRY_END( HINDI )
610 /*x3a*/ LANG_ENTRY_BEGIN( "mt", MALTESE )
611 LANG_ENTRY_END( MALTESE )
612 /*x3b*/ /*LANG_ENTRY_BEGIN( "??", SAAMI )
613 LANG_ENTRY_END( SAAMI ) */
614 /*x3c*/ LANG_ENTRY_BEGIN( "ga", GAELIC )
615 LANG_DIALECT_ENTRY( GAELIC, GAELIC )
616 LANG_ENTRY_END( GAELIC )
617 /*x3c*/ LANG_ENTRY_BEGIN( "gd", GAELIC )
618 LANG_DIALECT_ENTRY( GAELIC, GAELIC_SCOTTISH )
619 LANG_ENTRY_END( GAELIC )
620 /* 0x3d */
621 /*x3e*/ LANG_ENTRY_BEGIN( "ms", MALAY )
622 LANG_SUB_ENTRY( "MY", MALAY, MALAY )
623 LANG_SUB_ENTRY( "BN", MALAY, MALAY_BRUNEI_DARUSSALAM )
624 LANG_ENTRY_END( MALAY )
625 /*x3f*/ LANG_ENTRY_BEGIN( "kk", KAZAKH )
626 LANG_ENTRY_END( KAZAKH )
627 /* 0x40 */
628 /*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI )
629 LANG_ENTRY_END( SWAHILI )
630 /* 0x42 */
631 /*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK )
632 /* Cyrillic */
633 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
634 LANG_DIALECT_ENTRY( UZBEK, UZBEK_CYRILLIC )
635 else
636 LANG_DIALECT_ENTRY( UZBEK, UZBEK )
637 LANG_ENTRY_END( UZBEK )
638 /*x44*/ LANG_ENTRY_BEGIN( "tt", TATAR )
639 LANG_ENTRY_END( TATAR )
640 /*x45*/ LANG_ENTRY_BEGIN( "bn", BENGALI )
641 LANG_ENTRY_END( BENGALI )
642 /*x46*/ LANG_ENTRY_BEGIN( "pa", PUNJABI )
643 LANG_ENTRY_END( PUNJABI )
644 /*x47*/ LANG_ENTRY_BEGIN( "gu", GUJARATI )
645 LANG_ENTRY_END( GUJARATI )
646 /*x48*/ LANG_ENTRY_BEGIN( "or", ORIYA )
647 LANG_ENTRY_END( ORIYA )
648 /*x49*/ LANG_ENTRY_BEGIN( "ta", TAMIL )
649 LANG_ENTRY_END( TAMIL )
650 /*x4a*/ LANG_ENTRY_BEGIN( "te", TELUGU )
651 LANG_ENTRY_END( TELUGU )
652 /*x4b*/ LANG_ENTRY_BEGIN( "kn", KANNADA )
653 LANG_ENTRY_END( KANNADA )
654 /*x4c*/ LANG_ENTRY_BEGIN( "ml", MALAYALAM )
655 LANG_ENTRY_END( MALAYALAM )
656 /*x4d*/ LANG_ENTRY_BEGIN( "as", ASSAMESE )
657 LANG_ENTRY_END( ASSAMESE )
658 /*x4e*/ LANG_ENTRY_BEGIN( "mr", MARATHI )
659 LANG_ENTRY_END( MARATHI )
660 /*x4f*/ LANG_ENTRY_BEGIN( "sa", SANSKRIT )
661 LANG_ENTRY_END( SANSKRIT )
662 /* 0x50 -> 0x56 */
663 /*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
664 LANG_ENTRY_END( KONKANI ) */
665 /* 0x58 -> ... */
666 LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */
667 LANG_ENTRY_END( ESPERANTO )
668 LANG_ENTRY_BEGIN( "wa", WALON ) /* not official */
669 LANG_ENTRY_END( WALON )
671 ret = LANG_ENGLISH;
673 end_MAIN_GetLanguageID:
674 if (Charset) free(charset);
675 free(dialect);
677 return ret;
680 /***********************************************************************
681 * MAIN_ParseLanguageOption
683 * Parse -language option.
685 void MAIN_ParseLanguageOption( char *arg )
687 const WINE_LANGUAGE_DEF *p = Languages;
689 /* for compatibility whith non-iso names previously used */
690 if (!strcmp("Sw",arg)) { strcpy(arg,"Sv"); FIXME_(system)("use 'Sv' instead of 'Sw'\n");}
691 if (!strcmp("Cz",arg)) { strcpy(arg,"Cs"); FIXME_(system)("use 'Cs' instead of 'Cz'\n");}
692 if (!strcmp("Po",arg)) { strcpy(arg,"Pt"); FIXME_(system)("use 'Pt' instead of 'Po'\n");}
694 Options.language = LANG_Xx; /* First (dummy) language */
695 for (;p->name;p++)
697 if (!lstrcmpiA( p->name, arg ))
699 WINE_LanguageId = p->langid;
700 return;
702 Options.language++;
704 MESSAGE( "Invalid language specified '%s'. Supported languages are: ", arg );
705 for (p = Languages; p->name; p++) MESSAGE( "%s ", p->name );
706 MESSAGE( "\n" );
707 ExitProcess(1);
711 /***********************************************************************
712 * MAIN_ParseModeOption
714 * Parse -mode option.
716 void MAIN_ParseModeOption( char *arg )
718 if (!lstrcmpiA("enhanced", arg)) Options.mode = MODE_ENHANCED;
719 else if (!lstrcmpiA("standard", arg)) Options.mode = MODE_STANDARD;
720 else
722 MESSAGE( "Invalid mode '%s' specified.\n", arg);
723 MESSAGE( "Valid modes are: 'standard', 'enhanced' (default).\n");
724 ExitProcess(1);
728 /***********************************************************************
729 * MAIN_ParseOptions
731 * Parse command line options and open display.
733 static void MAIN_ParseOptions( int *argc, char *argv[] )
735 int i;
736 char *pcDot;
738 Options.argc = argc;
739 Options.argv = argv;
740 Options.programName = MAIN_GetProgramName( *argc, argv );
742 /* initialise Options.language to 0 to tell "no language choosen yet" */
743 Options.language = 0;
745 /* make sure there is no "." in Options.programName to confuse the X
746 resource database lookups */
747 if ((pcDot = strchr(Options.programName, '.'))) *pcDot = '\0';
749 for (i = 1; i < *argc; i++)
751 if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
753 MESSAGE( "%s\n", WINE_RELEASE_INFO );
754 ExitProcess(0);
756 if (!strcmp( argv[i], "-h" ) || !strcmp( argv[i], "-help" ))
758 MAIN_Usage(argv[0]);
759 ExitProcess(0);
764 /***********************************************************************
765 * called_at_exit
767 static void called_at_exit(void)
769 if (GDI_Driver)
770 GDI_Driver->pFinalize();
771 if (USER_Driver)
772 USER_Driver->pFinalize();
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;