Release 970804

Sun Aug  3 14:03:43 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [documentation/Makefile.in]
	Create links for files included from wine.texinfo.

	* [wine.man]
	Moved to documentation dir.

	* [if1632/builtin.c]
	Made SYSTEM.DLL always loaded by default.

	* [loader/signal.c] [if1632/signal.c]
	Split signal.c in generic/emulator-specific parts.

	* [misc/system.c] [if1632/thunk.c]
	Implemented system timer functions.
	Fixed InquireSystem parameters.

	* [msdos/ioports.c]
	Defined inb/outb functions to avoid including asm/io.h.
	Use the right instruction for word and dword direct access.

	* [multimedia/mmsystem.c]
	Fixed CallTo16 usage.

Sat Aug 2 13:05:23 1997  Andreas Mohr <100.30936@germany.net>

	* [controls/edit.c]
	When text is inserted into a newly created editline, the caret
	is placed after the text. Should be placed before the text. Fixed.

	* [files/file.c]
	Removed O_TRUNC flag from OF_WRITE mode in _lopen32().
	According to doc _lopen() never truncates files.

	* [if1632/user.spec] [misc/comm.c]
	Added stub for EnableCommNotification().

	* [misc/ver.c]
	Fixed problem with VerQueryValue*() running over end of name table
	in rare cases.

	* [msdos/int21.c]
	Enhanced ioctlGetDeviceInfo() to correctly return the current drive.

	* [multimedia/joystick.c] [windows/message.c]
	Added joystick support !!!
	Needs Linux >= 2.1.45 or joystick-0.8.0.tar.gz.

Fri Aug  1 18:02:09 1997  Morten Welinder  <terra@diku.dk>

	* [if1632/user32.spec]
	Define DrawAnimatedRects32.

	* [graphics/painting.c]
	(DrawAnimatedRects32): Create stub.

	* [misc/registry.c]
	Cope with NULL class in RegQueryInfoKey32A.

	* [if1632/user32.spec]
	Add GetMenuItemInfo32[AW].

	* [controls/menu.c]
	(InsertMenu32A): Upgrade flags to 8 hex-digits.
	(MENUEX_ParseResource): First shot at implementation.
	(LoadMenuIndirect32A): Handle extended menus.
	(GetMenuItemInfo32[AW]): First shot at implementation.

	* [include/windows.h]
	Define MFT_*, MFS_*, MIIM_* macros.  Define MENUITEMINFO[AW]
 	structures and pointers.

	* [Makefile.in]
	(etags): Add TAGS as target.

	* [if1632/comctl32.spec]
	Use Windows 95's ordinals.  Add a few missing stubs.

Thu Jul 31 14:01:13 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [objects/color.c]
	Fix for 16 color mode of XFree.

	* [if1632/kernel32.spec][win32/ordinals.c]
	Moved/added some ordinal only exported functions from kernel32.dll
	(mostly thunking preparation stuff).

Wed Jul 30 09:16:38 1997  John Harvey <john@division.co.uk>

	* [graphics/win16drv/init.c] [include/win16drv.h]
        Escape(SETABORTPROC) returns success to keep pbrush.exe happy.
        Escape(NEXTBAND) implemented to make HP PCL printer driver work in
 	word.  Stub for PATBLT added to start work on printing more than
 	text.

Mon Jul 28 13:14:28 1997  Victor Schneider <vischne@ibm.net>

	* [libtest/expand.c]
	New Winelib test program.

Wed Jul 23 09:37:13 1997  Adrian Harvey <adrian@select.com.au>

	* [tools/build.c] [tools/build-spec.txt] [if1632/kernel.spec]
	  [if1632/user.spec]
	Added ability to set filename wine considers the built-in DLLs 
	to be in  to something other than name.DLL with new "file" key
	in .spec files.
	Made kernel filename KRNL386.EXE (some programs use this name 
	explicitly - ChemOffice install now starts up).
	Made user filename USER.EXE (just to be tidy).

Sun Jul 20 23:51:02 1997  David A. Cuthbert <dacut@henry.ece.cmu.edu>

	* [controls/menu.c] [misc/tweak.c] [include/tweak.h]
	Fixed MENU_KeyLeft and MENU_KeyRight to handle multiple-column
	menus.  Misc menu drawing issues for Win95 tweaks fixed.  Misc
	warnings fixed.

	* [loader/module.c]
	Spaces are now permitted in file/path names on the command line.
	If multiple matches can be made, the preferred match is the
	path/file with fewer spaces.

Tue Jul 29 02:21:15 1997  Bruce Milner <Bruce.Milner@genetics.utah.edu>

	* [misc/compobj.c]
	Added CLSIDFromString and StringFromCLSID.
diff --git a/programs/progman/grpfile.c b/programs/progman/grpfile.c
index 44f9f04..bb4a5e5 100644
--- a/programs/progman/grpfile.c
+++ b/programs/progman/grpfile.c
@@ -2,10 +2,12 @@
  * Program Manager
  *
  * Copyright 1996 Ulrich Schmid
