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