swight@bbn.com (Sterling Wight) (02/15/89)
I have a shell application which needs to call a set of library routines. I would like these routines to be separately linkable and replaceable, so anyone can write a different version of them without having to access the shell application itself. I have a scheme for doing this, which is quite general and free of limitations: - The library is written as a separate application. - The main entry point is declared to have a parameters which are used to communicate with the shell (operation code, address of data block, return code etc.) - loading the library: the shell opens the library application's file and reads code segment zero. from the data there, the shell can figure out how much space is needed for the A5 world of the library. The shell allocates this space as a non-relocatable block and copy the jump table's contents into it. - calling the library. The shell makes the library resource file the current one, saves a copy of A5 and then sets A5 to point to the library A5 area. The shell also copies the pointer to QD variables into this area, and updates the low-memory variable which contains the current value of A5. After all is set, a long subroutine call is made to the main entry point. On return, everything is restored. - Unloading the library. All the library segments are purged and its A5 area is freed. What I would like to hear is about possible flaws or hidden traps that might arise while implementing this scheme. If anyone has done it before (I know that the MPW shell is doing something similar) I would be glad to hear from his/her experience. In Real Life: Sterling Wight Electronic Mail: swight@labs-n.bbn.com Phone: (617) 873-2524