Release 951124

Tue Nov 21 18:49:10 1995  Alexandre Julliard  <julliard@sunsite.unc.edu>

	* [configure.in] [Makefile] [misc/dos_fs.c]
	Got rid of autoconf.h file.

	* [debugger/dbg.y]
	More logical behavior upon syntax errors.

	* [include/hook.h] [windows/hook.c]
	Changed hook structure and rewrote most of the hook functions for
	better compatibility, based on investigations by Alex Korobka.

	* [include/message.h] [windows/message.c]
	Added hooks to message queue structure and made the structure
	layout Windows-compatible.
	Added support for WH_MOUSE, WH_KEYBOARD, WH_HARDWARE and
	WH_JOURNALRECORD hooks.

	* [misc/main.c]
	Added command-line option for changing the language at run-time
 	(not implemented yet), based on a suggestion from Michael Patra.

	* [objects/cursoricon.c]
	Fixed silly SEGPTR bug in DumpIcon().

Mon Nov 20 22:22:22 1995  Alex Korobka <alex@phm30.pharm.sunysb.edu>

	* [controls/listbox.c] [controls/combo.c] [include/listbox.h]
	Partial implementaion of LBS_EXTENDEDSEL style,
	yet more updates for drag & drop support. Now works.

	* [windows/defwnd.c]
	More message handlers.

	* [windows/win.c]
	DragObject, DragDetect, AnyPopup functions. 

	* [controls/listbox.c]
	More kludgy fixes (WM_...TOITEM, etc.).

	* [objects/cursoricon.c] [objects/oembitmap.c]
	IconToCursor skeleton, patch for OBM_LoadCursorIcon to handle new
	cursor.

	* [include/bitmaps/ocr*]
	New OEM cursors.

Mon Nov 20 11:05:20 EST 1995  Jim Peterson <jspeter@birch.ee.vt.edu>

	* [toolkit/heap.c]
	Swapped flags and size arguments to LocalRealloc as per changes in
	memory/local.c by William Magro in previous release.

	* [include/wintypes.h]
	Reinstated the #define's for 'min' and 'max', since they're part of
	the Windows API.  I really don't think it's a wise idea, so I put
	a '#ifndef DONT_DEFINE_min_AND_max' around them.  I think the actual
	WINE code should never use these (it should use 'MIN' and 'MAX'
	instead).

	* [loader/*]
	Put '#ifndef WINELIB' around many things that WINElib should not need.

	* [controls/edit.c]
	Took out many '#if defined(WINELIB)' sections with the associated
	comment 'temporary fix, until Local memory is correctly implemented in
	WINELIB', since the effective translations are now in 
	toolkit/miscstubs.c.
	Took out the #ifndef's I put in EDIT_ClearText.  Whoever modified this
	file fixed (or at least postponed) the bug I had encountered.

	* [loader/task.c]
	Put an #ifdef in TASK_CreateTask() that hardwires the current drive to
	C:  This will probably cause a lot of trouble if this change is
	forgotten in the future, but it will let things like the OpenFileName
	dialog work for now.

	* [toolkit/libres.c] [toolkit/Makefile.in] [toolkit/Makefile]
	  [include/libres.h]
	Made new libres.c file, which will contain functions for supporting
	accessing resources by name in WINElib.  'winerc' will need to be
	changed.

	* [toolkit/heap.c]
	Refined memory routines to allow for differences between LocalAlloc
	and GlobalAlloc and between LocalSize and GlobalSize.

	* [windows/message.c] [include/windows.h]
	Defined the GetCurrentTime routine in windows/message.c, and removed
	the #define in windows.h.

Mon Nov 20 00:36:42 MET 1995 Sven Verdoolaege <skimo@dns.ufsia.ac.be>

	* [*/*]
	Added new debugging type DEBUG_WIN32 and DEBUG_ENV.

	* [loader/module.c]
	Added undocumented GetExpWinVer.

	* [tools/build.c]
	Previous code didn't pop possibly changed %esi, %edi and %edx
	from the stack.
	
	* [win32/advapi.c]
	Added GetUserNameA.

	* [win32/code_page.c]
	Added stub for MultiByteToWideChar.

	* [win32/console.c]
	Added SetConsoleCtrlHandler stub.

	* [win32/file.c]
	Added ReadFile CreateFileA GetFileInformationByHandle stubs.
	Added CloseHandle.

	* [win32/memory.c]
	Changed VirtualAlloc and VirtualFree.

	* [win32/process.c]
	Added ExitProcess.