+ *           1997 Peter Schlaile
  */
 
 #include "windows.h"
 #include "progman.h"
+#include "mmsystem.h"
 
 #define MALLOCHUNK 1000
 
@@ -370,11 +372,11 @@
     }
 
   {
-    /* Warn about the incompatibility */
+    /* Warn about the (possible) incompatibility */
     CHAR msg[MAX_PATHNAME_LEN + 200];
     wsprintf(msg,
 	     "Group files written by this DRAFT Program Manager "
-	     "cannot be read by the Microsoft Program Manager!!\n"
+	     "possibly cannot be read by the Microsoft Program Manager!!\n"
 	     "Are you sure to write %s?", szPath);
     if (IDOK != MessageBox(Globals.hMainWnd, msg, "WARNING",
 			   MB_OKCANCEL | MB_DEFBUTTON2)) return FALSE;
@@ -425,6 +427,72 @@
   *Icons += sizeXor;
 }
 
+/***********************************************************************/
+UINT16 GRPFILE_checksum;
+BOOL GRPFILE_checksum_half_word;
+BYTE GRPFILE_checksum_last_byte;
+/***********************************************************************
+ *
+ *           GRPFILE_InitChecksum
+ */
+
+static void GRPFILE_InitChecksum()
+{
+	GRPFILE_checksum = 0;
+	GRPFILE_checksum_half_word = 0;
+}
+
+/***********************************************************************
+ *
+ *           GRPFILE_GetChecksum
+ */
+
+static UINT16 GRPFILE_GetChecksum()
+{
+	return GRPFILE_checksum;
+}
+
+/***********************************************************************
+ *
+ *           GRPFILE_WriteWithChecksum
+ * 
+ * Looks crazier than it is:
+ * 
+ * chksum = 0;
+ * chksum = cksum - 1. word;
+ * chksum = cksum - 2. word;
+ * ...
+ * 
+ * if (filelen is even)
+ *      great I'm finished
+ * else
+ *      ignore last byte
+ */
+
+static UINT GRPFILE_WriteWithChecksum(HFILE file, LPCSTR str, UINT size)
+{
+	UINT i;
+	if (GRPFILE_checksum_half_word) {
+		GRPFILE_checksum -= GRPFILE_checksum_last_byte;	
+	}
+	for (i=0; i < size; i++) {
+		if (GRPFILE_checksum_half_word) {
+			GRPFILE_checksum -= str[i] << 8;
+		} else {
+			GRPFILE_checksum -= str[i];
+		}
+		GRPFILE_checksum_half_word ^= 1;
+	}
+	
+	if (GRPFILE_checksum_half_word) {
+		GRPFILE_checksum_last_byte = str[size-1];
+		GRPFILE_checksum += GRPFILE_checksum_last_byte;
+	}
+	
+	return _lwrite(file, str, size);
+}
+
+
 /***********************************************************************
  *
  *           GRPFILE_DoWriteGroupFile
@@ -439,6 +507,10 @@
   BOOL   need_extension;
   LPCSTR lpszTitle = LocalLock(group->hName);
 
+  UINT16 checksum;
+	
+  GRPFILE_InitChecksum();
+	
   /* Calculate offsets */
   NumProg = 0;
   Icons   = 0;
@@ -467,14 +539,10 @@
   /* Header */
   buffer[0] = 'P';
   buffer[1] = 'M';
-#if 0
-  buffer[2] = 'C'; /* Original magic number */
+  buffer[2] = 'C'; 
   buffer[3] = 'C';
-#else
-  buffer[2] = 'X'; /* Modified magic number: no checksum */
-  buffer[3] = 'X';
-#endif
-  PUT_SHORT(buffer,  4, 0); /* Checksum ignored */
+	
+  PUT_SHORT(buffer,  4, 0); /* Checksum zero for now, written later */
   PUT_SHORT(buffer,  6, Extension);
   /* Update group->nCmdShow */
   if (IsIconic(group->hWnd))      nCmdShow = SW_SHOWMINIMIZED;
@@ -494,7 +562,7 @@
   PUT_SHORT(buffer, 30, 0x0000); /* unknown */
   PUT_SHORT(buffer, 32, NumProg);
 
-  if (HFILE_ERROR == _lwrite(file, buffer, 34)) return FALSE;
+  if (HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 34)) return FALSE;
 
   /* Program table */
   CurrProg = Progs;
@@ -505,14 +573,16 @@
       PROGRAM *program = LocalLock(hProgram);
 
       PUT_SHORT(buffer, 0, CurrProg);
-      if (HFILE_ERROR == _lwrite(file, buffer, 2)) return FALSE;
+      if (HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 2)) 
+	      return FALSE;
 
       GRPFILE_CalculateSizes(program, &CurrProg, &CurrIcon);
       hProgram = program->hNext;
     }
 
   /* Title */
