~ubuntu-branches/ubuntu/hoary/curl/hoary-security

« back to all changes in this revision

Viewing changes to lib/getinfo.c

  • Committer: Bazaar Package Importer
  • Author(s): Domenico Andreoli
  • Date: 2004-06-04 19:09:25 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040604190925-wy048bp31320r2z6
Tags: 7.12.0.is.7.11.2-1
* Reverted to version 7.11.2 (closes: #252348).
* Disabled support for libidn (closes: #252367). This is to leave
  curl in unstable as much similar as possible to the one in testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
 
1
/***************************************************************************
2
2
 *                                  _   _ ____  _     
3
3
 *  Project                     ___| | | |  _ \| |    
4
4
 *                             / __| | | | |_) | |    
5
5
 *                            | (__| |_| |  _ <| |___ 
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 2000, Daniel Stenberg, <daniel@haxx.se>, et al.
9
 
 *
10
 
 * In order to be useful for every potential user, curl and libcurl are
11
 
 * dual-licensed under the MPL and the MIT/X-derivate licenses.
12
 
 *
 
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
 * 
13
14
 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
14
15
 * copies of the Software, and permit persons to whom the Software is
15
 
 * furnished to do so, under the terms of the MPL or the MIT/X-derivate
16
 
 * licenses. You may pick one of these licenses.
 
16
 * furnished to do so, under the terms of the COPYING file.
17
17
 *
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: getinfo.c,v 1.18 2002/02/20 13:46:54 bagder Exp $
22
 
 *****************************************************************************/
 
21
 * $Id: getinfo.c,v 1.36 2004/03/11 21:51:55 bagder Exp $
 
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
25
25
 
26
26
#include <curl/curl.h>
27
27
 
28
28
#include "urldata.h"
 
29
#include "getinfo.h"
29
30
 
30
31
#include <stdio.h>
31
32
#include <string.h>
35
36
#include        <stdlib.h>
36
37
#endif
37
38
 
 
39
/* Make this the last #include */
 
40
#ifdef CURLDEBUG
 
41
#include "memdebug.h"
 
42
#else
 
43
#include <stdlib.h>
 
44
#endif
 
45
 
38
46
/*
39
47
 * This is supposed to be called in the beginning of a permform() session
40
48
 * and should reset all session-info variables
49
57
  pro->t_pretransfer = 0;
50
58
  pro->t_starttransfer = 0;
51
59
  pro->timespent = 0;
 
60
  pro->t_redirect = 0;
52
61
 
53
62
  info->httpcode = 0;
54
63
  info->httpversion=0;
66
75
CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
67
76
{
68
77
  va_list arg;
69
 
  long *param_longp;
70
 
  double *param_doublep;
71
 
  char **param_charp;
 
78
  long *param_longp=NULL;
 
79
  double *param_doublep=NULL;
 
80
  char **param_charp=NULL;
72
81
  va_start(arg, info);
73
82
 
74
83
  switch(info&CURLINFO_TYPEMASK) {
95
104
  case CURLINFO_EFFECTIVE_URL:
96
105
    *param_charp = data->change.url?data->change.url:(char *)"";
97
106
    break;
98
 
  case CURLINFO_HTTP_CODE:
 
107
  case CURLINFO_RESPONSE_CODE:
99
108
    *param_longp = data->info.httpcode;
100
109
    break;
 
110
  case CURLINFO_HTTP_CONNECTCODE:
 
111
    *param_longp = data->info.httpproxycode;
 
112
    break;
101
113
  case CURLINFO_FILETIME:
102
114
    *param_longp = data->info.filetime;
103
115
    break;
123
135
    *param_doublep = data->progress.t_starttransfer;
124
136
    break;
125
137
  case CURLINFO_SIZE_UPLOAD:
126
 
    *param_doublep =  data->progress.uploaded;
 
138
    *param_doublep =  (double)data->progress.uploaded;
127
139
    break;
128
140
  case CURLINFO_SIZE_DOWNLOAD:
129
 
    *param_doublep = data->progress.downloaded;
 
141
    *param_doublep = (double)data->progress.downloaded;
130
142
    break;
131
143
  case CURLINFO_SPEED_DOWNLOAD:
132
 
    *param_doublep =  data->progress.dlspeed;
 
144
    *param_doublep =  (double)data->progress.dlspeed;
133
145
    break;
134
146
  case CURLINFO_SPEED_UPLOAD:
135
 
    *param_doublep = data->progress.ulspeed;
 
147
    *param_doublep = (double)data->progress.ulspeed;
136
148
    break;
137
149
  case CURLINFO_SSL_VERIFYRESULT:
138
150
    *param_longp = data->set.ssl.certverifyresult;
139
151
    break;
140
152
  case CURLINFO_CONTENT_LENGTH_DOWNLOAD:
141
 
    *param_doublep = data->progress.size_dl;
 
153
    *param_doublep = (double)data->progress.size_dl;
142
154
    break;
143
155
  case CURLINFO_CONTENT_LENGTH_UPLOAD:
144
 
    *param_doublep = data->progress.size_ul;
 
156
    *param_doublep = (double)data->progress.size_ul;
 
157
    break;
 
158
  case CURLINFO_REDIRECT_TIME:
 
159
    *param_doublep =  data->progress.t_redirect;
 
160
    break;
 
161
  case CURLINFO_REDIRECT_COUNT:
 
162
    *param_longp = data->set.followlocation;
145
163
    break;
146
164
  case CURLINFO_CONTENT_TYPE:
147
165
    *param_charp = data->info.contenttype;
148
166
    break;
 
167
  case CURLINFO_PRIVATE:
 
168
    *param_charp = data->set.private;
 
169
    break;
 
170
  case CURLINFO_HTTPAUTH_AVAIL:
 
171
    *param_longp = data->info.httpauthavail;
 
172
    break;
 
173
  case CURLINFO_PROXYAUTH_AVAIL:
 
174
    *param_longp = data->info.proxyauthavail;
 
175
    break;
149
176
  default:
150
177
    return CURLE_BAD_FUNCTION_ARGUMENT;
151
178
  }
152
179
  return CURLE_OK;
153
180
}
154
 
 
155
 
/*
156
 
 * local variables:
157
 
 * eval: (load-file "../curl-mode.el")
158
 
 * end:
159
 
 * vim600: fdm=marker
160
 
 * vim: et sw=2 ts=2 sts=2 tw=78
161
 
 */