doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lib507.c
Go to the documentation of this file.
1 #include "test.h"
2 
3 int test(char *URL)
4 {
5  CURL* curls;
6  CURLM* multi;
7  int still_running;
8  int i;
9  CURLMsg *msg;
10 
11  multi = curl_multi_init();
12 
13  curls=curl_easy_init();
14  curl_easy_setopt(curls, CURLOPT_URL, URL);
15  curl_multi_add_handle(multi, curls);
16 
17  while ( CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi, &still_running) );
18  while(still_running) {
19  struct timeval timeout;
20  int rc;
21  fd_set fdread;
22  fd_set fdwrite;
23  fd_set fdexcep;
24  int maxfd;
25  FD_ZERO(&fdread);
26  FD_ZERO(&fdwrite);
27  FD_ZERO(&fdexcep);
28  timeout.tv_sec = 1;
29  timeout.tv_usec = 0;
30  curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
31  rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
32  switch(rc) {
33  case -1:
34  break;
35  case 0:
36  default:
37  while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi, &still_running));
38  break;
39  }
40  }
41  msg = curl_multi_info_read(multi, &still_running);
42  /* this should now contain a result code from the easy handle,
43  get it */
44  i = msg->data.result;
45 
46  curl_multi_cleanup(multi);
47  curl_easy_cleanup(curls);
48 
49  return i; /* return the final return code */
50 }
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
long tv_sec
Definition: timeval.h:37
CURLcode result
Definition: multi.h:100
CURLcode curl_easy_setopt(CURL *curl, CURLoption option,...)
Definition: easy.c:217
int i
Definition: process.py:33
long tv_usec
Definition: timeval.h:38
int test(char *URL)
Definition: lib507.c:3
#define select(args...)
Definition: amigaos.h:39
CURLM * curl_multi_init(void)
Definition: multi.c:114
CURLMcode curl_multi_cleanup(CURLM *multi_handle)
Definition: multi.c:583
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
CURLMcode curl_multi_add_handle(CURLM *multi_handle, CURL *curl_handle)
Definition: multi.c:134
Definition: multi.h:95
void curl_easy_cleanup(CURL *curl)
Definition: easy.c:288
CURL * curl_easy_init(void)
Definition: easy.c:195
CURLMsg * curl_multi_info_read(CURLM *multi_handle, int *msgs_in_queue)
Definition: multi.c:614