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
)"on" },
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
);
567 screen
= DefaultScreenOfDisplay( display
);
568 screenWidth
= WidthOfScreen( screen
);
569 screenHeight
= HeightOfScreen( screen
);
570 if (screenDepth
) /* -depth option specified */
572 depth_list
= XListDepths(display
,DefaultScreen(display
),&depth_count
);
573 for (i
= 0; i
< depth_count
; i
++)
574 if (depth_list
[i
] == screenDepth
) break;
576 if (i
>= depth_count
)
578 fprintf( stderr
, "%s: Depth %d not supported on this screen.\n",
579 Options
.programName
, screenDepth
);
583 else screenDepth
= DefaultDepthOfScreen( screen
);
584 if (Options
.synchronous
) XSynchronize( display
, True
);
585 if (Options
.desktopGeometry
) MAIN_CreateDesktop( argc
, argv
);
586 else rootWindow
= DefaultRootWindow( display
);
589 atexit(called_at_exit
);
591 ret_val
= _WinMain( argc
, argv
);
596 /***********************************************************************
597 * MessageBeep (USER.104)
599 void MessageBeep(WORD i
)
604 /***********************************************************************
605 * GetVersion (KERNEL.3)
607 LONG
GetVersion(void)
609 return MAKELONG( WINVERSION
, WINDOSVER
);
612 /***********************************************************************
613 * GetWinFlags (KERNEL.132)
615 LONG
GetWinFlags(void)
617 static const long cpuflags
[5] =
618 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
622 /* There doesn't seem to be any Pentium flag. */
624 long cpuflag
= cpuflags
[MIN (runtime_cpu (), 4)];
626 long cpuflag
= cpuflags
[4];
629 switch(Options
.mode
) {
631 result
= (WF_STANDARD
| cpuflag
| WF_PMODE
| WF_80x87
);
635 result
= (WF_ENHANCED
| cpuflag
| WF_PMODE
| WF_80x87
| WF_PAGING
);
639 fprintf(stderr
, "Unknown mode set? This shouldn't happen. Check GetWinFlags()!\n");
646 /***********************************************************************
647 * SetEnvironment (GDI.132)
649 int SetEnvironment(LPSTR lpPortName
, LPSTR lpEnviron
, WORD nCount
)
652 LPENVENTRY lpEnv
= lpEnvList
;
653 dprintf_env(stddeb
, "SetEnvironment('%s', '%s', %d) !\n",
654 lpPortName
, lpEnviron
, nCount
);
655 if (lpPortName
== NULL
) return -1;
656 while (lpEnv
!= NULL
) {
657 if (lpEnv
->Name
!= NULL
&& strcmp(lpEnv
->Name
, lpPortName
) == 0) {
658 if (nCount
== 0 || lpEnviron
== NULL
) {
659 if (lpEnv
->Prev
!= NULL
) lpEnv
->Prev
->Next
= lpEnv
->Next
;
660 if (lpEnv
->Next
!= NULL
) lpEnv
->Next
->Prev
= lpEnv
->Prev
;
664 dprintf_env(stddeb
, "SetEnvironment() // entry deleted !\n");
668 lpEnv
->Value
= malloc(nCount
);
669 if (lpEnv
->Value
== NULL
) {
670 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry value !\n");
673 memcpy(lpEnv
->Value
, lpEnviron
, nCount
);
674 lpEnv
->wSize
= nCount
;
675 dprintf_env(stddeb
, "SetEnvironment() // entry modified !\n");
678 if (lpEnv
->Next
== NULL
) break;
681 if (nCount
== 0 || lpEnviron
== NULL
) return -1;
682 dprintf_env(stddeb
, "SetEnvironment() // new entry !\n");
683 lpNewEnv
= malloc(sizeof(ENVENTRY
));
684 if (lpNewEnv
== NULL
) {
685 dprintf_env(stddeb
, "SetEnvironment() // Error allocating new entry !\n");
688 if (lpEnvList
== NULL
) {
689 lpEnvList
= lpNewEnv
;
690 lpNewEnv
->Prev
= NULL
;
694 lpEnv
->Next
= lpNewEnv
;
695 lpNewEnv
->Prev
= lpEnv
;
697 lpNewEnv
->Next
= NULL
;
698 lpNewEnv
->Name
= malloc(strlen(lpPortName
) + 1);
699 if (lpNewEnv
->Name
== NULL
) {
700 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry name !\n");
703 strcpy(lpNewEnv
->Name
, lpPortName
);
704 lpNewEnv
->Value
= malloc(nCount
);
705 if (lpNewEnv
->Value
== NULL
) {
706 dprintf_env(stddeb
, "SetEnvironment() // Error allocating entry value !\n");
709 memcpy(lpNewEnv
->Value
, lpEnviron
, nCount
);
710 lpNewEnv
->wSize
= nCount
;
714 /***********************************************************************
715 * SetEnvironmentVariableA (KERNEL32.484)
717 BOOL
SetEnvironmentVariableA(LPSTR lpName
, LPSTR lpValue
)
721 rc
= SetEnvironment(lpName
, lpValue
, strlen(lpValue
) + 1);
722 return (rc
> 0) ? 1 : 0;
725 /***********************************************************************
726 * GetEnvironment (GDI.134)
728 int GetEnvironment(LPSTR lpPortName
, LPSTR lpEnviron
, WORD nMaxSiz
)
731 LPENVENTRY lpEnv
= lpEnvList
;
732 dprintf_env(stddeb
, "GetEnvironment('%s', '%s', %d) !\n",
733 lpPortName
, lpEnviron
, nMaxSiz
);
734 while (lpEnv
!= NULL
) {
735 if (lpEnv
->Name
!= NULL
&& strcmp(lpEnv
->Name
, lpPortName
) == 0) {
736 nCount
= MIN(nMaxSiz
, lpEnv
->wSize
);
737 memcpy(lpEnviron
, lpEnv
->Value
, nCount
);
738 dprintf_env(stddeb
, "GetEnvironment() // found '%s' !\n", lpEnviron
);
743 dprintf_env(stddeb
, "GetEnvironment() // not found !\n");
747 /***********************************************************************
748 * GetEnvironmentVariableA (KERNEL32.213)
750 DWORD
GetEnvironmentVariableA(LPSTR lpName
, LPSTR lpValue
, DWORD size
)
752 return GetEnvironment(lpName
, lpValue
, size
);
755 /***********************************************************************
756 * GetEnvironmentStrings (KERNEL32.210)
758 LPVOID
GetEnvironmentStrings(void)
762 char *envtable
, *envptr
;
764 /* Count the total number of bytes we'll need for the string
765 * table. Include the trailing nuls and the final double nul.
771 if(lpEnv
->Name
!= NULL
)
773 count
+= strlen(lpEnv
->Name
) + 1;
774 count
+= strlen(lpEnv
->Value
) + 1;
779 envtable
= malloc(count
);
787 if(lpEnv
->Name
!= NULL
)
789 count
= sprintf(envptr
, "%s=%s", lpEnv
->Name
, lpEnv
->Value
);
801 LPVOID
GetEnvironmentStringsW(void)
805 char *envtable
, *envptr
;
808 /* Count the total number of bytes we'll need for the string
809 * table. Include the trailing nuls and the final double nul.
815 if(lpEnv
->Name
!= NULL
)
817 count
+= strlen(lpEnv
->Name
) + 1;
818 count
+= strlen(lpEnv
->Value
) + 1;
824 envtable
= malloc(count
);
832 if(lpEnv
->Name
!= NULL
)
834 count
= sprintf(envptr
, "%s=%s", lpEnv
->Name
, lpEnv
->Value
);
842 wenvtable
= malloc(2*len
);
843 for(count
=0;count
<len
;count
++)
844 wenvtable
[count
]=(WCHAR
)envtable
[count
];
850 void FreeEnvironmentStringsA(void *e
)
855 void FreeEnvironmentStringsW(void* e
)
860 /***********************************************************************
861 * GetTimerResolution (USER.14)
863 LONG
GetTimerResolution(void)
868 /***********************************************************************
869 * SystemParametersInfo (USER.483)
871 BOOL
SystemParametersInfo (UINT uAction
, UINT uParam
, LPVOID lpvParam
, UINT fuWinIni
)
875 XKeyboardState keyboard_state
;
876 XKeyboardControl keyboard_value
;
879 fprintf(stderr
, "SystemParametersInfo: action %d, param %x, flag %x\n",
880 uAction
, uParam
, fuWinIni
);
884 XGetKeyboardControl(display
, &keyboard_state
);
885 if (keyboard_state
.bell_percent
== 0)
886 *(BOOL
*) lpvParam
= FALSE
;
888 *(BOOL
*) lpvParam
= TRUE
;
892 *(INT
*)lpvParam
= GetSystemMetrics( SM_CXFRAME
);
895 case SPI_GETFASTTASKSWITCH
:
896 *(BOOL
*) lpvParam
= FALSE
;
897 /* FIXME GetProfileInt( "windows", "CoolSwitch", 1 ) */
900 case SPI_GETGRIDGRANULARITY
:
901 *(INT
*) lpvParam
= 1;
902 /* FIXME GetProfileInt( "desktop", "GridGranularity", 1 ) */
905 case SPI_GETICONTITLEWRAP
:
906 *(BOOL
*) lpvParam
= FALSE
;
907 /* FIXME GetProfileInt( "desktop", "?", True ) */
910 case SPI_GETKEYBOARDDELAY
:
911 *(INT
*) lpvParam
= 1;
915 case SPI_GETKEYBOARDSPEED
:
916 *(WORD
*) lpvParam
= 30;
920 case SPI_GETMENUDROPALIGNMENT
:
921 *(BOOL
*) lpvParam
= GetSystemMetrics( SM_MENUDROPALIGNMENT
); /* XXX check this */
924 case SPI_GETSCREENSAVEACTIVE
:
925 /* FIXME GetProfileInt( "windows", "ScreenSaveActive", 1 ); */
926 *(BOOL
*) lpvParam
= FALSE
;
929 case SPI_GETSCREENSAVETIMEOUT
:
930 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
931 XGetScreenSaver(display
, &timeout
, &temp
,&temp
,&temp
);
932 *(INT
*) lpvParam
= timeout
* 1000;
935 case SPI_ICONHORIZONTALSPACING
:
936 if (lpvParam
== NULL
)
937 fprintf(stderr
, "SystemParametersInfo: Horizontal icon spacing set to %d\n.", uParam
);
939 *(INT
*) lpvParam
= GetSystemMetrics( SM_CXICONSPACING
);
942 case SPI_ICONVERTICALSPACING
:
943 if (lpvParam
== NULL
)
944 fprintf(stderr
, "SystemParametersInfo: Vertical icon spacing set to %d\n.", uParam
);
946 *(INT
*) lpvParam
= GetSystemMetrics( SM_CYICONSPACING
);
951 keyboard_value
.bell_percent
= -1;
953 keyboard_value
.bell_percent
= 0;
954 XChangeKeyboardControl(display
, KBBellPercent
,
958 case SPI_SETSCREENSAVEACTIVE
:
960 XActivateScreenSaver(display
);
962 XResetScreenSaver(display
);
965 case SPI_SETSCREENSAVETIMEOUT
:
966 XSetScreenSaver(display
, uParam
, 60, DefaultBlanking
,
970 case SPI_SETDESKWALLPAPER
:
971 return (SetDeskWallPaper((LPSTR
) lpvParam
));
974 case SPI_SETDESKPATTERN
:
975 if ((INT
) uParam
== -1) {
976 GetProfileString("Desktop", "Pattern",
977 "170 85 170 85 170 85 170 85",
978 buffer
, sizeof(buffer
) );
979 return (DESKTOP_SetPattern((LPSTR
) buffer
));
981 return (DESKTOP_SetPattern((LPSTR
) lpvParam
));
984 case SPI_GETICONTITLELOGFONT
:
986 /* FIXME GetProfileString( "?", "?", "?" ) */
987 LPLOGFONT lpLogFont
= (LPLOGFONT
)lpvParam
;
988 lpLogFont
->lfHeight
= 10;
989 lpLogFont
->lfWidth
= 0;
990 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
991 lpLogFont
->lfWeight
= FW_NORMAL
;
992 lpLogFont
->lfItalic
= lpLogFont
->lfStrikeOut
= lpLogFont
->lfUnderline
= FALSE
;
993 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
994 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
995 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
996 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
1001 case SPI_SETDOUBLECLKHEIGHT
:
1002 case SPI_SETDOUBLECLICKTIME
:
1003 case SPI_SETDOUBLECLKWIDTH
:
1004 case SPI_SETFASTTASKSWITCH
:
1005 case SPI_SETKEYBOARDDELAY
:
1006 case SPI_SETKEYBOARDSPEED
:
1007 fprintf(stderr
, "SystemParametersInfo: option %d ignored.\n", uParam
);
1011 fprintf(stderr
, "SystemParametersInfo: unknown option %d.\n", uParam
);
1017 /***********************************************************************
1018 * HMEMCPY (KERNEL.348)
1020 void hmemcpy(LPVOID hpvDest
, LPCVOID hpvSource
, LONG cbCopy
)
1022 memcpy(hpvDest
, hpvSource
, cbCopy
);
1025 /***********************************************************************
1028 void Copy(LPVOID lpSource
, LPVOID lpDest
, WORD nBytes
)
1030 memcpy(lpDest
, lpSource
, nBytes
);
1033 /***********************************************************************
1034 * SWAPMOUSEBUTTON (USER.186)
1036 BOOL
SwapMouseButton(BOOL fSwap
)
1038 return 0; /* don't swap */
1041 /***********************************************************************
1042 * FileCDR (KERNEL.130)
1044 void FileCDR(FARPROC x
)
1046 printf("FileCDR(%8x)\n", (int) x
);
1049 /***********************************************************************
1050 * GetWinDebugInfo (KERNEL.355)
1052 BOOL
GetWinDebugInfo(WINDEBUGINFO
*lpwdi
, UINT flags
)
1054 printf("GetWinDebugInfo(%8lx,%d) stub returning 0\n", (unsigned long)lpwdi
, flags
);
1055 /* 0 means not in debugging mode/version */
1056 /* Can this type of debugging be used in wine ? */
1057 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1061 /***********************************************************************
1062 * GetWinDebugInfo (KERNEL.355)
1064 BOOL
SetWinDebugInfo(WINDEBUGINFO
*lpwdi
)
1066 printf("SetWinDebugInfo(%8lx) stub returning 0\n", (unsigned long)lpwdi
);
1067 /* 0 means not in debugging mode/version */
1068 /* Can this type of debugging be used in wine ? */
1069 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */