Moved error codes to cderr.h.
[wine/multimedia.git] / misc / main.c
blob005e75c2ad794854f83969123057574ab2e4d8f2
1 /*
2 * Main function.
4 * Copyright 1994 Alexandre Julliard
5 */
7 #include "config.h"
9 #ifndef X_DISPLAY_MISSING
10 #include "ts_xlib.h"
11 #include "x11drv.h"
12 #else /* X_DISPLAY_MISSING */
13 #include "ttydrv.h"
14 #endif /* X_DISPLAY_MISSING */
16 #include <locale.h>
17 #include <ctype.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <unistd.h>
21 #ifdef MALLOC_DEBUGGING
22 # include <malloc.h>
23 #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 "debug.h"
34 #include "debugdefs.h"
35 #include "xmalloc.h"
36 #include "version.h"
37 #include "winnls.h"
38 #include "console.h"
39 #include "monitor.h"
41 /* when adding new languages look at ole/ole2nls.c
42 * for proper iso name and Windows code (add 0x0400
43 * to the code listed there)
45 const WINE_LANGUAGE_DEF Languages[] =
47 {"En",0x0409}, /* LANG_En */
48 {"Es",0x040A}, /* LANG_Es */
49 {"De",0x0407}, /* LANG_De */
50 {"No",0x0414}, /* LANG_No */
51 {"Fr",0x040C}, /* LANG_Fr */
52 {"Fi",0x040B}, /* LANG_Fi */
53 {"Da",0x0406}, /* LANG_Da */
54 {"Cs",0x0405}, /* LANG_Cs */
55 {"Eo",0x048f}, /* LANG_Eo */
56 {"It",0x0410}, /* LANG_It */
57 {"Ko",0x0412}, /* LANG_Ko */
58 {"Hu",0x040e}, /* LANG_Hu */
59 {"Pl",0x0415}, /* LANG_Pl */
60 {"Pt",0x0416}, /* LANG_Pt */
61 {"Sv",0x041d}, /* LANG_Sv */
62 {"Ca",0x0403}, /* LANG_Ca */
63 {"Nl",0x0413}, /* LANG_Nl */
64 {"Ru",0x0419}, /* LANG_Ru */
65 {NULL,0}
68 WORD WINE_LanguageId = 0x409; /* english as default */
70 struct options Options =
71 { /* default options */
72 0, /* argc */
73 NULL, /* argv */
74 NULL, /* desktopGeometry */
75 NULL, /* programName */
76 NULL, /* argv0 */
77 NULL, /* dllFlags */
78 FALSE, /* usePrivateMap */
79 FALSE, /* useFixedMap */
80 FALSE, /* synchronous */
81 FALSE, /* backing store */
82 SW_SHOWNORMAL, /* cmdShow */
83 FALSE,
84 FALSE, /* failReadOnly */
85 MODE_ENHANCED, /* Enhanced mode */
86 #ifdef DEFAULT_LANG
87 DEFAULT_LANG, /* Default language */
88 #else
89 LANG_En,
90 #endif
91 FALSE, /* Managed windows */
92 FALSE, /* Perfect graphics */
93 FALSE, /* No DGA */
94 NULL, /* Alternate config file name */
95 0 /* screenDepth */
98 static char szUsage[] =
99 "%s\n"
100 "Usage: %s [options] \"program_name [arguments]\"\n"
101 #ifndef X_DISPLAY_MISSING
102 "\n"
103 "Options:\n"
104 " -backingstore Turn on backing store\n"
105 " -config name Specify config file to use\n"
106 " -console driver Select which driver(s) to use for the console\n"
107 " -debug Enter debugger before starting application\n"
108 " -debugmsg name Turn debugging-messages on or off\n"
109 " -depth n Change the depth to use for multiple-depth screens\n"
110 " -desktop geom Use a desktop window of the given geometry\n"
111 " -display name Use the specified display\n"
112 " -dll name Enable or disable built-in DLLs\n"
113 " -failreadonly Read only files may not be opened in write mode\n"
114 " -fixedmap Use a \"standard\" color map\n"
115 " -help Show this help message\n"
116 " -iconic Start as an icon\n"
117 " -language xx Set the language (one of Ca,Cs,Da,De,En,Eo,Es,Fi,Fr,Hu,It,\n"
118 " Ko,Nl,No,Pl,Pt,Sv,Ru)\n"
119 " -managed Allow the window manager to manage created windows\n"
120 " -mode mode Start Wine in a particular mode (standard or enhanced)\n"
121 " -name name Set the application name\n"
122 " -nodga Disable XFree86 DGA extensions\n"
123 " -perfect Favor correctness over speed for graphical operations\n"
124 " -privatemap Use a private color map\n"
125 " -synchronous Turn on synchronous display mode\n"
126 " -version Display the Wine version\n"
127 " -winver Version to imitate (one of win31,win95,nt351,nt40)\n"
128 " -dosver DOS version to imitate (x.xx, e.g. 6.22). Only valid with -winver win31\n"
129 #endif /* X_DISPLAY_MISSING */
132 /***********************************************************************
133 * MAIN_Usage
135 void MAIN_Usage( char *name )
137 MSG( szUsage, WINE_RELEASE_INFO, name );
138 exit(1);
141 /***********************************************************************
142 * MAIN_GetProgramName
144 * Get the program name. The name is specified by (in order of precedence):
145 * - the option '-name'.
146 * - the environment variable 'WINE_NAME'.
147 * - the last component of argv[0].
149 static char *MAIN_GetProgramName( int argc, char *argv[] )
151 int i;
152 char *p;
154 for (i = 1; i < argc-1; i++)
155 if (!strcmp( argv[i], "-name" )) return argv[i+1];
156 if ((p = getenv( "WINE_NAME" )) != NULL) return p;
157 if ((p = strrchr( argv[0], '/' )) != NULL) return p+1;
158 return argv[0];
161 /***********************************************************************
162 * MAIN_ParseDebugOptions
164 * Turns specific debug messages on or off, according to "options".
166 * RETURNS
167 * TRUE if parsing was successful
169 BOOL MAIN_ParseDebugOptions(char *options)
171 /* defined in relay32/relay386.c */
172 extern char **debug_relay_includelist;
173 extern char **debug_relay_excludelist;
174 /* defined in relay32/snoop.c */
175 extern char **debug_snoop_includelist;
176 extern char **debug_snoop_excludelist;
178 int i;
179 int l, cls, dotracerelay = TRACE_ON(relay);
181 l = strlen(options);
182 if (l<3)
183 return FALSE;
184 if (options[l-1]=='\n') options[l-1]='\0';
187 if ((*options!='+')&&(*options!='-')){
188 int j;
190 for(j=0; j<DEBUG_CLASS_COUNT; j++)
191 if(!lstrncmpiA(options, debug_cl_name[j], strlen(debug_cl_name[j])))
192 break;
193 if(j==DEBUG_CLASS_COUNT)
194 goto error;
195 options += strlen(debug_cl_name[j]);
196 if ((*options!='+')&&(*options!='-'))
197 goto error;
198 cls = j;
200 else
201 cls = -1; /* all classes */
203 if (strchr(options,','))
204 l=strchr(options,',')-options;
205 else
206 l=strlen(options);
208 if (!lstrncmpiA(options+1,"all",l-1))
210 int i, j;
211 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
212 for(j=0; j<DEBUG_CLASS_COUNT; j++)
213 if(cls == -1 || cls == j)
214 debug_msg_enabled[i][j]=(*options=='+');
216 else if (!lstrncmpiA(options+1, "relay=", 6) ||
217 !lstrncmpiA(options+1, "snoop=", 6))
219 int i, j;
220 char *s, *s2, ***output, c;
222 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
223 if (debug_ch_name && (!lstrncmpiA(debug_ch_name[i],options+1,5))){
224 for(j=0; j<DEBUG_CLASS_COUNT; j++)
225 if(cls == -1 || cls == j)
226 debug_msg_enabled[i][j]=TRUE;
227 break;
229 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
230 if (i==DEBUG_CHANNEL_COUNT)
231 goto error;
232 output = (*options == '+') ?
233 ((*(options+1) == 'r') ?
234 &debug_relay_includelist :
235 &debug_snoop_includelist) :
236 ((*(options+1) == 'r') ?
237 &debug_relay_excludelist :
238 &debug_snoop_excludelist);
239 s = options + 7;
240 i = 1;
241 while((s = strchr(s, ':'))) i++, s++;
242 *output = malloc(sizeof(char **) * i + 1);
243 i = 0;
244 s = options + 7;
245 while((s2 = strchr(s, ':'))) {
246 c = *s2;
247 *s2 = '\0';
248 *((*output)+i) = strdup(s);
249 *s2 = c;
250 s = s2 + 1;
251 i++;
253 c = *(options + l);
254 *(options + l) = '\0';
255 *((*output)+i) = strdup(s);
256 *(options + l) = c;
257 *((*output)+i+1) = NULL;
259 else
261 int i, j;
262 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
263 if (debug_ch_name && (!lstrncmpiA(options+1,debug_ch_name[i],l-1))){
264 for(j=0; j<DEBUG_CLASS_COUNT; j++)
265 if(cls == -1 || cls == j)
266 debug_msg_enabled[i][j]=(*options=='+');
267 break;
269 if (i==DEBUG_CHANNEL_COUNT)
270 goto error;
272 options+=l;
274 while((*options==',')&&(*(++options)));
276 /* special handling for relay debugging */
277 if (dotracerelay != TRACE_ON(relay))
278 BUILTIN32_SwitchRelayDebug( TRACE_ON(relay) );
280 if (!*options)
281 return TRUE;
283 error:
284 MSG("%s: Syntax: -debugmsg [class]+xxx,... or "
285 "-debugmsg [class]-xxx,...\n",Options.argv[0]);
286 MSG("Example: -debugmsg +all,warn-heap\n"
287 " turn on all messages except warning heap messages\n");
288 MSG("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
289 " turn on -debugmsg +relay only as specified\n"
290 "Special case: -debugmsg -relay=DLL:DLL.###:FuncName\n"
291 " turn on -debugmsg +relay except as specified\n"
292 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
294 MSG("Available message classes:\n");
295 for(i=0;i<DEBUG_CLASS_COUNT;i++)
296 MSG( "%-9s", debug_cl_name[i]);
297 MSG("\n\n");
299 MSG("Available message types:\n");
300 MSG("%-9s ","all");
301 for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
302 if(debug_ch_name[i])
303 MSG("%-9s%c",debug_ch_name[i],
304 (((i+2)%8==0)?'\n':' '));
305 MSG("\n\n");
306 exit(1);
309 /***********************************************************************
310 * MAIN_GetLanguageID
312 * INPUT:
313 * Lang: a string whose two first chars are the iso name of a language.
314 * Country: a string whose two first chars are the iso name of country
315 * Charset: a string defining the chossen charset encoding
316 * Dialect: a string defining a variation of the locale
318 * all those values are from the standardized format of locale
319 * name in unix which is: Lang[_Country][.Charset][@Dialect]
321 * RETURNS:
322 * the numeric code of the language used by Windows (or 0x00)
324 int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
326 char lang[3]="??", country[3]={0,0,0};
327 char *charset=NULL, *dialect=NULL;
328 int i,j,ret=0;
330 if (Lang==NULL) return 0x00;
331 if (Lang[0]) lang[0]=tolower(Lang[0]);
332 if (Lang[1]) lang[1]=tolower(Lang[1]);
334 if (Country!=NULL) {
335 if (Country[0]) country[0]=toupper(Country[0]);
336 if (Country[1]) country[1]=toupper(Country[1]);
339 if (Charset!=NULL) {
340 j=strlen(Charset);
341 charset=(char*)malloc(j+1);
342 for (i=0;i<j;i++)
343 charset[i]=toupper(Charset[i]);
344 charset[i]='\0';
347 if (Dialect!=NULL) {
348 j=strlen(Dialect);
349 dialect=(char*)malloc(j+1);
350 for (i=0;i<j;i++)
351 dialect[i]=tolower(Dialect[i]);
352 dialect[i]='\0';
353 } else {
354 dialect = malloc(1);
355 dialect[0] = '\0';
358 #define LANG_ENTRY_BEGIN(x,y) if(!strcmp(lang, x )) { \
359 if (!country[0]) { \
360 ret=LANG_##y ; \
361 goto end_MAIN_GetLanguageID; \
363 #define LANG_SUB_ENTRY(x,y,z) if (!strcmp(country, x )) \
364 ret = MAKELANGID( LANG_##y , SUBLANG_##z ); \
365 goto end_MAIN_GetLanguageID;
366 #define LANG_DIALECT_ENTRY(x,y) { ret = MAKELANGID(LANG_##x , SUBLANG_##y ); \
367 goto end_MAIN_GetLanguageID; }
368 #define LANG_ENTRY_END(x) ret = MAKELANGID(LANG_##x , SUBLANG_DEFAULT); \
369 goto end_MAIN_GetLanguageID; \
372 /*x01*/ LANG_ENTRY_BEGIN( "ar", ARABIC )
373 LANG_SUB_ENTRY( "SA", ARABIC, ARABIC)
374 LANG_SUB_ENTRY( "IQ", ARABIC, ARABIC_IRAQ )
375 LANG_SUB_ENTRY( "EG", ARABIC, ARABIC_EGYPT )
376 LANG_SUB_ENTRY( "LY", ARABIC, ARABIC_LIBYA )
377 LANG_SUB_ENTRY( "DZ", ARABIC, ARABIC_ALGERIA )
378 LANG_SUB_ENTRY( "MA", ARABIC, ARABIC_MOROCCO )
379 LANG_SUB_ENTRY( "TN", ARABIC, ARABIC_TUNISIA )
380 LANG_SUB_ENTRY( "OM", ARABIC, ARABIC_OMAN )
381 LANG_SUB_ENTRY( "YE", ARABIC, ARABIC_YEMEN )
382 LANG_SUB_ENTRY( "SY", ARABIC, ARABIC_SYRIA )
383 LANG_SUB_ENTRY( "JO", ARABIC, ARABIC_JORDAN )
384 LANG_SUB_ENTRY( "LB", ARABIC, ARABIC_LEBANON )
385 LANG_SUB_ENTRY( "KW", ARABIC, ARABIC_KUWAIT )
386 LANG_SUB_ENTRY( "AE", ARABIC, ARABIC_UAE )
387 LANG_SUB_ENTRY( "BH", ARABIC, ARABIC_BAHRAIN )
388 LANG_SUB_ENTRY( "QA", ARABIC, ARABIC_QATAR )
389 LANG_ENTRY_END( ARABIC )
390 /*x02*/ LANG_ENTRY_BEGIN( "bu", BULGARIAN )
391 LANG_ENTRY_END( BULGARIAN )
392 /*x03*/ LANG_ENTRY_BEGIN( "ca", CATALAN )
393 LANG_ENTRY_END( CATALAN )
394 /*x04*/ LANG_ENTRY_BEGIN( "zh", CHINESE )
395 LANG_SUB_ENTRY( "TW", CHINESE, CHINESE_TRADITIONAL )
396 LANG_SUB_ENTRY( "CN", CHINESE, CHINESE_SIMPLIFIED )
397 LANG_SUB_ENTRY( "HK", CHINESE, CHINESE_HONGKONG )
398 LANG_SUB_ENTRY( "SG", CHINESE, CHINESE_SINGAPORE )
399 LANG_SUB_ENTRY( "MO", CHINESE, CHINESE_MACAU )
400 LANG_ENTRY_END( CHINESE )
401 /*x05*/ LANG_ENTRY_BEGIN( "cs", CZECH )
402 LANG_ENTRY_END( CZECH )
403 /*x06*/ LANG_ENTRY_BEGIN( "da", DANISH )
404 LANG_ENTRY_END( DANISH )
405 /*x07*/ LANG_ENTRY_BEGIN( "de", GERMAN )
406 LANG_SUB_ENTRY( "DE", GERMAN, GERMAN )
407 LANG_SUB_ENTRY( "CH", GERMAN, GERMAN_SWISS )
408 LANG_SUB_ENTRY( "AT", GERMAN, GERMAN_AUSTRIAN )
409 LANG_SUB_ENTRY( "LU", GERMAN, GERMAN_LUXEMBOURG )
410 LANG_SUB_ENTRY( "LI", GERMAN, GERMAN_LIECHTENSTEIN )
411 LANG_ENTRY_END( GERMAN )
412 /*x08*/ LANG_ENTRY_BEGIN( "el", GREEK )
413 LANG_ENTRY_END( GREEK )
414 /*x09*/ LANG_ENTRY_BEGIN( "en", ENGLISH )
415 LANG_SUB_ENTRY( "US", ENGLISH, ENGLISH_US )
416 LANG_SUB_ENTRY( "UK", ENGLISH, ENGLISH_UK )
417 LANG_SUB_ENTRY( "AU", ENGLISH, ENGLISH_AUS )
418 LANG_SUB_ENTRY( "CA", ENGLISH, ENGLISH_CAN )
419 LANG_SUB_ENTRY( "NZ", ENGLISH, ENGLISH_NZ )
420 LANG_SUB_ENTRY( "EI", ENGLISH, ENGLISH_EIRE )
421 LANG_SUB_ENTRY( "ZA", ENGLISH, ENGLISH_SAFRICA )
422 LANG_SUB_ENTRY( "JM", ENGLISH, ENGLISH_JAMAICA )
423 /* LANG_SUB_ENTRY( "AG", ENGLISH, ENGLISH_CARIBBEAN ) */
424 LANG_SUB_ENTRY( "BZ", ENGLISH, ENGLISH_BELIZE )
425 LANG_SUB_ENTRY( "TT", ENGLISH, ENGLISH_TRINIDAD )
426 LANG_SUB_ENTRY( "ZW", ENGLISH, ENGLISH_ZIMBABWE )
427 LANG_SUB_ENTRY( "PH", ENGLISH, ENGLISH_PHILIPPINES )
428 LANG_ENTRY_END( ENGLISH )
429 /*x0a*/ LANG_ENTRY_BEGIN( "es", SPANISH )
430 /* traditional sorting */
431 if (!strcmp(dialect,"tradicional"))
432 LANG_DIALECT_ENTRY( SPANISH, SPANISH )
433 LANG_SUB_ENTRY( "MX", SPANISH, SPANISH_MEXICAN )
434 LANG_SUB_ENTRY( "ES", SPANISH, SPANISH_MODERN )
435 LANG_SUB_ENTRY( "GT", SPANISH, SPANISH_GUATEMALA )
436 LANG_SUB_ENTRY( "CR", SPANISH, SPANISH_COSTARICA )
437 LANG_SUB_ENTRY( "PA", SPANISH, SPANISH_PANAMA )
438 LANG_SUB_ENTRY( "DO", SPANISH, SPANISH_DOMINICAN )
439 LANG_SUB_ENTRY( "VE", SPANISH, SPANISH_VENEZUELA )
440 LANG_SUB_ENTRY( "CO", SPANISH, SPANISH_COLOMBIA )
441 LANG_SUB_ENTRY( "PE", SPANISH, SPANISH_PERU )
442 LANG_SUB_ENTRY( "AR", SPANISH, SPANISH_ARGENTINA )
443 LANG_SUB_ENTRY( "EC", SPANISH, SPANISH_ECUADOR )
444 LANG_SUB_ENTRY( "CL", SPANISH, SPANISH_CHILE )
445 LANG_SUB_ENTRY( "UY", SPANISH, SPANISH_URUGUAY )
446 LANG_SUB_ENTRY( "PY", SPANISH, SPANISH_PARAGUAY )
447 LANG_SUB_ENTRY( "BO", SPANISH, SPANISH_BOLIVIA )
448 LANG_SUB_ENTRY( "HN", SPANISH, SPANISH_HONDURAS )
449 LANG_SUB_ENTRY( "NI", SPANISH, SPANISH_NICARAGUA )
450 LANG_SUB_ENTRY( "PR", SPANISH, SPANISH_PUERTO_RICO )
451 LANG_ENTRY_END( SPANISH )
452 /*x0b*/ LANG_ENTRY_BEGIN( "fi", FINNISH )
453 LANG_ENTRY_END( FINNISH )
454 /*x0c*/ LANG_ENTRY_BEGIN( "fr", FRENCH )
455 LANG_SUB_ENTRY( "FR", FRENCH, FRENCH )
456 LANG_SUB_ENTRY( "BE", FRENCH, FRENCH_BELGIAN )
457 LANG_SUB_ENTRY( "CA", FRENCH, FRENCH_CANADIAN )
458 LANG_SUB_ENTRY( "CH", FRENCH, FRENCH_SWISS )
459 LANG_SUB_ENTRY( "LU", FRENCH, FRENCH_LUXEMBOURG )
460 LANG_SUB_ENTRY( "MC", FRENCH, FRENCH_MONACO )
461 LANG_ENTRY_END( FRENCH )
462 /*x0d*/ LANG_ENTRY_BEGIN( "iw", HEBREW )
463 LANG_ENTRY_END( HEBREW )
464 /*x0e*/ LANG_ENTRY_BEGIN( "hu", HUNGARIAN )
465 LANG_ENTRY_END( HUNGARIAN )
466 /*x0f*/ LANG_ENTRY_BEGIN( "ic", ICELANDIC )
467 LANG_ENTRY_END( ICELANDIC )
468 /*x10*/ LANG_ENTRY_BEGIN( "it", ITALIAN )
469 LANG_SUB_ENTRY( "IT", ITALIAN, ITALIAN )
470 LANG_SUB_ENTRY( "CH", ITALIAN, ITALIAN_SWISS )
471 LANG_ENTRY_END( ITALIAN )
472 /*x11*/ LANG_ENTRY_BEGIN( "ja", JAPANESE )
473 LANG_ENTRY_END( JAPANESE )
474 /*x12*/ LANG_ENTRY_BEGIN( "ko", KOREAN )
475 /* JOHAB encoding */
476 if (!strcmp(charset,"JOHAB"))
477 LANG_DIALECT_ENTRY( KOREAN, KOREAN_JOHAB )
478 else
479 LANG_DIALECT_ENTRY( KOREAN, KOREAN )
480 LANG_ENTRY_END( KOREAN )
481 /*x13*/ LANG_ENTRY_BEGIN( "nl", DUTCH )
482 LANG_SUB_ENTRY( "NL", DUTCH, DUTCH )
483 LANG_SUB_ENTRY( "BE", DUTCH, DUTCH_BELGIAN )
484 LANG_SUB_ENTRY( "SR", DUTCH, DUTCH_SURINAM )
485 LANG_ENTRY_END( DUTCH )
486 /*x14*/ LANG_ENTRY_BEGIN( "no", NORWEGIAN )
487 /* nynorsk */
488 if (!strcmp(dialect,"nynorsk"))
489 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_NYNORSK )
490 else
491 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_BOKMAL )
492 LANG_ENTRY_END( NORWEGIAN )
493 /*x15*/ LANG_ENTRY_BEGIN( "pl", POLISH )
494 LANG_ENTRY_END( POLISH )
495 /*x16*/ LANG_ENTRY_BEGIN( "pt", PORTUGUESE )
496 LANG_SUB_ENTRY( "BR", PORTUGUESE, PORTUGUESE_BRAZILIAN )
497 LANG_SUB_ENTRY( "PT", PORTUGUESE, PORTUGUESE )
498 LANG_ENTRY_END( PORTUGUESE )
499 /*x17*/ LANG_ENTRY_BEGIN( "rm", RHAETO_ROMANCE )
500 LANG_ENTRY_END( RHAETO_ROMANCE )
501 /*x18*/ LANG_ENTRY_BEGIN( "ro", ROMANIAN )
502 LANG_SUB_ENTRY( "RO", ROMANIAN, ROMANIAN )
503 LANG_SUB_ENTRY( "MD", ROMANIAN, ROMANIAN_MOLDAVIA )
504 LANG_ENTRY_END( ROMANIAN )
505 /*x19*/ LANG_ENTRY_BEGIN( "ru", RUSSIAN )
506 LANG_SUB_ENTRY( "RU", RUSSIAN, RUSSIAN )
507 LANG_SUB_ENTRY( "MD", RUSSIAN, RUSSIAN_MOLDAVIA )
508 LANG_ENTRY_END( RUSSIAN )
509 /*x1a*/ if (!strcmp(lang,"sh") || !strcmp(lang,"hr") || !strcmp(lang,"sr")) {
510 if (!country[0])
511 LANG_DIALECT_ENTRY( SERBO_CROATIAN, NEUTRAL)
512 if (!strcmp(charset,"ISO-8859-5"))
513 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN )
514 LANG_SUB_ENTRY( "HR", SERBO_CROATIAN, CROATIAN )
515 if (!strcmp(country,"YU") && !strcmp(charset,"ISO-8859-2"))
516 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
517 LANG_SUB_ENTRY( "YU", SERBO_CROATIAN, SERBIAN )
518 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
520 /*x1b*/ LANG_ENTRY_BEGIN( "sk", SLOVAK )
521 LANG_ENTRY_END( SLOVAK )
522 /*x1c*/ LANG_ENTRY_BEGIN( "sq", ALBANIAN )
523 LANG_ENTRY_END( ALBANIAN )
524 /*x1d*/ LANG_ENTRY_BEGIN( "sv", SWEDISH )
525 LANG_SUB_ENTRY( "SE", SWEDISH, SWEDISH )
526 LANG_SUB_ENTRY( "FI", SWEDISH, SWEDISH_FINLAND )
527 LANG_ENTRY_END( SWEDISH )
528 /*x1e*/ LANG_ENTRY_BEGIN( "th", THAI )
529 LANG_ENTRY_END( THAI )
530 /*x1f*/ LANG_ENTRY_BEGIN( "tr", TURKISH )
531 LANG_ENTRY_END( TURKISH )
532 /*x20*/ LANG_ENTRY_BEGIN( "ur", URDU )
533 LANG_ENTRY_END( URDU )
534 /*x21*/ LANG_ENTRY_BEGIN( "in", INDONESIAN )
535 LANG_ENTRY_END( INDONESIAN )
536 /*x22*/ LANG_ENTRY_BEGIN( "uk", UKRAINIAN )
537 LANG_ENTRY_END( UKRAINIAN )
538 /*x23*/ LANG_ENTRY_BEGIN( "be", BYELORUSSIAN )
539 LANG_ENTRY_END( BYELORUSSIAN )
540 /*x24*/ LANG_ENTRY_BEGIN( "sl", SLOVENIAN )
541 LANG_ENTRY_END( SLOVENIAN )
542 /*x25*/ LANG_ENTRY_BEGIN( "et", ESTONIAN )
543 LANG_ENTRY_END( ESTONIAN )
544 /*x26*/ LANG_ENTRY_BEGIN( "lv", LATVIAN )
545 LANG_ENTRY_END( LATVIAN )
546 /*x27*/ LANG_ENTRY_BEGIN( "lt", LITHUANIAN )
547 /* traditional sorting ? */
548 if (!strcmp(dialect,"classic") || !strcmp(dialect,"traditional"))
549 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN_CLASSIC )
550 else
551 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN )
552 LANG_ENTRY_END( LITHUANIAN )
553 /*x28*/ LANG_ENTRY_BEGIN( "mi", MAORI )
554 LANG_ENTRY_END( MAORI )
555 /*x29*/ LANG_ENTRY_BEGIN( "fa", FARSI )
556 LANG_ENTRY_END( FARSI )
557 /*x2a*/ LANG_ENTRY_BEGIN( "vi", VIETNAMESE )
558 LANG_ENTRY_END( VIETNAMESE )
559 /*x2b*/ LANG_ENTRY_BEGIN( "hy", ARMENIAN )
560 LANG_ENTRY_END( ARMENIAN )
561 /*x2c*/ LANG_ENTRY_BEGIN( "az", AZERI )
562 /* Cyrillic */
563 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
564 LANG_DIALECT_ENTRY( AZERI, AZERI_CYRILLIC )
565 else
566 LANG_DIALECT_ENTRY( AZERI, AZERI )
567 LANG_ENTRY_END( AZERI )
568 /*x2d*/ LANG_ENTRY_BEGIN( "eu", BASQUE )
569 LANG_ENTRY_END( BASQUE )
570 /*x2e*/ /*LANG_ENTRY_BEGIN( "??", SORBIAN )
571 LANG_ENTRY_END( SORBIAN ) */
572 /*x2f*/ LANG_ENTRY_BEGIN( "mk", MACEDONIAN )
573 LANG_ENTRY_END( MACEDONIAN )
574 /*x30*/ /*LANG_ENTRY_BEGIN( "??", SUTU )
575 LANG_ENTRY_END( SUTU ) */
576 /*x31*/ LANG_ENTRY_BEGIN( "ts", TSONGA )
577 LANG_ENTRY_END( TSONGA )
578 /*x32*/ /*LANG_ENTRY_BEGIN( "??", TSWANA )
579 LANG_ENTRY_END( TSWANA ) */
580 /*x33*/ /*LANG_ENTRY_BEGIN( "??", VENDA )
581 LANG_ENTRY_END( VENDA ) */
582 /*x34*/ LANG_ENTRY_BEGIN( "xh", XHOSA )
583 LANG_ENTRY_END( XHOSA )
584 /*x35*/ LANG_ENTRY_BEGIN( "zu", ZULU )
585 LANG_ENTRY_END( ZULU )
586 /*x36*/ LANG_ENTRY_BEGIN( "af", AFRIKAANS )
587 LANG_ENTRY_END( AFRIKAANS )
588 /*x37*/ LANG_ENTRY_BEGIN( "ka", GEORGIAN )
589 LANG_ENTRY_END( GEORGIAN )
590 /*x38*/ LANG_ENTRY_BEGIN( "fo", FAEROESE )
591 LANG_ENTRY_END( FAEROESE )
592 /*x39*/ LANG_ENTRY_BEGIN( "hi", HINDI )
593 LANG_ENTRY_END( HINDI )
594 /*x3a*/ LANG_ENTRY_BEGIN( "mt", MALTESE )
595 LANG_ENTRY_END( MALTESE )
596 /*x3b*/ /*LANG_ENTRY_BEGIN( "??", SAAMI )
597 LANG_ENTRY_END( SAAMI ) */
598 /*x3c*/ LANG_ENTRY_BEGIN( "ga", GAELIC )
599 LANG_DIALECT_ENTRY( GAELIC, GAELIC )
600 LANG_ENTRY_END( GAELIC )
601 /*x3c*/ LANG_ENTRY_BEGIN( "gd", GAELIC )
602 LANG_DIALECT_ENTRY( GAELIC, GAELIC_SCOTTISH )
603 LANG_ENTRY_END( GAELIC )
604 /* 0x3d */
605 /*x3e*/ LANG_ENTRY_BEGIN( "ms", MALAY )
606 LANG_SUB_ENTRY( "MY", MALAY, MALAY )
607 LANG_SUB_ENTRY( "BN", MALAY, MALAY_BRUNEI_DARUSSALAM )
608 LANG_ENTRY_END( MALAY )
609 /*x3f*/ LANG_ENTRY_BEGIN( "kk", KAZAKH )
610 LANG_ENTRY_END( KAZAKH )
611 /* 0x40 */
612 /*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI )
613 LANG_ENTRY_END( SWAHILI )
614 /* 0x42 */
615 /*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK )
616 /* Cyrillic */
617 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
618 LANG_DIALECT_ENTRY( UZBEK, UZBEK_CYRILLIC )
619 else
620 LANG_DIALECT_ENTRY( UZBEK, UZBEK )
621 LANG_ENTRY_END( UZBEK )
622 /*x44*/ LANG_ENTRY_BEGIN( "tt", TATAR )
623 LANG_ENTRY_END( TATAR )
624 /*x45*/ LANG_ENTRY_BEGIN( "bn", BENGALI )
625 LANG_ENTRY_END( BENGALI )
626 /*x46*/ LANG_ENTRY_BEGIN( "pa", PUNJABI )
627 LANG_ENTRY_END( PUNJABI )
628 /*x47*/ LANG_ENTRY_BEGIN( "gu", GUJARATI )
629 LANG_ENTRY_END( GUJARATI )
630 /*x48*/ LANG_ENTRY_BEGIN( "or", ORIYA )
631 LANG_ENTRY_END( ORIYA )
632 /*x49*/ LANG_ENTRY_BEGIN( "ta", TAMIL )
633 LANG_ENTRY_END( TAMIL )
634 /*x4a*/ LANG_ENTRY_BEGIN( "te", TELUGU )
635 LANG_ENTRY_END( TELUGU )
636 /*x4b*/ LANG_ENTRY_BEGIN( "kn", KANNADA )
637 LANG_ENTRY_END( KANNADA )
638 /*x4c*/ LANG_ENTRY_BEGIN( "ml", MALAYALAM )
639 LANG_ENTRY_END( MALAYALAM )
640 /*x4d*/ LANG_ENTRY_BEGIN( "as", ASSAMESE )
641 LANG_ENTRY_END( ASSAMESE )
642 /*x4e*/ LANG_ENTRY_BEGIN( "mr", MARATHI )
643 LANG_ENTRY_END( MARATHI )
644 /*x4f*/ LANG_ENTRY_BEGIN( "sa", SANSKRIT )
645 LANG_ENTRY_END( SANSKRIT )
646 /* 0x50 -> 0x56 */
647 /*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
648 LANG_ENTRY_END( KONKANI ) */
649 /* 0x58 -> ... */
650 LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */
651 LANG_ENTRY_END( ESPERANTO )
653 ret = LANG_ENGLISH;
655 end_MAIN_GetLanguageID:
656 if (Charset) free(charset);
657 free(dialect);
659 return ret;
662 /***********************************************************************
663 * MAIN_ParseLanguageOption
665 * Parse -language option.
667 void MAIN_ParseLanguageOption( char *arg )
669 const WINE_LANGUAGE_DEF *p = Languages;
671 /* for compatibility whith non-iso names previously used */
672 if (!strcmp("Sw",arg)) { strcpy(arg,"Sv"); FIXME(system,"use 'Sv' instead of 'Sw'\n");}
673 if (!strcmp("Cz",arg)) { strcpy(arg,"Cs"); FIXME(system,"use 'Cs' instead of 'Cz'\n");}
674 if (!strcmp("Po",arg)) { strcpy(arg,"Pt"); FIXME(system,"use 'Pt' instead of 'Po'\n");}
676 Options.language = LANG_Xx; /* First (dummy) language */
677 for (;p->name;p++)
679 if (!lstrcmpiA( p->name, arg ))
681 WINE_LanguageId = p->langid;
682 return;
684 Options.language++;
686 MSG( "Invalid language specified '%s'. Supported languages are: ", arg );
687 for (p = Languages; p->name; p++) MSG( "%s ", p->name );
688 MSG( "\n" );
689 exit(1);
693 /***********************************************************************
694 * MAIN_ParseModeOption
696 * Parse -mode option.
698 void MAIN_ParseModeOption( char *arg )
700 if (!lstrcmpiA("enhanced", arg)) Options.mode = MODE_ENHANCED;
701 else if (!lstrcmpiA("standard", arg)) Options.mode = MODE_STANDARD;
702 else
704 MSG( "Invalid mode '%s' specified.\n", arg);
705 MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
706 exit(1);
710 /***********************************************************************
711 * MAIN_ParseOptions
713 * Parse command line options and open display.
715 static void MAIN_ParseOptions( int *argc, char *argv[] )
717 int i;
718 char *pcDot;
720 Options.argc = argc;
721 Options.argv = argv;
722 Options.programName = MAIN_GetProgramName( *argc, argv );
723 Options.argv0 = argv[0];
725 /* initialise Options.language to 0 to tell "no language choosen yet" */
726 Options.language = 0;
728 /* make sure there is no "." in Options.programName to confuse the X
729 resource database lookups */
730 if ((pcDot = strchr(Options.programName, '.'))) *pcDot = '\0';
732 for (i = 1; i < *argc; i++)
734 if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
736 MSG( "%s\n", WINE_RELEASE_INFO );
737 exit(0);
739 if (!strcmp( argv[i], "-h" ) || !strcmp( argv[i], "-help" ))
741 MAIN_Usage(argv[0]);
742 exit(0);
746 #ifndef X_DISPLAY_MISSING
747 X11DRV_MAIN_ParseOptions(argc,argv);
748 #else /* X_DISPLAY_MISSING */
749 TTYDRV_MAIN_ParseOptions(argc,argv);
750 #endif /* X_DISPLAY_MISSING */
753 /***********************************************************************
754 * called_at_exit
756 static void called_at_exit(void)
758 #ifndef X_DISPLAY_MISSING
759 X11DRV_MAIN_RestoreSetup();
760 #else /* X_DISPLAY_MISSING */
761 TTYDRV_MAIN_RestoreSetup();
762 #endif /* X_DISPLAY_MISSING */
763 COLOR_Cleanup();
764 WINSOCK_Shutdown();
765 /* FIXME: should check for other processes or threads */
766 DeleteCriticalSection( HEAP_SystemLock );
767 CONSOLE_Close();
770 /***********************************************************************
771 * MAIN_WineInit
773 * Wine initialisation and command-line parsing
775 BOOL MAIN_WineInit( int *argc, char *argv[] )
777 struct timeval tv;
779 #ifdef MALLOC_DEBUGGING
780 char *trace;
782 mcheck(NULL);
783 if (!(trace = getenv("MALLOC_TRACE")))
785 MSG( "MALLOC_TRACE not set. No trace generated\n" );
787 else
789 MSG( "malloc trace goes to %s\n", trace );
790 mtrace();
792 #endif
794 setbuf(stdout,NULL);
795 setbuf(stderr,NULL);
797 setlocale(LC_CTYPE,"");
798 gettimeofday( &tv, NULL);
799 MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
801 #ifndef X_DISPLAY_MISSING
802 X11DRV_MAIN_Initialize();
803 MAIN_ParseOptions( argc, argv );
804 X11DRV_MAIN_Create();
805 X11DRV_MAIN_SaveSetup();
806 #else /* !defined(X_DISPLAY_MISSING) */
807 TTYDRV_MAIN_Initialize();
808 MAIN_ParseOptions( argc, argv );
809 TTYDRV_MAIN_Create();
810 TTYDRV_MAIN_SaveSetup();
811 #endif /* !defined(X_DISPLAY_MISSING) */
813 #ifndef X_DISPLAY_MISSING
814 MONITOR_PrimaryMonitor.pDriver = &X11DRV_MONITOR_Driver;
815 #else /* !defined(X_DISPLAY_MISSING) */
816 MONITOR_PrimaryMonitor.pDriver = &TTYDRV_MONITOR_Driver;
817 #endif /* !defined(X_DISPLAY_MISSING) */
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 TSXBell( display, 0 );
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 TSXBell(display, 0);
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;
869 int temp;
870 XKeyboardState keyboard_state;
872 switch (uAction) {
873 case SPI_GETBEEP:
874 TSXGetKeyboardControl(display, &keyboard_state);
875 if (keyboard_state.bell_percent == 0)
876 *(BOOL *) lpvParam = FALSE;
877 else
878 *(BOOL *) lpvParam = TRUE;
879 break;
881 case SPI_GETBORDER:
882 *(INT *)lpvParam = GetSystemMetrics( SM_CXFRAME );
883 break;
885 case SPI_GETDRAGFULLWINDOWS:
886 *(BOOL *) lpvParam = FALSE;
887 break;
889 case SPI_SETDRAGFULLWINDOWS:
890 break;
892 case SPI_GETFASTTASKSWITCH:
893 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
894 *(BOOL *) lpvParam = TRUE;
895 else
896 *(BOOL *) lpvParam = FALSE;
897 break;
899 case SPI_GETGRIDGRANULARITY:
900 *(INT*)lpvParam=GetProfileIntA("desktop","GridGranularity",1);
901 break;
903 case SPI_GETICONTITLEWRAP:
904 *(BOOL*)lpvParam=GetProfileIntA("desktop","IconTitleWrap",TRUE);
905 break;
907 case SPI_GETKEYBOARDDELAY:
908 *(INT*)lpvParam=GetProfileIntA("keyboard","KeyboardDelay",1);
909 break;
911 case SPI_GETKEYBOARDSPEED:
912 *(DWORD*)lpvParam=GetProfileIntA("keyboard","KeyboardSpeed",30);
913 break;
915 case SPI_GETMENUDROPALIGNMENT:
916 *(BOOL*)lpvParam=GetSystemMetrics(SM_MENUDROPALIGNMENT); /* XXX check this */
917 break;
919 case SPI_GETSCREENSAVEACTIVE:
920 if ( GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1 )
921 *(BOOL*)lpvParam = TRUE;
922 else
923 *(BOOL*)lpvParam = FALSE;
924 break;
926 case SPI_GETSCREENSAVETIMEOUT:
927 #ifndef X_DISPLAY_MISSING
928 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
929 #else /* X_DISPLAY_MISSING */
930 timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
931 #endif /* X_DISPLAY_MISSING */
932 *(INT *) lpvParam = timeout * 1000;
933 break;
935 case SPI_ICONHORIZONTALSPACING:
936 /* FIXME Get/SetProfileInt */
937 if (lpvParam == NULL)
938 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
939 else
940 *(INT*)lpvParam=GetSystemMetrics(SM_CXICONSPACING);
941 break;
943 case SPI_ICONVERTICALSPACING:
944 /* FIXME Get/SetProfileInt */
945 if (lpvParam == NULL)
946 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
947 else
948 *(INT*)lpvParam=GetSystemMetrics(SM_CYICONSPACING);
949 break;
951 case SPI_GETICONTITLELOGFONT: {
952 LPLOGFONTA lpLogFont = (LPLOGFONTA)lpvParam;
954 /* from now on we always have an alias for MS Sans Serif */
956 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
957 lpLogFont->lfFaceName, LF_FACESIZE );
958 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 8);
959 lpLogFont->lfWidth = 0;
960 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
961 lpLogFont->lfWeight = FW_NORMAL;
962 lpLogFont->lfItalic = FALSE;
963 lpLogFont->lfStrikeOut = FALSE;
964 lpLogFont->lfUnderline = FALSE;
965 lpLogFont->lfCharSet = ANSI_CHARSET;
966 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
967 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
968 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
969 break;
971 case SPI_GETWORKAREA:
972 SetRect( (RECT *)lpvParam, 0, 0,
973 GetSystemMetrics( SM_CXSCREEN ),
974 GetSystemMetrics( SM_CYSCREEN )
976 break;
977 case SPI_GETNONCLIENTMETRICS:
979 #define lpnm ((LPNONCLIENTMETRICSA)lpvParam)
981 if( lpnm->cbSize == sizeof(NONCLIENTMETRICSA) )
983 /* FIXME: initialize geometry entries */
985 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
986 (LPVOID)&(lpnm->lfCaptionFont),0);
987 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
988 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
989 (LPVOID)&(lpnm->lfSmCaptionFont),0);
990 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
991 (LPVOID)&(lpnm->lfMenuFont),0);
992 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
993 (LPVOID)&(lpnm->lfStatusFont),0);
994 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
995 (LPVOID)&(lpnm->lfMessageFont),0);
997 #undef lpnm
998 break;
1000 case SPI_GETANIMATION: {
1001 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1003 /* Tell it "disabled" */
1004 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1005 uParam = sizeof(ANIMATIONINFO);
1006 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
1007 break;
1010 case SPI_SETANIMATION: {
1011 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1013 /* Do nothing */
1014 WARN(system, "SPI_SETANIMATION ignored.\n");
1015 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1016 uParam = sizeof(ANIMATIONINFO);
1017 break;
1020 case SPI_GETHIGHCONTRAST:
1022 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
1024 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1026 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
1028 /* Indicate that there is no high contrast available */
1029 lpHighContrastA->dwFlags = 0;
1030 lpHighContrastA->lpszDefaultScheme = NULL;
1032 else
1034 return FALSE;
1037 break;
1040 default:
1041 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
1043 return TRUE;
1047 /***********************************************************************
1048 * SystemParametersInfo16 (USER.483)
1050 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
1051 LPVOID lpvParam, UINT16 fuWinIni )
1053 int timeout;
1054 char buffer[256];
1055 int temp;
1056 XKeyboardState keyboard_state;
1057 XKeyboardControl keyboard_value;
1059 switch (uAction)
1061 case SPI_GETBEEP:
1062 TSXGetKeyboardControl(display, &keyboard_state);
1063 if (keyboard_state.bell_percent == 0)
1064 *(BOOL16 *) lpvParam = FALSE;
1065 else
1066 *(BOOL16 *) lpvParam = TRUE;
1067 break;
1069 case SPI_GETBORDER:
1070 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME );
1071 break;
1073 case SPI_GETFASTTASKSWITCH:
1074 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
1075 *(BOOL16 *) lpvParam = TRUE;
1076 else
1077 *(BOOL16 *) lpvParam = FALSE;
1078 break;
1080 case SPI_GETGRIDGRANULARITY:
1081 *(INT16 *) lpvParam = GetProfileIntA( "desktop",
1082 "GridGranularity",
1083 1 );
1084 break;
1086 case SPI_GETICONTITLEWRAP:
1087 *(BOOL16 *) lpvParam = GetProfileIntA( "desktop",
1088 "IconTitleWrap",
1089 TRUE );
1090 break;
1092 case SPI_GETKEYBOARDDELAY:
1093 *(INT16 *) lpvParam = GetProfileIntA( "keyboard",
1094 "KeyboardDelay", 1 );
1095 break;
1097 case SPI_GETKEYBOARDSPEED:
1098 *(WORD *) lpvParam = GetProfileIntA( "keyboard",
1099 "KeyboardSpeed",
1100 30 );
1101 break;
1103 case SPI_GETMENUDROPALIGNMENT:
1104 *(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */
1105 break;
1107 case SPI_GETSCREENSAVEACTIVE:
1108 if ( GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1 )
1109 *(BOOL16 *) lpvParam = TRUE;
1110 else
1111 *(BOOL16 *) lpvParam = FALSE;
1112 break;
1114 case SPI_GETSCREENSAVETIMEOUT:
1115 #ifndef X_DISPLAY_MISSING
1116 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
1117 #else /* X_DISPLAY_MISSING */
1118 timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
1119 #endif /* X_DISPLAY_MISSING */
1120 *(INT16 *) lpvParam = timeout;
1121 break;
1123 case SPI_ICONHORIZONTALSPACING:
1124 /* FIXME Get/SetProfileInt */
1125 if (lpvParam == NULL)
1126 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1127 else
1128 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING );
1129 break;
1131 case SPI_ICONVERTICALSPACING:
1132 /* FIXME Get/SetProfileInt */
1133 if (lpvParam == NULL)
1134 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1135 else
1136 *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING);
1137 break;
1139 case SPI_SETBEEP:
1140 if (uParam == TRUE)
1141 keyboard_value.bell_percent = -1;
1142 else
1143 keyboard_value.bell_percent = 0;
1144 TSXChangeKeyboardControl(display, KBBellPercent,
1145 &keyboard_value);
1146 break;
1148 case SPI_SETSCREENSAVEACTIVE:
1149 if (uParam == TRUE)
1150 TSXActivateScreenSaver(display);
1151 else
1152 TSXResetScreenSaver(display);
1153 break;
1155 case SPI_SETSCREENSAVETIMEOUT:
1156 TSXSetScreenSaver(display, uParam, 60, DefaultBlanking,
1157 DefaultExposures);
1158 break;
1160 case SPI_SETDESKWALLPAPER:
1161 return (SetDeskWallPaper((LPSTR) lpvParam));
1162 break;
1164 case SPI_SETDESKPATTERN:
1165 if ((INT16)uParam == -1) {
1166 GetProfileStringA("Desktop", "Pattern",
1167 "170 85 170 85 170 85 170 85",
1168 buffer, sizeof(buffer) );
1169 return (DESKTOP_SetPattern((LPSTR) buffer));
1170 } else
1171 return (DESKTOP_SetPattern((LPSTR) lpvParam));
1172 break;
1174 case SPI_GETICONTITLELOGFONT:
1176 LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
1178 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
1179 lpLogFont->lfFaceName, LF_FACESIZE );
1180 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 8);
1181 lpLogFont->lfWidth = 0;
1182 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1183 lpLogFont->lfWeight = FW_NORMAL;
1184 lpLogFont->lfItalic = FALSE;
1185 lpLogFont->lfStrikeOut = FALSE;
1186 lpLogFont->lfUnderline = FALSE;
1187 lpLogFont->lfCharSet = ANSI_CHARSET;
1188 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1189 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1190 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1191 break;
1193 case SPI_GETNONCLIENTMETRICS:
1195 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
1196 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
1198 /* FIXME: initialize geometry entries */
1199 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1200 (LPVOID)&(lpnm->lfCaptionFont),0);
1201 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1202 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1203 (LPVOID)&(lpnm->lfSmCaptionFont),0);
1204 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1205 (LPVOID)&(lpnm->lfMenuFont),0);
1206 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1207 (LPVOID)&(lpnm->lfStatusFont),0);
1208 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1209 (LPVOID)&(lpnm->lfMessageFont),0);
1211 else /* winfile 95 sets sbSize to 340 */
1212 SystemParametersInfoA( uAction, uParam, lpvParam, fuWinIni );
1213 #undef lpnm
1214 break;
1216 case SPI_LANGDRIVER:
1217 case SPI_SETBORDER:
1218 case SPI_SETDOUBLECLKHEIGHT:
1219 case SPI_SETDOUBLECLICKTIME:
1220 case SPI_SETDOUBLECLKWIDTH:
1221 case SPI_SETFASTTASKSWITCH:
1222 case SPI_SETKEYBOARDDELAY:
1223 case SPI_SETKEYBOARDSPEED:
1224 WARN(system, "Option %d ignored.\n", uAction);
1225 break;
1227 case SPI_GETWORKAREA:
1228 SetRect16( (RECT16 *)lpvParam, 0, 0,
1229 GetSystemMetrics16( SM_CXSCREEN ),
1230 GetSystemMetrics16( SM_CYSCREEN ) );
1231 break;
1233 default:
1234 WARN(system, "Unknown option %d.\n", uAction);
1235 break;
1237 return 1;
1240 /***********************************************************************
1241 * SystemParametersInfo32W (USER32.541)
1243 BOOL WINAPI SystemParametersInfoW( UINT uAction, UINT uParam,
1244 LPVOID lpvParam, UINT fuWinIni )
1246 char buffer[256];
1248 switch (uAction)
1250 case SPI_SETDESKWALLPAPER:
1251 if (lpvParam)
1253 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1254 return SetDeskWallPaper(buffer);
1256 return SetDeskWallPaper(NULL);
1258 case SPI_SETDESKPATTERN:
1259 if ((INT) uParam == -1)
1261 GetProfileStringA("Desktop", "Pattern",
1262 "170 85 170 85 170 85 170 85",
1263 buffer, sizeof(buffer) );
1264 return (DESKTOP_SetPattern((LPSTR) buffer));
1266 if (lpvParam)
1268 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1269 return DESKTOP_SetPattern(buffer);
1271 return DESKTOP_SetPattern(NULL);
1273 case SPI_GETICONTITLELOGFONT:
1275 LPLOGFONTW lpLogFont = (LPLOGFONTW)lpvParam;
1276 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
1277 buffer, sizeof(buffer) );
1278 lstrcpynAtoW(lpLogFont->lfFaceName, buffer ,LF_FACESIZE);
1279 lpLogFont->lfHeight = 10;
1280 lpLogFont->lfWidth = 0;
1281 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1282 lpLogFont->lfWeight = FW_NORMAL;
1283 lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE;
1284 lpLogFont->lfCharSet = ANSI_CHARSET;
1285 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1286 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1287 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1289 break;
1290 case SPI_GETNONCLIENTMETRICS: {
1291 /* FIXME: implement correctly */
1292 LPNONCLIENTMETRICSW lpnm=(LPNONCLIENTMETRICSW)lpvParam;
1294 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0);
1295 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1296 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfSmCaptionFont),0);
1297 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0);
1298 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0);
1299 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0);
1300 break;
1303 case SPI_GETHIGHCONTRAST:
1305 LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
1307 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1309 if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
1311 /* Indicate that there is no high contrast available */
1312 lpHighContrastW->dwFlags = 0;
1313 lpHighContrastW->lpszDefaultScheme = NULL;
1315 else
1317 return FALSE;
1320 break;
1323 default:
1324 return SystemParametersInfoA(uAction,uParam,lpvParam,fuWinIni);
1327 return TRUE;
1331 /***********************************************************************
1332 * FileCDR (KERNEL.130)
1334 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
1336 FIXME(file,"(0x%8x): stub\n", (int) x);
1337 return (FARPROC16)TRUE;