Release 950319
[wine.git] / misc / main.c
blobb672f44d49184bd2924f28fba541abb4a753c587
1 /*
2 * Main function.
4 * Copyright 1994 Alexandre Julliard
6 static char Copyright[] = "Copyright Alexandre Julliard, 1994";
7 */
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <ctype.h>
12 #include <locale.h>
13 #ifdef MALLOC_DEBUGGING
14 #include <malloc.h>
15 #endif
16 #include <X11/Xlib.h>
17 #include <X11/Xresource.h>
18 #include <X11/Xutil.h>
19 #include <X11/cursorfont.h>
20 #include "wine.h"
21 #include "msdos.h"
22 #include "windows.h"
23 #include "comm.h"
24 #include "miscemu.h"
25 #include "winsock.h"
26 #include "options.h"
27 #include "dos_fs.h"
28 #include "desktop.h"
29 #include "prototypes.h"
30 #include "texts.h"
31 #include "dlls.h"
32 #include "library.h"
33 #define DEBUG_DEFINE_VARIABLES
34 #include "stddebug.h"
35 #include "debug.h"
37 extern ButtonTexts ButtonText;
39 static const char people[] = "Wine is available thanks to the work of "\
40 "Bob Amstadt, Dag Asheim, Martin Ayotte, Erik Bos, John Brezak, "\
41 "Andrew Bulhak, John Burton, Paul Falstad, Peter Galbavy, Jeffrey Hsu, "\
42 "Miguel de Icaza, Alexandre Julliard, Jon Konrath, Scott A. Laird, "\
43 "Martin von Loewis, Kenneth MacDonald, Peter MacDonald, David Metcalfe, "\
44 "Michael Patra, John Richardson, Johannes Ruscheinski, Yngvi Sigurjonsson, "\
45 "Rick Sladkey, William Smith, Jon Tombs, Linus Torvalds, Carl Williams, "\
46 "Karl Guenter Wuensch, and Eric Youngdale.";
48 #define WINE_CLASS "Wine" /* Class name for resources */
50 typedef struct tagENVENTRY {
51 LPSTR Name;
52 LPSTR Value;
53 WORD wSize;
54 struct tagENVENTRY *Prev;
55 struct tagENVENTRY *Next;
56 } ENVENTRY;
57 typedef ENVENTRY *LPENVENTRY;
59 LPENVENTRY lpEnvList = NULL;
61 Display *display;
62 Screen *screen;
63 Window rootWindow;
64 int screenWidth = 0, screenHeight = 0; /* Desktop window dimensions */
65 int screenDepth = 0; /* Screen depth to use */
66 int desktopX = 0, desktopY = 0; /* Desktop window position (if any) */
68 struct options Options =
69 { /* default options */
70 NULL, /* spyFilename */
71 NULL, /* desktopGeometry */
72 NULL, /* programName */
73 FALSE, /* usePrivateMap */
74 FALSE, /* synchronous */
75 FALSE, /* backing store */
76 SW_SHOWNORMAL, /* cmdShow */
77 FALSE,
78 FALSE /* AllowReadOnly */
82 static XrmOptionDescRec optionsTable[] =
84 { "-backingstore", ".backingstore", XrmoptionNoArg, (caddr_t)"on" },
85 { "-desktop", ".desktop", XrmoptionSepArg, (caddr_t)NULL },
86 { "-depth", ".depth", XrmoptionSepArg, (caddr_t)NULL },
87 { "-display", ".display", XrmoptionSepArg, (caddr_t)NULL },
88 { "-iconic", ".iconic", XrmoptionNoArg, (caddr_t)"on" },
89 { "-name", ".name", XrmoptionSepArg, (caddr_t)NULL },
90 { "-privatemap", ".privatemap", XrmoptionNoArg, (caddr_t)"on" },
91 { "-synchronous", ".synchronous", XrmoptionNoArg, (caddr_t)"on" },
92 { "-spy", ".spy", XrmoptionSepArg, (caddr_t)NULL },
93 { "-debug", ".debug", XrmoptionNoArg, (caddr_t)"on" },
94 { "-debugmsg", ".debugmsg", XrmoptionSepArg, (caddr_t)NULL },
95 { "-dll", ".dll", XrmoptionSepArg, (caddr_t)NULL },
96 { "-allowreadonly", ".allowreadonly", XrmoptionNoArg, (caddr_t)"on" }
99 #define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
101 #define USAGE \
102 "Usage: %s [options] program_name [arguments]\n" \
103 "\n" \
104 "Options:\n" \
105 " -depth n Change the depth to use for multiple-depth screens\n" \
106 " -desktop geom Use a desktop window of the given geometry\n" \
107 " -display name Use the specified display\n" \
108 " -iconic Start as an icon\n" \
109 " -debug Enter debugger before starting application\n" \
110 " -name name Set the application name\n" \
111 " -privatemap Use a private color map\n" \
112 " -synchronous Turn on synchronous display mode\n" \
113 " -backingstore Turn on backing store\n" \
114 " -spy file Turn on message spying to the specified file\n" \
115 " -relaydbg Obsolete. Use -debugmsg +relay instead\n" \
116 " -debugmsg name Turn debugging-messages on or off\n" \
117 " -dll name Enable or disable built-in DLLs\n" \
118 " -allowreadonly Read only files may be opened in write mode\n"
122 /***********************************************************************
123 * MAIN_Usage
125 static void MAIN_Usage( char *name )
127 fprintf( stderr, USAGE, name );
128 exit(1);
132 /***********************************************************************
133 * MAIN_GetProgramName
135 * Get the program name. The name is specified by (in order of precedence):
136 * - the option '-name'.
137 * - the environment variable 'WINE_NAME'.
138 * - the last component of argv[0].
140 static char *MAIN_GetProgramName( int argc, char *argv[] )
142 int i;
143 char *p;
145 for (i = 1; i < argc-1; i++)
146 if (!strcmp( argv[i], "-name" )) return argv[i+1];
147 if ((p = getenv( "WINE_NAME" )) != NULL) return p;
148 if ((p = strrchr( argv[0], '/' )) != NULL) return p+1;
149 return argv[0];
153 /***********************************************************************
154 * MAIN_GetResource
156 * Fetch the value of resource 'name' using the correct instance name.
157 * 'name' must begin with '.' or '*'
159 static int MAIN_GetResource( XrmDatabase db, char *name, XrmValue *value )
161 char *buff_instance, *buff_class;
162 char *dummy;
163 int retval;
165 buff_instance = (char *)malloc(strlen(Options.programName)+strlen(name)+1);
166 buff_class = (char *)malloc( strlen(WINE_CLASS) + strlen(name) + 1 );
168 strcpy( buff_instance, Options.programName );
169 strcat( buff_instance, name );
170 strcpy( buff_class, WINE_CLASS );
171 strcat( buff_class, name );
172 retval = XrmGetResource( db, buff_instance, buff_class, &dummy, value );
173 free( buff_instance );
174 free( buff_class );
175 return retval;
179 /***********************************************************************
180 * MAIN_GetButtonText
182 * Fetch the value of resource 'name' using the correct instance name.
183 * 'name' must begin with '.' or '*'
185 * The address of the string got from the XResoure is stored in Button.Label.
186 * The corresponding hotkey is taken from this string.
189 static void MAIN_GetButtonText( XrmDatabase db, char *name, ButtonDesc *Button)
191 XrmValue value;
192 char *i;
194 if (MAIN_GetResource( db, name, &value))
196 Button->Label = value.addr;
197 i = strchr(Button->Label,'&');
198 if ( i == NULL )
199 Button->Hotkey = '\0';
200 else if ( i++ == '\0' )
201 Button->Hotkey = '\0';
202 else
203 Button->Hotkey = *i;
205 Button->Hotkey = toupper(Button->Hotkey);
208 /***********************************************************************
209 * MAIN_GetAllButtonTexts
211 * Read all Button-labels from X11-resources if they exist.
214 static void MAIN_GetAllButtonTexts(XrmDatabase db)
216 MAIN_GetButtonText(db, ".YesLabel", &ButtonText.Yes);
217 MAIN_GetButtonText(db, ".NoLabel", &ButtonText.No);
218 MAIN_GetButtonText(db, ".OkLabel", &ButtonText.Ok);
219 MAIN_GetButtonText(db, ".CancelLabel", &ButtonText.Cancel);
220 MAIN_GetButtonText(db, ".AbortLabel", &ButtonText.Abort);
221 MAIN_GetButtonText(db, ".RetryLabel", &ButtonText.Retry);
222 MAIN_GetButtonText(db, ".IgnoreLabel", &ButtonText.Ignore);
223 MAIN_GetButtonText(db, ".CancelLabel", &ButtonText.Cancel);
226 /***********************************************************************
227 * ParseDebugOptions
229 * Turns specific debug messages on or off, according to "options".
230 * Returns TRUE if parsing was successfull
232 #ifdef DEBUG_RUNTIME
234 BOOL ParseDebugOptions(char *options)
236 int l;
237 if (strlen(options)<3)
238 return FALSE;
241 if ((*options!='+')&&(*options!='-'))
242 return FALSE;
243 if (strchr(options,','))
244 l=strchr(options,',')-options;
245 else
246 l=strlen(options);
247 if (!strncasecmp(options+1,"all",l-1))
249 int i;
250 for (i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
251 debug_msg_enabled[i]=(*options=='+');
253 else
255 int i;
256 for (i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
257 if (debug_msg_name && (!strncasecmp(options+1,debug_msg_name[i],l-1)))
259 debug_msg_enabled[i]=(*options=='+');
260 break;
262 if (i==sizeof(debug_msg_enabled)/sizeof(short))
263 return FALSE;
265 options+=l;
267 while((*options==',')&&(*(++options)));
268 if (*options)
269 return FALSE;
270 else
271 return TRUE;
274 #endif
276 /***********************************************************************
277 * MAIN_ParseDLLOptions
279 * Set runtime DLL usage flags
281 static BOOL MAIN_ParseDLLOptions(char *options)
283 int l;
284 int i;
285 if (strlen(options)<3)
286 return FALSE;
289 if ((*options!='+')&&(*options!='-'))
290 return FALSE;
291 if (strchr(options,','))
292 l=strchr(options,',')-options;
293 else l=strlen(options);
294 for (i=0;i<N_BUILTINS;i++)
295 if (!strncasecmp(options+1,dll_builtin_table[i].dll_name,l-1))
297 dll_builtin_table[i].dll_is_used=(*options=='+');
298 break;
300 if (i==N_BUILTINS)
301 return FALSE;
302 options+=l;
304 while((*options==',')&&(*(++options)));
305 if (*options)
306 return FALSE;
307 else
308 return TRUE;
313 /***********************************************************************
314 * MAIN_ParseOptions
316 * Parse command line options and open display.
318 static void MAIN_ParseOptions( int *argc, char *argv[] )
320 char *display_name;
321 XrmValue value;
322 XrmDatabase db = XrmGetFileDatabase("/usr/lib/X11/app-defaults/Wine");
324 /* Parse command line */
325 Options.programName = MAIN_GetProgramName( *argc, argv );
326 XrmParseCommand( &db, optionsTable, NB_OPTIONS,
327 Options.programName, argc, argv );
329 #ifdef WINELIB
330 /* Need to assemble command line and pass it to WinMain */
331 #else
332 if (*argc < 2 || strcasecmp(argv[1], "-h") == 0)
333 MAIN_Usage( argv[0] );
334 #endif
336 /* Open display */
338 if (MAIN_GetResource( db, ".display", &value )) display_name = value.addr;
339 else display_name = NULL;
341 if (!(display = XOpenDisplay( display_name )))
343 fprintf( stderr, "%s: Can't open display: %s\n",
344 argv[0], display_name ? display_name : "" );
345 exit(1);
348 /* Get all options */
349 if (MAIN_GetResource( db, ".iconic", &value ))
350 Options.cmdShow = SW_SHOWMINIMIZED;
351 if (MAIN_GetResource( db, ".privatemap", &value ))
352 Options.usePrivateMap = TRUE;
353 if (MAIN_GetResource( db, ".synchronous", &value ))
354 Options.synchronous = TRUE;
355 if (MAIN_GetResource( db, ".backingstore", &value ))
356 Options.backingstore = TRUE;
357 if (MAIN_GetResource( db, ".debug", &value ))
358 Options.debug = TRUE;
359 if (MAIN_GetResource( db, ".allowreadonly", &value ))
360 Options.allowReadOnly = TRUE;
361 if (MAIN_GetResource( db, ".spy", &value))
362 Options.spyFilename = value.addr;
363 if (MAIN_GetResource( db, ".depth", &value))
364 screenDepth = atoi( value.addr );
365 if (MAIN_GetResource( db, ".desktop", &value))
366 Options.desktopGeometry = value.addr;
367 #ifdef DEBUG_RUNTIME
368 if (MAIN_GetResource( db, ".debugoptions", &value))
369 ParseDebugOptions((char*)value.addr);
370 #endif
371 if (MAIN_GetResource( db, ".debugmsg", &value))
373 #ifndef DEBUG_RUNTIME
374 fprintf(stderr,"%s: Option \"-debugmsg\" not implemented.\n" \
375 " Recompile with DEBUG_RUNTIME in include/stddebug.h defined.\n",
376 argv[0]);
377 exit(1);
378 #else
379 if (ParseDebugOptions((char*)value.addr)==FALSE)
381 int i;
382 fprintf(stderr,"%s: Syntax: -debugmsg +xxx,... or -debugmsg -xxx,...\n",argv[0]);
383 fprintf(stderr,"Example: -debugmsg +all,-heap turn on all messages except heap messages\n");
384 fprintf(stderr,"Available message types:\n");
385 fprintf(stderr,"%-9s ","all");
386 for(i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
387 if(debug_msg_name[i])
388 fprintf(stderr,"%-9s%c",debug_msg_name[i],
389 (((i+2)%8==0)?'\n':' '));
390 fprintf(stderr,"\n\n");
391 exit(1);
393 #endif
396 if(MAIN_GetResource( db, ".dll", &value))
397 if(MAIN_ParseDLLOptions((char*)value.addr)==FALSE)
399 int i;
400 fprintf(stderr,"%s: Syntax: -dll +xxx,... or -dll -xxx,...\n",argv[0]);
401 fprintf(stderr,"Example: -dll -ole2 Do not use emulated OLE2.DLL\n");
402 fprintf(stderr,"Available DLLs\n");
403 for(i=0;i<N_BUILTINS;i++)
404 fprintf(stderr,"%-9s%c",dll_builtin_table[i].dll_name,
405 (((i+2)%8==0)?'\n':' '));
406 fprintf(stderr,"\n\n");
407 exit(1);
410 /* MAIN_GetAllButtonTexts(db); */
415 /***********************************************************************
416 * MAIN_CreateDesktop
418 static void MAIN_CreateDesktop( int argc, char *argv[] )
420 int flags;
421 unsigned int width = 640, height = 480; /* Default size = 640x480 */
422 char *name = "Wine desktop";
423 XSizeHints *size_hints;
424 XWMHints *wm_hints;
425 XClassHint *class_hints;
426 XSetWindowAttributes win_attr;
427 XTextProperty window_name;
429 flags = XParseGeometry( Options.desktopGeometry,
430 &desktopX, &desktopY, &width, &height );
431 screenWidth = width;
432 screenHeight = height;
434 /* Create window */
436 win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
437 PointerMotionMask | ButtonPressMask |
438 ButtonReleaseMask | EnterWindowMask |
439 StructureNotifyMask;
440 win_attr.cursor = XCreateFontCursor( display, XC_top_left_arrow );
442 rootWindow = XCreateWindow( display, DefaultRootWindow(display),
443 desktopX, desktopY, width, height, 0,
444 CopyFromParent, InputOutput, CopyFromParent,
445 CWEventMask | CWCursor, &win_attr );
447 /* Set window manager properties */
449 size_hints = XAllocSizeHints();
450 wm_hints = XAllocWMHints();
451 class_hints = XAllocClassHint();
452 if (!size_hints || !wm_hints || !class_hints)
454 fprintf( stderr, "Not enough memory for window manager hints.\n" );
455 exit(1);
457 size_hints->min_width = size_hints->max_width = width;
458 size_hints->min_height = size_hints->max_height = height;
459 size_hints->flags = PMinSize | PMaxSize;
460 if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
461 if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
462 else size_hints->flags |= PSize;
464 wm_hints->flags = InputHint | StateHint;
465 wm_hints->input = True;
466 wm_hints->initial_state = NormalState;
467 class_hints->res_name = argv[0];
468 class_hints->res_class = "Wine";
470 XStringListToTextProperty( &name, 1, &window_name );
471 XSetWMProperties( display, rootWindow, &window_name, &window_name,
472 argv, argc, size_hints, wm_hints, class_hints );
473 XFree( size_hints );
474 XFree( wm_hints );
475 XFree( class_hints );
477 /* Map window */
479 XMapWindow( display, rootWindow );
483 XKeyboardState keyboard_state;
485 /***********************************************************************
486 * MAIN_SaveSetup
488 static void MAIN_SaveSetup(void)
490 XGetKeyboardControl(display, &keyboard_state);
493 /***********************************************************************
494 * MAIN_RestoreSetup
496 static void MAIN_RestoreSetup(void)
498 XKeyboardControl keyboard_value;
500 keyboard_value.key_click_percent = keyboard_state.key_click_percent;
501 keyboard_value.bell_percent = keyboard_state.bell_percent;
502 keyboard_value.bell_pitch = keyboard_state.bell_pitch;
503 keyboard_value.bell_duration = keyboard_state.bell_duration;
504 keyboard_value.auto_repeat_mode = keyboard_state.global_auto_repeat;
506 XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent |
507 KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value);
510 static void malloc_error()
512 fprintf(stderr,"malloc is not feeling well. Good bye\n");
513 exit(1);
516 static void called_at_exit(void)
518 Comm_DeInit();
519 sync_profiles();
520 MAIN_RestoreSetup();
521 WSACleanup();
524 /***********************************************************************
525 * main
527 int main( int argc, char *argv[] )
529 int ret_val;
530 int depth_count, i;
531 int *depth_list;
533 setlocale(LC_CTYPE,"");
535 XrmInitialize();
537 MAIN_ParseOptions( &argc, argv );
539 #ifdef MALLOC_DEBUGGING
540 if(debugging_malloc)
542 char *trace=getenv("MALLOC_TRACE");
543 if(!trace)
545 dprintf_malloc(stddeb,"MALLOC_TRACE not set. No trace generated\n");
546 }else
548 dprintf_malloc(stddeb,"malloc trace goes to %s\n",trace);
549 mtrace();
551 mcheck(malloc_error);
553 #endif
555 screen = DefaultScreenOfDisplay( display );
556 screenWidth = WidthOfScreen( screen );
557 screenHeight = HeightOfScreen( screen );
558 if (screenDepth) /* -depth option specified */
560 depth_list = XListDepths(display,DefaultScreen(display),&depth_count);
561 for (i = 0; i < depth_count; i++)
562 if (depth_list[i] == screenDepth) break;
563 XFree( depth_list );
564 if (i >= depth_count)
566 fprintf( stderr, "%s: Depth %d not supported on this screen.\n",
567 Options.programName, screenDepth );
568 exit(1);
571 else screenDepth = DefaultDepthOfScreen( screen );
572 if (Options.synchronous) XSynchronize( display, True );
573 if (Options.desktopGeometry) MAIN_CreateDesktop( argc, argv );
574 else rootWindow = DefaultRootWindow( display );
576 MAIN_SaveSetup();
577 DOS_InitFS();
578 Comm_Init();
579 #ifndef WINELIB
580 INT21_Init();
581 #endif
582 #ifndef sparc
583 atexit(called_at_exit);
584 #else
585 on_exit (called_at_exit, 0);
586 #endif
588 ret_val = _WinMain( argc, argv );
590 return ret_val;
593 /***********************************************************************
594 * MessageBeep (USER.104)
596 void MessageBeep(WORD i)
598 XBell(display, 100);
601 /***********************************************************************
602 * GetVersion (KERNEL.3)
604 LONG GetVersion(void)
606 return( 0x03300a03 ); /* dos 3.30 & win 3.10 */
609 /***********************************************************************
610 * GetWinFlags (KERNEL.132)
612 LONG GetWinFlags(void)
614 return (WF_STANDARD | WF_CPU286 | WF_PMODE | WF_80x87);
617 /***********************************************************************
618 * SetEnvironment (GDI.132)
620 int SetEnvironment(LPSTR lpPortName, LPSTR lpEnviron, WORD nCount)
622 LPENVENTRY lpNewEnv;
623 LPENVENTRY lpEnv = lpEnvList;
624 printf("SetEnvironnement('%s', '%s', %d) !\n",
625 lpPortName, lpEnviron, nCount);
626 if (lpPortName == NULL) return -1;
627 while (lpEnv != NULL) {
628 if (lpEnv->Name != NULL && strcmp(lpEnv->Name, lpPortName) == 0) {
629 if (nCount == 0 || lpEnviron == NULL) {
630 if (lpEnv->Prev != NULL) lpEnv->Prev->Next = lpEnv->Next;
631 if (lpEnv->Next != NULL) lpEnv->Next->Prev = lpEnv->Prev;
632 free(lpEnv->Value);
633 free(lpEnv->Name);
634 free(lpEnv);
635 printf("SetEnvironnement() // entry deleted !\n");
636 return -1;
638 free(lpEnv->Value);
639 lpEnv->Value = malloc(nCount);
640 if (lpEnv->Value == NULL) {
641 printf("SetEnvironment() // Error allocating entry value !\n");
642 return 0;
644 memcpy(lpEnv->Value, lpEnviron, nCount);
645 lpEnv->wSize = nCount;
646 printf("SetEnvironnement() // entry modified !\n");
647 return nCount;
649 if (lpEnv->Next == NULL) break;
650 lpEnv = lpEnv->Next;
652 if (nCount == 0 || lpEnviron == NULL) return -1;
653 printf("SetEnvironnement() // new entry !\n");
654 lpNewEnv = malloc(sizeof(ENVENTRY));
655 if (lpNewEnv == NULL) {
656 printf("SetEnvironment() // Error allocating new entry !\n");
657 return 0;
659 if (lpEnvList == NULL) {
660 lpEnvList = lpNewEnv;
661 lpNewEnv->Prev = NULL;
663 else {
664 lpEnv->Next = lpNewEnv;
665 lpNewEnv->Prev = lpEnv;
667 lpNewEnv->Next = NULL;
668 lpNewEnv->Name = malloc(strlen(lpPortName) + 1);
669 if (lpNewEnv->Name == NULL) {
670 printf("SetEnvironment() // Error allocating entry name !\n");
671 return 0;
673 strcpy(lpNewEnv->Name, lpPortName);
674 lpNewEnv->Value = malloc(nCount);
675 if (lpNewEnv->Value == NULL) {
676 printf("SetEnvironment() // Error allocating entry value !\n");
677 return 0;
679 memcpy(lpNewEnv->Value, lpEnviron, nCount);
680 lpNewEnv->wSize = nCount;
681 return nCount;
684 /***********************************************************************
685 * GetEnvironment (GDI.134)
687 int GetEnvironment(LPSTR lpPortName, LPSTR lpEnviron, WORD nMaxSiz)
689 WORD nCount;
690 LPENVENTRY lpEnv = lpEnvList;
691 printf("GetEnvironnement('%s', '%s', %d) !\n",
692 lpPortName, lpEnviron, nMaxSiz);
693 while (lpEnv != NULL) {
694 if (lpEnv->Name != NULL && strcmp(lpEnv->Name, lpPortName) == 0) {
695 nCount = min(nMaxSiz, lpEnv->wSize);
696 memcpy(lpEnviron, lpEnv->Value, nCount);
697 printf("GetEnvironnement() // found '%s' !\n", lpEnviron);
698 return nCount;
700 lpEnv = lpEnv->Next;
702 printf("GetEnvironnement() // not found !\n");
703 return 0;
706 /***********************************************************************
707 * GetTimerResolution (USER.14)
709 LONG GetTimerResolution(void)
711 return (1000);
714 /***********************************************************************
715 * SystemParametersInfo (USER.483)
717 BOOL SystemParametersInfo (UINT uAction, UINT uParam, void FAR *lpvParam, UINT fuWinIni)
719 int timeout, temp;
720 char buffer[256];
721 XKeyboardState keyboard_state;
722 XKeyboardControl keyboard_value;
725 fprintf(stderr, "SystemParametersInfo: action %d, param %x, flag %x\n",
726 uAction, uParam, fuWinIni);
728 switch (uAction) {
729 case SPI_GETBEEP:
730 XGetKeyboardControl(display, &keyboard_state);
731 if (keyboard_state.bell_percent == 0)
732 *(BOOL *) lpvParam = FALSE;
733 else
734 *(BOOL *) lpvParam = TRUE;
735 break;
737 case SPI_GETBORDER:
738 *(INT *) lpvParam = 1;
739 break;
741 case SPI_GETFASTTASKSWITCH:
742 *(BOOL *) lpvParam = FALSE;
743 break;
745 case SPI_GETGRIDGRANULARITY:
746 *(INT *) lpvParam = 1;
747 break;
749 case SPI_GETICONTITLEWRAP:
750 *(BOOL *) lpvParam = FALSE;
751 break;
753 case SPI_GETKEYBOARDDELAY:
754 *(INT *) lpvParam = 1;
755 break;
757 case SPI_GETKEYBOARDSPEED:
758 *(WORD *) lpvParam = 30;
759 break;
761 case SPI_GETMENUDROPALIGNMENT:
762 *(BOOL *) lpvParam = FALSE;
763 break;
765 case SPI_GETSCREENSAVEACTIVE:
766 *(BOOL *) lpvParam = FALSE;
767 break;
769 case SPI_GETSCREENSAVETIMEOUT:
770 XGetScreenSaver(display, &timeout, &temp,&temp,&temp);
771 *(INT *) lpvParam = timeout * 1000;
772 break;
774 case SPI_ICONHORIZONTALSPACING:
775 if (lpvParam == NULL)
776 fprintf(stderr, "SystemParametersInfo: Horizontal icon spacing set to %d\n.", uParam);
777 else
778 *(INT *) lpvParam = 50;
779 break;
781 case SPI_ICONVERTICALSPACING:
782 if (lpvParam == NULL)
783 fprintf(stderr, "SystemParametersInfo: Vertical icon spacing set to %d\n.", uParam);
784 else
785 *(INT *) lpvParam = 50;
786 break;
788 case SPI_SETBEEP:
789 if (uParam == TRUE)
790 keyboard_value.bell_percent = -1;
791 else
792 keyboard_value.bell_percent = 0;
793 XChangeKeyboardControl(display, KBBellPercent,
794 &keyboard_value);
795 break;
797 case SPI_SETSCREENSAVEACTIVE:
798 if (uParam == TRUE)
799 XActivateScreenSaver(display);
800 else
801 XResetScreenSaver(display);
802 break;
804 case SPI_SETSCREENSAVETIMEOUT:
805 XSetScreenSaver(display, uParam, 60, DefaultBlanking,
806 DefaultExposures);
807 break;
809 case SPI_SETDESKWALLPAPER:
810 return (SetDeskWallPaper((LPSTR) lpvParam));
811 break;
813 case SPI_SETDESKPATTERN:
814 if ((INT) uParam == -1) {
815 GetProfileString("Desktop", "Pattern",
816 "170 85 170 85 170 85 170 85",
817 buffer, sizeof(buffer) );
818 return (DESKTOP_SetPattern((LPSTR) buffer));
819 } else
820 return (DESKTOP_SetPattern((LPSTR) lpvParam));
821 break;
823 case SPI_LANGDRIVER:
824 case SPI_SETBORDER:
825 case SPI_SETDOUBLECLKHEIGHT:
826 case SPI_SETDOUBLECLICKTIME:
827 case SPI_SETDOUBLECLKWIDTH:
828 case SPI_SETFASTTASKSWITCH:
829 case SPI_SETKEYBOARDDELAY:
830 case SPI_SETKEYBOARDSPEED:
831 fprintf(stderr, "SystemParametersInfo: option %d ignored.\n", uParam);
832 break;
834 default:
835 fprintf(stderr, "SystemParametersInfo: unknown option %d.\n", uParam);
836 break;
838 return 1;
841 /***********************************************************************
842 * HMEMCPY (KERNEL.348)
844 void hmemcpy(void FAR *hpvDest, const void FAR *hpvSource, long cbCopy)
846 memcpy(hpvDest, hpvSource, cbCopy);
849 /***********************************************************************
850 * COPY (GDI.250)
852 void Copy(LPVOID lpSource, LPVOID lpDest, WORD nBytes)
854 memcpy(lpDest, lpSource, nBytes);
857 /***********************************************************************
858 * SWAPMOUSEBUTTON (USER.186)
860 BOOL SwapMouseButton(BOOL fSwap)
862 return 0; /* don't swap */
865 /***********************************************************************
866 * ISROMMODULE (KERNEL.323)
868 BOOL IsRomModule(HANDLE x)
870 /* I don't know the prototype, I assume that it returns true
871 if the dll is located in rom */
873 return FALSE;
876 /***********************************************************************
877 * FileCDR (KERNEL.130)
879 void FileCDR(FARPROC x)
881 printf("FileCDR(%8x)\n", (int) x);