changeset 1362:412af8059331

Attempt to get it building with Mingw again... builds but crashes. Fix building DLL without HTML widget support... Mingw is missing required headers. Moved wrapper functions into the main source file so it will export the APIs even if unsupported. Removed debugging code from XBrowseForFolder.cpp because Mingw does not support it.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 18 Nov 2011 18:56:40 +0000
parents 324812debcc9
children cdbe26a4b116
files makefile.mingw win/XBrowseForFolder.cpp win/browser.c win/dirent.c win/dw.c win/dwcompat-mingw.def
diffstat 6 files changed, 128 insertions(+), 122 deletions(-) [+]
line wrap: on
line diff
--- a/makefile.mingw	Fri Nov 18 16:50:49 2011 +0000
+++ b/makefile.mingw	Fri Nov 18 18:56:40 2011 +0000
@@ -9,36 +9,40 @@
 DEFS =
 LIBS =
 
-CFLAGS = -O -g -DMSVC -DBUILD_DLL -I../ -I../platform -Wall -mthreads -o $(@)
-LDFLAGS = -shared -mwindows -mthreads -lcomctl32
+CFLAGS = -O -g -DMSVC -DWIN32 -D__WIN32__ -DGDIPLUS -DBUILD_DLL -I./win -I. -I./platform -Wall -mthreads -o $(@)
+LDFLAGS = -shared -mwindows -mthreads -lcomctl32 -lole32 -loleaut32 -luserenv -lmsimg32 -lgdiplus
 
 COMPATOBJECTS = compat.o dirent.o
+OBJECTS = dw.o XBrowseForFolder.o
 
 VPATH=../ ../win
 
 all: dw.dll dwcompat.dll dwtest.exe
 
-dw.dll:  dw.o ../win/dww.def
-	$(CC) $(CFLAGS) $(DEFS) -o dw.dll dw.o $(LDFLAGS) \
-	-Wl,--out-implib,dw.a -Wl,-Map,dw.dll.map -Wl,--cref ../win/dw-mingw.def
+dw.dll:  $(OBJECTS) win/dw-mingw.def
+	$(CC) $(CFLAGS) $(DEFS) -o dw.dll $(OBJECTS) $(LDFLAGS) \
+	-Wl,--out-implib,dw.a -Wl,-Map,dw.dll.map -Wl,--cref  -Wl,--enable-stdcall-fixup win/dw-mingw.def 
 
-dwcompat.dll:  $(COMPATOBJECTS)
+dwcompat.dll:  $(COMPATOBJECTS) win/dwcompat-mingw.def
 	$(CC) $(CFLAGS) $(DEFS) -o dwcompat.dll $(COMPATOBJECTS) $(LDFLAGS) -lwsock32 \
-  -Wl,--out-implib,dwcompat.a -Wl,-Map,dwcompat.dll.map -Wl,--cref ../win/dwcompat-mingw.def
+  -Wl,--out-implib,dwcompat.a -Wl,-Map,dwcompat.dll.map -Wl,--cref  -Wl,--enable-stdcall-fixup win/dwcompat-mingw.def 
 
 dwtest.exe: dwtest.o dw.a dwcompat.a
 	$(CC) $(CFLAGS) -o dwtest.exe dwtest.o dw.a dwcompat.a
 
-dw.obj: dw.c
+dw.o: win/dw.c
+	$(CC) $(CFLAGS) -c $<	
+
+XBrowseForFolder.o: win/XBrowseForFolder.cpp
 	$(CC) $(CFLAGS) -c $<	
 
-compat.obj: compat.c
+compat.o: compat.c
 	$(CC) $(CFLAGS) -c $<	
 
-dirent.obj: os2/dirent.c
+dirent.o: win/dirent.c
 	$(CC) $(CFLAGS) -c $<	
 
-dwtest.obj: dwtest.c
+dwtest.o: dwtest.c
 	$(CC) $(CFLAGS) -c $<	
 
 DEPS := $(wildcard *.d)
--- a/win/XBrowseForFolder.cpp	Fri Nov 18 16:50:49 2011 +0000
+++ b/win/XBrowseForFolder.cpp	Fri Nov 18 18:56:40 2011 +0000
@@ -29,12 +29,11 @@
 //
 ///////////////////////////////////////////////////////////////////////////////
 
-// if you don't want to use MFC, comment out the following line:
-//#include "stdafx.h"
+/* Make sure we get the right version */
+#define _WIN32_IE 0x0500
 
 #ifndef __AFX_H__
 #include "windows.h"
