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