Libinfo-129.tar.gz
[apple/libinfo.git] / lookup.subproj / netdb_async.h
1 /*
2 * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Portions Copyright (c) 2002 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25 #ifndef _NETDB_ASYNC_H_
26 #define _NETDB_ASYNC_H_
27
28 #include <sys/cdefs.h>
29 #include <mach/mach.h>
30 #include <netdb.h>
31
32 __BEGIN_DECLS
33
34 /*
35 @typedef gethostbyaddr_async_callback
36 @discussion Type of the callback function used when a
37 gethostbyaddr_async_start() request is delivered.
38 @param hent The resolved host entry.
39 @param context The context provided when the request
40 was initiated.
41 */
42 typedef void (*gethostbyaddr_async_callback) (
43 struct hostent *hent,
44 void *context
45 );
46
47 /*!
48 @function gethostbyaddr_async_start
49 @description Asynchronously resolves an Internet address
50 @param addr The address to be resolved.
51 @param len The length, in bytes, of the address.
52 @param type
53 @param callout The function to be called when the specified
54 address has been resolved.
55 @param context A user specified context which will be passed
56 to the callout function.
57 @result A mach reply port which will be sent a message when
58 the addr resolution has completed. This message
59 should be passed to the gethostbyaddr_async_handleReply
60 function. A NULL value indicates that no address
61 was specified or some other error occurred which
62 prevented the resolution from being started.
63 */
64 mach_port_t
65 gethostbyaddr_async_start (
66 const char *addr,
67 int len,
68 int type,
69 gethostbyaddr_async_callback callout,
70 void *context
71 );
72
73
74 /*!
75 @function gethostbyaddr_async_handleReply
76 @description This function should be called with the Mach message sent
77 to the port returned by the call to gethostbyaddr_async_start.
78 The reply message will be interpreted and will result in a
79 call to the specified callout function.
80 @param replyMsg The Mach message.
81 */
82 void
83 gethostbyaddr_async_handleReply (
84 void *replyMsg
85 );
86
87
88 /*
89 @typedef gethostbyname_async_callback
90 @discussion Type of the callback function used when a
91 gethostbyname_async_start() request is delivered.
92 @param hent The resolved host entry.
93 @param context The context provided when the request
94 was initiated.
95 */
96 typedef void (*gethostbyname_async_callback) (
97 struct hostent *hent,
98 void *context
99 );
100
101 /*!
102 @function gethostbyname_async_start
103 @description Asynchronously resolves a hostname
104 @param name The hostname to be resolved.
105 @param callout The function to be called when the specified
106 hostname has been resolved.
107 @param context A user specified context which will be passed
108 to the callout function.
109 @result A mach reply port which will be sent a message when
110 the name resolution has completed. This message
111 should be passed to the gethostbyname_async_handleReply
112 function. A NULL value indicates that no hostname
113 was specified or some other error occurred which
114 prevented the resolution from being started.
115 */
116 mach_port_t
117 gethostbyname_async_start (
118 const char *name,
119 gethostbyname_async_callback callout,
120 void *context
121 );
122
123
124 /*!
125 @function gethostbyname_async_handleReply
126 @description This function should be called with the Mach message sent
127 to the port returned by the call to gethostbyname_async_start.
128 The reply message will be interpreted and will result in a
129 call to the specified callout function.
130 @param replyMsg The Mach message.
131 */
132 void
133 gethostbyname_async_handleReply (
134 void *replyMsg
135 );
136
137
138 /*
139 @typedef getipnodebyaddr_async_callback
140 @discussion Type of the callback function used when a
141 getipnodebyaddr_async_start() request is delivered.
142 @param hent The resolved host entry. If not NULL, the caller
143 must call freehostent() on the host entry.
144 @param error If error code if the resolved host entry is NULL
145 @param context The context provided when the request
146 was initiated.
147 */
148 typedef void (*getipnodebyaddr_async_callback) (
149 struct hostent *hent,
150 int error,
151 void *context
152 );
153
154 /*!
155 @function getipnodebyaddr_async_start
156 @description Asynchronously resolves an Internet address
157 @param addr The address to be resolved.
158 @param len The length, in bytes, of the address.
159 @param af The address family
160 @param error
161 @param callout The function to be called when the specified
162 address has been resolved.
163 @param context A user specified context which will be passed
164 to the callout function.
165 @result A mach reply port which will be sent a message when
166 the addr resolution has completed. This message
167 should be passed to the getipnodebyaddr_async_handleReply
168 function. A NULL value indicates that no address
169 was specified or some other error occurred which
170 prevented the resolution from being started.
171 */
172 mach_port_t
173 getipnodebyaddr_async_start (
174 const void *addr,
175 size_t len,
176 int af,
177 int *error,
178 getipnodebyaddr_async_callback callout,
179 void *context
180 );
181
182
183 /*!
184 @function getipnodebyaddr_async_handleReply
185 @description This function should be called with the Mach message sent
186 to the port returned by the call to getipnodebyaddr_async_start.
187 The reply message will be interpreted and will result in a
188 call to the specified callout function.
189 @param replyMsg The Mach message.
190 */
191 void
192 getipnodebyaddr_async_handleReply (
193 void *replyMsg
194 );
195
196
197 /*
198 @typedef getipnodebyname_async_callback
199 @discussion Type of the callback function used when a
200 getipnodebyname_async_start() request is delivered.
201 @param hent The resolved host entry. If not NULL, the caller
202 must call freehostent() on the host entry.
203 @param error If error code if the resolved host entry is NULL
204 @param context The context provided when the request
205 was initiated.
206 */
207 typedef void (*getipnodebyname_async_callback) (
208 struct hostent *hent,
209 int error,
210 void *context
211 );
212
213 /*!
214 @function getipnodebyname_async_start
215 @description Asynchronously resolves a hostname
216 @param name The hostname to be resolved.
217 @param af
218 @param flags
219 @param error
220 @param callout The function to be called when the specified
221 hostname has been resolved.
222 @param context A user specified context which will be passed
223 to the callout function.
224 @result A mach reply port which will be sent a message when
225 the name resolution has completed. This message
226 should be passed to the getipnodebyname_async_handleReply
227 function. A NULL value indicates that no hostname
228 was specified or some other error occurred which
229 prevented the resolution from being started.
230 */
231 mach_port_t
232 getipnodebyname_async_start (
233 const char *name,
234 int af,
235 int flags,
236 int *error,
237 getipnodebyname_async_callback callout,
238 void *context
239 );
240
241
242 /*!
243 @function getipnodebyname_async_handleReply
244 @description This function should be called with the Mach message sent
245 to the port returned by the call to getipnodebyname_async_start.
246 The reply message will be interpreted and will result in a
247 call to the specified callout function.
248 @param replyMsg The Mach message.
249 */
250 void
251 getipnodebyname_async_handleReply (
252 void *replyMsg
253 );
254
255 __END_DECLS
256
257 #endif /* !_NETDB_ASYNC_H_ */