1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/google-breakpad/src/third_party/curl/multi.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,346 @@ 1.4 +#ifndef __CURL_MULTI_H 1.5 +#define __CURL_MULTI_H 1.6 +/*************************************************************************** 1.7 + * _ _ ____ _ 1.8 + * Project ___| | | | _ \| | 1.9 + * / __| | | | |_) | | 1.10 + * | (__| |_| | _ <| |___ 1.11 + * \___|\___/|_| \_\_____| 1.12 + * 1.13 + * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al. 1.14 + * 1.15 + * This software is licensed as described in the file COPYING, which 1.16 + * you should have received as part of this distribution. The terms 1.17 + * are also available at http://curl.haxx.se/docs/copyright.html. 1.18 + * 1.19 + * You may opt to use, copy, modify, merge, publish, distribute and/or sell 1.20 + * copies of the Software, and permit persons to whom the Software is 1.21 + * furnished to do so, under the terms of the COPYING file. 1.22 + * 1.23 + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 1.24 + * KIND, either express or implied. 1.25 + * 1.26 + * $Id: multi.h,v 1.45 2008-05-20 10:21:50 patrickm Exp $ 1.27 + ***************************************************************************/ 1.28 +/* 1.29 + This is an "external" header file. Don't give away any internals here! 1.30 + 1.31 + GOALS 1.32 + 1.33 + o Enable a "pull" interface. The application that uses libcurl decides where 1.34 + and when to ask libcurl to get/send data. 1.35 + 1.36 + o Enable multiple simultaneous transfers in the same thread without making it 1.37 + complicated for the application. 1.38 + 1.39 + o Enable the application to select() on its own file descriptors and curl's 1.40 + file descriptors simultaneous easily. 1.41 + 1.42 +*/ 1.43 + 1.44 +/* 1.45 + * This header file should not really need to include "curl.h" since curl.h 1.46 + * itself includes this file and we expect user applications to do #include 1.47 + * <curl/curl.h> without the need for especially including multi.h. 1.48 + * 1.49 + * For some reason we added this include here at one point, and rather than to 1.50 + * break existing (wrongly written) libcurl applications, we leave it as-is 1.51 + * but with this warning attached. 1.52 + */ 1.53 +#include "curl.h" 1.54 + 1.55 +#ifdef __cplusplus 1.56 +extern "C" { 1.57 +#endif 1.58 + 1.59 +typedef void CURLM; 1.60 + 1.61 +typedef enum { 1.62 + CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or 1.63 + curl_multi_socket*() soon */ 1.64 + CURLM_OK, 1.65 + CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */ 1.66 + CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */ 1.67 + CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */ 1.68 + CURLM_INTERNAL_ERROR, /* this is a libcurl bug */ 1.69 + CURLM_BAD_SOCKET, /* the passed in socket argument did not match */ 1.70 + CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */ 1.71 + CURLM_LAST 1.72 +} CURLMcode; 1.73 + 1.74 +/* just to make code nicer when using curl_multi_socket() you can now check 1.75 + for CURLM_CALL_MULTI_SOCKET too in the same style it works for 1.76 + curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */ 1.77 +#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM 1.78 + 1.79 +typedef enum { 1.80 + CURLMSG_NONE, /* first, not used */ 1.81 + CURLMSG_DONE, /* This easy handle has completed. 'result' contains 1.82 + the CURLcode of the transfer */ 1.83 + CURLMSG_LAST /* last, not used */ 1.84 +} CURLMSG; 1.85 + 1.86 +struct CURLMsg { 1.87 + CURLMSG msg; /* what this message means */ 1.88 + CURL *easy_handle; /* the handle it concerns */ 1.89 + union { 1.90 + void *whatever; /* message-specific data */ 1.91 + CURLcode result; /* return code for transfer */ 1.92 + } data; 1.93 +}; 1.94 +typedef struct CURLMsg CURLMsg; 1.95 + 1.96 +/* 1.97 + * Name: curl_multi_init() 1.98 + * 1.99 + * Desc: inititalize multi-style curl usage 1.100 + * 1.101 + * Returns: a new CURLM handle to use in all 'curl_multi' functions. 1.102 + */ 1.103 +CURL_EXTERN CURLM *curl_multi_init(void); 1.104 + 1.105 +/* 1.106 + * Name: curl_multi_add_handle() 1.107 + * 1.108 + * Desc: add a standard curl handle to the multi stack 1.109 + * 1.110 + * Returns: CURLMcode type, general multi error code. 1.111 + */ 1.112 +CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle, 1.113 + CURL *curl_handle); 1.114 + 1.115 + /* 1.116 + * Name: curl_multi_remove_handle() 1.117 + * 1.118 + * Desc: removes a curl handle from the multi stack again 1.119 + * 1.120 + * Returns: CURLMcode type, general multi error code. 1.121 + */ 1.122 +CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle, 1.123 + CURL *curl_handle); 1.124 + 1.125 + /* 1.126 + * Name: curl_multi_fdset() 1.127 + * 1.128 + * Desc: Ask curl for its fd_set sets. The app can use these to select() or 1.129 + * poll() on. We want curl_multi_perform() called as soon as one of 1.130 + * them are ready. 1.131 + * 1.132 + * Returns: CURLMcode type, general multi error code. 1.133 + */ 1.134 +CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle, 1.135 + fd_set *read_fd_set, 1.136 + fd_set *write_fd_set, 1.137 + fd_set *exc_fd_set, 1.138 + int *max_fd); 1.139 + 1.140 + /* 1.141 + * Name: curl_multi_perform() 1.142 + * 1.143 + * Desc: When the app thinks there's data available for curl it calls this 1.144 + * function to read/write whatever there is right now. This returns 1.145 + * as soon as the reads and writes are done. This function does not 1.146 + * require that there actually is data available for reading or that 1.147 + * data can be written, it can be called just in case. It returns 1.148 + * the number of handles that still transfer data in the second 1.149 + * argument's integer-pointer. 1.150 + * 1.151 + * Returns: CURLMcode type, general multi error code. *NOTE* that this only 1.152 + * returns errors etc regarding the whole multi stack. There might 1.153 + * still have occurred problems on invidual transfers even when this 1.154 + * returns OK. 1.155 + */ 1.156 +CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle, 1.157 + int *running_handles); 1.158 + 1.159 + /* 1.160 + * Name: curl_multi_cleanup() 1.161 + * 1.162 + * Desc: Cleans up and removes a whole multi stack. It does not free or 1.163 + * touch any individual easy handles in any way. We need to define 1.164 + * in what state those handles will be if this function is called 1.165 + * in the middle of a transfer. 1.166 + * 1.167 + * Returns: CURLMcode type, general multi error code. 1.168 + */ 1.169 +CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle); 1.170 + 1.171 +/* 1.172 + * Name: curl_multi_info_read() 1.173 + * 1.174 + * Desc: Ask the multi handle if there's any messages/informationals from 1.175 + * the individual transfers. Messages include informationals such as 1.176 + * error code from the transfer or just the fact that a transfer is 1.177 + * completed. More details on these should be written down as well. 1.178 + * 1.179 + * Repeated calls to this function will return a new struct each 1.180 + * time, until a special "end of msgs" struct is returned as a signal 1.181 + * that there is no more to get at this point. 1.182 + * 1.183 + * The data the returned pointer points to will not survive calling 1.184 + * curl_multi_cleanup(). 1.185 + * 1.186 + * The 'CURLMsg' struct is meant to be very simple and only contain 1.187 + * very basic informations. If more involved information is wanted, 1.188 + * we will provide the particular "transfer handle" in that struct 1.189 + * and that should/could/would be used in subsequent 1.190 + * curl_easy_getinfo() calls (or similar). The point being that we 1.191 + * must never expose complex structs to applications, as then we'll 1.192 + * undoubtably get backwards compatibility problems in the future. 1.193 + * 1.194 + * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out 1.195 + * of structs. It also writes the number of messages left in the 1.196 + * queue (after this read) in the integer the second argument points 1.197 + * to. 1.198 + */ 1.199 +CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle, 1.200 + int *msgs_in_queue); 1.201 + 1.202 +/* 1.203 + * Name: curl_multi_strerror() 1.204 + * 1.205 + * Desc: The curl_multi_strerror function may be used to turn a CURLMcode 1.206 + * value into the equivalent human readable error string. This is 1.207 + * useful for printing meaningful error messages. 1.208 + * 1.209 + * Returns: A pointer to a zero-terminated error message. 1.210 + */ 1.211 +CURL_EXTERN const char *curl_multi_strerror(CURLMcode); 1.212 + 1.213 +/* 1.214 + * Name: curl_multi_socket() and 1.215 + * curl_multi_socket_all() 1.216 + * 1.217 + * Desc: An alternative version of curl_multi_perform() that allows the 1.218 + * application to pass in one of the file descriptors that have been 1.219 + * detected to have "action" on them and let libcurl perform. 1.220 + * See man page for details. 1.221 + */ 1.222 +#define CURL_POLL_NONE 0 1.223 +#define CURL_POLL_IN 1 1.224 +#define CURL_POLL_OUT 2 1.225 +#define CURL_POLL_INOUT 3 1.226 +#define CURL_POLL_REMOVE 4 1.227 + 1.228 +#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD 1.229 + 1.230 +#define CURL_CSELECT_IN 0x01 1.231 +#define CURL_CSELECT_OUT 0x02 1.232 +#define CURL_CSELECT_ERR 0x04 1.233 + 1.234 +typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */ 1.235 + curl_socket_t s, /* socket */ 1.236 + int what, /* see above */ 1.237 + void *userp, /* private callback 1.238 + pointer */ 1.239 + void *socketp); /* private socket 1.240 + pointer */ 1.241 +/* 1.242 + * Name: curl_multi_timer_callback 1.243 + * 1.244 + * Desc: Called by libcurl whenever the library detects a change in the 1.245 + * maximum number of milliseconds the app is allowed to wait before 1.246 + * curl_multi_socket() or curl_multi_perform() must be called 1.247 + * (to allow libcurl's timed events to take place). 1.248 + * 1.249 + * Returns: The callback should return zero. 1.250 + */ 1.251 +typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */ 1.252 + long timeout_ms, /* see above */ 1.253 + void *userp); /* private callback 1.254 + pointer */ 1.255 + 1.256 +CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s, 1.257 + int *running_handles); 1.258 + 1.259 +CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle, 1.260 + curl_socket_t s, 1.261 + int ev_bitmask, 1.262 + int *running_handles); 1.263 + 1.264 +CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle, 1.265 + int *running_handles); 1.266 + 1.267 +#ifndef CURL_ALLOW_OLD_MULTI_SOCKET 1.268 +/* This macro below was added in 7.16.3 to push users who recompile to use 1.269 + the new curl_multi_socket_action() instead of the old curl_multi_socket() 1.270 +*/ 1.271 +#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z) 1.272 +#endif 1.273 + 1.274 +/* 1.275 + * Name: curl_multi_timeout() 1.276 + * 1.277 + * Desc: Returns the maximum number of milliseconds the app is allowed to 1.278 + * wait before curl_multi_socket() or curl_multi_perform() must be 1.279 + * called (to allow libcurl's timed events to take place). 1.280 + * 1.281 + * Returns: CURLM error code. 1.282 + */ 1.283 +CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle, 1.284 + long *milliseconds); 1.285 + 1.286 +#undef CINIT /* re-using the same name as in curl.h */ 1.287 + 1.288 +#ifdef CURL_ISOCPP 1.289 +#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num 1.290 +#else 1.291 +/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ 1.292 +#define LONG CURLOPTTYPE_LONG 1.293 +#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT 1.294 +#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT 1.295 +#define OFF_T CURLOPTTYPE_OFF_T 1.296 +#define CINIT(name,type,number) CURLMOPT_/**/name = type + number 1.297 +#endif 1.298 + 1.299 +typedef enum { 1.300 + /* This is the socket callback function pointer */ 1.301 + CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1), 1.302 + 1.303 + /* This is the argument passed to the socket callback */ 1.304 + CINIT(SOCKETDATA, OBJECTPOINT, 2), 1.305 + 1.306 + /* set to 1 to enable pipelining for this multi handle */ 1.307 + CINIT(PIPELINING, LONG, 3), 1.308 + 1.309 + /* This is the timer callback function pointer */ 1.310 + CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4), 1.311 + 1.312 + /* This is the argument passed to the timer callback */ 1.313 + CINIT(TIMERDATA, OBJECTPOINT, 5), 1.314 + 1.315 + /* maximum number of entries in the connection cache */ 1.316 + CINIT(MAXCONNECTS, LONG, 6), 1.317 + 1.318 + CURLMOPT_LASTENTRY /* the last unused */ 1.319 +} CURLMoption; 1.320 + 1.321 + 1.322 +/* 1.323 + * Name: curl_multi_setopt() 1.324 + * 1.325 + * Desc: Sets options for the multi handle. 1.326 + * 1.327 + * Returns: CURLM error code. 1.328 + */ 1.329 +CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle, 1.330 + CURLMoption option, ...); 1.331 + 1.332 + 1.333 +/* 1.334 + * Name: curl_multi_assign() 1.335 + * 1.336 + * Desc: This function sets an association in the multi handle between the 1.337 + * given socket and a private pointer of the application. This is 1.338 + * (only) useful for curl_multi_socket uses. 1.339 + * 1.340 + * Returns: CURLM error code. 1.341 + */ 1.342 +CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle, 1.343 + curl_socket_t sockfd, void *sockp); 1.344 + 1.345 +#ifdef __cplusplus 1.346 +} /* end of extern "C" */ 1.347 +#endif 1.348 + 1.349 +#endif