Package Name: appleevents

Return to: Package List


with Interfaces.C; use Interfaces.C;
with Interfaces.C.Extensions; use Interfaces.C.Extensions;
with Types; use Types;
with Memory; use Memory;
with Quickdraw; use Quickdraw;
with Events; use Events;
with Notification; use Notification;

package AppleEvents is
   --  
   --  File:       AppleEvents.h
   --  
   --  Contains:   AppleEvent Package Interfaces.
   --  
   --  Version:    Technology: System 7.5
   --              Package:    Universal Interfaces 2.1 in ŇMPW LatestÓ on ETO #18
   --  
   --  Copyright:  © 1984-1995 by Apple Computer, Inc.

   --              All rights reserved.
-- Apple event descriptor types
	typeBoolean          : constant OSType := ToRes("bool");
	typeChar             : constant OSType := ToRes("TEXT");
	typeSMInt            : constant OSType := ToRes("shor");
	typeInteger          : constant OSType := ToRes("long");
	typeSMFloat          : constant OSType := ToRes("sing");
	typeFloat            : constant OSType := ToRes("doub");
	typeLongInteger      : constant OSType := ToRes("long");
	typeShortInteger     : constant OSType := ToRes("shor");
	typeLongFloat        : constant OSType := ToRes("doub");
	typeShortFloat       : constant OSType := ToRes("sing");
	typeExtended         : constant OSType := ToRes("exte");
	typeComp             : constant OSType := ToRes("comp");
	typeMagnitude        : constant OSType := ToRes("magn");
	typeAEList           : constant OSType := ToRes("list");
	typeAERecord         : constant OSType := ToRes("reco");
	typeAppleEvent       : constant OSType := ToRes("aevt");
	typeTrue             : constant OSType := ToRes("true");
	typeFalse            : constant OSType := ToRes("fals");
	typeAlias            : constant OSType := ToRes("alis");
	typeEnumerated       : constant OSType := ToRes("enum");
	typeType             : constant OSType := ToRes("type");
	typeAppParameters    : constant OSType := ToRes("appa");
	typeProperty         : constant OSType := ToRes("prop");
	typeFSS              : constant OSType := ToRes("fss ");
	typeKeyword          : constant OSType := ToRes("keyw");
	typeSectionH         : constant OSType := ToRes("sect");
	typeWildCard         : constant OSType := ToRes("****");
	typeApplSignature    : constant OSType := ToRes("sign");
	typeQDRectangle      : constant OSType := ToRes("qdrt");
	typeFixed            : constant OSType := ToRes("fixd");
	typeSessionID        : constant OSType := ToRes("ssid");
	typeTargetID         : constant OSType := ToRes("targ");
	typeProcessSerialNumber : constant OSType := ToRes("psn ");
	typeNull             : constant OSType := ToRes("null"); -- null or nonexistent data
-- Keywords for Apple event parameters
	keyDirectObject      : constant OSType := ToRes("----");
	keyErrorNumber       : constant OSType := ToRes("errn");
	keyErrorString       : constant OSType := ToRes("errs");
	keyProcessSerialNumber : constant OSType := ToRes("psn ");
-- Keywords for Apple event attributes
	keyTransactionIDAttr : constant OSType := ToRes("tran");
	keyReturnIDAttr      : constant OSType := ToRes("rtid");
	keyEventClassAttr    : constant OSType := ToRes("evcl");
	keyEventIDAttr       : constant OSType := ToRes("evid");
	keyAddressAttr       : constant OSType := ToRes("addr");
	keyOptionalKeywordAttr : constant OSType := ToRes("optk");
	keyTimeoutAttr       : constant OSType := ToRes("timo");
	keyInteractLevelAttr : constant OSType := ToRes("inte"); -- this attribute is read only - will be set in AESend
	keyEventSourceAttr   : constant OSType := ToRes("esrc"); -- this attribute is read only
	keyMissedKeywordAttr : constant OSType := ToRes("miss"); -- this attribute is read only
	keyOriginalAddressAttr : constant OSType := ToRes("from"); -- new in 1.0.1
-- Keywords for special handlers
	keyPreDispatch       : constant OSType := ToRes("phac"); -- preHandler accessor call
	keySelectProc        : constant OSType := ToRes("selh"); -- more selector call
-- Keyword for recording
	keyAERecorderCount   : constant OSType := ToRes("recr"); -- available only in vers 1.0.1 and greater