-#include "crtdbg.h"
 #include "tchar.h"
 #endif
 
@@ -42,22 +41,15 @@
 #include "io.h"
 #include "XBrowseForFolder.h"
 
+#ifndef __MINGW32__
 #pragma warning(disable: 4127)	// conditional expression is constant (_ASSERTE)
 #pragma warning(disable : 4996)	// disable bogus deprecation warning
-
-#ifndef __noop
-#if _MSC_VER < 1300
-#define __noop ((void)0)
-#endif
 #endif
 
-#undef TRACE
-#define TRACE __noop
-
-//=============================================================================
-// if you want to see the TRACE output, uncomment this line:
-//#include "XTrace.h"
-//=============================================================================
+/* MingW does not have this */
+#if !defined(BIF_NONEWFOLDERBUTTON)
+# define BIF_NONEWFOLDERBUTTON 0x200
+#endif
 
 //=============================================================================
 // struct to pass to callback function
@@ -99,7 +91,6 @@
 // ScreenToClientX - helper function in case non-MFC
 static void ScreenToClientX(HWND hWnd, LPRECT lpRect)
 {
-	_ASSERTE(::IsWindow(hWnd));
 	::ScreenToClient(hWnd, (LPPOINT)lpRect);
 	::ScreenToClient(hWnd, ((LPPOINT)lpRect)+1);
 }
@@ -108,7 +99,6 @@
 // MoveWindowX - helper function in case non-MFC
 static void MoveWindowX(HWND hWnd, CRect& rect, BOOL bRepaint)
 {
-	_ASSERTE(::IsWindow(hWnd));
 	::MoveWindow(hWnd, rect.left, rect.top,
 		rect.Width(), rect.Height(), bRepaint);
 }
@@ -117,8 +107,6 @@
 // SizeBrowseDialog - resize dialog, move controls
 static void SizeBrowseDialog(HWND hWnd, FOLDER_PROPS *fp)
 {
-	TRACE(_T("in void SizeBrowseDialog\n"));
-
 	// find the folder tree and make dialog larger
 	HWND hwndTree = FindWindowEx(hWnd, NULL, _T("SysTreeView32"), NULL);
 
@@ -127,19 +115,15 @@
 		// ... this usually means that BIF_NEWDIALOGSTYLE is enabled.
 		// Then the class name is as used in the code below.
 		hwndTree = FindWindowEx(hWnd, NULL, _T("SHBrowseForFolder ShellNameSpace Control"), NULL);
-		TRACE(_T("SHBrowseForFolder ShellNameSpace Control: hwndTree=%X\n"), hwndTree);
 	}
 
 	CRect rectDlg;
 
-	_ASSERTE(IsWindow(hwndTree));
-
 	if (hwndTree)
 	{
 		// check if edit box
 		int nEditHeight = 0;
 		HWND hwndEdit = FindWindowEx(hWnd, NULL, _T("Edit"), NULL);
-		TRACE(_T("hwndEdit=%x\n"), hwndEdit);
 		CRect rectEdit;
 		if (hwndEdit && (fp->ulFlags & BIF_EDITBOX))
 		{
@@ -185,7 +169,6 @@
 		rectCancel.left = rectCancel.right - w;
 		if (hwndCancel)
 		{
-			//TRACERECT(rectCancel);
 			MoveWindowX(hwndCancel, rectCancel, FALSE);
 		}
 
@@ -224,14 +207,8 @@
 		rectTree.left = hMargin;
 		rectTree.bottom = rectOK.top - 10;//nMargin;
 		rectTree.right = rectDlg.right - hMargin;
-		//TRACERECT(rectTree);
 		MoveWindowX(hwndTree, rectTree, FALSE);
 	}
-	else
-	{
-		TRACE(_T("ERROR - tree control not found.\n"));
-		//_ASSERTE(hwndTree);
-	}
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -247,8 +224,6 @@
 	{
 		case BFFM_INITIALIZED:		// sent when the browse dialog box has finished initializing.
 		{
-			TRACE(_T("hWnd=%X\n"), hWnd);
-
 			// remove context help button from dialog caption
 			LONG lStyle = ::GetWindowLong(hWnd, GWL_STYLE);
 			lStyle &= ~DS_CONTEXTHELP;
@@ -295,12 +270,10 @@
 					SHFILEINFO sfi;
 					::SHGetFileInfo((LPCTSTR)lParam, 0, &sfi, sizeof(sfi),
 							SHGFI_PIDL | SHGFI_ATTRIBUTES);
-					TRACE(_T("dwAttributes=0x%08X\n"), sfi.dwAttributes);
 
 					// fail if pidl is a link
 					if (sfi.dwAttributes & SFGAO_LINK)
 					{
-						TRACE(_T("SFGAO_LINK\n"));
 						bRet = FALSE;
 					}
 				}
@@ -311,8 +284,6 @@
 			{
 				::EnableWindow(GetDlgItem(hWnd, IDOK), FALSE);
 			}
-
-			TRACE(_T("szDir=%s\n"), szDir);
 		}
 		break;
 	}
