4 * Copyright 1994 Alexandre Julliard
12 /* #include <locale.h> */
13 #ifdef MALLOC_DEBUGGING
17 #include <X11/Xresource.h>
18 #include <X11/Xutil.h>
19 #include <X11/Xlocale.h>
20 #include <X11/cursorfont.h>
32 #define DEBUG_DEFINE_VARIABLES
37 const char people
[] = "Wine is available thanks to the work of "
38 "Bob Amstadt, Dag Asheim, Martin Ayotte, Ross Biro, Uwe Bonnes, Erik Bos, "
39 "Fons Botman, John Brezak, Andrew Bulhak, John Burton, "
40 "Niels de Carpentier, Roman Dolejsi, Frans van Dorsselaer, Paul Falstad, "
41 "Olaf Flebbe, Peter Galbavy, Ramon Garcia, Hans de Graaff, "
42 "Charles M. Hannum, John Harvey, Cameron Heide, Jochen Hoenicke, "
43 "Onno Hovers, Jeffrey Hsu, Miguel de Icaza, Jukka Iivonen, "
44 "Alexandre Julliard, Jochen Karrer, Andreas Kirschbaum, Albrecht Kleine, "
45 "Jon Konrath, Alex Korobka, Greg Kreider, Anand Kumria, Scott A. Laird, "
46 "Martin von Loewis, Kenneth MacDonald, Peter MacDonald, William Magro, "
47 "Juergen Marquardt, Marcus Meissner, Graham Menhennitt, David Metcalfe, "
48 "Steffen Moeller, Philippe De Muyter, Itai Nahshon, Michael Patra, "
49 "Jim Peterson, Robert Pouliot, Keith Reynolds, John Richardson, "
50 "Johannes Ruscheinski, Thomas Sandford, Constantine Sapuntzakis, "
51 "Daniel Schepler, Ulrich Schmid, Bernd Schmidt, Yngvi Sigurjonsson, "
52 "Rick Sladkey, William Smith, Erik Svendsen, Tristan Tarrant, "
53 "Andrew Taylor, Duncan C Thomson, Goran Thyni, Jimmy Tirtawangsa, "
54 "Jon Tombs, Linus Torvalds, Gregory Trubetskoy, Michael Veksler, "
55 "Sven Verdoolaege, Eric Warnke, Manfred Weichel, Morten Welinder, "
56 "Jan Willamowius, Carl Williams, Karl Guenter Wuensch, Eric Youngdale, "
57 "and James Youngman. ";
59 const WINE_LANGUAGE_DEF Languages
[] =
61 {"En",0x0409}, /* LANG_En */
62 {"Es",0x040A}, /* LANG_Es */
63 {"De",0x0407}, /* LANG_De */
64 {"No",0x0414}, /* LANG_No */
65 {"Fr",0x0400}, /* LANG_Fr */
66 {"Fi",0x040B}, /* LANG_Fi */
67 {"Da",0x0406}, /* LANG_Da */
68 {"Cz",0x0405}, /* LANG_Cz */
69 {"Eo", 0}, /* LANG_Eo */ /* FIXME languageid */
70 {"It",0x0410}, /* LANG_It */
71 {"Ko",0x0412}, /* LANG_Ko */
75 WORD WINE_LanguageId
= 0;
77 #define WINE_CLASS "Wine" /* Class name for resources */
79 #define WINE_APP_DEFAULTS "/usr/lib/X11/app-defaults/Wine"
81 typedef struct tagENVENTRY
{
85 struct tagENVENTRY
*Prev
;
86 struct tagENVENTRY
*Next
;
87 } ENVENTRY
, *LPENVENTRY
;
89 LPENVENTRY lpEnvList
= NULL
;
94 int screenWidth
= 0, screenHeight
= 0; /* Desktop window dimensions */
95 int screenDepth
= 0; /* Screen depth to use */
96 int desktopX
= 0, desktopY
= 0; /* Desktop window position (if any) */
99 OSVERSIONINFO32A getVersionEx
;
101 struct options Options
=
102 { /* default options */
103 NULL
, /* desktopGeometry */
104 NULL
, /* programName */
105 FALSE
, /* usePrivateMap */
106 FALSE
, /* useFixedMap */
107 FALSE
, /* synchronous */
108 FALSE
, /* backing store */
109 SW_SHOWNORMAL
, /* cmdShow */
111 FALSE
, /* failReadOnly */
112 MODE_ENHANCED
, /* Enhanced mode */
113 FALSE
, /* IPC enabled */
115 DEFAULT_LANG
, /* Default language */
119 FALSE
, /* Managed windows */
120 FALSE
/* Perfect graphics */
124 static XrmOptionDescRec optionsTable
[] =
126 { "-backingstore", ".backingstore", XrmoptionNoArg
, (caddr_t
)"on" },
127 { "-desktop", ".desktop", XrmoptionSepArg
, (caddr_t
)NULL
},
128 { "-depth", ".depth", XrmoptionSepArg
, (caddr_t
)NULL
},
129 { "-display", ".display", XrmoptionSepArg
, (caddr_t
)NULL
},
130 { "-iconic", ".iconic", XrmoptionNoArg
, (caddr_t
)"on" },
131 { "-ipc", ".ipc", XrmoptionNoArg
, (caddr_t
)"off"},
132 { "-language", ".language", XrmoptionSepArg
, (caddr_t
)"En" },
133 { "-name", ".name", XrmoptionSepArg
, (caddr_t
)NULL
},
134 { "-perfect", ".perfect", XrmoptionNoArg
, (caddr_t
)"on" },
135 { "-privatemap", ".privatemap", XrmoptionNoArg
, (caddr_t
)"on" },
136 { "-fixedmap", ".fixedmap", XrmoptionNoArg
, (caddr_t
)"on" },
137 { "-synchronous", ".synchronous", XrmoptionNoArg
, (caddr_t
)"on" },
138 { "-debug", ".debug", XrmoptionNoArg
, (caddr_t
)"on" },
139 { "-debugmsg", ".debugmsg", XrmoptionSepArg
, (caddr_t
)NULL
},
140 { "-dll", ".dll", XrmoptionSepArg
, (caddr_t
)NULL
},
141 { "-failreadonly", ".failreadonly", XrmoptionNoArg
, (caddr_t
)"on" },
142 { "-mode", ".mode", XrmoptionSepArg
, (caddr_t
)NULL
},
143 { "-managed", ".managed", XrmoptionNoArg
, (caddr_t
)"off"},
144 { "-winver", ".winver", XrmoptionSepArg
, (caddr_t
)NULL
}
147 #define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
150 "Usage: %s [options] program_name [arguments]\n" \
153 " -backingstore Turn on backing store\n" \
154 " -debug Enter debugger before starting application\n" \
155 " -debugmsg name Turn debugging-messages on or off\n" \
156 " -depth n Change the depth to use for multiple-depth screens\n" \
157 " -desktop geom Use a desktop window of the given geometry\n" \
158 " -display name Use the specified display\n" \
159 " -dll name Enable or disable built-in DLLs\n" \
160 " -failreadonly Read only files may not be opened in write mode\n" \
161 " -fixedmap Use a \"standard\" color map\n" \
162 " -iconic Start as an icon\n" \
163 " -ipc Enable IPC facilities\n" \
164 " -language xx Set the language (one of En,Es,De,No,Fr,Fi,Da,Cz,Eo,It,Ko)\n" \
165 " -managed Allow the window manager to manage created windows\n" \
166 " -mode mode Start Wine in a particular mode (standard or enhanced)\n" \
167 " -name name Set the application name\n" \
168 " -perfect Favor correctness over speed for graphical operations\n" \
169 " -privatemap Use a private color map\n" \
170 " -synchronous Turn on synchronous display mode\n" \
171 " -winver Version to imitate (one of win31,win95,nt351)\n"
175 /***********************************************************************
179 void MAIN_Usage( char *name
)
181 fprintf( stderr
, USAGE
, name
);
187 /***********************************************************************
188 * MAIN_GetProgramName
190 * Get the program name. The name is specified by (in order of precedence):
191 * - the option '-name'.
192 * - the environment variable 'WINE_NAME'.
193 * - the last component of argv[0].
195 static char *MAIN_GetProgramName( int argc
, char *argv
[] )
200 for (i
= 1; i
< argc
-1; i
++)
201 if (!strcmp( argv
[i
], "-name" )) return argv
[i
+1];
202 if ((p
= getenv( "WINE_NAME" )) != NULL
) return p
;
203 if ((p
= strrchr( argv
[0], '/' )) != NULL
) return p
+1;
208 /***********************************************************************
211 * Fetch the value of resource 'name' using the correct instance name.
212 * 'name' must begin with '.' or '*'
214 static int MAIN_GetResource( XrmDatabase db
, char *name
, XrmValue
*value
)
216 char *buff_instance
, *buff_class
;
220 buff_instance
= (char *)xmalloc(strlen(Options
.programName
)+strlen(name
)+1);
221 buff_class
= (char *)xmalloc( strlen(WINE_CLASS
) + strlen(name
) + 1 );
223 strcpy( buff_instance
, Options
.programName
);
224 strcat( buff_instance
, name
);
225 strcpy( buff_class
, WINE_CLASS
);
226 strcat( buff_class
, name
);
227 retval
= XrmGetResource( db
, buff_instance
, buff_class
, &dummy
, value
);
228 free( buff_instance
);
234 /***********************************************************************
237 * Turns specific debug messages on or off, according to "options".
238 * Returns TRUE if parsing was successful
242 BOOL
ParseDebugOptions(char *options
)
245 if (strlen(options
)<3)
249 if ((*options
!='+')&&(*options
!='-'))
251 if (strchr(options
,','))
252 l
=strchr(options
,',')-options
;
255 if (!lstrncmpi32A(options
+1,"all",l
-1))
258 for (i
=0;i
<sizeof(debug_msg_enabled
)/sizeof(short);i
++)
259 debug_msg_enabled
[i
]=(*options
=='+');
264 for (i
=0;i
<sizeof(debug_msg_enabled
)/sizeof(short);i
++)
265 if (debug_msg_name
&& (!lstrncmpi32A(options
+1,debug_msg_name
[i
],l
-1)))
267 debug_msg_enabled
[i
]=(*options
=='+');
270 if (i
==sizeof(debug_msg_enabled
)/sizeof(short))
275 while((*options
==',')&&(*(++options
)));
285 /***********************************************************************
286 * MAIN_ParseLanguageOption
288 * Parse -language option.
290 static void MAIN_ParseLanguageOption( char *arg
)
292 const WINE_LANGUAGE_DEF
*p
= Languages
;
294 Options
.language
= LANG_En
; /* First language */
297 if (!lstrcmpi32A( p
->name
, arg
))
299 WINE_LanguageId
= p
->langid
;
304 fprintf( stderr
, "Invalid language specified '%s'. Supported languages are: ", arg
);
305 for (p
= Languages
; p
->name
; p
++) fprintf( stderr
, "%s ", p
->name
);
306 fprintf( stderr
, "\n" );
311 /***********************************************************************
312 * MAIN_ParseModeOption
314 * Parse -mode option.
316 static void MAIN_ParseModeOption( char *arg
)
318 if (!lstrcmpi32A("enhanced", arg
)) Options
.mode
= MODE_ENHANCED
;
319 else if (!lstrcmpi32A("standard", arg
)) Options
.mode
= MODE_STANDARD
;
322 fprintf(stderr
, "Invalid mode '%s' specified.\n", arg
);
323 fprintf(stderr
, "Valid modes are: 'standard', 'enhanced' (default).\n");
328 /**********************************************************************
331 static void MAIN_ParseVersion( char *arg
)
333 /* If you add any other options,
334 verify the values you return on the real thing */
335 if(strcmp(arg
,"win31")==0)
337 getVersion16
= 0x06160A03;
338 /* FIXME: My Win32s installation failed to execute the
339 MSVC 4 test program. So check these values */
340 getVersion32
= 0x80000A03;
341 getVersionEx
.dwMajorVersion
=3;
342 getVersionEx
.dwMinorVersion
=10;
343 getVersionEx
.dwBuildNumber
=0;
344 getVersionEx
.dwPlatformId
=VER_PLATFORM_WIN32s
;
345 strcpy(getVersionEx
.szCSDVersion
,"Win32s 1.3");
347 else if(strcmp(arg
, "win95")==0)
349 getVersion16
= 0x07005F03;
350 getVersion32
= 0xC0000004;
351 getVersionEx
.dwMajorVersion
=4;
352 getVersionEx
.dwMinorVersion
=0;
353 getVersionEx
.dwBuildNumber
=0x40003B6;
354 getVersionEx
.dwPlatformId
=VER_PLATFORM_WIN32_WINDOWS
;
355 strcpy(getVersionEx
.szCSDVersion
,"");
357 else if(strcmp(arg
, "nt351")==0)
359 getVersion16
= 0x05000A03;
360 getVersion32
= 0x04213303;
361 getVersionEx
.dwMajorVersion
=3;
362 getVersionEx
.dwMinorVersion
=51;
363 getVersionEx
.dwBuildNumber
=0x421;
364 getVersionEx
.dwPlatformId
=VER_PLATFORM_WIN32_NT
;
365 strcpy(getVersionEx
.szCSDVersion
,"Service Pack 2");
367 else fprintf(stderr
, "Unknown winver system code - ignored\n");
370 /***********************************************************************
373 * Parse command line options and open display.
375 static void MAIN_ParseOptions( int *argc
, char *argv
[] )
377 char *display_name
= NULL
;
379 XrmDatabase db
= XrmGetFileDatabase(WINE_APP_DEFAULTS
);
383 Options
.programName
= MAIN_GetProgramName( *argc
, argv
);
385 /* Get display name from command line */
386 for (i
= 1; i
< *argc
- 1; i
++)
387 if (!strcmp( argv
[i
], "-display" ))
389 display_name
= argv
[i
+1];
394 /* Need to assemble command line and pass it to WinMain */
396 if (*argc
< 2 || lstrcmpi32A(argv
[1], "-h") == 0)
397 MAIN_Usage( argv
[0] );
402 if (display_name
== NULL
&&
403 MAIN_GetResource( db
, ".display", &value
)) display_name
= value
.addr
;
405 if (!(display
= XOpenDisplay( display_name
)))
407 fprintf( stderr
, "%s: Can't open display: %s\n",
408 argv
[0], display_name
? display_name
: "(none specified)" );
412 /* Merge file and screen databases */
413 if ((xrm_string
= XResourceManagerString( display
)) != NULL
)
415 XrmDatabase display_db
= XrmGetStringDatabase( xrm_string
);
416 XrmMergeDatabases( display_db
, &db
);
419 /* Parse command line */
420 XrmParseCommand( &db
, optionsTable
, NB_OPTIONS
,
421 Options
.programName
, argc
, argv
);
423 /* Get all options */
424 if (MAIN_GetResource( db
, ".iconic", &value
))
425 Options
.cmdShow
= SW_SHOWMINIMIZED
;
426 if (MAIN_GetResource( db
, ".privatemap", &value
))
427 Options
.usePrivateMap
= TRUE
;
428 if (MAIN_GetResource( db
, ".fixedmap", &value
))
429 Options
.useFixedMap
= TRUE
;
430 if (MAIN_GetResource( db
, ".synchronous", &value
))
431 Options
.synchronous
= TRUE
;
432 if (MAIN_GetResource( db
, ".backingstore", &value
))
433 Options
.backingstore
= TRUE
;
434 if (MAIN_GetResource( db
, ".debug", &value
))
435 Options
.debug
= TRUE
;
436 if (MAIN_GetResource( db
, ".failreadonly", &value
))
437 Options
.failReadOnly
= TRUE
;
438 if (MAIN_GetResource( db
, ".ipc", &value
))
440 if (MAIN_GetResource( db
, ".perfect", &value
))
441 Options
.perfectGraphics
= TRUE
;
442 if (MAIN_GetResource( db
, ".depth", &value
))
443 screenDepth
= atoi( value
.addr
);
444 if (MAIN_GetResource( db
, ".desktop", &value
))
445 Options
.desktopGeometry
= value
.addr
;
446 if (MAIN_GetResource( db
, ".language", &value
))
447 MAIN_ParseLanguageOption( (char *)value
.addr
);
448 if (MAIN_GetResource( db
, ".managed", &value
))
449 Options
.managed
= TRUE
;
450 if (MAIN_GetResource( db
, ".mode", &value
))
451 MAIN_ParseModeOption( (char *)value
.addr
);
454 if (MAIN_GetResource( db
, ".debugoptions", &value
))
455 ParseDebugOptions((char*)value
.addr
);
457 if (MAIN_GetResource( db
, ".debugmsg", &value
))
459 #ifndef DEBUG_RUNTIME
460 fprintf(stderr
,"%s: Option \"-debugmsg\" not implemented.\n" \
461 " Recompile with DEBUG_RUNTIME in include/stddebug.h defined.\n",
465 if (ParseDebugOptions((char*)value
.addr
)==FALSE
)
468 fprintf(stderr
,"%s: Syntax: -debugmsg +xxx,... or -debugmsg -xxx,...\n",argv
[0]);
469 fprintf(stderr
,"Example: -debugmsg +all,-heap turn on all messages except heap messages\n");
470 fprintf(stderr
,"Available message types:\n");
471 fprintf(stderr
,"%-9s ","all");
472 for(i
=0;i
<sizeof(debug_msg_enabled
)/sizeof(short);i
++)
473 if(debug_msg_name
[i
])
474 fprintf(stderr
,"%-9s%c",debug_msg_name
[i
],
475 (((i
+2)%8==0)?'\n':' '));
476 fprintf(stderr
,"\n\n");
482 if(MAIN_GetResource( db
, ".dll", &value
))
485 if (!BUILTIN_ParseDLLOptions( (char*)value
.addr
))
487 fprintf(stderr
,"%s: Syntax: -dll +xxx,... or -dll -xxx,...\n",argv
[0]);
488 fprintf(stderr
,"Example: -dll -ole2 Do not use emulated OLE2.DLL\n");
489 fprintf(stderr
,"Available DLLs:\n");
494 fprintf(stderr
,"-dll not supported in libwine\n");
498 if(MAIN_GetResource( db
, ".winver", &value
))
499 MAIN_ParseVersion( (char*)value
.addr
);
503 /***********************************************************************
506 static void MAIN_CreateDesktop( int argc
, char *argv
[] )
509 unsigned int width
= 640, height
= 480; /* Default size = 640x480 */
510 char *name
= "Wine desktop";
511 XSizeHints
*size_hints
;
513 XClassHint
*class_hints
;
514 XSetWindowAttributes win_attr
;
515 XTextProperty window_name
;
516 Atom XA_WM_DELETE_WINDOW
;
518 flags
= XParseGeometry( Options
.desktopGeometry
,
519 &desktopX
, &desktopY
, &width
, &height
);
521 screenHeight
= height
;
525 win_attr
.event_mask
= ExposureMask
| KeyPressMask
| KeyReleaseMask
|
526 PointerMotionMask
| ButtonPressMask
|
527 ButtonReleaseMask
| EnterWindowMask
|
529 win_attr
.cursor
= XCreateFontCursor( display
, XC_top_left_arrow
);
531 rootWindow
= XCreateWindow( display
, DefaultRootWindow(display
),
532 desktopX
, desktopY
, width
, height
, 0,
533 CopyFromParent
, InputOutput
, CopyFromParent
,
534 CWEventMask
| CWCursor
, &win_attr
);
536 /* Set window manager properties */
538 size_hints
= XAllocSizeHints();
539 wm_hints
= XAllocWMHints();
540 class_hints
= XAllocClassHint();
541 if (!size_hints
|| !wm_hints
|| !class_hints
)
543 fprintf( stderr
, "Not enough memory for window manager hints.\n" );
546 size_hints
->min_width
= size_hints
->max_width
= width
;
547 size_hints
->min_height
= size_hints
->max_height
= height
;
548 size_hints
->flags
= PMinSize
| PMaxSize
;
549 if (flags
& (XValue
| YValue
)) size_hints
->flags
|= USPosition
;
550 if (flags
& (WidthValue
| HeightValue
)) size_hints
->flags
|= USSize
;
551 else size_hints
->flags
|= PSize
;
553 wm_hints
->flags
= InputHint
| StateHint
;
554 wm_hints
->input
= True
;
555 wm_hints
->initial_state
= NormalState
;
556 class_hints
->res_name
= argv
[0];
557 class_hints
->res_class
= "Wine";
559 XStringListToTextProperty( &name
, 1, &window_name
);
560 XSetWMProperties( display
, rootWindow
, &window_name
, &window_name
,
561 argv
, argc
, size_hints
, wm_hints
, class_hints
);
562 XA_WM_DELETE_WINDOW
= XInternAtom( display
, "WM_DELETE_WINDOW", False
);
563 XSetWMProtocols( display
, rootWindow
, &XA_WM_DELETE_WINDOW
, 1 );
566 XFree( class_hints
);
570 XMapWindow( display
, rootWindow
);
574 XKeyboardState keyboard_state
;
576 /***********************************************************************
579 static void MAIN_SaveSetup(void)
581 XGetKeyboardControl(display
, &keyboard_state
);
584 /***********************************************************************
587 static void MAIN_RestoreSetup(void)
589 XKeyboardControl keyboard_value
;
591 keyboard_value
.key_click_percent
= keyboard_state
.key_click_percent
;
592 keyboard_value
.bell_percent
= keyboard_state
.bell_percent
;
593 keyboard_value
.bell_pitch
= keyboard_state
.bell_pitch
;
594 keyboard_value
.bell_duration
= keyboard_state
.bell_duration
;
595 keyboard_value
.auto_repeat_mode
= keyboard_state
.global_auto_repeat
;
597 XChangeKeyboardControl(display
, KBKeyClickPercent
| KBBellPercent
|
598 KBBellPitch
| KBBellDuration
| KBAutoRepeatMode
, &keyboard_value
);
602 static void called_at_exit(void)
609 /***********************************************************************
612 * Wine initialisation and command-line parsing
614 BOOL32
MAIN_WineInit( int *argc
, char *argv
[] )
620 extern int _WinMain(int argc
, char **argv
);
622 #ifdef MALLOC_DEBUGGING
626 if (!(trace
= getenv("MALLOC_TRACE")))
628 fprintf( stderr
, "MALLOC_TRACE not set. No trace generated\n" );
632 fprintf( stderr
, "malloc trace goes to %s\n", trace
);
640 setlocale(LC_CTYPE
,"");
641 gettimeofday( &tv
, NULL
);
642 MSG_WineStartTicks
= (tv
.tv_sec
* 1000) + (tv
.tv_usec
/ 1000);
646 putenv("XKB_DISABLE="); /* Disable XKB extension if present. */
648 MAIN_ParseOptions( argc
, argv
);
650 if (Options
.desktopGeometry
&& Options
.managed
)
652 fprintf( stderr
, "%s: -managed and -desktop options cannot be used together\n",
653 Options
.programName
);
657 screen
= DefaultScreenOfDisplay( display
);
658 screenWidth
= WidthOfScreen( screen
);
659 screenHeight
= HeightOfScreen( screen
);
660 if (screenDepth
) /* -depth option specified */
662 depth_list
= XListDepths(display
,DefaultScreen(display
),&depth_count
);
663 for (i
= 0; i
< depth_count
; i
++)
664 if (depth_list
[i
] == screenDepth
) break;
666 if (i
>= depth_count
)
668 fprintf( stderr
, "%s: Depth %d not supported on this screen.\n",
669 Options
.programName
, screenDepth
);
673 else screenDepth
= DefaultDepthOfScreen( screen
);
674 if (Options
.synchronous
) XSynchronize( display
, True
);
675 if (Options
.desktopGeometry
) MAIN_CreateDesktop( *argc
, argv
);
676 else rootWindow
= DefaultRootWindow( display
);
679 atexit(called_at_exit
);
684 /***********************************************************************
685 * MessageBeep (USER.104)
687 void MessageBeep(WORD i
)
693 /***********************************************************************
696 BOOL32
Beep( DWORD dwFreq
, DWORD dwDur
)
698 /* dwFreq and dwDur are ignored by Win95 */
704 /***********************************************************************
705 * GetVersion16 (KERNEL.3)
707 LONG
GetVersion16(void)
709 if (getVersion16
) return getVersion16
;
710 return MAKELONG( WINVERSION
, WINDOSVER
);
714 /***********************************************************************
717 LONG
GetVersion32(void)
719 if (getVersion32
) return getVersion32
;
720 return MAKELONG( 4, DOSVERSION
);
724 /***********************************************************************
727 BOOL32
GetVersionEx32A(OSVERSIONINFO32A
*v
)
729 if(v
->dwOSVersionInfoSize
!=sizeof(OSVERSIONINFO32A
))
731 fprintf(stddeb
,"wrong OSVERSIONINFO size from app");
736 /* Return something like NT 3.5 */
737 v
->dwMajorVersion
= 3;
738 v
->dwMinorVersion
= 5;
739 v
->dwBuildNumber
= 42;
740 v
->dwPlatformId
= VER_PLATFORM_WIN32_NT
;
741 strcpy(v
->szCSDVersion
, "Wine is not an emulator");
744 v
->dwMajorVersion
= getVersionEx
.dwMajorVersion
;
745 v
->dwMinorVersion
= getVersionEx
.dwMinorVersion
;
746 v
->dwBuildNumber
= getVersionEx
.dwBuildNumber
;
747 v
->dwPlatformId
= getVersionEx
.dwPlatformId
;
748 strcpy(v
->szCSDVersion
, getVersionEx
.szCSDVersion
);
753 /***********************************************************************
756 BOOL32
GetVersionEx32W(OSVERSIONINFO32W
*v
)
759 if(v
->dwOSVersionInfoSize
!=sizeof(OSVERSIONINFO32W
))
761 fprintf(stddeb
,"wrong OSVERSIONINFO size from app");
764 v1
.dwOSVersionInfoSize
=sizeof(v1
);
765 GetVersionEx32A(&v1
);
766 v
->dwMajorVersion
= v1
.dwMajorVersion
;
767 v
->dwMinorVersion
= v1
.dwMinorVersion
;
768 v
->dwBuildNumber
= v1
.dwBuildNumber
;
769 v
->dwPlatformId
= v1
.dwPlatformId
;
770 lstrcpyAtoW( v
->szCSDVersion
, v1
.szCSDVersion
);
774 /***********************************************************************
775 * GetWinFlags (KERNEL.132)
777 DWORD
GetWinFlags(void)
779 static const long cpuflags
[5] =
780 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
782 long result
= 0,cpuflag
;
786 /* There doesn't seem to be any Pentium flag. */
787 cpuflag
= cpuflags
[MIN (si
.wProcessorLevel
, 4)];
789 switch(Options
.mode
) {
791 result
= (WF_STANDARD
| cpuflag
| WF_PMODE
| WF_80x87
);
795 result
= (WF_ENHANCED
| cpuflag
| WF_PMODE
| WF_80x87
| WF_PAGING
);
799 fprintf(stderr
, "Unknown mode set? This shouldn't happen. Check GetWinFlags()!\n");
802 if( getVersionEx
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
803 result
|= 0x4000; /* undocumented WF_WINNT */
807 /***********************************************************************
808 * SetEnvironment (GDI.132)
810 int SetEnvironment(LPCSTR lpPortName
, LPCSTR lpEnviron
, WORD nCount
)
813 LPENVENTRY lpEnv
= lpEnvList
;
814 dprintf_env(stddeb
, "SetEnvironment('%s', '%s', %d) !\n",
815 lpPortName
, lpEnviron
, nCount
);
816 if (lpPortName
== NULL
) return -1;
817 while (lpEnv
!= NULL
) {
818 if (lpEnv
->Name
!= NULL
&& strcmp(lpEnv
->Name
, lpPortName
) == 0) {
819 if (nCount
== 0 || lpEnviron
== NULL
) {
820 if (lpEnv
->Prev
!= NULL
) lpEnv
->Prev
->Next
= lpEnv
->Next
;
821 if (lpEnv
->Next
!= NULL
) lpEnv
->Next
->Prev
= lpEnv
->Prev
;
825 dprintf_env(stddeb
, "SetEnvironment() // entry deleted !\n");
829 lpEnv
->Value
= malloc(nCount
);
830 if (lpEnv
->Value
== NULL
) {
831 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry value !\n");
834 memcpy(lpEnv
->Value
, lpEnviron
, nCount
);
835 lpEnv
->wSize
= nCount
;
836 dprintf_env(stddeb
, "SetEnvironment() // entry modified !\n");
839 if (lpEnv
->Next
== NULL
) break;
842 if (nCount
== 0 || lpEnviron
== NULL
) return -1;
843 dprintf_env(stddeb
, "SetEnvironment() // new entry !\n");
844 lpNewEnv
= malloc(sizeof(ENVENTRY
));
845 if (lpNewEnv
== NULL
) {
846 dprintf_env(stddeb
, "SetEnvironment() // Error allocating new entry !\n");
849 if (lpEnvList
== NULL
) {
850 lpEnvList
= lpNewEnv
;
851 lpNewEnv
->Prev
= NULL
;
855 lpEnv
->Next
= lpNewEnv
;
856 lpNewEnv
->Prev
= lpEnv
;
858 lpNewEnv
->Next
= NULL
;
859 lpNewEnv
->Name
= malloc(strlen(lpPortName
) + 1);
860 if (lpNewEnv
->Name
== NULL
) {
861 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry name !\n");
864 strcpy(lpNewEnv
->Name
, lpPortName
);
865 lpNewEnv
->Value
= malloc(nCount
);
866 if (lpNewEnv
->Value
== NULL
) {
867 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry value !\n");
870 memcpy(lpNewEnv
->Value
, lpEnviron
, nCount
);
871 lpNewEnv
->wSize
= nCount
;
876 /***********************************************************************
877 * GetEnvironment (GDI.134)
879 int GetEnvironment(LPSTR lpPortName
, LPSTR lpEnviron
, WORD nMaxSiz
)
882 LPENVENTRY lpEnv
= lpEnvList
;
884 dprintf_env(stddeb
, "GetEnvironment('%s', '%s', %d) !\n",
885 lpPortName
, lpEnviron
, nMaxSiz
);
886 while (lpEnv
!= NULL
) {
887 if (lpEnv
->Name
!= NULL
&& strcmp(lpEnv
->Name
, lpPortName
) == 0) {
888 if( lpEnviron
== NULL
) return lpEnv
->wSize
;
889 nCount
= MIN(nMaxSiz
, lpEnv
->wSize
);
890 memcpy(lpEnviron
, lpEnv
->Value
, nCount
);
891 dprintf_env(stddeb
, "GetEnvironment() // found '%s' !\n", lpEnv
->Value
);
896 dprintf_env(stddeb
, "GetEnvironment() // not found !\n");
901 /***********************************************************************
902 * GetTimerResolution (USER.14)
904 LONG
GetTimerResolution(void)
909 /***********************************************************************
910 * SystemParametersInfo32A (USER32.539)
912 BOOL32
SystemParametersInfo32A( UINT32 uAction
, UINT32 uParam
,
913 LPVOID lpvParam
, UINT32 fuWinIni
)
915 return SystemParametersInfo16(uAction
,uParam
,lpvParam
,fuWinIni
);
919 /***********************************************************************
920 * SystemParametersInfo16 (USER.483)
922 BOOL16
SystemParametersInfo16( UINT16 uAction
, UINT16 uParam
,
923 LPVOID lpvParam
, UINT16 fuWinIni
)
927 XKeyboardState keyboard_state
;
928 XKeyboardControl keyboard_value
;
934 XGetKeyboardControl(display
, &keyboard_state
);
935 if (keyboard_state
.bell_percent
== 0)
936 *(BOOL
*) lpvParam
= FALSE
;
938 *(BOOL
*) lpvParam
= TRUE
;
942 *(INT
*)lpvParam
= GetSystemMetrics( SM_CXFRAME
);
945 case SPI_GETFASTTASKSWITCH
:
946 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
947 *(BOOL
*) lpvParam
= TRUE
;
949 *(BOOL
*) lpvParam
= FALSE
;
952 case SPI_GETGRIDGRANULARITY
:
953 *(INT
*) lpvParam
= GetProfileInt32A( "desktop",
958 case SPI_GETICONTITLEWRAP
:
959 *(BOOL
*) lpvParam
= GetProfileInt32A( "desktop",
964 case SPI_GETKEYBOARDDELAY
:
965 *(INT
*) lpvParam
= GetProfileInt32A( "keyboard",
966 "KeyboardDelay", 1 );
969 case SPI_GETKEYBOARDSPEED
:
970 *(WORD
*) lpvParam
= GetProfileInt32A( "keyboard",
975 case SPI_GETMENUDROPALIGNMENT
:
976 *(BOOL
*) lpvParam
= GetSystemMetrics( SM_MENUDROPALIGNMENT
); /* XXX check this */
979 case SPI_GETSCREENSAVEACTIVE
:
980 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
981 *(BOOL
*) lpvParam
= TRUE
;
983 *(BOOL
*) lpvParam
= FALSE
;
986 case SPI_GETSCREENSAVETIMEOUT
:
987 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
988 XGetScreenSaver(display
, &timeout
, &temp
,&temp
,&temp
);
989 *(INT
*) lpvParam
= timeout
* 1000;
992 case SPI_ICONHORIZONTALSPACING
:
993 /* FIXME Get/SetProfileInt */
994 if (lpvParam
== NULL
)
995 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
997 *(INT
*) lpvParam
= GetSystemMetrics( SM_CXICONSPACING
);
1000 case SPI_ICONVERTICALSPACING
:
1001 /* FIXME Get/SetProfileInt */
1002 if (lpvParam
== NULL
)
1003 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1005 *(INT
*) lpvParam
= GetSystemMetrics(SM_CYICONSPACING
);
1010 keyboard_value
.bell_percent
= -1;
1012 keyboard_value
.bell_percent
= 0;
1013 XChangeKeyboardControl(display
, KBBellPercent
,
1017 case SPI_SETSCREENSAVEACTIVE
:
1019 XActivateScreenSaver(display
);
1021 XResetScreenSaver(display
);
1024 case SPI_SETSCREENSAVETIMEOUT
:
1025 XSetScreenSaver(display
, uParam
, 60, DefaultBlanking
,
1029 case SPI_SETDESKWALLPAPER
:
1030 return (SetDeskWallPaper32((LPSTR
) lpvParam
));
1033 case SPI_SETDESKPATTERN
:
1034 if ((INT16
)uParam
== -1) {
1035 GetProfileString32A("Desktop", "Pattern",
1036 "170 85 170 85 170 85 170 85",
1037 buffer
, sizeof(buffer
) );
1038 return (DESKTOP_SetPattern((LPSTR
) buffer
));
1040 return (DESKTOP_SetPattern((LPSTR
) lpvParam
));
1043 case SPI_GETICONTITLELOGFONT
:
1045 /* FIXME GetProfileString32A( "?", "?", "?" ) */
1046 LPLOGFONT16 lpLogFont
= (LPLOGFONT16
)lpvParam
;
1047 lpLogFont
->lfHeight
= 10;
1048 lpLogFont
->lfWidth
= 0;
1049 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
1050 lpLogFont
->lfWeight
= FW_NORMAL
;
1051 lpLogFont
->lfItalic
= FALSE
;
1052 lpLogFont
->lfStrikeOut
= FALSE
;
1053 lpLogFont
->lfUnderline
= FALSE
;
1054 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
1055 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1056 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1057 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
1061 case SPI_LANGDRIVER
:
1063 case SPI_SETDOUBLECLKHEIGHT
:
1064 case SPI_SETDOUBLECLICKTIME
:
1065 case SPI_SETDOUBLECLKWIDTH
:
1066 case SPI_SETFASTTASKSWITCH
:
1067 case SPI_SETKEYBOARDDELAY
:
1068 case SPI_SETKEYBOARDSPEED
:
1069 fprintf(stderr
, "SystemParametersInfo: option %d ignored.\n", uAction
);
1072 case SPI_GETWORKAREA
:
1073 SetRect16( (RECT16
*)lpvParam
, 0, 0,
1074 GetSystemMetrics( SM_CXSCREEN
),
1075 GetSystemMetrics( SM_CYSCREEN
) );
1079 fprintf(stderr
, "SystemParametersInfo: unknown option %d.\n", uAction
);
1085 /***********************************************************************
1086 * SystemParametersInfo32W (USER32.540)
1088 BOOL32
SystemParametersInfo32W( UINT32 uAction
, UINT32 uParam
,
1089 LPVOID lpvParam
, UINT32 fuWinIni
)
1095 case SPI_SETDESKWALLPAPER
:
1098 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
1099 return SetDeskWallPaper32(buffer
);
1101 return SetDeskWallPaper32(NULL
);
1103 case SPI_SETDESKPATTERN
:
1104 if ((INT
) uParam
== -1)
1106 GetProfileString32A("Desktop", "Pattern",
1107 "170 85 170 85 170 85 170 85",
1108 buffer
, sizeof(buffer
) );
1109 return (DESKTOP_SetPattern((LPSTR
) buffer
));
1113 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
1114 return DESKTOP_SetPattern(buffer
);
1116 return DESKTOP_SetPattern(NULL
);
1118 case SPI_GETICONTITLELOGFONT
:
1120 /* FIXME GetProfileString32A( "?", "?", "?" ) */
1121 LPLOGFONT32W lpLogFont
= (LPLOGFONT32W
)lpvParam
;
1122 lpLogFont
->lfHeight
= 10;
1123 lpLogFont
->lfWidth
= 0;
1124 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
1125 lpLogFont
->lfWeight
= FW_NORMAL
;
1126 lpLogFont
->lfItalic
= lpLogFont
->lfStrikeOut
= lpLogFont
->lfUnderline
= FALSE
;
1127 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
1128 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1129 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1130 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
1135 return SystemParametersInfo32A(uAction
,uParam
,lpvParam
,fuWinIni
);
1142 /***********************************************************************
1143 * SWAPMOUSEBUTTON (USER.186)
1145 BOOL
SwapMouseButton(BOOL fSwap
)
1147 return 0; /* don't swap */
1150 /***********************************************************************
1151 * FileCDR (KERNEL.130)
1153 void FileCDR(FARPROC16 x
)
1155 printf("FileCDR(%8x)\n", (int) x
);
1158 /***********************************************************************
1159 * GetWinDebugInfo (KERNEL.355)
1161 BOOL
GetWinDebugInfo(WINDEBUGINFO
*lpwdi
, UINT flags
)
1163 printf("GetWinDebugInfo(%8lx,%d) stub returning 0\n", (unsigned long)lpwdi
, flags
);
1164 /* 0 means not in debugging mode/version */
1165 /* Can this type of debugging be used in wine ? */
1166 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1170 /***********************************************************************
1171 * GetWinDebugInfo (KERNEL.355)
1173 BOOL
SetWinDebugInfo(WINDEBUGINFO
*lpwdi
)
1175 printf("SetWinDebugInfo(%8lx) stub returning 0\n", (unsigned long)lpwdi
);
1176 /* 0 means not in debugging mode/version */
1177 /* Can this type of debugging be used in wine ? */
1178 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */