]> git.ipfire.org Git - thirdparty/squid.git/blob - src/defines.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / defines.h
1 /*
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_DEFINES_H
10 #define SQUID_DEFINES_H
11
12 #ifndef TRUE
13 #define TRUE 1
14 #endif
15 #ifndef FALSE
16 #define FALSE 0
17 #endif
18
19 #ifndef BUFSIZ
20 #define BUFSIZ 4096 /* make unreasonable guess */
21 #endif
22
23 #define BROWSERNAMELEN 128
24
25 #define ACL_SUNDAY 0x01
26 #define ACL_MONDAY 0x02
27 #define ACL_TUESDAY 0x04
28 #define ACL_WEDNESDAY 0x08
29 #define ACL_THURSDAY 0x10
30 #define ACL_FRIDAY 0x20
31 #define ACL_SATURDAY 0x40
32 #define ACL_ALLWEEK 0x7F
33 #define ACL_WEEKDAYS 0x3E
34
35 /* Select types. */
36 #define COMM_SELECT_READ (0x1)
37 #define COMM_SELECT_WRITE (0x2)
38
39 #define DISK_OK (0)
40 #define DISK_ERROR (-1)
41 #define DISK_EOF (-2)
42 #define DISK_NO_SPACE_LEFT (-6)
43
44 #define DNS_INBUF_SZ 4096
45
46 #define FD_DESC_SZ 64
47
48 #define FQDN_LOOKUP_IF_MISS 0x01
49 #define FQDN_MAX_NAMES 5
50
51 #define HTTP_REPLY_FIELD_SZ 128
52
53 #define BUF_TYPE_8K 1
54 #define BUF_TYPE_MALLOC 2
55
56 #define ANONYMIZER_NONE 0
57 #define ANONYMIZER_STANDARD 1
58 #define ANONYMIZER_PARANOID 2
59
60 #define USER_IDENT_SZ 64
61 #define IDENT_NONE 0
62 #define IDENT_PENDING 1
63 #define IDENT_DONE 2
64
65 #define IP_LOOKUP_IF_MISS 0x01
66
67 #define MAX_MIME 4096
68
69 /* Mark a neighbor cache as dead if it doesn't answer this many pings */
70 #define HIER_MAX_DEFICIT 20
71
72 #define ICP_FLAG_HIT_OBJ 0x80000000ul
73 #define ICP_FLAG_SRC_RTT 0x40000000ul
74
75 /* Version */
76 #define ICP_VERSION_2 2
77 #define ICP_VERSION_3 3
78 #define ICP_VERSION_CURRENT ICP_VERSION_2
79
80 #define DIRECT_UNKNOWN 0
81 #define DIRECT_NO 1
82 #define DIRECT_MAYBE 2
83 #define DIRECT_YES 3
84
85 #define REDIRECT_AV_FACTOR 1000
86
87 #define REDIRECT_NONE 0
88 #define REDIRECT_PENDING 1
89 #define REDIRECT_DONE 2
90
91 #define AUTHENTICATE_AV_FACTOR 1000
92 /* AUTHENTICATION */
93
94 #define NTLM_CHALLENGE_SZ 300
95
96 #define CONNECT_PORT 443
97
98 #define current_stacksize(stack) ((stack)->top - (stack)->base)
99
100 /* logfile status */
101 #define LOG_ENABLE 1
102 #define LOG_DISABLE 0
103
104 #define SM_PAGE_SIZE 4096
105 #define MAX_CLIENT_BUF_SZ 4096
106
107 #define EBIT_SET(flag, bit) ((void)((flag) |= ((1L<<(bit)))))
108 #define EBIT_CLR(flag, bit) ((void)((flag) &= ~((1L<<(bit)))))
109 #define EBIT_TEST(flag, bit) ((flag) & ((1L<<(bit))))
110
111 /* bit opearations on a char[] mask of unlimited length */
112 #define CBIT_BIT(bit) (1<<((bit)%8))
113 #define CBIT_BIN(mask, bit) (mask)[(bit)>>3]
114 #define CBIT_SET(mask, bit) ((void)(CBIT_BIN(mask, bit) |= CBIT_BIT(bit)))
115 #define CBIT_CLR(mask, bit) ((void)(CBIT_BIN(mask, bit) &= ~CBIT_BIT(bit)))
116 #define CBIT_TEST(mask, bit) (CBIT_BIN(mask, bit) & CBIT_BIT(bit))
117
118 #define MAX_FILES_PER_DIR (1<<20)
119
120 #define MAX_URL 8192
121 #define MAX_LOGIN_SZ 128
122
123 #define PEER_MAX_ADDRESSES 10
124 #define RTT_AV_FACTOR 50
125 #define RTT_BACKGROUND_AV_FACTOR 25 /* Background pings need a smaller factor since they are sent less frequently */
126
127 #define PEER_DEAD 0
128 #define PEER_ALIVE 1
129
130 #define AUTH_MSG_SZ 4096
131 #define HTTP_REPLY_BUF_SZ 4096
132 #define CLIENT_REQ_BUF_SZ 4096
133
134 #if !defined(ERROR_BUF_SZ) && defined(MAX_URL)
135 #define ERROR_BUF_SZ (MAX_URL << 2)
136 #endif
137
138 #if SQUID_SNMP
139 #define VIEWINCLUDED 1
140 #define VIEWEXCLUDED 2
141 #endif
142
143 #define STORE_META_OK 0x03
144 #define STORE_META_DIRTY 0x04
145 #define STORE_META_BAD 0x05
146
147 #define IPC_NONE 0
148 #define IPC_TCP_SOCKET 1
149 #define IPC_UDP_SOCKET 2
150 #define IPC_FIFO 3
151 #define IPC_UNIX_STREAM 4
152 #define IPC_UNIX_DGRAM 5
153
154 /* required for AF_UNIX below to be defined [on FreeBSD] */
155 #if HAVE_SYS_SOCKET_H
156 #include <sys/socket.h>
157 #endif
158
159 #if HAVE_SOCKETPAIR && defined (AF_UNIX)
160 #define IPC_STREAM IPC_UNIX_STREAM
161 #define IPC_DGRAM IPC_UNIX_DGRAM
162 #else
163 #define IPC_STREAM IPC_TCP_SOCKET
164 #define IPC_DGRAM IPC_UDP_SOCKET
165 #endif
166
167 #define STORE_META_KEY STORE_META_KEY_MD5
168
169 #define STORE_META_TLD_START sizeof(int)+sizeof(char)
170 #define STORE_META_TLD_SIZE STORE_META_TLD_START
171 #define SwapMetaType(x) (char)x[0]
172 #define SwapMetaSize(x) &x[sizeof(char)]
173 #define SwapMetaData(x) &x[STORE_META_TLD_START]
174 #define STORE_HDR_METASIZE (4*sizeof(time_t)+2*sizeof(uint16_t)+sizeof(uint64_t))
175 #define STORE_HDR_METASIZE_OLD (4*sizeof(time_t)+2*sizeof(uint16_t)+sizeof(size_t))
176
177 #define COUNT_INTERVAL 60
178 /*
179 * keep 60 minutes' worth of per-minute readings (+ current reading)
180 */
181 #define N_COUNT_HIST (3600 / COUNT_INTERVAL) + 1
182 /*
183 * keep 3 days' (72 hours) worth of hourly readings
184 */
185 #define N_COUNT_HOUR_HIST (86400 * 3) / (60 * COUNT_INTERVAL)
186
187 /* handy to determine the #elements in a static array */
188 #define countof(arr) (sizeof(arr)/sizeof(*arr))
189
190 /*
191 * This many TCP connections must FAIL before we mark the
192 * peer as DEAD
193 */
194 #define PEER_TCP_MAGIC_COUNT 10
195
196 #define URI_WHITESPACE_STRIP 0
197 #define URI_WHITESPACE_ALLOW 1
198 #define URI_WHITESPACE_ENCODE 2
199 #define URI_WHITESPACE_CHOP 3
200 #define URI_WHITESPACE_DENY 4
201
202 #ifndef O_TEXT
203 #define O_TEXT 0
204 #endif
205 #ifndef O_BINARY
206 #define O_BINARY 0
207 #endif
208
209 /*
210 * Macro to find file access mode
211 */
212 #ifdef O_ACCMODE
213 #define FILE_MODE(x) ((x)&O_ACCMODE)
214 #else
215 #define FILE_MODE(x) ((x)&(O_RDONLY|O_WRONLY|O_RDWR))
216 #endif
217
218 #define HTTP_REQBUF_SZ 4096
219
220 /* CygWin & Windows NT Port */
221 #if _SQUID_WINDOWS_
222 #define _WIN_SQUID_SERVICE_CONTROL_STOP SERVICE_CONTROL_STOP
223 #define _WIN_SQUID_SERVICE_CONTROL_SHUTDOWN SERVICE_CONTROL_SHUTDOWN
224 #define _WIN_SQUID_SERVICE_CONTROL_INTERROGATE SERVICE_CONTROL_INTERROGATE
225 #define _WIN_SQUID_SERVICE_CONTROL_ROTATE 128
226 #define _WIN_SQUID_SERVICE_CONTROL_RECONFIGURE 129
227 #define _WIN_SQUID_SERVICE_CONTROL_DEBUG 130
228 #define _WIN_SQUID_SERVICE_CONTROL_INTERRUPT 131
229 #define _WIN_SQUID_SERVICE_OPTION "--ntservice"
230 #define _WIN_SQUID_RUN_MODE_INTERACTIVE 0
231 #define _WIN_SQUID_RUN_MODE_SERVICE 1
232 #endif
233
234 #endif /* SQUID_DEFINES_H */
235