2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 /***************************************************************************
19 * Description: Global definitions and include files that should exist *
21 * Author: Gal Shachor <shachor@il.ibm.com> *
22 * Version: $Revision: 1126561 $ *
23 ***************************************************************************/
28 #if defined(HAVE_CONFIG_H)
34 /* Ignore most warnings (back down to /W3) for poorly constructed headers
36 #if defined(_MSC_VER) && _MSC_VER >= 1200
37 #pragma warning(push, 3)
40 /* disable or reduce the frequency of...
41 * C4057: indirection to slightly different base types
42 * C4075: slight indirection changes (unsigned short* vs short[])
43 * C4100: unreferenced formal parameter
44 * C4127: conditional expression is constant
45 * C4163: '_rotl64' : not available as an intrinsic function
46 * C4201: nonstandard extension nameless struct/unions
47 * C4244: int to char/short - precision loss
48 * C4514: unreferenced inline function removed
50 #pragma warning(disable: 4100 4127 4163 4201 4514; once: 4057 4075 4244)
52 /* Ignore Microsoft's interpretation of secure development
53 * and the POSIX string handling API
55 #if defined(_MSC_VER) && _MSC_VER >= 1400
56 #ifndef _CRT_SECURE_NO_DEPRECATE
57 #define _CRT_SECURE_NO_DEPRECATE
59 #pragma warning(disable: 4996)
60 #endif /* defined(_MSC_VER) && _MSC_VER >= 1400 */
61 #endif /* defined(WIN32) */
63 #include "jk_version.h"
67 #include "apr_strings.h"
80 #include "ap_config.h"
84 #include "ap_config.h"
85 extern char *strdup(const char *str);
88 #include <sys/types.h>
93 #ifndef WIN32_LEAN_AND_MEAN
94 #define WIN32_LEAN_AND_MEAN
98 /* Restrict the server to a subset of Windows NT 4.0 header files by default
100 #define _WIN32_WINNT 0x0500
113 * Add a _very_few_ declarations missing from the restricted set of headers
114 * (If this list becomes extensive, re-enable the required headers above!)
115 * winsock headers were excluded by WIN32_LEAN_AND_MEAN, so include them now
117 #include <winsock2.h>
120 #endif /* _WINDOWS_ */
126 #include <sys/timeb.h>
129 #include <ws2tcpip.h>
132 #if defined(NETWARE) && defined(__NOVELL_LIBC__)
133 #include <novsock2.h>
134 #define __sys_socket_h__
136 #define __netinet_in_h__
137 #define HAVE_VSNPRINTF
138 #define HAVE_SNPRINTF
141 #include <netinet/in.h>
142 #include <sys/socket.h>
147 typedef int socklen_t;
150 #include <netinet/tcp.h>
151 #include <arpa/inet.h>
153 #if !defined(_OSD_POSIX) && !defined(AS400) && !defined(__CYGWIN__) && !defined(HPUX11)
154 #include <sys/socketvar.h>
156 #if !defined(HPUX11) && !defined(AS400)
157 #include <sys/select.h>
161 #include <sys/time.h>
162 #include <sys/ioctl.h>
168 #endif /* __cplusplus */
170 #define JK_WORKER_FILE_TAG ("worker_file")
171 #define JK_MOUNT_FILE_TAG ("worker_mount_file")
172 #define JK_LOG_LEVEL_TAG ("log_level")
173 #define JK_LOG_FILE_TAG ("log_file")
174 #define JK_SHM_FILE_TAG ("shm_file")
175 #define JK_WORKER_NAME_TAG ("worker")
177 #define JK_WORKER_FILE_DEF ("workers.properties")
179 /* Urimap reload check time. Use 60 seconds by default.
181 #define JK_URIMAP_DEF_RELOAD (60)
186 #define JK_UNSET (-1)
191 #define JK_SESSION_IDENTIFIER "JSESSIONID"
192 #define JK_PATH_SESSION_IDENTIFIER ";jsessionid"
194 #if defined(WIN32) || defined(NETWARE)
197 #define C_LEVEL_TRY_START
198 #define C_LEVEL_TRY_END
199 #define C_LEVEL_FINALLY_START
200 #define C_LEVEL_FINALLY_END
202 #define JK_METHOD __stdcall
203 #define C_LEVEL_TRY_START __try {
204 #define C_LEVEL_TRY_END }
205 #define C_LEVEL_FINALLY_START __finally {
206 #define C_LEVEL_FINALLY_END }
208 #define PATH_SEPERATOR (';')
209 #define FILE_SEPERATOR ('\\')
210 #define PATH_ENV_VARIABLE ("PATH")
212 /* incompatible names... */
214 #define strcasecmp stricmp
216 #else /* defined(WIN32) || defined(NETWARE) */
218 #define C_LEVEL_TRY_START
219 #define C_LEVEL_TRY_END
220 #define C_LEVEL_FINALLY_START
221 #define C_LEVEL_FINALLY_END
222 #define PATH_SEPERATOR (':')
223 #define FILE_SEPERATOR ('/')
224 #define PATH_ENV_VARIABLE ("LD_LIBRARY_PATH")
225 #endif /* defined(WIN32) || defined(NETWARE) */
230 #define JK_HTTP_OK 200
231 #define JK_HTTP_BAD_REQUEST 400
232 #define JK_HTTP_UNAUTHORIZED 401
233 #define JK_HTTP_REQUEST_TOO_LARGE 413
234 #define JK_HTTP_SERVER_ERROR 500
235 #define JK_HTTP_NOT_IMPLEMENTED 501
236 #define JK_HTTP_BAD_GATEWAY 502
237 #define JK_HTTP_SERVER_BUSY 503
238 #define JK_HTTP_GATEWAY_TIME_OUT 504
245 #define RECO_NONE 0x00
246 #define RECO_INITED 0x01
247 #define RECO_FILLED 0x02
253 #define JK_OPT_FWDURIMASK 0x0007
255 #define JK_OPT_FWDURICOMPAT 0x0001
256 #define JK_OPT_FWDURICOMPATUNPARSED 0x0002
257 #define JK_OPT_FWDURIESCAPED 0x0003
258 #define JK_OPT_FWDURIPROXY 0x0004
260 #define JK_OPT_FWDURIDEFAULT JK_OPT_FWDURIPROXY
262 #define JK_OPT_FWDDIRS 0x0008
263 /* Forward local instead remote address */
264 #define JK_OPT_FWDLOCAL 0x0010
265 #define JK_OPT_FLUSHPACKETS 0x0020
266 #define JK_OPT_FLUSHEADER 0x0040
267 #define JK_OPT_DISABLEREUSE 0x0080
268 #define JK_OPT_FWDCERTCHAIN 0x0100
269 #define JK_OPT_FWDKEYSIZE 0x0200
270 #define JK_OPT_REJECTUNSAFE 0x0400
272 #define JK_OPT_DEFAULT (JK_OPT_FWDURIDEFAULT | JK_OPT_FWDKEYSIZE)
274 /* Check for EBCDIC systems */
276 /* Check for Apache 2.0 running on an EBCDIC system */
277 #if APR_CHARSET_EBCDIC
279 #include <util_ebcdic.h>
281 #define USE_CHARSET_EBCDIC
282 #define jk_xlate_to_ascii(b, l) ap_xlate_proto_to_ascii(b, l)
283 #define jk_xlate_from_ascii(b, l) ap_xlate_proto_from_ascii(b, l)
285 #else /* APR_CHARSET_EBCDIC */
287 /* Check for Apache 1.3 running on an EBCDIC system */
288 #ifdef CHARSET_EBCDIC
290 #define USE_CHARSET_EBCDIC
291 #define jk_xlate_to_ascii(b, l) ebcdic2ascii(b, b, l)
292 #define jk_xlate_from_ascii(b, l) ascii2ebcdic(b, b, l)
294 #else /* CHARSET_EBCDIC */
296 /* We're in on an ASCII system */
298 #define jk_xlate_to_ascii(b, l) /* NOOP */
299 #define jk_xlate_from_ascii(b, l) /* NOOP */
301 #endif /* CHARSET_EBCDIC */
303 #endif /* APR_CHARSET_EBCDIC */
305 /* on i5/OS V5R4 HTTP/APR APIs and Datas are in UTF */
306 #if defined(AS400_UTF8)
307 #undef USE_CHARSET_EBCDIC
308 #define jk_xlate_to_ascii(b, l) /* NOOP */
309 #define jk_xlate_from_ascii(b, l) /* NOOP */
312 /* jk_uint32_t defines a four byte word */
313 /* jk_uint64_t defines a eight byte word */
315 typedef unsigned int jk_uint32_t;
316 #define JK_UINT32_T_FMT "u"
317 #define JK_UINT32_T_HEX_FMT "x"
318 typedef unsigned __int64 jk_uint64_t;
319 #define JK_UINT64_T_FMT "I64u"
320 #define JK_UINT64_T_HEX_FMT "I64x"
321 #define JK_PID_T_FMT "d"
322 #define JK_PTHREAD_T_FMT "d"
323 #elif defined(AS400) || defined(NETWARE)
324 typedef unsigned int jk_uint32_t;
325 #define JK_UINT32_T_FMT "u"
326 #define JK_UINT32_T_HEX_FMT "x"
327 typedef unsigned long long jk_uint64_t;
328 #define JK_UINT64_T_FMT "llu"
329 #define JK_UINT64_T_HEX_FMT "llx"
330 #define JK_PID_T_FMT "d"
331 #define JK_PTHREAD_T_FMT "d"
333 #include "jk_types.h"
336 #define JK_UINT32_T_FMT_LEN (sizeof(JK_UINT32_T_FMT) - 1)
337 #define JK_UINT32_T_HEX_FMT_LEN (sizeof(JK_UINT32_T_HEX_FMT) - 1)
338 #define JK_UINT64_T_FMT_LEN (sizeof(JK_UINT64_T_FMT) - 1)
339 #define JK_UINT64_T_HEX_FMT_LEN (sizeof(JK_UINT64_T_HEX_FMT) - 1)
342 /* For WIN32, emulate gettimeofday() using _ftime() */
343 #define gettimeofday(tv, tz) { struct _timeb tb; _ftime(&tb); \
344 (tv)->tv_sec = (long)tb.time; \
345 (tv)->tv_usec = tb.millitm * 1000; }
346 #define HAVE_VSNPRINTF
347 #define HAVE_SNPRINTF
349 #define snprintf apr_snprintf
350 #define vsnprintf apr_vsnprintf
352 /* define snprint to match windows version */
353 #define snprintf _snprintf
354 #define vsnprintf _vsnprintf
358 /* Use apr snprintf() and vsnprintf() when needed */
359 #if defined(HAVE_APR)
360 #if !defined(HAVE_SNPRINTF)
361 #define snprintf apr_snprintf
363 #if !defined(HAVE_VSNPRINTF)
364 #define vsnprintf apr_vsnprintf
368 /* Use ap snprintf() and vsnprintf() when needed */
369 #if !defined(HAVE_APR)
370 #if !defined(HAVE_SNPRINTF)
371 #define snprintf ap_snprintf
373 #if !defined(HAVE_VSNPRINTF)
374 #define vsnprintf ap_vsnprintf
378 #if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__))
379 typedef SOCKET jk_sock_t;
380 #define IS_VALID_SOCKET(s) ((s) != INVALID_SOCKET)
381 #define JK_INVALID_SOCKET INVALID_SOCKET
383 typedef int jk_sock_t;
384 #define IS_VALID_SOCKET(s) ((s) > 0)
385 #define JK_INVALID_SOCKET (-1)
389 #ifdef __NOVELL_LIBC__
397 #define strcasecmp(a,b) apr_strnatcasecmp(a,b)
402 #endif /* __cplusplus */
404 #endif /* JK_GLOBAL_H */