From 3a405baf3847f45425b21e263792b4c092de9189 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sun, 30 Oct 1994 16:25:19 +0000 Subject: [PATCH] Release 941030 Sun Oct 30 13:01:18 1994 Alexandre Julliard (julliard@lamisun.epfl.ch) * [controls/static.c] Bug fix for SS_ICON controls. * [if1632/Imakefile] Fixed call.o dependencies. * [objects/clipping.c] [objects/dc.c] Fixed visible region handling. hVisRgn is always non-null now. * [windows/dce.c] Bug fix in GetDCEx for CS_OWNDC windows. * [windows/nonclient.c] [windows/painting.c] Fixes to icon window drawing. * [windows/winpos.c] A few fixes in SetWindowPos(). Sun Oct 30 12:50:24 1994 Michael Patra * [objects/bitblt.c] BitBlt(): BitBlt is now able to handle any raster operation. If the request can't be passed to XWindows directly, it's quite slow, though. * [*/*.c] [misc/main.c] Improvements of the system for handling debug messages. Options are now also loaded from /usr/lib/X11/app-defaults/Wine (insert *debugoptions: +xxx there if you want to have turn messages xxx on). * [controls/menu.c] DestroyMenu(): The whole window won't be destroyed as a sideeffect any longer. * [misc/file.c] OpenFile(): Fixed bug in searching in system/window-directory. Sun Oct 30 12:25:53 1994 Jimmy Tirtawangsa * [include/windows.h] Bug fix for window related structures. DCB and COMSTAT are affected. They must be packed. * [misc/comm.c] Bug fix for COM ports: Dial and dialog window in terminal.exe now works. Non sequential COM assignments in wine.conf should not break now. Baudrate can be specified in wine.conf to overcome baudrate limitation in mswindow. See sample wine.ini * [include/comm.h] add baudrate field to DosDeviceStructre * [object/font.c] Bug fix for font assignment. Use pairs of foundry and family fontnames in X11 to correspond with window's fonts. Put font assignment ini wine.ini. * [wine.ini] Adding optional baudrate after port name in "serialports" section Add new section, "fonts". "default" is special key in "fonts" to match any unmatch window font. Oct 29, 94 (new address) wine@trgcorp.mksinfo.qc.ca (Martin Ayotte) * [if1632/relay.c] * [if1632/commdlg.spec] New file. * [misc/commdlg.c] New file. * [include/commdlg.h] New file. Begin of an emulated COMMDLG DLL, built-in for now. (BTW, if you want to switch between built-in & 16bits CommDlg, only thing you need to do is to put the real/dummy name in file relay.c) * [controls/scroll.c] * [controls/combo.c] * [controls/listbox.c] Few bug fixes and/or cosmetic. * [misc/audio.c] * [misc/mmaux.c] bug fixes and flags returned to emulate SB16. * [misc/midi.c] New file. skeleton for 'Midi' MMSYSTEM & MCI driver. * [misc/mcianim.c] New file. skeleton for 'Animation1' MCI driver. * [windows/win.c] Add new stub for GetLastActiveWindow(). Tue Oct 25 09:17:25 1994 Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de) * [if1632/call.S] [tools/build.c] Support for ELF format. (Not complete) Sun Oct 23 00:51:50 1994 Paul Falstad (pf@zoof) * [if1632/user.spec] Add stubs for ArrangeIconicWindows(), etc. * [if1632/kernel.spec] Add IsBad*Ptr() functions. * [loader/signal.c] Add test_memory(), for use with IsBad*Ptr(). * [windows/winpos.c] Add stubs for TileChildWindows(), etc. * [windows/win.c] IsWindow() shouldn't crash if it's given a bad handle. Add stub for GetLastActivePopup(). * [memory/global.c] Implement the IsBad*Ptr() functions. * [controls/listbox.c] Return the full longword of the item data in LB_GETITEMDATA. * [controls/edit.c] Don't let the user select an area past the end of the text. * [objects/text.c] In DrawText(), the code to delete crlfs also removed multiple consecutive newlines. Also, using DT_CALCRECT didn't return the right height, and the width wasn't returned at all. This caused MessageBoxes to be missing much of their text. * [windows/scroll.c] ScrollWindow[Ex] didn't work right with null LPRECT arguments. Fri Oct 21 21:47:19 1994 Paul Falstad (pf@zoof.cts.com) * [miscemu/int21.c] Fixed int21 0x42 handler to properly assemble 32-bit seek ptr. * [misc/property.c] Fixed inverted logic in EnumProps(), and changed CallBack16() call to use new arg format. * [windows/win.c] Fixed CallBack16() call in Enum[Child]Windows to use new arg format; this fixes crashes in enum procedures. Wed Oct 19 21:30:00 PDT 1994 martin@cs.csufresno.edu * [misc/clipboard.c] [windows/event.c] [windows/message.c] Added cut and paste between Wine and other X clients via the PRIMARY selection. Text only this time. * [controls/edit.c] EDIT_LineLength, EDIT_TextLine return 0 for lines after last one. * [windows/defwnd.c] Send WM_SYSCOMMAND to overlapped ancestor window, not the receiver of WM_SYSKEYDOWN Sat Oct 22 15:01:02 1994 Thomas Sandford * [controls/edit.c] ClientWidth()/ClientHeight() macros: return 0 if size would be negative EDIT_StrLength(): takes unsigned char* instead of char* * [controls/listbox.c] ListBoxWndProc(): in "case WM_MOUSEMOVE" - set lphl at start of case instead of in each place required (it was omitted in some places causing problems!) * [controls/menu.c] MENU_CalcItemSize(): don't try to find size of a text item if the pointer is NULL * [include/heap.h] added definition of HEAP_LocalInit() * [include/msdos.h] removed buggy pointer() macro (use SAFEMAKEPTR() from segmem.h instead) * [loader/selector.c] IPCCopySelector(): added missing flags to shmget() call ? does this break linux - I added these flags in a previous patch but they were missing in the corresponding release ? * [loader/signal.c] win_fault(): added missing definitions of i, dump for those not running NetBSD or linux * [misc/dos_fs.c] DOS_GetCurrentDir(): made temp[] static so it can be safely returned * [miscemu/int21.c,int25.c,int26.c] Changed all invocations of pointer() to SAFEMAKEPTR(). Included segmem.h where necessary. * [windows/dialog.c] CreateDialogIndirectParam(): Changed HEAP_Init() call to HEAP_LocalInit(), removed redundant variables Sat Oct 22 00:29:41 MET 1994 Dag Asheim (dash@ifi.uio.no) * [loader/library.c] [loader/main.c] [loader/ne_image.c] [misc/exec.c] [miscemu/int10.c] [miscemu/int21.c] [objects/bitblt.c] [objects/metafile.c] Rewritten more printf's to use the new debugging system, and made wine less verbose per default. Use "-debugmsg +module" to get (almost) the same behavior as before. --- ChangeLog | 219 ++++++ Imakefile | 1 + controls/combo.c | 317 +++++--- controls/edit.c | 70 +- controls/listbox.c | 455 ++++++------ controls/menu.c | 40 +- controls/scroll.c | 58 +- controls/static.c | 25 +- if1632/Imakefile | 28 +- if1632/call.S | 191 ++--- if1632/callback.c | 33 +- if1632/commdlg.spec | 32 + if1632/kernel.spec | 12 +- if1632/mmsystem.spec | 5 + if1632/relay.c | 1 + if1632/user.spec | 8 +- include/combo.h | 3 + include/comm.h | 1 + include/commdlg.h | 298 ++++++++ include/debug.h | 364 ++++++++-- include/dlgs.h | 186 +++++ include/dlls.h | 3 +- include/gdi.h | 6 +- include/heap.h | 1 + include/listbox.h | 40 +- include/msdos.h | 29 +- include/scroll.h | 33 +- include/stddebug.h | 32 + include/windows.h | 10 +- include/winpos.h | 1 + loader/dump.c | 24 +- loader/ldt.c | 8 +- loader/ldtlib.c | 4 +- loader/library.c | 81 +-- loader/main.c | 10 +- loader/ne_image.c | 46 +- loader/ne_resource.c | 58 +- loader/pe_image.c | 17 +- loader/pe_resource.c | 42 +- loader/resource.c | 69 +- loader/selector.c | 35 +- loader/signal.c | 38 +- loader/task.c | 83 +-- memory/global.c | 77 +- memory/linear.c | 2 +- misc/Imakefile | 3 + misc/audio.c | 66 +- misc/clipboard.c | 83 +++ misc/comm.c | 87 ++- misc/commdlg.c | 1127 +++++++++++++++++++++++++++++ misc/dos_fs.c | 6 +- misc/exec.c | 4 +- misc/file.c | 6 +- misc/main.c | 96 ++- misc/mcianim.c | 679 ++++++++++++++++++ misc/mcicda.c | 6 +- misc/message.c | 76 +- misc/midi.c | 983 +++++++++++++++++++++++++ misc/mmaux.c | 58 +- misc/mmsystem.c | 240 +++++-- misc/profile.c | 49 +- misc/property.c | 70 +- misc/shell.c | 111 ++- misc/spy.c | 2 +- misc/stress.c | 53 +- misc/winsocket.c | 149 ++-- miscemu/int10.c | 4 +- miscemu/int21.c | 66 +- miscemu/int25.c | 5 +- miscemu/int26.c | 5 +- objects/bitblt.c | 157 +++- objects/bitmap.c | 12 +- objects/brush.c | 7 + objects/clipping.c | 252 ++++--- objects/dc.c | 53 +- objects/dcvalues.c | 2 - objects/font.c | 101 ++- objects/metafile.c | 4 +- objects/text.c | 17 +- rc/ChangeLog | 5 + rc/Imakefile | 44 ++ rc/README | 38 + rc/README.sysres | 19 + rc/TODO | 63 ++ rc/rc.h | 105 +++ rc/rc.l | 76 ++ rc/rc.y | 211 ++++++ rc/sysres.rc | 1626 ++++++++++++++++++++++++++++++++++++++++++ rc/systest.c | 109 +++ rc/winelogo.bmp | Bin 0 -> 65078 bytes rc/winerc.c | 574 +++++++++++++++ tools/build.c | 47 +- tools/make_debug | 4 +- windows/caret.c | 11 +- windows/class.c | 6 +- windows/cursor.c | 23 +- windows/dce.c | 16 +- windows/defwnd.c | 7 +- windows/dialog.c | 16 +- windows/event.c | 75 ++ windows/graphics.c | 25 +- windows/message.c | 4 +- windows/nonclient.c | 6 +- windows/painting.c | 21 +- windows/scroll.c | 8 +- windows/win.c | 29 +- windows/winpos.c | 106 ++- wine.ini | 12 + 108 files changed, 9123 insertions(+), 1898 deletions(-) create mode 100644 if1632/commdlg.spec create mode 100644 include/commdlg.h create mode 100644 include/dlgs.h create mode 100644 misc/commdlg.c create mode 100644 misc/mcianim.c create mode 100644 misc/midi.c create mode 100644 rc/ChangeLog create mode 100644 rc/Imakefile create mode 100644 rc/README create mode 100644 rc/README.sysres create mode 100644 rc/TODO create mode 100644 rc/rc.h create mode 100644 rc/rc.l create mode 100644 rc/rc.y create mode 100644 rc/sysres.rc create mode 100644 rc/systest.c create mode 100644 rc/winelogo.bmp create mode 100644 rc/winerc.c diff --git a/ChangeLog b/ChangeLog index 0ec9eaa233f..37409fe1897 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,222 @@ +---------------------------------------------------------------------- +Sun Oct 30 13:01:18 1994 Alexandre Julliard (julliard@lamisun.epfl.ch) + + * [controls/static.c] + Bug fix for SS_ICON controls. + + * [if1632/Imakefile] + Fixed call.o dependencies. + + * [objects/clipping.c] [objects/dc.c] + Fixed visible region handling. hVisRgn is always non-null now. + + * [windows/dce.c] + Bug fix in GetDCEx for CS_OWNDC windows. + + * [windows/nonclient.c] [windows/painting.c] + Fixes to icon window drawing. + + * [windows/winpos.c] + A few fixes in SetWindowPos(). + +Sun Oct 30 12:50:24 1994 Michael Patra + + * [objects/bitblt.c] + BitBlt(): BitBlt is now able to handle any raster operation. If + the request can't be passed to XWindows directly, it's quite + slow, though. + + * [*/*.c] + [misc/main.c] + Improvements of the system for handling debug messages. Options are + now also loaded from /usr/lib/X11/app-defaults/Wine (insert + *debugoptions: +xxx there if you want to have turn messages xxx on). + + * [controls/menu.c] + DestroyMenu(): The whole window won't be destroyed as a sideeffect + any longer. + + * [misc/file.c] + OpenFile(): Fixed bug in searching in system/window-directory. + +Sun Oct 30 12:25:53 1994 Jimmy Tirtawangsa + + * [include/windows.h] + Bug fix for window related structures. + DCB and COMSTAT are affected. They must be packed. + + * [misc/comm.c] + Bug fix for COM ports: + Dial and dialog window in terminal.exe now works. + Non sequential COM assignments in wine.conf should not break now. + Baudrate can be specified in wine.conf to overcome baudrate limitation + in mswindow. See sample wine.ini + + * [include/comm.h] + add baudrate field to DosDeviceStructre + + * [object/font.c] + Bug fix for font assignment. + Use pairs of foundry and family fontnames in X11 to correspond with + window's fonts. + Put font assignment ini wine.ini. + + * [wine.ini] + Adding optional baudrate after port name in "serialports" section + Add new section, "fonts". + "default" is special key in "fonts" to match any unmatch window font. + +Oct 29, 94 (new address) wine@trgcorp.mksinfo.qc.ca (Martin Ayotte) + + * [if1632/relay.c] + * [if1632/commdlg.spec] New file. + * [misc/commdlg.c] New file. + * [include/commdlg.h] New file. + Begin of an emulated COMMDLG DLL, built-in for now. + (BTW, if you want to switch between built-in & 16bits CommDlg, only + thing you need to do is to put the real/dummy name in file relay.c) + + * [controls/scroll.c] + * [controls/combo.c] + * [controls/listbox.c] + Few bug fixes and/or cosmetic. + + * [misc/audio.c] + * [misc/mmaux.c] + bug fixes and flags returned to emulate SB16. + + * [misc/midi.c] New file. + skeleton for 'Midi' MMSYSTEM & MCI driver. + + * [misc/mcianim.c] New file. + skeleton for 'Animation1' MCI driver. + + * [windows/win.c] + Add new stub for GetLastActiveWindow(). + +Tue Oct 25 09:17:25 1994 Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de) + + * [if1632/call.S] [tools/build.c] + Support for ELF format. (Not complete) + +Sun Oct 23 00:51:50 1994 Paul Falstad (pf@zoof) + + * [if1632/user.spec] + Add stubs for ArrangeIconicWindows(), etc. + + * [if1632/kernel.spec] + Add IsBad*Ptr() functions. + + * [loader/signal.c] + Add test_memory(), for use with IsBad*Ptr(). + + * [windows/winpos.c] + Add stubs for TileChildWindows(), etc. + + * [windows/win.c] + IsWindow() shouldn't crash if it's given a bad handle. + Add stub for GetLastActivePopup(). + + * [memory/global.c] + Implement the IsBad*Ptr() functions. + + * [controls/listbox.c] + Return the full longword of the item data in LB_GETITEMDATA. + + * [controls/edit.c] + Don't let the user select an area past the end of the text. + + * [objects/text.c] + In DrawText(), the code to delete crlfs also removed multiple + consecutive newlines. Also, using DT_CALCRECT didn't return + the right height, and the width wasn't returned at all. + This caused MessageBoxes to be missing much of their text. + + * [windows/scroll.c] + ScrollWindow[Ex] didn't work right with null LPRECT arguments. + +Fri Oct 21 21:47:19 1994 Paul Falstad (pf@zoof.cts.com) + + * [miscemu/int21.c] + Fixed int21 0x42 handler to properly assemble 32-bit seek ptr. + + * [misc/property.c] + Fixed inverted logic in EnumProps(), and changed CallBack16() + call to use new arg format. + + * [windows/win.c] + Fixed CallBack16() call in Enum[Child]Windows to use new arg + format; this fixes crashes in enum procedures. + +Wed Oct 19 21:30:00 PDT 1994 martin@cs.csufresno.edu + + * [misc/clipboard.c] + [windows/event.c] + [windows/message.c] + Added cut and paste between Wine and other X clients via + the PRIMARY selection. Text only this time. + + * [controls/edit.c] + EDIT_LineLength, EDIT_TextLine return 0 for lines after last one. + + * [windows/defwnd.c] + Send WM_SYSCOMMAND to overlapped ancestor window, + not the receiver of WM_SYSKEYDOWN + +Sat Oct 22 15:01:02 1994 Thomas Sandford + + * [controls/edit.c] + ClientWidth()/ClientHeight() macros: return 0 if size would + be negative + EDIT_StrLength(): takes unsigned char* instead of char* + + * [controls/listbox.c] + ListBoxWndProc(): in "case WM_MOUSEMOVE" - set lphl at start of + case instead of in each place required (it was omitted in + some places causing problems!) + + * [controls/menu.c] + MENU_CalcItemSize(): don't try to find size of a text item + if the pointer is NULL + + * [include/heap.h] + added definition of HEAP_LocalInit() + + * [include/msdos.h] + removed buggy pointer() macro (use SAFEMAKEPTR() from segmem.h + instead) + + * [loader/selector.c] + IPCCopySelector(): added missing flags to shmget() call + ? does this break linux - I added these flags in a previous + patch but they were missing in the corresponding release ? + + * [loader/signal.c] + win_fault(): added missing definitions of i, dump for those + not running NetBSD or linux + + * [misc/dos_fs.c] + DOS_GetCurrentDir(): made temp[] static so it can be safely + returned + + * [miscemu/int21.c,int25.c,int26.c] + Changed all invocations of pointer() to SAFEMAKEPTR(). Included + segmem.h where necessary. + + * [windows/dialog.c] + CreateDialogIndirectParam(): Changed HEAP_Init() call to + HEAP_LocalInit(), removed redundant variables + +Sat Oct 22 00:29:41 MET 1994 Dag Asheim (dash@ifi.uio.no) + + * [loader/library.c] [loader/main.c] [loader/ne_image.c] + [misc/exec.c] [miscemu/int10.c] [miscemu/int21.c] + [objects/bitblt.c] [objects/metafile.c] + Rewritten more printf's to use the new debugging system, and + made wine less verbose per default. Use "-debugmsg +module" + to get (almost) the same behavior as before. + +---------------------------------------------------------------------- Sun Oct 16 13:29:07 1994 Alexandre Julliard (julliard@lamisun.epfl.ch) * [controls/button.c] diff --git a/Imakefile b/Imakefile index 5b5f709842c..9a38b3d7e77 100644 --- a/Imakefile +++ b/Imakefile @@ -30,6 +30,7 @@ COMMONSUBDIRS = \ loader \ misc \ objects \ + rc \ test \ windows diff --git a/controls/combo.c b/controls/combo.c index 0dc66fb4ed0..fbf10f1f1b2 100644 --- a/controls/combo.c +++ b/controls/combo.c @@ -14,6 +14,7 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; #include "windows.h" #include "combo.h" +#include "user.h" #include "heap.h" #include "win.h" #include "prototypes.h" @@ -22,11 +23,18 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; /* #undef DEBUG_COMBO */ #include "debug.h" + /* windows/graphics.c */ +extern void GRAPH_DrawReliefRect( HDC hdc, RECT *rect, + int thickness, BOOL pressed ); +extern BOOL GRAPH_DrawBitmap( HDC hdc, HBITMAP hbitmap, int xdest, int ydest, + int xsrc, int ysrc, int width, int height, int rop ); + HBITMAP hComboBit = 0; LPHEADCOMBO ComboGetStorageHeader(HWND hwnd); int CreateComboStruct(HWND hwnd); +void ComboBoxStaticOwnerDraw(HWND hWnd, LPHEADCOMBO lphc); /*********************************************************************** @@ -34,66 +42,75 @@ int CreateComboStruct(HWND hwnd); */ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) { - RECT rect; - int y, count; - int width, height; - WND *wndPtr; - LPHEADCOMBO lphc; - HDC hDC; - BITMAP bm; - char str[128]; - PAINTSTRUCT paintstruct; - int style; - switch(message) - { - case WM_CREATE: - wndPtr = WIN_FindWndPtr(hwnd); - if (wndPtr == NULL) return 0; - dprintf_combo(stddeb,"Combo WM_CREATE %p !\n", lphc); - if (hComboBit == (HBITMAP)NULL) - hComboBit = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_COMBO)); - GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm); - wndPtr->dwStyle &= 0xFFFFFFFFL ^ (WS_VSCROLL | WS_HSCROLL); - GetWindowRect(hwnd, &rect); - width = rect.right - rect.left; - height = rect.bottom - rect.top; - SetWindowPos(hwnd, 0, 0, 0, width + bm.bmHeight, bm.bmHeight, - SWP_NOMOVE | SWP_NOZORDER); - CreateComboStruct(hwnd); - lphc = ComboGetStorageHeader(hwnd); - if (lphc == NULL) return 0; - if (wndPtr->dwStyle & CBS_SIMPLE) -/* lphc->hWndEdit = CreateWindow("EDIT", "", */ - lphc->hWndEdit = CreateWindow("STATIC", "", - WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT, - 0, 0, width - bm.bmHeight, bm.bmHeight, - hwnd, 1, wndPtr->hInstance, 0L); - else - lphc->hWndEdit = CreateWindow("STATIC", "", - WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT, - 0, 0, width - bm.bmHeight, bm.bmHeight, - hwnd, 1, wndPtr->hInstance, 0L); - style=0; - if ((wndPtr->dwStyle & CBS_HASSTRINGS) == CBS_HASSTRINGS) - style |= LBS_HASSTRINGS; - if ((wndPtr->dwStyle & CBS_OWNERDRAWFIXED) ==CBS_OWNERDRAWFIXED) - style |= LBS_OWNERDRAWFIXED; - if ((wndPtr->dwStyle & CBS_OWNERDRAWVARIABLE)==CBS_OWNERDRAWVARIABLE) - style |= LBS_OWNERDRAWVARIABLE; - lphc->hWndLBox = CreateWindow("LISTBOX", "", - WS_POPUP | WS_BORDER | WS_VSCROLL | LBS_NOTIFY | style, - rect.left, rect.top + bm.bmHeight, - width, height, wndPtr->hwndParent, 0, - wndPtr->hInstance, (LPSTR)MAKELONG(0, hwnd)); - ShowWindow(lphc->hWndLBox, SW_HIDE); - dprintf_combo(stddeb,"Combo Creation LBox=%X!\n", - lphc->hWndLBox); - return 0; + RECT rect; + int y, count; + int width, height; + WND *wndPtr; + LPHEADCOMBO lphc; + HDC hDC; + BITMAP bm; + char str[128]; + PAINTSTRUCT paintstruct; + LPDRAWITEMSTRUCT lpdis; + DWORD dwStyle; + switch(message) { + case WM_CREATE: + wndPtr = WIN_FindWndPtr(hwnd); + if (wndPtr == NULL) return 0; + dprintf_combo(stddeb,"Combo WM_CREATE %p !\n", lphc); + if (hComboBit == (HBITMAP)NULL) + hComboBit = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_COMBO)); + GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm); + wndPtr->dwStyle &= 0xFFFFFFFFL ^ (WS_VSCROLL | WS_HSCROLL); + GetWindowRect(hwnd, &rect); + width = rect.right - rect.left; + height = rect.bottom - rect.top; + if (height < bm.bmHeight) height = bm.bmHeight; +/* SetWindowPos(hwnd, 0, 0, 0, width + bm.bmHeight, bm.bmHeight, + SWP_NOMOVE | SWP_NOZORDER); */ + SetWindowPos(hwnd, 0, 0, 0, width, bm.bmHeight, + SWP_NOMOVE | SWP_NOZORDER); + CreateComboStruct(hwnd); + lphc = ComboGetStorageHeader(hwnd); + if (lphc == NULL) return 0; +/* SetRect(&lphc->RectEdit, 0, 0, width - 2, bm.bmHeight); */ + SetRect(&lphc->RectEdit, 0, 0, width - bm.bmHeight, bm.bmHeight); + if (wndPtr->dwStyle & CBS_DROPDOWNLIST) { + if ((wndPtr->dwStyle & CBS_OWNERDRAWFIXED) == CBS_OWNERDRAWFIXED || + (wndPtr->dwStyle & CBS_OWNERDRAWVARIABLE) == CBS_OWNERDRAWVARIABLE) + lphc->hWndEdit = 0; + else + lphc->hWndEdit = CreateWindow("STATIC", "", + WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT, + 0, 0, width - bm.bmHeight, bm.bmHeight, + hwnd, 1, wndPtr->hInstance, 0L); + } + else { +/* lphc->hWndEdit = CreateWindow("EDIT", "", */ + lphc->hWndEdit = CreateWindow("STATIC", "", + WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT, + 0, 0, width - bm.bmHeight, bm.bmHeight, + hwnd, 1, wndPtr->hInstance, 0L); + } + dwStyle = WS_POPUP | WS_BORDER | WS_VSCROLL | LBS_NOTIFY; + if ((wndPtr->dwStyle & CBS_HASSTRINGS) == CBS_HASSTRINGS) + dwStyle |= LBS_HASSTRINGS; + if ((wndPtr->dwStyle & CBS_OWNERDRAWFIXED) == CBS_OWNERDRAWFIXED) + dwStyle |= LBS_OWNERDRAWFIXED; + if ((wndPtr->dwStyle & CBS_OWNERDRAWVARIABLE) == CBS_OWNERDRAWVARIABLE) + dwStyle |= LBS_OWNERDRAWVARIABLE; + lphc->hWndLBox = CreateWindow("LISTBOX", "", dwStyle, + rect.left, rect.top + bm.bmHeight, + width, height, wndPtr->hwndParent, 0, + wndPtr->hInstance, (LPSTR)MAKELONG(0, hwnd)); + ShowWindow(lphc->hWndLBox, SW_HIDE); + dprintf_combo(stddeb,"Combo Creation LBox=%X!\n", lphc->hWndLBox); + return 0; case WM_DESTROY: lphc = ComboGetStorageHeader(hwnd); if (lphc == 0) return 0; /* - DestroyWindow(lphc->hWndEdit); + if (lphc->hWndEdit != 0) DestroyWindow(lphc->hWndEdit); */ DestroyWindow(lphc->hWndLBox); free(lphc); @@ -114,24 +131,29 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) case WM_COMMAND: wndPtr = WIN_FindWndPtr(hwnd); lphc = ComboGetStorageHeader(hwnd); - if (lphc == NULL) return 0; + if (lphc == NULL || wndPtr == NULL) return 0; if (LOWORD(lParam) == lphc->hWndLBox) { - switch(HIWORD(lParam)) { - case LBN_SELCHANGE: - lphc->dwState = lphc->dwState & (CB_SHOWDROPDOWN ^ 0xFFFFFFFFL); - ShowWindow(lphc->hWndLBox, SW_HIDE); - y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); - if (y != LB_ERR) { - SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str); - SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); - } - SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu, - MAKELONG(hwnd, CBN_SELCHANGE)); - break; - case LBN_DBLCLK: - SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu, - MAKELONG(hwnd, CBN_DBLCLK)); - break; + switch(HIWORD(lParam)) { + case LBN_SELCHANGE: + lphc->dwState = lphc->dwState & (CB_SHOWDROPDOWN ^ 0xFFFFFFFFL); + ShowWindow(lphc->hWndLBox, SW_HIDE); + y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); + if (y != LB_ERR) { + SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str); + if (lphc->hWndEdit != 0) + SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); + else { + InvalidateRect(hwnd, NULL, TRUE); + UpdateWindow(hwnd); + } + } + SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu, + MAKELONG(hwnd, CBN_SELCHANGE)); + break; + case LBN_DBLCLK: + SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu, + MAKELONG(hwnd, CBN_DBLCLK)); + break; } } break; @@ -178,14 +200,18 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) case WM_KEYDOWN: wndPtr = WIN_FindWndPtr(hwnd); lphc = ComboGetStorageHeader(hwnd); - if (lphc == NULL) return 0; + if (lphc == NULL || wndPtr == NULL) return 0; y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); count = SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L); dprintf_combo(stddeb,"COMBOBOX // GetKeyState(VK_MENU)=%d\n", GetKeyState(VK_MENU)); if (GetKeyState(VK_MENU) < 0) { lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN; if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) { - ShowWindow(lphc->hWndLBox, SW_SHOW); + GetWindowRect(hwnd, &rect); + SetWindowPos(lphc->hWndLBox, 0, rect.left, rect.bottom, 0, 0, + SWP_NOREDRAW | SWP_NOSIZE); + SetWindowPos(lphc->hWndLBox, 0, 0, 0, 0, 0, SWP_SHOWWINDOW | + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); SetFocus(lphc->hWndLBox); } else { @@ -193,7 +219,8 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); if (y != LB_ERR) { SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str); - SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); + if (lphc->hWndEdit != 0) + SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); } } } @@ -214,9 +241,11 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) } if (y < 0) y = 0; if (y >= count) y = count - 1; + lphc->LastSel = y; SendMessage(lphc->hWndLBox, LB_SETCURSEL, y, 0L); SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str); - SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); + if (lphc->hWndEdit != 0) + SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu, MAKELONG(hwnd, CBN_SELCHANGE)); } @@ -226,8 +255,21 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) return(SendMessage(GetParent(hwnd), WM_MEASUREITEM, wParam, lParam)); case WM_CTLCOLOR: return(SendMessage(GetParent(hwnd), WM_CTLCOLOR, wParam, lParam)); + case WM_SETREDRAW: + dprintf_combo(stddeb,"ComboBoxWndProc WM_SETREDRAW hWnd=%04X w=%04X !\n", hwnd, wParam); + lphc = ComboGetStorageHeader(hwnd); + if (lphc == NULL) return 0; + lphc->bRedrawFlag = wParam; + break; case WM_DRAWITEM: - return(SendMessage(GetParent(hwnd), WM_DRAWITEM, wParam, lParam)); + dprintf_combo(stddeb,"ComboBoxWndProc // WM_DRAWITEM w=%04X l=%08lX\n", wParam, lParam); + wndPtr = WIN_FindWndPtr(hwnd); + if (wndPtr == NULL) break; + lpdis = (LPDRAWITEMSTRUCT)lParam; + if (lpdis == NULL) break; + lpdis->CtlType = ODT_COMBOBOX; + lpdis->CtlID = wndPtr->wIDmenu; + return(SendMessage(GetParent(hwnd), WM_DRAWITEM, wParam, lParam)); case WM_PAINT: GetClientRect(hwnd, &rect); hDC = BeginPaint(hwnd, &paintstruct); @@ -241,8 +283,13 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) EndPaint(hwnd, &paintstruct); lphc = ComboGetStorageHeader(hwnd); if (lphc == NULL) return 0; - InvalidateRect(lphc->hWndEdit, NULL, TRUE); - UpdateWindow(lphc->hWndEdit); + if (lphc->hWndEdit != 0) { + InvalidateRect(lphc->hWndEdit, NULL, TRUE); + UpdateWindow(lphc->hWndEdit); + } + else { + ComboBoxStaticOwnerDraw(hwnd, lphc); + } if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) { InvalidateRect(lphc->hWndLBox, NULL, TRUE); UpdateWindow(lphc->hWndLBox); @@ -251,7 +298,8 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) case WM_SETFOCUS: lphc = ComboGetStorageHeader(hwnd); if (lphc == NULL) return 0; - SetFocus(lphc->hWndEdit); + if (lphc->hWndEdit != 0) + SetFocus(lphc->hWndEdit); break; case WM_KILLFOCUS: lphc = ComboGetStorageHeader(hwnd); @@ -260,11 +308,12 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); if (y != LB_ERR) { SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str); - SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); + if (lphc->hWndEdit != 0) + SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str); } break; case CB_ADDSTRING: - dprintf_combo(stddeb,"CB_ADDSTRING '%s' !\n", (LPSTR)lParam); + dprintf_combo(stddeb,"CB_ADDSTRING '%s' !\n", (LPSTR)lParam); lphc = ComboGetStorageHeader(hwnd); if (lphc == NULL) return 0; return(SendMessage(lphc->hWndLBox, LB_ADDSTRING, wParam, lParam)); @@ -319,14 +368,16 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) dprintf_combo(stddeb,"ComboBox CB_GETEDITSEL !\n"); lphc = ComboGetStorageHeader(hwnd); if (lphc == NULL) return 0; -/* return(SendMessage(lphc->hWndEdit, EM_GETSEL, 0, 0L)); */ +/* if (lphc->hWndEdit != 0) + return(SendMessage(lphc->hWndEdit, EM_GETSEL, 0, 0L)); */ break; case CB_SETEDITSEL: dprintf_combo(stddeb,"ComboBox CB_SETEDITSEL lParam=%lX !\n", lParam); lphc = ComboGetStorageHeader(hwnd); if (lphc == NULL) return 0; -/* return(SendMessage(lphc->hWndEdit, EM_SETSEL, 0, lParam)); */ +/* if (lphc->hWndEdit != 0) + return(SendMessage(lphc->hWndEdit, EM_SETSEL, 0, lParam)); */ break; case CB_SELECTSTRING: dprintf_combo(stddeb,"ComboBox CB_SELECTSTRING !\n"); @@ -339,7 +390,11 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) if (lphc == NULL) return 0; lphc->dwState = lphc->dwState | CB_SHOWDROPDOWN; if (wParam != 0) { - ShowWindow(lphc->hWndLBox, SW_SHOW); + GetWindowRect(hwnd, &rect); + SetWindowPos(lphc->hWndLBox, 0, rect.left, rect.bottom, 0, 0, + SWP_NOREDRAW | SWP_NOSIZE); + SetWindowPos(lphc->hWndLBox, 0, 0, 0, 0, 0, SWP_SHOWWINDOW | + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); } else { lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN; @@ -364,7 +419,8 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) dprintf_combo(stddeb,"ComboBox CB_LIMITTEXT !\n"); lphc = ComboGetStorageHeader(hwnd); if (lphc == NULL) return 0; -/* return(SendMessage(lphc->hWndEdit, EM_LIMITTEXT, wParam, 0L)); */ +/* if (lphc->hWndEdit != 0) + return(SendMessage(lphc->hWndEdit, EM_LIMITTEXT, wParam, 0L)); */ break; default: @@ -377,35 +433,79 @@ return 0; LPHEADCOMBO ComboGetStorageHeader(HWND hwnd) { - WND *wndPtr; - LPHEADCOMBO lphc; - wndPtr = WIN_FindWndPtr(hwnd); - if (wndPtr == 0) { - fprintf(stderr,"Bad Window handle on ComboBox !\n"); - return 0; - } - lphc = *((LPHEADCOMBO *)&wndPtr->wExtra[1]); - return lphc; + WND *wndPtr; + LPHEADCOMBO lphc; + wndPtr = WIN_FindWndPtr(hwnd); + if (wndPtr == 0) { + fprintf(stderr,"Bad Window handle on ComboBox !\n"); + return 0; + } + lphc = *((LPHEADCOMBO *)&wndPtr->wExtra[1]); + return lphc; } int CreateComboStruct(HWND hwnd) { - WND *wndPtr; - LPHEADCOMBO lphc; - wndPtr = WIN_FindWndPtr(hwnd); - if (wndPtr == 0) { - fprintf(stderr,"Bad Window handle on ComboBox !\n"); - return 0; - } - lphc = (LPHEADCOMBO)malloc(sizeof(HEADCOMBO)); - *((LPHEADCOMBO *)&wndPtr->wExtra[1]) = lphc; - lphc->dwState = 0; - return TRUE; + WND *wndPtr; + LPHEADCOMBO lphc; + wndPtr = WIN_FindWndPtr(hwnd); + if (wndPtr == 0) { + fprintf(stderr,"Bad Window handle on ComboBox !\n"); + return 0; + } + lphc = (LPHEADCOMBO)malloc(sizeof(HEADCOMBO)); + *((LPHEADCOMBO *)&wndPtr->wExtra[1]) = lphc; + lphc->hWndEdit = 0; + lphc->hWndLBox = 0; + lphc->dwState = 0; + lphc->LastSel = -1; + return TRUE; } +void ComboBoxStaticOwnerDraw(HWND hWnd, LPHEADCOMBO lphc) +{ + HDC hDC; + HBRUSH hBrush; + short y; + char str[64]; + LPSTR ptr = NULL; + HANDLE hTemp; + WND *wndPtr; + LPDRAWITEMSTRUCT lpdis; + dprintf_combo(stddeb,"ComboBoxStaticOwnerDraw(%04X, %p) !\n", hWnd, lphc); + y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L); + if (y != LB_ERR) { + SendMessage(lphc->hWndLBox, LB_GETTEXT, y, (LPARAM)str); + ptr = (LPSTR)SendMessage(lphc->hWndLBox, LB_GETITEMDATA, y, 0L); + } + hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLOR, (WORD)hDC, + MAKELONG(hWnd, CTLCOLOR_STATIC)); + if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(WHITE_BRUSH); + wndPtr = WIN_FindWndPtr(hWnd); + if (wndPtr == NULL) return; + hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(DRAWITEMSTRUCT)); + lpdis = (LPDRAWITEMSTRUCT) USER_HEAP_ADDR(hTemp); + if (lpdis == NULL) { + printf("ComboBox Ownerdraw // Error allocating DRAWITEMSTRUCT !\n"); + return; + } + hDC = GetDC(hWnd); + FillRect(hDC, &lphc->RectEdit, hBrush); + lpdis->hDC = hDC; + if (y != LB_ERR) lpdis->itemID = y - 1; + CopyRect(&lpdis->rcItem, &lphc->RectEdit); + lpdis->itemData = (DWORD)ptr; + lpdis->itemAction = ODA_DRAWENTIRE; + lpdis->CtlType = ODT_COMBOBOX; + lpdis->CtlID = wndPtr->wIDmenu; + SendMessage(GetParent(hWnd), WM_DRAWITEM, y, (LPARAM)lpdis); + USER_HEAP_FREE(hTemp); + ReleaseDC(hWnd, hDC); +} + /************************************************************************ * DlgDirSelectComboBox [USER.194] @@ -413,7 +513,8 @@ int CreateComboStruct(HWND hwnd) BOOL DlgDirSelectComboBox(HWND hDlg, LPSTR lpStr, int nIDLBox) { fprintf(stdnimp,"DlgDirSelectComboBox(%04X, '%s', %d) \n", - hDlg, lpStr, nIDLBox); + hDlg, lpStr, nIDLBox); + return TRUE; } diff --git a/controls/edit.c b/controls/edit.c index 968cc3dc7aa..81e5b4f6209 100644 --- a/controls/edit.c +++ b/controls/edit.c @@ -18,8 +18,8 @@ static char Copyright[] = "Copyright David W. Metcalfe, 1994"; #include "user.h" #include "scroll.h" #include "stddebug.h" -/* #define DEBUG_EDIT /* */ -/* #undef DEBUG_EDIT /* */ +/* #define DEBUG_EDIT */ +/* #undef DEBUG_EDIT */ #include "debug.h" @@ -69,10 +69,12 @@ typedef struct } EDITSTATE; -#define ClientWidth(wndPtr) (wndPtr->rectClient.right - \ - wndPtr->rectClient.left) -#define ClientHeight(wndPtr, es) ((wndPtr->rectClient.bottom - \ - wndPtr->rectClient.top) / es->txtht) +#define ClientWidth(wndPtr) \ + (wndPtr->rectClient.right > wndPtr->rectClient.left ? \ + wndPtr->rectClient.right - wndPtr->rectClient.left : 0) +#define ClientHeight(wndPtr, es) \ + (wndPtr->rectClient.bottom > wndPtr->rectClient.top ? \ + (wndPtr->rectClient.bottom - wndPtr->rectClient.top) / es->txtht : 0) #define EditBufLen(wndPtr) (wndPtr->dwStyle & ES_MULTILINE \ ? EDITLEN : ENTRYLEN) #define CurrChar (EDIT_TextLine(hwnd, es->CurrLine) + es->CurrCol) @@ -94,7 +96,6 @@ static BOOL TextMarking; /* TRUE if text marking in progress */ static BOOL ButtonDown; /* TRUE if left mouse button down */ static int ButtonRow; /* row in text buffer when button pressed */ static int ButtonCol; /* col in text buffer when button pressed */ -static BOOL Print = FALSE; LONG EditWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam); @@ -106,7 +107,7 @@ void EDIT_ModTextPointers(HWND hwnd, int lineno, int var); void EDIT_PaintMsg(HWND hwnd); HANDLE EDIT_GetTextLine(HWND hwnd, int selection); char *EDIT_TextLine(HWND hwnd, int sel); -int EDIT_StrLength(HWND hwnd, char *str, int len, int pcol); +int EDIT_StrLength(HWND hwnd, unsigned char *str, int len, int pcol); int EDIT_LineLength(HWND hwnd, int num); void EDIT_WriteTextLine(HWND hwnd, RECT *rc, int y); void EDIT_WriteText(HWND hwnd, char *lp, int off, int len, int row, @@ -177,7 +178,6 @@ void swap(int *a, int *b); LONG EditWndProc(HWND hwnd, WORD uMsg, WORD wParam, LONG lParam) { LONG lResult = 0L; - HDC hdc; char *textPtr; int len; WND *wndPtr = WIN_FindWndPtr(hwnd); @@ -466,7 +466,6 @@ long EDIT_NCCreateMsg(HWND hwnd, LONG lParam) EDITSTATE *es; unsigned int *textPtrs; char *text; - int len; /* store pointer to local or global heap in window structure so that */ /* EDITSTATE structure itself can be stored on local heap */ @@ -627,7 +626,7 @@ void EDIT_BuildTextPointers(HWND hwnd) WND *wndPtr = WIN_FindWndPtr(hwnd); char *text, *cp; int incrs = INITLINES; - unsigned int off, len, temp; + unsigned int off, len; EDITSTATE *es; unsigned int *textPtrs; short *charWidths; @@ -772,6 +771,7 @@ char *EDIT_TextLine(HWND hwnd, int sel) unsigned int *textPtrs = (unsigned int *)EDIT_HeapAddr(hwnd, es->hTextPtrs); + if(sel>es->wlines)return NULL; return (text + *(textPtrs + sel)); } @@ -784,12 +784,9 @@ char *EDIT_TextLine(HWND hwnd, int sel) * the width of a tab. */ -int EDIT_StrLength(HWND hwnd, char *str, int len, int pcol) +int EDIT_StrLength(HWND hwnd, unsigned char *str, int len, int pcol) { int i, plen = 0; - WND *wndPtr = WIN_FindWndPtr(hwnd); - EDITSTATE *es = - (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); for (i = 0; i < len; i++) plen += EDIT_CharWidth(hwnd, (BYTE)(*(str + i)), pcol + plen); @@ -807,12 +804,10 @@ int EDIT_StrLength(HWND hwnd, char *str, int len, int pcol) int EDIT_LineLength(HWND hwnd, int num) { - WND *wndPtr = WIN_FindWndPtr(hwnd); - EDITSTATE *es = - (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); char *cp = EDIT_TextLine(hwnd, num); char *cp1; + if(!cp)return 0; cp1 = strchr(cp, '\n'); return cp1 ? (int)(cp1 - cp) : strlen(cp); } @@ -827,14 +822,12 @@ int EDIT_LineLength(HWND hwnd, int num) void EDIT_WriteTextLine(HWND hwnd, RECT *rect, int y) { int len = 0; - unsigned char line[200]; HANDLE hLine; unsigned char *lp; int lnlen, lnlen1; int col, off = 0; int sbl, sel, sbc, sec; RECT rc; - BOOL trunc = FALSE; WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); @@ -1049,7 +1042,7 @@ void EDIT_WriteText(HWND hwnd, char *lp, int off, int len, int row, cp++; scol += tabwidth; - while (cp1 = strchr(cp, VK_TAB)) + while ((cp1 = strchr(cp, VK_TAB))) { TextOut(hdc, scol, row * es->txtht, cp, (int)(cp1 - cp)); scol += EDIT_StrLength(hwnd, cp, (int)(cp1 - cp), scol); @@ -1102,9 +1095,6 @@ HANDLE EDIT_GetStr(HWND hwnd, char *lp, int off, int len, int *diff) char *str; int ch = 0, i = 0, j, s_i; int ch1; - WND *wndPtr = WIN_FindWndPtr(hwnd); - EDITSTATE *es = - (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); dprintf_edit(stddeb,"EDIT_GetStr %s %d %d\n", lp, off, len); @@ -1147,8 +1137,6 @@ HANDLE EDIT_GetStr(HWND hwnd, char *lp, int off, int len, int *diff) void EDIT_CharMsg(HWND hwnd, WORD wParam) { WND *wndPtr = WIN_FindWndPtr(hwnd); - EDITSTATE *es = - (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); dprintf_edit(stddeb,"EDIT_CharMsg: wParam=%c\n", (char)wParam); @@ -1326,7 +1314,7 @@ int EDIT_CharWidth(HWND hwnd, short ch, int pcol) int EDIT_GetNextTabStop(HWND hwnd, int pcol) { - int i, tmp; + int i; int baseUnitWidth = LOWORD(GetDialogBaseUnits()); WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = @@ -1360,7 +1348,6 @@ void EDIT_Forward(HWND hwnd) WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); - char *text = EDIT_HeapAddr(hwnd, es->hText); if (*CurrChar == '\0') return; @@ -1449,7 +1436,6 @@ void EDIT_Backward(HWND hwnd) WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); - char *text = EDIT_HeapAddr(hwnd, es->hText); if (es->CurrCol) { @@ -1480,11 +1466,9 @@ void EDIT_Backward(HWND hwnd) void EDIT_End(HWND hwnd) { - RECT rc; WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); - char *text = EDIT_HeapAddr(hwnd, es->hText); while (*CurrChar && *CurrChar != '\n') { @@ -1510,7 +1494,6 @@ void EDIT_End(HWND hwnd) void EDIT_Home(HWND hwnd) { - RECT rc; WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); @@ -1667,7 +1650,6 @@ void EDIT_KeyDownMsg(HWND hwnd, WORD wParam) void EDIT_KeyHScroll(HWND hwnd, WORD opt) { - RECT rc; int hscrollpos; WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = @@ -1779,7 +1761,6 @@ void EDIT_KeyVScrollLine(HWND hwnd, WORD opt) void EDIT_KeyVScrollPage(HWND hwnd, WORD opt) { - RECT rc; int vscrollpos; WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = @@ -1827,7 +1808,6 @@ void EDIT_KeyVScrollPage(HWND hwnd, WORD opt) void EDIT_KeyVScrollDoc(HWND hwnd, WORD opt) { - RECT rc; int vscrollpos; WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = @@ -2050,7 +2030,6 @@ void EDIT_VScrollLine(HWND hwnd, WORD opt) void EDIT_VScrollPage(HWND hwnd, WORD opt) { - RECT rc; int vscrollpos; WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = @@ -2114,7 +2093,6 @@ void EDIT_HScrollMsg(HWND hwnd, WORD wParam, LONG lParam) void EDIT_SizeMsg(HWND hwnd, WORD wParam, LONG lParam) { - RECT rc; WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); @@ -2200,9 +2178,6 @@ int EDIT_PixelToChar(HWND hwnd, int row, int *pixel) { int ch = 0, i = 0, s_i; char *text; - WND *wndPtr = WIN_FindWndPtr(hwnd); - EDITSTATE *es = - (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); dprintf_edit(stddeb,"EDIT_PixelToChar: row=%d, pixel=%d\n", row, *pixel); @@ -2233,7 +2208,6 @@ LONG EDIT_SetTextMsg(HWND hwnd, LONG lParam) { int len; char *text; - RECT rc; WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); @@ -2440,7 +2414,6 @@ void EDIT_DeleteSel(HWND hwnd) WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); - char *text = EDIT_HeapAddr(hwnd, es->hText); if (SelMarked(es)) { @@ -2555,7 +2528,7 @@ void EDIT_ExtendSel(HWND hwnd, int x, int y) { int bbl, bel, bbc, bec; char *cp; - int len; + int len, line; BOOL end = FALSE; WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = @@ -2565,8 +2538,11 @@ void EDIT_ExtendSel(HWND hwnd, int x, int y) bbl = es->SelEndLine; bbc = es->SelEndCol; - cp = EDIT_TextLine(hwnd, es->wtop + y / es->txtht); - len = EDIT_LineLength(hwnd, es->wtop + y / es->txtht); + line = es->wtop + y / es->txtht; + if (line > es->wlines) + line = es->wlines; + cp = EDIT_TextLine(hwnd, line); + len = EDIT_LineLength(hwnd, line); es->WndRow = y / es->txtht; if (es->WndRow > es->wlines - es->wtop - 1) @@ -2699,9 +2675,6 @@ LONG EDIT_GetLineMsg(HWND hwnd, WORD wParam, LONG lParam) char *cp, *cp1; int len; char *buffer = (char *)lParam; - WND *wndPtr = WIN_FindWndPtr(hwnd); - EDITSTATE *es = - (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); cp = EDIT_TextLine(hwnd, wParam); cp1 = EDIT_TextLine(hwnd, wParam + 1); @@ -3077,7 +3050,6 @@ unsigned int EDIT_HeapSize(HWND hwnd, unsigned int handle) void EDIT_SetHandleMsg(HWND hwnd, WORD wParam) { - MDESC *m; WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra))); diff --git a/controls/listbox.c b/controls/listbox.c index a639814bd37..b5d59b785b7 100644 --- a/controls/listbox.c +++ b/controls/listbox.c @@ -22,8 +22,8 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; #include "scroll.h" #include "prototypes.h" #include "stddebug.h" -/* #define DEBUG_LISTBOX /* */ -/* #undef DEBUG_LISTBOX /* */ +/* #define DEBUG_LISTBOX */ +/* #undef DEBUG_LISTBOX */ #include "debug.h" #define GMEM_ZEROINIT 0x0040 @@ -58,6 +58,11 @@ int ListBoxFindNextMatch(HWND hwnd, WORD wChar); ((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) != LBS_OWNERDRAWVARIABLE) ) || \ ((wndPtr->dwStyle & LBS_HASSTRINGS) == LBS_HASSTRINGS) ) +#define HasStrings(wndPtr) ( \ + ( ((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) != LBS_OWNERDRAWFIXED) && \ + ((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) != LBS_OWNERDRAWVARIABLE) ) || \ + ((wndPtr->dwStyle & LBS_HASSTRINGS) == LBS_HASSTRINGS) ) + /*********************************************************************** * ListBoxWndProc @@ -68,6 +73,7 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) LPHEADLIST lphl; HWND hWndCtl; WORD wRet; + LONG lRet; RECT rect; int y; CREATESTRUCT *createStruct; @@ -76,7 +82,7 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) case WM_CREATE: CreateListBoxStruct(hwnd); lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr); - dprintf_listbox(stddeb,"ListBox WM_CREATE %lX !\n", lphl); + dprintf_listbox(stddeb,"ListBox WM_CREATE %p !\n", lphl); if (lphl == NULL) return 0; createStruct = (CREATESTRUCT *)lParam; if (HIWORD(createStruct->lpCreateParams) != 0) @@ -102,11 +108,11 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) ListBoxResetContent(hwnd); free(lphl); *((LPHEADLIST *)&wndPtr->wExtra[1]) = 0; - dprintf_listbox(stddeb,"ListBox WM_DESTROY %lX !\n", lphl); + dprintf_listbox(stddeb,"ListBox WM_DESTROY %p !\n", lphl); return 0; case WM_VSCROLL: - dprintf_listbox(stddeb,"ListBox WM_VSCROLL w=%04X l=%08X !\n", + dprintf_listbox(stddeb,"ListBox WM_VSCROLL w=%04X l=%08lX !\n", wParam, lParam); lphl = ListBoxGetStorageHeader(hwnd); if (lphl == NULL) return 0; @@ -143,7 +149,7 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) return 0; case WM_HSCROLL: - dprintf_listbox(stddeb,"ListBox WM_HSCROLL w=%04X l=%08X !\n", + dprintf_listbox(stddeb,"ListBox WM_HSCROLL w=%04X l=%08lX !\n", wParam, lParam); lphl = ListBoxGetStorageHeader(hwnd); if (lphl == NULL) return 0; @@ -195,6 +201,8 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) if (lphl == NULL) return 0; lphl->PrevFocused = lphl->ItemFocused; y = ListBoxFindMouse(hwnd, LOWORD(lParam), HIWORD(lParam)); + if (y==-1) + return 0; if ((wndPtr->dwStyle & LBS_MULTIPLESEL) == LBS_MULTIPLESEL) { lphl->ItemFocused = y; wRet = ListBoxGetSel(hwnd, y); @@ -202,6 +210,9 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) } else { ListBoxSetCurSel(hwnd, y); + if ((wndPtr->dwStyle && LBS_NOTIFY) != 0) + SendMessage(lphl->hWndLogicParent, WM_COMMAND, + wndPtr->wIDmenu, MAKELONG(hwnd, LBN_SELCHANGE)); } ListBoxGetItemRect(hwnd, y, &rectsel); InvalidateRect(hwnd, NULL, TRUE); @@ -223,11 +234,11 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) MAKELONG(hwnd, LBN_DBLCLK)); return 0; case WM_MOUSEMOVE: + lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr); + if (lphl == NULL) return 0; if ((wParam & MK_LBUTTON) != 0) { y = HIWORD(lParam); if (y < 4) { - lphl = ListBoxGetStorageHeader(hwnd); - if (lphl == NULL) return 0; if (lphl->FirstVisible > 1) { lphl->FirstVisible--; if (wndPtr->dwStyle & WS_VSCROLL) @@ -239,8 +250,6 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) } GetClientRect(hwnd, &rect); if (y > (rect.bottom - 4)) { - lphl = ListBoxGetStorageHeader(hwnd); - if (lphl == NULL) return 0; if (lphl->FirstVisible < lphl->ItemsCount) { lphl->FirstVisible++; if (wndPtr->dwStyle & WS_VSCROLL) @@ -252,14 +261,15 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) } if ((y > 0) && (y < (rect.bottom - 4))) { if ((y < rectsel.top) || (y > rectsel.bottom)) { - lphl = ListBoxGetStorageHeader(hwnd); - if (lphl == NULL) return 0; wRet = ListBoxFindMouse(hwnd, LOWORD(lParam), HIWORD(lParam)); if ((wndPtr->dwStyle & LBS_MULTIPLESEL) == LBS_MULTIPLESEL) { lphl->ItemFocused = wRet; } else { ListBoxSetCurSel(hwnd, wRet); + if ((wndPtr->dwStyle && LBS_NOTIFY) != 0) + SendMessage(lphl->hWndLogicParent, WM_COMMAND, + wndPtr->wIDmenu, MAKELONG(hwnd, LBN_SELCHANGE)); } ListBoxGetItemRect(hwnd, wRet, &rectsel); InvalidateRect(hwnd, NULL, TRUE); @@ -327,6 +337,9 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) if (lphl->FirstVisible < 1) lphl->FirstVisible = 1; if ((wndPtr->dwStyle & LBS_MULTIPLESEL) != LBS_MULTIPLESEL) { ListBoxSetCurSel(hwnd, lphl->ItemFocused); + if ((wndPtr->dwStyle && LBS_NOTIFY) != 0) + SendMessage(lphl->hWndLogicParent, WM_COMMAND, + wndPtr->wIDmenu, MAKELONG(hwnd, LBN_SELCHANGE)); } if (wndPtr->dwStyle & WS_VSCROLL) SetScrollPos(hwnd, SB_VERT, lphl->FirstVisible, TRUE); @@ -341,6 +354,15 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) else lphl->hFont = wParam; if (wParam == 0) break; + break; + case WM_SETREDRAW: +#ifdef DEBUG_LISTBOX + printf("ListBox WM_SETREDRAW hWnd=%04X w=%04X !\n", hwnd, wParam); +#endif + lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr); + if (lphl == NULL) return 0; + lphl->bRedrawFlag = wParam; + break; case WM_PAINT: wndPtr = WIN_FindWndPtr(hwnd); if ((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED) { @@ -401,23 +423,29 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) case LB_GETHORIZONTALEXTENT: return wRet; case LB_GETITEMDATA: - wRet = ListBoxGetText(hwnd, wParam, (LPSTR)lParam, TRUE); - return wRet; + lRet = ListBoxGetText(hwnd, wParam, (LPSTR)lParam, HasStrings(wndPtr)); + return lRet; case LB_GETITEMHEIGHT: - return wRet; + ListBoxGetItemRect(hwnd, wParam, &rect); + return (rect.bottom - rect.top); case LB_GETITEMRECT: - return wRet; + ListBoxGetItemRect(hwnd, wParam, (LPRECT)lParam); + return 0; case LB_GETSEL: wRet = ListBoxGetSel(hwnd, wParam); return wRet; case LB_GETSELCOUNT: - return wRet; + lphl = ListBoxGetStorageHeader(hwnd); + if (lphl == NULL) return LB_ERR; + return lphl->SelCount; case LB_GETSELITEMS: return wRet; case LB_GETTEXTLEN: return wRet; case LB_GETTOPINDEX: - return wRet; + lphl = ListBoxGetStorageHeader(hwnd); + if (lphl == NULL) return LB_ERR; + return lphl->FirstVisible; case LB_SELECTSTRING: return wRet; case LB_SELITEMRANGE: @@ -426,6 +454,7 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) return wRet; case LB_SETCOLUMNWIDTH: lphl = ListBoxGetStorageHeader(hwnd); + if (lphl == NULL) return LB_ERR; lphl->ColumnsWidth = wParam; break; case LB_SETHORIZONTALEXTENT: @@ -434,7 +463,10 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) wRet = ListBoxSetItemData(hwnd, wParam, lParam); return wRet; case LB_SETTABSTOPS: - return wRet; + lphl = ListBoxGetStorageHeader(hwnd); + if (lphl == NULL) return LB_ERR; + lphl->FirstVisible = wParam; + return 0; case LB_SETCURSEL: dprintf_listbox(stddeb,"ListBox LB_SETCURSEL wParam=%x !\n", wParam); @@ -500,19 +532,18 @@ void StdDrawListBox(HWND hwnd) HBRUSH hBrush; int OldBkMode; DWORD dwOldTextColor; - HWND hWndParent; HDC hdc; RECT rect; - UINT i, h, h2, maxwidth, ipc; - char C[128]; + int i, h, h2, maxwidth, ipc; h = 0; hdc = BeginPaint( hwnd, &ps ); - if (!IsWindowVisible(hwnd)) { - EndPaint( hwnd, &ps ); - return; - } + if (!IsWindowVisible(hwnd)) { + EndPaint( hwnd, &ps ); + return; + } lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr); if (lphl == NULL) goto EndOfPaint; + if (!lphl->bRedrawFlag) goto EndOfPaint; SelectObject(hdc, lphl->hFont); hBrush = SendMessage(lphl->hWndLogicParent, WM_CTLCOLOR, (WORD)hdc, MAKELONG(hwnd, CTLCOLOR_LISTBOX)); @@ -592,18 +623,19 @@ void OwnerDrawListBox(HWND hwnd) PAINTSTRUCT ps; HBRUSH hBrush; HWND hWndParent; - HDC hdc; - RECT rect; - UINT i, h, h2, maxwidth; - char C[128]; + DWORD itemData; + HDC hdc; + RECT rect; + int i, h, h2, maxwidth; h = 0; hdc = BeginPaint(hwnd, &ps); - if (!IsWindowVisible(hwnd)) { - EndPaint( hwnd, &ps ); - return; - } + if (!IsWindowVisible(hwnd)) { + EndPaint( hwnd, &ps ); + return; + } lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr); if (lphl == NULL) goto EndOfPaint; + if (!lphl->bRedrawFlag) goto EndOfPaint; hBrush = SendMessage(lphl->hWndLogicParent, WM_CTLCOLOR, (WORD)hdc, MAKELONG(hwnd, CTLCOLOR_LISTBOX)); if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(WHITE_BRUSH); @@ -623,11 +655,10 @@ void OwnerDrawListBox(HWND hwnd) lpls->dis.hwndItem = hwnd; lpls->dis.CtlType = ODT_LISTBOX; lpls->dis.itemID = i - 1; - if ((!lpls->dis.CtlID)&&(lphl->hWndLogicParent)) - { - ListBoxGetWindowAndStorage(lphl->hWndLogicParent, &ParentWndPtr); + if ((!lpls->dis.CtlID) && (lphl->hWndLogicParent)) { + ParentWndPtr = WIN_FindWndPtr(lphl->hWndLogicParent); lpls->dis.CtlID = ParentWndPtr->wIDmenu; - } + } h2 = lpls->dis.rcItem.bottom - lpls->dis.rcItem.top; lpls->dis.rcItem.top = h; lpls->dis.rcItem.bottom = h + h2; @@ -645,10 +676,18 @@ void OwnerDrawListBox(HWND hwnd) lpls->dis.rcItem.right, lpls->dis.rcItem.bottom); dprintf_listbox(stddeb,"LBOX WM_DRAWITEM Parent=%X &dis=%lX CtlID=%u !\n", hWndParent, (LONG)&lpls->dis, lpls->dis.CtlID); - dprintf_listbox(stddeb,"LBOX WM_DRAWITEM %08X!\n",lpls->dis.itemData); + dprintf_listbox(stddeb,"LBOX WM_DRAWITEM %08lX!\n",lpls->dis.itemData); if (HasStrings(wndPtr)) dprintf_listbox(stddeb," '%s'\n",lpls->itemText); - SendMessage(lphl->hWndLogicParent, WM_DRAWITEM, i-1, (LPARAM)&lpls->dis); + if (HasStrings(wndPtr)) { + itemData = lpls->dis.itemData; + lpls->dis.itemData = (DWORD)lpls->itemText; + } + SendMessage(lphl->hWndLogicParent, WM_DRAWITEM, + i-1, (LPARAM)&lpls->dis); + if (HasStrings(wndPtr)) + lpls->dis.itemData = itemData; + /* if (lpls->dis.itemState != 0) { InvertRect(hdc, &lpls->dis.rcItem); } */ @@ -662,7 +701,7 @@ void OwnerDrawListBox(HWND hwnd) EndOfPaint: EndPaint( hwnd, &ps ); if ((lphl->ItemsCount > lphl->ItemsVisible) & - (wndPtr->dwStyle & WS_VSCROLL)) { + (wndPtr->dwStyle & WS_VSCROLL)) { /* InvalidateRect(wndPtr->hWndVScroll, NULL, TRUE); UpdateWindow(wndPtr->hWndVScroll); @@ -679,8 +718,7 @@ int ListBoxFindMouse(HWND hwnd, int X, int Y) LPHEADLIST lphl; LPLISTSTRUCT lpls; RECT rect; - UINT i, h, h2, w, w2; - char C[128]; + int i, h, h2, w, w2; lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr); if (lphl == NULL) return LB_ERR; if (lphl->ItemsCount == 0) return LB_ERR; @@ -715,39 +753,48 @@ int ListBoxFindMouse(HWND hwnd, int X, int Y) int CreateListBoxStruct(HWND hwnd) { - WND *wndPtr; - LPHEADLIST lphl; - wndPtr = WIN_FindWndPtr(hwnd); - lphl = (LPHEADLIST)malloc(sizeof(HEADLIST)); - lphl->lpFirst = NULL; - *((LPHEADLIST *)&wndPtr->wExtra[1]) = lphl; /* HEAD of List */ - lphl->ItemsCount = 0; - lphl->ItemsVisible = 0; - lphl->FirstVisible = 1; - lphl->StdItemHeight = 15; - lphl->DrawCtlType = ODT_LISTBOX; - return TRUE; + WND *wndPtr; + LPHEADLIST lphl; + wndPtr = WIN_FindWndPtr(hwnd); + lphl = (LPHEADLIST)malloc(sizeof(HEADLIST)); + lphl->lpFirst = NULL; + *((LPHEADLIST *)&wndPtr->wExtra[1]) = lphl; /* HEAD of List */ + lphl->ItemsCount = 0; + lphl->ItemsVisible = 0; + lphl->FirstVisible = 1; + lphl->ColumnsVisible = 1; + lphl->ItemsPerColumn = 0; + lphl->StdItemHeight = 15; + lphl->ItemFocused = 0; + lphl->PrevFocused = 0; + lphl->SelCount = 0; + lphl->DrawCtlType = ODT_LISTBOX; + lphl->bRedrawFlag = TRUE; + return TRUE; } void ListBoxAskMeasure(WND *wndPtr, LPHEADLIST lphl, LPLISTSTRUCT lpls) { - MEASUREITEMSTRUCT *measure; + MEASUREITEMSTRUCT *lpmeasure; HANDLE hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(MEASUREITEMSTRUCT)); - measure = (MEASUREITEMSTRUCT *) USER_HEAP_ADDR(hTemp); - if (measure == NULL) { + lpmeasure = (MEASUREITEMSTRUCT *) USER_HEAP_ADDR(hTemp); + if (lpmeasure == NULL) { fprintf(stderr,"ListBoxAskMeasure() // Bad allocation of Measure struct !\n"); return; } - measure->CtlType = ODT_LISTBOX; - measure->CtlID = wndPtr->wIDmenu; - measure->itemID = lpls->dis.itemID; - measure->itemWidth = wndPtr->rectWindow.right - wndPtr->rectWindow.left; - measure->itemHeight = 0; - measure->itemData = lpls->dis.itemData; - SendMessage(lphl->hWndLogicParent, WM_MEASUREITEM, 0, (DWORD)measure); - lpls->dis.rcItem.right = lpls->dis.rcItem.left + measure->itemWidth; - lpls->dis.rcItem.bottom = lpls->dis.rcItem.top + measure->itemHeight; + lpmeasure->CtlType = ODT_LISTBOX; + lpmeasure->CtlID = wndPtr->wIDmenu; + lpmeasure->itemID = lpls->dis.itemID; + lpmeasure->itemWidth = wndPtr->rectWindow.right - wndPtr->rectWindow.left; + lpmeasure->itemHeight = 0; + if (HasStrings(wndPtr)) + lpmeasure->itemData = (DWORD)lpls->itemText; + else + lpmeasure->itemData = lpls->dis.itemData; + SendMessage(lphl->hWndLogicParent, WM_MEASUREITEM, 0, (DWORD)lpmeasure); + lpls->dis.rcItem.right = lpls->dis.rcItem.left + lpmeasure->itemWidth; + lpls->dis.rcItem.bottom = lpls->dis.rcItem.top + lpmeasure->itemHeight; USER_HEAP_FREE(hTemp); } @@ -757,14 +804,15 @@ int ListBoxAddString(HWND hwnd, LPSTR newstr) WND *wndPtr; LPHEADLIST lphl; LPLISTSTRUCT lpls, lplsnew; - HANDLE hTemp; + HANDLE hItem; + HANDLE hStr; LPSTR str; lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr); if (lphl == NULL) return LB_ERR; - hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(LISTSTRUCT)); - lplsnew = (LPLISTSTRUCT) USER_HEAP_ADDR(hTemp); + hItem = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(LISTSTRUCT)); + lplsnew = (LPLISTSTRUCT) USER_HEAP_ADDR(hItem); if (lplsnew == NULL) { - fprintf(stderr,"ListBoxAddString() // Bad allocation of new item !\n"); + dprintf_listbox(stddeb,"ListBoxAddString() // Bad allocation of new item !\n"); return LB_ERRSPACE; } lpls = lphl->lpFirst; @@ -778,47 +826,47 @@ int ListBoxAddString(HWND hwnd, LPSTR newstr) lphl->lpFirst = lplsnew; lphl->ItemsCount++; dprintf_listbox(stddeb,"Items Count = %u\n", lphl->ItemsCount); - hTemp = 0; - ListBoxDefaultItem(hwnd, wndPtr, lphl, lplsnew); - if (HasStrings(wndPtr)) - { - hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, strlen(newstr) + 1); - str = (LPSTR)USER_HEAP_ADDR(hTemp); - if (str == NULL) return LB_ERRSPACE; - strcpy(str, newstr); - newstr = str; - lplsnew->itemText = str; - lplsnew->dis.itemData = 0; - dprintf_listbox(stddeb,"ListBoxAddString// after strcpy '%s'\n", str); - } - else - { - lplsnew->itemText = NULL; - lplsnew->dis.itemData = (DWORD)newstr; - } - lplsnew->hMem = hTemp; - lplsnew->lpNext = NULL; - lplsnew->dis.itemID = lphl->ItemsCount; - lplsnew->hData = hTemp; - if (((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)|| ((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED)) + hStr = 0; + + ListBoxDefaultItem(hwnd, wndPtr, lphl, lplsnew); + if (HasStrings(wndPtr)) { + hStr = USER_HEAP_ALLOC(GMEM_MOVEABLE, strlen(newstr) + 1); + str = (LPSTR)USER_HEAP_ADDR(hStr); + if (str == NULL) return LB_ERRSPACE; + strcpy(str, newstr); + newstr = str; + lplsnew->itemText = str; + dprintf_listbox(stddeb,"ListBoxAddString // LBS_HASSTRINGS after strcpy '%s'\n", str); + } + else { + lplsnew->itemText = NULL; + lplsnew->dis.itemData = (DWORD)newstr; + } + lplsnew->hMem = hItem; + lplsnew->lpNext = NULL; + lplsnew->dis.itemID = lphl->ItemsCount; + lplsnew->hData = hStr; + if (((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE) || + ((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED)) ListBoxAskMeasure(wndPtr, lphl, lplsnew); - if (wndPtr->dwStyle & WS_VSCROLL) - SetScrollRange(hwnd, SB_VERT, 1, lphl->ItemsCount, - (lphl->FirstVisible != 1)); - if ((wndPtr->dwStyle & WS_HSCROLL) && lphl->ItemsPerColumn != 0) - SetScrollRange(hwnd, SB_HORZ, 1, lphl->ItemsVisible / - lphl->ItemsPerColumn + 1, (lphl->FirstVisible != 1)); - if (lphl->FirstVisible >= (lphl->ItemsCount - lphl->ItemsVisible)) { - InvalidateRect(hwnd, NULL, TRUE); - UpdateWindow(hwnd); - } - if ((lphl->ItemsCount - lphl->FirstVisible) == lphl->ItemsVisible) { if (wndPtr->dwStyle & WS_VSCROLL) - ShowScrollBar(hwnd, SB_VERT, TRUE); - if (wndPtr->dwStyle & WS_HSCROLL) - ShowScrollBar(hwnd, SB_HORZ, TRUE); - } - return lphl->ItemsCount-1; + SetScrollRange(hwnd, SB_VERT, 1, lphl->ItemsCount, + (lphl->FirstVisible != 1 && lphl->bRedrawFlag)); + if ((wndPtr->dwStyle & WS_HSCROLL) && lphl->ItemsPerColumn != 0) + SetScrollRange(hwnd, SB_HORZ, 1, + lphl->ItemsVisible / lphl->ItemsPerColumn + 1, + (lphl->FirstVisible != 1 && lphl->bRedrawFlag)); + if (lphl->FirstVisible >= (lphl->ItemsCount - lphl->ItemsVisible)) { + InvalidateRect(hwnd, NULL, TRUE); + UpdateWindow(hwnd); + } + if ((lphl->ItemsCount - lphl->FirstVisible) == lphl->ItemsVisible) { + if (wndPtr->dwStyle & WS_VSCROLL) + ShowScrollBar(hwnd, SB_VERT, TRUE); + if (wndPtr->dwStyle & WS_HSCROLL) + ShowScrollBar(hwnd, SB_HORZ, TRUE); + } + return (lphl->ItemsCount - 1); } @@ -827,10 +875,11 @@ int ListBoxInsertString(HWND hwnd, UINT uIndex, LPSTR newstr) WND *wndPtr; LPHEADLIST lphl; LPLISTSTRUCT lpls, lplsnew; - HANDLE hTemp; + HANDLE hItem; + HANDLE hStr; LPSTR str; UINT Count; - dprintf_listbox(stddeb,"ListBoxInsertString(%04X, %d, %08X);\n", + dprintf_listbox(stddeb,"ListBoxInsertString(%04X, %d, %p);\n", hwnd, uIndex, newstr); if (uIndex == (UINT)-1) return ListBoxAddString(hwnd, newstr); lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr); @@ -846,47 +895,42 @@ int ListBoxInsertString(HWND hwnd, UINT uIndex, LPSTR newstr) if (lpls->lpNext == NULL) return LB_ERR; lpls = (LPLISTSTRUCT)lpls->lpNext; } - hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(LISTSTRUCT)); - lplsnew = (LPLISTSTRUCT) USER_HEAP_ADDR(hTemp); + hItem = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(LISTSTRUCT)); + lplsnew = (LPLISTSTRUCT) USER_HEAP_ADDR(hItem); if (lplsnew == NULL) { - fprintf(stderr,"ListBoxInsertString() // Bad allocation of new item !\n"); + printf("ListBoxInsertString() // Bad allocation of new item !\n"); return LB_ERRSPACE; } ListBoxDefaultItem(hwnd, wndPtr, lphl, lplsnew); - lplsnew->hMem = hTemp; - if (uIndex == 0) - { + lplsnew->hMem = hItem; + if (uIndex == 0) { lplsnew->lpNext = lphl->lpFirst; lphl->lpFirst = lplsnew; - } - else - { + } + else { lplsnew->lpNext = lpls->lpNext; lpls->lpNext = lplsnew; - } + } lphl->ItemsCount++; - hTemp = 0; - if (HasStrings(wndPtr)) - { - hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, strlen(newstr) + 1); - str = (LPSTR)USER_HEAP_ADDR(hTemp); - if (str == NULL) return LB_ERRSPACE; - strcpy(str, newstr); - newstr = str; - lplsnew->itemText = str; - lplsnew->dis.itemData = 0; -#ifdef DEBUG_LISTBOX - printf("ListBoxInsertString // after strcpy '%s'\n", str); -#endif - } - else - { - lplsnew->itemText = NULL; - lplsnew->dis.itemData = (DWORD)newstr; - } + hStr = 0; + + if (HasStrings(wndPtr)) { + hStr = USER_HEAP_ALLOC(GMEM_MOVEABLE, strlen(newstr) + 1); + str = (LPSTR)USER_HEAP_ADDR(hStr); + if (str == NULL) return LB_ERRSPACE; + strcpy(str, newstr); + newstr = str; + lplsnew->itemText = str; + dprintf_listbox(stddeb,"ListBoxInsertString // LBS_HASSTRINGS after strcpy '%s'\n", str); + } + else { + lplsnew->itemText = NULL; + lplsnew->dis.itemData = (DWORD)newstr; + } lplsnew->dis.itemID = lphl->ItemsCount; - lplsnew->hData = hTemp; - if (((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)|| ((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED)) + lplsnew->hData = hStr; + if (((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE) || + ((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED)) ListBoxAskMeasure(wndPtr, lphl, lplsnew); if (wndPtr->dwStyle & WS_VSCROLL) SetScrollRange(hwnd, SB_VERT, 1, lphl->ItemsCount, @@ -904,10 +948,9 @@ int ListBoxInsertString(HWND hwnd, UINT uIndex, LPSTR newstr) InvalidateRect(hwnd, NULL, TRUE); UpdateWindow(hwnd); } -#ifdef DEBUG_LISTBOX - printf("ListBoxInsertString // count=%d\n", lphl->ItemsCount); -#endif - return /* lphl->ItemsCount;*/ uIndex; + dprintf_listbox(stddeb,"ListBoxInsertString // count=%d\n", lphl->ItemsCount); +/* return lphl->ItemsCount; */ + return uIndex; } @@ -917,8 +960,7 @@ int ListBoxGetText(HWND hwnd, UINT uIndex, LPSTR OutStr, BOOL bItemData) LPHEADLIST lphl; LPLISTSTRUCT lpls; UINT Count; - if (!bItemData) - *OutStr=0; + if (!bItemData) *OutStr=0; lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr); if (lphl == NULL) return LB_ERR; if (uIndex >= lphl->ItemsCount) return LB_ERR; @@ -1055,8 +1097,8 @@ int ListBoxResetContent(HWND hwnd) lphl->lpFirst = NULL; lphl->FirstVisible = 1; lphl->ItemsCount = 0; - lphl->ItemFocused = /*0*/-1; - lphl->PrevFocused = /*0*/-1; + lphl->ItemFocused = -1; + lphl->PrevFocused = -1; if ((wndPtr->dwStyle && LBS_NOTIFY) != 0) SendMessage(lphl->hWndLogicParent, WM_COMMAND, wndPtr->wIDmenu, MAKELONG(hwnd, LBN_SELCHANGE)); @@ -1153,64 +1195,56 @@ int ListBoxGetSel(HWND hwnd, WORD wIndex) int ListBoxDirectory(HWND hwnd, UINT attrib, LPSTR filespec) { - struct dosdirent *dp; - struct dosdirent *newdp; - struct stat st; - int x, wRet; - char temp[256]; -#ifdef DEBUG_LISTBOX - fprintf(stderr,"ListBoxDirectory: %s, %4x\n",filespec,attrib); -#endif - if ((dp = (struct dosdirent *)DOS_opendir(filespec)) ==NULL) return 0; - while (dp = (struct dosdirent *)DOS_readdir(dp)) - { - if (!dp->inuse) break; -#ifdef DEBUG_LISTBOX - printf("ListBoxDirectory %08X '%s' !\n", dp->filename, dp->filename); -#endif - if (dp->attribute & FA_DIREC) - { - if (attrib & DDL_DIRECTORY) - { - sprintf(temp, "[%s]", dp->filename); - if ( (wRet = ListBoxAddString(hwnd, temp)) == LB_ERR) break; - } - } - else - { - if (attrib & DDL_EXCLUSIVE) - { - if (attrib & (DDL_READWRITE | DDL_READONLY | DDL_HIDDEN | - DDL_SYSTEM) ) - if ( (wRet = ListBoxAddString(hwnd, dp->filename)) - == LB_ERR) - break; - } - else - { - if ( (wRet = ListBoxAddString(hwnd, dp->filename)) == LB_ERR) - break; - } - } - } - DOS_closedir(dp); - - if (attrib & DDL_DRIVES) - { - for (x=0;x!=MAX_DOS_DRIVES;x++) - { - if (DOS_ValidDrive(x)) - { - sprintf(temp, "[-%c-]", 'a'+x); - if ( (wRet = ListBoxAddString(hwnd, temp)) == LB_ERR) - break; - } - } - } -#ifdef DEBUG_LISTBOX - printf("End of ListBoxDirectory !\n"); -#endif - return wRet; + struct dosdirent *dp; + int x, wRet; + BOOL OldFlag; + char temp[256]; + LPHEADLIST lphl; + dprintf_listbox(stddeb,"ListBoxDirectory: %s, %4x\n",filespec,attrib); + lphl = ListBoxGetStorageHeader(hwnd); + if (lphl == NULL) return LB_ERR; + if ((dp = (struct dosdirent *)DOS_opendir(filespec)) ==NULL) return 0; + OldFlag = lphl->bRedrawFlag; + lphl->bRedrawFlag = FALSE; + while ((dp = (struct dosdirent *)DOS_readdir(dp))) { + if (!dp->inuse) break; + dprintf_listbox(stddeb,"ListBoxDirectory %p '%s' !\n", dp->filename, dp->filename); + if (dp->attribute & FA_DIREC) { + if (attrib & DDL_DIRECTORY) { + sprintf(temp, "[%s]", dp->filename); + if ( (wRet = ListBoxAddString(hwnd, temp)) == LB_ERR) break; + } + } + else { + if (attrib & DDL_EXCLUSIVE) { + if (attrib & (DDL_READWRITE | DDL_READONLY | DDL_HIDDEN | + DDL_SYSTEM) ) + if ( (wRet = ListBoxAddString(hwnd, dp->filename)) + == LB_ERR) break; + } + else { + if ( (wRet = ListBoxAddString(hwnd, dp->filename)) + == LB_ERR) break; + } + } + } + DOS_closedir(dp); + + if (attrib & DDL_DRIVES) { + for (x=0;x!=MAX_DOS_DRIVES;x++) { + if (DOS_ValidDrive(x)) { + sprintf(temp, "[-%c-]", 'a'+x); + if ( (wRet = ListBoxAddString(hwnd, temp)) == LB_ERR) break; + } + } + } + lphl->bRedrawFlag = OldFlag; + if (OldFlag) { + InvalidateRect(hwnd, NULL, TRUE); + UpdateWindow(hwnd); + } + dprintf_listbox(stddeb,"End of ListBoxDirectory !\n"); + return wRet; } @@ -1357,7 +1391,8 @@ int ListBoxFindNextMatch(HWND hwnd, WORD wChar) */ BOOL DlgDirSelect(HWND hDlg, LPSTR lpStr, int nIDLBox) { - fprintf(stdnimp,"DlgDirSelect(%04X, '%s', %d) \n", hDlg, lpStr, nIDLBox); + fprintf(stdnimp,"DlgDirSelect(%04X, '%s', %d) \n", hDlg, lpStr, nIDLBox); + return FALSE; } diff --git a/controls/menu.c b/controls/menu.c index 8290ddaba2a..3d5fef02404 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -24,14 +24,15 @@ static char Copyright2[] = "Copyright Alexandre Julliard, 1994"; #include "user.h" #include "win.h" #include "message.h" +#include "stddebug.h" +/* #define DEBUG_MENU */ +/* #undef DEBUG_MENU */ +/* #define DEBUG_MENUCALC */ +/* #undef DEBUG_MENUCALC */ +/* #define DEBUG_MENUSHORTCUT */ +/* #undef DEBUG_MENUSHORTCUT */ #include "debug.h" -/* #define DEBUG_MENU /* */ -/* #undef DEBUG_MENU /* */ -/* #define DEBUG_MENUCALC /* */ -/* #undef DEBUG_MENUCALC /* */ -/* #define DEBUG_MENUSHORTCUT /* */ -/* #undef DEBUG_MENUSHORTCUT /* */ /* Dimension of the menu bitmaps */ static WORD check_bitmap_width = 0, check_bitmap_height = 0; @@ -288,7 +289,7 @@ static void MENU_CalcItemSize( HDC hdc, LPMENUITEM lpitem, HWND hwndOwner, /* If we get here, then it is a text item */ - dwSize = GetTextExtent( hdc, lpitem->item_text, strlen(lpitem->item_text)); + dwSize = (lpitem->item_text == NULL) ? 0 : GetTextExtent( hdc, lpitem->item_text, strlen(lpitem->item_text)); lpitem->rect.right += LOWORD(dwSize); lpitem->rect.bottom += max( HIWORD(dwSize), SYSMETRICS_CYMENU ); @@ -605,7 +606,7 @@ WORD MENU_DrawMenuBar(HDC hDC, LPRECT lprect, HWND hwnd, BOOL suppress_draw) lppop = (LPPOPUPMENU) USER_HEAP_ADDR( wndPtr->wIDmenu ); if (lppop == NULL || lprect == NULL) return SYSMETRICS_CYMENU; - dprintf_menu(stddeb,"MENU_DrawMenuBar(%04X, %08X, %08X); !\n", + dprintf_menu(stddeb,"MENU_DrawMenuBar(%04X, %p, %p); !\n", hDC, lprect, lppop); if (lppop->Height == 0) MENU_MenuBarCalcSize(hDC, lprect, lppop, hwnd); lprect->bottom = lprect->top + lppop->Height; @@ -1527,7 +1528,7 @@ int GetMenuString(HMENU hMenu, WORD wItemID, { LPMENUITEM lpitem; int maxsiz; - dprintf_menu(stddeb,"GetMenuString(%04X, %04X, %08X, %d, %04X);\n", + dprintf_menu(stddeb,"GetMenuString(%04X, %04X, %p, %d, %04X);\n", hMenu, wItemID, str, nMaxSiz, wFlags); if (str == NULL) return FALSE; lpitem = MENU_FindItem( &hMenu, &wItemID, wFlags ); @@ -1624,10 +1625,12 @@ BOOL InsertMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewIt LPPOPUPMENU menu; if (IS_STRING_ITEM(wFlags)) - dprintf_menu(stddeb,"InsertMenu (%04X, %04X, %04X, '%s') !\n", - hMenu, wFlags, wItemID, lpNewItem); + { + dprintf_menu(stddeb,"InsertMenu (%04X, %04X, %04X, %04X, '%s') !\n", + hMenu, nPos, wFlags, wItemID, lpNewItem); + } else - dprintf_menu(stddeb,"InsertMenu (%04X, %04X, %04X, %04X, %08X) !\n", + dprintf_menu(stddeb,"InsertMenu (%04X, %04X, %04X, %04X, %p) !\n", hMenu, nPos, wFlags, wItemID, lpNewItem); /* Find where to insert new item */ @@ -1763,7 +1766,7 @@ BOOL ModifyMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewIt dprintf_menu(stddeb,"ModifyMenu (%04X, %04X, %04X, %04X, '%s') !\n", hMenu, nPos, wFlags, wItemID, lpNewItem); else - dprintf_menu(stddeb,"ModifyMenu (%04X, %04X, %04X, %04X, %08X) !\n", + dprintf_menu(stddeb,"ModifyMenu (%04X, %04X, %04X, %04X, %p) !\n", hMenu, nPos, wFlags, wItemID, lpNewItem); if (!(lpitem = MENU_FindItem( &hMenu, &nPos, wFlags ))) return FALSE; @@ -1872,7 +1875,8 @@ BOOL DestroyMenu(HMENU hMenu) if (hMenu == 0) return FALSE; lppop = (LPPOPUPMENU) USER_HEAP_ADDR(hMenu); if (lppop == NULL) return FALSE; - if (lppop->hWnd) DestroyWindow (lppop->hWnd); + if ((lppop->wFlags & MF_POPUP) && lppop->hWnd) + DestroyWindow( lppop->hWnd ); if (lppop->hItems) { @@ -1912,10 +1916,10 @@ HMENU GetSystemMenu(HWND hWnd, BOOL bRevert) */ BOOL SetSystemMenu(HWND hWnd, HMENU newHmenu) { - WND *wndPtr; + WND *wndPtr; - if ((wndPtr = WIN_FindWndPtr(hWnd)) != NULL) - wndPtr->hSysMenu = newHmenu; + if ((wndPtr = WIN_FindWndPtr(hWnd)) != NULL) wndPtr->hSysMenu = newHmenu; + return TRUE; } @@ -2030,7 +2034,7 @@ HMENU LoadMenuIndirect(LPSTR menu_template) { HMENU hMenu; MENU_HEADER *menu_desc; - dprintf_menu(stddeb,"LoadMenuIndirect: menu_template '%08X'\n", + dprintf_menu(stddeb,"LoadMenuIndirect: menu_template '%p'\n", menu_template); hMenu = CreateMenu(); menu_desc = (MENU_HEADER *)menu_template; diff --git a/controls/scroll.c b/controls/scroll.c index 36c7ef80b0d..74be05004b1 100644 --- a/controls/scroll.c +++ b/controls/scroll.c @@ -20,8 +20,8 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; #include "win.h" #include "prototypes.h" #include "stddebug.h" -/* #define DEBUG_SCROLL /* */ -/* #undef DEBUG_SCROLL /* */ +/* #define DEBUG_SCROLL */ +/* #undef DEBUG_SCROLL */ #include "debug.h" @@ -34,6 +34,10 @@ HBITMAP hDnArrowD = 0; HBITMAP hLfArrowD = 0; HBITMAP hRgArrowD = 0; + /* windows/graphics.c */ +extern void GRAPH_DrawReliefRect( HDC hdc, RECT *rect, + int thickness, BOOL pressed ); + LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hWnd, WND **wndPtr); LPHEADSCROLL ScrollBarGetStorageHeader(HWND hWnd); LPHEADSCROLL GetScrollObjectStruct(HWND hWnd, int nBar); @@ -51,17 +55,12 @@ LPHEADSCROLL AllocScrollBar(DWORD dwStyle, int width, int height); */ LONG ScrollBarWndProc( HWND hWnd, WORD message, WORD wParam, LONG lParam ) { - WORD wRet; - short x, y; - short width, height; WND *wndPtr; LPHEADSCROLL lphs; PAINTSTRUCT ps; HDC hDC; - BITMAP bm; - RECT rect, rect2; + RECT rect; LPCREATESTRUCT lpCreat; - static RECT rectsel; POINT *pt; pt=(POINT*)&lParam; switch(message) { @@ -90,7 +89,7 @@ LONG ScrollBarWndProc( HWND hWnd, WORD message, WORD wParam, LONG lParam ) case WM_DESTROY: lphs = ScrollBarGetWindowAndStorage(hWnd, &wndPtr); if (lphs == 0) return 0; - dprintf_scroll(stddeb,"ScrollBar WM_DESTROY %lX !\n", lphs); + dprintf_scroll(stddeb,"ScrollBar WM_DESTROY %p !\n", lphs); free(lphs); *((LPHEADSCROLL *)&wndPtr->wExtra[1]) = 0; return 0; @@ -143,10 +142,19 @@ LONG ScrollBarWndProc( HWND hWnd, WORD message, WORD wParam, LONG lParam ) SetTimer(hWnd, 1, 100, NULL); return 0; + case WM_SETREDRAW: +#ifdef DEBUG_SCROLL + printf("ScrollBar WM_SETREDRAW hWnd=%04X w=%04X !\n", hWnd, wParam); +#endif + lphs = ScrollBarGetStorageHeader(hWnd); + if (lphs == NULL) return 0; + lphs->bRedrawFlag = wParam; + break; + case WM_PAINT: hDC = BeginPaint(hWnd, &ps); lphs = ScrollBarGetStorageHeader(hWnd); - if (lphs != NULL) { + if (lphs != NULL && lphs->bRedrawFlag) { GetClientRect(hWnd, &rect); StdDrawScrollBar(hWnd, hDC, SB_CTL, &rect, lphs); } @@ -164,7 +172,7 @@ void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y) { LPHEADSCROLL lphs; HWND hWndParent; - RECT rect, rect2; + RECT rect; int width, height; LONG dwOwner; lphs = GetScrollObjectStruct(hWnd, nBar); @@ -265,7 +273,7 @@ void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y) void ScrollBarButtonUp(HWND hWnd, int nBar, int x, int y) { LPHEADSCROLL lphs; - RECT rect, rect2; + RECT rect; HDC hDC; dprintf_scroll(stddeb,"ScrollBarButtonUp // x=%d y=%d\n", x, y); lphs = GetScrollObjectStruct(hWnd, nBar); @@ -308,7 +316,7 @@ void ScrollBarMouseMove(HWND hWnd, int nBar, WORD wParam, int x, int y) LPHEADSCROLL lphs; HWND hWndParent; HWND hWndOwner; - LONG dwOwner; + if ((wParam & MK_LBUTTON) == 0) return; lphs = GetScrollObjectStruct(hWnd, nBar); if (lphs->ThumbActive == 0) return; @@ -391,9 +399,10 @@ void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL HBITMAP hOldBmp; BITMAP bm; RECT rect; - UINT i, w, w2, h, h2, siz; - char C[128]; + UINT w, w2, h, h2; + if (lphs == NULL) return; + if (!lphs->bRedrawFlag) return; dprintf_scroll(stddeb,"StdDrawScrollBar nBar=%04X !\n", nBar); if (lphs->Direction == WM_VSCROLL) dprintf_scroll(stddeb,"StdDrawScrollBar Vertical left=%d top=%d right=%d bottom=%d !\n", @@ -505,7 +514,6 @@ void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL int CreateScrollBarStruct(HWND hWnd) { - RECT rect; int width, height; WND *wndPtr; LPHEADSCROLL lphs; @@ -516,7 +524,7 @@ int CreateScrollBarStruct(HWND hWnd) lphs = AllocScrollBar(WS_VSCROLL, width, height); else lphs = AllocScrollBar(WS_HSCROLL, width, height); - dprintf_scroll(stddeb,"CreateScrollBarStruct %lX !\n", lphs); + dprintf_scroll(stddeb,"CreateScrollBarStruct %p !\n", lphs); *((LPHEADSCROLL *)&wndPtr->wExtra[1]) = lphs; lphs->hWndOwner = hWnd; CopyRect(&lphs->rect, &wndPtr->rectClient); @@ -549,6 +557,7 @@ LPHEADSCROLL AllocScrollBar(DWORD dwStyle, int width, int height) fprintf(stderr,"Bad Memory Alloc on ScrollBar !\n"); return NULL; } + lphs->bRedrawFlag = TRUE; lphs->ThumbActive = FALSE; lphs->TimerPending = FALSE; lphs->ButtonDown = 0; @@ -589,7 +598,7 @@ void NC_CreateScrollBars(HWND hWnd) if (wndPtr->dwStyle & WS_VSCROLL) { if (wndPtr->dwStyle & WS_HSCROLL) height -= SYSMETRICS_CYHSCROLL; lphs = AllocScrollBar(WS_VSCROLL, SYSMETRICS_CXVSCROLL, height); - dprintf_scroll(stddeb,"NC_CreateScrollBars Vertical %lX !\n", + dprintf_scroll(stddeb,"NC_CreateScrollBars Vertical %p !\n", lphs); lphs->rect.left = width - SYSMETRICS_CYVSCROLL; lphs->rect.right = width; @@ -601,7 +610,7 @@ void NC_CreateScrollBars(HWND hWnd) if (wndPtr->dwStyle & WS_HSCROLL) { if (wndPtr->dwStyle & WS_VSCROLL) width -= SYSMETRICS_CYVSCROLL; lphs = AllocScrollBar(WS_HSCROLL, width, SYSMETRICS_CYHSCROLL); - dprintf_scroll(stddeb,"NC_CreateScrollBars Horizontal %lX !\n", lphs); + dprintf_scroll(stddeb,"NC_CreateScrollBars Horizontal %p !\n", lphs); lphs->rect.top = height - SYSMETRICS_CYHSCROLL; lphs->rect.bottom = height; lphs->hWndOwner = hWnd; @@ -750,17 +759,20 @@ void ShowScrollBar(HWND hWnd, WORD wBar, BOOL bFlag) wndPtr = WIN_FindWndPtr(hWnd); if ((wBar == SB_VERT) || (wBar == SB_BOTH)) { if (bFlag) - wndPtr->scroll_flags != 0x0001; + wndPtr->scroll_flags |= 1; else - wndPtr->scroll_flags &= 0xFFFE; + wndPtr->scroll_flags &= ~1; } if ((wBar == SB_HORZ) || (wBar == SB_BOTH)) { if (bFlag) - wndPtr->scroll_flags != 0x0002; + wndPtr->scroll_flags |= 2; else - wndPtr->scroll_flags &= 0xFFFD; + wndPtr->scroll_flags &= ~2; } SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); } + + + diff --git a/controls/static.c b/controls/static.c index e36b412ca09..b61c9e1b3cf 100644 --- a/controls/static.c +++ b/controls/static.c @@ -86,6 +86,17 @@ LONG StaticWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam) InvalidateRect(hWnd, NULL, FALSE); break; + case WM_NCCREATE: + if (style == SS_ICON) + { + CREATESTRUCT * createStruct = (CREATESTRUCT *)lParam; + if (createStruct->lpszName) + STATIC_SetIcon( hWnd, LoadIcon( createStruct->hInstance, + createStruct->lpszName )); + break; + } + return DefWindowProc(hWnd, uMsg, wParam, lParam); + case WM_CREATE: if (style < 0L || style > LAST_STATIC_TYPE) { lResult = -1L; @@ -95,17 +106,13 @@ LONG StaticWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam) color_windowframe = GetSysColor(COLOR_WINDOWFRAME); color_background = GetSysColor(COLOR_BACKGROUND); color_window = GetSysColor(COLOR_WINDOW); - if (style == SS_ICON) - { - CREATESTRUCT * createStruct = (CREATESTRUCT *)lParam; - if (createStruct->lpszName) - STATIC_SetIcon( hWnd, LoadIcon( createStruct->hInstance, - createStruct->lpszName )); - } break; - case WM_DESTROY: - STATIC_SetIcon( hWnd, 0 ); /* Destroy the current icon */ + case WM_NCDESTROY: + if (style == SS_ICON) + STATIC_SetIcon( hWnd, 0 ); /* Destroy the current icon */ + else + lResult = DefWindowProc(hWnd, uMsg, wParam, lParam); break; case WM_PAINT: diff --git a/if1632/Imakefile b/if1632/Imakefile index 4c15d440cc4..9812c1d7c47 100644 --- a/if1632/Imakefile +++ b/if1632/Imakefile @@ -3,18 +3,17 @@ MODULE = if1632 -#ifdef WINELIB SRCS = \ callback.c \ relay.c -#else -SRCS = \ - call.S \ - callback.c \ - relay.c -#endif +#ifdef WINELIB +CALLOBJS = +DLLOBJS = +#else +CALLOBJS = call.o DLLOBJS = \ + dll_commdlg.o \ dll_gdi.o \ dll_kernel.o \ dll_keyboard.o \ @@ -29,22 +28,18 @@ DLLOBJS = \ dll_user.o \ dll_win87em.o \ dll_winsock.o - -#ifdef WINELIB -DLLOBJS= #endif -OBJS1= $(SRCS:.S=.o) - #ifndef NewBuild -OBJS = $(DLLOBJS) $(OBJS1:.c=.o) $(DLLOBJS:.o=_tab.o) +OBJS = $(CALLOBJS) $(DLLOBJS) $(SRCS:.c=.o) $(DLLOBJS:.o=_tab.o) #else -OBJS = $(DLLOBJS) $(OBJS1:.c=.o) $(DLLOBJS:.o=_tab.o) $(DLLOBJS:dll_.rly_) +OBJS = $(CALLOBJS) $(DLLOBJS) $(SRCS:.c=.o) $(DLLOBJS:.o=_tab.o) $(DLLOBJS:dll_.rly_) #endif /* * If you add a new spec file, copy one of these lines */ +MakeDllFromSpec(commdlg,$(TOP)/$(MODULE)) MakeDllFromSpec(gdi,$(TOP)/$(MODULE)) MakeDllFromSpec(kernel,$(TOP)/$(MODULE)) MakeDllFromSpec(keyboard,$(TOP)/$(MODULE)) @@ -63,10 +58,13 @@ MakeDllFromSpec(winsock,$(TOP)/$(MODULE)) WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS)) DependTarget() +#ifndef WINELIB pop.h: $(TOP)/tools/build $(TOP)/tools/build -p -call.s: call.S pop.h +call.o: call.S pop.h + gcc -I. -c -o call.o call.S +#endif includes:: touch pop.h diff --git a/if1632/call.S b/if1632/call.S index 48f6d759f3b..5a6b10b2c91 100644 --- a/if1632/call.S +++ b/if1632/call.S @@ -6,6 +6,11 @@ #endif #if defined(__NetBSD__) || defined(__FreeBSD__) #define UDATASEL 0x27 +#endif +#ifdef __ELF__ +#define A( addr) addr +#else +#define A( addr) _##addr #endif .data jump_target: @@ -15,23 +20,23 @@ return_value: /********************************************************************** * Places to keep info about the current 32-bit stack frame. */ - .globl _IF1632_Saved32_esp,_IF1632_Saved32_ebp,_IF1632_Saved32_ss -_IF1632_Saved32_esp: + .globl A( IF1632_Saved32_esp), A(IF1632_Saved32_ebp), A(IF1632_Saved32_ss) +A(IF1632_Saved32_esp): .long 0 -_IF1632_Saved32_ebp: +A(IF1632_Saved32_ebp): .long 0 -_IF1632_Saved32_ss: +A(IF1632_Saved32_ss): .word 0 /********************************************************************** * Places to keep info about the current 16-bit stack frame. */ - .globl _IF1632_Saved16_esp,_IF1632_Saved16_ebp,_IF1632_Saved16_ss -_IF1632_Saved16_esp: + .globl A(IF1632_Saved16_esp),A(IF1632_Saved16_ebp),A(IF1632_Saved16_ss) +A(IF1632_Saved16_esp): .long 0 -_IF1632_Saved16_ebp: +A(IF1632_Saved16_ebp): .long 0 -_IF1632_Saved16_ss: +A(IF1632_Saved16_ss): .word 0 nbytes: @@ -56,8 +61,8 @@ offset: * 16 target ds */ .align 4 - .globl _CallToInit16 -_CallToInit16: + .globl A(CallToInit16) +A(CallToInit16): pushl %ebp movl %esp,%ebp @@ -65,9 +70,9 @@ _CallToInit16: * Save our registers */ pushal - pushl _IF1632_Saved32_esp - pushl _IF1632_Saved32_ebp - pushw _IF1632_Saved32_ss + pushl A(IF1632_Saved32_esp) + pushl A(IF1632_Saved32_ebp) + pushw A(IF1632_Saved32_ss) /* * Get target address. @@ -79,18 +84,18 @@ _CallToInit16: /* * Put stack registers where we can get them after stack switch. */ - movw %ss,_IF1632_Saved32_ss - movl %esp,_IF1632_Saved32_esp - movl %ebp,_IF1632_Saved32_ebp + movw %ss,A(IF1632_Saved32_ss) + movl %esp,A(IF1632_Saved32_esp) + movl %ebp,A(IF1632_Saved32_ebp) /* * Load initial registers */ - movw _WIN_StackSize,%bx - movw _WIN_HeapSize,%cx + movw A(WIN_StackSize),%bx + movw A(WIN_HeapSize),%cx movl $0,%esi xorl %eax,%eax - movw _PSPSelector,%ax + movw A(PSPSelector),%ax movw %ax,%es movw 16(%ebp),%ax movw %ax,%ds @@ -131,16 +136,16 @@ _CallToInit16: movw %ax,%fs movw %ax,%gs popl %eax - movw _IF1632_Saved32_ss,%ss - movl _IF1632_Saved32_esp,%esp - movl _IF1632_Saved32_ebp,%ebp + movw A(IF1632_Saved32_ss),%ss + movl A(IF1632_Saved32_esp),%esp + movl A(IF1632_Saved32_ebp),%ebp /* * Restore registers, but do not destroy return value. */ - popw _IF1632_Saved32_ss - popl _IF1632_Saved32_ebp - popl _IF1632_Saved32_esp + popw A(IF1632_Saved32_ss) + popl A(IF1632_Saved32_ebp) + popl A(IF1632_Saved32_esp) movl %eax,return_value popal movl return_value,%eax @@ -158,8 +163,8 @@ _CallToInit16: * 12 target ds */ .align 4 - .globl _CallTo16 -_CallTo16: + .globl A(CallTo16) +A(CallTo16): pushl %ebp movl %esp,%ebp @@ -174,17 +179,17 @@ _CallTo16: /* * Switch to 16-bit stack */ - pushl _IF1632_Saved32_esp - pushl _IF1632_Saved32_ebp - pushw _IF1632_Saved32_ss + pushl A(IF1632_Saved32_esp) + pushl A(IF1632_Saved32_ebp) + pushw A(IF1632_Saved32_ss) - movw %ss,_IF1632_Saved32_ss - movl %esp,_IF1632_Saved32_esp - movl %ebp,_IF1632_Saved32_ebp + movw %ss,A(IF1632_Saved32_ss) + movl %esp,A(IF1632_Saved32_esp) + movl %ebp,A(IF1632_Saved32_ebp) - movw _IF1632_Saved16_ss,%ss - movl _IF1632_Saved16_esp,%esp - movl _IF1632_Saved16_ebp,%ebp + movw A(IF1632_Saved16_ss),%ss + movl A(IF1632_Saved16_esp),%esp + movl A(IF1632_Saved16_ebp),%ebp /* * Call entry point @@ -213,17 +218,17 @@ _CallTo16: movw %ax,%gs popl %eax - movw %ss,_IF1632_Saved16_ss - movl %esp,_IF1632_Saved16_esp - movl %ebp,_IF1632_Saved16_ebp + movw %ss,A(IF1632_Saved16_ss) + movl %esp,A(IF1632_Saved16_esp) + movl %ebp,A(IF1632_Saved16_ebp) - movw _IF1632_Saved32_ss,%ss - movl _IF1632_Saved32_esp,%esp - movl _IF1632_Saved32_ebp,%ebp + movw A(IF1632_Saved32_ss),%ss + movl A(IF1632_Saved32_esp),%esp + movl A(IF1632_Saved32_ebp),%ebp - popw _IF1632_Saved32_ss - popl _IF1632_Saved32_ebp - popl _IF1632_Saved32_esp + popw A(IF1632_Saved32_ss) + popl A(IF1632_Saved32_ebp) + popl A(IF1632_Saved32_esp) movl %eax,return_value movw return_value+2,%dx @@ -246,8 +251,8 @@ _CallTo16: * 16-bit stack. */ .align 4 - .globl _CallTo32 -_CallTo32: + .globl A(CallTo32) +A(CallTo32): pushl %ebp movl %esp,%ebp @@ -270,26 +275,26 @@ _CallTo32: * Save old stack save variables, save stack registers, reload * stack registers. */ - pushl _IF1632_Saved16_esp - pushl _IF1632_Saved16_ebp - pushw _IF1632_Saved16_ss + pushl A(IF1632_Saved16_esp) + pushl A(IF1632_Saved16_ebp) + pushw A(IF1632_Saved16_ss) - movw %ss,_IF1632_Saved16_ss - movl %esp,_IF1632_Saved16_esp - movl %ebp,_IF1632_Saved16_ebp + movw %ss,A(IF1632_Saved16_ss) + movl %esp,A(IF1632_Saved16_esp) + movl %ebp,A(IF1632_Saved16_ebp) - movw _IF1632_Saved32_ss,%ss - movl _IF1632_Saved32_esp,%esp - movl _IF1632_Saved32_ebp,%ebp + movw A(IF1632_Saved32_ss),%ss + movl A(IF1632_Saved32_esp),%esp + movl A(IF1632_Saved32_ebp),%ebp /* * Call entry point */ pushl %edx - pushw _IF1632_Saved16_ss - pushw _IF1632_Saved16_esp + pushw A(IF1632_Saved16_ss) + pushw A(IF1632_Saved16_esp) pushl %eax - call _DLLRelay + call A(DLLRelay) popl %edx popl %edx @@ -298,13 +303,13 @@ _CallTo32: /* * Restore registers, but do not destroy return value. */ - movw _IF1632_Saved16_ss,%ss - movl _IF1632_Saved16_esp,%esp - movl _IF1632_Saved16_ebp,%ebp + movw A(IF1632_Saved16_ss),%ss + movl A(IF1632_Saved16_esp),%esp + movl A(IF1632_Saved16_ebp),%ebp - popw _IF1632_Saved16_ss - popl _IF1632_Saved16_ebp - popl _IF1632_Saved16_esp + popw A(IF1632_Saved16_ss) + popl A(IF1632_Saved16_ebp) + popl A(IF1632_Saved16_esp) popw %es popw %ds @@ -348,8 +353,8 @@ noargs: * word of EAX won't be moved to DX. */ .align 4 - .globl _CallTo32_16 -_CallTo32_16: + .globl A(CallTo32_16) +A(CallTo32_16): pushl %ebp movl %esp,%ebp @@ -372,26 +377,26 @@ _CallTo32_16: * Save old stack save variables, save stack registers, reload * stack registers. */ - pushl _IF1632_Saved16_esp - pushl _IF1632_Saved16_ebp - pushw _IF1632_Saved16_ss + pushl A(IF1632_Saved16_esp) + pushl A(IF1632_Saved16_ebp) + pushw A(IF1632_Saved16_ss) - movw %ss,_IF1632_Saved16_ss - movl %esp,_IF1632_Saved16_esp - movl %ebp,_IF1632_Saved16_ebp + movw %ss,A(IF1632_Saved16_ss) + movl %esp,A(IF1632_Saved16_esp) + movl %ebp,A(IF1632_Saved16_ebp) - movw _IF1632_Saved32_ss,%ss - movl _IF1632_Saved32_esp,%esp - movl _IF1632_Saved32_ebp,%ebp + movw A(IF1632_Saved32_ss),%ss + movl A(IF1632_Saved32_esp),%esp + movl A(IF1632_Saved32_ebp),%ebp /* * Call entry point */ pushl %edx - pushw _IF1632_Saved16_ss - pushw _IF1632_Saved16_esp + pushw A(IF1632_Saved16_ss) + pushw A(IF1632_Saved16_esp) pushl %eax - call _DLLRelay + call A(DLLRelay) popl %edx popl %edx @@ -400,13 +405,13 @@ _CallTo32_16: /* * Restore registers, but do not destroy return value. */ - movw _IF1632_Saved16_ss,%ss - movl _IF1632_Saved16_esp,%esp - movl _IF1632_Saved16_ebp,%ebp + movw A(IF1632_Saved16_ss),%ss + movl A(IF1632_Saved16_esp),%esp + movl A(IF1632_Saved16_ebp),%ebp - popw _IF1632_Saved16_ss - popl _IF1632_Saved16_ebp - popl _IF1632_Saved16_esp + popw A(IF1632_Saved16_ss) + popl A(IF1632_Saved16_ebp) + popl A(IF1632_Saved16_esp) popw %es popw %ds @@ -437,18 +442,18 @@ noargs2: /********************************************************************** * ReturnFromRegisterFunc() */ - .globl _ReturnFromRegisterFunc -_ReturnFromRegisterFunc: + .globl A(ReturnFromRegisterFunc) +A(ReturnFromRegisterFunc): /* * Restore 16-bit stack */ - movw _IF1632_Saved16_ss,%ss - movl _IF1632_Saved16_esp,%esp - movl _IF1632_Saved16_ebp,%ebp + movw A(IF1632_Saved16_ss),%ss + movl A(IF1632_Saved16_esp),%esp + movl A(IF1632_Saved16_ebp),%ebp - popw _IF1632_Saved16_ss - popl _IF1632_Saved16_ebp - popl _IF1632_Saved16_esp + popw A(IF1632_Saved16_ss) + popl A(IF1632_Saved16_ebp) + popl A(IF1632_Saved16_esp) popw %es popw %ds diff --git a/if1632/callback.c b/if1632/callback.c index 3d69c34652f..6f27756961f 100644 --- a/if1632/callback.c +++ b/if1632/callback.c @@ -10,6 +10,12 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; #include "segmem.h" #include #include "dlls.h" +#include "stddebug.h" +/* #define DEBUG_CALLBACK */ +/* #undef DEBUG_CALLBACK */ +#include "debug.h" + + extern SEGDESC Segments[]; extern unsigned short IF1632_Saved16_ss; extern unsigned long IF1632_Saved16_ebp; @@ -99,8 +105,6 @@ CallBack16(void *func, int n_args, ...) void * CALLBACK_MakeProcInstance(void *func, int instance) { - int handle; - void *new_func; struct thunk_s *tp; int i; @@ -129,8 +133,6 @@ CALLBACK_MakeProcInstance(void *func, int instance) */ void FreeProcInstance(FARPROC func) { - int handle; - void *new_func; struct thunk_s *tp; int i; @@ -155,7 +157,7 @@ HANDLE GetCodeHandle( FARPROC proc ) /* Return the code segment containing 'proc'. */ /* Not sure if this is really correct (shouldn't matter that much). */ printf( "STUB: GetCodeHandle(%p) returning %x\n", - tp->thunk[8] + (tp->thunk[9] << 8) ); + proc, tp->thunk[8] + (tp->thunk[9] << 8) ); return tp->thunk[8] + (tp->thunk[9] << 8); } @@ -197,9 +199,7 @@ LONG CallWindowProc( WNDPROC func, HWND hwnd, WORD message, } else if (Is16bitAddress(func)) { -#ifdef DEBUG_CALLBACK - printf("CallWindowProc // 16bit func=%08X !\n", func); -#endif + dprintf_callback(stddeb, "CallWindowProc // 16bit func=%p !\n", func); PushOn16( CALLBACK_SIZE_WORD, hwnd ); PushOn16( CALLBACK_SIZE_WORD, message ); PushOn16( CALLBACK_SIZE_WORD, wParam ); @@ -209,9 +209,7 @@ LONG CallWindowProc( WNDPROC func, HWND hwnd, WORD message, } else { -#ifdef DEBUG_CALLBACK - printf("CallWindowProc // 32bit func=%08X !\n", func); -#endif + dprintf_callback(stddeb, "CallWindowProc // 32bit func=%08X !\n", func); return (*func)(hwnd, message, wParam, lParam); } } @@ -325,15 +323,12 @@ int Catch (LPCATCHBUF cbuf) (IF1632_Saved16_esp & 0xffff)); memcpy (stack16, sb -> stack_part, STACK_DEPTH_16); -#ifdef DEBUG_CATCH - printf ("Been thrown here: %d, retval = %d\n", sb, retval); -#endif + dprintf_catch (stddeb, "Been thrown here: %d, retval = %d\n", + sb, retval); free ((void *) sb); return (retval); } else { -#ifdef DEBUG_CATCH - printf ("Will somtime get thrown here: %d\n", sb); -#endif + dprintf_catch (stddeb, "Will somtime get thrown here: %d\n", sb); return (retval); } } @@ -341,9 +336,7 @@ int Catch (LPCATCHBUF cbuf) void Throw (LPCATCHBUF cbuf, int val) { sb = *((struct special_buffer **)cbuf); -#ifdef DEBUG_CATCH - printf ("Throwing to: %d\n", sb); -#endif + dprintf_catch (stddeb, "Throwing to: %d\n", sb); longjmp (sb -> buffer, val); } #endif /* !WINELIB */ diff --git a/if1632/commdlg.spec b/if1632/commdlg.spec new file mode 100644 index 00000000000..c52227b645b --- /dev/null +++ b/if1632/commdlg.spec @@ -0,0 +1,32 @@ +# $Id: commdlg.spec,v 1.3 1994/20/08 04:04:21 root Exp root $ +# +name commdlg +id 15 +length 31 + + 1 pascal GETOPENFILENAME(ptr) GetOpenFileName(1) + 2 pascal GETSAVEFILENAME(ptr) GetSaveFileName(1) + 5 pascal CHOOSECOLOR(ptr) ChooseColor(1) + 6 pascal FILEOPENDLGPROC(word word word long) FileOpenDlgProc(1 2 3 4) + 7 pascal FILESAVEDLGPROC(word word word long) FileSaveDlgProc(1 2 3 4) + 8 pascal COLORDLGPROC(word word word long) ColorDlgProc(1 2 3 4) +# 9 pascal LOADALTERBITMAP exported, shared data + 11 pascal FINDTEXT(ptr) FindText(1) + 12 pascal REPLACETEXT(ptr) ReplaceText(1) + 13 pascal FINDTEXTDLGPROC(word word word long) FindTextDlgProc(1 2 3 4) + 14 pascal REPLACETEXTDLGPROC(word word word long) ReplaceTextDlgProc(1 2 3 4) +# 15 pascal CHOOSEFONT exported, shared data +# 16 pascal FORMATCHARDLGPROC exported, shared data +# 18 pascal FONTSTYLEENUMPROC exported, shared data +# 19 pascal FONTFAMILYENUMPROC exported, shared data + 20 pascal PRINTDLG(ptr) PrintDlg(1) + 21 pascal PRINTDLGPROC(word word word long) PrintDlgProc(1 2 3 4) + 22 pascal PRINTSETUPDLGPROC(word word word long) PrintSetupDlgProc(1 2 3 4) +# 23 pascal EDITINTEGERONLY exported, shared data +# 25 pascal WANTARROWS exported, shared data + 26 pascal COMMDLGEXTENDEDERROR() CommDlgExtendError() + 27 pascal GETFILETITLE(ptr ptr word) GetFileTitle(1 2 3) +# 28 pascal WEP exported, shared data +# 29 pascal DWLBSUBCLASS exported, shared data +# 30 pascal DWUPARROWHACK exported, shared data +# 31 pascal DWOKSUBCLASS exported, shared data diff --git a/if1632/kernel.spec b/if1632/kernel.spec index f3930a5b29e..e2655671cb8 100644 --- a/if1632/kernel.spec +++ b/if1632/kernel.spec @@ -221,10 +221,10 @@ length 415 #328 _DEBUGOUTPUT #329 K329 #332 THHOOK -#334 ISBADREADPTR -#335 ISBADWRITEPTR -#336 ISBADCODEPTR -#337 ISBADSTRINGPTR +334 pascal IsBadReadPtr(ptr long) IsBadReadPtr(1 2) +335 pascal IsBadWritePtr(ptr long) IsBadWritePtr(1 2) +336 pascal IsBadCodePtr(ptr) IsBadCodePtr(1) +337 pascal IsBadStringPtr(ptr word) IsBadStringPtr(1 2) #338 HASGPHANDLER #339 DIAGQUERY #340 DIAGOUTPUT @@ -233,8 +233,8 @@ length 415 #343 REGISTERWINOLDAPHOOK #344 GETWINOLDAPHOOKS #345 ISSHAREDSELECTOR -#346 ISBADHUGEREADPTR -#347 ISBADHUGEWRITEPTR +346 pascal IsBadHugeReadPtr(ptr long) IsBadHugeReadPtr(1 2) +347 pascal IsBadHugeWritePtr(ptr long) IsBadHugeWritePtr(1 2) 348 pascal hmemcpy(ptr ptr long) hmemcpy(1 2 3) 349 pascal16 _hread(word ptr long) _hread(1 2 3) 350 pascal16 _hwrite(word ptr long) _hwrite(1 2 3) diff --git a/if1632/mmsystem.spec b/if1632/mmsystem.spec index d599d196c4e..d074caec4de 100644 --- a/if1632/mmsystem.spec +++ b/if1632/mmsystem.spec @@ -34,6 +34,7 @@ length 1226 211 pascal MIDIOUTGETVOLUME(word ptr) midiOutGetVolume(1 2) 212 pascal MIDIOUTSETVOLUME(word long) midiOutSetVolume(1 2) 215 pascal MIDIOUTGETID(word ptr) midiOutGetID(1 2) +216 pascal MIDIOUTMESSAGE(word word long long) midiOutMessage(1 2 3 4) 301 pascal MIDIINGETNUMDEVS() midiInGetNumDevs() 302 pascal MIDIINGETDEVCAPS(word ptr word) midiInGetDevCaps(1 2 3) 303 pascal MIDIINGETERRORTEXT(word ptr word) midiInGetErrorText(1 2 3) @@ -45,10 +46,12 @@ length 1226 310 pascal MIDIINSTOP(word) midiInStop(1) 311 pascal MIDIINRESET(word) midiInReset(1) 312 pascal MIDIINGETID(word ptr) midiInGetID(1 2) +313 pascal MIDIINMESSAGE(word word long long) midiInMessage(1 2 3 4) 350 pascal AUXGETNUMDEVS() auxGetNumDevs() 351 pascal AUXGETDEVCAPS(word ptr word) auxGetDevCaps(1 2 3) 352 pascal AUXGETVOLUME(word ptr) auxGetVolume(1 2) 353 pascal AUXSETVOLUME(word long) auxSetVolume(1 2) +354 pascal AUXOUTMESSAGE(word word long long) auxOutMessage(1 2 3 4) 401 pascal WAVEOUTGETNUMDEVS() waveOutGetNumDevs() 402 pascal WAVEOUTGETDEVCAPS(word ptr word) waveOutGetDevCaps(1 2 3) 403 pascal WAVEOUTGETERRORTEXT(word ptr word) waveOutGetErrorText(1 2 3) @@ -69,6 +72,7 @@ length 1226 418 pascal WAVEOUTSETPLAYBACKRATE(word long) waveOutSetPlaybackRate(1 2) 419 pascal WAVEOUTBREAKLOOP(word) waveOutBreakLoop(1) 420 pascal WAVEOUTGETID(word ptr) waveOutGetID(1 2) +421 pascal WAVEOUTMESSAGE(word word long long) waveOutMessage(1 2 3 4) 501 pascal WAVEINGETNUMDEVS() waveInGetNumDevs() 502 pascal WAVEINGETDEVCAPS(word ptr word) waveInGetDevCaps(1 2 3) 503 pascal WAVEINGETERRORTEXT(word ptr word) waveInGetErrorText(1 2 3) @@ -82,6 +86,7 @@ length 1226 511 pascal WAVEINRESET(word) waveInReset(1) 512 pascal WAVEINGETPOSITION(word ptr word) waveInGetPosition(1 2 3) 513 pascal WAVEINGETID(word ptr) waveInGetID(1 2) +514 pascal WAVEINMESSAGE(word word long long) waveInMessage(1 2 3 4) 601 pascal timeGetSystemTime(ptr word) timeGetSystemTime(1 2) 602 pascal timeSetEvent(word word ptr long word) timeSetEvent(1 2 3 4 5) 603 pascal timeKillEvent(word) timeKillEvent(1) diff --git a/if1632/relay.c b/if1632/relay.c index 9bf9682fd56..d9d9994bdad 100644 --- a/if1632/relay.c +++ b/if1632/relay.c @@ -46,6 +46,7 @@ struct dll_name_table_entry_s dll_builtin_table[N_BUILTINS] = { "SYSTEM", WineLibSkip(SYSTEM_table), 20 ,12}, { "TOOLHELP",WineLibSkip(TOOLHELP_table), 83, 13}, { "MOUSE", WineLibSkip(MOUSE_table), 8, 14}, + { "EMUCOMMDLG", WineLibSkip(COMMDLG_table), 31, 15}, }; /* don't forget to increase N_BUILTINS in dll.h if you add a dll */ diff --git a/if1632/user.spec b/if1632/user.spec index 673bbc3ec16..3e7af173a7e 100644 --- a/if1632/user.spec +++ b/if1632/user.spec @@ -172,7 +172,7 @@ length 540 167 pascal ShowCaret(word) ShowCaret(1) 168 pascal SetCaretBlinkTime(word) SetCaretBlinkTime(1) 169 pascal GetCaretBlinkTime() GetCaretBlinkTime() -#170 ARRANGEICONICWINDOWS +170 pascal ArrangeIconicWindows(word) ArrangeIconicWindows(1) 171 pascal WinHelp(word ptr word long) WinHelp(1 2 3 4) #172 SWITCHTOTHISWINDOW 173 pascal LoadCursor(word ptr) LoadCursor(1 2) @@ -203,8 +203,8 @@ length 540 TabbedTextOut(1 2 3 4 5 6 7 8) 197 pascal GETTABBEDTEXTEXTENT(word ptr word word ptr) GetTabbedTextExtent(1 2 3 4 5) -#198 CASCADECHILDWINDOWS -#199 TILECHILDWINDOWS +198 pascal CascadeChildWindows(word word) CascadeChildWindows(1 2) +199 pascal TileChildWindows(word word) TileChildWindows(1 2) 200 pascal OpenComm(ptr word word) OpenComm(1 2 3) 201 pascal SetCommState(ptr) SetCommState(1) 202 pascal GetCommState(word ptr) GetCommState(1 2) @@ -299,7 +299,7 @@ length 540 284 pascal16 GetFreeSystemResources(word) GetFreeSystemResources(1) #285 BEAR285 286 pascal GetDesktopWindow() GetDesktopWindow() -#287 GETLASTACTIVEPOPUP +287 pascal GetLastActivePopup(word) GetLastActivePopup(1) 288 pascal GetMessageExtraInfo() GetMessageExtraInfo() #289 KEYB_EVENT 290 pascal RedrawWindow(word ptr word word) RedrawWindow(1 2 3 4) diff --git a/include/combo.h b/include/combo.h index 01626648f34..4b0d4449f52 100644 --- a/include/combo.h +++ b/include/combo.h @@ -8,6 +8,9 @@ typedef struct tagHEADCOMBO { DWORD dwState; HWND hWndEdit; HWND hWndLBox; + short LastSel; + RECT RectEdit; + BOOL bRedrawFlag; } HEADCOMBO; typedef HEADCOMBO FAR* LPHEADCOMBO; diff --git a/include/comm.h b/include/comm.h index 7f746857332..785a7b71eaa 100644 --- a/include/comm.h +++ b/include/comm.h @@ -16,6 +16,7 @@ struct DosDeviceStruct { int suspended; int unget; int unget_byte; + int baudrate; }; #endif /* COMM_H */ diff --git a/include/commdlg.h b/include/commdlg.h new file mode 100644 index 00000000000..737e6e0c471 --- /dev/null +++ b/include/commdlg.h @@ -0,0 +1,298 @@ +/* + * COMMDLG - Common Wine Dialog ... :-) + */ + +#ifndef COMMDLG_H +#define COMMDLG_H + +#define RT_CURSOR MAKEINTRESOURCE(1) +#define RT_BITMAP MAKEINTRESOURCE(2) +#define RT_ICON MAKEINTRESOURCE(3) +#define RT_MENU MAKEINTRESOURCE(4) +#define RT_DIALOG MAKEINTRESOURCE(5) +#define RT_STRING MAKEINTRESOURCE(6) +#define RT_FONTDIR MAKEINTRESOURCE(7) +#define RT_FONT MAKEINTRESOURCE(8) +#define RT_ACCELERATOR MAKEINTRESOURCE(9) +#define RT_RCDATA MAKEINTRESOURCE(10) + +#define RT_GROUP_CURSOR MAKEINTRESOURCE(12) +#define RT_GROUP_ICON MAKEINTRESOURCE(14) + +#ifndef HGLOBAL +#define HGLOBAL HANDLE +#endif + +#define OFN_READONLY 0x00000001 +#define OFN_OVERWRITEPROMPT 0x00000002 +#define OFN_HIDEREADONLY 0x00000004 +#define OFN_NOCHANGEDIR 0x00000008 +#define OFN_SHOWHELP 0x00000010 +#define OFN_ENABLEHOOK 0x00000020 +#define OFN_ENABLETEMPLATE 0x00000040 +#define OFN_ENABLETEMPLATEHANDLE 0x00000080 +#define OFN_NOVALIDATE 0x00000100 +#define OFN_ALLOWMULTISELECT 0x00000200 +#define OFN_EXTENSIONDIFFERENT 0x00000400 +#define OFN_PATHMUSTEXIST 0x00000800 +#define OFN_FILEMUSTEXIST 0x00001000 +#define OFN_CREATEPROMPT 0x00002000 +#define OFN_SHAREAWARE 0x00004000 +#define OFN_NOREADONLYRETURN 0x00008000 +#define OFN_NOTESTFILECREATE 0x00010000 + +#define OFN_SHAREFALLTHROUGH 2 +#define OFN_SHARENOWARN 1 +#define OFN_SHAREWARN 0 + + +typedef struct { + DWORD lStructSize; + HWND hwndOwner; + HINSTANCE hInstance; + LPCSTR lpstrFilter; + LPSTR lpstrCustomFilter; + DWORD nMaxCustFilter; + DWORD nFilterIndex; + LPSTR lpstrFile; + DWORD nMaxFile; + LPSTR lpstrFileTitle; + DWORD nMaxFileTitle; + LPCSTR lpstrInitialDir; + LPCSTR lpstrTitle; + DWORD Flags; + UINT nFileOffset; + UINT nFileExtension; + LPCSTR lpstrDefExt; + LPARAM lCustData; + UINT (CALLBACK *lpfnHook)(HWND, UINT, WPARAM, LPARAM); + LPCSTR lpTemplateName; + } OPENFILENAME; +typedef OPENFILENAME * LPOPENFILENAME; + + +typedef struct { + DWORD lStructSize; + HWND hwndOwner; + HWND hInstance; + COLORREF rgbResult; + COLORREF FAR* lpCustColors; + DWORD Flags; + LPARAM lCustData; + UINT (CALLBACK* lpfnHook)(HWND, UINT, WPARAM, LPARAM); + LPCSTR lpTemplateName; + } CHOOSECOLOR; +typedef CHOOSECOLOR *LPCHOOSECOLOR; + +#define CC_RGBINIT 0x00000001 +#define CC_FULLOPEN 0x00000002 +#define CC_PREVENTFULLOPEN 0x00000004 +#define CC_SHOWHELP 0x00000008 +#define CC_ENABLEHOOK 0x00000010 +#define CC_ENABLETEMPLATE 0x00000020 +#define CC_ENABLETEMPLATEHANDLE 0x00000040 + +typedef struct { + DWORD lStructSize; /* size of this struct 0x20 */ + HWND hwndOwner; /* handle to owner's window */ + HINSTANCE hInstance; /* instance handle of.EXE that */ + /* contains cust. dlg. template */ + DWORD Flags; /* one or more of the FR_?? */ + LPSTR lpstrFindWhat; /* ptr. to search string */ + LPSTR lpstrReplaceWith; /* ptr. to replace string */ + UINT wFindWhatLen; /* size of find buffer */ + UINT wReplaceWithLen; /* size of replace buffer */ + LPARAM lCustData; /* data passed to hook fn. */ + UINT (CALLBACK* lpfnHook)(HWND, UINT, WPARAM, LPARAM); + LPCSTR lpTemplateName; /* custom template name */ + } FINDREPLACE; +typedef FINDREPLACE *LPFINDREPLACE; + +#define FR_DOWN 0x00000001 +#define FR_WHOLEWORD 0x00000002 +#define FR_MATCHCASE 0x00000004 +#define FR_FINDNEXT 0x00000008 +#define FR_REPLACE 0x00000010 +#define FR_REPLACEALL 0x00000020 +#define FR_DIALOGTERM 0x00000040 +#define FR_SHOWHELP 0x00000080 +#define FR_ENABLEHOOK 0x00000100 +#define FR_ENABLETEMPLATE 0x00000200 +#define FR_NOUPDOWN 0x00000400 +#define FR_NOMATCHCASE 0x00000800 +#define FR_NOWHOLEWORD 0x00001000 +#define FR_ENABLETEMPLATEHANDLE 0x00002000 +#define FR_HIDEUPDOWN 0x00004000 +#define FR_HIDEMATCHCASE 0x00008000 +#define FR_HIDEWHOLEWORD 0x00010000 + + +typedef struct { + DWORD lStructSize; + HWND hwndOwner; /* caller's window handle */ + HDC hDC; /* printer DC/IC or NULL */ + LOGFONT FAR* lpLogFont; /* ptr. to a LOGFONT struct */ + short iPointSize; /* 10 * size in points of selected font */ + DWORD Flags; /* enum. type flags */ + COLORREF rgbColors; /* returned text color */ + LPARAM lCustData; /* data passed to hook fn. */ + UINT (CALLBACK* lpfnHook)(HWND, UINT, WPARAM, LPARAM); + LPCSTR lpTemplateName; /* custom template name */ + HINSTANCE hInstance; /* instance handle of.EXE that */ + /* contains cust. dlg. template */ + LPSTR lpszStyle; /* return the style field here */ + /* must be LF_FACESIZE or bigger */ + UINT nFontType; /* same value reported to the */ + /* EnumFonts callback with the */ + /* extra FONTTYPE_ bits added */ + short nSizeMin; /* minimum pt size allowed & */ + short nSizeMax; /* max pt size allowed if */ + /* CF_LIMITSIZE is used */ + } CHOOSEFONT; +typedef CHOOSEFONT *LPCHOOSEFONT; + + +#define CF_SCREENFONTS 0x00000001 +#define CF_PRINTERFONTS 0x00000002 +#define CF_BOTH (CF_SCREENFONTS | CF_PRINTERFONTS) +#define CF_SHOWHELP 0x00000004L +#define CF_ENABLEHOOK 0x00000008L +#define CF_ENABLETEMPLATE 0x00000010L +#define CF_ENABLETEMPLATEHANDLE 0x00000020L +#define CF_INITTOLOGFONTSTRUCT 0x00000040L +#define CF_USESTYLE 0x00000080L +#define CF_EFFECTS 0x00000100L +#define CF_APPLY 0x00000200L +#define CF_ANSIONLY 0x00000400L +#define CF_NOVECTORFONTS 0x00000800L +#define CF_NOOEMFONTS CF_NOVECTORFONTS +#define CF_NOSIMULATIONS 0x00001000L +#define CF_LIMITSIZE 0x00002000L +#define CF_FIXEDPITCHONLY 0x00004000L +#define CF_WYSIWYG 0x00008000L /* use with CF_SCREENFONTS & CF_PRINTERFONTS */ +#define CF_FORCEFONTEXIST 0x00010000L +#define CF_SCALABLEONLY 0x00020000L +#define CF_TTONLY 0x00040000L +#define CF_NOFACESEL 0x00080000L +#define CF_NOSTYLESEL 0x00100000L +#define CF_NOSIZESEL 0x00200000L + +#define SIMULATED_FONTTYPE 0x8000 +#define PRINTER_FONTTYPE 0x4000 +#define SCREEN_FONTTYPE 0x2000 +#define BOLD_FONTTYPE 0x0100 +#define ITALIC_FONTTYPE 0x0200 +#define REGULAR_FONTTYPE 0x0400 + +#define WM_CHOOSEFONT_GETLOGFONT (WM_USER + 1) + +#define LBSELCHSTRING "commdlg_LBSelChangedNotify" +#define SHAREVISTRING "commdlg_ShareViolation" +#define FILEOKSTRING "commdlg_FileNameOK" +#define COLOROKSTRING "commdlg_ColorOK" +#define SETRGBSTRING "commdlg_SetRGBColor" +#define FINDMSGSTRING "commdlg_FindReplace" +#define HELPMSGSTRING "commdlg_help" + +#define CD_LBSELNOITEMS -1 +#define CD_LBSELCHANGE 0 +#define CD_LBSELSUB 1 +#define CD_LBSELADD 2 + +typedef struct { + DWORD lStructSize; + HWND hwndOwner; + HGLOBAL hDevMode; + HGLOBAL hDevNames; + HDC hDC; + DWORD Flags; + UINT nFromPage; + UINT nToPage; + UINT nMinPage; + UINT nMaxPage; + UINT nCopies; + HINSTANCE hInstance; + LPARAM lCustData; + UINT (CALLBACK* lpfnPrintHook)(HWND, UINT, WPARAM, LPARAM); + UINT (CALLBACK* lpfnSetupHook)(HWND, UINT, WPARAM, LPARAM); + LPCSTR lpPrintTemplateName; + LPCSTR lpSetupTemplateName; + HGLOBAL hPrintTemplate; + HGLOBAL hSetupTemplate; + } PRINTDLG; +typedef PRINTDLG * LPPRINTDLG; + + +#define PD_ALLPAGES 0x00000000 +#define PD_SELECTION 0x00000001 +#define PD_PAGENUMS 0x00000002 +#define PD_NOSELECTION 0x00000004 +#define PD_NOPAGENUMS 0x00000008 +#define PD_COLLATE 0x00000010 +#define PD_PRINTTOFILE 0x00000020 +#define PD_PRINTSETUP 0x00000040 +#define PD_NOWARNING 0x00000080 +#define PD_RETURNDC 0x00000100 +#define PD_RETURNIC 0x00000200 +#define PD_RETURNDEFAULT 0x00000400 +#define PD_SHOWHELP 0x00000800 +#define PD_ENABLEPRINTHOOK 0x00001000 +#define PD_ENABLESETUPHOOK 0x00002000 +#define PD_ENABLEPRINTTEMPLATE 0x00004000 +#define PD_ENABLESETUPTEMPLATE 0x00008000 +#define PD_ENABLEPRINTTEMPLATEHANDLE 0x00010000 +#define PD_ENABLESETUPTEMPLATEHANDLE 0x00020000 +#define PD_USEDEVMODECOPIES 0x00040000 +#define PD_DISABLEPRINTTOFILE 0x00080000 +#define PD_HIDEPRINTTOFILE 0x00100000 + +typedef struct { + UINT wDriverOffset; + UINT wDeviceOffset; + UINT wOutputOffset; + UINT wDefault; + } DEVNAMES; +typedef DEVNAMES * LPDEVNAMES; + +#define DN_DEFAULTPRN 0x0001 + + +#define CDERR_DIALOGFAILURE 0xFFFF +#define CDERR_GENERALCODES 0x0000 +#define CDERR_STRUCTSIZE 0x0001 +#define CDERR_INITIALIZATION 0x0002 +#define CDERR_NOTEMPLATE 0x0003 +#define CDERR_NOHINSTANCE 0x0004 +#define CDERR_LOADSTRFAILURE 0x0005 +#define CDERR_FINDRESFAILURE 0x0006 +#define CDERR_LOADRESFAILURE 0x0007 +#define CDERR_LOCKRESFAILURE 0x0008 +#define CDERR_MEMALLOCFAILURE 0x0009 +#define CDERR_MEMLOCKFAILURE 0x000A +#define CDERR_NOHOOK 0x000B +#define CDERR_REGISTERMSGFAIL 0x000C + +/************************************************************************ +* COMMDLG Resources placed in Wine SYSRES.DLL * +************************************************************************/ + +#define OBM_FOLDER 32520 +#define OBM_FOLDER2 32521 +#define OBM_FLOPPY 32522 +#define OBM_HDISK 32523 +#define OBM_CDROM 32524 + +#define OPENFILEDLG 3 +#define SAVEFILEDLG 4 +#define PRINTDLG 5 +#define PRINTSETUPDLG 6 +#define FONTDLG 7 +#define COLORDLG 8 +#define FINDDLG 9 +#define REPLACEDLG 10 + + + +#endif /* #ifdef COMMDLG_H */ + + diff --git a/include/debug.h b/include/debug.h index ab069232efc..eb60565f671 100644 --- a/include/debug.h +++ b/include/debug.h @@ -9,7 +9,9 @@ #ifdef DEBUG_NONE_EXT #undef DEBUG_ACCEL #undef DEBUG_BITMAP +#undef DEBUG_CALLBACK #undef DEBUG_CARET +#undef DEBUG_CATCH #undef DEBUG_CDAUDIO #undef DEBUG_CLASS #undef DEBUG_CLIPBOARD @@ -33,36 +35,51 @@ #undef DEBUG_GRAPHICS #undef DEBUG_HEAP #undef DEBUG_ICON +#undef DEBUG_IF #undef DEBUG_INT #undef DEBUG_KEY #undef DEBUG_KEYBOARD #undef DEBUG_LDT #undef DEBUG_LISTBOX +#undef DEBUG_MCI +#undef DEBUG_MCIANIM #undef DEBUG_MCIWAVE #undef DEBUG_MDI #undef DEBUG_MENU #undef DEBUG_MENUCALC #undef DEBUG_MESSAGE #undef DEBUG_METAFILE +#undef DEBUG_MMIO +#undef DEBUG_MMTIME #undef DEBUG_MODULE #undef DEBUG_MSG +#undef DEBUG_MSGBOX #undef DEBUG_NONCLIENT #undef DEBUG_PALETTE +#undef DEBUG_PROFILE +#undef DEBUG_PROP +#undef DEBUG_REG #undef DEBUG_REGION #undef DEBUG_RESOURCE #undef DEBUG_SCROLL +#undef DEBUG_SELECTORS +#undef DEBUG_STRESS #undef DEBUG_SYSCOLOR +#undef DEBUG_TASK #undef DEBUG_TEXT #undef DEBUG_TIMER #undef DEBUG_UTILITY #undef DEBUG_WIN +#undef DEBUG_WINSOCK #endif #ifdef DEBUG_ALL_EXT #define DEBUG_ACCEL #define DEBUG_BITMAP +#define DEBUG_CALLBACK #define DEBUG_CARET +#define DEBUG_CATCH #define DEBUG_CDAUDIO #define DEBUG_CLASS #define DEBUG_CLIPBOARD @@ -86,29 +103,42 @@ #define DEBUG_GRAPHICS #define DEBUG_HEAP #define DEBUG_ICON +#define DEBUG_IF #define DEBUG_INT #define DEBUG_KEY #define DEBUG_KEYBOARD #define DEBUG_LDT #define DEBUG_LISTBOX +#define DEBUG_MCI +#define DEBUG_MCIANIM #define DEBUG_MCIWAVE #define DEBUG_MDI #define DEBUG_MENU #define DEBUG_MENUCALC #define DEBUG_MESSAGE #define DEBUG_METAFILE +#define DEBUG_MMIO +#define DEBUG_MMTIME #define DEBUG_MODULE #define DEBUG_MSG +#define DEBUG_MSGBOX #define DEBUG_NONCLIENT #define DEBUG_PALETTE +#define DEBUG_PROFILE +#define DEBUG_PROP +#define DEBUG_REG #define DEBUG_REGION #define DEBUG_RESOURCE #define DEBUG_SCROLL +#define DEBUG_SELECTORS +#define DEBUG_STRESS #define DEBUG_SYSCOLOR +#define DEBUG_TASK #define DEBUG_TEXT #define DEBUG_TIMER #define DEBUG_UTILITY #define DEBUG_WIN +#define DEBUG_WINSOCK #endif @@ -125,11 +155,21 @@ short debug_msg_enabled[]={ #else 0, #endif +#ifdef DEBUG_CALLBACK +1, +#else +0, +#endif #ifdef DEBUG_CARET 1, #else 0, #endif +#ifdef DEBUG_CATCH +1, +#else +0, +#endif #ifdef DEBUG_CDAUDIO 1, #else @@ -245,6 +285,11 @@ short debug_msg_enabled[]={ #else 0, #endif +#ifdef DEBUG_IF +1, +#else +0, +#endif #ifdef DEBUG_INT 1, #else @@ -270,6 +315,16 @@ short debug_msg_enabled[]={ #else 0, #endif +#ifdef DEBUG_MCI +1, +#else +0, +#endif +#ifdef DEBUG_MCIANIM +1, +#else +0, +#endif #ifdef DEBUG_MCIWAVE 1, #else @@ -300,6 +355,16 @@ short debug_msg_enabled[]={ #else 0, #endif +#ifdef DEBUG_MMIO +1, +#else +0, +#endif +#ifdef DEBUG_MMTIME +1, +#else +0, +#endif #ifdef DEBUG_MODULE 1, #else @@ -310,6 +375,11 @@ short debug_msg_enabled[]={ #else 0, #endif +#ifdef DEBUG_MSGBOX +1, +#else +0, +#endif #ifdef DEBUG_NONCLIENT 1, #else @@ -320,6 +390,21 @@ short debug_msg_enabled[]={ #else 0, #endif +#ifdef DEBUG_PROFILE +1, +#else +0, +#endif +#ifdef DEBUG_PROP +1, +#else +0, +#endif +#ifdef DEBUG_REG +1, +#else +0, +#endif #ifdef DEBUG_REGION 1, #else @@ -335,11 +420,26 @@ short debug_msg_enabled[]={ #else 0, #endif +#ifdef DEBUG_SELECTORS +1, +#else +0, +#endif +#ifdef DEBUG_STRESS +1, +#else +0, +#endif #ifdef DEBUG_SYSCOLOR 1, #else 0, #endif +#ifdef DEBUG_TASK +1, +#else +0, +#endif #ifdef DEBUG_TEXT 1, #else @@ -360,6 +460,11 @@ short debug_msg_enabled[]={ #else 0, #endif +#ifdef DEBUG_WINSOCK +1, +#else +0, +#endif 0}; #else extern short debug_msg_enabled[]; @@ -388,7 +493,17 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_caret if(debug_msg_enabled[2]) fprintf +#define dprintf_callback if(debug_msg_enabled[2]) fprintf +#else +#ifdef DEBUG_CALLBACK +#define dprintf_callback fprintf +#else +#define dprintf_callback +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_caret if(debug_msg_enabled[3]) fprintf #else #ifdef DEBUG_CARET #define dprintf_caret fprintf @@ -398,7 +513,17 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_cdaudio if(debug_msg_enabled[3]) fprintf +#define dprintf_catch if(debug_msg_enabled[4]) fprintf +#else +#ifdef DEBUG_CATCH +#define dprintf_catch fprintf +#else +#define dprintf_catch +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_cdaudio if(debug_msg_enabled[5]) fprintf #else #ifdef DEBUG_CDAUDIO #define dprintf_cdaudio fprintf @@ -408,7 +533,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_class if(debug_msg_enabled[4]) fprintf +#define dprintf_class if(debug_msg_enabled[6]) fprintf #else #ifdef DEBUG_CLASS #define dprintf_class fprintf @@ -418,7 +543,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_clipboard if(debug_msg_enabled[5]) fprintf +#define dprintf_clipboard if(debug_msg_enabled[7]) fprintf #else #ifdef DEBUG_CLIPBOARD #define dprintf_clipboard fprintf @@ -428,7 +553,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_clipping if(debug_msg_enabled[6]) fprintf +#define dprintf_clipping if(debug_msg_enabled[8]) fprintf #else #ifdef DEBUG_CLIPPING #define dprintf_clipping fprintf @@ -438,7 +563,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_combo if(debug_msg_enabled[7]) fprintf +#define dprintf_combo if(debug_msg_enabled[9]) fprintf #else #ifdef DEBUG_COMBO #define dprintf_combo fprintf @@ -448,7 +573,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_comm if(debug_msg_enabled[8]) fprintf +#define dprintf_comm if(debug_msg_enabled[10]) fprintf #else #ifdef DEBUG_COMM #define dprintf_comm fprintf @@ -458,7 +583,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_cursor if(debug_msg_enabled[9]) fprintf +#define dprintf_cursor if(debug_msg_enabled[11]) fprintf #else #ifdef DEBUG_CURSOR #define dprintf_cursor fprintf @@ -468,7 +593,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_dc if(debug_msg_enabled[10]) fprintf +#define dprintf_dc if(debug_msg_enabled[12]) fprintf #else #ifdef DEBUG_DC #define dprintf_dc fprintf @@ -478,7 +603,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_dialog if(debug_msg_enabled[11]) fprintf +#define dprintf_dialog if(debug_msg_enabled[13]) fprintf #else #ifdef DEBUG_DIALOG #define dprintf_dialog fprintf @@ -488,7 +613,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_dll if(debug_msg_enabled[12]) fprintf +#define dprintf_dll if(debug_msg_enabled[14]) fprintf #else #ifdef DEBUG_DLL #define dprintf_dll fprintf @@ -498,7 +623,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_dosfs if(debug_msg_enabled[13]) fprintf +#define dprintf_dosfs if(debug_msg_enabled[15]) fprintf #else #ifdef DEBUG_DOSFS #define dprintf_dosfs fprintf @@ -508,7 +633,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_driver if(debug_msg_enabled[14]) fprintf +#define dprintf_driver if(debug_msg_enabled[16]) fprintf #else #ifdef DEBUG_DRIVER #define dprintf_driver fprintf @@ -518,7 +643,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_edit if(debug_msg_enabled[15]) fprintf +#define dprintf_edit if(debug_msg_enabled[17]) fprintf #else #ifdef DEBUG_EDIT #define dprintf_edit fprintf @@ -528,7 +653,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_enum if(debug_msg_enabled[16]) fprintf +#define dprintf_enum if(debug_msg_enabled[18]) fprintf #else #ifdef DEBUG_ENUM #define dprintf_enum fprintf @@ -538,7 +663,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_event if(debug_msg_enabled[17]) fprintf +#define dprintf_event if(debug_msg_enabled[19]) fprintf #else #ifdef DEBUG_EVENT #define dprintf_event fprintf @@ -548,7 +673,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_exec if(debug_msg_enabled[18]) fprintf +#define dprintf_exec if(debug_msg_enabled[20]) fprintf #else #ifdef DEBUG_EXEC #define dprintf_exec fprintf @@ -558,7 +683,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_file if(debug_msg_enabled[19]) fprintf +#define dprintf_file if(debug_msg_enabled[21]) fprintf #else #ifdef DEBUG_FILE #define dprintf_file fprintf @@ -568,7 +693,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_fixup if(debug_msg_enabled[20]) fprintf +#define dprintf_fixup if(debug_msg_enabled[22]) fprintf #else #ifdef DEBUG_FIXUP #define dprintf_fixup fprintf @@ -578,7 +703,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_font if(debug_msg_enabled[21]) fprintf +#define dprintf_font if(debug_msg_enabled[23]) fprintf #else #ifdef DEBUG_FONT #define dprintf_font fprintf @@ -588,7 +713,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_gdi if(debug_msg_enabled[22]) fprintf +#define dprintf_gdi if(debug_msg_enabled[24]) fprintf #else #ifdef DEBUG_GDI #define dprintf_gdi fprintf @@ -598,7 +723,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_graphics if(debug_msg_enabled[23]) fprintf +#define dprintf_graphics if(debug_msg_enabled[25]) fprintf #else #ifdef DEBUG_GRAPHICS #define dprintf_graphics fprintf @@ -608,7 +733,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_heap if(debug_msg_enabled[24]) fprintf +#define dprintf_heap if(debug_msg_enabled[26]) fprintf #else #ifdef DEBUG_HEAP #define dprintf_heap fprintf @@ -618,7 +743,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_icon if(debug_msg_enabled[25]) fprintf +#define dprintf_icon if(debug_msg_enabled[27]) fprintf #else #ifdef DEBUG_ICON #define dprintf_icon fprintf @@ -628,7 +753,17 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_int if(debug_msg_enabled[26]) fprintf +#define dprintf_if if(debug_msg_enabled[28]) fprintf +#else +#ifdef DEBUG_IF +#define dprintf_if fprintf +#else +#define dprintf_if +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_int if(debug_msg_enabled[29]) fprintf #else #ifdef DEBUG_INT #define dprintf_int fprintf @@ -638,7 +773,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_key if(debug_msg_enabled[27]) fprintf +#define dprintf_key if(debug_msg_enabled[30]) fprintf #else #ifdef DEBUG_KEY #define dprintf_key fprintf @@ -648,7 +783,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_keyboard if(debug_msg_enabled[28]) fprintf +#define dprintf_keyboard if(debug_msg_enabled[31]) fprintf #else #ifdef DEBUG_KEYBOARD #define dprintf_keyboard fprintf @@ -658,7 +793,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_ldt if(debug_msg_enabled[29]) fprintf +#define dprintf_ldt if(debug_msg_enabled[32]) fprintf #else #ifdef DEBUG_LDT #define dprintf_ldt fprintf @@ -668,7 +803,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_listbox if(debug_msg_enabled[30]) fprintf +#define dprintf_listbox if(debug_msg_enabled[33]) fprintf #else #ifdef DEBUG_LISTBOX #define dprintf_listbox fprintf @@ -678,7 +813,27 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_mciwave if(debug_msg_enabled[31]) fprintf +#define dprintf_mci if(debug_msg_enabled[34]) fprintf +#else +#ifdef DEBUG_MCI +#define dprintf_mci fprintf +#else +#define dprintf_mci +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_mcianim if(debug_msg_enabled[35]) fprintf +#else +#ifdef DEBUG_MCIANIM +#define dprintf_mcianim fprintf +#else +#define dprintf_mcianim +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_mciwave if(debug_msg_enabled[36]) fprintf #else #ifdef DEBUG_MCIWAVE #define dprintf_mciwave fprintf @@ -688,7 +843,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_mdi if(debug_msg_enabled[32]) fprintf +#define dprintf_mdi if(debug_msg_enabled[37]) fprintf #else #ifdef DEBUG_MDI #define dprintf_mdi fprintf @@ -698,7 +853,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_menu if(debug_msg_enabled[33]) fprintf +#define dprintf_menu if(debug_msg_enabled[38]) fprintf #else #ifdef DEBUG_MENU #define dprintf_menu fprintf @@ -708,7 +863,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_menucalc if(debug_msg_enabled[34]) fprintf +#define dprintf_menucalc if(debug_msg_enabled[39]) fprintf #else #ifdef DEBUG_MENUCALC #define dprintf_menucalc fprintf @@ -718,7 +873,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_message if(debug_msg_enabled[35]) fprintf +#define dprintf_message if(debug_msg_enabled[40]) fprintf #else #ifdef DEBUG_MESSAGE #define dprintf_message fprintf @@ -728,7 +883,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_metafile if(debug_msg_enabled[36]) fprintf +#define dprintf_metafile if(debug_msg_enabled[41]) fprintf #else #ifdef DEBUG_METAFILE #define dprintf_metafile fprintf @@ -738,7 +893,27 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_module if(debug_msg_enabled[37]) fprintf +#define dprintf_mmio if(debug_msg_enabled[42]) fprintf +#else +#ifdef DEBUG_MMIO +#define dprintf_mmio fprintf +#else +#define dprintf_mmio +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_mmtime if(debug_msg_enabled[43]) fprintf +#else +#ifdef DEBUG_MMTIME +#define dprintf_mmtime fprintf +#else +#define dprintf_mmtime +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_module if(debug_msg_enabled[44]) fprintf #else #ifdef DEBUG_MODULE #define dprintf_module fprintf @@ -748,7 +923,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_msg if(debug_msg_enabled[38]) fprintf +#define dprintf_msg if(debug_msg_enabled[45]) fprintf #else #ifdef DEBUG_MSG #define dprintf_msg fprintf @@ -758,7 +933,17 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_nonclient if(debug_msg_enabled[39]) fprintf +#define dprintf_msgbox if(debug_msg_enabled[46]) fprintf +#else +#ifdef DEBUG_MSGBOX +#define dprintf_msgbox fprintf +#else +#define dprintf_msgbox +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_nonclient if(debug_msg_enabled[47]) fprintf #else #ifdef DEBUG_NONCLIENT #define dprintf_nonclient fprintf @@ -768,7 +953,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_palette if(debug_msg_enabled[40]) fprintf +#define dprintf_palette if(debug_msg_enabled[48]) fprintf #else #ifdef DEBUG_PALETTE #define dprintf_palette fprintf @@ -778,7 +963,37 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_region if(debug_msg_enabled[41]) fprintf +#define dprintf_profile if(debug_msg_enabled[49]) fprintf +#else +#ifdef DEBUG_PROFILE +#define dprintf_profile fprintf +#else +#define dprintf_profile +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_prop if(debug_msg_enabled[50]) fprintf +#else +#ifdef DEBUG_PROP +#define dprintf_prop fprintf +#else +#define dprintf_prop +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_reg if(debug_msg_enabled[51]) fprintf +#else +#ifdef DEBUG_REG +#define dprintf_reg fprintf +#else +#define dprintf_reg +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_region if(debug_msg_enabled[52]) fprintf #else #ifdef DEBUG_REGION #define dprintf_region fprintf @@ -788,7 +1003,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_resource if(debug_msg_enabled[42]) fprintf +#define dprintf_resource if(debug_msg_enabled[53]) fprintf #else #ifdef DEBUG_RESOURCE #define dprintf_resource fprintf @@ -798,7 +1013,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_scroll if(debug_msg_enabled[43]) fprintf +#define dprintf_scroll if(debug_msg_enabled[54]) fprintf #else #ifdef DEBUG_SCROLL #define dprintf_scroll fprintf @@ -808,7 +1023,27 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_syscolor if(debug_msg_enabled[44]) fprintf +#define dprintf_selectors if(debug_msg_enabled[55]) fprintf +#else +#ifdef DEBUG_SELECTORS +#define dprintf_selectors fprintf +#else +#define dprintf_selectors +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_stress if(debug_msg_enabled[56]) fprintf +#else +#ifdef DEBUG_STRESS +#define dprintf_stress fprintf +#else +#define dprintf_stress +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_syscolor if(debug_msg_enabled[57]) fprintf #else #ifdef DEBUG_SYSCOLOR #define dprintf_syscolor fprintf @@ -818,7 +1053,17 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_text if(debug_msg_enabled[45]) fprintf +#define dprintf_task if(debug_msg_enabled[58]) fprintf +#else +#ifdef DEBUG_TASK +#define dprintf_task fprintf +#else +#define dprintf_task +#endif +#endif + +#ifdef DEBUG_RUNTIME +#define dprintf_text if(debug_msg_enabled[59]) fprintf #else #ifdef DEBUG_TEXT #define dprintf_text fprintf @@ -828,7 +1073,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_timer if(debug_msg_enabled[46]) fprintf +#define dprintf_timer if(debug_msg_enabled[60]) fprintf #else #ifdef DEBUG_TIMER #define dprintf_timer fprintf @@ -838,7 +1083,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_utility if(debug_msg_enabled[47]) fprintf +#define dprintf_utility if(debug_msg_enabled[61]) fprintf #else #ifdef DEBUG_UTILITY #define dprintf_utility fprintf @@ -848,7 +1093,7 @@ extern short debug_msg_enabled[]; #endif #ifdef DEBUG_RUNTIME -#define dprintf_win if(debug_msg_enabled[48]) fprintf +#define dprintf_win if(debug_msg_enabled[62]) fprintf #else #ifdef DEBUG_WIN #define dprintf_win fprintf @@ -857,6 +1102,16 @@ extern short debug_msg_enabled[]; #endif #endif +#ifdef DEBUG_RUNTIME +#define dprintf_winsock if(debug_msg_enabled[63]) fprintf +#else +#ifdef DEBUG_WINSOCK +#define dprintf_winsock fprintf +#else +#define dprintf_winsock +#endif +#endif + #ifdef DEBUG_RUNTIME @@ -864,7 +1119,9 @@ extern short debug_msg_enabled[]; static char *debug_msg_name[] = { "accel", "bitmap", +"callback", "caret", +"catch", "cdaudio", "class", "clipboard", @@ -888,29 +1145,42 @@ static char *debug_msg_name[] = { "graphics", "heap", "icon", +"if", "int", "key", "keyboard", "ldt", "listbox", +"mci", +"mcianim", "mciwave", "mdi", "menu", "menucalc", "message", "metafile", +"mmio", +"mmtime", "module", "msg", +"msgbox", "nonclient", "palette", +"profile", +"prop", +"reg", "region", "resource", "scroll", +"selectors", +"stress", "syscolor", +"task", "text", "timer", "utility", "win", +"winsock", ""}; #endif #endif diff --git a/include/dlgs.h b/include/dlgs.h new file mode 100644 index 00000000000..f7116ac518e --- /dev/null +++ b/include/dlgs.h @@ -0,0 +1,186 @@ +/****************************************************************************** +* dlgs.h - Common dialog's dialog control ID numbers * +******************************************************************************/ + +#ifndef DLGS_H +#define DLGS_H + +#define ctlFirst 0x0400 +#define ctlLast 0x04ff + /* Push buttons */ +#define psh1 0x0400 +#define psh2 0x0401 +#define psh3 0x0402 +#define psh4 0x0403 +#define psh5 0x0404 +#define psh6 0x0405 +#define psh7 0x0406 +#define psh8 0x0407 +#define psh9 0x0408 +#define psh10 0x0409 +#define psh11 0x040a +#define psh12 0x040b +#define psh13 0x040c +#define psh14 0x040d +#define psh15 0x040e +#define pshHelp psh15 +#define psh16 0x040f + /* Checkboxes */ +#define chx1 0x0410 +#define chx2 0x0411 +#define chx3 0x0412 +#define chx4 0x0413 +#define chx5 0x0414 +#define chx6 0x0415 +#define chx7 0x0416 +#define chx8 0x0417 +#define chx9 0x0418 +#define chx10 0x0419 +#define chx11 0x041a +#define chx12 0x041b +#define chx13 0x041c +#define chx14 0x041d +#define chx15 0x041e +#define chx16 0x041f + /* Radio buttons */ +#define rad1 0x0420 +#define rad2 0x0421 +#define rad3 0x0422 +#define rad4 0x0423 +#define rad5 0x0424 +#define rad6 0x0425 +#define rad7 0x0426 +#define rad8 0x0427 +#define rad9 0x0428 +#define rad10 0x0429 +#define rad11 0x042a +#define rad12 0x042b +#define rad13 0x042c +#define rad14 0x042d +#define rad15 0x042e +#define rad16 0x042f + /* Groups, frames, rectangles, and icons */ +#define grp1 0x0430 +#define grp2 0x0431 +#define grp3 0x0432 +#define grp4 0x0433 +#define frm1 0x0434 +#define frm2 0x0435 +#define frm3 0x0436 +#define frm4 0x0437 +#define rct1 0x0438 +#define rct2 0x0439 +#define rct3 0x043a +#define rct4 0x043b +#define ico1 0x043c +#define ico2 0x043d +#define ico3 0x043e +#define ico4 0x043f + /* Static text */ +#define stc1 0x0440 +#define stc2 0x0441 +#define stc3 0x0442 +#define stc4 0x0443 +#define stc5 0x0444 +#define stc6 0x0445 +#define stc7 0x0446 +#define stc8 0x0447 +#define stc9 0x0448 +#define stc10 0x0449 +#define stc11 0x044a +#define stc12 0x044b +#define stc13 0x044c +#define stc14 0x044d +#define stc15 0x044e +#define stc16 0x044f +#define stc17 0x0450 +#define stc18 0x0451 +#define stc19 0x0452 +#define stc20 0x0453 +#define stc21 0x0454 +#define stc22 0x0455 +#define stc23 0x0456 +#define stc24 0x0457 +#define stc25 0x0458 +#define stc26 0x0459 +#define stc27 0x045a +#define stc28 0x045b +#define stc29 0x045c +#define stc30 0x045d +#define stc31 0x045e +#define stc32 0x045f + /* Listboxes */ +#define lst1 0x0460 +#define lst2 0x0461 +#define lst3 0x0462 +#define lst4 0x0463 +#define lst5 0x0464 +#define lst6 0x0465 +#define lst7 0x0466 +#define lst8 0x0467 +#define lst9 0x0468 +#define lst10 0x0469 +#define lst11 0x046a +#define lst12 0x046b +#define lst13 0x046c +#define lst14 0x046d +#define lst15 0x046e +#define lst16 0x046f + /* Combo boxes */ +#define cmb1 0x0470 +#define cmb2 0x0471 +#define cmb3 0x0472 +#define cmb4 0x0473 +#define cmb5 0x0474 +#define cmb6 0x0475 +#define cmb7 0x0476 +#define cmb8 0x0477 +#define cmb9 0x0478 +#define cmb10 0x0479 +#define cmb11 0x047a +#define cmb12 0x047b +#define cmb13 0x047c +#define cmb14 0x047d +#define cmb15 0x047e +#define cmb16 0x047f + /* Edit controls */ +#define edt1 0x0480 +#define edt2 0x0481 +#define edt3 0x0482 +#define edt4 0x0483 +#define edt5 0x0484 +#define edt6 0x0485 +#define edt7 0x0486 +#define edt8 0x0487 +#define edt9 0x0488 +#define edt10 0x0489 +#define edt11 0x048a +#define edt12 0x048b +#define edt13 0x048c +#define edt14 0x048d +#define edt15 0x048e +#define edt16 0x048f + /* Scroll bars */ +#define scr1 0x0490 +#define scr2 0x0491 +#define scr3 0x0492 +#define scr4 0x0493 +#define scr5 0x0494 +#define scr6 0x0495 +#define scr7 0x0496 +#define scr8 0x0497 + +/* These dialog resource ordinals really start at 0x0600, but the + * RC Compiler can't handle hex for resource IDs, hence the decimal. + */ +#define FILEOPENORD 1536 +#define MULTIFILEOPENORD 1537 +#define PRINTDLGORD 1538 +#define PRNSETUPDLGORD 1539 +#define FINDDLGORD 1540 +#define REPLACEDLGORD 1541 +#define FONTDLGORD 1542 +#define FORMATDLGORD31 1543 +#define FORMATDLGORD30 1544 + +#endif /* #ifdef DLGS_H */ diff --git a/include/dlls.h b/include/dlls.h index 5a5cdf6de1e..b4a3fc08932 100644 --- a/include/dlls.h +++ b/include/dlls.h @@ -112,7 +112,8 @@ extern struct dll_table_entry_s STRESS_table[]; extern struct dll_table_entry_s SYSTEM_table[]; extern struct dll_table_entry_s TOOLHELP_table[]; extern struct dll_table_entry_s MOUSE_table[]; +extern struct dll_table_entry_s COMMDLG_table[]; -#define N_BUILTINS 14 +#define N_BUILTINS 15 #endif /* DLLS_H */ diff --git a/include/gdi.h b/include/gdi.h index 9198f21f818..bc553df5cc6 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -124,8 +124,8 @@ typedef struct DeviceCaps *devCaps; HANDLE hMetaFile; - HRGN hClipRgn; /* Clip region */ - HRGN hVisRgn; /* Visible region */ + HRGN hClipRgn; /* Clip region (may be 0) */ + HRGN hVisRgn; /* Visible region (must never be 0) */ HRGN hGCClipRgn; /* GC clip region (ClipRgn AND VisRgn) */ HPEN hPen; HBRUSH hBrush; @@ -158,8 +158,6 @@ typedef struct WORD MapMode; short DCOrgX; /* DC origin */ short DCOrgY; - short DCSizeX; /* DC dimensions */ - short DCSizeY; short CursPosX; /* Current position */ short CursPosY; short WndOrgX; diff --git a/include/heap.h b/include/heap.h index 7ff97a09c1b..ff4321a14fc 100644 --- a/include/heap.h +++ b/include/heap.h @@ -37,6 +37,7 @@ extern void *HEAP_ReAlloc(MDESC **free_list, void *old_block, int new_size, unsigned int flags); extern LHEAP *HEAP_LocalFindHeap(unsigned short owner); extern unsigned int HEAP_LocalSize(MDESC **free_list, unsigned int handle); +extern void HEAP_LocalInit(unsigned short owner, void *start, int length); #define HEAP_OWNER (Segments[Stack16Frame[11] >> 3].owner) #define LOCALHEAP() (&HEAP_LocalFindHeap(HEAP_OWNER)->free_list) diff --git a/include/listbox.h b/include/listbox.h index 22148ec8038..e244781529e 100644 --- a/include/listbox.h +++ b/include/listbox.h @@ -4,30 +4,32 @@ typedef struct tagLISTSTRUCT { - DRAWITEMSTRUCT dis; - HANDLE hMem; - HANDLE hData; - char *itemText; - void *lpNext; + DRAWITEMSTRUCT dis; + HANDLE hMem; + HANDLE hData; + char *itemText; + void *lpNext; } LISTSTRUCT; typedef LISTSTRUCT FAR* LPLISTSTRUCT; typedef struct tagHEADLIST { - short FirstVisible; - short ItemsCount; - short ItemsVisible; - short ColumnsVisible; - short ItemsPerColumn; - short ItemFocused; - short PrevFocused; - short StdItemHeight; - short ColumnsWidth; - short DrawCtlType; - void *lpFirst; - DWORD dwStyle; - HWND hWndLogicParent; - HFONT hFont; + short FirstVisible; + short ItemsCount; + short ItemsVisible; + short ColumnsVisible; + short ItemsPerColumn; + short ItemFocused; + short PrevFocused; + short SelCount; + short StdItemHeight; + short ColumnsWidth; + short DrawCtlType; + void *lpFirst; + DWORD dwStyle; + HWND hWndLogicParent; + HFONT hFont; + BOOL bRedrawFlag; } HEADLIST; typedef HEADLIST FAR* LPHEADLIST; diff --git a/include/msdos.h b/include/msdos.h index 0578218a39f..0529883d223 100644 --- a/include/msdos.h +++ b/include/msdos.h @@ -30,25 +30,24 @@ struct fcb { #define DOSVERSION 0x0330; #define MAX_DOS_DRIVES 26 -#define pointer(a,b) (BYTE*)(((WORD) a << 16) | b) -#define segment(a) ((DWORD)a >> 16) -#define offset(a) ((DWORD)a & 0xffff) +#define segment(a) ((DWORD)(a) >> 16) +#define offset(a) ((DWORD)(a) & 0xffff) -#define setword(a,b) *(BYTE*)(a) = b & 0xff; \ - *((BYTE*)(a + 1)) = (b>>8) & 0xff; +#define setword(a,b) *(BYTE*)(a) = (b) & 0xff; \ + *((BYTE*)((a)+1)) = ((b)>>8) & 0xff; -#define setdword(a,b) *(BYTE*)a = b & 0xff; \ - *((BYTE*)a + 1) = (b>>8) & 0xff; \ - *((BYTE*)a + 2) = (b>>16) & 0xff; \ - *((BYTE*)a + 3) = (b>>24) & 0xff; +#define setdword(a,b) *(BYTE*)(a) = (b) & 0xff; \ + *((BYTE*)(a)+1) = ((b)>>8) & 0xff; \ + *((BYTE*)(a)+2) = ((b)>>16) & 0xff; \ + *((BYTE*)(a)+3) = ((b)>>24) & 0xff; -#define getword(a) (WORD) *(BYTE*)a + \ - (*((BYTE*)a + 1) << 8) +#define getword(a) (WORD) *(BYTE*)(a) + \ + (*((BYTE*)(a) + 1) << 8) -#define getdword(a) (DWORD) (*(BYTE*)a + \ - (*((BYTE*)a + 1) << 8) + \ - (*((BYTE*)a + 2) << 16) + \ - (*((BYTE*)a + 3) << 24)) +#define getdword(a) (DWORD) (*(BYTE*)(a) + \ + (*((BYTE*)(a) + 1) << 8) + \ + (*((BYTE*)(a) + 2) << 16) + \ + (*((BYTE*)(a) + 3) << 24)) /* dos file attributes */ diff --git a/include/scroll.h b/include/scroll.h index 02ce9d13142..96a6be9fe7d 100644 --- a/include/scroll.h +++ b/include/scroll.h @@ -4,22 +4,23 @@ typedef struct tagHEADSSCROLL { - short CurVal; - short MinVal; - short MaxVal; - short MaxPix; - short CurPix; - short ThumbVal; - RECT rect; - RECT rectUp; - RECT rectDown; - BOOL ThumbActive; - BOOL TimerPending; - WORD ButtonDown; - WORD Direction; - DWORD dwStyle; - HWND hWndOwner; -} HEADSCROLL; + short CurVal; + short MinVal; + short MaxVal; + short MaxPix; + short CurPix; + short ThumbVal; + RECT rect; + RECT rectUp; + RECT rectDown; + BOOL ThumbActive; + BOOL TimerPending; + WORD ButtonDown; + WORD Direction; + DWORD dwStyle; + HWND hWndOwner; + BOOL bRedrawFlag; + } HEADSCROLL; typedef HEADSCROLL FAR* LPHEADSCROLL; diff --git a/include/stddebug.h b/include/stddebug.h index cda6a2ee816..465bd2560c7 100644 --- a/include/stddebug.h +++ b/include/stddebug.h @@ -68,6 +68,8 @@ /* #define DEBUG_WIN */ /* #define DEBUG_ENUM */ /* #define DEBUG_DLL */ +/* #define DEBUG_MSGBOX */ +/* #define DEBUG_CATCH */ # /* Do not remove this line or change anything below this line */ @@ -75,7 +77,9 @@ #ifdef DEBUG_NONE #undef DEBUG_ACCEL #undef DEBUG_BITMAP +#undef DEBUG_CALLBACK #undef DEBUG_CARET +#undef DEBUG_CATCH #undef DEBUG_CDAUDIO #undef DEBUG_CLASS #undef DEBUG_CLIPBOARD @@ -99,36 +103,51 @@ #undef DEBUG_GRAPHICS #undef DEBUG_HEAP #undef DEBUG_ICON +#undef DEBUG_IF #undef DEBUG_INT #undef DEBUG_KEY #undef DEBUG_KEYBOARD #undef DEBUG_LDT #undef DEBUG_LISTBOX +#undef DEBUG_MCI +#undef DEBUG_MCIANIM #undef DEBUG_MCIWAVE #undef DEBUG_MDI #undef DEBUG_MENU #undef DEBUG_MENUCALC #undef DEBUG_MESSAGE #undef DEBUG_METAFILE +#undef DEBUG_MMIO +#undef DEBUG_MMTIME #undef DEBUG_MODULE #undef DEBUG_MSG +#undef DEBUG_MSGBOX #undef DEBUG_NONCLIENT #undef DEBUG_PALETTE +#undef DEBUG_PROFILE +#undef DEBUG_PROP +#undef DEBUG_REG #undef DEBUG_REGION #undef DEBUG_RESOURCE #undef DEBUG_SCROLL +#undef DEBUG_SELECTORS +#undef DEBUG_STRESS #undef DEBUG_SYSCOLOR +#undef DEBUG_TASK #undef DEBUG_TEXT #undef DEBUG_TIMER #undef DEBUG_UTILITY #undef DEBUG_WIN +#undef DEBUG_WINSOCK #endif #ifdef DEBUG_ALL #define DEBUG_ACCEL #define DEBUG_BITMAP +#define DEBUG_CALLBACK #define DEBUG_CARET +#define DEBUG_CATCH #define DEBUG_CDAUDIO #define DEBUG_CLASS #define DEBUG_CLIPBOARD @@ -152,27 +171,40 @@ #define DEBUG_GRAPHICS #define DEBUG_HEAP #define DEBUG_ICON +#define DEBUG_IF #define DEBUG_INT #define DEBUG_KEY #define DEBUG_KEYBOARD #define DEBUG_LDT #define DEBUG_LISTBOX +#define DEBUG_MCI +#define DEBUG_MCIANIM #define DEBUG_MCIWAVE #define DEBUG_MDI #define DEBUG_MENU #define DEBUG_MENUCALC #define DEBUG_MESSAGE #define DEBUG_METAFILE +#define DEBUG_MMIO +#define DEBUG_MMTIME #define DEBUG_MODULE #define DEBUG_MSG +#define DEBUG_MSGBOX #define DEBUG_NONCLIENT #define DEBUG_PALETTE +#define DEBUG_PROFILE +#define DEBUG_PROP +#define DEBUG_REG #define DEBUG_REGION #define DEBUG_RESOURCE #define DEBUG_SCROLL +#define DEBUG_SELECTORS +#define DEBUG_STRESS #define DEBUG_SYSCOLOR +#define DEBUG_TASK #define DEBUG_TEXT #define DEBUG_TIMER #define DEBUG_UTILITY #define DEBUG_WIN +#define DEBUG_WINSOCK #endif diff --git a/include/windows.h b/include/windows.h index ee8fc6fa7f0..96d80eaf170 100644 --- a/include/windows.h +++ b/include/windows.h @@ -1195,7 +1195,7 @@ typedef OFSTRUCT *LPOFSTRUCT; typedef struct tagDCB { BYTE Id; - UINT BaudRate; + UINT BaudRate WINE_PACKED; BYTE ByteSize; BYTE Parity; BYTE StopBits; @@ -1227,15 +1227,15 @@ typedef struct tagDCB char PeChar; char EofChar; char EvtChar; - UINT TxDelay; + UINT TxDelay WINE_PACKED; } DCB; typedef DCB FAR* LPDCB; typedef struct tagCOMSTAT { BYTE status; - UINT cbInQue; - UINT cbOutQue; + UINT cbInQue WINE_PACKED; + UINT cbOutQue WINE_PACKED; } COMSTAT; #define CSTF_CTSHOLD 0x01 @@ -2655,6 +2655,7 @@ Fb(BOOL,GetTextMetrics,HDC,a,LPTEXTMETRIC,b) Fb(BOOL,InvertRgn,HDC,a,HRGN,b) Fb(BOOL,IsChild,HWND,a,HWND,b) Fb(BOOL,IsDialogMessage,HWND,a,LPMSG,b) +Fb(BOOL,KillSystemTimer,HWND,a,WORD,b) Fb(BOOL,KillTimer,HWND,a,WORD,b) Fb(BOOL,OemToAnsi,LPSTR,a,LPSTR,b) Fb(BOOL,PaintRgn,HDC,a,HRGN,b) @@ -2916,6 +2917,7 @@ Fd(WORD,GetPaletteEntries,HPALETTE,a,WORD,b,WORD,c,LPPALETTEENTRY,d) Fd(WORD,GetPrivateProfileInt,LPSTR,a,LPSTR,b,short,c,LPSTR,d) Fd(WORD,GetSystemPaletteEntries,HDC,a,WORD,b,WORD,c,LPPALETTEENTRY,d) Fd(WORD,SetPaletteEntries,HPALETTE,a,WORD,b,WORD,c,LPPALETTEENTRY,d) +Fd(WORD,SetSystemTimer,HWND,a,WORD,d,WORD,b,FARPROC,c) Fd(WORD,SetTimer,HWND,a,WORD,d,WORD,b,FARPROC,c) Fd(BOOL,SetViewportExtEx,HDC,a,short,b,short,c,LPSIZE,d) Fd(BOOL,SetViewportOrgEx,HDC,a,short,b,short,c,LPPOINT,d) diff --git a/include/winpos.h b/include/winpos.h index 1353f92a408..837a5b3d9dc 100644 --- a/include/winpos.h +++ b/include/winpos.h @@ -15,6 +15,7 @@ typedef struct WORD suggestedCount; WORD valid; WORD wMagic; + HWND hwndParent; WINDOWPOS winPos[1]; } DWP; diff --git a/loader/dump.c b/loader/dump.c index 08e1962d5a2..1cf84fa6995 100644 --- a/loader/dump.c +++ b/loader/dump.c @@ -29,14 +29,14 @@ PrintFileHeader(struct ne_header_s *ne_header) ne_header->header_type[1]); printf("linker version: %d.%d\n", ne_header->linker_version, ne_header->linker_revision); - printf("format flags: %04.4x\n", ne_header->format_flags); - printf("automatic data segment: %04.4x\n", ne_header->auto_data_seg); - printf("CS:IP %04.4x:%04.4x\n", ne_header->cs, ne_header->ip); - printf("SS:SP %04.4x:%04.4x\n", ne_header->ss, ne_header->sp); - printf("additional flags: %02.2x\n", ne_header->additional_flags); - printf("operating system: %02.2x\n", ne_header->operating_system); - printf("fast load offset: %04.4x\n", ne_header->fastload_offset); - printf("fast load length: %04.4x\n", ne_header->fastload_length); + printf("format flags: %04x\n", ne_header->format_flags); + printf("automatic data segment: %04x\n", ne_header->auto_data_seg); + printf("CS:IP %04x:%04x\n", ne_header->cs, ne_header->ip); + printf("SS:SP %04x:%04x\n", ne_header->ss, ne_header->sp); + printf("additional flags: %02x\n", ne_header->additional_flags); + printf("operating system: %02x\n", ne_header->operating_system); + printf("fast load offset: %04x\n", ne_header->fastload_offset); + printf("fast load length: %04x\n", ne_header->fastload_length); } /********************************************************************** @@ -49,10 +49,10 @@ PrintSegmentTable(struct ne_segment_table_entry_s *seg_table, int nentries) for (i = 0; i < nentries; i++) { - printf(" %2d: OFFSET %04.4x, LENGTH %04.4x, ", + printf(" %2d: OFFSET %04x, LENGTH %04x, ", i + 1, seg_table[i].seg_data_offset, seg_table[i].seg_data_length); - printf("FLAGS %04.4x, MIN ALLOC %04.4x\n", + printf("FLAGS %04x, MIN ALLOC %04x\n", seg_table[i].seg_flags, seg_table[i].min_alloc); } } @@ -85,9 +85,9 @@ PrintRelocationTable(char *exe_ptr, rep = (struct relocation_entry_s *) (sp + 1); for (i = 0; i < n_entries; i++, rep++) { - printf(" ADDR TYPE %d, TYPE %d, OFFSET %04.4x,", + printf(" ADDR TYPE %d, TYPE %d, OFFSET %04x,", rep->address_type, rep->relocation_type, rep->offset); - printf("TARGET %04.4x %04.4x\n", rep->target1, rep->target2); + printf("TARGET %04x %04x\n", rep->target1, rep->target2); } } #endif /* ifndef WINELIB */ diff --git a/loader/ldt.c b/loader/ldt.c index 96ca5e4d4e1..ebcd5749149 100644 --- a/loader/ldt.c +++ b/loader/ldt.c @@ -55,7 +55,7 @@ print_ldt() #endif if (*lp & 1000) { - printf("Entry %2d: Base %08.8x, Limit %05.5x, DPL %d, Type %d\n", + printf("Entry %2d: Base %08lx, Limit %05lx, DPL %d, Type %d\n", i, base_addr, limit, dpl, type); printf(" "); if (*lp & 0x100) @@ -75,13 +75,13 @@ print_ldt() else printf("byte limit, "); printf("\n"); - printf(" %08.8x %08.8x\n", *(lp), *(lp-1)); + printf(" %08lx %08lx\n", *(lp), *(lp-1)); } else { - printf("Entry %2d: Base %08.8x, Limit %05.5x, DPL %d, Type %d\n", + printf("Entry %2d: Base %08lx, Limit %05lx, DPL %d, Type %d\n", i, base_addr, limit, dpl, type); - printf(" SYSTEM: %08.8x %08.8x\n", *lp, *(lp-1)); + printf(" SYSTEM: %08x %08x\n", *lp, *(lp-1)); } } } diff --git a/loader/ldtlib.c b/loader/ldtlib.c index 8266c7f5835..6e4c30baa25 100644 --- a/loader/ldtlib.c +++ b/loader/ldtlib.c @@ -7,8 +7,8 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; #include #include "autoconf.h" #include "stddebug.h" -/* #define DEBUG_LDT /* */ -/* #undef DEBUG_LDT /* */ +/* #define DEBUG_LDT */ +/* #undef DEBUG_LDT */ #include "debug.h" #ifdef linux diff --git a/loader/library.c b/loader/library.c index ea6f623d4dc..1f9291d7249 100644 --- a/loader/library.c +++ b/loader/library.c @@ -22,8 +22,8 @@ static char Copyright[] = "Copyright 1993, 1994 Martin Ayotte, Robert J. Amstadt #include "task.h" #include "toolhelp.h" #include "stddebug.h" -/* #define DEBUG_MODULE /* */ -/* #undef DEBUG_MODULE /* */ +/* #define DEBUG_MODULE */ +/* #undef DEBUG_MODULE */ #include "debug.h" extern char WindowsPath[256]; @@ -96,12 +96,12 @@ void InitializeLoadedDLLs(struct w_files *wpnt) static flagReadyToRun = 0; struct w_files *final_wpnt; - printf("InitializeLoadedDLLs %08X\n", wpnt); + dprintf_module(stddeb,"InitializeLoadedDLLs(%08lX)\n", wpnt); if (wpnt == NULL) { flagReadyToRun = 1; - fprintf(stderr, "Initializing DLLs\n"); + dprintf_module(stddeb,"Initializing DLLs\n"); } if (!flagReadyToRun) @@ -109,7 +109,7 @@ void InitializeLoadedDLLs(struct w_files *wpnt) #if 1 if (wpnt != NULL) - fprintf(stderr, "Initializing %s\n", wpnt->name); + dprintf_module(stddeb,"Initializing %s\n", wpnt->name); #endif /* @@ -140,7 +140,7 @@ HINSTANCE LoadImage(char *module, int filetype, int change_dir) char buffer[256], header[2], modulename[64], *fullname; ExtractDLLName(module, modulename); - printf("LoadImage [%s]\n", module); + dprintf_module(stddeb,"LoadImage [%s]\n", module); /* built-in one ? */ if (FindDLLTable(modulename)) { return GetModuleHandle(modulename); @@ -166,7 +166,7 @@ HINSTANCE LoadImage(char *module, int filetype, int change_dir) fullname = GetDosFileName(fullname); - fprintf(stderr,"LoadImage: loading %s (%s)\n [%s]\n", + dprintf_module(stddeb,"LoadImage: loading %s (%s)\n [%s]\n", module, buffer, fullname); if (change_dir && fullname) @@ -209,8 +209,12 @@ HINSTANCE LoadImage(char *module, int filetype, int change_dir) { myerror("Unable to read MZ header from file"); } + + /* This field is ignored according to "Windows Internals", p.242 */ +#if 0 if (wpnt->mz_header->must_be_0x40 != 0x40) myerror("This is not a Windows program"); +#endif /* read first two bytes to determine filetype */ lseek(wpnt->fd, wpnt->mz_header->ne_offset, SEEK_SET); @@ -261,45 +265,45 @@ HANDLE GetModuleHandle(LPSTR lpModuleName) ExtractDLLName(lpModuleName, dllname); if ((int) lpModuleName & 0xffff0000) - printf("GetModuleHandle('%s');\n", lpModuleName); + dprintf_module(stddeb,"GetModuleHandle('%s');\n", lpModuleName); else - printf("GetModuleHandle('%x');\n", lpModuleName); + dprintf_module(stddeb,"GetModuleHandle('%p');\n", lpModuleName); -/* printf("GetModuleHandle // searching in builtin libraries\n");*/ +/* dprintf_module(stddeb,"GetModuleHandle // searching in builtin libraries\n");*/ for (i = 0; i < N_BUILTINS; i++) { if (dll_builtin_table[i].dll_name == NULL) break; if (((int) lpModuleName & 0xffff0000) == 0) { if (0xFF00 + i == (int) lpModuleName) { - printf("GetModuleHandle('%s') return %04X \n", + dprintf_module(stddeb,"GetModuleHandle('%s') return %04X \n", lpModuleName, 0xff00 + i); return 0xFF00 + i; } } else if (strcasecmp(dll_builtin_table[i].dll_name, dllname) == 0) { - printf("GetModuleHandle('%x') return %04X \n", + dprintf_module(stddeb,"GetModuleHandle('%p') return %04X \n", lpModuleName, 0xFF00 + i); return (0xFF00 + i); } } - printf("GetModuleHandle // searching in loaded modules\n"); + dprintf_module(stddeb,"GetModuleHandle // searching in loaded modules\n"); while (w) { -/* printf("GetModuleHandle // '%x' \n", w->name); */ +/* dprintf_module(stddeb,"GetModuleHandle // '%x' \n", w->name); */ if (((int) lpModuleName & 0xffff0000) == 0) { if (w->hinstance == (int) lpModuleName) { - printf("GetModuleHandle('%x') return %04X \n", + dprintf_module(stddeb,"GetModuleHandle('%p') return %04X \n", lpModuleName, w->hinstance); return w->hinstance; } } else if (strcasecmp(w->name, dllname) == 0) { - printf("GetModuleHandle('%s') return %04X \n", + dprintf_module(stddeb,"GetModuleHandle('%s') return %04X \n", lpModuleName, w->hinstance); return w->hinstance; } w = w->next; } - printf("GetModuleHandle('%x') not found !\n", lpModuleName); + printf("GetModuleHandle('%p') not found !\n", lpModuleName); return 0; } @@ -311,7 +315,7 @@ int GetModuleUsage(HANDLE hModule) { struct w_files *w; - printf("GetModuleUsage(%04X);\n", hModule); + dprintf_module(stddeb,"GetModuleUsage(%04X);\n", hModule); /* built-in dll ? */ if (IS_BUILTIN_DLL(hModule)) @@ -332,7 +336,7 @@ int GetModuleFileName(HANDLE hModule, LPSTR lpFileName, short nSize) LPSTR str; char windir[256], temp[256]; - printf("GetModuleFileName(%04X, %08X, %d);\n", hModule, lpFileName, nSize); + dprintf_module(stddeb,"GetModuleFileName(%04X, %p, %d);\n", hModule, lpFileName, nSize); if (lpFileName == NULL) return 0; if (nSize < 1) return 0; @@ -343,7 +347,7 @@ int GetModuleFileName(HANDLE hModule, LPSTR lpFileName, short nSize) sprintf(temp, "%s\\%s.DLL", windir, dll_builtin_table[hModule & 0x00ff].dll_name); ToDos(temp); strncpy(lpFileName, temp, nSize); - printf("GetModuleFileName copied '%s' (internal dll) return %d \n", lpFileName, nSize); + dprintf_module(stddeb,"GetModuleFileName copied '%s' (internal dll) return %d \n", lpFileName, nSize); return strlen(lpFileName); } @@ -353,7 +357,7 @@ int GetModuleFileName(HANDLE hModule, LPSTR lpFileName, short nSize) str = GetDosFileName(w->filename); if (nSize > strlen(str)) nSize = strlen(str) + 1; strncpy(lpFileName, str, nSize); - printf("GetModuleFileName copied '%s' return %d \n", lpFileName, nSize); + dprintf_module(stddeb,"GetModuleFileName copied '%s' return %d \n", lpFileName, nSize); return nSize - 1; } @@ -379,8 +383,7 @@ HANDLE LoadLibrary(LPSTR libname) */ void FreeLibrary(HANDLE hLib) { - struct w_files *wpnt; - printf("FreeLibrary(%04X);\n", hLib); + dprintf_module(stddeb,"FreeLibrary(%04X);\n", hLib); /* built-in dll ? */ if (IS_BUILTIN_DLL(hLib) || hLib == 0 || hLib == hSysRes) @@ -399,11 +402,11 @@ void FreeLibrary(HANDLE hLib) if (lpMod->ModuleName != NULL) free(lpMod->ModuleName); if (lpMod->FileName != NULL) free(lpMod->FileName); GlobalFree(lpMod->hModule); - printf("FreeLibrary // freed !\n"); + dprintf_module(stddeb,"FreeLibrary // freed !\n"); return; } lpMod->Count--; - printf("FreeLibrary // Count decremented !\n"); + dprintf_module(stddeb,"FreeLibrary // Count decremented !\n"); return; } lpMod = lpMod->lpNextModule; @@ -433,7 +436,7 @@ FARPROC GetProcAddress(HANDLE hModule, char *proc_name) { if ((int) proc_name & 0xffff0000) { - printf("GetProcAddress: builtin %#04X, '%s'\n", + dprintf_module(stddeb,"GetProcAddress: builtin %#04X, '%s'\n", hModule, proc_name); if (GetEntryDLLName(dll_builtin_table[hModule - 0xFF00].dll_name, proc_name, &sel, &addr)) @@ -443,7 +446,7 @@ FARPROC GetProcAddress(HANDLE hModule, char *proc_name) } else { - printf("GetProcAddress: builtin %#04X, %d\n", + dprintf_module(stddeb,"GetProcAddress: builtin %#04X, %d\n", hModule, (int)proc_name); if (GetEntryDLLOrdinal(dll_builtin_table[hModule-0xFF00].dll_name, (int)proc_name & 0x0000FFFF, &sel, &addr)) @@ -452,14 +455,14 @@ FARPROC GetProcAddress(HANDLE hModule, char *proc_name) } } ret = MAKELONG(addr, sel); - printf("GetProcAddress // ret=%08X sel=%04X addr=%04X\n", + dprintf_module(stddeb,"GetProcAddress // ret=%08X sel=%04X addr=%04X\n", ret, sel, addr); return (FARPROC)ret; } if (hModule == 0) { hTask = GetCurrentTask(); - printf("GetProcAddress // GetCurrentTask()=%04X\n", hTask); + dprintf_module(stddeb,"GetProcAddress // GetCurrentTask()=%04X\n", hTask); lpTask = (LPTASKENTRY) GlobalLock(hTask); if (lpTask == NULL) { @@ -467,7 +470,7 @@ FARPROC GetProcAddress(HANDLE hModule, char *proc_name) return NULL; } hModule = lpTask->hInst; - printf("GetProcAddress: current module=%04X instance=%04X!\n", + dprintf_module(stddeb,"GetProcAddress: current module=%04X instance=%04X!\n", lpTask->hModule, lpTask->hInst); GlobalUnlock(hTask); } @@ -475,11 +478,11 @@ FARPROC GetProcAddress(HANDLE hModule, char *proc_name) w = w->next; if (w == NULL) return NULL; - printf("GetProcAddress // Module Found ! w->filename='%s'\n", w->filename); + dprintf_module(stddeb,"GetProcAddress // Module Found ! w->filename='%s'\n", w->filename); if ((int)proc_name & 0xFFFF0000) { AnsiUpper(proc_name); - printf("GetProcAddress: %04X, '%s'\n", hModule, proc_name); + dprintf_module(stddeb,"GetProcAddress: %04X, '%s'\n", hModule, proc_name); cpnt = w->ne->nrname_table; while(TRUE) { @@ -488,10 +491,8 @@ FARPROC GetProcAddress(HANDLE hModule, char *proc_name) len = *cpnt++; strncpy(C, cpnt, len); C[len] = '\0'; -#ifdef DEBUG_MODULE - printf("pointing Function '%s' ordinal=%d !\n", + dprintf_module(stddeb,"pointing Function '%s' ordinal=%d !\n", C, *((unsigned short *)(cpnt + len))); -#endif if (strncmp(cpnt, proc_name, len) == 0) { ordinal = *((unsigned short *)(cpnt + len)); @@ -507,7 +508,7 @@ FARPROC GetProcAddress(HANDLE hModule, char *proc_name) } else { - printf("GetProcAddress: %#04x, %d\n", hModule, (int) proc_name); + dprintf_module(stddeb,"GetProcAddress: %#04x, %d\n", hModule, (int) proc_name); ordinal = (int)proc_name; } ret = GetEntryPointFromOrdinal(w, ordinal); @@ -518,7 +519,7 @@ FARPROC GetProcAddress(HANDLE hModule, char *proc_name) } addr = ret & 0xffff; sel = (ret >> 16); - printf("GetProcAddress // ret=%08X sel=%04X addr=%04X\n", ret, sel, addr); + dprintf_module(stddeb,"GetProcAddress // ret=%08X sel=%04X addr=%04X\n", ret, sel, addr); return (FARPROC) ret; #endif /* WINELIB */ } @@ -552,7 +553,7 @@ FillModStructLoaded(MODULEENTRY *lpModule, struct w_files *dll) */ BOOL ModuleFirst(MODULEENTRY *lpModule) { - printf("ModuleFirst(%08X)\n", (int) lpModule); + dprintf_module(stddeb,"ModuleFirst(%08X)\n", (int) lpModule); FillModStructBuiltIn(lpModule, &dll_builtin_table[0]); return TRUE; @@ -565,7 +566,7 @@ BOOL ModuleNext(MODULEENTRY *lpModule) { struct w_files *w; - printf("ModuleNext(%08X)\n", (int) lpModule); + dprintf_module(stddeb,"ModuleNext(%08X)\n", (int) lpModule); if (IS_BUILTIN_DLL(lpModule->hModule)) { /* last built-in ? */ @@ -594,7 +595,7 @@ HMODULE ModuleFindHandle(MODULEENTRY *lpModule, HMODULE hModule) { struct w_files *w; - printf("ModuleFindHandle(%08X, %04X)\n", (int) lpModule, (int)hModule); + dprintf_module(stddeb,"ModuleFindHandle(%08X, %04X)\n", (int) lpModule, (int)hModule); /* built-in dll ? */ if (IS_BUILTIN_DLL(hModule)) { diff --git a/loader/main.c b/loader/main.c index eefa3c11292..5721a52e169 100644 --- a/loader/main.c +++ b/loader/main.c @@ -20,8 +20,8 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; #include "task.h" #include "options.h" #include "stddebug.h" -/* #define DEBUG_DLL /* */ -/* #undef DEBUG_DLL /* */ +/* #define DEBUG_DLL */ +/* #undef DEBUG_DLL */ #include "debug.h" @@ -83,7 +83,8 @@ int _WinMain(int argc, char **argv) exit(1); } hTaskMain = CreateNewTask(hInstMain, 0); - printf("_WinMain // hTaskMain=%04X hInstMain=%04X !\n", hTaskMain, hInstMain); + dprintf_dll(stddeb,"_WinMain // hTaskMain=%04X hInstMain=%04X !\n", + hTaskMain, hInstMain); GetPrivateProfileString("wine", "SystemResources", "sysres.dll", filename, sizeof(filename), WINE_INI); @@ -93,7 +94,8 @@ int _WinMain(int argc, char **argv) fprintf(stderr, "wine: can't load %s!.\n", filename); exit(1); } else - dprintf_dll(stddeb,"System Resources Loaded // hSysRes='%04X'\n", hSysRes); + dprintf_dll(stddeb,"System Resources Loaded // hSysRes='%04X'\n", + hSysRes); #ifdef WINESTAT cp = strrchr(argv[0], '/'); diff --git a/loader/ne_image.c b/loader/ne_image.c index 03d3b860506..5584fec1295 100644 --- a/loader/ne_image.c +++ b/loader/ne_image.c @@ -25,8 +25,8 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; #include "arch.h" #include "options.h" #include "stddebug.h" -/* #define DEBUG_FIXUP /* */ -/* #undef DEBUG_FIXUP /* */ +/* #define DEBUG_FIXUP */ +/* #undef DEBUG_FIXUP */ #include "debug.h" extern HANDLE CreateNewTask(HINSTANCE hInst); @@ -284,7 +284,7 @@ FixupSegment(struct w_files * wpnt, int segment_num) return -1; } - dprintf_fixup(stddeb,"%d: %s.%d: %04.4x:%04.4x\n", i + 1, + dprintf_fixup(stddeb,"%d: %s.%d: %04x:%04x\n", i + 1, dll_name, ordinal, selector, address); break; @@ -317,7 +317,7 @@ FixupSegment(struct w_files * wpnt, int segment_num) return -1; } - dprintf_fixup(stddeb,"%d: %s %s.%d: %04.4x:%04.4x\n", i + 1, + dprintf_fixup(stddeb,"%d: %s %s.%d: %04x:%04x\n", i + 1, func_name, dll_name, ordinal, selector, address); break; @@ -335,7 +335,7 @@ FixupSegment(struct w_files * wpnt, int segment_num) address = rep->target2; } - dprintf_fixup(stddeb,"%d: %04.4x:%04.4x\n", + dprintf_fixup(stddeb,"%d: %04x:%04x\n", i + 1, selector, address); break; @@ -349,19 +349,19 @@ FixupSegment(struct w_files * wpnt, int segment_num) * exist. */ dprintf_fixup(stddeb, - "%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ", + "%d: ADDR TYPE %d, TYPE %d, OFFSET %04x, ", i + 1, rep->address_type, rep->relocation_type, rep->offset); - dprintf_fixup(stddeb,"TARGET %04.4x %04.4x\n", + dprintf_fixup(stddeb,"TARGET %04x %04x\n", rep->target1, rep->target2); continue; default: dprintf_fixup(stddeb, - "%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ", + "%d: ADDR TYPE %d, TYPE %d, OFFSET %04x, ", i + 1, rep->address_type, rep->relocation_type, rep->offset); - dprintf_fixup(stddeb,"TARGET %04.4x %04.4x\n", + dprintf_fixup(stddeb,"TARGET %04x %04x\n", rep->target1, rep->target2); free(rep1); return -1; @@ -376,10 +376,10 @@ FixupSegment(struct w_files * wpnt, int segment_num) if (FindDLLTable(dll_name) == NULL) additive = 2; dprintf_fixup(stddeb, - "%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ", + "%d: ADDR TYPE %d, TYPE %d, OFFSET %04x, ", i + 1, rep->address_type, rep->relocation_type, rep->offset); - dprintf_fixup(stddeb,"TARGET %04.4x %04.4x\n", + dprintf_fixup(stddeb,"TARGET %04x %04x\n", rep->target1, rep->target2); dprintf_fixup(stddeb, " Additive = %d\n", additive); } @@ -388,8 +388,8 @@ FixupSegment(struct w_files * wpnt, int segment_num) { case NE_RADDR_OFFSET16: do { - dprintf_fixup(stddeb," %04.4x:%04.4x:%04.4x OFFSET16\n", - (unsigned long) sp >> 16, (int) sp & 0xFFFF, *sp); + dprintf_fixup(stddeb," %04x:%04x:%04x OFFSET16\n", + (unsigned int) sp >> 16, (int) sp & 0xFFFF, *sp); next_addr = *sp; *sp = (unsigned short) address; if (additive == 2) @@ -402,8 +402,8 @@ FixupSegment(struct w_files * wpnt, int segment_num) case NE_RADDR_POINTER32: do { - dprintf_fixup(stddeb," %04.4x:%04.4x:%04.4x POINTER32\n", - (unsigned long) sp >> 16, (int) sp & 0xFFFF, *sp); + dprintf_fixup(stddeb," %04x:%04x:%04x POINTER32\n", + (unsigned int) sp >> 16, (int) sp & 0xFFFF, *sp); next_addr = *sp; *sp = (unsigned short) address; if (additive == 2) @@ -417,8 +417,8 @@ FixupSegment(struct w_files * wpnt, int segment_num) case NE_RADDR_SELECTOR: do { - dprintf_fixup(stddeb," %04.4x:%04.4x:%04.4x SELECTOR\n", - (unsigned long) sp >> 16, (int) sp & 0xFFFF, *sp); + dprintf_fixup(stddeb," %04x:%04x:%04x SELECTOR\n", + (unsigned int) sp >> 16, (int) sp & 0xFFFF, *sp); next_addr = *sp; *sp = (unsigned short) selector; sp = (unsigned short *) ((char *) sel->base_addr + next_addr); @@ -431,11 +431,11 @@ FixupSegment(struct w_files * wpnt, int segment_num) default: dprintf_fixup(stddeb, - "%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ", + "%d: ADDR TYPE %d, TYPE %d, OFFSET %04x, ", i + 1, rep->address_type, rep->relocation_type, rep->offset); dprintf_fixup(stddeb, - "TARGET %04.4x %04.4x\n", rep->target1, rep->target2); + "TARGET %04x %04x\n", rep->target1, rep->target2); free(rep1); return -1; } @@ -447,7 +447,7 @@ FixupSegment(struct w_files * wpnt, int segment_num) int NEunloadImage(struct w_files *wpnt) { - printf("NEunloadImage() called!\n"); + dprintf_fixup(stdnimp, "NEunloadImage() called!\n"); /* free resources, image */ return 1; } @@ -491,13 +491,13 @@ void InitNEDLL(struct w_files *wpnt) ip_reg = wpnt->ne->ne_header->ip; if (cs_reg) { - fprintf(stderr, "Initializing %s, cs:ip %04x:%04x, ds %04x\n", + dprintf_dll(stddeb,"Initializing %s, cs:ip %04x:%04x, ds %04x\n", wpnt->name, cs_reg, ip_reg, ds_reg); rv = CallTo16(cs_reg << 16 | ip_reg, ds_reg); - printf ("rv = %x\n", rv); + dprintf_exec(stddeb,"rv = %x\n", rv); } else - printf("%s skipped\n", wpnt->name); + dprintf_exec(stddeb,"%s skipped\n", wpnt->name); } } diff --git a/loader/ne_resource.c b/loader/ne_resource.c index 25e0b4cd98b..9e665c0285a 100644 --- a/loader/ne_resource.c +++ b/loader/ne_resource.c @@ -14,8 +14,11 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; #include "arch.h" #include "dlls.h" #include "resource.h" - +#include "stddebug.h" /* #define DEBUG_RESOURCE */ +/* #undef DEBUG_RESOURCE */ +#include "debug.h" + static int ResourceFd = -1; static HANDLE ResourceInst = 0; @@ -142,10 +145,8 @@ OpenResourceFile(HANDLE instance) #endif #endif -#ifdef DEBUG_RESOURCE - printf("OpenResourceFile(%04X) // file='%s' hFile=%04X !\n", + dprintf_resource(stddeb, "OpenResourceFile(%04X) // file='%s' hFile=%04X !\n", instance, w->filename, ResourceFd); -#endif return ResourceFd; } @@ -170,22 +171,16 @@ int type_match(int type_id1, int type_id2, int fd, off_t off) } if ((type_id2 & 0x8000) != 0) return 0; -#ifdef DEBUG_RESOURCE - printf("type_compare: type_id2=%04X !\n", type_id2); -#endif + dprintf_resource(stddeb, "type_compare: type_id2=%04X !\n", type_id2); old_pos = lseek(fd, 0, SEEK_CUR); lseek(fd, off + type_id2, SEEK_SET); read(fd, &c, 1); nbytes = CONV_CHAR_TO_LONG (c); -#ifdef DEBUG_RESOURCE - printf("type_compare: namesize=%d\n", nbytes); -#endif + dprintf_resource(stddeb, "type_compare: namesize=%d\n", nbytes); read(fd, name, nbytes); lseek(fd, old_pos, SEEK_SET); name[nbytes] = '\0'; -#ifdef DEBUG_RESOURCE - printf("type_compare: name=`%s'\n", name); -#endif + dprintf_resource(stddeb, "type_compare: name=`%s'\n", name); return strcasecmp((char *) type_id1, name) == 0; } @@ -227,10 +222,8 @@ FindResourceByNumber(struct resource_nameinfo_s *result_p, printf("FindResourceByNumber (%X) bad typeinfo size !\n", resource_id); return -1; } -#ifdef DEBUG_RESOURCE - printf("FindResourceByNumber type=%X count=%d ?=%d searched=%08X\n", + dprintf_resource(stddeb, "FindResourceByNumber type=%X count=%d ?=%ld searched=%08X\n", typeinfo.type_id, typeinfo.count, typeinfo.reserved, type_id); -#endif if (typeinfo.type_id == 0) break; if (type_match(type_id, typeinfo.type_id, ResourceFd, rtoff)) { @@ -245,10 +238,8 @@ FindResourceByNumber(struct resource_nameinfo_s *result_p, printf("FindResourceByNumber (%X) bad nameinfo size !\n", resource_id); return -1; } -#ifdef DEBUG_RESOURCE - printf("FindResource: search type=%X id=%X // type=%X id=%X\n", + dprintf_resource(stddeb, "FindResource: search type=%X id=%X // type=%X id=%X\n", type_id, resource_id, typeinfo.type_id, nameinfo.id); -#endif if (nameinfo.id == resource_id) { memcpy(result_p, &nameinfo, sizeof(nameinfo)); return size_shift; @@ -325,10 +316,8 @@ FindResourceByName(struct resource_nameinfo_s *result_p, printf("FindResourceByName (%s) bad typeinfo size !\n", resource_name); return -1; } -#ifdef DEBUG_RESOURCE - printf("FindResourceByName typeinfo.type_id=%X count=%d type_id=%X\n", + dprintf_resource(stddeb, "FindResourceByName typeinfo.type_id=%X count=%d type_id=%X\n", typeinfo.type_id, typeinfo.count, type_id); -#endif if (typeinfo.type_id == 0) break; if (type_match(type_id, typeinfo.type_id, ResourceFd, rtoff)) { @@ -347,25 +336,19 @@ FindResourceByName(struct resource_nameinfo_s *result_p, /* if ((nameinfo.id & 0x8000) != 0) continue; */ -#ifdef DEBUG_RESOURCE - printf("FindResourceByName // nameinfo.id=%04X !\n", nameinfo.id); -#endif + dprintf_resource(stddeb, "FindResourceByName // nameinfo.id=%04X !\n", nameinfo.id); old_pos = lseek(ResourceFd, 0, SEEK_CUR); new_pos = rtoff + nameinfo.id; lseek(ResourceFd, new_pos, SEEK_SET); read(ResourceFd, &nbytes, 1); -#ifdef DEBUG_RESOURCE - printf("FindResourceByName // namesize=%d !\n", nbytes); -#endif + dprintf_resource(stddeb, "FindResourceByName // namesize=%d !\n", nbytes); nbytes = CONV_CHAR_TO_LONG (nbytes); read(ResourceFd, name, nbytes); lseek(ResourceFd, old_pos, SEEK_SET); name[nbytes] = '\0'; -#ifdef DEBUG_RESOURCE - printf("FindResourceByName type_id=%X (%d of %d) name='%s' resource_name='%s'\n", + dprintf_resource(stddeb, "FindResourceByName type_id=%X (%d of %d) name='%s' resource_name='%s'\n", typeinfo.type_id, i + 1, typeinfo.count, name, resource_name); -#endif if (strcasecmp(name, resource_name) == 0) { memcpy(result_p, &nameinfo, sizeof(nameinfo)); @@ -392,9 +375,8 @@ int GetRsrcCount(HINSTANCE hInst, int type_id) off_t rtoff; if (hInst == 0) return 0; -#ifdef DEBUG_RESOURCE - printf("GetRsrcCount hInst=%04X typename=%08X\n", hInst, type_id); -#endif + dprintf_resource(stddeb, "GetRsrcCount hInst=%04X typename=%08X\n", + hInst, type_id); if (OpenResourceFile(hInst) < 0) return 0; /* @@ -416,10 +398,8 @@ int GetRsrcCount(HINSTANCE hInst, int type_id) printf("GetRsrcCount // bad typeinfo size !\n"); return 0; } -#ifdef DEBUG_RESOURCE - printf("GetRsrcCount // typeinfo.type_id=%X count=%d type_id=%X\n", + dprintf_resource(stddeb, "GetRsrcCount // typeinfo.type_id=%X count=%d type_id=%X\n", typeinfo.type_id, typeinfo.count, type_id); -#endif if (typeinfo.type_id == 0) break; if (type_match(type_id, typeinfo.type_id, ResourceFd, rtoff)) { return typeinfo.count; @@ -440,10 +420,8 @@ NE_FindResource(HANDLE instance, LPSTR resource_name, LPSTR type_name, { int type; -#ifdef DEBUG_RESOURCE - printf("NE_FindResource hInst=%04X typename=%08X resname=%08X\n", + dprintf_resource(stddeb, "NE_FindResource hInst=%04X typename=%p resname=%p\n", instance, type_name, resource_name); -#endif ResourceFd = r->fd; ResourceFileInfo = r->wpnt; diff --git a/loader/pe_image.c b/loader/pe_image.c index 948e8e6990f..78b536b1ed1 100644 --- a/loader/pe_image.c +++ b/loader/pe_image.c @@ -6,6 +6,7 @@ * ftp.microsoft.com:/pub/developer/MSDN/CD8/PEFILE.ZIP */ +#include #include #include #include @@ -41,7 +42,7 @@ char * xmmap(char * vaddr, unsigned int v_size, int prot, int flags, /* Sigh. Alignment must be wrong for mmap. Do this the hard way. */ if(!(flags & MAP_FIXED)) { - vaddr = 0x40000000; + vaddr = (char *)0x40000000; flags |= MAP_FIXED; }; @@ -51,7 +52,7 @@ char * xmmap(char * vaddr, unsigned int v_size, int prot, int flags, return vaddr; }; -dump_exports(struct PE_Export_Directory * pe_exports) +void dump_exports(struct PE_Export_Directory * pe_exports) { char * Module; int i; @@ -60,7 +61,7 @@ dump_exports(struct PE_Export_Directory * pe_exports) u_char ** name, *ename; Module = ((char *) load_addr) + pe_exports->Name; - printf("\n*******EXPORT DATA*******\nModule name is %s, %d functions, %d names\n", + printf("\n*******EXPORT DATA*******\nModule name is %s, %ld functions, %ld names\n", Module, pe_exports->Number_Of_Functions, pe_exports->Number_Of_Names); @@ -73,13 +74,11 @@ dump_exports(struct PE_Export_Directory * pe_exports) for(i=0; i< pe_exports->Number_Of_Functions; i++) { ename = (char *) (((char *) load_addr) + (int) *name++); - printf("%-32s %4d %8.8x\n", ename, *ordinal++, *function++); + printf("%-32s %4d %8.8lx\n", ename, *ordinal++, *function++); } - - return; } -dump_imports(struct PE_Import_Directory *pe_imports) +void dump_imports(struct PE_Import_Directory *pe_imports) { struct PE_Import_Directory * pe_imp; @@ -88,7 +87,7 @@ dump_imports(struct PE_Import_Directory *pe_imports) pe_imp = pe_imports; while (pe_imp->ModuleName) { - char * Module, *Function; + char * Module; struct pe_import_name * pe_name; unsigned int * import_list; char * c; @@ -119,7 +118,7 @@ static void dump_table(struct w_files *wpnt) printf(" Name VSz Vaddr SzRaw Fileadr *Reloc *Lineum #Reloc #Linum Char\n"); for(i=0; i< wpnt->pe->pe_header->coff.NumberOfSections; i++) { - printf("%8s: %4.4x %8.8x %8.8x %8.8x %8.8x %8.8x %4.4x %4.4x %8.8x\n", + printf("%8s: %4.4lx %8.8lx %8.8lx %8.8lx %8.8lx %8.8lx %4.4x %4.4x %8.8lx\n", wpnt->pe->pe_seg[i].Name, wpnt->pe->pe_seg[i].Virtual_Size, wpnt->pe->pe_seg[i].Virtual_Address, diff --git a/loader/pe_resource.c b/loader/pe_resource.c index d82789cdfe1..41fa92d1c1b 100644 --- a/loader/pe_resource.c +++ b/loader/pe_resource.c @@ -18,13 +18,15 @@ #include "peexe.h" #include "dlls.h" #include "resource.h" +#include "stddebug.h" +/* #define DEBUG_RESOURCE */ +/* #undef DEBUG_RESOURCE */ +#include "debug.h" -#define DEBUG_RESOURCE static int find_lang(char *root, struct PE_Resource_Directory *resource, RESOURCE *r) { - int i; struct PE_Directory_Entry *type_dir; struct PE_Resource_Leaf_Entry *leaf; @@ -33,10 +35,8 @@ find_lang(char *root, struct PE_Resource_Directory *resource, RESOURCE *r) /* grab the 1st resource available */ leaf = (struct PE_Resource_Leaf_Entry *) (root + type_dir->OffsetToData); -#ifdef DEBUG_RESOURCE - printf("\t\tPE_findlang: id %8x\n", (int) type_dir->Name); - printf("\t\taddress %d, size %d, language id %d\n", leaf->OffsetToData, leaf->Size, leaf->CodePage); -#endif + 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); @@ -44,11 +44,10 @@ find_lang(char *root, struct PE_Resource_Directory *resource, RESOURCE *r) /* for(i=0; i< resource->NumberOfIdEntries; i++) { leaf = (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)); -#ifdef DEBUG_RESOURCE - printf("\t\tPE_findlang: id %8x\n", (int) type_dir->Name); - printf("\t\t%x %x %x\n", leaf->OffsetToData, leaf->Size, - leaf->CodePage); -#endif + 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++; } */ } @@ -69,9 +68,7 @@ find_resource(char *root, struct PE_Resource_Directory *resource, 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); -#ifdef DEBUG_RESOURCE - printf("\tPE_findresource: name %s\n", res_name); -#endif + dprintf_resource(stddeb, "\tPE_findresource: name %s\n", res_name); if (strcasecmp(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++; @@ -79,9 +76,7 @@ find_resource(char *root, struct PE_Resource_Directory *resource, } else { type_dir += resource->NumberOfNamedEntries; for(i=0; i< resource->NumberOfIdEntries; i++) { -#ifdef DEBUG_RESOURCE - printf("\tPE_findresource: name %8x\n", (int) type_dir->Name); -#endif + 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++; @@ -107,9 +102,8 @@ find_type(struct PE_Resource_Directory *resource, LPSTR resource_name, 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); -#ifdef DEBUG_RESOURCE - printf("PE_findtype: type %s\n", res_name); -#endif + dprintf_resource(stddeb, "PE_findtype: type %s\n", + res_name); if (strcasecmp(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++; @@ -117,9 +111,7 @@ find_type(struct PE_Resource_Directory *resource, LPSTR resource_name, } else { type_dir += resource->NumberOfNamedEntries; for(i=0; i< resource->NumberOfIdEntries; i++) { -#ifdef DEBUG_RESOURCE - printf("PE_findtype: type %8x\n", (int) type_dir->Name); -#endif + 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++; @@ -135,10 +127,8 @@ int PE_FindResource(HANDLE instance, LPSTR resource_name, LPSTR type_name, RESOURCE *r) { -#ifdef DEBUG_RESOURCE - printf("PE_FindResource hInst=%04X typename=%08X resname=%08X\n", + dprintf_resource(stddeb, "PE_FindResource hInst=%04X typename=%08X resname=%08X\n", instance, (int) type_name, (int) resource_name); -#endif if (HIWORD((DWORD)resource_name)) if (resource_name[0] == '#') resource_name = (LPSTR) atoi(resource_name + 1); diff --git a/loader/resource.c b/loader/resource.c index 867c783cb50..f1ed5cbc690 100644 --- a/loader/resource.c +++ b/loader/resource.c @@ -19,10 +19,10 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; #include "dlls.h" #include "resource.h" #include "stddebug.h" -/* #define DEBUG_RESOURCE /* */ -/* #undef DEBUG_RESOURCE /* */ -/* #define DEBUG_ACCEL /* */ -/* #undef DEBUG_ACCEL /* */ +/* #define DEBUG_RESOURCE */ +/* #undef DEBUG_RESOURCE */ +/* #define DEBUG_ACCEL */ +/* #undef DEBUG_ACCEL */ #include "debug.h" #define MIN(a,b) ((a) < (b) ? (a) : (b)) @@ -110,9 +110,8 @@ HANDLE AllocResource(HANDLE instance, HANDLE hResInfo, DWORD dwSize) RESOURCE *r; int image_size; -#ifdef DEBUG_RESOURCE - printf("AllocResource(%04X, %04X, %08X);\n", instance, hResInfo, (int) dwSize); -#endif + dprintf_resource(stddeb, "AllocResource(%04X, %04X, %08X);\n", + instance, hResInfo, (int) dwSize); if (instance == (HANDLE)NULL) instance = hSysRes; @@ -140,9 +139,8 @@ int AccessResource(HANDLE instance, HANDLE hResInfo) int fd; RESOURCE *r; -#ifdef DEBUG_RESOURCE - printf("AccessResource(%04X, %04X);\n", instance, hResInfo); -#endif + dprintf_resource(stddeb, "AccessResource(%04X, %04X);\n", + instance, hResInfo); if (instance == (HANDLE)NULL) instance = hSysRes; @@ -165,9 +163,8 @@ WORD SizeofResource(HANDLE instance, HANDLE hResInfo) RESOURCE *r; int size; -#ifdef DEBUG_RESOURCE - printf("SizeofResource(%04X, %04X);\n", instance, hResInfo); -#endif + dprintf_resource(stddeb, "SizeofResource(%04X, %04X);\n", + instance, hResInfo); if (instance == (HANDLE)NULL) instance = hSysRes; @@ -191,9 +188,7 @@ HANDLE LoadResource(HANDLE instance, HANDLE hResInfo) void *image; HANDLE h; -#ifdef DEBUG_RESOURCE - printf("LoadResource(%04X, %04X);\n", instance, hResInfo); -#endif + dprintf_resource(stddeb, "LoadResource(%04X, %04X);\n", instance, hResInfo); if (instance == (HANDLE)NULL) instance = hSysRes; @@ -233,9 +228,7 @@ HANDLE FreeResource(HANDLE hResData) { RESOURCE *r, *rp; -#ifdef DEBUG_RESOURCE - printf("FreeResource: handle %04x\n", hResData); -#endif + dprintf_resource(stddeb, "FreeResource: handle %04x\n", hResData); for (r = rp = Top; r ; r = r->next) { if (r->rsc_mem == hResData) { @@ -269,9 +262,8 @@ HBITMAP ConvertCoreBitmap( HDC hdc, BITMAPCOREHEADER * image ) HBITMAP hbitmap; char * bits; int i, size, n_colors; - + n_colors = 1 << image->bcBitCount; - if (image->bcBitCount < 24) { size = sizeof(BITMAPINFOHEADER) + n_colors * sizeof(RGBQUAD); @@ -337,10 +329,8 @@ RSC_LoadResource(int instance, LPSTR rsc_name, LPSTR type, int *image_size_ret) if (instance == (HANDLE)NULL) instance = hSysRes; -#ifdef DEBUG_RESOURCE - printf("RSC_LoadResource: instance = %04x, name = %08x, type = %08x\n", + dprintf_resource(stddeb, "RSC_LoadResource: instance = %04x, name = %08x, type = %08x\n", instance, (int) rsc_name, (int) type); -#endif if ((hResInfo = FindResource(instance, rsc_name, (LPSTR) type)) == (HANDLE) NULL) { return (HANDLE)NULL; @@ -371,6 +361,7 @@ HICON LoadIcon(HANDLE instance, LPSTR icon_name) HDC hMemDC2; HDC hdc; int image_size; + HBITMAP hbmpOld1, hbmpOld2; #ifdef DEBUG_RESOURCE printf("LoadIcon(%04X", instance); @@ -458,9 +449,11 @@ HICON LoadIcon(HANDLE instance, LPSTR icon_name) GlobalFree(rsc_mem); hMemDC = CreateCompatibleDC(hdc); hMemDC2 = CreateCompatibleDC(hdc); - SelectObject(hMemDC, lpico->hBitmap); - SelectObject(hMemDC2, lpico->hBitMask); - BitBlt(hMemDC, 0, 0, bih->biWidth, bih->biHeight, hMemDC2, 0, 0, SRCINVERT); + hbmpOld1 = SelectObject(hMemDC, lpico->hBitmap); + hbmpOld2 = SelectObject(hMemDC2, lpico->hBitMask); + BitBlt(hMemDC, 0, 0, bih->biWidth, bih->biHeight, hMemDC2, 0, 0,SRCINVERT); + SelectObject( hMemDC, hbmpOld1 ); + SelectObject( hMemDC2, hbmpOld2 ); DeleteDC(hMemDC); DeleteDC(hMemDC2); ReleaseDC(GetDesktopWindow(), hdc); @@ -479,13 +472,11 @@ HICON CreateIcon(HANDLE hInstance, int nWidth, int nHeight, HICON hIcon; ICONALLOC *lpico; -#ifdef DEBUG_RESOURCE - printf("CreateIcon: hInstance = %04x, nWidth = %08x, nHeight = %08x \n", + dprintf_resource(stddeb, "CreateIcon: hInstance = %04x, nWidth = %08x, nHeight = %08x \n", hInstance, nWidth, nHeight); - printf(" nPlanes = %04x, nBitsPixel = %04x,",nPlanes, nBitsPixel); - printf(" lpANDbits= %04x, lpXORbits = %04x, \n", (int)lpANDbits, + dprintf_resource(stddeb, " nPlanes = %04x, nBitsPixel = %04x,",nPlanes, nBitsPixel); + dprintf_resource(stddeb, " lpANDbits= %04x, lpXORbits = %04x, \n", (int)lpANDbits, (int)lpXORbits); -#endif if (hInstance == (HANDLE)NULL) { printf("CreateIcon / hInstance %04x not Found!\n",hInstance); @@ -522,9 +513,7 @@ HICON CreateIcon(HANDLE hInstance, int nWidth, int nHeight, } GlobalUnlock(hIcon); -#ifdef DEBUG_RESOURCE - printf("CreateIcon Alloc hIcon=%X\n", hIcon); -#endif + dprintf_resource(stddeb, "CreateIcon Alloc hIcon=%X\n", hIcon); return hIcon; } @@ -612,9 +601,7 @@ int TranslateAccelerator(HWND hWnd, HANDLE hAccel, LPMSG msg) msg->message != WM_KEYUP && msg->message != WM_CHAR) return 0; -#ifdef DEBUG_ACCEL - printf("TranslateAccelerators hAccel=%04X !\n", hAccel); -#endif + dprintf_accel(stddeb, "TranslateAccelerators hAccel=%04X !\n", hAccel); lpAccelTbl = (LPACCELHEADER)GlobalLock(hAccel); for (i = 0; i < lpAccelTbl->wCount; i++) { @@ -667,10 +654,8 @@ LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen) int string_num; int i; -#ifdef DEBUG_RESOURCE - printf("LoadString: instance = %04x, id = %d, buffer = %08x, " + dprintf_resource(stddeb, "LoadString: instance = %04x, id = %d, buffer = %08x, " "length = %d\n", instance, resource_id, (int) buffer, buflen); -#endif hmem = RSC_LoadResource(instance, (char *) ((resource_id >> 4) + 1), (LPSTR) NE_RSCTYPE_STRING, &rsc_size); @@ -760,7 +745,7 @@ LoadBitmap(HANDLE instance, LPSTR bmp_name) return 0; } lp = (long *) GlobalLinearLock(rsc_mem); - if (!(hdc = GetDC(0))) lp == NULL; + if (!(hdc = GetDC(0))) lp = NULL; if (lp == NULL) { GlobalFree(rsc_mem); diff --git a/loader/selector.c b/loader/selector.c index b38feeb3395..eb17a27734c 100644 --- a/loader/selector.c +++ b/loader/selector.c @@ -29,10 +29,11 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; #include "wine.h" #include "windows.h" #include "prototypes.h" +#include "stddebug.h" +/* #define DEBUG_SELECTORS */ +/* #undef DEBUG_SELECTORS */ #include "debug.h" -/* #define DEBUG_SELECTORS /* */ -/* #undef DEBUG_SELECTORS /* */ #ifdef linux #define DEV_ZERO @@ -68,6 +69,9 @@ extern char WindowsPath[256]; extern char **Argv; extern int Argc; extern char **environ; + +unsigned int +GetEntryPointFromOrdinal(struct w_files * wpnt, int ordinal); /********************************************************************** * FindUnusedSelectors @@ -160,7 +164,7 @@ IPCCopySelector(int i_old, unsigned long new, int swap_type) */ if (s_old->shm_key == -1) { - s_old->shm_key = shmget(IPC_PRIVATE, s_old->length, IPC_CREAT); + s_old->shm_key = shmget(IPC_PRIVATE, s_old->length, IPC_CREAT | 0600); if (s_old->shm_key == -1) { if (s_new) { @@ -232,7 +236,7 @@ IPCCopySelector(int i_old, unsigned long new, int swap_type) */ WORD AllocSelector(WORD old_selector) { - SEGDESC *s_new, *s_old; + SEGDESC *s_new; int i_new, i_old; int selector; @@ -506,9 +510,8 @@ CreateNewSegments(int code_flag, int read_only, int length, int n_segments) i = FindUnusedSelectors(n_segments); -#ifdef DEBUG_SELECTORS - fprintf(stddeb, "Using %d segments starting at index %d.\n", n_segments, i); -#endif + dprintf_selectors(stddeb, "Using %d segments starting at index %d.\n", + n_segments, i); /* * Fill in selector info. @@ -661,10 +664,6 @@ unsigned int GetEntryDLLOrdinal(char * dll_name, int ordinal, int * sel, unsigned int GetEntryPointFromOrdinal(struct w_files * wpnt, int ordinal) { - int fd = wpnt->fd; - struct mz_header_s *mz_header = wpnt->mz_header; - struct ne_header_s *ne_header = wpnt->ne->ne_header; - union lookup entry_tab_pointer; struct entry_tab_header_s *eth; struct entry_tab_movable_s *etm; @@ -771,11 +770,9 @@ CreateEnvironment(void) /* * Display environment */ -#ifdef DEBUG_SELECTORS - fprintf(stddeb, "Environment at %08.8x\n", s->base_addr); + dprintf_selectors(stddeb, "Environment at %08.8x\n", s->base_addr); for (p = s->base_addr; *p; p += strlen(p) + 1) - fprintf(stddeb, " %s\n", p); -#endif + dprintf_selectors(stddeb, " %s\n", p); return s; } @@ -848,7 +845,7 @@ CreateSelectors(struct w_files * wpnt) int fd = wpnt->fd; struct ne_segment_table_entry_s *seg_table = wpnt->ne->seg_table; struct ne_header_s *ne_header = wpnt->ne->ne_header; - SEGDESC *selectors, *s, *stmp; + SEGDESC *selectors, *s; unsigned short auto_data_sel; int contents, read_only; int SelectorTableLength; @@ -992,7 +989,6 @@ CreateSelectors(struct w_files * wpnt) void FixupFunctionPrologs(struct w_files * wpnt) { - struct mz_header_s *mz_header = wpnt->mz_header; struct ne_header_s *ne_header = wpnt->ne->ne_header; union lookup entry_tab_pointer; struct entry_tab_header_s *eth; @@ -1059,6 +1055,7 @@ FixupFunctionPrologs(struct w_files * wpnt) DWORD GetSelectorBase(WORD wSelector) { fprintf(stdnimp, "GetSelectorBase(selector %4X) stub!\n", wSelector); + return 0; } /*********************************************************************** @@ -1066,7 +1063,7 @@ DWORD GetSelectorBase(WORD wSelector) */ void SetSelectorBase(WORD wSelector, DWORD dwBase) { - fprintf(stdnimp, "SetSelectorBase(selector %4X, base %8X) stub!\n", + fprintf(stdnimp, "SetSelectorBase(selector %4X, base %8lX) stub!\n", wSelector, dwBase); } @@ -1085,7 +1082,7 @@ DWORD GetSelectorLimit(WORD wSelector) */ void SetSelectorLimit(WORD wSelector, DWORD dwLimit) { - fprintf(stdnimp, "SetSelectorLimit(selector %4X, base %8X) stub!\n", + fprintf(stdnimp, "SetSelectorLimit(selector %4X, base %8lX) stub!\n", wSelector, dwLimit); } diff --git a/loader/signal.c b/loader/signal.c index 24256e41d6f..aa5f467a6b5 100644 --- a/loader/signal.c +++ b/loader/signal.c @@ -4,6 +4,7 @@ #include #include #include +#include #if defined(__NetBSD__) || defined(__FreeBSD__) #include @@ -102,6 +103,9 @@ static void win_fault(int signal, int code, struct sigcontext *scp) { #endif unsigned char * instr; +#if !(defined (linux) || defined (__NetBSD__)) + int i, *dump; +#endif /* First take care of a few preliminaries */ #ifdef linux @@ -132,7 +136,7 @@ static void win_fault(int signal, int code, struct sigcontext *scp) { #endif fprintf(stderr, - "Segmentation fault in Wine program (%x:%x)." + "Segmentation fault in Wine program (%x:%lx)." " Please debug\n", scp->sc_cs, scp->sc_eip); goto oops; @@ -195,7 +199,7 @@ static void win_fault(int signal, int code, struct sigcontext *scp) XUngrabPointer(display, CurrentTime); XUngrabServer(display); XFlush(display); - fprintf(stderr,"In win_fault %x:%x\n", scp->sc_cs, scp->sc_eip); + fprintf(stderr,"In win_fault %x:%lx\n", scp->sc_cs, scp->sc_eip); #if defined(linux) || defined(__NetBSD__) wine_debug(signal, scp); /* Enter our debugger */ #else @@ -278,4 +282,34 @@ int init_wine_signals(void) #endif } +static sigjmp_buf segv_jmpbuf; + +static void +segv_handler() +{ + siglongjmp(segv_jmpbuf, 1); +} + +int +test_memory( char *p, int write ) +{ + int ret = FALSE; + struct sigaction new_act; + struct sigaction old_act; + + memset(&new_act, 0, sizeof new_act); + new_act.sa_handler = segv_handler; + if (sigsetjmp( segv_jmpbuf, 1 ) == 0) { + char c = 100; + if (sigaction(SIGSEGV, &new_act, &old_act) < 0) + perror("sigaction"); + c = *p; + if (write) + *p = c; + ret = TRUE; + } + wine_sigaction(SIGSEGV, &old_act, NULL); + return ret; +} + #endif /* ifndef WINELIB */ diff --git a/loader/task.c b/loader/task.c index d43e4048b83..693612fbe57 100644 --- a/loader/task.c +++ b/loader/task.c @@ -12,13 +12,12 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994"; #include "windows.h" #include "wine.h" #include "task.h" +#include "stddebug.h" +/* #define DEBUG_TASK */ +/* #undef DEBUG_TASK */ #include "debug.h" -/* #define DEBUG_TASK /* */ -/* #undef DEBUG_TASK /* */ - - static LPWINETASKENTRY lpTaskList = NULL; static int nTaskCount = 0; @@ -29,18 +28,14 @@ HTASK GetCurrentTask() { LPWINETASKENTRY lpTask = lpTaskList; int pid = getpid(); -#ifdef DEBUG_TASK - fprintf(stddeb,"GetCurrentTask() // unix_pid=%08X !\n", pid); -#endif + dprintf_task(stddeb,"GetCurrentTask() // unix_pid=%08X !\n", pid); if (lpTask == NULL) return 0; while (TRUE) { if (lpTask->unix_pid == pid) break; if (lpTask->lpNextTask == NULL) return 0; lpTask = lpTask->lpNextTask; } -#ifdef DEBUG_TASK - fprintf(stddeb,"GetCurrentTask() returned hTask=%04X !\n", lpTask->te.hTask); -#endif + dprintf_task(stddeb,"GetCurrentTask() returned hTask=%04X !\n", lpTask->te.hTask); return lpTask->te.hTask; } @@ -50,9 +45,7 @@ HTASK GetCurrentTask() */ WORD GetNumTasks() { -#ifdef DEBUG_TASK - fprintf(stddeb,"GetNumTasks() returned %d !\n", nTaskCount); -#endif + dprintf_task(stddeb,"GetNumTasks() returned %d !\n", nTaskCount); return nTaskCount; } @@ -65,23 +58,17 @@ HTASK GetWindowTask(HWND hWnd) HWND *wptr; int count; LPWINETASKENTRY lpTask = lpTaskList; -#ifdef DEBUG_TASK - fprintf(stddeb,"GetWindowTask(%04X) !\n", hWnd); -#endif + dprintf_task(stddeb,"GetWindowTask(%04X) !\n", hWnd); while (lpTask != NULL) { wptr = lpTask->lpWndList; if (wptr != NULL) { count = 0; while (++count < MAXWIN_PER_TASK) { -#ifdef DEBUG_TASK - fprintf(stddeb,"GetWindowTask // searching %04X %04X !\n", + dprintf_task(stddeb,"GetWindowTask // searching %04X %04X !\n", lpTask->te.hTask, *(wptr)); -#endif if (*(wptr) == hWnd) { -#ifdef DEBUG_TASK - fprintf(stddeb,"GetWindowTask(%04X) found hTask=%04X !\n", + dprintf_task(stddeb,"GetWindowTask(%04X) found hTask=%04X !\n", hWnd, lpTask->te.hTask); -#endif return lpTask->te.hTask; } wptr++; @@ -102,30 +89,22 @@ BOOL EnumTaskWindows(HANDLE hTask, FARPROC lpEnumFunc, LONG lParam) BOOL bRet; int count = 0; LPWINETASKENTRY lpTask = lpTaskList; -#ifdef DEBUG_TASK - fprintf(stddeb,"EnumTaskWindows(%04X, %08X, %08X) !\n", hTask, lpEnumFunc, lParam); -#endif + dprintf_task(stddeb,"EnumTaskWindows(%04X, %08X, %08X) !\n", hTask, lpEnumFunc, lParam); while (TRUE) { if (lpTask->te.hTask == hTask) break; if (lpTask == NULL) { -#ifdef DEBUG_TASK - fprintf(stddeb,"EnumTaskWindows // hTask=%04X not found !\n", hTask); -#endif + dprintf_task(stddeb,"EnumTaskWindows // hTask=%04X not found !\n", hTask); return FALSE; } lpTask = lpTask->lpNextTask; } -#ifdef DEBUG_TASK - fprintf(stddeb,"EnumTaskWindows // found hTask=%04X !\n", hTask); -#endif + dprintf_task(stddeb,"EnumTaskWindows // found hTask=%04X !\n", hTask); wptr = lpTask->lpWndList; if (wptr == NULL) return FALSE; if (lpEnumFunc == NULL) return FALSE; while ((hWnd = *(wptr++)) != 0) { if (++count >= MAXWIN_PER_TASK) return FALSE; -#ifdef DEBUG_TASK - fprintf(stddeb,"EnumTaskWindows // hWnd=%04X count=%d !\n", hWnd, count); -#endif + dprintf_task(stddeb,"EnumTaskWindows // hWnd=%04X count=%d !\n", hWnd, count); #ifdef WINELIB bRet = (*lpEnumFunc)(hWnd, lParam); #else @@ -158,9 +137,7 @@ HANDLE CreateNewTask(HINSTANCE hInst, HTASK hTaskParent) } hTask = GlobalAlloc(GMEM_MOVEABLE, sizeof(WINETASKENTRY)); lpNewTask = (LPWINETASKENTRY) GlobalLock(hTask); -#ifdef DEBUG_TASK - fprintf(stddeb,"CreateNewTask entry allocated %08X\n", lpNewTask); -#endif + dprintf_task(stddeb,"CreateNewTask entry allocated %08X\n", lpNewTask); if (lpNewTask == NULL) return 0; if (lpTaskList == NULL) { lpTaskList = lpNewTask; @@ -191,10 +168,8 @@ HANDLE CreateNewTask(HINSTANCE hInst, HTASK hTaskParent) lpNewTask->lpWndList = (HWND *) malloc(MAXWIN_PER_TASK * sizeof(HWND)); if (lpNewTask->lpWndList != NULL) memset((LPSTR)lpNewTask->lpWndList, 0, MAXWIN_PER_TASK * sizeof(HWND)); -#ifdef DEBUG_TASK - fprintf(stddeb,"CreateNewTask // unix_pid=%08X return hTask=%04X\n", + dprintf_task(stddeb,"CreateNewTask // unix_pid=%08X return hTask=%04X\n", lpNewTask->unix_pid, hTask); -#endif GlobalUnlock(hTask); nTaskCount++; return hTask; @@ -209,9 +184,7 @@ BOOL AddWindowToTask(HTASK hTask, HWND hWnd) HWND *wptr; int count = 0; LPWINETASKENTRY lpTask = lpTaskList; -#ifdef DEBUG_TASK - fprintf(stddeb,"AddWindowToTask(%04X, %04X); !\n", hTask, hWnd); -#endif + dprintf_task(stddeb,"AddWindowToTask(%04X, %04X); !\n", hTask, hWnd); while (TRUE) { if (lpTask->te.hTask == hTask) break; if (lpTask == NULL) { @@ -227,9 +200,7 @@ BOOL AddWindowToTask(HTASK hTask, HWND hWnd) wptr++; } *wptr = hWnd; -#ifdef DEBUG_TASK - fprintf(stddeb,"AddWindowToTask // window added, count=%d !\n", count); -#endif + dprintf_task(stddeb,"AddWindowToTask // window added, count=%d !\n", count); return TRUE; } @@ -242,9 +213,7 @@ BOOL RemoveWindowFromTask(HTASK hTask, HWND hWnd) HWND *wptr; int count = 0; LPWINETASKENTRY lpTask = lpTaskList; -#ifdef DEBUG_TASK - fprintf(stddeb,"RemoveWindowToTask(%04X, %04X); !\n", hTask, hWnd); -#endif + dprintf_task(stddeb,"RemoveWindowFromTask (%04X, %04X); !\n", hTask, hWnd); while (TRUE) { if (lpTask->te.hTask == hTask) break; if (lpTask == NULL) { @@ -264,17 +233,13 @@ BOOL RemoveWindowFromTask(HTASK hTask, HWND hWnd) if (++count >= MAXWIN_PER_TASK) return FALSE; wptr++; } -#ifdef DEBUG_TASK - fprintf(stddeb,"RemoveWindowFromTask // window removed, count=%d !\n", --count); -#endif + dprintf_task(stddeb,"RemoveWindowFromTask // window removed, count=%d !\n", --count); return TRUE; } BOOL TaskFirst(LPTASKENTRY lpTask) { -#ifdef DEBUG_TASK - fprintf(stddeb,"TaskFirst(%8x)\n", (int) lpTask); -#endif + dprintf_task(stddeb,"TaskFirst(%8x)\n", (int) lpTask); if (lpTaskList) { memcpy(lpTask, &lpTaskList->te, lpTask->dwSize); return TRUE; @@ -285,9 +250,7 @@ BOOL TaskFirst(LPTASKENTRY lpTask) BOOL TaskNext(LPTASKENTRY lpTask) { LPWINETASKENTRY list; -#ifdef DEBUG_TASK - fprintf(stddeb,"TaskNext(%8x)\n", (int) lpTask); -#endif + dprintf_task(stddeb,"TaskNext(%8x)\n", (int) lpTask); list = lpTaskList; while (list) { if (list->te.hTask == lpTask->hTask) { @@ -306,9 +269,7 @@ BOOL TaskNext(LPTASKENTRY lpTask) BOOL TaskFindHandle(LPTASKENTRY lpTask, HTASK hTask) { static LPWINETASKENTRY list; -#ifdef DEBUG_TASK - fprintf(stddeb,"TaskFindHandle(%8x,%4x)\n", (int) lpTask, hTask); -#endif + dprintf_task(stddeb,"TaskFindHandle(%8x,%4x)\n", (int) lpTask, hTask); list = lpTaskList; while (list) { if (list->te.hTask == hTask) { diff --git a/memory/global.c b/memory/global.c index 8ab7d2e8151..9450c956c5b 100644 --- a/memory/global.c +++ b/memory/global.c @@ -196,9 +196,15 @@ GlobalAlloc(unsigned int flags, unsigned long size) g = GlobalGetFreeSegments(flags, segments); if (g == NULL) + { + dprintf_heap(stddeb, "==> NULL\n"); return 0; + } else + { + dprintf_heap(stddeb, "==> %04x\n",g->handle); return g->handle; + } } /* * Otherwise we just need a little piece of a segment. @@ -226,7 +232,10 @@ GlobalAlloc(unsigned int flags, unsigned long size) { g = GlobalGetFreeSegments(0, 1); if (g == NULL) + { + dprintf_heap(stddeb, "==> Null\n"); return 0; + } g->handle = 0; g->sequence = 0; @@ -235,7 +244,10 @@ GlobalAlloc(unsigned int flags, unsigned long size) m = HEAP_Alloc((MDESC **) g->addr, flags & GLOBAL_FLAGS_ZEROINIT, size); if (m == NULL) + { + dprintf_heap(stddeb, "==> Null\n"); return 0; + } } /* @@ -449,7 +461,7 @@ GlobalHandle(unsigned int selector) if (g->handle == selector) { if (g->sequence > 0) - return g->handle; + return MAKELONG(g->handle, selector); else { fprintf(stderr, "Attempt to get a handle " @@ -458,7 +470,7 @@ GlobalHandle(unsigned int selector) } } } - + dprintf_heap(stddeb, "GlobalHandle ==> Null\n"); return 0; } @@ -820,6 +832,65 @@ BOOL MemManInfo(LPMEMMANINFO lpmmi) */ LONG SetSwapAreaSize( WORD size ) { - printf( "STUB: SetSwapAreaSize(%d)\n", size ); + dprintf_heap(stdnimp, "STUB: SetSwapAreaSize(%d)\n", size ); return MAKELONG( size, 0xffff ); } + +/*********************************************************************** + * IsBadCodePtr (KERNEL.336) + */ +BOOL IsBadCodePtr( FARPROC lpfn ) +{ + printf( "STUB: IsBadCodePtr(%p)\n", lpfn ); + return FALSE; +} + +/*********************************************************************** + * IsBadHugeWritePtr (KERNEL.347) + */ +BOOL IsBadHugeWritePtr( const char *lp, DWORD cb ) +{ + return !test_memory(&lp[cb-1], TRUE); +} + +/*********************************************************************** + * IsBadWritePtr (KERNEL.335) + */ +BOOL IsBadWritePtr( const char *lp, DWORD cb ) +{ + if ((0xffff & (unsigned int) lp) + cb > 0xffff) + return TRUE; + return !test_memory(&lp[cb-1], TRUE); +} + +/*********************************************************************** + * IsBadReadPtr (KERNEL.334) + */ +BOOL IsBadReadPtr( const char *lp, DWORD cb ) +{ + if ((0xffff & (unsigned int) lp) + cb > 0xffff) + return TRUE; + return !test_memory(&lp[cb-1], FALSE); +} + +/*********************************************************************** + * IsBadHugeReadPtr (KERNEL.346) + */ +BOOL IsBadHugeReadPtr( const char *lp, DWORD cb ) +{ + if ((0xffff & (unsigned int) lp) + cb > 0xffff) + return TRUE; + return !test_memory(&lp[cb-1], FALSE); +} + +/*********************************************************************** + * IsBadStringPtr (KERNEL.337) + */ +BOOL IsBadStringPtr( const char *lp, UINT cb ) +{ + if (!IsBadReadPtr(lp, cb+1)) + return FALSE; + if (lp[cb]) + return FALSE; + return TRUE; +} diff --git a/memory/linear.c b/memory/linear.c index 1bceeaacb52..1ebb17b0311 100644 --- a/memory/linear.c +++ b/memory/linear.c @@ -164,7 +164,7 @@ GlobalLinearUnlock(unsigned int block) } /**********************************************************************/ -LinearTest() +void LinearTest() { #if 0 unsigned int handle; diff --git a/misc/Imakefile b/misc/Imakefile index 3bd175fdb98..c5bdec95621 100644 --- a/misc/Imakefile +++ b/misc/Imakefile @@ -7,6 +7,7 @@ SRCS = \ atom.c \ clipboard.c \ comm.c \ + commdlg.c \ dos_fs.c \ driver.c \ exec.c \ @@ -15,8 +16,10 @@ SRCS = \ keyboard.c \ lstr.c \ main.c \ + mcianim.c \ mcicda.c \ message.c \ + midi.c \ mmaux.c \ mmsystem.c \ network.c \ diff --git a/misc/audio.c b/misc/audio.c index 1aad3cd845b..42e63ee5ce3 100644 --- a/misc/audio.c +++ b/misc/audio.c @@ -1,4 +1,4 @@ -/* +/* * Sample Wine Driver for Linux * * Copyright 1994 Martin Ayotte @@ -11,6 +11,8 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994"; #ifdef BUILTIN_MMSYSTEM +#define EMULATE_SB16 + #include #include #include @@ -344,7 +346,7 @@ DWORD WAVE_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms) end = lpParms->dwTo; dprintf_mciwave(stddeb,"WAVE_mciPlay // MCI_TO=%d \n", end); } -/* +/**/ if (dwFlags & MCI_NOTIFY) { dprintf_mciwave(stddeb, "WAVE_mciPlay // MCI_NOTIFY %08X !\n", lpParms->dwCallback); @@ -360,7 +362,7 @@ DWORD WAVE_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms) return 0; } } -*/ +/**/ lpWaveHdr = &MCIWavDev[wDevID].WaveHdr; lpWaveHdr->lpData = (LPSTR) malloc(64000); lpWaveHdr->dwBufferLength = 32000; @@ -719,7 +721,7 @@ DWORD WAVE_mciGetDevCaps(UINT wDevID, DWORD dwFlags, lpParms->dwReturn = TRUE; break; case MCI_GETDEVCAPS_CAN_SAVE: - lpParms->dwReturn = FALSE; + lpParms->dwReturn = TRUE; break; case MCI_WAVE_GETDEVCAPS_INPUTS: lpParms->dwReturn = 1; @@ -752,7 +754,8 @@ DWORD WAVE_mciInfo(UINT wDevID, DWORD dwFlags, LPMCI_INFO_PARMS lpParms) lpParms->lpstrReturn = "Linux Sound System 0.5"; break; case MCI_INFO_FILE: - lpParms->lpstrReturn = "FileName"; + lpParms->lpstrReturn = + (LPSTR)MCIWavDev[wDevID].openParms.lpstrElementName; break; case MCI_WAVE_INPUT: lpParms->lpstrReturn = "Linux Sound System 0.5"; @@ -793,12 +796,19 @@ DWORD wodGetDevCaps(WORD wDevID, LPWAVEOUTCAPS lpCaps, DWORD dwSize) if (lpCaps == NULL) return MMSYSERR_NOTENABLED; audio = open (SOUND_DEV, O_WRONLY, 0); if (audio == -1) return MMSYSERR_NOTENABLED; - lpCaps->wMid = 0xFF; /* Manufac ID */ - lpCaps->wPid = 0x01; /* Product ID */ - strcpy(lpCaps->szPname, "Linux WAV Driver"); - lpCaps->dwFormats = 0; - lpCaps->dwSupport = 0; +#ifdef EMULATE_SB16 + lpCaps->wMid = 0x0002; + lpCaps->wPid = 0x0104; + strcpy(lpCaps->szPname, "SB16 Wave Out"); +#else + lpCaps->wMid = 0x00FF; /* Manufac ID */ + lpCaps->wPid = 0x0001; /* Product ID */ + strcpy(lpCaps->szPname, "Linux WAVOUT Driver"); +#endif + lpCaps->dwFormats = 0x00000000; + lpCaps->dwSupport = WAVECAPS_VOLUME; lpCaps->wChannels = (IOCTL(audio, SNDCTL_DSP_STEREO, dsp_stereo) != 0) ? 1 : 2; + if (lpCaps->wChannels > 1) lpCaps->dwSupport |= WAVECAPS_LRVOLUME; bytespersmpl = (IOCTL(audio, SNDCTL_DSP_SAMPLESIZE, samplesize) != 0) ? 1 : 2; smplrate = 44100; if (IOCTL(audio, SNDCTL_DSP_SPEED, smplrate) == 0) { @@ -1223,10 +1233,16 @@ DWORD widGetDevCaps(WORD wDevID, LPWAVEINCAPS lpCaps, DWORD dwSize) if (lpCaps == NULL) return MMSYSERR_NOTENABLED; audio = open (SOUND_DEV, O_RDONLY, 0); if (audio == -1) return MMSYSERR_NOTENABLED; - lpCaps->wMid = 0xFF; /* Manufac ID */ - lpCaps->wPid = 0x01; /* Product ID */ - strcpy(lpCaps->szPname, "Linux WAV Driver"); - lpCaps->dwFormats = 0; +#ifdef EMULATE_SB16 + lpCaps->wMid = 0x0002; + lpCaps->wPid = 0x0004; + strcpy(lpCaps->szPname, "SB16 Wave Out"); +#else + lpCaps->wMid = 0x00FF; /* Manufac ID */ + lpCaps->wPid = 0x0001; /* Product ID */ + strcpy(lpCaps->szPname, "Linux WAVIN Driver"); +#endif + lpCaps->dwFormats = 0x00000000; lpCaps->wChannels = (IOCTL(audio, SNDCTL_DSP_STEREO, dsp_stereo) != 0) ? 1 : 2; bytespersmpl = (IOCTL(audio, SNDCTL_DSP_SAMPLESIZE, samplesize) != 0) ? 1 : 2; smplrate = 44100; @@ -1681,26 +1697,4 @@ DWORD widMessage(WORD wDevID, WORD wMsg, DWORD dwUser, } -/*-----------------------------------------------------------------------*/ - - - -/************************************************************************** -* midMessage [sample driver] -*/ -DWORD midMessage(WORD wDevID, WORD wMsg, DWORD dwUser, - DWORD dwParam1, DWORD dwParam2) -{ - return MMSYSERR_NOTENABLED; -} - -/************************************************************************** -* modMessage [sample driver] -*/ -DWORD modMessage(WORD wDevID, WORD wMsg, DWORD dwUser, - DWORD dwParam1, DWORD dwParam2) -{ - return MMSYSERR_NOTENABLED; -} - #endif /* #ifdef BUILTIN_MMSYSTEM */ diff --git a/misc/clipboard.c b/misc/clipboard.c index ad2d99a1a38..391031457ce 100644 --- a/misc/clipboard.c +++ b/misc/clipboard.c @@ -13,6 +13,8 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994"; #include #include #include +#include +#include #include "prototypes.h" #include "heap.h" #include "win.h" @@ -35,6 +37,8 @@ typedef CLIPFORMAT FAR* LPCLIPFORMAT; static HWND hWndClipboardOwner = 0; static HWND hWndViewer = 0; static WORD LastRegFormat = 0xC000; +static Bool wait_for_selection = False; +static Bool wineOwnsSelection = False; CLIPFORMAT ClipFormats[12] = { { CF_TEXT, 1, "Text", (HANDLE)NULL, 0, NULL, &ClipFormats[1] }, @@ -91,6 +95,11 @@ BOOL EmptyClipboard() } lpFormat = lpFormat->NextFormat; } + if(wineOwnsSelection){ + dprintf_clipboard(stddeb,"Losing selection\n"); + wineOwnsSelection=False; + XSetSelectionOwner(display,XA_PRIMARY,None,CurrentTime); + } return TRUE; } @@ -119,6 +128,11 @@ HANDLE SetClipboardData(WORD wFormat, HANDLE hData) if (lpFormat->wFormatID == wFormat) break; lpFormat = lpFormat->NextFormat; } + /* doc says we shouldn't use CurrentTime */ + /* should we become owner of CLIPBOARD as well? */ + XSetSelectionOwner(display,XA_PRIMARY,WIN_GetXWindow(hWndClipboardOwner),CurrentTime); + wineOwnsSelection = True; + dprintf_clipboard(stddeb,"Getting selection\n"); if (lpFormat->hData != 0) GlobalFree(lpFormat->hData); lpFormat->hData = hData; return lpFormat->hData; @@ -132,6 +146,15 @@ HANDLE GetClipboardData(WORD wFormat) { LPCLIPFORMAT lpFormat = ClipFormats; dprintf_clipboard(stddeb,"GetClipboardData(%04X) !\n", wFormat); + if(wFormat == CF_TEXT && !wineOwnsSelection) + { wait_for_selection=True; + dprintf_clipboard(stddeb,"Requesting selection\n"); + XConvertSelection(display,XA_PRIMARY,XA_STRING, + XInternAtom(display,"PRIMARY_TEXT",False), + WIN_GetXWindow(hWndClipboardOwner),CurrentTime); + /* TODO: need time-out for broken clients */ + while(wait_for_selection)MSG_WaitXEvent(-1); + } while(TRUE) { if (lpFormat == NULL) return 0; if (lpFormat->wFormatID == wFormat) break; @@ -289,6 +312,8 @@ BOOL IsClipboardFormatAvailable(WORD wFormat) { LPCLIPFORMAT lpFormat = ClipFormats; dprintf_clipboard(stddeb,"IsClipboardFormatAvailable(%04X) !\n", wFormat); + if(wFormat == CF_TEXT) /* obtain selection as text if possible */ + return GetClipboardData(CF_TEXT)!=0; while(TRUE) { if (lpFormat == NULL) return FALSE; if (lpFormat->wFormatID == wFormat) break; @@ -319,4 +344,62 @@ int GetPriorityClipboardFormat(WORD FAR *lpPriorityList, short nCount) } +/************************************************************************** + * CLIPBOARD_ReadSelection + * + * The current selection owner has set prop at our window w + * Transfer the property contents into the Clipboard + */ +void CLIPBOARD_ReadSelection(Window w,Atom prop) +{ + HANDLE hText; + LPCLIPFORMAT lpFormat = ClipFormats; + if(prop==None)hText=NULL; + else{ + Atom atype=None; + int aformat; + unsigned long nitems,remain; + unsigned char *val=NULL; + dprintf_clipboard(stddeb,"Received prop %s\n",XGetAtomName(display,prop)); + /* TODO: Properties longer than 64K */ + if(XGetWindowProperty(display,w,prop,0,0x3FFF,True,XA_STRING, + &atype, &aformat, &nitems, &remain, &val)!=Success) + printf("couldn't read property\n"); + dprintf_clipboard(stddeb,"Type %s,Format %d,nitems %d,value %s\n", + XGetAtomName(display,atype),aformat,nitems,val); + if(atype!=XA_STRING || aformat!=8){ + fprintf(stderr,"Property not set\n"); + hText=NULL; + } else { + dprintf_clipboard(stddeb,"Selection is %s\n",val); + hText=GlobalAlloc(GMEM_MOVEABLE, nitems); + memcpy(GlobalLock(hText),val,nitems+1); + GlobalUnlock(hText); + } + XFree(val); + } + while(TRUE) { + if (lpFormat == NULL) return; + if (lpFormat->wFormatID == CF_TEXT) break; + lpFormat = lpFormat->NextFormat; + } + if (lpFormat->hData != 0) GlobalFree(lpFormat->hData); + wait_for_selection=False; + lpFormat->hData = hText; + dprintf_clipboard(stddeb,"Received selection\n"); +} +/************************************************************************** + * CLIPBOARD_ReleaseSelection + * + * Wine lost the primary selection. + * Empty the clipboard, but don't set the current owner to None. + * Make sure current get/put attempts fail. + */ +void CLIPBOARD_ReleaseSelection(HWND hwnd) +{ + wineOwnsSelection=False; + OpenClipboard(hwnd); + EmptyClipboard(); + CloseClipboard(); +} diff --git a/misc/comm.c b/misc/comm.c index 930a5f167a3..00a0d6a1e19 100644 --- a/misc/comm.c +++ b/misc/comm.c @@ -29,55 +29,62 @@ int commerror = 0, eventmask = 0; struct DosDeviceStruct COM[MAX_PORTS]; struct DosDeviceStruct LPT[MAX_PORTS]; -void Comm_DeInit(void); - void Comm_Init(void) { - int x, serial = 0, parallel = 0; - char option[10], temp[256]; + int x; + char option[10], temp[256], *btemp; struct stat st; for (x=0; x!=MAX_PORTS; x++) { strcpy(option,"COMx"); - option[3] = '0' + x; + option[3] = '1' + x; option[4] = '\0'; GetPrivateProfileString("serialports", option, "*", temp, sizeof(temp), WINE_INI); if (!strcmp(temp, "*") || *temp == '\0') - COM[serial].devicename = NULL; + COM[x].devicename = NULL; else { + btemp = index(temp,','); + if (btemp != NULL) { + *btemp++ = '\0'; + COM[x].baudrate = atoi(btemp); + } else { + COM[x].baudrate = -1; + } stat(temp, &st); if (!S_ISCHR(st.st_mode)) - fprintf(stderr,"comm: can 't use `%s' as COM%d !\n", temp, x); + fprintf(stderr,"comm: can 't use `%s' as %s !\n", temp, option); else - if ((COM[serial].devicename = malloc(strlen(temp)+1)) == NULL) + if ((COM[x].devicename = malloc(strlen(temp)+1)) == NULL) fprintf(stderr,"comm: can't malloc for device info!\n"); else { - COM[serial].fd = 0; - strcpy(COM[serial].devicename, temp); - serial++; + COM[x].fd = 0; + strcpy(COM[x].devicename, temp); } - } + dprintf_comm(stddeb, + "Comm_Init: %s = %s\n", option, COM[x].devicename); + } strcpy(option, "LPTx"); - option[3] = '0' + x; + option[3] = '1' + x; option[4] = '\0'; GetPrivateProfileString("parallelports", option, "*", temp, sizeof(temp), WINE_INI); if (!strcmp(temp, "*") || *temp == '\0') - LPT[parallel].devicename = NULL; + LPT[x].devicename = NULL; else { stat(temp, &st); if (!S_ISCHR(st.st_mode)) - fprintf(stderr,"comm: can 't use `%s' as LPT%d !\n", temp, x); + fprintf(stderr,"comm: can 't use `%s' as %s !\n", temp, option); else - if ((LPT[parallel].devicename = malloc(strlen(temp)+1)) == NULL) + if ((LPT[x].devicename = malloc(strlen(temp)+1)) == NULL) fprintf(stderr,"comm: can't malloc for device info!\n"); else { - LPT[parallel].fd = 0; - strcpy(LPT[parallel].devicename, temp); - parallel++; + LPT[x].fd = 0; + strcpy(LPT[x].devicename, temp); } + dprintf_comm(stddeb, + "Comm_Init: %s = %s\n", option, LPT[x].devicename); } } @@ -128,7 +135,7 @@ int ValidLPTPort(int x) int WinError(void) { - perror("comm"); + dprintf_comm(stddeb, "WinError: errno = %d\n", errno); switch (errno) { default: return CE_IOE; @@ -175,8 +182,11 @@ int BuildCommDCB(LPSTR device, DCB FAR *lpdcb) strcpy(temp,device+5); ptr = strtok(temp, ","); - dprintf_comm(stddeb,"BuildCommDCB: baudrate (%s)\n", ptr); - lpdcb->BaudRate = atoi(ptr); + if (COM[port].baudrate > 0) + lpdcb->BaudRate = COM[port].baudrate; + else + lpdcb->BaudRate = atoi(ptr); + dprintf_comm(stddeb,"BuildCommDCB: baudrate (%d)\n", lpdcb->BaudRate); ptr = strtok(NULL, ","); if (islower(*ptr)) @@ -243,6 +253,9 @@ int OpenComm(LPSTR device, UINT cbInQueue, UINT cbOutQueue) commerror = IE_BADID; } + dprintf_comm(stddeb, + "OpenComm: %s = %s\n", device, COM[port].devicename); + if (!ValidCOMPort(port)) { commerror = IE_BADID; return -1; @@ -251,7 +264,7 @@ int OpenComm(LPSTR device, UINT cbInQueue, UINT cbOutQueue) return COM[port].fd; } - fd = open(COM[port].devicename, O_RDWR | O_NONBLOCK, 0); + fd = open(COM[port].devicename, O_RDWR | O_NONBLOCK); if (fd == -1) { commerror = WinError(); return -1; @@ -344,13 +357,13 @@ LONG EscapeCommFunction(int fd, int nFunction) break; case GETMAXCOM: - for (max = 0;COM[max].devicename;max++) + for (max = MAX_PORTS;!COM[max].devicename;max--) ; return max; break; case GETMAXLPT: - for (max = 0;LPT[max].devicename;max++) + for (max = MAX_PORTS;!LPT[max].devicename;max--) ; return 0x80 + max; break; @@ -425,9 +438,13 @@ int FlushComm(int fd, int fnQueue) int GetCommError(int fd, COMSTAT FAR *lpStat) { + int temperror; + dprintf_comm(stddeb, "GetCommError: fd %d (current error %d)\n", fd, commerror); - return(commerror); + temperror = commerror; + commerror = 0; + return(temperror); } UINT FAR* SetCommEventMask(int fd, UINT fuEvtMask) @@ -449,6 +466,7 @@ UINT GetCommEventMask(int fd, int fnEvtClear) int SetCommState(DCB FAR *lpdcb) { struct termios port; + struct DosDeviceStruct *ptr; dprintf_comm(stddeb, "SetCommState: fd %d, ptr %d\n", lpdcb->Id, (long) lpdcb); @@ -471,6 +489,12 @@ int SetCommState(DCB FAR *lpdcb) port.c_lflag &= ~(ICANON|ECHO|ISIG); port.c_lflag |= NOFLSH; + if ((ptr = GetDeviceStruct(lpdcb->Id)) == NULL) { + commerror = IE_BADID; + return -1; + } + if (ptr->baudrate > 0) + lpdcb->BaudRate = ptr->baudrate; dprintf_comm(stddeb,"SetCommState: baudrate %d\n",lpdcb->BaudRate); #ifdef CBAUD port.c_cflag &= ~CBAUD; @@ -823,9 +847,14 @@ int ReadComm(int fd, LPSTR lpvBuf, int cbRead) status = read(fd, (void *) lpvBuf, cbRead); if (status == -1) { - commerror = WinError(); - return -1 - length; - } else { + if (errno != EAGAIN) { + commerror = WinError(); + return -1 - length; + } else { + commerror = 0; + return length; + } + } else { commerror = 0; return length + status; } diff --git a/misc/commdlg.c b/misc/commdlg.c new file mode 100644 index 00000000000..aa1614bd856 --- /dev/null +++ b/misc/commdlg.c @@ -0,0 +1,1127 @@ +/* + * COMMDLG functions + * + * Copyright 1994 Martin Ayotte + */ +static char Copyright[] = "Copyright Martin Ayotte, 1994"; + +/* +#define DEBUG_OPENDLG +#define DEBUG_OPENDLG_DRAW +*/ + +#include "stdio.h" +#include "dialog.h" +#include "win.h" +#include "user.h" +#include "message.h" +#include "heap.h" +#include "commdlg.h" +#include "dlgs.h" + +#define OPENFILEDLG2 11 +#define SAVEFILEDLG2 12 + + +extern HINSTANCE hSysRes; +static DWORD CommDlgLastError = 0; + +static HBITMAP hFolder = 0; +static HBITMAP hFolder2 = 0; +static HBITMAP hFloppy = 0; +static HBITMAP hHDisk = 0; +static HBITMAP hCDRom = 0; + +int DOS_GetDefaultDrive(void); +void DOS_SetDefaultDrive(int drive); +char *DOS_GetCurrentDir(int drive); +int DOS_ChangeDir(int drive, char *dirname); + +BOOL FileDlg_Init(HWND hWnd, DWORD lParam); +BOOL OpenDlg_ScanFiles(HWND hWnd, WORD nDrive, LPSTR newPath, LPSTR fileSpec); +BOOL OpenDlg_ScanDir(HWND hWnd, WORD nDrive, LPSTR newPath, LPSTR fileSpec); +LPSTR OpenDlg_GetFileType(LPCSTR types, WORD index); +LPSTR OpenDlg_ExtractCurDir(LPSTR FullPath, short MaxLen); +BOOL FileOpenDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam); +BOOL FileSaveDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam); +BOOL ColorDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam); +BOOL PrintDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam); +BOOL PrintSetupDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam); +BOOL ReplaceTextDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam); +BOOL FindTextDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam); + +/*********************************************************************** + * GetOpenFileName [COMMDLG.1] + */ +BOOL GetOpenFileName(LPOPENFILENAME lpofn) +{ + HANDLE hDlgTmpl; + HANDLE hResInfo; + HINSTANCE hInst; + WND *wndPtr; + BOOL bRet; + printf("GetOpenFileName(%08X); !\n", lpofn); + if (lpofn == NULL) return FALSE; + printf("GetOpenFileName // Flags=%08X !\n", lpofn->Flags); + printf("GetOpenFileName // nMaxFile=%d lpstrFile='%s' !\n", + lpofn->nMaxFile, lpofn->lpstrFile); + printf("GetOpenFileName // lpstrInitialDir='%s' !\n", lpofn->lpstrInitialDir); + printf("GetOpenFileName // lpstrFilter=%08X !\n", lpofn->lpstrFilter); + printf("GetOpenFileName // nFilterIndex=%d !\n", lpofn->nFilterIndex); + if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) { + hDlgTmpl = lpofn->hInstance; + } + else { + if (lpofn->Flags & OFN_ENABLETEMPLATE) { + printf("GetOpenFileName // avant FindResource hInstance=%04X lpTemplateName='%s' !\n", + lpofn->hInstance, lpofn->lpTemplateName); + hInst = lpofn->hInstance; + hResInfo = FindResource(hInst, + (LPSTR)lpofn->lpTemplateName, RT_DIALOG); + } + else { + printf("GetOpenFileName // avant FindResource hSysRes=%04X !\n", hSysRes); + hInst = hSysRes; + hResInfo = FindResource(hInst, MAKEINTRESOURCE(OPENFILEDLG2), RT_DIALOG); + } + if (hResInfo == 0) { + CommDlgLastError = CDERR_FINDRESFAILURE; + return FALSE; + } + printf("GetOpenFileName // apres FindResource hResInfo=%04X!\n", hResInfo); + hDlgTmpl = LoadResource(hInst, hResInfo); + } + if (hDlgTmpl == 0) { + CommDlgLastError = CDERR_LOADRESFAILURE; + return FALSE; + } + printf("GetOpenFileName // apres LoadResource hDlgTmpl=%04X!\n", hDlgTmpl); + wndPtr = WIN_FindWndPtr(lpofn->hwndOwner); + bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl, + lpofn->hwndOwner, (WNDPROC)FileOpenDlgProc, (DWORD)lpofn); + +/* strcpy(lpofn->lpstrFile, "SETUP.TXT"); */ +/* strcpy(lpofn->lpstrFileTitle, "SETUP.TXT");*/ +/* + lpofn->nFileOffset = 0; + lpofn->nFileExtension = strlen(lpofn->lpstrFile) - 3; + bRet = TRUE; +*/ + printf("GetOpenFileName // return lpstrFile='%s' !\n", lpofn->lpstrFile); + return bRet; +} + + +/*********************************************************************** + * GetSaveFileName [COMMDLG.2] + */ +BOOL GetSaveFileName(LPOPENFILENAME lpofn) +{ + HANDLE hDlgTmpl; + HANDLE hResInfo; + HINSTANCE hInst; + WND *wndPtr; + BOOL bRet; + printf("GetSaveFileName(%08X); !\n", lpofn); + if (lpofn == NULL) return FALSE; + printf("GetSaveFileName // Flags=%08X !\n", lpofn->Flags); + printf("GetSaveFileName // nMaxFile=%d lpstrFile='%s' !\n", + lpofn->nMaxFile, lpofn->lpstrFile); + printf("GetSaveFileName // lpstrInitialDir='%s' !\n", lpofn->lpstrInitialDir); + printf("GetSaveFileName // lpstrFilter=%08X !\n", lpofn->lpstrFilter); + if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) { + hDlgTmpl = lpofn->hInstance; + } + else { + if (lpofn->Flags & OFN_ENABLETEMPLATE) { + printf("GetSaveFileName // avant FindResource lpTemplateName='%s' !\n", + lpofn->lpTemplateName); + hInst = lpofn->hInstance; + hResInfo = FindResource(hInst, + (LPSTR)lpofn->lpTemplateName, RT_DIALOG); + } + else { + printf("GetSaveFileName // avant FindResource !\n"); + hInst = hSysRes; + hResInfo = FindResource(hInst, MAKEINTRESOURCE(SAVEFILEDLG2), RT_DIALOG); + } + if (hResInfo == 0) { + CommDlgLastError = CDERR_FINDRESFAILURE; + return FALSE; + } + hDlgTmpl = LoadResource(hInst, hResInfo); + } + if (hDlgTmpl == 0) { + CommDlgLastError = CDERR_LOADRESFAILURE; + return FALSE; + } + wndPtr = WIN_FindWndPtr(lpofn->hwndOwner); + bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl, + lpofn->hwndOwner, (WNDPROC)FileSaveDlgProc, (DWORD)lpofn); + printf("GetSaveFileName // return lpstrFile='%s' !\n", lpofn->lpstrFile); + return bRet; +} + + +/*********************************************************************** + * ChooseColor [COMMDLG.5] + */ +BOOL ChooseColor(LPCHOOSECOLOR lpChCol) +{ + HANDLE hDlgTmpl; + HANDLE hResInfo; + WND *wndPtr; + BOOL bRet; + hResInfo = FindResource(hSysRes, MAKEINTRESOURCE(COLORDLG), RT_DIALOG); + hDlgTmpl = LoadResource(hSysRes, hResInfo); + wndPtr = WIN_FindWndPtr(lpChCol->hwndOwner); + bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl, + lpChCol->hwndOwner, (WNDPROC)ColorDlgProc, (DWORD)lpChCol); + return bRet; +} + + +/*********************************************************************** + * FileOpenDlgProc [COMMDLG.6] + */ +BOOL FileOpenDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam) +{ + int n; + LPSTR ptr; + LPSTR fspec; + char str[512]; + char C2[128]; + WORD wRet; + HBRUSH hBrush; + HDC hMemDC; + HBITMAP hBitmap; + BITMAP bm; + WND *wndPtr; + LPMEASUREITEMSTRUCT lpmeasure; + LPDRAWITEMSTRUCT lpdis; + static int nDrive; + static char CurPath[512]; + static LPOPENFILENAME lpofn; + + switch (wMsg) { + case WM_INITDIALOG: +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // WM_INITDIALOG lParam=%08X\n", lParam); +#endif + printf("FileOpenDlgProc // WM_INITDIALOG lParam=%08X\n", lParam); + if (!FileDlg_Init(hWnd, lParam)) return TRUE; + SendDlgItemMessage(hWnd, cmb1, CB_RESETCONTENT, 0, 0L); + lpofn = (LPOPENFILENAME)lParam; + ptr = (LPSTR)lpofn->lpstrFilter; + strcpy(CurPath, lpofn->lpstrInitialDir); +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // lpstrInitialDir='%s' !\n", CurPath); +#endif + while((n = strlen(ptr)) != 0) { +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // file type '%s' !\n", ptr); +#endif + SendDlgItemMessage(hWnd, cmb1, CB_ADDSTRING, 0, (DWORD)ptr); + ptr += ++n; +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // file spec '%s' !\n", ptr); +#endif + n = strlen(ptr); + ptr += ++n; + } + SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (DWORD)str); + SendDlgItemMessage(hWnd, cmb1, CB_SETCURSEL, + lpofn->nFilterIndex - 1, 0L); + DlgDirListComboBox(hWnd, "", cmb2, 0, 0xC000); + nDrive = 2; /* Drive 'C:' */ + SendDlgItemMessage(hWnd, cmb2, CB_SETCURSEL, nDrive, 0L); + sprintf(str, "%c:\\%s", nDrive + 'A', DOS_GetCurrentDir(nDrive)); + fspec = OpenDlg_GetFileType(lpofn->lpstrFilter, + lpofn->nFilterIndex); +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // WM_INITDIALOG fspec #%d = '%s' !\n", + lpofn->nFilterIndex, fspec); +#endif + if (!OpenDlg_ScanDir(hWnd, nDrive, str, fspec)) { + printf("OpenDlg_ScanDir // ChangeDir Error !\n"); + } + else { + strcpy(CurPath, str); + } + ShowWindow(hWnd, SW_SHOWNORMAL); + return TRUE; + + case WM_SHOWWINDOW: + if (wParam == 0) break; + if (!(lpofn->Flags & OFN_SHOWHELP)) { + ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE); + } + if (lpofn->Flags & OFN_HIDEREADONLY) { + ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE); + } + return TRUE; + + case WM_MEASUREITEM: + GetObject(hFolder2, sizeof(BITMAP), (LPSTR)&bm); + lpmeasure = (LPMEASUREITEMSTRUCT)lParam; + lpmeasure->itemHeight = bm.bmHeight; +#ifdef DEBUG_OPENDLG_DRAW + printf("FileOpenDlgProc WM_MEASUREITEM Height=%d !\n", bm.bmHeight); +#endif + return TRUE; + + case WM_DRAWITEM: +#ifdef DEBUG_OPENDLG_DRAW + printf("FileOpenDlgProc // WM_DRAWITEM w=%04X l=%08X\n", wParam, lParam); +#endif + if (lParam == 0L) break; + lpdis = (LPDRAWITEMSTRUCT)lParam; +#ifdef DEBUG_OPENDLG_DRAW + printf("FileOpenDlgProc // WM_DRAWITEM CtlType=%04X CtlID=%04X \n", + lpdis->CtlType, lpdis->CtlID); +#endif + if ((lpdis->CtlType == ODT_LISTBOX) && (lpdis->CtlID == lst1)) { + hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH)); + SelectObject(lpdis->hDC, hBrush); + FillRect(lpdis->hDC, &lpdis->rcItem, hBrush); + ptr = (LPSTR) lpdis->itemData; + if (ptr == NULL) break; + TextOut(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, + ptr, strlen(ptr)); + } + if ((lpdis->CtlType == ODT_LISTBOX) && (lpdis->CtlID == lst2)) { + hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH)); + SelectObject(lpdis->hDC, hBrush); + FillRect(lpdis->hDC, &lpdis->rcItem, hBrush); + ptr = (LPSTR) lpdis->itemData; + if (ptr == NULL) break; + if (strcmp(ptr, "[.]") == 0) { + hBitmap = hFolder2; +/* ptr = OpenDlg_ExtractCurDir(CurPath, -1); */ + ptr = CurPath; + } + else + hBitmap = hFolder; + GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm); + TextOut(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth, + lpdis->rcItem.top, ptr, strlen(ptr)); + hMemDC = CreateCompatibleDC(lpdis->hDC); + SelectObject(hMemDC, hBitmap); + BitBlt(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, + bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); + DeleteDC(hMemDC); + } + if ((lpdis->CtlType == ODT_COMBOBOX) && (lpdis->CtlID == cmb2)) { + hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH)); + SelectObject(lpdis->hDC, hBrush); + FillRect(lpdis->hDC, &lpdis->rcItem, hBrush); + ptr = (LPSTR) lpdis->itemData; + if (ptr == NULL) break; + switch(ptr[2]) { + case 'a': + case 'b': + hBitmap = hFloppy; + break; + default: + hBitmap = hHDisk; + } + GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm); + TextOut(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth, + lpdis->rcItem.top, ptr, strlen(ptr)); + hMemDC = CreateCompatibleDC(lpdis->hDC); + SelectObject(hMemDC, hBitmap); + BitBlt(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, + bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); + DeleteDC(hMemDC); + } + if (lpdis->itemState != 0) { + InvertRect(lpdis->hDC, &lpdis->rcItem); + } + break; + + case WM_COMMAND: + switch (wParam) { + case lst1: + if (HIWORD(lParam) == LBN_DBLCLK || + HIWORD(lParam) == LBN_SELCHANGE) { +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // LBN_SELCHANGE on lst1 !\n"); +#endif + wRet = SendDlgItemMessage(hWnd, lst1, LB_GETCURSEL, 0, 0L); + SendDlgItemMessage(hWnd, lst1, LB_GETTEXT, wRet, (DWORD)C2); + } + if (HIWORD(lParam) == LBN_DBLCLK) { +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // LBN_DBLCLK on lst1 !\n"); +#endif + return SendMessage(hWnd, WM_COMMAND, IDOK, 0L); + } + break; + case lst2: + if (HIWORD(lParam) == LBN_DBLCLK) { +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // LBN_DBLCLK on lst2 !\n"); +#endif + wRet = SendDlgItemMessage(hWnd, cmb1, CB_GETCURSEL, 0, 0L); + if (wRet == (WORD)LB_ERR) return 0; + fspec = OpenDlg_GetFileType(lpofn->lpstrFilter, wRet + 1); + C2[0] = '\0'; + wRet = SendDlgItemMessage(hWnd, lst2, LB_GETCURSEL, 0, 0L); + if (wRet == (WORD)LB_ERR) return 0; + SendDlgItemMessage(hWnd, lst2, LB_GETTEXT, wRet, (DWORD)C2); + if (C2[0] == '[') { + C2[strlen(C2) - 1] = '\0'; + sprintf(str, "%s\\%s", CurPath, &C2[1]); + if (!OpenDlg_ScanDir(hWnd, nDrive, str, fspec)) { + printf("OpenDlg_ScanDir // ChangeDir Error !\n"); + } + else { + strcpy(CurPath, str); + } + } + } + break; + case cmb1: + if (HIWORD(lParam) == CBN_SELCHANGE) { + wRet = SendDlgItemMessage(hWnd, cmb1, CB_GETCURSEL, 0, 0L); + if (wRet == (WORD)LB_ERR) return 0; + fspec = OpenDlg_GetFileType(lpofn->lpstrFilter, wRet + 1); + printf("FileOpenDlgProc // new fspec #%d = '%s' !\n", wRet, fspec); + if (!OpenDlg_ScanFiles(hWnd, nDrive, CurPath, fspec)) { + printf("OpenDlg_ScanFiles // Change FileType Error !\n"); + } + } + break; + case cmb2: +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // combo #2 changed !\n"); +#endif + wRet = SendDlgItemMessage(hWnd, cmb1, CB_GETCURSEL, 0, 0L); + if (wRet == (WORD)LB_ERR) return 0; + fspec = OpenDlg_GetFileType(lpofn->lpstrFilter, wRet + 1); + wRet = SendDlgItemMessage(hWnd, cmb2, CB_GETCURSEL, 0, 0L); + if (wRet == (WORD)LB_ERR) return 0; + printf("FileOpenDlgProc // combo #2 CB_GETCURSEL=%d !\n", wRet); + SendDlgItemMessage(hWnd, cmb2, CB_GETLBTEXT, wRet, (DWORD)C2); + nDrive = C2[2] - 'a'; +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // new drive selected=%d !\n", nDrive); +#endif + sprintf(str, "%c:\\%s", nDrive + 'A', DOS_GetCurrentDir(nDrive)); +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // new drive , curPath='%s' !\n", str); +#endif + if (!OpenDlg_ScanDir(hWnd, nDrive, str, fspec)) { + printf("OpenDlg_ScanDir // ChangeDir Error !\n"); + } + else { + strcpy(CurPath, str); + } + break; + case chx1: +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // read-only toggled !\n"); +#endif + break; + case pshHelp: +#ifdef DEBUG_OPENDLG + printf("FileOpenDlgProc // pshHelp pressed !\n"); +#endif + break; + case IDOK: + ShowWindow(hWnd, SW_HIDE); + SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 0, (DWORD)str); + wRet = SendDlgItemMessage(hWnd, lst1, LB_GETCURSEL, 0, 0L); + SendDlgItemMessage(hWnd, lst1, LB_GETTEXT, wRet, (DWORD)str); + printf("FileOpenDlgProc // IDOK str='%s'\n", str); + strcpy(lpofn->lpstrFile, str); + lpofn->nFileOffset = 0; + lpofn->nFileExtension = strlen(lpofn->lpstrFile) - 3; + if (lpofn->lpstrFileTitle != NULL) { + wRet = SendDlgItemMessage(hWnd, lst1, LB_GETCURSEL, 0, 0L); + SendDlgItemMessage(hWnd, lst1, LB_GETTEXT, wRet, (DWORD)str); + strcpy(lpofn->lpstrFileTitle, str); + } + EndDialog(hWnd, TRUE); + return(TRUE); + case IDCANCEL: + EndDialog(hWnd, FALSE); + return(TRUE); + } + return(FALSE); + } + + +/* + case WM_CTLCOLOR: + SetBkColor((HDC)wParam, 0x00C0C0C0); + switch (HIWORD(lParam)) + { + case CTLCOLOR_BTN: + SetTextColor((HDC)wParam, 0x00000000); + return(hGRAYBrush); + case CTLCOLOR_STATIC: + SetTextColor((HDC)wParam, 0x00000000); + return(hGRAYBrush); + } + return(FALSE); + +*/ + return FALSE; +} + + +/*********************************************************************** + * FileDlg_Init [internal] + */ +BOOL FileDlg_Init(HWND hWnd, DWORD lParam) +{ + LPOPENFILENAME lpofn; + lpofn = (LPOPENFILENAME)lParam; + if (lpofn == NULL) { + fprintf(stderr, "FileDlg_Init // Bad LPOPENFILENAME pointer !"); + return FALSE; + } + if (hFolder == (HBITMAP)NULL) + hFolder = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_FOLDER)); + if (hFolder2 == (HBITMAP)NULL) + hFolder2 = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_FOLDER2)); + if (hFloppy == (HBITMAP)NULL) + hFloppy = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_FLOPPY)); + if (hHDisk == (HBITMAP)NULL) + hHDisk = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_HDISK)); + if (hCDRom == (HBITMAP)NULL) + hCDRom = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_CDROM)); + if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 || + hHDisk == 0 || hCDRom == 0) + fprintf(stderr, "FileDlg_Init // Error loading bitmaps !"); + return TRUE; +} + + +/*********************************************************************** + * OpenDlg_ScanFiles [internal] + */ +BOOL OpenDlg_ScanFiles(HWND hWnd, WORD nDrive, LPSTR newPath, LPSTR fileSpec) +{ + int OldDrive; + char OldPath[512]; + char str[512]; + OldDrive = DOS_GetDefaultDrive(); + DOS_SetDefaultDrive(nDrive) ; + strcpy(OldPath, DOS_GetCurrentDir(nDrive)); +#ifdef DEBUG_OPENDLG + printf("OpenDlg_ScanFiles // OldDrive=%d OldPath='%s'\n", OldDrive, OldPath); + printf("OpenDlg_ScanFiles // wanted newPath='%s'\n", newPath); +#endif + if (newPath[1] == ':') + DOS_ChangeDir(nDrive, &newPath[2]); + else + DOS_ChangeDir(nDrive, newPath); + sprintf(newPath, "%c:\\%s", nDrive + 'A', DOS_GetCurrentDir(nDrive)); +#ifdef DEBUG_OPENDLG + printf("OpenDlg_ScanFiles // actual newPath='%s'\n", newPath); +#endif + if (strlen(newPath) == 3) newPath[2] = '\0'; + sprintf(str, "%s\\%s", newPath, fileSpec); + DlgDirList(hWnd, str, lst1, 0, 0x0000); + SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (DWORD)str); + DOS_ChangeDir(nDrive, OldPath); + DOS_SetDefaultDrive(OldDrive); + return TRUE; +} + + + +/*********************************************************************** + * OpenDlg_ScanDir [internal] + */ +BOOL OpenDlg_ScanDir(HWND hWnd, WORD nDrive, LPSTR newPath, LPSTR fileSpec) +{ + int OldDrive; + char OldPath[512]; + char str[512]; + OldDrive = DOS_GetDefaultDrive(); + DOS_SetDefaultDrive(nDrive) ; + strcpy(OldPath, DOS_GetCurrentDir(nDrive)); +#ifdef DEBUG_OPENDLG + printf("OpenDlg_ScanDir // OldDrive=%d OldPath='%s'\n", OldDrive, OldPath); + printf("OpenDlg_ScanDir // wanted newPath='%s'\n", newPath); +#endif + if (newPath[1] == ':') + DOS_ChangeDir(nDrive, &newPath[2]); + else + DOS_ChangeDir(nDrive, newPath); + sprintf(newPath, "%c:\\%s", nDrive + 'A', DOS_GetCurrentDir(nDrive)); +#ifdef DEBUG_OPENDLG + printf("OpenDlg_ScanDir // actual newPath='%s'\n", newPath); +#endif + if (strlen(newPath) == 3) newPath[2] = '\0'; + sprintf(str, "%s\\%s", newPath, fileSpec); + DlgDirList(hWnd, str, lst1, 0, 0x0000); + SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (DWORD)str); + sprintf(str, "%s\\*.*", newPath); + DlgDirList(hWnd, str, lst2, 0, 0x8010); + if (strlen(newPath) == 2) strcat(newPath, "\\"); + SendDlgItemMessage(hWnd, stc1, WM_SETTEXT, 0, (DWORD)newPath); + DOS_ChangeDir(nDrive, OldPath); + DOS_SetDefaultDrive(OldDrive); + return TRUE; +} + + + +/*********************************************************************** + * OpenDlg_GetFileType [internal] + */ +LPSTR OpenDlg_GetFileType(LPCSTR types, WORD index) +{ + int n; + int i = 1; + LPSTR ptr = (LPSTR) types; + if (ptr == NULL) return NULL; + while((n = strlen(ptr)) != 0) { +#ifdef DEBUG_OPENDLG + printf("OpenDlg_GetFileType // file type '%s' !\n", ptr); +#endif + ptr += ++n; +#ifdef DEBUG_OPENDLG + printf("OpenDlg_GetFileType // file spec '%s' !\n", ptr); +#endif + if (i++ == index) return ptr; + n = strlen(ptr); + ptr += ++n; + } + return NULL; +} + + +/*********************************************************************** + * OpenDlg_ExtractCurDir [internal] + */ +LPSTR OpenDlg_ExtractCurDir(LPSTR FullPath, short MaxLen) +{ + LPSTR ptr; + if (MaxLen < 0) MaxLen = strlen(FullPath); + ptr = FullPath + MaxLen - 1; + if (*ptr == '\\') return NULL; + while (ptr > FullPath) { + if (*ptr == '\\') return (ptr + 1); + ptr--; + } + return NULL; +} + + +/*********************************************************************** + * FileSaveDlgProc [COMMDLG.7] + */ +BOOL FileSaveDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam) +{ + int n; + LPSTR ptr; + LPSTR fspec; + char str[512]; + char C2[128]; + WORD wRet; + HBRUSH hBrush; + HDC hMemDC; + HBITMAP hBitmap; + BITMAP bm; + LPMEASUREITEMSTRUCT lpmeasure; + LPDRAWITEMSTRUCT lpdis; + static int nDrive; + static int OldDrive; + static char OldPath[512]; + static char CurPath[512]; + static LPOPENFILENAME lpofn; + + switch (wMsg) { + case WM_INITDIALOG: +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // WM_INITDIALOG lParam=%08X\n", lParam); +#endif + if (!FileDlg_Init(hWnd, lParam)) return TRUE; + SendDlgItemMessage(hWnd, cmb1, CB_RESETCONTENT, 0, 0L); + lpofn = (LPOPENFILENAME)lParam; + ptr = (LPSTR)lpofn->lpstrFilter; + strcpy(CurPath, lpofn->lpstrInitialDir); + while((n = strlen(ptr)) != 0) { +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // file type '%s' !\n", ptr); +#endif + SendDlgItemMessage(hWnd, cmb1, CB_ADDSTRING, 0, (DWORD)ptr); + ptr += ++n; +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // file spec '%s' !\n", ptr); +#endif + n = strlen(ptr); + ptr += ++n; + } + SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (DWORD)str); + SendDlgItemMessage(hWnd, cmb1, CB_SETCURSEL, + lpofn->nFilterIndex - 1, 0L); + DlgDirListComboBox(hWnd, "", cmb2, 0, 0xC000); + nDrive = 2; /* Drive 'C:' */ + SendDlgItemMessage(hWnd, cmb2, CB_SETCURSEL, nDrive, 0L); + sprintf(str, "%c:\\%s", nDrive + 'A', DOS_GetCurrentDir(nDrive)); + fspec = OpenDlg_GetFileType(lpofn->lpstrFilter, + lpofn->nFilterIndex); +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // WM_INITDIALOG fspec #%d = '%s' !\n", + lpofn->nFilterIndex, fspec); +#endif + if (!OpenDlg_ScanDir(hWnd, nDrive, str, fspec)) { + printf("OpenDlg_ScanDir // ChangeDir Error !\n"); + } + else { + strcpy(CurPath, str); + } + ShowWindow(hWnd, SW_SHOWNORMAL); + return (TRUE); + + case WM_SHOWWINDOW: + if (wParam == 0) break; + if (!(lpofn->Flags & OFN_SHOWHELP)) { + ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE); + } + if (lpofn->Flags & OFN_HIDEREADONLY) { + ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE); + } + return TRUE; + + case WM_MEASUREITEM: + GetObject(hFolder2, sizeof(BITMAP), (LPSTR)&bm); + lpmeasure = (LPMEASUREITEMSTRUCT)lParam; + lpmeasure->itemHeight = bm.bmHeight; +#ifdef DEBUG_OPENDLG_DRAW + printf("FileSaveDlgProc WM_MEASUREITEM Height=%d !\n", bm.bmHeight); +#endif + return TRUE; + + case WM_DRAWITEM: +#ifdef DEBUG_OPENDLG_DRAW + printf("FileSaveDlgProc // WM_DRAWITEM w=%04X l=%08X\n", wParam, lParam); +#endif + if (lParam == 0L) break; + lpdis = (LPDRAWITEMSTRUCT)lParam; +#ifdef DEBUG_OPENDLG_DRAW + printf("FileSaveDlgProc // WM_DRAWITEM lpdis->CtlID=%04X\n", lpdis->CtlID); +#endif + if ((lpdis->CtlType == ODT_LISTBOX) && (lpdis->CtlID == lst1)) { + hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH)); + SelectObject(lpdis->hDC, hBrush); + FillRect(lpdis->hDC, &lpdis->rcItem, hBrush); + ptr = (LPSTR) lpdis->itemData; + if (ptr == NULL) break; + TextOut(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, + ptr, strlen(ptr)); + } + if ((lpdis->CtlType == ODT_LISTBOX) && (lpdis->CtlID == lst2)) { + hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH)); + SelectObject(lpdis->hDC, hBrush); + FillRect(lpdis->hDC, &lpdis->rcItem, hBrush); + ptr = (LPSTR) lpdis->itemData; + if (ptr == NULL) break; + if (strcmp(ptr, "[.]") == 0) { + hBitmap = hFolder2; + ptr = CurPath; + } + else + hBitmap = hFolder; + GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm); + TextOut(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth, + lpdis->rcItem.top, ptr, strlen(ptr)); + hMemDC = CreateCompatibleDC(lpdis->hDC); + SelectObject(hMemDC, hBitmap); + BitBlt(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, + bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); + DeleteDC(hMemDC); + } + if ((lpdis->CtlType == ODT_COMBOBOX) && (lpdis->CtlID == cmb2)) { + hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH)); + SelectObject(lpdis->hDC, hBrush); + FillRect(lpdis->hDC, &lpdis->rcItem, hBrush); + ptr = (LPSTR) lpdis->itemData; + if (ptr == NULL) break; + switch(ptr[2]) { + case 'a': + case 'b': + hBitmap = hFloppy; + break; + default: + hBitmap = hHDisk; + } + GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm); + TextOut(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth, + lpdis->rcItem.top, ptr, strlen(ptr)); + hMemDC = CreateCompatibleDC(lpdis->hDC); + SelectObject(hMemDC, hBitmap); + BitBlt(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, + bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); + DeleteDC(hMemDC); + } + break; + + case WM_COMMAND: + switch (wParam) { + case lst1: + if (HIWORD(lParam) == LBN_DBLCLK || + HIWORD(lParam) == LBN_SELCHANGE) { +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // LBN_SELCHANGE on lst1 !\n"); +#endif + wRet = SendDlgItemMessage(hWnd, lst1, LB_GETCURSEL, 0, 0L); + SendDlgItemMessage(hWnd, lst1, LB_GETTEXT, wRet, (DWORD)C2); + } + if (HIWORD(lParam) == LBN_DBLCLK) { +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // LBN_DBLCLK on lst1 !\n"); +#endif + return SendMessage(hWnd, WM_COMMAND, IDOK, 0L); + } + break; + case lst2: + if (HIWORD(lParam) == LBN_DBLCLK) { +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // LBN_DBLCLK on lst2 !\n"); +#endif + wRet = SendDlgItemMessage(hWnd, cmb1, CB_GETCURSEL, 0, 0L); + fspec = OpenDlg_GetFileType(lpofn->lpstrFilter, wRet + 1); + C2[0] = '\0'; + wRet = SendDlgItemMessage(hWnd, lst2, LB_GETCURSEL, 0, 0L); + SendDlgItemMessage(hWnd, lst2, LB_GETTEXT, wRet, (DWORD)C2); + if (C2[0] == '[') { + C2[strlen(C2) - 1] = '\0'; + sprintf(str, "%s\\%s", CurPath, &C2[1]); + if (!OpenDlg_ScanDir(hWnd, nDrive, str, fspec)) { + printf("FileSaveDlgProc // ChangeDir Error !\n"); + } + else { + strcpy(CurPath, str); + } + } + } + break; + case cmb1: + if (HIWORD(lParam) == CBN_SELCHANGE) { + wRet = SendDlgItemMessage(hWnd, cmb1, CB_GETCURSEL, 0, 0L); + fspec = OpenDlg_GetFileType(lpofn->lpstrFilter, wRet + 1); + printf("FileSaveDlgProc // new fspec #%d = '%s' !\n", wRet, fspec); + if (!OpenDlg_ScanFiles(hWnd, nDrive, CurPath, fspec)) { + printf("OpenDlg_ScanFile // Change FileType Error !\n"); + } + } + break; + case cmb2: +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // combo #2 changed !\n"); +#endif + wRet = SendDlgItemMessage(hWnd, cmb1, CB_GETCURSEL, 0, 0L); + if (wRet == (WORD)LB_ERR) return 0; + fspec = OpenDlg_GetFileType(lpofn->lpstrFilter, wRet + 1); + wRet = SendDlgItemMessage(hWnd, cmb2, CB_GETCURSEL, 0, 0L); + if (wRet == (WORD)LB_ERR) return 0; + printf("FileSaveDlgProc // combo #2 CB_GETCURSEL=%d !\n", wRet); + SendDlgItemMessage(hWnd, cmb2, CB_GETLBTEXT, wRet, (DWORD)C2); + nDrive = C2[2] - 'a'; +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // new drive selected=%d !\n", nDrive); +#endif + sprintf(str, "%c:\\%s", nDrive + 'A', DOS_GetCurrentDir(nDrive)); +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // new drive , curPath='%s' !\n", str); +#endif + if (!OpenDlg_ScanDir(hWnd, nDrive, str, fspec)) { + printf("FileSaveDlgProc // Change Drive Error !\n"); + } + else { + strcpy(CurPath, str); + } + break; + case chx1: +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // read-only toggled !\n"); +#endif + break; + case pshHelp: +#ifdef DEBUG_OPENDLG + printf("FileSaveDlgProc // pshHelp pressed !\n"); +#endif + break; + case IDOK: + strcpy(lpofn->lpstrFile, "titi.txt"); + if (lpofn->lpstrFileTitle != NULL) { + strcpy(lpofn->lpstrFileTitle, "titi.txt"); + } + EndDialog(hWnd, TRUE); + return(TRUE); + case IDCANCEL: + EndDialog(hWnd, FALSE); + return(TRUE); + } + return(FALSE); + } + return FALSE; +} + + +/*********************************************************************** + * ColorDlgProc [COMMDLG.8] + */ +BOOL ColorDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam) +{ + switch (wMsg) { + case WM_INITDIALOG: + printf("ColorDlgProc // WM_INITDIALOG lParam=%08X\n", lParam); + ShowWindow(hWnd, SW_SHOWNORMAL); + return (TRUE); + + case WM_COMMAND: + switch (wParam) { + case IDOK: + EndDialog(hWnd, TRUE); + return(TRUE); + case IDCANCEL: + EndDialog(hWnd, FALSE); + return(TRUE); + } + return(FALSE); + } + return FALSE; +} + + +/*********************************************************************** + * FindTextDlg [COMMDLG.11] + */ +BOOL FindText(LPFINDREPLACE lpFind) +{ + HANDLE hDlgTmpl; + HANDLE hResInfo; + WND *wndPtr; + BOOL bRet; + hResInfo = FindResource(hSysRes, MAKEINTRESOURCE(FINDDLG), RT_DIALOG); + if (hResInfo == 0) { + CommDlgLastError = CDERR_FINDRESFAILURE; + return FALSE; + } + hDlgTmpl = LoadResource(hSysRes, hResInfo); + if (hDlgTmpl == 0) { + CommDlgLastError = CDERR_LOADRESFAILURE; + return FALSE; + } + wndPtr = WIN_FindWndPtr(lpFind->hwndOwner); + bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl, + lpFind->hwndOwner, (WNDPROC)FindTextDlgProc, (DWORD)lpFind); + return bRet; +} + + +/*********************************************************************** + * ReplaceTextDlg [COMMDLG.12] + */ +BOOL ReplaceText(LPFINDREPLACE lpFind) +{ + HANDLE hDlgTmpl; + HANDLE hResInfo; + WND *wndPtr; + BOOL bRet; + hResInfo = FindResource(hSysRes, MAKEINTRESOURCE(REPLACEDLG), RT_DIALOG); + if (hResInfo == 0) { + CommDlgLastError = CDERR_FINDRESFAILURE; + return FALSE; + } + hDlgTmpl = LoadResource(hSysRes, hResInfo); + if (hDlgTmpl == 0) { + CommDlgLastError = CDERR_LOADRESFAILURE; + return FALSE; + } + wndPtr = WIN_FindWndPtr(lpFind->hwndOwner); + bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl, + lpFind->hwndOwner, (WNDPROC)ReplaceTextDlgProc, (DWORD)lpFind); + return bRet; +} + + +/*********************************************************************** + * FindTextDlgProc [COMMDLG.13] + */ +BOOL FindTextDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam) +{ + switch (wMsg) { + case WM_INITDIALOG: + printf("FindTextDlgProc // WM_INITDIALOG lParam=%08X\n", lParam); + ShowWindow(hWnd, SW_SHOWNORMAL); + return (TRUE); + + case WM_COMMAND: + switch (wParam) { + case IDOK: + EndDialog(hWnd, TRUE); + return(TRUE); + case IDCANCEL: + EndDialog(hWnd, FALSE); + return(TRUE); + } + return(FALSE); + } + return FALSE; +} + + +/*********************************************************************** + * ReplaceTextDlgProc [COMMDLG.14] + */ +BOOL ReplaceTextDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam) +{ + switch (wMsg) { + case WM_INITDIALOG: + printf("ReplaceTextDlgProc // WM_INITDIALOG lParam=%08X\n", lParam); + ShowWindow(hWnd, SW_SHOWNORMAL); + return (TRUE); + + case WM_COMMAND: + switch (wParam) { + case IDOK: + EndDialog(hWnd, TRUE); + return(TRUE); + case IDCANCEL: + EndDialog(hWnd, FALSE); + return(TRUE); + } + return(FALSE); + } + return FALSE; +} + + +/*********************************************************************** + * PrintDlg [COMMDLG.20] + */ +BOOL PrintDlg(LPPRINTDLG lpPrint) +{ + HANDLE hDlgTmpl; + HANDLE hResInfo; + WND *wndPtr; + BOOL bRet; + printf("PrintDlg(%08X) // Flags=%08X\n", lpPrint->Flags); + if (lpPrint->Flags & PD_PRINTSETUP) + hResInfo = FindResource(hSysRes, MAKEINTRESOURCE(PRINTSETUPDLG), RT_DIALOG); + else + hResInfo = FindResource(hSysRes, MAKEINTRESOURCE(PRINTDLG), RT_DIALOG); + if (hResInfo == 0) { + CommDlgLastError = CDERR_FINDRESFAILURE; + return FALSE; + } + hDlgTmpl = LoadResource(hSysRes, hResInfo); + if (hDlgTmpl == 0) { + CommDlgLastError = CDERR_LOADRESFAILURE; + return FALSE; + } + wndPtr = WIN_FindWndPtr(lpPrint->hwndOwner); + if (lpPrint->Flags & PD_PRINTSETUP) + bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl, + lpPrint->hwndOwner, (WNDPROC)PrintSetupDlgProc, (DWORD)lpPrint); + else + bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl, + lpPrint->hwndOwner, (WNDPROC)PrintDlgProc, (DWORD)lpPrint); + return bRet; +} + + +/*********************************************************************** + * PrintDlgProc [COMMDLG.21] + */ +BOOL PrintDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam) +{ + switch (wMsg) { + case WM_INITDIALOG: + printf("PrintDlgProc // WM_INITDIALOG lParam=%08X\n", lParam); + ShowWindow(hWnd, SW_SHOWNORMAL); + return (TRUE); + + case WM_COMMAND: + switch (wParam) { + case IDOK: + EndDialog(hWnd, TRUE); + return(TRUE); + case IDCANCEL: + EndDialog(hWnd, FALSE); + return(TRUE); + } + return(FALSE); + } + return FALSE; +} + + +/*********************************************************************** + * PrintSetupDlgProc [COMMDLG.22] + */ +BOOL PrintSetupDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam) +{ + switch (wMsg) { + case WM_INITDIALOG: + printf("PrintSetupDlgProc // WM_INITDIALOG lParam=%08X\n", lParam); + ShowWindow(hWnd, SW_SHOWNORMAL); + return (TRUE); + + case WM_COMMAND: + switch (wParam) { + case IDOK: + EndDialog(hWnd, TRUE); + return(TRUE); + case IDCANCEL: + EndDialog(hWnd, FALSE); + return(TRUE); + } + return(FALSE); + } + return FALSE; +} + + +/*********************************************************************** + * CommDlgExtendError [COMMDLG.26] + */ +DWORD CommDlgExtendError(void) +{ + return CommDlgLastError; +} + + +/*********************************************************************** + * GetFileTitle [COMMDLG.27] + */ +int GetFileTitle(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf) +{ + int i, len; + printf("GetFileTitle(%08X %08X %d); \n", lpFile, lpTitle, cbBuf); + if (lpFile == NULL || lpTitle == NULL) return -1; + len = strlen(lpFile); + if (len == 0) return -1; + if (strchr(lpFile, '*') != NULL) return -1; + if (strchr(lpFile, '[') != NULL) return -1; + if (strchr(lpFile, ']') != NULL) return -1; + len--; + if (lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':') return -1; + for (i = len; i >= 0; i--) { + if (lpFile[i] == '/' || + lpFile[i] == '\\' || + lpFile[i] == ':') { + i++; + break; + } + } + printf("\n---> '%s' ", &lpFile[i]); + len = min(cbBuf, strlen(&lpFile[i]) + 1); + strncpy(lpTitle, &lpFile[i], len + 1); + if (len != cbBuf) + return len; + else + return 0; +} + + + diff --git a/misc/dos_fs.c b/misc/dos_fs.c index 29a68edf18c..f6ba92f4bbf 100644 --- a/misc/dos_fs.c +++ b/misc/dos_fs.c @@ -382,9 +382,7 @@ static void GetUnixDirName(char *rootdir, char *name) ToUnix(rootdir); -#ifdef DEBUG - fprintf(stderr,"%s\n", rootdir); -#endif + dprintf_dosfs(stddeb,"%s\n", rootdir); } @@ -440,7 +438,7 @@ char *DOS_GetCurrentDir(int drive) { /* should return 'WINDOWS\SYSTEM' */ - char temp[256]; + static char temp[256]; if (!DOS_ValidDrive(drive)) return 0; diff --git a/misc/exec.c b/misc/exec.c index 31d3570c863..920cb273bda 100644 --- a/misc/exec.c +++ b/misc/exec.c @@ -129,14 +129,14 @@ void StartNewTask(HINSTANCE hInst) dprintf_exec(stddeb,"StartNewTask() before CallToInit16() !\n"); rv = CallToInit16(cs_reg << 16 | ip_reg, ss_reg << 16 | sp_reg, ds_reg); - printf ("rv = %x\n", rv); + dprintf_exec(stddeb,"rv = %x\n", rv); } #else void StartNewTask (HINSTANCE hInst) { - printf ("Not yet implemented\n"); + fprintf(stdnimp, "StartNewTask(): Not yet implemented\n"); } #endif diff --git a/misc/file.c b/misc/file.c index 5a9d86a274a..2320a8b0e32 100644 --- a/misc/file.c +++ b/misc/file.c @@ -186,12 +186,14 @@ INT OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle) if ( (!stat(GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) ) break; GetWindowsDirectory (filename,MAX_PATH); - if (filename[1] != ':') strcat(filename,"\\"); + if ((!filename[0])||(filename[strlen(filename)-1]!='\\')) + strcat(filename, "\\"); strcat (filename, lpFileName); if ( (!stat(GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) ) break; GetSystemDirectory (filename,MAX_PATH); - if (filename[1] != ':') strcat(filename,"\\"); + if ((!filename[0])||(filename[strlen(filename)-1]!='\\')) + strcat(filename, "\\"); strcat (filename, lpFileName); if ( (!stat(GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) ) break; diff --git a/misc/main.c b/misc/main.c index 5c2a1a4897f..3b9250eac1b 100644 --- a/misc/main.c +++ b/misc/main.c @@ -200,6 +200,56 @@ static void MAIN_GetAllButtonTexts(XrmDatabase db) MAIN_GetButtonText(db, ".CancelLabel", &ButtonText.Cancel); } +/*********************************************************************** + * ParseDebugOptions + * + * Turns specific debug messages on or off, according to "options". + * Returns TRUE if parsing was successfull + */ +#ifdef DEBUG_RUNTIME + +BOOL ParseDebugOptions(char *options) +{ + int l; + if (strlen(options)<3) + return FALSE; + do + { + if ((*options!='+')&&(*options!='-')) + return FALSE; + if (strchr(options,',')) + l=strchr(options,',')-options; + else + l=strlen(options); + if (!strncasecmp(options+1,"all",l-1)) + { + int i; + for (i=0;i +#include +#include +#include +#include +#include +#include "win.h" +#include "user.h" +#include "driver.h" +#include "mmsystem.h" +#include "stddebug.h" +/* #define DEBUG_ANIM /* */ +/* #undef DEBUG_ANIM /* */ +#include "debug.h" + +#define MAX_ANIMDRV 2 + +#define ANIMFRAMES_PERSEC 30 +#define ANIMFRAMES_PERMIN 1800 +#define SECONDS_PERMIN 60 + +#ifdef linux +typedef struct { + int nUseCount; /* Incremented for each shared open */ + BOOL fShareable; /* TRUE if first open was shareable */ + WORD wNotifyDeviceID; /* MCI device ID with a pending notification */ + HANDLE hCallback; /* Callback handle for pending notification */ + MCI_OPEN_PARMS openParms; + DWORD dwTimeFormat; + int mode; + UINT nCurTrack; + DWORD dwCurFrame; + UINT nTracks; + DWORD dwTotalLen; + LPDWORD lpdwTrackLen; + LPDWORD lpdwTrackPos; + } LINUX_ANIM; + +static LINUX_ANIM AnimDev[MAX_ANIMDRV]; +#endif + + +DWORD ANIM_CalcTime(UINT wDevID, DWORD dwFormatType, DWORD dwFrame); +DWORD ANIM_CalcFrame(UINT wDevID, DWORD dwFormatType, DWORD dwTime); + + +/*-----------------------------------------------------------------------*/ + +/************************************************************************** +* ANIM_mciOpen [internal] +*/ +DWORD ANIM_mciOpen(DWORD dwFlags, LPMCI_OPEN_PARMS lpParms) +{ +#ifdef linux + UINT wDevID; + int cdrom; + dprintf_mcianim(stddeb,"ANIM_mciOpen(%08X, %08X);\n", + dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; + wDevID = lpParms->wDeviceID; + if (AnimDev[wDevID].nUseCount > 0) { + /* The driver already open on this channel */ + /* If the driver was opened shareable before and this open specifies */ + /* shareable then increment the use count */ + if (AnimDev[wDevID].fShareable && (dwFlags & MCI_OPEN_SHAREABLE)) + ++AnimDev[wDevID].nUseCount; + else + return MCIERR_MUST_USE_SHAREABLE; + } + else { + AnimDev[wDevID].nUseCount = 1; + AnimDev[wDevID].fShareable = dwFlags & MCI_OPEN_SHAREABLE; + } + if (dwFlags & MCI_OPEN_ELEMENT) { + dprintf_mcianim(stddeb,"ANIM_mciOpen // MCI_OPEN_ELEMENT !\n"); +/* return MCIERR_NO_ELEMENT_ALLOWED; */ + } + memcpy(&AnimDev[wDevID].openParms, lpParms, sizeof(MCI_OPEN_PARMS)); + AnimDev[wDevID].wNotifyDeviceID = lpParms->wDeviceID; + AnimDev[wDevID].mode = 0; + AnimDev[wDevID].dwTimeFormat = MCI_FORMAT_TMSF; + AnimDev[wDevID].nCurTrack = 0; + AnimDev[wDevID].nTracks = 0; + AnimDev[wDevID].dwTotalLen = 0; + AnimDev[wDevID].lpdwTrackLen = NULL; + AnimDev[wDevID].lpdwTrackPos = NULL; + if (dwFlags & MCI_NOTIFY) { + dprintf_mcianim(stddeb, + "ANIM_mciOpen // MCI_NOTIFY_SUCCESSFUL %08X !\n", + lpParms->dwCallback); + mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), + AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); + } + return 0; +#else + return MCIERR_HARDWARE; +#endif +} + +/************************************************************************** +* ANIM_mciClose [internal] +*/ +DWORD ANIM_mciClose(UINT wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms) +{ +#ifdef linux + dprintf_mcianim(stddeb,"ANIM_mciClose(%u, %08X, %08X);\n", + wDevID, dwParam, lpParms); + if (AnimDev[wDevID].lpdwTrackLen != NULL) free(AnimDev[wDevID].lpdwTrackLen); + if (AnimDev[wDevID].lpdwTrackPos != NULL) free(AnimDev[wDevID].lpdwTrackPos); +#endif +} + +/************************************************************************** +* ANIM_mciGetDevCaps [internal] +*/ +DWORD ANIM_mciGetDevCaps(UINT wDevID, DWORD dwFlags, + LPMCI_GETDEVCAPS_PARMS lpParms) +{ +#ifdef linux + dprintf_mcianim(stddeb,"ANIM_mciGetDevCaps(%u, %08X, %08X);\n", + wDevID, dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; + if (dwFlags & MCI_GETDEVCAPS_ITEM) { + dprintf_mcianim(stddeb, + "ANIM_mciGetDevCaps // MCI_GETDEVCAPS_ITEM dwItem=%08X;\n", + lpParms->dwItem); + switch(lpParms->dwItem) { + case MCI_GETDEVCAPS_CAN_RECORD: + lpParms->dwReturn = FALSE; + break; + case MCI_GETDEVCAPS_HAS_AUDIO: + lpParms->dwReturn = FALSE; + break; + case MCI_GETDEVCAPS_HAS_VIDEO: + lpParms->dwReturn = FALSE; + break; + case MCI_GETDEVCAPS_DEVICE_TYPE: + lpParms->dwReturn = MCI_DEVTYPE_ANIMATION; + break; + case MCI_GETDEVCAPS_USES_FILES: + lpParms->dwReturn = TRUE; + break; + case MCI_GETDEVCAPS_COMPOUND_DEVICE: + lpParms->dwReturn = FALSE; + break; + case MCI_GETDEVCAPS_CAN_EJECT: + lpParms->dwReturn = TRUE; + break; + case MCI_GETDEVCAPS_CAN_PLAY: + lpParms->dwReturn = FALSE; + break; + case MCI_GETDEVCAPS_CAN_SAVE: + lpParms->dwReturn = FALSE; + break; + default: + return MCIERR_UNRECOGNIZED_COMMAND; + } + } + dprintf_mcianim(stddeb, + "ANIM_mciGetDevCaps // lpParms->dwReturn=%08X;\n", + lpParms->dwReturn); + return 0; +#else + return MCIERR_INTERNAL; +#endif +} + +/************************************************************************** +* ANIM_mciInfo [internal] +*/ +DWORD ANIM_mciInfo(UINT wDevID, DWORD dwFlags, LPMCI_INFO_PARMS lpParms) +{ +#ifdef linux + dprintf_mcianim(stddeb,"ANIM_mciInfo(%u, %08X, %08X);\n", + wDevID, dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; + lpParms->lpstrReturn = NULL; + switch(dwFlags) { + case MCI_INFO_PRODUCT: + lpParms->lpstrReturn = "Linux ANIMATION 0.5"; + break; + case MCI_INFO_FILE: + lpParms->lpstrReturn = + (LPSTR)AnimDev[wDevID].openParms.lpstrElementName; + break; + case MCI_ANIM_INFO_TEXT: + lpParms->lpstrReturn = "Animation Window"; + break; + default: + return MCIERR_UNRECOGNIZED_COMMAND; + } + if (lpParms->lpstrReturn != NULL) + lpParms->dwRetSize = strlen(lpParms->lpstrReturn); + else + lpParms->dwRetSize = 0; + return 0; +#else + return MCIERR_INTERNAL; +#endif +} + +/************************************************************************** +* ANIM_mciStatus [internal] +*/ +DWORD ANIM_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms) +{ +#ifdef linux + dprintf_mcianim(stddeb,"ANIM_mciStatus(%u, %08X, %08X);\n", + wDevID, dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; + if (dwFlags & MCI_NOTIFY) { + dprintf_mcianim(stddeb, + "ANIM_mciStatus // MCI_NOTIFY_SUCCESSFUL %08X !\n", + lpParms->dwCallback); + mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), + AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); + } + if (dwFlags & MCI_STATUS_ITEM) { + switch(lpParms->dwItem) { + case MCI_STATUS_CURRENT_TRACK: + lpParms->dwReturn = AnimDev[wDevID].nCurTrack; + dprintf_mcianim(stddeb,"ANIM_mciStatus // CURRENT_TRACK=%u!\n", lpParms->dwReturn); + return 0; + case MCI_STATUS_LENGTH: + if (dwFlags & MCI_TRACK) { + dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_TRACK #%u LENGTH=??? !\n", + lpParms->dwTrack); + if (lpParms->dwTrack > AnimDev[wDevID].nTracks) + return MCIERR_OUTOFRANGE; + lpParms->dwReturn = AnimDev[wDevID].lpdwTrackLen[lpParms->dwTrack]; + } + else + lpParms->dwReturn = AnimDev[wDevID].dwTotalLen; + lpParms->dwReturn = ANIM_CalcTime(wDevID, + AnimDev[wDevID].dwTimeFormat, lpParms->dwReturn); + dprintf_mcianim(stddeb,"ANIM_mciStatus // LENGTH=%u !\n", lpParms->dwReturn); + return 0; + case MCI_STATUS_MODE: + lpParms->dwReturn = AnimDev[wDevID].mode; + dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_MODE=%08X !\n", + lpParms->dwReturn); + return 0; + case MCI_STATUS_MEDIA_PRESENT: + lpParms->dwReturn = TRUE; + dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_MEDIA_PRESENT !\n"); + return 0; + case MCI_STATUS_NUMBER_OF_TRACKS: + lpParms->dwReturn = 1; + dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_NUMBER_OF_TRACKS = %u !\n", + lpParms->dwReturn); + if (lpParms->dwReturn == (WORD)-1) return MCIERR_INTERNAL; + return 0; + case MCI_STATUS_POSITION: + lpParms->dwReturn = AnimDev[wDevID].dwCurFrame; + if (dwFlags & MCI_STATUS_START) { + lpParms->dwReturn = 0; + dprintf_mcianim(stddeb,"CDAUDIO_mciStatus // get MCI_STATUS_START !\n"); + } + if (dwFlags & MCI_TRACK) { + if (lpParms->dwTrack > AnimDev[wDevID].nTracks) + return MCIERR_OUTOFRANGE; + lpParms->dwReturn = AnimDev[wDevID].lpdwTrackPos[lpParms->dwTrack - 1]; + dprintf_mcianim(stddeb,"ANIM_mciStatus // get MCI_TRACK #%u !\n", lpParms->dwTrack); + } + lpParms->dwReturn = ANIM_CalcTime(wDevID, + AnimDev[wDevID].dwTimeFormat, lpParms->dwReturn); + dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_POSITION=%08X !\n", + lpParms->dwReturn); + return 0; + case MCI_STATUS_READY: + dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_READY !\n"); + lpParms->dwReturn = TRUE; + return 0; + case MCI_STATUS_TIME_FORMAT: + dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_TIME_FORMAT !\n"); + lpParms->dwReturn = MCI_FORMAT_MILLISECONDS; + return 0; + default: + fprintf(stderr,"ANIM_mciStatus // unknown command %04X !\n", lpParms->dwItem); + return MCIERR_UNRECOGNIZED_COMMAND; + } + } + fprintf(stderr,"ANIM_mciStatus // not MCI_STATUS_ITEM !\n"); + return 0; +#else + return MMSYSERR_NOTENABLED; +#endif +} + + +/************************************************************************** +* ANIM_CalcTime [internal] +*/ +DWORD ANIM_CalcTime(UINT wDevID, DWORD dwFormatType, DWORD dwFrame) +{ + DWORD dwTime = 0; +#ifdef linux + UINT wTrack; + UINT wMinutes; + UINT wSeconds; + UINT wFrames; + dprintf_mcianim(stddeb,"ANIM_CalcTime(%u, %08X, %lu);\n", + wDevID, dwFormatType, dwFrame); +TryAGAIN: + switch (dwFormatType) { + case MCI_FORMAT_MILLISECONDS: + dwTime = dwFrame / ANIMFRAMES_PERSEC * 1000; + dprintf_mcianim(stddeb, + "ANIM_CalcTime // MILLISECONDS %u\n", dwTime); + break; + case MCI_FORMAT_MSF: + wMinutes = dwFrame / ANIMFRAMES_PERMIN; + wSeconds = (dwFrame - ANIMFRAMES_PERMIN * wMinutes) / ANIMFRAMES_PERSEC; + wFrames = dwFrame - ANIMFRAMES_PERMIN * wMinutes - + ANIMFRAMES_PERSEC * wSeconds; + dwTime = MCI_MAKE_MSF(wMinutes, wSeconds, wFrames); + dprintf_mcianim(stddeb,"ANIM_CalcTime // MSF %02u:%02u:%02u -> dwTime=%u\n", + wMinutes, wSeconds, wFrames, dwTime); + break; + case MCI_FORMAT_TMSF: + for (wTrack = 0; wTrack < AnimDev[wDevID].nTracks; wTrack++) { +/* dwTime += AnimDev[wDevID].lpdwTrackLen[wTrack - 1]; + printf("Adding trk#%u curpos=%u \n", dwTime); + if (dwTime >= dwFrame) break; */ + if (AnimDev[wDevID].lpdwTrackPos[wTrack - 1] >= dwFrame) break; + } + wMinutes = dwFrame / ANIMFRAMES_PERMIN; + wSeconds = (dwFrame - ANIMFRAMES_PERMIN * wMinutes) / ANIMFRAMES_PERSEC; + wFrames = dwFrame - ANIMFRAMES_PERMIN * wMinutes - + ANIMFRAMES_PERSEC * wSeconds; + dwTime = MCI_MAKE_TMSF(wTrack, wMinutes, wSeconds, wFrames); + dprintf_mcianim(stddeb, + "ANIM_CalcTime // %02u-%02u:%02u:%02u\n", + wTrack, wMinutes, wSeconds, wFrames); + break; + default: + /* unknown format ! force TMSF ! ... */ + dwFormatType = MCI_FORMAT_TMSF; + goto TryAGAIN; + } +#endif + return dwTime; +} + + +/************************************************************************** +* ANIM_CalcFrame [internal] +*/ +DWORD ANIM_CalcFrame(UINT wDevID, DWORD dwFormatType, DWORD dwTime) +{ + DWORD dwFrame = 0; +#ifdef linux + UINT wTrack; + dprintf_mcianim(stddeb,"ANIM_CalcFrame(%u, %08X, %lu);\n", + wDevID, dwFormatType, dwTime); +TryAGAIN: + switch (dwFormatType) { + case MCI_FORMAT_MILLISECONDS: + dwFrame = dwTime * ANIMFRAMES_PERSEC / 1000; + dprintf_mcianim(stddeb, + "ANIM_CalcFrame // MILLISECONDS %u\n", dwFrame); + break; + case MCI_FORMAT_MSF: + dprintf_mcianim(stddeb, + "ANIM_CalcFrame // MSF %02u:%02u:%02u\n", + MCI_MSF_MINUTE(dwTime), MCI_MSF_SECOND(dwTime), + MCI_MSF_FRAME(dwTime)); + dwFrame += ANIMFRAMES_PERMIN * MCI_MSF_MINUTE(dwTime); + dwFrame += ANIMFRAMES_PERSEC * MCI_MSF_SECOND(dwTime); + dwFrame += MCI_MSF_FRAME(dwTime); + break; + case MCI_FORMAT_TMSF: + wTrack = MCI_TMSF_TRACK(dwTime); + dprintf_mcianim(stddeb, + "ANIM_CalcFrame // TMSF %02u-%02u:%02u:%02u\n", + MCI_TMSF_TRACK(dwTime), MCI_TMSF_MINUTE(dwTime), + MCI_TMSF_SECOND(dwTime), MCI_TMSF_FRAME(dwTime)); + dprintf_mcianim(stddeb, + "ANIM_CalcFrame // TMSF trackpos[%u]=%u\n", + wTrack, AnimDev[wDevID].lpdwTrackPos[wTrack - 1]); + dwFrame = AnimDev[wDevID].lpdwTrackPos[wTrack - 1]; + dwFrame += ANIMFRAMES_PERMIN * MCI_TMSF_MINUTE(dwTime); + dwFrame += ANIMFRAMES_PERSEC * MCI_TMSF_SECOND(dwTime); + dwFrame += MCI_TMSF_FRAME(dwTime); + break; + default: + /* unknown format ! force TMSF ! ... */ + dwFormatType = MCI_FORMAT_TMSF; + goto TryAGAIN; + } +#endif + return dwFrame; +} + + + +/************************************************************************** +* ANIM_mciPlay [internal] +*/ +DWORD ANIM_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms) +{ +#ifdef linux + int start, end; + dprintf_mcianim(stddeb,"ANIM_mciPlay(%u, %08X, %08X);\n", + wDevID, dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; + start = 0; end = AnimDev[wDevID].dwTotalLen; + AnimDev[wDevID].nCurTrack = 1; + if (dwFlags & MCI_FROM) { + start = ANIM_CalcFrame(wDevID, + AnimDev[wDevID].dwTimeFormat, lpParms->dwFrom); + dprintf_mcianim(stddeb,"ANIM_mciPlay // MCI_FROM=%08X -> %u \n", + lpParms->dwFrom, start); + } + if (dwFlags & MCI_TO) { + end = ANIM_CalcFrame(wDevID, + AnimDev[wDevID].dwTimeFormat, lpParms->dwTo); + dprintf_mcianim(stddeb, + "ANIM_mciPlay // MCI_TO=%08X -> %u \n", + lpParms->dwTo, end); + } + AnimDev[wDevID].mode = MCI_MODE_PLAY; + if (dwFlags & MCI_NOTIFY) { + dprintf_mcianim(stddeb, + "ANIM_mciPlay // MCI_NOTIFY_SUCCESSFUL %08X !\n", + lpParms->dwCallback); + mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), + AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); + } + return 0; +#else + return MCIERR_HARDWARE; +#endif +} + +/************************************************************************** +* ANIM_mciStop [internal] +*/ +DWORD ANIM_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) +{ +#ifdef linux + dprintf_mcianim(stddeb,"ANIM_mciStop(%u, %08X, %08X);\n", + wDevID, dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; + AnimDev[wDevID].mode = MCI_MODE_STOP; + if (dwFlags & MCI_NOTIFY) { + dprintf_mcianim(stddeb, + "ANIM_mciStop // MCI_NOTIFY_SUCCESSFUL %08X !\n", + lpParms->dwCallback); + mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), + AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); + } + return 0; +#else + return MCIERR_HARDWARE; +#endif +} + +/************************************************************************** +* ANIM_mciPause [internal] +*/ +DWORD ANIM_mciPause(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) +{ +#ifdef linux + dprintf_mcianim(stddeb,"ANIM_mciPause(%u, %08X, %08X);\n", + wDevID, dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; + AnimDev[wDevID].mode = MCI_MODE_PAUSE; + if (dwFlags & MCI_NOTIFY) { + dprintf_mcianim(stddeb, + "ANIM_mciPause // MCI_NOTIFY_SUCCESSFUL %08X !\n", + lpParms->dwCallback); + mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), + AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); + } + return 0; +#else + return MCIERR_HARDWARE; +#endif +} + +/************************************************************************** +* ANIM_mciResume [internal] +*/ +DWORD ANIM_mciResume(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) +{ +#ifdef linux + dprintf_mcianim(stddeb,"ANIM_mciResume(%u, %08X, %08X);\n", + wDevID, dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; + AnimDev[wDevID].mode = MCI_MODE_STOP; + if (dwFlags & MCI_NOTIFY) { + dprintf_mcianim(stddeb, + "ANIM_mciResume // MCI_NOTIFY_SUCCESSFUL %08X !\n", + lpParms->dwCallback); + mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), + AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); + } + return 0; +#else + return MCIERR_HARDWARE; +#endif +} + +/************************************************************************** +* ANIM_mciSeek [internal] +*/ +DWORD ANIM_mciSeek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms) +{ +#ifdef linux + DWORD dwRet; + MCI_PLAY_PARMS PlayParms; + dprintf_mcianim(stddeb,"ANIM_mciSeek(%u, %08X, %08X);\n", + wDevID, dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; + AnimDev[wDevID].mode = MCI_MODE_SEEK; + switch(dwFlags) { + case MCI_SEEK_TO_START: + PlayParms.dwFrom = 0; + break; + case MCI_SEEK_TO_END: + PlayParms.dwFrom = AnimDev[wDevID].dwTotalLen; + break; + case MCI_TO: + PlayParms.dwFrom = lpParms->dwTo; + break; + } + dwRet = ANIM_mciPlay(wDevID, MCI_WAIT | MCI_FROM, &PlayParms); + if (dwRet != 0) return dwRet; + dwRet = ANIM_mciStop(wDevID, MCI_WAIT, (LPMCI_GENERIC_PARMS)&PlayParms); + if (dwFlags & MCI_NOTIFY) { + dprintf_mcianim(stddeb, + "ANIM_mciSeek // MCI_NOTIFY_SUCCESSFUL %08X !\n", + lpParms->dwCallback); + mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), + AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); + } + return dwRet; +#else + return MCIERR_HARDWARE; +#endif +} + + +/************************************************************************** +* ANIM_mciSet [internal] +*/ +DWORD ANIM_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms) +{ +#ifdef linux + dprintf_mcianim(stddeb,"ANIM_mciSet(%u, %08X, %08X);\n", + wDevID, dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; +/* + printf("ANIM_mciSet // dwTimeFormat=%08X\n", lpParms->dwTimeFormat); + printf("ANIM_mciSet // dwAudio=%08X\n", lpParms->dwAudio); +*/ + if (dwFlags & MCI_SET_TIME_FORMAT) { + switch (lpParms->dwTimeFormat) { + case MCI_FORMAT_MILLISECONDS: + dprintf_mcianim(stddeb, + "ANIM_mciSet // MCI_FORMAT_MILLISECONDS !\n"); + break; + case MCI_FORMAT_MSF: + dprintf_mcianim(stddeb,"ANIM_mciSet // MCI_FORMAT_MSF !\n"); + break; + case MCI_FORMAT_TMSF: + dprintf_mcianim(stddeb,"ANIM_mciSet // MCI_FORMAT_TMSF !\n"); + break; + default: + fprintf(stderr,"ANIM_mciSet // bad time format !\n"); + return MCIERR_BAD_TIME_FORMAT; + } + AnimDev[wDevID].dwTimeFormat = lpParms->dwTimeFormat; + } + if (dwFlags & MCI_SET_VIDEO) return MCIERR_UNSUPPORTED_FUNCTION; + if (dwFlags & MCI_SET_ON) return MCIERR_UNSUPPORTED_FUNCTION; + if (dwFlags & MCI_SET_OFF) return MCIERR_UNSUPPORTED_FUNCTION; + if (dwFlags & MCI_NOTIFY) { + dprintf_mcianim(stddeb, + "ANIM_mciSet // MCI_NOTIFY_SUCCESSFUL %08X !\n", + lpParms->dwCallback); + mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), + AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); + } + return 0; +#else + return MCIERR_HARDWARE; +#endif +} + + +/************************************************************************** +* ANIM_DriverProc [sample driver] +*/ +LRESULT ANIM_DriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg, + DWORD dwParam1, DWORD dwParam2) +{ +#ifdef linux + switch(wMsg) { + case DRV_LOAD: + return (LRESULT)1L; + case DRV_FREE: + return (LRESULT)1L; + case DRV_OPEN: + case MCI_OPEN_DRIVER: + case MCI_OPEN: + return ANIM_mciOpen(dwParam1, (LPMCI_OPEN_PARMS)dwParam2); + case DRV_CLOSE: + case MCI_CLOSE_DRIVER: + case MCI_CLOSE: + return ANIM_mciClose(dwDevID, dwParam1, + (LPMCI_GENERIC_PARMS)dwParam2); + case DRV_ENABLE: + return (LRESULT)1L; + case DRV_DISABLE: + return (LRESULT)1L; + case DRV_QUERYCONFIGURE: + return (LRESULT)1L; + case DRV_CONFIGURE: + MessageBox((HWND)NULL, "Sample MultiMedia Linux Driver !", + "MMLinux Driver", MB_OK); + return (LRESULT)1L; + case DRV_INSTALL: + return (LRESULT)DRVCNF_RESTART; + case DRV_REMOVE: + return (LRESULT)DRVCNF_RESTART; + case MCI_GETDEVCAPS: + return ANIM_mciGetDevCaps(dwDevID, dwParam1, + (LPMCI_GETDEVCAPS_PARMS)dwParam2); + case MCI_INFO: + return ANIM_mciInfo(dwDevID, dwParam1, + (LPMCI_INFO_PARMS)dwParam2); + case MCI_STATUS: + return ANIM_mciStatus(dwDevID, dwParam1, + (LPMCI_STATUS_PARMS)dwParam2); + case MCI_SET: + return ANIM_mciSet(dwDevID, dwParam1, + (LPMCI_SET_PARMS)dwParam2); + case MCI_PLAY: + return ANIM_mciPlay(dwDevID, dwParam1, + (LPMCI_PLAY_PARMS)dwParam2); + case MCI_STOP: + return ANIM_mciStop(dwDevID, dwParam1, + (LPMCI_GENERIC_PARMS)dwParam2); + case MCI_PAUSE: + return ANIM_mciPause(dwDevID, dwParam1, + (LPMCI_GENERIC_PARMS)dwParam2); + case MCI_RESUME: + return ANIM_mciResume(dwDevID, dwParam1, + (LPMCI_GENERIC_PARMS)dwParam2); + case MCI_SEEK: + return ANIM_mciSeek(dwDevID, dwParam1, + (LPMCI_SEEK_PARMS)dwParam2); + default: + return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2); + } +#else + return MCIERR_HARDWARE; +#endif +} + + +/*-----------------------------------------------------------------------*/ + +#endif /* #ifdef BUILTIN_MMSYSTEM */ diff --git a/misc/mcicda.c b/misc/mcicda.c index 213ebffe423..de2a3d81e4c 100644 --- a/misc/mcicda.c +++ b/misc/mcicda.c @@ -93,7 +93,7 @@ DWORD CDAUDIO_mciOpen(DWORD dwFlags, LPMCI_OPEN_PARMS lpParms) wDevID = lpParms->wDeviceID; if (CDADev[wDevID].nUseCount > 0) { /* The driver already open on this channel */ - /* If the driver was% op, ened shareable before and this open specifies */ + /* If the driver was opened shareable before and this open specifies */ /* shareable then increment the use count */ if (CDADev[wDevID].fShareable && (dwFlags & MCI_OPEN_SHAREABLE)) ++CDADev[wDevID].nUseCount; @@ -468,7 +468,7 @@ UINT CDAUDIO_GetNumberOfTracks(UINT wDevID) } /************************************************************************** -* CDAUDIO_GetNumberOfTracks [internal] +* CDAUDIO_GetTracksInfo [internal] */ BOOL CDAUDIO_GetTracksInfo(UINT wDevID) { @@ -544,7 +544,7 @@ BOOL CDAUDIO_GetTracksInfo(UINT wDevID) /************************************************************************** -* CDAUDIO_GetNumberOfTracks [internal] +* CDAUDIO_GetCDStatus [internal] */ BOOL CDAUDIO_GetCDStatus(UINT wDevID) { diff --git a/misc/message.c b/misc/message.c index 3f766df8af0..50637369077 100644 --- a/misc/message.c +++ b/misc/message.c @@ -6,7 +6,6 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; -#define DEBUG_MSGBOX #include #include @@ -21,7 +20,12 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; #include "heap.h" #include "win.h" #include "texts.h" - +#include "stddebug.h" +/* #define DEBUG_MSGBOX */ +/* #undef DEBUG_MSGBOX */ +#include "debug.h" + + /* * Defaults for button-texts */ @@ -76,17 +80,13 @@ int MessageBox(HWND hWnd, LPSTR str, LPSTR title, WORD type) wndPtr = WIN_FindWndPtr(hWnd); if (wndPtr == NULL) { hInst = hSysRes; -#ifdef DEBUG_MSGBOX - printf("MessageBox(NULL, %08X='%s', %08X='%s', %04X)\n", + dprintf_msgbox(stddeb,"MessageBox(NULL, %08X='%s', %08X='%s', %04X)\n", str, str, title, title, type); -#endif } else { hInst = wndPtr->hInstance; -#ifdef DEBUG_MSGBOX - printf("MessageBox(%04X, %08X='%s', %08X='%s', %04X)\n", + dprintf_msgbox(stddeb,"MessageBox(%04X, %08X='%s', %08X='%s', %04X)\n", hWnd, str, str, title, title, type); -#endif } lpmb = (LPMSGBOX) malloc(sizeof(MSGBOX)); memset(lpmb, 0, sizeof(MSGBOX)); @@ -116,9 +116,7 @@ int MessageBox(HWND hWnd, LPSTR str, LPSTR title, WORD type) wndClass.hbrBackground = GetStockObject(WHITE_BRUSH); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = "MESSAGEBOX"; -#ifdef DEBUG_MSGBOX - printf( "MessageBox // before RegisterClass, '%s' '%s' !\n", str, title); -#endif + dprintf_msgbox(stddeb, "MessageBox // before RegisterClass, '%s' '%s' !\n", str, title); if (!RegisterClass(&wndClass)) { printf("Unable to Register class 'MESSAGEBOX' !\n"); if (lpmb != NULL) free(lpmb); @@ -134,9 +132,7 @@ int MessageBox(HWND hWnd, LPSTR str, LPSTR title, WORD type) if (lpmb != NULL) free(lpmb); return 0; } -#ifdef DEBUG_MSGBOX - printf( "MessageBox // before Msg Loop !\n"); -#endif + dprintf_msgbox(stddeb, "MessageBox // before Msg Loop !\n"); while(TRUE) { if (!lpmb->ActiveFlg) break; if (!GetMessage(&msg, (HWND)NULL, 0, 0)) break; @@ -158,9 +154,7 @@ int MessageBox(HWND hWnd, LPSTR str, LPSTR title, WORD type) nRet = lpmb->wRetVal; if (lpmb != NULL) free(lpmb); if (!UnregisterClass("MESSAGEBOX", hInst)) return 0; -#ifdef DEBUG_MSGBOX - printf( "MessageBox return %04X !\n", nRet); -#endif + dprintf_msgbox(stddeb, "MessageBox return %04X !\n", nRet); return(nRet); } @@ -190,26 +184,17 @@ LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam) DWORD OldTextColor; RECT rect; LPMSGBOX lpmb; - BITMAP bm; - HBITMAP hBitMap; - HDC hMemDC; - HICON hIcon; - HINSTANCE hInst2; - int x; + switch(message) { case WM_CREATE: -#ifdef DEBUG_MSGBOX - printf("MessageBox WM_CREATE hWnd=%04X !\n", hWnd); -#endif + dprintf_msgbox(stddeb, "MessageBox WM_CREATE hWnd=%04X !\n", hWnd); wndPtr = WIN_FindWndPtr(hWnd); createStruct = (CREATESTRUCT *)lParam; lpmb = (LPMSGBOX)createStruct->lpCreateParams; if (lpmb == NULL) break; *((LPMSGBOX *)&wndPtr->wExtra[1]) = lpmb; -#ifdef DEBUG_MSGBOX - printf("MessageBox WM_CREATE title='%s' str='%s' !\n", + dprintf_msgbox(stddeb, "MessageBox WM_CREATE title='%s' str='%s' !\n", lpmb->Title, lpmb->Str); -#endif GetClientRect(hWnd, &rect); CopyRect(&lpmb->rectStr, &rect); lpmb->rectStr.bottom -= 32; @@ -295,17 +280,13 @@ LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam) } break; case WM_SHOWWINDOW: -#ifdef DEBUG_MSGBOX - printf("MessageBox WM_SHOWWINDOW hWnd=%04X !\n", hWnd); -#endif + dprintf_msgbox(stddeb, "MessageBox WM_SHOWWINDOW hWnd=%04X !\n", hWnd); if (!(wParam == 0 && lParam == 0L)) { InvalidateRect(hWnd, NULL, TRUE); } break; case WM_PAINT: -#ifdef DEBUG_MSGBOX - printf("MessageBox WM_PAINT hWnd=%04X !\n", hWnd); -#endif + dprintf_msgbox(stddeb, "MessageBox WM_PAINT hWnd=%04X !\n", hWnd); lpmb = MsgBoxGetStorageHeader(hWnd); if (lpmb == NULL) break; if (!lpmb->ActiveFlg) break; @@ -328,14 +309,10 @@ LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam) DrawText(hDC, lpmb->Str, -1, &rect, DT_CENTER | DT_WORDBREAK); SetTextColor(hDC, OldTextColor); EndPaint(hWnd, &ps); -#ifdef DEBUG_MSGBOX - printf("MessageBox End of WM_PAINT !\n"); -#endif + dprintf_msgbox(stddeb, "MessageBox End of WM_PAINT !\n"); break; case WM_DESTROY: -#ifdef DEBUG_MSGBOX - printf("MessageBox WM_DESTROY !\n"); -#endif + dprintf_msgbox(stddeb, "MessageBox WM_DESTROY !\n"); ReleaseCapture(); lpmb = MsgBoxGetStorageHeader(hWnd); if (lpmb == NULL) break; @@ -343,9 +320,7 @@ LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam) if (lpmb->hWndYes) DestroyWindow(lpmb->hWndYes); if (lpmb->hWndNo) DestroyWindow(lpmb->hWndNo); if (lpmb->hWndCancel) DestroyWindow(lpmb->hWndCancel); -#ifdef DEBUG_MSGBOX - printf("MessageBox WM_DESTROY end !\n"); -#endif + dprintf_msgbox(stddeb, "MessageBox WM_DESTROY end !\n"); lpmb->ActiveFlg = FALSE; break; case WM_COMMAND: @@ -353,9 +328,7 @@ LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam) if (lpmb == NULL) break; if (wParam < IDOK || wParam > IDNO) return(0); lpmb->wRetVal = wParam; -#ifdef DEBUG_MSGBOX - printf("MessageBox sending WM_CLOSE !\n"); -#endif + dprintf_msgbox(stddeb, "MessageBox sending WM_CLOSE !\n"); PostMessage(hWnd, WM_CLOSE, 0, 0L); break; case WM_CHAR: @@ -398,12 +371,10 @@ BOOL FAR PASCAL AboutWine_Proc(HWND hDlg, WORD msg, WORD wParam, LONG lParam) HDC hDC; HDC hMemDC; PAINTSTRUCT ps; - int OldBackMode; - HFONT hOldFont; RECT rect; BITMAP bm; - int X; OFSTRUCT ofstruct; + HBITMAP hbmpOld; static LPSTR ptr; static char str[256]; static HBITMAP hBitMap = 0; @@ -438,10 +409,11 @@ BOOL FAR PASCAL AboutWine_Proc(HWND hDlg, WORD msg, WORD wParam, LONG lParam) FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH)); InflateRect(&rect, -10, -10); hMemDC = CreateCompatibleDC(hDC); - SelectObject(hMemDC, hBitMap); + hbmpOld = SelectObject(hMemDC, hBitMap); GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm); BitBlt(hDC, rect.left, rect.top, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); + SelectObject( hMemDC, hbmpOld ); DeleteDC(hMemDC); EndPaint(hDlg, &ps); return TRUE; @@ -465,7 +437,7 @@ BOOL FAR PASCAL AboutWine_Proc(HWND hDlg, WORD msg, WORD wParam, LONG lParam) return TRUE; case IDCANCEL: case IDOK: -CloseDLG: if (hBitMap != 0 ) DeleteObject(hBitMap); + if (hBitMap != 0 ) DeleteObject(hBitMap); if (ptr != NULL) free(ptr); EndDialog(hDlg, TRUE); return TRUE; diff --git a/misc/midi.c b/misc/midi.c new file mode 100644 index 00000000000..cc20a08dd86 --- /dev/null +++ b/misc/midi.c @@ -0,0 +1,983 @@ +/* + * Sample MIDI Wine Driver for Linux + * + * Copyright 1994 Martin Ayotte + */ +static char Copyright[] = "Copyright Martin Ayotte, 1994"; + +#ifndef WINELIB +#define BUILTIN_MMSYSTEM +#endif + +#ifdef BUILTIN_MMSYSTEM + +#define DEBUG_MCIMIDI + +#include "stdio.h" +#include "win.h" +#include "user.h" +#include "driver.h" +#include "mmsystem.h" + +#include +#include +#ifdef linux +#include +#endif + +#ifdef linux +#define MIDI_DEV "/dev/midi" + +#ifdef SOUND_VERSION +#define IOCTL(a,b,c) ioctl(a,b,&c) +#else +#define IOCTL(a,b,c) (c = ioctl(a,b,c) ) +#endif + +#define MAX_MIDIINDRV 2 +#define MAX_MIDIOUTDRV 2 +#define MAX_MCIMIDIDRV 2 + +typedef struct { + int unixdev; + int state; + DWORD bufsize; + MIDIOPENDESC midiDesc; + WORD wFlags; + MIDIHDR lpQueueHdr; + DWORD dwTotalPlayed; + } LINUX_MIDIIN; + +typedef struct { + int unixdev; + int state; + DWORD bufsize; + MIDIOPENDESC midiDesc; + WORD wFlags; + MIDIHDR lpQueueHdr; + DWORD dwTotalPlayed; + } LINUX_MIDIOUT; + +typedef struct { + int nUseCount; /* Incremented for each shared open */ + BOOL fShareable; /* TRUE if first open was shareable */ + WORD wNotifyDeviceID; /* MCI device ID with a pending notification */ + HANDLE hCallback; /* Callback handle for pending notification */ + HMMIO hFile; /* mmio file handle open as Element */ + MCI_OPEN_PARMS openParms; + MIDIHDR MidiHdr; + WORD dwStatus; + } LINUX_MCIMIDI; + +static LINUX_MIDIIN MidiInDev[MAX_MIDIINDRV]; +static LINUX_MIDIOUT MidiOutDev[MAX_MIDIOUTDRV]; +static LINUX_MCIMIDI MCIMidiDev[MAX_MCIMIDIDRV]; +#endif + +DWORD MIDI_mciOpen(DWORD dwFlags, LPMCI_OPEN_PARMS lpParms); +DWORD MIDI_mciClose(UINT wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms); +DWORD MIDI_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms); +DWORD MIDI_mciRecord(UINT wDevID, DWORD dwFlags, LPMCI_RECORD_PARMS lpParms); +DWORD MIDI_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms); +DWORD MIDI_mciPause(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms); +DWORD MIDI_mciResume(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms); +DWORD MIDI_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms); +DWORD MIDI_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms); +DWORD MIDI_mciGetDevCaps(UINT wDevID, DWORD dwFlags, LPMCI_GETDEVCAPS_PARMS lpParms); +DWORD MIDI_mciInfo(UINT wDevID, DWORD dwFlags, LPMCI_INFO_PARMS lpParms); + + +/************************************************************************** +* MIDI_NotifyClient [internal] +*/ +DWORD MIDI_NotifyClient(UINT wDevID, WORD wMsg, + DWORD dwParam1, DWORD dwParam2) +{ +#ifdef linux + if (MidiInDev[wDevID].wFlags != DCB_NULL && !DriverCallback( + MidiInDev[wDevID].midiDesc.dwCallback, MidiInDev[wDevID].wFlags, + MidiInDev[wDevID].midiDesc.hMidi, wMsg, + MidiInDev[wDevID].midiDesc.dwInstance, dwParam1, dwParam2)) { + printf("MIDI_NotifyClient // can't notify client !\n"); + return MMSYSERR_NOERROR; + } +#else + return MMSYSERR_NOTENABLED; +#endif +} + + +/************************************************************************** +* AUDIO_DriverProc [sample driver] +*/ +LRESULT MIDI_DriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg, + DWORD dwParam1, DWORD dwParam2) +{ +#ifdef linux + switch(wMsg) { + case DRV_LOAD: + return (LRESULT)1L; + case DRV_FREE: + return (LRESULT)1L; + case DRV_OPEN: + return (LRESULT)1L; + case DRV_CLOSE: + return (LRESULT)1L; + case DRV_ENABLE: + return (LRESULT)1L; + case DRV_DISABLE: + return (LRESULT)1L; + case DRV_QUERYCONFIGURE: + return (LRESULT)1L; + case DRV_CONFIGURE: + MessageBox((HWND)NULL, "Sample Midi Linux Driver !", + "MMLinux Driver", MB_OK); + return (LRESULT)1L; + case DRV_INSTALL: + return (LRESULT)DRVCNF_RESTART; + case DRV_REMOVE: + return (LRESULT)DRVCNF_RESTART; + case MCI_OPEN_DRIVER: + case MCI_OPEN: + return MIDI_mciOpen(dwParam1, (LPMCI_OPEN_PARMS)dwParam2); + case MCI_CLOSE_DRIVER: + case MCI_CLOSE: + return MIDI_mciClose(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2); + case MCI_PLAY: + return MIDI_mciPlay(dwDevID, dwParam1, (LPMCI_PLAY_PARMS)dwParam2); + case MCI_RECORD: + return MIDI_mciRecord(dwDevID, dwParam1, (LPMCI_RECORD_PARMS)dwParam2); + case MCI_STOP: + return MIDI_mciStop(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2); + case MCI_SET: + return MIDI_mciSet(dwDevID, dwParam1, (LPMCI_SET_PARMS)dwParam2); + case MCI_PAUSE: + return MIDI_mciPause(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2); + case MCI_RESUME: + return MIDI_mciResume(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2); + case MCI_STATUS: + return MIDI_mciStatus(dwDevID, dwParam1, (LPMCI_STATUS_PARMS)dwParam2); + case MCI_GETDEVCAPS: + return MIDI_mciGetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS)dwParam2); + case MCI_INFO: + return MIDI_mciInfo(dwDevID, dwParam1, (LPMCI_INFO_PARMS)dwParam2); + default: + return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2); + } +#else + return MMSYSERR_NOTENABLED; +#endif +} + +/************************************************************************** +* MIDI_mciOpen [internal] +*/ +DWORD MIDI_mciOpen(DWORD dwFlags, LPMCI_OPEN_PARMS lpParms) +{ +#ifdef linux + int hFile; + UINT wDevID; + OFSTRUCT OFstruct; + MIDIOPENDESC MidiDesc; + DWORD dwRet; + char str[128]; + LPSTR ptr; +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciOpen(%08X, %08X)\n", dwFlags, lpParms); +#endif + if (lpParms == NULL) return MCIERR_INTERNAL; + wDevID = lpParms->wDeviceID; + if (MCIMidiDev[wDevID].nUseCount > 0) { + /* The driver already open on this channel */ + /* If the driver was opened shareable before and this open specifies */ + /* shareable then increment the use count */ + if (MCIMidiDev[wDevID].fShareable && (dwFlags & MCI_OPEN_SHAREABLE)) + ++MCIMidiDev[wDevID].nUseCount; + else + return MCIERR_MUST_USE_SHAREABLE; + } + else { + MCIMidiDev[wDevID].nUseCount = 1; + MCIMidiDev[wDevID].fShareable = dwFlags & MCI_OPEN_SHAREABLE; + } + if (dwFlags & MCI_OPEN_ELEMENT) { + printf("MIDI_mciOpen // MCI_OPEN_ELEMENT '%s' !\n", + lpParms->lpstrElementName); +/* printf("MIDI_mciOpen // cdw='%s'\n", DOS_GetCurrentDir(DOS_GetDefaultDrive())); */ + if (strlen(lpParms->lpstrElementName) > 0) { + strcpy(str, lpParms->lpstrElementName); + AnsiUpper(str); + MCIMidiDev[wDevID].hFile = mmioOpen(str, NULL, + MMIO_ALLOCBUF | MMIO_READWRITE | MMIO_EXCLUSIVE); + if (MCIMidiDev[wDevID].hFile == 0) { + printf("MIDI_mciOpen // can't find file='%s' !\n", str); + return MCIERR_FILE_NOT_FOUND; + } + } + else + MCIMidiDev[wDevID].hFile = 0; + } + printf("MIDI_mciOpen // hFile=%u\n", MCIMidiDev[wDevID].hFile); + memcpy(&MCIMidiDev[wDevID].openParms, lpParms, sizeof(MCI_OPEN_PARMS)); + MCIMidiDev[wDevID].wNotifyDeviceID = lpParms->wDeviceID; + MCIMidiDev[wDevID].dwStatus = MCI_MODE_STOP; + MidiDesc.hMidi = 0; + if (MCIMidiDev[wDevID].hFile != 0) { + MMCKINFO mmckInfo; + MMCKINFO ckMainRIFF; + if (mmioDescend(MCIMidiDev[wDevID].hFile, &ckMainRIFF, NULL, 0) != 0) { + return MCIERR_INTERNAL; + } +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciOpen // ParentChunk ckid=%.4s fccType=%.4s cksize=%08lX \n", + (LPSTR)&ckMainRIFF.ckid, (LPSTR)&ckMainRIFF.fccType, + ckMainRIFF.cksize); +#endif + if (ckMainRIFF.ckid != FOURCC_RIFF) return MCIERR_INTERNAL; + if (ckMainRIFF.fccType != mmioFOURCC('R', 'M', 'I', 'D') && + ckMainRIFF.fccType != mmioFOURCC('M', 'T', 'h', 'd')) { + return MCIERR_INTERNAL; + } + mmckInfo.ckid = mmioFOURCC('d', 'a', 't', 'a'); + if (mmioDescend(MCIMidiDev[wDevID].hFile, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK) != 0) { + return MCIERR_INTERNAL; + } +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciOpen // Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX \n", + (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, + mmckInfo.cksize); +#endif + } + dwRet = modMessage(0, MODM_OPEN, 0, (DWORD)&MidiDesc, CALLBACK_NULL); + dwRet = midMessage(0, MIDM_OPEN, 0, (DWORD)&MidiDesc, CALLBACK_NULL); + return 0; +#else + return MMSYSERR_NOTENABLED; +#endif +} + + +/************************************************************************** +* MIDI_mciClose [internal] +*/ +DWORD MIDI_mciClose(UINT wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms) +{ +#ifdef linux + DWORD dwRet; +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciClose(%u, %08X, %08X);\n", wDevID, dwParam, lpParms); +#endif + if (MCIMidiDev[wDevID].dwStatus != MCI_MODE_STOP) { + MIDI_mciStop(wDevID, MCI_WAIT, lpParms); + } + MCIMidiDev[wDevID].dwStatus = MCI_MODE_STOP; + MCIMidiDev[wDevID].nUseCount--; + if (MCIMidiDev[wDevID].nUseCount == 0) { + if (MCIMidiDev[wDevID].hFile != 0) { + close(MCIMidiDev[wDevID].hFile); + MCIMidiDev[wDevID].hFile = 0; + } + dwRet = modMessage(0, MODM_CLOSE, 0, 0L, 0L); + if (dwRet != MMSYSERR_NOERROR) return MCIERR_INTERNAL; + dwRet = midMessage(0, MIDM_CLOSE, 0, 0L, 0L); + if (dwRet != MMSYSERR_NOERROR) return MCIERR_INTERNAL; + } + return 0; +#else + return 0; +#endif +} + + +/************************************************************************** +* MIDI_mciPlay [internal] +*/ +DWORD MIDI_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms) +{ +#ifdef linux + int count; + int start, end; + LPMIDIHDR lpMidiHdr; + DWORD dwRet; +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciPlay(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms); +#endif + if (MCIMidiDev[wDevID].hFile == 0) { + printf("MIDI_mciPlay // can't find file='%s' !\n", + MCIMidiDev[wDevID].openParms.lpstrElementName); + return MCIERR_FILE_NOT_FOUND; + } + start = 1; end = 99999; + if (dwFlags & MCI_FROM) { + start = lpParms->dwFrom; + printf("MIDI_mciPlay // MCI_FROM=%d \n", start); + } + if (dwFlags & MCI_TO) { + end = lpParms->dwTo; + printf("MIDI_mciPlay // MCI_TO=%d \n", end); + } +/**/ + if (dwFlags & MCI_NOTIFY) { + printf("MIDI_mciPlay // MCI_NOTIFY %08X !\n", lpParms->dwCallback); + switch(fork()) { + case -1: + printf("MIDI_mciPlay // Can't 'fork' process !\n"); + break; + case 0: + printf("MIDI_mciPlay // process started ! play in background ...\n"); + break; + default: + printf("MIDI_mciPlay // process started ! return to caller...\n"); + return 0; + } + } +/**/ + lpMidiHdr = &MCIMidiDev[wDevID].MidiHdr; + lpMidiHdr->lpData = (LPSTR) malloc(64000); + lpMidiHdr->dwBufferLength = 32000; + lpMidiHdr->dwUser = 0L; + lpMidiHdr->dwFlags = 0L; + dwRet = modMessage(0, MODM_PREPARE, 0, (DWORD)lpMidiHdr, sizeof(MIDIHDR)); +/* printf("MIDI_mciPlay // after MODM_PREPARE \n"); */ + MCIMidiDev[wDevID].dwStatus = MCI_MODE_PLAY; + while(MCIMidiDev[wDevID].dwStatus != MCI_MODE_STOP) { + printf("MIDI_mciPlay // MCIMidiDev[wDevID].dwStatus=%p %d\n", + &MCIMidiDev[wDevID].dwStatus, MCIMidiDev[wDevID].dwStatus); + count = mmioRead(MCIMidiDev[wDevID].hFile, lpMidiHdr->lpData, lpMidiHdr->dwBufferLength); + if (count < 1) break; + lpMidiHdr->dwBytesRecorded = count; +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciPlay // before MODM_LONGDATA lpMidiHdr=%08X dwBytesRecorded=%u\n", + lpMidiHdr, lpMidiHdr->dwBytesRecorded); +#endif +/* dwRet = modMessage(0, MODM_LONGDATA, 0, (DWORD)lpMidiHdr, sizeof(MIDIHDR)); */ + } + dwRet = modMessage(0, MODM_UNPREPARE, 0, (DWORD)lpMidiHdr, sizeof(MIDIHDR)); + if (lpMidiHdr->lpData != NULL) { + free(lpMidiHdr->lpData); + lpMidiHdr->lpData = NULL; + } + MCIMidiDev[wDevID].dwStatus = MCI_MODE_STOP; + if (dwFlags & MCI_NOTIFY) { +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciPlay // MCI_NOTIFY_SUCCESSFUL %08X !\n", lpParms->dwCallback); +#endif + mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), + MCIMidiDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); + exit(1); + } + return 0; +#else + return MMSYSERR_NOTENABLED; +#endif +} + + +/************************************************************************** +* MIDI_mciRecord [internal] +*/ +DWORD MIDI_mciRecord(UINT wDevID, DWORD dwFlags, LPMCI_RECORD_PARMS lpParms) +{ +#ifdef linux + int count; + int start, end; + LPMIDIHDR lpMidiHdr; + DWORD dwRet; +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciRecord(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms); +#endif + if (MCIMidiDev[wDevID].hFile == 0) { + printf("MIDI_mciRecord // can't find file='%s' !\n", + MCIMidiDev[wDevID].openParms.lpstrElementName); + return MCIERR_FILE_NOT_FOUND; + } + start = 1; end = 99999; + if (dwFlags & MCI_FROM) { + start = lpParms->dwFrom; + printf("MIDI_mciRecord // MCI_FROM=%d \n", start); + } + if (dwFlags & MCI_TO) { + end = lpParms->dwTo; + printf("MIDI_mciRecord // MCI_TO=%d \n", end); + } + lpMidiHdr = &MCIMidiDev[wDevID].MidiHdr; + lpMidiHdr->lpData = (LPSTR) malloc(64000); + lpMidiHdr->dwBufferLength = 32000; + lpMidiHdr->dwUser = 0L; + lpMidiHdr->dwFlags = 0L; + dwRet = midMessage(0, MIDM_PREPARE, 0, (DWORD)lpMidiHdr, sizeof(MIDIHDR)); + printf("MIDI_mciRecord // after MIDM_PREPARE \n"); + MCIMidiDev[wDevID].dwStatus = MCI_MODE_RECORD; + while(MCIMidiDev[wDevID].dwStatus != MCI_MODE_STOP) { + printf("MIDI_mciRecord // MCIMidiDev[wDevID].dwStatus=%p %d\n", + &MCIMidiDev[wDevID].dwStatus, MCIMidiDev[wDevID].dwStatus); + lpMidiHdr->dwBytesRecorded = 0; + dwRet = midMessage(0, MIDM_START, 0, 0L, 0L); + printf("MIDI_mciRecord // after MIDM_START lpMidiHdr=%08X dwBytesRecorded=%u\n", + lpMidiHdr, lpMidiHdr->dwBytesRecorded); + if (lpMidiHdr->dwBytesRecorded == 0) break; + } + printf("MIDI_mciRecord // before MIDM_UNPREPARE \n"); + dwRet = midMessage(0, MIDM_UNPREPARE, 0, (DWORD)lpMidiHdr, sizeof(MIDIHDR)); + printf("MIDI_mciRecord // after MIDM_UNPREPARE \n"); + if (lpMidiHdr->lpData != NULL) { + free(lpMidiHdr->lpData); + lpMidiHdr->lpData = NULL; + } + MCIMidiDev[wDevID].dwStatus = MCI_MODE_STOP; + if (dwFlags & MCI_NOTIFY) { +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciRecord // MCI_NOTIFY_SUCCESSFUL %08X !\n", lpParms->dwCallback); +#endif + mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), + MCIMidiDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); + } + return 0; +#else + return MMSYSERR_NOTENABLED; +#endif +} + + +/************************************************************************** +* MIDI_mciStop [internal] +*/ +DWORD MIDI_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) +{ +#ifdef linux +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciStop(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms); +#endif + if (lpParms == NULL) return MCIERR_INTERNAL; + MCIMidiDev[wDevID].dwStatus = MCI_MODE_STOP; + printf("MIDI_mciStop // MCIMidiDev[wDevID].dwStatus=%p %d\n", + &MCIMidiDev[wDevID].dwStatus, MCIMidiDev[wDevID].dwStatus); + return 0; +#else + return MCIERR_INTERNAL; +#endif +} + + +/************************************************************************** +* MIDI_mciPause [internal] +*/ +DWORD MIDI_mciPause(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) +{ +#ifdef linux +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciPause(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms); +#endif + if (lpParms == NULL) return MCIERR_INTERNAL; + return 0; +#else + return MCIERR_INTERNAL; +#endif +} + + +/************************************************************************** +* MIDI_mciResume [internal] +*/ +DWORD MIDI_mciResume(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) +{ +#ifdef linux +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciResume(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms); +#endif + if (lpParms == NULL) return MCIERR_INTERNAL; + return 0; +#else + return MCIERR_INTERNAL; +#endif +} + + +/************************************************************************** +* MIDI_mciSet [internal] +*/ +DWORD MIDI_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms) +{ +#ifdef linux +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciSet(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms); +#endif + if (lpParms == NULL) return MCIERR_INTERNAL; +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciSet // dwTimeFormat=%08X\n", lpParms->dwTimeFormat); + printf("MIDI_mciSet // dwAudio=%08X\n", lpParms->dwAudio); +#endif + if (dwFlags & MCI_SET_TIME_FORMAT) { + switch (lpParms->dwTimeFormat) { + case MCI_FORMAT_MILLISECONDS: + printf("MIDI_mciSet // MCI_FORMAT_MILLISECONDS !\n"); + break; + case MCI_FORMAT_BYTES: + printf("MIDI_mciSet // MCI_FORMAT_BYTES !\n"); + break; + case MCI_FORMAT_SAMPLES: + printf("MIDI_mciSet // MCI_FORMAT_SAMPLES !\n"); + break; + default: + printf("MIDI_mciSet // bad time format !\n"); + return MCIERR_BAD_TIME_FORMAT; + } + } + if (dwFlags & MCI_SET_VIDEO) return MCIERR_UNSUPPORTED_FUNCTION; + if (dwFlags & MCI_SET_DOOR_OPEN) return MCIERR_UNSUPPORTED_FUNCTION; + if (dwFlags & MCI_SET_DOOR_CLOSED) return MCIERR_UNSUPPORTED_FUNCTION; + if (dwFlags & MCI_SET_AUDIO) { + printf("MIDI_mciSet // MCI_SET_AUDIO !\n"); + } + if (dwFlags && MCI_SET_ON) { + printf("MIDI_mciSet // MCI_SET_ON !\n"); + if (dwFlags && MCI_SET_AUDIO_LEFT) { + printf("MIDI_mciSet // MCI_SET_AUDIO_LEFT !\n"); + } + if (dwFlags && MCI_SET_AUDIO_RIGHT) { + printf("MIDI_mciSet // MCI_SET_AUDIO_RIGHT !\n"); + } + } + if (dwFlags & MCI_SET_OFF) { + printf("MIDI_mciSet // MCI_SET_OFF !\n"); + } + if (dwFlags & MCI_SEQ_SET_MASTER) { + printf("MIDI_mciSet // MCI_SEQ_SET_MASTER !\n"); + } + if (dwFlags & MCI_SEQ_SET_SLAVE) { + printf("MIDI_mciSet // MCI_SEQ_SET_SLAVE !\n"); + } + if (dwFlags & MCI_SEQ_SET_OFFSET) { + printf("MIDI_mciSet // MCI_SEQ_SET_OFFSET !\n"); + } + if (dwFlags & MCI_SEQ_SET_PORT) { + printf("MIDI_mciSet // MCI_SEQ_SET_PORT !\n"); + } + if (dwFlags & MCI_SEQ_SET_TEMPO) { + printf("MIDI_mciSet // MCI_SEQ_SET_TEMPO !\n"); + } + return 0; +#else + return MCIERR_INTERNAL; +#endif +} + + +/************************************************************************** +* MIDI_mciStatus [internal] +*/ +DWORD MIDI_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms) +{ +#ifdef linux +#ifdef DEBUG_MCIMIDI + printf("MIDI_mciStatus(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms); +#endif + if (lpParms == NULL) return MCIERR_INTERNAL; + if (dwFlags & MCI_STATUS_ITEM) { + switch(lpParms->dwItem) { + case MCI_STATUS_CURRENT_TRACK: + lpParms->dwReturn = 1; + break; + case MCI_STATUS_LENGTH: + lpParms->dwReturn = 5555; + if (dwFlags & MCI_TRACK) { + lpParms->dwTrack = 1; + lpParms->dwReturn = 2222; + } + break; + case MCI_STATUS_MODE: + lpParms->dwReturn = MCI_MODE_STOP; + break; + case MCI_STATUS_MEDIA_PRESENT: + printf("MIDI_mciStatus // MCI_STATUS_MEDIA_PRESENT !\n"); + lpParms->dwReturn = TRUE; + break; + case MCI_STATUS_NUMBER_OF_TRACKS: + lpParms->dwReturn = 1; + break; + case MCI_STATUS_POSITION: + lpParms->dwReturn = 3333; + if (dwFlags & MCI_STATUS_START) { + lpParms->dwItem = 1; + } + if (dwFlags & MCI_TRACK) { + lpParms->dwTrack = 1; + lpParms->dwReturn = 777; + } + break; + case MCI_STATUS_READY: + printf("MIDI_mciStatus // MCI_STATUS_READY !\n"); + lpParms->dwReturn = TRUE; + break; + case MCI_STATUS_TIME_FORMAT: + printf("MIDI_mciStatus // MCI_STATUS_TIME_FORMAT !\n"); + lpParms->dwReturn = MCI_FORMAT_MILLISECONDS; + break; + case MCI_SEQ_STATUS_DIVTYPE: + printf("MIDI_mciStatus // MCI_SEQ_STATUS_DIVTYPE !\n"); + lpParms->dwReturn = 0; + break; + case MCI_SEQ_STATUS_MASTER: + printf("MIDI_mciStatus // MCI_SEQ_STATUS_MASTER !\n"); + lpParms->dwReturn = 0; + break; + case MCI_SEQ_STATUS_SLAVE: + printf("MIDI_mciStatus // MCI_SEQ_STATUS_SLAVE !\n"); + lpParms->dwReturn = 0; + break; + case MCI_SEQ_STATUS_OFFSET: + printf("MIDI_mciStatus // MCI_SEQ_STATUS_OFFSET !\n"); + lpParms->dwReturn = 0; + break; + case MCI_SEQ_STATUS_PORT: + printf("MIDI_mciStatus // MCI_SEQ_STATUS_PORT !\n"); + lpParms->dwReturn = 0; + break; + case MCI_SEQ_STATUS_TEMPO: + printf("MIDI_mciStatus // MCI_SEQ_STATUS_TEMPO !\n"); + lpParms->dwReturn = 0; + break; + default: + printf("MIDI_mciStatus // unknowm command %04X !\n", lpParms->dwItem); + return MCIERR_UNRECOGNIZED_COMMAND; + } + } + if (dwFlags & MCI_NOTIFY) { + printf("MIDI_mciStatus // MCI_NOTIFY_SUCCESSFUL %08X !\n", lpParms->dwCallback); + mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), + MCIMidiDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL); + } + return 0; +#else + return MCIERR_INTERNAL; +#endif +} + +/************************************************************************** +* MIDI_mciGetDevCaps [internal] +*/ +DWORD MIDI_mciGetDevCaps(UINT wDevID, DWORD dwFlags, + LPMCI_GETDEVCAPS_PARMS lpParms) +{ +#ifdef linux + printf("MIDI_mciGetDevCaps(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; + if (dwFlags & MCI_GETDEVCAPS_ITEM) { + switch(lpParms->dwItem) { + case MCI_GETDEVCAPS_CAN_RECORD: + lpParms->dwReturn = TRUE; + break; + case MCI_GETDEVCAPS_HAS_AUDIO: + lpParms->dwReturn = TRUE; + break; + case MCI_GETDEVCAPS_HAS_VIDEO: + lpParms->dwReturn = FALSE; + break; + case MCI_GETDEVCAPS_DEVICE_TYPE: + lpParms->dwReturn = MCI_DEVTYPE_SEQUENCER; + break; + case MCI_GETDEVCAPS_USES_FILES: + lpParms->dwReturn = TRUE; + break; + case MCI_GETDEVCAPS_COMPOUND_DEVICE: + lpParms->dwReturn = TRUE; + break; + case MCI_GETDEVCAPS_CAN_EJECT: + lpParms->dwReturn = FALSE; + break; + case MCI_GETDEVCAPS_CAN_PLAY: + lpParms->dwReturn = TRUE; + break; + case MCI_GETDEVCAPS_CAN_SAVE: + lpParms->dwReturn = FALSE; + break; + default: + return MCIERR_UNRECOGNIZED_COMMAND; + } + } + return 0; +#else + return MCIERR_INTERNAL; +#endif +} + +/************************************************************************** +* MIDI_mciInfo [internal] +*/ +DWORD MIDI_mciInfo(UINT wDevID, DWORD dwFlags, LPMCI_INFO_PARMS lpParms) +{ +#ifdef linux + printf("MIDI_mciInfo(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms); + if (lpParms == NULL) return MCIERR_INTERNAL; + lpParms->lpstrReturn = NULL; + switch(dwFlags) { + case MCI_INFO_PRODUCT: + lpParms->lpstrReturn = "Linux Sound System 0.5"; + break; + case MCI_INFO_FILE: + lpParms->lpstrReturn = "FileName"; + break; + default: + return MCIERR_UNRECOGNIZED_COMMAND; + } + if (lpParms->lpstrReturn != NULL) + lpParms->dwRetSize = strlen(lpParms->lpstrReturn); + else + lpParms->dwRetSize = 0; + return 0; +#else + return MCIERR_INTERNAL; +#endif +} + + +/*-----------------------------------------------------------------------*/ + + +/************************************************************************** +* midGetDevCaps [internal] +*/ +DWORD midGetDevCaps(WORD wDevID, LPMIDIINCAPS lpCaps, DWORD dwSize) +{ + printf("midGetDevCaps(%u, %08X, %08X);\n", wDevID, lpCaps, dwSize); + return MMSYSERR_NOTENABLED; +} + +/************************************************************************** +* midOpen [internal] +*/ +DWORD midOpen(WORD wDevID, LPMIDIOPENDESC lpDesc, DWORD dwFlags) +{ + printf("modOpen(%u, %08X, %08X);\n", wDevID, lpDesc, dwFlags); + return MMSYSERR_NOTENABLED; +} + +/************************************************************************** +* midClose [internal] +*/ +DWORD midClose(WORD wDevID) +{ + printf("midClose(%u);\n", wDevID); + return MMSYSERR_NOTENABLED; +} + +/************************************************************************** +* midAddBuffer [internal] +*/ +DWORD midAddBuffer(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) +{ + printf("midAddBuffer(%u, %08X, %08X);\n", wDevID, lpMidiHdr, dwSize); + return MMSYSERR_NOTENABLED; +} + +/************************************************************************** +* midPrepare [internal] +*/ +DWORD midPrepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) +{ + printf("midPrepare(%u, %08X, %08X);\n", wDevID, lpMidiHdr, dwSize); + return MMSYSERR_NOTENABLED; +} + +/************************************************************************** +* midUnprepare [internal] +*/ +DWORD midUnprepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) +{ + printf("midUnprepare(%u, %08X, %08X);\n", wDevID, lpMidiHdr, dwSize); + return MMSYSERR_NOTENABLED; +} + +/************************************************************************** +* midReset [internal] +*/ +DWORD midReset(WORD wDevID) +{ + printf("midReset(%u);\n", wDevID); + return MMSYSERR_NOTENABLED; +} + + +/************************************************************************** +* midStart [internal] +*/ +DWORD midStart(WORD wDevID) +{ + printf("midStart(%u);\n", wDevID); + return MMSYSERR_NOTENABLED; +} + + +/************************************************************************** +* midStop [internal] +*/ +DWORD midStop(WORD wDevID) +{ + printf("midStop(%u);\n", wDevID); + return MMSYSERR_NOTENABLED; +} + + +/************************************************************************** +* midMessage [sample driver] +*/ +DWORD midMessage(WORD wDevID, WORD wMsg, DWORD dwUser, + DWORD dwParam1, DWORD dwParam2) +{ + printf("midMessage(%u, %04X, %08X, %08X, %08X);\n", + wDevID, wMsg, dwUser, dwParam1, dwParam2); + switch(wMsg) { + case MIDM_OPEN: + return midOpen(wDevID, (LPMIDIOPENDESC)dwParam1, dwParam2); + case MIDM_CLOSE: + return midClose(wDevID); + case MIDM_ADDBUFFER: + return midAddBuffer(wDevID, (LPMIDIHDR)dwParam1, dwParam2); + case MIDM_PREPARE: + return midPrepare(wDevID, (LPMIDIHDR)dwParam1, dwParam2); + case MIDM_UNPREPARE: + return midUnprepare(wDevID, (LPMIDIHDR)dwParam1, dwParam2); + case MIDM_GETDEVCAPS: + return midGetDevCaps(wDevID, (LPMIDIINCAPS)dwParam1, dwParam2); + case MIDM_GETNUMDEVS: + return 1L; + case MIDM_RESET: + return midReset(wDevID); + case MIDM_START: + return midStart(wDevID); + case MIDM_STOP: + return midStop(wDevID); + } + return MMSYSERR_NOTSUPPORTED; +} + + + +/*-----------------------------------------------------------------------*/ + + +/************************************************************************** +* modGetDevCaps [internal] +*/ +DWORD modGetDevCaps(WORD wDevID, LPMIDIOUTCAPS lpCaps, DWORD dwSize) +{ + printf("modGetDevCaps(%u, %08X, %08X);\n", wDevID, lpCaps, dwSize); + return MMSYSERR_NOTENABLED; +} + + +/************************************************************************** +* modOpen [internal] +*/ +DWORD modOpen(WORD wDevID, LPMIDIOPENDESC lpDesc, DWORD dwFlags) +{ + printf("modOpen(%u, %08X, %08X);\n", wDevID, lpDesc, dwFlags); + return MMSYSERR_NOTENABLED; +} + + +/************************************************************************** +* modClose [internal] +*/ +DWORD modClose(WORD wDevID) +{ + printf("modClose(%u);\n", wDevID); + return MMSYSERR_NOTENABLED; +} + +/************************************************************************** +* modData [internal] +*/ +DWORD modData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) +{ + printf("modData(%u, %08X, %08X);\n", wDevID, lpMidiHdr, dwSize); + return MMSYSERR_NOTENABLED; +} + +/************************************************************************** +* modLongData [internal] +*/ +DWORD modLongData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) +{ + printf("modLongData(%u, %08X, %08X);\n", wDevID, lpMidiHdr, dwSize); + return MMSYSERR_NOTENABLED; +} + +/************************************************************************** +* modPrepare [internal] +*/ +DWORD modPrepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) +{ + printf("modPrepare(%u, %08X, %08X);\n", wDevID, lpMidiHdr, dwSize); + return MMSYSERR_NOTENABLED; +} + +/************************************************************************** +* modUnprepare [internal] +*/ +DWORD modUnprepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) +{ + printf("modUnprepare(%u, %08X, %08X);\n", wDevID, lpMidiHdr, dwSize); + return MMSYSERR_NOTENABLED; +} + +/************************************************************************** +* modReset [internal] +*/ +DWORD modReset(WORD wDevID) +{ + printf("modReset(%u);\n", wDevID); + return MMSYSERR_NOTENABLED; +} + + +/************************************************************************** +* modGetPosition [internal] +*/ +DWORD modGetPosition(WORD wDevID, LPMMTIME lpTime, DWORD uSize) +{ + printf("modGetposition(%u, %08X, %08X);\n", wDevID, lpTime, uSize); + return MMSYSERR_NOTENABLED; +} + + +/************************************************************************** +* modMessage [sample driver] +*/ +DWORD modMessage(WORD wDevID, WORD wMsg, DWORD dwUser, + DWORD dwParam1, DWORD dwParam2) +{ + printf("modMessage(%u, %04X, %08X, %08X, %08X);\n", + wDevID, wMsg, dwUser, dwParam1, dwParam2); + switch(wMsg) { + case MODM_OPEN: + return modOpen(wDevID, (LPMIDIOPENDESC)dwParam1, dwParam2); + case MODM_CLOSE: + return modClose(wDevID); + case MODM_DATA: + return modData(wDevID, (LPMIDIHDR)dwParam1, dwParam2); + case MODM_LONGDATA: + return modLongData(wDevID, (LPMIDIHDR)dwParam1, dwParam2); + case MODM_PREPARE: + return modPrepare(wDevID, (LPMIDIHDR)dwParam1, dwParam2); + case MODM_UNPREPARE: + return modUnprepare(wDevID, (LPMIDIHDR)dwParam1, dwParam2); + case MODM_GETDEVCAPS: + return modGetDevCaps(wDevID, (LPMIDIOUTCAPS)dwParam1, dwParam2); + case MODM_GETNUMDEVS: + return 1L; + case MODM_GETVOLUME: + return 0L; + case MODM_SETVOLUME: + return 0L; + case MODM_RESET: + return modReset(wDevID); + } + return MMSYSERR_NOTSUPPORTED; +} + + +/*-----------------------------------------------------------------------*/ + + +#endif /* #ifdef BUILTIN_MMSYSTEM */ diff --git a/misc/mmaux.c b/misc/mmaux.c index 80ed111caea..1c4cc063c2a 100644 --- a/misc/mmaux.c +++ b/misc/mmaux.c @@ -11,6 +11,8 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994"; #ifdef BUILTIN_MMSYSTEM +#define EMULATE_SB16 + #include #include #include @@ -53,10 +55,55 @@ DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPS lpCaps, DWORD dwSize) return MMSYSERR_NOTENABLED; } if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) { + close(mixer); printf("AUX_GetDevCaps // unable read mixer !\n"); return MMSYSERR_NOTENABLED; } close(mixer); +#ifdef EMULATE_SB16 + lpCaps->wMid = 0x0002; + lpCaps->vDriverVersion = 0x0200; + lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME; + switch (wDevID) { + case 0: + lpCaps->wPid = 0x0196; + strcpy(lpCaps->szPname, "SB16 Aux: Wave"); + lpCaps->wTechnology = AUXCAPS_AUXIN; + break; + case 1: + lpCaps->wPid = 0x0197; + strcpy(lpCaps->szPname, "SB16 Aux: Midi Synth"); + lpCaps->wTechnology = AUXCAPS_AUXIN; + break; + case 2: + lpCaps->wPid = 0x0191; + strcpy(lpCaps->szPname, "SB16 Aux: CD"); + lpCaps->wTechnology = AUXCAPS_CDAUDIO; + break; + case 3: + lpCaps->wPid = 0x0192; + strcpy(lpCaps->szPname, "SB16 Aux: Line-In"); + lpCaps->wTechnology = AUXCAPS_AUXIN; + break; + case 4: + lpCaps->wPid = 0x0193; + strcpy(lpCaps->szPname, "SB16 Aux: Mic"); + lpCaps->wTechnology = AUXCAPS_AUXIN; + break; + case 5: + lpCaps->wPid = 0x0194; + strcpy(lpCaps->szPname, "SB16 Aux: Master"); + lpCaps->wTechnology = AUXCAPS_AUXIN; + break; + } +#else + lpCaps->wMid = 0xAA; + lpCaps->wPid = 0x55; + lpCaps->vDriverVersion = 0x0100; + strcpy(lpCaps->szPname, "Generic Linux Auxiliary Driver"); + lpCaps->wTechnology = AUXCAPS_CDAUDIO; + lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME; +#endif return MMSYSERR_NOERROR; #else return MMSYSERR_NOTENABLED; @@ -67,12 +114,13 @@ DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPS lpCaps, DWORD dwSize) /************************************************************************** * AUX_GetVolume [internal] */ -DWORD AUX_GetVolume(WORD wDevID, DWORD dwParam) +DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol) { #ifdef linux int mixer; int volume; - printf("AUX_GetVolume(%u, %08X);\n", wDevID, dwParam); + printf("AUX_GetVolume(%u, %08X);\n", wDevID, lpdwVol); + if (lpdwVol == NULL) return MMSYSERR_NOTENABLED; if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) { printf("Linux 'AUX_GetVolume' // mixer device not available !\n"); return MMSYSERR_NOTENABLED; @@ -82,6 +130,7 @@ DWORD AUX_GetVolume(WORD wDevID, DWORD dwParam) return MMSYSERR_NOTENABLED; } close(mixer); + *lpdwVol = MAKELONG(volume, volume); return MMSYSERR_NOERROR; #else return MMSYSERR_NOTENABLED; @@ -125,9 +174,10 @@ DWORD auxMessage(WORD wDevID, WORD wMsg, DWORD dwUser, case AUXDM_GETDEVCAPS: return AUX_GetDevCaps(wDevID, (LPAUXCAPS)dwParam1, dwParam2); case AUXDM_GETNUMDEVS: - return 0L; + printf("AUX_GetNumDevs();\n"); + return 1L; case AUXDM_GETVOLUME: - return AUX_GetVolume(wDevID, dwParam1); + return AUX_GetVolume(wDevID, (LPDWORD)dwParam1); case AUXDM_SETVOLUME: return AUX_SetVolume(wDevID, dwParam1); } diff --git a/misc/mmsystem.c b/misc/mmsystem.c index 4da49f94713..db60012bd96 100644 --- a/misc/mmsystem.c +++ b/misc/mmsystem.c @@ -16,6 +16,15 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; #include "user.h" #include "driver.h" #include "mmsystem.h" +#include "stddebug.h" +/* #define DEBUG_MCI */ +/* #undef DEBUG_MCI */ +/* #define DEBUG_MMTIME */ +/* #undef DEBUG_MMTIME */ +/* #define DEBUG_MMIO */ +/* #undef DEBUG_MMIO */ +#include "debug.h" + static WORD mciActiveDev = 0; static BOOL mmTimeStarted = FALSE; @@ -291,8 +300,10 @@ UINT WINAPI auxGetNumDevs() */ UINT WINAPI auxGetDevCaps(UINT uDeviceID, AUXCAPS FAR* lpCaps, UINT uSize) { - printf("auxGetDevCaps !\n"); - return 0; + printf("auxGetDevCaps(%04X, %08X, %d) !\n", + uDeviceID, lpCaps, uSize); + return auxMessage(uDeviceID, AUXDM_GETDEVCAPS, + 0L, (DWORD)lpCaps, (DWORD)uSize); } /************************************************************************** @@ -300,8 +311,8 @@ UINT WINAPI auxGetDevCaps(UINT uDeviceID, AUXCAPS FAR* lpCaps, UINT uSize) */ UINT WINAPI auxGetVolume(UINT uDeviceID, DWORD FAR* lpdwVolume) { - printf("auxGetVolume !\n"); - return 0; + printf("auxGetVolume(%04X, %08X) !\n", uDeviceID, lpdwVolume); + return auxMessage(uDeviceID, AUXDM_GETVOLUME, 0L, (DWORD)lpdwVolume, 0L); } /************************************************************************** @@ -309,8 +320,8 @@ UINT WINAPI auxGetVolume(UINT uDeviceID, DWORD FAR* lpdwVolume) */ UINT WINAPI auxSetVolume(UINT uDeviceID, DWORD dwVolume) { - printf("auxSetVolume !\n"); - return 0; + printf("auxSetVolume(%04X, %08X) !\n", uDeviceID, dwVolume); + return auxMessage(uDeviceID, AUXDM_SETVOLUME, 0L, dwVolume, 0L); } /************************************************************************** @@ -318,8 +329,10 @@ UINT WINAPI auxSetVolume(UINT uDeviceID, DWORD dwVolume) */ DWORD WINAPI auxOutMessage(UINT uDeviceID, UINT uMessage, DWORD dw1, DWORD dw2) { - printf("auxOutMessage !\n"); - return 0L; + LPMIDIOPENDESC lpDesc; + printf("auxOutMessage(%04X, %04X, %08X, %08X)\n", + uDeviceID, uMessage, dw1, dw2); + return auxMessage(uDeviceID, uMessage, 0L, dw1, dw2); } /************************************************************************** @@ -656,11 +669,11 @@ DWORD mciOpen(DWORD dwParam, LPMCI_OPEN_PARMS lpParms) return WAVE_DriverProc(0, 0, MCI_OPEN_DRIVER, dwParam, (DWORD)lpParms); case MCI_DEVTYPE_SEQUENCER: - printf("MCI_OPEN // No SEQUENCER yet !\n"); - return MCIERR_DEVICE_NOT_INSTALLED; + return MIDI_DriverProc(0, 0, MCI_OPEN_DRIVER, + dwParam, (DWORD)lpParms); case MCI_DEVTYPE_ANIMATION: - printf("MCI_OPEN // No ANIMATION yet !\n"); - return MCIERR_DEVICE_NOT_INSTALLED; + return ANIM_DriverProc(0, 0, MCI_OPEN_DRIVER, + dwParam, (DWORD)lpParms); case MCI_DEVTYPE_DIGITAL_VIDEO: printf("MCI_OPEN // No DIGITAL_VIDEO yet !\n"); return MCIERR_DEVICE_NOT_INSTALLED; @@ -691,6 +704,10 @@ DWORD mciClose(UINT wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms) dwRet = WAVE_DriverProc(mciDrv[wDevID].wDeviceID, 0, MCI_CLOSE, dwParam, (DWORD)lpParms); break; + case MCI_DEVTYPE_SEQUENCER: + dwRet = MIDI_DriverProc(mciDrv[wDevID].wDeviceID, 0, + MCI_CLOSE, dwParam, (DWORD)lpParms); + break; default: printf("mciClose() // unknown type=%04X !\n", mciDrv[wDevID].wType); } @@ -718,10 +735,8 @@ DWORD mciSound(UINT wDevID, DWORD dwParam, LPMCI_SOUND_PARMS lpParms) DWORD mciSendCommand(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2) { HDRVR hDrv = 0; -#ifdef DEBUG_MCI - printf("mciSendCommand(%04X, %04X, %08X, %08X)\n", + dprintf_mci(stddeb, "mciSendCommand(%04X, %04X, %08X, %08X)\n", wDevID, wMsg, dwParam1, dwParam2); -#endif switch(wMsg) { case MCI_OPEN: return mciOpen(dwParam1, (LPMCI_OPEN_PARMS)dwParam2); @@ -738,6 +753,9 @@ DWORD mciSendCommand(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2) case MCI_DEVTYPE_WAVEFORM_AUDIO: return WAVE_DriverProc(mciDrv[wDevID].wDeviceID, hDrv, wMsg, dwParam1, dwParam2); + case MCI_DEVTYPE_SEQUENCER: + return MIDI_DriverProc(mciDrv[wDevID].wDeviceID, hDrv, + wMsg, dwParam1, dwParam2); default: printf("mciSendCommand() // unknown type=%04X !\n", mciDrv[wDevID].wType); @@ -807,8 +825,11 @@ HTASK WINAPI mciGetCreatorTask(UINT uDeviceID) */ UINT WINAPI midiOutGetNumDevs(void) { + UINT count = 0; printf("midiOutGetNumDevs\n"); - return 0; + count += modMessage(0, MODM_GETNUMDEVS, 0L, 0L, 0L); + printf("midiOutGetNumDevs return %u \n", count); + return count; } /************************************************************************** @@ -885,9 +906,34 @@ msg# 343 : There are no MIDI devices installed on the system. Use the Drivers op UINT WINAPI midiOutOpen(HMIDIOUT FAR* lphMidiOut, UINT uDeviceID, DWORD dwCallback, DWORD dwInstance, DWORD dwFlags) { - printf("midiOutOpen\n"); + HMIDI hMidiOut; + LPMIDIOPENDESC lpDesc; + DWORD dwRet; + BOOL bMapperFlg = FALSE; if (lphMidiOut != NULL) *lphMidiOut = 0; - return 0; + printf("midiOutOpen(%08X, %d, %08X, %08X, %08X);\n", + lphMidiOut, uDeviceID, dwCallback, dwInstance, dwFlags); + if (uDeviceID == (UINT)MIDI_MAPPER) { + printf("midiOutOpen // MIDI_MAPPER mode requested !\n"); + bMapperFlg = TRUE; + uDeviceID = 0; + } + hMidiOut = GlobalAlloc(GMEM_MOVEABLE, sizeof(MIDIOPENDESC)); + if (lphMidiOut != NULL) *lphMidiOut = hMidiOut; + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiOut); + if (lpDesc == NULL) return MMSYSERR_NOMEM; + lpDesc->hMidi = hMidiOut; + lpDesc->dwCallback = dwCallback; + lpDesc->dwInstance = dwInstance; + while(uDeviceID < MAXMIDIDRIVERS) { + dwRet = modMessage(uDeviceID, MODM_OPEN, + lpDesc->dwInstance, (DWORD)lpDesc, 0L); + if (dwRet == MMSYSERR_NOERROR) break; + if (!bMapperFlg) break; + uDeviceID++; + printf("midiOutOpen // MIDI_MAPPER mode ! try next driver...\n"); + } + return dwRet; } /************************************************************************** @@ -895,8 +941,11 @@ UINT WINAPI midiOutOpen(HMIDIOUT FAR* lphMidiOut, UINT uDeviceID, */ UINT WINAPI midiOutClose(HMIDIOUT hMidiOut) { - printf("midiOutClose\n"); - return 0; + LPMIDIOPENDESC lpDesc; + printf("midiOutClose(%04X)\n", hMidiOut); + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiOut); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return modMessage(0, MODM_CLOSE, lpDesc->dwInstance, 0L, 0L); } /************************************************************************** @@ -905,8 +954,13 @@ UINT WINAPI midiOutClose(HMIDIOUT hMidiOut) UINT WINAPI midiOutPrepareHeader(HMIDIOUT hMidiOut, MIDIHDR FAR* lpMidiOutHdr, UINT uSize) { - printf("midiOutPrepareHeader\n"); - return 0; + LPMIDIOPENDESC lpDesc; + printf("midiOutPrepareHeader(%04X, %08X, %d)\n", + hMidiOut, lpMidiOutHdr, uSize); + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiOut); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return modMessage(0, MODM_PREPARE, lpDesc->dwInstance, + (DWORD)lpMidiOutHdr, (DWORD)uSize); } /************************************************************************** @@ -915,8 +969,13 @@ UINT WINAPI midiOutPrepareHeader(HMIDIOUT hMidiOut, UINT WINAPI midiOutUnprepareHeader(HMIDIOUT hMidiOut, MIDIHDR FAR* lpMidiOutHdr, UINT uSize) { - printf("midiOutUnprepareHeader\n"); - return 0; + LPMIDIOPENDESC lpDesc; + printf("midiOutUnprepareHeader(%04X, %08X, %d)\n", + hMidiOut, lpMidiOutHdr, uSize); + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiOut); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return modMessage(0, MODM_UNPREPARE, lpDesc->dwInstance, + (DWORD)lpMidiOutHdr, (DWORD)uSize); } /************************************************************************** @@ -924,8 +983,11 @@ UINT WINAPI midiOutUnprepareHeader(HMIDIOUT hMidiOut, */ UINT WINAPI midiOutShortMsg(HMIDIOUT hMidiOut, DWORD dwMsg) { - printf("midiOutShortMsg\n"); - return 0; + LPMIDIOPENDESC lpDesc; + printf("midiOutShortMsg(%04X, %08X)\n", hMidiOut, dwMsg); + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiOut); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return modMessage(0, MODM_DATA, lpDesc->dwInstance, dwMsg, 0L); } /************************************************************************** @@ -934,8 +996,13 @@ UINT WINAPI midiOutShortMsg(HMIDIOUT hMidiOut, DWORD dwMsg) UINT WINAPI midiOutLongMsg(HMIDIOUT hMidiOut, MIDIHDR FAR* lpMidiOutHdr, UINT uSize) { - printf("midiOutLongMsg\n"); - return 0; + LPMIDIOPENDESC lpDesc; + printf("midiOutLongMsg(%04X, %08X, %d)\n", + hMidiOut, lpMidiOutHdr, uSize); + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiOut); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return modMessage(0, MODM_LONGDATA, lpDesc->dwInstance, + (DWORD)lpMidiOutHdr, (DWORD)uSize); } /************************************************************************** @@ -997,9 +1064,15 @@ UINT WINAPI midiOutGetID(HMIDIOUT hMidiOut, UINT FAR* lpuDeviceID) /************************************************************************** * midiOutMessage [MMSYSTEM.216] */ -DWORD WINAPI midiOutMessage(HMIDIOUT hMidiOut, UINT uMessage, DWORD dw1, DWORD dw2) +DWORD WINAPI midiOutMessage(HMIDIOUT hMidiOut, UINT uMessage, + DWORD dwParam1, DWORD dwParam2) { - printf("midiOutMessage\n"); + LPMIDIOPENDESC lpDesc; + printf("midiOutMessage(%04X, %04X, %08X, %08X)\n", + hMidiOut, uMessage, dwParam1, dwParam2); + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiOut); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return modMessage(0, uMessage, lpDesc->dwInstance, dwParam1, dwParam2); return 0; } @@ -1037,9 +1110,34 @@ UINT WINAPI midiInGetErrorText(UINT uError, LPSTR lpText, UINT uSize) UINT WINAPI midiInOpen(HMIDIIN FAR* lphMidiIn, UINT uDeviceID, DWORD dwCallback, DWORD dwInstance, DWORD dwFlags) { - printf("midiInOpen\n"); + HMIDI hMidiIn; + LPMIDIOPENDESC lpDesc; + DWORD dwRet; + BOOL bMapperFlg = FALSE; if (lphMidiIn != NULL) *lphMidiIn = 0; - return 0; + printf("midiInOpen(%08X, %d, %08X, %08X, %08X);\n", + lphMidiIn, uDeviceID, dwCallback, dwInstance, dwFlags); + if (uDeviceID == (UINT)MIDI_MAPPER) { + printf("midiInOpen // MIDI_MAPPER mode requested !\n"); + bMapperFlg = TRUE; + uDeviceID = 0; + } + hMidiIn = GlobalAlloc(GMEM_MOVEABLE, sizeof(MIDIOPENDESC)); + if (lphMidiIn != NULL) *lphMidiIn = hMidiIn; + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiIn); + if (lpDesc == NULL) return MMSYSERR_NOMEM; + lpDesc->hMidi = hMidiIn; + lpDesc->dwCallback = dwCallback; + lpDesc->dwInstance = dwInstance; + while(uDeviceID < MAXMIDIDRIVERS) { + dwRet = midMessage(uDeviceID, MIDM_OPEN, + lpDesc->dwInstance, (DWORD)lpDesc, 0L); + if (dwRet == MMSYSERR_NOERROR) break; + if (!bMapperFlg) break; + uDeviceID++; + printf("midiInOpen // MIDI_MAPPER mode ! try next driver...\n"); + } + return dwRet; } /************************************************************************** @@ -1047,8 +1145,11 @@ UINT WINAPI midiInOpen(HMIDIIN FAR* lphMidiIn, UINT uDeviceID, */ UINT WINAPI midiInClose(HMIDIIN hMidiIn) { - printf("midiInClose\n"); - return 0; + LPMIDIOPENDESC lpDesc; + printf("midiInClose(%04X)\n", hMidiIn); + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiIn); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return midMessage(0, MIDM_CLOSE, lpDesc->dwInstance, 0L, 0L); } /************************************************************************** @@ -1057,8 +1158,13 @@ UINT WINAPI midiInClose(HMIDIIN hMidiIn) UINT WINAPI midiInPrepareHeader(HMIDIIN hMidiIn, MIDIHDR FAR* lpMidiInHdr, UINT uSize) { - printf("midiInPrepareHeader\n"); - return 0; + LPMIDIOPENDESC lpDesc; + printf("midiInPrepareHeader(%04X, %08X, %d)\n", + hMidiIn, lpMidiInHdr, uSize); + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiIn); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return midMessage(0, MIDM_PREPARE, lpDesc->dwInstance, + (DWORD)lpMidiInHdr, (DWORD)uSize); } /************************************************************************** @@ -1067,8 +1173,13 @@ UINT WINAPI midiInPrepareHeader(HMIDIIN hMidiIn, UINT WINAPI midiInUnprepareHeader(HMIDIIN hMidiIn, MIDIHDR FAR* lpMidiInHdr, UINT uSize) { - printf("midiInUnprepareHeader\n"); - return 0; + LPMIDIOPENDESC lpDesc; + printf("midiInUnprepareHeader(%04X, %08X, %d)\n", + hMidiIn, lpMidiInHdr, uSize); + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiIn); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return midMessage(0, MIDM_UNPREPARE, lpDesc->dwInstance, + (DWORD)lpMidiInHdr, (DWORD)uSize); } /************************************************************************** @@ -1123,8 +1234,12 @@ UINT WINAPI midiInGetID(HMIDIIN hMidiIn, UINT FAR* lpuDeviceID) DWORD WINAPI midiInMessage(HMIDIIN hMidiIn, UINT uMessage, DWORD dwParam1, DWORD dwParam2) { - printf("midiInMessage\n"); - return 0; + LPMIDIOPENDESC lpDesc; + printf("midiInMessage(%04X, %04X, %08X, %08X)\n", + hMidiIn, uMessage, dwParam1, dwParam2); + lpDesc = (LPMIDIOPENDESC) GlobalLock(hMidiIn); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return midMessage(0, uMessage, lpDesc->dwInstance, dwParam1, dwParam2); } @@ -1445,6 +1560,12 @@ UINT WINAPI waveOutGetID(HWAVEOUT hWaveOut, UINT FAR* lpuDeviceID) DWORD WINAPI waveOutMessage(HWAVEOUT hWaveOut, UINT uMessage, DWORD dwParam1, DWORD dwParam2) { + LPWAVEOPENDESC lpDesc; + printf("waveOutMessage(%04X, %04X, %08X, %08X)\n", + hWaveOut, uMessage, dwParam1, dwParam2); + lpDesc = (LPWAVEOPENDESC) GlobalLock(hWaveOut); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return wodMessage(0, uMessage, lpDesc->dwInstance, dwParam1, dwParam2); } /************************************************************************** @@ -1668,6 +1789,12 @@ UINT WINAPI waveInGetID(HWAVEIN hWaveIn, UINT FAR* lpuDeviceID) DWORD WINAPI waveInMessage(HWAVEIN hWaveIn, UINT uMessage, DWORD dwParam1, DWORD dwParam2) { + LPWAVEOPENDESC lpDesc; + printf("waveInMessage(%04X, %04X, %08X, %08X)\n", + hWaveIn, uMessage, dwParam1, dwParam2); + lpDesc = (LPWAVEOPENDESC) GlobalLock(hWaveIn); + if (lpDesc == NULL) return MMSYSERR_INVALHANDLE; + return widMessage(0, uMessage, lpDesc->dwInstance, dwParam1, dwParam2); } @@ -1684,10 +1811,7 @@ WORD FAR PASCAL MMSysTimeCallback(HWND hWnd, WORD wMsg, int nID, DWORD dwTime) if (lpTimer->wCurTime == 0) { lpTimer->wCurTime = lpTimer->wDelay; if (lpTimer->lpFunc != NULL) { -#ifdef DEBUG_MMTIME - printf("MMSysTimeCallback // before CallBack16 !\n"); - fflush(stdout); -#endif + dprintf_mmtime(stddeb,"MMSysTimeCallback // before CallBack16 !\n"); #ifdef WINELIB (*lpTimer->lpFunc)(lpTimer->wTimerID, (WORD)0, lpTimer->dwUser, (DWORD)0, (DWORD)0); @@ -1696,10 +1820,8 @@ WORD FAR PASCAL MMSysTimeCallback(HWND hWnd, WORD wMsg, int nID, DWORD dwTime) 0, (int)lpTimer->wTimerID, 0, (int)0, 2, lpTimer->dwUser, 2, 0, 2, 0); #endif -#ifdef DEBUG_MMTIME - printf("MMSysTimeCallback // after CallBack16 !\n"); + dprintf_mmtime(stddeb, "MMSysTimeCallback // after CallBack16 !\n"); fflush(stdout); -#endif } if (lpTimer->wFlags & TIME_ONESHOT) timeKillEvent(lpTimer->wTimerID); @@ -1883,9 +2005,7 @@ LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch) { int count; LPMMIOINFO lpmminfo; -#ifdef DEBUG_MMIO - printf("mmioRead(%04X, %08X, %ld);\n", hmmio, pch, cch); -#endif + dprintf_mmio(stddeb, "mmioRead(%04X, %08X, %ld);\n", hmmio, pch, cch); lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); if (lpmminfo == NULL) return 0; count = _lread(LOWORD(lpmminfo->dwReserved2), pch, cch); @@ -2036,27 +2156,21 @@ UINT WINAPI mmioDescend(HMMIO hmmio, MMCKINFO FAR* lpck, { DWORD dwfcc, dwOldPos; LPMMIOINFO lpmminfo; -#ifdef DEBUG_MMIO - printf("mmioDescend(%04X, %08X, %08X, %04X);\n", + dprintf_mmio(stddeb, "mmioDescend(%04X, %08X, %08X, %04X);\n", hmmio, lpck, lpckParent, uFlags); -#endif if (lpck == NULL) return 0; lpmminfo = (LPMMIOINFO)GlobalLock(hmmio); if (lpmminfo == NULL) return 0; dwfcc = lpck->ckid; dwOldPos = _llseek(LOWORD(lpmminfo->dwReserved2), 0, SEEK_CUR); if (lpckParent != NULL) { -#ifdef DEBUG_MMIO - printf("mmioDescend // seek inside parent at %ld !\n", lpckParent->dwDataOffset); -#endif + dprintf_mmio(stddeb, "mmioDescend // seek inside parent at %ld !\n", lpckParent->dwDataOffset); dwOldPos = _llseek(LOWORD(lpmminfo->dwReserved2), lpckParent->dwDataOffset, SEEK_SET); } if ((uFlags & MMIO_FINDCHUNK) || (uFlags & MMIO_FINDRIFF) || (uFlags & MMIO_FINDLIST)) { -#ifdef DEBUG_MMIO - printf("mmioDescend // MMIO_FINDxxxx dwfcc=%08X !\n", dwfcc); -#endif + dprintf_mmio(stddeb, "mmioDescend // MMIO_FINDxxxx dwfcc=%08X !\n", dwfcc); while (TRUE) { if (_lread(LOWORD(lpmminfo->dwReserved2), (LPSTR)lpck, sizeof(MMCKINFO)) < sizeof(MMCKINFO)) { @@ -2064,10 +2178,8 @@ UINT WINAPI mmioDescend(HMMIO hmmio, MMCKINFO FAR* lpck, GlobalUnlock(hmmio); return MMIOERR_CHUNKNOTFOUND; } -#ifdef DEBUG_MMIO - printf("mmioDescend // dwfcc=%08X ckid=%08X cksize=%08X !\n", + dprintf_mmio(stddeb, "mmioDescend // dwfcc=%08X ckid=%08X cksize=%08X !\n", dwfcc, lpck->ckid, lpck->cksize); -#endif if (dwfcc == lpck->ckid) break; dwOldPos += lpck->cksize + 2 * sizeof(DWORD); if (lpck->ckid == FOURCC_RIFF || lpck->ckid == FOURCC_LIST) @@ -2089,11 +2201,9 @@ UINT WINAPI mmioDescend(HMMIO hmmio, MMCKINFO FAR* lpck, lpck->dwDataOffset += sizeof(DWORD); lpmminfo->lDiskOffset = _llseek(LOWORD(lpmminfo->dwReserved2), lpck->dwDataOffset, SEEK_SET); -#ifdef DEBUG_MMIO - printf("mmioDescend // lpck->ckid=%08X lpck->cksize=%ld !\n", + dprintf_mmio(stddeb, "mmioDescend // lpck->ckid=%08X lpck->cksize=%ld !\n", lpck->ckid, lpck->cksize); printf("mmioDescend // lpck->fccType=%08X !\n", lpck->fccType); -#endif return 0; } diff --git a/misc/profile.c b/misc/profile.c index 7bd94881d6c..12a961e5279 100644 --- a/misc/profile.c +++ b/misc/profile.c @@ -25,8 +25,11 @@ static char Copyright [] = "Copyright (C) 1993 Miguel de Icaza"; #include "wine.h" #include "windows.h" #include "prototypes.h" +#include "stddebug.h" +/* #define DEBUG_PROFILE */ +/* #undef DEBUG_PROFILE */ +#include "debug.h" -/* #define DEBUG */ #define STRSIZE 255 #define xmalloc(x) malloc(x) @@ -97,15 +100,11 @@ static TSecHeader *load (char *filename) file = GetIniFileName(filename); -#ifdef DEBUG - printf("Load %s\n", file); -#endif + dprintf_profile(stddeb,"Load %s\n", file); if ((f = fopen (file, "r"))==NULL) return NULL; -#ifdef DEBUG - printf("Loading %s\n", file); -#endif + dprintf_profile(stddeb,"Loading %s\n", file); state = FirstBrace; @@ -121,9 +120,7 @@ static TSecHeader *load (char *filename) next = CharBuffer; SecHeader->AppName = strdup (CharBuffer); state = IgnoreToEOL; -#ifdef DEBUG - printf("%s: section %s\n", file, CharBuffer); -#endif + dprintf_profile(stddeb,"%s: section %s\n", file, CharBuffer); } else *next++ = c; break; @@ -151,7 +148,7 @@ static TSecHeader *load (char *filename) if (state == FirstBrace) /* On first pass, don't allow dangling keys */ break; - if (c == ' ' || c == '\t') + if (c == '\t') break; if (c == '\n' || c == ';' || overflow) /* Abort Definition */ @@ -167,15 +164,14 @@ static TSecHeader *load (char *filename) TKeys *temp; temp = SecHeader->Keys; + while(next[-1]==' ')next--; *next = '\0'; SecHeader->Keys = (TKeys *) xmalloc (sizeof (TKeys)); SecHeader->Keys->link = temp; SecHeader->Keys->KeyName = strdup (CharBuffer); state = KeyValue; next = CharBuffer; -#ifdef DEBUG - printf("%s: key %s\n", file, CharBuffer); -#endif + dprintf_profile(stddeb,"%s: key %s\n", file, CharBuffer); } else *next++ = c; break; @@ -186,10 +182,8 @@ static TSecHeader *load (char *filename) SecHeader->Keys->Value = strdup (CharBuffer); state = c == '\n' ? KeyDef : IgnoreToEOL; next = CharBuffer; -#ifdef DEBUG - printf ("[%s] (%s)=%s\n", SecHeader->AppName, + dprintf_profile (stddeb, "[%s] (%s)=%s\n", SecHeader->AppName, SecHeader->Keys->KeyName, SecHeader->Keys->Value); -#endif } else *next++ = c; break; @@ -243,28 +237,25 @@ static short GetSetProfile (int set, LPSTR AppName, LPSTR KeyName, char *p = ReturnedString; int left = Size - 2; int slen; -#ifdef DEBUG_PROFILE - printf("GetSetProfile // KeyName == NULL, Enumeration !\n"); -#endif + + dprintf_profile(stddeb,"GetSetProfile // KeyName == NULL, Enumeration !\n"); for (key = section->Keys; key; key = key->link){ if (left < 1) { - printf("GetSetProfile // No more storage for enum !\n"); + dprintf_profile(stddeb,"GetSetProfile // No more storage for enum !\n"); return (Size - 2); } slen = min(strlen(key->KeyName) + 1, left); -#ifdef DEBUG_PROFILE - printf("GetSetProfile // strncpy(%08X, %08X, %d);\n", + dprintf_profile(stddeb,"GetSetProfile // strncpy(%08X, %08X, %d);\n", ReturnedString, key->Value, slen); -#endif strncpy (p, key->KeyName, slen); -#ifdef DEBUG_PROFILE - printf("GetSetProfile // enum '%s' !\n", p); -#endif + dprintf_profile(stddeb,"GetSetProfile // enum '%s' !\n", p); left -= slen; p += slen; } *p = '\0'; +#ifdef DEBUG_PROFILE printf("GetSetProfile // normal end of enum !\n"); +#endif return (Size - 2 - left); } for (key = section->Keys; key; key = key->link){ @@ -311,10 +302,8 @@ short GetPrivateProfileString (LPSTR AppName, LPSTR KeyName, { int v; -#ifdef DEBUG_PROFILE - printf("GetPrivateProfileString ('%s', '%s', '%s', %08X, %d, %s\n", + dprintf_profile(stddeb,"GetPrivateProfileString ('%s', '%s', '%s', %08X, %d, %s\n", AppName, KeyName, Default, ReturnedString, Size, FileName); -#endif v = GetSetProfile (0,AppName,KeyName,Default,ReturnedString,Size,FileName); if (AppName) return strlen (ReturnedString); diff --git a/misc/property.c b/misc/property.c index b58d1731dd8..9733ae14225 100644 --- a/misc/property.c +++ b/misc/property.c @@ -3,9 +3,6 @@ */ static char Copyright[] = "Copyright Martin Ayotte, 1994"; -/* -#define DEBUG_PROP -*/ #include #include @@ -14,6 +11,11 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994"; #include "windows.h" #include "heap.h" #include "win.h" +#include "callback.h" +#include "stddebug.h" +/* #define DEBUG_PROP */ +/* #undef DEBUG_PROP */ +#include "debug.h" typedef struct tagPROPENTRY { LPSTR PropName; @@ -33,12 +35,10 @@ HANDLE RemoveProp(HWND hWnd, LPSTR lpStr) WND *wndPtr; LPPROPENTRY lpProp; HANDLE hOldData; -#ifdef DEBUG_PROP if (((DWORD)lpStr & 0xFFFF0000) == 0L) - printf("RemoveProp(%04X, Atom %04X)\n", hWnd, LOWORD((DWORD)lpStr)); + dprintf_prop(stddeb, "RemoveProp(%04X, Atom %04X)\n", hWnd, LOWORD((DWORD)lpStr)); else - printf("RemoveProp(%04X, '%s')\n", hWnd, lpStr); -#endif + dprintf_prop(stddeb, "RemoveProp(%04X, '%s')\n", hWnd, lpStr); wndPtr = WIN_FindWndPtr(hWnd); if (wndPtr == NULL) { printf("RemoveProp // Bad Window handle !\n"); @@ -46,9 +46,7 @@ HANDLE RemoveProp(HWND hWnd, LPSTR lpStr) } lpProp = (LPPROPENTRY) GlobalLock(wndPtr->hProp); if (lpProp == NULL) { -#ifdef DEBUG_PROP - printf("Property List Empty !\n"); -#endif + dprintf_prop(stddeb, "Property List Empty !\n"); return 0; } while (TRUE) { @@ -57,9 +55,7 @@ HANDLE RemoveProp(HWND hWnd, LPSTR lpStr) (((DWORD)lpStr & 0xFFFF0000) != 0L && lpProp->PropName != NULL && strcmp(lpProp->PropName, lpStr) == 0)) { -#ifdef DEBUG_PROP - printf("RemoveProp // Property found ! hData=%04X\n", lpProp->hData); -#endif + dprintf_prop(stddeb, "RemoveProp // Property found ! hData=%04X\n", lpProp->hData); hOldData = lpProp->hData; if (lpProp->lpPrevProp != NULL) lpProp->lpPrevProp->lpNextProp = lpProp->lpNextProp; @@ -74,9 +70,7 @@ HANDLE RemoveProp(HWND hWnd, LPSTR lpStr) lpProp = lpProp->lpNextProp; } GlobalUnlock(wndPtr->hProp); -#ifdef DEBUG_PROP - printf("RemoveProp // Property not found !\n"); -#endif + dprintf_prop(stddeb, "RemoveProp // Property not found !\n"); return 0; } @@ -88,12 +82,10 @@ HANDLE GetProp(HWND hWnd, LPSTR lpStr) { WND *wndPtr; LPPROPENTRY lpProp; -#ifdef DEBUG_PROP if (((DWORD)lpStr & 0xFFFF0000) == 0L) - printf("GetProp(%04X, Atom %04X)\n", hWnd, LOWORD((DWORD)lpStr)); + dprintf_prop(stddeb, "GetProp(%04X, Atom %04X)\n", hWnd, LOWORD((DWORD)lpStr)); else - printf("GetProp(%04X, '%s')\n", hWnd, lpStr); -#endif + dprintf_prop(stddeb, "GetProp(%04X, '%s')\n", hWnd, lpStr); wndPtr = WIN_FindWndPtr(hWnd); if (wndPtr == NULL) { printf("GetProp // Bad Window handle !\n"); @@ -101,9 +93,7 @@ HANDLE GetProp(HWND hWnd, LPSTR lpStr) } lpProp = (LPPROPENTRY) GlobalLock(wndPtr->hProp); if (lpProp == NULL) { -#ifdef DEBUG_PROP - printf("Property List Empty !\n"); -#endif + dprintf_prop(stddeb, "Property List Empty !\n"); return 0; } while (TRUE) { @@ -112,18 +102,14 @@ HANDLE GetProp(HWND hWnd, LPSTR lpStr) (((DWORD)lpStr & 0xFFFF0000) != 0L && lpProp->PropName != NULL && strcmp(lpProp->PropName, lpStr) == 0)) { -#ifdef DEBUG_PROP - printf("GetProp // Property found ! hData=%04X\n", lpProp->hData); -#endif + dprintf_prop(stddeb, "GetProp // Property found ! hData=%04X\n", lpProp->hData); GlobalUnlock(wndPtr->hProp); return lpProp->hData; } if (lpProp->lpNextProp == NULL) break; lpProp = lpProp->lpNextProp; } -#ifdef DEBUG_PROP - printf("GetProp // Property not found !\n"); -#endif + dprintf_prop(stddeb, "GetProp // Property not found !\n"); GlobalUnlock(wndPtr->hProp); return 0; } @@ -138,13 +124,11 @@ BOOL SetProp(HWND hWnd, LPSTR lpStr, HANDLE hData) HANDLE hNewProp; LPPROPENTRY lpNewProp; LPPROPENTRY lpProp; -#ifdef DEBUG_PROP if (((DWORD)lpStr & 0xFFFF0000) == 0L) - printf("SetProp(%04X, Atom %04X, %04X)\n", + dprintf_prop(stddeb, "SetProp(%04X, Atom %04X, %04X)\n", hWnd, LOWORD((DWORD)lpStr), hData); else - printf("SetProp(%04X, '%s', %04X)\n", hWnd, lpStr, hData); -#endif + dprintf_prop(stddeb, "SetProp(%04X, '%s', %04X)\n", hWnd, lpStr, hData); wndPtr = WIN_FindWndPtr(hWnd); if (wndPtr == NULL) { printf("SetProp // Bad Window handle !\n"); @@ -158,9 +142,7 @@ BOOL SetProp(HWND hWnd, LPSTR lpStr, HANDLE hData) (((DWORD)lpStr & 0xFFFF0000) != 0L && lpProp->PropName != NULL && strcmp(lpProp->PropName, lpStr) == 0)) { -#ifdef DEBUG_PROP - printf("SetProp // change already exinsting property !\n"); -#endif + dprintf_prop(stddeb, "SetProp // change already exinsting property !\n"); lpProp->hData = hData; GlobalUnlock(wndPtr->hProp); return TRUE; @@ -176,15 +158,11 @@ BOOL SetProp(HWND hWnd, LPSTR lpStr, HANDLE hData) GlobalUnlock(wndPtr->hProp); return FALSE; } -#ifdef DEBUG_PROP - printf("SetProp // entry allocated %08X\n", lpNewProp); -#endif + dprintf_prop(stddeb, "SetProp // entry allocated %08X\n", lpNewProp); if (lpProp == NULL) { wndPtr->hProp = hNewProp; lpNewProp->lpPrevProp = NULL; -#ifdef DEBUG_PROP - printf("SetProp // first entry \n"); -#endif + dprintf_prop(stddeb, "SetProp // first entry \n"); } else { lpProp->lpNextProp = lpNewProp; @@ -232,7 +210,7 @@ int EnumProps(HWND hWnd, FARPROC lpEnumFunc) printf("Property List Empty !\n"); return 0; } - if (lpEnumFunc != NULL) return 0; + if (lpEnumFunc == NULL) return 0; while (TRUE) { printf("EnumProps // lpProp->Atom=%04X !\n", lpProp->Atom); str = (LPSTR)MAKELONG(lpProp->Atom, 0); @@ -244,8 +222,10 @@ int EnumProps(HWND hWnd, FARPROC lpEnumFunc) nRet = (*lpEnumFunc)((HWND)hWnd, (WORD)0, (LPSTR)str, (HANDLE)lpProp->hData); #else - nRet = CallBack16(lpEnumFunc, 4, (HANDLE)lpProp->hData, - (LPSTR)str, (WORD)0, (HWND)hWnd); + nRet = CallBack16(lpEnumFunc, 3, + CALLBACK_SIZE_WORD, (HWND)hWnd, + CALLBACK_SIZE_LONG, (LPSTR)str, + CALLBACK_SIZE_WORD, (HANDLE)lpProp->hData); #endif if (nRet == 0) break; if (lpProp->lpNextProp == NULL) break; diff --git a/misc/shell.c b/misc/shell.c index 6682100889f..71af863f9db 100644 --- a/misc/shell.c +++ b/misc/shell.c @@ -8,10 +8,11 @@ #include "prototypes.h" #include "windows.h" #include "shell.h" +#include "stddebug.h" +/* #define DEBUG_REG */ +/* #undef DEBUG_REG */ +#include "debug.h" -/* -#define DEBUG_REG -*/ LPKEYSTRUCT lphRootKey = NULL; @@ -27,31 +28,23 @@ LONG RegOpenKey(HKEY hKey, LPCSTR lpSubKey, HKEY FAR *lphKey) LPKEYSTRUCT lpKey = lphRootKey; LPSTR ptr; char str[128]; - int size; -#ifdef DEBUG_REG - fprintf(stderr, "RegOpenKey(%04X, %08X='%s', %08X)\n", + + dprintf_reg(stddeb, "RegOpenKey(%04X, %08X='%s', %08X)\n", hKey, lpSubKey, lpSubKey, lphKey); -#endif if (lpKey == NULL) return ERROR_BADKEY; if (lpSubKey == NULL) return ERROR_INVALID_PARAMETER; if (lphKey == NULL) return ERROR_INVALID_PARAMETER; if (hKey != HKEY_CLASSES_ROOT) { -#ifdef DEBUG_REG - printf("RegOpenKey // specific key = %04X !\n", hKey); -#endif + dprintf_reg(stddeb,"RegOpenKey // specific key = %04X !\n", hKey); lpKey = (LPKEYSTRUCT)GlobalLock(hKey); } while ( (ptr = strchr(lpSubKey, '\\')) != NULL ) { strncpy(str, lpSubKey, (LONG)ptr - (LONG)lpSubKey); str[(LONG)ptr - (LONG)lpSubKey] = '\0'; lpSubKey = ptr + 1; -#ifdef DEBUG_REG - printf("RegOpenKey // next level '%s' !\n", str); -#endif + dprintf_reg(stddeb,"RegOpenKey // next level '%s' !\n", str); while(TRUE) { -#ifdef DEBUG_REG - printf("RegOpenKey // '%s' <-> '%s' !\n", str, lpKey->lpSubKey); -#endif + dprintf_reg(stddeb,"RegOpenKey // '%s' <-> '%s' !\n", str, lpKey->lpSubKey); if (lpKey->lpSubKey != NULL && lpKey->lpSubKey[0] != '\0' && strcmp(lpKey->lpSubKey, str) == 0) { lpKey = lpKey->lpSubLvl; @@ -78,9 +71,7 @@ LONG RegOpenKey(HKEY hKey, LPCSTR lpSubKey, HKEY FAR *lphKey) lpKey = lpKey->lpNextKey; } *lphKey = lpKey->hKey; -#ifdef DEBUG_REG - printf("RegOpenKey // return hKey=%04X !\n", lpKey->hKey); -#endif + dprintf_reg(stddeb,"RegOpenKey // return hKey=%04X !\n", lpKey->hKey); return ERROR_SUCCESS; } @@ -97,35 +88,25 @@ LONG RegCreateKey(HKEY hKey, LPCSTR lpSubKey, HKEY FAR *lphKey) LONG dwRet; LPSTR ptr; char str[128]; -#ifdef DEBUG_REG - fprintf(stderr, "RegCreateKey(%04X, '%s', %08X)\n", hKey, lpSubKey, lphKey); -#endif + dprintf_reg(stddeb, "RegCreateKey(%04X, '%s', %08X)\n", hKey, lpSubKey, lphKey); if (lpSubKey == NULL) return ERROR_INVALID_PARAMETER; if (lphKey == NULL) return ERROR_INVALID_PARAMETER; if (hKey != HKEY_CLASSES_ROOT) { -#ifdef DEBUG_REG - printf("RegCreateKey // specific key = %04X !\n", hKey); -#endif + dprintf_reg(stddeb,"RegCreateKey // specific key = %04X !\n", hKey); lpKey = (LPKEYSTRUCT)GlobalLock(hKey); } while ( (ptr = strchr(lpSubKey, '\\')) != NULL ) { strncpy(str, lpSubKey, (LONG)ptr - (LONG)lpSubKey); str[(LONG)ptr - (LONG)lpSubKey] = '\0'; lpSubKey = ptr + 1; -#ifdef DEBUG_REG - printf("RegCreateKey // next level '%s' !\n", str); -#endif + dprintf_reg(stddeb,"RegCreateKey // next level '%s' !\n", str); lpPrevKey = lpKey; while(TRUE) { -#ifdef DEBUG_REG - printf("RegCreateKey // '%s' <-> '%s' !\n", str, lpKey->lpSubKey); -#endif + dprintf_reg(stddeb,"RegCreateKey // '%s' <-> '%s' !\n", str, lpKey->lpSubKey); if (lpKey->lpSubKey != NULL && strcmp(lpKey->lpSubKey, str) == 0) { if (lpKey->lpSubLvl == NULL) { -#ifdef DEBUG_REG - printf("RegCreateKey // '%s' found !\n", str); -#endif + dprintf_reg(stddeb,"RegCreateKey // '%s' found !\n", str); if ( (ptr = strchr(lpSubKey, '\\')) != NULL ) { strncpy(str, lpSubKey, (LONG)ptr - (LONG)lpSubKey); str[(LONG)ptr - (LONG)lpSubKey] = '\0'; @@ -181,9 +162,7 @@ LONG RegCreateKey(HKEY hKey, LPCSTR lpSubKey, HKEY FAR *lphKey) lpNewKey->lpNextKey = NULL; lpNewKey->lpSubLvl = NULL; *lphKey = hNewKey; -#ifdef DEBUG_REG - printf("RegCreateKey // successful '%s' key=%04X !\n", lpSubKey, hNewKey); -#endif + dprintf_reg(stddeb,"RegCreateKey // successful '%s' key=%04X !\n", lpSubKey, hNewKey); return ERROR_SUCCESS; } @@ -193,7 +172,7 @@ LONG RegCreateKey(HKEY hKey, LPCSTR lpSubKey, HKEY FAR *lphKey) */ LONG RegCloseKey(HKEY hKey) { - fprintf(stderr, "EMPTY STUB !!! RegCloseKey(%04X);\n", hKey); + dprintf_reg(stdnimp, "EMPTY STUB !!! RegCloseKey(%04X);\n", hKey); return ERROR_INVALID_PARAMETER; } @@ -203,7 +182,7 @@ LONG RegCloseKey(HKEY hKey) */ LONG RegDeleteKey(HKEY hKey, LPCSTR lpSubKey) { - fprintf(stderr, "EMPTY STUB !!! RegDeleteKey(%04X, '%s');\n", + dprintf_reg(stdnimp, "EMPTY STUB !!! RegDeleteKey(%04X, '%s');\n", hKey, lpSubKey); return ERROR_INVALID_PARAMETER; } @@ -218,16 +197,12 @@ LONG RegSetValue(HKEY hKey, LPCSTR lpSubKey, DWORD dwType, HKEY hRetKey; LPKEYSTRUCT lpKey; LONG dwRet; -#ifdef DEBUG_REG - fprintf(stderr, "RegSetValue(%04X, '%s', %08X, '%s', %08X);\n", + dprintf_reg(stddeb, "RegSetValue(%04X, '%s', %08X, '%s', %08X);\n", hKey, lpSubKey, dwType, lpVal, dwIgnored); -#endif if (lpSubKey == NULL) return ERROR_INVALID_PARAMETER; if (lpVal == NULL) return ERROR_INVALID_PARAMETER; if ((dwRet = RegOpenKey(hKey, lpSubKey, &hRetKey)) != ERROR_SUCCESS) { -#ifdef DEBUG_REG - fprintf(stderr, "RegSetValue // key not found ... so create it !\n"); -#endif + dprintf_reg(stddeb, "RegSetValue // key not found ... so create it !\n"); if ((dwRet = RegCreateKey(hKey, lpSubKey, &hRetKey)) != ERROR_SUCCESS) { fprintf(stderr, "RegSetValue // key creation error %04X !\n", dwRet); return dwRet; @@ -238,9 +213,7 @@ LONG RegSetValue(HKEY hKey, LPCSTR lpSubKey, DWORD dwType, if (lpKey->lpValue != NULL) free(lpKey->lpValue); lpKey->lpValue = malloc(strlen(lpVal) + 1); strcpy(lpKey->lpValue, lpVal); -#ifdef DEBUG_REG - printf("RegSetValue // successful key='%s' val='%s' !\n", lpSubKey, lpVal); -#endif + dprintf_reg(stddeb,"RegSetValue // successful key='%s' val='%s' !\n", lpSubKey, lpVal); return ERROR_SUCCESS; } @@ -254,7 +227,7 @@ LONG RegQueryValue(HKEY hKey, LPCSTR lpSubKey, LPSTR lpVal, LONG FAR *lpcb) LPKEYSTRUCT lpKey; LONG dwRet; int size; - fprintf(stderr, "RegQueryValue(%04X, '%s', %08X, %08X);\n", + dprintf_reg(stddeb, "RegQueryValue(%04X, '%s', %08X, %08X);\n", hKey, lpSubKey, lpVal, lpcb); if (lpSubKey == NULL) return ERROR_INVALID_PARAMETER; if (lpVal == NULL) return ERROR_INVALID_PARAMETER; @@ -274,7 +247,7 @@ LONG RegQueryValue(HKEY hKey, LPCSTR lpSubKey, LPSTR lpVal, LONG FAR *lpcb) lpVal[0] = '\0'; *lpcb = (LONG)0; } - printf("RegQueryValue // return '%s' !\n", lpVal); + dprintf_reg(stddeb,"RegQueryValue // return '%s' !\n", lpVal); return ERROR_SUCCESS; } @@ -284,7 +257,7 @@ LONG RegQueryValue(HKEY hKey, LPCSTR lpSubKey, LPSTR lpVal, LONG FAR *lpcb) */ LONG RegEnumKey(HKEY hKey, DWORD dwSubKey, LPSTR lpBuf, DWORD dwSize) { - fprintf(stderr, "RegEnumKey : Empty Stub !!!\n"); + dprintf_reg(stdnimp, "RegEnumKey : Empty Stub !!!\n"); return ERROR_INVALID_PARAMETER; } @@ -293,7 +266,7 @@ LONG RegEnumKey(HKEY hKey, DWORD dwSubKey, LPSTR lpBuf, DWORD dwSize) */ void DragAcceptFiles(HWND hWnd, BOOL b) { - fprintf(stderr, "DragAcceptFiles : Empty Stub !!!\n"); + dprintf_reg(stdnimp, "DragAcceptFiles : Empty Stub !!!\n"); } @@ -302,7 +275,7 @@ void DragAcceptFiles(HWND hWnd, BOOL b) */ void DragQueryFile(HDROP h, UINT u, LPSTR u2, UINT u3) { - fprintf(stderr, "DragQueryFile : Empty Stub !!!\n"); + dprintf_reg(stdnimp, "DragQueryFile : Empty Stub !!!\n"); } @@ -312,7 +285,7 @@ void DragQueryFile(HDROP h, UINT u, LPSTR u2, UINT u3) */ void DragFinish(HDROP h) { - fprintf(stderr, "DragFinish : Empty Stub !!!\n"); + dprintf_reg(stdnimp, "DragFinish : Empty Stub !!!\n"); } @@ -322,8 +295,8 @@ void DragFinish(HDROP h) */ BOOL DragQueryPoint(HDROP h, POINT FAR *p) { - fprintf(stderr, "DragQueryPoinyt : Empty Stub !!!\n"); - + dprintf_reg(stdnimp, "DragQueryPoinyt : Empty Stub !!!\n"); + return FALSE; } @@ -332,12 +305,12 @@ BOOL DragQueryPoint(HDROP h, POINT FAR *p) */ HINSTANCE ShellExecute(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, int iShowCmd) { - fprintf(stderr, "ShellExecute // hWnd=%04X\n", hWnd); - fprintf(stderr, "ShellExecute // lpOperation='%s'\n", lpOperation); - fprintf(stderr, "ShellExecute // lpFile='%s'\n", lpFile); - fprintf(stderr, "ShellExecute // lpParameters='%s'\n", lpParameters); - fprintf(stderr, "ShellExecute // lpDirectory='%s'\n", lpDirectory); - fprintf(stderr, "ShellExecute // iShowCmd=%04X\n", iShowCmd); + dprintf_reg(stdnimp, "ShellExecute // hWnd=%04X\n", hWnd); + dprintf_reg(stdnimp, "ShellExecute // lpOperation='%s'\n", lpOperation); + dprintf_reg(stdnimp, "ShellExecute // lpFile='%s'\n", lpFile); + dprintf_reg(stdnimp, "ShellExecute // lpParameters='%s'\n", lpParameters); + dprintf_reg(stdnimp, "ShellExecute // lpDirectory='%s'\n", lpDirectory); + dprintf_reg(stdnimp, "ShellExecute // iShowCmd=%04X\n", iShowCmd); return 2; /* file not found */ } @@ -347,7 +320,7 @@ HINSTANCE ShellExecute(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpPa */ HINSTANCE FindExecutable(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult) { - fprintf(stderr, "FindExecutable : Empty Stub !!!\n"); + dprintf_reg(stdnimp, "FindExecutable : Empty Stub !!!\n"); } @@ -371,7 +344,7 @@ INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon) else *AppMisc = 0; - return DialogBox(hSysRes, "SHELL_ABOUT_MSGBOX", hWnd, (FARPROC)AboutDlgProc); + return DialogBox(hSysRes, "SHELL_ABOUT_MSGBOX", hWnd, (WNDPROC)AboutDlgProc); } @@ -407,14 +380,14 @@ HICON ExtractIcon(HINSTANCE hInst, LPCSTR lpszExeFileName, UINT nIconIndex) int count; HICON hIcon = 0; HINSTANCE hInst2 = hInst; - fprintf(stderr, "ExtractIcon(%04X, '%s', %d\n", + dprintf_reg(stddeb, "ExtractIcon(%04X, '%s', %d\n", hInst, lpszExeFileName, nIconIndex); if (lpszExeFileName != NULL) { hInst2 = LoadLibrary(lpszExeFileName); } if (hInst2 != 0 && nIconIndex == (UINT)-1) { count = GetRsrcCount(hInst2, NE_RSCTYPE_GROUP_ICON); - printf("ExtractIcon // '%s' has %d icons !\n", lpszExeFileName, count); + dprintf_reg(stddeb, "ExtractIcon // '%s' has %d icons !\n", lpszExeFileName, count); return (HICON)count; } if (hInst2 != hInst && hInst2 != 0) { @@ -429,7 +402,7 @@ HICON ExtractIcon(HINSTANCE hInst, LPCSTR lpszExeFileName, UINT nIconIndex) */ HICON ExtractAssociatedIcon(HINSTANCE hInst,LPSTR lpIconPath, LPWORD lpiIcon) { - fprintf(stderr, "ExtractAssociatedIcon : Empty Stub !!!\n"); + dprintf_reg(stdnimp, "ExtractAssociatedIcon : Empty Stub !!!\n"); } /************************************************************************* @@ -437,7 +410,7 @@ HICON ExtractAssociatedIcon(HINSTANCE hInst,LPSTR lpIconPath, LPWORD lpiIcon) */ int RegisterShellHook(void *ptr) { - fprintf(stderr, "RegisterShellHook : Empty Stub !!!\n"); + dprintf_reg(stdnimp, "RegisterShellHook : Empty Stub !!!\n"); return 0; } @@ -447,5 +420,5 @@ int RegisterShellHook(void *ptr) */ int ShellHookProc(void) { - fprintf(stderr, "ShellHookProc : Empty Stub !!!\n"); + dprintf_reg(stdnimp, "ShellHookProc : Empty Stub !!!\n"); } diff --git a/misc/spy.c b/misc/spy.c index 25987111d8f..f121b1846f7 100644 --- a/misc/spy.c +++ b/misc/spy.c @@ -268,7 +268,7 @@ void SpyMessage(HWND hwnd, WORD msg, WORD wParam, LONG lParam) strstr(SpyFilters, msg_name) == NULL) { msg_name[strlen(msg_name) - 1] = '\0'; - fprintf(SpyFp, "%04.4x %20.20s %04.4x %04.4x %08.8x\n", + fprintf(SpyFp, "%04x %20.20s %04x %04x %08lx\n", hwnd, msg_name, msg, wParam, lParam); } #endif diff --git a/misc/stress.c b/misc/stress.c index e503ef9d7b1..3223fa7d42e 100644 --- a/misc/stress.c +++ b/misc/stress.c @@ -2,23 +2,22 @@ #include #include "windows.h" #include "stress.h" +#include "stddebug.h" +/* #define DEBUG_STRESS */ +/* #undef DEBUG_STRESS */ +#include "debug.h" -#define STRESS_DEBUG int AllocDiskSpace(long lLeft, UINT uDrive) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: AllocDiskSpace %d, %ld\n", uDrive, lLeft); -#endif + dprintf_stress(stdnimp, "stress.dll: AllocDiskSpace %d, %ld\n", uDrive, lLeft); return 1; } int AllocFileHandles(int Left) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: AllocFileHandles %d\n", Left); -#endif + dprintf_stress(stddeb, "stress.dll: AllocFileHandles %d\n", Left); if (Left < 0) return -1; @@ -28,64 +27,48 @@ int AllocFileHandles(int Left) BOOL AllocGDIMem(UINT uLeft) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: AllocGDIMem %d\n", uLeft); -#endif + dprintf_stress(stddeb, "stress.dll: AllocGDIMem %d\n", uLeft); return 1; } BOOL AllocMem(DWORD dwLeft) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: AllocMem %ld\n", dwLeft); -#endif + dprintf_stress(stdnimp, "stress.dll: AllocMem %ld\n", dwLeft); return 1; } BOOL AllocUserMem(UINT uContig) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: AllocUserMem %d\n", uContig); -#endif + dprintf_stress(stddeb, "stress.dll: AllocUserMem %d\n", uContig); return 1; } void FreeAllMem(void) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: FreeAllMem\n"); -#endif + dprintf_stress(stddeb, "stress.dll: FreeAllMem\n"); } void FreeAllGDIMem(void) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: FreeAllGDIMem\n"); -#endif + dprintf_stress(stddeb, "stress.dll: FreeAllGDIMem\n"); } void FreeAllUserMem(void) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: FreeAllUserMem\n"); -#endif + dprintf_stress(stddeb, "stress.dll: FreeAllUserMem\n"); } void GetFreeAllUserMem(void) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: GetFreeAllUserMem\n"); -#endif + dprintf_stress(stddeb, "stress.dll: GetFreeAllUserMem\n"); } int GetFreeFileHandles(void) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: GetFreeFileHandles\n"); -#endif + dprintf_stress(stddeb, "stress.dll: GetFreeFileHandles\n"); #ifndef OPEN_MAX return _POSIX_OPEN_MAX; @@ -96,14 +79,10 @@ int GetFreeFileHandles(void) void UnAllocDiskSpace(UINT drive) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: UnAllocDiskSpace %d\n", drive); -#endif + dprintf_stress(stddeb, "stress.dll: UnAllocDiskSpace %d\n", drive); } void UnAllocFileHandles(void) { -#ifdef STRESS_DEBUG - fprintf(stderr, "stress.dll: GetFreeAllUserMem\n"); -#endif + dprintf_stress(stddeb, "stress.dll: GetFreeAllUserMem\n"); } diff --git a/misc/winsocket.c b/misc/winsocket.c index 5195e2a0696..f9e2b1df9b9 100644 --- a/misc/winsocket.c +++ b/misc/winsocket.c @@ -19,8 +19,11 @@ #include #include "heap.h" #include "winsock.h" +#include "stddebug.h" +/* #define DEBUG_WINSOCK */ +/* #undef DEBUG_WINSOCK */ +#include "debug.h" -#define DEBUG_WINSOCK static WORD wsa_errno; static int wsa_initted; @@ -180,9 +183,7 @@ SOCKET Winsock_accept(SOCKET s, struct sockaddr *addr, INT *addrlen) { int sock; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_accept: socket %d, ptr %8x, length %d\n", s, (int) addr, addrlen); -#endif + dprintf_winsock(stddeb, "WSA_accept: socket %d, ptr %8x, length %d\n", s, (int) addr, addrlen); if ((sock = accept(s, addr, (int *) addrlen)) < 0) { errno_to_wsaerrno(); @@ -193,10 +194,8 @@ SOCKET Winsock_accept(SOCKET s, struct sockaddr *addr, INT *addrlen) INT Winsock_bind(SOCKET s, struct sockaddr *name, INT namelen) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_bind: socket %d, ptr %8x, length %d\n", s, (int) name, namelen); + dprintf_winsock(stddeb, "WSA_bind: socket %d, ptr %8x, length %d\n", s, (int) name, namelen); dump_sockaddr(name); -#endif if (bind(s, name, namelen) < 0) { errno_to_wsaerrno(); @@ -207,9 +206,7 @@ INT Winsock_bind(SOCKET s, struct sockaddr *name, INT namelen) INT Winsock_closesocket(SOCKET s) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_closesocket: socket %d\n", s); -#endif + dprintf_winsock(stddeb, "WSA_closesocket: socket %d\n", s); FD_CLR(s, &fd_in_use); @@ -222,10 +219,8 @@ INT Winsock_closesocket(SOCKET s) INT Winsock_connect(SOCKET s, struct sockaddr *name, INT namelen) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_connect: socket %d, ptr %8x, length %d\n", s, (int) name, namelen); + dprintf_winsock(stddeb, "WSA_connect: socket %d, ptr %8x, length %d\n", s, (int) name, namelen); dump_sockaddr(name); -#endif if (connect(s, name, namelen) < 0) { errno_to_wsaerrno(); @@ -236,10 +231,8 @@ INT Winsock_connect(SOCKET s, struct sockaddr *name, INT namelen) INT Winsock_getpeername(SOCKET s, struct sockaddr *name, INT *namelen) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_getpeername: socket: %d, ptr %8x, ptr %8x\n", s, (int) name, *namelen); + dprintf_winsock(stddeb, "WSA_getpeername: socket: %d, ptr %8x, ptr %8x\n", s, (int) name, *namelen); dump_sockaddr(name); -#endif if (getpeername(s, name, (int *) namelen) < 0) { errno_to_wsaerrno(); @@ -250,9 +243,7 @@ INT Winsock_getpeername(SOCKET s, struct sockaddr *name, INT *namelen) INT Winsock_getsockname(SOCKET s, struct sockaddr *name, INT *namelen) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_getsockname: socket: %d, ptr %8x, ptr %8x\n", s, (int) name, (int) *namelen); -#endif + dprintf_winsock(stddeb, "WSA_getsockname: socket: %d, ptr %8x, ptr %8x\n", s, (int) name, (int) *namelen); if (getsockname(s, name, (int *) namelen) < 0) { errno_to_wsaerrno(); return SOCKET_ERROR; @@ -263,9 +254,7 @@ INT Winsock_getsockname(SOCKET s, struct sockaddr *name, INT *namelen) INT Winsock_getsockopt(SOCKET s, INT level, INT optname, char *optval, INT *optlen) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_getsockopt: socket: %d, opt %d, ptr %8x, ptr %8x\n", s, level, (int) optval, (int) *optlen); -#endif + dprintf_winsock(stddeb, "WSA_getsockopt: socket: %d, opt %d, ptr %8x, ptr %8x\n", s, level, (int) optval, (int) *optlen); convert_sockopt(&level, &optname); if (getsockopt(s, (int) level, optname, optval, (int *) optlen) < 0) { @@ -294,9 +283,7 @@ char *Winsock_inet_ntoa(struct in_addr in) { char *s; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_inet_ntoa: %8x\n", in); -#endif + dprintf_winsock(stddeb, "WSA_inet_ntoa: %8x\n", in); if ((s = inet_ntoa(in)) == NULL) { errno_to_wsaerrno(); @@ -310,9 +297,7 @@ char *Winsock_inet_ntoa(struct in_addr in) INT Winsock_ioctlsocket(SOCKET s, long cmd, u_long *argp) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_ioctl: socket %d, cmd %d, ptr %8x\n", s, cmd, (int) argp); -#endif + dprintf_winsock(stddeb, "WSA_ioctl: socket %d, cmd %d, ptr %8x\n", s, cmd, (int) argp); if (ioctl(s, cmd, argp) < 0) { errno_to_wsaerrno(); @@ -323,9 +308,7 @@ INT Winsock_ioctlsocket(SOCKET s, long cmd, u_long *argp) INT Winsock_listen(SOCKET s, INT backlog) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_listen: socket %d, backlog %d\n", s, backlog); -#endif + dprintf_winsock(stddeb, "WSA_listen: socket %d, backlog %d\n", s, backlog); if (listen(s, backlog) < 0) { errno_to_wsaerrno(); @@ -348,9 +331,7 @@ INT Winsock_recv(SOCKET s, char *buf, INT len, INT flags) { int length; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_recv: socket %d, ptr %8x, length %d, flags %d\n", s, (int) buf, len, flags); -#endif + dprintf_winsock(stddeb, "WSA_recv: socket %d, ptr %8x, length %d, flags %d\n", s, (int) buf, len, flags); if ((length = recv(s, buf, len, flags)) < 0) { errno_to_wsaerrno(); @@ -364,9 +345,7 @@ INT Winsock_recvfrom(SOCKET s, char *buf, INT len, INT flags, { int length; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_recvfrom: socket %d, ptr %8x, length %d, flags %d\n", s, buf, len, flags); -#endif + dprintf_winsock(stddeb, "WSA_recvfrom: socket %d, ptr %8x, length %d, flags %d\n", s, buf, len, flags); if ((length = recvfrom(s, buf, len, flags, from, fromlen)) < 0) { errno_to_wsaerrno(); @@ -378,9 +357,7 @@ INT Winsock_recvfrom(SOCKET s, char *buf, INT len, INT flags, INT Winsock_select(INT nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_select: fd # %d, ptr %8x, ptr %8x, ptr %*X\n", nfds, readfds, writefds, exceptfds); -#endif + dprintf_winsock(stddeb, "WSA_select: fd # %d, ptr %8x, ptr %8x, ptr %*X\n", nfds, readfds, writefds, exceptfds); return(select(nfds, readfds, writefds, exceptfds, timeout)); } @@ -389,9 +366,7 @@ INT Winsock_send(SOCKET s, char *buf, INT len, INT flags) { int length; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_send: socket %d, ptr %8x, length %d, flags %d\n", s, buf, len, flags); -#endif + dprintf_winsock(stddeb, "WSA_send: socket %d, ptr %8x, length %d, flags %d\n", s, buf, len, flags); if ((length = send(s, buf, len, flags)) < 0) { errno_to_wsaerrno(); @@ -405,9 +380,7 @@ INT Winsock_sendto(SOCKET s, char *buf, INT len, INT flags, { int length; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_sendto: socket %d, ptr %8x, length %d, flags %d\n", s, buf, len, flags); -#endif + dprintf_winsock(stddeb, "WSA_sendto: socket %d, ptr %8x, length %d, flags %d\n", s, buf, len, flags); if ((length = sendto(s, buf, len, flags, to, tolen)) < 0) { errno_to_wsaerrno(); @@ -419,9 +392,7 @@ INT Winsock_sendto(SOCKET s, char *buf, INT len, INT flags, INT Winsock_setsockopt(SOCKET s, INT level, INT optname, const char *optval, INT optlen) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_setsockopt: socket %d, level %d, opt %d, ptr %8x, len %d\n", s, level, optname, (int) optval, optlen); -#endif + dprintf_winsock(stddeb, "WSA_setsockopt: socket %d, level %d, opt %d, ptr %8x, len %d\n", s, level, optname, (int) optval, optlen); convert_sockopt(&level, &optname); if (setsockopt(s, level, optname, optval, optlen) < 0) { @@ -433,9 +404,7 @@ INT Winsock_setsockopt(SOCKET s, INT level, INT optname, const char *optval, INT Winsock_shutdown(SOCKET s, INT how) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_shutdown: socket s %d, how %d\n", s, how); -#endif + dprintf_winsock(stddeb, "WSA_shutdown: socket s %d, how %d\n", s, how); if (shutdown(s, how) < 0) { errno_to_wsaerrno(); @@ -448,15 +417,11 @@ SOCKET Winsock_socket(INT af, INT type, INT protocol) { int sock; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_socket: af=%d type=%d protocol=%d\n", af, type, protocol); -#endif + dprintf_winsock(stddeb, "WSA_socket: af=%d type=%d protocol=%d\n", af, type, protocol); if ((sock = socket(af, type, protocol)) < 0) { errno_to_wsaerrno(); -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_socket: failed !\n"); -#endif + dprintf_winsock(stddeb, "WSA_socket: failed !\n"); return INVALID_SOCKET; } @@ -467,9 +432,7 @@ SOCKET Winsock_socket(INT af, INT type, INT protocol) FD_SET(sock, &fd_in_use); -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_socket: fd %d\n", sock); -#endif + dprintf_winsock(stddeb, "WSA_socket: fd %d\n", sock); return sock; } @@ -477,9 +440,7 @@ struct hostent *Winsock_gethostbyaddr(const char *addr, INT len, INT type) { struct hostent *host; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_gethostbyaddr: ptr %8x, len %d, type %d\n", (int) addr, len, type); -#endif + dprintf_winsock(stddeb, "WSA_gethostbyaddr: ptr %8x, len %d, type %d\n", (int) addr, len, type); if ((host = gethostbyaddr(addr, len, type)) == NULL) { errno_to_wsaerrno(); @@ -494,9 +455,7 @@ struct hostent *Winsock_gethostbyname(const char *name) { struct hostent *host; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_gethostbyname: name %s\n", name); -#endif + dprintf_winsock(stddeb, "WSA_gethostbyname: name %s\n", name); if ((host = gethostbyname(name)) == NULL) { errno_to_wsaerrno(); @@ -510,9 +469,7 @@ struct hostent *Winsock_gethostbyname(const char *name) int Winsock_gethostname(char *name, INT namelen) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_gethostname: name %d, len %d\n", name, namelen); -#endif + dprintf_winsock(stddeb, "WSA_gethostname: name %d, len %d\n", name, namelen); if (gethostname(name, namelen) < 0) { errno_to_wsaerrno(); @@ -525,9 +482,7 @@ struct protoent *Winsock_getprotobyname(char *name) { struct protoent *proto; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_getprotobyname: name %s\n", name); -#endif + dprintf_winsock(stddeb, "WSA_getprotobyname: name %s\n", name); if ((proto = getprotobyname(name)) == NULL) { errno_to_wsaerrno(); @@ -542,9 +497,7 @@ struct protoent *Winsock_getprotobynumber(INT number) { struct protoent *proto; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_getprotobynumber: num %d\n", number); -#endif + dprintf_winsock(stddeb, "WSA_getprotobynumber: num %d\n", number); if ((proto = getprotobynumber(number)) == NULL) { errno_to_wsaerrno(); @@ -559,9 +512,7 @@ struct servent *Winsock_getservbyname(const char *name, const char *proto) { struct servent *service; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_getservbyname: name %s, proto %s\n", name, proto); -#endif + dprintf_winsock(stddeb, "WSA_getservbyname: name %s, proto %s\n", name, proto); if ((service = getservbyname(name, proto)) == NULL) { errno_to_wsaerrno(); @@ -576,9 +527,7 @@ struct servent *Winsock_getservbyport(INT port, const char *proto) { struct servent *service; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_getservbyport: port %d, name %s\n", port, proto); -#endif + dprintf_winsock(stddeb, "WSA_getservbyport: port %d, name %s\n", port, proto); if ((service = getservbyport(port, proto)) == NULL) { errno_to_wsaerrno(); @@ -776,9 +725,7 @@ INT WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent) long event; fd_set read_fds, write_fds, except_fds; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_AsyncSelect: socket %d, HWND %d, wMsg %d, event %d\n", s, hWnd, wMsg, lEvent); -#endif + dprintf_winsock(stddeb, "WSA_AsyncSelect: socket %d, HWND %d, wMsg %d, event %d\n", s, hWnd, wMsg, lEvent); /* remove outstanding asyncselect() processes */ /* kill */ @@ -820,51 +767,39 @@ INT WSAFDIsSet(INT fd, fd_set *set) INT WSACancelAsyncRequest(HANDLE hAsyncTaskHandle) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_AsyncRequest: handle %d\n", hAsyncTaskHandle); -#endif + dprintf_winsock(stddeb, "WSA_AsyncRequest: handle %d\n", hAsyncTaskHandle); return 0; } INT WSACancelBlockingCall(void) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_CancelBlockCall\n"); -#endif + dprintf_winsock(stddeb, "WSA_CancelBlockCall\n"); return 0; } INT WSAGetLastError(void) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_GetLastError\n"); -#endif + dprintf_winsock(stddeb, "WSA_GetLastError\n"); return wsa_errno; } void WSASetLastError(INT iError) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_SetLastErorr %d\n", iError); -#endif + dprintf_winsock(stddeb, "WSA_SetLastErorr %d\n", iError); wsa_errno = iError; } BOOL WSAIsBlocking(void) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_IsBlocking\n"); -#endif + dprintf_winsock(stddeb, "WSA_IsBlocking\n"); } FARPROC WSASetBlockingHook(FARPROC lpBlockFunc) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_SetBlockHook %8x, STUB!\n", lpBlockFunc); -#endif + dprintf_winsock(stddeb, "WSA_SetBlockHook %8x, STUB!\n", lpBlockFunc); BlockFunction = lpBlockFunc; return lpBlockFunc; @@ -872,9 +807,7 @@ FARPROC WSASetBlockingHook(FARPROC lpBlockFunc) INT WSAUnhookBlockingHook(void) { -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSA_UnhookBlockingHook\n"); -#endif + dprintf_winsock(stddeb, "WSA_UnhookBlockingHook\n"); BlockFunction = NULL; return 0; @@ -903,9 +836,7 @@ INT WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData) int HeapHandle; MDESC *MyHeap; -#ifdef DEBUG_WINSOCK - fprintf(stderr, "WSAStartup: verReq=%x\n", wVersionRequested); -#endif + dprintf_winsock(stddeb, "WSAStartup: verReq=%x\n", wVersionRequested); if (LOBYTE(wVersionRequested) < 1 || (LOBYTE(wVersionRequested) == 1 && diff --git a/miscemu/int10.c b/miscemu/int10.c index 2260fff7f72..123ddbbc3f6 100644 --- a/miscemu/int10.c +++ b/miscemu/int10.c @@ -9,8 +9,8 @@ void IntBarf(int i, struct sigcontext_struct *context) { - fprintf(stderr, "int%x: unknown/not implemented parameters:\n", i); - fprintf(stderr, "int%x: AX %04x, BX %04x, CX %04x, DX %04x, " + fprintf(stdnimp, "int%x: unknown/not implemented parameters:\n", i); + fprintf(stdnimp, "int%x: AX %04x, BX %04x, CX %04x, DX %04x, " "SI %04x, DI %04x, DS %04x, ES %04x\n", i, AX, BX, CX, DX, SI, DI, DS, ES); } diff --git a/miscemu/int21.c b/miscemu/int21.c index 84cb953c5b8..fae0a1b83d1 100644 --- a/miscemu/int21.c +++ b/miscemu/int21.c @@ -97,8 +97,8 @@ void errno_to_doserr(void) /* static void Barf(struct sigcontext_struct *context) { - fprintf(stderr, "int21: unknown/not implemented parameters:\n"); - fprintf(stderr, "int21: AX %04x, BX %04x, CX %04x, DX %04x, " + fprintf(stdnimp, "int21: unknown/not implemented parameters:\n"); + fprintf(stdnimp, "int21: AX %04x, BX %04x, CX %04x, DX %04x, " "SI %04x, DI %04x, DS %04x, ES %04x\n", AX, BX, CX, DX, SI, DI, DS, ES); } @@ -235,7 +235,7 @@ static void ReadFile(struct sigcontext_struct *context) return; } - ptr = pointer (DS,DX); + ptr = SAFEMAKEPTR (DS,DX); if (BX == 0) { *ptr = EOF; Error (0,0,0); @@ -261,7 +261,7 @@ static void WriteFile(struct sigcontext_struct *context) char *ptr; int x,size; - ptr = pointer (DS,DX); + ptr = SAFEMAKEPTR (DS,DX); if (BX == 0) { Error (InvalidHandle, EC_Unknown, EL_Unknown); @@ -312,7 +312,7 @@ static void SeekFile(struct sigcontext_struct *context) case 0: fileoffset = SEEK_SET; break; } - status = lseek(BX, (CX * 0x100) + DX, fileoffset); + status = lseek(BX, (CX << 16) + DX, fileoffset); if (status == -1) { errno_to_doserr(); AL = ExtendedError; SetCflag; @@ -355,7 +355,7 @@ static void ioctlGetDeviceInfo(struct sigcontext_struct *context) static void ioctlGenericBlkDevReq(struct sigcontext_struct *context) { - BYTE *dataptr = pointer(DS, DX); + BYTE *dataptr = SAFEMAKEPTR(DS, DX); int drive; if (BL == 0) @@ -436,7 +436,7 @@ static void CreateFile(struct sigcontext_struct *context) { int handle; - if ((handle = open(GetUnixFileName( pointer(DS,DX)), + if ((handle = open(GetUnixFileName( SAFEMAKEPTR(DS,DX)), O_CREAT | O_TRUNC | O_RDWR )) == -1) { errno_to_doserr(); AL = ExtendedError; @@ -469,7 +469,7 @@ void OpenExistingFile(struct sigcontext_struct *context) break; } - if ((handle = open(GetUnixFileName(pointer(DS,DX)), mode)) == -1) { + if ((handle = open(GetUnixFileName(SAFEMAKEPTR(DS,DX)), mode)) == -1) { errno_to_doserr(); AL = ExtendedError; SetCflag; @@ -486,7 +486,7 @@ void OpenExistingFile(struct sigcontext_struct *context) case 0x30: /* DENYREAD */ dprintf_int(stdnimp, "OpenExistingFile (%s): DENYREAD changed to DENYALL\n", - pointer(DS,DX)); + SAFEMAKEPTR(DS,DX)); case 0x10: /* DENYALL */ lock = LOCK_EX; break; @@ -550,10 +550,10 @@ static void RenameFile(struct sigcontext_struct *context) char *newname, *oldname; dprintf_int(stddeb,"int21: renaming %s to %s\n", - pointer(DS,DX), pointer(ES,DI) ); + SAFEMAKEPTR(DS,DX), SAFEMAKEPTR(ES,DI) ); - oldname = GetUnixFileName( pointer(DS,DX) ); - newname = GetUnixFileName( pointer(ES,DI) ); + oldname = GetUnixFileName( SAFEMAKEPTR(DS,DX) ); + newname = GetUnixFileName( SAFEMAKEPTR(ES,DI) ); rename( oldname, newname); ResetCflag; @@ -564,9 +564,9 @@ static void MakeDir(struct sigcontext_struct *context) { char *dirname; - dprintf_int(stddeb,"int21: makedir %s\n", pointer(DS,DX) ); + dprintf_int(stddeb,"int21: makedir %s\n", SAFEMAKEPTR(DS,DX) ); - if ((dirname = GetUnixFileName( pointer(DS,DX) ))== NULL) { + if ((dirname = GetUnixFileName( SAFEMAKEPTR(DS,DX) ))== NULL) { AL = CanNotMakeDir; SetCflag; return; @@ -583,7 +583,7 @@ static void MakeDir(struct sigcontext_struct *context) static void ChangeDir(struct sigcontext_struct *context) { int drive; - char *dirname = pointer(DS,DX); + char *dirname = SAFEMAKEPTR(DS,DX); drive = DOS_GetDefaultDrive(); dprintf_int(stddeb,"int21: changedir %s\n", dirname); if (dirname != NULL && dirname[1] == ':') { @@ -601,9 +601,9 @@ static void RemoveDir(struct sigcontext_struct *context) { char *dirname; - dprintf_int(stddeb,"int21: removedir %s\n", pointer(DS,DX) ); + dprintf_int(stddeb,"int21: removedir %s\n", SAFEMAKEPTR(DS,DX) ); - if ((dirname = GetUnixFileName( pointer(DS,DX) ))== NULL) { + if ((dirname = GetUnixFileName( SAFEMAKEPTR(DS,DX) ))== NULL) { AL = CanNotMakeDir; SetCflag; return; @@ -624,7 +624,7 @@ static void RemoveDir(struct sigcontext_struct *context) static void ExecProgram(struct sigcontext_struct *context) { - execl("wine", GetUnixFileName( pointer(DS,DX)) ); + execl("wine", GetUnixFileName( SAFEMAKEPTR(DS,DX)) ); } static void FindNext(struct sigcontext_struct *context) @@ -656,7 +656,7 @@ static void FindNext(struct sigcontext_struct *context) static void FindFirst(struct sigcontext_struct *context) { - BYTE drive, *path = pointer(DS, DX); + BYTE drive, *path = SAFEMAKEPTR(DS, DX); struct dosdirent *dp; if ((*path)&&(path[1] == ':')) { @@ -704,7 +704,7 @@ static void GetFileDateTime(struct sigcontext_struct *context) struct stat filestat; struct tm *now; - if ((filename = GetUnixFileName( pointer(DS,DX) ))== NULL) { + if ((filename = GetUnixFileName( SAFEMAKEPTR(DS,DX) ))== NULL) { AL = FileNotFound; SetCflag; return; @@ -724,7 +724,7 @@ static void SetFileDateTime(struct sigcontext_struct *context) char *filename; struct utimbuf filetime; - filename = GetUnixFileName( pointer(DS,DX) ); + filename = GetUnixFileName( SAFEMAKEPTR(DS,DX) ); filetime.actime = 0L; filetime.modtime = filetime.actime; @@ -750,7 +750,7 @@ static void CreateTempFile(struct sigcontext_struct *context) return; } - strcpy(pointer(DS,DX), temp); + strcpy(SAFEMAKEPTR(DS,DX), temp); AX = handle; ResetCflag; @@ -760,7 +760,7 @@ static void CreateNewFile(struct sigcontext_struct *context) { int handle; - if ((handle = open(GetUnixFileName( pointer(DS,DX) ), O_CREAT | O_EXCL | O_RDWR)) == -1) { + if ((handle = open(GetUnixFileName( SAFEMAKEPTR(DS,DX) ), O_CREAT | O_EXCL | O_RDWR)) == -1) { AL = WriteProtected; SetCflag; return; @@ -785,14 +785,14 @@ static void GetCurrentDirectory(struct sigcontext_struct *context) return; } - strcpy(pointer(DS,SI), DOS_GetCurrentDir(drive) ); + strcpy(SAFEMAKEPTR(DS,SI), DOS_GetCurrentDir(drive) ); ResetCflag; } static void GetDiskSerialNumber(struct sigcontext_struct *context) { int drive; - BYTE *dataptr = pointer(DS, DX); + BYTE *dataptr = SAFEMAKEPTR(DS, DX); DWORD serialnumber; if (BL == 0) @@ -820,7 +820,7 @@ static void GetDiskSerialNumber(struct sigcontext_struct *context) static void SetDiskSerialNumber(struct sigcontext_struct *context) { int drive; - BYTE *dataptr = pointer(DS, DX); + BYTE *dataptr = SAFEMAKEPTR(DS, DX); DWORD serialnumber; if (BL == 0) @@ -860,7 +860,7 @@ static void DumpFCB(BYTE *fcb) static void FindFirstFCB(struct sigcontext_struct *context) { - BYTE *fcb = pointer(DS, DX); + BYTE *fcb = SAFEMAKEPTR(DS, DX); struct fcb *standard_fcb; struct fcb *output_fcb; int drive; @@ -927,7 +927,7 @@ static void FindFirstFCB(struct sigcontext_struct *context) static void DeleteFileFCB(struct sigcontext_struct *context) { - BYTE *fcb = pointer(DS, DX); + BYTE *fcb = SAFEMAKEPTR(DS, DX); int drive; struct dosdirent *dp; char temp[256], *ptr; @@ -969,7 +969,7 @@ static void DeleteFileFCB(struct sigcontext_struct *context) static void RenameFileFCB(struct sigcontext_struct *context) { - BYTE *fcb = pointer(DS, DX); + BYTE *fcb = SAFEMAKEPTR(DS, DX); int drive; struct dosdirent *dp; char temp[256], oldname[256], newname[256], *oldnameptr, *newnameptr; @@ -1069,7 +1069,7 @@ static void fLock (struct sigcontext_struct * context) static void GetFileAttribute (struct sigcontext_struct * context) { - char *filename = pointer (DS,DX); + char *filename = SAFEMAKEPTR (DS,DX); struct stat s; int res,cx; @@ -1201,7 +1201,7 @@ int do_int21(struct sigcontext_struct * context) break; case 0x1a: /* SET DISK TRANSFER AREA ADDRESS */ - dta = pointer(DS, DX); + dta = SAFEMAKEPTR(DS, DX); break; case 0x1b: /* GET ALLOCATION INFORMATION FOR DEFAULT DRIVE */ @@ -1336,7 +1336,7 @@ int do_int21(struct sigcontext_struct * context) break; case 0x41: /* "UNLINK" - DELETE FILE */ - if (unlink( GetUnixFileName( pointer(DS,DX)) ) == -1) { + if (unlink( GetUnixFileName( SAFEMAKEPTR(DS,DX)) ) == -1) { errno_to_doserr(); AL = ExtendedError; SetCflag; @@ -1526,7 +1526,7 @@ int do_int21(struct sigcontext_struct * context) break; case 0x60: /* "TRUENAME" - CANONICALIZE FILENAME OR PATH */ - strncpy(pointer(ES,DI), pointer(DS,SI), strlen(pointer(DS,SI)) & 0x7f); + strncpy(SAFEMAKEPTR(ES,DI), SAFEMAKEPTR(DS,SI), strlen(SAFEMAKEPTR(DS,SI)) & 0x7f); ResetCflag; break; diff --git a/miscemu/int25.c b/miscemu/int25.c index 7f957176ecd..67c2ec6e8b5 100644 --- a/miscemu/int25.c +++ b/miscemu/int25.c @@ -2,6 +2,7 @@ #include #include "registers.h" #include "msdos.h" +#include "segmem.h" #include "wine.h" #include "stddebug.h" /* #define DEBUG_INT */ @@ -10,7 +11,7 @@ int do_int25(struct sigcontext_struct *context) { - BYTE *dataptr = pointer(DS, BX); + BYTE *dataptr = SAFEMAKEPTR(DS, BX); DWORD begin, length; if (CX == 0xffff) { @@ -37,7 +38,7 @@ int do_int25(struct sigcontext_struct *context) /* push flags on stack */ SP -= sizeof(WORD); - setword(pointer(SS,SP), (WORD) EFL); + setword(SAFEMAKEPTR(SS,SP), (WORD) EFL); return 1; } diff --git a/miscemu/int26.c b/miscemu/int26.c index 6abe98820f2..2b262edc48c 100644 --- a/miscemu/int26.c +++ b/miscemu/int26.c @@ -2,6 +2,7 @@ #include #include "registers.h" #include "msdos.h" +#include "segmem.h" #include "wine.h" #include "stddebug.h" /* #define DEBUG_INT */ @@ -12,7 +13,7 @@ void IntBarf(int i, struct sigcontext_struct *context); int do_int26(struct sigcontext_struct *context) { - BYTE *dataptr = pointer(DS, BX); + BYTE *dataptr = SAFEMAKEPTR(DS, BX); DWORD begin, length; if (CX == 0xffff) { @@ -32,7 +33,7 @@ int do_int26(struct sigcontext_struct *context) /* push flags on stack */ SP -= sizeof(WORD); - setword(pointer(SS,SP), (WORD) EFL); + setword(SAFEMAKEPTR(SS,SP), (WORD) EFL); return 1; } diff --git a/objects/bitblt.c b/objects/bitblt.c index 47aa35c019a..0aa4e9a12d5 100644 --- a/objects/bitblt.c +++ b/objects/bitblt.c @@ -15,11 +15,12 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include "metafile.h" #include "options.h" #include "stddebug.h" -/* #define DEBUG_GDI /* */ -/* #undef DEBUG_GDI /* */ +/* #define DEBUG_GDI */ +/* #undef DEBUG_GDI */ #include "debug.h" extern const int DC_XROPfunction[]; +extern Colormap COLOR_WinColormap; #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) @@ -41,7 +42,7 @@ BOOL PatBlt( HDC hdc, short left, short top, return TRUE; } - dprintf_gdi(stddeb, "PatBlt: %d %d,%d %dx%d %06x\n", + dprintf_gdi(stddeb, "PatBlt: %d %d,%d %dx%d %06lx\n", hdc, left, top, width, height, rop ); /* Convert ROP3 code to ROP2 code */ @@ -92,7 +93,7 @@ BOOL BitBlt( HDC hdcDest, short xDest, short yDest, short width, short height, DWORD saverop = rop; DC *dcDest, *dcSrc; - dprintf_gdi(stddeb, "BitBlt: %04x %d,%d %dx%d %04x %d,%d %08x\n", + dprintf_gdi(stddeb, "BitBlt: %04x %d,%d %dx%d %04x %d,%d %06lx\n", hdcDest, xDest, yDest, width, height, hdcSrc, xSrc, ySrc, rop); if (width == 0 || height == 0) return FALSE; @@ -100,12 +101,7 @@ BOOL BitBlt( HDC hdcDest, short xDest, short yDest, short width, short height, return PatBlt( hdcDest, xDest, yDest, width, height, rop ); rop >>= 16; - if ((rop & 0x0f) != (rop >> 4)) - { - dprintf_gdi(stdnimp, "BitBlt: Unimplemented ROP %02x\n", rop ); - return FALSE; - } - + dcSrc = (DC *) GDI_GetObjPtr( hdcSrc, DC_MAGIC ); if (!dcSrc) return FALSE; dcDest = (DC *) GDI_GetObjPtr( hdcDest, DC_MAGIC ); @@ -131,22 +127,128 @@ BOOL BitBlt( HDC hdcDest, short xDest, short yDest, short width, short height, return FALSE; /* Should call StretchBlt here */ DC_SetupGCForText( dcDest ); - XSetFunction( display, dcDest->u.x.gc, DC_XROPfunction[rop & 0x0f] ); - if (dcSrc->w.bitsPerPixel == dcDest->w.bitsPerPixel) - { - XCopyArea( display, dcSrc->u.x.drawable, - dcDest->u.x.drawable, dcDest->u.x.gc, - min(xs1,xs2), min(ys1,ys2), abs(xs2-xs1), abs(ys2-ys1), - min(xd1,xd2), min(yd1,yd2) ); - } + if (((rop & 0x0f) == (rop >> 4))&&(rop!=0xbb)) + /* FIXME: Test, whether more than just 0xbb has to be excluded */ + { + XSetFunction( display, dcDest->u.x.gc, DC_XROPfunction[rop & 0x0f] ); + if (dcSrc->w.bitsPerPixel == dcDest->w.bitsPerPixel) + { + XCopyArea( display, dcSrc->u.x.drawable, + dcDest->u.x.drawable, dcDest->u.x.gc, + min(xs1,xs2), min(ys1,ys2), abs(xs2-xs1), abs(ys2-ys1), + min(xd1,xd2), min(yd1,yd2) ); + } + else + { + if (dcSrc->w.bitsPerPixel != 1) return FALSE; + XCopyPlane( display, dcSrc->u.x.drawable, + dcDest->u.x.drawable, dcDest->u.x.gc, + min(xs1,xs2), min(ys1,ys2), abs(xs2-xs1), abs(ys2-ys1), + min(xd1,xd2), min(yd1,yd2), 1 ); + } + } else - { - if (dcSrc->w.bitsPerPixel != 1) return FALSE; - XCopyPlane( display, dcSrc->u.x.drawable, - dcDest->u.x.drawable, dcDest->u.x.gc, - min(xs1,xs2), min(ys1,ys2), abs(xs2-xs1), abs(ys2-ys1), - min(xd1,xd2), min(yd1,yd2), 1 ); - } + { + XImage *sxi, *dxi, *bxi; + int x,y,s,d,p,res,ofs,i,cp,cs,cd,cres; + XColor sentry,dentry,pentry,entry; + long colors[256]; + + /* HDC hdcBrush = CreateCompatibleDC(hdcDest); + DC *dcBrush;*/ + RECT r = {min(xDest,xDest+width), min(yDest,yDest+height), + MAX(xDest,xDest+width), MAX(yDest,yDest+height)}; + HBRUSH cur_brush=SelectObject(hdcDest, GetStockObject(BLACK_BRUSH)); + SelectObject(hdcDest, cur_brush); + /* FillRect(hdcBrush, &r, cur_brush);*/ + sxi=XGetImage(display, dcSrc->u.x.drawable, min(xs1,xs2), min(ys1,ys2), + abs(xs2-xs1), abs(ys2-ys1), AllPlanes, ZPixmap); + dxi=XGetImage(display, dcDest->u.x.drawable, min(xd1,xd2),min(yd1,yd2), + abs(xs2-xs1), abs(ys2-ys1), AllPlanes, ZPixmap); + /* dcBrush = (DC *) GDI_GetObjPtr( hdcBrush, DC_MAGIC );*/ + /* bxi=XGetImage(display, dcBrush->u.x.drawable, min(xd1,xd2),min(yd1,yd2), + abs(xs2-xs1), abs(ys2-ys1), AllPlanes, ZPixmap);*/ + /* FIXME: It's really not necessary to do this on the visible screen */ + FillRect(hdcDest, &r, cur_brush); + bxi=XGetImage(display, dcDest->u.x.drawable, min(xd1,xd2),min(yd1,yd2), + abs(xs2-xs1), abs(ys2-ys1), AllPlanes, ZPixmap); + for (i=0; iw.bitsPerPixel)); i++) + { + entry.pixel = i; + XQueryColor ( display, COLOR_WinColormap, &entry); + colors[i] = (int) RGB( entry.red>>8, entry.green>>8, entry.blue>>8 ); + } + if (dcSrc->w.bitsPerPixel == dcDest->w.bitsPerPixel) + { + for(x=0; x>8,sentry.green>>8, sentry.blue>>8 ); + } + if (d<256) + cd=colors[d]; + else + { + dentry.pixel = d; + XQueryColor ( display, COLOR_WinColormap, &dentry); + cd = (int) RGB( dentry.red>>8, dentry.green>>8,dentry.blue>>8 ); + } + if (p<256) + cp=colors[p]; + else + { + pentry.pixel = p; + XQueryColor ( display, COLOR_WinColormap, &pentry); + cp = (int) RGB( pentry.red>>8, pentry.green>>8,pentry.blue>>8 ); + } + cres = 0; + for(i=0; i<24; i++) + { + ofs=1<<(((cp>>i)&1)*4+((cs>>i)&1)*2+((cd>>i)&1)); + if (rop & ofs) + cres |= (1<w.bitsPerPixel)); i++) + if (colors[i]==cres) + { + res = i; + break; + } + if (res == -1) + res = GetNearestPaletteIndex(dcDest->w.hPalette, res); + } + XPutPixel(dxi, x, y, res); + } + } + } + else + fprintf(stderr,"BitBlt // depths different!\n"); + XPutImage(display, dcDest->u.x.drawable, dcDest->u.x.gc, + dxi, 0, 0, min(xd1,xd2), min(yd1,yd2), abs(xs2-xs1), abs(ys2-ys1)+38); + XDestroyImage(sxi); + XDestroyImage(dxi); + XDestroyImage(bxi); + /*DeleteDC(hdcBrush);*/ + } return TRUE; } @@ -351,9 +453,8 @@ BOOL StretchBlt( HDC hdcDest, short xDest, short yDest, short widthDest, short h XImage *sxi, *dxi; DWORD saverop = rop; WORD stretchmode; - BOOL flg; - dprintf_gdi(stddeb, "StretchBlt: %d %d,%d %dx%d %d %d,%d %dx%d %08x\n", + dprintf_gdi(stddeb, "StretchBlt: %d %d,%d %dx%d %d %d,%d %dx%d %06lx\n", hdcDest, xDest, yDest, widthDest, heightDest, hdcSrc, xSrc, ySrc, widthSrc, heightSrc, rop ); dprintf_gdi(stddeb, "StretchMode is %x\n", @@ -376,7 +477,7 @@ BOOL StretchBlt( HDC hdcDest, short xDest, short yDest, short widthDest, short h rop >>= 16; if ((rop & 0x0f) != (rop >> 4)) { - dprintf_gdi(stdnimp, "StretchBlt: Unimplemented ROP %02x\n", rop ); + fprintf(stdnimp, "StretchBlt: Unimplemented ROP %02lx\n", rop ); return FALSE; } diff --git a/objects/bitmap.c b/objects/bitmap.c index 0785559eab9..2b540e6618b 100644 --- a/objects/bitmap.c +++ b/objects/bitmap.c @@ -27,7 +27,8 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; /* GCs used for B&W and color bitmap operations */ GC BITMAP_monoGC = 0, BITMAP_colorGC = 0; -extern void DC_InitDC( HDC hdc ); /* dc.c */ +extern void DC_InitDC( HDC hdc ); /* objects/dc.c */ +extern void CLIPPING_UpdateGCRegion( DC * dc ); /* objects/clipping.c */ /*********************************************************************** * BITMAP_Init @@ -296,12 +297,16 @@ int BMP_GetObject( BITMAPOBJ * bmp, int count, LPSTR buffer ) HBITMAP BITMAP_SelectObject( HDC hdc, DC * dc, HBITMAP hbitmap, BITMAPOBJ * bmp ) { + HRGN hrgn; HBITMAP prevHandle = dc->w.hBitmap; if (!(dc->w.flags & DC_MEMORY)) return 0; + hrgn = CreateRectRgn( 0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight ); + if (!hrgn) return 0; + + DeleteObject( dc->w.hVisRgn ); + dc->w.hVisRgn = hrgn; dc->u.x.drawable = bmp->pixmap; - dc->w.DCSizeX = bmp->bitmap.bmWidth; - dc->w.DCSizeY = bmp->bitmap.bmHeight; dc->w.hBitmap = hbitmap; /* Change GC depth if needed */ @@ -313,6 +318,7 @@ HBITMAP BITMAP_SelectObject( HDC hdc, DC * dc, HBITMAP hbitmap, dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel; DC_InitDC( hdc ); } + else CLIPPING_UpdateGCRegion( dc ); /* Just update GC clip region */ return prevHandle; } diff --git a/objects/brush.c b/objects/brush.c index 1a4ff726506..6555d6c2f51 100644 --- a/objects/brush.c +++ b/objects/brush.c @@ -232,6 +232,8 @@ HBRUSH BRUSH_SelectObject( HDC hdc, DC * dc, HBRUSH hbrush, BRUSHOBJ * brush ) BITMAPINFO * bmpInfo; HBRUSH prevHandle = dc->w.hBrush; + dprintf_gdi(stddeb, "Brush_SelectObject hdc=%04x hbrush=%04x\n", + hdc,hbrush); if (dc->header.wMagic == METAFILE_DC_MAGIC) { switch (brush->logbrush.lbStyle) @@ -264,13 +266,16 @@ HBRUSH BRUSH_SelectObject( HDC hdc, DC * dc, HBRUSH hbrush, BRUSHOBJ * brush ) switch(brush->logbrush.lbStyle) { case BS_NULL: + dprintf_gdi( stddeb,"BS_NULL\n" ); break; case BS_SOLID: + dprintf_gdi( stddeb,"BS_SOLID\n" ); BRUSH_SelectSolidBrush( dc, brush->logbrush.lbColor ); break; case BS_HATCHED: + dprintf_gdi( stddeb, "BS_HATCHED\n" ); dc->u.x.brush.pixel = COLOR_ToPhysical( dc, brush->logbrush.lbColor ); dc->u.x.brush.pixmap = XCreateBitmapFromData( display, rootWindow, HatchBrushes[brush->logbrush.lbHatch], 8, 8 ); @@ -278,10 +283,12 @@ HBRUSH BRUSH_SelectObject( HDC hdc, DC * dc, HBRUSH hbrush, BRUSHOBJ * brush ) break; case BS_PATTERN: + dprintf_gdi( stddeb, "BS_PATTERN\n"); BRUSH_SelectPatternBrush( dc, brush->logbrush.lbHatch ); break; case BS_DIBPATTERN: + dprintf_gdi( stddeb, "BS_DIBPATTERN\n"); if ((bmpInfo = (BITMAPINFO *) GlobalLock( brush->logbrush.lbHatch ))) { int size = DIB_BitmapInfoSize( bmpInfo, brush->logbrush.lbColor ); diff --git a/objects/clipping.c b/objects/clipping.c index 26019dc3129..d6d8bbac5ab 100644 --- a/objects/clipping.c +++ b/objects/clipping.c @@ -10,8 +10,8 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include "gdi.h" #include "metafile.h" #include "stddebug.h" -/* #define DEBUG_CLIPPING /* */ -/* #undef DEBUG_CLIPPING /* */ +/* #define DEBUG_CLIPPING */ +/* #undef DEBUG_CLIPPING */ #include "debug.h" /*********************************************************************** @@ -19,32 +19,29 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; * * Set the clip region of the physical device. */ -void CLIPPING_SetDeviceClipping( DC * dc ) +static void CLIPPING_SetDeviceClipping( DC * dc ) { - if (dc->w.hGCClipRgn) + RGNOBJ *obj = (RGNOBJ *) GDI_GetObjPtr(dc->w.hGCClipRgn, REGION_MAGIC); + if (!obj) { - RGNOBJ *obj = (RGNOBJ *) GDI_GetObjPtr(dc->w.hGCClipRgn, REGION_MAGIC); - if (obj->region.xrgn) - { - XSetRegion( display, dc->u.x.gc, obj->region.xrgn ); - XSetClipOrigin( display, dc->u.x.gc, dc->w.DCOrgX, dc->w.DCOrgY ); - } - else if (obj->region.pixmap) - { - XSetClipMask( display, dc->u.x.gc, obj->region.pixmap ); - XSetClipOrigin( display, dc->u.x.gc, - dc->w.DCOrgX + obj->region.box.left, - dc->w.DCOrgY + obj->region.box.top ); - } - else /* Clip everything */ - { - XSetClipRectangles( display, dc->u.x.gc, 0, 0, NULL, 0, 0 ); - } + fprintf( stderr, "SetDeviceClipping: Rgn is 0. Please report this.\n"); + exit(1); } - else + if (obj->region.xrgn) { - XSetClipMask( display, dc->u.x.gc, None ); - XSetClipOrigin( display, dc->u.x.gc, dc->w.DCOrgX, dc->w.DCOrgY ); + XSetRegion( display, dc->u.x.gc, obj->region.xrgn ); + XSetClipOrigin( display, dc->u.x.gc, dc->w.DCOrgX, dc->w.DCOrgY ); + } + else if (obj->region.pixmap) + { + XSetClipMask( display, dc->u.x.gc, obj->region.pixmap ); + XSetClipOrigin( display, dc->u.x.gc, + dc->w.DCOrgX + obj->region.box.left, + dc->w.DCOrgY + obj->region.box.top ); + } + else /* Clip everything */ + { + XSetClipRectangles( display, dc->u.x.gc, 0, 0, NULL, 0, 0 ); } } @@ -54,66 +51,47 @@ void CLIPPING_SetDeviceClipping( DC * dc ) * * Update the GC clip region when the ClipRgn or VisRgn have changed. */ -static void CLIPPING_UpdateGCRegion( DC * dc ) +void CLIPPING_UpdateGCRegion( DC * dc ) { - if (!dc->w.hGCClipRgn) dc->w.hGCClipRgn = CreateRectRgn(0,0,0,0); + if (!dc->w.hGCClipRgn) dc->w.hGCClipRgn = CreateRectRgn( 0, 0, 0, 0 ); if (!dc->w.hVisRgn) { - if (!dc->w.hClipRgn) - { - DeleteObject( dc->w.hGCClipRgn ); - dc->w.hGCClipRgn = 0; - } - else - CombineRgn( dc->w.hGCClipRgn, dc->w.hClipRgn, 0, RGN_COPY ); + fprintf( stderr, "UpdateGCRegion: hVisRgn is zero. Please report this.\n" ); + exit(1); } + if (!dc->w.hClipRgn) + CombineRgn( dc->w.hGCClipRgn, dc->w.hVisRgn, 0, RGN_COPY ); else - { - if (!dc->w.hClipRgn) - CombineRgn( dc->w.hGCClipRgn, dc->w.hVisRgn, 0, RGN_COPY ); - else - CombineRgn( dc->w.hGCClipRgn, dc->w.hClipRgn, dc->w.hVisRgn, RGN_AND ); - } + CombineRgn( dc->w.hGCClipRgn, dc->w.hClipRgn, dc->w.hVisRgn, RGN_AND ); CLIPPING_SetDeviceClipping( dc ); } -/*********************************************************************** - * CLIPPING_SelectRgn - * - * Helper function for SelectClipRgn() and SelectVisRgn(). - */ -static int CLIPPING_SelectRgn( DC * dc, HRGN * hrgnPrev, HRGN hrgn ) -{ - int retval; - - if (hrgn) - { - if (!*hrgnPrev) *hrgnPrev = CreateRectRgn(0,0,0,0); - retval = CombineRgn( *hrgnPrev, hrgn, 0, RGN_COPY ); - } - else - { - if (*hrgnPrev) DeleteObject( *hrgnPrev ); - *hrgnPrev = 0; - retval = SIMPLEREGION; /* Clip region == client area */ - } - CLIPPING_UpdateGCRegion( dc ); - return retval; -} - - /*********************************************************************** * SelectClipRgn (GDI.44) */ int SelectClipRgn( HDC hdc, HRGN hrgn ) { + int retval; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - + dprintf_clipping(stddeb, "SelectClipRgn: %d %d\n", hdc, hrgn ); - return CLIPPING_SelectRgn( dc, &dc->w.hClipRgn, hrgn ); + + if (hrgn) + { + if (!dc->w.hClipRgn) dc->w.hClipRgn = CreateRectRgn(0,0,0,0); + retval = CombineRgn( dc->w.hClipRgn, hrgn, 0, RGN_COPY ); + } + else + { + if (dc->w.hClipRgn) DeleteObject( dc->w.hClipRgn ); + dc->w.hClipRgn = 0; + retval = SIMPLEREGION; /* Clip region == whole DC */ + } + CLIPPING_UpdateGCRegion( dc ); + return retval; } @@ -122,11 +100,15 @@ int SelectClipRgn( HDC hdc, HRGN hrgn ) */ int SelectVisRgn( HDC hdc, HRGN hrgn ) { + int retval; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return ERROR; - + if (!dc || !hrgn) return ERROR; + dprintf_clipping(stddeb, "SelectVisRgn: %d %d\n", hdc, hrgn ); - return CLIPPING_SelectRgn( dc, &dc->w.hVisRgn, hrgn ); + + retval = CombineRgn( dc->w.hVisRgn, hrgn, 0, RGN_COPY ); + CLIPPING_UpdateGCRegion( dc ); + return retval; } @@ -161,62 +143,45 @@ int OffsetClipRgn( HDC hdc, short x, short y ) */ int OffsetVisRgn( HDC hdc, short x, short y ) { + int retval; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; dprintf_clipping(stddeb, "OffsetVisRgn: %d %d,%d\n", hdc, x, y ); - - if (dc->w.hVisRgn) - { - int retval = OffsetRgn( dc->w.hVisRgn, x, y ); - CLIPPING_UpdateGCRegion( dc ); - return retval; - } - else return SIMPLEREGION; /* Clip region == client area */ + retval = OffsetRgn( dc->w.hVisRgn, x, y ); + CLIPPING_UpdateGCRegion( dc ); + return retval; } /*********************************************************************** - * CLIPPING_IntersectRect + * CLIPPING_IntersectClipRect * - * Helper function for {Intersect,Exclude}{Clip,Vis}Rect + * Helper function for {Intersect,Exclude}ClipRect */ -int CLIPPING_IntersectRect( DC * dc, HRGN * hrgn, short left, short top, - short right, short bottom, int exclude ) +static int CLIPPING_IntersectClipRect( DC * dc, short left, short top, + short right, short bottom, BOOL exclude) { - HRGN tempRgn = 0, prevRgn = 0, newRgn = 0; - RGNOBJ *newObj, *prevObj; - int retval; + HRGN tempRgn, newRgn; + int ret; - if (!*hrgn) + if (!(newRgn = CreateRectRgn( 0, 0, 0, 0 ))) return ERROR; + if (!(tempRgn = CreateRectRgn( left, top, right, bottom ))) { - if (!(*hrgn = CreateRectRgn( 0, 0, dc->w.DCSizeX, dc->w.DCSizeY ))) - goto Error; - prevRgn = *hrgn; + DeleteObject( newRgn ); + return ERROR; } - if (!(newRgn = CreateRectRgn( 0, 0, 0, 0))) goto Error; - if (!(tempRgn = CreateRectRgn( left, top, right, bottom ))) goto Error; - - retval = CombineRgn( newRgn, *hrgn, tempRgn, exclude ? RGN_DIFF : RGN_AND); - if (retval == ERROR) goto Error; - - newObj = (RGNOBJ *) GDI_GetObjPtr( newRgn, REGION_MAGIC ); - prevObj = (RGNOBJ *) GDI_GetObjPtr( *hrgn, REGION_MAGIC ); - if (newObj && prevObj) newObj->header.hNext = prevObj->header.hNext; + ret = CombineRgn( newRgn, dc->w.hClipRgn ? dc->w.hClipRgn : dc->w.hVisRgn, + tempRgn, exclude ? RGN_DIFF : RGN_AND); DeleteObject( tempRgn ); - if (*hrgn) DeleteObject( *hrgn ); - *hrgn = newRgn; - CLIPPING_UpdateGCRegion( dc ); - return retval; - Error: - if (tempRgn) DeleteObject( tempRgn ); - if (newRgn) DeleteObject( newRgn ); - if (prevRgn) + if (ret != ERROR) { - DeleteObject( prevRgn ); - *hrgn = 0; + if (dc->w.hClipRgn) DeleteObject( dc->w.hClipRgn ); + dc->w.hClipRgn = newRgn; + CLIPPING_UpdateGCRegion( dc ); } - return ERROR; + else DeleteObject( newRgn ); + return ret; } @@ -237,8 +202,7 @@ int ExcludeClipRect( HDC hdc, short left, short top, dprintf_clipping(stddeb, "ExcludeClipRect: %d %dx%d,%dx%d\n", hdc, left, top, right, bottom ); - return CLIPPING_IntersectRect( dc, &dc->w.hClipRgn, left, top, - right, bottom, 1 ); + return CLIPPING_IntersectClipRect( dc, left, top, right, bottom, TRUE ); } @@ -259,23 +223,55 @@ int IntersectClipRect( HDC hdc, short left, short top, dprintf_clipping(stddeb, "IntersectClipRect: %d %dx%d,%dx%d\n", hdc, left, top, right, bottom ); - return CLIPPING_IntersectRect( dc, &dc->w.hClipRgn, left, top, - right, bottom, 0 ); + return CLIPPING_IntersectClipRect( dc, left, top, right, bottom, FALSE ); +} + + +/*********************************************************************** + * CLIPPING_IntersectVisRect + * + * Helper function for {Intersect,Exclude}VisRect + */ +static int CLIPPING_IntersectVisRect( DC * dc, short left, short top, + short right, short bottom, BOOL exclude ) +{ + HRGN tempRgn, newRgn; + int ret; + + if (!(newRgn = CreateRectRgn( 0, 0, 0, 0 ))) return ERROR; + if (!(tempRgn = CreateRectRgn( left, top, right, bottom ))) + { + DeleteObject( newRgn ); + return ERROR; + } + ret = CombineRgn( newRgn, dc->w.hVisRgn, tempRgn, + exclude ? RGN_DIFF : RGN_AND); + DeleteObject( tempRgn ); + + if (ret != ERROR) + { + RGNOBJ *newObj = (RGNOBJ*)GDI_GetObjPtr( newRgn, REGION_MAGIC); + RGNOBJ *prevObj = (RGNOBJ*)GDI_GetObjPtr( dc->w.hVisRgn, REGION_MAGIC); + if (newObj && prevObj) newObj->header.hNext = prevObj->header.hNext; + DeleteObject( dc->w.hVisRgn ); + dc->w.hVisRgn = newRgn; + CLIPPING_UpdateGCRegion( dc ); + } + else DeleteObject( newRgn ); + return ret; } /*********************************************************************** * ExcludeVisRect (GDI.73) */ -int ExcludeVisRect( HDC hdc, short left, short top, - short right, short bottom ) +int ExcludeVisRect( HDC hdc, short left, short top, short right, short bottom ) { DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; dprintf_clipping(stddeb, "ExcludeVisRect: %d %dx%d,%dx%d\n", hdc, left, top, right, bottom ); - return CLIPPING_IntersectRect( dc, &dc->w.hVisRgn, left, top, - right, bottom, 1 ); + return CLIPPING_IntersectVisRect( dc, left, top, right, bottom, TRUE ); } @@ -283,14 +279,13 @@ int ExcludeVisRect( HDC hdc, short left, short top, * IntersectVisRect (GDI.98) */ int IntersectVisRect( HDC hdc, short left, short top, - short right, short bottom ) + short right, short bottom ) { DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; dprintf_clipping(stddeb, "IntersectVisRect: %d %dx%d,%dx%d\n", hdc, left, top, right, bottom ); - return CLIPPING_IntersectRect( dc, &dc->w.hVisRgn, left, top, - right, bottom, 0 ); + return CLIPPING_IntersectVisRect( dc, left, top, right, bottom, FALSE ); } @@ -334,15 +329,7 @@ int GetClipBox( HDC hdc, LPRECT rect ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; dprintf_clipping(stddeb, "GetClipBox: %d %p\n", hdc, rect ); - - if (dc->w.hGCClipRgn) return GetRgnBox( dc->w.hGCClipRgn, rect ); - else - { - rect->top = rect->left = 0; - rect->right = dc->w.DCSizeX; - rect->bottom = dc->w.DCSizeY; - return SIMPLEREGION; - } + return GetRgnBox( dc->w.hGCClipRgn, rect ); } @@ -356,7 +343,11 @@ HRGN SaveVisRgn( HDC hdc ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return 0; dprintf_clipping(stddeb, "SaveVisRgn: %d\n", hdc ); - if (!dc->w.hVisRgn) return 0; + if (!dc->w.hVisRgn) + { + fprintf( stderr, "SaveVisRgn: hVisRgn is zero. Please report this.\n" ); + exit(1); + } if (!(obj = (RGNOBJ *) GDI_GetObjPtr( dc->w.hVisRgn, REGION_MAGIC ))) return 0; if (!(copy = CreateRectRgn( 0, 0, 0, 0 ))) return 0; @@ -377,9 +368,8 @@ int RestoreVisRgn( HDC hdc ) HRGN saved; RGNOBJ *obj, *savedObj; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return ERROR; + if (!dc || !dc->w.hVisRgn) return ERROR; dprintf_clipping(stddeb, "RestoreVisRgn: %d\n", hdc ); - if (!dc->w.hVisRgn) return ERROR; if (!(obj = (RGNOBJ *) GDI_GetObjPtr( dc->w.hVisRgn, REGION_MAGIC ))) return ERROR; if (!(saved = obj->header.hNext)) return ERROR; diff --git a/objects/dc.c b/objects/dc.c index 5365efb62db..a38906c494d 100644 --- a/objects/dc.c +++ b/objects/dc.c @@ -21,7 +21,7 @@ static DeviceCaps * displayDevCaps = NULL; extern const WIN_DC_INFO DCVAL_defaultValues; -extern void CLIPPING_SetDeviceClipping( DC * dc ); /* objects/clipping.c */ +extern void CLIPPING_UpdateGCRegion( DC * dc ); /* objects/clipping.c */ extern WORD COLOR_ToPhysical( DC *dc, COLORREF color );/* objects/color.c */ extern void COLOR_SetMapping( DC *dc, HANDLE, WORD ); /* objects/color.c */ @@ -110,7 +110,7 @@ void DC_InitDC( HDC hdc ) SelectObject( hdc, dc->w.hFont ); XSetGraphicsExposures( display, dc->u.x.gc, False ); XSetSubwindowMode( display, dc->u.x.gc, IncludeInferiors ); - CLIPPING_SetDeviceClipping( dc ); + CLIPPING_UpdateGCRegion( dc ); } @@ -242,17 +242,14 @@ HDC GetDCState( HDC hdc ) newdc->saveLevel = 0; newdc->w.flags |= DC_SAVED; + newdc->w.hGCClipRgn = 0; + newdc->w.hVisRgn = CreateRectRgn( 0, 0, 0, 0 ); + CombineRgn( newdc->w.hVisRgn, dc->w.hVisRgn, 0, RGN_COPY ); if (dc->w.hClipRgn) { newdc->w.hClipRgn = CreateRectRgn( 0, 0, 0, 0 ); CombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY ); } - if (dc->w.hVisRgn) - { - newdc->w.hVisRgn = CreateRectRgn( 0, 0, 0, 0 ); - CombineRgn( newdc->w.hVisRgn, dc->w.hVisRgn, 0, RGN_COPY ); - } - newdc->w.hGCClipRgn = 0; COLOR_SetMapping( newdc, dc->u.x.pal.hMapping, dc->u.x.pal.mappingSize ); return handle; } @@ -264,26 +261,31 @@ HDC GetDCState( HDC hdc ) void SetDCState( HDC hdc, HDC hdcs ) { DC * dc, * dcs; - + HRGN hVisRgn, hClipRgn, hGCClipRgn; + if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return; if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC ))) return; if (!dcs->w.flags & DC_SAVED) return; dprintf_dc(stddeb, "SetDCState: %d %d\n", hdc, hdcs ); - if (dc->w.hClipRgn) DeleteObject( dc->w.hClipRgn ); - if (dc->w.hVisRgn) DeleteObject( dc->w.hVisRgn ); - if (dc->w.hGCClipRgn) DeleteObject( dc->w.hGCClipRgn ); + /* Save the regions before overwriting everything */ + hVisRgn = dc->w.hVisRgn; + hClipRgn = dc->w.hClipRgn; + hGCClipRgn = dc->w.hGCClipRgn; memcpy( &dc->w, &dcs->w, sizeof(dc->w) ); memcpy( &dc->u.x.pen, &dcs->u.x.pen, sizeof(dc->u.x.pen) ); - dc->w.hClipRgn = dc->w.hVisRgn = dc->w.hGCClipRgn = 0; dc->w.flags &= ~DC_SAVED; + /* Restore the regions */ + dc->w.hVisRgn = hVisRgn; + dc->w.hClipRgn = hClipRgn; + dc->w.hGCClipRgn = hGCClipRgn; + CombineRgn( dc->w.hVisRgn, dcs->w.hVisRgn, 0, RGN_COPY ); + SelectClipRgn( hdc, dcs->w.hClipRgn ); + SelectObject( hdc, dcs->w.hBrush ); SelectObject( hdc, dcs->w.hFont ); COLOR_SetMapping( dc, dcs->u.x.pal.hMapping, dcs->u.x.pal.mappingSize ); - - SelectClipRgn( hdc, dcs->w.hClipRgn ); - SelectVisRgn( hdc, dcs->w.hVisRgn ); } @@ -374,8 +376,13 @@ HDC CreateDC( LPSTR driver, LPSTR device, LPSTR output, LPSTR initData ) dc->w.flags = 0; dc->w.devCaps = displayDevCaps; dc->w.bitsPerPixel = displayDevCaps->bitsPixel; - dc->w.DCSizeX = displayDevCaps->horzRes; - dc->w.DCSizeY = displayDevCaps->vertRes; + dc->w.hVisRgn = CreateRectRgn( 0, 0, displayDevCaps->horzRes, + displayDevCaps->vertRes ); + if (!dc->w.hVisRgn) + { + GDI_HEAP_FREE( handle ); + return 0; + } DC_InitDC( handle ); @@ -426,9 +433,15 @@ HDC CreateCompatibleDC( HDC hdc ) dc->w.flags = DC_MEMORY; dc->w.bitsPerPixel = 1; dc->w.devCaps = displayDevCaps; - dc->w.DCSizeX = 1; - dc->w.DCSizeY = 1; dc->w.hBitmap = hbitmap; + dc->w.hVisRgn = CreateRectRgn( 0, 0, 1, 1 ); + + if (!dc->w.hVisRgn) + { + DeleteObject( hbitmap ); + GDI_HEAP_FREE( handle ); + return 0; + } DC_InitDC( handle ); diff --git a/objects/dcvalues.c b/objects/dcvalues.c index c1fafaf6644..2def05b2fd5 100644 --- a/objects/dcvalues.c +++ b/objects/dcvalues.c @@ -45,8 +45,6 @@ const WIN_DC_INFO DCVAL_defaultValues = MM_TEXT, /* MapMode */ 0, /* DCOrgX */ 0, /* DCOrgY */ - 0, /* DCSizeX */ - 0, /* DCSizeY */ 0, /* CursPosX */ 0, /* CursPosY */ 0, /* WndOrgX */ diff --git a/objects/font.c b/objects/font.c index 1a28d6c64bd..111984d3246 100644 --- a/objects/font.c +++ b/objects/font.c @@ -48,6 +48,47 @@ static LPLOGFONT lpLogFontList[MAX_FONTS] = { NULL }; #define CI_GET_DEFAULT_INFO(fs,cs) \ CI_GET_CHAR_INFO(fs, fs->default_char, NULL, cs) +struct FontStructure { + char *window; + char *x11; +} FontNames[32]; +int FontSize; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Font_Init + */ + +void Font_Init( void ) +{ + char temp[1024]; + LPSTR ptr; + int i; + + if( GetPrivateProfileString("fonts", NULL, "*", temp, sizeof(temp), WINE_INI) > 2 ) { + for( ptr = temp, i = 1; strlen(ptr) != 0; ptr += strlen(ptr) + 1, i++ ) + if( strcmp( ptr, "default" ) ) + FontNames[i].window = strdup( ptr ); + FontSize = i; + + for( i = 1; i < FontSize; i++ ) { + GetPrivateProfileString("fonts", FontNames[i].window, "*", temp, sizeof(temp), WINE_INI); + FontNames[i].x11 = strdup( temp ); + } + GetPrivateProfileString("fonts", "default", "*", temp, sizeof(temp), WINE_INI); + if( *temp == '*' ) + FontNames[0].x11 = strdup( temp ); + + } else { + FontNames[0].window = NULL; FontNames[0].x11 = "bitstream-courier"; + FontNames[1].window = "ms sans serif"; FontNames[1].x11 = "*-helvetica"; + FontNames[2].window = "ms serif"; FontNames[2].x11 = "*-times"; + FontNames[3].window = "fixedsys"; FontNames[3].x11 = "*-fixed"; + FontNames[4].window = "arial"; FontNames[4].x11 = "*-helvetica"; + FontNames[5].window = "helv"; FontNames[5].x11 = "*-helvetica"; + FontNames[6].window = "roman"; FontNames[6].x11 = "*-times"; + FontSize = 7; + } +} /*********************************************************************** * FONT_TranslateName @@ -57,26 +98,14 @@ static LPLOGFONT lpLogFontList[MAX_FONTS] = { NULL }; */ static const char *FONT_TranslateName( char *winFaceName ) { - int i; - static const char *mappings[] = - { - /*Windows name*/ /*X11 name*/ - "system", "helvetica", - "ms sans serif", "helvetica", - "ms serif", "times", - "fixedsys", "fixed", - "arial", "helvetica", - "helv", "helvetica", - "roman", "times" - }; + int i; - for (i = 0; i < sizeof(mappings)/sizeof(mappings[0]); i += 2) - if (!strcmp( winFaceName, mappings[i] )) - { - dprintf_font(stddeb, "---- Mapped %s to %s\n", winFaceName, mappings[i+1] ); - return mappings[i+1]; - } - return winFaceName; + for (i = 1; i < FontSize; i ++) + if( !strcmp( winFaceName, FontNames[i].window ) ) { + dprintf_font(stddeb, "---- Mapped %s to %s\n", winFaceName, FontNames[i].x11 ); + return FontNames[i].x11; + } + return FontNames[0].x11; } @@ -100,25 +129,37 @@ static XFontStruct * FONT_MatchFont( LOGFONT * font ) width = font->lfWidth * 10; spacing = (font->lfPitchAndFamily & FIXED_PITCH) ? 'm' : (font->lfPitchAndFamily & VARIABLE_PITCH) ? 'p' : '*'; - charset = (font->lfCharSet == ANSI_CHARSET) ? "iso8859-1" : "*"; + charset = (font->lfCharSet == ANSI_CHARSET) ? "iso8859-1" : "*-*"; if (*font->lfFaceName) family = FONT_TranslateName( font->lfFaceName ); else switch(font->lfPitchAndFamily & 0xf0) { - case FF_ROMAN: family = "times"; break; - case FF_SWISS: family = "helvetica"; break; - case FF_MODERN: family = "courier"; break; - case FF_SCRIPT: family = "*"; break; - case FF_DECORATIVE: family = "*"; break; - default: family = "*"; break; + case FF_ROMAN: + family = FONT_TranslateName( "roman" ); + break; + case FF_SWISS: + family = FONT_TranslateName( "swiss" ); + break; + case FF_MODERN: + family = FONT_TranslateName( "modern" ); + break; + case FF_SCRIPT: + family = FONT_TranslateName( "script" ); + break; + case FF_DECORATIVE: + family = FONT_TranslateName( "decorative" ); + break; + default: + family = FontNames[0].x11; + break; } while (TRUE) { /* Width==0 seems not to be a valid wildcard on SGI's, using * instead */ if ( width == 0 ) - sprintf( pattern, "-*-%s-%s-%c-normal-*-*-%d-*-*-%c-*-%s", + sprintf( pattern, "-%s-%s-%c-normal-*-*-%d-*-*-%c-*-%s", family, weight, slant, height, spacing, charset); else - sprintf( pattern, "-*-%s-%s-%c-normal-*-*-%d-*-*-%c-%d-%s", + sprintf( pattern, "-%s-%s-%c-normal-*-*-%d-*-*-%c-%d-%s", family, weight, slant, height, spacing, width, charset); dprintf_font(stddeb, "FONT_MatchFont: '%s'\n", pattern ); names = XListFonts( display, pattern, 1, &count ); @@ -525,9 +566,9 @@ void InitFontsList() slant = 'r'; spacing = '*'; charset = "*"; - family = "*"; + family = "*-*"; dprintf_font(stddeb,"InitFontsList !\n"); - sprintf( pattern, "-*-%s-%s-%c-normal-*-*-*-*-*-%c-*-%s", + sprintf( pattern, "-%s-%s-%c-normal-*-*-*-*-*-%c-*-%s", family, weight, slant, spacing, charset); names = XListFonts( display, pattern, MAX_FONTS, &count ); dprintf_font(stddeb,"InitFontsList // count=%d \n", count); diff --git a/objects/metafile.c b/objects/metafile.c index 83cf4c4f1d0..8715bf72e06 100644 --- a/objects/metafile.c +++ b/objects/metafile.c @@ -897,7 +897,7 @@ BOOL MF_MetaPoly(DC *dc, short func, LPPOINT pt, short count) BOOL MF_BitBlt(DC *dcDest, short xDest, short yDest, short width, short height, HDC hdcSrc, short xSrc, short ySrc, DWORD rop) { - dprintf_metafile(stdnimp,"MF_BitBlt: not implemented yet\n"); + fprintf(stdnimp,"MF_BitBlt: not implemented yet\n"); } @@ -908,5 +908,5 @@ BOOL MF_StretchBlt(DC *dcDest, short xDest, short yDest, short widthDest, short heightDest, HDC hdcSrc, short xSrc, short ySrc, short widthSrc, short heightSrc, DWORD rop) { - dprintf_metafile(stdnimp,"MF_StretchBlt: not implemented yet\n"); + fprintf(stdnimp,"MF_StretchBlt: not implemented yet\n"); } diff --git a/objects/text.c b/objects/text.c index 95b2eb7814e..e45973edc7a 100644 --- a/objects/text.c +++ b/objects/text.c @@ -62,9 +62,9 @@ static char *TEXT_NextLine(HDC hdc, char *str, int *count, char *dest, case LF: if (!(format & DT_SINGLELINE)) { - i++; - if (str[i] == CR || str[i] == LF) + if (str[i] == CR && str[i+1] == LF) i++; + i++; *len = j; return (&str[i]); } @@ -188,6 +188,7 @@ int DrawText( HDC hdc, LPSTR str, int count, LPRECT rect, WORD flags ) TEXTMETRIC tm; int x = rect->left, y = rect->top; int width = rect->right - rect->left; + int max_width = 0; dprintf_text(stddeb,"DrawText: '%s', %d , [(%d,%d),(%d,%d)]\n", str, count, rect->left, rect->top, rect->right, rect->bottom); @@ -237,8 +238,12 @@ int DrawText( HDC hdc, LPSTR str, int count, LPRECT rect, WORD flags ) else if (flags & DT_BOTTOM) y = rect->bottom - size.cy; } if (!(flags & DT_CALCRECT)) + { if (!ExtTextOut( hdc, x, y, (flags & DT_NOCLIP) ? 0 : ETO_CLIPPED, rect, line, len, NULL )) return 0; + } + else if (size.cx > max_width) + max_width = size.cx; if (prefix_offset != -1) { @@ -250,9 +255,9 @@ int DrawText( HDC hdc, LPSTR str, int count, LPRECT rect, WORD flags ) DeleteObject( hpen ); } + y += lh; if (strPtr) { - y += lh; if (!(flags & DT_NOCLIP)) { if (y > rect->bottom - lh) @@ -261,7 +266,11 @@ int DrawText( HDC hdc, LPSTR str, int count, LPRECT rect, WORD flags ) } } while (strPtr); - if (flags & DT_CALCRECT) rect->bottom = y; + if (flags & DT_CALCRECT) + { + rect->right = rect->left + max_width; + rect->bottom = y; + } return 1; } diff --git a/rc/ChangeLog b/rc/ChangeLog new file mode 100644 index 00000000000..c08835f25d9 --- /dev/null +++ b/rc/ChangeLog @@ -0,0 +1,5 @@ +---------------------------------------------------------------------- +Sun Sep 25 12:00:00 PDT 1994 + + * [rc/rc.y] [rc/rc.h] [rc/rc.l] [rc/winerc.c] + Files created diff --git a/rc/Imakefile b/rc/Imakefile new file mode 100644 index 00000000000..74c70641a92 --- /dev/null +++ b/rc/Imakefile @@ -0,0 +1,44 @@ +#include "../Wine.tmpl" + +.SUFFIXES: .rc + +.rc.c: + echo "#include \"windows.h\"" >$*.rct + echo WINDOWS_H_ENDS_HERE >>$*.rct + cat $< >>$*.rct + gcc -E -x c $(CFLAGS) $*.rct | sed -e '1,/^WINDOWS_H_ENDS_HERE/d' | winerc -v -p $* >$@ + $(RM) $*.rct + +AllTarget(sysres.c) + +sysres.c: winerc $(TOP)/include/windows.h + +includes:: + +clean:: + $(RM) sysres.c + + +XCOMM Rules to build the winerc program + +SRCS = \ + lex.yy.c \ + rc.tab.c \ + winerc.c + +OBJS = $(SRCS:.c=.o) + +depend:: rc.tab.c rc.tab.h lex.yy.c + +clean:: + $(RM) lex.yy.c rc.tab* y.tab.c + +ComplexProgramTarget(winerc) + +rc.tab.c rc.tab.h: rc.y + $(YACC) -b rc -d --debug rc.y + +lex.yy.c: rc.l + $(LEX) -I rc.l + + diff --git a/rc/README b/rc/README new file mode 100644 index 00000000000..d436c18fc21 --- /dev/null +++ b/rc/README @@ -0,0 +1,38 @@ +This is winerc, the resource compiler for the Wine project. It takes the +same input as rc.exe, but generates C files as output. These C files can +be linked together with the application, which can access the resource +data directly instead of using FindResource/LoadResource/LockResource. +The generated C code contains arrays, which represent the resource as if +it was obtained from LoadResource. A table to map resource names to +pointers is also available. +Primary applications are the resources of sysres.dll and a future +commdlg.dll, but the use in the library version is possible as well. +The expected advantage of using winerc over sysres.dll is a speed +improvement, however, actual data to support that claim are not +available. The use of winerc might also simplifies the source code. For +example, the system menu is managed in the function CopySysMenu +(controls/menu.c). A winerc-based implementation would just call + return LoadMenuIndirect(_Sysres_SYSMENU); +As the resources are already in the Wine image, they are loaded on +demand as any other part of a Unix executable image. + +Current State +This is the first release of winerc. It is alpha software, as the rest +of Wine is. If you use it for replacing sysres.dll, or if you write +other parts of Wine which require resource (like commdlg), you will +probably notice a loss in stability. This is especially true for cursor +and icon resources, as they are unlikely to work at all. See the TODO +file for details. + +Copying +The license for Wine applies for winerc as well. Read the files LICENSE +and WARRANTY in the current or any future distribution for details. You +can change any source files, and you can add your own copyright notice, +as long as you leave the existing copyrights intact. + +Bug Reports and Fixes +If you find a bug in winerc, you can report it to me, +martin@cs.csufresno.edu (Martin von Loewis) +or to comp.emulators.ms-windows.wine. If you can fix the bug, send the +diffs & ChangeLog to wine-new@amscons.com (Bob Amstadt), or send it to +me, and I will collect the fixes and forward them to wine-news. diff --git a/rc/README.sysres b/rc/README.sysres new file mode 100644 index 00000000000..df59f95fbe5 --- /dev/null +++ b/rc/README.sysres @@ -0,0 +1,19 @@ +This release of winerc contains a resource script for sysres.dll, +obtained by saving it as RC in Borland's Resource Workshop. Obsolete +or duplicate resources where removed. If you find that I deleted to +little or to much, drop me a note. +You are encouraged to create sysres dumps using your favoured resource +editor. If the output cannot be compiled, or the generated C code is +different from mine, report this as a bug. When comparing the results, +note that only the order might be different, which is not considered a +bug. +systest.c is a Windows program which shows how to use winerc generated +resources. Compile it with your Windows compiler, and link it with +sysres.c. It also shows how to prevent curious people from spying your +bitmaps, dialogs, and menus :-) + +Deleted resources: +Bitmap: OBMCLOSE +Menu: 1, 0xF140+2 +Dialog: 0XF140+3, EXCLAMATION_MSGBOX, QUESTION_MSGBOX, STOP_MSGBOX +Icon: SYSIDI_STOPICON diff --git a/rc/TODO b/rc/TODO new file mode 100644 index 00000000000..c00d31e8eb0 --- /dev/null +++ b/rc/TODO @@ -0,0 +1,63 @@ +1. User interface +- use GNU's long_getopt +- allow to pass input and output files via command line +- add options for various not-yet-implemented features (Unicode, Win32 +format, non-native/native alignment and endianness, compact output +format) + +2. Input format +- improve input file processing + Currently, certain pre- and postprocessing is required. winerc + should accept an arbitrary resource script and generate the C file + with as little intermediate files as possible. I'm not sure how to + handle the symbols from windows.h. There are certain options: + * winerc predefines the symbols via the cpp command line + * windows.h is #include'd, and the resulting C code is dropped + (Should winerc do C parsing here?) + * a stripped-down version of windows.h is included, + generated by "grep '^#' windows.h" + * windows.h #ifdef's every C code with _RC_INVOKED + (commercial solution) +- complete input syntax + The goal here is to support every existing resource file which is + accepted by another resource compiler, not to put as much fancy + features into the compiler as possible. Every correct resource file + which generates a parse error can be reported as a bug, a problem + analysis and a fix would be appreciated. + +3. Output file format +- add missing resources (fonts, versioninfo, stringtables,rcdata) +- check style handling + The semantics of control and dialog styles is somewhat poorly + documented. For example, I couldn't find a reference that every + control has the WS_VISIBLE and WS_CHILD style, even if they are + not specified. What other styles are considered default? + The existance of default styles implies support for disabling these, + unlike any other proper programming language, + NOT WS_VISIBLE | WS_GROUP + does *not* mean ~WS_VISIBLE, but WS_CHILD|WS_GROUP (in C semantics). + What other strange semantics are there? +- check cursor and icon handling + At the moment, the .CUR and .ICO files are copied byte-by-byte into + the C array. This is probably wrong, as there are things like cursor + and icon groups. In which way should they be present in a Wine image? + Should we have arrays for every cursor, as well as the cursor group? + Is one cursor per group enough, in the context of X? If so, do we + still need the group? +- create a more compact output file + The current format is well-suited for debugging, as one can easily + match it with a resource' hex dump. A more compact format would use + strings instead of integer lists. A clever algorithm for embedding + values <32 and >127 is required. +- platform independence + Currently, the lay-out of the resources is just as it is in Win3.1 - + packed structures, little endian. Although this format can be used + on any architecture, aligned data and native endianness would speed-up + the resource manipulation and simplify the code. OTOH, this would + break applications that rely on the lay-out. All this is of interest + for the library version only. +- Win32 support + +4. Programming Style +- memory management + No memory is freed in the current implementation. diff --git a/rc/rc.h b/rc/rc.h new file mode 100644 index 00000000000..d080882148a --- /dev/null +++ b/rc/rc.h @@ -0,0 +1,105 @@ +/* + * + * Copyright Martin von Loewis, 1994 + * + */ + +/* resource types */ +enum rt {acc,bmp,cur,dlg,fnt,ico,men,rdt,str}; +/* generic resource + Bytes can be inserted at arbitrary positions, the data field (res) + grows as required. As the dialog header contains the number of + controls, this number is generated in num_entries. If n_type if 0, + the resource name is i_name, and s_name otherwise. Top level + resources are linked via next. All gen_res objects are linked via + g_prev, g_next for debugging purposes. space is the length of res, + size is the used part of res. + As most bison rules are right recursive, new items are usually + inserted at the beginning +*/ +typedef struct gen_res{ + int size,space; + int num_entries; + enum rt type; + union{ + int i_name; + char* s_name; + }n; + int n_type; /*0 - integer, 1 = string*/ + struct gen_res *next; + struct gen_res *g_prev,*g_next; + unsigned char res[0]; +} gen_res; + +/* control/dialog style. or collects styles, and collects NOT styles */ +typedef struct rc_style{ + int and, or; +}rc_style; + +/* create a new resource */ +gen_res *new_res(void); +/* double the space of the resource */ +gen_res* grow(gen_res*); +/* insert byte array at the beginning, increase count */ +gen_res* insert_at_beginning(gen_res*,char*,int); +/* insert byte array at offset */ +gen_res* insert_bytes(gen_res*,char*,int,int); +/* delete bytes at offset */ +gen_res* delete_bytes(gen_res*,int,int); +/* create a new style */ +rc_style* new_style(void); +/* convert \t to tab etc. */ +char* parse_c_string(char*); +/* get the resources type, convert dlg to "DIALOG" and so on */ +char* get_typename(gen_res*); + +gen_res* add_accelerator(int,int,int,gen_res*); +gen_res* add_string_accelerator(char*,int,int,gen_res*); +gen_res* add_ascii_accelerator(int,int,int,gen_res*); +gen_res* add_vk_accelerator(int,int,int,gen_res*); + +gen_res* new_dialog(void); +gen_res* dialog_style(rc_style*,gen_res*); +int dialog_get_menu(gen_res*); +int dialog_get_class(gen_res*); +int dialog_get_caption(gen_res*); +int dialog_get_fontsize(gen_res*); +gen_res* dialog_caption(char*,gen_res*); +gen_res* dialog_font(short,char*,gen_res*); +gen_res* dialog_class(char*,gen_res*); +gen_res* dialog_menu(char*,gen_res*); +gen_res* create_control_desc(int,int,int,int,int,rc_style*); +gen_res* label_control_desc(char*,gen_res*); +gen_res* create_generic_control(char*,int,char*,rc_style*,int,int,int,int); +gen_res* add_control(int,int,gen_res*,gen_res*); +gen_res* add_icon(char*,int,int,int,gen_res*,gen_res*); +gen_res* add_generic_control(gen_res*,gen_res*); +gen_res* make_dialog(gen_res*,int,int,int,int,gen_res*); + +gen_res *hex_to_raw(char*,gen_res*); +gen_res *make_bitmap(gen_res*); +gen_res *make_icon(gen_res*); +gen_res *make_cursor(gen_res*); +gen_res *load_file(char*); + +gen_res *add_menuitem(char*,int,int,gen_res*); +gen_res *add_popup(char*,short,gen_res*,gen_res*); +gen_res *make_menu(gen_res*); + +gen_res *add_resource(gen_res*,gen_res*); + +void create_output(gen_res*); + +#define CT_BUTTON 0x80 +#define CT_EDIT 0x81 +#define CT_STATIC 0x82 +#define CT_LISTBOX 0x83 +#define CT_SCROLLBAR 0x84 +#define CT_COMBOBOX 0x85 + +extern int verbose; + +#ifdef __sun__ +#define strtoul strtol +#endif + diff --git a/rc/rc.l b/rc/rc.l new file mode 100644 index 00000000000..a09819f6b67 --- /dev/null +++ b/rc/rc.l @@ -0,0 +1,76 @@ +%{ +/* + * + * Copyright Martin von Loewis, 1994 + * + */ + +static char Copyright[] = "Copyright Martin von Loewis, 1994"; + +#include +#include +#include +#include "rc.h" +#include "rc.tab.h" +%} +%% +ACCELERATORS return ACCELERATORS; +ALT return ALT; +ASCII return ASCII; +BEGIN return tBEGIN; +BITMAP return tBITMAP; +CAPTION return CAPTION; +CHECKBOX return CHECKBOX; +CHECKED return CHECKED; +CLASS return CLASS; +COMBOBOX return COMBOBOX; +CONTROL return CONTROL; +CTEXT return CTEXT; +CURSOR return CURSOR; +DEFPUSHBUTTON return DEFPUSHBUTTON; +DIALOG return DIALOG; +DISCARDABLE return DISCARDABLE; +EDITTEXT return EDITTEXT; +END return tEND; +FIXED return FIXED; +FONT return FONT; +GRAYED return GRAYED; +GROUPBOX return GROUPBOX; +HELP return HELP; +ICON return ICON; +INACTIVE return INACTIVE; +LISTBOX return LISTBOX; +LTEXT return LTEXT; +MENU return MENU; +MENUBARBREAK return MENUBARBREAK; +MENUBREAK return MENUBREAK; +MENUITEM return MENUITEM; +MOVEABLE return MOVEABLE; +LOADONCALL return LOADONCALL; +NOINVERT return NOINVERT; +NOT return NOT; +NUMBER return NUMBER; +POPUP return POPUP; +PRELOAD return PRELOAD; +PUSHBUTTON return PUSHBUTTON; +PURE return PURE; +RADIOBUTTON return RADIOBUTTON; +RCDATA return RCDATA; +RTEXT return RTEXT; +SCROLLBAR return SCROLLBAR; +SHIFT return SHIFT; +SEPARATOR return SEPARATOR; +STRING return STRING; +STRINGTABLE return STRINGTABLE; +STYLE return STYLE; +VERSIONINFO return VERSIONINFO; +VIRTKEY return VIRTKEY; +\{ return tBEGIN; +\} return tEND; +[+-]?[0-9]+ yylval.num=atoi(yytext);return NUMBER; +0x[0-9A-Fa-f]+L? yylval.num=strtoul(yytext,0,16);return NUMBER; +[A-Za-z][A-Za-z_0-9]* yylval.str=strdup(yytext);return IDENT; +\"[^"]*\" yylval.str=parse_c_string(yytext);return STRING; +\'[^']*\' yylval.str=strdup(yytext+1);return SINGLE_QUOTED; +[ \t\n\r] ; +. return yytext[0]; diff --git a/rc/rc.y b/rc/rc.y new file mode 100644 index 00000000000..bfdaafcf7ce --- /dev/null +++ b/rc/rc.y @@ -0,0 +1,211 @@ +%{ +/* + * + * Copyright Martin von Loewis, 1994 + * + */ + +static char Copyright[] = "Copyright Martin von Loewis, 1994"; + +#include +#include "rc.h" +#include "windows.h" +%} +%union{ + gen_res *res; + char *str; + int num; + struct rc_style *style; +} +%token NUMBER +%token STRING SINGLE_QUOTED IDENT +%token ACCELERATORS ALT ASCII tBEGIN tBITMAP CAPTION CHECKBOX CHECKED +%token CLASS COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG +%token DISCARDABLE EDITTEXT tEND FIXED FONT GRAYED GROUPBOX HELP ICON +%token IDENT INACTIVE LISTBOX LTEXT MENU MENUBARBREAK MENUBREAK MENUITEM +%token MOVEABLE LOADONCALL NOINVERT NOT NOT_SUPPORTED POPUP PRELOAD +%token PURE PUSHBUTTON RADIOBUTTON RCDATA RTEXT SCROLLBAR SHIFT SEPARATOR +%token SINGLE_QUOTED STRING STRINGTABLE STYLE VERSIONINFO VIRTKEY +%type resource_file resource resources resource_definition accelerators +%type events bitmap cursor dialog dlg_attributes controls +%type generic_control labeled_control control_desc font icon +%type iconinfo menu menu_body item_definitions rcdata raw_data raw_elements +%type stringtable strings versioninfo +%type acc_options item_options +%type