Release 951226

Sat Dec 23 18:15:59 1995  Alexandre Julliard  <julliard@sunsite.unc.edu>

	* [configure.in] [Makefile.in] [tools/install-sh]
	New 'install' target installs Wine binary, library and man page.
	Library is now more logically named libwine.a.
	Split toolkit/ directory into library (for library code) and
	libtest (for test programs).

	* [controls/edit.c]
	Quick hack to partially support EM_PASSWORD style (avoids
	displaying your passwords on the screen when testing programs...)

	* [configure.in] [controls/menu.c] [include/resource.h]
	  [misc/commdlg.c] [misc/ole2nls.c] [misc/shell.c] [windows/msgbox.c]
	Language is now a run-time option (wine -language xx).

	* [debugger/dbg.y]
	Dump some more debugging info on crash.

	* [misc/profile.c]
	Only consider ';' as a comment if it's the first non-blank
	character on the line.

	* [miscemu/dpmi.c]
	More debugging info for real-mode callback.

	* [objects/gdiobj.c]
	Rewrote EnumObjects() to do the Right Thing.

	* [resources/sysres*]
	New directory containing system resources.

Fri Dec 22 11:24:39 GMT 1995  John Harvey <john@division.co.uk>

	* [win32/file.c] [win32/memory.c]
        Unixware doesn't have MAP_ANON ifdefed out for now.

	* [misc/dos_fs.c]
        DOS_GetDosFileName didn't truncate paths starting ./ properly.

	* [tools/build.c]
	Produces assembly code that works with the unixware assembler.

Wed Dec 20 22:22:29 +0100 1995  Morten Welinder <terra@diku.dk>

	* [miscemu/instr.c]
	INSTR_GetOperandAddr: 16-bit addresses should be masked to 16 bits.

	* [misc/dos_fs.c]
	DOS_readdir should always return directories, even if they don't
 	match the file name mask.

Tue Dec 19 18:00:00 1995  Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de>
	
	* [misc/exec.c]
	Give arguments to winhelp.

	* [miscemu/int21.c]
	Implemented Interrupt 21 AX=6C00 EXTENDED OPEN/CREATE.
	Created function ExtendedOpenCreateFile.
	Give for some Windows95 interrupts the return value 'not
	implemented'.

Sun Dec 17 16:51:56 EST 1995  Jim Peterson <jspeter@birch.ee.vt.edu>

	* [include/kernel32.h] [include/windows.h]
	Moved the typedefs for SYSTEMTIME and LPSYSTEMTIME from
 	include/kernel32.h to include/windows.h and declared the new Win32
 	API functions Sleep(), GetLocalTime(), and GetSystemTime().
  	Redefined INFINITE as 0xFFFFFFFF if WINELIB32.

	* [rc/rc (new file)]
	Created the shell script 'rc', which should simplify resource
 	compilation.

	* [win32/environment.c]
	Kludged around an undefined reference to wine_files.  This change
 	should be fixed some time.

	* [win32/time.c] [if1632/kernel32.spec]
	Added the functions GetSystemTime(), and Sleep().

	* [miscemu/int21.c]
	Renamed static function GetSystemTime to INT21_GetSystemTime to
 	avoid conflicts with the API function of the same name.

	* [include/wintypes.h]
	Added the SPFMT definition for printf statements.

	* [misc/shell.c] [include/shell.h]
	Changed ERROR_* defines to SHELL_ERROR_*, as they were conflicting
 	with the ones in include/winerror.h.  They should probably use the
 	versions in winerror.h, but I'm not certain, and that can be done
 	later.

	* [windows/mdi.c]
	Translated WM_MDIACTIVATE(?,(LOhwnd,HIhwnd)) messages to
 	WM_MDIACTIVATE(HIhwnd,LOhwnd) for WINELIB32.  The ? parameter
 	(boolean) was discarded with this translation.  Translated handler
 	of WM_MDISETMENU(ref,(loHMENU,hiHMENU)) to handle
 	WM_MDISETMENU(loHMENU, hiHMENU) messages in WINELIB32 (ref assumed
 	false, call DrawMenuBar() if desired).

	* [*/*]
	General explicit casts and more rigid typing to remove warnings.

	* [include/winpos.h] [windows/winpos.c]
	Changed return type of WINPOS_ChangeActiveWindow to BOOL.

	* [include/commdlg.h] [misc/commdlg.c]
	Added prototypes for ChooseColor(), CommDlgExtendedError(),
 	FindText() GetFileTitle(), GetOpenFileName(), GetSaveFileName(),
 	PrintDlg, and ReplaceText().
	Renamed the CommDlgExtendError() function to CommDlgExtendedError().
	Made GetFileTitle return a short, as per the API definition.

	* [Makefile.in]
	Added line to clean and distclean that removes temporaries from
 	the include directory.

Sat Dec 16 19:39:14 MET 1995  Steffen Moeller <smoe0024@rz.uni-hildesheim.de>

	* [controls/edit.c]
	Almost rewrote EDIT_GetLineMsg.

Sat Dec 16 13:51:48 MST 1995  Andrew Taylor <andrew@riscan.com>

	* [windows/mdi.c]
	Fixed MDITile() bug that occurs when 0 windows are present or all
	windows are minimized.

Wed Dec 12 23:30:00 1995  Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de>

	* [misc/profile.c]
        Try harder to find files, especially in the working directory.
	Look in $HOME/.wine too and create it there if it isn't found.
diff --git a/ANNOUNCE b/ANNOUNCE
index 3b5dff6..86723e9 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,13 +1,13 @@
-This is release 951212 of Wine the MS Windows emulator.  This is still a
+This is release 951226 of Wine the MS Windows emulator.  This is still a
 developer's only release.  There are many bugs and many unimplemented API
 features.  Most applications still do not work.
 
 Patches should be submitted to "wine-new@amscons.com".  Please don't forget
 to include a ChangeLog entry.  I'll make a new release every other week.
 
-WHAT'S NEW with Wine-951212: (see ChangeLog for details)
-	- Many more Winelib and Win32 fixes.
-	- Window management and MDI improvements.
+WHAT'S NEW with Wine-951226: (see ChangeLog for details)
+	- Many more Winelib fixes.
+	- Language is now a run-time option.
 	- Lots of bug fixes.
 
 See the README file in the distribution for installation instructions.
@@ -16,10 +16,10 @@
 the release is available at the ftp sites.  The sources will be available
 from the following locations:
 
-    sunsite.unc.edu:/pub/Linux/ALPHA/wine/Wine-951212.tar.gz
-    tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-951212.tar.gz
-    ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-951212.tar.gz
-    aris.com:/pub/linux/ALPHA/Wine/development/Wine-951212.tar.gz
+    sunsite.unc.edu:/pub/Linux/ALPHA/wine/Wine-951226.tar.gz
+    tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-951226.tar.gz
+    ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-951226.tar.gz
+    aris.com:/pub/linux/ALPHA/Wine/development/Wine-951226.tar.gz
 
 It should also be available from any site that mirrors tsx-11 or sunsite.
 
diff --git a/ChangeLog b/ChangeLog
index efd9fa4..fc9e70b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,142 @@
 ----------------------------------------------------------------------
+Sat Dec 23 18:15:59 1995  Alexandre Julliard  <julliard@sunsite.unc.edu>
+
+	* [configure.in] [Makefile.in] [tools/install-sh]
+	New 'install' target installs Wine binary, library and man page.
+	Library is now more logically named libwine.a.
+	Split toolkit/ directory into library (for library code) and
+	libtest (for test programs).
+
+	* [controls/edit.c]
+	Quick hack to partially support EM_PASSWORD style (avoids
+	displaying your passwords on the screen when testing programs...)
+
+	* [configure.in] [controls/menu.c] [include/resource.h]
+	  [misc/commdlg.c] [misc/ole2nls.c] [misc/shell.c] [windows/msgbox.c]
+	Language is now a run-time option (wine -language xx).
+
+	* [debugger/dbg.y]
+	Dump some more debugging info on crash.
+
+	* [misc/profile.c]
+	Only consider ';' as a comment if it's the first non-blank
+	character on the line.
+
+	* [miscemu/dpmi.c]
+	More debugging info for real-mode callback.
+
+	* [objects/gdiobj.c]
+	Rewrote EnumObjects() to do the Right Thing.
+
+	* [resources/sysres*]
+	New directory containing system resources.
+
+Fri Dec 22 11:24:39 GMT 1995  John Harvey <john@division.co.uk>
+
+	* [win32/file.c] [win32/memory.c]
+        Unixware doesn't have MAP_ANON ifdefed out for now.
+
+	* [misc/dos_fs.c]
+        DOS_GetDosFileName didn't truncate paths starting ./ properly.
+
+	* [tools/build.c]
+	Produces assembly code that works with the unixware assembler.
+
+Wed Dec 20 22:22:29 +0100 1995  Morten Welinder <terra@diku.dk>
+
+	* [miscemu/instr.c]
+	INSTR_GetOperandAddr: 16-bit addresses should be masked to 16 bits.
+
+	* [misc/dos_fs.c]
+	DOS_readdir should always return directories, even if they don't
+ 	match the file name mask.
+
+Tue Dec 19 18:00:00 1995  Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de>
+	
+	* [misc/exec.c]
+	Give arguments to winhelp.
+
+	* [miscemu/int21.c]
+	Implemented Interrupt 21 AX=6C00 EXTENDED OPEN/CREATE.
+	Created function ExtendedOpenCreateFile.
+	Give for some Windows95 interrupts the return value 'not
+	implemented'.
+
+Sun Dec 17 16:51:56 EST 1995  Jim Peterson <jspeter@birch.ee.vt.edu>
+
+	* [include/kernel32.h] [include/windows.h]
+	Moved the typedefs for SYSTEMTIME and LPSYSTEMTIME from
+ 	include/kernel32.h to include/windows.h and declared the new Win32
+ 	API functions Sleep(), GetLocalTime(), and GetSystemTime().
+  	Redefined INFINITE as 0xFFFFFFFF if WINELIB32.
+
+	* [rc/rc (new file)]
+	Created the shell script 'rc', which should simplify resource
+ 	compilation.
+
+	* [win32/environment.c]
+	Kludged around an undefined reference to wine_files.  This change
+ 	should be fixed some time.
+
+	* [win32/time.c] [if1632/kernel32.spec]
+	Added the functions GetSystemTime(), and Sleep().
+
+	* [miscemu/int21.c]
+	Renamed static function GetSystemTime to INT21_GetSystemTime to
+ 	avoid conflicts with the API function of the same name.
+
+	* [include/wintypes.h]
+	Added the SPFMT definition for printf statements.
+
+	* [misc/shell.c] [include/shell.h]
+	Changed ERROR_* defines to SHELL_ERROR_*, as they were conflicting
+ 	with the ones in include/winerror.h.  They should probably use the
+ 	versions in winerror.h, but I'm not certain, and that can be done
+ 	later.
+
+	* [windows/mdi.c]
+	Translated WM_MDIACTIVATE(?,(LOhwnd,HIhwnd)) messages to
+ 	WM_MDIACTIVATE(HIhwnd,LOhwnd) for WINELIB32.  The ? parameter
+ 	(boolean) was discarded with this translation.  Translated handler
+ 	of WM_MDISETMENU(ref,(loHMENU,hiHMENU)) to handle
+ 	WM_MDISETMENU(loHMENU, hiHMENU) messages in WINELIB32 (ref assumed
+ 	false, call DrawMenuBar() if desired).
+
+	* [*/*]
+	General explicit casts and more rigid typing to remove warnings.
+
+	* [include/winpos.h] [windows/winpos.c]
+	Changed return type of WINPOS_ChangeActiveWindow to BOOL.
+
+	* [include/commdlg.h] [misc/commdlg.c]
+	Added prototypes for ChooseColor(), CommDlgExtendedError(),
+ 	FindText() GetFileTitle(), GetOpenFileName(), GetSaveFileName(),
+ 	PrintDlg, and ReplaceText().
+	Renamed the CommDlgExtendError() function to CommDlgExtendedError().
+	Made GetFileTitle return a short, as per the API definition.
+
+	* [Makefile.in]
+	Added line to clean and distclean that removes temporaries from
+ 	the include directory.
+
+Sat Dec 16 19:39:14 MET 1995  Steffen Moeller <smoe0024@rz.uni-hildesheim.de>
+
+	* [controls/edit.c]
+	Almost rewrote EDIT_GetLineMsg.
+
+Sat Dec 16 13:51:48 MST 1995  Andrew Taylor <andrew@riscan.com>
+
+	* [windows/mdi.c]
+	Fixed MDITile() bug that occurs when 0 windows are present or all
+	windows are minimized.
+
+Wed Dec 12 23:30:00 1995  Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de>
+
+	* [misc/profile.c]
+        Try harder to find files, especially in the working directory.
+	Look in $HOME/.wine too and create it there if it isn't found.
+
+----------------------------------------------------------------------
 Mon Dec 11 19:08:55 1995  Alexandre Julliard  <julliard@sunsite.unc.edu>
 
 	* [misc/lstr.c]
diff --git a/Make.rules.in b/Make.rules.in
index 4dd971d..a6d4063 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -1,21 +1,36 @@
 # Global rules shared by all makefiles
 # The makefile must define at least TOPSRC and MODULE
 
+# First some useful definitions
+
 CC 	  = @CC@
+CPP       = @CPP@
 CFLAGS 	  = @CFLAGS@
 DEFS      = @DEFS@
-LANG	  = @LANG@
 X_CFLAGS  = @X_CFLAGS@
+X_LIBS    = @X_LIBS@
+XPM_LIB	  = -lXpm
+XLIB	  = @X_PRE_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@
+LDLIBS	  = @LDLIBS@
 YACC      = @YACC@
 LEX       = @LEX@
 LEXLIB    = @LEXLIB@
 DIVINCL   = -I$(TOPSRC)/include
-ALLCFLAGS = $(CFLAGS) $(DEFS) -ALANG\($(LANG)\) $(X_CFLAGS) $(DIVINCL) $(EXTRA_DEFS)
+ALLCFLAGS = $(CFLAGS) $(DEFS) $(X_CFLAGS) $(DIVINCL) $(EXTRA_DEFS)
 LDCOMBINE = ld -r
 RM        = rm -f
+BUILD     = $(TOPSRC)/tools/build
+WINERC    = $(TOPSRC)/rc/winerc
+WINELIB   = $(TOPSRC)/libwine.a
+SUBMAKE   = $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'DEFS=$(DEFS)'
 @SET_MAKE@
 
-OBJS = $(C_SRCS:.c=.o) $(ASM_SRCS:.S=.o)
+OBJS = $(C_SRCS:.c=.o) $(ASM_SRCS:.S=.o) $(EXTRA_OBJS)
+
+
+# Implicit rules
+
+.SUFFIXES: .rc
 
 .c.o:
 	$(CC) -c $(ALLCFLAGS) -o $*.o $<
@@ -23,20 +38,46 @@
 .S.o:
 	$(CC) -c -o $*.o $<  
 
+.rc.c:
+	echo "#include \"windows.h\"" >winerctmp.c
+	echo WINDOWS_H_ENDS_HERE >>winerctmp.c
+	cat $< >>winerctmp.c
+	$(CPP) $(DEFS) $(DIVINCL) -P winerctmp.c | sed -e '1,/^WINDOWS_H_ENDS_HERE/d' | $(WINERC) -c -o $* -p $*
+	$(RM) winerctmp.c
+
+.rc.h:
+	echo "#include \"windows.h\"" >winerctmp.c
+	echo WINDOWS_H_ENDS_HERE >>winerctmp.c
+	cat $< >>winerctmp.c
+	$(CPP) $(DEFS) $(DIVINCL) -P winerctmp.c | sed -e '1,/^WINDOWS_H_ENDS_HERE/d' | $(WINERC) -c -o $* -p $*
+	$(RM) winerctmp.c
+
+
+# Rule to rebuild resource compiler
+
+$(WINERC) check_winerc:
+	cd $(TOPSRC)/rc; $(SUBMAKE) winerc
+
+
+# Rule for main module
+
 $(MODULE).o: $(OBJS)
 	$(LDCOMBINE) $(OBJS) -o $(MODULE).o
 
+
+# Misc. rules
+
 depend:: $(C_SRCS)
 	sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
 	$(CC) $(ALLCFLAGS) -MM $(C_SRCS) >> tmp_make
 	mv tmp_make Makefile
 
 clean::
-	$(RM) *.o \#*\# *~ *.bak *.flc tmp_make
+	$(RM) *.o \#*\# *~ *.bak *.flc tmp_make winerctmp.c
 
 distclean:: clean
 	$(RM) Makefile
 
-langclean::
-
 dummy:
+
+# End of global rules
diff --git a/Makefile.in b/Makefile.in
index e7a7bb9..faea819 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -3,18 +3,18 @@
 # all (default):	build wine
 # clean:		remove all intermediate files
 # distclean:		also remove all files created by configure
-# langclean:		remove all files which have to be remade if
-#			a different LANGuage is selected
 # depend:		create the dependencies
 # etags:		Create a TAGS file for Emacs.
 #
 # Author: Michael Patra   <micky@marie.physik.tu-berlin.de>
 #                         <patra@itp1.physik.tu-berlin.de>
 
+# First some useful definitions
+
 CC 	  = @CC@
+CPP       = @CPP@
 CFLAGS 	  = @CFLAGS@
-DEFS      = @DEFS@
-LANG	  = @LANG@
+DEFS      = @DEFS@ -DWINE_INI_GLOBAL=\"$(WINE_INI_GLOBAL)\"
 X_CFLAGS  = @X_CFLAGS@
 X_LIBS    = @X_LIBS@
 TOPSRC    = @top_srcdir@
@@ -25,17 +25,50 @@
 AR        = ar rc
 RANLIB    = @RANLIB@
 RM        = rm -f
+SUBMAKE   = $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'DEFS=$(DEFS)'
 @SET_MAKE@
 
+# Installation infos
+
+INSTALL         = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA    = @INSTALL_DATA@
+prefix          = @prefix@
+exec_prefix     = @exec_prefix@
+bindir          = @bindir@
+libdir          = @libdir@
+sysconfdir      = @sysconfdir@
+mandir          = @mandir@/man1
+manext          = .1
+WINE_INI_GLOBAL = $(sysconfdir)/wine.conf
+
+# Main target to build
+
 MAIN_TARGET = @MAIN_TARGET@
 
-COMMONSUBDIRS = rc controls ipc loader misc multimedia objects win32 windows
+COMMONSUBDIRS = \
+	rc \
+	controls \
+	ipc \
+	loader \
+	misc \
+	multimedia \
+	objects \
+	resources \
+	win32 \
+	windows
 
-EMUSUBDIRS = tools debugger debugger/readline if1632 memory miscemu
+EMUSUBDIRS = \
+	tools \
+	debugger \
+	debugger/readline \
+	if1632 \
+	memory \
+	miscemu
 
-LIBSUBDIRS = toolkit
+LIBSUBDIRS = library
 
-ALLSUBDIRS = $(COMMONSUBDIRS) $(EMUSUBDIRS) $(LIBSUBDIRS)
+ALLSUBDIRS = $(COMMONSUBDIRS) $(EMUSUBDIRS) $(LIBSUBDIRS) libtest
 
 COMMONOBJS = \
 	controls/controls.o \
@@ -44,7 +77,7 @@
 	misc/misc.o \
 	multimedia/multimedia.o \
 	objects/objects.o \
-	rc/rc.o \
+	resources/resources.o \
 	win32/win32.o \
 	windows/windows.o
 
@@ -55,22 +88,31 @@
 	memory/memory.o \
 	miscemu/miscemu.o
 
-LIBOBJS = toolkit/toolkit.o
+LIBOBJS = library/library.o
 
 
 all: $(MAIN_TARGET)
 
+install: install_$(MAIN_TARGET)
+
 wine wine.sym: $(COMMONSUBDIRS) $(EMUSUBDIRS) dummy
 	$(CC) -o wine $(COMMONOBJS) $(EMUOBJS) $(LDOPTIONS) $(X_LIBS) $(XPM_LIB) $(XLIB) $(LDLIBS)
 	nm -n wine | grep -v _compiled >wine.sym
 
-winelib.a: $(COMMONSUBDIRS) $(LIBSUBDIRS) dummy
+install_wine: dummy
+	$(INSTALL_PROGRAM) wine $(bindir)/wine
+	$(INSTALL_DATA) wine.man $(mandir)/wine$(manext)
+
+libwine.a: $(COMMONSUBDIRS) $(LIBSUBDIRS) dummy
 	$(RM) $@
 	$(AR) $@ $(COMMONOBJS) $(LIBOBJS)
 	$(RANLIB) $@
 
+install_libwine.a: dummy
+	$(INSTALL_DATA) libwine.a $(libdir)
+
 $(ALLSUBDIRS): dummy
-	@cd $@; $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'DEFS=$(DEFS)' 'LANG=$(LANG)'
+	@cd $@; $(SUBMAKE)
 
 depend:
 	for i in $(ALLSUBDIRS); do (cd $$i; $(MAKE) depend); done
@@ -80,15 +122,13 @@
 
 clean:
 	for i in $(ALLSUBDIRS); do (cd $$i; $(MAKE) clean); done
-	$(RM) *.o \#*\# *~ *.bak *.flc wine wine.sym winelib.a TAGS
+	$(RM) *.o \#*\# *~ *.bak *.flc wine wine.sym libwine.a TAGS
+	$(RM) include/\#*\# include/*~ include/*.bak include/*.flc
 
 distclean:
 	for i in $(ALLSUBDIRS); do (cd $$i; $(MAKE) distclean); done
-	$(RM) *.o \#*\# *~ *.bak wine wine.sym winelib.a TAGS
+	$(RM) *.o \#*\# *~ *.bak wine wine.sym libwine.a TAGS
+	$(RM) include/\#*\# include/*~ include/*.bak include/*.flc
 	$(RM) config.* include/config.h Make.rules Makefile
 
-langclean:
-	for i in $(ALLSUBDIRS); do (cd $$i; $(MAKE) langclean); done
-	$(RM) wine wine.sym winelib.a
-
 dummy:
diff --git a/Wine.tmpl b/Wine.tmpl
deleted file mode 100644
index 1cc3320..0000000
--- a/Wine.tmpl
+++ /dev/null
@@ -1,17 +0,0 @@
-INCLUDES = -I$(TOP)/include -I$(TOP)
-
-XCOMM Imake rules go here
-
-/*
- * WineRelocatableTarget - generate rules to produce a relocatable object
- * file instead of a library.  
- */
-#ifndef WineRelocatableTarget
-#define WineRelocatableTarget(objname,objlist,depobj)				@@\
-AllTarget(objname.o)							@@\
-									@@\
-objname.o: depobj							@@\
-	$(RM) $@							@@\
-	$(LD) $(LDCOMBINEFLAGS) objlist depobj -o $@
-#endif /* WineRelocatableTarget */
-
diff --git a/configure b/configure
index 3223ea7..704cc35 100755
--- a/configure
+++ b/configure
@@ -2,7 +2,7 @@
 
 # From configure.in configure.in 1.00
 # Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.4 
+# Generated automatically using autoconf version 2.7 
 # Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
 #
 # This configure script is free software; the Free Software Foundation
@@ -15,8 +15,6 @@
 ac_help="$ac_help
   --with-library          build Wine as a library instead of an emulator"
 ac_help="$ac_help
-  --with-language=LANG    change the language (LANG=En/De/Fr/Es/No/Fi/Da)"
-ac_help="$ac_help
   --with-ipc              use inter-process communication for DDE"
 ac_help="$ac_help
   --with-malloc-debug     enable malloc() debugging"
@@ -44,9 +42,22 @@
 verbose=
 x_includes=NONE
 x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
 
 # Initialize some other variables.
 subdirs=
+MFLAGS= MAKEFLAGS=
 
 ac_prev=
 for ac_option
@@ -68,9 +79,14 @@
 
   case "$ac_option" in
 
-  -build | --build | --buil | --bui | --bu | --b)
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir="$ac_optarg" ;;
+
+  -build | --build | --buil | --bui | --bu)
     ac_prev=build ;;
-  -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*)
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
     build="$ac_optarg" ;;
 
   -cache-file | --cache-file | --cache-fil | --cache-fi \
@@ -80,6 +96,12 @@
   | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
     cache_file="$ac_optarg" ;;
 
+  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+  | --da=*)
+    datadir="$ac_optarg" ;;
+
   -disable-* | --disable-*)
     ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
     # Reject names that are not valid shell variable names.
@@ -130,12 +152,29 @@
 Directory and file names:
   --prefix=PREFIX         install architecture-independent files in PREFIX
                           [$ac_default_prefix]
-  --exec-prefix=PREFIX    install architecture-dependent files in PREFIX
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                           [same as prefix]
+  --bindir=DIR            user executables in DIR [EPREFIX/bin]
+  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
+  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
+  --datadir=DIR           read-only architecture-independent data in DIR
+                          [PREFIX/share]
+  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
+                          [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
+  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
+  --includedir=DIR        C header files in DIR [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
+  --infodir=DIR           info documentation in DIR [PREFIX/info]
+  --mandir=DIR            man documentation in DIR [PREFIX/man]
   --srcdir=DIR            find the sources in DIR [configure dir or ..]
   --program-prefix=PREFIX prepend PREFIX to installed program names
   --program-suffix=SUFFIX append SUFFIX to installed program names
-  --program-transform-name=PROGRAM run sed PROGRAM on installed program names
+  --program-transform-name=PROGRAM
+                          run sed PROGRAM on installed program names
+EOF
+    cat << EOF
 Host type:
   --build=BUILD           configure for building on BUILD [BUILD=HOST]
   --host=HOST             configure for HOST [guessed]
@@ -147,8 +186,10 @@
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --x-includes=DIR        X include files are in DIR
   --x-libraries=DIR       X library files are in DIR
---enable and --with options recognized:$ac_help
 EOF
+    if test -n "$ac_help"; then
+      echo "--enable and --with options recognized:$ac_help"
+    fi
     exit 0 ;;
 
   -host | --host | --hos | --ho)
@@ -156,6 +197,44 @@
   -host=* | --host=* | --hos=* | --ho=*)
     host="$ac_optarg" ;;
 
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir="$ac_optarg" ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir="$ac_optarg" ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir="$ac_optarg" ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir="$ac_optarg" ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst \
+  | --locals | --local | --loca | --loc | --lo)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+    localstatedir="$ac_optarg" ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir="$ac_optarg" ;;
+
   -nfp | --nfp | --nf)
     # Obsolete; use --without-fp.
     with_fp=no ;;
@@ -168,6 +247,15 @@
   | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
     no_recursion=yes ;;
 
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir="$ac_optarg" ;;
+
   -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
     ac_prev=prefix ;;
   -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
@@ -208,6 +296,23 @@
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir="$ac_optarg" ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir="$ac_optarg" ;;
+
   -site | --site | --sit)
     ac_prev=site ;;
   -site=* | --site=* | --sit=*)
@@ -218,6 +323,13 @@
   -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
     srcdir="$ac_optarg" ;;
 
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir="$ac_optarg" ;;
+
   -target | --target | --targe | --targ | --tar | --ta | --t)
     ac_prev=target ;;
   -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
@@ -227,7 +339,7 @@
     verbose=yes ;;
 
   -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 2.4"
+    echo "configure generated by autoconf version 2.7"
     exit 0 ;;
 
   -with-* | --with-*)
@@ -273,7 +385,7 @@
   -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
     ;;
 
-  *) 
+  *)
     if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
       echo "configure: warning: $ac_option: invalid host type" 1>&2
     fi
