home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 9
/
FreshFishVol9-CD2.bin
/
bbs
/
util
/
snoopdos-3.0.lha
/
SnoopDos
/
Source
/
SnoopDos.Roadmap
< prev
next >
Wrap
Text File
|
1994-09-17
|
18KB
|
385 lines
SnoopDos 3.0 -- Source Code Roadmap
Copyright © Eddy Carroll, September 1994. Freely distributable.
INTRODUCTION
SnoopDos was written using SAS/C 6.51. The Amiga programming community
owe a large debt of thanks to Doug Walker, Steve Krueger, Jim Cooper,
and everyone else at SAS Institute for providing such a useful and
stable development environment. Without SAS/C, development of SnoopDos
would have taken significantly longer.
If you have SAS/C, then you should be able to recompile SnoopDos with
no problems by simply typing "smake" in this directory. You might want
to turn off optimisation in the SCOPTIONS file if you are experimenting;
otherwise, prepare for a long wait.
If you are using DICE or another compiler, you will need to ensure that
you are using similar compiler options to those listed in SCOPTIONS. You
will also need to change the function prototypes in patches.h and perhaps
in patches.c. A future release may detect DICE automatically and do the
right thing.
In general, most files have an initialisation function and all have a
cleanup function. The initialisation function should be called at the
beginning of the code and the cleanup function at the end. All cleanup
functions are safe to call multiple times if necessary.
Note that all the source code has been formatted with a tab setting of
4 spaces. If your editor uses tabs set to some other width, then it is
strongly recommended that you run the code through Detab or a similar
utility, otherwise it will look a mess.
MODULE OVERVIEW
---------------
Here's a summary of the different files and what they are used for:
system.h Master include file for all system headers
system.c Includes system.h -- used to create the GST file
snoopdos.h Defines all program globals, structures, constants, protos
snoopdos.c Top level module. Initialises and cleans up other modules
buffer.c Allocates and formats events in the event buffer
language.c Makes localised text strings available to other modules
snooptext.h Master message include file used by all modules
patches.c All the patch code inserted into system libraries
patches.h Header file that prototypes all the patched functions
patchcode.s Low-level assembly code used by patch mechanism
settings.c Handles the command line interface to SnoopDos
gui.h Constants which define the exact appearance of the GUI
mainwin.c All functions relating to the main window
subwin.c All functions relating to the other three windows
miscwin.c Miscellaneous window and screen functions used everywhere
hotkey.c Handles commodity interface + Workbench AppIcon/Toolmenu
icon.h Image data for custom SnoopDos icon (from IconEdit)
snooptext.cd SnoopDos catalog description file, for localisation
snooptext.ct Example SnoopDos translation file, for localisation
testcalls.c Separate utility to stress test the SnoopDos patch code.
MODULE GUIDE
------------
Here's a more detailed look at the contents of each module. See the module
itself for full details.
SYSTEM.H
SYSTEM.C
System.h is the master include file for all Amiga system includes. Any
system include used by any module is placed in here. The entire set of
includes is then precompiled into a SAS/C GST file, which greatly speeds
up compilation.
System.c is the file used to generate the GST -- it simply includes
the System.h header file.
SNOOPDOS.H
SnoopDos.h is included by all other modules. It defines all the global
variables, structures, and prototypes used by SnoopDos. It also includes
the default program settings. Global variables with initial values are
defined when this file is included by SnoopDos.c, and declared when it's
included by other modules. Thus, if you change the initial value of
any global variables, SnoopDos.c must be recompiled (the makefile does
this automatically).
SNOOPDOS.C
SnoopDos.c is the top level module. It opens all the necessary libraries,
and calls the initialisation routines of most of the other modules. It is
also responsible for keeping the global program settings up to date. The
most important functions are:
Cleanup() Calls cleanup function of each module and exits
OpenLibs() Opens all libraries needed by SnoopDos
mysprintf() Re-entrant version of sprintf() library function
InstallSettings() Updates subset of global settings with new values
MainLoop() Waits for incoming events and dispatches them
main() Entry point for whole program.
BUFFER.C
Buffer.c contains all the functions that deal directly with the SnoopDos
event buffer. An "event" contains all the information needed to create a
single line of output in the SnoopDos window. Here are the most important
functions:
InitBuffer() Must be called at start of program
CleanupBuffers() Called when program exits
SetTotalBufferSize() Changes buffer size (allocating one if needed)
ClearBuffer() Empties buffer contents
GetNewEvent() Allocates space for a new event
ParseFormatString() Converts "%d %s %p" into an internal format
BuildFormatString() Converts internal format back to ascii string
FormatEvent() Creates a formatted output line from an event
UnderlineTitles() Creates an underline string for current titles
CheckSegTracker() Called regularly to see if SegTracker is loaded
LANGUAGE.C
SNOOPTEXT.H
Language.c deals with all the text strings used by SnoopDos. Specifically,
it identifies the users locale and decides whether to use the strings
hard-coded in the executable, or to read them from an external catalog
file instead. The main functions are:
InitTextTable() Called first. Creates default (english) string table
InitLocale() Checks for external catalog files
CleanupLocale() Frees any resources used by localisation
Snooptext.h is generated automatically from SnoopText.cd by Commodore's
CATCOMP utility. It defines a unique numeric identifier for each string,
and (when included by language.c) the strings themselves. It should never
be edited by hand. It's included in the archive for the convenience of
those who don't have CatComp.
PATCHES.C
PATCHES.H
PATCHCODE.S
Patches.c is the backbone of SnoopDos -- it contains all the patch
routines that intercept calls made by other programs to various system
functions. Most of the functions in this file must be completely
re-entrant, since they can be called by many processes simultaneously.
The most important functions are:
InitPatches() Initialises the memory-resident patch code
UpdatePatches() Attempts to install or remove all patches as needed
LoadFuncSettings() Updates patches to reflect function settings
CleanupPatches() Removes all patches (waiting until it's safe)
UpdateDeviceList() Builds list of currently mounted DOS devices
InitRamLibPatch() Fixes a bug in ramlib that can crash SnoopDos
BackgroundProcCode() Background task for pattern matching/name expansion
SetPattern() Parses the current AmigaDOS task match pattern
CreateEvent() Creates a new event, filling in various fields
HandlePaused() Puts a task to sleep when Pause is enabled
JumpOrigFunc() A macro that exits by calling the original function
Patches.h contains the prototypes for all the functions that are patched.
Each prototype defines the registers passed, along with a base register
in A6. The LVO offsets for each function are also defined here.
Patchcode.s contains the low-level assembly language patch code which is
used for each function. The same piece of code is copied multiple times
to create a unique patch for each function. Whenever any cha