diff --git a/.gitattributes b/.gitattributes index 38db6da929..a8a2692afe 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2919,6 +2919,15 @@ packages/extra/imlib/fpmake.inc svneol=native#text/plain packages/extra/imlib/fpmake.pp svneol=native#text/plain packages/extra/imlib/gdk_imlib/gdk_imlib.pp svneol=native#text/plain packages/extra/imlib/imlib/imlib.pp svneol=native#text/plain +packages/extra/ldap/Makefile svneol=native#text/plain +packages/extra/ldap/lber.pas svneol=native#text/plain +packages/extra/ldap/lber_typesh.inc svneol=native#text/plain +packages/extra/ldap/lberh.inc svneol=native#text/plain +packages/extra/ldap/ldap.pas svneol=native#text/plain +packages/extra/ldap/ldap_featuresh.inc svneol=native#text/plain +packages/extra/ldap/ldap_schemah.inc svneol=native#text/plain +packages/extra/ldap/ldaph.inc svneol=native#text/plain +packages/extra/ldap/ntlm.pas svneol=native#text/plain packages/extra/libgd/Makefile svneol=native#text/plain packages/extra/libgd/Makefile.fpc svneol=native#text/plain packages/extra/libgd/README -text diff --git a/packages/extra/Makefile b/packages/extra/Makefile index e2f17a664a..47466e9f4a 100644 --- a/packages/extra/Makefile +++ b/packages/extra/Makefile @@ -1,5 +1,5 @@ # -# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/09/14] +# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/09/16] # 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 m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd x86_64-win64 arm-linux arm-palmos arm-wince arm-gba powerpc64-linux @@ -231,7 +231,7 @@ UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET)) endif PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra) ifeq ($(FULL_TARGET),i386-linux) -override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 unixutil +override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap unixutil endif ifeq ($(FULL_TARGET),i386-go32v2) override TARGET_DIRS+=unzip @@ -270,7 +270,7 @@ ifeq ($(FULL_TARGET),i386-wince) override TARGET_DIRS+=unzip zlib tcl fftw endif ifeq ($(FULL_TARGET),m68k-linux) -override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 +override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap endif ifeq ($(FULL_TARGET),m68k-freebsd) override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 md4 @@ -288,7 +288,7 @@ ifeq ($(FULL_TARGET),m68k-palmos) override TARGET_DIRS+=palmunits endif ifeq ($(FULL_TARGET),powerpc-linux) -override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 +override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap endif ifeq ($(FULL_TARGET),powerpc-netbsd) override TARGET_DIRS+=unzip zlib x11 opengl gtk syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 md4 @@ -300,7 +300,7 @@ ifeq ($(FULL_TARGET),powerpc-darwin) override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 univint endif ifeq ($(FULL_TARGET),sparc-linux) -override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 +override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap endif ifeq ($(FULL_TARGET),sparc-netbsd) override TARGET_DIRS+=unzip zlib x11 opengl gtk syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 md4 @@ -309,7 +309,7 @@ ifeq ($(FULL_TARGET),sparc-solaris) override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 endif ifeq ($(FULL_TARGET),x86_64-linux) -override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 +override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap endif ifeq ($(FULL_TARGET),x86_64-freebsd) override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 md4 @@ -318,7 +318,7 @@ ifeq ($(FULL_TARGET),x86_64-win64) override TARGET_DIRS+=unzip opengl gtk gtk2 zlib tcl cdrom fpgtk winunits fftw md4 endif ifeq ($(FULL_TARGET),arm-linux) -override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 +override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap endif ifeq ($(FULL_TARGET),arm-palmos) override TARGET_DIRS+=palmunits @@ -327,7 +327,7 @@ ifeq ($(FULL_TARGET),arm-wince) override TARGET_DIRS+=unzip zlib tcl fftw endif ifeq ($(FULL_TARGET),powerpc64-linux) -override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 +override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid md4 ldap endif override INSTALL_FPCPACKAGE=y override INSTALL_FPCSUBDIR=packages/extra @@ -1419,6 +1419,7 @@ TARGET_DIRS_FPGTK=1 TARGET_DIRS_NEWT=1 TARGET_DIRS_UUID=1 TARGET_DIRS_MD4=1 +TARGET_DIRS_LDAP=1 TARGET_DIRS_UNIXUTIL=1 endif ifeq ($(FULL_TARGET),i386-go32v2) @@ -1616,6 +1617,7 @@ TARGET_DIRS_FPGTK=1 TARGET_DIRS_NEWT=1 TARGET_DIRS_UUID=1 TARGET_DIRS_MD4=1 +TARGET_DIRS_LDAP=1 endif ifeq ($(FULL_TARGET),m68k-freebsd) TARGET_DIRS_UNZIP=1 @@ -1717,6 +1719,7 @@ TARGET_DIRS_FPGTK=1 TARGET_DIRS_NEWT=1 TARGET_DIRS_UUID=1 TARGET_DIRS_MD4=1 +TARGET_DIRS_LDAP=1 endif ifeq ($(FULL_TARGET),powerpc-netbsd) TARGET_DIRS_UNZIP=1 @@ -1793,6 +1796,7 @@ TARGET_DIRS_FPGTK=1 TARGET_DIRS_NEWT=1 TARGET_DIRS_UUID=1 TARGET_DIRS_MD4=1 +TARGET_DIRS_LDAP=1 endif ifeq ($(FULL_TARGET),sparc-netbsd) TARGET_DIRS_UNZIP=1 @@ -1865,6 +1869,7 @@ TARGET_DIRS_FPGTK=1 TARGET_DIRS_NEWT=1 TARGET_DIRS_UUID=1 TARGET_DIRS_MD4=1 +TARGET_DIRS_LDAP=1 endif ifeq ($(FULL_TARGET),x86_64-freebsd) TARGET_DIRS_UNZIP=1 @@ -1929,6 +1934,7 @@ TARGET_DIRS_FPGTK=1 TARGET_DIRS_NEWT=1 TARGET_DIRS_UUID=1 TARGET_DIRS_MD4=1 +TARGET_DIRS_LDAP=1 endif ifeq ($(FULL_TARGET),arm-palmos) TARGET_DIRS_PALMUNITS=1 @@ -1965,6 +1971,7 @@ TARGET_DIRS_FPGTK=1 TARGET_DIRS_NEWT=1 TARGET_DIRS_UUID=1 TARGET_DIRS_MD4=1 +TARGET_DIRS_LDAP=1 endif ifdef TARGET_DIRS_UNZIP unzip_all: @@ -3091,6 +3098,51 @@ md4: $(MAKE) -C md4 all .PHONY: md4_all md4_debug md4_smart md4_release md4_units md4_examples md4_shared md4_install md4_sourceinstall md4_exampleinstall md4_distinstall md4_zipinstall md4_zipsourceinstall md4_zipexampleinstall md4_zipdistinstall md4_clean md4_distclean md4_cleanall md4_info md4_makefiles md4 endif +ifdef TARGET_DIRS_LDAP +ldap_all: + $(MAKE) -C ldap all +ldap_debug: + $(MAKE) -C ldap debug +ldap_smart: + $(MAKE) -C ldap smart +ldap_release: + $(MAKE) -C ldap release +ldap_units: + $(MAKE) -C ldap units +ldap_examples: + $(MAKE) -C ldap examples +ldap_shared: + $(MAKE) -C ldap shared +ldap_install: + $(MAKE) -C ldap install +ldap_sourceinstall: + $(MAKE) -C ldap sourceinstall +ldap_exampleinstall: + $(MAKE) -C ldap exampleinstall +ldap_distinstall: + $(MAKE) -C ldap distinstall +ldap_zipinstall: + $(MAKE) -C ldap zipinstall +ldap_zipsourceinstall: + $(MAKE) -C ldap zipsourceinstall +ldap_zipexampleinstall: + $(MAKE) -C ldap zipexampleinstall +ldap_zipdistinstall: + $(MAKE) -C ldap zipdistinstall +ldap_clean: + $(MAKE) -C ldap clean +ldap_distclean: + $(MAKE) -C ldap distclean +ldap_cleanall: + $(MAKE) -C ldap cleanall +ldap_info: + $(MAKE) -C ldap info +ldap_makefiles: + $(MAKE) -C ldap makefiles +ldap: + $(MAKE) -C ldap all +.PHONY: ldap_all ldap_debug ldap_smart ldap_release ldap_units ldap_examples ldap_shared ldap_install ldap_sourceinstall ldap_exampleinstall ldap_distinstall ldap_zipinstall ldap_zipsourceinstall ldap_zipexampleinstall ldap_zipdistinstall ldap_clean ldap_distclean ldap_cleanall ldap_info ldap_makefiles ldap +endif ifdef TARGET_DIRS_UNIXUTIL unixutil_all: $(MAKE) -C unixutil all diff --git a/packages/extra/Makefile.fpc b/packages/extra/Makefile.fpc index 554fca6342..7c964284cb 100644 --- a/packages/extra/Makefile.fpc +++ b/packages/extra/Makefile.fpc @@ -6,7 +6,7 @@ dirs_linux=unzip zlib fftw \ x11 opengl gtk gtk2 syslog \ forms svgalib ggi libpng libgd \ utmp bfd gdbm ncurses tcl cdrom \ - imlib gnome1 fpgtk newt uuid md4 + imlib gnome1 fpgtk newt uuid md4 ldap dirs_i386_linux=unixutil dirs_netbsd=unzip zlib \ x11 opengl gtk syslog \ diff --git a/packages/extra/ldap/Makefile b/packages/extra/ldap/Makefile new file mode 100644 index 0000000000..14a0cf62d8 --- /dev/null +++ b/packages/extra/ldap/Makefile @@ -0,0 +1,1828 @@ +# +# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/09/16] +# +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 m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd x86_64-win64 arm-linux arm-palmos arm-wince arm-gba powerpc64-linux +BSDs = freebsd netbsd openbsd darwin +UNIXs = linux $(BSDs) solaris qnx +LIMIT83fs = go32v2 os2 emx 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 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)) +FPC:=$(shell $(FPCPROG) -PB) +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/base $(FPCDIR)/packages/extra) +override PACKAGE_NAME=ldap +override PACKAGE_VERSION=2.0.0 +ifeq ($(FULL_TARGET),i386-linux) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-go32v2) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-win32) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-os2) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-freebsd) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-beos) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-netbsd) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-solaris) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-qnx) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-netware) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-openbsd) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-wdosx) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-darwin) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-emx) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-watcom) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-netwlibc) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),i386-wince) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),m68k-linux) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),m68k-freebsd) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),m68k-netbsd) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),m68k-amiga) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),m68k-atari) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),m68k-openbsd) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),m68k-palmos) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),powerpc-linux) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),powerpc-netbsd) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),powerpc-amiga) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),powerpc-macos) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),powerpc-darwin) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),powerpc-morphos) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),sparc-linux) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),sparc-netbsd) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),sparc-solaris) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),x86_64-linux) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),x86_64-freebsd) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),x86_64-win64) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),arm-linux) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),arm-palmos) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),arm-wince) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),arm-gba) +override TARGET_UNITS+=lber ldap ntlm +endif +ifeq ($(FULL_TARGET),powerpc64-linux) +override TARGET_UNITS+=lber ldap ntlm +endif +override INSTALL_FPCPACKAGE=y +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 +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 +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),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),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),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),x86_64-linux) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),x86_64-freebsd) +REQUIRE_PACKAGES_RTL=1 +endif +ifeq ($(FULL_TARGET),x86_64-win64) +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),powerpc64-linux) +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) -Xc +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 +ifdef LINKSHARED +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)) +EXECPPAS:=@$(PPAS) +endif +endif +.PHONY: fpc_units +ifneq ($(TARGET_UNITS),) +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 %$(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 + $(ZIPWRAPPER) +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 diff --git a/packages/extra/ldap/lber.pas b/packages/extra/ldap/lber.pas new file mode 100644 index 0000000000..d44208c1fd --- /dev/null +++ b/packages/extra/ldap/lber.pas @@ -0,0 +1,94 @@ +unit lber; + +{$mode objfpc} + +interface + +{$linklib lber} + +{$include lber_typesh.inc} +{$include lberh.inc} + +implementation + +function LBER_INVALID(t: ber_tag_t): ber_tag_t; +// #define LBER_INVALID(t) (((t) & (ber_tag_t) = $080UL) && (((t) & (ber_tag_t) ~ = $0FF)) +begin + LBER_INVALID := (t and $80) and (t and $FF); +end; + +function LBER_OPT_ON: Pointer; +// #define LBER_OPT_ON ((void *) &ber_pvt_opt_on) +begin + LBER_OPT_ON := @ber_pvt_opt_on; +end; + +function LBER_SBIOD_READ_NEXT(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t; +// #define LBER_SBIOD_READ_NEXT( sbiod, buf, len ) ( (sbiod)->sbiod_next->sbiod_io->sbi_read( (sbiod)->sbiod_next, buf, len ) ) +begin + LBER_SBIOD_READ_NEXT := sbiod^.sbiod_next^.sbiod_io^.sbi_read(sbiod^.sbiod_next, buf, len); +end; + +function LBER_SBIOD_WRITE_NEXT(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t; +// #define LBER_SBIOD_WRITE_NEXT( sbiod, buf, len ) ( (sbiod)->sbiod_next->sbiod_io->sbi_write( (sbiod)->sbiod_next, buf, len ) ) +begin + LBER_SBIOD_WRITE_NEXT := sbiod^.sbiod_next^.sbiod_io^.sbi_write(sbiod^.sbiod_next, buf, len); +end; + +function LBER_SBIOD_CTRL_NEXT(sbiod: PSockbuf_IO_Desc; opt: cint; arg: Pointer): cint; +// #define LBER_SBIOD_CTRL_NEXT( sbiod, opt, arg ) ( (sbiod)->sbiod_next ? ( (sbiod)->sbiod_next->sbiod_io->sbi_ctrl( (sbiod)->sbiod_next, opt, arg ) ) : 0 ) +begin + if Assigned(sbiod^.sbiod_next) then + LBER_SBIOD_CTRL_NEXT := sbiod^.sbiod_next^.sbiod_io^.sbi_ctrl(sbiod^.sbiod_next, opt, arg) else + LBER_SBIOD_CTRL_NEXT := 0; +end; + +function ber_bvstr(const str: PChar): PBerval; +begin + ber_bvstr := ber_str2bv(str, 0, false, nil); +end; + +function ber_bvstrdup(const str: PChar): PBerval; +begin + ber_bvstrdup := ber_str2bv(str, 0, true, nil); +end; + +function memcmp(p1, p2: Pointer; len: cint): cint; +var + I: cint; +begin + for I := 0 to len -1 do + begin + if pbyte(p1)^ < pbyte(p2)^ then + begin + memcmp := -1; + Exit; + end; + + if pbyte(p1)^ > pbyte(p2)^ then + begin + memcmp := 1; + Exit; + end; + + inc(p1, 1); + inc(p2, 1); + end; + + memcmp := 0; +end; + +function ber_bvcmp(v1, v2: PBerval): cint; +// #define ber_bvcmp(v1,v2) ((v1)->bv_len < (v2)->bv_len ? -1 : ((v1)->bv_len > (v2)->bv_len ? 1 : memcmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) )) +begin + if v1^.bv_len < v2^.bv_len then ber_bvcmp := -1 else + if v1^.bv_len > v2^.bv_len then ber_bvcmp := 1 else + ber_bvcmp := memcmp(v1^.bv_val, v2^.bv_val, v1^.bv_len); +end; + +function ber_errno: cint; +begin + ber_errno := ber_errno_addr^; +end; + +end. diff --git a/packages/extra/ldap/lber_typesh.inc b/packages/extra/ldap/lber_typesh.inc new file mode 100644 index 0000000000..5dfe0653f0 --- /dev/null +++ b/packages/extra/ldap/lber_typesh.inc @@ -0,0 +1,66 @@ +(* include/lber_types.h. Generated by configure. *) +(* $OpenLDAP: pkg/ldap/include/lber_types.h.in,v 1.10.2.3 2005/01/20 17:00:58 kurt Exp $ *) +(* This work is part of OpenLDAP Software . + * + * Copyright 1998-2005 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + *) + +(* + * LBER types + *) + +uses + ctypes; + +type + PPPChar = ^PPChar; + +(* LBER Boolean, enum, integers (32 bits or larger) *) + LBER_INT_T = cint; + +(* LBER tags (32 bits or larger) *) + LBER_TAG_T = clong; + +(* LBER socket descriptor *) + LBER_SOCKET_T = cint; + +(* LBER lengths (32 bits or larger) *) + LBER_LEN_T = clong; + +(* ------------------------------------------------------------ *) + +(* Booleans, enumerations, and integers *) + pber_int_t = ^ber_int_t; + ber_int_t = cint; // LBER_INT_T; + +(* signed and unsigned versions *) + pber_sint_t = ^ber_sint_t; + ber_sint_t = csint; // signed LBER_INT_T + + pber_uint_t = ^ber_uint_t; + ber_uint_t = cuint; // unsigned LBER_INT_T + +(* tags *) + pber_tag_t = ^ber_tag_t; + ber_tag_t = culong; // unsigned LBER_TAG_T + +(* "socket" descriptors *) + pber_socket_t = ^ber_socket_t; + ber_socket_t = cint; // LBER_SOCKET_T + +(* lengths *) + pber_len_t = ^ber_len_t; + ber_len_t = culong; // unsigned LBER_LEN_T + +(* signed lengths *) + pber_slen_t = ^ber_slen_t; + ber_slen_t = clong; // signed LBER_LEN_T; diff --git a/packages/extra/ldap/lberh.inc b/packages/extra/ldap/lberh.inc new file mode 100644 index 0000000000..53687e0825 --- /dev/null +++ b/packages/extra/ldap/lberh.inc @@ -0,0 +1,427 @@ +(* $OpenLDAP: pkg/ldap/include/lber.h,v 1.83.2.11 2005/01/20 17:00:58 kurt Exp $ *) +(* This work is part of OpenLDAP Software . + * + * Copyright 1998-2005 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + *) +(* Portions Copyright (c) 1990 Regents of the University of Michigan. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of Michigan at Ann Arbor. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + *) + +(* Overview of LBER tag construction + * + * Bits + * ______ + * 8 7 | CLASS + * 0 0 = UNIVERSAL + * 0 1 = APPLICATION + * 1 0 = CONTEXT-SPECIFIC + * 1 1 = PRIVATE + * _____ + * | 6 | DATA-TYPE + * 0 = PRIMITIVE + * 1 = CONSTRUCTED + * ___________ + * | 5 ... 1 | TAG-NUMBER + *) + +const +(* BER classes and mask *) + LBER_CLASS_UNIVERSAL = ber_tag_t($00); + LBER_CLASS_APPLICATION = ber_tag_t($40); + LBER_CLASS_CONTEXT = ber_tag_t($80); + LBER_CLASS_PRIVATE = ber_tag_t($c0); + LBER_CLASS_MASK = ber_tag_t($c0); + +(* BER encoding type and mask *) + LBER_PRIMITIVE = ber_tag_t($00); + LBER_CONSTRUCTED = ber_tag_t($20); + LBER_ENCODING_MASK = ber_tag_t($20); + + LBER_BIG_TAG_MASK = ber_tag_t($1f); + LBER_MORE_TAG_MASK = ber_tag_t($80); + +(* + * Note that LBER_ERROR and LBER_DEFAULT are values that can never appear + * as valid BER tags, and so it is safe to use them to report errors. In + * fact, any tag for which the following is true is invalid: + *) +function LBER_INVALID(t: ber_tag_t): ber_tag_t; + +const + LBER_ERROR = ber_tag_t(-1); + LBER_DEFAULT = ber_tag_t(-1); + +(* general BER types we know about *) + LBER_BOOLEAN = ber_tag_t($01); + LBER_INTEGER = ber_tag_t($02); + LBER_BITSTRING = ber_tag_t($03); + LBER_OCTETSTRING = ber_tag_t($04); + LBER_NULL = ber_tag_t($05); + LBER_ENUMERATED = ber_tag_t($0a); + LBER_SEQUENCE = ber_tag_t($30); (* constructed *) + LBER_SET = ber_tag_t($31); (* constructed *) + +(* LBER BerElement options *) + LBER_USE_DER = $01; + +(* get/set options for BerElement *) + LBER_OPT_BER_OPTIONS = $01; + LBER_OPT_BER_DEBUG = $02; + LBER_OPT_BER_REMAINING_BYTES = $03; + LBER_OPT_BER_TOTAL_BYTES = $04; + LBER_OPT_BER_BYTES_TO_WRITE = $05; + LBER_OPT_BER_MEMCTX = $06; + + LBER_OPT_DEBUG_LEVEL = LBER_OPT_BER_DEBUG; + LBER_OPT_REMAINING_BYTES = LBER_OPT_BER_REMAINING_BYTES; + LBER_OPT_TOTAL_BYTES = LBER_OPT_BER_TOTAL_BYTES; + LBER_OPT_BYTES_TO_WRITE = LBER_OPT_BER_BYTES_TO_WRITE; + + LBER_OPT_LOG_PRINT_FN = $8001; + LBER_OPT_MEMORY_FNS = $8002; + LBER_OPT_ERROR_FN = $8003; + LBER_OPT_LOG_PRINT_FILE = $8004; + +(* get/set Memory Debug options *) + LBER_OPT_MEMORY_INUSE = $8005; (* for memory debugging *) + LBER_OPT_LOG_PROC = $8006; (* for external logging function *) + + +type + BER_ERRNO_FN = function: pcint; cdecl; + + BER_LOG_PRINT_FN = procedure(const buf: PChar); cdecl; + + BER_MEMALLOC_FN = function(size: ber_len_t): Pointer; cdecl; + BER_MEMCALLOC_FN = function(n: ber_len_t; size: ber_len_t): Pointer; cdecl; + BER_MEMREALLOC_FN = function(p: Pointer; size: ber_len_t): Pointer; cdecl; + BER_MEMFREE_FN = function(p: Pointer): Pointer; cdecl; + + plber_memory_fns = ^lber_memory_fns; + lber_memory_fns = record + bmf_malloc : BER_MEMALLOC_FN; + bmf_calloc : BER_MEMCALLOC_FN; + bmf_realloc : BER_MEMREALLOC_FN; + bmf_free : BER_MEMFREE_FN; + end; + + PBerMemoryFunctions = ^BerMemoryFunctions; + BerMemoryFunctions = lber_memory_fns; + +const +(* LBER Sockbuf_IO options *) + LBER_SB_OPT_GET_FD = 1; + LBER_SB_OPT_SET_FD = 2; + LBER_SB_OPT_HAS_IO = 3; + LBER_SB_OPT_SET_NONBLOCK = 4; + LBER_SB_OPT_GET_SSL = 7; + LBER_SB_OPT_DATA_READY = 8; + LBER_SB_OPT_SET_READAHEAD = 9; + LBER_SB_OPT_DRAIN = 10; + LBER_SB_OPT_NEEDS_READ = 11; + LBER_SB_OPT_NEEDS_WRITE = 12; + LBER_SB_OPT_GET_MAX_INCOMING = 13; + LBER_SB_OPT_SET_MAX_INCOMING = 14; +(* Largest option used by the library *) + LBER_SB_OPT_OPT_MAX = 14; + +(* LBER IO operations stacking levels *) + LBER_SBIOD_LEVEL_PROVIDER = 10; + LBER_SBIOD_LEVEL_TRANSPORT = 20; + LBER_SBIOD_LEVEL_APPLICATION = 30; + +(* get/set options for Sockbuf *) + LBER_OPT_SOCKBUF_DESC = $1000; + LBER_OPT_SOCKBUF_OPTIONS = $1001; + LBER_OPT_SOCKBUF_DEBUG = $1002; + + LBER_OPT_SUCCESS = 0; + LBER_OPT_ERROR = -1; + +(* on/off values *) +const + LBER_OPT_OFF = Pointer(0); + +var + ber_pvt_opt_on: char; cvar; external; + +function LBER_OPT_ON: Pointer; + +(* Structure for LBER IO operarion descriptor *) +type + PBerElement = Pointer; + + PSockbuf = Pointer; + + PSeqorset = Pointer; + + PSockbuf_IO = ^Sockbuf_IO; + + PSockbuf_IO_Desc = ^Sockbuf_IO_Desc; + Sockbuf_IO_Desc = record + sbiod_level : cint; + sbiod_sb : PSockbuf; + sbiod_io : PSockbuf_IO; + sbiod_pvt : Pointer; + sbiod_next : PSockbuf_IO_Desc; + end; + +(* Structure for LBER IO operation functions *) + Sockbuf_IO = record + sbi_setup : function(sbiod: PSockbuf_IO_Desc; arg: Pointer): cint; cdecl; + sbi_remove : function(sbiod: PSockbuf_IO_Desc): cint; cdecl; + sbi_ctrl : function(sbiod: PSockbuf_IO_Desc; opt: cint; arg: Pointer): cint; cdecl; + sbi_read : function(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t; cdecl; + sbi_write : function(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t; cdecl; + sbi_close : function(sbiod: PSockbuf_IO_Desc): cint; cdecl; + end; + +(* Helper macros for LBER IO functions *) +function LBER_SBIOD_READ_NEXT(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t; + +function LBER_SBIOD_WRITE_NEXT(sbiod: PSockbuf_IO_Desc; buf: Pointer; len: ber_len_t): ber_slen_t; + +function LBER_SBIOD_CTRL_NEXT(sbiod: PSockbuf_IO_Desc; opt: cint; arg: Pointer): cint; + + +(* structure for returning a sequence of octet strings + length *) +type + PPPBerval = ^PPBerval; + PPBerval = ^PBerval; + PBerval = ^Berval; + Berval = record + bv_len : ber_len_t; + bv_val : PChar; + end; + + PBerVarray = ^BerVarray; + BerVarray = ^PBerval; (* To distinguish from a single bv *) + + +(* this should be moved to lber-cint.h *) + +(* + * in bprint.c: + *) +procedure ber_error_print(const data: PChar); cdecl; external; + +procedure ber_bprint(const data: PChar; len: ber_len_t); cdecl; external; + +procedure ber_dump(ber: PBerElement; inout : cint); cdecl; external; + +procedure ber_sos_dump(sos: PSeqorset); cdecl; external; + + +(* + * in decode.c: + *) +type + BERDecodeCallback = function(ber: PBerElement; data: Pointer; mode: cint): cint; cdecl; + + +function ber_get_tag(ber: PBerElement): ber_tag_t; cdecl; external; + +function ber_skip_tag(ber: PBerElement; var len: ber_len_t): ber_tag_t; cdecl; external; + +function ber_peek_tag(ber: PBerElement; var len: ber_len_t): ber_tag_t; cdecl; external; + +function ber_get_int(ber: PBerElement; var num: ber_int_t): ber_tag_t; cdecl; external; + +function ber_get_enum(ber: PBerElement; var num: ber_int_t): ber_tag_t; cdecl; external; + +function ber_get_stringb(ber: PBerElement; buf: PChar; var len: ber_len_t): ber_tag_t; cdecl; external; + +function ber_get_stringbv(ber: PBerElement; bv: PBerval; alloc: cbool): ber_tag_t; cdecl; external; + +function ber_get_stringa(ber: PBerElement; var buf: PChar): ber_tag_t; cdecl; external; + +function ber_get_stringal(ber: PBerElement; var bv: PBerval): ber_tag_t; cdecl; external; + +function ber_get_bitstringa(ber: PBerElement; var buf: PChar; var len: ber_len_t): ber_tag_t; cdecl; external; + +function ber_get_null(ber: PBerElement): ber_tag_t; cdecl; external; + +function ber_get_Boolean(ber: PBerElement; var boolval: ber_int_t): ber_tag_t; cdecl; external; + +function ber_first_element(ber: PBerElement; var len: ber_len_t; var last: PChar): ber_tag_t; cdecl; external; + +function ber_next_element(ber: PBerElement; var len: ber_len_t; const last: PChar): ber_tag_t; cdecl; external; + +function ber_scanf(ber: PBerElement;const fmt: PChar): ber_tag_t; cdecl; varargs; external; + + +(* + * in encode.c + *) +type + BEREncodeCallback = function(ber: PBerElement; data: Pointer): cint; + + +function ber_put_enum(ber: PBerElement; num: ber_int_t; tag: ber_tag_t): cint; cdecl; external; + +function ber_put_int(ber: PBerElement; num: ber_int_t; tag: ber_tag_t): cint; cdecl; external; + +function ber_put_ostring(ber: PBerElement; const str: PChar; len: ber_len_t; tag: ber_tag_t): cint; cdecl; external; + +function ber_put_berval(ber: PBerElement; bv: PBerval; tag: ber_tag_t): cint; cdecl; external; + +function ber_put_string(ber: PBerElement; const str: PChar; tag: ber_tag_t): cint; cdecl; external; + +function ber_put_bitstring(ber: PBerElement; const str: PChar; bitlen: ber_len_t; tag: ber_tag_t): cint; cdecl; external; + +function ber_put_null(ber: PBerElement; tag: ber_tag_t): cint; cdecl; external; + +function ber_put_boolean(ber: PBerElement; boolval: ber_int_t; tag: ber_tag_t): cint; cdecl; external; + +function ber_start_seq(ber: PBerElement; tag: ber_tag_t): cint; cdecl; external; + +function ber_start_set(ber: PBerElement; tag: ber_tag_t): cint; cdecl; external; + +function ber_put_seq(ber: PBerElement): cint; cdecl; external; + +function ber_put_set(ber: PBerElement): cint; cdecl; external; + +function ber_printf(ber: PBerElement; const fmt: PChar): cint; cdecl; varargs; external; + + +(* + * in io.c: + *) + +function ber_read(ber: PBerElement; buf: PChar; len: ber_len_t): ber_slen_t; cdecl; external; + +function ber_write(ber: PBerElement; const buf: PChar; len: ber_len_t; nosos: cint): ber_slen_t; cdecl; external; + +procedure ber_free(ber: PBerElement; freebuf: cbool); cdecl; external; + +procedure ber_free_buf(ber: PBerElement); cdecl; external; + +function ber_flush(sb: PSockbuf; ber: PBerElement; freeit: cbool): cint; cdecl; external; + +function ber_alloc: PBerElement; cdecl; external; deprecated; + +function der_alloc: PBerElement; cdecl; external; deprecated; + +function ber_alloc_t(beroptions: cint): PBerElement; cdecl; external; + +function ber_dup(ber: PBerElement): PBerElement; cdecl; external; + +function ber_get_next(sb: PSockbuf; var len: ber_len_t; ber: PBerElement): ber_tag_t; cdecl; external; + +procedure ber_init2(ber: PBerElement; bv: PBerval; options: cint); cdecl; external; + +procedure ber_init_w_nullc(ber: PBerElement; options: cint); cdecl; external; deprecated; + +procedure ber_reset(ber: PBerElement; was_writing: cbool); cdecl; external; + +function ber_init(bv: PBerval): PBerElement; cdecl; external; + +function ber_flatten(ber: PBerElement; var bvPtr: PBerval): cint; cdecl; external; + +function ber_flatten2(ber: PBerElement; bv: PBerval; alloc: cbool): cint; cdecl; external; + +function ber_remaining(ber: PBerElement): cint; cdecl; external; + + +(* + * LBER ber accessor functions + *) + +function ber_get_option(item: Pointer; option: cint; outvalue: Pointer): cint; cdecl; external; + +function ber_set_option(item: Pointer; option: cint; const invalue: Pointer): cint; cdecl; external; + + +(* + * LBER sockbuf.c + *) + +function ber_sockbuf_alloc: PSockbuf; cdecl; external; + +procedure ber_sockbuf_free(sb: PSockbuf); cdecl; external; + +function ber_sockbuf_add_io(sb: PSockbuf; sbio: PSockbuf_IO; layer: cint; arg: Pointer): cint; cdecl; external; + +function ber_sockbuf_remove_io(sb: PSockbuf; sbio: PSockbuf_IO; layer: cint): cint; cdecl; external; + +function ber_sockbuf_ctrl(sb: PSockbuf; opt: cint; arg: Pointer): cint; cdecl; external; + +var + ber_sockbuf_io_tcp : Sockbuf_IO; cvar; external; + ber_sockbuf_io_readahead : Sockbuf_IO; cvar; external; + ber_sockbuf_io_fd : Sockbuf_IO; cvar; external; + ber_sockbuf_io_debug : Sockbuf_IO; cvar; external; +{$IFDEF LDAP_CONNECTIONLESS} + ber_sockbuf_io_udp : Sockbuf_IO; cvar; external; +{$ENDIF} + + +(* + * LBER memory.c + *) + +function ber_memalloc(s: ber_len_t): Pointer; cdecl; external; + +function ber_memrealloc(p: Pointer; s: ber_len_t): Pointer; cdecl; external; + +function ber_memcalloc(n: ber_len_t; s: ber_len_t): Pointer; cdecl; external; + +procedure ber_memfree(p: Pointer); cdecl; external; + +procedure ber_memvfree(vector: PPointer); cdecl; external; + +procedure ber_bvfree(bv: PBerval); cdecl; external; + +procedure ber_bvecfree(bv: PPBerval); cdecl; external; + +function ber_bvecadd(var bvec: PPPBerval; bv: PBerval): cint; cdecl; external; + +function ber_dupbv(dst: PBerval; src: PBerval): PBerval; cdecl; external; + +function ber_bvdup(src: PBerval): PBerval; cdecl; external; + +function ber_str2bv(const str: PChar; len: ber_len_t; duplicate: cbool; bv: PBerval): PBerval; cdecl; external; + +function ber_mem2bv(const str: PChar; len: ber_len_t; duplicate: cbool; bv: PBerval): PBerval; cdecl; external; + +function ber_bvstr(const str: PChar): PBerval; + +function ber_bvstrdup(const str: PChar): PBerval; + +function ber_strdup(const str: PChar): PChar; cdecl; external; + +procedure ber_bvarray_free(p: BerVarray); cdecl; external; + +function ber_bvarray_add(p: PBerVarray; bv: PBerval): cint; cdecl; external; + +function ber_bvcmp(v1, v2: PBerval): cint; + + +(* + * error.c + *) + +function ber_errno_addr: pcint; cdecl; external; + +function ber_errno: cint; + +const + LBER_ERROR_NONE = $0; + LBER_ERROR_PARAM = $1; + LBER_ERROR_MEMORY = $2; diff --git a/packages/extra/ldap/ldap.pas b/packages/extra/ldap/ldap.pas new file mode 100644 index 0000000000..32356d57ea --- /dev/null +++ b/packages/extra/ldap/ldap.pas @@ -0,0 +1,73 @@ +unit ldap; + +{$mode objfpc} + +interface + +uses + ctypes, + lber; + +{$linklib ldap} + +{$include ldap_featuresh.inc} +{$include ldap_schemah.inc} +{$include ldaph.inc} + +implementation + +function LDAP_OPT_ON: Pointer; +// #define LDAP_OPT_ON ((void *) &ber_pvt_opt_on) +begin + LDAP_OPT_ON := @ber_pvt_opt_on; +end; + +function LDAP_RANGE(n, x, y: ber_int_t): Boolean; +// #define LDAP_RANGE(n,x,y) (((x) <= (n)) && ((n) <= (y))) +begin + LDAP_RANGE := (x <= n) and (n <= y); +end; + +function LDAP_ATTR_ERROR(n: ber_int_t): Boolean; +// #define LDAP_ATTR_ERROR(n) LDAP_RANGE((n),0x10,0x15) (* 16-21 *) +begin + LDAP_ATTR_ERROR := LDAP_RANGE(n, $10, $15); +end; + +function LDAP_NAME_ERROR(n: ber_int_t): Boolean; +// #define LDAP_NAME_ERROR(n) LDAP_RANGE((n),0x20,0x24) (* 32-34,36 *) +begin + LDAP_NAME_ERROR := LDAP_RANGE(n, $20, $24); +end; + +function LDAP_SECURITY_ERROR(n: ber_int_t): Boolean; +// #define LDAP_SECURITY_ERROR(n) LDAP_RANGE((n),0x2F,0x32) (* 47-50 *) +begin + LDAP_SECURITY_ERROR := LDAP_RANGE(n, $2F, $32); +end; + +function LDAP_SERVICE_ERROR(n: ber_int_t): Boolean; +// #define LDAP_SERVICE_ERROR(n) LDAP_RANGE((n),0x33,0x36) (* 51-54 *) +begin + LDAP_SERVICE_ERROR := LDAP_RANGE(n, $33, $36); +end; + +function LDAP_UPDATE_ERROR(n: ber_int_t): Boolean; +// #define LDAP_UPDATE_ERROR(n) LDAP_RANGE((n),0x40,0x47) (* 64-69,71 *) +begin + LDAP_UPDATE_ERROR := LDAP_RANGE(n, $40, $47); +end; + +function LDAP_API_ERROR(n: ber_int_t): Boolean; +// #define LDAP_API_ERROR(n) LDAP_RANGE((n),0x51,0x61) (* 81-97 *)} +begin + LDAP_API_ERROR := n < 0; +end; + +function LDAP_API_RESULT(n: ber_int_t): Boolean; +// #define LDAP_API_RESULT(n) (((n) == LDAP_SUCCESS) || LDAP_RANGE((n),0x51,0x61)) (* 0,81-97 *) +begin + LDAP_API_RESULT := n <= 0; +end; + +end. diff --git a/packages/extra/ldap/ldap_featuresh.inc b/packages/extra/ldap/ldap_featuresh.inc new file mode 100644 index 0000000000..9f0ef5be48 --- /dev/null +++ b/packages/extra/ldap/ldap_featuresh.inc @@ -0,0 +1,59 @@ +(* include/ldap_features.h. Generated automatically by configure. *) +(* $OpenLDAP: pkg/ldap/include/ldap_features.h.in,v 1.13.2.1 2003/02/09 17:02:17 kurt Exp $ *) +(* + * Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. A copy of this license is available at + * http://www.OpenLDAP.org/license.html or in file LICENSE in the + * top-level directory of the distribution. + *) + +(* + * LDAP Features + *) + +(* OpenLDAP API version macros *) +const + LDAP_VENDOR_VERSION = 20228; + LDAP_VENDOR_VERSION_MAJOR = 2; + LDAP_VENDOR_VERSION_MINOR = 2; + LDAP_VENDOR_VERSION_PATCH = 28; + +(* +** WORK IN PROGRESS! +** +** OpenLDAP reentrancy/thread-safeness should be dynamically +** checked using ldap_get_option(). +** +** The -lldap implementation is not thread-safe. +** +** The -lldap_r implementation is: +** LDAP_API_FEATURE_THREAD_SAFE (basic thread safety) +** but also be: +** LDAP_API_FEATURE_SESSION_THREAD_SAFE +** LDAP_API_FEATURE_OPERATION_THREAD_SAFE +** +** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE +** can be used to determine if -lldap_r is available at compile +** time. You must define LDAP_THREAD_SAFE if and only if you +** link with -lldap_r. +** +** If you fail to define LDAP_THREAD_SAFE when linking with +** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap, +** provided header definations and declarations may be incorrect. +** +*) + +(* is -lldap_r available or not *) +{$DEFINE LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE} + +(* LDAP v2 Kerberos Bind *) +//{$UNDEF LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND} + +(* LDAP v2 Referrals *) +//{$UNDEF LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS} + + diff --git a/packages/extra/ldap/ldap_schemah.inc b/packages/extra/ldap/ldap_schemah.inc new file mode 100644 index 0000000000..b75f830c74 --- /dev/null +++ b/packages/extra/ldap/ldap_schemah.inc @@ -0,0 +1,255 @@ +(* $OpenLDAP: pkg/ldap/include/ldap_schema.h,v 1.32.2.3 2005/01/20 17:00:59 kurt Exp $ *) +(* This work is part of OpenLDAP Software . + * + * Copyright 1998-2005 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + *) + +(* ldap-schema.h - Header for basic schema handling functions that can be + * used by both clients and servers. + * these routines should be renamed ldap_x_... + *) + + +(* Codes for parsing errors *) + +const + LDAP_SCHERR_OUTOFMEM = 1; + LDAP_SCHERR_UNEXPTOKEN = 2; + LDAP_SCHERR_NOLEFTPAREN = 3; + LDAP_SCHERR_NORIGHTPAREN = 4; + LDAP_SCHERR_NODIGIT = 5; + LDAP_SCHERR_BADNAME = 6; + LDAP_SCHERR_BADDESC = 7; + LDAP_SCHERR_BADSUP = 8; + LDAP_SCHERR_DUPOPT = 9; + LDAP_SCHERR_EMPTY = 10; + LDAP_SCHERR_MISSING = 11; + LDAP_SCHERR_OUT_OF_ORDER = 12; + +type + pldap_schema_extension_item = ^ldap_schema_extension_item; + ldap_schema_extension_item = record + lsei_name : PChar; + lsei_values : PPChar; + end; + + PPLDAPSchemaExtensionItem = ^PLDAPSchemaExtensionItem; + PLDAPSchemaExtensionItem = ^LDAPSchemaExtensionItem; + LDAPSchemaExtensionItem = ldap_schema_extension_item; + + pldap_syntax = ^ldap_syntax; + ldap_syntax = record + syn_oid : PChar; (* REQUIRED *) + syn_names : PPChar; (* OPTIONAL *) + syn_desc : PChar; (* OPTIONAL *) + syn_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *) + end; + + PLDAPSyntax = ^ldap_syntax; + LDAPSyntax = ldap_syntax; + + pldap_matchingrule = ^ldap_matchingrule; + ldap_matchingrule = record + mr_oid : PChar; (* REQUIRED *) + mr_names : PPChar; (* OPTIONAL *) + mr_desc : PChar; (* OPTIONAL *) + mr_obsolete : cint; (* OPTIONAL *) + mr_syntax_oid : PChar; (* REQUIRED *) + mr_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *) + end; + + PLDAPMatchingRule = ^LDAPMatchingRule; + LDAPMatchingRule = ldap_matchingrule; + + pldap_matchingruleuse = ^ldap_matchingruleuse; + ldap_matchingruleuse = record + mru_oid : PChar; (* REQUIRED *) + mru_names : PPChar; (* OPTIONAL *) + mru_desc : PChar; (* OPTIONAL *) + mru_obsolete : cint; (* OPTIONAL *) + mru_applies_oids: PPChar; (* REQUIRED *) + mru_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *) + end; + + PLDAPMatchingRuleUse = ^LDAPMatchingRuleUse; + LDAPMatchingRuleUse = ldap_matchingruleuse; + + pldap_attributetype = ^ldap_attributetype; + ldap_attributetype = record + at_oid : PChar; (* REQUIRED *) + at_names : PPChar; (* OPTIONAL *) + at_desc : PChar; (* OPTIONAL *) + at_obsolete : cint; (* 0=no, 1=yes *) + at_sup_oid : PChar; (* OPTIONAL *) + at_equality_oid : PChar; (* OPTIONAL *) + at_ordering_oid : PChar; (* OPTIONAL *) + at_substr_oid : PChar; (* OPTIONAL *) + at_syntax_oid : PChar; (* OPTIONAL *) + at_syntax_len : cint; (* OPTIONAL *) + at_single_value : cint; (* 0=no, 1=yes *) + at_collective : cint; (* 0=no, 1=yes *) + at_no_user_mod : cint; (* 0=no, 1=yes *) + at_usage : cint; (* 0=userApplications, 1=directoryOperation, 2=distributedOperation, 3=dSAOperation *) + at_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *) + end; + + PLDAPAttributeType = ^LDAPAttributeType; + LDAPAttributeType = ldap_attributetype; + + pldap_objectclass = ^ldap_objectclass; + ldap_objectclass = record + oc_oid : PChar; (* REQUIRED *) + oc_names : PPChar; (* OPTIONAL *) + oc_desc : PChar; (* OPTIONAL *) + oc_obsolete : cint; (* 0=no, 1=yes *) + oc_sup_oids : PPChar; (* OPTIONAL *) + oc_kind : cint; (* 0=ABSTRACT, 1=STRUCTURAL, 2=AUXILIARY *) + oc_at_oids_must : PPChar; (* OPTIONAL *) + oc_at_oids_may : PPChar; (* OPTIONAL *) + oc_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *) + end; + + PLDAPObjectClass = ^LDAPObjectClass; + LDAPObjectClass = ldap_objectclass; + + pldap_contentrule = ^ldap_contentrule; + ldap_contentrule = record + cr_oid : PChar; (* REQUIRED *) + cr_names : PPChar; (* OPTIONAL *) + cr_desc : PChar; (* OPTIONAL *) + cr_sup_oids : PPChar; (* OPTIONAL *) + cr_obsolete : cint; (* 0=no, 1=yes *) + cr_oc_oids_aux : PPChar; (* OPTIONAL *) + cr_at_oids_must : PPChar; (* OPTIONAL *) + cr_at_oids_may : PPChar; (* OPTIONAL *) + cr_at_oids_not : PPChar; (* OPTIONAL *) + cr_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *) + end; + + PLDAPContentRule = ^LDAPContentRule; + LDAPContentRule = ldap_contentrule; + + pldap_nameform = ^ldap_nameform; + ldap_nameform = record + nf_oid : PChar; (* REQUIRED *) + nf_names : PPChar; (* OPTIONAL *) + nf_desc : PChar; (* OPTIONAL *) + nf_obsolete : cint; (* 0=no, 1=yes *) + nf_objectclass : PChar; (* REQUIRED *) + nf_at_oids_must : PPChar; (* REQUIRED *) + nf_at_oids_may : PPChar; (* OPTIONAL *) + nf_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *) + end; + + PLDAPNameForm = ^LDAPNameForm; + LDAPNameForm = ldap_nameform; + + pldap_structurerule = ^ldap_structurerule; + ldap_structurerule = record + sr_ruleid : cint; (* REQUIRED *) + sr_names : PPChar; (* OPTIONAL *) + sr_desc : PChar; (* OPTIONAL *) + sr_obsolete : cint; (* 0=no, 1=yes *) + sr_nameform : PChar; (* REQUIRED *) + sr_nsup_ruleids : cint; (* number of sr_sup_ruleids *) + sr_sup_ruleids : pcint; (* OPTIONAL *) + sr_extensions : PPLDAPSchemaExtensionItem; (* OPTIONAL *) + end; + + PLDAPStructureRule = ^LDAPStructureRule; + LDAPStructureRule = ldap_structurerule; + + +(* + * Misc macros + *) +const + LDAP_SCHEMA_NO = 0; + LDAP_SCHEMA_YES = 1; + + LDAP_SCHEMA_USER_APPLICATIONS = 0; + LDAP_SCHEMA_DIRECTORY_OPERATION = 1; + LDAP_SCHEMA_DISTRIBUTED_OPERATION = 2; + LDAP_SCHEMA_DSA_OPERATION = 3; + + LDAP_SCHEMA_ABSTRACT = 0; + LDAP_SCHEMA_STRUCTURAL = 1; + LDAP_SCHEMA_AUXILIARY = 2; + + +(* + * Flags that control how liberal the parsing routines are. + *) +const + LDAP_SCHEMA_ALLOW_NONE = $00; (* Strict parsing *) + LDAP_SCHEMA_ALLOW_NO_OID = $01; (* Allow missing oid *) + LDAP_SCHEMA_ALLOW_QUOTED = $02; (* Allow bogus extra quotes *) + LDAP_SCHEMA_ALLOW_DESCR = $04; (* Allow descr instead of OID *) + LDAP_SCHEMA_ALLOW_DESCR_PREFIX = $08; (* Allow descr as OID prefix *) + LDAP_SCHEMA_ALLOW_OID_MACRO = $10; (* Allow OID macros in slapd *) + LDAP_SCHEMA_ALLOW_OUT_OF_ORDER_FIELDS = $20; (* Allow fields in most any order *) + LDAP_SCHEMA_ALLOW_ALL = $3f; (* Be very liberal in parsing *) + LDAP_SCHEMA_SKIP = $80; (* Don't malloc any result *) + + +function ldap_syntax2name(syn: PLDAPSyntax): PChar; cdecl; external; +function ldap_matchingrule2name(mr: PLDAPMatchingRule): PChar; cdecl; external; +function ldap_matchingruleuse2name(mru: PLDAPMatchingRuleUse): PChar; cdecl; external; +function ldap_attributetype2name(_at: PLDAPAttributeType): PChar; cdecl; external; +function ldap_objectclass2name(oc: PLDAPObjectClass): PChar; cdecl; external; +function ldap_contentrule2name(cr: PLDAPContentRule): PChar; cdecl; external; +function ldap_nameform2name(nf: PLDAPNameForm): PChar; cdecl; external; +function ldap_structurerule2name(sr: PLDAPStructureRule): PChar; cdecl; external; + +procedure ldap_syntax_free(syn: PLDAPSyntax); cdecl; external; +procedure ldap_matchingrule_free(mr: PLDAPMatchingRule); cdecl; external; +procedure ldap_matchingruleuse_free(mru: PLDAPMatchingRuleUse); cdecl; external; +procedure ldap_attributetype_free(_at: PLDAPAttributeType); cdecl; external; +procedure ldap_objectclass_free(oc: PLDAPObjectClass); cdecl; external; +procedure ldap_contentrule_free(cr: PLDAPContentRule); cdecl; external; +procedure ldap_nameform_free(nf: PLDAPNameForm); cdecl; external; +procedure ldap_structurerule_free(sr: PLDAPStructureRule); cdecl; external; + +function ldap_str2structurerule(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPStructureRule; cdecl; external; +function ldap_str2nameform(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPNameForm; cdecl; external; +function ldap_str2contentrule(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPContentRule; cdecl; external; +function ldap_str2objectclass(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPObjectClass; cdecl; external; +function ldap_str2attributetype(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPAttributeType; cdecl; external; +function ldap_str2syntax(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPSyntax; cdecl; external; +function ldap_str2matchingrule(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPMatchingRule; cdecl; external; +function ldap_str2matchingruleuse(const s: PChar; code: pcint; const errp: PPChar; flags: cuint): PLDAPMatchingRuleUse; cdecl; external; + +function ldap_structurerule2str(sr: PLDAPStructureRule): PChar; cdecl; external; +function ldap_structurerule2bv(sr: PLDAPStructureRule; bv: PBerval): PBerval; cdecl; external; + +function ldap_nameform2str(nf: PLDAPNameForm): PChar; cdecl; external; +function ldap_nameform2bv(nf: PLDAPNameForm; bv: PBerval): PBerval; cdecl; external; + +function ldap_contentrule2str(cr: PLDAPContentRule): PChar; cdecl; external; +function ldap_contentrule2bv(cr: PLDAPContentRule; bv: PBerval): PBerval; cdecl; external; + +function ldap_objectclass2str(oc: PLDAPObjectClass): PChar; cdecl; external; +function ldap_objectclass2bv(oc: PLDAPObjectClass; bv: PBerval): PBerval; cdecl; external; + +function ldap_attributetype2str(_at: PLDAPAttributeType): PChar; cdecl; external; +function ldap_attributetype2bv(_at: PLDAPAttributeType; bv: PBerval): PBerval; cdecl; external; + +function ldap_syntax2str(syn: PLDAPSyntax): PChar; cdecl; external; +function ldap_syntax2bv(syn: PLDAPSyntax; bv: PBerval): PBerval; cdecl; external; + +function ldap_matchingrule2str(mr: PLDAPMatchingRule): PChar; cdecl; external; +function ldap_matchingrule2bv(mr: PLDAPMatchingRule; bv: PBerval): PBerval; cdecl; external; + +function ldap_matchingruleuse2str(mru: PLDAPMatchingRuleUse): PChar; cdecl; external; +function ldap_matchingruleuse2bv(mru: PLDAPMatchingRuleUse; bv: PBerval): PBerval; cdecl; external; + +function ldap_scherr2str(code: cint): PChar; cdecl; external; diff --git a/packages/extra/ldap/ldaph.inc b/packages/extra/ldap/ldaph.inc new file mode 100644 index 0000000000..de14cf7363 --- /dev/null +++ b/packages/extra/ldap/ldaph.inc @@ -0,0 +1,1805 @@ +(* $OpenLDAP: pkg/ldap/include/ldap.h,v 1.168.2.16 2003/03/05 23:48:31 kurt Exp $ *) +(* + * Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. A copy of this license is available at + * http://www.OpenLDAP.org/license.html or in file LICENSE in the + * top-level directory of the distribution. + *) +(* Portions + * Copyright (c) 1990 Regents of the University of Michigan. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of Michigan at Ann Arbor. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + *) + +const + LDAP_VERSION1 = 1; + LDAP_VERSION2 = 2; + LDAP_VERSION3 = 3; + + LDAP_VERSION_MIN = LDAP_VERSION2; + LDAP_VERSION = LDAP_VERSION2; + LDAP_VERSION_MAX = LDAP_VERSION3; + +(* + * We'll use 2000+draft revision for our API version number + * As such, the number will be above the old RFC but below + * whatever number does finally get assigned + *) +const + LDAP_API_VERSION = 3001; + LDAP_VENDOR_NAME = 'OpenLDAP'; + +(* OpenLDAP API Features *) + LDAP_API_FEATURE_X_OPENLDAP = LDAP_VENDOR_VERSION; + +{$IF defined(LDAP_API_FEATURE_X_OPENLDAP_REENTRANT) or (defined(LDAP_THREAD_SAFE) and defined(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE))} + (* -lldap may or may not be thread safe *) + (* -lldap_r, if available, is always thread safe *) + {$DEFINE LDAP_API_FEATURE_THREAD_SAFE} +{$IFEND} +{$IF defined(LDAP_THREAD_SAFE) and defined(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE)} + //{$DEFINE LDAP_API_FEATURE_SESSION_SAFE} + //{$DEFINE LDAP_API_OPERATION_SESSION_SAFE} +{$IFEND} + + LDAP_PORT = 389; (* ldap:/// default LDAP port *) + LDAPS_PORT = 636; (* ldaps:/// default LDAP over TLS port *) + + LDAP_ROOT_DSE = ''; + LDAP_NO_ATTRS = '1.1'; + LDAP_ALL_USER_ATTRIBUTES = '*'; + LDAP_ALL_OPERATIONAL_ATTRIBUTES = '+'; (* OpenLDAP extension *) + + LDAP_MAXINT = 2147483647; + +(* + * LDAP_OPTions defined by draft-ldapext-ldap-c-api-02 + * 0x0000 - 0x0fff reserved for api options + * 0x1000 - 0x3fff reserved for api extended options + * 0x4000 - 0x7fff reserved for private and experimental options + *) + LDAP_OPT_API_INFO = $0000; + LDAP_OPT_DESC = $0001; (* deprecated *) + LDAP_OPT_DEREF = $0002; + LDAP_OPT_SIZELIMIT = $0003; + LDAP_OPT_TIMELIMIT = $0004; +(* $05 - $07 not defined by current draft *) + LDAP_OPT_REFERRALS = $0008; + LDAP_OPT_RESTART = $0009; +(* $0a - $10 not defined by current draft *) + LDAP_OPT_PROTOCOL_VERSION = $0011; + LDAP_OPT_SERVER_CONTROLS = $0012; + LDAP_OPT_CLIENT_CONTROLS = $0013; +(* $14 not defined by current draft *) + LDAP_OPT_API_FEATURE_INFO = $0015; + +(* $16 - $2f not defined by current draft *) + LDAP_OPT_HOST_NAME = $0030; + LDAP_OPT_RESULT_CODE = $0031; + LDAP_OPT_ERROR_NUMBER = LDAP_OPT_RESULT_CODE; + LDAP_OPT_ERROR_STRING = $0032; + LDAP_OPT_MATCHED_DN = $0033; + +(* $34 - $0fff not defined by current draft *) + +(* private and experimental options *) +(* OpenLDAP specific options *) + LDAP_OPT_DEBUG_LEVEL = $5001; (* debug level *) + LDAP_OPT_TIMEOUT = $5002; (* default timeout *) + LDAP_OPT_REFHOPLIMIT = $5003; (* ref hop limit *) + LDAP_OPT_NETWORK_TIMEOUT = $5005; (* socket level timeout *) + LDAP_OPT_URI = $5006; + LDAP_OPT_REFERRAL_URLS = $5007; (* Referral URLs *) + +(* OpenLDAP TLS options *) + LDAP_OPT_X_TLS = $6000; + LDAP_OPT_X_TLS_CTX = $6001; (* SSL CTX *) + LDAP_OPT_X_TLS_CACERTFILE = $6002; + LDAP_OPT_X_TLS_CACERTDIR = $6003; + LDAP_OPT_X_TLS_CERTFILE = $6004; + LDAP_OPT_X_TLS_KEYFILE = $6005; + LDAP_OPT_X_TLS_REQUIRE_CERT = $6006; +(* LDAP_OPT_X_TLS_PROTOCOL = $6007; *) + LDAP_OPT_X_TLS_CIPHER_SUITE = $6008; + LDAP_OPT_X_TLS_RANDOM_FILE = $6009; + LDAP_OPT_X_TLS_SSL_CTX = $600a; + LDAP_OPT_X_TLS_CRLCHECK = $600b; + LDAP_OPT_X_TLS_CONNECT_CB = $6600c; + LDAP_OPT_X_TLS_CONNECT_ARG = $6600d; + LDAP_OPT_X_TLS_DHFILE = $6600e; + + LDAP_OPT_X_TLS_NEVER = 0; + LDAP_OPT_X_TLS_HARD = 1; + LDAP_OPT_X_TLS_DEMAND = 2; + LDAP_OPT_X_TLS_ALLOW = 3; + LDAP_OPT_X_TLS_TRY = 4; + +(* OpenLDAP SASL options *) + LDAP_OPT_X_SASL_MECH = $6100; + LDAP_OPT_X_SASL_REALM = $6101; + LDAP_OPT_X_SASL_AUTHCID = $6102; + LDAP_OPT_X_SASL_AUTHZID = $6103; + LDAP_OPT_X_SASL_SSF = $6104; (* read-only *) + LDAP_OPT_X_SASL_SSF_EXTERNAL = $6105; (* write-only *) + LDAP_OPT_X_SASL_SECPROPS = $6106; (* write-only *) + LDAP_OPT_X_SASL_SSF_MIN = $6107; + LDAP_OPT_X_SASL_SSF_MAX = $6108; + LDAP_OPT_X_SASL_MAXBUFSIZE = $6109; + +(* Private API Extensions -- reserved for application use *) + LDAP_OPT_PRIVATE_EXTENSION_BASE = $7000; (* Private API inclusive *) + +(* + * ldap_get_option() and ldap_set_option() return values. + * As later versions may return other values indicating + * failure, current applications should only compare returned + * value against LDAP_OPT_SUCCESS. + *) + LDAP_OPT_SUCCESS = 0; + LDAP_OPT_ERROR = -1; + +(* on/off values *) + LDAP_OPT_OFF = Pointer(0); + +function LDAP_OPT_ON: Pointer; + +const + LDAP_API_INFO_VERSION = 1; + +type + PLDAPAPIInfo = ^LDAPAPIInfo; + LDAPAPIInfo = record + ldapai_info_version : cint; (* version of LDAPAPIInfo (1) *) + ldapai_api_version : cint; (* revision of API supported *) + ldapai_protocol_version : cint; (* highest LDAP version supported *) + ldapai_extensions : PPChar; (* names of API extensions *) + ldapai_vendor_name : PChar; (* name of supplier *) + ldapai_vendor_version : cint; (* supplier-specific version * 100 *) + end; + +const + LDAP_FEATURE_INFO_VERSION = 1; (* version of api feature structure *) + +type + pldap_apifeature_info = ^ldap_apifeature_info; + ldap_apifeature_info = record + ldapaif_info_version : cint; (* version of this struct (1) *) + ldapaif_name : PChar; (* matches LDAP_API_FEATURE_... less the prefix *) + ldapaif_version : cint; (* matches the value LDAP_API_FEATURE_... *) + end; + + PLDAPAPIFeatureInfo = ^LDAPAPIFeatureInfo; + LDAPAPIFeatureInfo = ldap_apifeature_info; + + PPPLDAPControl = ^PPLDAPControl; + PPLDAPControl = ^PLDAPControl; + PLDAPControl = ^LDAPControl; + LDAPControl = record + ldctl_oid : PChar; + ldctl_value : berval; + ldctl_iscritical : char; + end; + +const +(* LDAP Controls *) +(* standard track controls *) + LDAP_CONTROL_MANAGEDSAIT = '2.16.840.1.113730.3.4.2'; (* RFC 3296 *) + LDAP_CONTROL_SUBENTRIES = '1.3.6.1.4.1.4203.1.10.1'; (* RFC 3672 *) + LDAP_CONTROL_PAGEDRESULTS = '1.2.840.113556.1.4.319'; (* RFC 2696 *) + + LDAP_CONTROL_VALUESRETURNFILTER = '1.2.826.0.1.3344810.2.3'; (* RFC 3876 *) + LDAP_CONTROL_X_VALUESRETURNFILTER = '1.2.826.0.1.334810.2.3'; (* bad OID *) + + LDAP_CONTROL_ASSERT = '1.3.6.1.1.12'; + LDAP_CONTROL_PRE_READ = '1.3.6.1.1.13.1'; + LDAP_CONTROL_POST_READ = '1.3.6.1.1.13.2'; + +(* standard track - not implemented in slapd(8) *) + LDAP_CONTROL_SORTREQUEST = '1.2.840.113556.1.4.473'; (* RFC 2891 *) + LDAP_CONTROL_SORTRESPONSE = '1.2.840.113556.1.4.474'; (* RFC 2891 *) + +(* but not yet formalized controls *) + LDAP_CONTROL_PROXY_AUTHZ = '2.16.840.1.113730.3.4.18'; + +(* various works in progress *) + LDAP_CONTROL_NOOP = '1.3.6.1.4.1.4203.666.5.2'; + +(* LDAP VLV *)(* not implemented in slapd(8) *) + LDAP_CONTROL_VLVREQUEST = '2.16.840.1.113730.3.4.9'; + LDAP_CONTROL_VLVRESPONSE = '2.16.840.1.113730.3.4.10'; + +(* LDAP Sync -- draft-zeilenga-ldup-sync *)(* submitted for publication *) + LDAP_SYNC_OID = '1.3.6.1.4.1.4203.1.9.1'; + LDAP_CONTROL_SYNC = LDAP_SYNC_OID + '.1'; + LDAP_CONTROL_SYNC_STATE = LDAP_SYNC_OID + '.2'; + LDAP_CONTROL_SYNC_DONE = LDAP_SYNC_OID + '.3'; + LDAP_SYNC_INFO = LDAP_SYNC_OID + '.4'; + + LDAP_SYNC_NONE = $00; + LDAP_SYNC_REFRESH_ONLY = $01; + LDAP_SYNC_RESERVED = $02; + LDAP_SYNC_REFRESH_AND_PERSIST = $03; + + LDAP_SYNC_REFRESH_PRESENTS = 0; + LDAP_SYNC_REFRESH_DELETES = 1; + + LDAP_TAG_SYNC_NEW_COOKIE = ber_tag_t($80); + LDAP_TAG_SYNC_REFRESH_DELETE = ber_tag_t($a1); + LDAP_TAG_SYNC_REFRESH_PRESENT = ber_tag_t($a2); + LDAP_TAG_SYNC_ID_SET = ber_tag_t($a3); + + LDAP_TAG_SYNC_COOKIE = ber_tag_t($04); + LDAP_TAG_REFRESHDELETES = ber_tag_t($01); + LDAP_TAG_REFRESHDONE = ber_tag_t($01); + LDAP_TAG_RELOAD_HINT = ber_tag_t($01); + + LDAP_SYNC_PRESENT = 0; + LDAP_SYNC_ADD = 1; + LDAP_SYNC_MODIFY = 2; + LDAP_SYNC_DELETE = 3; + +(* MS ActiveDirectory controls (for compatibility) *) + LDAP_CONTROL_X_DOMAIN_SCOPE = '1.2.840.113556.1.4.1339'; + LDAP_CONTROL_X_PERMISSIVE_MODIFY = '1.2.840.113556.1.4.1413'; + +(* LDAP Unsolicited Notifications *) + LDAP_NOTICE_OF_DISCONNECTION = '1.3.6.1.4.1.1466.20036'; (* RFC 2251 *) + LDAP_NOTICE_DISCONNECT = LDAP_NOTICE_OF_DISCONNECTION; + +(* LDAP Extended Operations *) + LDAP_EXOP_START_TLS = '1.3.6.1.4.1.1466.20037'; (* RFC 2830 *) + + LDAP_EXOP_MODIFY_PASSWD = '1.3.6.1.4.1.4203.1.11.1'; (* RFC 3062 *) + LDAP_TAG_EXOP_MODIFY_PASSWD_ID = ber_tag_t($80); + LDAP_TAG_EXOP_MODIFY_PASSWD_OLD = ber_tag_t($81); + LDAP_TAG_EXOP_MODIFY_PASSWD_NEW = ber_tag_t($82); + LDAP_TAG_EXOP_MODIFY_PASSWD_GEN = ber_tag_t($80); + + LDAP_EXOP_X_WHO_AM_I = '1.3.6.1.4.1.4203.1.11.3'; + LDAP_EXOP_X_CANCEL = '1.3.6.1.4.1.4203.666.6.3'; + +(* LDAP Features *) + LDAP_FEATURE_ALL_OP_ATTRS = '1.3.6.1.4.1.4203.1.5.1'; (* RFC 3673 *) + LDAP_FEATURE_OBJECTCLASS_ATTRS = '1.3.6.1.4.1.4203.1.5.2'; (* @objectClass - new number to be assigned *) + LDAP_FEATURE_ABSOLUTE_FILTERS = '1.3.6.1.4.1.4203.1.5.3'; (* (&) (|) *) + LDAP_FEATURE_LANGUAGE_TAG_OPTIONS = '1.3.6.1.4.1.4203.1.5.4'; + LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS = '1.3.6.1.4.1.4203.1.5.5'; + LDAP_FEATURE_MODIFY_INCREMENT = '1.3.6.1.1.14'; + +(* + * specific LDAP instantiations of BER types we know about + *) + +(* Overview of LBER tag construction + * + * Bits + * ______ + * 8 7 | CLASS + * 0 0 = UNIVERSAL + * 0 1 = APPLICATION + * 1 0 = CONTEXT-SPECIFIC + * 1 1 = PRIVATE + * _____ + * | 6 | DATA-TYPE + * 0 = PRIMITIVE + * 1 = CONSTRUCTED + * ___________ + * | 5 ... 1 | TAG-NUMBER + *) + +(* general stuff *) + LDAP_TAG_MESSAGE = ber_tag_t($30); (* constructed + 16 *) + LDAP_TAG_MSGID = ber_tag_t($02); (* integer *) + + LDAP_TAG_LDAPDN = ber_tag_t($04); (* octet string *) + LDAP_TAG_LDAPCRED = ber_tag_t($04); (* octet string *) + + LDAP_TAG_CONTROLS = ber_tag_t($a0); (* context specific + constructed + 0 *) + LDAP_TAG_REFERRAL = ber_tag_t($a3); (* context specific + constructed + 3 *) + + LDAP_TAG_NEWSUPERIOR = ber_tag_t($80); (* context-specific + primitive + 0 *) + + LDAP_TAG_EXOP_REQ_OID = ber_tag_t($80); (* context specific + primitive *) + LDAP_TAG_EXOP_REQ_VALUE = ber_tag_t($81); (* context specific + primitive *) + LDAP_TAG_EXOP_RES_OID = ber_tag_t($8a); (* context specific + primitive *) + LDAP_TAG_EXOP_RES_VALUE = ber_tag_t($8b); (* context specific + primitive *) + + LDAP_TAG_IM_RES_OID = ber_tag_t($80); (* context specific + primitive *) + LDAP_TAG_IM_RES_VALUE = ber_tag_t($81); (* context specific + primitive *) + + LDAP_TAG_SASL_RES_CREDS = ber_tag_t($87); (* context specific + primitive *) + + +(* possible operations a client can invoke *) + LDAP_REQ_BIND = ber_tag_t($60); (* application + constructed *) + LDAP_REQ_UNBIND = ber_tag_t($42); (* application + primitive *) + LDAP_REQ_SEARCH = ber_tag_t($63); (* application + constructed *) + LDAP_REQ_MODIFY = ber_tag_t($66); (* application + constructed *) + LDAP_REQ_ADD = ber_tag_t($68); (* application + constructed *) + LDAP_REQ_DELETE = ber_tag_t($4a); (* application + primitive *) + LDAP_REQ_MODDN = ber_tag_t($6c); (* application + constructed *) + LDAP_REQ_MODRDN = LDAP_REQ_MODDN; + LDAP_REQ_RENAME = LDAP_REQ_MODDN; + LDAP_REQ_COMPARE = ber_tag_t($6e); (* application + constructed *) + LDAP_REQ_ABANDON = ber_tag_t($50); (* application + primitive *) + LDAP_REQ_EXTENDED = ber_tag_t($77); (* application + constructed *) + +(* possible result types a server can return *) + LDAP_RES_BIND = ber_tag_t($61); (* application + constructed *) + LDAP_RES_SEARCH_ENTRY = ber_tag_t($64); (* application + constructed *) + LDAP_RES_SEARCH_REFERENCE = ber_tag_t($73); (* V3: application + constructed *) + LDAP_RES_SEARCH_RESULT = ber_tag_t($65); (* application + constructed *) + LDAP_RES_MODIFY = ber_tag_t($67); (* application + constructed *) + LDAP_RES_ADD = ber_tag_t($69); (* application + constructed *) + LDAP_RES_DELETE = ber_tag_t($6b); (* application + constructed *) + LDAP_RES_MODDN = ber_tag_t($6d); (* application + constructed *) + LDAP_RES_MODRDN = LDAP_RES_MODDN; (* application + constructed *) + LDAP_RES_RENAME = LDAP_RES_MODDN; (* application + constructed *) + LDAP_RES_COMPARE = ber_tag_t($6f); (* application + constructed *) + LDAP_RES_EXTENDED = ber_tag_t($78); (* V3: application + constructed *) + LDAP_RES_INTERMEDIATE = ber_tag_t($79); (* V3+: application + constructed *) + + LDAP_RES_ANY = -1; + LDAP_RES_UNSOLICITED = 0; + + +(* sasl methods *) + LDAP_SASL_SIMPLE = PChar(0); + LDAP_SASL_NULL = ''; + + +(* authentication methods available *) + LDAP_AUTH_NONE = ber_tag_t($00); (* no authentication *) + LDAP_AUTH_SIMPLE = ber_tag_t($80); (* context specific + primitive *) + LDAP_AUTH_SASL = ber_tag_t($a3); (* context specific + constructed *) + LDAP_AUTH_KRBV4 = ber_tag_t($ff); (* means do both of the following *) + LDAP_AUTH_KRBV41 = ber_tag_t($81); (* context specific + primitive *) + LDAP_AUTH_KRBV42 = ber_tag_t($82); (* context specific + primitive *) + + +(* filter types *) + LDAP_FILTER_AND = ber_tag_t($a0); (* context specific + constructed *) + LDAP_FILTER_OR = ber_tag_t($a1); (* context specific + constructed *) + LDAP_FILTER_NOT = ber_tag_t($a2); (* context specific + constructed *) + LDAP_FILTER_EQUALITY = ber_tag_t($a3); (* context specific + constructed *) + LDAP_FILTER_SUBSTRINGS = ber_tag_t($a4); (* context specific + constructed *) + LDAP_FILTER_GE = ber_tag_t($a5); (* context specific + constructed *) + LDAP_FILTER_LE = ber_tag_t($a6); (* context specific + constructed *) + LDAP_FILTER_PRESENT = ber_tag_t($87); (* context specific + primitive *) + LDAP_FILTER_APPROX = ber_tag_t($a8); (* context specific + constructed *) + LDAP_FILTER_EXT = ber_tag_t($a9); (* context specific + constructed *) + +(* extended filter component types *) + LDAP_FILTER_EXT_OID = ber_tag_t($81); (* context specific *) + LDAP_FILTER_EXT_TYPE = ber_tag_t($82); (* context specific *) + LDAP_FILTER_EXT_VALUE = ber_tag_t($83); (* context specific *) + LDAP_FILTER_EXT_DNATTRS = ber_tag_t($84); (* context specific *) + +(* substring filter component types *) + LDAP_SUBSTRING_INITIAL = ber_tag_t($80); (* context specific *) + LDAP_SUBSTRING_ANY = ber_tag_t($81); (* context specific *) + LDAP_SUBSTRING_FINAL = ber_tag_t($82); (* context specific *) + +(* search scopes *) + LDAP_SCOPE_DEFAULT = ber_int_t(-1); (* OpenLDAP extension *) + LDAP_SCOPE_BASE = ber_int_t($0000); + LDAP_SCOPE_BASEOBJECT = LDAP_SCOPE_BASE; + LDAP_SCOPE_ONELEVEL = ber_int_t($0001); + LDAP_SCOPE_ONE = LDAP_SCOPE_ONELEVEL; + LDAP_SCOPE_SUBTREE = ber_int_t($0002); + LDAP_SCOPE_SUB = LDAP_SCOPE_SUBTREE; + + +(* + * possible error codes we can return + *) + +function LDAP_RANGE(n, x, y: ber_int_t): Boolean; + +const + LDAP_SUCCESS = $00; + LDAP_OPERATIONS_ERROR = $01; + LDAP_PROTOCOL_ERROR = $02; + LDAP_TIMELIMIT_EXCEEDED = $03; + LDAP_SIZELIMIT_EXCEEDED = $04; + LDAP_COMPARE_FALSE = $05; + LDAP_COMPARE_TRUE = $06; + LDAP_AUTH_METHOD_NOT_SUPPORTED = $07; + LDAP_STRONG_AUTH_NOT_SUPPORTED = LDAP_AUTH_METHOD_NOT_SUPPORTED; + LDAP_STRONG_AUTH_REQUIRED = $08; + LDAP_PARTIAL_RESULTS = $09; (* LDAPv2+ (not LDAPv3) *) + + LDAP_REFERRAL = $0a; (* LDAPv3 *) + LDAP_ADMINLIMIT_EXCEEDED = $0b; (* LDAPv3 *) + LDAP_UNAVAILABLE_CRITICAL_EXTENSION = $0c; (* LDAPv3 *) + LDAP_CONFIDENTIALITY_REQUIRED = $0d; (* LDAPv3 *) + LDAP_SASL_BIND_IN_PROGRESS = $0e; (* LDAPv3 *) + +function LDAP_ATTR_ERROR(n: ber_int_t): Boolean; + +const + LDAP_NO_SUCH_ATTRIBUTE = $10; + LDAP_UNDEFINED_TYPE = $11; + LDAP_INAPPROPRIATE_MATCHING = $12; + LDAP_CONSTRAINT_VIOLATION = $13; + LDAP_TYPE_OR_VALUE_EXISTS = $14; + LDAP_INVALID_SYNTAX = $15; + +function LDAP_NAME_ERROR(n: ber_int_t): Boolean; + +const + LDAP_NO_SUCH_OBJECT = $20; + LDAP_ALIAS_PROBLEM = $21; + LDAP_INVALID_DN_SYNTAX = $22; + LDAP_IS_LEAF = $23; (* not LDAPv3 *) + LDAP_ALIAS_DEREF_PROBLEM = $24; + +function LDAP_SECURITY_ERROR(n: ber_int_t): Boolean; + +const + LDAP_PROXY_AUTHZ_FAILURE = $2F; (* LDAPv3 proxy authorization *) + LDAP_INAPPROPRIATE_AUTH = $30; + LDAP_INVALID_CREDENTIALS = $31; + LDAP_INSUFFICIENT_ACCESS = $32; + +function LDAP_SERVICE_ERROR(n: ber_int_t): Boolean; + +const + LDAP_BUSY = $33; + LDAP_UNAVAILABLE = $34; + LDAP_UNWILLING_TO_PERFORM = $35; + LDAP_LOOP_DETECT = $36; + +function LDAP_UPDATE_ERROR(n: ber_int_t): Boolean; + +const + LDAP_NAMING_VIOLATION = $40; + LDAP_OBJECT_CLASS_VIOLATION = $41; + LDAP_NOT_ALLOWED_ON_NONLEAF = $42; + LDAP_NOT_ALLOWED_ON_RDN = $43; + LDAP_ALREADY_EXISTS = $44; + LDAP_NO_OBJECT_CLASS_MODS = $45; + LDAP_RESULTS_TOO_LARGE = $46; (* CLDAP *) + LDAP_AFFECTS_MULTIPLE_DSAS = $47; (* LDAPv3 *) + + LDAP_OTHER = $50; + +(* for the LDAP Sync operation *) + LDAP_SYNC_REFRESH_REQUIRED = $4100; + +(* for the LDAP No-Op control *) + LDAP_NO_OPERATION = $410e; + +(* for the Assertion control *) + LDAP_ASSERTION_FAILED = $410f; + +(* for the Cancel operation *) + LDAP_CANCELLED = $4110; + LDAP_NO_SUCH_OPERATION = $4111; + LDAP_TOO_LATE = $4112; + LDAP_CANNOT_CANCEL = $4113; + +(* API Error Codes + * + * Based on draft-ietf-ldap-c-api-xx + * but with new negative code values + *) + +function LDAP_API_ERROR(n: ber_int_t): Boolean; +function LDAP_API_RESULT(n: ber_int_t): Boolean; + +const + LDAP_SERVER_DOWN = -1; + LDAP_LOCAL_ERROR = -2; + LDAP_ENCODING_ERROR = -3; + LDAP_DECODING_ERROR = -4; + LDAP_TIMEOUT = -5; + LDAP_AUTH_UNKNOWN = -6; + LDAP_FILTER_ERROR = -7; + LDAP_USER_CANCELLED = -8; + LDAP_PARAM_ERROR = -9; + LDAP_NO_MEMORY = -10; + LDAP_CONNECT_ERROR = -11; + LDAP_NOT_SUPPORTED = -12; + LDAP_CONTROL_NOT_FOUND = -13; + LDAP_NO_RESULTS_RETURNED = -14; + LDAP_MORE_RESULTS_TO_RETURN = -15; + LDAP_CLIENT_LOOP = -16; + LDAP_REFERRAL_LIMIT_EXCEEDED = -17; + + +(* + * This structure represents both ldap messages and ldap responses. + * These are really the same, except in the case of search responses, + * where a response has multiple messages. + *) + +type +//typedef struct ldapmsg LDAPMessage; + pldapmsg = Pointer; + + PPLDAPMessage = ^PLDAPMessage; + PLDAPMessage = pldapmsg; + + +(* for modifications *) +const + LDAP_MOD_OP = $0007; + LDAP_MOD_ADD = $0000; + LDAP_MOD_DELETE = $0001; + LDAP_MOD_REPLACE = $0002; + LDAP_MOD_INCREMENT = $0003; (* OpenLDAP extension *) + LDAP_MOD_BVALUES = $0080; + +type + PPPLDAPMod = ^PPLDAPMod; + PPLDAPMod = ^PLDAPMod; + PLDAPMod = ^LDAPMod; + LDAPMod = record + mod_op : cint; + +(* IMPORTANT: do not use code 0x1000 (or above), + * it is used internally by the backends! + * (see ldap/servers/slapd/slap.h) + *) + + mod_type : PChar; + + case cint of + 0: (mod_vals : record + case cint of + 0: (modv_strvals : PPChar); + 1: (modv_bvals : PPBerval); + end); + 1: (case cint of + 0: (mod_values : PPChar); + 1: (mod_bvalues : PPBerval)); + end; + + +(* + * structure representing an ldap session which can + * encompass connections to multiple servers (in the + * face of referrals). + *) + PLDAP = Pointer; + +const + LDAP_DEREF_NEVER = $00; + LDAP_DEREF_SEARCHING = $01; + LDAP_DEREF_FINDING = $02; + LDAP_DEREF_ALWAYS = $03; + + LDAP_NO_LIMIT = 0; + +(* how many messages to retrieve results for *) + LDAP_MSG_ONE = $00; + LDAP_MSG_ALL = $01; + LDAP_MSG_RECEIVED = $02; + +(* + * types for ldap URL handling + *) + +type + pldap_url_desc = ^ldap_url_desc; + ldap_url_desc = record + lud_next : pldap_url_desc; + lud_scheme : PChar; + lud_host : PChar; + lud_port : cint; + lud_dn : PChar; + lud_attrs : PPChar; + lud_scope : cint; + lud_filter : PChar; + lud_exts : PChar; + lud_crit_exts : cint; + end; + + PLDAPURLDesc = ^LDAPURLDesc; + LDAPURLDesc = ldap_url_desc; + +const + LDAP_URL_SUCCESS = $00; (* Success *) + LDAP_URL_ERR_MEM = $01; (* can't allocate memory space *) + LDAP_URL_ERR_PARAM = $02; (* parameter is bad *) + + LDAP_URL_ERR_BADSCHEME = $03; (* URL doesn't begin with "ldap[si]://" *) + LDAP_URL_ERR_BADENCLOSURE = $04; (* URL is missing trailing ">" *) + LDAP_URL_ERR_BADURL = $05; (* URL is bad *) + LDAP_URL_ERR_BADHOST = $06; (* host port is bad *) + LDAP_URL_ERR_BADATTRS = $07; (* bad (or missing) attributes *) + LDAP_URL_ERR_BADSCOPE = $08; (* scope string is invalid (or missing) *) + LDAP_URL_ERR_BADFILTER = $09; (* bad or missing filter *) + LDAP_URL_ERR_BADEXTS = $0a; (* bad or missing extensions *) + +(* + * The API draft spec says we should declare (or cause to be declared) + * 'struct timeval'. We don't. See IETF LDAPext discussions. + *) +type + ptimeval = Pointer; + +(* + * in options.c: + *) +function ldap_get_option( + ld : PLDAP; + option : cint; + outvalue : Pointer + ): cint; cdecl; external; + +function ldap_set_option( + ld : PLDAP; + option : cint; + const invalue : Pointer + ): cint; cdecl; external; + +(* V3 REBIND Function Callback Prototype *) +type + LDAP_REBIND_PROC = function(ld: PLDAP; const url: PChar; request: ber_tag_t; msgid: ber_int_t; params: Pointer): cint; cdecl; + +function ldap_set_rebind_proc( + ld : PLDAP; + rebind_proc : LDAP_REBIND_PROC; + params : Pointer + ): cint; cdecl; external; + +(* V3 referral selection Function Callback Prototype *) +type + LDAP_NEXTREF_PROC = function(ld: PLDAP; refsp: PPPChar; cntp: pcint; params: Pointer): cint; cdecl; + + +function ldap_set_nextref_proc( + ld : PLDAP; + nextref_proc : LDAP_NEXTREF_PROC; + params : Pointer + ): cint; cdecl; external; + + +(* + * in controls.c: + *) + +function ldap_create_control( + const requestOID: PChar; + ber : PBerElement; + iscritical : cint; + var ctrlp : PLDAPControl + ): cint; cdecl; external; + +function ldap_find_control( + const oid : PChar; + ctrls : PPLDAPControl + ): PLDAPControl; cdecl; external; + +procedure ldap_control_free( + ctrl : PLDAPControl + ); cdecl; external; + +procedure ldap_controls_free( + ctrls : PPLDAPControl + ); cdecl; external; + + +(* + * in dnssrv.c: + *) + +function ldap_domain2dn( + const domain : PChar; + var dn : PChar + ): cint; cdecl; external; + +function ldap_dn2domain( + const dn : PChar; + var domain : PChar + ): cint; cdecl; external; + +function ldap_domain2hostlist( + const domain : PChar; + var hostlist : PChar + ): cint; cdecl; external; + + +(* + * in extended.c: + *) + +function ldap_extended_operation( + ld : PLDAP; + const reqoid : PChar; + reqdata : PBerval; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_extended_operation_s( + ld : PLDAP; + const reqoid : PChar; + reqdata : PBerval; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + var retoidp : PChar; + var retdatap : PBerval + ): cint; cdecl; external; + +function ldap_parse_extended_result( + ld : PLDAP; + res : PLDAPMessage; + var retoidp : PChar; + var retdatap : PBerval; + freeit : cbool + ): cint; cdecl; external; + +function ldap_parse_intermediate( + ld : PLDAP; + res : PLDAPMessage; + var retoidp : PChar; + var retdatap : PBerval; + serverctrls : PPPLDAPControl; + freeit : cbool + ): cint; cdecl; external; + + +(* + * in groupings.c: + *) +(*#ifdef LDAP_EXOP_GROUPING_CREATE + +LDAP_F( int ) +ldap_grouping_create LDAP_P(( + LDAP *ld, + LDAP_CONST char *grpoid, + struct berval *grpdata, + LDAPControl **serverctrls, + LDAPControl **clientctrls, + int *msgidp )); + +LDAP_F( int ) +ldap_grouping_create_s LDAP_P(( + LDAP *ld, + LDAP_CONST char *grpoid, + struct berval *grpdata, + LDAPControl **serverctrls, + LDAPControl **clientctrls, + struct berval **retgrpcookiep, + struct berval **retgrpdatap )); + +LDAP_F( int ) +ldap_parse_grouping_create_result LDAP_P(( + LDAP *ld, + LDAPMessage *res, + struct berval **retgrpcookiep, + struct berval **retgrpdatap, + LDAPControl ***serverctrls, + int freeit )); + +LDAP_F( int ) +ldap_grouping_end LDAP_P(( + LDAP *ld, + LDAP_CONST char *grpoid, + struct berval *grpdata, + LDAPControl **serverctrls, + LDAPControl **clientctrls, + int *msgidp )); + +LDAP_F( int ) +ldap_grouping_end_s LDAP_P(( + LDAP *ld, + LDAP_CONST char *grpoid, + struct berval *grpdata, + LDAPControl **serverctrls, + LDAPControl **clientctrls, + struct berval **retgrpdatap )); + +LDAP_F( int ) +ldap_parse_grouping_end_result LDAP_P(( + LDAP *ld, + LDAPMessage *res, + struct berval **retgrpdatap, + LDAPControl ***serverctrls, + int freeit )); + +LDAP_F( int ) +ldap_grouping_action_operation LDAP_P(( + LDAP *ld, + LDAP_CONST char *grpoid, + struct berval *grpdata, + LDAPControl **serverctrls, + LDAPControl **clientctrls, + int *msgidp )); + +LDAP_F( int ) +ldap_grouping_action_operation_s LDAP_P(( + LDAP *ld, + LDAP_CONST char *grpoid, + struct berval *grpdata, + LDAPControl **serverctrls, + LDAPControl **clientctrls, + struct berval **retgrpcookiep, + struct berval **retgrpdatap )); + +LDAP_F( int ) +ldap_parse_grouping_action_result LDAP_P(( + LDAP *ld, + LDAPMessage *res, + struct berval **retgrpcookiep, + struct berval **retgrpdatap, + LDAPControl ***serverctrls, + int freeit )); + +LDAP_F( int ) +ldap_parse_grouping_end_notice LDAP_P(( + LDAP *ld, + LDAPMessage *res, + struct berval **retdatap, + struct berval **retgrpcookiep, + struct berval **retgrpdatap, + int freeit )); + +LDAP_F( int ) +ldap_parse_grouping_info_notice LDAP_P(( + LDAP *ld, + LDAPMessage *res, + struct berval **retdatap, + struct berval **retgrpcookiep, + struct berval **retgrpdatap, + int freeit )); +#endif +*) + + +(* + * in abandon.c: + *) + +function ldap_abandon_ext( + ld : PLDAP; + msgid : cint; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl + ): cint; cdecl; external; + + +(* + * in add.c: + *) + +function ldap_add_ext( + ld : PLDAP; + const dn : PChar; + attrs : PPLDAPMod; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_add_ext_s( + ld : PLDAP; + const dn : PChar; + attrs : PPLDAPMod; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl + ): cint; cdecl; external; + + +(* + * in sasl.c: + *) + +function ldap_sasl_bind( + ld : PLDAP; + const dn : PChar; + const mechanism : PChar; + cred : PBerval; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_sasl_bind_s( + ld : PLDAP; + const dn : PChar; + const mechanism : PChar; + cred : PBerval; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + servercredp : PPBerval + ): cint; cdecl; external; + +(* Interaction flags (should be passed about in a control) + * Automatic (default): use defaults, prompt otherwise + * Interactive: prompt always + * Quiet: never prompt + *) +const + LDAP_SASL_AUTOMATIC = 0; + LDAP_SASL_INTERACTIVE = 1; + LDAP_SASL_QUIET = 2; + +(* + * V3 SASL Interaction Function Callback Prototype + * when using Cyrus SASL, interact is pointer to sasl_interact_t + * should likely passed in a control (and provided controls) + *) +type + LDAP_SASL_INTERACT_PROC = function(ld: PLDAP; flags: cuint; defaults, interact: Pointer): cint; cdecl; + +function ldap_sasl_interactive_bind_s( + ld : PLDAP; + const dn : PChar; + const mechanism : PChar; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + flags : cuint; + proc : LDAP_SASL_INTERACT_PROC; + defaults : Pointer + ): cint; cdecl; external; + +function ldap_parse_sasl_bind_result( + ld : PLDAP; + res : PLDAPMessage; + var servercredp : PBerval; + freeit : cbool + ): cint; cdecl; external; + + +(* + * in compare.c: + *) + +function ldap_compare_ext( + ld : PLDAP; + const dn : PChar; + const attr : PChar; + bvalue : PBerval; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_compare_ext_s( + ld : PLDAP; + const dn : PChar; + const attr : PChar; + bvalue : PBerval; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl + ): cint; cdecl; external; + + +(* + * in delete.c: + *) + +function ldap_delete_ext( + ld : PLDAP; + const dn : PChar; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_delete_ext_s( + ld : PLDAP; + const dn : PChar; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl + ): cint; cdecl; external; + + +(* + * in error.c: + *) + +function ldap_parse_result( + ld : PLDAP; + res : PLDAPMessage; + errcodep : pcint; + matcheddnp : PPChar; + errmsgp : PPChar; + referralsp : PPPChar; + serverctrls : PPPLDAPControl; + freeit : cbool + ): cint; cdecl; external; + +function ldap_err2string( + err : cint + ): PChar; cdecl; external; + + +(* + * in modify.c: + *) + +function ldap_modify_ext( + ld : PLDAP; + const dn : PChar; + mods : PPLDAPMod; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_modify_ext_s( + ld : PLDAP; + const dn : PChar; + mods : PPLDAPMod; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl + ): cint; cdecl; external; + + +(* + * in modrdn.c: + *) + +function ldap_rename( + ld : PLDAP; + const dn : PChar; + const newrdn : PChar; + const newSuperior: PChar; + deleteoldrdn : cbool; + sctrls : PPLDAPControl; + cctrls : PPPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_rename_s( + ld : PLDAP; + const dn : PChar; + const newrdn : PChar; + const newSuperior: PChar; + deleteoldrdn : cbool; + sctrls : PPLDAPControl; + cctrls : PPLDAPControl + ): cint; cdecl; external; + + +(* + * in open.c: + *) + +function ldap_create( + var ld : PLDAP + ): cint; cdecl; external; + +function ldap_initialize( + var ld : PLDAP; + const url : PChar + ): cint; cdecl; external; + + +(* + * in tls.c + *) + +function ldap_tls_inplace( + ld : PLDAP + ): cint; cdecl; external; + +function ldap_install_tls( + ld : PLDAP + ): cint; cdecl; external; + +function ldap_start_tls( + ld : PLDAP; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_start_tls_s( + ld : PLDAP; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl + ): cint; cdecl; external; + + +(* + * in messages.c: + *) + +function ldap_first_message( + ld : PLDAP; + chain : PLDAPMessage + ): PLDAPMessage; cdecl; external; + +function ldap_next_message( + ld : PLDAP; + msg : PLDAPMessage + ): PLDAPMessage; cdecl; external; + +function ldap_count_messages( + ld : PLDAP; + chain : PLDAPMessage + ): cint; cdecl; external; + + +(* + * in references.c: + *) + +function ldap_first_reference( + ld : PLDAP; + chain : PLDAPMessage + ): PLDAPMessage; cdecl; external; + +function ldap_next_reference( + ld : PLDAP; + ref : PLDAPMessage + ): PLDAPMessage; cdecl; external; + +function ldap_count_references( + ld : PLDAP; + chain : PLDAPMessage + ): cint; cdecl; external; + +function ldap_parse_reference( + ld : PLDAP; + ref : PLDAPMessage; + var referralsp : PPChar; + serverctrls : PPPLDAPControl; + freeit : cbool + ): cint; cdecl; external; + + +(* + * in getentry.c: + *) + +function ldap_first_entry( + ld : PLDAP; + chain : PLDAPMessage + ): PLDAPMessage; cdecl; external; + +function ldap_next_entry( + ld : PLDAP; + entry : PLDAPMessage + ): PLDAPMessage; cdecl; external; + +function ldap_count_entries( + ld : PLDAP; + chain : PLDAPMessage + ): cint; cdecl; external; + +function ldap_get_entry_controls( + ld : PLDAP; + entry : PLDAPMessage; + var serverctrls : PPLDAPControl + ): cint; cdecl; external; + + +(* + * in addentry.c + *) + +function ldap_delete_result_entry( + list : PPLDAPMessage; + e : PLDAPMessage + ): PLDAPMessage; cdecl; external; + +procedure ldap_add_result_entry( + list : PPLDAPMessage; + e : PLDAPMessage + ); cdecl; external; + + +(* + * in getdn.c + *) + +function ldap_get_dn( + ld : PLDAP; + entry : PLDAPMessage + ): PChar; cdecl; external; + +const + LDAP_AVA_NULL = $0000; + LDAP_AVA_STRING = $0001; + LDAP_AVA_BINARY = $0002; + LDAP_AVA_NONPRINTABLE = $0004; + LDAP_AVA_FREE_ATTR = $0010; + LDAP_AVA_FREE_VALUE = $0020; + +type + pldap_ava = ^ldap_ava; + ldap_ava = record + la_attr : berval; + la_value : berval; + la_flags : cuint; + la_private : Pointer; + end; + + PLDAPAVA = ^LDAPAVA; + LDAPAVA = ldap_ava; + + PLDAPRDN = ^LDAPRDN; + LDAPRDN = ^PLDAPAVA; + + PLDAPDN = ^LDAPDN; + LDAPDN = ^LDAPRDN; + +const +(* DN formats *) + LDAP_DN_FORMAT_LDAP = $0000; + LDAP_DN_FORMAT_LDAPV3 = $0010; + LDAP_DN_FORMAT_LDAPV2 = $0020; + LDAP_DN_FORMAT_DCE = $0030; + LDAP_DN_FORMAT_UFN = $0040; (* dn2str only *) + LDAP_DN_FORMAT_AD_CANONICAL = $0050; (* dn2str only *) + LDAP_DN_FORMAT_LBER = $00F0; (* for testing only *) + LDAP_DN_FORMAT_MASK = $00F0; + +(* DN flags *) + LDAP_DN_PRETTY = $0100; + LDAP_DN_SKIP = $0200; + LDAP_DN_P_NOLEADTRAILSPACES = $1000; + LDAP_DN_P_NOSPACEAFTERRDN = $2000; + LDAP_DN_PEDANTIC = $F000; + +procedure ldap_rdnfree(rdn: LDAPRDN); cdecl; external; +procedure ldap_dnfree(rdn: LDAPDN); cdecl; external; + +function ldap_bv2dn( + bv : PBerval; + var dn : LDAPDN; + flags : cuint + ): cint; cdecl; external; + +function ldap_str2dn( + const str : PChar; + var dn : LDAPDN; + flags : cuint + ): cint; cdecl; external; + +function ldap_dn2bv( + dn : LDAPDN; + bv : PBerval; + flags : cuint + ): cint; cdecl; external; + +function ldap_dn2str( + dn : LDAPDN; + var str : PChar; + flags : cuint + ): cint; cdecl; external; + +function ldap_bv2rdn( + bv : PBerval; + var rdn : LDAPRDN; + var next : PChar; + flags : cuint + ): cint; cdecl; external; + +function ldap_str2rdn( + const str : PChar; + var rdn : LDAPRDN; + var next : PChar; + flags : cuint + ): cint; cdecl; external; + +function ldap_rdn2bv( + rdn : LDAPRDN; + bv : PBerval; + flags : cuint + ): cint; cdecl; external; + +function ldap_rdn2str( + rdn : LDAPRDN; + var str : PChar; + flags : cuint + ): cint; cdecl; external; + +function ldap_dn_normalize( + const _in : PChar; + iflags : cuint; + var _out : PChar; + oflags : cuint + ): cint; cdecl; external; + + +type + LDAPDN_rewrite_func = function(dn: LDAPDN; flags: cuint; ctx: Pointer): cint; cdecl; + +function ldap_X509dn2bv( + x509_name : Pointer; + dn : PBerval; + func : LDAPDN_rewrite_func; + flags : cuint + ): cint; cdecl; external; + +function ldap_get_dn_ber( + ld : PLDAP; + e : PLDAPMessage; + var berout : PBerElement; + dn : PBerval + ): cint; cdecl; external; + +function ldap_get_attribute_ber( + ld : PLDAP; + e : PLDAPMessage; + ber : PBerElement; + attr : PBerval; + var vals : PBerval + ): cint; cdecl; external; + + +(* + * in getattr.c + *) + +function ldap_first_attribute( + ld : PLDAP; + entry : PLDAPMessage; + var ber : PBerElement + ): PChar; cdecl; external; + +function ldap_next_attribute( + ld : PLDAP; + entry : PLDAPMessage; + ber : PBerElement + ): PChar; cdecl; external; + + +(* + * in getvalues.c + *) + +function ldap_get_values_len( + ld : PLDAP; + entry : PLDAPMessage; + const target : PChar + ): PPBerval; cdecl; external; + +function ldap_count_values_len( + vals : PPBerval + ): cint; cdecl; external; + +procedure ldap_value_free_len( + vals : PPBerval + ); cdecl; external; + + +(* + * in result.c: + *) + +function ldap_result( + ld : PLDAP; + msgid : cint; + all : cint; + timeout : ptimeval; + var result : PLDAPMessage + ): cint; cdecl; external; + +function ldap_msgtype( + lm : PLDAPMessage + ): cint; cdecl; external; + +function ldap_msgid( + lm : PLDAPMessage + ): cint; cdecl; external; + +function ldap_msgfree( + lm : PLDAPMessage + ): cint; cdecl; external; + +function ldap_msgdelete( + ld : PLDAP; + msgid : cint + ): cint; cdecl; external; + + +(* + * in search.c: + *) + +function ldap_search_ext( + ld : PLDAP; + const base : PChar; + scope : cint; + const filter : PChar; + attrs : PPChar; + attrsonly : cbool; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + timout : ptimeval; + sizelimit : cint; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_search_ext_s( + ld : PLDAP; + const base : PChar; + scope : cint; + const filter : PChar; + attrs : PPChar; + attrsonly : cbool; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl; + timout : ptimeval; + sizelimit : cint; + var res : PLDAPMessage + ): cint; cdecl; external; + + +(* + * in unbind.c + *) + +function ldap_unbind_ext( + ld : PLDAP; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl + ): cint; cdecl; external; + +function ldap_unbind_ext_s( + ld : PLDAP; + serverctrls : PPLDAPControl; + clientctrls : PPLDAPControl + ): cint; cdecl; external; + + +(* + * in filter.c + *) + +function ldap_put_vrFilter( + ber : PBerElement; + const vrf : PChar + ): cint; cdecl; external; + + +(* + * in free.c + *) + +function ldap_memalloc( + s : ber_len_t + ): Pointer; cdecl; external; + +function ldap_memrealloc( + p : Pointer; + s : ber_len_t + ): Pointer; cdecl; external; + +function ldap_memcalloc( + n : ber_len_t; + s : ber_len_t + ): Pointer; cdecl; external; + +procedure ldap_memfree( + p : Pointer + ); cdecl; external; + +procedure ldap_memvfree( + v : PPointer + ); cdecl; external; + +function ldap_strdup( + const str : PChar + ): PChar; cdecl; external; + +procedure ldap_mods_free( + mods : PPLDAPMod; + freemods : cbool + ); cdecl; external; + + +(* + * in url.c + *) + +function ldap_is_ldap_url( + const url : PChar + ): cint; cdecl; external; + +function ldap_is_ldaps_url( + const url : PChar + ): cint; cdecl; external; + +function ldap_is_ldapi_url( + const url : PChar + ): cint; cdecl; external; + +function ldap_url_parse( + const url : PChar; + var ludpp : PLDAPURLDesc + ): cint; cdecl; external; + +function ldap_url_desc2str( + ludpp : PLDAPURLDesc + ): PChar; cdecl; external; + +procedure ldap_free_urldesc( + ludpp : PLDAPURLDesc + ); cdecl; external; + + +(* + * LDAP Cancel Extended Operation + * in cancel.c + *) +const + LDAP_API_FEATURE_CANCEL = 1000; + +function ldap_cancel( + ld : PLDAP; + cancelid : cint; + sctrl : PPLDAPControl; + cctrl : PPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + + +function ldap_cancel_s( + ld : PLDAP; + cancelid : cint; + sctrl : PPLDAPControl; + cctrl : PPLDAPControl + ): cint; cdecl; external; + + +(* + * LDAP Server Side Sort + * in sortctrl.c + *) + +const + LDAP_API_FEATURE_SERVER_SIDE_SORT = 1000; + +(* structure for a sort-key *) +type + PPLDAPSortKey = ^PLDAPSortKey; + PLDAPSortKey = ^LDAPSortKey; + LDAPSortKey = record + attributeType : PChar; + orderingRule : PChar; + reverseOrder : cbool; + end; + + +function ldap_create_sort_keylist( + var sortKeyList : PPLDAPSortKey; + keyString : PChar + ): cint; cdecl; external; + +procedure ldap_free_sort_keylist( + sortKeyList : PPLDAPSortKey + ); cdecl; external; + +function ldap_create_sort_control( + ld : PLDAP; + keyList : PPLDAPSortKey; + ctl_iscritical : cbool; + var ctrlp : PLDAPControl + ): cint; cdecl; external; + +function ldap_parse_sort_control( + ld : PLDAP; + ctrlp : PPLDAPControl; + var result : culong; + var attribute : PChar + ): cint; cdecl; external; + + +(* + * LDAP Virtual List View + * in vlvctrl.c + *) +const + LDAP_API_FEATURE_VIRTUAL_LIST_VIEW = 1000; + +(* structure for virtual list *) +type + PLDAPVLVInfo = ^LDAPVLVInfo; + LDAPVLVInfo = record + ldvlv_version : cint; + ldvlv_before_count : culong; + ldvlv_after_count : culong; + ldvlv_offset : culong; + ldvlv_count : culong; + ldvlv_attrvalue : PBerval; + ldvlv_context : PBerval; + ldvlv_extradata : Pointer; + end; + +function ldap_create_vlv_control( + ld : PLDAP; + ldvlistp : PLDAPVLVInfo; + var ctrlp : PLDAPControl + ): cint; cdecl; external; + +function ldap_parse_vlv_control( + ld : PLDAP; + ctrls : PPLDAPControl; + var target_posp : culong; + var list_countp : culong; + var contextp : PBerval; + var errcodep : cint + ): cint; cdecl; external; + + +(* + * LDAP Transactions + * in txn.c + *) + +(* +#ifdef LDAP_GROUP_TRANSACTION +LDAP_F( int ) +ldap_parse_txn_create LDAP_P(( + LDAP *ld, + LDAPMessage *res, + struct berval **cookie )); + +LDAP_F( int ) +ldap_txn_create LDAP_P(( + LDAP *ld, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp )); + +LDAP_F( int ) +ldap_txn_create_s LDAP_P(( + LDAP *ld, + struct berval **cookie, + LDAPControl **sctrls, + LDAPControl **cctrls )); + +LDAP_F( int ) +ldap_txn_end LDAP_P(( + LDAP *ld, + struct berval *cookie, + int commit, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp )); + +LDAP_F( int ) +ldap_txn_end_s LDAP_P(( + LDAP *ld, + struct berval *cookie, + int commit, + LDAPControl **sctrls, + LDAPControl **cctrls )); +#endif*) + + +(* + * LDAP Who Am I? + * in whoami.c + *) +const + LDAP_API_FEATURE_WHOAMI = 1000; + +function ldap_parse_whoami( + ld : PLDAP; + res : PLDAPMessage; + var authzid : PBerval + ): cint; cdecl; external; + +function ldap_whoami( + ld : PLDAP; + sctrl : PPLDAPControl; + cctrl : PPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_whoami_s( + ld : PLDAP; + var authzid : PBerval; + sctrl : PPLDAPControl; + cctrl : PPLDAPControl + ): cint; cdecl; external; + + +(* + * LDAP Password Modify + * in passwd.c + *) +const + LDAP_API_FEATURE_PASSWD_MODIFY = 1000; + +function ldap_parse_passwd( + ld : PLDAP; + res : PLDAPMessage; + newpasswd : PBerval + ): cint; cdecl; external; + +function ldap_passwd( + ld : PLDAP; + user : PBerval; + oldpw : PBerval; + newpw : PBerval; + sctrl : PPLDAPControl; + cctrl : PPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_passwd_s( + ld : PLDAP; + user : PBerval; + oldpw : PBerval; + newpw : PBerval; + newpasswd : PBerval; + sctrl : PPLDAPControl; + cctrl : PPLDAPControl + ): cint; cdecl; external; + + +(* + * LDAP Password Policy controls + * in ppolicy.c + *) + +(* +#ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST +#define LDAP_API_FEATURE_PASSWORD_POLICY 1000 + +typedef enum passpolicyerror_enum { + PP_passwordExpired = 0, + PP_accountLocked = 1, + PP_changeAfterReset = 2, + PP_passwordModNotAllowed = 3, + PP_mustSupplyOldPassword = 4, + PP_insufficientPasswordQuality = 5, + PP_passwordTooShort = 6, + PP_passwordTooYoung = 7, + PP_passwordInHistory = 8, + PP_noError = 65535 +} LDAPPasswordPolicyError; + +LDAP_F( int ) +ldap_create_passwordpolicy_control LDAP_P(( + LDAP *ld, + LDAPControl **ctrlp )); + +LDAP_F( int ) +ldap_parse_passwordpolicy_control LDAP_P(( + LDAP *ld, + LDAPControl *ctrl, + int *expirep, + int *gracep, + LDAPPasswordPolicyError *errorp )); + +LDAP_F( const char * ) +ldap_passwordpolicy_err2txt LDAP_P(( LDAPPasswordPolicyError )); +#endif*) + + +(* + * hacks for NTLM + *) +const + LDAP_AUTH_NTLM_REQUEST = ber_tag_t($8a); + LDAP_AUTH_NTLM_RESPONSE = ber_tag_t($8b); + +function ldap_ntlm_bind( + ld : PLDAP; + const dn : PChar; + tag : ber_tag_t; + cred : PBerval; + sctrl : PPLDAPControl; + cctrl : PPLDAPControl; + var msgidp : cint + ): cint; cdecl; external; + +function ldap_parse_ntlm_bind_result( + ld : PLDAP; + res : PLDAPMessage; + challenge : PBerval + ): cint; cdecl; external; diff --git a/packages/extra/ldap/ntlm.pas b/packages/extra/ldap/ntlm.pas new file mode 100644 index 0000000000..cd975d9487 --- /dev/null +++ b/packages/extra/ldap/ntlm.pas @@ -0,0 +1,434 @@ +(* + Translation of the SAMBA md4 code for FreePascal + Copyright (C) 2006 by Ivo Steinmann + Ported from SAMBA/source/libsmb/smbdes.c + + Unix SMB/CIFS implementation. + + a partial implementation of DES designed for use in the + SMB authentication protocol + + Copyright (C) Andrew Tridgell 1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*) + +unit ntlm; + +{$mode objfpc} + +interface + +uses + Strings, + Math, + md4; + +type + THash = array[0..15] of Byte; + +procedure nt_lm_owf_gen(const pwd: PChar; var nt_p16: THash; var lm_p16: THash); +procedure hash_to_str(const h: THash; const str: PChar); + +implementation + + +// +// Ported from SAMBA/source/libsmb/smbdes.c +// + +const + perm1: array[0..55] of Byte = ( + 57, 49, 41, 33, 25, 17, 9, + 1, 58, 50, 42, 34, 26, 18, + 10, 2, 59, 51, 43, 35, 27, + 19, 11, 3, 60, 52, 44, 36, + 63, 55, 47, 39, 31, 23, 15, + 7, 62, 54, 46, 38, 30, 22, + 14, 6, 61, 53, 45, 37, 29, + 21, 13, 5, 28, 20, 12, 4); + + perm2: array[0..47] of Byte = ( + 14, 17, 11, 24, 1, 5, + 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, + 16, 7, 27, 20, 13, 2, + 41, 52, 31, 37, 47, 55, + 30, 40, 51, 45, 33, 48, + 44, 49, 39, 56, 34, 53, + 46, 42, 50, 36, 29, 32); + + perm3: array[0..63] of Byte = ( + 58, 50, 42, 34, 26, 18, 10, 2, + 60, 52, 44, 36, 28, 20, 12, 4, + 62, 54, 46, 38, 30, 22, 14, 6, + 64, 56, 48, 40, 32, 24, 16, 8, + 57, 49, 41, 33, 25, 17, 9, 1, + 59, 51, 43, 35, 27, 19, 11, 3, + 61, 53, 45, 37, 29, 21, 13, 5, + 63, 55, 47, 39, 31, 23, 15, 7); + + perm4: array[0..47] of Byte = ( + 32, 1, 2, 3, 4, 5, + 4, 5, 6, 7, 8, 9, + 8, 9, 10, 11, 12, 13, + 12, 13, 14, 15, 16, 17, + 16, 17, 18, 19, 20, 21, + 20, 21, 22, 23, 24, 25, + 24, 25, 26, 27, 28, 29, + 28, 29, 30, 31, 32, 1); + + perm5: array[0..31] of Byte = ( + 16, 7, 20, 21, + 29, 12, 28, 17, + 1, 15, 23, 26, + 5, 18, 31, 10, + 2, 8, 24, 14, + 32, 27, 3, 9, + 19, 13, 30, 6, + 22, 11, 4, 25); + + perm6: array[0..63] of Byte = ( + 40, 8, 48, 16, 56, 24, 64, 32, + 39, 7, 47, 15, 55, 23, 63, 31, + 38, 6, 46, 14, 54, 22, 62, 30, + 37, 5, 45, 13, 53, 21, 61, 29, + 36, 4, 44, 12, 52, 20, 60, 28, + 35, 3, 43, 11, 51, 19, 59, 27, + 34, 2, 42, 10, 50, 18, 58, 26, + 33, 1, 41, 9, 49, 17, 57, 25); + + sc: array[0..15] of Byte = (1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1); + + sbox: array[0..7, 0..3, 0..15] of Byte = ( + ((14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7), + (0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8), + (4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0), + (15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13)), + + ((15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10), + (3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5), + (0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15), + (13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9)), + + ((10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8), + (13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1), + (13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7), + (1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12)), + + ((7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15), + (13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9), + (10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4), + (3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14)), + + ((2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9), + (14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6), + (4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14), + (11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3)), + + ((12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11), + (10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8), + (9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6), + (4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13)), + + ((4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1), + (13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6), + (1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2), + (6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12)), + + ((13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7), + (1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2), + (7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8), + (2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11))); + + +procedure permute({out} const _out: PByte; {in} const _in: PByte; {in} const p: PByte; {in} const n: Integer); +var + i: Integer; +begin + for i := 0 to n-1 do + _out[i] := _in[p[i]-1]; +end; + +procedure lshift({in/out} const d: PByte; {in} const count: Integer; {in} const n: Integer); +var + _out : array[0..63] of Byte; + i : Integer; +begin + for i := 0 to n-1 do + _out[i] := d[(i+count) mod n]; + for i := 0 to n-1 do + d[i] := _out[i]; +end; + +procedure concat({out} const _out: PByte; {in} const _in1, _in2: PByte; {in} const l1, l2: Integer); +var + i: Integer; +begin + for i := 0 to l1-1 do + _out[i] := _in1[i]; + for i := 0 to l2-1 do + _out[i+l1] := _in2[i]; +end; + +procedure mxor({out} const _out: PByte; {in} const _in1, _in2: PByte; {in} const n: Integer); +var + i: Integer; +begin + for i := 0 to n-1 do + _out[i] := _in1[i] xor _in2[i]; +end; + +procedure dohash({out} const _out: PByte; {in} const _in: PByte; {in} const key: PByte; {in} const forw: Boolean); +var + i : Integer; + j : Integer; + k : Integer; + pk1 : array[0..55] of Byte; + c : array[0..27] of Byte; + d : array[0..27] of Byte; + cd : array[0..55] of Byte; + ki : array[0..15,0..47] of Byte; + pd1 : array[0..63] of Byte; + l : array[0..31] of Byte; + r : array[0..31] of Byte; + rl : array[0..63] of Byte; + + er : array[0..47] of Byte; + erk : array[0..47] of Byte; + b : array[0..7,0..5] of Byte; + cb : array[0..31] of Byte; + pcb : array[0..31] of Byte; + r2 : array[0..31] of Byte; + + m : Integer; + n : Integer; +begin + permute(@pk1, key, @perm1, 56); + + for i := 0 to 27 do + begin + c[i] := pk1[i]; + d[i] := pk1[i+28]; + end; + + for i := 0 to 15 do + begin + lshift(@c, sc[i], 28); + lshift(@d, sc[i], 28); + + concat(@cd, @c, @d, 28, 28); + permute(@ki[i][0], @cd, @perm2, 48); + end; + + permute(@pd1, _in, @perm3, 64); + + for i := 0 to 31 do + begin + l[i] := pd1[i]; + r[i] := pd1[i+32]; + end; + + for i := 0 to 15 do + begin + permute(@er, @r, @perm4, 48); + + if forw then + mxor(@erk, @er, @ki[i][0], 48) else + mxor(@erk, @er, @ki[15-i][0], 48); + + for j := 0 to 7 do + for k := 0 to 5 do + b[j][k] := erk[j*6 + k]; + + for j := 0 to 7 do + begin + m := (b[j][0] shl 1) or b[j][5]; + + n := (b[j][1] shl 3) or (b[j][2] shl 2) or (b[j][3] shl 1) or (b[j][4]); + + for k := 0 to 3 do + b[j][k] := min(sbox[j][m][n] and (1 shl (3-k)), 1); // store binary + end; + + for j := 0 to 7 do + for k := 0 to 3 do + cb[j*4+k] := b[j][k]; + + permute(@pcb, @cb, @perm5, 32); + + mxor(@r2, @l, @pcb, 32); + + for j := 0 to 31 do + begin + l[j] := r[j]; + r[j] := r2[j]; + end; + end; + + concat(@rl, @r, @l, 32, 32); + + permute(_out, @rl, @perm6, 64); +end; + +procedure str_to_key({in} const str: PByte; {out} const key: PByte); +var + i: Integer; +begin + key[0] := str[0] shr 1; + key[1] := ((str[0] and $01) shl 6) or (str[1] shr 2); + key[2] := ((str[1] and $03) shl 5) or (str[2] shr 3); + key[3] := ((str[2] and $07) shl 4) or (str[3] shr 4); + key[4] := ((str[3] and $0F) shl 3) or (str[4] shr 5); + key[5] := ((str[4] and $1F) shl 2) or (str[5] shr 6); + key[6] := ((str[5] and $3F) shl 1) or (str[6] shr 7); + key[7] := str[6] and $7F; + for i := 0 to 7 do + key[i] := key[i] shl 1; +end; + +procedure smbhash({out} const _out: PByte; {in} const _in: PByte; {in} const key: PByte; {in} const forw: Boolean); +var + i : Integer; + outb : array[0..63] of Byte; + inb : array[0..63] of Byte; + keyb : array[0..63] of Byte; + key2 : array[0..7] of Byte; +begin + str_to_key(key, @key2); + + for i := 0 to 63 do + begin + inb[i] := min( _in[i div 8] and (1 shl (7-(i mod 8))), 1); // store binary + keyb[i] := min(key2[i div 8] and (1 shl (7-(i mod 8))), 1); // store binary + outb[i] := 0; + end; + + dohash(@outb, @inb, @keyb, forw); + + for i := 0 to 7 do + _out[I] := 0; + + for i := 0 to 63 do + begin + if outb[i] <> 0 then + _out[i div 8] := _out[i div 8] or (1 shl (7-(i mod 8))); + end; +end; + +procedure E_P16({in} const p14: PByte; {out} const p16: PByte); +const + sp8: array[0..7] of Byte = ($4b, $47, $53, $21, $40, $23, $24, $25); +begin + smbhash(@p16[0], @sp8, @p14[0], True); + smbhash(@p16[8], @sp8, @p14[7], True); +end; + +procedure E_P24({in} const p21: PByte; {in} const c8: PByte; {out} const p24: PByte); +begin + smbhash(@p24[0], c8, @p21[0], True); + smbhash(@p24[8], c8, @p21[7], True); + smbhash(@p24[16], c8, @p21[14], True); +end; + + + +// +// Ported from SAMBA/source/libsmb/smbencrypt.c +// + +(* + * Creates the MD4 Hash of the users password in NT UNICODE. + *) + +procedure E_md4hash({in} const pwd: PByte; {out} const p16: PByte); +var + len : Integer; + wpwd : array[0..128] of Word; +begin + FillChar(wpwd, Sizeof(wpwd), 0); + + (* Password must be converted to NT unicode - null terminated *) + len := 0; + while (len < 128) and (pwd[len] <> 0) do + begin + wpwd[len] := pwd[len]; + Inc(len); + end; + + mdfour(p16, @wpwd[0], 2*len); + + FillChar(wpwd, Sizeof(wpwd), 0); +end; + +procedure E_deshash({in} const pwd: PByte; {out} const p16: PByte); +var + dospwd: array[0..14] of Byte; +begin + FillChar(dospwd, Sizeof(dospwd), 0); + + (* Password must be converted to DOS charset - null terminated, uppercase *) + StrLCopy(@dospwd, @pwd[0], Sizeof(dospwd)-1); + StrUpper(@dospwd); + + (* ONly the first 14 chars are considered, password need not be null terminated *) + E_P16(@dospwd, p16); + + FillChar(dospwd, Sizeof(dospwd), 0); +end; + + +(* + * Does both the NT and LM owfs of a user's password + *) + +procedure nt_lm_owf_gen({in} const pwd: PChar; {out} var nt_p16: THash; {out} var lm_p16: THash); +var + passwd: array[0..513] of Char; +begin + FillChar(passwd, Sizeof(passwd), 0); + StrLCopy(passwd, pwd, sizeof(passwd)-1); + + (* Calculate the MD4 hash (NT compatible) of the password *) + FillChar(nt_p16, Sizeof(nt_p16), 0); + E_md4hash(@passwd, @nt_p16); + + (* Calculate the SMB (lanman) hash functions of the password *) + FillChar(lm_p16, Sizeof(lm_p16), 0); + E_deshash(@passwd, @lm_p16); + + (* clear out local copy of user's password (just being paranoid). *) + FillChar(passwd, Sizeof(passwd), 0); +end; + +procedure hash_to_str({in} const h: THash; {out} const str: PChar); +const + to_hex: array[0..15] of char = ('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); +var + i: integer; + p: PChar; +begin + p := str; + for i := 0 to 15 do + begin + p^ := to_hex[(h[i] shr 4) and $F]; + Inc(p); + p^ := to_hex[h[i] and $F]; + inc(p); + end; + p^ := #0; +end; + +end.