multi.h
Go to the documentation of this file.
00001 #ifndef __CURL_MULTI_H
00002 #define __CURL_MULTI_H
00003 /***************************************************************************
00004  *                                  _   _ ____  _
00005  *  Project                     ___| | | |  _ \| |
00006  *                             / __| | | | |_) | |
00007  *                            | (__| |_| |  _ <| |___
00008  *                             \___|\___/|_| \_\_____|
00009  *
00010  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00011  *
00012  * This software is licensed as described in the file COPYING, which
00013  * you should have received as part of this distribution. The terms
00014  * are also available at https://curl.haxx.se/docs/copyright.html.
00015  *
00016  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00017  * copies of the Software, and permit persons to whom the Software is
00018  * furnished to do so, under the terms of the COPYING file.
00019  *
00020  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00021  * KIND, either express or implied.
00022  *
00023  ***************************************************************************/
00024 /*
00025   This is an "external" header file. Don't give away any internals here!
00026 
00027   GOALS
00028 
00029   o Enable a "pull" interface. The application that uses libcurl decides where
00030     and when to ask libcurl to get/send data.
00031 
00032   o Enable multiple simultaneous transfers in the same thread without making it
00033     complicated for the application.
00034 
00035   o Enable the application to select() on its own file descriptors and curl's
00036     file descriptors simultaneous easily.
00037 
00038 */
00039 
00040 /*
00041  * This header file should not really need to include "curl.h" since curl.h
00042  * itself includes this file and we expect user applications to do #include
00043  * <curl/curl.h> without the need for especially including multi.h.
00044  *
00045  * For some reason we added this include here at one point, and rather than to
00046  * break existing (wrongly written) libcurl applications, we leave it as-is
00047  * but with this warning attached.
00048  */
00049 #include "curl.h"
00050 
00051 #ifdef  __cplusplus
00052 extern "C" {
00053 #endif
00054 
00055 #if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
00056 typedef struct Curl_multi CURLM;
00057 #else
00058 typedef void CURLM;
00059 #endif
00060 
00061 typedef enum {
00062   CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
00063                                     curl_multi_socket*() soon */
00064   CURLM_OK,
00065   CURLM_BAD_HANDLE,      /* the passed-in handle is not a valid CURLM handle */
00066   CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
00067   CURLM_OUT_OF_MEMORY,   /* if you ever get this, you're in deep sh*t */
00068   CURLM_INTERNAL_ERROR,  /* this is a libcurl bug */
00069   CURLM_BAD_SOCKET,      /* the passed in socket argument did not match */
00070   CURLM_UNKNOWN_OPTION,  /* curl_multi_setopt() with unsupported option */
00071   CURLM_ADDED_ALREADY,   /* an easy handle already added to a multi handle was
00072                             attempted to get added - again */
00073   CURLM_LAST
00074 } CURLMcode;
00075 
00076 /* just to make code nicer when using curl_multi_socket() you can now check
00077    for CURLM_CALL_MULTI_SOCKET too in the same style it works for
00078    curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
00079 #define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
00080 
00081 /* bitmask bits for CURLMOPT_PIPELINING */
00082 #define CURLPIPE_NOTHING   0L
00083 #define CURLPIPE_HTTP1     1L
00084 #define CURLPIPE_MULTIPLEX 2L
00085 
00086 typedef enum {
00087   CURLMSG_NONE, /* first, not used */
00088   CURLMSG_DONE, /* This easy handle has completed. 'result' contains
00089                    the CURLcode of the transfer */
00090   CURLMSG_LAST /* last, not used */
00091 } CURLMSG;
00092 
00093 struct CURLMsg {
00094   CURLMSG msg;       /* what this message means */
00095   CURL *easy_handle; /* the handle it concerns */
00096   union {
00097     void *whatever;    /* message-specific data */
00098     CURLcode result;   /* return code for transfer */
00099   } data;
00100 };
00101 typedef struct CURLMsg CURLMsg;
00102 
00103 /* Based on poll(2) structure and values.
00104  * We don't use pollfd and POLL* constants explicitly
00105  * to cover platforms without poll(). */
00106 #define CURL_WAIT_POLLIN    0x0001
00107 #define CURL_WAIT_POLLPRI   0x0002
00108 #define CURL_WAIT_POLLOUT   0x0004
00109 
00110 struct curl_waitfd {
00111   curl_socket_t fd;
00112   short events;
00113   short revents; /* not supported yet */
00114 };
00115 
00116 /*
00117  * Name:    curl_multi_init()
00118  *
00119  * Desc:    inititalize multi-style curl usage
00120  *
00121  * Returns: a new CURLM handle to use in all 'curl_multi' functions.
00122  */
00123 CURL_EXTERN CURLM *curl_multi_init(void);
00124 
00125 /*
00126  * Name:    curl_multi_add_handle()
00127  *
00128  * Desc:    add a standard curl handle to the multi stack
00129  *
00130  * Returns: CURLMcode type, general multi error code.
00131  */
00132 CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
00133                                             CURL *curl_handle);
00134 
00135  /*
00136   * Name:    curl_multi_remove_handle()
00137   *
00138   * Desc:    removes a curl handle from the multi stack again
00139   *
00140   * Returns: CURLMcode type, general multi error code.
00141   */
00142 CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
00143                                                CURL *curl_handle);
00144 
00145  /*
00146   * Name:    curl_multi_fdset()
00147   *
00148   * Desc:    Ask curl for its fd_set sets. The app can use these to select() or
00149   *          poll() on. We want curl_multi_perform() called as soon as one of
00150   *          them are ready.
00151   *
00152   * Returns: CURLMcode type, general multi error code.
00153   */
00154 CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
00155                                        fd_set *read_fd_set,
00156                                        fd_set *write_fd_set,
00157                                        fd_set *exc_fd_set,
00158                                        int *max_fd);
00159 
00160 /*
00161  * Name:     curl_multi_wait()
00162  *
00163  * Desc:     Poll on all fds within a CURLM set as well as any
00164  *           additional fds passed to the function.
00165  *
00166  * Returns:  CURLMcode type, general multi error code.
00167  */
00168 CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
00169                                       struct curl_waitfd extra_fds[],
00170                                       unsigned int extra_nfds,
00171                                       int timeout_ms,
00172                                       int *ret);
00173 
00174  /*
00175   * Name:    curl_multi_perform()
00176   *
00177   * Desc:    When the app thinks there's data available for curl it calls this
00178   *          function to read/write whatever there is right now. This returns
00179   *          as soon as the reads and writes are done. This function does not
00180   *          require that there actually is data available for reading or that
00181   *          data can be written, it can be called just in case. It returns
00182   *          the number of handles that still transfer data in the second
00183   *          argument's integer-pointer.
00184   *
00185   * Returns: CURLMcode type, general multi error code. *NOTE* that this only
00186   *          returns errors etc regarding the whole multi stack. There might
00187   *          still have occurred problems on invidual transfers even when this
00188   *          returns OK.
00189   */
00190 CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
00191                                          int *running_handles);
00192 
00193  /*
00194   * Name:    curl_multi_cleanup()
00195   *
00196   * Desc:    Cleans up and removes a whole multi stack. It does not free or
00197   *          touch any individual easy handles in any way. We need to define
00198   *          in what state those handles will be if this function is called
00199   *          in the middle of a transfer.
00200   *
00201   * Returns: CURLMcode type, general multi error code.
00202   */
00203 CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
00204 
00205 /*
00206  * Name:    curl_multi_info_read()
00207  *
00208  * Desc:    Ask the multi handle if there's any messages/informationals from
00209  *          the individual transfers. Messages include informationals such as
00210  *          error code from the transfer or just the fact that a transfer is
00211  *          completed. More details on these should be written down as well.
00212  *
00213  *          Repeated calls to this function will return a new struct each
00214  *          time, until a special "end of msgs" struct is returned as a signal
00215  *          that there is no more to get at this point.
00216  *
00217  *          The data the returned pointer points to will not survive calling
00218  *          curl_multi_cleanup().
00219  *
00220  *          The 'CURLMsg' struct is meant to be very simple and only contain
00221  *          very basic informations. If more involved information is wanted,
00222  *          we will provide the particular "transfer handle" in that struct
00223  *          and that should/could/would be used in subsequent
00224  *          curl_easy_getinfo() calls (or similar). The point being that we
00225  *          must never expose complex structs to applications, as then we'll
00226  *          undoubtably get backwards compatibility problems in the future.
00227  *
00228  * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
00229  *          of structs. It also writes the number of messages left in the
00230  *          queue (after this read) in the integer the second argument points
00231  *          to.
00232  */
00233 CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
00234                                           int *msgs_in_queue);
00235 
00236 /*
00237  * Name:    curl_multi_strerror()
00238  *
00239  * Desc:    The curl_multi_strerror function may be used to turn a CURLMcode
00240  *          value into the equivalent human readable error string.  This is
00241  *          useful for printing meaningful error messages.
00242  *
00243  * Returns: A pointer to a zero-terminated error message.
00244  */
00245 CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
00246 
00247 /*
00248  * Name:    curl_multi_socket() and
00249  *          curl_multi_socket_all()
00250  *
00251  * Desc:    An alternative version of curl_multi_perform() that allows the
00252  *          application to pass in one of the file descriptors that have been
00253  *          detected to have "action" on them and let libcurl perform.
00254  *          See man page for details.
00255  */
00256 #define CURL_POLL_NONE   0
00257 #define CURL_POLL_IN     1
00258 #define CURL_POLL_OUT    2
00259 #define CURL_POLL_INOUT  3
00260 #define CURL_POLL_REMOVE 4
00261 
00262 #define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
00263 
00264 #define CURL_CSELECT_IN   0x01
00265 #define CURL_CSELECT_OUT  0x02
00266 #define CURL_CSELECT_ERR  0x04
00267 
00268 typedef int (*curl_socket_callback)(CURL *easy,      /* easy handle */
00269                                     curl_socket_t s, /* socket */
00270                                     int what,        /* see above */
00271                                     void *userp,     /* private callback
00272                                                         pointer */
00273                                     void *socketp);  /* private socket
00274                                                         pointer */
00275 /*
00276  * Name:    curl_multi_timer_callback
00277  *
00278  * Desc:    Called by libcurl whenever the library detects a change in the
00279  *          maximum number of milliseconds the app is allowed to wait before
00280  *          curl_multi_socket() or curl_multi_perform() must be called
00281  *          (to allow libcurl's timed events to take place).
00282  *
00283  * Returns: The callback should return zero.
00284  */
00285 typedef int (*curl_multi_timer_callback)(CURLM *multi,    /* multi handle */
00286                                          long timeout_ms, /* see above */
00287                                          void *userp);    /* private callback
00288                                                              pointer */
00289 
00290 CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
00291                                         int *running_handles);
00292 
00293 CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
00294                                                curl_socket_t s,
00295                                                int ev_bitmask,
00296                                                int *running_handles);
00297 
00298 CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
00299                                             int *running_handles);
00300 
00301 #ifndef CURL_ALLOW_OLD_MULTI_SOCKET
00302 /* This macro below was added in 7.16.3 to push users who recompile to use
00303    the new curl_multi_socket_action() instead of the old curl_multi_socket()
00304 */
00305 #define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
00306 #endif
00307 
00308 /*
00309  * Name:    curl_multi_timeout()
00310  *
00311  * Desc:    Returns the maximum number of milliseconds the app is allowed to
00312  *          wait before curl_multi_socket() or curl_multi_perform() must be
00313  *          called (to allow libcurl's timed events to take place).
00314  *
00315  * Returns: CURLM error code.
00316  */
00317 CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
00318                                          long *milliseconds);
00319 
00320 #undef CINIT /* re-using the same name as in curl.h */
00321 
00322 #ifdef CURL_ISOCPP
00323 #define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
00324 #else
00325 /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
00326 #define LONG          CURLOPTTYPE_LONG
00327 #define OBJECTPOINT   CURLOPTTYPE_OBJECTPOINT
00328 #define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
00329 #define OFF_T         CURLOPTTYPE_OFF_T
00330 #define CINIT(name,type,number) CURLMOPT_name = type + number
00331 #endif
00332 
00333 typedef enum {
00334   /* This is the socket callback function pointer */
00335   CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
00336 
00337   /* This is the argument passed to the socket callback */
00338   CINIT(SOCKETDATA, OBJECTPOINT, 2),
00339 
00340     /* set to 1 to enable pipelining for this multi handle */
00341   CINIT(PIPELINING, LONG, 3),
00342 
00343    /* This is the timer callback function pointer */
00344   CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
00345 
00346   /* This is the argument passed to the timer callback */
00347   CINIT(TIMERDATA, OBJECTPOINT, 5),
00348 
00349   /* maximum number of entries in the connection cache */
00350   CINIT(MAXCONNECTS, LONG, 6),
00351 
00352   /* maximum number of (pipelining) connections to one host */
00353   CINIT(MAX_HOST_CONNECTIONS, LONG, 7),
00354 
00355   /* maximum number of requests in a pipeline */
00356   CINIT(MAX_PIPELINE_LENGTH, LONG, 8),
00357 
00358   /* a connection with a content-length longer than this
00359      will not be considered for pipelining */
00360   CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9),
00361 
00362   /* a connection with a chunk length longer than this
00363      will not be considered for pipelining */
00364   CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10),
00365 
00366   /* a list of site names(+port) that are blacklisted from
00367      pipelining */
00368   CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11),
00369 
00370   /* a list of server types that are blacklisted from
00371      pipelining */
00372   CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12),
00373 
00374   /* maximum number of open connections in total */
00375   CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13),
00376 
00377    /* This is the server push callback function pointer */
00378   CINIT(PUSHFUNCTION, FUNCTIONPOINT, 14),
00379 
00380   /* This is the argument passed to the server push callback */
00381   CINIT(PUSHDATA, OBJECTPOINT, 15),
00382 
00383   CURLMOPT_LASTENTRY /* the last unused */
00384 } CURLMoption;
00385 
00386 
00387 /*
00388  * Name:    curl_multi_setopt()
00389  *
00390  * Desc:    Sets options for the multi handle.
00391  *
00392  * Returns: CURLM error code.
00393  */
00394 CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
00395                                         CURLMoption option, ...);
00396 
00397 
00398 /*
00399  * Name:    curl_multi_assign()
00400  *
00401  * Desc:    This function sets an association in the multi handle between the
00402  *          given socket and a private pointer of the application. This is
00403  *          (only) useful for curl_multi_socket uses.
00404  *
00405  * Returns: CURLM error code.
00406  */
00407 CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
00408                                         curl_socket_t sockfd, void *sockp);
00409 
00410 
00411 /*
00412  * Name: curl_push_callback
00413  *
00414  * Desc: This callback gets called when a new stream is being pushed by the
00415  *       server. It approves or denies the new stream.
00416  *
00417  * Returns: CURL_PUSH_OK or CURL_PUSH_DENY.
00418  */
00419 #define CURL_PUSH_OK   0
00420 #define CURL_PUSH_DENY 1
00421 
00422 struct curl_pushheaders;  /* forward declaration only */
00423 
00424 CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
00425                                         size_t num);
00426 CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
00427                                          const char *name);
00428 
00429 typedef int (*curl_push_callback)(CURL *parent,
00430                                   CURL *easy,
00431                                   size_t num_headers,
00432                                   struct curl_pushheaders *headers,
00433                                   void *userp);
00434 
00435 #ifdef __cplusplus
00436 } /* end of extern "C" */
00437 #endif
00438 
00439 #endif


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05