]> sjero.net Git - wget/blob - src/host.h
Fix build when libpsl is not available
[wget] / src / host.h
1 /* Declarations for host.c
2    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3    2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation,
4    Inc.
5
6 This file is part of GNU Wget.
7
8 GNU Wget is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12
13 GNU Wget is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Wget.  If not, see <http://www.gnu.org/licenses/>.
20
21 Additional permission under GNU GPL version 3 section 7
22
23 If you modify this program, or any covered work, by linking or
24 combining it with the OpenSSL project's OpenSSL library (or a
25 modified version of that library), containing parts covered by the
26 terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
27 grants you additional permission to convey the resulting work.
28 Corresponding Source for a non-source form of such a combination
29 shall include the source code for the parts of OpenSSL used as well
30 as that of the covered work.  */
31
32 #ifndef HOST_H
33 #define HOST_H
34
35 #ifdef WINDOWS
36 # include <winsock2.h>
37 #else
38 # ifdef __VMS
39 #  include "vms_ip.h"
40 # else /* def __VMS */
41 #  include <netdb.h>
42 # endif /* def __VMS [else] */
43 # include <sys/socket.h>
44 # include <netinet/in.h>
45 #ifndef __BEOS__
46 # include <arpa/inet.h>
47 #endif
48 #endif
49
50 struct url;
51 struct address_list;
52
53 /* This struct defines an IP address, tagged with family type.  */
54
55 typedef struct {
56   /* Address family, one of AF_INET or AF_INET6. */
57   int family;
58
59   /* The actual data, in the form of struct in_addr or in6_addr: */
60   union {
61     struct in_addr d4;      /* IPv4 address */
62 #ifdef ENABLE_IPV6
63     struct in6_addr d6;     /* IPv6 address */
64 #endif
65   } data;
66
67   /* Under IPv6 getaddrinfo also returns scope_id.  Since it's
68      IPv6-specific it strictly belongs in the above union, but we put
69      it here for simplicity.  */
70 #if defined ENABLE_IPV6 && defined HAVE_SOCKADDR_IN6_SCOPE_ID
71   int ipv6_scope;
72 #endif
73 } ip_address;
74
75 /* IP_INADDR_DATA macro returns a void pointer that can be interpreted
76    as a pointer to struct in_addr in IPv4 context or a pointer to
77    struct in6_addr in IPv4 context.  This pointer can be passed to
78    functions that work on either, such as inet_ntop.  */
79 #define IP_INADDR_DATA(x) ((void *) &(x)->data)
80
81 enum {
82   LH_SILENT  = 1,
83   LH_BIND    = 2,
84   LH_REFRESH = 4
85 };
86 struct address_list *lookup_host (const char *, int);
87
88 void address_list_get_bounds (const struct address_list *, int *, int *);
89 const ip_address *address_list_address_at (const struct address_list *, int);
90 bool address_list_contains (const struct address_list *, const ip_address *);
91 void address_list_set_faulty (struct address_list *, int);
92 void address_list_set_connected (struct address_list *);
93 bool address_list_connected_p (const struct address_list *);
94 void address_list_release (struct address_list *);
95
96 const char *print_address (const ip_address *);
97 #ifdef ENABLE_IPV6
98 bool is_valid_ipv6_address (const char *, const char *);
99 #endif
100
101 bool is_valid_ip_address (const char *name);
102
103 bool accept_domain (struct url *);
104 bool sufmatch (const char **, const char *);
105
106 void host_cleanup (void);
107
108 #endif /* HOST_H */