home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
online
/
source
/
c
/
compilers
/
Tickle-4.0.sit.hqx
/
Tickle-4.0
/
src
/
AEvent.c
< prev
next >
Wrap
Text File
|
1993-11-18
|
24KB
|
788 lines
/*
** This source code was written by Tim Endres
** Email: time@ice.com.
** USMail: 8840 Main Street, Whitmore Lake, MI 48189
**
** Some portions of this application utilize sources
** that are copyrighted by ICE Engineering, Inc., and
** ICE Engineering retains all rights to those sources.
**
** Neither ICE Engineering, Inc., nor Tim Endres,
** warrants this source code for any reason, and neither
** party assumes any responsbility for the use of these
** sources, libraries, or applications. The user of these
** sources and binaries assumes all responsbilities for
** any resulting consequences.
*/
#include "tickle.h"
/* InitAEStuff checks to see if this machine has AppleEvents and
* does our setup.
* If AppleEvents are not found, we alert and exit.
* This is also the place where all the handlers for AppleEvents we deal
* with are installed. This includes the required AppleEvents, and the
* Edition Manager specific ones used in this app.
*/
#pragma segment AppleEvent
#define kMiscEventClass 'misc'
#define kAEDoScript 'dosc'
pascal OSErr AEOpenHandler();
pascal OSErr AEOpenDocHandler();
pascal OSErr AEPrintHandler();
pascal OSErr AEQuitHandler();
pascal OSErr AEDoScriptHandler();
pascal OSErr CoerceAliasToTargetID();
struct AEinstalls
{
AEEventClass theClass;
AEEventID theEvent;
EventHandlerProcPtr theProc;
}
HandlersToInstall [] =
{
/* The above are the four required AppleEvents. */
{ kCoreEventClass, kAEOpenApplication, AEOpenHandler },
{ kCoreEventClass, kAEOpenDocuments, AEOpenDocHandler },
{ kCoreEventClass, kAEPrintDocuments, AEPrintHandler },
{ kCoreEventClass, kAEQuitApplication, AEQuitHandler },
{ kMiscEventClass, kAEDoScript, AEDoScriptHandler },
};
struct COinstalls
{
DescType fromType;
DescType toType;
ProcPtr theProc;
Boolean isDesc; /* will usually be FALSE, System coercion */
}
CoercionsToInstall[] =
{
{ typeAlias, typeTargetID, CoerceAliasToTargetID, false },
};
InitAEStuff()
{
long mylong = 0;
int myerr = noErr;
int i;
/* The following series of calls installs all our AppleEvent Handlers.
** These handlers are added to the application event handler list that
** the AppleEvent manager maintains. So, whenever an AppleEvent happens
** and we call AEProcessEvent, the AppleEvent manager will check our
** list of handlers and dispatch to it if there is one.
*/
for (i = 0; i < ((sizeof(HandlersToInstall) / sizeof(struct AEinstalls))); i++)
{
myerr = AEInstallEventHandler( HandlersToInstall[i].theClass,
HandlersToInstall[i].theEvent,
HandlersToInstall[i].theProc,
0, FALSE);
if (myerr != noErr)
{
message_alert("Error %d installing Apple Event '%4.4s' Handler.",
myerr, &HandlersToInstall[i].theEvent);
}
}
/* now our coercion routines */
for (i = 0; i < ((sizeof(CoercionsToInstall) / sizeof(struct COinstalls))); i++)
{
myerr = AEInstallCoercionHandler( CoercionsToInstall[i].fromType,
CoercionsToInstall[i].toType,
CoercionsToInstall[i].theProc,
0, FALSE, FALSE);
if (myerr)
{
message_alert("Error %d installing coercion '%4.4s' handler.",
myerr, &CoercionsToInstall[i].fromType);
}
}
}
#pragma segment AppleEvents
void
DoHighLevelEvent(myEvent)
EventRecord *myEvent;
{
int myerr;
/*
** IF
** this is an AppleEvent, and we have a handler installed,
** AEProcessAppleEvent jumps to that handler
** ELSEIF
** there is a system handler for this event,
** AEProcessAppleEvent jumps to that
** ELSE
** return errEventNotHandled.
*/
myerr = AEProcessAppleEvent(myEvent);
if ((myerr != noErr) && (myerr != userCanceledErr)
&& (myerr != errAEEventNotHandled))
{
message_alert("Error #%d processing Apple Event.", myerr);
/*
** if it was a userCanceledErr (from the quit routine) and
** the reply has been sent from there already
** if it's a errAEEventNotHandled, then someone sent us
** an event we're not prepared for, that is not a reason
** to put up a dialog. Since anyone can send us events, then
** we could get all kinds of stray stuff, so just ignore it.
** you may want to check for debugging reasons
*/
}
}
Boolean
MissedAnyParameters(message)
AppleEvent *message;
{
int myerr;
DescType ignoredActualType;
AEKeyword missedKeyword;
Size ignoredActualSize;
myerr = AEGetAttributePtr(message, keyMissedKeywordAttr, typeKeyword,
&ignoredActualType, (Ptr)&missedKeyword,
sizeof(missedKeyword), &ignoredActualSize);
/* no error means that we found some more.*/
if (myerr == noErr) {
/* event.message = *(long *)&ignoredActualType; */
/* event.where = *(Point *)&missedKeyword; */
message_alert("MissedAnyParameters[%d]: extra parameters...", myerr);
myerr = errAEEventNotHandled;
}
else if (myerr != errAEDescNotFound) {
/*
** errAEDescNotFound means that there are no more parameters.
** If we get an error code other than that, flag it.
*/
message_alert("MissedAnyParameters[%d]: after AEGetAttributeDesc.", myerr);
}
return (myerr != errAEDescNotFound);
}
/*
** This is the standard Open Application event.
** You'll get this as one of the (if not the ) first events in your application.
** So, we open up a blank document.
** You will _NOT_ get this if you were launched with an event
** (like an 'odoc' or 'pdoc' ) so do _not_ do application initialiaztion things here!
** This routine may never get called!
*/
pascal OSErr
AEOpenHandler(message, reply, refnum)
AppleEvent *message;
AppleEvent *reply;
long refnum;
{
#pragma unused (message, reply, refnum)
/* Do open of default window here... */
return noErr;
}
/*
** Open Doc, opens our documents. Remember, this can happen at application start AND
** anytime else. If your app is up and running and the user goes to the desktop, hilites one
** of your files, and double-clicks or selects Open from the finder File menu this event
** handler will get called. Which means you don't do any initialization of globals here, or
** anything else except open then doc.
** SO -- Do NOT assume that you are at app start time in this
** routine, or bad things will surely happen to you.
*/
pascal OSErr
AEOpenDocHandler(message, reply, refnum)
AppleEvent *message;
AppleEvent *reply;
long refnum;
{
int i;
int result = noErr, myerr;
AEDesc theDesc;
FSSpec theFSS;
long numfiles;
AEKeyword ignoredKeyWord;
DescType ignoredType;
Size ignoredSize;
extern int tcl_feedback_output();
#pragma unused (reply, refnum)
myerr = AEGetParamDesc(message, keyDirectObject, typeAEList, &theDesc);
if (myerr != noErr)
{
result = myerr;
Feedback("GetParamDesc error %d in Open Doc", myerr);
}
if (! MissedAnyParameters(message))
{
/* Got all the parameters we need. Now, go through the direct object, */
/* see what type it is, and parse it up. */
myerr = AECountItems(&theDesc, &numfiles);
if (myerr != noErr)
{
result = myerr;
Feedback("Error %d AECountItems in Open Doc", myerr);
}
else {
for (i = 1; i <= numfiles && myerr == noErr ; ++i)
{
myerr = AEGetNthPtr(&theDesc, i, typeFSS, &ignoredKeyWord, &ignoredType,
(Ptr)&theFSS, sizeof(theFSS), &ignoredSize);
if (myerr == noErr)
{
result = myerr;
myerr = AEHandleDoc(&theFSS);
}
else
{
result = myerr;
Feedback("Error %d AEGetNthPtr in OpenDoc", myerr);
}
}
}
}
if (myerr = AEDisposeDesc(&theDesc))
{
result = myerr;
Feedback("Error %d AEDisposeDesc in Open Doc", myerr);
}
return result;
}
pascal OSErr
AEPrintHandler(message, reply, refnum)
AppleEvent *message;
AppleEvent *reply;
long refnum;
{
#pragma unused (message, reply, refnum)
/*
** No printing handler in yet, so we'll ignore this
** the operation is functionally identical to the ODOC event,
** with the additon of calling your print routine.
*/
message_alert("Print Document...");
return noErr;
}
/*
** Standard Quit event handler, to handle a Quit event from the Finder, for example.
** ••••• DO NOT CALL EXITTOSHELL HERE ••••• or you will never have a happy life.
** OK, it's a few months after I wrote that comment, and I've seen a lot of code
** come through DTS that calls ExitToShell from quit handlers. Let me explain...
** When an AppleEvent Handler is called (like this quit handler) you are ALMOST
** 100% in your application world. A5 is right, you can call any toolbox function,
** you can call your own routines, everything _seems_ like you are in complete
** control. Well, almost but not quite. The routine has been dispatch to from the
** AppleEvent Manager's space, so you _must_ return to that at some point!
** Which is why you can't call ETS from here. When you call ExitToShell from an
** AE Handler, the most likely thing that happens is the FInder quits, and your
** application keeps running. Which ain't what you want, y'know?
** so, DON'T CALL EXITTOSHELL FROM AN APPLEEVENT HANDLER!!!!!!!!!!!!!!
*/
pascal OSErr
AEQuitHandler(message, reply, refnum)
AppleEvent *message;
AppleEvent *reply;
long refnum;
{
#pragma unused (message, reply, refnum)
app_done = 1;
Feedback("Quit event...");
return noErr;
}
/*
** Open Doc, opens our documents. Remember, this can happen at application start AND
** anytime else. If your app is up and running and the user goes to the desktop, hilites one
** of your files, and double-clicks or selects Open from the finder File menu this event
** handler will get called. Which means you don't do any initialization of globals here, or
** anything else except open then doc.
** SO -- Do NOT assume that you are at app start time in this
** routine, or bad things will surely happen to you.
*/
pascal OSErr
AEDoScriptHandler(message, reply, refnum)
AppleEvent *message;
AppleEvent *reply;
long refnum;
{
int result = noErr, myerr;
char error_str[128];
AEDesc theDesc;
FSSpec theFSS;
long length;
Handle result_handle;
DescType ignoredType;
Size ignoredSize;
extern int tcl_feedback_output();
#pragma unused (reply, refnum)
result_handle = NewHandle(0);
if (result_handle != NULL) {
myerr = AEGetParamDesc(message, keyDirectObject, typeWildCard, &theDesc);
if (myerr != noErr) {
result = myerr;
Feedback("GetParamDesc error %d in Do Script", myerr);
}
if (! MissedAnyParameters(message)) {
/* Got all the parameters we need. Now, go through the direct object, */
/* see what type it is, and parse it up. */
/* dprintf( "GOT PARM type '%4.4s' handle x%lx ; dm %lx %d ",
&theDesc.descriptorType, theDesc.dataHandle,
*(theDesc.dataHandle), GetHandleSize(theDesc.dataHandle) ); */
if (theDesc.descriptorType == (DescType)'TEXT')
{
length = GetHandleSize(theDesc.dataHandle);
SetHandleSize(theDesc.dataHandle, length + 1);
if (MemError() == noErr) {
* (*theDesc.dataHandle + length) = '\0';
result = run_DoScript(theDesc.dataHandle, result_handle);
length = GetHandleSize(result_handle);
HLock(result_handle);
myerr = AEPutParamPtr(reply, keyDirectObject, typeChar,
*result_handle, length);
HUnlock(result_handle);
}
}
else if (theDesc.descriptorType == (DescType)'alis')
{
myerr = AEGetParamPtr( message,
keyDirectObject, typeFSS, &ignoredType,
(Ptr)&theFSS, sizeof(theFSS), &ignoredSize
);
if (myerr == noErr)
{
Feedback("AEDoScriptHandler: Execute script file '%.*s'.",
theFSS.name[0], &theFSS.name[1]);
run_AE_tcl_script(&theFSS, result_handle);
length = GetHandleSize(result_handle);
HLock(result_handle);
myerr = AEPutParamPtr(reply, keyDirectObject, typeChar,
*result_handle, length);
HUnlock(result_handle);
}
else
{
Feedback("AEDoScriptHandler: Error #%d AEGetParamPtr(typeFSS).", myerr);
}
}
else
{
sprintf(error_str, "invalid script type '%4.4s'", &theDesc.descriptorType);
myerr = AEPutParamPtr(reply, keyErrorString, typeChar,
error_str, strlen(error_str));
}
}
else
message_alert("AEDoScriptHandler: MissedAnyParameters!!!");
if (myerr = AEDisposeDesc(&theDesc)) {
result = myerr;
Feedback("Error %d AEDisposeDesc in Do Script.", myerr);
}
DisposHandle(result_handle);
}
else
result = MemError();
return result;
}
/*
** This is the 'ansr', or answer, handler. You need this if you ever want to
** use QueueReply as an option to AESend (which you will) since the reply
** is going to be coming in through your event loop like any other
** AppleEvent. So here it is
*/
pascal OSErr
AEAnswerHandler(message, reply, refnum)
AppleEvent *message;
AppleEvent *reply;
long refnum;
{
int myErr = noErr;
#pragma unused (message, reply, refnum)
return noErr;
/*
** •••• NOTE: One thing you may want to consider, and it's a side-effect of
** the AppleEvent manager's direct dispatching of events if you send them to yourself
** using the kCurrentProcess Process Serial Number constant.
** If you use kCurrentProcess, then the AppleEvent manager will directly dispatch
** to the AppleEvent handler, the event will _not_ go through WaitNextEvent.
** Normally, that's a very good thing. But there is one potential problem....
** It means that kQueueReply doesn't quite work the way you think it will when sending to
** yourself. The reply will _not_ be put in the event queue, instead this Answer hander
** will be called directly. And if you reply from the answer handler, that will dispatch right
** back to itself. And so on. So be aware that Queued replies are _not_ really
** queued when you are using kCurrentProcess!
*/
}
/*
** CoerceAliasToTargetID takes an applicaiton alias and coerces it to a process target ID
** Of course, to do this is needs to find and launch the application
** This handler uses pointers to the data, since the AppleEvent managr can handle this type
** of manipulation more efficiently than passing descs. You can install a desc handler
** instead, if you'd like.
** I actually don't use this in this sample, but I left it in as an example
** of a coercion handler
*/
pascal OSErr
CoerceAliasToTargetID(origData, inPtr, theSize, toType, refCon, returnID)
DescType origData;
Ptr inPtr;
Size theSize;
DescType toType;
long refCon;
AEDesc *returnID;
{
#pragma unused (origData, toType, refCon)
int myerr;
FSSpec theSpec;
Boolean changed;
Handle theAlias;
LaunchParamBlockRec launchThis;
theAlias = NewHandle(theSize);
if (theAlias != NULL)
{
HLock(theAlias);
BlockMove(inPtr, (Ptr)*theAlias, theSize);
HUnlock(theAlias);
launchThis.launchAppSpec = &theSpec;
/* the caller may have already done this, but it doesn't hurt to do it again */
myerr = ResolveAlias((FSSpec *)0, (AliasHandle)theAlias,
launchThis.launchAppSpec, &changed);
if (myerr != noErr)
return myerr;
/* launch the thing */
launchThis.launchBlockID = extendedBlock;
launchThis.launchEPBLength = extendedBlockLen;
launchThis.launchFileFlags = 0;
/* launchdontswitch because we just want to use the service. Also, it may be a */
/* background only application, so like you don't want it to come up, y'know? */
launchThis.launchControlFlags = launchContinue + launchNoFileFlags + launchDontSwitch;
launchThis.launchAppParameters = nil;
myerr = LaunchApplication(&launchThis);
if (myerr != noErr)
{
message_alert("LaunchApplication error %d.", myerr);
return myerr;
}
/*
** it launched. the PSN has been stored in the launchProcessSN field,
** now we have to make that a target
** fill in all the details for the target
** we'll just use the PSN to communicate
*/
myerr = AECreateDesc(typeProcessSerialNumber, (Ptr)&launchThis.launchProcessSN,
sizeof(ProcessSerialNumber), returnID);
message_alert("CreateDesc error after launch %d.", myerr);
}
else
myerr = MemError();
return myerr;
}
typedef struct
{
char name[48];
} DirListEntry;
AEHandleDoc(theFSS)
FSSpec *theFSS;
{
int result = noErr;
int i, entries, myerr, script_type = -1, run_it = 0;
short wdrefnum;
long dirid;
FSSpec myFSS;
CInfoPBRec cpb;
FInfo fileInfo;
char filename[64];
DirListEntry *list;
if (theFSS->name[1] == 0xA5)
{
Feedback("Skipping '%.*s'...", theFSS->name[0], &theFSS->name[1]);
return noErr;
}
cpb.hFileInfo.ioCompletion = 0;
cpb.hFileInfo.ioNamePtr = theFSS->name;
cpb.hFileInfo.ioVRefNum = theFSS->vRefNum;
cpb.hFileInfo.ioDirID = theFSS->parID;
cpb.hFileInfo.ioFDirIndex = 0;
myerr = PBGetCatInfo(&cpb, FALSE);
if (myerr != noErr)
{
Feedback("Error #%d getting CatInfo for '%.*s'.",
myerr, theFSS->name[0], &theFSS->name[1]);
}
else if ((cpb.hFileInfo.ioFlAttrib & ioDirMask) != 0)
{
/* DIRECTORY!!! */
Feedback("AppleEvent: Processing folder '%.*s'[%ld] with %ld items.",
theFSS->name[0], &theFSS->name[1], cpb.dirInfo.ioDrDirID, cpb.dirInfo.ioDrNmFls);
dirid = cpb.dirInfo.ioDrDirID;
list = (DirListEntry *) NewPtr(cpb.dirInfo.ioDrNmFls * sizeof(DirListEntry));
if (list == NULL)
{
Feedback("AppleEvent: Not enough memory to process folder '%.*s'.",
theFSS->name[0], &theFSS->name[1]);
}
else
{
for (i = 1, entries = 0 ; ; ++i)
{
cpb.hFileInfo.ioCompletion = 0;
cpb.hFileInfo.ioNamePtr = filename; filename[0] = '\0';
cpb.hFileInfo.ioVRefNum = theFSS->vRefNum;
cpb.hFileInfo.ioDirID = dirid;
cpb.hFileInfo.ioFDirIndex = i;
myerr = PBGetCatInfo(&cpb, FALSE);
if (myerr != noErr)
{
if (myerr != fnfErr)
Feedback("Error #%d CatInfo '%.*s' ENTRY #%d.",
myerr, theFSS->name[0], &theFSS->name[1], i);
break;
}
else
{
/*list[entries].directory = (cpb.hFileInfo.ioFlAttrib & ioDirMask) != 0;*/
BlockMove(filename, list[entries].name, filename[0]+1);
entries++;
}
}
for (i = 0; i < entries ; ++i)
{
BlockMove(list[i].name, myFSS.name, list[i].name[0] + 1);
myFSS.vRefNum = theFSS->vRefNum;
myFSS.parID = dirid;
AEHandleDoc(&myFSS);
}
DisposPtr((Ptr) list);
}
}
else
{
/* FILE */
FSpGetFInfo(theFSS, &fileInfo); /* make sure it's a data file */
if (fileInfo.fdType == 'TEXT')
{
if ( theFSS->name[theFSS->name[0]-3] == '.'
&& (theFSS->name[theFSS->name[0]-2] | 0x20) == 'h'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'q'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'x')
{
AEdecode_hqx(theFSS);
}
else if (theFSS->name[theFSS->name[0]-1] == '.'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'z')
{
AEdecompress(theFSS);
}
else if (theFSS->name[theFSS->name[0]-2] == '.'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'u'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'u') {
AEuudecode(theFSS);
}
else if (theFSS->name[theFSS->name[0]-3] == '.'
&& (theFSS->name[theFSS->name[0]-2] | 0x20) == 's'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'i'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 't') {
AEUnStuffIt(theFSS);
}
else if (theFSS->name[theFSS->name[0]-3] == '.'
&& (theFSS->name[theFSS->name[0]-2] | 0x20) == 't'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'a'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'r') {
AEExtract(theFSS);
}
else if (theFSS->name[theFSS->name[0]-2] == '.'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'm'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'b') {
AEUnMacBinary(theFSS);
}
else {
/* OK... Assume it is a script. */
if ( theFSS->name[theFSS->name[0]-3] == '.'
&& (theFSS->name[theFSS->name[0]-2] | 0x20) == 't'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'c'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'l')
{
script_type = 0; /* local script */
run_it = 1;
}
else
{
script_type = -1; /* text window */
run_it = 0;
}
Feedback("AppleEvent: %s script '%.*s'.",
(run_it ? "Running" : "Opening"), theFSS->name[0], &theFSS->name[1]);
if (run_it)
{
myerr = OpenWD(theFSS->vRefNum, theFSS->parID, 'MTcl', &wdrefnum);
if (myerr == noErr)
SetVol(NULL, wdrefnum);
else
Feedback("Error %d OpenWD().", myerr);
run_named_tcl_script(theFSS->name, NULL, tcl_feedback_output);
if (myerr == noErr)
myerr = CloseWD(wdrefnum);
}
#ifdef TCLAPPL
else
{
do_tge_file_open(theFSS, script_type);
}
#endif
}
}
else if (fileInfo.fdType == 'TARF')
{
Feedback("AppleEvent: Extracting Tar File '%.*s'.",
theFSS->name[0], &theFSS->name[1]);
AEExtract(theFSS);
}
else if (fileInfo.fdType == 'ZIVM')
{
Feedback("AppleEvent: Macintosh style De-Compress. Trying normal extract on '%.*s'.",
theFSS->name[0], &theFSS->name[1]);
AEdecompress(theFSS);
}
else if (fileInfo.fdType == 'ZIVU')
{
Feedback("AppleEvent: De-Compressing File '%.*s'.",
theFSS->name[0], &theFSS->name[1]);
AEdecompress(theFSS);
}
else if (fileInfo.fdType == 'MacB')
{
Feedback("AppleEvent: UnMacBinary File '%.*s'.",
theFSS->name[0], &theFSS->name[1]);
AEUnMacBinary(theFSS);
}
else if (fileInfo.fdType == 'SITD' || fileInfo.fdType == 'SIT!')
{
Feedback("AppleEvent: UnStuffing File '%.*s'.",
theFSS->name[0], &theFSS->name[1]);
AEUnStuffIt(theFSS);
}
else
{
if ( theFSS->name[theFSS->name[0]-3] == '.'
&& (theFSS->name[theFSS->name[0]-2] | 0x20) == 'h'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'q'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'x')
{
AEdecode_hqx(theFSS);
}
else if (theFSS->name[theFSS->name[0]-1] == '.'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'z')
{
AEdecompress(theFSS);
}
else if (theFSS->name[theFSS->name[0]-2] == '.'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'u'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'u')
{
AEuudecode(theFSS);
}
else if (theFSS->name[theFSS->name[0]-3] == '.'
&& (theFSS->name[theFSS->name[0]-2] | 0x20) == 't'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'a'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'r')
{
AEExtract(theFSS);
}
else if (theFSS->name[theFSS->name[0]-3] == '.'
&& (theFSS->name[theFSS->name[0]-2] | 0x20) == 's'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'i'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 't')
{
AEUnStuffIt(theFSS);
}
else if (theFSS->name[theFSS->name[0]-2] == '.'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'm'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'b')
{
AEUnMacBinary(theFSS);
}
else if (theFSS->name[theFSS->name[0]-3] == '.'
&& (theFSS->name[theFSS->name[0]-2] | 0x20) == 't'
&& (theFSS->name[theFSS->name[0]-1] | 0x20) == 'c'
&& (theFSS->name[theFSS->name[0]] | 0x20) == 'l')
{
Feedback("AppleEvent: %s script '%.*s'.",
(CheckOption() ? "Opening" : "Running"),
theFSS->name[0], &theFSS->name[1]);
myerr = OpenWD(theFSS->vRefNum, theFSS->parID, 'ERIK', &wdrefnum);
if (myerr == noErr)
SetVol(NULL, wdrefnum);
else
Feedback("Error %d OpenWD().", myerr);
if (! CheckOption())
run_named_tcl_script(theFSS->name, NULL, tcl_feedback_output);
#ifdef TCLAPPL
else
do_tge_file_open(theFSS, 0);
#endif
if (myerr == noErr)
myerr = CloseWD(wdrefnum);
}
else
Feedback("AppleEvent: What kind of document is '%.*s'? Type '%4.4s'.",
theFSS->name[0], &theFSS->name[1], &fileInfo.fdType);
}
}
return result;
}