under Windows 3.1.
- Cleanup of the NT sources. Remove DOS fossils.
/* -*-C-*-
-$Id: ntgui.c,v 1.5 1993/08/07 00:12:49 adams Exp $
+$Id: ntgui.c,v 1.6 1993/08/21 03:32:14 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
#include "os.h"
#include "ntgui.h"
#include "ntscreen.h"
+#include "ntdialog.h"
#include <string.h>
+#include <stdarg.h>
\f
extern /*static*/ HANDLE ghInstance = 0;
PRIMITIVE_HEADER(1);
{
SCHEME_OBJECT wndproc = ARG_REF(1);
- if (! ADDRESS_CONSTANT_P (OBJECT_ADDRESS (wndproc)))
+ if (! (ADDRESS_CONSTANT_P (OBJECT_ADDRESS (wndproc))))
signal_error_from_primitive (ERR_ARG_1_WRONG_TYPE);
general_scheme_wndproc = wndproc;
PRIMITIVE_RETURN (UNSPECIFIC);
lpvParam = (LPVOID) ARG_REF (10);
result = CreateWindowEx (0, class_name, window_name, style, x, y, w, h,
- hWndParent, hMenu, ghInstance, lpvParam);
+ hWndParent, hMenu, ghInstance, lpvParam);
return ulong_to_integer (result);
}
}
PRIMITIVE_RETURN (UNSPECIFIC);
}
-
-
\f
static void *
xmalloc (int size)
{
free (p);
}
+\f
+/* GUI utilities for debuggging .*/
+
+#ifdef W32_TRAP_DEBUG
+
+extern HANDLE ghInstance;
+extern HANDLE master_tty_window;
+extern int TellUser (char *, ...);
+extern int TellUserEx (int, char *, ...);
+extern char * AskUser (char *, int);
+
+int
+TellUser (char * format, ...)
+{
+ va_list arg_ptr;
+ char buffer[1024];
+
+ va_start (arg_ptr, format);
+ wvsprintf (&buffer[0], format, arg_ptr);
+ va_end (arg_ptr);
+ return (MessageBox (master_tty_window,
+ ((LPCSTR) &buffer[0]),
+ ((LPCSTR) "MIT Scheme Win32 Notification"),
+ (MB_TASKMODAL | MB_ICONINFORMATION
+ | MB_SETFOREGROUND | MB_OK)));
+}
+
+int
+TellUserEx (int flags, char * format, ...)
+{
+ va_list arg_ptr;
+ char buffer[1024];
+
+ va_start (arg_ptr, format);
+ wvsprintf (&buffer[0], format, arg_ptr);
+ va_end (arg_ptr);
+ return (MessageBox (master_tty_window,
+ ((LPCSTR) &buffer[0]),
+ ((LPCSTR) "MIT Scheme Win32 Notification"),
+ (MB_TASKMODAL | MB_ICONINFORMATION
+ | MB_SETFOREGROUND | flags)));
+}
+\f
+static char * askuserbuffer = ((char *) NULL);
+static int askuserbufferlength = 0;
+
+static BOOL APIENTRY
+DEFUN (askuserdlgproc, (hwnddlg, message, wparam, lparam),
+ HWND hwnddlg AND UINT message
+ AND WPARAM wparam AND LPARAM lparam)
+{
+ switch (message)
+ {
+ case WM_CLOSE:
+ done:
+ GetDlgItemText (hwnddlg, SCHEME_INPUT_TEXT,
+ askuserbuffer,
+ askuserbufferlength);
+ EndDialog (hwnddlg, 0);
+ return (TRUE);
+
+ case WM_COMMAND:
+ switch (wparam)
+ {
+ case IDOK:
+ goto done;
+
+ case IDCANCEL:
+ EndDialog (hwnddlg, -1);
+ return (TRUE);
+
+ default:
+ return (FALSE);
+ }
+
+ case WM_INITDIALOG:
+ return (TRUE);
+
+ default:
+ return (FALSE);
+ }
+}
+
+char *
+DEFUN (AskUser, (buf, len), char * buf AND int len)
+{
+ char * result;
+
+ askuserbuffer = buf;
+ askuserbufferlength = len;
+ result = (DialogBox (ghInstance,
+ SCHEME_INPUT,
+ master_tty_window,
+ askuserdlgproc));
+ if (result == -1)
+ return ((char *) NULL);
+
+ askuserbuffer = ((char *) NULL);
+ askuserbufferlength = 0;
+ return (buf);
+}
+
+#endif /* W32_TRAP_DEBUG */
/* -*-C-*-
-$Id: ntio.c,v 1.6 1993/07/28 20:28:14 gjr Exp $
+$Id: ntio.c,v 1.7 1993/08/21 03:34:00 gjr Exp $
Copyright (c) 1992-1993 Massachusetts Institute of Technology
unsigned int OS_channels_registered;
-HANDLE STDIN_HANDLE, STDOUT_HANDLE, STDERR_HANDLE;
-
+#ifndef GUI
+ HANDLE STDIN_HANDLE, STDOUT_HANDLE, STDERR_HANDLE;
+#endif
static void
-DEFUN_VOID (DOS_channel_close_all)
+DEFUN_VOID (NT_channel_close_all)
{
Tchannel channel;
for (channel = 0; (channel < OS_channel_table_size); channel += 1)
void
DEFUN_VOID (NT_initialize_channels)
{
- STDIN_HANDLE = GetStdHandle (STD_INPUT_HANDLE);
- STDOUT_HANDLE = GetStdHandle (STD_OUTPUT_HANDLE);
- STDERR_HANDLE = GetStdHandle (STD_ERROR_HANDLE);
+#ifndef GUI
+ STDIN_HANDLE = (GetStdHandle (STD_INPUT_HANDLE));
+ STDOUT_HANDLE = (GetStdHandle (STD_OUTPUT_HANDLE));
+ STDERR_HANDLE = (GetStdHandle (STD_ERROR_HANDLE));
if (STDIN_HANDLE == INVALID_HANDLE_VALUE ||
STDOUT_HANDLE == INVALID_HANDLE_VALUE ||
- STDERR_HANDLE == INVALID_HANDLE_VALUE) {
+ STDERR_HANDLE == INVALID_HANDLE_VALUE)
+ {
outf_fatal ("\nUnable to get standard handles %s(%d).\n",
__FILE__, __LINE__);
termination_init_error ();
}
-#ifndef GUI
SetConsoleMode (STDIN_HANDLE,
- ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT);
+ ( ENABLE_LINE_INPUT
+ | ENABLE_ECHO_INPUT
+ | ENABLE_PROCESSED_INPUT));
SetConsoleCtrlHandler (NT_ctrl_handler, TRUE);
#endif /* GUI */
master_tty_window = Screen_Create (NULL, "MIT Scheme", SW_SHOWNORMAL);
-
- OS_channel_table_size = (DOS_SC_OPEN_MAX ());
+ OS_channel_table_size = (NT_SC_OPEN_MAX ());
channel_table =
- (DOS_malloc (OS_channel_table_size * (sizeof (struct channel))));
+ (NT_malloc (OS_channel_table_size * (sizeof (struct channel))));
if (channel_table == 0)
- {
- outf_fatal ("\nUnable to allocate channel table.\n");
- termination_init_error ();
- }
+ {
+ outf_fatal ("\nUnable to allocate channel table.\n");
+ termination_init_error ();
+ }
{
Tchannel channel;
for (channel = 0; (channel < OS_channel_table_size); channel += 1)
MARK_CHANNEL_CLOSED (channel);
}
- add_reload_cleanup (DOS_channel_close_all);
+ add_reload_cleanup (NT_channel_close_all);
OS_channels_registered = 0;
return;
}
void
-DEFUN_VOID (DOS_reset_channels)
+DEFUN_VOID (NT_reset_channels)
{
- DOS_free (channel_table);
+ NT_free (channel_table);
channel_table = 0;
OS_channel_table_size = 0;
return;
return;
}
-//extern int EXFUN (dos_read, (int, PTR, size_t, int, int, int));
-//
-//int
-//DEFUN (dos_read, (fd, buffer, nbytes, buffered_p, blocking_p, intrpt_p),
-// HANDLE fd AND PTR buffer AND size_t nbytes
-// AND int buffered_p AND int blocking_p AND int intrpt_p)
-//{
-// if (nbytes == 0)
-// return (0);
-// else if (fd == (fileno (stdin)))
-// return (console_read (buffer, nbytes, buffered_p, blocking_p, intrpt_p));
-// else
-// return (DOS_read (fd, buffer, nbytes));
-//}
-
static void
Relinquish_Timeslice (void)
{
DEFUN (nt_channel_read, (channel, buffer, nbytes),
Tchannel channel AND PTR buffer AND size_t nbytes)
{
- DWORD bytesRead = 0;
+ DWORD bytesRead = 0;
if (nbytes == 0)
- return 0;
- else if (Screen_IsScreenHandle(CHANNEL_HANDLE (channel)))
+ return (0);
+
+ if (Screen_IsScreenHandle (CHANNEL_HANDLE (channel)))
{
bytesRead = Screen_Read ((CHANNEL_HANDLE (channel)),
((BOOL) (CHANNEL_BUFFERED (channel))),
buffer, nbytes);
- if (bytesRead == 0xffffffff) {
+ if (bytesRead == 0xffffffff)
+ {
/* for pleasantness give up rest of this timeslice */
Relinquish_Timeslice ();
errno = ERRNO_NONBLOCK;
}
- return (int)bytesRead;
+ return ((int) bytesRead);
}
- else if (IsConsoleHandle(CHANNEL_HANDLE (channel))) {
+
+ if (IsConsoleHandle (CHANNEL_HANDLE (channel)))
+ {
/* fake the console being a nonblocking channel that has nothing after
- each alternate read */
+ each alternate read
+ */
+
static int nonblock = 1;
nonblock = !nonblock;
- if (nonblock) {
+ if (nonblock)
+ {
errno = ERRNO_NONBLOCK;
- return -1;
+ return (-1);
}
- if (ReadFile (CHANNEL_HANDLE (channel), buffer, nbytes, &bytesRead, 0))
- return (int)bytesRead;
- else
- return -1;
- }
- else {
- if (ReadFile (CHANNEL_HANDLE (channel), buffer, nbytes, &bytesRead, 0))
- return (int)bytesRead;
- else
- return -1;
}
+
+ if (ReadFile (CHANNEL_HANDLE (channel), buffer, nbytes, &bytesRead, 0))
+ return ((int) bytesRead);
+ else
+ return (-1);
}
long
if (scr < 0)
{
if (errno == ERRNO_NONBLOCK)
- return -1;
- DOS_prim_check_errno (syscall_read);
+ return (-1);
+ NT_prim_check_errno (syscall_read);
continue;
}
else if (((size_t) scr) > nbytes)
error_external_return ();
- else {
- return (scr);
- }
+ else
+ return (scr);
}
}
\f
return (nbytes);
}
if (IsConsoleHandle (fd))
- return (dos_console_write (buffer, nbytes));
+ return (nt_console_write (buffer, nbytes));
if (WriteFile (fd, buffer, nbytes, &bytesWritten, 0))
return (bytesWritten);
else
if (scr < 0)
{
- DOS_prim_check_errno (syscall_write);
+ NT_prim_check_errno (syscall_write);
continue;
}
DEFUN (OS_channel_read_load_file, (channel, buffer, nbytes),
Tchannel channel AND PTR buffer AND size_t nbytes)
{
- DWORD scr;
- if (ReadFile (CHANNEL_HANDLE (channel), buffer, nbytes, &scr, 0))
- return scr;
- else
- return 0;
+ DWORD scr;
+
+ return ((ReadFile (CHANNEL_HANDLE (channel), buffer, nbytes, &scr, 0))
+ ? scr : 0);
}
size_t
Tchannel channel AND CONST PTR buffer AND size_t nbytes)
{
DWORD scr;
- if (WriteFile (CHANNEL_HANDLE (channel), buffer, nbytes, &scr, 0))
- return scr;
- else
- return 0;
+
+ return ((WriteFile (CHANNEL_HANDLE (channel), buffer, nbytes, &scr, 0))
+ ? scr : 0);
}
void
int
DEFUN (OS_terminal_buffered_p, (channel), Tchannel channel)
{
- return (CHANNEL_BUFFERED(channel));
+ return (CHANNEL_BUFFERED (channel));
}
void
DEFUN (OS_terminal_buffered, (channel), Tchannel channel)
{
- CHANNEL_BUFFERED(channel) = 1;
+ CHANNEL_BUFFERED (channel) = 1;
}
void
DEFUN (OS_terminal_nonbuffered, (channel), Tchannel channel)
{
- CHANNEL_BUFFERED(channel) = 0;
+ CHANNEL_BUFFERED (channel) = 0;
}
int
DEFUN (OS_terminal_cooked_output_p, (channel), Tchannel channel)
{
- return (CHANNEL_COOKED(channel));
+ return (CHANNEL_COOKED (channel));
}
void
DEFUN (OS_terminal_cooked_output, (channel), Tchannel channel)
{
- CHANNEL_COOKED(channel) = 1;
+ CHANNEL_COOKED (channel) = 1;
}
void
unsigned int
DEFUN (OS_terminal_get_ispeed, (channel), Tchannel channel)
{
- return 0;
+ return (0);
}
unsigned int
DEFUN (OS_terminal_get_ospeed, (channel), Tchannel channel)
{
- return 0;
+ return (0);
}
void
Tchannel channel AND
unsigned int baud)
{
+ return;
}
void
Tchannel channel AND
unsigned int baud)
{
+ return;
}
unsigned int
DEFUN (OS_baud_index_to_rate, (index), unsigned int index)
{
- return 9600;
+ return (9600);
}
int
DEFUN (OS_terminal_get_state, (channel, state_ptr),
Tchannel channel AND PTR state_ptr)
{
- unsigned char *statep = (unsigned char *) state_ptr;
+ unsigned char * statep = ((unsigned char *) state_ptr);
- *statep++ = CHANNEL_NONBLOCKING(channel);
- *statep++ = CHANNEL_BUFFERED(channel);
- *statep = CHANNEL_COOKED(channel);
+ *statep++ = CHANNEL_NONBLOCKING (channel);
+ *statep++ = CHANNEL_BUFFERED (channel);
+ *statep = CHANNEL_COOKED (channel);
return;
}
DEFUN (OS_terminal_set_state, (channel, state_ptr),
Tchannel channel AND PTR state_ptr)
{
- unsigned char *statep = (unsigned char *) state_ptr;
+ unsigned char * statep = ((unsigned char *) state_ptr);
- CHANNEL_NONBLOCKING(channel) = *statep++;
- CHANNEL_BUFFERED(channel) = *statep++;
- CHANNEL_COOKED(channel) = *statep;
+ CHANNEL_NONBLOCKING (channel) = *statep++;
+ CHANNEL_BUFFERED (channel) = *statep++;
+ CHANNEL_COOKED (channel) = *statep;
return;
}
return;
}
-/* No SELECT in DOS */
+/* Hold-over from DOS.
+ This needs to be updated to use the NT equivalent.
+ */
+
CONST int OS_have_select_p = 0;
long
return -4;
else
{
- DOS_prim_check_errno (syscall_read);
+ NT_prim_check_errno (syscall_read);
continue;
}
}
/* -*-C-*-
-$Id: ntio.h,v 1.4 1993/06/24 02:15:21 gjr Exp $
+$Id: ntio.h,v 1.5 1993/08/21 03:34:27 gjr Exp $
Copyright (c) 1992-1993 Massachusetts Institute of Technology
#define CARRIAGE_RETURN '\r'
#define LINEFEED '\n'
#define CNTRL_Z '\032'
-#define DELETE '\177'
+#define ASCII_DELETE '\177'
-#define CONSOLE_HANDLE (STDIN_HANDLE)
-#define IsConsoleHandle(h) ((h)==CONSOLE_HANDLE)
+extern BOOL EXFUN (Screen_IsScreenHandle, (HANDLE));
+
+#ifndef GUI
+# define CONSOLE_HANDLE (STDIN_HANDLE)
+# define IsConsoleHandle(h) ((h) == CONSOLE_HANDLE)
+#else
+# define IsConsoleHandle(h) (0 == 1)
+#endif
#endif /* SCM_NTIO_H */
/* -*-C-*-
-$Id: ntscmlib.h,v 1.1 1993/07/27 20:53:51 gjr Exp $
+$Id: ntscmlib.h,v 1.2 1993/08/21 03:38:52 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
promotional, or sales literature without prior written consent from
MIT in each case. */
-/* MIT Scheme under Windows system utilities exports. */
+/* MIT Scheme under Windows system-dependent utilities. */
#ifndef SCM_NTLIB_H
#include <windows.h>
+\f
+/* Timer installation status codes. */
#define WIN32_ASYNC_TIMER_OK 0
#define WIN32_ASYNC_TIMER_NONE 1
#define WIN32_ASYNC_TIMER_RESOLUTION 3
#define WIN32_ASYNC_TIMER_NOLOCK 4
#define WIN32_ASYNC_TIMER_NOMEM 5
-
-extern BOOL win32_under_win32s_p (void);
-
-extern char * win32_allocate_heap (unsigned long, unsigned long *);
-extern void win32_release_heap (char *, unsigned long);
-
-extern BOOL win32_lock_memory_area (void *, unsigned long);
-extern void win32_unlock_memory_area (void *, unsigned long);
-
-extern UINT win32_install_async_timer (unsigned long *, unsigned long *,
- unsigned long *, unsigned long,
- void **);
-extern void win32_flush_async_timer (void *);
+#define WIN32_ASYNC_TIMER_NOLDT 6
+
+#ifndef W32SUT_16
+
+/* Exports to Scheme */
+
+extern BOOL
+ win32_under_win32s_p (void);
+
+extern char *
+ win32_allocate_heap (unsigned long, /* size */
+ unsigned long *); /* handle */
+extern void
+ win32_release_heap (char *, /* base */
+ unsigned long); /* handle */
+
+extern BOOL
+ win32_lock_memory_area (void *, /* area */
+ unsigned long); /* size */
+extern void
+ win32_unlock_memory_area (void *, /* area */
+ unsigned long); /* size */
+
+extern UINT
+ win32_install_async_timer (unsigned long *, /* regs */
+ unsigned long, /* memtop off */
+ unsigned long, /* int_code off */
+ unsigned long, /* int_mask off */
+ unsigned long, /* mask */
+ void **); /* timer state */
+extern void
+ win32_flush_async_timer (void *);
+
+extern BOOL
+ win32_alloc_scheme_selectors (unsigned long, /* base */
+ unsigned long, /* limit */
+ unsigned short *, /* cs */
+ unsigned short *, /* ds */
+ unsigned short *); /* ss */
+extern void
+ win32_release_scheme_selectors (unsigned short, /* cs */
+ unsigned short, /* ds */
+ unsigned short); /* ss */
+#endif /* W32SUT_16 */
+\f
+#if defined(W32SUT_32) || defined(W32SUT_16)
+
+/* Under Win3.1, there is a 16-bit "universal thunk".
+ The following define the communications protocol.
+ */
+
+#include <stdarg.h>
+#include <w32sut.h>
+
+#ifdef W32SUT_16
+ typedef unsigned long FAR * SCM_ULPTR;
+#else
+ typedef unsigned long * SCM_ULPTR;
+#endif
+
+typedef LPVOID SCM_VDPTR;
+typedef unsigned long SCM_ULONG;
+typedef unsigned short SCM_BOOL;
+typedef unsigned short SCM_SEL;
+
+#define STRINGIFY(arg) #arg
+
+#define NTW16LIB_DLL_NAME "ntw16lib.dll"
+#define NTW16LIB_DLL_INIT ntw16lib_init
+#define NTW16LIB_DLL_ENTRY ntw16lib_handler
+
+#define NTW32LIB_RESERVED 0
+
+#define NTW32LIB_VIRTUAL_LOCK 1
+struct ntw32lib_vlock_s
+{
+ SCM_VDPTR area; /* ->16 */
+ SCM_ULONG size; /* ->16 */
+};
+
+#define NTW32LIB_VIRTUAL_UNLOCK 2
+struct ntw32lib_vulock_s
+{
+ SCM_VDPTR area; /* ->16 */
+ SCM_ULONG size; /* ->16 */
+};
+\f
+#define NTW32LIB_INSTALL_TIMER 3
+struct ntw32lib_itimer_s
+{
+ SCM_ULPTR base; /* ->16 */
+ SCM_ULONG memtop_off; /* ->16 */
+ SCM_ULONG int_code_off; /* ->16 */
+ SCM_ULONG int_mask_off; /* ->16 */
+ SCM_ULONG bit_mask; /* ->16 */
+ SCM_ULONG handle; /* ->32 */
+};
+
+#define NTW32LIB_FLUSH_TIMER 4
+struct ntw32lib_ftimer_s
+{
+ SCM_ULONG handle; /* ->16 */
+};
+
+#define NTW32LIB_ALLOC_SELECTORS 5
+struct ntw32lib_selalloc_s
+{
+ SCM_ULONG base; /* ->16 */
+ SCM_ULONG limit; /* ->16 */
+ SCM_SEL cs32; /* ->16 */
+ SCM_SEL ds32; /* ->16 */
+ SCM_SEL cs; /* ->32 */
+ SCM_SEL ds; /* ->32 */
+ SCM_SEL ss; /* ->32 */
+};
+
+#define NTW32LIB_FREE_SELECTORS 6
+struct ntw32lib_selfree_s
+{
+ SCM_SEL cs32; /* ->16 */
+ SCM_SEL ds32; /* ->16 */
+ SCM_SEL cs; /* ->16 */
+ SCM_SEL ds; /* ->16 */
+ SCM_SEL ss; /* ->16 */
+};
+
+#endif /* defined(W32SUT_32) || defined(W32SUT_16) */
#endif /* SCM_NTLIB_H */
#include "windows.h"
#include "ntgui.h"
+#include "ntdialog.h"
SHIELD3_ICON ICON shield3.ico
SHIELD4_ICON ICON shield4.ico
GRAPHICS_ICON ICON graphics.ico
CONSES_ICON ICON conses.ico
ENVIRONMENT_ICON ICON envir1.ico
+
+RCINCLUDE NTDIALOG.DLG
LIBRARY ntscmlib
DESCRIPTION "MIT Scheme Win32 DLL"
-VERSION 0.3
+VERSION 0.4
CODE PRELOAD MOVEABLE DISCARDABLE
DATA NONE
win32_unlock_memory_area @ 5
win32_install_async_timer @ 6
win32_flush_async_timer @ 7
+ win32_alloc_scheme_selectors @ 8
+ win32_release_scheme_selectors @ 9
LIBRARY ntscmlib
DESCRIPTION "MIT Scheme Win32 DLL"
-VERSION 0.3
+VERSION 0.4
CODE PRELOAD MOVEABLE DISCARDABLE
DATA NONE
win32_unlock_memory_area @ 5
win32_install_async_timer @ 6
win32_flush_async_timer @ 7
+ win32_alloc_scheme_selectors @ 8
+ win32_release_scheme_selectors @ 9