getinfo.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 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 https://curl.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. * SPDX-License-Identifier: curl
  22. *
  23. ***************************************************************************/
  24. #include "curl_setup.h"
  25. #include <curl/curl.h>
  26. #include "urldata.h"
  27. #include "getinfo.h"
  28. #include "vtls/vtls.h"
  29. #include "connect.h" /* Curl_getconnectinfo() */
  30. #include "progress.h"
  31. /* The last #include files should be: */
  32. #include "curl_memory.h"
  33. #include "memdebug.h"
  34. /*
  35. * Initialize statistical and informational data.
  36. *
  37. * This function is called in curl_easy_reset, curl_easy_duphandle and at the
  38. * beginning of a perform session. It must reset the session-info variables,
  39. * in particular all variables in struct PureInfo.
  40. */
  41. CURLcode Curl_initinfo(struct Curl_easy *data)
  42. {
  43. struct Progress *pro = &data->progress;
  44. struct PureInfo *info = &data->info;
  45. pro->t_nslookup = 0;
  46. pro->t_connect = 0;
  47. pro->t_appconnect = 0;
  48. pro->t_pretransfer = 0;
  49. pro->t_posttransfer = 0;
  50. pro->t_starttransfer = 0;
  51. pro->timespent = 0;
  52. pro->t_redirect = 0;
  53. pro->is_t_startransfer_set = FALSE;
  54. info->httpcode = 0;
  55. info->httpproxycode = 0;
  56. info->httpversion = 0;
  57. info->filetime = -1; /* -1 is an illegal time and thus means unknown */
  58. info->timecond = FALSE;
  59. info->header_size = 0;
  60. info->request_size = 0;
  61. info->proxyauthavail = 0;
  62. info->httpauthavail = 0;
  63. info->numconnects = 0;
  64. free(info->contenttype);
  65. info->contenttype = NULL;
  66. free(info->wouldredirect);
  67. info->wouldredirect = NULL;
  68. memset(&info->primary, 0, sizeof(info->primary));
  69. info->primary.remote_port = -1;
  70. info->primary.local_port = -1;
  71. info->retry_after = 0;
  72. info->conn_scheme = 0;
  73. info->conn_protocol = 0;
  74. #ifdef USE_SSL
  75. Curl_ssl_free_certinfo(data);
  76. #endif
  77. return CURLE_OK;
  78. }
  79. static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,
  80. const char **param_charp)
  81. {
  82. switch(info) {
  83. case CURLINFO_EFFECTIVE_URL:
  84. *param_charp = data->state.url ? data->state.url : (char *)"";
  85. break;
  86. case CURLINFO_EFFECTIVE_METHOD: {
  87. const char *m = data->set.str[STRING_CUSTOMREQUEST];
  88. if(!m) {
  89. if(data->set.opt_no_body)
  90. m = "HEAD";
  91. #ifndef CURL_DISABLE_HTTP
  92. else {
  93. switch(data->state.httpreq) {
  94. case HTTPREQ_POST:
  95. case HTTPREQ_POST_FORM:
  96. case HTTPREQ_POST_MIME:
  97. m = "POST";
  98. break;
  99. case HTTPREQ_PUT:
  100. m = "PUT";
  101. break;
  102. default: /* this should never happen */
  103. case HTTPREQ_GET:
  104. m = "GET";
  105. break;
  106. case HTTPREQ_HEAD:
  107. m = "HEAD";
  108. break;
  109. }
  110. }
  111. #endif
  112. }
  113. *param_charp = m;
  114. }
  115. break;
  116. case CURLINFO_CONTENT_TYPE:
  117. *param_charp = data->info.contenttype;
  118. break;
  119. case CURLINFO_PRIVATE:
  120. *param_charp = (char *) data->set.private_data;
  121. break;
  122. case CURLINFO_FTP_ENTRY_PATH:
  123. /* Return the entrypath string from the most recent connection.
  124. This pointer was copied from the connectdata structure by FTP.
  125. The actual string may be free()ed by subsequent libcurl calls so
  126. it must be copied to a safer area before the next libcurl call.
  127. Callers must never free it themselves. */
  128. *param_charp = data->state.most_recent_ftp_entrypath;
  129. break;
  130. case CURLINFO_REDIRECT_URL:
  131. /* Return the URL this request would have been redirected to if that
  132. option had been enabled! */
  133. *param_charp = data->info.wouldredirect;
  134. break;
  135. case CURLINFO_REFERER:
  136. /* Return the referrer header for this request, or NULL if unset */
  137. *param_charp = data->state.referer;
  138. break;
  139. case CURLINFO_PRIMARY_IP:
  140. /* Return the ip address of the most recent (primary) connection */
  141. *param_charp = data->info.primary.remote_ip;
  142. break;
  143. case CURLINFO_LOCAL_IP:
  144. /* Return the source/local ip address of the most recent (primary)
  145. connection */
  146. *param_charp = data->info.primary.local_ip;
  147. break;
  148. case CURLINFO_RTSP_SESSION_ID:
  149. #ifndef CURL_DISABLE_RTSP
  150. *param_charp = data->set.str[STRING_RTSP_SESSION_ID];
  151. #else
  152. *param_charp = NULL;
  153. #endif
  154. break;
  155. case CURLINFO_SCHEME:
  156. *param_charp = data->info.conn_scheme;
  157. break;
  158. case CURLINFO_CAPATH:
  159. #ifdef CURL_CA_PATH
  160. *param_charp = CURL_CA_PATH;
  161. #else
  162. *param_charp = NULL;
  163. #endif
  164. break;
  165. case CURLINFO_CAINFO:
  166. #ifdef CURL_CA_BUNDLE
  167. *param_charp = CURL_CA_BUNDLE;
  168. #else
  169. *param_charp = NULL;
  170. #endif
  171. break;
  172. default:
  173. return CURLE_UNKNOWN_OPTION;
  174. }
  175. return CURLE_OK;
  176. }
  177. static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
  178. long *param_longp)
  179. {
  180. curl_socket_t sockfd;
  181. union {
  182. unsigned long *to_ulong;
  183. long *to_long;
  184. } lptr;
  185. #ifdef DEBUGBUILD
  186. char *timestr = getenv("CURL_TIME");
  187. if(timestr) {
  188. unsigned long val = strtoul(timestr, NULL, 10);
  189. switch(info) {
  190. case CURLINFO_LOCAL_PORT:
  191. *param_longp = (long)val;
  192. return CURLE_OK;
  193. default:
  194. break;
  195. }
  196. }
  197. /* use another variable for this to allow different values */
  198. timestr = getenv("CURL_DEBUG_SIZE");
  199. if(timestr) {
  200. unsigned long val = strtoul(timestr, NULL, 10);
  201. switch(info) {
  202. case CURLINFO_HEADER_SIZE:
  203. case CURLINFO_REQUEST_SIZE:
  204. *param_longp = (long)val;
  205. return CURLE_OK;
  206. default:
  207. break;
  208. }
  209. }
  210. #endif
  211. switch(info) {
  212. case CURLINFO_RESPONSE_CODE:
  213. *param_longp = data->info.httpcode;
  214. break;
  215. case CURLINFO_HTTP_CONNECTCODE:
  216. *param_longp = data->info.httpproxycode;
  217. break;
  218. case CURLINFO_FILETIME:
  219. if(data->info.filetime > LONG_MAX)
  220. *param_longp = LONG_MAX;
  221. #if !defined(MSDOS) && !defined(__AMIGA__)
  222. else if(data->info.filetime < LONG_MIN)
  223. *param_longp = LONG_MIN;
  224. #endif
  225. else
  226. *param_longp = (long)data->info.filetime;
  227. break;
  228. case CURLINFO_HEADER_SIZE:
  229. *param_longp = (long)data->info.header_size;
  230. break;
  231. case CURLINFO_REQUEST_SIZE:
  232. *param_longp = (long)data->info.request_size;
  233. break;
  234. case CURLINFO_SSL_VERIFYRESULT:
  235. *param_longp = data->set.ssl.certverifyresult;
  236. break;
  237. case CURLINFO_PROXY_SSL_VERIFYRESULT:
  238. #ifndef CURL_DISABLE_PROXY
  239. *param_longp = data->set.proxy_ssl.certverifyresult;
  240. #else
  241. *param_longp = 0;
  242. #endif
  243. break;
  244. case CURLINFO_REDIRECT_COUNT:
  245. *param_longp = data->state.followlocation;
  246. break;
  247. case CURLINFO_HTTPAUTH_AVAIL:
  248. lptr.to_long = param_longp;
  249. *lptr.to_ulong = data->info.httpauthavail;
  250. break;
  251. case CURLINFO_PROXYAUTH_AVAIL:
  252. lptr.to_long = param_longp;
  253. *lptr.to_ulong = data->info.proxyauthavail;
  254. break;
  255. case CURLINFO_OS_ERRNO:
  256. *param_longp = data->state.os_errno;
  257. break;
  258. case CURLINFO_NUM_CONNECTS:
  259. *param_longp = data->info.numconnects;
  260. break;
  261. case CURLINFO_LASTSOCKET:
  262. sockfd = Curl_getconnectinfo(data, NULL);
  263. /* note: this is not a good conversion for systems with 64-bit sockets and
  264. 32-bit longs */
  265. if(sockfd != CURL_SOCKET_BAD)
  266. *param_longp = (long)sockfd;
  267. else
  268. /* this interface is documented to return -1 in case of badness, which
  269. may not be the same as the CURL_SOCKET_BAD value */
  270. *param_longp = -1;
  271. break;
  272. case CURLINFO_PRIMARY_PORT:
  273. /* Return the (remote) port of the most recent (primary) connection */
  274. *param_longp = data->info.primary.remote_port;
  275. break;
  276. case CURLINFO_LOCAL_PORT:
  277. /* Return the local port of the most recent (primary) connection */
  278. *param_longp = data->info.primary.local_port;
  279. break;
  280. case CURLINFO_PROXY_ERROR:
  281. *param_longp = (long)data->info.pxcode;
  282. break;
  283. case CURLINFO_CONDITION_UNMET:
  284. if(data->info.httpcode == 304)
  285. *param_longp = 1L;
  286. else
  287. /* return if the condition prevented the document to get transferred */
  288. *param_longp = data->info.timecond ? 1L : 0L;
  289. break;
  290. #ifndef CURL_DISABLE_RTSP
  291. case CURLINFO_RTSP_CLIENT_CSEQ:
  292. *param_longp = data->state.rtsp_next_client_CSeq;
  293. break;
  294. case CURLINFO_RTSP_SERVER_CSEQ:
  295. *param_longp = data->state.rtsp_next_server_CSeq;
  296. break;
  297. case CURLINFO_RTSP_CSEQ_RECV:
  298. *param_longp = data->state.rtsp_CSeq_recv;
  299. break;
  300. #else
  301. case CURLINFO_RTSP_CLIENT_CSEQ:
  302. case CURLINFO_RTSP_SERVER_CSEQ:
  303. case CURLINFO_RTSP_CSEQ_RECV:
  304. *param_longp = 0;
  305. break;
  306. #endif
  307. case CURLINFO_HTTP_VERSION:
  308. switch(data->info.httpversion) {
  309. case 10:
  310. *param_longp = CURL_HTTP_VERSION_1_0;
  311. break;
  312. case 11:
  313. *param_longp = CURL_HTTP_VERSION_1_1;
  314. break;
  315. case 20:
  316. *param_longp = CURL_HTTP_VERSION_2_0;
  317. break;
  318. case 30:
  319. *param_longp = CURL_HTTP_VERSION_3;
  320. break;
  321. default:
  322. *param_longp = CURL_HTTP_VERSION_NONE;
  323. break;
  324. }
  325. break;
  326. case CURLINFO_PROTOCOL:
  327. *param_longp = (long)data->info.conn_protocol;
  328. break;
  329. case CURLINFO_USED_PROXY:
  330. *param_longp =
  331. #ifdef CURL_DISABLE_PROXY
  332. 0
  333. #else
  334. data->info.used_proxy
  335. #endif
  336. ;
  337. break;
  338. default:
  339. return CURLE_UNKNOWN_OPTION;
  340. }
  341. return CURLE_OK;
  342. }
  343. #define DOUBLE_SECS(x) (double)(x)/1000000
  344. static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
  345. curl_off_t *param_offt)
  346. {
  347. #ifdef DEBUGBUILD
  348. char *timestr = getenv("CURL_TIME");
  349. if(timestr) {
  350. unsigned long val = strtoul(timestr, NULL, 10);
  351. switch(info) {
  352. case CURLINFO_TOTAL_TIME_T:
  353. case CURLINFO_NAMELOOKUP_TIME_T:
  354. case CURLINFO_CONNECT_TIME_T:
  355. case CURLINFO_APPCONNECT_TIME_T:
  356. case CURLINFO_PRETRANSFER_TIME_T:
  357. case CURLINFO_POSTTRANSFER_TIME_T:
  358. case CURLINFO_STARTTRANSFER_TIME_T:
  359. case CURLINFO_REDIRECT_TIME_T:
  360. case CURLINFO_SPEED_DOWNLOAD_T:
  361. case CURLINFO_SPEED_UPLOAD_T:
  362. *param_offt = (curl_off_t)val;
  363. return CURLE_OK;
  364. default:
  365. break;
  366. }
  367. }
  368. #endif
  369. switch(info) {
  370. case CURLINFO_FILETIME_T:
  371. *param_offt = (curl_off_t)data->info.filetime;
  372. break;
  373. case CURLINFO_SIZE_UPLOAD_T:
  374. *param_offt = data->progress.ul.cur_size;
  375. break;
  376. case CURLINFO_SIZE_DOWNLOAD_T:
  377. *param_offt = data->progress.dl.cur_size;
  378. break;
  379. case CURLINFO_SPEED_DOWNLOAD_T:
  380. *param_offt = data->progress.dl.speed;
  381. break;
  382. case CURLINFO_SPEED_UPLOAD_T:
  383. *param_offt = data->progress.ul.speed;
  384. break;
  385. case CURLINFO_CONTENT_LENGTH_DOWNLOAD_T:
  386. *param_offt = (data->progress.flags & PGRS_DL_SIZE_KNOWN) ?
  387. data->progress.dl.total_size : -1;
  388. break;
  389. case CURLINFO_CONTENT_LENGTH_UPLOAD_T:
  390. *param_offt = (data->progress.flags & PGRS_UL_SIZE_KNOWN) ?
  391. data->progress.ul.total_size : -1;
  392. break;
  393. case CURLINFO_TOTAL_TIME_T:
  394. *param_offt = data->progress.timespent;
  395. break;
  396. case CURLINFO_NAMELOOKUP_TIME_T:
  397. *param_offt = data->progress.t_nslookup;
  398. break;
  399. case CURLINFO_CONNECT_TIME_T:
  400. *param_offt = data->progress.t_connect;
  401. break;
  402. case CURLINFO_APPCONNECT_TIME_T:
  403. *param_offt = data->progress.t_appconnect;
  404. break;
  405. case CURLINFO_PRETRANSFER_TIME_T:
  406. *param_offt = data->progress.t_pretransfer;
  407. break;
  408. case CURLINFO_POSTTRANSFER_TIME_T:
  409. *param_offt = data->progress.t_posttransfer;
  410. break;
  411. case CURLINFO_STARTTRANSFER_TIME_T:
  412. *param_offt = data->progress.t_starttransfer;
  413. break;
  414. case CURLINFO_QUEUE_TIME_T:
  415. *param_offt = data->progress.t_postqueue;
  416. break;
  417. case CURLINFO_REDIRECT_TIME_T:
  418. *param_offt = data->progress.t_redirect;
  419. break;
  420. case CURLINFO_RETRY_AFTER:
  421. *param_offt = data->info.retry_after;
  422. break;
  423. case CURLINFO_XFER_ID:
  424. *param_offt = data->id;
  425. break;
  426. case CURLINFO_CONN_ID:
  427. *param_offt = data->conn ?
  428. data->conn->connection_id : data->state.recent_conn_id;
  429. break;
  430. case CURLINFO_EARLYDATA_SENT_T:
  431. *param_offt = data->progress.earlydata_sent;
  432. break;
  433. default:
  434. return CURLE_UNKNOWN_OPTION;
  435. }
  436. return CURLE_OK;
  437. }
  438. static CURLcode getinfo_double(struct Curl_easy *data, CURLINFO info,
  439. double *param_doublep)
  440. {
  441. #ifdef DEBUGBUILD
  442. char *timestr = getenv("CURL_TIME");
  443. if(timestr) {
  444. unsigned long val = strtoul(timestr, NULL, 10);
  445. switch(info) {
  446. case CURLINFO_TOTAL_TIME:
  447. case CURLINFO_NAMELOOKUP_TIME:
  448. case CURLINFO_CONNECT_TIME:
  449. case CURLINFO_APPCONNECT_TIME:
  450. case CURLINFO_PRETRANSFER_TIME:
  451. case CURLINFO_STARTTRANSFER_TIME:
  452. case CURLINFO_REDIRECT_TIME:
  453. case CURLINFO_SPEED_DOWNLOAD:
  454. case CURLINFO_SPEED_UPLOAD:
  455. *param_doublep = (double)val;
  456. return CURLE_OK;
  457. default:
  458. break;
  459. }
  460. }
  461. #endif
  462. switch(info) {
  463. case CURLINFO_TOTAL_TIME:
  464. *param_doublep = DOUBLE_SECS(data->progress.timespent);
  465. break;
  466. case CURLINFO_NAMELOOKUP_TIME:
  467. *param_doublep = DOUBLE_SECS(data->progress.t_nslookup);
  468. break;
  469. case CURLINFO_CONNECT_TIME:
  470. *param_doublep = DOUBLE_SECS(data->progress.t_connect);
  471. break;
  472. case CURLINFO_APPCONNECT_TIME:
  473. *param_doublep = DOUBLE_SECS(data->progress.t_appconnect);
  474. break;
  475. case CURLINFO_PRETRANSFER_TIME:
  476. *param_doublep = DOUBLE_SECS(data->progress.t_pretransfer);
  477. break;
  478. case CURLINFO_STARTTRANSFER_TIME:
  479. *param_doublep = DOUBLE_SECS(data->progress.t_starttransfer);
  480. break;
  481. case CURLINFO_SIZE_UPLOAD:
  482. *param_doublep = (double)data->progress.ul.cur_size;
  483. break;
  484. case CURLINFO_SIZE_DOWNLOAD:
  485. *param_doublep = (double)data->progress.dl.cur_size;
  486. break;
  487. case CURLINFO_SPEED_DOWNLOAD:
  488. *param_doublep = (double)data->progress.dl.speed;
  489. break;
  490. case CURLINFO_SPEED_UPLOAD:
  491. *param_doublep = (double)data->progress.ul.speed;
  492. break;
  493. case CURLINFO_CONTENT_LENGTH_DOWNLOAD:
  494. *param_doublep = (data->progress.flags & PGRS_DL_SIZE_KNOWN) ?
  495. (double)data->progress.dl.total_size : -1;
  496. break;
  497. case CURLINFO_CONTENT_LENGTH_UPLOAD:
  498. *param_doublep = (data->progress.flags & PGRS_UL_SIZE_KNOWN) ?
  499. (double)data->progress.ul.total_size : -1;
  500. break;
  501. case CURLINFO_REDIRECT_TIME:
  502. *param_doublep = DOUBLE_SECS(data->progress.t_redirect);
  503. break;
  504. default:
  505. return CURLE_UNKNOWN_OPTION;
  506. }
  507. return CURLE_OK;
  508. }
  509. static CURLcode getinfo_slist(struct Curl_easy *data, CURLINFO info,
  510. struct curl_slist **param_slistp)
  511. {
  512. union {
  513. struct curl_certinfo *to_certinfo;
  514. struct curl_slist *to_slist;
  515. } ptr;
  516. switch(info) {
  517. case CURLINFO_SSL_ENGINES:
  518. *param_slistp = Curl_ssl_engines_list(data);
  519. break;
  520. case CURLINFO_COOKIELIST:
  521. *param_slistp = Curl_cookie_list(data);
  522. break;
  523. case CURLINFO_CERTINFO:
  524. /* Return the a pointer to the certinfo struct. Not really an slist
  525. pointer but we can pretend it is here */
  526. ptr.to_certinfo = &data->info.certs;
  527. *param_slistp = ptr.to_slist;
  528. break;
  529. case CURLINFO_TLS_SESSION:
  530. case CURLINFO_TLS_SSL_PTR:
  531. {
  532. struct curl_tlssessioninfo **tsip = (struct curl_tlssessioninfo **)
  533. param_slistp;
  534. struct curl_tlssessioninfo *tsi = &data->tsi;
  535. #ifdef USE_SSL
  536. struct connectdata *conn = data->conn;
  537. #endif
  538. *tsip = tsi;
  539. tsi->backend = Curl_ssl_backend();
  540. tsi->internals = NULL;
  541. #ifdef USE_SSL
  542. if(conn && tsi->backend != CURLSSLBACKEND_NONE) {
  543. tsi->internals = Curl_ssl_get_internals(data, FIRSTSOCKET, info, 0);
  544. }
  545. #endif
  546. }
  547. break;
  548. default:
  549. return CURLE_UNKNOWN_OPTION;
  550. }
  551. return CURLE_OK;
  552. }
  553. static CURLcode getinfo_socket(struct Curl_easy *data, CURLINFO info,
  554. curl_socket_t *param_socketp)
  555. {
  556. switch(info) {
  557. case CURLINFO_ACTIVESOCKET:
  558. *param_socketp = Curl_getconnectinfo(data, NULL);
  559. break;
  560. default:
  561. return CURLE_UNKNOWN_OPTION;
  562. }
  563. return CURLE_OK;
  564. }
  565. CURLcode Curl_getinfo(struct Curl_easy *data, CURLINFO info, ...)
  566. {
  567. va_list arg;
  568. long *param_longp = NULL;
  569. double *param_doublep = NULL;
  570. curl_off_t *param_offt = NULL;
  571. const char **param_charp = NULL;
  572. struct curl_slist **param_slistp = NULL;
  573. curl_socket_t *param_socketp = NULL;
  574. int type;
  575. CURLcode result = CURLE_UNKNOWN_OPTION;
  576. if(!data)
  577. return CURLE_BAD_FUNCTION_ARGUMENT;
  578. va_start(arg, info);
  579. type = CURLINFO_TYPEMASK & (int)info;
  580. switch(type) {
  581. case CURLINFO_STRING:
  582. param_charp = va_arg(arg, const char **);
  583. if(param_charp)
  584. result = getinfo_char(data, info, param_charp);
  585. break;
  586. case CURLINFO_LONG:
  587. param_longp = va_arg(arg, long *);
  588. if(param_longp)
  589. result = getinfo_long(data, info, param_longp);
  590. break;
  591. case CURLINFO_DOUBLE:
  592. param_doublep = va_arg(arg, double *);
  593. if(param_doublep)
  594. result = getinfo_double(data, info, param_doublep);
  595. break;
  596. case CURLINFO_OFF_T:
  597. param_offt = va_arg(arg, curl_off_t *);
  598. if(param_offt)
  599. result = getinfo_offt(data, info, param_offt);
  600. break;
  601. case CURLINFO_SLIST:
  602. param_slistp = va_arg(arg, struct curl_slist **);
  603. if(param_slistp)
  604. result = getinfo_slist(data, info, param_slistp);
  605. break;
  606. case CURLINFO_SOCKET:
  607. param_socketp = va_arg(arg, curl_socket_t *);
  608. if(param_socketp)
  609. result = getinfo_socket(data, info, param_socketp);
  610. break;
  611. default:
  612. break;
  613. }
  614. va_end(arg);
  615. return result;
  616. }