@@ -351,9 +322,6 @@
 					  DWORD dwBufSize,
 					  BOOL bEditBox /*= FALSE*/)
 {
-	_ASSERTE(lpszBuf);
-	_ASSERTE(dwBufSize >= MAX_PATH);
-
 	if (lpszBuf == NULL || dwBufSize < MAX_PATH)
 		return FALSE;
 
@@ -377,7 +345,6 @@
 		{
 			// csidl
 			int nFolder = LOWORD((UINT)(UINT_PTR)lpszInitialFolder);
-			TRACE(_T("csidl:  nFolder=0x%X\n"), nFolder);
 			SHGetSpecialFolderPath(hWnd, szInitialPath, nFolder, FALSE);
 		}
 		else
@@ -386,7 +353,6 @@
 			_tcsncpy(szInitialPath, lpszInitialFolder,
 						sizeof(szInitialPath)/sizeof(TCHAR)-2);
 		}
-		TRACE(_T("szInitialPath=<%s>\n"), szInitialPath);
 	}
 
 	if ((szInitialPath[0] == _T('\0')) && (bi.pidlRoot == NULL))
@@ -424,10 +390,6 @@
 			_tcsncpy(lpszBuf, szBuffer, dwBufSize-1);
 			bRet = TRUE;
 		}
-		else
-		{
-			TRACE(_T("SHGetPathFromIDList failed\n"));
-		}
 	}
 
 	// free up pidls
--- a/win/browser.c	Fri Nov 18 16:50:49 2011 +0000
+++ b/win/browser.c	Fri Nov 18 18:56:40 2011 +0000
@@ -1138,7 +1138,7 @@
  * this function to display numerous pages in the specified window.
  */
 
