use CURLDEBUG instead of MALLOCDEBUG for preprocessor conditions
[platform/upstream/curl.git] / lib / hostip.h
1 #ifndef __HOSTIP_H
2 #define __HOSTIP_H
3 /***************************************************************************
4  *                                  _   _ ____  _     
5  *  Project                     ___| | | |  _ \| |    
6  *                             / __| | | | |_) | |    
7  *                            | (__| |_| |  _ <| |___ 
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2003, Daniel Stenberg, <daniel@haxx.se>, 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
26 #include "setup.h"
27 #include "hash.h"
28
29 struct addrinfo;
30 struct hostent;
31 struct SessionHandle;
32
33 void Curl_global_host_cache_init(void);
34 void Curl_global_host_cache_dtor(void);
35 curl_hash *Curl_global_host_cache_get(void);
36
37 #define Curl_global_host_cache_use(__p) ((__p)->set.global_dns_cache)
38
39 struct Curl_dns_entry {
40   Curl_addrinfo *addr;
41   time_t timestamp;
42   long inuse;      /* use-counter, make very sure you decrease this
43                       when you're done using the address you received */
44 #ifdef CURLDEBUG
45   char *entry_id;
46 #endif
47 };
48
49 /*
50  * Curl_resolv() returns an entry with the info for the specified host
51  * and port.
52  *
53  * The returned data *MUST* be "unlocked" with Curl_resolv_unlock() after
54  * use, or we'll leak memory!
55  */
56
57 struct Curl_dns_entry *Curl_resolv(struct SessionHandle *data,
58                                    char *hostname,
59                                    int port);
60
61 /* unlock a previously resolved dns entry */
62 void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns);
63
64 /* for debugging purposes only: */
65 void Curl_scan_cache_used(void *user, void *ptr);
66
67 /* free name info */
68 void Curl_freeaddrinfo(Curl_addrinfo *freeaddr);
69
70 /* free cached name info */
71 void Curl_freednsinfo(void *freethis);
72
73 #ifdef CURLDEBUG
74 void curl_freeaddrinfo(struct addrinfo *freethis,
75                        int line, const char *source);
76 int curl_getaddrinfo(char *hostname, char *service,
77                      struct addrinfo *hints,
78                      struct addrinfo **result,
79                      int line, const char *source);
80 #endif
81
82 #ifndef INADDR_NONE
83 #define CURL_INADDR_NONE (in_addr_t) ~0
84 #else
85 #define CURL_INADDR_NONE INADDR_NONE
86 #endif
87
88
89 #endif