doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lib503.c
Go to the documentation of this file.
1 #include "test.h"
2 
3 #include <sys/time.h>
4 #include <sys/types.h>
5 
6 /*
7  * Source code in here hugely as reported in bug report 651460 by
8  * Christopher R. Palmer.
9  *
10  * Use multi interface to get HTTPS document over proxy, and provide
11  * auth info.
12  */
13 
14 int test(char *URL)
15 {
16  CURL *c;
17  CURLM *m;
18 
20  c = curl_easy_init();
21  curl_easy_setopt(c, CURLOPT_PROXY, arg2); /* set in first.c */
22  curl_easy_setopt(c, CURLOPT_URL, URL);
23  curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing");
24  curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
25  curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1);
26  curl_easy_setopt(c, CURLOPT_HEADER, 1);
27 
28  {
29  CURLMcode res;
30  int running;
31  char done=FALSE;
32 
33  m = curl_multi_init();
34 
35  res = curl_multi_add_handle(m, c);
36 
37  while(!done) {
38  fd_set rd, wr, exc;
39  int max_fd;
40  struct timeval interval;
41 
42  interval.tv_sec = 1;
43  interval.tv_usec = 0;
44 
45  while (res == CURLM_CALL_MULTI_PERFORM) {
46  res = curl_multi_perform(m, &running);
47  if (running <= 0) {
48  done = TRUE;
49  break;
50  }
51  }
52  if(done)
53  break;
54 
55  if (res != CURLM_OK) {
56  fprintf(stderr, "not okay???\n");
57  return 80;
58  }
59 
60  FD_ZERO(&rd);
61  FD_ZERO(&wr);
62  FD_ZERO(&exc);
63  max_fd = 0;
64 
65  if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
66  fprintf(stderr, "unexpected failured of fdset.\n");
67  return 89;
68  }
69 
70  if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
71  fprintf(stderr, "bad select??\n");
72  return 95;
73  }
74 
76  }
77  }
81 
82  return CURLE_OK;
83 }
84 
CURLcode curl_global_init(long flags)
Globally initializes cURL given a bitwise set of the different features to initialize.
Definition: easy.c:147
int test(char *URL)
Definition: lib503.c:14
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
long tv_sec
Definition: timeval.h:37
CURLcode curl_easy_setopt(CURL *curl, CURLoption option,...)
Definition: easy.c:217
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: glext.h:5286
long tv_usec
Definition: timeval.h:38
const GLubyte * c
Definition: glext.h:4677
CURLMcode curl_multi_remove_handle(CURLM *multi_handle, CURL *curl_handle)
Definition: multi.c:182
#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
Definition: curl.h:210
CURLMcode
Definition: multi.h:78
CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
Definition: multi.c:306
void CURLM
Definition: multi.h:76
#define FALSE
Definition: mprintf.c:70
Definition: multi.h:80
void CURL
Definition: types.h:25
GLuint res
Definition: glext.h:5385
#define TRUE
Definition: mprintf.c:69
CURLMcode curl_multi_add_handle(CURLM *multi_handle, CURL *curl_handle)
Definition: multi.c:134
#define CURL_GLOBAL_ALL
Definition: curl.h:1153
void curl_easy_cleanup(CURL *curl)
Definition: easy.c:288
CURL * curl_easy_init(void)
Definition: easy.c:195