Bug fixes.
[wine/multimedia.git] / misc / main.c
blob9ec3198d89e425203a853353e6b09e085654b35f
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 CONSOLE_Close();
776 /***********************************************************************
777 * MAIN_WineInit
779 * Wine initialisation and command-line parsing
781 BOOL MAIN_WineInit( int *argc, char *argv[] )
783 struct timeval tv;
785 #ifdef MALLOC_DEBUGGING
786 char *trace;
788 mcheck(NULL);
789 if (!(trace = getenv("MALLOC_TRACE")))
791 MESSAGE( "MALLOC_TRACE not set. No trace generated\n" );
793 else
795 MESSAGE( "malloc trace goes to %s\n", trace );
796 mtrace();
798 #endif
800 setbuf(stdout,NULL);
801 setbuf(stderr,NULL);
803 setlocale(LC_CTYPE,"");
804 gettimeofday( &tv, NULL);
805 MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
807 MAIN_ParseOptions(argc, argv);
809 #ifndef X_DISPLAY_MISSING
810 USER_Driver = &X11DRV_USER_Driver;
811 #else /* !defined(X_DISPLAY_MISSING) */
812 USER_Driver = &TTYDRV_USER_Driver;
813 #endif /* !defined(X_DISPLAY_MISSING) */
815 USER_Driver->pInitialize();
817 MONITOR_Initialize(&MONITOR_PrimaryMonitor);
819 atexit(called_at_exit);
820 return TRUE;
823 /***********************************************************************
824 * MessageBeep16 (USER.104)
826 void WINAPI MessageBeep16( UINT16 i )
828 MessageBeep( i );
832 /***********************************************************************
833 * MessageBeep32 (USER32.390)
835 BOOL WINAPI MessageBeep( UINT i )
837 KEYBOARD_Beep();
838 return TRUE;
842 /***********************************************************************
843 * Beep (KERNEL32.11)
845 BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur )
847 /* dwFreq and dwDur are ignored by Win95 */
848 KEYBOARD_Beep();
849 return TRUE;
853 /***********************************************************************
854 * GetTimerResolution (USER.14)
856 LONG WINAPI GetTimerResolution16(void)
858 return (1000);
861 /***********************************************************************
862 * SystemParametersInfo32A (USER32.540)
864 BOOL WINAPI SystemParametersInfoA( UINT uAction, UINT uParam,
865 LPVOID lpvParam, UINT fuWinIni )
867 int timeout;
869 switch (uAction) {
870 case SPI_GETBEEP:
871 *(BOOL *) lpvParam = KEYBOARD_GetBeepActive();
872 break;
873 case SPI_SETBEEP:
874 KEYBOARD_SetBeepActive(uParam);
875 break;
877 case SPI_GETBORDER:
878 *(INT *)lpvParam = GetSystemMetrics( SM_CXFRAME );
879 break;
881 case SPI_GETDRAGFULLWINDOWS:
882 *(BOOL *) lpvParam = FALSE;
883 break;
885 case SPI_SETDRAGFULLWINDOWS:
886 break;
888 case SPI_GETFASTTASKSWITCH:
889 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
890 *(BOOL *) lpvParam = TRUE;
891 else
892 *(BOOL *) lpvParam = FALSE;
893 break;
895 case SPI_GETGRIDGRANULARITY:
896 *(INT*)lpvParam=GetProfileIntA("desktop","GridGranularity",1);
897 break;
899 case SPI_GETICONTITLEWRAP:
900 *(BOOL*)lpvParam=GetProfileIntA("desktop","IconTitleWrap",TRUE);
901 break;
903 case SPI_GETKEYBOARDDELAY:
904 *(INT*)lpvParam=GetProfileIntA("keyboard","KeyboardDelay",1);
905 break;
907 case SPI_GETKEYBOARDSPEED:
908 *(DWORD*)lpvParam=GetProfileIntA("keyboard","KeyboardSpeed",30);
909 break;
911 case SPI_GETMENUDROPALIGNMENT:
912 *(BOOL*)lpvParam=GetSystemMetrics(SM_MENUDROPALIGNMENT); /* XXX check this */
913 break;
915 case SPI_GETSCREENSAVEACTIVE:
916 if(MONITOR_GetScreenSaveActive(&MONITOR_PrimaryMonitor) ||
917 GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
918 *(BOOL*)lpvParam = TRUE;
919 else
920 *(BOOL*)lpvParam = FALSE;
921 break;
923 case SPI_GETSCREENSAVETIMEOUT:
924 timeout = MONITOR_GetScreenSaveTimeout(&MONITOR_PrimaryMonitor);
925 if(!timeout)
926 timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
927 *(INT *) lpvParam = timeout * 1000;
928 break;
930 case SPI_ICONHORIZONTALSPACING:
931 /* FIXME Get/SetProfileInt */
932 if (lpvParam == NULL)
933 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
934 else
935 *(INT*)lpvParam=GetSystemMetrics(SM_CXICONSPACING);
936 break;
938 case SPI_ICONVERTICALSPACING:
939 /* FIXME Get/SetProfileInt */
940 if (lpvParam == NULL)
941 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
942 else
943 *(INT*)lpvParam=GetSystemMetrics(SM_CYICONSPACING);
944 break;
946 case SPI_GETICONTITLELOGFONT: {
947 LPLOGFONTA lpLogFont = (LPLOGFONTA)lpvParam;
949 /* from now on we always have an alias for MS Sans Serif */
951 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
952 lpLogFont->lfFaceName, LF_FACESIZE );
953 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 13);
954 lpLogFont->lfWidth = 0;
955 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
956 lpLogFont->lfWeight = FW_NORMAL;
957 lpLogFont->lfItalic = FALSE;
958 lpLogFont->lfStrikeOut = FALSE;
959 lpLogFont->lfUnderline = FALSE;
960 lpLogFont->lfCharSet = ANSI_CHARSET;
961 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
962 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
963 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
964 break;
966 case SPI_GETWORKAREA:
967 SetRect( (RECT *)lpvParam, 0, 0,
968 GetSystemMetrics( SM_CXSCREEN ),
969 GetSystemMetrics( SM_CYSCREEN )
971 break;
972 case SPI_GETNONCLIENTMETRICS:
974 #define lpnm ((LPNONCLIENTMETRICSA)lpvParam)
976 if( lpnm->cbSize == sizeof(NONCLIENTMETRICSA) )
978 LPLOGFONTA lpLogFont = &(lpnm->lfMenuFont);
980 /* FIXME: initialize geometry entries */
981 /* FIXME: As these values are presumably in device units,
982 * we should calculate the defaults based on the screen dpi
984 /* caption */
985 lpnm->iCaptionWidth = ((TWEAK_WineLook > WIN31_LOOK) ? 32 : 20);
986 lpnm->iCaptionHeight = lpnm->iCaptionWidth;
987 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
988 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, (LPVOID)&(lpnm->lfCaptionFont),0);
990 /* small caption */
991 lpnm->iSmCaptionWidth = ((TWEAK_WineLook > WIN31_LOOK) ? 32 : 17);
992 lpnm->iSmCaptionHeight = lpnm->iSmCaptionWidth;
993 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, (LPVOID)&(lpnm->lfSmCaptionFont),0);
995 /* menus, FIXME: names of wine.conf entrys are bogus */
997 lpnm->iMenuWidth = GetProfileIntA("Desktop","MenuWidth", 13); /* size of the menu buttons*/
998 lpnm->iMenuHeight = GetProfileIntA("Desktop","MenuHeight",
999 (TWEAK_WineLook > WIN31_LOOK) ? 13 : 27);
1001 GetProfileStringA("Desktop", "MenuFont",
1002 (TWEAK_WineLook > WIN31_LOOK) ? "MS Sans Serif": "System",
1003 lpLogFont->lfFaceName, LF_FACESIZE );
1005 lpLogFont->lfHeight = -GetProfileIntA("Desktop","MenuFontSize", 13);
1006 lpLogFont->lfWidth = 0;
1007 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1008 lpLogFont->lfWeight = (TWEAK_WineLook > WIN31_LOOK) ? FW_NORMAL : FW_BOLD;
1009 lpLogFont->lfItalic = FALSE;
1010 lpLogFont->lfStrikeOut = FALSE;
1011 lpLogFont->lfUnderline = FALSE;
1012 lpLogFont->lfCharSet = ANSI_CHARSET;
1013 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1014 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1015 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1017 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
1018 (LPVOID)&(lpnm->lfStatusFont),0);
1019 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
1020 (LPVOID)&(lpnm->lfMessageFont),0);
1022 #undef lpnm
1023 break;
1025 case SPI_GETANIMATION: {
1026 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1028 /* Tell it "disabled" */
1029 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1030 uParam = sizeof(ANIMATIONINFO);
1031 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
1032 break;
1035 case SPI_SETANIMATION: {
1036 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1038 /* Do nothing */
1039 WARN_(system)("SPI_SETANIMATION ignored.\n");
1040 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1041 uParam = sizeof(ANIMATIONINFO);
1042 break;
1045 case SPI_GETHIGHCONTRAST:
1047 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
1049 FIXME_(system)("SPI_GETHIGHCONTRAST not fully implemented\n");
1051 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
1053 /* Indicate that there is no high contrast available */
1054 lpHighContrastA->dwFlags = 0;
1055 lpHighContrastA->lpszDefaultScheme = NULL;
1057 else
1059 return FALSE;
1062 break;
1065 default:
1066 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
1068 return TRUE;
1072 /***********************************************************************
1073 * SystemParametersInfo16 (USER.483)
1075 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
1076 LPVOID lpvParam, UINT16 fuWinIni )
1078 int timeout;
1079 char buffer[256];
1081 switch (uAction)
1083 case SPI_GETBEEP:
1084 *(BOOL *) lpvParam = KEYBOARD_GetBeepActive();
1085 break;
1087 case SPI_GETBORDER:
1088 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME );
1089 break;
1091 case SPI_GETFASTTASKSWITCH:
1092 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
1093 *(BOOL16 *) lpvParam = TRUE;
1094 else
1095 *(BOOL16 *) lpvParam = FALSE;
1096 break;
1098 case SPI_GETGRIDGRANULARITY:
1099 *(INT16 *) lpvParam = GetProfileIntA( "desktop",
1100 "GridGranularity",
1101 1 );
1102 break;
1104 case SPI_GETICONTITLEWRAP:
1105 *(BOOL16 *) lpvParam = GetProfileIntA( "desktop",
1106 "IconTitleWrap",
1107 TRUE );
1108 break;
1110 case SPI_GETKEYBOARDDELAY:
1111 *(INT16 *) lpvParam = GetProfileIntA( "keyboard",
1112 "KeyboardDelay", 1 );
1113 break;
1115 case SPI_GETKEYBOARDSPEED:
1116 *(WORD *) lpvParam = GetProfileIntA( "keyboard",
1117 "KeyboardSpeed",
1118 30 );
1119 break;
1121 case SPI_GETMENUDROPALIGNMENT:
1122 *(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */
1123 break;
1125 case SPI_GETSCREENSAVEACTIVE:
1126 if(MONITOR_GetScreenSaveActive(&MONITOR_PrimaryMonitor) ||
1127 GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
1128 *(BOOL16 *) lpvParam = TRUE;
1129 else
1130 *(BOOL16 *) lpvParam = FALSE;
1131 break;
1133 case SPI_GETSCREENSAVETIMEOUT:
1134 timeout = MONITOR_GetScreenSaveTimeout(&MONITOR_PrimaryMonitor);
1135 if(!timeout)
1136 timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
1137 *(INT16 *) lpvParam = timeout;
1138 break;
1140 case SPI_ICONHORIZONTALSPACING:
1141 /* FIXME Get/SetProfileInt */
1142 if (lpvParam == NULL)
1143 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1144 else
1145 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING );
1146 break;
1148 case SPI_ICONVERTICALSPACING:
1149 /* FIXME Get/SetProfileInt */
1150 if (lpvParam == NULL)
1151 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1152 else
1153 *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING);
1154 break;
1156 case SPI_SETBEEP:
1157 KEYBOARD_SetBeepActive(uParam);
1158 break;
1160 case SPI_SETSCREENSAVEACTIVE:
1161 MONITOR_SetScreenSaveActive(&MONITOR_PrimaryMonitor, uParam);
1162 break;
1164 case SPI_SETSCREENSAVETIMEOUT:
1165 MONITOR_SetScreenSaveTimeout(&MONITOR_PrimaryMonitor, uParam);
1166 break;
1168 case SPI_SETDESKWALLPAPER:
1169 return (SetDeskWallPaper((LPSTR) lpvParam));
1170 break;
1172 case SPI_SETDESKPATTERN:
1173 if ((INT16)uParam == -1) {
1174 GetProfileStringA("Desktop", "Pattern",
1175 "170 85 170 85 170 85 170 85",
1176 buffer, sizeof(buffer) );
1177 return (DESKTOP_SetPattern((LPSTR) buffer));
1178 } else
1179 return (DESKTOP_SetPattern((LPSTR) lpvParam));
1180 break;
1182 case SPI_GETICONTITLELOGFONT:
1184 LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
1185 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
1186 lpLogFont->lfFaceName, LF_FACESIZE );
1187 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 13);
1188 lpLogFont->lfWidth = 0;
1189 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1190 lpLogFont->lfWeight = FW_NORMAL;
1191 lpLogFont->lfItalic = FALSE;
1192 lpLogFont->lfStrikeOut = FALSE;
1193 lpLogFont->lfUnderline = FALSE;
1194 lpLogFont->lfCharSet = ANSI_CHARSET;
1195 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1196 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1197 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1198 break;
1200 case SPI_GETNONCLIENTMETRICS:
1202 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
1203 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
1205 /* FIXME: initialize geometry entries */
1206 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1207 (LPVOID)&(lpnm->lfCaptionFont),0);
1208 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1209 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1210 (LPVOID)&(lpnm->lfSmCaptionFont),0);
1211 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1212 (LPVOID)&(lpnm->lfMenuFont),0);
1213 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1214 (LPVOID)&(lpnm->lfStatusFont),0);
1215 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1216 (LPVOID)&(lpnm->lfMessageFont),0);
1218 else /* winfile 95 sets sbSize to 340 */
1219 SystemParametersInfoA( uAction, uParam, lpvParam, fuWinIni );
1220 #undef lpnm
1221 break;
1223 case SPI_LANGDRIVER:
1224 case SPI_SETBORDER:
1225 case SPI_SETDOUBLECLKHEIGHT:
1226 case SPI_SETDOUBLECLICKTIME:
1227 case SPI_SETDOUBLECLKWIDTH:
1228 case SPI_SETFASTTASKSWITCH:
1229 case SPI_SETKEYBOARDDELAY:
1230 case SPI_SETKEYBOARDSPEED:
1231 WARN_(system)("Option %d ignored.\n", uAction);
1232 break;
1234 case SPI_GETWORKAREA:
1235 SetRect16( (RECT16 *)lpvParam, 0, 0,
1236 GetSystemMetrics16( SM_CXSCREEN ),
1237 GetSystemMetrics16( SM_CYSCREEN ) );
1238 break;
1240 default:
1241 WARN_(system)("Unknown option %d.\n", uAction);
1242 break;
1244 return 1;
1247 /***********************************************************************
1248 * SystemParametersInfo32W (USER32.541)
1250 BOOL WINAPI SystemParametersInfoW( UINT uAction, UINT uParam,
1251 LPVOID lpvParam, UINT fuWinIni )
1253 char buffer[256];
1255 switch (uAction)
1257 case SPI_SETDESKWALLPAPER:
1258 if (lpvParam)
1260 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1261 return SetDeskWallPaper(buffer);
1263 return SetDeskWallPaper(NULL);
1265 case SPI_SETDESKPATTERN:
1266 if ((INT) uParam == -1)
1268 GetProfileStringA("Desktop", "Pattern",
1269 "170 85 170 85 170 85 170 85",
1270 buffer, sizeof(buffer) );
1271 return (DESKTOP_SetPattern((LPSTR) buffer));
1273 if (lpvParam)
1275 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1276 return DESKTOP_SetPattern(buffer);
1278 return DESKTOP_SetPattern(NULL);
1280 case SPI_GETICONTITLELOGFONT:
1282 LPLOGFONTW lpLogFont = (LPLOGFONTW)lpvParam;
1284 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
1285 buffer, sizeof(buffer) );
1286 lstrcpynAtoW(lpLogFont->lfFaceName, buffer, LF_FACESIZE);
1287 lpLogFont->lfHeight = 17;
1288 lpLogFont->lfWidth = 0;
1289 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1290 lpLogFont->lfWeight = FW_NORMAL;
1291 lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE;
1292 lpLogFont->lfCharSet = ANSI_CHARSET;
1293 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1294 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1295 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1297 break;
1298 case SPI_GETNONCLIENTMETRICS: {
1299 /* FIXME: implement correctly */
1300 LPNONCLIENTMETRICSW lpnm=(LPNONCLIENTMETRICSW)lpvParam;
1302 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0);
1303 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1304 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfSmCaptionFont),0);
1305 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0);
1306 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0);
1307 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0);
1308 break;
1311 case SPI_GETHIGHCONTRAST:
1313 LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
1315 FIXME_(system)("SPI_GETHIGHCONTRAST not fully implemented\n");
1317 if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
1319 /* Indicate that there is no high contrast available */
1320 lpHighContrastW->dwFlags = 0;
1321 lpHighContrastW->lpszDefaultScheme = NULL;
1323 else
1325 return FALSE;
1328 break;
1331 default:
1332 return SystemParametersInfoA(uAction,uParam,lpvParam,fuWinIni);
1335 return TRUE;
1339 /***********************************************************************
1340 * FileCDR (KERNEL.130)
1342 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
1344 FIXME_(file)("(0x%8x): stub\n", (int) x);
1345 return (FARPROC16)TRUE;