[comp.sys.mac.programmer] Writing INITs

mm3d+@andrew.cmu.edu (Matt McNally) (11/09/88)

     I've been asked to investigate the possibilities of using
an INIT on the Macintosh end of our 'Transparent Backup and Mail
Facilities' project for the college.   For example: Is it reasonable
to install an INIT (patched into ???) that will poll a Unix
server, using AppleTalk protecalls to a CAP based deamon?  A
typical usage might be to have the INIT polling the users account
for the existence of mail, and presenting a dialog box on the
Macintosh if mail exists on the Unix machine.

     I would be greatly appreciative of any leads that relate to
the implementation of INITs.  Has Tech Note 14 been updated recently?
Does anyone know of any available source code for INITs?

Any comments welcome,

--matt


==========================================================================
Matt McNally  Macintosh Dugan/Programmer - Macintosh II Project
              Carnegie Mellon,  College of Humanities and Social Sciences
              mm3d@andrew.cmu.edu
==========================================================================

jln@eecs.nwu.edu (John Norstad) (11/10/88)

Matt McNally writes:

>     I've been asked to investigate the possibilities of using
>an INIT on the Macintosh end of our 'Transparent Backup and Mail
>Facilities' project for the college.   For example: Is it reasonable
>to install an INIT (patched into ???) that will poll a Unix
>server, using AppleTalk protecalls to a CAP based deamon?  A
>typical usage might be to have the INIT polling the users account
>for the existence of mail, and presenting a dialog box on the
>Macintosh if mail exists on the Unix machine.

Yes, this is possible.  One way to do it would be to write an INIT that 
installs a VBL task.  The VBL task would wake up periodically and send
a message to the deamon, using AppleTalk asychronous calls with completion 
routines.  The VBL task can notify the user via the Notification Manager
if/when the deamon tells it that mail is available.  (The Notification
Manager requires system software 6.0 or later).  No patches are necessary.

Another way to accomplish the same goal would be to have the deamon do
the polling, and send a message to the Mac when new mail arrives.  The
Mac doesn't poll at all in this scheme.  In this case you'd write an 
INIT that installs a "listener" in the system heap.  In this context
a "listener" is an ATP GetRequest completion routine that waits for
a message to arrive on a designated socket, and notifies the user with
the Notification manager.  (Not to be confused with AppleTalk "socket
listeners").  Again, no patches are required.  The INIT
would issue the first ATP GetRequest call asynchronously, with the
system heap listener specified as the completion routine.  

One complication is that completion routines are register-based, so
you have to write them in assembler, or at least write some assembly
language glue.

>     I would be greatly appreciative of any leads that relate to
>the implementation of INITs.  Has Tech Note 14 been updated recently?
>Does anyone know of any available source code for INITs?

Writing INITs isn't difficult.  I use MPW, and have found everything
I needed to know in Inside Mac, the tech notes, the MPW manuals, and
Joel West's excellent book "Programming with Macintosh Programmer's
Workshop".  For info on AppleTalk you'll probably also want to read
"Inside AppleTalk".

Tech note 14 is now obsolete.  It says to consult the System Resource File
chapter of IM IV and the Start Manager chapter of IM V.

I'm currently working on an AppleTalk project that does some of the kinds
of things you're interested in.  I have an INIT that installs an ATP
"listener" in the system heap.  The listener is written in MPW Assembler, 
and the INIT is written in MPW C.

When I finish this project (in perhaps a month) I'll be distributing it
for free complete with source code.  If you really need it now you can
write me a note, twist my arm, and I could probably send you what 
I've got so far.  The completion routines and the INIT are done and
debugged.  All I have left is a DA that implements the user interface
to this mess, the uninteresting part :-)

John Norstad
Academic Computing and Network Services
Northwestern University

Bitnet:    jln@nuacc
Internet:  jln@nuacc.acns.nwu.edu