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 <micky@marie.physik.tu-berlin.de>
* [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 <j0t2527@tam2000.tamu.edu>
* [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 <t.d.g.sandford@bradford.ac.uk>
* [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.
diff --git a/misc/Imakefile b/misc/Imakefile
index 3bd175fd..c5bdec9 100644
--- a/misc/Imakefile
+++ b/misc/Imakefile
@@ -7,6 +7,7 @@
atom.c \
clipboard.c \
comm.c \
+ commdlg.c \
dos_fs.c \
driver.c \
exec.c \
@@ -15,8 +16,10 @@
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 1aad3cd..42e63ee 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 @@
#ifdef BUILTIN_MMSYSTEM
+#define EMULATE_SB16
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -344,7 +346,7 @@
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 @@
return 0;
}
}
-*/
+/**/
lpWaveHdr = &MCIWavDev[wDevID].WaveHdr;
lpWaveHdr->lpData = (LPSTR) malloc(64000);
lpWaveHdr->dwBufferLength = 32000;
@@ -719,7 +721,7 @@
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 @@
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 @@
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 @@
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 @@
}
-/*-----------------------------------------------------------------------*/
-
-
-
-/**************************************************************************
-* 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 ad2d99a..3910314 100644
--- a/misc/clipboard.c
+++ b/misc/clipboard.c
@@ -13,6 +13,8 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
#include "prototypes.h"
#include "heap.h"
#include "win.h"
@@ -35,6 +37,8 @@
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 @@
}
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 @@
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 @@
{
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 @@
{
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 @@
}
+/**************************************************************************
+ * 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 930a5f1..00a0d6a 100644
--- a/misc/comm.c
+++ b/misc/comm.c
@@ -29,55 +29,62 @@
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 WinError(void)
{
- perror("comm");
+ dprintf_comm(stddeb, "WinError: errno = %d\n", errno);
switch (errno) {
default:
return CE_IOE;
@@ -175,8 +182,11 @@
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 @@
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 @@
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 @@
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 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 @@
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 @@
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 @@
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 0000000..aa1614b
--- /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 29a68ed..f6ba92f 100644
--- a/misc/dos_fs.c
+++ b/misc/dos_fs.c
@@ -382,9 +382,7 @@
ToUnix(rootdir);
-#ifdef DEBUG
- fprintf(stderr,"%s\n", rootdir);
-#endif
+ dprintf_dosfs(stddeb,"%s\n", rootdir);
}
@@ -440,7 +438,7 @@
{
/* 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 31d3570..920cb27 100644
--- a/misc/exec.c
+++ b/misc/exec.c
@@ -129,14 +129,14 @@
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 5a9d86a..2320a8b 100644
--- a/misc/file.c
+++ b/misc/file.c
@@ -186,12 +186,14 @@
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 5c2a1a4..3b9250e 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -201,6 +201,56 @@
}
/***********************************************************************
+ * 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<sizeof(debug_msg_enabled)/sizeof(short);i++)
+ debug_msg_enabled[i]=(*options=='+');
+ }
+ else
+ {
+ int i;
+ for (i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
+ if (debug_msg_name && (!strncasecmp(options+1,debug_msg_name[i],l-1)))
+ {
+ debug_msg_enabled[i]=(*options=='+');
+ break;
+ }
+ if (i==sizeof(debug_msg_enabled)/sizeof(short))
+ return FALSE;
+ }
+ options+=l;
+ }
+ while((*options==',')&&(*(++options)));
+ if (*options)
+ return FALSE;
+ else
+ return TRUE;
+}
+
+#endif
+
+/***********************************************************************
* MAIN_ParseOptions
*
* Parse command line options and open display.
@@ -209,7 +259,7 @@
{
char *display_name;
XrmValue value;
- XrmDatabase db = NULL;
+ XrmDatabase db = XrmGetFileDatabase("/usr/lib/X11/app-defaults/Wine");
/* Parse command line */
Options.programName = MAIN_GetProgramName( *argc, argv );
@@ -254,6 +304,10 @@
screenDepth = atoi( value.addr );
if (MAIN_GetResource( db, ".desktop", &value))
Options.desktopGeometry = value.addr;
+#ifdef DEBUG_RUNTIME
+ if (MAIN_GetResource( db, ".debugoptions", &value))
+ ParseDebugOptions((char*)value.addr);
+#endif
if (MAIN_GetResource( db, ".debugmsg", &value))
{
#ifndef DEBUG_RUNTIME
@@ -262,38 +316,19 @@
argv[0]);
exit(1);
#else
- char *p=(char*)value.addr;
- if (strlen(p)<3)
- goto msgerror;
- if ((*p!='+')&&(*p!='-'))
- goto msgerror;
- if (!strcasecmp(p+1,"all"))
+ if (ParseDebugOptions((char*)value.addr)==FALSE)
{
int i;
- for (i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
- debug_msg_enabled[i]=(*p=='+');
- }
- else
- {
- int i;
- for (i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
- if (debug_msg_name && (!strcasecmp(p+1,debug_msg_name[i])))
- {
- debug_msg_enabled[i]=(*p=='+');
- break;
- }
- if (i==sizeof(debug_msg_enabled)/sizeof(short))
- {
- msgerror:
- fprintf(stderr,"%s: Syntax: -debugmsg +xxx or -debugmsg -xxx with xxx one of\n",argv[0]);
- fprintf(stderr,"%-9s ","all");
- for(i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
- if(debug_msg_name[i])
- fprintf(stderr,"%-9s%c",debug_msg_name[i],
+ fprintf(stderr,"%s: Syntax: -debugmsg +xxx,... or -debugmsg -xxx,...\n",argv[0]);
+ fprintf(stderr,"Example: -debugmsg +all,-heap turn on all messages except heap messages\n");
+ fprintf(stderr,"Available message types:\n");
+ fprintf(stderr,"%-9s ","all");
+ for(i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
+ if(debug_msg_name[i])
+ fprintf(stderr,"%-9s%c",debug_msg_name[i],
(((i+2)%8==0)?'\n':' '));
- fprintf(stderr,"\n\n");
- exit(1);
- }
+ fprintf(stderr,"\n\n");
+ exit(1);
}
#endif
}
@@ -435,6 +470,7 @@
MAIN_SaveSetup();
DOS_InitFS();
Comm_Init();
+ Font_Init();
#ifndef WINELIB
INT21_Init();
#endif
diff --git a/misc/mcianim.c b/misc/mcianim.c
new file mode 100644
index 0000000..8a850f9
--- /dev/null
+++ b/misc/mcianim.c
@@ -0,0 +1,679 @@
+/*
+ * Sample MCI ANIMATION Wine Driver for Linux
+ *
+ * Copyright 1994 Martin Ayotte
+ */
+static char Copyright[] = "Copyright Martin Ayotte, 1994";
+
+#ifndef WINELIB
+#define BUILTIN_MMSYSTEM
+#endif
+
+#ifdef BUILTIN_MMSYSTEM
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#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 213ebff..de2a3d8 100644
--- a/misc/mcicda.c
+++ b/misc/mcicda.c
@@ -93,7 +93,7 @@
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 @@
}
/**************************************************************************
-* CDAUDIO_GetNumberOfTracks [internal]
+* CDAUDIO_GetTracksInfo [internal]
*/
BOOL CDAUDIO_GetTracksInfo(UINT wDevID)
{
@@ -544,7 +544,7 @@
/**************************************************************************
-* CDAUDIO_GetNumberOfTracks [internal]
+* CDAUDIO_GetCDStatus [internal]
*/
BOOL CDAUDIO_GetCDStatus(UINT wDevID)
{
diff --git a/misc/message.c b/misc/message.c
index 3f766df..5063736 100644
--- a/misc/message.c
+++ b/misc/message.c
@@ -6,7 +6,6 @@
static char Copyright[] = "Copyright Martin Ayotte, 1993";
-#define DEBUG_MSGBOX
#include <stdlib.h>
#include <stdio.h>
@@ -21,7 +20,12 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 0000000..cc20a08
--- /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 <fcntl.h>
+#include <sys/ioctl.h>
+#ifdef linux
+#include <linux/soundcard.h>
+#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 80ed111..1c4cc06 100644
--- a/misc/mmaux.c
+++ b/misc/mmaux.c
@@ -11,6 +11,8 @@
#ifdef BUILTIN_MMSYSTEM
+#define EMULATE_SB16
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -53,10 +55,55 @@
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 @@
/**************************************************************************
* 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 @@
return MMSYSERR_NOTENABLED;
}
close(mixer);
+ *lpdwVol = MAKELONG(volume, volume);
return MMSYSERR_NOERROR;
#else
return MMSYSERR_NOTENABLED;
@@ -125,9 +174,10 @@
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 4da49f9..db60012 100644
--- a/misc/mmsystem.c
+++ b/misc/mmsystem.c
@@ -16,6 +16,15 @@
#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 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 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 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 @@
*/
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 @@
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 @@
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 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 @@
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 @@
*/
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 @@
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 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 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 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 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 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 @@
/**************************************************************************
* 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 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 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 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 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
{
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 @@
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 @@
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 7bd9488..12a961e 100644
--- a/misc/profile.c
+++ b/misc/profile.c
@@ -25,8 +25,11 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
{
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 b58d173..9733ae1 100644
--- a/misc/property.c
+++ b/misc/property.c
@@ -3,9 +3,6 @@
*/
static char Copyright[] = "Copyright Martin Ayotte, 1994";
-/*
-#define DEBUG_PROP
-*/
#include <stdlib.h>
#include <stdio.h>
@@ -14,6 +11,11 @@
#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 @@
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 @@
}
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 @@
(((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 @@
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 @@
{
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 @@
}
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 @@
(((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 @@
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 @@
(((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 @@
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 @@
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 @@
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 6682100..71af863 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 @@
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 @@
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 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 @@
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 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 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 @@
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 @@
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 @@
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 @@
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 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 @@
*/
void DragAcceptFiles(HWND hWnd, BOOL b)
{
- fprintf(stderr, "DragAcceptFiles : Empty Stub !!!\n");
+ dprintf_reg(stdnimp, "DragAcceptFiles : Empty Stub !!!\n");
}
@@ -302,7 +275,7 @@
*/
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 DragFinish(HDROP h)
{
- fprintf(stderr, "DragFinish : Empty Stub !!!\n");
+ dprintf_reg(stdnimp, "DragFinish : Empty Stub !!!\n");
}
@@ -322,8 +295,8 @@
*/
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 @@
*/
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 FindExecutable(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
{
- fprintf(stderr, "FindExecutable : Empty Stub !!!\n");
+ dprintf_reg(stdnimp, "FindExecutable : Empty Stub !!!\n");
}
@@ -371,7 +344,7 @@
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 @@
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 ExtractAssociatedIcon(HINSTANCE hInst,LPSTR lpIconPath, LPWORD lpiIcon)
{
- fprintf(stderr, "ExtractAssociatedIcon : Empty Stub !!!\n");
+ dprintf_reg(stdnimp, "ExtractAssociatedIcon : Empty Stub !!!\n");
}
/*************************************************************************
@@ -437,7 +410,7 @@
*/
int RegisterShellHook(void *ptr)
{
- fprintf(stderr, "RegisterShellHook : Empty Stub !!!\n");
+ dprintf_reg(stdnimp, "RegisterShellHook : Empty Stub !!!\n");
return 0;
}
@@ -447,5 +420,5 @@
*/
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 2598711..f121b18 100644
--- a/misc/spy.c
+++ b/misc/spy.c
@@ -268,7 +268,7 @@
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 e503ef9..3223fa7 100644
--- a/misc/stress.c
+++ b/misc/stress.c
@@ -2,23 +2,22 @@
#include <limits.h>
#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 @@
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 @@
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 5195e2a..f9e2b1d 100644
--- a/misc/winsocket.c
+++ b/misc/winsocket.c
@@ -19,8 +19,11 @@
#include <unistd.h>
#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 @@
{
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 @@
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_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_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_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_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_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 *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 @@
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_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 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 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_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 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 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_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_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 @@
{
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 @@
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 *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 *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 @@
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 *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 *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 *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 *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 @@
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 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 @@
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 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 &&