IMid.c
First, the filename. I supported InstallerMaker before working with VISE. While VISE allows its code resoruce extensions to be of any type, InstallerMaker requires that the type be 'IMid', thus the name of this project.
This file contains the entry point for the code resource, called main(), and is conditionally compiled for VISE and InstallerMaker, since each has a main() that is structured differently. When the application project (e.g. FTPWatcherPPC.µ) is built, neither of these main() routines are used, and this file is not even included. The application's main() is in the file main.c.
The A4/A5 issue needs to be taken care of upon entry and exit. There is also an issue with routines outside of this file referencing global data if those routines are callbacks, trap patches, etc. The comments within the file A4Globals.h does a great job of explaining this.
Conditional compilation for using QC for memory debugging is included. It is important that the API for QC be used to turn debugging on and off, rather than using the control panel u/i. This is because we can not tell the control panel to debug the code resource, but instead must select the VISE application, which does us little good.When the conditional compilation is enabled, QC is activated immeditately upon entering main(), and deactivated immediately before returning. However, A4 setting/restoring must happen before/after the activation/deactivation. We just have to assume that that code is bug free.
VISE passes main() a pointer to its control block. That pointer is not passed anywhere outside of main(), and only copies of its data used elsewhere. One of the fields in this structure is a grafPtr for the status dialog. For some reason I couldn't use this correctly, so I just assume that the status dialog is the frontmost window.
One VISE option that was investigated is "Only Store Catalog", and allows for the installer files to reside as standalone files outside of the installer archive. This is usually the case when a cd rom installer is used. This was investigated because it was hoped that the location of these files could be hacked to be the ftp server. It didn't quite work out that way, but since the code worked somewhat, it was left in but compiled out.
There are a number of points at which VISE can call a code resource. The ftp client should be called after VISE installs the dummy file. The code resource is loaded only once by VISE and is then called when appropriate. This means that initilization code is very important since globals don't automatically get reset each time that main() called. Variables declared static to a function get reinitialized, but variables static to a file do not. Because of this fact, it is possible to keep track of the state of the previous invocation of the code resource. For example, if the user canceled, and the "cancelRequestInQueue" flag is set, that flag remain set for every subsequent call of the code resource, letting us know that we should return without doing any processing.
The next step is to call the routine DoFTP() in the file main.c. When building as an application, rather than as a code resource, DoFTP() is conditionally compiled to be main(). After returning from DoFTP(), error flags are set, and an error dialog possibly displayed.
The function UnPatchExitToShell() is called. Patching ExitToShell() is necessary since all active TCP streams must be closed before exiting.
A special case of the ftp install is to look on the ftp server for a file called "Notice.txt". (The filename is hard coded.)
This file is used to indicate that an installer has become out of date. For example, when a new directory of install file is created, and a new installer built, a file called Notice.txt should be placed into the old directory. The old installer will find that file, since every installer should look for it.
If that file is not found on the server, the install continues. If the file is found, then the text from that file is displayed in a dialog box, and the user is given the opportunity to cancel the install.
The directory paths of where to search for the files is stored in the installer resource as type 'STR ', with id numbers starting at 6000. All STR resources starting at 6000 will be loaded and checked. It is possible for the notice dialog to be displayed more than once.
A sample resource is stored as id 6999.
this file last updated 19Sept96