]> sjero.net Git - wget/blob - src/host.h
4bf259701f9346e74831b3ee39c226566d980fcb
[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 2 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, write to the Free Software Foundation, Inc.,
18 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
20 In addition, as a special exception, the Free Software Foundation
21 gives permission to link the code of its release of Wget with the
22 OpenSSL project's "OpenSSL" library (or with modified versions of it
23 that use the same license as the "OpenSSL" library), and distribute
24 the linked executables.  You must obey the GNU General Public License
25 in all respects for all of the code used other than "OpenSSL".  If you
26 modify this file, you may extend this exception to your version of the
27 file, but you are not obligated to do so.  If you do not wish to do
28 so, delete this exception statement from your version.  */
29
30 #ifndef HOST_H
31 #define HOST_H
32
33 #ifdef WINDOWS
34 # include <winsock.h>
35 #else
36 # include <netdb.h>
37 # include <sys/socket.h>
38 # include <netinet/in.h>
39 #ifndef __BEOS__
40 # include <arpa/inet.h>
41 #endif
42 #endif
43
44 struct url;
45 struct address_list;
46
47 /* This struct defines an IP address, tagged with family type.  */
48
49 typedef struct {
50   /* Address family, one of AF_INET or AF_INET6. */
51   int family;
52
53   /* The actual data, in the form of struct in_addr or in6_addr: */
54   union {
55     struct in_addr d4;          /* IPv4 address */
56 #ifdef ENABLE_IPV6
57     struct in6_addr d6;         /* IPv6 address */
58 #endif
59   } data;
60
61   /* Under IPv6 getaddrinfo also returns scope_id.  Since it's
62      IPv6-specific it strictly belongs in the above union, but we put
63      it here for simplicity.  */
64 #if defined ENABLE_IPV6 && defined HAVE_SOCKADDR_IN6_SCOPE_ID
65   int ipv6_scope;
66 #endif
67 } ip_address;
68
69 /* IP_INADDR_DATA macro returns a void pointer that can be interpreted
70    as a pointer to struct in_addr in IPv4 context or a pointer to
71    struct in6_addr in IPv4 context.  This pointer can be passed to
72    functions that work on either, such as inet_ntop.  */
73 #define IP_INADDR_DATA(x) ((void *) &(x)->data)
74
75 enum {
76   LH_SILENT  = 1,
77   LH_BIND    = 2,
78   LH_REFRESH = 4
79 };
80 struct address_list *lookup_host (const char *, int);
81
82 void address_list_get_bounds (const struct address_list *, int *, int *);
83 const ip_address *address_list_address_at (const struct address_list *, int);
84 bool address_list_contains (const struct address_list *, const ip_address *);
85 void address_list_set_faulty (struct address_list *, int);
86 void address_list_set_connected (struct address_list *);
87 bool address_list_connected_p (const struct address_list *);
88 void address_list_release (struct address_list *);
89
90 const char *print_address (const ip_address *);
91 #ifdef ENABLE_IPV6
92 bool is_valid_ipv6_address (const char *, const char *);
93 #endif
94
95 bool accept_domain (struct url *);
96 bool sufmatch (const char **, const char *);
97
98 void host_cleanup (void);
99
100 #endif /* HOST_H */