diff --git a/httpd/httpd_1_3/ap_config.inc b/httpd/httpd_1_3/ap_config.inc new file mode 100644 index 000000000..a01876e4b --- /dev/null +++ b/httpd/httpd_1_3/ap_config.inc @@ -0,0 +1,1496 @@ +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + } + +{ + * ap_config.h: system-dependant #defines and includes... + * See PORTING for a listing of what they mean + } + +{$include ap_mmn.inc} { MODULE_MAGIC_NUMBER_ } + +{ + * Support for platform dependent autogenerated defines + } +{.$if not defined(WIN32) and not defined(NETWARE) and not defined(TPF)} +//#include "ap_config_auto.h" +//#endif + +{.$if defined(WIN32) or defined(NETWARE)} +{ not available under WIN32, so provide important entries manually } +{.$undefine HAVE_UNISTD_H} +//#endif + +{ Have to include sys/stat.h before ../win32/os.h so we can override +stat() properly } +//#ifndef NETWARE +//#include +//#endif +//#include + + +{ So that we can use inline on some critical functions, and use + * GNUC attributes (such as to get -Wall warnings for printf-like + * functions). Only do this in gcc 2.7 or later ... it may work + * on earlier stuff, but why chance it. + * + * We've since discovered that the gcc shipped with NeXT systems + * as "cc" is completely broken. It claims to be __GNUC__ and so + * on, but it doesn't implement half of the things that __GNUC__ + * means. In particular it's missing inline and the __attribute__ + * stuff. So we hack around it. PR#1613. -djg + } +{#if !defined(__GNUC__) || __GNUC__ < 2 || \ + (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\ + defined(NEXT) +#define ap_inline +#define __attribute__(__x) +#define ENUM_BITFIELD(e,n,w) signed int n : w +#else +#define ap_inline __inline__ +#define USE_GNU_INLINE +#define ENUM_BITFIELD(e,n,w) e n : w +#endif + +#include "os.h"} + +{ Define one of these according to your system. } +{$if defined(MINT)} +typedef int rlim_t; +#define JMP_BUF sigjmp_buf +#define NO_LONG_DOUBLE +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define _BSD_SOURCE +#define EAGAIN EWOULDBLOCK +int initgroups (char *, int); +char *crypt (const char *pw, const char *salt); +int gethostname (char *name, int namelen); + +{$else}{$if defined(MPE)} +#include +#define NO_SETSID +#define NO_KILLPG +#define NO_WRITEV +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD} +{ + UID/GID isn't a native concept for MPE, and it's definitely not a 100% + Unix implementation. There isn't a traditional superuser concept either, + so we're forced to liberalize SHM security a bit so the parent & children + can communicate when they're running with different UIDs within the same + GID (the GID will *always* be the same on MPE). Thus the weird SHM_R and + SHM_W below. +} +const + SHM_R = 0440; { Read permission } + SHM_W = 0220; { Write permission } +{$define NEED_INITGROUPS} +{$define NEED_STRCASECMP} +{$define NEED_STRDUP} +{$define NEED_STRNCASECMP} +//extern void GETPRIVMODE(); +//extern void GETUSERMODE(); +//extern char *inet_ntoa(); +//{$define NO_SLACK + S_IEXEC = S_IXUSR; + S_IREAD = S_IRUSR; + S_IWRITE = S_IWUSR; + PF_INET = AF_INET; +//#define HAVE_FCNTL_SERIALIZED_ACCEPT + +{$else}{$if defined(SUNOS4)} +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +char *crypt(const char *pw, const char *salt); +char *mktemp(char *); +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#include +#define NEED_STRERROR +typedef int rlim_t; +#define memmove(a,b,c) bcopy(b,a,c) +#define NO_LINGCLOSE +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define NEED_DIFFTIME +#define HAVE_SYSLOG 1 + +{$else}{$if defined(SOLARIS2)} +#undef HAVE_GMTOFF +#define NO_KILLPG +#undef NO_SETSID +#define bzero(a,b) memset(a,0,b) +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_PTHREAD_SERIALIZED_ACCEPT +#if !defined(USE_SYSVSEM_SERIALIZED_ACCEPT) && \ + !defined(USE_PTHREAD_SERIALIZED_ACCEPT) +#define USE_FCNTL_SERIALIZED_ACCEPT +#endif +#define NEED_UNION_SEMUN +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +int gethostname(char *name, int namelen); +#define HAVE_SYSLOG 1 +#define SYS_SIGLIST _sys_siglist +#define AP_ENABLE_EXCEPTION_HOOK +#define NONBLOCK_WHEN_MULTI_LISTEN + +{$else}{$if defined(IRIX)} +#undef HAVE_GMTOFF +{ IRIX has killpg, but it's only in _BSD_COMPAT, so don't use it in case + * there's some weird conflict with non-BSD signals } +#define NO_KILLPG +#undef NO_SETSID +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_USLOCK_SERIALIZED_ACCEPT +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#if !defined(USE_FLOCK_SERIALIZED_ACCEPT) && \ + !defined(USE_USLOCK_SERIALIZED_ACCEPT) && \ + !defined(USE_SYSVSEM_SERIALIZED_ACCEPT) +#define USE_FCNTL_SERIALIZED_ACCEPT +#endif +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define HAVE_MMAP 1 +#define USE_MMAP_FILES +#define NO_LONG_DOUBLE +#define NO_LINGCLOSE +#define HAVE_SYSLOG 1 +#define NONBLOCK_WHEN_MULTI_LISTEN + +{$else}{$if defined(HIUX)} +#undef HAVE_GMTOFF +#define NO_KILLPG +#undef NO_SETSID +#ifndef _HIUX_SOURCE +#define _HIUX_SOURCE +#endif +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define SELECT_NEEDS_CAST +#define HAVE_SYSLOG 1 + +{$else}{$if defined(HPUX11)} +#ifndef _HPUX_SOURCE +#define _HPUX_SOURCE +#endif +#define HAVE_SHMGET +#define USE_SHMGET_SCOREBOARD +#undef HAVE_GMTOFF +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_MMAP +#define USE_MMAP_FILES +#define NO_KILLPG +#undef NO_SETSID +#define HAVE_SYSLOG +#define AP_ENABLE_EXCEPTION_HOOK + +{$else}{$if defined(HPUX) or defined(HPUX10)} +#undef HAVE_GMTOFF +#define NO_KILLPG +#undef NO_SETSID +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#ifndef _HPUX_SOURCE +#define _HPUX_SOURCE +#endif +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define HAVE_SYSLOG 1 +#ifndef HPUX10 +#define SELECT_NEEDS_CAST +typedef int rlim_t; +#endif + +{$else}{$if defined(AIX)} +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#ifndef __ps2__ +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_SYSLOG 1 +#ifndef DEFAULT_GROUP +#define DEFAULT_GROUP "nobody" +#endif +#endif +#ifndef DEFAULT_USER +#define DEFAULT_USER "nobody" +#endif +#ifdef NEED_RLIM_T +typedef int rlim_t; +#endif +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#define NEED_UNION_SEMUN +#if AIX >= 430 +#define HAVE_PTHREAD_SERIALIZED_ACCEPT +#endif +#define USE_FCNTL_SERIALIZED_ACCEPT +#if AIX >= 432 +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#endif +#ifdef USEBCOPY +#define memmove(a,b,c) bcopy(b,a,c) +#endif +#if AIX >= 510 +#define NET_SIZE_T socklen_t +#elif AIX >= 420 +#define NET_SIZE_T size_t +#endif +#define AP_ENABLE_EXCEPTION_HOOK +#define NONBLOCK_WHEN_MULTI_LISTEN + +{$else}{$if defined(ULTRIX)} +{ we don't want to use sys/resource.h under + Ultrix although this header exists. } +#undef HAVE_SYS_RESOURCE_H +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +#define ULTRIX_BRAIN_DEATH +#define NEED_STRDUP +{ If you have Ultrix 4.3, and are using cc, const is broken } +#ifndef __ultrix__ { Hack to check for pre-Ultrix 4.4 cc } +#define const { Not implemented } +#endif + +{$else}{$if defined(OSF1)} +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define NO_LONG_DOUBLE +#define HAVE_SYSLOG 1 +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define NONBLOCK_WHEN_MULTI_LISTEN + +{$else}{$if defined(PARAGON)} +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define NO_LONG_DOUBLE +#define HAVE_SYSLOG 1 +typedef int rlim_t; + +{$else}{$if defined(SEQUENT)} +#define DEFAULT_USER "nobody" +#define DEFAULT_GROUP "nobody" +#define NO_SHMGET 1 +#define HAVE_MMAP 1 +#define HAVE_SYSLOG 1 +#define USE_MMAP_FILES 1 +#define USE_MMAP_SCOREBOARD 1 +#define HAVE_FCNTL_SERIALIZED_ACCEPT 1 +#define JMP_BUF sigjmp_buf +#undef NO_SETSID +#if SEQUENT < 40 +typedef int rlim_t; +#define NO_GETTIMEOFDAY +#undef HAVE_SYS_RESOURCE_H { exists but does not provide *rlimit funcs } +#include +#endif +#if SEQUENT < 42 +#define NEED_STRCASECMP +#define NEED_STRNCASECMP +#endif +#if SEQUENT < 44 +#define NO_KILLPG 1 +#define NET_SIZE_T int +#endif +#if SEQUENT >= 44 +#undef NO_KILLPG +#define NET_SIZE_T size_t +#endif + +{$else}{$if defined(NEXT)} +typedef unsigned short mode_t; +typedef int rlim_t; +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#define NO_SETSID +#define NEED_STRDUP +#define NO_LINGCLOSE +#undef _POSIX_SOURCE +#ifndef FD_CLOEXEC +#define FD_CLOEXEC 1 +#endif +#ifndef S_ISDIR +#define S_ISDIR(m) (((m)&(S_IFMT)) == (S_IFDIR)) +#endif +#ifndef S_ISREG +#define S_ISREG(m) (((m)&(S_IFMT)) == (S_IFREG)) +#endif +#ifndef S_IXUSR +#define S_IXUSR 00100 +#endif +#ifndef S_IRGRP +#define S_IRGRP 00040 +#endif +#ifndef S_IXGRP +#define S_IXGRP 00010 +#endif +#ifndef S_IROTH +#define S_IROTH 00004 +#endif +#ifndef S_IXOTH +#define S_IXOTH 00001 +#endif +#ifndef S_IRUSR +#define S_IRUSR S_IREAD +#endif +#ifndef S_IWUSR +#define S_IWUSR S_IWRITE +#endif +#ifndef S_IWGRP +#define S_IWGRP 000020 +#endif +#ifndef S_IWOTH +#define S_IWOTH 000002 +#endif + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +{ PR#2293 fix } +#define ap_wait_t union wait +#define waitpid(a,b,c) wait4((a) == -1 ? 0 : (a),(union wait *)(b),c,NULL) +#define WEXITSTATUS(status) (int)( WIFEXITED(status) ? ( (status).w_retcode ) : -1) +#define WTERMSIG(status) (int)( (status).w_termsig ) + +typedef int pid_t; +#define USE_LONGJMP +#define NO_USE_SIGACTION +#define HAVE_SYSLOG 1 + +#if defined(__DYNAMIC__) +#define HAVE_DYLD +#define DYLD_CANT_UNLOAD +#endif + +{$else}{$if defined(DARWIN)} { Darwin (Mac OS) } +#undef PLATFORM +#define PLATFORM "Darwin" +#define HAVE_DYLD +#define HAVE_GMTOFF +#define HAVE_MMAP +#define USE_MMAP_FILES +#define USE_MMAP_SCOREBOARD +#ifdef MAC_OS_X_SERVER +#define MAP_TMPFILE +#endif { MAC_OS_X_SERVER } +#define HAVE_RESOURCE +#define HAVE_SNPRINTF +#define JMP_BUF jmp_buf +#define USE_LONGJMP +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define USE_FLOCK_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define AP_ENABLE_EXCEPTION_HOOK + +{$else}{$if defined(LINUX)} + +//#if LINUX > 1 +//#include + +{ libc4 systems probably still work, it probably doesn't define + * __GNU_LIBRARY__ + * libc5 systems define __GNU_LIBRARY__ == 1, but don't define __GLIBC__ + * glibc 2.x and later systems define __GNU_LIBRARY__ == 6, but list it as + * "deprecated in favour of __GLIBC__"; the value 6 will never be changed. + * glibc 1.x systems (i.e. redhat 4.x on sparc/alpha) should have + * __GLIBC__ < 2 + * all glibc based systems need crypt.h + } +//#if defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 +//#include +//#endif + +{ glibc 2.0.0 through 2.0.4 need size_t * here, where 2.0.5 needs socklen_t * + * there's no way to discern between these two libraries. But using int should + * be portable because otherwise these libs would be hopelessly broken with + * reams of existing networking code. We'll use socklen_t * for 2.1.x and + * later. + * + * int works for all the earlier libs, and is picked up by default later. + } +//#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 0)) +//#define NET_SIZE_T socklen_t +//#endif + +const + HAVE_SHMGET = 1; +{$define USE_SHMGET_SCOREBOARD} + HAVE_MMAP = 1; +{$define USE_MMAP_FILES} + +//#if LINUX > 20 +{ see Pine.LNX.4.21.0011041233550.1897-100000@twinlark.arctic.org + * in new-httpd archives for performance numbers indicating these + * are the right choices for linux 2.2.x and later + } +{$define HAVE_SYSVSEM_SERIALIZED_ACCEPT} +{$define HAVE_FCNTL_SERIALIZED_ACCEPT} +{$define SINGLE_LISTEN_UNSERIALIZED_ACCEPT} +//#include +{$ifdef _SEM_SEMUN_UNDEFINED} +{$define NEED_UNION_SEMUN} +{$endif} +//#else +//#define USE_FCNTL_SERIALIZED_ACCEPT +//#endif + +//#define SYS_SIGLIST _sys_siglist + +{#else +#define USE_FCNTL_SERIALIZED_ACCEPT +#endif} + +{$undef HAVE_GMTOFF} +{$undef NO_KILLPG} +{$undef NO_SETSID} +{$undef NEED_STRDUP} +//#include + HAVE_SYSLOG = 1; + +{ glibc 2.1 and later finally define rlim_t } +{#if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1) +typedef int rlim_t; +#endif} +{$define AP_ENABLE_EXCEPTION_HOOK} + +{$else}{$if defined(SCO)} +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#define NEED_INITGROUPS +#define NO_WRITEV +#include +#define HAVE_SYSLOG 1 +#undef HAVE_SYS_RESOURCE_H + +{$else}{$if defined(ATHEOS)} + +#include +#include +#include + +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define USE_FCNTL_SERIALIZED_ACCEPT + +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#undef NEED_STRDUP +#define HAVE_SYSLOG 1 + +#ifdef PLATFORM +#undef PLATFORM +#endif +#define PLATFORM "AtheOS" + +{$else}{$if defined(SCO5)} + +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define SecureWare +#define HAVE_SYSLOG 1 + +{ Although SCO 5 defines these in (note the "s") they don't have + consts. Sigh. } +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, unsigned); + +{$else}{$if defined(AUX3)} +{ These are to let -Wall compile more cleanly } +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, unsigned); +extern int set42sig(), getopt(), getpeername(), bzero(); +extern int listen(), bind(), socket(), getsockname(); +extern int accept(), gethostname(), connect(), lstat(); +extern int select(), killpg(), shutdown(); +extern int initgroups(), setsockopt(); +extern char *shmat(); +extern int shmctl(); +extern int shmget(); +extern char *sbrk(); +extern char *crypt(); +#include +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#define NEED_STRDUP +{ fcntl() locking is expensive with NFS } +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +{ + * NOTE: If when you run Apache under A/UX and you get a warning + * that httpd couldn't move break, then the below value for + * MOVEBREAK (64megs) is too large for your setup. Try reducing + * to 0x2000000 which is still PLENTY of space. I doubt if + * even on heavy systems sbrk() would be called at all... + } +#define MOVEBREAK 0x4000000 +#define NO_LINGCLOSE +#define NO_SLACK +#define HAVE_SYSLOG 1 +#undef HAVE_SYS_RESOURCE_H { exists but does not provide *rlimit funcs } + +{$else}{$if defined(SVR4)} +#define NO_KILLPG +#undef NO_SETSID +#undef NEED_STRDUP +#ifndef MPRAS +#define NEED_STRCASECMP +#ifndef ENCORE +#define NEED_STRNCASECMP +#endif { ENCORE } +#endif { MPRAS } +#define bzero(a,b) memset(a,0,b) +{ A lot of SVR4 systems need this } +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#ifdef SNI +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#endif +#ifndef USE_SYSVSEM_SERIALIZED_ACCEPT +#define USE_FCNTL_SERIALIZED_ACCEPT +#endif +#define HAVE_SYSLOG 1 +#define NET_SIZE_T size_t +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#ifdef _OSD_POSIX { BS2000-POSIX mainframe needs initgroups } +#define NEED_HASHBANG_EMUL { execve() doesn't start shell scripts by default } +#define _KMEMUSER { Enable SHM_R/SHM_W defines in } +#define AP_ENABLE_EXCEPTION_HOOK +#undef NEED_STRCASECMP +#undef NEED_STRNCASECMP +#undef bzero +#endif {_OSD_POSIX} + +{$else}{$if defined(UW)} +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#if UW < 700 +#define NO_LINGCLOSE +#define NO_KILLPG +#else +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#endif +#undef NO_SETSID +#undef NEED_STRDUP +#define NEED_STRCASECMP +#define NEED_STRNCASECMP +#define bzero(a,b) memset(a,0,b) +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_SHMGET 1 +#undef USE_SHMGET_SCOREBOARD { force use of mmap() scoreboard } +#include +#if UW >= 200 +#define _POSIX_SOURCE +#endif +#define NET_SIZE_T size_t +#define HAVE_SYSLOG 1 + +{$else}{$if defined(DGUX)} +#define NO_KILLPG +#undef NO_SETSID +#undef NEED_STRDUP +#ifdef _IX86_DG +#undef NEED_STRCASECMP +#undef NEED_STRNCASECMP +#else +#define NEED_STRCASECMP +#define NEED_STRNCASECMP +#endif +#define bzero(a,b) memset(a,0,b) +{ A lot of SVR4 systems need this } +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define ap_inet_addr inet_network +#define HAVE_SYSLOG 1 + +{$else}{$if defined(__NetBSD__) or defined(__OpenBSD__) or defined(NETBSD)} +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +#define HAVE_SYSLOG 1 +#ifndef DEFAULT_USER +#define DEFAULT_USER "nobody" +#endif +#ifndef DEFAULT_GROUP +#define DEFAULT_GROUP "nogroup" +#endif +#define HAVE_SHMGET 1 +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#if defined(__OpenBSD__) +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#define USE_SYSVSEM_SERIALIZED_ACCEPT +#include +#if (OpenBSD >= 199912) +#define NET_SIZE_T socklen_t +#endif +#endif +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT + +{$else}{$if defined(UTS21)} +#undef HAVE_GMTOFF +#undef NO_KILLPG +#define NO_SETSID +#define NEED_WAITPID +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#define HAVE_SYSLOG 1 +#define USE_LONGJMP +#define JMP_BUF jmp_buf +#define NO_USE_SIGACTION +#define NEED_STRERROR +#define NEED_STRSTR +#define NEED_HASHBANG_EMUL +#define NDELAY_PIPE_RETURNS_ZERO +#define NO_DATA NO_ADDRESS +#define ap_wait_t union wait +#define WEXITSTATUS(status) (int)((status).w_retcode) +#define WTERMSIG(status) (int)((status).w_termsig) +#define strftime(buf,bufsize,fmt,tm) ascftime(buf,fmt,tm) +#undef HAVE_SYS_RESOURCE_H { exists but does not provide *rlimit funcs } +#include +#include + +{$else}{$if defined(APOLLO)} +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#define HAVE_SYSLOG 1 + +{$else}{$if defined(__FreeBSD__) or defined(__bsdi__)} +#if defined(__FreeBSD__) +#include +#endif +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#ifndef DEFAULT_USER +#define DEFAULT_USER "nobody" +#endif +#ifndef DEFAULT_GROUP +#define DEFAULT_GROUP "nogroup" +#endif +#if defined(__bsdi__) || \ +(defined(__FreeBSD_version) && (__FreeBSD_version < 220000)) +typedef quad_t rlim_t; +#endif +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define HAVE_SYSLOG 1 +#define SYS_SIGLIST sys_siglist +#if (defined(__FreeBSD_version) && (__FreeBSD_version >= 400000)) +#define NET_SIZE_T socklen_t +#endif + +{$else}{$if defined(QNX)} +#ifndef crypt +char *crypt(const char *pw, const char *salt); +#endif +#ifndef initgroups +int initgroups(char *, int); +#endif +#ifndef strncasecmp +#define strncasecmp strnicmp +#endif +#undef NO_KILLPG +#undef NO_SETSID +#define NEED_INITGROUPS +#define NEED_SELECT_H +#define NEED_PROCESS_H +#include +#define HAVE_MMAP 1 +#define USE_POSIX_SCOREBOARD +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define HAVE_SYSLOG 1 + +{$else}{$if defined(LYNXOS)} +#undef HAVE_GMTOFF +#undef USE_MMAP_SCOREBOARD +#undef USE_SHMGET_SCOREBOARD +#undef HAVE_FCNTL_SERIALIZED_ACCEPT +#undef HAVE_FLOCK_SERIALIZED_ACCEPT +#define HAVE_NONE_SERIALIZED_ACCEPT +#define USE_LONGJMP +#undef NO_KILLPG +#undef NO_SETSID +#undef NO_USE_SIGACTION +#undef NO_LINGCLOSE +extern char *crypt(char *pw, char *salt); +typedef int rlim_t; +#define HAVE_SYSLOG 1 + +{$else}{$if defined(UXPDS)} +#undef NEED_STRCASECMP +#undef NEED_STRNCASECMP +#undef NEED_STRDUP +#undef HAVE_GMTOFF +#define NO_KILLPG +#undef NO_SETSID +#define bzero(a,b) memset(a,0,b) +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_SYSLOG 1 + +{$else}{$if defined(OS2)} +{ Defines required for EMX OS/2 port. } +#define NO_KILLPG +#define NEED_STRCASECMP +#define NEED_STRNCASECMP +#define NEED_PROCESS_H +#define NO_SETSID +#define NO_TIMES +#define CASE_BLIND_FILESYSTEM +{ Add some drive name support } +#define chdir _chdir2 +#include +#define MAXSOCKETS 2048 +#define USE_OS2_SCOREBOARD +#define NO_RELIABLE_PIPED_LOGS +#define HAVE_OS2SEM_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define NO_SLACK +#define FOPEN_REQUIRES_T + +{$else}{$if defined(__MACHTEN__)} +typedef int rlim_t; +#undef NO_KILLPG +#define NO_SETSID +#define HAVE_GMTOFF 1 +#ifndef __MACHTEN_PPC__ +#ifndef __MACHTEN_68K__ +#define __MACHTEN_68K__ +#endif +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define NO_USE_SIGACTION +#define JMP_BUF sigjmp_buf +#define USE_LONGJMP +#undef NEED_STRDUP +#else +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#endif + +{ Convex OS v11 } +{$else}{$if defined(CONVEXOS11)} +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#undef NEED_STRDUP +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_SYSLOG 1 + +#define NO_TIMEZONE +#include +#include +typedef int rlim_t; + +{$else}{$if defined(ISC)} +#include +#define NO_KILLPG +#undef NO_SETSID +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_SYSLOG 1 + +{$else}{$if defined(NEWSOS)} +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define USE_LONGJMP +#define NO_SETSID +#define NO_USE_SIGACTION +#define NEED_WAITPID +#define NO_OTHER_CHILD +#define HAVE_SYSLOG 1 +#include +#include +#include +typedef int pid_t; +typedef int rlim_t; +typedef int mode_t; + +{$else}{$if defined(RISCIX)} +#include +typedef int rlim_t; +#define NO_USE_SIGACTION +#define USE_LONGJMP +#define NEED_STRCASECMP +#define NEED_STRNCASECMP +#define NEED_STRDUP + +{$else}{$if defined(BEOS)} +#undef PLATFORM +#define PLATFORM "BeOS" +#include +#include + +#define HAVE_BEOS_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT + +#define NO_WRITEV +#define NO_KILLPG +#define NEED_INITGROUPS +#define PF_INET AF_INET +#define S_IEXEC S_IXUSR + +{$else}{$if defined(BONE)} +#undef PLATFORM +#define PLATFORM "BeOS BONE" +#include + +#define NO_KILLPG +#define NEED_INITGROUPS +#define S_IEXEC S_IXUSR +#define HAVE_BEOS_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT + +{$else}{$if defined(_CX_SX)} +#define JMP_BUF sigjmp_buf +#include +#include + +{$else}{$if defined(WIN32)} + +{ All windows stuff is now in os/win32/os.h } + +{$else}{$if defined(TPF)} { IBM Transaction Processing Facility operating system } + +{ All TPF definitions are now in os/tpf/os.h } + +{$else}{$if defined(__TANDEM)} +#define NO_WRITEV +#define NO_KILLPG +#define NEED_INITGROUPS +#define NO_SLACK + +{$else}{$if defined(OS390)} { IBM OS/390 Operating System } +#define HAVE_MMAP +#define HAVE_SHMGET +#define USE_SHMGET_SCOREBOARD +#define USE_MMAP_FILES +#define NEED_UNION_SEMUN +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define _POSIX_SOURCE +#include +#ifdef SIGDUMP { SIGDUMP is not defined by OS/390 v1r2 } +#define NSIG SIGDUMP+1 +#else +#define NSIG 40 +#endif +#define JMP_BUF sigjmp_buf +#define _XOPEN_SOURCE_EXTENDED 1 +#define _OPEN_MSGQ_EXT +#define _XOPEN_SOURCE +#define SHM_R S_IRUSR +#define SHM_W S_IWUSR +#include +#include +#include +#include +#define NET_SIZE_T size_t +#define NEED_HASHBANG_EMUL +#define NONBLOCK_WHEN_MULTI_LISTEN + +{$else}{$if defined(CYGWIN)} { Cygwin 1.x POSIX layer for Win32 } +#define SYSTEM_UID 18 +#define JMP_BUF jmp_buf +#define NO_KILLPG +#define NO_SETSID +#define USE_LONGJMP +#define GDBM_STATIC +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_SYSLOG 1 +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_PTHREAD_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#if !defined(USE_FCNTL_SERIALIZED_ACCEPT) +#define USE_PTHREAD_SERIALIZED_ACCEPT +#endif + +{$else}{$if defined(NETWARE)} +#define NONBLOCK_WHEN_MULTI_LISTEN + +{$else} + { Unknown system - Edit these to match } + {$ifdef BSD} + {$define HAVE_GMTOFF} + {$else} + {$undefine HAVE_GMTOFF} + {$endif} + { NO_KILLPG is set on systems that don't have killpg } + {$undefine NO_KILLPG} + { NO_SETSID is set on systems that don't have setsid } + {$undefine NO_SETSID} + { NEED_STRDUP is set on stupid systems that don't have strdup. } + {$undefine NEED_STRDUP} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} +{$endif} + +//#ifdef HAVE_SYS_PARAM_H +//#include +//#endif { HAVE_SYS_PARAM_H } + +{ stuff marked API_EXPORT is part of the API, and intended for use + * by modules + } +//#ifndef API_EXPORT +//#define API_EXPORT(type) type +//#endif + +{ Stuff marked API_EXPORT_NONSTD is part of the API, and intended for + * use by modules. The difference between API_EXPORT and + * API_EXPORT_NONSTD is that the latter is required for any functions + * which use varargs or are used via indirect function call. This + * is to accomodate the two calling conventions in windows dlls. + } +{#ifndef API_EXPORT_NONSTD +#define API_EXPORT_NONSTD(type) type +#endif + +#ifndef MODULE_VAR_EXPORT +#define MODULE_VAR_EXPORT +#endif +#ifndef API_VAR_EXPORT +#define API_VAR_EXPORT +#endi} + +{ modules should not used functions marked CORE_EXPORT + * or CORE_EXPORT_NONSTD } +{#ifndef CORE_EXPORT +#define CORE_EXPORT API_EXPORT +#endif +#ifndef CORE_EXPORT_NONSTD +#define CORE_EXPORT_NONSTD API_EXPORT_NONSTD +#endif +} +{ On Darwin, symbols that conflict with loaded dylibs + * (eg. System framework) need to be declared as private symbols with + * __private_extern__. + * For other systems, make that a no-op. + } +{#if defined(DARWIN) && defined(__DYNAMIC__) +#define ap_private_extern __private_extern__ +#else +#define ap_private_extern +#endif} + +{ + * The particular directory style your system supports. If you have dirent.h + * in /usr/include (POSIX) or /usr/include/sys (SYSV), #include + * that file and define DIR_TYPE to be dirent. Otherwise, if you have + * /usr/include/sys/dir.h, define DIR_TYPE to be direct and include that + * file. If you have neither, I'm confused. + } + +{#ifndef NETWARE +#include +#endif +#include } + +{#if !defined(NEXT) && !defined(WIN32) +#include +#define DIR_TYPE dirent +#elif !defined(WIN32) +#include +#define DIR_TYPE direct +#else +#define DIR_TYPE dirent +#endif + +#include +#include +#include +#ifdef __TANDEM +#include +#endif +#include "ap_ctype.h" +#if !defined(MPE) && !defined(WIN32) && !defined(TPF41) && !defined(__TANDEM) && !defined(NETWARE) +#include +#endif +#if !defined(WIN32) && !defined(NETWARE) +#include +#ifdef HAVE_SYS_SELECT_H +#include +#endif }{ HAVE_SYS_SELECT_H } +{#ifndef TPF41 +#include +#endif }{ ndef TPF41 } +{#if defined(OS390) && !defined(NO_ADDRESS) +#define NO_ADDRESS NO_DATA } { Not defined properly by OS/390 v1r2 } +{#endif +#include +#include +#if !defined(MPE) && !defined(BEOS) && !defined(TPF41) +#include }{ for inet_ntoa } +{#endif +#include +#include +#include +#include +#ifndef BEOS +#define closesocket(s) close(s) +#endif +#ifndef O_BINARY +#define O_BINARY (0) +#endif +#endif }{ ndef WIN32 } + +{#include +#include } { for ctime } +{#ifdef WIN32 +#define strftime(s,max,format,tm) os_strftime(s,max,format,tm) +#endif +#include +#ifdef NETWARE +#undef SIGKILL +#undef SA_NOCLDSTOP +#undef SIGALRM +#undef SIGCHILD +#undef SIGCONT +#undef SIGHUP +#undef SIGPIPE +#undef SIGQUIT +#undef SIGSTOP +#undef SIGTSTP +#undef SIGTTIN +#undef SIGTTOU +#undef SIGUSR1 +#undef SIGUSR2 +#undef SIG_BLOCK +#undef SIG_SETMASK +#undef SIG_UNBLOCK +#endif +#if defined(TPF41) && defined(NSIG) +#undef NSIG +#endif +#include +#if !defined(QNX) && !defined(CONVEXOS11) && !defined(NEXT) && !defined(TPF41) && !defined(NETWARE) && !defined(MPE) +#include +#endif + +#ifdef NEED_PROCESS_H +#include +#endif} + +{#if defined(WIN32) || defined(USE_HSREGEX) +#include "hsregex.h" +#else +#include +#endif} + +{$include hsregex.inc} + +{#ifdef HAVE_SYS_RESOURCE_H +#include +#ifdef SUNOS4 +int getrlimit(int, struct rlimit *); +int setrlimit(int, struct rlimit *); +#endif +#endif +#ifdef USE_MMAP_SCOREBOARD +#if !defined(OS2) && !defined(WIN32)} +{ This file is not needed for OS/2 } +{#include +#endif +#endif +#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS) +#define MAP_ANON MAP_ANONYMOUS +#endif + +#if defined(USE_MMAP_FILES) && (defined(NO_MMAP) || !defined(HAVE_MMAP)) +#undef USE_MMAP_FILES +#endif + +#if defined(USE_MMAP_SCOREBOARD) && (defined(NO_MMAP) || !defined(HAVE_MMAP)) +#undef USE_MMAP_SCOREBOARD +#endif + +#if defined(USE_SHMGET_SCOREBOARD) && (defined(NO_SHMGET) || !defined(HAVE_SHMGET)) +#undef USE_SHMGET_SCOREBOARD +#endif} + +{ A USE_FOO_SERIALIZED_ACCEPT implies a HAVE_FOO_SERIALIZED_ACCEPT } +{#if defined(USE_USLOCK_SERIALIZED_ACCEPT) && !defined(HAVE_USLOCK_SERIALIZED_ACCEPT) +#define HAVE_USLOCK_SERIALIZED_ACCEPT +#endif +#if defined(USE_PTHREAD_SERIALIZED_ACCEPT) && !defined(HAVE_PTHREAD_SERIALIZED_ACCEPT) +#define HAVE_PTHREAD_SERIALIZED_ACCEPT +#endif +#if defined(USE_SYSVSEM_SERIALIZED_ACCEPT) && !defined(HAVE_SYSVSEM_SERIALIZED_ACCEPT) +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#endif +#if defined(USE_FCNTL_SERIALIZED_ACCEPT) && !defined(HAVE_FCNTL_SERIALIZED_ACCEPT) +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#endif +#if defined(USE_FLOCK_SERIALIZED_ACCEPT) && !defined(HAVE_FLOCK_SERIALIZED_ACCEPT) +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#endif +#if defined(USE_OS2SEM_SERIALIZED_ACCEPT) && !defined(HAVE_OS2SEM_SERIALIZED_ACCEPT) +#define HAVE_OS2SEM_SERIALIZED_ACCEPT +#endif +#if defined(USE_TPF_CORE_SERIALIZED_ACCEPT) && !defined(HAVE_TPF_CORE_SERIALIZED_ACCEPT) +#define HAVE_TPF_CORE_SERIALIZED_ACCEPT +#endif +#if defined(USE_BEOS_SERIALIZED_ACCEPT) && !defined(HAVE_BEOS_SERIALIZED_ACCEPT) +#define HAVE_BEOS_SERIALIZED_ACCEPT +#endif +#if defined(USE_NONE_SERIALIZED_ACCEPT) && !defined(HAVE_NONE_SERIALIZED_ACCEPT) +#define HAVE_NONE_SERIALIZED_ACCEPT +#endif} + + LOGNAME_MAX = 25; + +//#ifdef HAVE_UNISTD_H +//#include +//#endif + +//#ifdef ultrix +//#define ULTRIX_BRAIN_DEATH +//#endif + +{#ifndef S_ISLNK +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#endif + +#ifndef INADDR_NONE +#define INADDR_NONE ((unsigned long) -1) +#endif} + +{ + * Replace signal function with sigaction equivalent + } +{#ifndef NO_USE_SIGACTION +typedef void Sigfunc(int); + +#if defined(SIG_IGN) && !defined(SIG_ERR) +#define SIG_ERR ((Sigfunc *)-1) +#endif} + +{ + * For some strange reason, QNX defines signal to signal. Eliminate it. + } +{#ifdef signal +#undef signal +#endif +#define signal(s,f) ap_signal(s,f) +Sigfunc *signal(int signo, Sigfunc * func); +#endif + +#include + +#if defined(USE_LONGJMP) +#define ap_longjmp(x, y) longjmp((x), (y)) +#define ap_setjmp(x) setjmp(x) +#ifndef JMP_BUF +#define JMP_BUF jmp_buf +#endif +#else +#define ap_longjmp(x, y) siglongjmp((x), (y)) +#define ap_setjmp(x) sigsetjmp((x), 1) +#ifndef JMP_BUF +#define JMP_BUF sigjmp_buf +#endif +#endif} + +{ Majority of os's want to verify FD_SETSIZE } +{#if !defined(WIN32) && !defined(TPF) && !defined(NETWARE) +#define CHECK_FD_SETSIZE +#endif + +#ifdef USE_TPF_SELECT +#define ap_select(_a, _b, _c, _d, _e) \ + tpf_select(_a, _b, _c, _d, _e) +#elif defined(SELECT_NEEDS_CAST) +#define ap_select(_a, _b, _c, _d, _e) \ + select((_a), (int *)(_b), (int *)(_c), (int *)(_d), (_e)) +#else +#define ap_select(_a, _b, _c, _d, _e) \ + select(_a, _b, _c, _d, _e) +#endif + +#ifdef USE_TPF_ACCEPT +#define ap_accept(_fd, _sa, _ln) tpf_accept(_fd, _sa, _ln) +#else +#define ap_accept(_fd, _sa, _ln) accept(_fd, _sa, _ln) +#endif + +#ifdef NEED_SIGNAL_INTERRUPT +#define ap_check_signals() tpf_process_signals() +#else +#define ap_check_signals() +#endif + +#ifdef ULTRIX_BRAIN_DEATH +#define ap_fdopen(d,m) fdopen((d), (char *)(m)) +#else +#define ap_fdopen(d,m) fdopen((d), (m)) +#endif + +#ifndef ap_inet_addr +#define ap_inet_addr inet_addr +#endif + +#ifdef NO_OTHER_CHILD +#define NO_RELIABLE_PIPED_LOGS +#endif} + +{ When the underlying OS doesn't support exec() of scripts which start + * with a HASHBANG (#!) followed by interpreter name and args, define this. + } +{#ifdef NEED_HASHBANG_EMUL +extern int ap_execle(const char *filename, const char *arg,...); +extern int ap_execve(const char *filename, char * const argv[], + char * const envp[]);} +{ ap_execle() is a wrapper function around ap_execve(). } +{#define execle ap_execle +#define execve(path,argv,envp) ap_execve(path,argv,envp) +#endif} + +{ Finding offsets of elements within structures. + * Taken from the X code... they've sweated portability of this stuff + * so we don't have to. Sigh... + } + +{#if defined(CRAY) || (defined(__arm) && !defined(LINUX)) +#ifdef __STDC__ +#define XtOffset(p_type,field) _Offsetof(p_type,field) +#else +#ifdef CRAY2 +#define XtOffset(p_type,field) \ + (sizeof(int)*((unsigned int)&(((p_type)NULL)->field))) + +#else} { !CRAY2 } + +{#define XtOffset(p_type,field) ((unsigned int)&(((p_type)NULL)->field)) + +#endif }{ !CRAY2 } +//#endif { __STDC__ } +//#else { ! (CRAY || __arm) } + +//#define XtOffset(p_type,field) \ +// ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL))) + +//#endif { !CRAY } + +{#ifndef XtOffsetOf +#ifdef offsetof +#define XtOffsetOf(s_type,field) offsetof(s_type,field) +#else +#define XtOffsetOf(s_type,field) XtOffset(s_type*,field) +#endif +#endif} + +{ + * NET_SIZE_T exists because of shortsightedness on the POSIX committee. BSD + * systems used "int *" as the parameter to accept(), getsockname(), + * getpeername() et al. Consequently many unixes took an int * for that + * parameter. The POSIX committee decided that "int" was just too generic and + * had to be replaced with size_t almost everywhere. There's no problem with + * that when you're passing by value. But when you're passing by reference + * this creates a gross source incompatibility with existing programs. On + * 32-bit architectures it creates only a warning. On 64-bit architectures it + * creates broken code -- because "int *" is a pointer to a 64-bit quantity and + * "size_t *" is frequently a pointer to a 32-bit quantity. + * + * Some Unixes adopted "size_t *" for the sake of POSIX compliance. Others + * ignored it because it was such a broken interface. Chaos ensued. POSIX + * finally woke up and decided that it was wrong and created a new type + * socklen_t. The only useful value for socklen_t is int, and that's how + * everyone who has a clue implements it. It is almost always the case that + * NET_SIZE_T should be defined to be an int, unless the system being compiled + * for was created in the window of POSIX madness. + } +//#ifndef NET_SIZE_T +//#define NET_SIZE_T int +//#endif + +{ Linux defines __WCOREDUMP, but doesn't define WCOREDUMP unless __USE_BSD + * is in use... we'd prefer to just use WCOREDUMP everywhere. + } +//#if defined(__WCOREDUMP) && !defined(WCOREDUMP) +//#define WCOREDUMP __WCOREDUMP +//#endif + +//#ifdef SUNOS_LIB_PROTOTYPES +{ Prototypes needed to get a clean compile with gcc -Wall. + * Believe it or not, these do have to be declared, at least on SunOS, + * because they aren't mentioned in the relevant system headers. + * Sun Quality Software. Gotta love it. This section is not + * currently (13Nov97) used. + } + +{int getopt(int, char **, char *); + +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, int); +int toupper(int); +int tolower(int); + +int printf(char *,...); +int fprintf(FILE *, char *,...); +int fputs(char *, FILE *); +int fread(char *, int, int, FILE *); +int fwrite(char *, int, int, FILE *); +int fgetc(FILE *); +char *fgets(char *s, int, FILE*); +int fflush(FILE *); +int fclose(FILE *); +int ungetc(int, FILE *); +int _filbuf(FILE *); }{ !!! } +//int _flsbuf(unsigned char, FILE *); { !!! } +{int sscanf(char *, char *,...); +void setbuf(FILE *, char *); +void perror(char *); + +time_t time(time_t *); +int strftime(char *, int, const char *, struct tm *); + +int initgroups(char *, int);} +//int wait3(int *, int, void *); { Close enough for us... } +{int lstat(const char *, struct stat *); +int stat(const char *, struct stat *); +int flock(int, int); +#ifndef NO_KILLPG +int killpg(int, int); +#endif +int socket(int, int, int); +int setsockopt(int, int, int, const char *, int); +int listen(int, int); +int bind(int, struct sockaddr *, int); +int connect(int, struct sockaddr *, int); +int accept(int, struct sockaddr *, int *); +int shutdown(int, int); + +int getsockname(int s, struct sockaddr *name, int *namelen); +int getpeername(int s, struct sockaddr *name, int *namelen); +int gethostname(char *name, int namelen); +void syslog(int, char *,...); +char *mktemp(char *); + +int vfprintf(FILE *, const char *, va_list); + +#endif} { SUNOS_LIB_PROTOTYPES } + +{ The assumption is that when the functions are missing, + * then there's no matching prototype available either. + * Declare what is needed exactly as the replacement routines implement it. + } +{#ifdef NEED_STRDUP +extern char *strdup (const char *str); +#endif +#ifdef NEED_STRCASECMP +extern int strcasecmp (const char *a, const char *b); +#endif +#ifdef NEED_STRNCASECMP +extern int strncasecmp (const char *a, const char *b, int n); +#endif +#ifdef NEED_INITGROUPS +extern int initgroups(const char *name, gid_t basegid); +#endif +#ifdef NEED_WAITPID +extern int waitpid(pid_t pid, int *statusp, int options); +#endif +#ifdef NEED_STRERROR +extern char *strerror (int err); +#endif +#ifdef NEED_DIFFTIME +extern double difftime(time_t time1, time_t time0); +#endif + +#ifndef ap_wait_t +#define ap_wait_t int +#endif} + diff --git a/httpd/httpd_1_3/http_log.inc b/httpd/httpd_1_3/http_log.inc new file mode 100644 index 000000000..279bad57d --- /dev/null +++ b/httpd/httpd_1_3/http_log.inc @@ -0,0 +1,116 @@ +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + } + +{$ifdef HAVE_SYSLOG} +//#include + + APLOG_EMERG = LOG_EMERG; { system is unusable } + APLOG_ALERT = LOG_ALERT; { action must be taken immediately } + APLOG_CRIT = LOG_CRIT; { critical conditions } + APLOG_ERR = LOG_ERR; { error conditions } + APLOG_WARNING = LOG_WARNING; { warning conditions } + APLOG_NOTICE = LOG_NOTICE; { normal but significant condition } + APLOG_INFO = LOG_INFO; { informational } + APLOG_DEBUG = LOG_DEBUG; { debug-level messages } + + APLOG_LEVELMASK= LOG_PRIMASK; { mask off the level value } + +{$else} + + APLOG_EMERG = 0; { system is unusable } + APLOG_ALERT = 1; { action must be taken immediately } + APLOG_CRIT = 2; { critical conditions } + APLOG_ERR = 3; { error conditions } + APLOG_WARNING = 4; { warning conditions } + APLOG_NOTICE = 5; { normal but significant condition } + APLOG_INFO = 6; { informational } + APLOG_DEBUG = 7; { debug-level messages } + + APLOG_LEVELMASK= 7; { mask off the level value } + +{$endif} + + APLOG_NOERRNO = (APLOG_LEVELMASK + 1); +{$ifdef WIN32} +{ Set to indicate that error msg should come from Win32's GetLastError(), + * not errno. } + APLOG_WIN32ERROR = ((APLOG_LEVELMASK + 1) * 2); +{$endif} + + DEFAULT_LOGLEVEL = APLOG_WARNING; + +//#define APLOG_MARK __FILE__,__LINE__ + +//API_EXPORT(void) ap_open_logs (server_rec *, pool *p); + +{ The two primary logging functions, ap_log_error and ap_log_rerror, + * use a printf style format string to build the log message. It is + * VERY IMPORTANT that you not include any raw data from the network, + * such as the request-URI or request header fields, within the format + * string. Doing so makes the server vulnerable to a denial-of-service + * attack and other messy behavior. Instead, use a simple format string + * like "%s", followed by the string containing the untrusted data. + } +procedure ap_log_error( + const file_: PChar; line, level: Integer; + const s: Pserver_rec; const fmt: PChar; others: array of const); + cdecl; external LibHTTPD name 'ap_log_error'; + +// __attribute__((format(printf,5,6))); + +procedure ap_log_perror( + const file_: PChar; line, level: Integer; + const s: Prequest_rec; const fmt: PChar; others: array of const); + cdecl; external LibHTTPD name 'ap_log_perror'; + +// __attribute__((format(printf,5,6))); + +//API_EXPORT(void) ap_error_log2stderr (server_rec *); + +//API_EXPORT(void) ap_log_pid (pool *p, char *fname); +{ These are for legacy code, new code should use ap_log_error, + * or ap_log_rerror. + } +{API_EXPORT(void) ap_log_error_old(const char *err, server_rec *s); +API_EXPORT(void) ap_log_unixerr(const char *routine, const char *file, + const char *msg, server_rec *s); +API_EXPORT_NONSTD(void) ap_log_printf(const server_rec *s, const char *fmt, ...) + __attribute__((format(printf,2,3))); +API_EXPORT(void) ap_log_reason(const char *reason, const char *fname, + request_rec *r);} + +type + piped_log = record + p: PPool; +//#if !defined(NO_RELIABLE_PIPED_LOGS) || defined(TPF) + program_: PChar; + pid: cint; + fds: array[1..2] of cint; +//#else +// FILE *write_f; +//#endif + end; + +{API_EXPORT(piped_log *) ap_open_piped_log (pool *p, const char *program); +API_EXPORT(void) ap_close_piped_log (piped_log *);} +{#if !defined(NO_RELIABLE_PIPED_LOGS) || defined(TPF) +#define ap_piped_log_read_fd(pl) ((pl)->fds[0]) +#define ap_piped_log_write_fd(pl) ((pl)->fds[1]) +#else} +//#define ap_piped_log_read_fd(pl) (-1) +//#define ap_piped_log_write_fd(pl) (fileno((pl)->write_f)) +//#endif + diff --git a/httpd/httpd_1_3/http_main.inc b/httpd/httpd_1_3/http_main.inc new file mode 100644 index 000000000..d213670de --- /dev/null +++ b/httpd/httpd_1_3/http_main.inc @@ -0,0 +1,129 @@ +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + } + +{ + * Routines in http_main.c which other code --- in particular modules --- + * may want to call. Right now, that's limited to timeout handling. + * There are two functions which modules can call to trigger a timeout + * (with the per-virtual-server timeout duration); these are hard_timeout + * and soft_timeout. + * + * The difference between the two is what happens when the timeout + * expires (or earlier than that, if the client connection aborts) --- + * a soft_timeout just puts the connection to the client in an + * "aborted" state, which will cause http_protocol.c to stop trying to + * talk to the client, but otherwise allows the code to continue normally. + * hard_timeout(), by contrast, logs the request, and then aborts it + * completely --- longjmp()ing out to the accept() loop in http_main. + * Any resources tied into the request's resource pool will be cleaned up; + * everything that isn't will leak. + * + * soft_timeout() is recommended as a general rule, because it gives your + * code a chance to clean up. However, hard_timeout() may be the most + * convenient way of dealing with timeouts waiting for some external + * resource other than the client, if you can live with the restrictions. + * + * (When a hard timeout is in scope, critical sections can be guarded + * with block_alarms() and unblock_alarms() --- these are declared in + * alloc.c because they are most often used in conjunction with + * routines to allocate something or other, to make sure that the + * cleanup does get registered before any alarm is allowed to happen + * which might require it to be cleaned up; they * are, however, + * implemented in http_main.c). + * + * NOTE! It's not "fair" for a hard_timeout to be in scope through calls + * across modules. Your module code really has no idea what other modules may + * be present in the server, and they may not take too kindly to having a + * longjmp() happen -- it could result in corrupted state. Heck they may not + * even take to kindly to a soft_timeout()... because it can cause EINTR to + * happen on pretty much any syscall, and unless all the libraries and modules + * in use are known to deal well with EINTR it could cause corruption as well. + * But things are likely to do much better with a soft_timeout in scope than a + * hard_timeout. + * + * A module MAY NOT use a hard_timeout() across * sub_req_lookup_xxx() + * functions, or across run_sub_request() functions. A module SHOULD NOT use a + * soft_timeout() in either of these cases, but sometimes there's just no + * choice. + * + * kill_timeout() will disarm either variety of timeout. + * + * reset_timeout() resets the timeout in progress. + } + +{API_EXPORT(void) ap_start_shutdown(void); +API_EXPORT(void) ap_start_restart(int); +API_EXPORT(void) ap_hard_timeout(char *, request_rec *); +API_EXPORT(void) ap_keepalive_timeout(char *, request_rec *); +API_EXPORT(void) ap_soft_timeout(char *, request_rec *); +API_EXPORT(void) ap_kill_timeout(request_rec *); +API_EXPORT(void) ap_reset_timeout(request_rec *); + +API_EXPORT(void) ap_child_terminate(request_rec *r); +API_EXPORT(void) ap_sync_scoreboard_image(void); +API_EXPORT(int) ap_update_child_status(int child_num, int status, request_rec *r); +void ap_time_process_request(int child_num, int status); +API_EXPORT(unsigned int) ap_set_callback_and_alarm(void ( *fn) (int), int x); +API_EXPORT(int) ap_check_alarm(void); + +void setup_signal_names(char *prefix);} + +{ functions for determination and setting of accept() mutexing } +{char *ap_default_mutex_method(void); +char *ap_init_mutex_method(char *t);} + +{$ifndef NO_OTHER_CHILD} +{ + * register an other_child -- a child which the main loop keeps track of + * and knows it is different than the rest of the scoreboard. + * + * pid is the pid of the child. + * + * maintenance is a function that is invoked with a reason, the data + * pointer passed here, and when appropriate a status result from waitpid(). + * + * write_fd is an fd that is probed for writing by select() if it is ever + * unwritable, then maintenance is invoked with reason OC_REASON_UNWRITABLE. + * This is useful for log pipe children, to know when they've blocked. To + * disable this feature, use -1 for write_fd. + } +//API_EXPORT(void) ap_register_other_child(int pid, +// void ( *maintenance) (int reason, void *data, ap_wait_t status), void *data, +// int write_fd); + +const + OC_REASON_DEATH = 0; { child has died, caller must call + * unregister still } + OC_REASON_UNWRITABLE = 1; { write_fd is unwritable } + OC_REASON_RESTART = 2; { a restart is occuring, perform + * any necessary cleanup (including + * sending a special signal to child) + } + OC_REASON_UNREGISTER = 3; { unregister has been called, do + * whatever is necessary (including + * kill the child) } + OC_REASON_LOST = 4; { somehow the child exited without + * us knowing ... buggy os? } + +{ + * unregister an other_child. Note that the data pointer is used here, and + * is assumed to be unique per other_child. This is because the pid and + * write_fd are possibly killed off separately. + } +//API_EXPORT(void) ap_unregister_other_child(void *data); + +{$endif} + diff --git a/httpd/httpd_1_3/http_protocol.inc b/httpd/httpd_1_3/http_protocol.inc new file mode 100644 index 000000000..e60758aa4 --- /dev/null +++ b/httpd/httpd_1_3/http_protocol.inc @@ -0,0 +1,180 @@ +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + } + +{ + * Prototypes for routines which either talk directly back to the user, + * or control the ones that eventually do. + } + +{ Read a request and fill in the fields. } + +//API_EXPORT(request_rec *) ap_read_request(conn_rec *c); + +{ Send a single HTTP header field } + +//API_EXPORT_NONSTD(int) ap_send_header_field(request_rec *r, const char *fieldname, +// const char *fieldval); + +{ Send the minimal part of an HTTP response header... but modules should be + * very careful about using this, and should prefer ap_send_http_header(). + * Much of the HTTP/1.1 implementation correctness depends on code in + * ap_send_http_header(). + } +//API_EXPORT(void) ap_basic_http_header(request_rec *r); + +{ Send the Status-Line and header fields for HTTP response } + +//API_EXPORT(void) ap_send_http_header(request_rec *l); + +{ Send the response to special method requests } + +//API_EXPORT(int) ap_send_http_trace(request_rec *r); +//API_EXPORT(int) ap_send_http_options(request_rec *r); + +{ Finish up stuff after a request } + +//API_EXPORT(void) ap_finalize_request_protocol(request_rec *r); + +{ Send error back to client... last arg indicates error status in case + * we get an error in the process of trying to deal with an ErrorDocument + * to handle some other error. In that case, we print the default report + * for the first thing that went wrong, and more briefly report on the + * problem with the ErrorDocument. + } + +//API_EXPORT(void) ap_send_error_response(request_rec *r, int recursive_error); + +{ Set last modified header line from the lastmod date of the associated file. + * Also, set content length. + * + * May return an error status, typically USE_LOCAL_COPY (that when the + * permit_cache argument is set to one). + } + +{API_EXPORT(int) ap_set_content_length(request_rec *r, long length); +API_EXPORT(int) ap_set_keepalive(request_rec *r); +API_EXPORT(time_t) ap_rationalize_mtime(request_rec *r, time_t mtime); +API_EXPORT(char *) ap_make_etag(request_rec *r, int force_weak); +API_EXPORT(void) ap_set_etag(request_rec *r); +API_EXPORT(void) ap_set_last_modified(request_rec *r); +API_EXPORT(int) ap_meets_conditions(request_rec *r);} + +{ Other ways to send stuff at the client. All of these keep track + * of bytes_sent automatically. This indirection is intended to make + * it a little more painless to slide things like HTTP-NG packetization + * underneath the main body of the code later. In the meantime, it lets + * us centralize a bit of accounting (bytes_sent). + * + * These also return the number of bytes written by the call. + * They should only be called with a timeout registered, for obvious reaasons. + * (Ditto the send_header stuff). + } + +{API_EXPORT(long) ap_send_fd(FILE *f, request_rec *r); +API_EXPORT(long) ap_send_fd_length(FILE *f, request_rec *r, long length); + +API_EXPORT(long) ap_send_fb(BUFF *f, request_rec *r); +API_EXPORT(long) ap_send_fb_length(BUFF *f, request_rec *r, long length); + +API_EXPORT(size_t) ap_send_mmap(void *mm, request_rec *r, size_t offset, + size_t length);} + +{ Hmmm... could macrofy these for now, and maybe forever, though the + * definitions of the macros would get a whole lot hairier. + } + +//API_EXPORT(int) ap_rputc(int c, request_rec *r); + +function ap_rputs(const str: PChar; r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name 'ap_rputs'; +// external LibHTTPD name LibNamePrefix + 'ap_rputs' + LibSuff8; + +{API_EXPORT(int) ap_rwrite(const void *buf, int nbyte, request_rec *r); +API_EXPORT_NONSTD(int) ap_rvputs(request_rec *r,...); +API_EXPORT(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist); +API_EXPORT_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...) + __attribute__((format(printf,2,3))); +API_EXPORT(int) ap_rflush(request_rec *r);} + +{ + * Index used in custom_responses array for a specific error code + * (only use outside protocol.c is in getting them configured). + } + +//API_EXPORT(int) ap_index_of_response(int status); + +{ Reading a block of data from the client connection (e.g., POST arg) } + +{API_EXPORT(int) ap_setup_client_block(request_rec *r, int read_policy); +API_EXPORT(int) ap_should_client_block(request_rec *r); +API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz); +API_EXPORT(int) ap_discard_request_body(request_rec *r);} + +{ Sending a byterange } + +{API_EXPORT(int) ap_set_byterange(request_rec *r); +API_EXPORT(int) ap_each_byterange(request_rec *r, long *offset, long *length);} + +{ Support for the Basic authentication protocol. Note that there's + * nothing that prevents these from being in mod_auth.c, except that other + * modules which wanted to provide their own variants on finding users and + * passwords for Basic auth (a fairly common request) would then require + * mod_auth to be loaded or they wouldn't work. + * + * get_basic_auth_pw returns 0 (OK) if it set the 'pw' argument (and assured + * a correct value in r->connection->user); otherwise it returns an error + * code, either SERVER_ERROR if things are really confused, AUTH_REQUIRED + * if no authentication at all seemed to be in use, or DECLINED if there + * was authentication but it wasn't Basic (in which case, the caller should + * presumably decline as well). + * + * note_basic_auth_failure arranges for the right stuff to be scribbled on + * the HTTP return so that the client knows how to authenticate itself the + * next time. As does note_digest_auth_failure for Digest auth. + * + * note_auth_failure does the same thing, but will call the correct one + * based on the authentication type in use. + * + } + +//API_EXPORT(void) ap_note_auth_failure(request_rec *r); +//API_EXPORT(void) ap_note_basic_auth_failure(request_rec *r); +//API_EXPORT(void) ap_note_digest_auth_failure(request_rec *r); +//API_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, const char **pw); + +{ + * Setting up the protocol fields for subsidiary requests... + * Also, a wrapup function to keep the internal accounting straight. + } + +//API_EXPORT(void) ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r); +//API_EXPORT(void) ap_finalize_sub_req_protocol(request_rec *sub_r); + +{ This is also useful for putting sub_reqs and internal_redirects together } + +//CORE_EXPORT(void) ap_parse_uri(request_rec *r, const char *uri); + +{ Get the method number associated with the given string, assumed to + * contain an HTTP method. Returns M_INVALID if not recognized. + } +//API_EXPORT(int) ap_method_number_of(const char *method); + +//API_EXPORT(int) ap_getline(char *s, int n, BUFF *in, int fold); + +//API_EXPORT(long) ap_get_chunk_size(char *b); + + diff --git a/httpd/httpd_1_3/http_request.inc b/httpd/httpd_1_3/http_request.inc new file mode 100644 index 000000000..e36617974 --- /dev/null +++ b/httpd/httpd_1_3/http_request.inc @@ -0,0 +1,64 @@ +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + } + +{ http_request.c is the code which handles the main line of request + * processing, once a request has been read in (finding the right per- + * directory configuration, building it if necessary, and calling all + * the module dispatch functions in the right order). + * + * The pieces here which are public to the modules, allow them to learn + * how the server would handle some other file or URI, or perhaps even + * direct the server to serve that other file instead of the one the + * client requested directly. + * + * There are two ways to do that. The first is the sub_request mechanism, + * which handles looking up files and URIs as adjuncts to some other + * request (e.g., directory entries for multiviews and directory listings); + * the lookup functions stop short of actually running the request, but + * (e.g., for includes), a module may call for the request to be run + * by calling run_sub_req. The space allocated to create sub_reqs can be + * reclaimed by calling destroy_sub_req --- be sure to copy anything you care + * about which was allocated in its pool elsewhere before doing this. + } + +{API_EXPORT(request_rec *) ap_sub_req_lookup_uri(const char *new_file, + const request_rec *r); +API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file, + const request_rec *r); +API_EXPORT(request_rec *) ap_sub_req_method_uri(const char *method, + const char *new_file, + const request_rec *r); +API_EXPORT(int) ap_run_sub_req(request_rec *r); +API_EXPORT(void) ap_destroy_sub_req(request_rec *r);} + +{ + * Then there's the case that you want some other request to be served + * as the top-level request INSTEAD of what the client requested directly. + * If so, call this from a handler, and then immediately return OK. + } + +{API_EXPORT(void) ap_internal_redirect(const char *new_uri, request_rec *); +API_EXPORT(void) ap_internal_redirect_handler(const char *new_uri, request_rec *); +API_EXPORT(int) ap_some_auth_required(request_rec *r); +API_EXPORT(int) ap_is_initial_req(request_rec *r); +API_EXPORT(time_t) ap_update_mtime(request_rec *r, time_t dependency_mtime);} + +{$ifdef CORE_PRIVATE} +{ Function called by main.c to handle first-level request } +API_EXPORT(void) ap_process_request(request_rec *); +API_EXPORT(void) ap_die(int type, request_rec *r); +{$endif} + diff --git a/httpd/httpd_1_3/httpd.inc b/httpd/httpd_1_3/httpd.inc new file mode 100644 index 000000000..33ea06dc8 --- /dev/null +++ b/httpd/httpd_1_3/httpd.inc @@ -0,0 +1,1195 @@ +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + } + +{ + * httpd.h: header for simple (ha! not anymore) http daemon + } + +{ Headers in which EVERYONE has an interest... } +{$include ap_config.inc} +{$include ap_alloc.inc} +{$include buff.inc} +{$include ap.inc} + +{$include util_uri.inc} + +{ ----------------------------- config dir ------------------------------ } + +{ Define this to be the default server home dir. Most things later in this + * file with a relative pathname will have this added. + } +const + {$ifdef OS2} + { Set default for OS/2 file system } + HTTPD_ROOT = '/os2httpd'; + {$else}{$ifdef WINDOWS} + { Set default for Windows file system } + HTTPD_ROOT = '/apache'; + {$else}{$if defined(BEOS) or defined(BONE)} + { Set the default for BeOS } + HTTPD_ROOT = '/boot/home/apache'; + {$else}{$ifdef NETWARE} + { Set the default for NetWare } + HTTPD_ROOT = 'sys:/apache'; + {$else} + HTTPD_ROOT = '/usr/local/apache'; + {$endif} + {$endif} + {$endif} + {$endif} + +{ Default location of documents. Can be overridden by the DocumentRoot + * directive. + } + {$ifdef OS2} + { Set default for OS/2 file system } + DOCUMENT_LOCATION = HTTPD_ROOT + '/docs'; + {$else} + DOCUMENT_LOCATION = HTTPD_ROOT + '/htdocs'; + {$endif} + + { Max. number of dynamically loaded modules } + DYNAMIC_MODULE_LIMIT = 64; + + { Default administrator's address } + DEFAULT_ADMIN = '[no address given]'; + + { The target name of the installed Apache } + TARGET = 'httpd'; + +{ + * --------- You shouldn't have to edit anything below this line ---------- + * + * Any modifications to any defaults not defined above should be done in the + * respective config. file. + * + } + + +{ -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- } + +{#define HTTP_VERSION(major,minor) (1000*(major)+(minor)) +#define HTTP_VERSION_MAJOR(number) ((number)/1000) +#define HTTP_VERSION_MINOR(number) ((number)%1000)} + + +{ -------------- Port number for server running standalone --------------- } + + DEFAULT_HTTP_PORT = 80; + DEFAULT_HTTPS_PORT = 443; +//#define ap_is_default_port(port,r) ((port) == ap_default_port(r)) +{$ifdef NETWARE} +#define ap_http_method(r) ap_os_http_method((void*)r) +#define ap_default_port(r) ap_os_default_port((void*)r) +{$else} +// ap_http_method(r) = 'http'; +// ap_default_port(r) = DEFAULT_HTTP_PORT; +{$endif} + +{ --------- Default user name and group name running standalone ---------- } +{ --- These may be specified as numbers by placing a # before a number --- } + + DEFAULT_USER = '#-1'; + DEFAULT_GROUP = '#-1'; + +{$ifndef DEFAULT_ERRORLOG} +{$if defined(OS2) or defined(WIN32)} + DEFAULT_ERRORLOG = 'logs/error.log'; +{$else} + DEFAULT_ERRORLOG = 'logs/error_log'; +{$endif} +{$endif} { DEFAULT_ERRORLOG } + + DEFAULT_PIDLOG = 'logs/httpd.pid'; + + DEFAULT_SCOREBOARD = 'logs/apache_runtime_status'; + + DEFAULT_LOCKFILE = 'logs/accept.lock'; + +{ Define this to be what your HTML directory content files are called } + + DEFAULT_INDEX = 'index.html'; + +{ Define this to 1 if you want fancy indexing, 0 otherwise } + + DEFAULT_INDEXING = 0; + +{ Define this to be what type you'd like returned for files with unknown } +{ suffixes. MUST be all lower case. } + + DEFAULT_CONTENT_TYPE = 'text/plain'; + +{ Define this to be what your per-directory security files are called } +{$ifndef DEFAULT_ACCESS_FNAME} +{$ifdef OS2} +{ Set default for OS/2 file system } + DEFAULT_ACCESS_FNAME = 'htaccess'; +{$else} + DEFAULT_ACCESS_FNAME = '.htaccess'; +{$endif} +{$endif} { DEFAULT_ACCESS_FNAME } + +{ The name of the server config file } + + SERVER_CONFIG_FILE = 'conf/httpd.conf'; + +{ The name of the document config file } + + RESOURCE_CONFIG_FILE = 'conf/srm.conf'; + +{ The name of the MIME types file } + + TYPES_CONFIG_FILE = 'conf/mime.types'; + +{ The name of the access file } + + ACCESS_CONFIG_FILE = 'conf/access.conf'; + +{ Whether we should enable rfc1413 identity checking } + + DEFAULT_RFC1413 = 0; + +{ The default directory in user's home dir } + + DEFAULT_USER_DIR = 'public_html'; + +{ The default path for CGI scripts if none is currently set } + + DEFAULT_PATH = '/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin'; + +{ The path to the shell interpreter, for parsed docs } + + {$if defined(OS2) or defined(WIN32)} +{ Set default for OS/2 and Windows file system } + SHELL_PATH = 'CMD.EXE'; + {$else} + SHELL_PATH = '/bin/sh'; + {$endif} + +{ The path to the suExec wrapper, can be overridden in Configuration } + + SUEXEC_BIN = HTTPD_ROOT + '/bin/suexec'; + +{ The default string lengths } + HUGE_STRING_LEN = 8192; + MAX_STRING_LEN = HUGE_STRING_LEN; + +{ The timeout for waiting for messages } + + DEFAULT_TIMEOUT = 300; + +{ The timeout for waiting for keepalive timeout until next request } + + DEFAULT_KEEPALIVE_TIMEOUT = 15; + +{ The number of requests to entertain per connection } + + DEFAULT_KEEPALIVE = 100; + +{ The size of the server's internal read-write buffers } + IOBUFSIZE = 8192; + +{ The max number of regex captures that can be expanded by ap_pregsub } + AP_MAX_REG_MATCH = 10; + +{ Number of servers to spawn off by default --- also, if fewer than + * this free when the caretaker checks, it will spawn more. + } + + DEFAULT_START_DAEMON = 5; + +{ Maximum number of *free* server processes --- more than this, and + * they will die off. + } + + DEFAULT_MAX_FREE_DAEMON = 10; + +{ Minimum --- fewer than this, and more will be created } + + DEFAULT_MIN_FREE_DAEMON = 5; + +{ Limit on the total --- clients will be locked out if more servers than + * this are needed. It is intended solely to keep the server from crashing + * when things get out of hand. + * + * We keep a hard maximum number of servers, for two reasons --- first off, + * in case something goes seriously wrong, we want to stop the fork bomb + * short of actually crashing the machine we're running on by filling some + * kernel table. Secondly, it keeps the size of the scoreboard file small + * enough that we can read the whole thing without worrying too much about + * the overhead. + } +{$ifndef HARD_SERVER_LIMIT} +{$ifdef WIN32} + HARD_SERVER_LIMIT = 1024; +{$else}{$if defined(NETWARE)} + HARD_SERVER_LIMIT = 2048; +{$else} + HARD_SERVER_LIMIT = 256; +{$endif} +{$endif} +{$endif} + +{ + * Special Apache error codes. These are basically used + * in http_main.c so we can keep track of various errors. + * + * APEXIT_OK: + * A normal exit + * APEXIT_INIT: + * A fatal error arising during the server's init sequence + * APEXIT_CHILDINIT: + * The child died during it's init sequence + * APEXIT_CHILDFATAL: + * A fatal error, resulting in the whole server aborting. + * If a child exits with this error, the parent process + * considers this a server-wide fatal error and aborts. + * + } + APEXIT_OK = $0; + APEXIT_INIT = $2; + APEXIT_CHILDINIT = $3; + APEXIT_CHILDFATAL = $f; + +{ + * (Unix, OS/2 only) + * Interval, in microseconds, between scoreboard maintenance. During + * each scoreboard maintenance cycle the parent decides if it needs to + * spawn a new child (to meet MinSpareServers requirements), or kill off + * a child (to meet MaxSpareServers requirements). It will only spawn or + * kill one child per cycle. Setting this too low will chew cpu. The + * default is probably sufficient for everyone. But some people may want + * to raise this on servers which aren't dedicated to httpd and where they + * don't like the httpd waking up each second to see what's going on. + } + + SCOREBOARD_MAINTENANCE_INTERVAL = 1000000; + +{ Number of requests to try to handle in a single process. If <= 0, + * the children don't die off. That's the default here, since I'm still + * interested in finding and stanching leaks. + } + + DEFAULT_MAX_REQUESTS_PER_CHILD = 0; + + DEFAULT_THREADS_PER_CHILD = 50; + + DEFAULT_EXCESS_REQUESTS_PER_CHILD = 0; + +{ The maximum length of the queue of pending connections, as defined + * by listen(2). Under some systems, it should be increased if you + * are experiencing a heavy TCP SYN flood attack. + * + * It defaults to 511 instead of 512 because some systems store it + * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is + * 255 when truncated. + } + + DEFAULT_LISTENBACKLOG = 511; + +{ Limits on the size of various request items. These limits primarily + * exist to prevent simple denial-of-service attacks on a server based + * on misuse of the protocol. The recommended values will depend on the + * nature of the server resources -- CGI scripts and database backends + * might require large values, but most servers could get by with much + * smaller limits than we use below. The request message body size can + * be limited by the per-dir config directive LimitRequestBody. + * + * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE + * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190. + * These two limits can be lowered (but not raised) by the server config + * directives LimitRequestLine and LimitRequestFieldsize, respectively. + * + * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by + * the server config directive LimitRequestFields. + } + + { default limit on bytes in Request-Line (Method+URI+HTTP-version) } + DEFAULT_LIMIT_REQUEST_LINE = 8190; + + { default limit on bytes in any one header field } + DEFAULT_LIMIT_REQUEST_FIELDSIZE = 8190; + + { default limit on number of request header fields } + DEFAULT_LIMIT_REQUEST_FIELDS = 100; + +{ + * The default default character set name to add if AddDefaultCharset is + * enabled. Overridden with AddDefaultCharsetName. + } + DEFAULT_ADD_DEFAULT_CHARSET_NAME = 'iso-8859-1'; + +{ + * The below defines the base string of the Server: header. Additional + * tokens can be added via the ap_add_version_component() API call. + * + * The tokens are listed in order of their significance for identifying the + * application. + * + * "Product tokens should be short and to the point -- use of them for + * advertizing or other non-essential information is explicitly forbidden." + * + * Example: "Apache/1.1.0 MrWidget/0.1-alpha" + } + + SERVER_BASEVENDOR = 'Apache Group'; + SERVER_BASEPRODUCT = 'Apache'; + SERVER_BASEREVISION = '1.3.37'; + SERVER_BASEVERSION = SERVER_BASEPRODUCT + '/' + SERVER_BASEREVISION; + + SERVER_PRODUCT = SERVER_BASEPRODUCT; + SERVER_REVISION = SERVER_BASEREVISION; + SERVER_VERSION = SERVER_PRODUCT + '/' + SERVER_REVISION; + +type + server_token_type = ( + SrvTk_MIN, { eg: Apache/1.3.0 } + SrvTk_OS, { eg: Apache/1.3.0 (UNIX) } + SrvTk_FULL, { eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b } + SrvTk_PRODUCT_ONLY { eg: Apache } + ); + +//API_EXPORT(const char *) ap_get_server_version(void); +//API_EXPORT(void) ap_add_version_component(const char *component); +//API_EXPORT(const char *) ap_get_server_built(void); + +{ Numeric release version identifier: MMNNFFRBB: major minor fix final beta + * Always increases along the same track as the source branch. + * For example, Apache 1.4.2 would be '10402100', 2.5b7 would be '20500007'. + } +const + APACHE_RELEASE = 10337100; + + SERVER_PROTOCOL = 'HTTP/1.1'; + SERVER_SUPPORT = 'http://www.apache.org/'; + + DECLINED = -1; { Module declines to handle } + DONE = -2; { Module has served the response completely + * - it's safe to die() with no more output + } + OK = 0; { Module has handled this stage. } + + +{ ----------------------- HTTP Status Codes ------------------------- } + +{ The size of the static array in http_protocol.c for storing + * all of the potential response status-lines (a sparse table). + * A future version should dynamically generate the table at startup. + } + RESPONSE_CODES = 55; + + HTTP_CONTINUE = 100; + HTTP_SWITCHING_PROTOCOLS = 101; + HTTP_PROCESSING = 102; + HTTP_OK = 200; + HTTP_CREATED = 201; + HTTP_ACCEPTED = 202; + HTTP_NON_AUTHORITATIVE = 203; + HTTP_NO_CONTENT = 204; + HTTP_RESET_CONTENT = 205; + HTTP_PARTIAL_CONTENT = 206; + HTTP_MULTI_STATUS = 207; + HTTP_MULTIPLE_CHOICES = 300; + HTTP_MOVED_PERMANENTLY = 301; + HTTP_MOVED_TEMPORARILY = 302; + HTTP_SEE_OTHER = 303; + HTTP_NOT_MODIFIED = 304; + HTTP_USE_PROXY = 305; + HTTP_TEMPORARY_REDIRECT = 307; + HTTP_BAD_REQUEST = 400; + HTTP_UNAUTHORIZED = 401; + HTTP_PAYMENT_REQUIRED = 402; + HTTP_FORBIDDEN = 403; + HTTP_NOT_FOUND = 404; + HTTP_METHOD_NOT_ALLOWED = 405; + HTTP_NOT_ACCEPTABLE = 406; + HTTP_PROXY_AUTHENTICATION_REQUIRED= 407; + HTTP_REQUEST_TIME_OUT = 408; + HTTP_CONFLICT = 409; + HTTP_GONE = 410; + HTTP_LENGTH_REQUIRED = 411; + HTTP_PRECONDITION_FAILED = 412; + HTTP_REQUEST_ENTITY_TOO_LARGE = 413; + HTTP_REQUEST_URI_TOO_LARGE = 414; + HTTP_UNSUPPORTED_MEDIA_TYPE = 415; + HTTP_RANGE_NOT_SATISFIABLE = 416; + HTTP_EXPECTATION_FAILED = 417; + HTTP_UNPROCESSABLE_ENTITY = 422; + HTTP_LOCKED = 423; + HTTP_FAILED_DEPENDENCY = 424; + HTTP_INTERNAL_SERVER_ERROR = 500; + HTTP_NOT_IMPLEMENTED = 501; + HTTP_BAD_GATEWAY = 502; + HTTP_SERVICE_UNAVAILABLE = 503; + HTTP_GATEWAY_TIME_OUT = 504; + HTTP_VERSION_NOT_SUPPORTED = 505; + HTTP_VARIANT_ALSO_VARIES = 506; + HTTP_INSUFFICIENT_STORAGE = 507; + HTTP_NOT_EXTENDED = 510; + + DOCUMENT_FOLLOWS = HTTP_OK; + PARTIAL_CONTENT = HTTP_PARTIAL_CONTENT; + MULTIPLE_CHOICES = HTTP_MULTIPLE_CHOICES; + MOVED = HTTP_MOVED_PERMANENTLY; + REDIRECT = HTTP_MOVED_TEMPORARILY; + USE_LOCAL_COPY = HTTP_NOT_MODIFIED; + BAD_REQUEST = HTTP_BAD_REQUEST; + AUTH_REQUIRED = HTTP_UNAUTHORIZED; + FORBIDDEN = HTTP_FORBIDDEN; + NOT_FOUND = HTTP_NOT_FOUND; + METHOD_NOT_ALLOWED = HTTP_METHOD_NOT_ALLOWED; + NOT_ACCEPTABLE = HTTP_NOT_ACCEPTABLE; + LENGTH_REQUIRED = HTTP_LENGTH_REQUIRED; + PRECONDITION_FAILED= HTTP_PRECONDITION_FAILED; + SERVER_ERROR = HTTP_INTERNAL_SERVER_ERROR; + NOT_IMPLEMENTED = HTTP_NOT_IMPLEMENTED; + BAD_GATEWAY = HTTP_BAD_GATEWAY; + VARIANT_ALSO_VARIES= HTTP_VARIANT_ALSO_VARIES; + +{#define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200)) +#define ap_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300)) +#define ap_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400)) +#define ap_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600)) +#define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500)) +#define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600)) + +#define ap_status_drops_connection(x) \ + (((x) == HTTP_BAD_REQUEST) || \ + ((x) == HTTP_REQUEST_TIME_OUT) || \ + ((x) == HTTP_LENGTH_REQUIRED) || \ + ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \ + ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \ + ((x) == HTTP_INTERNAL_SERVER_ERROR) || \ + ((x) == HTTP_SERVICE_UNAVAILABLE) || \ + ((x) == HTTP_NOT_IMPLEMENTED))} + +{ Methods recognized (but not necessarily handled) by the server. + * These constants are used in bit shifting masks of size int, so it is + * unsafe to have more methods than bits in an int. HEAD == M_GET. + } + M_GET = 0; + M_PUT = 1; + M_POST = 2; + M_DELETE = 3; + M_CONNECT = 4; + M_OPTIONS = 5; + M_TRACE = 6; + M_PATCH = 7; + M_PROPFIND = 8; + M_PROPPATCH = 9; + M_MKCOL = 10; + M_COPY = 11; + M_MOVE = 12; + M_LOCK = 13; + M_UNLOCK = 14; + M_INVALID = 15; + + METHODS = 16; + + CGI_MAGIC_TYPE = 'application/x-httpd-cgi'; + INCLUDES_MAGIC_TYPE = 'text/x-server-parsed-html'; + INCLUDES_MAGIC_TYPE3 = 'text/x-server-parsed-html3'; +{$ifdef CHARSET_EBCDIC} + ASCIITEXT_MAGIC_TYPE_PREFIX = 'text/x-ascii-'; { Text files whose content-type starts with this are passed thru unconverted } +{$endif} {CHARSET_EBCDIC} + MAP_FILE_MAGIC_TYPE = 'application/x-type-map'; + ASIS_MAGIC_TYPE = 'httpd/send-as-is'; + DIR_MAGIC_TYPE = 'httpd/unix-directory'; + STATUS_MAGIC_TYPE = 'application/x-httpd-status'; + +{ + * Define the HTML doctype strings centrally. + } + DOCTYPE_HTML_2_0 = '' + LineEnding; + DOCTYPE_HTML_3_2 = '' + LineEnding; + DOCTYPE_HTML_4_0S = '' + LineEnding; + DOCTYPE_HTML_4_0T = '' + LineEnding; + DOCTYPE_HTML_4_0F = '' + LineEnding; + +{ Just in case your linefeed isn't the one the other end is expecting. } +{$ifndef CHARSET_EBCDIC} + LF = 10; + CR = 13; + CRLF = #15#12; +//#define OS_ASC(c) (c) +{$else} { CHARSET_EBCDIC } +//#include "ap_ebcdic.h" +{ OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in + * the buff package (bread/bputs/bwrite), so everywhere else, we use + * "native EBCDIC" CR and NL characters. These are therefore defined as + * '\r' and '\n'. + * NB: this is not the whole truth - sometimes \015 and \012 are contained + * in literal (EBCDIC!) strings, so these are not converted but passed. + } +#define CR '\r' +#define LF '\n' +#define CRLF "\r\n" +#define OS_ASC(c) (os_toascii[c]) +{$endif} { CHARSET_EBCDIC } + +{ Possible values for request_rec.read_body (set by handling module): + * REQUEST_NO_BODY Send 413 error if message has any body + * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length + * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me. + * REQUEST_CHUNKED_PASS Pass the chunks to me without removal. + } + REQUEST_NO_BODY = 0; + REQUEST_CHUNKED_ERROR = 1; + REQUEST_CHUNKED_DECHUNK = 2; + REQUEST_CHUNKED_PASS = 3; + + { Things moved up } + + DEFAULT_VHOST_ADDR = $ffffffff; + +{ Things which may vary per file-lookup WITHIN a request --- + * e.g., state of MIME config. Basically, the name of an object, info + * about the object, and any other info we may ahve which may need to + * change as we go poking around looking for it (e.g., overridden by + * .htaccess files). + * + * Note how the default state of almost all these things is properly + * zero, so that allocating it with pcalloc does the right thing without + * a whole lot of hairy initialization... so long as we are willing to + * make the (fairly) portable assumption that the bit pattern of a NULL + * pointer is, in fact, zero. + } + +{ This represents the result of calling htaccess; these are cached for + * each request. + } +type + Phtaccess_result = ^htaccess_result; + + htaccess_result = record + dir: PChar; { the directory to which this applies } + override_: cint; { the overrides allowed for the .htaccess file } + htaccess: Pointer; { the configuration directives } +{ the next one, or NULL if no more; N.B. never change this } + next: Phtaccess_result; + end; + + Pconn_rec = ^conn_rec; + Pserver_rec = ^server_rec; + Prequest_rec = ^request_rec; + Plisten_rec = ^listen_rec; + +{.$include util_uri.inc} + + proxyreqtype = ( + NOT_PROXY=0, + STD_PROXY, + PROXY_PASS + ); + + request_rec = record + + pool: Pap_pool; + connection: Pconn_rec; + server: Pserver_rec; + + next: Prequest_rec; { If we wind up getting redirected, + * pointer to the request we redirected to. + } + prev: Prequest_rec; { If this is an internal redirect, + * pointer to where we redirected *from*. + } + + main: Prequest_rec; { If this is a sub_request (see request.h) + * pointer back to the main request. + } + + { Info about the request itself... we begin with stuff that only + * protocol.c should ever touch... + } + + the_request: PChar; { First line of request, so we can log it } + assbackwards: cint; { HTTP/0.9, "simple" request } + proxyreq: proxyreqtype; { A proxy request (calculated during + * post_read_request or translate_name) } + header_only: cint; { HEAD request, as opposed to GET } + protocol: PChar; { Protocol, as given to us, or HTTP/0.9 } + proto_num: cint; { Number version of protocol; 1.1 = 1001 } + hostname: PChar; { Host, as set by full URI or Host: } + + request_time: time_t; { When the request started } + + status_line: PChar; { Status line, if set by script } + status: cint; { In any case } + + { Request method, two ways; also, protocol, etc.. Outside of protocol.c, + * look, but don't touch. + } + + method: PChar; { GET, HEAD, POST, etc. } + method_number: cint; { M_GET, M_POST, etc. } + + { + allowed is a bitvector of the allowed methods. + + A handler must ensure that the request method is one that + it is capable of handling. Generally modules should DECLINE + any request methods they do not handle. Prior to aborting the + handler like this the handler should set r->allowed to the list + of methods that it is willing to handle. This bitvector is used + to construct the "Allow:" header required for OPTIONS requests, + and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes. + + Since the default_handler deals with OPTIONS, all modules can + usually decline to deal with OPTIONS. TRACE is always allowed, + modules don't need to set it explicitly. + + Since the default_handler will always handle a GET, a + module which does *not* implement GET should probably return + METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET + handler can't be installed by mod_actions. + } + allowed: cint; { Allowed methods - for 405, OPTIONS, etc } + + sent_bodyct: cint; { byte count in stream is for body } + bytes_sent: clong; { body byte count, for easy access } + mtime: time_t; { Time the resource was last modified } + + { HTTP/1.1 connection-level features } + + chunked: cint; { sending chunked transfer-coding } + byterange: cint; { number of byte ranges } + boundary: PChar; { multipart/byteranges boundary } + range: PChar; { The Range: header } + clength: clong; { The "real" content length } + + remaining: clong; { bytes left to read } + read_length: clong; { bytes that have been read } + read_body: cint; { how the request body should be read } + read_chunked: cint; { reading chunked transfer-coding } + expecting_100: cuint; { is client waiting for a 100 response? } + + { MIME header environments, in and out. Also, an array containing + * environment variables to be passed to subprocesses, so people can + * write modules to add to that environment. + * + * The difference between headers_out and err_headers_out is that the + * latter are printed even on error, and persist across internal redirects + * (so the headers printed for ErrorDocument handlers will have them). + * + * The 'notes' table is for notes from one module to another, with no + * other set purpose in mind... + } + + headers_in: PTable; + headers_out: PTable; + err_headers_out: PTable; + subprocess_env: PTable; + notes: PTable; + + { content_type, handler, content_encoding, content_language, and all + * content_languages MUST be lowercased strings. They may be pointers + * to static strings; they should not be modified in place. + } + content_type: PChar; { Break these out --- we dispatch on 'em } + handler: PChar; { What we *really* dispatch on } + + content_encoding: PChar; + content_language: PChar; { for back-compat. only -- do not use } + content_languages: Parray_header; { array of (char*) } + + vlist_validator: PChar; { variant list validator (if negotiated) } + + no_cache: cint; + no_local_copy: cint; + + { What object is being requested (either directly, or via include + * or content-negotiation mapping). + } + + unparsed_uri: PChar; { the uri without any parsing performed } + uri: PChar; { the path portion of the URI } + filename: PChar; { filename if found, otherwise NULL } + path_info: PChar; + args: PChar; { QUERY_ARGS, if any } + finfo: Integer;//stat; { ST_MODE set to zero if no such file } + parsed_uri: uri_components; { components of uri, dismantled } + + { Various other config info which may change with .htaccess files + * These are config vectors, with one void* pointer for each module + * (the thing pointed to being the module's business). + } + + per_dir_config: Pointer; { Options set in config files, etc. } + request_config: Pointer; { Notes on *this* request } + +{ + * a linked list of the configuration directives in the .htaccess files + * accessed by this request. + * N.B. always add to the head of the list, _never_ to the end. + * that way, a sub request's list can (temporarily) point to a parent's list + } + htaccess: Phtaccess_result; + + { On systems with case insensitive file systems (Windows, OS/2, etc.), + * r->filename is case canonicalized (folded to either lower or upper + * case, depending on the specific system) to accomodate file access + * checking. case_preserved_filename is the same as r->filename + * except case is preserved. There is at least one instance where Apache + * needs access to the case preserved filename: Java class files published + * with WebDAV need to preserve filename case to make the Java compiler + * happy. + } + case_preserved_filename: PChar; + +{$ifdef CHARSET_EBCDIC} + { We don't want subrequests to modify our current conversion flags. + * These flags save the state of the conversion flags when subrequests + * are run. + } + struct { + unsigned conv_in:1; { convert ASCII->EBCDIC when read()ing? } + unsigned conv_out:1; { convert EBCDIC->ASCII when write()ing? } + } ebcdic; +{$endif} + +{ Things placed at the end of the record to avoid breaking binary + * compatibility. It would be nice to remember to reorder the entire + * record to improve 64bit alignment the next time we need to break + * binary compatibility for some other reason. + } + end; + + +{ Things which are per connection + } + + sockaddr_in = record end; + + conn_rec = record + + pool: Pap_pool; + server: Pserver_rec; + base_server: Pserver_rec; { Physical vhost this conn come in on } + vhost_lookup_data: Pointer; { used by http_vhost.c } + + { Information about the connection itself } + + child_num: cint; { The number of the child handling conn_rec } + client: PBUFF; { Connection to the guy } + + { Who is the client? } + + local_addr: sockaddr_in; { local address } + remote_addr: sockaddr_in; { remote address } + remote_ip: PChar; { Client's IP address } + remote_host: PChar; { Client's DNS name, if known. + * NULL if DNS hasn't been checked, + * "" if it has and no address was found. + * N.B. Only access this though + * get_remote_host() } + remote_logname: PChar; { Only ever set if doing rfc1413 lookups. + * N.B. Only access this through + * get_remote_logname() } + user: PChar; { If an authentication check was made, + * this gets set to the user name. We assume + * that there's only one user per connection(!) + } + ap_auth_type: PChar; { Ditto. } + +// unsigned aborted:1; { Are we still talking? } +// signed int keepalive:2; { Are we using HTTP Keep-Alive? +// * -1 fatal error, 0 undecided, 1 yes } +// unsigned keptalive:1; { Did we use HTTP Keep-Alive? } +// signed int double_reverse:2;{ have we done double-reverse DNS? +// * -1 yes/failure, 0 not yet, 1 yes/success } + keepalives: cint; { How many times have we used it? } + local_ip: PChar; { server IP address } + local_host: PChar; { used for ap_get_server_name when + * UseCanonicalName is set to DNS + * (ignores setting of HostnameLookups) } + end; + +{ Per-vhost config... } + +{ The address 255.255.255.255, when used as a virtualhost address, + * will become the "default" server when the ip doesn't match other vhosts. + } + + { Moved up } + + Pserver_addr_rec = ^server_addr_rec; + + in_addr = record end; + + server_addr_rec = record + next: Pserver_addr_rec; + host_addr: in_addr; { The bound address, for this server } + host_port: cushort; { The bound port, for this server } + virthost: PChar; { The name given in } + end; + + server_rec = record + + next: Pserver_rec; + + { description of where the definition came from } + defn_name: PChar; + defn_line_number: cuint; + + { Full locations of server config info } + + srm_confname: PChar; + access_confname: PChar; + + { Contact information } + + server_admin: PChar; + server_hostname: PChar; + port: cushort; { for redirects, etc. } + + { Log files --- note that transfer log is now in the modules... } + + error_fname: PChar; + error_log: Pointer; //FILE * + loglevel: cint; + + { Module-specific configuration for server, and defaults... } + + is_virtual: cint; { true if this is the virtual server } + module_config: Pointer; { Config vector containing pointers to + * modules' per-server config structures. + } + lookup_defaults: Pointer; { MIME type info, etc., before we start + * checking per-directory info. + } + { Transaction handling } + + addrs: Pserver_addr_rec; + timeout: cint; { Timeout, in seconds, before we give up } + keep_alive_timeout: cint; { Seconds we'll wait for another request } + keep_alive_max: cint; { Maximum requests per connection } + keep_alive: cint; { Use persistent connections? } + send_buffer_size: cint; { size of TCP send buffer (in bytes) } + + path: PChar; { Pathname for ServerPath } + pathlen: cint; { Length of path } + + names: Parray_header; { Normal names for ServerAlias servers } + wild_names: Parray_header; { Wildcarded names for ServerAlias servers } + + server_uid: uid_t; { effective user id when calling exec wrapper } + server_gid: gid_t; { effective group id when calling exec wrapper } + + limit_req_line: cint; { limit on size of the HTTP request line } + limit_req_fieldsize: cint; { limit on size of any request header field } + limit_req_fields: cint; { limit on number of request header fields } + end; + + { These are more like real hosts than virtual hosts } + + listen_rec = record + next: Plisten_rec; + local_addr: sockaddr_in; { local IP address and port } + fd: cint; + used: cint; { Only used during restart } + { more stuff here, like which protocol is bound to the port } + end; + +{ Prototypes for utilities... util.c. + } + +//extern void ap_util_init(void); + +{ Time } +{extern API_VAR_EXPORT const char ap_month_snames[12][4]; +extern API_VAR_EXPORT const char ap_day_snames[7][4]; + +API_EXPORT(struct tm *) ap_get_gmtoff(int *tz); +API_EXPORT(char *) ap_get_time(void); +API_EXPORT(char *) ap_field_noparam(pool *p, const char *intype); +API_EXPORT(char *) ap_ht_time(pool *p, time_t t, const char *fmt, int gmt); +API_EXPORT(char *) ap_gm_timestr_822(pool *p, time_t t); +} +{ String handling. The *_nc variants allow you to use non-const char **s as + arguments (unfortunately C won't automatically convert a char ** to a const + char **) } + +{API_EXPORT(char * ) ap_getword(pool *p, const char **line, char stop); +API_EXPORT(char * ) ap_getword_nc(pool *p, char **line, char stop); +API_EXPORT(char * ) ap_getword_white(pool *p, const char **line); +API_EXPORT(char * ) ap_getword_white_nc(pool *p, char **line); +API_EXPORT(char * ) ap_getword_nulls(pool *p, const char **line, char stop); +API_EXPORT(char * ) ap_getword_nulls_nc(pool *p, char **line, char stop); +API_EXPORT(char * ) ap_getword_conf(pool *p, const char **line); +API_EXPORT(char * ) ap_getword_conf_nc(pool *p, char **line); + +API_EXPORT(const char *) ap_size_list_item(const char **field, int *len); +API_EXPORT(char *) ap_get_list_item(pool *p, const char **field); +API_EXPORT(int) ap_find_list_item(pool *p, const char *line, const char *tok); + +API_EXPORT(char *) ap_get_token(pool *p, const char **accept_line, int accept_white); +API_EXPORT(int) ap_find_token(pool *p, const char *line, const char *tok); +API_EXPORT(int) ap_find_last_token(pool *p, const char *line, const char *tok); + +API_EXPORT(int) ap_is_url(const char *u); +API_EXPORT(int) ap_unescape_url(char *url); +API_EXPORT(void) ap_no2slash(char *name); +API_EXPORT(void) ap_getparents(char *name); +API_EXPORT(char *) ap_escape_path_segment(pool *p, const char *s); +API_EXPORT(char *) ap_os_escape_path(pool *p, const char *path, int partial); +#define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1) +API_EXPORT(char *) ap_escape_html(pool *p, const char *s); +API_EXPORT(char *) ap_construct_server(pool *p, const char *hostname, + unsigned port, const request_rec *r); +API_EXPORT(char *) ap_escape_logitem(pool *p, const char *str); +API_EXPORT(size_t) ap_escape_errorlog_item(char *dest, const char *source, + size_t buflen); +API_EXPORT(char *) ap_escape_shell_cmd(pool *p, const char *s); + +API_EXPORT(int) ap_count_dirs(const char *path); +API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n); +API_EXPORT(char *) ap_make_dirstr_parent(pool *p, const char *s);} +{ deprecated. The previous two routines are preferred. } +{API_EXPORT(char *) ap_make_dirstr(pool *a, const char *s, int n); +API_EXPORT(char *) ap_make_full_path(pool *a, const char *dir, const char *f); + +API_EXPORT(int) ap_is_matchexp(const char *str); +API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp); +API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp); +API_EXPORT(char *) ap_stripprefix(const char *bigstring, const char *prefix); +API_EXPORT(char *) ap_strcasestr(const char *s1, const char *s2); +API_EXPORT(char *) ap_pbase64decode(pool *p, const char *bufcoded); +API_EXPORT(char *) ap_pbase64encode(pool *p, char *string); +API_EXPORT(char *) ap_uudecode(pool *p, const char *bufcoded); +API_EXPORT(char *) ap_uuencode(pool *p, char *string); + +#if defined(OS2) || defined(WIN32) +API_EXPORT(char *) ap_double_quotes(pool *p, const char *str); +API_EXPORT(char *) ap_caret_escape_args(pool *p, const char *str); +#endif + +#ifdef OS2 +void os2pathname(char *path); +#endif + +API_EXPORT(int) ap_regexec(const regex_t *preg, const char *string, + size_t nmatch, regmatch_t pmatch[], int eflags); +API_EXPORT(size_t) ap_regerror(int errcode, const regex_t *preg, + char *errbuf, size_t errbuf_size); +API_EXPORT(char *) ap_pregsub(pool *p, const char *input, const char *source, + size_t nmatch, regmatch_t pmatch[]); + +API_EXPORT(void) ap_content_type_tolower(char *); +API_EXPORT(void) ap_str_tolower(char *); +API_EXPORT(int) ap_ind(const char *, char);} { Sigh... } +{API_EXPORT(int) ap_rind(const char *, char); + +API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring); +API_EXPORT(void) ap_remove_spaces(char *dest, char *src);} + +{ Common structure for reading of config files / passwd files etc. } +type + + Pconfigfile_t = ^configfile_t; + + getch_t = function (param: Pointer): cint; + + getstr_t = function (buf: Pointer; bufsiz: size_t; param: Pointer): Pointer; + + close_t = function (param: Pointer): cint; + + configfile_t = record + getch: getch_t; { a getc()-like function } + getstr: getstr_t; { a fgets()-like function } + close: close_t; { a close hander function } + param: Pointer; { the argument passed to getch/getstr/close } + name: PChar; { the filename / description } + line_number: cuint; { current line number, starting at 1 } + end; + +{ Open a configfile_t as FILE, return open configfile_t struct pointer } +//API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name); + +{ Allocate a configfile_t handle with user defined functions and params } +//API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool *p, const char *descr, +// void *param, +// int( *getc_func)(void*), +// void *( *gets_func) (void *buf, size_t bufsiz, void *param), +// int( *close_func)(void *param)); + +{ Read one line from open configfile_t, strip LF, increase line number } +//API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, configfile_t *cfp); + +{ Read one char from open configfile_t, increase line number upon LF } +//API_EXPORT(int) ap_cfg_getc(configfile_t *cfp); + +{ Detach from open configfile_t, calling the close handler } +//API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp); + +//#ifdef NEED_STRERROR +//char *strerror(int err); +//#endif + +{ Misc system hackery } + +{API_EXPORT(uid_t) ap_uname2id(const char *name); +API_EXPORT(gid_t) ap_gname2id(const char *name); +API_EXPORT(int) ap_is_directory(const char *name); +API_EXPORT(int) ap_is_rdirectory(const char *name); +API_EXPORT(int) ap_can_exec(const struct stat *); +API_EXPORT(void) ap_chdir_file(const char *file); +} +//#ifndef HAVE_CANONICAL_FILENAME +{ + * We can't define these in os.h because of dependence on pool pointer. + } +{#define ap_os_canonical_filename(p,f) (f) +#define ap_os_case_canonical_filename(p,f) (f) +#define ap_os_systemcase_filename(p,f) (f) +#else +API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file); +#ifdef WIN32 +API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); +API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile); +#elif defined(OS2) +API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); +API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile); +#elif defined(NETWARE) +API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); +#define ap_os_systemcase_filename(p,f) ap_os_case_canonical_filename(p,f) +#else +#define ap_os_case_canonical_filename(p,f) ap_os_canonical_filename(p,f) +#define ap_os_systemcase_filename(p,f) ap_os_canonical_filename(p,f) +#endif +#endi} + +//#ifdef CHARSET_EBCDIC +//API_EXPORT(int) ap_checkconv(struct request_rec *r); { for downloads } +//API_EXPORT(int) ap_checkconv_in(struct request_rec *r); { for uploads } +//#endif {#ifdef CHARSET_EBCDIC} + +{API_EXPORT(char *) ap_get_local_host(pool *); +API_EXPORT(unsigned long) ap_get_virthost_addr(char *hostname, unsigned short *port); + +extern API_VAR_EXPORT time_t ap_restart_time;} + +{ + * Apache tries to keep all of its long term filehandles (such as log files, + * and sockets) above this number. This is to workaround problems in many + * third party libraries that are compiled with a small FD_SETSIZE. There + * should be no reason to lower this, because it's only advisory. If a file + * can't be allocated above this number then it will remain in the "slack" + * area. + * + * Only the low slack line is used by default. If HIGH_SLACK_LINE is defined + * then an attempt is also made to keep all non-FILE * files above the high + * slack line. This is to work around a Solaris C library limitation, where it + * uses an unsigned char to store the file descriptor. + } + +const + LOW_SLACK_LINE = 15; + +{ #define HIGH_SLACK_LINE 255 } + +{ + * The ap_slack() function takes a fd, and tries to move it above the indicated + * line. It returns an fd which may or may not have moved above the line, and + * never fails. If the high line was requested and it fails it will also try + * the low line. + } +{#ifdef NO_SLACK +#define ap_slack(fd,line) (fd) +#else +int ap_slack(int fd, int line); +#define AP_SLACK_LOW 1 +#define AP_SLACK_HIGH 2 +#endif + +API_EXPORT(char *) ap_escape_quotes(pool *p, const char *instr);} + +{ + * Redefine assert() to something more useful for an Apache... + } +{API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) + __attribute__((noreturn)); +#define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))} + +{ The optimized timeout code only works if we're not MULTITHREAD and we're + * also not using a scoreboard file + } +{#if !defined (MULTITHREAD) && \ + (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD)) +#define OPTIMIZE_TIMEOUTS +#endif} + +{ A set of flags which indicate places where the server should raise(SIGSTOP). + * This is useful for debugging, because you can then attach to that process + * with gdb and continue. This is important in cases where one_process + * debugging isn't possible. + } + SIGSTOP_DETACH = 1; + SIGSTOP_MAKE_CHILD = 2; + SIGSTOP_SPAWN_CHILD = 4; + SIGSTOP_PIPED_LOG_SPAWN = 8; + SIGSTOP_CGI_CHILD = 16; + +{#ifdef DEBUG_SIGSTOP +extern int raise_sigstop_flags; +#define RAISE_SIGSTOP(x) do begin + if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\ + end while (0) +#else +#define RAISE_SIGSTOP(x) +#endif + +API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r);} + + { strtoul does not exist on sunos4. } + +// strtoul = strtoul_is_not_a_portable_function_use_strtol_instead + +//#ifdef AP_ENABLE_EXCEPTION_HOOK +{ The exception hook allows a module to run from the server's signal + * handler, and perform tasks such as logging the current request or + * getting a backtrace or performing other diagnostic functions. All + * operating system requirements for running in a signal handler must + * be respected, or the process may not exit properly. + * + * AP_ENABLE_EXCEPTION_HOOK is already defined for platforms that have + * been tested. It likely will work on other platforms. In order to + * test, define AP_ENABLE_EXCEPTION_HOOK at configure time. + } +type + ap_exception_info_t = record + sig: cint; + pid: pid_t; + end; + +{ Register a function to be called after a fatal exception (on *X systems, a + * "synchronous signal" such as SIGSEGV, SIGILL, etc.). + * + * Returns 0 on success, non-zero on failure. + * If EnableExceptionHook directive is not set to "on", this function will + * report failure and no such hooks will be called. + } +//API_EXPORT(extern int) ap_add_fatal_exception_hook(void (*fn)(ap_exception_info_t *)); +//#endif { AP_ENABLE_EXCEPTION_HOOK } + diff --git a/httpd/httpd_1_3/httpd.pas b/httpd/httpd_1_3/httpd.pas new file mode 100644 index 000000000..6aceb29a5 --- /dev/null +++ b/httpd/httpd_1_3/httpd.pas @@ -0,0 +1,181 @@ +{ + httpd.pas + + Copyright (C) 2006 Felipe Monteiro de Carvalho + + This unit is a pascal binding for the Apache 1.3.37 headers. + The headers were released under the following copyright: +} +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + } +unit httpd; + +{$ifdef fpc} + {$mode delphi}{$H+} +{$endif} + +{$IFNDEF FPC} + {$DEFINE WINDOWS} +{$ENDIF} + +{$IFDEF WIN32} + {$DEFINE WINDOWS} +{$ENDIF} + +{$ifdef Unix} + {$PACKRECORDS C} +{$endif} + +interface + +uses +{$ifdef WINDOWS} + Windows, +{$ELSE} + UnixType, +{$ENDIF} + ctypes; + +const +{$ifndef fpc} + LineEnding = #13#10; +{$endif} + +{$IFDEF WINDOWS} + LibHTTPD = 'libhttpd.dll'; +{$ELSE} + LibHTTPD = ''; +{$ENDIF} + +{$define Apache1_3} + +{ Declarations moved here to be on top of all declarations } + +{ configuration vector structure } +type + ap_conf_vector_t = record end; + Pap_conf_vector_t = ^ap_conf_vector_t; + PPap_conf_vector_t = ^Pap_conf_vector_t; + +{ + Main httpd header files + + Note: There are more include files other then these, because some include files + include more files. +} + +{.$include ap_provider.inc} +{.$include util_cfgtree.inc} + +{$include httpd.inc} +{$include http_config.inc} +{$include http_core.inc} +{$include http_log.inc} +{$include http_main.inc} +{$include http_protocol.inc} +{$include http_request.inc} +{$include http_vhost.inc} + +{.$include util_script.inc} +{.$include util_time.inc} +{.$include util_md5.inc} +{.$include ap_mpm.inc} + +implementation + +{ + Macros transformed into functions in the translation +} + +{ from httpd.inc } + +{ Internal representation for a HTTP protocol number, e.g., HTTP/1.1 } +function HTTP_VERSION(major, minor: Integer): Integer; +begin + Result := (1000*(major)+(minor)); +end; + +{ Major part of HTTP protocol } +function HTTP_VERSION_MAJOR(number: Integer): Integer; +begin + Result := number div 1000; +end; + +{ Minor part of HTTP protocol } +function HTTP_VERSION_MINOR(number: Integer): Integer; +begin + Result := number mod 1000; +end; + +{function ap_escape_uri(p: Papr_pool_t; const path: PChar): PChar; +begin + Result := ap_os_escape_path(p, path, 1); +end;} + +{ from http_config.inc } + +{ Use this in all standard modules } + +procedure STANDARD_MODULE_STUFF(var mod_: module); +begin + mod_.version := MODULE_MAGIC_NUMBER_MAJOR; + mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR; + mod_.module_index := -1; +// mod_.name: PChar; + mod_.dynamic_load_handle := nil; + mod_.next := nil; + mod_.magic := MODULE_MAGIC_COOKIE; +end; + +//procedure STANDARD20_MODULE_STUFF(var mod_: module); +//begin +// mod_.version := MODULE_MAGIC_NUMBER_MAJOR; +// mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR; +// mod_.module_index := -1; +// mod_.name: PChar; +// mod_.dynamic_load_handle := nil; +// mod_.next := nil; +// mod_.magic := MODULE_MAGIC_COOKIE; +// mod_.rewrite_args := nil; +//end; + +{ Use this only in MPMs } +//procedure MPM20_MODULE_STUFF(var mod_: module); +//begin +// mod_.version := MODULE_MAGIC_NUMBER_MAJOR; +// mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR; +// mod_.module_index := -1; +// mod_.name: PChar; +// mod_.dynamic_load_handle := nil; +// mod_.next := nil; +// mod_.magic := MODULE_MAGIC_COOKIE; +//end; + +function ap_get_module_config(v: Pap_conf_vector_t; m: Pmodule): Pap_conf_vector_t; +begin + Result := Pointer(Integer(v) + m^.module_index); +end; + +procedure ap_set_module_config(v: Pap_conf_vector_t; m: Pmodule; val: Pap_conf_vector_t); +var + P: PPointer; +begin + P := PPointer(Integer(v) + m^.module_index); + P^ := val; +end; + +end. + diff --git a/httpd/httpd_2_0/apr/apr.pas b/httpd/httpd_2_0/apr/apr.pas index ea2be9f9c..41e10da6c 100644 --- a/httpd/httpd_2_0/apr/apr.pas +++ b/httpd/httpd_2_0/apr/apr.pas @@ -92,6 +92,8 @@ type apr_int64_t = Int64; apr_uint64_t = Int64; apr_socklen_t = Integer; + + apr_uint32_tso_handle_t = cuint; type {$IFDEF WINDOWS} @@ -102,8 +104,11 @@ type {$ENDIF} apr_int32_t = Integer; + Papr_int32_t = ^Integer; apr_size_t = size_t; Papr_size_t = ^apr_size_t; + apr_int16_t = SmallInt; + Papr_int16_t = ^SmallInt; va_list = Pointer; @@ -182,6 +187,7 @@ type {$include apr_thread_proc.inc} {$include apr_version.inc} +{$include apr_poll.inc} implementation diff --git a/httpd/httpd_2_0/apr/apr_poll.inc b/httpd/httpd_2_0/apr/apr_poll.inc new file mode 100644 index 000000000..8f4fbac4f --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_poll.inc @@ -0,0 +1,259 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + } + +{ + * @file apr_poll.h + * @brief APR Poll interface + } +{#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" +#include "apr_inherit.h" +#include "apr_file_io.h" +#include "apr_network_io.h" + +#if APR_HAVE_NETINET_IN_H +#include +#endif} + +{ + * @defgroup apr_poll Poll Routines + * @ingroup APR + } + +{ + * @defgroup apr_poll_opt Poll options + } +const + APR_POLLIN = $001; {< Can read without blocking } + APR_POLLPRI = $002; {< Priority data available } + APR_POLLOUT = $004; {< Can write without blocking } + APR_POLLERR = $010; {< Pending error } + APR_POLLHUP = $020; {< Hangup occurred } + APR_POLLNVAL = $040; {< Descriptior invalid } + +{ Used in apr_pollfd_t to determine what the apr_descriptor is } +type + apr_datatype_e = ( + APR_NO_DESC, {< nothing here } + APR_POLL_SOCKET, {< descriptor refers to a socket } + APR_POLL_FILE, {< descriptor refers to a file } + APR_POLL_LASTDESC {< descriptor is the last one in the list } + ); + +{ Union of either an APR file or socket. } + apr_descriptor = record + case Integer of + 1: (f: Papr_file_t); {< file } + 2: (s: Papr_socket_t); {< socket } + end; + +{ @see apr_pollfd_t } + Papr_pollfd_t = ^apr_pollfd_t; + + PPapr_pollfd_t = ^Papr_pollfd_t; + +{ Poll descriptor set. } + apr_pollfd_t = record + p: Papr_pool_t; {< associated pool } + desc_type: apr_datatype_e; {< descriptor type } + reqevents: apr_int16_t; {< requested events } + rtnevents: apr_int16_t; {< returned events } + desc: apr_descriptor; {< @see apr_descriptor } + client_data: Pointer; {< allows app to associate context } + end; + +{ + * Setup the memory required for poll to operate properly + * @param new_poll The poll structure to be used. + * @param num The number of socket descriptors to be polled. + * @param cont The pool to operate on. + * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + } +function apr_poll_setup(new_poll: PPapr_pollfd_t; num: apr_int32_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_poll_setup' + LibSuff12; + +{ + * Poll the sockets in the poll structure + * @param aprset The poll structure we will be using. + * @param numsock The number of sockets we are polling + * @param nsds The number of sockets signalled. + * @param timeout The amount of time in microseconds to wait. This is + * a maximum, not a minimum. If a socket is signalled, we + * will wake up before this time. A negative number means + * wait until a socket is signalled. + * @remark + *
+ * The number of sockets signalled is returned in the second argument. 
+ *
+ *        This is a blocking call, and it will not return until either a 
+ *        socket has been signalled, or the timeout has expired. 
+ * 
+ } +function apr_poll(aprset: Papr_pollfd_t; numsock: apr_int32_t; + nsds: Papr_int32_t; timeout: apr_interval_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_poll' + LibSuff16; + +{ + * Add a socket to the poll structure. + * @param aprset The poll structure we will be using. + * @param sock The socket to add to the current poll structure. + * @param event The events to look for when we do the poll. One of: + *
+ *            APR_POLLIN       signal if read will not block
+ *            APR_POLLPRI      signal if prioirty data is availble to be read
+ *            APR_POLLOUT      signal if write will not block
+ * 
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + } +function apr_poll_socket_add(aprset: Papr_pollfd_t; sock: Papr_socket_t; + event: apr_int16_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_poll_socket_add' + LibSuff12; + +{ + * Modify a socket in the poll structure with mask. + * @param aprset The poll structure we will be using. + * @param sock The socket to modify in poll structure. + * @param events The events to stop looking for during the poll. One of: + *
+ *            APR_POLLIN       signal if read will not block
+ *            APR_POLLPRI      signal if priority data is available to be read
+ *            APR_POLLOUT      signal if write will not block
+ * 
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + } +function apr_poll_socket_mask(aprset: Papr_pollfd_t; sock: Papr_socket_t; + events: apr_int16_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_poll_socket_mask' + LibSuff12; + +{ + * Remove a socket from the poll structure. + * @param aprset The poll structure we will be using. + * @param sock The socket to remove from the current poll structure. + * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + } +function apr_poll_socket_remove(aprset: Papr_pollfd_t; sock: Papr_socket_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_poll_socket_remove' + LibSuff8; + +{ + * Clear all events in the poll structure. + * @param aprset The poll structure we will be using. + * @param events The events to clear from all sockets. One of: + *
+ *            APR_POLLIN       signal if read will not block
+ *            APR_POLLPRI      signal if priority data is available to be read
+ *            APR_POLLOUT      signal if write will not block
+ * 
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + } +function apr_poll_socket_clear(aprset: Papr_pollfd_t; + events: apr_int16_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_poll_socket_clear' + LibSuff8; + +{ + * Get the return events for the specified socket. + * @param event The returned events for the socket. One of: + *
+ *            APR_POLLIN       Data is available to be read 
+ *            APR_POLLPRI      Priority data is availble to be read
+ *            APR_POLLOUT      Write will succeed
+ *            APR_POLLERR      An error occurred on the socket
+ *            APR_POLLHUP      The connection has been terminated
+ *            APR_POLLNVAL     This is an invalid socket to poll on.
+ *                             Socket not open.
+ * 
+ * @param sock The socket we wish to get information about. + * @param aprset The poll structure we will be using. + * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + } +function apr_poll_revents_get(event: Papr_int16_t; sock: Papr_socket_t; + aprset: Papr_pollfd_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_poll_revents_get' + LibSuff12; + +{ General-purpose poll API for arbitrarily large numbers of + * file descriptors + } + +{ Opaque structure used for pollset API } +type + apr_pollset_t = record end; + Papr_pollset_t = ^apr_pollset_t; + PPapr_pollset_t = ^Papr_pollset_t; + +{ + * Setup a pollset object + * @param pollset The pointer in which to return the newly created object + * @param size The maximum number of descriptors that this pollset can hold + * @param p The pool from which to allocate the pollset + * @param flags Optional flags to modify the operation of the pollset + * (reserved for future expansion) + } +function apr_pollset_create(pollset: PPapr_pollset_t; size: apr_uint32_tso_handle_t; + p: Papr_pool_t; flags: apr_uint32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pollset_create' + LibSuff16; + +{ + * Destroy a pollset object + * @param pollset The pollset to destroy + } +function apr_pollset_destroy(pollset: Papr_pollset_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pollset_destroy' + LibSuff4; + +{ + * Add a socket or file descriptor to a pollset + * @param pollset The pollset to which to add the descriptor + * @param descriptor The descriptor to add + * @remark If you set client_data in the descriptor, that value + * will be returned in the client_data field whenever this + * descriptor is signalled in apr_pollset_poll(). + } +function apr_pollset_add(pollset: Papr_pollset_t; + const descriptor: Papr_pollfd_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pollset_add' + LibSuff8; + +{ + * Remove a descriptor from a pollset + * @param pollset The pollset from which to remove the descriptor + * @param descriptor The descriptor to remove + } +function apr_pollset_remove(pollset: Papr_pollset_t; + const descriptor: Papr_pollfd_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pollset_remove' + LibSuff8; + +{ + * Block for activity on the descriptor(s) in a pollset + * @param pollset The pollset to use + * @param timeout Timeout in microseconds + * @param num Number of signalled descriptors (output parameter) + * @param descriptors Array of signalled descriptors (output parameter) + } +function apr_pollset_poll(pollset: Papr_pollset_t; timeout: apr_interval_time_t; + num: Papr_int32_t; const descriptors: PPapr_pollfd_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pollset_poll' + LibSuff16; + diff --git a/httpd/httpd_2_2/apr/apr.pas b/httpd/httpd_2_2/apr/apr.pas index 11efe0e09..ea2be9f9c 100644 --- a/httpd/httpd_2_2/apr/apr.pas +++ b/httpd/httpd_2_2/apr/apr.pas @@ -107,7 +107,44 @@ type va_list = Pointer; -// TEMPORARY + // Network structures + + sockaddr = record + sa_family: cushort; // address family, AF_xxx + sa_data: array [1..14] of Char; // (NBO) 14 bytes of protocol address + end; + + in_addr = record + s_addr: culong; // load with inet_aton() + end; + + sockaddr_in = record + sin_family: cshort; // e.g. AF_INET + sin_port: cushort; // e.g. htons(3490) + sin_addr: in_addr; // see struct in_addr, below + sin_zero: array [1..8] of Char; // zero this if you want to + end; + + in6_addr = record + Case Integer of + 1: (u6_addr8: array [1..16] of Byte); + 2: (u6_addr16: array [1..8] of Word); + 3: (u6_addr32: array [1..4] of Cardinal); + end; +//#define s6_addr in6_u.u6_addr8 +//#define s6_addr16 in6_u.u6_addr16 +//#define s6_addr32 in6_u.u6_addr32 + + sockaddr_in6 = record + sin6_family: cushort; + sin6_port: Word; + sin6_flowinfo: Cardinal; + sin6_addr: in6_addr; + sin6_scope_id: Cardinal; + end; + + // TEMPORARY + Papr_xml_ns_scope = Pointer; Pap_method_list_t = Pointer; diff --git a/httpd/httpd_2_2/apr/apr_network_io.inc b/httpd/httpd_2_2/apr/apr_network_io.inc index 67b114f4d..ea93d118a 100644 --- a/httpd/httpd_2_2/apr/apr_network_io.inc +++ b/httpd/httpd_2_2/apr/apr_network_io.inc @@ -104,10 +104,10 @@ const * We need to make sure we always have an in_addr type, so APR will just * define it ourselves, if the platform doesn't provide it. } -type +{type in_addr = record - s_addr: apr_uint32_t; {< storage to hold the IP# } - end; + s_addr: apr_uint32_t; < storage to hold the IP# + end;} {$endif} const diff --git a/httpd/httpd_2_2/http_log.inc b/httpd/httpd_2_2/http_log.inc index 84b0c637b..cd5ad905c 100644 --- a/httpd/httpd_2_2/http_log.inc +++ b/httpd/httpd_2_2/http_log.inc @@ -1,9 +1,9 @@ -{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -331,6 +331,18 @@ type level: Integer; status: apr_status_t; const s: Pserver_rec; const r: Prequest_rec; p: Papr_pool_t; const errstr: PChar); cdecl; +{ + * hook method to log error messages + * @ingroup hooks + * @param file The file in which this function is called + * @param line The line number on which this function is called + * @param level The level of this error message + * @param status The status code from the previous command + * @param s The server which we are logging for + * @param r The request which we are logging for + * @param pool Memory pool to allocate from + * @param errstr message to log + } procedure ap_hook_error_log(pf: ap_HOOK_error_log_t; const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} diff --git a/httpd/httpd_2_2/http_main.inc b/httpd/httpd_2_2/http_main.inc index 09eb23070..484f2a173 100644 --- a/httpd/httpd_2_2/http_main.inc +++ b/httpd/httpd_2_2/http_main.inc @@ -1,9 +1,9 @@ -{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. -} + } //#include "apr_optional.h" @@ -21,7 +21,7 @@ * can safely ignore and pass on from its rewrite_args() handler. } const - AP_SERVER_BASEARGS = 'C:c:D:d:E:e:f:vVlLtSh?X'; + AP_SERVER_BASEARGS = 'C:c:D:d:E:e:f:vVlLtSMh?X'; { * @package Command line options @@ -43,5 +43,12 @@ const * effect the server based on command line options } //AP_DECLARE_DATA extern apr_array_header_t *ap_server_config_defines; +{ + * An optional function to send signal to server on presence of '-k' + * command line argument. + * Called if MPM defines AP_MPM_WANT_SIGNAL_SERVER + * @param status The exit status after sending signal + * @param pool Memory pool to allocate from + } //APR_DECLARE_OPTIONAL_FN(int, ap_signal_server, (int *, apr_pool_t *)); diff --git a/httpd/httpd_2_2/http_protocol.inc b/httpd/httpd_2_2/http_protocol.inc index db310b0c2..8ab5a5f3c 100644 --- a/httpd/httpd_2_2/http_protocol.inc +++ b/httpd/httpd_2_2/http_protocol.inc @@ -1,9 +1,9 @@ -{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -294,26 +294,16 @@ function ap_make_method_list(p: Papr_pool_t; nelts: Integer): Pap_method_list_t; {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD name LibNamePrefix + 'ap_make_method_list' + LibSuff8; +{ + * Copy a method list + * + * @param dest List to copy to + * @param src List to copy from + } procedure ap_copy_method_list(dest, src: Pap_method_list_t); {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD name LibNamePrefix + 'ap_copy_method_list' + LibSuff8; -type - comp_t = procedure (urec: Pointer; const mname: PChar; mnum: Integer); - -procedure ap_method_list_do( - comp: comp_t; rec: Pointer; ml: Pap_method_list_t; others: array of const); - cdecl; external LibHTTPD name 'ap_method_list_do'; - -type - ap_method_list_vdo_t = function (urec: Pointer; const mname: PChar; - mnum: Integer): Integer; cdecl; - -procedure ap_method_list_vdo(comp: ap_method_list_vdo_t; - rec: Pointer; const ml: Pap_method_list_t; cp: va_list); - {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} - external LibHTTPD name LibNamePrefix + 'ap_method_list_vdo' + LibSuff16; - { * Search for an HTTP method name in an ap_method_list_t structure, and * return true if found. @@ -720,19 +710,18 @@ procedure ap_hook_log_transaction(pf: ap_HOOK_log_transaction_t; external LibHTTPD name LibNamePrefix + 'ap_hook_log_transaction' + LibSuff16; { - * This hook allows modules to retrieve the http method from a request. This - * allows Apache modules to easily extend the methods that Apache understands + * This hook allows modules to retrieve the http scheme for a request. This + * allows Apache modules to easily extend the scheme that Apache understands * @param r The current request * @return The http method from the request - * @deffunc const char *ap_run_http_method(const request_rec *r) } type ap_HOOK_http_method_t = function(const r: Prequest_rec): PChar; cdecl; -procedure ap_hook_http_method(pf: ap_HOOK_http_method_t; +procedure ap_hook_http_scheme(pf: ap_HOOK_http_method_t; const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} - external LibHTTPD name LibNamePrefix + 'ap_hook_http_method' + LibSuff16; + external LibHTTPD name LibNamePrefix + 'ap_hook_http_scheme' + LibSuff16; { * Return the default port from the current request @@ -816,13 +805,19 @@ function ap_old_write_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_statu cdecl; external LibHTTPD name 'ap_old_write_filter'; { - * Setting up the protocol fields for subsidiary requests... - * Also, a wrapup function to keep the internal accounting straight. + * Sett up the protocol fields for subsidiary requests + * @param rnew New Sub Request + * @param r current request } procedure ap_set_sub_req_protocol(rnew: Prequest_rec; const r: Prequest_rec); {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD name LibNamePrefix + 'ap_set_sub_req_protocol' + LibSuff8; +{ + * A wrapup function to keep the internal accounting straight. + * Indicates that there is no more content coming. + * @param sub_r Subrequest that is now compete + } procedure ap_finalize_sub_req_protocol(sub_r: Prequest_rec); {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD name LibNamePrefix + 'ap_finalize_sub_req_protocol' + LibSuff4; diff --git a/httpd/httpd_2_2/http_vhost.inc b/httpd/httpd_2_2/http_vhost.inc index 109032ed1..4b71ddc12 100644 --- a/httpd/httpd_2_2/http_vhost.inc +++ b/httpd/httpd_2_2/http_vhost.inc @@ -1,9 +1,9 @@ -{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -45,10 +45,41 @@ procedure ap_fini_vhost_config(p: Papr_pool_t; main_server: Pserver_rec); } //const char *ap_parse_vhost_addrs(apr_pool_t *p, const char *hostname, server_rec *s); -{ handle NameVirtualHost directive } +{ + * handle NameVirtualHost directive + * @param cmd Command Parameters structure + * @param dummy NOT USED + * @param arg a host of the form "
[:port]" + } //const char *ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, // const char *arg); +{ + * Callback function for every Name Based Virtual Host. + * @param baton Opaque user object + * @param conn The current Connection + * @param s The current Server + * @see ap_vhost_iterate_given_conn + * @return 0 on success, any non-zero return will stop the iteration. + } +type + ap_vhost_iterate_conn_cb = function (baton: Pointer; conn: Pconn_rec; s: Pserver_rec): Integer; + +{ + * For every virtual host on this connection, call func_cb. + * @param conn The current connection + * @param func_cb Function called for every Name Based Virtual Host for this + * connection. + * @param baton Opaque object passed to func_cb. + * @return The return value from func_cb. + * @note If func_cb returns non-zero, the function will return at this point, + * and not continue iterating the virtual hosts. + } +function ap_vhost_iterate_given_conn(conn: Pconn_rec; + func_cb: ap_vhost_iterate_conn_cb; baton: Pointer): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_vhost_iterate_given_conn' + LibSuff12; + { * given an ip address only, give our best guess as to what vhost it is * @param conn The current connection diff --git a/httpd/httpd_2_2/httpd.inc b/httpd/httpd_2_2/httpd.inc index 13b03bef5..a79d9ca80 100644 --- a/httpd/httpd_2_2/httpd.inc +++ b/httpd/httpd_2_2/httpd.inc @@ -953,9 +953,14 @@ type { * @brief A structure to contain connection state information } + APR_RING_ENTRY_conn_state_t = record + next: Pconn_state_t; + prev: Pconn_state_t; + end; + conn_state_t = record { APR_RING of expiration timeouts } - timeout_list: conn_state_t; // APR_RING_ENTRY(conn_state_t); + timeout_list: APR_RING_ENTRY_conn_state_t; { the expiration time of the next keepalive timeout } expiration_time: apr_time_t; { Current state of the connection } diff --git a/httpd/httpd_2_2/httpd.pas b/httpd/httpd_2_2/httpd.pas index acb94d47a..08dd9291e 100644 --- a/httpd/httpd_2_2/httpd.pas +++ b/httpd/httpd_2_2/httpd.pas @@ -6,12 +6,12 @@ This unit is a pascal binding for the Apache 2.0.58 headers. The headers were released under the following copyright: } -{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -20,7 +20,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. -} + } unit httpd; {$ifdef fpc} diff --git a/httpd/mod_hello.lpi b/httpd/mod_hello.lpi index e3ad180af..53cf6ec84 100644 --- a/httpd/mod_hello.lpi +++ b/httpd/mod_hello.lpi @@ -7,7 +7,7 @@ - + @@ -21,15 +21,15 @@ - + - - + + - + @@ -41,8 +41,8 @@ - - + + @@ -53,8 +53,8 @@ - - + + @@ -65,8 +65,8 @@ - - + + @@ -81,20 +81,22 @@ - + - - + + - - + + + + @@ -110,12 +112,364 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -124,8 +478,8 @@ - - + + diff --git a/httpd/mod_hello.lpr b/httpd/mod_hello.lpr index 1e3e1e55c..aa8bebbd7 100644 --- a/httpd/mod_hello.lpr +++ b/httpd/mod_hello.lpr @@ -7,13 +7,17 @@ library mod_hello; * The mode must be objfpc on this unit because the unix code uses * some extensions introduced on Free Pascal *******************************************************************} -{$mode objfpc}{$H+} +{$ifdef fpc} + {$mode objfpc}{$H+} +{$endif} {$IFDEF WIN32} {$DEFINE WINDOWS} {$ENDIF} -uses SysUtils, httpd, apr; +{$define Apache2_2} + +uses SysUtils, httpd {$ifndef Apache1_3}, apr{$endif}; var test_module: module; {$ifdef Unix} public name 'test_module'; {$endif} @@ -47,12 +51,18 @@ begin end; { The following line just prints a message to the errorlog } - ap_log_error(MODULE_NAME, 54, APLOG_NOERRNO or APLOG_NOTICE, 0, r^.server, + ap_log_error(MODULE_NAME, 54, APLOG_NOERRNO or APLOG_NOTICE, + {$ifndef Apache1_3}0,{$endif} r^.server, 'mod_hello: %s', [PChar('Before content is output')]); { We set the content type before doing anything else } - ap_set_content_type(r, 'text/html'); - + {$ifdef Apache1_3} + r^.content_type := 'text/html'; +// ap_send_http_header(r); + {$else} + ap_set_content_type(r, 'text/html'); + {$endif} + { If the request is for a header only, and not a request for the whole content, then return OK now. We don't have to do anything else. } @@ -72,7 +82,7 @@ begin ap_rputs('' + LineEnding ,r); ap_rputs('

Hello world

' + LineEnding, r); ap_rputs('This is the first Apache Module working with the new binding from Free Pascal' + LineEnding, r); - ap_rprintf(r, '
A sample line generated by ap_rprintf
' + LineEnding, []); +// ap_rprintf(r, '
A sample line generated by ap_rprintf
' + LineEnding, []); ap_rputs('' + LineEnding, r); { We can either return OK or DECLINED at this point. If we return @@ -83,25 +93,51 @@ end; {******************************************************************* * Registers the hooks *******************************************************************} +{$ifdef apache1_3} + +procedure hw_init(s: PServer_rec; p: PPool); cdecl; +begin +end; + +var + hw_handlers: array[0..0] of handler_rec = + ( + (content_type: 'hw_app'; handler: @DefaultHandler) + ); + +{$else} + procedure RegisterHooks(p: Papr_pool_t); cdecl; begin ap_hook_handler(@DefaultHandler, nil, nil, APR_HOOK_MIDDLE); end; +{$endif} + {******************************************************************* * Library initialization code *******************************************************************} begin default_module_ptr := @test_module; FillChar(default_module_ptr^, SizeOf(default_module_ptr^), 0); - with test_module do - begin - version := MODULE_MAGIC_NUMBER_MAJOR; - minor_version := MODULE_MAGIC_NUMBER_MINOR; - module_index := -1; - name := MODULE_NAME; - magic := MODULE_MAGIC_COOKIE; - register_hooks := @RegisterHooks; - end; + + {$ifdef apache1_3} + STANDARD_MODULE_STUFF(test_module); + + with test_module do + begin + name := MODULE_NAME; + init := @hw_init; + handlers := hw_handlers; + end; + {$else} + STANDARD20_MODULE_STUFF(test_module); + + with test_module do + begin + name := MODULE_NAME; + register_hooks := @RegisterHooks; + end; + {$endif} end.