@@ -392,9 +504,12 @@
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5'
+ac_cpp='echo $CPP $CPPFLAGS 1>&5;
+$CPP $CPPFLAGS'
+ac_compile='echo ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5;
+${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5'
+ac_link='echo ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5;
+${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5'
 
 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
@@ -409,39 +524,48 @@
 fi
 
 		
+ac_aux_dir=
+for ac_dir in tools $srcdir/tools; do
+  if test -f $ac_dir/install-sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f $ac_dir/install.sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  { echo "configure: error: can not find install-sh or install.sh in tools $srcdir/tools" 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
 
 # We want these before the checks, so the checks can modify their values.
-test -z "$CFLAGS" && CFLAGS="-g -O2 -Wall" 
+test -z "$CFLAGS" && CFLAGS="-g -O2" 
 test -z "$LDFLAGS" && LDFLAGS=-g 
 test -z "$LDLIBS" && LDLIBS=-lm 
 
 
 # Check whether --with-library or --without-library was given.
-withval="$with_library"
-if test -n "$withval"; then
+if test "${with_library+set}" = set; then
+  withval="$with_library"
   cat >> confdefs.h <<\EOF
 #define WINELIB 1
 EOF
- MAIN_TARGET="winelib.a"
+ MAIN_TARGET="libwine.a"
 else
   MAIN_TARGET="wine"
 fi
 
 
 
-# Check whether --with-language or --without-language was given.
-withval="$with_language"
-if test -n "$withval"; then
-  LANG="$withval"
-else
-  LANG=En
-fi
-
-
-
 # Check whether --with-ipc or --without-ipc was given.
-withval="$with_ipc"
-if test -n "$withval"; then
+if test "${with_ipc+set}" = set; then
+  withval="$with_ipc"
   cat >> confdefs.h <<\EOF
 #define CONFIG_IPC 1
 EOF
@@ -450,8 +574,8 @@
 
 
 # Check whether --with-malloc-debug or --without-malloc-debug was given.
-withval="$with_malloc_debug"
-if test -n "$withval"; then
+if test "${with_malloc_debug+set}" = set; then
+  withval="$with_malloc_debug"
   cat >> confdefs.h <<\EOF
 #define MALLOC_DEBUGGING 1
 EOF
@@ -530,6 +654,7 @@
   ac_cv_prog_gcc=no
 fi
 fi
+
 echo "$ac_t""$ac_cv_prog_gcc" 1>&6
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
@@ -547,7 +672,8 @@
 rm -f conftest*
 
 fi
-    echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6
+
+echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6
     if test $ac_cv_prog_gcc_g = yes; then
       CFLAGS="-g -O"
     else
@@ -559,6 +685,7 @@
   test "${CFLAGS+set}" = set || CFLAGS="-g"
 fi
 
+test "x${GCC}" = "xyes" && CFLAGS="$CFLAGS -Wall -fno-strength-reduce"
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
@@ -574,7 +701,7 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 578 "configure"
+#line 705 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
@@ -588,7 +715,7 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 592 "configure"
+#line 719 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
@@ -640,8 +767,8 @@
 echo $ac_n "checking for X""... $ac_c" 1>&6
 
 # Check whether --with-x or --without-x was given.
-withval="$with_x"
-if test -n "$withval"; then
+if test "${with_x+set}" = set; then
+  withval="$with_x"
   :
 fi
 
@@ -667,7 +794,7 @@
   if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
     no_x=
     # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-    eval `make acfindx 2>/dev/null | grep -v make`
+    eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
     # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
     for ac_extension in a so sl; do
       if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
@@ -694,7 +821,7 @@
 test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
 test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
 cat > conftest.$ac_ext <<EOF
-#line 698 "configure"
+#line 825 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
@@ -757,7 +884,7 @@
 ac_save_LIBS="$LIBS"
 LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 761 "configure"
+#line 888 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -854,7 +981,7 @@
     X_LIBS="$X_LIBS -L$x_libraries"
     if test "`(uname) 2>/dev/null`" = SunOS &&
       uname -r | grep '^5' >/dev/null; then
-      X_LIBS="$X_LIBS -R$x_libraries"
+      X_LIBS="$X_LIBS -R $x_libraries"
     fi
   fi
 
@@ -869,13 +996,14 @@
   # libraries we check for below, so use a different variable.
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   echo $ac_n "checking for -lICE""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_lib_ICE'+set}'`\" = set"; then
+ac_lib_var=`echo ICE | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
 LIBS="-lICE  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 879 "configure"
+#line 1007 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -885,16 +1013,16 @@
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_ICE=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_ICE=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'ICE`\" = yes"; then
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
 else
@@ -912,13 +1040,14 @@
     # libraries were built with DECnet support.  And karl@cs.umb.edu says
     # the Alpha needs dnet_stub (dnet does not exist).
     echo $ac_n "checking for -ldnet""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_lib_dnet'+set}'`\" = set"; then
+ac_lib_var=`echo dnet | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 922 "configure"
+#line 1051 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -928,16 +1057,16 @@
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_dnet=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_dnet=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'dnet`\" = yes"; then
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
 else
@@ -946,13 +1075,14 @@
 
     if test $ac_cv_lib_dnet = no; then
       echo $ac_n "checking for -ldnet_stub""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_lib_dnet_stub'+set}'`\" = set"; then
+ac_lib_var=`echo dnet_stub | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 956 "configure"
+#line 1086 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -962,16 +1092,16 @@
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_dnet_stub=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_dnet_stub=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'dnet_stub`\" = yes"; then
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
 else
@@ -985,13 +1115,14 @@
     # Not sure which flavor of 386 UNIX this is, but it seems harmless to
     # check for it.
     echo $ac_n "checking for -lnsl""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_lib_nsl'+set}'`\" = set"; then
+ac_lib_var=`echo nsl | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 995 "configure"
+#line 1126 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1001,16 +1132,16 @@
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_nsl=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_nsl=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'nsl`\" = yes"; then
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
 else
@@ -1023,13 +1154,14 @@
     # But -lsocket is broken on IRIX, according to simon@lia.di.epfl.ch.
     if test "`(uname) 2>/dev/null`" != IRIX; then
       echo $ac_n "checking for -lsocket""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_lib_socket'+set}'`\" = set"; then
+ac_lib_var=`echo socket | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1033 "configure"
+#line 1165 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1039,16 +1171,16 @@
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_socket=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_socket=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'socket`\" = yes"; then
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lsocket"
 else
@@ -1127,13 +1259,14 @@
   *) ac_lib=l ;;
   esac
   echo $ac_n "checking for -l$ac_lib""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib'+set}'`\" = set"; then
+ac_lib_var=`echo $ac_lib | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
 LIBS="-l$ac_lib  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1137 "configure"
+#line 1270 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1143,16 +1276,16 @@
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib`\" = yes"; then
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   LEXLIB="-l$ac_lib"
 else
@@ -1189,14 +1322,74 @@
   echo "$ac_t""no" 1>&6
 fi
 
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+    IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  for ac_dir in $PATH; do
+    # Account for people who put trailing slashes in PATH elements.
+    case "$ac_dir/" in
+    /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+    *)
+      # OSF1 and SCO ODT 3.0 have their own names for install.
+      for ac_prog in ginstall installbsd scoinst install; do
+        if test -f $ac_dir/$ac_prog; then
+	  if test $ac_prog = install &&
+            grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+	    # AIX install.  It has an incompatible calling convention.
+	    # OSF/1 installbsd also uses dspmsg, but is usable.
+	    :
+	  else
+	    ac_cv_path_install="$ac_dir/$ac_prog -c"
+	    break 2
+	  fi
+	fi
+      done
+      ;;
+    esac
+  done
+  IFS="$ac_save_ifs"
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL="$ac_cv_path_install"
+  else
+    # As a last resort, use the slow shell script.  We don't cache a
+    # path for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the path is relative.
+    INSTALL="$ac_install_sh"
+  fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
 echo $ac_n "checking for -li386""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_lib_i386'+set}'`\" = set"; then
+ac_lib_var=`echo i386 | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
 LIBS="-li386  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1200 "configure"
+#line 1393 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1206,16 +1399,16 @@
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_i386=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_i386=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'i386`\" = yes"; then
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   LDLIBS="$LDLIBS -li386"
 else
@@ -1231,13 +1424,13 @@
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1235 "configure"
+#line 1428 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
 #include <assert.h>
 /* Override any gcc2 internal prototype to avoid an error.  */
-char $ac_func(); 
+char $ac_func();
 
 int main() { return 0; }
 int t() {
@@ -1265,7 +1458,7 @@
 fi
 if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-    ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'`
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
   cat >> confdefs.h <<EOF
 #define $ac_tr_func 1
 EOF
@@ -1283,7 +1476,7 @@
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1287 "configure"
+#line 1480 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
@@ -1301,7 +1494,7 @@
 fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-    ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'`
+    ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
   cat >> confdefs.h <<EOF
 #define $ac_tr_hdr 1
 EOF
@@ -1316,7 +1509,7 @@
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1320 "configure"
+#line 1513 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -1357,6 +1550,7 @@
 rm -f conftest*
 
 fi
+
 echo "$ac_t""$ac_cv_header_stat_broken" 1>&6
 if test $ac_cv_header_stat_broken = yes; then
   cat >> confdefs.h <<\EOF
@@ -1370,7 +1564,7 @@
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1374 "configure"
+#line 1568 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1383,7 +1577,7 @@
 char **p;
 /* NEC SVR4.0.2 mips cc rejects this.  */
 struct point {int x, y;};
-static struct point const zero;
+static struct point const zero = {0,0};
 /* AIX XL C 1.02.0.0 rejects this.
    It does not let you subtract one const X* pointer from another in an arm
    of an if-expression whose if-part is not a constant expression */
@@ -1430,6 +1624,7 @@
 rm -f conftest*
 
 fi
+
 echo "$ac_t""$ac_cv_c_const" 1>&6
 if test $ac_cv_c_const = no; then
   cat >> confdefs.h <<\EOF
@@ -1447,7 +1642,7 @@
   ac_cv_c_cross=yes
 else
 cat > conftest.$ac_ext <<EOF
-#line 1451 "configure"
+#line 1646 "configure"
 #include "confdefs.h"
 main(){return(0);}
 EOF
@@ -1460,15 +1655,16 @@
 fi
 rm -fr conftest*
 fi
-cross_compiling=$ac_cv_c_cross
+
 echo "$ac_t""$ac_cv_c_cross" 1>&6
+cross_compiling=$ac_cv_c_cross
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1472 "configure"
+#line 1668 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1490,7 +1686,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1494 "configure"
+#line 1690 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1508,7 +1704,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1512 "configure"
+#line 1708 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1526,10 +1722,10 @@
 if test $ac_cv_header_stdc = yes; then
   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
 if test "$cross_compiling" = yes; then
-  ac_cv_header_stdc=no
+  :
 else
 cat > conftest.$ac_ext <<EOF
-#line 1533 "configure"
+#line 1729 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1550,6 +1746,7 @@
 rm -fr conftest*
 fi
 fi
+
 echo "$ac_t""$ac_cv_header_stdc" 1>&6
 if test $ac_cv_header_stdc = yes; then
   cat >> confdefs.h <<\EOF
@@ -1563,7 +1760,7 @@
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1567 "configure"
+#line 1764 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1590,27 +1787,8 @@
 fi
 
 
-if test -z "${top_srcdir}"; then
-TOP_SRCDIR=`pwd`
-else
-TOP_SRCDIR="${top_srcdir}"
-fi
 
-echo $ac_n "checking for /usr/local/etc/wine.conf""... $ac_c" 1>&6
-if test -f /usr/local/etc/wine.conf; then
-echo "$ac_t""yes" 1>&6
-WINE_INI_GLOBAL='"/usr/local/etc/wine.conf"'
-else
-echo "$ac_t""no" 1>&6
-WINE_INI_GLOBAL="\"${TOP_SRCDIR}/wine.ini\""
-fi
-
-cat >> confdefs.h <<EOF
-#define WINE_INI_GLOBAL $WINE_INI_GLOBAL
-EOF
-
-
-MAKE_RULES=$TOP_SRCDIR/Make.rules
+MAKE_RULES=Make.rules
 
 
 trap '' 1 2 15
@@ -1701,7 +1879,7 @@
     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.4"
+    echo "$CONFIG_STATUS generated by autoconf version 2.7"
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
@@ -1710,12 +1888,35 @@
 done
 
 ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
 
-trap 'rm -fr `echo "Make.rules controls/Makefile ipc/Makefile loader/Makefile memory/Makefile misc/Makefile miscemu/Makefile multimedia/Makefile objects/Makefile win32/Makefile windows/Makefile rc/Makefile debugger/Makefile debugger/readline/Makefile tools/Makefile if1632/Makefile toolkit/Makefile Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+trap 'rm -fr `echo "
+Make.rules
+Makefile
+controls/Makefile
+debugger/Makefile
+debugger/readline/Makefile
+if1632/Makefile
+ipc/Makefile
+library/Makefile
+libtest/Makefile
+loader/Makefile
+memory/Makefile
+misc/Makefile
+miscemu/Makefile
+multimedia/Makefile
+objects/Makefile
+rc/Makefile
+resources/Makefile
+tools/Makefile
+win32/Makefile
+windows/Makefile " | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
 
-# Protect against being on the right side of a sed subst in config.status. 
-sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g; 
- s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
 $ac_vpsub
 $extrasub
 s%@CFLAGS@%$CFLAGS%g
@@ -1727,9 +1928,20 @@
 s%@exec_prefix@%$exec_prefix%g
 s%@prefix@%$prefix%g
 s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
 s%@LDLIBS@%$LDLIBS%g
 s%@MAIN_TARGET@%$MAIN_TARGET%g
-s%@LANG@%$LANG%g
 s%@SET_MAKE@%$SET_MAKE%g
 s%@CC@%$CC%g
 s%@CPP@%$CPP%g
@@ -1741,7 +1953,8 @@
 s%@LEX@%$LEX%g
 s%@LEXLIB@%$LEXLIB%g
 s%@RANLIB@%$RANLIB%g
-s%@WINE_INI_GLOBAL@%$WINE_INI_GLOBAL%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
 /@MAKE_RULES@/r $MAKE_RULES
 s%@MAKE_RULES@%%g
 
@@ -1749,7 +1962,26 @@
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
-CONFIG_FILES=\${CONFIG_FILES-"Make.rules controls/Makefile ipc/Makefile loader/Makefile memory/Makefile misc/Makefile miscemu/Makefile multimedia/Makefile objects/Makefile win32/Makefile windows/Makefile rc/Makefile debugger/Makefile debugger/readline/Makefile tools/Makefile if1632/Makefile toolkit/Makefile Makefile"}
+CONFIG_FILES=\${CONFIG_FILES-"Make.rules
+Makefile
+controls/Makefile
+debugger/Makefile
+debugger/readline/Makefile
+if1632/Makefile
+ipc/Makefile
+library/Makefile
+libtest/Makefile
+loader/Makefile
+memory/Makefile
+misc/Makefile
+miscemu/Makefile
+multimedia/Makefile
+objects/Makefile
+rc/Makefile
+resources/Makefile
+tools/Makefile
+win32/Makefile
+windows/Makefile "}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
@@ -1784,6 +2016,10 @@
     top_srcdir="$ac_dots$ac_given_srcdir" ;;
   esac
 
+  case "$ac_given_INSTALL" in
+  [/$]*) INSTALL="$ac_given_INSTALL" ;;
+  *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+  esac
   echo creating "$ac_file"
   rm -f "$ac_file"
   configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
@@ -1796,6 +2032,7 @@
 s%@configure_input@%$configure_input%g
 s%@srcdir@%$srcdir%g
 s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
 " -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file
 fi; done
 rm -f conftest.subs
diff --git a/configure.in b/configure.in
index 7eee842..27490d1 100644
--- a/configure.in
+++ b/configure.in
@@ -3,9 +3,10 @@
 dnl                         <patra@itp1.physik.tu-berlin.de>
 AC_REVISION([configure.in 1.00])
 AC_INIT(controls/edit.c)		
+AC_CONFIG_AUX_DIR(tools)
 
 # We want these before the checks, so the checks can modify their values.
-test -z "$CFLAGS" && CFLAGS="-g -O2 -Wall" AC_SUBST(CFLAGS)
+test -z "$CFLAGS" && CFLAGS="-g -O2" AC_SUBST(CFLAGS)
 test -z "$LDFLAGS" && LDFLAGS=-g AC_SUBST(LDFLAGS)
 test -z "$LDLIBS" && LDLIBS=-lm AC_SUBST(LDLIBS)
 
@@ -13,15 +14,9 @@
 
 AC_ARG_WITH(library,
 [  --with-library          build Wine as a library instead of an emulator],
-[AC_DEFINE(WINELIB) MAIN_TARGET="winelib.a"],[MAIN_TARGET="wine"])
+[AC_DEFINE(WINELIB) MAIN_TARGET="libwine.a"],[MAIN_TARGET="wine"])
 AC_SUBST(MAIN_TARGET)
 
-AC_ARG_WITH(language,
-[  --with-language=LANG    change the language (LANG=En/De/Fr/Es/No/Fi/Da)],
-[LANG="$withval"],
-[LANG=En],)
-AC_SUBST(LANG)
-
 AC_ARG_WITH(ipc,
 [  --with-ipc              use inter-process communication for DDE],
 [AC_DEFINE(CONFIG_IPC)])
@@ -34,10 +29,14 @@
 
 AC_PROG_MAKE_SET
 AC_PROG_CC
+dnl Add some options for gcc
+test "x${GCC}" = "xyes" && CFLAGS="$CFLAGS -Wall -fno-strength-reduce"
+AC_PROG_CPP
 AC_PATH_XTRA
 AC_PROG_YACC
 AC_PROG_LEX
 AC_PROG_RANLIB
+AC_PROG_INSTALL
 dnl Check for -li386 for NetBSD
 AC_CHECK_LIB(i386,i386_set_ldt,LDLIBS="$LDLIBS -li386")
 
@@ -49,27 +48,32 @@
 AC_C_CONST()
 AC_TYPE_SIZE_T()
 
-if test -z "${top_srcdir}"; then
-TOP_SRCDIR=`pwd`
-else
-TOP_SRCDIR="${top_srcdir}"
-fi
+dnl **** Generate output files ****
 
-AC_MSG_CHECKING(for /usr/local/etc/wine.conf)
-if test -f /usr/local/etc/wine.conf; then
-AC_MSG_RESULT(yes)
-WINE_INI_GLOBAL='"/usr/local/etc/wine.conf"'
-else
-AC_MSG_RESULT(no)
-WINE_INI_GLOBAL="\"${TOP_SRCDIR}/wine.ini\""
-fi
-AC_SUBST(WINE_INI_GLOBAL)
-AC_DEFINE_UNQUOTED(WINE_INI_GLOBAL,$WINE_INI_GLOBAL)
-
-MAKE_RULES=$TOP_SRCDIR/Make.rules
+MAKE_RULES=Make.rules
 AC_SUBST_FILE(MAKE_RULES)
 
-AC_OUTPUT(Make.rules controls/Makefile ipc/Makefile loader/Makefile memory/Makefile misc/Makefile miscemu/Makefile multimedia/Makefile objects/Makefile win32/Makefile windows/Makefile rc/Makefile debugger/Makefile debugger/readline/Makefile tools/Makefile if1632/Makefile toolkit/Makefile Makefile)
+AC_OUTPUT([
+Make.rules
+Makefile
+controls/Makefile
+debugger/Makefile
+debugger/readline/Makefile
+if1632/Makefile
+ipc/Makefile
+library/Makefile
+libtest/Makefile
+loader/Makefile
+memory/Makefile
+misc/Makefile
+miscemu/Makefile
+multimedia/Makefile
+objects/Makefile
+rc/Makefile
+resources/Makefile
+tools/Makefile
+win32/Makefile
+windows/Makefile ])
 
 echo
 echo "Configure finished.  Do 'make depend; make' to compile Wine."
@@ -79,5 +83,5 @@
 dnl comment-start: "dnl "
 dnl comment-end: ""
 dnl comment-start-skip: "\\bdnl\\b\\s *"
-dnl compile-command: "make configure config.h.in"
+dnl compile-command: "autoconf"
 dnl End:
diff --git a/controls/combo.c b/controls/combo.c
index e82deaa..6c3f320 100644
--- a/controls/combo.c
+++ b/controls/combo.c
@@ -434,7 +434,7 @@
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   WORD  wRet;
 
-  wRet = ListBoxFindString(lphl, wParam, lParam);
+  wRet = ListBoxFindString(lphl, wParam, (SEGPTR)lParam);
 
   /* XXX add functionality here */
 
@@ -447,7 +447,7 @@
 static LRESULT CBFindString(HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
-  return ListBoxFindString(lphl, wParam, lParam);
+  return ListBoxFindString(lphl, wParam, (SEGPTR)lParam);
 }
 
 /***********************************************************************
diff --git a/controls/edit.c b/controls/edit.c
index 8663d40..98c2841 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -63,7 +63,7 @@
     int SelEndLine;          /* ending line of selection */
     int SelEndCol;           /* ending column of selection */
     HFONT hFont;             /* handle of current font (if not default) */
-    HANDLE hDeletedText;     /* handle to deleted txet buffer for undo */
+    HANDLE hDeletedText;     /* handle to deleted text buffer for undo */
     int DeletedLength;       /* length of deleted text */
     int DeletedCurrLine;     /* starting line from which text was deleted */
     int DeletedCurrCol;      /* starting col from which text was deleted */
@@ -509,7 +509,15 @@
 	es->BlankLine[(es->ClientWidth / es->CharWidths[32]) + 1] = 0;
     }
 
-    if (!(cp = strchr(str, VK_TAB)))
+    if ((GetWindowLong( hwnd, GWL_STYLE ) & ES_PASSWORD))
+    {
+        int len = strlen(str);
+        char *buff = xmalloc( len+1 );
+        memset( buff, '*', len );
+        buff[len] = '\0';
+	TextOut( hdc, col - diff, row * es->txtht, buff, len );
+    }
+    else if (!(cp = strchr(str, VK_TAB)))
 	TextOut(hdc, col - diff, row * es->txtht, str, strlen(str));
     else
     {
@@ -1920,15 +1928,35 @@
  */
 static LONG EDIT_GetLineMsg(HWND hwnd, WORD wParam, LONG lParam)
 {
-    char *cp, *cp1;
-    int len;
-    unsigned char *buffer = (char *)lParam;
+    char *cp;
+    int len = 0;
+    unsigned char *buffer = (char *)PTR_SEG_TO_LIN(lParam);
 
-    cp = EDIT_TextLine(hwnd, wParam);
-    cp1 = EDIT_TextLine(hwnd, wParam + 1);
-    len = MIN((int)(cp1 - cp), (WORD)(*buffer));
+       /* the line wanted */
+    cp  = EDIT_TextLine  (hwnd, wParam);
+    len = EDIT_LineLength(hwnd, wParam);
+    
+       /* if cp==NULL nothing will be copied - I hope */
+    if ((char *) NULL == cp && 0 != len) {
+       fprintf(stdnimp,"edit: EDIT_GetLineMsg cp == NULL && len != 0"); 
+       return 0L;
+    }
+
+    if (0>len)
+       fprintf(stdnimp,"edit: EDIT_GetLineMsg len < 0"); 
+
+       /* suggested reason for the following line:
+          never copy more than the buffer's size ? 
+          I thought that this would make sense only if
+          the lstrcpyn fun was used instead of the gnu strncpy.
+       */
+    len = MIN(len, (WORD)(*buffer));
+
+    if (0>len)
+       fprintf(stdnimp,"edit: EDIT_GetLineMsg len < 0 after MIN"); 
+
     dprintf_edit( stddeb, "EDIT_GetLineMsg: %d %d, len %d\n", (int)(WORD)(*buffer), (int)(WORD)(*(char *)buffer), len);
-    strncpy(buffer, cp, len);
+    lstrcpyn(buffer, cp, len);
 
     return (LONG)len;
 }
diff --git a/controls/listbox.c b/controls/listbox.c
index 0beca3e..d1b0df7 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -759,7 +759,7 @@
 
   CreateListBoxStruct(hwnd, ODT_LISTBOX, dwStyle, GetParent(hwnd));
   lphl = ListBoxGetStorageHeader(hwnd);
-  dprintf_listbox(stddeb,"ListBox created: lphl = %p dwStyle = "NPFMT":"NPFMT"\n", 
+  dprintf_listbox(stddeb,"ListBox created: lphl = %p dwStyle = %04x:%04x\n", 
 			  lphl, HIWORD(dwStyle), LOWORD(dwStyle));
 
   GetClientRect(hwnd,&rect);
@@ -1431,7 +1431,7 @@
 static LONG LBFindString(HWND hwnd, WORD wParam, LONG lParam)
 {
   LPHEADLIST lphl = ListBoxGetStorageHeader(hwnd);
-  return ListBoxFindString(lphl, wParam, lParam);
+  return ListBoxFindString(lphl, wParam, (SEGPTR)lParam);
 }
 
 /***********************************************************************
@@ -1600,7 +1600,7 @@
   LPHEADLIST lphl = ListBoxGetStorageHeader(hwnd);
   WORD  wRet;
 
-  wRet = ListBoxFindString(lphl, wParam, lParam);
+  wRet = ListBoxFindString(lphl, wParam, (SEGPTR)lParam);
 
   /* XXX add functionality here */
 
diff --git a/controls/menu.c b/controls/menu.c
index 41f5a8b..63f424d 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -23,14 +23,10 @@
 #include "win.h"
 #include "message.h"
 #include "graphics.h"
+#include "resource.h"
 #include "stddebug.h"
-/* #define DEBUG_MENU */
-/* #define DEBUG_MENUCALC */
-/* #define DEBUG_MENUSHORTCUT */
 #include "debug.h"
 
-#include "../rc/sysres.h"
-
   /* Dimension of the menu bitmaps */
 static WORD check_bitmap_width = 0, check_bitmap_height = 0;
 static WORD arrow_bitmap_width = 0, arrow_bitmap_height = 0;
@@ -265,7 +261,7 @@
       mistruct->itemData = (long int)lpitem->item_text;
       mistruct->itemHeight = 16;
       mistruct->itemWidth = 30;
-      SendMessage(hwndOwner,WM_MEASUREITEM,0,mistrsegp);
+      SendMessage(hwndOwner,WM_MEASUREITEM,0,(LPARAM)mistrsegp);
       lpitem->rect.bottom += mistruct->itemHeight;
       lpitem->rect.right += mistruct->itemWidth;
       dprintf_menu(stddeb,"DrawMenuItem: MeasureItem %04x %d:%d!\n",
@@ -475,7 +471,7 @@
       distruct->hwndItem = hwnd;
       distruct->hDC = hdc;
       distruct->rcItem = lpitem->rect;
-      SendMessage(hwnd,WM_DRAWITEM,0,distrsegp);
+      SendMessage(hwnd,WM_DRAWITEM,0,(LPARAM)distrsegp);
       return;
     }
     if (menuBar && (lpitem->item_flags & MF_SEPARATOR)) return;
@@ -633,7 +629,7 @@
     int i;
     WND *wndPtr = WIN_FindWndPtr( hwnd );
     
-    lppop = (LPPOPUPMENU) USER_HEAP_LIN_ADDR( wndPtr->wIDmenu );
+    lppop = (LPPOPUPMENU) USER_HEAP_LIN_ADDR( (HMENU)wndPtr->wIDmenu );
     if (lppop == NULL || lprect == NULL) return SYSMETRICS_CYMENU;
     dprintf_menu(stddeb,"MENU_DrawMenuBar("NPFMT", %p, %p); !\n", 
 		 hDC, lprect, lppop);
@@ -1454,7 +1450,7 @@
     SendMessage( hwnd, WM_ENTERMENULOOP, 0, 0 );
     SendMessage( hwnd, WM_INITMENU, wndPtr->wIDmenu, 0 );
       /* Select first selectable item */
-    MENU_SelectItem( hwnd, wndPtr->wIDmenu, NO_SELECTED_ITEM );
+    MENU_SelectItem( hwnd, (HMENU)wndPtr->wIDmenu, NO_SELECTED_ITEM );
     MENU_SelectNextItem( hwnd, (HMENU)wndPtr->wIDmenu );
     MENU_TrackMenu( (HMENU)wndPtr->wIDmenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
 		    0, 0, hwnd, NULL );
@@ -1672,7 +1668,7 @@
 /**********************************************************************
  *			GetMenuItemCount		[USER.263]
  */
-WORD GetMenuItemCount(HMENU hMenu)
+INT GetMenuItemCount(HMENU hMenu)
 {
 	LPPOPUPMENU	menu;
 	dprintf_menu(stddeb,"GetMenuItemCount("NPFMT");\n", hMenu);
@@ -1724,7 +1720,7 @@
       /* Find where to insert new item */
 
     if ((wFlags & MF_BYPOSITION) && 
-        ((nPos == (UINT)-1) || (nPos == GetMenuItemCount(hMenu))))
+        ((nPos == (UINT)-1) || (nPos == (UINT)GetMenuItemCount(hMenu))))
     {
           /* Special case: append to menu 
              Some programs specify the menu length to do that */
@@ -1857,7 +1853,7 @@
 {
     MENUITEM *item = MENU_FindItem( &hMenu, &nPos, wFlags );
     if (!item) return FALSE;
-    if (item->item_flags & MF_POPUP) DestroyMenu( item->item_id );
+    if (item->item_flags & MF_POPUP) DestroyMenu( (HMENU)item->item_id );
       /* nPos is now the position of the item */
     RemoveMenu( hMenu, nPos, wFlags | MF_BYPOSITION );
     return TRUE;
@@ -2093,7 +2089,7 @@
     if ((UINT)nPos >= lppop->nItems) return 0;
     lpitem = (MENUITEM *) USER_HEAP_LIN_ADDR( lppop->hItems );
     if (!(lpitem[nPos].item_flags & MF_POPUP)) return 0;
-    return lpitem[nPos].item_id;
+    return (HMENU)lpitem[nPos].item_id;
 }
 
 
@@ -2190,9 +2186,12 @@
 HMENU CopySysMenu()
 {
     HMENU hMenu;
+    HGLOBAL handle;
     LPPOPUPMENU menu;
 
-    hMenu = LoadMenuIndirect( sysres_MENU_SYSMENU.bytes );
+    if (!(handle = SYSRES_LoadResource( SYSRES_MENU_SYSMENU ))) return 0;
+    hMenu = LoadMenuIndirect( GlobalLock( handle ) );
+    SYSRES_FreeResource( handle );
     if(!hMenu)
     {
 	dprintf_menu(stddeb,"No SYSMENU\n");
@@ -2230,17 +2229,18 @@
 	    AppendMenu(hMenu, popup_item->item_flags, 
 	    	(UINT)hSubMenu, popup_item->item_text);
 	    }
-	else {
-		MENUITEMTEMPLATE *normal_item = (MENUITEMTEMPLATE *) item;
-		next_item = (WORD *) (normal_item->item_text + 
-		strlen(normal_item->item_text) + 1);
-		if (strlen(normal_item->item_text) == 0 && normal_item->item_id == 0) 
-			normal_item->item_flags |= MF_SEPARATOR;
-		AppendMenu(hMenu, normal_item->item_flags, 
-			normal_item->item_id, normal_item->item_text);
-	    }
-	}
-    while (!(*item & MF_END));
+	else
+        {
+            MENUITEMTEMPLATE *normal_item = (MENUITEMTEMPLATE *) item;
+            WORD flags = normal_item->item_flags;
+            next_item = (WORD *) (normal_item->item_text + 
+                                  strlen(normal_item->item_text) + 1);
+            if (!normal_item->item_text[0] && !normal_item->item_id) 
+                flags |= MF_SEPARATOR;  /* FIXME: do this in InsertMenu? */
+            AppendMenu( hMenu, flags, normal_item->item_id,
+                        normal_item->item_text );
+        }
+    } while (!(*item & MF_END));
     return next_item;
 }
 
diff --git a/debugger/Makefile.in b/debugger/Makefile.in
index c91b01e..3962061 100644
--- a/debugger/Makefile.in
+++ b/debugger/Makefile.in
@@ -25,6 +25,6 @@
 	$(LEX) -8 -I debug.l
 
 clean::
-	rm -f y.tab.c y.tab.h lex.yy.c
+	$(RM) y.tab.c y.tab.h lex.yy.c
 
 ### Dependencies:
diff --git a/debugger/dbg.y b/debugger/dbg.y
index fbca65e..0d9f94c 100644
--- a/debugger/dbg.y
+++ b/debugger/dbg.y
@@ -235,6 +235,19 @@
         if (newmode != dbg_mode)
             fprintf(stderr,"In %d bit mode.\n", dbg_mode = newmode);
 
+        if (signal != SIGTRAP)  /* This is a real crash, dump some info */
+        {
+            DEBUG_InfoRegisters();
+            DEBUG_InfoStack();
+            if (dbg_mode == 16)
+            {
+                LDT_Print( SELECTOR_TO_ENTRY(DS_reg(DEBUG_context)), 1 );
+                if (ES_reg(DEBUG_context) != DS_reg(DEBUG_context))
+                    LDT_Print( SELECTOR_TO_ENTRY(ES_reg(DEBUG_context)), 1 );
+            }
+            DEBUG_BackTrace();
+        }
+
         /* Show where we crashed */
         DEBUG_PrintAddress( &addr, dbg_mode );
         fprintf(stderr,":  ");
diff --git a/debugger/stack.c b/debugger/stack.c
index be7fb9b..9b4e09f 100644
--- a/debugger/stack.c
+++ b/debugger/stack.c
@@ -40,13 +40,13 @@
     {  /* 32-bit mode */
         addr.seg = 0;
         addr.off = ESP_reg(DEBUG_context);
-        DEBUG_ExamineMemory( &addr, 10, 'x' );
+        DEBUG_ExamineMemory( &addr, 24, 'x' );
     }
     else  /* 16-bit mode */
     {
         addr.seg = SS_reg(DEBUG_context);
         addr.off = SP_reg(DEBUG_context);
-        DEBUG_ExamineMemory( &addr, 10, 'w' );
+        DEBUG_ExamineMemory( &addr, 24, 'w' );
     }
     fprintf(stderr,"\n");
 }
diff --git a/if1632/Makefile.in b/if1632/Makefile.in
index 60ac907..b8926e2 100644
--- a/if1632/Makefile.in
+++ b/if1632/Makefile.in
@@ -1,5 +1,4 @@
 TOPSRC = @top_srcdir@
-BUILD  = $(TOPSRC)/tools/build
 
 MODULE = if1632
 
@@ -41,7 +40,7 @@
 $(SPEC16_FILES) $(SPEC32_FILES): $(BUILD)
 
 $(BUILD) checkbuild:
-	cd $(TOPSRC)/tools; $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'DEFS=$(DEFS)' 'LANG=$(LANG)' build
+	cd $(TOPSRC)/tools; $(SUBMAKE) build
 
 call16.S: $(TOPSRC)/include/callback.h $(BUILD)
 	$(BUILD) -call16 `cat $(TOPSRC)/include/callback.h | grep "extern.*CallTo16_" | sed 's/.*CallTo16_\(.*\)(.*/\1/' | sort | uniq` > call16.S
diff --git a/if1632/commdlg.spec b/if1632/commdlg.spec
index 127e064..3f2e25c 100644
--- a/if1632/commdlg.spec
+++ b/if1632/commdlg.spec
@@ -1,29 +1,29 @@
 name	commdlg
 id	14
 
-  1   pascal  GETOPENFILENAME(ptr) GetOpenFileName
-  2   pascal  GETSAVEFILENAME(ptr) GetSaveFileName
-  5   pascal  CHOOSECOLOR(ptr) ChooseColor
-  6   pascal  FILEOPENDLGPROC(word word word long) FileOpenDlgProc
-  7   pascal  FILESAVEDLGPROC(word word word long) FileSaveDlgProc
-  8   pascal  COLORDLGPROC(word word word long) ColorDlgProc
-#  9   pascal  LOADALTERBITMAP exported, shared data
- 11   pascal  FINDTEXT(ptr) FindText
- 12   pascal  REPLACETEXT(ptr) ReplaceText
- 13   pascal  FINDTEXTDLGPROC(word word word long) FindTextDlgProc
- 14   pascal  REPLACETEXTDLGPROC(word word word long) ReplaceTextDlgProc
- 15   stub  ChooseFont
-# 16   pascal  FORMATCHARDLGPROC exported, shared data
-# 18   pascal  FONTSTYLEENUMPROC exported, shared data
-# 19   pascal  FONTFAMILYENUMPROC exported, shared data
- 20   pascal  PRINTDLG(ptr) PrintDlg
- 21   pascal  PRINTDLGPROC(word word word long) PrintDlgProc
- 22   pascal  PRINTSETUPDLGPROC(word word word long) PrintSetupDlgProc
-# 23   pascal  EDITINTEGERONLY exported, shared data
-# 25   pascal  WANTARROWS exported, shared data
- 26   pascal  COMMDLGEXTENDEDERROR() CommDlgExtendError
- 27   pascal  GETFILETITLE(ptr ptr word) GetFileTitle
-# 28   pascal  WEP exported, shared data
-# 29   pascal  DWLBSUBCLASS exported, shared data
-# 30   pascal  DWUPARROWHACK exported, shared data
-# 31   pascal  DWOKSUBCLASS exported, shared data
+1   pascal16 GetOpenFileName(ptr) GetOpenFileName
+2   pascal16 GetSaveFileName(ptr) GetSaveFileName
+5   pascal16 ChooseColor(ptr) ChooseColor
+6   pascal   FileOpenDlgProc(word word word long) FileOpenDlgProc
+7   pascal   FileSaveDlgProc(word word word long) FileSaveDlgProc
+8   pascal   ColorDlgProc(word word word long) ColorDlgProc
+#9   pascal  LOADALTERBITMAP exported, shared data
+11  pascal16 FindText(ptr) FindText
+12  pascal16 ReplaceText(ptr) ReplaceText
+13  pascal   FindTextDlgProc(word word word long) FindTextDlgProc
+14  pascal   ReplaceTextDlgProc(word word word long) ReplaceTextDlgProc
+15  stub ChooseFont
+#16  pascal  FORMATCHARDLGPROC exported, shared data
+#18  pascal  FONTSTYLEENUMPROC exported, shared data
+#19  pascal  FONTFAMILYENUMPROC exported, shared data
+20  pascal16 PrintDlg(ptr) PrintDlg
+21  pascal   PrintDlgProc(word word word long) PrintDlgProc
+22  pascal   PrintSetupDlgProc(word word word long) PrintSetupDlgProc
+#23  pascal  EDITINTEGERONLY exported, shared data
+#25  pascal  WANTARROWS exported, shared data
+26  pascal   CommDlgExtendedError() CommDlgExtendedError
+27  pascal16 GetFileTitle(ptr ptr word) GetFileTitle
+#28  pascal  WEP exported, shared data
+#29  pascal  DWLBSUBCLASS exported, shared data
+#30  pascal  DWUPARROWHACK exported, shared data
+#31  pascal  DWOKSUBCLASS exported, shared data
diff --git a/if1632/kernel32.spec b/if1632/kernel32.spec
index bb122a0..e7d3523 100644
--- a/if1632/kernel32.spec
+++ b/if1632/kernel32.spec
@@ -286,7 +286,7 @@
 0282 stub GetSystemDirectoryA
 0283 stub GetSystemDirectoryW
 0284 stub GetSystemInfo
-0285 stub GetSystemTime
+0285 	stdcall GetSystemTime(ptr) GetSystemTime
 0286 stub GetSystemTimeAdjustment
 0287 stub GetTapeParameters
 0288 stub GetTapePosition
@@ -525,7 +525,7 @@
 0520 stub SetupComm
 0521 stub ShowConsoleCursor
 0522 stub SizeofResource
-0523 stub Sleep
+0523 	stdcall Sleep(long) Sleep
 0524 stub SleepEx
 0525 stub SuspendThread
 0526 stub SystemTimeToFileTime
diff --git a/if1632/relay.c b/if1632/relay.c
index df41747..6f6f7c8 100644
--- a/if1632/relay.c
+++ b/if1632/relay.c
@@ -173,8 +173,10 @@
     struct dll_table_s *table;
     char *name;
 
-    if (*(DWORD *)PTR_SEG_TO_LIN(IF1632_Stack32_base) != 0xDEADBEEF) {
+    if (*(DWORD *)PTR_SEG_TO_LIN(IF1632_Stack32_base) != 0xDEADBEEF)
+    {
 	fprintf(stderr, "Wine wrote past the end of the 32 bit stack. Please report this.\n");
+        exit(1);  /* There's probably no point in going on */
     }
     if (!debugging_relay) return;
 
@@ -186,13 +188,16 @@
     switch(func_type)
     {
     case 0: /* long */
-        printf( "retval=0x%08x ds=%04x\n", ret_val, frame->ds );
+        printf( "retval=0x%08x ret=%04x:%04x ds=%04x\n",
+                ret_val, frame->cs, frame->ip, frame->ds );
         break;
     case 1: /* word */
-        printf( "retval=0x%04x ds=%04x\n", ret_val & 0xffff, frame->ds );
+        printf( "retval=0x%04x ret=%04x:%04x ds=%04x\n",
+                ret_val & 0xffff, frame->cs, frame->ip, frame->ds );
         break;
     case 2: /* regs */
-        printf( "retval=none ds=%04x\n", frame->ds );
+        printf( "retval=none ret=%04x:%04x ds=%04x\n",
+                frame->cs, frame->ip, frame->ds );
         {
             struct sigcontext_struct *context = (struct sigcontext_struct *)&args32;
             printf( "     AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
diff --git a/include/commdlg.h b/include/commdlg.h
index dcc96b9..f51e4b6 100644
--- a/include/commdlg.h
+++ b/include/commdlg.h
@@ -290,6 +290,15 @@
 #define FINDDLG		       		9
 #define REPLACEDLG	       		10
 
+BOOL  ChooseColor(LPCHOOSECOLOR lpChCol);
+DWORD CommDlgExtendedError(void);
+BOOL  FindText(LPFINDREPLACE lpFind);
+short GetFileTitle(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf);
+BOOL  GetOpenFileName(LPOPENFILENAME lpofn);
+BOOL  GetSaveFileName(LPOPENFILENAME lpofn);
+BOOL  PrintDlg(LPPRINTDLG lpPrint);
+BOOL  ReplaceText(LPFINDREPLACE lpFind);
+
 LRESULT FileOpenDlgProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
 LRESULT FileSaveDlgProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
 LRESULT ColorDlgProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
diff --git a/include/global.h b/include/global.h
index 6ea7b40..d1692be 100644
--- a/include/global.h
+++ b/include/global.h
@@ -16,7 +16,7 @@
     int shmid;
 } SHMDATA;
 
-extern HGLOBAL GLOBAL_CreateBlock( WORD flags, void *ptr, DWORD size,
+extern HGLOBAL GLOBAL_CreateBlock( WORD flags, const void *ptr, DWORD size,
                                    HGLOBAL hOwner, BOOL isCode,
                                    BOOL is32Bit, BOOL isReadOnly,
 				   SHMDATA *shmdata);
diff --git a/include/kernel32.h b/include/kernel32.h
index 501e8d8..367a639 100644
--- a/include/kernel32.h
+++ b/include/kernel32.h
@@ -56,16 +56,7 @@
         HANDLE hStdError;
 } STARTUPINFO, *LPSTARTUPINFO;
 
-typedef struct {
-        WORD wYear;
-        WORD wMonth;
-        WORD wDayOfWeek;
-        WORD wDay;
-        WORD wHour;
-        WORD wMinute;
-        WORD wSecond;
-        WORD wMilliseconds;
-} SYSTEMTIME, *LPSYSTEMTIME;
+/* SYSTEMTIME, and LPSYSTEMTIME moved to include/windows.h (JBP) */
 
 typedef struct {
         LONG Bias;
diff --git a/include/libres.h b/include/libres.h
index 918f042..a719692 100644
--- a/include/libres.h
+++ b/include/libres.h
@@ -6,18 +6,16 @@
 
 #ifdef WINELIB
 
-#include "windows.h"
+#include "wintypes.h"
 #include "resource.h"
 
-void    LIBRES_RegisterResources(struct resource** Res);
-
-INT     LIBRES_AccessResource( HINSTANCE hModule, HRSRC hRsrc );
-HGLOBAL LIBRES_AllocResource( HINSTANCE hModule, HRSRC hRsrc, DWORD size );
-HRSRC   LIBRES_FindResource( HINSTANCE hModule, LPCSTR name, LPCSTR type );
-BOOL    LIBRES_FreeResource( HGLOBAL handle );
-HGLOBAL LIBRES_LoadResource( HINSTANCE hModule, HRSRC hRsrc );
-LPVOID  LIBRES_LockResource( HGLOBAL handle );
-DWORD   LIBRES_SizeofResource( HINSTANCE hModule, HRSRC hRsrc );
+extern INT     LIBRES_AccessResource( HINSTANCE hModule, HRSRC hRsrc );
+extern HGLOBAL LIBRES_AllocResource( HINSTANCE hModule, HRSRC hRsrc, DWORD size );
+extern HRSRC   LIBRES_FindResource( HINSTANCE hModule, LPCSTR name, LPCSTR type );
+extern BOOL    LIBRES_FreeResource( HGLOBAL handle );
+extern HGLOBAL LIBRES_LoadResource( HINSTANCE hModule, HRSRC hRsrc );
+extern LPVOID  LIBRES_LockResource( HGLOBAL handle );
+extern DWORD   LIBRES_SizeofResource( HINSTANCE hModule, HRSRC hRsrc );
 
 #endif /* WINELIB */
 
diff --git a/include/message.h b/include/message.h
index 8956faf..85159b0 100644
--- a/include/message.h
+++ b/include/message.h
@@ -23,7 +23,7 @@
 
 typedef struct tagMESSAGEQUEUE
 {
-  WORD      next;                   /* 00 Next queue */
+  HANDLE    next;                   /* 00 Next queue */
   HTASK     hTask;                  /* 02 hTask owning the queue */
   WORD      msgSize;                /* 04 Size of messages in the queue */
   WORD      msgCount;               /* 06 Number of waiting messages */
diff --git a/include/module.h b/include/module.h
index 5ab729f..3ca58cc 100644
--- a/include/module.h
+++ b/include/module.h
@@ -113,7 +113,7 @@
 extern int MODULE_OpenFile( HMODULE hModule );
 extern LPSTR MODULE_GetModuleName( HMODULE hModule );
 extern WORD MODULE_GetOrdinal( HMODULE hModule, char *name );
-extern DWORD MODULE_GetEntryPoint( HMODULE hModule, WORD ordinal );
+extern SEGPTR MODULE_GetEntryPoint( HMODULE hModule, WORD ordinal );
 extern BOOL MODULE_SetEntryPoint( HMODULE hModule, WORD ordinal, WORD offset );
 extern LPSTR MODULE_GetEntryPointName( HMODULE hModule, WORD ordinal );
 
diff --git a/include/resource.h b/include/resource.h
index 26d5897..358a43e 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -9,6 +9,40 @@
 
 #include "wintypes.h"
 
+struct resource
+{
+    int id;
+    int type;
+    const char *name;
+    const unsigned char* bytes;
+    unsigned size;
+};
+
+/* Built-in resources */
+typedef enum
+{
+    SYSRES_MENU_SYSMENU,
+    SYSRES_DIALOG_MSGBOX,
+    SYSRES_DIALOG_SHELL_ABOUT_MSGBOX,
+    SYSRES_DIALOG_OPEN_FILE,
+    SYSRES_DIALOG_SAVE_FILE,
+    SYSRES_DIALOG_PRINT,
+    SYSRES_DIALOG_PRINT_SETUP,
+    SYSRES_DIALOG_CHOOSE_FONT,
+    SYSRES_DIALOG_CHOOSE_COLOR,
+    SYSRES_DIALOG_FIND_TEXT,
+    SYSRES_DIALOG_REPLACE_TEXT
+} SYSTEM_RESOURCE;
+
+extern void LIBRES_RegisterResources(const struct resource* const * Res);
+
+#if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)
+#define WINE_CONSTRUCTOR  __attribute__((constructor))
+#define HAVE_WINE_CONSTRUCTOR
+#else
+#define WINE_CONSTRUCTOR
+#endif
+
 extern int NE_AccessResource( HMODULE hModule, HRSRC hRsrc );
 extern BOOL NE_FreeResource( HMODULE hModule, HGLOBAL handle );
 extern HRSRC NE_FindResource( HMODULE hModule, SEGPTR typeId, SEGPTR resId );
@@ -17,19 +51,7 @@
 extern HGLOBAL NE_AllocResource( HMODULE hModule, HRSRC hRsrc, DWORD size );
 extern HGLOBAL NE_LoadResource( HMODULE hModule,  HRSRC hRsrc );
 
-struct resource
-{
-        int id,type;
-        char *name;
-        unsigned char* bytes;
-        unsigned size;
-};
-
-#if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)
-#define WINE_CONSTRUCTOR  __attribute__((constructor))
-#define HAVE_WINE_CONSTRUCTOR
-#else
-#define WINE_CONSTRUCTOR
-#endif
+extern HANDLE SYSRES_LoadResource( SYSTEM_RESOURCE id );
+extern void SYSRES_FreeResource( HANDLE handle );
 
 #endif /* __WINE_RESOURCE_H */
diff --git a/include/selectors.h b/include/selectors.h
index 83a5309..d06f13d 100644
--- a/include/selectors.h
+++ b/include/selectors.h
@@ -10,9 +10,10 @@
 #include "windows.h"
 #include "ldt.h"
 
-extern WORD SELECTOR_AllocBlock( void *base, DWORD size, enum seg_type type,
-                                 BOOL is32bit, BOOL readonly );
-extern WORD SELECTOR_ReallocBlock( WORD sel, void *base, DWORD size,
+extern WORD SELECTOR_AllocBlock( const void *base, DWORD size,
+				 enum seg_type type, BOOL is32bit,
+				 BOOL readonly );
+extern WORD SELECTOR_ReallocBlock( WORD sel, const void *base, DWORD size,
                                    enum seg_type type, BOOL is32bit,
                                    BOOL readonly );
 
diff --git a/include/shell.h b/include/shell.h
index 652f481..88ca4b1 100644
--- a/include/shell.h
+++ b/include/shell.h
@@ -7,15 +7,15 @@
 extern void SHELL_SaveRegistry();
 extern BOOL SHELL_Init();
 
-#define ERROR_SUCCESS           0L
-#define ERROR_BADDB             1L
-#define ERROR_BADKEY            2L
-#define ERROR_CANTOPEN          3L
-#define ERROR_CANTREAD          4L
-#define ERROR_CANTWRITE         5L
-#define ERROR_OUTOFMEMORY       6L
-#define ERROR_INVALID_PARAMETER 7L
-#define ERROR_ACCESS_DENIED     8L
+#define SHELL_ERROR_SUCCESS           0L
+#define SHELL_ERROR_BADDB             1L
+#define SHELL_ERROR_BADKEY            2L
+#define SHELL_ERROR_CANTOPEN          3L
+#define SHELL_ERROR_CANTREAD          4L
+#define SHELL_ERROR_CANTWRITE         5L
+#define SHELL_ERROR_OUTOFMEMORY       6L
+#define SHELL_ERROR_INVALID_PARAMETER 7L
+#define SHELL_ERROR_ACCESS_DENIED     8L
 
 #define REG_SZ                  1           /* string type */
 
diff --git a/include/windows.h b/include/windows.h
index e0430aa..3934834 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -1104,7 +1104,11 @@
 #define ONE5STOPBITS	1
 #define TWOSTOPBITS	2
 #define IGNORE		0
+#ifdef WINELIB32
+#define INFINITE        0xFFFFFFFF
+#else
 #define INFINITE	0xFFFF
+#endif
 
 #define CE_RXOVER	0x0001
 #define CE_OVERRUN	0x0002
@@ -2273,7 +2277,6 @@
 #define LMEM_ZEROINIT       0x0040
 #define LMEM_MODIFY         0x0080
 #define LMEM_DISCARDABLE    0x0F00
-#define LMEM_WINE_ALIGN     0x1000
 
 #define GMEM_FIXED          0x0000
 #define GMEM_MOVEABLE       0x0002
@@ -2510,6 +2513,18 @@
 #define DBF_APPLICATION     0x0008
 #define DBF_DRIVER          0x0010
 
+/* Win32-specific structures */
+
+typedef struct {
+        WORD wYear;
+        WORD wMonth;
+        WORD wDayOfWeek;
+        WORD wDay;
+        WORD wHour;
+        WORD wMinute;
+        WORD wSecond;
+        WORD wMilliseconds;
+} SYSTEMTIME, *LPSYSTEMTIME;
 
 #ifndef WINELIB
 #pragma pack(4)
@@ -2657,7 +2672,7 @@
 WORD       EnumClipboardFormats(WORD);
 int        EnumFonts(HDC,LPSTR,FARPROC,LPSTR);
 BOOL       EnumMetaFile(HDC,LOCALHANDLE,FARPROC,BYTE*);
-int        EnumObjects(HDC,int,FARPROC,LPSTR);
+int        EnumObjects(HDC,int,FARPROC,LPARAM);
 int        EnumProps(HWND,FARPROC);
 BOOL       EnumTaskWindows(HANDLE,FARPROC,LONG);
 BOOL       EnumWindows(FARPROC,LONG);
@@ -2762,10 +2777,11 @@
 void       GetKeyboardState(BYTE*);
 int        GetKeyboardType(int);
 HWND       GetLastActivePopup(HWND);
+VOID       GetLocalTime(LPSYSTEMTIME);     /* Win32 */
 WORD       GetMapMode(HDC);
 HMENU      GetMenu(HWND);
 DWORD      GetMenuCheckMarkDimensions(void);
-WORD       GetMenuItemCount(HMENU);
+INT        GetMenuItemCount(HMENU);
 UINT       GetMenuItemID(HMENU,int);
 UINT       GetMenuState(HMENU,UINT,UINT);
 int        GetMenuString(HMENU,UINT,LPSTR,short,UINT);
@@ -2815,6 +2831,7 @@
 int        GetSystemMetrics(WORD);
 WORD       GetSystemPaletteEntries(HDC,WORD,WORD,LPPALETTEENTRY);
 WORD       GetSystemPaletteUse(HDC);
+VOID       GetSystemTime(LPSYSTEMTIME);    /* Win32 */
 DWORD      GetTabbedTextExtent(HDC,LPSTR,int,int,LPINT);
 HINSTANCE  GetTaskDS(void);
 HGLOBAL    GetTaskQueue(HTASK);
@@ -3143,6 +3160,7 @@
 void       ShowScrollBar(HWND,WORD,BOOL);
 BOOL       ShowWindow(HWND,int);
 DWORD      SizeofResource(HINSTANCE,HRSRC);
+VOID       Sleep(DWORD);      /* Win32 */
 int        StartSound(void);
 int        StopSound(void);
 BOOL       StretchBlt(HDC,short,short,short,short,HDC,short,short,short,short,DWORD);
diff --git a/include/winpos.h b/include/winpos.h
index 56cabb7..8660036 100644
--- a/include/winpos.h
+++ b/include/winpos.h
@@ -28,7 +28,7 @@
 
 extern void WINPOS_FindIconPos( HWND hwnd );
 extern BOOL WINPOS_SetActiveWindow( HWND hWnd, BOOL fMouse, BOOL fChangeFocus);
-extern HWND WINPOS_ChangeActiveWindow( HWND hwnd, BOOL mouseMsg );
+extern BOOL WINPOS_ChangeActiveWindow( HWND hwnd, BOOL mouseMsg );
 extern LONG WINPOS_SendNCCalcSize( HWND hwnd, BOOL calcValidRect,
 				   RECT *newWindowRect, RECT *oldWindowRect,
 				   RECT *oldClientRect, WINDOWPOS *winpos,
diff --git a/include/wintypes.h b/include/wintypes.h
index 0d7689a..30ecb94 100644
--- a/include/wintypes.h
+++ b/include/wintypes.h
@@ -34,6 +34,7 @@
 typedef void* SEGPTR;
 #define UIFMT "%u"
 #define NPFMT "%p"
+#define SPFMT "%p"
 #else
 typedef short INT;
 typedef unsigned short UINT;
@@ -42,13 +43,15 @@
 typedef WORD NPVOID;
 typedef DWORD SEGPTR;
 #define UIFMT "%hu"
-#define NPFMT "%04X"
+#define NPFMT "%04x"
+#define SPFMT "%08lx"
 #endif
 typedef LONG LPARAM;
 typedef LONG LRESULT;
 typedef DWORD HHOOK;
 typedef char *LPSTR;
 typedef const char *LPCSTR;
+typedef LPCSTR LPCTSTR;
 typedef char *NPSTR;
 typedef INT *LPINT;
 typedef UINT *LPUINT;
diff --git a/library/Makefile.in b/library/Makefile.in
new file mode 100644
index 0000000..9e27caa
--- /dev/null
+++ b/library/Makefile.in
@@ -0,0 +1,17 @@
+TOPSRC = @top_srcdir@
+MODULE = library
+
+C_SRCS = \
+	atom.c \
+	arch.c \
+	heap.c \
+	libres.c \
+	miscstubs.c \
+	sup.c \
+	winmain.c
+
+all: $(MODULE).o
+
+@MAKE_RULES@
+
+### Dependencies:
diff --git a/toolkit/README.libres b/library/README.libres
similarity index 100%
rename from toolkit/README.libres
rename to library/README.libres
diff --git a/toolkit/README.resources b/library/README.resources
similarity index 100%
rename from toolkit/README.resources
rename to library/README.resources
diff --git a/toolkit/arch.c b/library/arch.c
similarity index 100%
rename from toolkit/arch.c
rename to library/arch.c
diff --git a/toolkit/atom.c b/library/atom.c
similarity index 100%
rename from toolkit/atom.c
rename to library/atom.c
diff --git a/toolkit/heap.c b/library/heap.c
similarity index 95%
rename from toolkit/heap.c
rename to library/heap.c
index 7bb3afd..6148c53 100644
--- a/toolkit/heap.c
+++ b/library/heap.c
@@ -79,11 +79,8 @@
     HANDLE hMem;
 
     slot = HEAP_GetFreeSlot (&hMem);
-    if (flags & LMEM_WINE_ALIGN)
-	m = memalign (4, bytes);
-    else
-	m = malloc (bytes);
-    if (m){
+    if ((m = malloc (bytes)))
+    {
 	*slot = m;
 	if (flags & LMEM_ZEROINIT)
 	    bzero (m, bytes);
@@ -221,11 +218,8 @@
     HeapData* m;
 
     bytes+=sizeof(HeapData);
-    if (flags & LMEM_WINE_ALIGN)
-	m = memalign (4, bytes);
-    else
-	m = malloc (bytes);
-    if (m){
+    if ((m = malloc (bytes)))
+    {
 	if (flags & LMEM_ZEROINIT)
 	    bzero (m, bytes);
     }
diff --git a/toolkit/libres.c b/library/libres.c
similarity index 89%
rename from toolkit/libres.c
rename to library/libres.c
index ae23b41..5f4c5b5 100644
--- a/toolkit/libres.c
+++ b/library/libres.c
@@ -7,29 +7,26 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include "libres.h"
+#include "windows.h"
+#include "xmalloc.h"
 
 typedef struct RLE
 {
-  struct resource** Resources;  /* NULL-terminated array of pointers */
-  struct RLE* next;
+    const struct resource* const * Resources;  /* NULL-terminated array of pointers */
+    struct RLE* next;
 } ResListE;
 
 static ResListE* ResourceList=NULL;
 
-void LIBRES_RegisterResources(struct resource** Res)
+void LIBRES_RegisterResources(const struct resource* const * Res)
 {
   ResListE** Curr;
   ResListE* n;
   for(Curr=&ResourceList; *Curr; Curr=&((*Curr)->next)) { }
   n=xmalloc(sizeof(ResListE));
-  if(n)
-  {
-    n->Resources=Res;
-    n->next=NULL;
-    *Curr=n;
-  }
-  else
-    fprintf(stderr,"LIBRES_RegisterResources(): Out of memory.\n");
+  n->Resources=Res;
+  n->next=NULL;
+  *Curr=n;
 }
 
 /**********************************************************************
@@ -39,7 +36,7 @@
 {
   int nameid=0,typeid;
   ResListE* ResBlock;
-  struct resource** Res;
+  const struct resource* const * Res;
 
   if(HIWORD(name))
   {
diff --git a/toolkit/miscstubs.c b/library/miscstubs.c
similarity index 98%
rename from toolkit/miscstubs.c
rename to library/miscstubs.c
index edab69e..8f62d4c 100644
--- a/toolkit/miscstubs.c
+++ b/library/miscstubs.c
@@ -109,13 +109,13 @@
     return handle;
 }
 
-HGLOBAL GLOBAL_CreateBlock( WORD flags, void *ptr, DWORD size,
+HGLOBAL GLOBAL_CreateBlock( WORD flags, const void *ptr, DWORD size,
 			    HGLOBAL hOwner, BOOL isCode,
 			    BOOL is32Bit, BOOL isReadOnly,
 			    SHMDATA *shmdata)
 {
 /*  fprintf(stderr,"JBP: GLOBAL_CreateBlock() faked.\n");*/
-  return ptr;
+  return (HGLOBAL)ptr;
 }
 
 BOOL GLOBAL_FreeBlock( HGLOBAL handle )
diff --git a/toolkit/sup.c b/library/sup.c
similarity index 100%
rename from toolkit/sup.c
rename to library/sup.c
diff --git a/toolkit/winmain.c b/library/winmain.c
similarity index 100%
rename from toolkit/winmain.c
rename to library/winmain.c
diff --git a/libtest/Makefile.in b/libtest/Makefile.in
new file mode 100644
index 0000000..23e4a66
--- /dev/null
+++ b/libtest/Makefile.in
@@ -0,0 +1,34 @@
+TOPSRC   = @top_srcdir@
+MODULE   = none
+PROGRAMS = hello hello2 hello3 rolex
+ALL_LIBS = $(WINELIB) $(X_LIBS) $(XPM_LIB) $(XLIB) $(LDLIBS)
+
+C_SRCS = \
+	hello.c \
+	hello2.c \
+	hello3.c \
+	hello3res.c \
+	rolex.c
+
+all: check_winerc $(PROGRAMS)
+
+@MAKE_RULES@
+
+hello: hello.o $(WINELIB)
+	$(CC) -o hello hello.o $(LDOPTIONS) $(ALL_LIBS)
+
+hello2: hello2.o $(WINELIB)
+	$(CC) -o hello2 hello2.o $(LDOPTIONS) $(ALL_LIBS)
+
+hello3: hello3res.o hello3.o $(WINELIB)
+	$(CC) -o hello3 hello3.o hello3res.o $(LDOPTIONS) $(ALL_LIBS)
+
+rolex: rolex.o $(WINELIB)
+	$(CC) -o rolex rolex.o $(LDOPTIONS) $(ALL_LIBS)
+
+clean::
+	$(RM) hello hello2 hello3 hello3res.c hello3res.h rolex
+
+hello3res.c hello3res.h: $(WINERC)
+
+### Dependencies:
diff --git a/libtest/README.rolex b/libtest/README.rolex
new file mode 100644
index 0000000..a481683
--- /dev/null
+++ b/libtest/README.rolex
@@ -0,0 +1,8 @@
+Windows clock application for WINE (by Jim Peterson)
+
+This is a translation of a Turbo Pascal OWL application I made once,
+so it's a little flaky (tons of globals, functions that could have
+been in-lined, etc.).  The file rolex.exe is a Win32 application
+compiled using this source code and Borland C++ 4.0.
+
+To try it out, type 'make rolex' or 'wine ./rolex.exe' (which fails).
diff --git a/toolkit/hello.c b/libtest/hello.c
similarity index 100%
rename from toolkit/hello.c
rename to libtest/hello.c
diff --git a/toolkit/hello2.c b/libtest/hello2.c
similarity index 100%
rename from toolkit/hello2.c
rename to libtest/hello2.c
diff --git a/toolkit/hello3.c b/libtest/hello3.c
similarity index 92%
rename from toolkit/hello3.c
rename to libtest/hello3.c
index 5b9cd51..fe532cb 100644
--- a/toolkit/hello3.c
+++ b/libtest/hello3.c
@@ -33,12 +33,12 @@
 	case WM_COMMAND:
 	switch(w){
 		case 100:
-			CreateDialogIndirect(0,hello3_DIALOG_DIADEMO.bytes,wnd,(WNDPROC)DlgProc);
+			CreateDialogIndirect(0,hello3res_DIALOG_DIADEMO.bytes,wnd,(WNDPROC)DlgProc);
 			return 0;
 		case 101:
 		{
-			BITMAPINFO *bm=hello3_BITMAP_BITDEMO.bytes;
-			char *bits=bm;
+			BITMAPINFO *bm=(BITMAPINFO*)hello3res_BITMAP_BITDEMO.bytes;
+			char *bits=(char*)bm;
 			HDC hdc=GetDC(wnd);
 			bits+=bm->bmiHeader.biSize;
 			bits+=(1<<bm->bmiHeader.biBitCount)*sizeof(RGBQUAD);
diff --git a/toolkit/hello3res.rc b/libtest/hello3res.rc
similarity index 100%
rename from toolkit/hello3res.rc
rename to libtest/hello3res.rc
diff --git a/libtest/rolex.c b/libtest/rolex.c
new file mode 100644
index 0000000..fc71f79
--- /dev/null
+++ b/libtest/rolex.c
@@ -0,0 +1,241 @@
+#include <math.h>
+#include <string.h>
+#include "windows.h"
+
+char* AppName = "Rolex";
+char* WindowName = "Rolex";
+int WindowWidth = 100;
+int WindowHeight = 121;
+COLORREF FaceColor = RGB(192,192,192);
+COLORREF HandColor = RGB(0,0,0);
+COLORREF EtchColor = RGB(0,0,0);
+
+float Pi=3.1415926;
+
+typedef struct
+{
+  int StartX,StartY,EndX,EndY;
+} HandData;
+
+int MaxX,MaxY;
+HandData OldSecond,OldHour,OldMinute;
+
+HWND HWindow;
+
+void DrawFace(HDC dc)
+{
+  int MidX, MidY, t;
+
+  MidX=MaxX/2;
+  MidY=MaxY/2;
+  SelectObject(dc,CreateSolidBrush(FaceColor));
+  SelectObject(dc,CreatePen(PS_SOLID,1,EtchColor));
+  Ellipse(dc,0,0,MaxX,MaxY);
+
+  for(t=0; t<12; t++)
+  {
+    MoveToEx(dc,MidX+sin(t*Pi/6)*0.9*MidX,MidY-cos(t*Pi/6)*0.9*MidY,NULL);
+    LineTo(dc,MidX+sin(t*Pi/6)*0.8*MidX,MidY-cos(t*Pi/6)*0.8*MidY);
+  }
+  if(MaxX>64 && MaxY>64)
+    for(t=0; t<60; t++)
+      SetPixel(dc,MidX+sin(t*Pi/30)*0.9*MidX,MidY-cos(t*Pi/30)*0.9*MidY
+	       ,EtchColor);
+  DeleteObject(SelectObject(dc,GetStockObject(NULL_BRUSH)));
+  DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
+  memset(&OldSecond,0,sizeof(OldSecond));
+  memset(&OldMinute,0,sizeof(OldMinute));
+  memset(&OldHour,0,sizeof(OldHour));
+}
+
+void DrawHourHand(HDC dc)
+{
+  MoveToEx(dc, OldHour.StartX, OldHour.StartY, NULL);
+  LineTo(dc, OldHour.EndX, OldHour.EndY);
+}
+
+void DrawMinuteHand(HDC dc)
+{
+  MoveToEx(dc, OldMinute.StartX, OldMinute.StartY, NULL);
+  LineTo(dc, OldMinute.EndX, OldMinute.EndY);
+}
+
+void DrawSecondHand(HDC dc)
+{
+  MoveToEx(dc, OldSecond.StartX, OldSecond.StartY, NULL);
+  LineTo(dc, OldSecond.EndX, OldSecond.EndY);
+}
+
+BOOL UpdateHourHand(HDC dc,int MidX,int MidY,int XExt,int YExt,WORD Pos)
+{
+  int Sx, Sy, Ex, Ey;
+  BOOL rv;
+
+  rv = FALSE;
+  Sx = MidX; Sy = MidY;
+  Ex = MidX+sin(Pos*Pi/6000)*XExt;
+  Ey = MidY-cos(Pos*Pi/6000)*YExt;
+  rv = ( Sx!=OldHour.StartX || Ex!=OldHour.EndX || 
+	 Sy!=OldHour.StartY || Ey!=OldHour.EndY );
+  if(rv)DrawHourHand(dc);
+  OldHour.StartX = Sx; OldHour.EndX = Ex;
+  OldHour.StartY = Sy; OldHour.EndY = Ey;
+  return rv;
+}
+
+BOOL UpdateMinuteHand(HDC dc,int MidX,int MidY,int XExt,int YExt,WORD Pos)
+{
+  int Sx, Sy, Ex, Ey;
+  BOOL rv;
+
+  rv = FALSE;
+  Sx = MidX; Sy = MidY;
+  Ex = MidX+sin(Pos*Pi/30000)*XExt;
+  Ey = MidY-cos(Pos*Pi/30000)*YExt;
+  rv = ( Sx!=OldMinute.StartX || Ex!=OldMinute.EndX ||
+	 Sy!=OldMinute.StartY || Ey!=OldMinute.EndY );
+  if(rv)DrawMinuteHand(dc);
+  OldMinute.StartX = Sx; OldMinute.EndX = Ex;
+  OldMinute.StartY = Sy; OldMinute.EndY = Ey;
+  return rv;
+}
+
+BOOL UpdateSecondHand(HDC dc,int MidX,int MidY,int XExt,int YExt,WORD Pos)
+{
+  int Sx, Sy, Ex, Ey;
+  BOOL rv;
+
+  rv = FALSE;
+  Sx = MidX; Sy = MidY;
+  Ex = MidX+sin(Pos*Pi/3000)*XExt;
+  Ey = MidY-cos(Pos*Pi/3000)*YExt;
+  rv = ( Sx!=OldSecond.StartX || Ex!=OldSecond.EndX ||
+	 Sy!=OldSecond.StartY || Ey!=OldSecond.EndY );
+  if(rv)DrawSecondHand(dc);
+  OldSecond.StartX = Sx; OldSecond.EndX = Ex;
+  OldSecond.StartY = Sy; OldSecond.EndY = Ey;
+  return rv;
+}
+
+void Idle(HDC idc)
+{
+  SYSTEMTIME st;
+  WORD H, M, S, F;
+  int MidX, MidY;
+  HDC dc;
+  BOOL Redraw;
+
+  if(idc)
+    dc=idc;
+  else
+    dc=GetDC(HWindow);
+  if(!dc)return;
+
+  GetLocalTime(&st);
+  H = st.wHour;
+  M = st.wMinute;
+  S = st.wSecond;
+  F = st.wMilliseconds / 10;
+  F = F + S*100;
+  M = M*1000+F/6;
+  H = H*1000+M/60;
+  MidX = MaxX/2;
+  MidY = MaxY/2;
+  SelectObject(dc,CreatePen(PS_SOLID,1,FaceColor));
+  Redraw = FALSE;
+  if(UpdateHourHand(dc,MidX,MidY,MidX*0.5,MidY*0.5,H)) Redraw = TRUE;
+  if(UpdateMinuteHand(dc,MidX,MidY,MidX*0.65,MidY*0.65,M)) Redraw = TRUE;
+  if(UpdateSecondHand(dc,MidX,MidY,MidX*0.79,MidY*0.79,F)) Redraw = TRUE;
+  DeleteObject(SelectObject(dc,CreatePen(PS_SOLID,1,HandColor)));
+  if(Redraw)
+  {
+    DrawSecondHand(dc);
+    DrawMinuteHand(dc);
+    DrawHourHand(dc);
+  }
+  DeleteObject(SelectObject(dc,GetStockObject(NULL_PEN)));
+  if(!idc) ReleaseDC(HWindow,dc);
+}
+
+LRESULT ProcessAppMsg(HWND wnd,UINT msg,WPARAM w,LPARAM l)
+{
+  PAINTSTRUCT PaintInfo;
+  HDC dc;
+
+  switch(msg)
+  {
+  case WM_PAINT:
+    if(GetUpdateRect(wnd,NULL,FALSE))
+    {
+      dc=BeginPaint(wnd,&PaintInfo);
+      DrawFace(dc);
+      Idle(dc);
+      EndPaint(wnd,&PaintInfo);
+    }
+    break;
+
+  case WM_SIZE:
+    MaxX = LOWORD(l);
+    MaxY = HIWORD(l);
+    break;
+
+  case WM_DESTROY:
+    PostQuitMessage (0);
+    break;
+
+  default:
+    return DefWindowProc (wnd, msg, w, l);
+  }
+  return 0l;
+}
+
+WPARAM MessageLoop()
+{
+  MSG msg;
+
+  while(1)
+  {
+    Sleep(1); /* sleep 1 millisecond */
+    if(PeekMessage(&msg,0,0,0,PM_REMOVE))
+    {
+      if(msg.message == WM_QUIT) return msg.wParam;
+      TranslateMessage(&msg);
+      DispatchMessage(&msg);
+    }
+    else
+      Idle(NULL);
+  }
+}
+
+int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
+{
+  WNDCLASS class;
+  if(!prev)
+  {
+    class.style = CS_HREDRAW | CS_VREDRAW;
+    class.lpfnWndProc = ProcessAppMsg;
+    class.cbClsExtra = 0;
+    class.cbWndExtra = 0;
+    class.hInstance  = inst;
+    class.hIcon      = 0; /* Draw my own icon */
+    class.hCursor    = LoadCursor (0, IDC_ARROW);
+    class.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
+    class.lpszMenuName = 0;
+    class.lpszClassName = AppName;
+  }
+  if (!RegisterClass (&class)) return -1;
+
+  HWindow=CreateWindowEx(WS_EX_TOPMOST,AppName,WindowName,WS_OVERLAPPEDWINDOW,
+			 CW_USEDEFAULT,CW_USEDEFAULT,WindowWidth,WindowHeight,
+			 0,0,inst,0);
+  memset(&OldSecond,0,sizeof(OldSecond));
+  memset(&OldMinute,0,sizeof(OldMinute));
+  memset(&OldHour,0,sizeof(OldHour));
+  MaxX = WindowWidth;
+  MaxY = WindowHeight;
+
+  ShowWindow (HWindow, show);
+  UpdateWindow (HWindow);
+
+  return MessageLoop();
+}
diff --git a/loader/module.c b/loader/module.c
index 1137f3d..d46529d 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -271,7 +271,9 @@
     close( cachedfd );
     hCachedModule = hModule;
     name = ((LOADEDFILEINFO*)((char*)pModule + pModule->fileinfo))->filename;
-    cachedfd = open( DOS_GetUnixFileName( name ), O_RDONLY );
+    if ((cachedfd = open( DOS_GetUnixFileName( name ), O_RDONLY )) == -1)
+        fprintf( stderr, "MODULE_OpenFile: can't open file '%s' for module "NPFMT"\n",
+                 name, hModule );
     dprintf_module( stddeb, "MODULE_OpenFile: opened '%s' -> %d\n",
                     name, cachedfd );
     return cachedfd;
@@ -457,7 +459,7 @@
 
     hModule = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, size );
     if (!hModule) return (HMODULE)11;  /* invalid exe */
-    FarSetOwner( hModule, hModule );
+    FarSetOwner( hModule, (WORD)(DWORD)hModule );
     pModule = (NE_MODULE *)GlobalLock( hModule );
     memcpy( pModule, &ne_header, sizeof(NE_MODULE) );
     pModule->count = 0;
@@ -666,7 +668,7 @@
  *
  * Return the entry point for a given ordinal.
  */
-DWORD MODULE_GetEntryPoint( HMODULE hModule, WORD ordinal )
+SEGPTR MODULE_GetEntryPoint( HMODULE hModule, WORD ordinal )
 {
     NE_MODULE *pModule;
     WORD curOrdinal = 1;
@@ -706,8 +708,8 @@
     }
 
     if (sel == 0xfe) sel = 0xffff;  /* constant entry */
-    else sel = (WORD)NE_SEG_TABLE(pModule)[sel-1].selector;
-    return MAKELONG( offset, sel );
+    else sel = (WORD)(DWORD)NE_SEG_TABLE(pModule)[sel-1].selector;
+    return (SEGPTR)MAKELONG( offset, sel );
 }
 
 
@@ -884,7 +886,7 @@
 
       /* Free the referenced modules */
 
-    pModRef = NE_MODULE_TABLE( pModule );
+    pModRef = (HMODULE*)NE_MODULE_TABLE( pModule );
     for (i = 0; i < pModule->modref_count; i++, pModRef++)
     {
         FreeModule( *pModRef );
@@ -1268,7 +1270,11 @@
 
       /* Now load the executable file */
 
+#ifdef WINELIB32
+    params.hEnvironment = (HANDLE)GetDOSEnvironment();
+#else
     params.hEnvironment = (HANDLE)SELECTOROF( GetDOSEnvironment() );
+#endif
     params.cmdLine  = (SEGPTR)WIN16_GlobalLock( cmdLineHandle );
     params.showCmd  = (SEGPTR)WIN16_GlobalLock( cmdShowHandle );
     params.reserved = 0;
@@ -1328,7 +1334,7 @@
 
     ret = MODULE_GetEntryPoint( hModule, ordinal );
 
-    dprintf_module( stddeb, "GetProcAddress: returning %08lx\n", ret );
+    dprintf_module( stddeb, "GetProcAddress: returning "SPFMT"\n", ret );
     return (FARPROC)ret;
 }
 
diff --git a/loader/ne_resource.c b/loader/ne_resource.c
index 18fd164..caf1e0d 100644
--- a/loader/ne_resource.c
+++ b/loader/ne_resource.c
@@ -57,7 +57,7 @@
                               pTypeInfo->type_id, pNameInfo->id );
             handle = LoadResource( hModule, 
 				   (HANDLE)((int)pNameInfo - (int)pModule) );
-            for(p = (WORD*)LockResource(handle); *p; p = (WORD *)((char*)p+*p))
+            for(p = (WORD*)LockResource(handle); p && *p; p = (WORD *)((char*)p+*p))
             {
                 dprintf_resource( stddeb,"  type=%04x '%s' id=%04x '%s'\n",
                                   p[1], (char *)(p+3), p[2],
diff --git a/loader/task.c b/loader/task.c
index 345b9f7..e7f2835 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -311,6 +311,7 @@
  * 32-bit entry point for a new task. This function is responsible for
  * setting up the registers and jumping to the 16-bit entry point.
  */
+#ifndef WINELIB
 static void TASK_CallToStart(void)
 {
     int cs_reg, ds_reg, ip_reg;
@@ -357,6 +358,7 @@
     fprintf( stderr, "TASK_CallToStart: Main program returned!\n" );
     TASK_KillCurrentTask( 1 );
 }
+#endif
 
 
 /***********************************************************************
@@ -747,7 +749,6 @@
 
 #ifndef WINELIB
     NE_InitializeDLLs( pTask->hModule );
-#endif
 
     /* Registers on return are:
      * ax     1 if OK, 0 on error
@@ -764,6 +765,7 @@
     ESI_reg(&context) = (DWORD)pTask->hPrevInstance;
     EDI_reg(&context) = (DWORD)pTask->hInstance;
     ES_reg (&context) = (WORD)pTask->hPDB;
+#endif
 
     /* Initialize the local heap */
     if ( pModule->heap_size )
@@ -910,7 +912,7 @@
     if (!thunkaddr) return (FARPROC)0;
     thunk = PTR_SEG_TO_LIN( thunkaddr );
 
-    dprintf_task( stddeb, "MakeProcInstance(%08lx,"NPFMT"): got thunk %08lx\n",
+    dprintf_task( stddeb, "MakeProcInstance("SPFMT","NPFMT"): got thunk "SPFMT"\n",
                   (SEGPTR)func, hInstance, (SEGPTR)thunkaddr );
     
     *thunk++ = 0xb8;    /* movw instance, %ax */
@@ -929,7 +931,7 @@
  */
 void FreeProcInstance( FARPROC func )
 {
-    dprintf_task( stddeb, "FreeProcInstance(%08lx)\n", (SEGPTR)func );
+    dprintf_task( stddeb, "FreeProcInstance("SPFMT")\n", (SEGPTR)func );
     TASK_FreeThunk( hCurrentTask, (SEGPTR)func );
 }
 
diff --git a/memory/global.c b/memory/global.c
index 0689c88..6d540a3 100644
--- a/memory/global.c
+++ b/memory/global.c
@@ -88,7 +88,7 @@
  *
  * Create a global heap block for a fixed range of linear memory.
  */
-HGLOBAL GLOBAL_CreateBlock( WORD flags, void *ptr, DWORD size,
+HGLOBAL GLOBAL_CreateBlock( WORD flags, const void *ptr, DWORD size,
                             HGLOBAL hOwner, BOOL isCode,
                             BOOL is32Bit, BOOL isReadOnly,
 			    SHMDATA *shmdata  )
diff --git a/memory/selector.c b/memory/selector.c
index 5b42003..d6c2db1 100644
--- a/memory/selector.c
+++ b/memory/selector.c
@@ -98,7 +98,7 @@
  *
  * Set the LDT entries for an array of selectors.
  */
-static void SELECTOR_SetEntries( WORD sel, void *base, DWORD size,
+static void SELECTOR_SetEntries( WORD sel, const void *base, DWORD size,
                                  enum seg_type type, BOOL is32bit,
                                  BOOL readonly )
 {
@@ -131,7 +131,7 @@
  *
  * Allocate selectors for a block of linear memory.
  */
-WORD SELECTOR_AllocBlock( void *base, DWORD size, enum seg_type type,
+WORD SELECTOR_AllocBlock( const void *base, DWORD size, enum seg_type type,
                           BOOL is32bit, BOOL readonly )
 {
     WORD sel, count;
@@ -149,7 +149,7 @@
  *
  * Change the size of a block of selectors.
  */
-WORD SELECTOR_ReallocBlock( WORD sel, void *base, DWORD size,
+WORD SELECTOR_ReallocBlock( WORD sel, const void *base, DWORD size,
                             enum seg_type type, BOOL is32bit, BOOL readonly )
 {
     WORD i, oldcount, newcount;
diff --git a/misc/Makefile.in b/misc/Makefile.in
index f4c201e..d6374a5 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -31,13 +31,7 @@
 	winsocket.c \
 	xmalloc.c
 
-all: checkrc $(MODULE).o
-
-checkrc: dummy
-	cd $(TOPSRC)/rc; $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'DEFS=$(DEFS)' 'LANG=$(LANG)'
-
-langclean::
-	$(RM) ole2nls.o
+all: $(MODULE).o
 
 @MAKE_RULES@
 
diff --git a/misc/commdlg.c b/misc/commdlg.c
index d6c8815..d147dde 100644
--- a/misc/commdlg.c
+++ b/misc/commdlg.c
@@ -9,12 +9,11 @@
 #include <string.h>
 #include "win.h"
 #include "user.h"
-#include "global.h"
 #include "message.h"
 #include "commdlg.h"
 #include "dlgs.h"
 #include "selectors.h"
-#include "../rc/sysres.h"
+#include "resource.h"
 #include "dos_fs.h"
 #include "stackframe.h"
 
@@ -72,11 +71,7 @@
         }
         hDlgTmpl = LoadResource( lpofn->hInstance, hResInfo );
     }
-    else hDlgTmpl = GLOBAL_CreateBlock( GMEM_FIXED,
-                                        sysres_DIALOG_OPEN_FILE.bytes,
-                                        sysres_DIALOG_OPEN_FILE.size,
-                                        GetCurrentPDB(), FALSE, FALSE,
-                                        TRUE, NULL );
+    else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_OPEN_FILE );
     if (!hDlgTmpl)
     {
         CommDlgLastError = CDERR_LOADRESFAILURE;
@@ -91,7 +86,7 @@
     if (!(lpofn->Flags & OFN_ENABLETEMPLATEHANDLE))
     {
         if (lpofn->Flags & OFN_ENABLETEMPLATE) FreeResource( hDlgTmpl );
-        else GLOBAL_FreeBlock( hDlgTmpl );
+        else SYSRES_FreeResource( hDlgTmpl );
     }
 
     printf("GetOpenFileName // return lpstrFile='%s' !\n", 
@@ -123,12 +118,7 @@
         }
         hDlgTmpl = LoadResource( lpofn->hInstance, hResInfo );
     }
-    else hDlgTmpl = GLOBAL_CreateBlock( GMEM_FIXED,
-                                        sysres_DIALOG_SAVE_FILE.bytes,
-                                        sysres_DIALOG_SAVE_FILE.size,
-                                        GetCurrentPDB(), FALSE, FALSE,
-                                        TRUE, NULL );
-
+    else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_SAVE_FILE );
 
     hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
     bRet = DialogBoxIndirectParam( hInst, hDlgTmpl, lpofn->hwndOwner,
@@ -137,7 +127,7 @@
     if (!(lpofn->Flags & OFN_ENABLETEMPLATEHANDLE))
     {
         if (lpofn->Flags & OFN_ENABLETEMPLATE) FreeResource( hDlgTmpl );
-        else GLOBAL_FreeBlock( hDlgTmpl );
+        else SYSRES_FreeResource( hDlgTmpl );
     }
 
     printf( "GetSaveFileName // return lpstrFile='%s' !\n", 
@@ -153,7 +143,7 @@
 {
     char temp[512], *cp;
 
-    SendDlgItemMessage(hwnd, edt1, WM_GETTEXT, 511, MAKE_SEGPTR(temp));
+    SendDlgItemMessage(hwnd, edt1, WM_GETTEXT, 511, (LPARAM)MAKE_SEGPTR(temp));
     cp = strrchr(temp, '\\');
     if (cp != NULL) {
 	strcpy(temp, cp+1);
@@ -172,7 +162,7 @@
   char str[512],str2[512];
 
   strncpy(str,newPath,511); str[511]=0;
-  SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 511, MAKE_SEGPTR(str2));
+  SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 511, (LPARAM)MAKE_SEGPTR(str2));
   strncat(str,str2,511-strlen(str)); str[511]=0;
   if (!DlgDirList(hWnd, str, lst1, 0, 0x0000)) return FALSE;
   DlgDirList(hWnd, "*.*", lst2, stc1, 0x8010);
@@ -225,7 +215,7 @@
 	SelectObject(lpdis->hDC, hBrush);
 	FillRect(lpdis->hDC, &lpdis->rcItem, hBrush);
 	SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, 
-		    MAKE_SEGPTR(str));
+		    (LPARAM)MAKE_SEGPTR(str));
 	TextOut(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
 		str, strlen(str));
 	if (lpdis->itemState != 0) {
@@ -239,7 +229,7 @@
 	SelectObject(lpdis->hDC, hBrush);
 	FillRect(lpdis->hDC, &lpdis->rcItem, hBrush);
 	SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, 
-		    MAKE_SEGPTR(str));
+		    (LPARAM)MAKE_SEGPTR(str));
 
 	hBitmap = hFolder;
 	GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
@@ -261,7 +251,7 @@
 	SelectObject(lpdis->hDC, hBrush);
 	FillRect(lpdis->hDC, &lpdis->rcItem, hBrush);
 	SendMessage(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, 
-		    MAKE_SEGPTR(str));
+		    (LPARAM)MAKE_SEGPTR(str));
 	switch(str[2]) {
 	 case 'a': case 'b':
 	    hBitmap = hFloppy;
@@ -323,7 +313,7 @@
 	  n = strlen(pstr);
 	  strncpy(tmpstr, pstr, 511); tmpstr[511]=0;
 	  printf("lpstrCustomFilter // add tmpstr='%s' ", tmpstr);
-	  SendDlgItemMessage(hWnd, cmb1, CB_ADDSTRING, 0, MAKE_SEGPTR(tmpstr));
+	  SendDlgItemMessage(hWnd, cmb1, CB_ADDSTRING, 0, (LPARAM)MAKE_SEGPTR(tmpstr));
 	  pstr += n + 1;
 	  n = strlen(pstr);
 	  printf("associated to '%s'\n", pstr);
@@ -337,7 +327,7 @@
       n = strlen(pstr);
       strncpy(tmpstr, pstr, 511); tmpstr[511]=0;
       printf("lpstrFilter // add tmpstr='%s' ", tmpstr);
-      SendDlgItemMessage(hWnd, cmb1, CB_ADDSTRING, 0, MAKE_SEGPTR(tmpstr));
+      SendDlgItemMessage(hWnd, cmb1, CB_ADDSTRING, 0, (LPARAM)MAKE_SEGPTR(tmpstr));
       pstr += n + 1;
       n = strlen(pstr);
       printf("associated to '%s'\n", pstr);
@@ -352,7 +342,7 @@
   tmpstr[511]=0;
   printf("nFilterIndex = %ld // SetText of edt1 to '%s'\n", 
   			lpofn->nFilterIndex, tmpstr);
-  SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr));
+  SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (LPARAM)MAKE_SEGPTR(tmpstr));
   /* get drive list */
   *tmpstr = 0;
   DlgDirListComboBox(hWnd, MAKE_SEGPTR(tmpstr), cmb2, 0, 0xC000);
@@ -399,8 +389,8 @@
       lRet = SendDlgItemMessage(hWnd, lst1, LB_GETCURSEL, 0, 0);
       if (lRet == LB_ERR) return TRUE;
       SendDlgItemMessage(hWnd, lst1, LB_GETTEXT, lRet,
-			 MAKE_SEGPTR(tmpstr));
-      SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr));
+			 (LPARAM)MAKE_SEGPTR(tmpstr));
+      SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (LPARAM)MAKE_SEGPTR(tmpstr));
       return TRUE;
     case lst2: /* directory list */
       FILEDLG_StripEditControl(hWnd);
@@ -409,7 +399,7 @@
 	  lRet = SendDlgItemMessage(hWnd, lst2, LB_GETCURSEL, 0, 0);
 	  if (lRet == LB_ERR) return TRUE;
 	  SendDlgItemMessage(hWnd, lst2, LB_GETTEXT, lRet,
-			     MAKE_SEGPTR(tmpstr));
+			     (LPARAM)MAKE_SEGPTR(tmpstr));
 	  if (tmpstr[0] == '[')
 	    {
 	      tmpstr[strlen(tmpstr) - 1] = 0;
@@ -430,7 +420,7 @@
       FILEDLG_StripEditControl(hWnd);
       lRet = SendDlgItemMessage(hWnd, cmb2, CB_GETCURSEL, 0, 0L);
       if (lRet == LB_ERR) return 0;
-      SendDlgItemMessage(hWnd, cmb2, CB_GETLBTEXT, lRet, MAKE_SEGPTR(tmpstr));
+      SendDlgItemMessage(hWnd, cmb2, CB_GETLBTEXT, lRet, (LPARAM)MAKE_SEGPTR(tmpstr));
       sprintf(tmpstr, "%c:", tmpstr[2]);
     reset_scan:
       lRet = SendDlgItemMessage(hWnd, cmb1, CB_GETCURSEL, 0, 0);
@@ -440,7 +430,7 @@
 				 PTR_SEG_TO_LIN(lpofn->lpstrFilter),
 				 lRet);
       strncpy(tmpstr2, pstr, 511); tmpstr2[511]=0;
-      SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr2));
+      SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (LPARAM)MAKE_SEGPTR(tmpstr2));
       FILEDLG_ScanDir(hWnd, tmpstr);
       return TRUE;
     case chx1:
@@ -449,7 +439,7 @@
       return TRUE;
     case IDOK:
     almost_ok:
-      SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 511, MAKE_SEGPTR(tmpstr));
+      SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 511, (LPARAM)MAKE_SEGPTR(tmpstr));
       pstr = strrchr(tmpstr, '\\');
       if (pstr == NULL)
 	pstr = strrchr(tmpstr, ':');
@@ -467,7 +457,7 @@
 	      *tmpstr=0;
 	    }
 	  printf("commdlg: %s, %s\n", tmpstr, tmpstr2);
-	  SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr2));
+	  SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (LPARAM)MAKE_SEGPTR(tmpstr2));
 	  FILEDLG_ScanDir(hWnd, tmpstr);
 	  return TRUE;
 	}
@@ -485,7 +475,7 @@
 				 PTR_SEG_TO_LIN(lpofn->lpstrFilter),
 				 lRet), 511);
       tmpstr2[511]=0;
-      SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr2));
+      SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (LPARAM)MAKE_SEGPTR(tmpstr2));
       /* if ScanDir succeeds, we have changed the directory */
       if (FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
       /* if not, this must be a filename */
@@ -495,13 +485,13 @@
 	  /* strip off the pathname */
 	  *pstr = 0;
 	  strncpy(tmpstr2, pstr+1, 511); tmpstr2[511]=0;
-	  SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr2));
+	  SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (LPARAM)MAKE_SEGPTR(tmpstr2));
 	  /* Should we MessageBox() if this fails? */
 	  if (!FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
 	  strcpy(tmpstr, tmpstr2);
 	}
       else 
-	SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr));
+	SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (LPARAM)MAKE_SEGPTR(tmpstr));
       ShowWindow(hWnd, SW_HIDE);
       {
 	int drive;
@@ -527,7 +517,7 @@
 	{
 	  lRet = SendDlgItemMessage(hWnd, lst1, LB_GETCURSEL, 0, 0);
 	  SendDlgItemMessage(hWnd, lst1, LB_GETTEXT, lRet,
-			     MAKE_SEGPTR(tmpstr));
+			     (LPARAM)MAKE_SEGPTR(tmpstr));
           printf("strcpy'ing '%s'\n",tmpstr); fflush(stdout);
 	  strcpy(PTR_SEG_TO_LIN(lpofn->lpstrFileTitle), tmpstr);
 	}
@@ -621,14 +611,12 @@
     HANDLE hInst, hDlgTmpl;
     BOOL bRet;
 
-    hDlgTmpl = GLOBAL_CreateBlock(GMEM_FIXED, sysres_DIALOG_CHOOSE_COLOR.bytes,
-                                  sysres_DIALOG_CHOOSE_COLOR.size,
-                                  GetCurrentPDB(), FALSE, FALSE, TRUE, NULL );
+    hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_CHOOSE_COLOR );
     hInst = WIN_GetWindowInstance( lpChCol->hwndOwner );
     bRet = DialogBoxIndirectParam( hInst, hDlgTmpl, lpChCol->hwndOwner,
                                    GetWndProcEntry16("ColorDlgProc"), 
                                    (DWORD)lpChCol );
-    GLOBAL_FreeBlock( hDlgTmpl );
+    SYSRES_FreeResource( hDlgTmpl );
     return bRet;
 }
 
@@ -668,14 +656,12 @@
     HANDLE hInst, hDlgTmpl;
     BOOL bRet;
 
-    hDlgTmpl = GLOBAL_CreateBlock(GMEM_FIXED, sysres_DIALOG_FIND_TEXT.bytes,
-                                  sysres_DIALOG_FIND_TEXT.size,
-                                  GetCurrentPDB(), FALSE, FALSE, TRUE, NULL );
+    hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_FIND_TEXT );
     hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
     bRet = DialogBoxIndirectParam( hInst, hDlgTmpl, lpFind->hwndOwner,
                                    GetWndProcEntry16("FindTextDlgProc"), 
                                    (DWORD)lpFind );
-    GLOBAL_FreeBlock( hDlgTmpl );
+    SYSRES_FreeResource( hDlgTmpl );
     return bRet;
 }
 
@@ -688,14 +674,12 @@
     HANDLE hInst, hDlgTmpl;
     BOOL bRet;
 
-    hDlgTmpl = GLOBAL_CreateBlock(GMEM_FIXED, sysres_DIALOG_REPLACE_TEXT.bytes,
-                                  sysres_DIALOG_REPLACE_TEXT.size,
-                                  GetCurrentPDB(), FALSE, FALSE, TRUE, NULL );
+    hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_REPLACE_TEXT );
     hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
     bRet = DialogBoxIndirectParam( hInst, hDlgTmpl, lpFind->hwndOwner,
                                    GetWndProcEntry16("ReplaceTextDlgProc"), 
                                    (DWORD)lpFind );
-    GLOBAL_FreeBlock( hDlgTmpl );
+    SYSRES_FreeResource( hDlgTmpl );
     return bRet;
 }
 
@@ -769,16 +753,9 @@
         return TRUE;
 
     if (lpPrint->Flags & PD_PRINTSETUP)
-        hDlgTmpl = GLOBAL_CreateBlock( GMEM_FIXED,
-                                       sysres_DIALOG_PRINT_SETUP.bytes,
-                                       sysres_DIALOG_PRINT_SETUP.size,
-                                       GetCurrentPDB(), FALSE,
-                                       FALSE, TRUE, NULL );
+	hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_PRINT_SETUP );
     else
-        hDlgTmpl = GLOBAL_CreateBlock( GMEM_FIXED, sysres_DIALOG_PRINT.bytes,
-                                       sysres_DIALOG_PRINT.size,
-                                       GetCurrentPDB(), FALSE,
-                                       FALSE, TRUE, NULL );
+	hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_PRINT );
 
     hInst = WIN_GetWindowInstance( lpPrint->hwndOwner );
     bRet = DialogBoxIndirectParam( hInst, hDlgTmpl, lpPrint->hwndOwner,
@@ -786,7 +763,7 @@
                                        GetWndProcEntry16("PrintSetupDlgProc") :
                                        GetWndProcEntry16("PrintDlgProc"),
                                    (DWORD)lpPrint );
-    GLOBAL_FreeBlock( hDlgTmpl );
+    SYSRES_FreeResource( hDlgTmpl );
     return bRet;
 }
 
@@ -845,9 +822,9 @@
 
 
 /***********************************************************************
- *           CommDlgExtendError   (COMMDLG.26)
+ *           CommDlgExtendedError   (COMMDLG.26)
  */
-DWORD CommDlgExtendError(void)
+DWORD CommDlgExtendedError(void)
 {
   return CommDlgLastError;
 }
@@ -856,7 +833,7 @@
 /***********************************************************************
  *           GetFileTitle   (COMMDLG.27)
  */
-int GetFileTitle(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
+short GetFileTitle(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
 {
     int i, len;
     printf("GetFileTitle(%p %p %d); \n", lpFile, lpTitle, cbBuf);
@@ -879,7 +856,7 @@
     printf("\n---> '%s' ", &lpFile[i]);
     
     len = strlen(lpFile+i)+1;
-    if (cbBuf < len);
+    if (cbBuf < len)
     	return len;
 
     strncpy(lpTitle, &lpFile[i], len);
diff --git a/misc/dos_fs.c b/misc/dos_fs.c
index 0d88d8f..6235df6 100644
--- a/misc/dos_fs.c
+++ b/misc/dos_fs.c
@@ -453,7 +453,7 @@
     } else {
 	/* Expand it if it's a relative name. */
 	getcwd(temp, 255);
-	if(strncmp(unixfilename, "./", 2) != 0) {
+	if(strncmp(unixfilename, "./", 2) == 0) {
 	    strcat(temp, unixfilename + 1);
 	} else {	    
 	    strcat(temp, "/");
@@ -934,20 +934,20 @@
 	    strcpy(de->filename, d->d_name);
 	    if (d->d_reclen > 12)
 	    de->filename[12] = '\0';
-
 	    ToDos(de->filename);
-	} while ( !match(de->filename, de->filemask) );
 
-	strcpy(temp,de->unixpath);
-	strcat(temp,"/");
-	strcat(temp,de->filename);
-	ToUnix(temp + strlen(de->unixpath));
+	    strcpy(temp,de->unixpath);
+	    strcat(temp,"/");
+	    strcat(temp,d->d_name);
+	    stat (temp, &st);
+	    de->attribute = 0x0;
+	    if S_ISDIR(st.st_mode)
+	      de->attribute |= FA_DIREC;
 
-	stat (temp, &st);
-	de->attribute = 0x0;
-	if S_ISDIR(st.st_mode)
-		de->attribute |= FA_DIREC;
-	
+	} while (!(de->attribute & FA_DIREC) &&
+		 !match(de->filename, de->filemask) );
+
+
 	de->filesize = st.st_size;
 	de->filetime = st.st_mtime;
 
diff --git a/misc/exec.c b/misc/exec.c
index ab5bc0e..1235661 100644
--- a/misc/exec.c
+++ b/misc/exec.c
@@ -57,12 +57,13 @@
 	case 0:
 	case HELP_HELPONHELP:
 		GetWindowsDirectory(str, sizeof(str));
-		strcat(str, "\\winhelp.exe");
+		strcat(str, "\\winhelp.exe winhelp.hlp");
         dprintf_exec(stddeb,"'%s'\n", str);
 		break;
 	case HELP_INDEX:
 		GetWindowsDirectory(str, sizeof(str));
-		strcat(str, "\\winhelp.exe");
+		strcat(str, "\\winhelp.exe ");
+		strcat(str, lpHelpFile);
         dprintf_exec(stddeb,"'%s'\n", str);
 		break;
 	default:
diff --git a/misc/ole2nls.c b/misc/ole2nls.c
index 0a20cf9..b02fe65a 100644
--- a/misc/ole2nls.c
+++ b/misc/ole2nls.c
@@ -10,6 +10,7 @@
 #include <string.h>
 #include "windows.h"
 #include "ole.h"
+#include "options.h"
 #include "winnls.h"
 #include "stddebug.h"
 #include "debug.h"
@@ -20,20 +21,18 @@
 DWORD WINAPI GetUserDefaultLCID()
 {
 /* Default sorting, neutral sublanguage */
-#if #LANG(En)
-	return 9;
-#elif #LANG(De)
-	return 7;
-#elif #LANG(Es)
-	return 7; /* Just a Guess :-) */
-#elif #LANG(Fr)
-	return 7; /* ditto :-) */
-#elif #LANG(No)
-	return 0x14;
-#else
-	/* Neutral language */
-	return 0;
-#endif
+    switch(Options.language)
+    {
+    case LANG_En: return 0x09;
+    case LANG_Es: return 0x07; /* Just a Guess :-) */
+    case LANG_De: return 0x07;
+    case LANG_No: return 0x14;
+    case LANG_Fr:
+    case LANG_Fi:
+    case LANG_Da:
+    default:
+	return 0;  /* Neutral language */
+    }
 }
 
 /***********************************************************************
@@ -192,7 +191,9 @@
 
 /* Now, the language specific definitions. They don't have to be
    complete */
-#if #LANG(De)
+    switch(Options.language)
+    {
+    case LANG_De:
 /* This definitions apply to Germany only. Users in Austria 
    or Switzerland might want to modify them */
 LOCVAL(LOCALE_ILANGUAGE,"9")
@@ -315,9 +316,9 @@
 LOCVAL(LOCALE_INEGSYMPRECEDES)
 LOCVAL(LOCALE_INEGSEPBYSPACE)
 */
-#endif /* LANG(De) */
+    break;  /* LANG(De) */
 
-#if #LANG(Da)
+    case LANG_Da:
 /* LOCVAL(LOCALE_ILANGUAGE,"9") */
 LOCVAL(LOCALE_SLANGUAGE,"Dansk")
 LOCVAL(LOCALE_SENGLANGUAGE,"Danish")
@@ -417,11 +418,13 @@
 /* LOCVAL(LOCALE_IPOSSEPBYSPACE) */
 /* LOCVAL(LOCALE_INEGSYMPRECEDES) */
 /* LOCVAL(LOCALE_INEGSEPBYSPACE) */
-#endif /* LANG(Da) */
+    break; /* LANG(Da) */
 
 /*Insert other languages here*/
 
-
+    default:
+	break;
+    }  /* switch */
 
 	if(!retLen)
 	{
diff --git a/misc/profile.c b/misc/profile.c
index 043eb28..ecd1b72 100644
--- a/misc/profile.c
+++ b/misc/profile.c
@@ -74,13 +74,13 @@
 	if (strchr(name, '/'))
 		return name;
 
-	if (strchr(name, '\\'))
-		return DOS_GetUnixFileName(name);
-
+        if (strlen(dir)) {
         strcpy(temp, dir);
         strcat(temp, "\\");
 	strcat(temp, name);
-	
+	}
+	else
+	  strcpy(temp, name);
 	return DOS_GetUnixFileName(temp);
 }
 
@@ -92,23 +92,37 @@
     char *bufptr;
     char *lastnonspc;
     int bufsize;
-    char *file;
+    char *file, *purefilename;
     int c;
     char path[MAX_PATH+1];
     BOOL firstbrace;
     
     *pfullname = NULL;
 
-    /* Try the Windows directory */
+    dprintf_profile(stddeb,"Trying to load file %s \n", filename);
 
-    GetWindowsDirectory(path, sizeof(path));
-    file = GetIniFileName(filename, path);
-
-    dprintf_profile(stddeb,"Load %s\n", file);
+    /* First try it as is */
+    file = GetIniFileName(filename, "");
     f = fopen(file, "r");
     
     if (f == NULL) {
-	/* Try the path of the current executable */
+
+      if  ((purefilename = strrchr( filename, '\\' )))
+	purefilename++; 
+      else if  ((purefilename = strrchr( filename, '/' ))) 
+	purefilename++; 
+      else
+	purefilename = filename;
+      ToUnix(purefilename);
+
+      /* Now try the Windows directory */
+      GetWindowsDirectory(path, sizeof(path));
+      file = GetIniFileName(purefilename, path);
+      dprintf_profile(stddeb,"Trying to load  in windows directory file %s\n",
+		      file);
+      f = fopen(file, "r");
+    
+      if (f == NULL) { 	/* Try the path of the current executable */
     
 	if (GetCurrentTask())
 	{
@@ -116,16 +130,37 @@
 	    GetModuleFileName( GetCurrentTask(), path, MAX_PATH );
 	    if ((p = strrchr( path, '\\' )))
 	    {
-		p[1] = '\0';
-		file = GetIniFileName(filename, path);
+		p[0] = '\0'; /* Remove trailing slash */
+		file = GetIniFileName(purefilename, path);
+		dprintf_profile(stddeb,
+				"Trying to load in current directory%s\n",
+				file);
 		f = fopen(file, "r");
 	    }
 	}
     }
+      if (f == NULL) { 	/* And now in $HOME/.wine */
+	
+	strcpy(file,getenv("HOME"));
+	strcat(file, "/.wine/");
+	strcat(file, purefilename);
+	dprintf_profile(stddeb,"Trying to load in user-directory %s\n", file);
+	f = fopen(file, "r");
+      }
+      
+      if (f == NULL) {
+	/* FIXED: we ought to create it now (in which directory?) */
+	/* lets do it in ~/.wine */
+	strcpy(file,getenv("HOME"));
+	strcat(file, "/.wine/");
+	strcat(file, purefilename);
+	dprintf_profile(stddeb,"Creating %s\n", file);
+	f = fopen(file, "w+");
     if (f == NULL) {
 	fprintf(stderr, "profile.c: load() can't find file %s\n", filename);
-        /* FIXME: we ought to create it now (in which directory?) */
 	return NULL;
+	}
+      }
     }
     
     *pfullname = strdup(file);
@@ -206,7 +241,7 @@
 	    skipspc = TRUE;
 	    do {
 		c = fgetc(f);
-		if (c == EOF || c == '\n' || c == ';') break;
+		if (c == EOF || c == '\n') break;
 		if (!isspace(c) || !skipspc) {
 		    skipspc = FALSE;
 		    bufsize++;
diff --git a/misc/shell.c b/misc/shell.c
index 5e1911c..5e50505 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -8,12 +8,11 @@
 #include <ctype.h>
 #include "windows.h"
 #include "shell.h"
-#include "global.h"
 #include "neexe.h"
 #include "selectors.h"
 #include "alias.h"
 #include "relay32.h"
-#include "../rc/sysres.h"
+#include "resource.h"
 #include "dlgs.h"
 #include "win.h"
 #include "stddebug.h"
@@ -224,7 +223,7 @@
 
 	dprintf_reg(stddeb, "RegOpenKey(%08lX, %p='%s', %p)\n",
 				       (DWORD)hKey, lpSubKey, lpSubKey, lphKey);
-	if (lphKey == NULL) return ERROR_INVALID_PARAMETER;
+	if (lphKey == NULL) return SHELL_ERROR_INVALID_PARAMETER;
         switch((DWORD)hKey) {
 	case 0: 
 	  lpKey = lphTopKey; break;
@@ -237,7 +236,7 @@
         }
 	if (lpSubKey == NULL || !*lpSubKey)  { 
 	  *lphKey = hKey; 
-	  return ERROR_SUCCESS; 
+	  return SHELL_ERROR_SUCCESS; 
 	}
         while(*lpSubKey) {
           ptr = strchr(lpSubKey,'\\');
@@ -254,11 +253,11 @@
           }
           if (lpKey == NULL) {
 	    dprintf_reg(stddeb,"RegOpenKey: key %s not found!\n",str);
-	    return ERROR_BADKEY;
+	    return SHELL_ERROR_BADKEY;
 	  }	    
 	}
         *lphKey = lpKey->hKey;
-	return ERROR_SUCCESS;
+	return SHELL_ERROR_SUCCESS;
 }
 
 
@@ -275,7 +274,7 @@
 	char		str[128];
 
 	dprintf_reg(stddeb, "RegCreateKey(%08lX, '%s', %p)\n",	(DWORD)hKey, lpSubKey, lphKey);
-	if (lphKey == NULL) return ERROR_INVALID_PARAMETER;
+	if (lphKey == NULL) return SHELL_ERROR_INVALID_PARAMETER;
         switch((DWORD)hKey) {
 	case 0: 
 	  lpKey = lphTopKey; break;
@@ -288,7 +287,7 @@
         }
 	if (lpSubKey == NULL || !*lpSubKey)  { 
 	  *lphKey = hKey; 
-	  return ERROR_SUCCESS;
+	  return SHELL_ERROR_SUCCESS;
 	}
         while (*lpSubKey) {
           dprintf_reg(stddeb, "RegCreateKey: Looking for subkey %s\n", lpSubKey);
@@ -309,13 +308,13 @@
 	    lpNewKey = (LPKEYSTRUCT) GlobalLock(hNewKey);
 	    if (lpNewKey == NULL) {
 	      printf("RegCreateKey // Can't alloc new key !\n");
-	      return ERROR_OUTOFMEMORY;
+	      return SHELL_ERROR_OUTOFMEMORY;
 	    }
 	    lpNewKey->hKey = hNewKey;
 	    lpNewKey->lpSubKey = malloc(strlen(str) + 1);
 	    if (lpNewKey->lpSubKey == NULL) {
 	      printf("RegCreateKey // Can't alloc key string !\n");
-	      return ERROR_OUTOFMEMORY;
+	      return SHELL_ERROR_OUTOFMEMORY;
 	    }
 	    strcpy(lpNewKey->lpSubKey, str);
 	    lpNewKey->lpNextKey = lpPrevKey->lpSubLvl;
@@ -333,7 +332,7 @@
 	    dprintf_reg(stddeb,"RegCreateKey // found '%s', key=%08lX\n", str, (DWORD)*lphKey);
 	  }
 	}
-	return ERROR_SUCCESS;
+	return SHELL_ERROR_SUCCESS;
 }
 
 
@@ -343,7 +342,7 @@
 LONG RegCloseKey(HKEY hKey)
 {
 	dprintf_reg(stdnimp, "EMPTY STUB !!! RegCloseKey(%08lX);\n", (DWORD)hKey);
-	return ERROR_SUCCESS;
+	return SHELL_ERROR_SUCCESS;
 }
 
 
@@ -354,7 +353,7 @@
 {
 	dprintf_reg(stdnimp, "EMPTY STUB !!! RegDeleteKey(%08lX, '%s');\n",
                      (DWORD)hKey, lpSubKey);
-	return ERROR_SUCCESS;
+	return SHELL_ERROR_SUCCESS;
 }
 
 
@@ -369,22 +368,22 @@
     LONG       	dwRet;
     dprintf_reg(stddeb, "RegSetValue(%08lX, '%s', %08lX, '%s', %08lX);\n",
 		(DWORD)hKey, lpSubKey, dwType, lpVal, dwIgnored);
-    /*if (lpSubKey == NULL) return ERROR_INVALID_PARAMETER;*/
-    if (lpVal == NULL) return ERROR_INVALID_PARAMETER;
-    if ((dwRet = RegOpenKey(hKey, lpSubKey, &hRetKey)) != ERROR_SUCCESS) {
+    /*if (lpSubKey == NULL) return SHELL_ERROR_INVALID_PARAMETER;*/
+    if (lpVal == NULL) return SHELL_ERROR_INVALID_PARAMETER;
+    if ((dwRet = RegOpenKey(hKey, lpSubKey, &hRetKey)) != SHELL_ERROR_SUCCESS) {
 	dprintf_reg(stddeb, "RegSetValue // key not found ... so create it !\n");
-	if ((dwRet = RegCreateKey(hKey, lpSubKey, &hRetKey)) != ERROR_SUCCESS) {
+	if ((dwRet = RegCreateKey(hKey, lpSubKey, &hRetKey)) != SHELL_ERROR_SUCCESS) {
 	    fprintf(stderr, "RegSetValue // key creation error %08lX !\n", dwRet);
 	    return dwRet;
 	}
     }
     lpKey = (LPKEYSTRUCT)GlobalLock(hRetKey);
-    if (lpKey == NULL) return ERROR_BADKEY;
+    if (lpKey == NULL) return SHELL_ERROR_BADKEY;
     if (lpKey->lpValue != NULL) free(lpKey->lpValue);
     lpKey->lpValue = xmalloc(strlen(lpVal) + 1);
     strcpy(lpKey->lpValue, lpVal);
     dprintf_reg(stddeb,"RegSetValue // successful key='%s' val='%s' !\n", lpSubKey, lpKey->lpValue);
-    return ERROR_SUCCESS;
+    return SHELL_ERROR_SUCCESS;
 }
 
 
@@ -400,16 +399,16 @@
 	dprintf_reg(stddeb, "RegQueryValue(%08lX, '%s', %p, %p);\n",
                     (DWORD)hKey, lpSubKey, lpVal, lpcb);
 	/*if (lpSubKey == NULL) return ERROR_INVALID_PARAMETER;*/
-	if (lpVal == NULL) return ERROR_INVALID_PARAMETER;
-	if (lpcb == NULL) return ERROR_INVALID_PARAMETER;
-        if (!*lpcb) return ERROR_INVALID_PARAMETER;
+	if (lpVal == NULL) return SHELL_ERROR_INVALID_PARAMETER;
+	if (lpcb == NULL) return SHELL_ERROR_INVALID_PARAMETER;
+        if (!*lpcb) return SHELL_ERROR_INVALID_PARAMETER;
 
-	if ((dwRet = RegOpenKey(hKey, lpSubKey, &hRetKey)) != ERROR_SUCCESS) {
+	if ((dwRet = RegOpenKey(hKey, lpSubKey, &hRetKey)) != SHELL_ERROR_SUCCESS) {
 		fprintf(stderr, "RegQueryValue // key not found !\n");
 		return dwRet;
 	}
 	lpKey = (LPKEYSTRUCT)GlobalLock(hRetKey);
-	if (lpKey == NULL) return ERROR_BADKEY;
+	if (lpKey == NULL) return SHELL_ERROR_BADKEY;
 	if (lpKey->lpValue != NULL) {
           if ((size = strlen(lpKey->lpValue)+1) > *lpcb){
             strncpy(lpVal,lpKey->lpValue,*lpcb-1);
@@ -423,7 +422,7 @@
 	  *lpcb = (LONG)1;
 	}
 	dprintf_reg(stddeb,"RegQueryValue // return '%s' !\n", lpVal);
-	return ERROR_SUCCESS;
+	return SHELL_ERROR_SUCCESS;
 }
 
 
@@ -436,7 +435,7 @@
 	LONG            len;
 
 	dprintf_reg(stddeb, "RegEnumKey(%08lX, %ld)\n", (DWORD)hKey, dwSubKey);
-	if (lpBuf == NULL) return ERROR_INVALID_PARAMETER;
+	if (lpBuf == NULL) return SHELL_ERROR_INVALID_PARAMETER;
         switch((DWORD)hKey) {
 	case 0: 
 	  lpKey = lphTopKey; break;
@@ -454,13 +453,13 @@
 	    strncpy(lpBuf,lpKey->lpSubKey,len);
 	    lpBuf[len] = 0;
             dprintf_reg(stddeb, "RegEnumKey: found %s\n",lpBuf);
-	    return ERROR_SUCCESS;
+	    return SHELL_ERROR_SUCCESS;
 	  }
           dwSubKey--;
           lpKey = lpKey->lpNextKey;
         }
 	dprintf_reg(stddeb, "RegEnumKey: key not found!\n");
-	return ERROR_INVALID_PARAMETER;
+	return SHELL_ERROR_INVALID_PARAMETER;
 }
 
 
@@ -584,7 +583,7 @@
       }
     } else {
       len=200;
-      if (RegQueryValue((HKEY)HKEY_CLASSES_ROOT,p,subclass,&len)==ERROR_SUCCESS) {
+      if (RegQueryValue((HKEY)HKEY_CLASSES_ROOT,p,subclass,&len)==SHELL_ERROR_SUCCESS) {
 	if (len>20)
 	  fprintf(stddeb,"ShellExecute:subclass with len %ld? (%s), please report.\n",len,subclass);
 	subclass[len]='\0';
@@ -593,7 +592,7 @@
 	strcat(subclass,"\\command");
 	dprintf_exec(stddeb,"ShellExecute:looking for %s.\n",subclass);
 	len=400;
-	if (RegQueryValue((HKEY)HKEY_CLASSES_ROOT,subclass,cmd,&len)==ERROR_SUCCESS) {
+	if (RegQueryValue((HKEY)HKEY_CLASSES_ROOT,subclass,cmd,&len)==SHELL_ERROR_SUCCESS) {
 	  char *t;
 	  dprintf_exec(stddeb,"ShellExecute:...got %s\n",cmd);
 	  cmd[len]='\0';
@@ -701,17 +700,13 @@
         initialized=1;
     }
 
-    handle = GLOBAL_CreateBlock( GMEM_FIXED,
-                                 sysres_DIALOG_SHELL_ABOUT_MSGBOX.bytes,
-                                 sysres_DIALOG_SHELL_ABOUT_MSGBOX.size,
-                                 GetCurrentPDB(), FALSE, FALSE,
-                                 TRUE, NULL );
+    handle = SYSRES_LoadResource( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX );
     if (!handle) return FALSE;
     bRet = DialogBoxIndirectParam( WIN_GetWindowInstance( hWnd ),
                                    handle, hWnd,
                                    GetWndProcEntry16("AboutDlgProc"), 
 				   (LONG)hIcon );
-    GLOBAL_FreeBlock( handle );
+    SYSRES_FreeResource( handle );
     return bRet;
 }
 
diff --git a/misc/user32.c b/misc/user32.c
index a9ce9af..5deaa83 100644
--- a/misc/user32.c
+++ b/misc/user32.c
@@ -158,5 +158,5 @@
     return (DWORD) CreateWindowEx(flags,MAKE_SEGPTR(classbuf),
 				  MAKE_SEGPTR(titlebuf),style,x,y,width,height,
 				  (HWND)parent,(HMENU)menu,(HINSTANCE)instance,
-				  param);
+				  (LPVOID)param);
 }
diff --git a/miscemu/dpmi.c b/miscemu/dpmi.c
index 7389396..1ba8f1a 100644
--- a/miscemu/dpmi.c
+++ b/miscemu/dpmi.c
@@ -17,6 +17,28 @@
 #include "debug.h"
 
 
+/* Structure for real-mode callbacks */
+typedef struct
+{
+    DWORD edi;
+    DWORD esi;
+    DWORD ebp;
+    DWORD reserved;
+    DWORD ebx;
+    DWORD edx;
+    DWORD ecx;
+    DWORD eax;
+    WORD  flags;
+    WORD  es;
+    WORD  ds;
+    WORD  fs;
+    WORD  gs;
+    WORD  ip;
+    WORD  cs;
+    WORD  sp;
+    WORD  ss;
+} REALMODECALL;
+
 /**********************************************************************
  *	    INT_Int31Handler
  *
@@ -132,13 +154,39 @@
         *  ES:DI points to real-mode call structure  
         *  Currently we just print it out and return error.
         */
-        ptr = (BYTE *)PTR_SEG_OFF_TO_LIN( ES_reg(&context), DI_reg(&context) );
-        fprintf(stdnimp,
-               "RealModeInt %02x: AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x DS=%04x\n",
-                BL_reg(&context),
-              *(WORD*)(ptr+0x1c),*(WORD*)(ptr+0x10),*(WORD*)(ptr+0x18),*(WORD*)(ptr+0x14),
-              *(WORD*)(ptr+0x04),*(WORD*)(ptr+0x00),*(WORD*)(ptr+0x22),*(WORD*)(ptr+0x24));
-        SET_CFLAG(&context);
+        {
+            REALMODECALL *p = (REALMODECALL *)PTR_SEG_OFF_TO_LIN( ES_reg(&context), DI_reg(&context) );
+            fprintf(stdnimp,
+                    "RealModeInt %02x: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n"
+                    "                ESI=%08lx EDI=%08lx ES=%04x DS=%04x\n",
+                    BL_reg(&context), p->eax, p->ebx, p->ecx, p->edx,
+                    p->esi, p->edi, p->es, p->ds );
+            SET_CFLAG(&context);
+        }
+        break;
+
+    case 0x0301:  /* Call real mode procedure with far return */
+        {
+            REALMODECALL *p = (REALMODECALL *)PTR_SEG_OFF_TO_LIN( ES_reg(&context), DI_reg(&context) );
+            fprintf(stdnimp,
+                    "RealModeCall: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n"
+                    "              ESI=%08lx EDI=%08lx ES=%04x DS=%04x CS:IP=%04x:%04x\n",
+                    p->eax, p->ebx, p->ecx, p->edx,
+                    p->esi, p->edi, p->es, p->ds, p->cs, p->ip );
+            SET_CFLAG(&context);
+        }
+        break;
+
+    case 0x0302:  /* Call real mode procedure with interrupt return */
+        {
+            REALMODECALL *p = (REALMODECALL *)PTR_SEG_OFF_TO_LIN( ES_reg(&context), DI_reg(&context) );
+            fprintf(stdnimp,
+                    "RealModeCallIret: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n"
+                    "                  ESI=%08lx EDI=%08lx ES=%04x DS=%04x CS:IP=%04x:%04x\n",
+                    p->eax, p->ebx, p->ecx, p->edx,
+                    p->esi, p->edi, p->es, p->ds, p->cs, p->ip );
+            SET_CFLAG(&context);
+        }
         break;
 
     case 0x0400:  /* Get DPMI version */
diff --git a/miscemu/instr.c b/miscemu/instr.c
index 09daf43..8b795a9 100644
--- a/miscemu/instr.c
+++ b/miscemu/instr.c
@@ -181,9 +181,11 @@
             base += (signed short)off;
             break;
         }
+        base &= 0xffff;
     }
     if (segprefix != -1) seg = segprefix;
 
+    /* FIXME: should check limit of the segment here */
     return (BYTE *)PTR_SEG_OFF_TO_LIN( seg, (base + (index << ss)) );
 }
 
diff --git a/miscemu/int21.c b/miscemu/int21.c
index 8c6fac4..143e04a 100644
--- a/miscemu/int21.c
+++ b/miscemu/int21.c
@@ -444,7 +444,7 @@
 	AX_reg(context) = now->tm_wday;
 }
 
-static void GetSystemTime(struct sigcontext_struct *context)
+static void INT21_GetSystemTime(struct sigcontext_struct *context)
 {
 	struct tm *now;
 	struct timeval tv;
@@ -603,6 +603,92 @@
 	RESET_CFLAG(context);
 }
 
+void ExtendedOpenCreateFile(struct sigcontext_struct *context)
+{
+  dprintf_int(stddeb, "int21: extended open/create: file= %s \n",
+	      DOS_GetUnixFileName(PTR_SEG_OFF_TO_LIN(DS_reg(context),SI_reg(context))));
+  /* Shuffle arguments to call OpenExistingFile */
+  AL_reg(context) = BL_reg(context);
+  DX_reg(context) = SI_reg(context);
+  /* BX,CX and DX should be preserved */
+  OpenExistingFile(context);
+  if ((EFL_reg(context) & 0x0001)==0) 
+    { /* It exists */
+      dprintf_int(stddeb, "int21: extended open/create %s exists \n",
+		  DOS_GetUnixFileName(PTR_SEG_OFF_TO_LIN(DS_reg(context),SI_reg(context))));
+      /* Now decide what do do */
+      if ((DL_reg(context) & 0x0007)== 0)
+	{
+	  BX_reg(context) = AX_reg(context);
+	  CloseFile(context);
+	  AX_reg(context) = 0x0050;/*File exists*/
+	  CX_reg(context) = 0;
+	  SET_CFLAG(context);
+	  dprintf_int(stddeb, "int21: extended open/create: failed because file exixts \n");
+	  return;
+	}
+      if ((DL_reg(context) & 0x0007)== 2) {
+	/* Truncate it, but first check if opend for write */
+	if ((BL_reg(context) & 0x0007)== 0) {
+	  BX_reg(context) = AX_reg(context);
+	  CloseFile(context);
+	  dprintf_int(stddeb, "int21: extended open/create: failed, trunc on ro file");
+	  AX_reg(context) = 0x000C;/*Access code invalid*/
+	  CX_reg(context) = 0;
+	  SET_CFLAG(context);
+	  return;
+	}
+	/* Shuffle arguments to call CloseFile */
+	dprintf_int(stddeb, "int21: extended open/create: Closing before truncate\n");
+	BX_reg(context) = AX_reg(context);
+	/* BX and DX should be preserved */
+	CloseFile(context);
+	if (EFL_reg(context) & 0x0001) {
+	  dprintf_int(stddeb, "int21: extended open/create: close before trunc failed");
+	  AX_reg(context) = 0x0019;/*Seek Error*/
+	  CX_reg(context) = 0;
+	  SET_CFLAG(context);
+	}
+	/* Shuffle arguments to call CreateFile */
+	dprintf_int(stddeb, "int21: extended open/create: Truncating\n");
+	AL_reg(context) = BL_reg(context);
+	/* CX is still the same */
+	DX_reg(context) = SI_reg(context);
+	CreateFile(context);
+	if (EFL_reg(context) & 0x0001) { /*no file open, flags set */
+	  dprintf_int(stddeb, "int21: extended open/create: truncfailed");
+	  return;
+	}
+	CX_reg(context) = 3;
+	return;
+      }
+      CX_reg(context) = 1;
+      return;
+    }
+  else /* file does not exist */
+    {
+     dprintf_int(stddeb, "int21: extended open/create %s dosen't exists \n",
+		  DOS_GetUnixFileName(PTR_SEG_OFF_TO_LIN(DS_reg(context),SI_reg(context))));
+      if ((DL_reg(context) & 0x00F0)== 0) {
+	CX_reg(context) = 0;
+	SET_CFLAG(context);
+	dprintf_int(stddeb, "int21: extended open/create: failed, file dosen't exist\n");
+	return;
+      }
+      /* Shuffle arguments to call CreateFile */
+      dprintf_int(stddeb, "int21: extended open/create: Creating\n");
+      AL_reg(context) = BL_reg(context);
+      /* CX should still be the same */
+      DX_reg(context) = SI_reg(context);
+      CreateFile(context);
+      if (EFL_reg(context) & 0x0001) { /*no file open, flags set */
+	dprintf_int(stddeb, "int21: extended open/create: create failed\n");
+	return;
+      }
+      CX_reg(context) = 2;
+      return;
+    }
+}
 static void RenameFile(struct sigcontext_struct *context)
 {
 	char *newname, *oldname;
@@ -1312,7 +1398,7 @@
             break;
 
 	  case 0x2c: /* GET SYSTEM TIME */
-	    GetSystemTime(&context);
+	    INT21_GetSystemTime(&context);
 	    break;
 
           case 0x2d: /* SET SYSTEM TIME */
@@ -1738,6 +1824,21 @@
 	    }
 	    break;
     
+	  case 0x6C: /* Extended Open/Create*/
+	    ExtendedOpenCreateFile(&context);
+	    break;
+	
+          case 0x70: /* MS-DOS 7 (Windows95) - ??? (country-specific?)*/
+          case 0x71: /* MS-DOS 7 (Chicago) - LONG FILENAME FUNCTIONS */
+          case 0x72: /* MS-DOS 7 (Windows95) - ??? */
+          case 0x73: /* MS-DOS 7 (Windows95) - DRIVE LOCKING ??? */
+            dprintf_int(stddeb,"int21: windows95 function AX %04x\n",
+ 			AX_reg(&context));
+ 	    dprintf_int(stddeb, "        returning unimplemented\n");
+ 	    SET_CFLAG(&context);
+ 	    AL_reg(&context) = 0;
+ 	    break;
+
           case 0xdc: /* CONNECTION SERVICES - GET CONNECTION NUMBER */
             break;
 
diff --git a/objects/bitmap.c b/objects/bitmap.c
index 72e18ad..7408f3b 100644
--- a/objects/bitmap.c
+++ b/objects/bitmap.c
@@ -227,7 +227,7 @@
     {
         char *str = (char *)PTR_SEG_TO_LIN( name );
         dprintf_bitmap( stddeb, "LoadBitmap("NPFMT",'%s')\n", instance, str );
-        if (str[0] == '#') name = (SEGPTR)(WORD)atoi( str + 1 );
+        if (str[0] == '#') name = (SEGPTR)(DWORD)(WORD)atoi( str + 1 );
     }
     else
         dprintf_bitmap( stddeb, "LoadBitmap("NPFMT",%04x)\n",
diff --git a/objects/cursoricon.c b/objects/cursoricon.c
index 4dc22b2..4098051 100644
--- a/objects/cursoricon.c
+++ b/objects/cursoricon.c
@@ -368,7 +368,7 @@
         return 0;
     }
     /* Make it owned by the module */
-    FarSetOwner( handle, GetExePtr( hInstance ) );
+    FarSetOwner( handle, (WORD)(DWORD)GetExePtr( hInstance ) );
     info = (CURSORICONINFO *)GlobalLock( handle );
     info->ptHotSpot.x   = hotspot.x;
     info->ptHotSpot.y   = hotspot.y;
@@ -404,7 +404,7 @@
     if (!(hInstance = GetExePtr( hInstance ))) return 0;
     size = GlobalSize( handle );
     hNew = GlobalAlloc( GMEM_MOVEABLE, size );
-    FarSetOwner( hNew, hInstance );
+    FarSetOwner( hNew, (WORD)(DWORD)hInstance );
     ptrNew = (char *)GlobalLock( hNew );
     memcpy( ptrNew, ptrOld, size );
     GlobalUnlock( handle );
diff --git a/objects/dc.c b/objects/dc.c
index 41c981a..68e7ff3 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -106,8 +106,8 @@
     caps->vertRes       = screenHeight;
     caps->bitsPixel     = screenDepth;
     caps->planes        = 1;
-    caps->numBrushes    = 0;
-    caps->numPens       = 0;
+    caps->numBrushes    = 16+6;  /* 16 solid + 6 hatched brushes */
+    caps->numPens       = 16;    /* 16 solid pens */
     caps->numMarkers    = 0;
     caps->numFonts      = 0;
     caps->numColors     = 1 << caps->bitsPixel;
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index bde259b..12cacd3 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -193,32 +193,6 @@
 
 
 /***********************************************************************
- *           GDI_AppendToPenBrushList
- */
-BOOL GDI_AppendToPenBrushList(HANDLE hNewObj)
-{
-	HANDLE	 	*lphObj;
-	int	       	i = 1;
-	if (hNewObj == 0) return FALSE;
-	if (lpPenBrushList == NULL) {
-		lpPenBrushList = xmalloc(MAX_OBJ * sizeof(HANDLE));
-		lpPenBrushList[0] = 0;
-		dprintf_gdi(stddeb,"GDI_AppendToPenBrushList() lpPenBrushList allocated !\n");
-	}
-	for (lphObj = lpPenBrushList; i < MAX_OBJ; i++) {
-		if (*lphObj == 0) {
-			*lphObj = hNewObj;
-			*(lphObj + 1) = 0;
-			dprintf_gdi(stddeb,"GDI_AppendToPenBrushList("NPFMT") appended (count=%d)\n", hNewObj, i);
-			return TRUE;
-		}
-		lphObj++;
-	}
-	return FALSE;
-}
-
-
-/***********************************************************************
  *           GDI_AllocObject
  */
 HANDLE GDI_AllocObject( WORD size, WORD magic )
@@ -231,9 +205,6 @@
     obj->hNext   = 0;
     obj->wMagic  = magic;
     obj->dwCount = ++count;
-    if (magic == PEN_MAGIC || magic == BRUSH_MAGIC) {
-      GDI_AppendToPenBrushList(handle);
-    }
     return handle;
 }
 
@@ -406,8 +377,71 @@
 /***********************************************************************
  *           EnumObjects    (GDI.71)
  */
-int EnumObjects(HDC hDC, int nObjType, FARPROC lpEnumFunc, LPSTR lpData)
+int EnumObjects( HDC hdc, int nObjType, FARPROC lpEnumFunc, LPARAM lParam )
 {
+    /* Solid colors to enumerate */
+    static const COLORREF solid_colors[] =
+    { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff),
+      RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00),
+      RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00),
+      RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff),
+      RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00),
+      RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80),
+      RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80),
+      RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
+    };
+    
+    int i, retval = 0;
+
+    dprintf_gdi( stddeb, "EnumObjects: "NPFMT" %d %08lx %08lx\n",
+                 hdc, nObjType, (DWORD)lpEnumFunc, lParam );
+    switch(nObjType)
+    {
+    case OBJ_PEN:
+        /* Enumerate solid pens */
+        for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
+        {
+            LOGPEN pen = { PS_SOLID, { 1, 0 }, solid_colors[i] };
+            retval = CallEnumObjectsProc( lpEnumFunc, MAKE_SEGPTR(&pen),
+                                          lParam );
+            dprintf_gdi( stddeb, "EnumObject: solid pen %08lx, ret=%d\n",
+                         solid_colors[i], retval);
+            if (!retval) break;
+        }
+        break;
+
+    case OBJ_BRUSH:
+        /* Enumerate solid brushes */
+        for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
+        {
+            LOGBRUSH brush = { BS_SOLID, solid_colors[i], 0 };
+            retval = CallEnumObjectsProc( lpEnumFunc, MAKE_SEGPTR(&brush),
+                                          lParam );
+            dprintf_gdi( stddeb, "EnumObject: solid brush %08lx, ret=%d\n",
+                         solid_colors[i], retval);
+            if (!retval) break;
+        }
+        if (!retval) break;
+
+        /* Now enumerate hatched brushes */
+        for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++)
+        {
+            LOGBRUSH brush = { BS_HATCHED, RGB(0,0,0), i };
+            retval = CallEnumObjectsProc( lpEnumFunc, MAKE_SEGPTR(&brush),
+                                          lParam );
+            dprintf_gdi( stddeb, "EnumObject: hatched brush %d, ret=%d\n",
+                         i, retval);
+            if (!retval) break;
+        }
+        break;
+
+    default:
+        fprintf( stderr, "EnumObjects: invalid type %d\n", nObjType );
+        break;
+    }
+    return retval;
+#if 0
+
   /*    HANDLE 		handle;
    DC 			*dc;*/
   HANDLE       	*lphObj;
@@ -508,8 +542,10 @@
   GDI_HEAP_FREE(hLog);
   dprintf_gdi(stddeb,"EnumObjects // End of enumeration !\n");
   return nRet;
+#endif
 }
 
+
 /***********************************************************************
  *		IsGDIObject(GDI.462)
  */
diff --git a/objects/metafile.c b/objects/metafile.c
index 297f514..ab0b7df 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -910,7 +910,7 @@
 	infohdr->biPlanes = bmp->bitmap.bmPlanes;
 	infohdr->biBitCount = bmp->bitmap.bmBitsPixel;
 	memcpy(mr->rdParam + (sizeof(BITMAPINFOHEADER) / 2) + 4,
-	       bmp->bitmap.bmBits, 
+	       PTR_SEG_TO_LIN(bmp->bitmap.bmBits),
 	       bmp->bitmap.bmHeight * bmp->bitmap.bmWidthBytes);
 	break;
 
diff --git a/rc/Makefile.in b/rc/Makefile.in
index f845784..6778692 100644
--- a/rc/Makefile.in
+++ b/rc/Makefile.in
@@ -1,40 +1,24 @@
 TOPSRC = @top_srcdir@
 
-MODULE = rc
+PROGRAM = winerc
+MODULE = none
 
-C_SRCS = sysres.c
+C_SRCS = y.tab.c lex.yy.c winerc.c 
 
-LANGUAGES = En Es De No Fr Fi Da
-
-all: $(MODULE).o
+all: $(PROGRAM)
 
 @MAKE_RULES@
 
+$(PROGRAM): $(OBJS)
+	$(CC) $(CFLAGS) -o winerc $(OBJS) $(LEXLIB)
+
 y.tab.c y.tab.h: parser.y
 	$(YACC) -d -t parser.y
 
 lex.yy.c: parser.l
 	$(LEX) -8 -I parser.l
 
-winerc: lex.yy.o winerc.o y.tab.o
-	$(CC) $(ALLCFLAGS) lex.yy.o winerc.o y.tab.o -o winerc $(LEXLIB)
-
-sysres.rct: sysres.rc $(LANGUAGES:%=sysres_%.rc)
-	echo "#include \"windows.h\"" >sysres.rct
-	echo WINDOWS_H_ENDS_HERE >>sysres.rct
-	cat sysres.rc >>sysres.rct
-
-sysres.c sysres.h: sysres.rct winerc
-	$(CC) $(ALLCFLAGS) -E -x c -P sysres.rct | sed -e '1,/^WINDOWS_H_ENDS_HERE/d' | ./winerc -o sysres -v -p sysres
-
 clean::
-	$(RM) lex.yy.c sysres.rct winerc y.tab.c y.tab.h sysres.c sysres.h
-
-langclean::
-	$(RM) sysres.c sysres.h sysres.o
-
-y.tab.o: y.tab.c y.tab.h parser.h
-lex.yy.o: lex.yy.c y.tab.h parser.h
-winerc.o: $(TOPSRC)/include/windows.h $(TOPSRC)/include/neexe.h parser.h y.tab.h
+	$(RM) y.tab.c y.tab.h lex.yy.c $(PROGRAM)
 
 ### Dependencies:
diff --git a/rc/sysres.rc b/rc/sysres.rc
deleted file mode 100644
index 52e3749..0000000
--- a/rc/sysres.rc
+++ /dev/null
@@ -1,17 +0,0 @@
-#if #LANG(En)
-#include "sysres_En.rc"
-#elif #LANG(De)
-#include "sysres_De.rc"
-#elif #LANG(No)
-#include "sysres_No.rc"
-#elif #LANG(Es)
-#include "sysres_Es.rc"
-#elif #LANG(Fr)
-#include "sysres_Fr.rc"
-#elif #LANG(Fi)
-#include "sysres_Fi.rc"
-#elif #LANG(Da)
-#include "sysres_Da.rc"
-#else
-#error LANG not set to an implemented language.
-#endif
diff --git a/rc/winerc.c b/rc/winerc.c
index c01227f..f5ec380 100644
--- a/rc/winerc.c
+++ b/rc/winerc.c
@@ -18,6 +18,7 @@
 
 char usage[]="winerc -bdvc -p prefix -o outfile < infile \n"
 	"   -b            Create a C array from a binary .res file\n"
+        "   -c            Add 'const' prefix to C constants\n"
 	"   -d            Output debugging information\n"
 	"   -p prefix     Give a prefix for the generated names\n"
 	"   -v            Show each resource as it is processed\n"
@@ -54,7 +55,7 @@
 	extern char* optarg;
 	int optc,lose,ret,binary;
 	lose=binary=0;
-	while((optc=getopt(argc,argv,"bdp:vo:"))!=EOF)
+	while((optc=getopt(argc,argv,"bcdp:vo:"))!=EOF)
 		switch(optc)
 		{
 			/* bison will print state transitions on stderr */
@@ -546,8 +547,8 @@
     for (it=top;it;it=it->next)
         fprintf( header,"extern %sstruct resource %s;\n",
                  ISCONSTANT, get_resource_name(it) );
-    fprintf( header,"\nextern %sstruct resource * %sTable[];\n",
-             ISCONSTANT, prefix );
+    fprintf( header,"\nextern %sstruct resource * %s%s_Table[];\n",
+             ISCONSTANT, ISCONSTANT, prefix );
 
     /* Print the resources bytes */
 
@@ -562,10 +563,10 @@
                  ISCONSTANT, get_resource_name(it) );
         for (i=0;i<it->size-1;i++)
         {
-            fprintf(code,"%#4x,",it->res[i]);
+            fprintf(code,"0x%02x, ",it->res[i]);
             if ((i&7)==7)fputc('\n',code);
         }
-        fprintf(code,"%#4x};\n\n",it->res[i]);
+        fprintf(code,"0x%02x };\n\n",it->res[i]);
     }
 
     /* Print the resources */
@@ -574,15 +575,15 @@
         int type;
         switch(it->type)
         {
-        case acc:type=RT_ACCELERATOR;break;
-        case bmp:type=RT_BITMAP;break;
-        case cur:type=RT_CURSOR;break;
-        case dlg:type=RT_DIALOG;break;
-        case fnt:type=RT_FONT;break;
-        case ico:type=RT_ICON;break;
-        case men:type=RT_MENU;break;
-        case rdt:type=RT_RCDATA;break;
-        case str:type=RT_STRING;break;
+        case acc:type=(int)RT_ACCELERATOR;break;
+        case bmp:type=(int)RT_BITMAP;break;
+        case cur:type=(int)RT_CURSOR;break;
+        case dlg:type=(int)RT_DIALOG;break;
+        case fnt:type=(int)RT_FONT;break;
+        case ico:type=(int)RT_ICON;break;
+        case men:type=(int)RT_MENU;break;
+        case rdt:type=(int)RT_RCDATA;break;
+        case str:type=(int)RT_STRING;break;
         default:fprintf(stderr,"Unknown restype\n");type=-1;break;
         }
         if(it->n_type)
@@ -597,7 +598,8 @@
 
     /* Print the resource table (NULL terminated) */
 
-    fprintf(code,"\n%sstruct resource * %sTable[] = {\n", ISCONSTANT, prefix);
+    fprintf(code,"\n%sstruct resource * %s%s_Table[] = {\n",
+	    ISCONSTANT, ISCONSTANT, prefix);
     for (it=top;it;it=it->next)
         fprintf( code, "  &%s,\n", get_resource_name(it) );
     fprintf( code, "  0\n};\n" );
@@ -608,7 +610,7 @@
                 "static void DoIt() WINE_CONSTRUCTOR;\n"
                 "static void DoIt()\n"
                 "{\n"
-                "\tLIBRES_RegisterResources(%sTable);\n"
+                "\tLIBRES_RegisterResources(%s_Table);\n"
                 "}\n\n"
                 "#ifndef HAVE_WINE_CONSTRUCTOR\n"
                 "void LIBWINE_Register_%s(){\n"
diff --git a/resources/Makefile.in b/resources/Makefile.in
new file mode 100644
index 0000000..3ccf2b0
--- /dev/null
+++ b/resources/Makefile.in
@@ -0,0 +1,20 @@
+TOPSRC = @top_srcdir@
+
+MODULE = resources
+
+LANGUAGES = En Es De No Fr Fi Da
+
+SYSRES_SRCS = $(LANGUAGES:%=sysres_%.c)
+
+C_SRCS = $(SYSRES_SRCS) sysres.c
+
+all: check_winerc $(MODULE).o
+
+@MAKE_RULES@
+
+$(SYSRES_SRCS): $(WINERC)
+
+clean::
+	$(RM) $(SYSRES_SRCS) $(SYSRES_SRCS:.c=.h)
+
+### Dependencies:
diff --git a/resources/sysres.c b/resources/sysres.c
new file mode 100644
index 0000000..04a6d52
--- /dev/null
+++ b/resources/sysres.c
@@ -0,0 +1,56 @@
+/*
+ * System resources loading
+ *
+ * Copyright 1995 Alexandre Julliard
+ */
+
+#include "windows.h"
+#include "global.h"
+#include "options.h"
+#include "resource.h"
+
+#include "sysres_En.h"
+#include "sysres_Es.h"
+#include "sysres_De.h"
+#include "sysres_No.h"
+#include "sysres_Fr.h"
+#include "sysres_Fi.h"
+#include "sysres_Da.h"
+
+
+static const struct resource * const * SYSRES_Resources[] =
+{
+    sysres_En_Table,  /* LANG_En */
+    sysres_Es_Table,  /* LANG_Es */
+    sysres_De_Table,  /* LANG_De */
+    sysres_No_Table,  /* LANG_No */
+    sysres_Fr_Table,  /* LANG_Fr */
+    sysres_Fi_Table,  /* LANG_Fi */
+    sysres_Da_Table   /* LANG_Da */
+};
+
+
+/***********************************************************************
+ *           SYSRES_LoadResource
+ *
+ * Create a global memory block for a system resource.
+ */
+HANDLE SYSRES_LoadResource( SYSTEM_RESOURCE id )
+{
+    const struct resource *resPtr;
+
+    resPtr = SYSRES_Resources[Options.language][id];
+    return GLOBAL_CreateBlock( GMEM_FIXED, resPtr->bytes, resPtr->size,
+			       GetCurrentPDB(), FALSE, FALSE, TRUE, NULL );
+}
+
+
+/***********************************************************************
+ *           SYSRES_FreeResource
+ *
+ * Free a global memory block for a system resource.
+ */
+void SYSRES_FreeResource( HANDLE handle )
+{
+    GLOBAL_FreeBlock( handle );
+}
diff --git a/rc/sysres_Da.rc b/resources/sysres_Da.rc
similarity index 100%
rename from rc/sysres_Da.rc
rename to resources/sysres_Da.rc
diff --git a/rc/sysres_De.rc b/resources/sysres_De.rc
similarity index 100%
rename from rc/sysres_De.rc
rename to resources/sysres_De.rc
diff --git a/rc/sysres_En.rc b/resources/sysres_En.rc
similarity index 100%
rename from rc/sysres_En.rc
rename to resources/sysres_En.rc
diff --git a/rc/sysres_Es.rc b/resources/sysres_Es.rc
similarity index 100%
rename from rc/sysres_Es.rc
rename to resources/sysres_Es.rc
diff --git a/rc/sysres_Fi.rc b/resources/sysres_Fi.rc
similarity index 100%
rename from rc/sysres_Fi.rc
rename to resources/sysres_Fi.rc
diff --git a/rc/sysres_Fr.rc b/resources/sysres_Fr.rc
similarity index 100%
rename from rc/sysres_Fr.rc
rename to resources/sysres_Fr.rc
diff --git a/rc/sysres_No.rc b/resources/sysres_No.rc
similarity index 100%
rename from rc/sysres_No.rc
rename to resources/sysres_No.rc
diff --git a/toolkit/Makefile.in b/toolkit/Makefile.in
deleted file mode 100644
index 46befbf..0000000
--- a/toolkit/Makefile.in
+++ /dev/null
@@ -1,40 +0,0 @@
-TOPSRC = @top_srcdir@
-X_LIBS = @X_LIBS@
-XLIB   = @X_PRE_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@
-MODULE = toolkit
-
-C_SRCS = \
-	atom.c \
-	arch.c \
-	heap.c \
-	libres.c \
-	miscstubs.c \
-	sup.c \
-	winmain.c
-
-all: $(MODULE).o
-
-hello: hello.o ../winelib.a
-	gcc -g -o hello hello.o ../winelib.a -lm $(X_LIBS) -lXpm $(XLIB)
-
-hello2: hello2.o ../winelib.a
-	gcc -g -o hello2 hello2.o ../winelib.a -lm $(X_LIBS) -lXpm $(XLIB)
-
-hello3: hello3res.o hello3.o
-	gcc -g -o hello3 hello3.o hello3res.o ../winelib.a -lm $(X_LIBS) -lXpm $(XLIB)
-
-hello3.o:   hello3res.o
-
-hello3res.o:    hello3res.rc
-	echo "#include \"windows.h\"" >hello3res.rct
-	echo WINDOWS_H_ENDS_HERE >>hello3res.rct
-	cat hello3res.rc  >>hello3res.rct
-	$(CC) $(ALLCFLAGS) -E -x c -P hello3res.rct | sed -e '1,/^WINDOWS_H_ENDS_HERE/d' | ../rc/winerc -o hello3res -v -p hello3
-	gcc -c $(ALLCFLAGS) hello3res.c
-
-@MAKE_RULES@
-
-clean::
-	$(RM) hello hello2 hello3
-
-### Dependencies:
diff --git a/tools/build.c b/tools/build.c
index 53a0150..c2571e0 100644
--- a/tools/build.c
+++ b/tools/build.c
@@ -808,7 +808,7 @@
 		    if(fdp->arg_types[argno]!='.') putchar( 'a'+argno );
 		    if (argno!=argc-1) putchar( ',' );
 		}
-		printf( ") __attribute((stdcall));" );
+		printf( ") __attribute((stdcall));\n" );
 	    }
 
             printf( "void %s_%d(", UpperDLLName, i);
@@ -1071,15 +1071,15 @@
 
     printf( "\tmovl " PREFIX "IF1632_Original32_esp, %%eax\n" );
     printf( "\torl %%eax,%%eax\n" );
-    printf( "\tje 0f\n" );
+    printf( "\tje no_orig_esp\n" );
     printf( "\tmovl %%eax,%%esp\n" );
-    printf( "0:\n" );
+    printf( "no_orig_esp:\n" );
 
     /* Transfer the arguments */
 
     printf( "\tmovl 12(%%ebp),%%ecx\n" );
     printf( "\torl %%ecx,%%ecx\n" );
-    printf( "\tje 1f\n" );
+    printf( "\tje no_args\n" );
     printf( "\tleal 16(%%ebp),%%esi\n" );
     printf( "\tshll $2,%%ecx\n" );
     printf( "\tsubl %%ecx,%%esp\n" );
@@ -1087,7 +1087,7 @@
     printf( "\tshrl $2,%%ecx\n" );
     printf( "\tcld\n" );
     printf( "\trep; movsl\n" );
-    printf( "1:\n" );
+    printf( "no_args:\n" );
 
     /* Call the function */
 
@@ -1321,6 +1321,9 @@
 
     printf( "\tpushw " PREFIX "IF1632_Saved16_sp\n" );
     printf( "\tpushw " PREFIX "IF1632_Saved16_ss\n" );
+#ifdef __svr4__
+    printf("\tdata16\n");
+#endif
     printf( "\tmovw %%ss," PREFIX "IF1632_Saved16_ss\n" );
     printf( "\tmovw %%sp," PREFIX "IF1632_Saved16_sp\n" );
 
@@ -1380,9 +1383,18 @@
 
     /* Restore the 16-bit stack */
 
+#ifdef __svr4__
+    printf( "\tdata16\n");
+#endif
     printf( "\tmovw " PREFIX "IF1632_Saved16_ss,%%ss\n" );
     printf( "\tmovw " PREFIX "IF1632_Saved16_sp,%%sp\n" );
+#ifdef __svr4__
+    printf( "\tdata16\n");
+#endif
     printf( "\tpopw " PREFIX "IF1632_Saved16_ss\n" );
+#ifdef __svr4__
+    printf( "\tdata16\n");
+#endif
     printf( "\tpopw " PREFIX "IF1632_Saved16_sp\n" );
 
     if (reg_func)
@@ -1547,6 +1559,9 @@
 
     /* Switch to the 16-bit stack */
 
+#ifdef __svr4__
+    printf("\tdata16\n");
+#endif
     printf( "\tmovw " PREFIX "IF1632_Saved16_ss,%%ss\n" );
     printf( "\tmovw " PREFIX "IF1632_Saved16_sp,%%sp\n" );
 
@@ -1608,6 +1623,9 @@
     {
         /* Set ax equal to ds for window procedures */
         printf( "\tmovw 16(%%ebx),%%ax\n" );
+#ifdef __svr4__
+        printf( "\tdata16\n");
+#endif
         printf( "\tmovw %%ax,%%ds\n" );
     }
 
@@ -1639,8 +1657,17 @@
     /* Restore 32-bit segment registers */
 
     printf( "\tmovw $0x%04x,%%bx\n", WINE_DATA_SELECTOR );
+#ifdef __svr4__
+    printf( "\tdata16\n");
+#endif
     printf( "\tmovw %%bx,%%ds\n" );
+#ifdef __svr4__
+    printf( "\tdata16\n");
+#endif
     printf( "\tmovw %%bx,%%es\n" );
+#ifdef __svr4__
+    printf( "\tdata16\n");
+#endif
     printf( "\tmovw %%bx,%%ss\n" );
 
     /* Restore the 32-bit stack */
diff --git a/tools/install-sh b/tools/install-sh
new file mode 100755
index 0000000..89fc9b0
--- /dev/null
+++ b/tools/install-sh
@@ -0,0 +1,238 @@
+#! /bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+#
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+tranformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+	-c) instcmd="$cpprog"
+	    shift
+	    continue;;
+
+	-d) dir_arg=true
+	    shift
+	    continue;;
+
+	-m) chmodcmd="$chmodprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-o) chowncmd="$chownprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-g) chgrpcmd="$chgrpprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-s) stripcmd="$stripprog"
+	    shift
+	    continue;;
+
+	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
+	    shift
+	    continue;;
+
+	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+	    shift
+	    continue;;
+
+	*)  if [ x"$src" = x ]
+	    then
+		src=$1
+	    else
+		# this colon is to work around a 386BSD /bin/sh bug
+		:
+		dst=$1
+	    fi
+	    shift
+	    continue;;
+    esac
+done
+
+if [ x"$src" = x ]
+then
+	echo "install:	no input file specified"
+	exit 1
+else
+	true
+fi
+
+if [ x"$dir_arg" != x ]; then
+	dst=$src
+	src=""
+	
+	if [ -d $dst ]; then
+		instcmd=:
+	else
+		instcmd=mkdir
+	fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad 
+# if $src (and thus $dsttmp) contains '*'.
+
+	if [ -f $src -o -d $src ]
+	then
+		true
+	else
+		echo "install:  $src does not exist"
+		exit 1
+	fi
+	
+	if [ x"$dst" = x ]
+	then
+		echo "install:	no destination specified"
+		exit 1
+	else
+		true
+	fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+	if [ -d $dst ]
+	then
+		dst="$dst"/`basename $src`
+	else
+		true
+	fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='	
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+	pathcomp="${pathcomp}${1}"
+	shift
+
+	if [ ! -d "${pathcomp}" ] ;
+        then
+		$mkdirprog "${pathcomp}"
+	else
+		true
+	fi
+
+	pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+	$doit $instcmd $dst &&
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+	if [ x"$transformarg" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		dstfile=`basename $dst $transformbasename | 
+			sed $transformarg`$transformbasename
+	fi
+
+# don't allow the sed command to completely eliminate the filename
+
+	if [ x"$dstfile" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		true
+	fi
+
+# Make a temp file name in the proper directory.
+
+	dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+	$doit $instcmd $src $dsttmp &&
+
+	trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+	$doit $rmcmd -f $dstdir/$dstfile &&
+	$doit $mvcmd $dsttmp $dstdir/$dstfile 
+
+fi &&
+
+
+exit 0
diff --git a/win32/advapi.c b/win32/advapi.c
index 7c9baf2..e60c784 100644
--- a/win32/advapi.c
+++ b/win32/advapi.c
@@ -35,6 +35,7 @@
 /***********************************************************************
  *           RegCreateKeyEx   (ADVAPI32.130)
  */
+LONG RegCreateKey(HKEY,LPCTSTR,LPHKEY);
 WINAPI LONG RegCreateKeyEx(HKEY key,
                             const char *subkey,
                             long dontuse,
diff --git a/win32/environment.c b/win32/environment.c
index e754f41..a9152f1 100644
--- a/win32/environment.c
+++ b/win32/environment.c
@@ -25,9 +25,13 @@
     char *cp;
     PDB *pdb = (PDB *)GlobalLock( GetCurrentPDB() );
 
+#ifndef WINELIB
     strcpy(buffer, wine_files->name);
     cp = buffer+strlen(buffer);
     *cp++ = ' ';
+#else
+    cp = buffer;
+#endif;
     memcpy( cp, &pdb->cmdLine[1], pdb->cmdLine[0] );
     dprintf_win32(stddeb,"CommandLine = %s\n", buffer );
     return buffer;
diff --git a/win32/file.c b/win32/file.c
index 9146964..2188ff5 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -30,6 +30,9 @@
 static void UnixTimeToFileTime(time_t unix_time, FILETIME *filetime);
 static int TranslateCreationFlags(DWORD create_flags);
 static int TranslateAccessFlags(DWORD access_flags);
+#ifndef MAP_ANON
+#define MAP_ANON 0
+#endif
 
 /***********************************************************************
  *           OpenFileMappingA             (KERNEL32.397)
@@ -43,6 +46,7 @@
  *           CreateFileMappingA		(KERNEL32.46)
  *
  */
+int TranslateProtectionFlags(DWORD);
 WINAPI HANDLE32 CreateFileMapping(HANDLE32 h,SECURITY_ATTRIBUTES *ats,
   DWORD pot,  DWORD sh,  DWORD hlow,  const char * lpName )
 {
@@ -97,7 +101,7 @@
                              DWORD offlo, DWORD size, DWORD st)
 {
     if (!size) size = ((FILEMAP_OBJECT *)handle)->size;
-    return mmap (st, size, ((FILEMAP_OBJECT *)handle)->prot, 
+    return mmap ((caddr_t)st, size, ((FILEMAP_OBJECT *)handle)->prot, 
                  MAP_ANON|MAP_PRIVATE, 
 		 ((FILEMAP_OBJECT *)handle)->file_obj->fd,
 		 offlo);
@@ -138,7 +142,7 @@
         lpfi->dwFileAttributes |= FILE_ATTRIBUTE_NORMAL;
     if(file_stat.st_mode & S_IFDIR)
         lpfi->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
-    if(file_stat.st_mode & S_IWRITE == 0)
+    if((file_stat.st_mode & S_IWRITE) == 0)
         lpfi->dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
 
     /* Translate the file times.  Use the last modification time
diff --git a/win32/memory.c b/win32/memory.c
index 78b04fe..352db66 100644
--- a/win32/memory.c
+++ b/win32/memory.c
@@ -20,6 +20,9 @@
 #ifndef PROT_NONE  /* FreeBSD doesn't define PROT_NONE */
 #define PROT_NONE 0
 #endif
+#ifndef MAP_ANON
+#define MAP_ANON 0
+#endif
 
 typedef struct {
     caddr_t	ptr;
@@ -33,6 +36,7 @@
 /***********************************************************************
  *           VirtualAlloc             (KERNEL32.548)
  */
+int TranslateProtectionFlags(DWORD);
 LPVOID VirtualAlloc(LPVOID lpvAddress, DWORD cbSize,
                    DWORD fdwAllocationType, DWORD fdwProtect)
 {
diff --git a/win32/object_mgt.c b/win32/object_mgt.c
index 07a6ed4..6495694 100644
--- a/win32/object_mgt.c
+++ b/win32/object_mgt.c
@@ -14,6 +14,6 @@
 
 int ValidateKernelObject(KERNEL_OBJECT *ptr)
 {
-  return (!ptr || (short int)ptr==-1);
+  return (!ptr || (short int)(int)ptr==-1);
 }
 
diff --git a/win32/time.c b/win32/time.c
index 04d6780..24be6a3 100644
--- a/win32/time.c
+++ b/win32/time.c
@@ -38,6 +38,29 @@
 }
 
 /***********************************************************************
+ *              GetSystemTime            (KERNEL32.285)
+ */
+VOID GetSystemTime(LPSYSTEMTIME systime)
+{
+    time_t local_time;
+    struct tm *local_tm;
+    struct timeval tv;
+
+    time(&local_time);
+    local_tm = gmtime(&local_time);
+    gettimeofday(&tv, NULL);
+
+    systime->wYear = local_tm->tm_year + 1900;
+    systime->wMonth = local_tm->tm_mon + 1;
+    systime->wDayOfWeek = local_tm->tm_wday;
+    systime->wDay = local_tm->tm_mday;
+    systime->wHour = local_tm->tm_hour;
+    systime->wMinute = local_tm->tm_min;
+    systime->wSecond = local_tm->tm_sec;
+    systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
+}
+
+/***********************************************************************
  *              GetTimeZoneInformation  (KERNEL32.302)
  */
 DWORD GetTimeZoneInformation(LPTIME_ZONE_INFORMATION tzinfo)
@@ -55,3 +78,12 @@
     return TIME_ZONE_ID_UNKNOWN;
 }
 
+/***********************************************************************
+ *              Sleep  (KERNEL32.523)
+ */
+VOID Sleep(DWORD cMilliseconds)
+{
+    if(cMilliseconds == INFINITE)
+        while(1) { /* Spin forever */ }
+    usleep(cMilliseconds*1000);
+}
diff --git a/windows/defwnd.c b/windows/defwnd.c
index bc901b0..42aad58 100644
--- a/windows/defwnd.c
+++ b/windows/defwnd.c
@@ -328,7 +328,7 @@
 	 len = 1;
 	 while(len < 64)
 		if( (hI = LoadIcon(wndPtr->hInstance,MAKEINTRESOURCE(len))) )
-		     return hI;
+		     return (LRESULT)hI;
 	}
         break;
 
diff --git a/windows/dialog.c b/windows/dialog.c
index 8f7cdb0..1ed5fe1 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -218,7 +218,7 @@
     HGLOBAL hmem;
     SEGPTR data;
 
-    dprintf_dialog(stddeb, "CreateDialogParam: "NPFMT",%08lx,"NPFMT",%08lx,%ld\n",
+    dprintf_dialog(stddeb, "CreateDialogParam: "NPFMT","SPFMT","NPFMT",%08lx,%ld\n",
 	    hInst, dlgTemplate, owner, (DWORD)dlgProc, param );
      
     if (!(hRsrc = FindResource( hInst, dlgTemplate, RT_DIALOG ))) return 0;
@@ -523,7 +523,7 @@
 {
     HWND hwnd;
     
-    dprintf_dialog(stddeb, "DialogBoxParam: "NPFMT",%08lx,"NPFMT",%08lx,%ld\n",
+    dprintf_dialog(stddeb, "DialogBoxParam: "NPFMT","SPFMT","NPFMT",%08lx,%ld\n",
 	    hInst, dlgTemplate, owner, (DWORD)dlgProc, param );
     hwnd = CreateDialogParam( hInst, dlgTemplate, owner, dlgProc, param );
     if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
@@ -751,7 +751,7 @@
 
     if (fSigned) sprintf( str, "%d", (int)value );
     else sprintf( str, "%u", value );
-    SendDlgItemMessage( hwnd, id, WM_SETTEXT, 0, MAKE_SEGPTR(str) );
+    SendDlgItemMessage( hwnd, id, WM_SETTEXT, 0, (LPARAM)MAKE_SEGPTR(str) );
 }
 
 
@@ -764,7 +764,7 @@
     long result = 0;
     
     if (translated) *translated = FALSE;
-    if (SendDlgItemMessage( hwnd, id, WM_GETTEXT, 30, MAKE_SEGPTR(str) ))
+    if (SendDlgItemMessage( hwnd, id, WM_GETTEXT, 30, (LPARAM)MAKE_SEGPTR(str) ))
     {
 	char * endptr;
 	result = strtol( str, &endptr, 10 );
diff --git a/windows/event.c b/windows/event.c
index 301e91f..780cc31 100644
--- a/windows/event.c
+++ b/windows/event.c
@@ -534,7 +534,7 @@
 	    winpos.flags |= SWP_NOSIZE;
 
 	/* Send WM_WINDOWPOSCHANGING */
-	SendMessage(hwnd, WM_WINDOWPOSCHANGING, 0, MAKE_SEGPTR(&winpos));
+	SendMessage(hwnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)MAKE_SEGPTR(&winpos));
 
 	/* Calculate new position and size */
 	newWindowRect.left = event->x;
@@ -549,7 +549,7 @@
 	/* Set new size and position */
 	wndPtr->rectWindow = newWindowRect;
 	wndPtr->rectClient = newClientRect;
-	SendMessage(hwnd, WM_WINDOWPOSCHANGED, 0, MAKE_SEGPTR(&winpos));
+	SendMessage(hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)MAKE_SEGPTR(&winpos));
     }
 }
 
diff --git a/windows/focus.c b/windows/focus.c
index 6e8e46a..bbd591b 100644
--- a/windows/focus.c
+++ b/windows/focus.c
@@ -11,7 +11,7 @@
 #include "winpos.h"
 #include "hook.h"
 #include "color.h"
-
+#include "options.h"
 
 static HWND hwndFocus = 0;
 
@@ -25,8 +25,9 @@
     XWindowAttributes win_attr;
     Window win;
 
-      /* Only mess with the X focus if there's no desktop window */
-    if (rootWindow != DefaultRootWindow(display)) return;
+    /* Only mess with the X focus if there's */
+    /* no desktop window and no window manager. */
+    if ((rootWindow != DefaultRootWindow(display)) || Options.managed) return;
 
     if (!hwnd)	/* If setting the focus to 0, uninstall the colormap */
     {
@@ -53,11 +54,11 @@
 {
     hwndFocus = hFocusTo;
 
-    if (hFocusFrom) SendMessage( hFocusFrom, WM_KILLFOCUS, hFocusTo, 0L);
+    if (hFocusFrom) SendMessage( hFocusFrom, WM_KILLFOCUS, (WPARAM)hFocusTo, 0L);
     if( !hFocusTo || hFocusTo != hwndFocus )
 	return;
 
-    SendMessage( hFocusTo, WM_SETFOCUS, hFocusFrom, 0L);
+    SendMessage( hFocusTo, WM_SETFOCUS, (WPARAM)hFocusFrom, 0L);
     FOCUS_SetXFocus( hFocusTo );
 }
 
@@ -88,7 +89,7 @@
 	if( hwnd == hwndFocus ) return hwnd;
 
 	/* call hooks */
-	if( HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, hwnd, hwndFocus) )
+	if( HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, (WPARAM)hwnd, (LPARAM)hwndFocus) )
 	    return 0;
 
         /* activate hwndTop if needed. */
@@ -99,7 +100,7 @@
 	    if (!IsWindow( hwnd )) return 0;  /* Abort if window destroyed */
 	}
     }
-    else if( HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, 0, hwndFocus ) )
+    else if( HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, 0, (LPARAM)hwndFocus ) )
              return 0;
 
       /* Change focus and send messages */
diff --git a/windows/hook.c b/windows/hook.c
index 2460cad..abb6c7f 100644
--- a/windows/hook.c
+++ b/windows/hook.c
@@ -226,7 +226,7 @@
     HTASK hTask = (id == WH_MSGFILTER) ? GetCurrentTask() : 0;
 
     HANDLE handle = HOOK_SetHook( id, proc, hInst, hTask );
-    if (!handle) return -1;
+    if (!handle) return (FARPROC)-1;
     if (!((HOOKDATA *)USER_HEAP_LIN_ADDR( handle ))->next) return 0;
     /* Not sure if the return value is correct; should not matter much
      * since it's never used (see DefHookProc). -- AJ */
@@ -319,7 +319,11 @@
 DWORD CallNextHookEx( HHOOK hhook, short code, WPARAM wParam, LPARAM lParam )
 {
     HANDLE next;
+#ifdef WINELIB32
+    if (!(next = HOOK_GetNextHook( (HANDLE)hhook ))) return 0;
+#else
     if (HIWORD(hhook) != HOOK_MAGIC) return 0;  /* Not a new format hook */
     if (!(next = HOOK_GetNextHook( LOWORD(hhook) ))) return 0;
+#endif
     return HOOK_CallHook( next, code, wParam, lParam );
 }
diff --git a/windows/mdi.c b/windows/mdi.c
index 0fe19aa..86d5413 100644
--- a/windows/mdi.c
+++ b/windows/mdi.c
@@ -58,6 +58,7 @@
 /**********************************************************************
  *			MDI_MenuAppendItem
  */
+#ifdef SUPERFLUOUS_FUNCTIONS
 static BOOL MDI_MenuAppendItem(WND *clientWnd, HWND hWndChild)
 {
     char buffer[128];
@@ -74,6 +75,7 @@
  return AppendMenu(clientInfo->hWindowMenu,MF_STRING,
                        wndPtr->wIDmenu,(LPSTR)buffer);
 }
+#endif
 
 /**********************************************************************
  *			MDI_MenuModifyItem
@@ -245,7 +247,8 @@
 			  WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU |
 			  WS_THICKFRAME | WS_VISIBLE | cs->style,
 			  cs->x, cs->y, cs->cx, cs->cy, parent, 
-                         (HMENU) wIDmenu, w->hInstance, (SEGPTR)lParam);
+                         (HMENU)(DWORD)(WORD)wIDmenu, w->hInstance, 
+			 (SEGPTR)lParam);
 
     if (hwnd)
     {
@@ -376,7 +379,7 @@
         ci->nActiveChildren--;
 
         if( ci->flagChildMaximized == child )
-            ci->flagChildMaximized = 1;
+            ci->flagChildMaximized = (HWND)1;
 
         if (flagDestroy)
 	   {
@@ -477,8 +480,13 @@
     if( wndPrev )
     {
 	SendMessage( prevActiveWnd, WM_NCACTIVATE, FALSE, 0L );
+#ifdef WINELIB32
+        SendMessage( prevActiveWnd, WM_MDIACTIVATE, (WPARAM)prevActiveWnd, 
+		     (LPARAM)hWndChild);
+#else
         SendMessage( prevActiveWnd, WM_MDIACTIVATE, FALSE,
 					    MAKELONG(hWndChild,prevActiveWnd));
+#endif
         /* uncheck menu item */
        	if( clientInfo->hWindowMenu )
        	        CheckMenuItem( clientInfo->hWindowMenu,
@@ -517,13 +525,18 @@
 	    SendMessage( hWndChild, WM_NCACTIVATE, TRUE, 0L);
 	    if( GetFocus() == GetParent(hWndChild) )
 		SendMessage( GetParent(hWndChild), WM_SETFOCUS, 
-			     GetParent(hWndChild), 0L );
+			     (WPARAM)GetParent(hWndChild), 0L );
 	    else
 		SetFocus( GetParent(hWndChild) );
     }
 
+#ifdef WINELIB32
+    SendMessage( hWndChild, WM_MDIACTIVATE, (WPARAM)hWndChild,
+		 (LPARAM)prevActiveWnd );
+#else
     SendMessage( hWndChild, WM_MDIACTIVATE, TRUE,
 				       MAKELONG(prevActiveWnd,hWndChild) );
+#endif
 
     return 1;
 }
@@ -678,6 +691,10 @@
 
     if( !listTop ) return 0;
 
+    /* just free memory and return if zero windows to tile */
+    if ( iToPosition == 0 )
+        goto MDITile_free;
+
     GetClientRect(parent, &rect);
 
     rows    = (int) sqrt((double) iToPosition);
@@ -725,7 +742,8 @@
 
 	x += xsize;
     }
-    
+
+  MDITile_free:
     /* free the rest if any */
     while( listTop ) {
 	 listPrev = listTop->prev;
@@ -791,7 +809,7 @@
 
     dprintf_mdi(stddeb, "MDIPaintMaximized: frame "NPFMT",  client "NPFMT
 		",  max flag %d,  menu %04x\n", hwndFrame, hwndClient, 
-		ci->flagChildMaximized, wndPtr ? wndPtr->wIDmenu : 0);
+		(int)ci->flagChildMaximized, wndPtr ? wndPtr->wIDmenu : 0);
 
     if (ci->flagChildMaximized && wndPtr && wndPtr->wIDmenu != 0)
     {
@@ -881,7 +899,7 @@
 	return 0;
 
       case WM_MDIACTIVATE:
-	SetWindowPos(wParam,0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
+	SetWindowPos((HWND)wParam,0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
 	return 0;
 
       case WM_MDICASCADE:
@@ -891,7 +909,7 @@
 	return (LONG)MDICreateChild(w, ci, hwnd, lParam );
 
       case WM_MDIDESTROY:
-	return MDIDestroyChild(w, ci, hwnd, wParam, TRUE);
+	return (LONG)MDIDestroyChild(w, ci, hwnd, (HWND)wParam, TRUE);
 
       case WM_MDIGETACTIVE:
 	return ((LONG) ci->hwndActiveChild | 
@@ -905,7 +923,7 @@
 	       return 0;
 	
       case WM_MDIMAXIMIZE:
-	return MDIMaximizeChild(hwnd, wParam, ci);
+	return MDIMaximizeChild(hwnd, (HWND)wParam, ci);
 
       case WM_MDINEXT:
 	MDI_SwitchActiveChild(hwnd, (HWND)wParam, lParam);
@@ -915,7 +933,11 @@
 	return MDIRestoreChild(hwnd, ci);
 
       case WM_MDISETMENU:
-	return MDISetMenu(hwnd, wParam, LOWORD(lParam), HIWORD(lParam));
+#ifdef WINELIB32
+	return (LRESULT)MDISetMenu(hwnd, FALSE, (HMENU)wParam, (HMENU)lParam);
+#else
+	return (LRESULT)MDISetMenu(hwnd, wParam, LOWORD(lParam), HIWORD(lParam));
+#endif
 	
       case WM_MDITILE:
 	ci->sbStop = TRUE;
@@ -989,7 +1011,11 @@
 	    childHwnd = MDI_GetChildByID( WIN_FindWndPtr(hwndMDIClient),
                                           wParam );
  	    if( childHwnd )
+#ifdef WINELIB32 /* FIXME: need to find out the equivalent Win32 message */
+	        SendMessage(hwndMDIClient, WM_MDIACTIVATE, 0 , 0);
+#else
 	        SendMessage(hwndMDIClient, WM_MDIACTIVATE, childHwnd , 0L);
+#endif
 	    break;
 
 	  case WM_NCLBUTTONDOWN:
@@ -1048,7 +1074,7 @@
         return 0;
 
       case WM_CLOSE:
-	SendMessage(GetParent(hwnd),WM_MDIDESTROY,hwnd,0L);
+	SendMessage(GetParent(hwnd),WM_MDIDESTROY,(WPARAM)hwnd,0L);
 	return 0;
 
       case WM_SIZE:
@@ -1158,11 +1184,11 @@
 void ScrollChildren(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
  WND	*wndPtr = WIN_FindWndPtr(hWnd);
- short 	 newPos;
+ short 	 newPos=-1;
  short 	 curPos;
  short 	 length;
- short 	 minPos;
- short 	 maxPos;
+ INT 	 minPos;
+ INT 	 maxPos;
  short   shift;
 
  if( !wndPtr ) return;
diff --git a/windows/message.c b/windows/message.c
index 23afe53..43bb4e4 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -1152,7 +1152,7 @@
 
     EnterSpyMessage(SPY_SENDMESSAGE, hwnd, msg, wParam, lParam);
 
-    HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, 1, MAKE_SEGPTR(&msgstruct) );
+    HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)MAKE_SEGPTR(&msgstruct) );
     if (!(wndPtr = WIN_FindWndPtr( hwnd ))) 
     {
         ExitSpyMessage(SPY_RESULT_INVALIDHWND,hwnd,msg,0);
@@ -1225,8 +1225,10 @@
     {
 	if (msg->lParam)
         {
+#ifndef WINELIB32
             HINSTANCE ds = msg->hwnd ? WIN_GetWindowInstance( msg->hwnd )
                                      : (HINSTANCE)CURRENT_DS;
+#endif
 /*            HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
 	    return CallWndProc( (WNDPROC)msg->lParam, ds, msg->hwnd,
                                 msg->message, msg->wParam, GetTickCount() );
@@ -1293,7 +1295,7 @@
  */
 WORD RegisterWindowMessage( SEGPTR str )
 {
-    dprintf_msg(stddeb, "RegisterWindowMessage: '%08lx'\n", str );
+    dprintf_msg(stddeb, "RegisterWindowMessage: '"SPFMT"'\n", str );
     return GlobalAddAtom( str );
 }
 
diff --git a/windows/msgbox.c b/windows/msgbox.c
index ddb9690..a83b8cc 100644
--- a/windows/msgbox.c
+++ b/windows/msgbox.c
@@ -7,12 +7,11 @@
 
 #include "windows.h"
 #include "dlgs.h"
-#include "global.h"
 #include "selectors.h"
 #include "alias.h"
 #include "relay32.h"
 #include "win.h"
-#include "../rc/sysres.h"
+#include "resource.h"
 #include "task.h"
 
 typedef struct {
@@ -201,15 +200,13 @@
         initialized=1;
     }
 
-    handle = GLOBAL_CreateBlock( GMEM_FIXED, sysres_DIALOG_MSGBOX.bytes,
-                                 sysres_DIALOG_MSGBOX.size, GetCurrentPDB(),
-                                 FALSE, FALSE, TRUE, NULL );
+    handle = SYSRES_LoadResource( SYSRES_DIALOG_MSGBOX );
     if (!handle) return 0;
     ret = DialogBoxIndirectParam( WIN_GetWindowInstance(hWnd),
                                   handle, hWnd,
                                   GetWndProcEntry16("SystemMessageBoxProc"),
                                   (LONG)&mbox );
-    GLOBAL_FreeBlock( handle );
+    SYSRES_FreeResource( handle );
     return ret;
 }
 
diff --git a/windows/nonclient.c b/windows/nonclient.c
index 9df7ae5..863b1c1 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -174,16 +174,16 @@
         MinMax.ptMaxPosition.y = -yinc;
     }
 
-    SendMessage( hwnd, WM_GETMINMAXINFO, 0, MAKE_SEGPTR(&MinMax) );
+    SendMessage( hwnd, WM_GETMINMAXINFO, 0, (LPARAM)MAKE_SEGPTR(&MinMax) );
 
       /* Some sanity checks */
 
     dprintf_nonclient(stddeb, 
 		      "NC_GetMinMaxInfo: %d %d / %d %d / %d %d / %d %d\n",
-		      MinMax.ptMaxSize.x,MinMax.ptMaxSize.y,
-		      MinMax.ptMaxPosition.x,MinMax.ptMaxPosition.y,
-		      MinMax.ptMaxTrackSize.x,MinMax.ptMaxTrackSize.y,
-		      MinMax.ptMinTrackSize.x,MinMax.ptMinTrackSize.y);
+		      (int)MinMax.ptMaxSize.x,(int)MinMax.ptMaxSize.y,
+		      (int)MinMax.ptMaxPosition.x,(int)MinMax.ptMaxPosition.y,
+		      (int)MinMax.ptMaxTrackSize.x,(int)MinMax.ptMaxTrackSize.y,
+		      (int)MinMax.ptMinTrackSize.x,(int)MinMax.ptMinTrackSize.y);
     MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
 				   MinMax.ptMinTrackSize.x );
     MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
@@ -892,7 +892,7 @@
     }
     *capturePoint = pt;
     SetCursorPos( capturePoint->x, capturePoint->y );
-    NC_HandleSetCursor( hwnd, hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
+    NC_HandleSetCursor( hwnd, (WPARAM)hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
     return hittest;
 }
 
diff --git a/windows/property.c b/windows/property.c
index 601615f..1dcafb8 100644
--- a/windows/property.c
+++ b/windows/property.c
@@ -31,7 +31,7 @@
     PROPERTY *prop;
     WND *wndPtr;
 
-    dprintf_prop( stddeb, "SetProp: "NPFMT" %08lx "NPFMT"\n", hwnd, str, hData );
+    dprintf_prop( stddeb, "SetProp: "NPFMT" "SPFMT" "NPFMT"\n", hwnd, str, hData );
     if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
     hProp = USER_HEAP_ALLOC( sizeof(PROPERTY) + 
                              (HIWORD(str) ? strlen(PTR_SEG_TO_LIN(str)) : 0 ));
@@ -62,7 +62,7 @@
     HANDLE hProp;
     WND *wndPtr;
 
-    dprintf_prop( stddeb, "GetProp: "NPFMT" %08lx\n", hwnd, str );
+    dprintf_prop( stddeb, "GetProp: "NPFMT" "SPFMT"\n", hwnd, str );
     if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
     hProp = wndPtr->hProp;
     while (hProp)
@@ -88,7 +88,7 @@
     HANDLE *hProp;
     WND *wndPtr;
 
-    dprintf_prop( stddeb, "RemoveProp: "NPFMT" %08lx\n", hwnd, str );
+    dprintf_prop( stddeb, "RemoveProp: "NPFMT" "SPFMT"\n", hwnd, str );
     if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
     hProp = &wndPtr->hProp;
     while (*hProp)
diff --git a/windows/scroll.c b/windows/scroll.c
index e8652cf..9c5ad2b 100644
--- a/windows/scroll.c
+++ b/windows/scroll.c
@@ -19,7 +19,7 @@
 
 
 
-extern DCE_GetVisRgn(HWND, WORD);
+extern HRGN DCE_GetVisRgn(HWND, WORD);
 
 static int RgnType;
 
@@ -127,10 +127,10 @@
     RECT rc, cliprc;
 
     dprintf_scroll(stddeb,"ScrollWindow: dx=%d, dy=%d, lpRect =%08lx clipRect=%i,%i,%i,%i\n", 
-	    dx, dy, (LONG)rect, (clipRect)?clipRect->left:0,
-                                (clipRect)?clipRect->top:0,
-                                (clipRect)?clipRect->right:0, 
-                                (clipRect)?clipRect->bottom:0);
+	    dx, dy, (LONG)rect, (int)((clipRect)?clipRect->left:0),
+                                (int)((clipRect)?clipRect->top:0),
+                                (int)((clipRect)?clipRect->right:0), 
+                                (int)((clipRect)?clipRect->bottom:0));
 
     /* if rect is NULL children have to be moved */
     if ( !rect )
@@ -146,8 +146,9 @@
        {
 	  GetClientRect(hwnd,&rc);
 	  dprintf_scroll(stddeb,"\trect=%i %i %i %i client=%i %i %i %i\n",
-			 rect->left,rect->top,rect->right,rect->bottom,rc.left,rc.top,
-			 rc.right,rc.bottom);
+			 (int)rect->left,(int)rect->top,(int)rect->right,
+			 (int)rect->bottom,(int)rc.left,(int)rc.top,
+			 (int)rc.right,(int)rc.bottom);
 
 	CopyRect(&rc, rect);
 	  hdc = GetDC(hwnd);
@@ -206,10 +207,10 @@
     DC *dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC);
 
     dprintf_scroll(stddeb,"ScrollDC: dx=%d dy=%d, hrgnUpdate="NPFMT" rc=%i %i %i %i\n",
-                                     dx,dy,hrgnUpdate,(rc)?rc->left:0,
-				                      (rc)?rc->top:0,
-				                      (rc)?rc->right:0,
-				                      (rc)?rc->bottom:0); 
+                                     dx,dy,hrgnUpdate,(int)((rc)?rc->left:0),
+				                      (int)((rc)?rc->top:0),
+				                      (int)((rc)?rc->right:0),
+				                      (int)((rc)?rc->bottom:0)); 
 
     if (rc == NULL)
 	return FALSE;
@@ -288,7 +289,7 @@
     HDC hdc;
     RECT rc, cliprc;
 
-    dprintf_scroll(stddeb,"ScrollWindowEx: dx=%d, dy=%d, wFlags="NPFMT"\n",dx, dy, flags);
+    dprintf_scroll(stddeb,"ScrollWindowEx: dx=%d, dy=%d, wFlags=%04x\n",dx, dy, flags);
 
     hdc = GetDC(hwnd);
 
diff --git a/windows/win.c b/windows/win.c
index 1848a3b..da50aec 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -496,7 +496,7 @@
     createStruct.lpszClass      = className;
     createStruct.dwExStyle      = 0;
 
-    wmcreate = SendMessage( hwnd, WM_NCCREATE, 0, MAKE_SEGPTR(&createStruct) );
+    wmcreate = SendMessage( hwnd, WM_NCCREATE, 0, (LPARAM)MAKE_SEGPTR(&createStruct) );
     if (!wmcreate)
     {
 	dprintf_win(stddeb,"CreateWindowEx: WM_NCCREATE return 0\n");
@@ -506,7 +506,7 @@
     {
 	WINPOS_SendNCCalcSize( hwnd, FALSE, &wndPtr->rectWindow,
 			       NULL, NULL, NULL, &wndPtr->rectClient );
-	wmcreate = SendMessage(hwnd, WM_CREATE, 0, MAKE_SEGPTR(&createStruct));
+	wmcreate = SendMessage(hwnd, WM_CREATE, 0, (LPARAM)MAKE_SEGPTR(&createStruct));
     }
 
     if (wmcreate == -1)
@@ -1309,8 +1309,8 @@
 
 	 if(ptrWnd)
 	    dprintf_msg(stddeb,"DragQueryUpdate: hwnd = "NPFMT", %i %i - %i %i\n",hWnd,
-			     ptrWnd->rectWindow.left,ptrWnd->rectWindow.top,
-			     ptrWnd->rectWindow.right,ptrWnd->rectWindow.bottom);	 
+			(int)ptrWnd->rectWindow.left,(int)ptrWnd->rectWindow.top,
+			(int)ptrWnd->rectWindow.right,(int)ptrWnd->rectWindow.bottom);	 
 	 else
 	    dprintf_msg(stddeb,"DragQueryUpdate: hwnd = "NPFMT"\n",hWnd);
 
@@ -1460,7 +1460,7 @@
     if( hCurrentCursor )
         SetCursor(hCurrentCursor);
 
-    dprintf_msg(stddeb,"drag: got "NPFMT"\n",btemp);
+    dprintf_msg(stddeb,"drag: got %04x\n",btemp);
 
     /* send WM_DRAGLOOP */
     SendMessage( hWnd, WM_DRAGLOOP, (WPARAM)(hCurrentCursor != hBummer) , 
@@ -1498,7 +1498,7 @@
 
  if( hCurrentCursor != hBummer ) 
 	dwRet = SendMessage( lpDragInfo->hScope, WM_DROPOBJECT, 
-			     hWnd, (LPARAM)spDragInfo );
+			     (WPARAM)hWnd, (LPARAM)spDragInfo );
  GlobalFree(hDragInfo);
 
  return dwRet;
diff --git a/windows/winpos.c b/windows/winpos.c
index 97109b7..659cd2f 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -583,7 +583,7 @@
 	return 1;
 
     SendMessage( hWnd, WM_ACTIVATEAPP, lpActStruct->wFlag,
-		(LPARAM)(lpActStruct->hWindowTask)?lpActStruct->hWindowTask:0);
+		(LPARAM)((lpActStruct->hWindowTask)?lpActStruct->hWindowTask:0));
     return 1;
 }
 
@@ -615,7 +615,7 @@
 	dprintf_win(stddeb,"WINPOS_ActivateWindow: no current active window.\n");
 
     /* call CBT hook chain */
-    wRet = HOOK_CallHooks(WH_CBT, HCBT_ACTIVATE, hWnd,
+    wRet = HOOK_CallHooks(WH_CBT, HCBT_ACTIVATE, (WPARAM)hWnd,
 			  (LPARAM)MAKE_SEGPTR(&cbtStruct));
 
     if( wRet ) return wRet;
@@ -623,6 +623,7 @@
     /* set prev active wnd to current active wnd and send notification */
     if( (hwndPrevActive = hwndActive) )
     {
+/* FIXME: need a Win32 translation for WINELIB32 */
 	if( !SendMessage(hwndPrevActive, WM_NCACTIVATE, 0, MAKELONG(hWnd,wIconized)) )
         {
 	    if (GetSysModalWindow() != hWnd) return 0;
@@ -647,7 +648,7 @@
 
     /* send palette messages */
     if( SendMessage( hWnd, WM_QUERYNEWPALETTE, 0, 0L) )
-	SendMessage((HWND)-1, WM_PALETTEISCHANGING, hWnd, 0L );
+	SendMessage((HWND)-1, WM_PALETTEISCHANGING, (WPARAM)hWnd, 0L );
 
     /* if prev wnd is minimized redraw icon title 
   if( hwndPrevActive )
@@ -718,6 +719,7 @@
     wndTemp->hwndLastActive = hWnd;
 
     wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
+/* FIXME: Needs a Win32 translation for WINELIB32 */
     SendMessage( hWnd, WM_NCACTIVATE, 1,
 		 MAKELONG(hwndPrevActive,wIconized));
 #ifdef WINELIB32
@@ -753,26 +755,26 @@
  *	   WINPOS_ChangeActiveWindow
  *
  */
-HWND WINPOS_ChangeActiveWindow( HWND hWnd, BOOL mouseMsg )
+BOOL WINPOS_ChangeActiveWindow( HWND hWnd, BOOL mouseMsg )
 {
     WND *wndPtr = WIN_FindWndPtr(hWnd);
 
-    if( !wndPtr ) return  0;
+    if( !wndPtr ) return FALSE;
 
     /* minors are not allowed */
     if( (wndPtr->dwStyle & WS_CHILD) && !( wndPtr->dwStyle & WS_POPUP))
 	return SendMessage(hWnd, WM_CHILDACTIVATE, 0, 0L);
 
-    if( hWnd == hwndActive ) return 0;     
+    if( hWnd == hwndActive ) return FALSE;
 
     if( !WINPOS_SetActiveWindow(hWnd ,mouseMsg ,TRUE) )
-	return 0;
+	return FALSE;
 
     /* switch desktop queue to current active here */
     if( wndPtr->hwndParent == GetDesktopWindow())
     { }
 
-    return 1;
+    return TRUE;
 }
 
 
@@ -799,10 +801,10 @@
 	params.lppos = winpos;
     }
     result = SendMessage( hwnd, WM_NCCALCSIZE, calcValidRect,
-                          MAKE_SEGPTR( &params ) );
+                          (LPARAM)MAKE_SEGPTR( &params ) );
     dprintf_win(stddeb, "WINPOS_SendNCCalcSize: %d %d %d %d\n",
-		params.rgrc[0].top,    params.rgrc[0].left,
-		params.rgrc[0].bottom, params.rgrc[0].right);
+		(int)params.rgrc[0].top,    (int)params.rgrc[0].left,
+		(int)params.rgrc[0].bottom, (int)params.rgrc[0].right);
     *newClientRect = params.rgrc[0];
     return result;
 }
@@ -1006,7 +1008,7 @@
       /* Send WM_WINDOWPOSCHANGING message */
 
     if (!(flags & SWP_NOSENDCHANGING))
-	SendMessage( hwnd, WM_WINDOWPOSCHANGING, 0, MAKE_SEGPTR(&winpos) );
+	SendMessage( hwnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)MAKE_SEGPTR(&winpos) );
 
       /* Calculate new position and size */
 
@@ -1162,7 +1164,7 @@
 
     if (!(winpos.flags & SWP_NOSENDCHANGING))
         SendMessage( winpos.hwnd, WM_WINDOWPOSCHANGED,
-                     0, MAKE_SEGPTR(&winpos) );
+                     0, (LPARAM)MAKE_SEGPTR(&winpos) );
 
     return TRUE;
 }
diff --git a/Wine.man b/wine.man
similarity index 100%
rename from Wine.man
rename to wine.man