[comp.sys.mac.programmer] Summary - INIT/cdev communication

Christopher Tate <CXT105@psuvm.psu.edu> (03/26/91)

Now that several people have pointed out to me the error of my ways in
thinking that I could keep a resource from my INIT file open at all
times, here's the suggested "most neato-keen way" to share information
between an INIT and a cdev (or an INIT and an application, or for that
matter just about anything):

Gestalt.

For people like me who don't understand what that implies, I'll summarize
chapter 3 of Inside Mac VI by saying that basically the Gestalt Manager
lets you specify a "system parameter" that other programs can query at
any time.  If you put the function that returns the parameter in the
system heap (z.B. in your INIT's code resource) then it'll stay around
until restart time.  To set up INIT/cdev communication, you allocate a
block of memory somewhere to act as a shared data space.  Then, you set
up a Gestalt selector that returns a handle to that data space.  All the
cdev has to do is ask Gestalt for that selector -- if it exists, the cdev
knows that the INIT was installed, and goes ahead and uses whatever data
it needs to.  If the selector doesn't exist, the cdev knows that the INIT
wasn't installed, and gives an appropriate error.

If the info in the data block includes things like the dirID and name of
the INIT/cdev file, the cdev can also easily write any changes in persistent
parameters back to disk for the next time the machine is restarted.

The only drawback is that the Gestalt calls require System 6.0.4 or later.

-------
Christopher Tate                           | Mercy (noun):
                                           |  The infrequent art of turning
  Bitnet: cxt105@psuvm                     |  thumbs-up on your opponent at
  Uucp:   ...!psuvax1!psuvm.bitnet!cxt105  |  the end of your rapier.

dorner@pequod.cso.uiuc.edu (Steve Dorner) (03/26/91)

>The only drawback is that the Gestalt calls require System 6.0.4 or later.

And that mere mortals aren't allowed to see the documentation on it...
--
Steve Dorner, U of Illinois Computing Services Office
Internet: s-dorner@uiuc.edu  UUCP: uunet!uiucuxc!uiuc.edu!s-dorner

Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) (03/28/91)

Steve Dorner writes in a message to All

SD> And that mere mortals aren't allowed to see the documentation 
SD> on it..

I recently DL-ed the TechNote on Gestalt off of the Mousehole BBS of MacTutor
fame... (408) 738-5791...


Lawson
 

--  
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!300!15.88!Lawson.English
Internet: Lawson.English@p88.f15.n300.z1.fidonet.org

jwwalker@opusc.csd.scarolina.edu (Jim Walker) (04/03/91)

In article <6553.27F82A2B@stjhmc.fidonet.org> Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) writes:
|Steve Dorner writes in a message to All
|
|SD> And that mere mortals aren't allowed to see the documentation 
|SD> on it..
|
|I recently DL-ed the TechNote on Gestalt off of the Mousehole BBS of MacTutor
|fame... (408) 738-5791...

Did you look at it after you DLed it?

There's a Tech Note that has a few comments on Gestalt and SysEnvirons, but
it is not complete documentation on Gestalt by a long shot.  Unless there
are Tech Notes that haven't appeared on comp.binaries.mac yet, there is no
real documentation on Gestalt outside of Inside Mac VI.
-- 
  -- Jim Walker 76367.2271@compuserve.com  walker@math.scarolina.edu