-  if (HFILE_ERROR == _lwrite(file, lpszTitle, lstrlen(lpszTitle) + 1))
+  if (HFILE_ERROR == GRPFILE_WriteWithChecksum(file, lpszTitle, 
+					       lstrlen(lpszTitle) + 1))
     return FALSE;
 
   /* Program entries */
@@ -545,10 +615,10 @@
       ptr += lstrlen(CmdLine) + 1;
       PUT_SHORT(buffer, 22, ptr);
 
-      if (HFILE_ERROR == _lwrite(file, buffer, 24) ||
-	  HFILE_ERROR == _lwrite(file, Name, lstrlen(Name) + 1) ||
-	  HFILE_ERROR == _lwrite(file, CmdLine, lstrlen(CmdLine) + 1) ||
-	  HFILE_ERROR == _lwrite(file, IconFile, lstrlen(IconFile) + 1))
+      if (HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 24) ||
+	  HFILE_ERROR == GRPFILE_WriteWithChecksum(file, Name, lstrlen(Name) + 1) ||
+	  HFILE_ERROR == GRPFILE_WriteWithChecksum(file, CmdLine, lstrlen(CmdLine) + 1) ||
+	  HFILE_ERROR == GRPFILE_WriteWithChecksum(file, IconFile, lstrlen(IconFile) + 1))
 	return FALSE;
 
       GRPFILE_CalculateSizes(program, &CurrProg, &CurrIcon);
@@ -574,9 +644,9 @@
       buffer[10] = iconinfo->bPlanes;
       buffer[11] = iconinfo->bBitsPerPixel;
 
-      if (HFILE_ERROR == _lwrite(file, buffer, 12) ||
-	  HFILE_ERROR == _lwrite(file, AndBits, sizeAnd) ||
-	  HFILE_ERROR == _lwrite(file, XorBits, sizeXor)) return FALSE;
+      if (HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 12) ||
+	  HFILE_ERROR == GRPFILE_WriteWithChecksum(file, AndBits, sizeAnd) ||
+	  HFILE_ERROR == GRPFILE_WriteWithChecksum(file, XorBits, sizeXor)) return FALSE;
 
       hProgram = program->hNext;
     }
@@ -589,7 +659,8 @@
       PUT_SHORT(buffer, 4, 0x000a);
       buffer[6] = 'P', buffer[7] = 'M';
       buffer[8] = 'C', buffer[9] = 'C';
-      if (HFILE_ERROR == _lwrite(file, buffer, 10)) return FALSE;
+      if (HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 10)) 
+	      return FALSE;
 
       seqnum = 0;
       hProgram = group->hPrograms;
@@ -604,8 +675,8 @@
 	      PUT_SHORT(buffer, 0, 0x8101);
 	      PUT_SHORT(buffer, 2, seqnum);
 	      PUT_SHORT(buffer, 4, 7 + lstrlen(lpszWorkDir));
-	      if (HFILE_ERROR == _lwrite(file, buffer, 6) ||
-		  HFILE_ERROR == _lwrite(file, lpszWorkDir, lstrlen(lpszWorkDir) + 1))
+	      if (HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 6) ||
+		  HFILE_ERROR == GRPFILE_WriteWithChecksum(file, lpszWorkDir, lstrlen(lpszWorkDir) + 1))
 		return FALSE;
 	    }
 
@@ -616,7 +687,7 @@
 	      PUT_SHORT(buffer, 2, seqnum);
 	      PUT_SHORT(buffer, 4, 8);
 	      PUT_SHORT(buffer, 6, program->nHotKey);
-	      if (HFILE_ERROR == _lwrite(file, buffer, 8)) return FALSE;
+	      if (HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 8)) return FALSE;
 	    }
 
 	  /* Show command */
@@ -626,7 +697,7 @@
 	      PUT_SHORT(buffer, 2, seqnum);
 	      PUT_SHORT(buffer, 4, 8);
 	      PUT_SHORT(buffer, 6, program->nCmdShow);
-	      if (HFILE_ERROR == _lwrite(file, buffer, 8)) return FALSE;
+	      if (HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 8)) return FALSE;
 	    }
 
 	  seqnum++;
@@ -637,9 +708,14 @@
       PUT_SHORT(buffer, 0, 0xffff);
       PUT_SHORT(buffer, 2, 0xffff);
       PUT_SHORT(buffer, 4, 0x0000);
-      if (HFILE_ERROR == _lwrite(file, buffer, 6)) return FALSE;
+      if (HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 6)) return FALSE;
     }
 
+  checksum = GRPFILE_GetChecksum();
+  _llseek(file, 4, SEEK_SET);
+  PUT_SHORT(buffer, 0, checksum);
+  _lwrite(file, buffer, 2);
+
   return TRUE;
 }