hostip.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef __HOSTIP_H
  2. #define __HOSTIP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2002, Daniel Stenberg, <[email protected]>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at http://curl.haxx.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. * $Id$
  24. ***************************************************************************/
  25. #include "setup.h"
  26. #include "hash.h"
  27. struct addrinfo;
  28. struct SessionHandle;
  29. void Curl_global_host_cache_init(void);
  30. void Curl_global_host_cache_dtor(void);
  31. curl_hash *Curl_global_host_cache_get(void);
  32. #define Curl_global_host_cache_use(__p) ((__p)->set.global_dns_cache)
  33. struct Curl_dns_entry {
  34. Curl_addrinfo *addr;
  35. time_t timestamp;
  36. long inuse; /* use-counter, make very sure you decrease this
  37. when you're done using the address you received */
  38. #ifdef MALLOCDEBUG
  39. char *entry_id;
  40. #endif
  41. };
  42. /*
  43. * Curl_resolv() returns an entry with the info for the specified host
  44. * and port.
  45. *
  46. * The returned data *MUST* be "unlocked" with Curl_resolv_unlock() after
  47. * use, or we'll leak memory!
  48. */
  49. struct Curl_dns_entry *Curl_resolv(struct SessionHandle *data,
  50. char *hostname,
  51. int port);
  52. /* unlock a previously resolved dns entry */
  53. #define Curl_resolv_unlock(dns) dns->inuse--
  54. /* for debugging purposes only: */
  55. void Curl_scan_cache_used(void *user, void *ptr);
  56. /* free name info */
  57. void Curl_freeaddrinfo(Curl_addrinfo *freeaddr);
  58. /* free cached name info */
  59. void Curl_freednsinfo(void *freethis);
  60. #ifdef MALLOCDEBUG
  61. void curl_freeaddrinfo(struct addrinfo *freethis,
  62. int line, const char *source);
  63. int curl_getaddrinfo(char *hostname, char *service,
  64. struct addrinfo *hints,
  65. struct addrinfo **result,
  66. int line, const char *source);
  67. #endif
  68. #endif