1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * The contents of this file are subject to the Mozilla Public License
9 * Version 1.0 (the "License"); you may not use this file except in
10 * compliance with the License. You may obtain a copy of the License at
11 * http://www.mozilla.org/MPL/
13 * Software distributed under the License is distributed on an "AS IS"
14 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
15 * License for the specific language governing rights and limitations
18 * The Original Code is Curl.
20 * The Initial Developer of the Original Code is Daniel Stenberg.
22 * Portions created by the Initial Developer are Copyright (C) 1999.
23 * All Rights Reserved.
25 * ------------------------------------------------------------
27 * - Daniel Stenberg <daniel@haxx.se>
38 * ------------------------------------------------------------
39 ****************************************************************************/
43 #include <curl/curl.h>
51 CURLcode curl_getinfo(CURL *curl, CURLINFO info, ...)
55 double *param_doublep;
57 struct UrlData *data = (struct UrlData *)curl;
60 switch(info&CURLINFO_TYPEMASK) {
62 return CURLE_BAD_FUNCTION_ARGUMENT;
64 param_charp = va_arg(arg, char **);
65 if(NULL == param_charp)
66 return CURLE_BAD_FUNCTION_ARGUMENT;
69 param_longp = va_arg(arg, long *);
70 if(NULL == param_longp)
71 return CURLE_BAD_FUNCTION_ARGUMENT;
74 param_doublep = va_arg(arg, double *);
75 if(NULL == param_doublep)
76 return CURLE_BAD_FUNCTION_ARGUMENT;
81 case CURLINFO_EFFECTIVE_URL:
82 *param_charp = data->url?data->url:"";
84 case CURLINFO_HTTP_CODE:
85 *param_longp = data->progress.httpcode;
87 case CURLINFO_HEADER_SIZE:
88 *param_longp = data->header_size;
90 case CURLINFO_REQUEST_SIZE:
91 *param_longp = data->request_size;
93 case CURLINFO_TOTAL_TIME:
94 *param_doublep = data->progress.timespent;
96 case CURLINFO_NAMELOOKUP_TIME:
97 *param_doublep = data->progress.t_nslookup;
99 case CURLINFO_CONNECT_TIME:
100 *param_doublep = data->progress.t_connect;
102 case CURLINFO_PRETRANSFER_TIME:
103 *param_doublep = data->progress.t_pretransfer;
105 case CURLINFO_SIZE_UPLOAD:
106 *param_doublep = data->progress.uploaded;
108 case CURLINFO_SIZE_DOWNLOAD:
109 *param_doublep = data->progress.downloaded;
111 case CURLINFO_SPEED_DOWNLOAD:
112 *param_doublep = data->progress.dlspeed;
114 case CURLINFO_SPEED_UPLOAD:
115 *param_doublep = data->progress.ulspeed;
117 case CURLINFO_SSL_VERIFYRESULT:
118 *param_longp = data->ssl.certverifyresult;
121 return CURLE_BAD_FUNCTION_ARGUMENT;