Sun Nov 19 17:54:42 1995   Bernd Schmidt <crux@pool.informatik.rwth-aachen.de>

	* [include/windows.h]
	Fixed a few broken structure definitions.

	* [loader/resource.c]
	FindResource(): Need to check for '#xxx' strings here.

	* [miscemu/int21.c]
	FindNext(): Return MS-DOS filenames uppercase.

	* [objects/cursoricon.c]
	CreateIcon(), CreateCursor(): Added missing element to CURSORICONINFO
	initializers.
	
	* [misc/file.c]
	_lopen(): Files opened in OF_WRITE mode are truncated.
	OpenFile(): Ignore OF_READ/OF_WRITE/OF_READWRITE when files are
	created; use read/write mode.
	
	* [misc/profile.c]
	load(): Rewritten.
	
	* [misc/commdlg.c]
	Fixed bad call to strncpy() that smashed the stack.

	* [controls/combo.c] [windows/winpos.c] [memory/selector.c]
	Operator precedence fixes. People who use gcc 2.7.1 don't need a
	debugger :-)
	
	* [if1632/gdi.spec] [objects/palette.c]
	Add ResizePalette() and AnimatePalette() stubs. They don't do anything,
	but sometimes that's good enough.

Fri Nov 17 09:10:35 GMT 1995  John Harvey <john@division.co.uk>

	* [include/wine.h] [include/registers.h] [include/winsock.h]
        Added definitions for Unixware.

	* [loader/signal.c] [misc/comm.c] [misc/winsocket.c]
	Misc. fixes for Unixware.

	* [loader/task.c]
        Made assignemts to context in InitTask for registers use the macros
        from registers.h to make them more portable. (Needed for Unixware)

	* [tools/build.c]
	Fixed register acces routines to work on Unixware. Bit grubby but
 	it seems to work.

	* [controls/edit.c]
	EDIT_WM_NCCreate allocates local heap if hasn't been previously
	allocated.
	
	* [miscemu/int21.c]
	mkdir now creates directory with permission to access it.

	* [misc/dos_fs.c]
	mkdir now creates directory with permission to access it.
	DOS_opendir now uses linked list of dirents to avoid problems with 
	realloc changing address of malloced memory.

Thu Nov 16 12:47:13 1995  Michael Patra  <patra@itp1.Physik.TU-Berlin.DE>

	* [controls/menu.c]
	MENU_CalcItemSize(): Fixed handling of empty menu items.

Sat Nov 11 21:46:54 1995  Hans de Graaff  <graaff@twi72.twi.tudelft.nl>

	* [misc/file.c]
	In OpenFile, unlink should be done on the unix filename.

Sat Nov 11 16:43:29 1995  Cameron Heide  (heide@ee.ualberta.ca)

        * [include/handle32.h]
        New header file containing internal Win32 kernel handle
        information.

        * [win32/file.c]
        Added ReadFile, CreateFile, and CloseFileHandle, and did
        some reorganizing to match the new handle allocation scheme.

        * [win32/init.c]
        Added CloseHandle and the creation of standard I/O handles.

        * [win32/object_mgt.c]
        New module for allocating and freeing Win32 kernel handles.
diff --git a/toolkit/Makefile.in b/toolkit/Makefile.in
index 55745dd..a1e6cb0 100644
--- a/toolkit/Makefile.in
+++ b/toolkit/Makefile.in
@@ -7,6 +7,7 @@
 	atom.c \
 	arch.c \
 	heap.c \
+	libres.c \
 	miscstubs.c \
 	sup.c \
 	winmain.c
