updated year in the copyright string
[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 - 2004, 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 struct connectdata;
33
34 void Curl_global_host_cache_init(void);
35 void Curl_global_host_cache_dtor(void);
36 curl_hash *Curl_global_host_cache_get(void);
37
38 #define Curl_global_host_cache_use(__p) ((__p)->set.global_dns_cache)
39
40 struct Curl_dns_entry {
41   Curl_addrinfo *addr;
42   time_t timestamp;
43   long inuse;      /* use-counter, make very sure you decrease this
44                       when you're done using the address you received */
45 };
46
47 /*
48  * Curl_resolv() returns an entry with the info for the specified host
49  * and port.
50  *
51  * The returned data *MUST* be "unlocked" with Curl_resolv_unlock() after
52  * use, or we'll leak memory!
53  */
54
55 int Curl_resolv(struct connectdata *conn,
56                 char *hostname,
57                 int port,
58                 struct Curl_dns_entry **dnsentry);
59
60 CURLcode Curl_is_resolved(struct connectdata *conn,
61                           struct Curl_dns_entry **dns);
62 CURLcode Curl_wait_for_resolv(struct connectdata *conn,
63                               struct Curl_dns_entry **dnsentry);
64 CURLcode Curl_multi_ares_fdset(struct connectdata *conn,
65                                fd_set *read_fd_set,
66                                fd_set *write_fd_set,
67                                int *max_fdp);
68 /* unlock a previously resolved dns entry */
69 void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns);
70
71 /* for debugging purposes only: */
72 void Curl_scan_cache_used(void *user, void *ptr);
73
74 /* free name info */
75 void Curl_freeaddrinfo(Curl_addrinfo *freeaddr);
76
77 /* free cached name info */
78 void Curl_freednsinfo(void *freethis);
79
80 /* prune old entries from the DNS cache */
81 void Curl_hostcache_prune(struct SessionHandle *data);
82
83 #ifdef CURLDEBUG
84 void curl_freeaddrinfo(struct addrinfo *freethis,
85                        int line, const char *source);
86 int curl_getaddrinfo(char *hostname, char *service,
87                      struct addrinfo *hints,
88                      struct addrinfo **result,
89                      int line, const char *source);
90 #endif
91
92 #ifndef INADDR_NONE
93 #define CURL_INADDR_NONE (in_addr_t) ~0
94 #else
95 #define CURL_INADDR_NONE INADDR_NONE
96 #endif
97
98
99 #endif