-- Keyword for version information
	keyAEVersion         : constant OSType := ToRes("vers"); -- available only in vers 1.0.1 and greater
-- Event Class
	kCoreEventClass      : constant OSType := ToRes("aevt");
-- Event IDŐs
	kAEOpenApplication   : constant OSType := ToRes("oapp");
	kAEOpenDocuments     : constant OSType := ToRes("odoc");
	kAEPrintDocuments    : constant OSType := ToRes("pdoc");
	kAEQuitApplication   : constant OSType := ToRes("quit");
	kAEAnswer            : constant OSType := ToRes("ansr");

	kAEApplicationDied   : constant OSType := ToRes("obit");
-- Constants for use in AESend mode
	kAENoReply           : constant := 16#00000001#; -- sender doesn't want a reply to event
	kAEQueueReply        : constant := 16#00000002#; -- sender wants a reply but won't wait
	kAEWaitReply         : constant := 16#00000003#; -- sender wants a reply and will wait
	kAENeverInteract     : constant := 16#00000010#; -- server should not interact with user
	kAECanInteract       : constant := 16#00000020#; -- server may try to interact with user
	kAEAlwaysInteract    : constant := 16#00000030#; -- server should always interact with user where appropriate
	kAECanSwitchLayer    : constant := 16#00000040#; -- interaction may switch layer
	kAEDontReconnect     : constant := 16#00000080#; -- don't reconnect if there is a sessClosedErr from PPCToolbox
	kAEWantReceipt       : constant := 16#00000200#; -- sender wants a receipt of message
	kAEDontRecord        : constant := 16#00001000#; -- don't record this event - available only in vers 1.0.1 and greater
	kAEDontExecute       : constant := 16#00002000#; -- don't send the event for recording - available only in vers 1.0.1 and greater
-- Constants for the send priority in AESend
	kAENormalPriority    : constant := 16#00000000#; -- post message at the end of the event queue

	kAEHighPriority      : constant := 16#00000001#; -- post message at the front of the event queue
-- Constants for recording
	kAEStartRecording    : constant OSType := ToRes("reca"); -- available only in vers 1.0.1 and greater
	kAEStopRecording     : constant OSType := ToRes("recc"); -- available only in vers 1.0.1 and greater
	kAENotifyStartRecording : constant OSType := ToRes("rec1"); -- available only in vers 1.0.1 and greater
	kAENotifyStopRecording  : constant OSType := ToRes("rec0"); -- available only in vers 1.0.1 and greater

	kAENotifyRecording   : constant OSType := ToRes("recr");
-- Constant for the returnID param of AECreateAppleEvent
	kAutoGenerateReturnID: constant := -1; -- AECreateAppleEvent will generate a session-unique ID
-- Constant for transaction IDŐs
	kAnyTransactionID    : constant := 0; -- no transaction is in use
-- Constants for timeout durations
	kAEDefaultTimeout    : constant := -1; -- timeout value determined by AEM

	kNoTimeOut : constant:= -2; -- wait until reply comes back, however long it takes
-- Constants for AEResumeTheCurrentEvent
	kAENoDispatch        : constant := 0; -- dispatch parameter to AEResumeTheCurrentEvent takes a pointer to a dispatch
	kAEUseStandardDispatch   : constant := 16#FFFFFFFF#; -- table, or one of these two constants
-- Constants for Refcon in AEResumeTheCurrentEvent with kAEUseStandardDispatch
	kAEDoNotIgnoreHandler    : constant := 16#00000000#;
	kAEIgnoreAppPhacHandler  : constant := 16#00000001#; -- available only in vers 1.0.1 and greater
	kAEIgnoreAppEventHandler : constant := 16#00000002#; -- available only in vers 1.0.1 and greater
	kAEIgnoreSysPhacHandler  : constant := 16#00000004#; -- available only in vers 1.0.1 and greater
	kAEIgnoreSysEventHandler : constant := 16#00000008#; -- available only in vers 1.0.1 and greater
	kAEIngoreBuiltInEventHandler : constant := 16#00000010#; -- available only in vers 1.0.1 and greater

	kAEDontDisposeOnResume : constant := 16#80000000#; -- available only in vers 1.0.1 and greater