diff --git a/toolkit/README.libres b/toolkit/README.libres
new file mode 100644
index 0000000..880272f
--- /dev/null
+++ b/toolkit/README.libres
@@ -0,0 +1,37 @@
+                        WINElib resources: a proposal
+
+One of the current issues with WINElib is the inadequate support for accessing
+resources by name.  I propose the following technique (which I have already
+begun to implement) to allow this:
+
+   An internal table of resource entries is provided along with a registering
+   function for adding a resource to this table.  'winerc' should construct
+   *.c files much the same way as it does now with the inclusion of a single
+   static 'constructor' function that registers the associated resources with
+   the internal mechanism like so:
+
+      static void DoIt() __attribute__ ((constructor));
+      static void DoIt()
+      {
+        LIBRES_RegisterResource(hello3_MENU_MAIN__bytes,
+                                sizeof(hello3_MENU_MAIN__bytes),
+                                "MAIN",
+                                RT_MENU);
+        LIBRES_RegisterResource(hello3_DIALOG_DIADEMO__bytes,
+                                sizeof(hello3_DIALOG_DIADEMO__bytes),
+                                "DIADEMO",
+                                RT_DIALOG);
+           ... etc. ...
+      }
+
+   The internal table can then be searched for the resource by name.
+
+The only potential drawback I've determined so far is this technique's
+reliance on gcc's 'constructor' attribute, which disallows compilation with
+some other compiler.  However, I'm guessing that WINE is already heavily
+dependent on gcc, so this is probably not too much of a factor.
+
+Any comments/suggestions/criticisms will be greatly appreciated.
+
+Thank you,
+--Jim
diff --git a/toolkit/heap.c b/toolkit/heap.c
index 75faefc..40e52cb 100644
--- a/toolkit/heap.c
+++ b/toolkit/heap.c
@@ -211,47 +211,13 @@
 
 #else /* WINELIB16 */
 
-#ifdef DEBUG_HEAP
-static void* LastTwenty[20]={ 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0  };
+typedef struct { DWORD Size; DWORD Padding[3]; } HeapData;
 
-void CheckMem(void* f)
+HANDLE HEAP_Alloc (WORD flags, DWORD bytes)
 {
-  int i;
+    HeapData* m;
 
-  for(i=0; i<20; i++)
-  {
-    if(LastTwenty[i]==f)
-      LastTwenty[i]=NULL;
-    else if(LastTwenty[i])
-      if( *((int*)LastTwenty[i]) != 0x12345678  ||
-	  *(((int*)LastTwenty[i])+1) != 0x0fedcba9 )
-	fprintf(stderr,"memory corrupted at %p\n",LastTwenty[i]);
-  }
-  fflush(stderr);
-}
-
-void NewMem(void* n)
-{
-  int i;
-  for(i=0; i<20; i++)
-    if(!LastTwenty[i])
-    {
-      LastTwenty[i]=n;
-      return;
-    }
-  for(i=0; i<20; i++)
-    LastTwenty[i]=LastTwenty[i+1];
-  LastTwenty[4]=n;
-}
-#endif
-
-HANDLE LocalAlloc (WORD flags, WORD bytes)
-{
-    HANDLE m;
-#ifdef DEBUG_HEAP
-    bytes+=2*sizeof(int);
-#endif
-
+    bytes+=sizeof(HeapData);
     if (flags & LMEM_WINE_ALIGN)
 	m = memalign (4, bytes);
     else
@@ -260,125 +226,118 @@
 	if (flags & LMEM_ZEROINIT)
 	    bzero (m, bytes);
     }
-#ifdef DEBUG_HEAP
-    CheckMem(NULL);
-    *((int*) m)=0x12345678;
-    *(((int*) m)+1)=0x0fedcba9;
-    fprintf(stderr,"%p malloc'd\n",m); fflush(stderr);
-    NewMem(m);
-    return (HANDLE) (((int*)m)+2);
-#endif
-    return m;
+    m->Size=bytes-sizeof(HeapData);
+    return m+1;
 }
 
-WORD LocalCompact (WORD min_free)
+HANDLE HEAP_Free (HANDLE hMem)
 {
-    return min_free;
+  HeapData* m=(HeapData*)hMem;
+  free(m-1);
+  return 0;
 }
 