-void API dw_html_action(HWND hwnd, int action)
+void _dw_html_action(HWND hwnd, int action)
 {	
 	IWebBrowser2	*webBrowser2;
 	IOleObject		*browserObject;
@@ -1225,7 +1225,7 @@
  * this function to display numerous pages in the specified window.
  */
 
-int API dw_html_raw(HWND hwnd, char *string)
+int _dw_html_raw(HWND hwnd, char *string)
 {	
 	IWebBrowser2	*webBrowser2;
 	LPDISPATCH		lpDispatch;
@@ -1354,7 +1354,7 @@
  * this function to display numerous pages in the specified window.
  */
 
-int API dw_html_url(HWND hwnd, char *url)
+int _dw_html_url(HWND hwnd, char *url)
 {
 	IWebBrowser2	*webBrowser2;
 	VARIANT			myURL;
--- a/win/dirent.c	Fri Nov 18 16:50:49 2011 +0000
+++ b/win/dirent.c	Fri Nov 18 18:56:40 2011 +0000
@@ -7,6 +7,7 @@
 
 #include "compat.h"
 #include <errno.h>
+#include <direct.h>
 
 #define error(rc) errno = 255
 
@@ -136,7 +137,6 @@
 
 	if (dir->number)
 	{
-		ULONG rc;
 		dir->count = 100;
 		if(!FindNextFile(dir->handle, &(dir->data)))
 		{
@@ -172,7 +172,6 @@
 {
 	if (dir->number > off) {
 		char name[MAXPATHLEN+2];
-		ULONG rc;
 
 		FindClose(dir->handle);
 
--- a/win/dw.c	Fri Nov 18 16:50:49 2011 +0000
+++ b/win/dw.c	Fri Nov 18 18:56:40 2011 +0000
@@ -18,6 +18,8 @@
 #include <string.h>
 #include <stdio.h>
 #include <process.h>
+#include <malloc.h>
+#include <io.h>
 #include <time.h>
 #include <math.h>
 #include "dw.h"
@@ -100,13 +102,22 @@
 #endif
 
 /*
- * MinGW (as at 3.2.3) doesn't have MIM_MENUDATA
- * so #define it here
+ * MinGW Is missing a bunch of definitions
+ * so #define them here...
  */
 
 #if !defined( MIM_MENUDATA )
 # define MIM_MENUDATA 0x00000008
 #endif
+#if !defined(PBS_MARQUEE)
+# define PBS_MARQUEE 0x08
+#endif
+#if !defined(PBM_SETMARQUEE)
+# define PBM_SETMARQUEE (WM_USER+10)
+#endif
+#if !defined(LVS_EX_DOUBLEBUFFER)
+# define LVS_EX_DOUBLEBUFFER 0x10000
+#endif
 
 HWND popup = (HWND)NULL, DW_HWND_OBJECT = (HWND)NULL;
 
@@ -160,7 +171,7 @@
 static int screenx, screeny;
 HFONT _DefaultFont = NULL;
 
-#ifdef BUILD_DLL
+#if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
 LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 #endif
 void _resize_notebook_page(HWND handle, int pageid);
@@ -391,7 +402,7 @@
    {
       strcpy( file, filename );
       strcat( file, image_exts[i] );
-      if ( access( file, 04 ) == 0 )
+      if ( _access( file, 04 ) == 0 )
       {
          /* Convert to wide format */
          MultiByteToWideChar(CP_ACP, 0, file, strlen(file)+1, wfile, wclen);
@@ -1707,12 +1718,12 @@
 {
    char buffer[40];
    int checkable;
-   sprintf( buffer, "_dw_checkable%ld", id );
+   sprintf( buffer, "_dw_checkable%d", id );
    checkable = (int)dw_window_get_data(DW_HWND_OBJECT, buffer);
    if ( checkable )
    {
       int is_checked;
-      sprintf( buffer, "_dw_ischecked%ld", id );
+      sprintf( buffer, "_dw_ischecked%d", id );
       is_checked = (int)dw_window_get_data(DW_HWND_OBJECT, buffer);
       is_checked = (is_checked) ? 0 : 1;
       dw_menu_item_set_check( window, id, is_checked );
@@ -2256,7 +2267,7 @@
             GetClassName( hWnd, tmpbuf, 99 );
             if ( strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1 ) == 0 )
             {
-               int value = _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1));
+               _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1));
             }
          }
       }
@@ -2876,9 +2887,7 @@
 /* Window procedure for container/listview */
 BOOL CALLBACK _containerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
 {
-   ContainerInfo *cinfo;
-
-   cinfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
+   ContainerInfo *continfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
 
    switch( msg )
    {
@@ -2888,18 +2897,18 @@
       _wndproc(hWnd, msg, mp1, mp2);
       break;
    case WM_PAINT:
-       if(cinfo->cinfo.pOldProc && (cinfo->even != DW_RGB_TRANSPARENT || cinfo->odd != DW_RGB_TRANSPARENT))
+       if(continfo->cinfo.pOldProc && (continfo->even != DW_RGB_TRANSPARENT || continfo->odd != DW_RGB_TRANSPARENT))
        {
             RECT rectUpd, rectDestin, rect;
             int iItems, iTop, i;
             COLORREF c;
 
             /* Load the default background color for the first pass */
-            ListView_SetTextBkColor(hWnd, cinfo->cinfo.back != -1 ? cinfo->cinfo.back : ListView_GetBkColor(hWnd));
+            ListView_SetTextBkColor(hWnd, continfo->cinfo.back != -1 ? continfo->cinfo.back : ListView_GetBkColor(hWnd));
             /* get the rectangle to be updated */
             GetUpdateRect(hWnd, &rectUpd, FALSE);
             /* allow default processing first */
-            CallWindowProc(cinfo->cinfo.pOldProc, hWnd, msg, 0, 0);
+            CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, 0, 0);
             /* number of displayed rows */
             iItems = ListView_GetCountPerPage(hWnd);
             /* first visible row */
@@ -2911,7 +2920,7 @@
                 if(ListView_GetItemRect(hWnd, i, &rect, LVIR_BOUNDS) && IntersectRect(&rectDestin, &rectUpd, &rect)) 
                 {
                     /* change text background colour accordingly */
-                    c = (i % 2) ? cinfo->odd : cinfo->even;
+                    c = (i % 2) ? continfo->odd : continfo->even;
 
                     if(c != DW_RGB_TRANSPARENT)
                     {
@@ -2919,7 +2928,7 @@
                         /* invalidate the row rectangle then... */
                         InvalidateRect(hWnd, &rectDestin, FALSE);
                         /* ...force default processing */
-                        CallWindowProc(cinfo->cinfo.pOldProc, hWnd, msg, 0, 0);
+                        CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, 0, 0);
                     }
                 }
             }            
@@ -3025,9 +3034,9 @@
       break;
    }
 
-   if(!cinfo || !cinfo->cinfo.pOldProc)
+   if(!continfo || !continfo->cinfo.pOldProc)
       return DefWindowProc(hWnd, msg, mp1, mp2);
-   return CallWindowProc(cinfo->cinfo.pOldProc, hWnd, msg, mp1, mp2);
+   return CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, mp1, mp2);
 }
 
 BOOL CALLBACK _treewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
@@ -3375,8 +3384,6 @@
 BOOL CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2)
 {
    BubbleButton *bubble;
-   POINT point;
-   RECT rect;
    WNDPROC pOldProc;
 
    bubble = (BubbleButton *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
@@ -3629,8 +3636,7 @@
    WNDCLASS wc;
    int z;
    INITCOMMONCONTROLSEX icc;
-   char *fname, *alttmpdir;
-   HFONT oldfont;
+   char *alttmpdir;
 #ifdef GDIPLUS
    struct GdiplusStartupInput si; 
 #endif
@@ -3698,7 +3704,7 @@
 
    RegisterClass(&wc);
 
-#ifdef BUILD_DLL
+#if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
    /* Register HTML renderer class */
    memset(&wc, 0, sizeof(WNDCLASS));
    wc.lpfnWndProc = (WNDPROC)_browserWindowProc;
@@ -4727,7 +4733,7 @@
  */
 HWND API dw_html_new(unsigned long id)
 {
-#if defined(BUILD_DLL) || defined(BUILD_HTML)
+#if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
    return CreateWindow(BrowserClassName,
                   "",
                   WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS,
@@ -4742,6 +4748,61 @@
 #endif
 }
 
+#if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
+void _dw_html_action(HWND hwnd, int action);
+int _dw_html_raw(HWND hwnd, char *string);
+int _dw_html_url(HWND hwnd, char *url);
+#endif
+
+/*
+ * Causes the embedded HTML widget to take action.
+ * Parameters:
+ *       handle: Handle to the window.
+ *       action: One of the DW_HTML_* constants.
+ */
+void API dw_html_action(HWND handle, int action)
+{
+#if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
+   _dw_html_action(handle, action);
+#endif
+}
+
+/*
+ * Render raw HTML code in the embedded HTML widget..
+ * Parameters:
+ *       handle: Handle to the window.
+ *       string: String buffer containt HTML code to
+ *               be rendered.
+ * Returns:
+ *       DW_ERROR_NONE (0) on success.
+ */
+int API dw_html_raw(HWND handle, char *string)
+{
+#if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
+   return _dw_html_raw(handle, string);
+#else
+   return DW_ERROR_GENERAL;
+#endif
+}
+
+/*
+ * Render file or web page in the embedded HTML widget..
+ * Parameters:
+ *       handle: Handle to the window.
+ *       url: Universal Resource Locator of the web or
+ *               file object to be rendered.
+ * Returns:
+ *       DW_ERROR_NONE (0) on success.
+ */
+int API dw_html_url(HWND handle, char *url)
+{
+#if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
+   return _dw_html_url(handle, url);
+#else
+   return DW_ERROR_GENERAL;
+#endif    
+}
+
 /*
  * Create a bitmap object to be packed.
  * Parameters:
@@ -5543,7 +5604,7 @@
    BubbleButton *bubble;
    HBITMAP hbitmap = 0;
    HANDLE hicon = 0;
-   int windowtype = 0, len;
+   int windowtype = 0;
 
    if (!(bubble = calloc(1, sizeof(BubbleButton))))
       return 0;
@@ -5604,7 +5665,7 @@
    HANDLE hicon = 0;
    char *file;
    FILE *fp;
-   int windowtype;
+   int windowtype = BS_BITMAP;
 
    if ( !(bubble = calloc(1, sizeof(BubbleButton))) )
       return 0;
@@ -5620,16 +5681,10 @@
          if((hicon = _dw_load_icon(file)))
             windowtype = BS_ICON;
          else
-         {
             hbitmap = _dw_load_bitmap(file, NULL);
-            windowtype = BS_BITMAP;
-         }
 #else
          if ( len > 1 && data[0] == 'B' && data[1] == 'M' ) /* first 2 chars of data is BM, then its a BMP */
-         {
             hbitmap = (HBITMAP)LoadImage( NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
-            windowtype = BS_BITMAP;
-         }
          else /* otherwise its assumed to be an ico */
          {
             hicon = LoadImage( NULL, file, IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
@@ -5921,10 +5976,10 @@
  */
 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename)
 {
-   HBITMAP hbitmap;
+   HBITMAP hbitmap = 0;
    HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
-   HICON icon = 0;
-   HICON oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0);
+   HANDLE icon = 0;
+   HANDLE oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0);
 
    if(id)
    {
@@ -6593,8 +6648,6 @@
       {
          if(!array[z])
          {
-            int oldpage = TabCtrl_GetCurSel(handle);
-
             array[z] = calloc(1, sizeof(NotebookPage));
             array[z]->realid = refid;
             array[z]->item.mask = TCIF_TEXT;
@@ -7942,7 +7995,7 @@
  */
 HICN API dw_icon_load_from_data(char *data, int len)
 {
-   HANDLE icon;
+   HANDLE icon = 0;
    char *file;
    FILE *fp;
 
@@ -8866,7 +8919,7 @@
    HDC hdcPaint;
    HBRUSH oldBrush;
    HPEN oldPen;
-   POINT *points;
+   POINT *points = NULL;
    int i;
 
    if ( handle )
@@ -8901,6 +8954,8 @@
          npoints++;
       }
    }
+   else
+      return;
 
    oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) );
    oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) );
@@ -9126,8 +9181,6 @@
 {
    HPIXMAP pixmap;
    HDC hdc;
-   COLORREF bkcolor;
-   ULONG cx, cy;
 
    if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
       return NULL;
@@ -9214,8 +9267,6 @@
    HPIXMAP pixmap;
    BITMAP bm;
    HDC hdc;
-   ULONG cx, cy;
-   BITMAPINFO *info;
 #ifndef GDIPLUS
    char *file;
 #endif
@@ -9283,7 +9334,6 @@
    HDC hdc;
    char *file;
    FILE *fp;
-   ULONG cx, cy;
 
    if ( !(pixmap = calloc(1,sizeof(struct _hpixmap))) )
    {
@@ -10164,7 +10214,7 @@
  *       Pointer to an allocated string of text or NULL if clipboard empty or contents could not
  *       be converted to text.
  */
-char *dw_clipboard_get_text()
+char * API dw_clipboard_get_text(void)
 {
    HANDLE handle;
    char *tmp, *ret = NULL;
@@ -10192,7 +10242,7 @@
  * Parameters:
  *       Text.
  */
-void dw_clipboard_set_text( char *str, int len )
+void API dw_clipboard_set_text( char *str, int len )
 {
    HGLOBAL ptr1;
    LPTSTR ptr2;
@@ -10305,15 +10355,15 @@
    char filterbuf[1001] = {0};
    int rc;
 
-   BROWSEINFO bi;
-   TCHAR szDir[MAX_PATH];
-   LPITEMIDLIST pidl;
-   LPMALLOC pMalloc;
-
    if ( flags == DW_DIRECTORY_OPEN )
    {
    /* If we aren't building a DLL, use the more simple browser */
 #ifndef BUILD_DLL
+      BROWSEINFO bi;
+      TCHAR szDir[MAX_PATH];
+      LPITEMIDLIST pidl;
+      LPMALLOC pMalloc;
+
       if (SUCCEEDED(SHGetMalloc(&pMalloc)))
       {
          ZeroMemory(&bi,sizeof(bi));
@@ -10438,7 +10488,7 @@
    }
    newparams[count] = NULL;
 
-   retcode = spawnvp(P_NOWAIT, program, newparams);
+   retcode = _spawnvp(P_NOWAIT, program, (const char * const *)newparams);
 
    for(z=0;z<count;z++)
    {
--- a/win/dwcompat-mingw.def	Fri Nov 18 16:50:49 2011 +0000
+++ b/win/dwcompat-mingw.def	Fri Nov 18 18:56:40 2011 +0000
@@ -3,22 +3,13 @@
 DESCRIPTION 'Dynamic Windows Compatibility Module for Win32'
 
 EXPORTS
-  sockread           @10
-  sockwrite          @11
-  sockclose          @12
-  socksprintf        @13
-  sockpipe           @14
-  sockinit           @15
-  sockshutdown       @16
-                        
   makedir            @20
-  nonblock           @21
+  vargs              @21
   setfileinfo        @22
   drivefree          @23
   isdrive            @24
   drivesize          @25
   getfsname          @26
-  block              @27
                         
   _opendir           @30
   _openxdir          @31