Commit f0b2354c authored by Alexandre Julliard's avatar Alexandre Julliard

Release 0.4.3

Tue Sep 28 19:59:21 1993 David Metcalfe * [windows/win.c] Implemented support for windows with no borders. Added GetParent(), GetDlgCtrlID(), GetWindowText() and GetWindowTextLength() functions. * [misc/xt.c] Added processing of WM_GETTEXT and WM_GETTEXTLENGTH messages to DefWindowProc and Implemented MessageBeep(). * [windows/syscolor.c] Added preliminary system color support. * [controls/button1.c] Mods to new button control and integration with Wine. Tue Sep 28 19:59:21 1993 Johannes Ruscheinski * [controls/button1.c] New button control using GDI functions. Tue Sep 28 19:59:21 1993 Eric Youngdale * [debugger/*] Added debugging capabilities to Wine Sat Sep 25 13:22:50 1993 Alexandre Julliard (julliard@di.epfl.ch) * [objects/region.c] Bug fix Fri Sep 24 07:35:11 1993 Bob Amstadt (bob at pooh) * [tools/build.c] Changed the entry point code to reduce the standard entry point size from 22 bytes to 10 bytes. This leaves about 4000 free entry points instead of the 800 in version 0.4.2. * [loader/resource.c] Rewrote functions to allow loading of resources from any DLL. * [loader/wine.c] [include/wine.h] Added functions GetFilenameFromInstance() and GetFileInfo() to search for a loaded file based on its instance handle. Added a field in struct w_files to make searching by an instance handle faster. Tue Sep 21 09:57:01 1993 miguel@roxanne.nuclecu.unam.mx (Miguel de Icaza) * [misc/profile.c] Implementation of .INI file handling Mon Sep 20 10:54:32 1993 David Metcalfe * [misc/profile.c.old] Implementation of .INI file handling Mon Sep 20 10:54:32 1993 John Brezak * [controls/WinButton.c] Bug fix with call to XtVaSetValues. Mon Sep 20 10:54:32 1993 Alexandre Julliard * [windows/win.c] Quick patch to get colormaps to work with button widget. Mon Sep 20 02:42:54 1993 (yngvi@hafro.is) * misc/keyboard.c: Ifdefed out some bogus Ansi<->Oem conversion functions * misc/lstr.c: New file with string functions like lstr* IsChar* *Ansi* Wed Sep 15 20:35:10 1993 John Brezak * [loader/signal.c] Additional changes to support NetBSD. Wed Sep 15 22:19:22 1993 Martin Ayotte * [windows/graphics.c] Added FrameRect function Tue Sep 14 13:54:45 1993 Alexandre Julliard * [objects/color.c] [objects/palette.c] Preliminary support for private color map. * [windows/class.c] Implemented CS_CLASSDC style. * [windows/dce.c] Moved DCEs to USER heap. Implemented class and window DCs. * [windows/event.c] Implemented CS_DBLCLKS style. * [windows/graphics.c] Bug fix in SetPixel(). * [windows/win.c] Implemented CS_OWNDC style. Implemented Get/SetWindowLong(). * [controls/menu.c] [windows/class.c] [windows/clipping.c] [windows/dce.c] [windows/message.c] [windows/win.c] Moved windows from global heap to USER heap.
parent f41aeca9
This source diff could not be displayed because it is too large. You can view the blob instead.
Tue Sep 28 19:59:21 1993 David Metcalfe
* [windows/win.c]
Implemented support for windows with no borders. Added
GetParent(), GetDlgCtrlID(), GetWindowText() and
GetWindowTextLength() functions.
* [misc/xt.c]
Added processing of WM_GETTEXT and WM_GETTEXTLENGTH messages
to DefWindowProc and Implemented MessageBeep().
* [windows/syscolor.c]
Added preliminary system color support.
* [controls/button1.c]
Mods to new button control and integration with Wine.
Tue Sep 28 19:59:21 1993 Johannes Ruscheinski
* [controls/button1.c]
New button control using GDI functions.
Tue Sep 28 19:59:21 1993 Eric Youngdale
* [debugger/*]
Added debugging capabilities to Wine
Sat Sep 25 13:22:50 1993 Alexandre Julliard (julliard@di.epfl.ch)
* [objects/region.c]
Bug fix
Fri Sep 24 07:35:11 1993 Bob Amstadt (bob at pooh)
* [tools/build.c]
Changed the entry point code to reduce the standard entry
point size from 22 bytes to 10 bytes. This leaves about
4000 free entry points instead of the 800 in version 0.4.2.
* [loader/resource.c]
Rewrote functions to allow loading of resources from any
DLL.
* [loader/wine.c] [include/wine.h]
Added functions GetFilenameFromInstance() and GetFileInfo()
to search for a loaded file based on its instance handle.
Added a field in struct w_files to make searching by an instance
handle faster.
Tue Sep 21 09:57:01 1993 miguel@roxanne.nuclecu.unam.mx (Miguel de Icaza)
* [misc/profile.c]
Implementation of .INI file handling
Mon Sep 20 10:54:32 1993 David Metcalfe
* [misc/profile.c.old]
Implementation of .INI file handling
Mon Sep 20 10:54:32 1993 John Brezak
* [controls/WinButton.c]
Bug fix with call to XtVaSetValues.
Mon Sep 20 10:54:32 1993 Alexandre Julliard
* [windows/win.c]
Quick patch to get colormaps to work with button widget.
Mon Sep 20 02:42:54 1993 (yngvi@hafro.is)
* misc/keyboard.c:
Ifdefed out some bogus Ansi<->Oem conversion functions
* misc/lstr.c:
New file with string functions like lstr* IsChar* *Ansi*
Wed Sep 15 20:35:10 1993 John Brezak
* [loader/signal.c]
Additional changes to support NetBSD.
Wed Sep 15 22:19:22 1993 Martin Ayotte
* [windows/graphics.c]
Added FrameRect function
Tue Sep 14 13:54:45 1993 Alexandre Julliard
* [objects/color.c] [objects/palette.c]
Preliminary support for private color map.
* [windows/class.c]
Implemented CS_CLASSDC style.
* [windows/dce.c]
Moved DCEs to USER heap.
Implemented class and window DCs.
* [windows/event.c]
Implemented CS_DBLCLKS style.
* [windows/graphics.c]
Bug fix in SetPixel().
* [windows/win.c]
Implemented CS_OWNDC style.
Implemented Get/SetWindowLong().
* [controls/menu.c] [windows/class.c] [windows/clipping.c]
[windows/dce.c] [windows/message.c] [windows/win.c]
Moved windows from global heap to USER heap.
Mon Sep 13 05:00:11 1993 Eric Youngdale Mon Sep 13 05:00:11 1993 Eric Youngdale
* [Makefile] [if1632/relay.c] [include/dlls.h] [selector.c] * [Makefile] [if1632/relay.c] [include/dlls.h] [selector.c]
......
...@@ -3,14 +3,15 @@ ...@@ -3,14 +3,15 @@
DEBUGOPTS= DEBUGOPTS=
COPTS=-O2 -m486 COPTS=-O2 -m486
INCLUDE_DIR=include INCLUDE_DIR=include
LDFLAGS=
###################################################################### ######################################################################
# These definitions are for the top level # These definitions are for the top level
TARGET=wine TARGET=wine
LIBS=-L. -L/usr/X386/lib -lXext -lXaw -lXt -lXmu -lX11 -lm LIBS=-L. -L/usr/X386/lib -lXext -lXaw -lXt -lXmu -lX11 -lm
OBJS=if1632/if1632.o controls/controls.o loader/loader.o \ OBJS=if1632/if1632.o controls/controls.o loader/loader.o \
memory/memory.o misc/misc.o objects/objects.o windows/windows.o memory/memory.o misc/misc.o objects/objects.o windows/windows.o debugger/debugger.o
SUBDIRS=if1632 controls loader memory misc objects windows SUBDIRS=if1632 controls loader memory misc objects windows debugger
all: $(TARGET) all: $(TARGET)
......
...@@ -7,14 +7,13 @@ INSTALLATION: ...@@ -7,14 +7,13 @@ INSTALLATION:
Linux: Linux:
Uncompress and untar this archive into the directory of your Uncompress and untar this archive into the directory of your
choice. This release requires a Linux version 0.99 pl12 kernel with choice. This release requires a Linux version 0.99 pl13 kernel
ALPHA-pl13-diffs. or above.
NetBSD: NetBSD:
If you use BSD make rather than GNU make, you must apply the patches If you use BSD make rather than GNU make, you must apply the patches
in the file "bsdmake.patch". This release requires NetBSD 0.9 with in the file "bsdmake.patch". This release requires NetBSD-current.
additional patches.
All: All:
...@@ -28,6 +27,24 @@ Grab a copy of Windows sol.exe (Solitaire) and run it with the command: ...@@ -28,6 +27,24 @@ Grab a copy of Windows sol.exe (Solitaire) and run it with the command:
Have a nice game of solitaire, but be careful. Emulation isn't perfect. Have a nice game of solitaire, but be careful. Emulation isn't perfect.
So, occassionally it will crash. So, occassionally it will crash.
WHAT'S NEW with version 0.4.3: (see ChangeLog for details)
- Bug fixes
- Resource loading now able to load DLL resources
- Button control now based on GDI calls
- Preliminary system color support
- Miscellaneous window functions
- Limited debugging facility (sometimes hangs)
WHAT'S NEW with version 0.4.2: (see ChangeLog for details)
- Bug fixes
- 32-bit callback functions allowed
- .INI file handling
- lstr* functions and ANSI<->OEM conversion functions.
WHAT'S NEW with version 0.4.1: (see ChangeLog for details)
- Bug fixes
- Memory usage changes.
WHAT'S NEW with version 0.4.0: (see ChangeLog for details) WHAT'S NEW with version 0.4.0: (see ChangeLog for details)
- Wine now compiles and runs under NetBSD. Patches are - Wine now compiles and runs under NetBSD. Patches are
required for NetBSD. required for NetBSD.
......
Date: Sun, 26 Sep 93 03:18:19 EDT
From: eric@tantalus.nrl.navy.mil (Eric Youngdale)
Message-Id: <9309260718.AA13966@tantalus.nrl.navy.mil>
To: bob@amscons.amscons.com
Cc: linux-activists@Niksula.hut.fi
In-Reply-To: Bob Amstadt's message of Sat, 25 Sep 1993 23:36:32 +0300
<m0oggMt-000CrhC@amscons.amscons.com>
X-Mn-Key: WABI
>I may just be dreaming, but I'm beginning to like the idea of a built
>in debugger.
So do I. I like it so much that I wrote one. It turns out that the
disassembly code in gdb is pretty much localized to one source file, and this
was easy to splice into a simple program. In addition, there are 2 variables
that you set if you are disassembling 16 bit code, so it makes it all the
better.
Anyway, there is a parser that understands a limited set of gdb
commands (very limited, but the 'x' command is pretty functional as long as you
stick to numeric rather than symbolic addresses). The parser understands $pc
and $sp for your convenience, and you can do things like "x/10i $pc" and "info
regs" to see what is going on. In principle you can do "x/x", "x/s", "x/d",
"x/w", "x/b", "x/i" and "x/c". I implemented an "info stack" command that
simply dumps a number of bytes from the stack onto the screen, but it currently
makes no attempt to actually interpret the stack frames.
This will probably not work on non-linux systems, and I have no idea
how much work it will be to fix it. To start with we need some simple macros
to determine (based upon a segment selector) whether we are in a 16 bit or a 32
bit segment, but this should be pretty easy to fix. I shamelessly ripped off a
bunch of files from gdb, and I obviously picked the ones for linux. For other
systems you may need to make adjustments to these files somehow. It is too
late in the evening to worry about this now.
It will probably be easy to modify the parser to allow you to change
memory locations and/or register values and then continue execution. Also,
some of the hooks for using readline with the parser are in place, but it does
not work reliably for some reason, so I left it out for now. Adding gnu
readline really would bloat the package a lot. Instead I could use Rich Salz's
editlib (the canonical test case for the DLL tools), which has a command line
history feature that could be an acceptable substitute - this is much smaller
than gnu readline, but I am not sure what features are present.
-Eric
In this directory you might find my implemantation of the Windows
String. The patch lstr.patch includes whats needed for the following
functions:
lstrcat,lstrcmp,lstrcmpi,lstrcpy,lstrcpyn,lstrlen,AnsiUpper,AnsiLower,
IsCharAlpha,IsCharAlphanumeric,IsCharUpper,IsCharLower,AnsiUpperBuff,
AnsiLowerBuff,AnsiNext,AnsiPrev. Simply apply the patch to Wine.0.4.1
and remake.
Also there should be the files oem2ansi.trl and ansi2oem.trl that
define how to translate between ansi and oem codepage 861 I believe
they call it. These files where created by the Windows program
oemansi.exe which is also included. To get the oem<->ansi translations
right for your part of the world just run oemansi under Windows not
Wine and oemansi will create oem2ansi and ansi2oem for your locale
that is if your Windows/Dos is set up correctly. Move the .trl files
into the directory from where you run wine. If Wine does not find the
*.trl in the current directory AnsiToOem and OemToAnsi will be
passive.
Shortcomings/Bugs:
Some functions depend upon libc functions like toupper, tolower and
isalpha that, as far as I know, are totally without support for NLS
and ISO 8859-1. Default Ansi<->OEM translations when *.trl files are
not found are missing.
NOTE: Please don't run oemansi.exe under wine.
File added
*** ./windows/Makefile.orig Fri Sep 3 16:37:58 1993 diff -ruN ../Backup//Makefile ./Makefile
--- ./windows/Makefile Thu Sep 9 22:56:21 1993 --- ../Backup//Makefile Tue Sep 14 09:47:00 1993
*************** +++ ./Makefile Thu Sep 16 09:59:52 1993
*** 14,19 **** @@ -7,7 +7,7 @@
depend: ######################################################################
$(CC) $(CFLAGS) -M *.c > .depend # These definitions are for the top level
TARGET=wine
! ifeq (.depend,$(wildcard .depend)) -LIBS=-L. -L/usr/X386/lib -lXext -lXaw -lXt -lXmu -lX11 -lm
! include .depend +LIBS=-L. -L/usr/X386/lib -lXext -lXaw -lXt -lXmu -lX11 -lm -li386
! endif OBJS=if1632/if1632.o controls/controls.o loader/loader.o \
--- 14,19 ---- memory/memory.o misc/misc.o objects/objects.o windows/windows.o
depend: SUBDIRS=if1632 controls loader memory misc objects windows
$(CC) $(CFLAGS) -M *.c > .depend diff -ruN ../Backup//controls/Makefile ./controls/Makefile
--- ../Backup//controls/Makefile Sat Sep 11 22:13:44 1993
! .if exists(.depend) +++ ./controls/Makefile Thu Sep 16 10:00:24 1993
! .include ".depend" @@ -14,6 +14,7 @@
! .endif depend:
*** ./tools/Makefile.orig Tue Jul 20 18:40:18 1993 $(CC) $(CFLAGS) -M *.c > .depend
--- ./tools/Makefile Thu Sep 9 22:56:21 1993
*************** -ifeq (.depend,$(wildcard .depend))
*** 12,17 **** -include .depend
# -endif
# Dependency lists +.if exists(.depend)
# +.include ".depend"
! ifeq (.depend,$(wildcard .depend)) +.endif
! include .depend +
! endif diff -ruN ../Backup//if1632/Makefile ./if1632/Makefile
--- 12,21 ---- --- ../Backup//if1632/Makefile Tue Sep 14 08:56:17 1993
# +++ ./if1632/Makefile Thu Sep 16 10:00:24 1993
# Dependency lists @@ -45,9 +45,9 @@
# depend:
! .if exists(.depend) $(CC) $(CFLAGS) -M *.c > .depend
! .include ".depend"
! .endif -ifeq (.depend,$(wildcard .depend))
! -include .depend
! #ifeq (.depend,$(wildcard .depend)) -endif
! #include .depend +.if exists(.depend)
! #endif +.include ".depend"
*** ./objects/Makefile.orig Fri Sep 3 16:39:20 1993 +.endif
--- ./objects/Makefile Thu Sep 9 22:56:23 1993
***************
*** 14,19 ****
depend: diff -ruN ../Backup//loader/Makefile ./loader/Makefile
$(CC) $(CFLAGS) -M *.c > .depend --- ../Backup//loader/Makefile Sat Sep 11 21:42:05 1993
+++ ./loader/Makefile Thu Sep 16 10:00:24 1993
! ifeq (.depend,$(wildcard .depend)) @@ -13,6 +13,6 @@
! include .depend depend:
! endif $(CC) $(CFLAGS) -M *.c > .depend
--- 14,19 ----
depend: -ifeq (.depend,$(wildcard .depend))
$(CC) $(CFLAGS) -M *.c > .depend -include .depend
-endif
! .if exists(.depend) +.if exists(.depend)
! .include ".depend" +.include ".depend"
! .endif +.endif
*** ./misc/Makefile.orig Thu Sep 9 11:16:49 1993 diff -ruN ../Backup//memory/Makefile ./memory/Makefile
--- ./misc/Makefile Thu Sep 9 22:56:23 1993 --- ../Backup//memory/Makefile Sat Sep 11 21:42:05 1993
*************** +++ ./memory/Makefile Thu Sep 16 10:00:24 1993
*** 13,18 **** @@ -13,6 +13,6 @@
depend: depend:
$(CC) $(CFLAGS) -M *.c > .depend $(CC) $(CFLAGS) -M *.c > .depend
! ifeq (.depend,$(wildcard .depend)) -ifeq (.depend,$(wildcard .depend))
! include .depend -include .depend
! endif -endif
--- 13,18 ---- +.if exists(.depend)
depend: +.include ".depend"
$(CC) $(CFLAGS) -M *.c > .depend +.endif
diff -ruN ../Backup//misc/Makefile ./misc/Makefile
! .if exists(.depend) --- ../Backup//misc/Makefile Tue Sep 14 09:17:00 1993
! .include ".depend" +++ ./misc/Makefile Thu Sep 16 10:00:24 1993
! .endif @@ -14,6 +14,6 @@
*** ./memory/Makefile.orig Tue Jul 20 18:43:02 1993 depend:
--- ./memory/Makefile Thu Sep 9 22:56:34 1993 $(CC) $(CFLAGS) -M *.c > .depend
***************
*** 13,18 **** -ifeq (.depend,$(wildcard .depend))
depend: -include .depend
$(CC) $(CFLAGS) -M *.c > .depend -endif
+.if exists(.depend)
! ifeq (.depend,$(wildcard .depend)) +.include ".depend"
! include .depend +.endif
! endif diff -ruN ../Backup//objects/Makefile ./objects/Makefile
--- 13,18 ---- --- ../Backup//objects/Makefile Tue Sep 14 13:59:04 1993
depend: +++ ./objects/Makefile Thu Sep 16 10:00:24 1993
$(CC) $(CFLAGS) -M *.c > .depend @@ -14,6 +14,6 @@
depend:
! .if exists(.depend) $(CC) $(CFLAGS) -M *.c > .depend
! .include ".depend"
! .endif -ifeq (.depend,$(wildcard .depend))
*** ./loader/Makefile.orig Mon Aug 30 20:44:18 1993 -include .depend
--- ./loader/Makefile Thu Sep 9 22:56:36 1993 -endif
*************** +.if exists(.depend)
*** 13,18 **** +.include ".depend"
depend: +.endif
$(CC) $(CFLAGS) -M *.c > .depend diff -ruN ../Backup//tools/Makefile ./tools/Makefile
--- ../Backup//tools/Makefile Tue Sep 14 09:46:40 1993
! ifeq (.depend,$(wildcard .depend)) +++ ./tools/Makefile Thu Sep 16 10:00:24 1993
! include .depend @@ -14,6 +14,10 @@
! endif #
--- 13,18 ---- # Dependency lists
depend: #
$(CC) $(CFLAGS) -M *.c > .depend -ifeq (.depend,$(wildcard .depend))
-include .depend
! .if exists(.depend) -endif
! .include ".depend" +.if exists(.depend)
! .endif +.include ".depend"
*** ./if1632/Makefile.orig Thu Sep 9 11:15:58 1993 +.endif
--- ./if1632/Makefile Thu Sep 9 22:56:38 1993 +
*************** +#ifeq (.depend,$(wildcard .depend))
*** 42,50 **** +#include .depend
depend: +#endif
$(CC) $(CFLAGS) -M *.c > .depend diff -ruN ../Backup//windows/Makefile ./windows/Makefile
--- ../Backup//windows/Makefile Tue Sep 14 08:39:45 1993
! ifeq (.depend,$(wildcard .depend)) +++ ./windows/Makefile Thu Sep 16 10:00:24 1993
! include .depend @@ -14,6 +14,6 @@
! endif depend:
$(CC) $(CFLAGS) -M *.c > .depend
-ifeq (.depend,$(wildcard .depend))
--- 42,50 ---- -include .depend
depend: -endif
$(CC) $(CFLAGS) -M *.c > .depend +.if exists(.depend)
+.include ".depend"
! .if exists(.depend) +.endif
! .include ".depend"
! .endif
*** ./controls/Makefile.orig Mon Aug 30 19:40:39 1993
--- ./controls/Makefile Thu Sep 9 22:56:43 1993
***************
*** 14,19 ****
depend:
$(CC) $(CFLAGS) -M *.c > .depend
! ifeq (.depend,$(wildcard .depend))
! include .depend
! endif
--- 14,20 ----
depend:
$(CC) $(CFLAGS) -M *.c > .depend
! .if exists(.depend)
! .include ".depend"
! .endif
!
CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR) CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR)
OBJS=menu.o widgets.o button.o SmeMenuButto.o WinLabel.o WinCommand.o \ OBJS=menu.o widgets.o button.o SmeMenuButto.o WinLabel.o WinCommand.o \
WinMenuButto.o WinButton.o WinMenuButto.o
default: controls.o default: controls.o
......
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/*
* Modifications for Wine
*
* 8/28/93 David Metcalfe (david@prism.demon.co.uk)
* Created from Command widget and added 3D effect
*/
#ifndef _WinButton_h
#define _WinButton_h
#include "WinLabel.h"
/* WinButton widget resources:
Name Class RepType Default Value
---- ----- ------- -------------
accelerators Accelerators AcceleratorTable NULL
ancestorSensitive AncestorSensitive Boolean True
background Background Pixel XtDefaultBackground
backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
bitmap Pixmap Pixmap None
borderColor BorderColor Pixel XtDefaultForeground
borderPixmap Pixmap Pixmap XtUnspecifiedPixmap
borderWidth BorderWidth Dimension 1
callback Callback XtCallbackList NULL
colormap Colormap Colormap parent's colormap
cornerRoundPercent CornerRoundPercent Dimension 25
cursor Cursor Cursor None
cursorName Cursor String NULL
depth Depth int parent's depth
destroyCallback Callback XtCallbackList NULL
encoding Encoding UnsignedChar XawTextEncoding8bit
font Font XFontStruct* XtDefaultFont
foreground Foreground Pixel XtDefaultForeground
height Height Dimension text height
highlightThickness Thickness Dimension 0 if shaped, else 2
insensitiveBorder Insensitive Pixmap Gray
internalHeight Height Dimension 2
internalWidth Width Dimension 4
justify Justify XtJustify XtJustifyCenter
label Label String NULL
leftBitmap LeftBitmap Pixmap None
mappedWhenManaged MappedWhenManaged Boolean True
pointerColor Foreground Pixel XtDefaultForeground
pointerColorBackground Background Pixel XtDefaultBackground
resize Resize Boolean True
screen Screen Screen parent's Screen
sensitive Sensitive Boolean True
shadowHighlight ShadowHighlight Pixel White
shadowShade ShadowShade Pixel Grey25
shadowThickness ShadowThickness Dimension 2
shapeStyle ShapeStyle ShapeStyle Rectangle
translations Translations TranslationTable see doc or source
width Width Dimension text width
x Position Position 0
y Position Position 0
*/
#define XtNhighlightThickness "highlightThickness"
#define XtNshapeStyle "shapeStyle"
#define XtCShapeStyle "ShapeStyle"
#define XtRShapeStyle "ShapeStyle"
#define XtNcornerRoundPercent "cornerRoundPercent"
#define XtCCornerRoundPercent "CornerRoundPercent"
#define XtNshadowThickness "shadowThickness"
#define XtCShadowThickness "ShadowThickness"
#define XtNshadowHighlight "shadowHighlight"
#define XtCShadowHighlight "ShadowHighlight"
#define XtNshadowShade "shadowShade"
#define XtCShadowShade "ShadowShade"
#define XawShapeRectangle XmuShapeRectangle
#define XawShapeOval XmuShapeOval
#define XawShapeEllipse XmuShapeEllipse
#define XawShapeRoundedRectangle XmuShapeRoundedRectangle
extern WidgetClass winButtonWidgetClass;
typedef struct _WinButtonClassRec *WinButtonWidgetClass;
typedef struct _WinButtonRec *WinButtonWidget;
#endif /* _WinButton_h */
/* DON'T ADD STUFF AFTER THIS */
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/*
* Modifications for Wine
*
* 8/28/93 David Metcalfe (david@prism.demon.co.uk)
* Created from Command widget and added 3D effect
*/
/*
* WinButtonP.h - Private definitions for WinButton widget
*
*/
#ifndef _WinButtonP_h
#define _WinButtonP_h
#include "WinButton.h"
#include "WinLabelP.h"
/***********************************************************************
*
* WinButton Widget Private Data
*
***********************************************************************/
typedef enum {
HighlightNone, /* Do not highlight. */
HighlightWhenUnset, /* Highlight only when unset, this is
to preserve current command widget
functionality. */
HighlightAlways /* Always highlight, lets the toggle widget
and other subclasses do the right thing. */
} XtCommandHighlight;
/************************************
*
* Class structure
*
***********************************/
/* New fields for the WinButton widget class record */
typedef struct _WinButtonClass
{
int makes_compiler_happy; /* not used */
} WinButtonClassPart;
/* Full class record declaration */
typedef struct _WinButtonClassRec {
CoreClassPart core_class;
SimpleClassPart simple_class;
WinLabelClassPart winlabel_class;
WinButtonClassPart winbutton_class;
} WinButtonClassRec;
extern WinButtonClassRec winButtonClassRec;
/***************************************
*
* Instance (widget) structure
*
**************************************/
/* New fields for the WinButton widget record */
typedef struct {
/* resources */
Dimension highlight_thickness;
Dimension shadow_thickness;
Pixel shadow_shade;
Pixel shadow_highlight;
XtCallbackList callbacks;
/* private state */
Pixmap gray_pixmap;
GC normal_GC;
GC inverse_GC;
GC shadow_highlight_gc;
GC shadow_shade_gc;
Boolean set;
XtCommandHighlight highlighted;
/* more resources */
int shape_style;
Dimension corner_round;
} WinButtonPart;
/* XtEventsPtr eventTable;*/
/* Full widget declaration */
typedef struct _WinButtonRec {
CorePart core;
SimplePart simple;
WinLabelPart winlabel;
WinButtonPart winbutton;
} WinButtonRec;
#endif /* _WinButtonP_h */
...@@ -141,7 +141,7 @@ MENU_SelectionCallback(Widget w, XtPointer client_data, XtPointer call_data) ...@@ -141,7 +141,7 @@ MENU_SelectionCallback(Widget w, XtPointer client_data, XtPointer call_data)
menu = MENU_FindMenuBar(this_item); menu = MENU_FindMenuBar(this_item);
if (menu != NULL) if (menu != NULL)
{ {
wndPtr = (WND *) GlobalLock(menu->ownerWnd); wndPtr = WIN_FindWndPtr(menu->ownerWnd);
if (wndPtr == NULL) if (wndPtr == NULL)
return; return;
...@@ -152,8 +152,6 @@ MENU_SelectionCallback(Widget w, XtPointer client_data, XtPointer call_data) ...@@ -152,8 +152,6 @@ MENU_SelectionCallback(Widget w, XtPointer client_data, XtPointer call_data)
CallWindowProc(wndPtr->lpfnWndProc, menu->ownerWnd, WM_COMMAND, CallWindowProc(wndPtr->lpfnWndProc, menu->ownerWnd, WM_COMMAND,
this_item->item_id, 0); this_item->item_id, 0);
GlobalUnlock(menu->ownerWnd);
} }
} }
......
...@@ -10,8 +10,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; ...@@ -10,8 +10,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include "win.h" #include "win.h"
static LONG WIDGETS_ButtonWndProc( HWND hwnd, WORD message, LONG ButtonWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam );
WORD wParam, LONG lParam );
static LONG WIDGETS_StaticWndProc( HWND hwnd, WORD message, static LONG WIDGETS_StaticWndProc( HWND hwnd, WORD message,
WORD wParam, LONG lParam ); WORD wParam, LONG lParam );
...@@ -19,8 +18,8 @@ static LONG WIDGETS_StaticWndProc( HWND hwnd, WORD message, ...@@ -19,8 +18,8 @@ static LONG WIDGETS_StaticWndProc( HWND hwnd, WORD message,
static WNDCLASS WIDGETS_BuiltinClasses[NB_BUILTIN_CLASSES] = static WNDCLASS WIDGETS_BuiltinClasses[NB_BUILTIN_CLASSES] =
{ {
{ 0, WIDGETS_ButtonWndProc, 0, 0, 0, 0, 0, 0, NULL, "BUTTON" }, { 0, (LONG(*)())ButtonWndProc, 0, 0, 0, 0, 0, 0, NULL, "BUTTON" },
{ 0, WIDGETS_StaticWndProc, 0, 0, 0, 0, 0, 0, NULL, "STATIC" } { 0, (LONG(*)())WIDGETS_StaticWndProc, 0, 0, 0, 0, 0, 0, NULL, "STATIC" }
}; };
static FARPROC WndProc32[NB_BUILTIN_CLASSES]; static FARPROC WndProc32[NB_BUILTIN_CLASSES];
...@@ -38,8 +37,6 @@ BOOL WIDGETS_Init() ...@@ -38,8 +37,6 @@ BOOL WIDGETS_Init()
for (i = 0; i < NB_BUILTIN_CLASSES; i++, pClass++) for (i = 0; i < NB_BUILTIN_CLASSES; i++, pClass++)
{ {
WndProc32[i] = pClass->lpfnWndProc;
pClass->lpfnWndProc = (FARPROC) i+1;
if (!RegisterClass(pClass)) return FALSE; if (!RegisterClass(pClass)) return FALSE;
} }
return TRUE; return TRUE;
...@@ -61,39 +58,6 @@ LONG WIDGETS_Call32WndProc( FARPROC func, HWND hwnd, WORD message, ...@@ -61,39 +58,6 @@ LONG WIDGETS_Call32WndProc( FARPROC func, HWND hwnd, WORD message,
/*********************************************************************** /***********************************************************************
* WIDGETS_ButtonWndProc
*/
static LONG WIDGETS_ButtonWndProc( HWND hwnd, WORD message,
WORD wParam, LONG lParam )
{
switch(message)
{
case WM_CREATE:
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint( hwnd, &ps );
EndPaint( hwnd, &ps );
return 0;
}
case WM_COMMAND:
{
WND *wndParent;
wndParent = WIN_FindWndPtr(hwnd);
CallWindowProc(wndParent->lpfnWndProc, hwnd, message, wParam, lParam);
return 0;
}
default:
return DefWindowProc( hwnd, message, wParam, lParam );
}
}
/***********************************************************************
* WIDGETS_StaticWndProc * WIDGETS_StaticWndProc
*/ */
static LONG WIDGETS_StaticWndProc( HWND hwnd, WORD message, static LONG WIDGETS_StaticWndProc( HWND hwnd, WORD message,
......
CFLAGS=-g -I../include # -DUSE_READLINE
LIBS= readline/libedit.a
OBJS=dbg.tab.o hash.o lex.yy.o info.o i386-pinsn.o
debugger.o: ${OBJS} readline/libedit.a
(cd readline; make)
ld -r -o debugger.o ${OBJS} $(LIBS)
readline/libedit.a:
(cd readline; make)
dbg.tab.o: dbg.tab.c
gcc $(CFLAGS) -DYYDEBUG=1 -c dbg.tab.c
lex.yy.o: lex.yy.c
gcc $(CFLAGS) -I. -c lex.yy.c
lex.yy.c: debug.l
flex -I debug.l
dbg.tab.c dbg.tab.h: dbg.y
bison -v -d dbg.y
dtest: dtest.o debugger.o
gcc -o dtest dtest.o debugger.o
clean:
rm -f *.o main dbg.tab.* lex.yy.* *.output *~ *# dtest
(cd readline; make clean)
This is the core of the Wine debugger. Many pieces have been
shamelessly stolen - the reverse assember was stolen from gdb more or
less intact. It turns out that there are two variables that are set
differently if you are reverse assembling 16 bit code, and on the
whole it seems to work. There may be bugs for all I know.
As far as non-linux systems are concerned, I simply ripped off
the linux configuration files from gdb. Other systems may be close
enough for these to work properly, but some tweaking may be required.
I apologize for the non-portability of this, but I wrote the
whole thing in about 4 hours, most of the time spent debugging a
stupid mistake in the parser.
-Eric
This is a list of things that theoretically should be possible in some
way or another. No commitment to actually do these, but these sound
possible to me right now. In no particular order. If someone else
wants to dig in, feel free.
1) Some kind of crude display capability. Not too hard, I guess.
Just keep a list of addresses, counts and formats that we
want displayed each time we enter the debugger.
2) Some kind of single step capability.
I am not sure - I think you just set a flag
in AFLAGS, and you get an interrupt back again.
The signal type would proabably be different, however,
but Wine could easily be patched to accept this one as well.
The main problem with this is that gdb normally runs in a
separate process so it is easy to single step second process.
Here we are all part of the same process. Perhaps we could look
ahead to the end of the instruction and set another breakpoint?
3) Some kind of breakpoint capability.
Requires single step. When we restart, we
remove the breakpoint, single step one instruction
replace the breakpoint, and then continue.
4) Some kind of watchpoint capability. Pretty easy once we have a
single step capability, but we end up running the program
really slowly one instruction at a time.
5) Some kind of .wdbinit file.
/* ANSI and traditional C compatability macros
Copyright 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* ANSI and traditional C compatibility macros
ANSI C is assumed if __STDC__ is #defined.
Macro ANSI C definition Traditional C definition
----- ---- - ---------- ----------- - ----------
PTR `void *' `char *'
LONG_DOUBLE `long double' `double'
CONST `const' `'
VOLATILE `volatile' `'
SIGNED `signed' `'
PTRCONST `void *const' `char *'
DEFUN(name, arglist, args)
Defines function NAME.
ARGLIST lists the arguments, separated by commas and enclosed in
parentheses. ARGLIST becomes the argument list in traditional C.
ARGS list the arguments with their types. It becomes a prototype in
ANSI C, and the type declarations in traditional C. Arguments should
be separated with `AND'. For functions with a variable number of
arguments, the last thing listed should be `DOTS'.
DEFUN_VOID(name)
Defines a function NAME, which takes no arguments.
EXFUN(name, prototype)
Is used in an external function declaration.
In ANSI C it is `NAMEPROTOTYPE' (so PROTOTYPE should be enclosed in
parentheses). In traditional C it is `NAME()'.
For a function that takes no arguments, PROTOTYPE should be `(NOARGS)'.
For example:
extern int EXFUN(printf, (CONST char *format DOTS));
int DEFUN(fprintf, (stream, format),
FILE *stream AND CONST char *format DOTS) { ... }
void DEFUN_VOID(abort) { ... }
*/
#ifndef _ANSIDECL_H
#define _ANSIDECL_H 1
/* Every source file includes this file,
so they will all get the switch for lint. */
/* LINTLIBRARY */
#ifdef __STDC__
#define PTR void *
#define PTRCONST void *CONST
#define LONG_DOUBLE long double
#define AND ,
#define NOARGS void
#define CONST const
#define VOLATILE volatile
#define SIGNED signed
#define DOTS , ...
#define EXFUN(name, proto) name proto
#define DEFUN(name, arglist, args) name(args)
#define DEFUN_VOID(name) name(NOARGS)
#define PROTO(type, name, arglist) type name arglist
/* We could use the EXFUN macro to handle prototypes, but
the name is misleading and the result is ugly. So just define a
simple macro to handle the parameter lists, as in:
static int foo PARAMS ((int, char));
EXFUN would do it like this:
static int EXFUN (foo, (int, char));
but the function is not external... EXFUN should be considered
obsolete, and new code written to use PARAMS. */
#define PARAMS(paramlist) paramlist
#else /* Not ANSI C. */
#define PTR char *
#define PTRCONST PTR
#define LONG_DOUBLE double
#define AND ;
#define NOARGS
#define CONST
#define VOLATILE
#define SIGNED
#define DOTS
#define EXFUN(name, proto) name()
#define DEFUN(name, arglist, args) name arglist args;
#define DEFUN_VOID(name) name()
#define PROTO(type, name, arglist) type name ()
#define PARAMS(paramlist) ()
#endif /* ANSI C. */
#endif /* ansidecl.h */
This diff is collapsed. Click to expand it.
%{
/* Parser for command lines in the Wine debugger
*
* Version 1.0
* Eric Youngdale
* 9/93
*/
#include <stdio.h>
#define YYSTYPE int
#include "regpos.h"
extern FILE * yyin;
unsigned int * regval = NULL;
unsigned int dbg_mask = 0;
unsigned int dbg_mode = 0;
void issue_prompt();
%}
%token CONT
%token QUIT
%token HELP
%token INFO
%token STACK
%token REG
%token REGS
%token NUM
%token SET
%token PRINT
%token IDENTIFIER
%token NO_SYMBOL
%token SYMBOLFILE
%token DEFINE
%%
input: /* empty */
| input line { issue_prompt(); }
line: '\n'
| infocmd '\n'
| error '\n' {yyerrok; }
| QUIT '\n' { exit(0); };
| HELP '\n' { dbg_help(); };
| CONT '\n' { return; };
| SYMBOLFILE IDENTIFIER '\n' { read_symboltable($2); };
| DEFINE IDENTIFIER expr '\n' { add_hash($2, $3); };
| x_command
| print_command
| deposit_command
deposit_command:
SET REG '=' expr '\n' { regval[$2] = $4; }
| SET '*' expr '=' expr '\n' { *((unsigned int *) $3) = $5; }
| SET symbol '=' expr '\n' { *((unsigned int *) $2) = $4; }
x_command:
'x' expr '\n' { examine_memory($2, 1, 'x'); };
| 'x' '/' fmt expr '\n' { examine_memory($4, 1, $3); };
| 'x' '/' NUM fmt expr '\n' { examine_memory($5, $3, $4); };
print_command:
PRINT expr '\n' { examine_memory(((unsigned int) &$2 ), 1, 'x'); };
fmt: 'x' { $$ = 'x'; }
| 'd' { $$ = 'd'; }
| 'i' { $$ = 'i'; }
| 'w' { $$ = 'w'; }
| 's' { $$ = 's'; }
| 'c' { $$ = 'c'; }
| 'b' { $$ = 'b'; }
symbol: IDENTIFIER { $$ = find_hash($1);
if($$ == 0xffffffff) {
fprintf(stderr,"Symbol %s not found\n", $1);
YYERROR;
};
};
expr: NUM { $$ = $1; }
| REG { $$ = regval[$1]; }
| symbol { $$ = *((unsigned int *) $1); }
| expr '+' NUM { $$ = $1 + $3; }
| expr '-' NUM { $$ = $1 - $3; };
| '(' expr ')' { $$ = $2; };
| '*' expr { $$ = *((unsigned int *) $2); };
infocmd: INFO REGS { info_reg(); }
| INFO STACK { info_stack(); };
%%
void
issue_prompt(){
#ifndef USE_READLINE
fprintf(stderr,"Wine-dbg>");
#endif
}
static int loaded_symbols = 0;
void
wine_debug(int * regs)
{
int i;
#ifdef YYDEBUG
yydebug = 0;
#endif
yyin = stdin;
regval = regs;
/* This only works for linux - NetBSD will need something different here. */
if((SC_CS & 7) != 7) {
dbg_mask = 0xffffffff;
dbg_mode = 32;
} else {
dbg_mask = 0xffff;
dbg_mode = 16;
};
/* This is intended to read the entry points from the Windows image, and
insert them in the hash table. It does not work yet, so it is commented out. */
#if 0
if(!loaded_symbols){
loaded_symbols++;
load_entrypoints();
};
#endif
/* Show where we crashed */
examine_memory(SC_EIP(dbg_mask), 1, 'i');
issue_prompt();
yyparse();
flush_symbols();
fprintf(stderr,"Returning to Wine...\n");
}
yyerror(char * s){
fprintf(stderr,"%s\n", s);
}
/* Lexical scanner for command line parsing in the Wine debugger
*
* Version 1.0
* Eric Youngdale
* 9/93
*/
%{
#include <stdio.h>
#include <string.h>
#include "dbg.tab.h"
#include "regpos.h"
#ifdef USE_READLINE
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
if ( (result = dbg_read((char *) buf, max_size )) < 0 ) \
YY_FATAL_ERROR( "read() in flex scanner failed" );
#endif
extern char * readline(char *);
static char * make_symbol(char *);
void flush_symbols();
static int syntax_error;
%}
DIGIT [0-9]
HEXDIGIT [0-9a-fA-F]
IDENTIFIER [_a-zA-Z\.~][_a-zA-Z0-9\.~]*
%%
\n { syntax_error = 0; return '\n'; } /* Indicate end of command */
"+" { return '+'; }
"-" { return '-'; }
"/" { return '/'; }
"=" { return '='; }
"(" { return '('; }
")" { return ')'; }
"*" { return '*'; }
"?" { return HELP; }
"0x"+{HEXDIGIT}+ {
sscanf(yytext, "%lx", &yylval);
return NUM;
}
{DIGIT}+ {
sscanf(yytext, "%lx", &yylval);
return NUM;
}
$pc { yylval = RN_EIP; return REG;}
$sp { yylval = RN_ESP; return REG;}
$eip { yylval = RN_EIP; return REG;}
$esp { yylval = RN_ESP; return REG;}
$ebp { yylval = RN_EBP; return REG;}
$eax { yylval = RN_EAX; return REG;}
$ebx { yylval = RN_EBX; return REG;}
$ecx { yylval = RN_ECX; return REG;}
$edx { yylval = RN_EDX; return REG;}
$esi { yylval = RN_ESI; return REG;}
$edi { yylval = RN_EDI; return REG;}
info|inf|in { return INFO; }
quit|qui|qu { return QUIT; }
help|hel|he { return HELP; }
set|se { return SET; }
cont|con|co { return CONT; }
symbolfile|symbolfil|symbolfi|symbolf|symbol|symbo|symb { return SYMBOLFILE; }
define|defin|defi|def|de { return DEFINE; }
print|prin|pri|pr { return PRINT; }
regs|reg|re { return REGS; }
stack|stac|sta|st { return STACK; }
x { return 'x'; }
d { return 'd'; }
i { return 'i'; }
w { return 'w'; }
b { return 'b'; }
s { return 's'; }
c { return 'c'; }
{IDENTIFIER} {yylval = (int) make_symbol(yytext);
return IDENTIFIER;
}
[ \t]+ /* Eat up whitespace */
. { if(syntax_error == 0) {
syntax_error ++; fprintf(stderr, "Syntax Error\n"); }
}
%%
#ifdef USE_READLINE
#ifndef whitespace
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
#endif
#if 0
/* Used only with GNU readline */
#include "readline/readline.h"
#include "readline/chardefs.h"
#endif
dbg_read(char * buf, int size){
char * line;
int len;
do{
flush_symbols();
line = readline ("Wine-dbg>");
len = strlen(line);
if (!line)
{
return 0;
}
else
{
/* Remove leading and trailing whitespace from the line.
Then, if there is anything left, add it to the history list
and execute it. */
stripwhite (line);
if (*line)
{
add_history (line);
if(size < len + 1){
fprintf(stderr,"Fatal readline goof.\n");
exit(0);
};
strcpy(buf, line);
buf[len] = '\n';
buf[len+1] = 0;
free(line);
return len + 1;
}
}
} while (1==1);
}
/* Strip whitespace from the start and end of STRING. */
stripwhite (string)
char *string;
{
register int i = 0;
while (whitespace (string[i]))
i++;
if (i)
strcpy (string, string + i);
i = strlen (string) - 1;
while (i > 0 && whitespace (string[i]))
i--;
string[++i] = '\0';
}
static char *local_symbols[10];
static int next_symbol;
char * make_symbol(char * symbol){
return local_symbols[next_symbol++] = strdup(symbol);
}
void
flush_symbols(){
while(--next_symbol>= 0) free(local_symbols[next_symbol]);
next_symbol = 0;
}
#endif
This diff is collapsed. Click to expand it.
#include <signal.h>
#include <stdio.h>
extern void wine_debug(unsigned int*);
#ifdef linux
#include <linux/sched.h>
#include <asm/system.h>
#endif
struct sigaction segv_act;
#ifdef linux
struct sigcontext_struct {
unsigned short sc_gs, __gsh;
unsigned short sc_fs, __fsh;
unsigned short sc_es, __esh;
unsigned short sc_ds, __dsh;
unsigned long sc_edi;
unsigned long sc_esi;
unsigned long sc_ebp;
unsigned long sc_esp;
unsigned long sc_ebx;
unsigned long sc_edx;
unsigned long sc_ecx;
unsigned long sc_eax;
unsigned long sc_trapno;
unsigned long sc_err;
unsigned long sc_eip;
unsigned short sc_cs, __csh;
unsigned long sc_eflags;
unsigned long esp_at_signal;
unsigned short sc_ss, __ssh;
unsigned long i387;
unsigned long oldmask;
unsigned long cr2;
};
#endif
#ifdef linux
static void win_fault(int signal, struct sigcontext_struct context){
struct sigcontext_struct *scp = &context;
#else
static void win_fault(int signal, int code, struct sigcontext *scp){
#endif
wine_debug((unsigned int *) scp); /* Enter our debugger */
}
char realtext[] = "This is what should really be printed\n";
int
main(){
char * pnt;
#ifdef linux
segv_act.sa_handler = (__sighandler_t) win_fault;
/* Point to the top of the stack, minus 4 just in case, and make
it aligned */
sigaction(SIGSEGV, &segv_act, NULL);
#endif
#ifdef __NetBSD__
struct sigstack ss;
sigset_t sig_mask;
ss.ss_sp = (char *) (((unsigned int)(cstack + sizeof(cstack) - 4)) & ~3);
ss.ss_onstack = 0;
if (sigstack(&ss, NULL) < 0) {
perror("sigstack");
exit(1);
}
sigemptyset(&sig_mask);
segv_act.sa_handler = (__sighandler_t) win_fault;
segv_act.sa_flags = SA_ONSTACK;
segv_act.sa_mask = sig_mask;
if (sigaction(SIGBUS, &segv_act, NULL) < 0) {
perror("sigaction");
exit(1);
}
#endif
fprintf(stderr,"%x\n", realtext);
/* Now force a segmentation fault */
pnt = (char *) 0xc0000000;
fprintf(stderr,"%s", pnt);
return 0;
}
unsigned int * wine_files = NULL;
GetEntryPointFromOrdinal(int wpnt, int ordinal) {}
/* Macros for the 'type' part of an fopen, freopen or fdopen.
<Read|Write>[Update]<Binary file|text file>
This version is for "same" systems, where text and binary files are
the same. An example is Unix. Many Unix systems could also add a
"b" to the string, indicating binary files, but some reject this
(and thereby don't conform to ANSI C, but what else is new?).
This file is designed for inclusion by host-dependent .h files. No
user application should include it directly, since that would make
the application unable to be configured for both "same" and "binary"
variant systems. */
#define FOPEN_RB "r"
#define FOPEN_WB "w"
#define FOPEN_AB "a"
#define FOPEN_RUB "r+"
#define FOPEN_WUB "w+"
#define FOPEN_AUB "a+"
#define FOPEN_RT "r"
#define FOPEN_WT "w"
#define FOPEN_AT "a"
#define FOPEN_RUT "r+"
#define FOPEN_WUT "w+"
#define FOPEN_AUT "a+"
/* Machine independent variables that describe the core file under GDB.
Copyright 1986, 1987, 1989, 1990, 1992 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Interface routines for core, executable, etc. */
#if !defined (GDBCORE_H)
#define GDBCORE_H 1
#include "bfd.h" /* Binary File Description */
/* Return the name of the executable file as a string.
ERR nonzero means get error if there is none specified;
otherwise return 0 in that case. */
extern char *
get_exec_file PARAMS ((int err));
/* Nonzero if there is a core file. */
extern int
have_core_file_p PARAMS ((void));
/* Read "memory data" from whatever target or inferior we have.
Returns zero if successful, errno value if not. EIO is used
for address out of bounds. If breakpoints are inserted, returns
shadow contents, not the breakpoints themselves. From breakpoint.c. */
extern int
read_memory_nobpt PARAMS ((CORE_ADDR memaddr, char *myaddr, unsigned len));
/* Report a memory error with error(). */
extern void
memory_error PARAMS ((int status, CORE_ADDR memaddr));
/* Like target_read_memory, but report an error if can't read. */
extern void
read_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
/* Read an integer from debugged memory, given address and number of bytes. */
extern long
read_memory_integer PARAMS ((CORE_ADDR memaddr, int len));
/* If this is prototyped, need to deal with void* vs. char*. */
extern void
write_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
/* Hook for `exec_file_command' command to call. */
extern void (*exec_file_display_hook) PARAMS ((char *filename));
extern void
specify_exec_file_hook PARAMS ((void (*hook) (char *filename)));
/* Binary File Diddlers for the exec and core files */
extern bfd *core_bfd;
extern bfd *exec_bfd;
/* Whether to open exec and core files read-only or read-write. */
extern int write_files;
extern void
core_file_command PARAMS ((char *filename, int from_tty));
extern void
exec_file_command PARAMS ((char *filename, int from_tty));
extern void
validate_files PARAMS ((void));
extern unsigned int
register_addr PARAMS ((int regno, int blockend));
extern int
xfer_core_file PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
extern void
fetch_core_registers PARAMS ((char *core_reg_sect, unsigned core_reg_size,
int which, unsigned int reg_addr));
extern void
registers_fetched PARAMS ((void));
#if !defined (KERNEL_U_ADDR)
extern CORE_ADDR kernel_u_addr;
#define KERNEL_U_ADDR kernel_u_addr
#endif
/* The target vector for core files */
extern struct target_ops core_ops;
/* target vector functions called directly from elsewhere */
void
core_open PARAMS ((char *, int));
void
core_detach PARAMS ((char *, int));
#endif /* !defined (GDBCORE_H) */
/*
* File hash.c - generate hash tables for Wine debugger symbols
*
* Copyright (C) 1993, Eric Youngdale.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <neexe.h>
#include <segmem.h>
#include <prototypes.h>
#include <wine.h>
struct name_hash{
struct name_hash * next;
unsigned int * address;
char * name;
};
#define NR_NAME_HASH 128
static struct name_hash * name_hash_table[NR_NAME_HASH] = {0,};
static unsigned int name_hash(const char * name){
unsigned int hash = 0;
const char * p;
p = name;
while (*p) hash = (hash << 15) + (hash << 3) + (hash >> 3) + *p++;
return hash % NR_NAME_HASH;
}
void add_hash(char * name, unsigned int * address){
struct name_hash * new;
int hash;
new = (struct name_hash *) malloc(sizeof(struct name_hash));
new->address = address;
new->name = strdup(name);
new->next = NULL;
hash = name_hash(name);
/* Now insert into the hash table */
new->next = name_hash_table[hash];
name_hash_table[hash] = new;
}
unsigned int * find_hash(char * name){
char buffer[256];
struct name_hash * nh;
for(nh = name_hash_table[name_hash(name)]; nh; nh = nh->next)
if(strcmp(nh->name, name) == 0) return nh->address;
if(name[0] != '_'){
buffer[0] = '_';
strcpy(buffer+1, name);
for(nh = name_hash_table[name_hash(buffer)]; nh; nh = nh->next)
if(strcmp(nh->name, buffer) == 0) return nh->address;
};
return (unsigned int *) 0xffffffff;
}
static char name_buffer[256];
char * find_nearest_symbol(unsigned int * address){
struct name_hash * nearest;
struct name_hash start;
struct name_hash * nh;
int i;
nearest = &start;
start.address = (unsigned int *) 0;
for(i=0; i<NR_NAME_HASH; i++) {
for(nh = name_hash_table[i]; nh; nh = nh->next)
if(nh->address <= address && nh->address > nearest->address)
nearest = nh;
};
if((unsigned int) nearest->address == 0) return NULL;
sprintf(name_buffer, "%s+0x%x", nearest->name, ((unsigned int) address) -
((unsigned int) nearest->address));
return name_buffer;
}
void
read_symboltable(char * filename){
FILE * symbolfile;
unsigned int addr;
int nargs;
char type;
char * cpnt;
char buffer[256];
char name[256];
symbolfile = fopen(filename, "r");
if(!symbolfile) {
fprintf(stderr,"Unable to open symbol table %s\n", filename);
return;
};
fprintf(stderr,"Reading symbols from file %s\n", filename);
while (1)
{
fgets(buffer, sizeof(buffer), symbolfile);
if (feof(symbolfile)) break;
/* Strip any text after a # sign (i.e. comments) */
cpnt = buffer;
while(*cpnt){
if(*cpnt == '#') {*cpnt = 0; break; };
cpnt++;
};
/* Quietly ignore any lines that have just whitespace */
cpnt = buffer;
while(*cpnt){
if(*cpnt != ' ' && *cpnt != '\t') break;
cpnt++;
};
if (!(*cpnt) || *cpnt == '\n') {
continue;
};
nargs = sscanf(buffer, "%x %c %s", &addr, &type, name);
add_hash(name, (unsigned int *) addr);
};
fclose(symbolfile);
}
/* Load the entry points from the dynamic linking into the hash tables.
* This does not work yet - something needs to be added before it scans the
* tables correctly
*/
void
load_entrypoints(){
char buffer[256];
char * cpnt;
int j, ordinal, len;
unsigned int address;
struct w_files * wpnt;
for(wpnt = wine_files; wpnt; wpnt = wpnt->next){
cpnt = wpnt->nrname_table;
while(1==1){
if( ((int) cpnt) - ((int)wpnt->nrname_table) >
wpnt->ne_header->nrname_tab_length) break;
len = *cpnt++;
strncpy(buffer, cpnt, len);
buffer[len] = 0;
ordinal = *((unsigned short *) (cpnt + len));
j = GetEntryPointFromOrdinal(wpnt, ordinal);
address = j & 0xffff;
j = j >> 16;
address |= (wpnt->selector_table[j].selector) << 16;
fprintf(stderr,"%s -> %x\n", buffer, address);
add_hash(buffer, (unsigned int *) address);
cpnt += len + 2;
};
};
return;
}
/*
* Wine debugger utility routines
* Eric Youngdale
* 9/93
*/
#include <stdio.h>
#include "regpos.h"
extern int * regval;
extern unsigned int dbg_mask;
extern unsigned int dbg_mode;
extern int print_insn(char * memaddr, char * realaddr, FILE * stream, int addrlen);
/* THese three helper functions eliminate the need for patching the
module from gdb for disassembly of code */
void read_memory(char * memaddr, char * buffer, int len){
memcpy(buffer, memaddr, len);
}
void fputs_filtered(char * buffer, FILE * outfile){
fputs(buffer, outfile);
}
void print_address(unsigned int addr, FILE * outfile){
char * name;
name = find_nearest_symbol(addr);
if(name)
fprintf(outfile,"0x%8.8x(%s)", addr, name);
else
fprintf(outfile,"0x%8.8x", addr);
}
void info_reg(){
fprintf(stderr,"Register dump:\n");
/* First get the segment registers out of the way */
fprintf(stderr," CS:%4.4x SS:%4.4x DS:%4.4x ES:%4.4x GS:%4.4x FS:%4.4x\n",
SC_CS, SC_SS, SC_DS, SC_ES, SC_GS, SC_FS);
/* Now dump the main registers */
fprintf(stderr," EIP:%8.8x ESP:%8.8x EBP:%8.8x EFLAGS:%8.8x\n",
SC_EIP(dbg_mask), SC_ESP(dbg_mask), SC_EBP(dbg_mask), SC_EFLAGS);
/* And dump the regular registers */
fprintf(stderr," EAX:%8.8x EBX:%8.8x ECX:%8.8x EDX:%8.8x\n",
SC_EAX(dbg_mask), SC_EBX(dbg_mask), SC_ECX(dbg_mask), SC_EDX(dbg_mask));
/* Finally dump these main registers */
fprintf(stderr," EDI:%8.8x ESI:%8.8x\n",
SC_EDI(dbg_mask), SC_ESI(dbg_mask));
}
void info_stack(){
unsigned int * dump;
int i;
fprintf(stderr,"Stack dump:\n");
dump = (int*) SC_EIP(dbg_mask);
for(i=0; i<22; i++)
{
fprintf(stderr," %8.8x", *dump++);
if ((i % 8) == 7)
fprintf(stderr,"\n");
}
fprintf(stderr,"\n");
}
void examine_memory(int addr, int count, char format){
char * pnt;
unsigned int * dump;
unsigned short int * wdump;
int i;
if((addr & 0xffff0000) == 0 && dbg_mode == 16)
addr |= (format == 'i' ? SC_CS : SC_DS) << 16;
if(format != 'i' && count > 1) {
print_address(addr, stderr);
fprintf(stderr,": ");
};
switch(format){
case 's':
pnt = (char *) addr;
if (count == 1) count = 256;
while(*pnt && count) {
fputc( *pnt++, stderr);
count--;
};
fprintf(stderr,"\n");
return;
case 'i':
for(i=0; i<count; i++) {
print_address(addr, stderr);
fprintf(stderr,": ");
addr += print_insn((char *) addr, (char *) addr, stderr, dbg_mode);
fprintf(stderr,"\n");
};
return;
case 'x':
dump = (unsigned int *) addr;
for(i=0; i<count; i++)
{
fprintf(stderr," %8.8x", *dump++);
if ((i % 8) == 7) {
fprintf(stderr,"\n");
print_address((unsigned int) dump, stderr);
fprintf(stderr,": ");
};
}
fprintf(stderr,"\n");
return;
case 'd':
dump = (unsigned int *) addr;
for(i=0; i<count; i++)
{
fprintf(stderr," %d", *dump++);
if ((i % 8) == 7) {
fprintf(stderr,"\n");
print_address((unsigned int) dump, stderr);
fprintf(stderr,": ");
};
}
fprintf(stderr,"\n");
return;
case 'w':
wdump = (unsigned short int *) addr;
for(i=0; i<count; i++)
{
fprintf(stderr," %d", *wdump++);
if ((i % 10) == 7) {
fprintf(stderr,"\n");
print_address((unsigned int) dump, stderr);
fprintf(stderr,": ");
};
}
fprintf(stderr,"\n");
return;
case 'c':
pnt = (char *) addr;
for(i=0; i<count; i++)
{
if(*pnt < 0x20) {
fprintf(stderr," ");
pnt++;
} else
fprintf(stderr," %c", *pnt++);
if ((i % 32) == 7) {
fprintf(stderr,"\n");
print_address((unsigned int) dump, stderr);
fprintf(stderr,": ");
};
}
fprintf(stderr,"\n");
return;
case 'b':
pnt = (char *) addr;
for(i=0; i<count; i++)
{
fprintf(stderr," %d", *pnt++);
if ((i % 32) == 7) {
fprintf(stderr,"\n");
print_address((unsigned int) dump, stderr);
fprintf(stderr,": ");
};
}
fprintf(stderr,"\n");
return;
};
/* The rest are fairly straightforward */
fprintf(stderr,"examine mem: %x %d %c\n", addr, count, format);
}
char * helptext[] = {
"The commands accepted by the Wine debugger are a small subset",
"of the commands that gdb would accept. The commands currently",
"are:\n",
" info reg",
" info stack",
" help",
" quit",
" print <expr>",
" symbolfile <filename>",
" define <identifier> <expr>",
" x <expr>",
" cont",
" set <reg> = <expr>",
" set *<expr> = <expr>",
"",
"The 'x' command accepts repeat counts and formats (including 'i') in the",
"same way that gdb does.",
"",
" The following are examples of legal expressions:",
" $eax $eax+0x3 0x1000 ($eip + 256) *$eax *($esp + 3)",
" Also, a nm format symbol table can be read from a file using the",
" symbolfile command. Symbols can also be defined individually with",
" the define command.",
"",
"The disassembly code seems to work most of the time, but it does get",
"a little confused at times. The 16 bit mode probably has not been used",
"much so there are probably bugs. I snagged the file from the gdb-4.7",
"source tree, which is what was on my latest cdrom. I should check to see",
"if newer versions of gdb have anything substanitally different for the",
"disassembler.",
"",
NULL};
void dbg_help(){
int i;
i = 0;
while(helptext[i]) fprintf(stderr,"%s\n", helptext[i++]);
}
## $Revision: 1.2 $
##
## OS-9 makefile for editline library.
##
.SUFFIXES:
RFILES = editline.r complete.r sysos9.r
%.r: %.c
cc68 -r -Dstrchr=index -Dstrrchr=rindex -DNEED_STRDUP -DSYS_OS9 $*.c
testit: testit.r editline.lib
cc68 -f=testit testit.r -l=editline.lib
$(RFILES): $(RFILES:%.r=%.c)
editline.lib: $(RFILES)
cat $(RFILES) >$@
## $Revision: 1.3 $
##
## Unix makefile for editline library.
##
## Set your options:
## -DANSI_ARROWS ANSI arrows keys work like emacs.
## -DHAVE_STDLIB Have <stdlib.h>.
## -DHAVE_TCGETATTR Have tcgetattr(), tcsetattr().
## -DHIDE Make static functions static (non debug).
## -DHIST_SIZE=n History size.
## -DNEED_STRDUP Don't have strdup().
## -DUNIQUE_HISTORY Don't save command if same as last one.
## -DUSE_DIRENT Use <dirent.h>, not <sys/dir.h>?
## -DUSE_TERMCAP Use the termcap library for terminal size
## see LDFLAGS, below, if you set this.
## -DNEED_PERROR Don't have perror() (used in testit)
DEFS = -DANSI_ARROWS -DHAVE_TCGETATTR -DHIDE -DUSE_DIRENT -DSYS_UNIX
## Set your C compiler:
WARN = -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings \
-Wunused -Wcomment -Wswitch
CC = gcc -ansi $(WARN)
#CC = cc
CFLAGS = $(DEFS) -O -g
## If you have -DUSE_TERMCAP, set this as appropriate:
#LDFLAGS = -ltermlib
#LDFLAGS = -ltermcap
## Set ranlib as appropriate:
RANLIB = ranlib
#RANLIB = echo
## End of configuration.
SOURCES = editline.c complete.c sysunix.c
OBJECTS = editline.o complete.o sysunix.o
SHARFILES = README Makefile editline.3 editline.h unix.h editline.c \
complete.c sysunix.c testit.c \
Make.os9 os9.h sysos9.c
all: libedit.a
testit: testit.c libedit.a
$(CC) $(CFLAGS) -o testit testit.c libedit.a $(LDFLAGS)
shar: $(SHARFILES)
shar $(SHARFILES) >shar
clean:
rm -f *.[oa] testit foo core tags lint lint.all a.out shar
lint: testit
lint -a -b -u -x $(DEFS) $(SOURCES) testit.c >lint.all
sed -e '/warning: function prototype not in scope/d' \
-e '/warning: old style argument declaration/'d \
-e '/mix of old and new style function declaration/'d \
<lint.all >lint
libedit.a: $(OBJECTS)
@rm -f $@
ar r $@ $(OBJECTS)
$(RANLIB) $@
$(OBJECTS): editline.h
$Revision: 1.5 $
This is a line-editing library. It can be linked into almost any
program to provide command-line editing and recall.
It is call-compatible with the FSF readline library, but it is a
fraction of the size (and offers fewer features). It does not use
standard I/O. It is distributed under a "C News-like" copyright.
Configuration is done in the Makefile. Type "make testit" to get
a small slow shell for testing.
An earlier version was distributed with Byron's rc. Principal
changes over that version include:
Faster.
Is eight-bit clean (thanks to brendan@cs.widener.edu)
Written in K&R C, but ANSI compliant (gcc all warnings)
Propagates EOF properly; rc trip test now passes
Doesn't need or use or provide memmove.
More robust
Calling sequence changed to be compatible with readline.
Test program, new manpage, better configuration
More system-independant; includes Unix and OS-9 support.
Enjoy,
Rich $alz
<rsalz@osf.org>
Copyright 1992 Simmule Turner and Rich Salz. All rights reserved.
This software is not subject to any license of the American Telephone
and Telegraph Company or of the Regents of the University of California.
Permission is granted to anyone to use this software for any purpose on
any computer system, and to alter it and redistribute it freely, subject
to the following restrictions:
1. The authors are not responsible for the consequences of use of this
software, no matter how awful, even if they arise from flaws in it.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission. Since few users ever read sources,
credits must appear in the documentation.
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software. Since few users
ever read sources, credits must appear in the documentation.
4. This notice may not be removed or altered.
/* $Revision: 1.3 $
**
** History and file completion functions for editline library.
*/
#include "editline.h"
#if defined(NEED_STRDUP)
/*
** Return an allocated copy of a string.
*/
char *
strdup(p)
char *p;
{
char *new;
if ((new = NEW(char, strlen(p) + 1)) != NULL)
(void)strcpy(new, p);
return new;
}
#endif /* defined(NEED_STRDUP) */
/*
** strcmp-like sorting predicate for qsort.
*/
STATIC int
compare(p1, p2)
CONST void *p1;
CONST void *p2;
{
CONST char **v1;
CONST char **v2;
v1 = (CONST char **)p1;
v2 = (CONST char **)p2;
return strcmp(*v1, *v2);
}
/*
** Fill in *avp with an array of names that match file, up to its length.
** Ignore . and .. .
*/
STATIC int
FindMatches(dir, file, avp)
char *dir;
char *file;
char ***avp;
{
char **av;
char **new;
char *p;
DIR *dp;
DIRENTRY *ep;
SIZE_T ac;
SIZE_T len;
if ((dp = opendir(dir)) == NULL)
return 0;
av = NULL;
ac = 0;
len = strlen(file);
while ((ep = readdir(dp)) != NULL) {
p = ep->d_name;
if (p[0] == '.' && (p[1] == '\0' || (p[1] == '.' && p[2] == '\0')))
continue;
if (len && strncmp(p, file, len) != 0)
continue;
if ((ac % MEM_INC) == 0) {
if ((new = NEW(char*, ac + MEM_INC)) == NULL)
break;
if (ac) {
COPYFROMTO(new, av, ac * sizeof (char **));
DISPOSE(av);
}
*avp = av = new;
}
if ((av[ac] = strdup(p)) == NULL) {
if (ac == 0)
DISPOSE(av);
break;
}
ac++;
}
/* Clean up and return. */
(void)closedir(dp);
if (ac)
qsort(av, ac, sizeof (char **), compare);
return ac;
}
/*
** Split a pathname into allocated directory and trailing filename parts.
*/
STATIC int
SplitPath(path, dirpart, filepart)
char *path;
char **dirpart;
char **filepart;
{
static char DOT[] = ".";
char *dpart;
char *fpart;
if ((fpart = strrchr(path, '/')) == NULL) {
if ((dpart = strdup(DOT)) == NULL)
return -1;
if ((fpart = strdup(path)) == NULL) {
DISPOSE(dpart);
return -1;
}
}
else {
if ((dpart = strdup(path)) == NULL)
return -1;
dpart[fpart - path] = '\0';
if ((fpart = strdup(++fpart)) == NULL) {
DISPOSE(dpart);
return -1;
}
}
*dirpart = dpart;
*filepart = fpart;
return 0;
}
/*
** Attempt to complete the pathname, returning an allocated copy.
** Fill in *unique if we completed it, or set it to 0 if ambiguous.
*/
char *
rl_complete(pathname, unique)
char *pathname;
int *unique;
{
char **av;
char *dir;
char *file;
char *new;
char *p;
SIZE_T ac;
SIZE_T end;
SIZE_T i;
SIZE_T j;
SIZE_T len;
if (SplitPath(pathname, &dir, &file) < 0)
return NULL;
if ((ac = FindMatches(dir, file, &av)) == 0) {
DISPOSE(dir);
DISPOSE(file);
return NULL;
}
p = NULL;
len = strlen(file);
if (ac == 1) {
/* Exactly one match -- finish it off. */
*unique = 1;
j = strlen(av[0]) - len + 2;
if ((p = NEW(char, j + 1)) != NULL) {
COPYFROMTO(p, av[0] + len, j);
if ((new = NEW(char, strlen(dir) + strlen(av[0]) + 2)) != NULL) {
(void)strcpy(new, dir);
(void)strcat(new, "/");
(void)strcat(new, av[0]);
rl_add_slash(new, p);
DISPOSE(new);
}
}
}
else {
*unique = 0;
if (len) {
/* Find largest matching substring. */
for (i = len, end = strlen(av[0]); i < end; i++)
for (j = 1; j < ac; j++)
if (av[0][i] != av[j][i])
goto breakout;
breakout:
if (i > len) {
j = i - len + 1;
if ((p = NEW(char, j)) != NULL) {
COPYFROMTO(p, av[0] + len, j);
p[j - 1] = '\0';
}
}
}
}
/* Clean up and return. */
DISPOSE(dir);
DISPOSE(file);
for (i = 0; i < ac; i++)
DISPOSE(av[i]);
DISPOSE(av);
return p;
}
/*
** Return all possible completions.
*/
int
rl_list_possib(pathname, avp)
char *pathname;
char ***avp;
{
char *dir;
char *file;
int ac;
if (SplitPath(pathname, &dir, &file) < 0)
return 0;
ac = FindMatches(dir, file, avp);
DISPOSE(dir);
DISPOSE(file);
return ac;
}
.\" $Revision: 1.1 $
.TH EDITLINE 3
.SH NAME
editline \- command-line editing library with history
.SH SYNOPSIS
.nf
.B "char *"
.B "readline(prompt)"
.B " char *prompt;"
.B "void"
.B "add_history(line)"
.B " char *line;"
.fi
.SH DESCRIPTION
.I Editline
is a library that provides an line-editing interface with text recall.
It is intended to be compatible with the
.I readline
library provided by the Free Software Foundation, but much smaller.
The bulk of this manual page describes the user interface.
.PP
The
.I readline
routine returns a line of text with the trailing newline removed.
The data is returned in a buffer allocated with
.IR malloc (3),
so the space should be released with
.IR free (3)
when the calling program is done with it.
Before accepting input from the user, the specified
.I prompt
is displayed on the terminal.
.PP
The
.I add_history
routine makes a copy of the specified
.I line
and adds it to the internal history list.
.SS "User Interface"
A program that uses this library provides a simple emacs-like editing
interface to its users.
A line may be edited before it is sent to the calling program by typing either
control characters or escape sequences.
A control character, shown as a caret followed by a letter, is typed by
holding down the ``control'' key while the letter is typed.
For example, ``^A'' is a control-A.
An escape sequence is entered by typing the ``escape'' key followed by one or
more characters.
The escape key is abbreviated as ``ESC.''
Note that unlike control keys, case matters in escape sequences; ``ESC\ F''
is not the same as ``ESC\ f''.
.PP
An editing command may be typed anywhere on the line, not just at the
beginning.
In addition, a return may also be typed anywhere on the line, not just at
the end.
.PP
Most editing commands may be given a repeat count,
.IR n ,
where
.I n
is a number.
To enter a repeat count, type the escape key, the number, and then
the command to execute.
For example, ``ESC\ 4\ ^f'' moves forward four characters.
If a command may be given a repeat count then the text ``[n]'' is given at the
end of its description.
.PP
The following control characters are accepted:
.RS
.nf
.ta \w'ESC DEL 'u
^A Move to the beginning of the line
^B Move left (backwards) [n]
^D Delete character [n]
^E Move to end of line
^F Move right (forwards) [n]
^G Ring the bell
^H Delete character before cursor (backspace key) [n]
^I Complete filename (tab key); see below
^J Done with line (return key)
^K Kill to end of line (or column [n])
^L Redisplay line
^M Done with line (alternate return key)
^N Get next line from history [n]
^P Get previous line from history [n]
^R Search backward (forward if [n]) through history for text;
\& must start line if text begins with an uparrow
^T Transpose characters
^V Insert next character, even if it is an edit command
^W Wipe to the mark
^X^X Exchange current location and mark
^Y Yank back last killed text
^[ Start an escape sequence (escape key)
^]c Move forward to next character ``c''
^? Delete character before cursor (delete key) [n]
.fi
.RE
.PP
The following escape sequences are provided.
.RS
.nf
.ta \w'ESC DEL 'u
ESC\ ^H Delete previous word (backspace key) [n]
ESC\ DEL Delete previous word (delete key) [n]
ESC\ SP Set the mark (space key); see ^X^X and ^Y above
ESC\ \. Get the last (or [n]'th) word from previous line
ESC\ \? Show possible completions; see below
ESC\ < Move to start of history
ESC\ > Move to end of history
ESC\ b Move backward a word [n]
ESC\ d Delete word under cursor [n]
ESC\ f Move forward a word [n]
ESC\ l Make word lowercase [n]
ESC\ u Make word uppercase [n]
ESC\ y Yank back last killed text
ESC\ v Show library version
ESC\ w Make area up to mark yankable
ESC\ nn Set repeat count to the number nn
ESC\ C Read from environment variable ``_C_'', where C is
\& an uppercase letter
.fi
.RE
.PP
The
.I editline
library has a small macro facility.
If you type the escape key followed by an uppercase letter,
.IR C ,
then the contents of the environment variable
.I _C_
are read in as if you had typed them at the keyboard.
For example, if the variable
.I _L_
contains the following:
.RS
^A^Kecho '^V^[[H^V^[[2J'^M
.RE
Then typing ``ESC L'' will move to the beginning of the line, kill the
entire line, enter the echo command needed to clear the terminal (if your
terminal is like a VT-100), and send the line back to the shell.
.PP
The
.I editline
library also does filename completion.
Suppose the root directory has the following files in it:
.RS
.nf
.ta \w'core 'u
bin vmunix
core vmunix.old
.fi
.RE
If you type ``rm\ /v'' and then the tab key.
.I Editline
will then finish off as much of the name as possible by adding ``munix''.
Because the name is not unique, it will then beep.
If you type the escape key and a question mark, it will display the
two choices.
If you then type a period and a tab, the library will finish off the filename
for you:
.RS
.nf
.RI "rm /v[TAB]" munix .TAB old
.fi
.RE
The tab key is shown by ``[TAB]'' and the automatically-entered text
is shown in italics.
.SH "BUGS AND LIMITATIONS"
Cannot handle lines more than 80 columns.
.SH AUTHORS
Simmule R. Turner <uunet.uu.net!capitol!sysgo!simmy>
and Rich $alz <rsalz@osf.org>.
Original manual page by DaviD W. Sanderson <dws@ssec.wisc.edu>.
/* $Revision: 1.3 $
**
** Internal header file for editline library.
*/
#include <stdio.h>
#if defined(HAVE_STDLIB)
#include <stdlib.h>
#include <string.h>
#endif /* defined(HAVE_STDLIB) */
#if defined(SYS_UNIX)
#include "unix.h"
#endif /* defined(SYS_UNIX) */
#if defined(SYS_OS9)
#include "os9.h"
#endif /* defined(SYS_OS9) */
#if !defined(SIZE_T)
#define SIZE_T unsigned int
#endif /* !defined(SIZE_T) */
typedef unsigned char CHAR;
#if defined(HIDE)
#define STATIC static
#else
#define STATIC /* NULL */
#endif /* !defined(HIDE) */
#if !defined(CONST)
#if defined(__STDC__)
#define CONST const
#else
#define CONST
#endif /* defined(__STDC__) */
#endif /* !defined(CONST) */
#define MEM_INC 64
#define SCREEN_INC 256
#define DISPOSE(p) free((char *)(p))
#define NEW(T, c) \
((T *)malloc((unsigned int)(sizeof (T) * (c))))
#define RENEW(p, T, c) \
(p = (T *)realloc((char *)(p), (unsigned int)(sizeof (T) * (c))))
#define COPYFROMTO(new, p, len) \
(void)memcpy((char *)(new), (char *)(p), (int)(len))
/*
** Variables and routines internal to this package.
*/
extern int rl_eof;
extern int rl_erase;
extern int rl_intr;
extern int rl_kill;
extern int rl_quit;
extern char *rl_complete();
extern int rl_list_possib();
extern void rl_ttyset();
extern void rl_add_slash();
#if !defined(HAVE_STDLIB)
extern char *getenv();
extern char *malloc();
extern char *realloc();
extern char *memcpy();
extern char *strcat();
extern char *strchr();
extern char *strrchr();
extern char *strcpy();
extern char *strdup();
extern int strcmp();
extern int strlen();
extern int strncmp();
#endif /* !defined(HAVE_STDLIB) */
/* $Revision: 1.1 $
**
** Editline system header file for OS-9 (on 68k).
*/
#define CRLF "\r\l"
#define FORWARD extern
#include <dir.h>
typedef struct direct DIRENTRY;
/* $Revision: 1.1 $
**
** OS-9 system-dependant routines for editline library.
*/
#include "editline.h"
#include <sgstat.h>
#include <modes.h>
void
rl_ttyset(Reset)
int Reset;
{
static struct sgbuf old;
struct sgbuf new;
if (Reset == 0) {
_gs_opt(0, &old);
_gs_opt(0, &new);
new.sg_backsp = 0; new.sg_delete = 0; new.sg_echo = 0;
new.sg_alf = 0; new.sg_nulls = 0; new.sg_pause = 0;
new.sg_page = 0; new.sg_bspch = 0; new.sg_dlnch = 0;
new.sg_eorch = 0; new.sg_eofch = 0; new.sg_rlnch = 0;
new.sg_dulnch = 0; new.sg_psch = 0; new.sg_kbich = 0;
new.sg_kbach = 0; new.sg_bsech = 0; new.sg_bellch = 0;
new.sg_xon = 0; new.sg_xoff = 0; new.sg_tabcr = 0;
new.sg_tabsiz = 0;
_ss_opt(0, &new);
rl_erase = old.sg_bspch;
rl_kill = old.sg_dlnch;
rl_eof = old.sg_eofch;
rl_intr = old.sg_kbich;
rl_quit = -1;
}
else
_ss_opt(0, &old);
}
void
rl_add_slash(path, p)
char *path;
char *p;
{
(void)strcat(p, access(path, S_IREAD | S_IFDIR) ? " " : "/");
}
/* $Revision: 1.1 $
**
** Unix system-dependant routines for editline library.
*/
#include "editline.h"
#if defined(HAVE_TCGETATTR)
#include <termios.h>
void
rl_ttyset(Reset)
int Reset;
{
static struct termios old;
struct termios new;
if (Reset == 0) {
(void)tcgetattr(0, &old);
rl_erase = old.c_cc[VERASE];
rl_kill = old.c_cc[VKILL];
rl_eof = old.c_cc[VEOF];
rl_intr = old.c_cc[VINTR];
rl_quit = old.c_cc[VQUIT];
new = old;
new.c_cc[VINTR] = -1;
new.c_cc[VQUIT] = -1;
new.c_lflag &= ~(ECHO | ICANON);
new.c_iflag &= ~(ISTRIP | INPCK);
new.c_cc[VMIN] = 1;
new.c_cc[VTIME] = 0;
(void)tcsetattr(0, TCSANOW, &new);
}
else
(void)tcsetattr(0, TCSANOW, &old);
}
#else
#include <sgtty.h>
void
rl_ttyset(Reset)
int Reset;
{
static struct sgttyb old_sgttyb;
static struct tchars old_tchars;
struct sgttyb new_sgttyb;
struct tchars new_tchars;
if (Reset == 0) {
(void)ioctl(0, TIOCGETP, &old_sgttyb);
rl_erase = old_sgttyb.sg_erase;
rl_kill = old_sgttyb.sg_kill;
(void)ioctl(0, TIOCGETC, &old_tchars);
rl_eof = old_tchars.t_eofc;
rl_intr = old_tchars.t_intrc;
rl_quit = old_tchars.t_quitc;
new_sgttyb = old_sgttyb;
new_sgttyb.sg_flags &= ~ECHO;
new_sgttyb.sg_flags |= RAW;
#if defined(PASS8)
new_sgttyb.sg_flags |= PASS8;
#endif /* defined(PASS8) */
(void)ioctl(0, TIOCSETP, &new_sgttyb);
new_tchars = old_tchars;
new_tchars.t_intrc = -1;
new_tchars.t_quitc = -1;
(void)ioctl(0, TIOCSETC, &new_tchars);
}
else {
(void)ioctl(0, TIOCSETP, &old_sgttyb);
(void)ioctl(0, TIOCSETC, &old_tchars);
}
}
#endif /* defined(HAVE_TCGETATTR) */
void
rl_add_slash(path, p)
char *path;
char *p;
{
struct stat Sb;
if (stat(path, &Sb) >= 0)
(void)strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ");
}
/* $Revision: 1.2 $
**
** A "micro-shell" to test editline library.
** If given any arguments, commands aren't executed.
*/
#include <stdio.h>
#if defined(HAVE_STDLIB)
#include <stdlib.h>
#endif /* defined(HAVE_STDLIB) */
const char version_string[] = "4.321";
extern char *readline();
extern void add_history();
#if !defined(HAVE_STDLIB)
extern int chdir();
extern int free();
extern int strncmp();
extern int system();
extern void exit();
#endif /* !defined(HAVE_STDLIB) */
#if defined(NEED_PERROR)
void
perror(s)
char *s;
{
extern int errno;
(voidf)printf(stderr, "%s: error %d\n", s, errno);
}
#endif /* defined(NEED_PERROR) */
/* ARGSUSED1 */
int
main(ac, av)
int ac;
char *av[];
{
char *p;
int doit;
doit = ac == 1;
while ((p = readline("testit> ")) != NULL) {
(void)printf("\t\t\t|%s|\n", p);
if (doit)
if (strncmp(p, "cd ", 3) == 0) {
if (chdir(&p[3]) < 0)
perror(&p[3]);
}
else if (system(p) != 0)
perror(p);
add_history(p);
free(p);
}
exit(0);
/* NOTREACHED */
}
/* $Revision: 1.1 $
**
** Editline system header file for Unix.
*/
#define CRLF "\r\n"
#define FORWARD STATIC
#include <sys/types.h>
#include <sys/stat.h>
#if defined(USE_DIRENT)
#include <dirent.h>
typedef struct dirent DIRENTRY;
#else
#include <sys/dir.h>
typedef struct direct DIRENTRY;
#endif /* defined(USE_DIRENT) */
#if !defined(S_ISDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif /* !defined(S_ISDIR) */
const char version_string[] = "1.234";
static char foobar[]="foobar";
const char * foo_string = foobar;
#ifdef linux
/* Register numbers */
#define RN_GS 0
#define RN_FS 1
#define RN_ES 2
#define RN_DS 3
#define RN_EDI 4
#define RN_ESI 5
#define RN_EBP 6
#define RN_ESP 7
#define RN_EBX 8
#define RN_EDX 9
#define RN_ECX 10
#define RN_EAX 11
#define RN_TRAPNO 12
#define RN_ERR 13
#define RN_EIP 14
#define RN_CS 15
#define RN_EFLAGS 16
#define RN_ESP_AT_SIGNAL 17
#define RN_SS 18
#define RN_I387 19
#define RN_OLDMASK 20
#define RN_CR2 21
#endif
#define SC_GS regval[RN_GS]
#define SC_FS regval[RN_FS]
#define SC_ES regval[RN_ES]
#define SC_DS regval[RN_DS]
#define SC_EDI(dbg_mask) (regval[RN_EDI] & dbg_mask)
#define SC_ESI(dbg_mask) (regval[RN_ESI] & dbg_mask)
#define SC_EBP(dbg_mask) (regval[RN_EBP] & dbg_mask)
#define SC_ESP(dbg_mask) (regval[RN_ESP] & dbg_mask)
#define SC_EBX(dbg_mask) (regval[RN_EBX] & dbg_mask)
#define SC_EDX(dbg_mask) (regval[RN_EDX] & dbg_mask)
#define SC_ECX(dbg_mask) (regval[RN_ECX] & dbg_mask)
#define SC_EAX(dbg_mask) (regval[RN_EAX] & dbg_mask)
#define SC_TRAPNO regval[RN_TRAPNO]
#define SC_ERR regval[RN_ERR]
#define SC_EIP(dbg_mask) (regval[RN_EIP] & dbg_mask)
#define SC_CS regval[RN_CS]
#define SC_EFLAGS regval[RN_EFLAGS]
#define ESP_AT_SIGNAL regval[RN_ESP_AT_SIGNAL]
#define SC_SS regval[RN_SS]
#define I387 regval[RN_I387]
#define OLDMASK regval[RN_OLDMASK]
#define CR2 regval[RN_CR2]
/* Macro definitions for linux.
Copyright (C) 1992 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#if !defined (TM_LINUX_H)
#define TM_LINUX_H 1
/* number of traps that happen between exec'ing the shell
* to run an inferior, and when we finally get to
* the inferior code. This is 2 on most implementations.
*/
#define START_INFERIOR_TRAPS_EXPECTED 2
#include "tm-i386v.h"
/* Define this if the C compiler puts an underscore at the front
of external names before giving them to the linker. */
#define NAMES_HAVE_UNDERSCORE
#endif /* !defined (TM_LINUX_H) */
/* Host support for i386.
Copyright 1986, 1987, 1989, 1992 Free Software Foundation, Inc.
Changes for 80386 by Pace Willisson (pace@prep.ai.mit.edu), July 1988.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HOST_BYTE_ORDER LITTLE_ENDIAN
/* I'm running gdb 3.4 under 386/ix 2.0.2, which is a derivative of AT&T's
Sys V/386 3.2.
On some machines, gdb crashes when it's starting up while calling the
vendor's termio tgetent() routine. It always works when run under
itself (actually, under 3.2, it's not an infinitely recursive bug.)
After some poking around, it appears that depending on the environment
size, or whether you're running YP, or the phase of the moon or something,
the stack is not always long-aligned when main() is called, and tgetent()
takes strong offense at that. On some machines this bug never appears, but
on those where it does, it occurs quite reliably. */
#define ALIGN_STACK_ON_STARTUP
/* define USG if you are using sys5 /usr/include's */
#define USG
#define HAVE_TERMIO
/* This is the amount to subtract from u.u_ar0
to get the offset in the core file of the register values. */
#define KERNEL_U_ADDR 0xe0000000
/* Native support for linux, for GDB, the GNU debugger.
Copyright (C) 1986, 1987, 1989, 1992 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "xm-i386v.h"
/* This is the amount to subtract from u.u_ar0
to get the offset in the core file of the register values. */
#undef KERNEL_U_ADDR
#define KERNEL_U_ADDR 0x0
#define PSIGNAL_IN_SIGNAL_H
...@@ -135,17 +135,22 @@ void FreeProcInstance(FARPROC func) ...@@ -135,17 +135,22 @@ void FreeProcInstance(FARPROC func)
LONG CallWindowProc( FARPROC func, HWND hwnd, WORD message, LONG CallWindowProc( FARPROC func, HWND hwnd, WORD message,
WORD wParam, LONG lParam ) WORD wParam, LONG lParam )
{ {
if ((unsigned int)func & 0xffff0000) if (Is16bitAddress(func))
{ {
PushOn16( CALLBACK_SIZE_WORD, hwnd ); PushOn16( CALLBACK_SIZE_WORD, hwnd );
PushOn16( CALLBACK_SIZE_WORD, message ); PushOn16( CALLBACK_SIZE_WORD, message );
PushOn16( CALLBACK_SIZE_WORD, wParam ); PushOn16( CALLBACK_SIZE_WORD, wParam );
PushOn16( CALLBACK_SIZE_LONG, lParam ); PushOn16( CALLBACK_SIZE_LONG, lParam );
printf("%8.8x(%4.4x, %4.4x, %4.4x, %8.8x)\n", func, hwnd, message, wParam, lParam);
return CallTo16((unsigned int) func, return CallTo16((unsigned int) func,
FindDataSegmentForCode((unsigned long) func)); FindDataSegmentForCode((unsigned long) func));
} }
else else
return WIDGETS_Call32WndProc( func, hwnd, message, wParam, lParam ); {
return (*func)(hwnd, message, wParam, lParam);
}
} }
/********************************************************************** /**********************************************************************
...@@ -153,9 +158,16 @@ LONG CallWindowProc( FARPROC func, HWND hwnd, WORD message, ...@@ -153,9 +158,16 @@ LONG CallWindowProc( FARPROC func, HWND hwnd, WORD message,
*/ */
void CallLineDDAProc(FARPROC func, short xPos, short yPos, long lParam) void CallLineDDAProc(FARPROC func, short xPos, short yPos, long lParam)
{ {
PushOn16( CALLBACK_SIZE_WORD, xPos ); if (Is16bitAddress(func))
PushOn16( CALLBACK_SIZE_WORD, yPos ); {
PushOn16( CALLBACK_SIZE_LONG, lParam ); PushOn16( CALLBACK_SIZE_WORD, xPos );
CallTo16((unsigned int) func, PushOn16( CALLBACK_SIZE_WORD, yPos );
FindDataSegmentForCode((unsigned long) func)); PushOn16( CALLBACK_SIZE_LONG, lParam );
CallTo16((unsigned int) func,
FindDataSegmentForCode((unsigned long) func));
}
else
{
(*func)(xPos, yPos, lParam);
}
} }
...@@ -32,11 +32,19 @@ length 415 ...@@ -32,11 +32,19 @@ length 415
50 pascal GetProcAddress(word ptr) GetProcAddress(1 2) 50 pascal GetProcAddress(word ptr) GetProcAddress(1 2)
51 pascal MakeProcInstance(ptr word) CALLBACK_MakeProcInstance(1 2) 51 pascal MakeProcInstance(ptr word) CALLBACK_MakeProcInstance(1 2)
52 pascal FreeProcInstance(ptr) FreeProcInstance(1) 52 pascal FreeProcInstance(ptr) FreeProcInstance(1)
59 pascal WriteProfileString(ptr ptr ptr) WriteProfileString(1 2 3)
60 pascal FindResource(word ptr ptr) FindResource(1 2 3)
61 pascal LoadResource(word word) LoadResource(1 2)
62 pascal LockResource(word) LockResource(1)
63 pascal FreeResource(word) FreeResource(1)
74 pascal OpenFile(ptr ptr word) KERNEL_OpenFile(1 2 3) 74 pascal OpenFile(ptr ptr word) KERNEL_OpenFile(1 2 3)
81 pascal _lclose(word) KERNEL__lclose(1) 81 pascal _lclose(word) KERNEL__lclose(1)
82 pascal _lread(word ptr word) KERNEL__lread(1 2 3) 82 pascal _lread(word ptr word) KERNEL__lread(1 2 3)
85 pascal _lopen(ptr word) KERNEL__lopen(1 2) 85 pascal _lopen(ptr word) KERNEL__lopen(1 2)
86 pascal _lwrite(word ptr word) KERNEL__lwrite(1 2 3) 86 pascal _lwrite(word ptr word) KERNEL__lwrite(1 2 3)
88 pascal lstrcpy(ptr ptr) lstrcpy(1 2)
89 pascal lstrcat(ptr ptr) lstrcat(1 2)
90 pascal lstrlen(ptr) lstrcpy(1)
91 register InitTask(word word word word word 91 register InitTask(word word word word word
word word word word word) word word word word word)
KERNEL_InitTask() KERNEL_InitTask()
...@@ -51,6 +59,8 @@ length 415 ...@@ -51,6 +59,8 @@ length 415
GetPrivateProfileInt(1 2 3 4) GetPrivateProfileInt(1 2 3 4)
128 pascal GetPrivateProfileString(ptr ptr ptr ptr s_word ptr) 128 pascal GetPrivateProfileString(ptr ptr ptr ptr s_word ptr)
GetPrivateProfileString(1 2 3 4 5 6) GetPrivateProfileString(1 2 3 4 5 6)
129 pascal WritePrivateProfileString(ptr ptr ptr ptr)
WritePrivateProfileString(1 2 3 4)
131 pascal GetDOSEnvironment() GetDOSEnvironment() 131 pascal GetDOSEnvironment() GetDOSEnvironment()
132 return GetWinFlags 0 0x413 132 return GetWinFlags 0 0x413
154 return GlobalNotify 4 0 154 return GlobalNotify 4 0
...@@ -66,3 +76,4 @@ length 415 ...@@ -66,3 +76,4 @@ length 415
57 pascal GetProfileInt(ptr ptr word) GetProfileInt(1 2 3) 57 pascal GetProfileInt(ptr ptr word) GetProfileInt(1 2 3)
58 pascal GetProfileString(ptr ptr ptr ptr word) GetProfileString(1 2 3 4 5) 58 pascal GetProfileString(ptr ptr ptr ptr word) GetProfileString(1 2 3 4 5)
199 pascal SetHandleCount(word) SetHandleCount(1) 199 pascal SetHandleCount(word) SetHandleCount(1)
353 pascal lstrcpyn(ptr ptr word) lstrcpyn(1 2 3)
...@@ -107,11 +107,6 @@ DLLRelay(unsigned int func_num, unsigned int seg_off) ...@@ -107,11 +107,6 @@ DLLRelay(unsigned int func_num, unsigned int seg_off)
IF1632_Saved16_ss == 0x0097) IF1632_Saved16_ss == 0x0097)
printf("ACK!!\n"); printf("ACK!!\n");
#if 0
IF1632_Saved16_esp &= 0x0000ffff;
IF1632_Saved16_ebp &= 0x0000ffff;
#endif
#ifdef DEBUG_STACK #ifdef DEBUG_STACK
stack_p = (unsigned short *) seg_off; stack_p = (unsigned short *) seg_off;
for (i = 0; i < 24; i++, stack_p++) for (i = 0; i < 24; i++, stack_p++)
......
# $Id: win87em.spec,v 1.3 1993/07/04 04:04:21 root Exp root $ # $Id: sound.spec,v 1.3 1993/07/04 04:04:21 root Exp root $
# #
name sound name sound
id 7 id 7
......
...@@ -17,11 +17,14 @@ length 540 ...@@ -17,11 +17,14 @@ length 540
19 pascal ReleaseCapture() ReleaseCapture() 19 pascal ReleaseCapture() ReleaseCapture()
31 pascal IsIconic(word) IsIconic(1) 31 pascal IsIconic(word) IsIconic(1)
33 pascal GetClientRect(word ptr) GetClientRect(1 2) 33 pascal GetClientRect(word ptr) GetClientRect(1 2)
36 pascal GetWindowText(word ptr word) GetWindowText(1 2 3)
38 pascal GetWindowTextLength(word) GetWindowTextLength(1)
39 pascal BeginPaint(word ptr) BeginPaint(1 2) 39 pascal BeginPaint(word ptr) BeginPaint(1 2)
40 pascal EndPaint(word ptr) EndPaint(1 2) 40 pascal EndPaint(word ptr) EndPaint(1 2)
41 pascal CreateWindow(ptr ptr long s_word s_word s_word s_word word word word ptr) 41 pascal CreateWindow(ptr ptr long s_word s_word s_word s_word word word word ptr)
CreateWindow(1 2 3 4 5 6 7 8 9 10 11) CreateWindow(1 2 3 4 5 6 7 8 9 10 11)
42 pascal ShowWindow(word word) ShowWindow(1 2) 42 pascal ShowWindow(word word) ShowWindow(1 2)
46 pascal GetParent(word) GetParent(1)
53 pascal DestroyWindow(word) DestroyWindow(1) 53 pascal DestroyWindow(word) DestroyWindow(1)
57 pascal RegisterClass(ptr) RegisterClass(1) 57 pascal RegisterClass(ptr) RegisterClass(1)
66 pascal GetDC(word) GetDC(1) 66 pascal GetDC(word) GetDC(1)
...@@ -37,6 +40,7 @@ length 540 ...@@ -37,6 +40,7 @@ length 540
80 pascal UnionRect(ptr ptr ptr) UnionRect(1 2 3) 80 pascal UnionRect(ptr ptr ptr) UnionRect(1 2 3)
81 pascal FillRect(word ptr word) FillRect(1 2 3) 81 pascal FillRect(word ptr word) FillRect(1 2 3)
82 pascal InvertRect(word ptr) InvertRect(1 2) 82 pascal InvertRect(word ptr) InvertRect(1 2)
83 pascal FrameRect(word ptr word) FrameRect(1 2 3)
85 pascal DrawText(word ptr s_word ptr word) DrawText(1 2 3 4 5) 85 pascal DrawText(word ptr s_word ptr word) DrawText(1 2 3 4 5)
102 pascal AdjustWindowRect(ptr long word) AdjustWindowRect(1 2 3) 102 pascal AdjustWindowRect(ptr long word) AdjustWindowRect(1 2 3)
104 pascal MessageBeep(word) MessageBeep(1) 104 pascal MessageBeep(word) MessageBeep(1)
...@@ -60,6 +64,10 @@ length 540 ...@@ -60,6 +64,10 @@ length 540
130 pascal SetClassWord(word s_word word) SetClassWord(1 2 3) 130 pascal SetClassWord(word s_word word) SetClassWord(1 2 3)
131 pascal GetClassLong(word s_word) GetClassLong(1 2) 131 pascal GetClassLong(word s_word) GetClassLong(1 2)
132 pascal SetClassLong(word s_word long) SetClassLong(1 2 3) 132 pascal SetClassLong(word s_word long) SetClassLong(1 2 3)
133 pascal GetWindowWord(word s_word) GetWindowWord(1 2)
134 pascal SetWindowWord(word s_word word) SetWindowWord(1 2 3)
135 pascal GetWindowLong(word s_word) GetWindowLong(1 2)
136 pascal SetWindowLong(word s_word long) SetWindowLong(1 2 3)
150 pascal LoadMenu(word ptr) LoadMenu(1 2) 150 pascal LoadMenu(word ptr) LoadMenu(1 2)
151 pascal CreateMenu() CreateMenu() 151 pascal CreateMenu() CreateMenu()
154 pascal CheckMenu(word word word) CheckMenu(1 2 3) 154 pascal CheckMenu(word word word) CheckMenu(1 2 3)
...@@ -69,12 +77,32 @@ length 540 ...@@ -69,12 +77,32 @@ length 540
174 pascal LoadIcon(word ptr) LoadIcon(1 2) 174 pascal LoadIcon(word ptr) LoadIcon(1 2)
175 pascal LoadBitmap(word ptr) LoadBitmap(1 2) 175 pascal LoadBitmap(word ptr) LoadBitmap(1 2)
176 pascal LoadString(word word ptr s_word) LoadString(1 2 3 4) 176 pascal LoadString(word word ptr s_word) LoadString(1 2 3 4)
177 pascal LoadAccelerators(word ptr) LoadAccelerators(1 2)
179 pascal GetSystemMetrics(word) GetSystemMetrics(1) 179 pascal GetSystemMetrics(word) GetSystemMetrics(1)
180 pascal GetSysColor(word) GetSysColor(1)
181 pascal SetSysColors(word ptr ptr) SetSysColors(1 2 3)
430 pascal lstrcmp(ptr ptr) lstrcmp(1 2)
431 pascal AnsiUpper(ptr) AnsiUpper(1)
432 pascal AnsiLower(ptr) AnsiLower(1)
433 pascal IsCharAlpha(byte) IsCharAlpha(1)
434 pascal IsCharAlphanumeric(byte) IsCharAlphanumeric(1)
435 pascal IsCharUpper(byte) IsCharUpper(1)
436 pascal IsCharLower(byte) IsCharLower(1)
437 pascal AnsiUpperBuff(ptr word) AnsiUpperBuff(1 2)
438 pascal AnsiLowerBuff(ptr word) AnsiLowerBuff(1 2)
471 pascal lstrcmpi(ptr ptr) lstrcmpi(1 2)
472 pascal AnsiNext(ptr) AnsiNext(1 )
473 pascal AnsiPrev(ptr ptr) AnsiPrev(1 2)
182 pascal KillSystemTimer(word word) KillSystemTimer(1 2) 182 pascal KillSystemTimer(word word) KillSystemTimer(1 2)
190 pascal GetUpdateRect(word ptr word) GetUpdateRect(1 2 3) 190 pascal GetUpdateRect(word ptr word) GetUpdateRect(1 2 3)
237 pascal GetUpdateRgn(word word word) GetUpdateRgn(1 2 3) 237 pascal GetUpdateRgn(word word word) GetUpdateRgn(1 2 3)
244 pascal EqualRect(ptr ptr) EqualRect(1 2) 244 pascal EqualRect(ptr ptr) EqualRect(1 2)
266 pascal SetMessageQueue(word) SetMessageQueue(1) 266 pascal SetMessageQueue(word) SetMessageQueue(1)
286 pascal GetDesktopWindow() GetDesktopWindow()
288 pascal GetMessageExtraInfo() GetMessageExtraInfo() 288 pascal GetMessageExtraInfo() GetMessageExtraInfo()
324 pascal FillWindow(word word word word) FillWindow(1 2 3 4) 324 pascal FillWindow(word word word word) FillWindow(1 2 3 4)
325 pascal PaintRect(word word word word ptr) PaintRect(1 2 3 4 5) 325 pascal PaintRect(word word word word ptr) PaintRect(1 2 3 4 5)
...@@ -83,5 +111,4 @@ length 540 ...@@ -83,5 +111,4 @@ length 540
373 pascal SubtractRect(ptr ptr ptr) SubtractRect(1 2 3) 373 pascal SubtractRect(ptr ptr ptr) SubtractRect(1 2 3)
403 pascal UnregisterClass(ptr word) UnregisterClass(1 2) 403 pascal UnregisterClass(ptr word) UnregisterClass(1 2)
411 pascal AppendMenu(word word word ptr) AppendMenu(1 2 3 4) 411 pascal AppendMenu(word word word ptr) AppendMenu(1 2 3 4)
177 pascal LoadAccelerators(word ptr) LoadAccelerators(1 2)
421 pascal wvsprintf(ptr ptr ptr) wvsprintf(1 2 3) 421 pascal wvsprintf(ptr ptr ptr) wvsprintf(1 2 3)
...@@ -17,7 +17,7 @@ typedef struct tagCLASS ...@@ -17,7 +17,7 @@ typedef struct tagCLASS
HCLASS hNext; /* Next class */ HCLASS hNext; /* Next class */
WORD wMagic; /* Magic number (must be CLASS_MAGIC) */ WORD wMagic; /* Magic number (must be CLASS_MAGIC) */
ATOM atomName; /* Name of the class */ ATOM atomName; /* Name of the class */
HANDLE hDCE; /* Class DC Entry (if CS_CLASSDC) */ HDC hdc; /* Class DC (if CS_CLASSDC) */
WORD cWindows; /* Count of existing windows of this class */ WORD cWindows; /* Count of existing windows of this class */
WNDCLASS wc __attribute__ ((packed)); /* Class information */ WNDCLASS wc __attribute__ ((packed)); /* Class information */
WORD wExtra[1]; /* Class extra bytes */ WORD wExtra[1]; /* Class extra bytes */
......
...@@ -32,4 +32,11 @@ struct segment_descriptor_s ...@@ -32,4 +32,11 @@ struct segment_descriptor_s
#define GLOBAL_FLAGS_EXECUTEONLY 0x00020000 #define GLOBAL_FLAGS_EXECUTEONLY 0x00020000
#define GLOBAL_FLAGS_READONLY 0x00020000 #define GLOBAL_FLAGS_READONLY 0x00020000
#define FIRST_SELECTOR 8
static __inline__ int Is16bitAddress(void *address)
{
return ((int) address >= (((FIRST_SELECTOR << 3) | 0x0007) << 16));
}
#endif /* SEGMEM_H */ #endif /* SEGMEM_H */
...@@ -32,9 +32,11 @@ typedef struct tagWND ...@@ -32,9 +32,11 @@ typedef struct tagWND
HWND hwndLastActive; /* Last active popup hwnd */ HWND hwndLastActive; /* Last active popup hwnd */
FARPROC lpfnWndProc; /* Window procedure */ FARPROC lpfnWndProc; /* Window procedure */
DWORD dwStyle; /* Window style (from CreateWindow) */ DWORD dwStyle; /* Window style (from CreateWindow) */
HANDLE hDCE; /* Window DC Entry (if CS_OWNDC) */ DWORD dwExStyle; /* Extended style (from CreateWindowEx) */
HDC hdc; /* Window DC (if CS_OWNDC) */
HMENU hmenuSystem; /* System menu */ HMENU hmenuSystem; /* System menu */
WORD wIDmenu; /* ID or hmenu (from CreateWindow) */ WORD wIDmenu; /* ID or hmenu (from CreateWindow) */
HANDLE hText; /* Handle of window text */
WORD flags; /* Misc. flags */ WORD flags; /* Misc. flags */
Widget shellWidget; /* For top-level windows */ Widget shellWidget; /* For top-level windows */
Widget winWidget; /* For all windows */ Widget winWidget; /* For all windows */
...@@ -47,10 +49,9 @@ typedef struct tagWND ...@@ -47,10 +49,9 @@ typedef struct tagWND
#define WIN_ERASE_UPDATERGN 1 /* Update region needs erasing */ #define WIN_ERASE_UPDATERGN 1 /* Update region needs erasing */
/* The caller must GlobalUnlock the pointer returned /* Window functions */
* by this function (except when NULL).
*/
WND * WIN_FindWndPtr( HWND hwnd ); WND * WIN_FindWndPtr( HWND hwnd );
HWND WIN_FindWinToRepaint( HWND hwnd );
#endif /* WIN_H */ #endif /* WIN_H */
...@@ -105,7 +105,7 @@ typedef struct { ...@@ -105,7 +105,7 @@ typedef struct {
#define GCW_STYLE (-26) #define GCW_STYLE (-26)
#define GCW_ATOM (-32) #define GCW_ATOM (-32)
/* Windows */
typedef struct { typedef struct {
void * lpCreateParams; void * lpCreateParams;
...@@ -122,6 +122,17 @@ typedef struct { ...@@ -122,6 +122,17 @@ typedef struct {
DWORD dwExStyle __attribute__ ((packed)); DWORD dwExStyle __attribute__ ((packed));
} CREATESTRUCT, *LPCREATESTRUCT; } CREATESTRUCT, *LPCREATESTRUCT;
/* Offsets for GetWindowLong() and GetWindowWord() */
#define GWL_EXSTYLE (-20)
#define GWL_STYLE (-16)
#define GWW_ID (-12)
#define GWW_HWNDPARENT (-8)
#define GWW_HINSTANCE (-6)
#define GWL_WNDPROC (-4)
#define DWL_MSGRESULT 0
#define DWL_DLGPROC 4
#define DWL_USER 8
typedef struct { short x, y; } POINT; typedef struct { short x, y; } POINT;
typedef POINT *PPOINT; typedef POINT *PPOINT;
...@@ -134,6 +145,7 @@ typedef struct ...@@ -134,6 +145,7 @@ typedef struct
short cy; short cy;
} SIZE, *LPSIZE; } SIZE, *LPSIZE;
#define MAKEPOINT(l) (*((POINT *)&(l)))
typedef struct tagMSG typedef struct tagMSG
{ {
...@@ -1452,7 +1464,7 @@ Fc(void,InvalidateRgn,HWND,a,HRGN,b,BOOL,c) ...@@ -1452,7 +1464,7 @@ Fc(void,InvalidateRgn,HWND,a,HRGN,b,BOOL,c)
Fc(void,OemToAnsiBuff,LPSTR,a,LPSTR,b,int,c) Fc(void,OemToAnsiBuff,LPSTR,a,LPSTR,b,int,c)
Fc(void,OffsetRect,LPRECT,a,short,b,short,c) Fc(void,OffsetRect,LPRECT,a,short,b,short,c)
Fc(void,SetDlgItemText,HWND,a,int,b,LPSTR,c) Fc(void,SetDlgItemText,HWND,a,int,b,LPSTR,c)
Fc(void,SetSysColors,int,a,LPINT,b,LONG*,c) Fc(void,SetSysColors,int,a,LPINT,b,COLORREF*,c)
Fc(void,ShowScrollBar,HWND,a,WORD,b,BOOL,c) Fc(void,ShowScrollBar,HWND,a,WORD,b,BOOL,c)
Fc(void,SwitchStackTo,WORD,a,WORD,b,WORD,c) Fc(void,SwitchStackTo,WORD,a,WORD,b,WORD,c)
Fd(BOOL,AppendMenu,HMENU,a,WORD,b,WORD,c,LPSTR,d) Fd(BOOL,AppendMenu,HMENU,a,WORD,b,WORD,c,LPSTR,d)
......
...@@ -15,8 +15,12 @@ struct w_files{ ...@@ -15,8 +15,12 @@ struct w_files{
char * lookup_table; char * lookup_table;
char * nrname_table; char * nrname_table;
char * rname_table; char * rname_table;
unsigned short hinstance;
}; };
extern struct w_files * wine_files; extern struct w_files * wine_files;
extern char *GetFilenameFromInstance(unsigned short instance);
extern struct w_files *GetFileInfo(unsigned short instance);
#endif #endif
...@@ -3,12 +3,47 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; ...@@ -3,12 +3,47 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "prototypes.h" #include "prototypes.h"
#include "neexe.h" #include "neexe.h"
#include "windows.h" #include "windows.h"
#include "gdi.h" #include "gdi.h"
#include "wine.h"
#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MIN(a,b) ((a) < (b) ? (a) : (b))
static int ResourceFd = -1;
static HANDLE ResourceInst = 0;
static struct w_files *ResourceFileInfo = NULL;
/**********************************************************************
* OpenResourceFile
*/
int
OpenResourceFile(HANDLE instance)
{
struct w_files *w;
if (ResourceInst == instance)
return ResourceFd;
w = GetFileInfo(instance);
if (w == NULL)
return -1;
if (ResourceFd >= 0)
close(ResourceFd);
ResourceInst = instance;
ResourceFileInfo = w;
ResourceFd = open(w->filename, O_RDONLY);
return ResourceFd;
}
/********************************************************************** /**********************************************************************
* ConvertCoreBitmap * ConvertCoreBitmap
...@@ -88,17 +123,19 @@ FindResourceByNumber(struct resource_nameinfo_s *result_p, ...@@ -88,17 +123,19 @@ FindResourceByNumber(struct resource_nameinfo_s *result_p,
struct resource_nameinfo_s nameinfo; struct resource_nameinfo_s nameinfo;
unsigned short size_shift; unsigned short size_shift;
int i; int i;
off_t rtoff;
/* /*
* Move to beginning of resource table. * Move to beginning of resource table.
*/ */
lseek(CurrentNEFile, (CurrentMZHeader->ne_offset + rtoff = (ResourceFileInfo->mz_header->ne_offset +
CurrentNEHeader->resource_tab_offset), SEEK_SET); ResourceFileInfo->ne_header->resource_tab_offset);
lseek(ResourceFd, rtoff, SEEK_SET);
/* /*
* Read block size. * Read block size.
*/ */
if (read(CurrentNEFile, &size_shift, sizeof(size_shift)) != if (read(ResourceFd, &size_shift, sizeof(size_shift)) !=
sizeof(size_shift)) sizeof(size_shift))
{ {
return -1; return -1;
...@@ -110,7 +147,7 @@ FindResourceByNumber(struct resource_nameinfo_s *result_p, ...@@ -110,7 +147,7 @@ FindResourceByNumber(struct resource_nameinfo_s *result_p,
typeinfo.type_id = 0xffff; typeinfo.type_id = 0xffff;
while (typeinfo.type_id != 0) while (typeinfo.type_id != 0)
{ {
if (read(CurrentNEFile, &typeinfo, sizeof(typeinfo)) != if (read(ResourceFd, &typeinfo, sizeof(typeinfo)) !=
sizeof(typeinfo)) sizeof(typeinfo))
{ {
return -1; return -1;
...@@ -119,7 +156,7 @@ FindResourceByNumber(struct resource_nameinfo_s *result_p, ...@@ -119,7 +156,7 @@ FindResourceByNumber(struct resource_nameinfo_s *result_p,
{ {
for (i = 0; i < typeinfo.count; i++) for (i = 0; i < typeinfo.count; i++)
{ {
if (read(CurrentNEFile, &nameinfo, sizeof(nameinfo)) != if (read(ResourceFd, &nameinfo, sizeof(nameinfo)) !=
sizeof(nameinfo)) sizeof(nameinfo))
{ {
return -1; return -1;
...@@ -159,17 +196,19 @@ FindResourceByName(struct resource_nameinfo_s *result_p, ...@@ -159,17 +196,19 @@ FindResourceByName(struct resource_nameinfo_s *result_p,
unsigned char nbytes; unsigned char nbytes;
char name[256]; char name[256];
int i; int i;
off_t rtoff;
/* /*
* Move to beginning of resource table. * Move to beginning of resource table.
*/ */
lseek(CurrentNEFile, (CurrentMZHeader->ne_offset + rtoff = (ResourceFileInfo->mz_header->ne_offset +
CurrentNEHeader->resource_tab_offset), SEEK_SET); ResourceFileInfo->ne_header->resource_tab_offset);
lseek(ResourceFd, rtoff, SEEK_SET);
/* /*
* Read block size. * Read block size.
*/ */
if (read(CurrentNEFile, &size_shift, sizeof(size_shift)) != if (read(ResourceFd, &size_shift, sizeof(size_shift)) !=
sizeof(size_shift)) sizeof(size_shift))
{ {
return -1; return -1;
...@@ -181,7 +220,7 @@ FindResourceByName(struct resource_nameinfo_s *result_p, ...@@ -181,7 +220,7 @@ FindResourceByName(struct resource_nameinfo_s *result_p,
typeinfo.type_id = 0xffff; typeinfo.type_id = 0xffff;
while (typeinfo.type_id != 0) while (typeinfo.type_id != 0)
{ {
if (read(CurrentNEFile, &typeinfo, sizeof(typeinfo)) != if (read(ResourceFd, &typeinfo, sizeof(typeinfo)) !=
sizeof(typeinfo)) sizeof(typeinfo))
{ {
return -1; return -1;
...@@ -190,7 +229,7 @@ FindResourceByName(struct resource_nameinfo_s *result_p, ...@@ -190,7 +229,7 @@ FindResourceByName(struct resource_nameinfo_s *result_p,
{ {
for (i = 0; i < typeinfo.count; i++) for (i = 0; i < typeinfo.count; i++)
{ {
if (read(CurrentNEFile, &nameinfo, sizeof(nameinfo)) != if (read(ResourceFd, &nameinfo, sizeof(nameinfo)) !=
sizeof(nameinfo)) sizeof(nameinfo))
{ {
return -1; return -1;
...@@ -199,14 +238,12 @@ FindResourceByName(struct resource_nameinfo_s *result_p, ...@@ -199,14 +238,12 @@ FindResourceByName(struct resource_nameinfo_s *result_p,
if (nameinfo.id & 0x8000) if (nameinfo.id & 0x8000)
continue; continue;
old_pos = lseek(CurrentNEFile, 0, SEEK_CUR); old_pos = lseek(ResourceFd, 0, SEEK_CUR);
new_pos = (CurrentMZHeader->ne_offset + new_pos = rtoff + nameinfo.id;
CurrentNEHeader->resource_tab_offset + lseek(ResourceFd, new_pos, SEEK_SET);
nameinfo.id); read(ResourceFd, &nbytes, 1);
lseek(CurrentNEFile, new_pos, SEEK_SET); read(ResourceFd, name, nbytes);
read(CurrentNEFile, &nbytes, 1); lseek(ResourceFd, old_pos, SEEK_SET);
read(CurrentNEFile, name, nbytes);
lseek(CurrentNEFile, old_pos, SEEK_SET);
name[nbytes] = '\0'; name[nbytes] = '\0';
if (strcasecmp(name, resource_name) == 0) if (strcasecmp(name, resource_name) == 0)
...@@ -222,53 +259,6 @@ FindResourceByName(struct resource_nameinfo_s *result_p, ...@@ -222,53 +259,6 @@ FindResourceByName(struct resource_nameinfo_s *result_p,
} }
/********************************************************************** /**********************************************************************
* LoadString
*/
int
LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen)
{
struct resource_nameinfo_s nameinfo;
unsigned short target_id;
unsigned char string_length;
int size_shift;
int string_num;
int i;
#ifdef DEBUG_RESOURCE
printf("LoadString: instance = %04x, id = %d, "
"buffer = %08x, length = %d\n",
instance, resource_id, buffer, buflen);
#endif
/*
* Find string entry.
*/
target_id = (resource_id >> 4) + 0x8001;
string_num = resource_id & 0x000f;
size_shift = FindResourceByNumber(&nameinfo, NE_RSCTYPE_STRING, target_id);
if (size_shift == -1)
return 0;
lseek(CurrentNEFile, (int) nameinfo.offset << size_shift, SEEK_SET);
for (i = 0; i < string_num; i++)
{
read(CurrentNEFile, &string_length, 1);
lseek(CurrentNEFile, string_length, SEEK_CUR);
}
read(CurrentNEFile, &string_length, 1);
i = MIN(string_length, buflen - 1);
read(CurrentNEFile, buffer, i);
buffer[i] = '\0';
#ifdef DEBUG_RESOURCE
printf(" '%s'\n", buffer);
#endif
return i;
}
/**********************************************************************
* LoadIcon * LoadIcon
*/ */
HICON HICON
...@@ -297,6 +287,43 @@ LoadAccelerators(HANDLE instance, LPSTR lpTableName) ...@@ -297,6 +287,43 @@ LoadAccelerators(HANDLE instance, LPSTR lpTableName)
fprintf(stderr,"LoadAccelerators: (%d),%d\n",instance,lpTableName); fprintf(stderr,"LoadAccelerators: (%d),%d\n",instance,lpTableName);
return 0; return 0;
} }
/**********************************************************************
* FindResource [KERNEL.60]
*/
HANDLE FindResource(HANDLE instance, LPSTR resource_name, LPSTR type_name)
{
fprintf(stderr,"FindResource: (%d),%d\n",instance, resource_name, type_name);
return 0;
}
/**********************************************************************
* LoadResource [KERNEL.61]
*/
HANDLE LoadResource(HANDLE instance, HANDLE hResInfo)
{
fprintf(stderr,"LoadResource: (%d),%d\n",instance, hResInfo);
return ;
}
/**********************************************************************
* LockResource [KERNEL.62]
*/
LPSTR LockResource(HANDLE hResData)
{
fprintf(stderr,"LockResource: %d\n", hResData);
return ;
}
/**********************************************************************
* FreeResource [KERNEL.63]
*/
BOOL FreeResource(HANDLE hResData)
{
fprintf(stderr,"FreeResource: %d\n", hResData);
return ;
}
/********************************************************************** /**********************************************************************
* RSC_LoadResource * RSC_LoadResource
...@@ -317,10 +344,13 @@ RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret) ...@@ -317,10 +344,13 @@ RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret)
{ {
return 0; return 0;
} }
else if (OpenResourceFile(instance) < 0)
return 0;
/* /*
* Get resource by ordinal * Get resource by ordinal
*/ */
else if (((int) rsc_name & 0xffff0000) == 0) if (((int) rsc_name & 0xffff0000) == 0)
{ {
size_shift = FindResourceByNumber(&nameinfo, type, size_shift = FindResourceByNumber(&nameinfo, type,
(int) rsc_name | 0x8000); (int) rsc_name | 0x8000);
...@@ -338,7 +368,7 @@ RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret) ...@@ -338,7 +368,7 @@ RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret)
/* /*
* Read resource. * Read resource.
*/ */
lseek(CurrentNEFile, ((int) nameinfo.offset << size_shift), SEEK_SET); lseek(ResourceFd, ((int) nameinfo.offset << size_shift), SEEK_SET);
image_size = nameinfo.length << size_shift; image_size = nameinfo.length << size_shift;
if (image_size_ret != NULL) if (image_size_ret != NULL)
...@@ -346,7 +376,7 @@ RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret) ...@@ -346,7 +376,7 @@ RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret)
hmem = GlobalAlloc(GMEM_MOVEABLE, image_size); hmem = GlobalAlloc(GMEM_MOVEABLE, image_size);
image = GlobalLock(hmem); image = GlobalLock(hmem);
if (image == NULL || read(CurrentNEFile, image, image_size) != image_size) if (image == NULL || read(ResourceFd, image, image_size) != image_size)
{ {
GlobalFree(hmem); GlobalFree(hmem);
return 0; return 0;
...@@ -357,6 +387,46 @@ RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret) ...@@ -357,6 +387,46 @@ RSC_LoadResource(int instance, char *rsc_name, int type, int *image_size_ret)
} }
/********************************************************************** /**********************************************************************
* LoadString
*/
int
LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen)
{
HANDLE hmem;
int rsc_size;
unsigned char *p;
int string_num;
int i;
#ifdef DEBUG_RESOURCE
printf("LoadString: instance = %04x, id = %d, "
"buffer = %08x, length = %d\n",
instance, resource_id, buffer, buflen);
#endif
hmem = RSC_LoadResource(instance, (char *) (resource_id >> 4),
NE_RSCTYPE_STRING, &rsc_size);
if (hmem == 0)
return 0;
p = GlobalLock(hmem);
string_num = resource_id & 0x000f;
for (i = 0; i < resource_id; i++)
p += *p;
i = MIN(buflen - 1, *p);
memcpy(buffer, p + 1, i);
buffer[i] = '\0';
GlobalFree(hmem);
#ifdef DEBUG_RESOURCE
printf(" '%s'\n", buffer);
#endif
return i;
}
/**********************************************************************
* RSC_LoadMenu * RSC_LoadMenu
*/ */
HANDLE HANDLE
...@@ -403,3 +473,5 @@ LoadBitmap(HANDLE instance, LPSTR bmp_name) ...@@ -403,3 +473,5 @@ LoadBitmap(HANDLE instance, LPSTR bmp_name)
ReleaseDC( 0, hdc ); ReleaseDC( 0, hdc );
return hbitmap; return hbitmap;
} }
...@@ -47,7 +47,7 @@ unsigned short PSPSelector; ...@@ -47,7 +47,7 @@ unsigned short PSPSelector;
unsigned char ran_out = 0; unsigned char ran_out = 0;
unsigned short SelectorOwners[MAX_SELECTORS]; unsigned short SelectorOwners[MAX_SELECTORS];
static int next_unused_selector = 8; static int next_unused_selector = FIRST_SELECTOR;
extern void KERNEL_Ordinal_102(); extern void KERNEL_Ordinal_102();
extern void UNIXLIB_Ordinal_0(); extern void UNIXLIB_Ordinal_0();
......
...@@ -6,9 +6,15 @@ ...@@ -6,9 +6,15 @@
#include <syscall.h> #include <syscall.h>
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#ifdef linux
#include <linux/sched.h> #include <linux/sched.h>
#include <asm/system.h> #include <asm/system.h>
#endif
char * cstack[4096];
struct sigaction segv_act;
#ifdef linux
extern void ___sig_restore(); extern void ___sig_restore();
extern void ___masksig_restore(); extern void ___masksig_restore();
...@@ -26,33 +32,36 @@ wine_sigaction(int sig,struct sigaction * new, struct sigaction * old) ...@@ -26,33 +32,36 @@ wine_sigaction(int sig,struct sigaction * new, struct sigaction * old)
return -1; return -1;
} }
char * cstack[4096];
struct sigaction segv_act;
struct sigcontext_struct { struct sigcontext_struct {
unsigned short gs, __gsh; unsigned short sc_gs, __gsh;
unsigned short fs, __fsh; unsigned short sc_fs, __fsh;
unsigned short es, __esh; unsigned short sc_es, __esh;
unsigned short ds, __dsh; unsigned short sc_ds, __dsh;
unsigned long edi; unsigned long sc_edi;
unsigned long esi; unsigned long sc_esi;
unsigned long ebp; unsigned long sc_ebp;
unsigned long esp; unsigned long sc_esp;
unsigned long ebx; unsigned long sc_ebx;
unsigned long edx; unsigned long sc_edx;
unsigned long ecx; unsigned long sc_ecx;
unsigned long eax; unsigned long sc_eax;
unsigned long trapno; unsigned long sc_trapno;
unsigned long err; unsigned long sc_err;
unsigned long eip; unsigned long sc_eip;
unsigned short cs, __csh; unsigned short sc_cs, __csh;
unsigned long eflags; unsigned long sc_eflags;
unsigned long esp_at_signal; unsigned long esp_at_signal;
unsigned short ss, __ssh; unsigned short sc_ss, __ssh;
unsigned long i387; unsigned long i387;
unsigned long oldmask; unsigned long oldmask;
unsigned long cr2; unsigned long cr2;
}; };
#endif
#ifdef __NetBSD__
#define sigcontext_struct sigcontext
#define HZ 100
#endif
static void static void
GetTimeDate(int time_flag, struct sigcontext_struct * context) GetTimeDate(int time_flag, struct sigcontext_struct * context)
...@@ -64,15 +73,15 @@ GetTimeDate(int time_flag, struct sigcontext_struct * context) ...@@ -64,15 +73,15 @@ GetTimeDate(int time_flag, struct sigcontext_struct * context)
now = localtime(&ltime); now = localtime(&ltime);
if (time_flag) if (time_flag)
{ {
context->ecx = (now->tm_hour << 8) | now->tm_min; context->sc_ecx = (now->tm_hour << 8) | now->tm_min;
context->edx = now->tm_sec << 8; context->sc_edx = now->tm_sec << 8;
} }
else else
{ {
context->ecx = now->tm_year + 1900; context->sc_ecx = now->tm_year + 1900;
context->edx = ((now->tm_mon + 1) << 8) | now->tm_mday; context->sc_edx = ((now->tm_mon + 1) << 8) | now->tm_mday;
context->eax &= 0xff00; context->sc_eax &= 0xff00;
context->eax |= now->tm_wday; context->sc_eax |= now->tm_wday;
} }
} }
...@@ -82,12 +91,12 @@ GetTimeDate(int time_flag, struct sigcontext_struct * context) ...@@ -82,12 +91,12 @@ GetTimeDate(int time_flag, struct sigcontext_struct * context)
static int static int
do_int21(struct sigcontext_struct * context){ do_int21(struct sigcontext_struct * context){
fprintf(stderr,"Doing int21 %x ", (context->eax >> 8) & 0xff); fprintf(stderr,"Doing int21 %x ", (context->sc_eax >> 8) & 0xff);
switch((context->eax >> 8) & 0xff){ switch((context->sc_eax >> 8) & 0xff){
case 0x30: case 0x30:
context->eax = 0x0303; /* Hey folks, this is DOS V3.3! */ context->sc_eax = 0x0303; /* Hey folks, this is DOS V3.3! */
context->ebx = 0; context->sc_ebx = 0;
context->ecx = 0; context->sc_ecx = 0;
break; break;
/* Ignore any attempt to set a segment vector */ /* Ignore any attempt to set a segment vector */
...@@ -96,8 +105,8 @@ do_int21(struct sigcontext_struct * context){ ...@@ -96,8 +105,8 @@ do_int21(struct sigcontext_struct * context){
case 0x35: /* Return a NULL segment selector - this will bomb case 0x35: /* Return a NULL segment selector - this will bomb
if anyone ever tries to use it */ if anyone ever tries to use it */
context->es = 0; context->sc_es = 0;
context->ebx = 0; context->sc_ebx = 0;
break; break;
case 0x2a: case 0x2a:
...@@ -109,11 +118,11 @@ do_int21(struct sigcontext_struct * context){ ...@@ -109,11 +118,11 @@ do_int21(struct sigcontext_struct * context){
/* Function does not return */ /* Function does not return */
case 0x4c: case 0x4c:
exit(context->eax & 0xff); exit(context->sc_eax & 0xff);
default: default:
fprintf(stderr,"Unable to handle int 0x21 %x\n", context->eax); fprintf(stderr,"Unable to handle int 0x21 %x\n", context->sc_eax);
return 1; return 1;
}; };
return 1; return 1;
...@@ -124,41 +133,53 @@ do_int1A(struct sigcontext_struct * context){ ...@@ -124,41 +133,53 @@ do_int1A(struct sigcontext_struct * context){
time_t ltime; time_t ltime;
int ticks; int ticks;
switch((context->eax >> 8) & 0xff){ switch((context->sc_eax >> 8) & 0xff){
case 0: case 0:
ltime = time(NULL); ltime = time(NULL);
ticks = (int) (ltime * HZ); ticks = (int) (ltime * HZ);
context->ecx = ticks >> 16; context->sc_ecx = ticks >> 16;
context->edx = ticks & 0x0000FFFF; context->sc_edx = ticks & 0x0000FFFF;
context->eax = 0; /* No midnight rollover */ context->sc_eax = 0; /* No midnight rollover */
break; break;
default: default:
fprintf(stderr,"Unable to handle int 0x1A %x\n", context->eax); fprintf(stderr,"Unable to handle int 0x1A %x\n", context->sc_eax);
return 1; return 1;
}; };
return 1; return 1;
} }
static void win_segfault(int signal, struct sigcontext_struct context){ #ifdef linux
static void win_fault(int signal, struct sigcontext_struct context){
struct sigcontext_struct *scp = &context;
#else
static void win_fault(int signal, int code, struct sigcontext *scp){
#endif
unsigned char * instr; unsigned char * instr;
unsigned char intno; unsigned char intno;
unsigned int * dump; unsigned int * dump;
int i; int i;
/* First take care of a few preliminaries */ /* First take care of a few preliminaries */
#ifdef linux
if(signal != SIGSEGV) exit(1); if(signal != SIGSEGV) exit(1);
if((context.cs & 7) != 7){ if((scp->sc_cs & 7) != 7){
#endif
#ifdef __NetBSD__
/* set_es(0x27); set_ds(0x27); */
if(signal != SIGBUS) exit(1);
if(scp->sc_cs == 0x1f){
#endif
fprintf(stderr, fprintf(stderr,
"Segmentation fault in Wine program (%x:%x)." "Segmentation fault in Wine program (%x:%x)."
" Please debug\n", " Please debug\n",
context.cs, context.eip); scp->sc_cs, scp->sc_eip);
goto oops; goto oops;
}; };
/* Now take a look at the actual instruction where the program /* Now take a look at the actual instruction where the program
bombed */ bombed */
instr = (char *) ((context.cs << 16) | (context.eip & 0xffff)); instr = (char *) ((scp->sc_cs << 16) | (scp->sc_eip & 0xffff));
if(*instr != 0xcd) { if(*instr != 0xcd) {
fprintf(stderr, fprintf(stderr,
...@@ -175,10 +196,10 @@ static void win_segfault(int signal, struct sigcontext_struct context){ ...@@ -175,10 +196,10 @@ static void win_segfault(int signal, struct sigcontext_struct context){
intno = *instr; intno = *instr;
switch(intno){ switch(intno){
case 0x21: case 0x21:
if(!do_int21(&context)) goto oops; if(!do_int21(scp)) goto oops;
break; break;
case 0x1A: case 0x1A:
if(!do_int1A(&context)) goto oops; if(!do_int1A(scp)) goto oops;
break; break;
default: default:
fprintf(stderr,"Unexpected Windows interrupt %x\n", intno); fprintf(stderr,"Unexpected Windows interrupt %x\n", intno);
...@@ -187,13 +208,16 @@ static void win_segfault(int signal, struct sigcontext_struct context){ ...@@ -187,13 +208,16 @@ static void win_segfault(int signal, struct sigcontext_struct context){
/* OK, done handling the interrupt */ /* OK, done handling the interrupt */
context.eip += 2; /* Bypass the int instruction */ scp->sc_eip += 2; /* Bypass the int instruction */
return; return;
oops: oops:
fprintf(stderr,"In win_segfault %x:%x\n", context.cs, context.eip); fprintf(stderr,"In win_fault %x:%x\n", scp->sc_cs, scp->sc_eip);
fprintf(stderr,"Stack: %x:%x\n", context.ss, context.esp_at_signal); #ifdef linux
dump = (int*) &context; wine_debug(scp); /* Enter our debugger */
#else
fprintf(stderr,"Stack: %x:%x\n", scp->sc_ss, scp->sc_esp);
dump = (int*) scp;
for(i=0; i<22; i++) for(i=0; i<22; i++)
{ {
fprintf(stderr," %8.8x", *dump++); fprintf(stderr," %8.8x", *dump++);
...@@ -202,15 +226,37 @@ static void win_segfault(int signal, struct sigcontext_struct context){ ...@@ -202,15 +226,37 @@ static void win_segfault(int signal, struct sigcontext_struct context){
} }
fprintf(stderr,"\n"); fprintf(stderr,"\n");
exit(1); exit(1);
#endif
} }
int int
init_wine_signals(){ init_wine_signals(){
segv_act.sa_handler = (__sighandler_t) win_segfault; #ifdef linux
segv_act.sa_handler = (__sighandler_t) win_fault;
/* Point to the top of the stack, minus 4 just in case, and make /* Point to the top of the stack, minus 4 just in case, and make
it aligned */ it aligned */
segv_act.sa_restorer = segv_act.sa_restorer =
(void (*)()) (((unsigned int)(cstack + sizeof(cstack) - 4)) & ~3); (void (*)()) (((unsigned int)(cstack + sizeof(cstack) - 4)) & ~3);
wine_sigaction(SIGSEGV, &segv_act, NULL); wine_sigaction(SIGSEGV, &segv_act, NULL);
#endif
#ifdef __NetBSD__
struct sigstack ss;
sigset_t sig_mask;
ss.ss_sp = (char *) (((unsigned int)(cstack + sizeof(cstack) - 4)) & ~3);
ss.ss_onstack = 0;
if (sigstack(&ss, NULL) < 0) {
perror("sigstack");
exit(1);
}
sigemptyset(&sig_mask);
segv_act.sa_handler = (__sighandler_t) win_fault;
segv_act.sa_flags = SA_ONSTACK;
segv_act.sa_mask = sig_mask;
if (sigaction(SIGBUS, &segv_act, NULL) < 0) {
perror("sigaction");
exit(1);
}
#endif
} }
...@@ -63,8 +63,38 @@ myerror(const char *s) ...@@ -63,8 +63,38 @@ myerror(const char *s)
exit(1); exit(1);
} }
/**********************************************************************
* GetFilenameFromInstance
*/
char *
GetFilenameFromInstance(unsigned short instance)
{
register struct w_files *w = wine_files;
while (w && w->hinstance != instance)
w = w->next;
if (w)
return w->filename;
else
return NULL;
}
/* Load one NE format executable into memory */ struct w_files *
GetFileInfo(unsigned short instance)
{
register struct w_files *w = wine_files;
while (w && w->hinstance != instance)
w = w->next;
return w;
}
/**********************************************************************
* LoadImage
* Load one NE format executable into memory
*/
LoadImage(char * filename, char * modulename) LoadImage(char * filename, char * modulename)
{ {
unsigned int read_size; unsigned int read_size;
...@@ -143,6 +173,9 @@ LoadImage(char * filename, char * modulename) ...@@ -143,6 +173,9 @@ LoadImage(char * filename, char * modulename)
if (read(wpnt->fd, wpnt->seg_table, read_size) != read_size) if (read(wpnt->fd, wpnt->seg_table, read_size) != read_size)
myerror("Unable to read segment table header from file"); myerror("Unable to read segment table header from file");
wpnt->selector_table = CreateSelectors(wpnt); wpnt->selector_table = CreateSelectors(wpnt);
wpnt->hinstance
= wpnt->
selector_table[wine_files->ne_header->auto_data_seg-1].selector;
/* Get the lookup table. This is used for looking up the addresses /* Get the lookup table. This is used for looking up the addresses
of functions that are exported */ of functions that are exported */
......
CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR) CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR)
OBJS=dos.o kernel.o user.o xt.o rect.o file.o sound.o emulate.o \ OBJS=dos.o kernel.o user.o xt.o rect.o file.o sound.o emulate.o \
keyboard.o profile.o keyboard.o profile.o lstr.o
default: misc.o default: misc.o
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <string.h> #include <string.h>
#include <limits.h> #include <limits.h>
#define OPEN_MAX 256
/*************************************************************************** /***************************************************************************
This structure stores the infomation needed for a single DOS drive This structure stores the infomation needed for a single DOS drive
***************************************************************************/ ***************************************************************************/
......
...@@ -11,6 +11,8 @@ int ToAscii(WORD wVirtKey, WORD wScanCode, LPSTR lpKeyState, ...@@ -11,6 +11,8 @@ int ToAscii(WORD wVirtKey, WORD wScanCode, LPSTR lpKeyState,
return -1; return -1;
} }
#ifdef BOGUS_ANSI_OEM
int AnsiToOem(LPSTR lpAnsiStr, LPSTR lpOemStr) int AnsiToOem(LPSTR lpAnsiStr, LPSTR lpOemStr)
{ {
printf("AnsiToOem (%s)\n",lpAnsiStr); printf("AnsiToOem (%s)\n",lpAnsiStr);
...@@ -25,6 +27,8 @@ BOOL OemToAnsi(LPSTR lpOemStr, LPSTR lpAnsiStr) ...@@ -25,6 +27,8 @@ BOOL OemToAnsi(LPSTR lpOemStr, LPSTR lpAnsiStr)
return -1; return -1;
} }
#endif
DWORD OemKeyScan(WORD wOemChar) DWORD OemKeyScan(WORD wOemChar)
{ {
printf("*OemKeyScan (%d)\n",wOemChar); printf("*OemKeyScan (%d)\n",wOemChar);
...@@ -84,6 +88,8 @@ int GetKeyNameText(LONG lParam, LPSTR lpBuffer, int nSize) ...@@ -84,6 +88,8 @@ int GetKeyNameText(LONG lParam, LPSTR lpBuffer, int nSize)
return 0; return 0;
} }
#ifdef BOGUS_ANSI_OEM
void AnsiToOemBuff(LPSTR lpAnsiStr, LPSTR lpOemStr, int nLength) void AnsiToOemBuff(LPSTR lpAnsiStr, LPSTR lpOemStr, int nLength)
{ {
printf("AnsiToOemBuff(%s,<ptr>,%d)\n",lpAnsiStr,nLength); printf("AnsiToOemBuff(%s,<ptr>,%d)\n",lpAnsiStr,nLength);
...@@ -96,6 +102,7 @@ void OemToAnsiBuff(LPSTR lpOemStr, LPSTR lpAnsiStr, int nLength) ...@@ -96,6 +102,7 @@ void OemToAnsiBuff(LPSTR lpOemStr, LPSTR lpAnsiStr, int nLength)
strncpy(lpAnsiStr,lpOemStr,nLength); /* should translate... */ strncpy(lpAnsiStr,lpOemStr,nLength); /* should translate... */
} }
#endif
......
static char Copyright[] = "Copyright Yngvi Sigurjonsson (yngvi@hafro.is), 1993";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <fcntl.h>
#include "prototypes.h"
#include "regfunc.h"
#include "windows.h"
#define LPCSTR LPSTR /* I think this should be const char **/
typedef unsigned short UINT;
/* Funny to divide them between user and kernel. */
/* KERNEL.89 */
LPSTR lstrcat(LPSTR target,LPCSTR source)
{
fprintf(stderr,"lstrcat(%s,%s)\n",target,source);
return strcat(target,source);
}
/* USER.430 */
int lstrcmp(LPCSTR str1,LPCSTR str2)
{
return strcmp(str1,str2);
}
/* USER.471 */
int lstrcmpi(LPCSTR str1,LPCSTR str2)
{
int i;
i=0;
while((toupper(str1[i])==toupper(str2[i]))&&(str1[i]!=0))
i++;
return toupper(str1[i])-toupper(str2[i]);
}
/* KERNEL.88 */
LPSTR lstrcpy(LPSTR target,LPCSTR source)
{
return strcpy(target,source);
}
/* KERNEL.353 */
LPSTR lstrcpyn(LPSTR target,LPCSTR source,int n)
{
return strncpy(target,source,n);
}
/* KERNEL.90 */
int lstrlen(LPCSTR str)
{
strlen(str);
}
/* AnsiUpper USER.431 */
char FAR* AnsiUpper(char FAR* strOrChar)
{
/* I am not sure if the locale stuff works with toupper, but then again
I am not sure if the Linux libc locale stuffs works at all */
if((int)strOrChar<256)
return (char FAR*) toupper((int)strOrChar);
else {
int i;
for(i=0;(i<65536)&&strOrChar[i];i++)
strOrChar[i]=toupper(strOrChar[i]);
return strOrChar;
}
}
/* AnsiLower USER.432 */
char FAR* AnsiLower(char FAR* strOrChar)
{
/* I am not sure if the locale stuff works with tolower, but then again
I am not sure if the Linux libc locale stuffs works at all */
if((int)strOrChar<256)
return (char FAR*)tolower((int)strOrChar);
else {
int i;
for(i=0;(i<65536)&&strOrChar[i];i++)
strOrChar[i]=tolower(strOrChar[i]);
return strOrChar;
}
}
/* AnsiUpperBuff USER.437 */
UINT AnsiUpperBuff(LPSTR str,UINT len)
{
int i;
len=(len==0)?65536:len;
for(i=0;i<len;i++)
str[i]=toupper(str[i]);
return i;
}
/* AnsiLowerBuff USER.438 */
UINT AnsiLowerBuff(LPSTR str,UINT len)
{
int i;
len=(len==0)?65536:len;
i=0;
for(i=0;i<len;i++)
str[i]=tolower(str[i]);
return i;
}
/* AnsiNext USER.472 */
LPSTR AnsiNext(LPCSTR current)
{
return (*current)?current+1:current;
}
/* AnsiPrev USER.473 */
char FAR* AnsiPrev(/*const*/ char FAR* start,char FAR* current)
{
return (current==start)?start:current-1;
}
/* IsCharAlpha USER 433 */
BOOL IsCharAlpha(char ch)
{
return isalpha(ch); /* This is probably not right for NLS */
}
/* IsCharAlphanumeric USER 434 */
BOOL IsCharAlphanumeric(char ch)
{
return (ch<'0')?0:(ch<'9');
}
/* IsCharUpper USER 435 */
BOOL IsCharUpper(char ch)
{
return isupper(ch);
}
/* IsCharUpper USER 436 */
BOOL IsCharLower(char ch)
{
return islower(ch);
}
static char Oem2Ansi[256];
static char Ansi2Oem[256];
void InitOemAnsiTranslations()
{
static int inited=0; /* should called called in some init function*/
int transfile,i;
if(inited) return;
if(transfile=open("oem2ansi.trl",O_RDONLY)){
read(transfile,Oem2Ansi,256);
close(transfile);
}
else { /* sets up passive translations if it does not find the file */
for(i=0;i<256;i++) /* Needs some fixing */
Oem2Ansi[i]=i;
}
if(transfile=open("ansi2oem.trl",O_RDONLY)){
read(transfile,Ansi2Oem,256);
close(transfile);
}
else { /* sets up passive translations if it does not find the file */
for(i=0;i<256;i++) /* Needs some fixing */
Ansi2Oem[i]=i;
}
inited=1;
}
/* AnsiToOem Keyboard.5 */
int AnsiToOem(LPSTR lpAnsiStr, LPSTR lpOemStr) /* why is this int ??? */
{
InitOemAnsiTranslations(); /* should called called in some init function*/
while(*lpAnsiStr){
*lpOemStr++=Ansi2Oem[*lpAnsiStr++];
}
return -1;
}
/* OemToAnsi Keyboard.6 */
BOOL OemToAnsi(LPSTR lpOemStr, LPSTR lpAnsiStr) /* why is this BOOL ???? */
{
InitOemAnsiTranslations(); /* should called called in some init function*/
while(*lpOemStr){
*lpAnsiStr++=Oem2Ansi[*lpOemStr++];
}
return -1;
}
/* AnsiToOemBuff Keyboard.134 */
void AnsiToOemBuff(LPSTR lpAnsiStr, LPSTR lpOemStr, int nLength)
{
int i;
InitOemAnsiTranslations(); /* should called called in some init function*/
for(i=0;i<nLength;i++)
lpOemStr[i]=Ansi2Oem[lpAnsiStr[i]];
}
/* OemToAnsi Keyboard.135 */
void OemToAnsiBuff(LPSTR lpOemStr, LPSTR lpAnsiStr, int nLength)
{
int i;
InitOemAnsiTranslations(); /* should called called in some init function*/
for(i=0;i<nLength;i++)
lpAnsiStr[i]=Oem2Ansi[lpOemStr[i]];
}
static char RCSId[] = "$Id: profile.c,v 1.1 1993/09/13 16:42:32 scott Exp $"; /*
static char Copyright[] = "Copyright Alexandre Julliard, 1993"; * Initialization-File Functions.
*
* Copyright (c) 1993 Miguel de Icaza
*
*/
#include "prototypes.h" static char Copyright [] = "Copyright (C) 1993 Miguel de Icaza";
#include <stdio.h>
#include <string.h>
#include "windows.h" #include "windows.h"
#define INIFILE "win.ini"
#define STRSIZE 255
#define xmalloc(x) malloc(x)
#define overflow (next == &CharBuffer [STRSIZE-1])
enum { FirstBrace, OnSecHeader, IgnoreToEOL, KeyDef, KeyValue };
typedef struct TKeys {
char *KeyName;
char *Value;
struct TKeys *link;
} TKeys;
typedef struct TSecHeader {
char *AppName;
TKeys *Keys;
struct TSecHeader *link;
} TSecHeader;
typedef struct TProfile {
char *FileName;
TSecHeader *Section;
struct TProfile *link;
} TProfile;
TProfile *Current = 0;
TProfile *Base = 0;
static TSecHeader *is_loaded (char *FileName)
{
TProfile *p = Base;
while (p){
if (!strcasecmp (FileName, p->FileName)){
Current = p;
return p->Section;
}
p = p->link;
}
return 0;
}
static TSecHeader *load (char *file)
{
FILE *f;
int state;
TSecHeader *SecHeader = 0;
char CharBuffer [STRSIZE];
char *next;
char c;
if ((f = fopen (file, "r"))==NULL)
return NULL;
state = FirstBrace;
while ((c = getc (f)) != EOF){
if (c == '\r') /* Ignore Carriage Return */
continue;
switch (state){
case OnSecHeader:
if (c == ']' || overflow){
*next = '\0';
next = CharBuffer;
SecHeader->AppName = strdup (CharBuffer);
state = IgnoreToEOL;
} else
*next++ = c;
break;
case IgnoreToEOL:
if (c == '\n'){
state = KeyDef;
next = CharBuffer;
}
break;
case FirstBrace:
case KeyDef:
if (c == '['){
TSecHeader *temp;
temp = SecHeader;
SecHeader = (TSecHeader *) xmalloc (sizeof (TSecHeader));
SecHeader->link = temp;
SecHeader->Keys = 0;
state = OnSecHeader;
next = CharBuffer;
break;
}
if (state == FirstBrace) /* On first pass, don't allow dangling keys */
break;
if (c == ' ' || c == '\t')
break;
if (c == '\n' || overflow) /* Abort Definition */
next = CharBuffer;
if (c == '=' || overflow){
TKeys *temp;
temp = SecHeader->Keys;
*next = '\0';
SecHeader->Keys = (TKeys *) xmalloc (sizeof (TKeys));
SecHeader->Keys->link = temp;
SecHeader->Keys->KeyName = strdup (CharBuffer);
state = KeyValue;
next = CharBuffer;
} else
*next++ = c;
break;
case KeyValue:
if (overflow || c == '\n'){
*next = '\0';
SecHeader->Keys->Value = strdup (CharBuffer);
state = c == '\n' ? KeyDef : IgnoreToEOL;
next = CharBuffer;
#ifdef DEBUG
printf ("[%s] (%s)=%s\n", SecHeader->AppName,
SecHeader->Keys->KeyName, SecHeader->Keys->Value);
#endif
} else
*next++ = c;
break;
} /* switch */
} /* while ((c = getc (f)) != EOF) */
return SecHeader;
}
static new_key (TSecHeader *section, char *KeyName, char *Value)
{
TKeys *key;
key = (TKeys *) xmalloc (sizeof (TKeys));
key->KeyName = strdup (KeyName);
key->Value = strdup (Value);
key->link = section->Keys;
section->Keys = key;
}
static short GetSetProfile (int set, LPSTR AppName, LPSTR KeyName,
LPSTR Default, LPSTR ReturnedString, short Size,
LPSTR FileName)
{
TProfile *New;
TSecHeader *section;
TKeys *key;
if (!(section = is_loaded (FileName))){
New = (TProfile *) xmalloc (sizeof (TProfile));
New->link = Base;
New->FileName = strdup (FileName);
New->Section = load (FileName);
Base = New;
section = New->Section;
Current = New;
}
/* Start search */
for (; section; section = section->link){
if (strcasecmp (section->AppName, AppName))
continue;
for (key = section->Keys; key; key = key->link){
if (strcasecmp (key->KeyName, KeyName))
continue;
if (set){
free (key->Value);
key->Value = strdup (Default);
return 1;
}
ReturnedString [Size-1] = 0;
strncpy (ReturnedString, key->Value, Size-1);
return 1;
}
/* If Getting the information, then don't write the information
to the INI file, need to run a couple of tests with windog */
/* No key found */
if (set)
new_key (section, KeyName, Default);
else {
ReturnedString [Size-1] = 0;
strncpy (ReturnedString, Default, Size-1);
}
return 1;
}
/* Non existent section */
if (set){
section = (TSecHeader *) xmalloc (sizeof (TSecHeader));
section->AppName = strdup (AppName);
section->Keys = 0;
new_key (section, KeyName, Default);
section->link = Current->Section;
Current->Section = section;
} else {
ReturnedString [Size-1] = 0;
strncpy (ReturnedString, Default, Size-1);
}
return 1;
}
short GetPrivateProfileString (LPSTR AppName, LPSTR KeyName,
LPSTR Default, LPSTR ReturnedString,
short Size, LPSTR FileName)
{
return (GetSetProfile (0, AppName, KeyName, Default, ReturnedString, Size, FileName));
}
int GetProfileString (LPSTR AppName, LPSTR KeyName, LPSTR Default,
LPSTR ReturnedString, int Size)
{
return GetPrivateProfileString (AppName, KeyName, Default,
ReturnedString, Size, INIFILE);
}
WORD GetPrivateProfileInt (LPSTR AppName, LPSTR KeyName, short Default,
LPSTR File)
{
static char IntBuf [5];
static char buf [5];
sprintf (buf, "%d", Default);
/* Check the exact semantic with the SDK */
GetPrivateProfileString (AppName, KeyName, buf, IntBuf, 5, File);
if (!strcasecmp (IntBuf, "true"))
return 1;
if (!strcasecmp (IntBuf, "yes"))
return 1;
return atoi (IntBuf);
}
WORD GetPrivateProfileInt( LPSTR section, LPSTR entry, WORD GetProfileInt (LPSTR AppName, LPSTR KeyName, int Default)
short defval, LPSTR filename )
{ {
printf( "GetPrivateProfileInt: %s %s %d %s\n", section, entry, defval, filename ); return GetPrivateProfileInt (AppName, KeyName, Default, INIFILE);
return defval;
} }
short GetPrivateProfileString( LPSTR section, LPSTR entry, LPSTR defval, BOOL WritePrivateProfileString (LPSTR AppName, LPSTR KeyName, LPSTR String,
LPSTR buffer, short count, LPSTR filename ) LPSTR FileName)
{ {
printf( "GetPrivateProfileString: %s %s %s %d %s\n", section, entry, defval, count, filename ); return GetSetProfile (1, AppName, KeyName, String, "", 0, FileName);
strncpy( buffer, defval, count );
buffer[count-1] = 0;
return strlen(buffer);
} }
BOOL WriteProfileString (LPSTR AppName, LPSTR KeyName, LPSTR String)
{
return (WritePrivateProfileString (AppName, KeyName, String, INIFILE));
}
WORD GetProfileInt( LPSTR lpAppName, LPSTR lpKeyName, int nDefault) static void dump_keys (FILE *profile, TKeys *p)
{ {
printf("GetProfileInt: %s %s %d\n",lpAppName,lpKeyName,nDefault); if (!p)
return nDefault; return;
dump_keys (profile, p->link);
fprintf (profile, "%s=%s\r\n", p->KeyName, p->Value);
} }
int GetProfileString(LPSTR lpAppName, LPSTR lpKeyName, LPSTR lpDefault, static void dump_sections (FILE *profile, TSecHeader *p)
LPSTR lpReturnedString, int nSize)
{ {
printf( "GetProfileString: %s %s %s %d \n", lpAppName,lpKeyName, if (!p)
lpDefault, nSize ); return;
strncpy( lpReturnedString,lpDefault,nSize ); dump_sections (profile, p->link);
lpReturnedString[nSize-1] = 0; fprintf (profile, "\r\n[%s]\r\n", p->AppName);
return strlen(lpReturnedString); dump_keys (profile, p->Keys);
}
static void dump_profile (TProfile *p)
{
FILE *profile;
if (!p)
return;
dump_profile (p->link);
if ((profile = fopen (p->FileName, "w")) != NULL){
dump_sections (profile, p->Section);
fclose (profile);
}
}
void sync_profiles ()
{
dump_profile (Base);
}
#ifdef DUMBTEST
main ()
{
char r [100], app [100], key [100], valor [100];
while (1){
printf ("Dame, Aplicacion, llave\n");
gets (app);
if (!app [0]){
sync_profiles ();
return;
}
gets (key);
gets (valor);
GetProfileString (app, key, "1No_Encontrado", r, sizeof (r));
printf ("(%d)\n", GetProfileInt (app, key, 5));
printf ("%s\n", r);
WriteProfileString (app, key, valor);
}
} }
#endif
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment