Large-scale renaming of all Win32 functions and types to use the
[wine/multimedia.git] / misc / main.c
blob809f3664474f33f761f6c01d016c6d9c864d18e5
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 {NULL,0}
67 WORD WINE_LanguageId = 0x409; /* english as default */
69 struct options Options =
70 { /* default options */
71 0, /* argc */
72 NULL, /* argv */
73 NULL, /* desktopGeometry */
74 NULL, /* programName */
75 NULL, /* argv0 */
76 NULL, /* dllFlags */
77 FALSE, /* usePrivateMap */
78 FALSE, /* useFixedMap */
79 FALSE, /* synchronous */
80 FALSE, /* backing store */
81 SW_SHOWNORMAL, /* cmdShow */
82 FALSE,
83 FALSE, /* failReadOnly */
84 MODE_ENHANCED, /* Enhanced mode */
85 #ifdef DEFAULT_LANG
86 DEFAULT_LANG, /* Default language */
87 #else
88 LANG_En,
89 #endif
90 FALSE, /* Managed windows */
91 FALSE, /* Perfect graphics */
92 FALSE, /* No DGA */
93 NULL, /* Alternate config file name */
94 0 /* screenDepth */
97 static char szUsage[] =
98 "%s\n"
99 "Usage: %s [options] \"program_name [arguments]\"\n"
100 #ifndef X_DISPLAY_MISSING
101 "\n"
102 "Options:\n"
103 " -backingstore Turn on backing store\n"
104 " -config name Specify config file to use\n"
105 " -console driver Select which driver(s) to use for the console\n"
106 " -debug Enter debugger before starting application\n"
107 " -debugmsg name Turn debugging-messages on or off\n"
108 " -depth n Change the depth to use for multiple-depth screens\n"
109 " -desktop geom Use a desktop window of the given geometry\n"
110 " -display name Use the specified display\n"
111 " -dll name Enable or disable built-in DLLs\n"
112 " -failreadonly Read only files may not be opened in write mode\n"
113 " -fixedmap Use a \"standard\" color map\n"
114 " -help Show this help message\n"
115 " -iconic Start as an icon\n"
116 " -language xx Set the language (one of Ca,Cs,Da,De,En,Eo,Es,Fi,Fr,Hu,It,\n"
117 " Ko,Nl,No,Pl,Pt,Sv)\n"
118 " -managed Allow the window manager to manage created windows\n"
119 " -mode mode Start Wine in a particular mode (standard or enhanced)\n"
120 " -name name Set the application name\n"
121 " -nodga Disable XFree86 DGA extensions\n"
122 " -perfect Favor correctness over speed for graphical operations\n"
123 " -privatemap Use a private color map\n"
124 " -synchronous Turn on synchronous display mode\n"
125 " -version Display the Wine version\n"
126 " -winver Version to imitate (one of win31,win95,nt351,nt40)\n"
127 " -dosver DOS version to imitate (x.xx, e.g. 6.22). Only valid with -winver win31\n"
128 #endif /* X_DISPLAY_MISSING */
131 /***********************************************************************
132 * MAIN_Usage
134 void MAIN_Usage( char *name )
136 MSG( szUsage, WINE_RELEASE_INFO, name );
137 exit(1);
140 /***********************************************************************
141 * MAIN_GetProgramName
143 * Get the program name. The name is specified by (in order of precedence):
144 * - the option '-name'.
145 * - the environment variable 'WINE_NAME'.
146 * - the last component of argv[0].
148 static char *MAIN_GetProgramName( int argc, char *argv[] )
150 int i;
151 char *p;
153 for (i = 1; i < argc-1; i++)
154 if (!strcmp( argv[i], "-name" )) return argv[i+1];
155 if ((p = getenv( "WINE_NAME" )) != NULL) return p;
156 if ((p = strrchr( argv[0], '/' )) != NULL) return p+1;
157 return argv[0];
160 /***********************************************************************
161 * MAIN_ParseDebugOptions
163 * Turns specific debug messages on or off, according to "options".
165 * RETURNS
166 * TRUE if parsing was successful
168 BOOL MAIN_ParseDebugOptions(char *options)
170 /* defined in relay32/relay386.c */
171 extern char **debug_relay_includelist;
172 extern char **debug_relay_excludelist;
173 /* defined in relay32/snoop.c */
174 extern char **debug_snoop_includelist;
175 extern char **debug_snoop_excludelist;
177 int i;
178 int l, cls, dotracerelay = TRACE_ON(relay);
180 l = strlen(options);
181 if (l<3)
182 return FALSE;
183 if (options[l-1]=='\n') options[l-1]='\0';
186 if ((*options!='+')&&(*options!='-')){
187 int j;
189 for(j=0; j<DEBUG_CLASS_COUNT; j++)
190 if(!lstrncmpiA(options, debug_cl_name[j], strlen(debug_cl_name[j])))
191 break;
192 if(j==DEBUG_CLASS_COUNT)
193 goto error;
194 options += strlen(debug_cl_name[j]);
195 if ((*options!='+')&&(*options!='-'))
196 goto error;
197 cls = j;
199 else
200 cls = -1; /* all classes */
202 if (strchr(options,','))
203 l=strchr(options,',')-options;
204 else
205 l=strlen(options);
207 if (!lstrncmpiA(options+1,"all",l-1))
209 int i, j;
210 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
211 for(j=0; j<DEBUG_CLASS_COUNT; j++)
212 if(cls == -1 || cls == j)
213 debug_msg_enabled[i][j]=(*options=='+');
215 else if (!lstrncmpiA(options+1, "relay=", 6) ||
216 !lstrncmpiA(options+1, "snoop=", 6))
218 int i, j;
219 char *s, *s2, ***output, c;
221 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
222 if (debug_ch_name && (!lstrncmpiA(debug_ch_name[i],options+1,5))){
223 for(j=0; j<DEBUG_CLASS_COUNT; j++)
224 if(cls == -1 || cls == j)
225 debug_msg_enabled[i][j]=TRUE;
226 break;
228 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
229 if (i==DEBUG_CHANNEL_COUNT)
230 goto error;
231 output = (*options == '+') ?
232 ((*(options+1) == 'r') ?
233 &debug_relay_includelist :
234 &debug_snoop_includelist) :
235 ((*(options+1) == 'r') ?
236 &debug_relay_excludelist :
237 &debug_snoop_excludelist);
238 s = options + 7;
239 i = 1;
240 while((s = strchr(s, ':'))) i++, s++;
241 *output = malloc(sizeof(char **) * i + 1);
242 i = 0;
243 s = options + 7;
244 while((s2 = strchr(s, ':'))) {
245 c = *s2;
246 *s2 = '\0';
247 *((*output)+i) = strdup(s);
248 *s2 = c;
249 s = s2 + 1;
250 i++;
252 c = *(options + l);
253 *(options + l) = '\0';
254 *((*output)+i) = strdup(s);
255 *(options + l) = c;
256 *((*output)+i+1) = NULL;
258 else
260 int i, j;
261 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
262 if (debug_ch_name && (!lstrncmpiA(options+1,debug_ch_name[i],l-1))){
263 for(j=0; j<DEBUG_CLASS_COUNT; j++)
264 if(cls == -1 || cls == j)
265 debug_msg_enabled[i][j]=(*options=='+');
266 break;
268 if (i==DEBUG_CHANNEL_COUNT)
269 goto error;
271 options+=l;
273 while((*options==',')&&(*(++options)));
275 /* special handling for relay debugging */
276 if (dotracerelay != TRACE_ON(relay))
277 BUILTIN32_SwitchRelayDebug( TRACE_ON(relay) );
279 if (!*options)
280 return TRUE;
282 error:
283 MSG("%s: Syntax: -debugmsg [class]+xxx,... or "
284 "-debugmsg [class]-xxx,...\n",Options.argv[0]);
285 MSG("Example: -debugmsg +all,warn-heap\n"
286 " turn on all messages except warning heap messages\n");
287 MSG("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
288 " turn on -debugmsg +relay only as specified\n"
289 "Special case: -debugmsg -relay=DLL:DLL.###:FuncName\n"
290 " turn on -debugmsg +relay except as specified\n"
291 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
293 MSG("Available message classes:\n");
294 for(i=0;i<DEBUG_CLASS_COUNT;i++)
295 MSG( "%-9s", debug_cl_name[i]);
296 MSG("\n\n");
298 MSG("Available message types:\n");
299 MSG("%-9s ","all");
300 for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
301 if(debug_ch_name[i])
302 MSG("%-9s%c",debug_ch_name[i],
303 (((i+2)%8==0)?'\n':' '));
304 MSG("\n\n");
305 exit(1);
308 /***********************************************************************
309 * MAIN_GetLanguageID
311 * INPUT:
312 * Lang: a string whose two first chars are the iso name of a language.
313 * Country: a string whose two first chars are the iso name of country
314 * Charset: a string defining the chossen charset encoding
315 * Dialect: a string defining a variation of the locale
317 * all those values are from the standardized format of locale
318 * name in unix which is: Lang[_Country][.Charset][@Dialect]
320 * RETURNS:
321 * the numeric code of the language used by Windows (or 0x00)
323 int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
325 char lang[3]="??", country[3]={0,0,0};
326 char *charset=NULL, *dialect=NULL;
327 int i,j,ret=0;
329 if (Lang==NULL) return 0x00;
330 if (Lang[0]) lang[0]=tolower(Lang[0]);
331 if (Lang[1]) lang[1]=tolower(Lang[1]);
333 if (Country!=NULL) {
334 if (Country[0]) country[0]=toupper(Country[0]);
335 if (Country[1]) country[1]=toupper(Country[1]);
338 if (Charset!=NULL) {
339 j=strlen(Charset);
340 charset=(char*)malloc(j+1);
341 for (i=0;i<j;i++)
342 charset[i]=toupper(Charset[i]);
343 charset[i]='\0';
346 if (Dialect!=NULL) {
347 j=strlen(Dialect);
348 dialect=(char*)malloc(j+1);
349 for (i=0;i<j;i++)
350 dialect[i]=tolower(Dialect[i]);
351 dialect[i]='\0';
354 #define LANG_ENTRY_BEGIN(x,y) if(!strcmp(lang, x )) { \
355 if (!country[0]) { \
356 ret=LANG_##y ; \
357 goto end_MAIN_GetLanguageID; \
359 #define LANG_SUB_ENTRY(x,y,z) if (!strcmp(country, x )) \
360 ret = MAKELANGID( LANG_##y , SUBLANG_##z ); \
361 goto end_MAIN_GetLanguageID;
362 #define LANG_DIALECT_ENTRY(x,y) { ret = MAKELANGID(LANG_##x , SUBLANG_##y ); \
363 goto end_MAIN_GetLanguageID; }
364 #define LANG_ENTRY_END(x) ret = MAKELANGID(LANG_##x , SUBLANG_DEFAULT); \
365 goto end_MAIN_GetLanguageID; \
368 /*x01*/ LANG_ENTRY_BEGIN( "ar", ARABIC )
369 LANG_SUB_ENTRY( "SA", ARABIC, ARABIC)
370 LANG_SUB_ENTRY( "IQ", ARABIC, ARABIC_IRAQ )
371 LANG_SUB_ENTRY( "EG", ARABIC, ARABIC_EGYPT )
372 LANG_SUB_ENTRY( "LY", ARABIC, ARABIC_LIBYA )
373 LANG_SUB_ENTRY( "DZ", ARABIC, ARABIC_ALGERIA )
374 LANG_SUB_ENTRY( "MA", ARABIC, ARABIC_MOROCCO )
375 LANG_SUB_ENTRY( "TN", ARABIC, ARABIC_TUNISIA )
376 LANG_SUB_ENTRY( "OM", ARABIC, ARABIC_OMAN )
377 LANG_SUB_ENTRY( "YE", ARABIC, ARABIC_YEMEN )
378 LANG_SUB_ENTRY( "SY", ARABIC, ARABIC_SYRIA )
379 LANG_SUB_ENTRY( "JO", ARABIC, ARABIC_JORDAN )
380 LANG_SUB_ENTRY( "LB", ARABIC, ARABIC_LEBANON )
381 LANG_SUB_ENTRY( "KW", ARABIC, ARABIC_KUWAIT )
382 LANG_SUB_ENTRY( "AE", ARABIC, ARABIC_UAE )
383 LANG_SUB_ENTRY( "BH", ARABIC, ARABIC_BAHRAIN )
384 LANG_SUB_ENTRY( "QA", ARABIC, ARABIC_QATAR )
385 LANG_ENTRY_END( ARABIC )
386 /*x02*/ LANG_ENTRY_BEGIN( "bu", BULGARIAN )
387 LANG_ENTRY_END( BULGARIAN )
388 /*x03*/ LANG_ENTRY_BEGIN( "ca", CATALAN )
389 LANG_ENTRY_END( CATALAN )
390 /*x04*/ LANG_ENTRY_BEGIN( "zh", CHINESE )
391 LANG_SUB_ENTRY( "TW", CHINESE, CHINESE_TRADITIONAL )
392 LANG_SUB_ENTRY( "CN", CHINESE, CHINESE_SIMPLIFIED )
393 LANG_SUB_ENTRY( "HK", CHINESE, CHINESE_HONGKONG )
394 LANG_SUB_ENTRY( "SG", CHINESE, CHINESE_SINGAPORE )
395 LANG_SUB_ENTRY( "MO", CHINESE, CHINESE_MACAU )
396 LANG_ENTRY_END( CHINESE )
397 /*x05*/ LANG_ENTRY_BEGIN( "cs", CZECH )
398 LANG_ENTRY_END( CZECH )
399 /*x06*/ LANG_ENTRY_BEGIN( "da", DANISH )
400 LANG_ENTRY_END( DANISH )
401 /*x07*/ LANG_ENTRY_BEGIN( "de", GERMAN )
402 LANG_SUB_ENTRY( "DE", GERMAN, GERMAN )
403 LANG_SUB_ENTRY( "CH", GERMAN, GERMAN_SWISS )
404 LANG_SUB_ENTRY( "AT", GERMAN, GERMAN_AUSTRIAN )
405 LANG_SUB_ENTRY( "LU", GERMAN, GERMAN_LUXEMBOURG )
406 LANG_SUB_ENTRY( "LI", GERMAN, GERMAN_LIECHTENSTEIN )
407 LANG_ENTRY_END( GERMAN )
408 /*x08*/ LANG_ENTRY_BEGIN( "el", GREEK )
409 LANG_ENTRY_END( GREEK )
410 /*x09*/ LANG_ENTRY_BEGIN( "en", ENGLISH )
411 LANG_SUB_ENTRY( "US", ENGLISH, ENGLISH_US )
412 LANG_SUB_ENTRY( "UK", ENGLISH, ENGLISH_UK )
413 LANG_SUB_ENTRY( "AU", ENGLISH, ENGLISH_AUS )
414 LANG_SUB_ENTRY( "CA", ENGLISH, ENGLISH_CAN )
415 LANG_SUB_ENTRY( "NZ", ENGLISH, ENGLISH_NZ )
416 LANG_SUB_ENTRY( "EI", ENGLISH, ENGLISH_EIRE )
417 LANG_SUB_ENTRY( "ZA", ENGLISH, ENGLISH_SAFRICA )
418 LANG_SUB_ENTRY( "JM", ENGLISH, ENGLISH_JAMAICA )
419 /* LANG_SUB_ENTRY( "AG", ENGLISH, ENGLISH_CARIBBEAN ) */
420 LANG_SUB_ENTRY( "BZ", ENGLISH, ENGLISH_BELIZE )
421 LANG_SUB_ENTRY( "TT", ENGLISH, ENGLISH_TRINIDAD )
422 LANG_SUB_ENTRY( "ZW", ENGLISH, ENGLISH_ZIMBABWE )
423 LANG_SUB_ENTRY( "PH", ENGLISH, ENGLISH_PHILIPPINES )
424 LANG_ENTRY_END( ENGLISH )
425 /*x0a*/ LANG_ENTRY_BEGIN( "es", SPANISH )
426 /* traditional sorting */
427 if (!strcmp(dialect,"tradicional"))
428 LANG_DIALECT_ENTRY( SPANISH, SPANISH )
429 LANG_SUB_ENTRY( "MX", SPANISH, SPANISH_MEXICAN )
430 LANG_SUB_ENTRY( "ES", SPANISH, SPANISH_MODERN )
431 LANG_SUB_ENTRY( "GT", SPANISH, SPANISH_GUATEMALA )
432 LANG_SUB_ENTRY( "CR", SPANISH, SPANISH_COSTARICA )
433 LANG_SUB_ENTRY( "PA", SPANISH, SPANISH_PANAMA )
434 LANG_SUB_ENTRY( "DO", SPANISH, SPANISH_DOMINICAN )
435 LANG_SUB_ENTRY( "VE", SPANISH, SPANISH_VENEZUELA )
436 LANG_SUB_ENTRY( "CO", SPANISH, SPANISH_COLOMBIA )
437 LANG_SUB_ENTRY( "PE", SPANISH, SPANISH_PERU )
438 LANG_SUB_ENTRY( "AR", SPANISH, SPANISH_ARGENTINA )
439 LANG_SUB_ENTRY( "EC", SPANISH, SPANISH_ECUADOR )
440 LANG_SUB_ENTRY( "CL", SPANISH, SPANISH_CHILE )
441 LANG_SUB_ENTRY( "UY", SPANISH, SPANISH_URUGUAY )
442 LANG_SUB_ENTRY( "PY", SPANISH, SPANISH_PARAGUAY )
443 LANG_SUB_ENTRY( "BO", SPANISH, SPANISH_BOLIVIA )
444 LANG_SUB_ENTRY( "HN", SPANISH, SPANISH_HONDURAS )
445 LANG_SUB_ENTRY( "NI", SPANISH, SPANISH_NICARAGUA )
446 LANG_SUB_ENTRY( "PR", SPANISH, SPANISH_PUERTO_RICO )
447 LANG_ENTRY_END( SPANISH )
448 /*x0b*/ LANG_ENTRY_BEGIN( "fi", FINNISH )
449 LANG_ENTRY_END( FINNISH )
450 /*x0c*/ LANG_ENTRY_BEGIN( "fr", FRENCH )
451 LANG_SUB_ENTRY( "FR", FRENCH, FRENCH )
452 LANG_SUB_ENTRY( "BE", FRENCH, FRENCH_BELGIAN )
453 LANG_SUB_ENTRY( "CA", FRENCH, FRENCH_CANADIAN )
454 LANG_SUB_ENTRY( "CH", FRENCH, FRENCH_SWISS )
455 LANG_SUB_ENTRY( "LU", FRENCH, FRENCH_LUXEMBOURG )
456 LANG_SUB_ENTRY( "MC", FRENCH, FRENCH_MONACO )
457 LANG_ENTRY_END( FRENCH )
458 /*x0d*/ LANG_ENTRY_BEGIN( "iw", HEBREW )
459 LANG_ENTRY_END( HEBREW )
460 /*x0e*/ LANG_ENTRY_BEGIN( "hu", HUNGARIAN )
461 LANG_ENTRY_END( HUNGARIAN )
462 /*x0f*/ LANG_ENTRY_BEGIN( "ic", ICELANDIC )
463 LANG_ENTRY_END( ICELANDIC )
464 /*x10*/ LANG_ENTRY_BEGIN( "it", ITALIAN )
465 LANG_SUB_ENTRY( "IT", ITALIAN, ITALIAN )
466 LANG_SUB_ENTRY( "CH", ITALIAN, ITALIAN_SWISS )
467 LANG_ENTRY_END( ITALIAN )
468 /*x11*/ LANG_ENTRY_BEGIN( "ja", JAPANESE )
469 LANG_ENTRY_END( JAPANESE )
470 /*x12*/ LANG_ENTRY_BEGIN( "ko", KOREAN )
471 /* JOHAB encoding */
472 if (!strcmp(charset,"JOHAB"))
473 LANG_DIALECT_ENTRY( KOREAN, KOREAN_JOHAB )
474 else
475 LANG_DIALECT_ENTRY( KOREAN, KOREAN )
476 LANG_ENTRY_END( KOREAN )
477 /*x13*/ LANG_ENTRY_BEGIN( "nl", DUTCH )
478 LANG_SUB_ENTRY( "NL", DUTCH, DUTCH )
479 LANG_SUB_ENTRY( "BE", DUTCH, DUTCH_BELGIAN )
480 LANG_SUB_ENTRY( "SR", DUTCH, DUTCH_SURINAM )
481 LANG_ENTRY_END( DUTCH )
482 /*x14*/ LANG_ENTRY_BEGIN( "no", NORWEGIAN )
483 /* nynorsk */
484 if (!strcmp(dialect,"nynorsk"))
485 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_NYNORSK )
486 else
487 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_BOKMAL )
488 LANG_ENTRY_END( NORWEGIAN )
489 /*x15*/ LANG_ENTRY_BEGIN( "pl", POLISH )
490 LANG_ENTRY_END( POLISH )
491 /*x16*/ LANG_ENTRY_BEGIN( "pt", PORTUGUESE )
492 LANG_SUB_ENTRY( "BR", PORTUGUESE, PORTUGUESE_BRAZILIAN )
493 LANG_SUB_ENTRY( "PT", PORTUGUESE, PORTUGUESE )
494 LANG_ENTRY_END( PORTUGUESE )
495 /*x17*/ LANG_ENTRY_BEGIN( "rm", RHAETO_ROMANCE )
496 LANG_ENTRY_END( RHAETO_ROMANCE )
497 /*x18*/ LANG_ENTRY_BEGIN( "ro", ROMANIAN )
498 LANG_SUB_ENTRY( "RO", ROMANIAN, ROMANIAN )
499 LANG_SUB_ENTRY( "MD", ROMANIAN, ROMANIAN_MOLDAVIA )
500 LANG_ENTRY_END( ROMANIAN )
501 /*x19*/ LANG_ENTRY_BEGIN( "ru", RUSSIAN )
502 LANG_SUB_ENTRY( "RU", RUSSIAN, RUSSIAN )
503 LANG_SUB_ENTRY( "MD", RUSSIAN, RUSSIAN_MOLDAVIA )
504 LANG_ENTRY_END( RUSSIAN )
505 /*x1a*/ if (!strcmp(lang,"sh") || !strcmp(lang,"hr") || !strcmp(lang,"sr")) {
506 if (!country[0])
507 LANG_DIALECT_ENTRY( SERBO_CROATIAN, NEUTRAL)
508 if (!strcmp(charset,"ISO-8859-5"))
509 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN )
510 LANG_SUB_ENTRY( "HR", SERBO_CROATIAN, CROATIAN )
511 if (!strcmp(country,"YU") && !strcmp(charset,"ISO-8859-2"))
512 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
513 LANG_SUB_ENTRY( "YU", SERBO_CROATIAN, SERBIAN )
514 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
516 /*x1b*/ LANG_ENTRY_BEGIN( "sk", SLOVAK )
517 LANG_ENTRY_END( SLOVAK )
518 /*x1c*/ LANG_ENTRY_BEGIN( "sq", ALBANIAN )
519 LANG_ENTRY_END( ALBANIAN )
520 /*x1d*/ LANG_ENTRY_BEGIN( "sv", SWEDISH )
521 LANG_SUB_ENTRY( "SE", SWEDISH, SWEDISH )
522 LANG_SUB_ENTRY( "FI", SWEDISH, SWEDISH_FINLAND )
523 LANG_ENTRY_END( SWEDISH )
524 /*x1e*/ LANG_ENTRY_BEGIN( "th", THAI )
525 LANG_ENTRY_END( THAI )
526 /*x1f*/ LANG_ENTRY_BEGIN( "tr", TURKISH )
527 LANG_ENTRY_END( TURKISH )
528 /*x20*/ LANG_ENTRY_BEGIN( "ur", URDU )
529 LANG_ENTRY_END( URDU )
530 /*x21*/ LANG_ENTRY_BEGIN( "in", INDONESIAN )
531 LANG_ENTRY_END( INDONESIAN )
532 /*x22*/ LANG_ENTRY_BEGIN( "uk", UKRAINIAN )
533 LANG_ENTRY_END( UKRAINIAN )
534 /*x23*/ LANG_ENTRY_BEGIN( "be", BYELORUSSIAN )
535 LANG_ENTRY_END( BYELORUSSIAN )
536 /*x24*/ LANG_ENTRY_BEGIN( "sl", SLOVENIAN )
537 LANG_ENTRY_END( SLOVENIAN )
538 /*x25*/ LANG_ENTRY_BEGIN( "et", ESTONIAN )
539 LANG_ENTRY_END( ESTONIAN )
540 /*x26*/ LANG_ENTRY_BEGIN( "lv", LATVIAN )
541 LANG_ENTRY_END( LATVIAN )
542 /*x27*/ LANG_ENTRY_BEGIN( "lt", LITHUANIAN )
543 /* traditional sorting ? */
544 if (!strcmp(dialect,"classic") || !strcmp(dialect,"traditional"))
545 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN_CLASSIC )
546 else
547 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN )
548 LANG_ENTRY_END( LITHUANIAN )
549 /*x28*/ LANG_ENTRY_BEGIN( "mi", MAORI )
550 LANG_ENTRY_END( MAORI )
551 /*x29*/ LANG_ENTRY_BEGIN( "fa", FARSI )
552 LANG_ENTRY_END( FARSI )
553 /*x2a*/ LANG_ENTRY_BEGIN( "vi", VIETNAMESE )
554 LANG_ENTRY_END( VIETNAMESE )
555 /*x2b*/ LANG_ENTRY_BEGIN( "hy", ARMENIAN )
556 LANG_ENTRY_END( ARMENIAN )
557 /*x2c*/ LANG_ENTRY_BEGIN( "az", AZERI )
558 /* Cyrillic */
559 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
560 LANG_DIALECT_ENTRY( AZERI, AZERI_CYRILLIC )
561 else
562 LANG_DIALECT_ENTRY( AZERI, AZERI )
563 LANG_ENTRY_END( AZERI )
564 /*x2d*/ LANG_ENTRY_BEGIN( "eu", BASQUE )
565 LANG_ENTRY_END( BASQUE )
566 /*x2e*/ /*LANG_ENTRY_BEGIN( "??", SORBIAN )
567 LANG_ENTRY_END( SORBIAN ) */
568 /*x2f*/ LANG_ENTRY_BEGIN( "mk", MACEDONIAN )
569 LANG_ENTRY_END( MACEDONIAN )
570 /*x30*/ /*LANG_ENTRY_BEGIN( "??", SUTU )
571 LANG_ENTRY_END( SUTU ) */
572 /*x31*/ LANG_ENTRY_BEGIN( "ts", TSONGA )
573 LANG_ENTRY_END( TSONGA )
574 /*x32*/ /*LANG_ENTRY_BEGIN( "??", TSWANA )
575 LANG_ENTRY_END( TSWANA ) */
576 /*x33*/ /*LANG_ENTRY_BEGIN( "??", VENDA )
577 LANG_ENTRY_END( VENDA ) */
578 /*x34*/ LANG_ENTRY_BEGIN( "xh", XHOSA )
579 LANG_ENTRY_END( XHOSA )
580 /*x35*/ LANG_ENTRY_BEGIN( "zu", ZULU )
581 LANG_ENTRY_END( ZULU )
582 /*x36*/ LANG_ENTRY_BEGIN( "af", AFRIKAANS )
583 LANG_ENTRY_END( AFRIKAANS )
584 /*x37*/ LANG_ENTRY_BEGIN( "ka", GEORGIAN )
585 LANG_ENTRY_END( GEORGIAN )
586 /*x38*/ LANG_ENTRY_BEGIN( "fo", FAEROESE )
587 LANG_ENTRY_END( FAEROESE )
588 /*x39*/ LANG_ENTRY_BEGIN( "hi", HINDI )
589 LANG_ENTRY_END( HINDI )
590 /*x3a*/ LANG_ENTRY_BEGIN( "mt", MALTESE )
591 LANG_ENTRY_END( MALTESE )
592 /*x3b*/ /*LANG_ENTRY_BEGIN( "??", SAAMI )
593 LANG_ENTRY_END( SAAMI ) */
594 /*x3c*/ LANG_ENTRY_BEGIN( "ga", GAELIC )
595 LANG_DIALECT_ENTRY( GAELIC, GAELIC )
596 LANG_ENTRY_END( GAELIC )
597 /*x3c*/ LANG_ENTRY_BEGIN( "gd", GAELIC )
598 LANG_DIALECT_ENTRY( GAELIC, GAELIC_SCOTTISH )
599 LANG_ENTRY_END( GAELIC )
600 /* 0x3d */
601 /*x3e*/ LANG_ENTRY_BEGIN( "ms", MALAY )
602 LANG_SUB_ENTRY( "MY", MALAY, MALAY )
603 LANG_SUB_ENTRY( "BN", MALAY, MALAY_BRUNEI_DARUSSALAM )
604 LANG_ENTRY_END( MALAY )
605 /*x3f*/ LANG_ENTRY_BEGIN( "kk", KAZAKH )
606 LANG_ENTRY_END( KAZAKH )
607 /* 0x40 */
608 /*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI )
609 LANG_ENTRY_END( SWAHILI )
610 /* 0x42 */
611 /*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK )
612 /* Cyrillic */
613 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
614 LANG_DIALECT_ENTRY( UZBEK, UZBEK_CYRILLIC )
615 else
616 LANG_DIALECT_ENTRY( UZBEK, UZBEK )
617 LANG_ENTRY_END( UZBEK )
618 /*x44*/ LANG_ENTRY_BEGIN( "tt", TATAR )
619 LANG_ENTRY_END( TATAR )
620 /*x45*/ LANG_ENTRY_BEGIN( "bn", BENGALI )
621 LANG_ENTRY_END( BENGALI )
622 /*x46*/ LANG_ENTRY_BEGIN( "pa", PUNJABI )
623 LANG_ENTRY_END( PUNJABI )
624 /*x47*/ LANG_ENTRY_BEGIN( "gu", GUJARATI )
625 LANG_ENTRY_END( GUJARATI )
626 /*x48*/ LANG_ENTRY_BEGIN( "or", ORIYA )
627 LANG_ENTRY_END( ORIYA )
628 /*x49*/ LANG_ENTRY_BEGIN( "ta", TAMIL )
629 LANG_ENTRY_END( TAMIL )
630 /*x4a*/ LANG_ENTRY_BEGIN( "te", TELUGU )
631 LANG_ENTRY_END( TELUGU )
632 /*x4b*/ LANG_ENTRY_BEGIN( "kn", KANNADA )
633 LANG_ENTRY_END( KANNADA )
634 /*x4c*/ LANG_ENTRY_BEGIN( "ml", MALAYALAM )
635 LANG_ENTRY_END( MALAYALAM )
636 /*x4d*/ LANG_ENTRY_BEGIN( "as", ASSAMESE )
637 LANG_ENTRY_END( ASSAMESE )
638 /*x4e*/ LANG_ENTRY_BEGIN( "mr", MARATHI )
639 LANG_ENTRY_END( MARATHI )
640 /*x4f*/ LANG_ENTRY_BEGIN( "sa", SANSKRIT )
641 LANG_ENTRY_END( SANSKRIT )
642 /* 0x50 -> 0x56 */
643 /*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
644 LANG_ENTRY_END( KONKANI ) */
645 /* 0x58 -> ... */
646 LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */
647 LANG_ENTRY_END( ESPERANTO )
649 ret = LANG_ENGLISH;
651 end_MAIN_GetLanguageID:
652 if (Charset) free(charset);
653 if (Dialect) free(dialect);
655 return ret;
658 /***********************************************************************
659 * MAIN_ParseLanguageOption
661 * Parse -language option.
663 void MAIN_ParseLanguageOption( char *arg )
665 const WINE_LANGUAGE_DEF *p = Languages;
667 /* for compatibility whith non-iso names previously used */
668 if (!strcmp("Sw",arg)) { strcpy(arg,"Sv"); FIXME(system,"use 'Sv' instead of 'Sw'\n");}
669 if (!strcmp("Cz",arg)) { strcpy(arg,"Cs"); FIXME(system,"use 'Cs' instead of 'Cz'\n");}
670 if (!strcmp("Po",arg)) { strcpy(arg,"Pt"); FIXME(system,"use 'Pt' instead of 'Po'\n");}
672 Options.language = LANG_Xx; /* First (dummy) language */
673 for (;p->name;p++)
675 if (!lstrcmpiA( p->name, arg ))
677 WINE_LanguageId = p->langid;
678 return;
680 Options.language++;
682 MSG( "Invalid language specified '%s'. Supported languages are: ", arg );
683 for (p = Languages; p->name; p++) MSG( "%s ", p->name );
684 MSG( "\n" );
685 exit(1);
689 /***********************************************************************
690 * MAIN_ParseModeOption
692 * Parse -mode option.
694 void MAIN_ParseModeOption( char *arg )
696 if (!lstrcmpiA("enhanced", arg)) Options.mode = MODE_ENHANCED;
697 else if (!lstrcmpiA("standard", arg)) Options.mode = MODE_STANDARD;
698 else
700 MSG( "Invalid mode '%s' specified.\n", arg);
701 MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
702 exit(1);
706 /***********************************************************************
707 * MAIN_ParseOptions
709 * Parse command line options and open display.
711 static void MAIN_ParseOptions( int *argc, char *argv[] )
713 int i;
714 char *pcDot;
716 Options.argc = argc;
717 Options.argv = argv;
718 Options.programName = MAIN_GetProgramName( *argc, argv );
719 Options.argv0 = argv[0];
721 /* initialise Options.language to 0 to tell "no language choosen yet" */
722 Options.language = 0;
724 /* make sure there is no "." in Options.programName to confuse the X
725 resource database lookups */
726 if ((pcDot = strchr(Options.programName, '.'))) *pcDot = '\0';
728 for (i = 1; i < *argc; i++)
730 if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
732 MSG( "%s\n", WINE_RELEASE_INFO );
733 exit(0);
735 if (!strcmp( argv[i], "-h" ) || !strcmp( argv[i], "-help" ))
737 MAIN_Usage(argv[0]);
738 exit(0);
742 #ifndef X_DISPLAY_MISSING
743 X11DRV_MAIN_ParseOptions(argc,argv);
744 #else /* X_DISPLAY_MISSING */
745 TTYDRV_MAIN_ParseOptions(argc,argv);
746 #endif /* X_DISPLAY_MISSING */
749 /***********************************************************************
750 * called_at_exit
752 static void called_at_exit(void)
754 #ifndef X_DISPLAY_MISSING
755 X11DRV_MAIN_RestoreSetup();
756 #else /* X_DISPLAY_MISSING */
757 TTYDRV_MAIN_RestoreSetup();
758 #endif /* X_DISPLAY_MISSING */
759 COLOR_Cleanup();
760 WINSOCK_Shutdown();
761 /* FIXME: should check for other processes or threads */
762 DeleteCriticalSection( HEAP_SystemLock );
763 CONSOLE_Close();
766 /***********************************************************************
767 * MAIN_WineInit
769 * Wine initialisation and command-line parsing
771 BOOL MAIN_WineInit( int *argc, char *argv[] )
773 struct timeval tv;
775 #ifdef MALLOC_DEBUGGING
776 char *trace;
778 mcheck(NULL);
779 if (!(trace = getenv("MALLOC_TRACE")))
781 MSG( "MALLOC_TRACE not set. No trace generated\n" );
783 else
785 MSG( "malloc trace goes to %s\n", trace );
786 mtrace();
788 #endif
790 setbuf(stdout,NULL);
791 setbuf(stderr,NULL);
793 setlocale(LC_CTYPE,"");
794 gettimeofday( &tv, NULL);
795 MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
797 #ifndef X_DISPLAY_MISSING
798 X11DRV_MAIN_Initialize();
799 MAIN_ParseOptions( argc, argv );
800 X11DRV_MAIN_Create();
801 X11DRV_MAIN_SaveSetup();
802 #else /* !defined(X_DISPLAY_MISSING) */
803 TTYDRV_MAIN_Initialize();
804 MAIN_ParseOptions( argc, argv );
805 TTYDRV_MAIN_Create();
806 TTYDRV_MAIN_SaveSetup();
807 #endif /* !defined(X_DISPLAY_MISSING) */
809 #ifndef X_DISPLAY_MISSING
810 MONITOR_PrimaryMonitor.pDriver = &X11DRV_MONITOR_Driver;
811 #else /* !defined(X_DISPLAY_MISSING) */
812 MONITOR_PrimaryMonitor.pDriver = &TTYDRV_MONITOR_Driver;
813 #endif /* !defined(X_DISPLAY_MISSING) */
814 MONITOR_Initialize(&MONITOR_PrimaryMonitor);
816 atexit(called_at_exit);
817 return TRUE;
820 /***********************************************************************
821 * MessageBeep16 (USER.104)
823 void WINAPI MessageBeep16( UINT16 i )
825 MessageBeep( i );
829 /***********************************************************************
830 * MessageBeep32 (USER32.390)
832 BOOL WINAPI MessageBeep( UINT i )
834 TSXBell( display, 0 );
835 return TRUE;
839 /***********************************************************************
840 * Beep (KERNEL32.11)
842 BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur )
844 /* dwFreq and dwDur are ignored by Win95 */
845 TSXBell(display, 0);
846 return TRUE;
850 /***********************************************************************
851 * GetTimerResolution (USER.14)
853 LONG WINAPI GetTimerResolution16(void)
855 return (1000);
858 /***********************************************************************
859 * SystemParametersInfo32A (USER32.540)
861 BOOL WINAPI SystemParametersInfoA( UINT uAction, UINT uParam,
862 LPVOID lpvParam, UINT fuWinIni )
864 int timeout;
865 int temp;
866 XKeyboardState keyboard_state;
868 switch (uAction) {
869 case SPI_GETBEEP:
870 TSXGetKeyboardControl(display, &keyboard_state);
871 if (keyboard_state.bell_percent == 0)
872 *(BOOL *) lpvParam = FALSE;
873 else
874 *(BOOL *) lpvParam = TRUE;
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 ( GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1 )
917 *(BOOL*)lpvParam = TRUE;
918 else
919 *(BOOL*)lpvParam = FALSE;
920 break;
922 case SPI_GETSCREENSAVETIMEOUT:
923 #ifndef X_DISPLAY_MISSING
924 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
925 #else /* X_DISPLAY_MISSING */
926 timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
927 #endif /* X_DISPLAY_MISSING */
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", 8);
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 /* FIXME: initialize geometry entries */
981 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
982 (LPVOID)&(lpnm->lfCaptionFont),0);
983 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
984 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
985 (LPVOID)&(lpnm->lfSmCaptionFont),0);
986 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
987 (LPVOID)&(lpnm->lfMenuFont),0);
988 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
989 (LPVOID)&(lpnm->lfStatusFont),0);
990 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
991 (LPVOID)&(lpnm->lfMessageFont),0);
993 #undef lpnm
994 break;
996 case SPI_GETANIMATION: {
997 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
999 /* Tell it "disabled" */
1000 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1001 uParam = sizeof(ANIMATIONINFO);
1002 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
1003 break;
1006 case SPI_SETANIMATION: {
1007 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1009 /* Do nothing */
1010 WARN(system, "SPI_SETANIMATION ignored.\n");
1011 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1012 uParam = sizeof(ANIMATIONINFO);
1013 break;
1016 case SPI_GETHIGHCONTRAST:
1018 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
1020 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1022 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
1024 /* Indicate that there is no high contrast available */
1025 lpHighContrastA->dwFlags = 0;
1026 lpHighContrastA->lpszDefaultScheme = NULL;
1028 else
1030 return FALSE;
1033 break;
1036 default:
1037 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
1039 return TRUE;
1043 /***********************************************************************
1044 * SystemParametersInfo16 (USER.483)
1046 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
1047 LPVOID lpvParam, UINT16 fuWinIni )
1049 int timeout;
1050 char buffer[256];
1051 int temp;
1052 XKeyboardState keyboard_state;
1053 XKeyboardControl keyboard_value;
1055 switch (uAction)
1057 case SPI_GETBEEP:
1058 TSXGetKeyboardControl(display, &keyboard_state);
1059 if (keyboard_state.bell_percent == 0)
1060 *(BOOL16 *) lpvParam = FALSE;
1061 else
1062 *(BOOL16 *) lpvParam = TRUE;
1063 break;
1065 case SPI_GETBORDER:
1066 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME );
1067 break;
1069 case SPI_GETFASTTASKSWITCH:
1070 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
1071 *(BOOL16 *) lpvParam = TRUE;
1072 else
1073 *(BOOL16 *) lpvParam = FALSE;
1074 break;
1076 case SPI_GETGRIDGRANULARITY:
1077 *(INT16 *) lpvParam = GetProfileIntA( "desktop",
1078 "GridGranularity",
1079 1 );
1080 break;
1082 case SPI_GETICONTITLEWRAP:
1083 *(BOOL16 *) lpvParam = GetProfileIntA( "desktop",
1084 "IconTitleWrap",
1085 TRUE );
1086 break;
1088 case SPI_GETKEYBOARDDELAY:
1089 *(INT16 *) lpvParam = GetProfileIntA( "keyboard",
1090 "KeyboardDelay", 1 );
1091 break;
1093 case SPI_GETKEYBOARDSPEED:
1094 *(WORD *) lpvParam = GetProfileIntA( "keyboard",
1095 "KeyboardSpeed",
1096 30 );
1097 break;
1099 case SPI_GETMENUDROPALIGNMENT:
1100 *(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */
1101 break;
1103 case SPI_GETSCREENSAVEACTIVE:
1104 if ( GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1 )
1105 *(BOOL16 *) lpvParam = TRUE;
1106 else
1107 *(BOOL16 *) lpvParam = FALSE;
1108 break;
1110 case SPI_GETSCREENSAVETIMEOUT:
1111 #ifndef X_DISPLAY_MISSING
1112 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
1113 #else /* X_DISPLAY_MISSING */
1114 timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
1115 #endif /* X_DISPLAY_MISSING */
1116 *(INT16 *) lpvParam = timeout;
1117 break;
1119 case SPI_ICONHORIZONTALSPACING:
1120 /* FIXME Get/SetProfileInt */
1121 if (lpvParam == NULL)
1122 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1123 else
1124 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING );
1125 break;
1127 case SPI_ICONVERTICALSPACING:
1128 /* FIXME Get/SetProfileInt */
1129 if (lpvParam == NULL)
1130 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1131 else
1132 *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING);
1133 break;
1135 case SPI_SETBEEP:
1136 if (uParam == TRUE)
1137 keyboard_value.bell_percent = -1;
1138 else
1139 keyboard_value.bell_percent = 0;
1140 TSXChangeKeyboardControl(display, KBBellPercent,
1141 &keyboard_value);
1142 break;
1144 case SPI_SETSCREENSAVEACTIVE:
1145 if (uParam == TRUE)
1146 TSXActivateScreenSaver(display);
1147 else
1148 TSXResetScreenSaver(display);
1149 break;
1151 case SPI_SETSCREENSAVETIMEOUT:
1152 TSXSetScreenSaver(display, uParam, 60, DefaultBlanking,
1153 DefaultExposures);
1154 break;
1156 case SPI_SETDESKWALLPAPER:
1157 return (SetDeskWallPaper((LPSTR) lpvParam));
1158 break;
1160 case SPI_SETDESKPATTERN:
1161 if ((INT16)uParam == -1) {
1162 GetProfileStringA("Desktop", "Pattern",
1163 "170 85 170 85 170 85 170 85",
1164 buffer, sizeof(buffer) );
1165 return (DESKTOP_SetPattern((LPSTR) buffer));
1166 } else
1167 return (DESKTOP_SetPattern((LPSTR) lpvParam));
1168 break;
1170 case SPI_GETICONTITLELOGFONT:
1172 LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
1174 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
1175 lpLogFont->lfFaceName, LF_FACESIZE );
1176 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 8);
1177 lpLogFont->lfWidth = 0;
1178 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1179 lpLogFont->lfWeight = FW_NORMAL;
1180 lpLogFont->lfItalic = FALSE;
1181 lpLogFont->lfStrikeOut = FALSE;
1182 lpLogFont->lfUnderline = FALSE;
1183 lpLogFont->lfCharSet = ANSI_CHARSET;
1184 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1185 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1186 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1187 break;
1189 case SPI_GETNONCLIENTMETRICS:
1191 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
1192 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
1194 /* FIXME: initialize geometry entries */
1195 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1196 (LPVOID)&(lpnm->lfCaptionFont),0);
1197 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1198 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1199 (LPVOID)&(lpnm->lfSmCaptionFont),0);
1200 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1201 (LPVOID)&(lpnm->lfMenuFont),0);
1202 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1203 (LPVOID)&(lpnm->lfStatusFont),0);
1204 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1205 (LPVOID)&(lpnm->lfMessageFont),0);
1207 else /* winfile 95 sets sbSize to 340 */
1208 SystemParametersInfoA( uAction, uParam, lpvParam, fuWinIni );
1209 #undef lpnm
1210 break;
1212 case SPI_LANGDRIVER:
1213 case SPI_SETBORDER:
1214 case SPI_SETDOUBLECLKHEIGHT:
1215 case SPI_SETDOUBLECLICKTIME:
1216 case SPI_SETDOUBLECLKWIDTH:
1217 case SPI_SETFASTTASKSWITCH:
1218 case SPI_SETKEYBOARDDELAY:
1219 case SPI_SETKEYBOARDSPEED:
1220 WARN(system, "Option %d ignored.\n", uAction);
1221 break;
1223 case SPI_GETWORKAREA:
1224 SetRect16( (RECT16 *)lpvParam, 0, 0,
1225 GetSystemMetrics16( SM_CXSCREEN ),
1226 GetSystemMetrics16( SM_CYSCREEN ) );
1227 break;
1229 default:
1230 WARN(system, "Unknown option %d.\n", uAction);
1231 break;
1233 return 1;
1236 /***********************************************************************
1237 * SystemParametersInfo32W (USER32.541)
1239 BOOL WINAPI SystemParametersInfoW( UINT uAction, UINT uParam,
1240 LPVOID lpvParam, UINT fuWinIni )
1242 char buffer[256];
1244 switch (uAction)
1246 case SPI_SETDESKWALLPAPER:
1247 if (lpvParam)
1249 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1250 return SetDeskWallPaper(buffer);
1252 return SetDeskWallPaper(NULL);
1254 case SPI_SETDESKPATTERN:
1255 if ((INT) uParam == -1)
1257 GetProfileStringA("Desktop", "Pattern",
1258 "170 85 170 85 170 85 170 85",
1259 buffer, sizeof(buffer) );
1260 return (DESKTOP_SetPattern((LPSTR) buffer));
1262 if (lpvParam)
1264 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1265 return DESKTOP_SetPattern(buffer);
1267 return DESKTOP_SetPattern(NULL);
1269 case SPI_GETICONTITLELOGFONT:
1271 LPLOGFONTW lpLogFont = (LPLOGFONTW)lpvParam;
1272 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
1273 buffer, sizeof(buffer) );
1274 lstrcpynAtoW(lpLogFont->lfFaceName, buffer ,LF_FACESIZE);
1275 lpLogFont->lfHeight = 10;
1276 lpLogFont->lfWidth = 0;
1277 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1278 lpLogFont->lfWeight = FW_NORMAL;
1279 lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE;
1280 lpLogFont->lfCharSet = ANSI_CHARSET;
1281 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1282 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1283 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1285 break;
1286 case SPI_GETNONCLIENTMETRICS: {
1287 /* FIXME: implement correctly */
1288 LPNONCLIENTMETRICSW lpnm=(LPNONCLIENTMETRICSW)lpvParam;
1290 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0);
1291 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1292 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfSmCaptionFont),0);
1293 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0);
1294 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0);
1295 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0);
1296 break;
1299 case SPI_GETHIGHCONTRAST:
1301 LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
1303 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1305 if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
1307 /* Indicate that there is no high contrast available */
1308 lpHighContrastW->dwFlags = 0;
1309 lpHighContrastW->lpszDefaultScheme = NULL;
1311 else
1313 return FALSE;
1316 break;
1319 default:
1320 return SystemParametersInfoA(uAction,uParam,lpvParam,fuWinIni);
1323 return TRUE;
1327 /***********************************************************************
1328 * FileCDR (KERNEL.130)
1330 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
1332 FIXME(file,"(0x%8x): stub\n", (int) x);
1333 return (FARPROC16)TRUE;