doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
multi.h
Go to the documentation of this file.
1 #ifndef __CURL_MULTI_H
2 #define __CURL_MULTI_H
3 /***************************************************************************
4  * _ _ ____ _
5  * Project ___| | | | _ \| |
6  * / __| | | | |_) | |
7  * | (__| |_| | _ <| |___
8  * \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
11  *
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.
15  *
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.
19  *
20  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21  * KIND, either express or implied.
22  *
23  * $Id: multi.h,v 1.17 2004/03/17 12:46:45 bagder Exp $
24  ***************************************************************************/
25 /*
26  This is meant to be the "external" header file. Don't give away any
27  internals here!
28 
29  This document presents a mixture of ideas from at least:
30  - Daniel Stenberg
31  - Steve Dekorte
32  - Sterling Hughes
33  - Ben Greear
34 
35  -------------------------------------------
36  GOALS
37 
38  o Enable a "pull" interface. The application that uses libcurl decides where
39  and when to ask libcurl to get/send data.
40 
41  o Enable multiple simultaneous transfers in the same thread without making it
42  complicated for the application.
43 
44  o Enable the application to select() on its own file descriptors and curl's
45  file descriptors simultaneous easily.
46 
47 */
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. */
51 #define WIN32 1
52 #endif
53 
54 #if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
55 #include <winsock2.h>
56 #else
57 
58 /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
59  libc5-based Linux systems. Only include it on system that are known to
60  require it! */
61 #if defined(_AIX) || defined(NETWARE)
62 #include <sys/select.h>
63 #endif
64 
65 #include <sys/socket.h>
66 #include <sys/time.h>
67 #include <sys/types.h>
68 #endif
69 
70 #include "curl.h"
71 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 
76 typedef void CURLM;
77 
78 typedef enum {
79  CURLM_CALL_MULTI_PERFORM=-1, /* please call curl_multi_perform() soon */
81  CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
82  CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
83  CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
84  CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
86 } CURLMcode;
87 
88 typedef enum {
89  CURLMSG_NONE, /* first, not used */
90  CURLMSG_DONE, /* This easy handle has completed. 'result' contains
91  the CURLcode of the transfer */
92  CURLMSG_LAST /* last, not used */
93 } CURLMSG;
94 
95 struct CURLMsg {
96  CURLMSG msg; /* what this message means */
97  CURL *easy_handle; /* the handle it concerns */
98  union {
99  void *whatever; /* message-specific data */
100  CURLcode result; /* return code for transfer */
101  } data;
102 };
103 typedef struct CURLMsg CURLMsg;
104 
105 /*
106  * Name: curl_multi_init()
107  *
108  * Desc: inititalize multi-style curl usage
109  * Returns: a new CURLM handle to use in all 'curl_multi' functions.
110  */
111 CURLM *curl_multi_init(void);
112 
113 /*
114  * Name: curl_multi_add_handle()
115  *
116  * Desc: add a standard curl handle to the multi stack
117  * Returns: CURLMcode type, general multi error code.
118  */
120  CURL *curl_handle);
121 
122  /*
123  * Name: curl_multi_remove_handle()
124  *
125  * Desc: removes a curl handle from the multi stack again
126  * Returns: CURLMcode type, general multi error code.
127  */
129  CURL *curl_handle);
130 
131  /*
132  * Name: curl_multi_fdset()
133  *
134  * Desc: Ask curl for its fd_set sets. The app can use these to select() or
135  * poll() on. We want curl_multi_perform() called as soon as one of
136  * them are ready.
137  * Returns: CURLMcode type, general multi error code.
138  */
140  fd_set *read_fd_set,
141  fd_set *write_fd_set,
142  fd_set *exc_fd_set,
143  int *max_fd);
144 
145  /*
146  * Name: curl_multi_perform()
147  *
148  * Desc: When the app thinks there's data available for curl it calls this
149  * function to read/write whatever there is right now. This returns
150  * as soon as the reads and writes are done. This function does not
151  * require that there actually is data available for reading or that
152  * data can be written, it can be called just in case. It returns
153  * the number of handles that still transfer data in the second
154  * argument's integer-pointer.
155  *
156  * Returns: CURLMcode type, general multi error code. *NOTE* that this only
157  * returns errors etc regarding the whole multi stack. There might
158  * still have occurred problems on invidual transfers even when this
159  * returns OK.
160  */
162  int *running_handles);
163 
164  /*
165  * Name: curl_multi_cleanup()
166  *
167  * Desc: Cleans up and removes a whole multi stack. It does not free or
168  * touch any individual easy handles in any way. We need to define
169  * in what state those handles will be if this function is called
170  * in the middle of a transfer.
171  * Returns: CURLMcode type, general multi error code.
172  */
174 
175 /*
176  * Name: curl_multi_info_read()
177  *
178  * Desc: Ask the multi handle if there's any messages/informationals from
179  * the individual transfers. Messages include informationals such as
180  * error code from the transfer or just the fact that a transfer is
181  * completed. More details on these should be written down as well.
182  *
183  * Repeated calls to this function will return a new struct each
184  * time, until a special "end of msgs" struct is returned as a signal
185  * that there is no more to get at this point.
186  *
187  * The data the returned pointer points to will not survive calling
188  * curl_multi_cleanup().
189  *
190  * The 'CURLMsg' struct is meant to be very simple and only contain
191  * very basic informations. If more involved information is wanted,
192  * we will provide the particular "transfer handle" in that struct
193  * and that should/could/would be used in subsequent
194  * curl_easy_getinfo() calls (or similar). The point being that we
195  * must never expose complex structs to applications, as then we'll
196  * undoubtably get backwards compatibility problems in the future.
197  *
198  * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
199  * of structs. It also writes the number of messages left in the
200  * queue (after this read) in the integer the second argument points
201  * to.
202  */
204  int *msgs_in_queue);
205 
206 #ifdef __cplusplus
207 } /* end of extern "C" */
208 #endif
209 
210 #endif
CURLMcode curl_multi_fdset(CURLM *multi_handle, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *exc_fd_set, int *max_fd)
Definition: multi.c:231
union CURLMsg::@3 data
CURLcode
Definition: curl.h:209
CURLcode result
Definition: multi.h:100
CURLM * multi_handle
Definition: fopen.c:81
CURLMcode curl_multi_remove_handle(CURLM *multi_handle, CURL *curl_handle)
Definition: multi.c:182
CURLM * curl_multi_init(void)
Definition: multi.c:114
CURLMcode curl_multi_cleanup(CURLM *multi_handle)
Definition: multi.c:583
CURL * easy_handle
Definition: multi.h:97
CURLMcode
Definition: multi.h:78
CURLMSG msg
Definition: multi.h:96
CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
Definition: multi.c:306
void CURLM
Definition: multi.h:76
void CURL
Definition: types.h:25
Definition: multi.h:80
CURLMcode curl_multi_add_handle(CURLM *multi_handle, CURL *curl_handle)
Definition: multi.c:134
Definition: multi.h:95
CURLMSG
Definition: multi.h:88
void * whatever
Definition: multi.h:99
CURLMsg * curl_multi_info_read(CURLM *multi_handle, int *msgs_in_queue)
Definition: multi.c:614