Release 960717 wine-960717
authorAlexandre Julliard <julliard@winehq.org>
Wed, 17 Jul 1996 20:02:21 +0000 (20:02 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 17 Jul 1996 20:02:21 +0000 (20:02 +0000)
Wed Jul 17 16:10:16 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

* [configure.in]
Generate include/config.h instead of putting everything on the
command-line.
Removed -with-malloc-debug option (not useful for end users
anyway).
Added check for memmove().

* [include/wintypes.h] [*/Makefile.in]
Added definition of __WINE__ symbol when compiling Wine code
(emulator or library) as opposed to user programs.

* [debugger/editline.c] [debugger/readline/*]
Moved all the readline code into debugger/editline.c. Removed the
readline subdirectory.

* [files/profile.c]
Added PROFILE_GetWineIniInt().

* [include/stackframe.h] [loader/task.c]
The 16-bit stackframe now also exists for Winelib (even though it
only ever contains one frame).

* [loader/module.c]
Added function MODULE_CreateDummyModule() to create a dummy Win16
module for Winelib and Win32.

* [memory/ldt.c]
Make sure the ldt entry contents will be acceptable for the Linux
kernel.

* [memory/selector.c]
Fixed SetSelectorLimit() when the limit is in pages.

* [misc/port.c]
Added memmove().

* [miscemu/dpmi.c]
Clear the segment registers that contain the selector being freed
in int31/ax=0001.
Added missing break after SelectorAccessRights call.

* [win32/struct32.c]
Added conversions for MDICREATESTRUCT.

* [windows/winproc.c]
Added message conversions for WM_MDICREATE.

Tue Jul 16 19:46:24 1996  Pavel Kankovsky <KAN@frode.dcit.cz>

* [windows/class.c]
Added GetExePtr() call in CLASS_FindClassByAtom().

Mon Jul 15 17:49:38 1996  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

* [if1632/*.spec]
Some more trivial specs added.

* [if1632/gdi32.spec] [objects/font.c][windows/dialog.c]
CreateFont32* added, changed to new naming std.

* [include/windows.h] [include/mmsystem.h] [include/wintypes.h]
Some defines/types added.

* [win32/thread.c]
TlsSetValue() returns boolean.

* [win32/resource.c] [loader/pe_resource.c] [loader/resource.c]
    [controls/menu.c] [objects/bitmap.c]
Cleanup of the resource functions, mostly changes to new naming
  standard and fixing of argument types so that they agree with the
  win16/win32 API.

Thu Jul 11 15:00:00 1996  Alex Korobka <alex@phm30.pharm.sunysb.edu>

* [windows/winpos.c]
ShowWindow() fixes.

* [windows/mdi.c]
Fix reversed LPARAM in WM_MDIACTIVATE.

* [wine.ini]
New option AllocSystemColors tells Wine how many colors to grab
from the system colormap.

* [objects/bitblt.c] [objects/dc.c]
Fixed pink garbage over Word buttons in PseudoColor. Added
optional DSTINVERT shortcut for faster text selection.

* [misc/wsprintf.c]
Skip bogus segmented pointers in wsvnprintf16().

* [objects/gdiobj.c]
Added palette handling to UnrealizeObject().

* [objects/color.c] [objects/palette.c] [windows/dce.c]
Wine gets palette manager with support for more than 20 colors.
Only PseudoColor and TrueColor visuals tested so far.

* [windows/winpos.c] [windows/win.c]
Set X size hints for WS_EX_DLGMODALFRAME windows (no resize) and
use XReconfigureWMWindows() instead of XConfigureWindow() in
managed mode.

* [memory/global.c]
Do not allocate more than 640K of DOS memory.

* [misc/main.c]
Do not allow -desktop and -managed together.

140 files changed:
ANNOUNCE
BUGS
ChangeLog
Make.rules.in
Makefile.in
configure
configure.in
controls/Makefile.in
controls/button.c
controls/combo.c
controls/desktop.c
controls/edit.c
controls/menu.c
controls/scroll.c
controls/static.c
controls/widgets.c
debugger/Makefile.in
debugger/dbg.y
debugger/debug.l
debugger/editline.c [moved from debugger/readline/editline.c with 79% similarity]
debugger/readline/Makefile.in [deleted file]
debugger/readline/README [deleted file]
debugger/readline/editline.3 [deleted file]
debugger/readline/editline.h [deleted file]
debugger/readline/sysunix.c [deleted file]
files/Makefile.in
files/file.c
files/profile.c
if1632/Makefile.in
if1632/comctl32.spec
if1632/gdi.spec
if1632/gdi32.spec
if1632/kernel.spec
if1632/kernel32.spec
if1632/relay.c
if1632/shell32.spec
if1632/user.spec
if1632/user32.spec
if1632/winmm.spec
include/callback.h
include/color.h
include/config.h.in [new file with mode: 0644]
include/file.h
include/gdi.h
include/hook.h
include/ldt.h
include/libres.h
include/mmsystem.h
include/options.h
include/palette.h
include/pe_image.h
include/resource.h
include/resource32.h
include/stackframe.h
include/struct32.h
include/task.h
include/windows.h
include/winsock.h
include/wintypes.h
include/winuser.h
ipc/Makefile.in
library/Makefile.in
library/libres.c
library/miscstubs.c
loader/Makefile.in
loader/builtin.c
loader/module.c
loader/ne_image.c
loader/ne_resource.c
loader/pe_image.c
loader/pe_resource.c
loader/resource.c
loader/task.c
memory/Makefile.in
memory/global.c
memory/ldt.c
memory/local.c
memory/selector.c
memory/string.c
misc/Makefile.in
misc/commdlg.c
misc/driver.c
misc/main.c
misc/port.c
misc/shell.c
misc/toolhelp.c
misc/winsocket.c
misc/wsprintf.c
miscemu/Makefile.in
miscemu/dpmi.c
multimedia/Makefile.in
multimedia/time.c
objects/Makefile.in
objects/bitblt.c
objects/bitmap.c
objects/color.c
objects/cursoricon.c
objects/dc.c
objects/font.c
objects/gdiobj.c
objects/linedda.c
objects/oembitmap.c
objects/palette.c
objects/text.c
programs/winhelp/hlp2sgml.c
programs/winhelp/hlpfile.c
programs/winhelp/winhelp.c
rc/Makefile.in
resources/Makefile.in
tools/Makefile.in
tools/build.c
win32/Makefile.in
win32/cursoricon32.c
win32/environment.c
win32/init.c
win32/newfns.c
win32/process.c
win32/resource.c [deleted file]
win32/struct32.c
win32/thread.c
win32/time.c
win32/user32.c
windows/Makefile.in
windows/class.c
windows/dce.c
windows/defwnd.c
windows/dialog.c
windows/event.c
windows/focus.c
windows/graphics.c
windows/hook.c
windows/mdi.c
windows/msgbox.c
windows/nonclient.c
windows/queue.c
windows/win.c
windows/winpos.c
windows/winproc.c
wine.ini
wine.man

index b90a4dbb778fd3aa1e3ea3a97b75b871b4574b0a..2c43984c4110fd0f55e50674f04c7c9e6673843b 100644 (file)
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,13 +1,13 @@
-This is release 960712 of Wine, the MS Windows emulator.  This is still a
+This is release 960717 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 correctly.
 
 Patches should be submitted to "julliard@lrc.epfl.ch".  Please don't
 forget to include a ChangeLog entry.
 
-WHAT'S NEW with Wine-960712: (see ChangeLog for details)
-       - Many built-in debugger improvements.
-       - Some more Win32 functions.
+WHAT'S NEW with Wine-960717: (see ChangeLog for details)
+       - New palette management.
+       - Changes to the configuration process.
        - Lots of bug fixes.
 
 See the README file in the distribution for installation instructions.
@@ -16,10 +16,10 @@ Because of lags created by using mirror, this message may reach you before
 the release is available at the ftp sites.  The sources will be available
 from the following locations:
 
-    sunsite.unc.edu:/pub/Linux/ALPHA/wine/development/Wine-960712.tar.gz
-    tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-960712.tar.gz
-    ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-960712.tar.gz
-    aris.com:/pub/linux/ALPHA/Wine/development/Wine-960712.tar.gz
+    sunsite.unc.edu:/pub/Linux/ALPHA/wine/development/Wine-960717.tar.gz
+    tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-960717.tar.gz
+    ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-960717.tar.gz
+    aris.com:/pub/linux/ALPHA/Wine/development/Wine-960717.tar.gz
 
 It should also be available from any site that mirrors tsx-11 or sunsite.
 
diff --git a/BUGS b/BUGS
index 19f3c084fedcffba2aad21f025d792e22caa896c..1148443703e27da86e307aecef401857ca636e42 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -1,26 +1,19 @@
-1. 32-bit/16-bit call translation:
-
-- EBP and ESP are sometimes corrupted while running 16-bit code.
-
-2. Messaging:
+1. Messaging:
 
 - Message flow is not correct for multiple tasks
 - Dialog Boxes created by WM_CREATE handler aren't visible
 - MDI does not send WM_GETMINMAX message.
 - resizing of MDI child windows sometimes leaves them unrepainted
 
-3. Controls:
+2. Controls:
 
 - Some features are missing (like VK_SHIFT aided multiple selection in listboxes)
 
-4. Miscellaneous:
+3. Miscellaneous:
 
-- InitializeLoadedDLLs() can't init LZEXPAND.DLL. (cs:ip => 0:0)
-- LoadCursor does not correctly handle bitmap cursors
 - AllocCSToDSAlias() shouldn't alloc alias for the same segment multiple times.
-- Dialogs don't support resources which are referred to as integers.
 
-5. Where to look in source files:
+4. Where to look in source files:
 
 - grep for FIXME in the source files.
 
index 5139957ce2e16ddaa9243cef23930dd257c994a1..09c335fa86a78be5389d91b610523a6e07951485 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,115 @@
+----------------------------------------------------------------------
+Wed Jul 17 16:10:16 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>
+
+       * [configure.in]
+       Generate include/config.h instead of putting everything on the
+       command-line.
+       Removed -with-malloc-debug option (not useful for end users
+       anyway).
+       Added check for memmove().
+
+       * [include/wintypes.h] [*/Makefile.in]
+       Added definition of __WINE__ symbol when compiling Wine code
+       (emulator or library) as opposed to user programs.
+
+       * [debugger/editline.c] [debugger/readline/*]
+       Moved all the readline code into debugger/editline.c. Removed the
+       readline subdirectory.
+
+       * [files/profile.c]
+       Added PROFILE_GetWineIniInt().
+
+       * [include/stackframe.h] [loader/task.c]
+       The 16-bit stackframe now also exists for Winelib (even though it
+       only ever contains one frame).
+
+       * [loader/module.c]
+       Added function MODULE_CreateDummyModule() to create a dummy Win16
+       module for Winelib and Win32.
+
+       * [memory/ldt.c]
+       Make sure the ldt entry contents will be acceptable for the Linux
+       kernel.
+
+       * [memory/selector.c]
+       Fixed SetSelectorLimit() when the limit is in pages.
+
+       * [misc/port.c]
+       Added memmove().
+
+       * [miscemu/dpmi.c]
+       Clear the segment registers that contain the selector being freed
+       in int31/ax=0001.
+       Added missing break after SelectorAccessRights call.
+
+       * [win32/struct32.c]
+       Added conversions for MDICREATESTRUCT.
+
+       * [windows/winproc.c]
+       Added message conversions for WM_MDICREATE.
+
+Tue Jul 16 19:46:24 1996  Pavel Kankovsky <KAN@frode.dcit.cz>
+
+       * [windows/class.c]
+       Added GetExePtr() call in CLASS_FindClassByAtom().
+
+Mon Jul 15 17:49:38 1996  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
+
+       * [if1632/*.spec]
+       Some more trivial specs added.
+
+       * [if1632/gdi32.spec] [objects/font.c][windows/dialog.c]
+       CreateFont32* added, changed to new naming std.
+
+       * [include/windows.h] [include/mmsystem.h] [include/wintypes.h]
+       Some defines/types added.
+
+       * [win32/thread.c]
+       TlsSetValue() returns boolean.
+
+       * [win32/resource.c] [loader/pe_resource.c] [loader/resource.c]
+         [controls/menu.c] [objects/bitmap.c]
+       Cleanup of the resource functions, mostly changes to new naming
+       standard and fixing of argument types so that they agree with the
+       win16/win32 API.
+
+Thu Jul 11 15:00:00 1996  Alex Korobka <alex@phm30.pharm.sunysb.edu>
+
+       * [windows/winpos.c]
+       ShowWindow() fixes.
+
+       * [windows/mdi.c]
+       Fix reversed LPARAM in WM_MDIACTIVATE.
+
+       * [wine.ini]
+       New option AllocSystemColors tells Wine how many colors to grab
+       from the system colormap.
+
+       * [objects/bitblt.c] [objects/dc.c]
+       Fixed pink garbage over Word buttons in PseudoColor. Added
+       optional DSTINVERT shortcut for faster text selection.
+
+       * [misc/wsprintf.c]
+       Skip bogus segmented pointers in wsvnprintf16(). 
+
+       * [objects/gdiobj.c]
+       Added palette handling to UnrealizeObject(). 
+
+       * [objects/color.c] [objects/palette.c] [windows/dce.c]
+       Wine gets palette manager with support for more than 20 colors. 
+       Only PseudoColor and TrueColor visuals tested so far.
+
+       * [windows/winpos.c] [windows/win.c] 
+       Set X size hints for WS_EX_DLGMODALFRAME windows (no resize) and
+       use XReconfigureWMWindows() instead of XConfigureWindow() in
+       managed mode.
+
+       * [memory/global.c]
+       Do not allocate more than 640K of DOS memory.
+
+       * [misc/main.c]
+       Do not allow -desktop and -managed together.
+
 ----------------------------------------------------------------------
 Fri Jul 12 17:43:05 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>
 
index bb56d51a191097e08761eb5ec0d995cc715e176c..d65987233e1dae8a3bcf5fe2cf331dad93112ce1 100644 (file)
@@ -6,8 +6,8 @@
 SHELL     = /bin/sh
 CC        = @CC@
 CPP       = @CPP@
-CFLAGS           = @CFLAGS@
-DEFS      = @DEFS@
+CFLAGS    = @CFLAGS@
+OPTIONS   = @OPTIONS@
 X_CFLAGS  = @X_CFLAGS@
 X_LIBS    = @X_LIBS@
 XPM_LIB          = -lXpm
@@ -17,13 +17,13 @@ YACC      = @YACC@
 LEX       = @LEX@
 LEXLIB    = @LEXLIB@
 DIVINCL   = -I$(TOPSRC)/include
-ALLCFLAGS = $(CFLAGS) $(DEFS) $(DIVINCL) $(X_CFLAGS) $(EXTRA_DEFS)
+ALLCFLAGS = $(CFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL) $(X_CFLAGS)
 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)'
+SUBMAKE   = $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'OPTIONS=$(OPTIONS)'
 @SET_MAKE@
 
 OBJS = $(C_SRCS:.c=.o) $(ASM_SRCS:.S=.o) $(EXTRA_OBJS)
@@ -43,14 +43,14 @@ OBJS = $(C_SRCS:.c=.o) $(ASM_SRCS:.S=.o) $(EXTRA_OBJS)
        echo "#include \"windows.h\"" >winerctmp.c
        echo WINDOWS_H_ENDS_HERE >>winerctmp.c
        cat $< >>winerctmp.c
-       $(CPP) $(DEFS) $(DIVINCL) -DRC_INVOKED -P winerctmp.c | sed -e '1,/^WINDOWS_H_ENDS_HERE/d' | $(WINERC) -c -o $* -p $*
+       $(CPP) $(OPTIONS) $(DIVINCL) -DRC_INVOKED -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 $*
+       $(CPP) $(OPTIONS) $(DIVINCL) -DRC_INVOKED -P winerctmp.c | sed -e '1,/^WINDOWS_H_ENDS_HERE/d' | $(WINERC) -c -o $* -p $*
        $(RM) winerctmp.c
 
 
index f8f62056eb9cd32bafff8a3ae4c681435c2445c5..89031f3bb6e29dfa5056076cfa376ec512a03f08 100644 (file)
 
 SHELL     = /bin/sh
 CC        = @CC@
-CPP       = @CPP@
-CFLAGS           = @CFLAGS@
-DEFS      = @DEFS@ -DWINE_INI_GLOBAL=\"$(WINE_INI_GLOBAL)\"
-X_CFLAGS  = @X_CFLAGS@
+CFLAGS    = @CFLAGS@
+OPTIONS   = @OPTIONS@
 X_LIBS    = @X_LIBS@
 TOPSRC    = @top_srcdir@
-DIVINCL   = -I$(TOPSRC)/include
-XPM_LIB          = -lXpm
-XLIB     = @X_PRE_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@
-LDLIBS   = @LDLIBS@
+XPM_LIB   = -lXpm
+XLIB      = @X_PRE_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@
+LDLIBS    = @LDLIBS@
 AR        = ar rc
 RANLIB    = @RANLIB@
 RM        = rm -f
-SUBMAKE   = $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'DEFS=$(DEFS)'
+SUBMAKE   = $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'OPTIONS=$(OPTIONS)'
 @SET_MAKE@
 
 # Installation infos
@@ -38,10 +35,8 @@ 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
 
@@ -64,7 +59,6 @@ COMMONSUBDIRS = \
 EMUSUBDIRS = \
        tools \
        debugger \
-       debugger/readline \
        if1632 \
        miscemu
 
@@ -89,7 +83,6 @@ COMMONOBJS = \
 
 EMUOBJS = \
        debugger/debugger.o \
-       debugger/readline/readline.o \
        if1632/if1632.o \
        miscemu/miscemu.o
 
@@ -141,7 +134,7 @@ clean:
        (cd include; $(RM) *.o \#*\# *~ *.bak *.orig *.rej *.flc)
 
 distclean: clean
-       $(RM) config.* Make.rules
+       $(RM) config.* Make.rules include/config.h
        $(RM) `find . \( -name Makefile -o -size 0 \) -print`
 
 dummy:
index 72b314342e432ba76353523c277064f60d7ab5fd..49f45df3b1b0cab429d57b67cf42995896fc665d 100755 (executable)
--- a/configure
+++ b/configure
@@ -18,8 +18,6 @@ ac_help="$ac_help
   --with-dll              build Wine as a DLL instead of an emulator"
 ac_help="$ac_help
   --with-ipc              use inter-process communication for DDE"
-ac_help="$ac_help
-  --with-malloc-debug     enable malloc() debugging"
 ac_help="$ac_help
   --with-x                use the X Window System"
 
@@ -523,6 +521,7 @@ else
 fi
 
                
+
 ac_aux_dir=
 for ac_dir in tools $srcdir/tools; do
   if test -f $ac_dir/install-sh; then
@@ -552,48 +551,27 @@ test -z "$LDLIBS" && LDLIBS=-lm
 # Check whether --with-library or --without-library was given.
 if test "${with_library+set}" = set; then
   withval="$with_library"
-  cat >> confdefs.h <<\EOF
-#define WINELIB 1
-EOF
- MAIN_TARGET="libwine.a"
+  OPTIONS="-DWINELIB" MAIN_TARGET="libwine.a"
 else
-  MAIN_TARGET="wine"
+  OPTIONS="" MAIN_TARGET="wine"
 fi
 
 
 # Check whether --with-dll or --without-dll was given.
 if test "${with_dll+set}" = set; then
   withval="$with_dll"
-  cat >> confdefs.h <<\EOF
-#define WINELIB 1
-EOF
- cat >> confdefs.h <<\EOF
-#define WINELIBDLL 1
-EOF
-
- MAIN_TARGET="libwine.so.1.0" CFLAGS="$CFLAGS -fPIC"
+  OPTIONS="-DWINELIB -DWINELIBDLL" MAIN_TARGET="libwine.so.1.0" CFLAGS="$CFLAGS -fPIC"
 fi
 
 
-
 # Check whether --with-ipc or --without-ipc was given.
 if test "${with_ipc+set}" = set; then
   withval="$with_ipc"
-  cat >> confdefs.h <<\EOF
-#define CONFIG_IPC 1
-EOF
-
+  OPTIONS="$OPTIONS -DCONFIG_IPC"
 fi
 
 
-# Check whether --with-malloc-debug or --without-malloc-debug was given.
-if test "${with_malloc_debug+set}" = set; then
-  withval="$with_malloc_debug"
-  cat >> confdefs.h <<\EOF
-#define MALLOC_DEBUGGING 1
-EOF
 
-fi
 
 
 
@@ -709,7 +687,7 @@ else
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:713: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:691: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -761,13 +739,13 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 765 "configure"
+#line 743 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:771: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:749: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   :
@@ -776,13 +754,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 780 "configure"
+#line 758 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:786: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:764: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   :
@@ -886,12 +864,12 @@ if test "$ac_x_includes" = NO; then
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 890 "configure"
+#line 868 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:895: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:873: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -958,7 +936,7 @@ if test "$ac_x_libraries" = NO; then
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 962 "configure"
+#line 940 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -966,7 +944,7 @@ int t() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:970: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+if { (eval echo configure:948: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -1087,7 +1065,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lICE  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1091 "configure"
+#line 1069 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1099,7 +1077,7 @@ int t() {
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:1103: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+if { (eval echo configure:1081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1135,7 +1113,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1139 "configure"
+#line 1117 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1147,7 +1125,7 @@ int t() {
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:1151: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+if { (eval echo configure:1129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1174,7 +1152,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1178 "configure"
+#line 1156 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1186,7 +1164,7 @@ int t() {
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:1190: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+if { (eval echo configure:1168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1218,7 +1196,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1222 "configure"
+#line 1200 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1230,7 +1208,7 @@ int t() {
 t_accept()
 ; return 0; }
 EOF
-if { (eval echo configure:1234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+if { (eval echo configure:1212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1262,7 +1240,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1266 "configure"
+#line 1244 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1274,7 +1252,7 @@ int t() {
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:1278: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+if { (eval echo configure:1256: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1302,7 +1280,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket -lnsl $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1306 "configure"
+#line 1284 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1314,7 +1292,7 @@ int t() {
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:1318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+if { (eval echo configure:1296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1412,7 +1390,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$ac_lib  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1416 "configure"
+#line 1394 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1424,7 +1402,7 @@ int t() {
 yywrap()
 ; return 0; }
 EOF
-if { (eval echo configure:1428: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+if { (eval echo configure:1406: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1539,7 +1517,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-li386  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1543 "configure"
+#line 1521 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1551,7 +1529,7 @@ int t() {
 i386_set_ldt()
 ; return 0; }
 EOF
-if { (eval echo configure:1555: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+if { (eval echo configure:1533: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1583,11 +1561,11 @@ else
   ac_cv_c_cross=yes
 else
 cat > conftest.$ac_ext <<EOF
-#line 1587 "configure"
+#line 1565 "configure"
 #include "confdefs.h"
 main(){return(0);}
 EOF
-{ (eval echo configure:1591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
+{ (eval echo configure:1569: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
   ac_cv_c_cross=no
 else
@@ -1608,7 +1586,7 @@ else
   ac_cv_c_gcc_strength_bug="yes"
 else
 cat > conftest.$ac_ext <<EOF
-#line 1612 "configure"
+#line 1590 "configure"
 #include "confdefs.h"
 
 int main(void) {
@@ -1619,7 +1597,7 @@ int main(void) {
   exit( Array[1] != -2 );
 }
 EOF
-{ (eval echo configure:1623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
+{ (eval echo configure:1601: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
   ac_cv_c_gcc_strength_bug="no"
 else
@@ -1637,14 +1615,14 @@ echo "$ac_t""$ac_cv_c_gcc_strength_bug" 1>&6
 fi
 
 
-for ac_func in tcgetattr usleep
+for ac_func in memmove tcgetattr usleep
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1648 "configure"
+#line 1626 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1668,7 +1646,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:1672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+if { (eval echo configure:1650: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1690,49 +1668,12 @@ else
 fi
 done
 
-for ac_hdr in stdlib.h
-do
-ac_safe=`echo "$ac_hdr" | tr './\055' '___'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 1702 "configure"
-#include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1707: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
-else
-  echo "$ac_err" >&5
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-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 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
-  cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
-EOF
-else
-  echo "$ac_t""no" 1>&6
-fi
-done
-
 echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
 if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1736 "configure"
+#line 1677 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -1787,7 +1728,7 @@ if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1791 "configure"
+#line 1732 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1837,7 +1778,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if { (eval echo configure:1841: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1782: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -1861,7 +1802,7 @@ 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 1865 "configure"
+#line 1806 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1869,7 +1810,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1873: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1814: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1884,7 +1825,7 @@ rm -f conftest*
 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 1888 "configure"
+#line 1829 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1902,7 +1843,7 @@ fi
 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 1906 "configure"
+#line 1847 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1923,7 +1864,7 @@ if test "$cross_compiling" = yes; then
   :
 else
 cat > conftest.$ac_ext <<EOF
-#line 1927 "configure"
+#line 1868 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1934,7 +1875,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-{ (eval echo configure:1938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
+{ (eval echo configure:1879: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
   :
 else
@@ -1958,7 +1899,7 @@ if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1962 "configure"
+#line 1903 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2038,19 +1979,7 @@ fi
 
 trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
 
-# Transform confdefs.h into DEFS.
-# Protect against shell expansion while executing Makefile rules.
-# Protect against Makefile macro expansion.
-cat > conftest.defs <<\EOF
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
-s%[    `~#$^&*(){}\\|;'"<>?]%\\&%g
-s%\[%\\&%g
-s%\]%\\&%g
-s%\$%$$%g
-EOF
-DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
-rm -f conftest.defs
-
+DEFS=-DHAVE_CONFIG_H
 
 # Without the "./", some shells look in PATH for config.status.
 : ${CONFIG_STATUS=./config.status}
@@ -2093,7 +2022,6 @@ Make.rules
 Makefile
 controls/Makefile
 debugger/Makefile
-debugger/readline/Makefile
 files/Makefile
 if1632/Makefile
 ipc/Makefile
@@ -2112,7 +2040,7 @@ rc/Makefile
 resources/Makefile
 tools/Makefile
 win32/Makefile
-windows/Makefile " | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+windows/Makefile  include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
@@ -2144,6 +2072,7 @@ s%@infodir@%$infodir%g
 s%@mandir@%$mandir%g
 s%@LDLIBS@%$LDLIBS%g
 s%@MAIN_TARGET@%$MAIN_TARGET%g
+s%@OPTIONS@%$OPTIONS%g
 s%@SET_MAKE@%$SET_MAKE%g
 s%@CC@%$CC%g
 s%@CPP@%$CPP%g
@@ -2168,7 +2097,6 @@ CONFIG_FILES=\${CONFIG_FILES-"Make.rules
 Makefile
 controls/Makefile
 debugger/Makefile
-debugger/readline/Makefile
 files/Makefile
 if1632/Makefile
 ipc/Makefile
@@ -2243,6 +2171,108 @@ s%@INSTALL@%$INSTALL%g
 fi; done
 rm -f conftest.subs
 
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([  ]*\)#\([        ]*define[       ][      ]*\)'
+ac_dB='\([     ][      ]*\)[^  ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([  ]*\)#\([        ]*\)undef\([    ][      ]*\)'
+ac_uB='\([     ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([  ]*\)#\([        ]*\)undef\([    ][      ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+CONFIG_HEADERS=${CONFIG_HEADERS-"include/config.h"}
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+  # Support "outfile[:infile]", defaulting infile="outfile.in".
+  case "$ac_file" in
+  *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
+       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+  *) ac_file_in="${ac_file}.in" ;;
+  esac
+
+  echo creating $ac_file
+
+  rm -f conftest.frag conftest.in conftest.out
+  cp $ac_given_srcdir/$ac_file_in conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h.  And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments.  This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[   ]*#[    ]*undef[        ][      ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+# Maximum number of lines to put in a single here document.
+ac_max_here_lines=12
+
+rm -f conftest.tail
+while :
+do
+  ac_lines=`grep -c . conftest.vals`
+  # grep -c gives empty output for an empty file on some AIX systems.
+  if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+  # Write a limited-size here document to conftest.frag.
+  echo '  cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+  echo 'CEOF
+  sed -f conftest.frag conftest.in > conftest.out
+  rm -f conftest.in
+  mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+  rm -f conftest.vals
+  mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+  rm -f conftest.frag conftest.h
+  echo "/* $ac_file.  Generated automatically by configure.  */" > conftest.h
+  cat conftest.in >> conftest.h
+  rm -f conftest.in
+  if cmp -s $ac_file conftest.h 2>/dev/null; then
+    echo "$ac_file is unchanged"
+    rm -f conftest.h
+  else
+    # Remove last slash and all that follows it.  Not all systems have dirname.
+      ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+      if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+      # The file is in a subdirectory.
+      test ! -d "$ac_dir" && mkdir "$ac_dir"
+    fi
+    rm -f $ac_file
+    mv conftest.h $ac_file
+  fi
+fi; done
+
 
 
 exit 0
index 55a417cf8912b81bbad8a34b8b81f6b312b0fe45..97f991e7627240b40f8d87f2da01401e8bf38988 100644 (file)
@@ -3,6 +3,7 @@ dnl Author: Michael Patra   <micky@marie.physik.tu-berlin.de>
 dnl                         <patra@itp1.physik.tu-berlin.de>
 AC_REVISION([configure.in 1.00])
 AC_INIT(controls/edit.c)               
+AC_CONFIG_HEADER(include/config.h)
 AC_CONFIG_AUX_DIR(tools)
 
 # We want these before the checks, so the checks can modify their values.
@@ -14,21 +15,19 @@ dnl **** Command-line arguments ****
 
 AC_ARG_WITH(library,
 [  --with-library          build Wine as a library instead of an emulator],
-[AC_DEFINE(WINELIB) MAIN_TARGET="libwine.a"],[MAIN_TARGET="wine"])
+[OPTIONS="-DWINELIB" MAIN_TARGET="libwine.a"],
+[OPTIONS="" MAIN_TARGET="wine"])
 
 AC_ARG_WITH(dll,
 [  --with-dll              build Wine as a DLL instead of an emulator],
-[AC_DEFINE(WINELIB) AC_DEFINE(WINELIBDLL)
- MAIN_TARGET="libwine.so.1.0" CFLAGS="$CFLAGS -fPIC"])
-AC_SUBST(MAIN_TARGET)
+[OPTIONS="-DWINELIB -DWINELIBDLL" MAIN_TARGET="libwine.so.1.0" CFLAGS="$CFLAGS -fPIC"])
 
 AC_ARG_WITH(ipc,
 [  --with-ipc              use inter-process communication for DDE],
-[AC_DEFINE(CONFIG_IPC)])
+[OPTIONS="$OPTIONS -DCONFIG_IPC"])
 
-AC_ARG_WITH(malloc-debug,
-[  --with-malloc-debug     enable malloc() debugging],
-[AC_DEFINE(MALLOC_DEBUGGING)])
+AC_SUBST(MAIN_TARGET)
+AC_SUBST(OPTIONS)
 
 dnl **** Check for some programs and libraries ****
 
@@ -69,8 +68,7 @@ fi
 
 dnl **** Check for functions and header files ****
 
-AC_CHECK_FUNCS(tcgetattr usleep)
-AC_CHECK_HEADERS(stdlib.h)
+AC_CHECK_FUNCS(memmove tcgetattr usleep)
 AC_HEADER_STAT()
 AC_C_CONST()
 AC_TYPE_SIZE_T()
@@ -85,7 +83,6 @@ Make.rules
 Makefile
 controls/Makefile
 debugger/Makefile
-debugger/readline/Makefile
 files/Makefile
 if1632/Makefile
 ipc/Makefile
index 3b018a470ba7cc38c846ed7b2f5861b19410c3ac..6dde058392f0178d6780786eea2f5f836037f7aa 100644 (file)
@@ -1,6 +1,6 @@
-TOPSRC  = @top_srcdir@
-
-MODULE         = controls
+DEFS   = -D__WINE__
+TOPSRC = @top_srcdir@
+MODULE = controls
 
 C_SRCS = \
        button.c \
index 620f2887708ea217ed104835b2dd8965cc0af975..c0aca7e7cee49f54234d5102bd342d9cf71a7d75 100644 (file)
@@ -98,7 +98,7 @@ LRESULT ButtonWndProc(HWND32 hWnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
         if (!hbitmapCheckBoxes)
         {
             BITMAP16 bmp;
-            hbitmapCheckBoxes = LoadBitmap(0, MAKEINTRESOURCE(OBM_CHECKBOXES));
+            hbitmapCheckBoxes = LoadBitmap16(0, MAKEINTRESOURCE(OBM_CHECKBOXES));
             GetObject16( hbitmapCheckBoxes, sizeof(bmp), &bmp );
             checkBoxWidth  = bmp.bmWidth / 4;
             checkBoxHeight = bmp.bmHeight / 3;
index 7006776346fea14b73c232b6f1dea44081f89da2..989c0b23dc1ad5b6d950758d66cddb8ffdc49b4c 100644 (file)
@@ -51,7 +51,7 @@ static int COMBO_Init()
   BITMAP16 bm;
   
   dprintf_combo(stddeb, "COMBO_Init\n");
-  hComboBit = LoadBitmap(0, MAKEINTRESOURCE(OBM_COMBO));
+  hComboBit = LoadBitmap16(0, MAKEINTRESOURCE(OBM_COMBO));
   GetObject16( hComboBit, sizeof(bm), &bm );
   CBitHeight = bm.bmHeight;
   CBitWidth = bm.bmWidth;
index 9b01ae7deb843e36e49a16d1bec123d455dbfb3c..b9fa9dded290b21c3fc51aed3e79551f4e20001a 100644 (file)
@@ -154,7 +154,7 @@ LRESULT DesktopWndProc( HWND32 hwnd, UINT32 message,
        ExitWindows( 0, 0 ); 
 
     case WM_SETCURSOR:
-        return (LRESULT)SetCursor( LoadCursor( 0, IDC_ARROW ) );
+        return (LRESULT)SetCursor( LoadCursor16( 0, IDC_ARROW ) );
     }
     
     return 0;
index f96c3c17059ab4f61304d815f4a1527d124b2f5a..5dae7f95837bafde8109df9e0ae82ffa3f5f793e 100644 (file)
@@ -617,7 +617,7 @@ static INT EDIT_CallWordBreakProc(WND *wndPtr, char *s, INT index, INT count, IN
        EDITWORDBREAKPROC wbp = (EDITWORDBREAKPROC)EDIT_EM_GetWordBreakProc(wndPtr, 0, 0L);
 
        if (wbp) {
-               return CallWordBreakProc((FARPROC)wbp,
+               return CallWordBreakProc((FARPROC16)wbp,
                                (LONG)MAKE_SEGPTR(s), index, count, action);
        } else
                return EDIT_WordBreakProc(s, index, count, action);
@@ -2107,7 +2107,7 @@ static LRESULT EDIT_EM_Undo(WND *wndPtr, WPARAM wParam, LPARAM lParam)
 static LRESULT EDIT_WM_Char(WND *wndPtr, WPARAM wParam, LPARAM lParam)
 {
        char str[2];
-       char c = (char)wParam;
+       unsigned char c = (unsigned char)wParam;
 
        switch (c) {
        case '\r':
@@ -2739,7 +2739,7 @@ static LRESULT EDIT_WM_Paste(WND *wndPtr, WPARAM wParam, LPARAM lParam)
 static LRESULT EDIT_WM_SetCursor(WND *wndPtr, WPARAM wParam, LPARAM lParam)
 {
        if (LOWORD(lParam) == HTCLIENT) {
-               SetCursor(LoadCursor(0, IDC_IBEAM));
+               SetCursor(LoadCursor16(0, IDC_IBEAM));
                return -1L;
        } else
                return 0L;
index 49bd76237017a62c3e355fd0299aaaa5d6055e85..c88082927d0a73d24a01ad2b362672eba1d7c9bc 100644 (file)
@@ -136,12 +136,12 @@ BOOL MENU_Init()
 
       /* Load bitmaps */
 
-    if (!(hStdCheck = LoadBitmap( 0, MAKEINTRESOURCE(OBM_CHECK) )))
+    if (!(hStdCheck = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_CHECK) )))
        return FALSE;
     GetObject16( hStdCheck, sizeof(bm), &bm );
     check_bitmap_width = bm.bmWidth;
     check_bitmap_height = bm.bmHeight;
-    if (!(hStdMnArrow = LoadBitmap( 0, MAKEINTRESOURCE(OBM_MNARROW) )))
+    if (!(hStdMnArrow = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_MNARROW) )))
        return FALSE;
     GetObject16( hStdMnArrow, sizeof(bm), &bm );
     arrow_bitmap_width = bm.bmWidth;
@@ -2514,11 +2514,11 @@ HMENU LookupMenuHandle( HMENU hmenu, INT id )
 /**********************************************************************
  *         LoadMenu    (USER.150)
  */
-HMENU LoadMenu( HINSTANCE instance, SEGPTR name )
+HMENU16 LoadMenu16( HINSTANCE16 instance, SEGPTR name )
 {
-    HRSRC hRsrc;
-    HGLOBAL handle;
-    HMENU hMenu;
+    HRSRC16 hRsrc;
+    HGLOBAL16 handle;
+    HMENU16 hMenu;
 
     if (HIWORD(name))
     {
@@ -2534,16 +2534,38 @@ HMENU LoadMenu( HINSTANCE instance, SEGPTR name )
     /* check for Win32 module */
     instance = GetExePtr( instance );
     if (MODULE_GetPtr(instance)->flags & NE_FFLAGS_WIN32)
-        return WIN32_LoadMenuA(instance,PTR_SEG_TO_LIN(name));
+        return LoadMenu32A(instance,PTR_SEG_TO_LIN(name));
 
-    if (!(hRsrc = FindResource( instance, name, RT_MENU ))) return 0;
-    if (!(handle = LoadResource( instance, hRsrc ))) return 0;
-    hMenu = LoadMenuIndirect16( LockResource(handle) );
-    FreeResource( handle );
+    if (!(hRsrc = FindResource16( instance, name, RT_MENU ))) return 0;
+    if (!(handle = LoadResource16( instance, hRsrc ))) return 0;
+    hMenu = LoadMenuIndirect16(LockResource16(handle));
+    FreeResource16( handle );
     return hMenu;
 }
 
 
+/*****************************************************************
+ *        LoadMenu32A   (USER32.370)
+ */
+HMENU32 LoadMenu32A( HINSTANCE32 instance, LPCSTR name )
+{
+    HRSRC32 hrsrc = FindResource32A( instance, name, (LPSTR)RT_MENU );
+    if (!hrsrc) return 0;
+    return LoadMenuIndirect32A( (LPCVOID)LoadResource32( instance, hrsrc ));
+}
+
+
+/*****************************************************************
+ *        LoadMenu32W   (USER32.372)
+ */
+HMENU32 LoadMenu32W( HINSTANCE32 instance, LPCWSTR name )
+{
+    HRSRC32 hrsrc = FindResource32W( instance, name, (LPWSTR)RT_MENU );
+    if (!hrsrc) return 0;
+    return LoadMenuIndirect32W( (LPCVOID)LoadResource32( instance, hrsrc ));
+}
+
+
 /**********************************************************************
  *         LoadMenuIndirect16    (USER.220)
  */
index 04321df66dead6a8792bacec86688a142110932e..649c81f01d608f3e271077a9f8c552c7d29acf17 100644 (file)
@@ -79,18 +79,18 @@ static UINT uTrackingPos = 0;
  */
 static void SCROLL_LoadBitmaps(void)
 {
-    hUpArrow  = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROW));
-    hDnArrow  = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROW));
-    hLfArrow  = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROW));
-    hRgArrow  = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROW));
-    hUpArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROWD));
-    hDnArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROWD));
-    hLfArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROWD));
-    hRgArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWD));
-    hUpArrowI = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROWI));
-    hDnArrowI = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROWI));
-    hLfArrowI = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROWI));
-    hRgArrowI = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWI));
+    hUpArrow  = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROW));
+    hDnArrow  = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROW));
+    hLfArrow  = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROW));
+    hRgArrow  = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROW));
+    hUpArrowD = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROWD));
+    hDnArrowD = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROWD));
+    hLfArrowD = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROWD));
+    hRgArrowD = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWD));
+    hUpArrowI = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROWI));
+    hDnArrowI = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROWI));
+    hLfArrowI = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROWI));
+    hRgArrowI = LoadBitmap16((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWI));
 }
 
 
index aa8e1a7a9c776aebf94e06036cff52a52b035fe2..72ded6450db4a99c0d3932e8468d7e1a538f6565 100644 (file)
@@ -87,9 +87,9 @@ LRESULT StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
                CREATESTRUCT16 *cs = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam);
                if (cs->lpszName)
                 {
-                    HICON hicon = LoadIcon( cs->hInstance, cs->lpszName );
+                    HICON16 hicon = LoadIcon16( cs->hInstance, cs->lpszName );
                     if (!hicon)  /* Try OEM icon (FIXME: is this right?) */
-                        hicon = LoadIcon( 0, cs->lpszName );
+                        hicon = LoadIcon16( 0, cs->lpszName );
                     STATIC_SetIcon( wndPtr, hicon );
                 }
                 return 1;
@@ -136,7 +136,7 @@ LRESULT StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
        case WM_SETTEXT:
            if (style == SS_ICON)
                /* FIXME : should we also return the previous hIcon here ??? */
-                STATIC_SetIcon( wndPtr, LoadIcon( wndPtr->hInstance,
+                STATIC_SetIcon( wndPtr, LoadIcon16( wndPtr->hInstance,
                                                   (SEGPTR)lParam ));
             else
                 DEFWND_SetText( wndPtr, (LPSTR)PTR_SEG_TO_LIN(lParam) );
index 7205bc098db73455ba75433297dbb564dc0dc340..4f8a78c75f747da4c750ee2238e739685c0fe5cf 100644 (file)
 #include "module.h"
 #include "heap.h"
 
-static WNDCLASS16 WIDGETS_BuiltinClasses16[] =
+typedef struct
+{
+    UINT16     style;
+    INT16      wndExtra;
+    HBRUSH16   background;
+    LPCSTR     procName;
+    LPCSTR     className;
+} BUILTIN_CLASS_INFO16;
+
+static const BUILTIN_CLASS_INFO16 WIDGETS_BuiltinClasses16[] =
 {
     { CS_GLOBALCLASS | CS_PARENTDC,
-          (WNDPROC16)"StaticWndProc", 0, sizeof(STATICINFO),
-          0, 0, 0, 0, 0, (SEGPTR)"STATIC" },
+       sizeof(STATICINFO), 0, "StaticWndProc", "STATIC" },
     { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
-          (WNDPROC16)"ScrollBarWndProc", 0, sizeof(SCROLLINFO),
-          0, 0, 0, 0, 0, (SEGPTR)"SCROLLBAR" },
+      sizeof(SCROLLINFO), 0, "ScrollBarWndProc", "SCROLLBAR" },
     { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
-          (WNDPROC16)"ListBoxWndProc", 0, 8,
-          0, 0, 0, 0, 0, (SEGPTR)"LISTBOX" },
+      8, 0, "ListBoxWndProc", "LISTBOX" },
     { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
-          (WNDPROC16)"ComboBoxWndProc", 0, 8,
-          0, 0, 0, 0, 0, (SEGPTR)"COMBOBOX" },
+      8, 0, "ComboBoxWndProc", "COMBOBOX" },
     { CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS,
-          (WNDPROC16)"ComboLBoxWndProc", 0, 8,
-          0, 0, 0, 0, 0, (SEGPTR)"COMBOLBOX" },
+      8, 0, "ComboLBoxWndProc", "COMBOLBOX" },
     { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
-          (WNDPROC16)"EditWndProc", 0, sizeof(DWORD),
-          0, 0, 0, 0, 0, (SEGPTR)"EDIT" },
-    { CS_GLOBALCLASS | CS_SAVEBITS, (WNDPROC16)"PopupMenuWndProc", 0, 8,
-          0, 0, 0, 0, 0, (SEGPTR)POPUPMENU_CLASS_NAME },
-    { CS_GLOBALCLASS | CS_SAVEBITS, (WNDPROC16)"DefDlgProc", 0, DLGWINDOWEXTRA,
-          0, 0, 0, 0, 0, (SEGPTR)DIALOG_CLASS_NAME },
-    { CS_GLOBALCLASS, (WNDPROC16)"MDIClientWndProc", 0, sizeof(MDICLIENTINFO),
-          0, 0, 0, STOCK_LTGRAY_BRUSH, 0, (SEGPTR)"MDICLIENT" }
+      sizeof(DWORD), 0, "EditWndProc", "EDIT" },
+    { CS_GLOBALCLASS | CS_SAVEBITS,
+      sizeof(HMENU32), 0, "PopupMenuWndProc", POPUPMENU_CLASS_NAME },
+    { CS_GLOBALCLASS | CS_SAVEBITS,
+      DLGWINDOWEXTRA, 0, "DefDlgProc", DIALOG_CLASS_NAME },
+    { CS_GLOBALCLASS, sizeof(MDICLIENTINFO),
+      STOCK_LTGRAY_BRUSH, "MDIClientWndProc", "MDICLIENT" }
 };
 
 #define NB_BUILTIN_CLASSES16 \
@@ -67,20 +70,28 @@ BOOL WIDGETS_Init(void)
 {
     int i;
     char *name;
-    WNDCLASS16 *class16  = WIDGETS_BuiltinClasses16;
+    const BUILTIN_CLASS_INFO16 *info16 = WIDGETS_BuiltinClasses16;
+    WNDCLASS16 class16;
     WNDCLASS32A *class32 = WIDGETS_BuiltinClasses32;
 
     if (!(name = SEGPTR_ALLOC( 20 * sizeof(char) ))) return FALSE;
 
     /* Create 16-bit classes */
 
-    for (i = 0; i < NB_BUILTIN_CLASSES16; i++, class16++)
+    class16.cbClsExtra    = 0;
+    class16.hInstance     = 0;
+    class16.hIcon         = 0;
+    class16.hCursor       = LoadCursor16( 0, IDC_ARROW );
+    class16.lpszMenuName  = (SEGPTR)0;
+    class16.lpszClassName = SEGPTR_GET(name);
+    for (i = 0; i < NB_BUILTIN_CLASSES16; i++, info16++)
     {
-        strcpy( name, (char *)class16->lpszClassName );
-        class16->lpszClassName = SEGPTR_GET(name);
-        class16->hCursor = LoadCursor( 0, IDC_ARROW );
-        class16->lpfnWndProc = MODULE_GetWndProcEntry16( (char *)class16->lpfnWndProc );
-        if (!RegisterClass16( class16 )) return FALSE;
+        class16.style         = info16->style;
+        class16.lpfnWndProc   = (WNDPROC16)MODULE_GetWndProcEntry16( info16->procName );
+        class16.cbWndExtra    = info16->wndExtra;
+        class16.hbrBackground = info16->background;
+        strcpy( name, info16->className );
+        if (!RegisterClass16( &class16 )) return FALSE;
     }
 
     /* Create 32-bit classes */
@@ -90,7 +101,7 @@ BOOL WIDGETS_Init(void)
         /* Just to make sure the string is > 0x10000 */
         strcpy( name, (char *)class32->lpszClassName );
         class32->lpszClassName = name;
-        class32->hCursor = LoadCursor( 0, IDC_ARROW );
+        class32->hCursor = LoadCursor16( 0, IDC_ARROW );
         if (!RegisterClass32A( class32 )) return FALSE;
     }
 
index 3962061d6c23c6583725510e9c8f12f15ef91869..640932e84e71a39c1dae90ad5d2406c05c3aa6e2 100644 (file)
@@ -1,11 +1,11 @@
-TOPSRC     = @top_srcdir@
-EXTRA_DEFS = -DUSE_READLINE
-
+DEFS   = -D__WINE__
+TOPSRC = @top_srcdir@
 MODULE = debugger
 
 C_SRCS = \
        break.c \
        db_disasm.c \
+       editline.c \
        hash.c \
        info.c \
        memory.c \
index 9a006a28e8eb4987402d600ddddabf5862045bb8..b94dee926f3f2814c712b39020831ae943f6a4ff 100644 (file)
@@ -205,7 +205,7 @@ expr:
 
 void 
 issue_prompt(){
-#ifndef USE_READLINE
+#ifdef DONT_USE_READLINE
        fprintf(stderr,"Wine-dbg>");
 #endif
 }
index abd10bff070d7a3295c75801ee23bb751cc4640e..71b2215b65abd376e81394ddd4105377a542038d 100644 (file)
@@ -1,8 +1,7 @@
-/* Lexical scanner for command line parsing in the Wine debugger
+/*
+ * Lexical scanner for command line parsing
  *
- * Version 1.0
- * Eric Youngdale
- * 9/93
+ * Copyright 1993 Eric Youngdale
  */
 
 %{
 #include "xmalloc.h"
 #include "y.tab.h"
 
-#ifdef USE_READLINE
+#ifndef DONT_USE_READLINE
 #undef YY_INPUT
 #define YY_INPUT(buf,result,max_size) \
        if ( (result = dbg_read((char *) buf, max_size )) < 0 ) \
            YY_FATAL_ERROR( "read() in flex scanner failed" );
-#endif
 
 extern char * readline(char *);
 extern void add_history(char *);
 static int dbg_read(char * buf, int size);
 static char * make_symbol(char *);
 void flush_symbols();
+
+#endif  /* DONT_USE_READLINE */
+
 static int syntax_error;
 %}
 
@@ -136,7 +137,8 @@ mode                                { return tMODE; }
 int yywrap(void) { return 1; }
 #endif
 
-#ifdef USE_READLINE
+#ifndef DONT_USE_READLINE
+
 #ifndef whitespace
 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
 #endif
@@ -216,10 +218,10 @@ char * make_symbol(char * symbol){
         return local_symbols[next_symbol++] = xstrdup(symbol);
 }
 
-void
-flush_symbols(){
+void flush_symbols()
+{
        while(--next_symbol>= 0) free(local_symbols[next_symbol]);
        next_symbol = 0;
 }
 
-#endif
+#endif  /* DONT_USE_READLINE */
similarity index 79%
rename from debugger/readline/editline.c
rename to debugger/editline.c
index eea22d76a48372ea2b52aac171fd81bc3a58bb85..51e7046d617ce896ccb33d98a51f1a8e46bdd5d3 100644 (file)
@@ -1,10 +1,38 @@
-/*  $Revision: 1.4 $
-**
-**  Main editing routines for editline library.
-*/
-#include "editline.h"
+/*
+ * Line-editing routines
+ *
+ * Copyright 1992 Simmule Turner and Rich Salz.  All rights reserved.
+ *
+ *  
+ *  This software is not subject to any license of the American Telephone
+ *  and Telegraph Company or of the Regents of the University of California.
+ *  
+ *  Permission is granted to anyone to use this software for any purpose on
+ *  any computer system, and to alter it and redistribute it freely, subject
+ *  to the following restrictions:
+ *  1. The authors are not responsible for the consequences of use of this
+ *     software, no matter how awful, even if they arise from flaws in it.
+ *  2. The origin of this software must not be misrepresented, either by
+ *     explicit claim or by omission.  Since few users ever read sources,
+ *     credits must appear in the documentation.
+ *  3. Altered versions must be plainly marked as such, and must not be
+ *     misrepresented as being the original software.  Since few users
+ *     ever read sources, credits must appear in the documentation.
+ *  4. This notice may not be removed or altered.
+ *
+ * The code was heavily simplified for inclusion in Wine. -- AJ
+ */
+
+#include "config.h"
 #include <ctype.h>
+#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+typedef unsigned char  CHAR;
 
 /*
 **  Manifest constants.
 #if    !defined(HIST_SIZE)
 #define HIST_SIZE      20
 #endif /* !defined(HIST_SIZE) */
+#define CRLF   "\r\n"
+#define MEM_INC                64
+#define SCREEN_INC     256
+
+#define DISPOSE(p)     free((char *)(p))
+#define NEW(T, c)      \
+       ((T *)malloc((unsigned int)(sizeof (T) * (c))))
+#define RENEW(p, T, c) \
+       (p = (T *)realloc((char *)(p), (unsigned int)(sizeof (T) * (c))))
+#define COPYFROMTO(new, p, len)        \
+       (void)memcpy((char *)(new), (char *)(p), (int)(len))
 
 /*
 **  Command status codes.
@@ -57,35 +96,35 @@ typedef struct _HISTORY {
 /*
 **  Globals.
 */
-int            rl_eof;
-int            rl_erase;
-int            rl_intr;
-int            rl_kill;
-
-STATIC CHAR            NIL[] = "";
-STATIC CONST CHAR      *Input = NIL;
-STATIC CHAR            *Line;
-STATIC CONST char      *Prompt;
-STATIC CHAR            *Yanked;
-STATIC char            *Screen;
-STATIC char            NEWLINE[]= CRLF;
-STATIC HISTORY         H;
-int            rl_quit;
-STATIC int             Repeat;
-STATIC int             End;
-STATIC int             Mark;
-STATIC int             OldPoint;
-STATIC int             Point;
-STATIC int             PushBack;
-STATIC int             Pushed;
-STATIC KEYMAP          Map[33];
-STATIC KEYMAP          MetaMap[16];
-STATIC SIZE_T          Length;
-STATIC SIZE_T          ScreenCount;
-STATIC SIZE_T          ScreenSize;
-STATIC char            *backspace;
-STATIC int             TTYwidth;
-STATIC int             TTYrows;
+static int             rl_eof;
+static int             rl_erase;
+static int             rl_intr;
+static int             rl_kill;
+
+static CHAR            NIL[] = "";
+static const CHAR      *Input = NIL;
+static CHAR            *Line;
+static const char      *Prompt;
+static CHAR            *Yanked;
+static char            *Screen;
+static char            NEWLINE[]= CRLF;
+static HISTORY         H;
+static int             rl_quit;
+static int             Repeat;
+static int             End;
+static int             Mark;
+static int             OldPoint;
+static int             Point;
+static int             PushBack;
+static int             Pushed;
+static KEYMAP          Map[33];
+static KEYMAP          MetaMap[16];
+static size_t          Length;
+static size_t          ScreenCount;
+static size_t          ScreenSize;
+static char            *backspace;
+static int             TTYwidth;
+static int             TTYrows;
 
 /* Display print 8-bit chars as `M-x' or as the actual 8-bit char? */
 int            rl_meta_chars = 1;
@@ -93,7 +132,7 @@ int          rl_meta_chars = 1;
 /*
 **  Declarations.
 */
-STATIC CHAR    *editinput();
+static CHAR    *editinput();
 extern int     read();
 extern int     write();
 #if    defined(USE_TERMCAP)
@@ -106,7 +145,80 @@ extern int tgetent();
 **  TTY input/output functions.
 */
 
-STATIC void
+#ifdef HAVE_TCGETATTR
+#include <termios.h>
+
+static void
+rl_ttyset(Reset)
+    int                                Reset;
+{
+    static struct termios      old;
+    struct termios             new;
+
+    if (Reset == 0) {
+       (void)tcgetattr(0, &old);
+       rl_erase = old.c_cc[VERASE];
+       rl_kill = old.c_cc[VKILL];
+       rl_eof = old.c_cc[VEOF];
+       rl_intr = old.c_cc[VINTR];
+       rl_quit = old.c_cc[VQUIT];
+
+       new = old;
+       new.c_cc[VINTR] = -1;
+       new.c_cc[VQUIT] = -1;
+       new.c_lflag &= ~(ECHO | ICANON);
+       new.c_iflag &= ~(ISTRIP | INPCK);
+       new.c_cc[VMIN] = 1;
+       new.c_cc[VTIME] = 0;
+       (void)tcsetattr(0, TCSANOW, &new);
+    }
+    else
+       (void)tcsetattr(0, TCSANOW, &old);
+}
+
+#else  /* HAVE_TCGETATTR */
+
+static void
+rl_ttyset(Reset)
+    int                                Reset;
+{
+    static struct sgttyb       old_sgttyb;
+    static struct tchars       old_tchars;
+    struct sgttyb              new_sgttyb;
+    struct tchars              new_tchars;
+
+    if (Reset == 0) {
+       (void)ioctl(0, TIOCGETP, &old_sgttyb);
+       rl_erase = old_sgttyb.sg_erase;
+       rl_kill = old_sgttyb.sg_kill;
+
+       (void)ioctl(0, TIOCGETC, &old_tchars);
+       rl_eof = old_tchars.t_eofc;
+       rl_intr = old_tchars.t_intrc;
+       rl_quit = old_tchars.t_quitc;
+
+       new_sgttyb = old_sgttyb;
+       new_sgttyb.sg_flags &= ~ECHO;
+       new_sgttyb.sg_flags |= RAW;
+#if    defined(PASS8)
+       new_sgttyb.sg_flags |= PASS8;
+#endif /* defined(PASS8) */
+       (void)ioctl(0, TIOCSETP, &new_sgttyb);
+
+       new_tchars = old_tchars;
+       new_tchars.t_intrc = -1;
+       new_tchars.t_quitc = -1;
+       (void)ioctl(0, TIOCSETC, &new_tchars);
+    }
+    else {
+       (void)ioctl(0, TIOCSETP, &old_sgttyb);
+       (void)ioctl(0, TIOCSETC, &old_tchars);
+    }
+}
+
+#endif /* HAVE_TCGETATTR */
+
+static void
 TTYflush()
 {
     if (ScreenCount) {
@@ -115,7 +227,7 @@ TTYflush()
     }
 }
 
-STATIC void
+static void
 TTYput(c)
     CHAR       c;
 {
@@ -126,7 +238,7 @@ TTYput(c)
     }
 }
 
-STATIC void
+static void
 TTYputs(p)
     CHAR       *p;
 {
@@ -134,7 +246,7 @@ TTYputs(p)
        TTYput(*p++);
 }
 
-STATIC void
+static void
 TTYshow(c)
     CHAR       c;
 {
@@ -155,7 +267,7 @@ TTYshow(c)
        TTYput(c);
 }
 
-STATIC void
+static void
 TTYstring(p)
     CHAR       *p;
 {
@@ -163,7 +275,7 @@ TTYstring(p)
        TTYshow(*p++);
 }
 
-STATIC unsigned int
+static unsigned int
 TTYget()
 {
     CHAR       c;
@@ -175,12 +287,12 @@ TTYget()
     }
     if (*Input)
        return *Input++;
-    return read(0, &c, (SIZE_T)1) == 1 ? c : EOF;
+    return read(0, &c, (size_t)1) == 1 ? c : EOF;
 }
 
 #define TTYback()      (backspace ? TTYputs((CHAR *)backspace) : TTYput('\b'))
 
-STATIC void
+static void
 TTYbackn(n)
     int                n;
 {
@@ -188,7 +300,7 @@ TTYbackn(n)
        TTYback();
 }
 
-STATIC void
+static void
 TTYinfo()
 {
     static int         init;
@@ -244,7 +356,7 @@ TTYinfo()
 \f
 
 
-STATIC void
+static void
 reposition()
 {
     int                i;
@@ -256,7 +368,7 @@ reposition()
        TTYshow(*p);
 }
 
-STATIC void
+static void
 left(Change)
     STATUS     Change;
 {
@@ -273,7 +385,7 @@ left(Change)
        Point--;
 }
 
-STATIC void
+static void
 right(Change)
     STATUS     Change;
 {
@@ -282,7 +394,7 @@ right(Change)
        Point++;
 }
 
-STATIC STATUS
+static STATUS
 ring_bell()
 {
     TTYput('\07');
@@ -290,7 +402,7 @@ ring_bell()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 do_macro(c)
     unsigned int       c;
 {
@@ -308,7 +420,7 @@ do_macro(c)
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 do_forward(move)
     STATUS     move;
 {
@@ -333,7 +445,7 @@ do_forward(move)
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 do_case(type)
     CASE       type;
 {
@@ -362,19 +474,19 @@ do_case(type)
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 case_down_word()
 {
     return do_case(TOlower);
 }
 
-STATIC STATUS
+static STATUS
 case_up_word()
 {
     return do_case(TOupper);
 }
 
-STATIC void
+static void
 ceol()
 {
     int                extras;
@@ -398,7 +510,7 @@ ceol()
        TTYback();
 }
 
-STATIC void
+static void
 clear_line()
 {
     Point = -strlen(Prompt);
@@ -409,11 +521,11 @@ clear_line()
     Line[0] = '\0';
 }
 
-STATIC STATUS
+static STATUS
 insert_string(p)
     CHAR       *p;
 {
-    SIZE_T     len;
+    size_t     len;
     int                i;
     CHAR       *new;
     CHAR       *q;
@@ -442,19 +554,19 @@ insert_string(p)
 }
 \f
 
-STATIC CHAR *
+static CHAR *
 next_hist()
 {
     return H.Pos >= H.Size - 1 ? NULL : H.Lines[++H.Pos];
 }
 
-STATIC CHAR *
+static CHAR *
 prev_hist()
 {
     return H.Pos == 0 ? NULL : H.Lines[--H.Pos];
 }
 
-STATIC STATUS
+static STATUS
 do_insert_hist(p)
     CHAR       *p;
 {
@@ -467,7 +579,7 @@ do_insert_hist(p)
     return insert_string(p);
 }
 
-STATIC STATUS
+static STATUS
 do_hist(move)
     CHAR       *(*move)();
 {
@@ -482,25 +594,25 @@ do_hist(move)
     return do_insert_hist(p);
 }
 
-STATIC STATUS
+static STATUS
 h_next()
 {
     return do_hist(next_hist);
 }
 
-STATIC STATUS
+static STATUS
 h_prev()
 {
     return do_hist(prev_hist);
 }
 
-STATIC STATUS
+static STATUS
 h_first()
 {
     return do_insert_hist(H.Lines[H.Pos = 0]);
 }
 
-STATIC STATUS
+static STATUS
 h_last()
 {
     return do_insert_hist(H.Lines[H.Pos = H.Size - 1]);
@@ -509,7 +621,7 @@ h_last()
 /*
 **  Return zero if pat appears as a substring in text.
 */
-STATIC int
+static int
 substrcmp(text, pat, len)
     char       *text;
     char       *pat;
@@ -525,7 +637,7 @@ substrcmp(text, pat, len)
     return 1;
 }
 
-STATIC CHAR *
+static CHAR *
 search_hist(search, move)
     CHAR       *search;
     CHAR       *(*move)();
@@ -566,11 +678,11 @@ search_hist(search, move)
     return NULL;
 }
 
-STATIC STATUS
+static STATUS
 h_search()
 {
     static int Searching;
-    CONST char *old_prompt;
+    const char *old_prompt;
     CHAR       *(*move)();
     CHAR       *p;
 
@@ -592,7 +704,7 @@ h_search()
     return do_insert_hist(p);
 }
 
-STATIC STATUS
+static STATUS
 fd_char()
 {
     int                i;
@@ -606,7 +718,7 @@ fd_char()
     return CSstay;
 }
 
-STATIC void
+static void
 save_yank(begin, i)
     int                begin;
     int                i;
@@ -619,13 +731,13 @@ save_yank(begin, i)
     if (i < 1)
        return;
 
-    if ((Yanked = NEW(CHAR, (SIZE_T)i + 1)) != NULL) {
+    if ((Yanked = NEW(CHAR, (size_t)i + 1)) != NULL) {
        COPYFROMTO(Yanked, &Line[begin], i);
        Yanked[i] = '\0';
     }
 }
 
-STATIC STATUS
+static STATUS
 delete_string(count)
     int                count;
 {
@@ -668,7 +780,7 @@ delete_string(count)
     return CSmove;
 }
 
-STATIC STATUS
+static STATUS
 bk_char()
 {
     int                i;
@@ -683,7 +795,7 @@ bk_char()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 bk_del_char()
 {
     int                i;
@@ -698,7 +810,7 @@ bk_del_char()
     return delete_string(i);
 }
 
-STATIC STATUS
+static STATUS
 redisplay()
 {
     TTYputs((CHAR *)NEWLINE);
@@ -707,7 +819,7 @@ redisplay()
     return CSmove;
 }
 
-STATIC STATUS
+static STATUS
 kill_line()
 {
     int                i;
@@ -733,7 +845,7 @@ kill_line()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 insert_char(c)
     int                c;
 {
@@ -760,7 +872,7 @@ insert_char(c)
     return s;
 }
 
-STATIC STATUS
+static STATUS
 meta()
 {
     unsigned int       c;
@@ -768,7 +880,6 @@ meta()
 
     if ((c = TTYget()) == EOF)
        return CSeof;
-#if    defined(ANSI_ARROWS)
     /* Also include VT-100 arrows. */
     if (c == '[' || c == 'O')
        switch (c = TTYget()) {
@@ -779,7 +890,6 @@ meta()
        case 'C':       return fd_char();
        case 'D':       return bk_char();
        }
-#endif /* defined(ANSI_ARROWS) */
 
     if (isdigit(c)) {
        for (Repeat = c - '0'; (c = TTYget()) != EOF && isdigit(c); )
@@ -798,7 +908,7 @@ meta()
     return ring_bell();
 }
 
-STATIC STATUS
+static STATUS
 emacs(c)
     unsigned int       c;
 {
@@ -820,7 +930,7 @@ emacs(c)
     return s;
 }
 
-STATIC STATUS
+static STATUS
 TTYspecial(c)
     unsigned int       c;
 {
@@ -848,7 +958,7 @@ TTYspecial(c)
     return CSdispatch;
 }
 
-STATIC CHAR *
+static CHAR *
 editinput()
 {
     unsigned int       c;
@@ -886,7 +996,7 @@ editinput()
     return NULL;
 }
 
-STATIC void
+static void
 hist_add(p)
     CHAR       *p;
 {
@@ -905,24 +1015,9 @@ hist_add(p)
     H.Pos = H.Size - 1;
 }
 
-/*
-**  For compatibility with FSF readline.
-*/
-/* ARGSUSED0 */
-void
-rl_reset_terminal(p)
-    char       *p;
-{
-}
-
-void
-rl_initialize()
-{
-}
-
 char *
 readline(prompt)
-    CONST char *prompt;
+    const char *prompt;
 {
     CHAR       *line;
 
@@ -965,7 +1060,7 @@ add_history(p)
 }
 \f
 
-STATIC STATUS
+static STATUS
 beg_line()
 {
     if (Point) {
@@ -975,13 +1070,13 @@ beg_line()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 del_char()
 {
     return delete_string(Repeat == NO_ARG ? 1 : Repeat);
 }
 
-STATIC STATUS
+static STATUS
 end_line()
 {
     if (Point != End) {
@@ -991,14 +1086,14 @@ end_line()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 accept_line()
 {
     Line[End] = '\0';
     return CSdone;
 }
 
-STATIC STATUS
+static STATUS
 transpose()
 {
     CHAR       c;
@@ -1016,7 +1111,7 @@ transpose()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 quote()
 {
     unsigned int       c;
@@ -1024,7 +1119,7 @@ quote()
     return (c = TTYget()) == EOF ? CSeof : insert_char((int)c);
 }
 
-STATIC STATUS
+static STATUS
 wipe()
 {
     int                i;
@@ -1042,14 +1137,14 @@ wipe()
     return delete_string(Mark - Point);
 }
 
-STATIC STATUS
+static STATUS
 mk_set()
 {
     Mark = Point;
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 exchange()
 {
     unsigned int       c;
@@ -1065,7 +1160,7 @@ exchange()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 yank()
 {
     if (Yanked && *Yanked)
@@ -1073,7 +1168,7 @@ yank()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 copy_region()
 {
     if (Mark > End)
@@ -1087,7 +1182,7 @@ copy_region()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 move_to_char()
 {
     unsigned int       c;
@@ -1104,13 +1199,13 @@ move_to_char()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 fd_word()
 {
     return do_forward(CSmove);
 }
 
-STATIC STATUS
+static STATUS
 fd_kill_word()
 {
     int                i;
@@ -1124,7 +1219,7 @@ fd_kill_word()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 bk_word()
 {
     int                i;
@@ -1145,7 +1240,7 @@ bk_word()
     return CSstay;
 }
 
-STATIC STATUS
+static STATUS
 bk_kill_word()
 {
     (void)bk_word();
@@ -1154,7 +1249,7 @@ bk_kill_word()
     return CSstay;
 }
 
-STATIC int
+static int
 argify(line, avp)
     CHAR       *line;
     CHAR       ***avp;
@@ -1200,7 +1295,7 @@ argify(line, avp)
     return ac;
 }
 
-STATIC STATUS
+static STATUS
 last_argument()
 {
     CHAR       **av;
@@ -1226,7 +1321,7 @@ last_argument()
     return s;
 }
 
-STATIC KEYMAP  Map[33] = {
+static KEYMAP  Map[33] = {
     {  CTL('@'),       ring_bell       },
     {  CTL('A'),       beg_line        },
     {  CTL('B'),       bk_char         },
@@ -1260,7 +1355,7 @@ STATIC KEYMAP     Map[33] = {
     {  0,              NULL            }
 };
 
-STATIC KEYMAP  MetaMap[16]= {
+static KEYMAP  MetaMap[16]= {
     {  CTL('H'),       bk_kill_word    },
     {  DEL,            bk_kill_word    },
     {  ' ',            mk_set  },
diff --git a/debugger/readline/Makefile.in b/debugger/readline/Makefile.in
deleted file mode 100644 (file)
index d3b0cad..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-TOPSRC     = @top_srcdir@
-EXTRA_DEFS = -DHIDE -DANSI_ARROWS
-
-MODULE = readline
-
-C_SRCS = editline.c sysunix.c
-
-all: $(MODULE).o
-
-@MAKE_RULES@
-
-### Dependencies:
diff --git a/debugger/readline/README b/debugger/readline/README
deleted file mode 100644 (file)
index c609789..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-$Revision: 1.5 $
-
-This is a line-editing library.  It can be linked into almost any
-program to provide command-line editing and recall.
-
-It is call-compatible with the FSF readline library, but it is a
-fraction of the size (and offers fewer features).  It does not use
-standard I/O.  It is distributed under a "C News-like" copyright.
-
-Configuration is done in the Makefile.  Type "make testit" to get
-a small slow shell for testing.
-
-An earlier version was distributed with Byron's rc.  Principal
-changes over that version include:
-       Faster.
-       Is eight-bit clean (thanks to brendan@cs.widener.edu)
-       Written in K&R C, but ANSI compliant (gcc all warnings)
-       Propagates EOF properly; rc trip test now passes
-       Doesn't need or use or provide memmove.
-       More robust
-       Calling sequence changed to be compatible with readline.
-       Test program, new manpage, better configuration
-       More system-independant; includes Unix and OS-9 support.
-
-Enjoy,
-       Rich $alz
-       <rsalz@osf.org>
-
- Copyright 1992 Simmule Turner and Rich Salz.  All rights reserved.
-
- This software is not subject to any license of the American Telephone
- and Telegraph Company or of the Regents of the University of California.
-
- Permission is granted to anyone to use this software for any purpose on
- any computer system, and to alter it and redistribute it freely, subject
- to the following restrictions:
- 1. The authors are not responsible for the consequences of use of this
-    software, no matter how awful, even if they arise from flaws in it.
- 2. The origin of this software must not be misrepresented, either by
-    explicit claim or by omission.  Since few users ever read sources,
-    credits must appear in the documentation.
- 3. Altered versions must be plainly marked as such, and must not be
-    misrepresented as being the original software.  Since few users
-    ever read sources, credits must appear in the documentation.
- 4. This notice may not be removed or altered.
diff --git a/debugger/readline/editline.3 b/debugger/readline/editline.3
deleted file mode 100644 (file)
index 1d851ed..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-.\" $Revision: 1.1 $
-.TH EDITLINE 3
-.SH NAME
-editline \- command-line editing library with history
-.SH SYNOPSIS
-.nf
-.B "char *"
-.B "readline(prompt)"
-.B "     char  *prompt;"
-
-.B "void"
-.B "add_history(line)"
-.B "    char   *line;"
-.fi
-.SH DESCRIPTION
-.I Editline
-is a library that provides an line-editing interface with text recall.
-It is intended to be compatible with the
-.I readline
-library provided by the Free Software Foundation, but much smaller.
-The bulk of this manual page describes the user interface.
-.PP
-The
-.I readline
-routine returns a line of text with the trailing newline removed.
-The data is returned in a buffer allocated with
-.IR malloc (3),
-so the space should be released with
-.IR free (3)
-when the calling program is done with it.
-Before accepting input from the user, the specified
-.I prompt
-is displayed on the terminal.
-.PP
-The
-.I add_history
-routine makes a copy of the specified
-.I line
-and adds it to the internal history list.
-.SS "User Interface"
-A program that uses this library provides a simple emacs-like editing
-interface to its users.
-A line may be edited before it is sent to the calling program by typing either
-control characters or escape sequences.
-A control character, shown as a caret followed by a letter, is typed by
-holding down the ``control'' key while the letter is typed.
-For example, ``^A'' is a control-A.
-An escape sequence is entered by typing the ``escape'' key followed by one or
-more characters.
-The escape key is abbreviated as ``ESC.''
-Note that unlike control keys, case matters in escape sequences; ``ESC\ F''
-is not the same as ``ESC\ f''.
-.PP
-An editing command may be typed anywhere on the line, not just at the
-beginning.
-In addition, a return may also be typed anywhere on the line, not just at
-the end.
-.PP
-Most editing commands may be given a repeat count,
-.IR n ,
-where
-.I n
-is a number.
-To enter a repeat count, type the escape key, the number, and then
-the command to execute.
-For example, ``ESC\ 4\ ^f'' moves forward four characters.
-If a command may be given a repeat count then the text ``[n]'' is given at the
-end of its description.
-.PP
-The following control characters are accepted:
-.RS
-.nf
-.ta \w'ESC DEL  'u
-^A     Move to the beginning of the line
-^B     Move left (backwards) [n]
-^D     Delete character [n]
-^E     Move to end of line
-^F     Move right (forwards) [n]
-^G     Ring the bell
-^H     Delete character before cursor (backspace key) [n]
-^I     Complete filename (tab key); see below
-^J     Done with line (return key)
-^K     Kill to end of line (or column [n])
-^L     Redisplay line
-^M     Done with line (alternate return key)
-^N     Get next line from history [n]
-^P     Get previous line from history [n]
-^R     Search backward (forward if [n]) through history for text;
-\&     must start line if text begins with an uparrow
-^T     Transpose characters
-^V     Insert next character, even if it is an edit command
-^W     Wipe to the mark
-^X^X   Exchange current location and mark
-^Y     Yank back last killed text
-^[     Start an escape sequence (escape key)
-^]c    Move forward to next character ``c''
-^?     Delete character before cursor (delete key) [n]
-.fi
-.RE
-.PP
-The following escape sequences are provided.
-.RS
-.nf
-.ta \w'ESC DEL  'u
-ESC\ ^H        Delete previous word (backspace key) [n]
-ESC\ DEL       Delete previous word (delete key) [n]
-ESC\ SP        Set the mark (space key); see ^X^X and ^Y above
-ESC\ \.        Get the last (or [n]'th) word from previous line
-ESC\ \?        Show possible completions; see below
-ESC\ < Move to start of history
-ESC\ > Move to end of history
-ESC\ b Move backward a word [n]
-ESC\ d Delete word under cursor [n]
-ESC\ f Move forward a word [n]
-ESC\ l Make word lowercase [n]
-ESC\ u Make word uppercase [n]
-ESC\ y Yank back last killed text
-ESC\ v Show library version
-ESC\ w Make area up to mark yankable
-ESC\ nn        Set repeat count to the number nn
-ESC\ C Read from environment variable ``_C_'', where C is
-\&     an uppercase letter
-.fi
-.RE
-.PP
-The
-.I editline
-library has a small macro facility.
-If you type the escape key followed by an uppercase letter,
-.IR C ,
-then the contents of the environment variable
-.I _C_
-are read in as if you had typed them at the keyboard.
-For example, if the variable
-.I _L_
-contains the following:
-.RS
-^A^Kecho '^V^[[H^V^[[2J'^M
-.RE
-Then typing ``ESC L'' will move to the beginning of the line, kill the
-entire line, enter the echo command needed to clear the terminal (if your
-terminal is like a VT-100), and send the line back to the shell.
-.PP
-The
-.I editline
-library also does filename completion.
-Suppose the root directory has the following files in it:
-.RS
-.nf
-.ta \w'core   'u
-bin    vmunix
-core   vmunix.old
-.fi
-.RE
-If you type ``rm\ /v'' and then the tab key.
-.I Editline
-will then finish off as much of the name as possible by adding ``munix''.
-Because the name is not unique, it will then beep.
-If you type the escape key and a question mark, it will display the
-two choices.
-If you then type a period and a tab, the library will finish off the filename
-for you:
-.RS
-.nf
-.RI "rm /v[TAB]" munix .TAB old
-.fi
-.RE
-The tab key is shown by ``[TAB]'' and the automatically-entered text
-is shown in italics.
-.SH "BUGS AND LIMITATIONS"
-Cannot handle lines more than 80 columns.
-.SH AUTHORS
-Simmule R. Turner <uunet.uu.net!capitol!sysgo!simmy>
-and Rich $alz <rsalz@osf.org>.
-Original manual page by DaviD W. Sanderson <dws@ssec.wisc.edu>.
diff --git a/debugger/readline/editline.h b/debugger/readline/editline.h
deleted file mode 100644 (file)
index fa16f3b..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*  $Revision: 1.3 $
-**
-**  Internal header file for editline library.
-*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-
-#define CRLF   "\r\n"
-
-
-#define SIZE_T size_t
-#define CONST  const
-
-typedef unsigned char  CHAR;
-
-#if    defined(HIDE)
-#define STATIC static
-#else
-#define STATIC /* NULL */
-#endif /* !defined(HIDE) */
-
-#define MEM_INC                64
-#define SCREEN_INC     256
-
-#define DISPOSE(p)     free((char *)(p))
-#define NEW(T, c)      \
-       ((T *)malloc((unsigned int)(sizeof (T) * (c))))
-#define RENEW(p, T, c) \
-       (p = (T *)realloc((char *)(p), (unsigned int)(sizeof (T) * (c))))
-#define COPYFROMTO(new, p, len)        \
-       (void)memcpy((char *)(new), (char *)(p), (int)(len))
-
-
-/*
-**  Variables and routines internal to this package.
-*/
-extern int     rl_eof;
-extern int     rl_erase;
-extern int     rl_intr;
-extern int     rl_kill;
-extern int     rl_quit;
-extern char    *rl_complete();
-extern int     rl_list_possib();
-extern void    rl_ttyset();
-extern void    rl_add_slash();
diff --git a/debugger/readline/sysunix.c b/debugger/readline/sysunix.c
deleted file mode 100644 (file)
index 010744e..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*  $Revision: 1.1 $
-**
-**  Unix system-dependant routines for editline library.
-*/
-#include "editline.h"
-
-#if    defined(HAVE_TCGETATTR)
-#include <termios.h>
-
-void
-rl_ttyset(Reset)
-    int                                Reset;
-{
-    static struct termios      old;
-    struct termios             new;
-
-    if (Reset == 0) {
-       (void)tcgetattr(0, &old);
-       rl_erase = old.c_cc[VERASE];
-       rl_kill = old.c_cc[VKILL];
-       rl_eof = old.c_cc[VEOF];
-       rl_intr = old.c_cc[VINTR];
-       rl_quit = old.c_cc[VQUIT];
-
-       new = old;
-       new.c_cc[VINTR] = -1;
-       new.c_cc[VQUIT] = -1;
-       new.c_lflag &= ~(ECHO | ICANON);
-       new.c_iflag &= ~(ISTRIP | INPCK);
-       new.c_cc[VMIN] = 1;
-       new.c_cc[VTIME] = 0;
-       (void)tcsetattr(0, TCSANOW, &new);
-    }
-    else
-       (void)tcsetattr(0, TCSANOW, &old);
-}
-
-#else
-#include <sgtty.h>
-
-void
-rl_ttyset(Reset)
-    int                                Reset;
-{
-    static struct sgttyb       old_sgttyb;
-    static struct tchars       old_tchars;
-    struct sgttyb              new_sgttyb;
-    struct tchars              new_tchars;
-
-    if (Reset == 0) {
-       (void)ioctl(0, TIOCGETP, &old_sgttyb);
-       rl_erase = old_sgttyb.sg_erase;
-       rl_kill = old_sgttyb.sg_kill;
-
-       (void)ioctl(0, TIOCGETC, &old_tchars);
-       rl_eof = old_tchars.t_eofc;
-       rl_intr = old_tchars.t_intrc;
-       rl_quit = old_tchars.t_quitc;
-
-       new_sgttyb = old_sgttyb;
-       new_sgttyb.sg_flags &= ~ECHO;
-       new_sgttyb.sg_flags |= RAW;
-#if    defined(PASS8)
-       new_sgttyb.sg_flags |= PASS8;
-#endif /* defined(PASS8) */
-       (void)ioctl(0, TIOCSETP, &new_sgttyb);
-
-       new_tchars = old_tchars;
-       new_tchars.t_intrc = -1;
-       new_tchars.t_quitc = -1;
-       (void)ioctl(0, TIOCSETC, &new_tchars);
-    }
-    else {
-       (void)ioctl(0, TIOCSETP, &old_sgttyb);
-       (void)ioctl(0, TIOCSETC, &old_tchars);
-    }
-}
-#endif /* defined(HAVE_TCGETATTR) */
-
-void
-rl_add_slash(path, p)
-    char       *path;
-    char       *p;
-{
-    struct stat        Sb;
-
-    if (stat(path, &Sb) >= 0)
-       (void)strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ");
-}
index cf17c1c2e029f18ecad15d00788708fb4928e081..ae0a95126d877afdc4fe21c796a953c1259bf131 100644 (file)
@@ -1,5 +1,8 @@
-TOPSRC = @top_srcdir@
-MODULE = files
+prefix     = @prefix@
+sysconfdir = @sysconfdir@
+DEFS       = -D__WINE__  -DETCDIR=\"$(sysconfdir)\"
+TOPSRC     = @top_srcdir@
+MODULE     = files
 
 C_SRCS = \
        directory.c \
index 3264c08f7df5a24df8ff70a243a8c306c56cf485..7d30397d6b44cdc26e8badd62809b01b660a10ee 100644 (file)
@@ -848,7 +848,7 @@ HFILE _lcreat( LPCSTR path, INT32 attr )
 /***********************************************************************
  *           _lcreat_uniq   (Not a Windows API)
  */
-HFILE _lcreat_uniq( LPCSTR path, INT attr )
+HFILE _lcreat_uniq( LPCSTR path, INT32 attr )
 {
     DOS_FILE *file;
     HFILE handle;
index ec4526176076ff23c96fbbc8088c669e364ef45f..63a302807e32d3a0e6b8dd50aff10faed7037b94 100644 (file)
@@ -53,6 +53,7 @@ static const char PROFILE_WineIniName[] = "/.winerc";
 /* Check for comments in profile */
 #define IS_ENTRY_COMMENT(str)  ((str)[0] == ';')
 
+#define WINE_INI_GLOBAL ETCDIR "/wine.conf"
 
 /***********************************************************************
  *           PROFILE_CopyEntry
@@ -561,6 +562,26 @@ int PROFILE_GetWineIniString( const char *section, const char *key_name,
 }
 
 
+/***********************************************************************
+ *           PROFILE_GetWineIniInt
+ *
+ * Get a config integer from the wine.ini file.
+ */
+int PROFILE_GetWineIniInt( const char *section, const char *key_name, int def )
+{
+    char buffer[20];
+    char *p;
+    long result;
+
+    PROFILEKEY *key = PROFILE_Find( &WineProfile, section, key_name, FALSE );
+    if (!key || !key->value) return def;
+    PROFILE_CopyEntry( buffer, key->value, sizeof(buffer), TRUE );
+    result = strtol( buffer, &p, 0 );
+    if (p == buffer) return 0;  /* No digits at all */
+    return (int)result;
+}
+
+
 /***********************************************************************
  *           PROFILE_LoadWineIni
  *
index 11586856e447884b175fa94bbf22b5072be83b3f..3774434764604d00ebe4e2eca061b5edbff80060 100644 (file)
@@ -1,5 +1,5 @@
+DEFS   = -D__WINE__ -DNO_TRANSITION_TYPES
 TOPSRC = @top_srcdir@
-
 MODULE = if1632
 
 DLLS   = \
index 668d7a90444eb3f36f9e95a94dcff12f3f23e186..f6b93fa172c77e064c127d36779a648d69e75a3d 100644 (file)
@@ -17,7 +17,7 @@ base  2
 12 stub LBItemFromPt
 13 stub DrawInsert
 14 stub CreateUpDownControl
-15 stub InitCommonControls
+15 return InitCommonControls 4 0
 16 stub CreateStatusWindowW
 17 stub CreateToolbarEx
 18 stub DestroyPropertySheetPage
index 92186e37d9501571d4450b7fb2f6943777f9b851..24b13b825dad4ec03e35e37afce8f9c23b215136 100644 (file)
@@ -64,7 +64,7 @@ heap  65488  # 65536 - 16 (instance data) - 32 (stock objects)
 54  pascal16 CreateEllipticRgn(s_word s_word s_word s_word) CreateEllipticRgn
 55  pascal16 CreateEllipticRgnIndirect(ptr) CreateEllipticRgnIndirect16
 56  pascal16 CreateFont(s_word s_word s_word s_word s_word word word word
-                        word word word word word ptr) CreateFont
+                        word word word word word ptr) CreateFont16
 57  pascal16 CreateFontIndirect(ptr) CreateFontIndirect16
 58  pascal16 CreateHatchBrush(word long) CreateHatchBrush
 60  pascal16 CreatePatternBrush(word) CreatePatternBrush
@@ -241,12 +241,12 @@ heap      65488  # 65536 - 16 (instance data) - 32 (stock objects)
 354 stub ShrinkGDIHeap
 355 stub FTrapping0
 360 pascal16 CreatePalette(ptr) CreatePalette
-361 pascal16 GDISelectPalette(word word) GDISelectPalette
+361 pascal16 GDISelectPalette(word word word) GDISelectPalette
 362 pascal16 GDIRealizePalette(word) GDIRealizePalette
 363 pascal16 GetPaletteEntries(word word word ptr) GetPaletteEntries
 364 pascal16 SetPaletteEntries(word word word ptr) SetPaletteEntries
 365 pascal16 RealizeDefaultPalette(word) RealizeDefaultPalette
-366 stub UpdateColors
+366 pascal16 UpdateColors(word) UpdateColors
 367 pascal16 AnimatePalette(word word word ptr) AnimatePalette
 368 pascal16 ResizePalette(word word) ResizePalette
 370 pascal16 GetNearestPaletteIndex(word long) GetNearestPaletteIndex
@@ -271,7 +271,7 @@ heap        65488  # 65536 - 16 (instance data) - 32 (stock objects)
 409 stub CREATEUSERDISCARDABLEBITMAP
 410 stub ISVALIDMETAFILE
 411 pascal16 GetCurLogFont(word) GetCurLogFont
-412 stub IsDCCurrentPalette
+412 pascal16 IsDCCurrentPalette(word) IsDCCurrentPalette
 439 pascal16 StretchDIBits (word s_word s_word word word word word
                                word word ptr ptr word long) StretchDIBits
 440 pascal16 SetDIBits(word word word word ptr ptr word) SetDIBits
index bf606d2fd95926fd3c2f5d7be74793f6c5751b8f..f14590753cec1c045e14bf50508ee8f0e7c5b670 100644 (file)
@@ -45,17 +45,19 @@ base        1
 0040 stdcall CreateEllipticRgnIndirect(ptr) CreateEllipticRgnIndirect32
 0041 stub CreateEnhMetaFileA
 0042 stub CreateEnhMetaFileW
-0043 stub CreateFontA
+0043 stdcall CreateFontA(long long long long long long long long
+                        long long long long long ptr) CreateFont32A
 0044 stdcall CreateFontIndirectA(ptr) CreateFontIndirect32A
 0045 stdcall CreateFontIndirectW(ptr) CreateFontIndirect32W
-0046 stub CreateFontW
+0046 stdcall CreateFontW(long long long long long long long long
+                        long long long long long ptr) CreateFont32W
 0047 stub CreateHalftonePalette
 0048 stub CreateHatchBrush
 0049 stdcall CreateICA(ptr ptr ptr ptr) CreateIC
 0050 stub CreateICW
 0051 stub CreateMetaFileA
 0052 stub CreateMetaFileW
-0053 stub CreatePalette
+0053 stdcall CreatePalette(ptr) CreatePalette
 0054 stub CreatePatternBrush
 0055 stdcall CreatePen(long long long) CreatePen
 0056 stub CreatePenIndirect
@@ -282,7 +284,7 @@ base        1
 0277 stub PolylineTo
 0278 stdcall PtInRegion(long long long) PtInRegion
 0279 stub PtVisible
-0280 stdcall RealizePalette(long) RealizePalette32
+0280 stdcall RealizePalette(long) RealizePalette
 0281 stdcall RectInRegion(long ptr) RectInRegion32
 0282 stdcall RectVisible(long ptr) RectVisible32
 0283 stdcall Rectangle(long long long long long) Rectangle
@@ -302,7 +304,7 @@ base        1
 0297 stub SelectClipRgn
 0298 stub SelectFontLocal
 0299 stdcall SelectObject(long long) SelectObject
-0300 stdcall SelectPalette(long long long) SelectPalette32
+0300 stdcall SelectPalette(long long long) SelectPalette
 0301 stub SetAbortProc
 0302 stub SetArcDirection
 0303 stdcall SetBitmapBits(long long ptr) SetBitmapBits
@@ -334,7 +336,7 @@ base        1
 0328 stub SetPixelFormat
 0329 stub SetPixelV
 0330 stub SetPolyFillMode
-0331 stub SetROP2
+0331 stdcall SetROP2(long long) SetROP2
 0332 stdcall SetRectRgn(long long long long long) SetRectRgn
 0333 stub SetRelAbs
 0334 stub SetStretchBltMode
index 4111ce2d0f801b0e6756f2ce0c40e7715609535f..a607a331b7668d1d1a4286c032919b6b9beae6c6 100644 (file)
@@ -56,13 +56,13 @@ type        win16
 57  pascal16 GetProfileInt(ptr ptr s_word) GetProfileInt
 58  pascal16 GetProfileString(ptr ptr ptr ptr word) GetProfileString
 59  pascal16 WriteProfileString(ptr ptr ptr) WriteProfileString
-60  pascal16 FindResource(word segptr segptr) FindResource
-61  pascal16 LoadResource(word word) LoadResource
-62  pascal LockResource(word) WIN16_LockResource
-63  pascal16 FreeResource(word) FreeResource
-64  pascal16 AccessResource(word word) AccessResource
-65  pascal SizeofResource(word word) SizeofResource
-66  pascal16 AllocResource(word word long) AllocResource
+60  pascal16 FindResource(word segptr segptr) FindResource16
+61  pascal16 LoadResource(word word) LoadResource16
+62  pascal LockResource(word) WIN16_LockResource16
+63  pascal16 FreeResource(word) FreeResource16
+64  pascal16 AccessResource(word word) AccessResource16
+65  pascal SizeofResource(word word) SizeofResource16
+66  pascal16 AllocResource(word word long) AllocResource16
 67  stub SetResourceHandler
 68  pascal16 InitAtomTable(word) InitAtomTable
 69  pascal16 FindAtom(segptr) FindAtom
index eb8dfff54187fdb654da88e89766d35d24366a08..7378cce80168d59468abb3da3c09758e7f0c2bc8 100644 (file)
@@ -524,7 +524,7 @@ base        1
 0519 stub SetVolumeLabelW
 0520 stub SetupComm
 0521 stub ShowConsoleCursor
-0522 stdcall SizeofResource(long long) SizeofResource
+0522 stdcall SizeofResource(long long) SizeofResource32
 0523   stdcall Sleep(long) Sleep
 0524 stub SleepEx
 0525 stub SuspendThread
index 9ecb6da4ef1cb028b6f3a4775064c7da447c5fae..84019481f2b25690c07f21f1ca514e5542fa3eb6 100644 (file)
 dprintf_relay
 #endif
 
-  /* Saved 16-bit stack for current process (Win16 only) */
-WORD IF1632_Saved16_ss = 0;
-WORD IF1632_Saved16_sp = 0;
-
-  /* Saved 32-bit stack for current process (Win16 only) */
-DWORD IF1632_Saved32_esp = 0;
-SEGPTR IF1632_Stack32_base = 0;
-
-  /* Original Unix stack */
-DWORD IF1632_Original32_esp;
-
 
 /***********************************************************************
  *           RELAY_Init
  */
-BOOL RELAY_Init(void)
+BOOL32 RELAY_Init(void)
 {
     WORD codesel;
 
@@ -127,7 +116,7 @@ void RELAY_DebugCallFrom16( int func_type, char *args,
 /***********************************************************************
  *           RELAY_DebugCallFrom16Ret
  */
-void RELAY_DebugCallFrom16Ret( int func_type, int ret_val, int args32 )
+void RELAY_DebugCallFrom16Ret( int func_type, int ret_val, SIGCONTEXT *context)
 {
     STACK16FRAME *frame;
     WORD ordinal;
@@ -156,13 +145,10 @@ void RELAY_DebugCallFrom16Ret( int func_type, int ret_val, int args32 )
     case 2: /* regs */
         printf( "retval=none ret=%04x:%04x ds=%04x\n",
                 frame->cs, frame->ip, frame->ds );
-        {
-            SIGCONTEXT *context = (SIGCONTEXT *)&args32;
-            printf( "     AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
-                    AX_reg(context), BX_reg(context), CX_reg(context),
-                    DX_reg(context), SI_reg(context), DI_reg(context),
-                    ES_reg(context), EFL_reg(context) );
-        }
+        printf( "     AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
+                AX_reg(context), BX_reg(context), CX_reg(context),
+                DX_reg(context), SI_reg(context), DI_reg(context),
+                ES_reg(context), EFL_reg(context) );
         break;
     }
 }
@@ -274,7 +260,7 @@ void RELAY_DebugCallTo32( unsigned int func, int nbargs, unsigned int arg1  )
 /**********************************************************************
  *          Catch    (KERNEL.55)
  */
-INT Catch( LPCATCHBUF lpbuf )
+INT16 Catch( LPCATCHBUF lpbuf )
 {
     STACK16FRAME *pFrame = CURRENT_STACK16;
 
@@ -298,7 +284,7 @@ INT Catch( LPCATCHBUF lpbuf )
 /**********************************************************************
  *          Throw    (KERNEL.56)
  */
-int Throw( LPCATCHBUF lpbuf, int retval )
+INT16 Throw( LPCATCHBUF lpbuf, INT16 retval )
 {
     STACK16FRAME *pFrame;
 
index 1f836b7f77f1650d247c481ba1033a01aa66adda..33a458d246cc28428c64cd5efa7e5b9bb2c232a6 100644 (file)
@@ -10,7 +10,7 @@ base  1
 0005 stub DllGetClassObject
 0006 stub DoEnvironmentSubstA
 0007 stub DoEnvironmentSubstW
-0008 stub DragAcceptFiles
+0008 stdcall DragAcceptFiles(long long) DragAcceptFiles
 0009 stub DragFinish
 0010 stub DragQueryFile
 0011 stub DragQueryFileA
index fbe9fb12a1e625ca5c564b8727dd558e71965c41..52ff7e722f8134994ffb8146bfb1ce4fe9151756 100644 (file)
@@ -149,7 +149,7 @@ heap        65520
 147 pascal16 SetClipboardViewer(word) SetClipboardViewer
 148 pascal16 GetClipboardViewer() GetClipboardViewer
 149 pascal16 ChangeClipboardChain(word ptr) ChangeClipboardChain
-150 pascal16 LoadMenu(word segptr) LoadMenu
+150 pascal16 LoadMenu(word segptr) LoadMenu16
 151 pascal16 CreateMenu() CreateMenu
 152 pascal16 DestroyMenu(word) DestroyMenu
 153 pascal16 ChangeMenu(word word segptr word word) ChangeMenu16
@@ -172,11 +172,11 @@ heap      65520
 170 pascal16 ArrangeIconicWindows(word) ArrangeIconicWindows
 171 pascal16 WinHelp(word ptr word long) WinHelp
 172 stub SwitchToThisWindow
-173 pascal16 LoadCursor(word segptr) LoadCursor
-174 pascal16 LoadIcon(word segptr) LoadIcon
-175 pascal16 LoadBitmap(word segptr) LoadBitmap
-176 pascal16 LoadString(word word ptr s_word) LoadString
-177 pascal16 LoadAccelerators(word segptr) LoadAccelerators
+173 pascal16 LoadCursor(word segptr) LoadCursor16
+174 pascal16 LoadIcon(word segptr) LoadIcon16
+175 pascal16 LoadBitmap(word segptr) LoadBitmap16
+176 pascal16 LoadString(word word ptr s_word) LoadString16
+177 pascal16 LoadAccelerators(word segptr) LoadAccelerators16
 178 pascal16 TranslateAccelerator(word word ptr) TranslateAccelerator
 179 pascal16 GetSystemMetrics(word) GetSystemMetrics
 180 pascal   GetSysColor(word) GetSysColor
@@ -187,8 +187,8 @@ heap        65520
 185 pascal16 GrayString(word word segptr segptr s_word s_word s_word s_word s_word) GrayString
 186 pascal16 SwapMouseButton(word) SwapMouseButton
 187 pascal16 EndMenu() EndMenu
-188 pascal16 SetSysModalWindow(word) SetSysModalWindow
-189 pascal16 GetSysModalWindow() GetSysModalWindow
+188 pascal16 SetSysModalWindow(word) SetSysModalWindow16
+189 pascal16 GetSysModalWindow() GetSysModalWindow16
 190 pascal16 GetUpdateRect(word ptr word) GetUpdateRect16
 191 pascal16 ChildWindowFromPoint(word long) ChildWindowFromPoint16
 192 pascal16 InSendMessage() InSendMessage
index ce2432cc0fc2f0a3541ea1d8420e02e16b4d255a..ef4b733d6d2e04efd94d32be40a3b3c7235fdad6 100644 (file)
@@ -137,7 +137,7 @@ base        1
 0130 stdcall DestroyCaret() DestroyCaret
 0131 stub DestroyCursor
 0132 stub DestroyIcon
-0133 stub DestroyMenu
+0133 stdcall DestroyMenu(long) DestroyMenu
 0134 stdcall DestroyWindow(long) DestroyWindow
 0135 stdcall DialogBoxIndirectParamA(long ptr long ptr long) DialogBoxIndirectParam32A
 0136 stub DialogBoxIndirectParamAorW
@@ -358,28 +358,28 @@ base      1
 0351 stub IsZoomed
 0352 stdcall KillSystemTimer(long long) KillSystemTimer32
 0353 stdcall KillTimer(long long) KillTimer32
-0354   stdcall LoadAcceleratorsA(long ptr) WIN32_LoadAcceleratorsA
-0355 stdcall LoadAcceleratorsW(long ptr)       WIN32_LoadAcceleratorsW
-0356   stdcall LoadBitmapA(long ptr) WIN32_LoadBitmapA
-0357   stdcall LoadBitmapW(long ptr) WIN32_LoadBitmapW
-0358   stdcall LoadCursorA(long ptr) WIN32_LoadCursorA
+0354 stdcall LoadAcceleratorsA(long ptr) LoadAccelerators32A
+0355 stdcall LoadAcceleratorsW(long ptr) LoadAccelerators32W
+0356 stdcall LoadBitmapA(long ptr) LoadBitmap32A
+0357 stdcall LoadBitmapW(long ptr) LoadBitmap32W
+0358 stdcall LoadCursorA(long ptr) LoadCursor32A
 0359 stub LoadCursorFromFileA
 0360 stub LoadCursorFromFileW
-0361   stdcall LoadCursorW(long ptr) WIN32_LoadCursorW
-0362   stdcall LoadIconA(long ptr) WIN32_LoadIconA
-0363   stdcall LoadIconW(long ptr) WIN32_LoadIconW
+0361 stdcall LoadCursorW(long ptr) LoadCursor32W
+0362 stdcall LoadIconA(long ptr) LoadIcon32A
+0363 stdcall LoadIconW(long ptr) LoadIcon32W
 0364 stub LoadImageA
 0365 stub LoadImageW
 0366 stub LoadKeyboardLayoutA
 0367 stub LoadKeyboardLayoutW
 0368 stub LoadLocalFonts
-0369 stdcall LoadMenuA(long ptr) WIN32_LoadMenuA
+0369 stdcall LoadMenuA(long ptr) LoadMenu32A
 0370 stdcall LoadMenuIndirectA(ptr) LoadMenuIndirect32A
 0371 stdcall LoadMenuIndirectW(ptr) LoadMenuIndirect32W
-0372 stdcall LoadMenuW(long ptr) WIN32_LoadMenuW
+0372 stdcall LoadMenuW(long ptr) LoadMenu32W
 0373 stub LoadRemoteFonts
-0374   stdcall LoadStringA(long long ptr long) WIN32_LoadStringA
-0375   stdcall LoadStringW(long long ptr long) WIN32_LoadStringW
+0374 stdcall LoadStringA(long long ptr long) LoadString32A
+0375 stdcall LoadStringW(long long ptr long) LoadString32W
 0376 stub LockWindowStation
 0377 stub LockWindowUpdate
 0378 stub LookupIconIdFromDirectory
@@ -434,7 +434,7 @@ base        1
 0427 stdcall RegisterClassExA(ptr) RegisterClassEx32A
 0428 stdcall RegisterClassExW(ptr) RegisterClassEx32W
 0429 stdcall RegisterClassW(ptr) RegisterClass32W
-0430 stub RegisterClipboardFormatA
+0430 stdcall RegisterClipboardFormatA(ptr) RegisterClipboardFormat
 0431 stub RegisterClipboardFormatW
 0432 stub RegisterHotKey
 0433 stub RegisterLogonProcess
index b5c47c4caf52333acbe2b4a87c1dfc3d6627e33b..8254403bad9054e28cae2863b47f2cc9515554cb 100644 (file)
@@ -49,7 +49,7 @@ type win32
 0048 stub mciLoadCommandResource
 0049 stub mciSendCommandA
 0050 stub mciSendCommandW
-0051 stub mciSendStringA
+0051 stdcall mciSendStringA(ptr ptr long long) mciSendString
 0052 stub mciSendStringW
 0053 stub mciSetDriverData
 0054 stub mciSetYieldProc
index 89d231ac1aab6db4ad4befc8bf99a49923066642..6d2d7aa18f60de88ff9949ad3fdddac05b40b990 100644 (file)
@@ -123,7 +123,7 @@ extern LONG CallTo32_4( FARPROC32, DWORD, DWORD, DWORD, DWORD );
 #define CallEnumObjectsProc( func, lpobj, lParam ) \
     (*func)( lpobj, lParam )
 #define CallEnumPropProc( func, hwnd, lpstr, data ) \
-    (*func)( hwnd, (LPCTSTR)(lpstr), data )
+    (*func)( hwnd, lpstr, data )
 #define CallEnumTaskWndProc( func, hwnd, lParam ) \
     (*func)( hwnd, lParam )
 #define CallEnumWindowsProc16( func, hwnd, lParam ) \
index 61486d3adfc30f43b180e8161a53a6e263e60df0..03a658bff705b5d680d45a896cf2e459068146cf 100644 (file)
@@ -1,17 +1,29 @@
 #ifndef __WINE_COLOR_H
 #define __WINE_COLOR_H
 
+#include "palette.h"
 #include "gdi.h"
 
-extern HPALETTE16 COLOR_Init(void);
-extern int COLOR_ToPhysical( DC *dc, COLORREF color );
-extern void COLOR_SetMapping( DC *dc, HANDLE map, HANDLE revMap, WORD size );
-extern BOOL COLOR_IsSolid( COLORREF color );
+#define COLOR_FIXED     0x0001          /* read-only colormap - have to use XAllocColor (if not virtual)*/
+#define COLOR_VIRTUAL   0x0002          /* no mapping needed - pixel == pixel color */
 
-extern Colormap COLOR_WinColormap;
-extern int COLOR_mapEGAPixel[16];
-extern int* COLOR_PaletteToPixel;
-extern int* COLOR_PixelToPalette;
-extern int COLOR_ColormapSize;
+#define COLOR_PRIVATE   0x1000          /* private colormap, identity mapping */
+
+#define PC_SYS_USED     0x80           /* system peFlags */
+#define PC_SYS_RESERVED 0x40
+
+extern HPALETTE16      COLOR_Init(void);
+extern COLORREF                COLOR_ToLogical(int pixel);
+extern int             COLOR_ToPhysical( DC *dc, COLORREF color );
+extern int             COLOR_SetMapping( PALETTEOBJ* pal, BOOL mapOnly );
+extern BOOL            COLOR_IsSolid( COLORREF color );
+extern Colormap                COLOR_GetColormap();
+extern UINT16          COLOR_GetSystemPaletteSize();
+extern UINT16          COLOR_GetSystemPaletteFlags();
+
+extern int     COLOR_mapEGAPixel[16];
+extern int*    COLOR_PaletteToPixel;
+extern int*    COLOR_PixelToPalette;
+extern int     COLOR_ColormapSize;
 
 #endif /* __WINE_COLOR_H */
diff --git a/include/config.h.in b/include/config.h.in
new file mode 100644 (file)
index 0000000..0bbdd70
--- /dev/null
@@ -0,0 +1,25 @@
+/* include/config.h.in.  Generated automatically from configure.in by autoheader.  */
+
+/* Define to empty if the keyword does not work.  */
+#undef const
+
+/* Define if you need to in order for stat and other things to work.  */
+#undef _POSIX_SOURCE
+
+/* Define to `unsigned' if <sys/types.h> doesn't define.  */
+#undef size_t
+
+/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly.  */
+#undef STAT_MACROS_BROKEN
+
+/* Define if you have the ANSI C header files.  */
+#undef STDC_HEADERS
+
+/* Define if you have the memmove function.  */
+#undef HAVE_MEMMOVE
+
+/* Define if you have the tcgetattr function.  */
+#undef HAVE_TCGETATTR
+
+/* Define if you have the usleep function.  */
+#undef HAVE_USLEEP
index 8a63e3daeed4b33dedd6b5e1dfd85e5d0ee39414..634ca761b36457770f733e27a14aab5861cabe6d 100644 (file)
@@ -21,6 +21,6 @@ extern int FILE_Fstat( HFILE hFile, BYTE *pattr, DWORD *psize,
 extern HFILE FILE_Dup( HFILE hFile );
 extern HFILE FILE_Dup2( HFILE hFile1, HFILE hFile2 );
 extern INT32 FILE_Read( HFILE hFile, LPVOID buffer, UINT32 count );
-extern INT _lcreat_uniq( LPCSTR path, INT attr );
+extern HFILE _lcreat_uniq( LPCSTR path, INT32 attr );
 
 #endif  /* __WINE_FILE_H */
index 8a1ef42bda963d1c1557d73754713d77318b1b16..86b68e99b0c14031237fa742ea81bd2490ab46fb 100644 (file)
@@ -152,14 +152,6 @@ typedef struct
     TEXTMETRIC16  metrics;
 } X_PHYSFONT;
 
-  /* X physical palette information */
-typedef struct
-{
-    HANDLE16  hMapping;     /* Color mapping table (or 0 for identity) */
-    HANDLE16  hRevMapping;  /* Reverse color mapping table */
-    WORD      mappingSize;
-} X_PHYSPALETTE;
-
   /* X-specific DC information */
 typedef struct
 {
@@ -168,7 +160,6 @@ typedef struct
     X_PHYSFONT    font;
     X_PHYSPEN     pen;
     X_PHYSBRUSH   brush;
-    X_PHYSPALETTE pal;
 } X_DC_INFO;
 
 
index 3a4284a0da74dfb2cf37642d5fb4f4d98a609bc0..4dcd375d5154c9765e3057f2c30ef41fad42ff4e 100644 (file)
@@ -17,8 +17,8 @@
 typedef struct
 {
     HANDLE16   next;               /* 00 Next hook in chain */
-    HOOKPROC   proc WINE_PACKED;   /* 02 Hook procedure */
-    short      id;                 /* 06 Hook id (WH_xxx) */
+    HOOKPROC16 proc WINE_PACKED;   /* 02 Hook procedure */
+    INT16      id;                 /* 06 Hook id (WH_xxx) */
     HQUEUE16   ownerQueue;         /* 08 Owner queue (0 for system hook) */
     HMODULE16  ownerModule;        /* 0a Owner module */
     WORD       inHookProc;         /* 0c TRUE if in this->proc */
@@ -28,9 +28,9 @@ typedef struct
 
 #define HOOK_MAGIC  ((int)'H' | (int)'K' << 8)  /* 'HK' */
 
-extern HANDLE HOOK_GetHook( short id , HQUEUE hQueue );
-extern DWORD HOOK_CallHooks( short id, short code,
-                             WPARAM wParam, LPARAM lParam );
+extern HANDLE16 HOOK_GetHook( INT16 id , HQUEUE16 hQueue );
+extern LRESULT HOOK_CallHooks( INT16 id, INT16 code,
+                               WPARAM16 wParam, LPARAM lParam );
 extern void HOOK_FreeModuleHooks( HMODULE16 hModule );
 extern void HOOK_FreeQueueHooks( HQUEUE16 hQueue );
 
index 0daaadec34403a5830f573f166df77d57516889a..78ab156951fe0c3c4fdaf43af7937e953a17364e 100644 (file)
@@ -19,7 +19,7 @@ enum seg_type
 typedef struct
 {
     unsigned long base;            /* base address */
-    unsigned long limit;           /* segment limit */
+    unsigned long limit;           /* segment limit (in pages or bytes) */
     int           seg_32bit;       /* is segment 32-bit? */
     int           read_only;       /* is segment read-only? */
     int           limit_in_pages;  /* is the limit in pages or bytes? */
index a719692f69e55642e4a289ad267f1f3a790e8d30..b7e9dcd28131d1818b28954ca6395f791413f06c 100644 (file)
 
 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 HRSRC32 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 );
+extern HGLOBAL32 LIBRES_LoadResource( HINSTANCE hModule, HRSRC32 hRsrc );
+extern LPVOID  LIBRES_LockResource( HGLOBAL32 handle );
+extern DWORD   LIBRES_SizeofResource( HINSTANCE hModule, HRSRC32 hRsrc );
 
 #endif /* WINELIB */
 
index 45fb92c284fdf77d02f2cf6b5769f7d0965a100b..063e995fb6bfde6303a6f32824211b0b4aef55af 100644 (file)
@@ -1457,6 +1457,20 @@ typedef struct {
 #define MCI_CONSTANT            8
 #define MCI_END_CONSTANT        9
 
+/* Mixer flags */
+#define MIXER_OBJECTF_HANDLE   0x80000000L
+#define MIXER_OBJECTF_MIXER    0x00000000L
+#define MIXER_OBJECTF_HMIXER   (MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIXER)
+#define MIXER_OBJECTF_WAVEOUT  0x10000000L
+#define MIXER_OBJECTF_HWAVEOUT (MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_WAVEOUT)
+#define MIXER_OBJECTF_WAVEIN   0x20000000L
+#define MIXER_OBJECTF_HWAVEIN  (MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_WAVEIN)
+#define MIXER_OBJECTF_MIDIOUT  0x30000000L
+#define MIXER_OBJECTF_HMIDIOUT (MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIDIOUT)
+#define MIXER_OBJECTF_MIDIIN   0x40000000L
+#define MIXER_OBJECTF_HMIDIIN  (MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIDIIN)
+#define MIXER_OBJECTF_AUX      0x50000000L
+
 #define MAKEMCIRESOURCE(wRet, wRes) MAKELRESULT((wRet), (wRes))
 
 typedef struct {
index 1bbbdd4bb7cba2b8dd9872aef2c2d46bebef4e1c..fffbbeece0f53047d574286078e837cc33679fd0 100644 (file)
@@ -49,6 +49,7 @@ struct options
     int    ipc;             /* Use IPC mechanisms */
     WINE_LANGUAGE language; /* Current language */
     int    managed;        /* Managed windows */
+    int    perfectGraphics; /* Favor correctness over speed for graphics */
 };
 
 extern struct options Options;
@@ -58,5 +59,7 @@ extern struct options Options;
 extern int PROFILE_LoadWineIni(void);
 extern int PROFILE_GetWineIniString( const char *section, const char *key_name,
                                      const char *def, char *buffer, int len );
+extern int PROFILE_GetWineIniInt( const char *section, const char *key_name,
+                                  int def );
 
 #endif
index 6345d7b87578fc2e5c7f2ae4e617e9b4eeb4d274..ce4519baab7d56bc7af34baf58717234d04588aa 100644 (file)
@@ -16,10 +16,13 @@ typedef struct
 {
     GDIOBJHDR   header;
     LOGPALETTE  logpalette WINE_PACKED;
+    int        *mapping;
 } PALETTEOBJ;
 
 #pragma pack(4)
 
 extern int PALETTE_GetObject( PALETTEOBJ * palette, int count, LPSTR buffer );
+extern BOOL PALETTE_DeleteObject( HPALETTE16 hpalette, PALETTEOBJ *palette );
+extern BOOL PALETTE_UnrealizeObject( HPALETTE16 hpalette, PALETTEOBJ *palette);
      
 #endif /* __WINE_PALETTE_H */
index c174fa4b20d5fe7841bdbeed8282bded9dc9fe48..1336fffc9c44cd37f6297044b66a64c77431f964 100644 (file)
@@ -14,7 +14,6 @@ struct pe_data {
        int base_addr;
        int load_addr;
        int vma_size;
-       int resource_offset; /* offset to resource typedirectory in file */
 };
 
 typedef struct pe_data PE_MODULE;
index e054b4f77c6dcb836a4376811eac361f484c05f4..7f202c0efe8aafde9f8f0dbdaaade5a4f713d53b 100644 (file)
@@ -43,13 +43,13 @@ extern void LIBRES_RegisterResources(const struct resource* const * Res);
 #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 );
-extern DWORD NE_SizeofResource( HMODULE hModule, HRSRC hRsrc );
-extern SEGPTR NE_LockResource( HMODULE hModule, HGLOBAL handle );
-extern HGLOBAL NE_AllocResource( HMODULE hModule, HRSRC hRsrc, DWORD size );
-extern HGLOBAL NE_LoadResource( HMODULE hModule,  HRSRC hRsrc );
+extern int NE_AccessResource( HMODULE16 hModule, HRSRC hRsrc );
+extern BOOL NE_FreeResource( HMODULE16 hModule, HGLOBAL handle );
+extern HRSRC NE_FindResource( HMODULE16 hModule, SEGPTR typeId, SEGPTR resId );
+extern DWORD NE_SizeofResource( HMODULE16 hModule, HRSRC hRsrc );
+extern SEGPTR NE_LockResource( HMODULE16 hModule, HGLOBAL handle );
+extern HGLOBAL NE_AllocResource( HMODULE16 hModule, HRSRC hRsrc, DWORD size );
+extern HGLOBAL NE_LoadResource( HMODULE16 hModule,  HRSRC hRsrc );
 
 extern HANDLE SYSRES_LoadResource( SYSTEM_RESOURCE id );
 extern void SYSRES_FreeResource( HANDLE handle );
index 81d97d6d707c6801d92a993f5f798e5342e4681c..644b6aef625c9294085fab9907bbcba5d9a17078 100644 (file)
 
 #include <stddef.h>
 
-HANDLE32 FindResource32A( HINSTANCE hModule, LPCSTR name, LPCSTR type );
-HANDLE32 FindResource32W( HINSTANCE hModule, LPCWSTR name, LPCWSTR type );
-HANDLE32 LoadResource32( HINSTANCE hModule, HANDLE32 hRsrc );
-LPVOID LockResource32( HANDLE32 handle );
-BOOL FreeResource32( HANDLE32 handle );
-INT AccessResource32( HINSTANCE hModule, HRSRC hRsrc );
-DWORD SizeofResource32( HINSTANCE hModule, HRSRC hRsrc );
-int WIN32_LoadStringW(HINSTANCE instance, DWORD resource_id, LPWSTR buffer, int buflen);
-int WIN32_LoadStringA(HINSTANCE instance, DWORD resource_id, LPSTR buffer, int buflen);
-
 typedef struct _IMAGE_RESOURCE_DIRECTORY {
        DWORD Characteristics;
        DWORD TimeDateStamp;
@@ -46,9 +36,4 @@ typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
        WCHAR NameString[1];
 } IMAGE_RESOURCE_DIR_STRING_U, *PIMAGE_RESOURCE_DIR_STRING_U;
 
-HMENU WIN32_LoadMenuIndirectW(void *menu);
-HMENU WIN32_LoadMenuW(HANDLE instance, LPCWSTR name);
-HMENU WIN32_LoadMenuIndirectA(void *menu);
-HMENU WIN32_LoadMenuA(HANDLE instance,LPCSTR name);
-
 #endif  /* __WINE_RESOURCE32_H */
index 77bb0e076a35b34d11f136f4b6364d3c092d8c85..359e2888178d345f1f5de03fee268e12d11b6002 100644 (file)
@@ -56,12 +56,12 @@ extern SEGPTR IF1632_Stack32_base;
   /* Original Unix stack */
 extern DWORD IF1632_Original32_esp;
 
-#ifndef WINELIB
 #define CURRENT_STACK16 \
     ((STACK16FRAME *)PTR_SEG_OFF_TO_LIN(IF1632_Saved16_ss,IF1632_Saved16_sp))
 
 #define CURRENT_DS   (CURRENT_STACK16->ds)
 
+#ifndef WINELIB
   /* Make a segmented pointer from a pointer to a variable located */
   /* on the 32-bit stack for the current task. */
 #if 0
@@ -71,8 +71,6 @@ extern DWORD IF1632_Original32_esp;
 #endif
 SEGPTR MAKE_SEGPTR(void *ptr);
 #else
-#define CURRENT_STACK16           error.error
-#define CURRENT_DS         ((WORD)GetTaskDS())
 #define MAKE_SEGPTR(ptr)   ((SEGPTR)ptr)
 #endif
 
index 0e43982ec0152d8a5fe74e3f24a484f3cb1244f7..c0e88cec6bb9c5f7e746103428e5a66b2dcdb314 100644 (file)
@@ -25,6 +25,10 @@ void STRUCT32_MSG32to16(const MSG32 *msg32,MSG16 *msg16);
 
 void STRUCT32_CREATESTRUCT32Ato16(const CREATESTRUCT32A*,CREATESTRUCT16*);
 void STRUCT32_CREATESTRUCT16to32A(const CREATESTRUCT16*,CREATESTRUCT32A*);
+void STRUCT32_MDICREATESTRUCT32Ato16( const MDICREATESTRUCT32A*,
+                                      MDICREATESTRUCT16*);
+void STRUCT32_MDICREATESTRUCT16to32A( const MDICREATESTRUCT16*,
+                                      MDICREATESTRUCT32A*);
 
 #pragma pack(1)
 
index 307dd8e750cbcc6dc2c2cd761b87f128ecce201e..2881c7070069565ddac2ffcc9f32a40e4fb593a5 100644 (file)
@@ -51,51 +51,51 @@ typedef struct
   /* Task database. See 'Windows Internals' p. 226 */
 typedef struct
 {
-    HTASK   hNext;                      /* Selector of next TDB */
-    WORD    sp;                         /* Stack pointer of task */
-    WORD    ss;                         /* Stack segment of task */
-    WORD    nEvents;                    /* Events for this task */
-    char    priority;                   /* Task priority, between -32 and 15 */
-    BYTE    unused1;
-    HGLOBAL hStack32;                   /* Handle to 32-bit stack */
-    HTASK   hSelf;                      /* Selector of this TDB */
-    HANDLE  hPrevInstance;              /* Previous instance of the module */
-    DWORD   esp;                        /* 32-bit stack pointer */
-    WORD    ctrlword8087;               /* 80x87 control word */
-    WORD    flags;                      /* Task flags */
-    UINT    error_mode;                 /* Error mode (see SetErrorMode) */
-    WORD    version;                    /* Expected Windows version */
-    HANDLE  hInstance;                  /* Instance handle for this task */
-    HMODULE hModule;                    /* Module handle */
-    HQUEUE  hQueue;                     /* Selector of task message queue */
-    HTASK   hParent;                    /* Selector of TDB of parent task */
-    WORD    signal_flags;               /* Flags related to signal handler */
-    DWORD   sighandler WINE_PACKED;     /* Signal handler */
-    DWORD   userhandler WINE_PACKED;    /* USER signal handler */
-    DWORD   discardhandler WINE_PACKED; /* Handler for GlobalDiscard() */
-    DWORD   int0 WINE_PACKED;           /* int 0 (divide by zero) handler */
-    DWORD   int2 WINE_PACKED;           /* int 2 (NMI) handler */
-    DWORD   int4 WINE_PACKED;           /* int 4 (INTO) handler */
-    DWORD   int6 WINE_PACKED;           /* int 6 (invalid opcode) handler */
-    DWORD   int7 WINE_PACKED;           /* int 7 (coprocessor) handler */
-    DWORD   int3e WINE_PACKED;          /* int 3e (80x87 emulator) handler */
-    DWORD   int75 WINE_PACKED;          /* int 75 (80x87 error) handler */
-    DWORD   compat_flags WINE_PACKED;   /* Compatibility flags */
-    BYTE    unused4[14];
-    HANDLE  hPDB;                       /* Selector of PDB (i.e. PSP) */
-    SEGPTR  dta WINE_PACKED;            /* Current DTA */
-    BYTE    curdrive;                   /* Current drive */
-    BYTE    curdir[65];                 /* Current directory */
-    WORD    nCmdShow;                   /* cmdShow parameter to WinMain */
-    HTASK   hYieldTo;                   /* Next task to schedule */
-    DWORD   dlls_to_init;               /* Ptr to list of DLL to initialize */
-    HANDLE  hCSAlias;                   /* Code segment alias for this TDB */
-    THUNKS  thunks WINE_PACKED;         /* Make proc instance thunks */
-    WORD    more_thunks[6*4];           /* Space for 6 more thunks */
-    BYTE    module_name[8];             /* Module name for task */
-    WORD    magic;                      /* TDB signature */
-    DWORD   unused7;
-    PDB     pdb;                        /* PDB for this task */
+    HTASK16   hNext;                      /* 00 Selector of next TDB */
+    WORD      sp;                         /* 02 Stack pointer of task */
+    WORD      ss;                         /* 04 Stack segment of task */
+    WORD      nEvents;                    /* 06 Events for this task */
+    char      priority;                   /* 08 Task priority, -32..15 */
+    BYTE      unused1;                    /* 09 */
+    HGLOBAL16 hStack32;                   /* 0a Handle to 32-bit stack */
+    HTASK16   hSelf;                      /* 0c Selector of this TDB */
+    HANDLE16  hPrevInstance;              /* 0e Previous instance of module */
+    DWORD     esp;                        /* 10 32-bit stack pointer */
+    WORD      ctrlword8087;               /* 14 80x87 control word */
+    WORD      flags;                      /* 16 Task flags */
+    UINT16    error_mode;                 /* 18 Error mode (see SetErrorMode)*/
+    WORD      version;                    /* 1a Expected Windows version */
+    HANDLE16  hInstance;                  /* 1c Instance handle for task */
+    HMODULE16 hModule;                    /* 1e Module handle */
+    HQUEUE16  hQueue;                     /* 20 Selector of task queue */
+    HTASK16   hParent;                    /* 22 Selector of TDB of parent */
+    WORD      signal_flags;               /* 24 Flags for signal handler */
+    DWORD     sighandler WINE_PACKED;     /* 26 Signal handler */
+    DWORD     userhandler WINE_PACKED;    /* 2a USER signal handler */
+    DWORD     discardhandler WINE_PACKED; /* 2e Handler for GlobalDiscard() */
+    DWORD     int0 WINE_PACKED;           /* 32 int 0 (divide by 0) handler */
+    DWORD     int2 WINE_PACKED;           /* 36 int 2 (NMI) handler */
+    DWORD     int4 WINE_PACKED;           /* 3a int 4 (INTO) handler */
+    DWORD     int6 WINE_PACKED;           /* 3e int 6 (invalid opc) handler */
+    DWORD     int7 WINE_PACKED;           /* 42 int 7 (coprocessor) handler */
+    DWORD     int3e WINE_PACKED;          /* 46 int 3e (80x87 emu) handler */
+    DWORD     int75 WINE_PACKED;          /* 4a int 75 (80x87 error) handler */
+    DWORD     compat_flags WINE_PACKED;   /* 4e Compatibility flags */
+    BYTE      unused4[14];                /* 52 */
+    HANDLE16  hPDB;                       /* 60 Selector of PDB (i.e. PSP) */
+    SEGPTR    dta WINE_PACKED;            /* 62 Current DTA */
+    BYTE      curdrive;                   /* 66 Current drive */
+    BYTE      curdir[65];                 /* 67 Current directory */
+    WORD      nCmdShow;                   /* a8 cmdShow parameter to WinMain */
+    HTASK16   hYieldTo;                   /* aa Next task to schedule */
+    DWORD     dlls_to_init;               /* ac Ptr to DLLs to initialize */
+    HANDLE16  hCSAlias;                   /* b0 Code segment for this TDB */
+    THUNKS    thunks WINE_PACKED;         /* b2 Make proc instance thunks */
+    WORD      more_thunks[6*4];           /* c2 Space for 6 more thunks */
+    BYTE      module_name[8];             /* f2 Module name for task */
+    WORD      magic;                      /* fa TDB signature */
+    DWORD     unused7;                    /* fc */
+    PDB       pdb;                        /* 100 PDB for this task */
 } TDB;
 
 #define TDB_MAGIC    ('T' | ('D' << 8))
@@ -107,10 +107,11 @@ typedef struct
 
 #pragma pack(4)
 
-extern BOOL TASK_Init(void);
-extern HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance,
-                              HANDLE hPrevInstance, HANDLE hEnvironment,
-                              char *cmdLine, WORD cmdShow );
-extern void TASK_KillCurrentTask( int exitCode );
+extern BOOL32 TASK_Init(void);
+extern HTASK16 TASK_CreateTask( HMODULE16 hModule, HINSTANCE16 hInstance,
+                                HINSTANCE16 hPrevInstance,
+                                HANDLE16 hEnvironment, LPCSTR cmdLine,
+                                UINT16 cmdShow );
+extern void TASK_KillCurrentTask( INT16 exitCode );
 
 #endif /* _WINE_TASK_H */
index 72fea65e851cc25ffa536cd545f14f3df70853af..396942a8515d5ce173dbd682eb7a2a0235578021 100644 (file)
@@ -8,9 +8,7 @@ extern "C" {
 #include "wintypes.h"
 #include "winuser.h"
 
-#ifndef WINELIB
 #pragma pack(1)
-#endif
 
 /* The SIZE structure */
 
@@ -57,9 +55,7 @@ DECL_WINELIB_TYPE(LPPOINT);
             ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
 
 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
-#ifdef WINELIB16
-#define MAKEPOINT(l)  MAKEPOINT16(l)
-#endif
+#define MAKEPOINT WINELIB_NAME(MAKEPOINT)
 
 /* The RECT structure */
 
@@ -1116,6 +1112,11 @@ typedef struct tagPALETTEENTRY
        BYTE peRed, peGreen, peBlue, peFlags;
 } PALETTEENTRY, *LPPALETTEENTRY;
 
+/* Logical palette entry flags */
+#define PC_RESERVED     0x01
+#define PC_EXPLICIT     0x02
+#define PC_NOCOLLAPSE   0x04
+
 typedef struct
 { 
     WORD           palVersion;
@@ -1538,12 +1539,11 @@ typedef struct
 #define ONESTOPBIT     0
 #define ONE5STOPBITS   1
 #define TWOSTOPBITS    2
+
 #define IGNORE         0
-#ifdef WINELIB32
-#define INFINITE        0xFFFFFFFF
-#else
-#define INFINITE       0xFFFF
-#endif
+#define INFINITE16      0xFFFF
+#define INFINITE32      0xFFFFFFFF
+#define INFINITE WINELIB_NAME(INFINITE)
 
 #define CE_RXOVER      0x0001
 #define CE_OVERRUN     0x0002
@@ -2157,6 +2157,8 @@ typedef struct
 #define SWP_NOSENDCHANGING  0x0400
 #define SWP_DEFERERASE      0x2000
 
+#define HWND_BROADCAST     ((HWND)0xffff)
+
 /* SetWindowPos() hwndInsertAfter field values */
 #define HWND_TOP            ((HWND)0)
 #define HWND_BOTTOM         ((HWND)1)
@@ -3177,19 +3179,20 @@ typedef struct _SYSTEM_POWER_STATUS
   DWORD   BatteryFullLifeTime;
 } SYSTEM_POWER_STATUS, *LPSYSTEM_POWER_STATUS;
 
-
-#ifndef WINELIB
 #pragma pack(4)
-#endif
 
 /* Declarations for functions that exist only in Win16 */
 
 WORD       AllocSelector(WORD);
 WORD       AllocSelectorArray(WORD);
+INT16      Catch(LPCATCHBUF);
+HANDLE16   FarGetOwner(HGLOBAL16);
+VOID       FarSetOwner(HGLOBAL16,HANDLE16);
 VOID       FillWindow(HWND16,HWND16,HDC16,HBRUSH16);
 WORD       FreeSelector(WORD);
 DWORD      GetBitmapDimension(HBITMAP16);
 HTASK16    GetCurrentTask(void);
+HMODULE16  GetExePtr(HANDLE16);
 HINSTANCE16 GetTaskDS(void);
 HQUEUE16   GetTaskQueue(HTASK16);
 BOOL16     LocalInit(HANDLE16,WORD,WORD);
@@ -3203,6 +3206,7 @@ DWORD      SetViewportExt(HDC16,INT16,INT16);
 DWORD      SetViewportOrg(HDC16,INT16,INT16);
 DWORD      SetWindowExt(HDC16,INT16,INT16);
 DWORD      SetWindowOrg(HDC16,INT16,INT16);
+INT16      Throw(LPCATCHBUF,INT16);
 VOID       hmemcpy(LPVOID,LPCVOID,LONG);
 
 /* Declarations for functions that exist only in Win32 */
@@ -3266,6 +3270,7 @@ INT16      LZStart(void);
 INT16      OffsetRgn(HRGN32,INT32,INT32);
 HFILE      OpenFile(LPCSTR,OFSTRUCT*,UINT32);
 BOOL16     PtInRegion(HRGN32,INT32,INT32);
+UINT16     RealizePalette(HDC32);
 DWORD      RegCloseKey(HKEY);
 DWORD      RegFlushKey(HKEY);
 LONG       SetBitmapBits(HBITMAP32,LONG,LPCVOID);
@@ -3283,12 +3288,18 @@ HFILE      _lopen(LPCSTR,INT32);
 
 /* Declarations for functions that change between Win16 and Win32 */
 
+INT16      AccessResource16(HINSTANCE16,HRSRC16);
+INT32      AccessResource32(HINSTANCE32,HRSRC32);
+#define    AccessResource WINELIB_NAME(AccessResource)
 BOOL16     AdjustWindowRect16(LPRECT16,DWORD,BOOL16);
 BOOL32     AdjustWindowRect32(LPRECT32,DWORD,BOOL32);
 #define    AdjustWindowRect WINELIB_NAME(AdjustWindowRect)
 BOOL16     AdjustWindowRectEx16(LPRECT16,DWORD,BOOL16,DWORD);
 BOOL32     AdjustWindowRectEx32(LPRECT32,DWORD,BOOL32,DWORD);
 #define    AdjustWindowRectEx WINELIB_NAME(AdjustWindowRectEx)
+HGLOBAL16  AllocResource16(HINSTANCE16,HRSRC16,DWORD);
+HGLOBAL32  AllocResource32(HINSTANCE32,HRSRC32,DWORD);
+#define    AllocResource WINELIB_NAME(AllocResource)
 BOOL16     AppendMenu16(HMENU16,UINT16,UINT16,SEGPTR);
 BOOL32     AppendMenu32A(HMENU32,UINT32,UINT32,LPCSTR);
 BOOL32     AppendMenu32W(HMENU32,UINT32,UINT32,LPCWSTR);
@@ -3386,6 +3397,10 @@ BOOL32     CreateDirectory32W(LPCWSTR,LPSECURITY_ATTRIBUTES);
 HRGN16     CreateEllipticRgnIndirect16(const RECT16 *);
 HRGN32     CreateEllipticRgnIndirect32(const RECT32 *);
 #define    CreateEllipticRgnIndirect WINELIB_NAME(CreateEllipticRgnIndirect)
+HFONT16    CreateFont16(INT16,INT16,INT16,INT16,INT16,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,LPCSTR);
+HFONT32    CreateFont32A(INT32,INT32,INT32,INT32,INT32,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,LPCSTR);
+HFONT32    CreateFont32W(INT32,INT32,INT32,INT32,INT32,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,LPCWSTR);
+#define    CreateFont WINELIB_NAME_AW(CreateFont)
 HFONT16    CreateFontIndirect16(const LOGFONT16*);
 HFONT32    CreateFontIndirect32A(const LOGFONT32A*);
 HFONT32    CreateFontIndirect32W(const LOGFONT32W*);
@@ -3496,6 +3511,10 @@ BOOL32     ExtTextOut32W(HDC32,INT32,INT32,UINT32,const RECT32*,LPCWSTR,UINT32,c
 INT16      FillRect16(HDC16,const RECT16*,HBRUSH16);
 INT32      FillRect32(HDC32,const RECT32*,HBRUSH32);
 #define    FillRect WINELIB_NAME(FillRect)
+HRSRC16    FindResource16(HINSTANCE16,SEGPTR,SEGPTR);
+HRSRC32    FindResource32A(HINSTANCE32,LPCSTR,LPCSTR);
+HRSRC32    FindResource32W(HINSTANCE32,LPCWSTR,LPCWSTR);
+#define    FindResource WINELIB_NAME_AW(FindResource)
 HWND16     FindWindow16(SEGPTR,LPCSTR);
 HWND32     FindWindow32A(LPCSTR,LPCSTR);
 HWND32     FindWindow32W(LPCWSTR,LPCWSTR);
@@ -3513,6 +3532,9 @@ BOOL16     FreeModule16(HMODULE16);
 void       FreeProcInstance16(FARPROC16);
 #define    FreeProcInstance32(proc) /*nothing*/
 #define    FreeProcInstance WINELIB_NAME(FreeProcInstance)
+BOOL16     FreeResource16(HGLOBAL16);
+BOOL32     FreeResource32(HGLOBAL32);
+#define    FreeResource WINELIB_NAME(FreeResource)
 BOOL16     GetBitmapDimensionEx16(HBITMAP16,LPSIZE16);
 BOOL32     GetBitmapDimensionEx32(HBITMAP32,LPSIZE32);
 #define    GetBitmapDimensionEx WINELIB_NAME(GetBitmapDimensionEx)
@@ -3603,6 +3625,9 @@ INT32      GetRgnBox32(HRGN32,LPRECT32);
 DWORD      GetShortPathName32A(LPCSTR,LPSTR,DWORD);
 DWORD      GetShortPathName32W(LPCWSTR,LPWSTR,DWORD);
 #define    GetShortPathName WINELIB_NAME_AW(GetShortPathName)
+HWND16     GetSysModalWindow16(void);
+#define    GetSysModalWindow32() ((HWND32)0)
+#define    GetSysModalWindow WINELIB_NAME(GetSysModalWindow)
 UINT16     GetSystemDirectory16(LPSTR,UINT16);
 UINT32     GetSystemDirectory32A(LPSTR,UINT32);
 UINT32     GetSystemDirectory32W(LPWSTR,UINT32);
@@ -3744,10 +3769,37 @@ HFILE      LZOpenFile32W(LPCWSTR,LPOFSTRUCT,UINT32);
 INT16      LZRead16(HFILE,SEGPTR,UINT16); 
 INT32      LZRead32(HFILE,LPVOID,UINT32); 
 #define    LZRead WINELIB_NAME(LZRead)
+HACCEL16   LoadAccelerators16(HINSTANCE16,SEGPTR);
+HACCEL32   LoadAccelerators32A(HINSTANCE32,LPCSTR);
+HACCEL32   LoadAccelerators32W(HINSTANCE32,LPCWSTR);
+#define    LoadAccelerators WINELIB_NAME_AW(LoadAccelerators)
+HBITMAP16  LoadBitmap16(HANDLE16,SEGPTR);
+HBITMAP32  LoadBitmap32A(HANDLE32,LPCSTR);
+HBITMAP32  LoadBitmap32W(HANDLE32,LPCWSTR);
+#define    LoadBitmap WINELIB_NAME(LoadBitmap)
+HCURSOR16  LoadCursor16(HINSTANCE16,SEGPTR);
+HCURSOR32  LoadCursor32A(HINSTANCE32,LPCSTR);
+HCURSOR32  LoadCursor32W(HINSTANCE32,LPCWSTR);
+#define    LoadCursor WINELIB_NAME_AW(LoadCursor)
+HICON16    LoadIcon16(HINSTANCE16,SEGPTR);
+HICON32    LoadIcon32A(HINSTANCE32,LPCSTR);
+HICON32    LoadIcon32W(HINSTANCE32,LPCWSTR);
+#define    LoadIcon WINELIB_NAME_AW(LoadIcon)
+HMENU16    LoadMenu16(HINSTANCE16,SEGPTR);
+HMENU32    LoadMenu32A(HINSTANCE32,LPCSTR);
+HMENU32    LoadMenu32W(HINSTANCE32,LPCWSTR);
+#define    LoadMenu WINELIB_NAME_AW(LoadMenu)
 HMENU16    LoadMenuIndirect16(LPCVOID);
 HMENU32    LoadMenuIndirect32A(LPCVOID);
 HMENU32    LoadMenuIndirect32W(LPCVOID);
 #define    LoadMenuIndirect WINELIB_NAME_AW(LoadMenuIndirect)
+HGLOBAL16  LoadResource16(HINSTANCE16,HRSRC16);
+HGLOBAL32  LoadResource32(HINSTANCE32,HRSRC32);
+#define    LoadResource WINELIB_NAME(LoadResource)
+INT16      LoadString16(HINSTANCE16,UINT16,LPSTR,INT16);
+INT32      LoadString32A(HINSTANCE32,UINT32,LPSTR,INT32);
+INT32      LoadString32W(HINSTANCE32,UINT32,LPWSTR,INT32);
+#define    LoadString WINELIB_NAME_AW(LoadString)
 HLOCAL16   LocalAlloc16(UINT16,WORD);
 HLOCAL32   LocalAlloc32(UINT32,DWORD);
 #define    LocalAlloc WINELIB_NAME(LocalAlloc)
@@ -3778,6 +3830,9 @@ UINT32     LocalSize32(HLOCAL32);
 BOOL16     LocalUnlock16(HLOCAL16);
 BOOL32     LocalUnlock32(HLOCAL32);
 #define    LocalUnlock WINELIB_NAME(LocalUnlock)
+LPVOID     LockResource16(HGLOBAL16);
+LPVOID     LockResource32(HGLOBAL32);
+#define    LockResource WINELIB_NAME(LockResource)
 HGLOBAL16  LockSegment16(HGLOBAL16);
 #define    LockSegment32(handle) GlobalFix((HANDLE32)(handle))
 #define    LockSegment WINELIB_NAME(LockSegment)
@@ -3962,6 +4017,9 @@ void       SetRect32(LPRECT32,INT32,INT32,INT32,INT32);
 void       SetRectEmpty16(LPRECT16);
 void       SetRectEmpty32(LPRECT32);
 #define    SetRectEmpty WINELIB_NAME(SetRectEmpty)
+HWND16     SetSysModalWindow16(HWND16);
+#define    SetSysModalWindow32(hwnd) ((HWND32)0)
+#define    SetSysModalWindow WINELIB_NAME(SetSysModalWindow)
 UINT16     SetSystemTimer16(HWND16,UINT16,UINT16,TIMERPROC16);
 UINT32     SetSystemTimer32(HWND32,UINT32,UINT32,TIMERPROC32);
 #define    SetSystemTimer WINELIB_NAME(SetSystemTimer)
@@ -4092,7 +4150,37 @@ LPSTR      lstrcpynWtoA(LPSTR,LPCWSTR,INT32);
 
 #ifndef NO_TRANSITION_TYPES
 
-#ifndef WINELIB
+#ifdef __WINE__
+# ifdef WINELIB32
+typedef INT32 INT;
+typedef UINT32 UINT;
+typedef BOOL32 BOOL;
+typedef WPARAM32 WPARAM;
+typedef HANDLE32 HANDLE;
+typedef HANDLE32 HBITMAP;
+typedef HANDLE32 HBRUSH;
+typedef HANDLE32 HCURSOR;
+typedef HANDLE32 HDC;
+typedef HANDLE32 HDRVR;
+typedef HANDLE32 HFONT;
+typedef HANDLE32 HGLOBAL;
+typedef HANDLE32 HICON;
+typedef HANDLE32 HINSTANCE;
+typedef HANDLE32 HMENU;
+typedef HANDLE32 HMETAFILE;
+typedef HANDLE32 HMIDI;
+typedef HANDLE32 HMIDIIN;
+typedef HANDLE32 HMIDIOUT;
+typedef HANDLE32 HMMIO;
+typedef HANDLE32 HQUEUE;
+typedef HANDLE32 HRGN;
+typedef HANDLE32 HRSRC;
+typedef HANDLE32 HTASK;
+typedef HANDLE32 HWAVE;
+typedef HANDLE32 HWAVEIN;
+typedef HANDLE32 HWAVEOUT;
+typedef HANDLE32 HWND;
+# else  /* WINELIB32 */
 typedef INT16 INT;
 typedef UINT16 UINT;
 typedef BOOL16 BOOL;
@@ -4113,7 +4201,6 @@ typedef HANDLE16 HMIDI;
 typedef HANDLE16 HMIDIIN;
 typedef HANDLE16 HMIDIOUT;
 typedef HANDLE16 HMMIO;
-typedef HANDLE16 HMODULE;
 typedef HANDLE16 HQUEUE;
 typedef HANDLE16 HRGN;
 typedef HANDLE16 HRSRC;
@@ -4122,8 +4209,8 @@ typedef HANDLE16 HWAVE;
 typedef HANDLE16 HWAVEIN;
 typedef HANDLE16 HWAVEOUT;
 typedef HANDLE16 HWND;
-typedef FARPROC16 FARPROC;
-#endif  /* WINELIB */
+# endif  /* WINELIB32 */
+#endif  /* __WINE__ */
 
 /* Callback function pointers types. */
 
@@ -4135,7 +4222,7 @@ typedef int (*FONTENUMPROC)(const void*,const void*,DWORD,LPARAM);
 typedef int (*GOBJENUMPROC)(LPVOID,LPARAM);
 /*typedef int (*MFENUMPROC)(HDC,HANDLETABLE*,METARECORD*,int,LPARAM);*/
 typedef int (*MFENUMPROC)(HDC,void*,void*,int,LPARAM);
-typedef BOOL (*PROPENUMPROC)(HWND,LPCTSTR,HANDLE);
+typedef BOOL (*PROPENUMPROC)(HWND,LPCSTR,HANDLE);
 #else
 typedef SEGPTR DRIVERPROC;
 typedef SEGPTR EDITWORDBREAKPROC;
@@ -4144,15 +4231,11 @@ typedef SEGPTR GOBJENUMPROC;
 typedef SEGPTR MFENUMPROC;
 typedef SEGPTR PROPENUMPROC;
 #endif
-typedef FARPROC HOOKPROC;
-
 
-INT        AccessResource(HINSTANCE,HRSRC);
 ATOM       AddAtom(SEGPTR);
 INT        AddFontResource(LPCSTR);
 WORD       AllocCStoDSAlias(WORD);
 WORD       AllocDStoCSAlias(WORD);
-HGLOBAL    AllocResource(HINSTANCE,HRSRC,DWORD);
 BOOL       AnimatePalette(HPALETTE16,UINT,UINT,LPPALETTEENTRY);
 LPSTR      AnsiLower(LPSTR);
 UINT       AnsiLowerBuff(LPSTR,UINT);
@@ -4172,7 +4255,6 @@ BOOL       BuildCommDCB(LPCSTR,DCB*);
 void       CalcChildScroll(HWND,WORD);
 BOOL       CallMsgFilter(SEGPTR,INT);
 LRESULT    CallNextHookEx(HHOOK,INT,WPARAM,LPARAM);
-INT        Catch(LPCATCHBUF);
 BOOL       ChangeClipboardChain(HWND,HWND);
 WORD       ChangeSelector(WORD,WORD);
 INT        CheckMenuItem(HMENU,UINT,UINT);
@@ -4194,7 +4276,6 @@ HANDLE     CreateCursorIconIndirect(HANDLE,CURSORICONINFO*,const BYTE*,const BYT
 HDC        CreateDC(LPCSTR,LPCSTR,LPCSTR,const DEVMODE*);
 HBRUSH     CreateDIBPatternBrush(HGLOBAL,UINT);
 HBITMAP    CreateDIBitmap(HDC,BITMAPINFOHEADER*,DWORD,LPVOID,BITMAPINFO*,UINT);
-HFONT      CreateFont(INT,INT,INT,INT,INT,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,LPCSTR);
 HBRUSH     CreateHatchBrush(INT,COLORREF);
 HDC        CreateIC(LPCSTR,LPCSTR,LPCSTR,const DEVMODE*);
 HICON      CreateIcon(HINSTANCE,INT,INT,BYTE,BYTE,const BYTE*,const BYTE*);
@@ -4248,21 +4329,17 @@ int        ExcludeClipRect(HDC,short,short,short,short);
 int        ExcludeVisRect(HDC,short,short,short,short);
 BOOL       ExitWindows(DWORD,WORD);
 HICON      ExtractIcon(HINSTANCE,LPCSTR,WORD);
-HANDLE16   FarGetOwner(HANDLE16);
-void       FarSetOwner(HANDLE16,HANDLE16);
 void       FatalAppExit(UINT,LPCSTR);
 void       FatalExit(int);
 BOOL       FillRgn(HDC,HRGN,HBRUSH);
 ATOM       FindAtom(SEGPTR);
 HINSTANCE  FindExecutable(LPCSTR,LPCSTR,LPSTR);
-HRSRC      FindResource(HINSTANCE,SEGPTR,SEGPTR);
 BOOL       FlashWindow(HWND,BOOL);
 int        FlushComm(int,int);
 BOOL       FrameRgn(HDC,HRGN,HBRUSH,int,int);
 void       FreeLibrary(HANDLE);
-BOOL       FreeResource(HGLOBAL);
 UINT       GDIRealizePalette(HDC);
-HPALETTE16 GDISelectPalette(HDC,HPALETTE16);
+HPALETTE16 GDISelectPalette(HDC,HPALETTE16,WORD);
 HWND       GetActiveWindow(void);
 DWORD      GetAspectRatioFilter(HDC);
 int        GetAsyncKeyState(int);
@@ -4279,8 +4356,8 @@ HANDLE     GetClipboardData(WORD);
 int        GetClipboardFormatName(WORD,LPSTR,short);
 HWND       GetClipboardOwner(void);
 HWND       GetClipboardViewer(void);
-HANDLE     GetCodeHandle(FARPROC);
-void       GetCodeInfo(FARPROC,LPVOID);
+HANDLE     GetCodeHandle(FARPROC16);
+void       GetCodeInfo(FARPROC16,LPVOID);
 int        GetCommError(int,COMSTAT*);
 UINT       GetCommEventMask(int,int);
 int        GetCommState(int,DCB*);
@@ -4304,7 +4381,6 @@ HWND       GetDlgItem(HWND,WORD);
 WORD       GetDlgItemInt(HWND,WORD,BOOL*,BOOL);
 WORD       GetDoubleClickTime(void);
 int        GetEnvironment(LPSTR,LPSTR,WORD);
-HMODULE    GetExePtr(HANDLE);
 HWND       GetFocus(void);
 DWORD      GetFreeSpace(UINT16);
 DWORD      GetHeapSpaces(HMODULE16);
@@ -4334,7 +4410,7 @@ HANDLE     GetMetaFileBits(HANDLE);
 int        GetModuleFileName(HANDLE,LPSTR,short);
 HMODULE16  GetModuleHandle(LPCSTR);
 int        GetModuleUsage(HANDLE);
-FARPROC    GetMouseEventProc(void);
+FARPROC16  GetMouseEventProc(void);
 DWORD      GetNearestColor(HDC,DWORD);
 WORD       GetNearestPaletteIndex(HPALETTE16,DWORD);
 HWND       GetNextDlgGroupItem(HWND,HWND,BOOL);
@@ -4364,7 +4440,6 @@ HANDLE     GetStockObject(int);
 WORD       GetStretchBltMode(HDC);
 HMENU      GetSubMenu(HMENU,short);
 COLORREF   GetSysColor(short);
-HWND       GetSysModalWindow(void);
 HMENU      GetSystemMenu(HWND,BOOL);
 int        GetSystemMetrics(WORD);
 WORD       GetSystemPaletteEntries(HDC,WORD,WORD,LPPALETTEENTRY);
@@ -4399,13 +4474,13 @@ void       GlobalFix(HGLOBAL16);
 void       GlobalFreeAll(HGLOBAL16);
 HGLOBAL16  GlobalLRUNewest(HGLOBAL16);
 HGLOBAL16  GlobalLRUOldest(HGLOBAL16);
-void       GlobalNotify(FARPROC);
+void       GlobalNotify(FARPROC16);
 WORD       GlobalPageLock(HGLOBAL16);
 WORD       GlobalPageUnlock(HGLOBAL16);
 BOOL16     GlobalUnWire(HGLOBAL16);
 void       GlobalUnfix(HGLOBAL16);
 SEGPTR     GlobalWire(HGLOBAL16);
-BOOL       GrayString(HDC,HBRUSH,FARPROC,LPARAM,INT,INT,INT,INT,INT);
+BOOL       GrayString(HDC,HBRUSH,FARPROC16,LPARAM,INT,INT,INT,INT,INT);
 BOOL       HiliteMenuItem(HWND,HMENU,UINT,UINT);
 BOOL       InSendMessage(void);
 WORD       InitAtomTable(WORD);
@@ -4433,19 +4508,11 @@ BOOL       IsWindowEnabled(HWND);
 BOOL       IsWindowVisible(HWND);
 BOOL       IsZoomed(HWND);
 void       LimitEmsPages(DWORD);
-void       LineDDA(short,short,short,short,FARPROC,long);
+void       LineDDA(short,short,short,short,FARPROC16,long);
 BOOL       LineTo(HDC,short,short);
-HANDLE     LoadAccelerators(HANDLE,SEGPTR);
-HBITMAP    LoadBitmap(HANDLE,SEGPTR);
-HCURSOR    LoadCursor(HANDLE,SEGPTR);
-HICON      LoadIcon(HANDLE,SEGPTR);
 HANDLE     LoadLibrary(LPCSTR);
-HMENU      LoadMenu(HANDLE,SEGPTR);
 HANDLE     LoadModule(LPCSTR,LPVOID);
-HGLOBAL    LoadResource(HINSTANCE,HRSRC);
-int        LoadString(HANDLE,WORD,LPSTR,int);
-FARPROC    LocalNotify(FARPROC);
-LPVOID     LockResource(HGLOBAL);
+FARPROC16  LocalNotify(FARPROC16);
 HMENU      LookupMenuHandle(HMENU,INT);
 WORD       MapVirtualKey(WORD,WORD);
 void       MessageBeep(WORD);
@@ -4482,7 +4549,6 @@ void       ProfStop(void);
 BOOL       PtVisible(HDC,short,short);
 int        ReadComm(int,LPSTR,int);
 WORD       RealizeDefaultPalette(HDC);
-UINT       RealizePalette(HDC);
 BOOL       Rectangle(HDC,INT,INT,INT,INT);
 WORD       RegisterClipboardFormat(LPCSTR);
 void       ReleaseCapture(void);
@@ -4546,7 +4612,7 @@ WORD       SetPolyFillMode(HDC,WORD);
 BOOL       SetProp(HWND,SEGPTR,HANDLE);
 WORD       SetROP2(HDC,WORD);
 WORD       SetRelAbs(HDC,WORD);
-FARPROC    SetResourceHandler(HANDLE,LPSTR,FARPROC);
+FARPROC16  SetResourceHandler(HANDLE,LPSTR,FARPROC16);
 int        SetScrollPos(HWND,int,int,BOOL);
 void       SetScrollRange(HWND,int,int,int,BOOL);
 WORD       SetSelectorBase(WORD,DWORD);
@@ -4555,7 +4621,6 @@ int        SetSoundNoise(int,int);
 WORD       SetStretchBltMode(HDC,WORD);
 LONG       SetSwapAreaSize(WORD);
 void       SetSysColors(int,LPINT16,COLORREF*);
-HWND       SetSysModalWindow(HWND);
 WORD       SetSystemPaletteUse(HDC,WORD);
 BOOL       SetSystemPowerState(BOOL, BOOL);
 BOOL       SetSystemTime(const SYSTEMTIME*);
@@ -4572,14 +4637,14 @@ int        SetVoiceSound(int,LONG,int);
 int        SetVoiceThreshold(int,int);
 BOOL       SetWinDebugInfo(LPWINDEBUGINFO);
 BOOL       SetWindowPos(HWND,HWND,INT,INT,INT,INT,WORD);
-FARPROC    SetWindowsHook(short,FARPROC);
-HHOOK      SetWindowsHookEx(short,HOOKPROC,HINSTANCE,HTASK);
+FARPROC16  SetWindowsHook(short,HOOKPROC16);
+HHOOK      SetWindowsHookEx(INT16,HOOKPROC16,HINSTANCE,HTASK);
 HINSTANCE  ShellExecute(HWND,LPCSTR,LPCSTR,LPSTR,LPCSTR,INT);
 int        ShowCursor(BOOL);
 void       ShowOwnedPopups(HWND,BOOL);
 void       ShowScrollBar(HWND,WORD,BOOL);
 BOOL       ShowWindow(HWND,int);
-DWORD      SizeofResource(HINSTANCE,HRSRC);
+DWORD      SizeofResource(HMODULE16,HRSRC);
 VOID       Sleep(DWORD); /* Win32 */
 int        StartSound(void);
 int        StopSound(void);
@@ -4592,14 +4657,13 @@ void       SwitchStackTo(WORD,WORD,WORD);
 int        SyncAllVoices(void);
 BOOL       SystemParametersInfo(UINT,UINT,LPVOID,UINT);
 LONG       TabbedTextOut(HDC,short,short,LPSTR,short,short,LPINT16,short);
-int        Throw(LPCATCHBUF,int);
 int        ToAscii(WORD,WORD,LPSTR,LPVOID,WORD);
 int        TranslateAccelerator(HWND,HANDLE,LPMSG16);
 BOOL       TranslateMDISysAccel(HWND,LPMSG16);
 BOOL       TranslateMessage(LPMSG16);
 int        TransmitCommChar(int,char);
 int        UngetCommChar(int,char);
-BOOL       UnhookWindowsHook(short,FARPROC);
+BOOL       UnhookWindowsHook(short,HOOKPROC16);
 BOOL       UnhookWindowsHookEx(HHOOK);
 BOOL       UnrealizeObject(HBRUSH);
 int        UpdateColors(HDC);
index c22e2e16c64c705db63d50a27323bbde64ad4b5c..0fb32026804844bc0702d3f745e751e3b69bb812 100644 (file)
@@ -196,7 +196,7 @@ void WSASetLastError(INT iError);
 INT WSAGetLastError(void);
 BOOL WSAIsBlocking(void);
 INT WSAUnhookBlockingHook(void);
-FARPROC WSASetBlockingHook(FARPROC lpBlockFunc);
+FARPROC16 WSASetBlockingHook(FARPROC16 lpBlockFunc);
 INT WSACancelBlockingCall(void);
 HANDLE WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
                              LPCSTR name, LPCSTR proto,
index 9fe61f2b2cd980c26c655db24eb12f08c5b989fd..5a61ec9af78b75b6bf94906ac28d08521e801e07 100644 (file)
@@ -7,6 +7,15 @@
 #ifndef __WINE_WINTYPES_H
 #define __WINE_WINTYPES_H
 
+#ifdef __WINE__
+#include "config.h"
+#endif
+
+#if !defined(__WINE__) && !defined(WINELIB)
+/* If we are not compiling Wine, then we are using Winelib */
+#define WINELIB
+#endif
+
 #ifdef WINELIB
 # ifdef WINELIB16
 #  undef WINELIB32
 /* Macros to map Winelib names to the correct implementation name */
 /* depending on WINELIB16, WINELIB32 and UNICODE macros.          */
 
-#ifdef WINELIB
+#ifdef __WINE__
+# define WINELIB_NAME(func)      this is a syntax error
+# define WINELIB_NAME_AW(func)   this is a syntax error
+#else  /* __WINE__ */
 # ifdef WINELIB32
 #  define WINELIB_NAME(func)     func##32
 #  ifdef UNICODE
 #  define WINELIB_NAME(func)     func##16
 #  define WINELIB_NAME_AW(func)  func##16
 # endif  /* WINELIB32 */
-#else   /* WINELIB */
-# define WINELIB_NAME(func)      this is a syntax error
-# define WINELIB_NAME_AW(func)   this is a syntax error
-#endif  /* WINELIB */
+#endif  /* __WINE__ */
 
-#ifdef WINELIB
-# define DECL_WINELIB_TYPE(type)     typedef WINELIB_NAME(type) type
-# define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type
-#else   /* WINELIB */
+#ifdef __WINE__
 # define DECL_WINELIB_TYPE(type)     /* nothing */
 # define DECL_WINELIB_TYPE_AW(type)  /* nothing */
-#endif  /* WINELIB */
+#else   /* __WINE__ */
+# define DECL_WINELIB_TYPE(type)     typedef WINELIB_NAME(type) type
+# define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type
+#endif  /* __WINE__ */
 
 /* Standard data types. These are the same for emulator and library. */
 
@@ -86,6 +95,7 @@ typedef ACCESS_MASK     REGSAM;
 typedef INT16           HFILE;
 typedef HANDLE32        HHOOK;
 typedef HANDLE32        HKEY;
+typedef HANDLE32        HMIXEROBJ;
 
 /* Pointers types. These are the same for emulator and library. */
 
@@ -104,6 +114,7 @@ typedef UINT16         *LPUINT16;
 typedef INT32          *LPINT32;
 typedef UINT32         *LPUINT32;
 typedef HKEY           *LPHKEY;
+typedef HMIXEROBJ      *LPHMIXEROBJ;
 
 /* Special case: a segmented pointer is just a pointer in the library. */
 
@@ -153,6 +164,7 @@ DECLARE_HANDLE(HWND);
 
 typedef LRESULT (*DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
 typedef LRESULT (*FARPROC16)();
+typedef LRESULT (*HOOKPROC16)(INT16,WPARAM16,LPARAM);
 typedef VOID (*TIMERPROC16)(HWND16,UINT16,UINT16,DWORD);
 typedef LRESULT (*WNDENUMPROC16)(HWND16,LPARAM);
 typedef LRESULT (*WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
@@ -161,6 +173,7 @@ typedef LRESULT (*WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
 
 typedef LRESULT (*DLGPROC32)(HWND32,UINT32,WPARAM32,LPARAM);
 typedef LRESULT (*FARPROC32)();
+typedef LRESULT (*HOOKPROC32)(INT32,WPARAM32,LPARAM);
 typedef VOID (*TIMERPROC32)(HWND32,UINT32,UINT32,DWORD);
 typedef LRESULT (*WNDENUMPROC32)(HWND32,LPARAM);
 typedef LRESULT (*WNDPROC32)(HWND32,UINT32,WPARAM32,LPARAM);
@@ -169,7 +182,7 @@ typedef LRESULT (*WNDPROC32)(HWND32,UINT32,WPARAM32,LPARAM);
 /* These types are _not_ defined for the emulator, because they */
 /* depend on the UNICODE macro that only exists in user's code. */
 
-#ifdef WINELIB
+#ifndef __WINE__
 # if defined(WINELIB32) && defined(UNICODE)
 typedef WCHAR TCHAR;
 typedef LPWSTR LPTSTR;
@@ -179,7 +192,7 @@ typedef CHAR TCHAR;
 typedef LPSTR LPTSTR;
 typedef LPCSTR LPCTSTR;
 # endif /* WINELIB32 && UNICODE */
-#endif   /* WINELIB */
+#endif   /* __WINE__ */
 
 /* Data types specific to the library. These do _not_ exist in the emulator. */
 
@@ -247,7 +260,7 @@ DECL_WINELIB_TYPE(WNDPROC);
 
 /* Define some empty macros for compatibility with Windows code. */
 
-#ifdef WINELIB
+#ifndef __WINE__
 #define CALLBACK
 #define NEAR
 #define FAR
@@ -257,15 +270,15 @@ DECL_WINELIB_TYPE(WNDPROC);
 #define _near
 #define _pascal
 #define __export
-#endif  /* WINELIB */
+#endif  /* __WINE__ */
 
 /* Macro for structure packing. */
 
-#ifdef WINELIB
-#define WINE_PACKED
-#else
+#ifdef __GNUC__
 #define WINE_PACKED __attribute__ ((packed))
-#endif  /* WINELIB */
+#else
+#define WINE_PACKED  /* nothing */
+#endif
 
 /* Macros to split words and longs. */
 
@@ -289,7 +302,7 @@ DECL_WINELIB_TYPE(WNDPROC);
 
 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
 
-#if !defined(WINELIB) || defined(__i386__)
+#ifdef __i386__
 #define PUT_WORD(ptr,w)   (*(WORD *)(ptr) = (w))
 #define GET_WORD(ptr)     (*(WORD *)(ptr))
 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
@@ -303,7 +316,7 @@ DECL_WINELIB_TYPE(WNDPROC);
                            PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
 #define GET_DWORD(ptr)    ((DWORD)(GET_WORD(ptr) | \
                                    ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
-#endif  /* !WINELIB || __i386__ */
+#endif  /* __i386__ */
 
 /* MIN and MAX macros */
 
index 4cba8751b0da62f1deb79d8c7780b417dfa4820c..9cd6041cd79766212a311d496e939974264444a2 100644 (file)
@@ -40,6 +40,8 @@ typedef struct
     LPCWSTR     lpszClassName;
 } WNDCLASS32W, *LPWNDCLASS32W;
 
+#pragma pack(1)
+
 typedef struct
 {
     UINT16      style;
@@ -54,6 +56,8 @@ typedef struct
     SEGPTR      lpszClassName WINE_PACKED;
 } WNDCLASS16, *LPWNDCLASS16;
 
+#pragma pack(4)
+
 typedef struct
 {
     UINT32      cbSize;
index a2c368bb73f24064f8e5b83d2bdc506cd5e51613..cd5ec969d46e950094395f1db305fd7a17a00623 100644 (file)
@@ -1,3 +1,4 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
 MODULE = ipc
 
index 22e8a1eef8ec14431ddac61f2a4eb13594fa4f6d..ed3aade5fe24028c99ef4f685b705917686ef00d 100644 (file)
@@ -1,3 +1,4 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
 MODULE = library
 
index f3c4e5abec2243b9d58414a8b8361fd271945a35..f7b450e08c7288b23784d92c386c3d5c841891dd 100644 (file)
@@ -32,7 +32,7 @@ void LIBRES_RegisterResources(const struct resource* const * Res)
 /**********************************************************************
  *         LIBRES_FindResource    
  */
-HRSRC LIBRES_FindResource( HINSTANCE hModule, LPCSTR name, LPCSTR type )
+HRSRC32 LIBRES_FindResource( HINSTANCE hModule, LPCSTR name, LPCSTR type )
 {
   int nameid=0,typeid;
   ResListE* ResBlock;
@@ -68,12 +68,12 @@ HRSRC LIBRES_FindResource( HINSTANCE hModule, LPCSTR name, LPCSTR type )
     for(Res=ResBlock->Resources; *Res; Res++)
       if(name)
       {
-       if((*Res)->type==typeid && !lstrcmpi((*Res)->name,name))
-         return (HRSRC)*Res;
+       if((*Res)->type==typeid && !lstrcmpi32A((*Res)->name,name))
+         return (HRSRC32)*Res;
       }
       else
        if((*Res)->type==typeid && (*Res)->id==nameid)
-         return (HRSRC)*Res;
+         return (HRSRC32)*Res;
   return 0;
 }
 
@@ -81,16 +81,16 @@ HRSRC LIBRES_FindResource( HINSTANCE hModule, LPCSTR name, LPCSTR type )
 /**********************************************************************
  *         LIBRES_LoadResource    
  */
-HGLOBAL LIBRES_LoadResource( HINSTANCE hModule, HRSRC hRsrc )
+HGLOBAL32 LIBRES_LoadResource( HINSTANCE hModule, HRSRC32 hRsrc )
 {
-  return (HGLOBAL)(((struct resource*)hRsrc)->bytes);
+  return (HGLOBAL32)(((struct resource*)hRsrc)->bytes);
 }
 
 
 /**********************************************************************
  *         LIBRES_LockResource    
  */
-LPVOID LIBRES_LockResource( HGLOBAL handle )
+LPVOID LIBRES_LockResource( HGLOBAL32 handle )
 {
   return (LPVOID)handle;
 }
@@ -118,7 +118,7 @@ INT LIBRES_AccessResource( HINSTANCE hModule, HRSRC hRsrc )
 /**********************************************************************
  *         LIBRES_SizeofResource    
  */
-DWORD LIBRES_SizeofResource( HINSTANCE hModule, HRSRC hRsrc )
+DWORD LIBRES_SizeofResource( HINSTANCE hModule, HRSRC32 hRsrc )
 {
   return (DWORD)(((struct resource*)hRsrc)->size);
 }
index ca70c3536ea42bf1321f15f1bab6441d8b19382c..0f3d9a0f3fe2bae1b03584c6c3f7038eece96523 100644 (file)
@@ -41,7 +41,7 @@ int CallTo32_LargeStack( int (*func)(), int nbargs, ...)
   }
 }
 
-WORD CallTo16_word_ ( FARPROC func, WORD arg ) { return func(arg); }
+WORD CallTo16_word_ ( FARPROC16 func, WORD arg ) { return func(arg); }
 
 extern LRESULT AboutDlgProc(HWND,UINT,WPARAM,LPARAM);
 extern LRESULT ColorDlgProc(HWND,UINT,WPARAM,LPARAM);
@@ -60,22 +60,16 @@ extern LRESULT ReplaceTextDlgProc(HWND,UINT,WPARAM,LPARAM);
 extern LRESULT ScrollBarWndProc(HWND,UINT,WPARAM,LPARAM);
 extern LRESULT StaticWndProc(HWND,UINT,WPARAM,LPARAM);
 extern LRESULT SystemMessageBoxProc(HWND,UINT,WPARAM,LPARAM);
-extern LRESULT TASK_Reschedule(HWND,UINT,WPARAM,LPARAM);
-
-LRESULT ErrorProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
-{
-  fprintf(stderr,"ERROR: ErrorProc() called!\n");
-  return 0;
-}
+extern LRESULT TASK_Reschedule(void);
 
 /***********************************************************************
  *           MODULE_GetWndProcEntry16 (not a Windows API function)
  *
  * Return an entry point from the WPROCS dll.
  */
-WNDPROC MODULE_GetWndProcEntry16( char *name )
+FARPROC16 MODULE_GetWndProcEntry16( char *name )
 {
-#define MAP_STR_TO_PROC(str,proc) if(!strcmp(name,str))return proc
+#define MAP_STR_TO_PROC(str,proc) if(!strcmp(name,str))return (FARPROC16)proc
   MAP_STR_TO_PROC("AboutDlgProc",AboutDlgProc);
   MAP_STR_TO_PROC("ColorDlgProc",ColorDlgProc);
   MAP_STR_TO_PROC("ComboBoxWndProc",ComboBoxWndProc);
@@ -96,7 +90,7 @@ WNDPROC MODULE_GetWndProcEntry16( char *name )
   MAP_STR_TO_PROC("SystemMessageBoxProc",SystemMessageBoxProc);
   MAP_STR_TO_PROC("TASK_Reschedule",TASK_Reschedule);
   fprintf(stderr,"warning: No mapping for %s(), add one in library/miscstubs.c\n",name);
-  return ErrorProc;
+  return NULL;
 }
 
 void DEBUG_EnterDebugger(void)
index 166ce95647a030e53fe9ccaafad51982951fe4b4..ba99e39ee178ace01b00fae29b797cd17068f74c 100644 (file)
@@ -1,3 +1,4 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
 MODULE = loader
 
index 73ebcd5d28752da3fbfce0b6d43b04f6cd2fc099..4717f66a6eab1f495b8b3f536b8edc565e83d142 100644 (file)
@@ -199,7 +199,7 @@ BOOL16 BUILTIN_Init(void)
  */
 HMODULE16 BUILTIN_LoadModule( LPCSTR name, BOOL16 force )
 {
-    HMODULE hModule;
+    HMODULE16 hModule;
     NE_MODULE *pModule;
     BUILTIN_DLL *table;
     char dllname[16], *p;
index 63c44e297ec14e61cf9d484a1e6ca92e8836a0a9..31a998bac9f64520a4dc4b0b9a1e97d7ba2680f5 100644 (file)
@@ -194,7 +194,7 @@ void MODULE_DumpModule( HMODULE16 hmodule )
  */
 void MODULE_WalkModules(void)
 {
-    HMODULE hModule = hFirstModule;
+    HMODULE16 hModule = hFirstModule;
     fprintf( stderr, "Module Flags Name\n" );
     while (hModule)
     {
@@ -368,6 +368,84 @@ HINSTANCE16 MODULE_CreateInstance( HMODULE16 hModule, LOADPARAMS *params )
 }
 
 
+/***********************************************************************
+ *           MODULE_CreateDummyModule
+ *
+ * Create a dummy NE module for Win32 or Winelib.
+ */
+HMODULE16 MODULE_CreateDummyModule( const OFSTRUCT *ofs )
+{
+    HMODULE16 hModule;
+    NE_MODULE *pModule;
+    SEGTABLEENTRY *pSegment;
+    char *pStr;
+
+    INT32 of_size = sizeof(OFSTRUCT) - sizeof(ofs->szPathName)
+                    + strlen(ofs->szPathName) + 1;
+    INT32 size = sizeof(NE_MODULE) +
+                 /* loaded file info */
+                 of_size +
+                 /* segment table: DS,CS */
+                 2 * sizeof(SEGTABLEENTRY) +
+                 /* name table */
+                 9 +
+                 /* several empty tables */
+                 8;
+
+    hModule = GlobalAlloc16( GMEM_MOVEABLE | GMEM_ZEROINIT, size );
+    if (!hModule) return (HMODULE16)11;  /* invalid exe */
+
+    FarSetOwner( hModule, hModule );
+    pModule = (NE_MODULE *)GlobalLock16( hModule );
+
+    /* Set all used entries */
+    pModule->magic            = NE_SIGNATURE;
+    pModule->count            = 1;
+    pModule->next             = 0;
+    pModule->flags            = 0;
+    pModule->dgroup           = 1;
+    pModule->ss               = 1;
+    pModule->cs               = 2;
+    pModule->heap_size        = 0xe000;
+    pModule->stack_size       = 0x1000;
+    pModule->seg_count        = 2;
+    pModule->modref_count     = 0;
+    pModule->nrname_size      = 0;
+    pModule->fileinfo         = sizeof(NE_MODULE);
+    pModule->os_flags         = NE_OSFLAGS_WINDOWS;
+    pModule->expected_version = 0x030a;
+    pModule->self             = hModule;
+
+    /* Set loaded file information */
+    memcpy( pModule + 1, ofs, of_size );
+    ((OFSTRUCT *)(pModule+1))->cBytes = of_size - 1;
+
+    pSegment = (SEGTABLEENTRY*)((char*)(pModule + 1) + of_size);
+    pModule->seg_table = pModule->dgroup_entry = (int)pSegment - (int)pModule;
+    /* Data segment */
+    pSegment->size    = 0;
+    pSegment->flags   = NE_SEGFLAGS_DATA;
+    pSegment->minsize = 0x1000;
+    pSegment++;
+    /* Code segment */
+    pSegment->flags   = 0;
+    pSegment++;
+
+    /* Module name */
+    pStr = (char *)pSegment;
+    pModule->name_table = (int)pStr - (int)pModule;
+    strcpy( pStr, "\x08W32SXXXX" );
+    pStr += 9;
+
+    /* All tables zero terminated */
+    pModule->res_table = pModule->import_table = pModule->entry_table =
+               (int)pStr - (int)pModule;
+
+    MODULE_RegisterModule( pModule );
+    return hModule;
+}
+
+
 /***********************************************************************
  *           MODULE_LoadExeHeader
  */
@@ -932,6 +1010,7 @@ HINSTANCE LoadModule( LPCSTR name, LPVOID paramBlock )
     HANDLE hInstance, hPrevInstance;
     NE_MODULE *pModule;
     LOADPARAMS *params = (LOADPARAMS *)paramBlock;
+    OFSTRUCT ofs;
 #ifndef WINELIB
     WORD *pModRef, *pDLLs;
     HFILE hFile;
@@ -941,8 +1020,6 @@ HINSTANCE LoadModule( LPCSTR name, LPVOID paramBlock )
 
     if (!hModule)  /* We have to load the module */
     {
-        OFSTRUCT ofs;
-
         /* Try to load the built-in first if not disabled */
         if ((hModule = BUILTIN_LoadModule( name, FALSE ))) return hModule;
 
@@ -1134,13 +1211,11 @@ HINSTANCE LoadModule( LPCSTR name, LPVOID paramBlock )
         pModule->count++;
     }
 #else
-    hModule = GlobalAlloc16( GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(NE_MODULE));
+    lstrcpyn32A( ofs.szPathName, name, sizeof(ofs.szPathName) );
+    if ((hModule = MODULE_CreateDummyModule( &ofs )) < 32) return hModule;
     pModule = (NE_MODULE *)GlobalLock16( hModule );
-    pModule->count = 1;
-    pModule->magic = NE_SIGNATURE;
-    pModule->self = hModule;
     hPrevInstance = 0;
-    hInstance = MODULE_CreateInstance( hModule, (LOADPARAMS*)paramBlock );
+    hInstance = MODULE_CreateInstance( hModule, params );
 #endif /* WINELIB */
 
       /* Create a task for this instance */
index 359242be1a80048c26bd605b0d419f8787215dae..ad5af2fedbcd68157f692722b196d3037a92ad08 100644 (file)
 /***********************************************************************
  *           NE_LoadSegment
  */
-BOOL NE_LoadSegment( HMODULE hModule, WORD segnum )
+BOOL NE_LoadSegment( HMODULE16 hModule, WORD segnum )
 {
     NE_MODULE *pModule;
     SEGTABLEENTRY *pSegTable, *pSeg;
     WORD *pModuleTable;
     WORD count, i, offset;
-    HMODULE module;
+    HMODULE16 module;
     FARPROC16 address;
     int fd;
     struct relocation_entry_s *rep, *reloc_entries;
@@ -449,7 +449,7 @@ void NE_FixupPrologs( NE_MODULE *pModule )
  *
  * Call the DLL initialization code
  */
-static BOOL NE_InitDLL( HMODULE hModule )
+static BOOL NE_InitDLL( HMODULE16 hModule )
 {
 #ifndef WINELIB
     int cs_reg, ds_reg, ip_reg, cx_reg, di_reg, bp_reg;
@@ -498,7 +498,7 @@ static BOOL NE_InitDLL( HMODULE hModule )
     pModule->cs = 0;  /* Don't initialize it twice */
     dprintf_dll( stddeb, "Calling LibMain, cs:ip=%04x:%04x ds=%04x di=%04x cx=%04x\n", 
                  cs_reg, ip_reg, ds_reg, di_reg, cx_reg );
-    return CallTo16_regs_( (FARPROC)(cs_reg << 16 | ip_reg), ds_reg,
+    return CallTo16_regs_( (FARPROC16)(cs_reg << 16 | ip_reg), ds_reg,
                            0 /*es*/, 0 /*bp*/, 0 /*ax*/, 0 /*bx*/,
                            cx_reg, 0 /*dx*/, 0 /*si*/, di_reg );
 #else
@@ -513,10 +513,10 @@ static BOOL NE_InitDLL( HMODULE hModule )
  *
  * Initialize the loaded DLLs.
  */
-void NE_InitializeDLLs( HMODULE hModule )
+void NE_InitializeDLLs( HMODULE16 hModule )
 {
     NE_MODULE *pModule;
-    HMODULE *pDLL;
+    HMODULE16 *pDLL;
 
     if (!(pModule = MODULE_GetPtr( hModule ))) return;
     if (pModule->flags & NE_FFLAGS_WIN32)
@@ -528,7 +528,7 @@ void NE_InitializeDLLs( HMODULE hModule )
     {
        HANDLE to_init = pModule->dlls_to_init;
        pModule->dlls_to_init = 0;
-        for (pDLL = (HMODULE *)GlobalLock16( to_init ); *pDLL; pDLL++)
+        for (pDLL = (HMODULE16 *)GlobalLock16( to_init ); *pDLL; pDLL++)
         {
             NE_InitializeDLLs( *pDLL );
             NE_InitDLL( *pDLL );
index 289e34650ecd8d82acd208dc45d4955059aefd20..bd74e65aec63d3106caa4509d7bbc29e33a1997e 100644 (file)
@@ -30,7 +30,7 @@
  * Find the type and resource id from their names.
  * Return value is MAKELONG( typeId, resId ), or 0 if not found.
  */
-static DWORD NE_FindNameTableId( HMODULE hModule, SEGPTR typeId, SEGPTR resId )
+static DWORD NE_FindNameTableId( HMODULE16 hModule, SEGPTR typeId, SEGPTR resId )
 {
     NE_MODULE *pModule;
     NE_TYPEINFO *pTypeInfo;
@@ -52,9 +52,9 @@ static DWORD NE_FindNameTableId( HMODULE hModule, SEGPTR typeId, SEGPTR resId )
         {
             dprintf_resource( stddeb, "NameTable entry: type=%04x id=%04x\n",
                               pTypeInfo->type_id, pNameInfo->id );
-            handle = LoadResource( hModule, 
+            handle = LoadResource16( hModule, 
                                   (HANDLE)((int)pNameInfo - (int)pModule) );
-            for(p = (WORD*)LockResource(handle); p && *p; p = (WORD *)((char*)p+*p))
+            for(p = (WORD*)LockResource16(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],
@@ -88,7 +88,7 @@ static DWORD NE_FindNameTableId( HMODULE hModule, SEGPTR typeId, SEGPTR resId )
                 ret = MAKELONG( p[1], p[2] );
                 break;
             }
-            FreeResource( handle );
+            FreeResource16( handle );
             if (ret) return ret;
         }
     }
@@ -134,7 +134,7 @@ static HRSRC NE_FindResourceFromType( NE_MODULE *pModule,
 /***********************************************************************
  *           NE_FindResource
  */
-HRSRC NE_FindResource( HMODULE hModule, SEGPTR typeId, SEGPTR resId )
+HRSRC NE_FindResource( HMODULE16 hModule, SEGPTR typeId, SEGPTR resId )
 {
     NE_TYPEINFO *pTypeInfo;
     HRSRC hRsrc;
@@ -211,7 +211,7 @@ HRSRC NE_FindResource( HMODULE hModule, SEGPTR typeId, SEGPTR resId )
 /***********************************************************************
  *           NE_AllocResource
  */
-HGLOBAL NE_AllocResource( HMODULE hModule, HRSRC hRsrc, DWORD size )
+HGLOBAL NE_AllocResource( HMODULE16 hModule, HRSRC hRsrc, DWORD size )
 {
     NE_NAMEINFO *pNameInfo=NULL;
     WORD sizeShift;
@@ -231,7 +231,7 @@ HGLOBAL NE_AllocResource( HMODULE hModule, HRSRC hRsrc, DWORD size )
 /***********************************************************************
  *           NE_AccessResource
  */
-int NE_AccessResource( HMODULE hModule, HRSRC hRsrc )
+int NE_AccessResource( HMODULE16 hModule, HRSRC hRsrc )
 {
     NE_NAMEINFO *pNameInfo=NULL;
     int fd;
@@ -254,7 +254,7 @@ int NE_AccessResource( HMODULE hModule, HRSRC hRsrc )
 /***********************************************************************
  *           NE_SizeofResource
  */
-DWORD NE_SizeofResource( HMODULE hModule, HRSRC hRsrc )
+DWORD NE_SizeofResource( HMODULE16 hModule, HRSRC hRsrc )
 {
     NE_NAMEINFO *pNameInfo=NULL;
     WORD sizeShift;
@@ -272,7 +272,7 @@ DWORD NE_SizeofResource( HMODULE hModule, HRSRC hRsrc )
 /***********************************************************************
  *           NE_LoadResource
  */
-HGLOBAL NE_LoadResource( HMODULE hModule,  HRSRC hRsrc )
+HGLOBAL NE_LoadResource( HMODULE16 hModule,  HRSRC hRsrc )
 {
     NE_NAMEINFO *pNameInfo=NULL;
     WORD sizeShift;
@@ -307,7 +307,7 @@ HGLOBAL NE_LoadResource( HMODULE hModule,  HRSRC hRsrc )
 /***********************************************************************
  *           NE_LockResource
  */
-SEGPTR NE_LockResource( HMODULE hModule, HGLOBAL handle )
+SEGPTR NE_LockResource( HMODULE16 hModule, HGLOBAL handle )
 {
     /* May need to reload the resource if discarded */
 
@@ -318,7 +318,7 @@ SEGPTR NE_LockResource( HMODULE hModule, HGLOBAL handle )
 /***********************************************************************
  *           NE_FreeResource
  */
-BOOL NE_FreeResource( HMODULE hModule, HGLOBAL handle )
+BOOL NE_FreeResource( HMODULE16 hModule, HGLOBAL handle )
 {
     NE_TYPEINFO *pTypeInfo;
     NE_NAMEINFO *pNameInfo;
@@ -346,7 +346,7 @@ BOOL NE_FreeResource( HMODULE hModule, HGLOBAL handle )
         }
         pTypeInfo = (NE_TYPEINFO *)pNameInfo;
     }
-    fprintf( stderr, "FreeResource: %04x %04x not found!\n", hModule, handle );
+    fprintf( stderr, "NE_FreeResource: %04x %04x not found!\n", hModule, handle );
     return handle;
 }
 #endif /* WINELIB */
index e95c39f2837ef439268151fbc1839dcac1ecf9e9..4dad04bc4aa7b55ba339575e5cc17fe90b4390d4 100644 (file)
@@ -122,7 +122,7 @@ FARPROC32 PE_FindExportedFunction(struct pe_data *pe, LPCSTR funcName)
                        if(strcmp(ename,funcName)==0)
                                return (FARPROC32)(load_addr + *function);
                }else{
-                       if(funcName == (int)*ordinal + exports->Base)
+                       if((int)funcName == (int)*ordinal + exports->Base)
                                return (FARPROC32)(load_addr + *function);
                }
                function++;
@@ -132,14 +132,14 @@ FARPROC32 PE_FindExportedFunction(struct pe_data *pe, LPCSTR funcName)
        return NULL;
 }
 
-void fixup_imports(struct pe_data *pe, HMODULE hModule)
+void fixup_imports(struct pe_data *pe, HMODULE16 hModule)
 { 
   struct PE_Import_Directory * pe_imp;
   int fixup_failed=0;
   unsigned int load_addr = pe->load_addr;
   int i;
   NE_MODULE *ne_mod;
-  HMODULE *mod_ptr;
+  HMODULE16 *mod_ptr;
 
  /* OK, now dump the import list */
   dprintf_win32(stddeb, "\nDumping imports list\n");
@@ -151,7 +151,7 @@ void fixup_imports(struct pe_data *pe, HMODULE hModule)
 
   /* Now, allocate memory for dlls_to_init */
   ne_mod = GlobalLock16(hModule);
-  ne_mod->dlls_to_init = GLOBAL_Alloc(GMEM_ZEROINIT,(i+1) * sizeof(HMODULE),
+  ne_mod->dlls_to_init = GLOBAL_Alloc(GMEM_ZEROINIT,(i+1) * sizeof(HMODULE16),
                                       hModule, FALSE, FALSE, FALSE );
   mod_ptr = GlobalLock16(ne_mod->dlls_to_init);
   /* load the modules and put their handles into the list */
@@ -159,7 +159,7 @@ void fixup_imports(struct pe_data *pe, HMODULE hModule)
   {
        char *name = (char*)load_addr+pe_imp->ModuleName;
        mod_ptr[i] = LoadModule(name,(LPVOID)-1);
-       if(mod_ptr[i]<=(HMODULE)32)
+       if(mod_ptr[i]<=(HMODULE16)32)
         {
             char *p, buffer[256];
 
@@ -169,7 +169,7 @@ void fixup_imports(struct pe_data *pe, HMODULE hModule)
             strcpy( p + 1, name );
             mod_ptr[i] = LoadModule( buffer, (LPVOID)-1 );
         }
-       if(mod_ptr[i]<=(HMODULE)32)
+       if(mod_ptr[i]<=(HMODULE16)32)
        {
                fprintf(stderr,"Module %s not found\n",name);
                exit(0);
@@ -349,7 +349,7 @@ static void do_relocations(struct pe_data *pe)
  *                     PE_LoadImage
  * Load one PE format executable into memory
  */
-static struct pe_data *PE_LoadImage( int fd, HMODULE hModule, WORD offset )
+static struct pe_data *PE_LoadImage( int fd, HMODULE16 hModule, WORD offset )
 {
     struct pe_data *pe;
     int i, result;
@@ -433,16 +433,9 @@ static struct pe_data *PE_LoadImage( int fd, HMODULE hModule, WORD offset )
        if(strcmp(pe->pe_seg[i].Name, ".edata") == 0)
                pe->pe_export = (struct PE_Export_Directory *) result;
 
-       if(strcmp(pe->pe_seg[i].Name, ".rsrc") == 0) {
+       if(strcmp(pe->pe_seg[i].Name, ".rsrc") == 0)
            pe->pe_resource = (struct PE_Resource_Directory *) result;
-#if 0
-/* FIXME pe->resource_offset should be deleted from structure if this
- ifdef doesn't break anything */
-           /* save offset for PE_FindResource */
-           pe->resource_offset = pe->pe_seg[i].Virtual_Address - 
-                                       pe->pe_seg[i].PointerToRawData;
-#endif 
-           }
+
        if(strcmp(pe->pe_seg[i].Name, ".reloc") == 0)
                pe->pe_reloc = (struct PE_Reloc_Block *) result;
 
@@ -522,113 +515,45 @@ static struct pe_data *PE_LoadImage( int fd, HMODULE hModule, WORD offset )
         return pe;
 }
 
-HINSTANCE MODULE_CreateInstance(HMODULE hModule,LOADPARAMS *params);
+HINSTANCE MODULE_CreateInstance(HMODULE16 hModule,LOADPARAMS *params);
 void InitTask( SIGCONTEXT *context );
 
 HINSTANCE PE_LoadModule( int fd, OFSTRUCT *ofs, LOADPARAMS* params )
 {
-        PE_MODULE *pe;
-       int size, of_size;
-       NE_MODULE *pModule;
-       SEGTABLEENTRY *pSegment;
-       char *pStr;
-       DWORD cts;
-       HMODULE hModule;
-       HINSTANCE hInstance;
-        struct mz_header_s mz_header;
-
-       lseek(fd,0,SEEK_SET);
-       read( fd, &mz_header, sizeof(mz_header) );
-
-        of_size = sizeof(OFSTRUCT) - sizeof(ofs->szPathName)
-                  + strlen(ofs->szPathName) + 1;
-       size = sizeof(NE_MODULE) +
-               /* loaded file info */
-               of_size +
-               /* segment table: DS,CS */
-               2 * sizeof(SEGTABLEENTRY) +
-               /* name table */
-               9 +
-               /* several empty tables */
-               8;
-
-       hModule = GlobalAlloc16( GMEM_MOVEABLE | GMEM_ZEROINIT, size );
-       if (!hModule) return (HINSTANCE)11;  /* invalid exe */
-
-       FarSetOwner( hModule, hModule );
-       
-       pModule = (NE_MODULE*)GlobalLock16(hModule);
-
-       /* Set all used entries */
-       pModule->magic=NE_SIGNATURE;
-       pModule->count=1;
-       pModule->next=0;
-       pModule->flags=NE_FFLAGS_WIN32;
-       pModule->dgroup=1;
-       pModule->ss=1;
-       pModule->cs=2;
-       /* Who wants to LocalAlloc for a PE Module? */
-       pModule->heap_size=0x1000;
-       pModule->stack_size=0xF000;
-       pModule->seg_count=1;
-       pModule->modref_count=0;
-       pModule->nrname_size=0;
-       pModule->fileinfo=sizeof(NE_MODULE);
-       pModule->os_flags=NE_OSFLAGS_WINDOWS;
-       pModule->expected_version=0x30A;
-        pModule->self = hModule;
-
-        /* Set loaded file information */
-        memcpy( pModule + 1, ofs, of_size );
-        ((OFSTRUCT *)(pModule+1))->cBytes = of_size - 1;
-
-       pSegment=(SEGTABLEENTRY*)((char*)(pModule + 1) + of_size);
-       pModule->seg_table=pModule->dgroup_entry=(int)pSegment-(int)pModule;
-       pSegment->size=0;
-       pSegment->flags=NE_SEGFLAGS_DATA;
-       pSegment->minsize=0x1000;
-       pSegment++;
-
-       cts=(DWORD)MODULE_GetWndProcEntry16("Win32CallToStart");
-#ifdef WINELIB32
-       pSegment->selector=(void*)cts;
-       pModule->ip=0;
-#else
-       pSegment->selector=cts>>16;  /* FIXME!! */
-       pModule->ip=cts & 0xFFFF;
-#endif
-       pSegment++;
+    HMODULE16 hModule;
+    HINSTANCE16 hInstance;
+    NE_MODULE *pModule;
+    SEGTABLEENTRY *pSegment;
+    FARPROC16 startup;
+    struct mz_header_s mz_header;
 
-       pStr=(char*)pSegment;
-       pModule->name_table=(int)pStr-(int)pModule;
-       strcpy(pStr,"\x08W32SXXXX");
-       pStr+=9;
+    if ((hModule = MODULE_CreateDummyModule( ofs )) < 32) return hModule;
+    pModule = (NE_MODULE *)GlobalLock16( hModule );
+    pModule->flags = NE_FFLAGS_WIN32;
 
-       /* All tables zero terminated */
-       pModule->res_table=pModule->import_table=pModule->entry_table=
-               (int)pStr-(int)pModule;
+    lseek( fd, 0, SEEK_SET );
+    read( fd, &mz_header, sizeof(mz_header) );
 
-        MODULE_RegisterModule( pModule );
+    /* Set the startup address */
 
-       pe = PE_LoadImage( fd, hModule, mz_header.ne_offset );
+    startup = MODULE_GetWndProcEntry16("Win32CallToStart");
+    pSegment = NE_SEG_TABLE(pModule) + pModule->cs - 1;
+    pSegment->selector = SELECTOROF(startup); /* FIXME */
+    pModule->ip = OFFSETOF(startup);
 
-        pModule->pe_module = pe;
-       pModule->heap_size=0x1000;
-       pModule->stack_size=0xE000;
+    pModule->pe_module = PE_LoadImage( fd, hModule, mz_header.ne_offset );
 
-       /* CreateInstance allocates now 64KB */
-       hInstance=MODULE_CreateInstance(hModule,NULL /* FIX: NULL? really? */);
+    hInstance = MODULE_CreateInstance( hModule, params );
 
-        /* FIXME: Is this really the correct place to initialise the DLL? */
-       if ((pe->pe_header->coff.Characteristics & IMAGE_FILE_DLL)) {
-/*            PE_InitDLL(hModule); */
-        } else {
-            TASK_CreateTask(hModule,hInstance,0,
-               params->hEnvironment,(LPSTR)PTR_SEG_TO_LIN(params->cmdLine),
-               *((WORD*)PTR_SEG_TO_LIN(params->showCmd)+1));
-            PE_InitializeDLLs(hModule);
-       }
-       return hInstance;
+    if (!(pModule->pe_module->pe_header->coff.Characteristics & IMAGE_FILE_DLL))
+    {
+        TASK_CreateTask( hModule, hInstance, 0,
+                         params->hEnvironment,
+                         (LPSTR)PTR_SEG_TO_LIN( params->cmdLine ),
+                         *((WORD*)PTR_SEG_TO_LIN(params->showCmd) + 1) );
+        PE_InitializeDLLs( hModule );
+    }
+    return hInstance;
 }
 
 int USER_InitApp(HINSTANCE hInstance);
@@ -637,29 +562,29 @@ void PE_InitTEB(int hTEB);
 void PE_Win32CallToStart( SIGCONTEXT *context )
 {
     int fs;
-    HMODULE hModule;
+    HMODULE16 hModule;
     NE_MODULE *pModule;
 
     dprintf_win32(stddeb,"Going to start Win32 program\n");    
-    InitTask( &context );
+    InitTask( context );
     hModule = GetExePtr( GetCurrentTask() );
     pModule = MODULE_GetPtr( hModule );
     USER_InitApp( hModule );
     fs=(int)GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, 0x10000 );
     PE_InitTEB(fs);
     __asm__ __volatile__("movw %w0,%%fs"::"r" (fs));
-    CallTaskStart32( (FARPROC)(pModule->pe_module->load_addr + 
+    CallTaskStart32( (FARPROC32)(pModule->pe_module->load_addr + 
                                pModule->pe_module->pe_header->opt_coff.AddressOfEntryPoint) );
 }
 
-int PE_UnloadImage( HMODULE hModule )
+int PE_UnloadImage( HMODULE16 hModule )
 {
        printf("PEunloadImage() called!\n");
        /* free resources, image, unmap */
        return 1;
 }
 
-static void PE_InitDLL(HMODULE hModule)
+static void PE_InitDLL(HMODULE16 hModule)
 {
     NE_MODULE *pModule;
     PE_MODULE *pe;
@@ -675,7 +600,7 @@ static void PE_InitDLL(HMODULE hModule)
     if (pe->pe_header->coff.Characteristics & IMAGE_FILE_DLL)
     {
         printf("InitPEDLL() called!\n");
-        CallDLLEntryProc32( (FARPROC)(pe->load_addr + 
+        CallDLLEntryProc32( (FARPROC32)(pe->load_addr + 
                                   pe->pe_header->opt_coff.AddressOfEntryPoint),
                             hModule, 0, 0 );
     }
@@ -708,16 +633,16 @@ void PE_InitTEB(int hTEB)
     pTEB->taskid = getpid();
 }
 
-void PE_InitializeDLLs(HMODULE hModule)
+void PE_InitializeDLLs(HMODULE16 hModule)
 {
        NE_MODULE *pModule;
-       HMODULE *pDLL;
+       HMODULE16 *pDLL;
        pModule = MODULE_GetPtr( GetExePtr(hModule) );
        if (pModule->dlls_to_init)
        {
                HANDLE to_init = pModule->dlls_to_init;
                pModule->dlls_to_init = 0;
-               for (pDLL = (HMODULE *)GlobalLock16( to_init ); *pDLL; pDLL++)
+               for (pDLL = (HMODULE16 *)GlobalLock16( to_init ); *pDLL; pDLL++)
                {
                        PE_InitializeDLLs( *pDLL );
                        PE_InitDLL( *pDLL );
index da19a6531b14a1eda2a405709810e93dde6b58f8..917877224db55c0a04f6e8f70566a366a42ae785 100644 (file)
 #ifndef WINELIB
 /*
- *     (c) 1994        Erik Bos        <erik@xs4all.nl>
+ * PE (Portable Execute) File Resources
  *
- *     based on Eric Youndale's pe-test and:
+ * Copyright 1995 Thomas Sandford
+ * Copyright 1996 Martin von Loewis
  *
- *     ftp.microsoft.com:/pub/developer/MSDN/CD8/PEFILE.ZIP
+ * Based on the Win16 resource handling code in loader/resource.c
+ * Copyright 1993 Robert J. Amstadt
+ * Copyright 1995 Alexandre Julliard
+ *
+ * This is not even at ALPHA level yet. Don't expect it to work!
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 #include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
+#include "wintypes.h"
 #include "windows.h"
-#include "ldt.h"
-#include "neexe.h"
-#include "peexe.h"
+#include "kernel32.h"
 #include "pe_image.h"
-#include "resource.h"
+#include "module.h"
+#include "handle32.h"
+#include "libres.h"
+#include "resource32.h"
+#include "stackframe.h"
+#include "neexe.h"
+#include "accel.h"
+#include "xmalloc.h"
+#include "string32.h"
 #include "stddebug.h"
-/* #define DEBUG_RESOURCE */
 #include "debug.h"
 
-#if 0
+int language = 0x0409;
 
-static int
-find_lang(char *root, struct PE_Resource_Directory *resource, RESOURCE *r)
-{
-       struct PE_Directory_Entry *type_dir;
-       struct PE_Resource_Leaf_Entry *leaf;
+#define PrintIdA(name) \
+    if (HIWORD((DWORD)name)) \
+        dprintf_resource( stddeb, "'%s'", name); \
+    else \
+        dprintf_resource( stddeb, "#%04x", LOWORD(name)); 
+#define PrintIdW(name)
+#define PrintId(name)
 
-       type_dir = (struct PE_Directory_Entry *)(resource + 1);
-       type_dir += resource->NumberOfNamedEntries;
-
-       /* grab the 1st resource available */
-       leaf = (struct PE_Resource_Leaf_Entry *) (root + type_dir->OffsetToData);
-               dprintf_resource(stddeb, "\t\tPE_findlang: id %8x\n", (int) type_dir->Name);
-               dprintf_resource(stddeb, "\t\taddress %ld, size %ld, language id %ld\n", leaf->OffsetToData, leaf->Size, leaf->CodePage);
-       r->offset = leaf->OffsetToData - r->wpnt->pe->resource_offset;
-       r->size = leaf->Size;
-       printf("\t\toffset %d, size %d\n", r->offset, r->size);
-       return 1;
+/**********************************************************************
+ *         GetResDirEntryW
+ *
+ *     Helper function - goes down one level of PE resource tree
+ *
+ */
+PIMAGE_RESOURCE_DIRECTORY GetResDirEntryW(PIMAGE_RESOURCE_DIRECTORY resdirptr,
+                                        LPCWSTR name,
+                                        DWORD root)
+{
+    int entrynum;
+    PIMAGE_RESOURCE_DIRECTORY_ENTRY entryTable;
+       int namelen;
 
-/*     for(i=0; i< resource->NumberOfIdEntries; i++) {
-               leaf = (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY));
-               dprintf_resource(stddeb, "\t\tPE_findlang: id %8x\n", 
-                       (int) type_dir->Name);
-               dprintf_resource(stddeb, "\t\t%x %x %x\n", leaf->OffsetToData, 
-                       leaf->Size, leaf->CodePage);
-               type_dir++;
-       } */
+    if (HIWORD(name)) {
+    /* FIXME: what about #xxx names? */
+       entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (
+                       (BYTE *) resdirptr + 
+                        sizeof(IMAGE_RESOURCE_DIRECTORY));
+       namelen = lstrlen32W(name);
+       for (entrynum = 0; entrynum < resdirptr->NumberOfNamedEntries; entrynum++)
+       {
+               PIMAGE_RESOURCE_DIR_STRING_U str =
+               (PIMAGE_RESOURCE_DIR_STRING_U) (root + 
+                       (entryTable[entrynum].Name & 0x7fffffff));
+               if(namelen != str->Length)
+                       continue;
+               if(lstrncmpi32W(name,str->NameString,str->Length)==0)
+                       return (PIMAGE_RESOURCE_DIRECTORY) (
+                               root +
+                               (entryTable[entrynum].OffsetToData & 0x7fffffff));
+       }
+       return NULL;
+    } else {
+       entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (
+                       (BYTE *) resdirptr + 
+                        sizeof(IMAGE_RESOURCE_DIRECTORY) +
+                       resdirptr->NumberOfNamedEntries * sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY));
+       for (entrynum = 0; entrynum < resdirptr->NumberOfIdEntries; entrynum++)
+           if ((DWORD)entryTable[entrynum].Name == (DWORD)name)
+               return (PIMAGE_RESOURCE_DIRECTORY) (
+                       root +
+                       (entryTable[entrynum].OffsetToData & 0x7fffffff));
+       return NULL;
+    }
 }
 
-static int 
-find_resource(char *root, struct PE_Resource_Directory *resource, 
-               LPSTR resource_name, RESOURCE *r)
+/**********************************************************************
+ *         GetResDirEntryA
+ *
+ *     Helper function - goes down one level of PE resource tree
+ *
+ */
+PIMAGE_RESOURCE_DIRECTORY GetResDirEntryA(PIMAGE_RESOURCE_DIRECTORY resdirptr,
+                                        LPCSTR name,
+                                        DWORD root)
 {
-       int i;
-       char res_name[256];
-       struct PE_Directory_Entry *type_dir;
-       struct PE_Directory_Name_String_U *name;
-       
-       type_dir = (struct PE_Directory_Entry *)(resource + 1);
+       LPWSTR                          xname;
+       PIMAGE_RESOURCE_DIRECTORY       ret;
 
-       if (HIWORD((DWORD)resource_name)) {
-               for(i=0; i< resource->NumberOfNamedEntries; i++) {
-                       name = (struct PE_Directory_Name_String_U *)(root + (type_dir->Name & ~IMAGE_RESOURCE_NAME_IS_STRING));
-                       memset(res_name, 0, sizeof(res_name));
-                       my_wcstombs(res_name, name->NameString, name->Length);
-                       dprintf_resource(stddeb, "\tPE_findresource: name %s\n", res_name);
-                       if (lstrcmpi(res_name, resource_name) == 0) 
-                               return find_lang(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), r);
-                       type_dir++;
-               }
-       } else {
-               type_dir += resource->NumberOfNamedEntries;
-               for(i=0; i< resource->NumberOfIdEntries; i++) {
-                       dprintf_resource(stddeb, "\tPE_findresource: name %8x\n", (int) type_dir->Name);
-                       if (type_dir->Name == ((int) resource_name & 0xff))
-                               return find_lang(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), r);
-                       type_dir++;
-               }
-       }
-       return 0;
+       if (HIWORD((DWORD)name))
+               xname   = STRING32_DupAnsiToUni(name);
+       else
+               xname   = (LPWSTR)name;
+
+       ret=GetResDirEntryW(resdirptr,xname,root);
+       if (HIWORD((DWORD)name))
+               free(xname);
+       return ret;
 }
 
-static int 
-find_type(struct PE_Resource_Directory *resource, LPSTR resource_name,
-               LPSTR type_name)
+/**********************************************************************
+ *         PE_FindResource32W
+ */
+HANDLE32 PE_FindResource32W( HINSTANCE hModule, LPCWSTR name, LPCWSTR type )
 {
-       int i;
-       char *root, res_name[256];
-       struct PE_Directory_Entry *type_dir;
-       struct PE_Directory_Name_String_U *name;
-       
-       root = (char *) resource;
-       type_dir = (struct PE_Directory_Entry *)(resource + 1);
+    PE_MODULE *pe;
+    NE_MODULE *pModule;
+    PIMAGE_RESOURCE_DIRECTORY resdirptr;
+    DWORD root;
+    HANDLE32 result;
 
-       if (HIWORD((DWORD)type_name)) {
-               for(i=0; i< resource->NumberOfNamedEntries; i++) {
-                       name = (struct PE_Directory_Name_String_U *)(root + (type_dir->Name & ~IMAGE_RESOURCE_NAME_IS_STRING));
-                       memset(res_name, 0, sizeof(res_name));
-                       my_wcstombs(res_name, name->NameString, name->Length);
-                       dprintf_resource(stddeb, "PE_findtype: type %s\n", 
-                               res_name);
-                       if (lstrcmpi(res_name, type_name) == 0) 
-                               return find_resource(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), resource_name, r);
-                       type_dir++;
-               }
-       } else {
-               type_dir += resource->NumberOfNamedEntries;
-               for(i=0; i< resource->NumberOfIdEntries; i++) {
-                       dprintf_resource(stddeb, "PE_findtype: type %8x\n", (int) type_dir->Name);
-                       if (type_dir->Name == ((int) type_name & 0xff))
-                               return find_resource(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), resource_name, r);
-                       type_dir++;
-               }
-       }
+    hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
+    dprintf_resource(stddeb, "FindResource: module=%08x type=", hModule );
+    PrintId( type );
+    dprintf_resource( stddeb, " name=" );
+    PrintId( name );
+    dprintf_resource( stddeb, "\n" );
+    if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
+    if (!(pModule->flags & NE_FFLAGS_WIN32)) return 0;  /* FIXME? */
+    if (!(pe = pModule->pe_module) || !pe->pe_resource) return 0;
+
+    resdirptr = (PIMAGE_RESOURCE_DIRECTORY) pe->pe_resource;
+    root = (DWORD) resdirptr;
+    if ((resdirptr = GetResDirEntryW(resdirptr, type, root)) == NULL)
+       return 0;
+    if ((resdirptr = GetResDirEntryW(resdirptr, name, root)) == NULL)
        return 0;
+    result = (HANDLE32)GetResDirEntryW(resdirptr, (LPCWSTR)language, root);
+       /* Try LANG_NEUTRAL, too */
+    if(!result)
+        return (HANDLE32)GetResDirEntryW(resdirptr, (LPCWSTR)0, root);
+    return result;
 }
 
+
 /**********************************************************************
- *                     PE_FindResource [KERNEL.60]
+ *         PE_LoadResource32
  */
-int
-PE_FindResource(HANDLE instance, SEGPTR resource_name, SEGPTR type_name,
-               RESOURCE *r)
+HANDLE32 PE_LoadResource32( HINSTANCE hModule, HANDLE32 hRsrc )
 {
-       dprintf_resource(stddeb, "PE_FindResource hInst=%04X typename=%08X resname=%08X\n", 
-               instance, (int) type_name, (int) resource_name);
-       if (HIWORD(resource_name))
-        {
-                char *resource_name_ptr = PTR_SEG_TO_LIN( resource_name );
-               if (resource_name_ptr[0] == '#')
-                       resource_name = (SEGPTR) atoi(resource_name_ptr + 1);
-                else
-                    resource_name = (SEGPTR)resource_name_ptr;
-        }
-       if (HIWORD(type_name)) 
-        {
-                char *type_name_ptr = PTR_SEG_TO_LIN( type_name );
-               if (type_name_ptr[0] == '#')
-                       type_name = (SEGPTR) atoi(type_name_ptr + 1);
-                else
-                        type_name = (SEGPTR) type_name_ptr;
-        }
-       return find_type(r->wpnt->pe->pe_resource, resource_name, type_name);
+    NE_MODULE *pModule;
+    PE_MODULE *pe;
+
+    if (!hModule) hModule = GetTaskDS(); /* FIXME: see FindResource32W */
+    hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
+    dprintf_resource(stddeb, "PE_LoadResource32: module=%04x res=%04x\n",
+                     hModule, hRsrc );
+    if (!hRsrc) return 0;
+
+    if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
+    if (!(pModule->flags & NE_FFLAGS_WIN32)) return 0;  /* FIXME? */
+    if (!(pe = pModule->pe_module) || !pe->pe_resource) return 0;
+    return (HANDLE32) (pe->load_addr+((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->OffsetToData);
 }
 #endif
-
-#endif /* WINELIB */
index 9f0aa83a4e45f711fdc26e60959da3d8fd9f9182..cea0057dc18764e9a16aa2fdae75b74441e7bd6c 100644 (file)
@@ -23,6 +23,8 @@
 #include "stddebug.h"
 #include "debug.h"
 #include "libres.h"
+#include "string32.h"
+#include "xmalloc.h"
 
 #define PrintId(name) \
     if (HIWORD((DWORD)name)) \
 
 
 /**********************************************************************
- *         FindResource    (KERNEL.60)
+ *         FindResource16    (KERNEL.60)
  */
-HRSRC FindResource( HMODULE hModule, SEGPTR name, SEGPTR type )
+HRSRC16 FindResource16( HMODULE16 hModule, SEGPTR name, SEGPTR type )
 {
     NE_MODULE *pModule;
 
     hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
-    dprintf_resource(stddeb, "FindResource: module=%04x type=", hModule );
+    dprintf_resource(stddeb, "FindResource16: module=%04x type=", hModule );
     PrintId( type );
     if (HIWORD(name))  /* Check for '#xxx' name */
     {
@@ -55,7 +57,7 @@ HRSRC FindResource( HMODULE hModule, SEGPTR name, SEGPTR type )
 #ifndef WINELIB
     if (pModule->flags & NE_FFLAGS_WIN32)
     {
-        fprintf(stderr,"Don't know how to FindResource() for Win32 module\n");
+        fprintf(stderr,"Don't know how to FindResource16() for Win32 module\n");
         return 0;
     }
     return NE_FindResource( hModule, type, name );
@@ -66,21 +68,67 @@ HRSRC FindResource( HMODULE hModule, SEGPTR name, SEGPTR type )
 
 
 /**********************************************************************
- *         LoadResource    (KERNEL.61)
+ *         FindResource32A    (KERNEL32.128)
  */
-HGLOBAL LoadResource( HMODULE hModule, HRSRC hRsrc )
+HANDLE32 FindResource32A( HINSTANCE32 hModule, LPCSTR name, LPCSTR type )
 {
+    LPWSTR xname,xtype;
+    HANDLE32 ret;
+
+    if (HIWORD((DWORD)name)) xname = STRING32_DupAnsiToUni(name);
+    else xname = (LPWSTR)name;
+    if (HIWORD((DWORD)type)) xtype = STRING32_DupAnsiToUni(type);
+    else xtype = (LPWSTR)type;
+    ret = FindResource32W(hModule,xname,xtype);
+    if (HIWORD((DWORD)name)) free(xname);
+    if (HIWORD((DWORD)type)) free(xtype);
+    return ret;
+}
+
+
+/**********************************************************************
+ *         FindResource32W    (KERNEL32.131)
+ */
+HRSRC32 FindResource32W( HINSTANCE32 hModule, LPCWSTR name, LPCWSTR type )
+{
+#ifndef WINELIB
     NE_MODULE *pModule;
 
+    /* Sometimes we get passed hModule = 0x00000000. FIXME: is GetTaskDS()
+     * ok?
+     */
+    if (!hModule) hModule = GetTaskDS();
     hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
-    dprintf_resource(stddeb, "LoadResource: module=%04x res=%04x\n",
+    dprintf_resource(stddeb, "FindResource32W: module=%08x type=", hModule );
+    PrintId( type );
+    dprintf_resource( stddeb, " name=" );
+    PrintId( name );
+    dprintf_resource( stddeb, "\n" );
+    if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
+    if (!(pModule->flags & NE_FFLAGS_WIN32)) return 0;
+    return PE_FindResource32W(hModule,name,type);
+#else
+    return LIBRES_FindResource( hModule, name, type );
+#endif
+}
+
+
+/**********************************************************************
+ *         LoadResource16    (KERNEL.61)
+ */
+HGLOBAL16 LoadResource16( HMODULE16 hModule, HRSRC16 hRsrc )
+{
+    NE_MODULE *pModule;
+
+    hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
+    dprintf_resource(stddeb, "LoadResource16: module=%04x res=%04x\n",
                      hModule, hRsrc );
     if (!hRsrc) return 0;
     if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
 #ifndef WINELIB
     if (pModule->flags & NE_FFLAGS_WIN32)
     {
-        fprintf(stderr,"Don't know how to LoadResource() for Win32 module\n");
+        fprintf(stderr,"Don't know how to LoadResource16() for Win32 module\n");
         return 0;
     }
     return NE_LoadResource( hModule, hRsrc );
@@ -89,15 +137,41 @@ HGLOBAL LoadResource( HMODULE hModule, HRSRC hRsrc )
 #endif
 }
 
+/**********************************************************************
+ *         LoadResource32    (KERNEL32.370)
+ */
+HGLOBAL32 LoadResource32( HINSTANCE32 hModule, HRSRC32 hRsrc )
+{
+#ifndef WINELIB
+    NE_MODULE *pModule;
+
+    if (!hModule) hModule = GetTaskDS(); /* FIXME: see FindResource32W */
+    hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
+    dprintf_resource(stddeb, "LoadResource32: module=%04x res=%04x\n",
+                     hModule, hRsrc );
+    if (!hRsrc) return 0;
+
+    if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
+    if (!(pModule->flags & NE_FFLAGS_WIN32))
+    {
+       fprintf(stderr,"LoadResource32: tried to load a non win32 resource.\n");
+       return 0;  /* FIXME? */
+    }
+    return PE_LoadResource32(hModule,hRsrc);
+#else
+    return LIBRES_LoadResource( hModule, hRsrc );
+#endif
+}
+
 
 /**********************************************************************
  *         LockResource    (KERNEL.62)
  */
 /* 16-bit version */
-SEGPTR WIN16_LockResource( HGLOBAL handle )
+SEGPTR WIN16_LockResource16(HGLOBAL16 handle)
 {
 #ifndef WINELIB
-    HMODULE hModule;
+    HMODULE16 hModule;
     NE_MODULE *pModule;
 
     dprintf_resource(stddeb, "LockResource: handle=%04x\n", handle );
@@ -115,11 +189,11 @@ SEGPTR WIN16_LockResource( HGLOBAL handle )
 #endif
 }
 
-/* 32-bit version */
-LPVOID LockResource( HGLOBAL handle )
+/* WINELIB 16-bit version */
+LPVOID LockResource16( HGLOBAL16 handle )
 {
 #ifndef WINELIB
-    HMODULE hModule;
+    HMODULE16 hModule;
     NE_MODULE *pModule;
 
     dprintf_resource(stddeb, "LockResource: handle=%04x\n", handle );
@@ -128,7 +202,7 @@ LPVOID LockResource( HGLOBAL handle )
     if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
     if (pModule->flags & NE_FFLAGS_WIN32)
     {
-        fprintf(stderr,"Don't know how to LockResource() for Win32 module\n");
+        fprintf(stderr,"Don't know how to LockResource16() for Win32 module\n");
         return 0;
     }
     return (LPSTR)PTR_SEG_TO_LIN( NE_LockResource( hModule, handle ) );
@@ -139,21 +213,30 @@ LPVOID LockResource( HGLOBAL handle )
 
 
 /**********************************************************************
- *         FreeResource    (KERNEL.63)
+ *         LockResource32    (KERNEL32.384)
+ */
+LPVOID LockResource32( HGLOBAL32 handle )
+{
+    return (LPVOID)handle;
+}
+
+
+/**********************************************************************
+ *         FreeResource16    (KERNEL.63)
  */
-BOOL FreeResource( HGLOBAL handle )
+BOOL16 FreeResource16( HGLOBAL16 handle )
 {
 #ifndef WINELIB
-    HMODULE hModule;
+    HMODULE16 hModule;
     NE_MODULE *pModule;
 
-    dprintf_resource(stddeb, "FreeResource: handle=%04x\n", handle );
+    dprintf_resource(stddeb, "FreeResource16: handle=%04x\n", handle );
     if (!handle) return FALSE;
     hModule = GetExePtr( handle );
     if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
     if (pModule->flags & NE_FFLAGS_WIN32)
     {
-        fprintf(stderr,"Don't know how to FreeResource() for Win32 module\n");
+        fprintf(stderr,"Don't know how to FreeResource16() for Win32 module\n");
         return 0;
     }
     return NE_FreeResource( hModule, handle );
@@ -162,23 +245,32 @@ BOOL FreeResource( HGLOBAL handle )
 #endif
 }
 
+/**********************************************************************
+ *         FreeResource32    (KERNEL32.145)
+ */
+BOOL32 FreeResource32( HGLOBAL32 handle )
+{
+    /* no longer used in Win32 */
+    return TRUE;
+}
+
 
 /**********************************************************************
- *         AccessResource    (KERNEL.64)
+ *         AccessResource16    (KERNEL.64)
  */
-INT AccessResource( HINSTANCE hModule, HRSRC hRsrc )
+INT16 AccessResource16( HINSTANCE16 hModule, HRSRC16 hRsrc )
 {
     NE_MODULE *pModule;
 
     hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
-    dprintf_resource(stddeb, "AccessResource: module=%04x res=%04x\n",
+    dprintf_resource(stddeb, "AccessResource16: module=%04x res=%04x\n",
                      hModule, hRsrc );
     if (!hRsrc) return 0;
     if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
 #ifndef WINELIB
     if (pModule->flags & NE_FFLAGS_WIN32)
     {
-        fprintf(stderr,"Don't know how to AccessResource() for Win32 module\n");
+        fprintf(stderr,"Don't know how to AccessResource16() for Win32 module\n");
         return 0;
     }
     return NE_AccessResource( hModule, hRsrc );
@@ -189,20 +281,34 @@ INT AccessResource( HINSTANCE hModule, HRSRC hRsrc )
 
 
 /**********************************************************************
- *         SizeofResource    (KERNEL.65)
+ *         AccessResource32    (KERNEL32.64)
  */
-DWORD SizeofResource( HMODULE hModule, HRSRC hRsrc )
+INT32 AccessResource32( HINSTANCE32 hModule, HRSRC32 hRsrc )
+{
+    hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
+    dprintf_resource(stddeb, "AccessResource: module=%04x res=%04x\n",
+                     hModule, hRsrc );
+    if (!hRsrc) return 0;
+    fprintf(stderr,"AccessResource32: not implemented\n");
+    return 0;
+}
+
+
+/**********************************************************************
+ *         SizeofResource16    (KERNEL.65)
+ */
+DWORD SizeofResource16( HMODULE16 hModule, HRSRC16 hRsrc )
 {
     NE_MODULE *pModule;
 
     hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
-    dprintf_resource(stddeb, "SizeofResource: module=%04x res=%04x\n",
+    dprintf_resource(stddeb, "SizeofResource16: module=%04x res=%04x\n",
                      hModule, hRsrc );
     if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
 #ifndef WINELIB
     if (pModule->flags & NE_FFLAGS_WIN32)
     {
-        fprintf(stderr,"Don't know how to SizeOfResource() for Win32 module\n");
+        fprintf(stderr,"Don't know how to SizeOfResource16() for Win32 module\n");
         return 0;
     }
     return NE_SizeofResource( hModule, hRsrc );
@@ -213,9 +319,22 @@ DWORD SizeofResource( HMODULE hModule, HRSRC hRsrc )
 
 
 /**********************************************************************
- *         AllocResource    (KERNEL.66)
+ *         SizeofResource32    (KERNEL32.522)
  */
-HGLOBAL AllocResource( HMODULE hModule, HRSRC hRsrc, DWORD size )
+DWORD SizeofResource32( HINSTANCE32 hModule, HRSRC32 hRsrc )
+{
+    hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
+    dprintf_resource(stddeb, "SizeofResource32: module=%04x res=%04x\n",
+                     hModule, hRsrc );
+    fprintf(stderr,"SizeofResource32: not implemented\n");
+    return 0;
+}
+
+
+/**********************************************************************
+ *         AllocResource16    (KERNEL.66)
+ */
+HGLOBAL16 AllocResource16( HMODULE16 hModule, HRSRC16 hRsrc, DWORD size )
 {
     NE_MODULE *pModule;
 
@@ -255,13 +374,13 @@ HANDLE DirectResAlloc(HANDLE hInstance, WORD wType, WORD wSize)
 
 
 /**********************************************************************
- *                     LoadAccelerators        [USER.177]
+ *                     LoadAccelerators16      [USER.177]
  */
-HANDLE LoadAccelerators(HANDLE instance, SEGPTR lpTableName)
+HACCEL16 LoadAccelerators16(HINSTANCE16 instance, SEGPTR lpTableName)
 {
-    HANDLE     hAccel;
-    HANDLE     rsc_mem;
-    HRSRC hRsrc;
+    HACCEL16   hAccel;
+    HGLOBAL16  rsc_mem;
+    HRSRC16 hRsrc;
     BYTE       *lp;
     ACCELHEADER        *lpAccelTbl;
     int        i, n;
@@ -273,12 +392,61 @@ HANDLE LoadAccelerators(HANDLE instance, SEGPTR lpTableName)
         dprintf_accel( stddeb, "LoadAccelerators: %04x %04x\n",
                        instance, LOWORD(lpTableName) );
 
-    if (!(hRsrc = FindResource( instance, lpTableName, RT_ACCELERATOR )))
+    if (!(hRsrc = FindResource16( instance, lpTableName, RT_ACCELERATOR )))
+      return 0;
+    if (!(rsc_mem = LoadResource16( instance, hRsrc ))) return 0;
+
+    lp = (BYTE *)LockResource16(rsc_mem);
+    n = SizeofResource16(instance,hRsrc)/sizeof(ACCELENTRY);
+    hAccel = GlobalAlloc16(GMEM_MOVEABLE, 
+       sizeof(ACCELHEADER) + (n + 1)*sizeof(ACCELENTRY));
+    lpAccelTbl = (LPACCELHEADER)GlobalLock16(hAccel);
+    lpAccelTbl->wCount = 0;
+    for (i = 0; i < n; i++) {
+       lpAccelTbl->tbl[i].type = *(lp++);
+       lpAccelTbl->tbl[i].wEvent = *((WORD *)lp);
+       lp += 2;
+       lpAccelTbl->tbl[i].wIDval = *((WORD *)lp);
+       lp += 2;
+       if (lpAccelTbl->tbl[i].wEvent == 0) break;
+       dprintf_accel(stddeb,
+               "Accelerator #%u / event=%04X id=%04X type=%02X \n", 
+               i, lpAccelTbl->tbl[i].wEvent, lpAccelTbl->tbl[i].wIDval, 
+               lpAccelTbl->tbl[i].type);
+       lpAccelTbl->wCount++;
+       }
+    GlobalUnlock16(hAccel);
+    FreeResource16( rsc_mem );
+    return hAccel;
+}
+
+/**********************************************************************
+ *                     LoadAccelerators32W     [USER.177]
+ */
+HACCEL32 LoadAccelerators32W(HINSTANCE32 instance,LPCWSTR lpTableName)
+{
+#if 0
+    HACCEL32   hAccel;
+    HGLOBAL32  rsc_mem;
+    HRSRC32 hRsrc;
+    BYTE       *lp;
+    ACCELHEADER        *lpAccelTbl;
+    int        i, n;
+
+    if (HIWORD(lpTableName))
+        dprintf_accel( stddeb, "LoadAccelerators: %04x '%s'\n",
+                      instance, (char *)( lpTableName ) );
+    else
+        dprintf_accel( stddeb, "LoadAccelerators: %04x %04x\n",
+                       instance, LOWORD(lpTableName) );
+
+    if (!(hRsrc = FindResource32W( instance, lpTableName, 
+               (LPCWSTR)RT_ACCELERATOR )))
       return 0;
-    if (!(rsc_mem = LoadResource( instance, hRsrc ))) return 0;
+    if (!(rsc_mem = LoadResource32( instance, hRsrc ))) return 0;
 
-    lp = (BYTE *)LockResource(rsc_mem);
-    n = SizeofResource( instance, hRsrc ) / sizeof(ACCELENTRY);
+    lp = (BYTE *)LockResource32(rsc_mem);
+    n = SizeofResource32(instance,hRsrc)/sizeof(ACCELENTRY);
     hAccel = GlobalAlloc16(GMEM_MOVEABLE, 
        sizeof(ACCELHEADER) + (n + 1)*sizeof(ACCELENTRY));
     lpAccelTbl = (LPACCELHEADER)GlobalLock16(hAccel);
@@ -297,10 +465,29 @@ HANDLE LoadAccelerators(HANDLE instance, SEGPTR lpTableName)
        lpAccelTbl->wCount++;
        }
     GlobalUnlock16(hAccel);
-    FreeResource( rsc_mem );
+    FreeResource32(rsc_mem);
     return hAccel;
+#else
+       fprintf(stderr,"LoadAcceleratorsW: not implemented\n");
+       return 0x100;  /* Return something anyway */
+#endif
 }
-\f
+
+HACCEL32 LoadAccelerators32A(HINSTANCE32 instance,LPCSTR lpTableName)
+{
+       LPWSTR   uni;
+       HACCEL32 result;
+       if (HIWORD(lpTableName))
+               uni=STRING32_DupAnsiToUni(lpTableName);
+       else
+               uni=(LPWSTR)lpTableName;
+       result=LoadAccelerators32W(instance,uni);
+       if (HIWORD(uni))
+               free(uni);
+       return result;
+}
+
+
 /**********************************************************************
  *                     TranslateAccelerator    [USER.178]
  */
@@ -351,14 +538,15 @@ int TranslateAccelerator(HWND hWnd, HANDLE hAccel, LPMSG16 msg)
     GlobalUnlock16(hAccel);
     return 0;
 }
-\f
+
 /**********************************************************************
- *                                     LoadString
+ *                                     LoadString16
  */
-int
-LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen)
+INT16
+LoadString16(HINSTANCE16 instance,UINT16 resource_id,LPSTR buffer,INT16 buflen)
 {
-    HANDLE hmem, hrsrc;
+    HGLOBAL16 hmem;
+    HRSRC16 hrsrc;
     unsigned char *p;
     int string_num;
     int i;
@@ -366,12 +554,12 @@ LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen)
     dprintf_resource(stddeb,"LoadString: inst=%04x id=%04x buff=%08x len=%d\n",
                      instance, resource_id, (int) buffer, buflen);
 
-    hrsrc = FindResource( instance, (SEGPTR)((resource_id>>4)+1), RT_STRING );
+    hrsrc = FindResource16( instance, (SEGPTR)((resource_id>>4)+1), RT_STRING );
     if (!hrsrc) return 0;
-    hmem = LoadResource( instance, hrsrc );
+    hmem = LoadResource16( instance, hrsrc );
     if (!hmem) return 0;
     
-    p = LockResource(hmem);
+    p = LockResource16(hmem);
     string_num = resource_id & 0x000f;
     for (i = 0; i < string_num; i++)
        p += *p + 1;
@@ -392,11 +580,73 @@ LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen)
        fprintf(stderr,"LoadString // I dont know why , but caller give buflen=%d *p=%d !\n", buflen, *p);
        fprintf(stderr,"LoadString // and try to obtain string '%s'\n", p + 1);
     }
-    FreeResource( hmem );
+    FreeResource16( hmem );
 
     dprintf_resource(stddeb,"LoadString // '%s' copied !\n", buffer);
     return i;
 }
 
+/**********************************************************************
+ *     LoadString32W           (USER32.375)
+ */
+INT32
+LoadString32W(HINSTANCE32 instance,UINT32 resource_id,LPWSTR buffer,int buflen)
+{
+    HGLOBAL32 hmem;
+    HRSRC32 hrsrc;
+    WCHAR *p;
+    int string_num;
+    int i;
+
+    dprintf_resource(stddeb, "LoadString: instance = %04x, id = %04x, buffer = %08x, "
+          "length = %d\n", instance, (int)resource_id, (int) buffer, buflen);
 
+    hrsrc = FindResource32W( instance, (LPCWSTR)((resource_id>>4)+1), 
+               (LPCWSTR)RT_STRING );
+    if (!hrsrc) return 0;
+    hmem = LoadResource32( instance, hrsrc );
+    if (!hmem) return 0;
+    
+    p = LockResource32(hmem);
+    string_num = resource_id & 0x000f;
+    for (i = 0; i < string_num; i++)
+       p += *p + 1;
+    
+    dprintf_resource( stddeb, "strlen = %d\n", (int)*p );
+    
+    i = MIN(buflen - 1, *p);
+    if (buffer == NULL)
+       return i;
+    if (i > 0) {
+       memcpy(buffer, p + 1, i * sizeof (WCHAR));
+       buffer[i] = (WCHAR) 0;
+    } else {
+       if (buflen > 1) {
+           buffer[0] = (WCHAR) 0;
+           return 0;
+       }
+#if 0
+       fprintf(stderr,"LoadString // I dont know why , but caller give buflen=%d *p=%d !\n", buflen, *p);
+       fprintf(stderr,"LoadString // and try to obtain string '%s'\n", p + 1);
+#endif
+    }
+#if 0
+    dprintf_resource(stddeb,"LoadString // '%s' copied !\n", buffer);
+#endif
+    return i;
+}
+
+/**********************************************************************
+ *     LoadString32A   (USER32.374)
+ */
+INT32
+LoadString32A(HINSTANCE32 instance,UINT32 resource_id,LPSTR buffer,int buflen)
+{
+    LPWSTR buffer2 = (LPWSTR)xmalloc(buflen*2);
+    INT32 retval = LoadString32W(instance,resource_id,buffer2,buflen);
+
+    STRING32_UniToAnsi(buffer,buffer2);
+    free(buffer2);
+    return retval;
+}
 
index 1cfeb3aa87a03cfc1a00eeff951f2709cec5f2f4..ef862d2ba2e69003c16d172994cdade72ea566bb 100644 (file)
 #define STACK32_SIZE 0x10000
 
 extern void USER_AppExit(HTASK, HINSTANCE, HQUEUE );
-/* ------ Internal variables ------ */
 
-static HTASK hFirstTask = 0;
-static HTASK hCurrentTask = 0;
-static HTASK hTaskToKill = 0;
-static HTASK hLockedTask = 0;
+  /* Saved 16-bit stack for current process (Win16 only) */
+WORD IF1632_Saved16_ss = 0;
+WORD IF1632_Saved16_sp = 0;
+
+  /* Saved 32-bit stack for current process (Win16 only) */
+DWORD IF1632_Saved32_esp = 0;
+SEGPTR IF1632_Stack32_base = 0;
+
+  /* Original Unix stack */
+DWORD IF1632_Original32_esp;
+
+static HTASK16 hFirstTask = 0;
+static HTASK16 hCurrentTask = 0;
+static HTASK16 hTaskToKill = 0;
+static HTASK16 hLockedTask = 0;
 static WORD nTaskCount = 0;
 static HANDLE hDOSEnvironment = 0;
 
-/* ------ Internal declarations ------ */
-
   /* TASK_Reschedule() 16-bit entry point */
-static FARPROC TASK_RescheduleProc;
+static FARPROC16 TASK_RescheduleProc;
 
 #ifdef WINELIB
 #define TASK_SCHEDULE()  TASK_Reschedule();
@@ -63,7 +71,7 @@ static HANDLE TASK_CreateDOSEnvironment(void);
 /***********************************************************************
  *           TASK_Init
  */
-BOOL TASK_Init(void)
+BOOL32 TASK_Init(void)
 {
     TASK_RescheduleProc = MODULE_GetWndProcEntry16( "TASK_Reschedule" );
     if (!(hDOSEnvironment = TASK_CreateDOSEnvironment()))
@@ -196,9 +204,9 @@ static HANDLE TASK_CreateDOSEnvironment(void)
 /***********************************************************************
  *           TASK_LinkTask
  */
-static void TASK_LinkTask( HTASK hTask )
+static void TASK_LinkTask( HTASK16 hTask )
 {
-    HTASK *prevTask;
+    HTASK16 *prevTask;
     TDB *pTask;
 
     if (!(pTask = (TDB *)GlobalLock16( hTask ))) return;
@@ -218,9 +226,9 @@ static void TASK_LinkTask( HTASK hTask )
 /***********************************************************************
  *           TASK_UnlinkTask
  */
-static void TASK_UnlinkTask( HTASK hTask )
+static void TASK_UnlinkTask( HTASK16 hTask )
 {
-    HTASK *prevTask;
+    HTASK16 *prevTask;
     TDB *pTask;
 
     prevTask = &hFirstTask;
@@ -369,7 +377,7 @@ static void TASK_CallToStart(void)
                  cs_reg, ip_reg, ds_reg,
                  IF1632_Saved16_ss, IF1632_Saved16_sp);
 
-    CallTo16_regs_( (FARPROC)(cs_reg << 16 | ip_reg), ds_reg,
+    CallTo16_regs_( (FARPROC16)(cs_reg << 16 | ip_reg), ds_reg,
                    pTask->hPDB /*es*/, 0 /*bp*/, 0 /*ax*/,
                    pModule->stack_size /*bx*/, pModule->heap_size /*cx*/,
                    0 /*dx*/, 0 /*si*/, ds_reg /*di*/ );
@@ -384,8 +392,9 @@ static void TASK_CallToStart(void)
 /***********************************************************************
  *           TASK_CreateTask
  */
-HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance, HANDLE hPrevInstance,
-                       HANDLE hEnvironment, char *cmdLine, WORD cmdShow )
+HTASK16 TASK_CreateTask( HMODULE16 hModule, HINSTANCE16 hInstance,
+                         HINSTANCE16 hPrevInstance, HANDLE16 hEnvironment,
+                         LPCSTR cmdLine, UINT16 cmdShow )
 {
     HTASK hTask;
     TDB *pTask;
@@ -394,10 +403,10 @@ HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance, HANDLE hPrevInstance,
     SEGTABLEENTRY *pSegTable;
     LPSTR name;
     char filename[256];
-#ifndef WINELIB32
     char *stack16Top, *stack32Top;
     STACK16FRAME *frame16;
     STACK32FRAME *frame32;
+#ifndef WINELIB32
     extern DWORD CALLTO16_RetAddr_word;
 #endif
     
@@ -466,17 +475,16 @@ HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance, HANDLE hPrevInstance,
       /* Fill the PDB */
 
     pTask->pdb.int20 = 0x20cd;
-#ifndef WINELIB
     pTask->pdb.dispatcher[0] = 0x9a;  /* ljmp */
+#ifndef WINELIB
     *(FARPROC16 *)&pTask->pdb.dispatcher[1] = MODULE_GetEntryPoint( GetModuleHandle("KERNEL"), 102 );  /* KERNEL.102 is DOS3Call() */
     pTask->pdb.savedint22 = INT_GetHandler( 0x22 );
     pTask->pdb.savedint23 = INT_GetHandler( 0x23 );
     pTask->pdb.savedint24 = INT_GetHandler( 0x24 );
-    pTask->pdb.fileHandlesPtr = (SEGPTR)MAKELONG( 0x18,
-                                              GlobalHandleToSel(pTask->hPDB) );
-#else
-    pTask->pdb.fileHandlesPtr = pTask->pdb.fileHandles;
 #endif
+    pTask->pdb.fileHandlesPtr =
+        PTR_SEG_OFF_TO_SEGPTR( GlobalHandleToSel(pTask->hPDB),
+                               (int)&((PDB *)0)->fileHandles );
     memset( pTask->pdb.fileHandles, 0xff, sizeof(pTask->pdb.fileHandles) );
     pTask->pdb.environment    = hEnvironment;
     pTask->pdb.nbFiles        = 20;
@@ -504,7 +512,6 @@ HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance, HANDLE hPrevInstance,
 
       /* Allocate the 32-bit stack */
 
-#ifndef WINELIB
     pTask->hStack32 = GLOBAL_Alloc( GMEM_FIXED, STACK32_SIZE, pTask->hPDB,
                                     FALSE, FALSE, FALSE );
 
@@ -520,8 +527,10 @@ HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance, HANDLE hPrevInstance,
     frame32->ecx = 0;
     frame32->ebx = 0;
     frame32->ebp = 0;
+#ifndef WINELIB
     frame32->retaddr = (DWORD)TASK_CallToStart;
     frame32->codeselector = WINE_CODE_SELECTOR;
+#endif
     pTask->esp = (DWORD)frame32;
 
       /* Create the 16-bit stack frame */
@@ -531,15 +540,17 @@ HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance, HANDLE hPrevInstance,
                  pSegTable[pModule->ss-1].minsize + pModule->stack_size) & ~1;
     stack16Top = (char *)PTR_SEG_OFF_TO_LIN( pTask->ss, pTask->sp );
     frame16 = (STACK16FRAME *)stack16Top - 1;
-    frame16->saved_ss = 0; /*pTask->ss;*/
-    frame16->saved_sp = 0; /*pTask->sp;*/
+    frame16->saved_ss = 0;
+    frame16->saved_sp = 0;
     frame16->ds = frame16->es = pTask->hInstance;
     frame16->entry_point = 0;
     frame16->entry_ip = OFFSETOF(TASK_RescheduleProc) + 14;
     frame16->entry_cs = SELECTOROF(TASK_RescheduleProc);
     frame16->bp = 0;
+#ifndef WINELIB
     frame16->ip = LOWORD( CALLTO16_RetAddr_word );
     frame16->cs = HIWORD( CALLTO16_RetAddr_word );
+#endif  /* WINELIB */
     pTask->sp -= sizeof(STACK16FRAME);
 
       /* If there's no 16-bit stack yet, use a part of the new task stack */
@@ -554,6 +565,7 @@ HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance, HANDLE hPrevInstance,
 
       /* Add a breakpoint at the start of the task */
 
+#ifndef WINELIB
     if (Options.debug)
     {
         if (pModule->flags & NE_FFLAGS_WIN32)
@@ -570,7 +582,7 @@ HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance, HANDLE hPrevInstance,
             DEBUG_AddBreakpoint( &addr );
         }
     }
-#endif
+#endif  /* WINELIB */
 
       /* Add the task to the linked list */
 
@@ -626,7 +638,7 @@ static void TASK_DeleteTask( HTASK hTask )
  * be killed when either TASK_Reschedule or this function is called again 
  * in the context of another task.
  */
-void TASK_KillCurrentTask( int exitCode )
+void TASK_KillCurrentTask( INT16 exitCode )
 {
     extern void EXEC_ExitWindows( int retCode );
 
@@ -731,7 +743,6 @@ void TASK_Reschedule(void)
 
       /* Save the stacks of the previous task (if any) */
 
-#ifndef WINELIB /* FIXME: JBP: IF1632 not allowed in libwine.a */
     if (pOldTask)
     {
         pOldTask->ss  = IF1632_Saved16_ss;
@@ -739,7 +750,6 @@ void TASK_Reschedule(void)
         pOldTask->esp = IF1632_Saved32_esp;
     }
     else IF1632_Original32_esp = IF1632_Saved32_esp;
-#endif
 
      /* Make the task the last in the linked list (round-robin scheduling) */
 
@@ -751,12 +761,10 @@ void TASK_Reschedule(void)
       /* Switch to the new stack */
 
     hCurrentTask = hTask;
-#ifndef WINELIB /* FIXME: JBP: IF1632 not allowed in libwine.a */
     IF1632_Saved16_ss   = pNewTask->ss;
     IF1632_Saved16_sp   = pNewTask->sp;
     IF1632_Saved32_esp  = pNewTask->esp;
     IF1632_Stack32_base = WIN16_GlobalLock16( pNewTask->hStack32 );
-#endif
 }
 
 
@@ -965,7 +973,7 @@ FARPROC16 MakeProcInstance16( FARPROC16 func, HANDLE16 hInstance )
     SEGPTR thunkaddr;
     
     thunkaddr = TASK_AllocThunk( hCurrentTask );
-    if (!thunkaddr) return (FARPROC)0;
+    if (!thunkaddr) return (FARPROC16)0;
     thunk = PTR_SEG_TO_LIN( thunkaddr );
 
     dprintf_task( stddeb, "MakeProcInstance(%08lx,%04x): got thunk %08lx\n",
@@ -976,7 +984,7 @@ FARPROC16 MakeProcInstance16( FARPROC16 func, HANDLE16 hInstance )
     *thunk++ = (BYTE)(hInstance >> 8);
     *thunk++ = 0xea;    /* ljmp func */
     *(DWORD *)thunk = (DWORD)func;
-    return (FARPROC)thunkaddr;
+    return (FARPROC16)thunkaddr;
 #endif
 }
 
@@ -996,7 +1004,7 @@ void FreeProcInstance16( FARPROC16 func )
 /**********************************************************************
  *         GetCodeHandle    (KERNEL.93)
  */
-HANDLE GetCodeHandle( FARPROC proc )
+HANDLE GetCodeHandle( FARPROC16 proc )
 {
 #ifndef WINELIB32
     HANDLE handle;
@@ -1109,7 +1117,7 @@ int GetInstanceData( HANDLE instance, WORD buffer, int len )
     char *ptr = (char *)GlobalLock16( instance );
     if (!ptr || !len) return 0;
     if ((int)buffer + len >= 0x10000) len = 0x10000 - buffer;
-    memcpy( ptr + buffer, (char *)GlobalLock16( CURRENT_DS ) + buffer, len );
+    memcpy( (char *)GlobalLock16(CURRENT_DS) + buffer, ptr + buffer, len );
     return len;
 }
 
@@ -1178,11 +1186,11 @@ BOOL IsTask( HTASK hTask )
 /***********************************************************************
  *           GetExePtr   (KERNEL.133)
  */
-HMODULE GetExePtr( HANDLE handle )
+HMODULE16 GetExePtr( HANDLE16 handle )
 {
     char *ptr;
-    HTASK hTask;
-    HANDLE owner;
+    HTASK16 hTask;
+    HANDLE16 owner;
 
       /* Check for module handle */
 
index a2e5b36746a02fbe21ea4fbba402986acda6671b..c0e1c98296c87484599a9c8761218ea345bccfaf 100644 (file)
@@ -1,3 +1,4 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
 MODULE = memory
 
index c21f5ceae671bd8875b29b0784187956fc8ed9ba..c3d66a75f1524d6182407db38df90003a5e51bc2 100644 (file)
@@ -46,6 +46,8 @@ typedef struct
 static GLOBALARENA *pGlobalArena = NULL;
 static int globalArenaSize = 0;
 
+static DWORD globalDOSfree = 655350;
+
 #define GLOBAL_MAX_ALLOC_SIZE 0x00ff0000  /* Largest allocation is 16M - 64K */
 
 #define GET_ARENA_PTR(handle)  (pGlobalArena + ((handle) >> __AHSHIFT))
@@ -550,11 +552,21 @@ BOOL16 GlobalUnWire( HGLOBAL16 handle )
 
 /***********************************************************************
  *           GlobalDOSAlloc   (KERNEL.184)
+ *
+ * Some programs rely on failure to allocate > 640K total with this function
  */
 DWORD GlobalDOSAlloc( DWORD size )
 {
-    WORD sel = GlobalAlloc16( GMEM_FIXED, size );
+    WORD sel;
+
+    if (size > globalDOSfree) return 0;
+    sel = GlobalAlloc16( GMEM_FIXED, size );
+
+    dprintf_global( stddeb, "GlobalDOSAlloc: %08lx -> returning %04x\n",
+                    size, sel );
     if (!sel) return 0;
+
+    globalDOSfree -= size;
     return MAKELONG( sel, sel /* this one ought to be a real-mode segment */ );
 }
 
@@ -564,7 +576,12 @@ DWORD GlobalDOSAlloc( DWORD size )
  */
 WORD GlobalDOSFree( WORD sel )
 {
-    return GlobalFree16( GlobalHandle16(sel) ) ? sel : 0;
+    GLOBALARENA *pArena = GET_ARENA_PTR(sel);
+
+    if (!pArena) return sel;
+    globalDOSfree += pArena->size;
+    GlobalFree16( pArena->handle );
+    return 0;
 }
 
 
@@ -652,7 +669,7 @@ void GlobalUnfix( HGLOBAL16 handle )
 /***********************************************************************
  *           FarSetOwner   (KERNEL.403)
  */
-void FarSetOwner( HANDLE16 handle, HANDLE16 hOwner )
+void FarSetOwner( HGLOBAL16 handle, HANDLE16 hOwner )
 {
     GET_ARENA_PTR(handle)->hOwner = hOwner;
 }
@@ -661,7 +678,7 @@ void FarSetOwner( HANDLE16 handle, HANDLE16 hOwner )
 /***********************************************************************
  *           FarGetOwner   (KERNEL.404)
  */
-HANDLE16 FarGetOwner( HANDLE16 handle )
+HANDLE16 FarGetOwner( HGLOBAL16 handle )
 {
     return GET_ARENA_PTR(handle)->hOwner;
 }
index 20ba25e07cc11b96022ec45fd5e0c9f0e87c59ec..35116372e63d3236b6fde0a732e5d412de726248 100644 (file)
@@ -95,6 +95,7 @@ int LDT_GetEntry( int entry, ldt_entry *content )
     content->seg_32bit      = (ldt_flags_copy[entry] & LDT_FLAGS_32BIT) != 0;
     content->read_only      = (ldt_flags_copy[entry] & LDT_FLAGS_READONLY) !=0;
     content->limit_in_pages = (ldt_flags_copy[entry] & LDT_FLAGS_BIG) !=0;
+    if (content->limit_in_pages) content->limit >>= 12;
     return ret;
 }
 
@@ -134,7 +135,34 @@ int LDT_SetEntry( int entry, const ldt_entry *content )
         ldt_info.contents       = content->type;
         ldt_info.read_exec_only = content->read_only != 0;
         ldt_info.limit_in_pages = content->limit_in_pages != 0;
-        ret = modify_ldt(1, &ldt_info, sizeof(ldt_info));
+        /* Make sure the info will be accepted by the kernel */
+        /* This is ugly, but what can I do? */
+        if (content->type == SEGMENT_STACK)
+        {
+            /* FIXME */
+        }
+        else
+        {
+            if (ldt_info.base_addr >= 0xc0000000)
+            {
+                fprintf( stderr, "LDT_SetEntry: invalid base addr %08lx\n",
+                         ldt_info.base_addr );
+                return -1;
+            }
+            if (content->limit_in_pages)
+            {
+                if ((ldt_info.limit << 12) + 0xfff >
+                                               0xc0000000 - ldt_info.base_addr)
+                    ldt_info.limit = (0xc0000000 - 0xfff - ldt_info.base_addr) >> 12;
+            }
+            else
+            {
+                if (ldt_info.limit > 0xc0000000 - ldt_info.base_addr)
+                    ldt_info.limit = 0xc0000000 - ldt_info.base_addr;
+            }
+        }
+        if ((ret = modify_ldt(1, &ldt_info, sizeof(ldt_info))) < 0)
+            perror( "modify_ldt" );
     }
 #endif  /* linux */
 
@@ -223,10 +251,9 @@ void LDT_Print( int start, int length )
             flags[1] = (ldt_flags_copy[i] & LDT_FLAGS_READONLY) ? '-' : 'w';
             flags[2] = '-';
         }
-        printf("%04x: sel=%04x base=%08lx limit=%05lx %s %d-bit %c%c%c\n",
+        printf("%04x: sel=%04x base=%08lx limit=%08lx %d-bit %c%c%c\n",
                 i, ENTRY_TO_SELECTOR(i),
                 ldt_copy[i].base, ldt_copy[i].limit,
-                ldt_flags_copy[i] & LDT_FLAGS_BIG ? "(pages)" : "(bytes)",
                 ldt_flags_copy[i] & LDT_FLAGS_32BIT ? 32 : 16,
                 flags[0], flags[1], flags[2] );
     }
index 502d73862be70aba4dd63aa6be1dcecb38aa8460..9f5c762f76437855aae41a0af9f5c86a77d5420e 100644 (file)
 #include "stddebug.h"
 #include "debug.h"
 
-#ifndef WINELIB
-#pragma pack(1)
-#endif
-
 typedef struct
 {
 /* Arena header */
@@ -61,6 +57,8 @@ typedef struct
     BYTE lock;                /* Lock count */
 } LOCALHANDLEENTRY;
 
+#pragma pack(1)
+
 typedef struct
 {
     WORD check;                 /* 00 Heap checking flag */
@@ -85,9 +83,7 @@ typedef struct
     WORD magic;                 /* 28 Magic number */
 } LOCALHEAPINFO;
 
-#ifndef WINELIB
 #pragma pack(4)
-#endif
 
 #define LOCAL_HEAP_MAGIC  0x484c  /* 'LH' */
 
index b0ddc796dba11ac8979fb6c0653f8621d0670df5..a38a0d1970ae96429fd84361f4e1bf1205bb03b8 100644 (file)
@@ -82,7 +82,6 @@ WORD FreeSelector( WORD sel )
     }
 
     /* Clear the saved 16-bit selector */
-#ifndef WINELIB
     frame = CURRENT_STACK16;
     while (frame)
     {
@@ -90,7 +89,6 @@ WORD FreeSelector( WORD sel )
         if ((frame->es >= sel) && (frame->es < nextsel)) frame->es = 0;
        frame = PTR_SEG_OFF_TO_LIN(frame->saved_ss, frame->saved_sp);
     }
-#endif
     return 0;
 }
 
@@ -297,7 +295,9 @@ WORD SetSelectorLimit( WORD sel, DWORD limit )
 {
     ldt_entry entry;
     LDT_GetEntry( SELECTOR_TO_ENTRY(sel), &entry );
-    entry.limit = limit;
+    entry.limit_in_pages = (limit >= 0x100000);
+    if (entry.limit_in_pages) entry.limit = limit >> 12;
+    else entry.limit = limit;
     LDT_SetEntry( SELECTOR_TO_ENTRY(sel), &entry );
     return sel;
 }
index 399eb0691154aed355e84e66ddfd7bb6e57def24..8dd57a2686aa597ebaeb34215fc4ad0ac8bce71f 100644 (file)
@@ -357,25 +357,7 @@ VOID RtlFillMemory( LPVOID ptr, UINT32 len, UINT32 fill )
  */
 VOID RtlMoveMemory( LPVOID dst, LPCVOID src, UINT32 len )
 {
-    /* memcpy does not support overlapped copies, */
-    /* and memmove is not portable. */
-    if (((BYTE *)dst + len <= (BYTE *)src) ||
-        ((BYTE *)src + len <= (BYTE *)dst))
-    {
-        memcpy( dst, src, len );
-        return;
-    }
-    /* do it the hard way (FIXME: could do better than this) */
-    if (dst < src)
-    {
-        while (len--) *((BYTE *)dst)++ = *((BYTE *)src)++;
-    }
-    else
-    {
-        dst = (BYTE *)dst + len - 1;
-        src = (BYTE *)src + len - 1;
-        while (len--) *((BYTE *)dst)-- = *((BYTE *)src)--;
-    }
+    memmove( dst, src, len );
 }
 
 
index 45872d97b0eaaff8fa5f730918e793ad0c6c9e11..a3acb9ed1b952bb81918be62adcd1a39fdfa63df 100644 (file)
@@ -1,3 +1,4 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
 MODULE = misc
 
index 3745eafc9c9b5e01a9402f3193d9bff9937b43f8..dda9e254111d7f78a2127cb6fab85441dd38b91a 100644 (file)
@@ -38,11 +38,11 @@ static BOOL FileDlg_Init()
     static BOOL initialized = 0;
     
     if (!initialized) {
-       if (!hFolder) hFolder = LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER));
-       if (!hFolder2) hFolder2 = LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER2));
-       if (!hFloppy) hFloppy = LoadBitmap(0, MAKEINTRESOURCE(OBM_FLOPPY));
-       if (!hHDisk) hHDisk = LoadBitmap(0, MAKEINTRESOURCE(OBM_HDISK));
-       if (!hCDRom) hCDRom = LoadBitmap(0, MAKEINTRESOURCE(OBM_CDROM));
+       if (!hFolder) hFolder = LoadBitmap16(0, MAKEINTRESOURCE(OBM_FOLDER));
+       if (!hFolder2) hFolder2 = LoadBitmap16(0, MAKEINTRESOURCE(OBM_FOLDER2));
+       if (!hFloppy) hFloppy = LoadBitmap16(0, MAKEINTRESOURCE(OBM_FLOPPY));
+       if (!hHDisk) hHDisk = LoadBitmap16(0, MAKEINTRESOURCE(OBM_HDISK));
+       if (!hCDRom) hCDRom = LoadBitmap16(0, MAKEINTRESOURCE(OBM_CDROM));
        if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 || 
            hHDisk == 0 || hCDRom == 0)
        {       
@@ -68,13 +68,13 @@ BOOL GetOpenFileName(LPOPENFILENAME lpofn)
     if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) hDlgTmpl = lpofn->hInstance;
     else if (lpofn->Flags & OFN_ENABLETEMPLATE)
     {
-        if (!(hResInfo = FindResourcelpofn->hInstance,
-                                       lpofn->lpTemplateName, RT_DIALOG)))
+        if (!(hResInfo = FindResource16(lpofn->hInstance,
+                                        lpofn->lpTemplateName, RT_DIALOG)))
         {
             CommDlgLastError = CDERR_FINDRESFAILURE;
             return FALSE;
         }
-        hDlgTmpl = LoadResource( lpofn->hInstance, hResInfo );
+        hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo );
     }
     else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_OPEN_FILE );
     if (!hDlgTmpl)
@@ -90,7 +90,7 @@ BOOL GetOpenFileName(LPOPENFILENAME lpofn)
 
     if (!(lpofn->Flags & OFN_ENABLETEMPLATEHANDLE))
     {
-        if (lpofn->Flags & OFN_ENABLETEMPLATE) FreeResource( hDlgTmpl );
+        if (lpofn->Flags & OFN_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
         else SYSRES_FreeResource( hDlgTmpl );
     }
 
@@ -115,13 +115,13 @@ BOOL GetSaveFileName(LPOPENFILENAME lpofn)
     else if (lpofn->Flags & OFN_ENABLETEMPLATE)
     {
         hInst = lpofn->hInstance;
-        if (!(hResInfo = FindResourcelpofn->hInstance,
-                                       lpofn->lpTemplateName, RT_DIALOG )))
+        if (!(hResInfo = FindResource16(lpofn->hInstance,
+                                        lpofn->lpTemplateName, RT_DIALOG )))
         {
             CommDlgLastError = CDERR_FINDRESFAILURE;
             return FALSE;
         }
-        hDlgTmpl = LoadResource( lpofn->hInstance, hResInfo );
+        hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo );
     }
     else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_SAVE_FILE );
 
@@ -131,7 +131,7 @@ BOOL GetSaveFileName(LPOPENFILENAME lpofn)
                         (DWORD)lpofn); 
     if (!(lpofn->Flags & OFN_ENABLETEMPLATEHANDLE))
     {
-        if (lpofn->Flags & OFN_ENABLETEMPLATE) FreeResource( hDlgTmpl );
+        if (lpofn->Flags & OFN_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
         else SYSRES_FreeResource( hDlgTmpl );
     }
 
@@ -375,7 +375,7 @@ static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
   SetDlgItemText32A( hWnd, edt1, tmpstr );
   /* get drive list */
   *tmpstr = 0;
-  DlgDirListComboBox16(hWnd, tmpstr, cmb2, 0, 0xC000);
+  DlgDirListComboBox16(hWnd, (LPSTR)MAKE_SEGPTR(tmpstr), cmb2, 0, 0xC000);
   /* read initial directory */
   if (PTR_SEG_TO_LIN(lpofn->lpstrInitialDir) != NULL) 
     {
@@ -1101,13 +1101,13 @@ BOOL ChooseColor(LPCHOOSECOLOR lpChCol)
     if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE) hDlgTmpl = lpChCol->hInstance;
     else if (lpChCol->Flags & CC_ENABLETEMPLATE)
     {
-        if (!(hResInfo = FindResourcelpChCol->hInstance,
-                                       lpChCol->lpTemplateName, RT_DIALOG)))
+        if (!(hResInfo = FindResource16(lpChCol->hInstance,
+                                        lpChCol->lpTemplateName, RT_DIALOG)))
         {
             CommDlgLastError = CDERR_FINDRESFAILURE;
             return FALSE;
         }
-        hDlgTmpl = LoadResource( lpChCol->hInstance, hResInfo );
+        hDlgTmpl = LoadResource16( lpChCol->hInstance, hResInfo );
     }
     else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_CHOOSE_COLOR );
     if (!hDlgTmpl)
@@ -1121,7 +1121,7 @@ BOOL ChooseColor(LPCHOOSECOLOR lpChCol)
                            (DWORD)lpChCol );
     if (!(lpChCol->Flags & CC_ENABLETEMPLATEHANDLE))
     {
-        if (lpChCol->Flags & CC_ENABLETEMPLATE) FreeResource( hDlgTmpl );
+        if (lpChCol->Flags & CC_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
         else SYSRES_FreeResource( hDlgTmpl );
     }
     return bRet;
@@ -1576,7 +1576,7 @@ static void CC_PrepareColorGraph(HWND hDlg)
  HBRUSH hbrush;
  HDC hdc ;
  RECT16 rect,client;
- HCURSOR hcursor=SetCursor(LoadCursor(0,IDC_WAIT));
+ HCURSOR hcursor=SetCursor(LoadCursor16(0,IDC_WAIT));
 
  GetClientRect16(hwnd,&client);
  hdc=GetDC(hwnd);
@@ -2182,13 +2182,13 @@ BOOL ChooseFont(LPCHOOSEFONT lpChFont)
     if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE) hDlgTmpl = lpChFont->hInstance;
     else if (lpChFont->Flags & CF_ENABLETEMPLATE)
     {
-        if (!(hResInfo = FindResourcelpChFont->hInstance,
-                                       lpChFont->lpTemplateName, RT_DIALOG)))
+        if (!(hResInfo = FindResource16(lpChFont->hInstance,
+                                        lpChFont->lpTemplateName, RT_DIALOG)))
         {
             CommDlgLastError = CDERR_FINDRESFAILURE;
             return FALSE;
         }
-        hDlgTmpl = LoadResource( lpChFont->hInstance, hResInfo );
+        hDlgTmpl = LoadResource16( lpChFont->hInstance, hResInfo );
     }
     else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_CHOOSE_FONT );
     if (!hDlgTmpl)
@@ -2202,7 +2202,7 @@ BOOL ChooseFont(LPCHOOSEFONT lpChFont)
                       (DWORD)lpChFont );
     if (!(lpChFont->Flags & CF_ENABLETEMPLATEHANDLE))
     {
-        if (lpChFont->Flags & CF_ENABLETEMPLATE) FreeResource( hDlgTmpl );
+        if (lpChFont->Flags & CF_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
         else SYSRES_FreeResource( hDlgTmpl );
     }
     return bRet;
@@ -2381,9 +2381,9 @@ LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam)
   HDC hdc;
   int i,j,res,init=0;
   long l;
-  FARPROC enumCallback = MODULE_GetWndProcEntry16("FontFamilyEnumProc");
+  FARPROC16 enumCallback = MODULE_GetWndProcEntry16("FontFamilyEnumProc");
   LPLOGFONT16 lpxx;
-  HCURSOR hcursor=SetCursor(LoadCursor(0,IDC_WAIT));
+  HCURSOR hcursor=SetCursor(LoadCursor16(0,IDC_WAIT));
   LPCHOOSEFONT lpcf;
 
   SetWindowLong32A(hDlg, DWL_USER, lParam); 
@@ -2398,7 +2398,7 @@ LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam)
     return FALSE;
   }
   if (!hBitmapTT)
-    hBitmapTT = LoadBitmap(0, MAKEINTRESOURCE(OBM_TRTYPE));
+    hBitmapTT = LoadBitmap16(0, MAKEINTRESOURCE(OBM_TRTYPE));
                         
   if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner))
     ShowWindow(GetDlgItem(hDlg,pshHelp),SW_HIDE);
@@ -2495,7 +2495,7 @@ LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
   BITMAP16 bm;
   LPMEASUREITEMSTRUCT16 lpmi=PTR_SEG_TO_LIN((LPMEASUREITEMSTRUCT16)lParam);
   if (!hBitmapTT)
-    hBitmapTT = LoadBitmap(0, MAKEINTRESOURCE(OBM_TRTYPE));
+    hBitmapTT = LoadBitmap16(0, MAKEINTRESOURCE(OBM_TRTYPE));
   GetObject16( hBitmapTT, sizeof(bm), &bm );
   lpmi->itemHeight=bm.bmHeight;
   /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
@@ -2615,7 +2615,7 @@ LRESULT CFn_WMCtlColor(HWND hDlg, WPARAM wParam, LPARAM lParam)
 LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam)
 {
   char buffer[200];
-  FARPROC enumCallback;
+  FARPROC16 enumCallback;
   HFONT hFont/*,hFontOld*/;
   int i,j;
   long l;
@@ -2636,7 +2636,7 @@ LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam)
                      i=SendDlgItemMessage16(hDlg,cmb1,CB_GETCURSEL,0,0);
                      if (i!=CB_ERR)
                      {
-                       HCURSOR hcursor=SetCursor(LoadCursor(0,IDC_WAIT));
+                       HCURSOR hcursor=SetCursor(LoadCursor16(0,IDC_WAIT));
                         SendDlgItemMessage16(hDlg,cmb1,CB_GETLBTEXT,i,(LPARAM)MAKE_SEGPTR(buffer));
                        dprintf_commdlg(stddeb,"WM_COMMAND/cmb1 =>%s\n",buffer);
                        enumCallback = MODULE_GetWndProcEntry16("FontStyleEnumProc");
index 6277f8af8e285734aef11737f3154f842112f890..4cc90436f9e6b25598030d2bea07043765dd3c15 100644 (file)
@@ -195,7 +195,7 @@ LRESULT CloseDriver(HDRVR16 hDrvr, LPARAM lParam1, LPARAM lParam2)
 HMODULE16 GetDriverModuleHandle(HDRVR16 hDrvr)
 {
     LPDRIVERITEM lpdrv;
-    HMODULE hModule = 0;
+    HMODULE16 hModule = 0;
 
     dprintf_driver( stddeb, "GetDriverModuleHandle(%04x);\n", hDrvr);
 
index 34dbccc831829f3e9f52f435efb47822e7177e6e..690775eb1bacafe3da69c1b835aaf14813b98da2 100644 (file)
@@ -111,7 +111,8 @@ struct options Options =
 #else
     LANG_En,
 #endif
-    FALSE          /* Managed windows */
+    FALSE,          /* Managed windows */
+    FALSE           /* Perfect graphics */
 };
 
 
@@ -125,6 +126,7 @@ static XrmOptionDescRec optionsTable[] =
     { "-ipc",           ".ipc",             XrmoptionNoArg,  (caddr_t)"off"},
     { "-language",      ".language",        XrmoptionSepArg, (caddr_t)"En" },
     { "-name",          ".name",            XrmoptionSepArg, (caddr_t)NULL },
+    { "-perfect",       ".perfect",         XrmoptionNoArg,  (caddr_t)"on" },
     { "-privatemap",    ".privatemap",      XrmoptionNoArg,  (caddr_t)"on" },
     { "-fixedmap",      ".fixedmap",        XrmoptionNoArg,  (caddr_t)"on" },
     { "-synchronous",   ".synchronous",     XrmoptionNoArg,  (caddr_t)"on" },
@@ -158,6 +160,7 @@ static XrmOptionDescRec optionsTable[] =
   "    -managed        Allow the window manager to manage created windows\n" \
   "    -mode mode      Start Wine in a particular mode (standard or enhanced)\n" \
   "    -name name      Set the application name\n" \
+  "    -perfect        Favor correctness over speed for graphical operations\n" \
   "    -privatemap     Use a private color map\n" \
   "    -synchronous    Turn on synchronous display mode\n" \
   "    -winver         Version to imitate (one of win31,win95,nt351)\n"
@@ -407,6 +410,8 @@ static void MAIN_ParseOptions( int *argc, char *argv[] )
         Options.allowReadOnly = TRUE;
     if (MAIN_GetResource( db, ".ipc", &value ))
         Options.ipc = TRUE;
+    if (MAIN_GetResource( db, ".perfect", &value ))
+       Options.perfectGraphics = TRUE;
     if (MAIN_GetResource( db, ".depth", &value))
        screenDepth = atoi( value.addr );
     if (MAIN_GetResource( db, ".desktop", &value))
@@ -615,6 +620,13 @@ int main( int argc, char *argv[] )
     
     MAIN_ParseOptions( &argc, argv );
 
+    if (Options.desktopGeometry && Options.managed)
+    {
+        fprintf( stderr, "%s: -managed and -desktop options cannot be used together\n",
+                 Options.programName );
+        exit(1);
+    }
+
     screen       = DefaultScreenOfDisplay( display );
     screenWidth  = WidthOfScreen( screen );
     screenHeight = HeightOfScreen( screen );
@@ -1175,7 +1187,7 @@ BOOL SwapMouseButton(BOOL fSwap)
 /***********************************************************************
 *      FileCDR (KERNEL.130)
 */
-void FileCDR(FARPROC x)
+void FileCDR(FARPROC16 x)
 {
        printf("FileCDR(%8x)\n", (int) x);
 }
index ef3b3d738995b1e9016c3e25e43f8335d566132d..33866f195321e9fe4eeb996455d370262b41d439 100644 (file)
@@ -1,8 +1,14 @@
+/*
+ * Misc. functions for systems that don't have them
+ *
+ * Copyright 1996 Alexandre Julliard
+ */
+
+#include "config.h"
 #include <sys/types.h>
 #include <sys/time.h>
 
 #ifndef HAVE_USLEEP
-
 unsigned int usleep (unsigned int useconds)
 {
     struct timeval delay;
@@ -13,8 +19,28 @@ unsigned int usleep (unsigned int useconds)
     select( 0, 0, 0, 0, &delay );
     return 0;
 }
-
 #endif /* HAVE_USLEEP */
 
-
-
+#ifndef HAVE_MEMMOVE
+void *memmove( void *dst, const void *src, unsigned int len )
+{
+    /* Use memcpy if not overlapping */
+    if (((char *)dst + len <= (char *)src) ||
+        ((char *)src + len <= (char *)dst))
+    {
+        memcpy( dst, src, len );
+    }
+    /* Otherwise do it the hard way (FIXME: could do better than this) */
+    else if (dst < src)
+    {
+        while (len--) *((char *)dst)++ = *((char *)src)++;
+    }
+    else
+    {
+        dst = (char *)dst + len - 1;
+        src = (char *)src + len - 1;
+        while (len--) *((char *)dst)-- = *((char *)src)--;
+    }
+    return dst;
+}
+#endif  /* HAVE_MEMMOVE */
index 1025acbacdbb2f74d75d7bb4341da733f03617e7..e9dbbcb8dd59a6291141390094f353989507c6ed 100644 (file)
@@ -359,7 +359,7 @@ INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon)
     else *AppMisc = 0;
     AppMisc[sizeof(AppMisc)-1]=0;
 
-    if (!hIcon) hIcon = LoadIcon(0,MAKEINTRESOURCE(OIC_WINEICON));
+    if (!hIcon) hIcon = LoadIcon16(0,MAKEINTRESOURCE(OIC_WINEICON));
     handle = SYSRES_LoadResource( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX );
     if (!handle) return FALSE;
     bRet = DialogBoxIndirectParam16( WIN_GetWindowInstance( hWnd ),
@@ -552,9 +552,9 @@ HICON ExtractIcon(HINSTANCE hInstance, LPCSTR lpszExeFileName, WORD nIconIndex)
  * Return icon for given file (either from file itself or from associated
  * executable) and patch parameters if needed.
  */
-HICON ExtractAssociatedIcon(HINSTANCE hInst,LPSTR lpIconPath, LPWORD lpiIcon)
+HICON16 ExtractAssociatedIcon(HINSTANCE16 hInst,LPSTR lpIconPath,LPWORD lpiIcon)
 {
-    HICON hIcon = ExtractIcon(hInst, lpIconPath, *lpiIcon);
+    HICON16 hIcon = ExtractIcon(hInst, lpIconPath, *lpiIcon);
 
     if( hIcon < 2 )
       {
@@ -580,7 +580,7 @@ HICON ExtractAssociatedIcon(HINSTANCE hInst,LPSTR lpIconPath, LPWORD lpiIcon)
          *lpiIcon = 6;   /* generic icon - found nothing */
 
         GetModuleFileName(hInst, lpIconPath, 0x80);
-       hIcon = LoadIcon( hInst, MAKEINTRESOURCE(*lpiIcon));
+       hIcon = LoadIcon16( hInst, MAKEINTRESOURCE(*lpiIcon));
       }
 
     return hIcon;
index 551078ca23d38c8dcb0255a9db23466fe43595ee..ff4c04b37888816c5cf2ee821129a545ff8aa975 100644 (file)
@@ -23,7 +23,7 @@
 static struct notify
 {
     HTASK    htask;
-    FARPROC  lpfnCallback;
+    FARPROC16 lpfnCallback;
     WORD     wFlags;
 } *notifys = NULL;
 
index dfa5fe0e1dc1dc4ea2ec3163a129dea0fb7557ed..d90ff8200320f2e4424e5f23fb83ac8bf654fa25 100644 (file)
@@ -37,7 +37,7 @@
 static WORD wsa_errno;
 static int wsa_initted;
 static key_t wine_key = 0;
-static FARPROC BlockFunction;
+static FARPROC16 BlockFunction;
 static fd_set fd_in_use;
 
 extern int h_errno;
@@ -1423,7 +1423,7 @@ BOOL WSAIsBlocking(void)
        return 0;
 }
 
-FARPROC WSASetBlockingHook(FARPROC lpBlockFunc)
+FARPROC16 WSASetBlockingHook(FARPROC16 lpBlockFunc)
 {
        dprintf_winsock(stddeb, "WSA_SetBlockHook %8lx, STUB!\n", (unsigned long) lpBlockFunc);
 
@@ -1434,7 +1434,7 @@ FARPROC WSASetBlockingHook(FARPROC lpBlockFunc)
 
        BlockFunction = lpBlockFunc;
 
-       return (FARPROC) lpBlockFunc;
+       return (FARPROC16) lpBlockFunc;
 }
 
 INT WSAUnhookBlockingHook(void)
index a57d23f1f48df858bf0c43be536024a7b741cb35..0eb9a2d0befe9e989e0e5bf5c391c66908e6cbff 100644 (file)
@@ -254,7 +254,8 @@ INT16 wvsnprintf16( LPSTR buffer, UINT16 maxlen, LPCSTR spec, LPCVOID args )
             break;
         case WPR_WSTRING:  /* No Unicode in Win16 */
         case WPR_STRING:
-            cur_arg = (DWORD)PTR_SEG_TO_LIN( *(SEGPTR *)args );
+            if (IsBadReadPtr( *(SEGPTR *)args, 1 )) cur_arg = (DWORD)"";
+            else cur_arg = (DWORD)PTR_SEG_TO_LIN( *(SEGPTR *)args );
             args = (SEGPTR *)args + 1;
             break;
         case WPR_HEXA:
@@ -498,16 +499,14 @@ INT16 wsprintf16( LPSTR buffer, LPCSTR spec, ... )
 }
 
 /* Emulator version */
-#ifndef WINELIB
 INT16 WIN16_wsprintf16(void)
 {
-    SEGPTR *win_stack = (DWORD *)CURRENT_STACK16->args;
+    SEGPTR *win_stack = (SEGPTR *)CURRENT_STACK16->args;
     LPSTR buffer = (LPSTR)PTR_SEG_TO_LIN(win_stack[0]);
     LPCSTR spec  = (LPCSTR)PTR_SEG_TO_LIN(win_stack[1]);
     return wvsprintf16( buffer, spec, &win_stack[2] );
 
 }
-#endif  /* WINELIB */
 
 
 /***********************************************************************
index f1f67ea88dcba54fa42df1bb01ab9052394c2365..b786d455ba51c600234da14b1ec708a88ac82267 100644 (file)
@@ -1,3 +1,4 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
 MODULE = miscemu
 
index 788f70b63bfd6a616a93a8674d3e1acfd03141cf..738c413ae96b7fb6d08d536326b7d3abe014da22 100644 (file)
@@ -6,9 +6,9 @@
 
 #include <stdio.h>
 #include <unistd.h>
-#include <stdlib.h>
 #include <string.h>
 #include "windows.h"
+#include "heap.h"
 #include "ldt.h"
 #include "module.h"
 #include "miscemu.h"
@@ -68,6 +68,19 @@ void INT_Int31Handler( SIGCONTEXT *context )
             AX_reg(context) = 0x8022;  /* invalid selector */
             SET_CFLAG(context);
         }
+        else
+        {
+            /* If a segment register contains the selector being freed, */
+            /* set it to zero. */
+            if (!((DS_reg(context)^BX_reg(context)) & ~3)) DS_reg(context) = 0;
+            if (!((ES_reg(context)^BX_reg(context)) & ~3)) ES_reg(context) = 0;
+#ifdef FS_reg
+            if (!((FS_reg(context)^BX_reg(context)) & ~3)) FS_reg(context) = 0;
+#endif
+#ifdef GS_reg
+            if (!((GS_reg(context)^BX_reg(context)) & ~3)) GS_reg(context) = 0;
+#endif
+        }
         break;
 
     case 0x0002:  /* Real mode segment to descriptor */
@@ -135,6 +148,7 @@ void INT_Int31Handler( SIGCONTEXT *context )
 
     case 0x0009:  /* Set selector access rights */
         SelectorAccessRights( BX_reg(context), 1, CX_reg(context) );
+        break;
 
     case 0x000a:  /* Allocate selector alias */
         if (!(AX_reg(context) = AllocCStoDSAlias( BX_reg(context) )))
@@ -199,8 +213,9 @@ void INT_Int31Handler( SIGCONTEXT *context )
             if ((BL_reg(context) == 0x2f) && ((p->eax & 0xFF00) == 0x1500))
             {
                 do_mscdex( context );
+               break;
             }
-            else SET_CFLAG(context);
+            SET_CFLAG(context);
         }
         break;
 
@@ -242,8 +257,8 @@ void INT_Int31Handler( SIGCONTEXT *context )
         break;
 
     case 0x0501:  /* Allocate memory block */
-        if (!(ptr = (BYTE *)malloc( MAKELONG( CX_reg(context),
-                                              BX_reg(context) ) )))
+        if (!(ptr = (BYTE *)HeapAlloc( SystemHeap, 0,MAKELONG( CX_reg(context),
+                                                           BX_reg(context) ))))
         {
             AX_reg(context) = 0x8012;  /* linear memory not available */
             SET_CFLAG(context);
@@ -256,12 +271,14 @@ void INT_Int31Handler( SIGCONTEXT *context )
         break;
 
     case 0x0502:  /* Free memory block */
-        free( (void *)MAKELONG( DI_reg(context), SI_reg(context) ) );
+        HeapFree( SystemHeap, 0,
+                  (void *)MAKELONG( DI_reg(context), SI_reg(context) ) );
         break;
 
     case 0x0503:  /* Resize memory block */
-        if (!(ptr = (BYTE *)realloc( (void *)MAKELONG(DI_reg(context),SI_reg(context)),
-                                     MAKELONG(CX_reg(context),BX_reg(context)))))
+        if (!(ptr = (BYTE *)HeapReAlloc( SystemHeap, 0,
+                           (void *)MAKELONG(DI_reg(context),SI_reg(context)),
+                                   MAKELONG(CX_reg(context),BX_reg(context)))))
         {
             AX_reg(context) = 0x8012;  /* linear memory not available */
             SET_CFLAG(context);
index 1e943af4a7a9093b80882ee8b564d58b24b1f035..d6e1c1cdf3234fa7535e59723eebcc22a920979b 100644 (file)
@@ -1,3 +1,4 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
 MODULE = multimedia
 
index 78e306c1bef3b2f9937103b2f7ecb3abe68cd433..cd2d86bd406e9e8956f95a5de345bee0ced6792b 100644 (file)
@@ -27,7 +27,7 @@ static MMTIME mmSysTimeSMPTE;
 typedef struct tagTIMERENTRY {
     WORD wDelay;
     WORD wResol;
-    FARPROC lpFunc;
+    FARPROC16 lpFunc;
     HINSTANCE hInstance;
     DWORD dwUser;
     WORD wFlags;
@@ -52,7 +52,7 @@ static VOID TIME_MMSysTimeCallback( HWND32 hwnd, UINT32 msg,
        lpTimer->wCurTime--;
        if (lpTimer->wCurTime == 0) {
            lpTimer->wCurTime = lpTimer->wDelay;
-           if (lpTimer->lpFunc != (FARPROC) NULL) {
+           if (lpTimer->lpFunc != (FARPROC16) NULL) {
                dprintf_mmtime(stddeb, "MMSysTimeCallback // before CallBack16 !\n");
                dprintf_mmtime(stddeb, "MMSysTimeCallback // lpFunc=%p wTimerID=%04X dwUser=%08lX !\n",
                        lpTimer->lpFunc, lpTimer->wTimerID, lpTimer->dwUser);
@@ -151,7 +151,7 @@ WORD timeSetEvent(WORD wDelay, WORD wResol, LPTIMECALLBACK lpFunc,
     lpNewTimer->wCurTime = wDelay;
     lpNewTimer->wDelay = wDelay;
     lpNewTimer->wResol = wResol;
-    lpNewTimer->lpFunc = (FARPROC) lpFunc;
+    lpNewTimer->lpFunc = (FARPROC16) lpFunc;
     lpNewTimer->hInstance = GetTaskDS();
        dprintf_mmtime(stddeb, "timeSetEvent // hInstance=%04X !\n", lpNewTimer->hInstance);
        dprintf_mmtime(stddeb, "timeSetEvent // PTR_SEG_TO_LIN(lpFunc)=%p !\n", 
index eb31162d596e06708c51cc3b4d7a20376ce27c58..08293120ae507f927a2eef4ff1f0bb9d3f188c8a 100644 (file)
@@ -1,3 +1,4 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
 MODULE = objects
 
index 9db1ceb3d9c0c4dcfb9987181dbabdbc212c2865..4eba5dbe315049c6adc8ab6660164d480d5b65e8 100644 (file)
@@ -1106,15 +1106,25 @@ BOOL BITBLT_InternalStretchBlt( DC *dcDst, short xDst, short yDst,
                         visRectDst.left, visRectDst.top, width, height );
         return TRUE;
 
+    case DSTINVERT:  /* 0x55 */
+        if ((dcDst->w.bitsPerPixel == 1) || !COLOR_PaletteToPixel ||
+            !Options.perfectGraphics)
+        {
+            XSetFunction( display, dcDst->u.x.gc, GXinvert );
+            XFillRectangle( display, dcDst->u.x.drawable, dcDst->u.x.gc,
+                            visRectDst.left, visRectDst.top, width, height ); 
+            return TRUE;
+        }
+        break;
+
     case PATINVERT:  /* 0x5a */
-          /* FIXME: This is not really correct, but for now PATINVERT is */
-          /* used to draw the window moving frame, so it has to be fast. */
+       if (Options.perfectGraphics) break;
         if (!DC_SetupGCForBrush( dcDst )) return TRUE;
         XSetFunction( display, dcDst->u.x.gc, GXxor );
         XFillRectangle( display, dcDst->u.x.drawable, dcDst->u.x.gc,
                         visRectDst.left, visRectDst.top, width, height );
         return TRUE;
-        
+
     case SRCCOPY:  /* 0xcc */
         if (dcSrc->w.bitsPerPixel == dcDst->w.bitsPerPixel)
         {
@@ -1155,8 +1165,8 @@ BOOL BITBLT_InternalStretchBlt( DC *dcDst, short xDst, short yDst,
         else
         {
             XSetFunction( display, dcDst->u.x.gc, GXcopy );
-            XSetForeground( display, dcDst->u.x.gc,
-                            COLOR_PaletteToPixel[COLOR_ColormapSize-1] );
+            XSetForeground( display, dcDst->u.x.gc, 
+                            COLOR_PaletteToPixel[COLOR_GetSystemPaletteSize() - 1]);
             XSetFillStyle( display, dcDst->u.x.gc, FillSolid );
         }
         XFillRectangle( display, dcDst->u.x.drawable, dcDst->u.x.gc,
index f54cdc7a287a7605142ff7d0d5bfd36debfa6e96..56805817b265901c812604a15345772751f63f3a 100644 (file)
@@ -12,6 +12,8 @@
 #include "callback.h"
 #include "dc.h"
 #include "bitmap.h"
+#include "heap.h"
+#include "string32.h"
 #include "stddebug.h"
 #include "debug.h"
 
@@ -227,24 +229,24 @@ LONG SetBitmapBits( HBITMAP32 hbitmap, LONG count, LPCVOID buffer )
 
 
 /**********************************************************************
- *         LoadBitmap    (USER.175)
+ *         LoadBitmap16    (USER.175)
  */
-HBITMAP LoadBitmap( HANDLE instance, SEGPTR name )
+HBITMAP16 LoadBitmap16( HINSTANCE16 instance, SEGPTR name )
 {
-    HBITMAP hbitmap = 0;
+    HBITMAP16 hbitmap = 0;
     HDC hdc;
-    HRSRC hRsrc;
-    HGLOBAL handle;
+    HRSRC16 hRsrc;
+    HGLOBAL16 handle;
     BITMAPINFO *info;
 
     if (HIWORD(name))
     {
         char *str = (char *)PTR_SEG_TO_LIN( name );
-        dprintf_bitmap( stddeb, "LoadBitmap(%04x,'%s')\n", instance, str );
+        dprintf_bitmap( stddeb, "LoadBitmap16(%04x,'%s')\n", instance, str );
         if (str[0] == '#') name = (SEGPTR)(DWORD)(WORD)atoi( str + 1 );
     }
     else
-        dprintf_bitmap( stddeb, "LoadBitmap(%04x,%04x)\n",
+        dprintf_bitmap( stddeb, "LoadBitmap16(%04x,%04x)\n",
                         instance, LOWORD(name) );
 
     if (!instance)  /* OEM bitmap */
@@ -253,10 +255,10 @@ HBITMAP LoadBitmap( HANDLE instance, SEGPTR name )
         return OBM_LoadBitmap( LOWORD((int)name) );
     }
 
-    if (!(hRsrc = FindResource( instance, name, RT_BITMAP ))) return 0;
-    if (!(handle = LoadResource( instance, hRsrc ))) return 0;
+    if (!(hRsrc = FindResource16( instance, name, RT_BITMAP ))) return 0;
+    if (!(handle = LoadResource16( instance, hRsrc ))) return 0;
 
-    info = (BITMAPINFO *)LockResource( handle );
+    info = (BITMAPINFO *)LockResource16( handle );
     if ((hdc = GetDC(0)) != 0)
     {
         char *bits = (char *)info + DIB_BitmapInfoSize( info, DIB_RGB_COLORS );
@@ -264,10 +266,59 @@ HBITMAP LoadBitmap( HANDLE instance, SEGPTR name )
                                   bits, info, DIB_RGB_COLORS );
         ReleaseDC( 0, hdc );
     }
-    FreeResource( handle );
+    FreeResource16( handle );
     return hbitmap;
 }
 
+/**********************************************************************
+ *         LoadBitmap32W   (USER32.357)
+ */
+HBITMAP32 LoadBitmap32W( HINSTANCE32 instance, LPCWSTR name )
+{
+    HBITMAP32 hbitmap = 0;
+    HDC hdc;
+    HRSRC32 hRsrc;
+    HGLOBAL32 handle;
+    BITMAPINFO *info;
+
+    if (!instance)  /* OEM bitmap */
+    {
+        if (HIWORD((int)name)) return 0;
+        return OBM_LoadBitmap( LOWORD((int)name) );
+    }
+
+    if (!(hRsrc = FindResource32W( instance, name,
+               (LPWSTR)RT_BITMAP ))) return 0;
+    if (!(handle = LoadResource32( instance, hRsrc ))) return 0;
+
+    info = (BITMAPINFO *)LockResource32( handle );
+    if ((hdc = GetDC(0)) != 0)
+    {
+        char *bits = (char *)info + DIB_BitmapInfoSize( info, DIB_RGB_COLORS );
+        hbitmap = CreateDIBitmap( hdc, &info->bmiHeader, CBM_INIT,
+                                  bits, info, DIB_RGB_COLORS );
+        ReleaseDC( 0, hdc );
+    }
+    return hbitmap;
+}
+
+
+/**********************************************************************
+ *         LoadBitmap32A   (USER32.356)
+ */
+HBITMAP32 LoadBitmap32A( HINSTANCE32 instance, LPCSTR name )
+{
+    HBITMAP32 res;
+    if (!HIWORD(name)) res = LoadBitmap32W(instance,(LPWSTR)name);
+    else
+    {
+        LPWSTR uni = STRING32_DupAnsiToUni(name);
+        res = LoadBitmap32W(instance,uni);
+        free(uni);
+    }
+    return res;
+}
+
 
 /***********************************************************************
  *           BITMAP_DeleteObject
index 6868a22e4e2c13ef114bc7eb03d6b8810ef7aad3..e92adea617eb26b015e67c6a591295ac7f9a708b 100644 (file)
  * Color functions
  *
  * Copyright 1993 Alexandre Julliard
+ * Copyright 1996 Alex Korobka
  */
 
 #include <stdlib.h>
 #include <X11/Xlib.h>
 #include <stdio.h>
+#include <string.h>
 #include "windows.h"
 #include "options.h"
 #include "gdi.h"
 #include "color.h"
-#include "palette.h"
 #include "stddebug.h"
 #include "debug.h"
 #include "xmalloc.h"
 
-Colormap COLOR_WinColormap = 0;
-static int COLOR_FixedMap = 0;
+/* Palette indexed mode:
 
-static int COLOR_Redshift = 0;
-static int COLOR_Redmax = 0;
+ *     logical palette -> mapping -> pixel
+ *                                  
+ *
+ * Windows needs contiguous color space ( from 0 to n ) but 
+ * it is possible only with private colormap. Otherwise we
+ * have to map DC palette indices to real pixel values.
+ * With private colormap it boils down to identity mapping. The
+ * other special case is when we have fixed color visual with 
+ * screendepth > 8 - we abandon mapping altogether (pixel
+ * values can be calculated without X server assistance).
+ *
+ * For info about general Windows palette management read
+ * http://198.105.232.5/MSDN/LIBRARY/TECHNOTE/CH3.HTM 
+ */
+
+extern void BITBLT_SetAccelMode( int ); /* speed up INVERT raster ops whenever possible 
+                                        * parameter is a speedup level (see bitblt.c)
+                                        */
+
+typedef struct
+{ 
+    Colormap    colorMap;
+    UINT16      size;
+    UINT16      flags;
+} CSPACE;
+
+static CSPACE cSpace = {0, 0, 0};
+
+static int COLOR_Redshift   = 0; /* to handle abortive COLOR_VIRTUAL visuals */
+static int COLOR_Redmax     = 0;
 static int COLOR_Greenshift = 0;
-static int COLOR_Greenmax = 0;
-static int COLOR_Blueshift = 0;
-static int COLOR_Bluemax = 0;
-static int COLOR_Graymax = 0;
+static int COLOR_Greenmax   = 0;
+static int COLOR_Blueshift  = 0;
+static int COLOR_Bluemax    = 0;
+static int COLOR_Graymax    = 0;
+
+/* System color space. 
+ *
+ * First 10 and last 10 colors in COLOR_sysPalette are
+ * "guarded". RealizePalette changes only the rest of colorcells. For
+ * currently inactive window it changes only DC palette mappings.
+ */
+
+#define NB_RESERVED_COLORS  20 /* number of fixed colors in system palette */
+
+Visual*                visual = NULL;
 
-  /* System palette static colors */
+static PALETTEENTRY* COLOR_sysPal = NULL;    /* current system palette */
+static int COLOR_gapStart = 256;
+static int COLOR_gapEnd = -1;
 
-#define NB_RESERVED_COLORS  20
+  /* First free dynamic color cell, 0 = full palette, -1 = fixed palette */
+static int COLOR_firstFree = 0; 
 
-  /* The first and last eight colors are EGA colors */
-static const PALETTEENTRY COLOR_sysPaletteEntries[NB_RESERVED_COLORS] =
+  /* Maps entry in the system palette to X pixel value */
+int* COLOR_PaletteToPixel = NULL;
+
+  /* Maps pixel to the entry in the system palette */
+int* COLOR_PixelToPalette = NULL;
+
+static const PALETTEENTRY __sysPalTemplate[NB_RESERVED_COLORS] = 
 {
+    /* first 10 entries in the system palette */
     /* red  green blue  flags */
-    { 0x00, 0x00, 0x00, 0 },
-    { 0x80, 0x00, 0x00, 0 },
-    { 0x00, 0x80, 0x00, 0 },
-    { 0x80, 0x80, 0x00, 0 },
-    { 0x00, 0x00, 0x80, 0 },
-    { 0x80, 0x00, 0x80, 0 },
-    { 0x00, 0x80, 0x80, 0 },
-    { 0xc0, 0xc0, 0xc0, 0 },
-    { 0xc0, 0xdc, 0xc0, 0 },
-    { 0xa6, 0xca, 0xf0, 0 },
-
-    { 0xff, 0xfb, 0xf0, 0 },
-    { 0xa0, 0xa0, 0xa4, 0 },
-    { 0x80, 0x80, 0x80, 0 },
-    { 0xff, 0x00, 0x00, 0 },
-    { 0x00, 0xff, 0x00, 0 },
-    { 0xff, 0xff, 0x00, 0 },
-    { 0x00, 0x00, 0xff, 0 },
-    { 0xff, 0x00, 0xff, 0 },
-    { 0x00, 0xff, 0xff, 0 },
-    { 0xff, 0xff, 0xff, 0 }
+    { 0x00, 0x00, 0x00, PC_SYS_USED },
+    { 0x80, 0x00, 0x00, PC_SYS_USED },
+    { 0x00, 0x80, 0x00, PC_SYS_USED },
+    { 0x80, 0x80, 0x00, PC_SYS_USED },
+    { 0x00, 0x00, 0x80, PC_SYS_USED },
+    { 0x80, 0x00, 0x80, PC_SYS_USED },
+    { 0x00, 0x80, 0x80, PC_SYS_USED },
+    { 0xc0, 0xc0, 0xc0, PC_SYS_USED },
+    { 0xc0, 0xdc, 0xc0, PC_SYS_USED },
+    { 0xa6, 0xca, 0xf0, PC_SYS_USED },
+
+    /* ... c_min/2 dynamic colorcells */
+
+    /* ... gap (for sparse palettes) */
+
+    /* ... c_min/2 dynamic colorcells */
+
+    { 0xff, 0xfb, 0xf0, PC_SYS_USED },
+    { 0xa0, 0xa0, 0xa4, PC_SYS_USED },
+    { 0x80, 0x80, 0x80, PC_SYS_USED },
+    { 0xff, 0x00, 0x00, PC_SYS_USED },
+    { 0x00, 0xff, 0x00, PC_SYS_USED },
+    { 0xff, 0xff, 0x00, PC_SYS_USED },
+    { 0x00, 0x00, 0xff, PC_SYS_USED },
+    { 0xff, 0x00, 0xff, PC_SYS_USED },
+    { 0x00, 0xff, 0xff, PC_SYS_USED },
+    { 0xff, 0xff, 0xff, PC_SYS_USED }     /* last 10 */
 };
 
-static HANDLE hSysColorTranslation = 0;
-static HANDLE hRevSysColorTranslation = 0;
+   /* Map an EGA index (0..15) to a pixel value in the system color space.  */
 
-   /* Map an EGA index (0..15) to a pixel value. Used for dithering. */
 int COLOR_mapEGAPixel[16];
 
-int* COLOR_PaletteToPixel = NULL;
-int* COLOR_PixelToPalette = NULL;
-int COLOR_ColormapSize = 0;
+/***********************************************************************
+ *     Misc auxiliary functions
+ */
+Colormap COLOR_GetColormap(void)
+{
+    return cSpace.colorMap;
+}
+
+UINT16 COLOR_GetSystemPaletteSize(void)
+{
+    return (cSpace.flags & COLOR_PRIVATE) ? cSpace.size : 256;
+}
+
+UINT16 COLOR_GetSystemPaletteFlags(void)
+{
+    return cSpace.flags;
+}
+
+void COLOR_FormatSystemPalette(void)
+{
+    int i, j = COLOR_firstFree = NB_RESERVED_COLORS/2;
+
+    COLOR_sysPal[j].peFlags = 0;
+    for( i = NB_RESERVED_COLORS/2 + 1 ; i < 256 - NB_RESERVED_COLORS/2 ; i++ )
+        if( i < COLOR_gapStart || i > COLOR_gapEnd )
+        {
+            COLOR_sysPal[i].peFlags = 0;       /* unused tag */
+            COLOR_sysPal[j].peRed = i;         /* next */
+            j = i;
+        }
+    COLOR_sysPal[j].peRed = 0;          /* terminal */
+}
+
 
 /***********************************************************************
- *           COLOR_BuildMap
+ *           COLOR_BuildPrivateMap/COLOR_BuildSharedMap
  *
- * Fill the private colormap.
+ * Executed only one time so we don't care about sloppiness,
+ * the rest have to be very tight though...
  */
-static BOOL COLOR_BuildMap( Colormap map, int depth, int size )
+static BOOL COLOR_BuildPrivateMap(CSPACE* cs)
 {
+    /* Private colormap - identity mapping */
+
     XColor color;
-    int r, g, b, red_incr, green_incr, blue_incr;
-    int index = 0;
+    int i; 
 
-      /* Fill the whole map with a range of colors */
+    COLOR_sysPal = (PALETTEENTRY*)xmalloc(sizeof(PALETTEENTRY)*cs->size);
 
-    blue_incr  = 0x10000 >> (depth / 3);
-    red_incr   = 0x10000 >> ((depth + 1) / 3);
-    green_incr = 0x10000 >> ((depth + 2) / 3);
+    dprintf_palette(stddeb,"\tbuilding private map - %i palette entries\n", cs->size);
 
-    for (r = red_incr - 1; r < 0x10000; r += red_incr)
-       for (g = green_incr - 1; g < 0x10000; g += green_incr)
-           for (b = blue_incr - 1; b < 0x10000; b += blue_incr)
+      /* Allocate system palette colors */ 
+
+    for( i=0; i < cs->size; i++ )
+    {
+       if( i < NB_RESERVED_COLORS/2 )
+       {
+         color.red   = __sysPalTemplate[i].peRed * 65535 / 255;
+         color.green = __sysPalTemplate[i].peGreen * 65535 / 255;
+         color.blue  = __sysPalTemplate[i].peBlue * 65535 / 255;
+        COLOR_sysPal[i] = __sysPalTemplate[i];
+       }
+       else if( i >= cs->size - NB_RESERVED_COLORS/2 )
+       {
+        int j = NB_RESERVED_COLORS + i - cs->size;
+         color.red   = __sysPalTemplate[j].peRed * 65535 / 255;
+         color.green = __sysPalTemplate[j].peGreen * 65535 / 255;
+         color.blue  = __sysPalTemplate[j].peBlue * 65535 / 255;
+        COLOR_sysPal[i] = __sysPalTemplate[j];
+       }
+
+       color.flags = DoRed | DoGreen | DoBlue;
+       color.pixel = i;
+       XStoreColor(display, cs->colorMap, &color);
+
+       /* Set EGA mapping if color in the first or last eight */
+
+       if (i < 8)
+           COLOR_mapEGAPixel[i] = color.pixel;
+       else if (i >= cs->size - 8 )
+           COLOR_mapEGAPixel[i - (cs->size - 16)] = color.pixel;
+    }
+
+    COLOR_PixelToPalette = COLOR_PaletteToPixel = NULL;
+
+    COLOR_gapStart = 256; COLOR_gapEnd = -1;
+
+    COLOR_firstFree = (cs->size > NB_RESERVED_COLORS)?NB_RESERVED_COLORS/2 : -1;
+    return FALSE;
+}
+
+static BOOL COLOR_BuildSharedMap(CSPACE* cs)
+{
+   XColor              color;
+   unsigned long        sysPixel[NB_RESERVED_COLORS];
+   unsigned long*      pixDynMapping = NULL;
+   unsigned long       plane_masks[1];
+   int                 i, j;
+   int                 color_ini_max = 256;
+
+   /* read "AllocSystemColors" from wine.conf */
+
+   color_ini_max = PROFILE_GetWineIniInt( "options", "AllocSystemColors", 256);
+   if (color_ini_max > 256) color_ini_max = 256;
+   if (color_ini_max < 20) color_ini_max = 20;
+   dprintf_palette(stddeb,"COLOR_Init: %d colors configured.\n",color_ini_max);
+   
+   dprintf_palette(stddeb,"\tbuilding shared map - %i palette entries\n", cs->size);
+
+   /* Be nice and allocate system colors as read-only */
+
+   for( i = 0; i < NB_RESERVED_COLORS; i++ )
+     { 
+        color.red   = __sysPalTemplate[i].peRed * 65535 / 255;
+        color.green = __sysPalTemplate[i].peGreen * 65535 / 255;
+        color.blue  = __sysPalTemplate[i].peBlue * 65535 / 255;
+        color.flags = DoRed | DoGreen | DoBlue;
+
+        if (!XAllocColor( display, cSpace.colorMap, &color ))
+           { 
+             fprintf(stderr, "Warning: Not enough free colors for system palette.\n" );
+             color.pixel = color.red = color.green = color.blue = 0;
+           }
+
+        sysPixel[i] = color.pixel;
+
+        dprintf_palette(stddeb,"\tsyscolor(%lx) -> pixel %i\n",
+                     *(COLORREF*)(__sysPalTemplate+i), (int)color.pixel);
+
+        /* Set EGA mapping if color in the first or last eight */
+
+        if (i < 8)
+            COLOR_mapEGAPixel[i] = color.pixel;
+        else if (i >= NB_RESERVED_COLORS - 8 )
+            COLOR_mapEGAPixel[i - (NB_RESERVED_COLORS-16)] = color.pixel;
+     }
+
+   if( !(cSpace.flags & COLOR_FIXED) )  
+     {
+       int c_min = 0, c_max = cs->size, c_val;
+
+       dprintf_palette(stddeb,"\tdynamic colormap... ");
+
+       /* comment this out if you want to debug palette init */
+
+       XGrabServer(display);
+
+       /* let's become the first client that actually follows 
+        * X guidelines and does binary search...
+        */
+
+       pixDynMapping = (unsigned long*)xmalloc(sizeof(long)*cs->size);
+        while( c_max - c_min > 0 )
+          {
+             c_val = (c_max + c_min)/2 + (c_max + c_min)%2;
+
+             if( !XAllocColorCells(display, cs->colorMap, False,
+                                   plane_masks, 0, pixDynMapping, c_val) )
+                 c_max = c_val - 1;
+             else
+               {
+                 XFreeColors(display, cs->colorMap, pixDynMapping, c_val, 0);
+                 c_min = c_val;
+               }
+          }
+
+       if( c_min > color_ini_max - NB_RESERVED_COLORS) 
+           c_min = color_ini_max - NB_RESERVED_COLORS;
+
+       c_min = (c_min/2) + (c_min/2);          /* need even set for split palette */
+
+       if( c_min > 0 )
+         if( !XAllocColorCells(display, cs->colorMap, False,
+                                plane_masks, 0, pixDynMapping, c_min) )
            {
-               if (index >= size) break;
-               color.pixel = index++;
-               color.red   = r;
-               color.green = g;
-               color.blue  = b;
-               XStoreColor( display, map, &color );
+             fprintf(stderr,"Inexplicable failure during colorcell allocation.\n");
+             c_min = 0;
            }
 
-    return TRUE;
+        cs->size = c_min + NB_RESERVED_COLORS;
+
+       COLOR_gapStart = cs->size/2;
+       COLOR_gapEnd = 256 - cs->size/2;
+
+       XUngrabServer(display);
+
+       dprintf_palette(stddeb,"adjusted size %i colorcells\n", cs->size);
+     }
+   else if( cSpace.flags & COLOR_VIRTUAL ) 
+       {
+          /* virtual colorspace - ToPhysical takes care of 
+           * color translations but we have to allocate full palette 
+          * to maintain compatibility
+          */
+         dprintf_palette(stddeb,"\tvirtual colorspace - screendepth %i\n", screenDepth);
+       }
+   else cs->size = NB_RESERVED_COLORS; /* system palette only - however we can alloc a bunch
+                                        * of colors and map to them */
+
+   dprintf_palette(stddeb,"Shared system palette uses %i colors.\n", cs->size);
+
+   /* Set gap to account for pixel shortage. It has to be right in the center
+    * of the system palette because otherwise raster ops get screwed.
+    * ( if we have 100 color palette and application does invert for pixel 1
+    *   it gets pixel 254 - far beyond our pathetic palette unless these 100
+    *   colors are mapped with the gap in the middle )
+    */
+
+   if( cs->size >= 256 )
+     { COLOR_gapStart = 256; COLOR_gapEnd = -1; }
+   else
+     { COLOR_gapStart = cs->size/2; COLOR_gapEnd = 255 - cs->size/2; }
+
+   COLOR_firstFree = ( cs->size > NB_RESERVED_COLORS && 
+                     (cs->flags & COLOR_VIRTUAL || !(cs->flags & COLOR_FIXED)) ) 
+                    ? NB_RESERVED_COLORS/2 : -1;
+
+   COLOR_sysPal = (PALETTEENTRY*)xmalloc(sizeof(PALETTEENTRY)*256);
+
+   /* Setup system palette entry <-> pixel mappings and fill in 20 fixed entries */
+
+   if( screenDepth <= 8 )
+   {
+       COLOR_PixelToPalette = (int*)xmalloc(sizeof(int)*256);
+       COLOR_PaletteToPixel = (int*)xmalloc(sizeof(int)*256);
+
+       for( i = j = 0; i < 256; i++ )
+       {
+           if( i >= COLOR_gapStart && i <= COLOR_gapEnd ) 
+           {
+               COLOR_PaletteToPixel[i] = 0;
+               COLOR_sysPal[i].peFlags = 0;    /* mark as unused */
+               continue;
+           }
+
+           if( i < NB_RESERVED_COLORS/2 )
+           {
+               COLOR_PaletteToPixel[i] = sysPixel[i];
+               COLOR_sysPal[i] = __sysPalTemplate[i];
+           }
+           else if( i >= 256 - NB_RESERVED_COLORS/2 )
+           {
+               COLOR_PaletteToPixel[i] = sysPixel[(i + NB_RESERVED_COLORS) - 256]; 
+               COLOR_sysPal[i] = __sysPalTemplate[(i + NB_RESERVED_COLORS) - 256];
+           }
+           else if( pixDynMapping )
+               COLOR_PaletteToPixel[i] = pixDynMapping[j++];
+           else
+               COLOR_PaletteToPixel[i] = i;
+
+           dprintf_palette(stddeb,"\tindex %i -> pixel %i\n", i, COLOR_PaletteToPixel[i]);
+
+           memset( COLOR_PixelToPalette, 0, 256*sizeof(int) );
+           COLOR_PixelToPalette[COLOR_PaletteToPixel[i]] = i;
+       }
+   }
+   if( pixDynMapping ) free(pixDynMapping);
+   return TRUE;
 }
 
 
 /***********************************************************************
  *           COLOR_InitPalette
  *
- * Create the system palette.
+ * Create the system palette and initialize mapping tables.
  */
 static HPALETTE16 COLOR_InitPalette(void)
 {
-    int i, size, pixel;
-    XColor color;
-    HPALETTE16 hpalette;
-    LOGPALETTE * palPtr;
-    WORD *colorTranslation, *revTranslation;
+    int                i;
+    HPALETTE16                 hpalette;
+    LOGPALETTE *       palPtr;
 
-    size = DefaultVisual( display, DefaultScreen(display) )->map_entries;
-    COLOR_ColormapSize = size;
-    if (screenDepth <= 8)
-    {
-        if (!(hSysColorTranslation = GDI_HEAP_ALLOC(sizeof(WORD)*NB_RESERVED_COLORS )))
-            return FALSE;
-        if (!(hRevSysColorTranslation = GDI_HEAP_ALLOC( sizeof(WORD)*size )))
-            return FALSE;
-        colorTranslation = (WORD *) GDI_HEAP_LIN_ADDR( hSysColorTranslation );
-        revTranslation   = (WORD *) GDI_HEAP_LIN_ADDR( hRevSysColorTranslation );
-    }
-    else colorTranslation = revTranslation = NULL;
+    /* calculate max palette size */
 
-    if ((COLOR_WinColormap == DefaultColormapOfScreen(screen)) && (screenDepth <= 8))
-    {
-        COLOR_PaletteToPixel = (int *)xmalloc( sizeof(int) * size );
-        COLOR_PixelToPalette = (int *)xmalloc( sizeof(int) * size );
-        for (i = 0; i < size; i++)  /* Set the default mapping */
-            COLOR_PaletteToPixel[i] = COLOR_PixelToPalette[i] = i;
-    }
+    cSpace.size = visual->map_entries;
 
-    for (i = 0; i < NB_RESERVED_COLORS; i++)
-    {
-       color.red   = COLOR_sysPaletteEntries[i].peRed * 65535 / 255;
-       color.green = COLOR_sysPaletteEntries[i].peGreen * 65535 / 255;
-       color.blue  = COLOR_sysPaletteEntries[i].peBlue * 65535 / 255;
-       color.flags = DoRed | DoGreen | DoBlue;
+    if (cSpace.flags & COLOR_PRIVATE)
+       COLOR_BuildPrivateMap( &cSpace );
+    else
+       COLOR_BuildSharedMap( &cSpace );
 
-        if (i < NB_RESERVED_COLORS/2)
-        {
-            /* Bottom half of the colormap */
-            pixel = i;
-            if (pixel >= size/2) continue;
-        }
-        else
-        {
-            /* Top half of the colormap */
-            pixel = size - NB_RESERVED_COLORS + i;
-            if (pixel < size/2) continue;
-        }
-       if (COLOR_WinColormap != DefaultColormapOfScreen(screen))
-       {
-            color.pixel = pixel;
-           XStoreColor( display, COLOR_WinColormap, &color );
-       }
-       else
-        {
-            if (!XAllocColor( display, COLOR_WinColormap, &color ))
-            {
-                fprintf(stderr, "Warning: Not enough free colors. Try using the -privatemap option.\n" );
-                color.pixel = color.red = color.green = color.blue = 0;
-            }
-            else if (COLOR_PaletteToPixel)
-            {
-                COLOR_PaletteToPixel[pixel] = color.pixel;
-                COLOR_PixelToPalette[color.pixel] = pixel;
-            }
-        }
-        if (colorTranslation) colorTranslation[i] = color.pixel;
-        if (revTranslation) revTranslation[color.pixel] = i;
-         /* Set EGA mapping if color in the first or last eight */
-       if (i < 8)
-           COLOR_mapEGAPixel[i] = color.pixel;
-       else if (i >= NB_RESERVED_COLORS-8)
-           COLOR_mapEGAPixel[i - (NB_RESERVED_COLORS-16)] = color.pixel;
-    }
+    /* Build free list ( use peRed as "next" ) */
+
+    if( COLOR_firstFree != -1 )
+       COLOR_FormatSystemPalette();
 
-    palPtr = malloc( sizeof(LOGPALETTE) + (NB_RESERVED_COLORS-1)*sizeof(PALETTEENTRY) );
+    /* create default palette (20 system colors) */
+
+    palPtr = xmalloc( sizeof(LOGPALETTE) + (NB_RESERVED_COLORS-1)*sizeof(PALETTEENTRY) );
     if (!palPtr) return FALSE;
+
     palPtr->palVersion = 0x300;
     palPtr->palNumEntries = NB_RESERVED_COLORS;
-    memcpy( palPtr->palPalEntry, COLOR_sysPaletteEntries,
-           sizeof(COLOR_sysPaletteEntries) );
+    for( i = 0; i < NB_RESERVED_COLORS; i ++ )
+    {
+        palPtr->palPalEntry[i].peRed = __sysPalTemplate[i].peRed;
+        palPtr->palPalEntry[i].peGreen = __sysPalTemplate[i].peGreen;
+        palPtr->palPalEntry[i].peBlue = __sysPalTemplate[i].peBlue;
+        palPtr->palPalEntry[i].peFlags = 0;  
+    }
     hpalette = CreatePalette( palPtr );
     free( palPtr );
     return hpalette;
 }
 
-void
-COLOR_Computeshifts(unsigned long maskbits, int *shift, int *max)
+
+/***********************************************************************
+ *          COLOR_Computeshifts
+ *
+ * Calculate conversion parameters for direct mapped visuals
+ */
+void COLOR_Computeshifts(unsigned long maskbits, int *shift, int *max)
 {
     int i;
 
-    if(maskbits==0) {
+    if (maskbits==0)
+    {
         *shift=0;
         *max=0;
         return;
@@ -210,55 +445,65 @@ COLOR_Computeshifts(unsigned long maskbits, int *shift, int *max)
     *max = maskbits;
 }
 
+
 /***********************************************************************
  *           COLOR_Init
  *
  * Initialize color map and system palette.
+ *
  */
 HPALETTE16 COLOR_Init(void)
 {
-    Visual * visual = DefaultVisual( display, DefaultScreen(display) );
+    visual = DefaultVisual( display, DefaultScreen(display) );
+
+    dprintf_palette(stddeb,"COLOR_Init: initializing palette manager...");
 
     switch(visual->class)
     {
+    case DirectColor:
+       cSpace.flags |= COLOR_VIRTUAL;
     case GrayScale:
     case PseudoColor:
-    case DirectColor:
-        COLOR_FixedMap = 0;
        if (Options.usePrivateMap)
        {
-           COLOR_WinColormap = XCreateColormap( display, rootWindow,
+           XSetWindowAttributes win_attr;
+
+           cSpace.flags |= COLOR_PRIVATE;
+           cSpace.colorMap = XCreateColormap( display, rootWindow,
                                                 visual, AllocAll );
-           if (COLOR_WinColormap)
+           if (cSpace.colorMap)
            {
-               COLOR_BuildMap( COLOR_WinColormap, screenDepth,
-                               visual->map_entries );
-               if (rootWindow != DefaultRootWindow(display))
-               {
-                   XSetWindowAttributes win_attr;
-                   win_attr.colormap = COLOR_WinColormap;
+              if( rootWindow != DefaultRootWindow(display) )
+                {
+                   win_attr.colormap = cSpace.colorMap;
                    XChangeWindowAttributes( display, rootWindow,
-                                            CWColormap, &win_attr );
-               }
-               break;
+                                        CWColormap, &win_attr );
+                }
+              break;
            }
        }
-       COLOR_WinColormap = DefaultColormapOfScreen( screen );
+       cSpace.colorMap = DefaultColormapOfScreen( screen );
         break;
+
     case StaticGray:
-       COLOR_WinColormap = DefaultColormapOfScreen( screen );
-       COLOR_FixedMap = 1;
+       cSpace.colorMap = DefaultColormapOfScreen( screen );
+       cSpace.flags |= COLOR_FIXED;
         COLOR_Graymax = (1<<screenDepth)-1;
         break;
-    case StaticColor:
+
     case TrueColor:
-       COLOR_WinColormap = DefaultColormapOfScreen( screen );
-       COLOR_FixedMap = 1;
+       cSpace.flags |= COLOR_VIRTUAL;
+    case StaticColor:
+        cSpace.colorMap = DefaultColormapOfScreen( screen );
+        cSpace.flags |= COLOR_FIXED;
         COLOR_Computeshifts(visual->red_mask, &COLOR_Redshift, &COLOR_Redmax);
         COLOR_Computeshifts(visual->green_mask, &COLOR_Greenshift, &COLOR_Greenmax);
         COLOR_Computeshifts(visual->blue_mask, &COLOR_Blueshift, &COLOR_Bluemax);
        break;  
     }
+
+    dprintf_palette(stddeb," visual class %i\n", visual->class);
+
     return COLOR_InitPalette();
 }
 
@@ -271,12 +516,15 @@ HPALETTE16 COLOR_Init(void)
 BOOL COLOR_IsSolid( COLORREF color )
 {
     int i;
-    const PALETTEENTRY *pEntry = COLOR_sysPaletteEntries;
+    const PALETTEENTRY *pEntry = COLOR_sysPal;
+
+    if (color & 0xff000000) return TRUE;               /* indexed color */
 
-    if (color & 0xff000000) return TRUE;
-    if (!color || (color == 0xffffff)) return TRUE;
-    for (i = NB_RESERVED_COLORS; i > 0; i--, pEntry++)
+    if (!color || (color == 0xffffff)) return TRUE;    /* black or white */
+
+    for (i = 0; i < 256 ; i++, pEntry++)
     {
+      if( i < COLOR_gapStart || i > COLOR_gapEnd )
        if ((GetRValue(color) == pEntry->peRed) &&
            (GetGValue(color) == pEntry->peGreen) &&
            (GetBValue(color) == pEntry->peBlue)) return TRUE;
@@ -286,72 +534,147 @@ BOOL COLOR_IsSolid( COLORREF color )
 
 
 /***********************************************************************
- *           COLOR_ToPhysical
+ *          COLOR_PaletteLookup
  *
- * Return the physical color closest to 'color'.
+ */
+int COLOR_PaletteLookupPixel( PALETTEENTRY* palPalEntry, int size,
+                              int* mapping, COLORREF col, BOOL skipReserved )
+{
+    int i, best = 0, diff = 0x7fffffff;
+    int r,g,b;
+
+    for( i = 0; i < size; i++ )
+    {
+        if( !(palPalEntry[i].peFlags & PC_SYS_USED) ||
+            (skipReserved && palPalEntry[i].peFlags  & PC_SYS_RESERVED) )
+            continue;
+
+        r = palPalEntry[i].peRed - GetRValue(col);
+        g = palPalEntry[i].peGreen - GetGValue(col);
+        b = palPalEntry[i].peBlue - GetBValue(col);
+
+        r = r*r + g*g + b*b;
+
+        if( r < diff ) { best = i; diff = r; }
+    }
+    return (mapping) ? mapping[best] : best;
+}
+
+
+/***********************************************************************
+ *          COLOR_PaletteLookupExactIndex
  *
- * ESW: This still needs a lot of work; in particular, what happens when
- * we have really large (> 8 bit) DirectColor boards?
- * But it should work better in 16 and 24 bit modes now.
- * (At least it pays attention to the X server's description
- * in TrueColor mode, instead of blindly passing through the
- * color spec and swapping red to blue or losing blue and part of the
- * green entirely, depending on what mode one is in!)
+ */
+int COLOR_PaletteLookupExactIndex( PALETTEENTRY* palPalEntry, int size,
+                                   COLORREF col )
+{
+    int i;
+    BYTE r = GetRValue(col), g = GetGValue(col), b = GetBValue(col);
+    for( i = 0; i < size; i++ )
+    {
+        if( palPalEntry[i].peFlags & PC_SYS_USED )     /* skip gap */
+            if( palPalEntry[i].peRed == r &&
+                palPalEntry[i].peGreen == g &&
+                palPalEntry[i].peBlue == b )
+                return i;
+    }
+    return -1;
+}
+
+
+/***********************************************************************
+ *           COLOR_ToLogical
  *
+ * Return RGB color for given X pixel.
+ */
+COLORREF COLOR_ToLogical(int pixel)
+{
+    XColor color;
+  
+    if (screenDepth > 8) return pixel;
+    if ((screenDepth <= 8) && (pixel < 256) && !(cSpace.flags & COLOR_VIRTUAL))
+        return  ( *(COLORREF*)(COLOR_sysPal + ((COLOR_PixelToPalette)?COLOR_PixelToPalette[pixel]:pixel)) ) & 0x00ffffff;
+
+    color.pixel = pixel;
+    XQueryColor(display, cSpace.colorMap, &color);
+
+    return RGB((color.red * 255)/COLOR_Redmax,
+               (color.green * 255)/COLOR_Greenmax,
+               (color.blue * 255)/COLOR_Bluemax);
+}
+
+
+/***********************************************************************
+ *           COLOR_ToPhysical
+ *
+ * Return the physical color closest to 'color'.
  */
 int COLOR_ToPhysical( DC *dc, COLORREF color )
 {
-    WORD index = 0;
-    WORD *mapping;
-    unsigned char      spec_type;
+    WORD                index = 0;
+    unsigned char       spec_type;
+    HPALETTE16          hPal = (dc)? dc->w.hPalette: STOCK_DEFAULT_PALETTE;
 
     spec_type = color >> 24;
-    if (spec_type == 0xff)
-       {
+
+    if( spec_type == 0xff )
+    {
        spec_type = 0; /* 'write' seems to need that for 'Page 1' text */
        color &= 0xffffff;
-       }
-    if (spec_type > 2)
-       fprintf(stderr, "COLOR_ToPhysical : color >> 24 not in {-1,0,1,2} : %08lx\n",
-           color);
+    }
+
+    if( spec_type > 2 )
+    {  
+       fprintf(stderr, "COLOR_ToPhysical : invalid RGB specifier for: %08lx\n", color);
+       spec_type = 0;
+    }
+
     if (dc && (dc->w.bitsPerPixel == 1) && (spec_type == 0))
     {
        /* monochrome */
         if (((color >> 16) & 0xff) +
             ((color >> 8) & 0xff) + (color & 0xff) > 255*3/2)
-            return 1;  /* white */
-        else return 0;  /* black */
+             return 1;   /* white */
+        else return 0;   /* black */
     }
 
-    if (COLOR_FixedMap)
+    if ( cSpace.flags & COLOR_FIXED )
     {
-        /* there is no colormap possible; we are going to have to compute
-           the pixel value from the visual information stored earlier */
+        /* there is no colormap limitation; we are going to have to compute
+         * the pixel value from the visual information stored earlier 
+        */
 
-       unsigned long red, green, blue;
-       unsigned idx;
-       PALETTEOBJ * palPtr;
+       unsigned        long red, green, blue;
+       unsigned        idx = 0;
+       PALETTEOBJ *    palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hPal, PALETTE_MAGIC );
 
        switch(spec_type)
         {
-        case 0: /* RGB */
-        case 2: /* PALETTERGB -- needs some work, but why bother; we've got a REALLY LARGE number of colors...? */
-        default:
+         default: 
+          case 0: /* RGB */
+
             red = GetRValue(color);
             green = GetGValue(color);
             blue = GetBValue(color);
             break;
 
-        case 1: /* PALETTEIDX -- hmm, get the real color from the stock palette */
-            palPtr = (PALETTEOBJ *) GDI_GetObjPtr( STOCK_DEFAULT_PALETTE, PALETTE_MAGIC);
-            idx = color & 0xffff;
+          case 2: /* PALETTERGB - not sure if we really need to search palette */
+       
+           idx = COLOR_PaletteLookupPixel( palPtr->logpalette.palPalEntry,
+                                           palPtr->logpalette.palNumEntries,
+                                           NULL, color, FALSE);
+          case 1: /* PALETTEINDEX */
+
+            idx = ((spec_type == 1)?color:idx) & 0xffff;
+
             if (idx >= palPtr->logpalette.palNumEntries)
             {
-                fprintf(stderr, "COLOR_ToPhysical(%lx) : idx %d is out of bounds, assuming black\n", color, idx);
+                fprintf(stderr, "\tRGB(%lx) : idx %d is out of bounds, assuming black\n", color, idx);
                 /* out of bounds */
                 red = green = blue = 0;
             }
-            else
+            else if( palPtr->mapping ) return palPtr->mapping[idx];
+           else
             {
                 red = palPtr->logpalette.palPalEntry[idx].peRed;
                 green = palPtr->logpalette.palPalEntry[idx].peGreen;
@@ -374,88 +697,139 @@ int COLOR_ToPhysical( DC *dc, COLORREF color )
            return (red << COLOR_Redshift) | (green << COLOR_Greenshift) | (blue << COLOR_Blueshift);
         }
     }
-    else switch(spec_type)
-    {
-    default:
-    case 0:  /* RGB */
-       index = GetNearestPaletteIndex( STOCK_DEFAULT_PALETTE, color );
-       break;
-    case 1:  /* PALETTEINDEX */
-       index = color & 0xffff;
-       break;
-    case 2:  /* PALETTERGB */
-       if (dc) index = GetNearestPaletteIndex( dc->w.hPalette, color );
-        else index = 0;
-       break;
-    }
-    if (dc&&dc->u.x.pal.mappingSize)
-    {
-        if (index >= dc->u.x.pal.mappingSize)
-        {
-            fprintf(stderr, "COLOR_ToPhysical(%lx) : idx %d is >= dc->u.x.pal.mappingSize, assuming pixel 0\n", color, index);
-            return 0;
-        }
-        mapping = (WORD *) GDI_HEAP_LIN_ADDR( dc->u.x.pal.hMapping );
-    }
-    else
+    else 
     {
-        if (index >= NB_RESERVED_COLORS)
-        {
-            fprintf(stderr, "COLOR_ToPhysical(%lx) : idx %d is >= NB_RESERVED_COLORS, assuming pixel 0\n", color, index);
-           return 0;
-        }
-        mapping = (WORD *) GDI_HEAP_LIN_ADDR( hSysColorTranslation );
+       PALETTEOBJ* palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hPal, PALETTE_MAGIC);
+
+       /* palPtr can be NULL when DC is being destroyed */
+
+       if( !palPtr ) return 0;
+       else if( !palPtr->mapping ) 
+            dprintf_palette(stddeb,"\tpalette %04x is not realized\n", dc->w.hPalette);
+
+       switch(spec_type)       /* we have to peruse DC and system palette */
+       {
+           default:
+                   case 0:  /* RGB */
+               index = COLOR_PaletteLookupPixel( COLOR_sysPal, 256, 
+                                                 COLOR_PaletteToPixel, color, FALSE);
+
+               /* dprintf_palette(stddeb,"\tRGB(%lx) -> pixel %i\n", color, index);
+                */
+               break;
+                   case 1:  /* PALETTEINDEX */
+               index = color & 0xffff;
+
+               if( index >= palPtr->logpalette.palNumEntries )
+                   fprintf(stderr, "\tRGB(%lx) : index %i is out of bounds\n", color, index); 
+               else if( palPtr->mapping ) index = palPtr->mapping[index];
+
+               /*  dprintf_palette(stddeb,"\tPALETTEINDEX(%04x) -> pixel %i\n", (WORD)color, index);
+                */
+               break;
+            case 2:  /* PALETTERGB */
+               index = COLOR_PaletteLookupPixel( palPtr->logpalette.palPalEntry, 
+                                             palPtr->logpalette.palNumEntries,
+                                             palPtr->mapping, color, FALSE);
+               /* dprintf_palette(stddeb,"\tPALETTERGB(%lx) -> pixel %i\n", color, index);
+                */
+               break;
+       }
     }
-    if (mapping) return mapping[index];
-    else return index;  /* Identity mapping */
+
+    return index;
 }
 
 
 /***********************************************************************
  *           COLOR_SetMapping
  *
- * Set the color-mapping table in a DC.
+ * Set the color-mapping table for selected palette. 
+ * Return number of entries which mapping has changed.
  */
-void COLOR_SetMapping( DC *dc, HANDLE map, HANDLE revMap, WORD size )
+int COLOR_SetMapping( PALETTEOBJ* palPtr, BOOL mapOnly )
 {
-    WORD *pmap, *pnewmap;
-    WORD i;
-
-    if (dc->u.x.pal.hMapping && (dc->u.x.pal.hMapping != hSysColorTranslation))
-       GDI_HEAP_FREE( dc->u.x.pal.hMapping );
-    if (dc->u.x.pal.hRevMapping &&
-        (dc->u.x.pal.hRevMapping != hRevSysColorTranslation))
-       GDI_HEAP_FREE( dc->u.x.pal.hRevMapping );
-    if (map && (map != hSysColorTranslation))
-    {
-         /* Copy mapping table */
-       dc->u.x.pal.hMapping = GDI_HEAP_ALLOC( sizeof(WORD) * size );
-       pmap = (WORD *) GDI_HEAP_LIN_ADDR( map );
-       pnewmap = (WORD *) GDI_HEAP_LIN_ADDR( dc->u.x.pal.hMapping );
-       memcpy( pnewmap, pmap, sizeof(WORD)*size );
-          /* Build reverse table */
-        dc->u.x.pal.hRevMapping = GDI_HEAP_ALLOC(sizeof(WORD)*COLOR_ColormapSize);
-        pmap = (WORD *) GDI_HEAP_LIN_ADDR( dc->u.x.pal.hRevMapping );
-        for (i = 0; i < size; i++) pmap[pnewmap[i]] = i;
-    }
-    else
+    int  i, index;
+    char flag;
+    int  prevMapping = (palPtr->mapping) ? 1 : 0;
+    int  iRemapped = 0;
+
+    /* free dynamic colors in system palette - 
+     * certain optimization is to free them only when they are needed */
+
+    if( !mapOnly && COLOR_firstFree != -1)
+        COLOR_FormatSystemPalette();
+
+    /* initialize palette mapping table */
+    palPtr->mapping = (int*)xrealloc(palPtr->mapping, sizeof(int)*
+                                     palPtr->logpalette.palNumEntries);
+
+    for( i = 0; i < palPtr->logpalette.palNumEntries; i++ )
     {
-        dc->u.x.pal.hMapping = map;
-        dc->u.x.pal.hRevMapping = map ? hRevSysColorTranslation : 0;
-    }
-    dc->u.x.pal.mappingSize = size;
-}
+        index = -1;
+        flag = PC_SYS_USED;
 
+        switch( palPtr->logpalette.palPalEntry[i].peFlags & 0x07 )
+        {
+       case PC_EXPLICIT:   /* palette entries are indices into system palette */
+            index = *(WORD*)(palPtr->logpalette.palPalEntry + i);
+            if( index > 255 || (index >= COLOR_gapStart && index <= COLOR_gapEnd) ) 
+            {
+                fprintf(stderr,"PC_EXPLICIT: idx %d out of system palette, assuming black.\n", index); 
+                index = 0;
+            }
+            break;
 
-/***********************************************************************
- *           RealizeDefaultPalette    (GDI.365)
- */
-WORD RealizeDefaultPalette( HDC hdc )
-{
-    DC *dc;
-    if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
-    dc->w.hPalette = STOCK_DEFAULT_PALETTE;
-    COLOR_SetMapping( dc, hSysColorTranslation,
-                      hRevSysColorTranslation, NB_RESERVED_COLORS );
-    return NB_RESERVED_COLORS;
+       case PC_RESERVED:   /* forbid future mappings to this entry */
+            flag |= PC_SYS_RESERVED;
+            /* fall through */
+       default:            /* try to collapse identical colors */
+            index = COLOR_PaletteLookupExactIndex(COLOR_sysPal, 256,  
+                             *(COLORREF*)(palPtr->logpalette.palPalEntry + i));
+            /* fall through */
+       case PC_NOCOLLAPSE: 
+            if( index < 0 )
+            {
+                if( COLOR_firstFree > 0 && !(cSpace.flags & COLOR_FIXED) && !mapOnly )
+                {
+                    XColor color;
+                    index = COLOR_firstFree;  /* ought to be available */
+                    COLOR_firstFree = COLOR_sysPal[index].peRed;
+                    color.pixel = (COLOR_PaletteToPixel) ? COLOR_PaletteToPixel[index] : index;
+                    color.red = palPtr->logpalette.palPalEntry[i].peRed * 65535 / 255;
+                    color.green = palPtr->logpalette.palPalEntry[i].peGreen * 65535 / 255;
+                    color.blue = palPtr->logpalette.palPalEntry[i].peBlue * 65535 / 255;
+                    color.flags = DoRed | DoGreen | DoBlue;
+                    XStoreColor(display, cSpace.colorMap, &color);
+                    COLOR_sysPal[index] = palPtr->logpalette.palPalEntry[i];
+                    COLOR_sysPal[index].peFlags = flag;
+                    if( COLOR_PaletteToPixel ) index = COLOR_PaletteToPixel[index];
+                    break;
+                }
+                else if ( cSpace.flags & COLOR_VIRTUAL ) 
+                {
+                    index = COLOR_ToPhysical( NULL, 0x00ffffff &
+                             *(COLORREF*)(palPtr->logpalette.palPalEntry + i));
+                    break;     
+                }
+
+                /* we have to map to existing entry in the system palette */
+
+                index = COLOR_PaletteLookupPixel(COLOR_sysPal, 256, NULL, 
+                       *(COLORREF*)(palPtr->logpalette.palPalEntry + i), TRUE);
+            }
+
+            if( COLOR_PaletteToPixel ) index = COLOR_PaletteToPixel[index];
+            break;
+        }
+
+        if( !prevMapping || palPtr->mapping[i] != index ) iRemapped++;
+        palPtr->mapping[i] = index;
+
+        /* dprintf_palette(stddeb,"\tentry %i (%lx) -> pixel %i\n", i, 
+                               *(COLORREF*)(palPtr->logpalette.palPalEntry + i), index);
+       */
+    }
+    return iRemapped;
 }
index 3a003a15ef3de473b64d3350f7c258db730cc81b..c750d6143b66fa821f1bc8c94299f2c46118ab4b 100644 (file)
@@ -198,20 +198,20 @@ static CURSORDIRENTRY *CURSORICON_FindBestCursor( CURSORICONDIR *dir,
  * Load the icon/cursor directory for a given resource name and find the
  * best matching entry.
  */
-static BOOL CURSORICON_LoadDirEntry(HANDLE hInstance, SEGPTR name,
+static BOOL CURSORICON_LoadDirEntry(HINSTANCE32 hInstance, SEGPTR name,
                                     int width, int height, int colors,
                                     BOOL fCursor, CURSORICONDIRENTRY *dirEntry)
 {
-    HRSRC hRsrc;
-    HANDLE hMem;
+    HRSRC16 hRsrc;
+    HGLOBAL16 hMem;
     CURSORICONDIR *dir;
     CURSORICONDIRENTRY *entry = NULL;
 
-    if (!(hRsrc = FindResource( hInstance, name,
+    if (!(hRsrc = FindResource16( hInstance, name,
                                 fCursor ? RT_GROUP_CURSOR : RT_GROUP_ICON )))
         return FALSE;
-    if (!(hMem = LoadResource( hInstance, hRsrc ))) return FALSE;
-    if ((dir = (CURSORICONDIR *)LockResource( hMem )))
+    if (!(hMem = LoadResource16( hInstance, hRsrc ))) return FALSE;
+    if ((dir = (CURSORICONDIR *)LockResource16( hMem )))
     {
         if (fCursor)
             entry = (CURSORICONDIRENTRY *)CURSORICON_FindBestCursor( dir,
@@ -221,7 +221,7 @@ static BOOL CURSORICON_LoadDirEntry(HANDLE hInstance, SEGPTR name,
                                                        width, height, colors );
         if (entry) *dirEntry = *entry;
     }
-    FreeResource( hMem );
+    FreeResource16( hMem );
     return (entry != NULL);
 }
 
@@ -245,11 +245,11 @@ HANDLE CURSORICON_LoadHandler( HANDLE handle, HINSTANCE hInstance,
 
     if (fCursor)  /* If cursor, get the hotspot */
     {
-        POINT16 *pt = (POINT16 *)LockResource( handle );
+        POINT16 *pt = (POINT16 *)LockResource16( handle );
         hotspot = *pt;
         bmi = (BITMAPINFO *)(pt + 1);
     }
-    else bmi = (BITMAPINFO *)LockResource( handle );
+    else bmi = (BITMAPINFO *)LockResource16( handle );
 
     /* Create a copy of the bitmap header */
 
@@ -391,13 +391,13 @@ static HANDLE CURSORICON_Load( HANDLE hInstance, SEGPTR name, int width,
 
     /* Load the resource */
 
-    if (!(hRsrc = FindResource( hInstance,
+    if (!(hRsrc = FindResource16( hInstance,
                                 MAKEINTRESOURCE( dirEntry.icon.wResId ),
                                 fCursor ? RT_CURSOR : RT_ICON ))) return 0;
-    if (!(handle = LoadResource( hInstance, hRsrc ))) return 0;
+    if (!(handle = LoadResource16( hInstance, hRsrc ))) return 0;
 
     hRet = CURSORICON_LoadHandler( handle, hInstance, fCursor );
-    FreeResource(handle);
+    FreeResource16(handle);
     return hRet;
 }
 
@@ -463,13 +463,13 @@ HCURSOR CURSORICON_IconToCursor(HICON hIcon)
 /***********************************************************************
  *           LoadCursor    (USER.173)
  */
-HCURSOR LoadCursor( HANDLE hInstance, SEGPTR name )
+HCURSOR16 LoadCursor16( HINSTANCE16 hInstance, SEGPTR name )
 {
     if (HIWORD(name))
-        dprintf_cursor( stddeb, "LoadCursor: %04x '%s'\n",
+        dprintf_cursor( stddeb, "LoadCursor16: %04x '%s'\n",
                         hInstance, (char *)PTR_SEG_TO_LIN( name ) );
     else
-        dprintf_cursor( stddeb, "LoadCursor: %04x %04x\n",
+        dprintf_cursor( stddeb, "LoadCursor16: %04x %04x\n",
                         hInstance, LOWORD(name) );
 
     return CURSORICON_Load( hInstance, name,
@@ -480,7 +480,7 @@ HCURSOR LoadCursor( HANDLE hInstance, SEGPTR name )
 /***********************************************************************
  *           LoadIcon    (USER.174)
  */
-HICON LoadIcon( HANDLE hInstance, SEGPTR name )
+HICON16 LoadIcon16(HINSTANCE16 hInstance,SEGPTR name)
 {
     if (HIWORD(name))
         dprintf_icon( stddeb, "LoadIcon: %04x '%s'\n",
@@ -935,7 +935,7 @@ void GetClipCursor32( RECT32 *rect )
  */
 WORD GetIconID( HANDLE hResource, DWORD resType )
 {
-    CURSORICONDIR *lpDir = LockResource(hResource);
+    CURSORICONDIR *lpDir = LockResource16(hResource);
 
     if (!lpDir || lpDir->idReserved ||
         ((lpDir->idType != 1) && (lpDir->idType != 2)))
index d305001929b1a50f892d0efa1698dd5111747e97..5e3eff9ca05e1df03357b0f1dc36127b68f4d3df 100644 (file)
@@ -334,8 +334,8 @@ BOOL DC_SetupGCForText( DC * dc )
  */
 BOOL DC_CallHookProc(DC* dc, WORD code, LPARAM lParam)
 {
-  BOOL   bRet = 0;
-  FARPROC ptr = GDI_GetDefDCHook();
+  BOOL bRet = FALSE;
+  FARPROC16 ptr = GDI_GetDefDCHook();
 
   dprintf_dc(stddeb,"CallDCHook: code %04x\n", code);
 
@@ -379,8 +379,6 @@ HDC GetDCState( HDC hdc )
        newdc->w.hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
        CombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY );
     }
-    COLOR_SetMapping( newdc, dc->u.x.pal.hMapping,
-                      dc->u.x.pal.hRevMapping, dc->u.x.pal.mappingSize );
     return handle;
 }
 
@@ -421,8 +419,6 @@ void SetDCState( HDC hdc, HDC hdcs )
 
     SelectObject( hdc, dcs->w.hBrush );
     SelectObject( hdc, dcs->w.hFont );
-    COLOR_SetMapping( dc, dcs->u.x.pal.hMapping,
-                      dcs->u.x.pal.hRevMapping, dcs->u.x.pal.mappingSize );
 }
 
 
index 29a76026fbada32e37a4a26704c2df758d7cbc38..fb4e2346528d0524bab39b269d4934cbecbdd0cb 100644 (file)
@@ -430,22 +430,56 @@ HFONT32 CreateFontIndirect32W( const LOGFONT32W *font )
 
 
 /***********************************************************************
- *           CreateFont    (GDI.56)
+ *           CreateFont16    (GDI.56)
  */
-HFONT CreateFont( INT height, INT width, INT esc, INT orient, INT weight,
-                 BYTE italic, BYTE underline, BYTE strikeout, BYTE charset,
-                 BYTE outpres, BYTE clippres, BYTE quality, BYTE pitch,
-                 LPCSTR name )
+HFONT16 CreateFont16( INT16 height, INT16 width, INT16 esc, INT16 orient,
+                      INT16 weight, BYTE italic, BYTE underline,
+                      BYTE strikeout, BYTE charset, BYTE outpres,
+                      BYTE clippres, BYTE quality, BYTE pitch, LPCSTR name )
 {
     LOGFONT16 logfont = {height, width, esc, orient, weight, italic, underline,
                       strikeout, charset, outpres, clippres, quality, pitch, };
-    dprintf_font(stddeb,"CreateFont(%d,%d)\n", height, width);
+    dprintf_font(stddeb,"CreateFont16(%d,%d)\n", height, width);
     if (name) lstrcpyn32A(logfont.lfFaceName,name,sizeof(logfont.lfFaceName));
     else logfont.lfFaceName[0] = '\0';
     return CreateFontIndirect16( &logfont );
 }
 
 
+
+/*************************************************************************
+ *           CreateFont32A    (GDI32.43)
+ */
+HFONT32 CreateFont32A( INT32 height, INT32 width, INT32 esc, INT32 orient,
+                       INT32 weight, DWORD italic, DWORD underline,
+                       DWORD strikeout, DWORD charset, DWORD outpres,
+                       DWORD clippres, DWORD quality, DWORD pitch, LPCSTR name)
+{
+    return (HFONT32)CreateFont16( height, width, esc, orient, weight, italic,
+                                  underline, strikeout, charset, outpres,
+                                  clippres, quality, pitch, name );
+}
+
+
+/*************************************************************************
+ *           CreateFont32W    (GDI32.46)
+ */
+HFONT32 CreateFont32W( INT32 height, INT32 width, INT32 esc, INT32 orient,
+                       INT32 weight, DWORD italic, DWORD underline,
+                       DWORD strikeout, DWORD charset, DWORD outpres,
+                       DWORD clippres, DWORD quality, DWORD pitch,
+                       LPCWSTR name )
+{
+    LPSTR namea = name ? STRING32_DupUniToAnsi(name) : NULL;
+    HFONT32 ret = (HFONT32)CreateFont16( height, width, esc, orient, weight,
+                                         italic, underline, strikeout, charset,
+                                         outpres, clippres, quality, pitch,
+                                         namea );
+    free(namea);
+    return ret;
+}
+
+
 /***********************************************************************
  *           FONT_GetObject
  */
@@ -483,7 +517,7 @@ HFONT FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font )
     {
        HFONT hnewfont;
 
-       hnewfont = CreateFont(10, 7, 0, 0, FW_DONTCARE,
+       hnewfont = CreateFont16(10, 7, 0, 0, FW_DONTCARE,
                              FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
                              DEFAULT_QUALITY, FF_DONTCARE, "*" );
        font = (FONTOBJ *) GDI_HEAP_LIN_ADDR( hnewfont );
index 7568e63fb5c75feee2a63e7714a141469f547b86..1dffd302d082a5c7ffc26d7fe066fef4535b154a 100644 (file)
@@ -27,10 +27,6 @@ WORD GDI_HeapSel = 0;
 #define OBJ_PEN             1
 #define OBJ_BRUSH           2
 
-#define MAX_OBJ                        1024
-HANDLE *lpPenBrushList = NULL;
-
-
 /***********************************************************************
  *          GDI stock objects 
  */
@@ -277,7 +273,7 @@ BOOL DeleteObject( HGDIOBJ16 obj )
       case PEN_MAGIC:     return GDI_FreeObject( obj );
       case BRUSH_MAGIC:   return BRUSH_DeleteObject( obj, (BRUSHOBJ*)header );
       case FONT_MAGIC:    return GDI_FreeObject( obj );
-      case PALETTE_MAGIC: return GDI_FreeObject( obj );
+      case PALETTE_MAGIC: return PALETTE_DeleteObject(obj,(PALETTEOBJ*)header);
       case BITMAP_MAGIC:  return BITMAP_DeleteObject( obj, (BITMAPOBJ*)header);
       case REGION_MAGIC:  return REGION_DeleteObject( obj, (RGNOBJ*)header );
     }
@@ -412,9 +408,26 @@ HANDLE SelectObject( HDC hdc, HANDLE handle )
 /***********************************************************************
  *           UnrealizeObject    (GDI.150)
  */
-BOOL UnrealizeObject( HANDLE handle )
+BOOL UnrealizeObject( HANDLE obj )
 {
-    dprintf_gdi(stdnimp, "UnrealizeObject: %04x\n", handle );
+      /* Check if object is valid */
+
+    GDIOBJHDR * header = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR( obj );
+    if (!header) return FALSE;
+
+    dprintf_gdi( stddeb, "UnrealizeObject: %04x\n", obj );
+
+      /* Unrealize object */
+
+    switch(header->wMagic)
+    {
+    case PALETTE_MAGIC: 
+        return PALETTE_UnrealizeObject( obj, (PALETTEOBJ *)header );
+
+    case BRUSH_MAGIC:
+        /* Windows resets the brush origin. We don't need to. */
+        break;
+    }
     return TRUE;
 }
 
index a6b1296b0b7f9a57aeb44322de564e5b53fdd31d..5ef10f294e9d94df05a82ab54e44bbe417e6056c 100644 (file)
@@ -13,7 +13,7 @@
  *             LineDDA         (GDI.100)
  */
 void LineDDA(short nXStart, short nYStart, short nXEnd, short nYEnd,
-            FARPROC callback, long lParam)
+            FARPROC16 callback, long lParam)
 {
     int xadd = 1, yadd = 1;
     int err,erradd;
index bb5939c6488a7003869f845eae0b311220cf6cc2..3de567fa19a8be663cf4c853e8fa1acfd8b79d23 100644 (file)
@@ -339,7 +339,7 @@ static BOOL OBM_CreateBitmaps( char **data, BOOL color, HBITMAP *hBitmap,
 
     attrs = (XpmAttributes *)xmalloc( XpmAttributesSize() );
     attrs->valuemask    = XpmColormap | XpmDepth | XpmColorSymbols |XpmHotspot;
-    attrs->colormap     = COLOR_WinColormap;
+    attrs->colormap     = COLOR_GetColormap();
     attrs->depth        = color ? screenDepth : 1;
     attrs->colorsymbols = (attrs->depth > 1) ? OBM_Colors : OBM_BlackAndWhite;
     attrs->numsymbols   = (attrs->depth > 1) ? NB_COLOR_SYMBOLS : 2;
index d0cf94ef59459399b052830387660e8e3fb7b3d1..c287be84b77c74122d9ef0e6105702b472c5a832 100644 (file)
@@ -2,6 +2,7 @@
  * GDI palette objects
  *
  * Copyright 1993,1994 Alexandre Julliard
+ * Copyright 1996 Alex Korobka
  *
  */
 #include <stdlib.h>
 /* #define DEBUG_PALETTE */
 #include "debug.h"
 
+extern HWND            DCE_hDC2hWnd( HDC );                    /* get associated window by 
+                                                                * walking DCE list */
+
 static WORD SystemPaletteUse = SYSPAL_STATIC;  /* currently not considered */
 
+static HPALETTE16 hPrimaryPalette = 0; /* used for WM_PALETTECHANGED */
+static HPALETTE16 hLastRealizedPalette = 0; /* UnrealizeObject() needs it */
+
 
 /***********************************************************************
  *           PALETTE_GetNearestIndexAndColor
  */
-static WORD PALETTE_GetNearestIndexAndColor(HPALETTE16 hpalette, COLORREF *color)
+static WORD PALETTE_GetNearestIndexAndColor( HPALETTE16 hpalette,
+                                             COLORREF *color)
 {
     int i, minDist, dist;
     WORD index = 0;
@@ -31,14 +39,13 @@ static WORD PALETTE_GetNearestIndexAndColor(HPALETTE16 hpalette, COLORREF *color
     palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
     if (!palPtr) return 0;
 
-    if ((COLOR_WinColormap != DefaultColormapOfScreen(screen)) &&
-       (hpalette == STOCK_DEFAULT_PALETTE))
+    if ( hpalette == STOCK_DEFAULT_PALETTE )
     {
        if ((*color & 0xffffff) == 0) return 0;  /* Entry 0 is black */
        if ((*color & 0xffffff) == 0xffffff)     /* Max entry is white */
            return palPtr->logpalette.palNumEntries - 1;
     }
-    
+
     r = GetRValue(*color);
     g = GetGValue(*color);
     b = GetBValue(*color);
@@ -60,12 +67,24 @@ static WORD PALETTE_GetNearestIndexAndColor(HPALETTE16 hpalette, COLORREF *color
        }
        entry++;
     }
+
     entry = &palPtr->logpalette.palPalEntry[index];
     *color = RGB( entry->peRed, entry->peGreen, entry->peBlue );
     return index;
 }
 
 
+/***********************************************************************
+ *           PALETTE_ValidateFlags
+ */
+void PALETTE_ValidateFlags(PALETTEENTRY* lpPalE, int size)
+{
+    int i = 0;
+    for( ; i<size ; i++ )
+        lpPalE[i].peFlags = PC_SYS_USED | (lpPalE[i].peFlags & 0x07);
+}
+
+
 /***********************************************************************
  *           CreatePalette    (GDI.360)
  */
@@ -73,13 +92,22 @@ HPALETTE16 CreatePalette( const LOGPALETTE* palette )
 {
     PALETTEOBJ * palettePtr;
     HPALETTE16 hpalette;
-    int size;
+    int size = sizeof(LOGPALETTE) + (palette->palNumEntries - 1) * sizeof(PALETTEENTRY);
+
+    dprintf_palette(stddeb,"CreatePalette: ");
 
-    size = sizeof(LOGPALETTE) + (palette->palNumEntries - 1) * sizeof(PALETTEENTRY);
-    hpalette = GDI_AllocObject( sizeof(GDIOBJHDR) + size, PALETTE_MAGIC );
+    dprintf_palette(stddeb,"%i entries, ", palette->palNumEntries);
+
+    hpalette = GDI_AllocObject( size + sizeof(int*) +sizeof(GDIOBJHDR) , PALETTE_MAGIC );
     if (!hpalette) return 0;
+
     palettePtr = (PALETTEOBJ *) GDI_HEAP_LIN_ADDR( hpalette );
     memcpy( &palettePtr->logpalette, palette, size );
+    PALETTE_ValidateFlags(palettePtr->logpalette.palPalEntry, 
+                         palettePtr->logpalette.palNumEntries);
+    palettePtr->mapping = NULL;
+
+    dprintf_palette(stddeb,"returning %04x\n", hpalette);
     return hpalette;
 }
 
@@ -92,14 +120,19 @@ WORD GetPaletteEntries( HPALETTE16 hpalette, WORD start, WORD count,
 {
     PALETTEOBJ * palPtr;
     int numEntries;
+
+    dprintf_palette(stddeb,"GetPaletteEntries: hpal = %04x, %i entries\n", hpalette, count);
         
     palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
     if (!palPtr) return 0;
+
     numEntries = palPtr->logpalette.palNumEntries;
     if (start >= numEntries) return 0;
     if (start+count > numEntries) count = numEntries - start;
     memcpy( entries, &palPtr->logpalette.palPalEntry[start],
            count * sizeof(PALETTEENTRY) );
+    for( numEntries = 0; numEntries < count ; numEntries++ )
+         if( entries[numEntries].peFlags & 0xF0 ) entries[numEntries].peFlags = 0;
     return count;
 }
 
@@ -112,14 +145,19 @@ WORD SetPaletteEntries( HPALETTE16 hpalette, WORD start, WORD count,
 {
     PALETTEOBJ * palPtr;
     int numEntries;
-        
+
+    dprintf_palette(stddeb,"SetPaletteEntries: hpal = %04x, %i entries\n", hpalette, count);
+
     palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
     if (!palPtr) return 0;
+
     numEntries = palPtr->logpalette.palNumEntries;
     if (start >= numEntries) return 0;
     if (start+count > numEntries) count = numEntries - start;
     memcpy( &palPtr->logpalette.palPalEntry[start], entries,
            count * sizeof(PALETTEENTRY) );
+    PALETTE_ValidateFlags(palPtr->logpalette.palPalEntry, 
+                         palPtr->logpalette.palNumEntries);
     return count;
 }
 
@@ -128,6 +166,10 @@ WORD SetPaletteEntries( HPALETTE16 hpalette, WORD start, WORD count,
  */
 BOOL ResizePalette(HPALETTE16 hPal, UINT cEntries)
 {
+
+    /* should simply realloc memory and zero out
+     * added entries, if any */
+
     fprintf(stdnimp,"ResizePalette: empty stub! \n");
     return FALSE;
 }
@@ -144,14 +186,11 @@ BOOL AnimatePalette(HPALETTE16 hPal, UINT StartIndex, UINT NumEntries,
 
 /***********************************************************************
  *           SetSystemPaletteUse    (GDI.373)
- *     Should this be per DC rather than system wide?
- *  Currently, it does not matter as the use is only set and returned,
- *  but not taken into account
  */
 WORD SetSystemPaletteUse( HDC hdc, WORD use)
 {
         WORD old=SystemPaletteUse;
-        printf("SetSystemPaletteUse(%04x,%04x) // empty stub !!!\n", hdc, use);
+        fprintf(stdnimp,"SetSystemPaletteUse(%04x,%04x) // empty stub !!!\n", hdc, use);
         SystemPaletteUse=use;
         return old;
 }
@@ -161,7 +200,7 @@ WORD SetSystemPaletteUse( HDC hdc, WORD use)
  */
 WORD GetSystemPaletteUse( HDC hdc )
 {
-       printf("GetSystemPaletteUse(%04x) // empty stub !!!\n", hdc);
+       fprintf(stdnimp,"GetSystemPaletteUse(%04x) // empty stub !!!\n", hdc);
        return SystemPaletteUse;
 }
 
@@ -182,8 +221,10 @@ WORD GetSystemPaletteEntries( HDC hdc, WORD start, WORD count,
        count = dc->w.devCaps->sizePalette - start;
     for (i = 0; i < count; i++)
     {
-       color.pixel = start + i;
-       XQueryColor( display, COLOR_WinColormap, &color );
+       color.pixel = (COLOR_PaletteToPixel)
+                     ? COLOR_PaletteToPixel[start + i]
+                     : start + i;
+       XQueryColor( display, COLOR_GetColormap(), &color );
        entries[i].peRed   = color.red >> 8;
        entries[i].peGreen = color.green >> 8;
        entries[i].peBlue  = color.blue >> 8;
@@ -232,10 +273,35 @@ int PALETTE_GetObject( PALETTEOBJ * palette, int count, LPSTR buffer )
 }
 
 
+/***********************************************************************
+ *           PALETTE_UnrealizeObject
+ */
+BOOL PALETTE_UnrealizeObject( HPALETTE16 hpalette, PALETTEOBJ *palette )
+{
+    if (palette->mapping)
+    {
+        free( palette->mapping );
+        palette->mapping = NULL;
+    }
+    if (hLastRealizedPalette == hpalette) hLastRealizedPalette = 0;
+    return TRUE;
+}
+
+
+/***********************************************************************
+ *           PALETTE_DeleteObject
+ */
+BOOL PALETTE_DeleteObject( HPALETTE16 hpalette, PALETTEOBJ *palette )
+{
+    free( palette->mapping );
+    return GDI_FreeObject( hpalette );
+}
+
+
 /***********************************************************************
  *           GDISelectPalette    (GDI.361)
  */
-HPALETTE16 GDISelectPalette( HDC hdc, HPALETTE16 hpal )
+HPALETTE16 GDISelectPalette( HDC hdc, HPALETTE16 hpal, WORD wBkg)
 {
     HPALETTE16 prev;
     DC *dc;
@@ -244,88 +310,127 @@ HPALETTE16 GDISelectPalette( HDC hdc, HPALETTE16 hpal )
     if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
     prev = dc->w.hPalette;
     dc->w.hPalette = hpal;
-    if (hpal != STOCK_DEFAULT_PALETTE) COLOR_SetMapping( dc, 0, 0, 0 );
-    else RealizeDefaultPalette( hdc );  /* Always realize default palette */
+    if (!wBkg) hPrimaryPalette = hpal; 
     return prev;
 }
 
 
 /***********************************************************************
  *           GDIRealizePalette    (GDI.362)
+ *
  */
 UINT GDIRealizePalette( HDC hdc )
 {
-    UINT        realized = 0;
-    COLORREF    color;
     DC*         dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ) ;
     PALETTEOBJ* palPtr;
+    int                realized = 0;
 
-    dprintf_palette(stdnimp, "GDIRealizePalette: %04x...", hdc );
-
-    if( dc )
-      {
+    dprintf_palette(stddeb, "GDIRealizePalette: %04x...", hdc );
+    
+    if( dc &&  dc->w.hPalette != hLastRealizedPalette )
+    {
         palPtr = (PALETTEOBJ *) GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC );
-
-        if( palPtr )
-          {
-            WORD        index, i;
-            HANDLE      hMap;
-            WORD*       pMap;
-
-            hMap = GDI_HEAP_ALLOC(sizeof(WORD)*palPtr->logpalette.palNumEntries);
-            pMap = (WORD*)GDI_HEAP_LIN_ADDR( hMap );
-
-            if( pMap )
-            {
-              for (i = 0; i < palPtr->logpalette.palNumEntries ; i++)
-              {
-                color = *(COLORREF*)(palPtr->logpalette.palPalEntry + i);
-                index = PALETTE_GetNearestIndexAndColor( STOCK_DEFAULT_PALETTE, &color);
-                if( index != i ) realized++;
-                pMap[i] = index;
-              }
-              COLOR_SetMapping(dc, hMap, 0, i);
-              GDI_HEAP_FREE(hMap);
-            }
-          }
-      }
+        
+       realized = COLOR_SetMapping(palPtr, dc->w.hPalette != hPrimaryPalette 
+                                  || dc->w.hPalette == STOCK_DEFAULT_PALETTE );
+       hLastRealizedPalette = dc->w.hPalette;
+    }
+    else dprintf_palette(stddeb, " skipping ");
+    
     dprintf_palette(stdnimp, " realized %i colors\n", realized );
-    return realized;
+    return (UINT)realized;
 }
 
 
 /***********************************************************************
- *           SelectPalette    (USER.282)
+ *           RealizeDefaultPalette    (GDI.365)
  */
-HPALETTE16 SelectPalette(HDC hDC, HPALETTE16 hPal, BOOL bForceBackground)
+WORD RealizeDefaultPalette( HDC hdc )
 {
-    return GDISelectPalette( hDC, hPal );
+    DC *dc;
+
+    dprintf_palette(stddeb,"RealizeDefaultPalette: %04x\n", hdc );
+
+    if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
+    if ( dc->w.flags & DC_MEMORY ) return 0;
+
+    hPrimaryPalette = STOCK_DEFAULT_PALETTE;
+    hLastRealizedPalette = STOCK_DEFAULT_PALETTE;
+    return COLOR_SetMapping( (PALETTEOBJ*)GDI_GetObjPtr(STOCK_DEFAULT_PALETTE, PALETTE_MAGIC ), TRUE);
 }
 
 
 /***********************************************************************
- *           SelectPalette32    (GDI32.300)
+ *           IsDCCurrentPalette   (GDI.412)
  */
-HPALETTE16 SelectPalette32(HDC hDC, HPALETTE16 hPal, BOOL bForceBackground)
+BOOL IsDCCurrentPalette(HDC hDC)
 {
-    return GDISelectPalette( hDC, hPal );
+    DC* dc = (DC *)GDI_GetObjPtr( hDC, DC_MAGIC );
+    return (dc->w.hPalette == hPrimaryPalette);
 }
 
-
 /***********************************************************************
- *           RealizePalette    (USER.283)
+ *           SelectPalette    (USER.282)
  */
-UINT RealizePalette(HDC hDC)
+HPALETTE16 SelectPalette( HDC hDC, HPALETTE16 hPal, BOOL bForceBackground )
 {
-    return GDIRealizePalette( hDC );
+    WORD       wBkgPalette = 1;
+    PALETTEOBJ* lpt = (PALETTEOBJ*) GDI_GetObjPtr( hPal, PALETTE_MAGIC );
+
+    dprintf_palette(stddeb,"SelectPalette: dc %04x pal %04x, force=%i ", 
+                           hDC, hPal, bForceBackground);
+    if( !lpt ) return 0;
+
+    dprintf_palette(stddeb," entries = %d\n", 
+                           lpt->logpalette.palNumEntries);
+
+    if( hPal != STOCK_DEFAULT_PALETTE )
+    {
+       HWND hWnd = DCE_hDC2hWnd( hDC );
+       HWND hActive = GetActiveWindow();
+       
+       /* set primary palette if it's related to current active */
+
+       if( hWnd && (hActive == hWnd || IsChild(hActive,hWnd)) &&
+            !bForceBackground )
+           wBkgPalette = 0;
+    }
+    return GDISelectPalette( hDC, hPal, wBkgPalette);
 }
 
 
 /***********************************************************************
- *           RealizePalette32    (GDI32.280)
+ *           RealizePalette    (USER.283) (GDI32.280)
  */
-UINT RealizePalette32(HDC hDC)
+UINT16 RealizePalette( HDC32 hDC )
 {
-    return GDIRealizePalette( hDC );
+    UINT16 realized = GDIRealizePalette( hDC );
+
+    /* do not send anything if no colors were changed */
+
+    if( IsDCCurrentPalette( hDC ) && realized )
+    {
+       /* Send palette change notification */
+
+       HWND hWnd;
+       if( (hWnd = DCE_hDC2hWnd( hDC )) )
+            SendMessage16( HWND_BROADCAST, WM_PALETTECHANGED, hWnd, 0L);
+    }
+    return realized;
 }
 
+
+/**********************************************************************
+ *         UpdateColors        (GDI.366)
+ *
+ */
+int UpdateColors( HDC hDC )
+{
+    HWND hWnd = DCE_hDC2hWnd( hDC );
+
+    /* Docs say that we have to remap current drawable pixel by pixel
+     * but it would take forever given the speed of XGet/PutPixel.
+     */
+    if (hWnd) InvalidateRect16( hWnd, NULL, FALSE );
+    return 0x666;
+}
index f8f825891221fd614cc6c2e056e74976d3d3371b..5c892d8cc7040947f14ec7f7bea83854a4e5dc43 100644 (file)
@@ -618,7 +618,7 @@ BOOL32 TextOut32W( HDC32 hdc, INT32 x, INT32 y, LPCWSTR str, INT32 count )
 /***********************************************************************
  *             GrayString (USER.185)
  */
-BOOL GrayString(HDC hdc, HBRUSH hbr, FARPROC gsprc, LPARAM lParam, 
+BOOL GrayString(HDC hdc, HBRUSH hbr, FARPROC16 gsprc, LPARAM lParam, 
                INT cch, INT x, INT y, INT cx, INT cy)
 {
     BOOL ret;
index 717b876f941f08f8e809eb3c91a35cf1f2261d4f..699be73a82219bb99d1f65c5eb58b16e846d55d9 100644 (file)
@@ -314,10 +314,11 @@ INT lstrlen(LPCSTR str)
   return strlen(str);
 }
 
-SEGPTR lstrcpy( SEGPTR target, SEGPTR source )
+LPSTR lstrcpy32A( LPSTR dst, LPCSTR src )
 {
-  strcpy( (char *)target, (char *)source );
-  return target;
+    if (!src || !dst) return NULL;
+    strcpy( dst, src );
+    return dst;
 }
 
 void hmemcpy(LPVOID hpvDest, LPCVOID hpvSource, LONG cbCopy)
index 0c7bcd84381738a202d8030a22d9b8c8cec713bc..2a6c36a58b7b115dee9e94ae92473470cbd5b85c 100644 (file)
@@ -183,7 +183,7 @@ HLPFILE *HLPFILE_ReadHlpFile(LPCSTR lpszPath)
 
   hlpfile->lpszPath   = GlobalLock(hHlpFile);
   hlpfile->lpszPath  += sizeof(HLPFILE);
-  lstrcpy(hlpfile->lpszPath, (SEGPTR) lpszPath);
+  strcpy(hlpfile->lpszPath, lpszPath);
 
   phrases.hBuffer = topic.hBuffer = hFileBuffer = 0;
 
index a7094734cdfdd1cdf9d2eb6e78d77bd148f594b1..594efe08af33ef8c11b31b0e20758712e0b3db13 100644 (file)
@@ -322,11 +322,11 @@ VOID WINHELP_CreateHelpWindow(LPCSTR lpszFile, LONG lHash, LPCSTR lpszWindow,
   /* Create main Window */
   if (!page) LoadString(Globals.hInstance, IDS_WINE_HELP, szCaption, sizeof(szCaption));
   hWnd = CreateWindow (bPopup ? TEXT_WIN_CLASS_NAME : MAIN_WIN_CLASS_NAME,
-                      page ? (SEGPTR) page->file->lpszTitle : (SEGPTR) szCaption,
+                      page ? page->file->lpszTitle : szCaption,
                       bPopup ? WS_POPUPWINDOW | WS_BORDER : WS_OVERLAPPEDWINDOW,
                       origin.x, origin.y, size.cx, size.cy,
                       0, bPrimary ? LoadMenu(Globals.hInstance, STRING_MENU_Xx) : 0,
-                      Globals.hInstance, (SEGPTR) win);
+                      Globals.hInstance, win);
 
   ShowWindow (hWnd, nCmdShow);
   UpdateWindow (hWnd);
@@ -359,10 +359,10 @@ static LRESULT WINHELP_MainWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
 
       /* Create button box and text Window */
       CreateWindow(BUTTON_BOX_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE,
-                  0, 0, 0, 0, hWnd, 0, Globals.hInstance, (SEGPTR) win);
+                  0, 0, 0, 0, hWnd, 0, Globals.hInstance, win);
 
       CreateWindow(TEXT_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE,
-                  0, 0, 0, 0, hWnd, 0, Globals.hInstance, (SEGPTR) win);
+                  0, 0, 0, 0, hWnd, 0, Globals.hInstance, win);
 
       /* Fall through */
     case WM_USER:
index 6778692cea9af0772a4f07e15d14f8c922e31f37..d4d178a3ec04162967b77763204f0f78457ef1e0 100644 (file)
@@ -1,3 +1,4 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
 
 PROGRAM = winerc
index d6e2d9b95401c90588cef692a115fd96f7294167..153df2c80d80f7c71ef2b60252b07090ecffa38e 100644 (file)
@@ -1,5 +1,5 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
-
 MODULE = resources
 
 LANGUAGES = En Es De No Fr Fi Da Cz Eo It Ko
index 507f69182a4dafb097cf1d605658dd1f92e3a192..3ff5e745cf56d52ccf4ac8fc5072ea453b74d1b4 100644 (file)
@@ -1,4 +1,5 @@
-TOPSRC  = @top_srcdir@
+DEFS   = -D__WINE__
+TOPSRC = @top_srcdir@
 
 PROGRAM = build
 MODULE  = none
index 6a446834ea768c370b8442dd2598d990eca0f3c4..1e0d7b62e8d10cfc2df9d232a0e229cd7020079e 100644 (file)
@@ -1661,9 +1661,9 @@ static void BuildCallFrom16Func( char *profile )
  * (ebp)    previous ebp
  *
  * Prototypes for the CallTo16 functions:
- *   extern WORD CallTo16_word_xxx( FARPROC func, WORD ds, args... );
- *   extern LONG CallTo16_long_xxx( FARPROC func, WORD ds, args... );
- *   extern void CallTo16_regs_( FARPROC func, WORD ds, WORD es, WORD bp,
+ *   extern WORD CallTo16_word_xxx( FARPROC16 func, WORD ds, args... );
+ *   extern LONG CallTo16_long_xxx( FARPROC16 func, WORD ds, args... );
+ *   extern void CallTo16_regs_( FARPROC16 func, WORD ds, WORD es, WORD bp,
  *                               WORD ax, WORD bx, WORD cx, WORD dx,
  *                               WORD si, WORD di );
  */
@@ -1981,7 +1981,7 @@ static void BuildCallFrom32Func( const char *profile )
  * (ebp)    previous ebp
  *
  * Prototype for the CallTo32 functions:
- *   extern LONG CallTo32_nn( FARPROC func, args... );
+ *   extern LONG CallTo32_nn( FARPROC32 func, args... );
  */
 static void BuildCallTo32Func( int args )
 {
index 452f909f074aa89ea40cef5a0c284d85c2204110..634e87bee4d62db138b6bff2004c84c030b2fac6 100644 (file)
@@ -1,3 +1,4 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
 MODULE = win32
 
@@ -15,7 +16,6 @@ C_SRCS = \
        newfns.c \
        object_mgt.c \
        process.c \
-       resource.c \
        string32.c \
        struct32.c \
        thread.c \
index e09b635ad75ffd1fda992455397e95844b519d4e..0e256a45b3ceedcbf4c27dd4ff9fe1c3b1cd445d 100644 (file)
@@ -33,7 +33,6 @@
 #include "win.h"
 #include "struct32.h"
 #include "string32.h"
-#include "resource32.h"
 #include "stddebug.h"
 #include "debug.h"
 #include "xmalloc.h"
@@ -456,22 +455,25 @@ static HANDLE CURSORICON32_Load( HANDLE hInstance, LPCWSTR name, int width,
 
 
 /***********************************************************************
- *           LoadCursor
+ *           LoadCursorW               (USER32.361)
  */
-HCURSOR WIN32_LoadCursorW( HANDLE hInstance, LPCWSTR name )
+HCURSOR32 LoadCursor32W(HINSTANCE32 hInstance,LPCWSTR name)
 {
     return CURSORICON32_Load( hInstance, name,
                             SYSMETRICS_CXCURSOR, SYSMETRICS_CYCURSOR, 1, TRUE);
 }
 
-HCURSOR WIN32_LoadCursorA(HANDLE hInstance, LPCSTR name)
+/***********************************************************************
+ *           LoadCursorA               (USER32.358)
+ */
+HCURSOR32 LoadCursor32A(HINSTANCE32 hInstance,LPCSTR name)
 {
-       HCURSOR res=0;
+       HCURSOR32 res=0;
        if(!HIWORD(name))
-               return WIN32_LoadCursorW(hInstance, name);
+               return LoadCursor32W(hInstance,(LPCWSTR)name);
        else {
                LPWSTR uni = STRING32_DupAnsiToUni(name);
-               res = WIN32_LoadCursorW(hInstance, uni);
+               res = LoadCursor32W(hInstance, uni);
                free(uni);
        }
        return res;
@@ -479,25 +481,28 @@ HCURSOR WIN32_LoadCursorA(HANDLE hInstance, LPCSTR name)
 
 
 /***********************************************************************
- *           LoadIcon
+ *           LoadIconW         (USER32.363)
  */
-HICON WIN32_LoadIconW( HANDLE hInstance, LPCWSTR name )
+HICON32 LoadIcon32W(HINSTANCE32 hInstance,LPCWSTR name)
 {
     return CURSORICON32_Load( hInstance, name,
                             SYSMETRICS_CXICON, SYSMETRICS_CYICON,
                             MIN( 16, 1 << screenDepth ), FALSE );
 }
 
-HICON WIN32_LoadIconA( HANDLE hInstance, LPCSTR name)
+/***********************************************************************
+ *           LoadIconA         (USER32.362)
+ */
+HICON32 LoadIcon32A(HINSTANCE32 hInstance,LPCSTR name)
 {
-       HICON res=0;
+       HICON32 res=0;
        if(!HIWORD(name))
-               return WIN32_LoadIconW(hInstance, name);
+               return LoadIcon32W(hInstance, (LPCWSTR)name);
        else {
                LPWSTR uni = STRING32_DupAnsiToUni(name);
-               res = WIN32_LoadIconW(hInstance, uni);
+               res = LoadIcon32W(hInstance, uni);
                free(uni);
        }
        return res;
 }
-       
+
index 54267c1b684fa9b887db291571d19dc1bfa5d303..3ea2385c55e8ca2c1d7b692ee3f1e0d5e975d3f9 100644 (file)
@@ -25,14 +25,14 @@ LPSTR GetCommandLineA(void)
     char *cp;
     PDB *pdb = (PDB *)GlobalLock16( GetCurrentPDB() );
 
-#ifndef WINELIB
-    strcpy(buffer, MODULE_GetModuleName( GetExePtr(GetCurrentTask()) ) );
-    cp = buffer+strlen(buffer);
-    *cp++ = ' ';
-#else
-    cp = buffer;
-#endif;
-    memcpy( cp, &pdb->cmdLine[1], pdb->cmdLine[0] );
+    lstrcpyn32A( buffer, MODULE_GetModuleName( GetExePtr(GetCurrentTask()) ),
+                 sizeof(buffer) - 1 );
+    cp = buffer + strlen(buffer);
+    if (pdb->cmdLine[0])
+    {
+        *cp++ = ' ';
+        memcpy( cp, &pdb->cmdLine[1], pdb->cmdLine[0] );
+    }
     dprintf_win32(stddeb,"CommandLine = %s\n", buffer );
     return buffer;
 }
index 09578227e46e6eeb4987caed41475c56ae49b68c..91f0128e1f38bf2f1d93034a3b2b0d0c083c8ea6 100644 (file)
@@ -63,7 +63,7 @@ BOOL CloseHandle(KERNEL_OBJECT *handle)
 /***********************************************************************
  *              GetModuleFileNameA      (KERNEL32.235)
  */
-DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
+DWORD GetModuleFileNameA(HMODULE32 hModule, LPSTR lpFilename, DWORD nSize)
 {
     strcpy(lpFilename, "c:\\dummy");
     return 8;
@@ -72,9 +72,9 @@ DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
 /***********************************************************************
  *              GetModuleHandle         (KERNEL32.237)
  */
-HMODULE WIN32_GetModuleHandle(char *module)
+HMODULE32 WIN32_GetModuleHandle(char *module)
 {
-    HMODULE hModule;
+    HMODULE32 hModule;
 
     dprintf_win32(stddeb, "GetModuleHandle: %s\n", module ? module : "NULL");
 /* Freecell uses the result of GetModuleHandleA(0) as the hInstance in
index a226e1611e7daf02cffe9123e6ec674ce13eb05c..805ed2e189eb5ff3b2379daf9adcfe0a51c74e82 100644 (file)
@@ -24,7 +24,7 @@ BOOL WIN32_WinHelpA(HWND hWnd,LPCSTR lpszHelp,UINT uCommand, DWORD dwData)
        return WinHelp(hWnd,lpszHelp,uCommand,dwData);
 }
 
-HHOOK SetWindowsHookEx32A(int HookId, HOOKPROC hookfn, HINSTANCE hModule,
+HHOOK SetWindowsHookEx32A(int HookId, HOOKPROC32 hookfn, HINSTANCE hModule,
                                DWORD ThreadId)
 
 {
index 2a41875b2bc14903dd92f92e89d9343bd6ac54e2..47c287349a44f054248a0a3f52178f1e61b21702 100644 (file)
@@ -135,7 +135,7 @@ BOOL FreeLibrary32(HINSTANCE hLibModule)
 BOOL GetProcessAffinityMask(HANDLE32 hProcess, LPDWORD lpProcessAffinityMask,
   LPDWORD lpSystemAffinityMask)
 {
-       dprintf_task(stddeb,"GetProcessAffinityMask(%x,%x,%x)\n",
+       dprintf_task(stddeb,"GetProcessAffinityMask(%x,%lx,%lx)\n",
                hProcess,(lpProcessAffinityMask?*lpProcessAffinityMask:0),
                (lpSystemAffinityMask?*lpSystemAffinityMask:0));
        /* It is definitely important for a process to know on what processor
@@ -152,7 +152,7 @@ BOOL GetProcessAffinityMask(HANDLE32 hProcess, LPDWORD lpProcessAffinityMask,
  */
 BOOL SetThreadAffinityMask(HANDLE32 hThread, DWORD dwThreadAffinityMask)
 {
-       dprintf_task(stddeb,"SetThreadAffinityMask(%x,%x)\n",hThread,
+       dprintf_task(stddeb,"SetThreadAffinityMask(%x,%lx)\n",hThread,
                dwThreadAffinityMask);
        /* FIXME: We let it fail */
        return 1;
diff --git a/win32/resource.c b/win32/resource.c
deleted file mode 100644 (file)
index 2b852bc..0000000
+++ /dev/null
@@ -1,459 +0,0 @@
-/*
- * Win32 Resources
- *
- * Copyright 1995 Thomas Sandford
- * Copyright 1996 Martin von Loewis
- *
- * Based on the Win16 resource handling code in loader/resource.c
- * Copyright 1993 Robert J. Amstadt
- * Copyright 1995 Alexandre Julliard
- *
- * This is not even at ALPHA level yet. Don't expect it to work!
- */
-
-#include <sys/types.h>
-#include "wintypes.h"
-#include "windows.h"
-#include "kernel32.h"
-#include "pe_image.h"
-#include "module.h"
-#include "handle32.h"
-#include "libres.h"
-#include "resource32.h"
-#include "stackframe.h"
-#include "neexe.h"
-#include "accel.h"
-#include "xmalloc.h"
-#include "string32.h"
-#include "stddebug.h"
-#include "debug.h"
-
-int language = 0x0409;
-
-#define PrintIdA(name) \
-    if (HIWORD((DWORD)name)) \
-        dprintf_resource( stddeb, "'%s'", name); \
-    else \
-        dprintf_resource( stddeb, "#%04x", LOWORD(name)); 
-#define PrintIdW(name)
-#define PrintId(name)
-
-/**********************************************************************
- *         GetResDirEntryW
- *
- *     Helper function - goes down one level of PE resource tree
- *
- */
-PIMAGE_RESOURCE_DIRECTORY GetResDirEntryW(PIMAGE_RESOURCE_DIRECTORY resdirptr,
-                                        LPCWSTR name,
-                                        DWORD root)
-{
-    int entrynum;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY entryTable;
-       int namelen;
-
-    if (HIWORD(name)) {
-    /* FIXME: what about #xxx names? */
-       entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (
-                       (BYTE *) resdirptr + 
-                        sizeof(IMAGE_RESOURCE_DIRECTORY));
-       namelen = lstrlen32W(name);
-       for (entrynum = 0; entrynum < resdirptr->NumberOfNamedEntries; entrynum++)
-       {
-               PIMAGE_RESOURCE_DIR_STRING_U str =
-               (PIMAGE_RESOURCE_DIR_STRING_U) (root + 
-                       (entryTable[entrynum].Name & 0x7fffffff));
-               if(namelen != str->Length)
-                       continue;
-               if(lstrncmpi32W(name,str->NameString,str->Length)==0)
-                       return (PIMAGE_RESOURCE_DIRECTORY) (
-                               root +
-                               (entryTable[entrynum].OffsetToData & 0x7fffffff));
-       }
-       return NULL;
-    } else {
-       entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (
-                       (BYTE *) resdirptr + 
-                        sizeof(IMAGE_RESOURCE_DIRECTORY) +
-                       resdirptr->NumberOfNamedEntries * sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY));
-       for (entrynum = 0; entrynum < resdirptr->NumberOfIdEntries; entrynum++)
-           if ((DWORD)entryTable[entrynum].Name == (DWORD)name)
-               return (PIMAGE_RESOURCE_DIRECTORY) (
-                       root +
-                       (entryTable[entrynum].OffsetToData & 0x7fffffff));
-       return NULL;
-    }
-}
-
-/**********************************************************************
- *         GetResDirEntryA
- *
- *     Helper function - goes down one level of PE resource tree
- *
- */
-PIMAGE_RESOURCE_DIRECTORY GetResDirEntryA(PIMAGE_RESOURCE_DIRECTORY resdirptr,
-                                        LPCSTR name,
-                                        DWORD root)
-{
-       LPWSTR                          xname;
-       PIMAGE_RESOURCE_DIRECTORY       ret;
-
-       if (HIWORD((DWORD)name))
-               xname   = STRING32_DupAnsiToUni(name);
-       else
-               xname   = (LPWSTR)name;
-
-       ret=GetResDirEntryW(resdirptr,xname,root);
-       if (HIWORD((DWORD)name))
-               free(xname);
-       return ret;
-}
-
-/**********************************************************************
- *         FindResourceA    (KERNEL32.128)
- */
-HANDLE32 FindResource32A( HINSTANCE hModule, LPCSTR name, LPCSTR type ) {
-       LPWSTR          xname,xtype;
-       HANDLE32        ret;
-
-       if (HIWORD((DWORD)name))
-               xname = STRING32_DupAnsiToUni(name);
-       else
-               xname = (LPWSTR)name;
-       if (HIWORD((DWORD)type))
-               xtype = STRING32_DupAnsiToUni(type);
-       else
-               xtype = (LPWSTR)type;
-       ret=FindResource32W(hModule,xname,xtype);
-       if (HIWORD((DWORD)name))
-               free(xname);
-       if (HIWORD((DWORD)type))
-               free(xtype);
-       return ret;
-}
-
-/**********************************************************************
- *         FindResourceW    (KERNEL32.131)
- */
-HANDLE32 FindResource32W( HINSTANCE hModule, LPCWSTR name, LPCWSTR type )
-{
-#ifndef WINELIB
-    PE_MODULE *pe;
-    NE_MODULE *pModule;
-    PIMAGE_RESOURCE_DIRECTORY resdirptr;
-    DWORD root;
-       HANDLE32 result;
-
-    /* Sometimes we get passed hModule = 0x00000000. FIXME: is GetTaskDS()
-     * ok?
-     */
-    if (!hModule) hModule = GetTaskDS();
-    hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
-    dprintf_resource(stddeb, "FindResource: module=%08x type=", hModule );
-    PrintId( type );
-    dprintf_resource( stddeb, " name=" );
-    PrintId( name );
-    dprintf_resource( stddeb, "\n" );
-    if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
-    if (!(pModule->flags & NE_FFLAGS_WIN32)) return 0;  /* FIXME? */
-    if (!(pe = pModule->pe_module) || !pe->pe_resource) return 0;
-
-    resdirptr = (PIMAGE_RESOURCE_DIRECTORY) pe->pe_resource;
-    root = (DWORD) resdirptr;
-    if ((resdirptr = GetResDirEntryW(resdirptr, type, root)) == NULL)
-       return 0;
-    if ((resdirptr = GetResDirEntryW(resdirptr, name, root)) == NULL)
-       return 0;
-    result = (HANDLE32)GetResDirEntryW(resdirptr, (LPCWSTR)language, root);
-       /* Try LANG_NEUTRAL, too */
-    if(!result)
-        return (HANDLE32)GetResDirEntryW(resdirptr, (LPCWSTR)0, root);
-    return result;
-    
-#else
-    return LIBRES_FindResource( hModule, name, type );
-#endif
-}
-
-
-/**********************************************************************
- *         LoadResource    (KERNEL32.370)
- */
-HANDLE32 LoadResource32( HINSTANCE hModule, HANDLE32 hRsrc )
-{
-#ifndef WINELIB
-    NE_MODULE *pModule;
-    PE_MODULE *pe;
-
-    if (!hModule) hModule = GetTaskDS(); /* FIXME: see FindResource32W */
-    hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
-    dprintf_resource(stddeb, "LoadResource: module=%04x res=%04x\n",
-                     hModule, hRsrc );
-    if (!hRsrc) return 0;
-
-    if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
-    if (!(pModule->flags & NE_FFLAGS_WIN32)) return 0;  /* FIXME? */
-    if (!(pe = pModule->pe_module) || !pe->pe_resource) return 0;
-    return (HANDLE32) (pe->load_addr+((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->OffsetToData);
-#else
-    return LIBRES_LoadResource( hModule, hRsrc );
-#endif
-}
-
-
-/**********************************************************************
- *         LockResource    (KERNEL.62)
- */
-LPVOID LockResource32( HANDLE32 handle )
-{
-       return (LPVOID) handle;
-}
-
-/**********************************************************************
- *         FreeResource    (KERNEL.63)
- */
-BOOL FreeResource32( HANDLE32 handle )
-{
-    /* no longer used in Win32 */
-    return TRUE;
-}
-
-/**********************************************************************
- *         AccessResource    (KERNEL.64)
- */
-INT AccessResource32( HINSTANCE hModule, HRSRC hRsrc )
-{
-    hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
-    dprintf_resource(stddeb, "AccessResource: module=%04x res=%04x\n",
-                     hModule, hRsrc );
-    if (!hRsrc) return 0;
-       fprintf(stderr,"AccessResource32: not implemented\n");
-       return 0;
-}
-
-
-/**********************************************************************
- *         SizeofResource    (KERNEL.65)
- */
-DWORD SizeofResource32( HINSTANCE hModule, HRSRC hRsrc )
-{
-    hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
-    dprintf_resource(stddeb, "SizeofResource: module=%04x res=%04x\n",
-                     hModule, hRsrc );
-       fprintf(stderr,"SizeofResource32: not implemented\n");
-       return 0;
-}
-
-/**********************************************************************
- *                     LoadAccelerators        [USER.177]
-*/
-HANDLE32 WIN32_LoadAcceleratorsW(HINSTANCE instance, LPCWSTR lpTableName)
-{
-#if 0
-    HANDLE32   hAccel;
-    HANDLE32   rsc_mem;
-    HANDLE32 hRsrc;
-    BYTE       *lp;
-    ACCELHEADER        *lpAccelTbl;
-    int        i, n;
-
-    if (HIWORD(lpTableName))
-        dprintf_accel( stddeb, "LoadAccelerators: %04x '%s'\n",
-                      instance, (char *)( lpTableName ) );
-    else
-        dprintf_accel( stddeb, "LoadAccelerators: %04x %04x\n",
-                       instance, LOWORD(lpTableName) );
-
-    if (!(hRsrc = FindResource32( instance, lpTableName, 
-               (LPCWSTR)RT_ACCELERATOR )))
-      return 0;
-    if (!(rsc_mem = LoadResource32( instance, hRsrc ))) return 0;
-
-    lp = (BYTE *)LockResource32(rsc_mem);
-    n = SizeofResource( instance, hRsrc ) / sizeof(ACCELENTRY);
-    hAccel = GlobalAlloc16(GMEM_MOVEABLE, 
-       sizeof(ACCELHEADER) + (n + 1)*sizeof(ACCELENTRY));
-    lpAccelTbl = (LPACCELHEADER)GlobalLock16(hAccel);
-    lpAccelTbl->wCount = 0;
-    for (i = 0; i < n; i++) {
-       lpAccelTbl->tbl[i].type = *(lp++);
-       lpAccelTbl->tbl[i].wEvent = *((WORD *)lp);
-       lp += 2;
-       lpAccelTbl->tbl[i].wIDval = *((WORD *)lp);
-       lp += 2;
-       if (lpAccelTbl->tbl[i].wEvent == 0) break;
-       dprintf_accel(stddeb,
-               "Accelerator #%u / event=%04X id=%04X type=%02X \n", 
-               i, lpAccelTbl->tbl[i].wEvent, lpAccelTbl->tbl[i].wIDval, 
-               lpAccelTbl->tbl[i].type);
-       lpAccelTbl->wCount++;
-       }
-    GlobalUnlock16(hAccel);
-    FreeResource( rsc_mem );
-    return hAccel;
-#else
-       fprintf(stderr,"LoadAcceleratorsW: not implemented\n");
-       return 0x100;  /* Return something anyway */
-#endif
-}
-
-HANDLE32 WIN32_LoadAcceleratorsA(HINSTANCE instance, LPCSTR lpTableName)
-{
-       LPWSTR          uni;
-       HANDLE32        result;
-       if (HIWORD(lpTableName))
-               uni=STRING32_DupAnsiToUni(lpTableName);
-       else
-               uni=(LPWSTR)lpTableName;
-       result=WIN32_LoadAcceleratorsW(instance,uni);
-       if (HIWORD(uni))
-               free(uni);
-       return result;
-}
-\f
-/**********************************************************************
- *                                     LoadString
- */
-int
-WIN32_LoadStringW(HINSTANCE instance, DWORD resource_id, LPWSTR buffer, int buflen)
-{
-    HANDLE32 hmem, hrsrc;
-    WCHAR *p;
-    int string_num;
-    int i;
-
-    dprintf_resource(stddeb, "LoadString: instance = %04x, id = %04x, buffer = %08x, "
-          "length = %d\n", instance, (int)resource_id, (int) buffer, buflen);
-
-    hrsrc = FindResource32W( instance, (LPCWSTR)((resource_id>>4)+1), 
-               (LPCWSTR)RT_STRING );
-    if (!hrsrc) return 0;
-    hmem = LoadResource32( instance, hrsrc );
-    if (!hmem) return 0;
-    
-    p = LockResource32(hmem);
-    string_num = resource_id & 0x000f;
-    for (i = 0; i < string_num; i++)
-       p += *p + 1;
-    
-    dprintf_resource( stddeb, "strlen = %d\n", (int)*p );
-    
-    i = MIN(buflen - 1, *p);
-    if (buffer == NULL)
-       return i;
-    if (i > 0) {
-       memcpy(buffer, p + 1, i * sizeof (WCHAR));
-       buffer[i] = (WCHAR) 0;
-    } else {
-       if (buflen > 1) {
-           buffer[0] = (WCHAR) 0;
-           return 0;
-       }
-#if 0
-       fprintf(stderr,"LoadString // I dont know why , but caller give buflen=%d *p=%d !\n", buflen, *p);
-       fprintf(stderr,"LoadString // and try to obtain string '%s'\n", p + 1);
-#endif
-    }
-    dprintf_resource(stddeb,"LoadString // '%s' copied !\n", buffer);
-    return i;
-}
-\f
-/**********************************************************************
- *                                     LoadStringA
- */
-int
-WIN32_LoadStringA(HINSTANCE instance, DWORD resource_id, LPSTR buffer, int buflen)
-{
-    WCHAR *buffer2 = xmalloc(buflen*2);
-    int retval = WIN32_LoadStringW(instance, resource_id, buffer2, buflen);
-
-    while (*buffer2) 
-       *buffer++ = (char) *buffer2++;
-    *buffer = 0;
-    return retval;
-}
-
-HICON LoadIconW32(HINSTANCE hisnt, LPCWSTR lpszIcon)
-
-{
-       return LoadIcon(0, IDI_APPLICATION);
-}
-
-HICON LoadIconA32(HINSTANCE hinst, LPCSTR lpszIcon)
-
-{
-       return LoadIconW32(hinst, lpszIcon);
-}
-/**********************************************************************
- *         LoadBitmapW
- */
-HBITMAP WIN32_LoadBitmapW( HANDLE instance, LPCWSTR name )
-{
-    HBITMAP hbitmap = 0;
-    HDC hdc;
-    HANDLE32 hRsrc;
-    HANDLE32 handle;
-    BITMAPINFO *info;
-
-    if (!instance)  /* OEM bitmap */
-    {
-        if (HIWORD((int)name)) return 0;
-        return OBM_LoadBitmap( LOWORD((int)name) );
-    }
-
-    if (!(hRsrc = FindResource32W( instance, name, 
-               (LPWSTR)RT_BITMAP ))) return 0;
-    if (!(handle = LoadResource32( instance, hRsrc ))) return 0;
-
-    info = (BITMAPINFO *)LockResource32( handle );
-    if ((hdc = GetDC(0)) != 0)
-    {
-        char *bits = (char *)info + DIB_BitmapInfoSize( info, DIB_RGB_COLORS );
-        hbitmap = CreateDIBitmap( hdc, &info->bmiHeader, CBM_INIT,
-                                  bits, info, DIB_RGB_COLORS );
-        ReleaseDC( 0, hdc );
-    }
-    return hbitmap;
-}
-/**********************************************************************
- *         LoadBitmapA
- */
-HBITMAP WIN32_LoadBitmapA( HANDLE instance, LPCSTR name )
-{
-    HBITMAP res;
-    if(!HIWORD(name))
-        res = WIN32_LoadBitmapW(instance,(LPWSTR)name);
-    else{
-        LPWSTR uni=STRING32_DupAnsiToUni(name);
-        res=WIN32_LoadBitmapW(instance,uni);
-        free(uni);
-    }
-    return res;
-}
-
-/*****************************************************************
- *        LoadMenuW                 (USER32.372)
- */
-HMENU WIN32_LoadMenuW(HANDLE instance, LPCWSTR name)
-{
-       HANDLE32 hrsrc;
-       hrsrc=FindResource32W(instance,name,(LPWSTR)RT_MENU);
-       if(!hrsrc)return 0;
-        return LoadMenuIndirect32W( LoadResource32(instance, hrsrc) );
-}
-
-/*****************************************************************
- *        LoadMenuA                 (USER32.370)
- */
-HMENU WIN32_LoadMenuA(HANDLE instance,LPCSTR name)
-{
-       HMENU res;
-       if(!HIWORD(name))
-               res = WIN32_LoadMenuW(instance,(LPWSTR)name);
-       else{
-               LPWSTR uni=STRING32_DupAnsiToUni(name);
-               res=WIN32_LoadMenuW(instance,uni);
-               free(uni);
-       }
-       return res;
-}
index 15047e9019c250b83d9d533c13af70d2a0cded0b..629a75a0ef8f1b42e08e598321883c94220bcfde 100644 (file)
@@ -160,3 +160,29 @@ void STRUCT32_CREATESTRUCT16to32A( const CREATESTRUCT16* from,
     to->style          = from->style;
     to->dwExStyle      = from->dwExStyle;
 }
+
+/* The strings are not copied */
+void STRUCT32_MDICREATESTRUCT32Ato16( const MDICREATESTRUCT32A* from,
+                                      MDICREATESTRUCT16* to )
+{
+    to->hOwner = (HINSTANCE16)from->hOwner;
+    to->x      = (INT16)from->x;     
+    to->y      = (INT16)from->y;     
+    to->cx     = (INT16)from->cx;    
+    to->cy     = (INT16)from->cy;    
+    to->style  = from->style; 
+    to->lParam = from->lParam;
+}
+
+void STRUCT32_MDICREATESTRUCT16to32A( const MDICREATESTRUCT16* from,
+                                      MDICREATESTRUCT32A *to )
+{
+    to->hOwner = (HINSTANCE32)from->hOwner;
+    to->x      = (INT32)from->x;     
+    to->y      = (INT32)from->y;     
+    to->cx     = (INT32)from->cx;    
+    to->cy     = (INT32)from->cy;    
+    to->style  = from->style; 
+    to->lParam = from->lParam;
+}
+
index 00e5daa091ae1b2ff7009e711f802e984ed0a2f3..1d539dc1c17db771437bda9e2a0233938ed558e2 100644 (file)
@@ -70,6 +70,7 @@ void DeleteCriticalSection(CRITICAL_SECTION* lpCrit)
 
 /***********************************************************************
  *           Tls is available only for the single thread
+ * (BTW: TLS means Thread Local Storage)
  */
 static LPVOID* Tls=0;
 static int TlsCount=0;
@@ -104,14 +105,15 @@ LPVOID TlsGetValue(DWORD index)
        return Tls[index];
 }
 
-void TlsSetValue(DWORD index,LPVOID value)
+BOOL32 TlsSetValue(DWORD index,LPVOID value)
 {
        if(index>=TlsCount)
        {
                /* FIXME: Set last error*/
-               return;
+               return FALSE;
        }
        Tls[index]=value;
+       return TRUE;
 }
 
 /* FIXME: This is required to work cross-addres space as well */
index 4756a3116aaf658a1d267682caaeddae8a72f3a8..3ac2e9c7d2afa4db8dc215a172f536e355dd0478 100644 (file)
@@ -134,7 +134,7 @@ BOOL32 SetTimeZoneInformation(const TIME_ZONE_INFORMATION *tzinfo)
  */
 VOID Sleep(DWORD cMilliseconds)
 {
-    if(cMilliseconds == INFINITE)
+    if(cMilliseconds == INFINITE32)
         while(1) sleep(1000); /* Spin forever */
     usleep(cMilliseconds*1000);
 }
index 6b1e455aa106a167024b7a4045c8a1936ac5821e..4451e2a572235d8d763b255c44999f7c4e49bfbb 100644 (file)
@@ -16,7 +16,6 @@
 #include "xmalloc.h"
 #include "handle32.h"
 #include "struct32.h"
-#include "resource32.h"
 #include "string32.h"
 #include "win.h"
 #include "debug.h"
index 9cb660797c7da83ad37dc37803d7f760f3d4f4f4..af47d45db8656ad19117a077a629b15267871e32 100644 (file)
@@ -1,3 +1,4 @@
+DEFS   = -D__WINE__
 TOPSRC = @top_srcdir@
 MODULE = windows
 
index ae75f003d45e724b9eea84d6a030b320d91ce5e3..80b6cc98c5a19904ef9c144a21ffac31923a2235 100644 (file)
@@ -215,13 +215,15 @@ CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE16 hinstance )
 {
     CLASS * class;
 
+    if (hinstance != 0xffff) hinstance = GetExePtr(hinstance);
+
       /* First search task-specific classes */
 
     for (class = firstClass; (class); class = class->next)
     {
         if (class->style & CS_GLOBALCLASS) continue;
         if ((class->atomName == atom) && 
-            ((hinstance==(HINSTANCE16)0xffff) ||
+            ((hinstance == 0xffff) ||
              (hinstance == class->hInstance))) return class;
     }
     
index f334bb9a706dc08780144af02e71309f8c53952a..97fc7f5e978bd233de685ce4c12e0d2692261413 100644 (file)
@@ -15,7 +15,6 @@
  * DCX_WINDOWPAINT - BeginPaint specific flag
  */
 
-#include "options.h"
 #include "dce.h"
 #include "class.h"
 #include "win.h"
@@ -118,6 +117,22 @@ HANDLE DCE_FindDCE(HDC hDC)
  return hdce;
 }
 
+/**********************************************************************
+ *         DCE_hDC2hWnd
+ */
+HWND DCE_hDC2hWnd(HDC hDC)
+{
+ HANDLE hdce = DCE_FindDCE(hDC); 
+
+ if( hdce )
+   {
+     DCE* dce = (DCE *) USER_HEAP_LIN_ADDR(hdce);
+     return dce->hwndCurrent;
+   }
+
+ return 0;
+}
+
 /***********************************************************************
  *   DCE_InvalidateDCE
  *
@@ -505,7 +520,8 @@ HDC GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
         }
            /* optimize away GetVisRgn for desktop if it isn't there */
 
-      else if( hwnd==GetDesktopWindow() && !Options.desktopGeometry ) 
+      else if ((hwnd == GetDesktopWindow()) &&
+               (rootWindow == DefaultRootWindow(display)))
               hrgnVisible = CreateRectRgn( 0, 0, SYSMETRICS_CXSCREEN,
                                                   SYSMETRICS_CYSCREEN);
       else hrgnVisible = DCE_GetVisRgn( hwnd, flags );
@@ -602,6 +618,7 @@ int ReleaseDC( HWND hwnd, HDC hdc )
     {
        SetDCState( dce->hDC, defaultDCstate );
        dce->DCXflags = DCX_CACHE;
+       dce->hwndCurrent = 0;
     }
     return 1;
 }
index 7d63ce10ab7613f41301a40ef65a8b3cf717fb50..87dc7d487a8b49ef160a32948026deb6b16f77c2 100644 (file)
@@ -322,7 +322,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT32 msg, WPARAM32 wParam,
             HICON hI = 0;
             UINT16 len = 1;
             while(len < 64)
-               if( (hI = LoadIcon(wndPtr->hInstance,MAKEINTRESOURCE(len))) )
+               if( (hI = LoadIcon16(wndPtr->hInstance,MAKEINTRESOURCE(len))) )
                     return (LRESULT)hI;
         }
         break;
index 7e86721526c8568cdc94d26a0824518bd826900a..bdd46a30c060b3272b6cf897be360662a1957106 100644 (file)
@@ -12,7 +12,6 @@
 #include "heap.h"
 #include "win.h"
 #include "ldt.h"
-#include "resource32.h"
 #include "stackframe.h"
 #include "string32.h"
 #include "user.h"
@@ -498,7 +497,7 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
     if (template.menuName)
     {
         LPSTR str = SEGPTR_STRDUP( template.menuName );  /* FIXME: win32 */
-        hMenu = LoadMenu( hInst, SEGPTR_GET(str) );
+        hMenu = LoadMenu16( hInst, SEGPTR_GET(str) );
         SEGPTR_FREE( str );
     }
 
@@ -508,7 +507,7 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
     {
           /* The font height must be negative as it is a point size */
           /* (see CreateFont() documentation in the Windows SDK).   */
-       hFont = CreateFont( -template.pointSize, 0, 0, 0, FW_DONTCARE,
+       hFont = CreateFont16( -template.pointSize, 0, 0, 0, FW_DONTCARE,
                            FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
                            DEFAULT_QUALITY, FF_DONTCARE,
                             template.faceName );  /* FIXME: win32 */
@@ -631,12 +630,12 @@ HWND16 CreateDialogParam16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
     dprintf_dialog(stddeb, "CreateDialogParam16: %04x,%08lx,%04x,%08lx,%ld\n",
                    hInst, (DWORD)dlgTemplate, owner, (DWORD)dlgProc, param );
 
-    if (!(hRsrc = FindResource( hInst, dlgTemplate, RT_DIALOG ))) return 0;
-    if (!(hmem = LoadResource( hInst, hRsrc ))) return 0;
-    if (!(data = LockResource( hmem ))) hwnd = 0;
+    if (!(hRsrc = FindResource16( hInst, dlgTemplate, RT_DIALOG ))) return 0;
+    if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
+    if (!(data = LockResource16( hmem ))) hwnd = 0;
     else hwnd = CreateDialogIndirectParam16( hInst, data, owner,
                                              dlgProc, param );
-    FreeResource( hmem );
+    FreeResource16( hmem );
     return hwnd;
 }
 
@@ -666,7 +665,8 @@ HWND32 CreateDialogParam32W( HINSTANCE32 hInst, LPCWSTR name,
 {
     HANDLE32 hrsrc = FindResource32W( hInst, name, (LPWSTR)RT_DIALOG );
     if (!hrsrc) return 0;
-    return CreateDialogIndirectParam32W( hInst, LoadResource32( hInst, hrsrc ),
+    return CreateDialogIndirectParam32W( hInst,
+                                         (LPVOID)LoadResource32(hInst, hrsrc),
                                          owner, dlgProc, param );
 }
 
index cf14d07fa72fac095494575933507f7c19726db8..e6a053b5ddb0fa1dd149679a9dee3695dfa43a77 100644 (file)
@@ -8,6 +8,7 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include <unistd.h>
 #include <sys/time.h>
 #include <sys/types.h>
@@ -872,7 +873,7 @@ HWND GetCapture()
 /***********************************************************************
  *           GetMouseEventProc   (USER.337)
  */
-FARPROC GetMouseEventProc(void)
+FARPROC16 GetMouseEventProc(void)
 {
     HMODULE16 hmodule = GetModuleHandle("USER");
     return MODULE_GetEntryPoint( hmodule,
index f31f73e7919ab5c94cfc6b31b124532eb8c61e63..1c2802587a6aaee63c209bf551923bda57000174 100644 (file)
@@ -19,6 +19,7 @@ static HWND hwndFocus = 0;
  *               FOCUS_SetXFocus
  *
  * Set the X focus.
+ * Explicit colormap management seems to work only with OLVWM.
  */
 static void FOCUS_SetXFocus( HWND hwnd )
 {
@@ -31,8 +32,8 @@ static void FOCUS_SetXFocus( HWND hwnd )
 
     if (!hwnd) /* If setting the focus to 0, uninstall the colormap */
     {
-       if (COLOR_WinColormap != DefaultColormapOfScreen(screen))
-           XUninstallColormap( display, COLOR_WinColormap );
+       if (COLOR_GetSystemPaletteFlags() & COLOR_PRIVATE)
+           XUninstallColormap( display, COLOR_GetColormap() );
        return;
     }
 
@@ -42,9 +43,10 @@ static void FOCUS_SetXFocus( HWND hwnd )
     if (!XGetWindowAttributes( display, win, &win_attr ) ||
         (win_attr.map_state != IsViewable))
         return;  /* If window is not viewable, don't change anything */
+
     XSetInputFocus( display, win, RevertToParent, CurrentTime );
-    if (COLOR_WinColormap != DefaultColormapOfScreen(screen))
-       XInstallColormap( display, COLOR_WinColormap );
+    if (COLOR_GetSystemPaletteFlags() & COLOR_PRIVATE)
+        XInstallColormap( display, COLOR_GetColormap() );
 }
 
 /*****************************************************************
index f1cb9e7a4fdc452a00193af4fcb3009d6b0376e0..ef7806de652ea55df6b4eb9c2391338502408299 100644 (file)
@@ -18,6 +18,7 @@
 #include "metafile.h"
 #include "syscolor.h"
 #include "stddebug.h"
+#include "palette.h"
 #include "color.h"
 #include "region.h"
 #include "debug.h"
@@ -551,7 +552,6 @@ INT32 FrameRect32( HDC32 hdc, const RECT32 *rect, HBRUSH32 hbrush )
 COLORREF SetPixel( HDC hdc, short x, short y, COLORREF color )
 {
     Pixel pixel;
-    PALETTEENTRY entry;
     
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) 
@@ -570,12 +570,9 @@ COLORREF SetPixel( HDC hdc, short x, short y, COLORREF color )
     XSetFunction( display, dc->u.x.gc, GXcopy );
     XDrawPoint( display, dc->u.x.drawable, dc->u.x.gc, x, y );
 
-    if (screenDepth <= 8)
-    {
-        GetPaletteEntries( dc->w.hPalette, pixel, 1, &entry );
-        return RGB( entry.peRed, entry.peGreen, entry.peBlue );
-    }
-    else return (COLORREF)pixel;
+    /* inefficient but simple... */
+
+    return COLOR_ToLogical(pixel);
 }
 
 
@@ -584,9 +581,7 @@ COLORREF SetPixel( HDC hdc, short x, short y, COLORREF color )
  */
 COLORREF GetPixel( HDC hdc, short x, short y )
 {
-    PALETTEENTRY entry;
     XImage * image;
-    WORD * mapping;
     int pixel;
 
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
@@ -605,11 +600,7 @@ COLORREF GetPixel( HDC hdc, short x, short y )
     pixel = XGetPixel( image, 0, 0 );
     XDestroyImage( image );
     
-    if (screenDepth > 8) return pixel;
-    mapping = (WORD *) GDI_HEAP_LIN_ADDR( dc->u.x.pal.hRevMapping );
-    if (mapping) pixel = mapping[pixel];
-    GetPaletteEntries( dc->w.hPalette, pixel, 1, &entry );
-    return RGB( entry.peRed, entry.peGreen, entry.peBlue );
+    return COLOR_ToLogical(pixel);
 }
 
 
index 9ea7c9ea91326ca0a90d05e7c623e33ae3b33cde..aa616c5bb977f3c87b616d2ebcbdcddebe0d453a 100644 (file)
  * Warning!
  * A HHOOK is a 32-bit handle for compatibility with Windows 3.0 where it was
  * a pointer to the next function. Now it is in fact composed of a USER heap
- * handle in the low 16 bits and of a HOOK_MAGIC value in the high 16 bits
- * (except for WINELIB32 where it is a 32-bit handle).  -- AJ
+ * handle in the low 16 bits and of a HOOK_MAGIC value in the high 16 bits.
  */
 
+#define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include "hook.h"
 #include "queue.h"
 #include "user.h"
@@ -29,7 +29,7 @@ static HANDLE16 HOOK_systemHooks[WH_NB_HOOKS] = { 0, };
  *
  * Get the next hook of a given hook.
  */
-static HANDLE HOOK_GetNextHook( HANDLE hook )
+static HANDLE16 HOOK_GetNextHook( HANDLE16 hook )
 {
     HOOKDATA *data = (HOOKDATA *)USER_HEAP_LIN_ADDR( hook );
     if (!data || !hook) return 0;
@@ -45,10 +45,10 @@ static HANDLE HOOK_GetNextHook( HANDLE hook )
  *
  * Get the first hook for a given type.
  */
-HANDLE HOOK_GetHook( short id , HQUEUE hQueue )
+HANDLE16 HOOK_GetHook( INT16 id , HQUEUE16 hQueue )
 {
     MESSAGEQUEUE *queue;
-    HANDLE hook = 0;
+    HANDLE16 hook = 0;
 
     if ((queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(hQueue) )) != NULL)
         hook = queue->hooks[id - WH_FIRST_HOOK];
@@ -62,17 +62,18 @@ HANDLE HOOK_GetHook( short id , HQUEUE hQueue )
  *
  * Install a given hook.
  */
-HANDLE HOOK_SetHook( short id, HOOKPROC proc, HINSTANCE hInst, HTASK hTask )
+static HANDLE16 HOOK_SetHook( INT16 id, HOOKPROC16 proc, HINSTANCE16 hInst,
+                              HTASK16 hTask )
 {
     HOOKDATA *data;
-    HANDLE handle;
-    HQUEUE hQueue = 0;
+    HANDLE16 handle;
+    HQUEUE16 hQueue = 0;
 
     if ((id < WH_FIRST_HOOK) || (id > WH_LAST_HOOK)) return 0;
     if (!(hInst = GetExePtr( hInst ))) return 0;
 
-    dprintf_hook( stddeb, "Setting hook %d: %08lx %04x %04x\n",
-                  id, (DWORD)proc, hInst, hTask );
+    dprintf_hook( stddeb, "Setting hook %d: %08x %04x %04x\n",
+                  id, (UINT32)proc, hInst, hTask );
 
     if (hTask)  /* Task-specific hook */
     {
@@ -90,7 +91,7 @@ HANDLE HOOK_SetHook( short id, HOOKPROC proc, HINSTANCE hInst, HTASK hTask )
 
     /* Create the hook structure */
 
-    if (!(handle = (HANDLE)USER_HEAP_ALLOC( sizeof(HOOKDATA) ))) return 0;
+    if (!(handle = USER_HEAP_ALLOC( sizeof(HOOKDATA) ))) return 0;
     data = (HOOKDATA *) USER_HEAP_LIN_ADDR( handle );
     data->proc        = proc;
     data->id          = id;
@@ -121,7 +122,7 @@ HANDLE HOOK_SetHook( short id, HOOKPROC proc, HINSTANCE hInst, HTASK hTask )
  *
  * Remove a hook from the list.
  */
-static BOOL HOOK_RemoveHook( HANDLE hook )
+static BOOL32 HOOK_RemoveHook( HANDLE16 hook )
 {
     HOOKDATA *data;
     HANDLE16 *prevHook;
@@ -133,7 +134,7 @@ static BOOL HOOK_RemoveHook( HANDLE hook )
     {
         /* Mark it for deletion later on */
         dprintf_hook( stddeb, "Hook still running, deletion delayed\n" );
-        data->proc = (FARPROC)0;
+        data->proc = (HOOKPROC16)0;
         return TRUE;
     }
 
@@ -162,13 +163,13 @@ static BOOL HOOK_RemoveHook( HANDLE hook )
  *
  * Call a hook procedure.
  */
-static DWORD HOOK_CallHook( HANDLE hook, short code,
-                            WPARAM wParam, LPARAM lParam )
+static LRESULT HOOK_CallHook( HANDLE16 hook, INT16 code,
+                              WPARAM16 wParam, LPARAM lParam )
 {
     HOOKDATA *data;
     MESSAGEQUEUE *queue;
-    HANDLE prevHook;
-    DWORD ret;
+    HANDLE16 prevHook;
+    LRESULT ret;
 
     /* Find the first hook with a valid proc */
 
@@ -204,9 +205,9 @@ static DWORD HOOK_CallHook( HANDLE hook, short code,
  *
  * Call a hook chain.
  */
-DWORD HOOK_CallHooks( short id, short code, WPARAM wParam, LPARAM lParam )
+LRESULT HOOK_CallHooks( INT16 id, INT16 code, WPARAM16 wParam, LPARAM lParam )
 {
-    HANDLE hook = HOOK_GetHook( id , 0 );
+    HANDLE16 hook = HOOK_GetHook( id , 0 );
     if (!hook) return 0;
     return HOOK_CallHook( hook, code, wParam, lParam );
 }
@@ -273,35 +274,31 @@ void HOOK_FreeQueueHooks( HQUEUE16 hQueue )
 /***********************************************************************
  *           SetWindowsHook   (USER.121)
  */
-FARPROC SetWindowsHook( short id, HOOKPROC proc )
+FARPROC16 SetWindowsHook( INT16 id, HOOKPROC16 proc )
 {
 #ifdef WINELIB
-    HINSTANCE hInst = 0;
+    HINSTANCE16 hInst = 0;
 #else
-    HINSTANCE hInst = FarGetOwner( HIWORD(proc) );
+    HINSTANCE16 hInst = FarGetOwner( HIWORD(proc) );
 #endif
     /* WH_MSGFILTER is the only task-specific hook for SetWindowsHook() */
-    HTASK hTask = (id == WH_MSGFILTER) ? GetCurrentTask() : 0;
+    HTASK16 hTask = (id == WH_MSGFILTER) ? GetCurrentTask() : 0;
 
-    HANDLE handle = HOOK_SetHook( id, proc, hInst, hTask );
-    if (!handle) return (FARPROC)-1;
+    HANDLE16 handle = HOOK_SetHook( id, proc, hInst, hTask );
+    if (!handle) return (FARPROC16)-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 */
-#ifdef WINELIB32
-    return (FARPROC)handle;
-#else
-    return (FARPROC)MAKELONG( handle, HOOK_MAGIC );
-#endif
+    return (FARPROC16)MAKELONG( handle, HOOK_MAGIC );
 }
 
 
 /***********************************************************************
  *           UnhookWindowsHook   (USER.234)
  */
-BOOL UnhookWindowsHook( short id, HOOKPROC proc )
+BOOL16 UnhookWindowsHook( INT16 id, HOOKPROC16 proc )
 {
-    HANDLE hook = HOOK_GetHook( id , 0 );
+    HANDLE16 hook = HOOK_GetHook( id , 0 );
 
     dprintf_hook( stddeb, "UnhookWindowsHook: %d %08lx\n", id, (DWORD)proc );
 
@@ -319,12 +316,12 @@ BOOL UnhookWindowsHook( short id, HOOKPROC proc )
 /***********************************************************************
  *           DefHookProc   (USER.235)
  */
-DWORD DefHookProc( short code, WORD wParam, DWORD lParam, HHOOK *hhook )
+LRESULT DefHookProc( INT16 code, WPARAM16 wParam, LPARAM lParam, HHOOK *hhook )
 {
     /* Note: the *hhook parameter is never used, since we rely on the
      * current hook value from the task queue to find the next hook. */
     MESSAGEQUEUE *queue;
-    HANDLE next;
+    HANDLE16 next;
 
     if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0;
     if (!(next = HOOK_GetNextHook( queue->hCurHook ))) return 0;
@@ -335,9 +332,9 @@ DWORD DefHookProc( short code, WORD wParam, DWORD lParam, HHOOK *hhook )
 /***********************************************************************
  *           CallMsgFilter   (USER.123)
  */
-BOOL CallMsgFilter( SEGPTR msg, INT code )
+BOOL16 CallMsgFilter( SEGPTR msg, INT16 code )
 {
-    if (GetSysModalWindow()) return FALSE;
+    if (GetSysModalWindow16()) return FALSE;
     if (HOOK_CallHooks( WH_SYSMSGFILTER, code, 0, (LPARAM)msg )) return TRUE;
     return HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)msg );
 }
@@ -346,42 +343,31 @@ BOOL CallMsgFilter( SEGPTR msg, INT code )
 /***********************************************************************
  *           SetWindowsHookEx   (USER.291)
  */
-HHOOK SetWindowsHookEx( short id, HOOKPROC proc, HINSTANCE hInst, HTASK hTask )
+HHOOK SetWindowsHookEx( INT16 id, HOOKPROC16 proc, HINSTANCE16 hInst,
+                        HTASK16 hTask )
 {
-    HANDLE handle = HOOK_SetHook( id, proc, hInst, hTask );
-#ifdef WINELIB32
-    return (HHOOK)handle;
-#else
+    HANDLE16 handle = HOOK_SetHook( id, proc, hInst, hTask );
     return MAKELONG( handle, HOOK_MAGIC );
-#endif
 }
 
 
 /***********************************************************************
  *           UnhookWindowHookEx   (USER.292)
  */
-BOOL UnhookWindowsHookEx( HHOOK hhook )
+BOOL16 UnhookWindowsHookEx( HHOOK hhook )
 {
-#ifdef WINELIB32
-    return HOOK_RemoveHook( (HANDLE)hhook );
-#else
     if (HIWORD(hhook) != HOOK_MAGIC) return FALSE;  /* Not a new format hook */
     return HOOK_RemoveHook( LOWORD(hhook) );
-#endif
 }
 
 
 /***********************************************************************
  *           CallNextHookEx   (USER.293)
  */
-LRESULT CallNextHookEx( HHOOK hhook, INT code, WPARAM wParam, LPARAM lParam )
+LRESULT CallNextHookEx(HHOOK hhook, INT16 code, WPARAM16 wParam, LPARAM lParam)
 {
-    HANDLE next;
-#ifdef WINELIB32
-    if (!(next = HOOK_GetNextHook( (HANDLE)hhook ))) return 0;
-#else
+    HANDLE16 next;
     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 );
 }
index 01b0fcf4b8ff858cc20e07f1d6e80f9edeb6b747..5f536919adcc761ae3ee9a51d3d60afa49a322c3 100644 (file)
@@ -354,16 +354,31 @@ HWND MDICreateChild(WND *w, MDICLIENTINFO *ci, HWND parent, LPARAM lParam )
                   WS_CLIPCHILDREN | WS_DISABLED | WS_VSCROLL | WS_HSCROLL );
         style |= (WS_VISIBLE | WS_OVERLAPPEDWINDOW);
       }
+
     hwnd = CreateWindow16( (LPCSTR)PTR_SEG_TO_LIN(cs->szClass),
                            (LPCSTR)PTR_SEG_TO_LIN(cs->szTitle), style, 
                          cs->x, cs->y, cs->cx, cs->cy, parent, 
                          (HMENU)(DWORD)(WORD)wIDmenu, w->hInstance, 
                         (LPVOID)lParam);
 
+    /* MDI windows are WS_CHILD so they won't be activated by CreateWindow */
+
     if (hwnd)
     {
+       WND* wnd = WIN_FindWndPtr( hwnd );
+
        MDI_MenuModifyItem(w ,hwnd); 
+       if( wnd->dwStyle & WS_MINIMIZE && ci->hwndActiveChild )
+           ShowWindow( hwnd, SW_SHOWMINNOACTIVE );
+       else
+         {
+           SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE );
+           if( wnd->dwStyle & WS_MAXIMIZE )
+             {
+                MDI_AugmentFrameMenu( ci, w->parent, hwnd );
+                MDI_UpdateFrameText( w->parent, ci->self, MDI_REPAINTFRAME, NULL ); 
+             }
+         }
         dprintf_mdi(stddeb, "MDICreateChild: created child - %04x\n",hwnd);
     }
     else
@@ -517,13 +532,15 @@ LONG MDI_ChildActivate(WND *clientPtr, HWND hWndChild)
     if( wndPrev )
     {
        SendMessage16( prevActiveWnd, WM_NCACTIVATE, FALSE, 0L );
+
 #ifdef WINELIB32
         SendMessage32A( prevActiveWnd, WM_MDIACTIVATE, (WPARAM)prevActiveWnd, 
                         (LPARAM)hWndChild);
-#else
+#else 
+
         SendMessage16( prevActiveWnd, WM_MDIACTIVATE, FALSE,
                        MAKELONG(hWndChild,prevActiveWnd));
-#endif
+#endif 
         /* uncheck menu item */
                if( clientInfo->hWindowMenu )
                        CheckMenuItem( clientInfo->hWindowMenu,
@@ -575,7 +592,7 @@ LONG MDI_ChildActivate(WND *clientPtr, HWND hWndChild)
                     (LPARAM)prevActiveWnd );
 #else
     SendMessage16( hWndChild, WM_MDIACTIVATE, TRUE,
-                   MAKELONG(prevActiveWnd,hWndChild) );
+                   MAKELONG(hWndChild,prevActiveWnd));
 #endif
 
     return 1;
@@ -641,8 +658,8 @@ HBITMAP CreateMDIMenuBitmap(void)
 {
  HDC           hDCSrc  = CreateCompatibleDC(0);
  HDC           hDCDest = CreateCompatibleDC(hDCSrc);
- HBITMAP       hbClose = LoadBitmap(0, MAKEINTRESOURCE(OBM_CLOSE) );
- HBITMAP       hbCopy,hb_src,hb_dest;
+ HBITMAP16     hbClose = LoadBitmap16(0, MAKEINTRESOURCE(OBM_CLOSE) );
+ HBITMAP16     hbCopy,hb_src,hb_dest;
 
  hb_src = SelectObject(hDCSrc,hbClose);
  hbCopy = CreateCompatibleBitmap(hDCSrc,SYSMETRICS_CXSIZE, SYSMETRICS_CYSIZE);
@@ -984,7 +1001,7 @@ LRESULT MDIClientWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
        if (!hBmpClose)
         {
             hBmpClose = CreateMDIMenuBitmap();
-            hBmpRestore = LoadBitmap( 0, MAKEINTRESOURCE(OBM_RESTORE) );
+            hBmpRestore = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE) );
         }
        MDI_UpdateFrameText(frameWnd, hwnd, MDI_NOFRAMEREPAINT,frameWnd->text);
 
@@ -1371,6 +1388,8 @@ LRESULT DefMDIChildProc16( HWND16 hwnd, UINT16 message,
               SendMessage16( hMaxChild, WM_SETREDRAW, TRUE, 0L );
              }
 
+           dprintf_mdi(stddeb,"\tMDI: maximizing child %04x\n", hwnd );
+
            ci->hwndChildMaximized = hwnd; /* !!! */
 
            MDI_AugmentFrameMenu( ci, clientWnd->parent, hwnd);
index ca18764a93beb814cc80a9b30581ae8b4751566e..bc739850cb318da8658e32bf9ff5c52a607779a5 100644 (file)
@@ -65,20 +65,20 @@ LRESULT SystemMessageBoxProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
     switch(lpmb->type & MB_ICONMASK) {
      case MB_ICONEXCLAMATION:
       SendDlgItemMessage16(hwnd, stc1, STM_SETICON, 
-                           (WPARAM)LoadIcon(0, IDI_EXCLAMATION), 0);
+                           (WPARAM)LoadIcon16(0, IDI_EXCLAMATION), 0);
       break;
      case MB_ICONQUESTION:
       SendDlgItemMessage16(hwnd, stc1, STM_SETICON, 
-                           (WPARAM)LoadIcon(0, IDI_QUESTION), 0);
+                           (WPARAM)LoadIcon16(0, IDI_QUESTION), 0);
       break;
      case MB_ICONASTERISK:
       SendDlgItemMessage16(hwnd, stc1, STM_SETICON, 
-                           (WPARAM)LoadIcon(0, IDI_ASTERISK), 0);
+                           (WPARAM)LoadIcon16(0, IDI_ASTERISK), 0);
       break;
      case MB_ICONHAND:
      default:
       SendDlgItemMessage16(hwnd, stc1, STM_SETICON, 
-                           (WPARAM)LoadIcon(0, IDI_HAND), 0);
+                           (WPARAM)LoadIcon16(0, IDI_HAND), 0);
       break;
     }
     
index 4d4751d4f527ec53e11c0e6c9a3edc83780c51e7..084632507076958286ae3240f158f6ac4148a2a9 100644 (file)
@@ -589,14 +589,14 @@ static void NC_DrawCaption( HDC hdc, RECT16 *rect, HWND hwnd,
 
     if (!hbitmapClose)
     {
-       if (!(hbitmapClose = LoadBitmap( 0, MAKEINTRESOURCE(OBM_CLOSE) )))
+       if (!(hbitmapClose = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_CLOSE) )))
            return;
-       hbitmapMinimize  = LoadBitmap( 0, MAKEINTRESOURCE(OBM_REDUCE) );
-       hbitmapMinimizeD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_REDUCED) );
-       hbitmapMaximize  = LoadBitmap( 0, MAKEINTRESOURCE(OBM_ZOOM) );
-       hbitmapMaximizeD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_ZOOMD) );
-       hbitmapRestore   = LoadBitmap( 0, MAKEINTRESOURCE(OBM_RESTORE) );
-       hbitmapRestoreD  = LoadBitmap( 0, MAKEINTRESOURCE(OBM_RESTORED) );
+       hbitmapMinimize  = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCE) );
+       hbitmapMinimizeD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_REDUCED) );
+       hbitmapMaximize  = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOM) );
+       hbitmapMaximizeD = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_ZOOMD) );
+       hbitmapRestore   = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE) );
+       hbitmapRestoreD  = LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORED) );
     }
     
     if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)
@@ -822,23 +822,23 @@ LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam )
 
     case HTLEFT:
     case HTRIGHT:
-       return (LONG)SetCursor( LoadCursor( 0, IDC_SIZEWE ) );
+       return (LONG)SetCursor( LoadCursor16( 0, IDC_SIZEWE ) );
 
     case HTTOP:
     case HTBOTTOM:
-       return (LONG)SetCursor( LoadCursor( 0, IDC_SIZENS ) );
+       return (LONG)SetCursor( LoadCursor16( 0, IDC_SIZENS ) );
 
     case HTTOPLEFT:
     case HTBOTTOMRIGHT:        
-       return (LONG)SetCursor( LoadCursor( 0, IDC_SIZENWSE ) );
+       return (LONG)SetCursor( LoadCursor16( 0, IDC_SIZENWSE ) );
 
     case HTTOPRIGHT:
     case HTBOTTOMLEFT:
-       return (LONG)SetCursor( LoadCursor( 0, IDC_SIZENESW ) );
+       return (LONG)SetCursor( LoadCursor16( 0, IDC_SIZENESW ) );
     }
 
     /* Default cursor: arrow */
-    return (LONG)SetCursor( LoadCursor( 0, IDC_ARROW ) );
+    return (LONG)SetCursor( LoadCursor16( 0, IDC_ARROW ) );
 }
 
 
index 85ebc1737fc052ed68e8b319f252112501fde98b..1d3437e5f7adb52c0c62fd397da664166f0c94ab 100644 (file)
 
 #define MAX_QUEUE_SIZE   120  /* Max. size of a message queue */
 
-static HQUEUE hFirstQueue = 0;
-static HQUEUE hmemSysMsgQueue = 0;
+static HQUEUE16 hFirstQueue = 0;
+static HQUEUE16 hmemSysMsgQueue = 0;
 static MESSAGEQUEUE *pMouseQueue = NULL;  /* Queue for last mouse message */
 static MESSAGEQUEUE *pKbdQueue = NULL;    /* Queue for last kbd message */
-static HQUEUE hDoomedQueue = 0;
+static HQUEUE16 hDoomedQueue = 0;
 static MESSAGEQUEUE *sysMsgQueue = NULL;
 
 /***********************************************************************
@@ -130,7 +130,7 @@ static HQUEUE QUEUE_CreateMsgQueue( int size )
 BOOL32 QUEUE_DeleteMsgQueue( HQUEUE16 hQueue )
 {
     MESSAGEQUEUE * msgQueue = (MESSAGEQUEUE*)GlobalLock16(hQueue);
-    HQUEUE *pPrev;
+    HQUEUE16 *pPrev;
 
     dprintf_msg(stddeb,"Deleting message queue %04x\n", hQueue);
 
@@ -401,7 +401,7 @@ static void QUEUE_WakeSomeone( UINT message )
     if ((message >= WM_KEYFIRST) && (message <= WM_KEYLAST)) wakeBit = QS_KEY;
     else wakeBit = (message == WM_MOUSEMOVE) ? QS_MOUSEMOVE : QS_MOUSEBUTTON;
 
-    if (!(hwnd = GetSysModalWindow()))
+    if (!(hwnd = GetSysModalWindow16()))
     {
         if (wakeBit == QS_KEY)
         {
index 83a8c36bf9c530f4fd131d9331661d66068dbb84..25ccc7f675942c6e66bc0fb7c7cf16562648b5b0 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <X11/Xatom.h>
 
 #include "options.h"
 #include "class.h"
@@ -601,7 +602,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCT32A *cs, ATOM classAtom,
                                  FocusChangeMask;
             win_attr.override_redirect = TRUE;
        }
-        win_attr.colormap      = COLOR_WinColormap;
+        win_attr.colormap      = COLOR_GetColormap();
         win_attr.backing_store = Options.backingstore ? WhenMapped : NotUseful;
         win_attr.save_under    = ((classPtr->style & CS_SAVEBITS) != 0);
         win_attr.cursor        = CURSORICON_XCursor;
@@ -614,6 +615,23 @@ static HWND WIN_CreateWindowEx( CREATESTRUCT32A *cs, ATOM classAtom,
        XA_WM_DELETE_WINDOW = XInternAtom( display, "WM_DELETE_WINDOW",
                                           False );
        XSetWMProtocols( display, wndPtr->window, &XA_WM_DELETE_WINDOW, 1 );
+
+        if ((wndPtr->flags & WIN_MANAGED) &&
+            (cs->dwExStyle & WS_EX_DLGMODALFRAME))
+        {
+            XSizeHints* size_hints = XAllocSizeHints();
+
+            if (size_hints)
+            {
+                size_hints->min_width = size_hints->max_width = cs->cx;
+                size_hints->min_height = size_hints->max_height = cs->cy;
+                size_hints->flags = (PSize | PMinSize | PMaxSize);
+                XSetWMSizeHints( display, wndPtr->window, size_hints,
+                                 XA_WM_NORMAL_HINTS );
+                XFree(size_hints);
+            }
+        }
+
        if (cs->hwndParent)  /* Get window owner */
        {
             Window win = WIN_GetXWindow( cs->hwndParent );
@@ -636,7 +654,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCT32A *cs, ATOM classAtom,
                        LoadMenu(cs->hInstance,(SEGPTR)classPtr->menuNameA);
 #else
             SEGPTR menuName = (SEGPTR)GetClassLong16( hwnd, GCL_MENUNAME );
-            if (menuName) cs->hMenu = LoadMenu( cs->hInstance, menuName );
+            if (menuName) cs->hMenu = LoadMenu16( cs->hInstance, menuName );
 #endif
         }
         if (cs->hMenu) SetMenu( hwnd, cs->hMenu );
@@ -1892,9 +1910,9 @@ BOOL FlashWindow(HWND hWnd, BOOL bInvert)
 
 
 /*******************************************************************
- *                     SetSysModalWindow               [USER.188]
+ *           SetSysModalWindow16   (USER.188)
  */
-HWND SetSysModalWindow(HWND hWnd)
+HWND16 SetSysModalWindow16( HWND16 hWnd )
 {
     HWND hWndOldModal = hwndSysModal;
     hwndSysModal = hWnd;
@@ -1904,13 +1922,14 @@ HWND SetSysModalWindow(HWND hWnd)
 
 
 /*******************************************************************
- *                     GetSysModalWindow               [USER.189]
+ *           GetSysModalWindow16   (USER.52)
  */
-HWND GetSysModalWindow(void)
+HWND16 GetSysModalWindow16(void)
 {
     return hwndSysModal;
 }
 
+
 /*******************************************************************
  *                     DRAG_QueryUpdate
  *
@@ -2046,7 +2065,7 @@ DWORD DragObject(HWND hwndScope, HWND hWnd, WORD wObj, HANDLE hOfStruct,
 
  if( !lpDragInfo || !spDragInfo ) return 0L;
 
- hBummer = LoadCursor(0,IDC_BUMMER);
+ hBummer = LoadCursor16(0,IDC_BUMMER);
 
  if( !hBummer || !wndPtr )
    {
index fcf56bac48cee3c4e9559cc0178125ddae4d27f5..db6e82b9a7c927384d2f067681cb37e61077e075 100644 (file)
@@ -5,6 +5,9 @@
  *                       1995,1996 Alex Korobka
  */
 
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
 #include "sysmetrics.h"
 #include "heap.h"
 #include "module.h"
@@ -14,6 +17,7 @@
 #include "message.h"
 #include "queue.h"
 #include "stackframe.h"
+#include "options.h"
 #include "winpos.h"
 #include "dce.h"
 #include "nonclient.h"
 /* #define DEBUG_WIN */
 #include "debug.h"
 
-#define  SWP_NOPOSCHANGE       (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
+#define  SWP_AGG_NOGEOMETRYCHANGE \
+    (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
+#define  SWP_AGG_NOPOSCHANGE \
+    (SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
+#define  SWP_AGG_STATUSFLAGS \
+    (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
 
 /* ----- external functions ----- */
 
@@ -520,7 +529,7 @@ BOOL MoveWindow( HWND hwnd, short x, short y, short cx, short cy, BOOL repaint)
 BOOL ShowWindow( HWND hwnd, int cmd ) 
 {    
     WND * wndPtr = WIN_FindWndPtr( hwnd );
-    BOOL wasVisible;
+    BOOL32 wasVisible, showFlag;
     POINT16 maxSize;
     int swpflags = 0;
     short x = 0, y = 0, cx = 0, cy = 0;
@@ -585,7 +594,7 @@ BOOL ShowWindow( HWND hwnd, int cmd )
                if( wndPtr->dwStyle & WS_MINIMIZE )
                    if( !SendMessage16( hwnd, WM_QUERYOPEN, 0, 0L ) )
                        {
-                        swpflags |= SWP_NOSIZE;
+                        swpflags |= SWP_NOSIZE | SWP_NOMOVE;
                         break;
                        }
 
@@ -617,7 +626,7 @@ BOOL ShowWindow( HWND hwnd, int cmd )
             {
                 if( !SendMessage16( hwnd, WM_QUERYOPEN, 0, 0L) )
                   {
-                    swpflags |= SWP_NOSIZE;
+                    swpflags |= SWP_NOSIZE | SWP_NOMOVE;
                     break;
                   }
                 wndPtr->ptIconPos.x = wndPtr->rectWindow.left;
@@ -656,13 +665,21 @@ BOOL ShowWindow( HWND hwnd, int cmd )
            break;
     }
 
+    showFlag = (cmd != SW_HIDE);
+    if (showFlag != wasVisible)
+    {
+        SendMessage16( hwnd, WM_SHOWWINDOW, showFlag, 0 );
+        if (!IsWindow( hwnd )) return wasVisible;
+    }
+
     /* We can't activate a child window */
     if (wndPtr->dwStyle & WS_CHILD) swpflags |= SWP_NOACTIVATE | SWP_NOZORDER;
-    SendMessage16( hwnd, WM_SHOWWINDOW, (cmd != SW_HIDE), 0 );
     SetWindowPos( hwnd, HWND_TOP, x, y, cx, cy, swpflags );
+    if (!IsWindow( hwnd )) return wasVisible;
 
     if (wndPtr->flags & WIN_NEED_SIZE)
     {
+        /* should happen only in CreateWindowEx() */
        int wParam = SIZE_RESTORED;
 
        wndPtr->flags &= ~WIN_NEED_SIZE;
@@ -873,7 +890,7 @@ BOOL WINPOS_SetActiveWindow( HWND hWnd, BOOL fMouse, BOOL fChangeFocus )
     {
         if (!SendMessage16( hwndPrevActive, WM_NCACTIVATE, FALSE, 0 ))
         {
-           if (GetSysModalWindow() != hWnd) return 0;
+           if (GetSysModalWindow16() != hWnd) return 0;
            /* disregard refusal if hWnd is sysmodal */
         }
 
@@ -1364,6 +1381,46 @@ static void WINPOS_SizeMoveClean(WND* Wnd, HRGN oldVisRgn, LPRECT16 lpOldWndRect
  DeleteObject(newVisRgn);
 }
 
+
+/***********************************************************************
+ *           WINPOS_ForceXWindowRaise
+ */
+void WINPOS_ForceXWindowRaise( WND* pWnd )
+{
+    XWindowChanges winChanges;
+    WND *wndStop, *wndLast;
+
+    if (!pWnd->window) return;
+        
+    wndLast = wndStop = pWnd;
+    winChanges.stack_mode = Above;
+    XReconfigureWMWindow( display, pWnd->window, 0, CWStackMode, &winChanges );
+
+    /* Recursively raise owned popups according to their z-order 
+     * (it would be easier with sibling-related Below but it doesn't
+     * work very well with SGI mwm for instance)
+     */
+    while (wndLast)
+    {
+        WND *wnd = WIN_GetDesktop()->child;
+        wndLast = NULL;
+        while (wnd != wndStop)
+        {
+            if (wnd->owner == pWnd &&
+                (wnd->dwStyle & WS_POPUP) &&
+                (wnd->dwStyle & WS_VISIBLE))
+                wndLast = wnd;
+            wnd = wnd->next;
+        }
+        if (wndLast)
+        {
+            WINPOS_ForceXWindowRaise( wndLast );
+            wndStop = wndLast;
+        }
+    }
+}
+
+
 /***********************************************************************
  *           WINPOS_SetXWindowPos
  *
@@ -1380,6 +1437,27 @@ static void WINPOS_SetXWindowPos( WINDOWPOS16 *winpos )
         winChanges.width     = winpos->cx;
         winChanges.height    = winpos->cy;
         changeMask |= CWWidth | CWHeight;
+
+        /* Tweak dialog window size hints */
+
+        if ((wndPtr->flags & WIN_MANAGED) &&
+            (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME))
+        {
+            XSizeHints *size_hints = XAllocSizeHints();
+
+            if (size_hints)
+            {
+                long supplied_return;
+
+                XGetWMSizeHints( display, wndPtr->window, size_hints,
+                                 &supplied_return, XA_WM_NORMAL_HINTS);
+                size_hints->min_width = size_hints->max_width = winpos->cx;
+                size_hints->min_height = size_hints->max_height = winpos->cy;
+                XSetWMSizeHints( display, wndPtr->window, size_hints,
+                                 XA_WM_NORMAL_HINTS );
+                XFree(size_hints);
+            }
+        }
     }
     if (!(winpos->flags & SWP_NOMOVE))
     {
@@ -1400,8 +1478,11 @@ static void WINPOS_SetXWindowPos( WINDOWPOS16 *winpos )
         }
         changeMask |= CWStackMode;
     }
-    if (changeMask)
-        XConfigureWindow( display, wndPtr->window, changeMask, &winChanges );
+    if (!changeMask) return;
+    if (wndPtr->flags & WIN_MANAGED)
+        XReconfigureWMWindow( display, wndPtr->window, 0,
+                              changeMask, &winChanges );
+    else XConfigureWindow( display, wndPtr->window, changeMask, &winChanges );
 }
 
 
@@ -1417,17 +1498,24 @@ BOOL SetWindowPos( HWND hwnd, HWND hwndInsertAfter, INT x, INT y,
     HRGN       visRgn = 0;
     int        result = 0;
 
-    dprintf_win(stddeb,"SetWindowPos: hwnd %04x, flags %08x\n", hwnd, flags);  
-
+    dprintf_win(stddeb,"SetWindowPos: hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n", 
+                                                hwnd, x, y, x+cx, y+cy, flags);  
       /* Check window handle */
 
     if (hwnd == GetDesktopWindow()) return FALSE;
     if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
 
-    /* Check for windows that may not be resized 
-       FIXME: this should be done only for Windows 3.0 programs */
-    if (flags ==(SWP_SHOWWINDOW) || flags ==(SWP_HIDEWINDOW ) )
-       flags |= SWP_NOSIZE | SWP_NOMOVE;
+    if (wndPtr->dwStyle & WS_VISIBLE) flags &= ~SWP_SHOWWINDOW;
+    else
+    {
+       flags &= ~SWP_HIDEWINDOW;
+       if (!(flags & SWP_SHOWWINDOW)) flags |= SWP_NOREDRAW;
+    }
+
+/*     Check for windows that may not be resized 
+       FIXME: this should be done only for Windows 3.0 programs 
+ */    if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
+           flags |= SWP_NOSIZE | SWP_NOMOVE;
 
       /* Check dimensions */
 
@@ -1631,7 +1719,7 @@ BOOL SetWindowPos( HWND hwnd, HWND hwndInsertAfter, INT x, INT y,
            BOOL bNoCopy = (flags & SWP_NOCOPYBITS) || 
                           (result >= WVR_HREDRAW && result < WVR_VALIDRECTS);
 
-           if( (winpos.flags & SWP_NOPOSCHANGE) != SWP_NOPOSCHANGE )
+           if( (winpos.flags & SWP_AGG_NOGEOMETRYCHANGE) != SWP_AGG_NOGEOMETRYCHANGE )
                /* optimize cleanup by BitBlt'ing where possible */
 
                WINPOS_SizeMoveClean(wndPtr, visRgn, &oldWindowRect, &oldClientRect, bNoCopy);
@@ -1706,7 +1794,10 @@ BOOL SetWindowPos( HWND hwnd, HWND hwndInsertAfter, INT x, INT y,
 
       /* And last, send the WM_WINDOWPOSCHANGED message */
 
-    if (!(winpos.flags & SWP_NOSENDCHANGING))
+    dprintf_win(stddeb,"\tstatus flags = %04x\n", winpos.flags & SWP_AGG_STATUSFLAGS);
+
+    if ( ((winpos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE) && 
+       !(winpos.flags & SWP_NOSENDCHANGING))
         SendMessage16( winpos.hwnd, WM_WINDOWPOSCHANGED,
                        0, (LPARAM)MAKE_SEGPTR(&winpos) );
 
index 501acfea5f12e31663c841d2e0b53cd19c5e3921..f52a6d248a62e33ffe2476bff1ce5459d574e828 100644 (file)
@@ -100,48 +100,6 @@ static void CallFrom16_long_wwwll(void) {}
 static void CallFrom32_stdcall_5(void) {}
 #endif  /* WINELIB */
 
-/* Reference 16->32A thunk */
-static const WINPROC_THUNK_FROM16 WINPROC_ThunkRef16To32A =
-{
-    0x58,                                       /* popl  %eax */
-    0x68, 0x00000000,                           /* pushl $proc32 */
-    0x50,                                       /* pushl %eax */
-    0x5566,                                     /* pushw %bp */
-    0x68, (void (*)())WINPROC_CallProc16To32A,  /* pushl $thunk32 */
-    0x9a, CallFrom16_long_wwwll,                /* lcall cs:relay */
-    WINE_CODE_SELECTOR
-};
-
-/* Reference 16->32W thunk */
-static const WINPROC_THUNK_FROM16 WINPROC_ThunkRef16To32W =
-{
-    0x58,                                       /* popl  %eax */
-    0x68, 0x00000000,                           /* pushl $proc32 */
-    0x50,                                       /* pushl %eax */
-    0x5566,                                     /* pushw %bp */
-    0x68, (void (*)())WINPROC_CallProc16To32W,  /* pushl $thunk32 */
-    0x9a, CallFrom16_long_wwwll,                /* lcall cs:relay */
-    WINE_CODE_SELECTOR
-};
-
-/* Reference 32->16 thunk */
-static const WINPROC_THUNK_FROM32 WINPROC_ThunkRef32To16 =
-{
-    0x58,                                       /* popl  %eax */
-    0x68, 0x00000000,                           /* pushl $proc16 */
-    0x50,                                       /* pushl %eax */
-    0x55,                                       /* pushl %ebp */
-    0x68, "WINPROC_CallProc32ATo16",            /* pushl $name */
-    0x68, (void (*)())WINPROC_CallProc32ATo16,  /* pushl $thunk32 */
-    0xe9, CallFrom32_stdcall_5                  /* jmp   relay */
-};
-
-/* Reference 32->32 jump */
-static const WINPROC_JUMP WINPROC_JumpRef =
-{
-    0xe9, 0x00000000                            /* jmp   proc (relative) */
-};
-
 static HANDLE32 WinProcHeap;
 
 /**********************************************************************
@@ -175,12 +133,10 @@ static WINDOWPROC *WINPROC_GetPtr( WNDPROC16 handle )
     {
         ptr = (BYTE *)handle;
         /* First check if it is the jmp address */
-        if (*ptr == WINPROC_JumpRef.jmp)
-            ptr -= (int)&((WINDOWPROC *)0)->jmp -
-                   (int)&((WINDOWPROC *)0)->thunk;
+        if (*ptr == 0xe9 /* jmp */) ptr -= (int)&((WINDOWPROC *)0)->jmp -
+                                           (int)&((WINDOWPROC *)0)->thunk;
         /* Now it must be the thunk address */
-        if (*ptr == WINPROC_ThunkRef16To32A.popl_eax)
-            ptr -= (int)&((WINDOWPROC *)0)->thunk;
+        if (*ptr == 0x58 /* popl eax */) ptr -= (int)&((WINDOWPROC *)0)->thunk;
         /* Now we have a pointer to the WINDOWPROC struct */
         if (((WINDOWPROC *)ptr)->magic == WINPROC_MAGIC)
             return (WINDOWPROC *)ptr;
@@ -192,8 +148,7 @@ static WINDOWPROC *WINPROC_GetPtr( WNDPROC16 handle )
     {
         ptr = (BYTE *)PTR_SEG_TO_LIN(handle);
         /* It must be the thunk address */
-        if (*ptr == WINPROC_ThunkRef32To16.popl_eax)
-            ptr -= (int)&((WINDOWPROC *)0)->thunk;
+        if (*ptr == 0x58 /* popl eax */) ptr -= (int)&((WINDOWPROC *)0)->thunk;
         /* Now we have a pointer to the WINDOWPROC struct */
         if (((WINDOWPROC *)ptr)->magic == WINPROC_MAGIC)
             return (WINDOWPROC *)ptr;
@@ -227,24 +182,35 @@ static WINDOWPROC *WINPROC_AllocWinProc( WNDPROC16 func, WINDOWPROCTYPE type )
         switch(type)
         {
         case WIN_PROC_16:
-            proc->thunk.t_from32 = WINPROC_ThunkRef32To16;
-            proc->thunk.t_from32.proc = func;
-            /* We need to fix the relative jump target */
-            proc->thunk.t_from32.relay = (void (*)())((DWORD)proc->thunk.t_from32.relay -
+            proc->thunk.t_from32.popl_eax    = 0x58;   /* popl  %eax */
+            proc->thunk.t_from32.pushl_func  = 0x68;   /* pushl $proc */
+            proc->thunk.t_from32.proc        = func;
+            proc->thunk.t_from32.pushl_eax   = 0x50;   /* pushl %eax */
+            proc->thunk.t_from32.pushl_ebp   = 0x55;   /* pushl %ebp */
+            proc->thunk.t_from32.pushl_name  = 0x68;   /* pushl $name */
+            proc->thunk.t_from32.name        = "WINPROC_CallProc32ATo16";
+            proc->thunk.t_from32.pushl_thunk = 0x68;   /* pushl $thunkfrom32 */
+            proc->thunk.t_from32.thunk32     = (void(*)())WINPROC_CallProc32ATo16;
+            proc->thunk.t_from32.jmp         = 0xe9;   /* jmp   relay*/
+            proc->thunk.t_from32.relay =  /* relative jump */
+                (void (*)())((DWORD)CallFrom32_stdcall_5 -
                                      (DWORD)(&proc->thunk.t_from32.relay + 1));
             break;
         case WIN_PROC_32A:
-            proc->thunk.t_from16 = WINPROC_ThunkRef16To32A;
-            proc->thunk.t_from16.proc = (FARPROC32)func;
-            proc->jmp = WINPROC_JumpRef;
-            /* Fixup relative jump */
-            proc->jmp.proc = (WNDPROC32)((DWORD)func -
-                                                 (DWORD)(&proc->jmp.proc + 1));
-            break;
         case WIN_PROC_32W:
-            proc->thunk.t_from16 = WINPROC_ThunkRef16To32W;
-            proc->thunk.t_from16.proc = (WNDPROC32)func;
-            proc->jmp = WINPROC_JumpRef;
+            proc->thunk.t_from16.popl_eax    = 0x58;   /* popl  %eax */
+            proc->thunk.t_from16.pushl_func  = 0x68;   /* pushl $proc */
+            proc->thunk.t_from16.proc        = (FARPROC32)func;
+            proc->thunk.t_from16.pushl_eax   = 0x50;   /* pushl %eax */
+            proc->thunk.t_from16.pushw_bp    = 0x5566; /* pushw %bp */
+            proc->thunk.t_from16.pushl_thunk = 0x68;   /* pushl $thunkfrom16 */
+            proc->thunk.t_from16.thunk32     = (type == WIN_PROC_32A) ?
+                                           (void(*)())WINPROC_CallProc16To32A :
+                                           (void(*)())WINPROC_CallProc16To32W;
+            proc->thunk.t_from16.lcall       = 0x9a;   /* lcall cs:relay */
+            proc->thunk.t_from16.relay       = CallFrom16_long_wwwll;
+            proc->thunk.t_from16.cs          = WINE_CODE_SELECTOR;
+            proc->jmp.jmp  = 0xe9;
             /* Fixup relative jump */
             proc->jmp.proc = (WNDPROC32)((DWORD)func -
                                                  (DWORD)(&proc->jmp.proc + 1));
@@ -409,6 +375,31 @@ INT32 WINPROC_MapMsg32ATo32W( UINT32 msg, WPARAM32 wParam, LPARAM *plparam )
             *plparam = (LPARAM)cs;
         }
         return 1;
+    case WM_MDICREATE:
+        {
+            MDICREATESTRUCT32W *cs =
+                (MDICREATESTRUCT32W *)HeapAlloc( SystemHeap, 0, sizeof(*cs) );
+            if (!cs) return -1;
+            *cs = *(MDICREATESTRUCT32W *)*plparam;
+            if (HIWORD(cs->szClass))
+                cs->szClass = STRING32_DupAnsiToUni( (LPCSTR)cs->szClass );
+            if (HIWORD(cs->szTitle))
+                cs->szTitle = STRING32_DupAnsiToUni( (LPCSTR)cs->szTitle );
+            *plparam = (LPARAM)cs;
+        }
+        return 1;
+    case WM_ASKCBFORMATNAME:
+    case WM_COMPAREITEM:
+    case WM_DELETEITEM:
+    case WM_DEVMODECHANGE:
+    case WM_MDIACTIVATE:
+    case WM_MEASUREITEM:
+    case WM_PAINTCLIPBOARD:
+    case WM_SIZECLIPBOARD:
+    case WM_WININICHANGE:
+        fprintf( stderr, "MapMsg32ATo32W: message %04x needs translation\n",
+                 msg );
+        return -1;
     default:  /* No translation needed */
         return 0;
     }
@@ -443,6 +434,14 @@ void WINPROC_UnmapMsg32ATo32W( UINT32 msg, WPARAM32 wParam, LPARAM lParam )
             HeapFree( SystemHeap, 0, cs );
         }
         break;
+    case WM_MDICREATE:
+        {
+            MDICREATESTRUCT32W *cs = (MDICREATESTRUCT32W *)lParam;
+            if (HIWORD(cs->szTitle)) free( (LPVOID)cs->szTitle );
+            if (HIWORD(cs->szClass)) free( (LPVOID)cs->szClass );
+            HeapFree( SystemHeap, 0, cs );
+        }
+        break;
     }
 }
 
@@ -483,6 +482,31 @@ INT32 WINPROC_MapMsg32WTo32A( UINT32 msg, WPARAM32 wParam, LPARAM *plparam )
             *plparam = (LPARAM)cs;
         }
         return 1;
+    case WM_MDICREATE:
+        {
+            MDICREATESTRUCT32A *cs =
+                (MDICREATESTRUCT32A *)HeapAlloc( SystemHeap, 0, sizeof(*cs) );
+            if (!cs) return -1;
+            *cs = *(MDICREATESTRUCT32A *)*plparam;
+            if (HIWORD(cs->szTitle))
+                cs->szTitle = STRING32_DupUniToAnsi( (LPCWSTR)cs->szTitle );
+            if (HIWORD(cs->szClass))
+                cs->szClass = STRING32_DupUniToAnsi( (LPCWSTR)cs->szClass );
+            *plparam = (LPARAM)cs;
+        }
+        return 1;
+    case WM_ASKCBFORMATNAME:
+    case WM_COMPAREITEM:
+    case WM_DELETEITEM:
+    case WM_DEVMODECHANGE:
+    case WM_MDIACTIVATE:
+    case WM_MEASUREITEM:
+    case WM_PAINTCLIPBOARD:
+    case WM_SIZECLIPBOARD:
+    case WM_WININICHANGE:
+        fprintf( stderr, "MapMsg32WTo32A: message %04x needs translation\n",
+                 msg );
+        return -1;
     default:  /* No translation needed */
         return 0;
     }
@@ -517,6 +541,14 @@ void WINPROC_UnmapMsg32WTo32A( UINT32 msg, WPARAM32 wParam, LPARAM lParam )
             HeapFree( SystemHeap, 0, cs );
         }
         break;
+    case WM_MDICREATE:
+        {
+            MDICREATESTRUCT32A *cs = (MDICREATESTRUCT32A *)lParam;
+            if (HIWORD(cs->szTitle)) free( (LPVOID)cs->szTitle );
+            if (HIWORD(cs->szClass)) free( (LPVOID)cs->szClass );
+            HeapFree( SystemHeap, 0, cs );
+        }
+        break;
     }
 }
 
@@ -580,6 +612,21 @@ INT32 WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16, UINT32 *pmsg32,
     case WM_GETTEXT:
         *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
         return 0;
+    case WM_MDICREATE:
+        {
+            MDICREATESTRUCT16 *cs16 =
+                (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
+            MDICREATESTRUCT32A *cs =
+                (MDICREATESTRUCT32A *)HeapAlloc( SystemHeap, 0,
+                                                sizeof(*cs) + sizeof(LPARAM) );
+            if (!cs) return -1;
+            STRUCT32_MDICREATESTRUCT16to32A( cs16, cs );
+            cs->szTitle = (LPCSTR)PTR_SEG_TO_LIN(cs16->szTitle);
+            cs->szClass = (LPCSTR)PTR_SEG_TO_LIN(cs16->szClass);
+            *(LPARAM *)(cs + 1) = *plparam;  /* Store the previous lParam */
+            *plparam = (LPARAM)cs;
+        }
+        return 1;
     case WM_MDISETMENU:
         *pwparam32 = (WPARAM32)(HMENU32)LOWORD(*plparam);
         *plparam   = (LPARAM)(HMENU32)HIWORD(*plparam);
@@ -656,7 +703,6 @@ INT32 WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16, UINT32 *pmsg32,
     case WM_DELETEITEM:
     case WM_DEVMODECHANGE:
     case WM_MDIACTIVATE:
-    case WM_MDICREATE:
     case WM_MEASUREITEM:
     case WM_PAINTCLIPBOARD:
     case WM_SIZECLIPBOARD:
@@ -692,6 +738,15 @@ void WINPROC_UnmapMsg16To32A( UINT32 msg, WPARAM32 wParam, LPARAM lParam )
             HeapFree( SystemHeap, 0, mmi );
         }
         break;
+    case WM_MDICREATE:
+        {
+            MDICREATESTRUCT32A *cs = (MDICREATESTRUCT32A *)lParam;
+            lParam = *(LPARAM *)(cs + 1);
+            STRUCT32_MDICREATESTRUCT32Ato16( cs,
+                                 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
+            HeapFree( SystemHeap, 0, cs );
+        }
+        break;
     case WM_NCCALCSIZE:
         {
             NCCALCSIZE_PARAMS16 *nc16;
@@ -769,6 +824,25 @@ INT32 WINPROC_MapMsg16To32W( UINT16 msg16, WPARAM16 wParam16, UINT32 *pmsg32,
             *plparam = (LPARAM)cs;
         }
         return 1;
+    case WM_MDICREATE:
+        {
+            MDICREATESTRUCT16 *cs16 =
+                (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
+            MDICREATESTRUCT32W *cs =
+                (MDICREATESTRUCT32W *)HeapAlloc( SystemHeap, 0,
+                                                sizeof(*cs) + sizeof(LPARAM) );
+            if (!cs) return -1;
+            STRUCT32_MDICREATESTRUCT16to32A( cs16, (MDICREATESTRUCT32A *)cs );
+            cs->szTitle = (LPCWSTR)PTR_SEG_TO_LIN(cs16->szTitle);
+            cs->szClass = (LPCWSTR)PTR_SEG_TO_LIN(cs16->szClass);
+            if (HIWORD(cs->szTitle))
+                cs->szTitle = STRING32_DupAnsiToUni( (LPCSTR)cs->szTitle );
+            if (HIWORD(cs->szClass))
+                cs->szClass = STRING32_DupAnsiToUni( (LPCSTR)cs->szClass );
+            *(LPARAM *)(cs + 1) = *plparam;  /* Store the previous lParam */
+            *plparam = (LPARAM)cs;
+        }
+        return 1;
     default:  /* No Unicode translation needed */
         return WINPROC_MapMsg16To32A( msg16, wParam16, pmsg32,
                                       pwparam32, plparam );
@@ -801,6 +875,17 @@ void WINPROC_UnmapMsg16To32W( UINT32 msg, WPARAM32 wParam, LPARAM lParam )
             HeapFree( SystemHeap, 0, cs );
         }
         break;
+    case WM_MDICREATE:
+        {
+            MDICREATESTRUCT32W *cs = (MDICREATESTRUCT32W *)lParam;
+            lParam = *(LPARAM *)(cs + 1);
+            STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCT32A *)cs,
+                                 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
+            if (HIWORD(cs->szTitle)) free( (LPVOID)cs->szTitle );
+            if (HIWORD(cs->szClass)) free( (LPVOID)cs->szClass );
+            HeapFree( SystemHeap, 0, cs );
+        }
+        break;
     default:
         WINPROC_UnmapMsg16To32A( msg, wParam, lParam );
         break;
@@ -878,6 +963,21 @@ INT32 WINPROC_MapMsg32ATo16( UINT32 msg32, WPARAM32 wParam32, UINT16 *pmsg16,
             *plparam = (LPARAM)SEGPTR_GET(str);
         }
         return 1;
+    case WM_MDICREATE:
+        {
+            MDICREATESTRUCT16 *cs;
+            MDICREATESTRUCT32A *cs32 = (MDICREATESTRUCT32A *)*plparam;
+            LPSTR name, cls;
+
+            if (!(cs = SEGPTR_NEW(MDICREATESTRUCT16))) return -1;
+            STRUCT32_MDICREATESTRUCT32Ato16( cs32, cs );
+            name = SEGPTR_STRDUP( cs32->szTitle );
+            cls  = SEGPTR_STRDUP( cs32->szClass );
+            cs->szTitle = SEGPTR_GET(name);
+            cs->szClass = SEGPTR_GET(cls);
+            *plparam = (LPARAM)SEGPTR_GET(cs);
+        }
+        return 1;
     case WM_MDISETMENU:
         *pwparam16 = TRUE;  /* FIXME? */
         *plparam   = MAKELPARAM( (HMENU16)LOWORD(wParam32),
@@ -955,7 +1055,6 @@ INT32 WINPROC_MapMsg32ATo16( UINT32 msg32, WPARAM32 wParam32, UINT16 *pmsg16,
     case WM_DELETEITEM:
     case WM_DEVMODECHANGE:
     case WM_MDIACTIVATE:
-    case WM_MDICREATE:
     case WM_MEASUREITEM:
     case WM_PAINTCLIPBOARD:
     case WM_SIZECLIPBOARD:
@@ -998,6 +1097,14 @@ void WINPROC_UnmapMsg32ATo16( UINT16 msg, WPARAM16 wParam, LPARAM lParam )
             SEGPTR_FREE( (LPARAM *)str - 1 );
         }
         break;
+    case WM_MDICREATE:
+        {
+            MDICREATESTRUCT16 *cs = (MDICREATESTRUCT16*)PTR_SEG_TO_LIN(lParam);
+            SEGPTR_FREE( PTR_SEG_TO_LIN(cs->szTitle) );
+            SEGPTR_FREE( PTR_SEG_TO_LIN(cs->szClass) );
+            SEGPTR_FREE( cs );
+        }
+        break;
     case WM_NCCALCSIZE:
         {
             NCCALCSIZE_PARAMS32 *nc32;
@@ -1079,6 +1186,32 @@ INT32 WINPROC_MapMsg32WTo16( UINT32 msg32, WPARAM32 wParam32, UINT16 *pmsg16,
             *plparam   = (LPARAM)SEGPTR_GET(cs);
         }
         return 1;
+    case WM_MDICREATE:
+        {
+            MDICREATESTRUCT16 *cs;
+            MDICREATESTRUCT32W *cs32 = (MDICREATESTRUCT32W *)*plparam;
+
+            if (!(cs = SEGPTR_NEW(MDICREATESTRUCT16))) return -1;
+            STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCT32A *)cs32, cs );
+            if (HIWORD(cs32->szTitle))
+            {
+                LPSTR name = SEGPTR_ALLOC( lstrlen32W(cs32->szTitle) + 1 );
+                STRING32_UniToAnsi( name, cs32->szTitle );
+                cs->szTitle = SEGPTR_GET(name);
+            }
+            else cs->szTitle = (SEGPTR)cs32->szTitle;
+            if (HIWORD(cs32->szClass))
+            {
+                LPSTR name = SEGPTR_ALLOC( lstrlen32W(cs32->szClass) + 1 );
+                STRING32_UniToAnsi( name, cs32->szClass );
+                cs->szClass = SEGPTR_GET(name);
+            }
+            else cs->szClass = (SEGPTR)cs32->szClass;
+            *pmsg16    = (UINT16)msg32;
+            *pwparam16 = (WPARAM16)LOWORD(wParam32);
+            *plparam   = (LPARAM)SEGPTR_GET(cs);
+        }
+        return 1;
     case WM_SETTEXT:
         {
             LPSTR str = SEGPTR_ALLOC( lstrlen32W((LPWSTR)*plparam) + 1 );
index f0690ec90a574db463dca634fe0c9dece4ad808b..28ffd4d99344f150defaaa40772f75e056e20441 100644 (file)
--- a/wine.ini
+++ b/wine.ini
@@ -36,6 +36,9 @@ Temp=e:\
 Path=c:\windows;c:\windows\system;e:\;e:\test;f:\
 SymbolTableFile=./wine.sym
 
+[options]
+AllocSystemColors=100
+
 [fonts]
 system=*-helvetica
 mssansserif=*-helvetica
index 8d5f17c4d236d36d5c7c6dbecd17b3cbf314e0c2..9220dc06edb23f1ab30015b4540773b22da60952 100644 (file)
--- a/wine.man
+++ b/wine.man
@@ -1,7 +1,7 @@
 .\" -*- nroff -*-
 .TH WINE 1 "September 1, 1995" "Version 9/1/95" "Windows Emulation"
 .SH NAME
-wine \- run Windows 3.x programs under Linux
+wine \- run Windows programs under Unix
 .SH SYNOPSIS
 .B wine
 [
@@ -13,7 +13,7 @@ wine \- run Windows 3.x programs under Linux
 ]
 .SH DESCRIPTION
 .B wine
-invokes the Linux Windows emulator.
+invokes the Windows emulator.
 .PP
 .B wine 
 currently runs a number of games and small applications (approximately