]> sjero.net Git - wget/blob - src/host.h
[svn] Merge of fix for bugs 20341 and 20410.
[wget] / src / host.h
1 /* Declarations for host.c
2    Copyright (C) 1996-2006 Free Software Foundation, Inc.
3
4 This file is part of GNU Wget.
5
6 GNU Wget is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10
11 GNU Wget is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Wget.  If not, see <http://www.gnu.org/licenses/>.
18
19 In addition, as a special exception, the Free Software Foundation
20 gives permission to link the code of its release of Wget with the
21 OpenSSL project's "OpenSSL" library (or with modified versions of it
22 that use the same license as the "OpenSSL" library), and distribute
23 the linked executables.  You must obey the GNU General Public License
24 in all respects for all of the code used other than "OpenSSL".  If you
25 modify this file, you may extend this exception to your version of the
26 file, but you are not obligated to do so.  If you do not wish to do
27 so, delete this exception statement from your version.  */
28
29 #ifndef HOST_H
30 #define HOST_H
31
32 #ifdef WINDOWS
33 # include <winsock.h>
34 #else
35 # include <netdb.h>
36 # include <sys/socket.h>
37 # include <netinet/in.h>
38 #ifndef __BEOS__
39 # include <arpa/inet.h>
40 #endif
41 #endif
42
43 struct url;
44 struct address_list;
45
46 /* This struct defines an IP address, tagged with family type.  */
47
48 typedef struct {
49   /* Address family, one of AF_INET or AF_INET6. */
50   int family;
51
52   /* The actual data, in the form of struct in_addr or in6_addr: */
53   union {
54     struct in_addr d4;          /* IPv4 address */
55 #ifdef ENABLE_IPV6
56     struct in6_addr d6;         /* IPv6 address */
57 #endif
58   } data;
59
60   /* Under IPv6 getaddrinfo also returns scope_id.  Since it's
61      IPv6-specific it strictly belongs in the above union, but we put
62      it here for simplicity.  */
63 #if defined ENABLE_IPV6 && defined HAVE_SOCKADDR_IN6_SCOPE_ID
64   int ipv6_scope;
65 #endif
66 } ip_address;
67
68 /* IP_INADDR_DATA macro returns a void pointer that can be interpreted
69    as a pointer to struct in_addr in IPv4 context or a pointer to
70    struct in6_addr in IPv4 context.  This pointer can be passed to
71    functions that work on either, such as inet_ntop.  */
72 #define IP_INADDR_DATA(x) ((void *) &(x)->data)
73
74 enum {
75   LH_SILENT  = 1,
76   LH_BIND    = 2,
77   LH_REFRESH = 4
78 };
79 struct address_list *lookup_host (const char *, int);
80
81 void address_list_get_bounds (const struct address_list *, int *, int *);
82 const ip_address *address_list_address_at (const struct address_list *, int);
83 bool address_list_contains (const struct address_list *, const ip_address *);
84 void address_list_set_faulty (struct address_list *, int);
85 void address_list_set_connected (struct address_list *);
86 bool address_list_connected_p (const struct address_list *);
87 void address_list_release (struct address_list *);
88
89 const char *print_address (const ip_address *);
90 #ifdef ENABLE_IPV6
91 bool is_valid_ipv6_address (const char *, const char *);
92 #endif
93
94 bool accept_domain (struct url *);
95 bool sufmatch (const char **, const char *);
96
97 void host_cleanup (void);
98
99 #endif /* HOST_H */