-WORD LocalFlags (HANDLE hMem)
+DWORD HEAP_Size (HANDLE hMem)
 {
-    return 0;
+  HeapData* m=(HeapData*)hMem;
+  return (m-1)->Size;
+}
+
+HANDLE HEAP_ReAlloc(HANDLE hMem,DWORD bytes,UINT flags)
+{
+  HeapData* m=(HeapData*)hMem;
+  if(!bytes)
+  {
+    free(m-1);
+    return 0; /* Inaccurate behavior, but should suffice */
+  }
+  m=realloc (m-1, bytes+sizeof(HeapData));
+  if(flags & LMEM_ZEROINIT && bytes > m->Size)
+    bzero ((char*)m+sizeof(HeapData)+m->Size, bytes-m->Size);
+  m->Size=bytes;
+  return m+1;
+}
+
+HANDLE LocalAlloc (WORD flags, WORD bytes)
+{
+  return HEAP_Alloc(flags,bytes);
+}
+
+UINT LocalFlags (HANDLE hMem)
+{
+  return 0;
 }
 
 HANDLE LocalFree (HANDLE hMem)
 {
-#ifdef DEBUG_HEAP
-    hMem=(HANDLE) (((int*)hMem)-2);
-    CheckMem(hMem);
-    fprintf(stderr,"%p free-ing...",hMem);
-    if( *((int*)hMem) != 0x12345678  ||
-        *(((int*)hMem)+1) != 0x0fedcba9 )
-      fprintf(stderr,"memory corrupted...");
-    else
-    { 
-      *((int*)hMem) = 0x9abcdef0;
-      *(((int*)hMem)+1) = 0x87654321;
-    }
-    fflush(stderr);
-#endif
-    free(hMem);
-#ifdef DEBUG_HEAP
-    fprintf(stderr,"free'd\n"); fflush(stderr);
-#endif
-    return 0;
+  return HEAP_Free(hMem);
 }
 
 BOOL LocalInit (HANDLE segment, WORD start, WORD end)
 {
-    return TRUE;
+  return TRUE;
 }
 
 LPVOID LocalLock (HANDLE hMem)
 {
+  return hMem;
+}
+
+HANDLE LocalReAlloc (HANDLE hMem, WORD new_size, WORD flags)
+{
+  if (!(flags & LMEM_MODIFY))
+    return HEAP_ReAlloc (hMem, new_size, flags);
+  else
     return hMem;
 }
 
-HANDLE LocalReAlloc (HANDLE hMem, WORD flags, WORD bytes)
+UINT LocalSize (HANDLE hMem)
 {
-#ifdef DEBUG_HEAP
-    LocalFree(hMem);
-    return LocalAlloc(flags,bytes); 
-#endif
-    return realloc(hMem, bytes);
-}
-
-WORD LocalSize (HANDLE hMem)
-{
-    /* Not implemented yet */
-  return 0;
+  return HEAP_Size(hMem);
 }
 
 
 BOOL LocalUnlock (HANDLE hMem)
 {
-    return 0;
+  return 0;
 }
 
 HANDLE GlobalAlloc (WORD flags, DWORD size)
 {
-    return LocalAlloc (flags, size);
+  return HEAP_Alloc (flags,size);
 }
 
 HANDLE GlobalFree (HANDLE hMem)
 {
-    return LocalFree (hMem);
+  return HEAP_Free (hMem);
 }
 
 LPVOID GlobalLock (HGLOBAL hMem)
 {
-    return LocalLock (hMem);
+  return hMem;
 }
 
 BOOL GlobalUnlock (HANDLE hMem)
 {
-    return LocalUnlock (hMem);
+  return 0;
 }
 
 WORD GlobalFlags (HANDLE hMem)
 {
-    return LocalFlags (hMem);
+  return LocalFlags (hMem);
 }
 
 DWORD GlobalSize (HANDLE hMem)
 {
-    return LocalSize (hMem);
-}
-
-DWORD GlobalCompact(DWORD desired)
-{
-    if (desired)
-	return desired;
-    else
-	return 0x01000000;	/* Should check the available core. */
+  return HEAP_Size (hMem);
 }
 
 HANDLE GlobalReAlloc(HANDLE hMem, DWORD new_size, WORD flags)
 {
-    if (!(flags & GMEM_MODIFY))
-      return LocalReAlloc (hMem, new_size, flags);
-    else
-      return hMem;
+  if (!(flags & GMEM_MODIFY))
+    return HEAP_ReAlloc (hMem, new_size, flags);
+  else
+    return hMem;
 }
 
 #endif