--  Apple event manager data types

   subtype AEEventClass is FourCharCode;

   subtype AEEventID is FourCharCode;

   subtype AEKeyword is FourCharCode;

   subtype DescType is ResType;
   type AEDesc is 
      record
         descriptorType : DescType;
         dataHandle : Handle;
      end record;
   type DescPtr is Access AEDesc;
   type DescHandle is Access DescPtr;

   type AEDesc_Vec_1 is array (0 .. 0) of AEDesc;
   type AEKeyDesc is 
      record
         descKey : AEKeyword;
         descContent : AEDesc;
      end record;

   type AEKeyDesc_Vec_1 is array (0 .. 0) of AEKeyDesc;
   --  an AEDesc which contains address data

   subtype AEAddressDesc is AEDesc;
   --  a list of AEDesc's is a special kind of AEDesc

   subtype AEDescList is AEDesc;
   --  AERecord is a list of keyworded AEDesc's

   subtype AERecord is AEDescList;
   --  an AERecord that contains an AppleEvent

   subtype AppleEvent is AERecord;
   --  parameter to AESend

   subtype AESendMode is Long_Integer;
   --  priority param of AESend

   subtype AESendPriority is Short_Integer;
   subtype AEInteractAllowed is SInt8;
   subtype AEEventSource is SInt8;

   subtype AEArrayType is SInt8;
	kAEInteractWithSelf  : constant SInt8 := 0;
	kAEInteractWithLocal : constant SInt8 := 1;
	kAEInteractWithAll   : constant SInt8 := 2;
	kAEUnknownSource     : constant SInt8 := 0;
	kAEDirectCall        : constant SInt8 := 1;
	kAESameProcess       : constant SInt8 := 2;
	kAELocalProcess      : constant SInt8 := 3;
	kAERemoteProcess     : constant SInt8 := 4;
	kAEDataArray         : constant SInt8 := 0;
	kAEPackedArray       : constant SInt8 := 1;
	kAEHandleArray       : constant SInt8 := 2;
	kAEDescArray         : constant SInt8 := 3;

	kAEKeyDescArray      : constant SInt8 := 4;
   type AEArrayData is array (0 .. 11) of char;
   type AEArrayDataPointer is Access AEArrayData;
   type Short_Integer_Vec_1 is array (0 .. 0) of Short_Integer;
   subtype AEArrayData_kAEDataArray is Short_Integer_Vec_1;
   type char_Vec_1 is array (0 .. 0) of char;
   subtype AEArrayData_kAEPackedArray is char_Vec_1;
   subtype AEArrayData_kAEHandleArray is Handle_Vec_1;
   subtype AEArrayData_kAEDescArray is AEDesc_Vec_1;


   subtype AEArrayData_kAEKeyDescArray is AEKeyDesc_Vec_1;
   type AEIdleProcPtr is access function
     (theEvent  : access EventRecord;
      sleepTime : access Long_Integer;
      mouseRgn  : access RgnHandle) return Boolean;
   type AEFilterProcPtr is access function
     (theEvent      : access EventRecord;
      returnID      : in     Long_Integer;
      transactionID : in     Long_Integer;
      sender        : access AEAddressDesc) return Boolean;
   type AEEventHandlerProcPtr is access function
     (theAppleEvent : access AppleEvent;
      reply         : access AppleEvent;
      handlerRefcon : in     Long_Integer) return OSErr;
   type AECoerceDescProcPtr is access function
     (fromDesc      : access AEDesc;
      toType        : in     DescType;
      handlerRefcon : in     Long_Integer;
      toDesc        : access AEDesc) return OSErr;
   type AECoercePtrProcPtr is access function
     (typeCode      : in     DescType;
      dataPtr       : in     Void_Ptr;
      dataSize      : in     Size;
      toType        : in     DescType;
      handlerRefcon : in     Long_Integer;

      result        : access AEDesc) return OSErr;
   subtype AEIdleUPP is UniversalProcPtr;
   subtype AEFilterUPP is UniversalProcPtr;
   subtype AEEventHandlerUPP is UniversalProcPtr;
   subtype AECoerceDescUPP is UniversalProcPtr;

   subtype AECoercePtrUPP is UniversalProcPtr;
	uppAEIdleProcInfo         : constant := 16#00000FD0#; -- FUNCTION (4 byte param, 4 byte param, 4 byte param): 1 byte result;
	uppAEFilterProcInfo       : constant := 16#00003FD0#; -- FUNCTION (4 byte param, 4 byte param, 4 byte param, 4 byte param): 1 byte result;
	uppAEEventHandlerProcInfo : constant := 16#00000FE0#; -- FUNCTION (4 byte param, 4 byte param, 4 byte param): 2 byte result;
	uppAECoerceDescProcInfo   : constant := 16#00003FE0#; -- FUNCTION (4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result;

	uppAECoercePtrProcInfo    : constant := 16#0003FFE0#; -- FUNCTION (4 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result;
   function NewAEIdleProc
     (userRoutine : AEIdleProcPtr) return AEIdleUPP;

   pragma Import (C, NewAEIdleProc, "NewAEIdleProc", "NewAEIdleProc");
   function NewAEFilterProc
     (userRoutine: AEFilterProcPtr) return AEFilterUPP;

   pragma Import (C, NewAEFilterProc, "NewAEFilterProc", "NewAEFilterProc");
   function NewAEEventHandlerProc
     (userRoutine: AEEventHandlerProcPtr) return AEEventHandlerUPP;

   pragma Import (C, NewAEEventHandlerProc, "NewAEEventHandlerProc", "NewAEEventHandlerProc");
   function NewAECoerceDescProc
     (userRoutine: AECoerceDescProcPtr) return AECoerceDescUPP;

   pragma Import (C, NewAECoerceDescProc, "NewAECoerceDescProc", "NewAECoerceDescProc");
   function NewAECoercePtrProc
     (userRoutine: AECoercePtrProcPtr) return AECoercePtrUPP;

   pragma Import (C, NewAECoercePtrProc, "NewAECoercePtrProc", "NewAECoercePtrProc");
   function CallAEIdleProc
     (theEvent    : access EventRecord;
      sleepTime   : access Long_Integer;
      mouseRgn    : access RgnHandle;
      userRoutine : in     AEIdleUPP) return Boolean;

   pragma Import (C, CallAEIdleProc, "CallAEIdleProc", "CallAEIdleProc");
   function CallAEFilterProc
     (theEvent     : access EventRecord;
      returnID     : in     Long_Integer;
      transactionID: in     Long_Integer;
      sender       : access AEAddressDesc;
      userRoutine  : in     AEIdleUPP) return Boolean;

   pragma Import (C, CallAEFilterProc, "CallAEFilterProc", "CallAEFilterProc");
   function CallAEEventHandlerProc
     (theAppleEvent : access AppleEvent;
      reply         : access AppleEvent;
      handlerRefcon : in     Long_Integer;
      userRoutine   : in     AEEventHandlerUPP) return OSErr;

   pragma Import (C, CallAEEventHandlerProc, "CallAEEventHandlerProc", "CallAEEventHandlerProc");
   function CallAECoerceDescProc
     (fromDesc      : access AEDesc;
      toType        : in     DescType;
      handlerRefcon : in     Long_Integer;
      toDesc        : access AEDesc;
      userRoutine   : in     AECoerceDescUPP) return OSErr;

   pragma Import (C, CallAECoerceDescProc, "CallAECoerceDescProc", "CallAECoerceDescProc");
   function CallAECoercePtrProc
     (typeCode      : in     DescType;
      dataPtr       : in     Ptr;
      dataSize      : in     Size;
      toType        : in     DescType;
      handlerRefcon : in     Long_Integer;
      result        : access AEDesc;
      userRoutine   : in     AECoercePtrUPP) return OSErr;

   pragma Import (C, CallAECoercePtrProc, "CallAECoercePtrProc", "CallAECoercePtrProc");

   subtype AECoercionHandlerUPP is UniversalProcPtr;
   --  **************************************************************************
   --  The following calls apply to any AEDesc. Every 'result' descriptor is
   --  created for you, so you will be responsible for memory management
   --  (including disposing) of the descriptors so created. Note: purgeable
   --  descriptor data is not supported - the AEM does not call LoadResource.
   --  **************************************************************************
   function AECreateDesc
     (typeCode           : in     DescType;
      dataPtr            : in     Void_Ptr;
      dataSize           : in     Size;
      result             : access AEDesc)
      return                      OSErr;

   pragma Import (C, AECreateDesc, "AECreateDesc", "AECreateDesc");
   function AECoercePtr
     (typeCode           : in     DescType;
      dataPtr            : in     Void_Ptr;
      dataSize           : in     Size;
      toType             : in     DescType;
      result             : access AEDesc)
      return                      OSErr;

   pragma Import (C, AECoercePtr, "AECoercePtr", "AECoercePtr");
   function AECoerceDesc
     (theAEDesc          : access AEDesc;
      toType             : in     DescType;
      result             : access AEDesc)
      return                      OSErr;

   pragma Import (C, AECoerceDesc, "AECoerceDesc", "AECoerceDesc");
   function AEDisposeDesc
     (theAEDesc          : access AEDesc)
      return                      OSErr;

   pragma Import (C, AEDisposeDesc, "AEDisposeDesc", "AEDisposeDesc");
   function AEDuplicateDesc
     (theAEDesc          : access AEDesc;
      result             : access AEDesc)
      return                      OSErr;

   pragma Import (C, AEDuplicateDesc, "AEDuplicateDesc", "AEDuplicateDesc");
   --  *************************************************************************
   --  The following calls apply to AEDescList. Since AEDescList is a subtype of
   --  AEDesc, the calls in the previous section can also be used for AEDescList.
   --  All list and array indices are 1-based. If the data was greater than
   --  maximumSize in the routines below, then actualSize will be greater than
   --  maximumSize, but only maximumSize bytes will actually be retrieved.
   --  *************************************************************************
   function AECreateList
     (factoringPtr       : in     Void_Ptr;
      factoredSize       : in     Size;
      isRecord           : in     Boolean;
      resultList         : access AEDescList)
      return                      OSErr;

   pragma Import (C, AECreateList, "AECreateList", "AECreateList");
   function AECountItems
     (theAEDescList      : access AEDescList;
      theCount           : access Long_Integer)
      return                      OSErr;

   pragma Import (C, AECountItems, "AECountItems", "AECountItems");
   function AEPutPtr
     (theAEDescList      : access AEDescList;
      index              : in     Long_Integer;
      typeCode           : in     DescType;
      dataPtr            : in     Void_Ptr;
      dataSize           : in     Size)
      return                      OSErr;

   pragma Import (C, AEPutPtr, "AEPutPtr", "AEPutPtr");
   function AEPutDesc
     (theAEDescList      : access AEDescList;
      index              : in     Long_Integer;
      theAEDesc          : access AEDesc)
      return                      OSErr;

   pragma Import (C, AEPutDesc, "AEPutDesc", "AEPutDesc");
   function AEGetNthPtr
     (theAEDescList      : access AEDescList;
      index              : in     Long_Integer;
      desiredType        : in     DescType;
      theAEKeyword       : access AEKeyword;
      typeCode           : access DescType;
      dataPtr            : in     Void_Ptr;
      maximumSize        : in     Size;
      actualSize         : access Size)
      return                      OSErr;

   pragma Import (C, AEGetNthPtr, "AEGetNthPtr", "AEGetNthPtr");
   function AEGetNthDesc
     (theAEDescList      : access AEDescList;
      index              : in     Long_Integer;
      desiredType        : in     DescType;
      theAEKeyword       : access AEKeyword;
      result             : access AEDesc)
      return                      OSErr;

   pragma Import (C, AEGetNthDesc, "AEGetNthDesc", "AEGetNthDesc");
   function AESizeOfNthItem
     (theAEDescList      : access AEDescList;
      index              : in     Long_Integer;
      typeCode           : access DescType;
      dataSize           : access Size)
      return                      OSErr;

   pragma Import (C, AESizeOfNthItem, "AESizeOfNthItem", "AESizeOfNthItem");
   function AEGetArray
     (theAEDescList      : access AEDescList;
      arrayType          : in     AEArrayType;
      arrayPtr           : in     AEArrayDataPointer;
      maximumSize        : in     Size;
      itemType           : access DescType;
      itemSize           : access Size;
      itemCount          : access Long_Integer)
      return                      OSErr;

   pragma Import (C, AEGetArray, "AEGetArray", "AEGetArray");
   function AEPutArray
     (theAEDescList      : access AEDescList;
      arrayType          : in     AEArrayType;
      arrayPtr           : access AEArrayData;
      itemType           : in     DescType;
      itemSize           : in     Size;
      itemCount          : in     Long_Integer)
      return                      OSErr;

   pragma Import (C, AEPutArray, "AEPutArray", "AEPutArray");
   function AEDeleteItem
     (theAEDescList      : access AEDescList;
      index              : in     Long_Integer)
      return                      OSErr;

   pragma Import (C, AEDeleteItem, "AEDeleteItem", "AEDeleteItem");
   --  **************************************************************************
   --  The following calls apply to AERecord. Since AERecord is a subtype of
   --  AEDescList, the calls in the previous sections can also be used for
   --  AERecord an AERecord can be created by using AECreateList with isRecord
   --  set to true.
   --  **************************************************************************
   function AEPutParamPtr
     (theAppleEvent      : access AppleEvent;
      theAEKeyword       : in     AEKeyword;
      typeCode           : in     DescType;
      dataPtr            : in     Void_Ptr;
      dataSize           : in     Size)
      return                      OSErr;

   pragma Import (C, AEPutParamPtr, "AEPutParamPtr", "AEPutParamPtr");
   function AEPutParamDesc
     (theAppleEvent      : access AppleEvent;
      theAEKeyword       : in     AEKeyword;
      theAEDesc          : access AEDesc)
      return                      OSErr;

   pragma Import (C, AEPutParamDesc, "AEPutParamDesc", "AEPutParamDesc");
   function AEGetParamPtr
     (theAppleEvent      : access AppleEvent;
      theAEKeyword       : in     AEKeyword;
      desiredType        : in     DescType;
      typeCode           : access DescType;
      dataPtr            : in     Void_Ptr;
      maximumSize        : in     Size;
      actualSize         : access Size)
      return                      OSErr;

   pragma Import (C, AEGetParamPtr, "AEGetParamPtr", "AEGetParamPtr");
   function AEGetParamDesc
     (theAppleEvent      : access AppleEvent;
      theAEKeyword       : in     AEKeyword;
      desiredType        : in     DescType;
      result             : access AEDesc)
      return                      OSErr;

   pragma Import (C, AEGetParamDesc, "AEGetParamDesc", "AEGetParamDesc");
   function AESizeOfParam
     (theAppleEvent      : access AppleEvent;
      theAEKeyword       : in     AEKeyword;
      typeCode           : access DescType;
      dataSize           : access Size)
      return                      OSErr;

   pragma Import (C, AESizeOfParam, "AESizeOfParam", "AESizeOfParam");
   function AEDeleteParam
     (theAppleEvent      : access AppleEvent;
      theAEKeyword       : in     AEKeyword)
      return                      OSErr;

   pragma Import (C, AEDeleteParam, "AEDeleteParam", "AEDeleteParam");
   --  **************************************************************************
   --  The following calls also apply to type AppleEvent. Message attributes are
   --  far more restricted, and can only be accessed through the following 5
   --  calls. The various list and record routines cannot be used to access the
   --  attributes of an event.
   --  **************************************************************************
   function AEGetAttributePtr
     (theAppleEvent      : access AppleEvent;
      theAEKeyword       : in     AEKeyword;
      desiredType        : in     DescType;
      typeCode           : access DescType;
      dataPtr            : in     Void_Ptr;
      maximumSize        : in     Size;
      actualSize         : access Size)
      return                      OSErr;

   pragma Import (C, AEGetAttributePtr, "AEGetAttributePtr", "AEGetAttributePtr");
   function AEGetAttributeDesc
     (theAppleEvent      : access AppleEvent;
      theAEKeyword       : in     AEKeyword;
      desiredType        : in     DescType;
      result             : access AEDesc)
      return                      OSErr;

   pragma Import (C, AEGetAttributeDesc, "AEGetAttributeDesc", "AEGetAttributeDesc");
   function AESizeOfAttribute
     (theAppleEvent      : access AppleEvent;
      theAEKeyword       : in     AEKeyword;
      typeCode           : access DescType;
      dataSize           : access Size)
      return                      OSErr;

   pragma Import (C, AESizeOfAttribute, "AESizeOfAttribute", "AESizeOfAttribute");
   function AEPutAttributePtr
     (theAppleEvent      : access AppleEvent;
      theAEKeyword       : in     AEKeyword;
      typeCode           : in     DescType;
      dataPtr            : in     Void_Ptr;
      dataSize           : in     Size)
      return                      OSErr;

   pragma Import (C, AEPutAttributePtr, "AEPutAttributePtr", "AEPutAttributePtr");
   function AEPutAttributeDesc
     (theAppleEvent      : access AppleEvent;
      theAEKeyword       : in     AEKeyword;
      theAEDesc          : access AEDesc)
      return                      OSErr;

   pragma Import (C, AEPutAttributeDesc, "AEPutAttributeDesc", "AEPutAttributeDesc");
   --  *************************************************************************
   --  The next couple of calls are basic routines used to create, send,
   --  and process AppleEvents.
   --  *************************************************************************
   function AECreateAppleEvent
     (theAEEventClass    : in     AEEventClass;
      theAEEventID       : in     AEEventID;
      target             : access AEAddressDesc;
      returnID           : in     Short_Integer;
      transactionID      : in     Long_Integer;
      result             : access AppleEvent)
      return                      OSErr;

   pragma Import (C, AECreateAppleEvent, "AECreateAppleEvent", "AECreateAppleEvent");
   function AESend
     (theAppleEvent      : access AppleEvent;
      reply              : access AppleEvent;
      sendMode           : in     AESendMode;
      sendPriority       : in     AESendPriority;
      timeOutInTicks     : in     Long_Integer;
      idleProc           : in     AEIdleUPP;
      filterProc         : in     AEFilterUPP)
      return                      OSErr;

   pragma Import (C, AESend, "AESend", "AESend");
   function AEProcessAppleEvent
     (theEventRecord     : access EventRecord)
      return                      OSErr;

   pragma Import (C, AEProcessAppleEvent, "AEProcessAppleEvent", "AEProcessAppleEvent");
   --  *
   --  Note: during event processing, an event handler may realize that it is likely
   --  to exceed the client's timeout limit. Passing the reply to this
   --  routine causes a wait event to be generated that asks the client
   --  for more time.
   --  *
   function AEResetTimer
     (reply              : access AppleEvent)
      return                      OSErr;

   pragma Import (C, AEResetTimer, "AEResetTimer", "AEResetTimer");
   --  **************************************************************************
   --  The following four calls are available for applications which need more
   --  sophisticated control over when and how events are processed. Applications
   --  which implement multi-session servers or which implement their own
   --  internal event queueing will probably be the major clients of these
   --  routines. They can be called from within a handler to prevent the AEM from
   --  disposing of the AppleEvent when the handler returns. They can be used to
   --  asynchronously process the event (as MacApp does).
   --  **************************************************************************
   function AESuspendTheCurrentEvent
     (theAppleEvent      : access AppleEvent)
      return                      OSErr;

   pragma Import (C, AESuspendTheCurrentEvent, "AESuspendTheCurrentEvent", "AESuspendTheCurrentEvent");
   --  *
   --  Note: The following routine tells the AppleEvent manager that processing
   --  is either about to resume or has been completed on a previously suspended
   --  event. The procPtr passed in as the dispatcher parameter will be called to
   --  attempt to redispatch the event. Several constants for the dispatcher
   --  parameter allow special behavior. They are:
   --     - kAEUseStandardDispatch means redispatch as if the event was just
   --       received, using the standard AppleEvent dispatch mechanism.
   --     - kAENoDispatch means ignore the parameter.
   --       Use this in the case where the event has been handled and no
   --       redispatch is needed.
   --     - non nil means call the routine which the dispatcher points to.
   --  *
   function AEResumeTheCurrentEvent
     (theAppleEvent      : access AppleEvent;
      reply              : access AppleEvent;
      dispatcher         : in     AEEventHandlerUPP;
      handlerRefcon      : in     Long_Integer)
      return                      OSErr;

   pragma Import (C, AEResumeTheCurrentEvent, "AEResumeTheCurrentEvent", "AEResumeTheCurrentEvent");
   function AEGetTheCurrentEvent
     (theAppleEvent      : access AppleEvent)
      return                      OSErr;

   pragma Import (C, AEGetTheCurrentEvent, "AEGetTheCurrentEvent", "AEGetTheCurrentEvent");
   function AESetTheCurrentEvent
     (theAppleEvent      : access AppleEvent)
      return                      OSErr;

   pragma Import (C, AESetTheCurrentEvent, "AESetTheCurrentEvent", "AESetTheCurrentEvent");
   --  *************************************************************************
   --  The following three calls are used to allow applications to behave
   --  courteously when a user interaction such as a dialog box is needed.
   --  *************************************************************************
   function AEGetInteractionAllowed
     (level              : access AEInteractAllowed)
      return                      OSErr;

   pragma Import (C, AEGetInteractionAllowed, "AEGetInteractionAllowed", "AEGetInteractionAllowed");
   function AESetInteractionAllowed
     (level              : in     AEInteractAllowed)
      return                      OSErr;

   pragma Import (C, AESetInteractionAllowed, "AESetInteractionAllowed", "AESetInteractionAllowed");
   function AEInteractWithUser
     (timeOutInTicks     : in     Long_Integer;
      nmReqPtr           : in     NMRecPtr;
      idleProc           : in     AEIdleUPP)
      return                      OSErr;

   pragma Import (C, AEInteractWithUser, "AEInteractWithUser", "AEInteractWithUser");
   --  *************************************************************************
   --  These calls are used to set up and modify the event dispatch table.
   --  *************************************************************************
   function AEInstallEventHandler
     (theAEEventClass    : in     AEEventClass;
      theAEEventID       : in     AEEventID;
      handler            : in     AEEventHandlerUPP;
      handlerRefcon      : in     Long_Integer;
      isSysHandler       : in     Boolean)
      return                      OSErr;

   pragma Import (C, AEInstallEventHandler, "AEInstallEventHandler", "AEInstallEventHandler");
   function AERemoveEventHandler
     (theAEEventClass    : in     AEEventClass;
      theAEEventID       : in     AEEventID;
      handler            : in     AEEventHandlerUPP;
      isSysHandler       : in     Boolean)
      return                      OSErr;

   pragma Import (C, AERemoveEventHandler, "AERemoveEventHandler", "AERemoveEventHandler");
   function AEGetEventHandler
     (theAEEventClass    : in     AEEventClass;
      theAEEventID       : in     AEEventID;
      handler            : access AEEventHandlerUPP;
      handlerRefcon      : access Long_Integer;
      isSysHandler       : in     Boolean)
      return                      OSErr;

   pragma Import (C, AEGetEventHandler, "AEGetEventHandler", "AEGetEventHandler");
   --  *************************************************************************
   --  These calls are used to set up and modify the coercion dispatch table.
   --  *************************************************************************
   function AEInstallCoercionHandler
     (fromType           : in     DescType;
      toType             : in     DescType;
      handler            : in     AECoercionHandlerUPP;
      handlerRefcon      : in     Long_Integer;
      fromTypeIsDesc     : in     Boolean;
      isSysHandler       : in     Boolean)
      return                      OSErr;

   pragma Import (C, AEInstallCoercionHandler, "AEInstallCoercionHandler", "AEInstallCoercionHandler");
   function AERemoveCoercionHandler
     (fromType           : in     DescType;
      toType             : in     DescType;
      handler            : in     AECoercionHandlerUPP;
      isSysHandler       : in     Boolean)
      return                      OSErr;

   pragma Import (C, AERemoveCoercionHandler, "AERemoveCoercionHandler", "AERemoveCoercionHandler");
   function AEGetCoercionHandler
     (fromType           : in     DescType;
      toType             : in     DescType;
      handler            : access AECoercionHandlerUPP;
      handlerRefcon      : access Long_Integer;
      fromTypeIsDesc     : access Boolean;
      isSysHandler       : in     Boolean)
      return                      OSErr;

   pragma Import (C, AEGetCoercionHandler, "AEGetCoercionHandler", "AEGetCoercionHandler");
   --  *************************************************************************
   --  These calls are used to set up and modify special hooks into the
   --  AppleEvent manager.
   --  *************************************************************************
   function AEInstallSpecialHandler
     (functionClass      : in     AEKeyword;
      handler            : in     UniversalProcPtr;
      isSysHandler       : in     Boolean)
      return                      OSErr;

   pragma Import (C, AEInstallSpecialHandler, "AEInstallSpecialHandler", "AEInstallSpecialHandler");
   function AERemoveSpecialHandler
     (functionClass      : in     AEKeyword;
      handler            : in     UniversalProcPtr;
      isSysHandler       : in     Boolean)
      return                      OSErr;

   pragma Import (C, AERemoveSpecialHandler, "AERemoveSpecialHandler", "AERemoveSpecialHandler");
   function AEGetSpecialHandler
     (functionClass      : in     AEKeyword;
      handler            : access UniversalProcPtr;
      isSysHandler       : in     Boolean)
      return                      OSErr;

   pragma Import (C, AEGetSpecialHandler, "AEGetSpecialHandler", "AEGetSpecialHandler");
   --  *************************************************************************
   --  This call was added in version 1.0.1. If called with the keyword
   --  keyAERecorderCount ('recr'), the number of recorders that are
   --  currently active is returned in 'result'.
   --  *************************************************************************
   --  available only in vers 1.0.1 and greater
   function AEManagerInfo
     (keyWord            : in     AEKeyword;
      result             : access Long_Integer)
      return                      OSErr;

   pragma Import (C, AEManagerInfo, "AEManagerInfo", "AEManagerInfo");
end AppleEvents;