home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / System / SnoopDos / SnoopDos_Source / SnoopDos.Roadmap < prev    next >
Text File  |  2000-01-12  |  19KB  |  401 lines

  1.  
  2.                         SnoopDos 3.1 -- Source Code Roadmap
  3.  
  4.            Copyright © Eddy Carroll, September 1994. Freely distributable.
  5.  
  6.            Updated by Luca Longone and Massimo Tantignone in January 2000.
  7.  
  8.  
  9. NOTE ABOUT THE 3.1 UPDATE
  10.  
  11.            References to PGP in the following text are not applicable to
  12.            SnoopDos versions greater than 3.0. If you need authentication,
  13.            please write to one of the following e-mail addresses:
  14.  
  15.            llong@tin.it, hexaae@tiscalinet.it (Luca Longone)
  16.            tanti@intercom.it (Massimo Tantignone)
  17.            ecarroll@iol.ie (Eddy Carroll)
  18.  
  19.            What follows is the original roadmap text for SnoopDos 3.0,
  20.            which is also valid for the 3.1 update.
  21.  
  22.  
  23. INTRODUCTION
  24.  
  25.     SnoopDos was written using SAS/C 6.51. The Amiga programming community
  26.     owe a large debt of thanks to Doug Walker, Steve Krueger, Jim Cooper,
  27.     and everyone else at SAS Institute for providing such a useful and
  28.     stable development environment. Without SAS/C, development of SnoopDos
  29.     would have taken significantly longer.
  30.  
  31.     If you have SAS/C, then you should be able to recompile SnoopDos with
  32.     no problems by simply typing "smake" in this directory. You might want
  33.     to turn off optimisation in the SCOPTIONS file if you are experimenting;
  34.     otherwise, prepare for a long wait.
  35.  
  36.     If you are using DICE or another compiler, you will need to ensure that
  37.     you are using similar compiler options to those listed in SCOPTIONS. You
  38.     will also need to change the function prototypes in patches.h and perhaps
  39.     in patches.c. A future release may detect DICE automatically and do the
  40.     right thing.
  41.  
  42.     In general, most files have an initialisation function and all have a
  43.     cleanup function. The initialisation function should be called at the
  44.     beginning of the code and the cleanup function at the end. All cleanup
  45.     functions are safe to call multiple times if necessary.
  46.  
  47.     Note that all the source code has been formatted with a tab setting of
  48.     4 spaces. If your editor uses tabs set to some other width, then it is
  49.     strongly recommended that you run the code through Detab or a similar
  50.     utility, otherwise it will look a mess.
  51.  
  52.  
  53. MODULE OVERVIEW
  54. ---------------
  55. Here's a summary of the different files and what they are used for:
  56.  
  57.        system.h   Master include file for all system headers
  58.        system.c   Includes system.h -- used to create the GST file
  59.      snoopdos.h   Defines all program globals, structures, constants, protos
  60.      snoopdos.c   Top level module. Initialises and cleans up other modules
  61.        buffer.c   Allocates and formats events in the event buffer
  62.      language.c   Makes localised text strings available to other modules
  63.     snooptext.h   Master message include file used by all modules
  64.       patches.c   All the patch code inserted into system libraries
  65.       patches.h   Header file that prototypes all the patched functions
  66.     patchcode.s   Low-level assembly code used by patch mechanism
  67.      settings.c   Handles the command line interface to SnoopDos
  68.           gui.h   Constants which define the exact appearance of the GUI
  69.       mainwin.c   All functions relating to the main window
  70.        subwin.c   All functions relating to the other three windows
  71.       miscwin.c   Miscellaneous window and screen functions used everywhere
  72.        hotkey.c   Handles commodity interface + Workbench AppIcon/Toolmenu
  73.          icon.h   Image data for custom SnoopDos icon (from IconEdit)
  74.     snooptext.cd  SnoopDos catalog description file, for localisation
  75.     snooptext.ct  Example SnoopDos translation file, for localisation
  76.     testcalls.c   Separate utility to stress test the SnoopDos patch code.
  77.  
  78.  
  79. MODULE GUIDE
  80. ------------
  81. Here's a more detailed look at the contents of each module. See the module
  82. itself for full details.
  83.  
  84.  
  85. SYSTEM.H
  86. SYSTEM.C
  87.  
  88.     System.h is the master include file for all Amiga system includes. Any
  89.     system include used by any module is placed in here. The entire set of
  90.     includes is then precompiled into a SAS/C GST file, which greatly speeds
  91.     up compilation.
  92.  
  93.    System.c is the file used to generate the GST -- it simply includes
  94.    the System.h header file.
  95.  
  96.  
  97. SNOOPDOS.H
  98.  
  99.     SnoopDos.h is included by all other modules. It defines all the global
  100.     variables, structures, and prototypes used by SnoopDos. It also includes
  101.     the default program settings. Global variables with initial values are
  102.     defined when this file is included by SnoopDos.c, and declared when it's
  103.     included by other modules. Thus, if you change the initial value of
  104.     any global variables, SnoopDos.c must be recompiled (the makefile does
  105.     this automatically).
  106.  
  107.  
  108. SNOOPDOS.C
  109.  
  110.     SnoopDos.c is the top level module. It opens all the necessary libraries,
  111.     and calls the initialisation routines of most of the other modules. It is
  112.     also responsible for keeping the global program settings up to date. The
  113.     most important functions are:
  114.  
  115.               Cleanup()  Calls cleanup function of each module and exits
  116.              OpenLibs()  Opens all libraries needed by SnoopDos
  117.             mysprintf()  Re-entrant version of sprintf() library function
  118.       InstallSettings()  Updates subset of global settings with new values
  119.              MainLoop()  Waits for incoming events and dispatches them
  120.                  main()  Entry point for whole program.
  121.  
  122.  
  123. BUFFER.C
  124.  
  125.     Buffer.c contains all the functions that deal directly with the SnoopDos
  126.     event buffer. An "event" contains all the information needed to create a
  127.     single line of output in the SnoopDos window. Here are the most important
  128.     functions:
  129.  
  130.               InitBuffer()  Must be called at start of program
  131.           CleanupBuffers()  Called when program exits
  132.       SetTotalBufferSize()  Changes buffer size (allocating one if needed)
  133.              ClearBuffer()  Empties buffer contents
  134.              GetNewEvent()  Allocates space for a new event
  135.        ParseFormatString()  Converts "%d %s %p" into an internal format
  136.        BuildFormatString()  Converts internal format back to ascii string
  137.              FormatEvent()  Creates a formatted output line from an event
  138.          UnderlineTitles()  Creates an underline string for current titles
  139.          CheckSegTracker()  Called regularly to see if SegTracker is loaded
  140.  
  141.  
  142. LANGUAGE.C
  143. SNOOPTEXT.H
  144.  
  145.     Language.c deals with all the text strings used by SnoopDos. Specifically,
  146.     it identifies the users locale and decides whether to use the strings
  147.     hard-coded in the executable, or to read them from an external catalog
  148.     file instead. The main functions are:
  149.  
  150.         InitTextTable()  Called first. Creates default (english) string table
  151.            InitLocale()  Checks for external catalog files
  152.         CleanupLocale()  Frees any resources used by localisation
  153.  
  154.     Snooptext.h is generated automatically from SnoopText.cd by Commodore's
  155.     CATCOMP utility. It defines a unique numeric identifier for each string,
  156.     and (when included by language.c) the strings themselves. It should never
  157.     be edited by hand. It's included in the archive for the convenience of
  158.     those who don't have CatComp.
  159.  
  160.  
  161. PATCHES.C
  162. PATCHES.H
  163. PATCHCODE.S
  164.  
  165.     Patches.c is the backbone of SnoopDos -- it contains all the patch
  166.     routines that intercept calls made by other programs to various system
  167.     functions. Most of the functions in this file must be completely
  168.     re-entrant, since they can be called by many processes simultaneously.
  169.     The most important functions are:
  170.  
  171.             InitPatches()  Initialises the memory-resident patch code
  172.           UpdatePatches()  Attempts to install or remove all patches as needed
  173.        LoadFuncSettings()  Updates patches to reflect function settings
  174.          CleanupPatches()  Removes all patches (waiting until it's safe)
  175.        UpdateDeviceList()  Builds list of currently mounted DOS devices
  176.         InitRamLibPatch()  Fixes a bug in ramlib that can crash SnoopDos
  177.      BackgroundProcCode()  Background task for pattern matching/name expansion
  178.              SetPattern()  Parses the current AmigaDOS task match pattern
  179.        CreateEvent()  Creates a new event, filling in various fields
  180.       HandlePaused()  Puts a task to sleep when Pause is enabled
  181.       JumpOrigFunc()  A macro that exits by calling the original function
  182.  
  183.     Patches.h contains the prototypes for all the functions that are patched.
  184.     Each prototype defines the registers passed, along with a base register
  185.     in A6. The LVO offsets for each function are also defined here.
  186.  
  187.     Patchcode.s contains the low-level assembly language patch code which is
  188.     used for each function. The same piece of code is copied multiple times
  189.     to create a unique patch for each function. Whenever any changes are
  190.     made to this code, or to the Patch structure which contains the code and
  191.     associated data, then the corresponding structure in Patches.c must be
  192.     updated. In addition, if the stack alignment on entry to the C patches
  193.     changes, the JumpOrigFunc() and MarkCallAddr macros must be adjusted.
  194.  
  195.  
  196. SETTINGS.C
  197.  
  198.     Settings.c controls all the program settings. This includes loading and
  199.     saving settings files to disk, parsing the Workbench and CLI startup
  200.     options, and handling the ARexx interface. The important functions are:
  201.  
  202.          InitSettings()  Initialises command name table
  203.          ParseCommand()  Syntax checks a SnoopDos command line
  204.           ExecCommand()  Executes a SnoopDos command line
  205.            SaveConfig()  Writes current settings to a command file
  206.            LoadConfig()  Executes all the commands in a command file
  207.            SendRemote()  Sends a command to a background copy of SnoopDos
  208.          ShowCommands()  Prints a formatted list of SnoopDos commands
  209.      ParseStartupOpts()  Parses Workbench and CLI startup options
  210.  
  211.          InitRexxPort()  Initialises ARexx port
  212.       CleanupRexxPort()  Frees ARexx port
  213.        HandleRexxMsgs()  Handles incoming ARexx messages
  214.  
  215.  
  216. GUI.H
  217.  
  218.     Gui.h file defines constants which relate to the SnoopDos GUI. These
  219.     are mainly used to finetune the gadget layout but also include a few
  220.     keyboard-related definitions. This file is included by MAINWIN.C,
  221.     SUBWIN.C and MISCWIN.C
  222.  
  223.  
  224. MAINWIN.C
  225.  
  226.     Mainwin.c handles everything associated with the main window. It has
  227.     grown too large and should really be subdivided (again). Here are the
  228.     most important functions in the file:
  229.  
  230.           CheckForScreen()  Locates current screen (locking if necessary)
  231.             ShowSnoopDos()  Opens SnoopDos window on the current screen
  232.             HideSnoopDos()  Closes main window, help and any other windows
  233.           OpenMainWindow()  Opens main window
  234.      CreateScrollGadgets()  Creates BOOPSI scroll gadgets for main window
  235.        CreateMainGadgets()  Creates gadtools gadgets for main window
  236.          CloseMainWindow()  Closes main window
  237.        CleanupMainWindow()  Frees all resources for main window
  238.         ReOpenMainWindow()  Closes and then opens main window
  239.        RecordWindowSizes()  Records sizes of all open windows
  240.         SetMainHideState()  Enables/disables Hide gadget and window title
  241.  
  242.                InitMenus()  Initialises shortcut keys for localised menus
  243.           SetMenuOptions()  Updates boolean menu options with current settings
  244.           HandleMainMsgs()  Handles menu, gadget and keypress input
  245.          HandleNewEvents()  Outputs any new events to the main window
  246.           SetMonitorMode()  Sets monitor mode to normal, Paused or Disabled
  247.  
  248.         RedrawMainWindow()  Draws everything in main window except gadgets
  249.           DrawHeaderLine()  Draws headerline at top of screen
  250.               ShowBuffer()  Redraws the main window buffer
  251.         DrawSelectedLine()  Highlights a single line in the buffer
  252.        ClearWindowBuffer()  Erases window buffer display
  253.         ScrollHorizontal()  Efficiently scrolls window contents to left/right
  254.        UpdateMainHScroll()  Updates horizontal scroll gadget to current offset
  255.        UpdateMainVScroll()  Updates vertical scroll gadget to current position
  256.               ShowStatus()  Displays a message in the status bar
  257.             UpdateStatus()  Displays status message reflecting current state
  258.  
  259.                  OpenLog()  Opens a new logfile
  260.                 WriteLog()  Writes some text to the logfile
  261.                 CloseLog()  Closes the current logfile
  262.               SaveBuffer()  Saves current buffer contents to file/clipboard
  263.             SetLogGadget()  Selects appropriate wording for log gadget
  264.  
  265. SUBWIN.C
  266.  
  267.     Subwin.c contains all the functions needed to manage the format editor,
  268.     settings window and function window. The most important functions are:
  269.  
  270.           CleanupSubWindow()  Closes all currently open windows
  271.  
  272.         OpenSettingsWindow()  Opens settings window
  273.        CloseSettingsWindow()  Closes the settings window
  274.      CreateSettingsGadgets()  Creates font-sensitive gadgets for window
  275.         HandleSettingsMsgs()  Handles keyboard and gadget input
  276.  
  277.         OpenFunctionWindow()  Opens function window and creates gagdets
  278.      CreateFunctionGadgets()  Creates font-sensitive gadgets for window
  279.        CloseFunctionWindow()  Closes the functions window
  280.             HandleFuncMsgs()  Handles keyboard and gadget input
  281.        ResetFuncToSelected()  Handles the "All/None/Selected" function gadgets
  282.               ShowFuncOpts()  Updates display of current function settings
  283.                GetFuncName()  Returns a name matching a function ID
  284.  
  285.           OpenFormatWindow()  Creates the format editor window and gadgets
  286.          CloseFormatWindow()  Closes the format editor window
  287.        CreateFormatGadgets()  Creates font-sensitive gadgets for window
  288.           HandleFormatMsgs()  Handles gadget and keyboard input
  289.      InstallNewFormat()  Updates all windows to reflect a new format
  290.             CreateBob()  Creates a new BOB (Blitter OBject)
  291.          FreeBob()  Frees a BOB created earlier
  292.                  PickupBob()  Copies a text line into a BOB for Drag & Drop
  293.          DropBob()  Drops the text line in a new position
  294.        UpdateBob()  Moves BOB to a new osition
  295.  
  296. MISCWIN.C
  297.  
  298.     Miscwin.c contains a variety of functions related to the GUI that don't
  299.     conveniently fit anywhere else. As well as general screen and window
  300.     functions, it also handles the AmigaGuide interface, and creates the
  301.     custom images used for the file/font gadgets in the settings window.
  302.  
  303.                 InitFonts()  Initialises fonts according to system preferences
  304.               SetupScreen()  Locates a screen for SnoopDos to open on
  305.             CleanupScreen()  Frees misc info related to current screen
  306.                 ShowError()  Displays an error requester
  307.               GetResponse()  Displays a requester with multiple choices
  308.                SelectFont()  Displays ASL font requester to get a font
  309.                SelectFile()  Displays ASL file requester to get a file name
  310.            AddKeyShortcut()  Update keyboard shortcuts array for a window
  311.                MyOpenFont()  Tries to open a font, from disk or from ROM
  312.         ConvertIMsgToChar()  Converts an IntuiMsg RAWKEY event to ascii
  313.  
  314.                ShowAGuide()  Loads AmigaGuide and displays a help page
  315.             CleanupAGuide()  Shuts down AmigaGuide
  316.          HandleAGuideMsgs()  Handles incoming messages from AmigaGuide
  317.  
  318.         CreateCustomImage()  Creates a new scaled file or font image
  319.           FreeCustomImage()  Frees an image allocated earlier
  320.                ShowGadget()  Presses or releases a button gadget
  321.  
  322.  
  323. HOTKEY.C
  324. ICON.H
  325.  
  326.     Hotkey.c contains functions to handle commodity support, and interfacing
  327.     with Workbench (for AppIcon and ToolMenu support). It also deals with
  328.     icons. The important functions are:
  329.  
  330.            InstallHotKey()  Installs commodity hotkey, initialising if needed
  331.            CleanupHotKey()  Shuts down commodity exchange support
  332.         HandleHotKeyMsgs()  Handles incoming msgs from commodity exchange
  333.  
  334.           GetProgramIcon()  Finds (or creates) the SnoopDos program icon
  335.                WriteIcon()  Writes current icon to disk
  336.             CleanupIcons()  Frees any icons allocated earlier
  337.  
  338.          AddProgramToWorkbench()  Creates an AppIcon or Tools menu entry
  339.     RemoveProgramFromWorkbench()  Removes any outstanding appicons/menu items
  340.            HandleWorkbenchMsgs()  Handles incoming msgs from Workbench
  341.  
  342.     Icon.h contains the image data for the image used when writing icons to
  343.     disk if no icon could be found for the SnoopDos executable. This is
  344.     generated directly from IconEdit (set the SRC=YES tooltype), and has a
  345.     30 line header that does a few #define's to isolate IconEdit-dependent
  346.     variable names from the rest of the program.
  347.  
  348.  
  349. SNOOPTEXT.CD
  350. SNOOPTEXT.CT
  351.  
  352.     SnoopText.cd is the localisation file for SnoopDos. It contains all the
  353.     messages used throughout the program. This file is compiled by Commodore's
  354.     CatComp utility to provide SNOOPTEXT.H which is then included by all
  355.     other modules. Thus, modifying SnoopText.cd requires that everything be
  356.     recompiled from scratch.
  357.  
  358.     SnoopText.ct is a ready-to-go translation file which can be used with
  359.     CatComp to produce an external catalog file for use with SnoopDos. It
  360.     was generated automatically from SnoopText.cd using CatEdit by Rafael
  361.     D'Halleweyn and is included for the convenience of those who don't have
  362.     CatEdit to hand.
  363.  
  364.  
  365. TESTCALLS.C
  366.  
  367.     This is a completely separate program. It was written to provide a means
  368.     of stress testing SnoopDos. It is not complete, hence it is not part
  369.     of the main SnoopDos program archive. Currently, it supports all of the
  370.     system functions and a few DOS functions.
  371.  
  372.     It can be instructed to continuously call one or more of the functions
  373.     monitored by SnoopDos. Many subtle bugs were uncovered by running this
  374.     multiple times simultaneously.
  375.  
  376.  
  377. DISTRIBUTION CONDITIONS
  378. -----------------------
  379.  
  380. You may freely use portions of the SnoopDos source code in your own programs
  381. if you wish. However, if you use two or more complete functions from the
  382. SnoopDos code, you must acknowledge the origin of those functions in your
  383. documentation and source code.
  384.  
  385. You may modify the SnoopDos source code to create new versions of SnoopDos
  386. for your own use only. You may not redistribute such new versions without my
  387. explicit permission.
  388.  
  389.  
  390. FURTHER INFORMATION
  391. -------------------
  392. For additional information about the source code or algorithms used, you
  393. can contact me at:
  394.  
  395.     ecarroll@maths.tcd.ie
  396.     ecarroll@cix.compulink.co.uk
  397.  
  398. To obtain a copy of my PGP public key (used to authenticate distribution
  399. copies of SnoopDos 3.0 and above) send a message to ecarroll@maths.tcd.ie
  400. with the subject line "PGPKEY".
  401.