diff --git a/toolkit/hello3.c b/toolkit/hello3.c
index c688cec..90fadb1 100644
--- a/toolkit/hello3.c
+++ b/toolkit/hello3.c
@@ -1,5 +1,16 @@
 #include <windows.h>
 #include "hello3res.h"
+#include <commdlg.h>
+
+BOOL FileOpen(HWND hWnd)
+{
+  char filename[80] = "test.c";
+  OPENFILENAME ofn = { sizeof(OPENFILENAME),
+		       hWnd, NULL, "C code\0*.c\0", NULL, 0, 0, filename, 80,
+		       NULL, 0, NULL, NULL, OFN_CREATEPROMPT |
+		       OFN_SHOWHELP, 0, 0, NULL, 0, NULL };
+  return GetOpenFileName(&ofn);
+}
 
 BOOL CALLBACK DlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
 {
@@ -37,6 +48,9 @@
 			ReleaseDC(wnd,hdc);
 			return 0;
 		}
+	        case 102:
+		        FileOpen(wnd);
+			return 0;
 		default:
 			return DefWindowProc (wnd, msg, w, l);
 	}
diff --git a/toolkit/hello3res.rc b/toolkit/hello3res.rc
index 23f29c5..5f5408c 100644
--- a/toolkit/hello3res.rc
+++ b/toolkit/hello3res.rc
@@ -3,6 +3,7 @@
  POPUP "Menu demo" {
    MENUITEM "Dialog Demo", 100
    MENUITEM "Bitmap Demo", 101
+   MENUITEM "Open...", 102
  }
 }
 
@@ -14,13 +15,10 @@
 	CONTROL "Pushbutton", 100, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 14, 92, 52, 13
 	CONTROL "Checkbox", 101, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 19, 76, 47, 12
 	CONTROL "Static text", 102, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 17, 60, 39, 10
-#if 0
-	/* Edit controls don't work, yet */
 	CONTROL "Edit control", 103, "EDIT", ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 18, 41, 44, 13
-#endif
 	CONTROL "Radio button", 104, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 17, 23, 58, 12
 	CONTROL "Checkbox", 101, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 19, 76, 47, 12
-#if 0
+#if 1
 	CONTROL "", 106, "COMBOBOX", CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 86, 23, 86, 85
 #else
 	CONTROL "", 106, "LISTBOX", LBS_STANDARD | LBS_DISABLENOSCROLL | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 86, 23, 86, 85
