MCPcopy Create free account
hub / github.com/NetHack/NetHack / AppleEventHandler

Function AppleEventHandler

outdated/sys/mac/macwin.c:272–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272static pascal OSErr
273AppleEventHandler(const AppleEvent *inAppleEvent, AppleEvent *outAEReply,
274 long inRefCon)
275{
276#if defined(__SC__) || defined(__MRC__)
277#pragma unused(outAEReply, inRefCon)
278#endif
279 Size actualSize;
280 DescType typeCode;
281 AEEventID EventID;
282 OSErr err;
283
284 /* Get Event ID */
285 err = AEGetAttributePtr(inAppleEvent, keyEventIDAttr, typeType, &typeCode,
286 &EventID, sizeof(EventID), &actualSize);
287 if (err == noErr) {
288 switch (EventID) {
289 default:
290 case kAEOpenApplication:
291 macFlags.gotOpen = 1;
292 /* fall through */
293 case kAEPrintDocuments:
294 err = errAEEventNotHandled;
295 break;
296 case kAEQuitApplication:
297 /* Flush key queue */
298 keyQueueCount = keyQueueWrite = keyQueueRead = 0;
299 AddToKeyQueue('S', 1);
300 break;
301 case kAEOpenDocuments: {
302 FSSpec fss;
303 FInfo fndrInfo;
304 AEKeyword keywd;
305 AEDescList docList;
306 long index, itemsInList;
307
308 if ((err = AEGetParamDesc(inAppleEvent, keyDirectObject,
309 typeAEList, &docList)) != noErr
310 || (err = AECountItems(&docList, &itemsInList)) != noErr) {
311 if (err == errAEDescNotFound)
312 itemsInList = 0;
313 else
314 break;
315 }
316
317 for (index = 1; index <= itemsInList; index++) {
318 err = AEGetNthPtr(&docList, index, typeFSS, &keywd, &typeCode,
319 (Ptr) &fss, sizeof(FSSpec), &actualSize);
320 if (noErr != err)
321 break;
322
323 err = FSpGetFInfo(&fss, &fndrInfo);
324 if (noErr != err)
325 break;
326
327 if (fndrInfo.fdType != SAVE_TYPE)
328 continue; /* only look at save files */
329

Callers

nothing calls this directly

Calls 2

AddToKeyQueueFunction · 0.85
process_openfileFunction · 0.85

Tested by

no test coverage detected