]> git.saurik.com Git - apple/cf.git/blob - CFMessagePort.h
CF-550.19.tar.gz
[apple/cf.git] / CFMessagePort.h
1 /*
2 * Copyright (c) 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /* CFMessagePort.h
25 Copyright (c) 1998-2009, Apple Inc. All rights reserved.
26 */
27
28 #if !defined(__COREFOUNDATION_CFMESSAGEPORT__)
29 #define __COREFOUNDATION_CFMESSAGEPORT__ 1
30
31 #include <CoreFoundation/CFString.h>
32 #include <CoreFoundation/CFRunLoop.h>
33 #include <CoreFoundation/CFData.h>
34 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
35 #include <dispatch/dispatch.h>
36 #endif
37
38 CF_EXTERN_C_BEGIN
39
40 typedef struct __CFMessagePort * CFMessagePortRef;
41
42 enum {
43 kCFMessagePortSuccess = 0,
44 kCFMessagePortSendTimeout = -1,
45 kCFMessagePortReceiveTimeout = -2,
46 kCFMessagePortIsInvalid = -3,
47 kCFMessagePortTransportError = -4,
48 kCFMessagePortBecameInvalidError = -5
49 };
50
51 typedef struct {
52 CFIndex version;
53 void * info;
54 const void *(*retain)(const void *info);
55 void (*release)(const void *info);
56 CFStringRef (*copyDescription)(const void *info);
57 } CFMessagePortContext;
58
59 typedef CFDataRef (*CFMessagePortCallBack)(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info);
60 /* If callout wants to keep a hold of the data past the return of the callout, it must COPY the data. This includes the case where the data is given to some routine which _might_ keep a hold of it; System will release returned CFData. */
61 typedef void (*CFMessagePortInvalidationCallBack)(CFMessagePortRef ms, void *info);
62
63 CF_EXPORT CFTypeID CFMessagePortGetTypeID(void);
64
65 CF_EXPORT CFMessagePortRef CFMessagePortCreateLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo);
66 CF_EXPORT CFMessagePortRef CFMessagePortCreateRemote(CFAllocatorRef allocator, CFStringRef name);
67
68 CF_EXPORT Boolean CFMessagePortIsRemote(CFMessagePortRef ms);
69 CF_EXPORT CFStringRef CFMessagePortGetName(CFMessagePortRef ms);
70 CF_EXPORT Boolean CFMessagePortSetName(CFMessagePortRef ms, CFStringRef newName);
71 CF_EXPORT void CFMessagePortGetContext(CFMessagePortRef ms, CFMessagePortContext *context);
72 CF_EXPORT void CFMessagePortInvalidate(CFMessagePortRef ms);
73 CF_EXPORT Boolean CFMessagePortIsValid(CFMessagePortRef ms);
74 CF_EXPORT CFMessagePortInvalidationCallBack CFMessagePortGetInvalidationCallBack(CFMessagePortRef ms);
75 CF_EXPORT void CFMessagePortSetInvalidationCallBack(CFMessagePortRef ms, CFMessagePortInvalidationCallBack callout);
76
77 /* NULL replyMode argument means no return value expected, dont wait for it */
78 CF_EXPORT SInt32 CFMessagePortSendRequest(CFMessagePortRef remote, SInt32 msgid, CFDataRef data, CFTimeInterval sendTimeout, CFTimeInterval rcvTimeout, CFStringRef replyMode, CFDataRef *returnData);
79
80 CF_EXPORT CFRunLoopSourceRef CFMessagePortCreateRunLoopSource(CFAllocatorRef allocator, CFMessagePortRef local, CFIndex order);
81
82 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
83 CF_EXPORT void CFMessagePortSetDispatchQueue(CFMessagePortRef ms, dispatch_queue_t queue) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
84 #endif
85
86 CF_EXTERN_C_END
87
88 #endif /* ! __COREFOUNDATION_CFMESSAGEPORT__ */
89