diff options
| author | marco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2008-01-27 17:22:29 +0000 |
|---|---|---|
| committer | marco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2008-01-27 17:22:29 +0000 |
| commit | 2dca422f73c58c9d88d62a683ad7c1591075e824 (patch) | |
| tree | 2c9571b81730cddf52948ea09d6083b2f7538a5c /packages/httpd13 | |
| parent | 226d13329bcd208710440d32aac668d0b1183988 (diff) | |
| download | fpc-2dca422f73c58c9d88d62a683ad7c1591075e824.tar.gz | |
* httpd moved, splitted, decapitated and rejoined
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@10061 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/httpd13')
| -rw-r--r-- | packages/httpd13/Makefile | 2286 | ||||
| -rw-r--r-- | packages/httpd13/Makefile.fpc | 26 | ||||
| -rw-r--r-- | packages/httpd13/fpmake.pp | 48 | ||||
| -rw-r--r-- | packages/httpd13/src/ap.inc | 175 | ||||
| -rw-r--r-- | packages/httpd13/src/ap_alloc.inc | 451 | ||||
| -rw-r--r-- | packages/httpd13/src/ap_config.inc | 1496 | ||||
| -rw-r--r-- | packages/httpd13/src/ap_mmn.inc | 237 | ||||
| -rw-r--r-- | packages/httpd13/src/buff.inc | 234 | ||||
| -rw-r--r-- | packages/httpd13/src/hsregex.inc | 99 | ||||
| -rw-r--r-- | packages/httpd13/src/http_config.inc | 402 | ||||
| -rw-r--r-- | packages/httpd13/src/http_core.inc | 422 | ||||
| -rw-r--r-- | packages/httpd13/src/http_log.inc | 126 | ||||
| -rw-r--r-- | packages/httpd13/src/http_main.inc | 160 | ||||
| -rw-r--r-- | packages/httpd13/src/http_protocol.inc | 239 | ||||
| -rw-r--r-- | packages/httpd13/src/http_request.inc | 82 | ||||
| -rw-r--r-- | packages/httpd13/src/http_vhost.inc | 49 | ||||
| -rw-r--r-- | packages/httpd13/src/httpd.inc | 1267 | ||||
| -rw-r--r-- | packages/httpd13/src/httpd.pas | 178 | ||||
| -rw-r--r-- | packages/httpd13/src/readdir.inc | 77 | ||||
| -rw-r--r-- | packages/httpd13/src/util_uri.inc | 84 | ||||
| -rw-r--r-- | packages/httpd13/src/win32_os.inc | 191 |
21 files changed, 8329 insertions, 0 deletions
diff --git a/packages/httpd13/Makefile b/packages/httpd13/Makefile new file mode 100644 index 0000000000..f20d5c595b --- /dev/null +++ b/packages/httpd13/Makefile @@ -0,0 +1,2286 @@ +# +# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/01/26] +# +default: all +MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded +BSDs = freebsd netbsd openbsd darwin +UNIXs = linux $(BSDs) solaris qnx +LIMIT83fs = go32v2 os2 emx watcom +OSNeedsComspecToRunBatch = go32v2 watcom +FORCE: +.PHONY: FORCE +override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH))) +ifneq ($(findstring darwin,$(OSTYPE)),) +inUnix=1 #darwin +SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH))) +else +ifeq ($(findstring ;,$(PATH)),) +inUnix=1 +SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH))) +else +SEARCHPATH:=$(subst ;, ,$(PATH)) +endif +endif +SEARCHPATH+=$(patsubst %/,%,$(subst \,/,$(dir $(MAKE)))) +PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH)))) +ifeq ($(PWD),) +PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH)))) +ifeq ($(PWD),) +$(error You need the GNU utils package to use this Makefile) +else +PWD:=$(firstword $(PWD)) +SRCEXEEXT= +endif +else +PWD:=$(firstword $(PWD)) +SRCEXEEXT=.exe +endif +ifndef inUnix +ifeq ($(OS),Windows_NT) +inWinNT=1 +else +ifdef OS2_SHELL +inOS2=1 +endif +endif +else +ifneq ($(findstring cygdrive,$(PATH)),) +inCygWin=1 +endif +endif +ifdef inUnix +SRCBATCHEXT=.sh +else +ifdef inOS2 +SRCBATCHEXT=.cmd +else +SRCBATCHEXT=.bat +endif +endif +ifdef COMSPEC +ifneq ($(findstring $(OS_SOURCE),$(OSNeedsComspecToRunBatch)),) +RUNBATCH=$(COMSPEC) /C +endif +endif +ifdef inUnix +PATHSEP=/ +else +PATHSEP:=$(subst /,\,/) +ifdef inCygWin +PATHSEP=/ +endif +endif +ifdef PWD +BASEDIR:=$(subst \,/,$(shell $(PWD))) +ifdef inCygWin +ifneq ($(findstring /cygdrive/,$(BASEDIR)),) +BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR)) +BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR))) +BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR)) +endif +endif +else +BASEDIR=. +endif +ifdef inOS2 +ifndef ECHO +ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO=echo +else +ECHO:=$(firstword $(ECHO)) +endif +else +ECHO:=$(firstword $(ECHO)) +endif +endif +export ECHO +endif +override DEFAULT_FPCDIR=../.. +ifndef FPC +ifdef PP +FPC=$(PP) +endif +endif +ifndef FPC +FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH)))) +ifneq ($(FPCPROG),) +FPCPROG:=$(firstword $(FPCPROG)) +ifneq ($(CPU_TARGET),) +FPC:=$(shell $(FPCPROG) -P$(CPU_TARGET) -PB) +else +FPC:=$(shell $(FPCPROG) -PB) +endif +ifneq ($(findstring Error,$(FPC)),) +override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH))))) +endif +else +override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH))))) +endif +endif +override FPC:=$(subst $(SRCEXEEXT),,$(FPC)) +override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT) +FOUNDFPC:=$(strip $(wildcard $(FPC))) +ifeq ($(FOUNDFPC),) +FOUNDFPC=$(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))) +ifeq ($(FOUNDFPC),) +$(error Compiler $(FPC) not found) +endif +endif +ifndef FPC_COMPILERINFO +FPC_COMPILERINFO:=$(shell $(FPC) -iVSPTPSOTO) +endif +ifndef FPC_VERSION +FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO)) +endif +export FPC FPC_VERSION FPC_COMPILERINFO +unexport CHECKDEPEND ALLDEPENDENCIES +ifndef CPU_TARGET +ifdef CPU_TARGET_DEFAULT +CPU_TARGET=$(CPU_TARGET_DEFAULT) +endif +endif +ifndef OS_TARGET +ifdef OS_TARGET_DEFAULT +OS_TARGET=$(OS_TARGET_DEFAULT) +endif +endif +ifneq ($(words $(FPC_COMPILERINFO)),5) +FPC_COMPILERINFO+=$(shell $(FPC) -iSP) +FPC_COMPILERINFO+=$(shell $(FPC) -iTP) +FPC_COMPILERINFO+=$(shell $(FPC) -iSO) +FPC_COMPILERINFO+=$(shell $(FPC) -iTO) +endif +ifndef CPU_SOURCE +CPU_SOURCE:=$(word 2,$(FPC_COMPILERINFO)) +endif +ifndef CPU_TARGET +CPU_TARGET:=$(word 3,$(FPC_COMPILERINFO)) +endif +ifndef OS_SOURCE +OS_SOURCE:=$(word 4,$(FPC_COMPILERINFO)) +endif +ifndef OS_TARGET +OS_TARGET:=$(word 5,$(FPC_COMPILERINFO)) +endif +FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET) +FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE) +ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),) +TARGETSUFFIX=$(OS_TARGET) +SOURCESUFFIX=$(OS_SOURCE) +else +TARGETSUFFIX=$(FULL_TARGET) +SOURCESUFFIX=$(FULL_SOURCE) +endif +ifneq ($(FULL_TARGET),$(FULL_SOURCE)) +CROSSCOMPILE=1 +endif +ifeq ($(findstring makefile,$(MAKECMDGOALS)),) +ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),) +$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first) +endif +endif +ifneq ($(findstring $(OS_TARGET),$(BSDs)),) +BSDhier=1 +endif +ifeq ($(OS_TARGET),linux) +linuxHier=1 +endif +export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE +ifdef FPCDIR +override FPCDIR:=$(subst \,/,$(FPCDIR)) +ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),) +override FPCDIR=wrong +endif +else +override FPCDIR=wrong +endif +ifdef DEFAULT_FPCDIR +ifeq ($(FPCDIR),wrong) +override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR)) +ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),) +override FPCDIR=wrong +endif +endif +endif +ifeq ($(FPCDIR),wrong) +ifdef inUnix +override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) +endif +else +override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))))) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),) +override FPCDIR:=$(BASEDIR) +ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),) +override FPCDIR=c:/pp +endif +endif +endif +endif +endif +ifndef CROSSBINDIR +CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX)) +endif +ifndef BINUTILSPREFIX +ifndef CROSSBINDIR +ifdef CROSSCOMPILE +BINUTILSPREFIX=$(CPU_TARGET)-$(OS_TARGET)- +endif +endif +endif +UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX)) +ifeq ($(UNITSDIR),) +UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET)) +endif +PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra) +override PACKAGE_NAME=httpd13 +override PACKAGE_VERSION=2.2.0 +ifeq ($(FULL_TARGET),i386-linux) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-go32v2) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-win32) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-os2) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-freebsd) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-beos) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-netbsd) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-solaris) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-qnx) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-netware) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-openbsd) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-wdosx) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-darwin) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-emx) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-watcom) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-netwlibc) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-wince) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-embedded) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),i386-symbian) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),m68k-linux) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),m68k-freebsd) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),m68k-netbsd) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),m68k-amiga) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),m68k-atari) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),m68k-openbsd) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),m68k-palmos) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),m68k-embedded) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),powerpc-linux) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),powerpc-netbsd) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),powerpc-amiga) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),powerpc-macos) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),powerpc-darwin) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),powerpc-morphos) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),powerpc-embedded) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),sparc-linux) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),sparc-netbsd) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),sparc-solaris) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),sparc-embedded) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),x86_64-linux) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),x86_64-freebsd) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),x86_64-darwin) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),x86_64-win64) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),x86_64-embedded) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),arm-linux) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),arm-palmos) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),arm-wince) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),arm-gba) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),arm-nds) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),arm-embedded) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),arm-symbian) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),powerpc64-linux) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),powerpc64-darwin) +override TARGET_UNITS+=httpd +endif +ifeq ($(FULL_TARGET),powerpc64-embedded) +override TARGET_UNITS+=httpd +endif +override INSTALL_FPCPACKAGE=y +ifeq ($(FULL_TARGET),i386-linux) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-go32v2) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-win32) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-os2) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-freebsd) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-beos) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-netbsd) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-solaris) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-qnx) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-netware) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-openbsd) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-wdosx) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-darwin) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-emx) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-watcom) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-netwlibc) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-wince) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-embedded) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-symbian) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),m68k-linux) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),m68k-freebsd) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),m68k-netbsd) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),m68k-amiga) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),m68k-atari) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),m68k-openbsd) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),m68k-palmos) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),m68k-embedded) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),powerpc-linux) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),powerpc-netbsd) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),powerpc-amiga) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),powerpc-macos) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),powerpc-darwin) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),powerpc-morphos) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),powerpc-embedded) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),sparc-linux) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),sparc-netbsd) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),sparc-solaris) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),sparc-embedded) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),x86_64-linux) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),x86_64-freebsd) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),x86_64-darwin) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),x86_64-win64) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),x86_64-embedded) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),arm-linux) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),arm-palmos) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),arm-wince) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),arm-gba) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),arm-nds) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),arm-embedded) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),arm-symbian) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),powerpc64-linux) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),powerpc64-darwin) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),powerpc64-embedded) +override COMPILER_INCLUDEDIR+=src +endif +ifeq ($(FULL_TARGET),i386-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-go32v2) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-win32) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-os2) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-freebsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-beos) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-netbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-solaris) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-qnx) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-netware) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-openbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-wdosx) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-darwin) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-emx) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-watcom) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-netwlibc) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-wince) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-symbian) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-freebsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-netbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-amiga) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-atari) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-openbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-palmos) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-netbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-amiga) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-macos) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-darwin) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-morphos) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),sparc-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),sparc-netbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),sparc-solaris) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),sparc-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),x86_64-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),x86_64-freebsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),x86_64-darwin) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),x86_64-win64) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),x86_64-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-palmos) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-wince) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-gba) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-nds) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-symbian) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc64-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc64-darwin) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc64-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifdef REQUIRE_UNITSDIR +override UNITSDIR+=$(REQUIRE_UNITSDIR) +endif +ifdef REQUIRE_PACKAGESDIR +override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR) +endif +ifdef ZIPINSTALL +ifneq ($(findstring $(OS_TARGET),$(UNIXs)),) +UNIXHier=1 +endif +else +ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),) +UNIXHier=1 +endif +endif +ifndef INSTALL_PREFIX +ifdef PREFIX +INSTALL_PREFIX=$(PREFIX) +endif +endif +ifndef INSTALL_PREFIX +ifdef UNIXHier +INSTALL_PREFIX=/usr/local +else +ifdef INSTALL_FPCPACKAGE +INSTALL_BASEDIR:=/pp +else +INSTALL_BASEDIR:=/$(PACKAGE_NAME) +endif +endif +endif +export INSTALL_PREFIX +ifdef INSTALL_FPCSUBDIR +export INSTALL_FPCSUBDIR +endif +ifndef DIST_DESTDIR +DIST_DESTDIR:=$(BASEDIR) +endif +export DIST_DESTDIR +ifndef COMPILER_UNITTARGETDIR +ifdef PACKAGEDIR_MAIN +COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX) +else +COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX) +endif +endif +ifndef COMPILER_TARGETDIR +COMPILER_TARGETDIR=. +endif +ifndef INSTALL_BASEDIR +ifdef UNIXHier +ifdef INSTALL_FPCPACKAGE +INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION) +else +INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME) +endif +else +INSTALL_BASEDIR:=$(INSTALL_PREFIX) +endif +endif +ifndef INSTALL_BINDIR +ifdef UNIXHier +INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin +else +INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin +ifdef INSTALL_FPCPACKAGE +ifdef CROSSCOMPILE +ifdef CROSSINSTALL +INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(SOURCESUFFIX) +else +INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX) +endif +else +INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX) +endif +endif +endif +endif +ifndef INSTALL_UNITDIR +INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX) +ifdef INSTALL_FPCPACKAGE +ifdef PACKAGE_NAME +INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME) +endif +endif +endif +ifndef INSTALL_LIBDIR +ifdef UNIXHier +INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib +else +INSTALL_LIBDIR:=$(INSTALL_UNITDIR) +endif +endif +ifndef INSTALL_SOURCEDIR +ifdef UNIXHier +ifdef BSDhier +SRCPREFIXDIR=share/src +else +ifdef linuxHier +SRCPREFIXDIR=share/src +else +SRCPREFIXDIR=src +endif +endif +ifdef INSTALL_FPCPACKAGE +ifdef INSTALL_FPCSUBDIR +INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME) +else +INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME) +endif +else +INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION) +endif +else +ifdef INSTALL_FPCPACKAGE +ifdef INSTALL_FPCSUBDIR +INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME) +else +INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME) +endif +else +INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source +endif +endif +endif +ifndef INSTALL_DOCDIR +ifdef UNIXHier +ifdef BSDhier +DOCPREFIXDIR=share/doc +else +ifdef linuxHier +DOCPREFIXDIR=share/doc +else +DOCPREFIXDIR=doc +endif +endif +ifdef INSTALL_FPCPACKAGE +INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME) +else +INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION) +endif +else +ifdef INSTALL_FPCPACKAGE +INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME) +else +INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc +endif +endif +endif +ifndef INSTALL_EXAMPLEDIR +ifdef UNIXHier +ifdef INSTALL_FPCPACKAGE +ifdef BSDhier +INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME) +else +ifdef linuxHier +INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples +else +INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME) +endif +endif +else +ifdef BSDhier +INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION) +else +ifdef linuxHier +INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION) +else +INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION) +endif +endif +endif +else +ifdef INSTALL_FPCPACKAGE +INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME) +else +INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples +endif +endif +endif +ifndef INSTALL_DATADIR +INSTALL_DATADIR=$(INSTALL_BASEDIR) +endif +ifndef INSTALL_SHAREDDIR +INSTALL_SHAREDDIR=$(INSTALL_PREFIX)/lib +endif +ifdef CROSSCOMPILE +ifndef CROSSBINDIR +CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(SOURCESUFFIX)) +ifeq ($(CROSSBINDIR),) +CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(TARGETSUFFIX)/bin/$(FULL_SOURCE)) +endif +endif +else +CROSSBINDIR= +endif +ifeq ($(OS_SOURCE),linux) +ifndef GCCLIBDIR +ifeq ($(CPU_TARGET),i386) +ifneq ($(findstring x86_64,$(shell uname -a)),) +ifeq ($(BINUTILSPREFIX),) +GCCLIBDIR:=$(shell dirname `gcc -m32 -print-libgcc-file-name`) +endif +endif +endif +ifeq ($(CPU_TARGET),powerpc64) +ifeq ($(BINUTILSPREFIX),) +GCCLIBDIR:=$(shell dirname `gcc -m64 -print-libgcc-file-name`) +endif +endif +endif +ifndef GCCLIBDIR +CROSSGCC=$(strip $(wildcard $(addsuffix /$(BINUTILSPREFIX)gcc$(SRCEXEEXT),$(SEARCHPATH)))) +ifneq ($(CROSSGCC),) +GCCLIBDIR:=$(shell dirname `$(CROSSGCC) -print-libgcc-file-name`) +endif +endif +ifndef OTHERLIBDIR +OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }') +endif +endif +ifdef inUnix +ifeq ($(OS_SOURCE),netbsd) +OTHERLIBDIR+=/usr/pkg/lib +endif +export GCCLIBDIR OTHERLIB +endif +BATCHEXT=.bat +LOADEREXT=.as +EXEEXT=.exe +PPLEXT=.ppl +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.so +SHAREDLIBPREFIX=libfp +STATICLIBPREFIX=libp +IMPORTLIBPREFIX=libimp +RSTEXT=.rst +ifeq ($(findstring 1.0.,$(FPC_VERSION)),) +ifeq ($(OS_TARGET),go32v1) +STATICLIBPREFIX= +SHORTSUFFIX=v1 +endif +ifeq ($(OS_TARGET),go32v2) +STATICLIBPREFIX= +SHORTSUFFIX=dos +endif +ifeq ($(OS_TARGET),watcom) +STATICLIBPREFIX= +OEXT=.obj +ASMEXT=.asm +SHAREDLIBEXT=.dll +SHORTSUFFIX=wat +endif +ifeq ($(OS_TARGET),linux) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=lnx +endif +ifeq ($(OS_TARGET),freebsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=fbs +endif +ifeq ($(OS_TARGET),netbsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=nbs +endif +ifeq ($(OS_TARGET),openbsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=obs +endif +ifeq ($(OS_TARGET),win32) +SHAREDLIBEXT=.dll +SHORTSUFFIX=w32 +endif +ifeq ($(OS_TARGET),os2) +BATCHEXT=.cmd +AOUTEXT=.out +STATICLIBPREFIX= +SHAREDLIBEXT=.dll +SHORTSUFFIX=os2 +ECHO=echo +endif +ifeq ($(OS_TARGET),emx) +BATCHEXT=.cmd +AOUTEXT=.out +STATICLIBPREFIX= +SHAREDLIBEXT=.dll +SHORTSUFFIX=emx +ECHO=echo +endif +ifeq ($(OS_TARGET),amiga) +EXEEXT= +SHAREDLIBEXT=.library +SHORTSUFFIX=amg +endif +ifeq ($(OS_TARGET),morphos) +EXEEXT= +SHAREDLIBEXT=.library +SHORTSUFFIX=mos +endif +ifeq ($(OS_TARGET),atari) +EXEEXT=.ttp +SHORTSUFFIX=ata +endif +ifeq ($(OS_TARGET),beos) +BATCHEXT=.sh +EXEEXT= +SHORTSUFFIX=be +endif +ifeq ($(OS_TARGET),solaris) +BATCHEXT=.sh +EXEEXT= +SHORTSUFFIX=sun +endif +ifeq ($(OS_TARGET),qnx) +BATCHEXT=.sh +EXEEXT= +SHORTSUFFIX=qnx +endif +ifeq ($(OS_TARGET),netware) +EXEEXT=.nlm +STATICLIBPREFIX= +SHORTSUFFIX=nw +endif +ifeq ($(OS_TARGET),netwlibc) +EXEEXT=.nlm +STATICLIBPREFIX= +SHORTSUFFIX=nwl +endif +ifeq ($(OS_TARGET),macos) +BATCHEXT= +EXEEXT= +DEBUGSYMEXT=.xcoff +SHORTSUFFIX=mac +endif +ifeq ($(OS_TARGET),darwin) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=dwn +endif +ifeq ($(OS_TARGET),gba) +EXEEXT=.gba +SHAREDLIBEXT=.so +SHORTSUFFIX=gba +endif +ifeq ($(OS_TARGET),symbian) +SHAREDLIBEXT=.dll +SHORTSUFFIX=symbian +endif +else +ifeq ($(OS_TARGET),go32v1) +PPUEXT=.pp1 +OEXT=.o1 +ASMEXT=.s1 +SMARTEXT=.sl1 +STATICLIBEXT=.a1 +SHAREDLIBEXT=.so1 +STATICLIBPREFIX= +SHORTSUFFIX=v1 +endif +ifeq ($(OS_TARGET),go32v2) +STATICLIBPREFIX= +SHORTSUFFIX=dos +endif +ifeq ($(OS_TARGET),watcom) +STATICLIBPREFIX= +SHORTSUFFIX=wat +endif +ifeq ($(OS_TARGET),linux) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=lnx +endif +ifeq ($(OS_TARGET),freebsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=fbs +endif +ifeq ($(OS_TARGET),netbsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=nbs +endif +ifeq ($(OS_TARGET),openbsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=obs +endif +ifeq ($(OS_TARGET),win32) +PPUEXT=.ppw +OEXT=.ow +ASMEXT=.sw +SMARTEXT=.slw +STATICLIBEXT=.aw +SHAREDLIBEXT=.dll +SHORTSUFFIX=w32 +endif +ifeq ($(OS_TARGET),os2) +BATCHEXT=.cmd +PPUEXT=.ppo +ASMEXT=.so2 +OEXT=.oo2 +AOUTEXT=.out +SMARTEXT=.sl2 +STATICLIBPREFIX= +STATICLIBEXT=.ao2 +SHAREDLIBEXT=.dll +SHORTSUFFIX=os2 +ECHO=echo +endif +ifeq ($(OS_TARGET),amiga) +EXEEXT= +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.library +SHORTSUFFIX=amg +endif +ifeq ($(OS_TARGET),atari) +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +EXEEXT=.ttp +SHORTSUFFIX=ata +endif +ifeq ($(OS_TARGET),beos) +BATCHEXT=.sh +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +EXEEXT= +SHORTSUFFIX=be +endif +ifeq ($(OS_TARGET),solaris) +BATCHEXT=.sh +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +EXEEXT= +SHORTSUFFIX=sun +endif +ifeq ($(OS_TARGET),qnx) +BATCHEXT=.sh +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +EXEEXT= +SHORTSUFFIX=qnx +endif +ifeq ($(OS_TARGET),netware) +STATICLIBPREFIX= +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.nlm +EXEEXT=.nlm +SHORTSUFFIX=nw +endif +ifeq ($(OS_TARGET),netwlibc) +STATICLIBPREFIX= +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.nlm +EXEEXT=.nlm +SHORTSUFFIX=nwl +endif +ifeq ($(OS_TARGET),macos) +BATCHEXT= +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +EXEEXT= +DEBUGSYMEXT=.xcoff +SHORTSUFFIX=mac +endif +endif +ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),) +FPCMADE=fpcmade.$(SHORTSUFFIX) +ZIPSUFFIX=$(SHORTSUFFIX) +ZIPCROSSPREFIX= +ZIPSOURCESUFFIX=src +ZIPEXAMPLESUFFIX=exm +else +FPCMADE=fpcmade.$(TARGETSUFFIX) +ZIPSOURCESUFFIX=.source +ZIPEXAMPLESUFFIX=.examples +ifdef CROSSCOMPILE +ZIPSUFFIX=.$(SOURCESUFFIX) +ZIPCROSSPREFIX=$(TARGETSUFFIX)- +else +ZIPSUFFIX=.$(TARGETSUFFIX) +ZIPCROSSPREFIX= +endif +endif +ifndef ECHO +ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO= __missing_command_ECHO +else +ECHO:=$(firstword $(ECHO)) +endif +else +ECHO:=$(firstword $(ECHO)) +endif +endif +export ECHO +ifndef DATE +DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(DATE),) +DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(DATE),) +DATE= __missing_command_DATE +else +DATE:=$(firstword $(DATE)) +endif +else +DATE:=$(firstword $(DATE)) +endif +endif +export DATE +ifndef GINSTALL +GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(GINSTALL),) +GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(GINSTALL),) +GINSTALL= __missing_command_GINSTALL +else +GINSTALL:=$(firstword $(GINSTALL)) +endif +else +GINSTALL:=$(firstword $(GINSTALL)) +endif +endif +export GINSTALL +ifndef CPPROG +CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(CPPROG),) +CPPROG= __missing_command_CPPROG +else +CPPROG:=$(firstword $(CPPROG)) +endif +endif +export CPPROG +ifndef RMPROG +RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(RMPROG),) +RMPROG= __missing_command_RMPROG +else +RMPROG:=$(firstword $(RMPROG)) +endif +endif +export RMPROG +ifndef MVPROG +MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(MVPROG),) +MVPROG= __missing_command_MVPROG +else +MVPROG:=$(firstword $(MVPROG)) +endif +endif +export MVPROG +ifndef MKDIRPROG +MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(MKDIRPROG),) +MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(MKDIRPROG),) +MKDIRPROG= __missing_command_MKDIRPROG +else +MKDIRPROG:=$(firstword $(MKDIRPROG)) +endif +else +MKDIRPROG:=$(firstword $(MKDIRPROG)) +endif +endif +export MKDIRPROG +ifndef ECHOREDIR +ifndef inUnix +ECHOREDIR=echo +else +ECHOREDIR=$(ECHO) +endif +endif +ifndef COPY +COPY:=$(CPPROG) -fp +endif +ifndef COPYTREE +COPYTREE:=$(CPPROG) -Rfp +endif +ifndef MKDIRTREE +MKDIRTREE:=$(MKDIRPROG) -p +endif +ifndef MOVE +MOVE:=$(MVPROG) -f +endif +ifndef DEL +DEL:=$(RMPROG) -f +endif +ifndef DELTREE +DELTREE:=$(RMPROG) -rf +endif +ifndef INSTALL +ifdef inUnix +INSTALL:=$(GINSTALL) -c -m 644 +else +INSTALL:=$(COPY) +endif +endif +ifndef INSTALLEXE +ifdef inUnix +INSTALLEXE:=$(GINSTALL) -c -m 755 +else +INSTALLEXE:=$(COPY) +endif +endif +ifndef MKDIR +MKDIR:=$(GINSTALL) -m 755 -d +endif +export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR +ifndef PPUMOVE +PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUMOVE),) +PPUMOVE= __missing_command_PPUMOVE +else +PPUMOVE:=$(firstword $(PPUMOVE)) +endif +endif +export PPUMOVE +ifndef FPCMAKE +FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(FPCMAKE),) +FPCMAKE= __missing_command_FPCMAKE +else +FPCMAKE:=$(firstword $(FPCMAKE)) +endif +endif +export FPCMAKE +ifndef ZIPPROG +ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ZIPPROG),) +ZIPPROG= __missing_command_ZIPPROG +else +ZIPPROG:=$(firstword $(ZIPPROG)) +endif +endif +export ZIPPROG +ifndef TARPROG +TARPROG:=$(strip $(wildcard $(addsuffix /gtar$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(TARPROG),) +TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(TARPROG),) +TARPROG= __missing_command_TARPROG +else +TARPROG:=$(firstword $(TARPROG)) +endif +else +TARPROG:=$(firstword $(TARPROG)) +endif +endif +export TARPROG +ASNAME=$(BINUTILSPREFIX)as +LDNAME=$(BINUTILSPREFIX)ld +ARNAME=$(BINUTILSPREFIX)ar +RCNAME=$(BINUTILSPREFIX)rc +ifneq ($(findstring 1.0.,$(FPC_VERSION)),) +ifeq ($(OS_TARGET),win32) +ifeq ($(CROSSBINDIR),) +ASNAME=asw +LDNAME=ldw +ARNAME=arw +endif +endif +endif +ifndef ASPROG +ifdef CROSSBINDIR +ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT) +else +ASPROG=$(ASNAME) +endif +endif +ifndef LDPROG +ifdef CROSSBINDIR +LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT) +else +LDPROG=$(LDNAME) +endif +endif +ifndef RCPROG +ifdef CROSSBINDIR +RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT) +else +RCPROG=$(RCNAME) +endif +endif +ifndef ARPROG +ifdef CROSSBINDIR +ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT) +else +ARPROG=$(ARNAME) +endif +endif +AS=$(ASPROG) +LD=$(LDPROG) +RC=$(RCPROG) +AR=$(ARPROG) +PPAS=ppas$(SRCBATCHEXT) +ifdef inUnix +LDCONFIG=ldconfig +else +LDCONFIG= +endif +ifdef DATE +DATESTR:=$(shell $(DATE) +%Y%m%d) +else +DATESTR= +endif +ifndef UPXPROG +ifeq ($(OS_TARGET),go32v2) +UPXPROG:=1 +endif +ifeq ($(OS_TARGET),win32) +UPXPROG:=1 +endif +ifdef UPXPROG +UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(UPXPROG),) +UPXPROG= +else +UPXPROG:=$(firstword $(UPXPROG)) +endif +else +UPXPROG= +endif +endif +export UPXPROG +ZIPOPT=-9 +ZIPEXT=.zip +ifeq ($(USETAR),bz2) +TAROPT=vj +TAREXT=.tar.bz2 +else +TAROPT=vz +TAREXT=.tar.gz +endif +override REQUIRE_PACKAGES=rtl +ifeq ($(FULL_TARGET),i386-linux) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-go32v2) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-win32) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-os2) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-freebsd) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-beos) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-netbsd) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-solaris) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-qnx) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-netware) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-openbsd) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-wdosx) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-darwin) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-emx) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-watcom) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-netwlibc) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-wince) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-embedded) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),i386-symbian) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),m68k-linux) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),m68k-freebsd) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),m68k-netbsd) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),m68k-amiga) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),m68k-atari) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),m68k-openbsd) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),m68k-palmos) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),m68k-embedded) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),powerpc-linux) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),powerpc-netbsd) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),powerpc-amiga) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),powerpc-macos) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),powerpc-darwin) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),powerpc-morphos) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),powerpc-embedded) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),sparc-linux) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),sparc-netbsd) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),sparc-solaris) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),sparc-embedded) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),x86_64-linux) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),x86_64-freebsd) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),x86_64-darwin) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),x86_64-win64) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),x86_64-embedded) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),arm-linux) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),arm-palmos) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),arm-wince) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),arm-gba) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),arm-nds) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),arm-embedded) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),arm-symbian) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),powerpc64-linux) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),powerpc64-darwin) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),powerpc64-embedded) +REQUIRE_PACKAGES_RTL=1 +endif +ifdef REQUIRE_PACKAGES_RTL +PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR)))))) +ifneq ($(PACKAGEDIR_RTL),) +ifneq ($(wildcard $(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)),) +UNITDIR_RTL=$(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX) +else +UNITDIR_RTL=$(PACKAGEDIR_RTL) +endif +ifdef CHECKDEPEND +$(PACKAGEDIR_RTL)/$(FPCMADE): + $(MAKE) -C $(PACKAGEDIR_RTL) $(FPCMADE) +override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(FPCMADE) +endif +else +PACKAGEDIR_RTL= +UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR))))) +ifneq ($(UNITDIR_RTL),) +UNITDIR_RTL:=$(firstword $(UNITDIR_RTL)) +else +UNITDIR_RTL= +endif +endif +ifdef UNITDIR_RTL +override COMPILER_UNITDIR+=$(UNITDIR_RTL) +endif +endif +ifndef NOCPUDEF +override FPCOPTDEF=$(CPU_TARGET) +endif +ifneq ($(OS_TARGET),$(OS_SOURCE)) +override FPCOPT+=-T$(OS_TARGET) +endif +ifneq ($(CPU_TARGET),$(CPU_SOURCE)) +override FPCOPT+=-P$(CPU_TARGET) +endif +ifeq ($(OS_SOURCE),openbsd) +override FPCOPT+=-FD$(NEW_BINUTILS_PATH) +endif +ifndef CROSSBOOTSTRAP +ifneq ($(BINUTILSPREFIX),) +override FPCOPT+=-XP$(BINUTILSPREFIX) +endif +ifneq ($(BINUTILSPREFIX),) +override FPCOPT+=-Xr$(RLINKPATH) +endif +endif +ifdef UNITDIR +override FPCOPT+=$(addprefix -Fu,$(UNITDIR)) +endif +ifdef LIBDIR +override FPCOPT+=$(addprefix -Fl,$(LIBDIR)) +endif +ifdef OBJDIR +override FPCOPT+=$(addprefix -Fo,$(OBJDIR)) +endif +ifdef INCDIR +override FPCOPT+=$(addprefix -Fi,$(INCDIR)) +endif +ifdef LINKSMART +override FPCOPT+=-XX +endif +ifdef CREATESMART +override FPCOPT+=-CX +endif +ifdef DEBUG +override FPCOPT+=-gl +override FPCOPTDEF+=DEBUG +endif +ifdef RELEASE +ifneq ($(findstring 2.0.,$(FPC_VERSION)),) +ifeq ($(CPU_TARGET),i386) +FPCCPUOPT:=-OG2p3 +endif +ifeq ($(CPU_TARGET),powerpc) +FPCCPUOPT:=-O1r +endif +else +FPCCPUOPT:=-O2 +endif +override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n +override FPCOPTDEF+=RELEASE +endif +ifdef STRIP +override FPCOPT+=-Xs +endif +ifdef OPTIMIZE +override FPCOPT+=-O2 +endif +ifdef VERBOSE +override FPCOPT+=-vwni +endif +ifdef COMPILER_OPTIONS +override FPCOPT+=$(COMPILER_OPTIONS) +endif +ifdef COMPILER_UNITDIR +override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR)) +endif +ifdef COMPILER_LIBRARYDIR +override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR)) +endif +ifdef COMPILER_OBJECTDIR +override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR)) +endif +ifdef COMPILER_INCLUDEDIR +override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR)) +endif +ifdef CROSSBINDIR +override FPCOPT+=-FD$(CROSSBINDIR) +endif +ifdef COMPILER_TARGETDIR +override FPCOPT+=-FE$(COMPILER_TARGETDIR) +ifeq ($(COMPILER_TARGETDIR),.) +override TARGETDIRPREFIX= +else +override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/ +endif +endif +ifdef COMPILER_UNITTARGETDIR +override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR) +ifeq ($(COMPILER_UNITTARGETDIR),.) +override UNITTARGETDIRPREFIX= +else +override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/ +endif +else +ifdef COMPILER_TARGETDIR +override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR) +override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX) +endif +endif +ifdef CREATESHARED +override FPCOPT+=-Cg +ifeq ($(CPU_TARGET),i386) +override FPCOPT+=-Aas +endif +endif +ifeq ($(findstring 2.0.,$(FPC_VERSION)),) +ifeq ($(OS_TARGET),linux) +ifeq ($(CPU_TARGET),x86_64) +override FPCOPT+=-Cg +endif +endif +endif +ifdef LINKSHARED +endif +ifdef GCCLIBDIR +override FPCOPT+=-Fl$(GCCLIBDIR) +endif +ifdef OTHERLIBDIR +override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR)) +endif +ifdef OPT +override FPCOPT+=$(OPT) +endif +ifdef FPCOPTDEF +override FPCOPT+=$(addprefix -d,$(FPCOPTDEF)) +endif +ifdef CFGFILE +override FPCOPT+=@$(CFGFILE) +endif +ifdef USEENV +override FPCEXTCMD:=$(FPCOPT) +override FPCOPT:=!FPCEXTCMD +export FPCEXTCMD +endif +override AFULL_TARGET=$(CPU_TARGET)-$(OS_TARGET) +override AFULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE) +ifneq ($(AFULL_TARGET),$(AFULL_SOURCE)) +override ACROSSCOMPILE=1 +endif +ifdef ACROSSCOMPILE +override FPCOPT+=$(CROSSOPT) +endif +override COMPILER:=$(FPC) $(FPCOPT) +ifeq (,$(findstring -s ,$(COMPILER))) +EXECPPAS= +else +ifeq ($(FULL_SOURCE),$(FULL_TARGET)) +ifdef RUNBATCH +EXECPPAS:=@$(RUNBATCH) $(PPAS) +else +EXECPPAS:=@$(PPAS) +endif +endif +endif +.PHONY: fpc_units +ifneq ($(TARGET_UNITS)$(TARGET_IMPLICITUNITS),) +override ALLTARGET+=fpc_units +override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS)) +override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS)) +override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES) +override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES) +endif +fpc_units: $(COMPILER_UNITTARGETDIR) $(UNITPPUFILES) +ifdef TARGET_RSTS +override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS)) +override CLEANRSTFILES+=$(RSTFILES) +endif +.PHONY: fpc_all fpc_smart fpc_debug fpc_release fpc_shared +$(FPCMADE): $(ALLDEPENDENCIES) $(ALLTARGET) + @$(ECHOREDIR) Compiled > $(FPCMADE) +fpc_all: $(FPCMADE) +fpc_smart: + $(MAKE) all LINKSMART=1 CREATESMART=1 +fpc_debug: + $(MAKE) all DEBUG=1 +fpc_release: + $(MAKE) all RELEASE=1 +.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .lpr .dpr .pp .rc .res +$(COMPILER_UNITTARGETDIR): + $(MKDIRTREE) $(COMPILER_UNITTARGETDIR) +$(COMPILER_TARGETDIR): + $(MKDIRTREE) $(COMPILER_TARGETDIR) +%$(PPUEXT): %.pp + $(COMPILER) $< + $(EXECPPAS) +%$(PPUEXT): %.pas + $(COMPILER) $< + $(EXECPPAS) +%$(EXEEXT): %.pp + $(COMPILER) $< + $(EXECPPAS) +%$(EXEEXT): %.pas + $(COMPILER) $< + $(EXECPPAS) +%$(EXEEXT): %.lpr + $(COMPILER) $< + $(EXECPPAS) +%$(EXEEXT): %.dpr + $(COMPILER) $< + $(EXECPPAS) +%.res: %.rc + windres -i $< -o $@ +vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR) +vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR) +vpath %.lpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR) +vpath %.dpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR) +vpath %.inc $(COMPILER_INCLUDEDIR) +vpath %$(OEXT) $(COMPILER_UNITTARGETDIR) +vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR) +.PHONY: fpc_shared +override INSTALLTARGET+=fpc_shared_install +ifndef SHARED_LIBVERSION +SHARED_LIBVERSION=$(FPC_VERSION) +endif +ifndef SHARED_LIBNAME +SHARED_LIBNAME=$(PACKAGE_NAME) +endif +ifndef SHARED_FULLNAME +SHARED_FULLNAME=$(SHAREDLIBPREFIX)$(SHARED_LIBNAME)-$(SHARED_LIBVERSION)$(SHAREDLIBEXT) +endif +ifndef SHARED_LIBUNITS +SHARED_LIBUNITS:=$(TARGET_UNITS) $(TARGET_IMPLICITUNITS) +override SHARED_LIBUNITS:=$(filter-out $(INSTALL_BUILDUNIT),$(SHARED_LIBUNITS)) +endif +fpc_shared: +ifdef HASSHAREDLIB + $(MAKE) all CREATESHARED=1 LINKSHARED=1 CREATESMART=1 +ifneq ($(SHARED_BUILD),n) + $(PPUMOVE) -q $(SHARED_LIBUNITS) -i$(COMPILER_UNITTARGETDIR) -o$(SHARED_FULLNAME) -d$(COMPILER_UNITTARGETDIR) +endif +else + @$(ECHO) Shared Libraries not supported +endif +fpc_shared_install: +ifneq ($(SHARED_BUILD),n) +ifneq ($(SHARED_LIBUNITS),) +ifneq ($(wildcard $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME)),) + $(INSTALL) $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME) $(INSTALL_SHAREDDIR) +endif +endif +endif +.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall +ifdef INSTALL_UNITS +override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS)) +endif +ifdef INSTALL_BUILDUNIT +override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT)$(PPUEXT),$(INSTALLPPUFILES)) +endif +ifdef INSTALLPPUFILES +override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) +ifneq ($(UNITTARGETDIRPREFIX),) +override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPUFILES))) +override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPULINKFILES)))) +endif +override INSTALL_CREATEPACKAGEFPC=1 +endif +ifdef INSTALLEXEFILES +ifneq ($(TARGETDIRPREFIX),) +override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(notdir $(INSTALLEXEFILES))) +endif +endif +fpc_install: all $(INSTALLTARGET) +ifdef INSTALLEXEFILES + $(MKDIR) $(INSTALL_BINDIR) +ifdef UPXPROG + -$(UPXPROG) $(INSTALLEXEFILES) +endif + $(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR) +endif +ifdef INSTALL_CREATEPACKAGEFPC +ifdef FPCMAKE +ifdef PACKAGE_VERSION +ifneq ($(wildcard Makefile.fpc),) + $(FPCMAKE) -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc + $(MKDIR) $(INSTALL_UNITDIR) + $(INSTALL) Package.fpc $(INSTALL_UNITDIR) +endif +endif +endif +endif +ifdef INSTALLPPUFILES + $(MKDIR) $(INSTALL_UNITDIR) + $(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR) +ifneq ($(INSTALLPPULINKFILES),) + $(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR) +endif +ifneq ($(wildcard $(LIB_FULLNAME)),) + $(MKDIR) $(INSTALL_LIBDIR) + $(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR) +ifdef inUnix + ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME) +endif +endif +endif +ifdef INSTALL_FILES + $(MKDIR) $(INSTALL_DATADIR) + $(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR) +endif +fpc_sourceinstall: distclean + $(MKDIR) $(INSTALL_SOURCEDIR) + $(COPYTREE) $(BASEDIR)/* $(INSTALL_SOURCEDIR) +fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS)) +ifdef HASEXAMPLES + $(MKDIR) $(INSTALL_EXAMPLEDIR) +endif +ifdef EXAMPLESOURCEFILES + $(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR) +endif +ifdef TARGET_EXAMPLEDIRS + $(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR) +endif +.PHONY: fpc_distinstall +fpc_distinstall: install exampleinstall +.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall +ifndef PACKDIR +ifndef inUnix +PACKDIR=$(BASEDIR)/../fpc-pack +else +PACKDIR=/tmp/fpc-pack +endif +endif +ifndef ZIPNAME +ifdef DIST_ZIPNAME +ZIPNAME=$(DIST_ZIPNAME) +else +ZIPNAME=$(PACKAGE_NAME) +endif +endif +ifndef FULLZIPNAME +FULLZIPNAME=$(ZIPCROSSPREFIX)$(ZIPPREFIX)$(ZIPNAME)$(ZIPSUFFIX) +endif +ifndef ZIPTARGET +ifdef DIST_ZIPTARGET +ZIPTARGET=DIST_ZIPTARGET +else +ZIPTARGET=install +endif +endif +ifndef USEZIP +ifdef inUnix +USETAR=1 +endif +endif +ifndef inUnix +USEZIPWRAPPER=1 +endif +ifdef USEZIPWRAPPER +ZIPPATHSEP=$(PATHSEP) +ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(SRCBATCHEXT)) +else +ZIPPATHSEP=/ +endif +ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR)) +ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR)) +ifdef USETAR +ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT) +ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) * +else +ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(ZIPEXT) +ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) * +endif +fpc_zipinstall: + $(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1 + $(MKDIR) $(DIST_DESTDIR) + $(DEL) $(ZIPDESTFILE) +ifdef USEZIPWRAPPER +ifneq ($(ECHOREDIR),echo) + $(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER) + $(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER) + $(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER) +else + echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER) + echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER) + echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER) +endif +ifdef inUnix + /bin/sh $(ZIPWRAPPER) +else +ifdef RUNBATCH + $(RUNBATCH) (ZIPWRAPPER) +else + $(ZIPWRAPPER) +endif +endif + $(DEL) $(ZIPWRAPPER) +else + $(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE) +endif + $(DELTREE) $(PACKDIR) +fpc_zipsourceinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=$(ZIPSOURCESUFFIX) +fpc_zipexampleinstall: +ifdef HASEXAMPLES + $(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=$(ZIPEXAMPLESUFFIX) +endif +fpc_zipdistinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=distinstall +.PHONY: fpc_clean fpc_cleanall fpc_distclean +ifdef EXEFILES +override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES)) +endif +ifdef CLEAN_UNITS +override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS)) +endif +ifdef CLEANPPUFILES +override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) +ifdef DEBUGSYMEXT +override CLEANPPULINKFILES+=$(subst $(PPUEXT),$(DEBUGSYMEXT),$(CLEANPPUFILES)) +endif +override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES)) +override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES))) +endif +fpc_clean: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +ifdef CLEAN_FILES + -$(DEL) $(CLEAN_FILES) +endif +ifdef LIB_NAME + -$(DEL) $(LIB_NAME) $(LIB_FULLNAME) +endif + -$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE) + -$(DEL) *$(ASMEXT) *_ppas$(BATCHEXT) +fpc_cleanall: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef COMPILER_UNITTARGETDIR +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +endif + -$(DELTREE) units + -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) +ifneq ($(PPUEXT),.ppu) + -$(DEL) *.o *.ppu *.a +endif + -$(DELTREE) *$(SMARTEXT) + -$(DEL) fpcmade.* Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE) + -$(DEL) *_ppas$(BATCHEXT) +ifdef AOUTEXT + -$(DEL) *$(AOUTEXT) +endif +ifdef DEBUGSYMEXT + -$(DEL) *$(DEBUGSYMEXT) +endif +fpc_distclean: cleanall +.PHONY: fpc_baseinfo +override INFORULES+=fpc_baseinfo +fpc_baseinfo: + @$(ECHO) + @$(ECHO) == Package info == + @$(ECHO) Package Name..... $(PACKAGE_NAME) + @$(ECHO) Package Version.. $(PACKAGE_VERSION) + @$(ECHO) + @$(ECHO) == Configuration info == + @$(ECHO) + @$(ECHO) FPC.......... $(FPC) + @$(ECHO) FPC Version.. $(FPC_VERSION) + @$(ECHO) Source CPU... $(CPU_SOURCE) + @$(ECHO) Target CPU... $(CPU_TARGET) + @$(ECHO) Source OS.... $(OS_SOURCE) + @$(ECHO) Target OS.... $(OS_TARGET) + @$(ECHO) Full Source.. $(FULL_SOURCE) + @$(ECHO) Full Target.. $(FULL_TARGET) + @$(ECHO) SourceSuffix. $(SOURCESUFFIX) + @$(ECHO) TargetSuffix. $(TARGETSUFFIX) + @$(ECHO) + @$(ECHO) == Directory info == + @$(ECHO) + @$(ECHO) Required pkgs... $(REQUIRE_PACKAGES) + @$(ECHO) + @$(ECHO) Basedir......... $(BASEDIR) + @$(ECHO) FPCDir.......... $(FPCDIR) + @$(ECHO) CrossBinDir..... $(CROSSBINDIR) + @$(ECHO) UnitsDir........ $(UNITSDIR) + @$(ECHO) PackagesDir..... $(PACKAGESDIR) + @$(ECHO) + @$(ECHO) GCC library..... $(GCCLIBDIR) + @$(ECHO) Other library... $(OTHERLIBDIR) + @$(ECHO) + @$(ECHO) == Tools info == + @$(ECHO) + @$(ECHO) As........ $(AS) + @$(ECHO) Ld........ $(LD) + @$(ECHO) Ar........ $(AR) + @$(ECHO) Rc........ $(RC) + @$(ECHO) + @$(ECHO) Mv........ $(MVPROG) + @$(ECHO) Cp........ $(CPPROG) + @$(ECHO) Rm........ $(RMPROG) + @$(ECHO) GInstall.. $(GINSTALL) + @$(ECHO) Echo...... $(ECHO) + @$(ECHO) Shell..... $(SHELL) + @$(ECHO) Date...... $(DATE) + @$(ECHO) FPCMake... $(FPCMAKE) + @$(ECHO) PPUMove... $(PPUMOVE) + @$(ECHO) Upx....... $(UPXPROG) + @$(ECHO) Zip....... $(ZIPPROG) + @$(ECHO) + @$(ECHO) == Object info == + @$(ECHO) + @$(ECHO) Target Loaders........ $(TARGET_LOADERS) + @$(ECHO) Target Units.......... $(TARGET_UNITS) + @$(ECHO) Target Implicit Units. $(TARGET_IMPLICITUNITS) + @$(ECHO) Target Programs....... $(TARGET_PROGRAMS) + @$(ECHO) Target Dirs........... $(TARGET_DIRS) + @$(ECHO) Target Examples....... $(TARGET_EXAMPLES) + @$(ECHO) Target ExampleDirs.... $(TARGET_EXAMPLEDIRS) + @$(ECHO) + @$(ECHO) Clean Units......... $(CLEAN_UNITS) + @$(ECHO) Clean Files......... $(CLEAN_FILES) + @$(ECHO) + @$(ECHO) Install Units....... $(INSTALL_UNITS) + @$(ECHO) Install Files....... $(INSTALL_FILES) + @$(ECHO) + @$(ECHO) == Install info == + @$(ECHO) + @$(ECHO) DateStr.............. $(DATESTR) + @$(ECHO) ZipName.............. $(ZIPNAME) + @$(ECHO) ZipPrefix............ $(ZIPPREFIX) + @$(ECHO) ZipCrossPrefix....... $(ZIPCROSSPREFIX) + @$(ECHO) ZipSuffix............ $(ZIPSUFFIX) + @$(ECHO) FullZipName.......... $(FULLZIPNAME) + @$(ECHO) Install FPC Package.. $(INSTALL_FPCPACKAGE) + @$(ECHO) + @$(ECHO) Install base dir..... $(INSTALL_BASEDIR) + @$(ECHO) Install binary dir... $(INSTALL_BINDIR) + @$(ECHO) Install library dir.. $(INSTALL_LIBDIR) + @$(ECHO) Install units dir.... $(INSTALL_UNITDIR) + @$(ECHO) Install source dir... $(INSTALL_SOURCEDIR) + @$(ECHO) Install doc dir...... $(INSTALL_DOCDIR) + @$(ECHO) Install example dir.. $(INSTALL_EXAMPLEDIR) + @$(ECHO) Install data dir..... $(INSTALL_DATADIR) + @$(ECHO) + @$(ECHO) Dist destination dir. $(DIST_DESTDIR) + @$(ECHO) Dist zip name........ $(DIST_ZIPNAME) + @$(ECHO) +.PHONY: fpc_info +fpc_info: $(INFORULES) +.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \ + fpc_makefile_dirs +fpc_makefile: + $(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc +fpc_makefile_sub1: +ifdef TARGET_DIRS + $(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS)) +endif +ifdef TARGET_EXAMPLEDIRS + $(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS)) +endif +fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS)) +fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2 +fpc_makefiles: fpc_makefile fpc_makefile_dirs +all: fpc_all +debug: fpc_debug +smart: fpc_smart +release: fpc_release +units: fpc_units +examples: +shared: fpc_shared +install: fpc_install +sourceinstall: fpc_sourceinstall +exampleinstall: fpc_exampleinstall +distinstall: fpc_distinstall +zipinstall: fpc_zipinstall +zipsourceinstall: fpc_zipsourceinstall +zipexampleinstall: fpc_zipexampleinstall +zipdistinstall: fpc_zipdistinstall +clean: fpc_clean +distclean: fpc_distclean +cleanall: fpc_cleanall +info: fpc_info +makefiles: fpc_makefiles +.PHONY: all debug smart release units examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles +ifneq ($(wildcard fpcmake.loc),) +include fpcmake.loc +endif +.NOTPARALLEL: diff --git a/packages/httpd13/Makefile.fpc b/packages/httpd13/Makefile.fpc new file mode 100644 index 0000000000..95ad7aa595 --- /dev/null +++ b/packages/httpd13/Makefile.fpc @@ -0,0 +1,26 @@ +# +# Makefile.fpc for httpd 1.3 unit +# + +[package] +name=httpd13 +version=2.2.0 + +[target] +units=httpd + +[require] +libc=y + +[install] +fpcpackage=y + +[compiler] +includedir=src +sourcedir=src tests + +[default] +fpcdir=../.. + +[rules] +.NOTPARALLEL: diff --git a/packages/httpd13/fpmake.pp b/packages/httpd13/fpmake.pp new file mode 100644 index 0000000000..f445687120 --- /dev/null +++ b/packages/httpd13/fpmake.pp @@ -0,0 +1,48 @@ +{$ifndef ALLPACKAGES} +{$mode objfpc}{$H+} +program fpmake; + +uses fpmkunit; + +Var + P : TPackage; + T : TTarget; +begin + With Installer do + begin +{$endif ALLPACKAGES} + + P:=AddPackage('httpd13'); +{$ifdef ALLPACKAGES} + P.Directory:='httpd13'; +{$endif ALLPACKAGES} + P.Version:='2.2.0'; + P.SourcePath.Add('src'); +// P.Dependencies.Add('x11'); + + T:=P.Targets.AddUnit('httpd.pas'); + with T.Dependencies do + begin + AddInclude('httpd.inc'); + AddInclude('ap_config.inc'); + AddInclude('ap_mmn.inc'); + AddInclude('hsregex.inc'); + AddInclude('ap_alloc.inc'); + AddInclude('readdir.inc'); + AddInclude('buff.inc'); + AddInclude('ap.inc'); + AddInclude('util_uri.inc'); + AddInclude('http_config.inc'); + AddInclude('http_core.inc'); + AddInclude('http_log.inc'); + AddInclude('http_main.inc'); + AddInclude('http_protocol.inc'); + AddInclude('http_request.inc'); + AddInclude('http_vhost.inc'); + end; + +{$ifndef ALLPACKAGES} + Run; + end; +end. +{$endif ALLPACKAGES} diff --git a/packages/httpd13/src/ap.inc b/packages/httpd13/src/ap.inc new file mode 100644 index 0000000000..6da834dbe6 --- /dev/null +++ b/packages/httpd13/src/ap.inc @@ -0,0 +1,175 @@ +{ 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. + } + +{ + * The ap_vsnprintf/ap_snprintf functions are based on, and used with the + * permission of, the SIO stdio-replacement strx_* functions by Panos + * Tsirigotis <panos@alumni.cs.colorado.edu> for xinetd. + } + +function ap_cpystrn(param1: PChar; const param2: PChar; param3: size_t): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{int ap_slack(int, int); +int ap_execle(const char *, const char *, ...); +int ap_execve(const char *, char * const argv[], char * const envp[]); } + +//function ap_getpass(const prompt: PChar; pwbuf: PChar; bufsiz: size_t): cint; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +//{$ifndef ap_strtol} +//function ap_strtol(const nptr: PChar; endptr: PPChar; base: cint): clong; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; +//{$endif} + +{ small utility macros to make things easier to read } + +{.$ifdef WIN32 +#define ap_killpg(x, y) +#else +#ifdef NO_KILLPG +#define ap_killpg(x, y) (kill (-(x), (y))) +#else +#define ap_killpg(x, y) (killpg ((x), (y))) +#endif +#endif} { WIN32 } + +{ ap_vformatter() is a generic printf-style formatting routine + * with some extensions. The extensions are: + * + * %pA takes a struct in_addr *, and prints it as a.b.c.d + * %pI takes a struct sockaddr_in * and prints it as a.b.c.d:port + * %pp takes a void * and outputs it in hex + * + * The %p hacks are to force gcc's printf warning code to skip + * over a pointer argument without complaining. This does + * mean that the ANSI-style %p (output a void * in hex format) won't + * work as expected at all, but that seems to be a fair trade-off + * for the increased robustness of having printf-warnings work. + * + * Additionally, ap_vformatter allows for arbitrary output methods + * using the ap_vformatter_buff and flush_func. + * + * The ap_vformatter_buff has two elements curpos and endpos. + * curpos is where ap_vformatter will write the next byte of output. + * It proceeds writing output to curpos, and updating curpos, until + * either the end of output is reached, or curpos == endpos (i.e. the + * buffer is full). + * + * If the end of output is reached, ap_vformatter returns the + * number of bytes written. + * + * When the buffer is full, the flush_func is called. The flush_func + * can return -1 to indicate that no further output should be attempted, + * and ap_vformatter will return immediately with -1. Otherwise + * the flush_func should flush the buffer in whatever manner is + * appropriate, re-initialize curpos and endpos, and return 0. + * + * Note that flush_func is only invoked as a result of attempting to + * write another byte at curpos when curpos >= endpos. So for + * example, it's possible when the output exactly matches the buffer + * space available that curpos == endpos will be true when + * ap_vformatter returns. + * + * ap_vformatter does not call out to any other code, it is entirely + * self-contained. This allows the callers to do things which are + * otherwise "unsafe". For example, ap_psprintf uses the "scratch" + * space at the unallocated end of a block, and doesn't actually + * complete the allocation until ap_vformatter returns. ap_psprintf + * would be completely broken if ap_vformatter were to call anything + * that used a pool. Similarly http_bprintf() uses the "scratch" + * space at the end of its output buffer, and doesn't actually note + * that the space is in use until it either has to flush the buffer + * or until ap_vformatter returns. + } + +type + ap_vformatter_buff = record + curpos: PChar; + endpos: PChar; + end; + + Pap_vformatter_buff = ^ap_vformatter_buff; + + flush_func_t = function (param: Pap_vformatter_buff): cint; + +function ap_vformatter(flush_func: flush_func_t; + param2: Pap_vformatter_buff; const fmt: PChar; ap: va_list): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ These are snprintf implementations based on ap_vformatter(). + * + * Note that various standards and implementations disagree on the return + * value of snprintf, and side-effects due to %n in the formatting string. + * ap_snprintf behaves as follows: + * + * Process the format string until the entire string is exhausted, or + * the buffer fills. If the buffer fills then stop processing immediately + * (so no further %n arguments are processed), and return the buffer + * length. In all cases the buffer is NUL terminated. The return value + * is the number of characters placed in the buffer, excluding the + * terminating NUL. All this implies that, at most, (len-1) characters + * will be copied over; if the return value is >= len, then truncation + * occured. + * + * In no event does ap_snprintf return a negative number. + } +function ap_snprintf(buf: PChar; len: size_t; const format: PChar; + others: array of const): cint; cdecl; external LibHTTPD; + +// __attribute__((format(printf,3,4))); + +function ap_vsnprintf(buf: PChar; len: size_t; const format: PChar; ap: va_list): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Simple BASE64 encode/decode functions. + * + * As we might encode binary strings, hence we require the length of + * the incoming plain source. And return the length of what we decoded. + * + * The decoding function takes any non valid char (i.e. whitespace, \0 + * or anything non A-Z,0-9 etc as terminal. + * + * plain strings/binary sequences are not assumed '\0' terminated. Encoded + * strings are neither. But propably should. + * + } +function ap_base64encode_len(len: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_base64encode(coded_dst: PChar; const plain_src: PChar; len_plain_src: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_base64encode_binary(coded_dst: PChar; const plain_src: PChar; len_plain_src: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + + +function ap_base64decode_len(const coded_src: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_base64decode(plain_dst: PChar; const coded_src: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_base64decode_binary(plain_dst: PChar; const coded_src: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Password validation, as used in AuthType Basic which is able to cope + * (based on the prefix) with the SHA1, Apache's internal MD5 and (depending + * on your platform either plain or crypt(3) passwords. + } +function ap_validate_password(const passwd, hash: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + diff --git a/packages/httpd13/src/ap_alloc.inc b/packages/httpd13/src/ap_alloc.inc new file mode 100644 index 0000000000..85db365db9 --- /dev/null +++ b/packages/httpd13/src/ap_alloc.inc @@ -0,0 +1,451 @@ +{ 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. + } + +{ + * Resource allocation routines... + * + * designed so that we don't have to keep track of EVERYTHING so that + * it can be explicitly freed later (a fundamentally unsound strategy --- + * particularly in the presence of die()). + * + * Instead, we maintain pools, and allocate items (both memory and I/O + * handlers) from the pools --- currently there are two, one for per + * transaction info, and one for config info. When a transaction is over, + * we can delete everything in the per-transaction pool without fear, and + * without thinking too hard about it either. + * + * rst + } + +{ Arenas for configuration info and transaction info + * --- actual layout of the pool structure is private to + * alloc.c. + } + + { Need declaration of DIR on Win32 } +{.$ifdef Windows} + {$include readdir.inc} +{.$endif} + +type + pool = record end; + Ppool = ^pool; + ap_pool = pool; + Pap_pool = ^ap_pool; + +function ap_init_alloc: PPool; { Set up everything } + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +//procedure ap_cleanup_alloc; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_make_sub_pool(param: PPool): PPool; { All pools are subpools of permanent_pool } + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_destroy_pool(param: PPool); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ pools have nested lifetimes -- sub_pools are destroyed when the + * parent pool is cleared. We allow certain liberties with operations + * on things such as tables (and on other structures in a more general + * sense) where we allow the caller to insert values into a table which + * were not allocated from the table's pool. The table's data will + * remain valid as long as all the pools from which its values are + * allocated remain valid. + * + * For example, if B is a sub pool of A, and you build a table T in + * pool B, then it's safe to insert data allocated in A or B into T + * (because B lives at most as long as A does, and T is destroyed when + * B is cleared/destroyed). On the other hand, if S is a table in + * pool A, it is safe to insert data allocated in A into S, but it + * is *not safe* to insert data allocated from B into S... because + * B can be cleared/destroyed before A is (which would leave dangling + * pointers in T's data structures). + * + * In general we say that it is safe to insert data into a table T + * if the data is allocated in any ancestor of T's pool. This is the + * basis on which the POOL_DEBUG code works -- it tests these ancestor + * relationships for all data inserted into tables. POOL_DEBUG also + * provides tools (ap_find_pool, and ap_pool_is_ancestor) for other + * folks to implement similar restrictions for their own data + * structures. + * + * However, sometimes this ancestor requirement is inconvenient -- + * sometimes we're forced to create a sub pool (such as through + * ap_sub_req_lookup_uri), and the sub pool is guaranteed to have + * the same lifetime as the parent pool. This is a guarantee implemented + * by the *caller*, not by the pool code. That is, the caller guarantees + * they won't destroy the sub pool individually prior to destroying the + * parent pool. + * + * In this case the caller must call ap_pool_join() to indicate this + * guarantee to the POOL_DEBUG code. There are a few examples spread + * through the standard modules. + } +{$ifndef POOL_DEBUG} +//#define ap_pool_join(a,b) +{$else} +//API_EXPORT(void) ap_pool_join(pool *p, pool *sub); +//API_EXPORT(pool *) ap_find_pool(const void *ts); +//API_EXPORT(int) ap_pool_is_ancestor(pool *a, pool *b); +{$endif} + +{ Clearing out EVERYTHING in an pool... destroys any sub-pools } + +procedure ap_clear_pool(param1: Ppool); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Preparing for exec() --- close files, etc., but *don't* flush I/O + * buffers, *don't* wait for subprocesses, and *don't* free any memory. + } + +procedure ap_cleanup_for_exec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ routines to allocate memory from an pool... } + +function ap_palloc(p: PPool; nbytes: cint): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_pcalloc(p: PPool; nbytes: cint): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_pstrdup(p: PPool; const s: Char): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ make a nul terminated copy of the n characters starting with s } + +function ap_pstrndup(p: PPool; const s: PChar; n: cint): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +//API_EXPORT_NONSTD(char *) ap_pstrcat(struct pool *,...); { all '...' must be char* } +//API_EXPORT_NONSTD(char *) ap_psprintf(struct pool *, const char *fmt, ...) +// __attribute__((format(printf,2,3))); +//API_EXPORT(char *) ap_pvsprintf(struct pool *, const char *fmt, va_list); + +{ array and alist management... keeping lists of things. + * Common enough to want common support code ... + } + +type + Parray_header = ^array_header; + + array_header = record + pool: Pap_pool; + elt_size: cint; + nelts: cint; + nalloc: cint; + elts: PChar; + end; + +//API_EXPORT(array_header *) ap_make_array(pool *p, int nelts, int elt_size); +//API_EXPORT(void *) ap_push_array(array_header *); +//API_EXPORT(void) ap_array_cat(array_header *dst, const array_header *src); +//API_EXPORT(array_header *) ap_append_arrays(pool *, const array_header *, +// const array_header *); + +{ ap_array_pstrcat generates a new string from the pool containing + * the concatenated sequence of substrings referenced as elements within + * the array. The string will be empty if all substrings are empty or null, + * or if there are no elements in the array. + * If sep is non-NUL, it will be inserted between elements as a separator. + } +function ap_array_pstrcat(p: PPool; const arr: Parray_header; const sep: Char): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ copy_array copies the *entire* array. copy_array_hdr just copies + * the header, and arranges for the elements to be copied if (and only + * if) the code subsequently does a push or arraycat. + } + +//API_EXPORT(array_header *) ap_copy_array(pool *p, const array_header *src); +//API_EXPORT(array_header *) ap_copy_array_hdr(pool *p, const array_header *src); + + +{ Tables. Implemented alist style, for now, though we try to keep + * it so that imposing a hash table structure on top in the future + * wouldn't be *too* hard... + * + * Note that key comparisons for these are case-insensitive, largely + * because that's what's appropriate and convenient everywhere they're + * currently being used... + } + +type + table = record end; + + Ptable = ^table; + + table_entry = record + key: PChar; { maybe NULL in future; + * check when iterating thru table_elts + } + val: PChar; + end; + + table_entry_t = table_entry; + +function ap_make_table(p: Ppool; nelts: cuint): Ptable; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_copy_table(p: Ppool; p1: Ptable): Ptable; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_clear_table(p1: Ptable); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_table_get(const p1: Ptable; const p2: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_table_set(p1: Ptable; const name, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_table_setn(p1: Ptable; const name, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_table_merge(p1: Ptable; const name, more_val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_table_mergen(p1: Ptable; const name, more_val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_table_unset(p1: Ptable; const key: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_table_add(p1: Ptable; const name, more_val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_table_addn(p1: Ptable; const name, more_val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{API_EXPORT_NONSTD(void) ap_table_do(int ( *comp) (void *, const char *, const char *), + void *rec, const table *t,...); + +API_EXPORT(table * ) ap_overlay_tables(pool *p, const table *overlay, const table *base); +} +{ Conceptually, ap_overlap_tables does this: + + array_header *barr = ap_table_elts(b); + table_entry *belt = (table_entry *)barr->elts; + int i; + + for (i = 0; i < barr->nelts; ++i) begin + if (flags & AP_OVERLAP_TABLES_MERGE) begin + ap_table_mergen(a, belt[i].key, belt[i].val); + end + else begin + ap_table_setn(a, belt[i].key, belt[i].val); + end; + end; + + Except that it is more efficient (less space and cpu-time) especially + when b has many elements. + + Notice the assumptions on the keys and values in b -- they must be + in an ancestor of a's pool. In practice b and a are usually from + the same pool. +} +const + AP_OVERLAP_TABLES_SET = (0); + AP_OVERLAP_TABLES_MERGE = (1); + +procedure ap_overlap_tables(a: Ptable; const b: Ptable; flags: cuint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ XXX: these know about the definition of struct table in alloc.c. That + * definition is not here because it is supposed to be private, and by not + * placing it here we are able to get compile-time diagnostics from modules + * written which assume that a table is the same as an array_header. -djg + } +//#define ap_table_elts(t) ((array_header *)(t)) +//#define ap_is_empty_table(t) (((t) == NULL)||(((array_header *)(t))->nelts == 0)) + +{ routines to remember allocation of other sorts of things... + * generic interface first. Note that we want to have two separate + * cleanup functions in the general case, one for exec() preparation, + * to keep CGI scripts and the like from inheriting access to things + * they shouldn't be able to touch, and one for actually cleaning up, + * when the actual server process wants to get rid of the thing, + * whatever it is. + * + * kill_cleanup disarms a cleanup, presumably because the resource in + * question has been closed, freed, or whatever, and it's scarce + * enough to want to reclaim (e.g., descriptors). It arranges for the + * resource not to be cleaned up a second time (it might have been + * reallocated). run_cleanup does the same, but runs it first. + * + * Cleanups are identified for purposes of finding & running them off by the + * plain_cleanup and data, which should presumably be unique. + * + * NB any code which invokes register_cleanup or kill_cleanup directly + * is a critical section which should be guarded by block_alarms() and + * unblock_alarms() below... + * + * ap_register_cleanup_ex provided to allow for an optional "cleanup" + * to be run at call-time for things like setting CLOSEXEC flags + * on fd's or whatever else may make sense. + } + +//API_EXPORT(void) ap_register_cleanup(pool *p, void *data, +// void (*plain_cleanup) (void *), +// void (*child_cleanup) (void *)); +//API_EXPORT(void) ap_register_cleanup_ex(pool *p, void *data, +// void (*plain_cleanup) (void *), +// void (*child_cleanup) (void *), +// int (*magic_cleanup) (void *)); + +//API_EXPORT(void) ap_kill_cleanup(pool *p, void *data, void (*plain_cleanup) (void *)); +//API_EXPORT(void) ap_run_cleanup(pool *p, void *data, void (*cleanup) (void *)); + +{ A "do-nothing" cleanup, for register_cleanup; it's faster to do + * things this way than to test for NULL. } +//API_EXPORT_NONSTD(void) ap_null_cleanup(void *data); + +{ The time between when a resource is actually allocated, and when it + * its cleanup is registered is a critical section, during which the + * resource could leak if we got interrupted or timed out. So, anything + * which registers cleanups should bracket resource allocation and the + * cleanup registry with these. (This is done internally by run_cleanup). + * + * NB they are actually implemented in http_main.c, since they are bound + * up with timeout handling in general... + } + +procedure ap_block_alarms; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_unblock_alarms; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Common cases which want utility support.. + * the note_cleanups_for_foo routines are for + } + +{API_EXPORT(FILE *) ap_pfopen(struct pool *, const char *name, const char *fmode); +API_EXPORT(FILE *) ap_pfdopen(struct pool *, int fd, const char *fmode);} + +function ap_popenf(p1: Ppool; const name: PChar; flg, mode: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_popenf_ex(p1: Ppool; const name: PChar; flg, mode, domagic: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{API_EXPORT(void) ap_note_cleanups_for_file(pool *, FILE *); +API_EXPORT(void) ap_note_cleanups_for_file_ex(pool *, FILE *, int);} + +procedure ap_note_cleanups_for_fd(p1: Ppool; p2: cint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_note_cleanups_for_fd_ex(p1: Ppool; p2, p3: cint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{$ifdef WIN32} +//API_EXPORT(void) ap_note_cleanups_for_h(pool *, HANDLE); +{$endif} + +procedure ap_kill_cleanups_for_fd(p: Ppool; fd: cint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + + +procedure ap_note_cleanups_for_socket(p1: Ppool; p2: cint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_note_cleanups_for_socket_ex(p1: Ppool; p2, p3: cint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_kill_cleanups_for_socket(p: Ppool; sock: cint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_psocket(p: Ppool; p2, p3, p4: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_psocket_ex(p: Ppool; p2, p3, p4, p5: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_pclosesocket(a: Ppool; sock: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + + +function ap_pregcomp(p: Ppool; const pattern: PChar; cflags: cint): Pregex_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_pregfree(p: Ppool; reg: Pregex_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ routines to note closes... file descriptors are constrained enough + * on some systems that we want to support this. + } + +//API_EXPORT(int) ap_pfclose(struct pool *, FILE *); + +function ap_pclosef(p1: Ppool; fd: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{$ifdef WIN32} +//API_EXPORT(int) ap_pcloseh(struct pool *, HANDLE hDevice); +{$endif} + +{ routines to deal with directories } + +function ap_popendir(p: Ppool; const name: PChar): PDIR; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_pclosedir(p: Ppool; d: PDIR); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ ... even child processes (which we may want to wait for, + * or to kill outright, on unexpected termination). + * + * ap_spawn_child is a utility routine which handles an awful lot of + * the rigamarole associated with spawning a child --- it arranges + * for pipes to the child's stdin and stdout, if desired (if not, + * set the associated args to NULL). It takes as args a function + * to call in the child, and an argument to be passed to the function. + } + +type + kill_conditions = ( + kill_never, { process is never sent any signals } + kill_always, { process is sent SIGKILL on pool cleanup } + kill_after_timeout, { SIGTERM, wait 3 seconds, SIGKILL } + just_wait, { wait forever for the process to complete } + kill_only_once { send SIGTERM and then wait } + ); + +procedure ap_note_subprocess(a: Ppool; pid: pid_t; how: kill_conditions); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{API_EXPORT(int) ap_spawn_child(pool *, int (*)(void *, child_info *), + void *, enum kill_conditions, + FILE **pipe_in, FILE **pipe_out, + FILE **pipe_err); +int ap_close_fd_on_exec(int fd);} + +{ magic numbers --- min free bytes to consider a free pool block useable, + * and the min amount to allocate if we have to go to malloc() } + +const + BLOCK_MINFREE = 4096; + BLOCK_MINALLOC = 8192; + +{ Finally, some accounting } + +function ap_bytes_in_pool(p: PPool): culong; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_bytes_in_free_blocks: culong; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + diff --git a/packages/httpd13/src/ap_config.inc b/packages/httpd13/src/ap_config.inc new file mode 100644 index 0000000000..881aa819ef --- /dev/null +++ b/packages/httpd13/src/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 <sys/types.h> +//#endif +//#include <sys/stat.h> + + +{ 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)} +type rlim_t = cint; +#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 <sys/times.h> +{$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)} +const + HAVE_GMTOFF = 1; +{$undefine NO_KILLPG} +#undef NO_SETSID +//char *crypt(const char *pw, const char *salt); +//char *mktemp(char *); + HAVE_MMAP = 1; +{$define USE_MMAP_SCOREBOARD} +{$define USE_MMAP_FILES} +#include <sys/time.h> +{$define NEED_STRERROR} +type rlim_t = cint; +#define memmove(a,b,c) bcopy(b,a,c) +{$define NO_LINGCLOSE} +{$define HAVE_FLOCK_SERIALIZED_ACCEPT} +{$define NEED_DIFFTIME} + 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 <sys/times.h> +#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) } +const + 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 <features.h> + +{ 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 <crypt.h> +//#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 <sys/sem.h> +{$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 <sys/time.h> + 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 <sys/time.h> +#define HAVE_SYSLOG 1 +#undef HAVE_SYS_RESOURCE_H + +{$else}{$if defined(ATHEOS)} + +#include <features.h> +#include <crypt.h> +#include <sys/time.h> + +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define USE_FCNTL_SERIALIZED_ACCEPT + +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#undef NEED_STRDUP +const + HAVE_SYSLOG = 1; + + 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 <strings.h> (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 <sys/time.h> +#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 <shm.h> } +#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 <sys/time.h> +#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 <sys/param.h> +#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 <sys/types.h> +#include <sys/time.h> + +{$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 <osreldate.h> +#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 <unix.h> +#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 <sys/time.h> +#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 <stdio.h> +#include <sys/types.h> +typedef int rlim_t; + +{$else}{$if defined(ISC)} +#include <net/errno.h> +#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 <sys/time.h> +#include <stdlib.h> +#include <sys/types.h> +typedef int pid_t; +typedef int rlim_t; +typedef int mode_t; + +{$else}{$if defined(RISCIX)} +#include <sys/time.h> +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 <stddef.h> +#include <kernel/OS.h> + +#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 <kernel/OS.h> + +#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 <sys/types.h> +#include <sys/time.h> + +{$else}{$if defined(WINDOWS)} + +{ All windows stuff is now in os/win32/os.h } + +{$include win32_os.inc} + +{$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 <signal.h> +#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 <sys/time.h> +#include <sys/types.h> +#include <sys/msg.h> +#include <sys/socket.h> +#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 <sys/param.h> +//#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 <sys/types.h> +#endif +#include <stdarg.h>} + +{#if !defined(NEXT) && !defined(WIN32) +#include <dirent.h> +#define DIR_TYPE dirent +#elif !defined(WIN32) +#include <sys/dir.h> +#define DIR_TYPE direct +#else +#define DIR_TYPE dirent +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#ifdef __TANDEM +#include <strings.h> +#endif +#include "ap_ctype.h" +#if !defined(MPE) && !defined(WIN32) && !defined(TPF41) && !defined(__TANDEM) && !defined(NETWARE) +#include <sys/file.h> +#endif +#if !defined(WIN32) && !defined(NETWARE) +#include <sys/socket.h> +#ifdef HAVE_SYS_SELECT_H +#include <sys/select.h> +#endif }{ HAVE_SYS_SELECT_H } +{#ifndef TPF41 +#include <netinet/in.h> +#endif }{ ndef TPF41 } +{#if defined(OS390) && !defined(NO_ADDRESS) +#define NO_ADDRESS NO_DATA } { Not defined properly by OS/390 v1r2 } +{#endif +#include <netdb.h> +#include <sys/ioctl.h> +#if !defined(MPE) && !defined(BEOS) && !defined(TPF41) +#include <arpa/inet.h> }{ for inet_ntoa } +{#endif +#include <sys/wait.h> +#include <pwd.h> +#include <grp.h> +#include <fcntl.h> +#ifndef BEOS +#define closesocket(s) close(s) +#endif +#ifndef O_BINARY +#define O_BINARY (0) +#endif +#endif }{ ndef WIN32 } + +{#include <limits.h> +#include <time.h>} { for ctime } +{#ifdef WIN32 +#define strftime(s,max,format,tm) os_strftime(s,max,format,tm) +#endif +#include <signal.h> +#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 <errno.h> +#if !defined(QNX) && !defined(CONVEXOS11) && !defined(NEXT) && !defined(TPF41) && !defined(NETWARE) && !defined(MPE) +#include <memory.h> +#endif + +#ifdef NEED_PROCESS_H +#include <process.h> +#endif} + +{#if defined(WIN32) || defined(USE_HSREGEX) +#include "hsregex.h" +#else +#include <regex.h> +#endif} + +{$include hsregex.inc} + +{#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#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 <sys/mman.h> +#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 <unistd.h> +//#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 <setjmp.h> + +#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. + } +type NET_SIZE_T = cint; + +{ 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} +type + ap_wait_t = cint; +{$endif} + diff --git a/packages/httpd13/src/ap_mmn.inc b/packages/httpd13/src/ap_mmn.inc new file mode 100644 index 0000000000..528e588780 --- /dev/null +++ b/packages/httpd13/src/ap_mmn.inc @@ -0,0 +1,237 @@ +{ 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. + } + +{ + * MODULE_MAGIC_NUMBER_MAJOR + * Major API changes that could cause compatibility problems for older modules + * such as structure size changes. No binary compatibility is possible across + * a change in the major version. + * + * MODULE_MAGIC_NUMBER_MINOR + * Minor API changes that do not cause binary compatibility problems. + * Should be reset to 0 when upgrading MODULE_MAGIC_NUMBER_MAJOR. + * + * See the MODULE_MAGIC_AT_LEAST macro below for an example. + } + +{ + * 19950525 - original value + * 19960512 (1.1b2) - updated, 1.1, version. + * 19960526 (1.1b3) - get_token(), table_unset(), pstrndup() + * functions added + * 19960725 (1.2-dev) - HTTP/1.1 compliance + * (new version of read_client_block) + * 19960806 (1.2-dev) - scan_script_header_err() added + * 19961007 (1.2-dev) - replace read_client_block() with get_client_block() + * 19961125 (1.2b1) - change setup_client_block() to Roy's version + * 19961211 (1.2b3) - rwrite() added + * 19970103 (1.2b5-dev) - header parse API + * 19970427 (1.2b9-dev) - port references made unsigned + * 19970526 (1.2) - correct vhost walk for multiple requests on a single + * connect + * 19970623 (1.3-dev) - NT changes + * 19970628 (1.3-dev) - ap_slack (fd fixes) added + * 19970717 (1.3-dev) - child_init API hook added + * 19970719 (1.3-dev) - discard_request_body() added (to clear the decks + * as needed) + * 19970728 (1.3a2-dev) - child_exit API hook added + * 19970818 (1.3a2-dev) - post read-request phase added + * 19970825 (1.3a2-dev) - r->mtime cell added + * 19970831 (1.3a2-dev) - error logging changed to use aplog_error() + * 19970902 (1.3a2-dev) - MD5 routines and structures renamed to ap_* + * 19970912 (1.3b1-dev) - set_last_modified split into set_last_modified, + * set_etag and meets_conditions + * register_other_child API + * piped_log API + * short_score split into parent and child pieces + * os_is_absolute_path + * 19971026 (1.3b3-dev) - custom config hooks in place + * 19980126 (1.3b4-dev) - ap_cpystrn(), table_addn(), table_setn(), + * table_mergen() + * 19980201 (1.3b4-dev) - construct_url() + * prototype server_rec * -> request_rec * + * add get_server_name() and get_server_port() + * 19980207 (1.3b4-dev) - add dynamic_load_handle to module structure as part + * of the STANDARD_MODULE_STUFF header + * 19980304 (1.3b6-dev) - abstraction of SERVER_BUILT and SERVER_VERSION + * 19980305 (1.3b6-dev) - ap_config.h added for use by external modules + * 19980312 (1.3b6-dev) - parse_uri_components() and its ilk + * remove r->hostlen, add r->unparsed_uri + * set_string_slot_lower() + * clarification: non-RAW_ARGS cmd handlers do not + * need to pstrdup() their arguments + * clarification: request_rec members content_type, + * handler, content_encoding, content_language, + * content_languages MUST all be lowercase strings, + * and MAY NOT be modified in place -- modifications + * require pstrdup(). + * 19980317 (1.3b6-dev) - CORE_EXPORTs for win32 and <Perl> + * API export basic_http_header, send_header_field, + * set_keepalive, srm_command_loop, check_cmd_context, + * tm2sec + * spacetoplus(), plustospace(), client_to_stdout() + * removed + * 19980324 (1.3b6-dev) - API_EXPORT(index_of_response) + * 19980413 (1.3b6-dev) - The BIG SYMBOL RENAMING: general ap_ prefix + * (see src/include/compat.h for more details) + * ap_vformatter() API, see src/include/ap.h + * 19980507 (1.3b7-dev) - addition of ap_add_version_component() and + * discontinuation of -DSERVER_SUBVERSION support + * 19980519 (1.3b7-dev) - add child_info * to spawn function (as passed to + * ap_spawn_child_err_buff) and to ap_call_exec to make + * children work correctly on Win32. + * 19980527 (1.3b8-dev) - renamed some more functions to ap_ prefix which were + * missed at the big renaming (they are defines): + * is_default_port, default_port and http_method. + * A new communication method for modules was added: + * they can create customized error messages under the + * "error-notes" key in the request_rec->notes table. + * This string will be printed in place of the canned + * error responses, and will be propagated to + * ErrorDocuments or cgi scripts in the + * (REDIRECT_)ERROR_NOTES variable. + * 19980627 (1.3.1-dev) - More renaming that we forgot/bypassed. In particular: + * table_elts --> ap_table_elts + * is_table_empty --> ap_is_table_empty + * 19980708 (1.3.1-dev) - ap_isalnum(), ap_isalpha(), ... "8-bit safe" ctype + * macros and apctype.h added + * 19980713 (1.3.1-dev) - renaming of C header files: + * 1. conf.h -> ap_config.h + * 2. conf_auto.h -> ap_config_auto.h - now merged + * 3. ap_config.h -> ap_config_auto.h - now merged + * 4. compat.h -> ap_compat.h + * 5. apctype.h -> ap_ctype.h + * 19980806 (1.3.2-dev) - add ap_log_rerror() + * - add ap_scan_script_header_err_core() + * - add ap_uuencode() + * - add ap_custom_response() + * 19980811 (1.3.2-dev) - added limit_req_line, limit_req_fieldsize, and + * limit_req_fields to server_rec. + * added limit_req_body to core_dir_config and + * ap_get_limit_req_body() to get its value. + * 19980812 (1.3.2-dev) - split off MODULE_MAGIC_NUMBER + * 19980812.2 - add ap_overlap_tables() + * 19980816 (1.3.2-dev) - change proxy to use tables for headers, change + * struct cache_req to typedef cache_req. + * Delete ap_proxy_get_header(), ap_proxy_add_header(), + * ap_proxy_del_header(). Change interface of + * ap_proxy_send_fb() and ap_proxy_cache_error(). + * Add ap_proxy_send_hdr_line() and ap_proxy_bputs2(). + * 19980825 (1.3.2-dev) - renamed is_HTTP_xxx() macros to ap_is_HTTP_xxx() + * 19980825.1 - mod_proxy only (minor change): modified interface of + * ap_proxy_read_headers() and rdcache() to use a + * request_rec* instead of pool* + * (for implementing better error reporting). + * 19980906 (1.3.2-dev) - added ap_md5_binary() + * 19980917 (1.3.2-dev) - bs2000: changed os_set_authfile() to os_set_account() + * 19981108 (1.3.4-dev) - added ap_method_number_of() + * - changed value of M_INVALID and added WebDAV methods + * 19981108.1 - ap_exists_config_define() is now public (minor bump) + * 19981204 - scoreboard changes -- added generation, changed + * exit_generation to running_generation. Somewhere + * earlier vhostrec was added, but it's only safe to use + * as of this rev. See scoreboard.h for documentation. + * 19981211 - DSO changes -- added ap_single_module_configure() + * -- added ap_single_module_init() + * 19981229 - mod_negotiation overhaul -- added ap_make_etag() + * and added vlist_validator to request_rec. + * 19990101 - renamed macro escape_uri() to ap_escape_uri() + * - added MODULE_MAGIC_COOKIE to identify module structs + * 19990103 (1.3.4-dev) - added ap_array_pstrcat() + * 19990105 (1.3.4-dev) - added ap_os_is_filename_valid() + * 19990106 (1.3.4-dev) - Move MODULE_MAGIC_COOKIE to the end of the + * STANDARD_MODULE_STUFF macro so the version + * numbers and file name remain at invariant offsets + * 19990108 (1.3.4-dev) - status_drops_connection -> ap_status_drops_connection + * scan_script_header -> ap_scan_script_header_err + * - reordered entries in request_rec that were waiting + * for a non-binary-compatible release. + * (1.3.5-dev) + * 19990108.1 - add ap_MD5Encode() for MD5 password handling. + * 19990108.2 - add ap_validate_password() and change ap_MD5Encode() + * to use a stronger algorithm. + * 19990108.4 - add ap_size_list_item(), ap_get_list_item(), and + * ap_find_list_item() + * 19990108.5 - added ap_sub_req_method_uri() and added const to the + * definition of method in request_rec. + * 19990108.6 - SIGPIPE is now ignored by the core server. + * 19990108.7 - ap_isxdigit added + * 19990320 - METHODS and M_INVALID symbol values modified + * 19990320.1 - add ap_vrprintf() + * 19990320.2 - add cmd_parms.context, ap_set_config_vectors, + * export ap_add_file_conf + * 19990320.3 - add ap_regexec() and ap_regerror() + * 19990320.4 - add ap_field_noparam() + * 19990320.5 - add local_ip/host to conn_rec for mass-vhost + * 19990320.6 - add ap_SHA1Final(), ap_SHA1Init(), + * ap_SHA1Update_binary(), ap_SHA1Update(), + * ap_base64encode(), ap_base64encode_binary(), + * ap_base64encode_len(), ap_base64decode(), + * ap_base64decode_binary(), ap_base64decode_len(), + * ap_pbase64decode(), ap_pbase64encode() + * 19990320.7 - add ap_strcasestr() + * 19990320.8 - add request_rec.case_preserved_filename + * 19990320.9 - renamed alloc.h to ap_alloc.h + * 19990320.10 - add ap_is_rdirectory() and ap_stripprefix() + * 19990320.11 - Add a couple of fields, callback_data and + * filter_callback to the end of buff.h + * 19990320.11 - Add some fields to the end of the core_dir_config + * structure + * 19990320.12 - add ap_getline(), ap_get_chunk_size() + * 19990320.13 - add ap_strtol() + * 19990320.14 - add ap_register_cleanup_ex(), + * ap_note_cleanups_for_fd_ex(), + * ap_note_cleanups_for_socket_ex(), + * ap_note_cleanups_for_file_ex(), + * ap_popenf_ex() and ap_psocket_ex(). + * 19990320.15 - ap_is_recursion_limit_exceeded() + * 19990320.16 - ap_escape_errorlog_item() + * 19990320.17 - ap_auth_nonce() and ap_auth_nonce added + * in core_dir_config. + * 19990320.18 - trace_enable member added to core server_config + } + +const + MODULE_MAGIC_COOKIE = $41503133; { "AP13" } + + MODULE_MAGIC_NUMBER_MAJOR = 19990320; + MODULE_MAGIC_NUMBER_MINOR = 18; { 0...n } + +{ Useful for testing for features. } + +{#define AP_MODULE_MAGIC_AT_LEAST(major,minor) \ + ((major) < MODULE_MAGIC_NUMBER_MAJOR \ + || ((major) == MODULE_MAGIC_NUMBER_MAJOR \ + && (minor) <= MODULE_MAGIC_NUMBER_MINOR))} + +{ + * For example, suppose you wish to use the ap_overlap_tables + * function. You can do this: + * + * #if AP_MODULE_MAGIC_AT_LEAST(19980812,2) + * ... use ap_overlap_tables() + * #else + * ... alternative code which doesn't use ap_overlap_tables() + * #endif + * + } + +{ deprecated. present for backwards compatibility } + + MODULE_MAGIC_NUMBER = MODULE_MAGIC_NUMBER_MAJOR; + +//#define MODULE_MAGIC_AT_LEAST old_broken_macro_we_hope_you_are_not_using + diff --git a/packages/httpd13/src/buff.inc b/packages/httpd13/src/buff.inc new file mode 100644 index 0000000000..29cecc52da --- /dev/null +++ b/packages/httpd13/src/buff.inc @@ -0,0 +1,234 @@ +{ 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 B_SFIO} +#include "sfio.h" +{$endif} + +//#include <stdarg.h> + +const +{ Reading is buffered } + B_RD = (1); +{ Writing is buffered } + B_WR = (2); + B_RDWR = (3); +{ At end of file, or closed stream; no further input allowed } + B_EOF = (4); +{ No further output possible } + B_EOUT = (8); +{ A read error has occurred } + B_RDERR =(16); +{ A write error has occurred } + B_WRERR =(32); +//#ifdef B_ERROR { in SVR4: sometimes defined in /usr/include/sys/buf.h } +//#undef B_ERROR +//#endif + B_ERROR =(48); +{ Use chunked writing } + B_CHUNK =(64); +{ bflush() if a read would block } + B_SAFEREAD =(128); +{ buffer is a socket } + B_SOCKET =(256); +{$ifdef CHARSET_EBCDIC} + B_ASCII2EBCDIC = $40000000; { Enable conversion for this buffer } + B_EBCDIC2ASCII = $80000000; { Enable conversion for this buffer } +{$endif} {CHARSET_EBCDIC} + +type + Pbuff_struct = ^buff_struct; + + PBUFF = Pbuff_struct; + + PPBUFF = ^PBUFF; + + error_t = procedure (fb: PBUFF; op: cint; data: Pointer); + + filter_callback_t = procedure (param1: PBUFF; const param2: Pointer; param3: cint); + + buff_struct = record + flags: cint; { flags } + inptr: PChar; { pointer to next location to read } + incnt: cint; { number of bytes left to read from input buffer; + * always 0 if had a read error } + outchunk: cint; { location of chunk header when chunking } + outcnt: cint; { number of byte put in output buffer } + inbase: PChar; + outbase: PChar; + bufsiz: cint; + error: error_t; + error_data: PChar; + bytes_sent: clong; { number of bytes actually written } + + pool: Pap_pool; + +{ could also put pointers to the basic I/O routines here } + fd: cint; { the file descriptor } + fd_in: cint; { input file descriptor, if different } +{$ifdef WINDOWS} + hFH: HANDLE; { Windows filehandle } +{$endif} + + { transport handle, for RPC binding handle or some such } + t_handle: PChar; + +{$ifdef B_SFIO} + sf_in: PSfio_t; + sf_out: PSfio_t; +{$endif} + + callback_data: Pointer; + filter_callback: filter_callback_t; + + end; + +{$ifdef B_SFIO} + apache_sfio = record + disc: Sfdisc_t; + buff: PBUFF; + end; + +extern Sfdisc_t *bsfio_new(pool *p, BUFF *b); +{$endif} + +{ Options to bset/getopt } +const + BO_BYTECT = (1); + +{ Stream creation and modification } + +function ap_bcreate(p: PPool; flags: cint): PBUFF; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_bpushfd(fb: PBUFF; fd_in, fd_out: cint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{$ifdef WINDOWS} + +procedure ap_bpushh(fb: PBUFF; hFH: HANDLE); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{$endif} + +function ap_bsetopt(fb: PBUFF; optname: cint; const optval: Pointer): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_bgetopt(fb: PBUFF; optname: cint; optval: Pointer): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_bsetflag(fb: PBUFF; flag, value: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_bclose(fb: PBUFF): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +//#define ap_bgetflag(fb, flag) ((fb)->flags & (flag)) + +{ Error handling } + +procedure ap_bonerror(fb: PBUFF; error: error_t; data: Pointer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ I/O } +function ap_bread(fb: PBUFF; buf: Pointer; nbyte: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; +{API_EXPORT(int) ap_bgets(char *s, int n, BUFF *fb); +API_EXPORT(int) ap_blookc(char *buff, BUFF *fb); +API_EXPORT(int) ap_bskiplf(BUFF *fb); +API_EXPORT(int) ap_bwrite(BUFF *fb, const void *buf, int nbyte); +API_EXPORT(int) ap_bflush(BUFF *fb); +API_EXPORT(int) ap_bputs(const char *x, BUFF *fb); +API_EXPORT_NONSTD(int) ap_bvputs(BUFF *fb,...); +API_EXPORT_NONSTD(int) ap_bprintf(BUFF *fb, const char *fmt,...) + __attribute__((format(printf,2,3))); +API_EXPORT(int) ap_vbprintf(BUFF *fb, const char *fmt, va_list vlist); +} +{ Internal routines } +{API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb); +API_EXPORT(int) ap_bfilbuf(BUFF *fb); + +#ifndef CHARSET_EBCDIC + +#define ap_bgetc(fb) ( ((fb)->incnt == 0) ? ap_bfilbuf(fb) : \ + ((fb)->incnt--, *((fb)->inptr++)) ) + +#define ap_bputc(c, fb) ((((fb)->flags & (B_EOUT|B_WRERR|B_WR)) != B_WR || \ + (fb)->outcnt == (fb)->bufsiz) ? ap_bflsbuf(c, (fb)) : \ + ((fb)->outbase[(fb)->outcnt++] = (c), 0)) + +#else} {CHARSET_EBCDIC} +{ +#define ap_bgetc(fb) ( ((fb)->incnt == 0) ? ap_bfilbuf(fb) : \ + ((fb)->incnt--, (fb->flags & B_ASCII2EBCDIC)\ + ?os_toebcdic[(unsigned char)*((fb)->inptr++)]:*((fb)->inptr++)) ) + +#define ap_bputc(c, fb) ((((fb)->flags & (B_EOUT|B_WRERR|B_WR)) != B_WR || \ + (fb)->outcnt == (fb)->bufsiz) ? ap_bflsbuf(c, (fb)) : \ + ((fb)->outbase[(fb)->outcnt++] = (fb->flags & B_EBCDIC2ASCII)\ + ?os_toascii[(unsigned char)c]:(c), 0)) + +#endif} {CHARSET_EBCDIC} + +type + child_info = record +{$ifdef WINDOWS} + { + * These handles are used by ap_call_exec to call + * create process with pipe handles. + } + hPipeInputRead: HANDLE; + hPipeOutputWrite: HANDLE; + hPipeErrorWrite: HANDLE; +{$else} + { + * We need to put a dummy member in here to avoid compilation + * errors under certain Unix compilers, like SGI's and HPUX's, + * which fail to compile a zero-sized struct. Of course + * it would be much nicer if there was actually a use for this + * structure under Unix. Aah the joys of x-platform code. + } + dummy: cint; +{$endif} + end; + + Pchild_info = ^child_info; + + func_t = function (param1: Pointer; param2: Pchild_info): cint; + +function ap_bspawn_child(p: PPool; + func: func_t; data: Pointer; kill_how: kill_conditions; pipe_in, pipe_out, pipe_err: PPBUFF): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ enable non-blocking operations } +function ap_bnonblock(fb: PBUFF; direction: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; +{ and get an fd to select() on } +function ap_bfileno(fb: PBUFF; direction: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ bflush() if a read now would block, but don't actually read anything } +procedure ap_bhalfduplex(fb: PBUFF); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{$if defined(WINDOWS) or defined(NETWARE) or defined(CYGWIN_WINSOCK)} + +{ ap_recvwithtimeout/ap_sendwithtimeout socket primitives for WinSock } +//API_EXPORT(int) ap_sendwithtimeout(int sock, const char *buf, int len, int flags); +//API_EXPORT(int) ap_recvwithtimeout(int sock, char *buf, int len, int flags); + +{$endif} + diff --git a/packages/httpd13/src/hsregex.inc b/packages/httpd13/src/hsregex.inc new file mode 100644 index 0000000000..4fc6bda2b6 --- /dev/null +++ b/packages/httpd13/src/hsregex.inc @@ -0,0 +1,99 @@ +{ DON'T EVEN THINK ABOUT EDITING THIS, go see regex/Makefile, + * search for mkh } + +{ ========= begin header generated by ./mkh ========= } + +{ === regex2.h === } +{#ifndef API_EXPORT +#ifdef WIN32 +#define API_EXPORT(type) __declspec(dllexport) type __stdcall +#else +#define API_EXPORT(type) type +#endif +#endif} + +{#if defined(MAC_OS) || defined(MAC_OS_X_SERVER) || (defined(DARWIN) && defined(__DYNAMIC__)) +#define ap_private_extern __private_extern__ +#else +#define ap_private_extern +#endif} + +type + regoff_t = Integer; + +{$ifdef windows} + off_t = regoff_t; +{$endif} + + Pregex_t = ^regex_t; + + Pre_guts = Pointer; + + regex_t = record + re_magic: cint; + re_nsub: size_t; { number of parenthesized subexpressions } + re_endp: PChar; { end pointer for REG_PEND } + re_g: Pre_guts; { none of your business :-) } + end; + + regmatch_t = record + rm_so: regoff_t; { start of match } + rm_eo: regoff_t; { end of match } + end; + + +{ === regcomp.c === } +//API_EXPORT(int) regcomp(regex_t *, const char *, int); + +const + REG_BASIC = 0000; + REG_EXTENDED = 0001; + REG_ICASE = 0002; + REG_NOSUB = 0004; + REG_NEWLINE = 0010; + REG_NOSPEC = 0020; + REG_PEND = 0040; + REG_DUMP = 0200; + + +{ === regerror.c === } + REG_NOMATCH = 1; + REG_BADPAT = 2; + REG_ECOLLATE = 3; + REG_ECTYPE = 4; + REG_EESCAPE = 5; + REG_ESUBREG = 6; + REG_EBRACK = 7; + REG_EPAREN = 8; + REG_EBRACE = 9; + REG_BADBR =10; + REG_ERANGE =11; + REG_ESPACE =12; + REG_BADRPT =13; + REG_EMPTY =14; + REG_ASSERT =15; + REG_INVARG =16; + REG_ATOI =255; { convert name to number (!) } + REG_ITOA =0400; { convert number to name (!) } + +//API_EXPORT(size_t) regerror(int, const regex_t *, char *, size_t); + + +{ === regexec.c === } +//API_EXPORT(int) regexec(const regex_t *, const char *, size_t, regmatch_t [], int); + +const + REG_NOTBOL = 00001; + REG_NOTEOL = 00002; + REG_STARTEND = 00004; + REG_TRACE = 00400; { tracing of execution } + REG_LARGE = 01000; { force large representation } + REG_BACKR = 02000; { force use of backref code } + + +{ === regfree.c === } +//API_EXPORT(void) regfree(regex_t *); + + +{ ========= end header generated by ./mkh ========= } + diff --git a/packages/httpd13/src/http_config.inc b/packages/httpd13/src/http_config.inc new file mode 100644 index 0000000000..f90db90432 --- /dev/null +++ b/packages/httpd13/src/http_config.inc @@ -0,0 +1,402 @@ +{ 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. + } + +{ + * The central data structures around here... + } + +{ Command dispatch structures... } + +{ Note that for all of these except RAW_ARGS, the config routine is + * passed a freshly allocated string which can be modified or stored + * or whatever... it's only necessary to do pstrdup() stuff with + * RAW_ARGS. + } +type + cmd_how = ( + RAW_ARGS, { cmd_func parses command line itself } + TAKE1, { one argument only } + TAKE2, { two arguments only } + ITERATE, { one argument, occuring multiple times + * (e.g., IndexIgnore) + } + ITERATE2, { two arguments, 2nd occurs multiple times + * (e.g., AddIcon) + } + FLAG, { One of 'On' or 'Off' } + NO_ARGS, { No args at all, e.g. </Directory> } + TAKE12, { one or two arguments } + TAKE3, { three arguments only } + TAKE23, { two or three arguments } + TAKE123, { one, two or three arguments } + TAKE13 { one or three arguments } + ); + + cs_func_t = function (): PChar; + + command_struct = record + name: PChar; { Name of this command } + func: cs_func_t; { Function invoked } + cmd_data: Pointer; { Extra data, for functions which + * implement multiple commands... + } + req_override: cint; { What overrides need to be allowed to + * enable this command. + } + args_how: cmd_how; { What the command expects as arguments } + + errmsg: PChar; { 'usage' message, in case of syntax errors } + end; + + command_rec = command_struct; + + Pcommand_rec = ^command_rec; + +{ The allowed locations for a configuration directive are the union of + * those indicated by each set bit in the req_override mask. + * + * (req_override & RSRC_CONF) => *.conf outside <Directory> or <Location> + * (req_override & ACCESS_CONF) => *.conf inside <Directory> or <Location> + * (req_override & OR_AUTHCFG) => *.conf inside <Directory> or <Location> + * and .htaccess when AllowOverride AuthConfig + * (req_override & OR_LIMIT) => *.conf inside <Directory> or <Location> + * and .htaccess when AllowOverride Limit + * (req_override & OR_OPTIONS) => *.conf anywhere + * and .htaccess when AllowOverride Options + * (req_override & OR_FILEINFO) => *.conf anywhere + * and .htaccess when AllowOverride FileInfo + * (req_override & OR_INDEXES) => *.conf anywhere + * and .htaccess when AllowOverride Indexes + } +const + OR_NONE = 0; + OR_LIMIT = 1; + OR_OPTIONS = 2; + OR_FILEINFO = 4; + OR_AUTHCFG = 8; + OR_INDEXES = 16; + OR_UNSET = 32; + ACCESS_CONF = 64; + RSRC_CONF = 128; + OR_ALL = (OR_LIMIT or OR_OPTIONS or OR_FILEINFO or OR_AUTHCFG or OR_INDEXES); + +{ This can be returned by a function if they don't wish to handle + * a command. Make it something not likely someone will actually use + * as an error code. + } + + DECLINE_CMD = '\a\b'; + +{ + * This structure is passed to a command which is being invoked, + * to carry a large variety of miscellaneous data which is all of + * use to *somebody*... + } + +type + cmd_parms = record + info: Pointer; { Argument to command from cmd_table } + override: cint; { Which allow-override bits are set } + limited: cint; { Which methods are <Limit>ed } + + config_file: Pconfigfile_t; { Config file structure from pcfg_openfile() } + + pool: Pap_pool; { Pool to allocate new storage in } + temp_pool: Ppool; { Pool for scratch memory; persists during + * configuration, but wiped before the first + * request is served... + } + server: Pserver_rec; { Server_rec being configured for } + path: PChar; { If configuring for a directory, + * pathname of that directory. + * NOPE! That's what it meant previous to the + * existance of <Files>, <Location> and regex + * matching. Now the only usefulness that can + * be derived from this field is whether a command + * is being called in a server context (path == NULL) + * or being called in a dir context (path != NULL). + } + cmd: Pcommand_rec; { configuration command } + end_token: PChar; { end token required to end a nested section } + context: Pointer; { per_dir_config vector passed + * to handle_command } + end; + +{ This structure records the existence of handlers in a module... } + + handler_t = function (param1: Prequest_rec): Integer; cdecl; + + Phandler_rec = ^handler_rec; + + handler_rec = record + content_type: PChar; { MUST be all lower case } + handler: handler_t; + end; + +{ + * Module structures. Just about everything is dispatched through + * these, directly or indirectly (through the command and handler + * tables). + } + + Pmodule_struct = ^module_struct; + +{$ifdef ULTRIX_BRAIN_DEATH} + init_t = procedure (); cdecl; + create_dir_config_t = function (): Pointer; cdecl; + merge_dir_config_t = function (): Pointer; cdecl; + create_server_config_t = function (): Pointer; cdecl; + merge_server_config_t = function (): Pointer; cdecl; +{$else} + init_t = procedure (param1: Pserver_rec; param2: Ppool); cdecl; + create_dir_config_t = function (p: Ppool; dir: PChar): Pointer; cdecl; + merge_dir_config_t = function (p: PPool; base_conf, new_conf: Pointer): Pointer; cdecl; + create_server_config_t = function (p: Ppool; s: Pserver_rec): Pointer; cdecl; + merge_server_config_t = function (p: Ppool; base_conf, new_conf: Pointer): Pointer; cdecl; +{$endif} + + hook_t = function (param1: Prequest_rec): cint; cdecl; + +{$ifdef ULTRIX_BRAIN_DEATH} + child_init_t = procedure (); + child_exit_t = procedure (); +{$else} + child_init_t = procedure (param1: Pserver_rec; param2: Ppool); cdecl; + child_exit_t = procedure (param1: Pserver_rec; param2: Ppool); cdecl; +{$endif} + + module_struct = record + version: cint; { API version, *not* module version; + * check that module is compatible with this + * version of the server. + } + minor_version: cint; { API minor version. Provides API feature + * milestones. Not checked during module init + } + module_index: cint; { Index to this modules structures in + * config vectors. + } + + name: PChar; + dynamic_load_handle: Pointer; + + next: Pmodule_struct; + + magic: culong; { Magic Cookie to identify a module structure; + * It's mainly important for the DSO facility + * (see also mod_so). + } + + { init() occurs after config parsing, but before any children are + * forked. + * Modules should not rely on the order in which create_server_config + * and create_dir_config are called. + } + + init: init_t; + create_dir_config: create_dir_config_t; + merge_dir_config: merge_dir_config_t; + create_server_config: create_server_config_t; + merge_server_config: merge_server_config_t; + + cmds: Pcommand_rec; + handlers: Phandler_rec; + + { Hooks for getting into the middle of server ops... + + * translate_handler --- translate URI to filename + * access_checker --- check access by host address, etc. All of these + * run; if all decline, that's still OK. + * check_user_id --- get and validate user id from the HTTP request + * auth_checker --- see if the user (from check_user_id) is OK *here*. + * If all of *these* decline, the request is rejected + * (as a SERVER_ERROR, since the module which was + * supposed to handle this was configured wrong). + * type_checker --- Determine MIME type of the requested entity; + * sets content_type, _encoding and _language fields. + * logger --- log a transaction. + * post_read_request --- run right after read_request or internal_redirect, + * and not run during any subrequests. + } + + translate_handler: hook_t; + ap_check_user_id: hook_t; + auth_checker: hook_t; + access_checker: hook_t; + type_checker: hook_t; + fixer_upper: hook_t; + logger: hook_t; + header_parser: hook_t; + + { Regardless of the model the server uses for managing "units of + * execution", i.e. multi-process, multi-threaded, hybrids of those, + * there is the concept of a "heavy weight process". That is, a + * process with its own memory space, file spaces, etc. This method, + * child_init, is called once for each heavy-weight process before + * any requests are served. Note that no provision is made yet for + * initialization per light-weight process (i.e. thread). The + * parameters passed here are the same as those passed to the global + * init method above. + } + + child_init: child_init_t; + child_exit: child_exit_t; + + post_read_request: hook_t; + end; + + module = module_struct; + + Pmodule = ^module; + +{ Initializer for the first few module slots, which are only + * really set up once we start running. Note that the first two slots + * provide a version check; this should allow us to deal with changes to + * the API. The major number should reflect changes to the API handler table + * itself or removal of functionality. The minor number should reflect + * additions of functionality to the existing API. (the server can detect + * an old-format module, and either handle it back-compatibly, or at least + * signal an error). See src/include/ap_mmn.h for MMN version history. + } + +procedure STANDARD_MODULE_STUFF(var mod_: module); + +{ Generic accessors for other modules to get at their own module-specific + * data + } + +{API_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m); +API_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val); + +#define ap_get_module_config(v,m) \ + (((void **)(v))[(m)->module_index]) +#define ap_set_module_config(v,m,val) \ + ((((void **)(v))[(m)->module_index]) = (val))} + +{ Generic command handling function... } + +{API_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *, char *, char *); +API_EXPORT_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *, char *, char *); +API_EXPORT_NONSTD(const char *) ap_set_flag_slot(cmd_parms *, char *, int); +API_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *, char *, char *);} + +{ For modules which need to read config files, open logs, etc. ... + * this returns the fname argument if it begins with '/'; otherwise + * it relativizes it wrt server_root. + } + +//API_EXPORT(char *) ap_server_root_relative(pool *p, char *fname); + +{ Finally, the hook for dynamically loading modules in... } + +procedure ap_add_module(m: Pmodule); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_remove_module(m: Pmodule); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_add_loaded_module(m: Pmodule); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_add_named_module(const name: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_clear_module_list(); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_find_module_name(m: Pmodule): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_find_linked_module(const name: PChar): Pmodule; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ for implementing subconfigs and customized config files } +{API_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config); + +#ifdef CORE_PRIVATE + +extern API_VAR_EXPORT module *top_module; + +extern module *ap_prelinked_modules[]; +extern module *ap_preloaded_modules[]; +extern API_VAR_EXPORT module **ap_loaded_modules;} + +{ For mod_so.c... } + +//API_EXPORT(void) ap_single_module_configure(pool *p, server_rec *s, module *m); + +{ For http_main.c... } + +{API_EXPORT(server_rec *) ap_read_config(pool *conf_pool, pool *temp_pool, char *config_name); +API_EXPORT(void) ap_init_modules(pool *p, server_rec *s); +API_EXPORT(void) ap_child_init_modules(pool *p, server_rec *s); +API_EXPORT(void) ap_child_exit_modules(pool *p, server_rec *s); +API_EXPORT(void) ap_setup_prelinked_modules(void); +API_EXPORT(void) ap_show_directives(void); +API_EXPORT(void) ap_show_modules(void); +void ap_cleanup_method_ptrs(void);} + +{ For http_request.c... } + +{CORE_EXPORT(void *) ap_create_request_config(pool *p); +CORE_EXPORT(void *) ap_create_per_dir_config(pool *p); +CORE_EXPORT(void *) ap_merge_per_dir_configs(pool *p, void *base, void *new);} + +{ For http_core.c... (<Directory> command and virtual hosts) } + +{CORE_EXPORT(int) ap_parse_htaccess(void **result, request_rec *r, int override, + const char *path, const char *access_name); + +CORE_EXPORT(const char *) ap_init_virtual_host(pool *p, const char *hostname, + server_rec *main_server, server_rec **); +CORE_EXPORT(void) ap_process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp); +} +{ ap_check_cmd_context() definitions: } +//API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden); + +{ ap_check_cmd_context(): Forbidden in: } +const + NOT_IN_VIRTUALHOST = $01; { <Virtualhost> } + NOT_IN_LIMIT = $02; { <Limit> } + NOT_IN_DIRECTORY = $04; { <Directory> } + NOT_IN_LOCATION = $08; { <Location> } + NOT_IN_FILES = $10; { <Files> } + NOT_IN_DIR_LOC_FILE = (NOT_IN_DIRECTORY or NOT_IN_LOCATION or NOT_IN_FILES); { <Directory>/<Location>/<Files>} + GLOBAL_ONLY = (NOT_IN_VIRTUALHOST or NOT_IN_LIMIT or NOT_IN_DIR_LOC_FILE); + + +{ Module-method dispatchers, also for http_request.c } + +//API_EXPORT(int) ap_translate_name(request_rec *); +//API_EXPORT(int) ap_check_access(request_rec *); { check access on non-auth basis } +//API_EXPORT(int) ap_check_user_id(request_rec *); { obtain valid username from client auth } +//API_EXPORT(int) ap_check_auth(request_rec *); { check (validated) user is authorized here } +//API_EXPORT(int) ap_find_types(request_rec *); { identify MIME type } +//API_EXPORT(int) ap_run_fixups(request_rec *); { poke around for other metainfo, etc.... } +//API_EXPORT(int) ap_invoke_handler(request_rec *); +//API_EXPORT(int) ap_log_transaction(request_rec *r); +//API_EXPORT(int) ap_header_parse(request_rec *); +//API_EXPORT(int) ap_run_post_read_request(request_rec *); + +{ for mod_perl } + +//CORE_EXPORT(const command_rec *) ap_find_command(const char *name, const command_rec *cmds); +//CORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod); +//CORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod); +//CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l); + +//#endif + diff --git a/packages/httpd13/src/http_core.inc b/packages/httpd13/src/http_core.inc new file mode 100644 index 0000000000..40ab79a4af --- /dev/null +++ b/packages/httpd13/src/http_core.inc @@ -0,0 +1,422 @@ +{ 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. + } + +{**************************************************************** + * + * The most basic server code is encapsulated in a single module + * known as the core, which is just *barely* functional enough to + * serve documents, though not terribly well. + * + * Largely for NCSA back-compatibility reasons, the core needs to + * make pieces of its config structures available to other modules. + * The accessors are declared here, along with the interpretation + * of one of them (allow_options). + } + +const + OPT_NONE = 0; + OPT_INDEXES = 1; + OPT_INCLUDES = 2; + OPT_SYM_LINKS = 4; + OPT_EXECCGI = 8; + OPT_UNSET = 16; + OPT_INCNOEXEC = 32; + OPT_SYM_OWNER = 64; + OPT_MULTI = 128; + OPT_ALL = (OPT_INDEXES or OPT_INCLUDES or OPT_SYM_LINKS or OPT_EXECCGI); + +{ options for get_remote_host() } +{ REMOTE_HOST returns the hostname, or NULL if the hostname + * lookup fails. It will force a DNS lookup according to the + * HostnameLookups setting. + } + REMOTE_HOST = (0); + +{ REMOTE_NAME returns the hostname, or the dotted quad if the + * hostname lookup fails. It will force a DNS lookup according + * to the HostnameLookups setting. + } + REMOTE_NAME = (1); + +{ REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is + * never forced. + } + REMOTE_NOLOOKUP = (2); + +{ REMOTE_DOUBLE_REV will always force a DNS lookup, and also force + * a double reverse lookup, regardless of the HostnameLookups + * setting. The result is the (double reverse checked) hostname, + * or NULL if any of the lookups fail. + } + REMOTE_DOUBLE_REV = (3); + + SATISFY_ALL = 0; + SATISFY_ANY = 1; + SATISFY_NOSPEC = 2; + +{ default maximum of internal redirects } + AP_DEFAULT_MAX_INTERNAL_REDIRECTS = 20; + +{ default maximum subrequest nesting level } + AP_DEFAULT_MAX_SUBREQ_DEPTH = 20; + +function ap_allow_options(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_allow_overrides(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_default_type(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_document_root(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + { Don't use this! If your request went + * through a Userdir, or something like + * that, it'll screw you. But it's + * back-compatible... + } + +function ap_get_remote_host(conn: Pconn_rec; dir_config: Pointer; type_: cint): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_get_remote_logname(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Used for constructing self-referencing URLs, and things like SERVER_PORT, + * and SERVER_NAME. + } +function ap_construct_url(p: Ppool; const uri: PChar; r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_get_server_name(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_get_server_port(const r: Prequest_rec): cuint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_get_limit_req_body(const r: Prequest_rec): culong; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_custom_response(r: Prequest_rec; status: cint; string_: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_exists_config_define(name: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Check if the current request is beyond the configured max. number of redirects or subrequests + * @param r The current request + * @return true (is exceeded) or false + } +function ap_is_recursion_limit_exceeded(const r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Authentication stuff. This is one of the places where compatibility + * with the old config files *really* hurts; they don't discriminate at + * all between different authentication schemes, meaning that we need + * to maintain common state for all of them in the core, and make it + * available to the other modules through interfaces. + } + +type + require_line = record + method_mask: cint; + requirement: PChar; + end; + +{API_EXPORT(const char *) ap_auth_type (request_rec *); +API_EXPORT(const char *) ap_auth_name (request_rec *); +API_EXPORT(const char *) ap_auth_nonce (request_rec *); +API_EXPORT(int) ap_satisfies (request_rec *r); +API_EXPORT(const array_header *) ap_requires (request_rec *); } + +{$ifdef WINDOWS} +{ + * CGI Script stuff for Win32... + } +type + file_type_e = ( eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, eFileTypeEXE32, + eFileTypeSCRIPT, eCommandShell16, eCommandShell32 ); + interpreter_source_e = ( INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY, + INTERPRETER_SOURCE_SHEBANG ); + +function ap_get_win32_interpreter(const param1: Prequest_rec; param2: PPChar): file_type_e; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; +{$endif} + +{.$ifdef CORE_PRIVATE} + +{ + * Core is also unlike other modules in being implemented in more than + * one file... so, data structures are declared here, even though most of + * the code that cares really is in http_core.c. Also, another accessor. + } + +//API_EXPORT(char *) ap_response_code_string (request_rec *r, int error_index); + +//extern API_VAR_EXPORT module core_module; + +{ Per-directory configuration } + +type + allow_options_t = Char; + overrides_t = Char + ; +{ + * Bits of info that go into making an ETag for a file + * document. Why a long? Because char historically + * proved too short for Options, and int can be different + * sizes on different platforms. + } + etag_components_t = culong; + +const + ETAG_UNSET = 0; + ETAG_NONE = (1 shl 0); + ETAG_MTIME = (1 shl 1); + ETAG_INODE = (1 shl 2); + ETAG_SIZE = (1 shl 3); + ETAG_BACKWARD = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE); + ETAG_ALL = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE); + + { Things moved up } + + HOSTNAME_LOOKUP_OFF = 0; + HOSTNAME_LOOKUP_ON = 1; + HOSTNAME_LOOKUP_DOUBLE= 2; + HOSTNAME_LOOKUP_UNSET = 3; + + USE_CANONICAL_NAME_OFF = (0); + USE_CANONICAL_NAME_ON = (1); + USE_CANONICAL_NAME_DNS = (2); + USE_CANONICAL_NAME_UNSET= (3); + + ADD_DEFAULT_CHARSET_OFF = (0); + ADD_DEFAULT_CHARSET_ON = (1); + ADD_DEFAULT_CHARSET_UNSET = (2); + +{$ifdef CHARSET_EBCDIC} + + { Configurable EBCDIC Conversion stuff } + { Direction specific conversion: } + dir_Out = 0; { 0utput (returned contents in a GET or POST) } + dir_In = 1; { 1nput (uploaded contents in a PUT / POST) } + + { Conversion Enabled/Disabled: } + conv_Unset = '?'; { Conversion unconfigured } + conv_Off = '0'; { BINARY or ASCII file (no conversion) } + conv_On = '1'; { TEXT file (EBCDIC->ASCII for dir_Out; ASCII->EBCDIC for dir_In) } + + LEGACY_KLUDGE = 1; { After a couple of versions this legacy kludge should be set to 0 } + ASCIITEXT_MAGIC_TYPE_PREFIX = 'text/x-ascii-'; { Text files whose content-type starts with this are passed thru unconverted } + +{$endif} + +type + ap_flag_e = ( + AP_FLAG_UNSET = 0, + AP_FLAG_ON = 1, + AP_FLAG_OFF = 2 + ); + + server_signature_t = ( srv_sig_unset, srv_sig_off, srv_sig_on, + srv_sig_withmail); + + + core_dir_config = record + { path of the directory/regex/etc. see also d_is_fnmatch below } + d: PChar; + { the number of slashes in d } + d_components: cuint; + + { If (opts & OPT_UNSET) then no absolute assignment to options has + * been made. + * invariant: (opts_add & opts_remove) == 0 + * Which said another way means that the last relative (options + or -) + * assignment made to each bit is recorded in exactly one of opts_add + * or opts_remove. + } + opts: allow_options_t; + opts_add: allow_options_t; + opts_remove: allow_options_t; + override_: overrides_t; + + { MIME typing --- the core doesn't do anything at all with this, + * but it does know what to slap on a request for a document which + * goes untyped by other mechanisms before it slips out the door... + } + + ap_default_type: PChar; + + { Authentication stuff. Groan... } + + satisfy: cint; + ap_auth_type: PChar; + ap_auth_name: PChar; + ap_requires: Parray_header; + + { Custom response config. These can contain text or a URL to redirect to. + * if response_code_strings is NULL then there are none in the config, + * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES. + * This lets us do quick merges in merge_core_dir_configs(). + } + + response_code_strings: PPChar; { from ErrorDocument, not from + * ap_custom_response() + } + + { Hostname resolution etc } + + { Moved Up } + +// unsigned int hostname_lookups : 4; + +// signed int do_rfc1413 : 2; { See if client is advertising a username? } + +// signed int content_md5 : 2; { calculate Content-MD5? } + + { Moved Up } + +// unsigned use_canonical_name : 2; + + { since is_fnmatch(conf->d) was being called so frequently in + * directory_walk() and its relatives, this field was created and + * is set to the result of that call. + } +// unsigned d_is_fnmatch : 1; + + { should we force a charset on any outgoing parameterless content-type? + * if so, which charset? + } + + { Moved up } + +// unsigned add_default_charset : 2; + add_default_charset_name: PChar; + + { System Resource Control } +{$ifdef RLIMIT_CPU} + limit_cpu: Prlimit; +{$endif} +{$if defined(RLIMIT_DATA) or defined(RLIMIT_VMEM) or defined(RLIMIT_AS)} + limit_mem: Prlimit; +{$endif} +{$ifdef RLIMIT_NPROC} + limit_nproc: Prlimit; +{$endif} + limit_req_body: culong; { limit on bytes in request msg body } + + { logging options } + server_signature: server_signature_t; + loglevel: cint; + + { Access control } + sec: Parray_header; + r: Pregex_t; + +{$ifdef WINDOWS} + { Where to find interpreter to run scripts } + script_interpreter_source: interpreter_source_e; +{$endif} + +{$ifdef CHARSET_EBCDIC} + + { Moved up } + + { The configuration args {On|Off}[={In|Out|InOut}] are currently stored + * as character strings ("0" = conv_Off, "1" = conv_On) + } + ebcdicconversion_by_ext_in: Ptable; + ebcdicconversion_by_ext_out: Ptable; + ebcdicconversion_by_type_in: Ptable; + ebcdicconversion_by_type_out: Ptable; + + { Moved up } + + x_ascii_magic_kludge: cint; { whether to handle the text/x-ascii- kludge } + +{$ifdef ADD_EBCDICCONVERT_DEBUG_HEADER} + ebcdicconversion_debug_header: cint; { whether to add an X-EBCDIC-Debug-{In,Out} header to the response } +{$endif} +{$endif} { CHARSET_EBCDIC } + + { + * What attributes/data should be included in ETag generation? + } + etag_bits: etag_components_t; + etag_add: etag_components_t; + etag_remove: etag_components_t; + + { + * Do we allow ISINDEX CGI scripts to pass their query argument as + * direct command line parameters or argv elements? + } + cgi_command_args: ap_flag_e; + + { Digest auth. } + ap_auth_nonce: PChar; + + end; + +{ Per-server core configuration } + +type + core_server_config = record + +{$ifdef GPROF} + gprof_dir: PChar; +{$endif} + + { Name translations --- we want the core to be able to do *something* + * so it's at least a minimally functional web server on its own (and + * can be tested that way). But let's keep it to the bare minimum: + } + ap_document_root: PChar; + + { Access control } + + access_name: PChar; + sec: Parray_header; + sec_url: Parray_header; + + { recursion backstopper } + recursion_limit_set: cint; { boolean } + redirect_limit: cint; { maximum number of internal redirects } + subreq_limit: cint; { maximum nesting level of subrequests } + + { TRACE control } + trace_enable: cint; { see AP_TRACE_ below } + + end; + +{ trace_enable options } +const + AP_TRACE_UNSET =-1; + AP_TRACE_DISABLE = 0; + AP_TRACE_ENABLE = 1; + AP_TRACE_EXTENDED = 2; + +{ for http_config.c } +//CORE_EXPORT(void) ap_core_reorder_directories(pool *, server_rec *); + +{ for mod_perl } +//CORE_EXPORT(void) ap_add_per_dir_conf (server_rec *s, void *dir_config); +//CORE_EXPORT(void) ap_add_per_url_conf (server_rec *s, void *url_config); +//CORE_EXPORT(void) ap_add_file_conf(core_dir_config *conf, void *url_config); +//CORE_EXPORT_NONSTD(const char *) ap_limit_section (cmd_parms *cmd, void *dummy, const char *arg); + +{.$endif} + diff --git a/packages/httpd13/src/http_log.inc b/packages/httpd13/src/http_log.inc new file mode 100644 index 0000000000..2dcffb18b2 --- /dev/null +++ b/packages/httpd13/src/http_log.inc @@ -0,0 +1,126 @@ +{ 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 <syslog.h> + + 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 WINDOWS} +{ 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__ + +procedure ap_open_logs(s: Pserver_rec; p: PPool); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ 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; + +// __attribute__((format(printf,5,6))); + +procedure ap_log_rerror( + const file_: PChar; line, level: Integer; + const s: Prequest_rec; const fmt: PChar; others: array of const); + cdecl; external LibHTTPD; + +// __attribute__((format(printf,5,6))); + +procedure ap_error_log2stderr(s: Pserver_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_log_pid(p: PPool; fname: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ 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; + + Ppiped_log = ^piped_log; + +procedure ap_open_piped_log(p: PPool; const program_: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_close_piped_log(p: Ppiped_log): Ppiped_log; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{#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/packages/httpd13/src/http_main.inc b/packages/httpd13/src/http_main.inc new file mode 100644 index 0000000000..10547159a7 --- /dev/null +++ b/packages/httpd13/src/http_main.inc @@ -0,0 +1,160 @@ +{ 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. + } + +procedure ap_start_shutdown(); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_start_restart(param: cint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_hard_timeout(p: PChar; r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_keepalive_timeout(p: PChar; r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_soft_timeout(p: PChar; r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_kill_timeout(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_reset_timeout(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + + +//procedure ap_child_terminate(r: Prequest_rec); +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_sync_scoreboard_image(); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_update_child_status(child_num, status: cint; r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ void ap_time_process_request(int child_num, int status); } + +type + fn_t = procedure (param: cint); + +function ap_set_callback_and_alarm(fn: fn_t; x: cint): cuint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_check_alarm(): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ 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. + } +type + maintenance_t = procedure (reason: cint; data: Pointer; status: ap_wait_t); + +procedure ap_register_other_child(pid: cint; + maintenance: maintenance_t; data: Pointer; write_fd: cint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +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. + } +procedure ap_unregister_other_child(data: Pointer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{$endif} + diff --git a/packages/httpd13/src/http_protocol.inc b/packages/httpd13/src/http_protocol.inc new file mode 100644 index 0000000000..733f05b635 --- /dev/null +++ b/packages/httpd13/src/http_protocol.inc @@ -0,0 +1,239 @@ +{ 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. } + +function ap_read_request(c: Pconn_rec): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Send a single HTTP header field } + +function ap_send_header_field(r: Prequest_rec; const fieldname, fieldval: PChar): cint; + cdecl; external LibHTTPD; + +{ 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(). + } +procedure ap_basic_http_header(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Send the Status-Line and header fields for HTTP response } + +procedure ap_send_http_header(l: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Send the response to special method requests } + +function ap_send_http_trace(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_send_http_options(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Finish up stuff after a request } + +procedure ap_finalize_request_protocol(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ 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. + } + +procedure ap_send_error_response(r: Prequest_rec; recursive_error: cint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ 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). + } + +function ap_set_content_length(r: Prequest_rec; length: clong): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_set_keepalive(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_rationalize_mtime(r: Prequest_rec; mtime: time_t): time_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_make_etag(r: Prequest_rec; force_weak: cint): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_set_etag(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_set_last_modified(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_meets_conditions(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ 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). + } + +//function ap_send_fd(f: PFILE; r: Prequest_rec): clong; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +//function ap_send_fd_length(f: PFILE; r: Prequest_rec; length: clong): clong; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_send_fb(f: PBUFF; r: Prequest_rec): clong; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_send_fb_length(f: PBUFF; r: Prequest_rec): clong; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_send_mmap(mm: Pointer; r: Prequest_rec; offset, length: size_t): size_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Hmmm... could macrofy these for now, and maybe forever, though the + * definitions of the macros would get a whole lot hairier. + } + +function ap_rputc(c: cint; r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_rputs(const str: PChar; r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_rwrite(const buf: Pointer; nbyte: cint; r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_rvputs(r: Prequest_rec; others: array of const): cint; + cdecl; external LibHTTPD; + +function ap_vrprintf(r: Prequest_rec; const fmt: PChar; vlist: va_list): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_rprintf(r: Prequest_rec; const fmt: PChar; others: array of const): cint; + cdecl; external LibHTTPD; + +{ __attribute__((format(printf,2,3)));} + +function ap_rflush(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ + * Index used in custom_responses array for a specific error code + * (only use outside protocol.c is in getting them configured). + } + +function ap_index_of_response(status: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Reading a block of data from the client connection (e.g., POST arg) } + +function ap_setup_client_block(r: Prequest_rec; read_policy: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_should_client_block(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_get_client_block(r: Prequest_rec; buffer: PChar; bufsiz: cint): clong; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_discard_request_body(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ Sending a byterange } + +function ap_set_byterange(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_each_byterange(r: Prequest_rec; offset, length: Pclong): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ 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. + * + } + +procedure ap_note_auth_failure(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_note_basic_auth_failure(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_note_digest_auth_failure(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_get_basic_auth_pw(r: Prequest_rec; const pw: PPChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ + * Setting up the protocol fields for subsidiary requests... + * Also, a wrapup function to keep the internal accounting straight. + } + +procedure ap_set_sub_req_protocol(rnew, r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_finalize_sub_req_protocol(sub_r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ 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. + } +function ap_method_number_of(const method: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_getline(s: PChar; n: cint; in_: PBUFF; fold: cint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_get_chunk_size(b: PChar): clong; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + diff --git a/packages/httpd13/src/http_request.inc b/packages/httpd13/src/http_request.inc new file mode 100644 index 0000000000..dbc77ea423 --- /dev/null +++ b/packages/httpd13/src/http_request.inc @@ -0,0 +1,82 @@ +{ 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. + } + +function ap_sub_req_lookup_uri(const new_file: PChar; + const r: Prequest_rec): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_sub_req_lookup_file(const new_file: PChar; + const r: Prequest_rec): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_sub_req_method_uri(const method, new_file: PChar; + const r: Prequest_rec): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + + +function ap_run_sub_req(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_destroy_sub_req(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ + * 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. + } + +procedure ap_internal_redirect(const new_uri: PChar; param2: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_internal_redirect_handler(const new_uri: PChar; param2: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_some_auth_required(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_is_initial_req(r: Prequest_rec): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_update_mtime(r: Prequest_rec; dependency_mtime: time_t): time_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{$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/packages/httpd13/src/http_vhost.inc b/packages/httpd13/src/http_vhost.inc new file mode 100644 index 0000000000..869738bc09 --- /dev/null +++ b/packages/httpd13/src/http_vhost.inc @@ -0,0 +1,49 @@ +{ 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. + } + +{ called before any config is read } +procedure ap_init_vhost_config(p: PPool); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ called after the config has been read } +procedure ap_fini_vhost_config(p: PPool; main_server: Pserver_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ handle addresses in <VirtualHost> statement } +function ap_parse_vhost_addrs(p: PPool; const hostname: PChar; s: Pserver_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ handle NameVirtualHost directive } +//function ap_set_name_virtual_host(cmd: Pcmd_parms; dummy: Pointer; arg: PChar): PChar; +// cdecl; external LibHTTPD; + +{ given an ip address only, give our best guess as to what vhost it is } +procedure ap_update_vhost_given_ip(conn: Pconn_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ The above is never enough, and this is always called after the headers + * have been read. It may change r->server. + } +procedure ap_update_vhost_from_headers(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ return 1 if the host:port matches any of the aliases of r->server + * return 0 otherwise + } +function ap_matches_request_vhost(r: Prequest_rec; const host: PChar; + port: cuint): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + diff --git a/packages/httpd13/src/httpd.inc b/packages/httpd13/src/httpd.inc new file mode 100644 index 0000000000..ac96740d2f --- /dev/null +++ b/packages/httpd13/src/httpd.inc @@ -0,0 +1,1267 @@ +{ 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(WINDOWS)} + 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(WINDOWS)} +{ 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 WINDOWS} + 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 = '<!DOCTYPE HTML PUBLIC "-//IETF//' + + 'DTD HTML 2.0//EN">' + LineEnding; + DOCTYPE_HTML_3_2 = '<!DOCTYPE HTML PUBLIC "-//W3C//' + + 'DTD HTML 3.2 Final//EN">' + LineEnding; + DOCTYPE_HTML_4_0S = '<!DOCTYPE HTML PUBLIC "-//W3C//' + + 'DTD HTML 4.0//EN"' + LineEnding + + '"http://www.w3.org/TR/REC-html40/strict.dtd">' + LineEnding; + DOCTYPE_HTML_4_0T = '<!DOCTYPE HTML PUBLIC "-//W3C//' + + 'DTD HTML 4.0 Transitional//EN"' + LineEnding + + '"http://www.w3.org/TR/REC-html40/loose.dtd">' + LineEnding; + DOCTYPE_HTML_4_0F = '<!DOCTYPE HTML PUBLIC "-//W3C//' + + 'DTD HTML 4.0 Frameset//EN"' + LineEnding + + '"http://www.w3.org/TR/REC-html40/frameset.dtd">' + 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. + } + CR = '\r'; + LF = '\n'; + 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 <VirtualHost> } + 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; + + tm = record end; + + Ptm = ^tm; + +{ 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];} + +function ap_get_gmtoff(tz: Pcint): Ptm; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_get_time: PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_field_noparam(p: Ppool; const intype: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_ht_time(p: Ppool; t: time_t; const fmt: PChar; gmt: cint): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_gm_timestr_822(p: Ppool; t: time_t): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{ 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 **) } + +function ap_getword(p: Ppool; const line: PPChar; stop: Char): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_getword_nc(p: Ppool; line: PPChar; stop: Char): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_getword_white(p: Ppool; const line: PPChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_getword_white_nc(p: Ppool; line: PPChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_getword_nulls(p: Ppool; const line: PPChar; stop: Char): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_getword_nulls_nc(p: Ppool; line: PPChar; stop: Char): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_getword_conf(p: Ppool; const line: PPChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_getword_conf_nc(p: Ppool; line: PPChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + + +function ap_size_list_item(const field: PPChar; len: Pcint): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_get_list_item(p: Ppool; const field: PPChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_find_list_item(p: Ppool; const line, tok: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + + +function ap_get_token(p: Ppool; const accept_line: PPChar; accept_white: cint): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_find_token(p: Ppool; const line, tok: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_find_last_token(p: Ppool; const line, tok: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + + +function ap_unescape_url(url: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_no2slash(name: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_getparents(name: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_escape_path_segment(p: Ppool; const s: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_os_escape_path(p: Ppool; const path: PChar; partial: cint): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +//#define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1) + +function ap_escape_html(p: Ppool; const s: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{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) or defined(WINDOWS)} +//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 } + +function ap_uname2id(const name: PChar): uid_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_gname2id(const name: PChar): gid_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_is_directory(const name: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_is_rdirectory(const name: PChar): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +function ap_can_exec(const stat: Pointer): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +procedure ap_chdir_file(const file_: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{$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 WINDOWS} +//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); +{$else}{$ifdef 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); +{$else}{$ifdef 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} +{$endif} +{$endif} +{$endif} + +{$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; + + 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); +const + AP_SLACK_LOW = 1; + 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; + + Pap_exception_info_t = ^ap_exception_info_t; + +{ 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. + } + fn_afeh_t = procedure (param: Pap_exception_info_t); + +function ap_add_fatal_exception_hook(fn: fn_afeh_t): cint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; + +{$endif} { AP_ENABLE_EXCEPTION_HOOK } + diff --git a/packages/httpd13/src/httpd.pas b/packages/httpd13/src/httpd.pas new file mode 100644 index 0000000000..d050e1573a --- /dev/null +++ b/packages/httpd13/src/httpd.pas @@ -0,0 +1,178 @@ +{ + 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 WIN64} + {$DEFINE WINDOWS} +{$ENDIF} + +{$ifdef Unix} + {$PACKRECORDS C} +{$endif} + +{$define Apache1_3} + +interface + +uses +{$ifdef WINDOWS} + Windows, +{$ELSE} + UnixType, +{$ENDIF} + ctypes; + +const +{$ifndef fpc} + LineEnding = #13#10; +{$endif} + +{$IFDEF WINDOWS} + LibHTTPD = 'ApacheCore.dll'; +{$ELSE} + LibHTTPD = ''; +{$ENDIF} + +{ Declarations moved here to be on top of all declarations } + +{ Various types} +type + time_t = LongInt; + size_t = Integer; + +{ 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; + +{ 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(PtrInt(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(PtrInt(v) + m^.module_index); + P^ := val; +end; + +end. + diff --git a/packages/httpd13/src/readdir.inc b/packages/httpd13/src/readdir.inc new file mode 100644 index 0000000000..1232223a78 --- /dev/null +++ b/packages/httpd13/src/readdir.inc @@ -0,0 +1,77 @@ +{ 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. + } + +{ + * Structures and types used to implement opendir/readdir/closedir + * on Windows 95/NT. + } + +{$ifdef WINDOWS} + +{#include <io.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> + +#ifndef API_EXPORT +# define API_EXPORT(type) __declspec(dllexport) type __stdcall +#endif} + +{ struct dirent - same as Unix } + +const + _MAX_FNAME = 256; + +type + dirent = record + d_ino: clong; { inode (always 1 in WIN32) } + d_off: off_t; { offset to this dirent } + d_reclen: cushort; { length of d_name } + d_name: array[0.._MAX_FNAME] of Char; { filename (null terminated) } + end; + +{ typedef DIR - not the same as Unix } + DIR = record + handle: clong; { _findfirst/_findnext handle } + offset: cshort; { offset into directory } + finished: cshort; { 1 if there are not more files } +// struct _finddata_t fileinfo; { from _findfirst/_findnext } + fileinfo: Pointer; { from _findfirst/_findnext } + dir: PChar; { the dir we are reading } + dent: dirent; { the dirent to return } + end; + + PDIR = ^DIR; + +{ Function prototypes } +{API_EXPORT(DIR *) opendir(const char *); +API_EXPORT(struct dirent *) readdir(DIR *); +API_EXPORT(int) closedir(DIR *);} + + va_list = Pointer; + +{ + * Simplified declarations for other platforms + } + +{$else} + + PDIR = Pointer; + + va_list = Pointer; + +{$endif} { WINDOWS } + diff --git a/packages/httpd13/src/util_uri.inc b/packages/httpd13/src/util_uri.inc new file mode 100644 index 0000000000..e12887a216 --- /dev/null +++ b/packages/httpd13/src/util_uri.inc @@ -0,0 +1,84 @@ +{ 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. + } + +{ + * util_uri.h: External Interface of util_uri.c + } + +type + schemes_t = record + name: PChar; + default_port: cushort; + end; + +const + DEFAULT_FTP_DATA_PORT = 20; + DEFAULT_FTP_PORT = 21; + DEFAULT_GOPHER_PORT = 70; + DEFAULT_NNTP_PORT = 119; + DEFAULT_WAIS_PORT = 210; + DEFAULT_SNEWS_PORT = 563; + DEFAULT_PROSPERO_PORT = 1525; { WARNING: conflict w/Oracle } + + DEFAULT_URI_SCHEME = 'http'; + +{ Flags passed to unparse_uri_components(): } + UNP_OMITSITEPART = (1 shl 0); { suppress "scheme://user@site:port" } + UNP_OMITUSER = (1 shl 1); { Just omit user } + UNP_OMITPASSWORD = (1 shl 2); { Just omit password } + UNP_OMITUSERINFO = (UNP_OMITUSER or UNP_OMITPASSWORD); { omit "user:password@" part } + UNP_REVEALPASSWORD = (1 shl 3); { Show plain text password (default: show XXXXXXXX) } + UNP_OMITPATHINFO = (1 shl 4); { Show "scheme://user@site:port" only } + UNP_OMITQUERY = (1 shl 5); { Omit the "?queryarg" from the path } + +type + hostent = record end; + Phostent = ^hostent; + + uri_components = record + scheme: PChar; { scheme ("http"/"ftp"/...) } + hostinfo: PChar; { combined [user[:password]@]host[:port] } + user: PChar; { user name, as in http://user:passwd@host:port/ } + password: PChar; { password, as in http://user:passwd@host:port/ } + hostname: PChar; { hostname from URI (or from Host: header) } + port_str: PChar; { port string (integer representation is in "port") } + path: PChar; { the request path (or "/" if only scheme://host was given) } + query: PChar; { Everything after a '?' in the path, if present } + fragment: PChar; { Trailing "#fragment" string, if present } + + hostent: Phostent; + + port: cushort; { The port number, numeric, valid only if port_str != NULL } + +// unsigned is_initialized:1; + +// unsigned dns_looked_up:1; +// unsigned dns_resolved:1; + + end; + +{ util_uri.c } +{API_EXPORT(unsigned short) ap_default_port_for_scheme(const char *scheme_str); +API_EXPORT(unsigned short) ap_default_port_for_request(const request_rec *r); +API_EXPORT(struct hostent *) ap_pduphostent(pool *p, const struct hostent *hp); +API_EXPORT(struct hostent *) ap_pgethostbyname(pool *p, const char *hostname); +API_EXPORT(char *) ap_unparse_uri_components(pool *p, const uri_components *uptr, + unsigned flags); +API_EXPORT(int) ap_parse_uri_components(pool *p, const char *uri, uri_components *uptr); +API_EXPORT(int) ap_parse_hostinfo_components(pool *p, const char *hostinfo, uri_components *uptr);} +{ called by the core in main() } +//extern void ap_util_uri_init(void); + diff --git a/packages/httpd13/src/win32_os.inc b/packages/httpd13/src/win32_os.inc new file mode 100644 index 0000000000..8371922245 --- /dev/null +++ b/packages/httpd13/src/win32_os.inc @@ -0,0 +1,191 @@ +{ 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 WINDOWS} + +{ + * Compile the server including all the Windows NT 4.0 header files by + * default. We still want the server to run on Win95/98 so use + * runtime checks before calling NT specific functions to verify we are + * really running on an NT system. + } +const + _WIN32_WINNT = $0400; + +{ If it isn't too late, prevent windows.h from including the original + * winsock.h header, so that we can still include winsock2.h + } +{#if !defined(_WINSOCKAPI_) || !defined(_WINDOWS_) +#define _WINSOCKAPI_ +#include <windows.h> +#include <winsock2.h> +#include <mswsock.h> +#else +#include <windows.h> +#endif +#include <process.h> +#include <malloc.h> +#include <io.h> +#include <fcntl.h>} + + PLATFORM = 'Win32'; + +{ + * This file in included in all Apache source code. It contains definitions + * of facilities available on _this_ operating system (HAVE_* macros), + * and prototypes of OS specific functions defined in os.c + } + +{ temporarily replace crypt } +{ char *crypt(const char *pw, const char *salt); } +//#define crypt(buf,salt) (buf) + +{ Although DIR_TYPE is dirent (see nt/readdir.h) we need direct.h for + chdir() } +//#include <direct.h> + +{$define STATUS} +{$define STRICT} +{$define CASE_BLIND_FILESYSTEM} +{$define NO_WRITEV} +{$define NO_SETSID} +{$define NO_USE_SIGACTION} +{$define NO_TIMES} +{$define NO_GETTIMEOFDAY} +{$define USE_LONGJMP} +{$define HAVE_MMAP} +{$define USE_MMAP_SCOREBOARD} +{$define MULTITHREAD} +{$define HAVE_CANONICAL_FILENAME} +{$define HAVE_DRIVE_LETTERS} +{$define HAVE_UNC_PATHS} + +type + uid_t = cint; + gid_t = cint; + pid_t = cint; + Ppid_t = ^pid_t; + tid_t = cint; +{$ifdef _MSC_VER} +{ modified to match declaration in sys/stat.h } + mode_t = cushort; +{$endif} + caddr_t = PChar; + +{ +Define export types. API_EXPORT_NONSTD is a nasty hack to avoid having to declare +every configuration function as __stdcall. +} + +{#ifdef SHARED_MODULE +#define API_VAR_EXPORT __declspec(dllimport) +#define API_EXPORT(type) __declspec(dllimport) type __stdcall +#define API_EXPORT_NONSTD(type) __declspec(dllimport) type __cdecl +#else +#define API_VAR_EXPORT __declspec(dllexport) +#define API_EXPORT(type) __declspec(dllexport) type __stdcall +#define API_EXPORT_NONSTD(type) __declspec(dllexport) type __cdecl +#endif +#define MODULE_VAR_EXPORT __declspec(dllexport) + +#define strcasecmp(s1, s2) stricmp(s1, s2) +#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n) +#define lstat(x, y) stat(x, y) +#ifndef S_ISLNK +#define S_ISLNK(m) (0) +#endif +#ifndef S_ISREG +#define S_ISREG(m) ((m & _S_IFREG) == _S_IFREG) +#endif +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR) +#endif +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#define JMP_BUF jmp_buf +#define sleep(t) Sleep(t*1000) +#ifndef O_CREAT +#define O_CREAT _O_CREAT +#endif +#ifndef O_RDWR +#define O_RDWR _O_RDWR +#endif +#define SIGPIPE 17} +{ Seems Windows is not a subgenius } +{$define NO_SLACK} +//#include <stddef.h> + +{ MSVC asserts that strtol "errno is set to ERANGE + * if overflow or underflow occurs" + * Ergo we can use the library strtol safely. + } +//#define ap_strtol strtol + +{$define NO_OTHER_CHILD} +{$define NO_RELIABLE_PIPED_LOGS} + +//__inline int ap_os_is_path_absolute(const char *file) +{ + For now, just do the same check that http_request.c and mod_alias.c + * do. + + return file && (file[0] == '/' || (file[1] == ':' && file[2] == '/')); +} + +{#define stat(f,ps) os_stat(f,ps) +API_EXPORT(int) os_stat(const char *szPath,struct stat *pStat); + +API_EXPORT(int) os_strftime(char *s, size_t max, const char *format, const struct tm *tm); + +#define _spawnv(mode,cmdname,argv) os_spawnv(mode,cmdname,argv) +#define spawnv(mode,cmdname,argv) os_spawnv(mode,cmdname,argv) +API_EXPORT(int) os_spawnv(int mode,const char *cmdname,const char *const *argv); +#define _spawnve(mode,cmdname,argv,envp) os_spawnve(mode,cmdname,argv,envp) +#define spawnve(mode,cmdname,argv,envp) os_spawnve(mode,cmdname,argv,envp) +API_EXPORT(int) os_spawnve(int mode,const char *cmdname,const char *const *argv,const char *const *envp); +#define _spawnle os_spawnle +#define spawnle os_spawnle +API_EXPORT_NONSTD(int) os_spawnle(int mode,const char *cmdname,...);} + +{ OS-dependent filename routines in util_win32.c } + +//API_EXPORT(int) ap_os_is_filename_valid(const char *file); + +{ Abstractions for dealing with shared object files (DLLs on Win32). + * These are used by mod_so.c + } +{#define ap_os_dso_handle_t HINSTANCE +#define ap_os_dso_init() +#define ap_os_dso_unload(l) FreeLibrary(l) +#define ap_os_dso_sym(h,s) GetProcAddress(h,s) + +API_EXPORT(ap_os_dso_handle_t) ap_os_dso_load(const char *); +API_EXPORT(const char *) ap_os_dso_error(void);} + +{ Other ap_os_ routines not used by this platform } +//#define ap_os_kill(pid, sig) kill(pid, sig) + +{ Some Win32isms } +{$define HAVE_ISNAN} +//#define isnan(n) _isnan(n) +{$define HAVE_ISINF} +//#define isinf(n) (!_finite(n)) + +//#define gettid() ((tid_t)GetCurrentThreadId()) + +{$endif} { WINDOWS } + |
