doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
getinfo.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
10  * This software is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution. The terms
12  * are also available at http://curl.haxx.se/docs/copyright.html.
13  *
14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15  * copies of the Software, and permit persons to whom the Software is
16  * furnished to do so, under the terms of the COPYING file.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  * $Id: getinfo.c,v 1.36 2004/03/11 21:51:55 bagder Exp $
22  ***************************************************************************/
23 
24 #include "setup.h"
25 
26 #include <curl/curl.h>
27 
28 #include "urldata.h"
29 #include "getinfo.h"
30 
31 #include <stdio.h>
32 #include <string.h>
33 #include <stdarg.h>
34 
35 #ifdef VMS
36 #include <stdlib.h>
37 #endif
38 
39 /* Make this the last #include */
40 #ifdef CURLDEBUG
41 #include "memdebug.h"
42 #else
43 #include <stdlib.h>
44 #endif
45 
46 /*
47  * This is supposed to be called in the beginning of a permform() session
48  * and should reset all session-info variables
49  */
51 {
52  struct Progress *pro = &data->progress;
53  struct PureInfo *info =&data->info;
54 
55  pro->t_nslookup = 0;
56  pro->t_connect = 0;
57  pro->t_pretransfer = 0;
58  pro->t_starttransfer = 0;
59  pro->timespent = 0;
60  pro->t_redirect = 0;
61 
62  info->httpcode = 0;
63  info->httpversion=0;
64  info->filetime=-1; /* -1 is an illegal time and thus means unknown */
65 
66  if (info->contenttype)
67  free(info->contenttype);
68  info->contenttype = NULL;
69 
70  info->header_size = 0;
71  info->request_size = 0;
72  return CURLE_OK;
73 }
74 
76 {
77  va_list arg;
78  long *param_longp=NULL;
79  double *param_doublep=NULL;
80  char **param_charp=NULL;
81  va_start(arg, info);
82 
83  switch(info&CURLINFO_TYPEMASK) {
84  default:
86  case CURLINFO_STRING:
87  param_charp = va_arg(arg, char **);
88  if(NULL == param_charp)
90  break;
91  case CURLINFO_LONG:
92  param_longp = va_arg(arg, long *);
93  if(NULL == param_longp)
95  break;
96  case CURLINFO_DOUBLE:
97  param_doublep = va_arg(arg, double *);
98  if(NULL == param_doublep)
100  break;
101  }
102 
103  switch(info) {
105  *param_charp = data->change.url?data->change.url:(char *)"";
106  break;
108  *param_longp = data->info.httpcode;
109  break;
111  *param_longp = data->info.httpproxycode;
112  break;
113  case CURLINFO_FILETIME:
114  *param_longp = data->info.filetime;
115  break;
117  *param_longp = data->info.header_size;
118  break;
120  *param_longp = data->info.request_size;
121  break;
122  case CURLINFO_TOTAL_TIME:
123  *param_doublep = data->progress.timespent;
124  break;
126  *param_doublep = data->progress.t_nslookup;
127  break;
129  *param_doublep = data->progress.t_connect;
130  break;
132  *param_doublep = data->progress.t_pretransfer;
133  break;
135  *param_doublep = data->progress.t_starttransfer;
136  break;
138  *param_doublep = (double)data->progress.uploaded;
139  break;
141  *param_doublep = (double)data->progress.downloaded;
142  break;
144  *param_doublep = (double)data->progress.dlspeed;
145  break;
147  *param_doublep = (double)data->progress.ulspeed;
148  break;
150  *param_longp = data->set.ssl.certverifyresult;
151  break;
153  *param_doublep = (double)data->progress.size_dl;
154  break;
156  *param_doublep = (double)data->progress.size_ul;
157  break;
159  *param_doublep = data->progress.t_redirect;
160  break;
162  *param_longp = data->set.followlocation;
163  break;
165  *param_charp = data->info.contenttype;
166  break;
167  case CURLINFO_PRIVATE:
168  *param_charp = data->set.private;
169  break;
171  *param_longp = data->info.httpauthavail;
172  break;
174  *param_longp = data->info.proxyauthavail;
175  break;
176  default:
178  }
179  return CURLE_OK;
180 }
CURLcode Curl_initinfo(struct SessionHandle *data)
Definition: getinfo.c:50
CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info,...)
Definition: getinfo.c:75
curl_off_t uploaded
Definition: urldata.h:610
struct ssl_config_data ssl
Definition: urldata.h:829
struct DynamicStatic change
Definition: urldata.h:899
#define CURLINFO_DOUBLE
Definition: curl.h:1100
CURLcode
Definition: curl.h:209
CURLINFO
Definition: curl.h:1104
char * contenttype
Definition: urldata.h:600
#define CURLINFO_TYPEMASK
Definition: curl.h:1102
long request_size
Definition: urldata.h:595
char * private
Definition: urldata.h:836
double t_nslookup
Definition: urldata.h:623
curl_off_t downloaded
Definition: urldata.h:609
struct Progress progress
Definition: urldata.h:902
long header_size
Definition: urldata.h:594
long followlocation
Definition: urldata.h:775
struct PureInfo info
Definition: urldata.h:905
long proxyauthavail
Definition: urldata.h:597
char * url
Definition: urldata.h:734
#define NULL
Definition: Lib.h:88
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:2853
double t_pretransfer
Definition: urldata.h:625
int httpversion
Definition: urldata.h:589
double t_connect
Definition: urldata.h:624
Definition: curl.h:210
double t_redirect
Definition: urldata.h:627
int httpproxycode
Definition: urldata.h:588
double timespent
Definition: urldata.h:618
int httpcode
Definition: urldata.h:587
long httpauthavail
Definition: urldata.h:598
curl_off_t ulspeed
Definition: urldata.h:621
double t_starttransfer
Definition: urldata.h:626
curl_off_t size_ul
Definition: urldata.h:608
struct UserDefined set
Definition: urldata.h:898
#define CURLINFO_LONG
Definition: curl.h:1099
#define CURLINFO_STRING
Definition: curl.h:1098
long certverifyresult
Definition: urldata.h:146
long filetime
Definition: urldata.h:590
curl_off_t dlspeed
Definition: urldata.h:620
curl_off_t size_dl
Definition: urldata.h:607