4 * Copyright 1994 Alexandre Julliard
13 #ifdef MALLOC_DEBUGGING
17 #include <X11/Xresource.h>
18 #include <X11/Xutil.h>
19 #include <X11/cursorfont.h>
29 #define DEBUG_DEFINE_VARIABLES
34 const char people
[] = "Wine is available thanks to the work of "
35 "Bob Amstadt, Dag Asheim, Martin Ayotte, Ross Biro, Uwe Bonnes, Erik Bos, "
36 "Fons Botman, John Brezak, Andrew Bulhak, John Burton, "
37 "Niels de Carpentier, Roman Dolejsi, Frans van Dorsselaer, Paul Falstad, "
38 "Olaf Flebbe, Peter Galbavy, Ramon Garcia, Hans de Graaff, "
39 "Charles M. Hannum, John Harvey, Cameron Heide, Jochen Hoenicke, "
40 "Onno Hovers, Jeffrey Hsu, Miguel de Icaza, Jukka Iivonen, "
41 "Alexandre Julliard, Jochen Karrer, Andreas Kirschbaum, Albrecht Kleine, "
42 "Jon Konrath, Alex Korobka, Greg Kreider, Anand Kumria, Scott A. Laird, "
43 "Martin von Loewis, Kenneth MacDonald, Peter MacDonald, William Magro, "
44 "Juergen Marquardt, Marcus Meissner, Graham Menhennitt, David Metcalfe, "
45 "Steffen Moeller, Philippe De Muyter, Itai Nahshon, Michael Patra, "
46 "Jim Peterson, Robert Pouliot, Keith Reynolds, John Richardson, "
47 "Johannes Ruscheinski, Thomas Sandford, Constantine Sapuntzakis, "
48 "Daniel Schepler, Ulrich Schmid, Bernd Schmidt, Yngvi Sigurjonsson, "
49 "Rick Sladkey, William Smith, Erik Svendsen, Tristan Tarrant, "
50 "Andrew Taylor, Duncan C Thomson, Goran Thyni, Jimmy Tirtawangsa, "
51 "Jon Tombs, Linus Torvalds, Gregory Trubetskoy, Michael Veksler, "
52 "Sven Verdoolaege, Eric Warnke, Manfred Weichel, Morten Welinder, "
53 "Jan Willamowius, Carl Williams, Karl Guenter Wuensch, Eric Youngdale, "
54 "and James Youngman. ";
56 const char *langNames
[] =
72 #define WINE_CLASS "Wine" /* Class name for resources */
74 typedef struct tagENVENTRY
{
78 struct tagENVENTRY
*Prev
;
79 struct tagENVENTRY
*Next
;
80 } ENVENTRY
, *LPENVENTRY
;
82 LPENVENTRY lpEnvList
= NULL
;
87 int screenWidth
= 0, screenHeight
= 0; /* Desktop window dimensions */
88 int screenDepth
= 0; /* Screen depth to use */
89 int desktopX
= 0, desktopY
= 0; /* Desktop window position (if any) */
91 struct options Options
=
92 { /* default options */
93 NULL
, /* desktopGeometry */
94 NULL
, /* programName */
95 FALSE
, /* usePrivateMap */
96 FALSE
, /* useFixedMap */
97 FALSE
, /* synchronous */
98 FALSE
, /* backing store */
99 SW_SHOWNORMAL
, /* cmdShow */
101 FALSE
, /* AllowReadOnly */
102 MODE_ENHANCED
, /* Enhanced mode */
103 FALSE
, /* IPC enabled */
105 DEFAULT_LANG
, /* Default language */
109 FALSE
/* Managed windows */
113 static XrmOptionDescRec optionsTable
[] =
115 { "-backingstore", ".backingstore", XrmoptionNoArg
, (caddr_t
)"on" },
116 { "-desktop", ".desktop", XrmoptionSepArg
, (caddr_t
)NULL
},
117 { "-depth", ".depth", XrmoptionSepArg
, (caddr_t
)NULL
},
118 { "-display", ".display", XrmoptionSepArg
, (caddr_t
)NULL
},
119 { "-iconic", ".iconic", XrmoptionNoArg
, (caddr_t
)"on" },
120 { "-ipc", ".ipc", XrmoptionNoArg
, (caddr_t
)"off"},
121 { "-language", ".language", XrmoptionSepArg
, (caddr_t
)"En" },
122 { "-name", ".name", XrmoptionSepArg
, (caddr_t
)NULL
},
123 { "-privatemap", ".privatemap", XrmoptionNoArg
, (caddr_t
)"on" },
124 { "-fixedmap", ".fixedmap", XrmoptionNoArg
, (caddr_t
)NULL
},
125 { "-synchronous", ".synchronous", XrmoptionNoArg
, (caddr_t
)"on" },
126 { "-debug", ".debug", XrmoptionNoArg
, (caddr_t
)"on" },
127 { "-debugmsg", ".debugmsg", XrmoptionSepArg
, (caddr_t
)NULL
},
128 { "-dll", ".dll", XrmoptionSepArg
, (caddr_t
)NULL
},
129 { "-allowreadonly", ".allowreadonly", XrmoptionNoArg
, (caddr_t
)"on" },
130 { "-mode", ".mode", XrmoptionSepArg
, (caddr_t
)NULL
},
131 { "-managed", ".managed", XrmoptionNoArg
, (caddr_t
)"off"}
134 #define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
137 "Usage: %s [options] program_name [arguments]\n" \
140 " -allowreadonly Read only files may be opened in write mode\n" \
141 " -backingstore Turn on backing store\n" \
142 " -debug Enter debugger before starting application\n" \
143 " -debugmsg name Turn debugging-messages on or off\n" \
144 " -depth n Change the depth to use for multiple-depth screens\n" \
145 " -desktop geom Use a desktop window of the given geometry\n" \
146 " -display name Use the specified display\n" \
147 " -dll name Enable or disable built-in DLLs\n" \
148 " -fixedmap Use a \"standard\" color map\n" \
149 " -iconic Start as an icon\n" \
150 " -ipc Enable IPC facilities\n" \
151 " -language xx Set the language (one of En,Es,De,No,Fr,Fi,Da,Cz,Eo,It,Ko)\n" \
152 " -managed Allow the window manager to manage created windows\n" \
153 " -mode mode Start Wine in a particular mode (standard or enhanced)\n" \
154 " -name name Set the application name\n" \
155 " -privatemap Use a private color map\n" \
156 " -synchronous Turn on synchronous display mode\n"
160 /***********************************************************************
164 static void MAIN_Usage( char *name
)
166 fprintf( stderr
, USAGE
, name
);
172 /***********************************************************************
173 * MAIN_GetProgramName
175 * Get the program name. The name is specified by (in order of precedence):
176 * - the option '-name'.
177 * - the environment variable 'WINE_NAME'.
178 * - the last component of argv[0].
180 static char *MAIN_GetProgramName( int argc
, char *argv
[] )
185 for (i
= 1; i
< argc
-1; i
++)
186 if (!strcmp( argv
[i
], "-name" )) return argv
[i
+1];
187 if ((p
= getenv( "WINE_NAME" )) != NULL
) return p
;
188 if ((p
= strrchr( argv
[0], '/' )) != NULL
) return p
+1;
193 /***********************************************************************
196 * Fetch the value of resource 'name' using the correct instance name.
197 * 'name' must begin with '.' or '*'
199 static int MAIN_GetResource( XrmDatabase db
, char *name
, XrmValue
*value
)
201 char *buff_instance
, *buff_class
;
205 buff_instance
= (char *)xmalloc(strlen(Options
.programName
)+strlen(name
)+1);
206 buff_class
= (char *)xmalloc( strlen(WINE_CLASS
) + strlen(name
) + 1 );
208 strcpy( buff_instance
, Options
.programName
);
209 strcat( buff_instance
, name
);
210 strcpy( buff_class
, WINE_CLASS
);
211 strcat( buff_class
, name
);
212 retval
= XrmGetResource( db
, buff_instance
, buff_class
, &dummy
, value
);
213 free( buff_instance
);
219 /***********************************************************************
222 * Turns specific debug messages on or off, according to "options".
223 * Returns TRUE if parsing was successfull
227 BOOL
ParseDebugOptions(char *options
)
230 if (strlen(options
)<3)
234 if ((*options
!='+')&&(*options
!='-'))
236 if (strchr(options
,','))
237 l
=strchr(options
,',')-options
;
240 if (!lstrncmpi(options
+1,"all",l
-1))
243 for (i
=0;i
<sizeof(debug_msg_enabled
)/sizeof(short);i
++)
244 debug_msg_enabled
[i
]=(*options
=='+');
249 for (i
=0;i
<sizeof(debug_msg_enabled
)/sizeof(short);i
++)
250 if (debug_msg_name
&& (!lstrncmpi(options
+1,debug_msg_name
[i
],l
-1)))
252 debug_msg_enabled
[i
]=(*options
=='+');
255 if (i
==sizeof(debug_msg_enabled
)/sizeof(short))
260 while((*options
==',')&&(*(++options
)));
270 /***********************************************************************
271 * MAIN_ParseLanguageOption
273 * Parse -language option.
275 static void MAIN_ParseLanguageOption( char *arg
)
277 const char **p
= langNames
;
279 Options
.language
= LANG_En
; /* First language */
280 for (p
= langNames
; *p
; p
++)
282 if (!lstrcmpi( *p
, arg
)) return;
285 fprintf( stderr
, "Invalid language specified '%s'. Supported languages are: ", arg
);
286 for (p
= langNames
; *p
; p
++) fprintf( stderr
, "%s ", *p
);
287 fprintf( stderr
, "\n" );
292 /***********************************************************************
293 * MAIN_ParseModeOption
295 * Parse -mode option.
297 static void MAIN_ParseModeOption( char *arg
)
299 if (!lstrcmpi("enhanced", arg
)) Options
.mode
= MODE_ENHANCED
;
300 else if (!lstrcmpi("standard", arg
)) Options
.mode
= MODE_STANDARD
;
303 fprintf(stderr
, "Invalid mode '%s' specified.\n", arg
);
304 fprintf(stderr
, "Valid modes are: 'standard', 'enhanced' (default).\n");
310 /***********************************************************************
313 * Parse command line options and open display.
315 static void MAIN_ParseOptions( int *argc
, char *argv
[] )
319 XrmDatabase db
= XrmGetFileDatabase("/usr/lib/X11/app-defaults/Wine");
321 /* Parse command line */
322 Options
.programName
= MAIN_GetProgramName( *argc
, argv
);
323 XrmParseCommand( &db
, optionsTable
, NB_OPTIONS
,
324 Options
.programName
, argc
, argv
);
327 /* Need to assemble command line and pass it to WinMain */
329 if (*argc
< 2 || lstrcmpi(argv
[1], "-h") == 0)
330 MAIN_Usage( argv
[0] );
335 if (MAIN_GetResource( db
, ".display", &value
)) display_name
= value
.addr
;
336 else display_name
= NULL
;
338 if (!(display
= XOpenDisplay( display_name
)))
340 fprintf( stderr
, "%s: Can't open display: %s\n",
341 argv
[0], display_name
? display_name
: "(none specified)" );
345 /* Get all options */
346 if (MAIN_GetResource( db
, ".iconic", &value
))
347 Options
.cmdShow
= SW_SHOWMINIMIZED
;
348 if (MAIN_GetResource( db
, ".privatemap", &value
))
349 Options
.usePrivateMap
= TRUE
;
350 if (MAIN_GetResource( db
, ".fixedmap", &value
))
351 Options
.useFixedMap
= TRUE
;
352 if (MAIN_GetResource( db
, ".synchronous", &value
))
353 Options
.synchronous
= TRUE
;
354 if (MAIN_GetResource( db
, ".backingstore", &value
))
355 Options
.backingstore
= TRUE
;
356 if (MAIN_GetResource( db
, ".debug", &value
))
357 Options
.debug
= TRUE
;
358 if (MAIN_GetResource( db
, ".allowreadonly", &value
))
359 Options
.allowReadOnly
= TRUE
;
360 if (MAIN_GetResource( db
, ".ipc", &value
))
362 if (MAIN_GetResource( db
, ".depth", &value
))
363 screenDepth
= atoi( value
.addr
);
364 if (MAIN_GetResource( db
, ".desktop", &value
))
365 Options
.desktopGeometry
= value
.addr
;
366 if (MAIN_GetResource( db
, ".language", &value
))
367 MAIN_ParseLanguageOption( (char *)value
.addr
);
368 if (MAIN_GetResource( db
, ".managed", &value
))
369 Options
.managed
= TRUE
;
370 if (MAIN_GetResource( db
, ".mode", &value
))
371 MAIN_ParseModeOption( (char *)value
.addr
);
374 if (MAIN_GetResource( db
, ".debugoptions", &value
))
375 ParseDebugOptions((char*)value
.addr
);
377 if (MAIN_GetResource( db
, ".debugmsg", &value
))
379 #ifndef DEBUG_RUNTIME
380 fprintf(stderr
,"%s: Option \"-debugmsg\" not implemented.\n" \
381 " Recompile with DEBUG_RUNTIME in include/stddebug.h defined.\n",
385 if (ParseDebugOptions((char*)value
.addr
)==FALSE
)
388 fprintf(stderr
,"%s: Syntax: -debugmsg +xxx,... or -debugmsg -xxx,...\n",argv
[0]);
389 fprintf(stderr
,"Example: -debugmsg +all,-heap turn on all messages except heap messages\n");
390 fprintf(stderr
,"Available message types:\n");
391 fprintf(stderr
,"%-9s ","all");
392 for(i
=0;i
<sizeof(debug_msg_enabled
)/sizeof(short);i
++)
393 if(debug_msg_name
[i
])
394 fprintf(stderr
,"%-9s%c",debug_msg_name
[i
],
395 (((i
+2)%8==0)?'\n':' '));
396 fprintf(stderr
,"\n\n");
402 if(MAIN_GetResource( db
, ".dll", &value
))
405 if (!BUILTIN_ParseDLLOptions( (char*)value
.addr
))
407 fprintf(stderr
,"%s: Syntax: -dll +xxx,... or -dll -xxx,...\n",argv
[0]);
408 fprintf(stderr
,"Example: -dll -ole2 Do not use emulated OLE2.DLL\n");
409 fprintf(stderr
,"Available DLLs:\n");
414 fprintf(stderr
,"-dll not supported in libwine\n");
420 /***********************************************************************
423 static void MAIN_CreateDesktop( int argc
, char *argv
[] )
426 unsigned int width
= 640, height
= 480; /* Default size = 640x480 */
427 char *name
= "Wine desktop";
428 XSizeHints
*size_hints
;
430 XClassHint
*class_hints
;
431 XSetWindowAttributes win_attr
;
432 XTextProperty window_name
;
433 Atom XA_WM_DELETE_WINDOW
;
435 flags
= XParseGeometry( Options
.desktopGeometry
,
436 &desktopX
, &desktopY
, &width
, &height
);
438 screenHeight
= height
;
442 win_attr
.event_mask
= ExposureMask
| KeyPressMask
| KeyReleaseMask
|
443 PointerMotionMask
| ButtonPressMask
|
444 ButtonReleaseMask
| EnterWindowMask
|
446 win_attr
.cursor
= XCreateFontCursor( display
, XC_top_left_arrow
);
448 rootWindow
= XCreateWindow( display
, DefaultRootWindow(display
),
449 desktopX
, desktopY
, width
, height
, 0,
450 CopyFromParent
, InputOutput
, CopyFromParent
,
451 CWEventMask
| CWCursor
, &win_attr
);
453 /* Set window manager properties */
455 size_hints
= XAllocSizeHints();
456 wm_hints
= XAllocWMHints();
457 class_hints
= XAllocClassHint();
458 if (!size_hints
|| !wm_hints
|| !class_hints
)
460 fprintf( stderr
, "Not enough memory for window manager hints.\n" );
463 size_hints
->min_width
= size_hints
->max_width
= width
;
464 size_hints
->min_height
= size_hints
->max_height
= height
;
465 size_hints
->flags
= PMinSize
| PMaxSize
;
466 if (flags
& (XValue
| YValue
)) size_hints
->flags
|= USPosition
;
467 if (flags
& (WidthValue
| HeightValue
)) size_hints
->flags
|= USSize
;
468 else size_hints
->flags
|= PSize
;
470 wm_hints
->flags
= InputHint
| StateHint
;
471 wm_hints
->input
= True
;
472 wm_hints
->initial_state
= NormalState
;
473 class_hints
->res_name
= argv
[0];
474 class_hints
->res_class
= "Wine";
476 XStringListToTextProperty( &name
, 1, &window_name
);
477 XSetWMProperties( display
, rootWindow
, &window_name
, &window_name
,
478 argv
, argc
, size_hints
, wm_hints
, class_hints
);
479 XA_WM_DELETE_WINDOW
= XInternAtom( display
, "WM_DELETE_WINDOW", False
);
480 XSetWMProtocols( display
, rootWindow
, &XA_WM_DELETE_WINDOW
, 1 );
483 XFree( class_hints
);
487 XMapWindow( display
, rootWindow
);
491 XKeyboardState keyboard_state
;
493 /***********************************************************************
496 static void MAIN_SaveSetup(void)
498 XGetKeyboardControl(display
, &keyboard_state
);
501 /***********************************************************************
504 static void MAIN_RestoreSetup(void)
506 XKeyboardControl keyboard_value
;
508 keyboard_value
.key_click_percent
= keyboard_state
.key_click_percent
;
509 keyboard_value
.bell_percent
= keyboard_state
.bell_percent
;
510 keyboard_value
.bell_pitch
= keyboard_state
.bell_pitch
;
511 keyboard_value
.bell_duration
= keyboard_state
.bell_duration
;
512 keyboard_value
.auto_repeat_mode
= keyboard_state
.global_auto_repeat
;
514 XChangeKeyboardControl(display
, KBKeyClickPercent
| KBBellPercent
|
515 KBBellPitch
| KBBellDuration
| KBAutoRepeatMode
, &keyboard_value
);
519 static void called_at_exit(void)
525 /***********************************************************************
528 #if defined(WINELIB) && defined(WINELIBDLL)
529 int _wine_main (int argc
, char *argv
[])
531 int main( int argc
, char *argv
[] )
539 extern int _WinMain(int argc
, char **argv
);
541 #ifdef MALLOC_DEBUGGING
545 if (!(trace
= getenv("MALLOC_TRACE")))
547 fprintf( stderr
, "MALLOC_TRACE not set. No trace generated\n" );
551 fprintf( stderr
, "malloc trace goes to %s\n", trace
);
559 setlocale(LC_CTYPE
,"");
560 gettimeofday( &tv
, NULL
);
561 MSG_WineStartTicks
= (tv
.tv_sec
* 1000) + (tv
.tv_usec
/ 1000);
565 MAIN_ParseOptions( &argc
, argv
);
568 SHELL_LoadRegistry();
570 screen
= DefaultScreenOfDisplay( display
);
571 screenWidth
= WidthOfScreen( screen
);
572 screenHeight
= HeightOfScreen( screen
);
573 if (screenDepth
) /* -depth option specified */
575 depth_list
= XListDepths(display
,DefaultScreen(display
),&depth_count
);
576 for (i
= 0; i
< depth_count
; i
++)
577 if (depth_list
[i
] == screenDepth
) break;
579 if (i
>= depth_count
)
581 fprintf( stderr
, "%s: Depth %d not supported on this screen.\n",
582 Options
.programName
, screenDepth
);
586 else screenDepth
= DefaultDepthOfScreen( screen
);
587 if (Options
.synchronous
) XSynchronize( display
, True
);
588 if (Options
.desktopGeometry
) MAIN_CreateDesktop( argc
, argv
);
589 else rootWindow
= DefaultRootWindow( display
);
592 atexit(called_at_exit
);
594 ret_val
= _WinMain( argc
, argv
);
599 /***********************************************************************
600 * MessageBeep (USER.104)
602 void MessageBeep(WORD i
)
607 /***********************************************************************
608 * GetVersion (KERNEL.3)
610 LONG
GetVersion(void)
612 return MAKELONG( WINVERSION
, WINDOSVER
);
615 /***********************************************************************
616 * GetWinFlags (KERNEL.132)
618 LONG
GetWinFlags(void)
620 static const long cpuflags
[5] =
621 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
625 /* There doesn't seem to be any Pentium flag. */
627 long cpuflag
= cpuflags
[MIN (runtime_cpu (), 4)];
629 long cpuflag
= cpuflags
[4];
632 switch(Options
.mode
) {
634 result
= (WF_STANDARD
| cpuflag
| WF_PMODE
| WF_80x87
);
638 result
= (WF_ENHANCED
| cpuflag
| WF_PMODE
| WF_80x87
| WF_PAGING
);
642 fprintf(stderr
, "Unknown mode set? This shouldn't happen. Check GetWinFlags()!\n");
649 /***********************************************************************
650 * SetEnvironment (GDI.132)
652 int SetEnvironment(LPSTR lpPortName
, LPSTR lpEnviron
, WORD nCount
)
655 LPENVENTRY lpEnv
= lpEnvList
;
656 dprintf_env(stddeb
, "SetEnvironment('%s', '%s', %d) !\n",
657 lpPortName
, lpEnviron
, nCount
);
658 if (lpPortName
== NULL
) return -1;
659 while (lpEnv
!= NULL
) {
660 if (lpEnv
->Name
!= NULL
&& strcmp(lpEnv
->Name
, lpPortName
) == 0) {
661 if (nCount
== 0 || lpEnviron
== NULL
) {
662 if (lpEnv
->Prev
!= NULL
) lpEnv
->Prev
->Next
= lpEnv
->Next
;
663 if (lpEnv
->Next
!= NULL
) lpEnv
->Next
->Prev
= lpEnv
->Prev
;
667 dprintf_env(stddeb
, "SetEnvironment() // entry deleted !\n");
671 lpEnv
->Value
= malloc(nCount
);
672 if (lpEnv
->Value
== NULL
) {
673 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry value !\n");
676 memcpy(lpEnv
->Value
, lpEnviron
, nCount
);
677 lpEnv
->wSize
= nCount
;
678 dprintf_env(stddeb
, "SetEnvironment() // entry modified !\n");
681 if (lpEnv
->Next
== NULL
) break;
684 if (nCount
== 0 || lpEnviron
== NULL
) return -1;
685 dprintf_env(stddeb
, "SetEnvironment() // new entry !\n");
686 lpNewEnv
= malloc(sizeof(ENVENTRY
));
687 if (lpNewEnv
== NULL
) {
688 dprintf_env(stddeb
, "SetEnvironment() // Error allocating new entry !\n");
691 if (lpEnvList
== NULL
) {
692 lpEnvList
= lpNewEnv
;
693 lpNewEnv
->Prev
= NULL
;
697 lpEnv
->Next
= lpNewEnv
;
698 lpNewEnv
->Prev
= lpEnv
;
700 lpNewEnv
->Next
= NULL
;
701 lpNewEnv
->Name
= malloc(strlen(lpPortName
) + 1);
702 if (lpNewEnv
->Name
== NULL
) {
703 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry name !\n");
706 strcpy(lpNewEnv
->Name
, lpPortName
);
707 lpNewEnv
->Value
= malloc(nCount
);
708 if (lpNewEnv
->Value
== NULL
) {
709 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry value !\n");
712 memcpy(lpNewEnv
->Value
, lpEnviron
, nCount
);
713 lpNewEnv
->wSize
= nCount
;
717 /***********************************************************************
718 * SetEnvironmentVariableA (KERNEL32.484)
720 BOOL
SetEnvironmentVariableA(LPSTR lpName
, LPSTR lpValue
)
724 rc
= SetEnvironment(lpName
, lpValue
, strlen(lpValue
) + 1);
725 return (rc
> 0) ? 1 : 0;
728 /***********************************************************************
729 * GetEnvironment (GDI.134)
731 int GetEnvironment(LPSTR lpPortName
, LPSTR lpEnviron
, WORD nMaxSiz
)
734 LPENVENTRY lpEnv
= lpEnvList
;
735 dprintf_env(stddeb
, "GetEnvironment('%s', '%s', %d) !\n",
736 lpPortName
, lpEnviron
, nMaxSiz
);
737 while (lpEnv
!= NULL
) {
738 if (lpEnv
->Name
!= NULL
&& strcmp(lpEnv
->Name
, lpPortName
) == 0) {
739 nCount
= MIN(nMaxSiz
, lpEnv
->wSize
);
740 memcpy(lpEnviron
, lpEnv
->Value
, nCount
);
741 dprintf_env(stddeb
, "GetEnvironment() // found '%s' !\n", lpEnviron
);
746 dprintf_env(stddeb
, "GetEnvironment() // not found !\n");
750 /***********************************************************************
751 * GetEnvironmentVariableA (KERNEL32.213)
753 DWORD
GetEnvironmentVariableA(LPSTR lpName
, LPSTR lpValue
, DWORD size
)
755 return GetEnvironment(lpName
, lpValue
, size
);
758 /***********************************************************************
759 * GetEnvironmentStrings (KERNEL32.210)
761 LPVOID
GetEnvironmentStrings(void)
765 char *envtable
, *envptr
;
767 /* Count the total number of bytes we'll need for the string
768 * table. Include the trailing nuls and the final double nul.
774 if(lpEnv
->Name
!= NULL
)
776 count
+= strlen(lpEnv
->Name
) + 1;
777 count
+= strlen(lpEnv
->Value
) + 1;
782 envtable
= malloc(count
);
790 if(lpEnv
->Name
!= NULL
)
792 count
= sprintf(envptr
, "%s=%s", lpEnv
->Name
, lpEnv
->Value
);
804 LPVOID
GetEnvironmentStringsW(void)
808 char *envtable
, *envptr
;
811 /* Count the total number of bytes we'll need for the string
812 * table. Include the trailing nuls and the final double nul.
818 if(lpEnv
->Name
!= NULL
)
820 count
+= strlen(lpEnv
->Name
) + 1;
821 count
+= strlen(lpEnv
->Value
) + 1;
827 envtable
= malloc(count
);
835 if(lpEnv
->Name
!= NULL
)
837 count
= sprintf(envptr
, "%s=%s", lpEnv
->Name
, lpEnv
->Value
);
845 wenvtable
= malloc(2*len
);
846 for(count
=0;count
<len
;count
++)
847 wenvtable
[count
]=(WCHAR
)envtable
[count
];
853 void FreeEnvironmentStringsA(void *e
)
858 void FreeEnvironmentStringsW(void* e
)
863 /***********************************************************************
864 * GetTimerResolution (USER.14)
866 LONG
GetTimerResolution(void)
871 /***********************************************************************
872 * SystemParametersInfo (USER.483)
874 BOOL
SystemParametersInfo (UINT uAction
, UINT uParam
, LPVOID lpvParam
, UINT fuWinIni
)
878 XKeyboardState keyboard_state
;
879 XKeyboardControl keyboard_value
;
882 fprintf(stderr
, "SystemParametersInfo: action %d, param %x, flag %x\n",
883 uAction
, uParam
, fuWinIni
);
887 XGetKeyboardControl(display
, &keyboard_state
);
888 if (keyboard_state
.bell_percent
== 0)
889 *(BOOL
*) lpvParam
= FALSE
;
891 *(BOOL
*) lpvParam
= TRUE
;
895 *(INT
*) lpvParam
= 1;
898 case SPI_GETFASTTASKSWITCH
:
899 *(BOOL
*) lpvParam
= FALSE
;
902 case SPI_GETGRIDGRANULARITY
:
903 *(INT
*) lpvParam
= 1;
906 case SPI_GETICONTITLEWRAP
:
907 *(BOOL
*) lpvParam
= FALSE
;
910 case SPI_GETKEYBOARDDELAY
:
911 *(INT
*) lpvParam
= 1;
914 case SPI_GETKEYBOARDSPEED
:
915 *(WORD
*) lpvParam
= 30;
918 case SPI_GETMENUDROPALIGNMENT
:
919 *(BOOL
*) lpvParam
= FALSE
;
922 case SPI_GETSCREENSAVEACTIVE
:
923 *(BOOL
*) lpvParam
= FALSE
;
926 case SPI_GETSCREENSAVETIMEOUT
:
927 XGetScreenSaver(display
, &timeout
, &temp
,&temp
,&temp
);
928 *(INT
*) lpvParam
= timeout
* 1000;
931 case SPI_ICONHORIZONTALSPACING
:
932 if (lpvParam
== NULL
)
933 fprintf(stderr
, "SystemParametersInfo: Horizontal icon spacing set to %d\n.", uParam
);
935 *(INT
*) lpvParam
= 50;
938 case SPI_ICONVERTICALSPACING
:
939 if (lpvParam
== NULL
)
940 fprintf(stderr
, "SystemParametersInfo: Vertical icon spacing set to %d\n.", uParam
);
942 *(INT
*) lpvParam
= 50;
947 keyboard_value
.bell_percent
= -1;
949 keyboard_value
.bell_percent
= 0;
950 XChangeKeyboardControl(display
, KBBellPercent
,
954 case SPI_SETSCREENSAVEACTIVE
:
956 XActivateScreenSaver(display
);
958 XResetScreenSaver(display
);
961 case SPI_SETSCREENSAVETIMEOUT
:
962 XSetScreenSaver(display
, uParam
, 60, DefaultBlanking
,
966 case SPI_SETDESKWALLPAPER
:
967 return (SetDeskWallPaper((LPSTR
) lpvParam
));
970 case SPI_SETDESKPATTERN
:
971 if ((INT
) uParam
== -1) {
972 GetProfileString("Desktop", "Pattern",
973 "170 85 170 85 170 85 170 85",
974 buffer
, sizeof(buffer
) );
975 return (DESKTOP_SetPattern((LPSTR
) buffer
));
977 return (DESKTOP_SetPattern((LPSTR
) lpvParam
));
980 case SPI_GETICONTITLELOGFONT
:
982 LPLOGFONT lpLogFont
= (LPLOGFONT
)lpvParam
;
983 lpLogFont
->lfHeight
= 10;
984 lpLogFont
->lfWidth
= 0;
985 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
986 lpLogFont
->lfWeight
= FW_NORMAL
;
987 lpLogFont
->lfItalic
= lpLogFont
->lfStrikeOut
= lpLogFont
->lfUnderline
= FALSE
;
988 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
989 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
990 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
991 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
996 case SPI_SETDOUBLECLKHEIGHT
:
997 case SPI_SETDOUBLECLICKTIME
:
998 case SPI_SETDOUBLECLKWIDTH
:
999 case SPI_SETFASTTASKSWITCH
:
1000 case SPI_SETKEYBOARDDELAY
:
1001 case SPI_SETKEYBOARDSPEED
:
1002 fprintf(stderr
, "SystemParametersInfo: option %d ignored.\n", uParam
);
1006 fprintf(stderr
, "SystemParametersInfo: unknown option %d.\n", uParam
);
1012 /***********************************************************************
1013 * HMEMCPY (KERNEL.348)
1015 void hmemcpy(LPVOID hpvDest
, LPCVOID hpvSource
, LONG cbCopy
)
1017 memcpy(hpvDest
, hpvSource
, cbCopy
);
1020 /***********************************************************************
1023 void Copy(LPVOID lpSource
, LPVOID lpDest
, WORD nBytes
)
1025 memcpy(lpDest
, lpSource
, nBytes
);
1028 /***********************************************************************
1029 * SWAPMOUSEBUTTON (USER.186)
1031 BOOL
SwapMouseButton(BOOL fSwap
)
1033 return 0; /* don't swap */
1036 /***********************************************************************
1037 * FileCDR (KERNEL.130)
1039 void FileCDR(FARPROC x
)
1041 printf("FileCDR(%8x)\n", (int) x
);
1044 /***********************************************************************
1045 * GetWinDebugInfo (KERNEL.355)
1047 BOOL
GetWinDebugInfo(WINDEBUGINFO FAR
* lpwdi
, UINT flags
)
1049 printf("GetWinDebugInfo(%8lx,%d) stub returning 0\n", (unsigned long)lpwdi
, flags
);
1050 /* 0 means not in debugging mode/version */
1051 /* Can this type of debugging be used in wine ? */
1052 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1056 /***********************************************************************
1057 * GetWinDebugInfo (KERNEL.355)
1059 BOOL
SetWinDebugInfo(WINDEBUGINFO FAR
* lpwdi
)
1061 printf("SetWinDebugInfo(%8lx) stub returning 0\n", (unsigned long)lpwdi
);
1062 /* 0 means not in debugging mode/version */
1063 /* Can this type of debugging be used in wine ? */
1064 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */