hostip.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 hostent;
  29. struct SessionHandle;
  30. void Curl_global_host_cache_init(void);
  31. void Curl_global_host_cache_dtor(void);
  32. curl_hash *Curl_global_host_cache_get(void);
  33. #define Curl_global_host_cache_use(__p) ((__p)->set.global_dns_cache)
  34. struct Curl_dns_entry {
  35. Curl_addrinfo *addr;
  36. time_t timestamp;
  37. long inuse; /* use-counter, make very sure you decrease this
  38. when you're done using the address you received */
  39. #ifdef MALLOCDEBUG
  40. char *entry_id;
  41. #endif
  42. };
  43. /*
  44. * Curl_resolv() returns an entry with the info for the specified host
  45. * and port.
  46. *
  47. * The returned data *MUST* be "unlocked" with Curl_resolv_unlock() after
  48. * use, or we'll leak memory!
  49. */
  50. struct Curl_dns_entry *Curl_resolv(struct SessionHandle *data,
  51. char *hostname,
  52. int port);
  53. /* unlock a previously resolved dns entry */
  54. #define Curl_resolv_unlock(dns) dns->inuse--
  55. /* for debugging purposes only: */
  56. void Curl_scan_cache_used(void *user, void *ptr);
  57. /* free name info */
  58. void Curl_freeaddrinfo(Curl_addrinfo *freeaddr);
  59. /* free cached name info */
  60. void Curl_freednsinfo(void *freethis);
  61. #ifdef MALLOCDEBUG
  62. void curl_freeaddrinfo(struct addrinfo *freethis,
  63. int line, const char *source);
  64. int curl_getaddrinfo(char *hostname, char *service,
  65. struct addrinfo *hints,
  66. struct addrinfo **result,
  67. int line, const char *source);
  68. #endif
  69. #endif