home *** CD-ROM | disk | FTP | other *** search
-
-
- /*⌐ Copyright 1988-1991 UserLand Software, Inc. All Rights Reserved.*/
-
-
-
- #include <iac.h>
- #include <processes.h>
- #include <GestaltEqu.h>
-
-
- /*
- This file contains C routines that simplify the Macintosh Apple Event Manager.
-
- The routines are grouped into several categories:
-
- 1. Utility routines, like IACcopystring and IACloadfromhandle. These are used
- locally to implement other iac.c routines.
-
- 2. Popping parameters off an Apple event, like IACgetstringparam and IACgetshortparam.
- When responding to an Apple event, you'll usually call one or more of these routines
- to get the parameters that are associated with an IAC message. Each parameter has
- a 4-character "key" associated with it, you provide the key when you're asking for
- the parameter. If there's an error popping the parameter, the iac.c routines will
- automatically return an error to the Apple event caller, all you have to do is check
- the returned boolean and pop out of your handler.
-
- 3. Returning a value from an Apple event call, routines like IACreturnstring and
- IACreturnerror.
-
- 4. Miscellaneous routines that defy categorization -- including IACinstallhandler,
- IACwaitroutine and IACinit.
-
- Change Notes --
-
- 10/26/91 DW: the routines that get params from an incoming event have been
- enhanced to return an error number and error string to the caller if we weren't
- able to get the requested parameter, or if it wasn't possible to coerce the
- parameter to the type desired by the caller. see IACparamerror for details.
-
- 11/5/91 DW: add IACnothandlederror -- call this when you receive a verb that
- you don't define. this is needed by the Applet Toolkit and applications built
- on top of it.
- */
-
-
-
-
- tyIACglobals IACglobals;
-
-
-
-
- static void IACcopystring (void *source, void *dest) {
-
- /*
- create a copy of source in dest. copy the length byte and
- all the characters in the source string.
-
- assume the strings are pascal strings, with the length byte in
- the first character of the string.
- */
-
- register char *s = source, *d = dest;
- register short i, len;
-
- len = (short) s [0];
-
- for (i = 0; i <= len; i++)
- *d++ = *s++;
- } /*IACcopystring*/
-
-
- static Boolean IACpushstring (void *source, void *dest) {
-
- /*
- insert the source string at the end of the destination string.
-
- assume the strings are pascal strings, with the length byte in
- the first character of the string.
- */
-
- register char *s = source, *d = dest;
- register short lensource = s [0];
- register short lendest = d [0];
- register short newlen = lensource + lendest;
-
- if (newlen > 255)
- return (false);
-
- d [0] = (char) newlen;
-
- d += (char) lendest + 1; /*point at the position we're copying into*/
-
- s++; /*point at 1st char after length byte*/
-
- while (lensource--)
- *d++ = *s++;
-
- return (true);
- } /*IACpushstring*/
-
-
- pascal Boolean IACstringtotext (s, htext) Str255 s; Handle *htext; {
-
- register long len;
- register Handle h;
-
- len = s [0];
-
- h = NewHandle (len);
-
- if (h == nil)
- return (false);
-
- BlockMove (&s [1], *h, len);
-
- *htext = h;
-
- return (true);
- } /*IACstringtotext*/
-
-
- pascal Boolean IACtexttostring (htext, s) Handle htext; Str255 s; {
-
- long len;
-
- len = GetHandleSize (htext);
-
- if (len > 255)
- len = 255;
-
- BlockMove (*htext, &s [1], len);
-
- s [0] = (char) len;
-
- return (true);
- } /*IACtexttostring*/
-
-
- static Boolean IACloadfromhandle (hload, ixload, ctload, pdata) Handle hload; long *ixload, ctload; void *pdata; {
-
- /*
- copy the next ctload bytes from hload into pdata and increment the index.
-
- return false if there aren't enough bytes.
-
- start ixload at 0.
- */
-
- register Handle h = hload;
- register long ct = ctload;
- register long ix = *ixload;
-
- if ((ix + ct) > GetHandleSize (h)) /*asked for more bytes than there are*/
- return (false);
-
- BlockMove (*h + ix, pdata, ct); /*copy out of the handle*/
-
- *ixload = ix + ct; /*increment the index into the handle*/
-
- return (true);
- } /*IACloadfromhandle*/
-
-
- pascal Boolean IAChaveappleevents () {
-
- /*
- return true if Apple events are available.
- */
-
- long gestaltAppleEventsPresent;
-
- if (Gestalt (gestaltAppleEventsAttr, &gestaltAppleEventsPresent) != noErr)
- return (false);
-
- return (gestaltAppleEventsPresent != 0);
- } /*IAChaveappleevents*/
-
-
- pascal Boolean IACinstallhandler (class, id, handler) AEEventClass class; AEEventID id; ProcPtr handler; {
-
- register OSErr errcode;
-
- errcode = AEInstallEventHandler (class, id, (EventHandlerProcPtr) handler, 0, false);
-
- return (errcode == noErr);
- } /*AEinstallhandler*/
-
-
- pascal Boolean IACinstallcoercionhandler (fromtype, totype, handler) DescType fromtype, totype; ProcPtr handler; {
-
- register OSErr errcode;
-
- errcode = AEInstallCoercionHandler (fromtype, totype, handler, (long) 0, false, false);
-
- return (errcode == noErr);
- } /*IACinstallcoercionhandler*/
-
-
- pascal Boolean IACnewverb (receiver, verbclass, verbtoken, event) OSType receiver, verbtoken, verbclass; AppleEvent *event; {
-
- /*
- create a new AppleEvent record addressed to the recipient, of the indicated class,
- with the indicated token identifier. return true if it worked, false otherwise.
- */
-
- AEAddressDesc adr;
- OSErr errcode;
-
- AECreateDesc (typeApplSignature, (Ptr) &receiver, sizeof (receiver), &adr);
-
- errcode = AECreateAppleEvent (verbclass, verbtoken, &adr, kAutoGenerateReturnID, kAnyTransactionID, event);
-
- AEDisposeDesc (&adr);
-
- return (errcode == noErr);
- } /*IACnewverb*/
-
-
- static Boolean IACbreakembrace (void) {
-
- /*
- return true if the user is holding down the cmd, option and shift keys.
- */
-
- register Ptr p;
- KeyMap keys;
-
- GetKeys (&keys);
-
- p = (Ptr) keys;
-
- return (BitTst (p, 63) && BitTst (p, 48) && BitTst (p, 61));
- } /*IACbreakembrace*/
-
-
- pascal short IACwaitroutine (ev, sleep, mousergn) EventRecord *ev; long *sleep; RgnHandle *mousergn; {
-
- /*
- called by the AppleEvent manager during AESend to give the user a chance to
- break out of a wait loop.
- */
-
- if (IACbreakembrace ()) /*user holding down cmd, option and shift keys*/
- return (-1); /*stop waiting*/
-
- return (0); /*keep waiting*/
- } /*IACwaitroutine*/
-
-
- pascal Boolean IACsendverb (event, reply) AppleEvent *event, *reply; {
-
- /*
- caller must dispose of the reply.
- */
-
- register OSErr ec;
- long mode;
-
- mode = kAEWaitReply + kAECanInteract + kAECanSwitchLayer;
-
- ec = AESend (
-
- event, reply, mode, kAEHighPriority, kNoTimeOut,
-
- (ProcPtr) IACwaitroutine, nil);
-
- AEDisposeDesc (event);
-
- return (ec == noErr);
- } /*IACsendverb*/
-
-
- pascal Boolean IACdisposeverb (event) AppleEvent *event; {
-
- return (AEDisposeDesc (event) == noErr);
- } /*IACdisposeverb*/
-
-
- pascal Boolean IACiserrorreply (errorstring) Str255 errorstring; {
-
- /*
- return true if the reply is an error -- if so it has an 'errn' value
- and an 'errs' value. if we return false, the reply is not an error.
- */
-
- OSErr ec;
- AEDesc desc;
-
- ec = AEGetParamDesc (IACglobals.reply, (AEKeyword) 'errn', 'shor', &desc);
-
- if (ec != noErr) /*the reply isn't an error*/
- return (false);
-
- AEDisposeDesc (&desc);
-
- ec = AEGetParamDesc (IACglobals.reply, (AEKeyword) 'errs', 's255', &desc);
-
- if (ec != noErr) {
-
- IACcopystring ((char *) "\pUnknown error.", (char *) errorstring);
-
- return (true);
- }
-
- IACcopystring ((char *) *desc.dataHandle, (char *) errorstring);
-
- AEDisposeDesc (&desc);
-
- return (true); /*there was an error returned*/
- } /*IACiserrorreply*/
-
-
- pascal Boolean IACpushbooleanparam (val, keyword) Boolean val; OSType keyword; {
-
- register OSErr ec;
-
- ec = AEPutParamPtr (
-
- IACglobals.event, (AEKeyword) keyword, typeBoolean,
-
- (Ptr) &val, sizeof (short));
-
- return (ec == noErr);
- } /*IACpushbooleanparam*/
-
-
- pascal Boolean IACpushshortparam (val, keyword) short val; OSType keyword; {
-
- register OSErr ec;
-
- ec = AEPutParamPtr (
-
- IACglobals.event, (AEKeyword) keyword, typeShortInteger,
-
- (Ptr) &val, sizeof (short));
-
- return (ec == noErr);
- } /*IACpushshortparam*/
-
-
- pascal Boolean IACpushlongparam (val, keyword) long val; OSType keyword; {
-
- register OSErr ec;
-
- ec = AEPutParamPtr (
-
- IACglobals.event, (AEKeyword) keyword, typeLongInteger,
-
- (Ptr) &val, sizeof (long));
-
- return (ec == noErr);
- } /*IACpushlongparam*/
-
-
- pascal short IACpushtextparam (val, keyword) Handle val; OSType keyword; {
-
- AEDesc desc;
- register OSErr ec;
- register long len;
-
- desc.descriptorType = 'TEXT';
-
- desc.dataHandle = val;
-
- ec = AEPutParamDesc (IACglobals.event, (AEKeyword) keyword, &desc);
-
- AEDisposeDesc (&desc);
-
- return (ec == noErr);
- } /*IACpushtextparam*/
-
-
- pascal short IACpushbinaryparam (val, keyword) Handle val; OSType keyword; {
-
- AEDesc desc;
- register OSErr ec;
- register long len;
-
- desc.descriptorType = 'BINA';
-
- desc.dataHandle = val;
-
- ec = AEPutParamDesc (IACglobals.event, (AEKeyword) keyword, &desc);
-
- AEDisposeDesc (&desc);
-
- return (ec == noErr);
- } /*IACpushbinaryparam*/
-
-
- pascal Boolean IACpushstringparam (val, keyword) Str255 val; OSType keyword; {
-
- register OSErr ec;
- Handle htext;
-
- if (!IACstringtotext (val, &htext))
- return (false);
-
- return (IACpushtextparam (htext, keyword));
- } /*IACpushstringparam*/
-
-
- pascal Boolean IACpushCstringparam (val, keyword) Str255 val; OSType keyword; {
-
- register OSErr ec;
- register long len = 0;
- register char *p = (char *) val;
-
- while (*p++) len++; /*get the length of the string*/
-
- ec = AEPutParamPtr (
-
- IACglobals.event, (AEKeyword) keyword, 'Sz ', (Ptr) &val, len + 1);
-
- return (ec == noErr);
- } /*IACpushCstringparam*/
-
-
- pascal Boolean IACreturnerror (errn, errs) short errn; Str255 errs; {
-
- /*
- return an error string and number in an AppleEvent.
- */
-
- register AppleEvent *x = IACglobals.event;
- register Boolean fl = false;
-
- IACglobals.event = IACglobals.reply; /*push params on the reply record*/
-
- if (IACpushstringparam (errs, keyErrorString)) {
-
- if (IACpushshortparam (errn, keyErrorNumber))
- fl = true;
- }
-
- IACglobals.reply = x; /*restore*/
-
- return (fl);
- } /*IACreturnerror*/
-
-
- pascal Boolean IACreturnboolean (fl) Boolean fl; {
-
- register OSErr ec;
-
- ec = AEPutParamPtr (
-
- IACglobals.reply, keyDirectObject, typeBoolean, (Ptr) &fl,
-
- (Size) sizeof (Boolean));
-
- return (ec == noErr);
- } /*IACreturnboolean*/
-
-
- pascal Boolean IACreturnshort (x) short x; {
-
- register OSErr ec;
-
- ec = AEPutParamPtr (
-
- IACglobals.reply, keyDirectObject, typeShortInteger, (Ptr) &x,
-
- (Size) sizeof (short));
-
- return (ec == noErr);
- } /*IACreturnshort*/
-
-
- pascal Boolean IACreturnlong (x) long x; {
-
- register OSErr ec;
-
- ec = AEPutParamPtr (
-
- IACglobals.reply, keyDirectObject, typeLongInteger, (Ptr) &x,
-
- (Size) sizeof (long));
-
- return (ec == noErr);
- } /*IACreturnlong*/
-
-
- pascal Boolean IACreturnrect (x) Rect *x; {
-
- register OSErr ec;
-
- ec = AEPutParamPtr (
-
- IACglobals.reply, keyDirectObject, 'qdrt', (Ptr) x,
-
- (Size) sizeof (Rect));
-
- return (ec == noErr);
- } /*IACreturnrect*/
-
-
- pascal Boolean IACreturnpoint (x) Point *x; {
-
- register OSErr ec;
-
- ec = AEPutParamPtr (
-
- IACglobals.reply, keyDirectObject, 'QDpt', (Ptr) x,
-
- (Size) sizeof (Point));
-
- return (ec == noErr);
- } /*IACreturnpoint*/
-
-
- pascal Boolean IACreturnbinary (x) Handle x; {
-
- register AppleEvent *oldevent = IACglobals.event;
- register Boolean fl = false;
-
- IACglobals.event = IACglobals.reply; /*push params on the reply record*/
-
- fl = IACpushbinaryparam (x, keyDirectObject);
-
- IACglobals.reply = oldevent; /*restore*/
-
- return (fl);
- } /*IACreturnbinary*/
-
-
- pascal Boolean IACreturntext (x) Handle x; {
-
- register AppleEvent *oldevent = IACglobals.event;
- register Boolean fl = false;
-
- IACglobals.event = IACglobals.reply; /*push params on the reply record*/
-
- fl = IACpushtextparam (x, keyDirectObject);
-
- IACglobals.reply = oldevent; /*restore*/
-
- return (fl);
- } /*IACreturntext*/
-
-
- pascal Boolean IACreturnstring (x) Str255 x; {
-
- Handle htext;
-
- if (!IACstringtotext (x, &htext))
- return (false);
-
- return (IACreturntext (htext));
- } /*IACreturnstring*/
-
-
- static void IACparamerror (OSErr errn, Str255 typestring, OSType paramkey) {
-
- /*
- build an error string that looks like:
-
- The 'read' verb requires a string parameter with a key of '----'
-
- And return it to the caller.
- */
-
- Str255 errs;
- Str255 bs;
- OSType verbtoken;
-
- verbtoken = IACgetverbtoken ();
-
- IACcopystring ("\pThe '", errs);
-
- bs [0] = 4;
-
- BlockMove (&verbtoken, &bs [1], 4);
-
- IACpushstring (bs, errs);
-
- IACpushstring ("\p' verb requires a ", errs);
-
- IACpushstring (typestring, errs);
-
- IACpushstring ("\p parameter with a key of '", errs);
-
- bs [0] = 4;
-
- BlockMove (¶mkey, &bs [1], 4);
-
- IACpushstring (bs, errs);
-
- IACpushstring ("\p'", errs);
-
- IACreturnerror (errn, errs);
- } /*IACparamerror*/
-
-
- pascal void IACnothandlederror (void) {
-
- /*
- call this if you receive an Apple event that you are not set up to handle.
-
- we return the standard "event not handled" error return. you can safely
- return noErr to the Apple Event Manager.
- */
-
- IACreturnerror (errAEEventNotHandled, "\p");
- } /*IACnothandlederror*/
-
-
- pascal Boolean IACgetbooleanparam (keyword, val) OSType keyword; Boolean *val; {
-
- register OSErr ec;
- DescType actualtype;
- Size actualsize;
-
- ec = AEGetParamPtr (
-
- IACglobals.event, (AEKeyword) keyword, typeBoolean,
-
- &actualtype, (Ptr) val, sizeof (Boolean), &actualsize);
-
- if (ec != noErr) {
-
- IACparamerror (ec, "\pboolean", keyword);
-
- return (false);
- }
-
- return (true);
- } /*IACgetbooleanparam*/
-
-
- pascal Boolean IACgetshortparam (keyword, val) OSType keyword; short *val; {
-
- register OSErr ec;
- DescType actualtype;
- Size actualsize;
-
- ec = AEGetParamPtr (
-
- IACglobals.event, (AEKeyword) keyword, typeShortInteger,
-
- &actualtype, (Ptr) val, sizeof (short), &actualsize);
-
- if (ec != noErr) {
-
- IACparamerror (ec, "\pshort", keyword);
-
- return (false);
- }
-
- return (true);
- } /*IACgetshortparam*/
-
-
- pascal Boolean IACgetlongparam (keyword, val) OSType keyword; long *val; {
-
- register OSErr ec;
- DescType actualtype;
- Size actualsize;
-
- ec = AEGetParamPtr (
-
- IACglobals.event, (AEKeyword) keyword, typeLongInteger,
-
- &actualtype, (Ptr) val, sizeof (long), &actualsize);
-
- if (ec != noErr) {
-
- IACparamerror (ec, "\plong", keyword);
-
- return (false);
- }
-
- return (true);
- } /*IACgetlongparam*/
-
-
- pascal Boolean IACgetCstringparam (keyword, val) OSType keyword; Str255 val; {
-
- DescType actualtype;
- Size actualsize;
- OSErr ec;
-
- ec = AEGetParamPtr (
-
- IACglobals.event, (AEKeyword) keyword, 'Sz ',
-
- &actualtype, (Ptr) val, sizeof (Str255), &actualsize);
-
- if (ec != noErr) {
-
- IACparamerror (ec, "\pstring", keyword);
-
- return (false);
- }
-
- return (true);
- } /*IACgetCstringparam*/
-
-
- pascal Boolean IACgetrectparam (keyword, val) OSType keyword; Rect *val; {
-
- register OSErr ec;
- DescType actualtype;
- Size actualsize;
-
- ec = AEGetParamPtr (
-
- IACglobals.event, (AEKeyword) keyword, 'qdrt',
-
- &actualtype, (Ptr) val, sizeof (Rect), &actualsize);
-
- if (ec != noErr) {
-
- IACparamerror (ec, "\prectangle", keyword);
-
- return (false);
- }
-
- return (true);
- } /*IACgetrectparam*/
-
-
- pascal Boolean IACgetpointparam (keyword, val) OSType keyword; Point *val; {
-
- register OSErr ec;
- DescType actualtype;
- Size actualsize;
-
- ec = AEGetParamPtr (
-
- IACglobals.event, (AEKeyword) keyword, 'QDpt',
-
- &actualtype, (Ptr) val, sizeof (Point), &actualsize);
-
- if (ec != noErr) {
-
- IACparamerror (ec, "\ppoint", keyword);
-
- return (false);
- }
-
- return (true);
- } /*IACgetpointparam*/
-
-
- pascal Boolean IACgettextparam (keyword, htext) OSType keyword; Handle *htext; {
-
- AEDesc result;
- OSErr ec;
-
- ec = AEGetParamDesc (IACglobals.event, (AEKeyword) keyword, 'TEXT', &result);
-
- if (ec != noErr) {
-
- IACparamerror (ec, "\ptext", keyword);
-
- return (false);
- }
-
- *htext = result.dataHandle;
-
- return (true);
- } /*IACgettextparam*/
-
-
- pascal Boolean IACgetbinaryparam (keyword, hbinary) OSType keyword; Handle *hbinary; {
-
- AEDesc result;
- OSErr ec;
-
- ec = AEGetParamDesc (IACglobals.event, (AEKeyword) keyword, 'BINA', &result);
-
- if (ec != noErr) {
-
- IACparamerror (ec, "\pbinary", keyword);
-
- return (false);
- }
-
- *hbinary = result.dataHandle;
-
- return (true);
- } /*IACgetbinaryparam*/
-
-
- pascal Boolean IACgetstringparam (keyword, val) OSType keyword; Str255 val; {
-
- Handle htext;
-
- if (!IACgettextparam (keyword, &htext))
- return (false);
-
- IACtexttostring (htext, val);
-
- DisposeHandle (htext);
-
- return (true);
- } /*IACgetstringparam*/
-
-
- static Boolean IACgetlongattr (list, key, type, pattr) AppleEvent *list; AEKeyword key; DescType type; long *pattr; {
-
- register OSErr ec;
- Size actualsize;
-
- ec = AEGetAttributePtr (
-
- list, key, type, &type, (Ptr) pattr, sizeof (long), &actualsize);
-
- return (ec == noErr);
- } /*IACgetlongattr*/
-
-
- pascal OSType IACgetverbtoken () {
-
- /*
- get the id/token of a verb from an AppleEvent
- */
-
- OSType verbtoken;
-
- if (!IACgetlongattr (IACglobals.event, keyEventIDAttr, typeType, (long *) &verbtoken))
- verbtoken = (OSType) 0;
-
- return (verbtoken);
- } /*IACgetverbtoken*/
-
-
- pascal OSErr IACdrivefilelist (handlespecroutine) tyFScallback handlespecroutine; {
-
- /*
- the opendoc and printdoc required events take a list of filespecs as a
- parameter. we factor out the common code, and make it a little easier for an
- application to handle these events.
-
- you supply a callback routine that handles a single filespec, you could
- print it or open it, depending on which of the required events is being
- invoked.
- */
-
- AEDesc desc;
- long ctfiles;
- DescType actualtype;
- long actualsize;
- AEKeyword actualkeyword;
- FSSpec fs;
- long i;
- OSErr ec;
-
- ec = AEGetKeyDesc (IACglobals.event, keyDirectObject, typeAEList, &desc);
-
- if (ec != noErr)
- return (ec);
-
- ec = AECountItems (&desc, &ctfiles);
-
- if (ec != noErr)
- return (ec);
-
- for (i = 1; i <= ctfiles; i ++) {
-
- ec = AEGetNthPtr (
- &desc, i, typeFSS, &actualkeyword, &actualtype,
-
- (Ptr) &fs, sizeof (fs), &actualsize);
-
- if (ec != noErr) {
-
- AEDisposeDesc (&desc);
-
- return (ec);
- }
-
- if (!(*handlespecroutine) (&fs))
- return (-1);
- } /*for*/
-
- return (noErr);
- } /*IACdrivefilelist*/
-
-
- static pascal OSErr CoerceTargetIDToType (DescType typecode, Ptr dataptr, Size datasize, DescType totype, long refcon, AEDesc *result) {
-
- TargetID target;
- ProcessSerialNumber psn;
- ProcessInfoRec info;
- Ptr addressoftype;
- OSErr ec;
-
- BlockMove (dataptr, &target, sizeof (target));
-
- if (target.location.locationKindSelector == ppcNoLocation) { /*local program*/
-
- ec = GetProcessSerialNumberFromPortName (&target.name, &psn);
-
- if (ec != noErr)
- return (ec);
-
- info.processInfoLength = (long) sizeof (info);
-
- info.processName = nil;
-
- info.processAppSpec = nil;
-
- ec = GetProcessInformation (&psn, &info);
-
- if (ec != noErr)
- return (ec);
-
- addressoftype = (Ptr) &info.processSignature;
- }
-
- else { /*not a local program*/
-
- if (target.name.portKindSelector == ppcByCreatorAndType)
- addressoftype = (Ptr) &target.name.u.port.creator;
- else
- addressoftype = ((Ptr) &target.name.u.portTypeStr) + 1; /*kloooge*/
- }
-
- (*result).descriptorType = typeType;
-
- return (PtrToHand (addressoftype, &(*result).dataHandle, 4));
- } /*CoerceTargetIDToType*/
-
-
- static pascal OSErr CoercePSNToType (DescType typecode, Ptr dataptr, Size datasize, DescType totype, long refcon, AEDesc *result) {
-
- ProcessInfoRec info;
- OSErr ec;
-
- info.processInfoLength = (long) sizeof (info);
-
- info.processName = nil;
-
- info.processAppSpec = nil;
-
- ec = GetProcessInformation ((ProcessSerialNumber *) dataptr, &info);
-
- if (ec != noErr)
- return (ec);
-
- (*result).descriptorType = typeType;
-
- return (PtrToHand (&info.processSignature, &(*result).dataHandle, 4));
- } /*CoercePSNToType*/
-
-
- pascal OSType IACgetsender () {
-
- /*
- get application signature from address attribute. automatically
- invokes our coercion handlers.
-
- this is needed by the Menu Sharing Toolkit -- when the user presses
- cmd-period to halt a script, the next time we get a message from the
- Menu Sharing server (usually Frontier) we return an error. but we only
- return the error if the call came from Frontier, we use this routine
- to identify the sender of the message.
-
- thanks to Kevin Calhoun of Apple Computer for providing this code!
- */
-
- OSType sender;
- Size actualsize;
- DescType actualtype;
- OSErr errcode;
-
- errcode = AEGetAttributePtr (
- IACglobals.event, keyAddressAttr, typeType, &actualtype, (Ptr) &sender,
-
- (long) sizeof (sender), &actualsize);
-
- return (sender);
- } /*IACgetsender*/
-
-
- pascal Boolean IACinit () {
-
- /*
- returns true if the machine we're running on has Apple events, and if we are
- able to install our coercion handlers. it may do more in future versions.
-
- call this routine before using any of the other iac.c routines. disable your
- Apple event support if we return false.
- */
-
- if (!IAChaveappleevents ())
- return (false);
-
- if (!IACinstallcoercionhandler (typeProcessSerialNumber, typeType, (ProcPtr) &CoercePSNToType))
- return (false);
-
- if (!IACinstallcoercionhandler (typeTargetID, typeType, (ProcPtr) &CoerceTargetIDToType))
- return (false);
-
- return (true);
- } /*IACinit*/
-
-
-