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, Erik Bos, "
36 "Fons Botman, John Brezak, Andrew Bulhak, John Burton, Paul Falstad, "
37 "Olaf Flebbe, Peter Galbavy, Ramon Garcia, Hans de Graaff, "
38 "Charles M. Hannum, Cameron Heide, Jochen Hoenicke, Jeffrey Hsu, "
39 "Miguel de Icaza, Alexandre Julliard, Jon Konrath, Scott A. Laird, "
40 "Martin von Loewis, Kenneth MacDonald, Peter MacDonald, William Magro, "
41 "Marcus Meissner, Graham Menhennitt, David Metcalfe, Michael Patra, "
42 "John Richardson, Johannes Ruscheinski, Thomas Sandford, "
43 "Constantine Sapuntzakis, Daniel Schepler, Bernd Schmidt, "
44 "Yngvi Sigurjonsson, Rick Sladkey, William Smith, Erik Svendsen, "
45 "Goran Thyni, Jimmy Tirtawangsa, Jon Tombs, Linus Torvalds, "
46 "Gregory Trubetskoy, Michael Veksler, Morten Welinder, Jan Willamowius, "
47 "Carl Williams, Karl Guenter Wuensch, Eric Youngdale, and James Youngman.";
49 static const char *langNames
[] =
63 #define WINE_CLASS "Wine" /* Class name for resources */
65 typedef struct tagENVENTRY
{
69 struct tagENVENTRY
*Prev
;
70 struct tagENVENTRY
*Next
;
71 } ENVENTRY
, *LPENVENTRY
;
73 LPENVENTRY lpEnvList
= NULL
;
78 int screenWidth
= 0, screenHeight
= 0; /* Desktop window dimensions */
79 int screenDepth
= 0; /* Screen depth to use */
80 int desktopX
= 0, desktopY
= 0; /* Desktop window position (if any) */
82 struct options Options
=
83 { /* default options */
84 NULL
, /* desktopGeometry */
85 NULL
, /* programName */
86 FALSE
, /* usePrivateMap */
87 FALSE
, /* useFixedMap */
88 FALSE
, /* synchronous */
89 FALSE
, /* backing store */
90 SW_SHOWNORMAL
, /* cmdShow */
92 FALSE
, /* AllowReadOnly */
93 MODE_ENHANCED
, /* Enhanced mode */
94 FALSE
, /* IPC enabled */
96 DEFAULT_LANG
, /* Default language */
100 FALSE
/* Managed windows */
104 static XrmOptionDescRec optionsTable
[] =
106 { "-backingstore", ".backingstore", XrmoptionNoArg
, (caddr_t
)"on" },
107 { "-desktop", ".desktop", XrmoptionSepArg
, (caddr_t
)NULL
},
108 { "-depth", ".depth", XrmoptionSepArg
, (caddr_t
)NULL
},
109 { "-display", ".display", XrmoptionSepArg
, (caddr_t
)NULL
},
110 { "-iconic", ".iconic", XrmoptionNoArg
, (caddr_t
)"on" },
111 { "-ipc", ".ipc", XrmoptionNoArg
, (caddr_t
)"off"},
112 { "-language", ".language", XrmoptionSepArg
, (caddr_t
)"En" },
113 { "-name", ".name", XrmoptionSepArg
, (caddr_t
)NULL
},
114 { "-privatemap", ".privatemap", XrmoptionNoArg
, (caddr_t
)"on" },
115 { "-fixedmap", ".fixedmap", XrmoptionNoArg
, (caddr_t
)NULL
},
116 { "-synchronous", ".synchronous", XrmoptionNoArg
, (caddr_t
)"on" },
117 { "-debug", ".debug", XrmoptionNoArg
, (caddr_t
)"on" },
118 { "-debugmsg", ".debugmsg", XrmoptionSepArg
, (caddr_t
)NULL
},
119 { "-dll", ".dll", XrmoptionSepArg
, (caddr_t
)NULL
},
120 { "-allowreadonly", ".allowreadonly", XrmoptionNoArg
, (caddr_t
)"on" },
121 { "-mode", ".mode", XrmoptionSepArg
, (caddr_t
)NULL
},
122 { "-managed", ".managed", XrmoptionNoArg
, (caddr_t
)"off"}
125 #define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
128 "Usage: %s [options] program_name [arguments]\n" \
131 " -allowreadonly Read only files may be opened in write mode\n" \
132 " -backingstore Turn on backing store\n" \
133 " -debug Enter debugger before starting application\n" \
134 " -debugmsg name Turn debugging-messages on or off\n" \
135 " -depth n Change the depth to use for multiple-depth screens\n" \
136 " -desktop geom Use a desktop window of the given geometry\n" \
137 " -display name Use the specified display\n" \
138 " -dll name Enable or disable built-in DLLs\n" \
139 " -fixedmap Use a \"standard\" color map\n" \
140 " -iconic Start as an icon\n" \
141 " -ipc Enable IPC facilities\n" \
142 " -language xx Set the language (one of En,Es,De,No,Fr,Fi,Da,Cz,Eo)\n" \
143 " -managed Allow the window manager to manage created windows\n" \
144 " -mode mode Start Wine in a particular mode (standard or enhanced)\n" \
145 " -name name Set the application name\n" \
146 " -privatemap Use a private color map\n" \
147 " -synchronous Turn on synchronous display mode\n"
151 /***********************************************************************
155 static void MAIN_Usage( char *name
)
157 fprintf( stderr
, USAGE
, name
);
163 /***********************************************************************
164 * MAIN_GetProgramName
166 * Get the program name. The name is specified by (in order of precedence):
167 * - the option '-name'.
168 * - the environment variable 'WINE_NAME'.
169 * - the last component of argv[0].
171 static char *MAIN_GetProgramName( int argc
, char *argv
[] )
176 for (i
= 1; i
< argc
-1; i
++)
177 if (!strcmp( argv
[i
], "-name" )) return argv
[i
+1];
178 if ((p
= getenv( "WINE_NAME" )) != NULL
) return p
;
179 if ((p
= strrchr( argv
[0], '/' )) != NULL
) return p
+1;
184 /***********************************************************************
187 * Fetch the value of resource 'name' using the correct instance name.
188 * 'name' must begin with '.' or '*'
190 static int MAIN_GetResource( XrmDatabase db
, char *name
, XrmValue
*value
)
192 char *buff_instance
, *buff_class
;
196 buff_instance
= (char *)xmalloc(strlen(Options
.programName
)+strlen(name
)+1);
197 buff_class
= (char *)xmalloc( strlen(WINE_CLASS
) + strlen(name
) + 1 );
199 strcpy( buff_instance
, Options
.programName
);
200 strcat( buff_instance
, name
);
201 strcpy( buff_class
, WINE_CLASS
);
202 strcat( buff_class
, name
);
203 retval
= XrmGetResource( db
, buff_instance
, buff_class
, &dummy
, value
);
204 free( buff_instance
);
210 /***********************************************************************
213 * Turns specific debug messages on or off, according to "options".
214 * Returns TRUE if parsing was successfull
218 BOOL
ParseDebugOptions(char *options
)
221 if (strlen(options
)<3)
225 if ((*options
!='+')&&(*options
!='-'))
227 if (strchr(options
,','))
228 l
=strchr(options
,',')-options
;
231 if (!lstrncmpi(options
+1,"all",l
-1))
234 for (i
=0;i
<sizeof(debug_msg_enabled
)/sizeof(short);i
++)
235 debug_msg_enabled
[i
]=(*options
=='+');
240 for (i
=0;i
<sizeof(debug_msg_enabled
)/sizeof(short);i
++)
241 if (debug_msg_name
&& (!lstrncmpi(options
+1,debug_msg_name
[i
],l
-1)))
243 debug_msg_enabled
[i
]=(*options
=='+');
246 if (i
==sizeof(debug_msg_enabled
)/sizeof(short))
251 while((*options
==',')&&(*(++options
)));
261 /***********************************************************************
262 * MAIN_ParseDLLOptions
264 * Set runtime DLL usage flags
266 static BOOL
MAIN_ParseDLLOptions(char *options
)
270 if (strlen(options
)<3)
274 if ((*options
!='+')&&(*options
!='-'))
276 if (strchr(options
,','))
277 l
=strchr(options
,',')-options
;
278 else l
=strlen(options
);
279 for (i
=0;i
<N_BUILTINS
;i
++)
280 if (!lstrncmpi(options
+1,dll_builtin_table
[i
].name
,l
-1))
282 dll_builtin_table
[i
].used
= (*options
=='+');
289 while((*options
==',')&&(*(++options
)));
299 /***********************************************************************
300 * MAIN_ParseLanguageOption
302 * Parse -language option.
304 static void MAIN_ParseLanguageOption( char *arg
)
306 const char **p
= langNames
;
308 Options
.language
= LANG_En
; /* First language */
309 for (p
= langNames
; *p
; p
++)
311 if (!lstrcmpi( *p
, arg
)) return;
314 fprintf( stderr
, "Invalid language specified '%s'. Supported languages are: ", arg
);
315 for (p
= langNames
; *p
; p
++) fprintf( stderr
, "%s ", *p
);
316 fprintf( stderr
, "\n" );
321 /***********************************************************************
322 * MAIN_ParseModeOption
324 * Parse -mode option.
326 static void MAIN_ParseModeOption( char *arg
)
328 if (!lstrcmpi("enhanced", arg
)) Options
.mode
= MODE_ENHANCED
;
329 else if (!lstrcmpi("standard", arg
)) Options
.mode
= MODE_STANDARD
;
332 fprintf(stderr
, "Invalid mode '%s' specified.\n", arg
);
333 fprintf(stderr
, "Valid modes are: 'standard', 'enhanced' (default).\n");
339 /***********************************************************************
342 * Parse command line options and open display.
344 static void MAIN_ParseOptions( int *argc
, char *argv
[] )
348 XrmDatabase db
= XrmGetFileDatabase("/usr/lib/X11/app-defaults/Wine");
350 /* Parse command line */
351 Options
.programName
= MAIN_GetProgramName( *argc
, argv
);
352 XrmParseCommand( &db
, optionsTable
, NB_OPTIONS
,
353 Options
.programName
, argc
, argv
);
356 /* Need to assemble command line and pass it to WinMain */
358 if (*argc
< 2 || lstrcmpi(argv
[1], "-h") == 0)
359 MAIN_Usage( argv
[0] );
364 if (MAIN_GetResource( db
, ".display", &value
)) display_name
= value
.addr
;
365 else display_name
= NULL
;
367 if (!(display
= XOpenDisplay( display_name
)))
369 fprintf( stderr
, "%s: Can't open display: %s\n",
370 argv
[0], display_name
? display_name
: "(none specified)" );
374 /* Get all options */
375 if (MAIN_GetResource( db
, ".iconic", &value
))
376 Options
.cmdShow
= SW_SHOWMINIMIZED
;
377 if (MAIN_GetResource( db
, ".privatemap", &value
))
378 Options
.usePrivateMap
= TRUE
;
379 if (MAIN_GetResource( db
, ".fixedmap", &value
))
380 Options
.useFixedMap
= TRUE
;
381 if (MAIN_GetResource( db
, ".synchronous", &value
))
382 Options
.synchronous
= TRUE
;
383 if (MAIN_GetResource( db
, ".backingstore", &value
))
384 Options
.backingstore
= TRUE
;
385 if (MAIN_GetResource( db
, ".debug", &value
))
386 Options
.debug
= TRUE
;
387 if (MAIN_GetResource( db
, ".allowreadonly", &value
))
388 Options
.allowReadOnly
= TRUE
;
389 if (MAIN_GetResource( db
, ".ipc", &value
))
391 if (MAIN_GetResource( db
, ".depth", &value
))
392 screenDepth
= atoi( value
.addr
);
393 if (MAIN_GetResource( db
, ".desktop", &value
))
394 Options
.desktopGeometry
= value
.addr
;
395 if (MAIN_GetResource( db
, ".language", &value
))
396 MAIN_ParseLanguageOption( (char *)value
.addr
);
397 if (MAIN_GetResource( db
, ".managed", &value
))
398 Options
.managed
= TRUE
;
399 if (MAIN_GetResource( db
, ".mode", &value
))
400 MAIN_ParseModeOption( (char *)value
.addr
);
403 if (MAIN_GetResource( db
, ".debugoptions", &value
))
404 ParseDebugOptions((char*)value
.addr
);
406 if (MAIN_GetResource( db
, ".debugmsg", &value
))
408 #ifndef DEBUG_RUNTIME
409 fprintf(stderr
,"%s: Option \"-debugmsg\" not implemented.\n" \
410 " Recompile with DEBUG_RUNTIME in include/stddebug.h defined.\n",
414 if (ParseDebugOptions((char*)value
.addr
)==FALSE
)
417 fprintf(stderr
,"%s: Syntax: -debugmsg +xxx,... or -debugmsg -xxx,...\n",argv
[0]);
418 fprintf(stderr
,"Example: -debugmsg +all,-heap turn on all messages except heap messages\n");
419 fprintf(stderr
,"Available message types:\n");
420 fprintf(stderr
,"%-9s ","all");
421 for(i
=0;i
<sizeof(debug_msg_enabled
)/sizeof(short);i
++)
422 if(debug_msg_name
[i
])
423 fprintf(stderr
,"%-9s%c",debug_msg_name
[i
],
424 (((i
+2)%8==0)?'\n':' '));
425 fprintf(stderr
,"\n\n");
431 if(MAIN_GetResource( db
, ".dll", &value
))
433 if(MAIN_ParseDLLOptions((char*)value
.addr
)==FALSE
)
436 fprintf(stderr
,"%s: Syntax: -dll +xxx,... or -dll -xxx,...\n",argv
[0]);
437 fprintf(stderr
,"Example: -dll -ole2 Do not use emulated OLE2.DLL\n");
438 fprintf(stderr
,"Available DLLs\n");
439 for(i
=0;i
<N_BUILTINS
;i
++)
440 fprintf(stderr
,"%-9s%c",dll_builtin_table
[i
].name
,
441 (((i
+2)%8==0)?'\n':' '));
442 fprintf(stderr
,"\n\n");
446 fprintf(stderr
,"-dll not supported in libwine\n");
451 /***********************************************************************
454 static void MAIN_CreateDesktop( int argc
, char *argv
[] )
457 unsigned int width
= 640, height
= 480; /* Default size = 640x480 */
458 char *name
= "Wine desktop";
459 XSizeHints
*size_hints
;
461 XClassHint
*class_hints
;
462 XSetWindowAttributes win_attr
;
463 XTextProperty window_name
;
464 Atom XA_WM_DELETE_WINDOW
;
466 flags
= XParseGeometry( Options
.desktopGeometry
,
467 &desktopX
, &desktopY
, &width
, &height
);
469 screenHeight
= height
;
473 win_attr
.event_mask
= ExposureMask
| KeyPressMask
| KeyReleaseMask
|
474 PointerMotionMask
| ButtonPressMask
|
475 ButtonReleaseMask
| EnterWindowMask
|
477 win_attr
.cursor
= XCreateFontCursor( display
, XC_top_left_arrow
);
479 rootWindow
= XCreateWindow( display
, DefaultRootWindow(display
),
480 desktopX
, desktopY
, width
, height
, 0,
481 CopyFromParent
, InputOutput
, CopyFromParent
,
482 CWEventMask
| CWCursor
, &win_attr
);
484 /* Set window manager properties */
486 size_hints
= XAllocSizeHints();
487 wm_hints
= XAllocWMHints();
488 class_hints
= XAllocClassHint();
489 if (!size_hints
|| !wm_hints
|| !class_hints
)
491 fprintf( stderr
, "Not enough memory for window manager hints.\n" );
494 size_hints
->min_width
= size_hints
->max_width
= width
;
495 size_hints
->min_height
= size_hints
->max_height
= height
;
496 size_hints
->flags
= PMinSize
| PMaxSize
;
497 if (flags
& (XValue
| YValue
)) size_hints
->flags
|= USPosition
;
498 if (flags
& (WidthValue
| HeightValue
)) size_hints
->flags
|= USSize
;
499 else size_hints
->flags
|= PSize
;
501 wm_hints
->flags
= InputHint
| StateHint
;
502 wm_hints
->input
= True
;
503 wm_hints
->initial_state
= NormalState
;
504 class_hints
->res_name
= argv
[0];
505 class_hints
->res_class
= "Wine";
507 XStringListToTextProperty( &name
, 1, &window_name
);
508 XSetWMProperties( display
, rootWindow
, &window_name
, &window_name
,
509 argv
, argc
, size_hints
, wm_hints
, class_hints
);
510 XA_WM_DELETE_WINDOW
= XInternAtom( display
, "WM_DELETE_WINDOW", False
);
511 XSetWMProtocols( display
, rootWindow
, &XA_WM_DELETE_WINDOW
, 1 );
514 XFree( class_hints
);
518 XMapWindow( display
, rootWindow
);
522 XKeyboardState keyboard_state
;
524 /***********************************************************************
527 static void MAIN_SaveSetup(void)
529 XGetKeyboardControl(display
, &keyboard_state
);
532 /***********************************************************************
535 static void MAIN_RestoreSetup(void)
537 XKeyboardControl keyboard_value
;
539 keyboard_value
.key_click_percent
= keyboard_state
.key_click_percent
;
540 keyboard_value
.bell_percent
= keyboard_state
.bell_percent
;
541 keyboard_value
.bell_pitch
= keyboard_state
.bell_pitch
;
542 keyboard_value
.bell_duration
= keyboard_state
.bell_duration
;
543 keyboard_value
.auto_repeat_mode
= keyboard_state
.global_auto_repeat
;
545 XChangeKeyboardControl(display
, KBKeyClickPercent
| KBBellPercent
|
546 KBBellPitch
| KBBellDuration
| KBAutoRepeatMode
, &keyboard_value
);
550 static void called_at_exit(void)
556 /***********************************************************************
559 #if defined(WINELIB) && defined(WINELIBDLL)
560 int _wine_main (int argc
, char *argv
[])
562 int main( int argc
, char *argv
[] )
570 extern int _WinMain(int argc
, char **argv
);
572 #ifdef MALLOC_DEBUGGING
576 if (!(trace
= getenv("MALLOC_TRACE")))
578 fprintf( stderr
, "MALLOC_TRACE not set. No trace generated\n" );
582 fprintf( stderr
, "malloc trace goes to %s\n", trace
);
590 setlocale(LC_CTYPE
,"");
591 gettimeofday( &tv
, NULL
);
592 MSG_WineStartTicks
= (tv
.tv_sec
* 1000) + (tv
.tv_usec
/ 1000);
596 MAIN_ParseOptions( &argc
, argv
);
599 SHELL_LoadRegistry();
601 screen
= DefaultScreenOfDisplay( display
);
602 screenWidth
= WidthOfScreen( screen
);
603 screenHeight
= HeightOfScreen( screen
);
604 if (screenDepth
) /* -depth option specified */
606 depth_list
= XListDepths(display
,DefaultScreen(display
),&depth_count
);
607 for (i
= 0; i
< depth_count
; i
++)
608 if (depth_list
[i
] == screenDepth
) break;
610 if (i
>= depth_count
)
612 fprintf( stderr
, "%s: Depth %d not supported on this screen.\n",
613 Options
.programName
, screenDepth
);
617 else screenDepth
= DefaultDepthOfScreen( screen
);
618 if (Options
.synchronous
) XSynchronize( display
, True
);
619 if (Options
.desktopGeometry
) MAIN_CreateDesktop( argc
, argv
);
620 else rootWindow
= DefaultRootWindow( display
);
623 atexit(called_at_exit
);
625 ret_val
= _WinMain( argc
, argv
);
630 /***********************************************************************
631 * MessageBeep (USER.104)
633 void MessageBeep(WORD i
)
638 /***********************************************************************
639 * GetVersion (KERNEL.3)
641 LONG
GetVersion(void)
643 return MAKELONG( WINVERSION
, WINDOSVER
);
646 /***********************************************************************
647 * GetWinFlags (KERNEL.132)
649 LONG
GetWinFlags(void)
651 static const long cpuflags
[5] =
652 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
656 /* There doesn't seem to be any Pentium flag. */
658 long cpuflag
= cpuflags
[MIN (runtime_cpu (), 4)];
660 long cpuflag
= cpuflags
[4];
663 switch(Options
.mode
) {
665 result
= (WF_STANDARD
| cpuflag
| WF_PMODE
| WF_80x87
);
669 result
= (WF_ENHANCED
| cpuflag
| WF_PMODE
| WF_80x87
| WF_PAGING
);
673 fprintf(stderr
, "Unknown mode set? This shouldn't happen. Check GetWinFlags()!\n");
680 /***********************************************************************
681 * SetEnvironment (GDI.132)
683 int SetEnvironment(LPSTR lpPortName
, LPSTR lpEnviron
, WORD nCount
)
686 LPENVENTRY lpEnv
= lpEnvList
;
687 dprintf_env(stddeb
, "SetEnvironment('%s', '%s', %d) !\n",
688 lpPortName
, lpEnviron
, nCount
);
689 if (lpPortName
== NULL
) return -1;
690 while (lpEnv
!= NULL
) {
691 if (lpEnv
->Name
!= NULL
&& strcmp(lpEnv
->Name
, lpPortName
) == 0) {
692 if (nCount
== 0 || lpEnviron
== NULL
) {
693 if (lpEnv
->Prev
!= NULL
) lpEnv
->Prev
->Next
= lpEnv
->Next
;
694 if (lpEnv
->Next
!= NULL
) lpEnv
->Next
->Prev
= lpEnv
->Prev
;
698 dprintf_env(stddeb
, "SetEnvironment() // entry deleted !\n");
702 lpEnv
->Value
= malloc(nCount
);
703 if (lpEnv
->Value
== NULL
) {
704 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry value !\n");
707 memcpy(lpEnv
->Value
, lpEnviron
, nCount
);
708 lpEnv
->wSize
= nCount
;
709 dprintf_env(stddeb
, "SetEnvironment() // entry modified !\n");
712 if (lpEnv
->Next
== NULL
) break;
715 if (nCount
== 0 || lpEnviron
== NULL
) return -1;
716 dprintf_env(stddeb
, "SetEnvironment() // new entry !\n");
717 lpNewEnv
= malloc(sizeof(ENVENTRY
));
718 if (lpNewEnv
== NULL
) {
719 dprintf_env(stddeb
, "SetEnvironment() // Error allocating new entry !\n");
722 if (lpEnvList
== NULL
) {
723 lpEnvList
= lpNewEnv
;
724 lpNewEnv
->Prev
= NULL
;
728 lpEnv
->Next
= lpNewEnv
;
729 lpNewEnv
->Prev
= lpEnv
;
731 lpNewEnv
->Next
= NULL
;
732 lpNewEnv
->Name
= malloc(strlen(lpPortName
) + 1);
733 if (lpNewEnv
->Name
== NULL
) {
734 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry name !\n");
737 strcpy(lpNewEnv
->Name
, lpPortName
);
738 lpNewEnv
->Value
= malloc(nCount
);
739 if (lpNewEnv
->Value
== NULL
) {
740 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry value !\n");
743 memcpy(lpNewEnv
->Value
, lpEnviron
, nCount
);
744 lpNewEnv
->wSize
= nCount
;
748 /***********************************************************************
749 * SetEnvironmentVariableA (KERNEL32.484)
751 BOOL
SetEnvironmentVariableA(LPSTR lpName
, LPSTR lpValue
)
755 rc
= SetEnvironment(lpName
, lpValue
, strlen(lpValue
) + 1);
756 return (rc
> 0) ? 1 : 0;
759 /***********************************************************************
760 * GetEnvironment (GDI.134)
762 int GetEnvironment(LPSTR lpPortName
, LPSTR lpEnviron
, WORD nMaxSiz
)
765 LPENVENTRY lpEnv
= lpEnvList
;
766 dprintf_env(stddeb
, "GetEnvironment('%s', '%s', %d) !\n",
767 lpPortName
, lpEnviron
, nMaxSiz
);
768 while (lpEnv
!= NULL
) {
769 if (lpEnv
->Name
!= NULL
&& strcmp(lpEnv
->Name
, lpPortName
) == 0) {
770 nCount
= MIN(nMaxSiz
, lpEnv
->wSize
);
771 memcpy(lpEnviron
, lpEnv
->Value
, nCount
);
772 dprintf_env(stddeb
, "GetEnvironment() // found '%s' !\n", lpEnviron
);
777 dprintf_env(stddeb
, "GetEnvironment() // not found !\n");
781 /***********************************************************************
782 * GetEnvironmentVariableA (KERNEL32.213)
784 DWORD
GetEnvironmentVariableA(LPSTR lpName
, LPSTR lpValue
, DWORD size
)
786 return GetEnvironment(lpName
, lpValue
, size
);
789 /***********************************************************************
790 * GetEnvironmentStrings (KERNEL32.210)
792 LPVOID
GetEnvironmentStrings(void)
796 char *envtable
, *envptr
;
798 /* Count the total number of bytes we'll need for the string
799 * table. Include the trailing nuls and the final double nul.
805 if(lpEnv
->Name
!= NULL
)
807 count
+= strlen(lpEnv
->Name
) + 1;
808 count
+= strlen(lpEnv
->Value
) + 1;
813 envtable
= malloc(count
);
821 if(lpEnv
->Name
!= NULL
)
823 count
= sprintf(envptr
, "%s=%s", lpEnv
->Name
, lpEnv
->Value
);
834 /***********************************************************************
835 * GetTimerResolution (USER.14)
837 LONG
GetTimerResolution(void)
842 /***********************************************************************
843 * SystemParametersInfo (USER.483)
845 BOOL
SystemParametersInfo (UINT uAction
, UINT uParam
, LPVOID lpvParam
, UINT fuWinIni
)
849 XKeyboardState keyboard_state
;
850 XKeyboardControl keyboard_value
;
853 fprintf(stderr
, "SystemParametersInfo: action %d, param %x, flag %x\n",
854 uAction
, uParam
, fuWinIni
);
858 XGetKeyboardControl(display
, &keyboard_state
);
859 if (keyboard_state
.bell_percent
== 0)
860 *(BOOL
*) lpvParam
= FALSE
;
862 *(BOOL
*) lpvParam
= TRUE
;
866 *(INT
*) lpvParam
= 1;
869 case SPI_GETFASTTASKSWITCH
:
870 *(BOOL
*) lpvParam
= FALSE
;
873 case SPI_GETGRIDGRANULARITY
:
874 *(INT
*) lpvParam
= 1;
877 case SPI_GETICONTITLEWRAP
:
878 *(BOOL
*) lpvParam
= FALSE
;
881 case SPI_GETKEYBOARDDELAY
:
882 *(INT
*) lpvParam
= 1;
885 case SPI_GETKEYBOARDSPEED
:
886 *(WORD
*) lpvParam
= 30;
889 case SPI_GETMENUDROPALIGNMENT
:
890 *(BOOL
*) lpvParam
= FALSE
;
893 case SPI_GETSCREENSAVEACTIVE
:
894 *(BOOL
*) lpvParam
= FALSE
;
897 case SPI_GETSCREENSAVETIMEOUT
:
898 XGetScreenSaver(display
, &timeout
, &temp
,&temp
,&temp
);
899 *(INT
*) lpvParam
= timeout
* 1000;
902 case SPI_ICONHORIZONTALSPACING
:
903 if (lpvParam
== NULL
)
904 fprintf(stderr
, "SystemParametersInfo: Horizontal icon spacing set to %d\n.", uParam
);
906 *(INT
*) lpvParam
= 50;
909 case SPI_ICONVERTICALSPACING
:
910 if (lpvParam
== NULL
)
911 fprintf(stderr
, "SystemParametersInfo: Vertical icon spacing set to %d\n.", uParam
);
913 *(INT
*) lpvParam
= 50;
918 keyboard_value
.bell_percent
= -1;
920 keyboard_value
.bell_percent
= 0;
921 XChangeKeyboardControl(display
, KBBellPercent
,
925 case SPI_SETSCREENSAVEACTIVE
:
927 XActivateScreenSaver(display
);
929 XResetScreenSaver(display
);
932 case SPI_SETSCREENSAVETIMEOUT
:
933 XSetScreenSaver(display
, uParam
, 60, DefaultBlanking
,
937 case SPI_SETDESKWALLPAPER
:
938 return (SetDeskWallPaper((LPSTR
) lpvParam
));
941 case SPI_SETDESKPATTERN
:
942 if ((INT
) uParam
== -1) {
943 GetProfileString("Desktop", "Pattern",
944 "170 85 170 85 170 85 170 85",
945 buffer
, sizeof(buffer
) );
946 return (DESKTOP_SetPattern((LPSTR
) buffer
));
948 return (DESKTOP_SetPattern((LPSTR
) lpvParam
));
951 case SPI_GETICONTITLELOGFONT
:
953 LPLOGFONT lpLogFont
= (LPLOGFONT
)lpvParam
;
954 lpLogFont
->lfHeight
= 10;
955 lpLogFont
->lfWidth
= 0;
956 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
957 lpLogFont
->lfWeight
= FW_NORMAL
;
958 lpLogFont
->lfItalic
= lpLogFont
->lfStrikeOut
= lpLogFont
->lfUnderline
= FALSE
;
959 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
960 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
961 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
962 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
967 case SPI_SETDOUBLECLKHEIGHT
:
968 case SPI_SETDOUBLECLICKTIME
:
969 case SPI_SETDOUBLECLKWIDTH
:
970 case SPI_SETFASTTASKSWITCH
:
971 case SPI_SETKEYBOARDDELAY
:
972 case SPI_SETKEYBOARDSPEED
:
973 fprintf(stderr
, "SystemParametersInfo: option %d ignored.\n", uParam
);
977 fprintf(stderr
, "SystemParametersInfo: unknown option %d.\n", uParam
);
983 /***********************************************************************
984 * HMEMCPY (KERNEL.348)
986 void hmemcpy(LPVOID hpvDest
, LPCVOID hpvSource
, LONG cbCopy
)
988 memcpy(hpvDest
, hpvSource
, cbCopy
);
991 /***********************************************************************
994 void Copy(LPVOID lpSource
, LPVOID lpDest
, WORD nBytes
)
996 memcpy(lpDest
, lpSource
, nBytes
);
999 /***********************************************************************
1000 * SWAPMOUSEBUTTON (USER.186)
1002 BOOL
SwapMouseButton(BOOL fSwap
)
1004 return 0; /* don't swap */
1007 /***********************************************************************
1008 * FileCDR (KERNEL.130)
1010 void FileCDR(FARPROC x
)
1012 printf("FileCDR(%8x)\n", (int) x
);
1015 /***********************************************************************
1016 * GetWinDebugInfo (KERNEL.355)
1018 BOOL
GetWinDebugInfo(WINDEBUGINFO FAR
* lpwdi
, UINT flags
)
1020 printf("GetWinDebugInfo(%8lx,%d) stub returning 0\n", (unsigned long)lpwdi
, flags
);
1021 /* 0 means not in debugging mode/version */
1022 /* Can this type of debugging be used in wine ? */
1023 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1027 /***********************************************************************
1028 * GetWinDebugInfo (KERNEL.355)
1030 BOOL
SetWinDebugInfo(WINDEBUGINFO FAR
* lpwdi
)
1032 printf("SetWinDebugInfo(%8lx) stub returning 0\n", (unsigned long)lpwdi
);
1033 /* 0 means not in debugging mode/version */
1034 /* Can this type of debugging be used in wine ? */
1035 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */