Mac OS 9
AEMach.h
Go to the documentation of this file.
1 
19 #ifndef __AEMACH__
20 #define __AEMACH__
21 
22 #ifndef __MACTYPES__
23 #include <MacTypes.h>
24 #endif
25 
26 #ifndef __MIXEDMODE__
27 #include <MixedMode.h>
28 #endif
29 
30 #ifndef __AEDATAMODEL__
31 #include <AEDataModel.h>
32 #endif
33 
34 #if PRAGMA_ONCE
35 #pragma once
36 #endif
37 
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #endif
42 
43 #if PRAGMA_IMPORT
44 #pragma import on
45 #endif
46 
47 #if PRAGMA_STRUCT_ALIGN
48 #pragma options align = mac68k
49 #elif PRAGMA_STRUCT_PACKPUSH
50 #pragma pack(push, 2)
51 #elif PRAGMA_STRUCT_PACK
52 #pragma pack(2)
53 #endif
54 
55  /*-
56  * AE Mach API --
57  *
58  * AppleEvents on OS X are implemented in terms of mach messages.
59  * To facilitate writing server processes that can send and receive
60  * AppleEvents, the following APIs are provided.
61  *
62  * AppleEvents are directed to a well known port uniquely tied to a
63  * process. The AE framework will discover this port based on the
64  * keyAddressAttr of the event (as specifed in AECreateAppleEvent by
65  * the target parameter.) If a port cannot be found,
66  * procNotFound (-600) will be returned on AESend.
67  *
68  * Of note is a new attribute for an AppleEvent, typeReplyPortAttr.
69  * This specifies the mach_port_t to which an AppleEvent reply
70  * should be directed. By default, replies are sent to the
71  * processes registered port where they are culled from the normal
72  * event stream if there is an outstanding AESend + kAEWaitReply.
73  * But it may be desirable for a client to specify their own port to
74  * receive quued replies.
75  * (In the case of AESendMessage with kAEWaitReply specified, an
76  * anonymous port will be used to block until the reply is received.)
77  *
78  * Not supplied is a convenience routine to block a server and
79  * process AppleEvents. This implementation will be detailed in a
80  * tech note.
81  **/
82  enum
83  {
84  typeReplyPortAttr = FOUR_CHAR_CODE('repp')
85  };
86 
87 #if TARGET_RT_MAC_MACHO
88 #ifdef _MACH_MESSAGE_H_ /* only use if <mach/port.h> previously included */
89  /*-
90  * Return the mach_port_t that was registered with the bootstrap
91  * server for this process. This port is considered public, and
92  * will be used by other applications to target your process. You
93  * are free to use this mach_port_t to add to a port set, if and
94  * only if, you are not also using routines from HIToolbox. In that
95  * case, HIToolbox retains control of this port and AppleEvents are
96  * dispatched through the main event loop.
97  **/
106  mach_port_t
107  AEGetRegisteredMachPort(void);
108 
109  /*-
110  * Decode a mach_msg into an AppleEvent and its related reply. (The
111  * reply is set up from fields of the event.) You can call this
112  * routine if you wish to dispatch or handle the event yourself. To
113  * return a reply to the sender, you should call:
114  *
115  * AESendMessage(reply, NULL, kAENoReply, kAENormalPriority,
116  *kAEDefaultTimeout);
117  *
118  * The contents of the header are invalid after this call.
119  **/
128  OSStatus
129  AEDecodeMessage(mach_msg_header_t *header, AppleEvent *event,
130  AppleEvent *reply); /* can be NULL */
131 
132  /*-
133  * Decodes and dispatches an event to an event handler. Handles
134  * packaging and returning the reply to the sender.
135  *
136  * The contents of the header are invalid after this call.
137  **/
146  OSStatus
147  AEProcessMessage(mach_msg_header_t *header);
148 
149  /*-
150  * Send an AppleEvent to a target process. If the target is the
151  * current process (as specified by using typeProcessSerialNumber of
152  * { 0, kCurrentProcess } it is dispatched directly to the
153  * appropriate event handler in your process and not serialized.
154  **/
163  OSStatus
164  AESendMessage(const AppleEvent *event, AppleEvent *reply, /* can be NULL */
165  AESendMode sendMode, long timeOutInTicks);
166 
167 #endif /* _MACH_MESSAGE_H_ */
168 #endif /* TARGET_RT_MAC_MACHO */
169 
170 #if PRAGMA_STRUCT_ALIGN
171 #pragma options align = reset
172 #elif PRAGMA_STRUCT_PACKPUSH
173 #pragma pack(pop)
174 #elif PRAGMA_STRUCT_PACK
175 #pragma pack()
176 #endif
177 
178 #ifdef PRAGMA_IMPORT_OFF
179 #pragma import off
180 #elif PRAGMA_IMPORT
181 #pragma import reset
182 #endif
183 
184 #ifdef __cplusplus
185 }
186 #endif
187 
188 #endif /* __AEMACH__ */
AppleEvent Data Model Interfaces.
Basic Macintosh data types.
Mixed Mode Manager Interfaces.
Definition: AEDataModel.h:175
Definition: Components.h:266
Definition: Events.h:224