help: fix FreqScope
[supercollider.git] / external_libraries / curl / multi.h
blobeada5e7a8404b4dbd86a44482da5dc13b717afa2
1 #ifndef __CURL_MULTI_H
2 #define __CURL_MULTI_H
3 /***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at http://curl.haxx.se/docs/copyright.html.
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 * $Id: multi.h,v 1.44 2007-05-30 20:04:44 bagder Exp $
24 ***************************************************************************/
26 This is an "external" header file. Don't give away any internals here!
28 GOALS
30 o Enable a "pull" interface. The application that uses libcurl decides where
31 and when to ask libcurl to get/send data.
33 o Enable multiple simultaneous transfers in the same thread without making it
34 complicated for the application.
36 o Enable the application to select() on its own file descriptors and curl's
37 file descriptors simultaneous easily.
42 * This header file should not really need to include "curl.h" since curl.h
43 * itself includes this file and we expect user applications to do #include
44 * <curl/curl.h> without the need for especially including multi.h.
46 * For some reason we added this include here at one point, and rather than to
47 * break existing (wrongly written) libcurl applications, we leave it as-is
48 * but with this warning attached.
50 #include "curl.h"
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
56 typedef void CURLM;
58 typedef enum {
59 CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
60 curl_multi_socket*() soon */
61 CURLM_OK,
62 CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
63 CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
64 CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
65 CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
66 CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
67 CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
68 CURLM_LAST
69 } CURLMcode;
71 /* just to make code nicer when using curl_multi_socket() you can now check
72 for CURLM_CALL_MULTI_SOCKET too in the same style it works for
73 curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
74 #define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
76 typedef enum {
77 CURLMSG_NONE, /* first, not used */
78 CURLMSG_DONE, /* This easy handle has completed. 'result' contains
79 the CURLcode of the transfer */
80 CURLMSG_LAST /* last, not used */
81 } CURLMSG;
83 struct CURLMsg {
84 CURLMSG msg; /* what this message means */
85 CURL *easy_handle; /* the handle it concerns */
86 union {
87 void *whatever; /* message-specific data */
88 CURLcode result; /* return code for transfer */
89 } data;
91 typedef struct CURLMsg CURLMsg;
94 * Name: curl_multi_init()
96 * Desc: inititalize multi-style curl usage
98 * Returns: a new CURLM handle to use in all 'curl_multi' functions.
100 CURL_EXTERN CURLM *curl_multi_init(void);
103 * Name: curl_multi_add_handle()
105 * Desc: add a standard curl handle to the multi stack
107 * Returns: CURLMcode type, general multi error code.
109 CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
110 CURL *curl_handle);
113 * Name: curl_multi_remove_handle()
115 * Desc: removes a curl handle from the multi stack again
117 * Returns: CURLMcode type, general multi error code.
119 CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
120 CURL *curl_handle);
123 * Name: curl_multi_fdset()
125 * Desc: Ask curl for its fd_set sets. The app can use these to select() or
126 * poll() on. We want curl_multi_perform() called as soon as one of
127 * them are ready.
129 * Returns: CURLMcode type, general multi error code.
131 CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
132 fd_set *read_fd_set,
133 fd_set *write_fd_set,
134 fd_set *exc_fd_set,
135 int *max_fd);
138 * Name: curl_multi_perform()
140 * Desc: When the app thinks there's data available for curl it calls this
141 * function to read/write whatever there is right now. This returns
142 * as soon as the reads and writes are done. This function does not
143 * require that there actually is data available for reading or that
144 * data can be written, it can be called just in case. It returns
145 * the number of handles that still transfer data in the second
146 * argument's integer-pointer.
148 * Returns: CURLMcode type, general multi error code. *NOTE* that this only
149 * returns errors etc regarding the whole multi stack. There might
150 * still have occurred problems on invidual transfers even when this
151 * returns OK.
153 CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
154 int *running_handles);
157 * Name: curl_multi_cleanup()
159 * Desc: Cleans up and removes a whole multi stack. It does not free or
160 * touch any individual easy handles in any way. We need to define
161 * in what state those handles will be if this function is called
162 * in the middle of a transfer.
164 * Returns: CURLMcode type, general multi error code.
166 CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
169 * Name: curl_multi_info_read()
171 * Desc: Ask the multi handle if there's any messages/informationals from
172 * the individual transfers. Messages include informationals such as
173 * error code from the transfer or just the fact that a transfer is
174 * completed. More details on these should be written down as well.
176 * Repeated calls to this function will return a new struct each
177 * time, until a special "end of msgs" struct is returned as a signal
178 * that there is no more to get at this point.
180 * The data the returned pointer points to will not survive calling
181 * curl_multi_cleanup().
183 * The 'CURLMsg' struct is meant to be very simple and only contain
184 * very basic informations. If more involved information is wanted,
185 * we will provide the particular "transfer handle" in that struct
186 * and that should/could/would be used in subsequent
187 * curl_easy_getinfo() calls (or similar). The point being that we
188 * must never expose complex structs to applications, as then we'll
189 * undoubtably get backwards compatibility problems in the future.
191 * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
192 * of structs. It also writes the number of messages left in the
193 * queue (after this read) in the integer the second argument points
194 * to.
196 CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
197 int *msgs_in_queue);
200 * Name: curl_multi_strerror()
202 * Desc: The curl_multi_strerror function may be used to turn a CURLMcode
203 * value into the equivalent human readable error string. This is
204 * useful for printing meaningful error messages.
206 * Returns: A pointer to a zero-terminated error message.
208 CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
211 * Name: curl_multi_socket() and
212 * curl_multi_socket_all()
214 * Desc: An alternative version of curl_multi_perform() that allows the
215 * application to pass in one of the file descriptors that have been
216 * detected to have "action" on them and let libcurl perform.
217 * See man page for details.
219 #define CURL_POLL_NONE 0
220 #define CURL_POLL_IN 1
221 #define CURL_POLL_OUT 2
222 #define CURL_POLL_INOUT 3
223 #define CURL_POLL_REMOVE 4
225 #define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
227 #define CURL_CSELECT_IN 0x01
228 #define CURL_CSELECT_OUT 0x02
229 #define CURL_CSELECT_ERR 0x04
231 typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
232 curl_socket_t s, /* socket */
233 int what, /* see above */
234 void *userp, /* private callback
235 pointer */
236 void *socketp); /* private socket
237 pointer */
239 * Name: curl_multi_timer_callback
241 * Desc: Called by libcurl whenever the library detects a change in the
242 * maximum number of milliseconds the app is allowed to wait before
243 * curl_multi_socket() or curl_multi_perform() must be called
244 * (to allow libcurl's timed events to take place).
246 * Returns: The callback should return zero.
248 typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
249 long timeout_ms, /* see above */
250 void *userp); /* private callback
251 pointer */
253 CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
254 int *running_handles);
256 CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
257 curl_socket_t s,
258 int ev_bitmask,
259 int *running_handles);
261 CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
262 int *running_handles);
264 #ifndef CURL_ALLOW_OLD_MULTI_SOCKET
265 /* This macro below was added in 7.16.3 to push users who recompile to use
266 the new curl_multi_socket_action() instead of the old curl_multi_socket()
268 #define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
269 #endif
272 * Name: curl_multi_timeout()
274 * Desc: Returns the maximum number of milliseconds the app is allowed to
275 * wait before curl_multi_socket() or curl_multi_perform() must be
276 * called (to allow libcurl's timed events to take place).
278 * Returns: CURLM error code.
280 CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
281 long *milliseconds);
283 #undef CINIT /* re-using the same name as in curl.h */
285 #ifdef CURL_ISOCPP
286 #define CINIT(name,type,number) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + number
287 #else
288 /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
289 #define LONG CURLOPTTYPE_LONG
290 #define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
291 #define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
292 #define OFF_T CURLOPTTYPE_OFF_T
293 #define CINIT(name,type,number) CURLMOPT_/**/name = type + number
294 #endif
296 typedef enum {
297 /* This is the socket callback function pointer */
298 CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
300 /* This is the argument passed to the socket callback */
301 CINIT(SOCKETDATA, OBJECTPOINT, 2),
303 /* set to 1 to enable pipelining for this multi handle */
304 CINIT(PIPELINING, LONG, 3),
306 /* This is the timer callback function pointer */
307 CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
309 /* This is the argument passed to the timer callback */
310 CINIT(TIMERDATA, OBJECTPOINT, 5),
312 /* maximum number of entries in the connection cache */
313 CINIT(MAXCONNECTS, LONG, 6),
315 CURLMOPT_LASTENTRY /* the last unused */
316 } CURLMoption;
320 * Name: curl_multi_setopt()
322 * Desc: Sets options for the multi handle.
324 * Returns: CURLM error code.
326 CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
327 CURLMoption option, ...);
331 * Name: curl_multi_assign()
333 * Desc: This function sets an association in the multi handle between the
334 * given socket and a private pointer of the application. This is
335 * (only) useful for curl_multi_socket uses.
337 * Returns: CURLM error code.
339 CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
340 curl_socket_t sockfd, void *sockp);
342 #ifdef __cplusplus
343 } /* end of extern "C" */
344 #endif
346 #endif