3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2005, 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.
24 ***************************************************************************/
26 This is meant to be the "external" header file. Don't give away any
29 This document presents a mixture of ideas from at least:
35 -------------------------------------------
38 o Enable a "pull" interface. The application that uses libcurl decides where
39 and when to ask libcurl to get/send data.
41 o Enable multiple simultaneous transfers in the same thread without making it
42 complicated for the application.
44 o Enable the application to select() on its own file descriptors and curl's
45 file descriptors simultaneous easily.
48 #if defined(_WIN32) && !defined(WIN32)
49 /* Chris Lewis mentioned that he doesn't get WIN32 defined, only _WIN32 so we
50 make this adjustment to catch this. */
54 #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) || \
56 #if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H))
57 /* The check above prevents the winsock2 inclusion if winsock.h already was
58 included, since they can't co-exist without problems */
63 /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
64 libc5-based Linux systems. Only include it on system that are known to
66 #if defined(_AIX) || defined(NETWARE)
67 #include <sys/select.h>
71 #include <sys/socket.h>
74 #include <sys/types.h>
86 CURLM_CALL_MULTI_PERFORM=-1, /* please call curl_multi_perform() soon */
88 CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
89 CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
90 CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
91 CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
96 CURLMSG_NONE, /* first, not used */
97 CURLMSG_DONE, /* This easy handle has completed. 'result' contains
98 the CURLcode of the transfer */
99 CURLMSG_LAST /* last, not used */
103 CURLMSG msg; /* what this message means */
104 CURL *easy_handle; /* the handle it concerns */
106 void *whatever; /* message-specific data */
107 CURLcode result; /* return code for transfer */
110 typedef struct CURLMsg CURLMsg;
113 * Name: curl_multi_init()
115 * Desc: inititalize multi-style curl usage
116 * Returns: a new CURLM handle to use in all 'curl_multi' functions.
118 CURL_EXTERN CURLM *curl_multi_init(void);
121 * Name: curl_multi_add_handle()
123 * Desc: add a standard curl handle to the multi stack
124 * Returns: CURLMcode type, general multi error code.
126 CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
130 * Name: curl_multi_remove_handle()
132 * Desc: removes a curl handle from the multi stack again
133 * Returns: CURLMcode type, general multi error code.
135 CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
139 * Name: curl_multi_fdset()
141 * Desc: Ask curl for its fd_set sets. The app can use these to select() or
142 * poll() on. We want curl_multi_perform() called as soon as one of
144 * Returns: CURLMcode type, general multi error code.
146 CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
148 fd_set *write_fd_set,
153 * Name: curl_multi_perform()
155 * Desc: When the app thinks there's data available for curl it calls this
156 * function to read/write whatever there is right now. This returns
157 * as soon as the reads and writes are done. This function does not
158 * require that there actually is data available for reading or that
159 * data can be written, it can be called just in case. It returns
160 * the number of handles that still transfer data in the second
161 * argument's integer-pointer.
163 * Returns: CURLMcode type, general multi error code. *NOTE* that this only
164 * returns errors etc regarding the whole multi stack. There might
165 * still have occurred problems on invidual transfers even when this
168 CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
169 int *running_handles);
172 * Name: curl_multi_cleanup()
174 * Desc: Cleans up and removes a whole multi stack. It does not free or
175 * touch any individual easy handles in any way. We need to define
176 * in what state those handles will be if this function is called
177 * in the middle of a transfer.
178 * Returns: CURLMcode type, general multi error code.
180 CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
183 * Name: curl_multi_info_read()
185 * Desc: Ask the multi handle if there's any messages/informationals from
186 * the individual transfers. Messages include informationals such as
187 * error code from the transfer or just the fact that a transfer is
188 * completed. More details on these should be written down as well.
190 * Repeated calls to this function will return a new struct each
191 * time, until a special "end of msgs" struct is returned as a signal
192 * that there is no more to get at this point.
194 * The data the returned pointer points to will not survive calling
195 * curl_multi_cleanup().
197 * The 'CURLMsg' struct is meant to be very simple and only contain
198 * very basic informations. If more involved information is wanted,
199 * we will provide the particular "transfer handle" in that struct
200 * and that should/could/would be used in subsequent
201 * curl_easy_getinfo() calls (or similar). The point being that we
202 * must never expose complex structs to applications, as then we'll
203 * undoubtably get backwards compatibility problems in the future.
205 * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
206 * of structs. It also writes the number of messages left in the
207 * queue (after this read) in the integer the second argument points
210 CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
214 * NAME curl_multi_strerror()
218 * The curl_multi_strerror function may be used to turn a CURLMcode value
219 * into the equivalent human readable error string. This is useful
220 * for printing meaningful error messages.
222 CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
225 } /* end of extern "C" */