]> sjero.net Git - wget/blob - src/host.h
[svn] Don't include netdb.h on windows.
[wget] / src / host.h
1 /* Declarations for host.c
2    Copyright (C) 1995, 1996, 1997, 2001 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
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20 #ifndef HOST_H
21 #define HOST_H
22
23 #ifdef WINDOWS
24 # include <winsock.h>
25 #else
26 # include <netdb.h>
27 # include <sys/socket.h>
28 # include <netinet/in.h>
29 #ifndef __BEOS__
30 # include <arpa/inet.h>
31 #endif
32 #endif
33
34 #undef INET6
35
36 struct url;
37 struct address_list;
38
39 /* wget_sockaddr is used instead of sockaddr where an IPV6 address
40    must fit.  */
41
42 typedef union {
43         struct sockaddr     sa;   /* Generic but too small */
44         struct sockaddr_in  sin;  /* IPv4 socket address */
45 #ifdef INET6
46         struct sockaddr_in6 sin6; /* IPv6 socket address */
47 #endif
48 } wget_sockaddr;
49
50 typedef struct {
51   unsigned char bytes[4];
52 } ip4_address;
53
54 /* If compiled with IPv6 support, we internally represent all IP
55    addresses as IPv6 addresses.  IPv4 addresses are dynamically mapped
56    to IPv6, i.e. stored in the format ::ffff:<Ipv4>.  */
57
58 #ifdef INET6
59 # define MAX_IP_ADDRESS_SIZE 16
60 #else
61 # define MAX_IP_ADDRESS_SIZE 4
62 #endif
63
64 typedef struct {
65   unsigned char bytes[MAX_IP_ADDRESS_SIZE];
66 } ip_address;
67
68 /* Function declarations */
69 struct address_list *lookup_host PARAMS ((const char *, int));
70 char *herrmsg PARAMS ((int));
71
72 void address_list_get_bounds PARAMS ((struct address_list *, int *, int *));
73 void address_list_copy_one PARAMS ((struct address_list *, int,
74                                     ip_address *));
75 int address_list_match_all PARAMS ((struct address_list *,
76                                     struct address_list *));
77 void address_list_set_faulty PARAMS ((struct address_list *, int));
78 void address_list_release PARAMS ((struct address_list *));
79
80 char *pretty_print_address PARAMS ((ip_address *));
81
82 int accept_domain PARAMS ((struct url *));
83 int sufmatch PARAMS ((const char **, const char *));
84
85 void host_cleanup PARAMS ((void));
86
87 void wget_sockaddr_set_address PARAMS((wget_sockaddr *, int, 
88                                        unsigned short, ip_address *));
89 void wget_sockaddr_set_port PARAMS((wget_sockaddr *, unsigned short));
90 void *wget_sockaddr_get_addr PARAMS((wget_sockaddr *));
91 unsigned short wget_sockaddr_get_port PARAMS((const wget_sockaddr *));
92 int sockaddr_len PARAMS(());
93 void map_ipv4_to_ip PARAMS((ip4_address *, ip_address *));
94 int  map_ip_to_ipv4 PARAMS((ip_address *, ip4_address *));
95  
96 extern  int     ip_default_family;      /* defined in host.c */
97
98
99 #endif /* HOST_H */