Handle localhost.localdomain in initHttp.
[polipo.git] / polipo.h
blobe099384e9424f56e8db47b7aa907c9dd639725d6
1 /*
2 Copyright (c) 2003-2006 by Juliusz Chroboczek
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
23 #ifndef _GNU_SOURCE
24 #define _GNU_SOURCE
25 #endif
27 #include <sys/param.h>
29 #ifdef __MINGW32_VERSION
30 #define MINGW
31 #endif
33 #include <stdlib.h>
34 #include <stdarg.h>
35 #include <stdio.h>
36 #include <errno.h>
37 #include <string.h>
38 #include <assert.h>
39 #include <unistd.h>
40 #include <fcntl.h>
41 #include <time.h>
42 #include <sys/time.h>
43 #include <sys/stat.h>
44 #include <dirent.h>
45 #ifndef MINGW
46 #include <sys/mman.h>
47 #include <sys/socket.h>
48 #include <netinet/in.h>
49 #include <netinet/tcp.h>
50 #include <arpa/inet.h>
51 #include <netdb.h>
52 #include <sys/types.h>
53 #include <sys/uio.h>
54 #include <sys/poll.h>
55 #include <sys/wait.h>
56 #include <sys/ioctl.h>
57 #include <signal.h>
58 #endif
60 #ifndef MAP_ANONYMOUS
61 #define MAP_ANONYMOUS MAP_ANON
62 #endif
64 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
65 /* nothing */
66 #elif defined(__GNUC__)
67 #define inline __inline
68 #if (__GNUC__ >= 3)
69 #define restrict __restrict
70 #else
71 #define restrict /**/
72 #endif
73 #else
74 #define inline /**/
75 #define restrict /**/
76 #endif
78 #if defined(__GNUC__) && (__GNUC__ >= 3)
79 #define ATTRIBUTE(x) __attribute__(x)
80 #else
81 #define ATTRIBUTE(x) /**/
82 #endif
84 #if defined __GLIBC__
85 #define HAVE_TM_GMTOFF
86 #ifndef __UCLIBC__
87 #define HAVE_TIMEGM
88 #define HAVE_FTS
89 #endif
90 #define HAVE_SETENV
91 #define HAVE_ASPRINTF
92 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
93 #define HAVE_MEMRCHR
94 #endif
95 #endif
97 #if defined(__linux__) && (__GNU_LIBRARY__ == 1)
98 /* Linux libc 5 */
99 #define HAVE_TIMEGM
100 #define HAVE_SETENV
101 #endif
103 #ifdef BSD
104 #define HAVE_TM_GMTOFF
105 #define HAVE_FTS
106 #define HAVE_SETENV
107 #ifdef __FreeBSD__
108 #define HAVE_ASPRINTF
109 #endif
110 #endif
112 #ifdef __CYGWIN__
113 #define HAVE_SETENV
114 #define HAVE_ASPRINTF
115 #endif
117 #ifndef O_BINARY
118 #define O_BINARY 0
119 #endif
121 #define HAVE_TZSET
123 #if _POSIX_VERSION >= 200112L
124 #define HAVE_SETENV
125 #endif
127 #ifndef NO_IPv6
129 #ifdef __GLIBC__
130 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
131 #define HAVE_IPv6
132 #endif
133 #endif
135 #ifdef __FreeBSD__
136 #if __FreeBSD_version >= 400000
137 #define HAVE_IPv6
138 #endif
139 #endif
141 #ifdef __NetBSD__
142 #if __NetBSD_Version__ >= 105000000
143 #define HAVE_IPv6
144 #endif
145 #endif
147 #ifdef __OpenBSD__
148 #if OpenBSD >= 200311
149 #define HAVE_IPv6
150 #endif
151 #endif
153 #endif
155 #if defined(i386) || defined(__mc68020__)
156 #define UNALIGNED_ACCESS
157 #endif
159 #ifndef MINGW
160 #define HAVE_FORK 1
161 #define HAVE_READV_WRITEV 1
162 #define READ(x, y, z) read(x, y, z)
163 #define WRITE(x, y, z) write(x, y, z)
164 #define CLOSE(x) close(x)
165 #else
166 #ifndef HAVE_REGEX
167 #define NO_FORBIDDEN
168 #endif
169 #endif
171 #ifdef HAVE_READV_WRITEV
172 #define WRITEV(x, y, z) writev(x, y, z)
173 #define READV(x, y, z) readv(x, y, z)
174 #endif
176 #ifndef HAVE_FORK
177 #define NO_REDIRECTOR
178 #endif
180 #include "mingw.h"
182 #include "ftsimport.h"
183 #include "atom.h"
184 #include "util.h"
185 #include "config.h"
186 #include "event.h"
187 #include "io.h"
188 #include "socks.h"
189 #include "chunk.h"
190 #include "object.h"
191 #include "dns.h"
192 #include "http.h"
193 #include "client.h"
194 #include "local.h"
195 #include "diskcache.h"
196 #include "server.h"
197 #include "http_parse.h"
198 #include "parse_time.h"
199 #include "forbidden.h"
200 #include "log.h"
201 #include "auth.h"
202 #include "tunnel.h"
204 extern AtomPtr configFile;
205 extern int daemonise;
206 extern AtomPtr pidFile;