Quell a GCC warning about a NULL format string on FreeBSD.
[polipo.git] / polipo.h
blobff971012f9b6b7440b6f2f681353528f362e27ef
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 #ifndef WIN32
28 #include <sys/param.h>
29 #endif
31 #ifdef __MINGW32_VERSION
32 #define MINGW
33 #endif
35 #include <limits.h>
36 #include <stdlib.h>
37 #include <stdarg.h>
38 #include <stdio.h>
39 #include <errno.h>
40 #include <string.h>
41 #include <assert.h>
42 #include <unistd.h>
43 #include <fcntl.h>
44 #include <time.h>
45 #include <sys/time.h>
46 #include <sys/stat.h>
47 #include <dirent.h>
48 #ifndef WIN32 /*MINGW*/
49 #include <sys/mman.h>
50 #include <sys/socket.h>
51 #include <netinet/in.h>
52 #include <netinet/tcp.h>
53 #include <arpa/inet.h>
54 #include <netdb.h>
55 #include <sys/types.h>
56 #include <sys/uio.h>
57 #include <sys/poll.h>
58 #include <sys/wait.h>
59 #include <sys/ioctl.h>
60 #include <signal.h>
61 #endif
63 #ifndef MAP_ANONYMOUS
64 #define MAP_ANONYMOUS MAP_ANON
65 #endif
67 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
68 /* nothing */
69 #elif defined(__GNUC__)
70 #define inline __inline
71 #if (__GNUC__ >= 3)
72 #define restrict __restrict
73 #else
74 #define restrict /**/
75 #endif
76 #else
77 #define inline /**/
78 #define restrict /**/
79 #endif
81 #if defined(__GNUC__) && (__GNUC__ >= 3)
82 #define ATTRIBUTE(x) __attribute__(x)
83 #else
84 #define ATTRIBUTE(x) /**/
85 #endif
87 #if defined __GLIBC__
88 #define HAVE_TM_GMTOFF
89 #ifndef __UCLIBC__
90 #define HAVE_TIMEGM
91 #define HAVE_FTS
92 #define HAVE_FFSL
93 #define HAVE_FFSLL
94 #endif
95 #define HAVE_SETENV
96 #define HAVE_ASPRINTF
97 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
98 #define HAVE_MEMRCHR
99 #endif
100 #endif
102 #if defined(__linux__) && (__GNU_LIBRARY__ == 1)
103 /* Linux libc 5 */
104 #define HAVE_TIMEGM
105 #define HAVE_SETENV
106 #endif
108 #ifdef BSD
109 #define HAVE_TM_GMTOFF
110 #define HAVE_FTS
111 #define HAVE_SETENV
112 #endif
114 #ifdef __CYGWIN__
115 #define HAVE_SETENV
116 #define HAVE_ASPRINTF
117 #endif
119 #ifndef O_BINARY
120 #define O_BINARY 0
121 #endif
123 #define HAVE_TZSET
125 #if _POSIX_VERSION >= 200112L
126 #define HAVE_SETENV
127 #endif
129 #ifndef NO_IPv6
131 #ifdef __GLIBC__
132 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
133 #define HAVE_IPv6
134 #endif
135 #endif
137 #ifdef __FreeBSD__
138 #define HAVE_ASPRINTF
139 #if __FreeBSD_version >= 400000
140 #define HAVE_IPv6
141 #define HAVE_TIMEGM
142 #endif
143 #if __FreeBSD_version >= 503001
144 #define HAVE_FFSL
145 #endif
146 #endif
148 #ifdef __NetBSD__
149 #if __NetBSD_Version__ >= 105000000
150 #define HAVE_IPv6
151 #endif
152 #if __NetBSD_Version__ >= 200000000
153 #define HAVE_TIMEGM
154 #define HAVE_ASPRINTF
155 #endif
156 #endif
158 #ifdef __OpenBSD__
159 #if OpenBSD >= 200311
160 #define HAVE_IPv6
161 #endif
162 #endif
164 #endif
166 #if defined(i386) || defined(__mc68020__) || defined(__x86_64__)
167 #define UNALIGNED_ACCESS
168 #endif
170 #ifndef WIN32 /*MINGW*/
171 #define HAVE_FORK
172 #ifndef NO_SYSLOG
173 #define HAVE_SYSLOG
174 #endif
175 #define HAVE_READV_WRITEV
176 #define HAVE_FFS
177 #define READ(x, y, z) read(x, y, z)
178 #define WRITE(x, y, z) write(x, y, z)
179 #define CLOSE(x) close(x)
180 #else
181 #ifndef HAVE_REGEX
182 #define NO_FORBIDDEN
183 #endif
184 #endif
186 #ifdef HAVE_READV_WRITEV
187 #define WRITEV(x, y, z) writev(x, y, z)
188 #define READV(x, y, z) readv(x, y, z)
189 #endif
191 #ifndef HAVE_FORK
192 #define NO_REDIRECTOR
193 #endif
195 #include "mingw.h"
197 #include "ftsimport.h"
198 #include "atom.h"
199 #include "util.h"
200 #include "config.h"
201 #include "event.h"
202 #include "io.h"
203 #include "socks.h"
204 #include "chunk.h"
205 #include "object.h"
206 #include "dns.h"
207 #include "http.h"
208 #include "client.h"
209 #include "local.h"
210 #include "diskcache.h"
211 #include "server.h"
212 #include "http_parse.h"
213 #include "parse_time.h"
214 #include "forbidden.h"
215 #include "log.h"
216 #include "auth.h"
217 #include "tunnel.h"
219 extern AtomPtr configFile;
220 extern int daemonise;
221 extern AtomPtr pidFile;