diff --git a/toolkit/libres.c b/toolkit/libres.c
new file mode 100644
index 0000000..c983ff6
--- /dev/null
+++ b/toolkit/libres.c
@@ -0,0 +1,106 @@
+/*
+ * WINElib-Resources
+ *
+ * Copied and modified heavily from loader/resource.c
+ */
+
+#include <stdio.h>
+#include "windows.h"
+
+struct resource /* This needs to coincide with what winerc generates. */
+{               /* It should really only appear in one place.         */
+  int id, type;
+  char *name;
+  unsigned char *bytes;
+  unsigned int size;
+};
+
+typedef struct RLE
+{
+  struct resource** Resources  /* NULL-terminated array of pointers */
+  struct RLE* next;
+} ResListE;
+
+static ResListE* ResourceList=NULL;
+
+void LIBRES_RegisterResources(struct resource** Res)
+{
+  ResListE** Curr;
+  ResListE* n;
+  for(Curr=&ResourceList; *Curr; Curr=&((*Curr)->next)) { }
+  n=malloc(sizeof(ResListE));
+  if(n)
+  {
+    n.Resources=Res;
+    n.next=NULL;
+    *Curr=n;
+  }
+  else
+    fprintf(stderr,"LIBRES_RegisterResources(): Out of memory.\n");
+}
+
+/**********************************************************************
+ *	    LIBRES_FindResource    
+ */
+HRSRC LIBRES_FindResource( HMODULE hModule, SEGPTR name, SEGPTR type )
+{
+  WINELIB_UNIMP("LIBRES_FindResource()");
+  return 0;
+}
+
+
+/**********************************************************************
+ *	    LIBRES_LoadResource    
+ */
+HGLOBAL LIBRES_LoadResource( HMODULE hModule, HRSRC hRsrc )
+{
+  return (HGLOBAL)(((struct resource*)hRsrc)->bytes);
+}
+
+
+/**********************************************************************
+ *	    LIBRES_LockResource    
+ */
+LPVOID LIBRES_LockResource( HMODULE hModule, HGLOBAL handle )
+{
+  return handle;
+}
+
+
+/**********************************************************************
+ *	    LIBRES_FreeResource    
+ */
+BOOL LIBRES_FreeResource( HMODULE hModule, HGLOBAL handle )
+{
+  return 0;
+}
+
+
+/**********************************************************************
+ *	    LIBRES_AccessResource    
+ */
+INT LIBRES_AccessResource( HINSTANCE hModule, HRSRC hRsrc )
+{
+  WINELIB_UNIMP("LIBRES_AccessResource()");
+  return -1;
+}
+
+
+/**********************************************************************
+ *	    LIBRES_SizeofResource    
+ */
+DWORD LIBRES_SizeofResource( HMODULE hModule, HRSRC hRsrc )
+{
+  return (HGLOBAL)(((struct resource*)hRsrc)->size);
+}
+
+
+/**********************************************************************
+ *	    LIBRES_AllocResource    
+ */
+HGLOBAL LIBRES_AllocResource( HMODULE hModule, HRSRC hRsrc, DWORD size )
+{
+  WINELIB_UNIMP("LIBRES_AllocResource()");
+  return 0;
+}
+
diff --git a/toolkit/miscstubs.c b/toolkit/miscstubs.c
index ddeeb49..edab69e 100644
--- a/toolkit/miscstubs.c
+++ b/toolkit/miscstubs.c
@@ -48,43 +48,20 @@
   fprintf(stderr,"JBP: GlobalFreeAll() ignored.\n");
 }
 
-SEGPTR WIN16_GlobalLock(HGLOBAL h)
-{
-  return (SEGPTR)h;
-}
-
-
-HLOCAL LOCAL_Free( WORD ds, HLOCAL handle )
-{
-    return LocalFree(handle);
-}
-
-HLOCAL LOCAL_Alloc( WORD ds, WORD flags, WORD size )
-{
-    return LocalAlloc(flags,size);
-}
-
-HLOCAL LOCAL_ReAlloc( WORD ds, HLOCAL handle, WORD size, WORD flags )
-{
-    return LocalReAlloc(handle,size,flags);
-}
-
+SEGPTR WIN16_GlobalLock(HGLOBAL h) 
+  { return (SEGPTR)h; }
+HLOCAL LOCAL_Free(WORD ds, HLOCAL handle) 
+  { return LocalFree(handle); }
+HLOCAL LOCAL_Alloc(WORD ds, WORD flags, WORD size)
+  { return LocalAlloc(flags,size); }
+HLOCAL LOCAL_ReAlloc(WORD ds, HLOCAL handle, WORD size, WORD flags)
+  { return LocalReAlloc(handle,size,flags); }
 NPVOID LOCAL_Lock( WORD ds, HLOCAL handle )
-{
-    return LocalLock(handle);
-}
-
+  { return LocalLock(handle); }
 BOOL LOCAL_Unlock( WORD ds, HLOCAL handle )
-{
-    fprintf(stderr,"JBP: LOCAL_Unlock() ignored.\n");
-    return 1;
-}
-
+  { return LocalUnlock(handle); }
 WORD LOCAL_Size( WORD ds, HLOCAL handle )
-{
-    fprintf(stderr,"JBP: LOCAL_Size() ignored.\n");
-    return 0;
-}
+  { return LocalSize(handle); }
 
 void FarSetOwner(HANDLE a, WORD b)
 {