Projects
Kolab:16
mozldap
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
mozldap.spec
Changed
@@ -17,13 +17,13 @@ %define major 6 %define minor 0 -%define submin 5 +%define submin 7 %define libsuffix %{major}0 Summary: Mozilla LDAP C SDK Name: mozldap Version: %{major}.%{minor}.%{submin} -Release: 11%{?dist} +Release: 1%{?dist} License: MPLv1.1 or GPLv2+ or LGPLv2+ URL: http://www.mozilla.org/directory/csdk.html Group: System Environment/Libraries @@ -81,7 +81,7 @@ %setup -q %build -cd mozilla/directory/c-sdk +cd c-sdk %configure \ %ifarch x86_64 ppc64 ia64 s390x sparc64 @@ -117,7 +117,7 @@ # Set up our package file %{__mkdir_p} $RPM_BUILD_ROOT%{_libdir}/pkgconfig -%{__cat} mozilla/directory/c-sdk/mozldap.pc.in \ +%{__cat} c-sdk/mozldap.pc.in \ | sed -e "s,%%libdir%%,%{_libdir},g" \ -e "s,%%prefix%%,%{_prefix},g" \ -e "s,%%major%%,%{major},g" \ @@ -144,13 +144,13 @@ # Copy the binary libraries we want for file in libssldap%{libsuffix}.so libprldap%{libsuffix}.so libldap%{libsuffix}.so libldif%{libsuffix}.so do - %{__install} -m 755 mozilla/dist/lib/$file $RPM_BUILD_ROOT%{_libdir} + %{__install} -m 755 ../dist/lib/$file $RPM_BUILD_ROOT%{_libdir} done # Copy the binaries we want for file in ldapsearch ldapmodify ldapdelete ldapcmp ldapcompare ldappasswd do - %{__install} -m 755 mozilla/dist/bin/$file $RPM_BUILD_ROOT%{_libexecdir}/%{name} + %{__install} -m 755 ../dist/bin/$file $RPM_BUILD_ROOT%{_libexecdir}/%{name} %if "%{_libexecdir}" != "%{_libdir}" pushd $RPM_BUILD_ROOT%{_libdir}/%{name} ln -s ../../..%{_libexecdir}/%{name}/$file $file @@ -159,19 +159,19 @@ done # Copy the include files -for file in mozilla/dist/public/ldap/*.h +for file in ../dist/public/ldap/*.h do %{__install} -p -m 644 $file $RPM_BUILD_ROOT%{_includedir}/%{name} done # Copy the developer files %{__mkdir_p} $RPM_BUILD_ROOT%{_datadir}/%{name} -cp -r mozilla/directory/c-sdk/ldap/examples $RPM_BUILD_ROOT%{_datadir}/%{name} +cp -r c-sdk/ldap/examples $RPM_BUILD_ROOT%{_datadir}/%{name} %{__mkdir_p} $RPM_BUILD_ROOT%{_datadir}/%{name}/etc -%{__install} -m 644 mozilla/directory/c-sdk/ldap/examples/xmplflt.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc -%{__install} -m 644 mozilla/directory/c-sdk/ldap/libraries/libldap/ldaptemplates.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc -%{__install} -m 644 mozilla/directory/c-sdk/ldap/libraries/libldap/ldapfilter.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc -%{__install} -m 644 mozilla/directory/c-sdk/ldap/libraries/libldap/ldapsearchprefs.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc +%{__install} -m 644 c-sdk/ldap/examples/xmplflt.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc +%{__install} -m 644 c-sdk/ldap/libraries/libldap/ldaptemplates.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc +%{__install} -m 644 c-sdk/ldap/libraries/libldap/ldapfilter.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc +%{__install} -m 644 c-sdk/ldap/libraries/libldap/ldapsearchprefs.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc %pre %if "%{_libexecdir}" != "%{_libdir}" @@ -194,7 +194,7 @@ %files %defattr(-,root,root,-) -%doc mozilla/directory/c-sdk/README.rpm +%doc c-sdk/README.rpm %{_libdir}/libssldap*.so %{_libdir}/libprldap*.so %{_libdir}/libldap*.so @@ -226,6 +226,9 @@ %{_datadir}/%{name} %changelog +* Sat Apr 07 2018 Christoph Erhardt <kolab@sicherha.de> - 6.0.7-1 +- Bump version to 6.0.7. + * Wed Oct 30 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 6.0.5-11 - Move the commands from a lib_t labeled directory to a bin_t labeled directory. @@ -279,7 +282,7 @@ - Fixed exports file generation for Solaris and Windows - no effect on linux - bumped version to 6.0.2 -* Mon Jan 9 2007 Rich Megginson <richm@stanfordalumni.org> - 6.0.1-2 +* Tue Jan 9 2007 Rich Megginson <richm@stanfordalumni.org> - 6.0.1-2 - Remove buildroot = "/" checking - Remove buildroot removal from %%build section
View file
debian-aggregate.patch
Changed
@@ -1,6 +1,6 @@ -diff -ur mozldap-6.0.5.orig/mozilla/directory/c-sdk/config/nsinstall.c mozldap-6.0.5/mozilla/directory/c-sdk/config/nsinstall.c ---- mozldap-6.0.5.orig/mozilla/directory/c-sdk/config/nsinstall.c 2003-10-10 16:03:43.000000000 +0100 -+++ mozldap-6.0.5/mozilla/directory/c-sdk/config/nsinstall.c 2013-09-07 16:35:36.268374378 +0100 +diff -ur mozldap-6.0.7.orig/c-sdk/config/nsinstall.c mozldap-6.0.7/c-sdk/config/nsinstall.c +--- mozldap-6.0.7.orig/c-sdk/config/nsinstall.c 2003-10-10 16:03:43.000000000 +0100 ++++ mozldap-6.0.7/c-sdk/config/nsinstall.c 2013-09-07 16:35:36.268374378 +0100 @@ -109,7 +109,7 @@ } #endif /* NEXTSTEP */ @@ -10,9 +10,9 @@ #include <getopt.h> #endif -diff -ur mozldap-6.0.5.orig/mozilla/directory/c-sdk/configure.in mozldap-6.0.5/mozilla/directory/c-sdk/configure.in ---- mozldap-6.0.5.orig/mozilla/directory/c-sdk/configure.in 2007-09-17 18:46:23.000000000 +0100 -+++ mozldap-6.0.5/mozilla/directory/c-sdk/configure.in 2013-09-07 16:36:01.274304681 +0100 +diff -ur mozldap-6.0.7.orig/c-sdk/configure.in mozldap-6.0.7/c-sdk/configure.in +--- mozldap-6.0.7.orig/c-sdk/configure.in 2007-09-17 18:46:23.000000000 +0100 ++++ mozldap-6.0.7/c-sdk/configure.in 2013-09-07 16:36:01.274304681 +0100 @@ -42,7 +42,7 @@ AC_PREREQ(2.12) AC_INIT(ldap/include/ldap.h) @@ -22,9 +22,9 @@ AC_CANONICAL_SYSTEM dnl ======================================================== -diff -ur mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/include/portable.h mozldap-6.0.5/mozilla/directory/c-sdk/ldap/include/portable.h ---- mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/include/portable.h 2006-10-03 21:43:40.000000000 +0100 -+++ mozldap-6.0.5/mozilla/directory/c-sdk/ldap/include/portable.h 2013-09-07 16:35:36.268374378 +0100 +diff -ur mozldap-6.0.7.orig/c-sdk/ldap/include/portable.h mozldap-6.0.7/c-sdk/ldap/include/portable.h +--- mozldap-6.0.7.orig/c-sdk/ldap/include/portable.h 2006-10-03 21:43:40.000000000 +0100 ++++ mozldap-6.0.7/c-sdk/ldap/include/portable.h 2013-09-07 16:35:36.268374378 +0100 @@ -122,7 +122,7 @@ * some systems don't have the BSD re_comp and re_exec routines */ @@ -83,9 +83,9 @@ defined(SCOOS) || defined(BSDI) || defined(NCR) || \ defined(NEC) || ( defined(HPUX10) && !defined(_REENTRANT)) || \ (defined(AIX) && !defined(USE_REENTRANT_LIBC)) -diff -ur mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libldap/Makefile.client mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libldap/Makefile.client ---- mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libldap/Makefile.client 2003-10-15 18:26:01.000000000 +0100 -+++ mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libldap/Makefile.client 2013-09-07 16:35:36.269374375 +0100 +diff -ur mozldap-6.0.7.orig/c-sdk/ldap/libraries/libldap/Makefile.client mozldap-6.0.7/c-sdk/ldap/libraries/libldap/Makefile.client +--- mozldap-6.0.7.orig/c-sdk/ldap/libraries/libldap/Makefile.client 2003-10-15 18:26:01.000000000 +0100 ++++ mozldap-6.0.7/c-sdk/ldap/libraries/libldap/Makefile.client 2013-09-07 16:35:36.269374375 +0100 @@ -177,7 +177,7 @@ EXTRA_LIBS += -L$(NSCP_DISTDIR)/lib endif @@ -104,9 +104,9 @@ $(LINK_LIB) ../liblber/$(OBJDIR_NAME)/*.a else $(LINK_LIB) $(EXTRA_LIBS) -diff -ur mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libldap/Makefile.in mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libldap/Makefile.in ---- mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libldap/Makefile.in 2007-06-20 18:57:11.000000000 +0100 -+++ mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libldap/Makefile.in 2013-09-07 16:35:51.511333122 +0100 +diff -ur mozldap-6.0.7.orig/c-sdk/ldap/libraries/libldap/Makefile.in mozldap-6.0.7/c-sdk/ldap/libraries/libldap/Makefile.in +--- mozldap-6.0.7.orig/c-sdk/ldap/libraries/libldap/Makefile.in 2007-06-20 18:57:11.000000000 +0100 ++++ mozldap-6.0.7/c-sdk/ldap/libraries/libldap/Makefile.in 2013-09-07 16:35:51.511333122 +0100 @@ -122,7 +122,7 @@ HDIR = $(topsrcdir)/ldap/include @@ -144,9 +144,9 @@ endif ifeq ($(OS_ARCH), WINNT) $(INSTALL) -m 444 $(LIBLDAP) $(dist_libdir) -diff -ur mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libldif/Makefile.in mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libldif/Makefile.in ---- mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libldif/Makefile.in 2007-06-20 18:57:11.000000000 +0100 -+++ mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libldif/Makefile.in 2013-09-07 16:35:47.129344984 +0100 +diff -ur mozldap-6.0.7.orig/c-sdk/ldap/libraries/libldif/Makefile.in mozldap-6.0.7/c-sdk/ldap/libraries/libldif/Makefile.in +--- mozldap-6.0.7.orig/c-sdk/ldap/libraries/libldif/Makefile.in 2007-06-20 18:57:11.000000000 +0100 ++++ mozldap-6.0.7/c-sdk/ldap/libraries/libldif/Makefile.in 2013-09-07 16:35:47.129344984 +0100 @@ -53,7 +53,7 @@ HDIR = $(topsrcdir)/ldap/include @@ -162,9 +162,9 @@ $(INSTALL) -m 444 $(DLLLDIF) $(dist_bindir) + ln -sf $(DLLLDIF) $(dist_libdir)/$(LIB_PREFIX)$(LDIF_LIBNAME).$(DLL_SUFFIX) endif -diff -ur mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libprldap/ldappr-error.c mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libprldap/ldappr-error.c ---- mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libprldap/ldappr-error.c 2004-03-15 06:25:32.000000000 +0000 -+++ mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libprldap/ldappr-error.c 2013-09-07 16:35:36.269374375 +0100 +diff -ur mozldap-6.0.7.orig/c-sdk/ldap/libraries/libprldap/ldappr-error.c mozldap-6.0.7/c-sdk/ldap/libraries/libprldap/ldappr-error.c +--- mozldap-6.0.7.orig/c-sdk/ldap/libraries/libprldap/ldappr-error.c 2004-03-15 06:25:32.000000000 +0000 ++++ mozldap-6.0.7/c-sdk/ldap/libraries/libprldap/ldappr-error.c 2013-09-07 16:35:36.269374375 +0100 @@ -233,7 +233,7 @@ #if defined(__hpux) || defined(_AIX) || defined(OSF1) || defined(DARWIN) || \ @@ -174,9 +174,9 @@ #define EDEADLOCK -1 #endif -diff -ur mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libprldap/Makefile.in mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libprldap/Makefile.in ---- mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libprldap/Makefile.in 2007-06-20 18:57:12.000000000 +0100 -+++ mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libprldap/Makefile.in 2013-09-07 16:35:47.130344981 +0100 +diff -ur mozldap-6.0.7.orig/c-sdk/ldap/libraries/libprldap/Makefile.in mozldap-6.0.7/c-sdk/ldap/libraries/libprldap/Makefile.in +--- mozldap-6.0.7.orig/c-sdk/ldap/libraries/libprldap/Makefile.in 2007-06-20 18:57:12.000000000 +0100 ++++ mozldap-6.0.7/c-sdk/ldap/libraries/libprldap/Makefile.in 2013-09-07 16:35:47.130344981 +0100 @@ -64,7 +64,7 @@ LIBPRLDAP = endif @@ -192,9 +192,9 @@ $(INSTALL) -m 444 $(DLLPRLDAP) $(dist_bindir) + ln -sf $(DLLPRLDAP) $(dist_libdir)/$(LIB_PREFIX)$(PRLDAP_LIBNAME).$(DLL_SUFFIX) endif -diff -ur mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libssldap/Makefile.in mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libssldap/Makefile.in ---- mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libssldap/Makefile.in 2007-06-20 18:57:12.000000000 +0100 -+++ mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libssldap/Makefile.in 2013-09-07 16:35:47.130344981 +0100 +diff -ur mozldap-6.0.7.orig/c-sdk/ldap/libraries/libssldap/Makefile.in mozldap-6.0.7/c-sdk/ldap/libraries/libssldap/Makefile.in +--- mozldap-6.0.7.orig/c-sdk/ldap/libraries/libssldap/Makefile.in 2007-06-20 18:57:12.000000000 +0100 ++++ mozldap-6.0.7/c-sdk/ldap/libraries/libssldap/Makefile.in 2013-09-07 16:35:47.130344981 +0100 @@ -60,7 +60,7 @@ HDIR = $(topsrcdir)/ldap/include @@ -210,9 +210,9 @@ $(INSTALL) -m 444 $(DLLSSLDAP) $(dist_bindir) + ln -sf $(DLLSSLDAP) $(dist_libdir)/$(LIB_PREFIX)$(SSLDAP_LIBNAME).$(DLL_SUFFIX) endif -diff -ur mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libssldap/sslerrstrs.h mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libssldap/sslerrstrs.h ---- mozldap-6.0.5.orig/mozilla/directory/c-sdk/ldap/libraries/libssldap/sslerrstrs.h 2006-10-10 14:37:35.000000000 +0100 -+++ mozldap-6.0.5/mozilla/directory/c-sdk/ldap/libraries/libssldap/sslerrstrs.h 2013-09-07 16:35:55.767321281 +0100 +diff -ur mozldap-6.0.7.orig/c-sdk/ldap/libraries/libssldap/sslerrstrs.h mozldap-6.0.7/c-sdk/ldap/libraries/libssldap/sslerrstrs.h +--- mozldap-6.0.7.orig/c-sdk/ldap/libraries/libssldap/sslerrstrs.h 2006-10-10 14:37:35.000000000 +0100 ++++ mozldap-6.0.7/c-sdk/ldap/libraries/libssldap/sslerrstrs.h 2013-09-07 16:35:55.767321281 +0100 @@ -247,7 +247,7 @@ "SSL peer was not expecting a handshake message it received.")
View file
debian.changelog
Changed
@@ -1,3 +1,9 @@ +mozilla-ldap-sdk (6.0.7-1) unstable; urgency=low + + * Bump version to 6.0.7 + + -- Christoph Erhardt <kolab@sicherha.de> Sat, 07 Apr 2018 20:07:23 +0200 + mozilla-ldap-sdk (6.0.5-3) unstable; urgency=low * Attempt to build in OBS
View file
debian.control
Changed
@@ -19,7 +19,7 @@ Package: libmozldap-0d Architecture: any -Depends: ${shlibs:Depends}, libnss3-1d, libsvrcore0, libsasl2-2, ${misc:Depends} +Depends: ${shlibs:Depends}, libnss3, libsvrcore0, libsasl2-2, ${misc:Depends} Description: Mozilla LDAP client library The Mozilla LDAP C SDK is a set of libraries that allow applications to communicate with LDAP (Lightweight
View file
debian.rules
Changed
@@ -25,7 +25,7 @@ CFLAGS += -g SO_SUFFIX := 60 -BASEDIR := $(CURDIR)/mozilla/directory/c-sdk +BASEDIR := $(CURDIR)/c-sdk DISTDIR := $(CURDIR)/mozilla/dist # FOR AUTOCONF 2.52 AND NEWER ONLY ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) @@ -51,7 +51,7 @@ # These variables are used only by get-orig-source, which will normally only # be run by maintainers. -VERSION = 6.0.5 +VERSION = 6.0.7 URL = http://ftp.mozilla.org/pub/mozilla.org/directory/c-sdk/releases/v$(VERSION)/src/ # Download the upstream source and make changes as required for DFSG reasons. # Assumes wget is available, as this is generally only used by the package @@ -63,9 +63,9 @@ fi wget $(URL)/mozldap-$(VERSION).tar.gz tar xzf mozldap-$(VERSION).tar.gz - rm -r mozldap-$(VERSION)/mozilla/directory/c-sdk/ldap/docs/ - rm -r mozldap-$(VERSION)/mozilla/directory/c-sdk/ldap/examples/macintosh - rm -r mozldap-$(VERSION)/mozilla/directory/c-sdk/ldap/examples/windows/winldap/res + rm -r mozldap-$(VERSION)/c-sdk/ldap/docs/ + rm -r mozldap-$(VERSION)/c-sdk/ldap/examples/macintosh + rm -r mozldap-$(VERSION)/c-sdk/ldap/examples/windows/winldap/res mv mozldap-$(VERSION) mozilla-ldap-sdk-$(VERSION) tar cf mozilla-ldap-sdk_$(VERSION)+dfsg.orig.tar mozilla-ldap-sdk-$(VERSION) rm -r mozilla-ldap-sdk-$(VERSION) mozldap-$(VERSION).tar.gz @@ -87,7 +87,7 @@ $(MAKE) -C $(BASEDIR) \ NSS_DYNAMIC_SOFTOKN=0 \ DEBIAN_SO_SUFFIX=$(DEBIAN_SO) - $(MAKE) -C mozilla/directory/c-sdk/ldap/clients/tools \ + $(MAKE) -C c-sdk/ldap/clients/tools \ NSS_DYNAMIC_SOFTOKN=0 touch build-stamp @@ -133,7 +133,7 @@ mkdir -p $(CURDIR)/debian/tmp/usr/share/doc/libmozldap-dev/examples # Copy the examples - -cp -r $(CURDIR)/mozilla/directory/c-sdk/ldap/examples/*.[ch] $(CURDIR)/mozilla/directory/c-sdk/ldap/examples/*.conf $(CURDIR)/debian/tmp/usr/share/doc/libmozldap-dev/examples + -cp -r $(CURDIR)/c-sdk/ldap/examples/*.[ch] $(CURDIR)/c-sdk/ldap/examples/*.conf $(CURDIR)/debian/tmp/usr/share/doc/libmozldap-dev/examples install -m644 $(CURDIR)/debian/libmozldap-0d.lintian-overrides $(CURDIR)/debian/libmozldap-0d/usr/share/lintian/overrides/libmozldap-0d install -m 644 -t $(CURDIR)/debian/libmozldap-dev/usr/lib/pkgconfig/ \
View file
mozldap-6.0.5.tar.gz/.
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/Makefile.in
Deleted
@@ -1,58 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2002 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -MOD_DEPTH = . -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ - -include $(MOD_DEPTH)/config/autoconf.mk - -DIRS = config ldap - -DIST_GARBAGE = config.cache config.log config.status - -include $(topsrcdir)/config/rules.mk - -# dummy target to allow platforms without a compiler-based depend (like GCC -# has) to call "make depend" here and not fail, at the cost of actual -# dependencies on such builds possibly being incorrect. A nasty hack, but -# this build system is going away soon. -# -depend: - -FORCE: -
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/build.mk
Deleted
@@ -1,587 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla Communicator client code, released -# March 31, 1998. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-1999 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -# some vendors may wish to override COMPVERSIONDIR from the command-line -# -ifdef USE_AUTOCONF -COMPVERSIONDIR = $(topsrcdir) -else -COMPVERSIONDIR = $(DEPTH)/directory/c-sdk -endif - -DEFAULT_VENDOR_NAME=mozilla.org -DEFAULT_VENDOR_VERSION=604 - -ifndef VENDOR_NAME -VENDOR_NAME = $(DEFAULT_VENDOR_NAME) -endif - -ifndef VENDOR_VERSION -VENDOR_VERSION = $(DEFAULT_VENDOR_VERSION) -endif - -ifeq ($(OS_ARCH), WINNT) - COMPONENT_PULL_METHOD=FTP - win_srcdir:=$(subst $(topsrcdir),$(WIN_TOP_SRC),$(srcdir)) -endif - -# component tags for internal build only -include $(COMPVERSIONDIR)/component_versions.mk - -# Ldap library -ifeq ($(OS_ARCH), WINNT) -LDAP_LIBNAME = nsldap32v$(LDAPVERS) -else -LDAP_LIBNAME = ldap$(LDAPVERS) -endif -DIR_VERSION = $(LDAPVERS_SUFFIX) -DIRSDK_VERSION = $(LDAPVERS_SUFFIX) - -# PrLdap library -ifeq ($(OS_ARCH), WINNT) -PRLDAP_LIBNAME = nsldappr32v$(PRLDAPVERS) -else -PRLDAP_LIBNAME = prldap$(PRLDAPVERS) -endif - -# lber library -ifeq ($(OS_ARCH), WINNT) -LBER_LIBNAME = nslber32v$(LBERVERS) -else -LBER_LIBNAME = lber$(LBERVERS) -endif - -# ldif library -ifeq ($(OS_ARCH), WINNT) -LDIF_LIBNAME = nsldif32v$(LDIFVERS) -else -LDIF_LIBNAME = ldif$(LDIFVERS) -endif - -# iutil library -ifeq ($(OS_ARCH), WINNT) -IUTIL_LIBNAME = nsiutil32v$(IUTILVERS) -else -IUTIL_LIBNAME = iutil$(IUTILVERS) -endif - -# util library -ifeq ($(OS_ARCH), WINNT) -UTIL_LIBNAME = nsutil32v$(UTILVERS) -else -UTIL_LIBNAME = util$(UTILVERS) -endif - -# ssl library -ifeq ($(OS_ARCH), WINNT) -SSLDAP_LIBNAME = nsldapssl32v$(SSLDAPVERS) -else -SSLDAP_LIBNAME = ssldap$(SSLDAPVERS) -endif - -# nss library -NSS_LIBNAME = nss$(NSSVERS) -ifeq ($(NSS_DYNAMIC_SOFTOKN),1) -SOFTOKN_LIBNAME = softokn$(NSSVERS) -endif -SSL_LIBNAME = ssl$(NSSVERS) - -ifeq ($(OS_ARCH), WINNT) -DYNAMICNSS = $(addsuffix .$(LIB_SUFFIX),$(SSL_LIBNAME) $(NSS_LIBNAME)) -else -DYNAMICNSS = $(addprefix -l,$(SSL_LIBNAME) $(NSS_LIBNAME) $(SOFTOKN_LIBNAME)) -endif -NSSLINK = $(NSS_LIBS) $(DYNAMICNSS) - -HYBRID_LIBNAME = freebl_hybrid_$(NSSVERS) -PURE32_LIBNAME = freebl_pure32_$(NSSVERS) - -ifneq ($(USE_64), 1) -ifeq ($(OS_ARCH), SunOS) -ifneq ($(OS_TEST),i86pc) -COPYFREEBL = 1 -endif -endif -ifeq ($(OS_ARCH), HP-UX) -ifneq ($(OS_TEST),ia64) -COPYFREEBL = 1 -endif -endif -endif - -# svrcore library -SVRCOREVERS = -SVRCOREVERS_SUFFIX = -SVRCORE_LIBNAME = svrcore$(SVRCOREVERS) -ifeq ($(OS_ARCH), WINNT) -SVRCORE_LINK = $(SVRCORE_LIBS) $(SVRCORE_LIBNAME).$(LIB_SUFFIX) -else -SVRCORE_LINK = $(SVRCORE_LIBS) -l$(SVRCORE_LIBNAME) -endif - -# sasl library -ifdef SASL_LIBS -SASL_LINK = $(SASL_LIBS) -endif - -# -# NSPR library -# - -PLCBASE=plc$(NSPR_LIBVERSION) -PLDSBASE=plds$(NSPR_LIBVERSION) -NSPRBASE=nspr$(NSPR_LIBVERSION) - -ifeq ($(OS_ARCH), WINNT) -PLC_BASENAME=lib$(PLCBASE) -PLDS_BASENAME=lib$(PLDSBASE) -NSPR_BASENAME=lib$(NSPRBASE) -DYNAMICNSPR = $(PLC_BASENAME).$(LIB_SUFFIX) $(PLDS_BASENAME).$(LIB_SUFFIX) $(NSPR_BASENAME).$(LIB_SUFFIX) -else -PLC_BASENAME=$(PLCBASE) -PLDS_BASENAME=$(PLDSBASE) -NSPR_BASENAME=$(NSPRBASE) -DYNAMICNSPR = -l$(PLCBASE) -l$(PLDSBASE) -l$(NSPRBASE) -endif - -# use the NSPRLINK macro in other makefiles to define the linker command line -# the mozilla client build likes to set the makefile macro directly -ifdef LIBS_ALREADY_SET -NSPRLINK = $(NSPR_LIBS) -else -NSPRLINK = $(NSPR_LIBS) $(DYNAMICNSPR) -endif - -# why the redundant definitions? apparently, all of these basename/libname macros are so that -# the ldapsdk can create a package containing all of the nspr shared libs/dlls - I don't think -# we should do this anymore, we should just depend on the user installing nspr first - then we -# can get rid of all of this junk -PLC_LIBNAME=$(PLCBASE) -PLDS_LIBNAME=$(PLDSBASE) -NSPR_LIBNAME=$(NSPRBASE) - -RM = rm -f -SED = sed - -# uncomment to enable support for LDAP referrals -LDAP_REFERRALS = -DLDAP_REFERRALS -DEFNETSSL = -DNET_SSL -NOLIBLCACHE = -DNO_LIBLCACHE -NSDOMESTIC = -DNS_DOMESTIC - - -ifdef BUILD_OPT -LDAP_DEBUG = -else -LDAP_DEBUG = -DLDAP_DEBUG -endif - - -ifdef BUILD_CLU -BUILDCLU = 1 -else -BUILDCLU = -endif - -# -# DEFS are included in CFLAGS -# -DEFS = $(PLATFORMCFLAGS) $(LDAP_DEBUG) \ - $(CLDAP) $(DEFNETSSL) $(NOLIBLCACHE) \ - $(LDAP_REFERRALS) $(LDAP_DNS) $(STR_TRANSLATION) \ - $(LIBLDAP_CHARSETS) $(LIBLDAP_DEF_CHARSET) \ - $(NSDOMESTIC) $(LDAPSSLIO) - - -ifeq ($(OS_ARCH), WINNT) -DIRVER_PROG=$(COMMON_OBJDIR)/dirver.exe -else -DIRVER_PROG=$(COMMON_OBJDIR)/dirver -endif - -ifeq ($(OS_ARCH), WINNT) -EXE_SUFFIX=.exe -RSC=rc -ifdef NS_USE_GCC -OFFLAG=-o # -else -OFFLAG=/Fo -MT = mt.exe -endif -else -OFFLAG=-o -endif - -ifeq ($(OS_ARCH), Linux) -DEFS += -DLINUX2_0 -DLINUX1_2 -DLINUX2_1 -endif - -ifeq ($(OS_ARCH), WINNT) -ifndef NS_USE_GCC -DLLEXPORTS_PREFIX=-DEF: -USE_DLL_EXPORTS_FILE = 1 -endif -endif - -ifeq ($(OS_ARCH), OS2) -USE_DLL_EXPORTS_FILE = 1 -endif - -ifeq ($(OS_ARCH), SunOS) -ifndef NS_USE_GCC -DLLEXPORTS_PREFIX=-Blocal -M -USE_DLL_EXPORTS_FILE = 1 -# else -# use the --version-script GNU ld argument - need to add support for -# GNU (linux and solaris and ???) to genexports.pl et. al. -endif # NS_USE_GCC -endif - -ifeq ($(OS_ARCH), IRIX) -DLLEXPORTS_PREFIX=-exports_file -USE_DLL_EXPORTS_FILE = 1 -endif - -ifeq ($(OS_ARCH), HP-UX) -DEFS += -Dhpux -D_REENTRANT -endif - -ifeq ($(OS_ARCH),AIX) -DLLEXPORTS_PREFIX=-bE: -DL=-ldl -USE_DLL_EXPORTS_FILE = 1 -endif - -ifeq ($(OS_ARCH),OSF1) -DEFS += -DOSF1V4 -DL= -endif - -ifeq ($(OS_ARCH),ReliantUNIX) -DL=-ldl -ifdef RPATHFLAG -USE_LD_RUN_PATH=1 -endif -USE_CCC_TO_LINK=1 -CCC=$(CXX) -endif - -ifeq ($(OS_ARCH),UnixWare) -DL= -endif - -ifeq ($(OS_ARCH), SunOS) - -# flag to pass to cc when linking to set runtime shared library search path -# this is used like this, for example: $(RPATHFLAG_PREFIX)../.. -# Also, use the C++ compiler to link for 64-bit builds. -ifeq ($(USE_64), 1) -USE_CCC_TO_LINK=1 -ifdef RPATHFLAG -RPATHFLAG_PREFIX=-R: -endif -else -ifdef RPATHFLAG -RPATHFLAG_PREFIX=-Wl,-R, -endif -endif - -ifdef NS_USE_GCC -USE_CCC_TO_LINK=1 -ifdef RPATHFLAG -RPATHFLAG_PREFIX=-Wl,-R, -endif -endif - -# flag to pass to ld when linking to set runtime shared library search path -# this is used like this, for example: $(LDRPATHFLAG_PREFIX)../.. -ifdef RPATHFLAG -LDRPATHFLAG_PREFIX=-R -endif - -# OS network libraries -PLATFORMLIBS+=-lresolv -lsocket -lnsl -lgen -ldl -lposix4 -endif - -ifeq ($(OS_ARCH), OSF1) -# Use the C++ compiler to link -USE_CCC_TO_LINK=1 - -# flag to pass to cc when linking to set runtime shared library search path -# this is used like this, for example: $(RPATHFLAG_PREFIX)../.. -ifdef RPATHFLAG -RPATHFLAG_PREFIX=-Wl,-rpath, - -# flag to pass to ld when linking to set runtime shared library search path -# this is used like this, for example: $(LDRPATHFLAG_PREFIX)../.. -LDRPATHFLAG_PREFIX=-rpath -endif - -# allow for unresolved symbols -DLL_LDFLAGS += -expect_unresolved "*" -endif # OSF1 - -ifeq ($(OS_ARCH), AIX) -# Flags to set runtime shared library search path. For example: -# $(CC) $(RPATHFLAG_PREFIX)../..$(RPATHFLAG_EXTRAS) -ifdef RPATHFLAG -RPATHFLAG_PREFIX=-blibpath: -RPATHFLAG_EXTRAS=:/usr/lib:/lib - -# flag to pass to ld when linking to set runtime shared library search path -# this is used like this, for example: $(LDRPATHFLAG_PREFIX)../.. -LDRPATHFLAG_PREFIX=-blibpath:/usr/lib:/lib: -endif - -DLL_LDFLAGS= -bM:SRE -bnoentry \ - -L.:/usr/lib/threads:/usr/lpp/xlC/lib:/usr/lib:/lib -DLL_EXTRA_LIBS= -bI:/usr/lib/lowsys.exp -lC_r -lC -lpthreads -lc_r -lm \ - /usr/lib/libc.a - -EXE_EXTRA_LIBS= -bI:/usr/lib/syscalls.exp -lsvld -lpthreads -endif # AIX - -ifeq ($(OS_ARCH), HP-UX) -# Use the C++ compiler to link -USE_CCC_TO_LINK=1 - -ifdef RPATHFLAG -# flag to pass to cc when linking to set runtime shared library search path -# this is used like this, for example: $(RPATHFLAG_PREFIX)../.. -RPATHFLAG_PREFIX=-Wl,+s,+b, - -# flag to pass to ld when linking to set runtime shared library search path -# this is used like this, for example: $(LDRPATHFLAG_PREFIX)../.. -LDRPATHFLAG_PREFIX=+s +b -endif - -# we need to link in the rt library to get sem_*() -PLATFORMLIBS += -lrt -PLATFORMCFLAGS= - -endif # HP-UX - -ifeq ($(OS_ARCH), Linux) -# Use the C++ compiler to link -USE_CCC_TO_LINK=1 - -# flag to pass to cc when linking to set runtime shared library search path -# this is used like this, for example: $(RPATHFLAG_PREFIX)../.. -ifdef RPATHFLAG -RPATHFLAG_PREFIX=-Wl,-rpath, - -# flag to pass to ld when linking to set runtime shared library search path -# this is used like this, for example: $(LDRPATHFLAG_PREFIX)../.. -# note, there is a trailing space -LDRPATHFLAG_PREFIX=-rpath -endif # RPATHFLAG -endif # Linux - -ifeq ($(OS_ARCH), Darwin) -# Darwin doesn't use RPATH. -#ifdef RPATHFLAG -RPATHFLAG_PREFIX= -#endif - -# Use the C++ compiler to link -USE_CCC_TO_LINK=1 -endif # Darwin - -# Use the C++ compiler to link... or not. -ifdef USE_CCC_TO_LINK -CC_FOR_LINK=$(CCC) -else -CC_FOR_LINK=$(CC) -endif - - -# -# XXX: does anyone know of a better way to solve the "LINK_LIB2" problem? -mcs -# -# Link to produce a console/windows exe on Windows -# - -ifeq ($(OS_ARCH), WINNT) - -ifdef NS_USE_GCC -LINK_EXE = $(CC_FOR_LINK) -o $@ $(LDFLAGS) $(LCFLAGS) $(DEPLIBS) \ - $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) -LINK_LIB = $(AR) cr $@ $(OBJS) -LINK_DLL = $(CC_FOR_LINK) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(@:.$(DLL_SUFFIX)=.$(LIB_SUFFIX)) $(LLFLAGS) $(DLL_LDFLAGS) -o $@ $(OBJS) $(EXTRA_LIBS) $(EXTRA_DLL_LIBS) -else -DEBUG_LINK_OPT=-DEBUG -ifeq ($(BUILD_OPT), 1) - ifndef MOZ_DEBUG_SYMBOLS - DEBUG_LINK_OPT= - endif - DEBUG_LINK_OPT += -OPT:REF -endif - -SUBSYSTEM=CONSOLE -ifndef MOZ_DEBUG_SYMBOLS -DEBUG_FLAGS=-PDB:NONE -endif - -LINK_EXE = $(CYGWIN_WRAPPER) link $(DEBUG_LINK_OPT) -OUT:"$@" -MAP $(ALDFLAGS) $(LDFLAGS) $(ML_DEBUG) \ - $(LCFLAGS) -NOLOGO $(DEBUG_FLAGS) -INCREMENTAL:NO \ - -NODEFAULTLIB:MSVCRTD -SUBSYSTEM:$(SUBSYSTEM) $(DEPLIBS) \ - $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) msvcrt.lib - -ifdef MT -LINK_EXE += ; if test -f $@.manifest ; then \ -$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \ -rm -f $@.manifest ; fi -endif # MSVC with manifest tool - from NSS rules.mk - -# AR is set when doing an autoconf build -ifdef AR -LINK_LIB = $(CYGWIN_WRAPPER) $(AR) $(OBJS) -else -LINK_LIB = $(CYGWIN_WRAPPER) lib -OUT:"$@" $(OBJS) -endif - -ifndef LD -LD=link -endif - -LINK_DLL = $(CYGWIN_WRAPPER) $(LD) $(DEBUG_LINK_OPT) -nologo -MAP -DLL $(DEBUG_FLAGS) \ - $(ML_DEBUG) -SUBSYSTEM:$(SUBSYSTEM) $(LLFLAGS) $(DLL_LDFLAGS) \ - $(EXTRA_LIBS) -out:"$@" $(OBJS) -endif # NS_USE_GCC -else # WINNT -# -# UNIX link commands -# -ifeq ($(OS_ARCH),OS2) -LINK_LIB = -$(RM) $@ && $(AR) $(AR_FLAGS) $(OBJS) && $(RANLIB) $@ -LINK_LIB2 = -$(RM) $@ && $(AR) $@ $(OBJS2) && $(RANLIB) $@ -ifeq ($(MOZ_OS2_TOOLS),VACPP) -LINK_DLL = $(LD) $(OS_DLLFLAGS) $(DLLFLAGS) $(OBJS) -else -LINK_DLL = $(LD) $(DSO_LDOPTS) $(ALDFLAGS) $(DLL_LDFLAGS) $(DLL_EXPORT_FLAGS) \ - -o $@ $(OBJS) -endif - -else - -LINK_LIB = $(RM) $@; $(AR) $(AR_FLAGS) $(OBJS); $(RANLIB) $@ -LINK_LIB2 = $(RM) $@; $(AR) $@ $(OBJS2); $(RANLIB) $@ -ifneq ($(LD),$(CC)) -ifdef SONAMEFLAG_PREFIX -LINK_DLL = $(LD) $(DSO_LDOPTS) $(LDRPATHFLAG_PREFIX)$(RPATHFLAG) $(ALDFLAGS) \ - $(DLL_LDFLAGS) $(DLL_EXPORT_FLAGS) \ - -o $@ $(SONAMEFLAG_PREFIX)$(notdir $@) $(OBJS) -else # SONAMEFLAG_PREFIX -LINK_DLL = $(LD) $(DSO_LDOPTS) $(LDRPATHFLAG_PREFIX)$(RPATHFLAG) $(ALDFLAGS) \ - $(DLL_LDFLAGS) $(DLL_EXPORT_FLAGS) \ - -o $@ $(OBJS) -endif # SONAMEFLAG_PREFIX -else # $(CC) is used to link libs -ifdef SONAMEFLAG_PREFIX -LINK_DLL = $(LD) $(DSO_LDOPTS) $(RPATHFLAG_PREFIX)$(RPATHFLAG) $(ALDFLAGS) \ - $(DLL_LDFLAGS) $(DLL_EXPORT_FLAGS) \ - -o $@ $(SONAMEFLAG_PREFIX)$(notdir $@) $(OBJS) -else # SONAMEFLAG_PREFIX -LINK_DLL = $(LD) $(DSO_LDOPTS) $(RPATHFLAG_PREFIX)$(RPATHFLAG) $(ALDFLAGS) \ - $(DLL_LDFLAGS) $(DLL_EXPORT_FLAGS) \ - -o $@ $(OBJS) -endif # SONAMEFLAG_PREFIX -endif # LD!CC -endif #!os2 - -ifeq ($(OS_ARCH), OSF1) -# The linker on OSF/1 gets confused if it finds an so_locations file -# that doesn't meet its expectations, so we arrange to remove it before -# linking. -SO_FILES_TO_REMOVE=so_locations -endif - -ifneq (,$(filter BeOS Darwin NetBSD,$(OS_ARCH))) -LINK_DLL = $(MKSHLIB) $(OBJS) -endif - -ifeq ($(OS_ARCH), HP-UX) -# On HPUX, we need a couple of changes: -# 1) Use the C++ compiler for linking, which will pass the +eh flag on down to the -# linker so the correct exception-handling-aware libC gets used (libnshttpd.sl -# needs this). -# 2) Add a "-Wl,-E" option so the linker gets a "-E" flag. This makes symbols -# in an executable visible to shared libraries loaded at runtime. -LINK_EXE = $(CC_FOR_LINK) -Wl,-E $(ALDFLAGS) $(LDFLAGS) $(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@ $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) - -ifeq ($(USE_64), 1) -ifeq ($(OS_RELEASE), B.11.23) -LINK_EXE = $(CC_FOR_LINK) -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L +DD64 -Wl,-E $(ALDFLAGS) $(LDFLAGS) $(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@ $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) -else -LINK_EXE = $(CC_FOR_LINK) -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L +DA2.0W +DS2.0 -Wl,-E $(ALDFLAGS) $(LDFLAGS) $(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@ $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) -endif -endif - -else # HP-UX -# everything except HPUX - -ifdef USE_LD_RUN_PATH -#does RPATH differently. instead we export RPATHFLAG as LD_RUN_PATH -#see ns/netsite/ldap/clients/tools/Makefile for an example -export LD_RUN_PATH=$(RPATHFLAG) -LINK_EXE = $(CC_FOR_LINK) $(ALDFLAGS) $(LDFLAGS) \ - -o $@ $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) -LINK_EXE_NOLIBSOBJS = $(CC_FOR_LINK) $(ALDFLAGS) $(LDFLAGS) -o $@ -else # USE_LD_RUN_PATH -LINK_EXE = $(CC_FOR_LINK) $(ALDFLAGS) $(LDFLAGS) \ - $(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) \ - -o $@ $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) -LINK_EXE_NOLIBSOBJS = $(CC_FOR_LINK) $(ALDFLAGS) $(LDFLAGS) \ - $(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) -o $@ -endif # USE_LD_RUN_PATH -endif # HP-UX -endif # WINNT - -ifndef PERL -PERL = perl -endif - -# -# shared library symbol export definitions -# -ifeq ($(OS_ARCH), WINNT) -GENEXPORTS=cmd /c $(PERL) $(LDAP_SRC)/build/genexports.pl -else -GENEXPORTS=$(PERL) $(LDAP_SRC)/build/genexports.pl -endif -
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/config
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/config/FreeBSD.mk
Deleted
@@ -1,86 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-2000 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -# -# Config stuff for FreeBSD -# - -include $(MOD_DEPTH)/config/UNIX.mk - -CC = gcc -CCC = g++ -RANLIB = ranlib - -ifeq ($(OS_TEST),alpha) -CPU_ARCH = alpha -else -OS_REL_CFLAGS = -Di386 -CPU_ARCH = x86 -endif -CPU_ARCH_TAG = _$(CPU_ARCH) - -OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -ansi -Wall -pipe $(THREAD_FLAG) -DFREEBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK - -# -# The default implementation strategy for FreeBSD is pthreads. -# -ifeq ($(CLASSIC_NSPR),1) -IMPL_STRATEGY = _EMU -DEFINES += -D_PR_LOCAL_THREADS_ONLY -else -USE_PTHREADS = 1 -IMPL_STRATEGY = _PTH -DEFINES += -D_THREAD_SAFE -THREAD_FLAG += -pthread -endif - -ARCH = freebsd - -MOZ_OBJFORMAT := $(shell test -x /usr/bin/objformat && /usr/bin/objformat || echo aout) - -ifeq ($(MOZ_OBJFORMAT),elf) -DLL_SUFFIX = so -else -DLL_SUFFIX = so.1.0 -endif - -DSO_CFLAGS = -fPIC -DSO_LDOPTS = -Bshareable - -MKSHLIB = $(LD) $(DSO_LDOPTS) - -G++INCLUDES = -I/usr/include/g++
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/config/Makefile.client
Deleted
@@ -1,149 +0,0 @@ -#! gmake -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-2000 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -MOD_DEPTH = .. - -# Indicate that this directory builds build tools. -INTERNAL_TOOLS = 1 - -include $(MOD_DEPTH)/config/config.mk - -CSRCS = now.c - -# This version hasn't been ported for us; the one in mozilla/config has -ifneq ($(OS_ARCH),OS2) -CSRCS += nsinstall.c - -PLSRCS = nfspwd.pl -endif - -ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) -PROG_SUFFIX = .exe -else -PROG_SUFFIX = -endif - -# Temporary workaround to disable the generation of -# library build time because now.c uses the 'long long' -# data type that's not available on some platforms. -ifeq (,$(filter-out NEC NEXTSTEP QNX SCOOS UNIXWARE,$(OS_ARCH))) -DEFINES += -DOMIT_LIB_BUILD_TIME -endif - -ifeq ($(OS_ARCH), IRIX) - ifeq ($(basename $(OS_RELEASE)),6) - ifeq ($(USE_N32),1) - XLDOPTS += -n32 -Wl,-woff,85 - ifeq ($(OS_RELEASE), 6_2) - XLDOPTS += -Wl,-woff,85 - endif - else - ifeq ($(USE_64),1) - XLDOPTS += -64 - else - XLDOPTS += -32 - endif - endif - endif -endif - -ifeq ($(OS_ARCH), HP-UX) - ifeq ($(OS_RELEASE), B.11.23) - ifeq ($(USE_64),1) - XLDOPTS += +DD64 - else - XLDOPTS += +DD32 - endif - else - ifeq ($(USE_64),1) - XLDOPTS += +DA2.0W - endif - endif -endif - -ifeq ($(MOZ_OS2_TOOLS),EMX) -XCFLAGS = $(OS_EXE_CFLAGS) -ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF) -XLDOPTS = -Zlinker /PM:VIO -endif -endif - -ifeq ($(MOZ_OS2_TOOLS),PGCC) -XCFLAGS = $(OS_EXE_CFLAGS) -XLDOPTS = -Zlinker /PM:VIO -endif - -ifeq ($(MOZ_OS2_TOOLS),VACPP) -OS_CFLAGS = $(OS_EXE_CFLAGS) -endif - -include $(MOD_DEPTH)/config/rules.mk - -PROGS = $(OBJDIR)/now$(PROG_SUFFIX) - -ifeq (,$(filter-out OS2 WINNT,$(OS_ARCH))) -TARGETS = $(PROGS) -else -PROGS += $(OBJDIR)/nsinstall$(PROG_SUFFIX) -TARGETS = $(PROGS) $(PLSRCS:.pl=) -endif - -OUTOPTION = -o # end of the line -ifeq (,$(filter-out WINNT WIN95,$(OS_TARGET))) -OUTOPTION = /Fe -endif - -# Redefine MAKE_OBJDIR for just this directory -define MAKE_OBJDIR -if test ! -d $(@D); then rm -rf $(@D); mkdir $(@D); else true; fi -endef - -export:: $(TARGETS) - -$(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX) - @$(MAKE_OBJDIR) -ifeq ($(MOZ_OS2_TOOLS),VACPP) - $(LINK) $(EXEFLAGS) $< -else - $(CC) $(XCFLAGS) $< $(XLDOPTS) $(OUTOPTION)$@ -endif - -cleanconfig: FORCE - $(RM) -r $(OBJDIR) - -FORCE:
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/config/Makefile.in
Deleted
@@ -1,151 +0,0 @@ -#! gmake -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-2000 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -MOD_DEPTH = .. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(MOD_DEPTH)/config/autoconf.mk - -# Indicate that this directory builds build tools. -INTERNAL_TOOLS = 1 - -# autoconf.mk must be deleted last (from the top-level directory) -# because it is included by every makefile. -DIST_GARBAGE = - -include $(topsrcdir)/config/config.mk - -ifndef MOZILLA_CLIENT -CSRCS = nsinstall.c -endif - -CSRCS += now.c - -PLSRCS = nfspwd.pl - -ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2,$(OS_ARCH))) -PROG_SUFFIX = .exe -else -PROG_SUFFIX = -endif - -# Temporary workaround to disable the generation of -# library build time because now.c uses the 'long long' -# data type that's not available on some platforms. -ifeq (,$(filter-out NEC NEXTSTEP QNX SCOOS UNIXWARE,$(OS_ARCH))) -DEFINES += -DOMIT_LIB_BUILD_TIME -endif - -ifeq ($(OS_ARCH), IRIX) - ifeq ($(basename $(OS_RELEASE)),6) - ifeq ($(USE_N32),1) - XLDOPTS += -n32 -Wl,-woff,85 - ifeq ($(OS_RELEASE), 6_2) - XLDOPTS += -Wl,-woff,85 - endif - else - ifeq ($(USE_64),1) - XLDOPTS += -64 - else - XLDOPTS += -32 - endif - endif - endif -endif - -ifeq ($(OS_ARCH), HP-UX) - ifeq ($(OS_RELEASE), B.11.23) - ifeq ($(USE_64),1) - XLDOPTS += +DD64 - else - XLDOPTS += +DD32 - endif - else - ifeq ($(USE_64),1) - XLDOPTS += +DA2.0W - endif - endif -endif - -ifeq ($(OS_ARCH), OpenVMS) - XLDOPTS += $(LDFLAGS) -endif - -ifeq ($(MOZ_OS2_TOOLS),EMX) -XCFLAGS = $(OS_EXE_CFLAGS) -XLDOPTS = -Zomf -Zlinker -PM:VIO -endif - -ifeq ($(MOZ_OS2_TOOLS),VACPP) -OS_CFLAGS = $(OS_EXE_CFLAGS) -endif - -include $(topsrcdir)/config/rules.mk - -PROGS = $(OBJDIR)/now$(PROG_SUFFIX) - -ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2,$(OS_ARCH))) -TARGETS = $(PROGS) -else -PROGS += $(OBJDIR)/nsinstall$(PROG_SUFFIX) -TARGETS = $(PROGS) $(PLSRCS:.pl=) -endif - -OUTOPTION = -o # end of the line -ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) -ifndef NS_USE_GCC -OUTOPTION = -Fe -endif -endif - -# Redefine MAKE_OBJDIR for just this directory -define MAKE_OBJDIR -if test ! -d $(@D); then rm -rf $(@D); mkdir $(@D); else true; fi -endef - -export:: $(TARGETS) - -$(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX) - @$(MAKE_OBJDIR) -ifeq ($(MOZ_OS2_TOOLS),VACPP) - $(LD) $(EXEFLAGS) $< -else - $(CC) $(XCFLAGS) $< $(XLDOPTS) $(OUTOPTION)$@ -endif
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/config/OS2.mk
Deleted
@@ -1,179 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-2000 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -# -# Configuration common to all (supported) versions of OS/2 -# -# OS_CFLAGS is the command line options for the compiler when -# building the .DLL object files. -# OS_EXE_CFLAGS is the command line options for the compiler -# when building the .EXE object files; this is for the test -# programs. -# the macro OS_CFLAGS is set to OS_EXE_CFLAGS inside of the -# makefile for the pr/tests directory. ... Hack. - -# Specify toolset. Default to EMX. -ifeq ($(MOZ_OS2_TOOLS),VACPP) -XP_OS2_VACPP = 1 -else -ifeq ($(MOZ_OS2_TOOLS),PGCC) -XP_OS2_EMX = 1 -else -MOZ_OS2_TOOLS = EMX -XP_OS2_EMX = 1 -endif -endif - -ifeq ($(XP_OS2_EMX),1) -MOZ_EMXTAG = $(subst .,,$(MOZ_OS2_EMX_OBJECTFORMAT)) -endif - -# -# On OS/2 we proudly support gbash... -# -SHELL = GBASH.EXE - -CC = icc -q -DXP_OS2 -N10 -CCC = icc -q -DXP_OS2 -DOS2=4 -N10 -LINK = -ilink -AR = -ilib /noignorecase /nologo /Out:$(subst /,\\,$@) -RANLIB = @echo RANLIB -BSDECHO = @echo BSDECHO -NSINSTALL = nsinstall -INSTALL = $(NSINSTALL) -MAKE_OBJDIR = if test ! -d $(OBJDIR); then mkdir $(OBJDIR); fi -IMPLIB = implib -nologo -noignorecase -FILTER = cppfilt -b -p -q -RC = rc.exe - -GARBAGE = - -XP_DEFINE = -DXP_PC -LIB_SUFFIX = lib -DLL_SUFFIX = dll -OBJ_SUFFIX = obj - -OS_CFLAGS = -W3 -Wcnd- -gm -gd+ -sd- -su4 -ge- -Mp -OS_EXE_CFLAGS = -W3 -Wcnd- -gm -gd+ -sd- -su4 -Mp -AR_EXTRA_ARGS = - -ifdef BUILD_OPT -OPTIMIZER = -O+ -Oi -DEFINES = -UDEBUG -U_DEBUG -DNDEBUG -DLLFLAGS = -DLL -OUT:$@ -MAP:$(@:.dll=.map) -EXEFLAGS = -PMTYPE:VIO -OUT:$@ -MAP:$(@:.exe=.map) -nologo -NOE -OBJDIR_TAG = _OPT -else -OPTIMIZER = -Ti+ -DE -DEFINES = -DDEBUG -D_DEBUG -DDEBUGPRINTS -DLLFLAGS = -DEBUG -DLL -OUT:$@ -MAP:$(@:.dll=.map) -EXEFLAGS = -DEBUG -PMTYPE:VIO -OUT:$@ -MAP:$(@:.exe=.map) -nologo -NOE -OBJDIR_TAG = _DBG -LDFLAGS = -DEBUG -endif - -DEFINES += -DOS2=4 -DEFINES += -D_X86_ -DEFINES += -D_PR_GLOBAL_THREADS_ONLY -DBSD_SELECT - -# Name of the binary code directories -ifdef MOZ_LITE -OBJDIR_NAME = $(subst OS2,NAV,$(OS_CONFIG))_$(MOZ_OS2_TOOLS)$(MOZ_EMXTAG)$(OBJDIR_TAG).OBJ -else -OBJDIR_NAME = $(OS_CONFIG)_$(MOZ_OS2_TOOLS)$(MOZ_EMXTAG)$(OBJDIR_TAG).OBJ -endif - -OS_DLLFLAGS = -nologo -DLL -FREE -NOE - -ifdef XP_OS2_VACPP - -OS_LIBS = so32dll.lib tcp32dll.lib - -DEFINES += -DXP_OS2_VACPP -DTCPV40HDRS - -else -CC = gcc -CCC = gcc -LINK = gcc -RC = rc.exe -FILTER = emxexp -IMPLIB = emximp -o - -# Determine which object format to use. Two choices: -# a.out and omf. We default to omf. -ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT), A.OUT) -AR = ar -q $@ -LIB_SUFFIX = a -else -OMF_FLAG = -Zomf -AR = emxomfar r $@ -LIB_SUFFIX = lib -endif - -# if we compile with GCC we can also use the high-memory flag if specified -ifeq ($(MOZ_OS2_HIGH_MEMORY),1) -HIGHMEM_LDFLAG = -Zhigh-mem -endif - -OS_LIBS = -lsocket -lemxio - -DEFINES += -DXP_OS2 -DXP_OS2_EMX -DOS2EMX_PLAIN_CHAR - -OS_CFLAGS = $(OMF_FLAG) -Wall -Wno-unused -Zmtd -OS_EXE_CFLAGS = $(OMF_FLAG) -Wall -Wno-unused -Zmtd -OS_DLLFLAGS = $(OMF_FLAG) -Zmt -Zdll -Zcrtdll $(HIGHMEM_LDFLAG) -o $@ -ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF) -EXEFLAGS += -Zlinker /DE -endif - -ifdef BUILD_OPT -OPTIMIZER = -O3 -DLLFLAGS = $(HIGHMEM_LDFLAG) -EXEFLAGS = $(HIGHMEM_LDFLAG) -Zmtd -o $@ -else -OPTIMIZER = -g #-s -DLLFLAGS = -g $(HIGHMEM_LDFLAG) #-s -EXEFLAGS = -g $(HIGHMEM_LDFLAG) $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@ # -s -ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF) -EXEFLAGS += -Zlinker /DE -endif -endif - -AR_EXTRA_ARGS = -endif - -
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/config/WIN32.mk
Deleted
@@ -1,179 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-2000 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -# -# Configuration common to all versions of Windows NT -# and Windows 95. -# - -# -# Client build: make sure we use the shmsdos.exe under $(MOZ_TOOLS). -# $(MOZ_TOOLS_FLIPPED) is $(MOZ_TOOLS) with all the backslashes -# flipped, so that gmake won't interpret them as escape characters. -# -ifdef PR_CLIENT_BUILD_WINDOWS -SHELL = $(MOZ_TOOLS_FLIPPED)/bin/shmsdos.exe -endif - -CC = cl -CCC = cl -LINK = link -AR = lib -NOLOGO -OUT:"$@" -RANLIB = echo -BSDECHO = echo -NSINSTALL = nsinstall -INSTALL = $(NSINSTALL) -define MAKE_OBJDIR -if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi -endef -RC = rc.exe - -GARBAGE = $(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb - -XP_DEFINE = -DXP_PC -OBJ_SUFFIX = obj -LIB_SUFFIX = lib -DLL_SUFFIX = dll - -OS_CFLAGS = -W3 -nologo -GF -Gy - -ifdef BUILD_OPT -OS_CFLAGS += -MD -OPTIMIZER = -O2 -DEFINES = -UDEBUG -U_DEBUG -DNDEBUG -DLLFLAGS = -OUT:"$@" -OBJDIR_TAG = _OPT - -# Add symbolic information for use by a profiler -ifdef MOZ_PROFILE -OPTIMIZER += -Zi -DLLFLAGS += -DEBUG -LDFLAGS += -DEBUG -endif - -else -# -# Define USE_DEBUG_RTL if you want to use the debug runtime library -# (RTL) in the debug build -# -ifdef USE_DEBUG_RTL -OS_CFLAGS += -MDd -else -OS_CFLAGS += -MD -endif -OPTIMIZER = -Od -Zi -#OPTIMIZER = -Zi -Fd$(OBJDIR)/ -Od -DEFINES = -DDEBUG -D_DEBUG -UNDEBUG - -DLLFLAGS = -DEBUG -OUT:"$@" -ifdef GLOWCODE -DLLFLAGS = -DEBUG -DEBUGTYPE:both -INCLUDE:_GlowCode -OUT:"$@" -endif - -OBJDIR_TAG = _DBG -LDFLAGS = -DEBUG -# -# When PROFILE=1 is defined, set the compile and link options -# to build targets for use by the ms-win32 profiler -# -ifdef PROFILE -LDFLAGS += -PROFILE -MAP -DLLFLAGS += -PROFILE -MAP -endif -endif - -DEFINES += -DWIN32 -D_WINDOWS - -# -# On Win95, we use the TlsXXX() interface by default because that -# allows us to load the NSPR DLL dynamically at run time. -# If you want to use static thread-local storage (TLS) for better -# performance, build the NSPR library with USE_STATIC_TLS=1. -# -ifeq ($(USE_STATIC_TLS),1) -DEFINES += -D_PR_USE_STATIC_TLS -endif - -# -# NSPR uses both fibers and static thread-local storage -# (i.e., __declspec(thread) variables) on NT. We need the -GT -# flag to turn off certain compiler optimizations so that fibers -# can use static TLS safely. -# -# Also, we optimize for Pentium (-G5) on NT. -# -ifeq ($(OS_TARGET),WINNT) -OS_CFLAGS += -GT -ifeq ($(CPU_ARCH),x86) -OS_CFLAGS += -G5 -endif -DEFINES += -DWINNT -else -DEFINES += -DWIN95 -D_PR_GLOBAL_THREADS_ONLY -endif - -ifeq ($(CPU_ARCH),x86) -DEFINES += -D_X86_ -else -ifeq ($(CPU_ARCH),MIPS) -DEFINES += -D_MIPS_ -else -ifeq ($(CPU_ARCH),ALPHA) -DEFINES += -D_ALPHA_=1 -else -CPU_ARCH = processor_is_undefined -endif -endif -endif - -# Name of the binary code directories - -ifeq ($(CPU_ARCH),x86) -CPU_ARCH_TAG = -else -CPU_ARCH_TAG = $(CPU_ARCH) -endif - -ifdef USE_DEBUG_RTL -OBJDIR_SUFFIX = OBJD -else -OBJDIR_SUFFIX = OBJ -endif - -OBJDIR_NAME = $(OS_CONFIG)$(CPU_ARCH_TAG)$(OBJDIR_TAG).$(OBJDIR_SUFFIX) - -OS_DLLFLAGS = -nologo -DLL -SUBSYSTEM:WINDOWS -PDB:NONE
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/config/autoconf
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/config/config.mk
Deleted
@@ -1,238 +0,0 @@ -#! gmake -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-2000 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -# Configuration information for building in the NSPR source module - -# Define an include-at-most-once-flag -NSPR_CONFIG_MK = 1 - -# -# The variable definitions in this file are inputs to NSPR's -# build system. This file, if present, is included at the -# beginning of config.mk. -# -# For example: -# -# BUILD_OPT=1 -# USE_PTHREADS=1 -# NS_USE_GCC= -# -ifndef topsrcdir -topsrcdir=$(MOD_DEPTH) -endif - -ifndef srcdir -srcdir=. -endif - -ifdef USE_AUTOCONF - -NFSPWD = $(MOD_DEPTH)/config/nfspwd - -CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(OS_CFLAGS)\ - $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) -CCCFLAGS = $(CCC_ONLY_FLAGS) $(OPTIMIZER) $(OS_CFLAGS)\ - $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) -# For purify -NOMD_CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\ - $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) -NOMD_CCFLAGS = $(CCC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\ - $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) - -ifeq ($(OS_ARCH),Darwin) -ifndef NSDISTMODE -NSDISTMODE=absolute_symlink -endif -PWD := $(shell pwd) -endif - -ifeq ($(NSDISTMODE),copy) -# copy files, but preserve source mtime -INSTALL = $(NSINSTALL) -t -else -ifeq ($(NSDISTMODE),absolute_symlink) -# install using absolute symbolic links -ifeq ($(OS_ARCH),Darwin) -INSTALL = $(NSINSTALL) -L $(PWD) -else -INSTALL = $(NSINSTALL) -L `$(NFSPWD)` -endif -else -# install using relative symbolic links -INSTALL = $(NSINSTALL) -R -endif -endif - -ifdef BUILD_DEBUG_GC -DEFINES += -DDEBUG_GC -endif - -GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) - -ifdef USE_AUTOCONF -DIST_GARBAGE += Makefile -endif - -DEFINES += -DFORCE_PR_LOG - -ifeq ($(_PR_NO_CLOCK_TIMER),1) -DEFINES += -D_PR_NO_CLOCK_TIMER -endif - -ifeq ($(USE_PTHREADS), 1) -DEFINES += -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM -endif - -ifeq ($(PTHREADS_USER), 1) -DEFINES += -DPTHREADS_USER -UHAVE_CVAR_BUILT_ON_SEM -endif - -ifeq ($(USE_IPV6),1) -DEFINES += -D_PR_INET6 -endif - -else # ! USE_AUTOCONF - -ifndef NSPR_MY_CONFIG_MK -NSPR_MY_CONFIG_MK = $(MOD_DEPTH)/config/my_config.mk -endif - -# -# The variable definitions in this file are used to -# override variable values set by NSPR's build system. -# This file, if present, is included at the end of config.mk. -# -# For example: -# -# DIST=/usr/local/nspr -# -ifndef NSPR_MY_OVERRIDES_MK -NSPR_MY_OVERRIDES_MK = $(MOD_DEPTH)/config/my_overrides.mk -endif - --include $(NSPR_MY_CONFIG_MK) - -include $(MOD_DEPTH)/config/module.df - -include $(MOD_DEPTH)/config/arch.mk - -ifndef NSDEPTH -NSDEPTH = $(MOD_DEPTH)/.. -endif - -# -# Default command macros; can be overridden in <arch>.mk. -# -# XXX FIXME: I removed CCF and LINKEXE. -AS = $(CC) -ASFLAGS = $(CFLAGS) -PURIFY = purify $(PURIFYOPTIONS) -LINK_DLL = $(LINK) $(OS_DLLFLAGS) $(DLLFLAGS) -NFSPWD = $(MOD_DEPTH)/config/nfspwd - -CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(OS_CFLAGS)\ - $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) -CCCFLAGS = $(CCC_ONLY_FLAGS) $(OPTIMIZER) $(OS_CFLAGS)\ - $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) -# For purify -NOMD_CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\ - $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) - -include $(MOD_DEPTH)/config/$(OS_TARGET).mk - -# Figure out where the binary code lives. -BUILD = $(OBJDIR_NAME) -OBJDIR = $(OBJDIR_NAME) -DIST = $(NSDEPTH)/dist/$(OBJDIR_NAME) -ifeq ($(MOZ_BITS),16) -MOZ_INCL = $(NSDEPTH)/dist/public/win16 -MOZ_DIST = $(NSDEPTH)/dist/WIN16D_D.OBJ -endif - -VPATH = $(OBJDIR) -DEPENDENCIES = $(OBJDIR)/.md - -ifdef BUILD_DEBUG_GC -DEFINES += -DDEBUG_GC -endif - -GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) - -#################################################################### -# -# The NSPR-specific configuration -# -#################################################################### - -OS_CFLAGS += -DFORCE_PR_LOG - -ifeq ($(_PR_NO_CLOCK_TIMER),1) -OS_CFLAGS += -D_PR_NO_CLOCK_TIMER -endif - -ifeq ($(USE_PTHREADS), 1) -OS_CFLAGS += -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM -endif - -ifeq ($(PTHREADS_USER), 1) -OS_CFLAGS += -DPTHREADS_USER -UHAVE_CVAR_BUILT_ON_SEM -endif - -ifeq ($(USE_IPV6),1) -OS_CFLAGS += -D_PR_INET6 -endif - -ifdef GC_LEAK_DETECTOR -OS_CFLAGS += -DGC_LEAK_DETECTOR -endif - -#################################################################### -# -# Configuration for the release process -# -#################################################################### - -RELEASE_DIR = $(NSDEPTH)/dist/release/$(MOD_NAME) - -RELEASE_INCLUDE_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/include -RELEASE_BIN_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/bin -RELEASE_LIB_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/lib - --include $(NSPR_MY_OVERRIDES_MK) - -endif # USE_AUTOCONF
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/config/nfspwd
Deleted
@@ -1,50 +0,0 @@ -#! perl -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-2000 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -require "fastcwd.pl"; - -$_ = &fastcwd; -if (m@^/[uh]/@o || s@^/tmp_mnt/@/@o) { - print("$_\n"); -} elsif ((($user, $rest) = m@^/usr/people/(\w+)/(.*)@o) - && readlink("/u/$user") eq "/usr/people/$user") { - print("/u/$user/$rest\n"); -} else { - chop($host = `hostname`); - print("/h/$host$_\n"); -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/config/now.c
Deleted
@@ -1,142 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape Portable Runtime (NSPR). - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include <stdio.h> -#include <stdlib.h> - -#if defined(VMS) -#include <sys/timeb.h> -#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS) -#include <sys/time.h> -#elif defined(WIN32) -#include <windows.h> -#elif defined(XP_OS2_VACPP) -#include <sys/timeb.h> -#else -#error "Architecture not supported" -#endif - - -int main(int argc, char **argv) -{ -#if defined(OMIT_LIB_BUILD_TIME) - /* - * Some platforms don't have any 64-bit integer type - * such as 'long long'. Because we can't use NSPR's - * PR_snprintf in this program, it is difficult to - * print a static initializer for PRInt64 (a struct). - * So we print nothing. The makefiles that build the - * shared libraries will detect the empty output string - * of this program and omit the library build time - * in PRVersionDescription. - */ -#elif defined(VMS) - long long now; - struct timeb b; - ftime(&b); - now = b.time; - now *= 1000000; - now += (1000 * b.millitm); - fprintf(stdout, "%Ld", now); -#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS) - long long now; - struct timeval tv; -#ifdef HAVE_SVID_GETTOD - gettimeofday(&tv); -#else - gettimeofday(&tv, NULL); -#endif - now = ((1000000LL) * tv.tv_sec) + (long long)tv.tv_usec; -#if defined(OSF1) - fprintf(stdout, "%ld", now); -#elif defined(BEOS) && defined(__POWERPC__) - fprintf(stdout, "%Ld", now); /* Metroworks on BeOS PPC */ -#else - fprintf(stdout, "%lld", now); -#endif - -#elif defined(WIN32) - __int64 now; - FILETIME ft; - GetSystemTimeAsFileTime(&ft); - CopyMemory(&now, &ft, sizeof(now)); - /* - * 116444736000000000 is the number of 100-nanosecond intervals - * between Jan. 1, 1601 and Jan. 1, 1970. - */ -#ifdef __GNUC__ - now = (now - 116444736000000000LL) / 10LL; - fprintf(stdout, "%lld", now); -#else - now = (now - 116444736000000000i64) / 10i64; - fprintf(stdout, "%I64d", now); -#endif - -#elif defined(XP_OS2_VACPP) -/* no long long or i64 so we use a string */ -#include <string.h> - char buf[24]; - char tbuf[7]; - time_t now; - long mtime; - int i; - - struct timeb b; - ftime(&b); - now = b.time; - _ltoa(now, buf, 10); - - mtime = b.millitm * 1000; - if (mtime == 0){ - ++now; - strcat(buf, "000000"); - } else { - _ltoa(mtime, tbuf, 10); - for (i = strlen(tbuf); i < 6; ++i) - strcat(buf, "0"); - strcat(buf, tbuf); - } - fprintf(stdout, "%s", buf); - -#else -#error "Architecture not supported" -#endif - - return 0; -} /* main */ - -/* now.c */
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/config/rules.mk
Deleted
@@ -1,495 +0,0 @@ -#! gmake -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-2000 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -################################################################################ -# We have a 4 pass build process: -# -# Pass 1. export - Create generated headers and stubs. Publish public headers to -# dist/<arch>/include. -# -# Pass 2. libs - Create libraries. Publish libraries to dist/<arch>/lib. -# -# Pass 3. all - Create programs. -# -# Pass 4. install - Publish programs to dist/<arch>/bin. -# -# Parameters to this makefile (set these before including): -# -# a) -# TARGETS -- the target to create -# (defaults to $LIBRARY $PROGRAM) -# b) -# DIRS -- subdirectories for make to recurse on -# (the 'all' rule builds $TARGETS $DIRS) -# c) -# CSRCS -- .c files to compile -# (used to define $OBJS) -# d) -# PROGRAM -- the target program name to create from $OBJS -# ($OBJDIR automatically prepended to it) -# e) -# LIBRARY -- the target library name to create from $OBJS -# ($OBJDIR automatically prepended to it) -# -################################################################################ - -ifndef topsrcdir -topsrcdir=$(MOD_DEPTH) -endif - -ifndef srcdir -srcdir=. -endif - -ifndef NSPR_CONFIG_MK -include $(topsrcdir)/config/config.mk -endif - -ifdef USE_AUTOCONF -ifdef CROSS_COMPILE -ifdef INTERNAL_TOOLS -CC=$(HOST_CC) -CCC=$(HOST_CXX) -CFLAGS=$(HOST_CFLAGS) -CXXFLAGS=$(HOST_CXXFLAGS) -endif -endif -endif - -# -# This makefile contains rules for building the following kinds of -# libraries: -# - LIBRARY: a static (archival) library -# - SHARED_LIBRARY: a shared (dynamic link) library -# - IMPORT_LIBRARY: an import library, used only on Windows and OS/2 -# -# The names of these libraries can be generated by simply specifying -# LIBRARY_NAME and LIBRARY_VERSION. -# - -ifdef LIBRARY_NAME -ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) - -# -# Win95, Win16, and OS/2 require library names conforming to the 8.3 rule. -# other platforms do not. -# -ifeq (,$(filter-out WIN95 WIN16 OS2,$(OS_TARGET))) -LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX) -SHARED_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX) -IMPORT_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX) -else -LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX) -SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX) -IMPORT_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX) -endif - -ifeq ($(OS_ARCH),OS2) -DEF_FILE := $(SHARED_LIBRARY:.dll=.def) -endif - -else - -LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX) -ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1) -SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_shr.a -else -ifdef MKSHLIB -SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX) -endif -endif - -endif -endif - -ifndef TARGETS -ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) -TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) -else -TARGETS = $(LIBRARY) $(SHARED_LIBRARY) -endif -endif - -# -# OBJS is the list of object files. It can be constructed by -# specifying CSRCS (list of C source files) and ASFILES (list -# of assembly language source files). -# - -ifndef OBJS -OBJS = $(addprefix $(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \ - $(addprefix $(OBJDIR)/,$(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))) -endif - -ifeq ($(OS_TARGET), WIN16) - comma := , - empty := - space := $(empty) $(empty) - W16OBJS = $(subst $(space),$(comma)$(space),$(strip $(OBJS))) - W16TEMP =$(OS_LIBS) $(EXTRA_LIBS) - ifeq ($(strip $(W16TEMP)),) - W16LIBS = - else - W16LIBS = library $(subst $(space),$(comma)$(space),$(strip $(W16TEMP))) - endif - W16DEF = $(notdir $(basename $(SHARED_LIBRARY))).DEF -endif - -ifeq ($(OS_ARCH), WINNT) -ifneq ($(OS_TARGET), WIN16) -OBJS += $(RES) -endif -endif - -ALL_TRASH = $(TARGETS) $(OBJS) $(filter-out . .., $(OBJDIR)) LOGS TAGS $(GARBAGE) \ - $(NOSUCHFILE) $(DEF_FILE)\ - so_locations - -ifdef DIRS -LOOP_OVER_DIRS = \ - @for d in $(DIRS); do \ - if test -d $$d; then \ - set -e; \ - echo "cd $$d; $(MAKE) $(MFLAGS) $@"; \ - $(MAKE) $(MFLAGS) -C $$d $@; \ - set +e; \ - else \ - echo "Skipping non-directory $$d..."; \ - fi; \ - done -endif - -################################################################################ - -all:: export - -export:: - +$(LOOP_OVER_DIRS) - -libs:: export - -install:: export - -clean:: - rm -rf $(OBJS) so_locations $(NOSUCHFILE) $(GARBAGE) - +$(LOOP_OVER_DIRS) - -clobber:: - rm -rf $(OBJS) $(TARGETS) $(filter-out . ..,$(OBJDIR)) $(GARBAGE) so_locations $(NOSUCHFILE) - +$(LOOP_OVER_DIRS) - -realclean clobber_all:: - rm -rf $(wildcard *.OBJ *.OBJD) dist $(ALL_TRASH) - +$(LOOP_OVER_DIRS) - -distclean:: - rm -rf $(wildcard *.OBJ *.OBJD) dist $(ALL_TRASH) $(DIST_GARBAGE) - +$(LOOP_OVER_DIRS) - -real_install:: $(RELEASE_BINS) $(RELEASE_HEADERS) $(RELEASE_LIBS) -ifdef RELEASE_BINS - $(NSINSTALL) -t -m 0755 $(RELEASE_BINS) $(DESTDIR)$(bindir) -endif -ifdef RELEASE_HEADERS - $(NSINSTALL) -t -m 0644 $(RELEASE_HEADERS) $(DESTDIR)$(includedir) -endif -ifdef RELEASE_LIBS - $(NSINSTALL) -t -m 0755 $(RELEASE_LIBS) $(DESTDIR)$(libdir) -endif - +$(LOOP_OVER_DIRS) - -release:: export -ifdef RELEASE_BINS - @echo "Copying executable programs and scripts to release directory" - @if test -z "$(BUILD_NUMBER)"; then \ - echo "BUILD_NUMBER must be defined"; \ - false; \ - else \ - true; \ - fi - @if test ! -d $(RELEASE_BIN_DIR); then \ - rm -rf $(RELEASE_BIN_DIR); \ - $(NSINSTALL) -D $(RELEASE_BIN_DIR);\ - else \ - true; \ - fi - cp $(RELEASE_BINS) $(RELEASE_BIN_DIR) -endif -ifdef RELEASE_LIBS - @echo "Copying libraries to release directory" - @if test -z "$(BUILD_NUMBER)"; then \ - echo "BUILD_NUMBER must be defined"; \ - false; \ - else \ - true; \ - fi - @if test ! -d $(RELEASE_LIB_DIR); then \ - rm -rf $(RELEASE_LIB_DIR); \ - $(NSINSTALL) -D $(RELEASE_LIB_DIR);\ - else \ - true; \ - fi - cp $(RELEASE_LIBS) $(RELEASE_LIB_DIR) -endif -ifdef RELEASE_HEADERS - @echo "Copying header files to release directory" - @if test -z "$(BUILD_NUMBER)"; then \ - echo "BUILD_NUMBER must be defined"; \ - false; \ - else \ - true; \ - fi - @if test ! -d $(RELEASE_HEADERS_DEST); then \ - rm -rf $(RELEASE_HEADERS_DEST); \ - $(NSINSTALL) -D $(RELEASE_HEADERS_DEST);\ - else \ - true; \ - fi - cp $(RELEASE_HEADERS) $(RELEASE_HEADERS_DEST) -endif - +$(LOOP_OVER_DIRS) - -alltags: - rm -f TAGS tags - find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs etags -a - find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs ctags -a - -$(NFSPWD): - cd $(@D); $(MAKE) $(MFLAGS) $(@F) - -$(PROGRAM): $(OBJS) - @$(MAKE_OBJDIR) -ifeq ($(OS_ARCH)_$(NS_USE_GCC),WINNT_) - $(CC) $(OBJS) -Fe$@ -link $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) -else -ifeq ($(MOZ_OS2_TOOLS),VACPP) - $(CC) $(OBJS) -Fe$@ $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) -else - $(CC) -o $@ $(CFLAGS) $(OBJS) $(LDFLAGS) -endif -endif - -$(LIBRARY): $(OBJS) - @$(MAKE_OBJDIR) - rm -f $@ -ifeq ($(MOZ_OS2_TOOLS),VACPP) - $(AR) $(subst /,\\,$(OBJS)) $(AR_EXTRA_ARGS) -else -ifdef USE_AUTOCONF - $(AR) $(AR_FLAGS) $(OBJS) $(AR_EXTRA_ARGS) -else - $(AR) $(OBJS) $(AR_EXTRA_ARGS) -endif # USE_AUTOCONF -endif - $(RANLIB) $@ - -ifeq ($(OS_TARGET), WIN16) -$(IMPORT_LIBRARY): $(SHARED_LIBRARY) - wlib $(OS_LIB_FLAGS) $@ +$(SHARED_LIBRARY) -endif - -ifeq ($(OS_TARGET), OS2) -$(DEF_FILE): $(LIBRARY) - rm -f $@ - echo LIBRARY $(notdir $(basename $(SHARED_LIBRARY))) INITINSTANCE TERMINSTANCE > $@ - echo PROTMODE >> $@ - echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@ - echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@ - echo EXPORTS >> $@ - $(FILTER) $(LIBRARY) >> $@ - -$(IMPORT_LIBRARY): $(DEF_FILE) - rm -f $@ - $(IMPLIB) $@ $(DEF_FILE) -endif - -$(SHARED_LIBRARY): $(OBJS) $(DEF_FILE) - @$(MAKE_OBJDIR) - rm -f $@ -ifdef USE_AUTOCONF - $(MKSHLIB) $(OBJS) $(EXTRA_LIBS) $(OS_LIBS) $(DEF_FILE) -else -ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1) - echo "#!" > $(OBJDIR)/lib$(LIBRARY_NAME)_syms - nm -B -C -g $(OBJS) \ - | awk '/ [T,D] / {print $$3}' \ - | sed -e 's/^\.//' \ - | sort -u >> $(OBJDIR)/lib$(LIBRARY_NAME)_syms - $(LD) $(XCFLAGS) -o $@ $(OBJS) -bE:$(OBJDIR)/lib$(LIBRARY_NAME)_syms \ - -bM:SRE -bnoentry $(OS_LIBS) $(EXTRA_LIBS) -else # AIX 4.1 -ifeq ($(OS_ARCH), WINNT) -ifeq ($(OS_TARGET), WIN16) - echo system windows dll initinstance >w16link - echo option map >>w16link - echo option oneautodata >>w16link - echo option heapsize=32K >>w16link - echo option $(OS_DLL_OPTION) >>w16link - echo debug $(DEBUGTYPE) all >>w16link - echo name $@ >>w16link - echo file >>w16link - echo $(W16OBJS) >>w16link - echo $(W16IMPORTS) >>w16link - echo $(W16LIBS) >>w16link - echo $(W16_EXPORTS) >>w16link - echo libfile libentry >>w16link - $(LINK) @w16link. - rm w16link -else # WIN16 - $(LINK_DLL) -MAP $(DLLBASE) $(OS_LIBS) $(EXTRA_LIBS) $(OBJS) -endif # WINNT -else -ifeq ($(MOZ_OS2_TOOLS),VACPP) - $(LINK_DLL) $(DLLBASE) $(OBJS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) -else # !os2 vacpp - $(MKSHLIB) -o $@ $(OBJS) $(EXTRA_LIBS) $(OS_LIBS) $(DEF_FILE) -endif # OS2 vacpp -endif # WINNT -endif # AIX 4.1 -endif # USE_AUTOCONF - - -ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) -$(RES): $(RESNAME) - @$(MAKE_OBJDIR) -ifeq ($(OS_TARGET),OS2) - $(RC) -DOS2 -r $(RESNAME) $(RES) -else -# The resource compiler does not understand the -U option. -ifdef NS_USE_GCC - $(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) -o $@ $< -else - $(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$(RES) $(RESNAME) -endif -endif - @echo $(RES) finished -endif - -$(OBJDIR)/%.$(OBJ_SUFFIX): %.cpp - @$(MAKE_OBJDIR) -ifeq ($(OS_ARCH)_$(NS_USE_GCC), WINNT_) - $(CCC) -Fo$@ -c $(CCCFLAGS) $< -else -ifeq ($(MOZ_OS2_TOOLS),VACPP) - $(CCC) -Fo$@ -c $(CCCFLAGS) $< -else - $(CCC) -o $@ -c $(CCCFLAGS) $< -endif -endif - -WCCFLAGS1 = $(subst /,\\,$(CFLAGS)) -WCCFLAGS2 = $(subst -I,-i=,$(WCCFLAGS1)) -WCCFLAGS3 = $(subst -D,-d,$(WCCFLAGS2)) -$(OBJDIR)/%.$(OBJ_SUFFIX): %.c - @$(MAKE_OBJDIR) -ifeq ($(OS_ARCH)_$(NS_USE_GCC), WINNT_) -ifeq ($(OS_TARGET), WIN16) -# $(MOD_DEPTH)/config/w16opt $(WCCFLAGS3) - echo $(WCCFLAGS3) >w16wccf - $(CC) -zq -fo$(OBJDIR)\\$*.$(OBJ_SUFFIX) @w16wccf $*.c - rm w16wccf -else - $(CC) -Fo$@ -c $(CFLAGS) $< -endif -else -ifeq ($(MOZ_OS2_TOOLS),VACPP) - $(CC) -Fo$@ -c $(CFLAGS) $< -else - $(CC) -o $@ -c $(CFLAGS) $< -endif -endif - - -$(OBJDIR)/%.$(OBJ_SUFFIX): %.s - @$(MAKE_OBJDIR) - $(AS) -o $@ $(ASFLAGS) -c $< - -%.i: %.c - $(CC) -C -E $(CFLAGS) $< > $*.i - -%: %.pl - rm -f $@; cp $< $@; chmod +x $@ - -# -# HACK ALERT -# -# The only purpose of this rule is to pass Mozilla's Tinderbox depend -# builds (http://tinderbox.mozilla.org/showbuilds.cgi). Mozilla's -# Tinderbox builds NSPR continuously as part of the Mozilla client. -# Because NSPR's make depend is not implemented, whenever we change -# an NSPR header file, the depend build does not recompile the NSPR -# files that depend on the header. -# -# This rule makes all the objects depend on a dummy header file. -# Touch this dummy header file to force the depend build to recompile -# everything. -# -# This rule should be removed when make depend is implemented. -# - -DUMMY_DEPEND_H = $(topsrcdir)/config/prdepend.h - -$(filter $(OBJDIR)/%.$(OBJ_SUFFIX),$(OBJS)): $(OBJDIR)/%.$(OBJ_SUFFIX): $(DUMMY_DEPEND_H) - -# END OF HACK - -################################################################################ -# Special gmake rules. -################################################################################ - -# -# Re-define the list of default suffixes, so gmake won't have to churn through -# hundreds of built-in suffix rules for stuff we don't need. -# -.SUFFIXES: -.SUFFIXES: .a .$(OBJ_SUFFIX) .c .cpp .s .h .i .pl - -# -# Fake targets. Always run these rules, even if a file/directory with that -# name already exists. -# -.PHONY: all alltags clean export install libs realclean release - -# -# List the target pattern of an implicit rule as a dependency of the -# special target .PRECIOUS to preserve intermediate files made by -# implicit rules whose target patterns match that file's name. -# (See GNU Make documentation, Edition 0.51, May 1996, Sec. 10.4, -# p. 107.) -# -.PRECIOUS: $(OBJDIR)/%.$(OBJ_SUFFIX)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/configure
Deleted
@@ -1,7362 +0,0 @@ -#! /bin/sh - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help - --with-dist-prefix=DIST_PREFIX - place build files in DIST_PREFIX [dist]" -ac_help="$ac_help - --with-dist-bindir=DIR build execuatables in DIR [DIST_PREFIX/bin]" -ac_help="$ac_help - --with-dist-libdir=DIR build library files in DIR [DIST_PREFIX/lib]" -ac_help="$ac_help - --with-mozilla Compile LDAP with Mozilla support" -ac_help="$ac_help - --enable-optimize(=val) Enable code optimizations (val, ie. -O2) " -ac_help="$ac_help - --disable-debug Do not compile in debugging symbols - --enable-debug(=val) Enable debugging (debug flags val)" -ac_help="$ac_help - --enable-win32-target=\$t - Specify win32 flavor. (WIN95 or WINNT)" -ac_help="$ac_help - --enable-debug-rtl Use the MSVC debug runtime library" -ac_help="$ac_help - --enable-n32 Enable n32 ABI support (IRIX only)" -ac_help="$ac_help - --enable-64bit Enable 64-bit support (on certain platforms)" -ac_help="$ac_help - --enable-mdupdate Enable use of certain compilers' mdupdate feature" -ac_help="$ac_help - --enable-clu Enable building the command-line utilities" -ac_help="$ac_help - --with-system-svrcore Use system installed SVRCORE" -ac_help="$ac_help -[ --with-svrcore[=PATH] Use svrcore - optional PATH is path to svrcore lib and include dirs]" -ac_help="$ac_help - --with-svrcore-inc=PATH svrcore include file directory" -ac_help="$ac_help - --with-svrcore-lib=PATH svrcore library directory" -ac_help="$ac_help - --with-system-nss Use system installed NSS" -ac_help="$ac_help -[ --with-nss[=PATH] Build libssldap, using NSS for crypto - optional PATH is path to NSS package]" -ac_help="$ac_help - --with-nss-inc=PATH Netscape Portable Runtime (NSS) include file directory" -ac_help="$ac_help - --with-nss-lib=PATH Netscape Portable Runtime (NSS) library directory" -ac_help="$ac_help - --with-nss-prefix=PFX Prefix where NSS is installed" -ac_help="$ac_help - --with-nss-exec-prefix=PFX - Exec prefix where NSS is installed" -ac_help="$ac_help - --with-system-nspr Use system installed NSPR" -ac_help="$ac_help - --with-nspr=PATH Netscape Portable Runtime (NSPR) directory" -ac_help="$ac_help - --with-nspr-inc=PATH Netscape Portable Runtime (NSPR) include file directory" -ac_help="$ac_help - --with-nspr-lib=PATH Netscape Portable Runtime (NSPR) library directory" -ac_help="$ac_help - --with-nspr-prefix=PFX Prefix where NSPR is installed" -ac_help="$ac_help - --with-nspr-exec-prefix=PFX - Exec prefix where NSPR is installed" -ac_help="$ac_help - --with-macos-sdk=dir Location of platform SDK to use (Mac OS X only)" -ac_help="$ac_help - --enable-os2-high-mem Enable high-memory support on OS/2" -ac_help="$ac_help - --with-rpath[[=dir]] Build the shared libs and cmd lines progs with an RPATH (default dir is ..:../lib:../../lib:../../../lib:../../../../lib)" -ac_help="$ac_help - --enable-strip Enable stripping of shared libs and programs" -ac_help="$ac_help - --with-pthreads Use system pthreads library as thread subsystem" -ac_help="$ac_help - --enable-user-pthreads Build using userland pthreads" -ac_help="$ac_help - --enable-nspr-threads Build using classic nspr threads" -ac_help="$ac_help - --with-bthreads Use system bthreads library as thread subsystem (BeOS only)" -ac_help="$ac_help - --with-native-threads Use native system threads as thread subsystem (Solaris only)" -ac_help="$ac_help - --enable-cplus Enable some c++ api routines" -ac_help="$ac_help - --enable-ipv6 Compile ipv6 support" -ac_help="$ac_help -[ --with-sasl[=PATH] Use system installed sasl - optional path for sasl]" -ac_help="$ac_help -[ --with-sasl-inc=PATH SASL include file directory]" -ac_help="$ac_help -[ --with-sasl-lib=PATH SASL library directory]" - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; - - -host | --host | --hos | --ho) - ac_prev=host ;; - -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" - exit 0 ;; - - -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=ldap/include/ldap.h - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file -else - echo "creating cache $cache_file" - > $cache_file -fi - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -ac_exeext= -ac_objext=o -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - -ac_aux_dir= -for ac_dir in ${srcdir}/config/autoconf $srcdir/${srcdir}/config/autoconf; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in ${srcdir}/config/autoconf $srcdir/${srcdir}/config/autoconf" 1>&2; exit 1; } -fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - - -# Do some error checking and defaulting for the host and target type. -# The inputs are: -# configure --host=HOST --target=TARGET --build=BUILD NONOPT -# -# The rules are: -# 1. You are not allowed to specify --host, --target, and nonopt at the -# same time. -# 2. Host defaults to nonopt. -# 3. If nonopt is not specified, then host defaults to the current host, -# as determined by config.guess. -# 4. Target and build default to nonopt. -# 5. If nonopt is not specified, then target and build default to host. - -# The aliases save the names the user supplied, while $host etc. -# will get canonicalized. -case $host---$target---$nonopt in -NONE---*---* | *---NONE---* | *---*---NONE) ;; -*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;; -esac - - -# Make sure we can run config.sub. -if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : -else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } -fi - -echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:662: checking host system type" >&5 - -host_alias=$host -case "$host_alias" in -NONE) - case $nonopt in - NONE) - if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : - else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } - fi ;; - *) host_alias=$nonopt ;; - esac ;; -esac - -host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$host" 1>&6 - -echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:683: checking target system type" >&5 - -target_alias=$target -case "$target_alias" in -NONE) - case $nonopt in - NONE) target_alias=$host_alias ;; - *) target_alias=$nonopt ;; - esac ;; -esac - -target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias` -target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$target" 1>&6 - -echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:701: checking build system type" >&5 - -build_alias=$build -case "$build_alias" in -NONE) - case $nonopt in - NONE) build_alias=$host_alias ;; - *) build_alias=$nonopt ;; - esac ;; -esac - -build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` -build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$build" 1>&6 - -test "$host_alias" != "$target_alias" && - test "$program_prefix$program_suffix$program_transform_name" = \ - NONENONEs,x,x, && - program_prefix=${target_alias}- - - -NSPR_VERSION=4 -_HAVE_PTHREADS= -USE_PTHREADS= -USE_USER_PTHREADS= -USE_NSPR_THREADS= -USE_N32= -USE_64= -USE_CPLUS= -USE_IPV6= -USE_MDUPDATE= -_OPTIMIZE_FLAGS=-O -_DEBUG_FLAGS=-g -MOZ_DEBUG=1 -MOZ_OPTIMIZE= -MFLAGS= -OBJDIR=. -OBJDIR_NAME=. -NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall' -NOSUCHFILE=/no-such-file - -RESOLVE_LINK_SYMBOLS= - -CFLAGS="${CFLAGS=}" -CXXFLAGS="${CXXFLAGS=}" -LDFLAGS="${LDFLAGS=}" -HOST_CFLAGS="${HOST_CFLAGS=}" -HOST_LDFLAGS="${HOST_LDFLAGS=}" - -case "$target" in -*-cygwin*|*-mingw*|*-msvc*|*-mks*) - # Check to see if we are really running in a msvc environemnt - _WIN32_MSVC= - for ac_prog in cl -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:761: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$CC" && break -done - - if test "$CC" = "cl"; then - echo 'main() { return 0; }' > dummy.c - ${CC} -o dummy dummy.c >/dev/null 2>&1 - if test $? = 0; then - _WIN32_MSVC=1 - CXX=$CC - else - echo "configure: warning: $(CC) test failed. Using normal feature tests" 1>&2 - fi - rm -f dummy dummy.o dummy.obj dummy.exe dummy.c - fi - ;; -esac - -if test -n "$_WIN32_MSVC"; then - SKIP_PATH_CHECKS=1 - SKIP_COMPILER_CHECKS=1 - SKIP_LIBRARY_CHECKS=1 -fi - -dist_prefix='${MOD_DEPTH}/../../dist' -dist_bindir='${dist_prefix}/bin' -dist_libdir='${dist_prefix}/lib' - -# Check whether --with-dist-prefix or --without-dist-prefix was given. -if test "${with_dist_prefix+set}" = set; then - withval="$with_dist_prefix" - dist_prefix=$withval -fi - - -# Check whether --with-dist-bindir or --without-dist-bindir was given. -if test "${with_dist_bindir+set}" = set; then - withval="$with_dist_bindir" - dist_bindir=$withval -fi - - -# Check whether --with-dist-libdir or --without-dist-libdir was given. -if test "${with_dist_libdir+set}" = set; then - withval="$with_dist_libdir" - dist_libdir=$withval -fi - - - - - - -# Check whether --with-mozilla or --without-mozilla was given. -if test "${with_mozilla+set}" = set; then - withval="$with_mozilla" - if test "$withval" = "yes"; then - cat >> confdefs.h <<\EOF -#define MOZILLA_CLIENT 1 -EOF - - MOZILLA_CLIENT=1 - else - MOZILLA_CLIENT= - fi -else - if test -n "$MOZILLA_CLIENT"; then - cat >> confdefs.h <<\EOF -#define MOZILLA_CLIENT 1 -EOF - - fi -fi - - -# Check whether --enable-optimize or --disable-optimize was given. -if test "${enable_optimize+set}" = set; then - enableval="$enable_optimize" - if test "$enableval" != "no"; then - MOZ_OPTIMIZE=1 - if test -n "$enableval" && test "$enableval" != "yes"; then - _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'` - _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS - fi - else - MOZ_OPTIMIZE= - fi -fi - - -# Check whether --enable-debug or --disable-debug was given. -if test "${enable_debug+set}" = set; then - enableval="$enable_debug" - if test "$enableval" = "no"; then - MOZ_DEBUG= - else - MOZ_DEBUG=1 - if test -n "$enableval" && test "$enableval" != "yes"; then - _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'` - _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS - fi - fi -fi - - -# Check whether --enable-win32-target or --disable-win32-target was given. -if test "${enable_win32_target+set}" = set; then - enableval="$enable_win32_target" - OS_TARGET=`echo $enableval | tr a-z A-Z` -else - OS_TARGET= -fi - - -# Check whether --enable-debug-rtl or --disable-debug-rtl was given. -if test "${enable_debug_rtl+set}" = set; then - enableval="$enable_debug_rtl" - if test "$enableval" = "yes"; then - USE_DEBUG_RTL=1 - fi -fi - - -# Check whether --enable-n32 or --disable-n32 was given. -if test "${enable_n32+set}" = set; then - enableval="$enable_n32" - if test "$enableval" = "yes"; then - USE_N32=1 - else if test "$enableval" = "no"; then - USE_N32= - fi - fi -fi - - -# Check whether --enable-64bit or --disable-64bit was given. -if test "${enable_64bit+set}" = set; then - enableval="$enable_64bit" - if test "$enableval" = "yes"; then - USE_64=1 ; export USE_64 - fi -fi - - -# Check whether --enable-mdupdate or --disable-mdupdate was given. -if test "${enable_mdupdate+set}" = set; then - enableval="$enable_mdupdate" - if test "$enableval" = "yes"; then - USE_MDUPDATE=1 - fi -fi - - -# Check whether --enable-clu or --disable-clu was given. -if test "${enable_clu+set}" = set; then - enableval="$enable_clu" - if test "$enableval" = "yes"; then - BUILDCLU=1 - - fi -fi - - -# Check whether --with-system-svrcore or --without-system-svrcore was given. -if test "${with_system_svrcore+set}" = set; then - withval="$with_system_svrcore" - if test "$withval" = "yes"; then - _SYSTEM_SVRCORE=1 - HAVE_SVRCORE=1 - SVRCORE_LIBS=-lsvrcore - - - USE_NSS=1 - no_nspr=no - else - _SYSTEM_SVRCORE= - fi -else - _SYSTEM_SVRCORE= -fi - - -if test -z "$_SYSTEM_SVRCORE" ; then - - echo $ac_n "checking for --with-svrcore""... $ac_c" 1>&6 -echo "configure:971: checking for --with-svrcore" >&5 - # Check whether --with-svrcore or --without-svrcore was given. -if test "${with_svrcore+set}" = set; then - withval="$with_svrcore" - if test "$withval" = "yes"; then - HAVE_SVRCORE=1 - echo "$ac_t""yes" 1>&6 - elif test -n "$withval" -a -d "$withval" -a -d "$withval/lib" -a -f "$withval/include/svrcore.h" ; then - HAVE_SVRCORE=1 - echo "$ac_t""using $withval" 1>&6 - SVRCORE_CFLAGS="-I$withval/include" - SVRCORE_LIBS="-L$withval/lib" - fi -else - HAVE_SVRCORE= -fi - - - # check for --with-svrcore-inc - # Check whether --with-svrcore-inc or --without-svrcore-inc was given. -if test "${with_svrcore_inc+set}" = set; then - withval="$with_svrcore_inc" - - if test -n "$withval" -a -f "$withval"/svrcore.h - then - echo "$ac_t""using $withval" 1>&6 - SVRCORE_CFLAGS="-I$withval" - else - echo - { echo "configure: error: $withval not found" 1>&2; exit 1; } - fi - -fi - - - # check for --with-svrcore-lib - # Check whether --with-svrcore-lib or --without-svrcore-lib was given. -if test "${with_svrcore_lib+set}" = set; then - withval="$with_svrcore_lib" - - if test -n "$withval" -a -d "$withval" - then - echo "$ac_t""using $withval" 1>&6 - SVRCORE_LIBS="-L$withval" - else - echo - { echo "configure: error: $withval not found" 1>&2; exit 1; } - fi - -fi - - - if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS" ; then - echo "$ac_t""no" 1>&6 - else - HAVE_SVRCORE=1 - fi - - - if test -n "$HAVE_SVRCORE" ; then - USE_NSS=1 - HAVE_SVRCORE=1 - - no_nspr=no - if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS" ; then - if test -n "$_SYSTEM_SVRCORE"; then - - if test -n "$HAVE_SVRCORE" ; then - no_svrcore="" - echo $ac_n "checking Trying pkg-config svrcore""... $ac_c" 1>&6 -echo "configure:1041: checking Trying pkg-config svrcore" >&5 - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1045: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$PKG_CONFIG" in - /*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -if test -n "$PKG_CONFIG"; then - echo "$ac_t""$PKG_CONFIG" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test -n "$PKG_CONFIG"; then - if $PKG_CONFIG --exists svrcore-devel; then - echo $ac_n "checking using SVRCORE from package svrcore""... $ac_c" 1>&6 -echo "configure:1080: checking using SVRCORE from package svrcore" >&5 - SVRCORE_CFLAGS=`$PKG_CONFIG --cflags-only-I svrcore-devel` - SVRCORE_LIBS=`$PKG_CONFIG --libs-only-L svrcore-devel` - else - no_svrcore="yes" - fi - else - no_svrcore="yes" - fi - - if test -z "$no_svrcore"; then - echo "$ac_t""yes" 1>&6 - MOZ_NATIVE_SVRCORE=1 - else - echo "$ac_t""no" 1>&6 - fi - - - - - fi - - else - - if test -n "$HAVE_SVRCORE" ; then - svrcorelibpath=`echo ../../dist/*.OBJ/lib | cut -f1 -d' '` - savedir=`pwd` - cd $svrcorelibpath - abs_svrcorelibpath=`pwd` - cd $savedir - svrcoreincpath=../../dist/public/svrcore - savedir=`pwd` - cd $svrcoreincpath - abs_svrcoreincpath=`pwd` - cd $savedir - if test -f "$abs_svrcoreincpath/svrcore.h" ; then - SVRCORE_CFLAGS="-I$abs_svrcoreincpath" - fi - if test -d "$abs_svrcorelibpath" ; then - SVRCORE_LIBS="-L$abs_svrcorelibpath" - fi - if test -n "$SVRCORE_CFLAGS" -a -n "$SVRCORE_LIBS" ; then - echo $ac_n "checking using in-tree SVRCORE from $svrcoreincpath $svrcorelibpath""... $ac_c" 1>&6 -echo "configure:1123: checking using in-tree SVRCORE from $svrcoreincpath $svrcorelibpath" >&5 - - - echo "$ac_t""yes" 1>&6 - elif test -n "$HAVE_SVRCORE" ; then - echo $ac_n "checking could not find in-tree SVRCORE in ../../dist""... $ac_c" 1>&6 -echo "configure:1129: checking could not find in-tree SVRCORE in ../../dist" >&5 - echo "$ac_t""no" 1>&6 - else - # If user didn't ask for it, don't complain (really!) - echo "$ac_t""no" 1>&6 - fi - fi - - if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS"; then - - if test -n "$HAVE_SVRCORE" ; then - no_svrcore="" - echo $ac_n "checking Trying pkg-config svrcore""... $ac_c" 1>&6 -echo "configure:1142: checking Trying pkg-config svrcore" >&5 - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1146: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$PKG_CONFIG" in - /*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -if test -n "$PKG_CONFIG"; then - echo "$ac_t""$PKG_CONFIG" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test -n "$PKG_CONFIG"; then - if $PKG_CONFIG --exists svrcore-devel; then - echo $ac_n "checking using SVRCORE from package svrcore""... $ac_c" 1>&6 -echo "configure:1181: checking using SVRCORE from package svrcore" >&5 - SVRCORE_CFLAGS=`$PKG_CONFIG --cflags-only-I svrcore-devel` - SVRCORE_LIBS=`$PKG_CONFIG --libs-only-L svrcore-devel` - else - no_svrcore="yes" - fi - else - no_svrcore="yes" - fi - - if test -z "$no_svrcore"; then - echo "$ac_t""yes" 1>&6 - MOZ_NATIVE_SVRCORE=1 - else - echo "$ac_t""no" 1>&6 - fi - - - - - fi - - fi - fi - fi - fi -fi - -if test -n "$HAVE_SVRCORE" -a -z "$_SYSTEM_SVRCORE" ; then - if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS"; then - { echo "configure: error: --with-svrcore specified, but no svrcore could be found" 1>&2; exit 1; } - fi -fi - -# Check whether --with-system-nss or --without-system-nss was given. -if test "${with_system_nss+set}" = set; then - withval="$with_system_nss" - if test "$withval" = "yes"; then - _SYSTEM_NSS=1 - USE_NSS=1 - no_nspr=no - elif test "$withval" = "no" ; then - _SYSTEM_NSS=no - fi -else - _SYSTEM_NSS= -fi - - -if test "$_WIN32_MSVC"; then - _SYSTEM_NSS= -fi - -if test -z "$_SYSTEM_NSS" -o "$_SYSTEM_NSS" = "no" ; then - - echo $ac_n "checking for --with-nss""... $ac_c" 1>&6 -echo "configure:1237: checking for --with-nss" >&5 - # Check whether --with-nss or --without-nss was given. -if test "${with_nss+set}" = set; then - withval="$with_nss" - if test "$withval" = "yes"; then - USE_NSS=1 - echo "$ac_t""yes" 1>&6 - elif test -d "$withval" -a -d "$withval/lib" -a -d "$withval/include" ; then - USE_NSS=1 - echo "$ac_t""using $withval" 1>&6 - NSS_CFLAGS="-I$withval/include" - NSS_LIBS="-L$withval/lib" - else - echo "$ac_t""no" 1>&6 - USE_NSS= - fi -else - echo "$ac_t""no" 1>&6 -fi - - - # check for --with-nss-inc - echo $ac_n "checking for --with-nss-inc""... $ac_c" 1>&6 -echo "configure:1260: checking for --with-nss-inc" >&5 - # Check whether --with-nss-inc or --without-nss-inc was given. -if test "${with_nss_inc+set}" = set; then - withval="$with_nss_inc" - - if test -f "$withval"/nss.h - then - echo "$ac_t""using $withval" 1>&6 - NSS_CFLAGS="-I$withval" - USE_NSS=1 - else - echo - { echo "configure: error: $withval not found" 1>&2; exit 1; } - fi - -else - echo "$ac_t""no" 1>&6 -fi - - - # check for --with-nss-lib - echo $ac_n "checking for --with-nss-lib""... $ac_c" 1>&6 -echo "configure:1282: checking for --with-nss-lib" >&5 - # Check whether --with-nss-lib or --without-nss-lib was given. -if test "${with_nss_lib+set}" = set; then - withval="$with_nss_lib" - - if test -d "$withval" - then - echo "$ac_t""using $withval" 1>&6 - NSS_LIBS="-L$withval" - USE_NSS=1 - else - echo - { echo "configure: error: $withval not found" 1>&2; exit 1; } - fi - -else - echo "$ac_t""no" 1>&6 -fi - - -fi - -if test -n "$USE_NSS" -a -z "$NSS_CFLAGS" -a -z "$NSS_LIBS" ; then - no_nspr=no - if test -z "$_SYSTEM_NSS" -o "$_SYSTEM_NSS" = "no" ; then - - nsslibpath=`echo ../../dist/*.OBJ/lib | cut -f1 -d' '` - savedir=`pwd` - cd $nsslibpath - abs_nsslibpath=`pwd` - cd $savedir - nssincpath=../../dist/public/nss - savedir=`pwd` - cd $nssincpath - abs_nssincpath=`pwd` - cd $savedir - if test -f "$abs_nssincpath/nss.h" ; then - NSS_CFLAGS="-I$abs_nssincpath" - fi - if test -d "$abs_nsslibpath" ; then - NSS_LIBS="-L$abs_nsslibpath" - fi - if test -n "$NSS_CFLAGS" -a -n "$NSS_LIBS" ; then - echo $ac_n "checking using in-tree NSS from $nssincpath $nsslibpath""... $ac_c" 1>&6 -echo "configure:1326: checking using in-tree NSS from $nssincpath $nsslibpath" >&5 - - - echo "$ac_t""yes" 1>&6 - else - echo $ac_n "checking could not find in-tree NSS in ../../dist""... $ac_c" 1>&6 -echo "configure:1332: checking could not find in-tree NSS in ../../dist" >&5 - echo "$ac_t""no" 1>&6 - fi - - fi - if test -z "$NSS_CFLAGS" -a "$_SYSTEM_NSS" != "no" ; then - -# Check whether --with-nss-prefix or --without-nss-prefix was given. -if test "${with_nss_prefix+set}" = set; then - withval="$with_nss_prefix" - nss_config_prefix="$withval" -else - nss_config_prefix="" -fi - - -# Check whether --with-nss-exec-prefix or --without-nss-exec-prefix was given. -if test "${with_nss_exec_prefix+set}" = set; then - withval="$with_nss_exec_prefix" - nss_config_exec_prefix="$withval" -else - nss_config_exec_prefix="" -fi - - - if test -n "$nss_config_exec_prefix"; then - nss_config_args="$nss_config_args --exec-prefix=$nss_config_exec_prefix" - if test -z "$NSS_CONFIG"; then - NSS_CONFIG=$nss_config_exec_prefix/bin/nss-config - fi - fi - if test -n "$nss_config_prefix"; then - nss_config_args="$nss_config_args --prefix=$nss_config_prefix" - if test -z "$NSS_CONFIG"; then - NSS_CONFIG=$nss_config_prefix/bin/nss-config - fi - fi - - if test -z "$NSS_CONFIG" ; then - unset ac_cv_path_NSS_CONFIG - # Extract the first word of "nss-config", so it can be a program name with args. -set dummy nss-config; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1375: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_NSS_CONFIG'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$NSS_CONFIG" in - /*) - ac_cv_path_NSS_CONFIG="$NSS_CONFIG" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_NSS_CONFIG="$NSS_CONFIG" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_NSS_CONFIG="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_path_NSS_CONFIG" && ac_cv_path_NSS_CONFIG="no" - ;; -esac -fi -NSS_CONFIG="$ac_cv_path_NSS_CONFIG" -if test -n "$NSS_CONFIG"; then - echo "$ac_t""$NSS_CONFIG" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - min_nss_version=3.9.0 - echo $ac_n "checking for NSS - version >= $min_nss_version (skipping)""... $ac_c" 1>&6 -echo "configure:1410: checking for NSS - version >= $min_nss_version (skipping)" >&5 - fi - - no_nss="" - if test "$NSS_CONFIG" = "no"; then - echo $ac_n "checking nss-config not found""... $ac_c" 1>&6 -echo "configure:1416: checking nss-config not found" >&5 - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1420: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$PKG_CONFIG" in - /*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -if test -n "$PKG_CONFIG"; then - echo "$ac_t""$PKG_CONFIG" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test -n "$PKG_CONFIG"; then - if $PKG_CONFIG --exists nss; then - echo $ac_n "checking using NSS from package nss""... $ac_c" 1>&6 -echo "configure:1455: checking using NSS from package nss" >&5 - NSS_CFLAGS=`$PKG_CONFIG --cflags-only-I nss` - NSS_LIBS=`$PKG_CONFIG --libs-only-L nss` - elif $PKG_CONFIG --exists mozilla-nss; then - echo $ac_n "checking using NSS from package mozilla-nss""... $ac_c" 1>&6 -echo "configure:1460: checking using NSS from package mozilla-nss" >&5 - NSS_CFLAGS=`$PKG_CONFIG --cflags-only-I mozilla-nss` - NSS_LIBS=`$PKG_CONFIG --libs-only-L mozilla-nss` - else - { echo "configure: error: system NSS not found" 1>&2; exit 1; } - no_nss="yes" - fi - else - no_nss="yes" - fi - else - echo $ac_n "checking using NSS from $NSS_CONFIG""... $ac_c" 1>&6 -echo "configure:1472: checking using NSS from $NSS_CONFIG" >&5 - NSS_CFLAGS=`$NSS_CONFIG $nss_config_args --cflags` - NSS_LIBS=`$NSS_CONFIG $nss_config_args --libs` - - nss_config_major_version=`$NSS_CONFIG $nss_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` - nss_config_minor_version=`$NSS_CONFIG $nss_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` - nss_config_micro_version=`$NSS_CONFIG $nss_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` - fi - - if test -z "$no_nss"; then - echo "$ac_t""yes" 1>&6 - MOZ_NATIVE_NSS=1 - else - echo "$ac_t""no" 1>&6 - fi - - - - - - - fi -fi - -if test -n "$USE_NSS" -a -z "$NSS_CFLAGS" -a -z "$NSS_LIBS" ; then - { echo "configure: error: Need to use NSS but no NSS was found" 1>&2; exit 1; } -fi - -# Check whether --with-system-nspr or --without-system-nspr was given. -if test "${with_system_nspr+set}" = set; then - withval="$with_system_nspr" - if test "$withval" = "yes"; then - _SYSTEM_NSPR=1 - no_nspr=no - elif test "$withval" = "no"; then - _SYSTEM_NSPR=no - fi -else - _SYSTEM_NSPR= -fi - - -if test "$_WIN32_MSVC"; then - _SYSTEM_NSPR=no -fi - -if test -z "$_SYSTEM_NSPR" -o "$_SYSTEM_NSPR" = "no" ; then - - # check for --with-nspr - echo $ac_n "checking for --with-nspr""... $ac_c" 1>&6 -echo "configure:1525: checking for --with-nspr" >&5 - # Check whether --with-nspr or --without-nspr was given. -if test "${with_nspr+set}" = set; then - withval="$with_nspr" - - if test "$withval" = "no" ; then - echo "$ac_t""no" 1>&6 - no_nspr="yes" - elif test "$withval" = "yes" ; then - echo "$ac_t""yes" 1>&6 - no_nspr="no" - elif test -f "$withval"/include/nspr.h -a -d "$withval"/lib - then - echo "$ac_t""using $withval" 1>&6 - NSPR_CFLAGS="-I$withval/include" - NSPR_LIBS="-L$withval/lib" - else - echo - { echo "configure: error: $withval not found" 1>&2; exit 1; } - fi - -else - echo "$ac_t""no" 1>&6 -fi - - - # check for --with-nspr-inc - echo $ac_n "checking for --with-nspr-inc""... $ac_c" 1>&6 -echo "configure:1553: checking for --with-nspr-inc" >&5 - # Check whether --with-nspr-inc or --without-nspr-inc was given. -if test "${with_nspr_inc+set}" = set; then - withval="$with_nspr_inc" - - if test -f "$withval"/nspr.h - then - echo "$ac_t""using $withval" 1>&6 - NSPR_CFLAGS="-I$withval" - else - echo - { echo "configure: error: $withval not found" 1>&2; exit 1; } - fi - -else - echo "$ac_t""no" 1>&6 -fi - - - # check for --with-nspr-lib - echo $ac_n "checking for --with-nspr-lib""... $ac_c" 1>&6 -echo "configure:1574: checking for --with-nspr-lib" >&5 - # Check whether --with-nspr-lib or --without-nspr-lib was given. -if test "${with_nspr_lib+set}" = set; then - withval="$with_nspr_lib" - - if test -d "$withval" - then - echo "$ac_t""using $withval" 1>&6 - NSPR_LIBS="-L$withval" - else - echo - { echo "configure: error: $withval not found" 1>&2; exit 1; } - fi - -else - echo "$ac_t""no" 1>&6 -fi - - -fi - -if test "$no_nspr" = "no" -a -z "$NSPR_CFLAGS" -a -z "$NSPR_LIBS" ; then - if test -z "$_SYSTEM_NSPR" -o "$_SYSTEM_NSPR" = "no" ; then - - echo $ac_n "checking checking for in-tree NSPR from ../../dist""... $ac_c" 1>&6 -echo "configure:1599: checking checking for in-tree NSPR from ../../dist" >&5 - for nsprpath in "../../dist" "../../dist"/*.OBJ ; do - savedir=`pwd` - cd $nsprpath - abs_nsprpath=`pwd` - cd $savedir - if test -f "$abs_nsprpath/include/nspr/nspr.h" ; then - NSPR_CFLAGS="-I$abs_nsprpath/include/nspr" - elif test -f "$abs_nsprpath/include/nspr.h" ; then - NSPR_CFLAGS="-I$abs_nsprpath/include" - fi - if test -d "$abs_nsprpath/lib" ; then - NSPR_LIBS="-L$abs_nsprpath/lib" - fi - if test -n "$NSPR_CFLAGS" -a -n "$NSPR_LIBS" ; then - break - fi - done - if test -n "$NSPR_CFLAGS" -a -n "$NSPR_LIBS" ; then - - - echo "$ac_t""yes" 1>&6 - else - echo "$ac_t""no" 1>&6 - fi - - fi - if test -z "$NSPR_CFLAGS" -a "$_SYSTEM_NSPR" != "no" ; then - -# Check whether --with-nspr-prefix or --without-nspr-prefix was given. -if test "${with_nspr_prefix+set}" = set; then - withval="$with_nspr_prefix" - nspr_config_prefix="$withval" -else - nspr_config_prefix="" -fi - - -# Check whether --with-nspr-exec-prefix or --without-nspr-exec-prefix was given. -if test "${with_nspr_exec_prefix+set}" = set; then - withval="$with_nspr_exec_prefix" - nspr_config_exec_prefix="$withval" -else - nspr_config_exec_prefix="" -fi - - - if test -n "$nspr_config_exec_prefix"; then - nspr_config_args="$nspr_config_args --exec-prefix=$nspr_config_exec_prefix" - if test -z "$NSPR_CONFIG"; then - NSPR_CONFIG=$nspr_config_exec_prefix/bin/nspr-config - fi - fi - if test -n "$nspr_config_prefix"; then - nspr_config_args="$nspr_config_args --prefix=$nspr_config_prefix" - if test -z "$NSPR_CONFIG"; then - NSPR_CONFIG=$nspr_config_prefix/bin/nspr-config - fi - fi - - if test -z "$NSPR_CONFIG" ; then - unset ac_cv_path_NSPR_CONFIG - # Extract the first word of "nspr-config", so it can be a program name with args. -set dummy nspr-config; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1664: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_NSPR_CONFIG'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$NSPR_CONFIG" in - /*) - ac_cv_path_NSPR_CONFIG="$NSPR_CONFIG" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_NSPR_CONFIG="$NSPR_CONFIG" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_NSPR_CONFIG="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_path_NSPR_CONFIG" && ac_cv_path_NSPR_CONFIG="no" - ;; -esac -fi -NSPR_CONFIG="$ac_cv_path_NSPR_CONFIG" -if test -n "$NSPR_CONFIG"; then - echo "$ac_t""$NSPR_CONFIG" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - min_nspr_version=4.0.0 - echo $ac_n "checking for NSPR - version >= $min_nspr_version (skipping)""... $ac_c" 1>&6 -echo "configure:1699: checking for NSPR - version >= $min_nspr_version (skipping)" >&5 - fi - - no_nspr="" - if test "$NSPR_CONFIG" = "no"; then - echo $ac_n "checking nspr-config not found""... $ac_c" 1>&6 -echo "configure:1705: checking nspr-config not found" >&5 - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1709: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$PKG_CONFIG" in - /*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -if test -n "$PKG_CONFIG"; then - echo "$ac_t""$PKG_CONFIG" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test -n "$PKG_CONFIG"; then - if $PKG_CONFIG --exists nspr; then - echo $ac_n "checking using NSPR from package nspr""... $ac_c" 1>&6 -echo "configure:1744: checking using NSPR from package nspr" >&5 - NSPR_CFLAGS=`$PKG_CONFIG --cflags-only-I nspr` - NSPR_LIBS=`$PKG_CONFIG --libs-only-L nspr` - elif $PKG_CONFIG --exists mozilla-nspr; then - echo $ac_n "checking using NSPR from package mozilla-nspr""... $ac_c" 1>&6 -echo "configure:1749: checking using NSPR from package mozilla-nspr" >&5 - NSPR_CFLAGS=`$PKG_CONFIG --cflags-only-I mozilla-nspr` - NSPR_LIBS=`$PKG_CONFIG --libs-only-L mozilla-nspr` - else - echo $ac_n "checking system NSPR not found""... $ac_c" 1>&6 -echo "configure:1754: checking system NSPR not found" >&5 - no_nspr="yes" - fi - else - no_nspr="yes" - fi - else - echo $ac_n "checking using NSPR from $NSPR_CONFIG""... $ac_c" 1>&6 -echo "configure:1762: checking using NSPR from $NSPR_CONFIG" >&5 - NSPR_CFLAGS=`$NSPR_CONFIG $nspr_config_args --cflags` - NSPR_LIBS=`$NSPR_CONFIG $nspr_config_args --libs` - - nspr_config_major_version=`$NSPR_CONFIG $nspr_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` - nspr_config_minor_version=`$NSPR_CONFIG $nspr_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` - nspr_config_micro_version=`$NSPR_CONFIG $nspr_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` - fi - - if test -z "$no_nspr"; then - echo "$ac_t""yes" 1>&6 - MOZ_NATIVE_NSPR=1 - else - echo "$ac_t""no" 1>&6 - fi - - - - - - - fi -fi - -if test -z "$NSPR_CFLAGS" -o -z "$NSPR_LIBS" ; then - if test -n "$MOZILLA_CLIENT" ; then - NSPR_CFLAGS='-I$(DIST)/include/nspr' - NSPR_LIBS='-L$(DIST)/lib '"-lplds$NSPR_VERSION -lplc$NSPR_VERSION -lnspr$NSPR_VERSION" - if test "$VACPP" = "yes"; then - NSPR_LIBS='$(DIST)/lib/nspr'$NSPR_VERSION'.lib $(DIST)/lib/plc'$NSPR_VERSION'.lib $(DIST)/lib/plds'$NSPR_VERSION'.lib '$_PTHREAD_LDFLAGS'' - elif test "$_WIN32_MSVC"; then - NSPR_LIBS='$(DIST)/lib/nspr'$NSPR_VERSION'.lib $(DIST)/lib/plc'$NSPR_VERSION'.lib $(DIST)/lib/plds'$NSPR_VERSION'.lib ' - fi - SKIP_CYGWIN_FIXUP=1 - LIBS_ALREADY_SET=1 - - elif test "$no_nspr" = "no" ; then - { echo "configure: error: Need to use NSPR but no NSPR was found" 1>&2; exit 1; } - fi -fi - - -case "$target" in -*-cygwin*) USE_WINDOWS_PATHS=1 ;; -esac - -if test -n "$_WIN32_MSVC" -a -n "$USE_WINDOWS_PATHS" ; then - if test -n "$NSPR_CFLAGS" -a -z "$SKIP_CYGWIN_FIXUP" ; then - path=`echo $NSPR_CFLAGS | sed -e 's/^-I//'` - path=`cygpath -m $path` - NSPR_CFLAGS="/I$path" - fi - if test -n "$NSPR_LIBS" -a -z "$SKIP_CYGWIN_FIXUP" ; then - path=`echo $NSPR_LIBS | sed -e 's/^-L//'` - path=`cygpath -m $path` - NSPR_LIBS="/LIBPATH:$path" - fi - - if test -n "$NSS_CFLAGS" ; then - path=`echo $NSS_CFLAGS | sed -e 's/^-I//'` - path=`cygpath -m $path` - NSS_CFLAGS="/I$path" - fi - - if test -n "$NSS_LIBS" ; then - path=`echo $NSS_LIBS | sed -e 's/^-L//'` - path=`cygpath -m $path` - NSS_LIBS="/LIBPATH:$path" - fi - - if test -n "$SVRCORE_CFLAGS" ; then - path=`echo $SVRCORE_CFLAGS | sed -e 's/^-I//'` - path=`cygpath -m $path` - SVRCORE_CFLAGS="/I$path" - fi - - if test -n "$SVRCORE_LIBS" ; then - path=`echo $SVRCORE_LIBS | sed -e 's/^-L//'` - path=`cygpath -m $path` - SVRCORE_LIBS="/LIBPATH:$path" - fi -fi - -case "$target" in - -*-aix*) - case "${target_os}" in - aix3.2*) - USE_NSPR_THREADS=1 - ;; - *) - USE_PTHREADS=1 - ;; - esac - ;; - -esac - -if test -z "$CC"; then - case "$target" in - - *-aix*) - if test -z "$USE_NSPR_THREADS"; then - CC=xlC_r - else - CC=xlC - fi - ;; - - *-hpux*) - CC=cc - ;; - - *-irix*) - CC=cc - ;; - - *-osf*) - CC=cc - ;; - - *-solaris*) - CC=cc - ;; - - esac -fi - -if test -z "$CXX"; then - case "$target" in - - *-aix*) - if test -z "$USE_NSPR_THREADS"; then - CXX=xlC_r - else - CXX=xlC - fi - ;; - - *-hpux*) - case "${target_os}" in - hpux10.30) - CXX=aCC - ;; - hpux11.*) - CXX=aCC - ;; - *) - CXX=CC - ;; - esac - ;; - - *-irix*) - CXX=CC - ;; - - *-osf*) - CXX=cxx - ;; - - *-solaris*) - CXX=CC - ;; - - esac -fi - -if test -z "$SKIP_PATH_CHECKS"; then - # Extract the first word of "$WHOAMI whoami", so it can be a program name with args. -set dummy $WHOAMI whoami; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1937: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_WHOAMI'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$WHOAMI" in - /*) - ac_cv_path_WHOAMI="$WHOAMI" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_WHOAMI="$WHOAMI" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_WHOAMI="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_path_WHOAMI" && ac_cv_path_WHOAMI="echo not_whoami" - ;; -esac -fi -WHOAMI="$ac_cv_path_WHOAMI" -if test -n "$WHOAMI"; then - echo "$ac_t""$WHOAMI" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -fi - -if test -n "$MOZ_DEBUG"; then - cat >> confdefs.h <<\EOF -#define DEBUG 1 -EOF - - DEFINES="$DEFINES -UNDEBUG" - case "${target_os}" in - beos*) - DEFINES="$DEFINES -DDEBUG_${USER}" - ;; - msvc*|mks*|cygwin*|mingw*|os2*) - DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`" - ;; - *) - DEFINES="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_`$WHOAMI`" - ;; - esac - MFLAGS="BUILD_DEBUG=full" -else - cat >> confdefs.h <<\EOF -#define NDEBUG 1 -EOF - - DEFINES="$DEFINES -UDEBUG" - MFLAGS="BUILD_DEBUG=optimize" -fi - -if test -n "$MOZILLA_CLIENT"; then - NSINSTALL='$(dist_bindir)/nsinstall' -fi - -if test -z "$SKIP_COMPILER_CHECKS"; then -cross_compiling=no -if test -n "$host" ; then - case $target in - *-darwin*) - if test "$host" != "$target" ; then - cross_compiling=yes - fi - ;; - *) - if test "$host" = "$build" ; then - cross_compiling=no - elif test "$host" != "$target" -o "$host" != "$build" ; then - cross_compiling=yes - fi - ;; - esac -fi -if test "$cross_compiling" = "no"; then - for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2027: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CXX="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CXX="$ac_cv_prog_CXX" -if test -n "$CXX"; then - echo "$ac_t""$CXX" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$CXX" && break -done -test -n "$CXX" || CXX="gcc" - - -echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:2059: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 - -ac_ext=C -# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cxx_cross - -cat > conftest.$ac_ext << EOF - -#line 2070 "configure" -#include "confdefs.h" - -int main(){return(0);} -EOF -if { (eval echo configure:2075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cxx_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cxx_cross=no - else - ac_cv_prog_cxx_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cxx_works=no -fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6 -if test $ac_cv_prog_cxx_works = no; then - { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:2101: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 -cross_compiling=$ac_cv_prog_cxx_cross - -echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 -echo "configure:2106: checking whether we are using GNU C++" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.C <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:2115: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gxx=yes -else - ac_cv_prog_gxx=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gxx" 1>&6 - -if test $ac_cv_prog_gxx = yes; then - GXX=yes -else - GXX= -fi - -ac_test_CXXFLAGS="${CXXFLAGS+set}" -ac_save_CXXFLAGS="$CXXFLAGS" -CXXFLAGS= -echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 -echo "configure:2134: checking whether ${CXX-g++} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.cc -if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then - ac_cv_prog_cxx_g=yes -else - ac_cv_prog_cxx_g=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6 -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS="$ac_save_CXXFLAGS" -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi - -for ac_declaration in \ - ''\ - '#include <stdlib.h>' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat > conftest.$ac_ext <<EOF -#line 2175 "configure" -#include "confdefs.h" -#include <stdlib.h> -$ac_declaration -int main() { -exit (42); -; return 0; } -EOF -if { (eval echo configure:2183: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - continue -fi -rm -f conftest* - cat > conftest.$ac_ext <<EOF -#line 2193 "configure" -#include "confdefs.h" -$ac_declaration -int main() { -exit (42); -; return 0; } -EOF -if { (eval echo configure:2200: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - break -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -done -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - - - if test "$CXX" = "cl" -a -z "$CC"; then - CC=$CXX - else - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2222: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2252: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_prog_rejected=no - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# -gt 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" - fi -fi -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test -z "$CC"; then - case "`uname -s`" in - *win32* | *WIN32*) - # Extract the first word of "cl", so it can be a program name with args. -set dummy cl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2303: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="cl" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - ;; - esac - fi - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } -fi - -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:2335: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -cat > conftest.$ac_ext << EOF - -#line 2346 "configure" -#include "confdefs.h" - -main(){return(0);} -EOF -if { (eval echo configure:2351: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no - else - ac_cv_prog_cc_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no -fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:2377: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:2382: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2391: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 - -if test $ac_cv_prog_gcc = yes; then - GCC=yes -else - GCC= -fi - -ac_test_CFLAGS="${CFLAGS+set}" -ac_save_CFLAGS="$CFLAGS" -CFLAGS= -echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:2410: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_cc_g=yes -else - ac_cv_prog_cc_g=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi - - fi - echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:2443: checking how to run the C preprocessor" >&5 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext <<EOF -#line 2458 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2464: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext <<EOF -#line 2475 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2481: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext <<EOF -#line 2492 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi - CPP="$ac_cv_prog_CPP" -else - ac_cv_prog_CPP="$CPP" -fi -echo "$ac_t""$CPP" 1>&6 - - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2525: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - for ac_prog in as -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2557: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_AS'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$AS" in - /*) - ac_cv_path_AS="$AS" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_AS="$AS" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_AS="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -AS="$ac_cv_path_AS" -if test -n "$AS"; then - echo "$ac_t""$AS" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$AS" && break -done -test -n "$AS" || AS="$CC" - - for ac_prog in ar -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2598: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_AR'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$AR" in - /*) - ac_cv_path_AR="$AR" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_AR="$AR" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_AR="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -AR="$ac_cv_path_AR" -if test -n "$AR"; then - echo "$ac_t""$AR" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$AR" && break -done -test -n "$AR" || AR="echo not_ar" - - for ac_prog in ld link -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2639: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$LD" in - /*) - ac_cv_path_LD="$LD" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_LD="$LD" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_LD="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -LD="$ac_cv_path_LD" -if test -n "$LD"; then - echo "$ac_t""$LD" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$LD" && break -done -test -n "$LD" || LD="echo not_ld" - - for ac_prog in strip -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2680: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_STRIP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$STRIP" in - /*) - ac_cv_path_STRIP="$STRIP" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_STRIP="$STRIP" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_STRIP="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -STRIP="$ac_cv_path_STRIP" -if test -n "$STRIP"; then - echo "$ac_t""$STRIP" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$STRIP" && break -done -test -n "$STRIP" || STRIP="echo not_strip" - - for ac_prog in windres -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2721: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_WINDRES'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$WINDRES" in - /*) - ac_cv_path_WINDRES="$WINDRES" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_WINDRES="$WINDRES" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_WINDRES="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -WINDRES="$ac_cv_path_WINDRES" -if test -n "$WINDRES"; then - echo "$ac_t""$WINDRES" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$WINDRES" && break -done -test -n "$WINDRES" || WINDRES="echo not_windres" - - if test -z "$HOST_CC"; then - HOST_CC="$CC" - fi - if test -z "$HOST_CFLAGS"; then - HOST_CFLAGS="$CFLAGS" - fi -else - echo "cross compiling from $host to $target" - - _SAVE_CC="$CC" - _SAVE_CFLAGS="$CFLAGS" - _SAVE_LDFLAGS="$LDFLAGS" - - echo $ac_n "checking for $host compiler""... $ac_c" 1>&6 -echo "configure:2771: checking for $host compiler" >&5 - for ac_prog in gcc cc /usr/ucb/cc -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2777: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_HOST_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$HOST_CC"; then - ac_cv_prog_HOST_CC="$HOST_CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_HOST_CC="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -HOST_CC="$ac_cv_prog_HOST_CC" -if test -n "$HOST_CC"; then - echo "$ac_t""$HOST_CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$HOST_CC" && break -done -test -n "$HOST_CC" || HOST_CC="""" - - if test -z "$HOST_CC"; then - { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } - fi - echo "$ac_t""$HOST_CC" 1>&6 - if test -z "$HOST_CFLAGS"; then - HOST_CFLAGS="$CFLAGS" - fi - if test -z "$HOST_LDFLAGS"; then - HOST_LDFLAGS="$LDFLAGS" - fi - - CC=$_SAVE_CC - CFLAGS=$_SAVE_CFLAGS - LDFLAGS=$_SAVE_LDFLAGS - - case "$build:$target" in - powerpc-apple-darwin8*:i?86-apple-darwin*) - _SAVE_CFLAGS=$CFLAGS - _SAVE_CXXFLAGS=$CXXLAGS - CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS" - CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS" - ;; - esac - - for ac_prog in $CC "${target_alias}-gcc" "${target}-gcc" -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2836: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$CC" && break -done -test -n "$CC" || CC="echo" - - unset ac_cv_prog_CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2870: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2900: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_prog_rejected=no - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# -gt 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" - fi -fi -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test -z "$CC"; then - case "`uname -s`" in - *win32* | *WIN32*) - # Extract the first word of "cl", so it can be a program name with args. -set dummy cl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2951: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="cl" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - ;; - esac - fi - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } -fi - -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:2983: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -cat > conftest.$ac_ext << EOF - -#line 2994 "configure" -#include "confdefs.h" - -main(){return(0);} -EOF -if { (eval echo configure:2999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no - else - ac_cv_prog_cc_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no -fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:3025: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:3030: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:3039: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 - -if test $ac_cv_prog_gcc = yes; then - GCC=yes -else - GCC= -fi - -ac_test_CFLAGS="${CFLAGS+set}" -ac_save_CFLAGS="$CFLAGS" -CFLAGS= -echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:3058: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_cc_g=yes -else - ac_cv_prog_cc_g=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi - - for ac_prog in $CXX "${target_alias}-g++" "${target}-g++" -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3094: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CXX="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CXX="$ac_cv_prog_CXX" -if test -n "$CXX"; then - echo "$ac_t""$CXX" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$CXX" && break -done -test -n "$CXX" || CXX="echo" - - unset ac_cv_prog_CXX - for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3130: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CXX="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CXX="$ac_cv_prog_CXX" -if test -n "$CXX"; then - echo "$ac_t""$CXX" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$CXX" && break -done -test -n "$CXX" || CXX="gcc" - - -echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:3162: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 - -ac_ext=C -# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cxx_cross - -cat > conftest.$ac_ext << EOF - -#line 3173 "configure" -#include "confdefs.h" - -int main(){return(0);} -EOF -if { (eval echo configure:3178: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cxx_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cxx_cross=no - else - ac_cv_prog_cxx_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cxx_works=no -fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6 -if test $ac_cv_prog_cxx_works = no; then - { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:3204: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 -cross_compiling=$ac_cv_prog_cxx_cross - -echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 -echo "configure:3209: checking whether we are using GNU C++" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.C <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:3218: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gxx=yes -else - ac_cv_prog_gxx=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gxx" 1>&6 - -if test $ac_cv_prog_gxx = yes; then - GXX=yes -else - GXX= -fi - -ac_test_CXXFLAGS="${CXXFLAGS+set}" -ac_save_CXXFLAGS="$CXXFLAGS" -CXXFLAGS= -echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 -echo "configure:3237: checking whether ${CXX-g++} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.cc -if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then - ac_cv_prog_cxx_g=yes -else - ac_cv_prog_cxx_g=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6 -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS="$ac_save_CXXFLAGS" -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi - -for ac_declaration in \ - ''\ - '#include <stdlib.h>' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat > conftest.$ac_ext <<EOF -#line 3278 "configure" -#include "confdefs.h" -#include <stdlib.h> -$ac_declaration -int main() { -exit (42); -; return 0; } -EOF -if { (eval echo configure:3286: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - continue -fi -rm -f conftest* - cat > conftest.$ac_ext <<EOF -#line 3296 "configure" -#include "confdefs.h" -$ac_declaration -int main() { -exit (42); -; return 0; } -EOF -if { (eval echo configure:3303: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - break -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -done -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - - - - case "$build:$target" in - powerpc-apple-darwin8*:i?86-apple-darwin*) - CFLAGS=$_SAVE_CFLAGS - CXXFLAGS=$_SAVE_CXXFLAGS - ;; - esac - - for ac_prog in $RANLIB "${target_alias}-ranlib" "${target}-ranlib" -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3332: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$RANLIB" && break -done -test -n "$RANLIB" || RANLIB="echo" - - for ac_prog in $AR "${target_alias}-ar" "${target}-ar" -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3367: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_AR="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -AR="$ac_cv_prog_AR" -if test -n "$AR"; then - echo "$ac_t""$AR" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$AR" && break -done -test -n "$AR" || AR="echo" - - for ac_prog in $AS "${target_alias}-as" "${target}-as" -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3402: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$AS"; then - ac_cv_prog_AS="$AS" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_AS="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -AS="$ac_cv_prog_AS" -if test -n "$AS"; then - echo "$ac_t""$AS" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$AS" && break -done -test -n "$AS" || AS="echo" - - for ac_prog in $LD "${target_alias}-ld" "${target}-ld" -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3437: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$LD"; then - ac_cv_prog_LD="$LD" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_LD="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -LD="$ac_cv_prog_LD" -if test -n "$LD"; then - echo "$ac_t""$LD" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$LD" && break -done -test -n "$LD" || LD="echo" - - for ac_prog in $STRIP "${target_alias}-strip" "${target}-strip" -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3472: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_STRIP="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -STRIP="$ac_cv_prog_STRIP" -if test -n "$STRIP"; then - echo "$ac_t""$STRIP" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$STRIP" && break -done -test -n "$STRIP" || STRIP="echo" - - for ac_prog in $WINDRES "${target_alias}-windres" "${target}-windres" -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3507: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$WINDRES"; then - ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_WINDRES="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -WINDRES="$ac_cv_prog_WINDRES" -if test -n "$WINDRES"; then - echo "$ac_t""$WINDRES" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$WINDRES" && break -done -test -n "$WINDRES" || WINDRES="echo" - -fi - -if test "$GCC" = "yes"; then - GNU_CC=1 -fi -if test "$GXX" = "yes"; then - GNU_CXX=1 -fi -if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then - GNU_AS=1 -fi -rm -f a.out - -case "$build:$target" in - i?86-apple-darwin*:powerpc-apple-darwin*) - cross_compiling=yes - ;; -esac - -if test "$cross_compiling" = "yes"; then - CROSS_COMPILE=1 -else - CROSS_COMPILE= -fi - -echo $ac_n "checking for gcc -pipe support""... $ac_c" 1>&6 -echo "configure:3563: checking for gcc -pipe support" >&5 -if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then - echo '#include <stdio.h>' > dummy-hello.c - echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c - ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5 - cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5 - if test $? = 0; then - _res_as_stdin="yes" - else - _res_as_stdin="no" - fi - if test "$_res_as_stdin" = "yes"; then - _SAVE_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -pipe" - cat > conftest.$ac_ext <<EOF -#line 3578 "configure" -#include "confdefs.h" - #include <stdio.h> -int main() { -printf("Hello World\n"); -; return 0; } -EOF -if { (eval echo configure:3585: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - _res_gcc_pipe="yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - _res_gcc_pipe="no" -fi -rm -f conftest* - CFLAGS=$_SAVE_CFLAGS - fi - if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then - _res="yes"; - CFLAGS="$CFLAGS -pipe" - CXXFLAGS="$CXXFLAGS -pipe" - else - _res="no" - fi - rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out - echo "$ac_t""$_res" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -fi # SKIP_COMPILER_CHECKS - -if test -z "$SKIP_PATH_CHECKS"; then - for ac_prog in perl5 perl -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3618: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$PERL" in - /*) - ac_cv_path_PERL="$PERL" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_PERL="$PERL" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_PERL="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -PERL="$ac_cv_path_PERL" -if test -n "$PERL"; then - echo "$ac_t""$PERL" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$PERL" && break -done -test -n "$PERL" || PERL="echo not_perl" - -elif test -z "$PERL"; then - PERL=perl -fi - -OBJ_SUFFIX=o -LIB_SUFFIX=a -LIB_PREFIX=lib -DLL_SUFFIX=so -ASM_SUFFIX=s -MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@' -AR_FLAGS='cr $@' -AS='$(CC)' -ASFLAGS='$(CFLAGS)' - -if test -n "$CROSS_COMPILE"; then - OS_ARCH=`echo $target_os | sed -e 's|/|_|g'` - OS_RELEASE= - OS_TEST="${target_cpu}" - case "${target_os}" in - linux*) OS_ARCH=Linux ;; - solaris*) OS_ARCH=SunOS OS_RELEASE=5 ;; - mingw*) OS_ARCH=WINNT ;; - darwin*) OS_ARCH=Darwin ;; - esac -else - OS_ARCH=`uname -s | sed -e 's|/|_|g'` - OS_RELEASE=`uname -r` - OS_TEST=`uname -m` -fi - -if test "$OS_ARCH" = "IRIX64"; then - OS_ARCH=IRIX -fi - -if test "$OS_ARCH" = "Linux"; then - OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'` - OS_RELEASE=`echo $OS_RELEASE | awk -F. '{ print $1 "." $2 }'` -fi - -####################################################################### -# Master "Core Components" macros for getting the OS target # -####################################################################### - -# -# Note: OS_TARGET should be specified on the command line for gmake. -# When OS_TARGET=WIN95 is specified, then a Windows 95 target is built. -# The difference between the Win95 target and the WinNT target is that -# the WinNT target uses Windows NT specific features not available -# in Windows 95. The Win95 target will run on Windows NT, but (supposedly) -# at lesser performance (the Win95 target uses threads; the WinNT target -# uses fibers). -# -# When OS_TARGET=WIN16 is specified, then a Windows 3.11 (16bit) target -# is built. See: win16_3.11.mk for lots more about the Win16 target. -# -# If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no -# cross-compilation. -# - -# -# The following hack allows one to build on a WIN95 machine (as if -# s/he were cross-compiling on a WINNT host for a WIN95 target). -# It also accomodates for MKS's uname.exe. If you never intend -# to do development on a WIN95 machine, you don't need this hack. -# -case "$OS_ARCH" in -WIN95) - OS_ARCH=WINNT - OS_TARGET=WIN95 - ;; -Windows_95) - OS_ARCH=Windows_NT - OS_TARGET=WIN95 - ;; -Windows_98) - OS_ARCH=Windows_NT - OS_TARGET=WIN95 - ;; -CYGWIN_9*|CYGWIN_ME*) - OS_ARCH='CYGWIN_NT-4.0' - OS_TARGET=WIN95 - ;; -OS_2) - OS_ARCH=OS2 - OS_TARGET=OS2 - ;; -WINCE) - OS_ARCH=WINCE - OS_TARGET=WINCE - ;; -esac - -# -# On WIN32, we also define the variable CPU_ARCH. -# - -case "$OS_ARCH" in -WINNT) - CPU_ARCH=`uname -p` - if test "$CPU_ARCH" = "I386"; then - CPU_ARCH=x86 - fi - ;; -Windows_NT) -# -# If uname -s returns "Windows_NT", we assume that we are using -# the uname.exe in MKS toolkit. -# -# The -r option of MKS uname only returns the major version number. -# So we need to use its -v option to get the minor version number. -# Moreover, it doesn't have the -p option, so we need to use uname -m. -# - OS_ARCH=WINNT - OS_MINOR_RELEASE=`uname -v` - if test "$OS_MINOR_RELEASE" = "00"; then - OS_MINOR_RELEASE=0 - fi - OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}" - CPU_ARCH=`uname -m` - # - # MKS's uname -m returns "586" on a Pentium machine. - # - if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then - CPU_ARCH=x86 - fi - ;; -CYGWIN32_NT|CYGWIN_NT*|MINGW*_NT*) -# -# If uname -s returns "CYGWIN_NT-4.0", we assume that we are using -# the uname.exe in the Cygwin tools. -# Prior to the Beta 20 release, Cygwin was called GNU-Win32. -# If uname -s returns "CYGWIN32/NT", we assume that we are using -# the uname.exe in the GNU-Win32 tools. -# If uname -s returns MINGW32_NT-5.1, we assume that we are using -# the uname.exe in the MSYS tools. -# - OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'` - OS_ARCH=WINNT - CPU_ARCH=`uname -m` - # - # Cygwin's uname -m returns "i686" on a Pentium Pro machine. - # - if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then - CPU_ARCH=x86 - fi - ;; -esac - -if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then - OS_TARGET=WIN95 - if test -n "$MOZ_DEBUG"; then - USE_DEBUG_RTL=1 - fi -fi -if test -z "$OS_TARGET"; then - OS_TARGET=$OS_ARCH -fi -if test "$OS_TARGET" = "WIN95"; then - OS_RELEASE="4.0" -fi -if test "$OS_TARGET" = "WIN16"; then - OS_RELEASE= -fi - -# Check whether --with-macos-sdk or --without-macos-sdk was given. -if test "${with_macos_sdk+set}" = set; then - withval="$with_macos_sdk" - MACOS_SDK_DIR=$withval -fi - - - -# Check whether --enable-os2-high-mem or --disable-os2-high-mem was given. -if test "${enable_os2_high_mem+set}" = set; then - enableval="$enable_os2_high_mem" - if test "$enableval" = "yes"; then - MOZ_OS2_HIGH_MEMORY=1 - else - MOZ_OS2_HIGH_MEMORY= - fi -fi - - -case "$host" in -*-mingw*) - NSINSTALL=nsinstall - WIN_TOP_SRC=`cd $srcdir && pwd -W` - ;; -*-cygwin*|*-msvc*|*-mks*) - CYGWIN_WRAPPER='sh $(topsrcdir)/config/cygwin-wrapper' - NSINSTALL='$(CYGWIN_WRAPPER) nsinstall' - if test "`${PERL} -v | grep -c cygwin 2>/dev/null`" = 0; then - PERL='$(CYGWIN_WRAPPER) perl' - fi - WIN_TOP_SRC=`cygpath -w $srcdir | sed -e 's|\\\\|/|g'` - ;; -*-beos*) - HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE" - ;; -*os2*) - ;; -*) - HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX" - ;; -esac - -DEFAULT_RPATHFLAG=..:../lib:../../lib:../../../lib:../../../../lib -# Check whether --with-rpath or --without-rpath was given. -if test "${with_rpath+set}" = set; then - withval="$with_rpath" - - if test "$withval" = "yes" ; then # set default - RPATHFLAG="$DEFAULT_RPATHFLAG" - elif test -n "$withval" ; then # user supplied - RPATHFLAG="$withval" - fi - -fi - - -case "$target" in - -*-aix*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define AIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define SYSV 1 -EOF - - DSO_LDOPTS='-brtl -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib' - ac_safe=`echo "sys/atomic_op.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for sys/atomic_op.h""... $ac_c" 1>&6 -echo "configure:3892: checking for sys/atomic_op.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 3897 "configure" -#include "confdefs.h" -#include <sys/atomic_op.h> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3902: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define AIX_HAVE_ATOMIC_OP_H 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi - - case "${target_os}" in - aix3.2*) - cat >> confdefs.h <<\EOF -#define AIX_RENAME_SELECT 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_NO_LARGE_FILES 1 -EOF - - ;; - aix4.1*) - cat >> confdefs.h <<\EOF -#define AIX_TIMERS 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_NO_LARGE_FILES 1 -EOF - - cat >> confdefs.h <<\EOF -#define AIX4_1 1 -EOF - - MKSHLIB= - DSO_LDOPTS= - ;; - aix4.2*) - cat >> confdefs.h <<\EOF -#define AIX_TIMERS 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_OFF64_T 1 -EOF - - ;; - aix4.3*) - cat >> confdefs.h <<\EOF -#define AIX_TIMERS 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_OFF64_T 1 -EOF - - cat >> confdefs.h <<\EOF -#define AIX4_3 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_SOCKLEN_T 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_FCNTL_FILE_LOCKING 1 -EOF - - USE_IPV6=1 - ;; - *) - cat >> confdefs.h <<\EOF -#define AIX_TIMERS 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_OFF64_T 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_SOCKLEN_T 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_FCNTL_FILE_LOCKING 1 -EOF - - USE_IPV6=1 - ;; - esac - CFLAGS="$CFLAGS -qro -qroconst" - if echo "$CC" | grep -c xlC_r; then - CFLAGS="$CFLAGS -qarch=com" - fi - AIX_WRAP='$(DIST)/lib/aixwrap.o' - AIX_TMP='./_aix_tmp.o' - if test -n "$USE_64"; then - OBJECT_MODE=64 - fi - RESOLVE_LINK_SYMBOLS=1 - ;; - -*-beos*) - cat >> confdefs.h <<\EOF -#define XP_BEOS 1 -EOF - - cat >> confdefs.h <<\EOF -#define BeOS 1 -EOF - - cat >> confdefs.h <<\EOF -#define BEOS 1 -EOF - - cat >> confdefs.h <<\EOF -#define _POSIX_SOURCE 1 -EOF - - DSO_LDOPTS=-nostart - USE_BTHREADS=1 - RESOLVE_LINK_SYMBOLS=1 - case "${target_cpu}" in - i*86) - _OPTIMIZE_FLAGS=-O2 - _DEBUG_FLAGS='-gdwarf-2 -O0' - MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@' - echo $ac_n "checking for gethostbyaddr in -lbind""... $ac_c" 1>&6 -echo "configure:4044: checking for gethostbyaddr in -lbind" >&5 -ac_lib_var=`echo bind'_'gethostbyaddr | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lbind $LIBS" -cat > conftest.$ac_ext <<EOF -#line 4052 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char gethostbyaddr(); - -int main() { -gethostbyaddr() -; return 0; } -EOF -if { (eval echo configure:4063: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - OS_LIBS="$OS_LIBS -lbind -lsocket" -else - echo "$ac_t""no" 1>&6 -fi - - ;; - powerpc) - CC=mwcc - CCC=mwcc - LD=mwld - DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o' - _OPTIMIZE_FLAGS=-O2 - _DEBUG_FLAGS='-g -O0' - ;; - esac - ;; - -*-bsdi*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define BSDI 1 -EOF - - cat >> confdefs.h <<\EOF -#define NEED_BSDREGEX 1 -EOF - - - CFLAGS="$CFLAGS -Wall -Wno-format" - CXXFLAGS="$CXXFLAGS -Wall -Wno-format" - - if echo "$OS_TEST" | grep -c 86 >/dev/null; then - CPU_ARCH=x86 - elif echo "$OS_TEST" | grep -c sparc >/dev/null; then - CPU_ARCH=sparc - fi - - DSO_LDOPTS=-r - - case "$target_os" in - bsdi1.1*) - cat >> confdefs.h <<\EOF -#define _PR_BSDI_JMPBUF_IS_ARRAY 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_STAT_HAS_ONLY_ST_ATIME 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_NEED_H_ERRNO 1 -EOF - - MKSHLIB= - DSO_CFLAGS= - DSO_LDOPTS= - ;; - - bsdi2.1*) - cat >> confdefs.h <<\EOF -#define _PR_TIMESPEC_HAS_TS_SEC 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_BSDI_JMPBUF_IS_ARRAY 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_DLL 1 -EOF - - cat >> confdefs.h <<\EOF -#define USE_DLFCN 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_STAT_HAS_ST_ATIMESPEC 1 -EOF - - ;; - - bsdi4.*) - cat >> confdefs.h <<\EOF -#define _PR_SELECT_CONST_TIMEVAL 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_BSDI_JMPBUF_IS_STRUCT 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_DLL 1 -EOF - - cat >> confdefs.h <<\EOF -#define USE_DLFCN 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_STAT_HAS_ST_ATIMESPEC 1 -EOF - - MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)' - DSO_CFLAGS=-fPIC - DSO_LDOPTS='-shared -soname $(@:$(OBJDIR)/%.so=%.so)' - STRIP="$STRIP -d" - case "$target_os" in - bsdi4.2*) - cat >> confdefs.h <<\EOF -#define _PR_HAVE_GETPROTO_R 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_GETPROTO_R_POINTER 1 -EOF - - ;; - esac - ;; - *) - cat >> confdefs.h <<\EOF -#define _PR_SELECT_CONST_TIMEVAL 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_BSDI_JMPBUF_IS_STRUCT 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_DLL 1 -EOF - - cat >> confdefs.h <<\EOF -#define USE_DLFCN 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_STAT_HAS_ST_ATIMESPEC 1 -EOF - - ;; - esac - - ;; - -*-darwin*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define DARWIN 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_BSD_FLOCK 1 -EOF - - CFLAGS="$CFLAGS -Wmost -fno-common" - case "${target_cpu}" in - i*86*) - cat >> confdefs.h <<\EOF -#define i386 1 -EOF - - CPU_ARCH=i386 - ;; - *) - cat >> confdefs.h <<\EOF -#define ppc 1 -EOF - - CPU_ARCH=ppc - ;; - esac - DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@' - # Use the standard preprocessor (cpp) - CFLAGS="$CFLAGS -no-cpp-precomp" - MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' - STRIP="$STRIP -x -S" - DLL_SUFFIX=dylib - USE_PTHREADS=1 - - - if test "$MACOS_SDK_DIR"; then - if test ! -d "$MACOS_SDK_DIR"; then - { echo "configure: error: SDK not found. When using --with-macos-sdk, you must -specify a valid SDK. SDKs are installed when the optional cross-development -tools are selected during the Xcode/Developer Tools installation." 1>&2; exit 1; } - fi - - - CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'` - GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'` - GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'` - - GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'` - if test "$GCC_VERSION_MAJOR" -lt "4" ; then - SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks" - if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then - SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks" - fi - - SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}" - - CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}" - - CPP="$CPP -nostdinc ${SDK_C_INCLUDE}" - - MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}" - LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS" - DSO_LDOPTS="${MACOS_SDK_LIBS} $DSO_LDOPTS" - export NEXT_ROOT=$MACOS_SDK_DIR - - if test -n "$CROSS_COMPILE" ; then - HOST_CC="NEXT_ROOT= $HOST_CC" - HOST_CXX="NEXT_ROOT= $HOST_CXX" - fi - else - CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}" - - CPP="$CPP -isysroot ${MACOS_SDK_DIR}" - - if test "$GCC_VERSION_FULL" != "4.0.0" ; then - LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}" - DSO_LDOPTS="$DSO_LDOPTS -isysroot ${MACOS_SDK_DIR}" - else - LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}" - DSO_LDOPTS="$DSO_LDOPTS -Wl,-syslibroot,${MACOS_SDK_DIR}" - fi - fi - fi - ;; - -*-dgux*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_LOCAL_THREADS_ONLY 1 -EOF - - cat >> confdefs.h <<\EOF -#define SVR4 1 -EOF - - cat >> confdefs.h <<\EOF -#define SYSV 1 -EOF - - cat >> confdefs.h <<\EOF -#define DGUX 1 -EOF - - cat >> confdefs.h <<\EOF -#define _DGUX_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define _POSIX4A_DRAFT6_SOURCE 1 -EOF - - DSO_LDOPTS=-G - _OPTIMIZE_FLAGS=-O2 - _DEBUG_FLAGS= - ;; - -*-freebsd*) - if test -z "$USE_NSPR_THREADS"; then - USE_PTHREADS=1 - fi - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define FREEBSD 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_BSD_FLOCK 1 -EOF - - CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall" - MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` - if test "$MOZ_OBJFORMAT" = "elf"; then - DLL_SUFFIX=so - else - DLL_SUFFIX=so.1.0 - fi - DSO_CFLAGS=-fPIC - DSO_LDOPTS=-Bshareable - ;; - -*-hpux*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define HPUX 1 -EOF - - cat >> confdefs.h <<\EOF -#define _HPUX_SOURCE 1 -EOF - - if test "$OS_TEST" = "ia64" ; then - cat >> confdefs.h <<\EOF -#define ia64 1 -EOF - - DLL_SUFFIX=so - else - cat >> confdefs.h <<\EOF -#define hppa 1 -EOF - - DLL_SUFFIX=sl - fi - DSO_LDOPTS='-b +h $(notdir $@)' - if test -z "$GNU_CC"; then - CC="$CC -Ae" - CXX="$CXX -ext" - if test "$OS_RELEASE" = "B.11.23"; then - CFLAGS="$CFLAGS +Olit=all" - CXXFLAGS="$CXXFLAGS +Olit=all" - else - CFLAGS="$CFLAGS +ESlit" - CXXFLAGS="$CXXFLAGS +ESlit" - fi - DSO_CFLAGS=+Z - else - DSO_CFLAGS=-fPIC - fi - - if test -n "$MOZILLA_CLIENT"; then - DEFAULT_IMPL_STRATEGY=_EMU - fi - - if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then - cat >> confdefs.h <<\EOF -#define _PR_NEED_H_ERRNO 1 -EOF - - cat >> confdefs.h <<\EOF -#define HPUX9 1 -EOF - - DEFAULT_IMPL_STRATEGY=_EMU - USE_NSPR_THREADS=1 - fi - - if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then - cat >> confdefs.h <<\EOF -#define _PR_NO_LARGE_FILES 1 -EOF - - fi - - if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then - cat >> confdefs.h <<\EOF -#define _PR_NEED_H_ERRNO 1 -EOF - - fi - - if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then - cat >> confdefs.h <<\EOF -#define HAVE_INT_LOCALTIME_R 1 -EOF - - fi - - if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00|B.11.11|B.11.23)' >/dev/null; then - cat >> confdefs.h <<\EOF -#define HAVE_POINTER_LOCALTIME_R 1 -EOF - - fi - - if test "$OS_RELEASE" = "B.10.01"; then - cat >> confdefs.h <<\EOF -#define HPUX10 1 -EOF - - DEFAULT_IMPL_STRATEGY=_EMU - fi - - if test "$OS_RELEASE" = "B.10.10"; then - cat >> confdefs.h <<\EOF -#define HPUX10 1 -EOF - - cat >> confdefs.h <<\EOF -#define HPUX10_10 1 -EOF - - DEFAULT_IMPL_STRATEGY=_PTH - fi - - if test "$OS_RELEASE" = "B.10.20"; then - cat >> confdefs.h <<\EOF -#define HPUX10 1 -EOF - - cat >> confdefs.h <<\EOF -#define HPUX10_20 1 -EOF - - if test -z "$GNU_CC"; then - CFLAGS="$CFLAGS +DAportable +DS1.1" - CXXFLAGS="$CXXFLAGS +DAportable +DS1.1" - fi - DEFAULT_IMPL_STRATEGY=_PTH - fi - - if test "$OS_RELEASE" = "B.10.30"; then - cat >> confdefs.h <<\EOF -#define HPUX10 1 -EOF - - cat >> confdefs.h <<\EOF -#define HPUX10_30 1 -EOF - - if test -z "$GNU_CC"; then - CFLAGS="$CFLAGS +DAportable +DS1.1" - CXXFLAGS="$CXXFLAGS +DAportable +DS1.1" - fi - DEFAULT_IMPL_STRATEGY=_PTH - fi - - if echo "$OS_RELEASE" | egrep '^(B.11.00|B.11.11)' >/dev/null; then - cat >> confdefs.h <<\EOF -#define HPUX10 1 -EOF - - cat >> confdefs.h <<\EOF -#define HPUX11 1 -EOF - - cat >> confdefs.h <<\EOF -#define _LARGEFILE64_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_OFF64_T 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_FCNTL_FILE_LOCKING 1 -EOF - - if test -z "$GNU_CC"; then - if test -z "$USE_64"; then - CFLAGS="$CFLAGS +DAportable +DS2.0" - CXXFLAGS="$CXXFLAGS +DAportable +DS2.0" - else - CFLAGS="$CFLAGS +DA2.0W +DS2.0" - CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0" - fi - fi - DEFAULT_IMPL_STRATEGY=_PTH - fi - - if test "$OS_RELEASE" = "B.11.23"; then - cat >> confdefs.h <<\EOF -#define HPUX10 1 -EOF - - cat >> confdefs.h <<\EOF -#define HPUX11 1 -EOF - - cat >> confdefs.h <<\EOF -#define _LARGEFILE64_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_OFF64_T 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_FCNTL_FILE_LOCKING 1 -EOF - - if test -z "$GNU_CC"; then - if test -z "$USE_64"; then - CFLAGS="$CFLAGS +DD32" - CXXFLAGS="$CXXFLAGS +DD32" - else - CFLAGS="$CFLAGS +DD64" - CXXFLAGS="$CXXFLAGS +DD64" - fi - fi - DEFAULT_IMPL_STRATEGY=_PTH - fi - - if test "$DEFAULT_RPATHFLAG" = "$RPATHFLAG" ; then - if test "$OS_RELEASE" = "B.11.23" -o "$OS_RELEASE" = "B.11.11" ; then - # add ORIGIN to default rpath - RPATHFLAG="\\\$\$ORIGIN/../lib:\\\$\$ORIGIN/../../lib:$RPATHFLAG" - fi - fi - - if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then - USE_NSPR_THREADS=1 - USE_PTHREADS= - USE_USER_THREADS= - elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then - USE_PTHREADS=1 - if test "$USE_NSPR_THREADS"; then - USE_PTHREADS= - fi - if test "$USE_USER_PTHREADS"; then - USE_PTHREADS= - fi - fi - - ;; - -*-irix*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define IRIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define SVR4 1 -EOF - - cat >> confdefs.h <<\EOF -#define _SGI_MP_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_FCNTL_FILE_LOCKING 1 -EOF - - DSO_LDOPTS='-rdata_shared -shared' - MKSHLIB='$(LD) $(DSO_LDOPTS) -soname $(notdir $@) -o $@' - STRIP="$STRIP -f" - RESOLVE_LINK_SYMBOLS=1 - case "${target_os}" in - irix6*) - cat >> confdefs.h <<\EOF -#define IRIX6 1 -EOF - - USE_PTHREADS=1 - USE_N32=1 - ;; - irix5*) - cat >> confdefs.h <<\EOF -#define IRIX5 1 -EOF - - USE_NSPR_THREADS=1 - ;; - *) - USE_PTHREADS=1 - USE_N32=1 - ;; - esac - if test "$GNU_CC"; then - AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)' - CFLAGS="$CFLAGS -Wall -Wno-format" - _OPTIMIZE_FLAGS="-O6" - else - if test -n "$USE_N32"; then - AS='as -D_ASM $(INCLUDES) -n32' - else - AS='as -D_ASM $(INCLUDES)' - fi - CFLAGS="$CFLAGS -fullwarn -xansi" - if test "$USE_N32"; then - _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000" - else - _OPTIMIZE_FLAGS="-O -Olimit 4000" - fi - if test "$USE_MDUPDATE"; then - CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" - fi - case "$target}" in - *-irix6.*) - CFLAGS="$CFLAGS -multigot" - DSO_LDOPTS="$DSO_LDOPTS -no_unresolved" - if test "$USE_N32"; then - CFLAGS="$CFLAGS -n32 -woff 1209" - DSO_LDOPTS="$DSO_LDOPTS -n32" - else - if test "$USE_64"; then - CFLAGS="$CFLAGS -64" - else - CFLAGS="$CFLAGS -32" - fi - fi - ;; - *) - CFLAGS="$CFLAGS -xgot" - ;; - esac - fi - if test "${target_os}" = "irix5.3"; then - cat >> confdefs.h <<\EOF -#define IRIX5_3 1 -EOF - - fi - case "${target_os}" in - irix6.5) - if test -z "$GNU_CC"; then - CFLAGS="$CFLAGS -mips3" - fi - cat >> confdefs.h <<\EOF -#define _PR_HAVE_GETPROTO_R 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_GETPROTO_R_POINTER 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_SGI_PRDA_PROCMASK 1 -EOF - - ;; - irix5*) - ;; - *) - cat >> confdefs.h <<\EOF -#define _PR_HAVE_SGI_PRDA_PROCMASK 1 -EOF - - ;; - esac - ;; - -*-linux*) - if test -z "$USE_NSPR_THREADS"; then - USE_PTHREADS=1 - fi - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define _POSIX_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define _BSD_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define _SVID_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define _LARGEFILE64_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_FCNTL_FILE_LOCKING 1 -EOF - - cat >> confdefs.h <<\EOF -#define LINUX 1 -EOF - - cat >> confdefs.h <<\EOF -#define linux 1 -EOF - - LD='$(CC)' - CFLAGS="$CFLAGS -ansi -Wall" - CXXFLAGS="$CXXFLAGS -ansi -Wall" - MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' - DSO_CFLAGS=-fPIC - DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' - OS_LIBS="$OS_LIBS -lc" - _OPTIMIZE_FLAGS=-O2 - _DEBUG_FLAGS="-g -fno-inline" # most people on linux use gcc/gdb, and that - # combo is not yet good at debugging inlined - # functions (even when using DWARF2 as the - # debugging format) - if echo "$OS_TEST" | grep -c 86 >/dev/null; then - CPU_ARCH=x86 - else - CPU_ARCH=$OS_TEST - fi - case "${target_cpu}" in - alpha) - cat >> confdefs.h <<\EOF -#define _ALPHA_ 1 -EOF - - cat >> confdefs.h <<\EOF -#define __alpha 1 -EOF - - CFLAGS="$CFLAGS -mieee" - CXXFLAGS="$CXXFLAGS -mieee" - ;; - i*86) - cat >> confdefs.h <<\EOF -#define i386 1 -EOF - - ;; - ia64) - ;; - m68k) - CFLAGS="$CFLAGS -m68020-40" - CXXFLAGS="$CXXFLAGS -m68020-40" - # - # gcc on Linux/m68k either has a bug or triggers a code-sequence - # bug in the 68060 which causes gcc to crash. The simplest way to - # avoid this is to enable a minimum level of optimization. - # - _DEBUG_FLAGS="$_DEBUG_FLAGS -O" - ;; - esac - ;; - -*-mingw*|*-cygwin*|*-msvc*|*-mks*) - cat >> confdefs.h <<\EOF -#define XP_PC 1 -EOF - - cat >> confdefs.h <<\EOF -#define WIN32 1 -EOF - - cat >> confdefs.h <<\EOF -#define _WINDOWS 1 -EOF - - RESOLVE_LINK_SYMBOLS=1 - PROG_SUFFIX=.exe - if test -n "$GNU_CC"; then - CC="$CC -mno-cygwin" - CXX="$CXX -mno-cygwin" - DLL_SUFFIX=dll - MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) -o $@' - # Use temp file for windres (bug 213281) - RC="$WINDRES -O coff --use-temp-file" - else - CYGWIN_WRAPPER='sh $(topsrcdir)/config/cygwin-wrapper' - CC=cl - CXX=cl - LD=link - # if the lib program is available, use it, otherwise use link /lib - # Extract the first word of "lib", so it can be a program name with args. -set dummy lib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4842: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_HAVE_MSVC_LIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$HAVE_MSVC_LIB"; then - ac_cv_prog_HAVE_MSVC_LIB="$HAVE_MSVC_LIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_HAVE_MSVC_LIB="1" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -HAVE_MSVC_LIB="$ac_cv_prog_HAVE_MSVC_LIB" -if test -n "$HAVE_MSVC_LIB"; then - echo "$ac_t""$HAVE_MSVC_LIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test "$HAVE_MSVC_LIB" = "1" ; then - AR='lib -NOLOGO -OUT:"$@"' - else - AR='$(LD) /lib -NOLOGO -OUT:"$@"' - fi - - AR_FLAGS= - RANLIB='echo not_ranlib' - STRIP='echo not_strip' - RC='$(CYGWIN_WRAPPER) rc.exe' - GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb' - OBJ_SUFFIX=obj - LIB_SUFFIX=lib - LIB_PREFIX= - DLL_SUFFIX=dll - - CFLAGS="$CFLAGS -W3 -nologo -GF -Gy" - DLLFLAGS='-OUT:"$@"' - _DEBUG_FLAGS=-Z7 - _OPTIMIZE_FLAGS=-O2 - if test -z "$MOZ_OPTIMIZE"; then - CFLAGS="$CFLAGS -Od" - fi - - if test -n "$USE_DEBUG_RTL"; then - CFLAGS="$CFLAGS -MDd" - else - CFLAGS="$CFLAGS -MD" - fi - - if test -n "$MOZ_DEBUG"; then - cat >> confdefs.h <<\EOF -#define _DEBUG 1 -EOF - - else - DEFINES="$DEFINES -U_DEBUG" - fi - - if test -n "$MOZ_OPTIMIZE"; then - if test -n "$MOZ_PROFILE"; then - _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Z7" - fi - if test -n "$MOZ_DEBUG_SYMBOLS"; then - _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Zi" - fi - if test -n "$MOZ_PROFILE" -o -n "$MOZ_DEBUG_SYMBOLS"; then - DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF" - LDFLAGS="$LDFLAGS -DEBUG -OPT:REF" - fi - fi - - if test -n "$MOZ_DEBUG"; then - DLLFLAGS="$DLLFLAGS -DEBUG" - LDFLAGS="$LDFLAGS -DEBUG" - fi - - if test "$OS_TARGET" = "WINNT"; then - CFLAGS="$CFLAGS -GT" - if test "$CPU_ARCH" = "x86"; then - CFLAGS="$CFLAGS -G5" - fi - fi - fi # GNU_CC - - if test -n "$USE_STATIC_TLS"; then - cat >> confdefs.h <<\EOF -#define _PR_USE_STATIC_TLS 1 -EOF - - fi - - if test "$OS_TARGET" = "WINNT"; then - cat >> confdefs.h <<\EOF -#define WINNT 1 -EOF - - else - cat >> confdefs.h <<\EOF -#define WIN95 1 -EOF - - # undefine WINNT as some versions of mingw gcc define it by default - DEFINES="$DEFINES -UWINNT" - cat >> confdefs.h <<\EOF -#define _PR_GLOBAL_THREADS_ONLY 1 -EOF - - fi - - OS_DLLFLAGS='-nologo -DLL -SUBSYSTEM:WINDOWS -PDB:NONE' - - case "$OS_TARGET" in - WINNT) - ;; - WIN95) - ;; - WIN16) - ;; - *) - { echo "configure: error: Missing OS_TARGET for ${target}. Use --enable-win32-target to set." 1>&2; exit 1; } - ;; - esac - - case "$target_cpu" in - i*86) - cat >> confdefs.h <<\EOF -#define _X86_ 1 -EOF - - ;; - alpha) - cat >> confdefs.h <<\EOF -#define _ALPHA_ 1 -EOF - - ;; - mips) - cat >> confdefs.h <<\EOF -#define _MIPS_ 1 -EOF - - ;; - *) - cat >> confdefs.h <<\EOF -#define _CPU_ARCH_NOT_DEFINED 1 -EOF - - ;; - esac - - ;; - -*-ncr-sysv*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define SVR4 1 -EOF - - cat >> confdefs.h <<\EOF -#define SYSV 1 -EOF - - cat >> confdefs.h <<\EOF -#define NCR 1 -EOF - - USE_NSPR_THREADS=1 - if test "$OS_RELEASE" = "2.03"; then - cat >> confdefs.h <<\EOF -#define _PR_STAT_HAS_ST_ATIM 1 -EOF - - else - cat >> confdefs.h <<\EOF -#define _PR_STAT_HAS_ST_ATIM_UNION 1 -EOF - - fi - - if test -z "$GNU_CC"; then - CFLAGS="$CFLAGS -Hnocopyr" - CXXFLAGS="$CXXFLAGS -Hnocopyr" - else - CFLAGS="$CFLAGS -fPIC -Wall" - CXXFLAGS="$CXXFLAGS -fPIC -Wall" - DSO_LDOPTS=-G - fi - ;; - -mips-nec-sysv*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define SVR4 1 -EOF - - cat >> confdefs.h <<\EOF -#define __SVR4 1 -EOF - - cat >> confdefs.h <<\EOF -#define NEC 1 -EOF - - cat >> confdefs.h <<\EOF -#define nec_ews 1 -EOF - - USE_NSPR_THREADS=1 - if test -z "$GNU_CC"; then - CC='$(NSDEPTH)/build/hcc cc -Xa -KGnum=0 -KOlimit=4000' - CXX=g++ - fi - OS_LIBS="$OS_LIBS -lsocket -lnsl -ldl" - DSO_LDOPTS=-G - ;; - -*-netbsd*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define NETBSD 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_BSD_FLOCK 1 -EOF - - USE_NSPR_THREADS=1 - - DSO_CFLAGS='-fPIC -DPIC' - CFLAGS="$CFLAGS -ansi -Wall" - CXXFLAGS="$CXXFLAGS -ansi -Wall" - MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)' - - if test -z "$OBJECT_FMT"; then - if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then - OBJECT_FMT=a.out - DLL_SUFFIX=so.1.0 - DSO_LDOPTS='-shared' - else - OBJECT_FMT=ELF - DLL_SUFFIX=so - DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)' - fi - fi - - if test "$LIBRUNPATH"; then - DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH" - fi - ;; - -mips-sony-newsos*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define SONY 1 -EOF - - cat >> confdefs.h <<\EOF -#define SYSV 1 -EOF - - cat >> confdefs.h <<\EOF -#define SVR4 1 -EOF - - cat >> confdefs.h <<\EOF -#define __svr4 1 -EOF - - cat >> confdefs.h <<\EOF -#define __svr4__ 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_SVID_GETTOD 1 -EOF - - USE_NSPR_THREADS=1 - CFLAGS="$CFLAGS -Xa -fullwarn" - CXXFLAGS="$CXXFLAGS -Xa -fullwarn" - DSO_LDOPTS=-G - ;; - -*-nextstep*|*-openstep*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define NEXTSTEP 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_BSD_FLOCK 1 -EOF - - cat >> confdefs.h <<\EOF -#define _POSIX_SOURCE 1 -EOF - - CFLAGS="$CFLAGS -Wall -fno-common -traditional-cpp -posix" - CXXFLAGS="$CXXFLAGS -Wall -fno-common -traditional-cpp -posix" - USE_NSPR_THREADS=1 - DLL_SUFFIX=dylib - ;; - - -*-nto*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define NTO 1 -EOF - - cat >> confdefs.h <<\EOF -#define _QNX_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_POINTER_LOCALTIME_R 1 -EOF - - MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@' - DSO_CFLAGS=-fPIC - DSO_LDOPTS=-shared - OS_LIBS="$OS_LIBS -lsocket" - _OPTIMIZE_FLAGS="-O1" - _DEBUG_FLAGS="-gstabs" - ;; - -*-openbsd*) - LD='$(CC)' - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define OPENBSD 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_BSD_FLOCK 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_SOCKLEN_T 1 -EOF - - CFLAGS="$CFLAGS -ansi -Wall" - CXXFLAGS="$CXXFLAGS -ansi -Wall" - DLL_SUFFIX=so.1.0 - DSO_CFLAGS=-fPIC - USE_NSPR_THREADS=1 - DSO_LDOPTS='-shared -fPIC' - ;; - -*-openvms*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - RESOLVE_LINK_SYMBOLS=1 - AR_FLAGS='c $@' - DSO_LDOPTS='-shared -auto_symvec $(LDFLAGS) $(OPTIMIZER)' - ;; - -*-os2*) - cat >> confdefs.h <<\EOF -#define XP_OS2 1 -EOF - - cat >> confdefs.h <<\EOF -#define XP_PC 1 -EOF - - cat >> confdefs.h <<\EOF -#define BSD_SELECT 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_GLOBAL_THREADS_ONLY 1 -EOF - - RESOLVE_LINK_SYMBOLS=1 - NSINSTALL=nsinstall - LIB_PREFIX= - LIB_SUFFIX=lib - DLL_SUFFIX=dll - DLLTOOL='' - RC=rc.exe - PROG_SUFFIX=.exe - - # EMX/GCC build - if test -n "$GNU_CC"; then -# AC_DEFINE(USE_OS2_TOOLKIT_HEADERS) - cat >> confdefs.h <<\EOF -#define XP_OS2_EMX 1 -EOF - - cat >> confdefs.h <<\EOF -#define OS2 1 -EOF - - cat >> confdefs.h <<\EOF -#define TCPV40HDRS 1 -EOF - - AR=emxomfar - AR_FLAGS='r $@' - LD='$(CC)' - CFLAGS="$CFLAGS -Wall -Zomf" - CXXFLAGS="$CFLAGS -Wall -Zomf" - MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' - DSO_CFLAGS= - DSO_LDOPTS='-Zomf -Zdll' - _OPTIMIZE_FLAGS=-O3 - _DEBUG_FLAGS="-g -fno-inline" - if test -n "$MOZ_OPTIMIZE"; then - DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA" - fi - OS_LIBS="-lsocket" - IMPLIB='emximp -o' - FILTER='emxexp -o' - if test -n "$MOZ_OS2_HIGH_MEMORY"; then - DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem" - LDFLAGS="$LDFLAGS -Zhigh-mem" - cat >> confdefs.h <<\EOF -#define MOZ_OS2_HIGH_MEMORY 1 -EOF - - fi - - # GCC for OS/2 currently predefines these, but we don't want them - DEFINES="$DEFINES -Uunix -U__unix -U__unix__" - - # Visual Age C++ build - elif test "$VACPP" = "yes"; then - MOZ_BUILD_ROOT=`pwd -D` - cat >> confdefs.h <<\EOF -#define XP_OS2_VACPP 1 -EOF - - cat >> confdefs.h <<\EOF -#define OS2 4 -EOF - - cat >> confdefs.h <<\EOF -#define TCPV40HDRS 1 -EOF - - cat >> confdefs.h <<\EOF -#define _X86_ 1 -EOF - - OBJ_SUFFIX=obj - AS=alp - ASFLAGS='-Mb' - ASM_SUFFIX=asm - AR=ilib - AR_FLAGS='/NOL /NOI /O:$(subst /,\\,$@)' - CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' - HOST_CFLAGS="$CFLAGS" - OS_CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' - OS_EXE_CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' - CXXFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' - OS_LIBS='so32dll.lib tcp32dll.lib' - LD='-ilink' - MKSHLIB='$(LD) $(DSO_LDOPTS)' - IMPLIB='implib -nologo -noignorecase' - FILTER='cppfilt -q -B -P' - _OPTIMIZE_FLAGS='/O+ /Gl+ /Gx+ /qtune=pentium /qarch=pentium' - _DEBUG_FLAGS='/Ti+ ' - LDFLAGS='/NOL /M /L' - DLLFLAGS='/O:$@ /DLL /INC:_dllentry /MAP:$(@:.dll=.map) /L /NOL' - EXEFLAGS='/OUT:$@ /PMTYPE:VIO /MAP:$(@:.exe=.map) /L /NOL' - if test -n "$MOZ_DEBUG"; then - LDFLAGS="$LDFLAGS /DE" - DLLFLAGS="$DLLFLAGS /DE" - EXEFLAGS="$EXEFLAGS /DE" - fi - if test -n "$MOZ_OPTIMIZE"; then - LDFLAGS="$LDFLAGS /OPTFUNC /EXEPACK:2 /PACKCODE /PACKDATA" - DLLFLAGS="$DLLFLAGS /OPTFUNC /EXEPACK:2 /PACKCODE /PACKDATA" - EXEFLAGS="$EXEFLAGS /OPTFUNC /EXEPACK:2 /PACKCODE /PACKDATA" - fi - fi - ;; - -*-osf*) - SHELL_OVERRIDE="SHELL = /usr/bin/ksh" - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define OSF1 1 -EOF - - cat >> confdefs.h <<\EOF -#define _REENTRANT 1 -EOF - - ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6 -echo "configure:5366: checking for machine/builtins.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 5371 "configure" -#include "confdefs.h" -#include <machine/builtins.h> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5376: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define OSF1_HAVE_MACHINE_BUILTINS_H 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi - - - if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then - USE_NSPR_THREADS=1 - fi - - if test -z "$GNU_CC"; then - CC="$CC -std1 -ieee_with_inexact" - if test "$OS_RELEASE" != "V2.0"; then - CC="$CC -readonly_strings" - fi - _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000" - fi - - if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then - cat >> confdefs.h <<\EOF -#define HAVE_INT_LOCALTIME_R 1 -EOF - - else - cat >> confdefs.h <<\EOF -#define HAVE_FCNTL_FILE_LOCKING 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_POINTER_LOCALTIME_R 1 -EOF - - fi - if echo $OS_RELEASE | grep -c V4.0 >/dev/null; then - cat >> confdefs.h <<\EOF -#define OSF1V4_MAP_PRIVATE_BUG 1 -EOF - - fi - DSO_LDOPTS='-shared -all -expect_unresolved "*" -soname $(notdir $@)' - ;; - -*-qnx*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define QNX 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_NEED_H_ERRNO 1 -EOF - - USE_NSPR_THREADS=1 - ;; - -*-*-sco*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define SCO 1 -EOF - - cat >> confdefs.h <<\EOF -#define sco 1 -EOF - - cat >> confdefs.h <<\EOF -#define SYSV 1 -EOF - - cat >> confdefs.h <<\EOF -#define _SVID3 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_NEED_H_ERRNO 1 -EOF - - CC='cc -b elf -KPIC' - CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w' - USE_NSPR_THREADS=1 - CPU_ARCH=x86 - DSO_LDOPTS='-b elf -G' - ;; - -*-sinix*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define SVR4 1 -EOF - - cat >> confdefs.h <<\EOF -#define SNI 1 -EOF - - cat >> confdefs.h <<\EOF -#define RELIANTUNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define sinix 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_SVID_GETTOD 1 -EOF - - if echo "$OS_TEST" | grep -c 86 2>/dev/null; then - cat >> confdefs.h <<\EOF -#define i386 1 -EOF - - CPU_ARCH=x86 - else - CPU_ARCH=mips - fi - - if test "$GNU_CC"; then - AS='$(CC) -x assembler-with-cpp' - if test "$CPU_ARCH" = "mips"; then - LD=gld - fi - CFLAGS="$CFLAGS -Wall -Wno-format" - else - AS='/usr/bin/cc' - _OPTIMIZE_FLAGS='-O -F Olimit,4000' - fi - - DSO_LDOPTS='-G -z defs -h $(@:$(OBJDIR)/%.so=%.so)' - - if test "$OS_RELEASE" = "5.43"; then - cat >> confdefs.h <<\EOF -#define IP_MULTICAST 1 -EOF - - fi - - OS_LIBS="$OS_LIBS -lsocket -lnsl -lresolv -ldl -lc" - USE_NSPR_THREADS=1 - ;; - -*-sunos*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define SUNOS4 1 -EOF - - CFLAGS="$CFLAGS -Wall -Wno-format" - if test "$USE_MDUPDATE"; then - CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" - fi - CPU_ARCH=sparc - DLL_SUFFIX=so.1.0 - DSO_LDOPTS= - DSO_CFLAGS=-fPIC - USE_NSPR_THREADS=1 - if test "$OS_RELEASE" = "4.1.3_U1"; then - _OPTIMIZE_FLAGS= - OS_LIBS="$OS_LIBS -lm" - fi - ;; - -*-solaris*) - if test -z "$USE_USER_THREADS" && test -z "$USE_NATIVE_THREADS"; then - USE_PTHREADS=1 - fi - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define SVR4 1 -EOF - - cat >> confdefs.h <<\EOF -#define SYSV 1 -EOF - - cat >> confdefs.h <<\EOF -#define __svr4 1 -EOF - - cat >> confdefs.h <<\EOF -#define __svr4__ 1 -EOF - - cat >> confdefs.h <<\EOF -#define SOLARIS 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_FCNTL_FILE_LOCKING 1 -EOF - - if test -n "$GNU_CC" ; then - if test -n "$USE_64"; then - CC="$CC -m64" - CXX="$CXX -m64" - fi - LD='$(CC)' - DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' - DSO_CFLAGS=-fPIC - CFLAGS="$CFLAGS -Wall" - CXXFLAGS="$CXXFLAGS -Wall" - if test -n "$USE_MDUPDATE"; then - CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" - CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)" - fi - else - LD=/usr/ccs/bin/ld - RANLIB=/usr/ccs/bin/ranlib - DSO_LDOPTS='-G -h $(notdir $@)' - DSO_CFLAGS=-KPIC - if test -n "$USE_64"; then - if test "$OS_TEST" = "i86pc"; then - CC="$CC -xarch=amd64" - CXX="$CXX -xarch=amd64" - else - CC="$CC -xarch=v9" - CXX="$CXX -xarch=v9" - fi - fi - CC="$CC -xstrconst" - if test -z "$MOZ_OPTIMIZE"; then - CFLAGS="$CFLAGS -xs" - CXXFLAGS="$CXXFLAGS -xs" - fi - fi - if test "$DEFAULT_RPATHFLAG" = "$RPATHFLAG" ; then - # add origin stuff - RPATHFLAG="\\\$\$ORIGIN/../lib:\\\$\$ORIGIN/../../lib:$RPATHFLAG" - fi - if test -z "$GNU_AS"; then - ASFLAGS="$ASFLAGS -Wa,-P" - fi - if test "$OS_TEST" = "i86pc"; then - cat >> confdefs.h <<\EOF -#define i386 1 -EOF - - - # The default debug format, DWARF (-g), is not supported by gcc - # on i386-ANY-sysv4/solaris, but the stabs format is. It is - # assumed that the Solaris assembler /usr/ccs/bin/as is used. - # If your gcc uses GNU as, you do not need the -Wa,-s option. - if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then - _DEBUG_FLAGS=-gstabs - if test -z "$GNU_AS"; then - _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s" - fi - fi - fi - case "${target_os}" in - solaris2.3*) - cat >> confdefs.h <<\EOF -#define _PR_NO_LARGE_FILES 1 -EOF - - ;; - solaris2.4*) - cat >> confdefs.h <<\EOF -#define _PR_NO_LARGE_FILES 1 -EOF - - ;; - solaris2.5*) - cat >> confdefs.h <<\EOF -#define SOLARIS2_5 1 -EOF - - ;; - *) - cat >> confdefs.h <<\EOF -#define _PR_HAVE_OFF64_T 1 -EOF - - # The lfcompile64(5) man page on Solaris 2.6 says: - # For applications that do not wish to conform to the POSIX or - # X/Open specifications, the 64-bit transitional interfaces - # are available by default. No compile-time flags need to be - # set. - # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default. - # The native compiler, gcc 2.8.x, and egcs don't have this problem. - if test -n "$GNU_CC"; then - cat >> confdefs.h <<\EOF -#define _LARGEFILE64_SOURCE 1 -EOF - - fi - ;; - esac - if test "$OS_TEST" = "sun4u"; then - # 64-bit Solaris requires SPARC V9 architecture, so the following - # is not needed. - if test -z "$USE_64"; then - ULTRASPARC_LIBRARY=ultrasparc - ULTRASPARC_FILTER_LIBRARY=libatomic.so - DSO_LDOPTS="$DSO_LDOPTS -f "'$(ULTRASPARC_FILTER_LIBRARY)' - fi - fi - ;; - -*-sco-sysv5*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - cat >> confdefs.h <<\EOF -#define UNIXWARE 1 -EOF - - cat >> confdefs.h <<\EOF -#define SVR4 1 -EOF - - cat >> confdefs.h <<\EOF -#define SYSV 1 -EOF - - USE_NSPR_THREADS=1 - if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then - cat >> confdefs.h <<\EOF -#define _PR_NO_LARGE_FILES 1 -EOF - - CC='$(NSDEPTH)/build/hcc cc' - CXX='$(NSDEPTH)/build/hcpp CC' - else - cat >> confdefs.h <<\EOF -#define _LARGEFILE64_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_OFF64_T 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_SOCKADDR_LEN 1 -EOF - - fi - DSO_LDOPTS=-G - CPU_ARCH=x86 - ;; - -*) - cat >> confdefs.h <<\EOF -#define XP_UNIX 1 -EOF - - ;; - -esac - -if test -z "$SKIP_LIBRARY_CHECKS"; then - -echo $ac_n "checking for dlopen""... $ac_c" 1>&6 -echo "configure:5763: checking for dlopen" >&5 -if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 5768 "configure" -#include "confdefs.h" -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char dlopen(); below. */ -#include <assert.h> -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_dlopen) || defined (__stub___dlopen) -choke me -#else -dlopen(); -#endif - -; return 0; } -EOF -if { (eval echo configure:5791: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_dlopen=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_dlopen=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 - - echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:5810: checking for dlopen in -ldl" >&5 -ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldl $LIBS" -cat > conftest.$ac_ext <<EOF -#line 5818 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen(); - -int main() { -dlopen() -; return 0; } -EOF -if { (eval echo configure:5829: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - OS_LIBS="-ldl $OS_LIBS" -else - echo "$ac_t""no" 1>&6 -fi - - -fi - - - - -if test $ac_cv_prog_gcc = yes; then - echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:5857: checking whether ${CC-cc} needs -traditional" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_pattern="Autoconf.*'x'" - cat > conftest.$ac_ext <<EOF -#line 5863 "configure" -#include "confdefs.h" -#include <sgtty.h> -Autoconf TIOCGETP -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "$ac_pattern" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_prog_gcc_traditional=yes -else - rm -rf conftest* - ac_cv_prog_gcc_traditional=no -fi -rm -f conftest* - - - if test $ac_cv_prog_gcc_traditional = no; then - cat > conftest.$ac_ext <<EOF -#line 5881 "configure" -#include "confdefs.h" -#include <termio.h> -Autoconf TCGETA -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "$ac_pattern" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_prog_gcc_traditional=yes -fi -rm -f conftest* - - fi -fi - -echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 - if test $ac_cv_prog_gcc_traditional = yes; then - CC="$CC -traditional" - fi -fi - -for ac_func in lchown strerror getaddrinfo getnameinfo -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5905: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 5910 "configure" -#include "confdefs.h" -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:5933: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi -done - - - - -# Check whether --enable-strip or --disable-strip was given. -if test "${enable_strip+set}" = set; then - enableval="$enable_strip" - ENABLE_STRIP=1 -fi - - - - - -echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 -echo "configure:5971: checking for pthread_create in -lpthreads" >&5 -echo " - #include <pthread.h> - void *foo(void *v) { int a = 1; } - int main() { - pthread_t t; - if (!pthread_create(&t, 0, &foo, 0)) { - pthread_join(t, 0); - } - exit(0); - }" > dummy.c ; - echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthreads $LDFLAGS $LIBS" 1>&5; - ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthreads $LDFLAGS $LIBS 2>&5; - _res=$? ; - rm -f dummy.c dummy${ac_exeext} ; - if test "$_res" = "0"; then - echo "$ac_t""yes" 1>&6 - _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads" - else - echo "$ac_t""no" 1>&6 - -echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:5993: checking for pthread_create in -lpthread" >&5 -echo " - #include <pthread.h> - void *foo(void *v) { int a = 1; } - int main() { - pthread_t t; - if (!pthread_create(&t, 0, &foo, 0)) { - pthread_join(t, 0); - } - exit(0); - }" > dummy.c ; - echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthread $LDFLAGS $LIBS" 1>&5; - ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthread $LDFLAGS $LIBS 2>&5; - _res=$? ; - rm -f dummy.c dummy${ac_exeext} ; - if test "$_res" = "0"; then - echo "$ac_t""yes" 1>&6 - _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread" - else - echo "$ac_t""no" 1>&6 - -echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:6015: checking for pthread_create in -lc_r" >&5 -echo " - #include <pthread.h> - void *foo(void *v) { int a = 1; } - int main() { - pthread_t t; - if (!pthread_create(&t, 0, &foo, 0)) { - pthread_join(t, 0); - } - exit(0); - }" > dummy.c ; - echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc_r $LDFLAGS $LIBS" 1>&5; - ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc_r $LDFLAGS $LIBS 2>&5; - _res=$? ; - rm -f dummy.c dummy${ac_exeext} ; - if test "$_res" = "0"; then - echo "$ac_t""yes" 1>&6 - _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r" - else - echo "$ac_t""no" 1>&6 - -echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6 -echo "configure:6037: checking for pthread_create in -lc" >&5 -echo " - #include <pthread.h> - void *foo(void *v) { int a = 1; } - int main() { - pthread_t t; - if (!pthread_create(&t, 0, &foo, 0)) { - pthread_join(t, 0); - } - exit(0); - }" > dummy.c ; - echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc $LDFLAGS $LIBS" 1>&5; - ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc $LDFLAGS $LIBS 2>&5; - _res=$? ; - rm -f dummy.c dummy${ac_exeext} ; - if test "$_res" = "0"; then - echo "$ac_t""yes" 1>&6 - _HAVE_PTHREADS=1 - - else - echo "$ac_t""no" 1>&6 - - fi - - - fi - - - fi - - - fi - - -# Check whether --with-pthreads or --without-pthreads was given. -if test "${with_pthreads+set}" = set; then - withval="$with_pthreads" - if test "$withval" = "yes"; then - if test -n "$_HAVE_PTHREADS"; then - USE_PTHREADS=1 - USE_USER_PTHREADS= - USE_NSPR_THREADS= - else - { echo "configure: error: --with-pthreads specified for a system without pthread support " 1>&2; exit 1; }; - fi - else - USE_PTHREADS= - _PTHREAD_LDFLAGS= - fi -else - if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USER_NSPR_THREADS"; then - USE_PTHREADS=1 - USE_USER_PTHREADS= - USE_NSPR_THREADS= - fi -fi - - -# Check whether --enable-user-pthreads or --disable-user-pthreads was given. -if test "${enable_user_pthreads+set}" = set; then - enableval="$enable_user_pthreads" - if test "$enableval" = "yes"; then - if test -n "$_HAVE_PTHREADS"; then - USE_PTHREADS= - USE_USER_PTHREADS=1 - USE_NSPR_THREADS= - else - { echo "configure: error: --enable-user-pthreads specified for a system without pthread support " 1>&2; exit 1; }; - fi - fi -fi - - -# Check whether --enable-nspr-threads or --disable-nspr-threads was given. -if test "${enable_nspr_threads+set}" = set; then - enableval="$enable_nspr_threads" - if test "$enableval" = "yes"; then - USE_PTHREADS= - USE_USER_PTHREADS= - USE_NSPR_THREADS=1 - fi -fi - - -case "$target" in -*-beos*) - # Check whether --with-bthreads or --without-bthreads was given. -if test "${with_bthreads+set}" = set; then - withval="$with_bthreads" - if test "$withval" = "yes"; then - USE_BTHREADS=1 - USE_USER_PTHREADS= - USE_PTHREADS= - fi -fi - - ;; - -*-solaris*) - # Check whether --with-native-threads or --without-native-threads was given. -if test "${with_native_threads+set}" = set; then - withval="$with_native_threads" - if test "$withval" = "yes"; then - USE_NATIVE_THREADS=1 - USE_USER_PTHREADS= - USE_PTHREADS= - fi -fi - - ;; -esac - -fi # SKIP_LIBRARY_CHECKS - -# Check whether --enable-cplus or --disable-cplus was given. -if test "${enable_cplus+set}" = set; then - enableval="$enable_cplus" - if test "$enableval" = "yes"; then - USE_CPLUS=1 - fi -fi - - -# Check whether --enable-ipv6 or --disable-ipv6 was given. -if test "${enable_ipv6+set}" = set; then - enableval="$enable_ipv6" - if test "$enableval" = "yes"; then - USE_IPV6=1 - fi -fi - - - -echo $ac_n "checking for --with-sasl""... $ac_c" 1>&6 -echo "configure:6171: checking for --with-sasl" >&5 -# Check whether --with-sasl or --without-sasl was given. -if test "${with_sasl+set}" = set; then - withval="$with_sasl" - - if test "$withval" = "yes"; then - echo "$ac_t""yes" 1>&6 - HAVE_SASL=1 - - if test -f /usr/include/sasl/sasl.h; then - SASL_CFLAGS="-I/usr/include/sasl" - elif test -f /usr/include/sasl.h; then - SASL_CFLAGS="-I/usr/include" - else - { echo "configure: error: sasl.h not found" 1>&2; exit 1; } - fi - - elif test -d "$withval" -a -d "$withval/lib" -a -d "$withval/include" ; then - echo "$ac_t""using $withval" 1>&6 - HAVE_SASL=1 - - if test -f "$withval/include/sasl/sasl.h"; then - SASL_CFLAGS="-I$withval/include/sasl" - elif test -f "$withval/include/sasl.h"; then - SASL_CFLAGS="-I$withval/include" - else - { echo "configure: error: sasl.h not found" 1>&2; exit 1; } - fi - - SASL_LIBS="-L$withval/lib" - else - echo "$ac_t""yes" 1>&6 - { echo "configure: error: sasl not found in $withval" 1>&2; exit 1; } - fi - -else - echo "$ac_t""no" 1>&6 -fi - - -echo $ac_n "checking for --with-sasl-inc""... $ac_c" 1>&6 -echo "configure:6212: checking for --with-sasl-inc" >&5 -# Check whether --with-sasl-inc or --without-sasl-inc was given. -if test "${with_sasl_inc+set}" = set; then - withval="$with_sasl_inc" - - if test -f "$withval"/sasl.h; then - echo "$ac_t""using $withval" 1>&6 - HAVE_SASL=1 - SASL_CFLAGS="-I$withval" - else - echo - { echo "configure: error: $withval/sasl.h not found" 1>&2; exit 1; } - fi - -else - echo "$ac_t""no" 1>&6 -fi - - -echo $ac_n "checking for --with-sasl-lib""... $ac_c" 1>&6 -echo "configure:6232: checking for --with-sasl-lib" >&5 -# Check whether --with-sasl-lib or --without-sasl-lib was given. -if test "${with_sasl_lib+set}" = set; then - withval="$with_sasl_lib" - - if test -d "$withval"; then - echo "$ac_t""using $withval" 1>&6 - HAVE_SASL=1 - SASL_LIBS="-L$withval" - else - echo - { echo "configure: error: $withval not found" 1>&2; exit 1; } - fi - -else - echo "$ac_t""no" 1>&6 -fi - - -# check for sasl -if test -n "$_WIN32_MSVC" -a -n "$USE_WINDOWS_PATHS" ; then - if test -n "$SASL_CFLAGS" -a -z "$SKIP_CYGWIN_FIXUP" ; then - path=`echo $SASL_CFLAGS | sed -e 's/^-I//'` - path=`cygpath -m $path` - SASL_CFLAGS="/I$path" - fi - if test -n "$SASL_LIBS" -a -z "$SKIP_CYGWIN_FIXUP" ; then - path=`echo $SASL_LIBS | sed -e 's/^-L//'` - path=`cygpath -m $path` - SASL_LIBS="/LIBPATH:$path" - fi - special_sasl_check_lib=1 -fi -# set ldflags to point to where the user told us to find the sasl libs, -# if any - otherwise it will just use the default location (e.g. /usr/lib) -# the way AC_CHECK_LIB works is it actually attempts to compile and link -# a test program - that's why we need to set LDFLAGS -SAVE_LDFLAGS=$LDFLAGS -if test -n "$SASL_LIBS" ; then - LDFLAGS="$LDFLAGS $SASL_LIBS" -fi - -echo $ac_n "checking for getaddrinfo""... $ac_c" 1>&6 -echo "configure:6275: checking for getaddrinfo" >&5 -if eval "test \"`echo '$''{'ac_cv_func_getaddrinfo'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 6280 "configure" -#include "confdefs.h" -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char getaddrinfo(); below. */ -#include <assert.h> -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char getaddrinfo(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_getaddrinfo) || defined (__stub___getaddrinfo) -choke me -#else -getaddrinfo(); -#endif - -; return 0; } -EOF -if { (eval echo configure:6303: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_getaddrinfo=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_getaddrinfo=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'getaddrinfo`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 - - echo $ac_n "checking for getaddrinfo in -lsocket""... $ac_c" 1>&6 -echo "configure:6322: checking for getaddrinfo in -lsocket" >&5 -ac_lib_var=`echo socket'_'getaddrinfo | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lsocket $LIBS" -cat > conftest.$ac_ext <<EOF -#line 6330 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char getaddrinfo(); - -int main() { -getaddrinfo() -; return 0; } -EOF -if { (eval echo configure:6341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LIBS="-lsocket -lnsl $LIBS" -else - echo "$ac_t""no" 1>&6 -fi - -fi - - -if test -n "$special_sasl_check_lib" ; then - # use this to override the ac_link LIBS used by AC_CHECK_LIB - # ac_link puts conftest.c betwen $LDFLAGS and $LIBS, but we - # have to use /LIBPATH which must come after the /link directive - # however, anything after /link on the command line is assumed to - # be a linker directive, and conftest.c is not valid there - # we want to end up with cl.exe .... conftest.c /link /LIBPATH:foo libsasl.lib - LDFLAGS= - SAVE_LIBS="$LIBS" - LIBS="/link $SASL_LIBS sasl32.lib" - echo $ac_n "checking for sasl_client_init in -lsasl32""... $ac_c" 1>&6 -echo "configure:6375: checking for sasl_client_init in -lsasl32" >&5 -ac_lib_var=`echo sasl32'_'sasl_client_init | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lsasl32 $LIBS" -cat > conftest.$ac_ext <<EOF -#line 6383 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char sasl_client_init(); - -int main() { -sasl_client_init() -; return 0; } -EOF -if { (eval echo configure:6394: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - sasl_lib=sasl32.lib -else - echo "$ac_t""no" 1>&6 -fi - - if test -z "$sasl_lib" ; then - LIBS="/link $SASL_LIBS libsasl2.lib" - echo $ac_n "checking for sasl_client_init in -lsasl2""... $ac_c" 1>&6 -echo "configure:6417: checking for sasl_client_init in -lsasl2" >&5 -ac_lib_var=`echo sasl2'_'sasl_client_init | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lsasl2 $LIBS" -cat > conftest.$ac_ext <<EOF -#line 6425 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char sasl_client_init(); - -int main() { -sasl_client_init() -; return 0; } -EOF -if { (eval echo configure:6436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - sasl_lib=libsasl2.lib -else - echo "$ac_t""no" 1>&6 -fi - - fi - if test -z "$sasl_lib" ; then - LIBS="/link $SASL_LIBS libsasl.lib" - echo $ac_n "checking for sasl_client_init in -lsasl""... $ac_c" 1>&6 -echo "configure:6460: checking for sasl_client_init in -lsasl" >&5 -ac_lib_var=`echo sasl'_'sasl_client_init | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lsasl $LIBS" -cat > conftest.$ac_ext <<EOF -#line 6468 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char sasl_client_init(); - -int main() { -sasl_client_init() -; return 0; } -EOF -if { (eval echo configure:6479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - sasl_lib=libsasl.lib -else - echo "$ac_t""no" 1>&6 -fi - - fi - LIBS="$SAVE_LIBS" -else - echo $ac_n "checking for sasl_client_init in -lsasl2""... $ac_c" 1>&6 -echo "configure:6503: checking for sasl_client_init in -lsasl2" >&5 -ac_lib_var=`echo sasl2'_'sasl_client_init | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lsasl2 $LIBS" -cat > conftest.$ac_ext <<EOF -#line 6511 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char sasl_client_init(); - -int main() { -sasl_client_init() -; return 0; } -EOF -if { (eval echo configure:6522: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - sasl_lib=-lsasl2 -else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for sasl_client_init in -lsasl""... $ac_c" 1>&6 -echo "configure:6541: checking for sasl_client_init in -lsasl" >&5 -ac_lib_var=`echo sasl'_'sasl_client_init | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lsasl $LIBS" -cat > conftest.$ac_ext <<EOF -#line 6549 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char sasl_client_init(); - -int main() { -sasl_client_init() -; return 0; } -EOF -if { (eval echo configure:6560: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - sasl_lib=-lsasl -else - echo "$ac_t""no" 1>&6 -fi - -fi - -fi - -SASL_LIBS="$SASL_LIBS $sasl_lib" -LDFLAGS=$SAVE_LDFLAGS - - - - - -if test -n "$HAVE_SASL"; then - cat >> confdefs.h <<\EOF -#define HAVE_SASL 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_SASL_OPTIONS 1 -EOF - - cat >> confdefs.h <<\EOF -#define LDAP_SASLIO_HOOKS 1 -EOF - -fi - - -if test -n "$USE_PTHREADS"; then - rm -f conftest* - ac_cv_have_dash_pthread=no - echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6 -echo "configure:6611: checking whether ${CC-cc} accepts -pthread" >&5 - echo 'int main() { return 0; }' | cat > conftest.c - ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1 - if test $? -eq 0; then - if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then - ac_cv_have_dash_pthread=yes - CFLAGS="$CFLAGS -pthread" - CXXFLAGS="$CXXFLAGS -pthread" - fi - fi - rm -f conftest* - echo "$ac_t""$ac_cv_have_dash_pthread" 1>&6 - - ac_cv_have_dash_pthreads=no - if test "$ac_cv_have_dash_pthread" = "no"; then - echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6 -echo "configure:6627: checking whether ${CC-cc} accepts -pthreads" >&5 - echo 'int main() { return 0; }' | cat > conftest.c - ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1 - if test $? -eq 0; then - if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then - ac_cv_have_dash_pthreads=yes - CFLAGS="$CFLAGS -pthreads" - CXXFLAGS="$CXXFLAGS -pthreads" - fi - fi - rm -f conftest* - echo "$ac_t""$ac_cv_have_dash_pthreads" 1>&6 - fi - - case "$target" in - *-solaris*) - if test "$ac_cv_have_dash_pthreads" = "yes"; then - _PTHREAD_LDFLAGS= - fi - ;; - *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*) - cat >> confdefs.h <<\EOF -#define _THREAD_SAFE 1 -EOF - - if test "$ac_cv_have_dash_pthread" = "yes"; then - _PTHREAD_LDFLAGS= - fi - ;; - *-linux*) - cat >> confdefs.h <<\EOF -#define _REENTRANT 1 -EOF - - ;; - esac - -else - if test -n "$USE_USER_PTHREADS"; then - USE_PTHREADS= - USE_NSPR_THREADS= - else - _PTHREAD_LDFLAGS= - fi -fi - -case "$target" in -*-aix*) - if test -n "$USE_NSPR_THREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_LOCAL_THREADS_ONLY 1 -EOF - - fi - case "$target_os" in - aix4.1*) - if test -z "$USE_PTHREADS"; then - cat >> confdefs.h <<\EOF -#define AIX_RENAME_SELECT 1 -EOF - - fi - ;; - aix4.2*) - if test -z "$USE_NSPR_THREADS"; then - cat >> confdefs.h <<\EOF -#define HAVE_POINTER_LOCALTIME_R 1 -EOF - - fi - ;; - aix4.3*) - if test -z "$USE_NSPR_THREADS"; then - cat >> confdefs.h <<\EOF -#define HAVE_POINTER_LOCALTIME_R 1 -EOF - - fi - if test -n "$USE_PTHREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_HAVE_THREADSAFE_GETHOST 1 -EOF - - fi - ;; - esac - ;; -*-bsdi*) - if test -n "$USE_PTHREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_NEED_PTHREAD_INIT 1 -EOF - - fi - ;; -*-freebsd*) - if test -n "$USE_NSPR_THREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_LOCAL_THREADS_ONLY 1 -EOF - - fi - ;; -*-hpux*) - if test -n "$USE_NSPR_THREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_LOCAL_THREADS_ONLY 1 -EOF - - fi - if test "$USE_PTHREADS"; then - if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then - cat >> confdefs.h <<\EOF -#define _REENTRANT 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_DCETHREADS 1 -EOF - - else - cat >> confdefs.h <<EOF -#define _POSIX_C_SOURCE 199506L -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_THREADSAFE_GETHOST 1 -EOF - - fi - fi - if test "$USE_USER_PTHREADS"; then - cat >> confdefs.h <<EOF -#define _POSIX_C_SOURCE 199506L -EOF - - fi - ;; -*-irix*) - if test "${target_os}" = "irix6.5"; then - if test -n "$USE_PTHREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_HAVE_GETHOST_R 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_GETHOST_R_POINTER 1 -EOF - - fi - fi - ;; -*-linux*) - if test -n "$USE_NSPR_THREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_LOCAL_THREADS_ONLY 1 -EOF - - fi - ;; -*-mingw*|*-cygwin*|*-msvc*|*-mks*|*-os2*|*-beos*) - USE_PTHREADS= - _PTHREAD_LDFLAGS= - USE_USER_PTHREADS= - ;; -*-netbsd*) - if test -n "$USE_NSPR_THREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_LOCAL_THREADS_ONLY 1 -EOF - - fi - ;; -*-osf*) - if test -n "$USE_NSPR_THREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_LOCAL_THREADS_ONLY 1 -EOF - - fi - if test -n "$USE_PTHREADS"; then - if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then - : - else - cat >> confdefs.h <<\EOF -#define _PR_HAVE_THREADSAFE_GETHOST 1 -EOF - - fi - fi - ;; -*-solaris*) - if test -n "$USE_NATIVE_THREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_GLOBAL_THREADS_ONLY 1 -EOF - - else - if test -n "$USE_NSPR_THREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_LOCAL_THREADS_ONLY 1 -EOF - - fi - fi - if test -z "$USE_NSPR_THREADS"; then - cat >> confdefs.h <<\EOF -#define _REENTRANT 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_POINTER_LOCALTIME_R 1 -EOF - - fi - ;; -*-nto*) - if test -n "$USE_PTHREADS"; then - cat >> confdefs.h <<\EOF -#define _PR_HAVE_GETHOST_R 1 -EOF - - cat >> confdefs.h <<\EOF -#define _PR_HAVE_GETHOST_R_POINTER 1 -EOF - - fi - ;; -esac - -OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS" - -if test -n "$_SAVE_OPTIMIZE_FLAGS"; then - _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS" -fi - -if test -n "$_SAVE_DEBUG_FLAGS"; then - _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS" -fi - -if test -n "$MOZ_OPTIMIZE"; then - CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS" - CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS" -fi - -if test -n "$MOZ_DEBUG"; then - CFLAGS="$CFLAGS $_DEBUG_FLAGS" - CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS" -fi - -case "$target_os" in -cygwin*|msvc*|mks*) - CC="\$(CYGWIN_WRAPPER) $CC" - CXX="\$(CYGWIN_WRAPPER) $CXX" - RC="\$(CYGWIN_WRAPPER) $RC" - ;; -esac - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -MAKEFILES=" -Makefile -config/Makefile -config/autoconf.mk -ldap/Makefile -ldap/clients/tools/Makefile -ldap/include/Makefile -ldap/libraries/Makefile -ldap/libraries/libldap/Makefile -ldap/libraries/libprldap/Makefile -ldap/libraries/libldif/Makefile -ldap/libraries/liblber/Makefile -ldap/libraries/libiutil/Makefile -ldap/libraries/libssldap/Makefile -ldap/libraries/libutil/Makefile -" - -mkdir ldap > /dev/null 2>&1 -mkdir ldap/clients > /dev/null 2>&1 - -trap '' 1 2 15 -cat > confcache <<\EOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# -EOF -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : -else - if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then we branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -cat >confdef2opt.sed <<\_ACEOF -t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g -t quote -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g -t quote -d -: quote -s,[ `~#$^&*(){}\\|;'"<>?],\\&,g -s,\[,\\&,g -s,\],\\&,g -s,\$,$$,g -p -_ACEOF -# We use echo to avoid assuming a particular line-breaking character. -# The extra dot is to prevent the shell from consuming trailing -# line-breaks from the sub-command output. A line-break within -# single-quotes doesn't work because, if this script is created in a -# platform that uses two characters for line-breaks (e.g., DOS), tr -# would break. -ac_LF_and_DOT=`echo; echo .` -DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` -rm -f confdef2opt.sed - - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS <<EOF -#! /bin/sh -# Generated automatically by configure. -# Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir - -trap 'rm -fr `echo "$MAKEFILES" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS <<EOF - -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@SHELL@%$SHELL%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@FFLAGS@%$FFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@host@%$host%g -s%@host_alias@%$host_alias%g -s%@host_cpu@%$host_cpu%g -s%@host_vendor@%$host_vendor%g -s%@host_os@%$host_os%g -s%@target@%$target%g -s%@target_alias@%$target_alias%g -s%@target_cpu@%$target_cpu%g -s%@target_vendor@%$target_vendor%g -s%@target_os@%$target_os%g -s%@build@%$build%g -s%@build_alias@%$build_alias%g -s%@build_cpu@%$build_cpu%g -s%@build_vendor@%$build_vendor%g -s%@build_os@%$build_os%g -s%@CC@%$CC%g -s%@dist_prefix@%$dist_prefix%g -s%@dist_bindir@%$dist_bindir%g -s%@dist_libdir@%$dist_libdir%g -s%@BUILDCLU@%$BUILDCLU%g -s%@SVRCORE_LIBS@%$SVRCORE_LIBS%g -s%@HAVE_SVRCORE@%$HAVE_SVRCORE%g -s%@PKG_CONFIG@%$PKG_CONFIG%g -s%@SVRCORE_CFLAGS@%$SVRCORE_CFLAGS%g -s%@NSS_CFLAGS@%$NSS_CFLAGS%g -s%@NSS_LIBS@%$NSS_LIBS%g -s%@NSS_CONFIG@%$NSS_CONFIG%g -s%@NSPR_CFLAGS@%$NSPR_CFLAGS%g -s%@NSPR_LIBS@%$NSPR_LIBS%g -s%@NSPR_CONFIG@%$NSPR_CONFIG%g -s%@LIBS_ALREADY_SET@%$LIBS_ALREADY_SET%g -s%@WHOAMI@%$WHOAMI%g -s%@CXX@%$CXX%g -s%@CPP@%$CPP%g -s%@RANLIB@%$RANLIB%g -s%@AS@%$AS%g -s%@AR@%$AR%g -s%@LD@%$LD%g -s%@STRIP@%$STRIP%g -s%@WINDRES@%$WINDRES%g -s%@HOST_CC@%$HOST_CC%g -s%@PERL@%$PERL%g -s%@HAVE_MSVC_LIB@%$HAVE_MSVC_LIB%g -s%@SASL_LIBS@%$SASL_LIBS%g -s%@SASL_CFLAGS@%$SASL_CFLAGS%g -s%@HAVE_SASL@%$HAVE_SASL%g -s%@SHELL_OVERRIDE@%$SHELL_OVERRIDE%g -s%@MOZILLA_CLIENT@%$MOZILLA_CLIENT%g -s%@HOST_CFLAGS@%$HOST_CFLAGS%g -s%@GNU_CC@%$GNU_CC%g -s%@CROSS_COMPILE@%$CROSS_COMPILE%g -s%@MOZ_OPTIMIZE@%$MOZ_OPTIMIZE%g -s%@USE_CPLUS@%$USE_CPLUS%g -s%@USE_IPV6@%$USE_IPV6%g -s%@USE_N32@%$USE_N32%g -s%@USE_64@%$USE_64%g -s%@OBJECT_MODE@%$OBJECT_MODE%g -s%@GC_LEAK_DETECTOR@%$GC_LEAK_DETECTOR%g -s%@ENABLE_STRIP@%$ENABLE_STRIP%g -s%@USE_PTHREADS@%$USE_PTHREADS%g -s%@USE_BTHREADS@%$USE_BTHREADS%g -s%@USE_USER_PTHREADS@%$USE_USER_PTHREADS%g -s%@USE_NATIVE_THREADS@%$USE_NATIVE_THREADS%g -s%@USE_NSPR_THREADS@%$USE_NSPR_THREADS%g -s%@USE_NSS@%$USE_NSS%g -s%@CPU_ARCH@%$CPU_ARCH%g -s%@OBJ_SUFFIX@%$OBJ_SUFFIX%g -s%@LIB_SUFFIX@%$LIB_SUFFIX%g -s%@LIB_PREFIX@%$LIB_PREFIX%g -s%@DLL_SUFFIX@%$DLL_SUFFIX%g -s%@ASM_SUFFIX@%$ASM_SUFFIX%g -s%@PROG_SUFFIX@%$PROG_SUFFIX%g -s%@MKSHLIB@%$MKSHLIB%g -s%@DSO_CFLAGS@%$DSO_CFLAGS%g -s%@DSO_LDOPTS@%$DSO_LDOPTS%g -s%@OS_TARGET@%$OS_TARGET%g -s%@OS_ARCH@%$OS_ARCH%g -s%@OS_RELEASE@%$OS_RELEASE%g -s%@OS_TEST@%$OS_TEST%g -s%@DEFINES@%$DEFINES%g -s%@AR_FLAGS@%$AR_FLAGS%g -s%@ASFLAGS@%$ASFLAGS%g -s%@FILTER@%$FILTER%g -s%@IMPLIB@%$IMPLIB%g -s%@OS_LIBS@%$OS_LIBS%g -s%@RESOLVE_LINK_SYMBOLS@%$RESOLVE_LINK_SYMBOLS%g -s%@NOSUCHFILE@%$NOSUCHFILE%g -s%@MOZ_OBJFORMAT@%$MOZ_OBJFORMAT%g -s%@ULTRASPARC_LIBRARY@%$ULTRASPARC_LIBRARY%g -s%@ULTRASPARC_FILTER_LIBRARY@%$ULTRASPARC_FILTER_LIBRARY%g -s%@OBJDIR@%$OBJDIR%g -s%@OBJDIR_NAME@%$OBJDIR_NAME%g -s%@NSINSTALL@%$NSINSTALL%g -s%@OPTIMIZER@%$OPTIMIZER%g -s%@RC@%$RC%g -s%@DLLFLAGS@%$DLLFLAGS%g -s%@EXEFLAGS@%$EXEFLAGS%g -s%@OS_DLLFLAGS@%$OS_DLLFLAGS%g -s%@CYGWIN_WRAPPER@%$CYGWIN_WRAPPER%g -s%@WIN_TOP_SRC@%$WIN_TOP_SRC%g -s%@NEXT_ROOT@%$NEXT_ROOT%g -s%@RPATHFLAG@%$RPATHFLAG%g -s%@MFLAGS@%$MFLAGS%g - -CEOF -EOF - -cat >> $CONFIG_STATUS <<\EOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" - else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` - fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF - -cat >> $CONFIG_STATUS <<EOF - -CONFIG_FILES=\${CONFIG_FILES-"$MAKEFILES"} -EOF -cat >> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* - -EOF -cat >> $CONFIG_STATUS <<EOF - -EOF -cat >> $CONFIG_STATUS <<\EOF - -exit 0 -EOF -chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 -
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/configure.in
Deleted
@@ -1,2650 +0,0 @@ -dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*- -dnl -dnl ***** BEGIN LICENSE BLOCK ***** -dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1 -dnl -dnl The contents of this file are subject to the Mozilla Public License Version -dnl 1.1 (the "License"); you may not use this file except in compliance with -dnl the License. You may obtain a copy of the License at -dnl http://www.mozilla.org/MPL/ -dnl -dnl Software distributed under the License is distributed on an "AS IS" basis, -dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -dnl for the specific language governing rights and limitations under the -dnl License. -dnl -dnl The Original Code is the Netscape Portable Runtime (NSPR). -dnl -dnl The Initial Developer of the Original Code is -dnl Netscape Communications Corporation. -dnl Portions created by the Initial Developer are Copyright (C) 1998-2000 -dnl the Initial Developer. All Rights Reserved. -dnl -dnl Contributor(s): -dnl Christopher Seawood <cls@seawood.org> -dnl Dan Mosedale <dmose@netscape.com> -dnl Howard Chu <hyc@symas.com> -dnl -dnl Alternatively, the contents of this file may be used under the terms of -dnl either of the GNU General Public License Version 2 or later (the "GPL"), -dnl or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -dnl in which case the provisions of the GPL or the LGPL are applicable instead -dnl of those above. If you wish to allow use of your version of this file only -dnl under the terms of either the GPL or the LGPL, and not to allow others to -dnl use your version of this file under the terms of the MPL, indicate your -dnl decision by deleting the provisions above and replace them with the notice -dnl and other provisions required by the GPL or the LGPL. If you do not delete -dnl the provisions above, a recipient may use your version of this file under -dnl the terms of any one of the MPL, the GPL or the LGPL. -dnl -dnl ***** END LICENSE BLOCK ***** - -AC_PREREQ(2.12) -AC_INIT(ldap/include/ldap.h) - -AC_CONFIG_AUX_DIR(${srcdir}/config/autoconf) -AC_CANONICAL_SYSTEM - -dnl ======================================================== -dnl = Defaults -dnl ======================================================== -NSPR_VERSION=4 -_HAVE_PTHREADS= -USE_PTHREADS= -USE_USER_PTHREADS= -USE_NSPR_THREADS= -USE_N32= -USE_64= -USE_CPLUS= -USE_IPV6= -USE_MDUPDATE= -_OPTIMIZE_FLAGS=-O -_DEBUG_FLAGS=-g -MOZ_DEBUG=1 -MOZ_OPTIMIZE= -MFLAGS= -OBJDIR=. -OBJDIR_NAME=. -NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall' -NOSUCHFILE=/no-such-file - -dnl Link in libraries necessary to resolve all symbols for shared libs -RESOLVE_LINK_SYMBOLS= - -dnl ======================================================== -dnl = -dnl = Dont change the following lines. Doing so breaks: -dnl = -dnl = CFLAGS="-foo" ./configure -dnl = -dnl ======================================================== -CFLAGS="${CFLAGS=}" -CXXFLAGS="${CXXFLAGS=}" -LDFLAGS="${LDFLAGS=}" -HOST_CFLAGS="${HOST_CFLAGS=}" -HOST_LDFLAGS="${HOST_LDFLAGS=}" - -case "$target" in -*-cygwin*|*-mingw*|*-msvc*|*-mks*) - # Check to see if we are really running in a msvc environemnt - _WIN32_MSVC= - AC_CHECK_PROGS(CC, cl) - if test "$CC" = "cl"; then - echo 'main() { return 0; }' > dummy.c - ${CC} -o dummy dummy.c >/dev/null 2>&1 - if test $? = 0; then - _WIN32_MSVC=1 - CXX=$CC - else - AC_MSG_WARN([$(CC) test failed. Using normal feature tests]) - fi - rm -f dummy dummy.o dummy.obj dummy.exe dummy.c - fi - ;; -esac - -if test -n "$_WIN32_MSVC"; then - SKIP_PATH_CHECKS=1 - SKIP_COMPILER_CHECKS=1 - SKIP_LIBRARY_CHECKS=1 -fi - -dnl ======================================================== -dnl = -dnl = Check options that may affect the compiler -dnl = -dnl ======================================================== -dist_prefix='${MOD_DEPTH}/../../dist' -dist_bindir='${dist_prefix}/bin' -dist_libdir='${dist_prefix}/lib' - -AC_ARG_WITH(dist-prefix, - [ --with-dist-prefix=DIST_PREFIX - place build files in DIST_PREFIX [dist]], - dist_prefix=$withval) - -AC_ARG_WITH(dist-bindir, - [ --with-dist-bindir=DIR build execuatables in DIR [DIST_PREFIX/bin]], - dist_bindir=$withval) - -AC_ARG_WITH(dist-libdir, - [ --with-dist-libdir=DIR build library files in DIR [DIST_PREFIX/lib]], - dist_libdir=$withval) - -AC_SUBST(dist_prefix) -AC_SUBST(dist_bindir) -AC_SUBST(dist_libdir) - -dnl Check if LDAP is being compiled for Mozilla -dnl Let --with-arg override environment setting -dnl -AC_ARG_WITH(mozilla, - [ --with-mozilla Compile LDAP with Mozilla support], - [ if test "$withval" = "yes"; then - AC_DEFINE(MOZILLA_CLIENT) - MOZILLA_CLIENT=1 - else - MOZILLA_CLIENT= - fi], - [ if test -n "$MOZILLA_CLIENT"; then - AC_DEFINE(MOZILLA_CLIENT) - fi]) - -AC_ARG_ENABLE(optimize, - [ --enable-optimize(=val) Enable code optimizations (val, ie. -O2) ], - [ if test "$enableval" != "no"; then - MOZ_OPTIMIZE=1 - if test -n "$enableval" && test "$enableval" != "yes"; then - _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'` - _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS - fi - else - MOZ_OPTIMIZE= - fi ]) - -AC_ARG_ENABLE(debug, - [ --disable-debug Do not compile in debugging symbols - --enable-debug(=val) Enable debugging (debug flags val)], - [ if test "$enableval" = "no"; then - MOZ_DEBUG= - else - MOZ_DEBUG=1 - if test -n "$enableval" && test "$enableval" != "yes"; then - _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'` - _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS - fi - fi]) - -AC_ARG_ENABLE(win32-target, - [ --enable-win32-target=\$t - Specify win32 flavor. (WIN95 or WINNT)], - OS_TARGET=`echo $enableval | tr a-z A-Z`, - OS_TARGET=) - -AC_ARG_ENABLE(debug-rtl, - [ --enable-debug-rtl Use the MSVC debug runtime library], - [ if test "$enableval" = "yes"; then - USE_DEBUG_RTL=1 - fi ]) - -AC_ARG_ENABLE(n32, - [ --enable-n32 Enable n32 ABI support (IRIX only)], - [ if test "$enableval" = "yes"; then - USE_N32=1 - else if test "$enableval" = "no"; then - USE_N32= - fi - fi ]) - -AC_ARG_ENABLE(64bit, - [ --enable-64bit Enable 64-bit support (on certain platforms)], - [ if test "$enableval" = "yes"; then - USE_64=1 ; export USE_64 - fi ], - []) - -AC_ARG_ENABLE(mdupdate, - [ --enable-mdupdate Enable use of certain compilers' mdupdate feature], - [ if test "$enableval" = "yes"; then - USE_MDUPDATE=1 - fi ]) - -dnl ======================================================== -dnl = build the optional command-line utilities such as -dnl = ldapsearch and ldapmodify. -dnl ======================================================== -AC_ARG_ENABLE(clu, - [ --enable-clu Enable building the command-line utilities], - [ if test "$enableval" = "yes"; then - BUILDCLU=1 - AC_SUBST(BUILDCLU) - fi ], - []) - -dnl ======================================================== -dnl = svrcore gives the command line tools secure PIN management -dnl = for client cert based authentication -dnl ======================================================== -dnl ======================================================== -dnl = Use the SVRCORE copy in the system (assuming it exists) -dnl = rather than the one in the source tree (mozilla/security) -dnl ======================================================== -AC_ARG_WITH(system-svrcore, - [ --with-system-svrcore Use system installed SVRCORE], - [ if test "$withval" = "yes"; then - _SYSTEM_SVRCORE=1 - HAVE_SVRCORE=1 - SVRCORE_LIBS=-lsvrcore - AC_SUBST(SVRCORE_LIBS) - AC_SUBST(HAVE_SVRCORE) -dnl svrcore implies both nspr and nss - USE_NSS=1 - no_nspr=no - else - _SYSTEM_SVRCORE= - fi], _SYSTEM_SVRCORE= ) - -dnl _SYSTEM_SVRCORE means /usr/lib and /usr/include so no need to add additional -dnl include or lib paths -if test -z "$_SYSTEM_SVRCORE" ; then - dnl first, see if user has specified explicit SVRCORE include and lib paths - AM_PATH_GIVEN_SVRCORE() - - dnl next, see if user explicitly said to use system svrcore - if test -n "$HAVE_SVRCORE" ; then -dnl svrcore implies both nspr and nss - USE_NSS=1 - HAVE_SVRCORE=1 - AC_SUBST(HAVE_SVRCORE) - no_nspr=no - if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS" ; then - if test -n "$_SYSTEM_SVRCORE"; then - AM_PATH_SVRCORE(4.0.1, [MOZ_NATIVE_SVRCORE=1], [MOZ_NATIVE_SVRCORE=]) - else - dnl see if we are being built in the same build tree as svrcore - AM_PATH_INTREE_SVRCORE(../../dist) - dnl failing that, see if we can find svrcore-config or pkg-config svrcore - if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS"; then - AM_PATH_SVRCORE(4.0.1, [MOZ_NATIVE_SVRCORE=1], [MOZ_NATIVE_SVRCORE=]) - fi - fi - fi - fi -fi - -if test -n "$HAVE_SVRCORE" -a -z "$_SYSTEM_SVRCORE" ; then - if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS"; then - AC_MSG_ERROR([--with-svrcore specified, but no svrcore could be found]) - fi -fi - -dnl ======================================================== -dnl = Use the NSS copy in the system (assuming it exists) -dnl = rather than the one in the source tree (mozilla/security) -dnl ======================================================== -AC_ARG_WITH(system-nss, - [ --with-system-nss Use system installed NSS], - [ if test "$withval" = "yes"; then - _SYSTEM_NSS=1 - USE_NSS=1 -dnl nss requires nspr - no_nspr=no - elif test "$withval" = "no" ; then - _SYSTEM_NSS=no - fi], _SYSTEM_NSS= ) - -if test "$_WIN32_MSVC"; then - _SYSTEM_NSS= -fi - -dnl first, see if user has specified explicit NSPR include and lib paths, -dnl of if the user has explicitly disabled the use of nss -if test -z "$_SYSTEM_NSS" -o "$_SYSTEM_NSS" = "no" ; then - AM_PATH_GIVEN_NSS() -fi - -dnl next, see if user explicitly said to use system nss -if test -n "$USE_NSS" -a -z "$NSS_CFLAGS" -a -z "$NSS_LIBS" ; then -dnl nss requires nspr - no_nspr=no - if test -z "$_SYSTEM_NSS" -o "$_SYSTEM_NSS" = "no" ; then -dnl see if we are being built in the same build tree as nss - AM_PATH_INTREE_NSS(../../dist) - fi -dnl failing that, see if we can find nss-config or pkg-config nss - if test -z "$NSS_CFLAGS" -a "$_SYSTEM_NSS" != "no" ; then - AM_PATH_NSS(3.9.0, [MOZ_NATIVE_NSS=1], [MOZ_NATIVE_NSS=]) - fi -fi - -dnl bomb out if nss not found -if test -n "$USE_NSS" -a -z "$NSS_CFLAGS" -a -z "$NSS_LIBS" ; then - AC_MSG_ERROR(Need to use NSS but no NSS was found) -fi - -dnl ======================================================== -dnl = Use the NSPR copy in the system (assuming it exists) -dnl = rather than the one in the source tree (mozilla/nsprpub) -dnl ======================================================== -AC_ARG_WITH(system-nspr, - [ --with-system-nspr Use system installed NSPR], - [ if test "$withval" = "yes"; then - _SYSTEM_NSPR=1 - no_nspr=no - elif test "$withval" = "no"; then - _SYSTEM_NSPR=no - fi], _SYSTEM_NSPR= ) - -if test "$_WIN32_MSVC"; then - _SYSTEM_NSPR=no -fi - -dnl first, see if user has specified explicit NSPR include and lib paths, -dnl of if the user has explicitly disabled the use of nspr -if test -z "$_SYSTEM_NSPR" -o "$_SYSTEM_NSPR" = "no" ; then - AM_PATH_GIVEN_NSPR() -fi - -dnl next, look for in-tree nspr if user did not specify explicit system nspr -if test "$no_nspr" = "no" -a -z "$NSPR_CFLAGS" -a -z "$NSPR_LIBS" ; then - if test -z "$_SYSTEM_NSPR" -o "$_SYSTEM_NSPR" = "no" ; then -dnl see if we are being built in the same build tree as nspr - AM_PATH_INTREE_NSPR(../../dist) - fi -dnl failing that, see if we can find nspr-config or pkg-config nspr - if test -z "$NSPR_CFLAGS" -a "$_SYSTEM_NSPR" != "no" ; then - AM_PATH_NSPR(4.0.0, [MOZ_NATIVE_NSPR=1], [MOZ_NATIVE_NSPR=]) - fi -fi - -dnl if we are being built as part of the mozilla client, and we could not -dnl find NSPR by any other method, just default to the default values -dnl used by the client build - NOTE that this sets the libpaths and the -dnl library link commands directly, so we don't need to muck with any -dnl cygwin path conversion stuff. The client build also uses --with-dist-prefix -dnl which sets $(DIST) in the makefiles -if test -z "$NSPR_CFLAGS" -o -z "$NSPR_LIBS" ; then - if test -n "$MOZILLA_CLIENT" ; then - NSPR_CFLAGS='-I$(DIST)/include/nspr' - NSPR_LIBS='-L$(DIST)/lib '"-lplds$NSPR_VERSION -lplc$NSPR_VERSION -lnspr$NSPR_VERSION" - dnl explicitly set libs for Visual Age C++ for OS/2 - if test "$VACPP" = "yes"; then - NSPR_LIBS='$(DIST)/lib/nspr'$NSPR_VERSION'.lib $(DIST)/lib/plc'$NSPR_VERSION'.lib $(DIST)/lib/plds'$NSPR_VERSION'.lib '$_PTHREAD_LDFLAGS'' - elif test "$_WIN32_MSVC"; then - NSPR_LIBS='$(DIST)/lib/nspr'$NSPR_VERSION'.lib $(DIST)/lib/plc'$NSPR_VERSION'.lib $(DIST)/lib/plds'$NSPR_VERSION'.lib ' - fi - SKIP_CYGWIN_FIXUP=1 - LIBS_ALREADY_SET=1 - AC_SUBST(LIBS_ALREADY_SET) - elif test "$no_nspr" = "no" ; then - AC_MSG_ERROR(Need to use NSPR but no NSPR was found) - fi -fi - -dnl ======================================================== -dnl If using cygwin (or another Windows shell that uses unix -dnl style paths by default - mingw?) and using MSVC, we need -dnl to convert the include and lib paths to the more MSVC -dnl friendly format - it's easier and faster to do it here -dnl than in cygwin-wrapper -dnl ======================================================== - -dnl add other runtime environments that use unix style paths -dnl *-cygwin*|*-mingw*|*-msvc*|*-mks*) -case "$target" in -*-cygwin*) USE_WINDOWS_PATHS=1 ;; -esac - -if test -n "$_WIN32_MSVC" -a -n "$USE_WINDOWS_PATHS" ; then - if test -n "$NSPR_CFLAGS" -a -z "$SKIP_CYGWIN_FIXUP" ; then - path=`echo $NSPR_CFLAGS | sed -e 's/^-I//'` - path=`cygpath -m $path` - NSPR_CFLAGS="/I$path" - fi - if test -n "$NSPR_LIBS" -a -z "$SKIP_CYGWIN_FIXUP" ; then - path=`echo $NSPR_LIBS | sed -e 's/^-L//'` - path=`cygpath -m $path` - NSPR_LIBS="/LIBPATH:$path" - fi - - if test -n "$NSS_CFLAGS" ; then - path=`echo $NSS_CFLAGS | sed -e 's/^-I//'` - path=`cygpath -m $path` - NSS_CFLAGS="/I$path" - fi - - if test -n "$NSS_LIBS" ; then - path=`echo $NSS_LIBS | sed -e 's/^-L//'` - path=`cygpath -m $path` - NSS_LIBS="/LIBPATH:$path" - fi - - if test -n "$SVRCORE_CFLAGS" ; then - path=`echo $SVRCORE_CFLAGS | sed -e 's/^-I//'` - path=`cygpath -m $path` - SVRCORE_CFLAGS="/I$path" - fi - - if test -n "$SVRCORE_LIBS" ; then - path=`echo $SVRCORE_LIBS | sed -e 's/^-L//'` - path=`cygpath -m $path` - SVRCORE_LIBS="/LIBPATH:$path" - fi -fi - -dnl ======================================================== -dnl = -dnl = Set the threading model -dnl = -dnl ======================================================== -case "$target" in - -*-aix*) - case "${target_os}" in - aix3.2*) - USE_NSPR_THREADS=1 - ;; - *) - USE_PTHREADS=1 - ;; - esac - ;; - -esac - -dnl ======================================================== -dnl = -dnl = Set the default C compiler -dnl = -dnl ======================================================== -if test -z "$CC"; then - case "$target" in - - *-aix*) - if test -z "$USE_NSPR_THREADS"; then - CC=xlC_r - else - CC=xlC - fi - ;; - - *-hpux*) - CC=cc - ;; - - *-irix*) - CC=cc - ;; - - *-osf*) - CC=cc - ;; - - *-solaris*) - CC=cc - ;; - - esac -fi - -dnl ======================================================== -dnl = -dnl = Set the default C++ compiler -dnl = -dnl ======================================================== -if test -z "$CXX"; then - case "$target" in - - *-aix*) - if test -z "$USE_NSPR_THREADS"; then - CXX=xlC_r - else - CXX=xlC - fi - ;; - - *-hpux*) - case "${target_os}" in - hpux10.30) - CXX=aCC - ;; - hpux11.*) - CXX=aCC - ;; - *) - CXX=CC - ;; - esac - ;; - - *-irix*) - CXX=CC - ;; - - *-osf*) - CXX=cxx - ;; - - *-solaris*) - CXX=CC - ;; - - esac -fi - -if test -z "$SKIP_PATH_CHECKS"; then - AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami) -fi - -if test -n "$MOZ_DEBUG"; then - AC_DEFINE(DEBUG) - DEFINES="$DEFINES -UNDEBUG" - case "${target_os}" in - beos*) - DEFINES="$DEFINES -DDEBUG_${USER}" - ;; - msvc*|mks*|cygwin*|mingw*|os2*) - DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`" - ;; - *) - DEFINES="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_`$WHOAMI`" - ;; - esac - MFLAGS="BUILD_DEBUG=full" -else - AC_DEFINE(NDEBUG) - DEFINES="$DEFINES -UDEBUG" - MFLAGS="BUILD_DEBUG=optimize" -fi - -dnl Use mozilla's nsinstall -if test -n "$MOZILLA_CLIENT"; then - NSINSTALL='$(dist_bindir)/nsinstall' -fi - -if test -z "$SKIP_COMPILER_CHECKS"; then -dnl ======================================================== -dnl Checks for compilers. -dnl ======================================================== -dnl NOTE that according to the latest autoconf 2.5x manual -dnl "Now, configure enters cross-compilation mode if and only if `--host' is passed." -dnl However, the mozilla build system expects us to assume different target and host -dnl means cross compiling. But, %configure in many linux RPM build systems sets the -dnl following: -dnl ./configure --build=i686-redhat-linux-gnu --host=i686-redhat-linux-gnu --target=i386-redhat-linux-gnu ... -dnl which means that the system is an i686, but we want to produce code which will run on i386 - in -dnl this case, we _do not_ want to cross compile -dnl So, additional logic: -dnl if $host = $build, do not cross compile -dnl otherwise, cross compile if host is given -cross_compiling=no -dnl host must be specified to cross compile -if test -n "$host" ; then - case $target in - *-darwin*) - if test "$host" != "$target" ; then - cross_compiling=yes - fi - ;; - *) -dnl host == build - do not cross compile - if test "$host" = "$build" ; then - cross_compiling=no -dnl host != build or host != target - do cross compile - elif test "$host" != "$target" -o "$host" != "$build" ; then - cross_compiling=yes - fi - ;; - esac -fi -if test "$cross_compiling" = "no"; then - AC_PROG_CXX - if test "$CXX" = "cl" -a -z "$CC"; then - CC=$CXX - else - AC_PROG_CC - fi - AC_PROG_CPP - AC_PROG_RANLIB - AC_PATH_PROGS(AS, as, $CC) - AC_PATH_PROGS(AR, ar, echo not_ar) - AC_PATH_PROGS(LD, ld link, echo not_ld) - AC_PATH_PROGS(STRIP, strip, echo not_strip) - AC_PATH_PROGS(WINDRES, windres, echo not_windres) - if test -z "$HOST_CC"; then - HOST_CC="$CC" - fi - if test -z "$HOST_CFLAGS"; then - HOST_CFLAGS="$CFLAGS" - fi -else - echo "cross compiling from $host to $target" - - _SAVE_CC="$CC" - _SAVE_CFLAGS="$CFLAGS" - _SAVE_LDFLAGS="$LDFLAGS" - - AC_MSG_CHECKING([for $host compiler]) - AC_CHECK_PROGS(HOST_CC, gcc cc /usr/ucb/cc, "") - if test -z "$HOST_CC"; then - AC_MSG_ERROR([no acceptable cc found in \$PATH]) - fi - AC_MSG_RESULT([$HOST_CC]) - if test -z "$HOST_CFLAGS"; then - HOST_CFLAGS="$CFLAGS" - fi - if test -z "$HOST_LDFLAGS"; then - HOST_LDFLAGS="$LDFLAGS" - fi - - CC=$_SAVE_CC - CFLAGS=$_SAVE_CFLAGS - LDFLAGS=$_SAVE_LDFLAGS - - case "$build:$target" in - powerpc-apple-darwin8*:i?86-apple-darwin*) - dnl The Darwin cross compiler doesn't necessarily point itself at a - dnl root that has libraries for the proper architecture, it defaults - dnl to the system root. The libraries in the system root on current - dnl versions of PPC OS X 10.4 aren't fat, so these target compiler - dnl checks will fail. Fake a working SDK in that case. - _SAVE_CFLAGS=$CFLAGS - _SAVE_CXXFLAGS=$CXXLAGS - CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS" - CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS" - ;; - esac - - AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo) - unset ac_cv_prog_CC - AC_PROG_CC - AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo) - unset ac_cv_prog_CXX - AC_PROG_CXX - - case "$build:$target" in - powerpc-apple-darwin8*:i?86-apple-darwin*) - dnl Revert the changes made above. From this point on, the target - dnl compiler will never be used without applying the SDK to CFLAGS - dnl (see --with-macos-sdk below). - CFLAGS=$_SAVE_CFLAGS - CXXFLAGS=$_SAVE_CXXFLAGS - ;; - esac - - AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", echo) - AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", echo) - AC_CHECK_PROGS(AS, $AS "${target_alias}-as" "${target}-as", echo) - AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", echo) - AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo) - AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo) -fi - -if test "$GCC" = "yes"; then - GNU_CC=1 -fi -if test "$GXX" = "yes"; then - GNU_CXX=1 -fi -if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then - GNU_AS=1 -fi -rm -f a.out - -case "$build:$target" in - i?86-apple-darwin*:powerpc-apple-darwin*) - dnl cross_compiling will have erroneously been set to "no" in this - dnl case, because the x86 build host is able to run ppc code in a - dnl translated environment, making a cross compiler appear native. - cross_compiling=yes - ;; -esac - -if test "$cross_compiling" = "yes"; then - CROSS_COMPILE=1 -else - CROSS_COMPILE= -fi - -dnl ======================================================== -dnl Check for gcc -pipe support -dnl ======================================================== -AC_MSG_CHECKING([for gcc -pipe support]) -if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then - echo '#include <stdio.h>' > dummy-hello.c - echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c - ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5 - cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5 - if test $? = 0; then - _res_as_stdin="yes" - else - _res_as_stdin="no" - fi - if test "$_res_as_stdin" = "yes"; then - _SAVE_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -pipe" - AC_TRY_COMPILE( [ #include <stdio.h> ], - [printf("Hello World\n");], - [_res_gcc_pipe="yes"], - [_res_gcc_pipe="no"] ) - CFLAGS=$_SAVE_CFLAGS - fi - if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then - _res="yes"; - CFLAGS="$CFLAGS -pipe" - CXXFLAGS="$CXXFLAGS -pipe" - else - _res="no" - fi - rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out - AC_MSG_RESULT([$_res]) -else - AC_MSG_RESULT([no]) -fi - -fi # SKIP_COMPILER_CHECKS - -dnl ======================================================== -dnl Checks for programs. -dnl ======================================================== -if test -z "$SKIP_PATH_CHECKS"; then - AC_PATH_PROGS(PERL, perl5 perl, echo not_perl) -elif test -z "$PERL"; then - PERL=perl -fi - -dnl ======================================================== -dnl Default platform specific options -dnl ======================================================== -OBJ_SUFFIX=o -LIB_SUFFIX=a -LIB_PREFIX=lib -DLL_SUFFIX=so -ASM_SUFFIX=s -MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@' -AR_FLAGS='cr $@' -AS='$(CC)' -ASFLAGS='$(CFLAGS)' - -if test -n "$CROSS_COMPILE"; then - OS_ARCH=`echo $target_os | sed -e 's|/|_|g'` - OS_RELEASE= - OS_TEST="${target_cpu}" - case "${target_os}" in - linux*) OS_ARCH=Linux ;; - solaris*) OS_ARCH=SunOS OS_RELEASE=5 ;; - mingw*) OS_ARCH=WINNT ;; - darwin*) OS_ARCH=Darwin ;; - esac -else - OS_ARCH=`uname -s | sed -e 's|/|_|g'` - OS_RELEASE=`uname -r` - OS_TEST=`uname -m` -fi - -if test "$OS_ARCH" = "IRIX64"; then - OS_ARCH=IRIX -fi - -if test "$OS_ARCH" = "Linux"; then - OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'` - OS_RELEASE=`echo $OS_RELEASE | awk -F. '{ print $1 "." $2 }'` -fi - -####################################################################### -# Master "Core Components" macros for getting the OS target # -####################################################################### - -# -# Note: OS_TARGET should be specified on the command line for gmake. -# When OS_TARGET=WIN95 is specified, then a Windows 95 target is built. -# The difference between the Win95 target and the WinNT target is that -# the WinNT target uses Windows NT specific features not available -# in Windows 95. The Win95 target will run on Windows NT, but (supposedly) -# at lesser performance (the Win95 target uses threads; the WinNT target -# uses fibers). -# -# When OS_TARGET=WIN16 is specified, then a Windows 3.11 (16bit) target -# is built. See: win16_3.11.mk for lots more about the Win16 target. -# -# If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no -# cross-compilation. -# - -# -# The following hack allows one to build on a WIN95 machine (as if -# s/he were cross-compiling on a WINNT host for a WIN95 target). -# It also accomodates for MKS's uname.exe. If you never intend -# to do development on a WIN95 machine, you don't need this hack. -# -case "$OS_ARCH" in -WIN95) - OS_ARCH=WINNT - OS_TARGET=WIN95 - ;; -Windows_95) - OS_ARCH=Windows_NT - OS_TARGET=WIN95 - ;; -Windows_98) - OS_ARCH=Windows_NT - OS_TARGET=WIN95 - ;; -CYGWIN_9*|CYGWIN_ME*) - OS_ARCH='CYGWIN_NT-4.0' - OS_TARGET=WIN95 - ;; -OS_2) - OS_ARCH=OS2 - OS_TARGET=OS2 - ;; -WINCE) - OS_ARCH=WINCE - OS_TARGET=WINCE - ;; -esac - -# -# On WIN32, we also define the variable CPU_ARCH. -# - -case "$OS_ARCH" in -WINNT) - CPU_ARCH=`uname -p` - if test "$CPU_ARCH" = "I386"; then - CPU_ARCH=x86 - fi - ;; -Windows_NT) -# -# If uname -s returns "Windows_NT", we assume that we are using -# the uname.exe in MKS toolkit. -# -# The -r option of MKS uname only returns the major version number. -# So we need to use its -v option to get the minor version number. -# Moreover, it doesn't have the -p option, so we need to use uname -m. -# - OS_ARCH=WINNT - OS_MINOR_RELEASE=`uname -v` - if test "$OS_MINOR_RELEASE" = "00"; then - OS_MINOR_RELEASE=0 - fi - OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}" - CPU_ARCH=`uname -m` - # - # MKS's uname -m returns "586" on a Pentium machine. - # - if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then - CPU_ARCH=x86 - fi - ;; -CYGWIN32_NT|CYGWIN_NT*|MINGW*_NT*) -# -# If uname -s returns "CYGWIN_NT-4.0", we assume that we are using -# the uname.exe in the Cygwin tools. -# Prior to the Beta 20 release, Cygwin was called GNU-Win32. -# If uname -s returns "CYGWIN32/NT", we assume that we are using -# the uname.exe in the GNU-Win32 tools. -# If uname -s returns MINGW32_NT-5.1, we assume that we are using -# the uname.exe in the MSYS tools. -# - OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'` - OS_ARCH=WINNT - CPU_ARCH=`uname -m` - # - # Cygwin's uname -m returns "i686" on a Pentium Pro machine. - # - if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then - CPU_ARCH=x86 - fi - ;; -esac - -if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then - OS_TARGET=WIN95 - if test -n "$MOZ_DEBUG"; then - USE_DEBUG_RTL=1 - fi -fi -if test -z "$OS_TARGET"; then - OS_TARGET=$OS_ARCH -fi -if test "$OS_TARGET" = "WIN95"; then - OS_RELEASE="4.0" -fi -if test "$OS_TARGET" = "WIN16"; then - OS_RELEASE= -fi - -dnl ======================================================== -dnl = Mac OS X SDK support -dnl ======================================================== -AC_ARG_WITH(macos-sdk, - [ --with-macos-sdk=dir Location of platform SDK to use (Mac OS X only)], - MACOS_SDK_DIR=$withval) - -dnl ======================================================== - -dnl ======================================================== -dnl Enable high-memory support on OS/2, disabled by default -dnl ======================================================== -AC_ARG_ENABLE(os2-high-mem, - [ --enable-os2-high-mem Enable high-memory support on OS/2], - [ if test "$enableval" = "yes"; then - MOZ_OS2_HIGH_MEMORY=1 - else - MOZ_OS2_HIGH_MEMORY= - fi ]) - -dnl ======================================================== -dnl Override of system specific host options -dnl ======================================================== -case "$host" in -*-mingw*) - NSINSTALL=nsinstall - WIN_TOP_SRC=`cd $srcdir && pwd -W` - ;; -*-cygwin*|*-msvc*|*-mks*) - CYGWIN_WRAPPER='sh $(topsrcdir)/config/cygwin-wrapper' - NSINSTALL='$(CYGWIN_WRAPPER) nsinstall' - if test "`${PERL} -v | grep -c cygwin 2>/dev/null`" = 0; then - PERL='$(CYGWIN_WRAPPER) perl' - fi - WIN_TOP_SRC=`cygpath -w $srcdir | sed -e 's|\\\\|/|g'` - ;; -*-beos*) - HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE" - ;; -*os2*) - ;; -*) - HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX" - ;; -esac - -dnl ======================================================== -dnl Check for --with-rpath and user supplied rpath -dnl ======================================================== -DEFAULT_RPATHFLAG=..:../lib:../../lib:../../../lib:../../../../lib -AC_ARG_WITH(rpath, - [ --with-rpath[[=dir]] Build the shared libs and cmd lines progs with an RPATH (default dir is ..:../lib:../../lib:../../../lib:../../../../lib)], -[ - if test "$withval" = "yes" ; then # set default - RPATHFLAG="$DEFAULT_RPATHFLAG" - elif test -n "$withval" ; then # user supplied - RPATHFLAG="$withval" - fi -]) - -dnl ======================================================== -dnl Override of system specific target options -dnl ======================================================== -case "$target" in - -*-aix*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(AIX) - AC_DEFINE(SYSV) - DSO_LDOPTS='-brtl -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib' - AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H)) - case "${target_os}" in - aix3.2*) - AC_DEFINE(AIX_RENAME_SELECT) - AC_DEFINE(_PR_NO_LARGE_FILES) - ;; - aix4.1*) - AC_DEFINE(AIX_TIMERS) - AC_DEFINE(_PR_NO_LARGE_FILES) - AC_DEFINE(AIX4_1) - MKSHLIB= - DSO_LDOPTS= - ;; - aix4.2*) - AC_DEFINE(AIX_TIMERS) - AC_DEFINE(_PR_HAVE_OFF64_T) - ;; - aix4.3*) - AC_DEFINE(AIX_TIMERS) - AC_DEFINE(_PR_HAVE_OFF64_T) - AC_DEFINE(AIX4_3) - AC_DEFINE(HAVE_SOCKLEN_T) - AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) - USE_IPV6=1 - ;; - *) - AC_DEFINE(AIX_TIMERS) - AC_DEFINE(_PR_HAVE_OFF64_T) - AC_DEFINE(HAVE_SOCKLEN_T) - AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) - USE_IPV6=1 - ;; - esac - CFLAGS="$CFLAGS -qro -qroconst" - if echo "$CC" | grep -c xlC_r; then - CFLAGS="$CFLAGS -qarch=com" - fi - AIX_WRAP='$(DIST)/lib/aixwrap.o' - AIX_TMP='./_aix_tmp.o' - if test -n "$USE_64"; then - OBJECT_MODE=64 - fi - RESOLVE_LINK_SYMBOLS=1 - ;; - -*-beos*) - AC_DEFINE(XP_BEOS) - AC_DEFINE(BeOS) - AC_DEFINE(BEOS) - AC_DEFINE(_POSIX_SOURCE) - DSO_LDOPTS=-nostart - USE_BTHREADS=1 - RESOLVE_LINK_SYMBOLS=1 - case "${target_cpu}" in - i*86) - _OPTIMIZE_FLAGS=-O2 - _DEBUG_FLAGS='-gdwarf-2 -O0' - MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@' - AC_CHECK_LIB(bind, gethostbyaddr, [OS_LIBS="$OS_LIBS -lbind -lsocket"]) - ;; - powerpc) - CC=mwcc - CCC=mwcc - LD=mwld - DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o' - _OPTIMIZE_FLAGS=-O2 - _DEBUG_FLAGS='-g -O0' - ;; - esac - ;; - -*-bsdi*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(BSDI) - AC_DEFINE(NEED_BSDREGEX) - - CFLAGS="$CFLAGS -Wall -Wno-format" - CXXFLAGS="$CXXFLAGS -Wall -Wno-format" - - if echo "$OS_TEST" | grep -c 86 >/dev/null; then - CPU_ARCH=x86 - elif echo "$OS_TEST" | grep -c sparc >/dev/null; then - CPU_ARCH=sparc - fi - - DSO_LDOPTS=-r - - case "$target_os" in - bsdi1.1*) - AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY) - AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME) - AC_DEFINE(_PR_NEED_H_ERRNO) - MKSHLIB= - DSO_CFLAGS= - DSO_LDOPTS= - ;; - - bsdi2.1*) - AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC) - AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY) - AC_DEFINE(HAVE_DLL) - AC_DEFINE(USE_DLFCN) - AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC) - ;; - - bsdi4.*) - AC_DEFINE(_PR_SELECT_CONST_TIMEVAL) - AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT) - AC_DEFINE(HAVE_DLL) - AC_DEFINE(USE_DLFCN) - AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC) - MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)' - DSO_CFLAGS=-fPIC - DSO_LDOPTS='-shared -soname $(@:$(OBJDIR)/%.so=%.so)' - STRIP="$STRIP -d" - case "$target_os" in - bsdi4.2*) - AC_DEFINE(_PR_HAVE_GETPROTO_R) - AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER) - ;; - esac - ;; - *) - AC_DEFINE(_PR_SELECT_CONST_TIMEVAL) - AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT) - AC_DEFINE(HAVE_DLL) - AC_DEFINE(USE_DLFCN) - AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC) - ;; - esac - - ;; - -*-darwin*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(DARWIN) - AC_DEFINE(HAVE_BSD_FLOCK) - CFLAGS="$CFLAGS -Wmost -fno-common" - case "${target_cpu}" in - i*86*) - AC_DEFINE(i386) - CPU_ARCH=i386 - ;; - *) - AC_DEFINE(ppc) - CPU_ARCH=ppc - ;; - esac - DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@' - # Use the standard preprocessor (cpp) - CFLAGS="$CFLAGS -no-cpp-precomp" - MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' - STRIP="$STRIP -x -S" - DLL_SUFFIX=dylib - USE_PTHREADS=1 - - dnl MACOS_SDK_DIR will be set to the SDK location whenever one is - dnl in use. NEXT_ROOT will be set and exported if it's needed for - dnl ld. - - if test "$MACOS_SDK_DIR"; then - dnl Sync this section with the one in Mozilla's top level. - if test ! -d "$MACOS_SDK_DIR"; then - AC_MSG_ERROR([SDK not found. When using --with-macos-sdk, you must -specify a valid SDK. SDKs are installed when the optional cross-development -tools are selected during the Xcode/Developer Tools installation.]) - fi - - changequote(,) - CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'` - GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'` - GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'` - changequote([,]) - GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'` - if test "$GCC_VERSION_MAJOR" -lt "4" ; then - SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks" - if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then - SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks" - fi - - SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}" - - CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}" - - dnl CPP needs to be set for AC_CHECK_HEADER. - CPP="$CPP -nostdinc ${SDK_C_INCLUDE}" - - dnl ld support for -syslibroot is compiler-agnostic, but only - dnl available on Tiger. Although it's possible to switch on - dnl the build host's OS release to use ld -syslibroot when - dnl available, ld -syslibroot cause warnings as long as - dnl NEXT_ROOT is set. NEXT_ROOT should be set because both - dnl both the compiler and linker use it. - dnl - dnl LDFLAGS is for the utilities built in config (now and - dnl nsinstall). DSO_LDOPTS is used when linking shared - dnl libraries. - MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}" - LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS" - DSO_LDOPTS="${MACOS_SDK_LIBS} $DSO_LDOPTS" - export NEXT_ROOT=$MACOS_SDK_DIR - - if test -n "$CROSS_COMPILE" ; then - dnl NEXT_ROOT will be in the environment, but it - dnl shouldn't be set for the build host. HOST_CXX is - dnl presently unused. - HOST_CC="NEXT_ROOT= $HOST_CC" - HOST_CXX="NEXT_ROOT= $HOST_CXX" - fi - else - dnl gcc >= 4.0 uses different paths than above, but knows - dnl how to find them itself. - CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}" - - dnl CPP needs to be set for AC_CHECK_HEADER. - CPP="$CPP -isysroot ${MACOS_SDK_DIR}" - - dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which - dnl has an ld that supports -syslibroot. Don't set - dnl NEXT_ROOT because it will be ignored and cause - dnl warnings when -syslibroot is specified. - dnl - dnl Both LDFLAGS and DSO_LDOPTS are set here, see the - dnl gcc < 4.0 case for the explanation. - if test "$GCC_VERSION_FULL" != "4.0.0" ; then - dnl gcc > 4.0.0 will pass -syslibroot to ld automatically - dnl based on the -isysroot it receives. - LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}" - DSO_LDOPTS="$DSO_LDOPTS -isysroot ${MACOS_SDK_DIR}" - else - dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs - dnl to be explicit. - LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}" - DSO_LDOPTS="$DSO_LDOPTS -Wl,-syslibroot,${MACOS_SDK_DIR}" - fi - fi - fi - ;; - -*-dgux*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(_PR_LOCAL_THREADS_ONLY) - AC_DEFINE(SVR4) - AC_DEFINE(SYSV) - AC_DEFINE(DGUX) - AC_DEFINE(_DGUX_SOURCE) - AC_DEFINE(_POSIX4A_DRAFT6_SOURCE) - DSO_LDOPTS=-G - _OPTIMIZE_FLAGS=-O2 - _DEBUG_FLAGS= - ;; - -*-freebsd*) - if test -z "$USE_NSPR_THREADS"; then - USE_PTHREADS=1 - fi - AC_DEFINE(XP_UNIX) - AC_DEFINE(FREEBSD) - AC_DEFINE(HAVE_BSD_FLOCK) - CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall" - MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` - if test "$MOZ_OBJFORMAT" = "elf"; then - DLL_SUFFIX=so - else - DLL_SUFFIX=so.1.0 - fi - DSO_CFLAGS=-fPIC - DSO_LDOPTS=-Bshareable - ;; - -*-hpux*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(HPUX) - AC_DEFINE(_HPUX_SOURCE) - if test "$OS_TEST" = "ia64" ; then - AC_DEFINE(ia64) - DLL_SUFFIX=so - else - AC_DEFINE(hppa) - DLL_SUFFIX=sl - fi - DSO_LDOPTS='-b +h $(notdir $@)' - if test -z "$GNU_CC"; then - CC="$CC -Ae" - CXX="$CXX -ext" - if test "$OS_RELEASE" = "B.11.23"; then - CFLAGS="$CFLAGS +Olit=all" - CXXFLAGS="$CXXFLAGS +Olit=all" - else - CFLAGS="$CFLAGS +ESlit" - CXXFLAGS="$CXXFLAGS +ESlit" - fi - DSO_CFLAGS=+Z - else - DSO_CFLAGS=-fPIC - fi - - if test -n "$MOZILLA_CLIENT"; then - DEFAULT_IMPL_STRATEGY=_EMU - fi - - if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then - AC_DEFINE(_PR_NEED_H_ERRNO) - AC_DEFINE(HPUX9) - DEFAULT_IMPL_STRATEGY=_EMU - USE_NSPR_THREADS=1 - fi - - if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then - AC_DEFINE(_PR_NO_LARGE_FILES) - fi - - if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then - AC_DEFINE(_PR_NEED_H_ERRNO) - fi - - if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then - AC_DEFINE(HAVE_INT_LOCALTIME_R) - fi - - if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00|B.11.11|B.11.23)' >/dev/null; then - AC_DEFINE(HAVE_POINTER_LOCALTIME_R) - fi - - if test "$OS_RELEASE" = "B.10.01"; then - AC_DEFINE(HPUX10) - DEFAULT_IMPL_STRATEGY=_EMU - fi - - if test "$OS_RELEASE" = "B.10.10"; then - AC_DEFINE(HPUX10) - AC_DEFINE(HPUX10_10) - DEFAULT_IMPL_STRATEGY=_PTH - fi - - if test "$OS_RELEASE" = "B.10.20"; then - AC_DEFINE(HPUX10) - AC_DEFINE(HPUX10_20) - if test -z "$GNU_CC"; then - CFLAGS="$CFLAGS +DAportable +DS1.1" - CXXFLAGS="$CXXFLAGS +DAportable +DS1.1" - fi - DEFAULT_IMPL_STRATEGY=_PTH - fi - - if test "$OS_RELEASE" = "B.10.30"; then - AC_DEFINE(HPUX10) - AC_DEFINE(HPUX10_30) - if test -z "$GNU_CC"; then - CFLAGS="$CFLAGS +DAportable +DS1.1" - CXXFLAGS="$CXXFLAGS +DAportable +DS1.1" - fi - DEFAULT_IMPL_STRATEGY=_PTH - fi - - if echo "$OS_RELEASE" | egrep '^(B.11.00|B.11.11)' >/dev/null; then - AC_DEFINE(HPUX10) - AC_DEFINE(HPUX11) - AC_DEFINE(_LARGEFILE64_SOURCE) - AC_DEFINE(_PR_HAVE_OFF64_T) - AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) - if test -z "$GNU_CC"; then - if test -z "$USE_64"; then - CFLAGS="$CFLAGS +DAportable +DS2.0" - CXXFLAGS="$CXXFLAGS +DAportable +DS2.0" - else - CFLAGS="$CFLAGS +DA2.0W +DS2.0" - CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0" - fi - fi - DEFAULT_IMPL_STRATEGY=_PTH - fi - - if test "$OS_RELEASE" = "B.11.23"; then - AC_DEFINE(HPUX10) - AC_DEFINE(HPUX11) - AC_DEFINE(_LARGEFILE64_SOURCE) - AC_DEFINE(_PR_HAVE_OFF64_T) - AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) - if test -z "$GNU_CC"; then - if test -z "$USE_64"; then - CFLAGS="$CFLAGS +DD32" - CXXFLAGS="$CXXFLAGS +DD32" - else - CFLAGS="$CFLAGS +DD64" - CXXFLAGS="$CXXFLAGS +DD64" - fi - fi - DEFAULT_IMPL_STRATEGY=_PTH - fi - - if test "$DEFAULT_RPATHFLAG" = "$RPATHFLAG" ; then - if test "$OS_RELEASE" = "B.11.23" -o "$OS_RELEASE" = "B.11.11" ; then - # add ORIGIN to default rpath - RPATHFLAG="\\\$\$ORIGIN/../lib:\\\$\$ORIGIN/../../lib:$RPATHFLAG" - fi - fi - - if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then - USE_NSPR_THREADS=1 - USE_PTHREADS= - USE_USER_THREADS= - elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then - USE_PTHREADS=1 - if test "$USE_NSPR_THREADS"; then - USE_PTHREADS= - fi - if test "$USE_USER_PTHREADS"; then - USE_PTHREADS= - fi - fi - - ;; - -*-irix*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(IRIX) - AC_DEFINE(SVR4) - AC_DEFINE(_SGI_MP_SOURCE) - AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) - DSO_LDOPTS='-rdata_shared -shared' - MKSHLIB='$(LD) $(DSO_LDOPTS) -soname $(notdir $@) -o $@' - STRIP="$STRIP -f" - RESOLVE_LINK_SYMBOLS=1 - case "${target_os}" in - irix6*) - AC_DEFINE(IRIX6) - USE_PTHREADS=1 - USE_N32=1 - ;; - irix5*) - AC_DEFINE(IRIX5) - USE_NSPR_THREADS=1 - ;; - *) - USE_PTHREADS=1 - USE_N32=1 - ;; - esac - if test "$GNU_CC"; then - dnl - dnl If we are using gcc with native binutils, we need to - dnl suppress the - dnl #lineno "filename" num num - dnl lines, which confuse IRIX native as. Add -Wp,-P to the - dnl gcc command line, which passes -P to the preprocessor. - dnl - AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)' - CFLAGS="$CFLAGS -Wall -Wno-format" - _OPTIMIZE_FLAGS="-O6" - else - if test -n "$USE_N32"; then - AS='as -D_ASM $(INCLUDES) -n32' - else - AS='as -D_ASM $(INCLUDES)' - fi - CFLAGS="$CFLAGS -fullwarn -xansi" - if test "$USE_N32"; then - _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000" - else - _OPTIMIZE_FLAGS="-O -Olimit 4000" - fi - if test "$USE_MDUPDATE"; then - CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" - fi - case "$target}" in - *-irix6.*) - CFLAGS="$CFLAGS -multigot" - DSO_LDOPTS="$DSO_LDOPTS -no_unresolved" - if test "$USE_N32"; then - CFLAGS="$CFLAGS -n32 -woff 1209" - DSO_LDOPTS="$DSO_LDOPTS -n32" - else - if test "$USE_64"; then - CFLAGS="$CFLAGS -64" - else - CFLAGS="$CFLAGS -32" - fi - fi - ;; - *) - CFLAGS="$CFLAGS -xgot" - ;; - esac - fi - if test "${target_os}" = "irix5.3"; then - AC_DEFINE(IRIX5_3) - fi - case "${target_os}" in - irix6.5) - if test -z "$GNU_CC"; then - CFLAGS="$CFLAGS -mips3" - fi - AC_DEFINE(_PR_HAVE_GETPROTO_R) - AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER) - AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK) - ;; - irix5*) - ;; - *) - AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK) - ;; - esac - ;; - -*-linux*) - if test -z "$USE_NSPR_THREADS"; then - USE_PTHREADS=1 - fi - AC_DEFINE(XP_UNIX) - AC_DEFINE(_POSIX_SOURCE) - AC_DEFINE(_BSD_SOURCE) - AC_DEFINE(_SVID_SOURCE) - AC_DEFINE(_LARGEFILE64_SOURCE) - AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) - AC_DEFINE(LINUX) - AC_DEFINE(linux) - LD='$(CC)' - CFLAGS="$CFLAGS -ansi -Wall" - CXXFLAGS="$CXXFLAGS -ansi -Wall" - MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' - DSO_CFLAGS=-fPIC - DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' - OS_LIBS="$OS_LIBS -lc" - _OPTIMIZE_FLAGS=-O2 - _DEBUG_FLAGS="-g -fno-inline" # most people on linux use gcc/gdb, and that - # combo is not yet good at debugging inlined - # functions (even when using DWARF2 as the - # debugging format) - if echo "$OS_TEST" | grep -c 86 >/dev/null; then - CPU_ARCH=x86 - else - CPU_ARCH=$OS_TEST - fi - case "${target_cpu}" in - alpha) - AC_DEFINE(_ALPHA_) - AC_DEFINE(__alpha) - CFLAGS="$CFLAGS -mieee" - CXXFLAGS="$CXXFLAGS -mieee" - ;; - i*86) - AC_DEFINE(i386) - ;; - ia64) - ;; - m68k) - CFLAGS="$CFLAGS -m68020-40" - CXXFLAGS="$CXXFLAGS -m68020-40" - # - # gcc on Linux/m68k either has a bug or triggers a code-sequence - # bug in the 68060 which causes gcc to crash. The simplest way to - # avoid this is to enable a minimum level of optimization. - # - _DEBUG_FLAGS="$_DEBUG_FLAGS -O" - ;; - esac - ;; - -*-mingw*|*-cygwin*|*-msvc*|*-mks*) - AC_DEFINE(XP_PC) - AC_DEFINE(WIN32) - AC_DEFINE(_WINDOWS) - RESOLVE_LINK_SYMBOLS=1 - PROG_SUFFIX=.exe - if test -n "$GNU_CC"; then - CC="$CC -mno-cygwin" - CXX="$CXX -mno-cygwin" - DLL_SUFFIX=dll - MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) -o $@' - # Use temp file for windres (bug 213281) - RC="$WINDRES -O coff --use-temp-file" - else - CYGWIN_WRAPPER='sh $(topsrcdir)/config/cygwin-wrapper' - CC=cl - CXX=cl - LD=link - # if the lib program is available, use it, otherwise use link /lib - AC_CHECK_PROG(HAVE_MSVC_LIB, lib, 1) - if test "$HAVE_MSVC_LIB" = "1" ; then - AR='lib -NOLOGO -OUT:"$@"' - else - AR='$(LD) /lib -NOLOGO -OUT:"$@"' - fi - - AR_FLAGS= - RANLIB='echo not_ranlib' - STRIP='echo not_strip' - RC='$(CYGWIN_WRAPPER) rc.exe' - GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb' - OBJ_SUFFIX=obj - LIB_SUFFIX=lib - LIB_PREFIX= - DLL_SUFFIX=dll - - CFLAGS="$CFLAGS -W3 -nologo -GF -Gy" - DLLFLAGS='-OUT:"$@"' - _DEBUG_FLAGS=-Z7 - _OPTIMIZE_FLAGS=-O2 - if test -z "$MOZ_OPTIMIZE"; then - CFLAGS="$CFLAGS -Od" - fi - - if test -n "$USE_DEBUG_RTL"; then - CFLAGS="$CFLAGS -MDd" - else - CFLAGS="$CFLAGS -MD" - fi - - if test -n "$MOZ_DEBUG"; then - AC_DEFINE(_DEBUG) - else - DEFINES="$DEFINES -U_DEBUG" - fi - - if test -n "$MOZ_OPTIMIZE"; then - if test -n "$MOZ_PROFILE"; then - _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Z7" - fi - if test -n "$MOZ_DEBUG_SYMBOLS"; then - _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Zi" - fi - if test -n "$MOZ_PROFILE" -o -n "$MOZ_DEBUG_SYMBOLS"; then - DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF" - LDFLAGS="$LDFLAGS -DEBUG -OPT:REF" - fi - fi - - if test -n "$MOZ_DEBUG"; then - DLLFLAGS="$DLLFLAGS -DEBUG" - LDFLAGS="$LDFLAGS -DEBUG" - fi - - if test "$OS_TARGET" = "WINNT"; then - CFLAGS="$CFLAGS -GT" - if test "$CPU_ARCH" = "x86"; then - CFLAGS="$CFLAGS -G5" - fi - fi - fi # GNU_CC - - if test -n "$USE_STATIC_TLS"; then - AC_DEFINE(_PR_USE_STATIC_TLS) - fi - - if test "$OS_TARGET" = "WINNT"; then - AC_DEFINE(WINNT) - else - AC_DEFINE(WIN95) - # undefine WINNT as some versions of mingw gcc define it by default - DEFINES="$DEFINES -UWINNT" - AC_DEFINE(_PR_GLOBAL_THREADS_ONLY) - fi - - OS_DLLFLAGS='-nologo -DLL -SUBSYSTEM:WINDOWS -PDB:NONE' - - case "$OS_TARGET" in - WINNT) - ;; - WIN95) - ;; - WIN16) - ;; - *) - AC_MSG_ERROR([Missing OS_TARGET for ${target}. Use --enable-win32-target to set.]) - ;; - esac - - case "$target_cpu" in - i*86) - AC_DEFINE(_X86_) - ;; - alpha) - AC_DEFINE(_ALPHA_) - ;; - mips) - AC_DEFINE(_MIPS_) - ;; - *) - AC_DEFINE(_CPU_ARCH_NOT_DEFINED) - ;; - esac - - ;; - -*-ncr-sysv*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(SVR4) - AC_DEFINE(SYSV) - AC_DEFINE(NCR) - USE_NSPR_THREADS=1 - if test "$OS_RELEASE" = "2.03"; then - AC_DEFINE(_PR_STAT_HAS_ST_ATIM) - else - AC_DEFINE(_PR_STAT_HAS_ST_ATIM_UNION) - fi - - if test -z "$GNU_CC"; then - CFLAGS="$CFLAGS -Hnocopyr" - CXXFLAGS="$CXXFLAGS -Hnocopyr" - else - CFLAGS="$CFLAGS -fPIC -Wall" - CXXFLAGS="$CXXFLAGS -fPIC -Wall" - DSO_LDOPTS=-G - fi - ;; - -mips-nec-sysv*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(SVR4) - AC_DEFINE(__SVR4) - AC_DEFINE(NEC) - AC_DEFINE(nec_ews) - USE_NSPR_THREADS=1 - if test -z "$GNU_CC"; then - CC='$(NSDEPTH)/build/hcc cc -Xa -KGnum=0 -KOlimit=4000' - CXX=g++ - fi - OS_LIBS="$OS_LIBS -lsocket -lnsl -ldl" - DSO_LDOPTS=-G - ;; - -*-netbsd*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(NETBSD) - AC_DEFINE(HAVE_BSD_FLOCK) - USE_NSPR_THREADS=1 - - DSO_CFLAGS='-fPIC -DPIC' - CFLAGS="$CFLAGS -ansi -Wall" - CXXFLAGS="$CXXFLAGS -ansi -Wall" - MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)' - - if test -z "$OBJECT_FMT"; then - if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then - OBJECT_FMT=a.out - DLL_SUFFIX=so.1.0 - DSO_LDOPTS='-shared' - else - OBJECT_FMT=ELF - DLL_SUFFIX=so - DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)' - fi - fi - - if test "$LIBRUNPATH"; then - DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH" - fi - ;; - -mips-sony-newsos*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(SONY) - AC_DEFINE(SYSV) - AC_DEFINE(SVR4) - AC_DEFINE(__svr4) - AC_DEFINE(__svr4__) - AC_DEFINE(HAVE_SVID_GETTOD) - USE_NSPR_THREADS=1 - CFLAGS="$CFLAGS -Xa -fullwarn" - CXXFLAGS="$CXXFLAGS -Xa -fullwarn" - DSO_LDOPTS=-G - ;; - -*-nextstep*|*-openstep*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(NEXTSTEP) - AC_DEFINE(HAVE_BSD_FLOCK) - AC_DEFINE(_POSIX_SOURCE) - CFLAGS="$CFLAGS -Wall -fno-common -traditional-cpp -posix" - CXXFLAGS="$CXXFLAGS -Wall -fno-common -traditional-cpp -posix" - USE_NSPR_THREADS=1 - DLL_SUFFIX=dylib - ;; - - -*-nto*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(NTO) - AC_DEFINE(_QNX_SOURCE) - AC_DEFINE(HAVE_POINTER_LOCALTIME_R) - MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@' - DSO_CFLAGS=-fPIC - DSO_LDOPTS=-shared - OS_LIBS="$OS_LIBS -lsocket" - _OPTIMIZE_FLAGS="-O1" - _DEBUG_FLAGS="-gstabs" - ;; - -*-openbsd*) - LD='$(CC)' - AC_DEFINE(XP_UNIX) - AC_DEFINE(OPENBSD) - AC_DEFINE(HAVE_BSD_FLOCK) - AC_DEFINE(HAVE_SOCKLEN_T) - CFLAGS="$CFLAGS -ansi -Wall" - CXXFLAGS="$CXXFLAGS -ansi -Wall" - DLL_SUFFIX=so.1.0 - DSO_CFLAGS=-fPIC - USE_NSPR_THREADS=1 - DSO_LDOPTS='-shared -fPIC' - ;; - -*-openvms*) - AC_DEFINE(XP_UNIX) - RESOLVE_LINK_SYMBOLS=1 - AR_FLAGS='c $@' - DSO_LDOPTS='-shared -auto_symvec $(LDFLAGS) $(OPTIMIZER)' - ;; - -*-os2*) - AC_DEFINE(XP_OS2) - AC_DEFINE(XP_PC) - AC_DEFINE(BSD_SELECT) - AC_DEFINE(_PR_GLOBAL_THREADS_ONLY) - RESOLVE_LINK_SYMBOLS=1 - NSINSTALL=nsinstall - LIB_PREFIX= - LIB_SUFFIX=lib - DLL_SUFFIX=dll - DLLTOOL='' - RC=rc.exe - PROG_SUFFIX=.exe - - # EMX/GCC build - if test -n "$GNU_CC"; then -# AC_DEFINE(USE_OS2_TOOLKIT_HEADERS) - AC_DEFINE(XP_OS2_EMX) - AC_DEFINE(OS2) - AC_DEFINE(TCPV40HDRS) - AR=emxomfar - AR_FLAGS='r $@' - LD='$(CC)' - CFLAGS="$CFLAGS -Wall -Zomf" - CXXFLAGS="$CFLAGS -Wall -Zomf" - MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' - DSO_CFLAGS= - DSO_LDOPTS='-Zomf -Zdll' - _OPTIMIZE_FLAGS=-O3 - _DEBUG_FLAGS="-g -fno-inline" - if test -n "$MOZ_OPTIMIZE"; then - DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA" - fi - OS_LIBS="-lsocket" - IMPLIB='emximp -o' - FILTER='emxexp -o' - if test -n "$MOZ_OS2_HIGH_MEMORY"; then - DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem" - LDFLAGS="$LDFLAGS -Zhigh-mem" - AC_DEFINE(MOZ_OS2_HIGH_MEMORY) - fi - - # GCC for OS/2 currently predefines these, but we don't want them - DEFINES="$DEFINES -Uunix -U__unix -U__unix__" - - # Visual Age C++ build - elif test "$VACPP" = "yes"; then - MOZ_BUILD_ROOT=`pwd -D` - AC_DEFINE(XP_OS2_VACPP) - AC_DEFINE(OS2,4) - AC_DEFINE(TCPV40HDRS) - AC_DEFINE(_X86_) - OBJ_SUFFIX=obj - AS=alp - ASFLAGS='-Mb' - ASM_SUFFIX=asm - AR=ilib - AR_FLAGS='/NOL /NOI /O:$(subst /,\\,$@)' - CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' - HOST_CFLAGS="$CFLAGS" - OS_CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' - OS_EXE_CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' - CXXFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' - OS_LIBS='so32dll.lib tcp32dll.lib' - LD='-ilink' - MKSHLIB='$(LD) $(DSO_LDOPTS)' - IMPLIB='implib -nologo -noignorecase' - FILTER='cppfilt -q -B -P' - _OPTIMIZE_FLAGS='/O+ /Gl+ /Gx+ /qtune=pentium /qarch=pentium' - _DEBUG_FLAGS='/Ti+ ' - LDFLAGS='/NOL /M /L' - DLLFLAGS='/O:$@ /DLL /INC:_dllentry /MAP:$(@:.dll=.map) /L /NOL' - EXEFLAGS='/OUT:$@ /PMTYPE:VIO /MAP:$(@:.exe=.map) /L /NOL' - if test -n "$MOZ_DEBUG"; then - LDFLAGS="$LDFLAGS /DE" - DLLFLAGS="$DLLFLAGS /DE" - EXEFLAGS="$EXEFLAGS /DE" - fi - if test -n "$MOZ_OPTIMIZE"; then - LDFLAGS="$LDFLAGS /OPTFUNC /EXEPACK:2 /PACKCODE /PACKDATA" - DLLFLAGS="$DLLFLAGS /OPTFUNC /EXEPACK:2 /PACKCODE /PACKDATA" - EXEFLAGS="$EXEFLAGS /OPTFUNC /EXEPACK:2 /PACKCODE /PACKDATA" - fi - fi - ;; - -*-osf*) - SHELL_OVERRIDE="SHELL = /usr/bin/ksh" - AC_DEFINE(XP_UNIX) - AC_DEFINE(OSF1) - AC_DEFINE(_REENTRANT) - AC_CHECK_HEADER(machine/builtins.h, AC_DEFINE(OSF1_HAVE_MACHINE_BUILTINS_H)) - - if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then - USE_NSPR_THREADS=1 - fi - - if test -z "$GNU_CC"; then - CC="$CC -std1 -ieee_with_inexact" - if test "$OS_RELEASE" != "V2.0"; then - CC="$CC -readonly_strings" - fi - _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000" - fi - - if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then - AC_DEFINE(HAVE_INT_LOCALTIME_R) - else - AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) - AC_DEFINE(HAVE_POINTER_LOCALTIME_R) - fi - if echo $OS_RELEASE | grep -c V4.0 >/dev/null; then - AC_DEFINE(OSF1V4_MAP_PRIVATE_BUG) - fi - DSO_LDOPTS='-shared -all -expect_unresolved "*" -soname $(notdir $@)' - ;; - -*-qnx*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(QNX) - AC_DEFINE(_PR_NEED_H_ERRNO) - USE_NSPR_THREADS=1 - ;; - -*-*-sco*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(SCO) - AC_DEFINE(sco) - AC_DEFINE(SYSV) - AC_DEFINE(_SVID3) - AC_DEFINE(_PR_NEED_H_ERRNO) - CC='cc -b elf -KPIC' - CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w' - USE_NSPR_THREADS=1 - CPU_ARCH=x86 - DSO_LDOPTS='-b elf -G' - ;; - -*-sinix*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(SVR4) - AC_DEFINE(SNI) - AC_DEFINE(RELIANTUNIX) - AC_DEFINE(sinix) - AC_DEFINE(HAVE_SVID_GETTOD) - if echo "$OS_TEST" | grep -c 86 2>/dev/null; then - AC_DEFINE(i386) - CPU_ARCH=x86 - else - CPU_ARCH=mips - fi - - if test "$GNU_CC"; then - AS='$(CC) -x assembler-with-cpp' - if test "$CPU_ARCH" = "mips"; then - LD=gld - fi - CFLAGS="$CFLAGS -Wall -Wno-format" - else - AS='/usr/bin/cc' - _OPTIMIZE_FLAGS='-O -F Olimit,4000' - fi - - DSO_LDOPTS='-G -z defs -h $(@:$(OBJDIR)/%.so=%.so)' - - if test "$OS_RELEASE" = "5.43"; then - AC_DEFINE(IP_MULTICAST) - fi - - OS_LIBS="$OS_LIBS -lsocket -lnsl -lresolv -ldl -lc" - USE_NSPR_THREADS=1 - ;; - -*-sunos*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(SUNOS4) - CFLAGS="$CFLAGS -Wall -Wno-format" - if test "$USE_MDUPDATE"; then - CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" - fi - CPU_ARCH=sparc - DLL_SUFFIX=so.1.0 - DSO_LDOPTS= - DSO_CFLAGS=-fPIC - USE_NSPR_THREADS=1 - if test "$OS_RELEASE" = "4.1.3_U1"; then - _OPTIMIZE_FLAGS= - OS_LIBS="$OS_LIBS -lm" - fi - ;; - -*-solaris*) - if test -z "$USE_USER_THREADS" && test -z "$USE_NATIVE_THREADS"; then - USE_PTHREADS=1 - fi - AC_DEFINE(XP_UNIX) - AC_DEFINE(SVR4) - AC_DEFINE(SYSV) - AC_DEFINE(__svr4) - AC_DEFINE(__svr4__) - AC_DEFINE(SOLARIS) - AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) - if test -n "$GNU_CC" ; then - if test -n "$USE_64"; then - CC="$CC -m64" - CXX="$CXX -m64" - fi - LD='$(CC)' - DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' - DSO_CFLAGS=-fPIC - CFLAGS="$CFLAGS -Wall" - CXXFLAGS="$CXXFLAGS -Wall" - if test -n "$USE_MDUPDATE"; then - CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" - CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)" - fi - else - LD=/usr/ccs/bin/ld - RANLIB=/usr/ccs/bin/ranlib - DSO_LDOPTS='-G -h $(notdir $@)' - DSO_CFLAGS=-KPIC - if test -n "$USE_64"; then - if test "$OS_TEST" = "i86pc"; then - CC="$CC -xarch=amd64" - CXX="$CXX -xarch=amd64" - else - CC="$CC -xarch=v9" - CXX="$CXX -xarch=v9" - fi - fi - CC="$CC -xstrconst" - if test -z "$MOZ_OPTIMIZE"; then - CFLAGS="$CFLAGS -xs" - CXXFLAGS="$CXXFLAGS -xs" - fi - fi - if test "$DEFAULT_RPATHFLAG" = "$RPATHFLAG" ; then - # add origin stuff - RPATHFLAG="\\\$\$ORIGIN/../lib:\\\$\$ORIGIN/../../lib:$RPATHFLAG" - fi - if test -z "$GNU_AS"; then - ASFLAGS="$ASFLAGS -Wa,-P" - fi - if test "$OS_TEST" = "i86pc"; then - AC_DEFINE(i386) - - # The default debug format, DWARF (-g), is not supported by gcc - # on i386-ANY-sysv4/solaris, but the stabs format is. It is - # assumed that the Solaris assembler /usr/ccs/bin/as is used. - # If your gcc uses GNU as, you do not need the -Wa,-s option. - if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then - _DEBUG_FLAGS=-gstabs - if test -z "$GNU_AS"; then - _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s" - fi - fi - fi - case "${target_os}" in - solaris2.3*) - AC_DEFINE(_PR_NO_LARGE_FILES) - ;; - solaris2.4*) - AC_DEFINE(_PR_NO_LARGE_FILES) - ;; - solaris2.5*) - AC_DEFINE(SOLARIS2_5) - ;; - *) - AC_DEFINE(_PR_HAVE_OFF64_T) - # The lfcompile64(5) man page on Solaris 2.6 says: - # For applications that do not wish to conform to the POSIX or - # X/Open specifications, the 64-bit transitional interfaces - # are available by default. No compile-time flags need to be - # set. - # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default. - # The native compiler, gcc 2.8.x, and egcs don't have this problem. - if test -n "$GNU_CC"; then - AC_DEFINE(_LARGEFILE64_SOURCE) - fi - ;; - esac - if test "$OS_TEST" = "sun4u"; then - # 64-bit Solaris requires SPARC V9 architecture, so the following - # is not needed. - if test -z "$USE_64"; then - ULTRASPARC_LIBRARY=ultrasparc - ULTRASPARC_FILTER_LIBRARY=libatomic.so - DSO_LDOPTS="$DSO_LDOPTS -f "'$(ULTRASPARC_FILTER_LIBRARY)' - fi - fi - ;; - -*-sco-sysv5*) - AC_DEFINE(XP_UNIX) - AC_DEFINE(UNIXWARE) - AC_DEFINE(SVR4) - AC_DEFINE(SYSV) - USE_NSPR_THREADS=1 - if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then - AC_DEFINE(_PR_NO_LARGE_FILES) - CC='$(NSDEPTH)/build/hcc cc' - CXX='$(NSDEPTH)/build/hcpp CC' - else - AC_DEFINE(_LARGEFILE64_SOURCE) - AC_DEFINE(_PR_HAVE_OFF64_T) - AC_DEFINE(_PR_HAVE_SOCKADDR_LEN) - fi - DSO_LDOPTS=-G - CPU_ARCH=x86 - ;; - -*) - AC_DEFINE(XP_UNIX) - ;; - -esac - -if test -z "$SKIP_LIBRARY_CHECKS"; then -dnl ======================================================== -dnl Check for system libraries -dnl ======================================================== -dnl AC_CHECK_LIB(C, main) -dnl AC_CHECK_LIB(C_r, main) -dnl AC_CHECK_LIB(c, main) -dnl AC_CHECK_LIB(c_r, main) -dnl AC_CHECK_LIB(dce, main) -dnl AC_CHECK_LIB(dl, main) -dnl AC_CHECK_LIB(dld, main) -dnl AC_CHECK_LIB(gen, main) -dnl AC_CHECK_LIB(ip6, main) -dnl AC_CHECK_LIB(l, main) -dnl AC_CHECK_LIB(m, main) -dnl AC_CHECK_LIB(nsl, main) -dnl AC_CHECK_LIB(posix4, main) -dnl AC_CHECK_LIB(prstrms, main) -dnl AC_CHECK_LIB(prstrms_shr, main) -dnl AC_CHECK_LIB(pthread, main) -dnl AC_CHECK_LIB(pthreads, main) -dnl AC_CHECK_LIB(resolv, main) -dnl AC_CHECK_LIB(rt, main) -dnl AC_CHECK_LIB(socket, main) -dnl AC_CHECK_LIB(svld, main) -dnl AC_CHECK_LIB(thread, main) -dnl AC_CHECK_LIB(vms_jackets, main) - -AC_CHECK_FUNC(dlopen,,[ - AC_CHECK_LIB(dl, dlopen, [OS_LIBS="-ldl $OS_LIBS"]) -]) - -dnl ======================================================== -dnl Check for system header files. -dnl ======================================================== -dnl AC_HEADER_DIRENT -dnl AC_HEADER_STDC -dnl AC_HEADER_SYS_WAIT -dnl AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/ioctl.h sys/time.h unistd.h) - -dnl ======================================================== -dnl Check for typedefs and structs -dnl ======================================================== -dnl AC_C_CONST -dnl AC_TYPE_UID_T -dnl AC_TYPE_MODE_T -dnl AC_TYPE_OFF_T -dnl AC_TYPE_PID_T -dnl AC_TYPE_SIZE_T -dnl AC_STRUCT_ST_BLKSIZE -dnl AC_STRUCT_ST_BLOCKS -dnl AC_STRUCT_ST_RDEV -dnl AC_HEADER_TIME -dnl AC_STRUCT_TM - -dnl ======================================================== -dnl Checks for library functions. -dnl ======================================================== -AC_PROG_GCC_TRADITIONAL -AC_CHECK_FUNCS(lchown strerror getaddrinfo getnameinfo) - -dnl AC_FUNC_MEMCMP -dnl AC_FUNC_MMAP -dnl AC_FUNC_SETVBUF_REVERSED -dnl AC_FUNC_STRCOLL -dnl AC_FUNC_STRFTIME -dnl AC_FUNC_UTIME_NULL -dnl AC_FUNC_VPRINTF -dnl AC_CHECK_FUNCS(ftime getcwd gethostname gettimeofday getwd mkdir mktime putenv rmdir select socket strdup strerror strstr strtol strtoul uname) - -dnl ======================================================== -dnl Check options -dnl ======================================================== - -dnl ======================================================== -dnl = -dnl = --enable-strip -dnl = -dnl = Enable stripping of libs and executables -dnl = -dnl ======================================================== -AC_ARG_ENABLE(strip, -[ --enable-strip Enable stripping of shared libs and programs], - [ ENABLE_STRIP=1 ]) - -dnl -dnl Apparently, some systems cannot properly check for the pthread -dnl library unless <pthread.h> is included so we need to test -dnl using it -dnl -dnl MOZ_CHECK_PTHREADS(lib, success, failure) -AC_DEFUN(MOZ_CHECK_PTHREADS, -[ -AC_MSG_CHECKING([for pthread_create in -l$1]) -echo " - #include <pthread.h> - void *foo(void *v) { int a = 1; } - int main() { - pthread_t t; - if (!pthread_create(&t, 0, &foo, 0)) { - pthread_join(t, 0); - } - exit(0); - }" > dummy.c ; - echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5; - ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5; - _res=$? ; - rm -f dummy.c dummy${ac_exeext} ; - if test "$_res" = "0"; then - AC_MSG_RESULT([yes]) - [$2] - else - AC_MSG_RESULT([no]) - [$3] - fi -]) - -MOZ_CHECK_PTHREADS(pthreads, - _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads", - MOZ_CHECK_PTHREADS(pthread, - _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread", - MOZ_CHECK_PTHREADS(c_r, - _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r", - MOZ_CHECK_PTHREADS(c, - _HAVE_PTHREADS=1 - ) - ) - ) -) - -AC_ARG_WITH(pthreads, - [ --with-pthreads Use system pthreads library as thread subsystem], - [ if test "$withval" = "yes"; then - if test -n "$_HAVE_PTHREADS"; then - USE_PTHREADS=1 - USE_USER_PTHREADS= - USE_NSPR_THREADS= - else - AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]); - fi - else - USE_PTHREADS= - _PTHREAD_LDFLAGS= - fi], - [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USER_NSPR_THREADS"; then - USE_PTHREADS=1 - USE_USER_PTHREADS= - USE_NSPR_THREADS= - fi]) - -AC_ARG_ENABLE(user-pthreads, - [ --enable-user-pthreads Build using userland pthreads], - [ if test "$enableval" = "yes"; then - if test -n "$_HAVE_PTHREADS"; then - USE_PTHREADS= - USE_USER_PTHREADS=1 - USE_NSPR_THREADS= - else - AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]); - fi - fi]) - -AC_ARG_ENABLE(nspr-threads, - [ --enable-nspr-threads Build using classic nspr threads], - [ if test "$enableval" = "yes"; then - USE_PTHREADS= - USE_USER_PTHREADS= - USE_NSPR_THREADS=1 - fi]) - -case "$target" in -*-beos*) - AC_ARG_WITH(bthreads, - [ --with-bthreads Use system bthreads library as thread subsystem (BeOS only)], - [ if test "$withval" = "yes"; then - USE_BTHREADS=1 - USE_USER_PTHREADS= - USE_PTHREADS= - fi]) - ;; - -*-solaris*) - AC_ARG_WITH(native-threads, - [ --with-native-threads Use native system threads as thread subsystem (Solaris only)], - [ if test "$withval" = "yes"; then - USE_NATIVE_THREADS=1 - USE_USER_PTHREADS= - USE_PTHREADS= - fi]) - ;; -esac - -fi # SKIP_LIBRARY_CHECKS - -AC_ARG_ENABLE(cplus, - [ --enable-cplus Enable some c++ api routines], - [ if test "$enableval" = "yes"; then - USE_CPLUS=1 - fi]) - -AC_ARG_ENABLE(ipv6, - [ --enable-ipv6 Compile ipv6 support], - [ if test "$enableval" = "yes"; then - USE_IPV6=1 - fi]) - -dnl ======================================================== -dnl = check for sasl options -dnl = This has to come after we set all of the platform specific -dnl = compiler and linker flags -dnl ======================================================== -AM_PATH_GIVEN_SASL() - -if test -n "$USE_PTHREADS"; then - dnl See if -pthread is supported. - rm -f conftest* - ac_cv_have_dash_pthread=no - AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread) - echo 'int main() { return 0; }' | cat > conftest.c - ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1 - if test $? -eq 0; then - if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then - ac_cv_have_dash_pthread=yes - CFLAGS="$CFLAGS -pthread" - CXXFLAGS="$CXXFLAGS -pthread" - fi - fi - rm -f conftest* - AC_MSG_RESULT($ac_cv_have_dash_pthread) - - dnl - dnl See if -pthreads is supported. - dnl - ac_cv_have_dash_pthreads=no - if test "$ac_cv_have_dash_pthread" = "no"; then - AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads) - echo 'int main() { return 0; }' | cat > conftest.c - ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1 - if test $? -eq 0; then - if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then - ac_cv_have_dash_pthreads=yes - CFLAGS="$CFLAGS -pthreads" - CXXFLAGS="$CXXFLAGS -pthreads" - fi - fi - rm -f conftest* - AC_MSG_RESULT($ac_cv_have_dash_pthreads) - fi - - case "$target" in - *-solaris*) - if test "$ac_cv_have_dash_pthreads" = "yes"; then - _PTHREAD_LDFLAGS= - fi - ;; - *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*) - AC_DEFINE(_THREAD_SAFE) - dnl -pthread links in -lc_r, so don't specify it explicitly. - if test "$ac_cv_have_dash_pthread" = "yes"; then - _PTHREAD_LDFLAGS= - fi - ;; - *-linux*) - AC_DEFINE(_REENTRANT) - ;; - esac - -else - if test -n "$USE_USER_PTHREADS"; then - USE_PTHREADS= - USE_NSPR_THREADS= - else - _PTHREAD_LDFLAGS= - fi -fi -dnl Special thread exceptions - -case "$target" in -*-aix*) - if test -n "$USE_NSPR_THREADS"; then - AC_DEFINE(_PR_LOCAL_THREADS_ONLY) - fi - case "$target_os" in - aix4.1*) - if test -z "$USE_PTHREADS"; then - AC_DEFINE(AIX_RENAME_SELECT) - fi - ;; - aix4.2*) - if test -z "$USE_NSPR_THREADS"; then - AC_DEFINE(HAVE_POINTER_LOCALTIME_R) - fi - ;; - aix4.3*) - if test -z "$USE_NSPR_THREADS"; then - AC_DEFINE(HAVE_POINTER_LOCALTIME_R) - fi - if test -n "$USE_PTHREADS"; then - AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST) - fi - ;; - esac - ;; -*-bsdi*) - if test -n "$USE_PTHREADS"; then - AC_DEFINE(_PR_NEED_PTHREAD_INIT) - fi - ;; -*-freebsd*) - if test -n "$USE_NSPR_THREADS"; then - AC_DEFINE(_PR_LOCAL_THREADS_ONLY) - fi - ;; -*-hpux*) - if test -n "$USE_NSPR_THREADS"; then - AC_DEFINE(_PR_LOCAL_THREADS_ONLY) - fi - if test "$USE_PTHREADS"; then - if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then - AC_DEFINE(_REENTRANT) - AC_DEFINE(_PR_DCETHREADS) - else - AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L) - AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST) - fi - fi - if test "$USE_USER_PTHREADS"; then - AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L) - fi - ;; -*-irix*) - if test "${target_os}" = "irix6.5"; then - if test -n "$USE_PTHREADS"; then - AC_DEFINE(_PR_HAVE_GETHOST_R) - AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER) - fi - fi - ;; -*-linux*) - if test -n "$USE_NSPR_THREADS"; then - AC_DEFINE(_PR_LOCAL_THREADS_ONLY) - fi - ;; -*-mingw*|*-cygwin*|*-msvc*|*-mks*|*-os2*|*-beos*) - dnl win32, os2 & beos cannot use pthreads - USE_PTHREADS= - _PTHREAD_LDFLAGS= - USE_USER_PTHREADS= - ;; -*-netbsd*) - if test -n "$USE_NSPR_THREADS"; then - AC_DEFINE(_PR_LOCAL_THREADS_ONLY) - fi - ;; -*-osf*) - if test -n "$USE_NSPR_THREADS"; then - AC_DEFINE(_PR_LOCAL_THREADS_ONLY) - fi - if test -n "$USE_PTHREADS"; then - if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then - : - else - AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST) - fi - fi - ;; -*-solaris*) - if test -n "$USE_NATIVE_THREADS"; then - AC_DEFINE(_PR_GLOBAL_THREADS_ONLY) - else - if test -n "$USE_NSPR_THREADS"; then - AC_DEFINE(_PR_LOCAL_THREADS_ONLY) - fi - fi - if test -z "$USE_NSPR_THREADS"; then - AC_DEFINE(_REENTRANT) - AC_DEFINE(HAVE_POINTER_LOCALTIME_R) - fi - ;; -*-nto*) - if test -n "$USE_PTHREADS"; then - AC_DEFINE(_PR_HAVE_GETHOST_R) - AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER) - fi - ;; -esac - -OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS" - -dnl If the user passed in arg to --enable-optimize or --enable-debug, -dnl make sure that we use it. -if test -n "$_SAVE_OPTIMIZE_FLAGS"; then - _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS" -fi - -if test -n "$_SAVE_DEBUG_FLAGS"; then - _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS" -fi - -if test -n "$MOZ_OPTIMIZE"; then - CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS" - CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS" -fi - -if test -n "$MOZ_DEBUG"; then - CFLAGS="$CFLAGS $_DEBUG_FLAGS" - CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS" -fi - -dnl ======================================================== -dnl Use cygwin wrapper for win32 builds, except MinGW/MSYS -dnl ======================================================== -case "$target_os" in -cygwin*|msvc*|mks*) - CC="\$(CYGWIN_WRAPPER) $CC" - CXX="\$(CYGWIN_WRAPPER) $CXX" - RC="\$(CYGWIN_WRAPPER) $RC" - ;; -esac - -dnl ======================================================== -dnl Substitution of found variables. -dnl ======================================================== -AC_SUBST(SHELL_OVERRIDE) - -AC_SUBST(MOZILLA_CLIENT) -AC_SUBST(CC) -AC_SUBST(CXX) -AC_SUBST(CFLAGS) -AC_SUBST(CXXFLAGS) -AC_SUBST(CPPFLAGS) -AC_SUBST(HOST_CC) -AC_SUBST(HOST_CFLAGS) -AC_SUBST(LDFLAGS) -AC_SUBST(GNU_CC) -AC_SUBST(CROSS_COMPILE) - -AC_SUBST(MOZ_OPTIMIZE) - -AC_SUBST(USE_CPLUS) -AC_SUBST(USE_IPV6) -AC_SUBST(USE_N32) -AC_SUBST(USE_64) -AC_SUBST(OBJECT_MODE) -AC_SUBST(GC_LEAK_DETECTOR) -AC_SUBST(ENABLE_STRIP) - -AC_SUBST(USE_PTHREADS) -AC_SUBST(USE_BTHREADS) -AC_SUBST(USE_USER_PTHREADS) -AC_SUBST(USE_NATIVE_THREADS) -AC_SUBST(USE_NSPR_THREADS) -AC_SUBST(USE_NSS) -AC_SUBST(NSS_CFLAGS) -AC_SUBST(NSS_LIBS) - -AC_SUBST(CPU_ARCH) - -AC_SUBST(OBJ_SUFFIX) -AC_SUBST(LIB_SUFFIX) -AC_SUBST(LIB_PREFIX) -AC_SUBST(DLL_SUFFIX) -AC_SUBST(ASM_SUFFIX) -AC_SUBST(PROG_SUFFIX) -AC_SUBST(MKSHLIB) -AC_SUBST(DSO_CFLAGS) -AC_SUBST(DSO_LDOPTS) - -AC_SUBST(OS_TARGET) -AC_SUBST(OS_ARCH) -AC_SUBST(OS_RELEASE) -AC_SUBST(OS_TEST) - -AC_SUBST(DEFINES) -AC_SUBST(DEFS) -AC_SUBST(AR) -AC_SUBST(AR_FLAGS) -AC_SUBST(AS) -AC_SUBST(ASFLAGS) -AC_SUBST(LD) -AC_SUBST(WINDRES) -AC_SUBST(RANLIB) -AC_SUBST(PERL) -AC_SUBST(STRIP) -AC_SUBST(FILTER) -AC_SUBST(IMPLIB) - -AC_SUBST(OS_LIBS) -AC_SUBST(RESOLVE_LINK_SYMBOLS) -AC_SUBST(NOSUCHFILE) -AC_SUBST(MOZ_OBJFORMAT) -AC_SUBST(ULTRASPARC_LIBRARY) -AC_SUBST(ULTRASPARC_FILTER_LIBRARY) - -AC_SUBST(OBJDIR) -AC_SUBST(OBJDIR_NAME) -AC_SUBST(NSINSTALL) -AC_SUBST(OPTIMIZER) -AC_SUBST(RC) -AC_SUBST(DLLFLAGS) -AC_SUBST(EXEFLAGS) -AC_SUBST(OS_DLLFLAGS) -AC_SUBST(CYGWIN_WRAPPER) -AC_SUBST(WIN_TOP_SRC) -AC_SUBST(NEXT_ROOT) -AC_SUBST(RPATHFLAG) - -AC_SUBST(MFLAGS) - -dnl ======================================================== -dnl Generate output files. -dnl ======================================================== -MAKEFILES=" -Makefile -config/Makefile -config/autoconf.mk -ldap/Makefile -ldap/clients/tools/Makefile -ldap/include/Makefile -ldap/libraries/Makefile -ldap/libraries/libldap/Makefile -ldap/libraries/libprldap/Makefile -ldap/libraries/libldif/Makefile -ldap/libraries/liblber/Makefile -ldap/libraries/libiutil/Makefile -ldap/libraries/libssldap/Makefile -ldap/libraries/libutil/Makefile -" - -dnl since configure won't handle 2 levels of directory -dnl structure for us.. -mkdir ldap > /dev/null 2>&1 -mkdir ldap/clients > /dev/null 2>&1 - -AC_OUTPUT([$MAKEFILES])
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/build
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/clients
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/clients/tools
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/clients/tools/common.c
Deleted
@@ -1,2745 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * code that is shared by two or more of the LDAP command line tools - */ - -#include "ldaptool.h" -#include "fileurl.h" - -#ifdef LDAP_TOOL_ARGPIN -#include "argpin.h" -#include "ntuserpin.h" -#endif /* LDAP_TOOL_ARGPIN */ - -#include <nspr.h> -#include <stdlib.h> -#include <time.h> /* for time() and ctime() */ -#ifdef HAVE_SASL_OPTIONS -#include <sasl.h> -#include "ldaptool-sasl.h" -#endif /* HAVE_SASL_OPTIONS */ - -#if defined(HPUX) -#include <sys/termios.h> /* for tcgetattr and tcsetattr */ -#endif /* HPUX */ - -#if !defined(macintosh) && !defined(DOS) && !defined( _WINDOWS ) -#include <sys/socket.h> -#endif - -static LDAP_REBINDPROC_CALLBACK get_rebind_credentials; -static void print_library_info( const LDAPAPIInfo *aip, FILE *fp ); -static int wait4result( LDAP *ld, int msgid, struct berval **servercredp, - char *msg ); -static int parse_result( LDAP *ld, LDAPMessage *res, - struct berval **servercredp, char *msg, int freeit ); -static int check_response_controls( LDAP *ld, char *msg, LDAPControl **ctrls, int freeit ); - -#ifdef LDAPTOOL_DEBUG_MEMORY -static void *ldaptool_debug_malloc( size_t size ); -static void *ldaptool_debug_calloc( size_t nelem, size_t elsize ); -static void *ldaptool_debug_realloc( void *ptr, size_t size ); -static void ldaptool_debug_free( void *ptr ); -#endif /* LDAPTOOL_DEBUG_MEMORY */ - -#if defined(NET_SSL) && defined(LDAP_TOOL_PKCS11) -static void ldaptool_setcallbacks( struct ldapssl_pkcs_fns *pfns); -static char * buildTokenCertName( const char *tokenName, const char *certName); -#endif -#ifdef HAVE_SASL_OPTIONS -static int saslSetParam(char *saslarg); -#endif /* HAVE_SASL_OPTIONS */ - -/* copied from ldaprot.h - required to parse the pwpolicy ctrl */ -#define LDAP_TAG_PWP_WARNING 0xA0L /* context specific + constructed */ -#define LDAP_TAG_PWP_SECSLEFT 0x80L /* context specific + primitive */ -#define LDAP_TAG_PWP_GRCLOGINS 0x81L /* context specific + primitive + 1 */ -#define LDAP_TAG_PWP_ERROR 0x81L /* context specific + primitive + 1 */ - -/* - * display usage for common options with one exception: -f is not included - * since the description tends to be tool-specific. - * - * As of 1-Jul-1998, of the characters in the set [A-Za-z] the following are - * not currently used by any of the tools: EJgjqr - */ -void -ldaptool_common_usage( int two_hosts ) -{ - fprintf( stderr, " -n\t\tshow what would be done but don't actually do it\n" ); - fprintf( stderr, " -v\t\trun in verbose mode (diagnostics to standard output)\n" ); - if ( two_hosts ) { - fprintf( stderr, " -h host\tLDAP server1 name or IP address (default: %s)\n", LDAPTOOL_DEFHOST ); - fprintf( stderr, " -p port\tLDAP server1 TCP port number (default: %d)\n", LDAP_PORT ); - fprintf( stderr, " -h host\tLDAP server2 name or IP address (default: %s)\n", LDAPTOOL_DEFHOST ); - fprintf( stderr, " -p port\tLDAP server2 TCP port number (default: %d)\n", LDAP_PORT ); - } else { - fprintf( stderr, " -h host\tLDAP server name or IP address (default: %s)\n", LDAPTOOL_DEFHOST ); - fprintf( stderr, " -p port\tLDAP server TCP port number (default: %d)\n", LDAP_PORT ); - } - fprintf( stderr, - " -V n\tLDAP protocol version number (%d or %d; default: %d)\n", - LDAP_VERSION2, LDAP_VERSION3, LDAP_VERSION3 ); -#if defined(NET_SSL) - fprintf( stderr, " -ZZ\t\tstart TLS request\n" ); - fprintf( stderr, " -ZZZ\tenforce start TLS request (successful server response required)\n" ); - fprintf( stderr, " -Z\t\tmake an SSL-encrypted connection\n" ); - fprintf( stderr, " -P pathname\tpath to SSL certificate database (default: current directory)\n" ); - fprintf( stderr, " -N\t\tname of certificate to use for SSL client authentication\n" ); - fprintf( stderr, " -K pathname\tpath to key database to use for SSL client authentication\n" ); - fprintf( stderr, " \t\t(default: path to certificate database provided with -P option)\n" ); -#ifdef LDAP_TOOL_PKCS11 - fprintf( stderr, " -m pathname\tpath to security module database\n"); -#endif /* LDAP_TOOL_PKCS11 */ - fprintf( stderr, " -W\t\tSSL key password\n" ); - fprintf( stderr, " -W - \tprompt for SSL key password\n" ); -#ifdef LDAP_TOOL_PKCS11 - fprintf( stderr, " -I file\tSSL key password 'file' containing token:password pair/s\n" ); - fprintf( stderr, " -Q [token][:certificate name]\tPKCS 11\n" ); -#endif /* LDAP_TOOL_PKCS11 */ - fprintf( stderr, " -3\t\tcheck hostnames in SSL certificates\n" ); -#endif /* NET_SSL */ - fprintf( stderr, " -D binddn\tbind dn\n" ); - fprintf( stderr, " -w passwd\tbind passwd (for simple authentication)\n" ); - fprintf( stderr, " -w - \tprompt for bind passwd (for simple authentication)\n" ); - fprintf( stderr, " -j file\tread bind passwd from 'file' (for simple authentication)\n" ); - fprintf( stderr, " -E\t\task server to expose (report) bind identity\n" ); - fprintf( stderr, " -g\t\tdo not send a password policy request control\n" ); -#ifdef LDAP_DEBUG - fprintf( stderr, " -d level\tset LDAP debugging level to `level'\n" ); -#endif - fprintf( stderr, " -R\t\tdo not automatically follow referrals\n" ); - fprintf( stderr, " -O limit\tmaximum number of referral hops to traverse (default: %d)\n", LDAPTOOL_DEFREFHOPLIMIT ); - fprintf( stderr, " -M\t\tmanage references (treat them as regular entries)\n" ); - fprintf( stderr, " -0\t\tignore LDAP library version mismatches\n" ); - fprintf( stderr, " -i charset\tcharacter set for command line input (default taken from locale)\n" ); - fprintf( stderr, " \t\tuse '-i 0' to override locale settings and bypass any conversions\n" ); - fprintf( stderr, " -k do not convert password to utf8 (use default from locale)\n" ); -#if 0 -/* - * Suppress usage for -y (old proxied authorization control) even though - * we still support it. We want to encourage people to use -Y instead (the - * new proxied authorization control). - */ - fprintf( stderr, " -y proxydn\tDN used for proxy authorization\n" ); -#endif - fprintf( stderr, " -Y proxyid\tproxied authorization id,\n" ); - fprintf( stderr, " \te.g, dn:uid=bjensen,dc=example,dc=com\n" ); - fprintf( stderr, " -H\t\tdisplay usage information\n" ); - fprintf( stderr, " -J controloid[:criticality[:value|::b64value|:<fileurl]]\n" ); - fprintf( stderr, "\t\tcriticality is a boolean value (default is false)\n" ); -#ifdef HAVE_SASL_OPTIONS -#ifdef HAVE_SASL_OPTIONS_2 - fprintf( stderr, " -2 attrName=attrVal\tSASL options which are described in the man page\n"); -#else - fprintf( stderr, " -o attrName=attrVal\tSASL options which are described in the man page\n"); -#endif -#endif /* HAVE_SASL_OPTIONS */ -} - -/* globals */ -char *ldaptool_charset = NULL; -char *ldaptool_host = LDAPTOOL_DEFHOST; -char *ldaptool_host2 = LDAPTOOL_DEFHOST; -int ldaptool_port = LDAP_PORT; -int ldaptool_port2 = LDAP_PORT; -int ldaptool_verbose = 0; -int ldaptool_not = 0; -int ldaptool_nobind = 0; -int ldaptool_noconv_passwd = 0; -FILE *ldaptool_fp = NULL; -char *ldaptool_progname = ""; -LDAPControl *ldaptool_request_ctrls[CONTROL_REQUESTS] = {0}; -#ifdef LDAP_DEBUG -int ldaptool_dbg_lvl = 0; -#endif /* LDAP_DEBUG */ - -/* statics */ -static char *binddn = NULL; -static char *passwd = NULL; -static int send_auth_response_ctrl = 0; -static int user_specified_port = 0; -static int user_specified_port2 = 0; -static int chase_referrals = 1; -static int lib_version_mismatch_is_fatal = 1; -static int ldversion = -1; /* use default */ -static int refhoplim = LDAPTOOL_DEFREFHOPLIMIT; -static int send_manage_dsait_ctrl = 0; -static int prompt_password = 0; -static int prompt_sslpassword = 0; -static FILE *password_fp = NULL; -static char *proxyauth_id = NULL; -static int proxyauth_version = 2; /* use newer proxy control */ -static int no_pwpolicy_req_ctrl = 0; -#ifdef HAVE_SASL_OPTIONS -static unsigned sasl_flags = LDAP_SASL_AUTOMATIC; -static char *sasl_mech = NULL; -static char *sasl_authid = NULL; -static char *sasl_realm = NULL; -static char *sasl_username = NULL; -static char *sasl_secprops = NULL; -static int ldapauth = -1; -#endif /* HAVE_SASL_OPTIONS */ - -#if defined(NET_SSL) -static int secure = 0; -static int isZ = 0; -static int isZZ = 0; -static int isZZZ = 0; -static int isN = 0; -static int isW = 0; -static int isw = 0; -static int isD = 0; -static int isj = 0; -static int isk = 0; -static int ssl_strength = LDAPTOOL_DEFSSLSTRENGTH; -static char *ssl_certdbpath = NULL; -static char *ssl_keydbpath = NULL; -static char *ssl_certname = NULL; -static char *ssl_passwd = NULL; - -#ifdef LDAP_TOOL_PKCS11 -static char *ssl_secmodpath = NULL; - -static char *pkcs_token = NULL; - -static char *ssl_donglefile = NULL; - -#if 0 -static char *pkcs_pin = NULL; -#endif -static struct ldapssl_pkcs_fns local_pkcs_fns = - {0,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL }; - -#endif /* LDAP_TOOL_PKCS11 */ -#endif /* NET_SSL */ - - - -/* - * Handle general initialization and options that are common to all of - * the LDAP tools. - * Handle options that are common to all of the LDAP tools. - * Note the the H option is included here but handled via the - * extra_opt_callback function (along with any "extra_opts" ). - * - * Return: final value for optind or -1 if usage should be displayed (for - * some fatal errors, we call exit here). - */ -int -ldaptool_process_args( int argc, char **argv, char *extra_opts, - int two_hosts, void (*extra_opt_callback)( int option, char *optarg )) -{ - int rc, i, hostnum; - char *optstring, *common_opts; - extern char *optarg; - extern int optind; - LDAPAPIInfo ldai; - char *ctrl_arg, *ctrl_oid=NULL, *ctrl_value=NULL; - int ctrl_criticality=0, vlen; - LDAPControl *ldctrl; - - /* - * Set program name global based on argv[0]. - */ - if (( ldaptool_progname = strrchr( argv[ 0 ], '/' )) == NULL ) { - ldaptool_progname = argv[ 0 ]; - } else { - ++ldaptool_progname; - } - -#ifdef LDAPTOOL_DEBUG_MEMORY - { - struct ldap_memalloc_fns mafns = { - ldaptool_debug_malloc, - ldaptool_debug_calloc, - ldaptool_debug_realloc, - ldaptool_debug_free - }; - - ldap_set_option( NULL, LDAP_OPT_MEMALLOC_FN_PTRS, &mafns ); - } -#endif /* LDAPTOOL_DEBUG_MEMORY */ - -#ifdef LDAP_DEBUG - i = LDAP_DEBUG_ANY; - ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, (void *) &i); -#endif - - /* - * Perform a sanity check on the revision of the LDAP API library to - * make sure it is at least as new as the one we were compiled against. - * If the API implementation is from the same vendor as we were compiled - * against, we also check to make sure the vendor version is at least - * as new as the library we were compiled against. - * - * Version differences are fatal unless the -0 option is passed on the - * tool command line (that's a zero, not an oh). We check for the - * presence of -0 in a crude way to it must appear by itself in argv. - */ - for ( i = 1; i < argc; ++i ) { - if ( strcmp( argv[i], "-0" ) == 0 ) { - lib_version_mismatch_is_fatal = 0; - break; - } - } - - memset( &ldai, 0, sizeof(ldai)); - ldai.ldapai_info_version = LDAP_API_INFO_VERSION; - if (( rc = ldap_get_option( NULL, LDAP_OPT_API_INFO, &ldai )) != 0 ) { - fprintf( stderr, "%s: unable to retrieve LDAP library version" - " information;\n\tthis program requires an LDAP library that" - " implements revision\n\t%d or greater of the LDAP API.\n", - ldaptool_progname, LDAP_API_VERSION ); - if ( lib_version_mismatch_is_fatal ) { - exit( LDAP_LOCAL_ERROR ); - } - } else if ( ldai.ldapai_api_version < LDAP_API_VERSION ) { - fprintf( stderr, "%s: this program requires an LDAP library that" - " implements revision\n\t%d or greater of the LDAP API;" - " running with revision %d.\n", - ldaptool_progname, LDAP_API_VERSION, ldai.ldapai_api_version ); - if ( lib_version_mismatch_is_fatal ) { - exit( LDAP_LOCAL_ERROR ); - } - } else if ( strcmp( ldai.ldapai_vendor_name, LDAP_VENDOR_NAME ) != 0 ) { - fprintf( stderr, "%s: this program requires %s's LDAP\n" - "\tlibrary version %2.2f or greater; running with\n" - "\t%s's version %2.2f.\n", - ldaptool_progname, LDAP_VENDOR_NAME, - (float)LDAP_VENDOR_VERSION / 100, - ldai.ldapai_vendor_name, - (float)ldai.ldapai_vendor_version / 100 ); - if ( lib_version_mismatch_is_fatal ) { - exit( LDAP_LOCAL_ERROR ); - } - } else if ( ldai.ldapai_vendor_version < LDAP_VENDOR_VERSION ) { - fprintf( stderr, "%s: this program requires %s's LDAP\n" - "\tlibrary version %2.2f or greater; running with" - " version %2.2f.\n", - ldaptool_progname, LDAP_VENDOR_NAME, - (float)LDAP_VENDOR_VERSION / 100, - (float)ldai.ldapai_vendor_version / 100 ); - if ( lib_version_mismatch_is_fatal ) { - exit( LDAP_LOCAL_ERROR ); - } - } - - /* - * Process command line options. - */ - if ( extra_opts == NULL ) { - extra_opts = ""; - } - -#ifdef HAVE_SASL_OPTIONS -#ifdef HAVE_SASL_OPTIONS_2 - common_opts = "kgnvEMRHZ02:3d:D:f:h:j:I:K:N:O:P:p:W:w:V:m:i:y:Y:J:"; -#else - common_opts = "kgnvEMRHZ03d:D:f:h:j:I:K:N:O:o:P:p:W:w:V:m:i:y:Y:J:"; -#endif -#else - common_opts = "kgnvEMRHZ03d:D:f:h:j:I:K:N:O:P:p:Q:W:w:V:m:i:k:y:Y:J:"; -#endif /* HAVE_SASL_OPTIONS */ - - if (( optstring = (char *) malloc( strlen( extra_opts ) + strlen( common_opts ) - + 1 )) == NULL ) { - perror( "malloc" ); - exit( LDAP_NO_MEMORY ); - } - - sprintf( optstring, "%s%s", common_opts, extra_opts ); - - if ( argc == 2 ) { - if ( ((strncmp( argv[1], "/?", strlen("/?") + 1 )) == 0 ) || - ((strncmp( argv[1], "-help", strlen("-help") + 1 )) == 0 ) || - ((strncmp( argv[1], "--help", strlen("--help") + 1 )) == 0 ) ) { - return( -1 ); - } - } - - hostnum = 0; - while ( (i = getopt( argc, argv, optstring )) != EOF ) { - switch( i ) { - case 'n': /* do Not do any LDAP operations */ - ++ldaptool_not; - break; - case 'v': /* verbose mode */ - ++ldaptool_verbose; - break; - case 'd': -#ifdef LDAP_DEBUG - ldaptool_dbg_lvl = atoi( optarg ); /* */ - ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, - (void *)&ldaptool_dbg_lvl); - ldaptool_dbg_lvl |= LDAP_DEBUG_ANY; - ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, - (void *)&ldaptool_dbg_lvl); -#else /* LDAP_DEBUG */ - fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" ); -#endif /* LDAP_DEBUG */ - break; - case 'R': /* don't automatically chase referrals */ - chase_referrals = 0; - break; - case 'f': /* input file */ - if ( optarg[0] == '-' && optarg[1] == '\0' ) { - ldaptool_fp = stdin; - } else if (( ldaptool_fp = ldaptool_open_file( optarg, "r" )) == NULL ) { - perror( optarg ); - exit( LDAP_PARAM_ERROR ); - } - break; - case 'h': /* ldap host */ - if ( hostnum == 0 ) { - ldaptool_host = strdup( optarg ); - } else if ( two_hosts ) { - ldaptool_host2 = strdup( optarg ); - } else { - fprintf( stderr, - "%s: only one host (-h option) should be specified\n", - ldaptool_progname ); - return(-1); /* usage error */ - } - ++hostnum; - break; - case 'D': /* bind DN */ - isD = 1; - binddn = strdup( optarg ); - break; - case 'E': /* expose bind identity via auth. response control */ - ++send_auth_response_ctrl; - break; - - case 'p': /* ldap port */ - if ( !user_specified_port ) { - ++user_specified_port; - ldaptool_port = atoi( optarg ); - } else if ( two_hosts ) { - ++user_specified_port2; - ldaptool_port2 = atoi( optarg ); - } else { - fprintf( stderr, - "%s: only one port (-p option) should be specified\n", - ldaptool_progname ); - return(-1); /* usage error */ - } - - break; -#if defined(NET_SSL) - case 'P': /* path to security database */ - if ( (0 == isZ) && (0 == isZZ) ) - { - secure = 1; /* do SSL encryption */ - } - ssl_certdbpath = strdup( optarg ); - if (NULL == ssl_certdbpath) - { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - break; - case 'Z': /* do SSL encryption */ - if ( (0 == isZ) && (0 == isZZ) ) - { - secure = 1; - isZ = 1; - } - else { - secure = 0; - isZ = 0; - /* -ZZZ for Server response required */ - if (isZZ == 1) isZZZ =1; - isZZ = 1; /* -ZZ : Start TLS request */ - } - break; - case 'N': /* nickname of cert. to use for client auth. */ - ssl_certname = strdup( optarg ); - if (NULL == ssl_certname) - { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - isN = 1; - break; - case 'K': /* location of key database */ - ssl_keydbpath = strdup( optarg ); - if (NULL == ssl_keydbpath) - { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - break; - case 'W': /* SSL key password */ - if ( optarg[0] == '-' && optarg[1] == '\0' ) { - prompt_sslpassword = 1; - } else { - ssl_passwd = strdup( optarg ); - if (NULL == ssl_passwd) - { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - } - isW = 1; - break; - - case '3': /* check hostnames in SSL certificates ("no third") */ - ssl_strength = LDAPSSL_AUTH_CNCHECK; - break; - -#ifdef LDAP_TOOL_PKCS11 - case 'm': /* SSL secmod path */ - ssl_secmodpath = strdup( optarg); - if (NULL == ssl_secmodpath) - { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - break; - - case 'Q': /* [token][:certificate name] */ - pkcs_token = strdup(optarg); - if (NULL == pkcs_token) - { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - - break; - - case 'I': /* PIN (password file) */ - ssl_donglefile = strdup( optarg ); - - break; -#endif /* LDAP_TOOL_PKCS11 */ - -#endif /* NET_SSL */ - case 'w': /* bind password */ - isw = 1; - if ( optarg[0] == '-' && optarg[1] == '\0' ) - prompt_password = 1; - else - passwd = strdup( optarg ); - break; - case 'j': /* bind password from file */ - isj = 1; - if ((password_fp = fopen( optarg, "r" )) == NULL ) { - fprintf(stderr, "%s: Unable to open '%s' file\n", - ldaptool_progname, optarg); - exit( LDAP_PARAM_ERROR ); - } - break; - case 'O': /* referral hop limit */ - refhoplim = atoi( optarg ); - break; - case 'V': /* protocol version */ - ldversion = atoi (optarg); - if ( ldversion != LDAP_VERSION2 && ldversion != LDAP_VERSION3 ) { - fprintf( stderr, "%s: LDAP protocol version %d is not " - "supported (use -V%d or -V%d)\n", - ldaptool_progname, ldversion, LDAP_VERSION2, - LDAP_VERSION3 ); - exit( LDAP_PARAM_ERROR ); - } - break; - case 'M': /* send a manageDsaIT control */ - send_manage_dsait_ctrl = 1; - break; - - case 'i': /* character set specified */ - ldaptool_charset = strdup( optarg ); - if (NULL == ldaptool_charset) - { - perror( "malloc" ); - exit( LDAP_NO_MEMORY ); - } - - break; - case 'k': /* bypass passwd conversion to utf8 */ - isk = 1; - ldaptool_noconv_passwd = 1; /* tell the tool about it */ - break; - case 'y': /* old (version 1) proxied authorization control */ - proxyauth_version = 1; - /*FALLTHRU*/ - case 'Y': /* new (version 2 ) proxied authorization control */ - proxyauth_id = strdup(optarg); - if (NULL == proxyauth_id) - { - perror( "malloc" ); - exit( LDAP_NO_MEMORY ); - } - - break; - - case '0': /* zero -- override LDAP library version check */ - break; /* already handled above */ - - case 'J': /* send an arbitrary control */ - if ( (ctrl_arg = strdup( optarg)) == NULL ) { - perror ("strdup"); - exit (LDAP_NO_MEMORY); - } - if (ldaptool_parse_ctrl_arg(ctrl_arg, ':', &ctrl_oid, - &ctrl_criticality, &ctrl_value, &vlen)) { - return (-1); - } - ldctrl = calloc(1,sizeof(LDAPControl)); - if (ctrl_value) { - rc = ldaptool_berval_from_ldif_value( ctrl_value, - vlen, &(ldctrl->ldctl_value), - 1 /* recognize file URLs */, - 0 /* always try file */, - 1 /* report errors */ ); - if ((rc = ldaptool_fileurlerr2ldaperr( rc )) != LDAP_SUCCESS) { - fprintf( stderr, "Unable to parse %s\n", ctrl_value); - return (-1); - } - } - ldctrl->ldctl_oid = ctrl_oid; - ldctrl->ldctl_iscritical = ctrl_criticality; - ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); - break; - case 'g': /* do not send password policy request control */ - no_pwpolicy_req_ctrl++; - break; -#ifdef HAVE_SASL_OPTIONS -#ifdef HAVE_SASL_OPTIONS_2 - case '2': /* attribute assignment */ -#else - case 'o': /* attribute assignment */ -#endif - if ((rc = saslSetParam(optarg)) == -1) { - return (-1); - } - ldapauth = LDAP_AUTH_SASL; - ldversion = LDAP_VERSION3; - break; -#endif /* HAVE_SASL_OPTIONS */ - default: - (*extra_opt_callback)( i, optarg ); - } - } - - /* If '-Z' is specified, check if '-P' is specified too. */ - if ( isN || isW ) { - if ( !(isZ || isZZ) ) { - fprintf( stderr, "%s: with -N, -W options, please specify either -Z , -ZZ or -ZZZ\n\n", ldaptool_progname ); - return (-1); - } - } - -#ifdef LDAP_TOOL_PKCS11 - /* if '-N' is specified, -W or -I is needed too */ - if ( isN && NULL == ssl_passwd && 0 == prompt_sslpassword && NULL == ssl_donglefile ) { - fprintf( stderr, "%s: with the -N option, please specify -W or -I also\n\n", ldaptool_progname ); - return (-1); - } -#else - /* if '-N' is specified, -W is needed too */ - if ( isN && NULL == ssl_passwd && 0 == prompt_sslpassword ) { - fprintf( stderr, "%s: with the -N option, please specify -W also\n\n", ldaptool_progname ); - return (-1); - } -#endif /* LDAP_TOOL_PKCS11 */ - - if ( isj && isw ) { - fprintf(stderr, "%s: -j and -w options cannot be specified simultaneously\n\n", ldaptool_progname ); - return (-1); - } - - /* complain if -j or -w does not also have -D, unless using SASL */ -#ifdef HAVE_SASL_OPTIONS - if ( (isj || isw) && !isD && ( ldapauth != LDAP_AUTH_SASL ) ) { -#else - if ( (isj || isw) && !isD ) { -#endif - fprintf(stderr, "%s: with -j, -w options, please specify -D\n\n", ldaptool_progname ); - return (-1); - } - - /* use default key and cert DB paths if not set on the command line */ - if ( NULL == ssl_keydbpath ) { - if ( NULL == ssl_certdbpath ) { - ssl_keydbpath = LDAPTOOL_DEFKEYDBPATH; - } else { - /* The ldapssl_.*init() functions, which call NSS_Initialize(), - * don't rely on the key DB path ending in the correct filename, - * so it is OK to just pass them the cert DB path. - */ - ssl_keydbpath = ssl_certdbpath; - } - } - if ( NULL == ssl_certdbpath ) { - ssl_certdbpath = LDAPTOOL_DEFCERTDBPATH; - } - - if (prompt_password != 0) { - char *password_string = "Enter bind password: "; - passwd = ldaptool_getpass( password_string ); - } else if (password_fp != NULL) { - passwd = ldaptool_read_password( password_fp ); - } - - /* - * If verbose (-v) flag was passed in, display program name and start time. - * If the verbose flag was passed at least twice (-vv), also display - * information about the API library we are running with. - */ - if ( ldaptool_verbose ) { - time_t curtime; - - curtime = time( NULL ); - printf( "%s: started %s\n", ldaptool_progname, ctime( &curtime )); - if ( ldaptool_verbose > 1 ) { - print_library_info( &ldai, stdout ); - } - } - -#ifdef LDAP_TOOL_PKCS11 - if ((NULL != pkcs_token) && (NULL != ssl_certname)) { - char *result; - - if ( (result = buildTokenCertName( pkcs_token, ssl_certname)) != NULL){ - free( ssl_certname ); - ssl_certname = result; - } - } -#endif /* LDAP_TOOL_PKCS11 */ - - free( optstring ); - - /* - * Clean up and return index of first non-option argument. - */ - if ( ldai.ldapai_extensions != NULL ) { - ldap_value_free( ldai.ldapai_extensions ); - } - if ( ldai.ldapai_vendor_name != NULL ) { - ldap_memfree( ldai.ldapai_vendor_name ); - } - -#ifdef HAVE_SASL_OPTIONS - if (ldversion == LDAP_VERSION2 && ldapauth == LDAP_AUTH_SASL) { - fprintf( stderr, "Incompatible with version %d\n", ldversion); - return (-1); - } -#endif /* HAVE_SASL_OPTIONS */ - - return( optind ); -} - - -/* - * Write detailed information about the API library we are running with to fp. - */ -static void -print_library_info( const LDAPAPIInfo *aip, FILE *fp ) -{ - int i; - LDAPAPIFeatureInfo fi; - - fprintf( fp, "LDAP Library Information -\n" - " Highest supported protocol version: %d\n" - " LDAP API revision: %d\n" - " API vendor name: %s\n" - " Vendor-specific version: %.2f\n", - aip->ldapai_protocol_version, aip->ldapai_api_version, - aip->ldapai_vendor_name, - (float)aip->ldapai_vendor_version / 100.0 ); - - if ( aip->ldapai_extensions != NULL ) { - fputs( " LDAP API Extensions:\n", fp ); - - for ( i = 0; aip->ldapai_extensions[i] != NULL; i++ ) { - fprintf( fp, " %s", aip->ldapai_extensions[i] ); - fi.ldapaif_info_version = LDAP_FEATURE_INFO_VERSION; - fi.ldapaif_name = aip->ldapai_extensions[i]; - fi.ldapaif_version = 0; - - if ( ldap_get_option( NULL, LDAP_OPT_API_FEATURE_INFO, &fi ) - != 0 ) { - fprintf( fp, " %s: ldap_get_option( NULL," - " LDAP_OPT_API_FEATURE_INFO, ... ) for %s failed" - " (Feature Info version: %d)\n", ldaptool_progname, - fi.ldapaif_name, fi.ldapaif_info_version ); - } else { - fprintf( fp, " (revision %d)\n", fi.ldapaif_version); - } - } - } - fputc( '\n', fp ); -} - - - -#ifdef LDAP_TOOL_ARGPIN -static int PinArgRegistration( void ) -{ - - /* pkcs_init was successful register the pin args */ - - SVRCOREArgPinObj *ArgPinObj; - char *tokenName; -#ifndef _WIN32 - SVRCOREStdPinObj *StdPinObj; -#else - SVRCOREFilePinObj *FilePinObj; - SVRCOREAltPinObj *AltPinObj; - SVRCORENTUserPinObj *NTUserPinObj; - int err; -#endif - char *pin; - char *filename; - /* Create and register the pin object for PKCS 11 */ - local_pkcs_fns.pkcs_getdonglefilename(NULL, &filename); - local_pkcs_fns.pkcs_getpin(NULL, "", &pin); -#ifndef _WIN32 - if ( SVRCORE_CreateStdPinObj(&StdPinObj, filename, PR_TRUE) != - SVRCORE_Success) { - fprintf(stderr, "Security Initialization: Unable to create PinObj " - "(%d)", PR_GetError()); - return -1; - } - if (pin != NULL) - { - local_pkcs_fns.pkcs_gettokenname(NULL, &tokenName); - SVRCORE_CreateArgPinObj(&ArgPinObj, tokenName, pin, (SVRCOREPinObj *)StdPinObj); - SVRCORE_RegisterPinObj((SVRCOREPinObj *)ArgPinObj); - } - else - { - SVRCORE_RegisterPinObj((SVRCOREPinObj *)StdPinObj); - } -#else - if (NULL != pin) - { - local_pkcs_fns.pkcs_gettokenname(NULL, &tokenName); - if ((err = SVRCORE_CreateNTUserPinObj(&NTUserPinObj)) != SVRCORE_Success){ - fprintf(stderr, "Security Initialization: Unable to create NTUserPinObj " - "(%d)", PR_GetError()); - exit( LDAP_LOCAL_ERROR ); - } - if ((err = SVRCORE_CreateArgPinObj(&ArgPinObj, tokenName, pin, - (SVRCOREPinObj *)NTUserPinObj)) != SVRCORE_Success) - { - fprintf(stderr, "Security Initialization: Unable to create ArgPinObj " - "(%d)", PR_GetError()); - return -1; - - } - SVRCORE_RegisterPinObj((SVRCOREPinObj *)ArgPinObj); - - } - else - { - if ((err = SVRCORE_CreateNTUserPinObj(&NTUserPinObj)) != SVRCORE_Success){ - fprintf( stderr, "Security Initialization: Unable to create NTUserPinObj " - "(%d)", PR_GetError()); - return -1; - } - if (filename && *filename) - { - if ((err = SVRCORE_CreateFilePinObj(&FilePinObj, filename)) != - SVRCORE_Success) { - fprintf( stderr, "Security Initialization: Unable to create FilePinObj " - "(%d)", PR_GetError()); - return -1; - - } - if ((err = SVRCORE_CreateAltPinObj(&AltPinObj, (SVRCOREPinObj *)FilePinObj, - (SVRCOREPinObj *)NTUserPinObj)) != SVRCORE_Success) { - fprintf( stderr, "Security Initialization: Unable to create AltPinObj " - "(%d)", PR_GetError()); - return -1; - } - SVRCORE_RegisterPinObj((SVRCOREPinObj *)AltPinObj); - } - else - { - SVRCORE_RegisterPinObj((SVRCOREPinObj *)NTUserPinObj); - } - } -#endif - return LDAP_SUCCESS; - -} -#endif /* LDAP_TOOL_ARGPIN */ - -#if !defined(macintosh) && !defined(DOS) && !defined( _WINDOWS ) -/* If numaddr is IPv6 numeric address and if possible, get FQDN from it. - * This conversion is needed to fulfill the spec of sasl_client_init. - * If successful, FQDN is stored in buf and return LDAP_SUCCESS - * If numaddr is not IPv6 numeric address, it returns non LDAP_SUCCESS (-1) - * If any step of the conversion fails, it returns non LDAP_SUCCESS (-1) - * Note: any conversion failure does not print out an error message. - */ -static int -getFQDNbyIPv6NumericAddr ( char *numaddr, char *buf, size_t blen ) -{ - char *hostp = NULL; - int isIPv6Numeric = 0; - int rc, return_value = -1; - - /* IPv6 numeric address includes 2 or more colons */ - /* example: [3ffe:1111:2222:3333::1] */ - hostp = strchr( numaddr, ':' ); - if ( hostp ) { /* found one colon */ - hostp = strchr( hostp+1, ':' ); - if ( hostp ) { /* found two colons */ - hostp = strchr( numaddr, '[' ); - if ( hostp ) { /* numaddr starts with '[' */ - /* example: [fe80::250:ffff:ffff:e53a%eth0] - * if interface is given, it's link-local. - * we don't do lookup */ - char *workp = strchr( ++hostp, '%' ); - if ( !workp ) { /* address does not include % */ - size_t mylen = 0; - isIPv6Numeric = 1; - workp = strchr( hostp, ']' ); - if ( workp ) { - mylen = workp - hostp; - } else { - mylen = strlen( hostp ); - } - if ( mylen >= blen ) { /* address too long */ - return return_value; - } - strncpy( buf, hostp, mylen ); - buf[mylen] = '\0'; - } - } else { - isIPv6Numeric = 1; - if ( strlen(numaddr) >= blen ) { /* address too long */ - return return_value; - } - strcpy( buf, numaddr ); - } - } - } - if ( !isIPv6Numeric ) { - return return_value; /* it's not IPv6 numeric address */ - } - { - struct sockaddr *saddr = NULL; - socklen_t slen = 0; -#ifdef HAVE_GETADDRINFO - struct addrinfo hints = {0}; - struct addrinfo *ainfo = NULL; - - hints.ai_flags = AI_ADDRCONFIG; - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - - rc = getaddrinfo( buf, NULL, &hints, &ainfo ); - if ( 0 == rc ) { - saddr = ainfo->ai_addr; - slen = ainfo->ai_addrlen; - } - /* if saddr is NULL here, getaddrinfo failed */ -#endif - if ( saddr && slen > 0 ) { -#ifdef HAVE_GETNAMEINFO - rc = getnameinfo( saddr, slen, buf, (socklen_t)blen, NULL, 0, NI_NAMEREQD ); - if (0 == rc) { - return_value = LDAP_SUCCESS; - } -#endif -#ifdef HAVE_GETADDRINFO - if ( ainfo ) { - freeaddrinfo( ainfo ); - } -#endif - if ( LDAP_SUCCESS == return_value ) { - return return_value; - } - } - } - /* getaddrinfo and getnameinfo are not available; let's use nspr apis */ - { - PRNetAddr praddr; - PRIntn idx = 0; - PRHostEnt prhent, prrevhent; - char tmpbuf[PR_NETDB_BUF_SIZE]; - if ( PR_GetIPNodeByName(buf, PR_AF_INET6, PR_AI_DEFAULT, - tmpbuf, sizeof(tmpbuf), &prhent) != PR_SUCCESS ) { - return return_value; - } - while (1) { - idx = PR_EnumerateHostEnt(idx, &prhent, 0, &praddr); - if (idx == -1) { - return return_value; - } - if (idx == 0) break; /* normal loop termination */ - if (PR_GetHostByAddr(&praddr, tmpbuf, sizeof(tmpbuf), - &prrevhent) == PR_FAILURE) { - return return_value; - } - if ( prrevhent.h_name ) { - PR_snprintf( buf, blen, "%s", prrevhent.h_name ); - return_value = LDAP_SUCCESS; - break; - } - } - return return_value; - } -} -#endif - -/* - * initialize and return an LDAP session handle. - * if errors occur, we exit here. - */ -LDAP * -ldaptool_ldap_init( int second_host ) -{ - LDAP *ld = NULL; - char *host; - int port, rc, user_port; -#if !defined(macintosh) && !defined(DOS) && !defined( _WINDOWS ) -#if defined(MAXHOSTNAMELEN) - char hname[MAXHOSTNAMELEN]; - size_t hlen = MAXHOSTNAMELEN; -#else - char hname[256]; - size_t hlen = 256; -#endif -#endif - - if ( ldaptool_not ) { - return( NULL ); - } - - if ( second_host ) { - host = ldaptool_host2; - port = ldaptool_port2; - user_port = user_specified_port2; - } else { - host = ldaptool_host; - port = ldaptool_port; - user_port = user_specified_port; - } -#if !defined(macintosh) && !defined(DOS) && !defined( _WINDOWS ) - /* If numaddr is IPv6 numeric address and if possible, get FQDN from it. */ - if ( getFQDNbyIPv6NumericAddr ( host, hname, hlen ) == LDAP_SUCCESS ) { - host = hname; - } -#endif - - if ( ldaptool_verbose ) { - printf( "ldap_init( %s, %d )\n", host, port ); - } - -#if defined(NET_SSL) - /* - * Initialize security libraries and databases and LDAP session. If - * ssl_certname is not NULL, then we will attempt to use client auth. - * if the server supports it. - */ -#ifdef LDAP_TOOL_PKCS11 - ldaptool_setcallbacks( &local_pkcs_fns ); - - if ( !second_host && ( secure || isZZ ) - &&(rc = ldapssl_pkcs_init( &local_pkcs_fns)) < 0) { - /* secure connection requested -- fail if no SSL */ - rc = PORT_GetError(); - fprintf( stderr, "SSL initialization failed: error %d (%s)\n", - rc, ldapssl_err2string( rc )); - exit( LDAP_LOCAL_ERROR ); - } - -#ifdef LDAP_TOOL_ARGPIN - if (secure || isZZ) { - if (PinArgRegistration( )) { - exit( LDAP_LOCAL_ERROR); - } - } -#endif /* LDAP_TOOL_ARGPIN */ - -#else /* LDAP_TOOL_PKCS11 */ - if ( !second_host && ( secure || isZZ ) - &&(rc = ldapssl_client_init( ssl_certdbpath, NULL )) < 0) { - /* secure connection requested -- fail if no SSL */ - rc = PORT_GetError(); - fprintf( stderr, "SSL initialization failed: error %d (%s)\n", - rc, ldapssl_err2string( rc )); - exit( LDAP_LOCAL_ERROR ); - } -#endif /* LDAP_TOOL_PKCS11 */ - - /* set the default SSL strength (used for all future ld's we create) */ - if ( ldapssl_set_strength( NULL, ssl_strength ) < 0 ) { - perror( "ldapssl_set_strength" ); - exit( LDAP_LOCAL_ERROR ); - } - - if (secure) { - if ( !user_port ) { - port = LDAPS_PORT; - } - - if (( ld = ldapssl_init( host, port, - secure )) != NULL && ssl_certname != NULL ) - if (ldapssl_enable_clientauth( ld, ssl_keydbpath, ssl_passwd, - ssl_certname ) != 0 ) { - exit ( ldaptool_print_lderror( ld, "ldapssl_enable_clientauth", - LDAPTOOL_CHECK4SSL_ALWAYS )); - } - } else if (isZZ) - {/* startTLS if -ZZ or -ZZZ option is used */ - - if (( ld = prldap_init( host, port, 0 )) == NULL) { - perror("prldap_init failed"); - exit( LDAP_LOCAL_ERROR ); - } - - /* Provide client authentication if -N option is used */ - if ( ssl_certname != NULL ) { - if (ldapssl_enable_clientauth( ld, ssl_keydbpath, ssl_passwd, - ssl_certname ) != 0 ) { - exit ( ldaptool_print_lderror( ld, "ldapssl_enable_clientauth", - LDAPTOOL_CHECK4SSL_ALWAYS )); - } - } - - /* Call to startTLS over the current clear-text connection */ - if ( ( rc = ldap_start_tls_s( ld, NULL, NULL ) ) != LDAP_SUCCESS ) { - fprintf( stderr, "ldap_start_tls_s failed: (%s)\n", - ldap_err2string(rc)); - if( isZZZ ) { - ldap_unbind( ld ); - exit( rc ); - } - } - - } /* End startTLS case */ - else { - /* In order to support IPv6, we use NSPR I/O */ - ld = prldap_init( host, port, 0 /* not shared across threads */ ); - } - -#else - /* In order to support IPv6, we use NSPR I/O */ - ld = prldap_init( host, port, 0 /* not shared across threads */ ); -#endif - - if ( ld == NULL ) { - perror( "ldap_init" ); - exit( LDAP_LOCAL_ERROR ); - } - - ldap_set_option( ld, LDAP_OPT_REFERRALS, chase_referrals ? LDAP_OPT_ON: - LDAP_OPT_OFF ); - if ( chase_referrals ) { - ldap_set_rebind_proc( ld, get_rebind_credentials, NULL ); - ldap_set_option( ld, LDAP_OPT_REFERRAL_HOP_LIMIT, &refhoplim ); - } - - if ( ldversion == -1 ) { /* not set with -V and not using local db */ - ldversion = LDAP_VERSION3; - } - ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &ldversion ); - - return( ld ); -} - - -/* - * perform a bind to the LDAP server if needed. - * if an error occurs, we exit here. - */ -void -ldaptool_bind( LDAP *ld ) -{ - int rc, ctrl_index = 0; - char *conv_binddn; - char *conv_passwd = NULL; - LDAPControl auth_resp_ctrl, *ctrl_array[ 3 ], **bindctrls; - LDAPControl pwpolicy_req_ctrl; - LDAPControl **ctrls = NULL; -#ifdef HAVE_SASL_OPTIONS - void *defaults; -#endif - - if ( ldaptool_not ) { - return; - } - - if ( send_auth_response_ctrl ) { - auth_resp_ctrl.ldctl_oid = LDAP_CONTROL_AUTH_REQUEST; - auth_resp_ctrl.ldctl_value.bv_val = NULL; - auth_resp_ctrl.ldctl_value.bv_len = 0; - auth_resp_ctrl.ldctl_iscritical = 0; - ctrl_array[ctrl_index++] = &auth_resp_ctrl; - } - - if ( !no_pwpolicy_req_ctrl ) { - pwpolicy_req_ctrl.ldctl_oid = LDAP_X_CONTROL_PWPOLICY_REQUEST; - pwpolicy_req_ctrl.ldctl_value.bv_val = NULL; - pwpolicy_req_ctrl.ldctl_value.bv_len = 0; - pwpolicy_req_ctrl.ldctl_iscritical = 0; - ctrl_array[ctrl_index++] = &pwpolicy_req_ctrl; - } - - if ( ctrl_index == 0 ) { - bindctrls = NULL; - } else { - ctrl_array[ctrl_index] = NULL; - bindctrls = ctrl_array; - } - - /* - * if using LDAPv3 and not using client auth., omit NULL bind for - * efficiency. - */ - if ( ldversion > LDAP_VERSION2 && binddn == NULL && passwd == NULL - && ssl_certname == NULL ) { -#ifdef HAVE_SASL_OPTIONS - if ( ldapauth != LDAP_AUTH_SASL ) { -#endif - /* let the tool know we did no bind */ - ldaptool_nobind = 1; - return; -#ifdef HAVE_SASL_OPTIONS - } -#endif - } - - /* - * do the bind, backing off one LDAP version if necessary - */ - conv_binddn = ldaptool_local2UTF8( binddn, "bind DN" ); - - if ( passwd != NULL ) { - if ( isk ) { - conv_passwd = strdup( passwd ); - } else { - conv_passwd = ldaptool_local2UTF8( passwd, "password" ); - } - } - -#ifdef HAVE_SASL_OPTIONS - if ( ldapauth == LDAP_AUTH_SASL) { - LDAPControl **rctrls = NULL; - if ( sasl_mech == NULL) { - fprintf( stderr, "Please specify the SASL mechanism name when " - "using SASL options\n"); - return; - } - - if ( sasl_secprops != NULL) { - rc = ldap_set_option( ld, LDAP_OPT_X_SASL_SECPROPS, - (void *) sasl_secprops ); - - if ( rc != LDAP_SUCCESS ) { - fprintf( stderr, "Unable to set LDAP_OPT_X_SASL_SECPROPS: %s\n", - sasl_secprops ); - return; - } - } - - defaults = ldaptool_set_sasl_defaults( ld, sasl_flags, sasl_mech, - sasl_authid, sasl_username, passwd, sasl_realm ); - if (defaults == NULL) { - perror ("malloc"); - exit (LDAP_NO_MEMORY); - } - - rc = ldap_sasl_interactive_bind_ext_s( ld, binddn, sasl_mech, - bindctrls, ctrls, sasl_flags, - ldaptool_sasl_interact, defaults, &rctrls ); - if (rc != LDAP_SUCCESS ) { - ldap_perror( ld, "Bind Error" ); - } - - check_response_controls( ld, "ldaptool_bind", rctrls, 1 ); - - } else -#endif /* HAVE_SASL_OPTIONS */ - - /* - * if using LDAPv3 and client auth., try a SASL EXTERNAL bind - */ - if ( ldversion > LDAP_VERSION2 && binddn == NULL && passwd == NULL - && ssl_certname != NULL ) { - rc = ldaptool_sasl_bind_s( ld, NULL, LDAP_SASL_EXTERNAL, NULL, - bindctrls, NULL, NULL, "ldap_sasl_bind" ); - } else { - rc = ldaptool_simple_bind_s( ld, conv_binddn, conv_passwd, bindctrls, NULL, - "ldap_simple_bind" ); - } - - if ( rc == LDAP_SUCCESS ) { - if ( conv_binddn != NULL ) { - free( conv_binddn ); - } - - if ( conv_passwd != NULL ) { - free( conv_passwd ); - } - - return; /* success */ - } - -#ifdef HAVE_SASL_OPTIONS - if (ldapauth != LDAP_AUTH_SASL) { -#endif /* HAVE_SASL_OPTIONS */ - if ( rc == LDAP_PROTOCOL_ERROR && ldversion > LDAP_VERSION2 ) { - /* - * try again, backing off one LDAP version - * this is okay even for client auth. because the way to achieve - * client auth. with LDAPv2 is to perform a NULL simple bind. - */ - --ldversion; - fprintf( stderr, "%s: the server doesn't understand LDAPv%d;" - " trying LDAPv%d instead...\n", ldaptool_progname, - ldversion + 1, ldversion ); - ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &ldversion ); - if (( rc = ldaptool_simple_bind_s( ld, conv_binddn, conv_passwd, - bindctrls, NULL, "ldap_simple_bind" )) == LDAP_SUCCESS ) { - if ( conv_binddn != NULL ) { - free( conv_binddn ); - } - - if ( conv_passwd != NULL ) { - free( conv_passwd ); - } - - return; /* a qualified success */ - } - } -#ifdef HAVE_SASL_OPTIONS - } -#endif /* HAVE_SASL_OPTIONS */ - - if ( conv_binddn != NULL ) { - free( conv_binddn ); - } - - if ( conv_passwd != NULL ) { - free( conv_passwd ); - } - - /* - * bind(s) failed -- fatal error - */ - ldap_unbind( ld ); - exit( rc ); -} - - -/* - * close open files, unbind, etc. - */ -void -ldaptool_cleanup( LDAP *ld ) -{ - if ( ld != NULL ) { - ldap_unbind( ld ); - } - - if ( ldaptool_fp != NULL && ldaptool_fp != stdin ) { - fclose( ldaptool_fp ); - ldaptool_fp = NULL; - } -} - - -/* - * Retrieve and print an LDAP error message. Returns the LDAP error code. - */ -int -ldaptool_print_lderror( LDAP *ld, char *msg, int check4ssl ) -{ - int lderr = ldap_get_lderrno( ld, NULL, NULL ); - - ldap_perror( ld, msg ); - if ( ( secure || isZZ ) && check4ssl != LDAPTOOL_CHECK4SSL_NEVER ) { - if ( check4ssl == LDAPTOOL_CHECK4SSL_ALWAYS - || ( lderr == LDAP_SERVER_DOWN ) - || ( lderr == LDAP_CONNECT_ERROR )) { - int sslerr = PORT_GetError(); - if ( isZZ ) { - fprintf( stderr, "\tTLS/SSL error %d (%s)\n", sslerr, - ldapssl_err2string( sslerr )); - } - else { - fprintf( stderr, "\tSSL error %d (%s)\n", sslerr, - ldapssl_err2string( sslerr )); - } - } - } - - return( lderr ); -} - - -/* - * print referrals to stderr - */ -void -ldaptool_print_referrals( char **refs ) -{ - int i; - - if ( refs != NULL ) { - for ( i = 0; refs[ i ] != NULL; ++i ) { - fprintf( stderr, "Referral: %s\n", refs[ i ] ); - } - } -} - - -/* - * print contents of an extended response to stderr - * this is mainly to support unsolicited notifications - * Returns an LDAP error code (from the extended result). - */ -int -ldaptool_print_extended_response( LDAP *ld, LDAPMessage *res, char *msg ) -{ - char *oid; - struct berval *data; - - if ( ldap_parse_extended_result( ld, res, &oid, &data, 0 ) - != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); - } else { - if ( oid != NULL ) { - if ( strcmp ( oid, LDAP_NOTICE_OF_DISCONNECTION ) == 0 ) { - fprintf( stderr, "%s: Notice of Disconnection\n", msg ); - } else { - fprintf( stderr, "%s: OID %s\n", msg, oid ); - } - ldap_memfree( oid ); - } else { - fprintf( stderr, "%s: missing OID\n", msg ); - } - - if ( data != NULL ) { - fprintf( stderr, "%s: Data (length %d):\n", msg, data->bv_len ); -#if 0 -/* XXXmcs: maybe we should display the actual data? */ - lber_bprint( data->bv_val, data->bv_len ); -#endif - ber_bvfree( data ); - } - } - - return parse_result( ld, res, NULL, msg, 1 ); -} - - -/* - * Like ldap_sasl_bind_s() but calls wait4result() to display - * any referrals returned and report errors in a consistent way. - */ -int -ldaptool_sasl_bind_s( LDAP *ld, const char *dn, const char *mechanism, - const struct berval *cred, LDAPControl **serverctrls, - LDAPControl **clientctrls, struct berval **servercredp, char *msg ) -{ - int rc, msgid; - - if ( servercredp != NULL ) { - *servercredp = NULL; - } - - if (( rc = ldap_sasl_bind( ld, dn, mechanism, cred, serverctrls, - clientctrls, &msgid )) != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); - } else { - rc = wait4result( ld, msgid, servercredp, msg ); - } - - return( rc ); -} - - -/* - * Like ldap_simple_bind_s() but calls wait4result() to display - * any referrals returned and report errors in a consistent way. - */ -int -ldaptool_simple_bind_s( LDAP *ld, const char *dn, const char *passwd, - LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ) -{ - struct berval bv; - - bv.bv_val = (char *)passwd; /* XXXmcs: had to cast away const */ - bv.bv_len = ( passwd == NULL ? 0 : strlen( passwd )); - return( ldaptool_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &bv, serverctrls, - clientctrls, NULL, msg )); -} - - -/* - * Like ldap_add_ext_s() but calls wait4result() to display - * any referrals returned and report errors in a consistent way. - */ -int -ldaptool_add_ext_s( LDAP *ld, const char *dn, LDAPMod **attrs, - LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ) -{ - int rc, msgid; - - if (( rc = ldap_add_ext( ld, dn, attrs, serverctrls, clientctrls, &msgid )) - != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); - } else { - /* - * 25-April-2000 Note: the next line used to read: - * rc = wait4result( ld, msgid, NULL, msg ); - * 'msgid' it was changed to 'LDAP_RES_ANY' in order to receive - * unsolicited notifications. - */ - rc = wait4result( ld, LDAP_RES_ANY, NULL, msg ); - } - - return( rc ); -} - - -/* - * Like ldap_modify_ext_s() but calls wait4result() to display - * any referrals returned and report errors in a consistent way. - */ -int -ldaptool_modify_ext_s( LDAP *ld, const char *dn, LDAPMod **mods, - LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ) -{ - int rc, msgid; - - if (( rc = ldap_modify_ext( ld, dn, mods, serverctrls, clientctrls, - &msgid )) != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); - } else { - rc = wait4result( ld, msgid, NULL, msg ); - } - - return( rc ); -} - - -/* - * Like ldap_delete_ext_s() but calls wait4result() to display - * any referrals returned and report errors in a consistent way. - */ -int -ldaptool_delete_ext_s( LDAP *ld, const char *dn, LDAPControl **serverctrls, - LDAPControl **clientctrls, char *msg ) -{ - int rc, msgid; - - if (( rc = ldap_delete_ext( ld, dn, serverctrls, clientctrls, &msgid )) - != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); - } else { - rc = wait4result( ld, msgid, NULL, msg ); - } - - return( rc ); -} - - -/* - * Like ldap_compare_ext_s() but calls wait4result() to display - * any referrals returned and report errors in a consistent way. - */ -int ldaptool_compare_ext_s( LDAP *ld, const char *dn, const char *attrtype, - const struct berval *bvalue, LDAPControl **serverctrls, - LDAPControl **clientctrls, char *msg ) -{ - int rc, msgid; - - if (( rc = ldap_compare_ext( ld, dn, attrtype, bvalue, serverctrls, - clientctrls, &msgid )) != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); - } else { - rc = wait4result( ld, msgid, NULL, msg ); - } - - return( rc ); -} - - -/* - * Like ldap_rename_s() but calls wait4result() to display - * any referrals returned and report errors in a consistent way. - */ -int -ldaptool_rename_s( LDAP *ld, const char *dn, const char *newrdn, - const char *newparent, int deleteoldrdn, LDAPControl **serverctrls, - LDAPControl **clientctrls, char *msg ) -{ - int rc, msgid; - - if (( rc = ldap_rename( ld, dn, newrdn, newparent, deleteoldrdn, - serverctrls, clientctrls, &msgid )) != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); - } else { - rc = wait4result( ld, msgid, NULL, msg ); - } - - return( rc ); -} - - -/* - * Wait for a result, check for and display errors and referrals. - * Also recognize and display "Unsolicited notification" messages. - * Returns an LDAP error code. - */ -static int -wait4result( LDAP *ld, int msgid, struct berval **servercredp, char *msg ) -{ - LDAPMessage *res; - int rc, received_only_unsolicited = 1; - - while ( received_only_unsolicited ) { - res = NULL; - if (( rc = ldap_result( ld, msgid, 1, (struct timeval *)NULL, &res )) - == -1 ) { - (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); - return( ldap_get_lderrno( ld, NULL, NULL )); - } - - /* - * Special handling for unsolicited notifications: - * 1. Parse and display contents. - * 2. go back and wait for another (real) result. - */ - if ( rc == LDAP_RES_EXTENDED - && ldap_msgid( res ) == LDAP_RES_UNSOLICITED ) { - rc = ldaptool_print_extended_response( ld, res, - "Unsolicited response" ); - } else { - rc = parse_result( ld, res, servercredp, msg, 1 ); - received_only_unsolicited = 0; /* we're done */ - } - } - - return( rc ); -} - - -static int -parse_result( LDAP *ld, LDAPMessage *res, struct berval **servercredp, - char *msg, int freeit ) -{ - int rc, lderr, errno; - char **refs = NULL; - LDAPControl **ctrls; - - if (( rc = ldap_parse_result( ld, res, &lderr, NULL, NULL, &refs, - &ctrls, 0 )) != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); - ldap_msgfree( res ); - return( rc ); - } - - if ( (rc = check_response_controls( ld, msg, ctrls, 1 )) != LDAP_SUCCESS ) { - ldap_msgfree( res ); - return( rc ); - } - - if ( servercredp != NULL && ( rc = ldap_parse_sasl_bind_result( ld, res, - servercredp, 0 )) != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); - ldap_msgfree( res ); - return( rc ); - } - - if ( freeit ) { - ldap_msgfree( res ); - } - - if ( LDAPTOOL_RESULT_IS_AN_ERROR( lderr )) { - (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); - } - - if ( refs != NULL ) { - ldaptool_print_referrals( refs ); - ldap_value_free( refs ); - } - - return( lderr ); -} - -/* - * check for response controls. authentication response control - * and PW POLICY control are the ones we care about right now. - */ -static int -check_response_controls( LDAP *ld, char *msg, LDAPControl **ctrls, int freeit ) -{ - int i; - int errno; - int pw_days=0, pw_hrs=0, pw_mins=0, pw_secs=0; /* for pwpolicy */ - char *s = NULL; - BerElement *ber = NULL; - static const char *pwpolicy_err2str[] = { - "Password has expired.", - "Account is locked.", - "Password has been reset by an administrator; you must change it.", - "Password change not allowed.", - "Must supply old password.", - "Invalid password syntax.", - "Password too short.", - "Password too young.", - "Password in history." - }; - - if ( NULL != ctrls ) { - for ( i = 0; NULL != ctrls[i]; ++i ) { - - if ( 0 == strcmp( ctrls[i]->ldctl_oid, - LDAP_CONTROL_AUTH_RESPONSE )) { - s = ctrls[i]->ldctl_value.bv_val; - if ( NULL == s ) { - s = "Null"; - } else if ( *s == '\0' ) { - s = "Anonymous"; - } - fprintf( stderr, "%s: bound as %s\n", ldaptool_progname, s ); - } /* end of LDAP_CONTROL_AUTH_RESPONSE */ - - if ( 0 == strcmp( ctrls[i]->ldctl_oid, - LDAP_CONTROL_PWEXPIRING )) { - - /* Warn the user his passwd is to expire */ - errno = 0; - pw_secs = atoi(ctrls[i]->ldctl_value.bv_val); - if ( pw_secs > 0 && errno != ERANGE ) { - if ( pw_secs > 86400 ) { - pw_days = ( pw_secs / 86400 ); - pw_secs = ( pw_secs % 86400 ); - } - if ( pw_secs > 3600 ) { - pw_hrs = ( pw_secs / 3600 ); - pw_secs = ( pw_secs % 3600 ); - } - if ( pw_secs > 60 ) { - pw_mins = ( pw_secs / 60 ); - pw_secs = ( pw_secs % 60 ); - } - - printf("%s: Warning ! Your password will expire after ", ldaptool_progname); - if ( pw_days ) { - printf ("%d days, ", pw_days); - } - if ( pw_hrs ) { - printf ("%d hrs, ", pw_hrs); - } - if ( pw_mins ) { - printf ("%d mins, ", pw_mins); - } - printf("%d seconds.\n", pw_secs); - } - } /* end of LDAP_CONTROL_PWEXPIRING */ - - if ( 0 == strcmp( ctrls[i]->ldctl_oid, - LDAP_X_CONTROL_PWPOLICY_RESPONSE )) { - ber_tag_t tag1=0, tag2=0, tag3=0; - ber_int_t warnvalue=0; - int grclogins=-1, secsleft=-1; - ber_int_t errvalue=-1; - static int err2str_size = sizeof(pwpolicy_err2str)/sizeof(pwpolicy_err2str[0]); - - if ( ( ber = ber_init(&(ctrls[i]->ldctl_value)) ) == NULL ) { - fprintf(stderr, "%s: not enough memory\n", ldaptool_progname); - return( LDAP_NO_MEMORY ); - } - if ( ber_scanf(ber,"{t", &tag1) == LBER_ERROR ) { - /* error */ - ber_free( ber, 1 ); - return (ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - switch (tag1) { - case LDAP_TAG_PWP_WARNING: - if ( ber_scanf(ber, "{ti}", &tag2, &warnvalue) - == LBER_ERROR ) { - /* error */ - ber_free( ber, 1 ); - return(ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - switch (tag2) { - case LDAP_TAG_PWP_SECSLEFT: - secsleft = (int)warnvalue; - break; - case LDAP_TAG_PWP_GRCLOGINS: - grclogins = (int)warnvalue; - break; - default: - /* error */ - ber_free( ber, 1 ); - return(ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - /* Now check for the error value if it's present */ - if ( ber_scanf(ber, "te", &tag3, &errvalue) != LBER_ERROR ) { - if (tag3 != LDAP_TAG_PWP_ERROR) { - errvalue = -1; - } - } - break; - case LDAP_TAG_PWP_ERROR: - if ( ber_scanf(ber, "e}", &errvalue) - == LBER_ERROR ) { - /* error */ - ber_free( ber, 1 ); - return(ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - break; - default : /* error */ - ber_free( ber, 1 ); - return(ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - - /* Now we have all the values */ - if ( secsleft >= 0 ) { - fprintf(stderr, "%s: Password will expire in %d seconds\n", - ldaptool_progname, secsleft); - } - if ( grclogins >= 0 ) { - fprintf(stderr, "%s: %d grace login(s) remain\n", - ldaptool_progname, grclogins); - } - if ( errvalue >= 0 && errvalue < err2str_size ) { - fprintf(stderr, "%s: %s\n", - ldaptool_progname, pwpolicy_err2str[errvalue]); - } else if ( errvalue != -1 ) { - fprintf(stderr, "%s: %s\n", - ldaptool_progname, - "Invalid error value in password policy response control"); - } - } /* end of LDAP_X_CONTROL_PWPOLICY_RESPONSE */ - - } - - if ( freeit ) { - ldap_controls_free( ctrls ); - ber_free( ber, 1 ); - } - } - return( LDAP_SUCCESS ); -} - -/* - * if -M was passed on the command line, create and return a "Manage DSA IT" - * LDAPv3 control. If not, return NULL. - */ -LDAPControl * -ldaptool_create_manage_dsait_control( void ) -{ - LDAPControl *ctl; - - if ( !send_manage_dsait_ctrl ) { - return( NULL ); - } - - if (( ctl = (LDAPControl *)calloc( 1, sizeof( LDAPControl ))) == NULL || - ( ctl->ldctl_oid = strdup( LDAP_CONTROL_MANAGEDSAIT )) == NULL ) { - perror( "calloc" ); - exit( LDAP_NO_MEMORY ); - } - - ctl->ldctl_iscritical = 1; - - return( ctl ); -} - -/* - * if -y "dn" was supplied on the command line, create the control - */ -LDAPControl * -ldaptool_create_proxyauth_control( LDAP *ld ) -{ - LDAPControl *ctl = NULL; - int rc; - - - if ( !proxyauth_id) - return( NULL ); - - if ( 2 == proxyauth_version ) { - rc = ldap_create_proxiedauth_control( ld, proxyauth_id, &ctl); - } else { - rc = ldap_create_proxyauth_control( ld, proxyauth_id, 1, &ctl); - } - if ( rc != LDAP_SUCCESS) - { - if (ctl) - ldap_control_free( ctl); - return NULL; - } - return( ctl ); -} - -/* Effective Rights control */ -LDAPControl * -ldaptool_create_geteffectiveRights_control ( LDAP *ld, const char *authzid, - const char **attrlist) -{ - LDAPControl *ctl = NULL; - int rc; - - rc = ldap_create_geteffectiveRights_control( ld, authzid, attrlist, 1, - &ctl); - - if ( rc != LDAP_SUCCESS) - { - if (ctl) - ldap_control_free( ctl); - return NULL; - } - return( ctl ); -} - -void -ldaptool_add_control_to_array( LDAPControl *ctrl, LDAPControl **array) -{ - - int i; - for (i=0; i< CONTROL_REQUESTS; i++) - { - if (*(array + i) == NULL) - { - *(array + i +1) = NULL; - *(array + i) = ctrl; - return ; - } - } - fprintf(stderr, "%s: failed to store request control!!!!!!\n", - ldaptool_progname); -} - -/* - * Dispose of all controls in array and prepare array for reuse. - */ -void -ldaptool_reset_control_array( LDAPControl **array ) -{ - int i; - - for ( i = 0; i < CONTROL_REQUESTS; i++ ) { - if ( array[i] != NULL ) { - ldap_control_free( array[i] ); - array[i] = NULL; - } - } -} - -/* - * This function calculates control value and its length. *value can - * be pointing to plain value, ":b64encoded value" or "<fileurl". - */ -static int -calculate_ctrl_value( const char *value, - char **ctrl_value, int *vlen) -{ - int b64; - if (*value == ':') { - value++; - b64 = 1; - } else { - b64 = 0; - } - *ctrl_value = (char *)value; - - if ( b64 ) { - if (( *vlen = ldif_base64_decode( (char *)value, - (unsigned char *)value )) < 0 ) { - fprintf( stderr, - "Unable to decode base64 control value \"%s\"\n", value); - return( -1 ); - } - } else { - *vlen = (int)strlen(*ctrl_value); - } - return( 0 ); -} - -/* - * Parse the optarg from -J option of ldapsearch - * and within LDIFfile for ldapmodify. Take ctrl_arg - * (the whole string) and divide it into oid, criticality - * and value. This function breaks down original ctrl_arg - * with '\0' in places. Also, calculate length of valuestring. - */ -int -ldaptool_parse_ctrl_arg(char *ctrl_arg, char sep, - char **ctrl_oid, int *ctrl_criticality, - char **ctrl_value, int *vlen) -{ - char *s, *p; - int strict; - - /* Initialize passed variables with default values */ - *ctrl_oid = *ctrl_value = NULL; - *ctrl_criticality = 0; - *vlen = 0; - - strict = (sep == ' ' ? 1 : 0); - if(!(s=strchr(ctrl_arg, sep))) { - /* Possible values of ctrl_arg are - * oid[:value|::b64value|:<fileurl] within LDIF, i.e. sep=' ' - * oid from command line option, i.e. sep=':' - */ - if (sep == ' ') { - if (!(s=strchr(ctrl_arg, ':'))) { - *ctrl_oid = ctrl_arg; - } - else { - /* ctrl_arg is of oid:[value|:b64value|<fileurl] - * form in the LDIF record. So, grab the oid and then - * jump to continue the parsing of ctrl_arg. - * 's' is pointing just after oid ends. - */ - *s++ = '\0'; - *ctrl_oid = ctrl_arg; - return (calculate_ctrl_value( s, ctrl_value, vlen )); - } - } else { - /* oid - from command line option, i.e. sep=':' */ - *ctrl_oid = ctrl_arg; - } - } - else { - /* Possible values of ctrl_arg are - * oid:criticality[:value|::b64value|:<fileurl] - command line - * oid criticality[:value|::b64value|:<fileurl] - LDIF - * And 's' is pointing just after oid ends. - */ - - if (*(s+1) == '\0') { - fprintf( stderr, "missing value\n" ); - return( -1 ); - } - *s = '\0'; - *ctrl_oid = ctrl_arg; - p = ++s; - if(!(s=strchr(p, ':'))) { - if ( (*ctrl_criticality = ldaptool_boolean_str2value(p, strict)) - == -1 ) { - fprintf( stderr, "Invalid criticality value\n" ); - return( -1 ); - } - } - else { - if (*(s+1) == '\0') { - fprintf( stderr, "missing value\n" ); - return ( -1 ); - } - *s++ = '\0'; - if ( (*ctrl_criticality = ldaptool_boolean_str2value(p, strict)) - == -1 ) { - fprintf( stderr, "Invalid criticality value\n" ); - return ( -1 ); - } - return (calculate_ctrl_value( s, ctrl_value, vlen )); - } - } - - return( 0 ); -} - - -/* - * callback function for LDAP bind credentials - */ -/*ARGSUSED*/ -static int -LDAP_CALL -LDAP_CALLBACK -get_rebind_credentials( LDAP *ld, char **whop, char **credp, - int *methodp, int freeit, void* arg ) -{ - if ( !freeit ) { - if ( binddn != NULL ) { - *whop = ldaptool_local2UTF8( binddn, "bind DN" ); - } - - if ( passwd != NULL ) { - if ( isk ) { - *credp = strdup( passwd ); - } else { - *credp = ldaptool_local2UTF8( passwd, "password" ); - } - } - - *methodp = LDAP_AUTH_SIMPLE; - } else { - if ( *whop != NULL ) { - free( *whop ); - } - - if ( *credp != NULL ) { - free( *credp ); - } - - *methodp = LDAP_AUTH_NONE; - } - - return( LDAP_SUCCESS ); -} - - -/* - * return pointer to pathname to temporary directory. - * First we see if the environment variable "TEMP" is set and use it. - * Then we see if the environment variable "TMP" is set and use it. - * If this fails, we use "/tmp" on UNIX and fail on Windows. - */ -char * -ldaptool_get_tmp_dir( void ) -{ - char *p; - int offset; - - if (( p = getenv( "TEMP" )) == NULL && ( p = getenv( "TMP" )) == NULL ) { -#ifdef _WINDOWS - fprintf( stderr, "%s: please set the TEMP environment variable.\n", - ldaptool_progname ); - exit( LDAP_LOCAL_ERROR ); -#else - return( "/tmp" ); /* last resort on UNIX */ -#endif - } - - /* - * remove trailing slash if present - */ - offset = strlen( p ) - 1; - if ( p[offset] == '/' -#ifdef _WINDOWS - || p[offset] == '\\' -#endif - ) { - if (( p = strdup( p )) == NULL ) { - perror( "strdup" ); - exit( LDAP_NO_MEMORY ); - } - - p[offset] = '\0'; - } - - return( p ); -} - - -int -ldaptool_berval_is_ascii( const struct berval *bvp ) -{ - unsigned long j; - int is_ascii = 1; /* optimistic */ - - for ( j = 0; j < bvp->bv_len; ++j ) { - if ( !isascii( bvp->bv_val[ j ] )) { - is_ascii = 0; - break; - } - } - - return( is_ascii ); -} - - -#ifdef LDAP_DEBUG_MEMORY -#define LDAPTOOL_ALLOC_FREED 0xF001 -#define LDAPTOOL_ALLOC_INUSE 0xF002 - -static void * -ldaptool_debug_alloc( void *ptr, size_t size ) -{ - int *statusp; - void *systemptr; - - if ( ptr == NULL ) { - systemptr = NULL; - } else { - systemptr = (void *)((char *)ptr - sizeof(int)); - } - - if (( statusp = (int *)realloc( systemptr, size + sizeof(int))) == NULL ) { - fprintf( stderr, "%s: realloc( 0x%x, %d) failed\n", - ldaptool_progname, systemptr, size ); - return( NULL ); - } - - *statusp = LDAPTOOL_ALLOC_INUSE; - - return( (char *)statusp + sizeof(int)); -} - - -static void * -ldaptool_debug_realloc( void *ptr, size_t size ) -{ - void *p; - - if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { - fprintf( stderr, "%s: => realloc( 0x%x, %d )\n", - ldaptool_progname, ptr, size ); - } - - p = ldaptool_debug_alloc( ptr, size ); - - if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { - fprintf( stderr, "%s: 0x%x <= realloc()\n", ldaptool_progname, p ); - } - - return( p ); -} - - -static void * -ldaptool_debug_malloc( size_t size ) -{ - void *p; - - if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { - fprintf( stderr, "%s: => malloc( %d)\n", ldaptool_progname, size ); - } - - p = ldaptool_debug_alloc( NULL, size ); - - if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { - fprintf( stderr, "%s: 0x%x <= malloc()\n", ldaptool_progname, p ); - } - - return( p ); -} - - -static void * -ldaptool_debug_calloc( size_t nelem, size_t elsize ) -{ - void *p; - - if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { - fprintf( stderr, "%s: => calloc( %d, %d )\n", - ldaptool_progname, nelem, elsize ); - } - - if (( p = ldaptool_debug_alloc( NULL, nelem * elsize )) != NULL ) { - memset( p, 0, nelem * elsize ); - } - - if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { - fprintf( stderr, "%s: 0x%x <= calloc()\n", ldaptool_progname, p ); - } - - return( p ); -} - - -static void -ldaptool_debug_free( void *ptr ) -{ - int *statusp = (int *)((char *)ptr - sizeof(int)); - - if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { - fprintf( stderr, "%s: => free( 0x%x )\n", ldaptool_progname, ptr ); - } - - if ( ptr == NULL ) { - fprintf( stderr, "%s: bad free( 0x0 ) attempted (NULL pointer)\n", - ldaptool_progname ); - } else if ( *statusp != LDAPTOOL_ALLOC_INUSE ) { - fprintf( stderr, "%s: bad free( 0x%x ) attempted" - " (block not in use; status is %d)\n", - ldaptool_progname, ptr, *statusp ); - } else { - *statusp = LDAPTOOL_ALLOC_FREED; - free( statusp ); - } -} -#endif /* LDAP_DEBUG_MEMORY */ - - -#if defined(NET_SSL) -#ifdef LDAP_TOOL_PKCS11 -static -char * -buildTokenCertName( const char *tokenName, const char *certName) -{ - - int tokenlen = strlen(tokenName); - int len = tokenlen + strlen(certName) +2; - char *result; - - if (( result = malloc( len )) != NULL) { - strcpy(result, tokenName); - *(result+tokenlen) = ':'; - ++tokenlen; - strcpy(result+tokenlen, certName); - } else { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - return result; -} - - - -/*ARGSUSED*/ -static int -ldaptool_getcertpath( void *context, char **certlocp ) -{ - - *certlocp = ssl_certdbpath; - if ( ldaptool_verbose ) { - if (ssl_certdbpath) - { - printf("ldaptool_getcertpath -- %s\n", ssl_certdbpath ); - } - else - { - printf("ldaptool_getcertpath -- (null)\n"); - } - - } - return LDAP_SUCCESS; -} - -/*ARGSUSED*/ -int -ldaptool_getcertname( void *context, char **certnamep ) -{ - - *certnamep = ssl_certname; - if ( ldaptool_verbose ) { - if (ssl_certname) - { - printf("ldaptool_getcertname -- %s\n", *certnamep); - } - else - { - printf("ldaptool_getcertname -- (null)\n"); - } - } - return LDAP_SUCCESS; -} - -/*ARGSUSED*/ -int -ldaptool_getkeypath(void *context, char **keylocp ) -{ - *keylocp = ssl_keydbpath; - if ( ldaptool_verbose ) { - if (ssl_keydbpath) - { - printf("ldaptool_getkeypath -- %s\n",*keylocp); - } - else - { - printf("ldaptool_getkeypath -- (null)\n"); - } - } - - return LDAP_SUCCESS; -} - -/*ARGSUSED*/ -int -ldaptool_gettokenname( void *context, char **tokennamep ) -{ - - *tokennamep = pkcs_token; - if ( ldaptool_verbose ) { - if (pkcs_token) - { - printf("ldaptool_gettokenname -- %s\n",*tokennamep); - } - else - { - printf("ldaptool_gettokenname -- (null)\n"); - } - } - - return LDAP_SUCCESS; -} - -/*ARGSUSED*/ -int -ldaptool_gettokenpin( void *context, const char *tokennamep, char **tokenpinp) -{ - -#if 0 - char *localtoken; -#endif - -/* XXXceb this stuff is removed for the time being. - * This function should return the pin from ssl_password - */ - - - *tokenpinp = ssl_passwd; - return LDAP_SUCCESS; - -#if 0 - - ldaptool_gettokenname( NULL, &localtoken); - - if (strcmp( localtoken, tokennamep)) - - *tokenpinp = pkcs_pin; - else - *tokenpinp = NULL; - - if ( ldaptool_verbose ) { - if (pkcs_pin) - { - printf("ldaptool_getokenpin --%s\n", tokenpinp); - } - else - { - printf("ldaptool_getokenpin -- (null)\n"); - } - } - return LDAP_SUCCESS; -#endif -} - -/*ARGSUSED*/ -int -ldaptool_getmodpath( void *context, char **modulep ) -{ - *modulep = ssl_secmodpath; - if ( ldaptool_verbose ) { - if (ssl_secmodpath) - { - printf("ldaptool_getmodpath -- %s\n", *modulep); - } - else - { - printf("ldaptool_getmodpath -- (null)\n"); - } - } - - return LDAP_SUCCESS; -} - -/*ARGSUSED*/ -int -ldaptool_getdonglefilename( void *context, char **filename ) -{ - *filename = ssl_donglefile; - if ( ldaptool_verbose ) { - if (ssl_donglefile) - { - printf("ldaptool_getdonglefilename -- %s\n", *filename); - } - else - { - printf("ldaptool_getdonglefilename -- (null)\n"); - } - - } - - return LDAP_SUCCESS; -} - -static void -ldaptool_setcallbacks( struct ldapssl_pkcs_fns *pfns) -{ - pfns->pkcs_getcertpath = (int (*)(void *, char **))ldaptool_getcertpath; - pfns->pkcs_getcertname = (int (*)(void *, char **))ldaptool_getcertname; - pfns->pkcs_getkeypath = (int (*)(void *, char **)) ldaptool_getkeypath; - pfns->pkcs_getmodpath = (int (*)(void *, char **)) ldaptool_getmodpath; - pfns->pkcs_getpin = (int (*)(void *, const char*, char **)) ldaptool_gettokenpin; - pfns->pkcs_gettokenname = (int (*)(void *, char **)) ldaptool_gettokenname; - pfns->pkcs_getdonglefilename = (int (*)(void *, char **)) ldaptool_getdonglefilename; - pfns->local_structure_id=PKCS_STRUCTURE_ID; -} - -#endif /* LDAP_TOOL_PKCS11 */ -#endif /* NET_SSL */ - -#ifdef HAVE_SASL_OPTIONS -/* - * Function checks for valid args, returns an error if not found - * and sets SASL params from command line - */ - -static int -saslSetParam(char *saslarg) -{ - char *attr = NULL; - int argnamelen; - - attr = strchr(saslarg, '='); - if (attr == NULL) { - fprintf( stderr, "Didn't find \"=\" character in %s\n", saslarg); - return (-1); - } - - argnamelen = attr - saslarg; - attr++; - - if (!strncasecmp(saslarg, "secProp", argnamelen)) { - if ( sasl_secprops != NULL ) { - fprintf( stderr, "secProp previously specified\n"); - return (-1); - } - if (( sasl_secprops = strdup(attr)) == NULL ) { - perror ("malloc"); - exit (LDAP_NO_MEMORY); - } - } else if (!strncasecmp(saslarg, "realm", argnamelen)) { - if ( sasl_realm != NULL ) { - fprintf( stderr, "Realm previously specified\n"); - return (-1); - } - if (( sasl_realm = strdup(attr)) == NULL ) { - perror ("malloc"); - exit (LDAP_NO_MEMORY); - } - } else if (!strncasecmp(saslarg, "authzid", argnamelen)) { - if (sasl_username != NULL) { - fprintf( stderr, "Authorization name previously specified\n"); - return (-1); - } - if (( sasl_username = strdup(attr)) == NULL ) { - perror ("malloc"); - exit (LDAP_NO_MEMORY); - } - } else if (!strncasecmp(saslarg, "authid", argnamelen)) { - if ( sasl_authid != NULL ) { - fprintf( stderr, "Authentication name previously specified\n"); - return (-1); - } - if (( sasl_authid = strdup(attr)) == NULL) { - perror ("malloc"); - exit (LDAP_NO_MEMORY); - } - } else if (!strncasecmp(saslarg, "mech", argnamelen)) { - if ( sasl_mech != NULL ) { - fprintf( stderr, "Mech previously specified\n"); - return (-1); - } - if (( sasl_mech = strdup(attr)) == NULL) { - perror ("malloc"); - exit (LDAP_NO_MEMORY); - } - } else if (!strncasecmp(saslarg, "flags", argnamelen)) { - int len = strlen(attr); - if (len && !strncasecmp(attr, "automatic", len)) { - sasl_flags = LDAP_SASL_AUTOMATIC; - } else if (len && !strncasecmp(attr, "interactive", len)) { - sasl_flags = LDAP_SASL_INTERACTIVE; - } else if (len && !strncasecmp(attr, "quiet", len)) { - sasl_flags = LDAP_SASL_QUIET; - } else { - fprintf(stderr, "Invalid SASL flags value [%s]: must be one of " - "automatic, interactive, or quiet\n", attr); - return (-1); - } - } else { - fprintf (stderr, "Invalid attribute name %s\n", saslarg); - return (-1); - } - return 0; -} -#endif /* HAVE_SASL_OPTIONS */ - -/* - * Implements getpass like functionality for supported platforms. - * - * It is the callers responsibility to zero out the memory used - * to store the password and to free it when it's finished with - * it. - */ -char * -ldaptool_getpass ( const char *prompt ) -{ - char *pass; - -#if defined(_WIN32) - char pbuf[257]; - fputs(prompt,stdout); - fflush(stdout); - if (fgets(pbuf,256,stdin) == NULL) { - pass = NULL; - } else { - char *tmp; - - tmp = strchr(pbuf,'\n'); - if (tmp) *tmp = '\0'; - tmp = strchr(pbuf,'\r'); - if (tmp) *tmp = '\0'; - pass = strdup(pbuf); - } -#else -#if defined(SOLARIS) - /* 256 characters on Solaris */ - pass = (char *)getpassphrase(prompt); -#else -#if defined(HPUX) - /* HP-UX has deprecated their password asking function, so we have - * to resort to doing it the hard way . . . */ - char pbuf[257]; - struct termios termstat; - tcflag_t savestat; - /* Only perform terminal manipulation if stdin is a terminal */ - int havetty = isatty(fileno(stdin)); - - fputs(prompt, stdout); - fflush(stdout); - - if(havetty) { - if(tcgetattr(fileno(stdin), &termstat) < 0) { - perror( "tcgetattr" ); - exit( LDAP_LOCAL_ERROR ); - } - savestat = termstat.c_lflag; - termstat.c_lflag &= ~(ECHO | ECHOE | ECHOK); - termstat.c_lflag |= (ICANON | ECHONL); - if(tcsetattr(fileno(stdin), TCSANOW, &termstat) < 0) { - perror( "tcsetattr" ); - exit( LDAP_LOCAL_ERROR ); - } - } - if (fgets(pbuf,256,stdin) == NULL) { - pass = NULL; - } else { - char *tmp; - pass = NULL; - tmp = strchr(pbuf,'\n'); - if (tmp) - *tmp = '\0'; - pass = strdup(pbuf); - } - if(havetty) { - termstat.c_lflag = savestat; - if(tcsetattr(fileno(stdin), TCSANOW, &termstat) < 0) { - perror( "tcgetattr" ); - exit( LDAP_LOCAL_ERROR ); - } - } -#else - /* limited to 16 chars on Tru64, 32 on AIX */ - pass = (char *)getpass(prompt); -#endif -#endif -#endif - - return pass; -} - -/* - * ldaptool_read_password - * - * Reads the password in from a file. - */ -char * -ldaptool_read_password( FILE *mod_password_fp ) -{ - int increment = 0; - int c, index; - char *mod_passwd = NULL; - - /* allocate initial block of memory */ - if ((mod_passwd = (char *)malloc(BUFSIZ)) == NULL) { - fprintf( stderr, "%s: not enough memory to read password from file\n", ldaptool_progname ); - exit( LDAP_NO_MEMORY ); - } - increment++; - index = 0; - while ((c = fgetc( mod_password_fp )) != '\n' && c != EOF) { - - /* check if we will overflow the buffer */ - if ((c != EOF) && (index == ((increment * BUFSIZ) -1))) { - - /* if we did, add another BUFSIZ worth of bytes */ - if ((mod_passwd = (char *) - realloc(mod_passwd, (increment + 1) * BUFSIZ)) == NULL) { - fprintf( stderr, "%s: not enough memory to read password from file\n", ldaptool_progname ); - exit( LDAP_NO_MEMORY ); - } - increment++; - } - mod_passwd[index++] = c; - } - mod_passwd[index] = '\0'; - - return( (char *)mod_passwd ); -} - -int -ldaptool_boolean_str2value ( const char *ptr, int strict ) -{ - if (strict) { - if ( !(strcasecmp(ptr, "true"))) { - return 1; - } - else if ( !(strcasecmp(ptr, "false"))) { - return 0; - } - else { - return (-1); - } - } - else { - if ( !(strcasecmp(ptr, "true")) || - !(strcasecmp(ptr, "t")) || - !(strcmp(ptr, "1")) ) { - return (1); - } - else if ( !(strcasecmp(ptr, "false")) || - !(strcasecmp(ptr, "f")) || - !(strcmp(ptr, "0")) ) { - return (0); - } - else { - return (-1); - } - } -} - -FILE * -ldaptool_open_file(const char *filename, const char *mode) -{ -#ifdef _LARGEFILE64_SOURCE - return fopen64(filename, mode); -#else - return fopen(filename, mode); -#endif -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/clients/tools/ldapcmp.c
Deleted
@@ -1,619 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* tool to compare the contents of two LDAP directory subtrees */ - -#include "ldaptool.h" - -typedef struct attr { - char *name; - char **vals; - struct attr *next; -} ATTR; /* used for comparing two entries */ - -static void options_callback( int option, char *optarg ); -static int docompare( LDAP *ld1, LDAP *ld2, char *base ); -static int cmp2(LDAP *ld1, LDAP *ld2, LDAPMessage *e1, int findonly ); -static void notfound(char *base, int dbaseno); -static ATTR* get_attrs( LDAP *ld, LDAPMessage *e ); -static char* cmp_attrs( ATTR *a1, ATTR *a2 ); -static void attr_free(ATTR *at); -#if 0 /* these functions are not used */ -static void print_entry( LDAP *ld, LDAPMessage *entry, int attrsonly ); -static void print_dn( LDAP *ld, LDAPMessage *entry ); -static void write_ldif_value( char *type, char *value, unsigned long vallen ); -#endif /* 0 */ - -static void -usage( void ) -{ - fprintf( stderr, - "usage: %s -b basedn [options] [attributes...]\nwhere:\n", - ldaptool_progname ); - fprintf( stderr, " basedn\tbase dn for search\n" ); - fprintf( stderr, "\t\t(if the environment variable LDAP_BASEDN is set,\n" ); - fprintf( stderr, "\t\tthen the -b flag is not required)\n" ); - fprintf( stderr, "options:\n" ); - fprintf( stderr, " -s scope\tone of base, one, or sub (default is sub)\n" ); - fprintf( stderr, " -l timelim\ttime limit (in seconds) for search (default is no limit)\n" ); - fprintf( stderr, " -z sizelim\tsize limit (in entries) for search (default is no limit)\n" ); - ldaptool_common_usage( 1 ); - exit( LDAP_PARAM_ERROR ); -} - -static char *base = NULL; -static int allow_binary, vals2tmp, ldif, scope, deref, differ=0; -static int attrsonly, timelimit, sizelimit; -#if 0 /* these statics are referenced only by unused functions */ -static char *sep = LDAPTOOL_DEFSEP; -static char **sortattr = NULL; -static int *skipsortattr = NULL; -static int includeufn; -#endif /* 0 */ - - -int -main( int argc, char **argv ) -{ - int rc, optind; - LDAP *ld1, *ld2; - -#ifdef notdef -#ifdef HPUX11 -#ifndef __LP64__ - _main( argc, argv); -#endif /* __LP64_ */ -#endif /* HPUX11 */ -#endif - - deref = LDAP_DEREF_NEVER; - allow_binary = vals2tmp = attrsonly = 0; - ldif = 1; - sizelimit = timelimit = 0; - scope = LDAP_SCOPE_SUBTREE; - - optind = ldaptool_process_args( argc, argv, "Bb:l:s:z:", 1, - options_callback ); - - if ( optind == -1 ) { - usage(); - } - - if ( base == NULL ) { - if (( base = getenv( "LDAP_BASEDN" )) == NULL ) { - usage(); - } - } - - ld1 = ldaptool_ldap_init( 0 ); - - ldap_set_option( ld1, LDAP_OPT_DEREF, &deref ); - ldap_set_option( ld1, LDAP_OPT_TIMELIMIT, &timelimit ); - ldap_set_option( ld1, LDAP_OPT_SIZELIMIT, &sizelimit ); - - ldaptool_bind( ld1 ); - - ld2 = ldaptool_ldap_init( 1 ); - - ldap_set_option( ld2, LDAP_OPT_DEREF, &deref ); - ldap_set_option( ld2, LDAP_OPT_TIMELIMIT, &timelimit ); - ldap_set_option( ld2, LDAP_OPT_SIZELIMIT, &sizelimit ); - - ldaptool_bind( ld2 ); - if ( ldaptool_verbose ) { - printf( "Connections to servers established. Beginning comparison.\n" ); - } - - rc = docompare( ld1, ld2, base ); - - ldaptool_cleanup( ld1 ); - ldaptool_cleanup( ld2 ); - if ( ldaptool_verbose && !rc ) { - if ( !differ ) { - printf( "compare completed: no differences found\n" ); - } else { - printf( "compare completed: ****differences were found****\n" ); - } - } - return( rc ); -} - - -static void -options_callback( int option, char *optarg ) -{ - switch( option ) { - case 'B': /* allow binary values to be printed, even if -o used */ - ++allow_binary; - break; - case 's': /* search scope */ - if ( strncasecmp( optarg, "base", 4 ) == 0 ) { - scope = LDAP_SCOPE_BASE; - } else if ( strncasecmp( optarg, "one", 3 ) == 0 ) { - scope = LDAP_SCOPE_ONELEVEL; - } else if ( strncasecmp( optarg, "sub", 3 ) == 0 ) { - scope = LDAP_SCOPE_SUBTREE; - } else { - fprintf( stderr, "scope should be base, one, or sub\n" ); - usage(); - } - break; - case 'b': /* searchbase */ - base = strdup( optarg ); - break; - case 'l': /* time limit */ - timelimit = atoi( optarg ); - break; - case 'z': /* size limit */ - sizelimit = atoi( optarg ); - break; - default: - usage(); - break; - } -} - - -/* - * Returns an LDAP error code. - */ -static int -docompare( LDAP *ld1, LDAP *ld2, char *base ) -{ - int rc, msgid; - LDAPMessage *res, *e; - LDAPControl *ctrls[2], **serverctrls; - - if ( ldaptool_verbose ) { - printf( "Base: %s\n\n", base ); - } - if ( ldaptool_not ) { - return( LDAP_SUCCESS ); - } - - if (( ctrls[0] = ldaptool_create_manage_dsait_control()) != NULL ) { - ctrls[1] = NULL; - serverctrls = ctrls; - } else { - serverctrls = NULL; - } - - if ( ldap_search_ext( ld1, base, scope, "objectClass=*", NULL, - 0, serverctrls, NULL, NULL, -1, &msgid ) != LDAP_SUCCESS ) { - return( ldaptool_print_lderror( ld1, "ldap_search", - LDAPTOOL_CHECK4SSL_IF_APPROP )); - } -/* XXXmcs: this code should be modified to display referrals and references */ - while ( (rc = ldap_result( ld1, LDAP_RES_ANY, 0, NULL, &res )) == - LDAP_RES_SEARCH_ENTRY ) { - e = ldap_first_entry( ld1, res ); - rc = cmp2( ld1, ld2, e , 0); - ldap_msgfree( res ); - } - if ( rc == -1 ) { - return( ldaptool_print_lderror( ld1, "ldap_result", - LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - if (( rc = ldap_result2error( ld1, res, 0 )) != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld1, "ldap_search", - LDAPTOOL_CHECK4SSL_IF_APPROP ); - } - ldap_msgfree( res ); - - if ( ldap_search_ext( ld2, base, scope, "objectClass=*", NULL, - 0, serverctrls, NULL, NULL, -1, &msgid ) == -1 ) { - return( ldaptool_print_lderror( ld2, "ldap_search", - LDAPTOOL_CHECK4SSL_IF_APPROP )); - } -/* XXXmcs: this code should be modified to display referrals and references */ - while ( (rc = ldap_result( ld2, LDAP_RES_ANY, 0, NULL, &res )) == - LDAP_RES_SEARCH_ENTRY ) { - e = ldap_first_entry( ld2, res ); - rc = cmp2( ld2, ld1, e , 1); - ldap_msgfree( res ); - } - if ( rc == -1 ) { - return( ldaptool_print_lderror( ld2, "ldap_result", - LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - if (( rc = ldap_result2error( ld1, res, 0 )) != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld1, "ldap_search", - LDAPTOOL_CHECK4SSL_IF_APPROP ); - } - ldap_msgfree( res ); - - return( rc ); -} - - -/* - * Returns an LDAP error code. - */ -static int -cmp2( LDAP *ld1, LDAP *ld2, LDAPMessage *e1, int findonly) -{ - LDAPMessage *e2, *res; - char *dn, *attrcmp; - int found=0, rc; - ATTR *a1, *a2; - - dn = ldap_get_dn( ld1, e1 ); - - if ( ldaptool_verbose ) { - if ( findonly ) { - printf( "Checking that %s exists on both servers\n", dn ); - } else { - printf("Comparing entry %s on both servers\n", dn ); - } - } - - if ( ldap_search( ld2, dn, LDAP_SCOPE_BASE, "objectClass=*", NULL, 0 ) == -1 ) { - return( ldaptool_print_lderror( ld2, "ldap_search", - LDAPTOOL_CHECK4SSL_IF_APPROP )); - } -/* XXXmcs: this code should be modified to display referrals and references */ - while ( (rc = ldap_result( ld2, LDAP_RES_ANY, 0, NULL, &res )) == - LDAP_RES_SEARCH_ENTRY ) { - e2 = ldap_first_entry( ld1, res ); - found = 1; - if ( !findonly ) { - a1 = get_attrs( ld1, e1 ); - a2 = get_attrs( ld2, e2 ); - attrcmp = cmp_attrs( a1, a2 ); - if ( strcmp( attrcmp, "") != 0 ) { - printf("\n%s%s\n", dn, attrcmp); - } - } - ldap_msgfree( res ); - } - if ( !found ) { - notfound( dn, findonly ); - differ = 1; - } - if ( rc == -1 ) { - return( ldaptool_print_lderror( ld2, "ldap_result", - LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - ldap_msgfree( res ); - ldap_memfree( dn ); - return(rc); -} - - -static ATTR* -get_attrs( LDAP *ld, LDAPMessage *e ) -{ - char *a; - ATTR *head, *tail, *tmp; - BerElement *ber; - - head=tail=tmp=NULL; - for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL; - a = ldap_next_attribute( ld, e, ber ) ) { - tmp = (ATTR*)malloc(sizeof(ATTR)); - if(head == NULL) - head = tail = tmp; - else { - tail->next = tmp; - tail = tmp; - } - tmp->name = a; - tmp->vals = ldap_get_values( ld, e, a ); - tmp->next = NULL; - } - if ( ber != NULL ) { - ber_free( ber, 0 ); - } - /* used for debugging - tmp=head; - while(tmp!= NULL) { - printf("\n%s :", tmp->name); - for(i=0; tmp->vals[i] != NULL; i++) - printf("\n\t%d %s", i, tmp->vals[i]); - tmp = tmp->next; - } - */ - return(head); -} - - -static char* -cmp_attrs( ATTR *a1, ATTR *a2 ) -{ - static char result[5000]; - char res[1000], partial[1000], *name = ""; - ATTR *head1, *head2, *tmp, *prev, *start; - int i, j, found; - - head1 = a1; - head2 = a2; - tmp = a2; - prev = NULL; - strcpy(result, ""); - while(head1 != NULL) { - name = head1->name; - if(head2 == NULL) { - while(head1 != NULL) { - sprintf(partial, "\ndifferent: %s(*)", head1->name); - strcat(result, partial); - for(i=0; head1->vals[i] != NULL; i++) { - sprintf(partial,"\n\t1: %s", head1->vals[i]); - strcat(result, partial); - } - tmp = head1; - head1 = head1->next; - attr_free(tmp); - } - differ = 1; - break; - } - name = head1->name; - start = tmp; - while(tmp != NULL) { - if(!strcmp(name, tmp->name)) { /* attr found */ - strcpy(res, ""); - for(i=0; (head1->vals[i]) != NULL; i++) { - found = 0; - for(j=0; (tmp->vals[j]) != NULL; j++) - if(!strcmp(head1->vals[i], tmp->vals[j])) { - found = 1; - tmp->vals[j][0] = 7; - break; - } - if(!found) { - sprintf(partial, "\n\t1: %s", head1->vals[i]); - strcat(res, partial); - } - } - for(j=0; tmp->vals[j] != NULL; j++) - if(tmp->vals[j][0] != 7){ - sprintf(partial, "\n\t2: %s", tmp->vals[j]); - strcat(res, partial); - } - - if(strcmp(res, "")) { - sprintf(partial, "\ndifferent: %s%s", name, res); - differ = 1; - strcat(result, partial); - } - if(prev == NULL) { /* tmp = head2 */ - head2 = head2->next; - attr_free(tmp); - tmp = head2; - } - else { - prev->next = tmp->next; - attr_free(tmp); - tmp = prev->next; - if(tmp == NULL) { - tmp = head2; - prev = NULL; - } - } - break; - } - else { /* attr not found */ - if(prev == NULL) - prev = head2; - else - prev = tmp; - tmp = tmp->next; - if(tmp == NULL) { /* end of list */ - tmp = head2; - prev = NULL; - } - if(tmp == start) { /* attr !exist in 2 */ - sprintf(partial, "\ndifferent: %s(*)", name); - differ = 1; - strcat(result, partial); - for(i=0; head1->vals[i] != NULL; i++) { - sprintf(partial, "\n\t1: %s", head1->vals[i]); - strcat(result, partial); - } - break; - } - } - } - start = head1; - head1 = head1->next; - attr_free(start); - } - while(head2 != NULL) { - sprintf(partial, "\ndifferent: %s(*)", head2->name); - differ = 1; - strcat(result, partial); - for(i=0; head2->vals[i] != NULL; i++) { - sprintf(partial, "\n\t2: %s", head2->vals[i]); - strcat(result, partial); - } - tmp = head2; - head2 = head2->next; - attr_free(tmp); - } - return(result); -} - - -static void -attr_free(ATTR *at) -{ - ldap_memfree(at->name); - ldap_value_free(at->vals); - free(at); -} - - -static void -notfound(char *base, int dbaseno) -{ - printf("%donly: %s\n", dbaseno+1, base); -} - - -#if 0 /* these function is not used */ -/* used for debugging */ -static void -print_dn( LDAP *ld, LDAPMessage *entry ) -{ - char *dn, *ufn; - - dn = ldap_get_dn( ld, entry ); - if ( ldif ) { - write_ldif_value( "dn", dn, strlen( dn )); - } else { - printf( "%s\n", dn ); - } - if ( includeufn ) { - ufn = ldap_dn2ufn( dn ); - if ( ldif ) { - write_ldif_value( "ufn", ufn, strlen( ufn )); - } else { - printf( "%s\n", ufn ); - } - free( ufn ); - } - ldap_memfree( dn ); -} - - -static void -print_entry( ld, entry, attrsonly ) - LDAP *ld; - LDAPMessage *entry; - int attrsonly; -{ - char *a, *dn, *ufn, tmpfname[ 256 ]; - int i, notascii; - BerElement *ber; - struct berval **bvals; - FILE *tmpfp; -#if defined( XP_WIN32 ) - char mode[20] = "w+b"; -#else - char mode[20] = "w"; -#endif - - dn = ldap_get_dn( ld, entry ); - if ( ldif ) { - write_ldif_value( "dn", dn, strlen( dn )); - } else { - printf( "%s\n", dn ); - } - if ( includeufn ) { - ufn = ldap_dn2ufn( dn ); - if ( ldif ) { - write_ldif_value( "ufn", ufn, strlen( ufn )); - } else { - printf( "%s\n", ufn ); - } - free( ufn ); - } - ldap_memfree( dn ); - - for ( a = ldap_first_attribute( ld, entry, &ber ); a != NULL; - a = ldap_next_attribute( ld, entry, ber ) ) { - if ( ldap_charray_inlist(sortattr, a) && /* in the list*/ - skipsortattr[ldap_charray_position(sortattr, a)] ) {/* and skip it*/ - continue; /* so skip it! */ - } - if ( attrsonly ) { - if ( ldif ) { - write_ldif_value( a, "", 0 ); - } else { - printf( "%s\n", a ); - } - } else if (( bvals = ldap_get_values_len( ld, entry, a )) != NULL ) { - for ( i = 0; bvals[i] != NULL; i++ ) { - if ( vals2tmp ) { - sprintf( tmpfname, "%s/ldapcmp-%s-XXXXXX", - ldaptool_get_tmp_dir(), a ); - tmpfp = NULL; - - if ( LDAPTOOL_MKTEMP( tmpfname ) == NULL ) { - perror( tmpfname ); - } else if (( tmpfp = ldaptool_open_file( tmpfname, mode)) == NULL ) { - perror( tmpfname ); - } else if ( fwrite( bvals[ i ]->bv_val, - bvals[ i ]->bv_len, 1, tmpfp ) == 0 ) { - perror( tmpfname ); - } else if ( ldif ) { - write_ldif_value( a, tmpfname, strlen( tmpfname )); - } else { - printf( "%s%s%s\n", a, sep, tmpfname ); - } - - if ( tmpfp != NULL ) { - fclose( tmpfp ); - } - } else { - notascii = 0; - if ( !ldif && !allow_binary ) { - notascii = !ldaptool_berval_is_ascii( bvals[ i ] ); - } - - if ( ldif ) { - write_ldif_value( a, bvals[ i ]->bv_val, - bvals[ i ]->bv_len ); - } else { - printf( "%s%s%s\n", a, sep, - notascii ? "NOT ASCII" : bvals[ i ]->bv_val ); - } - } - } - ber_bvecfree( bvals ); - } - } - if ( ber != NULL ) { - ber_free( ber, 0 ); - } -} - - -static void -write_ldif_value( char *type, char *value, unsigned long vallen ) -{ - char *ldif; - - /* ldif_type_and_value() fails only if malloc() fails. */ - if (( ldif = ldif_type_and_value( type, value, (int)vallen )) == NULL ) { - exit( LDAP_NO_MEMORY ); - } - - fputs( ldif, stdout ); - free( ldif ); -} -#endif /* 0 */
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/clients/tools/ldapcompare.c
Deleted
@@ -1,235 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* ldapdelete.c - simple program to delete an entry using LDAP */ - -#include "ldaptool.h" -#include "fileurl.h" - -static int contoper = 0; -static LDAP *ld; -static int ldapcompare_quiet = 0; - -static int docompare( LDAP *ld, const char *dn, const char *attrtype, - const struct berval *bvalue, LDAPControl **serverctrls ); -static void options_callback( int option, char *optarg ); -static int typeval2berval( char *typeval, char **typep, struct berval *bvp ); - - -static void -usage( int rc ) -{ - fprintf( stderr, "usage: %s [options] attributetype:value [dn...]\n", - ldaptool_progname ); - fprintf( stderr, " %s [options] attributetype::base64value [dn...]\n", - ldaptool_progname ); - fprintf( stderr, " %s [options] attributetype:<fileurl [dn...]\n", - ldaptool_progname ); - fprintf( stderr, "options:\n" ); - ldaptool_common_usage( 0 ); - fprintf( stderr, " -c\t\tcontinuous mode (do not stop on errors)\n" ); - fprintf( stderr, " -f file\tread DNs to compare against from file\n" ); - fprintf( stderr, " -q\t\tbe quiet when comparing entries\n" ); - exit( rc ); -} - - -int -main( int argc, char **argv ) -{ - char buf[ 4096 ], *typeval = NULL, *type = NULL; - struct berval bv; - int rc, optind; - LDAPControl *ldctrl; - -#ifdef notdef -#ifdef HPUX11 -#ifndef __LP64__ - _main( argc, argv); -#endif /* __LP64_ */ -#endif /* HPUX11 */ -#endif - - optind = ldaptool_process_args( argc, argv, "cq", 0, options_callback ); - - if ( optind == -1 ) { - usage ( LDAP_PARAM_ERROR ); - } - - if ( ldaptool_fp == NULL && optind >= argc ) { - ldaptool_fp = stdin; - } - - ld = ldaptool_ldap_init( 0 ); - - ldaptool_bind( ld ); - - if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) { - ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); - } - - if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) { - ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); - } - - if ( optind >= argc ) { - usage( LDAP_PARAM_ERROR ); - } - - typeval = ldaptool_local2UTF8( argv[optind], "type and value" ); - if (( rc = typeval2berval( typeval, &type, &bv )) != LDAP_SUCCESS ) { - fprintf( stderr, "%s: unable to parse \"%s\"\n", - ldaptool_progname, argv[optind] ); - usage( rc ); - free( typeval ); - } - ++optind; - - rc = 0; - if ( ldaptool_fp == NULL ) { - for ( ; optind < argc && - ( contoper || !LDAPTOOL_RESULT_IS_AN_ERROR( rc ) ); - ++optind ) { - char *conv; - - conv = ldaptool_local2UTF8( argv[ optind ], "DN" ); - rc = docompare( ld, conv, type, &bv, ldaptool_request_ctrls ); - if ( conv != NULL ) { - free( conv ); - } - } - } else { - while (( contoper || !LDAPTOOL_RESULT_IS_AN_ERROR( rc )) && - fgets(buf, sizeof(buf), ldaptool_fp) != NULL) { - buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */ - if ( *buf != '\0' ) { - rc = docompare( ld, buf, type, &bv, ldaptool_request_ctrls ); - } - } - } - - ldaptool_reset_control_array( ldaptool_request_ctrls ); - ldaptool_cleanup( ld ); - if ( typeval != NULL ) free( typeval ); - if ( bv.bv_val != NULL ) free( bv.bv_val ); - - return( rc ); -} - -/*ARGSUSED1*/ -static void -options_callback( int option, char *optarg ) -{ - switch( option ) { - case 'c': /* continuous operation mode */ - ++contoper; - break; - case 'q': /* quiet mode */ - ++ldapcompare_quiet; - break; - default: - usage( LDAP_PARAM_ERROR ); - } -} - - -static int -docompare( LDAP *ld, const char *dn, const char *attrtype, - const struct berval *bvalue, LDAPControl **serverctrls ) -{ - int rc; - - if ( !ldapcompare_quiet ) { - char *valuestr, tmpbuf[256]; - - if ( ldaptool_berval_is_ascii( bvalue )) { - valuestr = bvalue->bv_val; - } else { -#ifdef HAVE_SNPRINTF - snprintf( tmpbuf, sizeof(tmpbuf), "NOT ASCII (%d bytes)", - bvalue->bv_len ); -#else - sprintf( tmpbuf, "NOT ASCII (%d bytes)", - bvalue->bv_len ); -#endif - valuestr = tmpbuf; - } - printf( "%scomparing type: \"%s\" value: \"%s\" in entry \"%s\"\n", - ldaptool_not ? "!" : "", attrtype, valuestr, dn ); - } - if ( ldaptool_not ) { - rc = LDAP_COMPARE_TRUE; - } else { - rc = ldaptool_compare_ext_s( ld, dn, attrtype, bvalue, - serverctrls, NULL, "ldap_compare" ); - if ( !ldapcompare_quiet ) { - if ( rc == LDAP_COMPARE_TRUE ) { - puts( "compare TRUE" ); - } else if ( rc == LDAP_COMPARE_FALSE ) { - puts( "compare FALSE" ); - } - } - } - - return( rc ); -} - - -/* - * Parse an ldapcompare type:value or type::value argument. - * - * The *typep is set to point into the typeval string. - * bvp->bv_val is created from malloc'd memory. - * - * This function returns an LDAP error code (LDAP_SUCCESS if all goes well). - */ -static int -typeval2berval( char *typeval, char **typep, struct berval *bvp ) -{ - char *value; - int vlen, rc; - - if ( ldif_parse_line( typeval, typep, &value, &vlen ) != 0 ) { - return( LDAP_PARAM_ERROR ); - } - - rc = ldaptool_berval_from_ldif_value( value, vlen, bvp, - 1 /* recognize file URLs */, 0 /* always try file */, - 1 /* report errors */ ); - - return( ldaptool_fileurlerr2ldaperr( rc )); -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/clients/tools/ldapdelete.c
Deleted
@@ -1,158 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* ldapdelete.c - simple program to delete an entry using LDAP */ - -#include "ldaptool.h" - -static int contoper; -static LDAP *ld; - -static int dodelete( LDAP *ld, char *dn, LDAPControl **serverctrls ); -static void options_callback( int option, char *optarg ); - - -static void -usage( void ) -{ - fprintf( stderr, "usage: %s [options] [dn...]\n", ldaptool_progname ); - fprintf( stderr, "options:\n" ); - ldaptool_common_usage( 0 ); - fprintf( stderr, " -c\t\tcontinuous mode (do not stop on errors)\n" ); - fprintf( stderr, " -f file\tread DNs to delete from file (default: standard input)\n" ); - exit( LDAP_PARAM_ERROR ); -} - - -int -main( int argc, char **argv ) -{ - char buf[ 4096 ]; - int rc = 0; - int deref, optind; - LDAPControl *ldctrl; - -#ifdef notdef -#ifdef HPUX11 -#ifndef __LP64__ - _main( argc, argv); -#endif /* __LP64_ */ -#endif /* HPUX11 */ -#endif - - contoper = 0; - - optind = ldaptool_process_args( argc, argv, "c", 0, options_callback ); - - if ( optind == -1 ) { - usage(); - } - - if ( ldaptool_fp == NULL && optind >= argc ) { - ldaptool_fp = stdin; - } - - ld = ldaptool_ldap_init( 0 ); - - deref = LDAP_DEREF_NEVER; /* prudent, but probably unnecessary */ - ldap_set_option( ld, LDAP_OPT_DEREF, &deref ); - - ldaptool_bind( ld ); - - if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) { - ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); - } - - if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) { - ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); - } - - if ( ldaptool_fp == NULL ) { - for ( ; optind < argc; ++optind ) { - char *conv; - - conv = ldaptool_local2UTF8( argv[ optind ], "DN" ); - rc = dodelete( ld, conv, ldaptool_request_ctrls ); - if( conv != NULL ) - free( conv ); - } - } else { - while ((rc == 0 || contoper) && - fgets(buf, sizeof(buf), ldaptool_fp) != NULL) { - buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */ - if ( *buf != '\0' ) { - rc = dodelete( ld, buf, ldaptool_request_ctrls ); - } - } - } - - ldaptool_reset_control_array( ldaptool_request_ctrls ); - ldaptool_cleanup( ld ); - return( rc ); -} - -/*ARGSUSED1*/ -static void -options_callback( int option, char *optarg ) -{ - switch( option ) { - case 'c': /* continuous operation mode */ - ++contoper; - break; - default: - usage(); - } -} - - -static int -dodelete( LDAP *ld, char *dn, LDAPControl **serverctrls ) -{ - int rc; - - if ( ldaptool_verbose ) { - printf( "%sdeleting entry %s\n", ldaptool_not ? "!" : "", dn ); - } - if ( ldaptool_not ) { - rc = LDAP_SUCCESS; - } else if (( rc = ldaptool_delete_ext_s( ld, dn, serverctrls, NULL, - "ldap_delete" )) == LDAP_SUCCESS && ldaptool_verbose ) { - printf( "entry removed\n" ); - } - - return( rc ); -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/clients/tools/ldapmodify.c
Deleted
@@ -1,1045 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* ldapmodify.c - generic program to modify or add entries using LDAP */ - -#include "ldaptool.h" -#include "fileurl.h" - -static int newval, contoper, force, valsfromfiles, display_binary_values; -static int ldif_version = -1; /* -1 => unknown version */ -static LDAP *ld; -static char *rejfile = NULL; -static char *bulkimport_suffix = NULL; -static int ldapmodify_quiet = 0; - -#define LDAPMOD_MAXLINE 4096 - -/* strings found in replog/LDIF entries (mostly lifted from slurpd/slurp.h) */ -#define T_REPLICA_STR "replica" -#define T_DN_STR "dn" -#define T_VERSION_STR "version" -#define T_CHANGETYPESTR "changetype" -#define T_ADDCTSTR "add" -#define T_MODIFYCTSTR "modify" -#define T_DELETECTSTR "delete" -#define T_RENAMECTSTR "rename" /* non-standard */ -#define T_MODDNCTSTR "moddn" -#define T_MODRDNCTSTR "modrdn" -#define T_MODOPADDSTR "add" -#define T_MODOPREPLACESTR "replace" -#define T_MODOPDELETESTR "delete" -#define T_MODSEPSTR "-" -#define T_NEWRDNSTR "newrdn" -#define T_NEWSUPERIORSTR "newsuperior" -#define T_NEWPARENTSTR "newparent" -#define T_DELETEOLDRDNSTR "deleteoldrdn" -#define T_NEWSUPERIORSTR "newsuperior" -#define T_NEWPARENTSTR "newparent" /* non-standard */ - -/* bulk import */ -#define BULKIMPORT_START_OID "2.16.840.1.113730.3.5.7" -#define BULKIMPORT_STOP_OID "2.16.840.1.113730.3.5.8" - -static void options_callback( int option, char *optarg ); -static int process_ldapmod_rec( char *rbuf ); -static int process_ldif_rec( char *rbuf ); -static void addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, - char *value, int vlen ); -static int domodify( char *dn, LDAPMod **pmods, int newentry ); -static int dodelete( char *dn ); -static int dorename( char *dn, char *newrdn, char *newparent, - int deleteoldrdn ); -static void freepmods( LDAPMod **pmods ); -static char *read_one_record( FILE *fp ); -static char *strdup_and_trim( char *s ); - -static void -usage( void ) -{ - fprintf( stderr, "usage: %s [options]\n", ldaptool_progname ); - fprintf( stderr, "options:\n" ); - ldaptool_common_usage( 0 ); - fprintf( stderr, " -c\t\tcontinuous mode (do not stop on errors)\n" ); - fprintf( stderr, " -A\t\tdisplay non-ASCII values in conjunction with -v\n" ); - fprintf( stderr, " -f file\tread modifications from file (default: standard input)\n" ); - if ( strcmp( ldaptool_progname, "ldapmodify" ) == 0 ){ - fprintf( stderr, " -a\t\tadd entries\n" ); - } - fprintf( stderr, " -b\t\tread values that start with / from files (for bin attrs)\n" ); - fprintf( stderr, " -F\t\tforce application of all changes, regardless of\n" ); - fprintf( stderr, " \t\treplica lines\n" ); - fprintf( stderr, " -e rejfile\tsave rejected entries in \"rejfile\"\n" ); - fprintf( stderr, " -B suffix\tbulk import to \"suffix\"\n"); - fprintf( stderr, " -q\t\tbe quiet when adding/modifying entries\n" ); - exit( LDAP_PARAM_ERROR ); -} - - -int -main( int argc, char **argv ) -{ - char *rbuf, *saved_rbuf, *start, *p, *q; - FILE *rfp = NULL; - int rc, use_ldif, deref, optind; - LDAPControl *ldctrl; - - -#ifdef notdef -#ifdef HPUX11 -#ifndef __LP64__ - _main( argc, argv); -#endif /* __LP64_ */ -#endif /* HPUX11 */ -#endif - - valsfromfiles = display_binary_values = 0; - - optind = ldaptool_process_args( argc, argv, "aAbcFe:B:q", 0, - options_callback ); - - - if ( optind == -1 ) { - usage(); - } - - if ( !newval && strcmp( ldaptool_progname, "ldapadd" ) == 0 ) { - newval = 1; - } - - if ( ldaptool_fp == NULL ) { - ldaptool_fp = stdin; - } - - if ( argc - optind != 0 ) { - usage(); - } - - ld = ldaptool_ldap_init( 0 ); - - if ( !ldaptool_not ) { - deref = LDAP_DEREF_NEVER; /* this seems prudent */ - ldap_set_option( ld, LDAP_OPT_DEREF, &deref ); - } - - ldaptool_bind( ld ); - - if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) { - ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); - } - - if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) { - ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); - } - - rc = 0; - - /* turn on bulk import?*/ - if (bulkimport_suffix) { - struct berval bv, *retdata; - char *retoid; - - bv.bv_val = bulkimport_suffix; - bv.bv_len = strlen(bulkimport_suffix); - if ((rc = ldap_extended_operation_s(ld, - BULKIMPORT_START_OID, &bv, NULL, - NULL, &retoid, &retdata)) != 0) { - fprintf(stderr, "Error: unable to service " - "extended operation request\n\t'%s' for " - "bulk import\n\t(error:%d:'%s')\n", - BULKIMPORT_START_OID, rc, ldap_err2string(rc)); - return (rc); - } - if (retoid) - ldap_memfree(retoid); - if (retdata) - ber_bvfree(retdata); - } - - while (( rc == 0 || contoper ) && - ( rbuf = read_one_record( ldaptool_fp )) != NULL ) { - /* - * we assume record is ldif/slapd.replog if the first line - * has a colon that appears to the left of any equal signs, OR - * if the first line consists entirely of digits (an entry id) - */ - use_ldif = ( p = strchr( rbuf, ':' )) != NULL && - ( q = strchr( rbuf, '\n' )) != NULL && p < q && - (( q = strchr( rbuf, '=' )) == NULL || p < q ); - - start = rbuf; - saved_rbuf = strdup( rbuf ); - - if ( !use_ldif && ( q = strchr( rbuf, '\n' )) != NULL ) { - for ( p = rbuf; p < q; ++p ) { - if ( !isdigit( *p )) { - break; - } - } - if ( p >= q ) { - use_ldif = 1; - start = q + 1; - } - } - - if ( use_ldif ) { - rc = process_ldif_rec( start ); - } else { - rc = process_ldapmod_rec( start ); - } - if ( rc != LDAP_SUCCESS && rejfile != NULL ) { - /* Write this record to the reject file */ - int newfile = 0; - struct stat stbuf; - if ( stat( rejfile, &stbuf ) < 0 ) { - if ( errno == ENOENT ) { - newfile = 1; - } - } - if (( rfp = ldaptool_open_file( rejfile, "a" )) == NULL ) { - fprintf( stderr, "Cannot open error file \"%s\" - " - "erroneous entries will not be saved\n", rejfile ); - rejfile = NULL; - } else { - if ( newfile == 0 ) { - fputs( "\n", rfp ); - } - fprintf( rfp, "# Error: %s\n", ldap_err2string( rc )); - fputs( saved_rbuf, rfp ); - fclose( rfp ); - rfp = NULL; - } - } - - free( rbuf ); - free( saved_rbuf ); - } - ldaptool_reset_control_array( ldaptool_request_ctrls ); - - /* turn off bulk import?*/ - if (bulkimport_suffix) { - struct berval bv, *retdata; - char *retoid; - - bv.bv_val = ""; - bv.bv_len = 0; - if ((rc = ldap_extended_operation_s(ld, - BULKIMPORT_STOP_OID, &bv, NULL, - NULL, &retoid, &retdata)) != 0) { - - fprintf(stderr, "Error: unable to service " - "extended operation request\n\t '%s' for " - "bulk import\n\t(rc:%d:'%s')\n", - BULKIMPORT_STOP_OID, rc, ldap_err2string(rc)); - return (rc); - } - if (retoid) - ldap_memfree(retoid); - if (retdata) - ber_bvfree(retdata); - } - - ldaptool_cleanup( ld ); - return( rc ); -} - - -static void -options_callback( int option, char *optarg ) -{ - switch( option ) { - case 'a': /* add */ - newval = 1; - break; - case 'b': /* read values from files (for binary attributes) */ - valsfromfiles = 1; - break; - case 'A': /* display non-ASCII values when -v is used */ - display_binary_values = 1; - break; - case 'c': /* continuous operation */ - contoper = 1; - break; - case 'F': /* force all changes records to be used */ - force = 1; - break; - case 'e': - rejfile = strdup( optarg ); - break; - case 'B': /* bulk import option */ - bulkimport_suffix = strdup( optarg ); - break; - case 'q': /* quiet mode on add/modify operations */ - ldapmodify_quiet = 1; - break; - default: - usage(); - } -} - - - -static int -process_ldif_rec( char *rbuf ) -{ - char *line, *dn, *type, *value, *newrdn, *newparent, *p; - char *ctrl_oid=NULL, *ctrl_value=NULL; - int ctrl_criticality=1; - LDAPControl *ldctrl; - int rc, linenum, vlen, modop, replicaport; - int expect_modop, expect_sep, expect_chgtype_or_control, expect_newrdn; - int expect_deleteoldrdn, expect_newparent, rename, moddn; - int deleteoldrdn, saw_replica, use_record, new_entry, delete_entry; - int got_all, got_value; - LDAPMod **pmods; - - new_entry = newval; - - rc = got_all = saw_replica = delete_entry = expect_modop = 0; - expect_deleteoldrdn = expect_newrdn = expect_newparent = expect_sep = 0; - expect_chgtype_or_control = linenum = got_value = rename = moddn = 0; - deleteoldrdn = 1; - use_record = force; - pmods = NULL; - dn = newrdn = newparent = value = NULL; - modop = -1; /* invalid value */ - - while ( rc == 0 && ( line = ldif_getline( &rbuf )) != NULL ) { - ++linenum; - if ( expect_sep && strcasecmp( line, T_MODSEPSTR ) == 0 ) { - expect_sep = 0; - expect_modop = 1; - - /*If we see a separator in the input stream, - but we didn't get a value from the last modify - then we have to fill pmods with an empty value*/ - if (modop == LDAP_MOD_REPLACE && !got_value){ - addmodifyop( &pmods, modop, value, NULL, 0); - } - - got_value = 0; - continue; - } - - if ( ldif_parse_line( line, &type, &value, &vlen ) < 0 ) { - fprintf( stderr, "%s: invalid format (line %d of entry: %s)\n", - ldaptool_progname, linenum, dn == NULL ? "" : dn ); - fprintf( stderr, "%s: line contents: (%s)\n", - ldaptool_progname, line ); - rc = LDAP_PARAM_ERROR; - break; - } - -evaluate_line: - if ( dn == NULL ) { - if ( !use_record && strcasecmp( type, T_REPLICA_STR ) == 0 ) { - ++saw_replica; - if (( p = strchr( value, ':' )) == NULL ) { - replicaport = LDAP_PORT; - } else { - *p++ = '\0'; - replicaport = atoi( p ); - } - if ( strcasecmp( value, ldaptool_host ) == 0 && - replicaport == ldaptool_port ) { - use_record = 1; - } - - } else if ( strcasecmp( type, T_DN_STR ) == 0 ) { - if (( dn = strdup( value )) == NULL ) { - perror( "strdup" ); - exit( LDAP_NO_MEMORY ); - } - expect_chgtype_or_control = 1; - - } else if ( strcasecmp( type, T_VERSION_STR ) == 0 ) { - ldif_version = atoi( value ); - if ( ldif_version != LDIF_VERSION_ONE ) { - fprintf( stderr, "%s: LDIF version %d is not supported;" - " use version: %d\n", ldaptool_progname, ldif_version, - LDIF_VERSION_ONE ); - exit( LDAP_PARAM_ERROR ); - } - if ( ldaptool_verbose ) { - printf( "Processing a version %d LDIF file...\n", - ldif_version ); - } - - /* Now check if there's something left to process */ - /* and if not, go get the new record, else continue */ - if ( *rbuf == '\0' ) { - return( 0 ); - } - - } else if ( !saw_replica ) { - printf( "%s: skipping change record: no dn: line\n", - ldaptool_progname ); - return( 0 ); - } - - continue; /* skip all lines until we see "dn:" */ - } - - if ( expect_chgtype_or_control ) { - expect_chgtype_or_control = 0; - if ( !use_record && saw_replica ) { - printf( "%s: skipping change record for entry: %s\n\t(LDAP host/port does not match replica: lines)\n", - ldaptool_progname, dn ); - free( dn ); - return( 0 ); - } - - if ( strcasecmp( type, "control" ) == 0 ) { - value = strdup_and_trim( value ); - if (ldaptool_parse_ctrl_arg(value, ' ', &ctrl_oid, - &ctrl_criticality, &ctrl_value, &vlen)) { - usage(); - } - ldctrl = calloc(1,sizeof(LDAPControl)); - if (ctrl_value) { - rc = ldaptool_berval_from_ldif_value( ctrl_value, vlen, - &(ldctrl->ldctl_value), - 1 /* recognize file URLs */, 0 /* always try file */, - 1 /* report errors */ ); - if ((rc = ldaptool_fileurlerr2ldaperr( rc )) != LDAP_SUCCESS) { - fprintf( stderr, "Unable to parse %s\n", ctrl_value); - usage(); - } - } - ldctrl->ldctl_oid = ctrl_oid; - ldctrl->ldctl_iscritical = ctrl_criticality; - ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); - expect_chgtype_or_control = 1; - continue; - } - - if ( strcasecmp( type, T_CHANGETYPESTR ) == 0 ) { - value = strdup_and_trim( value ); - if ( strcasecmp( value, T_MODIFYCTSTR ) == 0 ) { - new_entry = 0; - expect_modop = 1; - } else if ( strcasecmp( value, T_ADDCTSTR ) == 0 ) { - new_entry = 1; - modop = LDAP_MOD_ADD; - } else if ( strcasecmp( value, T_MODRDNCTSTR ) == 0 ) { - expect_newrdn = 1; - moddn = 1; - } else if ( strcasecmp( value, T_MODDNCTSTR ) == 0 ) { - expect_newrdn = 1; - moddn = 1; - } else if ( strcasecmp( value, T_RENAMECTSTR ) == 0 ) { - expect_newrdn = 1; - rename = 1; - } else if ( strcasecmp( value, T_DELETECTSTR ) == 0 ) { - got_all = delete_entry = 1; - } else { - fprintf( stderr, - "%s: unknown %s \"%s\" (line %d of entry: %s)\n", - ldaptool_progname, T_CHANGETYPESTR, value, - linenum, dn ); - rc = LDAP_PARAM_ERROR; - } - free( value ); - continue; - } else if ( newval ) { /* missing changetype => add */ - new_entry = 1; - modop = LDAP_MOD_ADD; - } else { - /*The user MUST put in changetype: blah - unless adding a new entry with either -a or ldapadd*/ - fprintf(stderr, "%s: Missing changetype operation specification.\n\tThe dn line must be followed by \"changetype: operation\"\n\t(unless ldapmodify is called with -a option)\n\twhere operation is add|delete|modify|modrdn|moddn|rename\n\t\"%s\" is not a valid changetype operation specification\n\t(line %d of entry %s)\n", - ldaptool_progname, type, linenum, dn); - rc = LDAP_PARAM_ERROR; - /*expect_modop = 1; missing changetype => modify */ - } - } - - if ( expect_modop ) { - expect_modop = 0; - expect_sep = 1; - if ( strcasecmp( type, T_MODOPADDSTR ) == 0 ) { - modop = LDAP_MOD_ADD; - continue; - } else if ( strcasecmp( type, T_MODOPREPLACESTR ) == 0 ) { - modop = LDAP_MOD_REPLACE; - continue; - } else if ( strcasecmp( type, T_MODOPDELETESTR ) == 0 ) { - modop = LDAP_MOD_DELETE; - addmodifyop( &pmods, modop, value, NULL, 0 ); - continue; - } else { /*Bug 27479. Remove default add operation*/ - fprintf(stderr, "%s: Invalid parameter \"%s\" specified for changetype modify (line %d of entry %s)\n", - ldaptool_progname, type, linenum, dn); - rc = LDAP_PARAM_ERROR; - } - - } - - if ( expect_newrdn ) { - if ( strcasecmp( type, T_NEWRDNSTR ) == 0 ) { - if ( *value == '\0' ) { - fprintf( stderr, - "%s: newrdn value missing (line %d of entry: %s)\n", - ldaptool_progname, linenum, dn == NULL ? "" : dn ); - rc = LDAP_PARAM_ERROR; - } else if (( newrdn = strdup( value )) == NULL ) { - perror( "strdup" ); - exit( LDAP_NO_MEMORY ); - } else { - expect_newrdn = 0; - if ( rename ) { - expect_newparent = 1; - } else { - expect_deleteoldrdn = 1; - } - } - } else { - fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry %s)\n", - ldaptool_progname, T_NEWRDNSTR, type, linenum, dn ); - rc = LDAP_PARAM_ERROR; - } - } else if ( expect_newparent ) { - expect_newparent = 0; - if ( rename ) { - expect_deleteoldrdn = 1; - } - if ( strcasecmp( type, T_NEWPARENTSTR ) == 0 - || strcasecmp( type, T_NEWSUPERIORSTR ) == 0 ) { - if (( newparent = strdup( value )) == NULL ) { - perror( "strdup" ); - exit( LDAP_NO_MEMORY ); - } - } else { - /* Since this is an optional argument for rename/moddn, cause - * the current line to be re-evaluated if newparent doesn't - * follow deleteoldrdn. - */ - newparent = NULL; - goto evaluate_line; - } - } else if ( expect_deleteoldrdn ) { - if ( strcasecmp( type, T_DELETEOLDRDNSTR ) == 0 ) { - if ( *value == '\0' ) { - fprintf( stderr, - "%s: missing 0 or 1 (line %d of entry: %s)\n", - ldaptool_progname, linenum, dn == NULL ? "" : dn ); - rc = LDAP_PARAM_ERROR; - } else { - deleteoldrdn = ( *value == '0' ) ? 0 : 1; - expect_deleteoldrdn = 0; - if ( moddn ) { - expect_newparent = 1; - } - } - } else { - fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry %s)\n", - ldaptool_progname, T_DELETEOLDRDNSTR, type, linenum, - dn ); - rc = LDAP_PARAM_ERROR; - } - got_all = 1; - } else if ( got_all ) { - fprintf( stderr, - "%s: extra lines at end (line %d of entry %s)\n", - ldaptool_progname, linenum, dn ); - rc = LDAP_PARAM_ERROR; - got_all = 1; - } else { - addmodifyop( &pmods, modop, type, value, vlen ); - /*There was a value to replace*/ - got_value = 1; - - } - } - - if ( rc == 0 ) { - if ( delete_entry ) { - rc = dodelete( dn ); - } else if ( newrdn != NULL ) { - rc = dorename( dn, newrdn, newparent, deleteoldrdn ); - rename = 0; - } else { - - /*Patch to fix Bug 22183 - If pmods is null, then there is no - attribute to replace, so we alloc - an empty pmods*/ - if (modop == LDAP_MOD_REPLACE && !got_value && expect_sep){ - addmodifyop( &pmods, modop, value, NULL, 0); - }/*End Patch*/ - - - rc = domodify( dn, pmods, new_entry ); - } - - if ( rc == LDAP_SUCCESS ) { - rc = 0; - } - } - - if ( dn != NULL ) { - free( dn ); - } - if ( newrdn != NULL ) { - free( newrdn ); - } - if ( newparent != NULL ) { - free( newparent ); - } - if ( pmods != NULL ) { - freepmods( pmods ); - } - - return( rc ); -} - - -static int -process_ldapmod_rec( char *rbuf ) -{ - char *line, *dn, *p, *q, *attr, *value; - int rc, linenum; - LDAPMod **pmods; - - pmods = NULL; - dn = NULL; - linenum = 0; - line = rbuf; - rc = 0; - - while ( rc == 0 && rbuf != NULL && *rbuf != '\0' ) { - ++linenum; - if (( p = strchr( rbuf, '\n' )) == NULL ) { - rbuf = NULL; - } else { - if ( *(p-1) == '\\' ) { /* lines ending in '\' are continued */ - strcpy( p - 1, p ); - rbuf = p; - continue; - } - *p++ = '\0'; - rbuf = p; - } - - if ( dn == NULL ) { /* first line contains DN */ - if (( dn = strdup( line )) == NULL ) { - perror( "strdup" ); - exit( LDAP_NO_MEMORY ); - } - } else { - if (( p = strchr( line, '=' )) == NULL ) { - value = NULL; - p = line + strlen( line ); - } else { - *p++ = '\0'; - value = p; - } - - for ( attr = line; *attr != '\0' && isspace( *attr ); ++attr ) { - ; /* skip attribute leading white space */ - } - - for ( q = p - 1; q > attr && isspace( *q ); --q ) { - *q = '\0'; /* remove attribute trailing white space */ - } - - if ( value != NULL ) { - while ( isspace( *value )) { - ++value; /* skip value leading white space */ - } - for ( q = value + strlen( value ) - 1; q > value && - isspace( *q ); --q ) { - *q = '\0'; /* remove value trailing white space */ - } - if ( *value == '\0' ) { - value = NULL; - } - - } - - if ( value == NULL && newval ) { - fprintf( stderr, "%s: missing value on line %d (attr is %s)\n", - ldaptool_progname, linenum, attr ); - rc = LDAP_PARAM_ERROR; - } else { - int modop = -1; /* an invalid value */ - switch ( *attr ) { - case '-': - modop = LDAP_MOD_DELETE; - ++attr; - break; - case '+': - modop = LDAP_MOD_ADD; - ++attr; - break; - default: - /*Bug 27479. Remove the add default*/ - fprintf(stderr, "%s: Invalid parameter specified for changetype modify (line %d of entry %s)\n", - ldaptool_progname, linenum, dn); - rc = LDAP_PARAM_ERROR; - } - - if ( rc == 0 && modop != -1 ) { - addmodifyop( &pmods, modop, attr, value, - ( value == NULL ) ? 0 : strlen( value )); - } - } - } - - line = rbuf; - } - - if ( rc == 0 ) { - if ( dn == NULL ) { - rc = LDAP_PARAM_ERROR; - } else if (( rc = domodify( dn, pmods, newval )) == LDAP_SUCCESS ){ - rc = 0; - } - } - - if ( pmods != NULL ) { - freepmods( pmods ); - } - if ( dn != NULL ) { - free( dn ); - } - - return( rc ); -} - - -static void -addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen ) -{ - LDAPMod **pmods; - int i, j, rc; - struct berval *bvp; - - pmods = *pmodsp; - modop |= LDAP_MOD_BVALUES; - - i = 0; - if ( pmods != NULL ) { - for ( ; pmods[ i ] != NULL; ++i ) { - if ( strcasecmp( pmods[ i ]->mod_type, attr ) == 0 && - pmods[ i ]->mod_op == modop ) { - break; - } - } - } - - if ( pmods == NULL || pmods[ i ] == NULL ) { - if (( pmods = (LDAPMod **)LDAPTOOL_SAFEREALLOC( pmods, (i + 2) * - sizeof( LDAPMod * ))) == NULL ) { - perror( "realloc" ); - exit( LDAP_NO_MEMORY ); - } - *pmodsp = pmods; - pmods[ i + 1 ] = NULL; - if (( pmods[ i ] = (LDAPMod *)calloc( 1, sizeof( LDAPMod ))) - == NULL ) { - perror( "calloc" ); - exit( LDAP_NO_MEMORY ); - } - pmods[ i ]->mod_op = modop; - if (( pmods[ i ]->mod_type = strdup( attr )) == NULL ) { - perror( "strdup" ); - exit( LDAP_NO_MEMORY ); - } - } - - if ( value != NULL ) { - j = 0; - if ( pmods[ i ]->mod_bvalues != NULL ) { - for ( ; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) { - ; - } - } - if (( pmods[ i ]->mod_bvalues = (struct berval **) - LDAPTOOL_SAFEREALLOC( pmods[ i ]->mod_bvalues, - (j + 2) * sizeof( struct berval * ))) == NULL ) { - perror( "realloc" ); - exit( LDAP_NO_MEMORY ); - } - pmods[ i ]->mod_bvalues[ j + 1 ] = NULL; - if (( bvp = (struct berval *)malloc( sizeof( struct berval ))) - == NULL ) { - perror( "malloc" ); - exit( LDAP_NO_MEMORY ); - } - pmods[ i ]->mod_bvalues[ j ] = bvp; - - rc = ldaptool_berval_from_ldif_value( value, vlen, bvp, - ( ldif_version >= LDIF_VERSION_ONE ), valsfromfiles, - 1 /* report errors */ ); - if ( rc != LDAPTOOL_FILEURL_SUCCESS ) { - exit( ldaptool_fileurlerr2ldaperr( rc )); - } - } -} - - -static int -domodify( char *dn, LDAPMod **pmods, int newentry ) -{ - int i, j, notascii, op; - struct berval *bvp; - - if ( pmods == NULL ) { - fprintf( stderr, "%s: no attributes to change or add (entry %s)\n", - ldaptool_progname, dn ); - return( LDAP_PARAM_ERROR ); - } - - if ( ldaptool_verbose ) { - for ( i = 0; pmods[ i ] != NULL; ++i ) { - op = pmods[ i ]->mod_op & ~LDAP_MOD_BVALUES; - printf( "%s %s:\n", op == LDAP_MOD_REPLACE ? - "replace" : op == LDAP_MOD_ADD ? - "add" : "delete", pmods[ i ]->mod_type ); - if ( pmods[ i ]->mod_bvalues != NULL ) { - for ( j = 0; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) { - bvp = pmods[ i ]->mod_bvalues[ j ]; - notascii = 0; - if ( !display_binary_values ) { - notascii = !ldaptool_berval_is_ascii( bvp ); - } - if ( notascii ) { - printf( "\tNOT ASCII (%d bytes)\n", bvp->bv_len ); - } else { - printf( "\t%s\n", bvp->bv_val ); - } - } - } - } - } - - if ( !ldapmodify_quiet) { - if ( newentry ) { - printf( "%sadding new entry %s\n", - ldaptool_not ? "!" : "", dn ); - } else { - printf( "%smodifying entry %s\n", - ldaptool_not ? "!" : "", dn ); - } - } - - if ( !ldaptool_not ) { - if ( newentry ) { - unsigned int sleep_interval = 2; /* seconds */ - - while ((i = ldaptool_add_ext_s( ld, dn, pmods, - ldaptool_request_ctrls, NULL, "ldap_add" )) - == LDAP_BUSY) { - if ( sleep_interval > 3600 ) { - printf("ldap_add: Unable to complete request. "); - printf("Server is too "); - printf("busy servicing other requests\n"); - break; - } - if ( !ldapmodify_quiet ) { - printf("ldap_add: LDAP_BUSY returned by server. "); - printf("Will retry operation "); - printf("in %d seconds\n", sleep_interval); - } - sleep( sleep_interval ); - sleep_interval *= 2; - } - } else { - i = ldaptool_modify_ext_s( ld, dn, pmods, ldaptool_request_ctrls, - NULL, "ldap_modify" ); - } - if ( i == LDAP_SUCCESS && ldaptool_verbose ) { - printf( "modify complete\n" ); - } - } else { - i = LDAP_SUCCESS; - } - - if ( !ldapmodify_quiet) { - putchar( '\n' ); - } - - return( i ); -} - - -static int -dodelete( char *dn ) -{ - int rc; - - printf( "%sdeleting entry %s\n", ldaptool_not ? "!" : "", dn ); - if ( !ldaptool_not ) { - if (( rc = ldaptool_delete_ext_s( ld, dn, ldaptool_request_ctrls, - NULL, "ldap_delete" )) == LDAP_SUCCESS && ldaptool_verbose ) { - printf( "delete complete" ); - } - } else { - rc = LDAP_SUCCESS; - } - - putchar( '\n' ); - - return( rc ); -} - - -static int -dorename( char *dn, char *newrdn, char *newparent, int deleteoldrdn ) -{ - int rc; - - if ( ldaptool_verbose ) { - if ( newparent == NULL ) { - printf( "new RDN: %s (%skeep existing values)\n", - newrdn, deleteoldrdn ? "do not " : "" ); - } else { - printf( "new RDN: %s, new parent %s (%skeep existing values)\n", - newrdn, newparent, deleteoldrdn ? "do not " : "" ); - } - } - - printf( "%smodifying RDN of entry %s%s\n", - ldaptool_not ? "!" : "", dn, ( newparent == NULL ) ? "" : - " and/or moving it beneath a new parent\n" ); - - if ( !ldaptool_not ) { - if (( rc = ldaptool_rename_s( ld, dn, newrdn, newparent, deleteoldrdn, - ldaptool_request_ctrls, NULL, "ldap_rename" )) == LDAP_SUCCESS - && ldaptool_verbose ) { - printf( "rename completed\n" ); - } - } else { - rc = LDAP_SUCCESS; - } - - putchar( '\n' ); - - return( rc ); -} - - -static void -freepmods( LDAPMod **pmods ) -{ - int i; - - for ( i = 0; pmods[ i ] != NULL; ++i ) { - if ( pmods[ i ]->mod_bvalues != NULL ) { - ber_bvecfree( pmods[ i ]->mod_bvalues ); - } - if ( pmods[ i ]->mod_type != NULL ) { - free( pmods[ i ]->mod_type ); - } - free( pmods[ i ] ); - } - free( pmods ); -} - - -static char * -read_one_record( FILE *fp ) -{ - int len, gotnothing; - char *buf, line[ LDAPMOD_MAXLINE ]; - int lcur, lmax; - - lcur = lmax = 0; - buf = NULL; - gotnothing = 1; - - while ( fgets( line, sizeof(line), fp ) != NULL ) { - if ( (len = strlen( line )) < 2 ) { - if ( gotnothing ) { - continue; - } else { - break; - } - } - - /* Check if the blank line starts with '\r' (CR) */ - if ( ((len = strlen( line )) == 2) && (line[0] == '\r') ) { - if ( gotnothing ) { - continue; - } else { - break; - } - } - - if ( *line == '#' ) { - continue; /* skip comment lines */ - } - - gotnothing = 0; - if ( lcur + len + 1 > lmax ) { - lmax = LDAPMOD_MAXLINE - * (( lcur + len + 1 ) / LDAPMOD_MAXLINE + 1 ); - if (( buf = (char *)LDAPTOOL_SAFEREALLOC( buf, lmax )) == NULL ) { - perror( "realloc" ); - exit( LDAP_NO_MEMORY ); - } - } - strcpy( buf + lcur, line ); - lcur += len; - } - - return( buf ); -} - - -/* - * strdup and trim trailing blanks - */ -static char * -strdup_and_trim( char *s ) -{ - char *p; - - if (( s = strdup( s )) == NULL ) { - perror( "strdup" ); - exit( LDAP_NO_MEMORY ); - } - - p = s + strlen( s ) - 1; - while ( p >= s && isspace( *p )) { - --p; - } - *++p = '\0'; - - return( s ); -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/clients/tools/ldappasswd.c
Deleted
@@ -1,253 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Sun LDAP C SDK. - * - * The Initial Developer of the Original Code is Sun Microsystems, Inc. - * - * Portions created by Sun Microsystems, Inc are Copyright (C) 2005 - * Sun Microsystems, Inc. All Rights Reserved. - * - * Contributor(s): abobrov - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * ldappasswd.c - generic program to change LDAP users password - * by using password modify extended operation. - */ - -#include "ldaptool.h" -#include "fileurl.h" - -static int prompt_old_password = 0; -static int prompt_new_password = 0; -static int is_file_old = 0; -static int is_file_new = 0; -static FILE *old_password_fp = NULL; -static FILE *new_password_fp = NULL; -static char *old_password_string = "Old Password: "; -static char *new_password_string = "New Password: "; -static char *re_new_password_string = "Re-enter new Password: "; -static struct berval genpasswd = { 0, NULL }; -static struct berval oldpasswd = { 0, NULL }; -static struct berval newpasswd = { 0, NULL }; -static struct berval userid = { 0, NULL }; - -static void usage( void ); -static void options_callback( int option, char *optarg ); - -static void -usage( void ) -{ - fprintf( stderr, "usage: %s [options] [user]\n", ldaptool_progname ); - fprintf( stderr, "where:\n" ); - fprintf( stderr, " user\tauthentication id\n" ); - fprintf( stderr, " \te.g, uid=bjensen,dc=example,dc=com\n" ); - fprintf( stderr, "options:\n" ); - ldaptool_common_usage( 0 ); - fprintf( stderr, " -a passwd\told password\n" ); - fprintf( stderr, " -A\t\tprompt for old password\n" ); - fprintf( stderr, " -t file\tread old password from 'file'\n" ); - fprintf( stderr, " -s passwd\tnew password\n" ); - fprintf( stderr, " -S\t\tprompt for new password\n" ); - fprintf( stderr, " -T file\tread new password from 'file'\n" ); - exit( LDAP_PARAM_ERROR ); -} - -int -main( int argc, char **argv ) -{ - int optind; - int rc = LDAP_SUCCESS; /* being superoptimistic for -n */ - LDAP *ld; - -#ifdef notdef -#ifdef HPUX11 -#ifndef __LP64__ - _main( argc, argv); -#endif /* __LP64_ */ -#endif /* HPUX11 */ -#endif - - optind = ldaptool_process_args( argc, argv, "ASa:t:s:T:", 0, options_callback ); - - if ( (optind == -1) || (argc <= 1) ) { - usage(); - } - if ( (argc - optind) >= 1 ) { - if ( argv[ optind ] ) { - if ( (userid.bv_val = ldaptool_local2UTF8(argv[ optind ], "userid") ) == NULL ) { - fprintf( stderr, "%s: not enough memory\n", ldaptool_progname ); - exit( LDAP_NO_MEMORY ); - } - userid.bv_len = strlen( userid.bv_val ); - ++optind; - } - } - - ld = ldaptool_ldap_init( 0 ); - ldaptool_bind( ld ); - - if ( ldaptool_nobind && (userid.bv_val == NULL) && (userid.bv_len == 0) ) { - usage(); - } - - if ( !ldaptool_not ) { - rc = ldap_passwd_s( ld, userid.bv_val ? &userid : NULL, - oldpasswd.bv_val ? &oldpasswd : NULL, - newpasswd.bv_val ? &newpasswd : NULL, - &genpasswd, NULL, NULL ); - if ( rc != LDAP_SUCCESS ) { - ldap_perror( ld, ldaptool_progname ); - } else { - fprintf( stderr, "%s: password successfully changed\n", - ldaptool_progname ); - } - - if ( (genpasswd.bv_val != NULL) && (genpasswd.bv_len != 0) ) { - fprintf( stderr, "New password: %s\n", genpasswd.bv_val ); - } - } - - ldaptool_cleanup( ld ); - - return( rc ); -} - -static void -options_callback( int option, char *optarg ) -{ - char *old_passwd = NULL; - char *new_passwd = NULL; - char *re_newpasswd = NULL; - - switch( option ) { - case 'a': /* old password */ - old_passwd = strdup( optarg ); - if (NULL == old_passwd) - { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - break; - case 'A': /* prompt old password */ - prompt_old_password = 1; - break; - case 't': /* old password from file */ - if ((old_password_fp = fopen( optarg, "r" )) == NULL ) { - fprintf(stderr, "%s: Unable to open '%s' file\n", - ldaptool_progname, optarg); - exit( LDAP_PARAM_ERROR ); - } - is_file_old = 1; - break; - case 's': /* new password */ - new_passwd = strdup( optarg ); - if (NULL == new_passwd) - { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - break; - case 'S': /* prompt new password */ - prompt_new_password = 1; - break; - case 'T': /* new password from file */ - if ((new_password_fp = fopen( optarg, "r" )) == NULL ) { - fprintf(stderr, "%s: Unable to open '%s' file\n", - ldaptool_progname, optarg); - exit( LDAP_PARAM_ERROR ); - } - is_file_new = 1; - break; - default: - usage(); - break; - } - - if ( (oldpasswd.bv_val == NULL) && (oldpasswd.bv_len == 0) - && (prompt_old_password) ) { - old_passwd = ldaptool_getpass( old_password_string ); - } else if ( (oldpasswd.bv_val == NULL) && (oldpasswd.bv_len == 0) - && (is_file_old) ) { - old_passwd = ldaptool_read_password( old_password_fp ); - } - - if ( old_passwd ) { - if ( !ldaptool_noconv_passwd ) { - oldpasswd.bv_val = ldaptool_local2UTF8( old_passwd, "old password" ); - } else { - oldpasswd.bv_val = strdup( old_passwd ); - } - if (NULL == oldpasswd.bv_val) - { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - oldpasswd.bv_len = strlen( oldpasswd.bv_val ); - } - - if ( (newpasswd.bv_val == NULL) && (newpasswd.bv_len == 0) - && (prompt_new_password) ) { -try_again: - new_passwd = ldaptool_getpass( new_password_string ); - re_newpasswd = ldaptool_getpass( re_new_password_string ); - if ( (NULL == new_passwd) || (NULL == re_newpasswd) ) - { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - if ( (strncmp( new_passwd, re_newpasswd, - strlen( new_passwd ) ) ) ) { - fprintf( stderr, - "%s: They don't match.\n\nPlease try again\n", - ldaptool_progname ); - free( re_newpasswd ); - free( new_passwd ); - re_newpasswd = NULL; - new_passwd = NULL; - goto try_again; - } - } else if ( (newpasswd.bv_val == NULL) && (newpasswd.bv_len == 0) - && (is_file_new) ) { - new_passwd = ldaptool_read_password( new_password_fp ); - } - - if ( new_passwd ) { - if ( !ldaptool_noconv_passwd ) { - newpasswd.bv_val = ldaptool_local2UTF8( new_passwd, "new password" ); - } else { - newpasswd.bv_val = strdup( new_passwd ); - } - if (NULL == newpasswd.bv_val) { - perror("malloc"); - exit( LDAP_NO_MEMORY ); - } - newpasswd.bv_len = strlen( newpasswd.bv_val ); - } - -} -
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/clients/tools/ldapsearch.c
Deleted
@@ -1,1301 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* ldapsearch.c - generic program to search LDAP */ - -#include "ldaptool.h" -#include "fileurl.h" - -#define VLV_PARAM_SEP ':' - -static void usage( void ); -static int dosearch( LDAP *ld, char *base, int scope, char **attrs, - int attrsonly, char *filtpatt, char *value); -static void write_string_attr_value( char *attrname, char *strval, - unsigned long opts ); -#define LDAPTOOL_WRITEVALOPT_SUPPRESS_NAME 0x01 -static void write_ldif_value( char *type, char *value, unsigned long vallen, - unsigned long ldifoptions ); -static void print_entry( LDAP *ld, LDAPMessage *entry, int attrsonly ); -static void options_callback( int option, char *optarg ); -static void parse_and_display_reference( LDAP *ld, LDAPMessage *ref ); -static char *sortresult2string(ber_int_t result); -static char *changetype_num2string( ber_int_t chgtype ); -static char *msgtype2str( int msgtype ); -static char **get_effectiverights_attrlist(char * optarg); - -/* - * Prefix used in names of pseudo attributes added to the entry LDIF - * output if we receive an entryChangeNotification control with an entry - * (requested using persistent search). - */ -#define LDAPTOOL_PSEARCH_ATTR_PREFIX "persistentSearch-" - - -static void -usage( void ) -{ - fprintf( stderr, "usage: %s -b basedn [options] filter [attributes...]\n", ldaptool_progname ); - fprintf( stderr, " %s -b basedn [options] -f file [attributes...]\nwhere:\n", ldaptool_progname ); - fprintf( stderr, " basedn\tbase dn for search\n" ); - fprintf( stderr, "\t\t(if the environment variable LDAP_BASEDN is set,\n" ); - fprintf( stderr, "\t\tthen the -b flag is not required)\n" ); - fprintf( stderr, " filter\tRFC-2254 compliant LDAP search filter\n" ); - fprintf( stderr, " file\tfile containing a sequence of LDAP search filters to use\n" ); - fprintf( stderr, " attributes\twhitespace-separated list of attributes to retrieve\n" ); - fprintf( stderr, "\t\t(if no attribute list is given, all are retrieved)\n" ); - fprintf( stderr, "options:\n" ); - ldaptool_common_usage( 0 ); -#if defined( XP_WIN32 ) - fprintf( stderr, " -t\t\twrite values to files in temp directory.\n" ); -#else - fprintf( stderr, " -t\t\twrite values to files in /tmp\n" ); -#endif - fprintf( stderr, " -U\t\tproduce file URLs in conjunction with -t\n" ); - fprintf( stderr, " -e\t\tminimize base-64 encoding of values\n" ); - fprintf( stderr, " -u\t\tinclude User Friendly entry names in the output\n" ); - fprintf( stderr, " -r\t\tflush output after each entry is printed (useful with -C)\n" ); - fprintf( stderr, " -T\t\tdon't fold (wrap) long lines (default is to fold)\n" ); - fprintf( stderr, " -1\t\tomit leading \"version: %d\" line in LDIF output\n", LDIF_VERSION_ONE ); - fprintf( stderr, " -A\t\tretrieve attribute names only (no values)\n" ); - fprintf( stderr, " -B\t\tprint non-ASCII values and use old output format (attr=value)\n" ); - fprintf( stderr, " -x\t\tperforming sorting on server\n" ); - fprintf( stderr, " -F sep\tprint `sep' instead of `%s' between attribute names\n", LDAPTOOL_DEFSEP ); - fprintf( stderr, " \tand values in old output format (attr=value)\n" ); - fprintf( stderr, " -S attr\tsort the results by attribute `attr'\n" ); - fprintf( stderr, " -s scope\tone of base, one, or sub (default is sub)\n" ); - fprintf( stderr, " -a deref\tone of never, always, search, or find (default: never)\n" ); - fprintf( stderr, " \t(alias dereferencing)\n" ); - fprintf( stderr, " -l time lim\ttime limit (in seconds) for search (default is no limit)\n" ); - fprintf( stderr, " -z size lim\tsize limit (in entries) for search (default is no limit)\n" ); - fprintf( stderr, " -C PS:changetype[:changesonly[:entrychgcontrols]]\n" ); - fprintf( stderr, "\t\tchangetypes are add,delete,modify,moddn,any\n" ); - fprintf( stderr, "\t\tchangesonly and entrychgcontrols are boolean values\n" ); - fprintf( stderr, "\t\t(default is 1)\n" ); - fprintf( stderr, " -G before%cafter%cindex%ccount | before%cafter%cvalue where 'before' and\n", VLV_PARAM_SEP, VLV_PARAM_SEP, VLV_PARAM_SEP, VLV_PARAM_SEP, VLV_PARAM_SEP ); - fprintf( stderr, "\t\t'after' are the number of entries surrounding 'index.'\n"); - fprintf( stderr, "\t\t'count' is the content count, 'value' is the search value.\n"); - fprintf( stderr, " -c authzid\tspecifies the getEffectiveRights control authzid\n"); - fprintf( stderr, "\t\t eg. dn:uid=bjensen,dc=example,dc=com\n"); - fprintf( stderr, "\t\t A value of \"\" means \"the authorization id for the operation\".\n"); - fprintf( stderr, "\t\t A value of \"dn:\" means \"anonymous\"\n"); - fprintf( stderr, "\t\t (The aclRights operational attribute must be requested)\n"); - fprintf( stderr, " -X attrlist\tspecifies the getEffectiveRights control specific attribute list,\n"); - fprintf( stderr, "\t\t where attributes are space separated eg. \"nsroledn userPassword\"\n"); - - exit( LDAP_PARAM_ERROR ); -} - -static char *base = NULL; -static char *sep = LDAPTOOL_DEFSEP; -static char **sortattr = NULL; -static char *vlv_value = NULL; -static int sortsize = 0; -static int *skipsortattr = NULL; -static int includeufn, allow_binary, vals2tmp, ldif, scope, deref; -static int attrsonly, timelimit, sizelimit, server_sort, fold; -static int minimize_base64, produce_file_urls; -static int use_vlv = 0, vlv_before, vlv_after, vlv_index, vlv_count; -static int use_psearch=0; -static int flush_after_each_entry=0; -static int write_ldif_version = 1; -static char *get_effectiverights_control_target_dn = NULL; /* -c */ -static char **get_effectiverights_control_attrlist = NULL; /* -X */ -static int do_effective_rights_control = 0; - -/* Persistent search variables */ -static int chgtype=0, changesonly=1, return_echg_ctls=1; - - -int -main( int argc, char **argv ) -{ - char *filtpattern = NULL; - int free_filtpattern = 0; - char **attrs; - int rc, optind, i, first; - LDAP *ld; - - deref = LDAP_DEREF_NEVER; - allow_binary = vals2tmp = attrsonly = 0; - minimize_base64 = produce_file_urls = 0; - ldif = 1; - fold = 1; - sizelimit = timelimit = 0; - scope = LDAP_SCOPE_SUBTREE; - server_sort = 0; - -#ifdef notdef -#ifdef HPUX11 -#ifndef __LP64__ - _main( argc, argv); -#endif /* __LP64_ */ -#endif /* HPUX11 */ -#endif - - - ldaptool_reset_control_array( ldaptool_request_ctrls ); -#ifdef HAVE_SASL_OPTIONS -#ifdef HAVE_SASL_OPTIONS_2 - optind = ldaptool_process_args( argc, argv, "ABLTU1eortuxa:b:F:G:l:S:s:z:C:c:X:", - 0, options_callback ); -#else - optind = ldaptool_process_args( argc, argv, "ABLTU1ertuxa:b:F:G:l:S:s:z:C:c:X:", - 0, options_callback ); -#endif -#else - optind = ldaptool_process_args( argc, argv, - "ABLTU1eortuxa:b:F:G:l:S:s:z:C:c:X:", 0, options_callback ); -#endif /* HAVE_SASL_OPTIONS */ - - if ( optind == -1 ) { - usage(); - } - - if ( base == NULL ) { - if (( base = getenv( "LDAP_BASEDN" )) == NULL ) { - usage(); - } - } - if ( sortattr ) { - for ( sortsize = 0; sortattr[sortsize] != NULL; sortsize++ ) { - ; /* NULL */ - } - sortsize++; /* add in the final NULL field */ - skipsortattr = (int *) malloc( sortsize * sizeof(int *) ); - if ( skipsortattr == NULL ) { - fprintf( stderr, "Out of memory\n" ); - exit( LDAP_NO_MEMORY ); - } - memset( (char *) skipsortattr, 0, sortsize * sizeof(int *) ); - } else if ( server_sort ) { - server_sort = 0; /* ignore this option if no sortattrs were given */ - } - - if ( argc - optind < 1 ) { - if ( ldaptool_fp == NULL ) { - usage(); - } - attrs = NULL; - filtpattern = "%s"; - } else { /* there are additional args (filter + attrs) */ - if ( ldaptool_fp == NULL || strstr( argv[ optind ], "%s" ) != NULL ) { - filtpattern = ldaptool_local2UTF8( argv[ optind ], "filter" ); - free_filtpattern = 1; - ++optind; - } else { - filtpattern = "%s"; - } - - if ( argv[ optind ] == NULL ) { - attrs = NULL; - } else if ( sortattr == NULL || *sortattr == '\0' || server_sort) { - attrs = &argv[ optind ]; - } else { - attrs = ldap_charray_dup( &argv[ optind ] ); - if ( attrs == NULL ) { - fprintf( stderr, "Out of memory\n" ); - exit( LDAP_NO_MEMORY ); - } - for ( i = 0; i < (sortsize - 1); i++ ) { - if ( !ldap_charray_inlist( attrs, sortattr[i] ) ) { - if ( ldap_charray_add( &attrs, sortattr[i] ) != 0 ) { - fprintf( stderr, "Out of memory\n" ); - exit( LDAP_NO_MEMORY ); - } - /* - * attribute in the search list only for the purpose of - * sorting - */ - skipsortattr[i] = 1; - } - } - } - } - - ld = ldaptool_ldap_init( 0 ); - - if ( !ldaptool_not ) { - ldap_set_option( ld, LDAP_OPT_DEREF, &deref ); - ldap_set_option( ld, LDAP_OPT_TIMELIMIT, &timelimit ); - ldap_set_option( ld, LDAP_OPT_SIZELIMIT, &sizelimit ); - } - - ldaptool_bind( ld ); - - if ( ldaptool_verbose ) { - printf( "filter pattern: %s\nreturning: ", filtpattern ); - if ( attrs == NULL ) { - printf( "ALL" ); - } else { - for ( i = 0; attrs[ i ] != NULL; ++i ) { - printf( "%s ", attrs[ i ] ); - } - } - putchar( '\n' ); - } - - if ( ldaptool_fp == NULL ) { - char *conv = NULL; - - conv = ldaptool_local2UTF8( base, "base DN" ); - rc = dosearch( ld, conv, scope, attrs, attrsonly, filtpattern, "" ); - if( conv != NULL ) - free( conv ); - } else { - int done = 0; - - rc = LDAP_SUCCESS; - first = 1; - while ( rc == LDAP_SUCCESS && !done ) { - char *linep = NULL; - int increment = 0; - int c, index; - - /* allocate initial block of memory */ - if ((linep = (char *)malloc(BUFSIZ)) == NULL) { - fprintf( stderr, "Out of memory\n" ); - exit( LDAP_NO_MEMORY ); - } - increment++; - index = 0; - while ((c = fgetc( ldaptool_fp )) != '\n' && c != EOF) { - - /* check if we will overflow the buffer */ - if ((c != EOF) && (index == ((increment * BUFSIZ) -1))) { - - /* if we did, add another BUFSIZ worth of bytes */ - if ((linep = (char *) - realloc(linep, (increment + 1) * BUFSIZ)) == NULL) { - fprintf( stderr, "Out of memory\n" ); - exit( LDAP_NO_MEMORY ); - } - increment++; - } - linep[index++] = c; - } - - if (c == EOF) { - done = 1; - break; - } - - linep[index] = '\0'; - - if ( !first ) { - putchar( '\n' ); - } else { - first = 0; - } - rc = dosearch( ld, base, scope, attrs, attrsonly, filtpattern, - linep ); - free (linep); - } - } - - ldaptool_cleanup( ld ); - if ( (free_filtpattern != 0) && (filtpattern != NULL) ) { - free (filtpattern); - } - return( rc ); -} - - -static void -options_callback( int option, char *optarg ) -{ - char *s, *ps_ptr, *ps_arg; - char *temp_arg = NULL; - - switch( option ) { - case 'u': /* include UFN */ - ++includeufn; - break; - case 't': /* write attribute values to /tmp files */ - ++vals2tmp; - break; - case 'U': /* produce file URLs in conjunction with -t */ - ++produce_file_urls; - break; - case 'e': /* minimize base-64 encoding of values */ - ++minimize_base64; - break; - case 'A': /* retrieve attribute names only -- no values */ - ++attrsonly; - break; - case 'L': /* print entries in LDIF format -- now the default */ - break; - case 'r': /* flush output after each entry is written */ - flush_after_each_entry = 1; - break; - case 'B': /* allow binary values to be printed, use old format */ - ++allow_binary; - ldif = 0; - break; - case '1': /* omit leading "version: #" line from LDIF output */ - write_ldif_version = 0; - break; - case 's': /* search scope */ - if ( strncasecmp( optarg, "base", 4 ) == 0 ) { - scope = LDAP_SCOPE_BASE; - } else if ( strncasecmp( optarg, "one", 3 ) == 0 ) { - scope = LDAP_SCOPE_ONELEVEL; - } else if ( strncasecmp( optarg, "sub", 3 ) == 0 ) { - scope = LDAP_SCOPE_SUBTREE; - } else { - fprintf( stderr, "scope should be base, one, or sub\n" ); - usage(); - } - break; - - case 'a': /* set alias deref option */ - if ( strncasecmp( optarg, "never", 5 ) == 0 ) { - deref = LDAP_DEREF_NEVER; - } else if ( strncasecmp( optarg, "search", 5 ) == 0 ) { - deref = LDAP_DEREF_SEARCHING; - } else if ( strncasecmp( optarg, "find", 4 ) == 0 ) { - deref = LDAP_DEREF_FINDING; - } else if ( strncasecmp( optarg, "always", 6 ) == 0 ) { - deref = LDAP_DEREF_ALWAYS; - } else { - fprintf( stderr, "alias deref should be never, search, find, or always\n" ); - usage(); - } - break; - - case 'F': /* field separator */ - sep = strdup( optarg ); - break; - case 'c': /* getEffectiveRights control authzid */ - if ( optarg && optarg[0] == '\0' ) { - /* -c "" - means "This user" - */ - get_effectiverights_control_target_dn = NULL; - do_effective_rights_control = 1; - }else if ( strlen(optarg) < 3 || (strncasecmp(optarg, "dn:", 3) != 0) ) { - fprintf(stderr,"-c wrong format--should be \"\" or \"dn:...\".\n" - "\"dn:\" means anonymous user."); - usage(); - } else { - get_effectiverights_control_target_dn = strdup(optarg); - do_effective_rights_control = 1; - } - break; - case 'X': /* getEffectiveRights control attr list */ - get_effectiverights_control_attrlist = get_effectiverights_attrlist(optarg); - do_effective_rights_control = 1; - break; - case 'b': /* searchbase */ - base = strdup( optarg ); - break; - case 'l': /* time limit */ - timelimit = atoi( optarg ); - break; - case 'x': /* server sorting requested */ - server_sort = 1; - break; - case 'z': /* size limit */ - sizelimit = atoi( optarg ); - break; - case 'S': /* sort attribute */ - ldap_charray_add( &sortattr, strdup( optarg ) ); - break; - case 'T': /* don't fold lines */ - fold = 0; - break; - case 'G': /* do the virtual list setup */ - use_vlv++; - s = strchr(optarg, VLV_PARAM_SEP ); - - if (s != NULL) - { - vlv_before = atoi(optarg); - s++; - vlv_after = atoi( s ); - s = strchr(s, VLV_PARAM_SEP ); - if (s != NULL) - { - s++; - /* below is a small set of logic to implement the following cases - * -G23:23:wilber - * -G23:23:"wilber:wright" - * -G23:23:'wilber' - * -G23:23:wilber wright - * all of the above are before, after, value - NOTE: a colon not in a quoted - * string will break the parser!!!! - * -G23:23:45:600 - * above is index, count encoding - */ - - if (*s == '\'' || *s == '"') - { - vlv_value = strdup( s ); - } - else - { - if (strchr( s, VLV_PARAM_SEP )) - { - /* we have an index + count option */ - vlv_index = atoi( s ); - vlv_count = atoi( strchr( s, VLV_PARAM_SEP) + 1); - } - else - { - /* we don't have a quote surrounding the assertion value - * do we need to??? - */ - vlv_value = strdup( s ); - } - } - } - else - { - fprintf( stderr,"Illegal 'after' parameter for virtual list\n" ); - exit( LDAP_PARAM_ERROR ); - } - - } - else - { - fprintf( stderr,"Illegal 'before' parameter for virtual list\n" ); - exit( LDAP_PARAM_ERROR ); - } - break; - case 'C': - use_psearch++; - if ( (ps_arg = strdup( optarg)) == NULL ) { - perror ("strdup"); - exit (LDAP_NO_MEMORY); - } - - ps_ptr=strtok(ps_arg, ":"); - if (ps_ptr == NULL || (strcasecmp(ps_ptr, "ps")) ) { - fprintf (stderr, "Invalid argument for -C\n"); - usage(); - } - if (NULL != (ps_ptr=strtok(NULL, ":"))) { - if ( (temp_arg = strdup( ps_ptr )) == NULL ) { - perror ("strdup"); - exit (LDAP_NO_MEMORY); - } - } else { - fprintf (stderr, "Invalid argument for -C\n"); - usage(); - } - if (NULL != (ps_ptr=strtok(NULL, ":"))) { - if ( (changesonly = ldaptool_boolean_str2value(ps_ptr, 0)) == -1) { - fprintf(stderr, "Invalid option value: %s\n", ps_ptr); - usage(); - } - } - if (NULL != (ps_ptr=strtok(NULL, ":"))) { - if ( (return_echg_ctls = ldaptool_boolean_str2value(ps_ptr, 0)) == -1) { - fprintf(stderr, "Invalid option value: %s\n", ps_ptr); - usage(); - } - } - - /* Now parse the temp_arg and build chgtype as - * the changetypes are encountered */ - - if ((ps_ptr = strtok( temp_arg, "," )) == NULL) { - usage(); - } else { - while ( ps_ptr ) { - if ((strcasecmp(ps_ptr, "add"))==0) - chgtype |= LDAP_CHANGETYPE_ADD; - else if ((strcasecmp(ps_ptr, "delete"))==0) - chgtype |= LDAP_CHANGETYPE_DELETE; - else if ((strcasecmp(ps_ptr, "modify"))==0) - chgtype |= LDAP_CHANGETYPE_MODIFY; - else if ((strcasecmp(ps_ptr, "moddn"))==0) - chgtype |= LDAP_CHANGETYPE_MODDN; - else if ((strcasecmp(ps_ptr, "any"))==0) - chgtype = LDAP_CHANGETYPE_ANY; - else { - fprintf(stderr, "Unknown changetype: %s\n", ps_ptr); - usage(); - } - ps_ptr = strtok( NULL, "," ); - } - } - break; - default: - usage(); - break; - } -} - - -static int -dosearch( ld, base, scope, attrs, attrsonly, filtpatt, value ) - LDAP *ld; - char *base; - int scope; - char **attrs; - int attrsonly; - char *filtpatt; - char *value; -{ - char **refs = NULL, filter[ BUFSIZ ], *filterp = NULL; - int rc, first, matches; - LDAPMessage *res, *e; - LDAPControl *ldctrl; - LDAPControl **ctrl_response_array = NULL; - LDAPVirtualList vlv_data; - int msgid = 0; - int length = 0; - int mallocd_filter = 0; - - if ( strstr( filtpatt, "%s" ) == NULL ) { /* no need to sprintf() */ - filterp = filtpatt; - } else { - length = strlen( filtpatt ) + strlen ( value ) +1; - if ( length > BUFSIZ ) { - if ((filterp = (char *) - malloc ( length )) == NULL) { - perror( "filter and/or pattern too long?" ); - exit (LDAP_PARAM_ERROR); - } - mallocd_filter = 1; - } else { - filterp = filter; - } - -#ifdef HAVE_SNPRINTF - if ( snprintf( filterp, length, filtpatt, value ) < 0 ) { - perror( "snprintf filter (filter and/or pattern too long?)" ); - exit( LDAP_PARAM_ERROR ); - } -#else - sprintf( filterp, filtpatt, value ); -#endif - } - - if ( *filterp == '\0' ) { /* treat empty filter is a shortcut for oc=* */ - if (mallocd_filter) { - free(filterp); - mallocd_filter = 0; - } - filterp = "(objectclass=*)"; - } - - if ( ldaptool_verbose ) { - /* - * Display the filter that will be used. Add surrounding parens. - * if they are missing. - */ - if ( '(' == *filterp ) { - printf( "filter is: %s\n", filterp ); - } else { - printf( "filter is: (%s)\n", filterp ); - } - } - - if ( ldaptool_not ) { - if (mallocd_filter) free(filterp); - return( LDAP_SUCCESS ); - } - - if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) { - ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); - } - - if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) { - ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); - } - - if ( do_effective_rights_control ) { - if ((ldctrl = ldaptool_create_geteffectiveRights_control(ld, - get_effectiverights_control_target_dn, - (const char**) get_effectiverights_control_attrlist)) != NULL) { - ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); - } - } - - if (use_psearch) { - if ( ldap_create_persistentsearch_control( ld, chgtype, - changesonly, return_echg_ctls, - 1, &ldctrl ) != LDAP_SUCCESS ) - { - ldap_perror( ld, "ldap_create_persistentsearch_control" ); - return (1); - } - ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); - } - - - if (server_sort) { - /* First make a sort key list from the attribute list we have */ - LDAPsortkey **keylist = NULL; - int i = 0; - char *sortattrs = NULL; - char *s = NULL; - int string_length = 0; - - /* Count the sort strings */ - for (i = 0; i < sortsize - 1 ; i++) { - string_length += strlen(sortattr[i]) + 1; - } - - sortattrs = (char *) malloc(string_length + 1); - if (NULL == sortattrs) { - fprintf( stderr, "Out of memory\n" ); - exit( LDAP_NO_MEMORY ); - } - - s = sortattrs; - for (i = 0; i < sortsize - 1 ; i++) { - memcpy(s, sortattr[i], strlen(sortattr[i])); - s += strlen(sortattr[i]); - *s++ = ' '; - } - - sortattrs[string_length] = '\0'; - - ldap_create_sort_keylist(&keylist,sortattrs); - free(sortattrs); - sortattrs = NULL; - - /* Then make a control for the sort attributes we have */ - rc = ldap_create_sort_control(ld,keylist,0,&ldctrl); - ldap_free_sort_keylist(keylist); - if ( rc != LDAP_SUCCESS ) { - if (mallocd_filter) free(filterp); - return( ldaptool_print_lderror( ld, "ldap_create_sort_control", - LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - - ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); - - } - /* remember server side sorting must be available for vlv!!!! */ - - if (use_vlv) - { - vlv_data.ldvlist_before_count = vlv_before; - vlv_data.ldvlist_after_count = vlv_after; - if ( ldaptool_verbose ) { - printf( "vlv data %d, %d, ", - vlv_data.ldvlist_before_count, - vlv_data.ldvlist_after_count - ); - } - if (vlv_value) - { - vlv_data.ldvlist_attrvalue = vlv_value; - vlv_data.ldvlist_size = 0; - vlv_data.ldvlist_index = 0; - if ( ldaptool_verbose ) { - printf( "%s, 0, 0\n", vlv_data.ldvlist_attrvalue); - } - } - else - { - vlv_data.ldvlist_attrvalue = NULL; - vlv_data.ldvlist_size = vlv_count; - vlv_data.ldvlist_index = vlv_index; - if ( ldaptool_verbose ) { - printf( "(null), %d, %d\n", vlv_data.ldvlist_size, vlv_data.ldvlist_index ); - } - } - - if ( rc != LDAP_SUCCESS ) { - if (mallocd_filter) free(filterp); - return( ldaptool_print_lderror( ld, "ldap_create_sort_control", - LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - if (LDAP_SUCCESS != (rc = ldap_create_virtuallist_control(ld, - &vlv_data, &ldctrl))) - { - if (mallocd_filter) free(filterp); - return( ldaptool_print_lderror( ld, - "ldap_create_virtuallist_control", - LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - - ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); - - } - - if ( ldap_search_ext( ld, base, scope, filterp, attrs, attrsonly, - ldaptool_request_ctrls, NULL, NULL, -1, &msgid ) - != LDAP_SUCCESS ) { - if (mallocd_filter) free(filterp); - return( ldaptool_print_lderror( ld, "ldap_search", - LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - - - matches = 0; - first = 1; - if ( sortattr && !server_sort ) { - rc = ldap_result( ld, LDAP_RES_ANY, 1, NULL, &res ); - } else { - while ( (rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res )) != - LDAP_RES_SEARCH_RESULT && rc != -1 ) { - if ( rc != LDAP_RES_SEARCH_ENTRY ) { - if ( rc == LDAP_RES_SEARCH_REFERENCE ) { - parse_and_display_reference( ld, res ); - } else if ( rc == LDAP_RES_EXTENDED - && ldap_msgid( res ) == LDAP_RES_UNSOLICITED ) { - (void)ldaptool_print_extended_response( ld, res, - "Unsolicited response" ); - } else { - fprintf( stderr, "%s: ignoring LDAP response message" - " type 0x%x (%s)\n", - ldaptool_progname, rc, msgtype2str( rc )); - } - ldap_msgfree( res ); - continue; - } - matches++; - e = ldap_first_entry( ld, res ); - if ( !first ) { - putchar( '\n' ); - } else { - first = 0; - } - print_entry( ld, e, attrsonly ); - ldap_msgfree( res ); - } - } - if ( rc == -1 ) { - if (mallocd_filter) free(filterp); - return( ldaptool_print_lderror( ld, "ldap_result", - LDAPTOOL_CHECK4SSL_IF_APPROP )); - } - - if ( ldap_parse_result( ld, res, &rc, NULL, NULL, &refs, - &ctrl_response_array, 0 ) != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, "ldap_parse_result", - LDAPTOOL_CHECK4SSL_IF_APPROP ); - } else if ( rc != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, "ldap_search", - LDAPTOOL_CHECK4SSL_IF_APPROP ); - } - /* Parse the returned sort control */ - if (server_sort) { - ber_int_t result = 0; - char *attribute; - - if ( LDAP_SUCCESS != ldap_parse_sort_control(ld,ctrl_response_array,&result,&attribute) ) { - (void)ldaptool_print_lderror(ld, "ldap_parse_sort_control", - LDAPTOOL_CHECK4SSL_IF_APPROP ); - ldap_controls_free(ctrl_response_array); - ldap_msgfree(res); - if (mallocd_filter) free(filterp); - return ( ldap_get_lderrno( ld, NULL, NULL ) ); - } - - if (0 == result) { - if ( ldaptool_verbose ) { - printf( "Server indicated results sorted OK\n"); - } - } else { - if (NULL != attribute) { - printf("Server reported sorting error %d: %s, attribute in error\"%s\"\n",result,sortresult2string(result),attribute); - } else { - printf("Server reported sorting error %d: %s\n",result,sortresult2string(result)); - } - } - - } - - if (use_vlv) - { - ber_int_t vpos, vcount; - int vresult; - if ( LDAP_SUCCESS != ldap_parse_virtuallist_control(ld,ctrl_response_array,&vpos, &vcount,&vresult) ) { - (void)ldaptool_print_lderror( ld, "ldap_parse_virtuallist_control", - LDAPTOOL_CHECK4SSL_IF_APPROP ); - ldap_controls_free(ctrl_response_array); - ldap_msgfree(res); - if (mallocd_filter) free(filterp); - return ( ldap_get_lderrno( ld, NULL, NULL ) ); - } - - if (0 == vresult) { - if ( ldaptool_verbose ) { - printf( "Server indicated virtual list positioning OK\n"); - } - printf("index %d content count %d\n", vpos, vcount); - - } else { - printf("Server reported sorting error %d: %s\n",vresult,sortresult2string((ber_int_t)vresult)); - - } - - } - - ldap_controls_free(ctrl_response_array); - - if ( sortattr != NULL && !server_sort) { - - (void) ldap_multisort_entries( ld, &res, - ( *sortattr == NULL ) ? NULL : sortattr, - (LDAP_CMP_CALLBACK *)strcasecmp ); - matches = 0; - first = 1; - for ( e = ldap_first_entry( ld, res ); e != NULLMSG; - e = ldap_next_entry( ld, e ) ) { - matches++; - if ( !first ) { - putchar( '\n' ); - } else { - first = 0; - } - print_entry( ld, e, attrsonly ); - } - } - - if ( ldaptool_verbose ) { - printf( "%d matches\n", matches ); - } - - if ( refs != NULL ) { - ldaptool_print_referrals( refs ); - ldap_value_free( refs ); - } - - if (mallocd_filter) free(filterp); - - if ( flush_after_each_entry ) { - /* - * Ensure that sort control, VLV control, and other status - * information is flushed in a timely fashion. - */ - fflush( stdout ); - } - - ldap_msgfree( res ); - return( rc ); -} - - -static void -print_entry( ld, entry, attrsonly ) - LDAP *ld; - LDAPMessage *entry; - int attrsonly; -{ - char *a, *dn, *ufn, tmpfname[ BUFSIZ ]; - int i, notascii; - BerElement *ber; - struct berval **bvals; - FILE *tmpfp; -#if defined( XP_WIN32 ) - char mode[20] = "w+b"; -#else - char mode[20] = "w"; -#endif - - dn = ldap_get_dn( ld, entry ); - write_string_attr_value( "dn", dn, LDAPTOOL_WRITEVALOPT_SUPPRESS_NAME ); - if ( includeufn ) { - ufn = ldap_dn2ufn( dn ); - write_string_attr_value( "ufn", ufn, - LDAPTOOL_WRITEVALOPT_SUPPRESS_NAME ); - free( ufn ); - } - ldap_memfree( dn ); - - if ( use_psearch ) { - LDAPControl **ectrls = NULL; - int chgnumpresent; - ber_int_t chgtype; - ber_int_t chgnum; - char *prevdn, longbuf[ 128 ]; - - if ( ldap_get_entry_controls( ld, entry, &ectrls ) == LDAP_SUCCESS ) { - if ( ldap_parse_entrychange_control( ld, ectrls, &chgtype, - &prevdn, &chgnumpresent, &chgnum ) == LDAP_SUCCESS ) { - write_string_attr_value( - LDAPTOOL_PSEARCH_ATTR_PREFIX "changeType", - changetype_num2string( chgtype ), 0 ); - if ( chgnumpresent ) { - sprintf( longbuf, "%d", chgnum ); - write_string_attr_value( - LDAPTOOL_PSEARCH_ATTR_PREFIX "changeNumber", - longbuf, 0 ); - } - if ( NULL != prevdn ) { - write_string_attr_value( - LDAPTOOL_PSEARCH_ATTR_PREFIX "previousDN", - prevdn, 0 ); - ldap_memfree( prevdn ); - } - } - ldap_controls_free( ectrls ); - } - } - - for ( a = ldap_first_attribute( ld, entry, &ber ); a != NULL; - a = ldap_next_attribute( ld, entry, ber ) ) { - if ( ldap_charray_inlist(sortattr, a) && /* in the list*/ - skipsortattr[ldap_charray_position(sortattr, a)] ) {/* and skip it*/ - continue; /* so skip it! */ - } - if ( attrsonly ) { - if ( ldif ) { - write_ldif_value( a, "", 0, 0 ); - } else { - printf( "%s\n", a ); - } - } else if (( bvals = ldap_get_values_len( ld, entry, a )) != NULL ) { - for ( i = 0; bvals[i] != NULL; i++ ) { - if ( vals2tmp ) { -#ifdef HAVE_SNPRINTF - if ( snprintf( tmpfname, sizeof(tmpfname), - "%s/ldapsearch-%s-XXXXXX", - ldaptool_get_tmp_dir(), a ) < 0 ) { - perror( "snprintf tmpfname (attribute name too long?)" ); - exit( LDAP_PARAM_ERROR ); - } -#else - sprintf( tmpfname, "%s/ldapsearch-%s-XXXXXX", - ldaptool_get_tmp_dir(), a ); -#endif - tmpfp = NULL; - - if ( LDAPTOOL_MKTEMP( tmpfname ) == NULL ) { - perror( tmpfname ); - } else if (( tmpfp = ldaptool_open_file( tmpfname, mode)) == NULL ) { - perror( tmpfname ); - } else if ( bvals[ i ]->bv_len > 0 && - fwrite( bvals[ i ]->bv_val, - bvals[ i ]->bv_len, 1, tmpfp ) == 0 ) { - perror( tmpfname ); - } else if ( ldif ) { - if ( produce_file_urls ) { - char *url; - - if ( ldaptool_path2fileurl( tmpfname, &url ) != - LDAPTOOL_FILEURL_SUCCESS ) { - perror( "ldaptool_path2fileurl" ); - } else { - write_ldif_value( a, url, strlen( url ), - LDIF_OPT_VALUE_IS_URL ); - free( url ); - } - } else { - write_ldif_value( a, tmpfname, strlen( tmpfname ), - 0 ); - } - } else { - printf( "%s%s%s\n", a, sep, tmpfname ); - } - - if ( tmpfp != NULL ) { - fclose( tmpfp ); - } - } else { - notascii = 0; - if ( !ldif && !allow_binary ) { - notascii = !ldaptool_berval_is_ascii( bvals[i] ); - } - - if ( ldif ) { - write_ldif_value( a, bvals[ i ]->bv_val, - bvals[ i ]->bv_len, 0 ); - } else { - printf( "%s%s%s\n", a, sep, - notascii ? "NOT ASCII" : bvals[ i ]->bv_val ); - } - } - } - ber_bvecfree( bvals ); - } - ldap_memfree( a ); - } - - if ( ldap_get_lderrno( ld, NULL, NULL ) != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, "ldap_first_attribute/ldap_next_attribute", - LDAPTOOL_CHECK4SSL_IF_APPROP ); - } - - if ( flush_after_each_entry ) { - fflush( stdout ); - } - - if ( ber != NULL ) { - ber_free( ber, 0 ); - } -} - - -static void -write_string_attr_value( char *attrname, char *strval, unsigned long opts ) -{ - if ( strval == NULL ) { - strval = ""; - } - if ( ldif ) { - write_ldif_value( attrname, strval, strlen( strval ), 0 ); - } else if ( 0 != ( opts & LDAPTOOL_WRITEVALOPT_SUPPRESS_NAME )) { - printf( "%s\n", strval ); - } else { - printf( "%s%s%s\n", attrname, sep, strval ); - } -} - - -static void -write_ldif_value( char *type, char *value, unsigned long vallen, - unsigned long ldifoptions ) -{ - char *ldif; - static int wrote_version = 0; - - if ( write_ldif_version && !wrote_version ) { - char versionbuf[ 64 ]; - - wrote_version = 1; - sprintf( versionbuf, "%d", LDIF_VERSION_ONE ); - write_ldif_value( "version", versionbuf, strlen( versionbuf ), 0 ); - } - - if ( !fold ) { - ldifoptions |= LDIF_OPT_NOWRAP; - } - if ( minimize_base64 ) { - ldifoptions |= LDIF_OPT_MINIMAL_ENCODING; - } - - /* ldif_type_and_value() fails only if malloc() fails. */ - if (( ldif = ldif_type_and_value_with_options( type, value, (int)vallen, - ldifoptions )) == NULL ) { - exit( LDAP_NO_MEMORY ); - } - - fputs( ldif, stdout ); - free( ldif ); -} - - -static char * -sortresult2string(ber_int_t result) -{ - /* - success (0), -- results are sorted - operationsError (1), -- server internal failure - timeLimitExceeded (3), -- timelimit reached before - -- sorting was completed - strongAuthRequired (8), -- refused to return sorted - -- results via insecure - -- protocol - adminLimitExceeded (11), -- too many matching entries - -- for the server to sort - noSuchAttribute (16), -- unrecognized attribute - -- type in sort key - inappropriateMatching (18), -- unrecognized or inappro- - -- priate matching rule in - -- sort key - insufficientAccessRights (50), -- refused to return sorted - -- results to this client - busy (51), -- too busy to process - unwillingToPerform (53), -- unable to sort - other (80) - */ - - switch (result) { - case 0: return ("success"); - case 1: return ("operations error"); - case 3: return ("time limit exceeded"); - case 8: return ("strong auth required"); - case 11: return ("admin limit exceeded"); - case 16: return ("no such attribute"); - case 18: return ("unrecognized or inappropriate matching rule"); - case 50: return ("insufficient access rights"); - case 51: return ("too busy"); - case 53: return ("unable to sort"); - case 80: - default: return ("Er...Other ?"); - } -} - - -static void -parse_and_display_reference( LDAP *ld, LDAPMessage *ref ) -{ - int i; - char **refs; - - if ( ldap_parse_reference( ld, ref, &refs, NULL, 0 ) != LDAP_SUCCESS ) { - (void)ldaptool_print_lderror( ld, "ldap_parse_reference", - LDAPTOOL_CHECK4SSL_IF_APPROP ); - } else if ( refs != NULL && refs[ 0 ] != NULL ) { - fputs( "Unfollowed continuation reference(s):\n", stderr ); - for ( i = 0; refs[ i ] != NULL; ++i ) { - fprintf( stderr, " %s\n", refs[ i ] ); - } - ldap_value_free( refs ); - } -} - - -/*possible operations a client can invoke -- copied from ldaprot.h */ - -#ifndef LDAP_REQ_BIND -#define LDAP_REQ_BIND 0x60L /* application + constructed */ -#define LDAP_REQ_UNBIND 0x42L /* application + primitive */ -#define LDAP_REQ_SEARCH 0x63L /* application + constructed */ -#define LDAP_REQ_MODIFY 0x66L /* application + constructed */ -#define LDAP_REQ_ADD 0x68L /* application + constructed */ -#define LDAP_REQ_DELETE 0x4aL /* application + primitive */ -#define LDAP_REQ_RENAME 0x6cL /* application + constructed */ -#define LDAP_REQ_COMPARE 0x6eL /* application + constructed */ -#define LDAP_REQ_ABANDON 0x50L /* application + primitive */ -#define LDAP_REQ_EXTENDED 0x77L /* application + constructed */ -#endif /* LDAP_REQ_BIND */ - - - -struct ldapsearch_type2str { - - int ldst2s_type; /* message type */ - char *ldst2s_string; /* descriptive string */ -}; - - -static struct ldapsearch_type2str ldapsearch_msgtypes[] = { - - /* results: */ - { LDAP_RES_BIND, "bind result" }, - { LDAP_RES_SEARCH_REFERENCE, "continuation reference" }, - { LDAP_RES_SEARCH_ENTRY, "entry" }, - { LDAP_RES_SEARCH_RESULT, "search result" }, - { LDAP_RES_MODIFY, "modify result" }, - { LDAP_RES_ADD, "add result" }, - { LDAP_RES_DELETE, "delete result" }, - { LDAP_RES_MODDN, "rename result" }, - { LDAP_RES_COMPARE, "compare result" }, - { LDAP_RES_EXTENDED, "extended operation result" }, - /* requests: */ - { LDAP_REQ_BIND, "bind request" }, - { LDAP_REQ_UNBIND, "unbind request" }, - { LDAP_REQ_SEARCH, "search request" }, - { LDAP_REQ_MODIFY, "modify request" }, - { LDAP_REQ_ADD, "add request" }, - { LDAP_REQ_DELETE, "delete request" }, - { LDAP_REQ_RENAME, "rename request" }, - { LDAP_REQ_COMPARE, "compare request" }, - { LDAP_REQ_ABANDON, "abandon request" }, - { LDAP_REQ_EXTENDED, "extended request" }, - -}; - - -#define LDAPSEARCHTOOL_NUMTYPES (sizeof(ldapsearch_msgtypes) \ - / sizeof(struct ldapsearch_type2str)) - - -/* - * Return a descriptive string given an LDAP result message type (tag). - */ -static char * -msgtype2str( int msgtype ) -{ - char *s = "unknown"; - int i; - - s = "unknown"; - for ( i = 0; i < LDAPSEARCHTOOL_NUMTYPES; ++i ) { - if ( msgtype == ldapsearch_msgtypes[ i ].ldst2s_type ) { - s = ldapsearch_msgtypes[ i ].ldst2s_string; - } - } - return( s ); -} - - -/* - * Return a descriptive string given a Persistent Search change type - */ -static char * -changetype_num2string( ber_int_t chgtype ) -{ - char *s = "unknown"; - - switch( chgtype ) { - case LDAP_CHANGETYPE_ADD: - s = "add"; - break; - case LDAP_CHANGETYPE_DELETE: - s = "delete"; - break; - case LDAP_CHANGETYPE_MODIFY: - s = "modify"; - break; - case LDAP_CHANGETYPE_MODDN: - s = "moddn"; - break; - } - - return( s ); -} - -/* returns a null teminated charrary */ -static char **get_effectiverights_attrlist(char * optarg) -{ - int i = 0; - char ** retArray = NULL; - char * tmp_str = strdup(optarg); - - if ( tmp_str == NULL ) { - perror("strdup"); - exit(LDAP_NO_MEMORY); - } - - retArray = ldap_str2charray( tmp_str, " "); /* takes copies */ - if ( retArray == NULL ) { - fprintf( stderr, "%s: not enough memory\n", ldaptool_progname ); - exit( LDAP_NO_MEMORY ); - } - - free(tmp_str); - - while( retArray[i] != NULL ) { - - fprintf(stderr,"%s ", retArray[i]); - i++; - } - fprintf(stderr, "\n"); - - return(retArray); -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/clients/tools/ldaptool.h
Deleted
@@ -1,208 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _LDAPTOOL_H -#define _LDAPTOOL_H - -/* XXX:mhein The following is a workaround for the redefinition of */ -/* const problem on OSF. Fix to be provided by NSS */ -/* This is a pretty benign workaround for us which */ -/* should not cause problems in the future even if */ -/* we forget to take it out :-) */ - -#ifdef OSF1V4D -#ifndef __STDC__ -# define __STDC__ -#endif /* __STDC__ */ -#endif /* OSF1V4D */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> - -#ifdef AIX -#include <strings.h> -#endif - - -#ifdef SCOOS -#include <sys/types.h> -#endif - -#ifdef _WINDOWS -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -extern int getopt (int argc, char *const *argv, const char *optstring); -#include <io.h> /* for _mktemp() */ -#define LDAPTOOL_MKTEMP( p ) _mktemp( p ) -#else -#include <sys/file.h> -#include <sys/stat.h> -#include <unistd.h> - -#define LDAPTOOL_MKTEMP( p ) mktemp( p ) -#endif - -#ifdef LINUX -#include <getopt.h> /* not always included from unistd.h */ -#endif - -#include <ctype.h> - -#ifndef SCOOS -#include <sys/types.h> -#endif - -#include <sys/stat.h> -#include <fcntl.h> - -#if defined(NET_SSL) -#include <ssl.h> -#endif - -#include <portable.h> -#include <ldap.h> -#include <ldaplog.h> -#include <ldif.h> - -#if defined(NET_SSL) -#include <ldap_ssl.h> -#endif - -#include <ldappr.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * shared macros, structures, etc. - */ -#define LDAPTOOL_RESULT_IS_AN_ERROR( rc ) \ - ( (rc) != LDAP_SUCCESS && (rc) != LDAP_COMPARE_TRUE \ - && (rc) != LDAP_COMPARE_FALSE ) - -#define LDAPTOOL_DEFSEP "=" /* used by ldapcmp and ldapsearch */ -#define LDAPTOOL_DEFHOST "localhost" -#define LDAPTOOL_DEFSSLSTRENGTH LDAPSSL_AUTH_CERT -#define LDAPTOOL_DEFCERTDBPATH "." -#define LDAPTOOL_DEFKEYDBPATH "." -#define LDAPTOOL_DEFREFHOPLIMIT 5 - -#define LDAPTOOL_SAFEREALLOC( ptr, size ) ( ptr == NULL ? malloc( size ) : \ - realloc( ptr, size )) -/* this defines the max number of control requests for the tools */ -#define CONTROL_REQUESTS 50 - -/* - * globals (defined in common.c) - */ -extern char *ldaptool_host; -extern char *ldaptool_host2; -extern int ldaptool_port; -extern int ldaptool_port2; -extern int ldaptool_verbose; -extern int ldaptool_not; -extern int ldaptool_nobind; -extern int ldaptool_noconv_passwd; -extern char *ldaptool_progname; -extern FILE *ldaptool_fp; -extern char *ldaptool_charset; -extern LDAPControl *ldaptool_request_ctrls[]; -#ifdef LDAP_DEBUG -extern int ldaptool_dbg_lvl; -#define LDAPToolDebug(lvl,fmt,arg1,arg2,arg3) if (lvl & ldaptool_dbg_lvl) { fprintf(stderr,fmt,arg1,arg2,arg3); } -#else -#define LDAPToolDebug(lvl,fmt,arg1,arg2,arg3) -#endif /* LDAP_DEBUG */ - - -/* - * function prototypes - */ -void ldaptool_common_usage( int two_hosts ); -int ldaptool_process_args( int argc, char **argv, char *extra_opts, - int two_hosts, void (*extra_opt_callback)( int option, char *optarg )); -LDAP *ldaptool_ldap_init( int second_host ); -void ldaptool_bind( LDAP *ld ); -void ldaptool_cleanup( LDAP *ld ); -int ldaptool_print_lderror( LDAP *ld, char *msg, int check4ssl ); -#define LDAPTOOL_CHECK4SSL_NEVER 0 -#define LDAPTOOL_CHECK4SSL_ALWAYS 1 -#define LDAPTOOL_CHECK4SSL_IF_APPROP 2 /* if appropriate */ -LDAPControl *ldaptool_create_manage_dsait_control( void ); -void ldaptool_print_referrals( char **refs ); -int ldaptool_print_extended_response( LDAP *ld, LDAPMessage *res, char *msg ); -LDAPControl *ldaptool_create_proxyauth_control( LDAP *ld ); -LDAPControl *ldaptool_create_geteffectiveRights_control ( LDAP *ld, - const char *authzid, const char **attrlist ); -void ldaptool_add_control_to_array( LDAPControl *ctrl, LDAPControl **array); -void ldaptool_reset_control_array( LDAPControl **array ); -char *ldaptool_get_tmp_dir( void ); -char *ldaptool_local2UTF8( const char *s, const char *desc ); -char *ldaptool_getpass( const char *prompt ); -char *ldaptool_read_password( FILE *mod_password_fp ); -int ldaptool_berval_is_ascii( const struct berval *bvp ); -int ldaptool_sasl_bind_s( LDAP *ld, const char *dn, const char *mechanism, - const struct berval *cred, LDAPControl **serverctrls, - LDAPControl **clientctrls, struct berval **servercredp, char *msg ); -int ldaptool_simple_bind_s( LDAP *ld, const char *dn, const char *passwd, - LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ); -int ldaptool_add_ext_s( LDAP *ld, const char *dn, LDAPMod **attrs, - LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ); -int ldaptool_modify_ext_s( LDAP *ld, const char *dn, LDAPMod **mods, - LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ); -int ldaptool_delete_ext_s( LDAP *ld, const char *dn, LDAPControl **serverctrls, - LDAPControl **clientctrls, char *msg ); -int ldaptool_rename_s( LDAP *ld, const char *dn, const char *newrdn, - const char *newparent, int deleteoldrdn, LDAPControl **serverctrls, - LDAPControl **clientctrls, char *msg ); -int ldaptool_compare_ext_s( LDAP *ld, const char *dn, const char *attrtype, - const struct berval *bvalue, LDAPControl **serverctrls, - LDAPControl **clientctrls, char *msg ); -int ldaptool_boolean_str2value ( const char *s, int strict ); -int ldaptool_parse_ctrl_arg ( char *ctrl_arg, char sep, char **ctrl_oid, - int *ctrl_criticality, char **ctrl_value, int *vlen); -FILE *ldaptool_open_file ( const char *filename, const char * mode); - - -#ifdef __cplusplus -} -#endif - -#endif /* LDAPTOOL_H */
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/docs
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/examples
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/examples/Makefile
Deleted
@@ -1,318 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla Communicator client code, released -# March 31, 1998. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-1999 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -# UNIX Makefile for Directory SDK examples -# -# SSL examples are not built by default. Use 'make ssl' to build them. -# NSPR examples are not built by default. Use 'make nspr' to build them. -# - -############################################################################### -# If you are not building on Solaris, you will need to comment out the -# Solaris section and uncomment the appropriate section for your platform. -# -# Chances are you will need to do a little bit of work in order to get the -# examples to compile. If you are not compiling on Solaris, use the -# Solaris builds as a model for the libraries you need etc. Chances are -# they are the most up-to-date -# - -# For Solaris (32 bit) -# EXTRACFLAGS= -# EXTRALDFLAGS=-lsocket -lnsl -# EXTRANSPRLDFLAGS=-mt -# SLDAPLIB=ldap60 -lssldap60 -lssl3 -lnss3 -# LDAPLIB=ldap60 -# LDAPPRLIB=prldap60 -# NSPRLIB=nspr4 -# CC=cc - -# For Solaris (64 bit) -#EXTRACFLAGS= -#EXTRALDFLAGS=-lsocket -lnsl -#EXTRANSPRLDFLAGS=-mt -#SLDAPLIB=ldap60 -lssldap60 -lssl3 -lnss3 -#LDAPLIB=ldap60 -#LDAPPRLIB=prldap60 -#NSPRLIB=nspr4 -#CC=cc -xarch=v9 - -# For HP/UX (32 bit) -#EXTRACFLAGS=-Dhpux -D_HPUX_SOURCE -D_REENTRANT -Aa -#EXTRALDFLAGS=-Wl,+s+b -#SLDAPLIB=ldap60 -lssldap60 -lssl3 -lnss3 -#LDAPLIB=ldap60 -#LDAPPRLIB=prldap60 -#NSPRLIB=nspr4 -#CC=cc - -# For HP/UX (64 bit) -#EXTRACFLAGS=-DHPUX11 -DIS_64 +e +DA2.0W +DChpux +DS2.0 -#EXTRACFLAGS+=-D_LARGEFILE64_SOURCE -D_PR_HAVE_OFF64_T -#EXTRALDFLAGS=-lpthread +DA2.0W +DS2.0 -#SLDAPLIB=ldap60 -lssldap60 -lssl3 -lnss3 -#LDAPLIB=ldap60 -#LDAPPRLIB=prldap60 -#NSPRLIB=nspr4 -#CC=/opt/ansic/bin/cc - - -# For IRIX -#EXTRACFLAGS= -#EXTRALDFLAGS= -#SLDAPLIB=ldap60 -lssldap60 -lssl3 -lnss3 -#LDAPLIB=ldap60 -#LDAPPRLIB=prldap60 -#NSPRLIB=nspr4 -#CC=cc - -# For AIX -#EXTRACFLAGS= -#EXTRALDFLAGS=-brtl -#SLDAPLIB=ldap60 -lssldap60 -lssl3 -lnss3 -#LDAPLIB=ldap60 -#LDAPPRLIB=prldap60 -#NSPRLIB=nspr4 -#CC=cc - -# For Digital UNIX 4.0 -#EXTRACFLAGS= -#EXTRALDFLAGS=-taso -rpath ../lib -#SLDAPLIB=ldap60 -lssldap60 -lssl3 -lnss3 -#LDAPLIB=ldap60 -#LDAPPRLIB=prldap60 -#NSPRLIB=nspr4 -#CC=cc - -# For Linux 2.2 -EXTRACFLAGS=-I/usr/include/sasl -I/usr/include/nspr4 -EXTRALDFLAGS=-lsasl2 -lpthread -LDAPLIB=ldapssl60 -LDAPLIB=ldap60 -LDAPPRLIB=prldap60 -NSPRLIB=nspr4 -CC=gcc - -############################################################################### -# You should not need to change anything below here.... - -INTERNAL_LIBLDAP_HEADERS=$(wildcard ../libraries/libldap/*.h) -ifeq (,$(findstring h, $(INTERNAL_LIBLDAP_HEADERS))) -IN_SRC_TREE=0 -else -IN_SRC_TREE=1 -endif - -ifneq ($(IN_SRC_TREE),1) -# we are not in the C SDK source tree... so must be in a binary distribution -INCDIR=../include -LIBDIR=../lib -NSPRINCDIR=../include -NSPRLIBDIR=../lib - -else -# we are in the C SDK source tree... paths to headers and libs are different -NS_DEPTH = ../../.. -LDAP_SRC = .. -NSCP_DISTDIR = ../../../../dist -NSPR_TREE = ../.. -MOD_DEPTH = ../.. - -ifeq ($(HAVE_CCONF), 1) -COMPS_FROM_OBJDIR=1 -endif - -include $(NSPR_TREE)/config/config.mk - -ifeq ($(COMPS_FROM_OBJDIR),1) -NSPR_DISTDIR=$(NSCP_DISTDIR)/$(OBJDIR_NAME) -else -NSPR_DISTDIR=$(NSCP_DISTDIR) -endif - -INCDIR=$(NSCP_DISTDIR)/public/ldap -LIBDIR=$(NSCP_DISTDIR)/$(OBJDIR_NAME)/lib -NSPRINCDIR=$(NSPR_DISTDIR)/include -NSPRLIBDIR=$(NSPR_DISTDIR)/lib -endif - -LIBS=-L$(LIBDIR) -l$(LDAPLIB) $(EXTRALDFLAGS) -NSPRLIBS=$(EXTRANSPRLDFLAGS) -L$(NSPRLIBDIR) -l$(NSPRLIB) -l$(LDAPPRLIB) -SLIBS=-L$(LIBDIR) $(NSPRLIBS) -l$(SLDAPLIB) $(EXTRALDFLAGS) -OPTFLAGS=-g -CFLAGS=$(OPTFLAGS) -I$(INCDIR) -I$(NSPRINCDIR) $(EXTRACFLAGS) -NSPRCFLAGS=-I$(NSPRINCDIR) - -PROGS=search asearch csearch psearch rdentry getattrs srvrsort modattrs add del compare modrdn ppolicy getfilt crtfilt - -SSLPROGS=ssnoauth ssearch - -NSPRPROGS=nsprio - -ALLPROGS= $(PROGS) $(SSLPROGS) $(NSPRPROGS) - -standard: $(PROGS) - -ssl: $(SSLPROGS) - -nspr: $(NSPRPROGS) - -all: $(ALLPROGS) - -purify: $(PROGS) - make clean; make CC="purify $(CC)" - -search: search.o - $(CC) -o search search.o $(LIBS) - -search.o: examples.h - -csearch: csearch.o - $(CC) -o csearch csearch.o $(LIBS) - -csearch.o: examples.h - -psearch: psearch.o - $(CC) -o psearch psearch.o $(LIBS) - -psearch.o: examples.h - -ssearch: ssearch.o - $(CC) -o ssearch ssearch.o $(SLIBS) - -ssearch.o: examples.h - -ssnoauth: ssnoauth.o - $(CC) -o ssnoauth ssnoauth.o $(SLIBS) - -ssnoauth.o: examples.h - -rdentry: rdentry.o - $(CC) -o rdentry rdentry.o $(LIBS) - -rdentry.o: examples.h - -getattrs: getattrs.o - $(CC) -o getattrs getattrs.o $(LIBS) - -getattrs.o: examples.h - -srvrsort: srvrsort.o - $(CC) -o srvrsort srvrsort.o $(LIBS) - -srvrsort.o: examples.h - -modattrs: modattrs.o - $(CC) -o modattrs modattrs.o $(LIBS) - -modattrs.o: examples.h - -asearch: asearch.o - $(CC) -o asearch asearch.o $(LIBS) - -asearch.o: examples.h - -add: add.o - $(CC) -o add add.o $(LIBS) - -add.o: examples.h - -del: del.o - $(CC) -o del del.o $(LIBS) - -del.o: examples.h - -compare: compare.o - $(CC) -o compare compare.o $(LIBS) - -compare.o: examples.h - -modrdn: modrdn.o - $(CC) -o modrdn modrdn.o $(LIBS) - -modrdn.o: examples.h - -ppolicy: ppolicy.o - $(CC) -o ppolicy ppolicy.o $(LIBS) - -ppolicy.o: examples.h - -getfilt: getfilt.o - $(CC) -o getfilt getfilt.o $(LIBS) - -getfilt.o: examples.h - -crtfilt: crtfilt.o - $(CC) -o crtfilt crtfilt.o $(LIBS) - -crtfilt.o: examples.h - -nsprio: nsprio.o - $(CC) -o nsprio nsprio.o $(LIBS) $(NSPRLIBS) - -nsprio.o: examples.h - -sasl: sasl.o - $(CC) -o $@ $^ $(LIBS) $(NSPRLIBS) - -sasl.o: examples.h - -nsprsasl: nsprsasl.o - $(CC) -o $@ $^ $(LIBS) $(NSPRLIBS) - -nsprsasl.o: examples.h - -saslsearch: saslsearch.o - $(CC) -o $@ $^ $(LIBS) $(NSPRLIBS) - -saslsearch.o: examples.h - -nsprsaslsearch: nsprsaslsearch.o - $(CC) -o $@ $^ $(LIBS) $(NSPRLIBS) - -nsprsaslsearch.o: examples.h - -runall: $(PROGS) - @for i in $(PROGS); do \ - echo "-------------------------------------------------"; \ - echo "Executing $$i example..."; \ - ./$$i; \ - echo "$$i example done."; \ - done - -clean: - /bin/rm -f $(ALLPROGS) *.o a.out core
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/examples/macintosh
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/examples/windows
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/examples/windows/winldap
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/examples/windows/winldap/LDAP16.DEF
Deleted
@@ -1,45 +0,0 @@ -; -; ***** BEGIN LICENSE BLOCK ***** -; Version: MPL 1.1/GPL 2.0/LGPL 2.1 -; -; The contents of this file are subject to the Mozilla Public License Version -; 1.1 (the "License"); you may not use this file except in compliance with -; the License. You may obtain a copy of the License at -; http://www.mozilla.org/MPL/ -; -; Software distributed under the License is distributed on an "AS IS" basis, -; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -; for the specific language governing rights and limitations under the -; License. -; -; The Original Code is Mozilla Communicator client code. -; -; The Initial Developer of the Original Code is -; Netscape Communications Corporation. -; Portions created by the Initial Developer are Copyright (C) 1996-1999 -; the Initial Developer. All Rights Reserved. -; -; Contributor(s): -; -; Alternatively, the contents of this file may be used under the terms of -; either of the GNU General Public License Version 2 or later (the "GPL"), -; or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -; in which case the provisions of the GPL or the LGPL are applicable instead -; of those above. If you wish to allow use of your version of this file only -; under the terms of either the GPL or the LGPL, and not to allow others to -; use your version of this file under the terms of the MPL, indicate your -; decision by deleting the provisions above and replace them with the notice -; and other provisions required by the GPL or the LGPL. If you do not delete -; the provisions above, a recipient may use your version of this file under -; the terms of any one of the MPL, the GPL or the LGPL. -; -; ***** END LICENSE BLOCK ***** - -NAME LDAP16 -EXETYPE WINDOWS -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE MULTIPLE -HEAPSIZE 1024 - -EXPORTS -; ===List your explicitly exported functions here===
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/examples/windows/winldap/LDAP16.MAK
Deleted
@@ -1,223 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla Communicator client code. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1996-1999 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -# Microsoft Visual C++ generated build script - Do not modify - -PROJ = LDAP16 -DEBUG = 0 -PROGTYPE = 0 -CALLER = -ARGS = -DLLS = -D_RCDEFINES = -d_DEBUG -R_RCDEFINES = -dNDEBUG -ORIGIN = MSVC -ORIGIN_VER = 1.00 -PROJPATH = C:\NETSCAPE\LDAPSDK\EXAMPLES\WINDOWS\WINLDAP\ -USEMFC = 1 -CC = cl -CPP = cl -CXX = cl -CCREATEPCHFLAG = -CPPCREATEPCHFLAG = -CUSEPCHFLAG = -CPPUSEPCHFLAG = -FIRSTC = -FIRSTCPP = CONNDLG.CPP -RC = rc -CFLAGS_D_WEXE = /nologo /G3 /W3 /Zi /AL /Od /D "_DEBUG" /D "_AFX_NO_AFXCMN_SUPPORT" /D "_WINDOWS" /FR /GA /Fd"LDAP16.PDB" -CFLAGS_R_WEXE = /nologo /W3 /AL /O1 /D "NDEBUG" /D "_AFX_NO_AFXCMN_SUPPORT" /D "_WINDOWS" /FR /GA -LFLAGS_D_WEXE = /NOLOGO /NOD /PACKC:61440 /STACK:10240 /ALIGN:16 /ONERROR:NOEXE /CO -LFLAGS_R_WEXE = /NOLOGO /NOD /PACKC:61440 /STACK:10240 /ALIGN:16 /ONERROR:NOEXE -LIBS_D_WEXE = nsldap.lib lafxcwd oldnames libw llibcew commdlg.lib shell.lib -LIBS_R_WEXE = nsldap.lib lafxcw oldnames libw llibcew commdlg.lib shell.lib -RCFLAGS = /nologo -RESFLAGS = /nologo -RUNFLAGS = -DEFFILE = LDAP16.DEF -OBJS_EXT = -LIBS_EXT = -!if "$(DEBUG)" == "1" -CFLAGS = $(CFLAGS_D_WEXE) -LFLAGS = $(LFLAGS_D_WEXE) -LIBS = $(LIBS_D_WEXE) -MAPFILE = nul -RCDEFINES = $(D_RCDEFINES) -!else -CFLAGS = $(CFLAGS_R_WEXE) -LFLAGS = $(LFLAGS_R_WEXE) -LIBS = $(LIBS_R_WEXE) -MAPFILE = nul -RCDEFINES = $(R_RCDEFINES) -!endif -!if [if exist MSVC.BND del MSVC.BND] -!endif -SBRS = CONNDLG.SBR \ - LDAPDOC.SBR \ - LDAPVIEW.SBR \ - MAINFRM.SBR \ - PROPDLG.SBR \ - SRCHDLG.SBR \ - STDAFX.SBR \ - WINLDAP.SBR - - -CONNDLG_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \ - c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \ - c:\netscape\ldapsdk\examples\windows\winldap\conndlg.h - - -LDAPDOC_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \ - c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \ - c:\netscape\ldapsdk\examples\windows\winldap\ldapdoc.h - - -LDAPVIEW_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \ - c:\netscape\ldapsdk\include\ldap.h \ - c:\netscape\ldapsdk\include\lber.h \ - c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \ - c:\netscape\ldapsdk\examples\windows\winldap\ldapdoc.h \ - c:\netscape\ldapsdk\examples\windows\winldap\ldapview.h \ - c:\netscape\ldapsdk\examples\windows\winldap\propdlg.h - - -MAINFRM_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \ - c:\netscape\ldapsdk\include\ldap.h \ - c:\netscape\ldapsdk\include\lber.h \ - c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \ - c:\netscape\ldapsdk\examples\windows\winldap\mainfrm.h - - -PROPDLG_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \ - c:\netscape\ldapsdk\include\ldap.h \ - c:\netscape\ldapsdk\include\lber.h \ - c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \ - c:\netscape\ldapsdk\examples\windows\winldap\propdlg.h - - -SRCHDLG_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \ - c:\netscape\ldapsdk\include\ldap.h \ - c:\netscape\ldapsdk\include\lber.h \ - c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \ - c:\netscape\ldapsdk\examples\windows\winldap\srchdlg.h - - -STDAFX_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h - - -WINLDAP_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \ - c:\netscape\ldapsdk\include\ldap.h \ - c:\netscape\ldapsdk\include\lber.h \ - c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \ - c:\netscape\ldapsdk\examples\windows\winldap\mainfrm.h \ - c:\netscape\ldapsdk\examples\windows\winldap\ldapdoc.h \ - c:\netscape\ldapsdk\examples\windows\winldap\ldapview.h \ - c:\netscape\ldapsdk\examples\windows\winldap\conndlg.h \ - c:\netscape\ldapsdk\examples\windows\winldap\srchdlg.h - - -LDAP16_RCDEP = c:\netscape\ldapsdk\examples\windows\winldap\res\winldap.ico \ - c:\netscape\ldapsdk\examples\windows\winldap\res\winldap.rc2 - - -all: $(PROJ).EXE $(PROJ).BSC - -CONNDLG.OBJ: CONNDLG.CPP $(CONNDLG_DEP) - $(CPP) $(CFLAGS) $(CPPCREATEPCHFLAG) /c CONNDLG.CPP - -LDAPDOC.OBJ: LDAPDOC.CPP $(LDAPDOC_DEP) - $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c LDAPDOC.CPP - -LDAPVIEW.OBJ: LDAPVIEW.CPP $(LDAPVIEW_DEP) - $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c LDAPVIEW.CPP - -MAINFRM.OBJ: MAINFRM.CPP $(MAINFRM_DEP) - $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c MAINFRM.CPP - -PROPDLG.OBJ: PROPDLG.CPP $(PROPDLG_DEP) - $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c PROPDLG.CPP - -SRCHDLG.OBJ: SRCHDLG.CPP $(SRCHDLG_DEP) - $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c SRCHDLG.CPP - -STDAFX.OBJ: STDAFX.CPP $(STDAFX_DEP) - $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c STDAFX.CPP - -WINLDAP.OBJ: WINLDAP.CPP $(WINLDAP_DEP) - $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c WINLDAP.CPP - -LDAP16.RES: LDAP16.RC $(LDAP16_RCDEP) - $(RC) $(RCFLAGS) $(RCDEFINES) -r LDAP16.RC - - -$(PROJ).EXE:: LDAP16.RES - -$(PROJ).EXE:: CONNDLG.OBJ LDAPDOC.OBJ LDAPVIEW.OBJ MAINFRM.OBJ PROPDLG.OBJ SRCHDLG.OBJ \ - STDAFX.OBJ WINLDAP.OBJ $(OBJS_EXT) $(DEFFILE) - echo >NUL @<<$(PROJ).CRF -STDAFX.OBJ + -CONNDLG.OBJ + -LDAPDOC.OBJ + -LDAPVIEW.OBJ + -MAINFRM.OBJ + -PROPDLG.OBJ + -SRCHDLG.OBJ + -WINLDAP.OBJ + -$(OBJS_EXT) -$(PROJ).EXE -$(MAPFILE) -C:\MSVC\LIB\+ -C:\MSVC\MFC\LIB\+ -..\..\..\lib\+ -$(LIBS) -$(DEFFILE); -<< - link $(LFLAGS) @$(PROJ).CRF - $(RC) $(RESFLAGS) LDAP16.RES $@ - @copy $(PROJ).CRF MSVC.BND - -$(PROJ).EXE:: LDAP16.RES - if not exist MSVC.BND $(RC) $(RESFLAGS) LDAP16.RES $@ - -run: $(PROJ).EXE - $(PROJ) $(RUNFLAGS) - - -$(PROJ).BSC: $(SBRS) - bscmake @<< -/o$@ $(SBRS) -<<
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/examples/windows/winldap/LDAP16.RC
Deleted
@@ -1,277 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1996-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -//Microsoft App Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////// -// -// From TEXTINCLUDE 2 -// -#include "afxres.h" - -//////////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -#ifdef APSTUDIO_INVOKED - -//////////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""res\\winldap.rc2"" // non-App Studio edited resources\r\n" - "\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "\0" -END - -///////////////////////////////////////////////////////////////////////// -#endif // APSTUDIO_INVOKED - - -//////////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -IDR_MAINFRAME ICON DISCARDABLE res\winldap.ico - - -//////////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&Connect...\tCtrl+N", ID_FILE_CONNECT - MENUITEM "&Disconnect\tCtrl+D", ID_FILE_DISCONNECT - MENUITEM "&Search...\tCtrl+S", ID_FILE_SEARCH - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Help" - BEGIN - MENUITEM "&About Test16...", ID_APP_ABOUT - END -END - - - -//////////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE -BEGIN - "N", ID_FILE_NEW, VIRTKEY,CONTROL - "O", ID_FILE_OPEN, VIRTKEY,CONTROL - "S", ID_FILE_SAVE, VIRTKEY,CONTROL - "Z", ID_EDIT_UNDO, VIRTKEY,CONTROL - "X", ID_EDIT_CUT, VIRTKEY,CONTROL - "C", ID_EDIT_COPY, VIRTKEY,CONTROL - "V", ID_EDIT_PASTE, VIRTKEY,CONTROL - VK_BACK, ID_EDIT_UNDO, VIRTKEY,ALT - VK_DELETE, ID_EDIT_CUT, VIRTKEY,SHIFT - VK_INSERT, ID_EDIT_COPY, VIRTKEY,CONTROL - VK_INSERT, ID_EDIT_PASTE, VIRTKEY,SHIFT - VK_F6, ID_NEXT_PANE, VIRTKEY - VK_F6, ID_PREV_PANE, VIRTKEY,SHIFT -END - - - - -//////////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOG DISCARDABLE 34, 22, 217, 55 -CAPTION "About Test16" -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -FONT 8, "MS Sans Serif" -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "Test16 Application Version 1.0",IDC_STATIC,40,10,119,8 - LTEXT "Copyright \251 1997",IDC_STATIC,40,25,119,8 - DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP -END - -IDD_CONNECT_DIALOG DIALOG DISCARDABLE 0, 0, 186, 76 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Connect to Directory Server" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,35,55,50,14 - PUSHBUTTON "Cancel",IDCANCEL,103,55,50,14 - RTEXT "Host name:",IDC_STATIC,21,17,52,12 - EDITTEXT IDC_DIR_PORT,79,33,92,14,ES_AUTOHSCROLL - RTEXT "Port number:",IDC_STATIC,28,36,45,12 - EDITTEXT IDC_DIR_HOST,79,14,92,14,ES_AUTOHSCROLL -END - -IDD_SEARCH_DIALOG DIALOG DISCARDABLE 0, 0, 186, 103 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Search parameters" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,39,82,50,14 - PUSHBUTTON "Cancel",IDCANCEL,105,82,50,14 - RTEXT "Directory base:",IDC_STATIC,7,16,54,12 - EDITTEXT IDC_SEARCH_BASE,65,13,106,14,ES_AUTOHSCROLL - RTEXT "Search filter:",IDC_STATIC,10,34,51,12 - EDITTEXT IDC_SEARCH_FILTER,65,31,105,14,ES_AUTOHSCROLL - CONTROL "Base",IDC_SCOPE_BASE,"Button",BS_AUTORADIOBUTTON,23,60, - 32,10 - CONTROL "One level",IDC_SCOPE_ONE,"Button",BS_AUTORADIOBUTTON,69, - 60,46,10 - CONTROL "Subtree",IDC_SCOPE_SUB,"Button",BS_AUTORADIOBUTTON,121, - 60,41,10 - GROUPBOX "Scope",IDC_STATIC,13,49,159,24 -END - -IDD_ENTRY_PROPERTIES DIALOG DISCARDABLE 0, 0, 273, 202 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Properties" -FONT 8, "MS Sans Serif" -BEGIN -END - - -//////////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "winldap\n\nWinlda\n\n\nWinldap.Document\nWinlda Document" -END -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "Test16 Windows Application" - AFX_IDS_IDLEMESSAGE "Ready" -END -STRINGTABLE DISCARDABLE -BEGIN - ID_INDICATOR_EXT "EXT" - ID_INDICATOR_CAPS "CAP" - ID_INDICATOR_NUM "NUM" - ID_INDICATOR_SCRL "SCRL" - ID_INDICATOR_OVR "OVR" - ID_INDICATOR_REC "REC" -END -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_NEW "Create a new document" - ID_FILE_OPEN "Open an existing document" - ID_FILE_CLOSE "Close the active document" - ID_FILE_SAVE "Save the active document" - ID_FILE_SAVE_AS "Save the active document with a new name" - ID_APP_ABOUT "Display program information, version number and copyright" - ID_APP_EXIT "Quit the application; prompts to save documents" - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_NEXT_PANE "Switch to the next window pane" - ID_PREV_PANE "Switch back to the previous window pane" - ID_EDIT_CLEAR "Erase the selection" - ID_EDIT_CLEAR_ALL "Erase everything" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard" - ID_EDIT_FIND "Find the specified text" - ID_EDIT_PASTE "Insert Clipboard contents" - ID_EDIT_REPEAT "Repeat the last action" - ID_EDIT_REPLACE "Replace specific text with different text" - ID_EDIT_SELECT_ALL "Select the entire document" - ID_EDIT_UNDO "Undo the last action" - ID_EDIT_REDO "Redo the previously undone action" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_CONNECT "Connect to Directory Server" - ID_FILE_DISCONNECT "Disconnect from Directory Server" - ID_FILE_SEARCH "Search in Directory" -END - - -#ifndef APSTUDIO_INVOKED -//////////////////////////////////////////////////////////////////////////////// -// -// From TEXTINCLUDE 3 -// - -#include "res\winldap.rc2" // non-App Studio edited resources - -#include "afxres.rc" // Standard components - -//////////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/examples/windows/winldap/res
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/include
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/include/ldap-extension.h
Deleted
@@ -1,851 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* ldap-extension.h - extensions to the ldap c api specification */ - -#ifndef _LDAP_EXTENSION_H -#define _LDAP_EXTENSION_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define LDAP_PORT_MAX 65535 /* API extension */ -#define LDAP_VERSION1 1 /* API extension */ -#define LDAP_VERSION LDAP_VERSION3 /* API extension */ - -/* - * C LDAP features we support that are not (yet) part of the LDAP C API - * Internet Draft. Use the ldap_get_option() call with an option value of - * LDAP_OPT_API_FEATURE_INFO to retrieve information about a feature. - * - * Note that this list is incomplete; it includes only the most widely - * used extensions. Also, the version is 1 for all of these for now. - */ -#define LDAP_API_FEATURE_SERVER_SIDE_SORT 1 -#define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 1 -#define LDAP_API_FEATURE_PERSISTENT_SEARCH 1 -#define LDAP_API_FEATURE_PROXY_AUTHORIZATION 1 -#define LDAP_API_FEATURE_X_LDERRNO 1 -#define LDAP_API_FEATURE_X_MEMCACHE 1 -#define LDAP_API_FEATURE_X_IO_FUNCTIONS 1 -#define LDAP_API_FEATURE_X_EXTIO_FUNCTIONS 1 -#define LDAP_API_FEATURE_X_DNS_FUNCTIONS 1 -#define LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS 1 -#define LDAP_API_FEATURE_X_THREAD_FUNCTIONS 1 -#define LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS 1 -#define LDAP_API_FEATURE_X_GETLANGVALUES 1 -#define LDAP_API_FEATURE_X_CLIENT_SIDE_SORT 1 -#define LDAP_API_FEATURE_X_URL_FUNCTIONS 1 -#define LDAP_API_FEATURE_X_FILTER_FUNCTIONS 1 - -#define LDAP_ROOT_DSE "" /* API extension */ - -#define LDAP_OPT_DESC 0x01 /* 1 */ - -#define NULLMSG ((LDAPMessage *)0) - -/*built-in SASL methods */ -#define LDAP_SASL_EXTERNAL "EXTERNAL" /* TLS/SSL extension */ - -/* possible error codes we can be returned */ -#define LDAP_PARTIAL_RESULTS 0x09 /* 9 (UMich LDAPv2 extn) */ -#define NAME_ERROR(n) ((n & 0xf0) == 0x20) - -#define LDAP_SORT_CONTROL_MISSING 0x3C /* 60 (server side sort extn) */ -#define LDAP_INDEX_RANGE_ERROR 0x3D /* 61 (VLV extn) */ - -/* - * LDAPv3 server controls we know about - */ -#define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2" -#define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473" -#define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474" -#define LDAP_CONTROL_PERSISTENTSEARCH "2.16.840.1.113730.3.4.3" -#define LDAP_CONTROL_ENTRYCHANGE "2.16.840.1.113730.3.4.7" -#define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9" -#define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10" -#define LDAP_CONTROL_PROXYAUTH "2.16.840.1.113730.3.4.12" /* version 1 -*/ -#define LDAP_CONTROL_PROXIEDAUTH "2.16.840.1.113730.3.4.18" /* version 2 -*/ - -/* Authorization Identity Request and Response Controls */ -#define LDAP_CONTROL_AUTHZID_REQ "2.16.840.1.113730.3.4.16" -#define LDAP_CONTROL_AUTHZID_RES "2.16.840.1.113730.3.4.15" - -/* Authentication request and response controls */ -#define LDAP_CONTROL_AUTH_REQUEST LDAP_CONTROL_AUTHZID_REQ -#define LDAP_CONTROL_AUTH_RESPONSE LDAP_CONTROL_AUTHZID_RES - -/* Password information sent back to client */ -#define LDAP_CONTROL_PWEXPIRED "2.16.840.1.113730.3.4.4" -#define LDAP_CONTROL_PWEXPIRING "2.16.840.1.113730.3.4.5" - -/* Password Policy Control */ -#define LDAP_CONTROL_PASSWD_POLICY "1.3.6.1.4.1.42.2.27.8.5.1" - -/* Password Policy Control compatibility macros */ -#define LDAP_X_CONTROL_PWPOLICY_REQUEST LDAP_CONTROL_PASSWD_POLICY -#define LDAP_X_CONTROL_PWPOLICY_RESPONSE LDAP_CONTROL_PASSWD_POLICY -#define LDAP_CONTROL_PASSWORDPOLICYREQUEST LDAP_CONTROL_PASSWD_POLICY -#define LDAP_CONTROL_PASSWORDPOLICYRESPONSE LDAP_CONTROL_PASSWD_POLICY - -/* Password Modify Extended Operation */ -#define LDAP_EXOP_MODIFY_PASSWD "1.3.6.1.4.1.4203.1.11.1" - -/* Suppress virtual/inherited attribute values */ -#define LDAP_CONTROL_REAL_ATTRS_ONLY "2.16.840.1.113730.3.4.17" - -/* Only return virtual/inherited attribute values */ -#define LDAP_CONTROL_VIRTUAL_ATTRS_ONLY "2.16.840.1.113730.3.4.19" - -/* getEffectiveRights request */ -#define LDAP_CONTROL_GETEFFECTIVERIGHTS_REQUEST "1.3.6.1.4.1.42.2.27.9.5.2" - -/* Password Policy Control to get account availability */ -#define LDAP_CONTROL_ACCOUNT_USABLE "1.3.6.1.4.1.42.2.27.9.5.8" - -/* "Who am I?" Extended Operation */ -#define LDAP_EXOP_WHO_AM_I "1.3.6.1.4.1.4203.1.11.3" - -LDAP_API(void) LDAP_CALL ldap_ber_free( BerElement *ber, int freebuf ); - -LDAP_API(LDAPControl *) LDAP_CALL ldap_find_control( const char *oid, - LDAPControl **ctrls ); - -/* - * Server side sorting of search results (an LDAPv3 extension -- - * LDAP_API_FEATURE_SERVER_SIDE_SORT) - */ -typedef struct LDAPsortkey { /* structure for a sort-key */ - char * sk_attrtype; - char * sk_matchruleoid; - int sk_reverseorder; -} LDAPsortkey; - -/* where LDAP_CONTROL_ACCOUNT_USABLE control parse results */ -typedef struct LDAPuserstatus { /* user account availability */ - unsigned int us_available; /* availability status */ -#define LDAP_US_ACCOUNT_USABLE 1 -#define LDAP_US_ACCOUNT_NOT_USABLE 0 - int us_expire; /* will expire in seconds */ - int us_inactive; /* boolean inactivation status */ -#define LDAP_US_ACCOUNT_ACTIVE 0 -#define LDAP_US_ACCOUNT_INACTIVE 1 - int us_reset; /* boolean password reset */ -#define LDAP_US_ACCOUNT_NOT_RESET 0 -#define LDAP_US_ACCOUNT_RESET 1 - int us_expired; /* boolean password expired */ -#define LDAP_US_ACCOUNT_NOT_EXPIRED 0 -#define LDAP_US_ACCOUNT_EXPIRED 1 - int us_remaining; /* remaining logins */ - int us_seconds; /* will unlock in seconds */ -} LDAPuserstatus; - -/* LDAP_CONTROL_PASSWD_POLICY results */ -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_API(int) LDAP_CALL ldap_create_sort_control( LDAP *ld, - LDAPsortkey **sortKeyList, const char ctl_iscritical, - LDAPControl **ctrlp ); -LDAP_API(int) LDAP_CALL ldap_parse_sort_control( LDAP *ld, - LDAPControl **ctrls, ber_int_t *result, char **attribute ); - -LDAP_API(void) LDAP_CALL ldap_free_sort_keylist( LDAPsortkey **sortKeyList ); -LDAP_API(int) LDAP_CALL ldap_create_sort_keylist( LDAPsortkey ***sortKeyList, - const char *string_rep ); - -LDAP_API(int) LDAP_CALL ldap_create_userstatus_control( - LDAP *ld, const char ctl_iscritical, LDAPControl **ctrlp ); -LDAP_API(int) LDAP_CALL ldap_parse_userstatus_control( LDAP *ld, - LDAPControl **ctrlp, LDAPuserstatus *us ); - -LDAP_API(int) LDAP_CALL ldap_create_passwordpolicy_control( LDAP *ld, - LDAPControl **ctrlp ); -LDAP_API(int) LDAP_CALL ldap_create_passwordpolicy_control_ext( LDAP *ld, - const char ctl_iscritical, LDAPControl **ctrlp ); -LDAP_API(int) LDAP_CALL ldap_parse_passwordpolicy_control( LDAP *ld, - LDAPControl *ctrlp, ber_int_t *expirep, ber_int_t *gracep, - LDAPPasswordPolicyError *errorp ); -LDAP_API(int) LDAP_CALL ldap_parse_passwordpolicy_control_ext ( LDAP *ld, - LDAPControl **ctrlp, ber_int_t *expirep, ber_int_t *gracep, - LDAPPasswordPolicyError *errorp ); -LDAP_API(const char *) LDAP_CALL ldap_passwordpolicy_err2txt( - LDAPPasswordPolicyError err ); - -LDAP_API(int) LDAP_CALL ldap_create_authzid_control( LDAP *ld, - const char ctl_iscritical, LDAPControl **ctrlp ); -LDAP_API(int) LDAP_CALL ldap_parse_authzid_control( LDAP *ld, - LDAPControl **ctrlp, char **authzid ); - -LDAP_API(int) LDAP_CALL ldap_whoami( LDAP *ld, LDAPControl **serverctrls, - LDAPControl **clientctrls, int *msgidp ); -LDAP_API(int) LDAP_CALL ldap_whoami_s( LDAP *ld, struct berval **authzid, - LDAPControl **serverctrls, LDAPControl **clientctrls ); -LDAP_API(int) LDAP_CALL ldap_parse_whoami( LDAP *ld, LDAPMessage *result, - struct berval **authzid ); - -LDAP_API(int) LDAP_CALL ldap_create_geteffectiveRights_control( LDAP *ld, - const char *authzid, const char **attrlist, const char ctl_iscritical, - LDAPControl **ctrlp ); - -/* - * Virtual list view (an LDAPv3 extension -- LDAP_API_FEATURE_VIRTUAL_LIST_VIEW) - */ -/* - * structure that describes a VirtualListViewRequest control. - * note that ldvlist_index and ldvlist_size are only relevant to - * ldap_create_virtuallist_control() if ldvlist_attrvalue is NULL. - */ -typedef struct ldapvirtuallist { - ber_int_t ldvlist_before_count; /* # entries before target */ - ber_int_t ldvlist_after_count; /* # entries after target */ - char *ldvlist_attrvalue; /* jump to this value */ - ber_int_t ldvlist_index; /* list offset */ - ber_int_t ldvlist_size; /* number of items in vlist */ - void *ldvlist_extradata; /* for use by application */ -} LDAPVirtualList; - -/* - * VLV functions: - */ -LDAP_API(int) LDAP_CALL ldap_create_virtuallist_control( LDAP *ld, - LDAPVirtualList *ldvlistp, LDAPControl **ctrlp ); - -LDAP_API(int) LDAP_CALL ldap_parse_virtuallist_control( LDAP *ld, - LDAPControl **ctrls, ber_int_t *target_posp, - ber_int_t *list_sizep, int *errcodep ); - -/* - * Routines for creating persistent search controls and for handling - * "entry changed notification" controls (an LDAPv3 extension -- - * LDAP_API_FEATURE_PERSISTENT_SEARCH) - */ -#define LDAP_CHANGETYPE_ADD 1 -#define LDAP_CHANGETYPE_DELETE 2 -#define LDAP_CHANGETYPE_MODIFY 4 -#define LDAP_CHANGETYPE_MODDN 8 -#define LDAP_CHANGETYPE_ANY (1|2|4|8) -LDAP_API(int) LDAP_CALL ldap_create_persistentsearch_control( LDAP *ld, - int changetypes, int changesonly, int return_echg_ctls, - char ctl_iscritical, LDAPControl **ctrlp ); -LDAP_API(int) LDAP_CALL ldap_parse_entrychange_control( LDAP *ld, - LDAPControl **ctrls, ber_int_t *chgtypep, char **prevdnp, - int *chgnumpresentp, ber_int_t *chgnump ); - -/* - * Routines for creating Proxied Authorization controls (an LDAPv3 - * extension -- LDAP_API_FEATURE_PROXY_AUTHORIZATION) - * ldap_create_proxyauth_control() is for the old (version 1) control. - * ldap_create_proxiedauth_control() is for the newer (version 2) control. - */ -LDAP_API(int) LDAP_CALL ldap_create_proxyauth_control( LDAP *ld, - const char *dn, const char ctl_iscritical, LDAPControl **ctrlp ); -LDAP_API(int) LDAP_CALL ldap_create_proxiedauth_control( LDAP *ld, - const char *authzid, LDAPControl **ctrlp ); - -/* - * Functions to get and set LDAP error information (API extension -- - * LDAP_API_FEATURE_X_LDERRNO ) - * - * By using LDAP_OPT_THREAD_FN_PTRS, you can arrange for the error info. to - * be thread-specific. - */ -LDAP_API(int) LDAP_CALL ldap_get_lderrno( LDAP *ld, char **m, char **s ); -LDAP_API(int) LDAP_CALL ldap_set_lderrno( LDAP *ld, int e, char *m, char *s ); - - -/* - * LDAP URL functions and definitions (an API extension -- - * LDAP_API_FEATURE_X_URL_FUNCTIONS) - */ -/* - * types for ldap URL handling - */ -typedef struct ldap_url_desc { - char *lud_host; - int lud_port; - char *lud_dn; - char **lud_attrs; - int lud_scope; - char *lud_filter; - unsigned long lud_options; -#define LDAP_URL_OPT_SECURE 0x01 - char *lud_string; /* for internal use only */ -} LDAPURLDesc; - -#define NULLLDAPURLDESC ((LDAPURLDesc *)NULL) - -/* - * possible errors returned by ldap_url_parse() - */ -#define LDAP_URL_ERR_NOTLDAP 1 /* URL doesn't begin with "ldap://" */ -#define LDAP_URL_ERR_NODN 2 /* URL has no DN (required) */ -#define LDAP_URL_ERR_BADSCOPE 3 /* URL scope string is invalid */ -#define LDAP_URL_ERR_MEM 4 /* can't allocate memory space */ -#define LDAP_URL_ERR_PARAM 5 /* bad parameter to an URL function */ -#define LDAP_URL_UNRECOGNIZED_CRITICAL_EXTENSION 6 - -/* - * URL functions: - */ -LDAP_API(int) LDAP_CALL ldap_is_ldap_url( const char *url ); -LDAP_API(int) LDAP_CALL ldap_url_parse( const char *url, LDAPURLDesc **ludpp ); -LDAP_API(int) LDAP_CALL ldap_url_parse_no_defaults( const char *url, - LDAPURLDesc **ludpp, int dn_required); -LDAP_API(void) LDAP_CALL ldap_free_urldesc( LDAPURLDesc *ludp ); -LDAP_API(int) LDAP_CALL ldap_url_search( LDAP *ld, const char *url, - int attrsonly ); -LDAP_API(int) LDAP_CALL ldap_url_search_s( LDAP *ld, const char *url, - int attrsonly, LDAPMessage **res ); -LDAP_API(int) LDAP_CALL ldap_url_search_st( LDAP *ld, const char *url, - int attrsonly, struct timeval *timeout, LDAPMessage **res ); - - -/* - * Function to dispose of an array of LDAPMod structures (an API extension). - * Warning: don't use this unless the mods array was allocated using the - * same memory allocator as is being used by libldap. - */ -LDAP_API(void) LDAP_CALL ldap_mods_free( LDAPMod **mods, int freemods ); - -/* - * SSL option (an API extension): - */ -#define LDAP_OPT_SSL 0x0A /* 10 - API extension */ - -/* - * Referral hop limit (an API extension): - */ -#define LDAP_OPT_REFERRAL_HOP_LIMIT 0x10 /* 16 - API extension */ - -/* - * Rebind callback function (an API extension) - */ -#define LDAP_OPT_REBIND_FN 0x06 /* 6 - API extension */ -#define LDAP_OPT_REBIND_ARG 0x07 /* 7 - API extension */ -typedef int (LDAP_CALL LDAP_CALLBACK LDAP_REBINDPROC_CALLBACK)( LDAP *ld, - char **dnp, char **passwdp, int *authmethodp, int freeit, void *arg); -LDAP_API(void) LDAP_CALL ldap_set_rebind_proc( LDAP *ld, - LDAP_REBINDPROC_CALLBACK *rebindproc, void *arg ); - -/* - * Thread function callbacks (an API extension -- - * LDAP_API_FEATURE_X_THREAD_FUNCTIONS). - */ -#define LDAP_OPT_THREAD_FN_PTRS 0x05 /* 5 - API extension */ - -/* - * Thread callback functions: - */ -typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_ALLOC_CALLBACK)( void ); -typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_FREE_CALLBACK)( void *m ); -typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_LOCK_CALLBACK)( void *m ); -typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_UNLOCK_CALLBACK)( void *m ); -typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_ERRNO_CALLBACK)( void ); -typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_ERRNO_CALLBACK)( int e ); -typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_LDERRNO_CALLBACK)( - char **matchedp, char **errmsgp, void *arg ); -typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_LDERRNO_CALLBACK)( int err, - char *matched, char *errmsg, void *arg ); - -/* - * Structure to hold thread function pointers: - */ -struct ldap_thread_fns { - LDAP_TF_MUTEX_ALLOC_CALLBACK *ltf_mutex_alloc; - LDAP_TF_MUTEX_FREE_CALLBACK *ltf_mutex_free; - LDAP_TF_MUTEX_LOCK_CALLBACK *ltf_mutex_lock; - LDAP_TF_MUTEX_UNLOCK_CALLBACK *ltf_mutex_unlock; - LDAP_TF_GET_ERRNO_CALLBACK *ltf_get_errno; - LDAP_TF_SET_ERRNO_CALLBACK *ltf_set_errno; - LDAP_TF_GET_LDERRNO_CALLBACK *ltf_get_lderrno; - LDAP_TF_SET_LDERRNO_CALLBACK *ltf_set_lderrno; - void *ltf_lderrno_arg; -}; - -/* - * Extended I/O function callbacks option (an API extension -- - * LDAP_API_FEATURE_X_EXTIO_FUNCTIONS). - */ -#define LDAP_X_OPT_EXTIO_FN_PTRS (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F00) - /* 0x4000 + 0x0F00 = 0x4F00 = 20224 - API extension */ - -/* Additional Extended I/O function callback option (for Extended Socket Arg callback) */ -#define LDAP_X_OPT_SOCKETARG (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F02) - /* 0x4000 + 0x0F02 = 0x4F02 = 20226 - API extension */ - -/* - * These extended I/O function callbacks echo the BSD socket API but accept - * an extra pointer parameter at the end of their argument list that can - * be used by client applications for their own needs. For some of the calls, - * the pointer is a session argument of type struct lextiof_session_private * - * that is associated with the LDAP session handle (LDAP *). For others, the - * pointer is a socket specific struct lextiof_socket_private * argument that - * is associated with a particular socket (a TCP connection). - * - * The lextiof_session_private and lextiof_socket_private structures are not - * defined by the LDAP C API; users of this extended I/O interface should - * define these themselves. - * - * The combination of the integer socket number (i.e., lpoll_fd, which is - * the value returned by the CONNECT callback) and the application specific - * socket argument (i.e., lpoll_socketarg, which is the value set in *sockargpp - * by the CONNECT callback) must be unique. - * - * The types for the extended READ and WRITE callbacks are actually in lber.h. - * - * The CONNECT callback gets passed both the session argument (sessionarg) - * and a pointer to a socket argument (socketargp) so it has the - * opportunity to set the socket-specific argument. The CONNECT callback - * also takes a timeout parameter whose value can be set by calling - * ldap_set_option( ld, LDAP_X_OPT_..., &val ). The units used for the - * timeout parameter are milliseconds. - * - * A POLL interface is provided instead of a select() one. The timeout is - * in milliseconds. - * - * A NEWHANDLE callback function is also provided. It is called right - * after the LDAP session handle is created, e.g., during ldap_init(). - * If the NEWHANDLE callback returns anything other than LDAP_SUCCESS, - * the session handle allocation fails. - * - * A DISPOSEHANDLE callback function is also provided. It is called right - * before the LDAP session handle and its contents are destroyed, e.g., - * during ldap_unbind(). - */ - -/* - * Special timeout values for poll and connect: - */ -#define LDAP_X_IO_TIMEOUT_NO_WAIT 0 /* return immediately */ -#define LDAP_X_IO_TIMEOUT_NO_TIMEOUT (-1) /* block indefinitely */ - -/* LDAP poll()-like descriptor: - */ -typedef struct ldap_x_pollfd { /* used by LDAP_X_EXTIOF_POLL_CALLBACK */ - int lpoll_fd; /* integer file descriptor / socket */ - struct lextiof_socket_private - *lpoll_socketarg; - /* pointer socket and for use by */ - /* application */ - short lpoll_events; /* requested event */ - short lpoll_revents; /* returned event */ -} LDAP_X_PollFD; - -/* Event flags for lpoll_events and lpoll_revents: - */ -#define LDAP_X_POLLIN 0x01 /* regular data ready for reading */ -#define LDAP_X_POLLPRI 0x02 /* high priority data available */ -#define LDAP_X_POLLOUT 0x04 /* ready for writing */ -#define LDAP_X_POLLERR 0x08 /* error occurred -- only in lpoll_revents */ -#define LDAP_X_POLLHUP 0x10 /* connection closed -- only in lpoll_revents */ -#define LDAP_X_POLLNVAL 0x20 /* invalid lpoll_fd -- only in lpoll_revents */ - -/* Options passed to LDAP_X_EXTIOF_CONNECT_CALLBACK to modify socket behavior: - */ -#define LDAP_X_EXTIOF_OPT_NONBLOCKING 0x01 /* turn on non-blocking mode */ -#define LDAP_X_EXTIOF_OPT_SECURE 0x02 /* turn on 'secure' mode */ - - -/* extended I/O callback function prototypes: - */ -typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CONNECT_CALLBACK )( - const char *hostlist, int port, /* host byte order */ - int timeout /* milliseconds */, - unsigned long options, /* bitmapped options */ - struct lextiof_session_private *sessionarg, - struct lextiof_socket_private **socketargp ); -typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CLOSE_CALLBACK )( - int s, struct lextiof_socket_private *socketarg ); -typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_POLL_CALLBACK)( - LDAP_X_PollFD fds[], int nfds, int timeout /* milliseconds */, - struct lextiof_session_private *sessionarg ); -typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_NEWHANDLE_CALLBACK)( - LDAP *ld, struct lextiof_session_private *sessionarg ); -typedef void (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK)( - LDAP *ld, struct lextiof_session_private *sessionarg ); - - -/* Structure to hold extended I/O function pointers: - */ -struct ldap_x_ext_io_fns { - /* lextiof_size should always be set to LDAP_X_EXTIO_FNS_SIZE */ - int lextiof_size; - LDAP_X_EXTIOF_CONNECT_CALLBACK *lextiof_connect; - LDAP_X_EXTIOF_CLOSE_CALLBACK *lextiof_close; - LDAP_X_EXTIOF_READ_CALLBACK *lextiof_read; - LDAP_X_EXTIOF_WRITE_CALLBACK *lextiof_write; - LDAP_X_EXTIOF_POLL_CALLBACK *lextiof_poll; - LDAP_X_EXTIOF_NEWHANDLE_CALLBACK *lextiof_newhandle; - LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK *lextiof_disposehandle; - void *lextiof_session_arg; - LDAP_X_EXTIOF_WRITEV_CALLBACK *lextiof_writev; -}; -#define LDAP_X_EXTIO_FNS_SIZE sizeof(struct ldap_x_ext_io_fns) - -/* - * Utility functions for parsing space-separated host lists (useful for - * implementing an extended I/O CONNECT callback function). - */ -struct ldap_x_hostlist_status; -LDAP_API(int) LDAP_CALL ldap_x_hostlist_first( const char *hostlist, - int defport, char **hostp, int *portp /* host byte order */, - struct ldap_x_hostlist_status **statusp ); -LDAP_API(int) LDAP_CALL ldap_x_hostlist_next( char **hostp, - int *portp /* host byte order */, struct ldap_x_hostlist_status *status -); -LDAP_API(void) LDAP_CALL ldap_x_hostlist_statusfree( - struct ldap_x_hostlist_status *status ); - -/* - * Client side sorting of entries (an API extension -- - * LDAP_API_FEATURE_X_CLIENT_SIDE_SORT) - */ -/* - * Client side sorting callback functions: - */ -typedef const struct berval* (LDAP_C LDAP_CALLBACK - LDAP_KEYGEN_CALLBACK)( void *arg, LDAP *ld, LDAPMessage *entry ); -typedef int (LDAP_C LDAP_CALLBACK - LDAP_KEYCMP_CALLBACK)( void *arg, const struct berval*, - const struct berval* ); -typedef void (LDAP_C LDAP_CALLBACK - LDAP_KEYFREE_CALLBACK)( void *arg, const struct berval* ); -typedef int (LDAP_C LDAP_CALLBACK - LDAP_CMP_CALLBACK)(const char *val1, const char *val2); -typedef int (LDAP_C LDAP_CALLBACK - LDAP_VALCMP_CALLBACK)(const char **val1p, const char **val2p); - -/* - * Client side sorting functions: - */ -LDAP_API(int) LDAP_CALL ldap_keysort_entries( LDAP *ld, LDAPMessage **chain, - void *arg, LDAP_KEYGEN_CALLBACK *gen, LDAP_KEYCMP_CALLBACK *cmp, - LDAP_KEYFREE_CALLBACK *fre ); -LDAP_API(int) LDAP_CALL ldap_multisort_entries( LDAP *ld, LDAPMessage **chain, - char **attr, LDAP_CMP_CALLBACK *cmp ); -LDAP_API(int) LDAP_CALL ldap_sort_entries( LDAP *ld, LDAPMessage **chain, - char *attr, LDAP_CMP_CALLBACK *cmp ); -LDAP_API(int) LDAP_CALL ldap_sort_values( LDAP *ld, char **vals, - LDAP_VALCMP_CALLBACK *cmp ); -LDAP_API(int) LDAP_C LDAP_CALLBACK ldap_sort_strcasecmp( const char **a, - const char **b ); - - -/* - * Filter functions and definitions (an API extension -- - * LDAP_API_FEATURE_X_FILTER_FUNCTIONS) - */ -/* - * Structures, constants, and types for filter utility routines: - */ -typedef struct ldap_filt_info { - char *lfi_filter; - char *lfi_desc; - int lfi_scope; /* LDAP_SCOPE_BASE, etc */ - int lfi_isexact; /* exact match filter? */ - struct ldap_filt_info *lfi_next; -} LDAPFiltInfo; - -#define LDAP_FILT_MAXSIZ 1024 - -typedef struct ldap_filt_list LDAPFiltList; /* opaque filter list handle */ -typedef struct ldap_filt_desc LDAPFiltDesc; /* opaque filter desc handle */ - -/* - * Filter utility functions: - */ -LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter( char *fname ); -LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter_buf( char *buf, - long buflen ); -LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getfirstfilter( LDAPFiltDesc *lfdp, - char *tagpat, char *value ); -LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getnextfilter( LDAPFiltDesc *lfdp ); -LDAP_API(int) LDAP_CALL ldap_set_filter_additions( LDAPFiltDesc *lfdp, - char *prefix, char *suffix ); -LDAP_API(int) LDAP_CALL ldap_create_filter( char *buf, unsigned long buflen, - char *pattern, char *prefix, char *suffix, char *attr, - char *value, char **valwords ); -LDAP_API(void) LDAP_CALL ldap_getfilter_free( LDAPFiltDesc *lfdp ); - -/* - * Friendly mapping structure and routines (an API extension) - */ -typedef struct friendly { - char *f_unfriendly; - char *f_friendly; -} *FriendlyMap; -LDAP_API(char *) LDAP_CALL ldap_friendly_name( char *filename, char *name, - FriendlyMap *map ); -LDAP_API(void) LDAP_CALL ldap_free_friendlymap( FriendlyMap *map ); - -/* - * In Memory Cache (an API extension -- LDAP_API_FEATURE_X_MEMCACHE) - */ -typedef struct ldapmemcache LDAPMemCache; /* opaque in-memory cache handle */ - -LDAP_API(int) LDAP_CALL ldap_memcache_init( unsigned long ttl, - unsigned long size, char **baseDNs, struct ldap_thread_fns *thread_fns, - LDAPMemCache **cachep ); -LDAP_API(int) LDAP_CALL ldap_memcache_set( LDAP *ld, LDAPMemCache *cache ); -LDAP_API(int) LDAP_CALL ldap_memcache_get( LDAP *ld, LDAPMemCache **cachep ); -LDAP_API(void) LDAP_CALL ldap_memcache_flush( LDAPMemCache *cache, char *dn, - int scope ); -LDAP_API(void) LDAP_CALL ldap_memcache_destroy( LDAPMemCache *cache ); -LDAP_API(void) LDAP_CALL ldap_memcache_update( LDAPMemCache *cache ); - -/* - * Timeout value for nonblocking connect call - */ -#define LDAP_X_OPT_CONNECT_TIMEOUT (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F01) - /* 0x4000 + 0x0F01 = 0x4F01 = 20225 - API extension */ - -/* - * Socket buffer structure associated to the LDAP connection - */ -#define LDAP_X_OPT_SOCKBUF (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F03) - /* 0x4000 + 0x0F03 = 0x4F03 = 20227 - API extension */ - -/* - * Memory allocation callback functions (an API extension -- - * LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS). These are global and can - * not be set on a per-LDAP session handle basis. Install your own - * functions by making a call like this: - * ldap_set_option( NULL, LDAP_OPT_MEMALLOC_FN_PTRS, &memalloc_fns ); - * - * look in lber.h for the function typedefs themselves. - */ -#define LDAP_OPT_MEMALLOC_FN_PTRS 0x61 /* 97 - API extension */ - -struct ldap_memalloc_fns { - LDAP_MALLOC_CALLBACK *ldapmem_malloc; - LDAP_CALLOC_CALLBACK *ldapmem_calloc; - LDAP_REALLOC_CALLBACK *ldapmem_realloc; - LDAP_FREE_CALLBACK *ldapmem_free; -}; - - -/* - * Memory allocation functions (an API extension) - */ -void *ldap_x_malloc( size_t size ); -void *ldap_x_calloc( size_t nelem, size_t elsize ); -void *ldap_x_realloc( void *ptr, size_t size ); -void ldap_x_free( void *ptr ); - -/* - * Server reconnect (an API extension). - */ -#define LDAP_OPT_RECONNECT 0x62 /* 98 - API extension */ - - -/* - * Extra thread callback functions (an API extension -- - * LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS) - */ -#define LDAP_OPT_EXTRA_THREAD_FN_PTRS 0x65 /* 101 - API extension */ - -/* - * When bind is called, don't bind if there's a connection open with the same DN - */ -#define LDAP_OPT_NOREBIND 0x66 /* 102 - API extension */ - -typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_TRYLOCK_CALLBACK)( void *m ); -typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_ALLOC_CALLBACK)( void ); -typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_FREE_CALLBACK)( void *s ); -typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_WAIT_CALLBACK)( void *s ); -typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_POST_CALLBACK)( void *s ); -typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_THREADID_CALLBACK)(void); - -struct ldap_extra_thread_fns { - LDAP_TF_MUTEX_TRYLOCK_CALLBACK *ltf_mutex_trylock; - LDAP_TF_SEMA_ALLOC_CALLBACK *ltf_sema_alloc; - LDAP_TF_SEMA_FREE_CALLBACK *ltf_sema_free; - LDAP_TF_SEMA_WAIT_CALLBACK *ltf_sema_wait; - LDAP_TF_SEMA_POST_CALLBACK *ltf_sema_post; - LDAP_TF_THREADID_CALLBACK *ltf_threadid_fn; -}; - -/* - * Debugging level (an API extension) - */ -#define LDAP_OPT_DEBUG_LEVEL 0x6E /* 110 - API extension */ -/* On UNIX, there's only one copy of ldap_debug */ -/* On NT, each dll keeps its own module_ldap_debug, which */ -/* points to the process' ldap_debug and needs initializing after load */ -#ifdef _WIN32 -extern int *module_ldap_debug; -typedef void (*set_debug_level_fn_t)(int*); -#endif - -#ifdef LDAP_DNS -#define LDAP_OPT_DNS 0x0C /* 12 - API extension */ -#endif - -/* - * UTF-8 routines (should these move into libnls?) - */ -/* number of bytes in character */ -LDAP_API(int) LDAP_CALL ldap_utf8len( const char* ); -/* find next character */ -LDAP_API(char*) LDAP_CALL ldap_utf8next( char* ); -/* find previous character */ -LDAP_API(char*) LDAP_CALL ldap_utf8prev( char* ); -/* copy one character */ -LDAP_API(int) LDAP_CALL ldap_utf8copy( char* dst, const char* src ); -/* total number of characters */ -LDAP_API(size_t) LDAP_CALL ldap_utf8characters( const char* ); -/* get one UCS-4 character, and move *src to the next character */ -LDAP_API(unsigned long) LDAP_CALL ldap_utf8getcc( const char** src ); -/* UTF-8 aware strtok_r() */ -LDAP_API(char*) LDAP_CALL ldap_utf8strtok_r( char* src, const char* brk, char** -next); - -/* like isalnum(*s) in the C locale */ -LDAP_API(int) LDAP_CALL ldap_utf8isalnum( char* s ); -/* like isalpha(*s) in the C locale */ -LDAP_API(int) LDAP_CALL ldap_utf8isalpha( char* s ); -/* like isdigit(*s) in the C locale */ -LDAP_API(int) LDAP_CALL ldap_utf8isdigit( char* s ); -/* like isxdigit(*s) in the C locale */ -LDAP_API(int) LDAP_CALL ldap_utf8isxdigit(char* s ); -/* like isspace(*s) in the C locale */ -LDAP_API(int) LDAP_CALL ldap_utf8isspace( char* s ); - -#define LDAP_UTF8LEN(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8len (s) : 1) -#define LDAP_UTF8NEXT(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8next(s) : ( s)+1) -#define LDAP_UTF8INC(s) ((0x80 & *(unsigned char*)(s)) ? s=ldap_utf8next(s) : ++s) - -#define LDAP_UTF8PREV(s) ldap_utf8prev(s) -#define LDAP_UTF8DEC(s) (s=ldap_utf8prev(s)) - -#define LDAP_UTF8COPY(d,s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8copy(d,s) : ((*(d) = *(s)), 1)) -#define LDAP_UTF8GETCC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc (&s) : *s++) -#define LDAP_UTF8GETC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc ((const char**)&s) : *s++) - -/* SASL options */ -#define LDAP_OPT_X_SASL_MECH 0x6100 -#define LDAP_OPT_X_SASL_REALM 0x6101 -#define LDAP_OPT_X_SASL_AUTHCID 0x6102 -#define LDAP_OPT_X_SASL_AUTHZID 0x6103 -#define LDAP_OPT_X_SASL_SSF 0x6104 /* read-only */ -#define LDAP_OPT_X_SASL_SSF_EXTERNAL 0x6105 /* write-only */ -#define LDAP_OPT_X_SASL_SECPROPS 0x6106 /* write-only */ -#define LDAP_OPT_X_SASL_SSF_MIN 0x6107 -#define LDAP_OPT_X_SASL_SSF_MAX 0x6108 -#define LDAP_OPT_X_SASL_MAXBUFSIZE 0x6109 - -/* ldap_interactive_bind_s Interaction flags - * Interactive: prompt always - REQUIRED - */ -#define LDAP_SASL_AUTOMATIC 0U /* only prompt for missing items not supplied as defaults */ -#define LDAP_SASL_INTERACTIVE 1U /* prompt for everything and print defaults, if any */ -#define LDAP_SASL_QUIET 2U /* no prompts - only use defaults (e.g. for non-interactive apps) */ - -/* - * 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) - */ -typedef int (LDAP_SASL_INTERACT_PROC) - (LDAP *ld, unsigned flags, void* defaults, void *interact ); - -LDAP_API(int) LDAP_CALL ldap_sasl_interactive_bind_s ( - LDAP *ld, - const char *dn, /* usually NULL */ - const char *saslMechanism, - LDAPControl **serverControls, - LDAPControl **clientControls, - - /* should be client controls */ - unsigned flags, - LDAP_SASL_INTERACT_PROC *proc, - void *defaults ); - -LDAP_API(int) LDAP_CALL ldap_sasl_interactive_bind_ext_s ( - LDAP *ld, - const char *dn, /* usually NULL */ - const char *saslMechanism, - LDAPControl **serverControls, - LDAPControl **clientControls, - - /* should be client controls */ - unsigned flags, - LDAP_SASL_INTERACT_PROC *proc, - void *defaults, - LDAPControl ***responseControls ); - -/* - * Password modify functions - */ -LDAP_API(int) LDAP_CALL ldap_passwd( LDAP *ld, struct berval *userid, - struct berval *oldpasswd, struct berval *newpasswd, - LDAPControl **serverctrls, LDAPControl **clientctrls, - int *msgidp ); - -LDAP_API(int) LDAP_CALL ldap_passwd_s( LDAP *ld, struct berval *userid, - struct berval *oldpasswd, struct berval *newpasswd, - struct berval *genpasswd, LDAPControl **serverctrls, - LDAPControl **clientctrls ); - -LDAP_API(int) LDAP_CALL ldap_parse_passwd( LDAP *ld, LDAPMessage *result, - struct berval *genpasswd ); - -/* - * in reslist.c - */ -LDAP_API(LDAPMessage *) LDAP_CALL ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e ); -LDAP_API(void) LDAP_CALL ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e ); - -#ifdef __cplusplus -} -#endif -#endif /* _LDAP_EXTENSION_H */ -
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/include/ldap-platform.h
Deleted
@@ -1,98 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* ldap-platform.h - platform transparency */ - -#ifndef _LDAP_PLATFORM_H -#define _LDAP_PLATFORM_H - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined (WIN32) || defined (_WIN32) || defined( _CONSOLE ) -#include <windows.h> -# if defined( _WINDOWS ) -# include <winsock.h> -# endif -#elif defined(macintosh) -#ifndef LDAP_TYPE_TIMEVAL_DEFINED -#include <utime.h> -#endif -#ifndef LDAP_TYPE_SOCKET_DEFINED /* API extension */ -#include "macsocket.h" -#endif -#else /* everything else, e.g., Unix */ -#ifndef LDAP_TYPE_TIMEVAL_DEFINED -#include <sys/time.h> -#endif -#ifndef LDAP_TYPE_SOCKET_DEFINED /* API extension */ -#include <sys/types.h> -#include <sys/socket.h> -#endif -#endif - -#ifdef _AIX -#include <sys/select.h> -#endif /* _AIX */ - -#ifdef XP_OS2 -#include <sys/select.h> -#endif -#ifdef XP_OS2_EMX -/* - * EMX-specific tweaks: - * o Use stricmp instead of strcmpi. - */ -#define strcmpi stricmp -#endif - -/* - * LDAP_API macro definition: - */ -#ifndef LDAP_API -#if defined( _WINDOWS ) || defined( _WIN32 ) -#define LDAP_API(rt) rt -#else /* _WINDOWS */ -#define LDAP_API(rt) rt -#endif /* _WINDOWS */ -#endif /* LDAP_API */ - -#ifdef __cplusplus -} -#endif -#endif /* _LDAP_PLATFORM_H */
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/include/portable.h
Deleted
@@ -1,468 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Copyright (c) 1994 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. - */ - -#ifndef _PORTABLE_H -#define _PORTABLE_H - -/* - * portable.h for LDAP -- this is where we define common stuff to make - * life easier on various Unix systems. - * - * Unless you are porting LDAP to a new platform, you should not need to - * edit this file. - */ - -#ifndef SYSV -#if defined( hpux ) || defined( SOLARIS ) || defined ( sgi ) || defined( SVR4 ) -#define SYSV -#endif -#endif - -/* - * under System V, use sysconf() instead of getdtablesize - */ -#if !defined( USE_SYSCONF ) && defined( SYSV ) -#define USE_SYSCONF -#endif - -/* - * under System V, daemons should use setsid() instead of detaching from their - * tty themselves - */ -#if !defined( USE_SETSID ) && defined( SYSV ) -#define USE_SETSID -#endif - -/* - * System V has socket options in filio.h - */ -#if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux ) && !defined( AIX ) -#define NEED_FILIO -#endif - -/* - * use lockf() under System V - */ -#if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix )) -#define USE_LOCKF -#endif - -/* - * on many systems, we should use waitpid() instead of waitN() - */ -#if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) || defined( ultrix ) || defined( aix )) -#define USE_WAITPID -#endif - -/* - * define the wait status argument type - */ -#if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep ) -#define WAITSTATUSTYPE union wait -#else -#define WAITSTATUSTYPE int -#endif - -/* - * defined the options for openlog (syslog) - */ -#ifdef ultrix -#define OPENLOG_OPTIONS LOG_PID -#else -#define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT ) -#endif - -/* - * some systems don't have the BSD re_comp and re_exec routines - */ -#ifndef NEED_BSDREGEX -#if ( defined( SYSV ) || defined( NETBSD ) || defined( freebsd ) || defined( linux ) || defined( DARWIN )) && !defined(sgi) -#define NEED_BSDREGEX -#endif -#endif - -/* - * many systems do not have the setpwfile() library routine... we just - * enable use for those systems we know have it. - */ -#ifndef HAVE_SETPWFILE -#if defined( sunos4 ) || defined( ultrix ) || defined( OSF1 ) -#define HAVE_SETPWFILE -#endif -#endif - -/* - * Are sys_errlist and sys_nerr declared in stdio.h? - */ -#ifndef SYSERRLIST_IN_STDIO -#if defined( freebsd ) -#define SYSERRLIST_IN_STDIO -#endif -#endif - - -/* - * Is snprintf() part of the standard C runtime library? - */ -#if !defined(HAVE_SNPRINTF) -#if defined(SOLARIS) || defined(LINUX) || defined(HPUX) || defined(AIX) -#define HAVE_SNPRINTF -#endif -#if defined(_WINDOWS) -#define snprintf _snprintf -#define HAVE_SNPRINTF -#endif -#endif - - -/* - * Async IO. Use a non blocking implementation of connect() and - * dns functions - */ -#if !defined(LDAP_ASYNC_IO) -#if !defined(_WINDOWS) && !defined(macintosh) -#define LDAP_ASYNC_IO -#endif /* _WINDOWS */ -#endif - -/* - * for select() - */ -#if !defined(WINSOCK) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2) -#if defined(hpux) || defined(LINUX) || defined(SUNOS4) || defined(XP_BEOS) -#include <sys/time.h> -#else -#include <sys/select.h> -#endif -#if !defined(FD_SET) -#define NFDBITS 32 -#define FD_SETSIZE 32 -#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) -#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) -#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) -#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) -#endif /* !FD_SET */ -#endif /* !WINSOCK && !_WINDOWS && !macintosh */ - - -/* - * for connect() -- must we block signals when calling connect()? This - * is necessary on some buggy UNIXes. - */ -#if !defined(NSLDAPI_CONNECT_MUST_NOT_BE_INTERRUPTED) && \ - ( defined(AIX) || defined(IRIX) || defined(HPUX) || defined(SUNOS4) \ - || defined(SOLARIS) || defined(OSF1) ||defined(freebsd)) -#define NSLDAPI_CONNECT_MUST_NOT_BE_INTERRUPTED -#endif - -/* - * On most platforms, sigprocmask() works fine even in multithreaded code. - * But not everywhere. - */ -#ifdef AIX -#define NSLDAPI_MT_SAFE_SIGPROCMASK(h,s,o) sigthreadmask(h,s,o) -#else -#define NSLDAPI_MT_SAFE_SIGPROCMASK(h,s,o) sigprocmask(h,s,o) -#endif - -/* - * toupper and tolower macros are different under bsd and sys v - */ -#if defined( SYSV ) && !defined( hpux ) -#define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c) -#define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c) -#else -#define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c) -#define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c) -#endif - -/* - * put a cover on the tty-related ioctl calls we need to use - */ -#if defined( NeXT ) || (defined(SunOS) && SunOS < 40) -#define TERMIO_TYPE struct sgttyb -#define TERMFLAG_TYPE int -#define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop)) -#define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop)) -#define GETFLAGS( tio ) (tio).sg_flags -#define SETFLAGS( tio, flags ) (tio).sg_flags = (flags) -#else -#define USE_TERMIOS -#define TERMIO_TYPE struct termios -#define TERMFLAG_TYPE tcflag_t -#define GETATTR( fd, tiop ) tcgetattr((fd), (tiop)) -#define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop)) -#define GETFLAGS( tio ) (tio).c_lflag -#define SETFLAGS( tio, flags ) (tio).c_lflag = (flags) -#endif - -#if ( !defined( HPUX9 )) && ( !defined( sunos4 )) && ( !defined( SNI )) && \ - ( !defined( HAVE_TIME_R )) -#define HAVE_TIME_R -#endif - -#if defined(SNI) || defined(LINUX1_2) -int strcasecmp(const char *, const char *); -#ifdef SNI -int strncasecmp(const char *, const char *, int); -#endif /* SNI */ -#ifdef LINUX1_2 -int strncasecmp(const char *, const char *, size_t); -#endif /* LINUX1_2 */ -#endif /* SNI || LINUX1_2 */ - -#if defined(_WINDOWS) || defined(macintosh) || defined(XP_OS2) || defined(DARWIN) -#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) -#define NSLDAPI_CTIME( c, b, l ) ctime( c ) -#define STRTOK( s1, s2, l ) strtok( s1, s2 ) -#elif defined(XP_BEOS) -#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) -#define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b ) -#define STRTOK( s1, s2, l ) strtok_r( s1, s2, l ) -#define HAVE_STRTOK_R -#else /* UNIX */ -#if (defined(AIX) && defined(_THREAD_SAFE)) || defined(OSF1) -#define NSLDAPI_NETDB_BUF_SIZE sizeof(struct protoent_data) -#else -#define NSLDAPI_NETDB_BUF_SIZE 1024 -#endif - -#if defined(sgi) || defined(HPUX9) || defined(SCOOS) || \ - defined(UNIXWARE) || defined(SUNOS4) || defined(SNI) || defined(BSDI) || \ - defined(NCR) || defined(OSF1) || defined(NEC) || defined(VMS) || \ - ( defined(HPUX10) && !defined(_REENTRANT)) || defined(HPUX11) || \ - defined(UnixWare) || defined(NETBSD) || \ - defined(FREEBSD) || defined(OPENBSD) || \ - (defined(LINUX) && __GLIBC__ < 2) || \ - (defined(AIX) && !defined(USE_REENTRANT_LIBC)) -#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) -#elif defined(AIX) -/* Maybe this is for another version of AIX? - Commenting out for AIX 4.1 for Nova - Replaced with following to lines, stolen from the #else below -#define GETHOSTBYNAME_BUF_T struct hostent_data -*/ -typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE]; -#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t -#define GETHOSTBYNAME( n, r, b, l, e ) \ - (memset (&b, 0, l), gethostbyname_r (n, r, &b) ? NULL : r) -#elif defined(HPUX10) -#define GETHOSTBYNAME_BUF_T struct hostent_data -#define GETHOSTBYNAME( n, r, b, l, e ) nsldapi_compat_gethostbyname_r( n, r, (char *)&b, l, e ) -#elif defined(LINUX) -typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE]; -#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t -#define GETHOSTBYNAME( n, r, b, l, rp, e ) gethostbyname_r( n, r, b, l, rp, e ) -#define GETHOSTBYNAME_R_RETURNS_INT -#else -typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE]; -#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t -#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname_r( n, r, b, l, e ) -#endif -#if defined(HPUX9) || defined(LINUX1_2) || defined(LINUX2_0) || \ - defined(LINUX2_1) || defined(SUNOS4) || defined(SNI) || \ - defined(SCOOS) || defined(BSDI) || defined(NCR) || \ - defined(NEC) || ( defined(HPUX10) && !defined(_REENTRANT)) || \ - (defined(AIX) && !defined(USE_REENTRANT_LIBC)) -#define NSLDAPI_CTIME( c, b, l ) ctime( c ) -#elif defined(HPUX10) && defined(_REENTRANT) && !defined(HPUX11) -#define NSLDAPI_CTIME( c, b, l ) nsldapi_compat_ctime_r( c, b, l ) -#elif defined( IRIX6_2 ) || defined( IRIX6_3 ) || defined(UNIXWARE) \ - || defined(OSF1V4) || defined(AIX) || defined(UnixWare) \ - || defined(hpux) || defined(HPUX11) || defined(NETBSD) \ - || defined(IRIX6) || defined(FREEBSD) || defined(VMS) \ - || defined(NTO) || defined(OPENBSD) -#define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b ) -#elif defined( OSF1V3 ) -#define NSLDAPI_CTIME( c, b, l ) (ctime_r( c, b, l ) ? NULL : b) -#else -#define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b, l ) -#endif -#if defined(hpux9) || defined(SUNOS4) || defined(SNI) || \ - defined(SCOOS) || defined(BSDI) || defined(NCR) || defined(VMS) || \ - defined(NEC) || (defined(LINUX) && __GNU_LIBRARY__ != 6) || \ - (defined(AIX) && !defined(USE_REENTRANT_LIBC)) -#define STRTOK( s1, s2, l ) strtok( s1, s2 ) -#else -#define HAVE_STRTOK_R -#ifndef strtok_r -char *strtok_r(char *, const char *, char **); -#endif -#define STRTOK( s1, s2, l ) (char *)strtok_r( s1, s2, l ) -#endif /* STRTOK */ -#endif /* UNIX */ - -#if defined( ultrix ) || defined( nextstep ) -extern char *strdup(); -#endif /* ultrix || nextstep */ - -#if defined( sunos4 ) || defined( OSF1 ) -#define BSD_TIME 1 /* for servers/slapd/log.h */ -#endif /* sunos4 || osf */ - -#if defined(XP_OS2) -#include <machine/endian.h> /* for htonl, et.al. */ -#include <arpa/inet.h> /* for inet_addr() */ -#elif !defined(_WINDOWS) && !defined(macintosh) -#include <netinet/in.h> -#if !defined(XP_BEOS) -#include <arpa/inet.h> /* for inet_addr() */ -#endif -#endif - - -/* - * Define portable 32-bit integral types. - */ -#include <limits.h> -#if UINT_MAX >= 0xffffffffU /* an int holds at least 32 bits */ - typedef signed int nsldapi_int_32; - typedef unsigned int nsldapi_uint_32; -#else /* ints are < 32 bits; use long instead */ - typedef signed long nsldapi_int_32; - typedef unsigned long nsldapi_uint_32; -#endif - -/* - * Define a portable type for IPv4 style Internet addresses (32 bits): - */ -#if defined(_IN_ADDR_T) || defined(aix) || defined(HPUX11) || defined(OSF1) -typedef in_addr_t nsldapi_in_addr_t; -#else -typedef nsldapi_uint_32 nsldapi_in_addr_t; -#endif - -#ifdef SUNOS4 -#include <pcfs/pc_dir.h> /* for toupper() */ -int fprintf(FILE *, char *, ...); -int fseek(FILE *, long, int); -int fread(char *, int, int, FILE *); -int fclose(FILE *); -int fflush(FILE *); -int rewind(FILE *); -void *memmove(void *, const void *, size_t); -int strcasecmp(char *, char *); -int strncasecmp(char *, char *, int); -time_t time(time_t *); -void perror(char *); -int fputc(char, FILE *); -int fputs(char *, FILE *); -int re_exec(char *); -int socket(int, int, int); -void bzero(char *, int); -unsigned long inet_addr(char *); -char * inet_ntoa(struct in_addr); -int getdtablesize(); -int connect(int, struct sockaddr *, int); -#endif /* SUNOS4 */ - -/* #if defined(SUNOS4) || defined(SNI) */ -#if defined(SUNOS4) -int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); -#endif /* SUNOS4 || SNI */ - -/* - * SAFEMEMCPY is an overlap-safe copy from s to d of n bytes - */ -#ifdef macintosh -#define SAFEMEMCPY( d, s, n ) BlockMoveData( (Ptr)s, (Ptr)d, n ) -#else /* macintosh */ -#ifdef sunos4 -#define SAFEMEMCPY( d, s, n ) bcopy( s, d, n ) -#else /* sunos4 */ -#define SAFEMEMCPY( d, s, n ) memmove( d, s, n ) -#endif /* sunos4 */ -#endif /* macintosh */ - -#ifdef _WINDOWS - -#define strcasecmp strcmpi -#define strncasecmp _strnicmp -#define bzero(a, b) memset( a, 0, b ) -#define getpid _getpid -#define ioctl ioctlsocket -#define sleep(a) Sleep( a*1000 ) - -#define EMSGSIZE WSAEMSGSIZE -#define EWOULDBLOCK WSAEWOULDBLOCK -#define EHOSTUNREACH WSAEHOSTUNREACH - -#ifndef MAXPATHLEN -#define MAXPATHLEN _MAX_PATH -#endif - -/* We'd like this number to be prime for the hash - * into the Connection table */ -#define DS_MAX_NT_SOCKET_CONNECTIONS 2003 - -#elif defined(XP_OS2) - -#define strcasecmp stricmp -#define strncasecmp strnicmp -#define bzero(a, b) memset( a, 0, b ) -#include <string.h> /*for strcmpi()*/ -#include <time.h> /*for ctime()*/ - -#endif /* XP_OS2 */ - -/* Define a macro to support large files */ -#ifdef _LARGEFILE64_SOURCE -#define NSLDAPI_FOPEN( filename, mode ) fopen64( filename, mode ) -#else -#define NSLDAPI_FOPEN( filename, mode ) fopen( filename, mode ) -#endif - -#if defined(LINUX) || defined(AIX) || defined(HPUX) || defined(_WINDOWS) -size_t nsldapi_compat_strlcpy(char *dst, const char *src, size_t len); -#define STRLCPY nsldapi_compat_strlcpy -#else -#define STRLCPY strlcpy -#endif - -#endif /* _PORTABLE_H */
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libiutil
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/liblber
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/liblber/io.c
Deleted
@@ -1,1757 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * 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. - */ -/* io.c - ber general i/o routines */ - -#include "lber-int.h" - -#define bergetc( sb, len ) ( sb->sb_ber.ber_end > sb->sb_ber.ber_ptr ? \ - (unsigned char)*sb->sb_ber.ber_ptr++ : \ - ber_filbuf( sb, len )) - -# ifdef macintosh -/* - * MacTCP/OpenTransport - */ -# define read( s, b, l ) tcpread( s, 0, (unsigned char *)b, l, NULL ) -# define MAX_WRITE 65535 -# define BerWrite( sb, b, l ) tcpwrite( sb->sb_sd, (unsigned char *)(b), (l<MAX_WRITE)? l : MAX_WRITE ) -# else /* macintosh */ -# if defined(_WIN32) || defined(_WINDOWS) || defined(XP_OS2) -/* - * 32-bit Windows Socket API (under Windows NT or Windows 95) - */ -# define read( s, b, l ) recv( s, b, l, 0 ) -# define BerWrite( s, b, l ) send( s->sb_sd, b, l, 0 ) -# else /* _WIN32 */ -/* - * everything else (Unix/BSD 4.3 socket API) - */ -# define BerWrite( sb, b, l ) write( sb->sb_sd, b, l ) -# define udp_read( sb, b, l, al ) recvfrom(sb->sb_sd, (char *)b, l, 0, \ - (struct sockaddr *)sb->sb_fromaddr, \ - (al = sizeof(struct sockaddr), &al)) -# define udp_write( sb, b, l ) sendto(sb->sb_sd, (char *)(b), l, 0, \ - (struct sockaddr *)sb->sb_useaddr, sizeof(struct sockaddr)) -# endif /* _WIN32 */ -# endif /* macintosh */ - -#ifndef udp_read -#define udp_read( sb, b, l, al ) CLDAP NOT SUPPORTED -#define udp_write( sb, b, l ) CLDAP NOT SUPPORTED -#endif /* udp_read */ - -#define EXBUFSIZ 1024 -size_t lber_bufsize = EXBUFSIZ; - -#ifdef LDAP_DEBUG -int lber_debug; -#endif - -/* - * function prototypes - */ -static void nslberi_install_compat_io_fns( Sockbuf *sb ); -static int nslberi_extread_compat( int s, void *buf, int len, - struct lextiof_socket_private *arg ); -static int nslberi_extwrite_compat( int s, const void *buf, int len, - struct lextiof_socket_private *arg ); -static ber_tag_t get_tag( Sockbuf *sb, BerElement *ber); -static ber_len_t get_ber_len( BerElement *ber); -static ber_len_t read_len_in_ber( Sockbuf *sb, BerElement *ber); - -/* - * internal global structure for memory allocation callback functions - */ -static struct lber_memalloc_fns nslberi_memalloc_fns; - - -/* - * buffered read from "sb". - * returns value of first character read on success and -1 on error. - */ -static int -ber_filbuf( Sockbuf *sb, ber_slen_t len ) -{ - ssize_t rc; -#ifdef CLDAP - int addrlen; -#endif /* CLDAP */ - - if ( sb->sb_ber.ber_buf == NULL ) { - if ( (sb->sb_ber.ber_buf = (char *)NSLBERI_MALLOC( - READBUFSIZ )) == NULL ) { - return( -1 ); - } - sb->sb_ber.ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER; - sb->sb_ber.ber_ptr = sb->sb_ber.ber_buf; - sb->sb_ber.ber_end = sb->sb_ber.ber_buf; - } - - if ( sb->sb_naddr > 0 ) { -#ifdef CLDAP - rc = udp_read(sb, sb->sb_ber.ber_buf, READBUFSIZ, addrlen ); -#ifdef LDAP_DEBUG - if ( lber_debug ) { - char msg[80]; - sprintf( msg, "ber_filbuf udp_read %d bytes\n", - rc ); - ber_err_print( msg ); - if ( lber_debug > 1 && rc > 0 ) - lber_bprint( sb->sb_ber.ber_buf, rc ); - } -#endif /* LDAP_DEBUG */ -#else /* CLDAP */ - rc = -1; -#endif /* CLDAP */ - } else { - if ( sb->sb_ext_io_fns.lbextiofn_read != NULL ) { - rc = sb->sb_ext_io_fns.lbextiofn_read( - sb->sb_sd, sb->sb_ber.ber_buf, - ((sb->sb_options & LBER_SOCKBUF_OPT_NO_READ_AHEAD) - && (len < READBUFSIZ)) ? len : READBUFSIZ, - sb->sb_ext_io_fns.lbextiofn_socket_arg ); - } else { -#ifdef NSLDAPI_AVOID_OS_SOCKETS - return( -1 ); -#else - rc = read( sb->sb_sd, sb->sb_ber.ber_buf, - ((sb->sb_options & LBER_SOCKBUF_OPT_NO_READ_AHEAD) - && (len < READBUFSIZ)) ? len : READBUFSIZ ); -#endif - } - } - - if ( rc > 0 ) { - sb->sb_ber.ber_ptr = sb->sb_ber.ber_buf + 1; - sb->sb_ber.ber_end = sb->sb_ber.ber_buf + rc; - return( (unsigned char)*sb->sb_ber.ber_buf ); - } - - return( -1 ); -} - - -static ber_int_t -BerRead( Sockbuf *sb, char *buf, ber_slen_t len ) -{ - int c; - ber_int_t nread = 0; - - while (len > 0) - { - ber_int_t inberbuf = sb->sb_ber.ber_end - sb->sb_ber.ber_ptr; - if (inberbuf > 0) - { - size_t tocopy = len > inberbuf ? inberbuf : len; - SAFEMEMCPY(buf, sb->sb_ber.ber_ptr, tocopy); - buf += tocopy; - sb->sb_ber.ber_ptr += tocopy; - nread += tocopy; - len -= tocopy; - } - else - { - c = ber_filbuf(sb, len); - if (c < 0) - { - if (nread > 0) - break; - else - return c; - } - *buf++ = c; - nread++; - len--; - } - } - return (nread); -} - - -/* - * Note: ber_read() only uses the ber_end and ber_ptr elements of ber. - * Functions like ber_get_tag(), ber_skip_tag, and ber_peek_tag() rely on - * that fact, so if this code is changed to use any additional elements of - * the ber structure, those functions will need to be changed as well. - */ -ber_int_t -LDAP_CALL -ber_read( BerElement *ber, char *buf, ber_len_t len ) -{ - ber_len_t actuallen; - ber_uint_t nleft; - - nleft = ber->ber_end - ber->ber_ptr; - actuallen = nleft < len ? nleft : len; - - SAFEMEMCPY( buf, ber->ber_ptr, (size_t)actuallen ); - - ber->ber_ptr += actuallen; - - return( (ber_int_t)actuallen ); -} - -/* - * enlarge the ber buffer. - * return 0 on success, -1 on error. - */ -int -nslberi_ber_realloc( BerElement *ber, ber_len_t len ) -{ - ber_uint_t need, have, total; - size_t have_bytes; - Seqorset *s; - ber_int_t off; - char *oldbuf; - int freeoldbuf = 0; - - ber->ber_buf_reallocs++; - - have_bytes = ber->ber_end - ber->ber_buf; - have = have_bytes / lber_bufsize; - need = (len < lber_bufsize ? 1 : (len + (lber_bufsize - 1)) / lber_bufsize); - total = have * lber_bufsize + need * lber_bufsize * ber->ber_buf_reallocs; - - oldbuf = ber->ber_buf; - - if (ber->ber_buf == NULL) { - if ( (ber->ber_buf = (char *)NSLBERI_MALLOC( (size_t)total )) - == NULL ) { - return( -1 ); - } - ber->ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER; - } else { - if ( !(ber->ber_flags & LBER_FLAG_NO_FREE_BUFFER) ) { - freeoldbuf = 1; - } - /* transition to malloc'd buffer */ - if ( (ber->ber_buf = (char *)NSLBERI_MALLOC( - (size_t)total )) == NULL ) { - return( -1 ); - } - ber->ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER; - /* copy existing data into new malloc'd buffer */ - SAFEMEMCPY( ber->ber_buf, oldbuf, have_bytes ); - } - - ber->ber_end = ber->ber_buf + total; - - /* - * If the stinking thing was moved, we need to go through and - * reset all the sos and ber pointers. Offsets would've been - * a better idea... oh well. - */ - - if ( ber->ber_buf != oldbuf ) { - ber->ber_ptr = ber->ber_buf + (ber->ber_ptr - oldbuf); - - for ( s = ber->ber_sos; s != NULLSEQORSET; s = s->sos_next ) { - off = s->sos_first - oldbuf; - s->sos_first = ber->ber_buf + off; - - off = s->sos_ptr - oldbuf; - s->sos_ptr = ber->ber_buf + off; - } - - if ( freeoldbuf && oldbuf ) { - NSLBERI_FREE( oldbuf ); - } - } - - return( 0 ); -} - -/* - * returns "len" on success and -1 on failure. - */ -ber_int_t -LDAP_CALL -ber_write( BerElement *ber, char *buf, ber_len_t len, int nosos ) -{ - if ( nosos || ber->ber_sos == NULL ) { - if ( ber->ber_ptr + len > ber->ber_end ) { - if ( nslberi_ber_realloc( ber, len ) != 0 ) - return( -1 ); - } - SAFEMEMCPY( ber->ber_ptr, buf, (size_t)len ); - ber->ber_ptr += len; - return( len ); - } else { - if ( ber->ber_sos->sos_ptr + len > ber->ber_end ) { - if ( nslberi_ber_realloc( ber, len ) != 0 ) - return( -1 ); - } - SAFEMEMCPY( ber->ber_sos->sos_ptr, buf, (size_t)len ); - ber->ber_sos->sos_ptr += len; - ber->ber_sos->sos_clen += len; - return( len ); - } -} - -void -LDAP_CALL -ber_free( BerElement *ber, int freebuf ) -{ - if ( ber != NULL ) { - if ( freebuf && - !(ber->ber_flags & LBER_FLAG_NO_FREE_BUFFER)) { - NSLBERI_FREE(ber->ber_buf); - } - NSLBERI_FREE( (char *) ber ); - } -} - -/* - * return >= 0 on success, -1 on failure. - */ -int -LDAP_CALL -ber_flush( Sockbuf *sb, BerElement *ber, int freeit ) -{ - ssize_t nwritten = 0, towrite, rc; - int i = 0; - - if (ber->ber_rwptr == NULL) { - ber->ber_rwptr = ber->ber_buf; - } else if (ber->ber_rwptr >= ber->ber_end) { - /* we will use the ber_rwptr to continue an exited flush, - so if rwptr is not within the buffer we return an error. */ - return( -1 ); - } - - /* writev section - for iDAR only!!! */ - if (sb->sb_ext_io_fns.lbextiofn_writev != NULL) { - - /* add the sizes of the different buffers to write with writev */ - for (towrite = 0, i = 0; i < BER_ARRAY_QUANTITY; ++i) { - /* don't add lengths of null buffers - writev will ignore them */ - if (ber->ber_struct[i].ldapiov_base) { - towrite += ber->ber_struct[i].ldapiov_len; - } - } - - rc = sb->sb_ext_io_fns.lbextiofn_writev(sb->sb_sd, ber->ber_struct, BER_ARRAY_QUANTITY, - sb->sb_ext_io_fns.lbextiofn_socket_arg); - - if ( freeit ) - ber_free( ber, 1 ); - - if (rc >= 0) { - /* return the number of bytes TO BE written */ - return (towrite - rc); - } else { - /* otherwise it's an error */ - return (rc); - } - } /* end writev section */ - - towrite = ber->ber_ptr - ber->ber_rwptr; - -#ifdef LDAP_DEBUG - if ( lber_debug ) { - char msg[80]; - sprintf( msg, "ber_flush: %d bytes to sd %ld%s\n", towrite, - sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)" - : "" ); - ber_err_print( msg ); - if ( lber_debug > 1 ) - lber_bprint( ber->ber_rwptr, towrite ); - } -#endif -#if !defined(macintosh) && !defined(DOS) - if ( sb->sb_options & (LBER_SOCKBUF_OPT_TO_FILE | LBER_SOCKBUF_OPT_TO_FILE_ONLY) ) { - rc = write( sb->sb_copyfd, ber->ber_buf, towrite ); - if ( sb->sb_options & LBER_SOCKBUF_OPT_TO_FILE_ONLY ) { - return( (int)rc ); - } - } -#endif - - nwritten = 0; - do { - if (sb->sb_naddr > 0) { -#ifdef CLDAP - rc = udp_write( sb, ber->ber_buf + nwritten, - (size_t)towrite ); -#else /* CLDAP */ - rc = -1; -#endif /* CLDAP */ - if ( rc <= 0 ) - return( -1 ); - /* fake error if write was not atomic */ - if (rc < towrite) { -#if !defined( macintosh ) && !defined( DOS ) - errno = EMSGSIZE; /* For Win32, see portable.h */ -#endif - return( -1 ); - } - } else { - if ( sb->sb_ext_io_fns.lbextiofn_write != NULL ) { - if ( (rc = sb->sb_ext_io_fns.lbextiofn_write( - sb->sb_sd, ber->ber_rwptr, (size_t)towrite, - sb->sb_ext_io_fns.lbextiofn_socket_arg )) - <= 0 ) { - return( -1 ); - } - } else { -#ifdef NSLDAPI_AVOID_OS_SOCKETS - return( -1 ); -#else - if ( (rc = BerWrite( sb, ber->ber_rwptr, - (size_t) towrite )) <= 0 ) { - return( -1 ); - } -#endif - } - } - towrite -= rc; - nwritten += rc; - ber->ber_rwptr += rc; - } while ( towrite > 0 ); - - if ( freeit ) - ber_free( ber, 1 ); - - return( 0 ); -} - - -/* we pre-allocate a buffer to save the extra malloc later */ -BerElement * -LDAP_CALL -ber_alloc_t( int options ) -{ - BerElement *ber; - - if ( (ber = (BerElement*)NSLBERI_CALLOC( 1, - sizeof(struct berelement) + lber_bufsize )) == NULL ) { - return( NULL ); - } - - /* - * for compatibility with the C LDAP API standard, we recognize - * LBER_USE_DER as LBER_OPT_USE_DER. See lber.h for a bit more info. - */ - if ( options & LBER_USE_DER ) { - options &= ~LBER_USE_DER; - options |= LBER_OPT_USE_DER; - } - - ber->ber_tag = LBER_DEFAULT; - ber->ber_options = options; - ber->ber_buf = (char*)ber + sizeof(struct berelement); - ber->ber_ptr = ber->ber_buf; - ber->ber_end = ber->ber_buf + lber_bufsize; - ber->ber_flags = LBER_FLAG_NO_FREE_BUFFER; - - return( ber ); -} - - -BerElement * -LDAP_CALL -ber_alloc() -{ - return( ber_alloc_t( 0 ) ); -} - -BerElement * -LDAP_CALL -der_alloc() -{ - return( ber_alloc_t( LBER_OPT_USE_DER ) ); -} - -BerElement * -LDAP_CALL -ber_dup( BerElement *ber ) -{ - BerElement *new; - - if ( (new = ber_alloc()) == NULL ) - return( NULL ); - - *new = *ber; - - return( new ); -} - - -void -LDAP_CALL -ber_init_w_nullchar( BerElement *ber, int options ) -{ - (void) memset( (char *)ber, '\0', sizeof(struct berelement) ); - ber->ber_tag = LBER_DEFAULT; - - /* - * For compatibility with the C LDAP API standard, we recognize - * LBER_USE_DER as LBER_OPT_USE_DER. See lber.h for a bit more info. - */ - if ( options & LBER_USE_DER ) { - options &= ~LBER_USE_DER; - options |= LBER_OPT_USE_DER; - } - - ber->ber_options = options; -} - -void -LDAP_CALL -ber_reset( BerElement *ber, int was_writing ) -{ - if ( was_writing ) { - ber->ber_end = ber->ber_ptr; - ber->ber_ptr = ber->ber_buf; - } else { - ber->ber_ptr = ber->ber_end; - } - - ber->ber_rwptr = NULL; - ber->ber_tag_len_read = 0; - - memset(ber->ber_struct, 0, BER_CONTENTS_STRUCT_SIZE); -} - -/* Returns the length of the ber buffer so far, - taking into account sequences/sets also. - CAUTION: Returns 0 on null buffers as well - as 0 on empty buffers! -*/ -size_t -LDAP_CALL -ber_get_buf_datalen( BerElement *ber ) -{ - size_t datalen; - - if ( ( ber == NULL) || ( ber->ber_buf == NULL) || ( ber->ber_ptr == NULL ) ) { - datalen = 0; - } else if (ber->ber_sos == NULLSEQORSET) { - /* there are no sequences or sets yet, - so just subtract ptr from the beginning of the ber buffer */ - datalen = ber->ber_ptr - ber->ber_buf; - } else { - /* sequences exist, so just take the ptr of the sequence - on top of the stack and subtract the beginning of the - buffer from it */ - datalen = ber->ber_sos->sos_ptr - ber->ber_buf; - } - - return datalen; -} - -/* - if buf is 0 then malloc a buffer of length size - returns > 0 on success, 0 otherwise -*/ -int -LDAP_CALL -ber_stack_init(BerElement *ber, int options, char * buf, - size_t size) -{ - if (NULL == ber) - return 0; - - memset(ber, 0, sizeof(*ber)); - - /* - * for compatibility with the C LDAP API standard, we recognize - * LBER_USE_DER as LBER_OPT_USE_DER. See lber.h for a bit more info. - */ - - if ( options & LBER_USE_DER ) { - options &= ~LBER_USE_DER; - options |= LBER_OPT_USE_DER; - } - - ber->ber_tag = LBER_DEFAULT; - ber->ber_options = options; - - if ( ber->ber_buf && !(ber->ber_flags & LBER_FLAG_NO_FREE_BUFFER)) { - NSLBERI_FREE(ber->ber_buf); - } - - if (buf) { - ber->ber_buf = ber->ber_ptr = buf; - ber->ber_flags = LBER_FLAG_NO_FREE_BUFFER; - } else { - ber->ber_buf = ber->ber_ptr = (char *) NSLBERI_MALLOC(size); - } - - ber->ber_end = ber->ber_buf + size; - - return ber->ber_buf != 0; -} - -/* - * This call allows to release only the data part of - * the target Sockbuf. - * Other info of this Sockbuf are kept unchanged. - */ -void -LDAP_CALL -ber_sockbuf_free_data(Sockbuf *p) -{ - if ( p != NULL ) { - if ( p->sb_ber.ber_buf != NULL && - !(p->sb_ber.ber_flags & LBER_FLAG_NO_FREE_BUFFER) ) { - NSLBERI_FREE( p->sb_ber.ber_buf ); - p->sb_ber.ber_buf = NULL; - } - } -} - -/* simply returns ber_buf in the ber ... - explicitly for DS MMR only... -*/ -char * -LDAP_CALL -ber_get_buf_databegin (BerElement * ber) -{ - if (NULL != ber) { - return ber->ber_buf; - } else { - return NULL; - } -} - -#ifdef LDAP_DEBUG - -void -ber_dump( BerElement *ber, int inout ) -{ - char msg[128]; - sprintf( msg, "ber_dump: buf 0x%p, ptr 0x%p, rwptr 0x%p, end 0x%p\n", - ber->ber_buf, ber->ber_ptr, ber->ber_rwptr, ber->ber_end ); - ber_err_print( msg ); - if ( inout == 1 ) { - sprintf( msg, " current len %ld, contents:\n", - (long)(ber->ber_end - ber->ber_ptr) ); - ber_err_print( msg ); - lber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr ); - } else { - sprintf( msg, " current len %ld, contents:\n", - (long)(ber->ber_ptr - ber->ber_buf) ); - ber_err_print( msg ); - lber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf ); - } -} - -void -ber_sos_dump( Seqorset *sos ) -{ - char msg[80]; - ber_err_print ( "*** sos dump ***\n" ); - while ( sos != NULLSEQORSET ) { - sprintf( msg, "ber_sos_dump: clen %d first 0x%p ptr 0x%p\n", - sos->sos_clen, sos->sos_first, sos->sos_ptr ); - ber_err_print( msg ); - sprintf( msg, " current len %ld contents:\n", - (long)(sos->sos_ptr - sos->sos_first) ); - ber_err_print( msg ); - lber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first ); - - sos = sos->sos_next; - } - ber_err_print( "*** end dump ***\n" ); -} - -#endif - -/* return the tag - LBER_DEFAULT returned means trouble - * assumes the tag is only one byte! */ -static ber_tag_t -get_tag( Sockbuf *sb, BerElement *ber) -{ - unsigned char xbyte; - - if ( (BerRead( sb, (char *) &xbyte, 1 )) != 1 ) { - return( LBER_DEFAULT ); - } - - /* we only handle small (one byte) tags */ - if ( (xbyte & LBER_BIG_TAG_MASK) == LBER_BIG_TAG_MASK ) { - return( LBER_DEFAULT ); - } - - ber->ber_tag_contents[0] = xbyte; - ber->ber_struct[BER_STRUCT_TAG].ldapiov_len = 1; - return((ber_tag_t)xbyte); -} - - -/* Error checking? */ -/* Takes a ber and returns the actual length */ -static ber_len_t -get_ber_len( BerElement *ber) -{ - int noctets; - ber_len_t len = 0; - char xbyte; - - xbyte = ber->ber_len_contents[0]; - - /* long form */ - if (xbyte & 0x80) { - noctets = (int) (xbyte & 0x7f); - if (noctets >= MAX_LEN_SIZE) { - return(LBER_DEFAULT); - } - SAFEMEMCPY((char*) &len + sizeof(ber_len_t) - noctets, &ber->ber_len_contents[1], noctets); - len = LBER_NTOHL(len); - return(len); - } else { - return((ber_len_t)(xbyte)); - } -} - -/* LBER_DEFAULT means trouble - reads in the length, stores it in ber->ber_struct, and returns get_ber_len */ -static ber_len_t -read_len_in_ber( Sockbuf *sb, BerElement *ber) -{ - unsigned char xbyte; - int noctets; - int rc = 0, read_result = 0; - - /* - * Next, read the length. The first byte contains the length - * of the length. If bit 8 is set, the length is the long - * form, otherwise it's the short form. We don't allow a - * length that's greater than what we can hold in a ber_int_t - */ - if ( ber->ber_tag_len_read == 1) { - /* the length of the length hasn't been read yet */ - if ( BerRead( sb, (char *) &xbyte, 1 ) != 1 ) { - return( LBER_DEFAULT ); - } - ber->ber_tag_len_read = 2; - ber->ber_len_contents[0] = xbyte; - } else { - rc = ber->ber_tag_len_read - 2; - xbyte = ber->ber_len_contents[0]; - } - - /* long form of the length value */ - if ( xbyte & 0x80 ) { - noctets = (xbyte & 0x7f); - if ( noctets >= MAX_LEN_SIZE ) - return( LBER_DEFAULT ); - while (rc < noctets) { - read_result = BerRead( sb, &(ber->ber_len_contents[1]) + rc, noctets - rc ); - if (read_result <= 0) { - ber->ber_tag_len_read = rc + 2; /* so we can continue later - include tag and lenlen */ - return( LBER_DEFAULT ); - } - rc += read_result; - } - ber->ber_tag_len_read = rc + 2; /* adds tag (1 byte) and lenlen (1 byte) */ - ber->ber_struct[BER_STRUCT_LEN].ldapiov_len = 1 + noctets; - } else { /* short form of the length value */ - ber->ber_struct[BER_STRUCT_LEN].ldapiov_len = 1; - } - return(get_ber_len(ber)); -} - - -ber_tag_t -LDAP_CALL -ber_get_next( Sockbuf *sb, ber_len_t *len, BerElement *ber ) -{ - ber_len_t newlen; - ber_len_t toread; - ber_int_t rc; - ber_len_t orig_taglen_read = 0; - char * orig_rwptr = ber->ber_rwptr ? ber->ber_rwptr : ber->ber_buf; - -#ifdef LDAP_DEBUG - if ( lber_debug ) - ber_err_print( "ber_get_next\n" ); -#endif - - /* - * When rwptr is NULL this signifies that the tag and length have not been - * read in their entirety yet. (if at all) - */ - if ( ber->ber_rwptr == NULL ) { - - /* first save the amount we previously read, so we know what to return in len. */ - orig_taglen_read = ber->ber_tag_len_read; - - /* read the tag - if tag_len_read is greater than 0, then it has already been read. */ - if (ber->ber_tag_len_read == 0) { - if ((ber->ber_tag = get_tag(sb, ber)) == LBER_DEFAULT ) { - *len = 0; - return( LBER_DEFAULT ); - } - - ber->ber_tag_contents[0] = (char)ber->ber_tag; /* we only handle 1 byte tags */ - ber->ber_tag_len_read = 1; - - /* check for validity */ - if((sb->sb_options & LBER_SOCKBUF_OPT_VALID_TAG) && - (ber->ber_tag != sb->sb_valid_tag)) { - *len = 1; /* we just read the tag so far */ - return( LBER_DEFAULT); - } - } - - /* read the length */ - if ((newlen = read_len_in_ber(sb, ber)) == LBER_DEFAULT ) { - *len = ber->ber_tag_len_read - orig_taglen_read; - return( LBER_DEFAULT ); - } - - /* - * Finally, malloc a buffer for the contents and read it in. - * It's this buffer that's passed to all the other ber decoding - * routines. - */ - -#if defined( DOS ) && !( defined( _WIN32 ) || defined(XP_OS2) ) - if ( newlen > 65535 ) { /* DOS can't allocate > 64K */ - return( LBER_DEFAULT ); - } -#endif /* DOS && !_WIN32 */ - - if ( ( sb->sb_options & LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE ) - && newlen > sb->sb_max_incoming ) { - return( LBER_DEFAULT ); - } - - /* check to see if we already have enough memory allocated */ - if ( ((ber_len_t) ber->ber_end - (ber_len_t) ber->ber_buf) < newlen) { - if ( ber->ber_buf && !(ber->ber_flags & LBER_FLAG_NO_FREE_BUFFER)) { - NSLBERI_FREE(ber->ber_buf); - } - if ( (ber->ber_buf = (char *)NSLBERI_CALLOC( 1,(size_t)newlen )) - == NULL ) { - return( LBER_DEFAULT ); - } - ber->ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER; - orig_rwptr = ber->ber_buf; - } - - - ber->ber_len = newlen; - ber->ber_ptr = ber->ber_buf; - ber->ber_end = ber->ber_buf + newlen; - ber->ber_rwptr = ber->ber_buf; - ber->ber_tag_len_read = 0; /* now that rwptr is set, this doesn't matter */ - } - - /* OK, we've malloc-ed the buffer; now read the rest of the expected length */ - toread = (ber_len_t)ber->ber_end - (ber_len_t)ber->ber_rwptr; - do { - if ( (rc = BerRead( sb, ber->ber_rwptr, (ber_int_t)toread )) <= 0 ) { - *len = (ber_len_t) ber->ber_rwptr - (ber_len_t) orig_rwptr; - return( LBER_DEFAULT ); - } - - toread -= rc; - ber->ber_rwptr += rc; - } while ( toread > 0 ); - -#ifdef LDAP_DEBUG - if ( lber_debug ) { - char msg[80]; - sprintf( msg, "ber_get_next: tag 0x%x len %d contents:\n", - ber->ber_tag, ber->ber_len ); - ber_err_print( msg ); - if ( lber_debug > 1 ) - ber_dump( ber, 1 ); - } -#endif - - *len = (ber_len_t) ber->ber_rwptr - (ber_len_t) orig_rwptr; - ber->ber_rwptr = NULL; - ber->ber_struct[BER_STRUCT_VAL].ldapiov_len = ber->ber_len; - return( ber->ber_tag ); -} - -Sockbuf * -LDAP_CALL -ber_sockbuf_alloc() -{ - return( (Sockbuf *)NSLBERI_CALLOC( 1, sizeof(struct sockbuf) ) ); -} - -void -LDAP_CALL -ber_sockbuf_free(Sockbuf *p) -{ - if ( p != NULL ) { - if ( p->sb_ber.ber_buf != NULL && - !(p->sb_ber.ber_flags & LBER_FLAG_NO_FREE_BUFFER) ) { - NSLBERI_FREE( p->sb_ber.ber_buf ); - } - NSLBERI_FREE(p); - } -} - -/* - * return 0 on success and -1 on error - */ -int -LDAP_CALL -ber_set_option( struct berelement *ber, int option, void *value ) -{ - - /* - * memory allocation callbacks are global, so it is OK to pass - * NULL for ber. Handle this as a special case. - */ - if ( option == LBER_OPT_MEMALLOC_FN_PTRS ) { - /* struct copy */ - nslberi_memalloc_fns = *((struct lber_memalloc_fns *)value); - return( 0 ); - } - - /* - * lber_debug is global, so it is OK to pass - * NULL for ber. Handle this as a special case. - */ - if ( option == LBER_OPT_DEBUG_LEVEL ) { -#ifdef LDAP_DEBUG - lber_debug = *(int *)value; -#endif - return( 0 ); - } - - /* - * lber_bufsize is global, so it is OK to pass - * NULL for ber. Handle this as a special case. - */ - if ( option == LBER_OPT_BUFSIZE ) { - if ( *(size_t *)value > EXBUFSIZ ) { - lber_bufsize = *(size_t *)value; - } - return( 0 ); - } - - /* - * all the rest require a non-NULL ber - */ - if ( !NSLBERI_VALID_BERELEMENT_POINTER( ber )) { - return( -1 ); - } - - switch ( option ) { - case LBER_OPT_USE_DER: - case LBER_OPT_TRANSLATE_STRINGS: - if ( value != NULL ) { - ber->ber_options |= option; - } else { - ber->ber_options &= ~option; - } - break; - case LBER_OPT_REMAINING_BYTES: - ber->ber_end = ber->ber_ptr + *((ber_len_t *)value); - break; - case LBER_OPT_TOTAL_BYTES: - ber->ber_end = ber->ber_buf + *((ber_len_t *)value); - break; - case LBER_OPT_BYTES_TO_WRITE: - ber->ber_ptr = ber->ber_buf + *((ber_len_t *)value); - break; - default: - return( -1 ); - } - - return( 0 ); -} - -/* - * return 0 on success and -1 on error - */ -int -LDAP_CALL -ber_get_option( struct berelement *ber, int option, void *value ) -{ - /* - * memory callocation callbacks are global, so it is OK to pass - * NULL for ber. Handle this as a special case - */ - if ( option == LBER_OPT_MEMALLOC_FN_PTRS ) { - /* struct copy */ - *((struct lber_memalloc_fns *)value) = nslberi_memalloc_fns; - return( 0 ); - } - - /* - * lber_debug is global, so it is OK to pass - * NULL for ber. Handle this as a special case. - */ - if ( option == LBER_OPT_DEBUG_LEVEL ) { -#ifdef LDAP_DEBUG - *(int *)value = lber_debug; -#endif - return( 0 ); - } - - /* - * lber_bufsize is global, so it is OK to pass - * NULL for ber. Handle this as a special case. - */ - if ( option == LBER_OPT_BUFSIZE ) { - *(size_t *)value = lber_bufsize; - return( 0 ); - } - - /* - * all the rest require a non-NULL ber - */ - if ( !NSLBERI_VALID_BERELEMENT_POINTER( ber )) { - return( -1 ); - } - - switch ( option ) { - case LBER_OPT_USE_DER: - case LBER_OPT_TRANSLATE_STRINGS: - *((int *) value) = (ber->ber_options & option); - break; - case LBER_OPT_REMAINING_BYTES: - *((ber_len_t *) value) = ber->ber_end - ber->ber_ptr; - break; - case LBER_OPT_TOTAL_BYTES: - *((ber_len_t *) value) = ber->ber_end - ber->ber_buf; - break; - case LBER_OPT_BYTES_TO_WRITE: - *((ber_len_t *) value) = ber->ber_ptr - ber->ber_buf; - break; - default: - return( -1 ); - } - - return( 0 ); -} - -/* - * return 0 on success and -1 on error - */ -int -LDAP_CALL -ber_sockbuf_set_option( Sockbuf *sb, int option, void *value ) -{ - struct lber_x_ext_io_fns *extiofns; - - if ( !NSLBERI_VALID_SOCKBUF_POINTER( sb )) { - return( -1 ); - } - - /* check for a NULL value for certain options. */ - if (NULL == value) { - switch ( option ) { - case LBER_SOCKBUF_OPT_TO_FILE: - case LBER_SOCKBUF_OPT_TO_FILE_ONLY: - case LBER_SOCKBUF_OPT_NO_READ_AHEAD: - case LBER_SOCKBUF_OPT_READ_FN: - case LBER_SOCKBUF_OPT_WRITE_FN: - case LBER_SOCKBUF_OPT_EXT_IO_FNS: - case LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE: - /* do nothing - it's OK to have a NULL value for these options */ - break; - default: - return( -1 ); - } - } - - switch ( option ) { - case LBER_SOCKBUF_OPT_VALID_TAG: - sb->sb_valid_tag= *((ber_tag_t *) value); - /* use NULL to reset */ - if ( value != NULL ) { - sb->sb_options |= option; - } else { - sb->sb_options &= ~option; - } - break; - case LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE: - if ( value != NULL ) { - sb->sb_max_incoming = *((ber_len_t *) value); - sb->sb_options |= option; - } else { - /* setting the max incoming to 0 seems to be the only - way to tell the callers of ber_sockbuf_get_option - that this option isn't set. */ - sb->sb_max_incoming = 0; - sb->sb_options &= ~option; - } - break; - case LBER_SOCKBUF_OPT_TO_FILE: - case LBER_SOCKBUF_OPT_TO_FILE_ONLY: - case LBER_SOCKBUF_OPT_NO_READ_AHEAD: - if ( value != NULL ) { - sb->sb_options |= option; - } else { - sb->sb_options &= ~option; - } - break; - case LBER_SOCKBUF_OPT_DESC: - sb->sb_sd = *((LBER_SOCKET *) value); - break; - case LBER_SOCKBUF_OPT_COPYDESC: - sb->sb_copyfd = *((LBER_SOCKET *) value); - break; - case LBER_SOCKBUF_OPT_READ_FN: - sb->sb_io_fns.lbiof_read = (LDAP_IOF_READ_CALLBACK *) value; - nslberi_install_compat_io_fns( sb ); - break; - case LBER_SOCKBUF_OPT_WRITE_FN: - sb->sb_io_fns.lbiof_write = (LDAP_IOF_WRITE_CALLBACK *) value; - nslberi_install_compat_io_fns( sb ); - break; - case LBER_SOCKBUF_OPT_EXT_IO_FNS: - extiofns = (struct lber_x_ext_io_fns *) value; - if ( extiofns == NULL ) { /* remove */ - (void)memset( (char *)&sb->sb_ext_io_fns, '\0', - sizeof(sb->sb_ext_io_fns )); - } else if ( extiofns->lbextiofn_size - == LBER_X_EXTIO_FNS_SIZE ) { - /* struct copy */ - sb->sb_ext_io_fns = *extiofns; - } else if ( extiofns->lbextiofn_size - == LBER_X_EXTIO_FNS_SIZE_REV0 ) { - /* backwards compatiblity for older struct */ - sb->sb_ext_io_fns.lbextiofn_size = - LBER_X_EXTIO_FNS_SIZE; - sb->sb_ext_io_fns.lbextiofn_read = - extiofns->lbextiofn_read; - sb->sb_ext_io_fns.lbextiofn_write = - extiofns->lbextiofn_write; - sb->sb_ext_io_fns.lbextiofn_writev = NULL; - sb->sb_ext_io_fns.lbextiofn_socket_arg = - extiofns->lbextiofn_socket_arg; - } else { - return( -1 ); - } - break; - case LBER_SOCKBUF_OPT_SOCK_ARG: - sb->sb_ext_io_fns.lbextiofn_socket_arg = - (struct lextiof_socket_private *) value; - break; - default: - return( -1 ); - } - - return( 0 ); -} - -/* - * return 0 on success and -1 on error - */ -int -LDAP_CALL -ber_sockbuf_get_option( Sockbuf *sb, int option, void *value ) -{ - struct lber_x_ext_io_fns *extiofns; - - if ( !NSLBERI_VALID_SOCKBUF_POINTER( sb ) || (NULL == value)) { - return( -1 ); - } - - switch ( option ) { - case LBER_SOCKBUF_OPT_VALID_TAG: - *((ber_tag_t *) value) = sb->sb_valid_tag; - break; - case LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE: - *((ber_len_t *) value) = sb->sb_max_incoming; - break; - case LBER_SOCKBUF_OPT_TO_FILE: - case LBER_SOCKBUF_OPT_TO_FILE_ONLY: - case LBER_SOCKBUF_OPT_NO_READ_AHEAD: - *((int *) value) = (sb->sb_options & option); - break; - case LBER_SOCKBUF_OPT_DESC: - *((LBER_SOCKET *) value) = sb->sb_sd; - break; - case LBER_SOCKBUF_OPT_COPYDESC: - *((LBER_SOCKET *) value) = sb->sb_copyfd; - break; - case LBER_SOCKBUF_OPT_READ_FN: - *((LDAP_IOF_READ_CALLBACK **) value) - = sb->sb_io_fns.lbiof_read; - break; - case LBER_SOCKBUF_OPT_WRITE_FN: - *((LDAP_IOF_WRITE_CALLBACK **) value) - = sb->sb_io_fns.lbiof_write; - break; - case LBER_SOCKBUF_OPT_EXT_IO_FNS: - extiofns = (struct lber_x_ext_io_fns *) value; - if ( extiofns == NULL ) { - return( -1 ); - } else if ( extiofns->lbextiofn_size - == LBER_X_EXTIO_FNS_SIZE ) { - /* struct copy */ - *extiofns = sb->sb_ext_io_fns; - } else if ( extiofns->lbextiofn_size - == LBER_X_EXTIO_FNS_SIZE_REV0 ) { - /* backwards compatiblity for older struct */ - extiofns->lbextiofn_read = sb->sb_ext_io_fns.lbextiofn_read; - extiofns->lbextiofn_write = sb->sb_ext_io_fns.lbextiofn_write; - extiofns->lbextiofn_socket_arg = sb->sb_ext_io_fns.lbextiofn_socket_arg; - } else { - return( -1 ); - } - break; - case LBER_SOCKBUF_OPT_SOCK_ARG: - *((struct lextiof_socket_private **)value) = sb->sb_ext_io_fns.lbextiofn_socket_arg; - break; - default: - return( -1 ); - } - - return( 0 ); -} - - -/* new dboreham code below: */ - -struct byte_buffer { - unsigned char *p; - int offset; - int length; -}; -typedef struct byte_buffer byte_buffer; - - -/* This call allocates us a BerElement structure plus some extra memory. - * It returns a pointer to the BerElement, plus a pointer to the extra memory. - * This routine also allocates a ber data buffer within the same block, thus - * saving a call to calloc later when we read data. - */ -void* -LDAP_CALL -ber_special_alloc(size_t size, BerElement **ppBer) -{ - char *mem = NULL; - - /* Make sure mem size requested is aligned */ - if (0 != ( size & 0x03 )) { - size += (sizeof(ber_int_t) - (size & 0x03)); - } - - mem = NSLBERI_MALLOC(sizeof(struct berelement) + lber_bufsize + size ); - if (NULL == mem) { - return NULL; - } - *ppBer = (BerElement*) (mem + size); - memset(*ppBer,0,sizeof(struct berelement)); - (*ppBer)->ber_tag = LBER_DEFAULT; - (*ppBer)->ber_buf = mem + size + sizeof(struct berelement); - (*ppBer)->ber_ptr = (*ppBer)->ber_buf; - (*ppBer)->ber_end = (*ppBer)->ber_buf + lber_bufsize; - (*ppBer)->ber_flags = LBER_FLAG_NO_FREE_BUFFER; - return (void*)mem; -} - -void -LDAP_CALL -ber_special_free(void* buf, BerElement *ber) -{ - if (!(ber->ber_flags & LBER_FLAG_NO_FREE_BUFFER)) { - NSLBERI_FREE(ber->ber_buf); - } - NSLBERI_FREE( buf ); -} - -/* Copy up to bytes_to_read bytes from b into return_buffer. - * Returns a count of bytes copied (always >= 0). - */ -static int -read_bytes(byte_buffer *b, unsigned char *return_buffer, int bytes_to_read) -{ - /* copy up to bytes_to_read bytes into the caller's buffer, return the number of bytes copied */ - int bytes_to_copy = 0; - - if (bytes_to_read <= (b->length - b->offset) ) { - bytes_to_copy = bytes_to_read; - } else { - bytes_to_copy = (b->length - b->offset); - } - if (1 == bytes_to_copy) { - *return_buffer = *(b->p+b->offset++); - } else if (bytes_to_copy <= 0) { - bytes_to_copy = 0; /* never return a negative result */ - } else { - SAFEMEMCPY(return_buffer,b->p+b->offset,bytes_to_copy); - b->offset += bytes_to_copy; - } - return bytes_to_copy; -} - -/* return the tag - LBER_DEFAULT returned means trouble */ -static ber_tag_t -get_buffer_tag(byte_buffer *sb ) -{ - unsigned char xbyte; - ber_tag_t tag; - char *tagp; - int i; - - if ( (i = read_bytes( sb, &xbyte, 1 )) != 1 ) { - return( LBER_DEFAULT ); - } - - if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK ) { - return( (ber_uint_t) xbyte ); - } - - tagp = (char *) &tag; - tagp[0] = xbyte; - for ( i = 1; i < sizeof(ber_int_t); i++ ) { - if ( read_bytes( sb, &xbyte, 1 ) != 1 ) - return( LBER_DEFAULT ); - - tagp[i] = xbyte; - - if ( ! (xbyte & LBER_MORE_TAG_MASK) ) - break; - } - - /* tag too big! */ - if ( i == sizeof(ber_int_t) ) - return( LBER_DEFAULT ); - - /* want leading, not trailing 0's */ - return( tag >> (sizeof(ber_int_t) - i - 1) ); -} - -/* Like ber_get_next, but from a byte buffer the caller already has. */ -/* Bytes_Scanned returns the number of bytes we actually looked at in the buffer. */ -/* ber_get_next_buffer is now implemented in terms of ber_get_next_buffer_ext */ -/* and is here for backward compatibility. This new function allows us to pass */ -/* the Sockbuf structure along */ - -ber_uint_t -LDAP_CALL -ber_get_next_buffer( void *buffer, size_t buffer_size, ber_len_t *len, - BerElement *ber, ber_uint_t *Bytes_Scanned ) -{ - return (ber_get_next_buffer_ext( buffer, buffer_size, len, ber, - Bytes_Scanned, NULL)); -} - -/* - * Returns the tag of the message or LBER_ return code if an error occurs. - * - * If there was not enough data in the buffer to complete the message this - * is a "soft" error. In this case, *Bytes_Scanned is set to a positive - * number and return code is set to LBER_DEFAULT. - * - * On overflow condition when the length is either bigger than ber_uint_t - * type or the value preset via LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE option, - * *Bytes_Scanned is set to zero and return code is set to LBER_OVERFLOW. - * - * For backward compatibility errno is also set on these error conditions: - * - * EINVAL - LBER_SOCKBUF_OPT_VALID_TAG option set but tag doesnt match. - * EMSGSIZE - an overflow condition as described above for LBER_OVERFLOW. - */ -ber_uint_t -LDAP_CALL -ber_get_next_buffer_ext( void *buffer, size_t buffer_size, ber_len_t *len, - BerElement *ber, ber_uint_t *Bytes_Scanned, Sockbuf *sock ) -{ - ber_tag_t tag = 0; - ber_len_t netlen; - ber_len_t toread; - unsigned char lc; - ssize_t rc; - int noctets, diff; - byte_buffer sb = {0}; - - - /* - * Any ber element looks like this: tag length contents. - * Assuming everything's ok, we return the tag byte (we - * can assume a single byte), return the length in len, - * and the rest of the undecoded element in buf. - * - * Assumptions: - * 1) small tags (less than 128) - * 2) definite lengths - * 3) primitive encodings used whenever possible - */ - - /* - * first time through - malloc the buffer, set up ptrs, and - * read the tag and the length and as much of the rest as we can - */ - - sb.p = buffer; - sb.length = buffer_size; - - if ( ber->ber_rwptr == NULL ) { - - /* - * First, we read the tag. - */ - - /* if we have been called before with a fragment not - * containing a complete length, we have no rwptr but - * a tag already - */ - if ( ber->ber_tag == LBER_DEFAULT ) { - if ( (tag = get_buffer_tag( &sb )) == LBER_DEFAULT ) { - goto premature_exit; - } - ber->ber_tag = tag; - } - - if((sock->sb_options & LBER_SOCKBUF_OPT_VALID_TAG) && - (ber->ber_tag != sock->sb_valid_tag)) { -#if !defined( macintosh ) && !defined( DOS ) - errno = EINVAL; -#endif - goto error_exit; - } - - /* If we have been called before with an incomplete length, - * the fragment of the length read is in ber->ber_len_contents - * ber->ber_tag_len_read is the # of bytes of the length available - * from a previous fragment - */ - - if (ber->ber_tag_len_read) { - int nbytes; - - noctets = ((ber->ber_len_contents[0]) & 0x7f); - diff = noctets + 1 /* tag */ - ber->ber_tag_len_read; - - if ( (nbytes = read_bytes( &sb, (unsigned char *) &ber->ber_len_contents[0] + - ber->ber_tag_len_read, diff )) != diff ) { - - if (nbytes > 0) - ber->ber_tag_len_read+=nbytes; - - goto premature_exit; - } - *len = get_ber_len(ber); /* cast ber->ber_len_contents to unsigned long */ - - } else { - /* - * Next, read the length. The first byte contains the length - * of the length. If bit 8 is set, the length is the long - * form, otherwise it's the short form. We don't allow a - * length that's greater than what we can hold in an unsigned - * long. - */ - - *len = netlen = 0; - if ( read_bytes( &sb, &lc, 1 ) != 1 ) { - goto premature_exit; - } - if ( lc & 0x80 ) { - int nbytes; - - noctets = (lc & 0x7f); - if ( noctets > sizeof(ber_uint_t) ) { -#if !defined( macintosh ) && !defined( DOS ) - errno = EMSGSIZE; -#endif - *Bytes_Scanned = 0; - return(LBER_OVERFLOW); - } - diff = sizeof(ber_uint_t) - noctets; - if ( (nbytes = read_bytes( &sb, (unsigned char *)&netlen + diff, - noctets )) != noctets ) { - /* - * The length is in long form and we don't get it in one - * fragment, so stash partial length in the ber element - * for later use - */ - - ber->ber_tag_len_read = nbytes + 1; - ber->ber_len_contents[0]=lc; - memset(&(ber->ber_len_contents[1]), 0, sizeof(ber_uint_t)); - SAFEMEMCPY(&(ber->ber_len_contents[1]), (unsigned char *)&netlen + diff, nbytes); - - goto premature_exit; - } - *len = LBER_NTOHL( netlen ); - } else { - *len = lc; - } - } - - ber->ber_len = *len; - /* length fully decoded */ - ber->ber_tag_len_read=0; - /* - * Finally, malloc a buffer for the contents and read it in. - * It's this buffer that's passed to all the other ber decoding - * routines. - */ - -#if defined( DOS ) && !defined( _WIN32 ) - if ( *len > 65535 ) { /* DOS can't allocate > 64K */ - goto premature_exit; - } -#endif /* DOS && !_WIN32 */ - - if ( (sock != NULL) && - ( sock->sb_options & LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE ) - && (*len > sock->sb_max_incoming) ) { -#if !defined( macintosh ) && !defined( DOS ) - errno = EMSGSIZE; -#endif - *Bytes_Scanned = 0; - return( LBER_OVERFLOW ); - } - - if ( ber->ber_buf + *len > ber->ber_end ) { - if ( nslberi_ber_realloc( ber, *len ) != 0 ) - goto error_exit; - } - ber->ber_ptr = ber->ber_buf; - ber->ber_end = ber->ber_buf + *len; - ber->ber_rwptr = ber->ber_buf; - } - - toread = (ber_len_t)ber->ber_end - (ber_len_t)ber->ber_rwptr; - do { - if ( (rc = read_bytes( &sb, (unsigned char *)ber->ber_rwptr, - (ber_int_t)toread )) <= 0 ) { - goto premature_exit; - } - - toread -= rc; - ber->ber_rwptr += rc; - } while ( toread > 0 ); - - *len = ber->ber_len; - *Bytes_Scanned = sb.offset; - return( ber->ber_tag ); - -premature_exit: - /* - * we're here because we hit the end of the buffer before seeing - * all of the PDU - */ - *Bytes_Scanned = sb.offset; - return(LBER_DEFAULT); - -error_exit: - *Bytes_Scanned = 0; - return(LBER_DEFAULT); -} - - -/* The ber_flatten routine allocates a struct berval whose contents - * are a BER encoding taken from the ber argument. The bvPtr pointer - * points to the returned berval, which must be freed using - * ber_bvfree(). This routine returns 0 on success and -1 on error. - * The use of ber_flatten on a BerElement in which all '{' and '}' - * format modifiers have not been properly matched can result in a - * berval whose contents are not a valid BER encoding. - * Note that the ber_ptr is not modified. - */ -int -LDAP_CALL -ber_flatten( BerElement *ber, struct berval **bvPtr ) -{ - struct berval *new; - ber_len_t len; - - /* allocate a struct berval */ - if ( (new = (struct berval *)NSLBERI_MALLOC( sizeof(struct berval) )) - == NULL ) { - return( -1 ); - } - - /* - * Copy everything from the BerElement's ber_buf to ber_ptr - * into the berval structure. - */ - if ( ber == NULL ) { - new->bv_val = NULL; - new->bv_len = 0; - } else { - len = ber->ber_ptr - ber->ber_buf; - if ( ( new->bv_val = (char *)NSLBERI_MALLOC( len + 1 )) == NULL ) { - ber_bvfree( new ); - return( -1 ); - } - SAFEMEMCPY( new->bv_val, ber->ber_buf, (size_t)len ); - new->bv_val[len] = '\0'; - new->bv_len = len; - } - - /* set bvPtr pointer to point to the returned berval */ - *bvPtr = new; - - return( 0 ); -} - - -/* - * The ber_init function constructs and returns a new BerElement - * containing a copy of the data in the bv argument. ber_init - * returns the null pointer on error. - */ -BerElement * -LDAP_CALL -ber_init( const struct berval *bv ) -{ - BerElement *ber; - - /* construct BerElement */ - if (( ber = ber_alloc_t( 0 )) != NULLBER ) { - /* copy data from the bv argument into BerElement */ - /* XXXmcs: had to cast unsigned long bv_len to long */ - if ( (ber_write ( ber, bv->bv_val, bv->bv_len, 0 )) - != (ber_slen_t)bv->bv_len ) { - ber_free( ber, 1 ); - return( NULL ); - } - } - - /* - * reset ber_ptr back to the beginning of buffer so that this new - * and initialized ber element can be READ - */ - ber_reset( ber, 1); - - /* - * return a ptr to a new BerElement containing a copy of the data - * in the bv argument or a null pointer on error - */ - return( ber ); -} - - -/* - * memory allocation functions. - */ -void * -nslberi_malloc( size_t size ) -{ - return( nslberi_memalloc_fns.lbermem_malloc == NULL ? - malloc( size ) : - nslberi_memalloc_fns.lbermem_malloc( size )); -} - - -void * -nslberi_calloc( size_t nelem, size_t elsize ) -{ - return( nslberi_memalloc_fns.lbermem_calloc == NULL ? - calloc( nelem, elsize ) : - nslberi_memalloc_fns.lbermem_calloc( nelem, elsize )); -} - - -void * -nslberi_realloc( void *ptr, size_t size ) -{ - return( nslberi_memalloc_fns.lbermem_realloc == NULL ? - realloc( ptr, size ) : - nslberi_memalloc_fns.lbermem_realloc( ptr, size )); -} - - -void -nslberi_free( void *ptr ) -{ - if ( nslberi_memalloc_fns.lbermem_free == NULL ) { - free( ptr ); - } else { - nslberi_memalloc_fns.lbermem_free( ptr ); - } -} - - -/* - ****************************************************************************** - * functions to bridge the gap between new extended I/O functions that are - * installed using ber_sockbuf_set_option( ..., LBER_SOCKBUF_OPT_EXT_IO_FNS, - * ... ). - * - * the basic strategy is to use the new extended arg to hold a pointer to the - * Sockbuf itself so we can find the old functions and call them. - * note that the integer socket s passed in is not used. we use the sb_sd - * from the Sockbuf itself because it is the correct type. - */ -static int -nslberi_extread_compat( int s, void *buf, int len, - struct lextiof_socket_private *arg ) -{ - Sockbuf *sb = (Sockbuf *)arg; - - return( sb->sb_io_fns.lbiof_read( sb->sb_sd, buf, len )); -} - - -static int -nslberi_extwrite_compat( int s, const void *buf, int len, - struct lextiof_socket_private *arg ) -{ - Sockbuf *sb = (Sockbuf *)arg; - - return( sb->sb_io_fns.lbiof_write( sb->sb_sd, buf, len )); -} - - -/* - * Install I/O compatiblity functions. This can't fail. - */ -static void -nslberi_install_compat_io_fns( Sockbuf *sb ) -{ - sb->sb_ext_io_fns.lbextiofn_size = LBER_X_EXTIO_FNS_SIZE; - sb->sb_ext_io_fns.lbextiofn_read = nslberi_extread_compat; - sb->sb_ext_io_fns.lbextiofn_write = nslberi_extwrite_compat; - sb->sb_ext_io_fns.lbextiofn_writev = NULL; - sb->sb_ext_io_fns.lbextiofn_socket_arg = (void *)sb; -} -/* - * end of compat I/O functions - ****************************************************************************** - */
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap/Makefile.in
Deleted
@@ -1,372 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla Communicator client code, released -# March 31, 1998. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-1999 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -MOD_DEPTH = ../../.. -srcdir = @srcdir@ -topsrcdir = @top_srcdir@ -SASL_CFLAGS = @SASL_CFLAGS@ -SASL_LIBS = @SASL_LIBS@ -HAVE_SASL = @HAVE_SASL@ - -include $(MOD_DEPTH)/config/autoconf.mk -include $(topsrcdir)/build.mk - -SRCS = abandon.c \ - add.c \ - authzidctrl.c \ - bind.c \ - cache.c \ - charray.c \ - charset.c \ - compare.c \ - compat.c \ - control.c \ - countvalues.c \ - delete.c \ - disptmpl.c \ - dsparse.c \ - error.c \ - extendop.c \ - free.c \ - freevalues.c \ - friendly.c \ - getattr.c \ - getdn.c \ - getdxbyname.c \ - geteffectiverightsctrl.c \ - getentry.c \ - getfilter.c \ - getoption.c \ - getvalues.c \ - memcache.c \ - message.c \ - modify.c \ - open.c \ - os-ip.c \ - proxyauthctrl.c \ - psearch.c \ - pwmodext.c \ - pwpctrl.c \ - referral.c \ - regex.c \ - rename.c \ - request.c \ - reslist.c \ - result.c \ - saslbind.c \ - sbind.c \ - search.c \ - setoption.c \ - sort.c \ - sortctrl.c \ - srchpref.c \ - tmplout.c \ - ufn.c \ - unbind.c \ - unescape.c \ - url.c \ - userstatusctrl.c \ - utf8.c \ - vlistctrl.c \ - whoami.c - -ifeq ($(HAVE_SASL), 1) -SRCS += saslio.c -endif - -ifeq ($(OS_ARCH),WINNT) -SRCS += dllmain.c \ - mozock.c -endif -RELEASE_LIBS = $(SHARED_LIBRARY) $(DLLLDAP) - -REALOBJS = $(SRCS:.c=.$(OBJ_SUFFIX)) -OBJS = $(addprefix $(OBJDIR_NAME)/, $(REALOBJS)) - -DISTHDIR = $(DIST)/public/ldap -HDIR = $(topsrcdir)/ldap/include - -LIBLDAP = $(addprefix $(OBJDIR_NAME)/, $(LIB_PREFIX)$(LDAP_LIBNAME).$(LIB_SUFFIX)) -DLLLDAP = $(addprefix $(OBJDIR_NAME)/, $(LIB_PREFIX)$(LDAP_LIBNAME).$(DLL_SUFFIX)) - -INSTALLDIR = $(DIST)/$(OBJDIR_NAME) - -include $(topsrcdir)/config/rules.mk - -GARBAGE += $(LIBLDAP) $(DLLLDAP) - -LOCAL_INCLUDES = -I$(PUBLIC)/nspr -INCLUDES += -I$(DISTHDIR) -I$(HDIR) -I$(INSTALLDIR)/public - -ifeq ($(HAVE_SASL), 1) -INCLUDES += $(SASL_CFLAGS) -endif - -DEFINES += $(DEFS) -UMOZILLA_CLIENT - -ifdef USE_PTHREADS -DEFINES += -DUSE_PTHREADS -endif - -ifeq ($(OS_ARCH),WINNT) -PLATFORMCFLAGS = -DNEEDPROTOS -else -PLATFORMCFLAGS = -DUSE_WAITPID -DNEEDPROTOS -endif -THREADS = -THREADSLIB = - -ETCFILENAMES = ldapfilter.conf \ - ldapfriendly \ - ldapsearchprefs.conf \ - ldaptemplates.conf \ - $(NULL) - -ETCDIR = $(INSTALLDIR)/etc -ETCFILES = $(addprefix $(srcdir)/, $(ETCFILENAMES)) - -# -# if you want things to run in a different directory from where they -# are installed, set this accordingly (this path gets compiled into a -# few binaries). otherwise, leave it alone. -# -RUNTIMEETCDIR = $(ETCDIR) - -# -# shared library symbol export definitions -# -ifeq ($(USE_DLL_EXPORTS_FILE), 1) -ifeq ($(OS_ARCH), WINNT) -GENEXPORTS=cmd /c $(PERL) $(topsrcdir)/ldap/build/genexports.pl -else -GENEXPORTS=$(PERL) $(topsrcdir)/ldap/build/genexports.pl -endif - -# variable definitions for exported symbols -ifeq ($(OS_ARCH), WINNT) - LDAP_EXPORT_DEFS= $(srcdir)/../msdos/winsock/nsldap32.def -else -ifeq ($(OS_ARCH), OS2) - LDAP_EXPORT_DEFS= $(OBJDIR_NAME)/libldap.def -else - LDAP_EXPORT_DEFS= $(OBJDIR_NAME)/libldap.exp -endif -GARBAGE += $(LDAP_EXPORT_DEFS) -endif - -LDAP_EXPORT_FLAGS=$(addprefix $(DLLEXPORTS_PREFIX), $(LDAP_EXPORT_DEFS)) - -GENEXPARGS=$(BUILD_DEBUG) $(LDAPVERS_SUFFIX) $(LDAPVERS) -endif # USE_DLL_EXPORTS_FILE - -ifeq ($(OS_ARCH), SunOS) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -endif - -ifeq ($(OS_ARCH), IRIX) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) $(OS_LIBS) -lc -endif - -ifeq ($(OS_ARCH), Linux) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -endif - -ifeq ($(OS_ARCH), WINNT) -ifdef NS_USE_GCC -EXTRA_DLL_LIBS=-L$(dist_libdir) -l$(LBER_LIBNAME) -else -EXTRA_LIBS =wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib \ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \ - rpcrt4.lib uuid.lib winmm.lib -EXTRA_LIBS += $(dist_libdir)/$(LDIF_LIBNAME).lib -EXTRA_LIBS += $(dist_libdir)/$(LBER_LIBNAME).lib -endif -endif - -ifeq ($(MOZ_OS2_TOOLS),VACPP) -EXTRA_LIBS = $(dist_libdir)/$(LDIF_LIBNAME).lib -EXTRA_LIBS += $(dist_libdir)/$(LBER_LIBNAME).lib -EXTRA_LIBS += $(OS_LIBS) -endif -ifeq ($(MOZ_OS2_TOOLS),EMX) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) $(OS_LIBS) -endif - -ifeq ($(OS_ARCH), OSF1) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -EXTRA_LIBS += -L/usr/lib -lcxx -lpthread -lrt -lmach -lexc -endif - -ifeq ($(OS_ARCH), AIX) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -EXTRA_LIBS += -ldl -brtl -lpthreads -lc_r -lm -endif - -ifeq ($(OS_ARCH), HP-UX) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -ifdef USE_PTHREADS -EXTRA_LIBS += -ldld -lm -lpthread -else -EXTRA_LIBS += -ldld -lm -endif -endif - -ifeq ($(OS_ARCH), Darwin) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -endif - -ifeq ($(OS_ARCH), OpenVMS) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) $(OS_LIBS) -SHARED_LIBRARY_LIBS = $(dist_libdir)/lib$(LBER_LIBNAME).a -endif - -ifeq ($(OS_ARCH), BeOS) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -lbe -endif - -ifeq ($(OS_ARCH), NetBSD) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -endif - -ifeq ($(OS_ARCH), OpenBSD) -EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -pthread -endif - -ifeq ($(HAVE_SASL), 1) -EXTRA_LIBS += $(SASL_LINK) -endif - -########################################################################### - -ifeq ($(USE_DLL_EXPORTS_FILE), 1) -# recursive gmake rule to create exported symbols file -$(LDAP_EXPORT_DEFS):: $(srcdir)/../libldap.ex -ifeq ($(OS_ARCH), WINNT) - $(GENEXPORTS) Win32 $(srcdir)/../msdos/winsock/nsldap32.tdf $< $(GENEXPARGS) > $@ -else -ifeq ($(OS_ARCH), OS2) - echo LIBRARY $(LDAP_LIBNAME) INITINSTANCE TERMINSTANCE > $@ - echo PROTMODE >> $@ - echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@ - echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@ - echo EXPORTS >> $@ - $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) >> $@ -else - $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) > $@ -endif -endif -endif # USE_DLL_EXPORTS_FILE - -versiont.c: Makefile.client Version.c - @$(RM) $@ - @(u="$${USER-root}" v="$(shell cat ../../build/version)" d="$(shell pwd)" \ - h="$(shell hostname)" t="$(shell date)"; $(SED) -e "s|%WHEN%|$${t}|" \ - -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ - -e "s|%VERSION%|$${v}|" \ - < Version.c > $@) - -# Set the default sources for the export target -EXPDEPS = $(OBJDIR_NAME) $(LIBDIR) $(OBJS) $(LIBLDAP) $(DLLLDAP) -# Remove the LIB source if on win32 and using MSVC -# This avoids problems with -jX builds where 'link' will make both the -# .dll and .lib files in one pass -ifeq ($(OS_ARCH), WINNT) -ifeq ($(LD),link) -EXPDEPS = $(OBJDIR_NAME) $(LIBDIR) $(OBJS) $(DLLLDAP) -endif -endif - -export:: $(EXPDEPS) - -ltest:: $(LIBLDAP) test.o - $(LINK_EXE) test.o - -$(LIBDIR): - $(MKDIR) $(LIBDIR) - -$(LIBLDAP): $(OBJS) $(LIBDIR) $(LDAP_EXPORT_DEFS) - @echo ======= making $(LIBLDAP) -ifdef SO_FILES_TO_REMOVE - -$(RM) $(SO_FILES_TO_REMOVE) -endif -ifneq (,$(filter AIX Linux HP-UX Darwin BeOS QNX NetBSD OSF1 OpenBSD, $(OS_ARCH))) - $(LINK_LIB) -else -ifeq ($(OS_ARCH),OS2) -# create import library for OS/2 - rm -f $@ - $(IMPLIB) $@ $(LDAP_EXPORT_DEFS) -else - $(LINK_LIB) -endif -endif - -$(DLLLDAP): $(OBJS) $(LIBDIR) $(LDAP_EXPORT_DEFS) - @echo ======= making $(DLLLDAP) -ifdef SO_FILES_TO_REMOVE - -$(RM) $(SO_FILES_TO_REMOVE) -endif - $(LINK_DLL) $(LDAP_EXPORT_FLAGS) $(EXTRA_LIBS) - -veryclean:: clean - -# the $(dist_bindir) line is for the mozilla client, which for reasons -# unknown wants shared libraries in /bin also -# -# Set the default sources for the export target -EXPDEPS2 = $(LIBLDAP) $(DLLLDAP) -# Remove the LIB source if on win32 and using MSVC -# This avoids problems with -jX builds where 'link' will make both the -# .dll and .lib files in one pass -ifeq ($(OS_ARCH), WINNT) -ifeq ($(LD),link) -EXPDEPS2 = $(DLLLDAP) -endif -endif - -export:: $(EXPDEPS2) -ifdef MKSHLIB - $(INSTALL) -m 444 $(LIBLDAP) $(dist_libdir) - $(INSTALL) -m 444 $(DLLLDAP) $(dist_libdir) - $(INSTALL) -m 444 $(DLLLDAP) $(dist_bindir) -endif -ifeq ($(OS_ARCH), WINNT) - $(INSTALL) -m 444 $(LIBLDAP) $(dist_libdir) - $(INSTALL) -m 444 $(DLLLDAP) $(dist_libdir) -endif - $(INSTALL) -m 444 $(ETCFILES) $(ETCDIR)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap/authzidctrl.c
Deleted
@@ -1,157 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Sun LDAP C SDK. - * - * The Initial Developer of the Original Code is Sun Microsystems, Inc. - * - * Portions created by Sun Microsystems, Inc are Copyright (C) 2005 - * Sun Microsystems, Inc. All Rights Reserved. - * - * Contributor(s): abobrov@sun.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "ldap-int.h" - -/* ldap_create_authzid_control: - -Parameters are - -ld LDAP pointer to the desired connection - -ctl_iscritical Indicates whether the control is critical of not. - If this field is non-zero, the operation will only be - carried out if the control is recognized by the server - and/or client - -ctrlp the address of a place to put the constructed control -*/ - -int -LDAP_CALL -ldap_create_authzid_control ( - LDAP *ld, - const char ctl_iscritical, - LDAPControl **ctrlp - ) -{ - int rc; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - return( LDAP_PARAM_ERROR ); - } - - if ( ctrlp == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return ( LDAP_PARAM_ERROR ); - } - - rc = nsldapi_build_control( LDAP_CONTROL_AUTHZID_REQ, - NULL, NULL, ctl_iscritical, ctrlp ); - - LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); - return( rc ); -} - -/* ldap_parse_authzid_control: - -Parameters are - -ld LDAP pointer to the desired connection - -ctrlp An array of controls obtained from calling - ldap_parse_result on the set of results - returned by the server - -authzid authorization identity, as defined in - RFC 2829, section 9. -*/ - -int -LDAP_CALL -ldap_parse_authzid_control ( - LDAP *ld, - LDAPControl **ctrlp, - char **authzid - ) -{ - int i, foundAUTHZIDControl; - char *authzidp = NULL; - LDAPControl *AUTHZIDCtrlp = NULL; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) ) { - return( LDAP_PARAM_ERROR ); - } - - /* find the control in the list of controls if it exists */ - if ( ctrlp == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); - return ( LDAP_CONTROL_NOT_FOUND ); - } - foundAUTHZIDControl = 0; - for ( i = 0; (( ctrlp[i] != NULL ) && ( !foundAUTHZIDControl )); i++ ) { - foundAUTHZIDControl = !strcmp( ctrlp[i]->ldctl_oid, - LDAP_CONTROL_AUTHZID_RES ); - } - - /* - * The control is only included in a bind response if the resultCode - * for the bind operation is success. - */ - if ( !foundAUTHZIDControl ) { - LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); - return ( LDAP_CONTROL_NOT_FOUND ); - } else { - /* let local var point to the control */ - AUTHZIDCtrlp = ctrlp[i-1]; - } - - /* - * If the bind request succeeded and resulted in an identity (not anonymous), - * the controlValue contains the authorization identity (authzid), as - * defined in [AUTH] section 9, granted to the requestor. If the bind - * request resulted in an anonymous association, the controlValue field - * is a string of zero length. If the bind request resulted in more - * than one authzid, the primary authzid is returned in the controlValue - * field. - */ - if ( AUTHZIDCtrlp && AUTHZIDCtrlp->ldctl_value.bv_val && - AUTHZIDCtrlp->ldctl_value.bv_len ) { - authzidp = ( (char *)NSLDAPI_MALLOC( - ( AUTHZIDCtrlp->ldctl_value.bv_len + 1 ) ) ); - if ( authzidp == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); - return( LDAP_NO_MEMORY ); - } - STRLCPY( authzidp, AUTHZIDCtrlp->ldctl_value.bv_val, - ( AUTHZIDCtrlp->ldctl_value.bv_len + 1 ) ); - *authzid = authzidp; - } else { - authzid = NULL; - } - - return( LDAP_SUCCESS ); -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap/getdn.c
Deleted
@@ -1,369 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright (c) 1994 Regents of the University of Michigan. - * All rights reserved. - */ -/* - * getdn.c - */ - -#if 0 -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif -#endif - -#include "ldap-int.h" - -char * -LDAP_CALL -ldap_get_dn( LDAP *ld, LDAPMessage *entry ) -{ - char *dn; - struct berelement tmp; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_get_dn\n", 0, 0, 0 ); - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - return( NULL ); /* punt */ - } - - if ( !NSLDAPI_VALID_LDAPMESSAGE_ENTRY_POINTER( entry )) { - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return( NULL ); - } - - tmp = *entry->lm_ber; /* struct copy */ - if ( ber_scanf( &tmp, "{a", &dn ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - return( NULL ); - } - - return( dn ); -} - -char * -LDAP_CALL -ldap_dn2ufn( const char *dn ) -{ - char *p, *ufn, *r; - size_t plen; - int state; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_dn2ufn\n", 0, 0, 0 ); - - if ( dn == NULL ) { - dn = ""; - } - - if ( ldap_is_dns_dn( dn ) || ( p = strchr( dn, '=' )) == NULL ) - return( nsldapi_strdup( (char *)dn )); - - ufn = nsldapi_strdup( ++p ); - -#define INQUOTE 1 -#define OUTQUOTE 2 - state = OUTQUOTE; - for ( p = ufn, r = ufn; *p; p += plen ) { - plen = 1; - switch ( *p ) { - case '\\': - if ( *++p == '\0' ) - plen=0; - else { - *r++ = '\\'; - r += (plen = LDAP_UTF8COPY(r,p)); - } - break; - case '"': - if ( state == INQUOTE ) - state = OUTQUOTE; - else - state = INQUOTE; - *r++ = *p; - break; - case ';': - case ',': - if ( state == OUTQUOTE ) - *r++ = ','; - else - *r++ = *p; - break; - case '=': - if ( state == INQUOTE ) - *r++ = *p; - else { - char *rsave = r; - LDAP_UTF8DEC(r); - *rsave = '\0'; - while ( !ldap_utf8isspace( r ) && *r != ';' - && *r != ',' && r > ufn ) - LDAP_UTF8DEC(r); - LDAP_UTF8INC(r); - - if ( strcasecmp( r, "c" ) - && strcasecmp( r, "o" ) - && strcasecmp( r, "ou" ) - && strcasecmp( r, "st" ) - && strcasecmp( r, "l" ) - && strcasecmp( r, "dc" ) - && strcasecmp( r, "uid" ) - && strcasecmp( r, "cn" ) ) { - r = rsave; - *r++ = '='; - } - } - break; - default: - r += (plen = LDAP_UTF8COPY(r,p)); - break; - } - } - *r = '\0'; - - return( ufn ); -} - -char ** -LDAP_CALL -ldap_explode_dns( const char *dn ) -{ - int ncomps, maxcomps; - char *s, *cpydn; - char **rdns; -#ifdef HAVE_STRTOK_R /* defined in portable.h */ - char *lasts; -#endif - - if ( dn == NULL ) { - dn = ""; - } - - if ( (rdns = (char **)NSLDAPI_MALLOC( 8 * sizeof(char *) )) == NULL ) { - return( NULL ); - } - - maxcomps = 8; - ncomps = 0; - cpydn = nsldapi_strdup( (char *)dn ); - for ( s = STRTOK( cpydn, "@.", &lasts ); s != NULL; - s = STRTOK( NULL, "@.", &lasts ) ) { - if ( ncomps == maxcomps ) { - maxcomps *= 2; - if ( (rdns = (char **)NSLDAPI_REALLOC( rdns, maxcomps * - sizeof(char *) )) == NULL ) { - NSLDAPI_FREE( cpydn ); - return( NULL ); - } - } - rdns[ncomps++] = nsldapi_strdup( s ); - } - rdns[ncomps] = NULL; - NSLDAPI_FREE( cpydn ); - - return( rdns ); -} - -#define LDAP_DN 1 -#define LDAP_RDN 2 - -static char ** -ldap_explode( const char *dn, const int notypes, const int nametype ) -{ - char *p, *q, *rdnstart, **rdns = NULL; - size_t plen = 0; - int state = 0; - int count = 0; - int startquote = 0; - int endquote = 0; - int len = 0; - int goteq = 0; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_explode\n", 0, 0, 0 ); - - if ( dn == NULL ) { - dn = ""; - } - -#if 0 - if ( ldap_is_dns_dn( dn ) ) { - return( ldap_explode_dns( dn ) ); - } -#endif - - while ( ldap_utf8isspace( (char *)dn )) { /* ignore leading spaces */ - ++dn; - } - - p = rdnstart = (char *) dn; - state = OUTQUOTE; - - do { - p += plen; - plen = 1; - switch ( *p ) { - case '\\': - if ( *++p == '\0' ) - p--; - else - plen = LDAP_UTF8LEN(p); - break; - case '"': - if ( state == INQUOTE ) - state = OUTQUOTE; - else - state = INQUOTE; - break; - case '+': if ( nametype != LDAP_RDN ) break; - case ';': - case ',': - case '\0': - if ( state == OUTQUOTE ) { - /* - * semicolon and comma are not valid RDN - * separators. - */ - if ( nametype == LDAP_RDN && - ( *p == ';' || *p == ',' || !goteq)) { - ldap_charray_free( rdns ); - return NULL; - } - if ( (*p == ',' || *p == ';') && !goteq ) { - /* If we get here, we have a case similar - * to <attr>=<value>,<string>,<attr>=<value> - * This is not a valid dn */ - ldap_charray_free( rdns ); - return NULL; - } - goteq = 0; - ++count; - if ( rdns == NULL ) { - if (( rdns = (char **)NSLDAPI_MALLOC( 8 - * sizeof( char *))) == NULL ) - return( NULL ); - } else if ( count >= 8 ) { - if (( rdns = (char **)NSLDAPI_REALLOC( - rdns, (count+1) * - sizeof( char *))) == NULL ) - return( NULL ); - } - rdns[ count ] = NULL; - endquote = 0; - if ( notypes ) { - for ( q = rdnstart; - q < p && *q != '='; ++q ) { - ; - } - if ( q < p ) { /* *q == '=' */ - rdnstart = ++q; - } - if ( *rdnstart == '"' ) { - startquote = 1; - ++rdnstart; - } - - if ( (*(p-1) == '"') && startquote ) { - endquote = 1; - --p; - } - } - - len = p - rdnstart; - if (( rdns[ count-1 ] = (char *)NSLDAPI_CALLOC( - 1, len + 1 )) != NULL ) { - SAFEMEMCPY( rdns[ count-1 ], rdnstart, - len ); - if ( !endquote ) { - /* trim trailing spaces */ - while ( len > 0 && - ldap_utf8isspace( - &rdns[count-1][len-1] )) { - --len; - } - } - rdns[ count-1 ][ len ] = '\0'; - } - - /* - * Don't forget to increment 'p' back to where - * it should be. If we don't, then we will - * never get past an "end quote." - */ - if ( endquote == 1 ) - p++; - - rdnstart = *p ? p + 1 : p; - while ( ldap_utf8isspace( rdnstart )) - ++rdnstart; - } - break; - case '=': - if ( state == OUTQUOTE ) { - goteq = 1; - } - /* FALL */ - default: - plen = LDAP_UTF8LEN(p); - break; - } - } while ( *p ); - - return( rdns ); -} - -char ** -LDAP_CALL -ldap_explode_dn( const char *dn, const int notypes ) -{ - return( ldap_explode( dn, notypes, LDAP_DN ) ); -} - -char ** -LDAP_CALL -ldap_explode_rdn( const char *rdn, const int notypes ) -{ - return( ldap_explode( rdn, notypes, LDAP_RDN ) ); -} - -int -LDAP_CALL -ldap_is_dns_dn( const char *dn ) -{ - return( dn != NULL && dn[ 0 ] != '\0' && strchr( dn, '=' ) == NULL && - strchr( dn, ',' ) == NULL ); -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap/memcache.c
Deleted
@@ -1,2207 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * - * memcache.c - routines that implement an in-memory cache. - * - * To Do: 1) ber_dup_ext(). - * 2) referrals and reference? - */ - -#include <assert.h> -#include "ldap-int.h" - -/* - * Extra size allocated to BerElement. - * XXXmcs: must match EXBUFSIZ in liblber/io.c? - */ -#define EXTRA_SIZE 1024 - -/* Mode constants for function memcache_access() */ -#define MEMCACHE_ACCESS_ADD 0 -#define MEMCACHE_ACCESS_APPEND 1 -#define MEMCACHE_ACCESS_APPEND_LAST 2 -#define MEMCACHE_ACCESS_FIND 3 -#define MEMCACHE_ACCESS_DELETE 4 -#define MEMCACHE_ACCESS_DELETE_ALL 5 -#define MEMCACHE_ACCESS_UPDATE 6 -#define MEMCACHE_ACCESS_FLUSH 7 -#define MEMCACHE_ACCESS_FLUSH_ALL 8 -#define MEMCACHE_ACCESS_FLUSH_LRU 9 - -/* Mode constants for function memcache_adj_size */ -#define MEMCACHE_SIZE_DEDUCT 0 -#define MEMCACHE_SIZE_ADD 1 - -#define MEMCACHE_SIZE_ENTRIES 1 -#define MEMCACHE_SIZE_NON_ENTRIES 2 - -/* Size used for calculation if given size of cache is 0 */ -#define MEMCACHE_DEF_SIZE 131072 /* 128K bytes */ - -/* Index into different list structure */ -#define LIST_TTL 0 -#define LIST_LRU 1 -#define LIST_TMP 2 -#define LIST_TOTAL 3 - -/* Macros to make code more readable */ -#define NSLDAPI_VALID_MEMCACHE_POINTER( cp ) ( (cp) != NULL ) -#define NSLDAPI_STR_NONNULL( s ) ( (s) ? (s) : "" ) -#define NSLDAPI_SAFE_STRLEN( s ) ( (s) ? strlen((s)) + 1 : 1 ) - -/* Macros dealing with mutex */ -#define LDAP_MEMCACHE_MUTEX_LOCK( c ) \ - if ( (c) && ((c)->ldmemc_lock_fns).ltf_mutex_lock ) { \ - ((c)->ldmemc_lock_fns).ltf_mutex_lock( (c)->ldmemc_lock ); \ - } - -#define LDAP_MEMCACHE_MUTEX_UNLOCK( c ) \ - if ( (c) && ((c)->ldmemc_lock_fns).ltf_mutex_unlock ) { \ - ((c)->ldmemc_lock_fns).ltf_mutex_unlock( (c)->ldmemc_lock ); \ - } - -#define LDAP_MEMCACHE_MUTEX_ALLOC( c ) \ - ((c) && ((c)->ldmemc_lock_fns).ltf_mutex_alloc ? \ - ((c)->ldmemc_lock_fns).ltf_mutex_alloc() : NULL) - -#define LDAP_MEMCACHE_MUTEX_FREE( c ) \ - if ( (c) && ((c)->ldmemc_lock_fns).ltf_mutex_free ) { \ - ((c)->ldmemc_lock_fns).ltf_mutex_free( (c)->ldmemc_lock ); \ - } - -/* Macros used for triming unnecessary spaces in a basedn */ -#define NSLDAPI_IS_SPACE( c ) \ - (((c) == ' ') || ((c) == '\t') || ((c) == '\n')) - -#define NSLDAPI_IS_SEPARATER( c ) \ - ((c) == ',') - -/* Hash table callback function pointer definition */ -typedef int (*HashFuncPtr)(int table_size, void *key); -typedef int (*PutDataPtr)(void **ppTableData, void *key, void *pData); -typedef int (*GetDataPtr)(void *pTableData, void *key, void **ppData); -typedef int (*RemoveDataPtr)(void **ppTableData, void *key, void **ppData); -typedef int (*MiscFuncPtr)(void **ppTableData, void *key, void *pData); -typedef void (*ClrTableNodePtr)(void **ppTableData, void *pData); - -/* Structure of a node in a hash table */ -typedef struct HashTableNode_struct { - void *pData; -} HashTableNode; - -/* Structure of a hash table */ -typedef struct HashTable_struct { - HashTableNode *table; - int size; - HashFuncPtr hashfunc; - PutDataPtr putdata; - GetDataPtr getdata; - MiscFuncPtr miscfunc; - RemoveDataPtr removedata; - ClrTableNodePtr clrtablenode; -} HashTable; - -/* Structure uniquely identifies a search request */ -typedef struct ldapmemcacheReqId_struct { - LDAP *ldmemcrid_ld; - int ldmemcrid_msgid; -} ldapmemcacheReqId; - -/* Structure representing a ldap handle associated to memcache */ -typedef struct ldapmemcacheld_struct { - LDAP *ldmemcl_ld; - struct ldapmemcacheld_struct *ldmemcl_next; -} ldapmemcacheld; - -/* Structure representing header of a search result */ -typedef struct ldapmemcacheRes_struct { - char *ldmemcr_basedn; - unsigned long ldmemcr_crc_key; - unsigned long ldmemcr_resSize; - unsigned long ldmemcr_timestamp; - LDAPMessage *ldmemcr_resHead; - LDAPMessage *ldmemcr_resTail; - ldapmemcacheReqId ldmemcr_req_id; - struct ldapmemcacheRes_struct *ldmemcr_next[LIST_TOTAL]; - struct ldapmemcacheRes_struct *ldmemcr_prev[LIST_TOTAL]; - struct ldapmemcacheRes_struct *ldmemcr_htable_next; -} ldapmemcacheRes; - -/* Structure for memcache statistics */ -typedef struct ldapmemcacheStats_struct { - unsigned long ldmemcstat_tries; - unsigned long ldmemcstat_hits; -} ldapmemcacheStats; - -/* Structure of a memcache object */ -struct ldapmemcache { - unsigned long ldmemc_ttl; - unsigned long ldmemc_size; - unsigned long ldmemc_size_used; - unsigned long ldmemc_size_entries; - char **ldmemc_basedns; - void *ldmemc_lock; - ldapmemcacheld *ldmemc_lds; - HashTable *ldmemc_resTmp; - HashTable *ldmemc_resLookup; - ldapmemcacheRes *ldmemc_resHead[LIST_TOTAL]; - ldapmemcacheRes *ldmemc_resTail[LIST_TOTAL]; - struct ldap_thread_fns ldmemc_lock_fns; - ldapmemcacheStats ldmemc_stats; -}; - -/* Function prototypes */ -static int memcache_exist(LDAP *ld); -static int memcache_add_to_ld(LDAP *ld, int msgid, LDAPMessage *pMsg); -static int memcache_compare_dn(const char *main_dn, const char *dn, int scope); -static int memcache_dup_message(LDAPMessage *res, int msgid, int fromcache, - LDAPMessage **ppResCopy, unsigned long *pSize); -static BerElement* memcache_ber_dup(BerElement* pBer, unsigned long *pSize); - -static void memcache_trim_basedn_spaces(char *basedn); -static int memcache_validate_basedn(LDAPMemCache *cache, const char *basedn); -static int memcache_get_ctrls_len(LDAPControl **ctrls); -static void memcache_append_ctrls(char *buf, LDAPControl **serverCtrls, - LDAPControl **clientCtrls); -static int memcache_adj_size(LDAPMemCache *cache, unsigned long size, - int usageFlags, int bAdd); -static int memcache_free_entry(LDAPMemCache *cache, ldapmemcacheRes *pRes); -static int memcache_expired(LDAPMemCache *cache, ldapmemcacheRes *pRes, - unsigned long curTime); -static int memcache_add_to_list(LDAPMemCache *cache, ldapmemcacheRes *pRes, - int index); -static int memcache_add_res_to_list(ldapmemcacheRes *pRes, LDAPMessage *pMsg, - unsigned long size); -static int memcache_free_from_list(LDAPMemCache *cache, ldapmemcacheRes *pRes, - int index); -static int memcache_search(LDAP *ld, unsigned long key, LDAPMessage **ppRes); -static int memcache_add(LDAP *ld, unsigned long key, int msgid, - const char *basedn); -static int memcache_append(LDAP *ld, int msgid, LDAPMessage *pRes); -static int memcache_append_last(LDAP *ld, int msgid, LDAPMessage *pRes); -static int memcache_remove(LDAP *ld, int msgid); -#if 0 /* function not used */ -static int memcache_remove_all(LDAP *ld); -#endif /* 0 */ -static int memcache_access(LDAPMemCache *cache, int mode, - void *pData1, void *pData2, void *pData3); -#ifdef LDAP_DEBUG -static void memcache_print_list( LDAPMemCache *cache, int index ); -static void memcache_report_statistics( LDAPMemCache *cache ); -#endif /* LDAP_DEBUG */ - -static int htable_calculate_size(int sizelimit); -static int htable_sizeinbytes(HashTable *pTable); -static int htable_put(HashTable *pTable, void *key, void *pData); -static int htable_get(HashTable *pTable, void *key, void **ppData); -static int htable_misc(HashTable *pTable, void *key, void *pData); -static int htable_remove(HashTable *pTable, void *key, void **ppData); -static int htable_removeall(HashTable *pTable, void *pData); -static int htable_create(int size_limit, HashFuncPtr hashf, - PutDataPtr putDataf, GetDataPtr getDataf, - RemoveDataPtr removeDataf, ClrTableNodePtr clrNodef, - MiscFuncPtr miscOpf, HashTable **ppTable); -static int htable_free(HashTable *pTable); - -static int msgid_hashf(int table_size, void *key); -static int msgid_putdata(void **ppTableData, void *key, void *pData); -static int msgid_getdata(void *pTableData, void *key, void **ppData); -static int msgid_removedata(void **ppTableData, void *key, void **ppData); -static int msgid_clear_ld_items(void **ppTableData, void *key, void *pData); -static void msgid_clearnode(void **ppTableData, void *pData); - -static int attrkey_hashf(int table_size, void *key); -static int attrkey_putdata(void **ppTableData, void *key, void *pData); -static int attrkey_getdata(void *pTableData, void *key, void **ppData); -static int attrkey_removedata(void **ppTableData, void *key, void **ppData); -static void attrkey_clearnode(void **ppTableData, void *pData); - -static unsigned long crc32_convert(char *buf, int len); - -/* Create a memcache object. */ -int -LDAP_CALL -ldap_memcache_init( unsigned long ttl, unsigned long size, - char **baseDNs, struct ldap_thread_fns *thread_fns, - LDAPMemCache **cachep ) -{ - unsigned long total_size = 0; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_init\n", 0, 0, 0 ); - - if ( cachep == NULL ) { - return( LDAP_PARAM_ERROR ); - } - - if ((*cachep = (LDAPMemCache*)NSLDAPI_CALLOC(1, - sizeof(LDAPMemCache))) == NULL) { - return ( LDAP_NO_MEMORY ); - } - - total_size += sizeof(LDAPMemCache); - - (*cachep)->ldmemc_ttl = ttl; - (*cachep)->ldmemc_size = size; - (*cachep)->ldmemc_lds = NULL; - - /* Non-zero default size needed for calculating size of hash tables */ - size = (size ? size : MEMCACHE_DEF_SIZE); - - if (thread_fns) { - memcpy(&((*cachep)->ldmemc_lock_fns), thread_fns, - sizeof(struct ldap_thread_fns)); - } else { - memset(&((*cachep)->ldmemc_lock_fns), 0, - sizeof(struct ldap_thread_fns)); - } - - (*cachep)->ldmemc_lock = LDAP_MEMCACHE_MUTEX_ALLOC( *cachep ); - - /* Cache basedns */ - if (baseDNs != NULL) { - - int i; - - for (i = 0; baseDNs[i]; i++) { - ; - } - - (*cachep)->ldmemc_basedns = (char**)NSLDAPI_CALLOC(i + 1, - sizeof(char*)); - - if ((*cachep)->ldmemc_basedns == NULL) { - ldap_memcache_destroy(*cachep); - *cachep = NULL; - return ( LDAP_NO_MEMORY ); - } - - total_size += (i + 1) * sizeof(char*); - - for (i = 0; baseDNs[i]; i++) { - (*cachep)->ldmemc_basedns[i] = nsldapi_strdup(baseDNs[i]); - total_size += strlen(baseDNs[i]) + 1; - } - - (*cachep)->ldmemc_basedns[i] = NULL; - } - - /* Create hash table for temporary cache */ - if (htable_create(size, msgid_hashf, msgid_putdata, msgid_getdata, - msgid_removedata, msgid_clearnode, msgid_clear_ld_items, - &((*cachep)->ldmemc_resTmp)) != LDAP_SUCCESS) { - ldap_memcache_destroy(*cachep); - *cachep = NULL; - return( LDAP_NO_MEMORY ); - } - - total_size += htable_sizeinbytes((*cachep)->ldmemc_resTmp); - - /* Create hash table for primary cache */ - if (htable_create(size, attrkey_hashf, attrkey_putdata, - attrkey_getdata, attrkey_removedata, attrkey_clearnode, - NULL, &((*cachep)->ldmemc_resLookup)) != LDAP_SUCCESS) { - ldap_memcache_destroy(*cachep); - *cachep = NULL; - return( LDAP_NO_MEMORY ); - } - - total_size += htable_sizeinbytes((*cachep)->ldmemc_resLookup); - - /* See if there is enough room so far */ - if (memcache_adj_size(*cachep, total_size, MEMCACHE_SIZE_NON_ENTRIES, - MEMCACHE_SIZE_ADD) != LDAP_SUCCESS) { - ldap_memcache_destroy(*cachep); - *cachep = NULL; - return( LDAP_SIZELIMIT_EXCEEDED ); - } - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_init new cache 0x%p\n", - *cachep, 0, 0 ); - - return( LDAP_SUCCESS ); -} - -/* Associates a ldap handle to a memcache object. */ -int -LDAP_CALL -ldap_memcache_set( LDAP *ld, LDAPMemCache *cache ) -{ - int nRes = LDAP_SUCCESS; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_set\n", 0, 0, 0 ); - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) ) - return( LDAP_PARAM_ERROR ); - - LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); - - if (ld->ld_memcache != cache) { - - LDAPMemCache *c = ld->ld_memcache; - ldapmemcacheld *pCur = NULL; - ldapmemcacheld *pPrev = NULL; - - /* First dissociate handle from old cache */ - - LDAP_MEMCACHE_MUTEX_LOCK( c ); - - pCur = (c ? c->ldmemc_lds : NULL); - for (; pCur; pCur = pCur->ldmemcl_next) { - if (pCur->ldmemcl_ld == ld) - break; - pPrev = pCur; - } - - if (pCur) { - - ldapmemcacheReqId reqid; - - reqid.ldmemcrid_ld = ld; - reqid.ldmemcrid_msgid = -1; - htable_misc(c->ldmemc_resTmp, (void*)&reqid, (void*)c); - - if (pPrev) - pPrev->ldmemcl_next = pCur->ldmemcl_next; - else - c->ldmemc_lds = pCur->ldmemcl_next; - NSLDAPI_FREE(pCur); - pCur = NULL; - - memcache_adj_size(c, sizeof(ldapmemcacheld), - MEMCACHE_SIZE_NON_ENTRIES, MEMCACHE_SIZE_DEDUCT); - } - - LDAP_MEMCACHE_MUTEX_UNLOCK( c ); - - ld->ld_memcache = NULL; - - /* Exit if no new cache is specified */ - if (cache == NULL) { - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - return( LDAP_SUCCESS ); - } - - /* Then associate handle with new cache */ - - LDAP_MEMCACHE_MUTEX_LOCK( cache ); - - if ((nRes = memcache_adj_size(cache, sizeof(ldapmemcacheld), - MEMCACHE_SIZE_NON_ENTRIES, MEMCACHE_SIZE_ADD)) != LDAP_SUCCESS) { - LDAP_MEMCACHE_MUTEX_UNLOCK( cache ); - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - return nRes; - } - - pCur = (ldapmemcacheld*)NSLDAPI_CALLOC(1, sizeof(ldapmemcacheld)); - if (pCur == NULL) { - memcache_adj_size(cache, sizeof(ldapmemcacheld), - MEMCACHE_SIZE_NON_ENTRIES, MEMCACHE_SIZE_DEDUCT); - nRes = LDAP_NO_MEMORY; - } else { - pCur->ldmemcl_ld = ld; - pCur->ldmemcl_next = cache->ldmemc_lds; - cache->ldmemc_lds = pCur; - ld->ld_memcache = cache; - } - - LDAP_MEMCACHE_MUTEX_UNLOCK( cache ); - } - - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - - return nRes; -} - -/* Retrieves memcache with which the ldap handle has been associated. */ -int -LDAP_CALL -ldap_memcache_get( LDAP *ld, LDAPMemCache **cachep ) -{ - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_get ld: 0x%p\n", ld, 0, 0 ); - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || cachep == NULL ) { - return( LDAP_PARAM_ERROR ); - } - - LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); - *cachep = ld->ld_memcache; - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - - return( LDAP_SUCCESS ); -} - -/* - * Function that stays inside libldap and proactively expires items from - * the given cache. This should be called from a newly created thread since - * it will not return until after ldap_memcache_destroy() is called. - */ -void -LDAP_CALL -ldap_memcache_update( LDAPMemCache *cache ) -{ - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_update: cache 0x%p\n", - cache, 0, 0 ); - - if ( !NSLDAPI_VALID_MEMCACHE_POINTER( cache )) { - return; - } - - LDAP_MEMCACHE_MUTEX_LOCK( cache ); - memcache_access(cache, MEMCACHE_ACCESS_UPDATE, NULL, NULL, NULL); - LDAP_MEMCACHE_MUTEX_UNLOCK( cache ); -} - -/* Removes specified entries from given memcache. */ -void -LDAP_CALL -ldap_memcache_flush( LDAPMemCache *cache, char *dn, int scope ) -{ - LDAPDebug( LDAP_DEBUG_TRACE, - "ldap_memcache_flush( cache: 0x%p, dn: %s, scope: %d)\n", - cache, ( dn == NULL ) ? "(null)" : dn, scope ); - - if ( !NSLDAPI_VALID_MEMCACHE_POINTER( cache )) { - return; - } - - LDAP_MEMCACHE_MUTEX_LOCK( cache ); - - if (!dn) { - memcache_access(cache, MEMCACHE_ACCESS_FLUSH_ALL, NULL, NULL, NULL); - } else { - memcache_access(cache, MEMCACHE_ACCESS_FLUSH, - (void*)dn, (void*)scope, NULL); - } - - LDAP_MEMCACHE_MUTEX_UNLOCK( cache ); -} - -/* Destroys the given memcache. */ -void -LDAP_CALL -ldap_memcache_destroy( LDAPMemCache *cache ) -{ - int i = 0; - unsigned long size = sizeof(LDAPMemCache); - ldapmemcacheld *pNode = NULL, *pNextNode = NULL; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_destroy( 0x%p )\n", - cache, 0, 0 ); - - if ( !NSLDAPI_VALID_MEMCACHE_POINTER( cache )) { - return; - } - - /* Dissociate all ldap handes from this cache. */ - LDAP_MEMCACHE_MUTEX_LOCK( cache ); - - for (pNode = cache->ldmemc_lds; pNode; pNode = pNextNode, i++) { - LDAP_MUTEX_LOCK( pNode->ldmemcl_ld, LDAP_MEMCACHE_LOCK ); - cache->ldmemc_lds = pNode->ldmemcl_next; - pNode->ldmemcl_ld->ld_memcache = NULL; - LDAP_MUTEX_UNLOCK( pNode->ldmemcl_ld, LDAP_MEMCACHE_LOCK ); - pNextNode = pNode->ldmemcl_next; - NSLDAPI_FREE(pNode); - } - - size += i * sizeof(ldapmemcacheld); - - LDAP_MEMCACHE_MUTEX_UNLOCK( cache ); - - /* Free array of basedns */ - if (cache->ldmemc_basedns) { - for (i = 0; cache->ldmemc_basedns[i]; i++) { - size += strlen(cache->ldmemc_basedns[i]) + 1; - NSLDAPI_FREE(cache->ldmemc_basedns[i]); - } - size += (i + 1) * sizeof(char*); - NSLDAPI_FREE(cache->ldmemc_basedns); - } - - /* Free hash table used for temporary cache */ - if (cache->ldmemc_resTmp) { - size += htable_sizeinbytes(cache->ldmemc_resTmp); - memcache_access(cache, MEMCACHE_ACCESS_DELETE_ALL, NULL, NULL, NULL); - htable_free(cache->ldmemc_resTmp); - } - - /* Free hash table used for primary cache */ - if (cache->ldmemc_resLookup) { - size += htable_sizeinbytes(cache->ldmemc_resLookup); - memcache_access(cache, MEMCACHE_ACCESS_FLUSH_ALL, NULL, NULL, NULL); - htable_free(cache->ldmemc_resLookup); - } - - memcache_adj_size(cache, size, MEMCACHE_SIZE_NON_ENTRIES, - MEMCACHE_SIZE_DEDUCT); - - LDAP_MEMCACHE_MUTEX_FREE( cache ); - - NSLDAPI_FREE(cache); -} - -/************************* Internal API Functions ****************************/ - -/* Creates an integer key by applying the Cyclic Reduntency Check algorithm on - a long string formed by concatenating all the search parameters plus the - current bind DN. The key is used in the cache for looking up cached - entries. It is assumed that the CRC algorithm will generate - different integers from different byte strings. */ -int -ldap_memcache_createkey(LDAP *ld, const char *base, int scope, - const char *filter, char **attrs, - int attrsonly, LDAPControl **serverctrls, - LDAPControl **clientctrls, unsigned long *keyp) -{ - int nRes, i, j, i_smallest; - int len; - int defport; - char buf[50]; - char *tmp, *defhost, *binddn, *keystr, *tmpbase; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || (keyp == NULL) ) - return( LDAP_PARAM_ERROR ); - - *keyp = 0; - - if (!memcache_exist(ld)) - return( LDAP_LOCAL_ERROR ); - - LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); - LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache ); - nRes = memcache_validate_basedn(ld->ld_memcache, base); - LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache ); - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - - if (nRes != LDAP_SUCCESS) - return nRes; - - defhost = NSLDAPI_STR_NONNULL(ld->ld_defhost); - defport = ld->ld_defport; - tmpbase = nsldapi_strdup(NSLDAPI_STR_NONNULL(base)); - memcache_trim_basedn_spaces(tmpbase); - - if ((binddn = nsldapi_get_binddn(ld)) == NULL) - binddn = ""; - - sprintf(buf, "%i\n%i\n%i\n", defport, scope, (attrsonly ? 1 : 0)); - len = NSLDAPI_SAFE_STRLEN(buf) + NSLDAPI_SAFE_STRLEN(tmpbase) + - NSLDAPI_SAFE_STRLEN(filter) + NSLDAPI_SAFE_STRLEN(defhost) + - NSLDAPI_SAFE_STRLEN(binddn); - - if (attrs) { - for (i = 0; attrs[i]; i++) { - - for (i_smallest = j = i; attrs[j]; j++) { - if (strcasecmp(attrs[i_smallest], attrs[j]) > 0) - i_smallest = j; - } - - if (i != i_smallest) { - tmp = attrs[i]; - attrs[i] = attrs[i_smallest]; - attrs[i_smallest] = tmp; - } - - len += NSLDAPI_SAFE_STRLEN(attrs[i]); - } - } else { - len += 1; - } - - len += memcache_get_ctrls_len(serverctrls) + - memcache_get_ctrls_len(clientctrls) + 1; - - if ((keystr = (char*)NSLDAPI_CALLOC(len, sizeof(char))) == NULL) { - NSLDAPI_FREE(defhost); - return( LDAP_NO_MEMORY ); - } - - sprintf(keystr, "%s\n%s\n%s\n%s\n%s\n", binddn, tmpbase, - NSLDAPI_STR_NONNULL(defhost), NSLDAPI_STR_NONNULL(filter), - NSLDAPI_STR_NONNULL(buf)); - - if (attrs) { - for (i = 0; attrs[i]; i++) { - strcat(keystr, NSLDAPI_STR_NONNULL(attrs[i])); - strcat(keystr, "\n"); - } - } else { - strcat(keystr, "\n"); - } - - for (tmp = keystr; *tmp; - *tmp += (*tmp >= 'a' && *tmp <= 'z' ? 'A'-'a' : 0), tmp++) { - ; - } - - memcache_append_ctrls(keystr, serverctrls, clientctrls); - - /* CRC algorithm */ - *keyp = crc32_convert(keystr, len); - - NSLDAPI_FREE(keystr); - NSLDAPI_FREE(tmpbase); - - return LDAP_SUCCESS; -} - -/* Searches the cache for the right cached entries, and if found, attaches - them to the given ldap handle. This function relies on locking by the - caller. */ -int -ldap_memcache_result(LDAP *ld, int msgid, unsigned long key) -{ - int nRes; - LDAPMessage *pMsg = NULL; - - LDAPDebug( LDAP_DEBUG_TRACE, - "ldap_memcache_result( ld: 0x%p, msgid: %d, key: 0x%8.8lx)\n", - ld, msgid, key ); - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || (msgid < 0) ) { - return( LDAP_PARAM_ERROR ); - } - - if (!memcache_exist(ld)) { - return( LDAP_LOCAL_ERROR ); - } - - LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); - LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache ); - - /* Search the cache and append the results to ld if found */ - ++ld->ld_memcache->ldmemc_stats.ldmemcstat_tries; - if ((nRes = memcache_search(ld, key, &pMsg)) == LDAP_SUCCESS) { - nRes = memcache_add_to_ld(ld, msgid, pMsg); - ++ld->ld_memcache->ldmemc_stats.ldmemcstat_hits; - LDAPDebug( LDAP_DEBUG_TRACE, - "ldap_memcache_result: key 0x%8.8lx found in cache\n", - key, 0, 0 ); - } else { - LDAPDebug( LDAP_DEBUG_TRACE, - "ldap_memcache_result: key 0x%8.8lx not found in cache\n", - key, 0, 0 ); - } - -#ifdef LDAP_DEBUG - memcache_print_list( ld->ld_memcache, LIST_LRU ); - memcache_report_statistics( ld->ld_memcache ); -#endif /* LDAP_DEBUG */ - - LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache ); - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - - return nRes; -} - -/* Creates a new header in the cache so that entries arriving from the - directory server can later be cached under the header. */ -int -ldap_memcache_new(LDAP *ld, int msgid, unsigned long key, const char *basedn) -{ - int nRes; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) ) { - return( LDAP_PARAM_ERROR ); - } - - LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); - - if (!memcache_exist(ld)) { - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - return( LDAP_LOCAL_ERROR ); - } - - LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache ); - nRes = memcache_add(ld, key, msgid, basedn); - LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache ); - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - - return nRes; -} - -/* Appends a chain of entries to an existing cache header. Parameter "bLast" - indicates whether there will be more entries arriving for the search in - question. */ -int -ldap_memcache_append(LDAP *ld, int msgid, int bLast, LDAPMessage *result) -{ - int nRes = LDAP_SUCCESS; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_append( ld: 0x%p, ", ld, 0, 0 ); - LDAPDebug( LDAP_DEBUG_TRACE, "msgid %d, bLast: %d, result: 0x%p)\n", - msgid, bLast, result ); - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || !result ) { - return( LDAP_PARAM_ERROR ); - } - - LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); - - if (!memcache_exist(ld)) { - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - return( LDAP_LOCAL_ERROR ); - } - - LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache ); - - if (!bLast) - nRes = memcache_append(ld, msgid, result); - else - nRes = memcache_append_last(ld, msgid, result); - - LDAPDebug( LDAP_DEBUG_TRACE, - "ldap_memcache_append: %s result for msgid %d\n", - ( nRes == LDAP_SUCCESS ) ? "added" : "failed to add", msgid , 0 ); - - LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache ); - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - - return nRes; -} - -/* Removes partially cached results for a search as a result of calling - ldap_abandon() by the client. */ -int -ldap_memcache_abandon(LDAP *ld, int msgid) -{ - int nRes; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || (msgid < 0) ) { - return( LDAP_PARAM_ERROR ); - } - - LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); - - if (!memcache_exist(ld)) { - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - return( LDAP_LOCAL_ERROR ); - } - - LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache ); - nRes = memcache_remove(ld, msgid); - LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache ); - LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); - - return nRes; -} - -/*************************** helper functions *******************************/ - -/* Removes extraneous spaces in a basedn so that basedns differ by only those - spaces will be treated as equal. Extraneous spaces are those that - precedes the basedn and those that follow a comma. */ -/* - * XXXmcs: this is a bit too agressive... we need to deal with the fact that - * commas and spaces may be quoted, in which case it is wrong to remove them. - */ -static void -memcache_trim_basedn_spaces(char *basedn) -{ - char *pRead, *pWrite; - - if (!basedn) - return; - - for (pWrite = pRead = basedn; *pRead; ) { - for (; *pRead && NSLDAPI_IS_SPACE(*pRead); pRead++) { - ; - } - for (; *pRead && !NSLDAPI_IS_SEPARATER(*pRead); - *(pWrite++) = *(pRead++)) { - ; - } - *(pWrite++) = (*pRead ? *(pRead++) : *pRead); - } -} - -/* Verifies whether the results of a search should be cached or not by - checking if the search's basedn falls under any of the basedns for which - the memcache is responsible. */ -static int -memcache_validate_basedn(LDAPMemCache *cache, const char *basedn) -{ - int i; - - if ( cache->ldmemc_basedns == NULL ) { - return( LDAP_SUCCESS ); - } - -#if 1 - if (basedn == NULL) { - basedn = ""; - } -#else - /* XXXmcs: I do not understand this code... */ - if (basedn == NULL) - return (cache->ldmemc_basedns && cache->ldmemc_basedns[0] ? - LDAP_OPERATIONS_ERROR : LDAP_SUCCESS); - } -#endif - - for (i = 0; cache->ldmemc_basedns[i]; i++) { - if (memcache_compare_dn(basedn, cache->ldmemc_basedns[i], - LDAP_SCOPE_SUBTREE) == LDAP_COMPARE_TRUE) { - return( LDAP_SUCCESS ); - } - } - - return( LDAP_OPERATIONS_ERROR ); -} - -/* Calculates the length of the buffer needed to concatenate the contents of - a ldap control. */ -static int -memcache_get_ctrls_len(LDAPControl **ctrls) -{ - int len = 0, i; - - if (ctrls) { - for (i = 0; ctrls[i]; i++) { - len += strlen(NSLDAPI_STR_NONNULL(ctrls[i]->ldctl_oid)) + - (ctrls[i]->ldctl_value).bv_len + 4; - } - } - - return len; -} - -/* Contenates the contents of client and server controls to a buffer. */ -static void -memcache_append_ctrls(char *buf, LDAPControl **serverCtrls, - LDAPControl **clientCtrls) -{ - int i, j; - char *pCh = buf + strlen(buf); - LDAPControl **ctrls; - - for (j = 0; j < 2; j++) { - - if ((ctrls = (j ? clientCtrls : serverCtrls)) == NULL) - continue; - - for (i = 0; ctrls[i]; i++) { - sprintf(pCh, "%s\n", NSLDAPI_STR_NONNULL(ctrls[i]->ldctl_oid)); - pCh += strlen(NSLDAPI_STR_NONNULL(ctrls[i]->ldctl_oid)) + 1; - if ((ctrls[i]->ldctl_value).bv_len > 0) { - memcpy(pCh, (ctrls[i]->ldctl_value).bv_val, - (ctrls[i]->ldctl_value).bv_len); - pCh += (ctrls[i]->ldctl_value).bv_len; - } - sprintf(pCh, "\n%i\n", (ctrls[i]->ldctl_iscritical ? 1 : 0)); - pCh += 3; - } - } -} - -/* Increases or decreases the size (in bytes) the given memcache currently - uses. If the size goes over the limit, the function returns an error. */ -static int -memcache_adj_size(LDAPMemCache *cache, unsigned long size, - int usageFlags, int bAdd) -{ - LDAPDebug( LDAP_DEBUG_TRACE, - "memcache_adj_size: attempting to %s %ld %s bytes...\n", - bAdd ? "add" : "remove", size, - ( usageFlags & MEMCACHE_SIZE_ENTRIES ) ? "entry" : "non-entry" ); - - if (bAdd) { - cache->ldmemc_size_used += size; - if ((cache->ldmemc_size > 0) && - (cache->ldmemc_size_used > cache->ldmemc_size)) { - - if (size > cache->ldmemc_size_entries) { - cache->ldmemc_size_used -= size; - LDAPDebug( LDAP_DEBUG_TRACE, - "memcache_adj_size: failed (size > size_entries %ld).\n", - cache->ldmemc_size_entries, 0, 0 ); - return( LDAP_SIZELIMIT_EXCEEDED ); - } - - while (cache->ldmemc_size_used > cache->ldmemc_size) { - if (memcache_access(cache, MEMCACHE_ACCESS_FLUSH_LRU, - NULL, NULL, NULL) != LDAP_SUCCESS) { - cache->ldmemc_size_used -= size; - LDAPDebug( LDAP_DEBUG_TRACE, - "memcache_adj_size: failed (LRU flush failed).\n", - 0, 0, 0 ); - return( LDAP_SIZELIMIT_EXCEEDED ); - } - } - } - if (usageFlags & MEMCACHE_SIZE_ENTRIES) - cache->ldmemc_size_entries += size; - } else { - cache->ldmemc_size_used -= size; - assert(cache->ldmemc_size_used >= 0); - if (usageFlags & MEMCACHE_SIZE_ENTRIES) - cache->ldmemc_size_entries -= size; - } - -#ifdef LDAP_DEBUG - if ( cache->ldmemc_size == 0 ) { /* no size limit */ - LDAPDebug( LDAP_DEBUG_TRACE, - "memcache_adj_size: succeeded (new size: %ld bytes).\n", - cache->ldmemc_size_used, 0, 0 ); - } else { - LDAPDebug( LDAP_DEBUG_TRACE, - "memcache_adj_size: succeeded (new size: %ld bytes, " - "free space: %ld bytes).\n", cache->ldmemc_size_used, - cache->ldmemc_size - cache->ldmemc_size_used, 0 ); - } -#endif /* LDAP_DEBUG */ - - return( LDAP_SUCCESS ); -} - -/* Searches the cache for results for a particular search identified by - parameter "key", which was generated ldap_memcache_createkey(). */ -static int -memcache_search(LDAP *ld, unsigned long key, LDAPMessage **ppRes) -{ - int nRes; - ldapmemcacheRes *pRes; - - *ppRes = NULL; - - if (!memcache_exist(ld)) - return LDAP_LOCAL_ERROR; - - nRes = memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_FIND, - (void*)&key, (void*)(&pRes), NULL); - - if (nRes != LDAP_SUCCESS) - return nRes; - - *ppRes = pRes->ldmemcr_resHead; - assert((pRes->ldmemcr_req_id).ldmemcrid_msgid == -1); - - return( LDAP_SUCCESS ); -} - -/* Adds a new header into the cache as a place holder for entries - arriving later. */ -static int -memcache_add(LDAP *ld, unsigned long key, int msgid, - const char *basedn) -{ - ldapmemcacheReqId reqid; - - if (!memcache_exist(ld)) - return LDAP_LOCAL_ERROR; - - reqid.ldmemcrid_msgid = msgid; - reqid.ldmemcrid_ld = ld; - - return memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_ADD, - (void*)&key, (void*)&reqid, (void*)basedn); -} - -/* Appends search entries arriving from the dir server to the cache. */ -static int -memcache_append(LDAP *ld, int msgid, LDAPMessage *pRes) -{ - ldapmemcacheReqId reqid; - - if (!memcache_exist(ld)) - return LDAP_LOCAL_ERROR; - - reqid.ldmemcrid_msgid = msgid; - reqid.ldmemcrid_ld = ld; - - return memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_APPEND, - (void*)&reqid, (void*)pRes, NULL); -} - -/* Same as memcache_append(), but the entries being appended are the - last from the dir server. Once all entries for a search have arrived, - the entries are moved from secondary to primary cache, and a time - stamp is given to the entries. */ -static int -memcache_append_last(LDAP *ld, int msgid, LDAPMessage *pRes) -{ - ldapmemcacheReqId reqid; - - if (!memcache_exist(ld)) - return LDAP_LOCAL_ERROR; - - reqid.ldmemcrid_msgid = msgid; - reqid.ldmemcrid_ld = ld; - - return memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_APPEND_LAST, - (void*)&reqid, (void*)pRes, NULL); -} - -/* Removes entries from the temporary cache. */ -static int -memcache_remove(LDAP *ld, int msgid) -{ - ldapmemcacheReqId reqid; - - if (!memcache_exist(ld)) - return LDAP_LOCAL_ERROR; - - reqid.ldmemcrid_msgid = msgid; - reqid.ldmemcrid_ld = ld; - - return memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_DELETE, - (void*)&reqid, NULL, NULL); -} - -#if 0 /* this function is not used */ -/* Wipes out everything in the temporary cache directory. */ -static int -memcache_remove_all(LDAP *ld) -{ - if (!memcache_exist(ld)) - return LDAP_LOCAL_ERROR; - - return memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_DELETE_ALL, - NULL, NULL, NULL); -} -#endif /* 0 */ - -/* Returns TRUE or FALSE */ -static int -memcache_exist(LDAP *ld) -{ - return (ld->ld_memcache != NULL); -} - -/* Attaches cached entries to an ldap handle. */ -static int -memcache_add_to_ld(LDAP *ld, int msgid, LDAPMessage *pMsg) -{ - int nRes = LDAP_SUCCESS; - LDAPMessage **r; - LDAPMessage *pCopy; - - nRes = memcache_dup_message(pMsg, msgid, 1, &pCopy, NULL); - if (nRes != LDAP_SUCCESS) - return nRes; - - LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK ); - - for (r = &(ld->ld_responses); *r; r = &((*r)->lm_next)) - if ((*r)->lm_msgid == msgid) - break; - - if (*r) - for (r = &((*r)->lm_chain); *r; r = &((*r)->lm_chain)) { - ; - } - - *r = pCopy; - - LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); - - return nRes; -} - -/* Check if main_dn is included in {dn, scope} */ -static int -memcache_compare_dn(const char *main_dn, const char *dn, int scope) -{ - int nRes; - char **components = NULL; - char **main_components = NULL; - - components = ldap_explode_dn(dn, 0); - main_components = ldap_explode_dn(main_dn, 0); - - if (!components || !main_components) { - nRes = LDAP_COMPARE_TRUE; - } - else { - - int i, main_i; - - main_i = ldap_count_values(main_components) - 1; - i = ldap_count_values(components) - 1; - - for (; i >= 0 && main_i >= 0; i--, main_i--) { - if (strcasecmp(main_components[main_i], components[i])) - break; - } - - if (i >= 0 && main_i >= 0) { - nRes = LDAP_COMPARE_FALSE; - } - else if (i < 0 && main_i < 0) { - if (scope != LDAP_SCOPE_ONELEVEL) - nRes = LDAP_COMPARE_TRUE; - else - nRes = LDAP_COMPARE_FALSE; - } - else if (main_i < 0) { - nRes = LDAP_COMPARE_FALSE; - } - else { - if (scope == LDAP_SCOPE_BASE) - nRes = LDAP_COMPARE_FALSE; - else if (scope == LDAP_SCOPE_SUBTREE) - nRes = LDAP_COMPARE_TRUE; - else if (main_i == 0) - nRes = LDAP_COMPARE_TRUE; - else - nRes = LDAP_COMPARE_FALSE; - } - } - - if (components) - ldap_value_free(components); - - if (main_components) - ldap_value_free(main_components); - - return nRes; -} - -/* Dup a complete separate copy of a berelement, including the buffers - the berelement points to. */ -static BerElement* -memcache_ber_dup(BerElement* pBer, unsigned long *pSize) -{ - BerElement *p = ber_dup(pBer); - - *pSize = 0; - - if (p) { - - *pSize += sizeof(BerElement) + EXTRA_SIZE; - - if (p->ber_len <= EXTRA_SIZE) { - p->ber_flags |= LBER_FLAG_NO_FREE_BUFFER; - p->ber_buf = (char*)p + sizeof(BerElement); - } else { - p->ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER; - p->ber_buf = (char*)NSLDAPI_CALLOC(1, p->ber_len); - *pSize += (p->ber_buf ? p->ber_len : 0); - } - - if (p->ber_buf) { - p->ber_ptr = p->ber_buf + (pBer->ber_ptr - pBer->ber_buf); - p->ber_end = p->ber_buf + p->ber_len; - memcpy(p->ber_buf, pBer->ber_buf, p->ber_len); - } else { - ber_free(p, 0); - p = NULL; - *pSize = 0; - } - } - - return p; -} - -/* Dup a entry or a chain of entries. */ -static int -memcache_dup_message(LDAPMessage *res, int msgid, int fromcache, - LDAPMessage **ppResCopy, unsigned long *pSize) -{ - int nRes = LDAP_SUCCESS; - unsigned long ber_size; - LDAPMessage *pCur; - LDAPMessage **ppCurNew; - - *ppResCopy = NULL; - - if (pSize) - *pSize = 0; - - /* Make a copy of res */ - for (pCur = res, ppCurNew = ppResCopy; pCur; - pCur = pCur->lm_chain, ppCurNew = &((*ppCurNew)->lm_chain)) { - - if ((*ppCurNew = (LDAPMessage*)NSLDAPI_CALLOC(1, - sizeof(LDAPMessage))) == NULL) { - nRes = LDAP_NO_MEMORY; - break; - } - - memcpy(*ppCurNew, pCur, sizeof(LDAPMessage)); - (*ppCurNew)->lm_next = NULL; - (*ppCurNew)->lm_ber = memcache_ber_dup(pCur->lm_ber, &ber_size); - (*ppCurNew)->lm_msgid = msgid; - (*ppCurNew)->lm_fromcache = (fromcache != 0); - - if (pSize) - *pSize += sizeof(LDAPMessage) + ber_size; - } - - if ((nRes != LDAP_SUCCESS) && (*ppResCopy != NULL)) { - ldap_msgfree(*ppResCopy); - *ppResCopy = NULL; - if (pSize) - *pSize = 0; - } - - return nRes; -} - -/************************* Cache Functions ***********************/ - -/* Frees a cache header. */ -static int -memcache_free_entry(LDAPMemCache *cache, ldapmemcacheRes *pRes) -{ - if (pRes) { - - unsigned long size = sizeof(ldapmemcacheRes); - - if (pRes->ldmemcr_basedn) { - size += strlen(pRes->ldmemcr_basedn) + 1; - NSLDAPI_FREE(pRes->ldmemcr_basedn); - } - - if (pRes->ldmemcr_resHead) { - size += pRes->ldmemcr_resSize; - ldap_msgfree(pRes->ldmemcr_resHead); - } - - NSLDAPI_FREE(pRes); - - memcache_adj_size(cache, size, MEMCACHE_SIZE_ENTRIES, - MEMCACHE_SIZE_DEDUCT); - } - - return( LDAP_SUCCESS ); -} - -/* Detaches a cache header from the list of headers. */ -static int -memcache_free_from_list(LDAPMemCache *cache, ldapmemcacheRes *pRes, int index) -{ - if (pRes->ldmemcr_prev[index]) - pRes->ldmemcr_prev[index]->ldmemcr_next[index] = - pRes->ldmemcr_next[index]; - - if (pRes->ldmemcr_next[index]) - pRes->ldmemcr_next[index]->ldmemcr_prev[index] = - pRes->ldmemcr_prev[index]; - - if (cache->ldmemc_resHead[index] == pRes) - cache->ldmemc_resHead[index] = pRes->ldmemcr_next[index]; - - if (cache->ldmemc_resTail[index] == pRes) - cache->ldmemc_resTail[index] = pRes->ldmemcr_prev[index]; - - pRes->ldmemcr_prev[index] = NULL; - pRes->ldmemcr_next[index] = NULL; - - return( LDAP_SUCCESS ); -} - -/* Inserts a new cache header to a list of headers. */ -static int -memcache_add_to_list(LDAPMemCache *cache, ldapmemcacheRes *pRes, int index) -{ - if (cache->ldmemc_resHead[index]) - cache->ldmemc_resHead[index]->ldmemcr_prev[index] = pRes; - else - cache->ldmemc_resTail[index] = pRes; - - pRes->ldmemcr_prev[index] = NULL; - pRes->ldmemcr_next[index] = cache->ldmemc_resHead[index]; - cache->ldmemc_resHead[index] = pRes; - - return( LDAP_SUCCESS ); -} - -/* Appends a chain of entries to the given cache header. */ -static int -memcache_add_res_to_list(ldapmemcacheRes *pRes, LDAPMessage *pMsg, - unsigned long size) -{ - if (pRes->ldmemcr_resTail) - pRes->ldmemcr_resTail->lm_chain = pMsg; - else - pRes->ldmemcr_resHead = pMsg; - - for (pRes->ldmemcr_resTail = pMsg; - pRes->ldmemcr_resTail->lm_chain; - pRes->ldmemcr_resTail = pRes->ldmemcr_resTail->lm_chain) { - ; - } - - pRes->ldmemcr_resSize += size; - - return( LDAP_SUCCESS ); -} - - -#ifdef LDAP_DEBUG -static void -memcache_print_list( LDAPMemCache *cache, int index ) -{ - char *name; - ldapmemcacheRes *restmp; - - switch( index ) { - case LIST_TTL: - name = "TTL"; - break; - case LIST_LRU: - name = "LRU"; - break; - case LIST_TMP: - name = "TMP"; - break; - case LIST_TOTAL: - name = "TOTAL"; - break; - default: - name = "unknown"; - } - - LDAPDebug( LDAP_DEBUG_TRACE, "memcache 0x%p %s list:\n", - cache, name, 0 ); - for ( restmp = cache->ldmemc_resHead[index]; restmp != NULL; - restmp = restmp->ldmemcr_next[index] ) { - LDAPDebug( LDAP_DEBUG_TRACE, - " key: 0x%8.8lx, ld: 0x%p, msgid: %d\n", - restmp->ldmemcr_crc_key, - restmp->ldmemcr_req_id.ldmemcrid_ld, - restmp->ldmemcr_req_id.ldmemcrid_msgid ); - } - LDAPDebug( LDAP_DEBUG_TRACE, "memcache 0x%p end of %s list.\n", - cache, name, 0 ); -} -#endif /* LDAP_DEBUG */ - -/* Tells whether a cached result has expired. */ -static int -memcache_expired(LDAPMemCache *cache, ldapmemcacheRes *pRes, - unsigned long curTime) -{ - if (!cache->ldmemc_ttl) - return 0; - - return ((unsigned long)difftime( - (time_t)curTime, - (time_t)(pRes->ldmemcr_timestamp)) >= - cache->ldmemc_ttl); -} - -/* Operates the cache in a central place. */ -static int -memcache_access(LDAPMemCache *cache, int mode, - void *pData1, void *pData2, void *pData3) -{ - int nRes = LDAP_SUCCESS; - unsigned long size = 0; - - /* Add a new cache header to the cache. */ - if (mode == MEMCACHE_ACCESS_ADD) { - unsigned long key = *((unsigned long*)pData1); - char *basedn = (char*)pData3; - ldapmemcacheRes *pRes = NULL; - void* hashResult = NULL; - - nRes = htable_get(cache->ldmemc_resTmp, pData2, &hashResult); - if (nRes == LDAP_SUCCESS) - return( LDAP_ALREADY_EXISTS ); - - pRes = (ldapmemcacheRes*)NSLDAPI_CALLOC(1, sizeof(ldapmemcacheRes)); - if (pRes == NULL) - return( LDAP_NO_MEMORY ); - - pRes->ldmemcr_crc_key = key; - pRes->ldmemcr_req_id = *((ldapmemcacheReqId*)pData2); - pRes->ldmemcr_basedn = (basedn ? nsldapi_strdup(basedn) : NULL); - - size += sizeof(ldapmemcacheRes) + strlen(basedn) + 1; - nRes = memcache_adj_size(cache, size, MEMCACHE_SIZE_ENTRIES, - MEMCACHE_SIZE_ADD); - if (nRes == LDAP_SUCCESS) - nRes = htable_put(cache->ldmemc_resTmp, pData2, (void*)pRes); - if (nRes == LDAP_SUCCESS) - memcache_add_to_list(cache, pRes, LIST_TMP); - else - memcache_free_entry(cache, pRes); - } - /* Append entries to an existing cache header. */ - else if ((mode == MEMCACHE_ACCESS_APPEND) || - (mode == MEMCACHE_ACCESS_APPEND_LAST)) { - - LDAPMessage *pMsg = (LDAPMessage*)pData2; - LDAPMessage *pCopy = NULL; - ldapmemcacheRes *pRes = NULL; - void* hashResult = NULL; - - nRes = htable_get(cache->ldmemc_resTmp, pData1, &hashResult); - if (nRes != LDAP_SUCCESS) - return nRes; - - pRes = (ldapmemcacheRes*) hashResult; - nRes = memcache_dup_message(pMsg, pMsg->lm_msgid, 0, &pCopy, &size); - if (nRes != LDAP_SUCCESS) { - nRes = htable_remove(cache->ldmemc_resTmp, pData1, NULL); - assert(nRes == LDAP_SUCCESS); - memcache_free_from_list(cache, pRes, LIST_TMP); - memcache_free_entry(cache, pRes); - return nRes; - } - - nRes = memcache_adj_size(cache, size, MEMCACHE_SIZE_ENTRIES, - MEMCACHE_SIZE_ADD); - if (nRes != LDAP_SUCCESS) { - ldap_msgfree(pCopy); - nRes = htable_remove(cache->ldmemc_resTmp, pData1, NULL); - assert(nRes == LDAP_SUCCESS); - memcache_free_from_list(cache, pRes, LIST_TMP); - memcache_free_entry(cache, pRes); - return nRes; - } - - memcache_add_res_to_list(pRes, pCopy, size); - - if (mode == MEMCACHE_ACCESS_APPEND) - return( LDAP_SUCCESS ); - - nRes = htable_remove(cache->ldmemc_resTmp, pData1, NULL); - assert(nRes == LDAP_SUCCESS); - memcache_free_from_list(cache, pRes, LIST_TMP); - (pRes->ldmemcr_req_id).ldmemcrid_ld = NULL; - (pRes->ldmemcr_req_id).ldmemcrid_msgid = -1; - pRes->ldmemcr_timestamp = (unsigned long)time(NULL); - - if ((nRes = htable_put(cache->ldmemc_resLookup, - (void*)&(pRes->ldmemcr_crc_key), - (void*)pRes)) == LDAP_SUCCESS) { - memcache_add_to_list(cache, pRes, LIST_TTL); - memcache_add_to_list(cache, pRes, LIST_LRU); - } else { - memcache_free_entry(cache, pRes); - } - } - /* Search for cached entries for a particular search. */ - else if (mode == MEMCACHE_ACCESS_FIND) { - - ldapmemcacheRes **ppRes = (ldapmemcacheRes**)pData2; - - nRes = htable_get(cache->ldmemc_resLookup, pData1, (void**)ppRes); - if (nRes != LDAP_SUCCESS) - return nRes; - - if (!memcache_expired(cache, *ppRes, (unsigned long)time(0))) { - memcache_free_from_list(cache, *ppRes, LIST_LRU); - memcache_add_to_list(cache, *ppRes, LIST_LRU); - return( LDAP_SUCCESS ); - } - - nRes = htable_remove(cache->ldmemc_resLookup, pData1, NULL); - assert(nRes == LDAP_SUCCESS); - memcache_free_from_list(cache, *ppRes, LIST_TTL); - memcache_free_from_list(cache, *ppRes, LIST_LRU); - memcache_free_entry(cache, *ppRes); - nRes = LDAP_NO_SUCH_OBJECT; - *ppRes = NULL; - } - /* Remove cached entries in the temporary cache. */ - else if (mode == MEMCACHE_ACCESS_DELETE) { - - void* hashResult = NULL; - - if ((nRes = htable_remove(cache->ldmemc_resTmp, pData1, - &hashResult)) == LDAP_SUCCESS) { - ldapmemcacheRes *pCurRes = (ldapmemcacheRes*) hashResult; - memcache_free_from_list(cache, pCurRes, LIST_TMP); - memcache_free_entry(cache, pCurRes); - } - } - /* Wipe out the temporary cache. */ - else if (mode == MEMCACHE_ACCESS_DELETE_ALL) { - - nRes = htable_removeall(cache->ldmemc_resTmp, (void*)cache); - } - /* Remove expired entries from primary cache. */ - else if (mode == MEMCACHE_ACCESS_UPDATE) { - - ldapmemcacheRes *pCurRes = cache->ldmemc_resTail[LIST_TTL]; - unsigned long curTime = (unsigned long)time(NULL); - - for (; pCurRes; pCurRes = cache->ldmemc_resTail[LIST_TTL]) { - - if (!memcache_expired(cache, pCurRes, curTime)) - break; - - nRes = htable_remove(cache->ldmemc_resLookup, - (void*)&(pCurRes->ldmemcr_crc_key), NULL); - assert(nRes == LDAP_SUCCESS); - memcache_free_from_list(cache, pCurRes, LIST_TTL); - memcache_free_from_list(cache, pCurRes, LIST_LRU); - memcache_free_entry(cache, pCurRes); - } - } - /* Wipe out the primary cache. */ - else if (mode == MEMCACHE_ACCESS_FLUSH_ALL) { - - ldapmemcacheRes *pCurRes = cache->ldmemc_resHead[LIST_TTL]; - - nRes = htable_removeall(cache->ldmemc_resLookup, (void*)cache); - - for (; pCurRes; pCurRes = cache->ldmemc_resHead[LIST_TTL]) { - memcache_free_from_list(cache, pCurRes, LIST_LRU); - cache->ldmemc_resHead[LIST_TTL] = - cache->ldmemc_resHead[LIST_TTL]->ldmemcr_next[LIST_TTL]; - memcache_free_entry(cache, pCurRes); - } - cache->ldmemc_resTail[LIST_TTL] = NULL; - } - /* Remove cached entries in both primary and temporary cache. */ - else if (mode == MEMCACHE_ACCESS_FLUSH) { - - int i, list_id, bDone; - int scope = (int)pData2; - char *dn = (char*)pData1; - char *dnTmp; - BerElement ber; - LDAPMessage *pMsg; - ldapmemcacheRes *pRes; - - if (cache->ldmemc_basedns) { - for (i = 0; cache->ldmemc_basedns[i]; i++) { - if ((memcache_compare_dn(cache->ldmemc_basedns[i], dn, - LDAP_SCOPE_SUBTREE) == LDAP_COMPARE_TRUE) || - (memcache_compare_dn(dn, cache->ldmemc_basedns[i], - LDAP_SCOPE_SUBTREE) == LDAP_COMPARE_TRUE)) - break; - } - if (cache->ldmemc_basedns[i] == NULL) - return( LDAP_SUCCESS ); - } - - for (i = 0; i < 2; i++) { - - list_id = (i == 0 ? LIST_TTL : LIST_TMP); - - for (pRes = cache->ldmemc_resHead[list_id]; pRes != NULL; - pRes = pRes->ldmemcr_next[list_id]) { - - if ((memcache_compare_dn(pRes->ldmemcr_basedn, dn, - LDAP_SCOPE_SUBTREE) != LDAP_COMPARE_TRUE) && - (memcache_compare_dn(dn, pRes->ldmemcr_basedn, - LDAP_SCOPE_SUBTREE) != LDAP_COMPARE_TRUE)) - continue; - - for (pMsg = pRes->ldmemcr_resHead, bDone = 0; - !bDone && pMsg; pMsg = pMsg->lm_chain) { - - if (!NSLDAPI_IS_SEARCH_ENTRY( pMsg->lm_msgtype )) - continue; - - ber = *(pMsg->lm_ber); - if (ber_scanf(&ber, "{a", &dnTmp) != LBER_ERROR) { - bDone = (memcache_compare_dn(dnTmp, dn, scope) == - LDAP_COMPARE_TRUE); - ldap_memfree(dnTmp); - } - } - - if (!bDone) - continue; - - if (list_id == LIST_TTL) { - nRes = htable_remove(cache->ldmemc_resLookup, - (void*)&(pRes->ldmemcr_crc_key), NULL); - assert(nRes == LDAP_SUCCESS); - memcache_free_from_list(cache, pRes, LIST_TTL); - memcache_free_from_list(cache, pRes, LIST_LRU); - } else { - nRes = htable_remove(cache->ldmemc_resTmp, - (void*)&(pRes->ldmemcr_req_id), NULL); - assert(nRes == LDAP_SUCCESS); - memcache_free_from_list(cache, pRes, LIST_TMP); - } - memcache_free_entry(cache, pRes); - } - } - } - /* Flush least recently used entries from cache */ - else if (mode == MEMCACHE_ACCESS_FLUSH_LRU) { - - ldapmemcacheRes *pRes = cache->ldmemc_resTail[LIST_LRU]; - - if (pRes == NULL) - return LDAP_NO_SUCH_OBJECT; - - LDAPDebug( LDAP_DEBUG_TRACE, - "memcache_access FLUSH_LRU: removing key 0x%8.8lx\n", - pRes->ldmemcr_crc_key, 0, 0 ); - nRes = htable_remove(cache->ldmemc_resLookup, - (void*)&(pRes->ldmemcr_crc_key), NULL); - assert(nRes == LDAP_SUCCESS); - memcache_free_from_list(cache, pRes, LIST_TTL); - memcache_free_from_list(cache, pRes, LIST_LRU); - memcache_free_entry(cache, pRes); - } - /* Unknown command */ - else { - nRes = LDAP_PARAM_ERROR; - } - - return nRes; -} - - -#ifdef LDAP_DEBUG -static void -memcache_report_statistics( LDAPMemCache *cache ) -{ - unsigned long hitrate; - - if ( cache->ldmemc_stats.ldmemcstat_tries == 0 ) { - hitrate = 0; - } else { - hitrate = ( 100L * cache->ldmemc_stats.ldmemcstat_hits ) / - cache->ldmemc_stats.ldmemcstat_tries; - } - LDAPDebug( LDAP_DEBUG_STATS, "memcache 0x%p:\n", cache, 0, 0 ); - LDAPDebug( LDAP_DEBUG_STATS, " tries: %ld hits: %ld hitrate: %ld%%\n", - cache->ldmemc_stats.ldmemcstat_tries, - cache->ldmemc_stats.ldmemcstat_hits, hitrate ); - if ( cache->ldmemc_size <= 0 ) { /* no size limit */ - LDAPDebug( LDAP_DEBUG_STATS, " memory bytes used: %ld\n", - cache->ldmemc_size_used, 0, 0 ); - } else { - LDAPDebug( LDAP_DEBUG_STATS, " memory bytes used: %ld free: %ld\n", - cache->ldmemc_size_used, - cache->ldmemc_size - cache->ldmemc_size_used, 0 ); - } -} -#endif /* LDAP_DEBUG */ - -/************************ Hash Table Functions *****************************/ - -/* Calculates size (# of entries) of hash table given the size limit for - the cache. */ -static int -htable_calculate_size(int sizelimit) -{ - int i, j; - int size = (int)(((double)sizelimit / - (double)(sizeof(BerElement) + EXTRA_SIZE)) / 1.5); - - /* Get a prime # */ - size = (size & 0x1 ? size : size + 1); - for (i = 3, j = size / 2; i < j; i++) { - if ((size % i) == 0) { - size += 2; - i = 3; - j = size / 2; - } - } - - return size; -} - -/* Returns the size in bytes of the given hash table. */ -static int -htable_sizeinbytes(HashTable *pTable) -{ - if (!pTable) - return 0; - - return (pTable->size * sizeof(HashTableNode)); -} - -/* Inserts an item into the hash table. */ -static int -htable_put(HashTable *pTable, void *key, void *pData) -{ - int index = pTable->hashfunc(pTable->size, key); - - if (index >= 0 && index < pTable->size) - return pTable->putdata(&(pTable->table[index].pData), key, pData); - - return( LDAP_OPERATIONS_ERROR ); -} - -/* Retrieves an item from the hash table. */ -static int -htable_get(HashTable *pTable, void *key, void **ppData) -{ - int index = pTable->hashfunc(pTable->size, key); - - *ppData = NULL; - - if (index >= 0 && index < pTable->size) - return pTable->getdata(pTable->table[index].pData, key, ppData); - - return( LDAP_OPERATIONS_ERROR ); -} - -/* Performs a miscellaneous operation on a hash table entry. */ -static int -htable_misc(HashTable *pTable, void *key, void *pData) -{ - if (pTable->miscfunc) { - int index = pTable->hashfunc(pTable->size, key); - if (index >= 0 && index < pTable->size) - return pTable->miscfunc(&(pTable->table[index].pData), key, pData); - } - - return( LDAP_OPERATIONS_ERROR ); -} - -/* Removes an item from the hash table. */ -static int -htable_remove(HashTable *pTable, void *key, void **ppData) -{ - int index = pTable->hashfunc(pTable->size, key); - - if (ppData) - *ppData = NULL; - - if (index >= 0 && index < pTable->size) - return pTable->removedata(&(pTable->table[index].pData), key, ppData); - - return( LDAP_OPERATIONS_ERROR ); -} - -/* Removes everything in the hash table. */ -static int -htable_removeall(HashTable *pTable, void *pData) -{ - int i; - - for (i = 0; i < pTable->size; i++) - pTable->clrtablenode(&(pTable->table[i].pData), pData); - - return( LDAP_SUCCESS ); -} - -/* Creates a new hash table. */ -static int -htable_create(int size_limit, HashFuncPtr hashf, - PutDataPtr putDataf, GetDataPtr getDataf, - RemoveDataPtr removeDataf, ClrTableNodePtr clrNodef, - MiscFuncPtr miscOpf, HashTable **ppTable) -{ - size_limit = htable_calculate_size(size_limit); - - if ((*ppTable = (HashTable*)NSLDAPI_CALLOC(1, sizeof(HashTable))) == NULL) - return( LDAP_NO_MEMORY ); - - (*ppTable)->table = (HashTableNode*)NSLDAPI_CALLOC(size_limit, - sizeof(HashTableNode)); - if ((*ppTable)->table == NULL) { - NSLDAPI_FREE(*ppTable); - *ppTable = NULL; - return( LDAP_NO_MEMORY ); - } - - (*ppTable)->size = size_limit; - (*ppTable)->hashfunc = hashf; - (*ppTable)->putdata = putDataf; - (*ppTable)->getdata = getDataf; - (*ppTable)->miscfunc = miscOpf; - (*ppTable)->removedata = removeDataf; - (*ppTable)->clrtablenode = clrNodef; - - return( LDAP_SUCCESS ); -} - -/* Destroys a hash table. */ -static int -htable_free(HashTable *pTable) -{ - NSLDAPI_FREE(pTable->table); - NSLDAPI_FREE(pTable); - return( LDAP_SUCCESS ); -} - -/**************** Hash table callbacks for temporary cache ****************/ - -/* Hash function */ -static int -msgid_hashf(int table_size, void *key) -{ - unsigned code = (unsigned)((ldapmemcacheReqId*)key)->ldmemcrid_ld; - return (((code << 20) + (code >> 12)) % table_size); -} - -/* Called by hash table to insert an item. */ -static int -msgid_putdata(void **ppTableData, void *key, void *pData) -{ - ldapmemcacheReqId *pReqId = (ldapmemcacheReqId*)key; - ldapmemcacheRes *pRes = (ldapmemcacheRes*)pData; - ldapmemcacheRes **ppHead = (ldapmemcacheRes**)ppTableData; - ldapmemcacheRes *pCurRes = *ppHead; - ldapmemcacheRes *pPrev = NULL; - - for (; pCurRes; pCurRes = pCurRes->ldmemcr_htable_next) { - if ((pCurRes->ldmemcr_req_id).ldmemcrid_ld == pReqId->ldmemcrid_ld) - break; - pPrev = pCurRes; - } - - if (pCurRes) { - for (; pCurRes; pCurRes = pCurRes->ldmemcr_next[LIST_TTL]) { - if ((pCurRes->ldmemcr_req_id).ldmemcrid_msgid == - pReqId->ldmemcrid_msgid) - return( LDAP_ALREADY_EXISTS ); - pPrev = pCurRes; - } - pPrev->ldmemcr_next[LIST_TTL] = pRes; - pRes->ldmemcr_prev[LIST_TTL] = pPrev; - pRes->ldmemcr_next[LIST_TTL] = NULL; - } else { - if (pPrev) - pPrev->ldmemcr_htable_next = pRes; - else - *ppHead = pRes; - pRes->ldmemcr_htable_next = NULL; - } - - return( LDAP_SUCCESS ); -} - -/* Called by hash table to retrieve an item. */ -static int -msgid_getdata(void *pTableData, void *key, void **ppData) -{ - ldapmemcacheReqId *pReqId = (ldapmemcacheReqId*)key; - ldapmemcacheRes *pCurRes = (ldapmemcacheRes*)pTableData; - - *ppData = NULL; - - for (; pCurRes; pCurRes = pCurRes->ldmemcr_htable_next) { - if ((pCurRes->ldmemcr_req_id).ldmemcrid_ld == pReqId->ldmemcrid_ld) - break; - } - - if (!pCurRes) - return( LDAP_NO_SUCH_OBJECT ); - - for (; pCurRes; pCurRes = pCurRes->ldmemcr_next[LIST_TTL]) { - if ((pCurRes->ldmemcr_req_id).ldmemcrid_msgid == - pReqId->ldmemcrid_msgid) { - *ppData = (void*)pCurRes; - return( LDAP_SUCCESS ); - } - } - - return( LDAP_NO_SUCH_OBJECT ); -} - -/* Called by hash table to remove an item. */ -static int -msgid_removedata(void **ppTableData, void *key, void **ppData) -{ - ldapmemcacheRes *pHead = *((ldapmemcacheRes**)ppTableData); - ldapmemcacheRes *pCurRes = NULL; - ldapmemcacheRes *pPrev = NULL; - ldapmemcacheReqId *pReqId = (ldapmemcacheReqId*)key; - - if (ppData) - *ppData = NULL; - - for (; pHead; pHead = pHead->ldmemcr_htable_next) { - if ((pHead->ldmemcr_req_id).ldmemcrid_ld == pReqId->ldmemcrid_ld) - break; - pPrev = pHead; - } - - if (!pHead) - return( LDAP_NO_SUCH_OBJECT ); - - for (pCurRes = pHead; pCurRes; pCurRes = pCurRes->ldmemcr_next[LIST_TTL]) { - if ((pCurRes->ldmemcr_req_id).ldmemcrid_msgid == - pReqId->ldmemcrid_msgid) - break; - } - - if (!pCurRes) - return( LDAP_NO_SUCH_OBJECT ); - - if (ppData) { - pCurRes->ldmemcr_next[LIST_TTL] = NULL; - pCurRes->ldmemcr_prev[LIST_TTL] = NULL; - pCurRes->ldmemcr_htable_next = NULL; - *ppData = (void*)pCurRes; - } - - if (pCurRes != pHead) { - if (pCurRes->ldmemcr_prev[LIST_TTL]) - pCurRes->ldmemcr_prev[LIST_TTL]->ldmemcr_next[LIST_TTL] = - pCurRes->ldmemcr_next[LIST_TTL]; - if (pCurRes->ldmemcr_next[LIST_TTL]) - pCurRes->ldmemcr_next[LIST_TTL]->ldmemcr_prev[LIST_TTL] = - pCurRes->ldmemcr_prev[LIST_TTL]; - return( LDAP_SUCCESS ); - } - - if (pPrev) { - if (pHead->ldmemcr_next[LIST_TTL]) { - pPrev->ldmemcr_htable_next = pHead->ldmemcr_next[LIST_TTL]; - pHead->ldmemcr_next[LIST_TTL]->ldmemcr_htable_next = - pHead->ldmemcr_htable_next; - } else { - pPrev->ldmemcr_htable_next = pHead->ldmemcr_htable_next; - } - } else { - if (pHead->ldmemcr_next[LIST_TTL]) { - *((ldapmemcacheRes**)ppTableData) = pHead->ldmemcr_next[LIST_TTL]; - pHead->ldmemcr_next[LIST_TTL]->ldmemcr_htable_next = - pHead->ldmemcr_htable_next; - } else { - *((ldapmemcacheRes**)ppTableData) = pHead->ldmemcr_htable_next; - } - } - - return( LDAP_SUCCESS ); -} - -/* Called by hash table to remove all cached entries associated to searches - being performed using the given ldap handle. */ -static int -msgid_clear_ld_items(void **ppTableData, void *key, void *pData) -{ - LDAPMemCache *cache = (LDAPMemCache*)pData; - ldapmemcacheRes *pHead = *((ldapmemcacheRes**)ppTableData); - ldapmemcacheRes *pPrev = NULL; - ldapmemcacheRes *pCurRes = NULL; - ldapmemcacheReqId *pReqId = (ldapmemcacheReqId*)key; - - for (; pHead; pHead = pHead->ldmemcr_htable_next) { - if ((pHead->ldmemcr_req_id).ldmemcrid_ld == pReqId->ldmemcrid_ld) - break; - pPrev = pHead; - } - - if (!pHead) - return( LDAP_NO_SUCH_OBJECT ); - - if (pPrev) - pPrev->ldmemcr_htable_next = pHead->ldmemcr_htable_next; - else - *((ldapmemcacheRes**)ppTableData) = pHead->ldmemcr_htable_next; - - for (pCurRes = pHead; pHead; pCurRes = pHead) { - pHead = pHead->ldmemcr_next[LIST_TTL]; - memcache_free_from_list(cache, pCurRes, LIST_TMP); - memcache_free_entry(cache, pCurRes); - } - - return( LDAP_SUCCESS ); -} - -/* Called by hash table for removing all items in the table. */ -static void -msgid_clearnode(void **ppTableData, void *pData) -{ - LDAPMemCache *cache = (LDAPMemCache*)pData; - ldapmemcacheRes **ppHead = (ldapmemcacheRes**)ppTableData; - ldapmemcacheRes *pSubHead = *ppHead; - ldapmemcacheRes *pCurRes = NULL; - - for (; *ppHead; pSubHead = *ppHead) { - ppHead = &((*ppHead)->ldmemcr_htable_next); - for (pCurRes = pSubHead; pSubHead; pCurRes = pSubHead) { - pSubHead = pSubHead->ldmemcr_next[LIST_TTL]; - memcache_free_from_list(cache, pCurRes, LIST_TMP); - memcache_free_entry(cache, pCurRes); - } - } -} - -/********************* Hash table for primary cache ************************/ - -/* Hash function */ -static int -attrkey_hashf(int table_size, void *key) -{ - return ((*((unsigned long*)key)) % table_size); -} - -/* Called by hash table to insert an item. */ -static int -attrkey_putdata(void **ppTableData, void *key, void *pData) -{ - unsigned long attrkey = *((unsigned long*)key); - ldapmemcacheRes **ppHead = (ldapmemcacheRes**)ppTableData; - ldapmemcacheRes *pRes = *ppHead; - - for (; pRes; pRes = pRes->ldmemcr_htable_next) { - if (pRes->ldmemcr_crc_key == attrkey) - return( LDAP_ALREADY_EXISTS ); - } - - pRes = (ldapmemcacheRes*)pData; - pRes->ldmemcr_htable_next = *ppHead; - *ppHead = pRes; - - return( LDAP_SUCCESS ); -} - -/* Called by hash table to retrieve an item. */ -static int -attrkey_getdata(void *pTableData, void *key, void **ppData) -{ - unsigned long attrkey = *((unsigned long*)key); - ldapmemcacheRes *pRes = (ldapmemcacheRes*)pTableData; - - for (; pRes; pRes = pRes->ldmemcr_htable_next) { - if (pRes->ldmemcr_crc_key == attrkey) { - *ppData = (void*)pRes; - return( LDAP_SUCCESS ); - } - } - - *ppData = NULL; - - return( LDAP_NO_SUCH_OBJECT ); -} - -/* Called by hash table to remove an item. */ -static int -attrkey_removedata(void **ppTableData, void *key, void **ppData) -{ - unsigned long attrkey = *((unsigned long*)key); - ldapmemcacheRes **ppHead = (ldapmemcacheRes**)ppTableData; - ldapmemcacheRes *pRes = *ppHead; - ldapmemcacheRes *pPrev = NULL; - - for (; pRes; pRes = pRes->ldmemcr_htable_next) { - if (pRes->ldmemcr_crc_key == attrkey) { - if (ppData) - *ppData = (void*)pRes; - if (pPrev) - pPrev->ldmemcr_htable_next = pRes->ldmemcr_htable_next; - else - *ppHead = pRes->ldmemcr_htable_next; - pRes->ldmemcr_htable_next = NULL; - return( LDAP_SUCCESS ); - } - pPrev = pRes; - } - - if (ppData) - *ppData = NULL; - - return( LDAP_NO_SUCH_OBJECT ); -} - -/* Called by hash table for removing all items in the table. */ -static void -attrkey_clearnode(void **ppTableData, void *pData) -{ - ldapmemcacheRes **ppHead = (ldapmemcacheRes**)ppTableData; - ldapmemcacheRes *pRes = *ppHead; - - (void)pData; - - for (; *ppHead; pRes = *ppHead) { - ppHead = &((*ppHead)->ldmemcr_htable_next); - pRes->ldmemcr_htable_next = NULL; - } -} - -/***************************** CRC algorithm ********************************/ - -/* From http://www.faqs.org/faqs/compression-faq/part1/section-25.html */ - -/* - * Build auxiliary table for parallel byte-at-a-time CRC-32. - */ -#define NSLDAPI_CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ - -static nsldapi_uint_32 crc32_table[256] = { - 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, - 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, - 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, - 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, - 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, - 0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, - 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef, - 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, - 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, - 0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, - 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0, - 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, - 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, - 0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, - 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, - 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, - 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, - 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, - 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050, - 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, - 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, - 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, - 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1, - 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, - 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, - 0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, - 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9, - 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, - 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, - 0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, - 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71, - 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, - 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, - 0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, - 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, - 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, - 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, - 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, - 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676, - 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, - 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, - 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, - 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 }; - -/* Initialized first time "crc32()" is called. If you prefer, you can - * statically initialize it at compile time. [Another exercise.] - */ - -static unsigned long -crc32_convert(char *buf, int len) -{ - unsigned char *p; - nsldapi_uint_32 crc; - - crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ - for (p = (unsigned char *)buf; len > 0; ++p, --len) - crc = ((crc << 8) ^ crc32_table[(crc >> 24) ^ *p]) & 0xffffffff; - - return (unsigned long) ~crc; /* transmit complement, per CRC-32 spec */ -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap/pwpctrl.c
Deleted
@@ -1,315 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Sun LDAP C SDK. - * - * The Initial Developer of the Original Code is Sun Microsystems, Inc. - * - * Portions created by Sun Microsystems, Inc are Copyright (C) 2005 - * Sun Microsystems, Inc. All Rights Reserved. - * - * Contributor(s): abobrov@sun.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "ldap-int.h" - -/* ldap_create_passwordpolicy_control: - -Parameters are - -ld LDAP pointer to the desired connection - -ctrlp the address of a place to put the constructed control -*/ - -int -LDAP_CALL -ldap_create_passwordpolicy_control ( - LDAP *ld, - LDAPControl **ctrlp - ) -{ - int rc; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - return( LDAP_PARAM_ERROR ); - } - - if ( ctrlp == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return ( LDAP_PARAM_ERROR ); - } - - rc = nsldapi_build_control( LDAP_CONTROL_PASSWD_POLICY, - NULL, NULL, 0, ctrlp ); - - LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); - return( rc ); -} - -/* ldap_create_passwordpolicy_control_ext: - -Parameters are - -ld LDAP pointer to the desired connection - -ctl_iscritical Indicates whether the control is critical of not. If - this field is non-zero, the operation will only be car- - ried out if the control is recognized by the server - and/or client - -ctrlp the address of a place to put the constructed control -*/ - -int -LDAP_CALL -ldap_create_passwordpolicy_control_ext ( - LDAP *ld, - const char ctl_iscritical, - LDAPControl **ctrlp - ) -{ - int rc; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - return( LDAP_PARAM_ERROR ); - } - - if ( ctrlp == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return ( LDAP_PARAM_ERROR ); - } - - rc = nsldapi_build_control( LDAP_CONTROL_PASSWD_POLICY, - NULL, NULL, ctl_iscritical, ctrlp ); - - LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); - return( rc ); -} - -/* ldap_parse_passwordpolicy_control: - -Parameters are - -ld LDAP pointer to the desired connection - -ctrlp pointer to LDAPControl structure, obtained from - calling ldap_find_control() or by other means. - -exptimep result parameter is filled in with the number of seconds before - the password will expire. - -gracep result parameter is filled in with the number of grace logins - after the password has expired. - -errorcodep result parameter is filled in with the error code of the - password operation. -*/ - -int -LDAP_CALL -ldap_parse_passwordpolicy_control ( - LDAP *ld, - LDAPControl *ctrlp, - ber_int_t *expirep, - ber_int_t *gracep, - LDAPPasswordPolicyError *errorp - ) -{ - ber_len_t len; - ber_tag_t tag; - ber_int_t pp_exp = -1; - ber_int_t pp_grace = -1; - ber_int_t pp_warning = -1; - ber_int_t pp_err = PP_noError; - BerElement *ber = NULL; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) ) { - return( LDAP_PARAM_ERROR ); - } - - if ( ctrlp == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); - return ( LDAP_CONTROL_NOT_FOUND ); - } - - /* allocate a Ber element with the contents of the control's struct berval */ - if ( ( ber = ber_init( &ctrlp->ldctl_value ) ) == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); - return( LDAP_NO_MEMORY ); - } - - /* - * The control value should look like this: - * - * PasswordPolicyResponseValue ::= SEQUENCE { - * warning [0] CHOICE { - * timeBeforeExpiration [0] INTEGER (0 .. maxInt), - * graceLoginsRemaining [1] INTEGER (0 .. maxInt) } OPTIONAL - * error [1] ENUMERATED { - * passwordExpired (0), - * accountLocked (1), - * changeAfterReset (2), - * passwordModNotAllowed (3), - * mustSupplyOldPassword (4), - * insufficientPasswordQuality (5), - * passwordTooShort (6), - * passwordTooYoung (7), - * passwordInHistory (8) } OPTIONAL } - */ - - if ( ber_scanf( ber, "{" ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - - tag = ber_peek_tag( ber, &len ); - - while ( (tag != LBER_ERROR) && (tag != LBER_END_OF_SEQORSET) ) { - if ( tag == ( LBER_CONSTRUCTED | LBER_CLASS_CONTEXT ) ) { - ber_skip_tag( ber, &len ); - if ( ber_scanf( ber, "ti", &tag, &pp_warning ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - if ( tag == ( LBER_CLASS_CONTEXT | 0x01 ) ) { - pp_exp = pp_warning; - } else if ( tag == ( LBER_CLASS_CONTEXT | 0x02 ) ) { - pp_grace = pp_warning; - } - } else if ( tag == ( LBER_CLASS_CONTEXT | 0x01 ) ) { - if ( ber_scanf( ber, "ti", &tag, &pp_err ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - } - if ( tag == LBER_DEFAULT ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - tag = ber_skip_tag( ber, &len ); - } - - if (expirep) *expirep = pp_exp; - if (gracep) *gracep = pp_grace; - if (errorp) *errorp = pp_err; - - /* the ber encoding is no longer needed */ - ber_free( ber, 1 ); - return( LDAP_SUCCESS ); -} - -/* ldap_parse_passwordpolicy_control_ext: - -Parameters are - -ld LDAP pointer to the desired connection - -ctrlp An array of controls obtained from calling - ldap_parse_result on the set of results - returned by the server - -exptimep result parameter is filled in with the number of seconds before - the password will expire. - -gracep result parameter is filled in with the number of grace logins - after the password has expired. - -errorcodep result parameter is filled in with the error code of the - password operation. -*/ - -int -LDAP_CALL -ldap_parse_passwordpolicy_control_ext ( - LDAP *ld, - LDAPControl **ctrlp, - ber_int_t *expirep, - ber_int_t *gracep, - LDAPPasswordPolicyError *errorp - ) -{ - int i, foundPPControl; - LDAPControl *PPCtrlp = NULL; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) ) { - return( LDAP_PARAM_ERROR ); - } - - /* find the control in the list of controls if it exists */ - if ( ctrlp == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); - return ( LDAP_CONTROL_NOT_FOUND ); - } - foundPPControl = 0; - for ( i = 0; (( ctrlp[i] != NULL ) && ( !foundPPControl )); i++ ) { - foundPPControl = !strcmp( ctrlp[i]->ldctl_oid, LDAP_CONTROL_PASSWD_POLICY ); - } - if ( !foundPPControl ) { - LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); - return ( LDAP_CONTROL_NOT_FOUND ); - } else { - /* let local var point to the control */ - PPCtrlp = ctrlp[i-1]; - } - - return ( - ldap_parse_passwordpolicy_control( ld, PPCtrlp, expirep, gracep, errorp )); -} - -const char * -LDAP_CALL -ldap_passwordpolicy_err2txt( LDAPPasswordPolicyError err ) -{ - switch(err) { - case PP_passwordExpired: - return "Password expired"; - case PP_accountLocked: - return "Account locked"; - case PP_changeAfterReset: - return "Password must be changed"; - case PP_passwordModNotAllowed: - return "Policy prevents password modification"; - case PP_mustSupplyOldPassword: - return "Policy requires old password in order to change password"; - case PP_insufficientPasswordQuality: - return "Password fails quality checks"; - case PP_passwordTooShort: - return "Password is too short for policy"; - case PP_passwordTooYoung: - return "Password has been changed too recently"; - case PP_passwordInHistory: - return "New password is in list of old passwords"; - case PP_noError: - return "No error"; - default: - return "Unknown error code"; - } -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap/request.c
Deleted
@@ -1,1657 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright (c) 1995 Regents of the University of Michigan. - * All rights reserved. - */ -/* - * request.c - sending of ldap requests; handling of referrals - */ - -#if 0 -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif -#endif - -#include "ldap-int.h" - -static LDAPConn *find_connection( LDAP *ld, LDAPServer *srv, int any ); -static void free_servers( LDAPServer *srvlist ); -static int chase_one_referral( LDAP *ld, LDAPRequest *lr, LDAPRequest *origreq, - char *refurl, char *desc, int *unknownp, int is_reference ); -static int re_encode_request( LDAP *ld, BerElement *origber, - int msgid, LDAPURLDesc *ludp, BerElement **berp, int is_reference ); - -#ifdef LDAP_DNS -static LDAPServer *dn2servers( LDAP *ld, char *dn ); -#endif /* LDAP_DNS */ - - -/* returns an LDAP error code and also sets error inside LDAP * */ -int -nsldapi_alloc_ber_with_options( LDAP *ld, BerElement **berp ) -{ - int err; - - LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK ); - if (( *berp = ber_alloc_t( ld->ld_lberoptions )) == NULLBER ) { - err = LDAP_NO_MEMORY; - LDAP_SET_LDERRNO( ld, err, NULL, NULL ); - } else { - err = LDAP_SUCCESS; -#ifdef STR_TRANSLATION - nsldapi_set_ber_options( ld, *berp ); -#endif /* STR_TRANSLATION */ - } - LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); - - return( err ); -} - - -void -nsldapi_set_ber_options( LDAP *ld, BerElement *ber ) -{ - ber->ber_options = ld->ld_lberoptions; -#ifdef STR_TRANSLATION - if (( ld->ld_lberoptions & LBER_OPT_TRANSLATE_STRINGS ) != 0 ) { - ber_set_string_translators( ber, - ld->ld_lber_encode_translate_proc, - ld->ld_lber_decode_translate_proc ); - } -#endif /* STR_TRANSLATION */ -} - - -/* returns the message id of the request or -1 if an error occurs */ -int -nsldapi_send_initial_request( LDAP *ld, int msgid, unsigned long msgtype, - char *dn, BerElement *ber ) -{ - LDAPServer *servers; - - LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_send_initial_request\n", 0,0,0 ); - -#ifdef LDAP_DNS - LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK ); - if (( ld->ld_options & LDAP_BITOPT_DNS ) != 0 && ldap_is_dns_dn( dn )) { - if (( servers = dn2servers( ld, dn )) == NULL ) { - ber_free( ber, 1 ); - LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); - return( -1 ); - } - -#ifdef LDAP_DEBUG - if ( ldap_debug & LDAP_DEBUG_TRACE ) { - LDAPServer *srv; - char msg[256]; - - for ( srv = servers; srv != NULL; - srv = srv->lsrv_next ) { - sprintf( msg, - "LDAP server %s: dn %s, port %d\n", - srv->lsrv_host, ( srv->lsrv_dn == NULL ) ? - "(default)" : srv->lsrv_dn, - srv->lsrv_port ); - ber_err_print( msg ); - } - } -#endif /* LDAP_DEBUG */ - } else { -#endif /* LDAP_DNS */ - /* - * use of DNS is turned off or this is an LDAP DN... - * use our default connection - */ - servers = NULL; -#ifdef LDAP_DNS - } - LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); -#endif /* LDAP_DNS */ - - return( nsldapi_send_server_request( ld, ber, msgid, NULL, - servers, NULL, ( msgtype == LDAP_REQ_BIND ) ? dn : NULL, 0 )); -} - - -/* returns the message id of the request or -1 if an error occurs */ -int -nsldapi_send_server_request( - LDAP *ld, /* session handle */ - BerElement *ber, /* message to send */ - int msgid, /* ID of message to send */ - LDAPRequest *parentreq, /* non-NULL for referred requests */ - LDAPServer *srvlist, /* servers to connect to (NULL for default) */ - LDAPConn *lc, /* connection to use (NULL for default) */ - char *bindreqdn, /* non-NULL for bind requests */ - int bind /* perform a bind after opening new conn.? */ -) -{ - LDAPRequest *lr; - int err; - int incparent; /* did we bump parent's ref count? */ - /* EPIPE and Unsolicited Response handling variables */ - int res_rc = 0; - int epipe_err = 0; - int ext_res_rc = 0; - char *ext_oid = NULL; - struct berval *ext_data = NULL; - LDAPMessage *ext_res = NULL; - - LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_send_server_request\n", 0, 0, 0 ); - - incparent = 0; - LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK ); - if ( lc == NULL ) { - if ( srvlist == NULL ) { - if ( ld->ld_defconn == NULL ) { - LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK ); - if ( bindreqdn == NULL && ( ld->ld_options - & LDAP_BITOPT_RECONNECT ) != 0 ) { - LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, - NULL, NULL ); - ber_free( ber, 1 ); - LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); - LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); - return( -1 ); - } - LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); - - if ( nsldapi_open_ldap_defconn( ld ) < 0 ) { - ber_free( ber, 1 ); - LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); - return( -1 ); - } - } - lc = ld->ld_defconn; - } else { - if (( lc = find_connection( ld, srvlist, 1 )) == - NULL ) { - if ( bind && (parentreq != NULL) ) { - /* Remember the bind in the parent */ - incparent = 1; - ++parentreq->lr_outrefcnt; - } - - lc = nsldapi_new_connection( ld, &srvlist, 0, - 1, bind ); - } - free_servers( srvlist ); - } - } - - - /* - * return a fatal error if: - * 1. no connections exists - * or - * 2. the connection is dead - * or - * 3. it is not in the connected state with normal (non async) I/O - */ - if ( lc == NULL - || ( lc->lconn_status == LDAP_CONNST_DEAD ) - || ( 0 == (ld->ld_options & LDAP_BITOPT_ASYNC) && - lc->lconn_status != LDAP_CONNST_CONNECTED) ) { - - ber_free( ber, 1 ); - if ( lc != NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, NULL, NULL ); - } - if ( incparent ) { - /* Forget about the bind */ - --parentreq->lr_outrefcnt; - } - LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); - return( -1 ); - } - - if (( lr = nsldapi_new_request( lc, ber, msgid, - 1 /* expect a response */)) == NULL - || ( bindreqdn != NULL && ( bindreqdn = - nsldapi_strdup( bindreqdn )) == NULL )) { - if ( lr != NULL ) { - NSLDAPI_FREE( lr ); - } - LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); - nsldapi_free_connection( ld, lc, NULL, NULL, 0, 0 ); - ber_free( ber, 1 ); - if ( incparent ) { - /* Forget about the bind */ - --parentreq->lr_outrefcnt; - } - LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); - return( -1 ); - } - lr->lr_binddn = bindreqdn; - - if ( parentreq != NULL ) { /* sub-request */ - if ( !incparent ) { - /* Increment if we didn't do it before the bind */ - ++parentreq->lr_outrefcnt; - } - lr->lr_origid = parentreq->lr_origid; - lr->lr_parentcnt = parentreq->lr_parentcnt + 1; - lr->lr_parent = parentreq; - if ( parentreq->lr_child != NULL ) { - lr->lr_sibling = parentreq->lr_child; - } - parentreq->lr_child = lr; - } else { /* original request */ - lr->lr_origid = lr->lr_msgid; - } - - LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); - /* add new request to the end of the list of outstanding requests */ - nsldapi_queue_request_nolock( ld, lr ); - - /* - * Issue a non-blocking poll() if we need to check this - * connection's status. - */ - if ( lc->lconn_status == LDAP_CONNST_CONNECTING || - lc->lconn_pending_requests > 0 ) { - struct timeval tv; - - tv.tv_sec = tv.tv_usec = 0; - (void)nsldapi_iostatus_poll( ld, &tv ); - } - - /* - * If the connect is pending, check to see if it has now completed. - */ - if ( lc->lconn_status == LDAP_CONNST_CONNECTING && - nsldapi_iostatus_is_write_ready( ld, lc->lconn_sb )) { - lc->lconn_status = LDAP_CONNST_CONNECTED; - - LDAPDebug( LDAP_DEBUG_TRACE, - "nsldapi_send_server_request: connection 0x%p -" - " LDAP_CONNST_CONNECTING -> LDAP_CONNST_CONNECTED\n", - lc, 0, 0 ); - } - - if ( lc->lconn_status == LDAP_CONNST_CONNECTING || - lc->lconn_pending_requests > 0 ) { - /* - * The connect is not yet complete, or there are existing - * requests that have not yet been sent to the server. - * Delay sending this request. - */ - lr->lr_status = LDAP_REQST_WRITING; - ++lc->lconn_pending_requests; - nsldapi_iostatus_interest_write( ld, lc->lconn_sb ); - - /* - * If the connection is now connected, and it is ready - * to accept some more outbound data, send as many - * pending requests as possible. - */ - if ( lc->lconn_status != LDAP_CONNST_CONNECTING - && nsldapi_iostatus_is_write_ready( ld, lc->lconn_sb )) { - if ( nsldapi_send_pending_requests_nolock( ld, lc ) - == -1 ) { /* error */ - /* - * Since nsldapi_send_pending_requests_nolock() - * sets LDAP errno, there is no need to do so - * here. - */ - LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); - LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); - return( -1 ); - } - } - - } else { - if (( err = nsldapi_send_ber_message( ld, lc->lconn_sb, - ber, 0 /* do not free ber */, - 1 /* will handle EPIPE */ )) != 0 ) { - - epipe_err = LDAP_GET_ERRNO( ld ); - if ( epipe_err == EPIPE ) { - res_rc = nsldapi_result_nolock(ld, LDAP_RES_UNSOLICITED, 1, - 1, (struct timeval *) NULL, &ext_res); - if ( ( res_rc == LDAP_RES_EXTENDED ) && ext_res ) { - ext_res_rc = ldap_parse_extended_result( ld, ext_res, - &ext_oid, &ext_data, 0 ); - if ( ext_res_rc != LDAP_SUCCESS ) { - if ( ext_res ) { - ldap_msgfree( ext_res ); - } - nsldapi_connection_lost_nolock( ld, lc->lconn_sb ); - } else { -#ifdef LDAP_DEBUG - LDAPDebug( LDAP_DEBUG_TRACE, - "nsldapi_send_server_request: Unsolicited response\n", 0, 0, 0 ); - if ( ext_oid ) { - LDAPDebug( LDAP_DEBUG_TRACE, - "nsldapi_send_server_request: Unsolicited response oid: %s\n", - ext_oid, 0, 0 ); - } - if ( ext_data && ext_data->bv_len && ext_data->bv_val ) { - LDAPDebug( LDAP_DEBUG_TRACE, - "nsldapi_send_server_request: Unsolicited response len: %d\n", - ext_data->bv_len, 0, 0 ); - LDAPDebug( LDAP_DEBUG_TRACE, - "nsldapi_send_server_request: Unsolicited response val: %s\n", - ext_data->bv_val, 0, 0 ); - } - if ( !ext_oid && !ext_data ) { - LDAPDebug( LDAP_DEBUG_TRACE, - "nsldapi_send_server_request: Unsolicited response is empty\n", - 0, 0, 0 ); - } -#endif /* LDAP_DEBUG */ - if ( ext_oid ) { - if ( strcmp ( ext_oid, - LDAP_NOTICE_OF_DISCONNECTION ) == 0 ) { - if ( ext_data ) { - ber_bvfree( ext_data ); - } - if ( ext_oid ) { - ldap_memfree( ext_oid ); - } - if ( ext_res ) { - ldap_msgfree( ext_res ); - } - nsldapi_connection_lost_nolock( ld, - lc->lconn_sb ); - nsldapi_free_request( ld, lr, 0 ); - nsldapi_free_connection( ld, lc, - NULL, NULL, 0, 0 ); - LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); - LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); - return( -1 ); - } - } - } - } else { - if ( ext_res ) { - ldap_msgfree( ext_res ); - } - nsldapi_connection_lost_nolock( ld, lc->lconn_sb ); - } - } - - /* need to continue write later */ - if (err == -2 ) { - lr->lr_status = LDAP_REQST_WRITING; - ++lc->lconn_pending_requests; - nsldapi_iostatus_interest_write( ld, lc->lconn_sb ); - } else { - LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, NULL, NULL ); - nsldapi_free_request( ld, lr, 0 ); - nsldapi_free_connection( ld, lc, NULL, NULL, 0, 0 ); - LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); - LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); - return( -1 ); - } - - } else { - if ( parentreq == NULL ) { - ber->ber_end = ber->ber_ptr; - ber->ber_ptr = ber->ber_buf; - } - - /* sent -- waiting for a response */ - if (ld->ld_options & LDAP_BITOPT_ASYNC) { - lc->lconn_status = LDAP_CONNST_CONNECTED; - } - - nsldapi_iostatus_interest_read( ld, lc->lconn_sb ); - } - } - LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); - LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); - - LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL ); - return( msgid ); -} - - -/* - * nsldapi_send_ber_message(): Attempt to send a BER-encoded message. - * If freeit is non-zero, ber is freed when the send succeeds. - * If errno is EPIPE and epipe_handler is set we let the caller - * deal with EPIPE and dont call lost_nolock here but the caller - * should call lost_nolock itself when done with handling EPIPE. - * - * Return values: - * 0: message sent successfully. - * -1: a fatal error occurred while trying to send. - * -2: async. I/O is enabled and the send would block. - */ -int -nsldapi_send_ber_message( LDAP *ld, Sockbuf *sb, BerElement *ber, int freeit, - int epipe_handler ) -{ - int rc = 0; /* optimistic */ - int async = ( 0 != (ld->ld_options & LDAP_BITOPT_ASYNC)); - int more_to_send = 1; - - while ( more_to_send) { - /* - * ber_flush() doesn't set errno on EOF, so we pre-set it to - * zero to avoid getting tricked by leftover "EAGAIN" errors - */ - LDAP_SET_ERRNO( ld, 0 ); - - if ( ber_flush( sb, ber, freeit ) == 0 ) { - more_to_send = 0; /* success */ - } else { - int terrno = LDAP_GET_ERRNO( ld ); - if ( NSLDAPI_ERRNO_IO_INPROGRESS( terrno )) { - if ( async ) { - rc = -2; - break; - } - } else { - if ( !(epipe_handler && ( terrno == EPIPE )) ) { - nsldapi_connection_lost_nolock( ld, sb ); - } - rc = -1; /* fatal error */ - break; - } - } - } - - return( rc ); -} - - -/* - * nsldapi_send_pending_requests_nolock(): Send one or more pending requests - * that are associated with connection 'lc'. - * - * Return values: 0 -- success. - * -1 -- fatal error; connection closed. - * - * Must be called with these two mutexes locked, in this order: - * LDAP_CONN_LOCK - * LDAP_REQ_LOCK - */ -int -nsldapi_send_pending_requests_nolock( LDAP *ld, LDAPConn *lc ) -{ - int err; - int waiting_for_a_response = 0; - int rc = 0; - LDAPRequest *lr; - char *logname = "nsldapi_send_pending_requests_nolock"; - - LDAPDebug( LDAP_DEBUG_TRACE, "%s\n", logname, 0, 0 ); - - for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) { - /* - * This code relies on the fact that the ld_requests list - * is in order from oldest to newest request (the oldest - * requests that have not yet been sent to the server are - * sent first). - */ - if ( lr->lr_status == LDAP_REQST_WRITING - && lr->lr_conn == lc ) { - err = nsldapi_send_ber_message( ld, lc->lconn_sb, - lr->lr_ber, 0 /* do not free ber */, - 0 /* will not handle EPIPE */ ); - if ( err == 0 ) { /* send succeeded */ - LDAPDebug( LDAP_DEBUG_TRACE, - "%s: 0x%p SENT\n", logname, lr, 0 ); - lr->lr_ber->ber_end = lr->lr_ber->ber_ptr; - lr->lr_ber->ber_ptr = lr->lr_ber->ber_buf; - lr->lr_status = LDAP_REQST_INPROGRESS; - --lc->lconn_pending_requests; - } else if ( err == -2 ) { /* would block */ - rc = 0; /* not an error */ - LDAPDebug( LDAP_DEBUG_TRACE, - "%s: 0x%p WOULD BLOCK\n", logname, lr, 0 ); - break; - } else { /* fatal error */ - LDAPDebug( LDAP_DEBUG_TRACE, - "%s: 0x%p FATAL ERROR\n", logname, lr, 0 ); - LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, - NULL, NULL ); - nsldapi_free_request( ld, lr, 0 ); - lr = NULL; - nsldapi_free_connection( ld, lc, NULL, NULL, - 0, 0 ); - lc = NULL; - rc = -1; - break; - } - } - - if (lr->lr_status == LDAP_REQST_INPROGRESS ) { - if (lr->lr_expect_resp) { - ++waiting_for_a_response; - } else { - LDAPDebug( LDAP_DEBUG_TRACE, - "%s: 0x%p NO RESPONSE EXPECTED;" - " freeing request \n", logname, lr, 0 ); - nsldapi_free_request( ld, lr, 0 ); - lr = NULL; - } - } - } - - if ( lc != NULL ) { - if ( lc->lconn_pending_requests < 1 ) { - /* no need to poll for "write ready" any longer */ - nsldapi_iostatus_interest_clear( ld, lc->lconn_sb ); - } - - if ( waiting_for_a_response ) { - /* need to poll for "read ready" */ - nsldapi_iostatus_interest_read( ld, lc->lconn_sb ); - } - } - - LDAPDebug( LDAP_DEBUG_TRACE, "%s <- %d\n", logname, rc, 0 ); - return( rc ); -} - - -LDAPConn * -nsldapi_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, - int connect, int bind ) -{ - int rc = -1; - LDAPConn *lc; - LDAPServer *prevsrv, *srv; - Sockbuf *sb = NULL; - - /* - * make a new LDAP server connection - */ - if (( lc = (LDAPConn *)NSLDAPI_CALLOC( 1, sizeof( LDAPConn ))) == NULL - || ( !use_ldsb && ( sb = ber_sockbuf_alloc()) == NULL )) { - if ( lc != NULL ) { - NSLDAPI_FREE( (char *)lc ); - } - LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); - return( NULL ); - } - - LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK ); - if ( !use_ldsb ) { - /* - * we have allocated a new sockbuf - * set I/O routines to match those in default LDAP sockbuf - */ - IFP sb_fn; - struct lber_x_ext_io_fns extiofns; - - extiofns.lbextiofn_size = LBER_X_EXTIO_FNS_SIZE; - - if ( ber_sockbuf_get_option( ld->ld_sbp, - LBER_SOCKBUF_OPT_EXT_IO_FNS, &extiofns ) == 0 ) { - ber_sockbuf_set_option( sb, - LBER_SOCKBUF_OPT_EXT_IO_FNS, &extiofns ); - } - if ( ber_sockbuf_get_option( ld->ld_sbp, - LBER_SOCKBUF_OPT_READ_FN, (void *)&sb_fn ) == 0 - && sb_fn != NULL ) { - ber_sockbuf_set_option( sb, LBER_SOCKBUF_OPT_READ_FN, - (void *)sb_fn ); - } - if ( ber_sockbuf_get_option( ld->ld_sbp, - LBER_SOCKBUF_OPT_WRITE_FN, (void *)&sb_fn ) == 0 - && sb_fn != NULL ) { - ber_sockbuf_set_option( sb, LBER_SOCKBUF_OPT_WRITE_FN, - (void *)sb_fn ); - } - } - - lc->lconn_sb = ( use_ldsb ) ? ld->ld_sbp : sb; - lc->lconn_version = ld->ld_version; /* inherited */ - LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); - - if ( connect ) { - prevsrv = NULL; - /* - * save the return code for later - */ - for ( srv = *srvlistp; srv != NULL; srv = srv->lsrv_next ) { - rc = nsldapi_connect_to_host( ld, lc->lconn_sb, - srv->lsrv_host, srv->lsrv_port, - ( srv->lsrv_options & LDAP_SRV_OPT_SECURE ) != 0, - &lc->lconn_krbinstance ); - if (rc != -1) { - break; - } - prevsrv = srv; - } - - if ( srv == NULL ) { - if ( !use_ldsb ) { - NSLDAPI_FREE( (char *)lc->lconn_sb ); - } - NSLDAPI_FREE( (char *)lc ); - /* nsldapi_open_ldap_connection has already set ld_errno */ - return( NULL ); - } - - if ( prevsrv == NULL ) { - *srvlistp = srv->lsrv_next; - } else { - prevsrv->lsrv_next = srv->lsrv_next; - } - lc->lconn_server = srv; - } - - if ( 0 != (ld->ld_options & LDAP_BITOPT_ASYNC)) { - /* - * Technically, the socket may already be connected but we are - * not sure. By setting the state to LDAP_CONNST_CONNECTING, we - * ensure that we will check the socket status to make sure it - * is connected before we try to send any LDAP messages. - */ - lc->lconn_status = LDAP_CONNST_CONNECTING; - } else { - lc->lconn_status = LDAP_CONNST_CONNECTED; - } - - lc->lconn_next = ld->ld_conns; - ld->ld_conns = lc; - - /* - * XXX for now, we always do a synchronous bind. This will have - * to change in the long run... - */ - if ( bind ) { - int err, lderr, freepasswd, authmethod; - char *binddn, *passwd; - LDAPConn *savedefconn; - - freepasswd = err = 0; - - if ( ld->ld_rebind_fn == NULL ) { - binddn = passwd = ""; - authmethod = LDAP_AUTH_SIMPLE; - } else { - if (( lderr = (*ld->ld_rebind_fn)( ld, &binddn, &passwd, - &authmethod, 0, ld->ld_rebind_arg )) - == LDAP_SUCCESS ) { - freepasswd = 1; - } else { - LDAP_SET_LDERRNO( ld, lderr, NULL, NULL ); - err = -1; - } - } - - - if ( err == 0 ) { - savedefconn = ld->ld_defconn; - ld->ld_defconn = lc; - ++lc->lconn_refcnt; /* avoid premature free */ - - /* - * when binding, we will back down as low as LDAPv2 - * if we get back "protocol error" from bind attempts - */ - for ( ;; ) { - /* LDAP_MUTEX_UNLOCK(ld, LDAP_CONN_LOCK); */ - if (( lderr = ldap_bind_s( ld, binddn, passwd, - authmethod )) == LDAP_SUCCESS ) { - /* LDAP_MUTEX_LOCK(ld, LDAP_CONN_LOCK); */ - break; - } - /* LDAP_MUTEX_LOCK(ld, LDAP_CONN_LOCK); */ - if ( lc->lconn_version <= LDAP_VERSION2 - || lderr != LDAP_PROTOCOL_ERROR ) { - err = -1; - break; - } - --lc->lconn_version; /* try lower version */ - } - --lc->lconn_refcnt; - ld->ld_defconn = savedefconn; - } - - if ( freepasswd ) { - (*ld->ld_rebind_fn)( ld, &binddn, &passwd, - &authmethod, 1, ld->ld_rebind_arg ); - } - - if ( err != 0 ) { - nsldapi_free_connection( ld, lc, NULL, NULL, 1, 0 ); - lc = NULL; - } - } - - return( lc ); -} - - -#define LDAP_CONN_SAMEHOST( h1, h2 ) \ - (( (h1) == NULL && (h2) == NULL ) || \ - ( (h1) != NULL && (h2) != NULL && strcasecmp( (h1), (h2) ) == 0 )) - -static LDAPConn * -find_connection( LDAP *ld, LDAPServer *srv, int any ) -/* - * return an existing connection (if any) to the server srv - * if "any" is non-zero, check for any server in the "srv" chain - */ -{ - LDAPConn *lc; - LDAPServer *ls; - - for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { - for ( ls = srv; ls != NULL; ls = ls->lsrv_next ) { - if ( LDAP_CONN_SAMEHOST( ls->lsrv_host, - lc->lconn_server->lsrv_host ) - && ls->lsrv_port == lc->lconn_server->lsrv_port - && ls->lsrv_options == - lc->lconn_server->lsrv_options ) { - return( lc ); - } - if ( !any ) { - break; - } - } - } - - return( NULL ); -} - - -void -nsldapi_free_connection( LDAP *ld, LDAPConn *lc, LDAPControl **serverctrls, - LDAPControl **clientctrls, int force, int unbind ) -{ - LDAPConn *tmplc, *prevlc; - - LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_free_connection\n", 0, 0, 0 ); - - if ( force || --lc->lconn_refcnt <= 0 ) { - nsldapi_iostatus_interest_clear( ld, lc->lconn_sb ); - if ( lc->lconn_status == LDAP_CONNST_CONNECTED ) { - if ( unbind ) { - nsldapi_send_unbind( ld, lc->lconn_sb, - serverctrls, clientctrls ); - } - } - nsldapi_close_connection( ld, lc->lconn_sb ); - prevlc = NULL; - for ( tmplc = ld->ld_conns; tmplc != NULL; - tmplc = tmplc->lconn_next ) { - if ( tmplc == lc ) { - if ( prevlc == NULL ) { - ld->ld_conns = tmplc->lconn_next; - } else { - prevlc->lconn_next = tmplc->lconn_next; - } - break; - } - prevlc = tmplc; - } - free_servers( lc->lconn_server ); - if ( lc->lconn_krbinstance != NULL ) { - NSLDAPI_FREE( lc->lconn_krbinstance ); - } - /* - * if this is the default connection (lc->lconn_sb==ld->ld_sbp) - * we do not free the Sockbuf here since it will be freed - * later inside ldap_unbind(). - */ - if ( lc->lconn_sb != ld->ld_sbp ) { - ber_sockbuf_free( lc->lconn_sb ); - lc->lconn_sb = NULL; - } - if ( lc->lconn_ber != NULLBER ) { - ber_free( lc->lconn_ber, 1 ); - } - if ( lc->lconn_binddn != NULL ) { - NSLDAPI_FREE( lc->lconn_binddn ); - } -#ifdef LDAP_SASLIO_HOOKS - if ( lc->lconn_sasl_ctx ) { /* the sasl connection context */ - sasl_dispose(&lc->lconn_sasl_ctx); - lc->lconn_sasl_ctx = NULL; - } -#endif /* LDAP_SASLIO_HOOKS */ - NSLDAPI_FREE( lc ); - LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_free_connection: actually freed\n", - 0, 0, 0 ); - } else { - lc->lconn_lastused = time( 0 ); - LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_free_connection: refcnt %d\n", - lc->lconn_refcnt, 0, 0 ); - } -} - - -#ifdef LDAP_DEBUG -void -nsldapi_dump_connection( LDAP *ld, LDAPConn *lconns, int all ) -{ - LDAPConn *lc; - char msg[256]; -/* CTIME for this platform doesn't use this. */ -#if !defined(SUNOS4) && !defined(_WIN32) && !defined(LINUX) && !defined(macintosh) - char buf[26]; -#endif - - sprintf( msg, "** Connection%s:\n", all ? "s" : "" ); - ber_err_print( msg ); - for ( lc = lconns; lc != NULL; lc = lc->lconn_next ) { - if ( lc->lconn_server != NULL ) { - sprintf( msg, "* 0x%p - host: %s port: %d secure: %s%s\n", - lc, ( lc->lconn_server->lsrv_host == NULL ) ? "(null)" - : lc->lconn_server->lsrv_host, - lc->lconn_server->lsrv_port, - ( lc->lconn_server->lsrv_options & - LDAP_SRV_OPT_SECURE ) ? "Yes" : - "No", ( lc->lconn_sb == ld->ld_sbp ) ? - " (default)" : "" ); - ber_err_print( msg ); - } - sprintf( msg, " refcnt: %d pending: %d status: %s\n", - lc->lconn_refcnt, lc->lconn_pending_requests, - ( lc->lconn_status == LDAP_CONNST_CONNECTING ) - ? "Connecting" : - ( lc->lconn_status == LDAP_CONNST_DEAD ) ? "Dead" : - "Connected" ); - ber_err_print( msg ); - sprintf( msg, " last used: %s", - NSLDAPI_CTIME( (time_t *) &lc->lconn_lastused, buf, - sizeof(buf) )); - ber_err_print( msg ); - if ( lc->lconn_ber != NULLBER ) { - ber_err_print( " partial response has been received:\n" ); - ber_dump( lc->lconn_ber, 1 ); - } - ber_err_print( "\n" ); - - if ( !all ) { - break; - } - } -} - - -void -nsldapi_dump_requests_and_responses( LDAP *ld ) -{ - LDAPRequest *lr; - LDAPMessage *lm, *l; - char msg[256]; - - ber_err_print( "** Outstanding Requests:\n" ); - LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); - if (( lr = ld->ld_requests ) == NULL ) { - ber_err_print( " Empty\n" ); - } - for ( ; lr != NULL; lr = lr->lr_next ) { - sprintf( msg, " * 0x%p - msgid %d, origid %d, status %s\n", - lr, lr->lr_msgid, lr->lr_origid, ( lr->lr_status == - LDAP_REQST_INPROGRESS ) ? "InProgress" : - ( lr->lr_status == LDAP_REQST_CHASINGREFS ) ? "ChasingRefs" : - ( lr->lr_status == LDAP_REQST_CONNDEAD ) ? "Dead" : - "Writing" ); - ber_err_print( msg ); - sprintf( msg, " outstanding referrals %d, parent count %d\n", - lr->lr_outrefcnt, lr->lr_parentcnt ); - ber_err_print( msg ); - if ( lr->lr_binddn != NULL ) { - sprintf( msg, " pending bind DN: <%s>\n", lr->lr_binddn ); - ber_err_print( msg ); - } - } - LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); - - ber_err_print( "** Response Queue:\n" ); - LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK ); - if (( lm = ld->ld_responses ) == NULLMSG ) { - ber_err_print( " Empty\n" ); - } - for ( ; lm != NULLMSG; lm = lm->lm_next ) { - sprintf( msg, " * 0x%p - msgid %d, type %d\n", - lm, lm->lm_msgid, lm->lm_msgtype ); - ber_err_print( msg ); - if (( l = lm->lm_chain ) != NULL ) { - ber_err_print( " chained responses:\n" ); - for ( ; l != NULLMSG; l = l->lm_chain ) { - sprintf( msg, - " * 0x%p - msgid %d, type %d\n", - l, l->lm_msgid, l->lm_msgtype ); - ber_err_print( msg ); - } - } - } - LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); -} -#endif /* LDAP_DEBUG */ - - -LDAPRequest * -nsldapi_new_request( LDAPConn *lc, BerElement *ber, int msgid, int expect_resp ) -{ - LDAPRequest *lr; - - lr = (LDAPRequest *)NSLDAPI_CALLOC( 1, sizeof( LDAPRequest )); - - if ( lr != NULL ) { - lr->lr_conn = lc; - lr->lr_ber = ber; - lr->lr_msgid = lr->lr_origid = msgid; - lr->lr_expect_resp = expect_resp; - lr->lr_status = LDAP_REQST_INPROGRESS; - lr->lr_res_errno = LDAP_SUCCESS; /* optimistic */ - - if ( lc != NULL ) { /* mark connection as in use */ - ++lc->lconn_refcnt; - lc->lconn_lastused = time( 0 ); - } - } - - return( lr ); -} - - -void -nsldapi_free_request( LDAP *ld, LDAPRequest *lr, int free_conn ) -{ - LDAPRequest *tmplr, *nextlr; - - LDAPDebug( LDAP_DEBUG_TRACE, - "nsldapi_free_request 0x%p (origid %d, msgid %d)\n", - lr, lr->lr_origid, lr->lr_msgid ); - - if ( lr->lr_parent != NULL ) { - --lr->lr_parent->lr_outrefcnt; - } - - if ( lr->lr_status == LDAP_REQST_WRITING ) { - --lr->lr_conn->lconn_pending_requests; - } - - /* free all of our spawned referrals (child requests) */ - for ( tmplr = lr->lr_child; tmplr != NULL; tmplr = nextlr ) { - nextlr = tmplr->lr_sibling; - nsldapi_free_request( ld, tmplr, free_conn ); - } - - if ( free_conn ) { - nsldapi_free_connection( ld, lr->lr_conn, NULL, NULL, 0, 1 ); - } - - if ( lr->lr_prev == NULL ) { - ld->ld_requests = lr->lr_next; - } else { - lr->lr_prev->lr_next = lr->lr_next; - } - - if ( lr->lr_next != NULL ) { - lr->lr_next->lr_prev = lr->lr_prev; - } - - if ( lr->lr_ber != NULL ) { - ber_free( lr->lr_ber, 1 ); - } - - if ( lr->lr_res_error != NULL ) { - NSLDAPI_FREE( lr->lr_res_error ); - } - - if ( lr->lr_res_matched != NULL ) { - NSLDAPI_FREE( lr->lr_res_matched ); - } - - if ( lr->lr_binddn != NULL ) { - NSLDAPI_FREE( lr->lr_binddn ); - } - - if ( lr->lr_res_ctrls != NULL ) { - ldap_controls_free( lr->lr_res_ctrls ); - } - NSLDAPI_FREE( lr ); -} - - -/* - * Add a request to the end of the list of outstanding requests. - * This function must be called with these two locks in hand, acquired in - * this order: - * LDAP_CONN_LOCK - * LDAP_REQ_LOCK - */ -void -nsldapi_queue_request_nolock( LDAP *ld, LDAPRequest *lr ) -{ - if ( NULL == ld->ld_requests ) { - ld->ld_requests = lr; - } else { - LDAPRequest *tmplr; - - for ( tmplr = ld->ld_requests; tmplr->lr_next != NULL; - tmplr = tmplr->lr_next ) { - ; - } - tmplr->lr_next = lr; - lr->lr_prev = tmplr; - } -} - - -static void -free_servers( LDAPServer *srvlist ) -{ - LDAPServer *nextsrv; - - while ( srvlist != NULL ) { - nextsrv = srvlist->lsrv_next; - if ( srvlist->lsrv_dn != NULL ) { - NSLDAPI_FREE( srvlist->lsrv_dn ); - } - if ( srvlist->lsrv_host != NULL ) { - NSLDAPI_FREE( srvlist->lsrv_host ); - } - NSLDAPI_FREE( srvlist ); - srvlist = nextsrv; - } -} - - -/* - * Initiate chasing of LDAPv2+ (Umich extension) referrals. - * - * Returns an LDAP error code. - * - * Note that *hadrefp will be set to 1 if one or more referrals were found in - * "*errstrp" (even if we can't chase them) and zero if none were found. - * - * XXX merging of errors in this routine needs to be improved. - */ -int -nsldapi_chase_v2_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, - int *totalcountp, int *chasingcountp ) -{ - char *p, *ref, *unfollowed; - LDAPRequest *origreq; - int rc, tmprc, len, unknown; - - LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_chase_v2_referrals\n", 0, 0, 0 ); - - *totalcountp = *chasingcountp = 0; - - if ( *errstrp == NULL ) { - return( LDAP_SUCCESS ); - } - - len = strlen( *errstrp ); - for ( p = *errstrp; len >= LDAP_REF_STR_LEN; ++p, --len ) { - if (( *p == 'R' || *p == 'r' ) && strncasecmp( p, - LDAP_REF_STR, LDAP_REF_STR_LEN ) == 0 ) { - *p = '\0'; - p += LDAP_REF_STR_LEN; - break; - } - } - - if ( len < LDAP_REF_STR_LEN ) { - return( LDAP_SUCCESS ); - } - - if ( lr->lr_parentcnt >= ld->ld_refhoplimit ) { - LDAPDebug( LDAP_DEBUG_TRACE, - "more than %d referral hops (dropping)\n", - ld->ld_refhoplimit, 0, 0 ); - return( LDAP_REFERRAL_LIMIT_EXCEEDED ); - } - - /* find original request */ - for ( origreq = lr; origreq->lr_parent != NULL; - origreq = origreq->lr_parent ) { - ; - } - - unfollowed = NULL; - rc = LDAP_SUCCESS; - - /* parse out & follow referrals */ - for ( ref = p; rc == LDAP_SUCCESS && ref != NULL; ref = p ) { - if (( p = strchr( ref, '\n' )) != NULL ) { - *p++ = '\0'; - } else { - p = NULL; - } - - ++*totalcountp; - - rc = chase_one_referral( ld, lr, origreq, ref, "v2 referral", - &unknown, 0 /* not a reference */ ); - - if ( rc != LDAP_SUCCESS || unknown ) { - if (( tmprc = nsldapi_append_referral( ld, &unfollowed, - ref )) != LDAP_SUCCESS ) { - rc = tmprc; - } - } else { - ++*chasingcountp; - } - } - - NSLDAPI_FREE( *errstrp ); - *errstrp = unfollowed; - - return( rc ); -} - - -/* returns an LDAP error code */ -int -nsldapi_chase_v3_refs( LDAP *ld, LDAPRequest *lr, char **v3refs, - int is_reference, int *totalcountp, int *chasingcountp ) -{ - int rc = LDAP_SUCCESS; - int i, unknown; - LDAPRequest *origreq; - - *totalcountp = *chasingcountp = 0; - - if ( v3refs == NULL || v3refs[0] == NULL ) { - return( LDAP_SUCCESS ); - } - - *totalcountp = 1; - - if ( lr->lr_parentcnt >= ld->ld_refhoplimit ) { - LDAPDebug( LDAP_DEBUG_TRACE, - "more than %d referral hops (dropping)\n", - ld->ld_refhoplimit, 0, 0 ); - return( LDAP_REFERRAL_LIMIT_EXCEEDED ); - } - - /* find original request */ - for ( origreq = lr; origreq->lr_parent != NULL; - origreq = origreq->lr_parent ) { - ; - } - - /* - * in LDAPv3, we just need to follow one referral in the set. - * we dp this by stopping as soon as we succeed in initiating a - * chase on any referral (basically this means we were able to connect - * to the server and bind). - */ - for ( i = 0; v3refs[i] != NULL; ++i ) { - rc = chase_one_referral( ld, lr, origreq, v3refs[i], - is_reference ? "v3 reference" : "v3 referral", &unknown, - is_reference ); - if ( rc == LDAP_SUCCESS && !unknown ) { - *chasingcountp = 1; - break; - } - } - - /* XXXmcs: should we save unfollowed referrals somewhere? */ - - return( rc ); /* last error is as good as any other I guess... */ -} - - -/* - * returns an LDAP error code - * - * XXXmcs: this function used to have #ifdef LDAP_DNS code in it but I - * removed it when I improved the parsing (we don't define LDAP_DNS - * here at Netscape). - */ -static int -chase_one_referral( LDAP *ld, LDAPRequest *lr, LDAPRequest *origreq, - char *refurl, char *desc, int *unknownp, int is_reference ) -{ - int rc, tmprc, secure, msgid; - LDAPServer *srv; - BerElement *ber; - LDAPURLDesc *ludp; - - *unknownp = 0; - ludp = NULLLDAPURLDESC; - - if ( nsldapi_url_parse( refurl, &ludp, 0 ) != 0 ) { - LDAPDebug( LDAP_DEBUG_TRACE, - "ignoring unknown %s <%s>\n", desc, refurl, 0 ); - *unknownp = 1; - rc = LDAP_SUCCESS; - goto cleanup_and_return; - } - - secure = (( ludp->lud_options & LDAP_URL_OPT_SECURE ) != 0 ); - -/* XXXmcs: can't tell if secure is supported by connect callback */ - if ( secure && ld->ld_extconnect_fn == NULL ) { - LDAPDebug( LDAP_DEBUG_TRACE, - "ignoring LDAPS %s <%s>\n", desc, refurl, 0 ); - *unknownp = 1; - rc = LDAP_SUCCESS; - goto cleanup_and_return; - } - - LDAPDebug( LDAP_DEBUG_TRACE, "chasing LDAP%s %s: <%s>\n", - secure ? "S" : "", desc, refurl ); - - LDAP_MUTEX_LOCK( ld, LDAP_MSGID_LOCK ); - msgid = ++ld->ld_msgid; - LDAP_MUTEX_UNLOCK( ld, LDAP_MSGID_LOCK ); - - if (( tmprc = re_encode_request( ld, origreq->lr_ber, msgid, - ludp, &ber, is_reference )) != LDAP_SUCCESS ) { - rc = tmprc; - goto cleanup_and_return; - } - - if (( srv = (LDAPServer *)NSLDAPI_CALLOC( 1, sizeof( LDAPServer ))) - == NULL ) { - ber_free( ber, 1 ); - rc = LDAP_NO_MEMORY; - goto cleanup_and_return; - } - - if ( ludp->lud_host == NULL && ld->ld_defhost == NULL ) { - srv->lsrv_host = NULL; - } else { - if ( ludp->lud_host == NULL ) { - srv->lsrv_host = - nsldapi_strdup( origreq->lr_conn->lconn_server->lsrv_host ); - LDAPDebug( LDAP_DEBUG_TRACE, - "chase_one_referral: using hostname '%s' from original " - "request on new request\n", - srv->lsrv_host, 0, 0); - } else { - srv->lsrv_host = nsldapi_strdup( ludp->lud_host ); - LDAPDebug( LDAP_DEBUG_TRACE, - "chase_one_referral: using hostname '%s' as specified " - "on new request\n", - srv->lsrv_host, 0, 0); - } - - if ( srv->lsrv_host == NULL ) { - NSLDAPI_FREE( (char *)srv ); - ber_free( ber, 1 ); - rc = LDAP_NO_MEMORY; - goto cleanup_and_return; - } - } - - if ( ludp->lud_port == 0 && ludp->lud_host == NULL ) { - srv->lsrv_port = origreq->lr_conn->lconn_server->lsrv_port; - LDAPDebug( LDAP_DEBUG_TRACE, - "chase_one_referral: using port (%d) from original " - "request on new request\n", - srv->lsrv_port, 0, 0); - } else if ( ludp->lud_port != 0 ) { - srv->lsrv_port = ludp->lud_port; - LDAPDebug( LDAP_DEBUG_TRACE, - "chase_one_referral: using port (%d) as specified on " - "new request\n", - srv->lsrv_port, 0, 0); - } else { - srv->lsrv_port = secure ? LDAPS_PORT : LDAP_PORT; - LDAPDebug( LDAP_DEBUG_TRACE, - "chase_one_referral: using default port (%d)\n", - srv->lsrv_port, 0, 0 ); - } - - if ( secure ) { - srv->lsrv_options |= LDAP_SRV_OPT_SECURE; - } - - if ( nsldapi_send_server_request( ld, ber, msgid, - lr, srv, NULL, NULL, 1 ) < 0 ) { - rc = LDAP_GET_LDERRNO( ld, NULL, NULL ); - LDAPDebug( LDAP_DEBUG_ANY, "Unable to chase %s %s (%s)\n", - desc, refurl, ldap_err2string( rc )); - } else { - rc = LDAP_SUCCESS; - } - -cleanup_and_return: - if ( ludp != NULLLDAPURLDESC ) { - ldap_free_urldesc( ludp ); - } - - return( rc ); -} - - -/* returns an LDAP error code */ -int -nsldapi_append_referral( LDAP *ld, char **referralsp, char *s ) -{ - int first; - - if ( *referralsp == NULL ) { - first = 1; - *referralsp = (char *)NSLDAPI_MALLOC( strlen( s ) + - LDAP_REF_STR_LEN + 1 ); - } else { - first = 0; - *referralsp = (char *)NSLDAPI_REALLOC( *referralsp, - strlen( *referralsp ) + strlen( s ) + 2 ); - } - - if ( *referralsp == NULL ) { - return( LDAP_NO_MEMORY ); - } - - if ( first ) { - strcpy( *referralsp, LDAP_REF_STR ); - } else { - strcat( *referralsp, "\n" ); - } - strcat( *referralsp, s ); - - return( LDAP_SUCCESS ); -} - - - -/* returns an LDAP error code */ -static int -re_encode_request( LDAP *ld, BerElement *origber, int msgid, LDAPURLDesc *ludp, - BerElement **berp, int is_reference ) -{ -/* - * XXX this routine knows way too much about how the lber library works! - */ - ber_int_t origmsgid; - ber_tag_t tag; - ber_int_t ver; - int rc; - BerElement *ber; - struct berelement tmpber; - char *dn, *orig_dn; - /* extra stuff for search request */ - ber_int_t scope = -1; - - LDAPDebug( LDAP_DEBUG_TRACE, - "re_encode_request: new msgid %d, new dn <%s>\n", - msgid, ( ludp->lud_dn == NULL ) ? "NONE" : ludp->lud_dn, 0 ); - - tmpber = *origber; - - /* - * All LDAP requests are sequences that start with a message id. For - * everything except delete requests, this is followed by a sequence - * that is tagged with the operation code. For deletes, there is just - * a DN that is tagged with the operation code. - */ - - /* skip past msgid and get operation tag */ - if ( ber_scanf( &tmpber, "{it", &origmsgid, &tag ) == LBER_ERROR ) { - return( LDAP_DECODING_ERROR ); - } - - /* - * XXXmcs: we don't support filters in search referrals yet, - * so if present we return an error which is probably - * better than just ignoring the extra info. - * XXXrichm: we now support scopes. Supporting filters would require - * a lot more additional work to be able to read the filter from - * the ber original search request, convert to string, etc. It might - * be better and easier to change nsldapi_build_search_req to have - * some special mode by which you could tell it to skip filter and - * attrlist encoding if no filter was given - then we could just - * create a new ber search request with our new filter if present. - */ - if ( ( tag == LDAP_REQ_SEARCH ) && ( ludp->lud_filter != NULL )) { - return( LDAP_LOCAL_ERROR ); - } - - if ( tag == LDAP_REQ_BIND ) { - /* bind requests have a version number before the DN */ - rc = ber_scanf( &tmpber, "{ia", &ver, &orig_dn ); - } else if ( tag == LDAP_REQ_DELETE ) { - /* delete requests DNs are not within a sequence */ - rc = ber_scanf( &tmpber, "a", &orig_dn ); - } else if ( tag == LDAP_REQ_SEARCH ) { - /* need scope */ - rc = ber_scanf( &tmpber, "{ae", &orig_dn, &scope ); - } else { - rc = ber_scanf( &tmpber, "{a", &orig_dn ); - } - - if ( rc == LBER_ERROR ) { - return( LDAP_DECODING_ERROR ); - } - - if ( ludp->lud_dn == NULL ) { - dn = orig_dn; - } else { - dn = ludp->lud_dn; - NSLDAPI_FREE( orig_dn ); - orig_dn = NULL; - } - - if ( ludp->lud_scope != -1 ) { - scope = ludp->lud_scope; /* scope provided by ref - use it */ - } else if (is_reference) { - /* - * RFC 4511 says that the we should use scope BASE in the - * search reference if the client's original request was for scope - * ONELEVEL - since the server did not include the scope in the - * search reference returned, we must provide the correct behavior - * in the client (i.e. the correct behavior is implied) - * see RFC 4511 section 4.5.3 for more information - */ - if (scope == LDAP_SCOPE_ONELEVEL) { - scope = LDAP_SCOPE_BASE; - } - } - - /* allocate and build the new request */ - if (( rc = nsldapi_alloc_ber_with_options( ld, &ber )) - != LDAP_SUCCESS ) { - if ( orig_dn != NULL ) { - NSLDAPI_FREE( orig_dn ); - } - return( rc ); - } - - if ( tag == LDAP_REQ_BIND ) { - rc = ber_printf( ber, "{it{is", msgid, tag, ver , dn ); - } else if ( tag == LDAP_REQ_DELETE ) { - rc = ber_printf( ber, "{its}", msgid, tag, dn ); - } else if ( tag == LDAP_REQ_SEARCH ) { - rc = ber_printf( ber, "{it{se", msgid, tag, dn, scope ); - } else { - rc = ber_printf( ber, "{it{s", msgid, tag, dn ); - } - - if ( orig_dn != NULL ) { - NSLDAPI_FREE( orig_dn ); - } -/* - * can't use "dn" or "orig_dn" from this point on (they've been freed) - */ - - if ( rc == -1 ) { - ber_free( ber, 1 ); - return( LDAP_ENCODING_ERROR ); - } - - if ( tag != LDAP_REQ_DELETE && - ( ber_write( ber, tmpber.ber_ptr, ( tmpber.ber_end - - tmpber.ber_ptr ), 0 ) != ( tmpber.ber_end - tmpber.ber_ptr ) - || ber_printf( ber, "}}" ) == -1 )) { - ber_free( ber, 1 ); - return( LDAP_ENCODING_ERROR ); - } - -#ifdef LDAP_DEBUG - if ( ldap_debug & LDAP_DEBUG_PACKETS ) { - LDAPDebug( LDAP_DEBUG_ANY, "re_encode_request new request is:\n", - 0, 0, 0 ); - ber_dump( ber, 0 ); - } -#endif /* LDAP_DEBUG */ - - *berp = ber; - return( LDAP_SUCCESS ); -} - - -LDAPRequest * -nsldapi_find_request_by_msgid( LDAP *ld, int msgid ) -{ - LDAPRequest *lr; - - for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) { - if ( msgid == lr->lr_msgid ) { - break; - } - } - - return( lr ); -} - - -/* - * nsldapi_connection_lost_nolock() resets "ld" to a non-connected, known - * state. It should be called whenever a fatal error occurs on the - * Sockbuf "sb." sb == NULL means we don't know specifically where - * the problem was so we assume all connections are bad. - */ -void -nsldapi_connection_lost_nolock( LDAP *ld, Sockbuf *sb ) -{ - LDAPRequest *lr; - - /* - * change status of all pending requests that are associated with "sb - * to "connection dead." - * also change the connection status to "dead" and remove it from - * the list of sockets we are interested in. - */ - for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) { - if ( sb == NULL || - ( lr->lr_conn != NULL && lr->lr_conn->lconn_sb == sb )) { - lr->lr_status = LDAP_REQST_CONNDEAD; - if ( lr->lr_conn != NULL ) { - lr->lr_conn->lconn_status = LDAP_CONNST_DEAD; - nsldapi_iostatus_interest_clear( ld, - lr->lr_conn->lconn_sb ); - } - } - } -} - - -#ifdef LDAP_DNS -static LDAPServer * -dn2servers( LDAP *ld, char *dn ) /* dn can also be a domain.... */ -{ - char *p, *domain, *host, *server_dn, **dxs; - int i, port; - LDAPServer *srvlist, *prevsrv, *srv; - - if (( domain = strrchr( dn, '@' )) != NULL ) { - ++domain; - } else { - domain = dn; - } - - if (( dxs = nsldapi_getdxbyname( domain )) == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); - return( NULL ); - } - - srvlist = NULL; - - for ( i = 0; dxs[ i ] != NULL; ++i ) { - port = LDAP_PORT; - server_dn = NULL; - if ( strchr( dxs[ i ], ':' ) == NULL ) { - host = dxs[ i ]; - } else if ( strlen( dxs[ i ] ) >= 7 && - strncmp( dxs[ i ], "ldap://", 7 ) == 0 ) { - host = dxs[ i ] + 7; - if (( p = strchr( host, ':' )) == NULL ) { - p = host; - } else { - *p++ = '\0'; - port = atoi( p ); - } - if (( p = strchr( p, '/' )) != NULL ) { - server_dn = ++p; - if ( *server_dn == '\0' ) { - server_dn = NULL; - } - } - } else { - host = NULL; - } - - if ( host != NULL ) { /* found a server we can use */ - if (( srv = (LDAPServer *)NSLDAPI_CALLOC( 1, - sizeof( LDAPServer ))) == NULL ) { - free_servers( srvlist ); - srvlist = NULL; - break; /* exit loop & return */ - } - - /* add to end of list of servers */ - if ( srvlist == NULL ) { - srvlist = srv; - } else { - prevsrv->lsrv_next = srv; - } - prevsrv = srv; - - /* copy in info. */ - if (( srv->lsrv_host = nsldapi_strdup( host )) == NULL - || ( server_dn != NULL && ( srv->lsrv_dn = - nsldapi_strdup( server_dn )) == NULL )) { - free_servers( srvlist ); - srvlist = NULL; - break; /* exit loop & return */ - } - srv->lsrv_port = port; - } - } - - ldap_value_free( dxs ); - - if ( srvlist == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, NULL, NULL ); - } - - return( srvlist ); -} -#endif /* LDAP_DNS */
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap/result.c
Deleted
@@ -1,1473 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright (c) 1990 Regents of the University of Michigan. - * All rights reserved. - */ -/* - * result.c - wait for an ldap result - */ - -#if 0 -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif -#endif - -#include "ldap-int.h" - -/* - * Special return values used by some functions (wait4msg() and read1msg()). - */ -#define NSLDAPI_RESULT_TIMEOUT 0 -#define NSLDAPI_RESULT_ERROR (-1) -#define NSLDAPI_RESULT_NOT_FOUND (-2) - -static int check_response_queue( LDAP *ld, int msgid, int all, - int do_abandon_check, LDAPMessage **result ); -static int ldap_abandoned( LDAP *ld, int msgid ); -static int ldap_mark_abandoned( LDAP *ld, int msgid ); -static int wait4msg( LDAP *ld, int msgid, int all, int unlock_permitted, - struct timeval *timeout, LDAPMessage **result ); -static int read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn **lcp, - LDAPMessage **result ); -static void check_for_refs( LDAP *ld, LDAPRequest *lr, BerElement *ber, - int ldapversion, int *totalcountp, int *chasingcountp ); -static int build_result_ber( LDAP *ld, BerElement **berp, LDAPRequest *lr ); -static void merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ); -#if defined( CLDAP ) -static int cldap_select1( LDAP *ld, struct timeval *timeout ); -#endif -static void link_pend( LDAP *ld, LDAPPend *lp ); - -/* - * ldap_result - wait for an ldap result response to a message from the - * ldap server. If msgid is -1, any message will be accepted, otherwise - * ldap_result will wait for a response with msgid. If all is 0 the - * first message with id msgid will be accepted, otherwise, ldap_result - * will wait for all responses with id msgid and then return a pointer to - * the entire list of messages. This is only useful for search responses, - * which can be of two message types (zero or more entries, followed by an - * ldap result). The type of the first message received is returned. - * When waiting, any messages that have been abandoned are discarded. - * - * Example: - * ldap_result( s, msgid, all, timeout, result ) - */ -int -LDAP_CALL -ldap_result( - LDAP *ld, - int msgid, - int all, - struct timeval *timeout, - LDAPMessage **result -) -{ - int rc; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_result\n", 0, 0, 0 ); - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - return( -1 ); /* punt */ - } - - LDAP_MUTEX_LOCK( ld, LDAP_RESULT_LOCK ); - - rc = nsldapi_result_nolock(ld, msgid, all, 1, timeout, result); - - LDAP_MUTEX_UNLOCK( ld, LDAP_RESULT_LOCK ); - - return( rc ); -} - - -int -nsldapi_result_nolock( LDAP *ld, int msgid, int all, int unlock_permitted, - struct timeval *timeout, LDAPMessage **result ) -{ - int rc; - - LDAPDebug( LDAP_DEBUG_TRACE, - "nsldapi_result_nolock (msgid=%d, all=%d)\n", msgid, all, 0 ); - - /* - * First, look through the list of responses we have received on - * this association and see if the response we're interested in - * is there. If it is, return it. If not, call wait4msg() to - * wait until it arrives or timeout occurs. - */ - - if ( result == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return( -1 ); - } - - if ( check_response_queue( ld, msgid, all, 1, result ) != 0 ) { - LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL ); - rc = (*result)->lm_msgtype; - } else { - rc = wait4msg( ld, msgid, all, unlock_permitted, timeout, - result ); - } - - /* - * XXXmcs should use cache function pointers to hook in memcache - */ - if ( ld->ld_memcache != NULL && NSLDAPI_SEARCH_RELATED_RESULT( rc ) && - !((*result)->lm_fromcache )) { - ldap_memcache_append( ld, (*result)->lm_msgid, - (all || NSLDAPI_IS_SEARCH_RESULT( rc )), *result ); - } - - return( rc ); -} - - -/* - * Look through the list of queued responses for a message that matches the - * criteria in the msgid and all parameters. msgid == LDAP_RES_ANY matches - * all ids. - * - * If an appropriate message is found, a non-zero value is returned and the - * message is dequeued and assigned to *result. - * - * If not, *result is set to NULL and this function returns 0. - */ -static int -check_response_queue( LDAP *ld, int msgid, int all, int do_abandon_check, - LDAPMessage **result ) -{ - LDAPMessage *lm, *lastlm, *nextlm; - LDAPRequest *lr; - - LDAPDebug( LDAP_DEBUG_TRACE, - "=> check_response_queue (msgid=%d, all=%d)\n", msgid, all, 0 ); - - *result = NULL; - lastlm = NULL; - LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK ); - for ( lm = ld->ld_responses; lm != NULL; lm = nextlm ) { - nextlm = lm->lm_next; - - if ( do_abandon_check && ldap_abandoned( ld, lm->lm_msgid ) ) { - ldap_mark_abandoned( ld, lm->lm_msgid ); - - if ( lastlm == NULL ) { - ld->ld_responses = lm->lm_next; - } else { - lastlm->lm_next = nextlm; - } - - ldap_msgfree( lm ); - - continue; - } - - if ( msgid == LDAP_RES_ANY || lm->lm_msgid == msgid ) { - LDAPMessage *tmp; - - if ( all == 0 - || (lm->lm_msgtype != LDAP_RES_SEARCH_RESULT - && lm->lm_msgtype != LDAP_RES_SEARCH_REFERENCE - && lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY) ) - break; - - for ( tmp = lm; tmp != NULL; tmp = tmp->lm_chain ) { - if ( tmp->lm_msgtype == LDAP_RES_SEARCH_RESULT ) - break; - } - - if ( tmp == NULL ) { - LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); - LDAPDebug( LDAP_DEBUG_TRACE, - "<= check_response_queue NOT FOUND\n", - 0, 0, 0 ); - return( 0 ); /* no message to return */ - } - - break; - } - lastlm = lm; - } - - /* - * if we did not find a message OR if the one we found is a result for - * a request that is still pending, return failure. - */ - if ( lm == NULL - || (( lr = nsldapi_find_request_by_msgid( ld, lm->lm_msgid )) - != NULL && lr->lr_outrefcnt > 0 )) { - LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); - LDAPDebug( LDAP_DEBUG_TRACE, - "<= check_response_queue NOT FOUND\n", - 0, 0, 0 ); - return( 0 ); /* no message to return */ - } - - if ( all == 0 ) { - if ( lm->lm_chain == NULL ) { - if ( lastlm == NULL ) { - ld->ld_responses = lm->lm_next; - } else { - lastlm->lm_next = lm->lm_next; - } - } else { - if ( lastlm == NULL ) { - ld->ld_responses = lm->lm_chain; - ld->ld_responses->lm_next = lm->lm_next; - } else { - lastlm->lm_next = lm->lm_chain; - lastlm->lm_next->lm_next = lm->lm_next; - } - } - } else { - if ( lastlm == NULL ) { - ld->ld_responses = lm->lm_next; - } else { - lastlm->lm_next = lm->lm_next; - } - } - - if ( all == 0 ) { - lm->lm_chain = NULL; - } - lm->lm_next = NULL; - LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); - - *result = lm; - LDAPDebug( LDAP_DEBUG_TRACE, - "<= check_response_queue returning msgid %d type %d\n", - lm->lm_msgid, lm->lm_msgtype, 0 ); - return( 1 ); /* a message was found and returned in *result */ -} - - -/* - * wait4msg(): Poll for incoming LDAP messages, respecting the timeout. - * - * Return values: - * > 0: message received; value is the tag of the message. - * NSLDAPI_RESULT_TIMEOUT timeout exceeded. - * NSLDAPI_RESULT_ERROR fatal error occurred such as connection closed. - */ -static int -wait4msg( LDAP *ld, int msgid, int all, int unlock_permitted, - struct timeval *timeout, LDAPMessage **result ) -{ - int err, rc = NSLDAPI_RESULT_NOT_FOUND, msgfound; - struct timeval tv, *tvp; - long start_time = 0, tmp_time; - LDAPConn *lc, *nextlc; - /* lr points to the specific request we are waiting for, if any */ - LDAPRequest *lr = NULL; - -#ifdef LDAP_DEBUG - if ( timeout == NULL ) { - LDAPDebug( LDAP_DEBUG_TRACE, "wait4msg (infinite timeout)\n", - 0, 0, 0 ); - } else { - LDAPDebug( LDAP_DEBUG_TRACE, "wait4msg (timeout %ld sec, %ld usec)\n", - timeout->tv_sec, timeout->tv_usec, 0 ); - } -#endif /* LDAP_DEBUG */ - - /* check the cache */ - if ( ld->ld_cache_on && ld->ld_cache_result != NULL ) { - /* if ( unlock_permitted ) LDAP_MUTEX_UNLOCK( ld ); */ - LDAP_MUTEX_LOCK( ld, LDAP_CACHE_LOCK ); - rc = (ld->ld_cache_result)( ld, msgid, all, timeout, result ); - LDAP_MUTEX_UNLOCK( ld, LDAP_CACHE_LOCK ); - /* if ( unlock_permitted ) LDAP_MUTEX_LOCK( ld ); */ - if ( rc != NSLDAPI_RESULT_TIMEOUT ) { - return( rc ); - } - if ( ld->ld_cache_strategy == LDAP_CACHE_LOCALDB ) { - LDAP_SET_LDERRNO( ld, LDAP_TIMEOUT, NULL, NULL ); - return( NSLDAPI_RESULT_TIMEOUT ); - } - } - - /* - * if we are looking for a specific msgid, check to see if it is - * associated with a dead connection and return an error if so. - */ - if ( msgid != LDAP_RES_ANY && msgid != LDAP_RES_UNSOLICITED ) { - LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); - if (( lr = nsldapi_find_request_by_msgid( ld, msgid )) - == NULL ) { - LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, - nsldapi_strdup( "unknown message id" )); - return( NSLDAPI_RESULT_ERROR ); /* could not find request for msgid */ - } - if ( lr->lr_conn != NULL && - lr->lr_conn->lconn_status == LDAP_CONNST_DEAD ) { - nsldapi_free_request( ld, lr, 1 ); - LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); - LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, NULL, NULL ); - return( NSLDAPI_RESULT_ERROR ); /* connection dead */ - } - LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); - } - - if ( timeout == NULL ) { - tvp = NULL; - } else { - tv = *timeout; - tvp = &tv; - start_time = (long)time( NULL ); - } - - rc = NSLDAPI_RESULT_NOT_FOUND; - while ( rc == NSLDAPI_RESULT_NOT_FOUND ) { - msgfound = 0; -#ifdef LDAP_DEBUG - if ( ldap_debug & LDAP_DEBUG_TRACE ) { - nsldapi_dump_connection( ld, ld->ld_conns, 1 ); - nsldapi_dump_requests_and_responses( ld ); - } -#endif /* LDAP_DEBUG */ - - /* - * Check if we have some data in a connection's BER buffer. - * If so, use it. - */ - LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK ); - LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); - for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { - if ( lc->lconn_sb->sb_ber.ber_ptr < - lc->lconn_sb->sb_ber.ber_end ) { - /* read1msg() might free the connection. */ - rc = read1msg( ld, msgid, all, lc->lconn_sb, - &lc, result ); - /* Indicate to next segment that we've processed a message - (or several, via chased refs) this time around. */ - msgfound = 1; - break; - } - } - LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); - LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); - - if ( !msgfound ) { - /* - * There was no buffered data. Poll to check connection - * status (read/write readiness). - */ - err = nsldapi_iostatus_poll( ld, tvp ); - -#if defined( LDAP_DEBUG ) && !defined( macintosh ) && !defined( DOS ) - if ( err == -1 ) { - LDAPDebug( LDAP_DEBUG_TRACE, - "nsldapi_iostatus_poll returned -1: errno %d\n", - LDAP_GET_ERRNO( ld ), 0, 0 ); - } -#endif - -#if !defined( macintosh ) && !defined( DOS ) - /* - * If the restart option is enabled and the error - * was EINTR, try again. - */ - if ( err == -1 - && 0 != ( ld->ld_options & LDAP_BITOPT_RESTART ) - && LDAP_GET_ERRNO( ld ) == EINTR ) { - continue; - } -#endif - - /* - * Handle timeouts (no activity) and fatal errors. - */ - if ( err == -1 || err == 0 ) { - LDAP_SET_LDERRNO( ld, (err == -1 ? - LDAP_SERVER_DOWN : LDAP_TIMEOUT), NULL, - NULL ); - if ( err == -1 ) { - LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); - nsldapi_connection_lost_nolock( ld, - NULL ); - LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); - rc = NSLDAPI_RESULT_ERROR; - } else { - rc = NSLDAPI_RESULT_TIMEOUT; - } - return( rc ); - } - - /* - * Check each connection for interesting activity. - */ - LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK ); - LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); - for ( lc = ld->ld_conns; - rc == NSLDAPI_RESULT_NOT_FOUND && lc != NULL; - lc = nextlc ) { - nextlc = lc->lconn_next; - - /* - * For connections that are in the CONNECTING - * state, check for write ready (which - * indicates that the connection completed) and - * transition to the CONNECTED state. - */ - if ( lc->lconn_status == LDAP_CONNST_CONNECTING - && nsldapi_iostatus_is_write_ready( ld, - lc->lconn_sb ) ) { - lc->lconn_status = LDAP_CONNST_CONNECTED; - LDAPDebug( LDAP_DEBUG_TRACE, - "wait4msg: connection 0x%p -" - " LDAP_CONNST_CONNECTING ->" - " LDAP_CONNST_CONNECTED\n", - lc, 0, 0 ); - } - - if ( lc->lconn_status - != LDAP_CONNST_CONNECTED ) { - continue; - } - - /* - * For connections that are CONNECTED, check - * for read ready (which indicates that data - * from server is available), and, for - * connections with associated requests that - * have not yet been sent, write ready (okay - * to send some data to the server). - */ - if ( nsldapi_iostatus_is_read_ready( ld, - lc->lconn_sb )) { - /* read1msg() might free the connection. */ - rc = read1msg( ld, msgid, all, - lc->lconn_sb, &lc, result ); - } - - /* - * Send pending requests if possible. If there is no lc then - * it was a child connection closed by read1msg(). - */ - if ( lc && lc->lconn_pending_requests > 0 - && nsldapi_iostatus_is_write_ready( ld, - lc->lconn_sb )) { - err = nsldapi_send_pending_requests_nolock( - ld, lc ); - if ( err == -1 && - rc == NSLDAPI_RESULT_NOT_FOUND ) { - rc = NSLDAPI_RESULT_ERROR; - } - } - - } - - LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); - LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); - } - - /* - * It is possible that recursion occurred while chasing - * referrals and as a result the message we are looking - * for may have been placed on the response queue. Look - * for it there before continuing so we don't end up - * waiting on the network for a message that we already - * received! - */ - if ( rc == NSLDAPI_RESULT_NOT_FOUND && - check_response_queue( ld, msgid, all, 0, result ) != 0 ) { - LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL ); - rc = (*result)->lm_msgtype; - } - - /* - * honor the timeout if specified - */ - if ( rc == NSLDAPI_RESULT_NOT_FOUND && tvp != NULL ) { - tmp_time = (long)time( NULL ); - if (( tv.tv_sec -= ( tmp_time - start_time )) <= 0 ) { - rc = NSLDAPI_RESULT_TIMEOUT; - LDAP_SET_LDERRNO( ld, LDAP_TIMEOUT, NULL, - NULL ); - break; - } - - LDAPDebug( LDAP_DEBUG_TRACE, "wait4msg: %ld secs to go\n", - tv.tv_sec, 0, 0 ); - start_time = tmp_time; - } - } - - return( rc ); -} - - -#define NSLDAPI_REQUEST_COMPLETE( lr ) \ - ( (lr)->lr_outrefcnt <= 0 && \ - (lr)->lr_res_msgtype != LDAP_RES_SEARCH_ENTRY && \ - (lr)->lr_res_msgtype != LDAP_RES_SEARCH_REFERENCE ) - -/* - * read1msg() should be called with LDAP_CONN_LOCK and LDAP_REQ_LOCK locked. - * - * Return values: - * > 0: message received; value is the tag of the message. - * NSLDAPI_RESULT_TIMEOUT timeout exceeded. - * NSLDAPI_RESULT_ERROR fatal error occurred such as connection closed. - * NSLDAPI_RESULT_NOT_FOUND message not yet complete; keep waiting. - * - * The LDAPConn passed in my be freed by read1msg() if the reference count - * shows that it's no longer needed. - */ -static int -read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn **lcp, - LDAPMessage **result ) -{ - BerElement *ber; - LDAPMessage *new, *l, *prev, *chainprev, *tmp; - ber_int_t id; - ber_tag_t tag; - ber_len_t len; - int terrno, lderr, foundit = 0; - LDAPRequest *lr; - int rc, has_parent, message_can_be_returned; - int manufactured_result = 0; - LDAPConn *lc = *lcp; - - LDAPDebug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 ); - - message_can_be_returned = 1; /* the usual case... */ - - /* - * if we are not already in the midst of reading a message, allocate - * a ber that is associated with this connection - */ - if ( lc->lconn_ber == NULLBER && nsldapi_alloc_ber_with_options( ld, - &lc->lconn_ber ) != LDAP_SUCCESS ) { - return( NSLDAPI_RESULT_ERROR ); - } - - /* - * ber_get_next() doesn't set errno on EOF, so we pre-set it to - * zero to avoid getting tricked by leftover "EAGAIN" errors - */ - LDAP_SET_ERRNO( ld, 0 ); - - /* get the next message */ - if ( (tag = ber_get_next( sb, &len, lc->lconn_ber )) - != LDAP_TAG_MESSAGE ) { - terrno = LDAP_GET_ERRNO( ld ); - if ( terrno == EWOULDBLOCK || terrno == EAGAIN ) { - return( NSLDAPI_RESULT_NOT_FOUND ); /* try again */ - } - LDAP_SET_LDERRNO( ld, (tag == LBER_DEFAULT ? LDAP_SERVER_DOWN : - LDAP_LOCAL_ERROR), NULL, NULL ); - if ( tag == LBER_DEFAULT ) { - nsldapi_connection_lost_nolock( ld, sb ); - } - return( NSLDAPI_RESULT_ERROR ); - } - - /* - * Since we have received a complete message now, we pull this ber - * out of the connection structure and never read into it again. - */ - ber = lc->lconn_ber; - lc->lconn_ber = NULLBER; - - /* message id */ - if ( ber_get_int( ber, &id ) == LBER_ERROR ) { - ber_free( ber, 1 ); - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - return( NSLDAPI_RESULT_ERROR ); - } - - /* if it's been abandoned, toss it */ - if ( ldap_abandoned( ld, (int)id ) ) { - ber_free( ber, 1 ); - return( NSLDAPI_RESULT_NOT_FOUND ); /* continue looking */ - } - - if ( id == LDAP_RES_UNSOLICITED ) { - lr = NULL; - } else if (( lr = nsldapi_find_request_by_msgid( ld, id )) == NULL ) { - LDAPDebug( LDAP_DEBUG_ANY, - "no request for response with msgid %d (tossing)\n", - id, 0, 0 ); - ber_free( ber, 1 ); - return( NSLDAPI_RESULT_NOT_FOUND ); /* continue looking */ - } - - /* the message type */ - if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) { - ber_free( ber, 1 ); - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - return( NSLDAPI_RESULT_ERROR ); - } - LDAPDebug( LDAP_DEBUG_TRACE, "got %s msgid %d, original id %d\n", - ( tag == LDAP_RES_SEARCH_ENTRY ) ? "ENTRY" : - ( tag == LDAP_RES_SEARCH_REFERENCE ) ? "REFERENCE" : "RESULT", id, - ( lr == NULL ) ? id : lr->lr_origid ); - - if ( lr != NULL ) { - id = lr->lr_origid; - lr->lr_res_msgtype = tag; - } - rc = NSLDAPI_RESULT_NOT_FOUND; /* default is to keep looking (no response found) */ - - if ( id != LDAP_RES_UNSOLICITED && ( tag == LDAP_RES_SEARCH_REFERENCE || - tag != LDAP_RES_SEARCH_ENTRY )) { - int refchasing, reftotal, simple_request = 0; - LDAPControl **ctrls = NULL; - - check_for_refs( ld, lr, ber, lc->lconn_version, &reftotal, - &refchasing ); - - if ( refchasing > 0 || lr->lr_outrefcnt > 0 ) { - /* - * we're chasing one or more new refs... - */ - ber_free( ber, 1 ); - ber = NULLBER; - lr->lr_status = LDAP_REQST_CHASINGREFS; - message_can_be_returned = 0; - - } else if ( tag != LDAP_RES_SEARCH_REFERENCE ) { - /* - * this request is complete... - */ - has_parent = ( lr->lr_parent != NULL ); - - if ( lr->lr_outrefcnt <= 0 && !has_parent ) { - /* request without any refs */ - simple_request = ( reftotal == 0 ); - } - - /* - * If this is not a child request and it is a bind - * request, reset the connection's bind DN and - * status based on the result of the operation. - */ - if ( !has_parent && - LDAP_RES_BIND == lr->lr_res_msgtype && - lr->lr_conn != NULL ) { - if ( lr->lr_conn->lconn_binddn != NULL ) { - NSLDAPI_FREE( - lr->lr_conn->lconn_binddn ); - } - if ( LDAP_SUCCESS == nsldapi_parse_result( ld, - lr->lr_res_msgtype, ber, &lderr, NULL, - NULL, NULL, NULL ) - && LDAP_SUCCESS == lderr ) { - lr->lr_conn->lconn_bound = 1; - lr->lr_conn->lconn_binddn = - lr->lr_binddn; - lr->lr_binddn = NULL; - } else { - lr->lr_conn->lconn_bound = 0; - lr->lr_conn->lconn_binddn = NULL; - } - } - - /* - * if this response is to a child request, we toss - * the message contents and just merge error info. - * into the parent. - */ - if ( has_parent ) { - /* Extract any response controls from ber before ditching it */ - if( nsldapi_find_controls( ber, &ctrls ) != LDAP_SUCCESS ) { - ber_free( ber, 1 ); - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - return( NSLDAPI_RESULT_ERROR ); - } - - ber_free( ber, 1 ); - ber = NULLBER; - } - while ( lr->lr_parent != NULL ) { - merge_error_info( ld, lr->lr_parent, lr ); - - lr = lr->lr_parent; - --lr->lr_outrefcnt; - if ( !NSLDAPI_REQUEST_COMPLETE(lr)) { - break; - } - } - /* Stash response controls in original request so they can be baked - into the manufactured result message later */ - if( ctrls != NULL ) { - if( lr->lr_res_ctrls != NULL ) { - /* There are controls saved in original request already, - replace them with the new ones because we only save - the final controls received. - May want to arrange for merging intermediate response - controls into the array in the future */ - ldap_controls_free( lr->lr_res_ctrls ); - } - lr->lr_res_ctrls = ctrls; - } - - /* - * we recognize a request as fully complete when: - * 1) it is not a child request (NULL parent) - * 2) it has no outstanding referrals - * 3) we have received a result for the request (i.e., - * something other than an entry or a reference). - */ - if ( lr->lr_parent == NULL - && NSLDAPI_REQUEST_COMPLETE(lr)) { - id = lr->lr_msgid; - tag = lr->lr_res_msgtype; - LDAPDebug( LDAP_DEBUG_TRACE, - "request %d done\n", id, 0, 0 ); -LDAPDebug( LDAP_DEBUG_TRACE, -"res_errno: %d, res_error: <%s>, res_matched: <%s>\n", -lr->lr_res_errno, lr->lr_res_error ? lr->lr_res_error : "", -lr->lr_res_matched ? lr->lr_res_matched : "" ); - if ( !simple_request ) { - if ( ber != NULLBER ) { - ber_free( ber, 1 ); - ber = NULLBER; - } - if ( build_result_ber( ld, &ber, lr ) - != LDAP_SUCCESS ) { - rc = NSLDAPI_RESULT_ERROR; - } else { - manufactured_result = 1; - } - } - - nsldapi_free_request( ld, lr, 1 ); - /* Since we asked nsldapi_free_request() to free the - connection, lets make sure our callers know it's gone. */ - *lcp = NULL; - } else { - message_can_be_returned = 0; - } - } - } - - if ( ber == NULLBER ) { - return( rc ); - } - - /* make a new ldap message */ - if ( (new = (LDAPMessage*)NSLDAPI_CALLOC( 1, sizeof(struct ldapmsg) )) - == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); - return( NSLDAPI_RESULT_ERROR ); - } - new->lm_msgid = (int)id; - new->lm_msgtype = tag; - new->lm_ber = ber; - - /* - * if this is a search entry or if this request is complete (i.e., - * there are no outstanding referrals) then add to cache and check - * to see if we should return this to the caller right away or not. - */ - if ( message_can_be_returned ) { - if ( ld->ld_cache_on ) { - nsldapi_add_result_to_cache( ld, new ); - } - - if ( msgid == LDAP_RES_ANY || id == msgid ) { - if ( new->lm_msgtype == LDAP_RES_SEARCH_RESULT ) { - /* - * return the first response we have for this - * search request later (possibly an entire - * chain of messages). - */ - foundit = 1; - } else if ( all == 0 - || (new->lm_msgtype != LDAP_RES_SEARCH_REFERENCE - && new->lm_msgtype != LDAP_RES_SEARCH_ENTRY) ) { - *result = new; - LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, - NULL ); - return( tag ); - } - } - } - - /* - * if not, we must add it to the list of responses. if - * the msgid is already there, it must be part of an existing - * search response. - */ - - prev = NULL; - LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK ); - for ( l = ld->ld_responses; l != NULL; l = l->lm_next ) { - if ( l->lm_msgid == new->lm_msgid ) - break; - prev = l; - } - - /* not part of an existing search response */ - if ( l == NULL ) { - if ( foundit ) { - LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); - *result = new; - LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL ); - return( tag ); - } - - new->lm_next = ld->ld_responses; - ld->ld_responses = new; - LDAPDebug( LDAP_DEBUG_TRACE, - "adding new response id %d type %d (looking for id %d)\n", - new->lm_msgid, new->lm_msgtype, msgid ); - LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); - if( message_can_be_returned ) - POST( ld, new->lm_msgid, new ); - return( NSLDAPI_RESULT_NOT_FOUND ); /* continue looking */ - } - - LDAPDebug( LDAP_DEBUG_TRACE, - "adding response 0x%p - id %d type %d", - new, new->lm_msgid, new->lm_msgtype ); - LDAPDebug( LDAP_DEBUG_TRACE, " (looking for id %d)\n", msgid, 0, 0 ); - - /* - * part of a search response - add to end of list of entries - * - * the first step is to find the end of the list of entries and - * references. after the following loop is executed, tmp points to - * the last entry or reference in the chain. If there are none, - * tmp points to the search result. - */ - chainprev = NULL; - for ( tmp = l; tmp->lm_chain != NULL && - ( tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY - || tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ); - tmp = tmp->lm_chain ) { - chainprev = tmp; - } - - /* - * If this is a manufactured result message and a result is already - * queued we throw away the one that is queued and replace it with - * our new result. This is necessary so we don't end up returning - * more than one result. - */ - if ( manufactured_result && - tmp->lm_msgtype == LDAP_RES_SEARCH_RESULT ) { - /* - * the result is the only thing in the chain... replace it. - */ - new->lm_chain = tmp->lm_chain; - new->lm_next = tmp->lm_next; - if ( chainprev == NULL ) { - if ( prev == NULL ) { - ld->ld_responses = new; - } else { - prev->lm_next = new; - } - } else { - chainprev->lm_chain = new; - } - if ( l == tmp ) { - l = new; - } - ldap_msgfree( tmp ); - - } else if ( manufactured_result && tmp->lm_chain != NULL - && tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_RESULT ) { - /* - * entries or references are also present, so the result - * is the next entry after tmp. replace it. - */ - new->lm_chain = tmp->lm_chain->lm_chain; - new->lm_next = tmp->lm_chain->lm_next; - ldap_msgfree( tmp->lm_chain ); - tmp->lm_chain = new; - - } else if ( tmp->lm_msgtype == LDAP_RES_SEARCH_RESULT ) { - /* - * the result is the only thing in the chain... add before it. - */ - new->lm_chain = tmp; - if ( chainprev == NULL ) { - if ( prev == NULL ) { - ld->ld_responses = new; - } else { - prev->lm_next = new; - } - } else { - chainprev->lm_chain = new; - } - if ( l == tmp ) { - l = new; - } - - } else { - /* - * entries and/or references are present... add to the end - * of the entry/reference part of the chain. - */ - new->lm_chain = tmp->lm_chain; - tmp->lm_chain = new; - } - - /* - * return the first response or the whole chain if that's what - * we were looking for.... - */ - if ( foundit ) { - if ( all == 0 && l->lm_chain != NULL ) { - /* - * only return the first response in the chain - */ - if ( prev == NULL ) { - ld->ld_responses = l->lm_chain; - } else { - prev->lm_next = l->lm_chain; - } - l->lm_chain = NULL; - tag = l->lm_msgtype; - } else { - /* - * return all of the responses (may be a chain) - */ - if ( prev == NULL ) { - ld->ld_responses = l->lm_next; - } else { - prev->lm_next = l->lm_next; - } - } - *result = l; - LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); - LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL ); - return( tag ); - } - LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); - return( NSLDAPI_RESULT_NOT_FOUND ); /* continue looking */ -} - - -/* - * check for LDAPv2+ (UMich extension) or LDAPv3 referrals or references - * errors are merged in "lr". - */ -static void -check_for_refs( LDAP *ld, LDAPRequest *lr, BerElement *ber, - int ldapversion, int *totalcountp, int *chasingcountp ) -{ - int err, origerr; - char *errstr, *matcheddn, **v3refs; - - LDAPDebug( LDAP_DEBUG_TRACE, "check_for_refs\n", 0, 0, 0 ); - - *chasingcountp = *totalcountp = 0; - - if ( ldapversion < LDAP_VERSION2 || ( lr->lr_parent == NULL - && ( ld->ld_options & LDAP_BITOPT_REFERRALS ) == 0 )) { - /* referrals are not supported or are disabled */ - return; - } - - if ( lr->lr_res_msgtype == LDAP_RES_SEARCH_REFERENCE ) { - err = nsldapi_parse_reference( ld, ber, &v3refs, NULL ); - origerr = LDAP_REFERRAL; /* a small lie... */ - matcheddn = errstr = NULL; - } else { - err = nsldapi_parse_result( ld, lr->lr_res_msgtype, ber, - &origerr, &matcheddn, &errstr, &v3refs, NULL ); - } - - if ( err != LDAP_SUCCESS ) { - /* parse failed */ - return; - } - - if ( origerr == LDAP_REFERRAL ) { /* ldapv3 */ - if ( v3refs != NULL ) { - err = nsldapi_chase_v3_refs( ld, lr, v3refs, - ( lr->lr_res_msgtype == LDAP_RES_SEARCH_REFERENCE ), - totalcountp, chasingcountp ); - ldap_value_free( v3refs ); - } - } else if ( ldapversion == LDAP_VERSION2 - && origerr != LDAP_SUCCESS ) { - /* referrals may be present in the error string */ - err = nsldapi_chase_v2_referrals( ld, lr, &errstr, - totalcountp, chasingcountp ); - } - - /* set LDAP errno, message, and matched string appropriately */ - if ( lr->lr_res_error != NULL ) { - NSLDAPI_FREE( lr->lr_res_error ); - } - lr->lr_res_error = errstr; - - if ( lr->lr_res_matched != NULL ) { - NSLDAPI_FREE( lr->lr_res_matched ); - } - lr->lr_res_matched = matcheddn; - - if ( err == LDAP_SUCCESS && ( *chasingcountp == *totalcountp )) { - if ( *totalcountp > 0 && ( origerr == LDAP_PARTIAL_RESULTS - || origerr == LDAP_REFERRAL )) { - /* substitute success for referral error codes */ - lr->lr_res_errno = LDAP_SUCCESS; - } else { - /* preserve existing non-referral error code */ - lr->lr_res_errno = origerr; - } - } else if ( err != LDAP_SUCCESS ) { - /* error occurred while trying to chase referrals */ - lr->lr_res_errno = err; - } else { - /* some referrals were not recognized */ - lr->lr_res_errno = ( ldapversion == LDAP_VERSION2 ) - ? LDAP_PARTIAL_RESULTS : LDAP_REFERRAL; - } - - LDAPDebug( LDAP_DEBUG_TRACE, - "check_for_refs: new result: msgid %d, res_errno %d, ", - lr->lr_msgid, lr->lr_res_errno, 0 ); - LDAPDebug( LDAP_DEBUG_TRACE, " res_error <%s>, res_matched <%s>\n", - lr->lr_res_error ? lr->lr_res_error : "", - lr->lr_res_matched ? lr->lr_res_matched : "", 0 ); - LDAPDebug( LDAP_DEBUG_TRACE, - "check_for_refs: %d new refs(s); chasing %d of them\n", - *totalcountp, *chasingcountp, 0 ); -} - - -/* returns an LDAP error code and also sets it in LDAP * */ -static int -build_result_ber( LDAP *ld, BerElement **berp, LDAPRequest *lr ) -{ - ber_len_t len; - ber_int_t along; - BerElement *ber; - int err; - - if (( err = nsldapi_alloc_ber_with_options( ld, &ber )) - != LDAP_SUCCESS ) { - return( err ); - } - *berp = ber; - if ( ber_printf( ber, lr->lr_res_ctrls ? "{it{ess}" : "{it{ess}}", - lr->lr_msgid, (long)lr->lr_res_msgtype, lr->lr_res_errno, - lr->lr_res_matched ? lr->lr_res_matched : "", - lr->lr_res_error ? lr->lr_res_error : "" ) == -1 ) { - return( LDAP_ENCODING_ERROR ); - } - - if ( NULL != lr->lr_res_ctrls && nsldapi_put_controls( ld, - lr->lr_res_ctrls, 1 /* close seq */, ber ) != LDAP_SUCCESS ) { - return( LDAP_ENCODING_ERROR ); - } - - ber_reset( ber, 1 ); - if ( ber_skip_tag( ber, &len ) == LBER_ERROR || - ber_get_int( ber, &along ) == LBER_ERROR || - ber_peek_tag( ber, &len ) == LBER_ERROR ) { - return( LDAP_DECODING_ERROR ); - } - - return( LDAP_SUCCESS ); -} - - -static void -merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) -{ -/* - * Merge error information in "lr" with "parentr" error code and string. - */ - if ( lr->lr_res_errno == LDAP_PARTIAL_RESULTS ) { - parentr->lr_res_errno = lr->lr_res_errno; - if ( lr->lr_res_error != NULL ) { - (void)nsldapi_append_referral( ld, &parentr->lr_res_error, - lr->lr_res_error ); - } - } else if ( lr->lr_res_errno != LDAP_SUCCESS && - parentr->lr_res_errno == LDAP_SUCCESS ) { - parentr->lr_res_errno = lr->lr_res_errno; - if ( parentr->lr_res_error != NULL ) { - NSLDAPI_FREE( parentr->lr_res_error ); - } - parentr->lr_res_error = lr->lr_res_error; - lr->lr_res_error = NULL; - if ( NAME_ERROR( lr->lr_res_errno )) { - if ( parentr->lr_res_matched != NULL ) { - NSLDAPI_FREE( parentr->lr_res_matched ); - } - parentr->lr_res_matched = lr->lr_res_matched; - lr->lr_res_matched = NULL; - } - } - - LDAPDebug( LDAP_DEBUG_TRACE, "merged parent (id %d) error info: ", - parentr->lr_msgid, 0, 0 ); - LDAPDebug( LDAP_DEBUG_TRACE, "result lderrno %d, error <%s>, matched <%s>\n", - parentr->lr_res_errno, parentr->lr_res_error ? - parentr->lr_res_error : "", parentr->lr_res_matched ? - parentr->lr_res_matched : "" ); -} - -#if defined( CLDAP ) -#if !defined( macintosh ) && !defined( DOS ) && !defined( _WINDOWS ) && !defined(XP_OS2) -/* XXXmcs: was revised to support extended I/O callbacks but never compiled! */ -static int -cldap_select1( LDAP *ld, struct timeval *timeout ) -{ - int rc; - static int tblsize = 0; - NSLDAPIIOStatus *iosp = ld->ld_iostatus; - - if ( tblsize == 0 ) { -#ifdef USE_SYSCONF - tblsize = sysconf( _SC_OPEN_MAX ); -#else /* USE_SYSCONF */ - tblsize = getdtablesize(); -#endif /* USE_SYSCONF */ - } - - if ( tblsize >= FD_SETSIZE ) { - /* - * clamp value so we don't overrun the fd_set structure - */ - tblsize = FD_SETSIZE - 1; - } - - if ( NSLDAPI_IOSTATUS_TYPE_OSNATIVE == iosp->ios_type ) { - fd_set readfds; - - FD_ZERO( &readfds ); - FD_SET( ld->ld_sbp->sb_sd, &readfds ); - - /* XXXmcs: UNIX platforms should use poll() */ - rc = select( tblsize, &readfds, 0, 0, timeout ) ); - - } else if ( NSLDAPI_IOSTATUS_TYPE_CALLBACK == iosp->ios_type ) { - LDAP_X_PollFD pollfds[ 1 ]; - - pollfds[0].lpoll_fd = ld->ld_sbp->sb_sd; - pollfds[0].lpoll_arg = ld->ld_sbp->sb_arg; - pollfds[0].lpoll_events = LDAP_X_POLLIN; - pollfds[0].lpoll_revents = 0; - rc = ld->ld_extpoll_fn( pollfds, 1, nsldapi_tv2ms( timeout ), - ld->ld_ext_session_arg ); - } else { - LDAPDebug( LDAP_DEBUG_ANY, - "nsldapi_iostatus_poll: unknown I/O type %d\n", - rc = 0; /* simulate a timeout (what else to do?) */ - } - - return( rc ); -} -#endif /* !macintosh */ - - -#ifdef macintosh -static int -cldap_select1( LDAP *ld, struct timeval *timeout ) -{ - /* XXXmcs: needs to be revised to support I/O callbacks */ - return( tcpselect( ld->ld_sbp->sb_sd, timeout )); -} -#endif /* macintosh */ - - -#if (defined( DOS ) && defined( WINSOCK )) || defined( _WINDOWS ) || defined(XP_OS2) -/* XXXmcs: needs to be revised to support extended I/O callbacks */ -static int -cldap_select1( LDAP *ld, struct timeval *timeout ) -{ - fd_set readfds; - int rc; - - FD_ZERO( &readfds ); - FD_SET( ld->ld_sbp->sb_sd, &readfds ); - - if ( NSLDAPI_IO_TYPE_STANDARD == ld->ldiou_type && - NULL != ld->ld_select_fn ) { - rc = ld->ld_select_fn( 1, &readfds, 0, 0, timeout ); - } else if ( NSLDAPI_IO_TYPE_EXTENDED == ld->ldiou_type && - NULL != ld->ld_extselect_fn ) { - rc = ld->ld_extselect_fn( ld->ld_ext_session_arg, 1, &readfds, 0, - 0, timeout ) ); - } else { - /* XXXmcs: UNIX platforms should use poll() */ - rc = select( 1, &readfds, 0, 0, timeout ) ); - } - - return( rc == SOCKET_ERROR ? -1 : rc ); -} -#endif /* WINSOCK || _WINDOWS */ -#endif /* CLDAP */ - -int -LDAP_CALL -ldap_msgfree( LDAPMessage *lm ) -{ - LDAPMessage *next; - int type = 0; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_msgfree\n", 0, 0, 0 ); - - for ( ; lm != NULL; lm = next ) { - next = lm->lm_chain; - type = lm->lm_msgtype; - ber_free( lm->lm_ber, 1 ); - NSLDAPI_FREE( (char *) lm ); - } - - return( type ); -} - -/* - * ldap_msgdelete - delete a message. It returns: - * 0 if the entire message was deleted - * -1 if the message was not found, or only part of it was found - */ -int -ldap_msgdelete( LDAP *ld, int msgid ) -{ - LDAPMessage *lm, *prev; - int msgtype; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_msgdelete\n", 0, 0, 0 ); - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - return( -1 ); /* punt */ - } - - prev = NULL; - LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK ); - for ( lm = ld->ld_responses; lm != NULL; lm = lm->lm_next ) { - if ( lm->lm_msgid == msgid ) - break; - prev = lm; - } - - if ( lm == NULL ) - { - LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); - return( -1 ); - } - - if ( prev == NULL ) - ld->ld_responses = lm->lm_next; - else - prev->lm_next = lm->lm_next; - LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); - - msgtype = ldap_msgfree( lm ); - if ( msgtype == LDAP_RES_SEARCH_ENTRY - || msgtype == LDAP_RES_SEARCH_REFERENCE ) { - return( -1 ); - } - - return( 0 ); -} - - -/* - * return 1 if message msgid is waiting to be abandoned, 0 otherwise - */ -static int -ldap_abandoned( LDAP *ld, int msgid ) -{ - int i; - - LDAP_MUTEX_LOCK( ld, LDAP_ABANDON_LOCK ); - if ( ld->ld_abandoned == NULL ) - { - LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); - return( 0 ); - } - - for ( i = 0; ld->ld_abandoned[i] != -1; i++ ) - if ( ld->ld_abandoned[i] == msgid ) - { - LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); - return( 1 ); - } - - LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); - return( 0 ); -} - - -static int -ldap_mark_abandoned( LDAP *ld, int msgid ) -{ - int i; - - LDAP_MUTEX_LOCK( ld, LDAP_ABANDON_LOCK ); - if ( ld->ld_abandoned == NULL ) - { - LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); - return( -1 ); - } - - for ( i = 0; ld->ld_abandoned[i] != -1; i++ ) - if ( ld->ld_abandoned[i] == msgid ) - break; - - if ( ld->ld_abandoned[i] == -1 ) - { - LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); - return( -1 ); - } - - for ( ; ld->ld_abandoned[i] != -1; i++ ) { - ld->ld_abandoned[i] = ld->ld_abandoned[i + 1]; - } - - LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); - return( 0 ); -} - - -#ifdef CLDAP -int -cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement **ber ) -{ - int rc; - ber_tag_t tag; - ber_len_t len; - - if ( ld->ld_sbp->sb_ber.ber_ptr >= ld->ld_sbp->sb_ber.ber_end ) { - rc = cldap_select1( ld, timeout ); - if ( rc == -1 || rc == 0 ) { - LDAP_SET_LDERRNO( ld, (rc == -1 ? LDAP_SERVER_DOWN : - LDAP_TIMEOUT), NULL, NULL ); - return( rc ); - } - } - - /* get the next message */ - if ( (tag = ber_get_next( ld->ld_sbp, &len, ber )) - != LDAP_TAG_MESSAGE ) { - LDAP_SET_LDERRNO( ld, (tag == LBER_DEFAULT ? LDAP_SERVER_DOWN : - LDAP_LOCAL_ERROR), NULL, NULL ); - return( -1 ); - } - - return( tag ); -} -#endif /* CLDAP */ - -int -nsldapi_post_result( LDAP *ld, int msgid, LDAPMessage *result ) -{ - LDAPPend *lp; - - LDAPDebug( LDAP_DEBUG_TRACE, - "nsldapi_post_result(ld=0x%p, msgid=%d, result=0x%p)\n", - ld, msgid, result ); - LDAP_MUTEX_LOCK( ld, LDAP_PEND_LOCK ); - if( msgid == LDAP_RES_ANY ) { - /* - * Look for any pending request for which someone is waiting. - */ - for( lp = ld->ld_pend; lp != NULL; lp = lp->lp_next ) - { - if ( lp->lp_sema != NULL ) { - break; - } - } - /* - * If we did't find a pending request, lp is NULL at this - * point, and we will leave this function without doing - * anything more -- which is exactly what we want to do. - */ - } - else - { - /* - * Look for a pending request specific to this message id - */ - for( lp = ld->ld_pend; lp != NULL; lp = lp->lp_next ) - { - if( lp->lp_msgid == msgid ) - break; - } - - if( lp == NULL ) - { - /* - * No pending requests for this response... append to - * our pending result list. - */ - LDAPPend *newlp; - newlp = (LDAPPend *)NSLDAPI_CALLOC( 1, - sizeof( LDAPPend )); - if( newlp == NULL ) - { - LDAP_MUTEX_UNLOCK( ld, LDAP_PEND_LOCK ); - LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, - NULL ); - return (-1); - } - newlp->lp_msgid = msgid; - newlp->lp_result = result; - link_pend( ld, newlp ); - } - } - - - if( lp != NULL ) - { - /* - * Wake up a thread that is waiting for this result. - */ - lp->lp_msgid = msgid; - lp->lp_result = result; - LDAP_SEMA_POST( ld, lp ); - } - - LDAP_MUTEX_UNLOCK( ld, LDAP_PEND_LOCK ); - return (0); -} - -static void -link_pend( LDAP *ld, LDAPPend *lp ) -{ - if (( lp->lp_next = ld->ld_pend ) != NULL ) - { - lp->lp_next->lp_prev = lp; - } - ld->ld_pend = lp; - lp->lp_prev = NULL; -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap/saslbind.c
Deleted
@@ -1,877 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#include "ldap-int.h" - -#ifdef LDAP_SASLIO_HOOKS -/* - * Global SASL Init data - */ - -static int -nsldapi_sasl_fail() -{ - return( SASL_FAIL ); -} - -sasl_callback_t client_callbacks[] = { - { SASL_CB_GETOPT, nsldapi_sasl_fail, NULL }, - { SASL_CB_GETREALM, NULL, NULL }, - { SASL_CB_USER, NULL, NULL }, - { SASL_CB_CANON_USER, NULL, NULL }, - { SASL_CB_AUTHNAME, NULL, NULL }, - { SASL_CB_PASS, NULL, NULL }, - { SASL_CB_ECHOPROMPT, NULL, NULL }, - { SASL_CB_NOECHOPROMPT, NULL, NULL }, - { SASL_CB_LIST_END, NULL, NULL } -}; - -int -nsldapi_sasl_cvterrno( LDAP *ld, int err, char *msg ) -{ - int rc = LDAP_LOCAL_ERROR; - - switch (err) { - case SASL_OK: - rc = LDAP_SUCCESS; - break; - case SASL_NOMECH: - rc = LDAP_AUTH_UNKNOWN; - break; - case SASL_BADSERV: - rc = LDAP_CONNECT_ERROR; - break; - case SASL_DISABLED: - case SASL_ENCRYPT: - case SASL_EXPIRED: - case SASL_NOUSERPASS: - case SASL_NOVERIFY: - case SASL_PWLOCK: - case SASL_TOOWEAK: - case SASL_UNAVAIL: - case SASL_WEAKPASS: - rc = LDAP_INAPPROPRIATE_AUTH; - break; - case SASL_BADAUTH: - case SASL_NOAUTHZ: - rc = LDAP_INVALID_CREDENTIALS; - break; - case SASL_NOMEM: - rc = LDAP_NO_MEMORY; - break; - case SASL_NOUSER: - rc = LDAP_NO_SUCH_OBJECT; - break; - case SASL_CONTINUE: - case SASL_FAIL: - case SASL_INTERACT: - default: - rc = LDAP_LOCAL_ERROR; - break; - } - - LDAP_SET_LDERRNO( ld, rc, NULL, msg ); - return( rc ); -} - -#ifdef LDAP_SASLIO_GET_MECHS_FROM_SERVER -/* - * Get available SASL Mechanisms supported by the server - */ - -static int -nsldapi_get_sasl_mechs ( LDAP *ld, char **pmech ) -{ - char *attr[] = { "supportedSASLMechanisms", NULL }; - char **values, **v, *mech, *m; - LDAPMessage *res, *e; - struct timeval timeout; - int slen, rc; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - return( LDAP_PARAM_ERROR ); - } - - timeout.tv_sec = SEARCH_TIMEOUT_SECS; - timeout.tv_usec = 0; - - rc = ldap_search_st( ld, "", LDAP_SCOPE_BASE, - "objectclass=*", attr, 0, &timeout, &res ); - - if ( rc != LDAP_SUCCESS ) { - return( LDAP_GET_LDERRNO( ld, NULL, NULL ) ); - } - - e = ldap_first_entry( ld, res ); - if ( e == NULL ) { - ldap_msgfree( res ); - if ( ld->ld_errno == LDAP_SUCCESS ) { - LDAP_SET_LDERRNO( ld, LDAP_NO_SUCH_OBJECT, NULL, NULL ); - } - return( LDAP_GET_LDERRNO( ld, NULL, NULL ) ); - } - - values = ldap_get_values( ld, e, "supportedSASLMechanisms" ); - if ( values == NULL ) { - ldap_msgfree( res ); - LDAP_SET_LDERRNO( ld, LDAP_NO_SUCH_ATTRIBUTE, NULL, NULL ); - return( LDAP_NO_SUCH_ATTRIBUTE ); - } - - slen = 0; - for(v = values; *v != NULL; v++ ) { - slen += strlen(*v) + 1; - } - if ( (mech = NSLDAPI_CALLOC(1, slen)) == NULL) { - ldap_value_free( values ); - ldap_msgfree( res ); - LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); - return( LDAP_NO_MEMORY ); - } - m = mech; - for(v = values; *v; v++) { - if (v != values) { - *m++ = ' '; - } - slen = strlen(*v); - strncpy(m, *v, slen); - m += slen; - } - *m = '\0'; - - ldap_value_free( values ); - ldap_msgfree( res ); - - *pmech = mech; - - return( LDAP_SUCCESS ); -} -#endif /* LDAP_SASLIO_GET_MECHS_FROM_SERVER */ - -int -nsldapi_sasl_secprops( - const char *in, - sasl_security_properties_t *secprops ) -{ - int i; - char **props = NULL; - char *inp; - unsigned sflags = 0; - sasl_ssf_t max_ssf = 0; - sasl_ssf_t min_ssf = 0; - unsigned maxbufsize = 0; - int got_sflags = 0; - int got_max_ssf = 0; - int got_min_ssf = 0; - int got_maxbufsize = 0; - - if (in == NULL) { - return LDAP_PARAM_ERROR; - } - inp = nsldapi_strdup(in); - if (inp == NULL) { - return LDAP_PARAM_ERROR; - } - props = ldap_str2charray( inp, "," ); - NSLDAPI_FREE( inp ); - - if( props == NULL || secprops == NULL ) { - return LDAP_PARAM_ERROR; - } - - for( i=0; props[i]; i++ ) { - if( strcasecmp(props[i], "none") == 0 ) { - got_sflags++; - - } else if( strcasecmp(props[i], "noactive") == 0 ) { - got_sflags++; - sflags |= SASL_SEC_NOACTIVE; - - } else if( strcasecmp(props[i], "noanonymous") == 0 ) { - got_sflags++; - sflags |= SASL_SEC_NOANONYMOUS; - - } else if( strcasecmp(props[i], "nodict") == 0 ) { - got_sflags++; - sflags |= SASL_SEC_NODICTIONARY; - - } else if( strcasecmp(props[i], "noplain") == 0 ) { - got_sflags++; - sflags |= SASL_SEC_NOPLAINTEXT; - - } else if( strcasecmp(props[i], "forwardsec") == 0 ) { - got_sflags++; - sflags |= SASL_SEC_FORWARD_SECRECY; - - } else if( strcasecmp(props[i], "passcred") == 0 ) { - got_sflags++; - sflags |= SASL_SEC_PASS_CREDENTIALS; - - } else if( strncasecmp(props[i], - "minssf=", sizeof("minssf")) == 0 ) { - if( isdigit( props[i][sizeof("minssf")] ) ) { - got_min_ssf++; - min_ssf = atoi( &props[i][sizeof("minssf")] ); - } else { - return LDAP_NOT_SUPPORTED; - } - - } else if( strncasecmp(props[i], - "maxssf=", sizeof("maxssf")) == 0 ) { - if( isdigit( props[i][sizeof("maxssf")] ) ) { - got_max_ssf++; - max_ssf = atoi( &props[i][sizeof("maxssf")] ); - } else { - return LDAP_NOT_SUPPORTED; - } - - } else if( strncasecmp(props[i], - "maxbufsize=", sizeof("maxbufsize")) == 0 ) { - if( isdigit( props[i][sizeof("maxbufsize")] ) ) { - got_maxbufsize++; - maxbufsize = atoi( &props[i][sizeof("maxbufsize")] ); - if( maxbufsize && - (( maxbufsize < SASL_MIN_BUFF_SIZE ) - || (maxbufsize > SASL_MAX_BUFF_SIZE ))) { - return( LDAP_PARAM_ERROR ); - } - } else { - return( LDAP_NOT_SUPPORTED ); - } - } else { - return( LDAP_NOT_SUPPORTED ); - } - } - - if(got_sflags) { - secprops->security_flags = sflags; - } - if(got_min_ssf) { - secprops->min_ssf = min_ssf; - } - if(got_max_ssf) { - secprops->max_ssf = max_ssf; - } - if(got_maxbufsize) { - secprops->maxbufsize = maxbufsize; - } - - ldap_charray_free( props ); - return( LDAP_SUCCESS ); -} -#endif /* LDAP_SASLIO_HOOKS */ - -static int -nsldapi_sasl_bind_s( - LDAP *ld, - const char *dn, - const char *mechanism, - const struct berval *cred, - LDAPControl **serverctrls, - LDAPControl **clientctrls, - struct berval **servercredp, - LDAPControl ***responsectrls -) -{ - int err, msgid; - LDAPMessage *result; - - LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_sasl_bind_s\n", 0, 0, 0 ); - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - return( LDAP_PARAM_ERROR ); - } - - if ( NSLDAPI_LDAP_VERSION( ld ) < LDAP_VERSION3 ) { - LDAP_SET_LDERRNO( ld, LDAP_NOT_SUPPORTED, NULL, NULL ); - return( LDAP_NOT_SUPPORTED ); - } - - if ( ( err = ldap_sasl_bind( ld, dn, mechanism, cred, serverctrls, - clientctrls, &msgid )) != LDAP_SUCCESS ) - return( err ); - - if ( ldap_result( ld, msgid, 1, (struct timeval *) 0, &result ) == -1 ) - return( LDAP_GET_LDERRNO( ld, NULL, NULL ) ); - - /* Get the controls sent by the server if requested */ - if ( responsectrls ) { - if ( ( err = ldap_parse_result( ld, result, &err, NULL, NULL, - NULL, responsectrls, 0 )) != LDAP_SUCCESS ) - return( err ); - } - - err = ldap_parse_sasl_bind_result( ld, result, servercredp, 0 ); - if (err != LDAP_SUCCESS && err != LDAP_SASL_BIND_IN_PROGRESS) { - ldap_msgfree( result ); - return( err ); - } - - return( ldap_result2error( ld, result, 1 ) ); -} - -#ifdef LDAP_SASLIO_HOOKS -static int -nsldapi_sasl_do_bind( LDAP *ld, const char *dn, - const char *mechs, unsigned flags, - LDAP_SASL_INTERACT_PROC *callback, void *defaults, - LDAPControl **sctrl, LDAPControl **cctrl, LDAPControl ***rctrl ) -{ - sasl_interact_t *prompts = NULL; - sasl_conn_t *ctx = NULL; - sasl_ssf_t *ssf = NULL; - const char *mech = NULL; - int saslrc, rc; - struct berval ccred; - unsigned credlen; - int stepnum = 1; - char *sasl_username = NULL; - - if (rctrl) { - /* init to NULL so we can call ldap_controls_free below */ - *rctrl = NULL; - } - - if (NSLDAPI_LDAP_VERSION( ld ) < LDAP_VERSION3) { - LDAP_SET_LDERRNO( ld, LDAP_NOT_SUPPORTED, NULL, NULL ); - return( LDAP_NOT_SUPPORTED ); - } - - /* shouldn't happen */ - if (callback == NULL) { - return( LDAP_LOCAL_ERROR ); - } - - if ( (rc = nsldapi_sasl_open(ld, NULL, &ctx, 0)) != LDAP_SUCCESS ) { - return( rc ); - } - - ccred.bv_val = NULL; - ccred.bv_len = 0; - - LDAPDebug(LDAP_DEBUG_TRACE, "Starting SASL/%s authentication\n", - (mechs ? mechs : ""), 0, 0 ); - - do { - saslrc = sasl_client_start( ctx, - mechs, - &prompts, - (const char **)&ccred.bv_val, - &credlen, - &mech ); - - LDAPDebug(LDAP_DEBUG_TRACE, "Doing step %d of client start for SASL/%s authentication\n", - stepnum, (mech ? mech : ""), 0 ); - stepnum++; - - if( saslrc == SASL_INTERACT && - (callback)(ld, flags, defaults, prompts) != LDAP_SUCCESS ) { - break; - } - } while ( saslrc == SASL_INTERACT ); - - ccred.bv_len = credlen; - - if ( (saslrc != SASL_OK) && (saslrc != SASL_CONTINUE) ) { - return( nsldapi_sasl_cvterrno( ld, saslrc, nsldapi_strdup( sasl_errdetail( ctx ) ) ) ); - } - - stepnum = 1; - - do { - struct berval *scred; - int clientstepnum = 1; - - scred = NULL; - - if (rctrl) { - /* if we're looping again, we need to free any controls set - during the previous loop */ - /* NOTE that this assumes we only care about the controls - returned by the last call to nsldapi_sasl_bind_s - if - we care about _all_ controls, we will have to figure out - some way to append them each loop go round */ - ldap_controls_free(*rctrl); - *rctrl = NULL; - } - - LDAPDebug(LDAP_DEBUG_TRACE, "Doing step %d of bind for SASL/%s authentication\n", - stepnum, (mech ? mech : ""), 0 ); - stepnum++; - - /* notify server of a sasl bind step */ - rc = nsldapi_sasl_bind_s(ld, dn, mech, &ccred, - sctrl, cctrl, &scred, rctrl); - - if ( ccred.bv_val != NULL ) { - ccred.bv_val = NULL; - } - - if ( rc != LDAP_SUCCESS && rc != LDAP_SASL_BIND_IN_PROGRESS ) { - ber_bvfree( scred ); - return( rc ); - } - - if( rc == LDAP_SUCCESS && saslrc == SASL_OK ) { - /* we're done, no need to step */ - if( scred ) { - if ( scred->bv_len == 0 ) { /* MS AD sends back empty screds */ - LDAPDebug(LDAP_DEBUG_ANY, - "SASL BIND complete - ignoring empty credential response\n", - 0, 0, 0); - ber_bvfree( scred ); - } else { - /* but server provided us with data! */ - LDAPDebug(LDAP_DEBUG_TRACE, - "SASL BIND complete but invalid because server responded with credentials - length [%u]\n", - scred->bv_len, 0, 0); - ber_bvfree( scred ); - LDAP_SET_LDERRNO( ld, LDAP_LOCAL_ERROR, - NULL, "Error during SASL handshake - invalid server credential response" ); - return( LDAP_LOCAL_ERROR ); - } - } - break; - } - - /* perform the next step of the sasl bind */ - do { - LDAPDebug(LDAP_DEBUG_TRACE, "Doing client step %d of bind step %d for SASL/%s authentication\n", - clientstepnum, stepnum, (mech ? mech : "") ); - clientstepnum++; - saslrc = sasl_client_step( ctx, - (scred == NULL) ? NULL : scred->bv_val, - (scred == NULL) ? 0 : scred->bv_len, - &prompts, - (const char **)&ccred.bv_val, - &credlen ); - - if( saslrc == SASL_INTERACT && - (callback)(ld, flags, defaults, prompts) - != LDAP_SUCCESS ) { - break; - } - } while ( saslrc == SASL_INTERACT ); - - ccred.bv_len = credlen; - ber_bvfree( scred ); - - if ( (saslrc != SASL_OK) && (saslrc != SASL_CONTINUE) ) { - return( nsldapi_sasl_cvterrno( ld, saslrc, nsldapi_strdup( sasl_errdetail( ctx ) ) ) ); - } - } while ( rc == LDAP_SASL_BIND_IN_PROGRESS ); - - if ( rc != LDAP_SUCCESS ) { - return( rc ); - } - - if ( saslrc != SASL_OK ) { - return( nsldapi_sasl_cvterrno( ld, saslrc, nsldapi_strdup( sasl_errdetail( ctx ) ) ) ); - } - - saslrc = sasl_getprop( ctx, SASL_USERNAME, (const void **) &sasl_username ); - if ( (saslrc == SASL_OK) && sasl_username ) { - LDAPDebug(LDAP_DEBUG_TRACE, "SASL identity: %s\n", sasl_username, 0, 0); - } - - saslrc = sasl_getprop( ctx, SASL_SSF, (const void **) &ssf ); - if( saslrc == SASL_OK ) { - if( ssf && *ssf ) { - LDAPDebug(LDAP_DEBUG_TRACE, - "SASL install encryption, for SSF: %lu\n", - (unsigned long) *ssf, 0, 0 ); - nsldapi_sasl_install( ld, NULL ); - } - } - - return( rc ); -} -#endif /* LDAP_SASLIO_HOOKS */ - - -/* - * ldap_sasl_bind - authenticate to the ldap server. The dn, mechanism, - * and credentials of the entry to which to bind are supplied. An LDAP - * error code is returned and if LDAP_SUCCESS is returned *msgidp is set - * to the id of the request initiated. - * - * Example: - * struct berval creds; - * LDAPControl **ctrls; - * int err, msgid; - * ... fill in creds with credentials ... - * ... fill in ctrls with server controls ... - * err = ldap_sasl_bind( ld, "cn=manager, o=university of michigan, c=us", - * "mechanismname", &creds, ctrls, NULL, &msgid ); - */ -int -LDAP_CALL -ldap_sasl_bind( - LDAP *ld, - const char *dn, - const char *mechanism, - const struct berval *cred, - LDAPControl **serverctrls, - LDAPControl **clientctrls, - int *msgidp -) -{ - BerElement *ber; - int rc, simple, msgid, ldapversion; - - /* - * The ldapv3 bind request looks like this: - * BindRequest ::= SEQUENCE { - * version INTEGER, - * name DistinguishedName, -- who - * authentication CHOICE { - * simple [0] OCTET STRING, -- passwd - * sasl [3] SaslCredentials -- v3 only - * } - * } - * SaslCredentials ::= SEQUENCE { - * mechanism LDAPString, - * credentials OCTET STRING - * } - * all wrapped up in an LDAPMessage sequence. - */ - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_sasl_bind\n", 0, 0, 0 ); - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - return( LDAP_PARAM_ERROR ); - } - - if ( msgidp == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return( LDAP_PARAM_ERROR ); - } - - if ( ( ld->ld_options & LDAP_BITOPT_RECONNECT ) != 0 ) { - nsldapi_handle_reconnect( ld ); - } - - simple = ( mechanism == LDAP_SASL_SIMPLE ); - ldapversion = NSLDAPI_LDAP_VERSION( ld ); - - /* only ldapv3 or higher can do sasl binds */ - if ( !simple && ldapversion < LDAP_VERSION3 ) { - LDAP_SET_LDERRNO( ld, LDAP_NOT_SUPPORTED, NULL, NULL ); - return( LDAP_NOT_SUPPORTED ); - } - - LDAP_MUTEX_LOCK( ld, LDAP_MSGID_LOCK ); - msgid = ++ld->ld_msgid; - LDAP_MUTEX_UNLOCK( ld, LDAP_MSGID_LOCK ); - - if ( dn == NULL ) - dn = ""; - - if ( ld->ld_cache_on && ld->ld_cache_bind != NULL ) { - LDAP_MUTEX_LOCK( ld, LDAP_CACHE_LOCK ); - if ( (rc = (ld->ld_cache_bind)( ld, msgid, LDAP_REQ_BIND, dn, - cred, LDAP_AUTH_SASL )) != 0 ) { - *msgidp = rc; - LDAP_MUTEX_UNLOCK( ld, LDAP_CACHE_LOCK ); - return( LDAP_SUCCESS ); - } - LDAP_MUTEX_UNLOCK( ld, LDAP_CACHE_LOCK ); - } - - /* create a message to send */ - if (( rc = nsldapi_alloc_ber_with_options( ld, &ber )) - != LDAP_SUCCESS ) { - return( rc ); - } - - /* fill it in */ - if ( simple ) { /* simple bind; works in LDAPv2 or v3 */ - struct berval tmpcred; - - if ( cred == NULL ) { - tmpcred.bv_val = ""; - tmpcred.bv_len = 0; - cred = &tmpcred; - } - rc = ber_printf( ber, "{it{isto}", msgid, LDAP_REQ_BIND, - ldapversion, dn, LDAP_AUTH_SIMPLE, cred->bv_val, - cred->bv_len ); - - } else { /* SASL bind; requires LDAPv3 or better */ - if ( cred == NULL ) { - rc = ber_printf( ber, "{it{ist{s}}", msgid, - LDAP_REQ_BIND, ldapversion, dn, LDAP_AUTH_SASL, - mechanism ); - } else { - rc = ber_printf( ber, "{it{ist{so}}", msgid, - LDAP_REQ_BIND, ldapversion, dn, LDAP_AUTH_SASL, - mechanism, cred->bv_val, - cred->bv_len ); - } - } - - if ( rc == -1 ) { - LDAP_SET_LDERRNO( ld, LDAP_ENCODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_ENCODING_ERROR ); - } - - if ( (rc = nsldapi_put_controls( ld, serverctrls, 1, ber )) - != LDAP_SUCCESS ) { - ber_free( ber, 1 ); - return( rc ); - } - - /* send the message */ - rc = nsldapi_send_initial_request( ld, msgid, LDAP_REQ_BIND, - (char *)dn, ber ); - *msgidp = rc; - return( rc < 0 ? LDAP_GET_LDERRNO( ld, NULL, NULL ) : LDAP_SUCCESS ); -} - -/* - * ldap_sasl_bind_s - bind to the ldap server using sasl authentication - * The dn, mechanism, and credentials of the entry to which to bind are - * supplied. LDAP_SUCCESS is returned upon success, the ldap error code - * otherwise. - * - * Example: - * struct berval creds; - * ... fill in creds with credentials ... - * ldap_sasl_bind_s( ld, "cn=manager, o=university of michigan, c=us", - * "mechanismname", &creds ) - */ -int -LDAP_CALL -ldap_sasl_bind_s( - LDAP *ld, - const char *dn, - const char *mechanism, - const struct berval *cred, - LDAPControl **serverctrls, - LDAPControl **clientctrls, - struct berval **servercredp -) -{ - return ( nsldapi_sasl_bind_s( ld, dn, mechanism, cred, - serverctrls, clientctrls, servercredp, NULL ) ); -} - -#ifdef LDAP_SASLIO_HOOKS -/* - * SASL Authentication Interface: ldap_sasl_interactive_bind_s - * - * This routine takes a DN, SASL mech list, and a SASL callback - * and performs the necessary sequencing to complete a SASL bind - * to the LDAP connection ld. The user provided callback can - * use an optionally provided set of default values to complete - * any necessary interactions. - * - * Currently imposes the following restrictions: - * A mech list must be provided - * LDAP_SASL_INTERACTIVE mode requires a callback - */ -int -LDAP_CALL -ldap_sasl_interactive_bind_s( LDAP *ld, const char *dn, - const char *saslMechanism, - LDAPControl **sctrl, LDAPControl **cctrl, unsigned flags, - LDAP_SASL_INTERACT_PROC *callback, void *defaults ) -{ - return ldap_sasl_interactive_bind_ext_s( ld, dn, - saslMechanism, sctrl, cctrl, flags, callback, - defaults, NULL ); -} - -/* - * ldap_sasl_interactive_bind_ext_s - * - * This function extends ldap_sasl_interactive_bind_s by allowing - * controls received from the server to be returned as rctrl. The - * caller must pass in a valid LDAPControl** pointer and free the - * array of controls when finished with them e.g. - * LDAPControl **retctrls = NULL; - * ... - * ldap_sasl_interactive_bind_ext_s(ld, ...., &retctrls); - * ... - * ldap_controls_free(retctrls); - * Only the controls from the server during the last bind step are returned - - * intermediate controls (if any, usually not) are discarded. - */ -int -LDAP_CALL -ldap_sasl_interactive_bind_ext_s( LDAP *ld, const char *dn, - const char *saslMechanism, - LDAPControl **sctrl, LDAPControl **cctrl, unsigned flags, - LDAP_SASL_INTERACT_PROC *callback, void *defaults, LDAPControl ***rctrl ) -{ -#ifdef LDAP_SASLIO_GET_MECHS_FROM_SERVER - char *smechs; -#endif - int rc; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_sasl_interactive_bind_s\n", 0, 0, 0 ); - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - return( LDAP_PARAM_ERROR ); - } - - if ((flags == LDAP_SASL_INTERACTIVE) && (callback == NULL)) { - return( LDAP_PARAM_ERROR ); - } - - LDAP_MUTEX_LOCK(ld, LDAP_SASL_LOCK ); - - if( saslMechanism == NULL || *saslMechanism == '\0' ) { -#ifdef LDAP_SASLIO_GET_MECHS_FROM_SERVER - rc = nsldapi_get_sasl_mechs( ld, &smechs ); - if( rc != LDAP_SUCCESS ) { - LDAP_MUTEX_UNLOCK(ld, LDAP_SASL_LOCK ); - return( rc ); - } - saslMechanism = smechs; -#else - LDAP_MUTEX_UNLOCK(ld, LDAP_SASL_LOCK ); - return( LDAP_PARAM_ERROR ); -#endif /* LDAP_SASLIO_GET_MECHS_FROM_SERVER */ - } - - rc = nsldapi_sasl_do_bind( ld, dn, saslMechanism, - flags, callback, defaults, sctrl, cctrl, rctrl); - - LDAP_MUTEX_UNLOCK(ld, LDAP_SASL_LOCK ); - return( rc ); -} -#else /* LDAP_SASLIO_HOOKS */ -/* stubs for platforms that do not support SASL */ -int -LDAP_CALL -ldap_sasl_interactive_bind_s( LDAP *ld, const char *dn, - const char *saslMechanism, - LDAPControl **sctrl, LDAPControl **cctrl, unsigned flags, - LDAP_SASL_INTERACT_PROC *callback, void *defaults ) -{ - return LDAP_SUCCESS; -} - -int -LDAP_CALL -ldap_sasl_interactive_bind_ext_s( LDAP *ld, const char *dn, - const char *saslMechanism, - LDAPControl **sctrl, LDAPControl **cctrl, unsigned flags, - LDAP_SASL_INTERACT_PROC *callback, void *defaults, LDAPControl ***rctrl ) -{ - return LDAP_SUCCESS; -} -#endif /* LDAP_SASLIO_HOOKS */ - - -/* returns an LDAP error code that indicates if parse succeeded or not */ -int -LDAP_CALL -ldap_parse_sasl_bind_result( - LDAP *ld, - LDAPMessage *res, - struct berval **servercredp, - int freeit -) -{ - BerElement ber; - int rc, err; - ber_int_t along; - ber_len_t len; - char *m, *e; - - LDAPDebug( LDAP_DEBUG_TRACE, "ldap_parse_sasl_bind_result\n", 0, 0, 0 ); - - /* - * the ldapv3 SASL bind response looks like this: - * - * BindResponse ::= [APPLICATION 1] SEQUENCE { - * COMPONENTS OF LDAPResult, - * serverSaslCreds [7] OCTET STRING OPTIONAL - * } - * - * all wrapped up in an LDAPMessage sequence. - */ - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || - !NSLDAPI_VALID_LDAPMESSAGE_BINDRESULT_POINTER( res )) { - return( LDAP_PARAM_ERROR ); - } - - /* only ldapv3 or higher can do sasl binds */ - if ( NSLDAPI_LDAP_VERSION( ld ) < LDAP_VERSION3 ) { - LDAP_SET_LDERRNO( ld, LDAP_NOT_SUPPORTED, NULL, NULL ); - return( LDAP_NOT_SUPPORTED ); - } - - if ( servercredp != NULL ) { - *servercredp = NULL; - } - - ber = *(res->lm_ber); /* struct copy */ - - /* skip past message id, matched dn, error message ... */ - rc = ber_scanf( &ber, "{iaa}", &along, &m, &e ); - - if ( rc != LBER_ERROR && - ber_peek_tag( &ber, &len ) == LDAP_TAG_SASL_RES_CREDS ) { - rc = ber_get_stringal( &ber, servercredp ); - } - - if ( freeit ) { - ldap_msgfree( res ); - } - - if ( rc == LBER_ERROR ) { - err = LDAP_DECODING_ERROR; - } else { - err = (int) along; - } - - LDAP_SET_LDERRNO( ld, err, m, e ); - /* this is a little kludge for the 3.0 Barracuda/hammerhead relese */ - /* the docs state that the return is either LDAP_DECODING_ERROR */ - /* or LDAP_SUCCESS. Here we match the docs... it's cleaner in 3.1 */ - - if ( LDAP_DECODING_ERROR == err ) { - return (LDAP_DECODING_ERROR); - } else { - return( LDAP_SUCCESS ); - } -} -
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap/ufn.c
Deleted
@@ -1,549 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright (c) 1990 Regents of the University of Michigan. - * All rights reserved. - */ -/* - * ufn.c - */ - -#if 0 -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif -#endif - -#include "ldap-int.h" - -typedef int (LDAP_CALL *cancelptype)( void *cancelparm ); - -static int ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, - char *prefix, char **attrs, int attrsonly, - LDAPMessage **res, LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm, - char *tag1, char *tag2, char *tag3 ); -static LDAPMessage *ldap_msg_merge( LDAP *ld, LDAPMessage *a, LDAPMessage *b ); -static LDAPMessage *ldap_ufn_expand( LDAP *ld, - LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm, char **dns, - char *filter, int scope, char **attrs, int aonly, int *err ); - -/* - * ldap_ufn_search_ctx - do user friendly searching; provide cancel feature; - * specify ldapfilter.conf tags for each phase of search - * - * ld LDAP descriptor - * ufncomp the exploded user friendly name to look for - * ncomp number of elements in ufncomp - * prefix where to start searching - * attrs list of attribute types to return for matches - * attrsonly 1 => attributes only 0 => attributes and values - * res will contain the result of the search - * cancelproc routine that returns non-zero if operation should be - * cancelled. This can be NULL. If it is non-NULL, the - * routine will be called periodically. - * cancelparm void * that is passed to cancelproc - * tag[123] the ldapfilter.conf tag that will be used in phases - * 1, 2, and 3 of the search, respectively - * - * Example: - * char *attrs[] = { "mail", "title", 0 }; - * char *ufncomp[] = { "howes", "umich", "us", 0 } - * LDAPMessage *res; - * error = ldap_ufn_search_ctx( ld, ufncomp, 3, NULL, attrs, attrsonly, - * &res, acancelproc, along, "ufn first", - * "ufn intermediate", "ufn last" ); - */ - -static int -ldap_ufn_search_ctx( - LDAP *ld, - char **ufncomp, - int ncomp, - char *prefix, - char **attrs, - int attrsonly, - LDAPMessage **res, - LDAP_CANCELPROC_CALLBACK *cancelproc, - void *cancelparm, - char *tag1, - char *tag2, - char *tag3 -) -{ - char *dn, *ftag = NULL; - char **dns = NULL; - int max, i, err, scope = 0, phase, tries; - LDAPFiltInfo *fi; - LDAPMessage *tmpcand; - LDAPMessage *candidates; - static char *objattrs[] = { "objectClass", NULL }; - - /* - * look up ufn components from most to least significant. - * there are 3 phases. - * phase 1 search the root for orgs or countries - * phase 2 search for orgs - * phase 3 search for a person - * in phases 1 and 2, we are building a list of candidate DNs, - * below which we will search for the final component of the ufn. - * for each component we try the filters listed in the - * filterconfig file, first one-level (except the last compoment), - * then subtree. if any of them produce any results, we go on to - * the next component. - */ - - *res = NULL; - candidates = NULL; - phase = 1; - for ( ncomp--; ncomp != -1; ncomp-- ) { - if ( *ufncomp[ncomp] == '"' ) { - char *quote; - - if ( (quote = strrchr( ufncomp[ncomp], '"' )) != NULL ) - *quote = '\0'; - strcpy( ufncomp[ncomp], ufncomp[ncomp] + 1 ); - } - if ( ncomp == 0 ) - phase = 3; - - switch ( phase ) { - case 1: - ftag = tag1; - scope = LDAP_SCOPE_ONELEVEL; - break; - case 2: - ftag = tag2; - scope = LDAP_SCOPE_ONELEVEL; - break; - case 3: - ftag = tag3; - scope = LDAP_SCOPE_SUBTREE; - break; - } - - /* - * construct an array of DN's to search below from the - * list of candidates. - */ - - if ( candidates == NULL ) { - if ( prefix != NULL ) { - if ( (dns = (char **)NSLDAPI_MALLOC( - sizeof(char *) * 2 )) == NULL ) { - err = LDAP_NO_MEMORY; - LDAP_SET_LDERRNO( ld, err, NULL, NULL ); - return( err ); - } - dns[0] = nsldapi_strdup( prefix ); - dns[1] = NULL; - } else { - dns = NULL; - } - } else { - i = 0, max = 0; - for ( tmpcand = candidates; tmpcand != NULL && - tmpcand->lm_msgtype != LDAP_RES_SEARCH_RESULT; - tmpcand = tmpcand->lm_chain ) - { - if ( (dn = ldap_get_dn( ld, tmpcand )) == NULL ) - continue; - - if ( dns == NULL ) { - if ( (dns = (char **)NSLDAPI_MALLOC( - sizeof(char *) * 8 )) == NULL ) { - err = LDAP_NO_MEMORY; - LDAP_SET_LDERRNO( ld, err, - NULL, NULL ); - return( err ); - } - max = 8; - } else if ( i >= max ) { - if ( (dns = (char **)NSLDAPI_REALLOC( - dns, sizeof(char *) * 2 * max )) - == NULL ) { - err = LDAP_NO_MEMORY; - LDAP_SET_LDERRNO( ld, err, - NULL, NULL ); - return( err ); - } - max *= 2; - } - dns[i++] = dn; - dns[i] = NULL; - } - ldap_msgfree( candidates ); - candidates = NULL; - } - tries = 0; - tryagain: - tries++; - for ( fi = ldap_getfirstfilter( ld->ld_filtd, ftag, - ufncomp[ncomp] ); fi != NULL; - fi = ldap_getnextfilter( ld->ld_filtd ) ) - { - if ( (candidates = ldap_ufn_expand( ld, cancelproc, - cancelparm, dns, fi->lfi_filter, scope, - phase == 3 ? attrs : objattrs, - phase == 3 ? attrsonly : 1, &err )) != NULL ) - { - break; - } - - if ( err == -1 || err == LDAP_USER_CANCELLED ) { - if ( dns != NULL ) { - ldap_value_free( dns ); - dns = NULL; - } - return( err ); - } - } - - if ( candidates == NULL ) { - if ( tries < 2 && phase != 3 ) { - scope = LDAP_SCOPE_SUBTREE; - goto tryagain; - } else { - if ( dns != NULL ) { - ldap_value_free( dns ); - dns = NULL; - } - return( err ); - } - } - - /* go on to the next component */ - if ( phase == 1 ) - phase++; - if ( dns != NULL ) { - ldap_value_free( dns ); - dns = NULL; - } - } - *res = candidates; - - return( err ); -} - -int -LDAP_CALL -ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly, - LDAPMessage **res, LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm, - char *tag1, char *tag2, char *tag3 ) -{ - char **ufncomp, **prefixcomp; - char *pbuf; - int ncomp, pcomp, i, err = 0; - - /* getfilter stuff must be inited before we are called */ - if ( ld->ld_filtd == NULL ) { - err = LDAP_PARAM_ERROR; - LDAP_SET_LDERRNO( ld, err, NULL, NULL ); - return( err ); - } - - /* call ldap_explode_dn() to break the ufn into its components */ - if ( (ufncomp = ldap_explode_dn( ufn, 0 )) == NULL ) { - err = LDAP_LOCAL_ERROR; - LDAP_SET_LDERRNO( ld, err, NULL, NULL ); - return( err ); - } - for ( ncomp = 0; ufncomp[ncomp] != NULL; ncomp++ ) - ; /* NULL */ - - /* more than two components => try it fully qualified first */ - if ( ncomp > 2 || ld->ld_ufnprefix == NULL ) { - err = ldap_ufn_search_ctx( ld, ufncomp, ncomp, NULL, attrs, - attrsonly, res, cancelproc, cancelparm, tag1, tag2, tag3 ); - - if ( ldap_count_entries( ld, *res ) > 0 ) { - ldap_value_free( ufncomp ); - return( err ); - } else { - ldap_msgfree( *res ); - *res = NULL; - } - } - - if ( ld->ld_ufnprefix == NULL ) { - ldap_value_free( ufncomp ); - return( err ); - } - - /* if that failed, or < 2 components, use the prefix */ - if ( (prefixcomp = ldap_explode_dn( ld->ld_ufnprefix, 0 )) == NULL ) { - ldap_value_free( ufncomp ); - err = LDAP_LOCAL_ERROR; - LDAP_SET_LDERRNO( ld, err, NULL, NULL ); - return( err ); - } - for ( pcomp = 0; prefixcomp[pcomp] != NULL; pcomp++ ) - ; /* NULL */ - if ( (pbuf = (char *)NSLDAPI_MALLOC( strlen( ld->ld_ufnprefix ) + 1 )) - == NULL ) { - ldap_value_free( ufncomp ); - ldap_value_free( prefixcomp ); - err = LDAP_NO_MEMORY; - LDAP_SET_LDERRNO( ld, err, NULL, NULL ); - return( err ); - } - - for ( i = 0; i < pcomp; i++ ) { - int j; - - *pbuf = '\0'; - for ( j = i; j < pcomp; j++ ) { - strcat( pbuf, prefixcomp[j] ); - if ( j + 1 < pcomp ) - strcat( pbuf, "," ); - } - err = ldap_ufn_search_ctx( ld, ufncomp, ncomp, pbuf, attrs, - attrsonly, res, cancelproc, cancelparm, tag1, tag2, tag3 ); - - if ( ldap_count_entries( ld, *res ) > 0 ) { - break; - } else { - ldap_msgfree( *res ); - *res = NULL; - } - } - - ldap_value_free( ufncomp ); - ldap_value_free( prefixcomp ); - NSLDAPI_FREE( pbuf ); - - return( err ); -} - -/* - * same as ldap_ufn_search_ct, except without the ability to specify - * ldapfilter.conf tags. - */ -int -LDAP_CALL -ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs, int attrsonly, - LDAPMessage **res, LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm ) -{ - return( ldap_ufn_search_ct( ld, ufn, attrs, attrsonly, res, cancelproc, - cancelparm, "ufn first", "ufn intermediate", "ufn last" ) ); -} - -/* - * same as ldap_ufn_search_c without the cancel function - */ -int -LDAP_CALL -ldap_ufn_search_s( LDAP *ld, char *ufn, char **attrs, int attrsonly, - LDAPMessage **res ) -{ - struct timeval tv; - - tv.tv_sec = ld->ld_timelimit; - - return( ldap_ufn_search_ct( ld, ufn, attrs, attrsonly, res, - ld->ld_timelimit ? ldap_ufn_timeout : NULL, - ld->ld_timelimit ? (void *) &tv : NULL, - "ufn first", "ufn intermediate", "ufn last" ) ); -} - - -/* - * ldap_msg_merge - merge two ldap search result chains. the more - * serious of the two error result codes is kept. - */ - -static LDAPMessage * -ldap_msg_merge( LDAP *ld, LDAPMessage *a, LDAPMessage *b ) -{ - LDAPMessage *end, *aprev, *aend, *bprev, *bend; - - if ( a == NULL ) - return( b ); - - if ( b == NULL ) - return( a ); - - /* find the ends of the a and b chains */ - aprev = NULL; - for ( aend = a; aend->lm_chain != NULL; aend = aend->lm_chain ) - aprev = aend; - bprev = NULL; - for ( bend = b; bend->lm_chain != NULL; bend = bend->lm_chain ) - bprev = bend; - - /* keep result a */ - if ( ldap_result2error( ld, aend, 0 ) != LDAP_SUCCESS ) { - /* remove result b */ - ldap_msgfree( bend ); - if ( bprev != NULL ) - bprev->lm_chain = NULL; - else - b = NULL; - end = aend; - if ( aprev != NULL ) - aprev->lm_chain = NULL; - else - a = NULL; - /* keep result b */ - } else { - /* remove result a */ - ldap_msgfree( aend ); - if ( aprev != NULL ) - aprev->lm_chain = NULL; - else - a = NULL; - end = bend; - if ( bprev != NULL ) - bprev->lm_chain = NULL; - else - b = NULL; - } - - if ( (a == NULL && b == NULL) || (a == NULL && bprev == NULL) || - (b == NULL && aprev == NULL) ) - return( end ); - - if ( a == NULL ) { - bprev->lm_chain = end; - return( b ); - } else if ( b == NULL ) { - aprev->lm_chain = end; - return( a ); - } else { - bprev->lm_chain = end; - aprev->lm_chain = b; - return( a ); - } -} - -static LDAPMessage * -ldap_ufn_expand( LDAP *ld, LDAP_CANCELPROC_CALLBACK *cancelproc, - void *cancelparm, char **dns, char *filter, int scope, - char **attrs, int aonly, int *err ) -{ - LDAPMessage *tmpcand, *tmpres; - char *dn; - int i, msgid; - struct timeval tv; - - /* search for this component below the current candidates */ - tmpcand = NULL; - i = 0; - do { - if ( dns != NULL ) - dn = dns[i]; - else - dn = ""; - - if (( msgid = ldap_search( ld, dn, scope, filter, attrs, - aonly )) == -1 ) { - ldap_msgfree( tmpcand ); - *err = LDAP_GET_LDERRNO( ld, NULL, NULL ); - return( NULL ); - } - - tv.tv_sec = 0; - tv.tv_usec = 100000; /* 1/10 of a second */ - - do { - *err = ldap_result( ld, msgid, 1, &tv, &tmpres ); - if ( *err == 0 && cancelproc != NULL && - (*cancelproc)( cancelparm ) != 0 ) { - ldap_abandon( ld, msgid ); - *err = LDAP_USER_CANCELLED; - LDAP_SET_LDERRNO( ld, *err, NULL, NULL ); - } - } while ( *err == 0 ); - - if ( *err == LDAP_USER_CANCELLED || *err < 0 || - ( *err = ldap_result2error( ld, tmpres, 0 )) == -1 ) { - ldap_msgfree( tmpcand ); - return( NULL ); - } - - tmpcand = ldap_msg_merge( ld, tmpcand, tmpres ); - - i++; - } while ( dns != NULL && dns[i] != NULL ); - - if ( ldap_count_entries( ld, tmpcand ) > 0 ) { - return( tmpcand ); - } else { - ldap_msgfree( tmpcand ); - return( NULL ); - } -} - -/* - * ldap_ufn_setfilter - set the filter config file used in ufn searching - */ - -LDAPFiltDesc * -LDAP_CALL -ldap_ufn_setfilter( LDAP *ld, char *fname ) -{ - if ( ld->ld_filtd != NULL ) - ldap_getfilter_free( ld->ld_filtd ); - - return( ld->ld_filtd = ldap_init_getfilter( fname ) ); -} - -void -LDAP_CALL -ldap_ufn_setprefix( LDAP *ld, char *prefix ) -{ - if ( ld->ld_ufnprefix != NULL ) - NSLDAPI_FREE( ld->ld_ufnprefix ); - - ld->ld_ufnprefix = nsldapi_strdup( prefix ); -} - -int -LDAP_C -ldap_ufn_timeout( void *tvparam ) -{ - struct timeval *tv; - - tv = (struct timeval *)tvparam; - - if ( tv->tv_sec != 0 ) { - tv->tv_usec = tv->tv_sec * 1000000; /* sec => micro sec */ - tv->tv_sec = 0; - } - tv->tv_usec -= 100000; /* 1/10 of a second */ - - return( tv->tv_usec <= 0 ? 1 : 0 ); -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap/userstatusctrl.c
Deleted
@@ -1,229 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Sun LDAP C SDK. - * - * The Initial Developer of the Original Code is Sun Microsystems, Inc. - * - * Portions created by Sun Microsystems, Inc are Copyright (C) 2005 - * Sun Microsystems, Inc. All Rights Reserved. - * - * Contributor(s): abobrov@sun.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "ldap-int.h" - -/* ldap_create_userstatus_control: - - Parameters are - - ld LDAP pointer to the desired connection - - ctl_iscritical Indicates whether the control is critical of not. If - this field is non-zero, the operation will only be car- - ried out if the control is recognized by the server - and/or client - - ctrlp the address of a place to put the constructed control -*/ - -int -LDAP_CALL -ldap_create_userstatus_control ( - LDAP *ld, - const char ctl_iscritical, - LDAPControl **ctrlp - ) -{ - int rc; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - return( LDAP_PARAM_ERROR ); - } - - if ( ctrlp == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return ( LDAP_PARAM_ERROR ); - } - - rc = nsldapi_build_control( LDAP_CONTROL_ACCOUNT_USABLE, - NULL, NULL, ctl_iscritical, ctrlp ); - - LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); - return( rc ); -} - -/* ldap_parse_userstatus_control: - - Parameters are - - ld LDAP pointer to the desired connection - - ctrlp An array of controls obtained from calling - ldap_parse_result on the set of results - returned by the server - - us the address of struct LDAPuserstatus - to parse control results to -*/ - -int -LDAP_CALL -ldap_parse_userstatus_control ( - LDAP *ld, - LDAPControl **ctrlp, - LDAPuserstatus *us - ) -{ - BerElement *ber = NULL; - int i, foundUSControl; - LDAPControl *USCtrlp = NULL; - ber_len_t len; - ber_tag_t tag; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || us == NULL ) { - return( LDAP_PARAM_ERROR ); - } - - /* find the control in the list of controls if it exists */ - if ( ctrlp == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); - return ( LDAP_CONTROL_NOT_FOUND ); - } - foundUSControl = 0; - for ( i = 0; (( ctrlp[i] != NULL ) && ( !foundUSControl )); i++ ) { - foundUSControl = !strcmp( ctrlp[i]->ldctl_oid, LDAP_CONTROL_ACCOUNT_USABLE ); - } - if ( !foundUSControl ) { - LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); - return ( LDAP_CONTROL_NOT_FOUND ); - } else { - /* let local var point to the control */ - USCtrlp = ctrlp[i-1]; - } - - /* allocate a Ber element with the contents of the control's struct berval */ - if ( ( ber = ber_init( &USCtrlp->ldctl_value ) ) == NULL ) { - LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); - return( LDAP_NO_MEMORY ); - } - - memset( us, 0, sizeof(struct LDAPuserstatus) ); - - /* - * The control value should look like this: - * - * ACCOUNT_USABLE_RESPONSE::= CHOICE { - * is_available [0] INTEGER, ** seconds before expiration ** - * is_not_available [1] More_info - * } - * More_info::= SEQUENCE { - * inactive [0] BOOLEAN DEFAULT FALSE, - * reset [1] BOOLEAN DEFAULT FALSE, - * expired [2] BOOLEAN DEFAULT FALSE, - * remaining_grace [3] INTEGER OPTIONAL, - * seconds_before_unlock [4] INTEGER OPTIONAL - * } - */ - - if ( ( ber_scanf( ber, "t", &tag ) ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - - tag = (( tag & LBER_CONSTRUCTED ) == LBER_CONSTRUCTED ) ? 1 : 0; - - if ( !tag ) { - us->us_available = 1; - if ( ber_scanf( ber, "i", &us->us_expire ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - } else { - us->us_available = 0; - tag = 0; - if ( ( ber_scanf( ber, "{t", &tag ) ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - while ( tag != LBER_ERROR && tag != LBER_END_OF_SEQORSET ) { - tag = tag & (~LBER_CLASS_CONTEXT); - switch (tag) - { - case 0: - if ( ber_scanf( ber, "b", &us->us_inactive ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - us->us_inactive = ( us->us_inactive != 0 ) ? 1 : 0; - break; - case 1: - if ( ber_scanf( ber, "b", &us->us_reset ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - us->us_reset = ( us->us_reset != 0 ) ? 1 : 0; - break; - case 2: - if ( ber_scanf( ber, "b", &us->us_expired ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - us->us_expired = ( us->us_expired != 0 ) ? 1 : 0; - break; - case 3: - if ( ber_scanf( ber, "i", &us->us_remaining ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - break; - case 4: - if ( ber_scanf( ber, "i", &us->us_seconds ) == LBER_ERROR ) { - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - break; - default: - LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); - ber_free( ber, 1 ); - return( LDAP_DECODING_ERROR ); - } - ber_scanf( ber, "t", &tag ); - } - } - - /* the ber encoding is no longer needed */ - ber_free( ber, 1 ); - return( LDAP_SUCCESS ); -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldap/whoami.c
Deleted
@@ -1,132 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Sun LDAP C SDK. - * - * The Initial Developer of the Original Code is Sun Microsystems, Inc. - * - * Portions created by Sun Microsystems, Inc are Copyright (C) 2005 - * Sun Microsystems, Inc. All Rights Reserved. - * - * Contributor(s): abobrov@sun.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "ldap-int.h" - -/* ldap_whoami */ -int -LDAP_CALL -ldap_whoami ( - LDAP *ld, - LDAPControl **serverctrls, - LDAPControl **clientctrls, - int *msgidp - ) -{ - int rc; - struct berval *requestdata = NULL; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return( LDAP_PARAM_ERROR ); - } - - rc = ldap_extended_operation( ld, LDAP_EXOP_WHO_AM_I, requestdata, - serverctrls, clientctrls, msgidp ); - - return( rc ); -} - -/* ldap_parse_whoami */ -int -LDAP_CALL -ldap_parse_whoami ( - LDAP *ld, - LDAPMessage *result, - struct berval **authzid - ) -{ - int rc; - char *retoidp = NULL; - char *authzidp = NULL; - struct berval *retdatap = NULL; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return( LDAP_PARAM_ERROR ); - } - if ( !result ) { - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return( LDAP_PARAM_ERROR ); - } - - *authzid = NULL; - - rc = ldap_parse_extended_result( ld, result, &retoidp, authzid, 0 ); - - if ( rc != LDAP_SUCCESS ) { - return( rc ); - } - - ldap_memfree( retoidp ); - return( LDAP_SUCCESS ); -} - -/* ldap_whoami_s */ -int -LDAP_CALL -ldap_whoami_s ( - LDAP *ld, - struct berval **authzid, - LDAPControl **serverctrls, - LDAPControl **clientctrls - ) -{ - int rc; - int msgid; - LDAPMessage *result = NULL; - - if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { - LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return( LDAP_PARAM_ERROR ); - } - - rc = ldap_whoami( ld, serverctrls, clientctrls, &msgid ); - if ( rc != LDAP_SUCCESS ) { - return( rc ); - } - - rc = ldap_result( ld, msgid, LDAP_MSG_ALL, NULL, &result ); - if ( rc == -1 ) { - return( LDAP_GET_LDERRNO( ld, NULL, NULL ) ); - } - - rc = ldap_parse_whoami( ld, result, authzid ); - - ldap_msgfree( result ); - - return( rc ); -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldif
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libldif/Makefile.in
Deleted
@@ -1,166 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla Communicator client code, released -# March 31, 1998. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-1999 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -MOD_DEPTH = ../../.. -srcdir = @srcdir@ -topsrcdir = @top_srcdir@ - -include $(MOD_DEPTH)/config/autoconf.mk -include $(topsrcdir)/build.mk - -SRCS = line64.c - -RELEASE_LIBS = $(SHARED_LIBRARY) $(DLLLDIF) - -REALOBJS = $(SRCS:.c=.$(OBJ_SUFFIX)) -OBJS = $(addprefix $(OBJDIR_NAME)/, $(REALOBJS)) - -HDIR = $(topsrcdir)/ldap/include - -LIBLDIF = $(addprefix $(OBJDIR_NAME)/, $(LIB_PREFIX)$(LDIF_LIBNAME).$(LIB_SUFFIX)) -DLLLDIF = $(addprefix $(OBJDIR_NAME)/, $(LIB_PREFIX)$(LDIF_LIBNAME).$(DLL_SUFFIX)) - -INSTALLDIR = $(DIST)/$(OBJDIR_NAME) - -include $(topsrcdir)/config/rules.mk - -GARBAGE += $(LIBLDIF) - -LOCAL_INCLUDES = -I$(PUBLIC)/nspr -INCLUDES += -I$(HDIR) -I$(INSTALLDIR)/include -I$(DIST)/include -DEFINES += $(DEFS) - -PLATFORMCFLAGS = -DUSE_WAITPID -DNEEDPROTOS -PLATFORMLIBS = -THREADS = -THREADSLIB = - -ifeq ($(OS_ARCH), AIX) -PLATFORMLIBS += -ldl -brtl -lpthreads -lc_r -lm -endif - -# -# shared library symbol export definitions -# -ifeq ($(USE_DLL_EXPORTS_FILE), 1) -ifeq ($(OS_ARCH), WINNT) -GENEXPORTS=cmd /c $(PERL) $(topsrcdir)/ldap/build/genexports.pl -else -GENEXPORTS=$(PERL) $(topsrcdir)/ldap/build/genexports.pl -endif - -# variable definitions for exported symbols -ifeq ($(OS_ARCH), WINNT) - LDIF_EXPORT_DEFS= $(srcdir)/../msdos/winsock/nsldif32.def -else -ifeq ($(OS_ARCH), OS2) - LDIF_EXPORT_DEFS= $(OBJDIR_NAME)/libldif.def -else - LDIF_EXPORT_DEFS= $(OBJDIR_NAME)/libldif.exp -endif -GARBAGE += $(LDIF_EXPORT_DEFS) -endif - -LDIF_EXPORT_FLAGS=$(addprefix $(DLLEXPORTS_PREFIX), $(LDIF_EXPORT_DEFS)) - -GENEXPARGS=$(BUILD_DEBUG) $(LDIFVERS_SUFFIX) $(LDIFVERS) -endif # USE_DLL_EXPORTS_FILE - - -########################################################################### - -ifeq ($(USE_DLL_EXPORTS_FILE), 1) -# recursive gmake rule to create exported symbols file -$(LDIF_EXPORT_DEFS):: $(srcdir)/../libldif.ex -ifeq ($(OS_ARCH), WINNT) - $(GENEXPORTS) Win32 $(srcdir)/../msdos/winsock/nsldif32.tdf $< $(GENEXPARGS) > $@ -else -ifeq ($(OS_ARCH), OS2) - echo LIBRARY $(LDIF_LIBNAME) INITINSTANCE TERMINSTANCE > $@ - echo PROTMODE >> $@ - echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@ - echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@ - echo EXPORTS >> $@ - $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) >> $@ -else - $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) > $@ -endif -endif -endif # USE_DLL_EXPORTS_FILE - -versiont.c: Makefile.client Version.c - @$(RM) $@ - @(u="$${USER-root}" v="$(shell cat ../../build/version)" d="$(shell pwd)" \ - h="$(shell hostname)" t="$(shell date)"; $(SED) -e "s|%WHEN%|$${t}|" \ - -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ - -e "s|%VERSION%|$${v}|" \ - < Version.c > $@) - -export:: $(OBJDEST) $(LIBDIR) $(OBJS) $(LIBLDIF) - -$(LIBDIR): - $(MKDIR) $(LIBDIR) - -$(LIBLDIF): $(OBJS) $(LIBDIR) - @echo ======= making $(LIBLDIF) - - $(LINK_LIB) - -$(DLLLDIF): $(OBJS) $(LIBDIR) $(LDIF_EXPORT_DEFS) - @echo ======= making $(DLLLDIF) - -ifdef SO_FILES_TO_REMOVE - -$(RM) $(SO_FILES_TO_REMOVE) -endif - - $(LINK_DLL) $(LDIF_EXPORT_FLAGS) $(PLATFORMLIBS) $(EXTRA_LIBS) - - -veryclean:: clean - -$(OBJDEST): - $(MKDIR) $(OBJDEST) - -export:: $(DLLLDIF) $(LIBLDIF) - $(INSTALL) -m 444 $(LIBLDIF) $(dist_libdir) - -ifdef MKSHLIB - $(INSTALL) -m 444 $(LIBLDIF) $(dist_libdir) - $(INSTALL) -m 444 $(DLLLDIF) $(dist_libdir) - $(INSTALL) -m 444 $(DLLLDIF) $(dist_bindir) -endif
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libprldap
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libprldap/Makefile.in
Deleted
@@ -1,250 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla Communicator client code, released -# March 31, 1998. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-1999 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -MOD_DEPTH = ../../.. -srcdir = @srcdir@ -topsrcdir = @top_srcdir@ -NSPR_LIBS = @NSPR_LIBS@ -NSPR_CFLAGS = @NSPR_CFLAGS@ - -include $(MOD_DEPTH)/config/autoconf.mk -include $(topsrcdir)/build.mk - -SRCS = ldappr-dns.c \ - ldappr-error.c \ - ldappr-io.c \ - ldappr-public.c \ - ldappr-threads.c - -REALOBJS = $(SRCS:.c=.$(OBJ_SUFFIX)) -OBJS = $(addprefix $(OBJDIR_NAME)/, $(REALOBJS)) - -DISTHDIR = $(DIST)/public/ldap -HDIR = $(topsrcdir)/ldap/include - -ifneq (,$(filter OS2 WINNT,$(OS_ARCH))) -LIBPRLDAP = $(addprefix $(OBJDIR_NAME)/, \ - $(LIB_PREFIX)$(PRLDAP_LIBNAME).$(LIB_SUFFIX)) -else -LIBPRLDAP = -endif -DLLPRLDAP = $(addprefix $(OBJDIR_NAME)/, \ - $(LIB_PREFIX)$(PRLDAP_LIBNAME).$(DLL_SUFFIX)) - -INSTALLDIR = $(DIST)/$(OBJDIR_NAME) - -RELEASE_LIBS = $(DLLPRLDAP) - -include $(topsrcdir)/config/rules.mk - -GARBAGE += $(LIBPRLDAP) $(DLLPRLDAP) - -LOCAL_INCLUDES = -INCLUDES += -I$(DISTHDIR) -I$(HDIR) -I$(INSTALLDIR)/include \ - $(NSPR_CFLAGS) -DEFINES += $(DEFS) - -PLATFORMCFLAGS = -DUSE_WAITPID -DNEEDPROTOS -PLATFORMLIBS = -THREADS = -THREADSLIB = - -# -# shared library symbol export definitions -# -ifeq ($(USE_DLL_EXPORTS_FILE), 1) -ifeq ($(OS_ARCH), WINNT) -GENEXPORTS=cmd /c $(PERL) $(topsrcdir)/ldap/build/genexports.pl -else -GENEXPORTS=$(PERL) $(topsrcdir)/ldap/build/genexports.pl -endif - -# variable definitions for exported symbols -ifeq ($(OS_ARCH), WINNT) - PRLDAP_EXPORT_DEFS= $(srcdir)/../msdos/winsock/nsldappr32.def -else -ifeq ($(OS_ARCH), OS2) - PRLDAP_EXPORT_DEFS= $(OBJDIR_NAME)/libprldap.def -else - PRLDAP_EXPORT_DEFS= $(OBJDIR_NAME)/libprldap.exp -endif -GARBAGE += $(LDAP_EXPORT_DEFS) -endif - -PRLDAP_EXPORT_FLAGS=$(addprefix $(DLLEXPORTS_PREFIX), $(PRLDAP_EXPORT_DEFS)) - -GENEXPARGS=$(BUILD_DEBUG) $(PRLDAPVERS_SUFFIX) $(PRLDAPVERS) -endif # USE_DLL_EXPORTS_FILE - -ifeq ($(OS_ARCH), WINNT) -ifdef NS_USE_GCC -EXTRA_DLL_LIBS =-L$(dist_libdir) -l$(LDAP_LIBNAME) \ - $(NSPRLINK) -else -EXTRA_LIBS =wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib \ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \ - rpcrt4.lib uuid.lib winmm.lib -EXTRA_LIBS += $(dist_libdir)/$(LDAP_LIBNAME).lib -EXTRA_LIBS += $(NSPRLINK) -endif -CUSTOM_LIBS=1 -endif - -ifeq ($(OS_ARCH),OS2) -EXTRA_LIBS = $(dist_libdir)/$(LDAP_LIBNAME).lib -EXTRA_LIBS += $(dist_libdir)/$(LBER_LIBNAME).lib -EXTRA_LIBS += $(NSPRLINK) -EXTRA_LIBS += $(OS_LIBS) -CUSTOM_LIBS=1 -endif - -ifeq ($(OS_ARCH), OSF1) -EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -EXTRA_LIBS += $(NSPRLINK) -EXTRA_LIBS += -lcxx -lpthread -lrt -lmach -lexc -CUSTOM_LIBS=1 -endif - -ifeq ($(OS_ARCH), AIX) -EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -EXTRA_LIBS += $(NSPRLINK) -EXTRA_LIBS += -ldl -brtl -lpthreads -lc_r -lm -CUSTOM_LIBS=1 -endif - -# no extra libs on HP-UX -ifeq ($(OS_ARCH), HP-UX) -CUSTOM_LIBS=1 -endif - -# if you need to do something extra for extra_libs or extra_dll_libs for a -# specific platform, do them above according the other ones for WINNT, OS2, etc. -# then define CUSTOM_LIBS=1 - if you just want the standard ones as defined -# below, you don't have to do anything -ifndef CUSTOM_LIBS -EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -EXTRA_LIBS += $(NSPRLINK) -endif - -OBJDEST = $(OBJDIR_NAME) - -########################################################################### - -ifeq ($(USE_DLL_EXPORTS_FILE), 1) -# recursive gmake rule to create exported symbols file -$(PRLDAP_EXPORT_DEFS):: $(srcdir)/libprldap.ex -ifeq ($(OS_ARCH), WINNT) - $(GENEXPORTS) Win32 $(srcdir)/../msdos/winsock/nsldappr32.tdf $< $(GENEXPARGS) > $@ -else -ifeq ($(OS_ARCH), OS2) - echo LIBRARY $(PRLDAP_LIBNAME) INITINSTANCE TERMINSTANCE > $@ - echo PROTMODE >> $@ - echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@ - echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@ - echo EXPORTS >> $@ - $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) >> $@ -else - $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) > $@ -endif -endif -endif # USE_DLL_EXPORTS_FILE - -versiont.c: Makefile.client Version.c - @$(RM) $@ - @(u="$${USER-root}" v="$(shell cat ../../build/version)" d="$(shell pwd)" \ - h="$(shell hostname)" t="$(shell date)"; $(SED) -e "s|%WHEN%|$${t}|" \ - -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ - -e "s|%VERSION%|$${v}|" \ - < Version.c > $@) - -export:: $(OBJDEST) $(LIBDIR) $(OBJS) $(DLLPRLDAP) - -$(LIBDIR): - $(MKDIR) $(LIBDIR) - -$(LIBPRLDAP): $(OBJS) $(LIBDIR) $(PRLDAP_EXPORT_DEFS) - @echo ======= making $(LIBPRLDAP) -ifdef SO_FILES_TO_REMOVE - -$(RM) $(SO_FILES_TO_REMOVE) -endif -ifeq ($(OS_ARCH),OS2) -# create import library for OS/2 - rm -f $@ - $(IMPLIB) $@ $(PRLDAP_EXPORT_DEFS) -else - $(LINK_LIB) $(EXTRA_LIBS) -endif - -$(DLLPRLDAP): $(OBJS) $(LIBDIR) $(PRLDAP_EXPORT_DEFS) - @echo ======= making $(DLLPRLDAP) -ifdef SO_FILES_TO_REMOVE - -$(RM) $(SO_FILES_TO_REMOVE) -endif - $(LINK_DLL) $(PRLDAP_EXPORT_FLAGS) $(EXTRA_LIBS) - -veryclean:: clean - -$(OBJDEST): - $(MKDIR) $(OBJDEST) - -# the $(dist_bindir) line is for the mozilla client, which for reasons -# unknown wants shared libraries in /bin also -# -# Set the default sources for the export target -EXPDEPS2 = $(LIBPRLDAP) $(DLLPRLDAP) -# Remove the LIB source if on win32 and using MSVC -# This avoids problems with -jX builds where 'link' will make both the -# .dll and .lib files in one pass -ifeq ($(OS_ARCH), WINNT) -ifeq ($(LD),link) -EXPDEPS2 = $(DLLPRLDAP) -endif -endif - -export:: $(EXPDEPS2) -ifeq ($(OS_ARCH), WINNT) - $(INSTALL) -m 555 $(LIBPRLDAP) $(dist_libdir) - $(INSTALL) -m 555 $(DLLPRLDAP) $(dist_libdir) -endif -ifeq ($(OS_ARCH),OS2) - $(INSTALL) -m 444 $(LIBPRLDAP) $(dist_libdir) -endif -ifdef MKSHLIB - $(INSTALL) -m 555 $(DLLPRLDAP) $(dist_libdir) - $(INSTALL) -m 444 $(DLLPRLDAP) $(dist_bindir) -endif
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libprldap/ldappr-error.c
Deleted
@@ -1,337 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Utilities for manageing the relationship between NSPR errors and - * OS (errno-style) errors. - * - * The overall strategy used is to map NSPR errors into OS errors. - */ - -#include "ldappr-int.h" - -void -prldap_set_system_errno( int oserrno ) -{ - PR_SetError( PR_GetError(), oserrno ); -} - - -int -prldap_get_system_errno( void ) -{ - return( PR_GetOSError()); -} - -/* - * Retrieve the NSPR error number, convert to a system error code, and return - * the result. - */ -struct prldap_errormap_entry { - PRInt32 erm_nspr; /* NSPR error code */ - int erm_system; /* corresponding system error code */ -}; - -/* XXX: not sure if this extra mapping for Windows is good or correct */ -#ifdef _WINDOWS -#ifndef ENOTSUP -#define ENOTSUP -1 -#endif -#ifndef ETIMEDOUT -#define ETIMEDOUT WSAETIMEDOUT -#endif -#ifndef EADDRNOTAVAIL -#define EADDRNOTAVAIL WSAEADDRNOTAVAIL -#endif -#ifndef EAFNOSUPPORT -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#endif -#ifndef EISCONN -#define EISCONN WSAEISCONN -#endif -#ifndef EADDRINUSE -#define EADDRINUSE WSAEADDRINUSE -#endif -#ifndef ECONNREFUSED -#define ECONNREFUSED WSAECONNREFUSED -#endif -#ifndef EHOSTUNREACH -#define EHOSTUNREACH WSAEHOSTUNREACH -#endif -#ifndef ENOTCONN -#define ENOTCONN WSAENOTCONN -#endif -#ifndef ENOTSOCK -#define ENOTSOCK WSAENOTSOCK -#endif -#ifndef EPROTOTYPE -#define EPROTOTYPE WSAEPROTOTYPE -#endif -#ifndef EOPNOTSUPP -#define EOPNOTSUPP WSAEOPNOTSUPP -#endif -#ifndef EPROTONOSUPPORT -#define EPROTONOSUPPORT WSAEPROTONOSUPPORT -#endif -#ifndef EOVERFLOW -#define EOVERFLOW -1 -#endif -#ifndef ECONNRESET -#define ECONNRESET WSAECONNRESET -#endif -#ifndef ELOOP -#define ELOOP WSAELOOP -#endif -#ifndef ENOTBLK -#define ENOTBLK -1 -#endif -#ifndef ETXTBSY -#define ETXTBSY -1 -#endif -#ifndef ENETDOWN -#define ENETDOWN WSAENETDOWN -#endif -#ifndef ESHUTDOWN -#define ESHUTDOWN WSAESHUTDOWN -#endif -#ifndef ECONNABORTED -#define ECONNABORTED WSAECONNABORTED -#endif -#endif /* _WINDOWS */ - -#if defined(macintosh) -/* - * Some Unix error defs. Under CW 7, we can't define OTUNIXERRORS because - * it generates many conflicts with errno.h. Define what we need here. - * These need to be in sync with OpenTransport.h - */ -#define EWOULDBLOCK 35 -#define ENOTSOCK 38 -#define EPROTOTYPE 41 -#define EPROTONOSUPPORT 43 -#define EOPNOTSUPP 45 -#define EADDRINUSE 48 -#define EADDRNOTAVAIL 49 -#define ENETDOWN 50 -#define ECONNABORTED 53 -#define ECONNRESET 54 -#define EISCONN 56 -#define ENOTCONN 57 -#define ESHUTDOWN 58 -#define ETIMEDOUT 60 -#define ECONNREFUSED 61 -#define EHOSTUNREACH 65 -#define EAFNOSUPPORT -1 -#define ELOOP -1 -#define ENOTBLK -1 -#define ENOTSUP -1 -#define EOVERFLOW -1 -#define ETXTBSY -1 -#endif /* macintosh */ - -#ifdef XP_OS2 -#ifdef XP_OS2_EMX -#define SOCBASEERR 0 -#endif -#ifndef ENOTSUP -#define ENOTSUP -1 -#endif -#ifndef EOVERFLOW -#define EOVERFLOW -1 -#endif -#ifndef EDEADLOCK -#define EDEADLOCK -1 -#endif -#ifndef EFAULT -#define EFAULT SOCEFAULT -#endif -#ifndef EPIPE -#define EPIPE SOCEPIPE -#endif -#ifndef EIO -#define EIO (SOCBASEERR+5) -#endif -#ifndef EDEADLK -#define EDEADLK (SOCBASEERR+11) -#endif -#ifndef ENOTBLK -#define ENOTBLK (SOCBASEERR+15) -#endif -#ifndef EBUSY -#define EBUSY (SOCBASEERR+16) -#endif -#ifndef ENOTDIR -#define ENOTDIR (SOCBASEERR+20) -#endif -#ifndef EISDIR -#define EISDIR (SOCBASEERR+21) -#endif -#ifndef ENFILE -#define ENFILE (SOCBASEERR+23) -#endif -#ifndef ETXTBSY -#define ETXTBSY (SOCBASEERR+26) -#endif -#ifndef EFBIG -#define EFBIG (SOCBASEERR+27) -#endif -#ifndef ESPIPE -#define ESPIPE (SOCBASEERR+29) -#endif -#ifndef EROFS -#define EROFS (SOCBASEERR+30) -#endif -#endif - -#ifdef BEOS -#define ENOTSUP -1 -#define ENOTBLK -1 -#define ETXTBSY -1 -#endif - -#if defined(BSDI) || defined(OPENBSD) || defined (NETBSD) -#define ENOTSUP -1 -#endif - -#if defined(OSF1) || defined(BSDI) || defined(VMS) || defined(OPENBSD) -#define EOVERFLOW -1 -#endif - -#if defined(__hpux) || defined(_AIX) || defined(OSF1) || defined(DARWIN) || \ - defined(BEOS) || defined(FREEBSD) || defined(BSDI) || defined(VMS) || \ - defined(OPENBSD) || defined(NETBSD) -#define EDEADLOCK -1 -#endif - -/* XXX: need to verify that the -1 entries are correct (no mapping) */ -static struct prldap_errormap_entry prldap_errormap[] = { - { PR_OUT_OF_MEMORY_ERROR, ENOMEM }, - { PR_BAD_DESCRIPTOR_ERROR, EBADF }, - { PR_WOULD_BLOCK_ERROR, EAGAIN }, - { PR_ACCESS_FAULT_ERROR, EFAULT }, - { PR_INVALID_METHOD_ERROR, EINVAL }, /* XXX: correct mapping ? */ - { PR_ILLEGAL_ACCESS_ERROR, EACCES }, /* XXX: correct mapping ? */ - { PR_UNKNOWN_ERROR, -1 }, - { PR_PENDING_INTERRUPT_ERROR, -1 }, - { PR_NOT_IMPLEMENTED_ERROR, ENOTSUP }, - { PR_IO_ERROR, EIO }, - { PR_IO_TIMEOUT_ERROR, ETIMEDOUT }, /* XXX: correct mapping ? */ - { PR_IO_PENDING_ERROR, -1 }, - { PR_DIRECTORY_OPEN_ERROR, ENOTDIR }, - { PR_INVALID_ARGUMENT_ERROR, EINVAL }, - { PR_ADDRESS_NOT_AVAILABLE_ERROR, EADDRNOTAVAIL }, - { PR_ADDRESS_NOT_SUPPORTED_ERROR, EAFNOSUPPORT }, - { PR_IS_CONNECTED_ERROR, EISCONN }, - { PR_BAD_ADDRESS_ERROR, EFAULT }, /* XXX: correct mapping ? */ - { PR_ADDRESS_IN_USE_ERROR, EADDRINUSE }, - { PR_CONNECT_REFUSED_ERROR, ECONNREFUSED }, - { PR_NETWORK_UNREACHABLE_ERROR, EHOSTUNREACH }, - { PR_CONNECT_TIMEOUT_ERROR, ETIMEDOUT }, - { PR_NOT_CONNECTED_ERROR, ENOTCONN }, - { PR_LOAD_LIBRARY_ERROR, -1 }, - { PR_UNLOAD_LIBRARY_ERROR, -1 }, - { PR_FIND_SYMBOL_ERROR, -1 }, - { PR_INSUFFICIENT_RESOURCES_ERROR, -1 }, - { PR_DIRECTORY_LOOKUP_ERROR, EHOSTUNREACH },/* an approximation */ - { PR_TPD_RANGE_ERROR, -1 }, - { PR_PROC_DESC_TABLE_FULL_ERROR, -1 }, - { PR_SYS_DESC_TABLE_FULL_ERROR, -1 }, - { PR_NOT_SOCKET_ERROR, ENOTSOCK }, - { PR_NOT_TCP_SOCKET_ERROR, EPROTOTYPE }, - { PR_SOCKET_ADDRESS_IS_BOUND_ERROR, -1 }, - { PR_NO_ACCESS_RIGHTS_ERROR, EACCES }, /* XXX: correct mapping ? */ - { PR_OPERATION_NOT_SUPPORTED_ERROR, EOPNOTSUPP }, - { PR_PROTOCOL_NOT_SUPPORTED_ERROR, EPROTONOSUPPORT }, - { PR_REMOTE_FILE_ERROR, -1 }, - { PR_BUFFER_OVERFLOW_ERROR, EOVERFLOW }, - { PR_CONNECT_RESET_ERROR, ECONNRESET }, - { PR_RANGE_ERROR, ERANGE }, - { PR_DEADLOCK_ERROR, EDEADLK }, - { PR_FILE_IS_LOCKED_ERROR, EDEADLOCK }, /* XXX: correct mapping ? */ - { PR_FILE_TOO_BIG_ERROR, EFBIG }, - { PR_NO_DEVICE_SPACE_ERROR, ENOSPC }, - { PR_PIPE_ERROR, EPIPE }, - { PR_NO_SEEK_DEVICE_ERROR, ESPIPE }, - { PR_IS_DIRECTORY_ERROR, EISDIR }, - { PR_LOOP_ERROR, ELOOP }, - { PR_NAME_TOO_LONG_ERROR, ENAMETOOLONG }, - { PR_FILE_NOT_FOUND_ERROR, ENOENT }, - { PR_NOT_DIRECTORY_ERROR, ENOTDIR }, - { PR_READ_ONLY_FILESYSTEM_ERROR, EROFS }, - { PR_DIRECTORY_NOT_EMPTY_ERROR, ENOTEMPTY }, - { PR_FILESYSTEM_MOUNTED_ERROR, EBUSY }, - { PR_NOT_SAME_DEVICE_ERROR, EXDEV }, - { PR_DIRECTORY_CORRUPTED_ERROR, -1 }, - { PR_FILE_EXISTS_ERROR, EEXIST }, - { PR_MAX_DIRECTORY_ENTRIES_ERROR, -1 }, - { PR_INVALID_DEVICE_STATE_ERROR, ENOTBLK }, /* XXX: correct mapping ? */ - { PR_DEVICE_IS_LOCKED_ERROR, -2 }, - { PR_NO_MORE_FILES_ERROR, ENFILE }, - { PR_END_OF_FILE_ERROR, -1 }, - { PR_FILE_SEEK_ERROR, ESPIPE }, /* XXX: correct mapping ? */ - { PR_FILE_IS_BUSY_ERROR, ETXTBSY }, - { PR_OPERATION_ABORTED_ERROR, -1 }, - { PR_IN_PROGRESS_ERROR, -1 }, - { PR_ALREADY_INITIATED_ERROR, -1 }, - { PR_GROUP_EMPTY_ERROR, -1 }, - { PR_INVALID_STATE_ERROR, -1 }, - { PR_NETWORK_DOWN_ERROR, ENETDOWN }, - { PR_SOCKET_SHUTDOWN_ERROR, ESHUTDOWN }, - { PR_CONNECT_ABORTED_ERROR, ECONNABORTED }, - { PR_HOST_UNREACHABLE_ERROR, EHOSTUNREACH }, - { PR_MAX_ERROR, -1 }, -}; - - -int -prldap_prerr2errno( void ) -{ - int oserr, i; - PRInt32 nsprerr; - - nsprerr = PR_GetError(); - - oserr = -1; /* unknown */ - for ( i = 0; prldap_errormap[i].erm_nspr != PR_MAX_ERROR; ++i ) { - if ( prldap_errormap[i].erm_nspr == nsprerr ) { - oserr = prldap_errormap[i].erm_system; - break; - } - } - - return( oserr ); -}
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libssldap
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libssldap/Makefile.in
Deleted
@@ -1,243 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla Communicator client code, released -# March 31, 1998. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998-1999 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -MOD_DEPTH = ../../.. -srcdir = @srcdir@ -topsrcdir = @top_srcdir@ -NSPR_LIBS = @NSPR_LIBS@ -NSPR_CFLAGS = @NSPR_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -NSS_CFLAGS = @NSS_CFLAGS@ - -include $(MOD_DEPTH)/config/autoconf.mk -include $(topsrcdir)/build.mk - -SRCS = clientinit.c \ - ldapsinit.c \ - errormap.c - -REALOBJS = $(SRCS:.c=.$(OBJ_SUFFIX)) - -SSLOBJDEST = $(OBJDIR_NAME) -OBJS = $(addprefix $(SSLOBJDEST)/, $(REALOBJS)) - -DISTHDIR = $(DIST)/public/ldap -HDIR = $(topsrcdir)/ldap/include - -LIBSSLDAP = $(addprefix $(SSLOBJDEST)/, $(LIB_PREFIX)$(SSLDAP_LIBNAME).$(LIB_SUFFIX)) -DLLSSLDAP = $(addprefix $(SSLOBJDEST)/, $(LIB_PREFIX)$(SSLDAP_LIBNAME).$(DLL_SUFFIX)) - -INSTALLDIR = $(DIST)/$(OBJDIR_NAME) - -RELEASE_LIBS = $(DLLSSLDAP) - -include $(topsrcdir)/config/rules.mk - -GARBAGE += $(LIBSSLDAP) $(DLLSSLDAP) - -LOCAL_INCLUDES = -I$(PUBLIC)/nspr -INCLUDES += -I$(DISTHDIR) -I$(HDIR) -I$(INSTALLDIR)/include \ - -I$(DIST)/include \ - $(NSS_CFLAGS) \ - $(NSPR_CFLAGS) - -DEFINES += $(DEFS) - -PLATFORMCFLAGS = -DUSE_WAITPID -DNEEDPROTOS -PLATFORMLIBS = -THREADS = -THREADSLIB = - -# -# shared library symbol export definitions -# -ifeq ($(USE_DLL_EXPORTS_FILE), 1) -ifeq ($(OS_ARCH), WINNT) -GENEXPORTS=cmd /c $(PERL) $(topsrcdir)/ldap/build/genexports.pl -else -GENEXPORTS=$(PERL) $(topsrcdir)/ldap/build/genexports.pl -endif - -# variable definitions for exported symbols -ifeq ($(OS_ARCH), WINNT) - SSLDAP_EXPORT_DEFS= $(srcdir)/../msdos/winsock/nsldapssl32.def -else - SSLDAP_EXPORT_DEFS= $(SSLOBJDEST)/libldap_ssl.exp -endif - -SSLDAP_EXPORT_FLAGS=$(addprefix $(DLLEXPORTS_PREFIX), $(SSLDAP_EXPORT_DEFS)) - -GENEXPARGS=$(BUILD_DEBUG) $(SSLDAPVERS_SUFFIX) $(SSLDAPVERS) -endif # USE_DLL_EXPORTS_FILE - -ifeq ($(OS_ARCH), SunOS) -EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -# NSPR, NSS, etc. other mozilla components do not put their shared libs -# in dist_libdir but rather in $(DIST)/$(RELEASE_OBJDIR_NAME)/lib -EXTRA_LIBS += $(NSPRLINK) -endif - -ifeq ($(OS_ARCH), WINNT) -ifdef NS_USE_GCC -EXTRA_DLL_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -l$(PRLDAP_LIBNAME) \ - $(NSSLINK) $(NSPRLINK) -else -EXTRA_LIBS =wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib \ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \ - rpcrt4.lib uuid.lib winmm.lib -EXTRA_LIBS += $(dist_libdir)/$(LDAP_LIBNAME).lib -EXTRA_LIBS += $(dist_libdir)/$(PRLDAP_LIBNAME).lib -EXTRA_LIBS += $(NSSLINK) -EXTRA_LIBS += $(NSPRLINK) -endif -CUSTOM_LIBS=1 -endif - -ifeq ($(OS_ARCH),OS2) -EXTRA_LIBS = $(OS_LIBS) -EXTRA_LIBS += $(dist_libdir)/$(LDAP_LIBNAME).lib -EXTRA_LIBS += $(dist_libdir)/$(PRLDAP_LIBNAME).lib -EXTRA_LIBS += $(NSSLINK) -EXTRA_LIBS += $(NSPRLINK) -CUSTOM_LIBS=1 -endif - -ifeq ($(OS_ARCH), OSF1) -EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -EXTRA_LIBS += $(NSPRLINK) -EXTRA_LIBS += -lcxx -lpthread -lrt -lmach -lexc -CUSTOM_LIBS=1 -endif - -ifeq ($(OS_ARCH), AIX) -EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -EXTRA_LIBS += $(NSPRLINK) -EXTRA_LIBS += $(NSSLINK) -l $(PRLDAP_LIBNAME) -EXTRA_LIBS += -ldl -brtl -lpthreads -lc_r -lm -CUSTOM_LIBS=1 -endif - -ifeq ($(OS_ARCH), IRIX) -EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -EXTRA_LIBS += $(NSPRLINK) -EXTRA_LIBS += $(NSSLINK) -l $(PRLDAP_LIBNAME) -EXTRA_LIBS += $(OS_LIBS) -lc -CUSTOM_LIBS=1 -endif - -ifeq ($(OS_ARCH), Darwin) -EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -l$(PRLDAP_LIBNAME) -EXTRA_LIBS += $(NSSLINK) -EXTRA_LIBS += $(NSPRLINK) -EXTRA_LIBS += $(OS_LIBS) -CUSTOM_LIBS=1 -endif - -ifeq ($(OS_ARCH), BeOS) -EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -l$(PRLDAP_LIBNAME) -EXTRA_LIBS += $(NSSLINK) -EXTRA_LIBS += $(NSPRLINK) -EXTRA_LIBS += $(OS_LIBS) -CUSTOM_LIBS=1 -endif - -ifeq ($(OS_ARCH), HP-UX) -CUSTOM_LIBS=1 -endif - -ifndef CUSTOM_LIBS -EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -l$(PRLDAP_LIBNAME) -EXTRA_LIBS += $(NSSLINK) -EXTRA_LIBS += $(NSPRLINK) -endif - -OBJDEST = $(OBJDIR_NAME) - -########################################################################### - -ifeq ($(USE_DLL_EXPORTS_FILE), 1) -# recursive gmake rule to create exported symbols file -$(SSLDAP_EXPORT_DEFS):: ../libldap_ssl.ex -ifeq ($(OS_ARCH), WINNT) - $(GENEXPORTS) Win32 $(srcdir)/../msdos/winsock/nsldapssl32.tdf $< $(GENEXPARGS) > $@ -else - $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) > $@ -endif -endif # USE_DLL_EXPORTS_FILE - -versiont.c: Makefile.client Version.c - @$(RM) $@ - @(u="$${USER-root}" v="$(shell cat ../../build/version)" d="$(shell pwd)" \ - h="$(shell hostname)" t="$(shell date)"; $(SED) -e "s|%WHEN%|$${t}|" \ - -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ - -e "s|%VERSION%|$${v}|" \ - < Version.c > $@) - -export:: $(OBJDEST) $(LIBDIR) $(OBJS) $(DLLSSLDAP) - -$(LIBDIR): - $(MKDIR) $(LIBDIR) - -$(LIBSSLDAP): $(OBJS) $(LIBDIR) $(SSLDAP_EXPORT_DEFS) - @echo ======= making $(LIBSSLDAP) - ifdef SO_FILES_TO_REMOVE - -$(RM) $(SO_FILES_TO_REMOVE) - endif - $(LINK_LIB) $(EXTRA_LIBS) - -$(DLLSSLDAP): $(OBJS) $(LIBDIR) $(SSLDAP_EXPORT_DEFS) - @echo ======= making $(DLLSSLDAP) -ifdef SO_FILES_TO_REMOVE - -$(RM) $(SO_FILES_TO_REMOVE) -endif - $(LINK_DLL) $(SSLDAP_EXPORT_FLAGS) $(EXTRA_LIBS) - -veryclean:: clean - -$(OBJDEST): - $(MKDIR) $(OBJDEST) - -export:: $(DLLSSLDAP) -ifeq ($(OS_ARCH), WINNT) - $(INSTALL) -m 555 $(LIBSSLDAP) $(dist_libdir) - $(INSTALL) -m 555 $(DLLSSLDAP) $(dist_libdir) -endif -ifdef MKSHLIB - $(INSTALL) -m 555 $(DLLSSLDAP) $(dist_libdir) - $(INSTALL) -m 444 $(DLLSSLDAP) $(dist_bindir) -endif
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libssldap/ldapsinit.c
Deleted
@@ -1,1550 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Sun Microsystems - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * ldapsinit.c - */ - -#if defined(NET_SSL) - -#if defined( _WINDOWS ) -#include <windows.h> -#endif - -/* XXX:mhein The following is a workaround for the redefinition of */ -/* const problem on OSF. Fix to be provided by NSS */ -/* This is a pretty benign workaround for us which */ -/* should not cause problems in the future even if */ -/* we forget to take it out :-) */ - -#ifdef OSF1V4D -#ifndef __STDC__ -# define __STDC__ -#endif /* __STDC__ */ -#endif /* OSF1V4D */ - -#include <errno.h> -#include <nspr.h> -#include <cert.h> -#include <key.h> -#include <ssl.h> -#include <sslproto.h> -#include <sslerr.h> -#include <prnetdb.h> - -#include <ldap.h> -#include <ldap_ssl.h> -#include <ldappr.h> -#include <pk11func.h> - -/* - * Macro that determines how many SSL options we support. As of June, 2002 - * NSS supports 14 options numbered 1-14 (see nss/ssl.h). We allow some - * room for expansion. - */ -#define LDAPSSL_MAX_SSL_OPTION 20 - -/* - * Data structure to hold the standard NSPR I/O function pointers set by - * libprldap. We save them in our session data structure so we can call - * them from our own I/O functions (we add functionality to support SSL - * while using libprldap's functions as much as possible). - */ -typedef struct ldapssl_std_functions { - LDAP_X_EXTIOF_CLOSE_CALLBACK *lssf_close_fn; - LDAP_X_EXTIOF_CONNECT_CALLBACK *lssf_connect_fn; - LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK *lssf_disposehdl_fn; -} LDAPSSLStdFunctions; - - - -/* - * LDAP session data structure. - */ -typedef struct ldapssl_session_info { - int lssei_using_pcks_fns; - int lssei_ssl_strength; - PRBool lssei_ssl_ready; - PRBool lssei_tls_init; /* indicates startTLS success */ - PRBool lssei_client_auth; - PRBool lssei_ssl_option_value[LDAPSSL_MAX_SSL_OPTION+1]; - PRBool lssei_ssl_option_isset[LDAPSSL_MAX_SSL_OPTION+1]; - char *lssei_certnickname; - char *lssei_keypasswd; /* if NULL, assume pre-auth. */ - LDAPSSLStdFunctions lssei_std_functions; - CERTCertDBHandle *lssei_certdbh; -} LDAPSSLSessionInfo; - - -/* - * LDAP socket data structure. - */ -typedef struct ldapssl_socket_info { - LDAPSSLSessionInfo *soi_sessioninfo; /* session info */ -} LDAPSSLSocketInfo; - - -/* - * XXXceb This is a hack until the new IO functions are done. - * this function MUST be called before ldapssl_enable_clientauth. - * right now, this function is called in ldapssl_pkcs_init(); - */ - -static int using_pkcs_functions = 0; - - -void set_using_pkcs_functions( int val ) -{ - using_pkcs_functions = val; -} - - -/* - * Utility functions: - */ -static int set_ssl_options( PRFileDesc *sslfd, PRBool *optval, - PRBool *optisset ); -static void ldapssl_free_session_info( LDAPSSLSessionInfo **ssipp ); -static void ldapssl_free_socket_info( LDAPSSLSocketInfo **soipp ); -static char *ldapssl_libldap_compat_strdup(const char *s1); - - -/* - * SSL Stuff - */ - -static int ldapssl_AuthCertificate(void *sessionarg, PRFileDesc *fd, - PRBool checkSig, PRBool isServer); - -/* - * client auth stuff - */ -static SECStatus get_clientauth_data( void *sessionarg, PRFileDesc *prfd, - CERTDistNames *caNames, CERTCertificate **pRetCert, - SECKEYPrivateKey **pRetKey ); -static SECStatus get_keyandcert( LDAPSSLSessionInfo *ssip, - CERTCertificate **pRetCert, SECKEYPrivateKey **pRetKey, - char **errmsgp ); -static SECStatus check_clientauth_nicknames_and_passwd( LDAP *ld, - LDAPSSLSessionInfo *ssip ); -static char *get_keypassword( PK11SlotInfo *slot, PRBool retry, - void *sessionarg ); - -/* - * Static variables. - */ -/* SSL strength setting for new LDAPS sessions */ -static int default_ssl_strength = LDAPSSL_AUTH_CERT; - -/* - * Arrays to track global defaults for SSL options. These are used for - * new LDAPS sessions. For each option, we track both the option value - * and a Boolean that indicates whether the value has been set using - * the ldapssl_set_option() call. If an option has not been set, we - * don't make any NSS calls to set it; that way, the default NSS option - * values are used. Similar arrays are included in the LDAPSSLSessionInfo - * structure so options can be set on a per-LDAP session basis as well. - */ -static PRBool default_ssl_option_value[LDAPSSL_MAX_SSL_OPTION+1] = {0}; -static PRBool default_ssl_option_isset[LDAPSSL_MAX_SSL_OPTION+1] = {0}; - - -/* - * Like ldap_init(), except also install I/O routines from libsec so we - * can support SSL. If defsecure is non-zero, SSL is enabled for the - * default connection as well. - */ -LDAP * -LDAP_CALL -ldapssl_init( const char *defhost, int defport, int defsecure ) -{ - LDAP *ld; - - - if (0 ==defport) - defport = LDAPS_PORT; - - if (( ld = ldap_init( defhost, defport )) == NULL ) { - return( NULL ); - } - - if ( ldapssl_install_routines( ld ) < 0 || ldap_set_option( ld, - LDAP_OPT_SSL, defsecure ? LDAP_OPT_ON : LDAP_OPT_OFF ) != 0 ) { - PR_SetError( PR_GetError(), EINVAL ); /* XXXmcs: just a guess! */ - ldap_unbind( ld ); - return( NULL ); - } - - return( ld ); -} - - -static int -ldapssl_close(int s, struct lextiof_socket_private *socketarg) -{ - PRLDAPSocketInfo soi; - LDAPSSLSocketInfo *ssoip; - LDAPSSLSessionInfo *sseip; - - memset( &soi, 0, sizeof(soi)); - soi.soinfo_size = PRLDAP_SOCKETINFO_SIZE; - if ( prldap_get_socket_info( s, socketarg, &soi ) != LDAP_SUCCESS ) { - return( -1 ); - } - - ssoip = (LDAPSSLSocketInfo *)soi.soinfo_appdata; - sseip = ssoip->soi_sessioninfo; - - ldapssl_free_socket_info( (LDAPSSLSocketInfo **)&soi.soinfo_appdata ); - - return( (*(sseip->lssei_std_functions.lssf_close_fn))( s, socketarg )); -} - - -static int -ldapssl_connect(const char *hostlist, int defport, int timeout, - unsigned long options, struct lextiof_session_private *sessionarg, - struct lextiof_socket_private **socketargp ) -{ - int intfd = -1; - PRBool secure; - PRLDAPSessionInfo sei; - PRLDAPSocketInfo soi; - LDAPSSLSocketInfo *ssoip = NULL; - LDAPSSLSessionInfo *sseip; - PRFileDesc *sslfd = NULL; - - /* - * Determine if secure option is set. Also, clear secure bit in options - * the we pass to the standard connect() function (since it doesn't know - * how to handle the secure option). - */ - if ( 0 != ( options & LDAP_X_EXTIOF_OPT_SECURE )) { - secure = PR_TRUE; - options &= ~LDAP_X_EXTIOF_OPT_SECURE; - } else { - secure = PR_FALSE; - } - - /* - * Retrieve session info. so we can store a pointer to our session info. - * in our socket info. later. - */ - memset( &sei, 0, sizeof(sei)); - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - if ( prldap_get_session_info( NULL, sessionarg, &sei ) != LDAP_SUCCESS ) { - return( -1 ); - } - sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; - - /* - * Call the standard connect() callback to make the TCP connection. If it - * succeeds, *socketargp is set. - */ - intfd = (*(sseip->lssei_std_functions.lssf_connect_fn))( hostlist, defport, - timeout, options, sessionarg, socketargp ); - if ( intfd < 0 ) { - return( intfd ); - } - - /* - * Retrieve socket info. so we have the PRFileDesc. - */ - memset( &soi, 0, sizeof(soi)); - soi.soinfo_size = PRLDAP_SOCKETINFO_SIZE; - if ( prldap_get_socket_info( intfd, *socketargp, &soi ) != LDAP_SUCCESS ) { - goto close_socket_and_exit_with_error; - } - - /* - * Allocate a structure to hold our socket-specific data. - */ - if ( NULL == ( ssoip = PR_Calloc( 1, sizeof( LDAPSSLSocketInfo )))) { - goto close_socket_and_exit_with_error; - } - ssoip->soi_sessioninfo = sseip; - - /* - * Add SSL layer and enable SSL. - */ - if (( sslfd = SSL_ImportFD( NULL, soi.soinfo_prfd )) == NULL ) { - goto close_socket_and_exit_with_error; - } - - if ( SSL_OptionSet( sslfd, SSL_SECURITY, secure ) != SECSuccess || - SSL_OptionSet( sslfd, SSL_HANDSHAKE_AS_CLIENT, secure ) - != SECSuccess || ( secure && SSL_ResetHandshake( sslfd, - PR_FALSE ) != SECSuccess )) { - goto close_socket_and_exit_with_error; - } - - /* - * Set hostname which will be retrieved (depending on ssl strength) when - * using client or server auth. - */ - if ( SSL_SetURL( sslfd, hostlist ) != SECSuccess ) { - goto close_socket_and_exit_with_error; - } - - /* - * Set any SSL options that were modified by a previous call to - * the ldapssl_set_option() function. - */ - if ( set_ssl_options( sslfd, sseip->lssei_ssl_option_value, - sseip->lssei_ssl_option_isset ) < 0 ) { - goto close_socket_and_exit_with_error; - } - - /* - * Let the standard NSPR to LDAP layer know about the new socket and - * our own socket-specific data. - */ - soi.soinfo_prfd = sslfd; - soi.soinfo_appdata = (void *)ssoip; - if ( prldap_set_socket_info( intfd, *socketargp, &soi ) != LDAP_SUCCESS ) { - goto close_socket_and_exit_with_error; - } - sslfd = NULL; /* so we don't close the socket twice upon error */ - - /* - * Install certificate hook function. - */ - SSL_AuthCertificateHook( soi.soinfo_prfd, - (SSLAuthCertificate)ldapssl_AuthCertificate, - (void *)sseip ); - - if ( SSL_GetClientAuthDataHook( soi.soinfo_prfd, - get_clientauth_data, sseip->lssei_client_auth ? sseip : NULL ) != 0 ) { - goto close_socket_and_exit_with_error; - } - - return( intfd ); /* success */ - -close_socket_and_exit_with_error: - if ( NULL != sslfd && sslfd != soi.soinfo_prfd ) { - PR_Close( sslfd ); - } - if ( NULL != ssoip ) { - ldapssl_free_socket_info( &ssoip ); - } - if ( intfd >= 0 && NULL != *socketargp ) { - (*(sseip->lssei_std_functions.lssf_close_fn))( intfd, *socketargp ); - } - return( -1 ); -} - - -static void -ldapssl_disposehandle(LDAP *ld, struct lextiof_session_private *sessionarg) -{ - PRLDAPSessionInfo sei; - LDAPSSLSessionInfo *sseip; - LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK *disposehdl_fn; - - memset( &sei, 0, sizeof( sei )); - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - if ( prldap_get_session_info( ld, NULL, &sei ) == LDAP_SUCCESS ) { - sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; - disposehdl_fn = sseip->lssei_std_functions.lssf_disposehdl_fn; - ldapssl_free_session_info( &sseip ); - (*disposehdl_fn)( ld, sessionarg ); - } -} - -static -LDAPSSLSessionInfo * -ldapssl_alloc_sessioninfo() -{ - LDAPSSLSessionInfo *ssip; - - /* - * Allocate our own session information. - */ - if ( NULL == ( ssip = (LDAPSSLSessionInfo *)PR_Calloc( 1, - sizeof( LDAPSSLSessionInfo )))) { - return( NULL ); - } - - /* - * Initialize session info. - * XXX: it would be nice to be able to set these on a per-session basis: - * lssei_using_pcks_fns - * lssei_certdbh - */ - ssip->lssei_ssl_strength = default_ssl_strength; - memcpy( ssip->lssei_ssl_option_value, default_ssl_option_value, - sizeof(ssip->lssei_ssl_option_value)); - memcpy( ssip->lssei_ssl_option_isset, default_ssl_option_isset, - sizeof(ssip->lssei_ssl_option_isset)); - ssip->lssei_using_pcks_fns = using_pkcs_functions; - ssip->lssei_certdbh = CERT_GetDefaultCertDB(); - ssip->lssei_ssl_ready = PR_TRUE; - - return( ssip ); -} - -/* - * Install I/O routines from libsec and NSPR into libldap to allow libldap - * to do SSL. - * - * We rely on libprldap to provide most of the functions, and then we override - * a few of them to support SSL. - */ -int -LDAP_CALL -ldapssl_install_routines( LDAP *ld ) -{ - struct ldap_x_ext_io_fns iofns; - LDAPSSLSessionInfo *ssip; - PRLDAPSessionInfo sei; - - /* install standard NSPR functions */ - if ( prldap_install_routines( - ld, - 1 /* shared -- we have to assume it is */ ) - != LDAP_SUCCESS ) { - return( -1 ); - } - - /* - * Allocate session information. - */ - if ( (ssip = ldapssl_alloc_sessioninfo()) == NULL ) - { - ldap_set_lderrno( ld, LDAP_NO_MEMORY, NULL, NULL ); - return( -1 ); - } - - /* - * override a few functions, saving a pointer to the standard function - * in each case so we can call it from our SSL savvy functions. - */ - memset( &iofns, 0, sizeof(iofns)); - iofns.lextiof_size = LDAP_X_EXTIO_FNS_SIZE; - if ( ldap_get_option( ld, LDAP_X_OPT_EXTIO_FN_PTRS, (void *)&iofns ) < 0 ) { - ldapssl_free_session_info( &ssip ); - return( -1 ); - } - - /* override socket, connect, and disposehandle */ - ssip->lssei_std_functions.lssf_connect_fn = iofns.lextiof_connect; - iofns.lextiof_connect = ldapssl_connect; - ssip->lssei_std_functions.lssf_close_fn = iofns.lextiof_close; - iofns.lextiof_close = ldapssl_close; - ssip->lssei_std_functions.lssf_disposehdl_fn = iofns.lextiof_disposehandle; - iofns.lextiof_disposehandle = ldapssl_disposehandle; - - if ( ldap_set_option( ld, LDAP_X_OPT_EXTIO_FN_PTRS, (void *)&iofns ) < 0 ) { - ldapssl_free_session_info( &ssip ); - return( -1 ); - } - - /* - * Store session info. for later retrieval. - */ - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - sei.seinfo_appdata = (void *)ssip; - if ( prldap_set_session_info( ld, NULL, &sei ) != LDAP_SUCCESS ) { - ldapssl_free_session_info( &ssip ); - return( -1 ); - } - - return( 0 ); -} - -/* Sets up SSL for the NSPR layered connection (or plain Text connection - * with startTLS extended I/O request already acknowledged by the server) - * Call this function after the call to ldaptls_setup() - * - * Returns an LDAP API result code (LDAP_SUCCESS if all goes well). - */ -static int -ldaptls_complete(LDAP *ld) -{ - PRBool secure = 1; - PRLDAPSessionInfo sei; - PRLDAPSocketInfo soi; - LDAPSSLSocketInfo *ssoip = NULL; - LDAPSSLSessionInfo *sseip = NULL; - PRFileDesc *sslfd = NULL; - LBER_SOCKET intfd = -1; - int rc = LDAP_LOCAL_ERROR; - char *hostlist = NULL; - struct lextiof_socket_private *socketargp = NULL; - - /* - * Get hostlist from LDAP Handle - */ - if ( ldap_get_option(ld, LDAP_OPT_HOST_NAME, &hostlist) < 0 ) { - rc = ldap_get_lderrno( ld, NULL, NULL ); - goto close_socket_and_exit_with_error; - } - - /* - * Get File Desc from current connection - */ - if ( ldap_get_option(ld, LDAP_OPT_DESC, &intfd) < 0 ) { - rc = ldap_get_lderrno( ld, NULL, NULL ); - goto close_socket_and_exit_with_error; - } - - - /* - * Get Socket Arg Pointer - */ - if ( ldap_get_option(ld, LDAP_X_OPT_SOCKETARG, &socketargp) < 0 ) { - rc = ldap_get_lderrno( ld, NULL, NULL ); - goto close_socket_and_exit_with_error; - } - - - /* - * Retrieve session info. so we can store a pointer to our session info. - * in our socket info. later. - */ - memset( &sei, 0, sizeof(sei)); - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - if (LDAP_SUCCESS != (rc = prldap_get_session_info(ld, NULL, &sei))) { - goto close_socket_and_exit_with_error; - } - sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; - - /* - * Retrieve socket info. - */ - memset( &soi, 0, sizeof(soi)); - soi.soinfo_size = PRLDAP_SOCKETINFO_SIZE; - if (LDAP_SUCCESS != - (rc = prldap_get_socket_info(intfd, socketargp, &soi))) { - goto close_socket_and_exit_with_error; - } - - /* - * Allocate a structure to hold our socket-specific data. - */ - if ( NULL == ( ssoip = PR_Calloc( 1, sizeof( LDAPSSLSocketInfo )))) { - rc = LDAP_NO_MEMORY; - goto close_socket_and_exit_with_error; - } - ssoip->soi_sessioninfo = sseip; - - /* - * Add SSL layer and enable SSL. - */ - if (( sslfd = SSL_ImportFD( NULL, soi.soinfo_prfd )) == NULL ) { - rc = LDAP_LOCAL_ERROR; - goto close_socket_and_exit_with_error; - } - - if ( SSL_OptionSet( sslfd, SSL_SECURITY, secure ) != SECSuccess || - SSL_OptionSet( sslfd, SSL_ENABLE_TLS, secure ) != SECSuccess || - SSL_OptionSet( sslfd, SSL_HANDSHAKE_AS_CLIENT, secure ) != SECSuccess || - ( secure && SSL_ResetHandshake( sslfd, PR_FALSE ) != SECSuccess ) ) { - rc = LDAP_LOCAL_ERROR; - goto close_socket_and_exit_with_error; - } - - /* - * Set hostname which will be retrieved (depending on ssl strength) when - * using client or server auth. - */ - if ( SSL_SetURL( sslfd, hostlist ) != SECSuccess ) { - rc = LDAP_LOCAL_ERROR; - goto close_socket_and_exit_with_error; - } - ldap_memfree(hostlist); - hostlist = NULL; - - /* - * Set any SSL options that were modified by a previous call to - * the ldapssl_set_option() function. - */ - if ( set_ssl_options( sslfd, sseip->lssei_ssl_option_value, - sseip->lssei_ssl_option_isset ) < 0 ) { - rc = LDAP_LOCAL_ERROR; - goto close_socket_and_exit_with_error; - } - - - /* - * Let the standard NSPR to LDAP layer know about the new socket and - * our own socket-specific data. - */ - soi.soinfo_prfd = sslfd; - soi.soinfo_appdata = (void *)ssoip; - - if ( LDAP_SUCCESS != - (rc = prldap_set_socket_info( intfd, socketargp, &soi ))) { - goto close_socket_and_exit_with_error; - } - sslfd = NULL; /* so we don't close the socket twice upon error */ - - /* - * Install certificate hook function. - */ - SSL_AuthCertificateHook( soi.soinfo_prfd, - (SSLAuthCertificate)ldapssl_AuthCertificate, - (void *)sseip ); - - if ( SSL_GetClientAuthDataHook( soi.soinfo_prfd, - get_clientauth_data, sseip->lssei_client_auth ? sseip : NULL ) != 0 ) { - rc = LDAP_LOCAL_ERROR; - goto close_socket_and_exit_with_error; - } - - return( LDAP_SUCCESS ); /* success */ - - close_socket_and_exit_with_error: - - ldap_memfree(hostlist); - hostlist = NULL; - - if ( NULL != sslfd && sslfd != soi.soinfo_prfd ) { - PR_Close( sslfd ); - } - if ( NULL != ssoip ) { - ldapssl_free_socket_info( &ssoip ); - } - if ( intfd >= 0 && NULL != socketargp && sseip != NULL ) { - (*(sseip->lssei_std_functions.lssf_close_fn))( intfd, - socketargp ); - } - return( rc ); - -} /* ldaptls_complete() */ - - - -/* - * Install I/O routines from libsec and NSPR into libldap to allow libldap - * to do TLS. - * - * We rely on libprldap to provide most of the functions. - * Returns an LDAP API result code (LDAP_SUCCESS if all goes well). - */ -static int -ldaptls_setup( LDAP *ld ) -{ - - int rc = LDAP_LOCAL_ERROR; - LDAPSSLSessionInfo *ssip; - PRLDAPSessionInfo sei; - - /* Check for valid input parameters. */ - if ( ld == NULL ) { - ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return( LDAP_PARAM_ERROR ); - } - - /* Check if NSPR Layer is Installed */ - if ( !prldap_is_installed(ld) ) { - /* No NSPR Layer installed, - * Call prldap_import_connection() that installs the NSPR I/O layer - * and imports connection details from Clear-text connection - */ - if (LDAP_SUCCESS != (rc = prldap_import_connection( ld ))) { - return( rc ); - } - } - - memset( &sei, 0, sizeof(sei)); - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - if ( (rc = prldap_get_session_info( ld, NULL, &sei )) == LDAP_SUCCESS ) { - ssip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; - } else { - return( rc ); - } - - if ( NULL == ssip ) { - if ( (ssip = ldapssl_alloc_sessioninfo()) == NULL ) { - ldap_set_lderrno( ld, LDAP_NO_MEMORY, NULL, NULL ); - return( LDAP_NO_MEMORY ); - } - - /* - * Store session info. for later retrieval. - */ - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - sei.seinfo_appdata = (void *)ssip; - if (LDAP_SUCCESS != (rc = prldap_set_session_info( ld, NULL, &sei ))) { - ldapssl_free_session_info( &ssip ); - return( rc ); - } - } - - ssip->lssei_tls_init= PR_TRUE; - - return( LDAP_SUCCESS ); -} /* ldaptls_setup()*/ - -/* Function; ldap_start_tls_s() - * startTLS request - * Returns an LDAP API result code (LDAP_SUCCESS if all goes well). - * - */ -int -LDAP_CALL -ldap_start_tls_s(LDAP *ld, - LDAPControl **serverctrls, - LDAPControl **clientctrls) -{ - int rc = -1; - int version = LDAP_VERSION3; - - /* Error check on LDAP handle */ - if ( ld == NULL ) { - ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); - return( LDAP_PARAM_ERROR ); - } - - - /* Make sure we are dealing with LDAPv3 */ - if ( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) < 0 ) { - return( ldap_get_lderrno( ld, NULL, NULL )); - } - - /* Issue the Start TLS extended operation */ - rc = ldap_extended_operation_s( ld, LDAP_EXOP_START_TLS, NULL, serverctrls, - clientctrls, NULL, NULL ); - if ( rc != LDAP_SUCCESS ) - { - return( rc ); - } - - /* Initialize TLS and enable SSL on the LDAP session */ - if ( LDAP_SUCCESS == ( rc = ldaptls_setup( ld ) ) && - LDAP_SUCCESS == ( rc = ldaptls_complete( ld ) )) { - if (ldap_set_option( ld, LDAP_OPT_SSL, LDAP_OPT_ON ) < 0 ) { - rc = ldap_get_lderrno( ld, NULL, NULL ); - } - } - - if (LDAP_SUCCESS != rc) { - /* Allow to proceed in clear text if secure session fails */ - ldap_set_option( ld, LDAP_OPT_SSL, LDAP_OPT_OFF ); - } - - return( rc ); -} - - - -/*ARGSUSED*/ -int -LDAP_CALL -ldapssl_enable_clientauth( LDAP *ld, char *keynickname, - char *keypasswd, char *certnickname ) -{ - LDAPSSLSessionInfo *ssip; - PRLDAPSessionInfo sei; - int new_session_allocated = 0; - - /* - * Check parameters - * allow keypasswd to be NULL in case PK11_SetPasswordFunc() - * already set by the user to their own private pin callback. - * there is no proper way to test if PK11_SetPasswordFunc() - * callback is already set apart from NSS private interfaces - */ - if ( certnickname == NULL ) { - ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, - ldapssl_libldap_compat_strdup( - "A non-NULL certnickname is required" )); - return( -1 ); - } - - /* - * Get session info. data structure. - */ - memset( &sei, 0, sizeof(sei)); - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - if ( prldap_get_session_info( ld, NULL, &sei ) == LDAP_SUCCESS ) { - ssip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; - } else { - return( -1 ); - } - - if ( NULL == ssip ) { /* Failed to get ssl session info pointer */ - /* - * Allocate our own session information. - */ - if ( NULL == ( ssip = ldapssl_alloc_sessioninfo())) { - ldap_set_lderrno( ld, LDAP_NO_MEMORY, NULL, NULL ); - return( -1 ); - } - /* - * Store session info. for later retrieval. - */ - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - sei.seinfo_appdata = (void *)ssip; - if ( prldap_set_session_info( ld, NULL, &sei ) != LDAP_SUCCESS ) { - return( -1 ); - } - new_session_allocated = 1; - } - - if ( !(ssip->lssei_ssl_ready) && !new_session_allocated ) { - /* standard SSL setup has not yet done */ - ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, - ldapssl_libldap_compat_strdup( - "An SSL-ready LDAP session handle is required" )); - return( -1 ); - } - - /* - * Update session info. data structure. - */ - ssip->lssei_certnickname = PL_strdup( certnickname ); - if ( keypasswd ) { - ssip->lssei_keypasswd = PL_strdup( keypasswd ); - } else { - /* set lssei_using_pcks_fns to prevent our own PK11_SetPasswordFunc() - * callback being installed in get_keyandcert() if keypasswd is NULL - * workaround for now til NSS comes up with proper check interface - */ - ssip->lssei_using_pcks_fns = 1; - ssip->lssei_keypasswd = NULL; /* assume pre-authenticated */ - } - - if ( NULL == ssip->lssei_certnickname || - ( keypasswd && ( NULL == ssip->lssei_keypasswd ) ) ) { - ldap_set_lderrno( ld, LDAP_NO_MEMORY, NULL, NULL ); - return( -1 ); - } - - if ( check_clientauth_nicknames_and_passwd( ld, ssip ) != SECSuccess ) { - /* LDAP errno is set by check_clientauth_nicknames_and_passwd() */ - return( -1 ); - } - - /* Mark the session as client auth enabled */ - ssip->lssei_client_auth = PR_TRUE; - - return( LDAP_SUCCESS ); -} - - -/* - * Set the SSL strength for an existing SSL-enabled LDAP session handle. - * - * See the description of ldapssl_serverauth_init() above for valid - * sslstrength values. If ld is NULL, the default for new LDAP session - * handles is set. - * - * Returns 0 if all goes well and -1 if an error occurs. - */ -int -LDAP_CALL -ldapssl_set_strength( LDAP *ld, int sslstrength ) -{ - int rc = 0; /* assume success */ - - if ( sslstrength != LDAPSSL_AUTH_WEAK && - sslstrength != LDAPSSL_AUTH_CERT && - sslstrength != LDAPSSL_AUTH_CNCHECK ) { - rc = -1; - } else { - if ( NULL == ld ) { /* set default strength */ - default_ssl_strength = sslstrength; - } else { /* set session-specific strength */ - PRLDAPSessionInfo sei; - LDAPSSLSessionInfo *sseip; - - memset( &sei, 0, sizeof( sei )); - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - if ( prldap_get_session_info( ld, NULL, &sei ) == LDAP_SUCCESS ) { - sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; - sseip->lssei_ssl_strength = sslstrength; - } else { - rc = -1; - } - } - } - - return( rc ); -} - - -/* - * Set SSL options for an existing SSL-enabled LDAP session handle. - * If ld is NULL, the default options used for all future LDAP SSL sessions - * are the ones affected. The option values are specific to the underlying - * SSL provider; see ssl.h within the Network Security Services (NSS) - * distribution for the options supported by NSS (the default SSL provider). - * - * This function should be called before any LDAP connections are created. - * - * Returns: 0 if all goes well. - */ -int -LDAP_CALL -ldapssl_set_option( LDAP *ld, int option, int on ) -{ - int rc = 0; /* assume success */ - - if ( option < 0 || option > LDAPSSL_MAX_SSL_OPTION ) { - ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); - rc = -1; - } else { - if ( NULL == ld ) { - /* set default options for new LDAP sessions */ - default_ssl_option_value[option] = on; - default_ssl_option_isset[option] = PR_TRUE; - } else { - /* set session options */ - PRLDAPSessionInfo sei; - LDAPSSLSessionInfo *sseip; - - memset( &sei, 0, sizeof( sei )); - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - if ( prldap_get_session_info( ld, NULL, &sei ) == LDAP_SUCCESS ) { - sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; - sseip->lssei_ssl_option_value[option] = on; - sseip->lssei_ssl_option_isset[option] = PR_TRUE; - } else { - rc = -1; - } - } - } - - return( rc ); -} - - -/* - * Retrieve SSL options for an existing SSL-enabled LDAP session handle. - * If ld is NULL, the default options to be used for all future LDAP SSL - * sessions are retrieved. The option values are specific to the underlying - * SSL provider; see ssl.h within the Network Security Services (NSS) - * distribution for the options supported by NSS (the default SSL provider). - * - * Returns: 0 if all goes well. - */ -int -LDAP_CALL -ldapssl_get_option( LDAP *ld, int option, int *onp ) -{ - int rc = 0; /* assume success */ - - if ( option < 0 || option > LDAPSSL_MAX_SSL_OPTION || onp == NULL ) { - ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); - rc = -1; - } else { - int rv = 0, set_rv = 0; - - if ( NULL == ld ) { - /* return default options for new LDAP sessions */ - if ( default_ssl_option_isset[option] ) { - rv = default_ssl_option_value[option]; - set_rv = 1; - } - } else { - /* return session options */ - PRLDAPSessionInfo sei; - LDAPSSLSessionInfo *sseip; - - memset( &sei, 0, sizeof( sei )); - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - if ( prldap_get_session_info( ld, NULL, &sei ) - == LDAP_SUCCESS ) { - sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; - if ( sseip->lssei_ssl_option_isset[option] ) { - rv = sseip->lssei_ssl_option_value[option]; - set_rv = 1; - } - } else { - rc = -1; - } - } - - if ( !set_rv ) { - PRBool pron = PR_FALSE; - if ( rc == 0 && SSL_OptionGetDefault( (PRInt32)option, &pron ) - != SECSuccess ) { - rc = -1; - } - rv = pron; - } - - *onp = rv; /* always return a value */ - } - - return( rc ); -} - -#ifdef LDAPSSL_DEBUG -struct optitem { - PRInt32 om_option; - const char *om_string; -} optmap[] = { - { SSL_SECURITY, "SSL_SECURITY" }, - { SSL_SOCKS, "SSL_SOCKS" }, - { SSL_REQUEST_CERTIFICATE, "SSL_REQUEST_CERTIFICATE" }, - { SSL_HANDSHAKE_AS_CLIENT, "SSL_HANDSHAKE_AS_CLIENT" }, - { SSL_HANDSHAKE_AS_SERVER, "SSL_HANDSHAKE_AS_SERVER" }, - { SSL_ENABLE_SSL2, "SSL_ENABLE_SSL2" }, - { SSL_ENABLE_SSL3, "SSL_ENABLE_SSL3" }, - { SSL_NO_CACHE, "SSL_NO_CACHE" }, - { SSL_REQUIRE_CERTIFICATE, "SSL_REQUIRE_CERTIFICATE" }, - { SSL_ENABLE_FDX, "SSL_ENABLE_FDX" }, - { SSL_V2_COMPATIBLE_HELLO, "SSL_V2_COMPATIBLE_HELLO" }, - { SSL_ENABLE_TLS, "SSL_ENABLE_TLS" }, - { SSL_ROLLBACK_DETECTION, "SSL_ROLLBACK_DETECTION" }, - { -1, NULL }, -}; - -static const char * -sslopt2string( PRInt32 option ) -{ - int i; - const char *s = "unknown"; - - for ( i = 0; optmap[i].om_option != -1; ++i ) { - if ( optmap[i].om_option == option ) { - s = optmap[i].om_string; - break; - } - } - - return( s ); -} -#endif /* LDAPSSL_DEBUG */ - -static int -set_ssl_options( PRFileDesc *sslfd, PRBool *optval, PRBool *optisset ) -{ - SECStatus secrc = SECSuccess; - PRInt32 option; - - for ( option = 0; - ( secrc == SECSuccess ) && ( option < LDAPSSL_MAX_SSL_OPTION ); - ++option ) { - if ( optisset[ option ] ) { -#ifdef LDAPSSL_DEBUG - fprintf( stderr, - "set_ssl_options: setting option %d - %s to %d (%s)\n", - option, sslopt2string(option), optval[ option ], - optval[ option ] ? "ON" : "OFF" ); -#endif /* LDAPSSL_DEBUG */ - - secrc = SSL_OptionSet( sslfd, option, optval[ option ] ); - } - } - - if ( secrc == SECSuccess ) { - return( 0 ); - } - - PR_SetError( PR_GetError(), EINVAL ); /* set OS error only */ - return( -1 ); -} - - -static void -ldapssl_free_session_info( LDAPSSLSessionInfo **ssipp ) -{ - if ( NULL != ssipp && NULL != *ssipp ) { - if ( NULL != (*ssipp)->lssei_certnickname ) { - PL_strfree( (*ssipp)->lssei_certnickname ); - (*ssipp)->lssei_certnickname = NULL; - } - if ( NULL != (*ssipp)->lssei_keypasswd ) { - PL_strfree( (*ssipp)->lssei_keypasswd ); - (*ssipp)->lssei_keypasswd = NULL; - } - PR_Free( *ssipp ); - *ssipp = NULL; - } -} - - -static void -ldapssl_free_socket_info( LDAPSSLSocketInfo **soipp ) -{ - if ( NULL != soipp && NULL != *soipp ) { - PR_Free( *soipp ); - *soipp = NULL; - } -} - - -/* this function provides cert authentication. This is called during - * the SSL_Handshake process. Once the cert has been retrieved from - * the server, the it is checked, using VerifyCertNow(), then - * the cn is checked against the host name, set with SSL_SetURL() - */ - -static int -ldapssl_AuthCertificate(void *sessionarg, PRFileDesc *fd, PRBool checkSig, - PRBool isServer) -{ - SECStatus rv = SECFailure; - LDAPSSLSessionInfo *sseip; - CERTCertificate *cert; - SECCertUsage certUsage; - char *hostname = (char *)0; - - if (!sessionarg || !fd) { - return rv; - } - - sseip = (LDAPSSLSessionInfo *)sessionarg; - - if (LDAPSSL_AUTH_WEAK == sseip->lssei_ssl_strength ) { /* no check */ - return SECSuccess; - } - - if ( isServer ) { - certUsage = certUsageSSLClient; - } else { - certUsage = certUsageSSLServer; - } - cert = SSL_PeerCertificate( fd ); - - rv = CERT_VerifyCertNow(sseip->lssei_certdbh, cert, checkSig, - certUsage, NULL); - - if ( rv != SECSuccess || isServer ) { - /* must destroy cert to avoid mem leak */ - CERT_DestroyCertificate(cert); - return rv; - } - - if ( LDAPSSL_AUTH_CNCHECK == sseip->lssei_ssl_strength ) { - /* cert is OK. This is the client side of an SSL connection. - * Now check the name field in the cert against the desired hostname. - * NB: This is our only defense against Man-In-The-Middle (MITM) - * attacks! - */ - - hostname = SSL_RevealURL( fd ); - - if (hostname && hostname[0]) { - rv = CERT_VerifyCertName(cert, hostname); - } else { - rv = SECFailure; - } - if (hostname) { - PL_strfree(hostname); - } - if (rv != SECSuccess) { - PORT_SetError(SSL_ERROR_BAD_CERT_DOMAIN); - } - } - - /* must destroy cert to avoid mem leak */ - CERT_DestroyCertificate(cert); - return((int)rv); -} - - -/* - * called during SSL client auth. when server wants our cert and key. - * returns: SECSuccess if we succeeded and set *pRetCert and *pRetKey, - * SECFailure otherwise. - * if SECFailure is returned SSL will proceed without sending a cert. - */ -/*ARGSUSED*/ -static SECStatus -get_clientauth_data( void *sessionarg, PRFileDesc *prfd, - CERTDistNames *caNames, CERTCertificate **pRetCert, - SECKEYPrivateKey **pRetKey ) - -{ - LDAPSSLSessionInfo *ssip; - - if (( ssip = (LDAPSSLSessionInfo *)sessionarg ) == NULL ) { - return( SECFailure ); /* client auth. not enabled */ - } - - return( get_keyandcert( ssip, pRetCert, pRetKey, NULL )); -} - -static SECStatus -get_keyandcert( LDAPSSLSessionInfo *ssip, - CERTCertificate **pRetCert, SECKEYPrivateKey **pRetKey, - char **errmsgp ) -{ - CERTCertificate *cert; - SECKEYPrivateKey *key; - - if ( !ssip->lssei_using_pcks_fns && (NULL != ssip->lssei_keypasswd) ) { - /* - * XXX: This function should be called only once, and probably - * in one of the ldapssl_.*_init() calls. - */ - PK11_SetPasswordFunc( get_keypassword ); - } - - if (( cert = CERT_FindUserCertByUsage( CERT_GetDefaultCertDB(), - ssip->lssei_certnickname, certUsageSSLClient, - PR_FALSE, (void *)ssip )) == NULL ) { - if ( errmsgp != NULL ) { - *errmsgp = "unable to find certificate"; - } - return( SECFailure ); - } - - if (( key = PK11_FindKeyByAnyCert( cert, (void *)ssip )) == NULL ) { - CERT_DestroyCertificate( cert ); - if ( errmsgp != NULL ) { - *errmsgp = "bad key or key password"; - } - return( SECFailure ); - } - - *pRetCert = cert; - *pRetKey = key; - return( SECSuccess ); -} - - -/* - * This function returns the password to NSS. - * This function is enable through PK11_SetPasswordFunc - * only if pkcs functions are not being used. - */ -/*ARGSUSED*/ -static char * -get_keypassword( PK11SlotInfo *slot, PRBool retry, void *sessionarg ) -{ - LDAPSSLSessionInfo *ssip; - - if ( retry) - return (NULL); - - ssip = (LDAPSSLSessionInfo *)sessionarg; - if ( NULL == ssip || NULL == ssip->lssei_keypasswd ) { - return( NULL ); - } - - return( PL_strdup(ssip->lssei_keypasswd) ); -} - - -/* - * performs some basic checks on clientauth cert and key/password - * - * XXXmcs: could perform additional checks... see servers/slapd/ssl.c - * 1) check expiration - * 2) check that public key in cert matches private key - * see ns/netsite/ldap/servers/slapd/ssl.c:slapd_ssl_init() for example code. - */ -static SECStatus -check_clientauth_nicknames_and_passwd( LDAP *ld, LDAPSSLSessionInfo *ssip ) -{ - char *errmsg = NULL; - CERTCertificate *cert = NULL; - SECKEYPrivateKey *key = NULL; - SECStatus rv; - - rv = get_keyandcert( ssip, &cert, &key, &errmsg ); - - if ( rv != SECSuccess ) { - if ( errmsg != NULL ) { - errmsg = ldapssl_libldap_compat_strdup( errmsg ); - } - ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, errmsg ); - return( rv ); - } - - if ( cert != NULL ) { - CERT_DestroyCertificate( cert ); - } - if ( key != NULL ) { - SECKEY_DestroyPrivateKey( key ); - } - return( SECSuccess ); -} - - -/* - * A strdup() work-alike that uses libldap's memory allocator. - */ -static char * -ldapssl_libldap_compat_strdup(const char *s1) -{ - char *s2; - - if ( NULL == s1 ) { - s2 = NULL; - } else { - size_t len = strlen( s1 ); - - if ( NULL != ( s2 = (char *)ldap_x_malloc( len + 1 ))) { - strcpy( s2, s1 ); - } - } - - return s2; -} - - - -/* there are patches and kludges. this is both. force some linkers to - * link this stuff in - */ -int stubs_o_stuff( void ) -{ - PRExplodedTime exploded; - PLArenaPool pool; - - const char *name ="t"; - PRUint32 size = 0, align = 0; - - PR_ImplodeTime( &exploded ); - PL_InitArenaPool( &pool, name, size, align); - PR_Cleanup(); - PR_fprintf((PRFileDesc*)stderr, "Bad IDEA!!"); - - return 0; - -} - - -/* - * Import the file descriptor corresponding to the socket of an already - * open LDAP connection into SSL, and update the socket and session - * information accordingly. Returns 0 if all goes well. - */ -int -LDAP_CALL -ldapssl_import_fd ( LDAP *ld, int secure ) -{ - PRLDAPSessionInfo sei; - PRLDAPSocketInfo soi; - LDAPSSLSocketInfo *ssoip = NULL; - LDAPSSLSessionInfo *sseip; - PRFileDesc *sslfd = NULL; - LBER_SOCKET intfd = -1; - char *hostlist; - struct lextiof_socket_private *socketargp; - - /* - * Get hostlist from LDAP Handle - */ - if ( ldap_get_option(ld, LDAP_OPT_HOST_NAME, &hostlist) < 0 ) { - return( -1 ); - } - - /* - * Get File Desc from current connection - */ - if ( ldap_get_option(ld, LDAP_OPT_DESC, &intfd) < 0 ) { - return( -1 ); - } - - /* - * Get Socket Arg Pointer - */ - if ( ldap_get_option(ld, LDAP_X_OPT_SOCKETARG, &socketargp) < 0 ) { - return( -1 ); - } - - /* - * Retrieve session info. so we can store a pointer to our session info. - * in our socket info. later. - */ - memset( &sei, 0, sizeof(sei)); - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - if ( prldap_get_session_info( ld, NULL, &sei ) != LDAP_SUCCESS ) { - return( -1 ); - } - sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; - - - /* - * Retrieve socket info. so we have the PRFileDesc. - */ - memset( &soi, 0, sizeof(soi)); - soi.soinfo_size = PRLDAP_SOCKETINFO_SIZE; - if ( prldap_get_socket_info( intfd, socketargp, &soi ) != LDAP_SUCCESS ) { - return( -1 ); - } - - /* - * Allocate a structure to hold our socket-specific data. - */ - if ( NULL == ( ssoip = PR_Calloc( 1, sizeof( LDAPSSLSocketInfo )))) { - goto reset_socket_and_exit_with_error; - } - ssoip->soi_sessioninfo = sseip; - - /* - * Add SSL layer and let the standard NSPR to LDAP layer and enable SSL. - */ - if (( sslfd = SSL_ImportFD( NULL, soi.soinfo_prfd )) == NULL ) { - goto reset_socket_and_exit_with_error; - } - - if ( SSL_OptionSet( sslfd, SSL_SECURITY, secure ) != SECSuccess || - SSL_OptionSet( sslfd, SSL_ENABLE_TLS, secure ) || - SSL_OptionSet( sslfd, SSL_HANDSHAKE_AS_CLIENT, secure ) - != SECSuccess || ( secure && SSL_ResetHandshake( sslfd, - PR_FALSE ) != SECSuccess )) { - goto reset_socket_and_exit_with_error; - } - - /* - * Set hostname which will be retrieved (depending on ssl strength) when - * using client or server auth. - */ - if ( SSL_SetURL( sslfd, hostlist ) != SECSuccess ) { - goto reset_socket_and_exit_with_error; - } - - /* - * Set any SSL options that were modified by a previous call to - * the ldapssl_set_option() function. - */ - if ( set_ssl_options( sslfd, sseip->lssei_ssl_option_value, - sseip->lssei_ssl_option_isset ) < 0 ) { - goto reset_socket_and_exit_with_error; - } - - /* - * Let the standard NSPR to LDAP layer know about the new socket and - * our own socket-specific data. - */ - soi.soinfo_prfd = sslfd; - soi.soinfo_appdata = (void *)ssoip; - if ( prldap_set_default_socket_info( ld, &soi ) != LDAP_SUCCESS ) { - goto reset_socket_and_exit_with_error; - } - - /* - * Install certificate hook function. - */ - if ( SSL_AuthCertificateHook( soi.soinfo_prfd, - (SSLAuthCertificate)ldapssl_AuthCertificate, - (void *)sseip) != 0 ) { - goto reset_socket_and_exit_with_error; - } - - if ( SSL_GetClientAuthDataHook( soi.soinfo_prfd, - get_clientauth_data, sseip->lssei_certnickname ? sseip : NULL ) - != 0 ) { - goto reset_socket_and_exit_with_error; - } - - return 0; - - reset_socket_and_exit_with_error: - if ( NULL != sslfd ) { - /* - * "Unimport" the socket from SSL, i.e. get rid of the upper layer of - * the file descriptor stack, which represents SSL. - */ - soi.soinfo_prfd = sslfd; - sslfd = PR_PopIOLayer( soi.soinfo_prfd, PR_TOP_IO_LAYER ); - sslfd->dtor( sslfd ); - } - if ( NULL != ssoip ) { - ldapssl_free_socket_info( &ssoip ); - soi.soinfo_appdata = NULL; - } - prldap_set_default_socket_info( ld, &soi ); - - return( -1 ); -} - - -/* - * Reset an LDAP session from SSL to a non-secure status. Basically, - * this function undoes the work done by ldapssl_install_routines. - * Returns 0 if all goes well. - */ -int -LDAP_CALL -ldapssl_reset_to_nonsecure ( LDAP *ld ) -{ - PRLDAPSessionInfo sei; - LDAPSSLSessionInfo *sseip; - - struct ldap_x_ext_io_fns iofns; - int rc = 0; - - /* - * Retrieve session info. - */ - memset( &sei, 0, sizeof(sei)); - sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; - if ( prldap_get_session_info( ld, NULL, &sei ) != LDAP_SUCCESS ) { - return( -1 ); - } - sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; - - if ( sseip != NULL ) { - /* - * Reset the standard extended io functions. - */ - memset( &iofns, 0, sizeof(iofns)); - iofns.lextiof_size = LDAP_X_EXTIO_FNS_SIZE; - if ( ldap_get_option( ld, LDAP_X_OPT_EXTIO_FN_PTRS, (void *)&iofns ) - < 0) { - rc = -1; - goto free_session_info; - } - - /* reset socket, connect, and ioctl */ - iofns.lextiof_connect = sseip->lssei_std_functions.lssf_connect_fn; - iofns.lextiof_close = sseip->lssei_std_functions.lssf_close_fn; - iofns.lextiof_disposehandle = - sseip->lssei_std_functions.lssf_disposehdl_fn; - - if ( ldap_set_option( ld, LDAP_X_OPT_EXTIO_FN_PTRS, (void *)&iofns ) - < 0) { - rc = -1; - goto free_session_info; - } - -free_session_info: - ldapssl_free_session_info( &sseip ); - sei.seinfo_appdata = NULL; - if ( prldap_set_session_info( ld, NULL, &sei ) != LDAP_SUCCESS ) { - rc = -1; - } - } /* if ( sseip && *sseip ) */ - - if ( ldap_set_option( ld, LDAP_OPT_SSL, LDAP_OPT_OFF ) < 0 ) { - return (-1); - } - - return rc; -} -#endif /* NET_SSL */
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/libutil
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/macintosh
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/macintosh/tcp-univhdrs
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/msdos
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/msdos/winsock
Deleted
-(directory)
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/libldap.tdf
Deleted
@@ -1,49 +0,0 @@ -; -; ***** BEGIN LICENSE BLOCK ***** -; Version: MPL 1.1/GPL 2.0/LGPL 2.1 -; -; The contents of this file are subject to the Mozilla Public License Version -; 1.1 (the "License"); you may not use this file except in compliance with -; the License. You may obtain a copy of the License at -; http://www.mozilla.org/MPL/ -; -; Software distributed under the License is distributed on an "AS IS" basis, -; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -; for the specific language governing rights and limitations under the -; License. -; -; The Original Code is Mozilla Communicator client code. -; -; The Initial Developer of the Original Code is -; Netscape Communications Corporation. -; Portions created by the Initial Developer are Copyright (C) 1996-1999 -; the Initial Developer. All Rights Reserved. -; -; Contributor(s): -; -; Alternatively, the contents of this file may be used under the terms of -; either of the GNU General Public License Version 2 or later (the "GPL"), -; or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -; in which case the provisions of the GPL or the LGPL are applicable instead -; of those above. If you wish to allow use of your version of this file only -; under the terms of either the GPL or the LGPL, and not to allow others to -; use your version of this file under the terms of the MPL, indicate your -; decision by deleting the provisions above and replace them with the notice -; and other provisions required by the GPL or the LGPL. If you do not delete -; the provisions above, a recipient may use your version of this file under -; the terms of any one of the MPL, the GPL or the LGPL. -; -; ***** END LICENSE BLOCK ***** - -LIBRARY NSLDAP -DESCRIPTION 'Lightweight Directory Access Protocol Client API for 16-bit Windows' -EXETYPE WINDOWS -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE SINGLE - -HEAPSIZE 4096 - -EXPORTS -; we need to manually assign ordinal numbers so we can add new routines -; and not disturb the ordinals and thus not require callers to relink. -$EXPORTS
View file
mozldap-6.0.5.tar.gz/mozilla/directory/c-sdk/mozldap.spec
Deleted
@@ -1,237 +0,0 @@ -%define nspr_name nspr -%define nspr_version 4.6 -%define nss_name nss -%define nss_version 3.11 -%define svrcore_name svrcore -%define svrcore_version 4.0.3 - -%define major 6 -%define minor 0 -%define submin 4 -%define libsuffix %{major}0 - -Summary: Mozilla LDAP C SDK -Name: mozldap -Version: %{major}.%{minor}.%{submin} -Release: 1%{?dist} -License: MPL/GPL/LGPL -URL: http://www.mozilla.org/directory/csdk.html -Group: System Environment/Libraries -Requires: %{nspr_name} >= %{nspr_version} -Requires: %{nss_name} >= %{nss_version} -Requires: %{svrcore_name} >= %{svrcore_version} -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: %{nspr_name}-devel >= %{nspr_version} -BuildRequires: %{nss_name}-devel >= %{nss_version} -BuildRequires: %{svrcore_name}-devel >= %{svrcore_version} -BuildRequires: gcc-c++ -BuildRequires: cyrus-sasl-devel - -Source0: ftp://ftp.mozilla.org/pub/mozilla.org/directory/c-sdk/releases/v%{version}/src/%{name}-%{version}.tar.gz - -%description -The Mozilla LDAP C SDK is a set of libraries that -allow applications to communicate with LDAP directory -servers. These libraries are derived from the University -of Michigan and Netscape LDAP libraries. They use Mozilla -NSPR and NSS for crypto. - - -%package tools -Summary: Tools for the Mozilla LDAP C SDK -Group: System Environment/Base -Requires: %{name} = %{version}-%{release} -BuildRequires: %{nspr_name}-devel >= %{nspr_version} -BuildRequires: %{nss_name}-devel >= %{nss_version} -BuildRequires: %{svrcore_name}-devel >= %{svrcore_version} - -%description tools -The mozldap-tools package provides the ldapsearch, -ldapmodify, and ldapdelete tools that use the -Mozilla LDAP C SDK libraries. - - -%package devel -Summary: Development libraries and examples for Mozilla LDAP C SDK -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} -Requires: %{nspr_name}-devel >= %{nspr_version} -Requires: %{nss_name}-devel >= %{nss_version} -Requires: %{svrcore_name}-devel >= %{svrcore_version} -Requires: pkgconfig - -%description devel -Header and Library files for doing development with the Mozilla LDAP C SDK - -%prep -%setup -q - -%build -cd mozilla/directory/c-sdk - -%configure \ -%ifarch x86_64 ppc64 ia64 s390x - --enable-64bit \ -%endif - --with-sasl \ - --enable-clu \ - --with-system-svrcore \ - --enable-optimize \ - --disable-debug - -# Enable compiler optimizations and disable debugging code -BUILD_OPT=1 -export BUILD_OPT - -# Generate symbolic info for debuggers -XCFLAGS="$RPM_OPT_FLAGS" -export XCFLAGS - -PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 -PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 - -export PKG_CONFIG_ALLOW_SYSTEM_LIBS -export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS - -make \ -%ifarch x86_64 ppc64 ia64 s390x - USE_64=1 -%endif - -%install -%{__rm} -rf $RPM_BUILD_ROOT - -# Set up our package file -%{__mkdir_p} $RPM_BUILD_ROOT%{_libdir}/pkgconfig -%{__cat} mozilla/directory/c-sdk/mozldap.pc.in \ - | sed -e "s,%%libdir%%,%{_libdir},g" \ - -e "s,%%prefix%%,%{_prefix},g" \ - -e "s,%%major%%,%{major},g" \ - -e "s,%%minor%%,%{minor},g" \ - -e "s,%%submin%%,%{submin},g" \ - -e "s,%%libsuffix%%,%{libsuffix},g" \ - -e "s,%%bindir%%,%{_libdir}/%{name},g" \ - -e "s,%%exec_prefix%%,%{_prefix},g" \ - -e "s,%%includedir%%,%{_includedir}/%{name},g" \ - -e "s,%%NSPR_VERSION%%,%{nspr_version},g" \ - -e "s,%%NSS_VERSION%%,%{nss_version},g" \ - -e "s,%%SVRCORE_VERSION%%,%{svrcore_version},g" \ - -e "s,%%MOZLDAP_VERSION%%,%{version},g" \ - > $RPM_BUILD_ROOT%{_libdir}/pkgconfig/%{name}.pc - -# There is no make install target so we'll do it ourselves. - -%{__mkdir_p} $RPM_BUILD_ROOT%{_includedir}/%{name} -%{__mkdir_p} $RPM_BUILD_ROOT%{_libdir}/%{name} - -# Copy the binary libraries we want -for file in libssldap%{libsuffix}.so libprldap%{libsuffix}.so libldap%{libsuffix}.so libldif%{libsuffix}.so -do - %{__install} -m 755 mozilla/dist/lib/$file $RPM_BUILD_ROOT%{_libdir} -done - -# Copy the binaries we want -for file in ldapsearch ldapmodify ldapdelete ldapcmp ldapcompare ldappasswd -do - %{__install} -m 755 mozilla/dist/bin/$file $RPM_BUILD_ROOT%{_libdir}/%{name} -done - -# Copy the include files -for file in mozilla/dist/public/ldap/*.h -do - %{__install} -p -m 644 $file $RPM_BUILD_ROOT%{_includedir}/%{name} -done - -# Copy the developer files -%{__mkdir_p} $RPM_BUILD_ROOT%{_datadir}/%{name} -cp -r mozilla/directory/c-sdk/ldap/examples $RPM_BUILD_ROOT%{_datadir}/%{name} -%{__mkdir_p} $RPM_BUILD_ROOT%{_datadir}/%{name}/etc -%{__install} -m 644 mozilla/directory/c-sdk/ldap/examples/xmplflt.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc -%{__install} -m 644 mozilla/directory/c-sdk/ldap/libraries/libldap/ldaptemplates.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc -%{__install} -m 644 mozilla/directory/c-sdk/ldap/libraries/libldap/ldapfilter.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc -%{__install} -m 644 mozilla/directory/c-sdk/ldap/libraries/libldap/ldapsearchprefs.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc - -%clean -%{__rm} -rf $RPM_BUILD_ROOT - - -%post -p /sbin/ldconfig - - -%postun -p /sbin/ldconfig - - -%files -%defattr(-,root,root,-) -%doc mozilla/directory/c-sdk/README.rpm -%{_libdir}/libssldap*.so -%{_libdir}/libprldap*.so -%{_libdir}/libldap*.so -%{_libdir}/libldif*.so - -%files tools -%defattr(-,root,root,-) -%dir %{_libdir}/%{name} -%{_libdir}/%{name}/ldapsearch -%{_libdir}/%{name}/ldapmodify -%{_libdir}/%{name}/ldapdelete -%{_libdir}/%{name}/ldapcmp -%{_libdir}/%{name}/ldapcompare -%{_libdir}/%{name}/ldappasswd - -%files devel -%defattr(-,root,root,-) -%{_libdir}/pkgconfig/%{name}.pc -%{_includedir}/%{name} -%{_datadir}/%{name} - -%changelog -* Wed Jun 20 2007 Rich Megginson <rmeggins@redhat.com> - 6.0.4-1 -- bump version to 6.0.4 - this version has some memory leak -- fixes for SASL related code, fixes for control handling with -- referral chasing, and packaging improvements -- use -p when installing include files to preserve timestamps - -* Thu May 24 2007 Rich Megginson <rmeggins@redhat.com> - 6.0.3-3 -- We only need cyrus-sasl-devel as a BuildRequires in the main package - -* Mon May 21 2007 Rich Megginson <rmeggins@redhat.com> - 6.0.3-2 -- added cyrus-sasl-devel and pkgconfig to devel package Requires - -* Tue Mar 13 2007 Rich Megginson <richm@stanfordalumni.org> - 6.0.3-1 -- bumped version to 6.0.3 -- minor build fixes for some platforms - -* Mon Jan 15 2007 Rich Megginson <richm@stanfordalumni.org> - 6.0.2-1 -- Fixed exports file generation for Solaris and Windows - no effect on linux -- bumped version to 6.0.2 - -* Mon Jan 9 2007 Rich Megginson <richm@stanfordalumni.org> - 6.0.1-2 -- Remove buildroot = "/" checking -- Remove buildroot removal from %%build section - -* Mon Jan 8 2007 Rich Megginson <richm@stanfordalumni.org> - 6.0.1-1 -- bump version to 6.0.1 -- added libldif and ldif.h - -* Fri Dec 8 2006 Axel Thimm <Axel.Thimm@ATrpms.net> - 6.0.0-2 -- Rename to mozldap. -- move configure step to %%build section. -- clean up excessive use of %%defines, make more Fedora like. -- fix mismatching soname issue. -- generic specfile cosmetics. - -* Thu Oct 5 2006 Rich Megginson <richm@stanforalumni.org> - 6.0.0-1 -- Bump version to 6.0.0 - add support for submit/patch level (3rd level) in version numbering - -* Tue Apr 18 2006 Richard Megginson <richm@stanforalumni.org> - 5.17-3 -- make more Fedora Core friendly - move each requires and buildrequires to a separate line -- remove --with-nss since svrcore implies it; fix some macro errors; macro-ize nspr and nss names -- fix directory attrs in devel package - -* Tue Jan 31 2006 Rich Megginson <rmeggins@redhat.com> - 5.17-2 -- use --with-system-svrcore to configure - -* Mon Dec 19 2005 Rich Megginson <rmeggins@redhat.com> - 5.17-1 -- Initial revision -
View file
mozldap-6.0.7.tar.gz/c-sdk/Makefile.in
Added
@@ -0,0 +1,62 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 2002 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +MOD_DEPTH = . +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ + +include $(MOD_DEPTH)/config/autoconf.mk + +DIRS = config ldap + +DIST_GARBAGE = config.cache config.log config.status + +include $(topsrcdir)/config/rules.mk + +# dummy target to allow platforms without a compiler-based depend (like GCC +# has) to call "make depend" here and not fail, at the cost of actual +# dependencies on such builds possibly being incorrect. A nasty hack, but +# this build system is going away soon. +# +depend: + +FORCE: + +distclean:: + rm -f $(DIST_GARBAGE) + rm -f config/autoconf.mk + rm -f `cat unallmakefiles` unallmakefiles
View file
mozldap-6.0.7.tar.gz/c-sdk/README.configure
Changed
(renamed from mozilla/directory/c-sdk/README.configure)
View file
mozldap-6.0.7.tar.gz/c-sdk/README.rpm
Changed
(renamed from mozilla/directory/c-sdk/README.rpm)
View file
mozldap-6.0.7.tar.gz/c-sdk/aclocal.m4
Changed
(renamed from mozilla/directory/c-sdk/aclocal.m4)
View file
mozldap-6.0.7.tar.gz/c-sdk/build.mk
Added
@@ -0,0 +1,572 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is Mozilla Communicator client code, released +# March 31, 1998. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-1999 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +# some vendors may wish to override COMPVERSIONDIR from the command-line +# +ifdef USE_AUTOCONF +COMPVERSIONDIR = $(topsrcdir) +else +COMPVERSIONDIR = $(DEPTH)/directory/c-sdk +endif + +DEFAULT_VENDOR_NAME=mozilla.org +DEFAULT_VENDOR_VERSION=607 + +ifndef VENDOR_NAME +VENDOR_NAME = $(DEFAULT_VENDOR_NAME) +endif + +ifndef VENDOR_VERSION +VENDOR_VERSION = $(DEFAULT_VENDOR_VERSION) +endif + +ifeq ($(OS_ARCH), WINNT) + COMPONENT_PULL_METHOD=FTP + win_srcdir:=$(subst $(topsrcdir),$(WIN_TOP_SRC),$(srcdir)) +endif + +# component tags for internal build only +include $(COMPVERSIONDIR)/component_versions.mk + +# Ldap library +ifeq ($(OS_ARCH), WINNT) +LDAP_LIBNAME = nsldap32v$(LDAPVERS) +else +LDAP_LIBNAME = ldap$(LDAPVERS) +endif +DIR_VERSION = $(LDAPVERS_SUFFIX) +DIRSDK_VERSION = $(LDAPVERS_SUFFIX) + +# PrLdap library +ifeq ($(OS_ARCH), WINNT) +PRLDAP_LIBNAME = nsldappr32v$(PRLDAPVERS) +else +PRLDAP_LIBNAME = prldap$(PRLDAPVERS) +endif + +# lber library +ifeq ($(OS_ARCH), WINNT) +LBER_LIBNAME = nslber32v$(LBERVERS) +else +LBER_LIBNAME = lber$(LBERVERS) +endif + +# ldif library +ifeq ($(OS_ARCH), WINNT) +LDIF_LIBNAME = nsldif32v$(LDIFVERS) +else +LDIF_LIBNAME = ldif$(LDIFVERS) +endif + +# iutil library +ifeq ($(OS_ARCH), WINNT) +IUTIL_LIBNAME = nsiutil32v$(IUTILVERS) +else +IUTIL_LIBNAME = iutil$(IUTILVERS) +endif + +# util library +ifeq ($(OS_ARCH), WINNT) +UTIL_LIBNAME = nsutil32v$(UTILVERS) +else +UTIL_LIBNAME = util$(UTILVERS) +endif + +# ssl library +ifeq ($(OS_ARCH), WINNT) +SSLDAP_LIBNAME = nsldapssl32v$(SSLDAPVERS) +else +SSLDAP_LIBNAME = ssldap$(SSLDAPVERS) +endif + +# nss library +NSS_LIBNAME = nss$(NSSVERS) +ifeq ($(NSS_DYNAMIC_SOFTOKN),1) +SOFTOKN_LIBNAME = softokn$(NSSVERS) +endif +SSL_LIBNAME = ssl$(NSSVERS) + +ifeq ($(OS_ARCH), WINNT) +DYNAMICNSS = $(addsuffix .$(LIB_SUFFIX),$(SSL_LIBNAME) $(NSS_LIBNAME)) +else +DYNAMICNSS = $(addprefix -l,$(SSL_LIBNAME) $(NSS_LIBNAME) $(SOFTOKN_LIBNAME)) +endif +NSSLINK = $(NSS_LIBS) $(DYNAMICNSS) + +HYBRID_LIBNAME = freebl_hybrid_$(NSSVERS) +PURE32_LIBNAME = freebl_pure32_$(NSSVERS) + +ifneq ($(USE_64), 1) +ifeq ($(OS_ARCH), SunOS) +ifneq ($(OS_TEST),i86pc) +COPYFREEBL = 1 +endif +endif +ifeq ($(OS_ARCH), HP-UX) +ifneq ($(OS_TEST),ia64) +COPYFREEBL = 1 +endif +endif +endif + +# svrcore library +SVRCOREVERS = +SVRCOREVERS_SUFFIX = +SVRCORE_LIBNAME = svrcore$(SVRCOREVERS) +ifeq ($(OS_ARCH), WINNT) +SVRCORE_LINK = $(SVRCORE_LIBS) $(SVRCORE_LIBNAME).$(LIB_SUFFIX) +else +SVRCORE_LINK = $(SVRCORE_LIBS) -l$(SVRCORE_LIBNAME) +endif + +# sasl library +ifdef SASL_LIBS +SASL_LINK = $(SASL_LIBS) +endif + +# +# NSPR library +# + +PLCBASE=plc$(NSPR_LIBVERSION) +PLDSBASE=plds$(NSPR_LIBVERSION) +NSPRBASE=nspr$(NSPR_LIBVERSION) + +ifeq ($(OS_ARCH), WINNT) +PLC_BASENAME=lib$(PLCBASE) +PLDS_BASENAME=lib$(PLDSBASE) +NSPR_BASENAME=lib$(NSPRBASE) +DYNAMICNSPR = $(PLC_BASENAME).$(LIB_SUFFIX) $(PLDS_BASENAME).$(LIB_SUFFIX) $(NSPR_BASENAME).$(LIB_SUFFIX) +else +PLC_BASENAME=$(PLCBASE) +PLDS_BASENAME=$(PLDSBASE) +NSPR_BASENAME=$(NSPRBASE) +DYNAMICNSPR = -l$(PLCBASE) -l$(PLDSBASE) -l$(NSPRBASE) +endif + +# use the NSPRLINK macro in other makefiles to define the linker command line +# the mozilla client build likes to set the makefile macro directly +ifdef LIBS_ALREADY_SET +NSPRLINK = $(NSPR_LIBS) +else +NSPRLINK = $(NSPR_LIBS) $(DYNAMICNSPR) +endif + +# why the redundant definitions? apparently, all of these basename/libname macros are so that +# the ldapsdk can create a package containing all of the nspr shared libs/dlls - I don't think +# we should do this anymore, we should just depend on the user installing nspr first - then we +# can get rid of all of this junk +PLC_LIBNAME=$(PLCBASE) +PLDS_LIBNAME=$(PLDSBASE) +NSPR_LIBNAME=$(NSPRBASE) + +RM = rm -f +SED = sed + +# uncomment to enable support for LDAP referrals +LDAP_REFERRALS = -DLDAP_REFERRALS +DEFNETSSL = -DNET_SSL +NOLIBLCACHE = -DNO_LIBLCACHE +NSDOMESTIC = -DNS_DOMESTIC + + +ifdef BUILD_OPT +LDAP_DEBUG = +else +LDAP_DEBUG = -DLDAP_DEBUG +endif + + +ifdef BUILD_CLU +BUILDCLU = 1 +else +BUILDCLU = +endif + +# +# DEFS are included in CFLAGS +# +DEFS = $(PLATFORMCFLAGS) $(LDAP_DEBUG) \ + $(CLDAP) $(DEFNETSSL) $(NOLIBLCACHE) \ + $(LDAP_REFERRALS) $(LDAP_DNS) $(STR_TRANSLATION) \ + $(LIBLDAP_CHARSETS) $(LIBLDAP_DEF_CHARSET) \ + $(NSDOMESTIC) $(LDAPSSLIO) + + +ifeq ($(OS_ARCH), WINNT) +DIRVER_PROG=$(COMMON_OBJDIR)/dirver.exe +else +DIRVER_PROG=$(COMMON_OBJDIR)/dirver +endif + +ifeq ($(OS_ARCH), WINNT) +EXE_SUFFIX=.exe +RSC=rc +ifdef NS_USE_GCC +OFFLAG=-o # +else +OFFLAG=/Fo +MT = mt.exe +endif +else +OFFLAG=-o +endif + +ifeq ($(OS_ARCH), Linux) +DEFS += -DLINUX2_0 -DLINUX1_2 -DLINUX2_1 +endif + +ifeq ($(OS_ARCH), WINNT) +ifndef NS_USE_GCC +DLLEXPORTS_PREFIX=-DEF: +USE_DLL_EXPORTS_FILE = 1 +endif +endif + +ifeq ($(OS_ARCH), OS2) +USE_DLL_EXPORTS_FILE = 1 +endif + +ifeq ($(OS_ARCH), SunOS) +ifndef NS_USE_GCC +DLLEXPORTS_PREFIX=-Blocal -M +USE_DLL_EXPORTS_FILE = 1 +# else +# use the --version-script GNU ld argument - need to add support for +# GNU (linux and solaris and ???) to genexports.pl et. al. +endif # NS_USE_GCC +endif + +ifeq ($(OS_ARCH), IRIX) +DLLEXPORTS_PREFIX=-exports_file +USE_DLL_EXPORTS_FILE = 1 +endif + +ifeq ($(OS_ARCH), HP-UX) +DEFS += -Dhpux -D_REENTRANT +endif + +ifeq ($(OS_ARCH),AIX) +DLLEXPORTS_PREFIX=-bE: +DL=-ldl +USE_DLL_EXPORTS_FILE = 1 +endif + +ifeq ($(OS_ARCH),OSF1) +DEFS += -DOSF1V4 +DL= +endif + +ifeq ($(OS_ARCH),ReliantUNIX) +DL=-ldl +ifdef RPATHFLAG +USE_LD_RUN_PATH=1 +endif +USE_CCC_TO_LINK=1 +CCC=$(CXX) +endif + +ifeq ($(OS_ARCH),UnixWare) +DL= +endif + +ifeq ($(OS_ARCH), SunOS) + +# flag to pass to cc when linking to set runtime shared library search path +# this is used like this, for example: $(RPATHFLAG_PREFIX)../.. +# Also, use the C++ compiler to link for 64-bit builds. +ifeq ($(USE_64), 1) +USE_CCC_TO_LINK=1 +ifdef RPATHFLAG +RPATHFLAG_PREFIX=-R: +endif +else +ifdef RPATHFLAG +RPATHFLAG_PREFIX=-Wl,-R, +endif +endif + +ifdef NS_USE_GCC +USE_CCC_TO_LINK=1 +ifdef RPATHFLAG +RPATHFLAG_PREFIX=-Wl,-R, +endif +endif + +# flag to pass to ld when linking to set runtime shared library search path +# this is used like this, for example: $(LDRPATHFLAG_PREFIX)../.. +ifdef RPATHFLAG +LDRPATHFLAG_PREFIX=-R +endif + +# OS network libraries +PLATFORMLIBS+=-lresolv -lsocket -lnsl -lgen -ldl -lposix4 +endif + +ifeq ($(OS_ARCH), OSF1) +# Use the C++ compiler to link +USE_CCC_TO_LINK=1 + +# flag to pass to cc when linking to set runtime shared library search path +# this is used like this, for example: $(RPATHFLAG_PREFIX)../.. +ifdef RPATHFLAG +RPATHFLAG_PREFIX=-Wl,-rpath, + +# flag to pass to ld when linking to set runtime shared library search path +# this is used like this, for example: $(LDRPATHFLAG_PREFIX)../.. +LDRPATHFLAG_PREFIX=-rpath +endif + +# allow for unresolved symbols +DLL_LDFLAGS += -expect_unresolved "*" +endif # OSF1 + +ifeq ($(OS_ARCH), AIX) +# Flags to set runtime shared library search path. For example: +# $(CC) $(RPATHFLAG_PREFIX)../..$(RPATHFLAG_EXTRAS) +ifdef RPATHFLAG +RPATHFLAG_PREFIX=-blibpath: +RPATHFLAG_EXTRAS=:/usr/lib:/lib + +# flag to pass to ld when linking to set runtime shared library search path +# this is used like this, for example: $(LDRPATHFLAG_PREFIX)../.. +LDRPATHFLAG_PREFIX=-blibpath:/usr/lib:/lib: +endif + +DLL_LDFLAGS= -bM:SRE -bnoentry \ + -L.:/usr/lib/threads:/usr/lpp/xlC/lib:/usr/lib:/lib +DLL_EXTRA_LIBS= -bI:/usr/lib/lowsys.exp -lC_r -lC -lpthreads -lc_r -lm \ + /usr/lib/libc.a + +EXE_EXTRA_LIBS= -bI:/usr/lib/syscalls.exp -lsvld -lpthreads +endif # AIX + +ifeq ($(OS_ARCH), HP-UX) +# Use the C++ compiler to link +USE_CCC_TO_LINK=1 + +ifdef RPATHFLAG +# flag to pass to cc when linking to set runtime shared library search path +# this is used like this, for example: $(RPATHFLAG_PREFIX)../.. +RPATHFLAG_PREFIX=-Wl,+s,+b, + +# flag to pass to ld when linking to set runtime shared library search path +# this is used like this, for example: $(LDRPATHFLAG_PREFIX)../.. +LDRPATHFLAG_PREFIX=+s +b +endif + +# we need to link in the rt library to get sem_*() +PLATFORMLIBS += -lrt +PLATFORMCFLAGS= + +endif # HP-UX + +ifeq ($(OS_ARCH), Linux) +# Use the C++ compiler to link +USE_CCC_TO_LINK=1 + +# flag to pass to cc when linking to set runtime shared library search path +# this is used like this, for example: $(RPATHFLAG_PREFIX)../.. +ifdef RPATHFLAG +RPATHFLAG_PREFIX=-Wl,-rpath, + +# flag to pass to ld when linking to set runtime shared library search path +# this is used like this, for example: $(LDRPATHFLAG_PREFIX)../.. +# note, there is a trailing space +LDRPATHFLAG_PREFIX=-rpath +endif # RPATHFLAG +endif # Linux + +ifeq ($(OS_ARCH), Darwin) +# Darwin doesn't use RPATH. +#ifdef RPATHFLAG +RPATHFLAG_PREFIX= +#endif + +# Use the C++ compiler to link +USE_CCC_TO_LINK=1 +endif # Darwin + +# Use the C++ compiler to link... or not. +ifdef USE_CCC_TO_LINK +CC_FOR_LINK=$(CCC) +else +CC_FOR_LINK=$(CC) +endif + + +# +# XXX: does anyone know of a better way to solve the "LINK_LIB2" problem? -mcs +# +# Link to produce a console/windows exe on Windows +# + +ifeq ($(OS_ARCH), WINNT) + +ifdef NS_USE_GCC +LINK_EXE = $(CC_FOR_LINK) -o $@ $(LDFLAGS) $(LCFLAGS) $(DEPLIBS) \ + $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) +LINK_LIB = $(AR) cr $@ $(OBJS) +LINK_DLL = $(CC_FOR_LINK) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(@:.$(DLL_SUFFIX)=.$(LIB_SUFFIX)) $(LLFLAGS) $(DLL_LDFLAGS) -o $@ $(OBJS) $(EXTRA_LIBS) $(EXTRA_DLL_LIBS) +else +SUBSYSTEM=CONSOLE + +LINK_EXE = $(CYGWIN_WRAPPER) link $(DLLFLAGS) -OUT:"$@" -MAP $(ALDFLAGS) $(LDFLAGS) $(ML_DEBUG) \ + $(LCFLAGS) -NOLOGO $(DEBUG_FLAGS) -INCREMENTAL:NO \ + -NODEFAULTLIB:MSVCRTD -SUBSYSTEM:$(SUBSYSTEM) $(DEPLIBS) \ + $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) msvcrt.lib + +ifdef MT +LINK_EXE += ; if test -f $@.manifest ; then \ +$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \ +rm -f $@.manifest ; fi +endif # MSVC with manifest tool - from NSS rules.mk + +# AR is set when doing an autoconf build +ifdef AR +LINK_LIB = $(CYGWIN_WRAPPER) $(AR) $(OBJS) +else +LINK_LIB = $(CYGWIN_WRAPPER) lib -OUT:"$@" $(OBJS) +endif + +ifndef LD +LD=link +endif + +LINK_DLL = $(CYGWIN_WRAPPER) $(LD) $(DLLFLAGS) -MAP $(OS_DLLFLAGS) \ + $(ML_DEBUG) -SUBSYSTEM:$(SUBSYSTEM) $(LLFLAGS) $(DLL_LDFLAGS) \ + $(EXTRA_LIBS) -out:"$@" $(OBJS) +endif # NS_USE_GCC +else # WINNT +# +# UNIX link commands +# +ifeq ($(OS_ARCH),OS2) +LINK_LIB = -$(RM) $@ && $(AR) $(AR_FLAGS) $(OBJS) && $(RANLIB) $@ +LINK_LIB2 = -$(RM) $@ && $(AR) $@ $(OBJS2) && $(RANLIB) $@ +LINK_DLL = $(LD) $(DSO_LDOPTS) $(ALDFLAGS) $(DLL_LDFLAGS) $(DLL_EXPORT_FLAGS) \ + -o $@ $(OBJS) + +else + +LINK_LIB = $(RM) $@; $(AR) $(AR_FLAGS) $(OBJS); $(RANLIB) $@ +LINK_LIB2 = $(RM) $@; $(AR) $@ $(OBJS2); $(RANLIB) $@ +ifneq ($(LD),$(CC)) +ifdef SONAMEFLAG_PREFIX +LINK_DLL = $(LD) $(DSO_LDOPTS) $(LDRPATHFLAG_PREFIX)$(RPATHFLAG) $(ALDFLAGS) \ + $(DLL_LDFLAGS) $(DLL_EXPORT_FLAGS) \ + -o $@ $(SONAMEFLAG_PREFIX)$(notdir $@) $(OBJS) +else # SONAMEFLAG_PREFIX +LINK_DLL = $(LD) $(DSO_LDOPTS) $(LDRPATHFLAG_PREFIX)$(RPATHFLAG) $(ALDFLAGS) \ + $(DLL_LDFLAGS) $(DLL_EXPORT_FLAGS) \ + -o $@ $(OBJS) +endif # SONAMEFLAG_PREFIX +else # $(CC) is used to link libs +ifdef SONAMEFLAG_PREFIX +LINK_DLL = $(LD) $(DSO_LDOPTS) $(RPATHFLAG_PREFIX)$(RPATHFLAG) $(ALDFLAGS) \ + $(DLL_LDFLAGS) $(DLL_EXPORT_FLAGS) \ + -o $@ $(SONAMEFLAG_PREFIX)$(notdir $@) $(OBJS) +else # SONAMEFLAG_PREFIX +LINK_DLL = $(LD) $(DSO_LDOPTS) $(RPATHFLAG_PREFIX)$(RPATHFLAG) $(ALDFLAGS) \ + $(DLL_LDFLAGS) $(DLL_EXPORT_FLAGS) \ + -o $@ $(OBJS) +endif # SONAMEFLAG_PREFIX +endif # LD!CC +endif #!os2 + +ifeq ($(OS_ARCH), OSF1) +# The linker on OSF/1 gets confused if it finds an so_locations file +# that doesn't meet its expectations, so we arrange to remove it before +# linking. +SO_FILES_TO_REMOVE=so_locations +endif + +ifneq (,$(filter BeOS Darwin NetBSD,$(OS_ARCH))) +LINK_DLL = $(MKSHLIB) $(OBJS) +endif + +ifeq ($(OS_ARCH), HP-UX) +# On HPUX, we need a couple of changes: +# 1) Use the C++ compiler for linking, which will pass the +eh flag on down to the +# linker so the correct exception-handling-aware libC gets used (libnshttpd.sl +# needs this). +# 2) Add a "-Wl,-E" option so the linker gets a "-E" flag. This makes symbols +# in an executable visible to shared libraries loaded at runtime. +LINK_EXE = $(CC_FOR_LINK) -Wl,-E $(ALDFLAGS) $(LDFLAGS) $(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@ $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) + +ifeq ($(USE_64), 1) +ifeq ($(OS_RELEASE), B.11.23) +LINK_EXE = $(CC_FOR_LINK) -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L +DD64 -Wl,-E $(ALDFLAGS) $(LDFLAGS) $(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@ $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) +else +LINK_EXE = $(CC_FOR_LINK) -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L +DA2.0W +DS2.0 -Wl,-E $(ALDFLAGS) $(LDFLAGS) $(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@ $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) +endif +endif + +else # HP-UX +# everything except HPUX + +ifdef USE_LD_RUN_PATH +#does RPATH differently. instead we export RPATHFLAG as LD_RUN_PATH +#see ns/netsite/ldap/clients/tools/Makefile for an example +export LD_RUN_PATH=$(RPATHFLAG) +LINK_EXE = $(CC_FOR_LINK) $(ALDFLAGS) $(LDFLAGS) \ + -o $@ $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) +LINK_EXE_NOLIBSOBJS = $(CC_FOR_LINK) $(ALDFLAGS) $(LDFLAGS) -o $@ +else # USE_LD_RUN_PATH +LINK_EXE = $(CC_FOR_LINK) $(ALDFLAGS) $(LDFLAGS) \ + $(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) \ + -o $@ $(filter %.$(OBJ_SUFFIX),$^) $(OBJS) $(EXTRA_LIBS) $(PLATFORMLIBS) +LINK_EXE_NOLIBSOBJS = $(CC_FOR_LINK) $(ALDFLAGS) $(LDFLAGS) \ + $(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) -o $@ +endif # USE_LD_RUN_PATH +endif # HP-UX +endif # WINNT + +ifndef PERL +PERL = perl +endif + +# +# shared library symbol export definitions +# +ifeq ($(OS_ARCH), WINNT) +GENEXPORTS=cmd /c $(PERL) $(LDAP_SRC)/build/genexports.pl +else +GENEXPORTS=$(PERL) $(LDAP_SRC)/build/genexports.pl +endif +
View file
mozldap-6.0.7.tar.gz/c-sdk/build_mozldap_rpm
Changed
(renamed from mozilla/directory/c-sdk/build_mozldap_rpm)
View file
mozldap-6.0.7.tar.gz/c-sdk/component_versions.mk
Changed
(renamed from mozilla/directory/c-sdk/component_versions.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/AIX.mk
Changed
(renamed from mozilla/directory/c-sdk/config/AIX.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/BSD_OS.mk
Changed
(renamed from mozilla/directory/c-sdk/config/BSD_OS.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/BeOS.mk
Changed
(renamed from mozilla/directory/c-sdk/config/BeOS.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/DGUX.mk
Changed
(renamed from mozilla/directory/c-sdk/config/DGUX.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/FreeBSD.mk
Added
@@ -0,0 +1,86 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Netscape Portable Runtime (NSPR). +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-2000 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +# +# Config stuff for FreeBSD +# + +include $(MOD_DEPTH)/config/UNIX.mk + +CC = gcc +CCC = g++ +RANLIB = ranlib + +ifeq ($(OS_TEST),alpha) +CPU_ARCH = alpha +else +OS_REL_CFLAGS = -Di386 +CPU_ARCH = x86 +endif +CPU_ARCH_TAG = _$(CPU_ARCH) + +OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -ansi -Wall -pipe $(THREAD_FLAG) -DFREEBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK + +# +# The default implementation strategy for FreeBSD is pthreads. +# +ifeq ($(CLASSIC_NSPR),1) +IMPL_STRATEGY = _EMU +DEFINES += -D_PR_LOCAL_THREADS_ONLY +else +USE_PTHREADS = 1 +IMPL_STRATEGY = _PTH +DEFINES += -D_THREAD_SAFE +THREAD_FLAG += -pthread +endif + +ARCH = freebsd + +MOZ_OBJFORMAT := $(shell test -x /usr/bin/objformat && /usr/bin/objformat || echo elf) + +ifeq ($(MOZ_OBJFORMAT),elf) +DLL_SUFFIX = so +else +DLL_SUFFIX = so.1.0 +endif + +DSO_CFLAGS = -fPIC +DSO_LDOPTS = -Bshareable + +MKSHLIB = $(LD) $(DSO_LDOPTS) + +G++INCLUDES = -I/usr/include/g++
View file
mozldap-6.0.7.tar.gz/c-sdk/config/HP-UX.mk
Changed
(renamed from mozilla/directory/c-sdk/config/HP-UX.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/IRIX.mk
Changed
(renamed from mozilla/directory/c-sdk/config/IRIX.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/Linux.mk
Changed
(renamed from mozilla/directory/c-sdk/config/Linux.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/Makefile.client
Added
@@ -0,0 +1,134 @@ +#! gmake +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Netscape Portable Runtime (NSPR). +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-2000 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +MOD_DEPTH = .. + +# Indicate that this directory builds build tools. +INTERNAL_TOOLS = 1 + +include $(MOD_DEPTH)/config/config.mk + +CSRCS = now.c + +# This version hasn't been ported for us; the one in mozilla/config has +ifneq ($(OS_ARCH),OS2) +CSRCS += nsinstall.c + +PLSRCS = nfspwd.pl +endif + +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) +PROG_SUFFIX = .exe +else +PROG_SUFFIX = +endif + +# Temporary workaround to disable the generation of +# library build time because now.c uses the 'long long' +# data type that's not available on some platforms. +ifeq (,$(filter-out NEC NEXTSTEP QNX SCOOS UNIXWARE,$(OS_ARCH))) +DEFINES += -DOMIT_LIB_BUILD_TIME +endif + +ifeq ($(OS_ARCH), IRIX) + ifeq ($(basename $(OS_RELEASE)),6) + ifeq ($(USE_N32),1) + XLDOPTS += -n32 -Wl,-woff,85 + ifeq ($(OS_RELEASE), 6_2) + XLDOPTS += -Wl,-woff,85 + endif + else + ifeq ($(USE_64),1) + XLDOPTS += -64 + else + XLDOPTS += -32 + endif + endif + endif +endif + +ifeq ($(OS_ARCH), HP-UX) + ifeq ($(OS_RELEASE), B.11.23) + ifeq ($(USE_64),1) + XLDOPTS += +DD64 + else + XLDOPTS += +DD32 + endif + else + ifeq ($(USE_64),1) + XLDOPTS += +DA2.0W + endif + endif +endif + +ifeq ($(OS_ARCH), OS2) +XCFLAGS = $(OS_EXE_CFLAGS) +XLDOPTS = -Zlinker /PM:VIO +endif + +include $(MOD_DEPTH)/config/rules.mk + +PROGS = $(OBJDIR)/now$(PROG_SUFFIX) + +ifeq (,$(filter-out OS2 WINNT,$(OS_ARCH))) +TARGETS = $(PROGS) +else +PROGS += $(OBJDIR)/nsinstall$(PROG_SUFFIX) +TARGETS = $(PROGS) $(PLSRCS:.pl=) +endif + +OUTOPTION = -o # end of the line +ifeq (,$(filter-out WINNT WIN95,$(OS_TARGET))) +OUTOPTION = /Fe +endif + +# Redefine MAKE_OBJDIR for just this directory +define MAKE_OBJDIR +if test ! -d $(@D); then rm -rf $(@D); mkdir $(@D); else true; fi +endef + +export:: $(TARGETS) + +$(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX) + @$(MAKE_OBJDIR) + $(CC) $(XCFLAGS) $< $(XLDOPTS) $(OUTOPTION)$@ + +cleanconfig: FORCE + $(RM) -r $(OBJDIR) + +FORCE:
View file
mozldap-6.0.7.tar.gz/c-sdk/config/Makefile.in
Added
@@ -0,0 +1,143 @@ +#! gmake +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Netscape Portable Runtime (NSPR). +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-2000 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +MOD_DEPTH = .. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(MOD_DEPTH)/config/autoconf.mk + +# Indicate that this directory builds build tools. +INTERNAL_TOOLS = 1 + +# autoconf.mk must be deleted last (from the top-level directory) +# because it is included by every makefile. +DIST_GARBAGE = + +include $(topsrcdir)/config/config.mk + +ifndef MOZILLA_CLIENT +CSRCS = nsinstall.c +endif + +CSRCS += now.c + +PLSRCS = nfspwd.pl + +ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2,$(OS_ARCH))) +PROG_SUFFIX = .exe +else +PROG_SUFFIX = +endif + +# Temporary workaround to disable the generation of +# library build time because now.c uses the 'long long' +# data type that's not available on some platforms. +ifeq (,$(filter-out NEC NEXTSTEP QNX SCOOS UNIXWARE,$(OS_ARCH))) +DEFINES += -DOMIT_LIB_BUILD_TIME +endif + +ifeq ($(OS_ARCH), IRIX) + ifeq ($(basename $(OS_RELEASE)),6) + ifeq ($(USE_N32),1) + XLDOPTS += -n32 -Wl,-woff,85 + ifeq ($(OS_RELEASE), 6_2) + XLDOPTS += -Wl,-woff,85 + endif + else + ifeq ($(USE_64),1) + XLDOPTS += -64 + else + XLDOPTS += -32 + endif + endif + endif +endif + +ifeq ($(OS_ARCH), HP-UX) + ifeq ($(OS_RELEASE), B.11.23) + ifeq ($(USE_64),1) + XLDOPTS += +DD64 + else + XLDOPTS += +DD32 + endif + else + ifeq ($(USE_64),1) + XLDOPTS += +DA2.0W + endif + endif +endif + +ifeq ($(OS_ARCH), OpenVMS) + XLDOPTS += $(LDFLAGS) +endif + +ifeq ($(OS_ARCH),OS2) +XCFLAGS = $(OS_EXE_CFLAGS) +XLDOPTS = -Zomf -Zlinker -PM:VIO +endif + +include $(topsrcdir)/config/rules.mk + +PROGS = $(OBJDIR)/now$(PROG_SUFFIX) + +ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2,$(OS_ARCH))) +TARGETS = $(PROGS) +else +PROGS += $(OBJDIR)/nsinstall$(PROG_SUFFIX) +TARGETS = $(PROGS) $(PLSRCS:.pl=) +endif + +OUTOPTION = -o # end of the line +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) +ifndef NS_USE_GCC +OUTOPTION = -Fe +endif +endif + +# Redefine MAKE_OBJDIR for just this directory +define MAKE_OBJDIR +if test ! -d $(@D); then rm -rf $(@D); mkdir $(@D); else true; fi +endef + +export:: $(TARGETS) + +$(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX) + @$(MAKE_OBJDIR) + $(CC) $(XCFLAGS) $< $(XLDOPTS) $(OUTOPTION)$@
View file
mozldap-6.0.7.tar.gz/c-sdk/config/NCR.mk
Changed
(renamed from mozilla/directory/c-sdk/config/NCR.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/NEC.mk
Changed
(renamed from mozilla/directory/c-sdk/config/NEC.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/NEWS-OS.mk
Changed
(renamed from mozilla/directory/c-sdk/config/NEWS-OS.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/NEXTSTEP.mk
Changed
(renamed from mozilla/directory/c-sdk/config/NEXTSTEP.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/NTO.mk
Changed
(renamed from mozilla/directory/c-sdk/config/NTO.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/NetBSD.mk
Changed
(renamed from mozilla/directory/c-sdk/config/NetBSD.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/OS2.mk
Added
@@ -0,0 +1,117 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Netscape Portable Runtime (NSPR). +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-2000 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +# +# Configuration common to all (supported) versions of OS/2 +# +# OS_CFLAGS is the command line options for the compiler when +# building the .DLL object files. +# OS_EXE_CFLAGS is the command line options for the compiler +# when building the .EXE object files; this is for the test +# programs. +# the macro OS_CFLAGS is set to OS_EXE_CFLAGS inside of the +# makefile for the pr/tests directory. ... Hack. + +# Specify toolset. +XP_OS2 = 1 + +# +# On OS/2 we use ash... +# +SHELL = ASH.EXE + +RANLIB = @echo RANLIB +BSDECHO = @echo BSDECHO +NSINSTALL = nsinstall +INSTALL = $(NSINSTALL) +MAKE_OBJDIR = if test ! -d $(OBJDIR); then mkdir $(OBJDIR); fi + +GARBAGE = + +XP_DEFINE = -DXP_PC +DLL_SUFFIX = dll +OBJ_SUFFIX = o + + +# Name of the binary code directories +ifdef MOZ_LITE +OBJDIR_NAME = $(subst OS2,NAV,$(OS_CONFIG))_$(MOZ_OS2_TOOLS)$(OBJDIR_TAG).OBJ +else +OBJDIR_NAME = $(OS_CONFIG)_$(MOZ_OS2_TOOLS)$(OBJDIR_TAG).OBJ +endif + +OS_DLLFLAGS = -nologo -DLL -FREE -NOE + +CC = gcc +CCC = gcc +LINK = gcc +RC = rc.exe +FILTER = emxexp +IMPLIB = emximp -o + +OMF_FLAG = -Zomf +AR = emxomfar r $@ +LIB_SUFFIX = lib + +# if we compile with GCC we can also use the high-memory flag if specified +ifeq ($(MOZ_OS2_HIGH_MEMORY),1) +HIGHMEM_LDFLAG = -Zhigh-mem +endif + +OS_LIBS = -lemxio + +DEFINES += -DXP_OS2 -DOS2EMX_PLAIN_CHAR + +OS_CFLAGS = $(OMF_FLAG) -Wall -Wno-unused -Zmtd +OS_EXE_CFLAGS = $(OMF_FLAG) -Wall -Wno-unused -Zmtd +OS_DLLFLAGS = $(OMF_FLAG) -Zmt -Zdll -Zcrtdll $(HIGHMEM_LDFLAG) -o $@ +EXEFLAGS += -Zlinker /DE + +ifdef BUILD_OPT +OPTIMIZER = -O3 +DLLFLAGS = $(HIGHMEM_LDFLAG) +EXEFLAGS = $(HIGHMEM_LDFLAG) -Zmtd -o $@ +else +OPTIMIZER = -g #-s +DLLFLAGS = -g $(HIGHMEM_LDFLAG) #-s +EXEFLAGS = -g $(HIGHMEM_LDFLAG) $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@ # -s +EXEFLAGS += -Zlinker /DE +endif + +AR_EXTRA_ARGS = + +
View file
mozldap-6.0.7.tar.gz/c-sdk/config/OSF1.mk
Changed
(renamed from mozilla/directory/c-sdk/config/OSF1.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/OpenBSD.mk
Changed
(renamed from mozilla/directory/c-sdk/config/OpenBSD.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/OpenVMS.mk
Changed
(renamed from mozilla/directory/c-sdk/config/OpenVMS.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/QNX.mk
Changed
(renamed from mozilla/directory/c-sdk/config/QNX.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/README
Changed
(renamed from mozilla/directory/c-sdk/config/README)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/Rhapsody.mk
Changed
(renamed from mozilla/directory/c-sdk/config/Rhapsody.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/SCOOS.mk
Changed
(renamed from mozilla/directory/c-sdk/config/SCOOS.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/SINIX.mk
Changed
(renamed from mozilla/directory/c-sdk/config/SINIX.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/SunOS.mk
Changed
(renamed from mozilla/directory/c-sdk/config/SunOS.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/SunOS4.mk
Changed
(renamed from mozilla/directory/c-sdk/config/SunOS4.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/SunOS5.8_i86pc.mk
Changed
(renamed from mozilla/directory/c-sdk/config/SunOS5.8_i86pc.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/SunOS5.9.mk
Changed
(renamed from mozilla/directory/c-sdk/config/SunOS5.9.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/SunOS5.9_i86pc.mk
Changed
(renamed from mozilla/directory/c-sdk/config/SunOS5.9_i86pc.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/SunOS5.mk
Changed
(renamed from mozilla/directory/c-sdk/config/SunOS5.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/UNIX.mk
Changed
(renamed from mozilla/directory/c-sdk/config/UNIX.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/UNIXWARE.mk
Changed
(renamed from mozilla/directory/c-sdk/config/UNIXWARE.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/WIN32.mk
Added
@@ -0,0 +1,176 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Netscape Portable Runtime (NSPR). +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-2000 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +# +# Configuration common to all versions of Windows NT +# and Windows 95. +# + +# +# Client build: make sure we use the shmsdos.exe under $(MOZ_TOOLS). +# $(MOZ_TOOLS_FLIPPED) is $(MOZ_TOOLS) with all the backslashes +# flipped, so that gmake won't interpret them as escape characters. +# +ifdef PR_CLIENT_BUILD_WINDOWS +SHELL = $(MOZ_TOOLS_FLIPPED)/bin/shmsdos.exe +endif + +CC = cl +CCC = cl +LINK = link +AR = lib -NOLOGO -OUT:"$@" +RANLIB = echo +BSDECHO = echo +NSINSTALL = nsinstall +INSTALL = $(NSINSTALL) +define MAKE_OBJDIR +if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi +endef +RC = rc.exe + +GARBAGE = $(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb + +XP_DEFINE = -DXP_PC +OBJ_SUFFIX = obj +LIB_SUFFIX = lib +DLL_SUFFIX = dll + +OS_CFLAGS = -W3 -nologo -GF -Gy + +ifdef BUILD_OPT +OS_CFLAGS += -MD +OPTIMIZER = -O2 +DEFINES = -UDEBUG -U_DEBUG -DNDEBUG +DLLFLAGS = -OUT:"$@" +OBJDIR_TAG = _OPT + +else +# +# Define USE_DEBUG_RTL if you want to use the debug runtime library +# (RTL) in the debug build +# +ifdef USE_DEBUG_RTL +OS_CFLAGS += -MDd +else +OS_CFLAGS += -MD +endif +OPTIMIZER = -Od -Zi +#OPTIMIZER = -Zi -Fd$(OBJDIR)/ -Od +DEFINES = -DDEBUG -D_DEBUG -UNDEBUG + +DLLFLAGS = -DEBUG -OUT:"$@" +ifdef GLOWCODE +DLLFLAGS = -DEBUG -DEBUGTYPE:both -INCLUDE:_GlowCode -OUT:"$@" +endif + +OBJDIR_TAG = _DBG +LDFLAGS = -DEBUG +# +# When PROFILE=1 is defined, set the compile and link options +# to build targets for use by the ms-win32 profiler +# +ifdef PROFILE +LDFLAGS += -PROFILE -MAP +DLLFLAGS += -PROFILE -MAP +endif +endif + +DEFINES += -DWIN32 -D_WINDOWS + +# +# On Win95, we use the TlsXXX() interface by default because that +# allows us to load the NSPR DLL dynamically at run time. +# If you want to use static thread-local storage (TLS) for better +# performance, build the NSPR library with USE_STATIC_TLS=1. +# +ifeq ($(USE_STATIC_TLS),1) +DEFINES += -D_PR_USE_STATIC_TLS +endif + +# +# NSPR uses both fibers and static thread-local storage +# (i.e., __declspec(thread) variables) on NT. We need the -GT +# flag to turn off certain compiler optimizations so that fibers +# can use static TLS safely. +# +# Also, we optimize for Pentium (-G5) on NT. +# +ifeq ($(OS_TARGET),WINNT) +OS_CFLAGS += -GT +ifeq ($(CPU_ARCH),x86) +OS_CFLAGS += -G5 +endif +DEFINES += -DWINNT +else +DEFINES += -DWIN95 -D_PR_GLOBAL_THREADS_ONLY +endif + +ifeq ($(CPU_ARCH),x86) +DEFINES += -D_X86_ +else +ifeq ($(CPU_ARCH),MIPS) +DEFINES += -D_MIPS_ +else +ifeq ($(CPU_ARCH),ALPHA) +DEFINES += -D_ALPHA_=1 +else +ifeq ($(CPU_ARCH),x86_64) +DEFINES += -D_AMD64_ -D_M_AMD64 +else +CPU_ARCH = processor_is_undefined +endif +endif +endif +endif + +# Name of the binary code directories + +ifeq ($(CPU_ARCH),x86) +CPU_ARCH_TAG = +else +CPU_ARCH_TAG = $(CPU_ARCH) +endif + +ifdef USE_DEBUG_RTL +OBJDIR_SUFFIX = OBJD +else +OBJDIR_SUFFIX = OBJ +endif + +OBJDIR_NAME = $(OS_CONFIG)$(CPU_ARCH_TAG)$(OBJDIR_TAG).$(OBJDIR_SUFFIX) + +OS_DLLFLAGS = -nologo -DLL -SUBSYSTEM:WINDOWS -PDB:NONE
View file
mozldap-6.0.7.tar.gz/c-sdk/config/WIN95.mk
Changed
(renamed from mozilla/directory/c-sdk/config/WIN95.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/WINNT.mk
Changed
(renamed from mozilla/directory/c-sdk/config/WINNT.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/arch.mk
Changed
(renamed from mozilla/directory/c-sdk/config/arch.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/autoconf.mk.in
Changed
(renamed from mozilla/directory/c-sdk/config/autoconf.mk.in)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/autoconf/config.guess
Changed
(renamed from mozilla/directory/c-sdk/config/autoconf/config.guess)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/autoconf/config.sub
Changed
(renamed from mozilla/directory/c-sdk/config/autoconf/config.sub)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/autoconf/install-sh
Changed
(renamed from mozilla/directory/c-sdk/config/autoconf/install-sh)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/autoconf/nspr.m4
Changed
(renamed from mozilla/directory/c-sdk/config/autoconf/nspr.m4)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/autoconf/nss.m4
Changed
(renamed from mozilla/directory/c-sdk/config/autoconf/nss.m4)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/autoconf/sasl.m4
Changed
(renamed from mozilla/directory/c-sdk/config/autoconf/sasl.m4)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/autoconf/svrcore.m4
Changed
(renamed from mozilla/directory/c-sdk/config/autoconf/svrcore.m4)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/config.mk
Added
@@ -0,0 +1,226 @@ +#! gmake +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Netscape Portable Runtime (NSPR). +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-2000 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +# Configuration information for building in the NSPR source module + +# Define an include-at-most-once-flag +NSPR_CONFIG_MK = 1 + +# +# The variable definitions in this file are inputs to NSPR's +# build system. This file, if present, is included at the +# beginning of config.mk. +# +# For example: +# +# BUILD_OPT=1 +# USE_PTHREADS=1 +# NS_USE_GCC= +# +ifndef topsrcdir +topsrcdir=$(MOD_DEPTH) +endif + +ifndef srcdir +srcdir=. +endif + +ifdef USE_AUTOCONF + +NFSPWD = $(MOD_DEPTH)/config/nfspwd + +CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(OS_CFLAGS)\ + $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) +CCCFLAGS = $(CCC_ONLY_FLAGS) $(OPTIMIZER) $(OS_CFLAGS)\ + $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) +# For purify +NOMD_CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\ + $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) +NOMD_CCFLAGS = $(CCC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\ + $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) + +ifeq ($(OS_ARCH),Darwin) +ifndef NSDISTMODE +NSDISTMODE=absolute_symlink +endif +PWD := $(shell pwd) +endif + +ifeq ($(NSDISTMODE),copy) +# copy files, but preserve source mtime +INSTALL = $(NSINSTALL) -t +else +ifeq ($(NSDISTMODE),absolute_symlink) +# install using absolute symbolic links +ifeq ($(OS_ARCH),Darwin) +INSTALL = $(NSINSTALL) -L $(PWD) +else +INSTALL = $(NSINSTALL) -L `$(NFSPWD)` +endif +else +# install using relative symbolic links +INSTALL = $(NSINSTALL) -R +endif +endif + +ifdef BUILD_DEBUG_GC +DEFINES += -DDEBUG_GC +endif + +GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) + +DEFINES += -DFORCE_PR_LOG + +ifeq ($(_PR_NO_CLOCK_TIMER),1) +DEFINES += -D_PR_NO_CLOCK_TIMER +endif + +ifeq ($(USE_PTHREADS), 1) +DEFINES += -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM +endif + +ifeq ($(PTHREADS_USER), 1) +DEFINES += -DPTHREADS_USER -UHAVE_CVAR_BUILT_ON_SEM +endif + +ifeq ($(USE_IPV6),1) +DEFINES += -D_PR_INET6 +endif + +else # ! USE_AUTOCONF + +ifndef NSPR_MY_CONFIG_MK +NSPR_MY_CONFIG_MK = $(MOD_DEPTH)/config/my_config.mk +endif + +# +# The variable definitions in this file are used to +# override variable values set by NSPR's build system. +# This file, if present, is included at the end of config.mk. +# +# For example: +# +# DIST=/usr/local/nspr +# +ifndef NSPR_MY_OVERRIDES_MK +NSPR_MY_OVERRIDES_MK = $(MOD_DEPTH)/config/my_overrides.mk +endif + +-include $(NSPR_MY_CONFIG_MK) + +include $(MOD_DEPTH)/config/module.df + +include $(MOD_DEPTH)/config/arch.mk + +ifndef NSDEPTH +NSDEPTH = $(MOD_DEPTH)/.. +endif + +# +# Default command macros; can be overridden in <arch>.mk. +# +# XXX FIXME: I removed CCF and LINKEXE. +AS = $(CC) +ASFLAGS = $(CFLAGS) +PURIFY = purify $(PURIFYOPTIONS) +LINK_DLL = $(LINK) $(OS_DLLFLAGS) $(DLLFLAGS) +NFSPWD = $(MOD_DEPTH)/config/nfspwd + +CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(OS_CFLAGS)\ + $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) +CCCFLAGS = $(CCC_ONLY_FLAGS) $(OPTIMIZER) $(OS_CFLAGS)\ + $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) +# For purify +NOMD_CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\ + $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS) + +include $(MOD_DEPTH)/config/$(OS_TARGET).mk + +# Figure out where the binary code lives. +BUILD = $(OBJDIR_NAME) +OBJDIR = $(OBJDIR_NAME) +DIST = $(NSDEPTH)/dist/$(OBJDIR_NAME) + +VPATH = $(OBJDIR) +DEPENDENCIES = $(OBJDIR)/.md + +ifdef BUILD_DEBUG_GC +DEFINES += -DDEBUG_GC +endif + +GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) + +#################################################################### +# +# The NSPR-specific configuration +# +#################################################################### + +OS_CFLAGS += -DFORCE_PR_LOG + +ifeq ($(_PR_NO_CLOCK_TIMER),1) +OS_CFLAGS += -D_PR_NO_CLOCK_TIMER +endif + +ifeq ($(USE_PTHREADS), 1) +OS_CFLAGS += -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM +endif + +ifeq ($(PTHREADS_USER), 1) +OS_CFLAGS += -DPTHREADS_USER -UHAVE_CVAR_BUILT_ON_SEM +endif + +ifeq ($(USE_IPV6),1) +OS_CFLAGS += -D_PR_INET6 +endif + +#################################################################### +# +# Configuration for the release process +# +#################################################################### + +RELEASE_DIR = $(NSDEPTH)/dist/release/$(MOD_NAME) + +RELEASE_INCLUDE_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/include +RELEASE_BIN_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/bin +RELEASE_LIB_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/lib + +-include $(NSPR_MY_OVERRIDES_MK) + +endif # USE_AUTOCONF
View file
mozldap-6.0.7.tar.gz/c-sdk/config/cygwin-wrapper
Changed
(renamed from mozilla/directory/c-sdk/config/cygwin-wrapper)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/libc_r.h
Changed
(renamed from mozilla/directory/c-sdk/config/libc_r.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/module.df
Changed
(renamed from mozilla/directory/c-sdk/config/module.df)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/nfspwd
Changed
(renamed from mozilla/directory/c-sdk/config/nfspwd.pl)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/nfspwd.pl
Added
@@ -0,0 +1,50 @@ +#! perl +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Netscape Portable Runtime (NSPR). +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-2000 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +require "fastcwd.pl"; + +$_ = &fastcwd; +if (m@^/[uh]/@o || s@^/tmp_mnt/@/@o) { + print("$_\n"); +} elsif ((($user, $rest) = m@^/usr/people/(\w+)/(.*)@o) + && readlink("/u/$user") eq "/usr/people/$user") { + print("/u/$user/$rest\n"); +} else { + chop($host = `hostname`); + print("/h/$host$_\n"); +}
View file
mozldap-6.0.7.tar.gz/c-sdk/config/now.c
Added
@@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Netscape Portable Runtime (NSPR). + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include <stdio.h> +#include <stdlib.h> + +#if defined(VMS) +#include <sys/timeb.h> +#elif defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) +#include <sys/time.h> +#elif defined(WIN32) +#include <windows.h> +#else +#error "Architecture not supported" +#endif + + +int main(int argc, char **argv) +{ +#if defined(OMIT_LIB_BUILD_TIME) + /* + * Some platforms don't have any 64-bit integer type + * such as 'long long'. Because we can't use NSPR's + * PR_snprintf in this program, it is difficult to + * print a static initializer for PRInt64 (a struct). + * So we print nothing. The makefiles that build the + * shared libraries will detect the empty output string + * of this program and omit the library build time + * in PRVersionDescription. + */ +#elif defined(VMS) + long long now; + struct timeb b; + ftime(&b); + now = b.time; + now *= 1000000; + now += (1000 * b.millitm); + fprintf(stdout, "%Ld", now); +#elif defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) + long long now; + struct timeval tv; +#ifdef HAVE_SVID_GETTOD + gettimeofday(&tv); +#else + gettimeofday(&tv, NULL); +#endif + now = ((1000000LL) * tv.tv_sec) + (long long)tv.tv_usec; +#if defined(OSF1) + fprintf(stdout, "%ld", now); +#elif defined(BEOS) && defined(__POWERPC__) + fprintf(stdout, "%Ld", now); /* Metroworks on BeOS PPC */ +#else + fprintf(stdout, "%lld", now); +#endif + +#elif defined(WIN32) + __int64 now; + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + CopyMemory(&now, &ft, sizeof(now)); + /* + * 116444736000000000 is the number of 100-nanosecond intervals + * between Jan. 1, 1601 and Jan. 1, 1970. + */ +#ifdef __GNUC__ + now = (now - 116444736000000000LL) / 10LL; + fprintf(stdout, "%lld", now); +#else + now = (now - 116444736000000000i64) / 10i64; + fprintf(stdout, "%I64d", now); +#endif + +#else +#error "Architecture not supported" +#endif + + return 0; +} /* main */ + +/* now.c */
View file
mozldap-6.0.7.tar.gz/c-sdk/config/nsinstall.c
Changed
(renamed from mozilla/directory/c-sdk/config/nsinstall.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/pathsub.h
Changed
(renamed from mozilla/directory/c-sdk/config/pathsub.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/prdepend.h
Changed
(renamed from mozilla/directory/c-sdk/config/prdepend.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/prmkdir.bat
Changed
(renamed from mozilla/directory/c-sdk/config/prmkdir.bat)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/rules.mk
Added
@@ -0,0 +1,471 @@ +#! gmake +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Netscape Portable Runtime (NSPR). +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-2000 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +################################################################################ +# We have a 4 pass build process: +# +# Pass 1. export - Create generated headers and stubs. Publish public headers to +# dist/<arch>/include. +# +# Pass 2. libs - Create libraries. Publish libraries to dist/<arch>/lib. +# +# Pass 3. all - Create programs. +# +# Pass 4. install - Publish programs to dist/<arch>/bin. +# +# Parameters to this makefile (set these before including): +# +# a) +# TARGETS -- the target to create +# (defaults to $LIBRARY $PROGRAM) +# b) +# DIRS -- subdirectories for make to recurse on +# (the 'all' rule builds $TARGETS $DIRS) +# c) +# CSRCS -- .c files to compile +# (used to define $OBJS) +# d) +# PROGRAM -- the target program name to create from $OBJS +# ($OBJDIR automatically prepended to it) +# e) +# LIBRARY -- the target library name to create from $OBJS +# ($OBJDIR automatically prepended to it) +# +################################################################################ + +ifndef topsrcdir +topsrcdir=$(MOD_DEPTH) +endif + +ifndef srcdir +srcdir=. +endif + +ifndef NSPR_CONFIG_MK +include $(topsrcdir)/config/config.mk +endif + +ifdef USE_AUTOCONF +ifdef CROSS_COMPILE +ifdef INTERNAL_TOOLS +CC=$(HOST_CC) +CCC=$(HOST_CXX) +CFLAGS=$(HOST_CFLAGS) +CXXFLAGS=$(HOST_CXXFLAGS) +endif +endif +endif + +# +# This makefile contains rules for building the following kinds of +# libraries: +# - LIBRARY: a static (archival) library +# - SHARED_LIBRARY: a shared (dynamic link) library +# - IMPORT_LIBRARY: an import library, used only on Windows and OS/2 +# +# The names of these libraries can be generated by simply specifying +# LIBRARY_NAME and LIBRARY_VERSION. +# + +ifdef LIBRARY_NAME +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) + +# +# Win95, Win16, and OS/2 require library names conforming to the 8.3 rule. +# other platforms do not. +# +ifeq (,$(filter-out WIN95 WIN16 OS2,$(OS_TARGET))) +LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX) +SHARED_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX) +IMPORT_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX) +else +LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX) +SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX) +IMPORT_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX) +endif + +ifeq ($(OS_ARCH),OS2) +DEF_FILE := $(SHARED_LIBRARY:.dll=.def) +endif + +else + +LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX) +ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1) +SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_shr.a +else +ifdef MKSHLIB +SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX) +endif +endif + +endif +endif + +ifndef TARGETS +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) +TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) +else +TARGETS = $(LIBRARY) $(SHARED_LIBRARY) +endif +endif + +# +# OBJS is the list of object files. It can be constructed by +# specifying CSRCS (list of C source files) and ASFILES (list +# of assembly language source files). +# + +ifndef OBJS +OBJS = $(addprefix $(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \ + $(addprefix $(OBJDIR)/,$(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))) +endif + +ifeq ($(OS_TARGET), WIN16) + comma := , + empty := + space := $(empty) $(empty) + W16OBJS = $(subst $(space),$(comma)$(space),$(strip $(OBJS))) + W16TEMP =$(OS_LIBS) $(EXTRA_LIBS) + ifeq ($(strip $(W16TEMP)),) + W16LIBS = + else + W16LIBS = library $(subst $(space),$(comma)$(space),$(strip $(W16TEMP))) + endif + W16DEF = $(notdir $(basename $(SHARED_LIBRARY))).DEF +endif + +ifeq ($(OS_ARCH), WINNT) +ifneq ($(OS_TARGET), WIN16) +OBJS += $(RES) +endif +endif + +ALL_TRASH = $(TARGETS) $(OBJS) $(filter-out . .., $(OBJDIR)) LOGS TAGS $(GARBAGE) \ + $(NOSUCHFILE) $(DEF_FILE)\ + so_locations + +ifdef DIRS +LOOP_OVER_DIRS = \ + @for d in $(DIRS); do \ + if test -d $$d; then \ + set -e; \ + echo "cd $$d; $(MAKE) $(MFLAGS) $@"; \ + $(MAKE) $(MFLAGS) -C $$d $@; \ + set +e; \ + else \ + echo "Skipping non-directory $$d..."; \ + fi; \ + done +endif + +################################################################################ + +all:: export + +export:: + +$(LOOP_OVER_DIRS) + +libs:: export + +install:: export + +clean:: + rm -rf $(OBJS) so_locations $(NOSUCHFILE) $(GARBAGE) + +$(LOOP_OVER_DIRS) + +clobber:: + rm -rf $(OBJS) $(TARGETS) $(filter-out . ..,$(OBJDIR)) $(GARBAGE) so_locations $(NOSUCHFILE) + +$(LOOP_OVER_DIRS) + +realclean clobber_all distclean:: + rm -rf $(wildcard *.OBJ *.OBJD) dist $(ALL_TRASH) + +$(LOOP_OVER_DIRS) + +real_install:: $(RELEASE_BINS) $(RELEASE_HEADERS) $(RELEASE_LIBS) +ifdef RELEASE_BINS + $(NSINSTALL) -t -m 0755 $(RELEASE_BINS) $(DESTDIR)$(bindir) +endif +ifdef RELEASE_HEADERS + $(NSINSTALL) -t -m 0644 $(RELEASE_HEADERS) $(DESTDIR)$(includedir) +endif +ifdef RELEASE_LIBS + $(NSINSTALL) -t -m 0755 $(RELEASE_LIBS) $(DESTDIR)$(libdir) +endif + +$(LOOP_OVER_DIRS) + +release:: export +ifdef RELEASE_BINS + @echo "Copying executable programs and scripts to release directory" + @if test -z "$(BUILD_NUMBER)"; then \ + echo "BUILD_NUMBER must be defined"; \ + false; \ + else \ + true; \ + fi + @if test ! -d $(RELEASE_BIN_DIR); then \ + rm -rf $(RELEASE_BIN_DIR); \ + $(NSINSTALL) -D $(RELEASE_BIN_DIR);\ + else \ + true; \ + fi + cp $(RELEASE_BINS) $(RELEASE_BIN_DIR) +endif +ifdef RELEASE_LIBS + @echo "Copying libraries to release directory" + @if test -z "$(BUILD_NUMBER)"; then \ + echo "BUILD_NUMBER must be defined"; \ + false; \ + else \ + true; \ + fi + @if test ! -d $(RELEASE_LIB_DIR); then \ + rm -rf $(RELEASE_LIB_DIR); \ + $(NSINSTALL) -D $(RELEASE_LIB_DIR);\ + else \ + true; \ + fi + cp $(RELEASE_LIBS) $(RELEASE_LIB_DIR) +endif +ifdef RELEASE_HEADERS + @echo "Copying header files to release directory" + @if test -z "$(BUILD_NUMBER)"; then \ + echo "BUILD_NUMBER must be defined"; \ + false; \ + else \ + true; \ + fi + @if test ! -d $(RELEASE_HEADERS_DEST); then \ + rm -rf $(RELEASE_HEADERS_DEST); \ + $(NSINSTALL) -D $(RELEASE_HEADERS_DEST);\ + else \ + true; \ + fi + cp $(RELEASE_HEADERS) $(RELEASE_HEADERS_DEST) +endif + +$(LOOP_OVER_DIRS) + +alltags: + rm -f TAGS tags + find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs etags -a + find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs ctags -a + +$(NFSPWD): + cd $(@D); $(MAKE) $(MFLAGS) $(@F) + +$(PROGRAM): $(OBJS) + @$(MAKE_OBJDIR) +ifeq ($(OS_ARCH)_$(NS_USE_GCC),WINNT_) + $(CC) $(OBJS) -Fe$@ -link $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) +else + $(CC) -o $@ $(CFLAGS) $(OBJS) $(LDFLAGS) +endif + +$(LIBRARY): $(OBJS) + @$(MAKE_OBJDIR) + rm -f $@ +ifdef USE_AUTOCONF + $(AR) $(AR_FLAGS) $(OBJS) $(AR_EXTRA_ARGS) +else + $(AR) $(OBJS) $(AR_EXTRA_ARGS) +endif # USE_AUTOCONF + $(RANLIB) $@ + +ifeq ($(OS_TARGET), WIN16) +$(IMPORT_LIBRARY): $(SHARED_LIBRARY) + wlib $(OS_LIB_FLAGS) $@ +$(SHARED_LIBRARY) +endif + +ifeq ($(OS_TARGET), OS2) +$(DEF_FILE): $(LIBRARY) + rm -f $@ + echo LIBRARY $(notdir $(basename $(SHARED_LIBRARY))) INITINSTANCE TERMINSTANCE > $@ + echo PROTMODE >> $@ + echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@ + echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@ + echo EXPORTS >> $@ + $(FILTER) $(LIBRARY) >> $@ + +$(IMPORT_LIBRARY): $(DEF_FILE) + rm -f $@ + $(IMPLIB) $@ $(DEF_FILE) +endif + +$(SHARED_LIBRARY): $(OBJS) $(DEF_FILE) + @$(MAKE_OBJDIR) + rm -f $@ +ifdef USE_AUTOCONF + $(MKSHLIB) $(OBJS) $(EXTRA_LIBS) $(OS_LIBS) $(DEF_FILE) +else +ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1) + echo "#!" > $(OBJDIR)/lib$(LIBRARY_NAME)_syms + nm -B -C -g $(OBJS) \ + | awk '/ [T,D] / {print $$3}' \ + | sed -e 's/^\.//' \ + | sort -u >> $(OBJDIR)/lib$(LIBRARY_NAME)_syms + $(LD) $(XCFLAGS) -o $@ $(OBJS) -bE:$(OBJDIR)/lib$(LIBRARY_NAME)_syms \ + -bM:SRE -bnoentry $(OS_LIBS) $(EXTRA_LIBS) +else # AIX 4.1 +ifeq ($(OS_ARCH), WINNT) +ifeq ($(OS_TARGET), WIN16) + echo system windows dll initinstance >w16link + echo option map >>w16link + echo option oneautodata >>w16link + echo option heapsize=32K >>w16link + echo option $(OS_DLL_OPTION) >>w16link + echo debug $(DEBUGTYPE) all >>w16link + echo name $@ >>w16link + echo file >>w16link + echo $(W16OBJS) >>w16link + echo $(W16IMPORTS) >>w16link + echo $(W16LIBS) >>w16link + echo $(W16_EXPORTS) >>w16link + echo libfile libentry >>w16link + $(LINK) @w16link. + rm w16link +else # WIN16 + $(LINK_DLL) -MAP $(DLLBASE) $(OS_LIBS) $(EXTRA_LIBS) $(OBJS) +endif # WINNT +else + $(MKSHLIB) -o $@ $(OBJS) $(EXTRA_LIBS) $(OS_LIBS) $(DEF_FILE) +endif # WINNT +endif # AIX 4.1 +endif # USE_AUTOCONF + + +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) +$(RES): $(RESNAME) + @$(MAKE_OBJDIR) +ifeq ($(OS_TARGET),OS2) + $(RC) -DOS2 -r $(RESNAME) $(RES) +else +# The resource compiler does not understand the -U option. +ifdef NS_USE_GCC + $(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) -o $@ $< +else + $(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$(RES) $(RESNAME) +endif +endif + @echo $(RES) finished +endif + +$(OBJDIR)/%.$(OBJ_SUFFIX): %.cpp + @$(MAKE_OBJDIR) +ifeq ($(OS_ARCH)_$(NS_USE_GCC), WINNT_) + $(CCC) -Fo$@ -c $(CCCFLAGS) $< +else + $(CCC) -o $@ -c $(CCCFLAGS) $< +endif + +WCCFLAGS1 = $(subst /,\\,$(CFLAGS)) +WCCFLAGS2 = $(subst -I,-i=,$(WCCFLAGS1)) +WCCFLAGS3 = $(subst -D,-d,$(WCCFLAGS2)) +$(OBJDIR)/%.$(OBJ_SUFFIX): %.c + @$(MAKE_OBJDIR) +ifeq ($(OS_ARCH)_$(NS_USE_GCC), WINNT_) +ifeq ($(OS_TARGET), WIN16) +# $(MOD_DEPTH)/config/w16opt $(WCCFLAGS3) + echo $(WCCFLAGS3) >w16wccf + $(CC) -zq -fo$(OBJDIR)\\$*.$(OBJ_SUFFIX) @w16wccf $*.c + rm w16wccf +else + $(CC) -Fo$@ -c $(CFLAGS) $< +endif +else + $(CC) -o $@ -c $(CFLAGS) $< +endif + + +$(OBJDIR)/%.$(OBJ_SUFFIX): %.s + @$(MAKE_OBJDIR) + $(AS) -o $@ $(ASFLAGS) -c $< + +%.i: %.c + $(CC) -C -E $(CFLAGS) $< > $*.i + +%: %.pl + rm -f $@; cp $< $@; chmod +x $@ + +# +# HACK ALERT +# +# The only purpose of this rule is to pass Mozilla's Tinderbox depend +# builds (http://tinderbox.mozilla.org/showbuilds.cgi). Mozilla's +# Tinderbox builds NSPR continuously as part of the Mozilla client. +# Because NSPR's make depend is not implemented, whenever we change +# an NSPR header file, the depend build does not recompile the NSPR +# files that depend on the header. +# +# This rule makes all the objects depend on a dummy header file. +# Touch this dummy header file to force the depend build to recompile +# everything. +# +# This rule should be removed when make depend is implemented. +# + +DUMMY_DEPEND_H = $(topsrcdir)/config/prdepend.h + +$(filter $(OBJDIR)/%.$(OBJ_SUFFIX),$(OBJS)): $(OBJDIR)/%.$(OBJ_SUFFIX): $(DUMMY_DEPEND_H) + +# END OF HACK + +################################################################################ +# Special gmake rules. +################################################################################ + +# +# Re-define the list of default suffixes, so gmake won't have to churn through +# hundreds of built-in suffix rules for stuff we don't need. +# +.SUFFIXES: +.SUFFIXES: .a .$(OBJ_SUFFIX) .c .cpp .s .h .i .pl + +# +# Fake targets. Always run these rules, even if a file/directory with that +# name already exists. +# +.PHONY: all alltags clean export install libs realclean release + +# +# List the target pattern of an implicit rule as a dependency of the +# special target .PRECIOUS to preserve intermediate files made by +# implicit rules whose target patterns match that file's name. +# (See GNU Make documentation, Edition 0.51, May 1996, Sec. 10.4, +# p. 107.) +# +.PRECIOUS: $(OBJDIR)/%.$(OBJ_SUFFIX)
View file
mozldap-6.0.7.tar.gz/c-sdk/config/win16.mk
Changed
(renamed from mozilla/directory/c-sdk/config/win16.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/configure
Added
@@ -0,0 +1,7385 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --with-dist-prefix=DIST_PREFIX + place build files in DIST_PREFIX [dist]" +ac_help="$ac_help + --with-dist-bindir=DIR build execuatables in DIR [DIST_PREFIX/bin]" +ac_help="$ac_help + --with-dist-libdir=DIR build library files in DIR [DIST_PREFIX/lib]" +ac_help="$ac_help + --with-mozilla Compile LDAP with Mozilla support" +ac_help="$ac_help + --enable-optimize(=val) Enable code optimizations (val, ie. -O2) " +ac_help="$ac_help + --enable-debug(=val) Enable debugging (debug flags val)" +ac_help="$ac_help + --enable-win32-target=\$t + Specify win32 flavor. (WIN95 or WINNT)" +ac_help="$ac_help + --enable-debug-rtl Use the MSVC debug runtime library" +ac_help="$ac_help + --enable-n32 Enable n32 ABI support (IRIX only)" +ac_help="$ac_help + --enable-64bit Enable 64-bit support (on certain platforms)" +ac_help="$ac_help + --enable-mdupdate Enable use of certain compilers' mdupdate feature" +ac_help="$ac_help + --enable-clu Enable building the command-line utilities" +ac_help="$ac_help + --with-system-svrcore Use system installed SVRCORE" +ac_help="$ac_help +[ --with-svrcore[=PATH] Use svrcore - optional PATH is path to svrcore lib and include dirs]" +ac_help="$ac_help + --with-svrcore-inc=PATH svrcore include file directory" +ac_help="$ac_help + --with-svrcore-lib=PATH svrcore library directory" +ac_help="$ac_help + --with-system-nss Use system installed NSS" +ac_help="$ac_help +[ --with-nss[=PATH] Build libssldap, using NSS for crypto - optional PATH is path to NSS package]" +ac_help="$ac_help + --with-nss-inc=PATH Netscape Portable Runtime (NSS) include file directory" +ac_help="$ac_help + --with-nss-lib=PATH Netscape Portable Runtime (NSS) library directory" +ac_help="$ac_help + --with-nss-prefix=PFX Prefix where NSS is installed" +ac_help="$ac_help + --with-nss-exec-prefix=PFX + Exec prefix where NSS is installed" +ac_help="$ac_help + --with-system-nspr Use system installed NSPR" +ac_help="$ac_help + --with-nspr=PATH Netscape Portable Runtime (NSPR) directory" +ac_help="$ac_help + --with-nspr-inc=PATH Netscape Portable Runtime (NSPR) include file directory" +ac_help="$ac_help + --with-nspr-lib=PATH Netscape Portable Runtime (NSPR) library directory" +ac_help="$ac_help + --with-nspr-prefix=PFX Prefix where NSPR is installed" +ac_help="$ac_help + --with-nspr-exec-prefix=PFX + Exec prefix where NSPR is installed" +ac_help="$ac_help + --with-macos-sdk=dir Location of platform SDK to use (Mac OS X only)" +ac_help="$ac_help + --disable-os2-high-mem Disable high-memory support on OS/2" +ac_help="$ac_help + --with-rpath[[=dir]] Build the shared libs and cmd lines progs with an RPATH (default dir is ..:../lib:../../lib:../../../lib:../../../../lib)" +ac_help="$ac_help + --enable-strip Enable stripping of shared libs and programs" +ac_help="$ac_help + --with-pthreads Use system pthreads library as thread subsystem" +ac_help="$ac_help + --enable-user-pthreads Build using userland pthreads" +ac_help="$ac_help + --enable-nspr-threads Build using classic nspr threads" +ac_help="$ac_help + --with-bthreads Use system bthreads library as thread subsystem (BeOS only)" +ac_help="$ac_help + --with-native-threads Use native system threads as thread subsystem (Solaris only)" +ac_help="$ac_help + --enable-cplus Enable some c++ api routines" +ac_help="$ac_help + --enable-ipv6 Compile ipv6 support" +ac_help="$ac_help +[ --with-sasl[=PATH] Use system installed sasl - optional path for sasl]" +ac_help="$ac_help +[ --with-sasl-inc=PATH SASL include file directory]" +ac_help="$ac_help +[ --with-sasl-lib=PATH SASL library directory]" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=ldap/include/ldap.h + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + +ac_aux_dir= +for ac_dir in ${srcdir}/config/autoconf $srcdir/${srcdir}/config/autoconf; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in ${srcdir}/config/autoconf $srcdir/${srcdir}/config/autoconf" 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + + +# Do some error checking and defaulting for the host and target type. +# The inputs are: +# configure --host=HOST --target=TARGET --build=BUILD NONOPT +# +# The rules are: +# 1. You are not allowed to specify --host, --target, and nonopt at the +# same time. +# 2. Host defaults to nonopt. +# 3. If nonopt is not specified, then host defaults to the current host, +# as determined by config.guess. +# 4. Target and build default to nonopt. +# 5. If nonopt is not specified, then target and build default to host. + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +case $host---$target---$nonopt in +NONE---*---* | *---NONE---* | *---*---NONE) ;; +*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;; +esac + + +# Make sure we can run config.sub. +if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:661: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +echo $ac_n "checking target system type""... $ac_c" 1>&6 +echo "configure:682: checking target system type" >&5 + +target_alias=$target +case "$target_alias" in +NONE) + case $nonopt in + NONE) target_alias=$host_alias ;; + *) target_alias=$nonopt ;; + esac ;; +esac + +target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias` +target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$target" 1>&6 + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:700: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +test "$host_alias" != "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + + +NSPR_VERSION=4 +_HAVE_PTHREADS= +USE_PTHREADS= +USE_USER_PTHREADS= +USE_NSPR_THREADS= +USE_N32= +USE_64= +USE_CPLUS= +USE_IPV6= +USE_MDUPDATE= +_OPTIMIZE_FLAGS=-O +_DEBUG_FLAGS=-g +MOZ_DEBUG= +MOZ_OPTIMIZE=1 +MFLAGS= +OBJDIR=. +OBJDIR_NAME=. +NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall' +NOSUCHFILE=/no-such-file +MOZ_OS2_HIGH_MEMORY=1 + +RESOLVE_LINK_SYMBOLS= + +CFLAGS="${CFLAGS=}" +CXXFLAGS="${CXXFLAGS=}" +LDFLAGS="${LDFLAGS=}" +DLLFLAGS="${DLLFLAGS=}" +HOST_CFLAGS="${HOST_CFLAGS=}" +HOST_LDFLAGS="${HOST_LDFLAGS=}" + +case "$target" in +*-cygwin*|*-mingw*|*-msvc*|*-mks*) + # Check to see if we are really running in a msvc environemnt + _WIN32_MSVC= + for ac_prog in cl +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:762: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$CC" && break +done + + if test "$CC" = "cl"; then + echo 'main() { return 0; }' > dummy.c + ${CC} -o dummy dummy.c >/dev/null 2>&1 + if test $? = 0; then + _WIN32_MSVC=1 + CXX=$CC + else + echo "configure: warning: $(CC) test failed. Using normal feature tests" 1>&2 + fi + rm -f dummy dummy.o dummy.obj dummy.exe dummy.c + fi + ;; +esac + +if test -n "$_WIN32_MSVC"; then + SKIP_PATH_CHECKS=1 + SKIP_COMPILER_CHECKS=1 + SKIP_LIBRARY_CHECKS=1 +fi + +dist_prefix='${MOD_DEPTH}/../../dist' +dist_bindir='${dist_prefix}/bin' +dist_libdir='${dist_prefix}/lib' + +# Check whether --with-dist-prefix or --without-dist-prefix was given. +if test "${with_dist_prefix+set}" = set; then + withval="$with_dist_prefix" + dist_prefix=$withval +fi + + +# Check whether --with-dist-bindir or --without-dist-bindir was given. +if test "${with_dist_bindir+set}" = set; then + withval="$with_dist_bindir" + dist_bindir=$withval +fi + + +# Check whether --with-dist-libdir or --without-dist-libdir was given. +if test "${with_dist_libdir+set}" = set; then + withval="$with_dist_libdir" + dist_libdir=$withval +fi + + + + + + +# Check whether --with-mozilla or --without-mozilla was given. +if test "${with_mozilla+set}" = set; then + withval="$with_mozilla" + if test "$withval" = "yes"; then + cat >> confdefs.h <<\EOF +#define MOZILLA_CLIENT 1 +EOF + + MOZILLA_CLIENT=1 + else + MOZILLA_CLIENT= + fi +else + if test -n "$MOZILLA_CLIENT"; then + cat >> confdefs.h <<\EOF +#define MOZILLA_CLIENT 1 +EOF + + fi +fi + + +# Check whether --enable-optimize or --disable-optimize was given. +if test "${enable_optimize+set}" = set; then + enableval="$enable_optimize" + if test "$enableval" != "no"; then + MOZ_OPTIMIZE=1 + if test -n "$enableval" && test "$enableval" != "yes"; then + _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'` + _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS + fi + else + MOZ_OPTIMIZE= + fi +fi + + +# Check whether --enable-debug or --disable-debug was given. +if test "${enable_debug+set}" = set; then + enableval="$enable_debug" + if test "$enableval" != "no"; then + MOZ_DEBUG=1 + if test -n "$enableval" && test "$enableval" != "yes"; then + _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'` + _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS + fi + else + MOZ_DEBUG= + fi +fi + + +# Check whether --enable-win32-target or --disable-win32-target was given. +if test "${enable_win32_target+set}" = set; then + enableval="$enable_win32_target" + OS_TARGET=`echo $enableval | tr a-z A-Z` +else + OS_TARGET= +fi + + +# Check whether --enable-debug-rtl or --disable-debug-rtl was given. +if test "${enable_debug_rtl+set}" = set; then + enableval="$enable_debug_rtl" + if test "$enableval" = "yes"; then + USE_DEBUG_RTL=1 + fi +fi + + +# Check whether --enable-n32 or --disable-n32 was given. +if test "${enable_n32+set}" = set; then + enableval="$enable_n32" + if test "$enableval" = "yes"; then + USE_N32=1 + else if test "$enableval" = "no"; then + USE_N32= + fi + fi +fi + + +# Check whether --enable-64bit or --disable-64bit was given. +if test "${enable_64bit+set}" = set; then + enableval="$enable_64bit" + if test "$enableval" = "yes"; then + USE_64=1 ; export USE_64 + fi +fi + + +# Check whether --enable-mdupdate or --disable-mdupdate was given. +if test "${enable_mdupdate+set}" = set; then + enableval="$enable_mdupdate" + if test "$enableval" = "yes"; then + USE_MDUPDATE=1 + fi +fi + + +# Check whether --enable-clu or --disable-clu was given. +if test "${enable_clu+set}" = set; then + enableval="$enable_clu" + if test "$enableval" = "yes"; then + BUILDCLU=1 + + fi +fi + + +# Check whether --with-system-svrcore or --without-system-svrcore was given. +if test "${with_system_svrcore+set}" = set; then + withval="$with_system_svrcore" + if test "$withval" = "yes"; then + _SYSTEM_SVRCORE=1 + HAVE_SVRCORE=1 + SVRCORE_LIBS=-lsvrcore + + + USE_NSS=1 + no_nspr=no + else + _SYSTEM_SVRCORE= + fi +else + _SYSTEM_SVRCORE= +fi + + +if test -z "$_SYSTEM_SVRCORE" ; then + + echo $ac_n "checking for --with-svrcore""... $ac_c" 1>&6 +echo "configure:972: checking for --with-svrcore" >&5 + # Check whether --with-svrcore or --without-svrcore was given. +if test "${with_svrcore+set}" = set; then + withval="$with_svrcore" + if test "$withval" = "yes"; then + HAVE_SVRCORE=1 + echo "$ac_t""yes" 1>&6 + elif test -n "$withval" -a -d "$withval" -a -d "$withval/lib" -a -f "$withval/include/svrcore.h" ; then + HAVE_SVRCORE=1 + echo "$ac_t""using $withval" 1>&6 + SVRCORE_CFLAGS="-I$withval/include" + SVRCORE_LIBS="-L$withval/lib" + fi +else + HAVE_SVRCORE= +fi + + + # check for --with-svrcore-inc + # Check whether --with-svrcore-inc or --without-svrcore-inc was given. +if test "${with_svrcore_inc+set}" = set; then + withval="$with_svrcore_inc" + + if test -n "$withval" -a -f "$withval"/svrcore.h + then + echo "$ac_t""using $withval" 1>&6 + SVRCORE_CFLAGS="-I$withval" + else + echo + { echo "configure: error: $withval not found" 1>&2; exit 1; } + fi + +fi + + + # check for --with-svrcore-lib + # Check whether --with-svrcore-lib or --without-svrcore-lib was given. +if test "${with_svrcore_lib+set}" = set; then + withval="$with_svrcore_lib" + + if test -n "$withval" -a -d "$withval" + then + echo "$ac_t""using $withval" 1>&6 + SVRCORE_LIBS="-L$withval" + else + echo + { echo "configure: error: $withval not found" 1>&2; exit 1; } + fi + +fi + + + if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS" ; then + echo "$ac_t""no" 1>&6 + else + HAVE_SVRCORE=1 + fi + + + if test -n "$HAVE_SVRCORE" ; then + USE_NSS=1 + HAVE_SVRCORE=1 + + no_nspr=no + if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS" ; then + if test -n "$_SYSTEM_SVRCORE"; then + + if test -n "$HAVE_SVRCORE" ; then + no_svrcore="" + echo $ac_n "checking Trying pkg-config svrcore""... $ac_c" 1>&6 +echo "configure:1042: checking Trying pkg-config svrcore" >&5 + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1046: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$PKG_CONFIG" in + /*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +if test -n "$PKG_CONFIG"; then + echo "$ac_t""$PKG_CONFIG" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -n "$PKG_CONFIG"; then + if $PKG_CONFIG --exists svrcore-devel; then + echo $ac_n "checking using SVRCORE from package svrcore""... $ac_c" 1>&6 +echo "configure:1081: checking using SVRCORE from package svrcore" >&5 + SVRCORE_CFLAGS=`$PKG_CONFIG --cflags-only-I svrcore-devel` + SVRCORE_LIBS=`$PKG_CONFIG --libs-only-L svrcore-devel` + else + no_svrcore="yes" + fi + else + no_svrcore="yes" + fi + + if test -z "$no_svrcore"; then + echo "$ac_t""yes" 1>&6 + MOZ_NATIVE_SVRCORE=1 + else + echo "$ac_t""no" 1>&6 + fi + + + + + fi + + else + + if test -n "$HAVE_SVRCORE" ; then + svrcorelibpath=`echo ../../dist/*.OBJ/lib | cut -f1 -d' '` + savedir=`pwd` + cd $svrcorelibpath + abs_svrcorelibpath=`pwd` + cd $savedir + svrcoreincpath=../../dist/public/svrcore + savedir=`pwd` + cd $svrcoreincpath + abs_svrcoreincpath=`pwd` + cd $savedir + if test -f "$abs_svrcoreincpath/svrcore.h" ; then + SVRCORE_CFLAGS="-I$abs_svrcoreincpath" + fi + if test -d "$abs_svrcorelibpath" ; then + SVRCORE_LIBS="-L$abs_svrcorelibpath" + fi + if test -n "$SVRCORE_CFLAGS" -a -n "$SVRCORE_LIBS" ; then + echo $ac_n "checking using in-tree SVRCORE from $svrcoreincpath $svrcorelibpath""... $ac_c" 1>&6 +echo "configure:1124: checking using in-tree SVRCORE from $svrcoreincpath $svrcorelibpath" >&5 + + + echo "$ac_t""yes" 1>&6 + elif test -n "$HAVE_SVRCORE" ; then + echo $ac_n "checking could not find in-tree SVRCORE in ../../dist""... $ac_c" 1>&6 +echo "configure:1130: checking could not find in-tree SVRCORE in ../../dist" >&5 + echo "$ac_t""no" 1>&6 + else + # If user didn't ask for it, don't complain (really!) + echo "$ac_t""no" 1>&6 + fi + fi + + if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS"; then + + if test -n "$HAVE_SVRCORE" ; then + no_svrcore="" + echo $ac_n "checking Trying pkg-config svrcore""... $ac_c" 1>&6 +echo "configure:1143: checking Trying pkg-config svrcore" >&5 + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1147: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$PKG_CONFIG" in + /*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +if test -n "$PKG_CONFIG"; then + echo "$ac_t""$PKG_CONFIG" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -n "$PKG_CONFIG"; then + if $PKG_CONFIG --exists svrcore-devel; then + echo $ac_n "checking using SVRCORE from package svrcore""... $ac_c" 1>&6 +echo "configure:1182: checking using SVRCORE from package svrcore" >&5 + SVRCORE_CFLAGS=`$PKG_CONFIG --cflags-only-I svrcore-devel` + SVRCORE_LIBS=`$PKG_CONFIG --libs-only-L svrcore-devel` + else + no_svrcore="yes" + fi + else + no_svrcore="yes" + fi + + if test -z "$no_svrcore"; then + echo "$ac_t""yes" 1>&6 + MOZ_NATIVE_SVRCORE=1 + else + echo "$ac_t""no" 1>&6 + fi + + + + + fi + + fi + fi + fi + fi +fi + +if test -n "$HAVE_SVRCORE" -a -z "$_SYSTEM_SVRCORE" ; then + if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS"; then + { echo "configure: error: --with-svrcore specified, but no svrcore could be found" 1>&2; exit 1; } + fi +fi + +# Check whether --with-system-nss or --without-system-nss was given. +if test "${with_system_nss+set}" = set; then + withval="$with_system_nss" + if test "$withval" = "yes"; then + _SYSTEM_NSS=1 + USE_NSS=1 + no_nspr=no + elif test "$withval" = "no" ; then + _SYSTEM_NSS=no + fi +else + _SYSTEM_NSS= +fi + + +if test "$_WIN32_MSVC"; then + _SYSTEM_NSS= +fi + +if test -z "$_SYSTEM_NSS" -o "$_SYSTEM_NSS" = "no" ; then + + echo $ac_n "checking for --with-nss""... $ac_c" 1>&6 +echo "configure:1238: checking for --with-nss" >&5 + # Check whether --with-nss or --without-nss was given. +if test "${with_nss+set}" = set; then + withval="$with_nss" + if test "$withval" = "yes"; then + USE_NSS=1 + echo "$ac_t""yes" 1>&6 + elif test -d "$withval" -a -d "$withval/lib" -a -d "$withval/include" ; then + USE_NSS=1 + echo "$ac_t""using $withval" 1>&6 + NSS_CFLAGS="-I$withval/include" + NSS_LIBS="-L$withval/lib" + else + echo "$ac_t""no" 1>&6 + USE_NSS= + fi +else + echo "$ac_t""no" 1>&6 +fi + + + # check for --with-nss-inc + echo $ac_n "checking for --with-nss-inc""... $ac_c" 1>&6 +echo "configure:1261: checking for --with-nss-inc" >&5 + # Check whether --with-nss-inc or --without-nss-inc was given. +if test "${with_nss_inc+set}" = set; then + withval="$with_nss_inc" + + if test -f "$withval"/nss.h + then + echo "$ac_t""using $withval" 1>&6 + NSS_CFLAGS="-I$withval" + USE_NSS=1 + else + echo + { echo "configure: error: $withval not found" 1>&2; exit 1; } + fi + +else + echo "$ac_t""no" 1>&6 +fi + + + # check for --with-nss-lib + echo $ac_n "checking for --with-nss-lib""... $ac_c" 1>&6 +echo "configure:1283: checking for --with-nss-lib" >&5 + # Check whether --with-nss-lib or --without-nss-lib was given. +if test "${with_nss_lib+set}" = set; then + withval="$with_nss_lib" + + if test -d "$withval" + then + echo "$ac_t""using $withval" 1>&6 + NSS_LIBS="-L$withval" + USE_NSS=1 + else + echo + { echo "configure: error: $withval not found" 1>&2; exit 1; } + fi + +else + echo "$ac_t""no" 1>&6 +fi + + +fi + +if test -n "$USE_NSS" -a -z "$NSS_CFLAGS" -a -z "$NSS_LIBS" ; then + no_nspr=no + if test -z "$_SYSTEM_NSS" -o "$_SYSTEM_NSS" = "no" ; then + + nsslibpath=`echo ../../dist/*.OBJ/lib | cut -f1 -d' '` + savedir=`pwd` + cd $nsslibpath + abs_nsslibpath=`pwd` + cd $savedir + nssincpath=../../dist/public/nss + savedir=`pwd` + cd $nssincpath + abs_nssincpath=`pwd` + cd $savedir + if test -f "$abs_nssincpath/nss.h" ; then + NSS_CFLAGS="-I$abs_nssincpath" + fi + if test -d "$abs_nsslibpath" ; then + NSS_LIBS="-L$abs_nsslibpath" + fi + if test -n "$NSS_CFLAGS" -a -n "$NSS_LIBS" ; then + echo $ac_n "checking using in-tree NSS from $nssincpath $nsslibpath""... $ac_c" 1>&6 +echo "configure:1327: checking using in-tree NSS from $nssincpath $nsslibpath" >&5 + + + echo "$ac_t""yes" 1>&6 + else + echo $ac_n "checking could not find in-tree NSS in ../../dist""... $ac_c" 1>&6 +echo "configure:1333: checking could not find in-tree NSS in ../../dist" >&5 + echo "$ac_t""no" 1>&6 + fi + + fi + if test -z "$NSS_CFLAGS" -a "$_SYSTEM_NSS" != "no" ; then + +# Check whether --with-nss-prefix or --without-nss-prefix was given. +if test "${with_nss_prefix+set}" = set; then + withval="$with_nss_prefix" + nss_config_prefix="$withval" +else + nss_config_prefix="" +fi + + +# Check whether --with-nss-exec-prefix or --without-nss-exec-prefix was given. +if test "${with_nss_exec_prefix+set}" = set; then + withval="$with_nss_exec_prefix" + nss_config_exec_prefix="$withval" +else + nss_config_exec_prefix="" +fi + + + if test -n "$nss_config_exec_prefix"; then + nss_config_args="$nss_config_args --exec-prefix=$nss_config_exec_prefix" + if test -z "$NSS_CONFIG"; then + NSS_CONFIG=$nss_config_exec_prefix/bin/nss-config + fi + fi + if test -n "$nss_config_prefix"; then + nss_config_args="$nss_config_args --prefix=$nss_config_prefix" + if test -z "$NSS_CONFIG"; then + NSS_CONFIG=$nss_config_prefix/bin/nss-config + fi + fi + + if test -z "$NSS_CONFIG" ; then + unset ac_cv_path_NSS_CONFIG + # Extract the first word of "nss-config", so it can be a program name with args. +set dummy nss-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1376: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_NSS_CONFIG'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$NSS_CONFIG" in + /*) + ac_cv_path_NSS_CONFIG="$NSS_CONFIG" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_NSS_CONFIG="$NSS_CONFIG" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_NSS_CONFIG="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NSS_CONFIG" && ac_cv_path_NSS_CONFIG="no" + ;; +esac +fi +NSS_CONFIG="$ac_cv_path_NSS_CONFIG" +if test -n "$NSS_CONFIG"; then + echo "$ac_t""$NSS_CONFIG" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + min_nss_version=3.9.0 + echo $ac_n "checking for NSS - version >= $min_nss_version (skipping)""... $ac_c" 1>&6 +echo "configure:1411: checking for NSS - version >= $min_nss_version (skipping)" >&5 + fi + + no_nss="" + if test "$NSS_CONFIG" = "no"; then + echo $ac_n "checking nss-config not found""... $ac_c" 1>&6 +echo "configure:1417: checking nss-config not found" >&5 + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1421: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$PKG_CONFIG" in + /*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +if test -n "$PKG_CONFIG"; then + echo "$ac_t""$PKG_CONFIG" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -n "$PKG_CONFIG"; then + if $PKG_CONFIG --exists nss; then + echo $ac_n "checking using NSS from package nss""... $ac_c" 1>&6 +echo "configure:1456: checking using NSS from package nss" >&5 + NSS_CFLAGS=`$PKG_CONFIG --cflags-only-I nss` + NSS_LIBS=`$PKG_CONFIG --libs-only-L nss` + elif $PKG_CONFIG --exists mozilla-nss; then + echo $ac_n "checking using NSS from package mozilla-nss""... $ac_c" 1>&6 +echo "configure:1461: checking using NSS from package mozilla-nss" >&5 + NSS_CFLAGS=`$PKG_CONFIG --cflags-only-I mozilla-nss` + NSS_LIBS=`$PKG_CONFIG --libs-only-L mozilla-nss` + else + { echo "configure: error: system NSS not found" 1>&2; exit 1; } + no_nss="yes" + fi + else + no_nss="yes" + fi + else + echo $ac_n "checking using NSS from $NSS_CONFIG""... $ac_c" 1>&6 +echo "configure:1473: checking using NSS from $NSS_CONFIG" >&5 + NSS_CFLAGS=`$NSS_CONFIG $nss_config_args --cflags` + NSS_LIBS=`$NSS_CONFIG $nss_config_args --libs` + + nss_config_major_version=`$NSS_CONFIG $nss_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + nss_config_minor_version=`$NSS_CONFIG $nss_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + nss_config_micro_version=`$NSS_CONFIG $nss_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + fi + + if test -z "$no_nss"; then + echo "$ac_t""yes" 1>&6 + MOZ_NATIVE_NSS=1 + else + echo "$ac_t""no" 1>&6 + fi + + + + + + + fi +fi + +if test -n "$USE_NSS" -a -z "$NSS_CFLAGS" -a -z "$NSS_LIBS" ; then + { echo "configure: error: Need to use NSS but no NSS was found" 1>&2; exit 1; } +fi + +# Check whether --with-system-nspr or --without-system-nspr was given. +if test "${with_system_nspr+set}" = set; then + withval="$with_system_nspr" + if test "$withval" = "yes"; then + _SYSTEM_NSPR=1 + no_nspr=no + elif test "$withval" = "no"; then + _SYSTEM_NSPR=no + fi +else + _SYSTEM_NSPR= +fi + + +if test "$_WIN32_MSVC"; then + _SYSTEM_NSPR=no +fi + +if test -z "$_SYSTEM_NSPR" -o "$_SYSTEM_NSPR" = "no" ; then + + # check for --with-nspr + echo $ac_n "checking for --with-nspr""... $ac_c" 1>&6 +echo "configure:1526: checking for --with-nspr" >&5 + # Check whether --with-nspr or --without-nspr was given. +if test "${with_nspr+set}" = set; then + withval="$with_nspr" + + if test "$withval" = "no" ; then + echo "$ac_t""no" 1>&6 + no_nspr="yes" + elif test "$withval" = "yes" ; then + echo "$ac_t""yes" 1>&6 + no_nspr="no" + elif test -f "$withval"/include/nspr.h -a -d "$withval"/lib + then + echo "$ac_t""using $withval" 1>&6 + NSPR_CFLAGS="-I$withval/include" + NSPR_LIBS="-L$withval/lib" + else + echo + { echo "configure: error: $withval not found" 1>&2; exit 1; } + fi + +else + echo "$ac_t""no" 1>&6 +fi + + + # check for --with-nspr-inc + echo $ac_n "checking for --with-nspr-inc""... $ac_c" 1>&6 +echo "configure:1554: checking for --with-nspr-inc" >&5 + # Check whether --with-nspr-inc or --without-nspr-inc was given. +if test "${with_nspr_inc+set}" = set; then + withval="$with_nspr_inc" + + if test -f "$withval"/nspr.h + then + echo "$ac_t""using $withval" 1>&6 + NSPR_CFLAGS="-I$withval" + else + echo + { echo "configure: error: $withval not found" 1>&2; exit 1; } + fi + +else + echo "$ac_t""no" 1>&6 +fi + + + # check for --with-nspr-lib + echo $ac_n "checking for --with-nspr-lib""... $ac_c" 1>&6 +echo "configure:1575: checking for --with-nspr-lib" >&5 + # Check whether --with-nspr-lib or --without-nspr-lib was given. +if test "${with_nspr_lib+set}" = set; then + withval="$with_nspr_lib" + + if test -d "$withval" + then + echo "$ac_t""using $withval" 1>&6 + NSPR_LIBS="-L$withval" + else + echo + { echo "configure: error: $withval not found" 1>&2; exit 1; } + fi + +else + echo "$ac_t""no" 1>&6 +fi + + +fi + +if test "$no_nspr" = "no" -a -z "$NSPR_CFLAGS" -a -z "$NSPR_LIBS" ; then + if test -z "$_SYSTEM_NSPR" -o "$_SYSTEM_NSPR" = "no" ; then + + echo $ac_n "checking checking for in-tree NSPR from ../../dist""... $ac_c" 1>&6 +echo "configure:1600: checking checking for in-tree NSPR from ../../dist" >&5 + for nsprpath in "../../dist" "../../dist"/*.OBJ ; do + savedir=`pwd` + cd $nsprpath + abs_nsprpath=`pwd` + cd $savedir + if test -f "$abs_nsprpath/include/nspr/nspr.h" ; then + NSPR_CFLAGS="-I$abs_nsprpath/include/nspr" + elif test -f "$abs_nsprpath/include/nspr.h" ; then + NSPR_CFLAGS="-I$abs_nsprpath/include" + fi + if test -d "$abs_nsprpath/lib" ; then + NSPR_LIBS="-L$abs_nsprpath/lib" + fi + if test -n "$NSPR_CFLAGS" -a -n "$NSPR_LIBS" ; then + break + fi + done + if test -n "$NSPR_CFLAGS" -a -n "$NSPR_LIBS" ; then + + + echo "$ac_t""yes" 1>&6 + else + echo "$ac_t""no" 1>&6 + fi + + fi + if test -z "$NSPR_CFLAGS" -a "$_SYSTEM_NSPR" != "no" ; then + +# Check whether --with-nspr-prefix or --without-nspr-prefix was given. +if test "${with_nspr_prefix+set}" = set; then + withval="$with_nspr_prefix" + nspr_config_prefix="$withval" +else + nspr_config_prefix="" +fi + + +# Check whether --with-nspr-exec-prefix or --without-nspr-exec-prefix was given. +if test "${with_nspr_exec_prefix+set}" = set; then + withval="$with_nspr_exec_prefix" + nspr_config_exec_prefix="$withval" +else + nspr_config_exec_prefix="" +fi + + + if test -n "$nspr_config_exec_prefix"; then + nspr_config_args="$nspr_config_args --exec-prefix=$nspr_config_exec_prefix" + if test -z "$NSPR_CONFIG"; then + NSPR_CONFIG=$nspr_config_exec_prefix/bin/nspr-config + fi + fi + if test -n "$nspr_config_prefix"; then + nspr_config_args="$nspr_config_args --prefix=$nspr_config_prefix" + if test -z "$NSPR_CONFIG"; then + NSPR_CONFIG=$nspr_config_prefix/bin/nspr-config + fi + fi + + if test -z "$NSPR_CONFIG" ; then + unset ac_cv_path_NSPR_CONFIG + # Extract the first word of "nspr-config", so it can be a program name with args. +set dummy nspr-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1665: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_NSPR_CONFIG'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$NSPR_CONFIG" in + /*) + ac_cv_path_NSPR_CONFIG="$NSPR_CONFIG" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_NSPR_CONFIG="$NSPR_CONFIG" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_NSPR_CONFIG="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NSPR_CONFIG" && ac_cv_path_NSPR_CONFIG="no" + ;; +esac +fi +NSPR_CONFIG="$ac_cv_path_NSPR_CONFIG" +if test -n "$NSPR_CONFIG"; then + echo "$ac_t""$NSPR_CONFIG" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + min_nspr_version=4.0.0 + echo $ac_n "checking for NSPR - version >= $min_nspr_version (skipping)""... $ac_c" 1>&6 +echo "configure:1700: checking for NSPR - version >= $min_nspr_version (skipping)" >&5 + fi + + no_nspr="" + if test "$NSPR_CONFIG" = "no"; then + echo $ac_n "checking nspr-config not found""... $ac_c" 1>&6 +echo "configure:1706: checking nspr-config not found" >&5 + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1710: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$PKG_CONFIG" in + /*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +if test -n "$PKG_CONFIG"; then + echo "$ac_t""$PKG_CONFIG" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -n "$PKG_CONFIG"; then + if $PKG_CONFIG --exists nspr; then + echo $ac_n "checking using NSPR from package nspr""... $ac_c" 1>&6 +echo "configure:1745: checking using NSPR from package nspr" >&5 + NSPR_CFLAGS=`$PKG_CONFIG --cflags-only-I nspr` + NSPR_LIBS=`$PKG_CONFIG --libs-only-L nspr` + elif $PKG_CONFIG --exists mozilla-nspr; then + echo $ac_n "checking using NSPR from package mozilla-nspr""... $ac_c" 1>&6 +echo "configure:1750: checking using NSPR from package mozilla-nspr" >&5 + NSPR_CFLAGS=`$PKG_CONFIG --cflags-only-I mozilla-nspr` + NSPR_LIBS=`$PKG_CONFIG --libs-only-L mozilla-nspr` + else + echo $ac_n "checking system NSPR not found""... $ac_c" 1>&6 +echo "configure:1755: checking system NSPR not found" >&5 + no_nspr="yes" + fi + else + no_nspr="yes" + fi + else + echo $ac_n "checking using NSPR from $NSPR_CONFIG""... $ac_c" 1>&6 +echo "configure:1763: checking using NSPR from $NSPR_CONFIG" >&5 + NSPR_CFLAGS=`$NSPR_CONFIG $nspr_config_args --cflags` + NSPR_LIBS=`$NSPR_CONFIG $nspr_config_args --libs` + + nspr_config_major_version=`$NSPR_CONFIG $nspr_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + nspr_config_minor_version=`$NSPR_CONFIG $nspr_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + nspr_config_micro_version=`$NSPR_CONFIG $nspr_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + fi + + if test -z "$no_nspr"; then + echo "$ac_t""yes" 1>&6 + MOZ_NATIVE_NSPR=1 + else + echo "$ac_t""no" 1>&6 + fi + + + + + + + fi +fi + +if test -z "$NSPR_CFLAGS" -o -z "$NSPR_LIBS" ; then + if test -n "$MOZILLA_CLIENT" ; then + NSPR_CFLAGS='-I$(DIST)/include/nspr' + NSPR_LIBS='-L$(DIST)/lib '"-lplds$NSPR_VERSION -lplc$NSPR_VERSION -lnspr$NSPR_VERSION" + if test "$_WIN32_MSVC"; then + NSPR_LIBS='$(DIST)/lib/nspr'$NSPR_VERSION'.lib $(DIST)/lib/plc'$NSPR_VERSION'.lib $(DIST)/lib/plds'$NSPR_VERSION'.lib ' + fi + LIBS_ALREADY_SET=1 + + elif test "$no_nspr" = "no" ; then + { echo "configure: error: Need to use NSPR but no NSPR was found" 1>&2; exit 1; } + fi +fi + + +case "$target" in +*-cygwin*) USE_WINDOWS_PATHS=1 ;; +*-mingw*) CONVERT_LIBPATH=1 ;; +esac + +if test -n "$_WIN32_MSVC" -a -n "$USE_WINDOWS_PATHS" ; then + if test -n "$NSPR_CFLAGS" -a -z "$LIBS_ALREADY_SET" ; then + path=`echo $NSPR_CFLAGS | sed -e 's/^-I//'` + path=`cygpath -m $path` + NSPR_CFLAGS="/I$path" + fi + if test -n "$NSPR_LIBS" -a -z "$LIBS_ALREADY_SET" ; then + path=`echo $NSPR_LIBS | sed -e 's/^-L//'` + path=`cygpath -m $path` + NSPR_LIBS="/LIBPATH:$path" + fi + + if test -n "$NSS_CFLAGS" ; then + path=`echo $NSS_CFLAGS | sed -e 's/^-I//'` + path=`cygpath -m $path` + NSS_CFLAGS="/I$path" + fi + + if test -n "$NSS_LIBS" ; then + path=`echo $NSS_LIBS | sed -e 's/^-L//'` + path=`cygpath -m $path` + NSS_LIBS="/LIBPATH:$path" + fi + + if test -n "$SVRCORE_CFLAGS" ; then + path=`echo $SVRCORE_CFLAGS | sed -e 's/^-I//'` + path=`cygpath -m $path` + SVRCORE_CFLAGS="/I$path" + fi + + if test -n "$SVRCORE_LIBS" ; then + path=`echo $SVRCORE_LIBS | sed -e 's/^-L//'` + path=`cygpath -m $path` + SVRCORE_LIBS="/LIBPATH:$path" + fi +fi + +if test -n "$_WIN32_MSVC" -a -n "$NSPR_LIBS" -a -n "$CONVERT_LIBPATH" -a -z "$LIBS_ALREADY_SET" ; then + path=`echo $NSPR_LIBS | sed -e 's/^-L//'` + path=`cd "$path" ; pwd -W` + NSPR_LIBS="/LIBPATH:$path" +fi +if test -n "$_WIN32_MSVC" -a -n "$NSS_LIBS" -a -n "$CONVERT_LIBPATH" ; then + path=`echo $NSS_LIBS | sed -e 's/^-L//'` + path=`cd "$path" ; pwd -W` + NSS_LIBS="/LIBPATH:$path" +fi +if test -n "$_WIN32_MSVC" -a -n "$SVRCORE_LIBS" -a -n "$CONVERT_LIBPATH" ; then + path=`echo $SVRCORE_LIBS | sed -e 's/^-L//'` + path=`cd "$path" ; pwd -W` + SVRCORE_LIBS="/LIBPATH:$path" +fi + +case "$target" in + +*-aix*) + case "${target_os}" in + aix3.2*) + USE_NSPR_THREADS=1 + ;; + *) + USE_PTHREADS=1 + ;; + esac + ;; + +esac + +if test -z "$CC"; then + case "$target" in + + *-aix*) + if test -z "$USE_NSPR_THREADS"; then + CC=xlC_r + else + CC=xlC + fi + ;; + + *-hpux*) + CC=cc + ;; + + *-irix*) + CC=cc + ;; + + *-osf*) + CC=cc + ;; + + *-solaris*) + CC=cc + ;; + + esac +fi + +if test -z "$CXX"; then + case "$target" in + + *-aix*) + if test -z "$USE_NSPR_THREADS"; then + CXX=xlC_r + else + CXX=xlC + fi + ;; + + *-hpux*) + case "${target_os}" in + hpux10.30) + CXX=aCC + ;; + hpux11.*) + CXX=aCC + ;; + *) + CXX=CC + ;; + esac + ;; + + *-irix*) + CXX=CC + ;; + + *-osf*) + CXX=cxx + ;; + + *-solaris*) + CXX=CC + ;; + + esac +fi + +if test -z "$SKIP_PATH_CHECKS"; then + # Extract the first word of "$WHOAMI whoami", so it can be a program name with args. +set dummy $WHOAMI whoami; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1952: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_WHOAMI'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$WHOAMI" in + /*) + ac_cv_path_WHOAMI="$WHOAMI" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_WHOAMI="$WHOAMI" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_WHOAMI="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_WHOAMI" && ac_cv_path_WHOAMI="echo not_whoami" + ;; +esac +fi +WHOAMI="$ac_cv_path_WHOAMI" +if test -n "$WHOAMI"; then + echo "$ac_t""$WHOAMI" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +fi + +if test -n "$MOZ_DEBUG"; then + cat >> confdefs.h <<\EOF +#define DEBUG 1 +EOF + + DEFINES="$DEFINES -UNDEBUG" + case "${target_os}" in + beos*) + DEFINES="$DEFINES -DDEBUG_${USER}" + ;; + msvc*|mks*|cygwin*|mingw*|os2*) + DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`" + ;; + *) + DEFINES="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_`$WHOAMI`" + ;; + esac + MFLAGS="BUILD_DEBUG=full" +else + cat >> confdefs.h <<\EOF +#define NDEBUG 1 +EOF + + DEFINES="$DEFINES -UDEBUG" + MFLAGS="BUILD_DEBUG=optimize" +fi + +if test -n "$MOZILLA_CLIENT"; then + NSINSTALL='$(dist_bindir)/nsinstall' +fi + +if test -z "$SKIP_COMPILER_CHECKS"; then +cross_compiling=no +if test -n "$host" ; then + case $target in + *-darwin*) + if test "$host" != "$target" ; then + cross_compiling=yes + fi + ;; + *) + if test "$host" = "$build" ; then + cross_compiling=no + elif test "$host" != "$target" -o "$host" != "$build" ; then + cross_compiling=yes + fi + ;; + esac +fi +if test "$cross_compiling" = "no"; then + for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2042: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CXX="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CXX="$ac_cv_prog_CXX" +if test -n "$CXX"; then + echo "$ac_t""$CXX" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$CXX" && break +done +test -n "$CXX" || CXX="gcc" + + +echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:2074: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 + +ac_ext=C +# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cxx_cross + +cat > conftest.$ac_ext << EOF + +#line 2085 "configure" +#include "confdefs.h" + +int main(){return(0);} +EOF +if { (eval echo configure:2090: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cxx_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cxx_cross=no + else + ac_cv_prog_cxx_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cxx_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6 +if test $ac_cv_prog_cxx_works = no; then + { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:2116: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 +cross_compiling=$ac_cv_prog_cxx_cross + +echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 +echo "configure:2121: checking whether we are using GNU C++" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.C <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:2130: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gxx=yes +else + ac_cv_prog_gxx=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gxx" 1>&6 + +if test $ac_cv_prog_gxx = yes; then + GXX=yes +else + GXX= +fi + +ac_test_CXXFLAGS="${CXXFLAGS+set}" +ac_save_CXXFLAGS="$CXXFLAGS" +CXXFLAGS= +echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 +echo "configure:2149: checking whether ${CXX-g++} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.cc +if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then + ac_cv_prog_cxx_g=yes +else + ac_cv_prog_cxx_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6 +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS="$ac_save_CXXFLAGS" +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi + +for ac_declaration in \ + ''\ + '#include <stdlib.h>' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat > conftest.$ac_ext <<EOF +#line 2190 "configure" +#include "confdefs.h" +#include <stdlib.h> +$ac_declaration +int main() { +exit (42); +; return 0; } +EOF +if { (eval echo configure:2198: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + continue +fi +rm -f conftest* + cat > conftest.$ac_ext <<EOF +#line 2208 "configure" +#include "confdefs.h" +$ac_declaration +int main() { +exit (42); +; return 0; } +EOF +if { (eval echo configure:2215: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + + + if test "$CXX" = "cl" -a -z "$CC"; then + CC=$CXX + else + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2237: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2267: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2318: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:2350: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 2361 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:2366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:2392: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:2397: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2406: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:2425: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + + fi + echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:2458: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext <<EOF +#line 2473 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2479: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext <<EOF +#line 2490 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2496: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext <<EOF +#line 2507 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2513: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2540: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + for ac_prog in as +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2572: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_AS'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$AS" in + /*) + ac_cv_path_AS="$AS" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_AS="$AS" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_AS="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +AS="$ac_cv_path_AS" +if test -n "$AS"; then + echo "$ac_t""$AS" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$AS" && break +done +test -n "$AS" || AS="$CC" + + for ac_prog in ar +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2613: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_AR'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$AR" in + /*) + ac_cv_path_AR="$AR" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_AR="$AR" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_AR="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +AR="$ac_cv_path_AR" +if test -n "$AR"; then + echo "$ac_t""$AR" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$AR" && break +done +test -n "$AR" || AR="echo not_ar" + + for ac_prog in ld link +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2654: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$LD" in + /*) + ac_cv_path_LD="$LD" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_LD="$LD" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_LD="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +LD="$ac_cv_path_LD" +if test -n "$LD"; then + echo "$ac_t""$LD" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$LD" && break +done +test -n "$LD" || LD="echo not_ld" + + for ac_prog in strip +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2695: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_STRIP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$STRIP" in + /*) + ac_cv_path_STRIP="$STRIP" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_STRIP="$STRIP" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_STRIP="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +STRIP="$ac_cv_path_STRIP" +if test -n "$STRIP"; then + echo "$ac_t""$STRIP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$STRIP" && break +done +test -n "$STRIP" || STRIP="echo not_strip" + + for ac_prog in windres +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2736: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_WINDRES'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$WINDRES" in + /*) + ac_cv_path_WINDRES="$WINDRES" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_WINDRES="$WINDRES" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_WINDRES="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +WINDRES="$ac_cv_path_WINDRES" +if test -n "$WINDRES"; then + echo "$ac_t""$WINDRES" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$WINDRES" && break +done +test -n "$WINDRES" || WINDRES="echo not_windres" + + if test -z "$HOST_CC"; then + HOST_CC="$CC" + fi + if test -z "$HOST_CFLAGS"; then + HOST_CFLAGS="$CFLAGS" + fi +else + echo "cross compiling from $host to $target" + + _SAVE_CC="$CC" + _SAVE_CFLAGS="$CFLAGS" + _SAVE_LDFLAGS="$LDFLAGS" + + echo $ac_n "checking for $host compiler""... $ac_c" 1>&6 +echo "configure:2786: checking for $host compiler" >&5 + for ac_prog in gcc cc /usr/ucb/cc +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2792: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_HOST_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$HOST_CC"; then + ac_cv_prog_HOST_CC="$HOST_CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_HOST_CC="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +HOST_CC="$ac_cv_prog_HOST_CC" +if test -n "$HOST_CC"; then + echo "$ac_t""$HOST_CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$HOST_CC" && break +done +test -n "$HOST_CC" || HOST_CC="""" + + if test -z "$HOST_CC"; then + { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } + fi + echo "$ac_t""$HOST_CC" 1>&6 + if test -z "$HOST_CFLAGS"; then + HOST_CFLAGS="$CFLAGS" + fi + if test -z "$HOST_LDFLAGS"; then + HOST_LDFLAGS="$LDFLAGS" + fi + + CC=$_SAVE_CC + CFLAGS=$_SAVE_CFLAGS + LDFLAGS=$_SAVE_LDFLAGS + + case "$build:$target" in + powerpc-apple-darwin8*:i?86-apple-darwin*) + _SAVE_CFLAGS=$CFLAGS + _SAVE_CXXFLAGS=$CXXLAGS + CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS" + CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS" + ;; + esac + + for ac_prog in $CC "${target_alias}-gcc" "${target}-gcc" +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2851: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$CC" && break +done +test -n "$CC" || CC="echo" + + unset ac_cv_prog_CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2885: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2915: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2966: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:2998: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 3009 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:3014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:3040: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:3045: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:3054: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:3073: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + + for ac_prog in $CXX "${target_alias}-g++" "${target}-g++" +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:3109: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CXX="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CXX="$ac_cv_prog_CXX" +if test -n "$CXX"; then + echo "$ac_t""$CXX" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$CXX" && break +done +test -n "$CXX" || CXX="echo" + + unset ac_cv_prog_CXX + for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:3145: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CXX="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CXX="$ac_cv_prog_CXX" +if test -n "$CXX"; then + echo "$ac_t""$CXX" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$CXX" && break +done +test -n "$CXX" || CXX="gcc" + + +echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:3177: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 + +ac_ext=C +# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cxx_cross + +cat > conftest.$ac_ext << EOF + +#line 3188 "configure" +#include "confdefs.h" + +int main(){return(0);} +EOF +if { (eval echo configure:3193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cxx_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cxx_cross=no + else + ac_cv_prog_cxx_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cxx_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6 +if test $ac_cv_prog_cxx_works = no; then + { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:3219: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 +cross_compiling=$ac_cv_prog_cxx_cross + +echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 +echo "configure:3224: checking whether we are using GNU C++" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.C <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:3233: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gxx=yes +else + ac_cv_prog_gxx=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gxx" 1>&6 + +if test $ac_cv_prog_gxx = yes; then + GXX=yes +else + GXX= +fi + +ac_test_CXXFLAGS="${CXXFLAGS+set}" +ac_save_CXXFLAGS="$CXXFLAGS" +CXXFLAGS= +echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 +echo "configure:3252: checking whether ${CXX-g++} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.cc +if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then + ac_cv_prog_cxx_g=yes +else + ac_cv_prog_cxx_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6 +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS="$ac_save_CXXFLAGS" +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi + +for ac_declaration in \ + ''\ + '#include <stdlib.h>' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat > conftest.$ac_ext <<EOF +#line 3293 "configure" +#include "confdefs.h" +#include <stdlib.h> +$ac_declaration +int main() { +exit (42); +; return 0; } +EOF +if { (eval echo configure:3301: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + continue +fi +rm -f conftest* + cat > conftest.$ac_ext <<EOF +#line 3311 "configure" +#include "confdefs.h" +$ac_declaration +int main() { +exit (42); +; return 0; } +EOF +if { (eval echo configure:3318: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + + + + case "$build:$target" in + powerpc-apple-darwin8*:i?86-apple-darwin*) + CFLAGS=$_SAVE_CFLAGS + CXXFLAGS=$_SAVE_CXXFLAGS + ;; + esac + + for ac_prog in $RANLIB "${target_alias}-ranlib" "${target}-ranlib" +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:3347: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$RANLIB" && break +done +test -n "$RANLIB" || RANLIB="echo" + + for ac_prog in $AR "${target_alias}-ar" "${target}-ar" +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:3382: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AR="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +AR="$ac_cv_prog_AR" +if test -n "$AR"; then + echo "$ac_t""$AR" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$AR" && break +done +test -n "$AR" || AR="echo" + + for ac_prog in $AS "${target_alias}-as" "${target}-as" +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:3417: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AS="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +AS="$ac_cv_prog_AS" +if test -n "$AS"; then + echo "$ac_t""$AS" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$AS" && break +done +test -n "$AS" || AS="echo" + + for ac_prog in $LD "${target_alias}-ld" "${target}-ld" +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:3452: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$LD"; then + ac_cv_prog_LD="$LD" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_LD="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +LD="$ac_cv_prog_LD" +if test -n "$LD"; then + echo "$ac_t""$LD" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$LD" && break +done +test -n "$LD" || LD="echo" + + for ac_prog in $STRIP "${target_alias}-strip" "${target}-strip" +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:3487: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_STRIP="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +STRIP="$ac_cv_prog_STRIP" +if test -n "$STRIP"; then + echo "$ac_t""$STRIP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$STRIP" && break +done +test -n "$STRIP" || STRIP="echo" + + for ac_prog in $WINDRES "${target_alias}-windres" "${target}-windres" +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:3522: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$WINDRES"; then + ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_WINDRES="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +WINDRES="$ac_cv_prog_WINDRES" +if test -n "$WINDRES"; then + echo "$ac_t""$WINDRES" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$WINDRES" && break +done +test -n "$WINDRES" || WINDRES="echo" + +fi + +if test "$GCC" = "yes"; then + GNU_CC=1 +fi +if test "$GXX" = "yes"; then + GNU_CXX=1 +fi +if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then + GNU_AS=1 +fi +rm -f a.out + +case "$build:$target" in + i?86-apple-darwin*:powerpc-apple-darwin*) + cross_compiling=yes + ;; +esac + +if test "$cross_compiling" = "yes"; then + CROSS_COMPILE=1 +else + CROSS_COMPILE= +fi + +echo $ac_n "checking for gcc -pipe support""... $ac_c" 1>&6 +echo "configure:3578: checking for gcc -pipe support" >&5 +if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then + echo '#include <stdio.h>' > dummy-hello.c + echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c + ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5 + cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5 + if test $? = 0; then + _res_as_stdin="yes" + else + _res_as_stdin="no" + fi + if test "$_res_as_stdin" = "yes"; then + _SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -pipe" + cat > conftest.$ac_ext <<EOF +#line 3593 "configure" +#include "confdefs.h" + #include <stdio.h> +int main() { +printf("Hello World\n"); +; return 0; } +EOF +if { (eval echo configure:3600: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + _res_gcc_pipe="yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + _res_gcc_pipe="no" +fi +rm -f conftest* + CFLAGS=$_SAVE_CFLAGS + fi + if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then + _res="yes"; + CFLAGS="$CFLAGS -pipe" + CXXFLAGS="$CXXFLAGS -pipe" + else + _res="no" + fi + rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out + echo "$ac_t""$_res" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +fi # SKIP_COMPILER_CHECKS + +if test -z "$SKIP_PATH_CHECKS"; then + for ac_prog in perl5 perl +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:3633: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$PERL" in + /*) + ac_cv_path_PERL="$PERL" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_PERL="$PERL" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_PERL="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +PERL="$ac_cv_path_PERL" +if test -n "$PERL"; then + echo "$ac_t""$PERL" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$PERL" && break +done +test -n "$PERL" || PERL="echo not_perl" + +elif test -z "$PERL"; then + PERL=perl +fi + +OBJ_SUFFIX=o +LIB_SUFFIX=a +LIB_PREFIX=lib +DLL_SUFFIX=so +ASM_SUFFIX=s +MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@' +AR_FLAGS='cr $@' +AS='$(CC)' +ASFLAGS='$(CFLAGS)' + +if test -n "$CROSS_COMPILE"; then + OS_ARCH=`echo $target_os | sed -e 's|/|_|g'` + OS_RELEASE= + OS_TEST="${target_cpu}" + case "${target_os}" in + linux*) OS_ARCH=Linux ;; + solaris*) OS_ARCH=SunOS OS_RELEASE=5 ;; + mingw*) OS_ARCH=WINNT ;; + darwin*) OS_ARCH=Darwin ;; + esac +else + OS_ARCH=`uname -s | sed -e 's|/|_|g'` + OS_RELEASE=`uname -r` + OS_TEST=`uname -m` +fi + +if test "$OS_ARCH" = "IRIX64"; then + OS_ARCH=IRIX +fi + +if test "$OS_ARCH" = "Linux"; then + OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'` + OS_RELEASE=`echo $OS_RELEASE | awk -F. '{ print $1 "." $2 }'` +fi + +####################################################################### +# Master "Core Components" macros for getting the OS target # +####################################################################### + +# +# Note: OS_TARGET should be specified on the command line for gmake. +# When OS_TARGET=WIN95 is specified, then a Windows 95 target is built. +# The difference between the Win95 target and the WinNT target is that +# the WinNT target uses Windows NT specific features not available +# in Windows 95. The Win95 target will run on Windows NT, but (supposedly) +# at lesser performance (the Win95 target uses threads; the WinNT target +# uses fibers). +# +# When OS_TARGET=WIN16 is specified, then a Windows 3.11 (16bit) target +# is built. See: win16_3.11.mk for lots more about the Win16 target. +# +# If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no +# cross-compilation. +# + +# +# The following hack allows one to build on a WIN95 machine (as if +# s/he were cross-compiling on a WINNT host for a WIN95 target). +# It also accomodates for MKS's uname.exe. If you never intend +# to do development on a WIN95 machine, you don't need this hack. +# +case "$OS_ARCH" in +WIN95) + OS_ARCH=WINNT + OS_TARGET=WIN95 + ;; +Windows_95) + OS_ARCH=Windows_NT + OS_TARGET=WIN95 + ;; +Windows_98) + OS_ARCH=Windows_NT + OS_TARGET=WIN95 + ;; +CYGWIN_9*|CYGWIN_ME*) + OS_ARCH='CYGWIN_NT-4.0' + OS_TARGET=WIN95 + ;; +OS_2) + OS_ARCH=OS2 + OS_TARGET=OS2 + ;; +WINCE) + OS_ARCH=WINCE + OS_TARGET=WINCE + ;; +esac + +# +# On WIN32, we also define the variable CPU_ARCH. +# + +case "$OS_ARCH" in +WINNT) + CPU_ARCH=`uname -p` + if test "$CPU_ARCH" = "I386"; then + CPU_ARCH=x86 + fi + ;; +Windows_NT) +# +# If uname -s returns "Windows_NT", we assume that we are using +# the uname.exe in MKS toolkit. +# +# The -r option of MKS uname only returns the major version number. +# So we need to use its -v option to get the minor version number. +# Moreover, it doesn't have the -p option, so we need to use uname -m. +# + OS_ARCH=WINNT + OS_MINOR_RELEASE=`uname -v` + if test "$OS_MINOR_RELEASE" = "00"; then + OS_MINOR_RELEASE=0 + fi + OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}" + CPU_ARCH=`uname -m` + # + # MKS's uname -m returns "586" on a Pentium machine. + # + if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then + CPU_ARCH=x86 + fi + ;; +CYGWIN32_NT|CYGWIN_NT*|MINGW*_NT*) +# +# If uname -s returns "CYGWIN_NT-4.0", we assume that we are using +# the uname.exe in the Cygwin tools. +# Prior to the Beta 20 release, Cygwin was called GNU-Win32. +# If uname -s returns "CYGWIN32/NT", we assume that we are using +# the uname.exe in the GNU-Win32 tools. +# If uname -s returns MINGW32_NT-5.1, we assume that we are using +# the uname.exe in the MSYS tools. +# + OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'` + OS_ARCH=WINNT + CPU_ARCH=`uname -m` + # + # Cygwin's uname -m returns "i686" on a Pentium Pro machine. + # + if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then + CPU_ARCH=x86 + fi + ;; +esac + +if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then + OS_TARGET=WIN95 + if test -n "$MOZ_DEBUG"; then + USE_DEBUG_RTL=1 + fi +fi +if test -z "$OS_TARGET"; then + OS_TARGET=$OS_ARCH +fi +if test "$OS_TARGET" = "WIN95"; then + OS_RELEASE="4.0" +fi +if test "$OS_TARGET" = "WIN16"; then + OS_RELEASE= +fi + +# Check whether --with-macos-sdk or --without-macos-sdk was given. +if test "${with_macos_sdk+set}" = set; then + withval="$with_macos_sdk" + MACOS_SDK_DIR=$withval +fi + + +# Check whether --enable-os2-high-mem or --disable-os2-high-mem was given. +if test "${enable_os2_high_mem+set}" = set; then + enableval="$enable_os2_high_mem" + if test "$enableval" = "no"; then + MOZ_OS2_HIGH_MEMORY= + else + MOZ_OS2_HIGH_MEMORY=1 + fi +fi + + +case "$host" in +*-mingw*) + NSINSTALL=nsinstall + WIN_TOP_SRC=`cd $srcdir && pwd -W` + ;; +*-cygwin*|*-msvc*|*-mks*) + CYGWIN_WRAPPER='sh $(topsrcdir)/config/cygwin-wrapper' + NSINSTALL='$(CYGWIN_WRAPPER) nsinstall' + if test "`${PERL} -v | grep -c cygwin 2>/dev/null`" = 0; then + PERL='$(CYGWIN_WRAPPER) perl' + fi + WIN_TOP_SRC=`cygpath -w $srcdir | sed -e 's|\\\\|/|g'` + ;; +*-beos*) + HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE" + ;; +*os2*) + ;; +*) + HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX" + ;; +esac + +DEFAULT_RPATHFLAG=..:../lib:../../lib:../../../lib:../../../../lib +# Check whether --with-rpath or --without-rpath was given. +if test "${with_rpath+set}" = set; then + withval="$with_rpath" + + if test "$withval" = "yes" ; then # set default + RPATHFLAG="$DEFAULT_RPATHFLAG" + elif test -n "$withval" ; then # user supplied + RPATHFLAG="$withval" + fi + +fi + + +case "$target" in + +*-aix*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define AIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define SYSV 1 +EOF + + DSO_LDOPTS='-brtl -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib' + ac_safe=`echo "sys/atomic_op.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for sys/atomic_op.h""... $ac_c" 1>&6 +echo "configure:3906: checking for sys/atomic_op.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 3911 "configure" +#include "confdefs.h" +#include <sys/atomic_op.h> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:3916: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define AIX_HAVE_ATOMIC_OP_H 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi + + case "${target_os}" in + aix3.2*) + cat >> confdefs.h <<\EOF +#define AIX_RENAME_SELECT 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_NO_LARGE_FILES 1 +EOF + + ;; + aix4.1*) + cat >> confdefs.h <<\EOF +#define AIX_TIMERS 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_NO_LARGE_FILES 1 +EOF + + cat >> confdefs.h <<\EOF +#define AIX4_1 1 +EOF + + MKSHLIB= + DSO_LDOPTS= + ;; + aix4.2*) + cat >> confdefs.h <<\EOF +#define AIX_TIMERS 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_OFF64_T 1 +EOF + + ;; + aix4.3*) + cat >> confdefs.h <<\EOF +#define AIX_TIMERS 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_OFF64_T 1 +EOF + + cat >> confdefs.h <<\EOF +#define AIX4_3 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_SOCKLEN_T 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_FCNTL_FILE_LOCKING 1 +EOF + + USE_IPV6=1 + ;; + *) + cat >> confdefs.h <<\EOF +#define AIX_TIMERS 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_OFF64_T 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_SOCKLEN_T 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_FCNTL_FILE_LOCKING 1 +EOF + + USE_IPV6=1 + ;; + esac + CFLAGS="$CFLAGS -qro -qroconst" + if echo "$CC" | grep -c xlC_r; then + CFLAGS="$CFLAGS -qarch=com" + fi + AIX_WRAP='$(DIST)/lib/aixwrap.o' + AIX_TMP='./_aix_tmp.o' + if test -n "$USE_64"; then + OBJECT_MODE=64 + fi + RESOLVE_LINK_SYMBOLS=1 + ;; + +*-beos*) + cat >> confdefs.h <<\EOF +#define XP_BEOS 1 +EOF + + cat >> confdefs.h <<\EOF +#define BeOS 1 +EOF + + cat >> confdefs.h <<\EOF +#define BEOS 1 +EOF + + cat >> confdefs.h <<\EOF +#define _POSIX_SOURCE 1 +EOF + + DSO_LDOPTS=-nostart + USE_BTHREADS=1 + RESOLVE_LINK_SYMBOLS=1 + case "${target_cpu}" in + i*86) + _OPTIMIZE_FLAGS=-O2 + _DEBUG_FLAGS='-gdwarf-2 -O0' + MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@' + echo $ac_n "checking for gethostbyaddr in -lbind""... $ac_c" 1>&6 +echo "configure:4058: checking for gethostbyaddr in -lbind" >&5 +ac_lib_var=`echo bind'_'gethostbyaddr | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lbind $LIBS" +cat > conftest.$ac_ext <<EOF +#line 4066 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gethostbyaddr(); + +int main() { +gethostbyaddr() +; return 0; } +EOF +if { (eval echo configure:4077: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + OS_LIBS="$OS_LIBS -lbind -lsocket" +else + echo "$ac_t""no" 1>&6 +fi + + ;; + powerpc) + CC=mwcc + CCC=mwcc + LD=mwld + DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o' + _OPTIMIZE_FLAGS=-O2 + _DEBUG_FLAGS='-g -O0' + ;; + esac + ;; + +*-bsdi*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define BSDI 1 +EOF + + cat >> confdefs.h <<\EOF +#define NEED_BSDREGEX 1 +EOF + + + CFLAGS="$CFLAGS -Wall -Wno-format" + CXXFLAGS="$CXXFLAGS -Wall -Wno-format" + + if echo "$OS_TEST" | grep -c 86 >/dev/null; then + CPU_ARCH=x86 + elif echo "$OS_TEST" | grep -c sparc >/dev/null; then + CPU_ARCH=sparc + fi + + DSO_LDOPTS=-r + + case "$target_os" in + bsdi1.1*) + cat >> confdefs.h <<\EOF +#define _PR_BSDI_JMPBUF_IS_ARRAY 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_STAT_HAS_ONLY_ST_ATIME 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_NEED_H_ERRNO 1 +EOF + + MKSHLIB= + DSO_CFLAGS= + DSO_LDOPTS= + ;; + + bsdi2.1*) + cat >> confdefs.h <<\EOF +#define _PR_TIMESPEC_HAS_TS_SEC 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_BSDI_JMPBUF_IS_ARRAY 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_DLL 1 +EOF + + cat >> confdefs.h <<\EOF +#define USE_DLFCN 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_STAT_HAS_ST_ATIMESPEC 1 +EOF + + ;; + + bsdi4.*) + cat >> confdefs.h <<\EOF +#define _PR_SELECT_CONST_TIMEVAL 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_BSDI_JMPBUF_IS_STRUCT 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_DLL 1 +EOF + + cat >> confdefs.h <<\EOF +#define USE_DLFCN 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_STAT_HAS_ST_ATIMESPEC 1 +EOF + + MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)' + DSO_CFLAGS=-fPIC + DSO_LDOPTS='-shared -soname $(@:$(OBJDIR)/%.so=%.so)' + STRIP="$STRIP -d" + case "$target_os" in + bsdi4.2*) + cat >> confdefs.h <<\EOF +#define _PR_HAVE_GETPROTO_R 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_GETPROTO_R_POINTER 1 +EOF + + ;; + esac + ;; + *) + cat >> confdefs.h <<\EOF +#define _PR_SELECT_CONST_TIMEVAL 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_BSDI_JMPBUF_IS_STRUCT 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_DLL 1 +EOF + + cat >> confdefs.h <<\EOF +#define USE_DLFCN 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_STAT_HAS_ST_ATIMESPEC 1 +EOF + + ;; + esac + + ;; + +*-darwin*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define DARWIN 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_BSD_FLOCK 1 +EOF + + CFLAGS="$CFLAGS -Wmost -fno-common" + case "${target_cpu}" in + i*86*) + cat >> confdefs.h <<\EOF +#define i386 1 +EOF + + CPU_ARCH=i386 + ;; + *) + cat >> confdefs.h <<\EOF +#define ppc 1 +EOF + + CPU_ARCH=ppc + ;; + esac + DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@' + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + STRIP="$STRIP -x -S" + DLL_SUFFIX=dylib + USE_PTHREADS=1 + + + if test "$MACOS_SDK_DIR"; then + if test ! -d "$MACOS_SDK_DIR"; then + { echo "configure: error: SDK not found. When using --with-macos-sdk, you must +specify a valid SDK. SDKs are installed when the optional cross-development +tools are selected during the Xcode/Developer Tools installation." 1>&2; exit 1; } + fi + + + CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'` + GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'` + GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'` + + GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'` + if test "$GCC_VERSION_MAJOR" -lt "4" ; then + SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks" + if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then + SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks" + fi + + SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}" + + CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}" + + CPP="$CPP -nostdinc ${SDK_C_INCLUDE}" + + MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}" + LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS" + DSO_LDOPTS="${MACOS_SDK_LIBS} $DSO_LDOPTS" + export NEXT_ROOT=$MACOS_SDK_DIR + + if test -n "$CROSS_COMPILE" ; then + HOST_CC="NEXT_ROOT= $HOST_CC" + HOST_CXX="NEXT_ROOT= $HOST_CXX" + fi + else + CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}" + + CPP="$CPP -isysroot ${MACOS_SDK_DIR}" + + if test "$GCC_VERSION_FULL" != "4.0.0" ; then + LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}" + DSO_LDOPTS="$DSO_LDOPTS -isysroot ${MACOS_SDK_DIR}" + else + LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}" + DSO_LDOPTS="$DSO_LDOPTS -Wl,-syslibroot,${MACOS_SDK_DIR}" + fi + fi + fi + ;; + +*-dgux*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_LOCAL_THREADS_ONLY 1 +EOF + + cat >> confdefs.h <<\EOF +#define SVR4 1 +EOF + + cat >> confdefs.h <<\EOF +#define SYSV 1 +EOF + + cat >> confdefs.h <<\EOF +#define DGUX 1 +EOF + + cat >> confdefs.h <<\EOF +#define _DGUX_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define _POSIX4A_DRAFT6_SOURCE 1 +EOF + + DSO_LDOPTS=-G + _OPTIMIZE_FLAGS=-O2 + _DEBUG_FLAGS= + ;; + +*-dragonfly*) + if test -z "$USE_NSPR_THREADS"; then + USE_PTHREADS=1 + fi + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define DRAGONFLY 1 +EOF + + DSO_CFLAGS=-fPIC + DSO_LDOPTS='-shared' + ;; + +*-freebsd*) + if test -z "$USE_NSPR_THREADS"; then + USE_PTHREADS=1 + fi + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define FREEBSD 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_BSD_FLOCK 1 +EOF + + CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall" + MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf` + if test "$MOZ_OBJFORMAT" = "elf"; then + DLL_SUFFIX=so + else + DLL_SUFFIX=so.1.0 + fi + DSO_CFLAGS=-fPIC + DSO_LDOPTS=-Bshareable + ;; + +*-hpux*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define HPUX 1 +EOF + + cat >> confdefs.h <<\EOF +#define _HPUX_SOURCE 1 +EOF + + if test "$OS_TEST" = "ia64" ; then + cat >> confdefs.h <<\EOF +#define ia64 1 +EOF + + DLL_SUFFIX=so + else + cat >> confdefs.h <<\EOF +#define hppa 1 +EOF + + DLL_SUFFIX=sl + fi + DSO_LDOPTS='-b +h $(notdir $@)' + if test -z "$GNU_CC"; then + CC="$CC -Ae" + CXX="$CXX -ext" + if test "$OS_RELEASE" = "B.11.23"; then + CFLAGS="$CFLAGS +Olit=all" + CXXFLAGS="$CXXFLAGS +Olit=all" + else + CFLAGS="$CFLAGS +ESlit" + CXXFLAGS="$CXXFLAGS +ESlit" + fi + DSO_CFLAGS=+Z + else + DSO_CFLAGS=-fPIC + fi + + if test -n "$MOZILLA_CLIENT"; then + DEFAULT_IMPL_STRATEGY=_EMU + fi + + if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then + cat >> confdefs.h <<\EOF +#define _PR_NEED_H_ERRNO 1 +EOF + + cat >> confdefs.h <<\EOF +#define HPUX9 1 +EOF + + DEFAULT_IMPL_STRATEGY=_EMU + USE_NSPR_THREADS=1 + fi + + if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then + cat >> confdefs.h <<\EOF +#define _PR_NO_LARGE_FILES 1 +EOF + + fi + + if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then + cat >> confdefs.h <<\EOF +#define _PR_NEED_H_ERRNO 1 +EOF + + fi + + if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then + cat >> confdefs.h <<\EOF +#define HAVE_INT_LOCALTIME_R 1 +EOF + + fi + + if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00|B.11.11|B.11.23)' >/dev/null; then + cat >> confdefs.h <<\EOF +#define HAVE_POINTER_LOCALTIME_R 1 +EOF + + fi + + if test "$OS_RELEASE" = "B.10.01"; then + cat >> confdefs.h <<\EOF +#define HPUX10 1 +EOF + + DEFAULT_IMPL_STRATEGY=_EMU + fi + + if test "$OS_RELEASE" = "B.10.10"; then + cat >> confdefs.h <<\EOF +#define HPUX10 1 +EOF + + cat >> confdefs.h <<\EOF +#define HPUX10_10 1 +EOF + + DEFAULT_IMPL_STRATEGY=_PTH + fi + + if test "$OS_RELEASE" = "B.10.20"; then + cat >> confdefs.h <<\EOF +#define HPUX10 1 +EOF + + cat >> confdefs.h <<\EOF +#define HPUX10_20 1 +EOF + + if test -z "$GNU_CC"; then + CFLAGS="$CFLAGS +DAportable +DS1.1" + CXXFLAGS="$CXXFLAGS +DAportable +DS1.1" + fi + DEFAULT_IMPL_STRATEGY=_PTH + fi + + if test "$OS_RELEASE" = "B.10.30"; then + cat >> confdefs.h <<\EOF +#define HPUX10 1 +EOF + + cat >> confdefs.h <<\EOF +#define HPUX10_30 1 +EOF + + if test -z "$GNU_CC"; then + CFLAGS="$CFLAGS +DAportable +DS1.1" + CXXFLAGS="$CXXFLAGS +DAportable +DS1.1" + fi + DEFAULT_IMPL_STRATEGY=_PTH + fi + + if echo "$OS_RELEASE" | egrep '^(B.11.00|B.11.11)' >/dev/null; then + cat >> confdefs.h <<\EOF +#define HPUX10 1 +EOF + + cat >> confdefs.h <<\EOF +#define HPUX11 1 +EOF + + cat >> confdefs.h <<\EOF +#define _LARGEFILE64_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_OFF64_T 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_FCNTL_FILE_LOCKING 1 +EOF + + if test -z "$GNU_CC"; then + if test -z "$USE_64"; then + CFLAGS="$CFLAGS +DAportable +DS2.0" + CXXFLAGS="$CXXFLAGS +DAportable +DS2.0" + else + CFLAGS="$CFLAGS +DA2.0W +DS2.0" + CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0" + fi + fi + DEFAULT_IMPL_STRATEGY=_PTH + fi + + if test "$OS_RELEASE" = "B.11.23"; then + cat >> confdefs.h <<\EOF +#define HPUX10 1 +EOF + + cat >> confdefs.h <<\EOF +#define HPUX11 1 +EOF + + cat >> confdefs.h <<\EOF +#define _LARGEFILE64_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_OFF64_T 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_FCNTL_FILE_LOCKING 1 +EOF + + if test -z "$GNU_CC"; then + if test -z "$USE_64"; then + CFLAGS="$CFLAGS +DD32" + CXXFLAGS="$CXXFLAGS +DD32" + else + CFLAGS="$CFLAGS +DD64" + CXXFLAGS="$CXXFLAGS +DD64" + fi + fi + DEFAULT_IMPL_STRATEGY=_PTH + fi + + if test "$DEFAULT_RPATHFLAG" = "$RPATHFLAG" ; then + if test "$OS_RELEASE" = "B.11.23" -o "$OS_RELEASE" = "B.11.11" ; then + # add ORIGIN to default rpath + RPATHFLAG="\\\$\$ORIGIN/../lib:\\\$\$ORIGIN/../../lib:$RPATHFLAG" + fi + fi + + if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then + USE_NSPR_THREADS=1 + USE_PTHREADS= + USE_USER_THREADS= + elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then + USE_PTHREADS=1 + if test "$USE_NSPR_THREADS"; then + USE_PTHREADS= + fi + if test "$USE_USER_PTHREADS"; then + USE_PTHREADS= + fi + fi + + ;; + +*-irix*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define IRIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define SVR4 1 +EOF + + cat >> confdefs.h <<\EOF +#define _SGI_MP_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_FCNTL_FILE_LOCKING 1 +EOF + + DSO_LDOPTS='-rdata_shared -shared' + MKSHLIB='$(LD) $(DSO_LDOPTS) -soname $(notdir $@) -o $@' + STRIP="$STRIP -f" + RESOLVE_LINK_SYMBOLS=1 + case "${target_os}" in + irix6*) + cat >> confdefs.h <<\EOF +#define IRIX6 1 +EOF + + USE_PTHREADS=1 + USE_N32=1 + ;; + irix5*) + cat >> confdefs.h <<\EOF +#define IRIX5 1 +EOF + + USE_NSPR_THREADS=1 + ;; + *) + USE_PTHREADS=1 + USE_N32=1 + ;; + esac + if test "$GNU_CC"; then + AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)' + CFLAGS="$CFLAGS -Wall -Wno-format" + _OPTIMIZE_FLAGS="-O6" + else + if test -n "$USE_N32"; then + AS='as -D_ASM $(INCLUDES) -n32' + else + AS='as -D_ASM $(INCLUDES)' + fi + CFLAGS="$CFLAGS -fullwarn -xansi" + if test "$USE_N32"; then + _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000" + else + _OPTIMIZE_FLAGS="-O -Olimit 4000" + fi + if test "$USE_MDUPDATE"; then + CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" + fi + case "$target}" in + *-irix6.*) + CFLAGS="$CFLAGS -multigot" + DSO_LDOPTS="$DSO_LDOPTS -no_unresolved" + if test "$USE_N32"; then + CFLAGS="$CFLAGS -n32 -woff 1209" + DSO_LDOPTS="$DSO_LDOPTS -n32" + else + if test "$USE_64"; then + CFLAGS="$CFLAGS -64" + else + CFLAGS="$CFLAGS -32" + fi + fi + ;; + *) + CFLAGS="$CFLAGS -xgot" + ;; + esac + fi + if test "${target_os}" = "irix5.3"; then + cat >> confdefs.h <<\EOF +#define IRIX5_3 1 +EOF + + fi + case "${target_os}" in + irix6.5) + if test -z "$GNU_CC"; then + CFLAGS="$CFLAGS -mips3" + fi + cat >> confdefs.h <<\EOF +#define _PR_HAVE_GETPROTO_R 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_GETPROTO_R_POINTER 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_SGI_PRDA_PROCMASK 1 +EOF + + ;; + irix5*) + ;; + *) + cat >> confdefs.h <<\EOF +#define _PR_HAVE_SGI_PRDA_PROCMASK 1 +EOF + + ;; + esac + ;; + +*-linux*) + if test -z "$USE_NSPR_THREADS"; then + USE_PTHREADS=1 + fi + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define _POSIX_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define _BSD_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define _SVID_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define _LARGEFILE64_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_FCNTL_FILE_LOCKING 1 +EOF + + cat >> confdefs.h <<\EOF +#define LINUX 1 +EOF + + cat >> confdefs.h <<\EOF +#define linux 1 +EOF + + LD='$(CC)' + CFLAGS="$CFLAGS -ansi -Wall" + CXXFLAGS="$CXXFLAGS -ansi -Wall" + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + DSO_CFLAGS=-fPIC + DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' + OS_LIBS="$OS_LIBS -lc" + _OPTIMIZE_FLAGS=-O2 + _DEBUG_FLAGS="-g -fno-inline" # most people on linux use gcc/gdb, and that + # combo is not yet good at debugging inlined + # functions (even when using DWARF2 as the + # debugging format) + case "$OS_TEST" in + i*86) + CPU_ARCH=x86 + ;; + *) + CPU_ARCH=$OS_TEST + ;; + esac + + case "${target_cpu}" in + alpha) + cat >> confdefs.h <<\EOF +#define _ALPHA_ 1 +EOF + + cat >> confdefs.h <<\EOF +#define __alpha 1 +EOF + + CFLAGS="$CFLAGS -mieee" + CXXFLAGS="$CXXFLAGS -mieee" + ;; + i*86) + cat >> confdefs.h <<\EOF +#define i386 1 +EOF + + ;; + ia64) + ;; + m68k) + CFLAGS="$CFLAGS -m68020-40" + CXXFLAGS="$CXXFLAGS -m68020-40" + # + # gcc on Linux/m68k either has a bug or triggers a code-sequence + # bug in the 68060 which causes gcc to crash. The simplest way to + # avoid this is to enable a minimum level of optimization. + # + _DEBUG_FLAGS="$_DEBUG_FLAGS -O" + ;; + esac + ;; + +*-mingw*|*-cygwin*|*-msvc*|*-mks*) + cat >> confdefs.h <<\EOF +#define XP_PC 1 +EOF + + cat >> confdefs.h <<\EOF +#define WIN32 1 +EOF + + cat >> confdefs.h <<\EOF +#define _WINDOWS 1 +EOF + + RESOLVE_LINK_SYMBOLS=1 + PROG_SUFFIX=.exe + if test -n "$GNU_CC"; then + CC="$CC -mno-cygwin" + CXX="$CXX -mno-cygwin" + DLL_SUFFIX=dll + MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) -o $@' + # Use temp file for windres (bug 213281) + RC="$WINDRES -O coff --use-temp-file" + else + CC=cl + CXX=cl + LD=link + # if the lib program is available, use it, otherwise use link /lib + # Extract the first word of "lib", so it can be a program name with args. +set dummy lib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:4873: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_HAVE_MSVC_LIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$HAVE_MSVC_LIB"; then + ac_cv_prog_HAVE_MSVC_LIB="$HAVE_MSVC_LIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_HAVE_MSVC_LIB="1" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +HAVE_MSVC_LIB="$ac_cv_prog_HAVE_MSVC_LIB" +if test -n "$HAVE_MSVC_LIB"; then + echo "$ac_t""$HAVE_MSVC_LIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test "$HAVE_MSVC_LIB" = "1" ; then + AR='lib -NOLOGO -OUT:"$@"' + else + AR='$(LD) /lib -NOLOGO -OUT:"$@"' + fi + + AR_FLAGS= + RANLIB='echo not_ranlib' + STRIP='echo not_strip' + RC=rc.exe + GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb' + OBJ_SUFFIX=obj + LIB_SUFFIX=lib + LIB_PREFIX= + DLL_SUFFIX=dll + + # Determine compiler version + + _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p' + + + CC_VERSION=`"${CC}" -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"` + _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'` + _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'` + _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'` + _CC_BUILD=`echo ${CC_VERSION} | awk -F\. '{ print $4 }'` + _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION} + + if test "$_CC_MAJOR_VERSION" -eq "14"; then + if test "$_CC_RELEASE" -gt 50727 -o \ + \( "$_CC_RELEASE" -eq 50727 -a "$_CC_BUILD" -ge 762 \); then + _USE_DYNAMICBASE=1 + fi + elif test $_CC_MAJOR_VERSION -ge 15; then + _USE_DYNAMICBASE=1 + fi + + if test -n "$_USE_DYNAMICBASE"; then + DLLFLAGS="$DLLFLAGS -DYNAMICBASE" + fi + + CFLAGS="$CFLAGS -W3 -nologo -GF -Gy" + DLLFLAGS="$DLLFLAGS -OUT:\"\$@\"" + + _DEBUG_FLAGS=-Z7 + _OPTIMIZE_FLAGS=-O2 + if test -z "$MOZ_OPTIMIZE"; then + CFLAGS="$CFLAGS -Od" + fi + + if test -n "$USE_DEBUG_RTL"; then + CFLAGS="$CFLAGS -MDd" + else + CFLAGS="$CFLAGS -MD" + fi + + if test -n "$MOZ_DEBUG"; then + cat >> confdefs.h <<\EOF +#define _DEBUG 1 +EOF + + else + DEFINES="$DEFINES -U_DEBUG" + fi + + if test -n "$MOZ_OPTIMIZE"; then + if test -n "$MOZ_DEBUG_SYMBOLS"; then + _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Zi" + DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF" + LDFLAGS="$LDFLAGS -DEBUG -OPT:REF" + fi + fi + + if test -n "$MOZ_DEBUG"; then + DLLFLAGS="$DLLFLAGS -DEBUG" + LDFLAGS="$LDFLAGS -DEBUG" + fi + + OS_DLLFLAGS='-nologo -DLL -SUBSYSTEM:WINDOWS' + if test "$_MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then + OS_DLLFLAGS="$OS_DLLFLAGS -PDB:NONE" + fi + + if test "$OS_TARGET" = "WINNT"; then + CFLAGS="$CFLAGS -GT" + if test "$CPU_ARCH" = "x86"; then + CFLAGS="$CFLAGS -G5" + fi + fi + fi # GNU_CC + + if test -n "$USE_STATIC_TLS"; then + cat >> confdefs.h <<\EOF +#define _PR_USE_STATIC_TLS 1 +EOF + + fi + + if test "$OS_TARGET" = "WINNT"; then + cat >> confdefs.h <<\EOF +#define WINNT 1 +EOF + + else + cat >> confdefs.h <<\EOF +#define WIN95 1 +EOF + + # undefine WINNT as some versions of mingw gcc define it by default + DEFINES="$DEFINES -UWINNT" + cat >> confdefs.h <<\EOF +#define _PR_GLOBAL_THREADS_ONLY 1 +EOF + + fi + + case "$OS_TARGET" in + WINNT) + ;; + WIN95) + ;; + WIN16) + ;; + *) + { echo "configure: error: Missing OS_TARGET for ${target}. Use --enable-win32-target to set." 1>&2; exit 1; } + ;; + esac + + case "$target_cpu" in + i*86) + if test -n "$USE_64"; then + cat >> confdefs.h <<\EOF +#define _AMD64_ 1 +EOF + + cat >> confdefs.h <<\EOF +#define _M_AMD64 1 +EOF + + else + cat >> confdefs.h <<\EOF +#define _X86_ 1 +EOF + + fi + ;; + alpha) + cat >> confdefs.h <<\EOF +#define _ALPHA_ 1 +EOF + + ;; + mips) + cat >> confdefs.h <<\EOF +#define _MIPS_ 1 +EOF + + ;; + x86_64) + cat >> confdefs.h <<\EOF +#define _AMD64_ 1 +EOF + + cat >> confdefs.h <<\EOF +#define _M_AMD64 1 +EOF + + ;; + *) + cat >> confdefs.h <<\EOF +#define _CPU_ARCH_NOT_DEFINED 1 +EOF + + ;; + esac + + if test -n "$USE_64"; then + cat >> confdefs.h <<\EOF +#define _WIN64 1 +EOF + + fi + ;; + +*-ncr-sysv*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define SVR4 1 +EOF + + cat >> confdefs.h <<\EOF +#define SYSV 1 +EOF + + cat >> confdefs.h <<\EOF +#define NCR 1 +EOF + + USE_NSPR_THREADS=1 + if test "$OS_RELEASE" = "2.03"; then + cat >> confdefs.h <<\EOF +#define _PR_STAT_HAS_ST_ATIM 1 +EOF + + else + cat >> confdefs.h <<\EOF +#define _PR_STAT_HAS_ST_ATIM_UNION 1 +EOF + + fi + + if test -z "$GNU_CC"; then + CFLAGS="$CFLAGS -Hnocopyr" + CXXFLAGS="$CXXFLAGS -Hnocopyr" + else + CFLAGS="$CFLAGS -fPIC -Wall" + CXXFLAGS="$CXXFLAGS -fPIC -Wall" + DSO_LDOPTS=-G + fi + ;; + +mips-nec-sysv*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define SVR4 1 +EOF + + cat >> confdefs.h <<\EOF +#define __SVR4 1 +EOF + + cat >> confdefs.h <<\EOF +#define NEC 1 +EOF + + cat >> confdefs.h <<\EOF +#define nec_ews 1 +EOF + + USE_NSPR_THREADS=1 + if test -z "$GNU_CC"; then + CC='$(NSDEPTH)/build/hcc cc -Xa -KGnum=0 -KOlimit=4000' + CXX=g++ + fi + OS_LIBS="$OS_LIBS -lsocket -lnsl -ldl" + DSO_LDOPTS=-G + ;; + +*-netbsd*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define NETBSD 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_BSD_FLOCK 1 +EOF + + USE_NSPR_THREADS=1 + + DSO_CFLAGS='-fPIC -DPIC' + CFLAGS="$CFLAGS -ansi -Wall" + CXXFLAGS="$CXXFLAGS -ansi -Wall" + MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)' + + if test -z "$OBJECT_FMT"; then + if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then + OBJECT_FMT=a.out + DLL_SUFFIX=so.1.0 + DSO_LDOPTS='-shared' + else + OBJECT_FMT=ELF + DLL_SUFFIX=so + DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)' + fi + fi + + if test "$LIBRUNPATH"; then + DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH" + fi + ;; + +mips-sony-newsos*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define SONY 1 +EOF + + cat >> confdefs.h <<\EOF +#define SYSV 1 +EOF + + cat >> confdefs.h <<\EOF +#define SVR4 1 +EOF + + cat >> confdefs.h <<\EOF +#define __svr4 1 +EOF + + cat >> confdefs.h <<\EOF +#define __svr4__ 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_SVID_GETTOD 1 +EOF + + USE_NSPR_THREADS=1 + CFLAGS="$CFLAGS -Xa -fullwarn" + CXXFLAGS="$CXXFLAGS -Xa -fullwarn" + DSO_LDOPTS=-G + ;; + +*-nextstep*|*-openstep*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define NEXTSTEP 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_BSD_FLOCK 1 +EOF + + cat >> confdefs.h <<\EOF +#define _POSIX_SOURCE 1 +EOF + + CFLAGS="$CFLAGS -Wall -fno-common -traditional-cpp -posix" + CXXFLAGS="$CXXFLAGS -Wall -fno-common -traditional-cpp -posix" + USE_NSPR_THREADS=1 + DLL_SUFFIX=dylib + ;; + + +*-nto*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define NTO 1 +EOF + + cat >> confdefs.h <<\EOF +#define _QNX_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_POINTER_LOCALTIME_R 1 +EOF + + MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@' + DSO_CFLAGS=-fPIC + DSO_LDOPTS=-shared + OS_LIBS="$OS_LIBS -lsocket" + _OPTIMIZE_FLAGS="-O1" + _DEBUG_FLAGS="-gstabs" + ;; + +*-openbsd*) + LD='$(CC)' + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define OPENBSD 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_BSD_FLOCK 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_SOCKLEN_T 1 +EOF + + CFLAGS="$CFLAGS -ansi -Wall" + CXXFLAGS="$CXXFLAGS -ansi -Wall" + DLL_SUFFIX=so.1.0 + DSO_CFLAGS=-fPIC + USE_NSPR_THREADS=1 + DSO_LDOPTS='-shared -fPIC' + ;; + +*-openvms*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + RESOLVE_LINK_SYMBOLS=1 + AR_FLAGS='c $@' + DSO_LDOPTS='-shared -auto_symvec $(LDFLAGS) $(OPTIMIZER)' + ;; + +*-os2*) + cat >> confdefs.h <<\EOF +#define OS2 1 +EOF + + cat >> confdefs.h <<\EOF +#define XP_OS2 1 +EOF + + cat >> confdefs.h <<\EOF +#define XP_PC 1 +EOF + +# AC_DEFINE(USE_OS2_TOOLKIT_HEADERS) + cat >> confdefs.h <<\EOF +#define TCPV40HDRS 1 +EOF + + cat >> confdefs.h <<\EOF +#define BSD_SELECT 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_GLOBAL_THREADS_ONLY 1 +EOF + + RESOLVE_LINK_SYMBOLS=1 + NSINSTALL=nsinstall + LIB_PREFIX= + LIB_SUFFIX=lib + DLL_SUFFIX=dll + DLLTOOL='' + RC=rc.exe + PROG_SUFFIX=.exe + AR=emxomfar + AR_FLAGS='r $@' + LD='$(CC)' + CFLAGS="$CFLAGS -Wall -Zomf" + CXXFLAGS="$CFLAGS -Wall -Zomf" + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + DSO_CFLAGS= + DSO_LDOPTS='-Zomf -Zdll' + _OPTIMIZE_FLAGS=-O3 + _DEBUG_FLAGS="-g -fno-inline" + if test -n "$MOZ_OPTIMIZE"; then + DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA" + fi + OS_LIBS="-lsocket" + IMPLIB='emximp -o' + FILTER='emxexp -o' + if test -n "$MOZ_OS2_HIGH_MEMORY"; then + DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem" + LDFLAGS="$LDFLAGS -Zhigh-mem" + cat >> confdefs.h <<\EOF +#define MOZ_OS2_HIGH_MEMORY 1 +EOF + + fi + + # GCC for OS/2 currently predefines these, but we don't want them + DEFINES="$DEFINES -Uunix -U__unix -U__unix__" + ;; + +*-osf*) + SHELL_OVERRIDE="SHELL = /usr/bin/ksh" + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define OSF1 1 +EOF + + cat >> confdefs.h <<\EOF +#define _REENTRANT 1 +EOF + + ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6 +echo "configure:5390: checking for machine/builtins.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 5395 "configure" +#include "confdefs.h" +#include <machine/builtins.h> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:5400: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define OSF1_HAVE_MACHINE_BUILTINS_H 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi + + + if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then + USE_NSPR_THREADS=1 + fi + + if test -z "$GNU_CC"; then + CC="$CC -std1 -ieee_with_inexact" + if test "$OS_RELEASE" != "V2.0"; then + CC="$CC -readonly_strings" + fi + _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000" + fi + + if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then + cat >> confdefs.h <<\EOF +#define HAVE_INT_LOCALTIME_R 1 +EOF + + else + cat >> confdefs.h <<\EOF +#define HAVE_FCNTL_FILE_LOCKING 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_POINTER_LOCALTIME_R 1 +EOF + + fi + if echo $OS_RELEASE | grep -c V4.0 >/dev/null; then + cat >> confdefs.h <<\EOF +#define OSF1V4_MAP_PRIVATE_BUG 1 +EOF + + fi + DSO_LDOPTS='-shared -all -expect_unresolved "*" -soname $(notdir $@)' + ;; + +*-qnx*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define QNX 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_NEED_H_ERRNO 1 +EOF + + USE_NSPR_THREADS=1 + ;; + +*-*-sco*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define SCO 1 +EOF + + cat >> confdefs.h <<\EOF +#define sco 1 +EOF + + cat >> confdefs.h <<\EOF +#define SYSV 1 +EOF + + cat >> confdefs.h <<\EOF +#define _SVID3 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_NEED_H_ERRNO 1 +EOF + + CC='cc -b elf -KPIC' + CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w' + USE_NSPR_THREADS=1 + CPU_ARCH=x86 + DSO_LDOPTS='-b elf -G' + ;; + +*-sinix*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define SVR4 1 +EOF + + cat >> confdefs.h <<\EOF +#define SNI 1 +EOF + + cat >> confdefs.h <<\EOF +#define RELIANTUNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define sinix 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_SVID_GETTOD 1 +EOF + + if echo "$OS_TEST" | grep -c 86 2>/dev/null; then + cat >> confdefs.h <<\EOF +#define i386 1 +EOF + + CPU_ARCH=x86 + else + CPU_ARCH=mips + fi + + if test "$GNU_CC"; then + AS='$(CC) -x assembler-with-cpp' + if test "$CPU_ARCH" = "mips"; then + LD=gld + fi + CFLAGS="$CFLAGS -Wall -Wno-format" + else + AS='/usr/bin/cc' + _OPTIMIZE_FLAGS='-O -F Olimit,4000' + fi + + DSO_LDOPTS='-G -z defs -h $(@:$(OBJDIR)/%.so=%.so)' + + if test "$OS_RELEASE" = "5.43"; then + cat >> confdefs.h <<\EOF +#define IP_MULTICAST 1 +EOF + + fi + + OS_LIBS="$OS_LIBS -lsocket -lnsl -lresolv -ldl -lc" + USE_NSPR_THREADS=1 + ;; + +*-sunos*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define SUNOS4 1 +EOF + + CFLAGS="$CFLAGS -Wall -Wno-format" + if test "$USE_MDUPDATE"; then + CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" + fi + CPU_ARCH=sparc + DLL_SUFFIX=so.1.0 + DSO_LDOPTS= + DSO_CFLAGS=-fPIC + USE_NSPR_THREADS=1 + if test "$OS_RELEASE" = "4.1.3_U1"; then + _OPTIMIZE_FLAGS= + OS_LIBS="$OS_LIBS -lm" + fi + ;; + +*-solaris*) + if test -z "$USE_USER_THREADS" && test -z "$USE_NATIVE_THREADS"; then + USE_PTHREADS=1 + fi + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define SVR4 1 +EOF + + cat >> confdefs.h <<\EOF +#define SYSV 1 +EOF + + cat >> confdefs.h <<\EOF +#define __svr4 1 +EOF + + cat >> confdefs.h <<\EOF +#define __svr4__ 1 +EOF + + cat >> confdefs.h <<\EOF +#define SOLARIS 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_FCNTL_FILE_LOCKING 1 +EOF + + if test -n "$GNU_CC" ; then + if test -n "$USE_64"; then + CC="$CC -m64" + CXX="$CXX -m64" + fi + LD='$(CC)' + DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' + DSO_CFLAGS=-fPIC + CFLAGS="$CFLAGS -Wall" + CXXFLAGS="$CXXFLAGS -Wall" + if test -n "$USE_MDUPDATE"; then + CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" + CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)" + fi + else + LD=/usr/ccs/bin/ld + RANLIB=/usr/ccs/bin/ranlib + DSO_LDOPTS='-G -h $(notdir $@)' + DSO_CFLAGS=-KPIC + if test -n "$USE_64"; then + if test "$OS_TEST" = "i86pc"; then + CC="$CC -xarch=amd64" + CXX="$CXX -xarch=amd64" + else + CC="$CC -xarch=v9" + CXX="$CXX -xarch=v9" + fi + fi + CC="$CC -xstrconst" + if test -z "$MOZ_OPTIMIZE"; then + CFLAGS="$CFLAGS -xs" + CXXFLAGS="$CXXFLAGS -xs" + fi + fi + if test "$DEFAULT_RPATHFLAG" = "$RPATHFLAG" ; then + # add origin stuff + RPATHFLAG="\\\$\$ORIGIN/../lib:\\\$\$ORIGIN/../../lib:$RPATHFLAG" + fi + if test -z "$GNU_AS"; then + ASFLAGS="$ASFLAGS -Wa,-P" + fi + if test "$OS_TEST" = "i86pc"; then + cat >> confdefs.h <<\EOF +#define i386 1 +EOF + + + # The default debug format, DWARF (-g), is not supported by gcc + # on i386-ANY-sysv4/solaris, but the stabs format is. It is + # assumed that the Solaris assembler /usr/ccs/bin/as is used. + # If your gcc uses GNU as, you do not need the -Wa,-s option. + if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then + _DEBUG_FLAGS=-gstabs + if test -z "$GNU_AS"; then + _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s" + fi + fi + fi + case "${target_os}" in + solaris2.3*) + cat >> confdefs.h <<\EOF +#define _PR_NO_LARGE_FILES 1 +EOF + + ;; + solaris2.4*) + cat >> confdefs.h <<\EOF +#define _PR_NO_LARGE_FILES 1 +EOF + + ;; + solaris2.5*) + cat >> confdefs.h <<\EOF +#define SOLARIS2_5 1 +EOF + + ;; + *) + cat >> confdefs.h <<\EOF +#define _PR_HAVE_OFF64_T 1 +EOF + + # The lfcompile64(5) man page on Solaris 2.6 says: + # For applications that do not wish to conform to the POSIX or + # X/Open specifications, the 64-bit transitional interfaces + # are available by default. No compile-time flags need to be + # set. + # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default. + # The native compiler, gcc 2.8.x, and egcs don't have this problem. + if test -n "$GNU_CC"; then + cat >> confdefs.h <<\EOF +#define _LARGEFILE64_SOURCE 1 +EOF + + fi + ;; + esac + if test "$OS_TEST" = "sun4u"; then + # 64-bit Solaris requires SPARC V9 architecture, so the following + # is not needed. + if test -z "$USE_64"; then + ULTRASPARC_LIBRARY=ultrasparc + ULTRASPARC_FILTER_LIBRARY=libatomic.so + DSO_LDOPTS="$DSO_LDOPTS -f "'$(ULTRASPARC_FILTER_LIBRARY)' + fi + fi + ;; + +*-sco-sysv5*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + cat >> confdefs.h <<\EOF +#define UNIXWARE 1 +EOF + + cat >> confdefs.h <<\EOF +#define SVR4 1 +EOF + + cat >> confdefs.h <<\EOF +#define SYSV 1 +EOF + + USE_NSPR_THREADS=1 + if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then + cat >> confdefs.h <<\EOF +#define _PR_NO_LARGE_FILES 1 +EOF + + CC='$(NSDEPTH)/build/hcc cc' + CXX='$(NSDEPTH)/build/hcpp CC' + else + cat >> confdefs.h <<\EOF +#define _LARGEFILE64_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_OFF64_T 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_SOCKADDR_LEN 1 +EOF + + fi + DSO_LDOPTS=-G + CPU_ARCH=x86 + ;; + +*) + cat >> confdefs.h <<\EOF +#define XP_UNIX 1 +EOF + + ;; + +esac + +if test -z "$SKIP_LIBRARY_CHECKS"; then + +echo $ac_n "checking for dlopen""... $ac_c" 1>&6 +echo "configure:5787: checking for dlopen" >&5 +if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 5792 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_dlopen) || defined (__stub___dlopen) +choke me +#else +dlopen(); +#endif + +; return 0; } +EOF +if { (eval echo configure:5815: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_dlopen=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_dlopen=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 + + echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 +echo "configure:5834: checking for dlopen in -ldl" >&5 +ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldl $LIBS" +cat > conftest.$ac_ext <<EOF +#line 5842 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen(); + +int main() { +dlopen() +; return 0; } +EOF +if { (eval echo configure:5853: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + OS_LIBS="-ldl $OS_LIBS" +else + echo "$ac_t""no" 1>&6 +fi + + +fi + + + + +if test $ac_cv_prog_gcc = yes; then + echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 +echo "configure:5881: checking whether ${CC-cc} needs -traditional" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_pattern="Autoconf.*'x'" + cat > conftest.$ac_ext <<EOF +#line 5887 "configure" +#include "confdefs.h" +#include <sgtty.h> +Autoconf TIOCGETP +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "$ac_pattern" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_prog_gcc_traditional=yes +else + rm -rf conftest* + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat > conftest.$ac_ext <<EOF +#line 5905 "configure" +#include "confdefs.h" +#include <termio.h> +Autoconf TCGETA +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "$ac_pattern" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi + +echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + +for ac_func in lchown strerror getaddrinfo getnameinfo +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:5929: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 5934 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:5957: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + + + +# Check whether --enable-strip or --disable-strip was given. +if test "${enable_strip+set}" = set; then + enableval="$enable_strip" + ENABLE_STRIP=1 +fi + + + + + +echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 +echo "configure:5995: checking for pthread_create in -lpthreads" >&5 +echo " + #include <pthread.h> + void *foo(void *v) { int a = 1; } + int main() { + pthread_t t; + if (!pthread_create(&t, 0, &foo, 0)) { + pthread_join(t, 0); + } + exit(0); + }" > dummy.c ; + echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthreads $LDFLAGS $LIBS" 1>&5; + ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthreads $LDFLAGS $LIBS 2>&5; + _res=$? ; + rm -f dummy.c dummy${ac_exeext} ; + if test "$_res" = "0"; then + echo "$ac_t""yes" 1>&6 + _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads" + else + echo "$ac_t""no" 1>&6 + +echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 +echo "configure:6017: checking for pthread_create in -lpthread" >&5 +echo " + #include <pthread.h> + void *foo(void *v) { int a = 1; } + int main() { + pthread_t t; + if (!pthread_create(&t, 0, &foo, 0)) { + pthread_join(t, 0); + } + exit(0); + }" > dummy.c ; + echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthread $LDFLAGS $LIBS" 1>&5; + ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthread $LDFLAGS $LIBS 2>&5; + _res=$? ; + rm -f dummy.c dummy${ac_exeext} ; + if test "$_res" = "0"; then + echo "$ac_t""yes" 1>&6 + _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread" + else + echo "$ac_t""no" 1>&6 + +echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 +echo "configure:6039: checking for pthread_create in -lc_r" >&5 +echo " + #include <pthread.h> + void *foo(void *v) { int a = 1; } + int main() { + pthread_t t; + if (!pthread_create(&t, 0, &foo, 0)) { + pthread_join(t, 0); + } + exit(0); + }" > dummy.c ; + echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc_r $LDFLAGS $LIBS" 1>&5; + ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc_r $LDFLAGS $LIBS 2>&5; + _res=$? ; + rm -f dummy.c dummy${ac_exeext} ; + if test "$_res" = "0"; then + echo "$ac_t""yes" 1>&6 + _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r" + else + echo "$ac_t""no" 1>&6 + +echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6 +echo "configure:6061: checking for pthread_create in -lc" >&5 +echo " + #include <pthread.h> + void *foo(void *v) { int a = 1; } + int main() { + pthread_t t; + if (!pthread_create(&t, 0, &foo, 0)) { + pthread_join(t, 0); + } + exit(0); + }" > dummy.c ; + echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc $LDFLAGS $LIBS" 1>&5; + ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc $LDFLAGS $LIBS 2>&5; + _res=$? ; + rm -f dummy.c dummy${ac_exeext} ; + if test "$_res" = "0"; then + echo "$ac_t""yes" 1>&6 + _HAVE_PTHREADS=1 + + else + echo "$ac_t""no" 1>&6 + + fi + + + fi + + + fi + + + fi + + +# Check whether --with-pthreads or --without-pthreads was given. +if test "${with_pthreads+set}" = set; then + withval="$with_pthreads" + if test "$withval" = "yes"; then + if test -n "$_HAVE_PTHREADS"; then + USE_PTHREADS=1 + USE_USER_PTHREADS= + USE_NSPR_THREADS= + else + { echo "configure: error: --with-pthreads specified for a system without pthread support " 1>&2; exit 1; }; + fi + else + USE_PTHREADS= + _PTHREAD_LDFLAGS= + fi +else + if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USER_NSPR_THREADS"; then + USE_PTHREADS=1 + USE_USER_PTHREADS= + USE_NSPR_THREADS= + fi +fi + + +# Check whether --enable-user-pthreads or --disable-user-pthreads was given. +if test "${enable_user_pthreads+set}" = set; then + enableval="$enable_user_pthreads" + if test "$enableval" = "yes"; then + if test -n "$_HAVE_PTHREADS"; then + USE_PTHREADS= + USE_USER_PTHREADS=1 + USE_NSPR_THREADS= + else + { echo "configure: error: --enable-user-pthreads specified for a system without pthread support " 1>&2; exit 1; }; + fi + fi +fi + + +# Check whether --enable-nspr-threads or --disable-nspr-threads was given. +if test "${enable_nspr_threads+set}" = set; then + enableval="$enable_nspr_threads" + if test "$enableval" = "yes"; then + USE_PTHREADS= + USE_USER_PTHREADS= + USE_NSPR_THREADS=1 + fi +fi + + +case "$target" in +*-beos*) + # Check whether --with-bthreads or --without-bthreads was given. +if test "${with_bthreads+set}" = set; then + withval="$with_bthreads" + if test "$withval" = "yes"; then + USE_BTHREADS=1 + USE_USER_PTHREADS= + USE_PTHREADS= + fi +fi + + ;; + +*-solaris*) + # Check whether --with-native-threads or --without-native-threads was given. +if test "${with_native_threads+set}" = set; then + withval="$with_native_threads" + if test "$withval" = "yes"; then + USE_NATIVE_THREADS=1 + USE_USER_PTHREADS= + USE_PTHREADS= + fi +fi + + ;; +esac + +fi # SKIP_LIBRARY_CHECKS + +# Check whether --enable-cplus or --disable-cplus was given. +if test "${enable_cplus+set}" = set; then + enableval="$enable_cplus" + if test "$enableval" = "yes"; then + USE_CPLUS=1 + fi +fi + + +# Check whether --enable-ipv6 or --disable-ipv6 was given. +if test "${enable_ipv6+set}" = set; then + enableval="$enable_ipv6" + if test "$enableval" = "yes"; then + USE_IPV6=1 + fi +fi + + + +echo $ac_n "checking for --with-sasl""... $ac_c" 1>&6 +echo "configure:6195: checking for --with-sasl" >&5 +# Check whether --with-sasl or --without-sasl was given. +if test "${with_sasl+set}" = set; then + withval="$with_sasl" + + if test "$withval" = "yes"; then + echo "$ac_t""yes" 1>&6 + HAVE_SASL=1 + + if test -f /usr/include/sasl/sasl.h; then + SASL_CFLAGS="-I/usr/include/sasl" + elif test -f /usr/include/sasl.h; then + SASL_CFLAGS="-I/usr/include" + else + { echo "configure: error: sasl.h not found" 1>&2; exit 1; } + fi + + elif test -d "$withval" -a -d "$withval/lib" -a -d "$withval/include" ; then + echo "$ac_t""using $withval" 1>&6 + HAVE_SASL=1 + + if test -f "$withval/include/sasl/sasl.h"; then + SASL_CFLAGS="-I$withval/include/sasl" + elif test -f "$withval/include/sasl.h"; then + SASL_CFLAGS="-I$withval/include" + else + { echo "configure: error: sasl.h not found" 1>&2; exit 1; } + fi + + SASL_LIBS="-L$withval/lib" + else + echo "$ac_t""yes" 1>&6 + { echo "configure: error: sasl not found in $withval" 1>&2; exit 1; } + fi + +else + echo "$ac_t""no" 1>&6 +fi + + +echo $ac_n "checking for --with-sasl-inc""... $ac_c" 1>&6 +echo "configure:6236: checking for --with-sasl-inc" >&5 +# Check whether --with-sasl-inc or --without-sasl-inc was given. +if test "${with_sasl_inc+set}" = set; then + withval="$with_sasl_inc" + + if test -f "$withval"/sasl.h; then + echo "$ac_t""using $withval" 1>&6 + HAVE_SASL=1 + SASL_CFLAGS="-I$withval" + else + echo + { echo "configure: error: $withval/sasl.h not found" 1>&2; exit 1; } + fi + +else + echo "$ac_t""no" 1>&6 +fi + + +echo $ac_n "checking for --with-sasl-lib""... $ac_c" 1>&6 +echo "configure:6256: checking for --with-sasl-lib" >&5 +# Check whether --with-sasl-lib or --without-sasl-lib was given. +if test "${with_sasl_lib+set}" = set; then + withval="$with_sasl_lib" + + if test -d "$withval"; then + echo "$ac_t""using $withval" 1>&6 + HAVE_SASL=1 + SASL_LIBS="-L$withval" + else + echo + { echo "configure: error: $withval not found" 1>&2; exit 1; } + fi + +else + echo "$ac_t""no" 1>&6 +fi + + +# check for sasl +if test -n "$_WIN32_MSVC" -a -n "$USE_WINDOWS_PATHS" ; then + if test -n "$SASL_CFLAGS" -a -z "$SKIP_CYGWIN_FIXUP" ; then + path=`echo $SASL_CFLAGS | sed -e 's/^-I//'` + path=`cygpath -m $path` + SASL_CFLAGS="/I$path" + fi + if test -n "$SASL_LIBS" -a -z "$SKIP_CYGWIN_FIXUP" ; then + path=`echo $SASL_LIBS | sed -e 's/^-L//'` + path=`cygpath -m $path` + SASL_LIBS="/LIBPATH:$path" + fi + special_sasl_check_lib=1 +fi +# set ldflags to point to where the user told us to find the sasl libs, +# if any - otherwise it will just use the default location (e.g. /usr/lib) +# the way AC_CHECK_LIB works is it actually attempts to compile and link +# a test program - that's why we need to set LDFLAGS +SAVE_LDFLAGS=$LDFLAGS +if test -n "$SASL_LIBS" ; then + LDFLAGS="$LDFLAGS $SASL_LIBS" +fi + +echo $ac_n "checking for getaddrinfo""... $ac_c" 1>&6 +echo "configure:6299: checking for getaddrinfo" >&5 +if eval "test \"`echo '$''{'ac_cv_func_getaddrinfo'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 6304 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char getaddrinfo(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char getaddrinfo(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_getaddrinfo) || defined (__stub___getaddrinfo) +choke me +#else +getaddrinfo(); +#endif + +; return 0; } +EOF +if { (eval echo configure:6327: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_getaddrinfo=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_getaddrinfo=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'getaddrinfo`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 + + echo $ac_n "checking for getaddrinfo in -lsocket""... $ac_c" 1>&6 +echo "configure:6346: checking for getaddrinfo in -lsocket" >&5 +ac_lib_var=`echo socket'_'getaddrinfo | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsocket $LIBS" +cat > conftest.$ac_ext <<EOF +#line 6354 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char getaddrinfo(); + +int main() { +getaddrinfo() +; return 0; } +EOF +if { (eval echo configure:6365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="-lsocket -lnsl $LIBS" +else + echo "$ac_t""no" 1>&6 +fi + +fi + + +if test -n "$special_sasl_check_lib" ; then + # use this to override the ac_link LIBS used by AC_CHECK_LIB + # ac_link puts conftest.c betwen $LDFLAGS and $LIBS, but we + # have to use /LIBPATH which must come after the /link directive + # however, anything after /link on the command line is assumed to + # be a linker directive, and conftest.c is not valid there + # we want to end up with cl.exe .... conftest.c /link /LIBPATH:foo libsasl.lib + LDFLAGS= + SAVE_LIBS="$LIBS" + LIBS="/link $SASL_LIBS sasl32.lib" + echo $ac_n "checking for sasl_client_init in -lsasl32""... $ac_c" 1>&6 +echo "configure:6399: checking for sasl_client_init in -lsasl32" >&5 +ac_lib_var=`echo sasl32'_'sasl_client_init | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsasl32 $LIBS" +cat > conftest.$ac_ext <<EOF +#line 6407 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char sasl_client_init(); + +int main() { +sasl_client_init() +; return 0; } +EOF +if { (eval echo configure:6418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + sasl_lib=sasl32.lib +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$sasl_lib" ; then + LIBS="/link $SASL_LIBS libsasl2.lib" + echo $ac_n "checking for sasl_client_init in -lsasl2""... $ac_c" 1>&6 +echo "configure:6441: checking for sasl_client_init in -lsasl2" >&5 +ac_lib_var=`echo sasl2'_'sasl_client_init | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsasl2 $LIBS" +cat > conftest.$ac_ext <<EOF +#line 6449 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char sasl_client_init(); + +int main() { +sasl_client_init() +; return 0; } +EOF +if { (eval echo configure:6460: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + sasl_lib=libsasl2.lib +else + echo "$ac_t""no" 1>&6 +fi + + fi + if test -z "$sasl_lib" ; then + LIBS="/link $SASL_LIBS libsasl.lib" + echo $ac_n "checking for sasl_client_init in -lsasl""... $ac_c" 1>&6 +echo "configure:6484: checking for sasl_client_init in -lsasl" >&5 +ac_lib_var=`echo sasl'_'sasl_client_init | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsasl $LIBS" +cat > conftest.$ac_ext <<EOF +#line 6492 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char sasl_client_init(); + +int main() { +sasl_client_init() +; return 0; } +EOF +if { (eval echo configure:6503: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + sasl_lib=libsasl.lib +else + echo "$ac_t""no" 1>&6 +fi + + fi + LIBS="$SAVE_LIBS" +else + echo $ac_n "checking for sasl_client_init in -lsasl2""... $ac_c" 1>&6 +echo "configure:6527: checking for sasl_client_init in -lsasl2" >&5 +ac_lib_var=`echo sasl2'_'sasl_client_init | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsasl2 $LIBS" +cat > conftest.$ac_ext <<EOF +#line 6535 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char sasl_client_init(); + +int main() { +sasl_client_init() +; return 0; } +EOF +if { (eval echo configure:6546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + sasl_lib=-lsasl2 +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for sasl_client_init in -lsasl""... $ac_c" 1>&6 +echo "configure:6565: checking for sasl_client_init in -lsasl" >&5 +ac_lib_var=`echo sasl'_'sasl_client_init | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsasl $LIBS" +cat > conftest.$ac_ext <<EOF +#line 6573 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char sasl_client_init(); + +int main() { +sasl_client_init() +; return 0; } +EOF +if { (eval echo configure:6584: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + sasl_lib=-lsasl +else + echo "$ac_t""no" 1>&6 +fi + +fi + +fi + +SASL_LIBS="$SASL_LIBS $sasl_lib" +LDFLAGS=$SAVE_LDFLAGS + + + + + +if test -n "$HAVE_SASL"; then + cat >> confdefs.h <<\EOF +#define HAVE_SASL 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_SASL_OPTIONS 1 +EOF + + cat >> confdefs.h <<\EOF +#define LDAP_SASLIO_HOOKS 1 +EOF + +fi + + +if test -n "$USE_PTHREADS"; then + rm -f conftest* + ac_cv_have_dash_pthread=no + echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6 +echo "configure:6635: checking whether ${CC-cc} accepts -pthread" >&5 + echo 'int main() { return 0; }' | cat > conftest.c + ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1 + if test $? -eq 0; then + if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then + ac_cv_have_dash_pthread=yes + CFLAGS="$CFLAGS -pthread" + CXXFLAGS="$CXXFLAGS -pthread" + fi + fi + rm -f conftest* + echo "$ac_t""$ac_cv_have_dash_pthread" 1>&6 + + ac_cv_have_dash_pthreads=no + if test "$ac_cv_have_dash_pthread" = "no"; then + echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6 +echo "configure:6651: checking whether ${CC-cc} accepts -pthreads" >&5 + echo 'int main() { return 0; }' | cat > conftest.c + ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1 + if test $? -eq 0; then + if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then + ac_cv_have_dash_pthreads=yes + CFLAGS="$CFLAGS -pthreads" + CXXFLAGS="$CXXFLAGS -pthreads" + fi + fi + rm -f conftest* + echo "$ac_t""$ac_cv_have_dash_pthreads" 1>&6 + fi + + case "$target" in + *-solaris*) + if test "$ac_cv_have_dash_pthreads" = "yes"; then + _PTHREAD_LDFLAGS= + fi + ;; + *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*) + cat >> confdefs.h <<\EOF +#define _THREAD_SAFE 1 +EOF + + if test "$ac_cv_have_dash_pthread" = "yes"; then + _PTHREAD_LDFLAGS= + fi + ;; + *-linux*) + cat >> confdefs.h <<\EOF +#define _REENTRANT 1 +EOF + + ;; + esac + +else + if test -n "$USE_USER_PTHREADS"; then + USE_PTHREADS= + USE_NSPR_THREADS= + else + _PTHREAD_LDFLAGS= + fi +fi + +case "$target" in +*-aix*) + if test -n "$USE_NSPR_THREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_LOCAL_THREADS_ONLY 1 +EOF + + fi + case "$target_os" in + aix4.1*) + if test -z "$USE_PTHREADS"; then + cat >> confdefs.h <<\EOF +#define AIX_RENAME_SELECT 1 +EOF + + fi + ;; + aix4.2*) + if test -z "$USE_NSPR_THREADS"; then + cat >> confdefs.h <<\EOF +#define HAVE_POINTER_LOCALTIME_R 1 +EOF + + fi + ;; + aix4.3*) + if test -z "$USE_NSPR_THREADS"; then + cat >> confdefs.h <<\EOF +#define HAVE_POINTER_LOCALTIME_R 1 +EOF + + fi + if test -n "$USE_PTHREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_HAVE_THREADSAFE_GETHOST 1 +EOF + + fi + ;; + esac + ;; +*-bsdi*) + if test -n "$USE_PTHREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_NEED_PTHREAD_INIT 1 +EOF + + fi + ;; +*-freebsd*) + if test -n "$USE_NSPR_THREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_LOCAL_THREADS_ONLY 1 +EOF + + fi + ;; +*-hpux*) + if test -n "$USE_NSPR_THREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_LOCAL_THREADS_ONLY 1 +EOF + + fi + if test "$USE_PTHREADS"; then + if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then + cat >> confdefs.h <<\EOF +#define _REENTRANT 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_DCETHREADS 1 +EOF + + else + cat >> confdefs.h <<EOF +#define _POSIX_C_SOURCE 199506L +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_THREADSAFE_GETHOST 1 +EOF + + fi + fi + if test "$USE_USER_PTHREADS"; then + cat >> confdefs.h <<EOF +#define _POSIX_C_SOURCE 199506L +EOF + + fi + ;; +*-irix*) + if test "${target_os}" = "irix6.5"; then + if test -n "$USE_PTHREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_HAVE_GETHOST_R 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_GETHOST_R_POINTER 1 +EOF + + fi + fi + ;; +*-linux*) + if test -n "$USE_NSPR_THREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_LOCAL_THREADS_ONLY 1 +EOF + + fi + ;; +*-mingw*|*-cygwin*|*-msvc*|*-mks*|*-os2*|*-beos*) + USE_PTHREADS= + _PTHREAD_LDFLAGS= + USE_USER_PTHREADS= + ;; +*-netbsd*) + if test -n "$USE_NSPR_THREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_LOCAL_THREADS_ONLY 1 +EOF + + fi + ;; +*-osf*) + if test -n "$USE_NSPR_THREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_LOCAL_THREADS_ONLY 1 +EOF + + fi + if test -n "$USE_PTHREADS"; then + if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then + : + else + cat >> confdefs.h <<\EOF +#define _PR_HAVE_THREADSAFE_GETHOST 1 +EOF + + fi + fi + ;; +*-solaris*) + if test -n "$USE_NATIVE_THREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_GLOBAL_THREADS_ONLY 1 +EOF + + else + if test -n "$USE_NSPR_THREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_LOCAL_THREADS_ONLY 1 +EOF + + fi + fi + if test -z "$USE_NSPR_THREADS"; then + cat >> confdefs.h <<\EOF +#define _REENTRANT 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_POINTER_LOCALTIME_R 1 +EOF + + fi + ;; +*-nto*) + if test -n "$USE_PTHREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_HAVE_GETHOST_R 1 +EOF + + cat >> confdefs.h <<\EOF +#define _PR_HAVE_GETHOST_R_POINTER 1 +EOF + + fi + ;; +esac + +OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS" + +if test -n "$_SAVE_OPTIMIZE_FLAGS"; then + _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS" +fi + +if test -n "$_SAVE_DEBUG_FLAGS"; then + _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS" +fi + +if test -n "$MOZ_OPTIMIZE"; then + CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS" + CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS" +fi + +if test -n "$MOZ_DEBUG"; then + CFLAGS="$CFLAGS $_DEBUG_FLAGS" + CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS" +fi + +case "$target_os" in +cygwin*|msvc*|mks*) + CC="\$(CYGWIN_WRAPPER) $CC" + CXX="\$(CYGWIN_WRAPPER) $CXX" + RC="\$(CYGWIN_WRAPPER) $RC" + ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +MAKEFILES=" +Makefile +config/Makefile +config/autoconf.mk +ldap/Makefile +ldap/clients/tools/Makefile +ldap/include/Makefile +ldap/libraries/Makefile +ldap/libraries/libldap/Makefile +ldap/libraries/libprldap/Makefile +ldap/libraries/libldif/Makefile +ldap/libraries/liblber/Makefile +ldap/libraries/libiutil/Makefile +ldap/libraries/libssldap/Makefile +ldap/libraries/libutil/Makefile +" + +mkdir ldap > /dev/null 2>&1 +mkdir ldap/clients > /dev/null 2>&1 + +echo $MAKEFILES > unallmakefiles + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then we branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +cat >confdef2opt.sed <<\_ACEOF +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +t quote +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +t quote +d +: quote +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,\[,\\&,g +s,\],\\&,g +s,\$,$$,g +p +_ACEOF +# We use echo to avoid assuming a particular line-breaking character. +# The extra dot is to prevent the shell from consuming trailing +# line-breaks from the sub-command output. A line-break within +# single-quotes doesn't work because, if this script is created in a +# platform that uses two characters for line-breaks (e.g., DOS), tr +# would break. +ac_LF_and_DOT=`echo; echo .` +DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` +rm -f confdef2opt.sed + + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS <<EOF +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir + +trap 'rm -fr `echo "$MAKEFILES" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS <<EOF + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; + s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@host@%$host%g +s%@host_alias@%$host_alias%g +s%@host_cpu@%$host_cpu%g +s%@host_vendor@%$host_vendor%g +s%@host_os@%$host_os%g +s%@target@%$target%g +s%@target_alias@%$target_alias%g +s%@target_cpu@%$target_cpu%g +s%@target_vendor@%$target_vendor%g +s%@target_os@%$target_os%g +s%@build@%$build%g +s%@build_alias@%$build_alias%g +s%@build_cpu@%$build_cpu%g +s%@build_vendor@%$build_vendor%g +s%@build_os@%$build_os%g +s%@CC@%$CC%g +s%@dist_prefix@%$dist_prefix%g +s%@dist_bindir@%$dist_bindir%g +s%@dist_libdir@%$dist_libdir%g +s%@BUILDCLU@%$BUILDCLU%g +s%@SVRCORE_LIBS@%$SVRCORE_LIBS%g +s%@HAVE_SVRCORE@%$HAVE_SVRCORE%g +s%@PKG_CONFIG@%$PKG_CONFIG%g +s%@SVRCORE_CFLAGS@%$SVRCORE_CFLAGS%g +s%@NSS_CFLAGS@%$NSS_CFLAGS%g +s%@NSS_LIBS@%$NSS_LIBS%g +s%@NSS_CONFIG@%$NSS_CONFIG%g +s%@NSPR_CFLAGS@%$NSPR_CFLAGS%g +s%@NSPR_LIBS@%$NSPR_LIBS%g +s%@NSPR_CONFIG@%$NSPR_CONFIG%g +s%@LIBS_ALREADY_SET@%$LIBS_ALREADY_SET%g +s%@WHOAMI@%$WHOAMI%g +s%@CXX@%$CXX%g +s%@CPP@%$CPP%g +s%@RANLIB@%$RANLIB%g +s%@AS@%$AS%g +s%@AR@%$AR%g +s%@LD@%$LD%g +s%@STRIP@%$STRIP%g +s%@WINDRES@%$WINDRES%g +s%@HOST_CC@%$HOST_CC%g +s%@PERL@%$PERL%g +s%@HAVE_MSVC_LIB@%$HAVE_MSVC_LIB%g +s%@SASL_LIBS@%$SASL_LIBS%g +s%@SASL_CFLAGS@%$SASL_CFLAGS%g +s%@HAVE_SASL@%$HAVE_SASL%g +s%@SHELL_OVERRIDE@%$SHELL_OVERRIDE%g +s%@MOZILLA_CLIENT@%$MOZILLA_CLIENT%g +s%@HOST_CFLAGS@%$HOST_CFLAGS%g +s%@GNU_CC@%$GNU_CC%g +s%@CROSS_COMPILE@%$CROSS_COMPILE%g +s%@MOZ_OPTIMIZE@%$MOZ_OPTIMIZE%g +s%@USE_CPLUS@%$USE_CPLUS%g +s%@USE_IPV6@%$USE_IPV6%g +s%@USE_N32@%$USE_N32%g +s%@USE_64@%$USE_64%g +s%@OBJECT_MODE@%$OBJECT_MODE%g +s%@ENABLE_STRIP@%$ENABLE_STRIP%g +s%@USE_PTHREADS@%$USE_PTHREADS%g +s%@USE_BTHREADS@%$USE_BTHREADS%g +s%@USE_USER_PTHREADS@%$USE_USER_PTHREADS%g +s%@USE_NATIVE_THREADS@%$USE_NATIVE_THREADS%g +s%@USE_NSPR_THREADS@%$USE_NSPR_THREADS%g +s%@USE_NSS@%$USE_NSS%g +s%@CPU_ARCH@%$CPU_ARCH%g +s%@OBJ_SUFFIX@%$OBJ_SUFFIX%g +s%@LIB_SUFFIX@%$LIB_SUFFIX%g +s%@LIB_PREFIX@%$LIB_PREFIX%g +s%@DLL_SUFFIX@%$DLL_SUFFIX%g +s%@ASM_SUFFIX@%$ASM_SUFFIX%g +s%@PROG_SUFFIX@%$PROG_SUFFIX%g +s%@MKSHLIB@%$MKSHLIB%g +s%@DSO_CFLAGS@%$DSO_CFLAGS%g +s%@DSO_LDOPTS@%$DSO_LDOPTS%g +s%@OS_TARGET@%$OS_TARGET%g +s%@OS_ARCH@%$OS_ARCH%g +s%@OS_RELEASE@%$OS_RELEASE%g +s%@OS_TEST@%$OS_TEST%g +s%@DEFINES@%$DEFINES%g +s%@AR_FLAGS@%$AR_FLAGS%g +s%@ASFLAGS@%$ASFLAGS%g +s%@FILTER@%$FILTER%g +s%@IMPLIB@%$IMPLIB%g +s%@OS_LIBS@%$OS_LIBS%g +s%@RESOLVE_LINK_SYMBOLS@%$RESOLVE_LINK_SYMBOLS%g +s%@NOSUCHFILE@%$NOSUCHFILE%g +s%@MOZ_OBJFORMAT@%$MOZ_OBJFORMAT%g +s%@ULTRASPARC_LIBRARY@%$ULTRASPARC_LIBRARY%g +s%@ULTRASPARC_FILTER_LIBRARY@%$ULTRASPARC_FILTER_LIBRARY%g +s%@OBJDIR@%$OBJDIR%g +s%@OBJDIR_NAME@%$OBJDIR_NAME%g +s%@NSINSTALL@%$NSINSTALL%g +s%@OPTIMIZER@%$OPTIMIZER%g +s%@RC@%$RC%g +s%@DLLFLAGS@%$DLLFLAGS%g +s%@EXEFLAGS@%$EXEFLAGS%g +s%@OS_DLLFLAGS@%$OS_DLLFLAGS%g +s%@CYGWIN_WRAPPER@%$CYGWIN_WRAPPER%g +s%@WIN_TOP_SRC@%$WIN_TOP_SRC%g +s%@NEXT_ROOT@%$NEXT_ROOT%g +s%@RPATHFLAG@%$RPATHFLAG%g +s%@MFLAGS@%$MFLAGS%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <<EOF + +CONFIG_FILES=\${CONFIG_FILES-"$MAKEFILES"} +EOF +cat >> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +EOF +cat >> $CONFIG_STATUS <<EOF + +EOF +cat >> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 +
View file
mozldap-6.0.7.tar.gz/c-sdk/configure.in
Added
@@ -0,0 +1,2677 @@ +dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*- +dnl +dnl ***** BEGIN LICENSE BLOCK ***** +dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1 +dnl +dnl The contents of this file are subject to the Mozilla Public License Version +dnl 1.1 (the "License"); you may not use this file except in compliance with +dnl the License. You may obtain a copy of the License at +dnl http://www.mozilla.org/MPL/ +dnl +dnl Software distributed under the License is distributed on an "AS IS" basis, +dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +dnl for the specific language governing rights and limitations under the +dnl License. +dnl +dnl The Original Code is the Netscape Portable Runtime (NSPR). +dnl +dnl The Initial Developer of the Original Code is +dnl Netscape Communications Corporation. +dnl Portions created by the Initial Developer are Copyright (C) 1998-2000 +dnl the Initial Developer. All Rights Reserved. +dnl +dnl Contributor(s): +dnl Christopher Seawood <cls@seawood.org> +dnl Dan Mosedale <dmose@netscape.com> +dnl Howard Chu <hyc@symas.com> +dnl +dnl Alternatively, the contents of this file may be used under the terms of +dnl either of the GNU General Public License Version 2 or later (the "GPL"), +dnl or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +dnl in which case the provisions of the GPL or the LGPL are applicable instead +dnl of those above. If you wish to allow use of your version of this file only +dnl under the terms of either the GPL or the LGPL, and not to allow others to +dnl use your version of this file under the terms of the MPL, indicate your +dnl decision by deleting the provisions above and replace them with the notice +dnl and other provisions required by the GPL or the LGPL. If you do not delete +dnl the provisions above, a recipient may use your version of this file under +dnl the terms of any one of the MPL, the GPL or the LGPL. +dnl +dnl ***** END LICENSE BLOCK ***** + +AC_PREREQ(2.12) +AC_INIT(ldap/include/ldap.h) + +AC_CONFIG_AUX_DIR(${srcdir}/config/autoconf) +AC_CANONICAL_SYSTEM + +dnl ======================================================== +dnl = Defaults +dnl ======================================================== +NSPR_VERSION=4 +_HAVE_PTHREADS= +USE_PTHREADS= +USE_USER_PTHREADS= +USE_NSPR_THREADS= +USE_N32= +USE_64= +USE_CPLUS= +USE_IPV6= +USE_MDUPDATE= +_OPTIMIZE_FLAGS=-O +_DEBUG_FLAGS=-g +MOZ_DEBUG= +MOZ_OPTIMIZE=1 +MFLAGS= +OBJDIR=. +OBJDIR_NAME=. +NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall' +NOSUCHFILE=/no-such-file +MOZ_OS2_HIGH_MEMORY=1 + +dnl Link in libraries necessary to resolve all symbols for shared libs +RESOLVE_LINK_SYMBOLS= + +dnl ======================================================== +dnl = +dnl = Dont change the following lines. Doing so breaks: +dnl = +dnl = CFLAGS="-foo" ./configure +dnl = +dnl ======================================================== +CFLAGS="${CFLAGS=}" +CXXFLAGS="${CXXFLAGS=}" +LDFLAGS="${LDFLAGS=}" +DLLFLAGS="${DLLFLAGS=}" +HOST_CFLAGS="${HOST_CFLAGS=}" +HOST_LDFLAGS="${HOST_LDFLAGS=}" + +case "$target" in +*-cygwin*|*-mingw*|*-msvc*|*-mks*) + # Check to see if we are really running in a msvc environemnt + _WIN32_MSVC= + AC_CHECK_PROGS(CC, cl) + if test "$CC" = "cl"; then + echo 'main() { return 0; }' > dummy.c + ${CC} -o dummy dummy.c >/dev/null 2>&1 + if test $? = 0; then + _WIN32_MSVC=1 + CXX=$CC + else + AC_MSG_WARN([$(CC) test failed. Using normal feature tests]) + fi + rm -f dummy dummy.o dummy.obj dummy.exe dummy.c + fi + ;; +esac + +if test -n "$_WIN32_MSVC"; then + SKIP_PATH_CHECKS=1 + SKIP_COMPILER_CHECKS=1 + SKIP_LIBRARY_CHECKS=1 +fi + +dnl ======================================================== +dnl = +dnl = Check options that may affect the compiler +dnl = +dnl ======================================================== +dist_prefix='${MOD_DEPTH}/../../dist' +dist_bindir='${dist_prefix}/bin' +dist_libdir='${dist_prefix}/lib' + +AC_ARG_WITH(dist-prefix, + [ --with-dist-prefix=DIST_PREFIX + place build files in DIST_PREFIX [dist]], + dist_prefix=$withval) + +AC_ARG_WITH(dist-bindir, + [ --with-dist-bindir=DIR build execuatables in DIR [DIST_PREFIX/bin]], + dist_bindir=$withval) + +AC_ARG_WITH(dist-libdir, + [ --with-dist-libdir=DIR build library files in DIR [DIST_PREFIX/lib]], + dist_libdir=$withval) + +AC_SUBST(dist_prefix) +AC_SUBST(dist_bindir) +AC_SUBST(dist_libdir) + +dnl Check if LDAP is being compiled for Mozilla +dnl Let --with-arg override environment setting +dnl +AC_ARG_WITH(mozilla, + [ --with-mozilla Compile LDAP with Mozilla support], + [ if test "$withval" = "yes"; then + AC_DEFINE(MOZILLA_CLIENT) + MOZILLA_CLIENT=1 + else + MOZILLA_CLIENT= + fi], + [ if test -n "$MOZILLA_CLIENT"; then + AC_DEFINE(MOZILLA_CLIENT) + fi]) + +AC_ARG_ENABLE(optimize, + [ --enable-optimize(=val) Enable code optimizations (val, ie. -O2) ], + [ if test "$enableval" != "no"; then + MOZ_OPTIMIZE=1 + if test -n "$enableval" && test "$enableval" != "yes"; then + _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'` + _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS + fi + else + MOZ_OPTIMIZE= + fi ]) + +AC_ARG_ENABLE(debug, + [ --enable-debug(=val) Enable debugging (debug flags val)], + [ if test "$enableval" != "no"; then + MOZ_DEBUG=1 + if test -n "$enableval" && test "$enableval" != "yes"; then + _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'` + _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS + fi + else + MOZ_DEBUG= + fi]) + +AC_ARG_ENABLE(win32-target, + [ --enable-win32-target=\$t + Specify win32 flavor. (WIN95 or WINNT)], + OS_TARGET=`echo $enableval | tr a-z A-Z`, + OS_TARGET=) + +AC_ARG_ENABLE(debug-rtl, + [ --enable-debug-rtl Use the MSVC debug runtime library], + [ if test "$enableval" = "yes"; then + USE_DEBUG_RTL=1 + fi ]) + +AC_ARG_ENABLE(n32, + [ --enable-n32 Enable n32 ABI support (IRIX only)], + [ if test "$enableval" = "yes"; then + USE_N32=1 + else if test "$enableval" = "no"; then + USE_N32= + fi + fi ]) + +AC_ARG_ENABLE(64bit, + [ --enable-64bit Enable 64-bit support (on certain platforms)], + [ if test "$enableval" = "yes"; then + USE_64=1 ; export USE_64 + fi ], + []) + +AC_ARG_ENABLE(mdupdate, + [ --enable-mdupdate Enable use of certain compilers' mdupdate feature], + [ if test "$enableval" = "yes"; then + USE_MDUPDATE=1 + fi ]) + +dnl ======================================================== +dnl = build the optional command-line utilities such as +dnl = ldapsearch and ldapmodify. +dnl ======================================================== +AC_ARG_ENABLE(clu, + [ --enable-clu Enable building the command-line utilities], + [ if test "$enableval" = "yes"; then + BUILDCLU=1 + AC_SUBST(BUILDCLU) + fi ], + []) + +dnl ======================================================== +dnl = svrcore gives the command line tools secure PIN management +dnl = for client cert based authentication +dnl ======================================================== +dnl ======================================================== +dnl = Use the SVRCORE copy in the system (assuming it exists) +dnl = rather than the one in the source tree (mozilla/security) +dnl ======================================================== +AC_ARG_WITH(system-svrcore, + [ --with-system-svrcore Use system installed SVRCORE], + [ if test "$withval" = "yes"; then + _SYSTEM_SVRCORE=1 + HAVE_SVRCORE=1 + SVRCORE_LIBS=-lsvrcore + AC_SUBST(SVRCORE_LIBS) + AC_SUBST(HAVE_SVRCORE) +dnl svrcore implies both nspr and nss + USE_NSS=1 + no_nspr=no + else + _SYSTEM_SVRCORE= + fi], _SYSTEM_SVRCORE= ) + +dnl _SYSTEM_SVRCORE means /usr/lib and /usr/include so no need to add additional +dnl include or lib paths +if test -z "$_SYSTEM_SVRCORE" ; then + dnl first, see if user has specified explicit SVRCORE include and lib paths + AM_PATH_GIVEN_SVRCORE() + + dnl next, see if user explicitly said to use system svrcore + if test -n "$HAVE_SVRCORE" ; then +dnl svrcore implies both nspr and nss + USE_NSS=1 + HAVE_SVRCORE=1 + AC_SUBST(HAVE_SVRCORE) + no_nspr=no + if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS" ; then + if test -n "$_SYSTEM_SVRCORE"; then + AM_PATH_SVRCORE(4.0.1, [MOZ_NATIVE_SVRCORE=1], [MOZ_NATIVE_SVRCORE=]) + else + dnl see if we are being built in the same build tree as svrcore + AM_PATH_INTREE_SVRCORE(../../dist) + dnl failing that, see if we can find svrcore-config or pkg-config svrcore + if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS"; then + AM_PATH_SVRCORE(4.0.1, [MOZ_NATIVE_SVRCORE=1], [MOZ_NATIVE_SVRCORE=]) + fi + fi + fi + fi +fi + +if test -n "$HAVE_SVRCORE" -a -z "$_SYSTEM_SVRCORE" ; then + if test -z "$SVRCORE_CFLAGS" -o -z "$SVRCORE_LIBS"; then + AC_MSG_ERROR([--with-svrcore specified, but no svrcore could be found]) + fi +fi + +dnl ======================================================== +dnl = Use the NSS copy in the system (assuming it exists) +dnl = rather than the one in the source tree (mozilla/security) +dnl ======================================================== +AC_ARG_WITH(system-nss, + [ --with-system-nss Use system installed NSS], + [ if test "$withval" = "yes"; then + _SYSTEM_NSS=1 + USE_NSS=1 +dnl nss requires nspr + no_nspr=no + elif test "$withval" = "no" ; then + _SYSTEM_NSS=no + fi], _SYSTEM_NSS= ) + +if test "$_WIN32_MSVC"; then + _SYSTEM_NSS= +fi + +dnl first, see if user has specified explicit NSPR include and lib paths, +dnl of if the user has explicitly disabled the use of nss +if test -z "$_SYSTEM_NSS" -o "$_SYSTEM_NSS" = "no" ; then + AM_PATH_GIVEN_NSS() +fi + +dnl next, see if user explicitly said to use system nss +if test -n "$USE_NSS" -a -z "$NSS_CFLAGS" -a -z "$NSS_LIBS" ; then +dnl nss requires nspr + no_nspr=no + if test -z "$_SYSTEM_NSS" -o "$_SYSTEM_NSS" = "no" ; then +dnl see if we are being built in the same build tree as nss + AM_PATH_INTREE_NSS(../../dist) + fi +dnl failing that, see if we can find nss-config or pkg-config nss + if test -z "$NSS_CFLAGS" -a "$_SYSTEM_NSS" != "no" ; then + AM_PATH_NSS(3.9.0, [MOZ_NATIVE_NSS=1], [MOZ_NATIVE_NSS=]) + fi +fi + +dnl bomb out if nss not found +if test -n "$USE_NSS" -a -z "$NSS_CFLAGS" -a -z "$NSS_LIBS" ; then + AC_MSG_ERROR(Need to use NSS but no NSS was found) +fi + +dnl ======================================================== +dnl = Use the NSPR copy in the system (assuming it exists) +dnl = rather than the one in the source tree (mozilla/nsprpub) +dnl ======================================================== +AC_ARG_WITH(system-nspr, + [ --with-system-nspr Use system installed NSPR], + [ if test "$withval" = "yes"; then + _SYSTEM_NSPR=1 + no_nspr=no + elif test "$withval" = "no"; then + _SYSTEM_NSPR=no + fi], _SYSTEM_NSPR= ) + +if test "$_WIN32_MSVC"; then + _SYSTEM_NSPR=no +fi + +dnl first, see if user has specified explicit NSPR include and lib paths, +dnl of if the user has explicitly disabled the use of nspr +if test -z "$_SYSTEM_NSPR" -o "$_SYSTEM_NSPR" = "no" ; then + AM_PATH_GIVEN_NSPR() +fi + +dnl next, look for in-tree nspr if user did not specify explicit system nspr +if test "$no_nspr" = "no" -a -z "$NSPR_CFLAGS" -a -z "$NSPR_LIBS" ; then + if test -z "$_SYSTEM_NSPR" -o "$_SYSTEM_NSPR" = "no" ; then +dnl see if we are being built in the same build tree as nspr + AM_PATH_INTREE_NSPR(../../dist) + fi +dnl failing that, see if we can find nspr-config or pkg-config nspr + if test -z "$NSPR_CFLAGS" -a "$_SYSTEM_NSPR" != "no" ; then + AM_PATH_NSPR(4.0.0, [MOZ_NATIVE_NSPR=1], [MOZ_NATIVE_NSPR=]) + fi +fi + +dnl if we are being built as part of the mozilla client, and we could not +dnl find NSPR by any other method, just default to the default values +dnl used by the client build - NOTE that this sets the libpaths and the +dnl library link commands directly, so we don't need to muck with any +dnl cygwin path conversion stuff. The client build also uses --with-dist-prefix +dnl which sets $(DIST) in the makefiles +if test -z "$NSPR_CFLAGS" -o -z "$NSPR_LIBS" ; then + if test -n "$MOZILLA_CLIENT" ; then + NSPR_CFLAGS='-I$(DIST)/include/nspr' + NSPR_LIBS='-L$(DIST)/lib '"-lplds$NSPR_VERSION -lplc$NSPR_VERSION -lnspr$NSPR_VERSION" + if test "$_WIN32_MSVC"; then + NSPR_LIBS='$(DIST)/lib/nspr'$NSPR_VERSION'.lib $(DIST)/lib/plc'$NSPR_VERSION'.lib $(DIST)/lib/plds'$NSPR_VERSION'.lib ' + fi + LIBS_ALREADY_SET=1 + AC_SUBST(LIBS_ALREADY_SET) + elif test "$no_nspr" = "no" ; then + AC_MSG_ERROR(Need to use NSPR but no NSPR was found) + fi +fi + +dnl ======================================================== +dnl If using cygwin (or another Windows shell that uses unix +dnl style paths by default - mingw?) and using MSVC, we need +dnl to convert the include and lib paths to the more MSVC +dnl friendly format - it's easier and faster to do it here +dnl than in cygwin-wrapper +dnl ======================================================== + +dnl add other runtime environments that use unix style paths +dnl *-cygwin*|*-mingw*|*-msvc*|*-mks*) +dnl mozilla-build msys seems not to convert -L to /LIBPATH +dnl it just converts -L to /L and link issues an error +case "$target" in +*-cygwin*) USE_WINDOWS_PATHS=1 ;; +*-mingw*) CONVERT_LIBPATH=1 ;; +esac + +if test -n "$_WIN32_MSVC" -a -n "$USE_WINDOWS_PATHS" ; then + if test -n "$NSPR_CFLAGS" -a -z "$LIBS_ALREADY_SET" ; then + path=`echo $NSPR_CFLAGS | sed -e 's/^-I//'` + path=`cygpath -m $path` + NSPR_CFLAGS="/I$path" + fi + if test -n "$NSPR_LIBS" -a -z "$LIBS_ALREADY_SET" ; then + path=`echo $NSPR_LIBS | sed -e 's/^-L//'` + path=`cygpath -m $path` + NSPR_LIBS="/LIBPATH:$path" + fi + + if test -n "$NSS_CFLAGS" ; then + path=`echo $NSS_CFLAGS | sed -e 's/^-I//'` + path=`cygpath -m $path` + NSS_CFLAGS="/I$path" + fi + + if test -n "$NSS_LIBS" ; then + path=`echo $NSS_LIBS | sed -e 's/^-L//'` + path=`cygpath -m $path` + NSS_LIBS="/LIBPATH:$path" + fi + + if test -n "$SVRCORE_CFLAGS" ; then + path=`echo $SVRCORE_CFLAGS | sed -e 's/^-I//'` + path=`cygpath -m $path` + SVRCORE_CFLAGS="/I$path" + fi + + if test -n "$SVRCORE_LIBS" ; then + path=`echo $SVRCORE_LIBS | sed -e 's/^-L//'` + path=`cygpath -m $path` + SVRCORE_LIBS="/LIBPATH:$path" + fi +fi + +dnl there seems to be no way to pass /libpath:/msys/style/path +dnl to the link command line and have that converted to +dnl /libpath:c:\dos\style\path +dnl i've tried -libpath, /libpath, //libpath +dnl msys does not have the cygpath command - however, pwd -W will +dnl return the current directory in a suitable fornat +if test -n "$_WIN32_MSVC" -a -n "$NSPR_LIBS" -a -n "$CONVERT_LIBPATH" -a -z "$LIBS_ALREADY_SET" ; then + path=`echo $NSPR_LIBS | sed -e 's/^-L//'` + path=`cd "$path" ; pwd -W` + NSPR_LIBS="/LIBPATH:$path" +fi +if test -n "$_WIN32_MSVC" -a -n "$NSS_LIBS" -a -n "$CONVERT_LIBPATH" ; then + path=`echo $NSS_LIBS | sed -e 's/^-L//'` + path=`cd "$path" ; pwd -W` + NSS_LIBS="/LIBPATH:$path" +fi +if test -n "$_WIN32_MSVC" -a -n "$SVRCORE_LIBS" -a -n "$CONVERT_LIBPATH" ; then + path=`echo $SVRCORE_LIBS | sed -e 's/^-L//'` + path=`cd "$path" ; pwd -W` + SVRCORE_LIBS="/LIBPATH:$path" +fi + +dnl ======================================================== +dnl = +dnl = Set the threading model +dnl = +dnl ======================================================== +case "$target" in + +*-aix*) + case "${target_os}" in + aix3.2*) + USE_NSPR_THREADS=1 + ;; + *) + USE_PTHREADS=1 + ;; + esac + ;; + +esac + +dnl ======================================================== +dnl = +dnl = Set the default C compiler +dnl = +dnl ======================================================== +if test -z "$CC"; then + case "$target" in + + *-aix*) + if test -z "$USE_NSPR_THREADS"; then + CC=xlC_r + else + CC=xlC + fi + ;; + + *-hpux*) + CC=cc + ;; + + *-irix*) + CC=cc + ;; + + *-osf*) + CC=cc + ;; + + *-solaris*) + CC=cc + ;; + + esac +fi + +dnl ======================================================== +dnl = +dnl = Set the default C++ compiler +dnl = +dnl ======================================================== +if test -z "$CXX"; then + case "$target" in + + *-aix*) + if test -z "$USE_NSPR_THREADS"; then + CXX=xlC_r + else + CXX=xlC + fi + ;; + + *-hpux*) + case "${target_os}" in + hpux10.30) + CXX=aCC + ;; + hpux11.*) + CXX=aCC + ;; + *) + CXX=CC + ;; + esac + ;; + + *-irix*) + CXX=CC + ;; + + *-osf*) + CXX=cxx + ;; + + *-solaris*) + CXX=CC + ;; + + esac +fi + +if test -z "$SKIP_PATH_CHECKS"; then + AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami) +fi + +if test -n "$MOZ_DEBUG"; then + AC_DEFINE(DEBUG) + DEFINES="$DEFINES -UNDEBUG" + case "${target_os}" in + beos*) + DEFINES="$DEFINES -DDEBUG_${USER}" + ;; + msvc*|mks*|cygwin*|mingw*|os2*) + DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`" + ;; + *) + DEFINES="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_`$WHOAMI`" + ;; + esac + MFLAGS="BUILD_DEBUG=full" +else + AC_DEFINE(NDEBUG) + DEFINES="$DEFINES -UDEBUG" + MFLAGS="BUILD_DEBUG=optimize" +fi + +dnl Use mozilla's nsinstall +if test -n "$MOZILLA_CLIENT"; then + NSINSTALL='$(dist_bindir)/nsinstall' +fi + +if test -z "$SKIP_COMPILER_CHECKS"; then +dnl ======================================================== +dnl Checks for compilers. +dnl ======================================================== +dnl NOTE that according to the latest autoconf 2.5x manual +dnl "Now, configure enters cross-compilation mode if and only if `--host' is passed." +dnl However, the mozilla build system expects us to assume different target and host +dnl means cross compiling. But, %configure in many linux RPM build systems sets the +dnl following: +dnl ./configure --build=i686-redhat-linux-gnu --host=i686-redhat-linux-gnu --target=i386-redhat-linux-gnu ... +dnl which means that the system is an i686, but we want to produce code which will run on i386 - in +dnl this case, we _do not_ want to cross compile +dnl So, additional logic: +dnl if $host = $build, do not cross compile +dnl otherwise, cross compile if host is given +cross_compiling=no +dnl host must be specified to cross compile +if test -n "$host" ; then + case $target in + *-darwin*) + if test "$host" != "$target" ; then + cross_compiling=yes + fi + ;; + *) +dnl host == build - do not cross compile + if test "$host" = "$build" ; then + cross_compiling=no +dnl host != build or host != target - do cross compile + elif test "$host" != "$target" -o "$host" != "$build" ; then + cross_compiling=yes + fi + ;; + esac +fi +if test "$cross_compiling" = "no"; then + AC_PROG_CXX + if test "$CXX" = "cl" -a -z "$CC"; then + CC=$CXX + else + AC_PROG_CC + fi + AC_PROG_CPP + AC_PROG_RANLIB + AC_PATH_PROGS(AS, as, $CC) + AC_PATH_PROGS(AR, ar, echo not_ar) + AC_PATH_PROGS(LD, ld link, echo not_ld) + AC_PATH_PROGS(STRIP, strip, echo not_strip) + AC_PATH_PROGS(WINDRES, windres, echo not_windres) + if test -z "$HOST_CC"; then + HOST_CC="$CC" + fi + if test -z "$HOST_CFLAGS"; then + HOST_CFLAGS="$CFLAGS" + fi +else + echo "cross compiling from $host to $target" + + _SAVE_CC="$CC" + _SAVE_CFLAGS="$CFLAGS" + _SAVE_LDFLAGS="$LDFLAGS" + + AC_MSG_CHECKING([for $host compiler]) + AC_CHECK_PROGS(HOST_CC, gcc cc /usr/ucb/cc, "") + if test -z "$HOST_CC"; then + AC_MSG_ERROR([no acceptable cc found in \$PATH]) + fi + AC_MSG_RESULT([$HOST_CC]) + if test -z "$HOST_CFLAGS"; then + HOST_CFLAGS="$CFLAGS" + fi + if test -z "$HOST_LDFLAGS"; then + HOST_LDFLAGS="$LDFLAGS" + fi + + CC=$_SAVE_CC + CFLAGS=$_SAVE_CFLAGS + LDFLAGS=$_SAVE_LDFLAGS + + case "$build:$target" in + powerpc-apple-darwin8*:i?86-apple-darwin*) + dnl The Darwin cross compiler doesn't necessarily point itself at a + dnl root that has libraries for the proper architecture, it defaults + dnl to the system root. The libraries in the system root on current + dnl versions of PPC OS X 10.4 aren't fat, so these target compiler + dnl checks will fail. Fake a working SDK in that case. + _SAVE_CFLAGS=$CFLAGS + _SAVE_CXXFLAGS=$CXXLAGS + CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS" + CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS" + ;; + esac + + AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo) + unset ac_cv_prog_CC + AC_PROG_CC + AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo) + unset ac_cv_prog_CXX + AC_PROG_CXX + + case "$build:$target" in + powerpc-apple-darwin8*:i?86-apple-darwin*) + dnl Revert the changes made above. From this point on, the target + dnl compiler will never be used without applying the SDK to CFLAGS + dnl (see --with-macos-sdk below). + CFLAGS=$_SAVE_CFLAGS + CXXFLAGS=$_SAVE_CXXFLAGS + ;; + esac + + AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", echo) + AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", echo) + AC_CHECK_PROGS(AS, $AS "${target_alias}-as" "${target}-as", echo) + AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", echo) + AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo) + AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo) +fi + +if test "$GCC" = "yes"; then + GNU_CC=1 +fi +if test "$GXX" = "yes"; then + GNU_CXX=1 +fi +if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then + GNU_AS=1 +fi +rm -f a.out + +case "$build:$target" in + i?86-apple-darwin*:powerpc-apple-darwin*) + dnl cross_compiling will have erroneously been set to "no" in this + dnl case, because the x86 build host is able to run ppc code in a + dnl translated environment, making a cross compiler appear native. + cross_compiling=yes + ;; +esac + +if test "$cross_compiling" = "yes"; then + CROSS_COMPILE=1 +else + CROSS_COMPILE= +fi + +dnl ======================================================== +dnl Check for gcc -pipe support +dnl ======================================================== +AC_MSG_CHECKING([for gcc -pipe support]) +if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then + echo '#include <stdio.h>' > dummy-hello.c + echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c + ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5 + cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5 + if test $? = 0; then + _res_as_stdin="yes" + else + _res_as_stdin="no" + fi + if test "$_res_as_stdin" = "yes"; then + _SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -pipe" + AC_TRY_COMPILE( [ #include <stdio.h> ], + [printf("Hello World\n");], + [_res_gcc_pipe="yes"], + [_res_gcc_pipe="no"] ) + CFLAGS=$_SAVE_CFLAGS + fi + if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then + _res="yes"; + CFLAGS="$CFLAGS -pipe" + CXXFLAGS="$CXXFLAGS -pipe" + else + _res="no" + fi + rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out + AC_MSG_RESULT([$_res]) +else + AC_MSG_RESULT([no]) +fi + +fi # SKIP_COMPILER_CHECKS + +dnl ======================================================== +dnl Checks for programs. +dnl ======================================================== +if test -z "$SKIP_PATH_CHECKS"; then + AC_PATH_PROGS(PERL, perl5 perl, echo not_perl) +elif test -z "$PERL"; then + PERL=perl +fi + +dnl ======================================================== +dnl Default platform specific options +dnl ======================================================== +OBJ_SUFFIX=o +LIB_SUFFIX=a +LIB_PREFIX=lib +DLL_SUFFIX=so +ASM_SUFFIX=s +MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@' +AR_FLAGS='cr $@' +AS='$(CC)' +ASFLAGS='$(CFLAGS)' + +if test -n "$CROSS_COMPILE"; then + OS_ARCH=`echo $target_os | sed -e 's|/|_|g'` + OS_RELEASE= + OS_TEST="${target_cpu}" + case "${target_os}" in + linux*) OS_ARCH=Linux ;; + solaris*) OS_ARCH=SunOS OS_RELEASE=5 ;; + mingw*) OS_ARCH=WINNT ;; + darwin*) OS_ARCH=Darwin ;; + esac +else + OS_ARCH=`uname -s | sed -e 's|/|_|g'` + OS_RELEASE=`uname -r` + OS_TEST=`uname -m` +fi + +if test "$OS_ARCH" = "IRIX64"; then + OS_ARCH=IRIX +fi + +if test "$OS_ARCH" = "Linux"; then + OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'` + OS_RELEASE=`echo $OS_RELEASE | awk -F. '{ print $1 "." $2 }'` +fi + +####################################################################### +# Master "Core Components" macros for getting the OS target # +####################################################################### + +# +# Note: OS_TARGET should be specified on the command line for gmake. +# When OS_TARGET=WIN95 is specified, then a Windows 95 target is built. +# The difference between the Win95 target and the WinNT target is that +# the WinNT target uses Windows NT specific features not available +# in Windows 95. The Win95 target will run on Windows NT, but (supposedly) +# at lesser performance (the Win95 target uses threads; the WinNT target +# uses fibers). +# +# When OS_TARGET=WIN16 is specified, then a Windows 3.11 (16bit) target +# is built. See: win16_3.11.mk for lots more about the Win16 target. +# +# If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no +# cross-compilation. +# + +# +# The following hack allows one to build on a WIN95 machine (as if +# s/he were cross-compiling on a WINNT host for a WIN95 target). +# It also accomodates for MKS's uname.exe. If you never intend +# to do development on a WIN95 machine, you don't need this hack. +# +case "$OS_ARCH" in +WIN95) + OS_ARCH=WINNT + OS_TARGET=WIN95 + ;; +Windows_95) + OS_ARCH=Windows_NT + OS_TARGET=WIN95 + ;; +Windows_98) + OS_ARCH=Windows_NT + OS_TARGET=WIN95 + ;; +CYGWIN_9*|CYGWIN_ME*) + OS_ARCH='CYGWIN_NT-4.0' + OS_TARGET=WIN95 + ;; +OS_2) + OS_ARCH=OS2 + OS_TARGET=OS2 + ;; +WINCE) + OS_ARCH=WINCE + OS_TARGET=WINCE + ;; +esac + +# +# On WIN32, we also define the variable CPU_ARCH. +# + +case "$OS_ARCH" in +WINNT) + CPU_ARCH=`uname -p` + if test "$CPU_ARCH" = "I386"; then + CPU_ARCH=x86 + fi + ;; +Windows_NT) +# +# If uname -s returns "Windows_NT", we assume that we are using +# the uname.exe in MKS toolkit. +# +# The -r option of MKS uname only returns the major version number. +# So we need to use its -v option to get the minor version number. +# Moreover, it doesn't have the -p option, so we need to use uname -m. +# + OS_ARCH=WINNT + OS_MINOR_RELEASE=`uname -v` + if test "$OS_MINOR_RELEASE" = "00"; then + OS_MINOR_RELEASE=0 + fi + OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}" + CPU_ARCH=`uname -m` + # + # MKS's uname -m returns "586" on a Pentium machine. + # + if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then + CPU_ARCH=x86 + fi + ;; +CYGWIN32_NT|CYGWIN_NT*|MINGW*_NT*) +# +# If uname -s returns "CYGWIN_NT-4.0", we assume that we are using +# the uname.exe in the Cygwin tools. +# Prior to the Beta 20 release, Cygwin was called GNU-Win32. +# If uname -s returns "CYGWIN32/NT", we assume that we are using +# the uname.exe in the GNU-Win32 tools. +# If uname -s returns MINGW32_NT-5.1, we assume that we are using +# the uname.exe in the MSYS tools. +# + OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'` + OS_ARCH=WINNT + CPU_ARCH=`uname -m` + # + # Cygwin's uname -m returns "i686" on a Pentium Pro machine. + # + if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then + CPU_ARCH=x86 + fi + ;; +esac + +if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then + OS_TARGET=WIN95 + if test -n "$MOZ_DEBUG"; then + USE_DEBUG_RTL=1 + fi +fi +if test -z "$OS_TARGET"; then + OS_TARGET=$OS_ARCH +fi +if test "$OS_TARGET" = "WIN95"; then + OS_RELEASE="4.0" +fi +if test "$OS_TARGET" = "WIN16"; then + OS_RELEASE= +fi + +dnl ======================================================== +dnl = Mac OS X SDK support +dnl ======================================================== +AC_ARG_WITH(macos-sdk, + [ --with-macos-sdk=dir Location of platform SDK to use (Mac OS X only)], + MACOS_SDK_DIR=$withval) + +dnl ======================================================== +dnl Enable high-memory support on OS/2 by default. +dnl ======================================================== +AC_ARG_ENABLE(os2-high-mem, + [ --disable-os2-high-mem Disable high-memory support on OS/2], + [ if test "$enableval" = "no"; then + MOZ_OS2_HIGH_MEMORY= + else + MOZ_OS2_HIGH_MEMORY=1 + fi ]) + +dnl ======================================================== +dnl Override of system specific host options +dnl ======================================================== +case "$host" in +*-mingw*) + NSINSTALL=nsinstall + WIN_TOP_SRC=`cd $srcdir && pwd -W` + ;; +*-cygwin*|*-msvc*|*-mks*) + CYGWIN_WRAPPER='sh $(topsrcdir)/config/cygwin-wrapper' + NSINSTALL='$(CYGWIN_WRAPPER) nsinstall' + if test "`${PERL} -v | grep -c cygwin 2>/dev/null`" = 0; then + PERL='$(CYGWIN_WRAPPER) perl' + fi + WIN_TOP_SRC=`cygpath -w $srcdir | sed -e 's|\\\\|/|g'` + ;; +*-beos*) + HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE" + ;; +*os2*) + ;; +*) + HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX" + ;; +esac + +dnl ======================================================== +dnl Check for --with-rpath and user supplied rpath +dnl ======================================================== +DEFAULT_RPATHFLAG=..:../lib:../../lib:../../../lib:../../../../lib +AC_ARG_WITH(rpath, + [ --with-rpath[[=dir]] Build the shared libs and cmd lines progs with an RPATH (default dir is ..:../lib:../../lib:../../../lib:../../../../lib)], +[ + if test "$withval" = "yes" ; then # set default + RPATHFLAG="$DEFAULT_RPATHFLAG" + elif test -n "$withval" ; then # user supplied + RPATHFLAG="$withval" + fi +]) + +dnl ======================================================== +dnl Override of system specific target options +dnl ======================================================== +case "$target" in + +*-aix*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(AIX) + AC_DEFINE(SYSV) + DSO_LDOPTS='-brtl -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib' + AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H)) + case "${target_os}" in + aix3.2*) + AC_DEFINE(AIX_RENAME_SELECT) + AC_DEFINE(_PR_NO_LARGE_FILES) + ;; + aix4.1*) + AC_DEFINE(AIX_TIMERS) + AC_DEFINE(_PR_NO_LARGE_FILES) + AC_DEFINE(AIX4_1) + MKSHLIB= + DSO_LDOPTS= + ;; + aix4.2*) + AC_DEFINE(AIX_TIMERS) + AC_DEFINE(_PR_HAVE_OFF64_T) + ;; + aix4.3*) + AC_DEFINE(AIX_TIMERS) + AC_DEFINE(_PR_HAVE_OFF64_T) + AC_DEFINE(AIX4_3) + AC_DEFINE(HAVE_SOCKLEN_T) + AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) + USE_IPV6=1 + ;; + *) + AC_DEFINE(AIX_TIMERS) + AC_DEFINE(_PR_HAVE_OFF64_T) + AC_DEFINE(HAVE_SOCKLEN_T) + AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) + USE_IPV6=1 + ;; + esac + CFLAGS="$CFLAGS -qro -qroconst" + if echo "$CC" | grep -c xlC_r; then + CFLAGS="$CFLAGS -qarch=com" + fi + AIX_WRAP='$(DIST)/lib/aixwrap.o' + AIX_TMP='./_aix_tmp.o' + if test -n "$USE_64"; then + OBJECT_MODE=64 + fi + RESOLVE_LINK_SYMBOLS=1 + ;; + +*-beos*) + AC_DEFINE(XP_BEOS) + AC_DEFINE(BeOS) + AC_DEFINE(BEOS) + AC_DEFINE(_POSIX_SOURCE) + DSO_LDOPTS=-nostart + USE_BTHREADS=1 + RESOLVE_LINK_SYMBOLS=1 + case "${target_cpu}" in + i*86) + _OPTIMIZE_FLAGS=-O2 + _DEBUG_FLAGS='-gdwarf-2 -O0' + MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@' + AC_CHECK_LIB(bind, gethostbyaddr, [OS_LIBS="$OS_LIBS -lbind -lsocket"]) + ;; + powerpc) + CC=mwcc + CCC=mwcc + LD=mwld + DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o' + _OPTIMIZE_FLAGS=-O2 + _DEBUG_FLAGS='-g -O0' + ;; + esac + ;; + +*-bsdi*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(BSDI) + AC_DEFINE(NEED_BSDREGEX) + + CFLAGS="$CFLAGS -Wall -Wno-format" + CXXFLAGS="$CXXFLAGS -Wall -Wno-format" + + if echo "$OS_TEST" | grep -c 86 >/dev/null; then + CPU_ARCH=x86 + elif echo "$OS_TEST" | grep -c sparc >/dev/null; then + CPU_ARCH=sparc + fi + + DSO_LDOPTS=-r + + case "$target_os" in + bsdi1.1*) + AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY) + AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME) + AC_DEFINE(_PR_NEED_H_ERRNO) + MKSHLIB= + DSO_CFLAGS= + DSO_LDOPTS= + ;; + + bsdi2.1*) + AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC) + AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY) + AC_DEFINE(HAVE_DLL) + AC_DEFINE(USE_DLFCN) + AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC) + ;; + + bsdi4.*) + AC_DEFINE(_PR_SELECT_CONST_TIMEVAL) + AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT) + AC_DEFINE(HAVE_DLL) + AC_DEFINE(USE_DLFCN) + AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC) + MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)' + DSO_CFLAGS=-fPIC + DSO_LDOPTS='-shared -soname $(@:$(OBJDIR)/%.so=%.so)' + STRIP="$STRIP -d" + case "$target_os" in + bsdi4.2*) + AC_DEFINE(_PR_HAVE_GETPROTO_R) + AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER) + ;; + esac + ;; + *) + AC_DEFINE(_PR_SELECT_CONST_TIMEVAL) + AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT) + AC_DEFINE(HAVE_DLL) + AC_DEFINE(USE_DLFCN) + AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC) + ;; + esac + + ;; + +*-darwin*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(DARWIN) + AC_DEFINE(HAVE_BSD_FLOCK) + CFLAGS="$CFLAGS -Wmost -fno-common" + case "${target_cpu}" in + i*86*) + AC_DEFINE(i386) + CPU_ARCH=i386 + ;; + *) + AC_DEFINE(ppc) + CPU_ARCH=ppc + ;; + esac + DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@' + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + STRIP="$STRIP -x -S" + DLL_SUFFIX=dylib + USE_PTHREADS=1 + + dnl MACOS_SDK_DIR will be set to the SDK location whenever one is + dnl in use. NEXT_ROOT will be set and exported if it's needed for + dnl ld. + + if test "$MACOS_SDK_DIR"; then + dnl Sync this section with the one in Mozilla's top level. + if test ! -d "$MACOS_SDK_DIR"; then + AC_MSG_ERROR([SDK not found. When using --with-macos-sdk, you must +specify a valid SDK. SDKs are installed when the optional cross-development +tools are selected during the Xcode/Developer Tools installation.]) + fi + + changequote(,) + CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'` + GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'` + GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'` + changequote([,]) + GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'` + if test "$GCC_VERSION_MAJOR" -lt "4" ; then + SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks" + if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then + SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks" + fi + + SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}" + + CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}" + + dnl CPP needs to be set for AC_CHECK_HEADER. + CPP="$CPP -nostdinc ${SDK_C_INCLUDE}" + + dnl ld support for -syslibroot is compiler-agnostic, but only + dnl available on Tiger. Although it's possible to switch on + dnl the build host's OS release to use ld -syslibroot when + dnl available, ld -syslibroot cause warnings as long as + dnl NEXT_ROOT is set. NEXT_ROOT should be set because both + dnl both the compiler and linker use it. + dnl + dnl LDFLAGS is for the utilities built in config (now and + dnl nsinstall). DSO_LDOPTS is used when linking shared + dnl libraries. + MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}" + LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS" + DSO_LDOPTS="${MACOS_SDK_LIBS} $DSO_LDOPTS" + export NEXT_ROOT=$MACOS_SDK_DIR + + if test -n "$CROSS_COMPILE" ; then + dnl NEXT_ROOT will be in the environment, but it + dnl shouldn't be set for the build host. HOST_CXX is + dnl presently unused. + HOST_CC="NEXT_ROOT= $HOST_CC" + HOST_CXX="NEXT_ROOT= $HOST_CXX" + fi + else + dnl gcc >= 4.0 uses different paths than above, but knows + dnl how to find them itself. + CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}" + + dnl CPP needs to be set for AC_CHECK_HEADER. + CPP="$CPP -isysroot ${MACOS_SDK_DIR}" + + dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which + dnl has an ld that supports -syslibroot. Don't set + dnl NEXT_ROOT because it will be ignored and cause + dnl warnings when -syslibroot is specified. + dnl + dnl Both LDFLAGS and DSO_LDOPTS are set here, see the + dnl gcc < 4.0 case for the explanation. + if test "$GCC_VERSION_FULL" != "4.0.0" ; then + dnl gcc > 4.0.0 will pass -syslibroot to ld automatically + dnl based on the -isysroot it receives. + LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}" + DSO_LDOPTS="$DSO_LDOPTS -isysroot ${MACOS_SDK_DIR}" + else + dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs + dnl to be explicit. + LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}" + DSO_LDOPTS="$DSO_LDOPTS -Wl,-syslibroot,${MACOS_SDK_DIR}" + fi + fi + fi + ;; + +*-dgux*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(_PR_LOCAL_THREADS_ONLY) + AC_DEFINE(SVR4) + AC_DEFINE(SYSV) + AC_DEFINE(DGUX) + AC_DEFINE(_DGUX_SOURCE) + AC_DEFINE(_POSIX4A_DRAFT6_SOURCE) + DSO_LDOPTS=-G + _OPTIMIZE_FLAGS=-O2 + _DEBUG_FLAGS= + ;; + +*-dragonfly*) + if test -z "$USE_NSPR_THREADS"; then + USE_PTHREADS=1 + fi + AC_DEFINE(XP_UNIX) + AC_DEFINE(DRAGONFLY) + DSO_CFLAGS=-fPIC + DSO_LDOPTS='-shared' + ;; + +*-freebsd*) + if test -z "$USE_NSPR_THREADS"; then + USE_PTHREADS=1 + fi + AC_DEFINE(XP_UNIX) + AC_DEFINE(FREEBSD) + AC_DEFINE(HAVE_BSD_FLOCK) + CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall" + MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf` + if test "$MOZ_OBJFORMAT" = "elf"; then + DLL_SUFFIX=so + else + DLL_SUFFIX=so.1.0 + fi + DSO_CFLAGS=-fPIC + DSO_LDOPTS=-Bshareable + ;; + +*-hpux*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(HPUX) + AC_DEFINE(_HPUX_SOURCE) + if test "$OS_TEST" = "ia64" ; then + AC_DEFINE(ia64) + DLL_SUFFIX=so + else + AC_DEFINE(hppa) + DLL_SUFFIX=sl + fi + DSO_LDOPTS='-b +h $(notdir $@)' + if test -z "$GNU_CC"; then + CC="$CC -Ae" + CXX="$CXX -ext" + if test "$OS_RELEASE" = "B.11.23"; then + CFLAGS="$CFLAGS +Olit=all" + CXXFLAGS="$CXXFLAGS +Olit=all" + else + CFLAGS="$CFLAGS +ESlit" + CXXFLAGS="$CXXFLAGS +ESlit" + fi + DSO_CFLAGS=+Z + else + DSO_CFLAGS=-fPIC + fi + + if test -n "$MOZILLA_CLIENT"; then + DEFAULT_IMPL_STRATEGY=_EMU + fi + + if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then + AC_DEFINE(_PR_NEED_H_ERRNO) + AC_DEFINE(HPUX9) + DEFAULT_IMPL_STRATEGY=_EMU + USE_NSPR_THREADS=1 + fi + + if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then + AC_DEFINE(_PR_NO_LARGE_FILES) + fi + + if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then + AC_DEFINE(_PR_NEED_H_ERRNO) + fi + + if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then + AC_DEFINE(HAVE_INT_LOCALTIME_R) + fi + + if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00|B.11.11|B.11.23)' >/dev/null; then + AC_DEFINE(HAVE_POINTER_LOCALTIME_R) + fi + + if test "$OS_RELEASE" = "B.10.01"; then + AC_DEFINE(HPUX10) + DEFAULT_IMPL_STRATEGY=_EMU + fi + + if test "$OS_RELEASE" = "B.10.10"; then + AC_DEFINE(HPUX10) + AC_DEFINE(HPUX10_10) + DEFAULT_IMPL_STRATEGY=_PTH + fi + + if test "$OS_RELEASE" = "B.10.20"; then + AC_DEFINE(HPUX10) + AC_DEFINE(HPUX10_20) + if test -z "$GNU_CC"; then + CFLAGS="$CFLAGS +DAportable +DS1.1" + CXXFLAGS="$CXXFLAGS +DAportable +DS1.1" + fi + DEFAULT_IMPL_STRATEGY=_PTH + fi + + if test "$OS_RELEASE" = "B.10.30"; then + AC_DEFINE(HPUX10) + AC_DEFINE(HPUX10_30) + if test -z "$GNU_CC"; then + CFLAGS="$CFLAGS +DAportable +DS1.1" + CXXFLAGS="$CXXFLAGS +DAportable +DS1.1" + fi + DEFAULT_IMPL_STRATEGY=_PTH + fi + + if echo "$OS_RELEASE" | egrep '^(B.11.00|B.11.11)' >/dev/null; then + AC_DEFINE(HPUX10) + AC_DEFINE(HPUX11) + AC_DEFINE(_LARGEFILE64_SOURCE) + AC_DEFINE(_PR_HAVE_OFF64_T) + AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) + if test -z "$GNU_CC"; then + if test -z "$USE_64"; then + CFLAGS="$CFLAGS +DAportable +DS2.0" + CXXFLAGS="$CXXFLAGS +DAportable +DS2.0" + else + CFLAGS="$CFLAGS +DA2.0W +DS2.0" + CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0" + fi + fi + DEFAULT_IMPL_STRATEGY=_PTH + fi + + if test "$OS_RELEASE" = "B.11.23"; then + AC_DEFINE(HPUX10) + AC_DEFINE(HPUX11) + AC_DEFINE(_LARGEFILE64_SOURCE) + AC_DEFINE(_PR_HAVE_OFF64_T) + AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) + if test -z "$GNU_CC"; then + if test -z "$USE_64"; then + CFLAGS="$CFLAGS +DD32" + CXXFLAGS="$CXXFLAGS +DD32" + else + CFLAGS="$CFLAGS +DD64" + CXXFLAGS="$CXXFLAGS +DD64" + fi + fi + DEFAULT_IMPL_STRATEGY=_PTH + fi + + if test "$DEFAULT_RPATHFLAG" = "$RPATHFLAG" ; then + if test "$OS_RELEASE" = "B.11.23" -o "$OS_RELEASE" = "B.11.11" ; then + # add ORIGIN to default rpath + RPATHFLAG="\\\$\$ORIGIN/../lib:\\\$\$ORIGIN/../../lib:$RPATHFLAG" + fi + fi + + if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then + USE_NSPR_THREADS=1 + USE_PTHREADS= + USE_USER_THREADS= + elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then + USE_PTHREADS=1 + if test "$USE_NSPR_THREADS"; then + USE_PTHREADS= + fi + if test "$USE_USER_PTHREADS"; then + USE_PTHREADS= + fi + fi + + ;; + +*-irix*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(IRIX) + AC_DEFINE(SVR4) + AC_DEFINE(_SGI_MP_SOURCE) + AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) + DSO_LDOPTS='-rdata_shared -shared' + MKSHLIB='$(LD) $(DSO_LDOPTS) -soname $(notdir $@) -o $@' + STRIP="$STRIP -f" + RESOLVE_LINK_SYMBOLS=1 + case "${target_os}" in + irix6*) + AC_DEFINE(IRIX6) + USE_PTHREADS=1 + USE_N32=1 + ;; + irix5*) + AC_DEFINE(IRIX5) + USE_NSPR_THREADS=1 + ;; + *) + USE_PTHREADS=1 + USE_N32=1 + ;; + esac + if test "$GNU_CC"; then + dnl + dnl If we are using gcc with native binutils, we need to + dnl suppress the + dnl #lineno "filename" num num + dnl lines, which confuse IRIX native as. Add -Wp,-P to the + dnl gcc command line, which passes -P to the preprocessor. + dnl + AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)' + CFLAGS="$CFLAGS -Wall -Wno-format" + _OPTIMIZE_FLAGS="-O6" + else + if test -n "$USE_N32"; then + AS='as -D_ASM $(INCLUDES) -n32' + else + AS='as -D_ASM $(INCLUDES)' + fi + CFLAGS="$CFLAGS -fullwarn -xansi" + if test "$USE_N32"; then + _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000" + else + _OPTIMIZE_FLAGS="-O -Olimit 4000" + fi + if test "$USE_MDUPDATE"; then + CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" + fi + case "$target}" in + *-irix6.*) + CFLAGS="$CFLAGS -multigot" + DSO_LDOPTS="$DSO_LDOPTS -no_unresolved" + if test "$USE_N32"; then + CFLAGS="$CFLAGS -n32 -woff 1209" + DSO_LDOPTS="$DSO_LDOPTS -n32" + else + if test "$USE_64"; then + CFLAGS="$CFLAGS -64" + else + CFLAGS="$CFLAGS -32" + fi + fi + ;; + *) + CFLAGS="$CFLAGS -xgot" + ;; + esac + fi + if test "${target_os}" = "irix5.3"; then + AC_DEFINE(IRIX5_3) + fi + case "${target_os}" in + irix6.5) + if test -z "$GNU_CC"; then + CFLAGS="$CFLAGS -mips3" + fi + AC_DEFINE(_PR_HAVE_GETPROTO_R) + AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER) + AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK) + ;; + irix5*) + ;; + *) + AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK) + ;; + esac + ;; + +*-linux*) + if test -z "$USE_NSPR_THREADS"; then + USE_PTHREADS=1 + fi + AC_DEFINE(XP_UNIX) + AC_DEFINE(_POSIX_SOURCE) + AC_DEFINE(_BSD_SOURCE) + AC_DEFINE(_SVID_SOURCE) + AC_DEFINE(_LARGEFILE64_SOURCE) + AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) + AC_DEFINE(LINUX) + AC_DEFINE(linux) + LD='$(CC)' + CFLAGS="$CFLAGS -ansi -Wall" + CXXFLAGS="$CXXFLAGS -ansi -Wall" + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + DSO_CFLAGS=-fPIC + DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' + OS_LIBS="$OS_LIBS -lc" + _OPTIMIZE_FLAGS=-O2 + _DEBUG_FLAGS="-g -fno-inline" # most people on linux use gcc/gdb, and that + # combo is not yet good at debugging inlined + # functions (even when using DWARF2 as the + # debugging format) + case "$OS_TEST" in + i*86) + CPU_ARCH=x86 + ;; + *) + CPU_ARCH=$OS_TEST + ;; + esac + + case "${target_cpu}" in + alpha) + AC_DEFINE(_ALPHA_) + AC_DEFINE(__alpha) + CFLAGS="$CFLAGS -mieee" + CXXFLAGS="$CXXFLAGS -mieee" + ;; + i*86) + AC_DEFINE(i386) + ;; + ia64) + ;; + m68k) + CFLAGS="$CFLAGS -m68020-40" + CXXFLAGS="$CXXFLAGS -m68020-40" + # + # gcc on Linux/m68k either has a bug or triggers a code-sequence + # bug in the 68060 which causes gcc to crash. The simplest way to + # avoid this is to enable a minimum level of optimization. + # + _DEBUG_FLAGS="$_DEBUG_FLAGS -O" + ;; + esac + ;; + +*-mingw*|*-cygwin*|*-msvc*|*-mks*) + AC_DEFINE(XP_PC) + AC_DEFINE(WIN32) + AC_DEFINE(_WINDOWS) + RESOLVE_LINK_SYMBOLS=1 + PROG_SUFFIX=.exe + if test -n "$GNU_CC"; then + CC="$CC -mno-cygwin" + CXX="$CXX -mno-cygwin" + DLL_SUFFIX=dll + MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) -o $@' + # Use temp file for windres (bug 213281) + RC="$WINDRES -O coff --use-temp-file" + else + CC=cl + CXX=cl + LD=link + # if the lib program is available, use it, otherwise use link /lib + AC_CHECK_PROG(HAVE_MSVC_LIB, lib, 1) + if test "$HAVE_MSVC_LIB" = "1" ; then + AR='lib -NOLOGO -OUT:"$@"' + else + AR='$(LD) /lib -NOLOGO -OUT:"$@"' + fi + + AR_FLAGS= + RANLIB='echo not_ranlib' + STRIP='echo not_strip' + RC=rc.exe + GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb' + OBJ_SUFFIX=obj + LIB_SUFFIX=lib + LIB_PREFIX= + DLL_SUFFIX=dll + + # Determine compiler version + changequote(,) + _MSVC_VER_FILTER='s|.* \([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p' + changequote([,]) + + CC_VERSION=`"${CC}" -v 2>&1 | sed -ne "$_MSVC_VER_FILTER"` + _CC_MAJOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $1 }'` + _CC_MINOR_VERSION=`echo ${CC_VERSION} | awk -F\. '{ print $2 }'` + _CC_RELEASE=`echo ${CC_VERSION} | awk -F\. '{ print $3 }'` + _CC_BUILD=`echo ${CC_VERSION} | awk -F\. '{ print $4 }'` + _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION} + + if test "$_CC_MAJOR_VERSION" -eq "14"; then + dnl -DYNAMICBASE is only supported on VC8SP1 or newer, + dnl so be very specific here! + dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762 + if test "$_CC_RELEASE" -gt 50727 -o \ + \( "$_CC_RELEASE" -eq 50727 -a "$_CC_BUILD" -ge 762 \); then + _USE_DYNAMICBASE=1 + fi + elif test $_CC_MAJOR_VERSION -ge 15; then + _USE_DYNAMICBASE=1 + fi + + if test -n "$_USE_DYNAMICBASE"; then + DLLFLAGS="$DLLFLAGS -DYNAMICBASE" + fi + + CFLAGS="$CFLAGS -W3 -nologo -GF -Gy" + DLLFLAGS="$DLLFLAGS -OUT:\"\$@\"" + + _DEBUG_FLAGS=-Z7 + _OPTIMIZE_FLAGS=-O2 + if test -z "$MOZ_OPTIMIZE"; then + CFLAGS="$CFLAGS -Od" + fi + + if test -n "$USE_DEBUG_RTL"; then + CFLAGS="$CFLAGS -MDd" + else + CFLAGS="$CFLAGS -MD" + fi + + if test -n "$MOZ_DEBUG"; then + AC_DEFINE(_DEBUG) + else + DEFINES="$DEFINES -U_DEBUG" + fi + + if test -n "$MOZ_OPTIMIZE"; then + if test -n "$MOZ_DEBUG_SYMBOLS"; then + _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Zi" + DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF" + LDFLAGS="$LDFLAGS -DEBUG -OPT:REF" + fi + fi + + if test -n "$MOZ_DEBUG"; then + DLLFLAGS="$DLLFLAGS -DEBUG" + LDFLAGS="$LDFLAGS -DEBUG" + fi + + OS_DLLFLAGS='-nologo -DLL -SUBSYSTEM:WINDOWS' + if test "$_MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then + OS_DLLFLAGS="$OS_DLLFLAGS -PDB:NONE" + fi + + if test "$OS_TARGET" = "WINNT"; then + CFLAGS="$CFLAGS -GT" + if test "$CPU_ARCH" = "x86"; then + CFLAGS="$CFLAGS -G5" + fi + fi + fi # GNU_CC + + if test -n "$USE_STATIC_TLS"; then + AC_DEFINE(_PR_USE_STATIC_TLS) + fi + + if test "$OS_TARGET" = "WINNT"; then + AC_DEFINE(WINNT) + else + AC_DEFINE(WIN95) + # undefine WINNT as some versions of mingw gcc define it by default + DEFINES="$DEFINES -UWINNT" + AC_DEFINE(_PR_GLOBAL_THREADS_ONLY) + fi + + case "$OS_TARGET" in + WINNT) + ;; + WIN95) + ;; + WIN16) + ;; + *) + AC_MSG_ERROR([Missing OS_TARGET for ${target}. Use --enable-win32-target to set.]) + ;; + esac + + case "$target_cpu" in + i*86) + if test -n "$USE_64"; then + AC_DEFINE(_AMD64_) + AC_DEFINE(_M_AMD64) + else + AC_DEFINE(_X86_) + fi + ;; + alpha) + AC_DEFINE(_ALPHA_) + ;; + mips) + AC_DEFINE(_MIPS_) + ;; + x86_64) + AC_DEFINE(_AMD64_) + AC_DEFINE(_M_AMD64) + ;; + *) + AC_DEFINE(_CPU_ARCH_NOT_DEFINED) + ;; + esac + + if test -n "$USE_64"; then + AC_DEFINE(_WIN64) + fi + ;; + +*-ncr-sysv*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(SVR4) + AC_DEFINE(SYSV) + AC_DEFINE(NCR) + USE_NSPR_THREADS=1 + if test "$OS_RELEASE" = "2.03"; then + AC_DEFINE(_PR_STAT_HAS_ST_ATIM) + else + AC_DEFINE(_PR_STAT_HAS_ST_ATIM_UNION) + fi + + if test -z "$GNU_CC"; then + CFLAGS="$CFLAGS -Hnocopyr" + CXXFLAGS="$CXXFLAGS -Hnocopyr" + else + CFLAGS="$CFLAGS -fPIC -Wall" + CXXFLAGS="$CXXFLAGS -fPIC -Wall" + DSO_LDOPTS=-G + fi + ;; + +mips-nec-sysv*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(SVR4) + AC_DEFINE(__SVR4) + AC_DEFINE(NEC) + AC_DEFINE(nec_ews) + USE_NSPR_THREADS=1 + if test -z "$GNU_CC"; then + CC='$(NSDEPTH)/build/hcc cc -Xa -KGnum=0 -KOlimit=4000' + CXX=g++ + fi + OS_LIBS="$OS_LIBS -lsocket -lnsl -ldl" + DSO_LDOPTS=-G + ;; + +*-netbsd*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(NETBSD) + AC_DEFINE(HAVE_BSD_FLOCK) + USE_NSPR_THREADS=1 + + DSO_CFLAGS='-fPIC -DPIC' + CFLAGS="$CFLAGS -ansi -Wall" + CXXFLAGS="$CXXFLAGS -ansi -Wall" + MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)' + + if test -z "$OBJECT_FMT"; then + if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then + OBJECT_FMT=a.out + DLL_SUFFIX=so.1.0 + DSO_LDOPTS='-shared' + else + OBJECT_FMT=ELF + DLL_SUFFIX=so + DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)' + fi + fi + + if test "$LIBRUNPATH"; then + DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH" + fi + ;; + +mips-sony-newsos*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(SONY) + AC_DEFINE(SYSV) + AC_DEFINE(SVR4) + AC_DEFINE(__svr4) + AC_DEFINE(__svr4__) + AC_DEFINE(HAVE_SVID_GETTOD) + USE_NSPR_THREADS=1 + CFLAGS="$CFLAGS -Xa -fullwarn" + CXXFLAGS="$CXXFLAGS -Xa -fullwarn" + DSO_LDOPTS=-G + ;; + +*-nextstep*|*-openstep*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(NEXTSTEP) + AC_DEFINE(HAVE_BSD_FLOCK) + AC_DEFINE(_POSIX_SOURCE) + CFLAGS="$CFLAGS -Wall -fno-common -traditional-cpp -posix" + CXXFLAGS="$CXXFLAGS -Wall -fno-common -traditional-cpp -posix" + USE_NSPR_THREADS=1 + DLL_SUFFIX=dylib + ;; + + +*-nto*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(NTO) + AC_DEFINE(_QNX_SOURCE) + AC_DEFINE(HAVE_POINTER_LOCALTIME_R) + MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@' + DSO_CFLAGS=-fPIC + DSO_LDOPTS=-shared + OS_LIBS="$OS_LIBS -lsocket" + _OPTIMIZE_FLAGS="-O1" + _DEBUG_FLAGS="-gstabs" + ;; + +*-openbsd*) + LD='$(CC)' + AC_DEFINE(XP_UNIX) + AC_DEFINE(OPENBSD) + AC_DEFINE(HAVE_BSD_FLOCK) + AC_DEFINE(HAVE_SOCKLEN_T) + CFLAGS="$CFLAGS -ansi -Wall" + CXXFLAGS="$CXXFLAGS -ansi -Wall" + DLL_SUFFIX=so.1.0 + DSO_CFLAGS=-fPIC + USE_NSPR_THREADS=1 + DSO_LDOPTS='-shared -fPIC' + ;; + +*-openvms*) + AC_DEFINE(XP_UNIX) + RESOLVE_LINK_SYMBOLS=1 + AR_FLAGS='c $@' + DSO_LDOPTS='-shared -auto_symvec $(LDFLAGS) $(OPTIMIZER)' + ;; + +*-os2*) + AC_DEFINE(OS2) + AC_DEFINE(XP_OS2) + AC_DEFINE(XP_PC) +# AC_DEFINE(USE_OS2_TOOLKIT_HEADERS) + AC_DEFINE(TCPV40HDRS) + AC_DEFINE(BSD_SELECT) + AC_DEFINE(_PR_GLOBAL_THREADS_ONLY) + RESOLVE_LINK_SYMBOLS=1 + NSINSTALL=nsinstall + LIB_PREFIX= + LIB_SUFFIX=lib + DLL_SUFFIX=dll + DLLTOOL='' + RC=rc.exe + PROG_SUFFIX=.exe + AR=emxomfar + AR_FLAGS='r $@' + LD='$(CC)' + CFLAGS="$CFLAGS -Wall -Zomf" + CXXFLAGS="$CFLAGS -Wall -Zomf" + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + DSO_CFLAGS= + DSO_LDOPTS='-Zomf -Zdll' + _OPTIMIZE_FLAGS=-O3 + _DEBUG_FLAGS="-g -fno-inline" + if test -n "$MOZ_OPTIMIZE"; then + DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA" + fi + OS_LIBS="-lsocket" + IMPLIB='emximp -o' + FILTER='emxexp -o' + if test -n "$MOZ_OS2_HIGH_MEMORY"; then + DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem" + LDFLAGS="$LDFLAGS -Zhigh-mem" + AC_DEFINE(MOZ_OS2_HIGH_MEMORY) + fi + + # GCC for OS/2 currently predefines these, but we don't want them + DEFINES="$DEFINES -Uunix -U__unix -U__unix__" + ;; + +*-osf*) + SHELL_OVERRIDE="SHELL = /usr/bin/ksh" + AC_DEFINE(XP_UNIX) + AC_DEFINE(OSF1) + AC_DEFINE(_REENTRANT) + AC_CHECK_HEADER(machine/builtins.h, AC_DEFINE(OSF1_HAVE_MACHINE_BUILTINS_H)) + + if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then + USE_NSPR_THREADS=1 + fi + + if test -z "$GNU_CC"; then + CC="$CC -std1 -ieee_with_inexact" + if test "$OS_RELEASE" != "V2.0"; then + CC="$CC -readonly_strings" + fi + _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000" + fi + + if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then + AC_DEFINE(HAVE_INT_LOCALTIME_R) + else + AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) + AC_DEFINE(HAVE_POINTER_LOCALTIME_R) + fi + if echo $OS_RELEASE | grep -c V4.0 >/dev/null; then + AC_DEFINE(OSF1V4_MAP_PRIVATE_BUG) + fi + DSO_LDOPTS='-shared -all -expect_unresolved "*" -soname $(notdir $@)' + ;; + +*-qnx*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(QNX) + AC_DEFINE(_PR_NEED_H_ERRNO) + USE_NSPR_THREADS=1 + ;; + +*-*-sco*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(SCO) + AC_DEFINE(sco) + AC_DEFINE(SYSV) + AC_DEFINE(_SVID3) + AC_DEFINE(_PR_NEED_H_ERRNO) + CC='cc -b elf -KPIC' + CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w' + USE_NSPR_THREADS=1 + CPU_ARCH=x86 + DSO_LDOPTS='-b elf -G' + ;; + +*-sinix*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(SVR4) + AC_DEFINE(SNI) + AC_DEFINE(RELIANTUNIX) + AC_DEFINE(sinix) + AC_DEFINE(HAVE_SVID_GETTOD) + if echo "$OS_TEST" | grep -c 86 2>/dev/null; then + AC_DEFINE(i386) + CPU_ARCH=x86 + else + CPU_ARCH=mips + fi + + if test "$GNU_CC"; then + AS='$(CC) -x assembler-with-cpp' + if test "$CPU_ARCH" = "mips"; then + LD=gld + fi + CFLAGS="$CFLAGS -Wall -Wno-format" + else + AS='/usr/bin/cc' + _OPTIMIZE_FLAGS='-O -F Olimit,4000' + fi + + DSO_LDOPTS='-G -z defs -h $(@:$(OBJDIR)/%.so=%.so)' + + if test "$OS_RELEASE" = "5.43"; then + AC_DEFINE(IP_MULTICAST) + fi + + OS_LIBS="$OS_LIBS -lsocket -lnsl -lresolv -ldl -lc" + USE_NSPR_THREADS=1 + ;; + +*-sunos*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(SUNOS4) + CFLAGS="$CFLAGS -Wall -Wno-format" + if test "$USE_MDUPDATE"; then + CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" + fi + CPU_ARCH=sparc + DLL_SUFFIX=so.1.0 + DSO_LDOPTS= + DSO_CFLAGS=-fPIC + USE_NSPR_THREADS=1 + if test "$OS_RELEASE" = "4.1.3_U1"; then + _OPTIMIZE_FLAGS= + OS_LIBS="$OS_LIBS -lm" + fi + ;; + +*-solaris*) + if test -z "$USE_USER_THREADS" && test -z "$USE_NATIVE_THREADS"; then + USE_PTHREADS=1 + fi + AC_DEFINE(XP_UNIX) + AC_DEFINE(SVR4) + AC_DEFINE(SYSV) + AC_DEFINE(__svr4) + AC_DEFINE(__svr4__) + AC_DEFINE(SOLARIS) + AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) + if test -n "$GNU_CC" ; then + if test -n "$USE_64"; then + CC="$CC -m64" + CXX="$CXX -m64" + fi + LD='$(CC)' + DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' + DSO_CFLAGS=-fPIC + CFLAGS="$CFLAGS -Wall" + CXXFLAGS="$CXXFLAGS -Wall" + if test -n "$USE_MDUPDATE"; then + CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" + CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)" + fi + else + LD=/usr/ccs/bin/ld + RANLIB=/usr/ccs/bin/ranlib + DSO_LDOPTS='-G -h $(notdir $@)' + DSO_CFLAGS=-KPIC + if test -n "$USE_64"; then + if test "$OS_TEST" = "i86pc"; then + CC="$CC -xarch=amd64" + CXX="$CXX -xarch=amd64" + else + CC="$CC -xarch=v9" + CXX="$CXX -xarch=v9" + fi + fi + CC="$CC -xstrconst" + if test -z "$MOZ_OPTIMIZE"; then + CFLAGS="$CFLAGS -xs" + CXXFLAGS="$CXXFLAGS -xs" + fi + fi + if test "$DEFAULT_RPATHFLAG" = "$RPATHFLAG" ; then + # add origin stuff + RPATHFLAG="\\\$\$ORIGIN/../lib:\\\$\$ORIGIN/../../lib:$RPATHFLAG" + fi + if test -z "$GNU_AS"; then + ASFLAGS="$ASFLAGS -Wa,-P" + fi + if test "$OS_TEST" = "i86pc"; then + AC_DEFINE(i386) + + # The default debug format, DWARF (-g), is not supported by gcc + # on i386-ANY-sysv4/solaris, but the stabs format is. It is + # assumed that the Solaris assembler /usr/ccs/bin/as is used. + # If your gcc uses GNU as, you do not need the -Wa,-s option. + if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then + _DEBUG_FLAGS=-gstabs + if test -z "$GNU_AS"; then + _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s" + fi + fi + fi + case "${target_os}" in + solaris2.3*) + AC_DEFINE(_PR_NO_LARGE_FILES) + ;; + solaris2.4*) + AC_DEFINE(_PR_NO_LARGE_FILES) + ;; + solaris2.5*) + AC_DEFINE(SOLARIS2_5) + ;; + *) + AC_DEFINE(_PR_HAVE_OFF64_T) + # The lfcompile64(5) man page on Solaris 2.6 says: + # For applications that do not wish to conform to the POSIX or + # X/Open specifications, the 64-bit transitional interfaces + # are available by default. No compile-time flags need to be + # set. + # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default. + # The native compiler, gcc 2.8.x, and egcs don't have this problem. + if test -n "$GNU_CC"; then + AC_DEFINE(_LARGEFILE64_SOURCE) + fi + ;; + esac + if test "$OS_TEST" = "sun4u"; then + # 64-bit Solaris requires SPARC V9 architecture, so the following + # is not needed. + if test -z "$USE_64"; then + ULTRASPARC_LIBRARY=ultrasparc + ULTRASPARC_FILTER_LIBRARY=libatomic.so + DSO_LDOPTS="$DSO_LDOPTS -f "'$(ULTRASPARC_FILTER_LIBRARY)' + fi + fi + ;; + +*-sco-sysv5*) + AC_DEFINE(XP_UNIX) + AC_DEFINE(UNIXWARE) + AC_DEFINE(SVR4) + AC_DEFINE(SYSV) + USE_NSPR_THREADS=1 + if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then + AC_DEFINE(_PR_NO_LARGE_FILES) + CC='$(NSDEPTH)/build/hcc cc' + CXX='$(NSDEPTH)/build/hcpp CC' + else + AC_DEFINE(_LARGEFILE64_SOURCE) + AC_DEFINE(_PR_HAVE_OFF64_T) + AC_DEFINE(_PR_HAVE_SOCKADDR_LEN) + fi + DSO_LDOPTS=-G + CPU_ARCH=x86 + ;; + +*) + AC_DEFINE(XP_UNIX) + ;; + +esac + +if test -z "$SKIP_LIBRARY_CHECKS"; then +dnl ======================================================== +dnl Check for system libraries +dnl ======================================================== +dnl AC_CHECK_LIB(C, main) +dnl AC_CHECK_LIB(C_r, main) +dnl AC_CHECK_LIB(c, main) +dnl AC_CHECK_LIB(c_r, main) +dnl AC_CHECK_LIB(dce, main) +dnl AC_CHECK_LIB(dl, main) +dnl AC_CHECK_LIB(dld, main) +dnl AC_CHECK_LIB(gen, main) +dnl AC_CHECK_LIB(ip6, main) +dnl AC_CHECK_LIB(l, main) +dnl AC_CHECK_LIB(m, main) +dnl AC_CHECK_LIB(nsl, main) +dnl AC_CHECK_LIB(posix4, main) +dnl AC_CHECK_LIB(prstrms, main) +dnl AC_CHECK_LIB(prstrms_shr, main) +dnl AC_CHECK_LIB(pthread, main) +dnl AC_CHECK_LIB(pthreads, main) +dnl AC_CHECK_LIB(resolv, main) +dnl AC_CHECK_LIB(rt, main) +dnl AC_CHECK_LIB(socket, main) +dnl AC_CHECK_LIB(svld, main) +dnl AC_CHECK_LIB(thread, main) +dnl AC_CHECK_LIB(vms_jackets, main) + +AC_CHECK_FUNC(dlopen,,[ + AC_CHECK_LIB(dl, dlopen, [OS_LIBS="-ldl $OS_LIBS"]) +]) + +dnl ======================================================== +dnl Check for system header files. +dnl ======================================================== +dnl AC_HEADER_DIRENT +dnl AC_HEADER_STDC +dnl AC_HEADER_SYS_WAIT +dnl AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/ioctl.h sys/time.h unistd.h) + +dnl ======================================================== +dnl Check for typedefs and structs +dnl ======================================================== +dnl AC_C_CONST +dnl AC_TYPE_UID_T +dnl AC_TYPE_MODE_T +dnl AC_TYPE_OFF_T +dnl AC_TYPE_PID_T +dnl AC_TYPE_SIZE_T +dnl AC_STRUCT_ST_BLKSIZE +dnl AC_STRUCT_ST_BLOCKS +dnl AC_STRUCT_ST_RDEV +dnl AC_HEADER_TIME +dnl AC_STRUCT_TM + +dnl ======================================================== +dnl Checks for library functions. +dnl ======================================================== +AC_PROG_GCC_TRADITIONAL +AC_CHECK_FUNCS(lchown strerror getaddrinfo getnameinfo) + +dnl AC_FUNC_MEMCMP +dnl AC_FUNC_MMAP +dnl AC_FUNC_SETVBUF_REVERSED +dnl AC_FUNC_STRCOLL +dnl AC_FUNC_STRFTIME +dnl AC_FUNC_UTIME_NULL +dnl AC_FUNC_VPRINTF +dnl AC_CHECK_FUNCS(ftime getcwd gethostname gettimeofday getwd mkdir mktime putenv rmdir select socket strdup strerror strstr strtol strtoul uname) + +dnl ======================================================== +dnl Check options +dnl ======================================================== + +dnl ======================================================== +dnl = +dnl = --enable-strip +dnl = +dnl = Enable stripping of libs and executables +dnl = +dnl ======================================================== +AC_ARG_ENABLE(strip, +[ --enable-strip Enable stripping of shared libs and programs], + [ ENABLE_STRIP=1 ]) + +dnl +dnl Apparently, some systems cannot properly check for the pthread +dnl library unless <pthread.h> is included so we need to test +dnl using it +dnl +dnl MOZ_CHECK_PTHREADS(lib, success, failure) +AC_DEFUN(MOZ_CHECK_PTHREADS, +[ +AC_MSG_CHECKING([for pthread_create in -l$1]) +echo " + #include <pthread.h> + void *foo(void *v) { int a = 1; } + int main() { + pthread_t t; + if (!pthread_create(&t, 0, &foo, 0)) { + pthread_join(t, 0); + } + exit(0); + }" > dummy.c ; + echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5; + ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5; + _res=$? ; + rm -f dummy.c dummy${ac_exeext} ; + if test "$_res" = "0"; then + AC_MSG_RESULT([yes]) + [$2] + else + AC_MSG_RESULT([no]) + [$3] + fi +]) + +MOZ_CHECK_PTHREADS(pthreads, + _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads", + MOZ_CHECK_PTHREADS(pthread, + _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread", + MOZ_CHECK_PTHREADS(c_r, + _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r", + MOZ_CHECK_PTHREADS(c, + _HAVE_PTHREADS=1 + ) + ) + ) +) + +AC_ARG_WITH(pthreads, + [ --with-pthreads Use system pthreads library as thread subsystem], + [ if test "$withval" = "yes"; then + if test -n "$_HAVE_PTHREADS"; then + USE_PTHREADS=1 + USE_USER_PTHREADS= + USE_NSPR_THREADS= + else + AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]); + fi + else + USE_PTHREADS= + _PTHREAD_LDFLAGS= + fi], + [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USER_NSPR_THREADS"; then + USE_PTHREADS=1 + USE_USER_PTHREADS= + USE_NSPR_THREADS= + fi]) + +AC_ARG_ENABLE(user-pthreads, + [ --enable-user-pthreads Build using userland pthreads], + [ if test "$enableval" = "yes"; then + if test -n "$_HAVE_PTHREADS"; then + USE_PTHREADS= + USE_USER_PTHREADS=1 + USE_NSPR_THREADS= + else + AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]); + fi + fi]) + +AC_ARG_ENABLE(nspr-threads, + [ --enable-nspr-threads Build using classic nspr threads], + [ if test "$enableval" = "yes"; then + USE_PTHREADS= + USE_USER_PTHREADS= + USE_NSPR_THREADS=1 + fi]) + +case "$target" in +*-beos*) + AC_ARG_WITH(bthreads, + [ --with-bthreads Use system bthreads library as thread subsystem (BeOS only)], + [ if test "$withval" = "yes"; then + USE_BTHREADS=1 + USE_USER_PTHREADS= + USE_PTHREADS= + fi]) + ;; + +*-solaris*) + AC_ARG_WITH(native-threads, + [ --with-native-threads Use native system threads as thread subsystem (Solaris only)], + [ if test "$withval" = "yes"; then + USE_NATIVE_THREADS=1 + USE_USER_PTHREADS= + USE_PTHREADS= + fi]) + ;; +esac + +fi # SKIP_LIBRARY_CHECKS + +AC_ARG_ENABLE(cplus, + [ --enable-cplus Enable some c++ api routines], + [ if test "$enableval" = "yes"; then + USE_CPLUS=1 + fi]) + +AC_ARG_ENABLE(ipv6, + [ --enable-ipv6 Compile ipv6 support], + [ if test "$enableval" = "yes"; then + USE_IPV6=1 + fi]) + +dnl ======================================================== +dnl = check for sasl options +dnl = This has to come after we set all of the platform specific +dnl = compiler and linker flags +dnl ======================================================== +AM_PATH_GIVEN_SASL() + +if test -n "$USE_PTHREADS"; then + dnl See if -pthread is supported. + rm -f conftest* + ac_cv_have_dash_pthread=no + AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread) + echo 'int main() { return 0; }' | cat > conftest.c + ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1 + if test $? -eq 0; then + if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then + ac_cv_have_dash_pthread=yes + CFLAGS="$CFLAGS -pthread" + CXXFLAGS="$CXXFLAGS -pthread" + fi + fi + rm -f conftest* + AC_MSG_RESULT($ac_cv_have_dash_pthread) + + dnl + dnl See if -pthreads is supported. + dnl + ac_cv_have_dash_pthreads=no + if test "$ac_cv_have_dash_pthread" = "no"; then + AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads) + echo 'int main() { return 0; }' | cat > conftest.c + ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1 + if test $? -eq 0; then + if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then + ac_cv_have_dash_pthreads=yes + CFLAGS="$CFLAGS -pthreads" + CXXFLAGS="$CXXFLAGS -pthreads" + fi + fi + rm -f conftest* + AC_MSG_RESULT($ac_cv_have_dash_pthreads) + fi + + case "$target" in + *-solaris*) + if test "$ac_cv_have_dash_pthreads" = "yes"; then + _PTHREAD_LDFLAGS= + fi + ;; + *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*) + AC_DEFINE(_THREAD_SAFE) + dnl -pthread links in -lc_r, so don't specify it explicitly. + if test "$ac_cv_have_dash_pthread" = "yes"; then + _PTHREAD_LDFLAGS= + fi + ;; + *-linux*) + AC_DEFINE(_REENTRANT) + ;; + esac + +else + if test -n "$USE_USER_PTHREADS"; then + USE_PTHREADS= + USE_NSPR_THREADS= + else + _PTHREAD_LDFLAGS= + fi +fi +dnl Special thread exceptions + +case "$target" in +*-aix*) + if test -n "$USE_NSPR_THREADS"; then + AC_DEFINE(_PR_LOCAL_THREADS_ONLY) + fi + case "$target_os" in + aix4.1*) + if test -z "$USE_PTHREADS"; then + AC_DEFINE(AIX_RENAME_SELECT) + fi + ;; + aix4.2*) + if test -z "$USE_NSPR_THREADS"; then + AC_DEFINE(HAVE_POINTER_LOCALTIME_R) + fi + ;; + aix4.3*) + if test -z "$USE_NSPR_THREADS"; then + AC_DEFINE(HAVE_POINTER_LOCALTIME_R) + fi + if test -n "$USE_PTHREADS"; then + AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST) + fi + ;; + esac + ;; +*-bsdi*) + if test -n "$USE_PTHREADS"; then + AC_DEFINE(_PR_NEED_PTHREAD_INIT) + fi + ;; +*-freebsd*) + if test -n "$USE_NSPR_THREADS"; then + AC_DEFINE(_PR_LOCAL_THREADS_ONLY) + fi + ;; +*-hpux*) + if test -n "$USE_NSPR_THREADS"; then + AC_DEFINE(_PR_LOCAL_THREADS_ONLY) + fi + if test "$USE_PTHREADS"; then + if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then + AC_DEFINE(_REENTRANT) + AC_DEFINE(_PR_DCETHREADS) + else + AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L) + AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST) + fi + fi + if test "$USE_USER_PTHREADS"; then + AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L) + fi + ;; +*-irix*) + if test "${target_os}" = "irix6.5"; then + if test -n "$USE_PTHREADS"; then + AC_DEFINE(_PR_HAVE_GETHOST_R) + AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER) + fi + fi + ;; +*-linux*) + if test -n "$USE_NSPR_THREADS"; then + AC_DEFINE(_PR_LOCAL_THREADS_ONLY) + fi + ;; +*-mingw*|*-cygwin*|*-msvc*|*-mks*|*-os2*|*-beos*) + dnl win32, os2 & beos cannot use pthreads + USE_PTHREADS= + _PTHREAD_LDFLAGS= + USE_USER_PTHREADS= + ;; +*-netbsd*) + if test -n "$USE_NSPR_THREADS"; then + AC_DEFINE(_PR_LOCAL_THREADS_ONLY) + fi + ;; +*-osf*) + if test -n "$USE_NSPR_THREADS"; then + AC_DEFINE(_PR_LOCAL_THREADS_ONLY) + fi + if test -n "$USE_PTHREADS"; then + if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then + : + else + AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST) + fi + fi + ;; +*-solaris*) + if test -n "$USE_NATIVE_THREADS"; then + AC_DEFINE(_PR_GLOBAL_THREADS_ONLY) + else + if test -n "$USE_NSPR_THREADS"; then + AC_DEFINE(_PR_LOCAL_THREADS_ONLY) + fi + fi + if test -z "$USE_NSPR_THREADS"; then + AC_DEFINE(_REENTRANT) + AC_DEFINE(HAVE_POINTER_LOCALTIME_R) + fi + ;; +*-nto*) + if test -n "$USE_PTHREADS"; then + AC_DEFINE(_PR_HAVE_GETHOST_R) + AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER) + fi + ;; +esac + +OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS" + +dnl If the user passed in arg to --enable-optimize or --enable-debug, +dnl make sure that we use it. +if test -n "$_SAVE_OPTIMIZE_FLAGS"; then + _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS" +fi + +if test -n "$_SAVE_DEBUG_FLAGS"; then + _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS" +fi + +if test -n "$MOZ_OPTIMIZE"; then + CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS" + CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS" +fi + +if test -n "$MOZ_DEBUG"; then + CFLAGS="$CFLAGS $_DEBUG_FLAGS" + CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS" +fi + +dnl ======================================================== +dnl Use cygwin wrapper for win32 builds, except MinGW/MSYS +dnl ======================================================== +case "$target_os" in +cygwin*|msvc*|mks*) + CC="\$(CYGWIN_WRAPPER) $CC" + CXX="\$(CYGWIN_WRAPPER) $CXX" + RC="\$(CYGWIN_WRAPPER) $RC" + ;; +esac + +dnl ======================================================== +dnl Substitution of found variables. +dnl ======================================================== +AC_SUBST(SHELL_OVERRIDE) + +AC_SUBST(MOZILLA_CLIENT) +AC_SUBST(CC) +AC_SUBST(CXX) +AC_SUBST(CFLAGS) +AC_SUBST(CXXFLAGS) +AC_SUBST(CPPFLAGS) +AC_SUBST(HOST_CC) +AC_SUBST(HOST_CFLAGS) +AC_SUBST(LDFLAGS) +AC_SUBST(GNU_CC) +AC_SUBST(CROSS_COMPILE) + +AC_SUBST(MOZ_OPTIMIZE) + +AC_SUBST(USE_CPLUS) +AC_SUBST(USE_IPV6) +AC_SUBST(USE_N32) +AC_SUBST(USE_64) +AC_SUBST(OBJECT_MODE) +AC_SUBST(ENABLE_STRIP) + +AC_SUBST(USE_PTHREADS) +AC_SUBST(USE_BTHREADS) +AC_SUBST(USE_USER_PTHREADS) +AC_SUBST(USE_NATIVE_THREADS) +AC_SUBST(USE_NSPR_THREADS) +AC_SUBST(USE_NSS) +AC_SUBST(NSS_CFLAGS) +AC_SUBST(NSS_LIBS) + +AC_SUBST(CPU_ARCH) + +AC_SUBST(OBJ_SUFFIX) +AC_SUBST(LIB_SUFFIX) +AC_SUBST(LIB_PREFIX) +AC_SUBST(DLL_SUFFIX) +AC_SUBST(ASM_SUFFIX) +AC_SUBST(PROG_SUFFIX) +AC_SUBST(MKSHLIB) +AC_SUBST(DSO_CFLAGS) +AC_SUBST(DSO_LDOPTS) + +AC_SUBST(OS_TARGET) +AC_SUBST(OS_ARCH) +AC_SUBST(OS_RELEASE) +AC_SUBST(OS_TEST) + +AC_SUBST(DEFINES) +AC_SUBST(DEFS) +AC_SUBST(AR) +AC_SUBST(AR_FLAGS) +AC_SUBST(AS) +AC_SUBST(ASFLAGS) +AC_SUBST(LD) +AC_SUBST(WINDRES) +AC_SUBST(RANLIB) +AC_SUBST(PERL) +AC_SUBST(STRIP) +AC_SUBST(FILTER) +AC_SUBST(IMPLIB) + +AC_SUBST(OS_LIBS) +AC_SUBST(RESOLVE_LINK_SYMBOLS) +AC_SUBST(NOSUCHFILE) +AC_SUBST(MOZ_OBJFORMAT) +AC_SUBST(ULTRASPARC_LIBRARY) +AC_SUBST(ULTRASPARC_FILTER_LIBRARY) + +AC_SUBST(OBJDIR) +AC_SUBST(OBJDIR_NAME) +AC_SUBST(NSINSTALL) +AC_SUBST(OPTIMIZER) +AC_SUBST(RC) +AC_SUBST(DLLFLAGS) +AC_SUBST(EXEFLAGS) +AC_SUBST(OS_DLLFLAGS) +AC_SUBST(CYGWIN_WRAPPER) +AC_SUBST(WIN_TOP_SRC) +AC_SUBST(NEXT_ROOT) +AC_SUBST(RPATHFLAG) + +AC_SUBST(MFLAGS) + +dnl ======================================================== +dnl Generate output files. +dnl ======================================================== +MAKEFILES=" +Makefile +config/Makefile +config/autoconf.mk +ldap/Makefile +ldap/clients/tools/Makefile +ldap/include/Makefile +ldap/libraries/Makefile +ldap/libraries/libldap/Makefile +ldap/libraries/libprldap/Makefile +ldap/libraries/libldif/Makefile +ldap/libraries/liblber/Makefile +ldap/libraries/libiutil/Makefile +ldap/libraries/libssldap/Makefile +ldap/libraries/libutil/Makefile +" + +dnl since configure won't handle 2 levels of directory +dnl structure for us.. +mkdir ldap > /dev/null 2>&1 +mkdir ldap/clients > /dev/null 2>&1 + +echo $MAKEFILES > unallmakefiles + +AC_OUTPUT([$MAKEFILES])
View file
mozldap-6.0.7.tar.gz/c-sdk/gmakefile.win
Changed
(renamed from mozilla/directory/c-sdk/gmakefile.win)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/Makefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/Makefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/Makefile.in
Changed
(renamed from mozilla/directory/c-sdk/ldap/Makefile.in)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/build/compver.sh
Changed
(renamed from mozilla/directory/c-sdk/ldap/build/compver.sh)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/build/genexports.pl
Changed
(renamed from mozilla/directory/c-sdk/ldap/build/genexports.pl)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/build/my_overrides.mk
Changed
(renamed from mozilla/directory/c-sdk/ldap/build/my_overrides.mk)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/build/nsftp.sh
Changed
(renamed from mozilla/directory/c-sdk/ldap/build/nsftp.sh)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/build/replace.pl
Changed
(renamed from mozilla/directory/c-sdk/ldap/build/replace.pl)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/build/replace.pm
Changed
(renamed from mozilla/directory/c-sdk/ldap/build/replace.pm)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/Makefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/Makefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/Makefile.in
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/Makefile.in)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/Options.txt
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/Options.txt)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/argpin.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/argpin.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/argpin.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/argpin.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/common.c
Added
@@ -0,0 +1,2773 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * code that is shared by two or more of the LDAP command line tools + */ + +#include "ldaptool.h" +#include "fileurl.h" + +#ifdef LDAP_TOOL_ARGPIN +#include "argpin.h" +#include "ntuserpin.h" +#endif /* LDAP_TOOL_ARGPIN */ + +#include <nspr.h> +#include <stdlib.h> +#include <time.h> /* for time() and ctime() */ +#ifdef HAVE_SASL_OPTIONS +#include <sasl.h> +#include "ldaptool-sasl.h" +#endif /* HAVE_SASL_OPTIONS */ + +#if defined(HPUX) +#include <sys/termios.h> /* for tcgetattr and tcsetattr */ +#endif /* HPUX */ + +#if !defined(macintosh) && !defined(DOS) && !defined( _WINDOWS ) +#include <sys/socket.h> +#endif + +static LDAP_REBINDPROC_CALLBACK get_rebind_credentials; +static void print_library_info( const LDAPAPIInfo *aip, FILE *fp ); +static int wait4result( LDAP *ld, int msgid, struct berval **servercredp, + char *msg ); +static int parse_result( LDAP *ld, LDAPMessage *res, + struct berval **servercredp, char *msg, int freeit ); +static int check_response_controls( LDAP *ld, char *msg, LDAPControl **ctrls, int freeit ); + +#ifdef LDAPTOOL_DEBUG_MEMORY +static void *ldaptool_debug_malloc( size_t size ); +static void *ldaptool_debug_calloc( size_t nelem, size_t elsize ); +static void *ldaptool_debug_realloc( void *ptr, size_t size ); +static void ldaptool_debug_free( void *ptr ); +#endif /* LDAPTOOL_DEBUG_MEMORY */ + +#if defined(NET_SSL) && defined(LDAP_TOOL_PKCS11) +static void ldaptool_setcallbacks( struct ldapssl_pkcs_fns *pfns); +static char * buildTokenCertName( const char *tokenName, const char *certName); +#endif +#ifdef HAVE_SASL_OPTIONS +static int saslSetParam(char *saslarg); +#endif /* HAVE_SASL_OPTIONS */ + +/* copied from ldaprot.h - required to parse the pwpolicy ctrl */ +#define LDAP_TAG_PWP_WARNING 0xA0L /* context specific + constructed */ +#define LDAP_TAG_PWP_SECSLEFT 0x80L /* context specific + primitive */ +#define LDAP_TAG_PWP_GRCLOGINS 0x81L /* context specific + primitive + 1 */ +#define LDAP_TAG_PWP_ERROR 0x81L /* context specific + primitive + 1 */ + +/* + * display usage for common options with one exception: -f is not included + * since the description tends to be tool-specific. + * + * As of 1-Jul-1998, of the characters in the set [A-Za-z] the following are + * not currently used by any of the tools: EJgjqr + */ +void +ldaptool_common_usage( int two_hosts ) +{ + fprintf( stderr, " -n\t\tshow what would be done but don't actually do it\n" ); + fprintf( stderr, " -v\t\trun in verbose mode (diagnostics to standard output)\n" ); + if ( two_hosts ) { + fprintf( stderr, " -h host\tLDAP server1 name or IP address (default: %s)\n", LDAPTOOL_DEFHOST ); + fprintf( stderr, " -p port\tLDAP server1 TCP port number (default: %d)\n", LDAP_PORT ); + fprintf( stderr, " -h host\tLDAP server2 name or IP address (default: %s)\n", LDAPTOOL_DEFHOST ); + fprintf( stderr, " -p port\tLDAP server2 TCP port number (default: %d)\n", LDAP_PORT ); + } else { + fprintf( stderr, " -h host\tLDAP server name or IP address (default: %s)\n", LDAPTOOL_DEFHOST ); + fprintf( stderr, " -p port\tLDAP server TCP port number (default: %d)\n", LDAP_PORT ); + } + fprintf( stderr, + " -V n\tLDAP protocol version number (%d or %d; default: %d)\n", + LDAP_VERSION2, LDAP_VERSION3, LDAP_VERSION3 ); +#if defined(NET_SSL) + fprintf( stderr, " -ZZ\t\tstart TLS request\n" ); + fprintf( stderr, " -ZZZ\tenforce start TLS request (successful server response required)\n" ); + fprintf( stderr, " -Z\t\tmake an SSL-encrypted connection\n" ); + fprintf( stderr, " -P pathname\tpath to SSL certificate database (default: current directory)\n" ); + fprintf( stderr, " -N\t\tname of certificate to use for SSL client authentication\n" ); + fprintf( stderr, " -K pathname\tpath to key database to use for SSL client authentication\n" ); + fprintf( stderr, " \t\t(default: path to certificate database provided with -P option)\n" ); +#ifdef LDAP_TOOL_PKCS11 + fprintf( stderr, " -m pathname\tpath to security module database\n"); +#endif /* LDAP_TOOL_PKCS11 */ + fprintf( stderr, " -W\t\tSSL key password\n" ); + fprintf( stderr, " -W - \tprompt for SSL key password\n" ); +#ifdef LDAP_TOOL_PKCS11 + fprintf( stderr, " -I file\tSSL key password 'file' containing token:password pair/s\n" ); + fprintf( stderr, " -Q [token][:certificate name]\tPKCS 11\n" ); +#endif /* LDAP_TOOL_PKCS11 */ + fprintf( stderr, " -3\t\tcheck hostnames in SSL certificates\n" ); +#endif /* NET_SSL */ + fprintf( stderr, " -D binddn\tbind dn\n" ); + fprintf( stderr, " -w passwd\tbind passwd (for simple authentication)\n" ); + fprintf( stderr, " -w - \tprompt for bind passwd (for simple authentication)\n" ); + fprintf( stderr, " -j file\tread bind passwd from 'file' (for simple authentication)\n" ); + fprintf( stderr, " -E\t\task server to expose (report) bind identity\n" ); + fprintf( stderr, " -g\t\tdo not send a password policy request control\n" ); +#ifdef LDAP_DEBUG + fprintf( stderr, " -d level\tset LDAP debugging level to `level'\n" ); +#endif + fprintf( stderr, " -R\t\tdo not automatically follow referrals\n" ); + fprintf( stderr, " -O limit\tmaximum number of referral hops to traverse (default: %d)\n", LDAPTOOL_DEFREFHOPLIMIT ); + fprintf( stderr, " -M\t\tmanage references (treat them as regular entries)\n" ); + fprintf( stderr, " -0\t\tignore LDAP library version mismatches\n" ); + fprintf( stderr, " -i charset\tcharacter set for command line input (default taken from locale)\n" ); + fprintf( stderr, " \t\tuse '-i 0' to override locale settings and bypass any conversions\n" ); + fprintf( stderr, " -k do not convert password to utf8 (use default from locale)\n" ); +#if 0 +/* + * Suppress usage for -y (old proxied authorization control) even though + * we still support it. We want to encourage people to use -Y instead (the + * new proxied authorization control). + */ + fprintf( stderr, " -y proxydn\tDN used for proxy authorization\n" ); +#endif + fprintf( stderr, " -Y proxyid\tproxied authorization id,\n" ); + fprintf( stderr, " \te.g, dn:uid=bjensen,dc=example,dc=com\n" ); + fprintf( stderr, " -H\t\tdisplay usage information\n" ); + fprintf( stderr, " -J controloid[:criticality[:value|::b64value|:<fileurl]]\n" ); + fprintf( stderr, "\t\tcriticality is a boolean value (default is false)\n" ); +#ifdef HAVE_SASL_OPTIONS +#ifdef HAVE_SASL_OPTIONS_2 + fprintf( stderr, " -2 attrName=attrVal\tSASL options which are described in the man page\n"); +#else + fprintf( stderr, " -o attrName=attrVal\tSASL options which are described in the man page\n"); +#endif +#endif /* HAVE_SASL_OPTIONS */ +} + +/* globals */ +char *ldaptool_charset = NULL; +char *ldaptool_host = LDAPTOOL_DEFHOST; +char *ldaptool_host2 = LDAPTOOL_DEFHOST; +int ldaptool_port = LDAP_PORT; +int ldaptool_port2 = LDAP_PORT; +int ldaptool_verbose = 0; +int ldaptool_not = 0; +int ldaptool_nobind = 0; +int ldaptool_noconv_passwd = 0; +FILE *ldaptool_fp = NULL; +char *ldaptool_progname = ""; +LDAPControl *ldaptool_request_ctrls[CONTROL_REQUESTS] = {0}; +#ifdef LDAP_DEBUG +int ldaptool_dbg_lvl = 0; +#endif /* LDAP_DEBUG */ + +/* statics */ +static char *binddn = NULL; +static char *passwd = NULL; +static int send_auth_response_ctrl = 0; +static int user_specified_port = 0; +static int user_specified_port2 = 0; +static int chase_referrals = 1; +static int lib_version_mismatch_is_fatal = 1; +static int ldversion = -1; /* use default */ +static int refhoplim = LDAPTOOL_DEFREFHOPLIMIT; +static int send_manage_dsait_ctrl = 0; +static int prompt_password = 0; +static int prompt_sslpassword = 0; +static FILE *password_fp = NULL; +static char *proxyauth_id = NULL; +static int proxyauth_version = 2; /* use newer proxy control */ +static int no_pwpolicy_req_ctrl = 0; +#ifdef HAVE_SASL_OPTIONS +static unsigned sasl_flags = LDAP_SASL_AUTOMATIC; +static char *sasl_mech = NULL; +static char *sasl_authid = NULL; +static char *sasl_realm = NULL; +static char *sasl_username = NULL; +static char *sasl_secprops = NULL; +static int ldapauth = -1; +#endif /* HAVE_SASL_OPTIONS */ + +#if defined(NET_SSL) +static int secure = 0; +static int isZ = 0; +static int isZZ = 0; +static int isZZZ = 0; +static int isN = 0; +static int isW = 0; +static int isw = 0; +static int isD = 0; +static int isj = 0; +static int isk = 0; +static int ssl_strength = LDAPTOOL_DEFSSLSTRENGTH; +static char *ssl_certdbpath = NULL; +static char *ssl_keydbpath = NULL; +static char *ssl_certname = NULL; +static char *ssl_passwd = NULL; + +#ifdef LDAP_TOOL_PKCS11 +static char *ssl_secmodpath = NULL; + +static char *pkcs_token = NULL; + +static char *ssl_donglefile = NULL; + +#if 0 +static char *pkcs_pin = NULL; +#endif +static struct ldapssl_pkcs_fns local_pkcs_fns = + {0,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL }; + +#endif /* LDAP_TOOL_PKCS11 */ +#endif /* NET_SSL */ + + + +/* + * Handle general initialization and options that are common to all of + * the LDAP tools. + * Handle options that are common to all of the LDAP tools. + * Note the the H option is included here but handled via the + * extra_opt_callback function (along with any "extra_opts" ). + * + * Return: final value for optind or -1 if usage should be displayed (for + * some fatal errors, we call exit here). + */ +int +ldaptool_process_args( int argc, char **argv, char *extra_opts, + int two_hosts, void (*extra_opt_callback)( int option, char *optarg )) +{ + int rc, i, hostnum; + char *optstring, *common_opts; + extern char *optarg; + extern int optind; + LDAPAPIInfo ldai; + char *ctrl_arg, *ctrl_oid=NULL, *ctrl_value=NULL; + int ctrl_criticality=0, vlen; + LDAPControl *ldctrl; + + /* + * Set program name global based on argv[0]. + */ + if (( ldaptool_progname = strrchr( argv[ 0 ], '/' )) == NULL ) { + ldaptool_progname = argv[ 0 ]; + } else { + ++ldaptool_progname; + } + +#ifdef LDAPTOOL_DEBUG_MEMORY + { + struct ldap_memalloc_fns mafns = { + ldaptool_debug_malloc, + ldaptool_debug_calloc, + ldaptool_debug_realloc, + ldaptool_debug_free + }; + + ldap_set_option( NULL, LDAP_OPT_MEMALLOC_FN_PTRS, &mafns ); + } +#endif /* LDAPTOOL_DEBUG_MEMORY */ + +#ifdef LDAP_DEBUG + i = LDAP_DEBUG_ANY; + ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, (void *) &i); +#endif + + /* + * Perform a sanity check on the revision of the LDAP API library to + * make sure it is at least as new as the one we were compiled against. + * If the API implementation is from the same vendor as we were compiled + * against, we also check to make sure the vendor version is at least + * as new as the library we were compiled against. + * + * Version differences are fatal unless the -0 option is passed on the + * tool command line (that's a zero, not an oh). We check for the + * presence of -0 in a crude way to it must appear by itself in argv. + */ + for ( i = 1; i < argc; ++i ) { + if ( strcmp( argv[i], "-0" ) == 0 ) { + lib_version_mismatch_is_fatal = 0; + break; + } + } + + memset( &ldai, 0, sizeof(ldai)); + ldai.ldapai_info_version = LDAP_API_INFO_VERSION; + if (( rc = ldap_get_option( NULL, LDAP_OPT_API_INFO, &ldai )) != 0 ) { + fprintf( stderr, "%s: unable to retrieve LDAP library version" + " information;\n\tthis program requires an LDAP library that" + " implements revision\n\t%d or greater of the LDAP API.\n", + ldaptool_progname, LDAP_API_VERSION ); + if ( lib_version_mismatch_is_fatal ) { + exit( LDAP_LOCAL_ERROR ); + } + } else if ( ldai.ldapai_api_version < LDAP_API_VERSION ) { + fprintf( stderr, "%s: this program requires an LDAP library that" + " implements revision\n\t%d or greater of the LDAP API;" + " running with revision %d.\n", + ldaptool_progname, LDAP_API_VERSION, ldai.ldapai_api_version ); + if ( lib_version_mismatch_is_fatal ) { + exit( LDAP_LOCAL_ERROR ); + } + } else if ( strcmp( ldai.ldapai_vendor_name, LDAP_VENDOR_NAME ) != 0 ) { + fprintf( stderr, "%s: this program requires %s's LDAP\n" + "\tlibrary version %2.2f or greater; running with\n" + "\t%s's version %2.2f.\n", + ldaptool_progname, LDAP_VENDOR_NAME, + (float)LDAP_VENDOR_VERSION / 100, + ldai.ldapai_vendor_name, + (float)ldai.ldapai_vendor_version / 100 ); + if ( lib_version_mismatch_is_fatal ) { + exit( LDAP_LOCAL_ERROR ); + } + } else if ( ldai.ldapai_vendor_version < LDAP_VENDOR_VERSION ) { + fprintf( stderr, "%s: this program requires %s's LDAP\n" + "\tlibrary version %2.2f or greater; running with" + " version %2.2f.\n", + ldaptool_progname, LDAP_VENDOR_NAME, + (float)LDAP_VENDOR_VERSION / 100, + (float)ldai.ldapai_vendor_version / 100 ); + if ( lib_version_mismatch_is_fatal ) { + exit( LDAP_LOCAL_ERROR ); + } + } + + /* + * Process command line options. + */ + if ( extra_opts == NULL ) { + extra_opts = ""; + } + +#ifdef HAVE_SASL_OPTIONS +#ifdef HAVE_SASL_OPTIONS_2 + common_opts = "kgnvEMRHZ02:3d:D:f:h:j:I:K:N:O:P:p:W:w:V:m:i:y:Y:J:"; +#else + common_opts = "kgnvEMRHZ03d:D:f:h:j:I:K:N:O:o:P:p:W:w:V:m:i:y:Y:J:"; +#endif +#else + common_opts = "kgnvEMRHZ03d:D:f:h:j:I:K:N:O:P:p:Q:W:w:V:m:i:k:y:Y:J:"; +#endif /* HAVE_SASL_OPTIONS */ + + if (( optstring = (char *) malloc( strlen( extra_opts ) + strlen( common_opts ) + + 1 )) == NULL ) { + perror( "malloc" ); + exit( LDAP_NO_MEMORY ); + } + + sprintf( optstring, "%s%s", common_opts, extra_opts ); + + if ( argc == 2 ) { + if ( ((strncmp( argv[1], "/?", strlen("/?") + 1 )) == 0 ) || + ((strncmp( argv[1], "-help", strlen("-help") + 1 )) == 0 ) || + ((strncmp( argv[1], "--help", strlen("--help") + 1 )) == 0 ) ) { + return( -1 ); + } + } + + hostnum = 0; + while ( (i = getopt( argc, argv, optstring )) != EOF ) { + switch( i ) { + case 'n': /* do Not do any LDAP operations */ + ++ldaptool_not; + break; + case 'v': /* verbose mode */ + ++ldaptool_verbose; + break; + case 'd': +#ifdef LDAP_DEBUG + ldaptool_dbg_lvl = atoi( optarg ); /* */ + ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, + (void *)&ldaptool_dbg_lvl); + ldaptool_dbg_lvl |= LDAP_DEBUG_ANY; + ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, + (void *)&ldaptool_dbg_lvl); +#else /* LDAP_DEBUG */ + fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" ); +#endif /* LDAP_DEBUG */ + break; + case 'R': /* don't automatically chase referrals */ + chase_referrals = 0; + break; + case 'f': /* input file */ + if ( optarg[0] == '-' && optarg[1] == '\0' ) { + ldaptool_fp = stdin; + } else if (( ldaptool_fp = ldaptool_open_file( optarg, "r" )) == NULL ) { + perror( optarg ); + exit( LDAP_PARAM_ERROR ); + } + break; + case 'h': /* ldap host */ + if ( hostnum == 0 ) { + ldaptool_host = strdup( optarg ); + } else if ( two_hosts ) { + ldaptool_host2 = strdup( optarg ); + } else { + fprintf( stderr, + "%s: only one host (-h option) should be specified\n", + ldaptool_progname ); + return(-1); /* usage error */ + } + ++hostnum; + break; + case 'D': /* bind DN */ + isD = 1; + binddn = strdup( optarg ); + break; + case 'E': /* expose bind identity via auth. response control */ + ++send_auth_response_ctrl; + break; + + case 'p': /* ldap port */ + if ( !user_specified_port ) { + ++user_specified_port; + ldaptool_port = atoi( optarg ); + } else if ( two_hosts ) { + ++user_specified_port2; + ldaptool_port2 = atoi( optarg ); + } else { + fprintf( stderr, + "%s: only one port (-p option) should be specified\n", + ldaptool_progname ); + return(-1); /* usage error */ + } + + break; +#if defined(NET_SSL) + case 'P': /* path to security database */ + if ( (0 == isZ) && (0 == isZZ) ) + { + secure = 1; /* do SSL encryption */ + } + ssl_certdbpath = strdup( optarg ); + if (NULL == ssl_certdbpath) + { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + break; + case 'Z': /* do SSL encryption */ + if ( (0 == isZ) && (0 == isZZ) ) + { + secure = 1; + isZ = 1; + } + else { + secure = 0; + isZ = 0; + /* -ZZZ for Server response required */ + if (isZZ == 1) isZZZ =1; + isZZ = 1; /* -ZZ : Start TLS request */ + } + break; + case 'N': /* nickname of cert. to use for client auth. */ + ssl_certname = strdup( optarg ); + if (NULL == ssl_certname) + { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + isN = 1; + break; + case 'K': /* location of key database */ + ssl_keydbpath = strdup( optarg ); + if (NULL == ssl_keydbpath) + { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + break; + case 'W': /* SSL key password */ + if ( optarg[0] == '-' && optarg[1] == '\0' ) { + prompt_sslpassword = 1; + } else { + ssl_passwd = strdup( optarg ); + if (NULL == ssl_passwd) + { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + } + isW = 1; + break; + + case '3': /* check hostnames in SSL certificates ("no third") */ + ssl_strength = LDAPSSL_AUTH_CNCHECK; + break; + +#ifdef LDAP_TOOL_PKCS11 + case 'm': /* SSL secmod path */ + ssl_secmodpath = strdup( optarg); + if (NULL == ssl_secmodpath) + { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + break; + + case 'Q': /* [token][:certificate name] */ + pkcs_token = strdup(optarg); + if (NULL == pkcs_token) + { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + + break; + + case 'I': /* PIN (password file) */ + ssl_donglefile = strdup( optarg ); + + break; +#endif /* LDAP_TOOL_PKCS11 */ + +#endif /* NET_SSL */ + case 'w': /* bind password */ + isw = 1; + if ( optarg[0] == '-' && optarg[1] == '\0' ) + prompt_password = 1; + else + passwd = strdup( optarg ); + break; + case 'j': /* bind password from file */ + isj = 1; + if ((password_fp = fopen( optarg, "r" )) == NULL ) { + fprintf(stderr, "%s: Unable to open '%s' file\n", + ldaptool_progname, optarg); + exit( LDAP_PARAM_ERROR ); + } + break; + case 'O': /* referral hop limit */ + refhoplim = atoi( optarg ); + break; + case 'V': /* protocol version */ + ldversion = atoi (optarg); + if ( ldversion != LDAP_VERSION2 && ldversion != LDAP_VERSION3 ) { + fprintf( stderr, "%s: LDAP protocol version %d is not " + "supported (use -V%d or -V%d)\n", + ldaptool_progname, ldversion, LDAP_VERSION2, + LDAP_VERSION3 ); + exit( LDAP_PARAM_ERROR ); + } + break; + case 'M': /* send a manageDsaIT control */ + send_manage_dsait_ctrl = 1; + break; + + case 'i': /* character set specified */ + ldaptool_charset = strdup( optarg ); + if (NULL == ldaptool_charset) + { + perror( "malloc" ); + exit( LDAP_NO_MEMORY ); + } + + break; + case 'k': /* bypass passwd conversion to utf8 */ + isk = 1; + ldaptool_noconv_passwd = 1; /* tell the tool about it */ + break; + case 'y': /* old (version 1) proxied authorization control */ + proxyauth_version = 1; + /*FALLTHRU*/ + case 'Y': /* new (version 2 ) proxied authorization control */ + proxyauth_id = strdup(optarg); + if (NULL == proxyauth_id) + { + perror( "malloc" ); + exit( LDAP_NO_MEMORY ); + } + + break; + + case '0': /* zero -- override LDAP library version check */ + break; /* already handled above */ + + case 'J': /* send an arbitrary control */ + if ( (ctrl_arg = strdup( optarg)) == NULL ) { + perror ("strdup"); + exit (LDAP_NO_MEMORY); + } + if (ldaptool_parse_ctrl_arg(ctrl_arg, ':', &ctrl_oid, + &ctrl_criticality, &ctrl_value, &vlen)) { + return (-1); + } + ldctrl = calloc(1,sizeof(LDAPControl)); + if (ctrl_value) { + rc = ldaptool_berval_from_ldif_value( ctrl_value, + vlen, &(ldctrl->ldctl_value), + 1 /* recognize file URLs */, + 0 /* always try file */, + 1 /* report errors */ ); + if ((rc = ldaptool_fileurlerr2ldaperr( rc )) != LDAP_SUCCESS) { + fprintf( stderr, "Unable to parse %s\n", ctrl_value); + return (-1); + } + } + ldctrl->ldctl_oid = ctrl_oid; + ldctrl->ldctl_iscritical = ctrl_criticality; + ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); + break; + case 'g': /* do not send password policy request control */ + no_pwpolicy_req_ctrl++; + break; +#ifdef HAVE_SASL_OPTIONS +#ifdef HAVE_SASL_OPTIONS_2 + case '2': /* attribute assignment */ +#else + case 'o': /* attribute assignment */ +#endif + if ((rc = saslSetParam(optarg)) == -1) { + return (-1); + } + ldapauth = LDAP_AUTH_SASL; + ldversion = LDAP_VERSION3; + break; +#endif /* HAVE_SASL_OPTIONS */ + default: + (*extra_opt_callback)( i, optarg ); + } + } + + /* If '-Z' is specified, check if '-P' is specified too. */ + if ( isN || isW ) { + if ( !(isZ || isZZ) ) { + fprintf( stderr, "%s: with -N, -W options, please specify either -Z , -ZZ or -ZZZ\n\n", ldaptool_progname ); + return (-1); + } + } + +#ifdef LDAP_TOOL_PKCS11 + /* if '-N' is specified, -W or -I is needed too */ + if ( isN && NULL == ssl_passwd && 0 == prompt_sslpassword && NULL == ssl_donglefile ) { + fprintf( stderr, "%s: with the -N option, please specify -W or -I also\n\n", ldaptool_progname ); + return (-1); + } +#else + /* if '-N' is specified, -W is needed too */ + if ( isN && NULL == ssl_passwd && 0 == prompt_sslpassword ) { + fprintf( stderr, "%s: with the -N option, please specify -W also\n\n", ldaptool_progname ); + return (-1); + } +#endif /* LDAP_TOOL_PKCS11 */ + + if ( isj && isw ) { + fprintf(stderr, "%s: -j and -w options cannot be specified simultaneously\n\n", ldaptool_progname ); + return (-1); + } + + /* complain if -j or -w does not also have -D, unless using SASL */ +#ifdef HAVE_SASL_OPTIONS + if ( (isj || isw) && !isD && ( ldapauth != LDAP_AUTH_SASL ) ) { +#else + if ( (isj || isw) && !isD ) { +#endif + fprintf(stderr, "%s: with -j, -w options, please specify -D\n\n", ldaptool_progname ); + return (-1); + } + + /* use default key and cert DB paths if not set on the command line */ + if ( NULL == ssl_keydbpath ) { + if ( NULL == ssl_certdbpath ) { + ssl_keydbpath = LDAPTOOL_DEFKEYDBPATH; + } else { + /* The ldapssl_.*init() functions, which call NSS_Initialize(), + * don't rely on the key DB path ending in the correct filename, + * so it is OK to just pass them the cert DB path. + */ + ssl_keydbpath = ssl_certdbpath; + } + } + if ( NULL == ssl_certdbpath ) { + ssl_certdbpath = LDAPTOOL_DEFCERTDBPATH; + } + + if (prompt_password != 0) { + char *password_string = "Enter bind password: "; + passwd = ldaptool_getpass( password_string ); + } else if (password_fp != NULL) { + passwd = ldaptool_read_password( password_fp ); + } + + /* + * If verbose (-v) flag was passed in, display program name and start time. + * If the verbose flag was passed at least twice (-vv), also display + * information about the API library we are running with. + */ + if ( ldaptool_verbose ) { + time_t curtime; + + curtime = time( NULL ); + printf( "%s: started %s\n", ldaptool_progname, ctime( &curtime )); + if ( ldaptool_verbose > 1 ) { + print_library_info( &ldai, stdout ); + } + } + +#ifdef LDAP_TOOL_PKCS11 + if ((NULL != pkcs_token) && (NULL != ssl_certname)) { + char *result; + + if ( (result = buildTokenCertName( pkcs_token, ssl_certname)) != NULL){ + free( ssl_certname ); + ssl_certname = result; + } + } +#endif /* LDAP_TOOL_PKCS11 */ + + free( optstring ); + + /* + * Clean up and return index of first non-option argument. + */ + if ( ldai.ldapai_extensions != NULL ) { + ldap_value_free( ldai.ldapai_extensions ); + } + if ( ldai.ldapai_vendor_name != NULL ) { + ldap_memfree( ldai.ldapai_vendor_name ); + } + +#ifdef HAVE_SASL_OPTIONS + if (ldversion == LDAP_VERSION2 && ldapauth == LDAP_AUTH_SASL) { + fprintf( stderr, "Incompatible with version %d\n", ldversion); + return (-1); + } +#endif /* HAVE_SASL_OPTIONS */ + + return( optind ); +} + + +/* + * Write detailed information about the API library we are running with to fp. + */ +static void +print_library_info( const LDAPAPIInfo *aip, FILE *fp ) +{ + int i; + LDAPAPIFeatureInfo fi; + + fprintf( fp, "LDAP Library Information -\n" + " Highest supported protocol version: %d\n" + " LDAP API revision: %d\n" + " API vendor name: %s\n" + " Vendor-specific version: %.2f\n", + aip->ldapai_protocol_version, aip->ldapai_api_version, + aip->ldapai_vendor_name, + (float)aip->ldapai_vendor_version / 100.0 ); + + if ( aip->ldapai_extensions != NULL ) { + fputs( " LDAP API Extensions:\n", fp ); + + for ( i = 0; aip->ldapai_extensions[i] != NULL; i++ ) { + fprintf( fp, " %s", aip->ldapai_extensions[i] ); + fi.ldapaif_info_version = LDAP_FEATURE_INFO_VERSION; + fi.ldapaif_name = aip->ldapai_extensions[i]; + fi.ldapaif_version = 0; + + if ( ldap_get_option( NULL, LDAP_OPT_API_FEATURE_INFO, &fi ) + != 0 ) { + fprintf( fp, " %s: ldap_get_option( NULL," + " LDAP_OPT_API_FEATURE_INFO, ... ) for %s failed" + " (Feature Info version: %d)\n", ldaptool_progname, + fi.ldapaif_name, fi.ldapaif_info_version ); + } else { + fprintf( fp, " (revision %d)\n", fi.ldapaif_version); + } + } + } + fputc( '\n', fp ); +} + + + +#ifdef LDAP_TOOL_ARGPIN +static int PinArgRegistration( void ) +{ + + /* pkcs_init was successful register the pin args */ + + SVRCOREArgPinObj *ArgPinObj; + char *tokenName; +#ifndef _WIN32 + SVRCOREStdPinObj *StdPinObj; +#else + SVRCOREFilePinObj *FilePinObj; + SVRCOREAltPinObj *AltPinObj; + SVRCORENTUserPinObj *NTUserPinObj; + int err; +#endif + char *pin; + char *filename; + /* Create and register the pin object for PKCS 11 */ + local_pkcs_fns.pkcs_getdonglefilename(NULL, &filename); + local_pkcs_fns.pkcs_getpin(NULL, "", &pin); +#ifndef _WIN32 + if ( SVRCORE_CreateStdPinObj(&StdPinObj, filename, PR_TRUE) != + SVRCORE_Success) { + fprintf(stderr, "Security Initialization: Unable to create PinObj " + "(%d)", PR_GetError()); + return -1; + } + if (pin != NULL) + { + local_pkcs_fns.pkcs_gettokenname(NULL, &tokenName); + SVRCORE_CreateArgPinObj(&ArgPinObj, tokenName, pin, (SVRCOREPinObj *)StdPinObj); + SVRCORE_RegisterPinObj((SVRCOREPinObj *)ArgPinObj); + } + else + { + SVRCORE_RegisterPinObj((SVRCOREPinObj *)StdPinObj); + } +#else + if (NULL != pin) + { + local_pkcs_fns.pkcs_gettokenname(NULL, &tokenName); + if ((err = SVRCORE_CreateNTUserPinObj(&NTUserPinObj)) != SVRCORE_Success){ + fprintf(stderr, "Security Initialization: Unable to create NTUserPinObj " + "(%d)", PR_GetError()); + exit( LDAP_LOCAL_ERROR ); + } + if ((err = SVRCORE_CreateArgPinObj(&ArgPinObj, tokenName, pin, + (SVRCOREPinObj *)NTUserPinObj)) != SVRCORE_Success) + { + fprintf(stderr, "Security Initialization: Unable to create ArgPinObj " + "(%d)", PR_GetError()); + return -1; + + } + SVRCORE_RegisterPinObj((SVRCOREPinObj *)ArgPinObj); + + } + else + { + if ((err = SVRCORE_CreateNTUserPinObj(&NTUserPinObj)) != SVRCORE_Success){ + fprintf( stderr, "Security Initialization: Unable to create NTUserPinObj " + "(%d)", PR_GetError()); + return -1; + } + if (filename && *filename) + { + if ((err = SVRCORE_CreateFilePinObj(&FilePinObj, filename)) != + SVRCORE_Success) { + fprintf( stderr, "Security Initialization: Unable to create FilePinObj " + "(%d)", PR_GetError()); + return -1; + + } + if ((err = SVRCORE_CreateAltPinObj(&AltPinObj, (SVRCOREPinObj *)FilePinObj, + (SVRCOREPinObj *)NTUserPinObj)) != SVRCORE_Success) { + fprintf( stderr, "Security Initialization: Unable to create AltPinObj " + "(%d)", PR_GetError()); + return -1; + } + SVRCORE_RegisterPinObj((SVRCOREPinObj *)AltPinObj); + } + else + { + SVRCORE_RegisterPinObj((SVRCOREPinObj *)NTUserPinObj); + } + } +#endif + return LDAP_SUCCESS; + +} +#endif /* LDAP_TOOL_ARGPIN */ + +#if !defined(macintosh) && !defined(DOS) && !defined( _WINDOWS ) +/* If numaddr is IPv6 numeric address and if possible, get FQDN from it. + * This conversion is needed to fulfill the spec of sasl_client_init. + * If successful, FQDN is stored in buf and return LDAP_SUCCESS + * If numaddr is not IPv6 numeric address, it returns non LDAP_SUCCESS (-1) + * If any step of the conversion fails, it returns non LDAP_SUCCESS (-1) + * Note: any conversion failure does not print out an error message. + */ +static int +getFQDNbyIPv6NumericAddr ( char *numaddr, char *buf, size_t blen ) +{ + char *hostp = NULL; + int isIPv6Numeric = 0; + int rc, return_value = -1; + + /* IPv6 numeric address includes 2 or more colons */ + /* example: [3ffe:1111:2222:3333::1] */ + hostp = strchr( numaddr, ':' ); + if ( hostp ) { /* found one colon */ + hostp = strchr( hostp+1, ':' ); + if ( hostp ) { /* found two colons */ + hostp = strchr( numaddr, '[' ); + if ( hostp ) { /* numaddr starts with '[' */ + /* example: [fe80::250:ffff:ffff:e53a%eth0] + * if interface is given, it's link-local. + * we don't do lookup */ + char *workp = strchr( ++hostp, '%' ); + if ( !workp ) { /* address does not include % */ + size_t mylen = 0; + isIPv6Numeric = 1; + workp = strchr( hostp, ']' ); + if ( workp ) { + mylen = workp - hostp; + } else { + mylen = strlen( hostp ); + } + if ( mylen >= blen ) { /* address too long */ + return return_value; + } + strncpy( buf, hostp, mylen ); + buf[mylen] = '\0'; + } + } else { + isIPv6Numeric = 1; + if ( strlen(numaddr) >= blen ) { /* address too long */ + return return_value; + } + strcpy( buf, numaddr ); + } + } + } + if ( !isIPv6Numeric ) { + return return_value; /* it's not IPv6 numeric address */ + } + { + struct sockaddr *saddr = NULL; + socklen_t slen = 0; +#ifdef HAVE_GETADDRINFO + struct addrinfo hints = {0}; + struct addrinfo *ainfo = NULL; + + hints.ai_flags = AI_ADDRCONFIG; + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + + rc = getaddrinfo( buf, NULL, &hints, &ainfo ); + if ( 0 == rc ) { + saddr = ainfo->ai_addr; + slen = ainfo->ai_addrlen; + } + /* if saddr is NULL here, getaddrinfo failed */ +#endif + if ( saddr && slen > 0 ) { +#ifdef HAVE_GETNAMEINFO + rc = getnameinfo( saddr, slen, buf, (socklen_t)blen, NULL, 0, NI_NAMEREQD ); + if (0 == rc) { + return_value = LDAP_SUCCESS; + } +#endif +#ifdef HAVE_GETADDRINFO + if ( ainfo ) { + freeaddrinfo( ainfo ); + } +#endif + if ( LDAP_SUCCESS == return_value ) { + return return_value; + } + } + } + /* getaddrinfo and getnameinfo are not available; let's use nspr apis */ + { + PRNetAddr praddr; + PRIntn idx = 0; + PRHostEnt prhent, prrevhent; + char tmpbuf[PR_NETDB_BUF_SIZE]; + if ( PR_GetIPNodeByName(buf, PR_AF_INET6, PR_AI_DEFAULT, + tmpbuf, sizeof(tmpbuf), &prhent) != PR_SUCCESS ) { + return return_value; + } + while (1) { + idx = PR_EnumerateHostEnt(idx, &prhent, 0, &praddr); + if (idx == -1) { + return return_value; + } + if (idx == 0) break; /* normal loop termination */ + if (PR_GetHostByAddr(&praddr, tmpbuf, sizeof(tmpbuf), + &prrevhent) == PR_FAILURE) { + return return_value; + } + if ( prrevhent.h_name ) { + PR_snprintf( buf, blen, "%s", prrevhent.h_name ); + return_value = LDAP_SUCCESS; + break; + } + } + return return_value; + } +} +#endif + +/* + * initialize and return an LDAP session handle. + * if errors occur, we exit here. + */ +LDAP * +ldaptool_ldap_init( int second_host ) +{ + LDAP *ld = NULL; + char *host; + int port, rc, user_port; +#if !defined(macintosh) && !defined(DOS) && !defined( _WINDOWS ) +#if defined(MAXHOSTNAMELEN) + char hname[MAXHOSTNAMELEN]; + size_t hlen = MAXHOSTNAMELEN; +#else + char hname[256]; + size_t hlen = 256; +#endif +#endif + + if ( ldaptool_not ) { + return( NULL ); + } + + if ( second_host ) { + host = ldaptool_host2; + port = ldaptool_port2; + user_port = user_specified_port2; + } else { + host = ldaptool_host; + port = ldaptool_port; + user_port = user_specified_port; + } +#if !defined(macintosh) && !defined(DOS) && !defined( _WINDOWS ) + /* If numaddr is IPv6 numeric address and if possible, get FQDN from it. */ + if ( getFQDNbyIPv6NumericAddr ( host, hname, hlen ) == LDAP_SUCCESS ) { + host = hname; + } +#endif + + if ( ldaptool_verbose ) { + printf( "ldap_init( %s, %d )\n", host, port ); + } + +#if defined(NET_SSL) + /* + * Initialize security libraries and databases and LDAP session. If + * ssl_certname is not NULL, then we will attempt to use client auth. + * if the server supports it. + */ +#ifdef LDAP_TOOL_PKCS11 + ldaptool_setcallbacks( &local_pkcs_fns ); + + if ( !second_host && ( secure || isZZ ) + &&(rc = ldapssl_pkcs_init( &local_pkcs_fns)) < 0) { + /* secure connection requested -- fail if no SSL */ + rc = PORT_GetError(); + fprintf( stderr, "SSL initialization failed: error %d (%s)\n", + rc, ldapssl_err2string( rc )); + exit( LDAP_LOCAL_ERROR ); + } + +#ifdef LDAP_TOOL_ARGPIN + if (secure || isZZ) { + if (PinArgRegistration( )) { + exit( LDAP_LOCAL_ERROR); + } + } +#endif /* LDAP_TOOL_ARGPIN */ + +#else /* LDAP_TOOL_PKCS11 */ + if ( !second_host && ( secure || isZZ ) + &&(rc = ldapssl_client_init( ssl_certdbpath, NULL )) < 0) { + /* secure connection requested -- fail if no SSL */ + rc = PORT_GetError(); + fprintf( stderr, "SSL initialization failed: error %d (%s)\n", + rc, ldapssl_err2string( rc )); + exit( LDAP_LOCAL_ERROR ); + } +#endif /* LDAP_TOOL_PKCS11 */ + + /* set the default SSL strength (used for all future ld's we create) */ + if ( ldapssl_set_strength( NULL, ssl_strength ) < 0 ) { + perror( "ldapssl_set_strength" ); + exit( LDAP_LOCAL_ERROR ); + } + + if (secure) { + if ( !user_port ) { + port = LDAPS_PORT; + } + + if (( ld = ldapssl_init( host, port, + secure )) != NULL && ssl_certname != NULL ) + if (ldapssl_enable_clientauth( ld, ssl_keydbpath, ssl_passwd, + ssl_certname ) != 0 ) { + exit ( ldaptool_print_lderror( ld, "ldapssl_enable_clientauth", + LDAPTOOL_CHECK4SSL_ALWAYS )); + } + } else if (isZZ) + {/* startTLS if -ZZ or -ZZZ option is used */ + + if (( ld = prldap_init( host, port, 0 )) == NULL) { + perror("prldap_init failed"); + exit( LDAP_LOCAL_ERROR ); + } + + /* Provide client authentication if -N option is used */ + if ( ssl_certname != NULL ) { + if (ldapssl_enable_clientauth( ld, ssl_keydbpath, ssl_passwd, + ssl_certname ) != 0 ) { + exit ( ldaptool_print_lderror( ld, "ldapssl_enable_clientauth", + LDAPTOOL_CHECK4SSL_ALWAYS )); + } + } + + /* Call to startTLS over the current clear-text connection */ + if ( ( rc = ldap_start_tls_s( ld, NULL, NULL ) ) != LDAP_SUCCESS ) { + fprintf( stderr, "ldap_start_tls_s failed: (%s)\n", + ldap_err2string(rc)); + if( isZZZ ) { + ldap_unbind( ld ); + exit( rc ); + } + } + + } /* End startTLS case */ + else { + /* In order to support IPv6, we use NSPR I/O */ + ld = prldap_init( host, port, 0 /* not shared across threads */ ); + } + +#else + /* In order to support IPv6, we use NSPR I/O */ + ld = prldap_init( host, port, 0 /* not shared across threads */ ); +#endif + + if ( ld == NULL ) { + perror( "ldap_init" ); + exit( LDAP_LOCAL_ERROR ); + } + + ldap_set_option( ld, LDAP_OPT_REFERRALS, chase_referrals ? LDAP_OPT_ON: + LDAP_OPT_OFF ); + if ( chase_referrals ) { + ldap_set_rebind_proc( ld, get_rebind_credentials, NULL ); + ldap_set_option( ld, LDAP_OPT_REFERRAL_HOP_LIMIT, &refhoplim ); + } + + if ( ldversion == -1 ) { /* not set with -V and not using local db */ + ldversion = LDAP_VERSION3; + } + ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &ldversion ); + + return( ld ); +} + + +/* + * perform a bind to the LDAP server if needed. + * if an error occurs, we exit here. + */ +void +ldaptool_bind( LDAP *ld ) +{ + int rc, ctrl_index = 0; + char *conv_binddn; + char *conv_passwd = NULL; + LDAPControl auth_resp_ctrl, *ctrl_array[ 3 ], **bindctrls; + LDAPControl pwpolicy_req_ctrl; + LDAPControl **ctrls = NULL; +#ifdef HAVE_SASL_OPTIONS + void *defaults; +#endif + + if ( ldaptool_not ) { + return; + } + + if ( send_auth_response_ctrl ) { + auth_resp_ctrl.ldctl_oid = LDAP_CONTROL_AUTH_REQUEST; + auth_resp_ctrl.ldctl_value.bv_val = NULL; + auth_resp_ctrl.ldctl_value.bv_len = 0; + auth_resp_ctrl.ldctl_iscritical = 0; + ctrl_array[ctrl_index++] = &auth_resp_ctrl; + } + + if ( !no_pwpolicy_req_ctrl ) { + pwpolicy_req_ctrl.ldctl_oid = LDAP_X_CONTROL_PWPOLICY_REQUEST; + pwpolicy_req_ctrl.ldctl_value.bv_val = NULL; + pwpolicy_req_ctrl.ldctl_value.bv_len = 0; + pwpolicy_req_ctrl.ldctl_iscritical = 0; + ctrl_array[ctrl_index++] = &pwpolicy_req_ctrl; + } + + if ( ctrl_index == 0 ) { + bindctrls = NULL; + } else { + ctrl_array[ctrl_index] = NULL; + bindctrls = ctrl_array; + } + + /* + * if using LDAPv3 and not using client auth., omit NULL bind for + * efficiency. + */ + if ( ldversion > LDAP_VERSION2 && binddn == NULL && passwd == NULL + && ssl_certname == NULL ) { +#ifdef HAVE_SASL_OPTIONS + if ( ldapauth != LDAP_AUTH_SASL ) { +#endif + /* let the tool know we did no bind */ + ldaptool_nobind = 1; + return; +#ifdef HAVE_SASL_OPTIONS + } +#endif + } + + /* + * do the bind, backing off one LDAP version if necessary + */ + conv_binddn = ldaptool_local2UTF8( binddn, "bind DN" ); + + if ( passwd != NULL ) { + if ( isk ) { + conv_passwd = strdup( passwd ); + } else { + conv_passwd = ldaptool_local2UTF8( passwd, "password" ); + } + } + +#ifdef HAVE_SASL_OPTIONS + if ( ldapauth == LDAP_AUTH_SASL) { + LDAPControl **rctrls = NULL; + if ( sasl_mech == NULL) { + fprintf( stderr, "Please specify the SASL mechanism name when " + "using SASL options\n"); + return; + } + + if ( sasl_secprops != NULL) { + rc = ldap_set_option( ld, LDAP_OPT_X_SASL_SECPROPS, + (void *) sasl_secprops ); + + if ( rc != LDAP_SUCCESS ) { + fprintf( stderr, "Unable to set LDAP_OPT_X_SASL_SECPROPS: %s\n", + sasl_secprops ); + return; + } + } + + defaults = ldaptool_set_sasl_defaults( ld, sasl_flags, sasl_mech, + sasl_authid, sasl_username, passwd, sasl_realm ); + if (defaults == NULL) { + perror ("malloc"); + exit (LDAP_NO_MEMORY); + } + + rc = ldap_sasl_interactive_bind_ext_s( ld, binddn, sasl_mech, + bindctrls, ctrls, sasl_flags, + ldaptool_sasl_interact, defaults, &rctrls ); + if (rc != LDAP_SUCCESS ) { + ldap_perror( ld, "Bind Error" ); + } + + check_response_controls( ld, "ldaptool_bind", rctrls, 1 ); + + } else +#endif /* HAVE_SASL_OPTIONS */ + + /* + * if using LDAPv3 and client auth., try a SASL EXTERNAL bind + */ + if ( ldversion > LDAP_VERSION2 && binddn == NULL && passwd == NULL + && ssl_certname != NULL ) { + rc = ldaptool_sasl_bind_s( ld, NULL, LDAP_SASL_EXTERNAL, NULL, + bindctrls, NULL, NULL, "ldap_sasl_bind" ); + } else { + rc = ldaptool_simple_bind_s( ld, conv_binddn, conv_passwd, bindctrls, NULL, + "ldap_simple_bind" ); + } + + if ( rc == LDAP_SUCCESS ) { + if ( conv_binddn != NULL ) { + free( conv_binddn ); + } + + if ( conv_passwd != NULL ) { + free( conv_passwd ); + } + + return; /* success */ + } + +#ifdef HAVE_SASL_OPTIONS + if (ldapauth != LDAP_AUTH_SASL) { +#endif /* HAVE_SASL_OPTIONS */ + if ( rc == LDAP_PROTOCOL_ERROR && ldversion > LDAP_VERSION2 ) { + /* + * try again, backing off one LDAP version + * this is okay even for client auth. because the way to achieve + * client auth. with LDAPv2 is to perform a NULL simple bind. + */ + --ldversion; + fprintf( stderr, "%s: the server doesn't understand LDAPv%d;" + " trying LDAPv%d instead...\n", ldaptool_progname, + ldversion + 1, ldversion ); + ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &ldversion ); + if (( rc = ldaptool_simple_bind_s( ld, conv_binddn, conv_passwd, + bindctrls, NULL, "ldap_simple_bind" )) == LDAP_SUCCESS ) { + if ( conv_binddn != NULL ) { + free( conv_binddn ); + } + + if ( conv_passwd != NULL ) { + free( conv_passwd ); + } + + return; /* a qualified success */ + } + } +#ifdef HAVE_SASL_OPTIONS + } +#endif /* HAVE_SASL_OPTIONS */ + + if ( conv_binddn != NULL ) { + free( conv_binddn ); + } + + if ( conv_passwd != NULL ) { + free( conv_passwd ); + } + + /* + * bind(s) failed -- fatal error + */ + ldap_unbind( ld ); + exit( rc ); +} + + +/* + * close open files, unbind, etc. + */ +void +ldaptool_cleanup( LDAP *ld ) +{ + if ( ld != NULL ) { + ldap_unbind( ld ); + } + + if ( ldaptool_fp != NULL && ldaptool_fp != stdin ) { + fclose( ldaptool_fp ); + ldaptool_fp = NULL; + } +} + + +/* + * Retrieve and print an LDAP error message. Returns the LDAP error code. + */ +int +ldaptool_print_lderror( LDAP *ld, char *msg, int check4ssl ) +{ + int lderr = ldap_get_lderrno( ld, NULL, NULL ); + + ldap_perror( ld, msg ); + if ( ( secure || isZZ ) && check4ssl != LDAPTOOL_CHECK4SSL_NEVER ) { + if ( check4ssl == LDAPTOOL_CHECK4SSL_ALWAYS + || ( lderr == LDAP_SERVER_DOWN ) + || ( lderr == LDAP_CONNECT_ERROR )) { + int sslerr = PORT_GetError(); + if ( isZZ ) { + fprintf( stderr, "\tTLS/SSL error %d (%s)\n", sslerr, + ldapssl_err2string( sslerr )); + } + else { + fprintf( stderr, "\tSSL error %d (%s)\n", sslerr, + ldapssl_err2string( sslerr )); + } + } + } + + return( lderr ); +} + + +/* + * print referrals to stderr + */ +void +ldaptool_print_referrals( char **refs ) +{ + int i; + + if ( refs != NULL ) { + for ( i = 0; refs[ i ] != NULL; ++i ) { + fprintf( stderr, "Referral: %s\n", refs[ i ] ); + } + } +} + + +/* + * print contents of an extended response to stderr + * this is mainly to support unsolicited notifications + * Returns an LDAP error code (from the extended result). + */ +int +ldaptool_print_extended_response( LDAP *ld, LDAPMessage *res, char *msg ) +{ + char *oid; + struct berval *data; + + if ( ldap_parse_extended_result( ld, res, &oid, &data, 0 ) + != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); + } else { + if ( oid != NULL ) { + if ( strcmp ( oid, LDAP_NOTICE_OF_DISCONNECTION ) == 0 ) { + fprintf( stderr, "%s: Notice of Disconnection\n", msg ); + } else { + fprintf( stderr, "%s: OID %s\n", msg, oid ); + } + ldap_memfree( oid ); + } else { + fprintf( stderr, "%s: missing OID\n", msg ); + } + + if ( data != NULL ) { + fprintf( stderr, "%s: Data (length %d):\n", msg, data->bv_len ); +#if 0 +/* XXXmcs: maybe we should display the actual data? */ + lber_bprint( data->bv_val, data->bv_len ); +#endif + ber_bvfree( data ); + } + } + + return parse_result( ld, res, NULL, msg, 1 ); +} + + +/* + * Like ldap_sasl_bind_s() but calls wait4result() to display + * any referrals returned and report errors in a consistent way. + */ +int +ldaptool_sasl_bind_s( LDAP *ld, const char *dn, const char *mechanism, + const struct berval *cred, LDAPControl **serverctrls, + LDAPControl **clientctrls, struct berval **servercredp, char *msg ) +{ + int rc, msgid; + + if ( servercredp != NULL ) { + *servercredp = NULL; + } + + if (( rc = ldap_sasl_bind( ld, dn, mechanism, cred, serverctrls, + clientctrls, &msgid )) != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); + } else { + rc = wait4result( ld, msgid, servercredp, msg ); + } + + return( rc ); +} + + +/* + * Like ldap_simple_bind_s() but calls wait4result() to display + * any referrals returned and report errors in a consistent way. + */ +int +ldaptool_simple_bind_s( LDAP *ld, const char *dn, const char *passwd, + LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ) +{ + struct berval bv; + + bv.bv_val = (char *)passwd; /* XXXmcs: had to cast away const */ + bv.bv_len = ( passwd == NULL ? 0 : strlen( passwd )); + return( ldaptool_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &bv, serverctrls, + clientctrls, NULL, msg )); +} + + +/* + * Like ldap_add_ext_s() but calls wait4result() to display + * any referrals returned and report errors in a consistent way. + */ +int +ldaptool_add_ext_s( LDAP *ld, const char *dn, LDAPMod **attrs, + LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ) +{ + int rc, msgid; + + if (( rc = ldap_add_ext( ld, dn, attrs, serverctrls, clientctrls, &msgid )) + != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); + } else { + /* + * 25-April-2000 Note: the next line used to read: + * rc = wait4result( ld, msgid, NULL, msg ); + * 'msgid' it was changed to 'LDAP_RES_ANY' in order to receive + * unsolicited notifications. + */ + rc = wait4result( ld, LDAP_RES_ANY, NULL, msg ); + } + + return( rc ); +} + + +/* + * Like ldap_modify_ext_s() but calls wait4result() to display + * any referrals returned and report errors in a consistent way. + */ +int +ldaptool_modify_ext_s( LDAP *ld, const char *dn, LDAPMod **mods, + LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ) +{ + int rc, msgid; + + if (( rc = ldap_modify_ext( ld, dn, mods, serverctrls, clientctrls, + &msgid )) != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); + } else { + rc = wait4result( ld, msgid, NULL, msg ); + } + + return( rc ); +} + + +/* + * Like ldap_delete_ext_s() but calls wait4result() to display + * any referrals returned and report errors in a consistent way. + */ +int +ldaptool_delete_ext_s( LDAP *ld, const char *dn, LDAPControl **serverctrls, + LDAPControl **clientctrls, char *msg ) +{ + int rc, msgid; + + if (( rc = ldap_delete_ext( ld, dn, serverctrls, clientctrls, &msgid )) + != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); + } else { + rc = wait4result( ld, msgid, NULL, msg ); + } + + return( rc ); +} + + +/* + * Like ldap_compare_ext_s() but calls wait4result() to display + * any referrals returned and report errors in a consistent way. + */ +int ldaptool_compare_ext_s( LDAP *ld, const char *dn, const char *attrtype, + const struct berval *bvalue, LDAPControl **serverctrls, + LDAPControl **clientctrls, char *msg ) +{ + int rc, msgid; + + if (( rc = ldap_compare_ext( ld, dn, attrtype, bvalue, serverctrls, + clientctrls, &msgid )) != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); + } else { + rc = wait4result( ld, msgid, NULL, msg ); + } + + return( rc ); +} + + +/* + * Like ldap_rename_s() but calls wait4result() to display + * any referrals returned and report errors in a consistent way. + */ +int +ldaptool_rename_s( LDAP *ld, const char *dn, const char *newrdn, + const char *newparent, int deleteoldrdn, LDAPControl **serverctrls, + LDAPControl **clientctrls, char *msg ) +{ + int rc, msgid; + + if (( rc = ldap_rename( ld, dn, newrdn, newparent, deleteoldrdn, + serverctrls, clientctrls, &msgid )) != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); + } else { + rc = wait4result( ld, msgid, NULL, msg ); + } + + return( rc ); +} + + +/* + * Wait for a result, check for and display errors and referrals. + * Also recognize and display "Unsolicited notification" messages. + * Returns an LDAP error code. + */ +static int +wait4result( LDAP *ld, int msgid, struct berval **servercredp, char *msg ) +{ + LDAPMessage *res; + int rc, received_only_unsolicited = 1; + + while ( received_only_unsolicited ) { + res = NULL; + if (( rc = ldap_result( ld, msgid, 1, (struct timeval *)NULL, &res )) + == -1 ) { + (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); + return( ldap_get_lderrno( ld, NULL, NULL )); + } + + /* + * Special handling for unsolicited notifications: + * 1. Parse and display contents. + * 2. go back and wait for another (real) result. + */ + if ( rc == LDAP_RES_EXTENDED + && ldap_msgid( res ) == LDAP_RES_UNSOLICITED ) { + rc = ldaptool_print_extended_response( ld, res, + "Unsolicited response" ); + } else { + rc = parse_result( ld, res, servercredp, msg, 1 ); + received_only_unsolicited = 0; /* we're done */ + } + } + + return( rc ); +} + + +static int +parse_result( LDAP *ld, LDAPMessage *res, struct berval **servercredp, + char *msg, int freeit ) +{ + int rc, lderr, errno; + char **refs = NULL; + LDAPControl **ctrls; + + if (( rc = ldap_parse_result( ld, res, &lderr, NULL, NULL, &refs, + &ctrls, 0 )) != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); + ldap_msgfree( res ); + return( rc ); + } + + if ( (rc = check_response_controls( ld, msg, ctrls, 1 )) != LDAP_SUCCESS ) { + ldap_msgfree( res ); + return( rc ); + } + + if ( servercredp != NULL && ( rc = ldap_parse_sasl_bind_result( ld, res, + servercredp, 0 )) != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); + ldap_msgfree( res ); + return( rc ); + } + + if ( freeit ) { + ldap_msgfree( res ); + } + + if ( LDAPTOOL_RESULT_IS_AN_ERROR( lderr )) { + (void)ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP ); + } + + if ( refs != NULL ) { + ldaptool_print_referrals( refs ); + ldap_value_free( refs ); + } + + return( lderr ); +} + +/* + * check for response controls. authentication response control + * and PW POLICY control are the ones we care about right now. + */ +static int +check_response_controls( LDAP *ld, char *msg, LDAPControl **ctrls, int freeit ) +{ + int i; + int errno; + int pw_days=0, pw_hrs=0, pw_mins=0, pw_secs=0; /* for pwpolicy */ + char *s = NULL; + BerElement *ber = NULL; + static const char *pwpolicy_err2str[] = { + "Password has expired.", + "Account is locked.", + "Password has been reset by an administrator; you must change it.", + "Password change not allowed.", + "Must supply old password.", + "Invalid password syntax.", + "Password too short.", + "Password too young.", + "Password in history." + }; + + if ( NULL != ctrls ) { + for ( i = 0; NULL != ctrls[i]; ++i ) { + + if ( 0 == strcmp( ctrls[i]->ldctl_oid, + LDAP_CONTROL_AUTH_RESPONSE )) { + s = ctrls[i]->ldctl_value.bv_val; + if ( NULL == s ) { + s = "Null"; + } else if ( *s == '\0' ) { + s = "Anonymous"; + } + fprintf( stderr, "%s: bound as %s\n", ldaptool_progname, s ); + } /* end of LDAP_CONTROL_AUTH_RESPONSE */ + + if ( 0 == strcmp( ctrls[i]->ldctl_oid, + LDAP_CONTROL_PWEXPIRING )) { + + /* Warn the user his passwd is to expire */ + errno = 0; + pw_secs = atoi(ctrls[i]->ldctl_value.bv_val); + if ( pw_secs > 0 && errno != ERANGE ) { + if ( pw_secs > 86400 ) { + pw_days = ( pw_secs / 86400 ); + pw_secs = ( pw_secs % 86400 ); + } + if ( pw_secs > 3600 ) { + pw_hrs = ( pw_secs / 3600 ); + pw_secs = ( pw_secs % 3600 ); + } + if ( pw_secs > 60 ) { + pw_mins = ( pw_secs / 60 ); + pw_secs = ( pw_secs % 60 ); + } + + printf("%s: Warning ! Your password will expire after ", ldaptool_progname); + if ( pw_days ) { + printf ("%d days, ", pw_days); + } + if ( pw_hrs ) { + printf ("%d hrs, ", pw_hrs); + } + if ( pw_mins ) { + printf ("%d mins, ", pw_mins); + } + printf("%d seconds.\n", pw_secs); + } + } /* end of LDAP_CONTROL_PWEXPIRING */ + + if ( 0 == strcmp( ctrls[i]->ldctl_oid, + LDAP_X_CONTROL_PWPOLICY_RESPONSE )) { + ber_tag_t tag1=0, tag2=0, tag3=0; + ber_int_t warnvalue=0; + int grclogins=-1, secsleft=-1; + ber_int_t errvalue=-1; + static int err2str_size = sizeof(pwpolicy_err2str)/sizeof(pwpolicy_err2str[0]); + + if ( ( ber = ber_init(&(ctrls[i]->ldctl_value)) ) == NULL ) { + fprintf(stderr, "%s: not enough memory\n", ldaptool_progname); + return( LDAP_NO_MEMORY ); + } + if ( ber_scanf(ber,"{t", &tag1) == LBER_ERROR ) { + /* error */ + ber_free( ber, 1 ); + return (ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + switch (tag1) { + case LDAP_TAG_PWP_WARNING: + if ( ber_scanf(ber, "{ti}", &tag2, &warnvalue) + == LBER_ERROR ) { + /* error */ + ber_free( ber, 1 ); + return(ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + switch (tag2) { + case LDAP_TAG_PWP_SECSLEFT: + secsleft = (int)warnvalue; + break; + case LDAP_TAG_PWP_GRCLOGINS: + grclogins = (int)warnvalue; + break; + default: + /* error */ + ber_free( ber, 1 ); + return(ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + /* Now check for the error value if it's present */ + if ( ber_scanf(ber, "te", &tag3, &errvalue) != LBER_ERROR ) { + if (tag3 != LDAP_TAG_PWP_ERROR) { + errvalue = -1; + } + } + break; + case LDAP_TAG_PWP_ERROR: + if ( ber_scanf(ber, "e}", &errvalue) + == LBER_ERROR ) { + /* error */ + ber_free( ber, 1 ); + return(ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + break; + default : /* error */ + ber_free( ber, 1 ); + return(ldaptool_print_lderror( ld, msg, LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + + /* Now we have all the values */ + if ( secsleft >= 0 ) { + fprintf(stderr, "%s: Password will expire in %d seconds\n", + ldaptool_progname, secsleft); + } + if ( grclogins >= 0 ) { + fprintf(stderr, "%s: %d grace login(s) remain\n", + ldaptool_progname, grclogins); + } + if ( errvalue >= 0 && errvalue < err2str_size ) { + fprintf(stderr, "%s: %s\n", + ldaptool_progname, pwpolicy_err2str[errvalue]); + } else if ( errvalue != -1 ) { + fprintf(stderr, "%s: %s\n", + ldaptool_progname, + "Invalid error value in password policy response control"); + } + } /* end of LDAP_X_CONTROL_PWPOLICY_RESPONSE */ + + } + + if ( freeit ) { + ldap_controls_free( ctrls ); + ber_free( ber, 1 ); + } + } + return( LDAP_SUCCESS ); +} + +/* + * if -M was passed on the command line, create and return a "Manage DSA IT" + * LDAPv3 control. If not, return NULL. + */ +LDAPControl * +ldaptool_create_manage_dsait_control( void ) +{ + LDAPControl *ctl; + + if ( !send_manage_dsait_ctrl ) { + return( NULL ); + } + + if (( ctl = (LDAPControl *)calloc( 1, sizeof( LDAPControl ))) == NULL || + ( ctl->ldctl_oid = strdup( LDAP_CONTROL_MANAGEDSAIT )) == NULL ) { + perror( "calloc" ); + exit( LDAP_NO_MEMORY ); + } + + ctl->ldctl_iscritical = 1; + + return( ctl ); +} + +/* + * if -y "dn" was supplied on the command line, create the control + */ +LDAPControl * +ldaptool_create_proxyauth_control( LDAP *ld ) +{ + LDAPControl *ctl = NULL; + int rc; + + + if ( !proxyauth_id) + return( NULL ); + + if ( 2 == proxyauth_version ) { + rc = ldap_create_proxiedauth_control( ld, proxyauth_id, &ctl); + } else { + rc = ldap_create_proxyauth_control( ld, proxyauth_id, 1, &ctl); + } + if ( rc != LDAP_SUCCESS) + { + if (ctl) + ldap_control_free( ctl); + return NULL; + } + return( ctl ); +} + +/* Effective Rights control */ +LDAPControl * +ldaptool_create_geteffectiveRights_control ( LDAP *ld, const char *authzid, + const char **attrlist) +{ + LDAPControl *ctl = NULL; + int rc; + + rc = ldap_create_geteffectiveRights_control( ld, authzid, attrlist, 1, + &ctl); + + if ( rc != LDAP_SUCCESS) + { + if (ctl) + ldap_control_free( ctl); + return NULL; + } + return( ctl ); +} + +void +ldaptool_add_control_to_array( LDAPControl *ctrl, LDAPControl **array) +{ + + int i; + for (i=0; i< CONTROL_REQUESTS; i++) + { + if (*(array + i) == NULL) + { + *(array + i +1) = NULL; + *(array + i) = ctrl; + return ; + } + } + fprintf(stderr, "%s: failed to store request control!!!!!!\n", + ldaptool_progname); +} + +/* + * Dispose of all controls in array and prepare array for reuse. + */ +void +ldaptool_reset_control_array( LDAPControl **array ) +{ + int i; + + for ( i = 0; i < CONTROL_REQUESTS; i++ ) { + if ( array[i] != NULL ) { + ldap_control_free( array[i] ); + array[i] = NULL; + } + } +} + +/* + * This function calculates control value and its length. *value can + * be pointing to plain value, ":b64encoded value" or "<fileurl". + */ +static int +calculate_ctrl_value( const char *value, + char **ctrl_value, int *vlen) +{ + int b64; + if (*value == ':') { + value++; + b64 = 1; + } else { + b64 = 0; + } + *ctrl_value = (char *)value; + + if ( b64 ) { + if (( *vlen = ldif_base64_decode( (char *)value, + (unsigned char *)value )) < 0 ) { + fprintf( stderr, + "Unable to decode base64 control value \"%s\"\n", value); + return( -1 ); + } + } else { + *vlen = (int)strlen(*ctrl_value); + } + return( 0 ); +} + +/* + * Parse the optarg from -J option of ldapsearch + * and within LDIFfile for ldapmodify. Take ctrl_arg + * (the whole string) and divide it into oid, criticality + * and value. This function breaks down original ctrl_arg + * with '\0' in places. Also, calculate length of valuestring. + */ +int +ldaptool_parse_ctrl_arg(char *ctrl_arg, char sep, + char **ctrl_oid, int *ctrl_criticality, + char **ctrl_value, int *vlen) +{ + char *s, *p; + int strict; + + /* Initialize passed variables with default values */ + *ctrl_oid = *ctrl_value = NULL; + *ctrl_criticality = 0; + *vlen = 0; + + strict = (sep == ' ' ? 1 : 0); + if(!(s=strchr(ctrl_arg, sep))) { + /* Possible values of ctrl_arg are + * oid[:value|::b64value|:<fileurl] within LDIF, i.e. sep=' ' + * oid from command line option, i.e. sep=':' + */ + if (sep == ' ') { + if (!(s=strchr(ctrl_arg, ':'))) { + *ctrl_oid = ctrl_arg; + } + else { + /* ctrl_arg is of oid:[value|:b64value|<fileurl] + * form in the LDIF record. So, grab the oid and then + * jump to continue the parsing of ctrl_arg. + * 's' is pointing just after oid ends. + */ + *s++ = '\0'; + *ctrl_oid = ctrl_arg; + return (calculate_ctrl_value( s, ctrl_value, vlen )); + } + } else { + /* oid - from command line option, i.e. sep=':' */ + *ctrl_oid = ctrl_arg; + } + } + else { + /* Possible values of ctrl_arg are + * oid:criticality[:value|::b64value|:<fileurl] - command line + * oid criticality[:value|::b64value|:<fileurl] - LDIF + * And 's' is pointing just after oid ends. + */ + + if (*(s+1) == '\0') { + fprintf( stderr, "missing value\n" ); + return( -1 ); + } + *s = '\0'; + *ctrl_oid = ctrl_arg; + p = ++s; + if(!(s=strchr(p, ':'))) { + if ( (*ctrl_criticality = ldaptool_boolean_str2value(p, strict)) + == -1 ) { + fprintf( stderr, "Invalid criticality value\n" ); + return( -1 ); + } + } + else { + if (*(s+1) == '\0') { + fprintf( stderr, "missing value\n" ); + return ( -1 ); + } + *s++ = '\0'; + if ( (*ctrl_criticality = ldaptool_boolean_str2value(p, strict)) + == -1 ) { + fprintf( stderr, "Invalid criticality value\n" ); + return ( -1 ); + } + return (calculate_ctrl_value( s, ctrl_value, vlen )); + } + } + + return( 0 ); +} + + +/* + * callback function for LDAP bind credentials + */ +/*ARGSUSED*/ +static int +LDAP_CALL +LDAP_CALLBACK +get_rebind_credentials( LDAP *ld, char **whop, char **credp, + int *methodp, int freeit, void* arg ) +{ + if ( !freeit ) { + if ( binddn != NULL ) { + *whop = ldaptool_local2UTF8( binddn, "bind DN" ); + } + + if ( passwd != NULL ) { + if ( isk ) { + *credp = strdup( passwd ); + } else { + *credp = ldaptool_local2UTF8( passwd, "password" ); + } + } + + *methodp = LDAP_AUTH_SIMPLE; + } else { + if ( *whop != NULL ) { + free( *whop ); + } + + if ( *credp != NULL ) { + free( *credp ); + } + + *methodp = LDAP_AUTH_NONE; + } + + return( LDAP_SUCCESS ); +} + + +/* + * return pointer to pathname to temporary directory. + * First we see if the environment variable "TEMP" is set and use it. + * Then we see if the environment variable "TMP" is set and use it. + * If this fails, we use "/tmp" on UNIX and fail on Windows. + */ +char * +ldaptool_get_tmp_dir( void ) +{ + char *p; + int offset; + + if (( p = getenv( "TEMP" )) == NULL && ( p = getenv( "TMP" )) == NULL ) { +#ifdef _WINDOWS + fprintf( stderr, "%s: please set the TEMP environment variable.\n", + ldaptool_progname ); + exit( LDAP_LOCAL_ERROR ); +#else + return( "/tmp" ); /* last resort on UNIX */ +#endif + } + + /* + * remove trailing slash if present + */ + offset = strlen( p ) - 1; + if ( p[offset] == '/' +#ifdef _WINDOWS + || p[offset] == '\\' +#endif + ) { + if (( p = strdup( p )) == NULL ) { + perror( "strdup" ); + exit( LDAP_NO_MEMORY ); + } + + p[offset] = '\0'; + } + + return( p ); +} + + +int +ldaptool_berval_is_ascii( const struct berval *bvp ) +{ + unsigned long j; + int is_ascii = 1; /* optimistic */ + + for ( j = 0; j < bvp->bv_len; ++j ) { + if ( !isascii( bvp->bv_val[ j ] )) { + is_ascii = 0; + break; + } + } + + return( is_ascii ); +} + + +#ifdef LDAP_DEBUG_MEMORY +#define LDAPTOOL_ALLOC_FREED 0xF001 +#define LDAPTOOL_ALLOC_INUSE 0xF002 + +static void * +ldaptool_debug_alloc( void *ptr, size_t size ) +{ + int *statusp; + void *systemptr; + + if ( ptr == NULL ) { + systemptr = NULL; + } else { + systemptr = (void *)((char *)ptr - sizeof(int)); + } + + if (( statusp = (int *)realloc( systemptr, size + sizeof(int))) == NULL ) { + fprintf( stderr, "%s: realloc( 0x%x, %d) failed\n", + ldaptool_progname, systemptr, size ); + return( NULL ); + } + + *statusp = LDAPTOOL_ALLOC_INUSE; + + return( (char *)statusp + sizeof(int)); +} + + +static void * +ldaptool_debug_realloc( void *ptr, size_t size ) +{ + void *p; + + if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { + fprintf( stderr, "%s: => realloc( 0x%x, %d )\n", + ldaptool_progname, ptr, size ); + } + + p = ldaptool_debug_alloc( ptr, size ); + + if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { + fprintf( stderr, "%s: 0x%x <= realloc()\n", ldaptool_progname, p ); + } + + return( p ); +} + + +static void * +ldaptool_debug_malloc( size_t size ) +{ + void *p; + + if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { + fprintf( stderr, "%s: => malloc( %d)\n", ldaptool_progname, size ); + } + + p = ldaptool_debug_alloc( NULL, size ); + + if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { + fprintf( stderr, "%s: 0x%x <= malloc()\n", ldaptool_progname, p ); + } + + return( p ); +} + + +static void * +ldaptool_debug_calloc( size_t nelem, size_t elsize ) +{ + void *p; + + if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { + fprintf( stderr, "%s: => calloc( %d, %d )\n", + ldaptool_progname, nelem, elsize ); + } + + if (( p = ldaptool_debug_alloc( NULL, nelem * elsize )) != NULL ) { + memset( p, 0, nelem * elsize ); + } + + if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { + fprintf( stderr, "%s: 0x%x <= calloc()\n", ldaptool_progname, p ); + } + + return( p ); +} + + +static void +ldaptool_debug_free( void *ptr ) +{ + int *statusp = (int *)((char *)ptr - sizeof(int)); + + if ( ldaptool_dbg_lvl & LDAP_DEBUG_TRACE ) { + fprintf( stderr, "%s: => free( 0x%x )\n", ldaptool_progname, ptr ); + } + + if ( ptr == NULL ) { + fprintf( stderr, "%s: bad free( 0x0 ) attempted (NULL pointer)\n", + ldaptool_progname ); + } else if ( *statusp != LDAPTOOL_ALLOC_INUSE ) { + fprintf( stderr, "%s: bad free( 0x%x ) attempted" + " (block not in use; status is %d)\n", + ldaptool_progname, ptr, *statusp ); + } else { + *statusp = LDAPTOOL_ALLOC_FREED; + free( statusp ); + } +} +#endif /* LDAP_DEBUG_MEMORY */ + + +#if defined(NET_SSL) +#ifdef LDAP_TOOL_PKCS11 +static +char * +buildTokenCertName( const char *tokenName, const char *certName) +{ + + int tokenlen = strlen(tokenName); + int len = tokenlen + strlen(certName) +2; + char *result; + + if (( result = malloc( len )) != NULL) { + strcpy(result, tokenName); + *(result+tokenlen) = ':'; + ++tokenlen; + strcpy(result+tokenlen, certName); + } else { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + return result; +} + + + +/*ARGSUSED*/ +static int +ldaptool_getcertpath( void *context, char **certlocp ) +{ + + *certlocp = ssl_certdbpath; + if ( ldaptool_verbose ) { + if (ssl_certdbpath) + { + printf("ldaptool_getcertpath -- %s\n", ssl_certdbpath ); + } + else + { + printf("ldaptool_getcertpath -- (null)\n"); + } + + } + return LDAP_SUCCESS; +} + +/*ARGSUSED*/ +int +ldaptool_getcertname( void *context, char **certnamep ) +{ + + *certnamep = ssl_certname; + if ( ldaptool_verbose ) { + if (ssl_certname) + { + printf("ldaptool_getcertname -- %s\n", *certnamep); + } + else + { + printf("ldaptool_getcertname -- (null)\n"); + } + } + return LDAP_SUCCESS; +} + +/*ARGSUSED*/ +int +ldaptool_getkeypath(void *context, char **keylocp ) +{ + *keylocp = ssl_keydbpath; + if ( ldaptool_verbose ) { + if (ssl_keydbpath) + { + printf("ldaptool_getkeypath -- %s\n",*keylocp); + } + else + { + printf("ldaptool_getkeypath -- (null)\n"); + } + } + + return LDAP_SUCCESS; +} + +/*ARGSUSED*/ +int +ldaptool_gettokenname( void *context, char **tokennamep ) +{ + + *tokennamep = pkcs_token; + if ( ldaptool_verbose ) { + if (pkcs_token) + { + printf("ldaptool_gettokenname -- %s\n",*tokennamep); + } + else + { + printf("ldaptool_gettokenname -- (null)\n"); + } + } + + return LDAP_SUCCESS; +} + +/*ARGSUSED*/ +int +ldaptool_gettokenpin( void *context, const char *tokennamep, char **tokenpinp) +{ + +#if 0 + char *localtoken; +#endif + +/* XXXceb this stuff is removed for the time being. + * This function should return the pin from ssl_password + */ + + + *tokenpinp = ssl_passwd; + return LDAP_SUCCESS; + +#if 0 + + ldaptool_gettokenname( NULL, &localtoken); + + if (strcmp( localtoken, tokennamep)) + + *tokenpinp = pkcs_pin; + else + *tokenpinp = NULL; + + if ( ldaptool_verbose ) { + if (pkcs_pin) + { + printf("ldaptool_getokenpin --%s\n", tokenpinp); + } + else + { + printf("ldaptool_getokenpin -- (null)\n"); + } + } + return LDAP_SUCCESS; +#endif +} + +/*ARGSUSED*/ +int +ldaptool_getmodpath( void *context, char **modulep ) +{ + *modulep = ssl_secmodpath; + if ( ldaptool_verbose ) { + if (ssl_secmodpath) + { + printf("ldaptool_getmodpath -- %s\n", *modulep); + } + else + { + printf("ldaptool_getmodpath -- (null)\n"); + } + } + + return LDAP_SUCCESS; +} + +/*ARGSUSED*/ +int +ldaptool_getdonglefilename( void *context, char **filename ) +{ + *filename = ssl_donglefile; + if ( ldaptool_verbose ) { + if (ssl_donglefile) + { + printf("ldaptool_getdonglefilename -- %s\n", *filename); + } + else + { + printf("ldaptool_getdonglefilename -- (null)\n"); + } + + } + + return LDAP_SUCCESS; +} + +static void +ldaptool_setcallbacks( struct ldapssl_pkcs_fns *pfns) +{ + pfns->pkcs_getcertpath = (int (*)(void *, char **))ldaptool_getcertpath; + pfns->pkcs_getcertname = (int (*)(void *, char **))ldaptool_getcertname; + pfns->pkcs_getkeypath = (int (*)(void *, char **)) ldaptool_getkeypath; + pfns->pkcs_getmodpath = (int (*)(void *, char **)) ldaptool_getmodpath; + pfns->pkcs_getpin = (int (*)(void *, const char*, char **)) ldaptool_gettokenpin; + pfns->pkcs_gettokenname = (int (*)(void *, char **)) ldaptool_gettokenname; + pfns->pkcs_getdonglefilename = (int (*)(void *, char **)) ldaptool_getdonglefilename; + pfns->local_structure_id=PKCS_STRUCTURE_ID; +} + +#endif /* LDAP_TOOL_PKCS11 */ +#endif /* NET_SSL */ + +#ifdef HAVE_SASL_OPTIONS +/* + * Function checks for valid args, returns an error if not found + * and sets SASL params from command line + */ + +static int +saslSetParam(char *saslarg) +{ + char *attr = NULL; + int argnamelen; + + attr = strchr(saslarg, '='); + if (attr == NULL) { + fprintf( stderr, "Didn't find \"=\" character in %s\n", saslarg); + return (-1); + } + + argnamelen = attr - saslarg; + attr++; + + if (!strncasecmp(saslarg, "secProp", argnamelen)) { + if ( sasl_secprops != NULL ) { + fprintf( stderr, "secProp previously specified\n"); + return (-1); + } + if (( sasl_secprops = strdup(attr)) == NULL ) { + perror ("malloc"); + exit (LDAP_NO_MEMORY); + } + } else if (!strncasecmp(saslarg, "realm", argnamelen)) { + if ( sasl_realm != NULL ) { + fprintf( stderr, "Realm previously specified\n"); + return (-1); + } + if (( sasl_realm = strdup(attr)) == NULL ) { + perror ("malloc"); + exit (LDAP_NO_MEMORY); + } + } else if (!strncasecmp(saslarg, "authzid", argnamelen)) { + if (sasl_username != NULL) { + fprintf( stderr, "Authorization name previously specified\n"); + return (-1); + } + if (( sasl_username = strdup(attr)) == NULL ) { + perror ("malloc"); + exit (LDAP_NO_MEMORY); + } + } else if (!strncasecmp(saslarg, "authid", argnamelen)) { + if ( sasl_authid != NULL ) { + fprintf( stderr, "Authentication name previously specified\n"); + return (-1); + } + if (( sasl_authid = strdup(attr)) == NULL) { + perror ("malloc"); + exit (LDAP_NO_MEMORY); + } + } else if (!strncasecmp(saslarg, "mech", argnamelen)) { + if ( sasl_mech != NULL ) { + fprintf( stderr, "Mech previously specified\n"); + return (-1); + } + if (( sasl_mech = strdup(attr)) == NULL) { + perror ("malloc"); + exit (LDAP_NO_MEMORY); + } + } else if (!strncasecmp(saslarg, "flags", argnamelen)) { + int len = strlen(attr); + if (len && !strncasecmp(attr, "automatic", len)) { + sasl_flags = LDAP_SASL_AUTOMATIC; + } else if (len && !strncasecmp(attr, "interactive", len)) { + sasl_flags = LDAP_SASL_INTERACTIVE; + } else if (len && !strncasecmp(attr, "quiet", len)) { + sasl_flags = LDAP_SASL_QUIET; + } else { + fprintf(stderr, "Invalid SASL flags value [%s]: must be one of " + "automatic, interactive, or quiet\n", attr); + return (-1); + } + } else { + fprintf (stderr, "Invalid attribute name %s\n", saslarg); + return (-1); + } + return 0; +} +#endif /* HAVE_SASL_OPTIONS */ + +/* + * Implements getpass like functionality for supported platforms. + * + * It is the callers responsibility to zero out the memory used + * to store the password and to free it when it's finished with + * it. + */ +char * +ldaptool_getpass ( const char *prompt ) +{ + char *pass; + +#if defined(_WIN32) + char pbuf[257]; + fputs(prompt,stdout); + fflush(stdout); + if (fgets(pbuf,256,stdin) == NULL) { + pass = NULL; + } else { + char *tmp; + + tmp = strchr(pbuf,'\n'); + if (tmp) *tmp = '\0'; + tmp = strchr(pbuf,'\r'); + if (tmp) *tmp = '\0'; + pass = strdup(pbuf); + } +#else +#if defined(SOLARIS) + /* 256 characters on Solaris */ + pass = (char *)getpassphrase(prompt); +#else +#if defined(HPUX) + /* HP-UX has deprecated their password asking function, so we have + * to resort to doing it the hard way . . . */ + char pbuf[257]; + struct termios termstat; + tcflag_t savestat; + /* Only perform terminal manipulation if stdin is a terminal */ + int havetty = isatty(fileno(stdin)); + + fputs(prompt, stdout); + fflush(stdout); + + if(havetty) { + if(tcgetattr(fileno(stdin), &termstat) < 0) { + perror( "tcgetattr" ); + exit( LDAP_LOCAL_ERROR ); + } + savestat = termstat.c_lflag; + termstat.c_lflag &= ~(ECHO | ECHOE | ECHOK); + termstat.c_lflag |= (ICANON | ECHONL); + if(tcsetattr(fileno(stdin), TCSANOW, &termstat) < 0) { + perror( "tcsetattr" ); + exit( LDAP_LOCAL_ERROR ); + } + } + if (fgets(pbuf,256,stdin) == NULL) { + pass = NULL; + } else { + char *tmp; + pass = NULL; + tmp = strchr(pbuf,'\n'); + if (tmp) + *tmp = '\0'; + pass = strdup(pbuf); + } + if(havetty) { + termstat.c_lflag = savestat; + if(tcsetattr(fileno(stdin), TCSANOW, &termstat) < 0) { + perror( "tcgetattr" ); + exit( LDAP_LOCAL_ERROR ); + } + } +#else + /* limited to 16 chars on Tru64, 32 on AIX */ + pass = (char *)getpass(prompt); +#endif +#endif +#endif + + return pass; +} + +/* + * ldaptool_read_password + * + * Reads the password in from a file. + */ +char * +ldaptool_read_password( FILE *mod_password_fp ) +{ + int increment = 0; + int c, index; + char *mod_passwd = NULL; + + /* allocate initial block of memory */ + if ((mod_passwd = (char *)malloc(BUFSIZ)) == NULL) { + fprintf( stderr, "%s: not enough memory to read password from file\n", ldaptool_progname ); + exit( LDAP_NO_MEMORY ); + } + increment++; + index = 0; + while ((c = fgetc( mod_password_fp )) != '\n' && c != EOF) { + + /* check if we will overflow the buffer */ + if ((c != EOF) && (index == ((increment * BUFSIZ) -1))) { + + /* if we did, add another BUFSIZ worth of bytes */ + if ((mod_passwd = (char *) + realloc(mod_passwd, (increment + 1) * BUFSIZ)) == NULL) { + fprintf( stderr, "%s: not enough memory to read password from file\n", ldaptool_progname ); + exit( LDAP_NO_MEMORY ); + } + increment++; + } + mod_passwd[index++] = c; + } + mod_passwd[index] = '\0'; + + return( (char *)mod_passwd ); +} + +int +ldaptool_boolean_str2value ( const char *ptr, int strict ) +{ + if (strict) { + if ( !(strcasecmp(ptr, "true"))) { + return 1; + } + else if ( !(strcasecmp(ptr, "false"))) { + return 0; + } + else { + return (-1); + } + } + else { + if ( !(strcasecmp(ptr, "true")) || + !(strcasecmp(ptr, "t")) || + !(strcmp(ptr, "1")) ) { + return (1); + } + else if ( !(strcasecmp(ptr, "false")) || + !(strcasecmp(ptr, "f")) || + !(strcmp(ptr, "0")) ) { + return (0); + } + else { + return (-1); + } + } +} + +FILE * +ldaptool_open_file(const char *filename, const char *mode) +{ +#ifdef _LARGEFILE64_SOURCE + return fopen64(filename, mode); +#else + return fopen(filename, mode); +#endif +} + +/* + * check for and report input or output error on named stream + * return ldap_err or ferror() (ldap_err takes precedence) + * assume that fflush() already has been called if needed. + * don't want to fflush() an input stream. + */ +int +ldaptool_check_ferror(FILE * stream, const int ldap_err, const char *msg) +{ + int err = 0; + if ((err = ferror(stream)) != 0 ) { + fprintf(stderr, "%s: ERROR: ", ldaptool_progname); + perror(msg); + err = LDAP_LOCAL_ERROR; + } + + /* + * reporting LDAP_ error code is more important than + * reporting errors from ferror() + */ + if (LDAP_SUCCESS == ldap_err) { + return(err); + } + else { + return(ldap_err); + } +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/convutf8.cpp
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/convutf8.cpp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/examples-from-ldif-spec.ldif
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/examples-from-ldif-spec.ldif)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/fileurl.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/fileurl.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/fileurl.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/fileurl.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ldapcmp.c
Added
@@ -0,0 +1,623 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* tool to compare the contents of two LDAP directory subtrees */ + +#include "ldaptool.h" + +typedef struct attr { + char *name; + char **vals; + struct attr *next; +} ATTR; /* used for comparing two entries */ + +static void options_callback( int option, char *optarg ); +static int docompare( LDAP *ld1, LDAP *ld2, char *base ); +static int cmp2(LDAP *ld1, LDAP *ld2, LDAPMessage *e1, int findonly ); +static void notfound(char *base, int dbaseno); +static ATTR* get_attrs( LDAP *ld, LDAPMessage *e ); +static char* cmp_attrs( ATTR *a1, ATTR *a2 ); +static void attr_free(ATTR *at); +#if 0 /* these functions are not used */ +static void print_entry( LDAP *ld, LDAPMessage *entry, int attrsonly ); +static void print_dn( LDAP *ld, LDAPMessage *entry ); +static void write_ldif_value( char *type, char *value, unsigned long vallen ); +#endif /* 0 */ + +static void +usage( void ) +{ + fprintf( stderr, + "usage: %s -b basedn [options] [attributes...]\nwhere:\n", + ldaptool_progname ); + fprintf( stderr, " basedn\tbase dn for search\n" ); + fprintf( stderr, "\t\t(if the environment variable LDAP_BASEDN is set,\n" ); + fprintf( stderr, "\t\tthen the -b flag is not required)\n" ); + fprintf( stderr, "options:\n" ); + fprintf( stderr, " -s scope\tone of base, one, or sub (default is sub)\n" ); + fprintf( stderr, " -l timelim\ttime limit (in seconds) for search (default is no limit)\n" ); + fprintf( stderr, " -z sizelim\tsize limit (in entries) for search (default is no limit)\n" ); + ldaptool_common_usage( 1 ); + exit( LDAP_PARAM_ERROR ); +} + +static char *base = NULL; +static int allow_binary, vals2tmp, ldif, scope, deref, differ=0; +static int attrsonly, timelimit, sizelimit; +#if 0 /* these statics are referenced only by unused functions */ +static char *sep = LDAPTOOL_DEFSEP; +static char **sortattr = NULL; +static int *skipsortattr = NULL; +static int includeufn; +#endif /* 0 */ + + +int +main( int argc, char **argv ) +{ + int rc, optind; + LDAP *ld1, *ld2; + +#ifdef notdef +#ifdef HPUX11 +#ifndef __LP64__ + _main( argc, argv); +#endif /* __LP64_ */ +#endif /* HPUX11 */ +#endif + + deref = LDAP_DEREF_NEVER; + allow_binary = vals2tmp = attrsonly = 0; + ldif = 1; + sizelimit = timelimit = 0; + scope = LDAP_SCOPE_SUBTREE; + + optind = ldaptool_process_args( argc, argv, "Bb:l:s:z:", 1, + options_callback ); + + if ( optind == -1 ) { + usage(); + } + + if ( base == NULL ) { + if (( base = getenv( "LDAP_BASEDN" )) == NULL ) { + usage(); + } + } + + ld1 = ldaptool_ldap_init( 0 ); + + ldap_set_option( ld1, LDAP_OPT_DEREF, &deref ); + ldap_set_option( ld1, LDAP_OPT_TIMELIMIT, &timelimit ); + ldap_set_option( ld1, LDAP_OPT_SIZELIMIT, &sizelimit ); + + ldaptool_bind( ld1 ); + + ld2 = ldaptool_ldap_init( 1 ); + + ldap_set_option( ld2, LDAP_OPT_DEREF, &deref ); + ldap_set_option( ld2, LDAP_OPT_TIMELIMIT, &timelimit ); + ldap_set_option( ld2, LDAP_OPT_SIZELIMIT, &sizelimit ); + + ldaptool_bind( ld2 ); + if ( ldaptool_verbose ) { + printf( "Connections to servers established. Beginning comparison.\n" ); + } + + rc = docompare( ld1, ld2, base ); + + ldaptool_cleanup( ld1 ); + ldaptool_cleanup( ld2 ); + if ( ldaptool_verbose && !rc ) { + if ( !differ ) { + printf( "compare completed: no differences found\n" ); + } else { + printf( "compare completed: ****differences were found****\n" ); + } + } + + /* check for and report output error */ + fflush( stdout ); + rc = ldaptool_check_ferror( stdout, rc, "output error (output might be incomplete)" ); + return( rc ); +} + + +static void +options_callback( int option, char *optarg ) +{ + switch( option ) { + case 'B': /* allow binary values to be printed, even if -o used */ + ++allow_binary; + break; + case 's': /* search scope */ + if ( strncasecmp( optarg, "base", 4 ) == 0 ) { + scope = LDAP_SCOPE_BASE; + } else if ( strncasecmp( optarg, "one", 3 ) == 0 ) { + scope = LDAP_SCOPE_ONELEVEL; + } else if ( strncasecmp( optarg, "sub", 3 ) == 0 ) { + scope = LDAP_SCOPE_SUBTREE; + } else { + fprintf( stderr, "scope should be base, one, or sub\n" ); + usage(); + } + break; + case 'b': /* searchbase */ + base = strdup( optarg ); + break; + case 'l': /* time limit */ + timelimit = atoi( optarg ); + break; + case 'z': /* size limit */ + sizelimit = atoi( optarg ); + break; + default: + usage(); + break; + } +} + + +/* + * Returns an LDAP error code. + */ +static int +docompare( LDAP *ld1, LDAP *ld2, char *base ) +{ + int rc, msgid; + LDAPMessage *res, *e; + LDAPControl *ctrls[2], **serverctrls; + + if ( ldaptool_verbose ) { + printf( "Base: %s\n\n", base ); + } + if ( ldaptool_not ) { + return( LDAP_SUCCESS ); + } + + if (( ctrls[0] = ldaptool_create_manage_dsait_control()) != NULL ) { + ctrls[1] = NULL; + serverctrls = ctrls; + } else { + serverctrls = NULL; + } + + if ( ldap_search_ext( ld1, base, scope, "objectClass=*", NULL, + 0, serverctrls, NULL, NULL, -1, &msgid ) != LDAP_SUCCESS ) { + return( ldaptool_print_lderror( ld1, "ldap_search", + LDAPTOOL_CHECK4SSL_IF_APPROP )); + } +/* XXXmcs: this code should be modified to display referrals and references */ + while ( (rc = ldap_result( ld1, LDAP_RES_ANY, 0, NULL, &res )) == + LDAP_RES_SEARCH_ENTRY ) { + e = ldap_first_entry( ld1, res ); + rc = cmp2( ld1, ld2, e , 0); + ldap_msgfree( res ); + } + if ( rc == -1 ) { + return( ldaptool_print_lderror( ld1, "ldap_result", + LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + if (( rc = ldap_result2error( ld1, res, 0 )) != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld1, "ldap_search", + LDAPTOOL_CHECK4SSL_IF_APPROP ); + } + ldap_msgfree( res ); + + if ( ldap_search_ext( ld2, base, scope, "objectClass=*", NULL, + 0, serverctrls, NULL, NULL, -1, &msgid ) == -1 ) { + return( ldaptool_print_lderror( ld2, "ldap_search", + LDAPTOOL_CHECK4SSL_IF_APPROP )); + } +/* XXXmcs: this code should be modified to display referrals and references */ + while ( (rc = ldap_result( ld2, LDAP_RES_ANY, 0, NULL, &res )) == + LDAP_RES_SEARCH_ENTRY ) { + e = ldap_first_entry( ld2, res ); + rc = cmp2( ld2, ld1, e , 1); + ldap_msgfree( res ); + } + if ( rc == -1 ) { + return( ldaptool_print_lderror( ld2, "ldap_result", + LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + if (( rc = ldap_result2error( ld1, res, 0 )) != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld1, "ldap_search", + LDAPTOOL_CHECK4SSL_IF_APPROP ); + } + ldap_msgfree( res ); + + return( rc ); +} + + +/* + * Returns an LDAP error code. + */ +static int +cmp2( LDAP *ld1, LDAP *ld2, LDAPMessage *e1, int findonly) +{ + LDAPMessage *e2, *res; + char *dn, *attrcmp; + int found=0, rc; + ATTR *a1, *a2; + + dn = ldap_get_dn( ld1, e1 ); + + if ( ldaptool_verbose ) { + if ( findonly ) { + printf( "Checking that %s exists on both servers\n", dn ); + } else { + printf("Comparing entry %s on both servers\n", dn ); + } + } + + if ( ldap_search( ld2, dn, LDAP_SCOPE_BASE, "objectClass=*", NULL, 0 ) == -1 ) { + return( ldaptool_print_lderror( ld2, "ldap_search", + LDAPTOOL_CHECK4SSL_IF_APPROP )); + } +/* XXXmcs: this code should be modified to display referrals and references */ + while ( (rc = ldap_result( ld2, LDAP_RES_ANY, 0, NULL, &res )) == + LDAP_RES_SEARCH_ENTRY ) { + e2 = ldap_first_entry( ld1, res ); + found = 1; + if ( !findonly ) { + a1 = get_attrs( ld1, e1 ); + a2 = get_attrs( ld2, e2 ); + attrcmp = cmp_attrs( a1, a2 ); + if ( strcmp( attrcmp, "") != 0 ) { + printf("\n%s%s\n", dn, attrcmp); + } + } + ldap_msgfree( res ); + } + if ( !found ) { + notfound( dn, findonly ); + differ = 1; + } + if ( rc == -1 ) { + return( ldaptool_print_lderror( ld2, "ldap_result", + LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + ldap_msgfree( res ); + ldap_memfree( dn ); + return(rc); +} + + +static ATTR* +get_attrs( LDAP *ld, LDAPMessage *e ) +{ + char *a; + ATTR *head, *tail, *tmp; + BerElement *ber; + + head=tail=tmp=NULL; + for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL; + a = ldap_next_attribute( ld, e, ber ) ) { + tmp = (ATTR*)malloc(sizeof(ATTR)); + if(head == NULL) + head = tail = tmp; + else { + tail->next = tmp; + tail = tmp; + } + tmp->name = a; + tmp->vals = ldap_get_values( ld, e, a ); + tmp->next = NULL; + } + if ( ber != NULL ) { + ber_free( ber, 0 ); + } + /* used for debugging + tmp=head; + while(tmp!= NULL) { + printf("\n%s :", tmp->name); + for(i=0; tmp->vals[i] != NULL; i++) + printf("\n\t%d %s", i, tmp->vals[i]); + tmp = tmp->next; + } + */ + return(head); +} + + +static char* +cmp_attrs( ATTR *a1, ATTR *a2 ) +{ + static char result[5000]; + char res[1000], partial[1000], *name = ""; + ATTR *head1, *head2, *tmp, *prev, *start; + int i, j, found; + + head1 = a1; + head2 = a2; + tmp = a2; + prev = NULL; + strcpy(result, ""); + while(head1 != NULL) { + name = head1->name; + if(head2 == NULL) { + while(head1 != NULL) { + sprintf(partial, "\ndifferent: %s(*)", head1->name); + strcat(result, partial); + for(i=0; head1->vals[i] != NULL; i++) { + sprintf(partial,"\n\t1: %s", head1->vals[i]); + strcat(result, partial); + } + tmp = head1; + head1 = head1->next; + attr_free(tmp); + } + differ = 1; + break; + } + name = head1->name; + start = tmp; + while(tmp != NULL) { + if(!strcmp(name, tmp->name)) { /* attr found */ + strcpy(res, ""); + for(i=0; (head1->vals[i]) != NULL; i++) { + found = 0; + for(j=0; (tmp->vals[j]) != NULL; j++) + if(!strcmp(head1->vals[i], tmp->vals[j])) { + found = 1; + tmp->vals[j][0] = 7; + break; + } + if(!found) { + sprintf(partial, "\n\t1: %s", head1->vals[i]); + strcat(res, partial); + } + } + for(j=0; tmp->vals[j] != NULL; j++) + if(tmp->vals[j][0] != 7){ + sprintf(partial, "\n\t2: %s", tmp->vals[j]); + strcat(res, partial); + } + + if(strcmp(res, "")) { + sprintf(partial, "\ndifferent: %s%s", name, res); + differ = 1; + strcat(result, partial); + } + if(prev == NULL) { /* tmp = head2 */ + head2 = head2->next; + attr_free(tmp); + tmp = head2; + } + else { + prev->next = tmp->next; + attr_free(tmp); + tmp = prev->next; + if(tmp == NULL) { + tmp = head2; + prev = NULL; + } + } + break; + } + else { /* attr not found */ + if(prev == NULL) + prev = head2; + else + prev = tmp; + tmp = tmp->next; + if(tmp == NULL) { /* end of list */ + tmp = head2; + prev = NULL; + } + if(tmp == start) { /* attr !exist in 2 */ + sprintf(partial, "\ndifferent: %s(*)", name); + differ = 1; + strcat(result, partial); + for(i=0; head1->vals[i] != NULL; i++) { + sprintf(partial, "\n\t1: %s", head1->vals[i]); + strcat(result, partial); + } + break; + } + } + } + start = head1; + head1 = head1->next; + attr_free(start); + } + while(head2 != NULL) { + sprintf(partial, "\ndifferent: %s(*)", head2->name); + differ = 1; + strcat(result, partial); + for(i=0; head2->vals[i] != NULL; i++) { + sprintf(partial, "\n\t2: %s", head2->vals[i]); + strcat(result, partial); + } + tmp = head2; + head2 = head2->next; + attr_free(tmp); + } + return(result); +} + + +static void +attr_free(ATTR *at) +{ + ldap_memfree(at->name); + ldap_value_free(at->vals); + free(at); +} + + +static void +notfound(char *base, int dbaseno) +{ + printf("%donly: %s\n", dbaseno+1, base); +} + + +#if 0 /* these function is not used */ +/* used for debugging */ +static void +print_dn( LDAP *ld, LDAPMessage *entry ) +{ + char *dn, *ufn; + + dn = ldap_get_dn( ld, entry ); + if ( ldif ) { + write_ldif_value( "dn", dn, strlen( dn )); + } else { + printf( "%s\n", dn ); + } + if ( includeufn ) { + ufn = ldap_dn2ufn( dn ); + if ( ldif ) { + write_ldif_value( "ufn", ufn, strlen( ufn )); + } else { + printf( "%s\n", ufn ); + } + free( ufn ); + } + ldap_memfree( dn ); +} + + +static void +print_entry( ld, entry, attrsonly ) + LDAP *ld; + LDAPMessage *entry; + int attrsonly; +{ + char *a, *dn, *ufn, tmpfname[ 256 ]; + int i, notascii; + BerElement *ber; + struct berval **bvals; + FILE *tmpfp; +#if defined( XP_WIN32 ) + char mode[20] = "w+b"; +#else + char mode[20] = "w"; +#endif + + dn = ldap_get_dn( ld, entry ); + if ( ldif ) { + write_ldif_value( "dn", dn, strlen( dn )); + } else { + printf( "%s\n", dn ); + } + if ( includeufn ) { + ufn = ldap_dn2ufn( dn ); + if ( ldif ) { + write_ldif_value( "ufn", ufn, strlen( ufn )); + } else { + printf( "%s\n", ufn ); + } + free( ufn ); + } + ldap_memfree( dn ); + + for ( a = ldap_first_attribute( ld, entry, &ber ); a != NULL; + a = ldap_next_attribute( ld, entry, ber ) ) { + if ( ldap_charray_inlist(sortattr, a) && /* in the list*/ + skipsortattr[ldap_charray_position(sortattr, a)] ) {/* and skip it*/ + continue; /* so skip it! */ + } + if ( attrsonly ) { + if ( ldif ) { + write_ldif_value( a, "", 0 ); + } else { + printf( "%s\n", a ); + } + } else if (( bvals = ldap_get_values_len( ld, entry, a )) != NULL ) { + for ( i = 0; bvals[i] != NULL; i++ ) { + if ( vals2tmp ) { + sprintf( tmpfname, "%s/ldapcmp-%s-XXXXXX", + ldaptool_get_tmp_dir(), a ); + tmpfp = NULL; + + if ( LDAPTOOL_MKTEMP( tmpfname ) == NULL ) { + perror( tmpfname ); + } else if (( tmpfp = ldaptool_open_file( tmpfname, mode)) == NULL ) { + perror( tmpfname ); + } else if ( fwrite( bvals[ i ]->bv_val, + bvals[ i ]->bv_len, 1, tmpfp ) == 0 ) { + perror( tmpfname ); + } else if ( ldif ) { + write_ldif_value( a, tmpfname, strlen( tmpfname )); + } else { + printf( "%s%s%s\n", a, sep, tmpfname ); + } + + if ( tmpfp != NULL ) { + fclose( tmpfp ); + } + } else { + notascii = 0; + if ( !ldif && !allow_binary ) { + notascii = !ldaptool_berval_is_ascii( bvals[ i ] ); + } + + if ( ldif ) { + write_ldif_value( a, bvals[ i ]->bv_val, + bvals[ i ]->bv_len ); + } else { + printf( "%s%s%s\n", a, sep, + notascii ? "NOT ASCII" : bvals[ i ]->bv_val ); + } + } + } + ber_bvecfree( bvals ); + } + } + if ( ber != NULL ) { + ber_free( ber, 0 ); + } +} + + +static void +write_ldif_value( char *type, char *value, unsigned long vallen ) +{ + char *ldif; + + /* ldif_type_and_value() fails only if malloc() fails. */ + if (( ldif = ldif_type_and_value( type, value, (int)vallen )) == NULL ) { + exit( LDAP_NO_MEMORY ); + } + + fputs( ldif, stdout ); + free( ldif ); +} +#endif /* 0 */
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ldapcompare.c
Added
@@ -0,0 +1,238 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldapdelete.c - simple program to delete an entry using LDAP */ + +#include "ldaptool.h" +#include "fileurl.h" + +static int contoper = 0; +static LDAP *ld; +static int ldapcompare_quiet = 0; + +static int docompare( LDAP *ld, const char *dn, const char *attrtype, + const struct berval *bvalue, LDAPControl **serverctrls ); +static void options_callback( int option, char *optarg ); +static int typeval2berval( char *typeval, char **typep, struct berval *bvp ); + + +static void +usage( int rc ) +{ + fprintf( stderr, "usage: %s [options] attributetype:value [dn...]\n", + ldaptool_progname ); + fprintf( stderr, " %s [options] attributetype::base64value [dn...]\n", + ldaptool_progname ); + fprintf( stderr, " %s [options] attributetype:<fileurl [dn...]\n", + ldaptool_progname ); + fprintf( stderr, "options:\n" ); + ldaptool_common_usage( 0 ); + fprintf( stderr, " -c\t\tcontinuous mode (do not stop on errors)\n" ); + fprintf( stderr, " -f file\tread DNs to compare against from file\n" ); + fprintf( stderr, " -q\t\tbe quiet when comparing entries\n" ); + exit( rc ); +} + + +int +main( int argc, char **argv ) +{ + char buf[ 4096 ], *typeval = NULL, *type = NULL; + struct berval bv; + int rc, optind; + LDAPControl *ldctrl; + +#ifdef notdef +#ifdef HPUX11 +#ifndef __LP64__ + _main( argc, argv); +#endif /* __LP64_ */ +#endif /* HPUX11 */ +#endif + + optind = ldaptool_process_args( argc, argv, "cq", 0, options_callback ); + + if ( optind == -1 ) { + usage ( LDAP_PARAM_ERROR ); + } + + if ( ldaptool_fp == NULL && optind >= argc ) { + ldaptool_fp = stdin; + } + + ld = ldaptool_ldap_init( 0 ); + + ldaptool_bind( ld ); + + if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) { + ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); + } + + if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) { + ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); + } + + if ( optind >= argc ) { + usage( LDAP_PARAM_ERROR ); + } + + typeval = ldaptool_local2UTF8( argv[optind], "type and value" ); + if (( rc = typeval2berval( typeval, &type, &bv )) != LDAP_SUCCESS ) { + fprintf( stderr, "%s: unable to parse \"%s\"\n", + ldaptool_progname, argv[optind] ); + usage( rc ); + free( typeval ); + } + ++optind; + + rc = 0; + if ( ldaptool_fp == NULL ) { + for ( ; optind < argc && + ( contoper || !LDAPTOOL_RESULT_IS_AN_ERROR( rc ) ); + ++optind ) { + char *conv; + + conv = ldaptool_local2UTF8( argv[ optind ], "DN" ); + rc = docompare( ld, conv, type, &bv, ldaptool_request_ctrls ); + if ( conv != NULL ) { + free( conv ); + } + } + } else { + while (( contoper || !LDAPTOOL_RESULT_IS_AN_ERROR( rc )) && + fgets(buf, sizeof(buf), ldaptool_fp) != NULL) { + buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */ + if ( *buf != '\0' ) { + rc = docompare( ld, buf, type, &bv, ldaptool_request_ctrls ); + } + } + } + + ldaptool_reset_control_array( ldaptool_request_ctrls ); + ldaptool_cleanup( ld ); + if ( typeval != NULL ) free( typeval ); + if ( bv.bv_val != NULL ) free( bv.bv_val ); + + /* check for and report output error */ + fflush( stdout ); + rc = ldaptool_check_ferror( stdout, rc, "output error (output might be incomplete)" ); + return( rc ); +} + +/*ARGSUSED1*/ +static void +options_callback( int option, char *optarg ) +{ + switch( option ) { + case 'c': /* continuous operation mode */ + ++contoper; + break; + case 'q': /* quiet mode */ + ++ldapcompare_quiet; + break; + default: + usage( LDAP_PARAM_ERROR ); + } +} + + +static int +docompare( LDAP *ld, const char *dn, const char *attrtype, + const struct berval *bvalue, LDAPControl **serverctrls ) +{ + int rc; + + if ( !ldapcompare_quiet ) { + char *valuestr, tmpbuf[256]; + + if ( ldaptool_berval_is_ascii( bvalue )) { + valuestr = bvalue->bv_val; + } else { +#ifdef HAVE_SNPRINTF + snprintf( tmpbuf, sizeof(tmpbuf), "NOT ASCII (%d bytes)", + bvalue->bv_len ); +#else + sprintf( tmpbuf, "NOT ASCII (%d bytes)", + bvalue->bv_len ); +#endif + valuestr = tmpbuf; + } + printf( "%scomparing type: \"%s\" value: \"%s\" in entry \"%s\"\n", + ldaptool_not ? "!" : "", attrtype, valuestr, dn ); + } + if ( ldaptool_not ) { + rc = LDAP_COMPARE_TRUE; + } else { + rc = ldaptool_compare_ext_s( ld, dn, attrtype, bvalue, + serverctrls, NULL, "ldap_compare" ); + if ( !ldapcompare_quiet ) { + if ( rc == LDAP_COMPARE_TRUE ) { + puts( "compare TRUE" ); + } else if ( rc == LDAP_COMPARE_FALSE ) { + puts( "compare FALSE" ); + } + } + } + + return( rc ); +} + + +/* + * Parse an ldapcompare type:value or type::value argument. + * + * The *typep is set to point into the typeval string. + * bvp->bv_val is created from malloc'd memory. + * + * This function returns an LDAP error code (LDAP_SUCCESS if all goes well). + */ +static int +typeval2berval( char *typeval, char **typep, struct berval *bvp ) +{ + char *value; + int vlen, rc; + + if ( ldif_parse_line( typeval, typep, &value, &vlen ) != 0 ) { + return( LDAP_PARAM_ERROR ); + } + + rc = ldaptool_berval_from_ldif_value( value, vlen, bvp, + 1 /* recognize file URLs */, 0 /* always try file */, + 1 /* report errors */ ); + + return( ldaptool_fileurlerr2ldaperr( rc )); +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ldapdelete.c
Added
@@ -0,0 +1,162 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldapdelete.c - simple program to delete an entry using LDAP */ + +#include "ldaptool.h" + +static int contoper; +static LDAP *ld; + +static int dodelete( LDAP *ld, char *dn, LDAPControl **serverctrls ); +static void options_callback( int option, char *optarg ); + + +static void +usage( void ) +{ + fprintf( stderr, "usage: %s [options] [dn...]\n", ldaptool_progname ); + fprintf( stderr, "options:\n" ); + ldaptool_common_usage( 0 ); + fprintf( stderr, " -c\t\tcontinuous mode (do not stop on errors)\n" ); + fprintf( stderr, " -f file\tread DNs to delete from file (default: standard input)\n" ); + exit( LDAP_PARAM_ERROR ); +} + + +int +main( int argc, char **argv ) +{ + char buf[ 4096 ]; + int rc = 0; + int deref, optind; + LDAPControl *ldctrl; + +#ifdef notdef +#ifdef HPUX11 +#ifndef __LP64__ + _main( argc, argv); +#endif /* __LP64_ */ +#endif /* HPUX11 */ +#endif + + contoper = 0; + + optind = ldaptool_process_args( argc, argv, "c", 0, options_callback ); + + if ( optind == -1 ) { + usage(); + } + + if ( ldaptool_fp == NULL && optind >= argc ) { + ldaptool_fp = stdin; + } + + ld = ldaptool_ldap_init( 0 ); + + deref = LDAP_DEREF_NEVER; /* prudent, but probably unnecessary */ + ldap_set_option( ld, LDAP_OPT_DEREF, &deref ); + + ldaptool_bind( ld ); + + if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) { + ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); + } + + if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) { + ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); + } + + if ( ldaptool_fp == NULL ) { + for ( ; optind < argc; ++optind ) { + char *conv; + + conv = ldaptool_local2UTF8( argv[ optind ], "DN" ); + rc = dodelete( ld, conv, ldaptool_request_ctrls ); + if( conv != NULL ) + free( conv ); + } + } else { + while ((rc == 0 || contoper) && + fgets(buf, sizeof(buf), ldaptool_fp) != NULL) { + buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */ + if ( *buf != '\0' ) { + rc = dodelete( ld, buf, ldaptool_request_ctrls ); + } + } + } + + ldaptool_reset_control_array( ldaptool_request_ctrls ); + ldaptool_cleanup( ld ); + + /* check for and report output error */ + fflush( stdout ); + rc = ldaptool_check_ferror( stdout, rc, "output error (output might be incomplete)" ); + return( rc ); +} + +/*ARGSUSED1*/ +static void +options_callback( int option, char *optarg ) +{ + switch( option ) { + case 'c': /* continuous operation mode */ + ++contoper; + break; + default: + usage(); + } +} + + +static int +dodelete( LDAP *ld, char *dn, LDAPControl **serverctrls ) +{ + int rc; + + if ( ldaptool_verbose ) { + printf( "%sdeleting entry %s\n", ldaptool_not ? "!" : "", dn ); + } + if ( ldaptool_not ) { + rc = LDAP_SUCCESS; + } else if (( rc = ldaptool_delete_ext_s( ld, dn, serverctrls, NULL, + "ldap_delete" )) == LDAP_SUCCESS && ldaptool_verbose ) { + printf( "entry removed\n" ); + } + + return( rc ); +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ldapmodify.c
Added
@@ -0,0 +1,1049 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldapmodify.c - generic program to modify or add entries using LDAP */ + +#include "ldaptool.h" +#include "fileurl.h" + +static int newval, contoper, force, valsfromfiles, display_binary_values; +static int ldif_version = -1; /* -1 => unknown version */ +static LDAP *ld; +static char *rejfile = NULL; +static char *bulkimport_suffix = NULL; +static int ldapmodify_quiet = 0; + +#define LDAPMOD_MAXLINE 4096 + +/* strings found in replog/LDIF entries (mostly lifted from slurpd/slurp.h) */ +#define T_REPLICA_STR "replica" +#define T_DN_STR "dn" +#define T_VERSION_STR "version" +#define T_CHANGETYPESTR "changetype" +#define T_ADDCTSTR "add" +#define T_MODIFYCTSTR "modify" +#define T_DELETECTSTR "delete" +#define T_RENAMECTSTR "rename" /* non-standard */ +#define T_MODDNCTSTR "moddn" +#define T_MODRDNCTSTR "modrdn" +#define T_MODOPADDSTR "add" +#define T_MODOPREPLACESTR "replace" +#define T_MODOPDELETESTR "delete" +#define T_MODSEPSTR "-" +#define T_NEWRDNSTR "newrdn" +#define T_NEWSUPERIORSTR "newsuperior" +#define T_NEWPARENTSTR "newparent" +#define T_DELETEOLDRDNSTR "deleteoldrdn" +#define T_NEWSUPERIORSTR "newsuperior" +#define T_NEWPARENTSTR "newparent" /* non-standard */ + +/* bulk import */ +#define BULKIMPORT_START_OID "2.16.840.1.113730.3.5.7" +#define BULKIMPORT_STOP_OID "2.16.840.1.113730.3.5.8" + +static void options_callback( int option, char *optarg ); +static int process_ldapmod_rec( char *rbuf ); +static int process_ldif_rec( char *rbuf ); +static void addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, + char *value, int vlen ); +static int domodify( char *dn, LDAPMod **pmods, int newentry ); +static int dodelete( char *dn ); +static int dorename( char *dn, char *newrdn, char *newparent, + int deleteoldrdn ); +static void freepmods( LDAPMod **pmods ); +static char *read_one_record( FILE *fp ); +static char *strdup_and_trim( char *s ); + +static void +usage( void ) +{ + fprintf( stderr, "usage: %s [options]\n", ldaptool_progname ); + fprintf( stderr, "options:\n" ); + ldaptool_common_usage( 0 ); + fprintf( stderr, " -c\t\tcontinuous mode (do not stop on errors)\n" ); + fprintf( stderr, " -A\t\tdisplay non-ASCII values in conjunction with -v\n" ); + fprintf( stderr, " -f file\tread modifications from file (default: standard input)\n" ); + if ( strcmp( ldaptool_progname, "ldapmodify" ) == 0 ){ + fprintf( stderr, " -a\t\tadd entries\n" ); + } + fprintf( stderr, " -b\t\tread values that start with / from files (for bin attrs)\n" ); + fprintf( stderr, " -F\t\tforce application of all changes, regardless of\n" ); + fprintf( stderr, " \t\treplica lines\n" ); + fprintf( stderr, " -e rejfile\tsave rejected entries in \"rejfile\"\n" ); + fprintf( stderr, " -B suffix\tbulk import to \"suffix\"\n"); + fprintf( stderr, " -q\t\tbe quiet when adding/modifying entries\n" ); + exit( LDAP_PARAM_ERROR ); +} + + +int +main( int argc, char **argv ) +{ + char *rbuf, *saved_rbuf, *start, *p, *q; + FILE *rfp = NULL; + int rc, use_ldif, deref, optind; + LDAPControl *ldctrl; + + +#ifdef notdef +#ifdef HPUX11 +#ifndef __LP64__ + _main( argc, argv); +#endif /* __LP64_ */ +#endif /* HPUX11 */ +#endif + + valsfromfiles = display_binary_values = 0; + + optind = ldaptool_process_args( argc, argv, "aAbcFe:B:q", 0, + options_callback ); + + + if ( optind == -1 ) { + usage(); + } + + if ( !newval && strcmp( ldaptool_progname, "ldapadd" ) == 0 ) { + newval = 1; + } + + if ( ldaptool_fp == NULL ) { + ldaptool_fp = stdin; + } + + if ( argc - optind != 0 ) { + usage(); + } + + ld = ldaptool_ldap_init( 0 ); + + if ( !ldaptool_not ) { + deref = LDAP_DEREF_NEVER; /* this seems prudent */ + ldap_set_option( ld, LDAP_OPT_DEREF, &deref ); + } + + ldaptool_bind( ld ); + + if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) { + ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); + } + + if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) { + ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls); + } + + rc = 0; + + /* turn on bulk import?*/ + if (bulkimport_suffix) { + struct berval bv, *retdata; + char *retoid; + + bv.bv_val = bulkimport_suffix; + bv.bv_len = strlen(bulkimport_suffix); + if ((rc = ldap_extended_operation_s(ld, + BULKIMPORT_START_OID, &bv, NULL, + NULL, &retoid, &retdata)) != 0) { + fprintf(stderr, "Error: unable to service " + "extended operation request\n\t'%s' for " + "bulk import\n\t(error:%d:'%s')\n", + BULKIMPORT_START_OID, rc, ldap_err2string(rc)); + return (rc); + } + if (retoid) + ldap_memfree(retoid); + if (retdata) + ber_bvfree(retdata); + } + + while (( rc == 0 || contoper ) && + ( rbuf = read_one_record( ldaptool_fp )) != NULL ) { + /* + * we assume record is ldif/slapd.replog if the first line + * has a colon that appears to the left of any equal signs, OR + * if the first line consists entirely of digits (an entry id) + */ + use_ldif = ( p = strchr( rbuf, ':' )) != NULL && + ( q = strchr( rbuf, '\n' )) != NULL && p < q && + (( q = strchr( rbuf, '=' )) == NULL || p < q ); + + start = rbuf; + saved_rbuf = strdup( rbuf ); + + if ( !use_ldif && ( q = strchr( rbuf, '\n' )) != NULL ) { + for ( p = rbuf; p < q; ++p ) { + if ( !isdigit( *p )) { + break; + } + } + if ( p >= q ) { + use_ldif = 1; + start = q + 1; + } + } + + if ( use_ldif ) { + rc = process_ldif_rec( start ); + } else { + rc = process_ldapmod_rec( start ); + } + if ( rc != LDAP_SUCCESS && rejfile != NULL ) { + /* Write this record to the reject file */ + int newfile = 0; + struct stat stbuf; + if ( stat( rejfile, &stbuf ) < 0 ) { + if ( errno == ENOENT ) { + newfile = 1; + } + } + if (( rfp = ldaptool_open_file( rejfile, "a" )) == NULL ) { + fprintf( stderr, "Cannot open error file \"%s\" - " + "erroneous entries will not be saved\n", rejfile ); + rejfile = NULL; + } else { + if ( newfile == 0 ) { + fputs( "\n", rfp ); + } + fprintf( rfp, "# Error: %s\n", ldap_err2string( rc )); + fputs( saved_rbuf, rfp ); + fclose( rfp ); + rfp = NULL; + } + } + + free( rbuf ); + free( saved_rbuf ); + } + ldaptool_reset_control_array( ldaptool_request_ctrls ); + + /* turn off bulk import?*/ + if (bulkimport_suffix) { + struct berval bv, *retdata; + char *retoid; + + bv.bv_val = ""; + bv.bv_len = 0; + if ((rc = ldap_extended_operation_s(ld, + BULKIMPORT_STOP_OID, &bv, NULL, + NULL, &retoid, &retdata)) != 0) { + + fprintf(stderr, "Error: unable to service " + "extended operation request\n\t '%s' for " + "bulk import\n\t(rc:%d:'%s')\n", + BULKIMPORT_STOP_OID, rc, ldap_err2string(rc)); + return (rc); + } + if (retoid) + ldap_memfree(retoid); + if (retdata) + ber_bvfree(retdata); + } + + ldaptool_cleanup( ld ); + + /* check for and report output error */ + fflush( stdout ); + rc = ldaptool_check_ferror( stdout, rc, "output error (output might be incomplete)" ); + return( rc ); +} + + +static void +options_callback( int option, char *optarg ) +{ + switch( option ) { + case 'a': /* add */ + newval = 1; + break; + case 'b': /* read values from files (for binary attributes) */ + valsfromfiles = 1; + break; + case 'A': /* display non-ASCII values when -v is used */ + display_binary_values = 1; + break; + case 'c': /* continuous operation */ + contoper = 1; + break; + case 'F': /* force all changes records to be used */ + force = 1; + break; + case 'e': + rejfile = strdup( optarg ); + break; + case 'B': /* bulk import option */ + bulkimport_suffix = strdup( optarg ); + break; + case 'q': /* quiet mode on add/modify operations */ + ldapmodify_quiet = 1; + break; + default: + usage(); + } +} + + + +static int +process_ldif_rec( char *rbuf ) +{ + char *line, *dn, *type, *value, *newrdn, *newparent, *p; + char *ctrl_oid=NULL, *ctrl_value=NULL; + int ctrl_criticality=1; + LDAPControl *ldctrl; + int rc, linenum, vlen, modop, replicaport; + int expect_modop, expect_sep, expect_chgtype_or_control, expect_newrdn; + int expect_deleteoldrdn, expect_newparent, rename, moddn; + int deleteoldrdn, saw_replica, use_record, new_entry, delete_entry; + int got_all, got_value; + LDAPMod **pmods; + + new_entry = newval; + + rc = got_all = saw_replica = delete_entry = expect_modop = 0; + expect_deleteoldrdn = expect_newrdn = expect_newparent = expect_sep = 0; + expect_chgtype_or_control = linenum = got_value = rename = moddn = 0; + deleteoldrdn = 1; + use_record = force; + pmods = NULL; + dn = newrdn = newparent = value = NULL; + modop = -1; /* invalid value */ + + while ( rc == 0 && ( line = ldif_getline( &rbuf )) != NULL ) { + ++linenum; + if ( expect_sep && strcasecmp( line, T_MODSEPSTR ) == 0 ) { + expect_sep = 0; + expect_modop = 1; + + /*If we see a separator in the input stream, + but we didn't get a value from the last modify + then we have to fill pmods with an empty value*/ + if (modop == LDAP_MOD_REPLACE && !got_value){ + addmodifyop( &pmods, modop, value, NULL, 0); + } + + got_value = 0; + continue; + } + + if ( ldif_parse_line( line, &type, &value, &vlen ) < 0 ) { + fprintf( stderr, "%s: invalid format (line %d of entry: %s)\n", + ldaptool_progname, linenum, dn == NULL ? "" : dn ); + fprintf( stderr, "%s: line contents: (%s)\n", + ldaptool_progname, line ); + rc = LDAP_PARAM_ERROR; + break; + } + +evaluate_line: + if ( dn == NULL ) { + if ( !use_record && strcasecmp( type, T_REPLICA_STR ) == 0 ) { + ++saw_replica; + if (( p = strchr( value, ':' )) == NULL ) { + replicaport = LDAP_PORT; + } else { + *p++ = '\0'; + replicaport = atoi( p ); + } + if ( strcasecmp( value, ldaptool_host ) == 0 && + replicaport == ldaptool_port ) { + use_record = 1; + } + + } else if ( strcasecmp( type, T_DN_STR ) == 0 ) { + if (( dn = strdup( value )) == NULL ) { + perror( "strdup" ); + exit( LDAP_NO_MEMORY ); + } + expect_chgtype_or_control = 1; + + } else if ( strcasecmp( type, T_VERSION_STR ) == 0 ) { + ldif_version = atoi( value ); + if ( ldif_version != LDIF_VERSION_ONE ) { + fprintf( stderr, "%s: LDIF version %d is not supported;" + " use version: %d\n", ldaptool_progname, ldif_version, + LDIF_VERSION_ONE ); + exit( LDAP_PARAM_ERROR ); + } + if ( ldaptool_verbose ) { + printf( "Processing a version %d LDIF file...\n", + ldif_version ); + } + + /* Now check if there's something left to process */ + /* and if not, go get the new record, else continue */ + if ( *rbuf == '\0' ) { + return( 0 ); + } + + } else if ( !saw_replica ) { + printf( "%s: skipping change record: no dn: line\n", + ldaptool_progname ); + return( 0 ); + } + + continue; /* skip all lines until we see "dn:" */ + } + + if ( expect_chgtype_or_control ) { + expect_chgtype_or_control = 0; + if ( !use_record && saw_replica ) { + printf( "%s: skipping change record for entry: %s\n\t(LDAP host/port does not match replica: lines)\n", + ldaptool_progname, dn ); + free( dn ); + return( 0 ); + } + + if ( strcasecmp( type, "control" ) == 0 ) { + value = strdup_and_trim( value ); + if (ldaptool_parse_ctrl_arg(value, ' ', &ctrl_oid, + &ctrl_criticality, &ctrl_value, &vlen)) { + usage(); + } + ldctrl = calloc(1,sizeof(LDAPControl)); + if (ctrl_value) { + rc = ldaptool_berval_from_ldif_value( ctrl_value, vlen, + &(ldctrl->ldctl_value), + 1 /* recognize file URLs */, 0 /* always try file */, + 1 /* report errors */ ); + if ((rc = ldaptool_fileurlerr2ldaperr( rc )) != LDAP_SUCCESS) { + fprintf( stderr, "Unable to parse %s\n", ctrl_value); + usage(); + } + } + ldctrl->ldctl_oid = ctrl_oid; + ldctrl->ldctl_iscritical = ctrl_criticality; + ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); + expect_chgtype_or_control = 1; + continue; + } + + if ( strcasecmp( type, T_CHANGETYPESTR ) == 0 ) { + value = strdup_and_trim( value ); + if ( strcasecmp( value, T_MODIFYCTSTR ) == 0 ) { + new_entry = 0; + expect_modop = 1; + } else if ( strcasecmp( value, T_ADDCTSTR ) == 0 ) { + new_entry = 1; + modop = LDAP_MOD_ADD; + } else if ( strcasecmp( value, T_MODRDNCTSTR ) == 0 ) { + expect_newrdn = 1; + moddn = 1; + } else if ( strcasecmp( value, T_MODDNCTSTR ) == 0 ) { + expect_newrdn = 1; + moddn = 1; + } else if ( strcasecmp( value, T_RENAMECTSTR ) == 0 ) { + expect_newrdn = 1; + rename = 1; + } else if ( strcasecmp( value, T_DELETECTSTR ) == 0 ) { + got_all = delete_entry = 1; + } else { + fprintf( stderr, + "%s: unknown %s \"%s\" (line %d of entry: %s)\n", + ldaptool_progname, T_CHANGETYPESTR, value, + linenum, dn ); + rc = LDAP_PARAM_ERROR; + } + free( value ); + continue; + } else if ( newval ) { /* missing changetype => add */ + new_entry = 1; + modop = LDAP_MOD_ADD; + } else { + /*The user MUST put in changetype: blah + unless adding a new entry with either -a or ldapadd*/ + fprintf(stderr, "%s: Missing changetype operation specification.\n\tThe dn line must be followed by \"changetype: operation\"\n\t(unless ldapmodify is called with -a option)\n\twhere operation is add|delete|modify|modrdn|moddn|rename\n\t\"%s\" is not a valid changetype operation specification\n\t(line %d of entry %s)\n", + ldaptool_progname, type, linenum, dn); + rc = LDAP_PARAM_ERROR; + /*expect_modop = 1; missing changetype => modify */ + } + } + + if ( expect_modop ) { + expect_modop = 0; + expect_sep = 1; + if ( strcasecmp( type, T_MODOPADDSTR ) == 0 ) { + modop = LDAP_MOD_ADD; + continue; + } else if ( strcasecmp( type, T_MODOPREPLACESTR ) == 0 ) { + modop = LDAP_MOD_REPLACE; + continue; + } else if ( strcasecmp( type, T_MODOPDELETESTR ) == 0 ) { + modop = LDAP_MOD_DELETE; + addmodifyop( &pmods, modop, value, NULL, 0 ); + continue; + } else { /*Bug 27479. Remove default add operation*/ + fprintf(stderr, "%s: Invalid parameter \"%s\" specified for changetype modify (line %d of entry %s)\n", + ldaptool_progname, type, linenum, dn); + rc = LDAP_PARAM_ERROR; + } + + } + + if ( expect_newrdn ) { + if ( strcasecmp( type, T_NEWRDNSTR ) == 0 ) { + if ( *value == '\0' ) { + fprintf( stderr, + "%s: newrdn value missing (line %d of entry: %s)\n", + ldaptool_progname, linenum, dn == NULL ? "" : dn ); + rc = LDAP_PARAM_ERROR; + } else if (( newrdn = strdup( value )) == NULL ) { + perror( "strdup" ); + exit( LDAP_NO_MEMORY ); + } else { + expect_newrdn = 0; + if ( rename ) { + expect_newparent = 1; + } else { + expect_deleteoldrdn = 1; + } + } + } else { + fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry %s)\n", + ldaptool_progname, T_NEWRDNSTR, type, linenum, dn ); + rc = LDAP_PARAM_ERROR; + } + } else if ( expect_newparent ) { + expect_newparent = 0; + if ( rename ) { + expect_deleteoldrdn = 1; + } + if ( strcasecmp( type, T_NEWPARENTSTR ) == 0 + || strcasecmp( type, T_NEWSUPERIORSTR ) == 0 ) { + if (( newparent = strdup( value )) == NULL ) { + perror( "strdup" ); + exit( LDAP_NO_MEMORY ); + } + } else { + /* Since this is an optional argument for rename/moddn, cause + * the current line to be re-evaluated if newparent doesn't + * follow deleteoldrdn. + */ + newparent = NULL; + goto evaluate_line; + } + } else if ( expect_deleteoldrdn ) { + if ( strcasecmp( type, T_DELETEOLDRDNSTR ) == 0 ) { + if ( *value == '\0' ) { + fprintf( stderr, + "%s: missing 0 or 1 (line %d of entry: %s)\n", + ldaptool_progname, linenum, dn == NULL ? "" : dn ); + rc = LDAP_PARAM_ERROR; + } else { + deleteoldrdn = ( *value == '0' ) ? 0 : 1; + expect_deleteoldrdn = 0; + if ( moddn ) { + expect_newparent = 1; + } + } + } else { + fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry %s)\n", + ldaptool_progname, T_DELETEOLDRDNSTR, type, linenum, + dn ); + rc = LDAP_PARAM_ERROR; + } + got_all = 1; + } else if ( got_all ) { + fprintf( stderr, + "%s: extra lines at end (line %d of entry %s)\n", + ldaptool_progname, linenum, dn ); + rc = LDAP_PARAM_ERROR; + got_all = 1; + } else { + addmodifyop( &pmods, modop, type, value, vlen ); + /*There was a value to replace*/ + got_value = 1; + + } + } + + if ( rc == 0 ) { + if ( delete_entry ) { + rc = dodelete( dn ); + } else if ( newrdn != NULL ) { + rc = dorename( dn, newrdn, newparent, deleteoldrdn ); + rename = 0; + } else { + + /*Patch to fix Bug 22183 + If pmods is null, then there is no + attribute to replace, so we alloc + an empty pmods*/ + if (modop == LDAP_MOD_REPLACE && !got_value && expect_sep){ + addmodifyop( &pmods, modop, value, NULL, 0); + }/*End Patch*/ + + + rc = domodify( dn, pmods, new_entry ); + } + + if ( rc == LDAP_SUCCESS ) { + rc = 0; + } + } + + if ( dn != NULL ) { + free( dn ); + } + if ( newrdn != NULL ) { + free( newrdn ); + } + if ( newparent != NULL ) { + free( newparent ); + } + if ( pmods != NULL ) { + freepmods( pmods ); + } + + return( rc ); +} + + +static int +process_ldapmod_rec( char *rbuf ) +{ + char *line, *dn, *p, *q, *attr, *value; + int rc, linenum; + LDAPMod **pmods; + + pmods = NULL; + dn = NULL; + linenum = 0; + line = rbuf; + rc = 0; + + while ( rc == 0 && rbuf != NULL && *rbuf != '\0' ) { + ++linenum; + if (( p = strchr( rbuf, '\n' )) == NULL ) { + rbuf = NULL; + } else { + if ( *(p-1) == '\\' ) { /* lines ending in '\' are continued */ + strcpy( p - 1, p ); + rbuf = p; + continue; + } + *p++ = '\0'; + rbuf = p; + } + + if ( dn == NULL ) { /* first line contains DN */ + if (( dn = strdup( line )) == NULL ) { + perror( "strdup" ); + exit( LDAP_NO_MEMORY ); + } + } else { + if (( p = strchr( line, '=' )) == NULL ) { + value = NULL; + p = line + strlen( line ); + } else { + *p++ = '\0'; + value = p; + } + + for ( attr = line; *attr != '\0' && isspace( *attr ); ++attr ) { + ; /* skip attribute leading white space */ + } + + for ( q = p - 1; q > attr && isspace( *q ); --q ) { + *q = '\0'; /* remove attribute trailing white space */ + } + + if ( value != NULL ) { + while ( isspace( *value )) { + ++value; /* skip value leading white space */ + } + for ( q = value + strlen( value ) - 1; q > value && + isspace( *q ); --q ) { + *q = '\0'; /* remove value trailing white space */ + } + if ( *value == '\0' ) { + value = NULL; + } + + } + + if ( value == NULL && newval ) { + fprintf( stderr, "%s: missing value on line %d (attr is %s)\n", + ldaptool_progname, linenum, attr ); + rc = LDAP_PARAM_ERROR; + } else { + int modop = -1; /* an invalid value */ + switch ( *attr ) { + case '-': + modop = LDAP_MOD_DELETE; + ++attr; + break; + case '+': + modop = LDAP_MOD_ADD; + ++attr; + break; + default: + /*Bug 27479. Remove the add default*/ + fprintf(stderr, "%s: Invalid parameter specified for changetype modify (line %d of entry %s)\n", + ldaptool_progname, linenum, dn); + rc = LDAP_PARAM_ERROR; + } + + if ( rc == 0 && modop != -1 ) { + addmodifyop( &pmods, modop, attr, value, + ( value == NULL ) ? 0 : strlen( value )); + } + } + } + + line = rbuf; + } + + if ( rc == 0 ) { + if ( dn == NULL ) { + rc = LDAP_PARAM_ERROR; + } else if (( rc = domodify( dn, pmods, newval )) == LDAP_SUCCESS ){ + rc = 0; + } + } + + if ( pmods != NULL ) { + freepmods( pmods ); + } + if ( dn != NULL ) { + free( dn ); + } + + return( rc ); +} + + +static void +addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen ) +{ + LDAPMod **pmods; + int i, j, rc; + struct berval *bvp; + + pmods = *pmodsp; + modop |= LDAP_MOD_BVALUES; + + i = 0; + if ( pmods != NULL ) { + for ( ; pmods[ i ] != NULL; ++i ) { + if ( strcasecmp( pmods[ i ]->mod_type, attr ) == 0 && + pmods[ i ]->mod_op == modop ) { + break; + } + } + } + + if ( pmods == NULL || pmods[ i ] == NULL ) { + if (( pmods = (LDAPMod **)LDAPTOOL_SAFEREALLOC( pmods, (i + 2) * + sizeof( LDAPMod * ))) == NULL ) { + perror( "realloc" ); + exit( LDAP_NO_MEMORY ); + } + *pmodsp = pmods; + pmods[ i + 1 ] = NULL; + if (( pmods[ i ] = (LDAPMod *)calloc( 1, sizeof( LDAPMod ))) + == NULL ) { + perror( "calloc" ); + exit( LDAP_NO_MEMORY ); + } + pmods[ i ]->mod_op = modop; + if (( pmods[ i ]->mod_type = strdup( attr )) == NULL ) { + perror( "strdup" ); + exit( LDAP_NO_MEMORY ); + } + } + + if ( value != NULL ) { + j = 0; + if ( pmods[ i ]->mod_bvalues != NULL ) { + for ( ; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) { + ; + } + } + if (( pmods[ i ]->mod_bvalues = (struct berval **) + LDAPTOOL_SAFEREALLOC( pmods[ i ]->mod_bvalues, + (j + 2) * sizeof( struct berval * ))) == NULL ) { + perror( "realloc" ); + exit( LDAP_NO_MEMORY ); + } + pmods[ i ]->mod_bvalues[ j + 1 ] = NULL; + if (( bvp = (struct berval *)malloc( sizeof( struct berval ))) + == NULL ) { + perror( "malloc" ); + exit( LDAP_NO_MEMORY ); + } + pmods[ i ]->mod_bvalues[ j ] = bvp; + + rc = ldaptool_berval_from_ldif_value( value, vlen, bvp, + ( ldif_version >= LDIF_VERSION_ONE ), valsfromfiles, + 1 /* report errors */ ); + if ( rc != LDAPTOOL_FILEURL_SUCCESS ) { + exit( ldaptool_fileurlerr2ldaperr( rc )); + } + } +} + + +static int +domodify( char *dn, LDAPMod **pmods, int newentry ) +{ + int i, j, notascii, op; + struct berval *bvp; + + if ( pmods == NULL ) { + fprintf( stderr, "%s: no attributes to change or add (entry %s)\n", + ldaptool_progname, dn ); + return( LDAP_PARAM_ERROR ); + } + + if ( ldaptool_verbose ) { + for ( i = 0; pmods[ i ] != NULL; ++i ) { + op = pmods[ i ]->mod_op & ~LDAP_MOD_BVALUES; + printf( "%s %s:\n", op == LDAP_MOD_REPLACE ? + "replace" : op == LDAP_MOD_ADD ? + "add" : "delete", pmods[ i ]->mod_type ); + if ( pmods[ i ]->mod_bvalues != NULL ) { + for ( j = 0; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) { + bvp = pmods[ i ]->mod_bvalues[ j ]; + notascii = 0; + if ( !display_binary_values ) { + notascii = !ldaptool_berval_is_ascii( bvp ); + } + if ( notascii ) { + printf( "\tNOT ASCII (%d bytes)\n", bvp->bv_len ); + } else { + printf( "\t%s\n", bvp->bv_val ); + } + } + } + } + } + + if ( !ldapmodify_quiet) { + if ( newentry ) { + printf( "%sadding new entry %s\n", + ldaptool_not ? "!" : "", dn ); + } else { + printf( "%smodifying entry %s\n", + ldaptool_not ? "!" : "", dn ); + } + } + + if ( !ldaptool_not ) { + if ( newentry ) { + unsigned int sleep_interval = 2; /* seconds */ + + while ((i = ldaptool_add_ext_s( ld, dn, pmods, + ldaptool_request_ctrls, NULL, "ldap_add" )) + == LDAP_BUSY) { + if ( sleep_interval > 3600 ) { + printf("ldap_add: Unable to complete request. "); + printf("Server is too "); + printf("busy servicing other requests\n"); + break; + } + if ( !ldapmodify_quiet ) { + printf("ldap_add: LDAP_BUSY returned by server. "); + printf("Will retry operation "); + printf("in %d seconds\n", sleep_interval); + } + sleep( sleep_interval ); + sleep_interval *= 2; + } + } else { + i = ldaptool_modify_ext_s( ld, dn, pmods, ldaptool_request_ctrls, + NULL, "ldap_modify" ); + } + if ( i == LDAP_SUCCESS && ldaptool_verbose ) { + printf( "modify complete\n" ); + } + } else { + i = LDAP_SUCCESS; + } + + if ( !ldapmodify_quiet) { + putchar( '\n' ); + } + + return( i ); +} + + +static int +dodelete( char *dn ) +{ + int rc; + + printf( "%sdeleting entry %s\n", ldaptool_not ? "!" : "", dn ); + if ( !ldaptool_not ) { + if (( rc = ldaptool_delete_ext_s( ld, dn, ldaptool_request_ctrls, + NULL, "ldap_delete" )) == LDAP_SUCCESS && ldaptool_verbose ) { + printf( "delete complete" ); + } + } else { + rc = LDAP_SUCCESS; + } + + putchar( '\n' ); + + return( rc ); +} + + +static int +dorename( char *dn, char *newrdn, char *newparent, int deleteoldrdn ) +{ + int rc; + + if ( ldaptool_verbose ) { + if ( newparent == NULL ) { + printf( "new RDN: %s (%skeep existing values)\n", + newrdn, deleteoldrdn ? "do not " : "" ); + } else { + printf( "new RDN: %s, new parent %s (%skeep existing values)\n", + newrdn, newparent, deleteoldrdn ? "do not " : "" ); + } + } + + printf( "%smodifying RDN of entry %s%s\n", + ldaptool_not ? "!" : "", dn, ( newparent == NULL ) ? "" : + " and/or moving it beneath a new parent\n" ); + + if ( !ldaptool_not ) { + if (( rc = ldaptool_rename_s( ld, dn, newrdn, newparent, deleteoldrdn, + ldaptool_request_ctrls, NULL, "ldap_rename" )) == LDAP_SUCCESS + && ldaptool_verbose ) { + printf( "rename completed\n" ); + } + } else { + rc = LDAP_SUCCESS; + } + + putchar( '\n' ); + + return( rc ); +} + + +static void +freepmods( LDAPMod **pmods ) +{ + int i; + + for ( i = 0; pmods[ i ] != NULL; ++i ) { + if ( pmods[ i ]->mod_bvalues != NULL ) { + ber_bvecfree( pmods[ i ]->mod_bvalues ); + } + if ( pmods[ i ]->mod_type != NULL ) { + free( pmods[ i ]->mod_type ); + } + free( pmods[ i ] ); + } + free( pmods ); +} + + +static char * +read_one_record( FILE *fp ) +{ + int len, gotnothing; + char *buf, line[ LDAPMOD_MAXLINE ]; + int lcur, lmax; + + lcur = lmax = 0; + buf = NULL; + gotnothing = 1; + + while ( fgets( line, sizeof(line), fp ) != NULL ) { + if ( (len = strlen( line )) < 2 ) { + if ( gotnothing ) { + continue; + } else { + break; + } + } + + /* Check if the blank line starts with '\r' (CR) */ + if ( ((len = strlen( line )) == 2) && (line[0] == '\r') ) { + if ( gotnothing ) { + continue; + } else { + break; + } + } + + if ( *line == '#' ) { + continue; /* skip comment lines */ + } + + gotnothing = 0; + if ( lcur + len + 1 > lmax ) { + lmax = LDAPMOD_MAXLINE + * (( lcur + len + 1 ) / LDAPMOD_MAXLINE + 1 ); + if (( buf = (char *)LDAPTOOL_SAFEREALLOC( buf, lmax )) == NULL ) { + perror( "realloc" ); + exit( LDAP_NO_MEMORY ); + } + } + strcpy( buf + lcur, line ); + lcur += len; + } + + return( buf ); +} + + +/* + * strdup and trim trailing blanks + */ +static char * +strdup_and_trim( char *s ) +{ + char *p; + + if (( s = strdup( s )) == NULL ) { + perror( "strdup" ); + exit( LDAP_NO_MEMORY ); + } + + p = s + strlen( s ) - 1; + while ( p >= s && isspace( *p )) { + --p; + } + *++p = '\0'; + + return( s ); +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ldapmodrdn.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/ldapmodrdn.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ldappasswd.c
Added
@@ -0,0 +1,265 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Sun LDAP C SDK. + * + * The Initial Developer of the Original Code is Sun Microsystems, Inc. + * + * Portions created by Sun Microsystems, Inc are Copyright (C) 2005 + * Sun Microsystems, Inc. All Rights Reserved. + * + * Contributor(s): abobrov + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * ldappasswd.c - generic program to change LDAP users password + * by using password modify extended operation. + */ + +#include "ldaptool.h" +#include "fileurl.h" + +static int prompt_old_password = 0; +static int prompt_new_password = 0; +static int is_file_old = 0; +static int is_file_new = 0; +static FILE *old_password_fp = NULL; +static FILE *new_password_fp = NULL; +static char *old_password_string = "Old Password: "; +static char *new_password_string = "New Password: "; +static char *re_new_password_string = "Re-enter new Password: "; +static struct berval genpasswd = { 0, NULL }; +static struct berval oldpasswd = { 0, NULL }; +static struct berval newpasswd = { 0, NULL }; +static struct berval userid = { 0, NULL }; + +static void usage( void ); +static void options_callback( int option, char *optarg ); + +static void +usage( void ) +{ + fprintf( stderr, "usage: %s [options] [user]\n", ldaptool_progname ); + fprintf( stderr, "where:\n" ); + fprintf( stderr, " user\tauthentication id\n" ); + fprintf( stderr, " \te.g, uid=bjensen,dc=example,dc=com\n" ); + fprintf( stderr, "options:\n" ); + ldaptool_common_usage( 0 ); + fprintf( stderr, " -a passwd\told password\n" ); + fprintf( stderr, " -A\t\tprompt for old password\n" ); + fprintf( stderr, " -t file\tread old password from 'file'\n" ); + fprintf( stderr, " -s passwd\tnew password\n" ); + fprintf( stderr, " -S\t\tprompt for new password\n" ); + fprintf( stderr, " -T file\tread new password from 'file'\n" ); + exit( LDAP_PARAM_ERROR ); +} + +int +main( int argc, char **argv ) +{ + int optind; + int rc = LDAP_SUCCESS; /* being superoptimistic for -n */ + LDAP *ld; + LDAPControl *ldctrl; + +#ifdef notdef +#ifdef HPUX11 +#ifndef __LP64__ + _main( argc, argv); +#endif /* __LP64_ */ +#endif /* HPUX11 */ +#endif + + optind = ldaptool_process_args( argc, argv, "ASa:t:s:T:", 0, options_callback ); + + if ( (optind == -1) || (argc <= 1) ) { + usage(); + } + if ( (argc - optind) >= 1 ) { + if ( argv[ optind ] ) { + if ( (userid.bv_val = ldaptool_local2UTF8(argv[ optind ], "userid") ) == NULL ) { + fprintf( stderr, "%s: not enough memory\n", ldaptool_progname ); + exit( LDAP_NO_MEMORY ); + } + userid.bv_len = strlen( userid.bv_val ); + ++optind; + } + } + + ld = ldaptool_ldap_init( 0 ); + ldaptool_bind( ld ); + + if ( ldaptool_nobind && (userid.bv_val == NULL) && (userid.bv_len == 0) ) { + usage(); + } + + if ((ldctrl = ldaptool_create_manage_dsait_control()) != NULL) { + ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); + } + + if ((ldctrl = ldaptool_create_proxyauth_control(ld)) != NULL) { + ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); + } + + if ( !ldaptool_not ) { + rc = ldap_passwd_s( ld, userid.bv_val ? &userid : NULL, + oldpasswd.bv_val ? &oldpasswd : NULL, + newpasswd.bv_val ? &newpasswd : NULL, + &genpasswd, ldaptool_request_ctrls, NULL ); + if ( rc != LDAP_SUCCESS ) { + ldap_perror( ld, ldaptool_progname ); + } else { + fprintf( stderr, "%s: password successfully changed\n", + ldaptool_progname ); + } + + if ( (genpasswd.bv_val != NULL) && (genpasswd.bv_len != 0) ) { + fprintf( stderr, "New password: %s\n", genpasswd.bv_val ); + } + } + + ldaptool_cleanup( ld ); + + /* check for and report output error */ + fflush( stdout ); + rc = ldaptool_check_ferror( stdout, rc, "output error (output might be incomplete)" ); + return( rc ); +} + +static void +options_callback( int option, char *optarg ) +{ + char *old_passwd = NULL; + char *new_passwd = NULL; + char *re_newpasswd = NULL; + + switch( option ) { + case 'a': /* old password */ + old_passwd = strdup( optarg ); + if (NULL == old_passwd) + { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + break; + case 'A': /* prompt old password */ + prompt_old_password = 1; + break; + case 't': /* old password from file */ + if ((old_password_fp = fopen( optarg, "r" )) == NULL ) { + fprintf(stderr, "%s: Unable to open '%s' file\n", + ldaptool_progname, optarg); + exit( LDAP_PARAM_ERROR ); + } + is_file_old = 1; + break; + case 's': /* new password */ + new_passwd = strdup( optarg ); + if (NULL == new_passwd) + { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + break; + case 'S': /* prompt new password */ + prompt_new_password = 1; + break; + case 'T': /* new password from file */ + if ((new_password_fp = fopen( optarg, "r" )) == NULL ) { + fprintf(stderr, "%s: Unable to open '%s' file\n", + ldaptool_progname, optarg); + exit( LDAP_PARAM_ERROR ); + } + is_file_new = 1; + break; + default: + usage(); + break; + } + + if ( (oldpasswd.bv_val == NULL) && (oldpasswd.bv_len == 0) + && (prompt_old_password) ) { + old_passwd = ldaptool_getpass( old_password_string ); + } else if ( (oldpasswd.bv_val == NULL) && (oldpasswd.bv_len == 0) + && (is_file_old) ) { + old_passwd = ldaptool_read_password( old_password_fp ); + } + + if ( old_passwd ) { + if ( !ldaptool_noconv_passwd ) { + oldpasswd.bv_val = ldaptool_local2UTF8( old_passwd, "old password" ); + } else { + oldpasswd.bv_val = strdup( old_passwd ); + } + if (NULL == oldpasswd.bv_val) + { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + oldpasswd.bv_len = strlen( oldpasswd.bv_val ); + } + + if ( (newpasswd.bv_val == NULL) && (newpasswd.bv_len == 0) + && (prompt_new_password) ) { +try_again: + new_passwd = ldaptool_getpass( new_password_string ); + re_newpasswd = ldaptool_getpass( re_new_password_string ); + if ( (NULL == new_passwd) || (NULL == re_newpasswd) ) + { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + if ( (strncmp( new_passwd, re_newpasswd, + strlen( new_passwd ) ) ) ) { + fprintf( stderr, + "%s: They don't match.\n\nPlease try again\n", + ldaptool_progname ); + free( re_newpasswd ); + free( new_passwd ); + re_newpasswd = NULL; + new_passwd = NULL; + goto try_again; + } + } else if ( (newpasswd.bv_val == NULL) && (newpasswd.bv_len == 0) + && (is_file_new) ) { + new_passwd = ldaptool_read_password( new_password_fp ); + } + + if ( new_passwd ) { + if ( !ldaptool_noconv_passwd ) { + newpasswd.bv_val = ldaptool_local2UTF8( new_passwd, "new password" ); + } else { + newpasswd.bv_val = strdup( new_passwd ); + } + if (NULL == newpasswd.bv_val) { + perror("malloc"); + exit( LDAP_NO_MEMORY ); + } + newpasswd.bv_len = strlen( newpasswd.bv_val ); + } + +} +
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ldapsearch.c
Added
@@ -0,0 +1,1306 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldapsearch.c - generic program to search LDAP */ + +#include "ldaptool.h" +#include "fileurl.h" + +#define VLV_PARAM_SEP ':' + +static void usage( void ); +static int dosearch( LDAP *ld, char *base, int scope, char **attrs, + int attrsonly, char *filtpatt, char *value); +static void write_string_attr_value( char *attrname, char *strval, + unsigned long opts ); +#define LDAPTOOL_WRITEVALOPT_SUPPRESS_NAME 0x01 +static void write_ldif_value( char *type, char *value, unsigned long vallen, + unsigned long ldifoptions ); +static void print_entry( LDAP *ld, LDAPMessage *entry, int attrsonly ); +static void options_callback( int option, char *optarg ); +static void parse_and_display_reference( LDAP *ld, LDAPMessage *ref ); +static char *sortresult2string(ber_int_t result); +static char *changetype_num2string( ber_int_t chgtype ); +static char *msgtype2str( int msgtype ); +static char **get_effectiverights_attrlist(char * optarg); + +/* + * Prefix used in names of pseudo attributes added to the entry LDIF + * output if we receive an entryChangeNotification control with an entry + * (requested using persistent search). + */ +#define LDAPTOOL_PSEARCH_ATTR_PREFIX "persistentSearch-" + + +static void +usage( void ) +{ + fprintf( stderr, "usage: %s -b basedn [options] filter [attributes...]\n", ldaptool_progname ); + fprintf( stderr, " %s -b basedn [options] -f file [attributes...]\nwhere:\n", ldaptool_progname ); + fprintf( stderr, " basedn\tbase dn for search\n" ); + fprintf( stderr, "\t\t(if the environment variable LDAP_BASEDN is set,\n" ); + fprintf( stderr, "\t\tthen the -b flag is not required)\n" ); + fprintf( stderr, " filter\tRFC-2254 compliant LDAP search filter\n" ); + fprintf( stderr, " file\tfile containing a sequence of LDAP search filters to use\n" ); + fprintf( stderr, " attributes\twhitespace-separated list of attributes to retrieve\n" ); + fprintf( stderr, "\t\t(if no attribute list is given, all are retrieved)\n" ); + fprintf( stderr, "options:\n" ); + ldaptool_common_usage( 0 ); +#if defined( XP_WIN32 ) + fprintf( stderr, " -t\t\twrite values to files in temp directory.\n" ); +#else + fprintf( stderr, " -t\t\twrite values to files in /tmp\n" ); +#endif + fprintf( stderr, " -U\t\tproduce file URLs in conjunction with -t\n" ); + fprintf( stderr, " -e\t\tminimize base-64 encoding of values\n" ); + fprintf( stderr, " -u\t\tinclude User Friendly entry names in the output\n" ); + fprintf( stderr, " -r\t\tflush output after each entry is printed (useful with -C)\n" ); + fprintf( stderr, " -T\t\tdon't fold (wrap) long lines (default is to fold)\n" ); + fprintf( stderr, " -1\t\tomit leading \"version: %d\" line in LDIF output\n", LDIF_VERSION_ONE ); + fprintf( stderr, " -A\t\tretrieve attribute names only (no values)\n" ); + fprintf( stderr, " -B\t\tprint non-ASCII values and use old output format (attr=value)\n" ); + fprintf( stderr, " -x\t\tperforming sorting on server\n" ); + fprintf( stderr, " -F sep\tprint `sep' instead of `%s' between attribute names\n", LDAPTOOL_DEFSEP ); + fprintf( stderr, " \tand values in old output format (attr=value)\n" ); + fprintf( stderr, " -S attr\tsort the results by attribute `attr'\n" ); + fprintf( stderr, " -s scope\tone of base, one, or sub (default is sub)\n" ); + fprintf( stderr, " -a deref\tone of never, always, search, or find (default: never)\n" ); + fprintf( stderr, " \t(alias dereferencing)\n" ); + fprintf( stderr, " -l time lim\ttime limit (in seconds) for search (default is no limit)\n" ); + fprintf( stderr, " -z size lim\tsize limit (in entries) for search (default is no limit)\n" ); + fprintf( stderr, " -C PS:changetype[:changesonly[:entrychgcontrols]]\n" ); + fprintf( stderr, "\t\tchangetypes are add,delete,modify,moddn,any\n" ); + fprintf( stderr, "\t\tchangesonly and entrychgcontrols are boolean values\n" ); + fprintf( stderr, "\t\t(default is 1)\n" ); + fprintf( stderr, " -G before%cafter%cindex%ccount | before%cafter%cvalue where 'before' and\n", VLV_PARAM_SEP, VLV_PARAM_SEP, VLV_PARAM_SEP, VLV_PARAM_SEP, VLV_PARAM_SEP ); + fprintf( stderr, "\t\t'after' are the number of entries surrounding 'index.'\n"); + fprintf( stderr, "\t\t'count' is the content count, 'value' is the search value.\n"); + fprintf( stderr, " -c authzid\tspecifies the getEffectiveRights control authzid\n"); + fprintf( stderr, "\t\t eg. dn:uid=bjensen,dc=example,dc=com\n"); + fprintf( stderr, "\t\t A value of \"\" means \"the authorization id for the operation\".\n"); + fprintf( stderr, "\t\t A value of \"dn:\" means \"anonymous\"\n"); + fprintf( stderr, "\t\t (The aclRights operational attribute must be requested)\n"); + fprintf( stderr, " -X attrlist\tspecifies the getEffectiveRights control specific attribute list,\n"); + fprintf( stderr, "\t\t where attributes are space separated eg. \"nsroledn userPassword\"\n"); + + exit( LDAP_PARAM_ERROR ); +} + +static char *base = NULL; +static char *sep = LDAPTOOL_DEFSEP; +static char **sortattr = NULL; +static char *vlv_value = NULL; +static int sortsize = 0; +static int *skipsortattr = NULL; +static int includeufn, allow_binary, vals2tmp, ldif, scope, deref; +static int attrsonly, timelimit, sizelimit, server_sort, fold; +static int minimize_base64, produce_file_urls; +static int use_vlv = 0, vlv_before, vlv_after, vlv_index, vlv_count; +static int use_psearch=0; +static int flush_after_each_entry=0; +static int write_ldif_version = 1; +static char *get_effectiverights_control_target_dn = NULL; /* -c */ +static char **get_effectiverights_control_attrlist = NULL; /* -X */ +static int do_effective_rights_control = 0; + +/* Persistent search variables */ +static int chgtype=0, changesonly=1, return_echg_ctls=1; + + +int +main( int argc, char **argv ) +{ + char *filtpattern = NULL; + int free_filtpattern = 0; + char **attrs; + int rc, optind, i, first; + LDAP *ld; + + deref = LDAP_DEREF_NEVER; + allow_binary = vals2tmp = attrsonly = 0; + minimize_base64 = produce_file_urls = 0; + ldif = 1; + fold = 1; + sizelimit = timelimit = 0; + scope = LDAP_SCOPE_SUBTREE; + server_sort = 0; + +#ifdef notdef +#ifdef HPUX11 +#ifndef __LP64__ + _main( argc, argv); +#endif /* __LP64_ */ +#endif /* HPUX11 */ +#endif + + + ldaptool_reset_control_array( ldaptool_request_ctrls ); +#ifdef HAVE_SASL_OPTIONS +#ifdef HAVE_SASL_OPTIONS_2 + optind = ldaptool_process_args( argc, argv, "ABLTU1eortuxa:b:F:G:l:S:s:z:C:c:X:", + 0, options_callback ); +#else + optind = ldaptool_process_args( argc, argv, "ABLTU1ertuxa:b:F:G:l:S:s:z:C:c:X:", + 0, options_callback ); +#endif +#else + optind = ldaptool_process_args( argc, argv, + "ABLTU1eortuxa:b:F:G:l:S:s:z:C:c:X:", 0, options_callback ); +#endif /* HAVE_SASL_OPTIONS */ + + if ( optind == -1 ) { + usage(); + } + + if ( base == NULL ) { + if (( base = getenv( "LDAP_BASEDN" )) == NULL ) { + usage(); + } + } + if ( sortattr ) { + for ( sortsize = 0; sortattr[sortsize] != NULL; sortsize++ ) { + ; /* NULL */ + } + sortsize++; /* add in the final NULL field */ + skipsortattr = (int *) malloc( sortsize * sizeof(int *) ); + if ( skipsortattr == NULL ) { + fprintf( stderr, "Out of memory\n" ); + exit( LDAP_NO_MEMORY ); + } + memset( (char *) skipsortattr, 0, sortsize * sizeof(int *) ); + } else if ( server_sort ) { + server_sort = 0; /* ignore this option if no sortattrs were given */ + } + + if ( argc - optind < 1 ) { + if ( ldaptool_fp == NULL ) { + usage(); + } + attrs = NULL; + filtpattern = "%s"; + } else { /* there are additional args (filter + attrs) */ + if ( ldaptool_fp == NULL || strstr( argv[ optind ], "%s" ) != NULL ) { + filtpattern = ldaptool_local2UTF8( argv[ optind ], "filter" ); + free_filtpattern = 1; + ++optind; + } else { + filtpattern = "%s"; + } + + if ( argv[ optind ] == NULL ) { + attrs = NULL; + } else if ( sortattr == NULL || *sortattr == '\0' || server_sort) { + attrs = &argv[ optind ]; + } else { + attrs = ldap_charray_dup( &argv[ optind ] ); + if ( attrs == NULL ) { + fprintf( stderr, "Out of memory\n" ); + exit( LDAP_NO_MEMORY ); + } + for ( i = 0; i < (sortsize - 1); i++ ) { + if ( !ldap_charray_inlist( attrs, sortattr[i] ) ) { + if ( ldap_charray_add( &attrs, sortattr[i] ) != 0 ) { + fprintf( stderr, "Out of memory\n" ); + exit( LDAP_NO_MEMORY ); + } + /* + * attribute in the search list only for the purpose of + * sorting + */ + skipsortattr[i] = 1; + } + } + } + } + + ld = ldaptool_ldap_init( 0 ); + + if ( !ldaptool_not ) { + ldap_set_option( ld, LDAP_OPT_DEREF, &deref ); + ldap_set_option( ld, LDAP_OPT_TIMELIMIT, &timelimit ); + ldap_set_option( ld, LDAP_OPT_SIZELIMIT, &sizelimit ); + } + + ldaptool_bind( ld ); + + if ( ldaptool_verbose ) { + printf( "filter pattern: %s\nreturning: ", filtpattern ); + if ( attrs == NULL ) { + printf( "ALL" ); + } else { + for ( i = 0; attrs[ i ] != NULL; ++i ) { + printf( "%s ", attrs[ i ] ); + } + } + putchar( '\n' ); + } + + if ( ldaptool_fp == NULL ) { + char *conv = NULL; + + conv = ldaptool_local2UTF8( base, "base DN" ); + rc = dosearch( ld, conv, scope, attrs, attrsonly, filtpattern, "" ); + if( conv != NULL ) + free( conv ); + } else { + int done = 0; + + rc = LDAP_SUCCESS; + first = 1; + while ( rc == LDAP_SUCCESS && !done ) { + char *linep = NULL; + int increment = 0; + int c, index; + + /* allocate initial block of memory */ + if ((linep = (char *)malloc(BUFSIZ)) == NULL) { + fprintf( stderr, "Out of memory\n" ); + exit( LDAP_NO_MEMORY ); + } + increment++; + index = 0; + while ((c = fgetc( ldaptool_fp )) != '\n' && c != EOF) { + + /* check if we will overflow the buffer */ + if ((c != EOF) && (index == ((increment * BUFSIZ) -1))) { + + /* if we did, add another BUFSIZ worth of bytes */ + if ((linep = (char *) + realloc(linep, (increment + 1) * BUFSIZ)) == NULL) { + fprintf( stderr, "Out of memory\n" ); + exit( LDAP_NO_MEMORY ); + } + increment++; + } + linep[index++] = c; + } + + if (c == EOF) { + done = 1; + break; + } + + linep[index] = '\0'; + + if ( !first ) { + putchar( '\n' ); + } else { + first = 0; + } + rc = dosearch( ld, base, scope, attrs, attrsonly, filtpattern, + linep ); + free (linep); + } + } + + ldaptool_cleanup( ld ); + if ( (free_filtpattern != 0) && (filtpattern != NULL) ) { + free (filtpattern); + } + + + /* check for and report output error */ + fflush( stdout ); + rc = ldaptool_check_ferror( stdout, rc, "output error (output might be incomplete)" ); + return( rc ); +} + + +static void +options_callback( int option, char *optarg ) +{ + char *s, *ps_ptr, *ps_arg; + char *temp_arg = NULL; + + switch( option ) { + case 'u': /* include UFN */ + ++includeufn; + break; + case 't': /* write attribute values to /tmp files */ + ++vals2tmp; + break; + case 'U': /* produce file URLs in conjunction with -t */ + ++produce_file_urls; + break; + case 'e': /* minimize base-64 encoding of values */ + ++minimize_base64; + break; + case 'A': /* retrieve attribute names only -- no values */ + ++attrsonly; + break; + case 'L': /* print entries in LDIF format -- now the default */ + break; + case 'r': /* flush output after each entry is written */ + flush_after_each_entry = 1; + break; + case 'B': /* allow binary values to be printed, use old format */ + ++allow_binary; + ldif = 0; + break; + case '1': /* omit leading "version: #" line from LDIF output */ + write_ldif_version = 0; + break; + case 's': /* search scope */ + if ( strncasecmp( optarg, "base", 4 ) == 0 ) { + scope = LDAP_SCOPE_BASE; + } else if ( strncasecmp( optarg, "one", 3 ) == 0 ) { + scope = LDAP_SCOPE_ONELEVEL; + } else if ( strncasecmp( optarg, "sub", 3 ) == 0 ) { + scope = LDAP_SCOPE_SUBTREE; + } else { + fprintf( stderr, "scope should be base, one, or sub\n" ); + usage(); + } + break; + + case 'a': /* set alias deref option */ + if ( strncasecmp( optarg, "never", 5 ) == 0 ) { + deref = LDAP_DEREF_NEVER; + } else if ( strncasecmp( optarg, "search", 5 ) == 0 ) { + deref = LDAP_DEREF_SEARCHING; + } else if ( strncasecmp( optarg, "find", 4 ) == 0 ) { + deref = LDAP_DEREF_FINDING; + } else if ( strncasecmp( optarg, "always", 6 ) == 0 ) { + deref = LDAP_DEREF_ALWAYS; + } else { + fprintf( stderr, "alias deref should be never, search, find, or always\n" ); + usage(); + } + break; + + case 'F': /* field separator */ + sep = strdup( optarg ); + break; + case 'c': /* getEffectiveRights control authzid */ + if ( optarg && optarg[0] == '\0' ) { + /* -c "" + means "This user" + */ + get_effectiverights_control_target_dn = NULL; + do_effective_rights_control = 1; + }else if ( strlen(optarg) < 3 || (strncasecmp(optarg, "dn:", 3) != 0) ) { + fprintf(stderr,"-c wrong format--should be \"\" or \"dn:...\".\n" + "\"dn:\" means anonymous user."); + usage(); + } else { + get_effectiverights_control_target_dn = strdup(optarg); + do_effective_rights_control = 1; + } + break; + case 'X': /* getEffectiveRights control attr list */ + get_effectiverights_control_attrlist = get_effectiverights_attrlist(optarg); + do_effective_rights_control = 1; + break; + case 'b': /* searchbase */ + base = strdup( optarg ); + break; + case 'l': /* time limit */ + timelimit = atoi( optarg ); + break; + case 'x': /* server sorting requested */ + server_sort = 1; + break; + case 'z': /* size limit */ + sizelimit = atoi( optarg ); + break; + case 'S': /* sort attribute */ + ldap_charray_add( &sortattr, strdup( optarg ) ); + break; + case 'T': /* don't fold lines */ + fold = 0; + break; + case 'G': /* do the virtual list setup */ + use_vlv++; + s = strchr(optarg, VLV_PARAM_SEP ); + + if (s != NULL) + { + vlv_before = atoi(optarg); + s++; + vlv_after = atoi( s ); + s = strchr(s, VLV_PARAM_SEP ); + if (s != NULL) + { + s++; + /* below is a small set of logic to implement the following cases + * -G23:23:wilber + * -G23:23:"wilber:wright" + * -G23:23:'wilber' + * -G23:23:wilber wright + * all of the above are before, after, value - NOTE: a colon not in a quoted + * string will break the parser!!!! + * -G23:23:45:600 + * above is index, count encoding + */ + + if (*s == '\'' || *s == '"') + { + vlv_value = strdup( s ); + } + else + { + if (strchr( s, VLV_PARAM_SEP )) + { + /* we have an index + count option */ + vlv_index = atoi( s ); + vlv_count = atoi( strchr( s, VLV_PARAM_SEP) + 1); + } + else + { + /* we don't have a quote surrounding the assertion value + * do we need to??? + */ + vlv_value = strdup( s ); + } + } + } + else + { + fprintf( stderr,"Illegal 'after' parameter for virtual list\n" ); + exit( LDAP_PARAM_ERROR ); + } + + } + else + { + fprintf( stderr,"Illegal 'before' parameter for virtual list\n" ); + exit( LDAP_PARAM_ERROR ); + } + break; + case 'C': + use_psearch++; + if ( (ps_arg = strdup( optarg)) == NULL ) { + perror ("strdup"); + exit (LDAP_NO_MEMORY); + } + + ps_ptr=strtok(ps_arg, ":"); + if (ps_ptr == NULL || (strcasecmp(ps_ptr, "ps")) ) { + fprintf (stderr, "Invalid argument for -C\n"); + usage(); + } + if (NULL != (ps_ptr=strtok(NULL, ":"))) { + if ( (temp_arg = strdup( ps_ptr )) == NULL ) { + perror ("strdup"); + exit (LDAP_NO_MEMORY); + } + } else { + fprintf (stderr, "Invalid argument for -C\n"); + usage(); + } + if (NULL != (ps_ptr=strtok(NULL, ":"))) { + if ( (changesonly = ldaptool_boolean_str2value(ps_ptr, 0)) == -1) { + fprintf(stderr, "Invalid option value: %s\n", ps_ptr); + usage(); + } + } + if (NULL != (ps_ptr=strtok(NULL, ":"))) { + if ( (return_echg_ctls = ldaptool_boolean_str2value(ps_ptr, 0)) == -1) { + fprintf(stderr, "Invalid option value: %s\n", ps_ptr); + usage(); + } + } + + /* Now parse the temp_arg and build chgtype as + * the changetypes are encountered */ + + if ((ps_ptr = strtok( temp_arg, "," )) == NULL) { + usage(); + } else { + while ( ps_ptr ) { + if ((strcasecmp(ps_ptr, "add"))==0) + chgtype |= LDAP_CHANGETYPE_ADD; + else if ((strcasecmp(ps_ptr, "delete"))==0) + chgtype |= LDAP_CHANGETYPE_DELETE; + else if ((strcasecmp(ps_ptr, "modify"))==0) + chgtype |= LDAP_CHANGETYPE_MODIFY; + else if ((strcasecmp(ps_ptr, "moddn"))==0) + chgtype |= LDAP_CHANGETYPE_MODDN; + else if ((strcasecmp(ps_ptr, "any"))==0) + chgtype = LDAP_CHANGETYPE_ANY; + else { + fprintf(stderr, "Unknown changetype: %s\n", ps_ptr); + usage(); + } + ps_ptr = strtok( NULL, "," ); + } + } + break; + default: + usage(); + break; + } +} + + +static int +dosearch( ld, base, scope, attrs, attrsonly, filtpatt, value ) + LDAP *ld; + char *base; + int scope; + char **attrs; + int attrsonly; + char *filtpatt; + char *value; +{ + char **refs = NULL, filter[ BUFSIZ ], *filterp = NULL; + int rc, first, matches; + LDAPMessage *res, *e; + LDAPControl *ldctrl; + LDAPControl **ctrl_response_array = NULL; + LDAPVirtualList vlv_data; + int msgid = 0; + int length = 0; + int mallocd_filter = 0; + + if ( strstr( filtpatt, "%s" ) == NULL ) { /* no need to sprintf() */ + filterp = filtpatt; + } else { + length = strlen( filtpatt ) + strlen ( value ) +1; + if ( length > BUFSIZ ) { + if ((filterp = (char *) + malloc ( length )) == NULL) { + perror( "filter and/or pattern too long?" ); + exit (LDAP_PARAM_ERROR); + } + mallocd_filter = 1; + } else { + filterp = filter; + } + +#ifdef HAVE_SNPRINTF + if ( snprintf( filterp, length, filtpatt, value ) < 0 ) { + perror( "snprintf filter (filter and/or pattern too long?)" ); + exit( LDAP_PARAM_ERROR ); + } +#else + sprintf( filterp, filtpatt, value ); +#endif + } + + if ( *filterp == '\0' ) { /* treat empty filter is a shortcut for oc=* */ + if (mallocd_filter) { + free(filterp); + mallocd_filter = 0; + } + filterp = "(objectclass=*)"; + } + + if ( ldaptool_verbose ) { + /* + * Display the filter that will be used. Add surrounding parens. + * if they are missing. + */ + if ( '(' == *filterp ) { + printf( "filter is: %s\n", filterp ); + } else { + printf( "filter is: (%s)\n", filterp ); + } + } + + if ( ldaptool_not ) { + if (mallocd_filter) free(filterp); + return( LDAP_SUCCESS ); + } + + if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) { + ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); + } + + if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) { + ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); + } + + if ( do_effective_rights_control ) { + if ((ldctrl = ldaptool_create_geteffectiveRights_control(ld, + get_effectiverights_control_target_dn, + (const char**) get_effectiverights_control_attrlist)) != NULL) { + ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); + } + } + + if (use_psearch) { + if ( ldap_create_persistentsearch_control( ld, chgtype, + changesonly, return_echg_ctls, + 1, &ldctrl ) != LDAP_SUCCESS ) + { + ldap_perror( ld, "ldap_create_persistentsearch_control" ); + return (1); + } + ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); + } + + + if (server_sort) { + /* First make a sort key list from the attribute list we have */ + LDAPsortkey **keylist = NULL; + int i = 0; + char *sortattrs = NULL; + char *s = NULL; + int string_length = 0; + + /* Count the sort strings */ + for (i = 0; i < sortsize - 1 ; i++) { + string_length += strlen(sortattr[i]) + 1; + } + + sortattrs = (char *) malloc(string_length + 1); + if (NULL == sortattrs) { + fprintf( stderr, "Out of memory\n" ); + exit( LDAP_NO_MEMORY ); + } + + s = sortattrs; + for (i = 0; i < sortsize - 1 ; i++) { + memcpy(s, sortattr[i], strlen(sortattr[i])); + s += strlen(sortattr[i]); + *s++ = ' '; + } + + sortattrs[string_length] = '\0'; + + ldap_create_sort_keylist(&keylist,sortattrs); + free(sortattrs); + sortattrs = NULL; + + /* Then make a control for the sort attributes we have */ + rc = ldap_create_sort_control(ld,keylist,0,&ldctrl); + ldap_free_sort_keylist(keylist); + if ( rc != LDAP_SUCCESS ) { + if (mallocd_filter) free(filterp); + return( ldaptool_print_lderror( ld, "ldap_create_sort_control", + LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + + ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); + + } + /* remember server side sorting must be available for vlv!!!! */ + + if (use_vlv) + { + vlv_data.ldvlist_before_count = vlv_before; + vlv_data.ldvlist_after_count = vlv_after; + if ( ldaptool_verbose ) { + printf( "vlv data %d, %d, ", + vlv_data.ldvlist_before_count, + vlv_data.ldvlist_after_count + ); + } + if (vlv_value) + { + vlv_data.ldvlist_attrvalue = vlv_value; + vlv_data.ldvlist_size = 0; + vlv_data.ldvlist_index = 0; + if ( ldaptool_verbose ) { + printf( "%s, 0, 0\n", vlv_data.ldvlist_attrvalue); + } + } + else + { + vlv_data.ldvlist_attrvalue = NULL; + vlv_data.ldvlist_size = vlv_count; + vlv_data.ldvlist_index = vlv_index; + if ( ldaptool_verbose ) { + printf( "(null), %d, %d\n", vlv_data.ldvlist_size, vlv_data.ldvlist_index ); + } + } + + if ( rc != LDAP_SUCCESS ) { + if (mallocd_filter) free(filterp); + return( ldaptool_print_lderror( ld, "ldap_create_sort_control", + LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + if (LDAP_SUCCESS != (rc = ldap_create_virtuallist_control(ld, + &vlv_data, &ldctrl))) + { + if (mallocd_filter) free(filterp); + return( ldaptool_print_lderror( ld, + "ldap_create_virtuallist_control", + LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + + ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls); + + } + + if ( ldap_search_ext( ld, base, scope, filterp, attrs, attrsonly, + ldaptool_request_ctrls, NULL, NULL, -1, &msgid ) + != LDAP_SUCCESS ) { + if (mallocd_filter) free(filterp); + return( ldaptool_print_lderror( ld, "ldap_search", + LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + + + matches = 0; + first = 1; + if ( sortattr && !server_sort ) { + rc = ldap_result( ld, LDAP_RES_ANY, 1, NULL, &res ); + } else { + while ( (rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res )) != + LDAP_RES_SEARCH_RESULT && rc != -1 ) { + if ( rc != LDAP_RES_SEARCH_ENTRY ) { + if ( rc == LDAP_RES_SEARCH_REFERENCE ) { + parse_and_display_reference( ld, res ); + } else if ( rc == LDAP_RES_EXTENDED + && ldap_msgid( res ) == LDAP_RES_UNSOLICITED ) { + (void)ldaptool_print_extended_response( ld, res, + "Unsolicited response" ); + } else { + fprintf( stderr, "%s: ignoring LDAP response message" + " type 0x%x (%s)\n", + ldaptool_progname, rc, msgtype2str( rc )); + } + ldap_msgfree( res ); + continue; + } + matches++; + e = ldap_first_entry( ld, res ); + if ( !first ) { + putchar( '\n' ); + } else { + first = 0; + } + print_entry( ld, e, attrsonly ); + ldap_msgfree( res ); + } + } + if ( rc == -1 ) { + if (mallocd_filter) free(filterp); + return( ldaptool_print_lderror( ld, "ldap_result", + LDAPTOOL_CHECK4SSL_IF_APPROP )); + } + + if ( ldap_parse_result( ld, res, &rc, NULL, NULL, &refs, + &ctrl_response_array, 0 ) != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, "ldap_parse_result", + LDAPTOOL_CHECK4SSL_IF_APPROP ); + } else if ( rc != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, "ldap_search", + LDAPTOOL_CHECK4SSL_IF_APPROP ); + } + /* Parse the returned sort control */ + if (server_sort) { + ber_int_t result = 0; + char *attribute; + + if ( LDAP_SUCCESS != ldap_parse_sort_control(ld,ctrl_response_array,&result,&attribute) ) { + (void)ldaptool_print_lderror(ld, "ldap_parse_sort_control", + LDAPTOOL_CHECK4SSL_IF_APPROP ); + ldap_controls_free(ctrl_response_array); + ldap_msgfree(res); + if (mallocd_filter) free(filterp); + return ( ldap_get_lderrno( ld, NULL, NULL ) ); + } + + if (0 == result) { + if ( ldaptool_verbose ) { + printf( "Server indicated results sorted OK\n"); + } + } else { + if (NULL != attribute) { + printf("Server reported sorting error %d: %s, attribute in error\"%s\"\n",result,sortresult2string(result),attribute); + } else { + printf("Server reported sorting error %d: %s\n",result,sortresult2string(result)); + } + } + + } + + if (use_vlv) + { + ber_int_t vpos, vcount; + int vresult; + if ( LDAP_SUCCESS != ldap_parse_virtuallist_control(ld,ctrl_response_array,&vpos, &vcount,&vresult) ) { + (void)ldaptool_print_lderror( ld, "ldap_parse_virtuallist_control", + LDAPTOOL_CHECK4SSL_IF_APPROP ); + ldap_controls_free(ctrl_response_array); + ldap_msgfree(res); + if (mallocd_filter) free(filterp); + return ( ldap_get_lderrno( ld, NULL, NULL ) ); + } + + if (0 == vresult) { + if ( ldaptool_verbose ) { + printf( "Server indicated virtual list positioning OK\n"); + } + printf("index %d content count %d\n", vpos, vcount); + + } else { + printf("Server reported sorting error %d: %s\n",vresult,sortresult2string((ber_int_t)vresult)); + + } + + } + + ldap_controls_free(ctrl_response_array); + + if ( sortattr != NULL && !server_sort) { + + (void) ldap_multisort_entries( ld, &res, + ( *sortattr == NULL ) ? NULL : sortattr, + (LDAP_CMP_CALLBACK *)strcasecmp ); + matches = 0; + first = 1; + for ( e = ldap_first_entry( ld, res ); e != NULLMSG; + e = ldap_next_entry( ld, e ) ) { + matches++; + if ( !first ) { + putchar( '\n' ); + } else { + first = 0; + } + print_entry( ld, e, attrsonly ); + } + } + + if ( ldaptool_verbose ) { + printf( "%d matches\n", matches ); + } + + if ( refs != NULL ) { + ldaptool_print_referrals( refs ); + ldap_value_free( refs ); + } + + if (mallocd_filter) free(filterp); + + if ( flush_after_each_entry ) { + /* + * Ensure that sort control, VLV control, and other status + * information is flushed in a timely fashion. + */ + fflush( stdout ); + } + + ldap_msgfree( res ); + return( rc ); +} + + +static void +print_entry( ld, entry, attrsonly ) + LDAP *ld; + LDAPMessage *entry; + int attrsonly; +{ + char *a, *dn, *ufn, tmpfname[ BUFSIZ ]; + int i, notascii; + BerElement *ber; + struct berval **bvals; + FILE *tmpfp; +#if defined( XP_WIN32 ) + char mode[20] = "w+b"; +#else + char mode[20] = "w"; +#endif + + dn = ldap_get_dn( ld, entry ); + write_string_attr_value( "dn", dn, LDAPTOOL_WRITEVALOPT_SUPPRESS_NAME ); + if ( includeufn ) { + ufn = ldap_dn2ufn( dn ); + write_string_attr_value( "ufn", ufn, + LDAPTOOL_WRITEVALOPT_SUPPRESS_NAME ); + free( ufn ); + } + ldap_memfree( dn ); + + if ( use_psearch ) { + LDAPControl **ectrls = NULL; + int chgnumpresent; + ber_int_t chgtype; + ber_int_t chgnum; + char *prevdn, longbuf[ 128 ]; + + if ( ldap_get_entry_controls( ld, entry, &ectrls ) == LDAP_SUCCESS ) { + if ( ldap_parse_entrychange_control( ld, ectrls, &chgtype, + &prevdn, &chgnumpresent, &chgnum ) == LDAP_SUCCESS ) { + write_string_attr_value( + LDAPTOOL_PSEARCH_ATTR_PREFIX "changeType", + changetype_num2string( chgtype ), 0 ); + if ( chgnumpresent ) { + sprintf( longbuf, "%d", chgnum ); + write_string_attr_value( + LDAPTOOL_PSEARCH_ATTR_PREFIX "changeNumber", + longbuf, 0 ); + } + if ( NULL != prevdn ) { + write_string_attr_value( + LDAPTOOL_PSEARCH_ATTR_PREFIX "previousDN", + prevdn, 0 ); + ldap_memfree( prevdn ); + } + } + ldap_controls_free( ectrls ); + } + } + + for ( a = ldap_first_attribute( ld, entry, &ber ); a != NULL; + a = ldap_next_attribute( ld, entry, ber ) ) { + if ( ldap_charray_inlist(sortattr, a) && /* in the list*/ + skipsortattr[ldap_charray_position(sortattr, a)] ) {/* and skip it*/ + continue; /* so skip it! */ + } + if ( attrsonly ) { + if ( ldif ) { + write_ldif_value( a, "", 0, 0 ); + } else { + printf( "%s\n", a ); + } + } else if (( bvals = ldap_get_values_len( ld, entry, a )) != NULL ) { + for ( i = 0; bvals[i] != NULL; i++ ) { + if ( vals2tmp ) { +#ifdef HAVE_SNPRINTF + if ( snprintf( tmpfname, sizeof(tmpfname), + "%s/ldapsearch-%s-XXXXXX", + ldaptool_get_tmp_dir(), a ) < 0 ) { + perror( "snprintf tmpfname (attribute name too long?)" ); + exit( LDAP_PARAM_ERROR ); + } +#else + sprintf( tmpfname, "%s/ldapsearch-%s-XXXXXX", + ldaptool_get_tmp_dir(), a ); +#endif + tmpfp = NULL; + + if ( LDAPTOOL_MKTEMP( tmpfname ) == NULL ) { + perror( tmpfname ); + } else if (( tmpfp = ldaptool_open_file( tmpfname, mode)) == NULL ) { + perror( tmpfname ); + } else if ( bvals[ i ]->bv_len > 0 && + fwrite( bvals[ i ]->bv_val, + bvals[ i ]->bv_len, 1, tmpfp ) == 0 ) { + perror( tmpfname ); + } else if ( ldif ) { + if ( produce_file_urls ) { + char *url; + + if ( ldaptool_path2fileurl( tmpfname, &url ) != + LDAPTOOL_FILEURL_SUCCESS ) { + perror( "ldaptool_path2fileurl" ); + } else { + write_ldif_value( a, url, strlen( url ), + LDIF_OPT_VALUE_IS_URL ); + free( url ); + } + } else { + write_ldif_value( a, tmpfname, strlen( tmpfname ), + 0 ); + } + } else { + printf( "%s%s%s\n", a, sep, tmpfname ); + } + + if ( tmpfp != NULL ) { + fclose( tmpfp ); + } + } else { + notascii = 0; + if ( !ldif && !allow_binary ) { + notascii = !ldaptool_berval_is_ascii( bvals[i] ); + } + + if ( ldif ) { + write_ldif_value( a, bvals[ i ]->bv_val, + bvals[ i ]->bv_len, 0 ); + } else { + printf( "%s%s%s\n", a, sep, + notascii ? "NOT ASCII" : bvals[ i ]->bv_val ); + } + } + } + ber_bvecfree( bvals ); + } + ldap_memfree( a ); + } + + if ( ldap_get_lderrno( ld, NULL, NULL ) != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, "ldap_first_attribute/ldap_next_attribute", + LDAPTOOL_CHECK4SSL_IF_APPROP ); + } + + if ( flush_after_each_entry ) { + fflush( stdout ); + } + + if ( ber != NULL ) { + ber_free( ber, 0 ); + } +} + + +static void +write_string_attr_value( char *attrname, char *strval, unsigned long opts ) +{ + if ( strval == NULL ) { + strval = ""; + } + if ( ldif ) { + write_ldif_value( attrname, strval, strlen( strval ), 0 ); + } else if ( 0 != ( opts & LDAPTOOL_WRITEVALOPT_SUPPRESS_NAME )) { + printf( "%s\n", strval ); + } else { + printf( "%s%s%s\n", attrname, sep, strval ); + } +} + + +static void +write_ldif_value( char *type, char *value, unsigned long vallen, + unsigned long ldifoptions ) +{ + char *ldif; + static int wrote_version = 0; + + if ( write_ldif_version && !wrote_version ) { + char versionbuf[ 64 ]; + + wrote_version = 1; + sprintf( versionbuf, "%d", LDIF_VERSION_ONE ); + write_ldif_value( "version", versionbuf, strlen( versionbuf ), 0 ); + } + + if ( !fold ) { + ldifoptions |= LDIF_OPT_NOWRAP; + } + if ( minimize_base64 ) { + ldifoptions |= LDIF_OPT_MINIMAL_ENCODING; + } + + /* ldif_type_and_value() fails only if malloc() fails. */ + if (( ldif = ldif_type_and_value_with_options( type, value, (int)vallen, + ldifoptions )) == NULL ) { + exit( LDAP_NO_MEMORY ); + } + + fputs( ldif, stdout ); + free( ldif ); +} + + +static char * +sortresult2string(ber_int_t result) +{ + /* + success (0), -- results are sorted + operationsError (1), -- server internal failure + timeLimitExceeded (3), -- timelimit reached before + -- sorting was completed + strongAuthRequired (8), -- refused to return sorted + -- results via insecure + -- protocol + adminLimitExceeded (11), -- too many matching entries + -- for the server to sort + noSuchAttribute (16), -- unrecognized attribute + -- type in sort key + inappropriateMatching (18), -- unrecognized or inappro- + -- priate matching rule in + -- sort key + insufficientAccessRights (50), -- refused to return sorted + -- results to this client + busy (51), -- too busy to process + unwillingToPerform (53), -- unable to sort + other (80) + */ + + switch (result) { + case 0: return ("success"); + case 1: return ("operations error"); + case 3: return ("time limit exceeded"); + case 8: return ("strong auth required"); + case 11: return ("admin limit exceeded"); + case 16: return ("no such attribute"); + case 18: return ("unrecognized or inappropriate matching rule"); + case 50: return ("insufficient access rights"); + case 51: return ("too busy"); + case 53: return ("unable to sort"); + case 80: + default: return ("Er...Other ?"); + } +} + + +static void +parse_and_display_reference( LDAP *ld, LDAPMessage *ref ) +{ + int i; + char **refs; + + if ( ldap_parse_reference( ld, ref, &refs, NULL, 0 ) != LDAP_SUCCESS ) { + (void)ldaptool_print_lderror( ld, "ldap_parse_reference", + LDAPTOOL_CHECK4SSL_IF_APPROP ); + } else if ( refs != NULL && refs[ 0 ] != NULL ) { + fputs( "Unfollowed continuation reference(s):\n", stderr ); + for ( i = 0; refs[ i ] != NULL; ++i ) { + fprintf( stderr, " %s\n", refs[ i ] ); + } + ldap_value_free( refs ); + } +} + + +/*possible operations a client can invoke -- copied from ldaprot.h */ + +#ifndef LDAP_REQ_BIND +#define LDAP_REQ_BIND 0x60L /* application + constructed */ +#define LDAP_REQ_UNBIND 0x42L /* application + primitive */ +#define LDAP_REQ_SEARCH 0x63L /* application + constructed */ +#define LDAP_REQ_MODIFY 0x66L /* application + constructed */ +#define LDAP_REQ_ADD 0x68L /* application + constructed */ +#define LDAP_REQ_DELETE 0x4aL /* application + primitive */ +#define LDAP_REQ_RENAME 0x6cL /* application + constructed */ +#define LDAP_REQ_COMPARE 0x6eL /* application + constructed */ +#define LDAP_REQ_ABANDON 0x50L /* application + primitive */ +#define LDAP_REQ_EXTENDED 0x77L /* application + constructed */ +#endif /* LDAP_REQ_BIND */ + + + +struct ldapsearch_type2str { + + int ldst2s_type; /* message type */ + char *ldst2s_string; /* descriptive string */ +}; + + +static struct ldapsearch_type2str ldapsearch_msgtypes[] = { + + /* results: */ + { LDAP_RES_BIND, "bind result" }, + { LDAP_RES_SEARCH_REFERENCE, "continuation reference" }, + { LDAP_RES_SEARCH_ENTRY, "entry" }, + { LDAP_RES_SEARCH_RESULT, "search result" }, + { LDAP_RES_MODIFY, "modify result" }, + { LDAP_RES_ADD, "add result" }, + { LDAP_RES_DELETE, "delete result" }, + { LDAP_RES_MODDN, "rename result" }, + { LDAP_RES_COMPARE, "compare result" }, + { LDAP_RES_EXTENDED, "extended operation result" }, + /* requests: */ + { LDAP_REQ_BIND, "bind request" }, + { LDAP_REQ_UNBIND, "unbind request" }, + { LDAP_REQ_SEARCH, "search request" }, + { LDAP_REQ_MODIFY, "modify request" }, + { LDAP_REQ_ADD, "add request" }, + { LDAP_REQ_DELETE, "delete request" }, + { LDAP_REQ_RENAME, "rename request" }, + { LDAP_REQ_COMPARE, "compare request" }, + { LDAP_REQ_ABANDON, "abandon request" }, + { LDAP_REQ_EXTENDED, "extended request" }, + +}; + + +#define LDAPSEARCHTOOL_NUMTYPES (sizeof(ldapsearch_msgtypes) \ + / sizeof(struct ldapsearch_type2str)) + + +/* + * Return a descriptive string given an LDAP result message type (tag). + */ +static char * +msgtype2str( int msgtype ) +{ + char *s = "unknown"; + int i; + + s = "unknown"; + for ( i = 0; i < LDAPSEARCHTOOL_NUMTYPES; ++i ) { + if ( msgtype == ldapsearch_msgtypes[ i ].ldst2s_type ) { + s = ldapsearch_msgtypes[ i ].ldst2s_string; + } + } + return( s ); +} + + +/* + * Return a descriptive string given a Persistent Search change type + */ +static char * +changetype_num2string( ber_int_t chgtype ) +{ + char *s = "unknown"; + + switch( chgtype ) { + case LDAP_CHANGETYPE_ADD: + s = "add"; + break; + case LDAP_CHANGETYPE_DELETE: + s = "delete"; + break; + case LDAP_CHANGETYPE_MODIFY: + s = "modify"; + break; + case LDAP_CHANGETYPE_MODDN: + s = "moddn"; + break; + } + + return( s ); +} + +/* returns a null teminated charrary */ +static char **get_effectiverights_attrlist(char * optarg) +{ + int i = 0; + char ** retArray = NULL; + char * tmp_str = strdup(optarg); + + if ( tmp_str == NULL ) { + perror("strdup"); + exit(LDAP_NO_MEMORY); + } + + retArray = ldap_str2charray( tmp_str, " "); /* takes copies */ + if ( retArray == NULL ) { + fprintf( stderr, "%s: not enough memory\n", ldaptool_progname ); + exit( LDAP_NO_MEMORY ); + } + + free(tmp_str); + + while( retArray[i] != NULL ) { + + fprintf(stderr,"%s ", retArray[i]); + i++; + } + fprintf(stderr, "\n"); + + return(retArray); +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ldaptool-sasl.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/ldaptool-sasl.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ldaptool-sasl.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/ldaptool-sasl.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ldaptool.h
Added
@@ -0,0 +1,209 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef _LDAPTOOL_H +#define _LDAPTOOL_H + +/* XXX:mhein The following is a workaround for the redefinition of */ +/* const problem on OSF. Fix to be provided by NSS */ +/* This is a pretty benign workaround for us which */ +/* should not cause problems in the future even if */ +/* we forget to take it out :-) */ + +#ifdef OSF1V4D +#ifndef __STDC__ +# define __STDC__ +#endif /* __STDC__ */ +#endif /* OSF1V4D */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> + +#ifdef AIX +#include <strings.h> +#endif + + +#ifdef SCOOS +#include <sys/types.h> +#endif + +#ifdef _WINDOWS +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +extern int getopt (int argc, char *const *argv, const char *optstring); +#include <io.h> /* for _mktemp() */ +#define LDAPTOOL_MKTEMP( p ) _mktemp( p ) +#else +#include <sys/file.h> +#include <sys/stat.h> +#include <unistd.h> + +#define LDAPTOOL_MKTEMP( p ) mktemp( p ) +#endif + +#ifdef LINUX +#include <getopt.h> /* not always included from unistd.h */ +#endif + +#include <ctype.h> + +#ifndef SCOOS +#include <sys/types.h> +#endif + +#include <sys/stat.h> +#include <fcntl.h> + +#if defined(NET_SSL) +#include <ssl.h> +#endif + +#include <portable.h> +#include <ldap.h> +#include <ldaplog.h> +#include <ldif.h> + +#if defined(NET_SSL) +#include <ldap_ssl.h> +#endif + +#include <ldappr.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * shared macros, structures, etc. + */ +#define LDAPTOOL_RESULT_IS_AN_ERROR( rc ) \ + ( (rc) != LDAP_SUCCESS && (rc) != LDAP_COMPARE_TRUE \ + && (rc) != LDAP_COMPARE_FALSE ) + +#define LDAPTOOL_DEFSEP "=" /* used by ldapcmp and ldapsearch */ +#define LDAPTOOL_DEFHOST "localhost" +#define LDAPTOOL_DEFSSLSTRENGTH LDAPSSL_AUTH_CERT +#define LDAPTOOL_DEFCERTDBPATH "." +#define LDAPTOOL_DEFKEYDBPATH "." +#define LDAPTOOL_DEFREFHOPLIMIT 5 + +#define LDAPTOOL_SAFEREALLOC( ptr, size ) ( ptr == NULL ? malloc( size ) : \ + realloc( ptr, size )) +/* this defines the max number of control requests for the tools */ +#define CONTROL_REQUESTS 50 + +/* + * globals (defined in common.c) + */ +extern char *ldaptool_host; +extern char *ldaptool_host2; +extern int ldaptool_port; +extern int ldaptool_port2; +extern int ldaptool_verbose; +extern int ldaptool_not; +extern int ldaptool_nobind; +extern int ldaptool_noconv_passwd; +extern char *ldaptool_progname; +extern FILE *ldaptool_fp; +extern char *ldaptool_charset; +extern LDAPControl *ldaptool_request_ctrls[]; +#ifdef LDAP_DEBUG +extern int ldaptool_dbg_lvl; +#define LDAPToolDebug(lvl,fmt,arg1,arg2,arg3) if (lvl & ldaptool_dbg_lvl) { fprintf(stderr,fmt,arg1,arg2,arg3); } +#else +#define LDAPToolDebug(lvl,fmt,arg1,arg2,arg3) +#endif /* LDAP_DEBUG */ + + +/* + * function prototypes + */ +void ldaptool_common_usage( int two_hosts ); +int ldaptool_process_args( int argc, char **argv, char *extra_opts, + int two_hosts, void (*extra_opt_callback)( int option, char *optarg )); +LDAP *ldaptool_ldap_init( int second_host ); +void ldaptool_bind( LDAP *ld ); +void ldaptool_cleanup( LDAP *ld ); +int ldaptool_print_lderror( LDAP *ld, char *msg, int check4ssl ); +#define LDAPTOOL_CHECK4SSL_NEVER 0 +#define LDAPTOOL_CHECK4SSL_ALWAYS 1 +#define LDAPTOOL_CHECK4SSL_IF_APPROP 2 /* if appropriate */ +LDAPControl *ldaptool_create_manage_dsait_control( void ); +void ldaptool_print_referrals( char **refs ); +int ldaptool_print_extended_response( LDAP *ld, LDAPMessage *res, char *msg ); +LDAPControl *ldaptool_create_proxyauth_control( LDAP *ld ); +LDAPControl *ldaptool_create_geteffectiveRights_control ( LDAP *ld, + const char *authzid, const char **attrlist ); +void ldaptool_add_control_to_array( LDAPControl *ctrl, LDAPControl **array); +void ldaptool_reset_control_array( LDAPControl **array ); +char *ldaptool_get_tmp_dir( void ); +char *ldaptool_local2UTF8( const char *s, const char *desc ); +char *ldaptool_getpass( const char *prompt ); +char *ldaptool_read_password( FILE *mod_password_fp ); +int ldaptool_berval_is_ascii( const struct berval *bvp ); +int ldaptool_sasl_bind_s( LDAP *ld, const char *dn, const char *mechanism, + const struct berval *cred, LDAPControl **serverctrls, + LDAPControl **clientctrls, struct berval **servercredp, char *msg ); +int ldaptool_simple_bind_s( LDAP *ld, const char *dn, const char *passwd, + LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ); +int ldaptool_add_ext_s( LDAP *ld, const char *dn, LDAPMod **attrs, + LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ); +int ldaptool_modify_ext_s( LDAP *ld, const char *dn, LDAPMod **mods, + LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg ); +int ldaptool_delete_ext_s( LDAP *ld, const char *dn, LDAPControl **serverctrls, + LDAPControl **clientctrls, char *msg ); +int ldaptool_rename_s( LDAP *ld, const char *dn, const char *newrdn, + const char *newparent, int deleteoldrdn, LDAPControl **serverctrls, + LDAPControl **clientctrls, char *msg ); +int ldaptool_compare_ext_s( LDAP *ld, const char *dn, const char *attrtype, + const struct berval *bvalue, LDAPControl **serverctrls, + LDAPControl **clientctrls, char *msg ); +int ldaptool_boolean_str2value ( const char *s, int strict ); +int ldaptool_parse_ctrl_arg ( char *ctrl_arg, char sep, char **ctrl_oid, + int *ctrl_criticality, char **ctrl_value, int *vlen); +FILE *ldaptool_open_file ( const char *filename, const char * mode); +int ldaptool_check_ferror( FILE * stream, const int ldap_err, const char *msg ); + + +#ifdef __cplusplus +} +#endif + +#endif /* LDAPTOOL_H */
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ntuserpin.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/ntuserpin.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/clients/tools/ntuserpin.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/clients/tools/ntuserpin.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/docs/ldap-c-api-internet-draft.txt
Changed
(renamed from mozilla/directory/c-sdk/ldap/docs/ldap-c-api-internet-draft.txt)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/README
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/README)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/add.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/add.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/asearch.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/asearch.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/compare.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/compare.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/crtfilt.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/crtfilt.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/csearch.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/csearch.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/del.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/del.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/examples.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/examples.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/getattrs.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/getattrs.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/getfilt.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/getfilt.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/macintosh/asearch (2i).68k.u
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/macintosh/asearch (2i).68k.u)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/macintosh/asearch (4i).68k.u
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/macintosh/asearch (4i).68k.u)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/macintosh/asearch PPC.u
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/macintosh/asearch PPC.u)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/modattrs.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/modattrs.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/modrdn.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/modrdn.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/nsprio.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/nsprio.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/nsprsasl.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/nsprsasl.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/nsprsaslsearch.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/nsprsaslsearch.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/ppolicy.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/ppolicy.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/psearch.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/psearch.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/rdentry.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/rdentry.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/sasl.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/sasl.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/saslsearch.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/saslsearch.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/search.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/search.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/srvrsort.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/srvrsort.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/ssearch.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/ssearch.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/ssnoauth.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/ssnoauth.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/win32.mak
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/win32.mak)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/ConnDlg.cpp
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/ConnDlg.cpp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/ConnDlg.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/ConnDlg.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/LdapDoc.cpp
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/LdapDoc.cpp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/LdapDoc.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/LdapDoc.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/LdapView.cpp
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/LdapView.cpp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/LdapView.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/LdapView.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/MainFrm.cpp
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/MainFrm.cpp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/MainFrm.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/MainFrm.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/PropDlg.cpp
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/PropDlg.cpp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/PropDlg.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/PropDlg.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/Resource.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/Resource.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/SrchDlg.cpp
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/SrchDlg.cpp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/SrchDlg.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/SrchDlg.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/StdAfx.cpp
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/StdAfx.cpp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/StdAfx.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/StdAfx.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/res/LdapDoc.ico
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/res/LdapDoc.ico)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/res/Toolbar.bmp
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/res/Toolbar.bmp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/res/winldap.ico
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/res/winldap.ico)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/res/winldap.rc2
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/res/winldap.rc2)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/winldap.cpp
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/winldap.cpp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/winldap.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/winldap.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/winldap.mak
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/winldap.mak)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/windows/winldap/winldap.rc
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/windows/winldap/winldap.rc)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/examples/xmplflt.conf
Changed
(renamed from mozilla/directory/c-sdk/ldap/examples/xmplflt.conf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/MANIFEST
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/MANIFEST)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/Makefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/Makefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/Makefile.in
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/Makefile.in)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/disptmpl.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/disptmpl.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/iutil.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/iutil.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/lber.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/lber.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/lcache.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/lcache.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/ldap-deprecated.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/ldap-deprecated.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/ldap-extension.h
Added
@@ -0,0 +1,853 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldap-extension.h - extensions to the ldap c api specification */ + +#ifndef _LDAP_EXTENSION_H +#define _LDAP_EXTENSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define LDAP_PORT_MAX 65535 /* API extension */ +#define LDAP_VERSION1 1 /* API extension */ +#define LDAP_VERSION LDAP_VERSION3 /* API extension */ + +/* + * C LDAP features we support that are not (yet) part of the LDAP C API + * Internet Draft. Use the ldap_get_option() call with an option value of + * LDAP_OPT_API_FEATURE_INFO to retrieve information about a feature. + * + * Note that this list is incomplete; it includes only the most widely + * used extensions. Also, the version is 1 for all of these for now. + */ +#define LDAP_API_FEATURE_SERVER_SIDE_SORT 1 +#define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 1 +#define LDAP_API_FEATURE_PERSISTENT_SEARCH 1 +#define LDAP_API_FEATURE_PROXY_AUTHORIZATION 1 +#define LDAP_API_FEATURE_X_LDERRNO 1 +#define LDAP_API_FEATURE_X_MEMCACHE 1 +#define LDAP_API_FEATURE_X_IO_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_EXTIO_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_DNS_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_THREAD_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_GETLANGVALUES 1 +#define LDAP_API_FEATURE_X_CLIENT_SIDE_SORT 1 +#define LDAP_API_FEATURE_X_URL_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_FILTER_FUNCTIONS 1 + +#define LDAP_ROOT_DSE "" /* API extension */ + +#define LDAP_OPT_DESC 0x01 /* 1 */ + +#define NULLMSG ((LDAPMessage *)0) + +/*built-in SASL methods */ +#define LDAP_SASL_EXTERNAL "EXTERNAL" /* TLS/SSL extension */ + +/* possible error codes we can be returned */ +#define LDAP_PARTIAL_RESULTS 0x09 /* 9 (UMich LDAPv2 extn) */ +#define NAME_ERROR(n) ((n & 0xf0) == 0x20) + +#define LDAP_SORT_CONTROL_MISSING 0x3C /* 60 (server side sort extn) */ +#define LDAP_INDEX_RANGE_ERROR 0x3D /* 61 (VLV extn) */ + +/* + * LDAPv3 server controls we know about + */ +#define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2" +#define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473" +#define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474" +#define LDAP_CONTROL_PERSISTENTSEARCH "2.16.840.1.113730.3.4.3" +#define LDAP_CONTROL_ENTRYCHANGE "2.16.840.1.113730.3.4.7" +#define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9" +#define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10" +#define LDAP_CONTROL_PROXYAUTH "2.16.840.1.113730.3.4.12" /* version 1 +*/ +#define LDAP_CONTROL_PROXIEDAUTH "2.16.840.1.113730.3.4.18" /* version 2 +*/ + +/* Authorization Identity Request and Response Controls */ +#define LDAP_CONTROL_AUTHZID_REQ "2.16.840.1.113730.3.4.16" +#define LDAP_CONTROL_AUTHZID_RES "2.16.840.1.113730.3.4.15" + +/* Authentication request and response controls */ +#define LDAP_CONTROL_AUTH_REQUEST LDAP_CONTROL_AUTHZID_REQ +#define LDAP_CONTROL_AUTH_RESPONSE LDAP_CONTROL_AUTHZID_RES + +/* Password information sent back to client */ +#define LDAP_CONTROL_PWEXPIRED "2.16.840.1.113730.3.4.4" +#define LDAP_CONTROL_PWEXPIRING "2.16.840.1.113730.3.4.5" + +/* Password Policy Control */ +#define LDAP_CONTROL_PASSWD_POLICY "1.3.6.1.4.1.42.2.27.8.5.1" + +/* Password Policy Control compatibility macros */ +#define LDAP_X_CONTROL_PWPOLICY_REQUEST LDAP_CONTROL_PASSWD_POLICY +#define LDAP_X_CONTROL_PWPOLICY_RESPONSE LDAP_CONTROL_PASSWD_POLICY +#define LDAP_CONTROL_PASSWORDPOLICYREQUEST LDAP_CONTROL_PASSWD_POLICY +#define LDAP_CONTROL_PASSWORDPOLICYRESPONSE LDAP_CONTROL_PASSWD_POLICY + +/* Password Modify Extended Operation */ +#define LDAP_EXOP_MODIFY_PASSWD "1.3.6.1.4.1.4203.1.11.1" + +/* Suppress virtual/inherited attribute values */ +#define LDAP_CONTROL_REAL_ATTRS_ONLY "2.16.840.1.113730.3.4.17" + +/* Only return virtual/inherited attribute values */ +#define LDAP_CONTROL_VIRTUAL_ATTRS_ONLY "2.16.840.1.113730.3.4.19" + +/* getEffectiveRights request */ +#define LDAP_CONTROL_GETEFFECTIVERIGHTS_REQUEST "1.3.6.1.4.1.42.2.27.9.5.2" + +/* Password Policy Control to get account availability */ +#define LDAP_CONTROL_ACCOUNT_USABLE "1.3.6.1.4.1.42.2.27.9.5.8" + +/* "Who am I?" Extended Operation */ +#define LDAP_EXOP_WHO_AM_I "1.3.6.1.4.1.4203.1.11.3" + +LDAP_API(void) LDAP_CALL ldap_ber_free( BerElement *ber, int freebuf ); + +LDAP_API(LDAPControl *) LDAP_CALL ldap_find_control( const char *oid, + LDAPControl **ctrls ); + +/* + * Server side sorting of search results (an LDAPv3 extension -- + * LDAP_API_FEATURE_SERVER_SIDE_SORT) + */ +typedef struct LDAPsortkey { /* structure for a sort-key */ + char * sk_attrtype; + char * sk_matchruleoid; + int sk_reverseorder; +} LDAPsortkey; + +/* where LDAP_CONTROL_ACCOUNT_USABLE control parse results */ +typedef struct LDAPuserstatus { /* user account availability */ + unsigned int us_available; /* availability status */ +#define LDAP_US_ACCOUNT_USABLE 1 +#define LDAP_US_ACCOUNT_NOT_USABLE 0 + int us_expire; /* will expire in seconds */ + int us_inactive; /* boolean inactivation status */ +#define LDAP_US_ACCOUNT_ACTIVE 0 +#define LDAP_US_ACCOUNT_INACTIVE 1 + int us_reset; /* boolean password reset */ +#define LDAP_US_ACCOUNT_NOT_RESET 0 +#define LDAP_US_ACCOUNT_RESET 1 + int us_expired; /* boolean password expired */ +#define LDAP_US_ACCOUNT_NOT_EXPIRED 0 +#define LDAP_US_ACCOUNT_EXPIRED 1 + int us_remaining; /* remaining logins */ + int us_seconds; /* will unlock in seconds */ +} LDAPuserstatus; + +/* LDAP_CONTROL_PASSWD_POLICY results */ +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_API(int) LDAP_CALL ldap_create_sort_control( LDAP *ld, + LDAPsortkey **sortKeyList, const char ctl_iscritical, + LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_parse_sort_control( LDAP *ld, + LDAPControl **ctrls, ber_int_t *result, char **attribute ); + +LDAP_API(void) LDAP_CALL ldap_free_sort_keylist( LDAPsortkey **sortKeyList ); +LDAP_API(int) LDAP_CALL ldap_create_sort_keylist( LDAPsortkey ***sortKeyList, + const char *string_rep ); + +LDAP_API(int) LDAP_CALL ldap_create_userstatus_control( + LDAP *ld, const char ctl_iscritical, LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_parse_userstatus_control( LDAP *ld, + LDAPControl **ctrlp, LDAPuserstatus *us ); + +LDAP_API(int) LDAP_CALL ldap_create_passwordpolicy_control( LDAP *ld, + LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_create_passwordpolicy_control_ext( LDAP *ld, + const char ctl_iscritical, LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_parse_passwordpolicy_control( LDAP *ld, + LDAPControl *ctrlp, ber_int_t *expirep, ber_int_t *gracep, + LDAPPasswordPolicyError *errorp ); +LDAP_API(int) LDAP_CALL ldap_parse_passwordpolicy_control_ext ( LDAP *ld, + LDAPControl **ctrlp, ber_int_t *expirep, ber_int_t *gracep, + LDAPPasswordPolicyError *errorp ); +LDAP_API(const char *) LDAP_CALL ldap_passwordpolicy_err2txt( + LDAPPasswordPolicyError err ); + +LDAP_API(int) LDAP_CALL ldap_create_authzid_control( LDAP *ld, + const char ctl_iscritical, LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_parse_authzid_control( LDAP *ld, + LDAPControl **ctrlp, char **authzid ); + +LDAP_API(int) LDAP_CALL ldap_whoami( LDAP *ld, LDAPControl **serverctrls, + LDAPControl **clientctrls, int *msgidp ); +LDAP_API(int) LDAP_CALL ldap_whoami_s( LDAP *ld, struct berval **authzid, + LDAPControl **serverctrls, LDAPControl **clientctrls ); +LDAP_API(int) LDAP_CALL ldap_parse_whoami( LDAP *ld, LDAPMessage *result, + struct berval **authzid ); + +LDAP_API(int) LDAP_CALL ldap_create_geteffectiveRights_control( LDAP *ld, + const char *authzid, const char **attrlist, const char ctl_iscritical, + LDAPControl **ctrlp ); + +/* + * Virtual list view (an LDAPv3 extension -- LDAP_API_FEATURE_VIRTUAL_LIST_VIEW) + */ +/* + * structure that describes a VirtualListViewRequest control. + * note that ldvlist_index and ldvlist_size are only relevant to + * ldap_create_virtuallist_control() if ldvlist_attrvalue is NULL. + */ +typedef struct ldapvirtuallist { + ber_int_t ldvlist_before_count; /* # entries before target */ + ber_int_t ldvlist_after_count; /* # entries after target */ + char *ldvlist_attrvalue; /* jump to this value */ + ber_int_t ldvlist_index; /* list offset */ + ber_int_t ldvlist_size; /* number of items in vlist */ + void *ldvlist_extradata; /* for use by application */ +} LDAPVirtualList; + +/* + * VLV functions: + */ +LDAP_API(int) LDAP_CALL ldap_create_virtuallist_control( LDAP *ld, + LDAPVirtualList *ldvlistp, LDAPControl **ctrlp ); + +LDAP_API(int) LDAP_CALL ldap_parse_virtuallist_control( LDAP *ld, + LDAPControl **ctrls, ber_int_t *target_posp, + ber_int_t *list_sizep, int *errcodep ); + +/* + * Routines for creating persistent search controls and for handling + * "entry changed notification" controls (an LDAPv3 extension -- + * LDAP_API_FEATURE_PERSISTENT_SEARCH) + */ +#define LDAP_CHANGETYPE_ADD 1 +#define LDAP_CHANGETYPE_DELETE 2 +#define LDAP_CHANGETYPE_MODIFY 4 +#define LDAP_CHANGETYPE_MODDN 8 +#define LDAP_CHANGETYPE_ANY (1|2|4|8) +LDAP_API(int) LDAP_CALL ldap_create_persistentsearch_control( LDAP *ld, + int changetypes, int changesonly, int return_echg_ctls, + char ctl_iscritical, LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_parse_entrychange_control( LDAP *ld, + LDAPControl **ctrls, ber_int_t *chgtypep, char **prevdnp, + int *chgnumpresentp, ber_int_t *chgnump ); + +/* + * Routines for creating Proxied Authorization controls (an LDAPv3 + * extension -- LDAP_API_FEATURE_PROXY_AUTHORIZATION) + * ldap_create_proxyauth_control() is for the old (version 1) control. + * ldap_create_proxiedauth_control() is for the newer (version 2) control. + */ +LDAP_API(int) LDAP_CALL ldap_create_proxyauth_control( LDAP *ld, + const char *dn, const char ctl_iscritical, LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_create_proxiedauth_control( LDAP *ld, + const char *authzid, LDAPControl **ctrlp ); + +/* + * Functions to get and set LDAP error information (API extension -- + * LDAP_API_FEATURE_X_LDERRNO ) + * + * By using LDAP_OPT_THREAD_FN_PTRS, you can arrange for the error info. to + * be thread-specific. + */ +LDAP_API(int) LDAP_CALL ldap_get_lderrno( LDAP *ld, char **m, char **s ); +LDAP_API(int) LDAP_CALL ldap_set_lderrno( LDAP *ld, int e, char *m, char *s ); + + +/* + * LDAP URL functions and definitions (an API extension -- + * LDAP_API_FEATURE_X_URL_FUNCTIONS) + */ +/* + * types for ldap URL handling + */ +typedef struct ldap_url_desc { + char *lud_host; + int lud_port; + char *lud_dn; + char **lud_attrs; + int lud_scope; + char *lud_filter; + unsigned long lud_options; +#define LDAP_URL_OPT_SECURE 0x01 + char *lud_string; /* for internal use only */ +} LDAPURLDesc; + +#define NULLLDAPURLDESC ((LDAPURLDesc *)NULL) + +/* + * possible errors returned by ldap_url_parse() + */ +#define LDAP_URL_ERR_NOTLDAP 1 /* URL doesn't begin with "ldap://" */ +#define LDAP_URL_ERR_NODN 2 /* URL has no DN (required) */ +#define LDAP_URL_ERR_BADSCOPE 3 /* URL scope string is invalid */ +#define LDAP_URL_ERR_MEM 4 /* can't allocate memory space */ +#define LDAP_URL_ERR_PARAM 5 /* bad parameter to an URL function */ +#define LDAP_URL_UNRECOGNIZED_CRITICAL_EXTENSION 6 + +/* + * URL functions: + */ +LDAP_API(int) LDAP_CALL ldap_is_ldap_url( const char *url ); +LDAP_API(int) LDAP_CALL ldap_url_parse( const char *url, LDAPURLDesc **ludpp ); +LDAP_API(int) LDAP_CALL ldap_url_parse_no_defaults( const char *url, + LDAPURLDesc **ludpp, int dn_required); +LDAP_API(void) LDAP_CALL ldap_free_urldesc( LDAPURLDesc *ludp ); +LDAP_API(int) LDAP_CALL ldap_url_search( LDAP *ld, const char *url, + int attrsonly ); +LDAP_API(int) LDAP_CALL ldap_url_search_s( LDAP *ld, const char *url, + int attrsonly, LDAPMessage **res ); +LDAP_API(int) LDAP_CALL ldap_url_search_st( LDAP *ld, const char *url, + int attrsonly, struct timeval *timeout, LDAPMessage **res ); + + +/* + * Function to dispose of an array of LDAPMod structures (an API extension). + * Warning: don't use this unless the mods array was allocated using the + * same memory allocator as is being used by libldap. + */ +LDAP_API(void) LDAP_CALL ldap_mods_free( LDAPMod **mods, int freemods ); + +/* + * SSL option (an API extension): + */ +#define LDAP_OPT_SSL 0x0A /* 10 - API extension */ + +/* + * Referral hop limit (an API extension): + */ +#define LDAP_OPT_REFERRAL_HOP_LIMIT 0x10 /* 16 - API extension */ + +/* + * Rebind callback function (an API extension) + */ +#define LDAP_OPT_REBIND_FN 0x06 /* 6 - API extension */ +#define LDAP_OPT_REBIND_ARG 0x07 /* 7 - API extension */ +typedef int (LDAP_CALL LDAP_CALLBACK LDAP_REBINDPROC_CALLBACK)( LDAP *ld, + char **dnp, char **passwdp, int *authmethodp, int freeit, void *arg); +LDAP_API(void) LDAP_CALL ldap_set_rebind_proc( LDAP *ld, + LDAP_REBINDPROC_CALLBACK *rebindproc, void *arg ); + +/* + * Thread function callbacks (an API extension -- + * LDAP_API_FEATURE_X_THREAD_FUNCTIONS). + */ +#define LDAP_OPT_THREAD_FN_PTRS 0x05 /* 5 - API extension */ + +/* + * Thread callback functions: + */ +typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_ALLOC_CALLBACK)( void ); +typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_FREE_CALLBACK)( void *m ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_LOCK_CALLBACK)( void *m ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_UNLOCK_CALLBACK)( void *m ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_ERRNO_CALLBACK)( void ); +typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_ERRNO_CALLBACK)( int e ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_LDERRNO_CALLBACK)( + char **matchedp, char **errmsgp, void *arg ); +typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_LDERRNO_CALLBACK)( int err, + char *matched, char *errmsg, void *arg ); + +/* + * Structure to hold thread function pointers: + */ +struct ldap_thread_fns { + LDAP_TF_MUTEX_ALLOC_CALLBACK *ltf_mutex_alloc; + LDAP_TF_MUTEX_FREE_CALLBACK *ltf_mutex_free; + LDAP_TF_MUTEX_LOCK_CALLBACK *ltf_mutex_lock; + LDAP_TF_MUTEX_UNLOCK_CALLBACK *ltf_mutex_unlock; + LDAP_TF_GET_ERRNO_CALLBACK *ltf_get_errno; + LDAP_TF_SET_ERRNO_CALLBACK *ltf_set_errno; + LDAP_TF_GET_LDERRNO_CALLBACK *ltf_get_lderrno; + LDAP_TF_SET_LDERRNO_CALLBACK *ltf_set_lderrno; + void *ltf_lderrno_arg; +}; + +/* + * Extended I/O function callbacks option (an API extension -- + * LDAP_API_FEATURE_X_EXTIO_FUNCTIONS). + */ +#define LDAP_X_OPT_EXTIO_FN_PTRS (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F00) + /* 0x4000 + 0x0F00 = 0x4F00 = 20224 - API extension */ + +/* Additional Extended I/O function callback option (for Extended Socket Arg callback) */ +#define LDAP_X_OPT_SOCKETARG (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F02) + /* 0x4000 + 0x0F02 = 0x4F02 = 20226 - API extension */ + +/* + * These extended I/O function callbacks echo the BSD socket API but accept + * an extra pointer parameter at the end of their argument list that can + * be used by client applications for their own needs. For some of the calls, + * the pointer is a session argument of type struct lextiof_session_private * + * that is associated with the LDAP session handle (LDAP *). For others, the + * pointer is a socket specific struct lextiof_socket_private * argument that + * is associated with a particular socket (a TCP connection). + * + * The lextiof_session_private and lextiof_socket_private structures are not + * defined by the LDAP C API; users of this extended I/O interface should + * define these themselves. + * + * The combination of the integer socket number (i.e., lpoll_fd, which is + * the value returned by the CONNECT callback) and the application specific + * socket argument (i.e., lpoll_socketarg, which is the value set in *sockargpp + * by the CONNECT callback) must be unique. + * + * The types for the extended READ and WRITE callbacks are actually in lber.h. + * + * The CONNECT callback gets passed both the session argument (sessionarg) + * and a pointer to a socket argument (socketargp) so it has the + * opportunity to set the socket-specific argument. The CONNECT callback + * also takes a timeout parameter whose value can be set by calling + * ldap_set_option( ld, LDAP_X_OPT_..., &val ). The units used for the + * timeout parameter are milliseconds. + * + * A POLL interface is provided instead of a select() one. The timeout is + * in milliseconds. + * + * A NEWHANDLE callback function is also provided. It is called right + * after the LDAP session handle is created, e.g., during ldap_init(). + * If the NEWHANDLE callback returns anything other than LDAP_SUCCESS, + * the session handle allocation fails. + * + * A DISPOSEHANDLE callback function is also provided. It is called right + * before the LDAP session handle and its contents are destroyed, e.g., + * during ldap_unbind(). + */ + +/* + * Special timeout values for poll and connect: + */ +#define LDAP_X_IO_TIMEOUT_NO_WAIT 0 /* return immediately */ +#define LDAP_X_IO_TIMEOUT_NO_TIMEOUT (-1) /* block indefinitely */ + +/* LDAP poll()-like descriptor: + */ +typedef struct ldap_x_pollfd { /* used by LDAP_X_EXTIOF_POLL_CALLBACK */ + int lpoll_fd; /* integer file descriptor / socket */ + struct lextiof_socket_private + *lpoll_socketarg; + /* pointer socket and for use by */ + /* application */ + short lpoll_events; /* requested event */ + short lpoll_revents; /* returned event */ +} LDAP_X_PollFD; + +/* Event flags for lpoll_events and lpoll_revents: + */ +#define LDAP_X_POLLIN 0x01 /* regular data ready for reading */ +#define LDAP_X_POLLPRI 0x02 /* high priority data available */ +#define LDAP_X_POLLOUT 0x04 /* ready for writing */ +#define LDAP_X_POLLERR 0x08 /* error occurred -- only in lpoll_revents */ +#define LDAP_X_POLLHUP 0x10 /* connection closed -- only in lpoll_revents */ +#define LDAP_X_POLLNVAL 0x20 /* invalid lpoll_fd -- only in lpoll_revents */ + +/* Options passed to LDAP_X_EXTIOF_CONNECT_CALLBACK to modify socket behavior: + */ +#define LDAP_X_EXTIOF_OPT_NONBLOCKING 0x01 /* turn on non-blocking mode */ +#define LDAP_X_EXTIOF_OPT_SECURE 0x02 /* turn on 'secure' mode */ + + +/* extended I/O callback function prototypes: + */ +typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CONNECT_CALLBACK )( + const char *hostlist, int port, /* host byte order */ + int timeout /* milliseconds */, + unsigned long options, /* bitmapped options */ + struct lextiof_session_private *sessionarg, + struct lextiof_socket_private **socketargp ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CLOSE_CALLBACK )( + int s, struct lextiof_socket_private *socketarg ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_POLL_CALLBACK)( + LDAP_X_PollFD fds[], int nfds, int timeout /* milliseconds */, + struct lextiof_session_private *sessionarg ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_NEWHANDLE_CALLBACK)( + LDAP *ld, struct lextiof_session_private *sessionarg ); +typedef void (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK)( + LDAP *ld, struct lextiof_session_private *sessionarg ); + + +/* Structure to hold extended I/O function pointers: + */ +struct ldap_x_ext_io_fns { + /* lextiof_size should always be set to LDAP_X_EXTIO_FNS_SIZE */ + int lextiof_size; + LDAP_X_EXTIOF_CONNECT_CALLBACK *lextiof_connect; + LDAP_X_EXTIOF_CLOSE_CALLBACK *lextiof_close; + LDAP_X_EXTIOF_READ_CALLBACK *lextiof_read; + LDAP_X_EXTIOF_WRITE_CALLBACK *lextiof_write; + LDAP_X_EXTIOF_POLL_CALLBACK *lextiof_poll; + LDAP_X_EXTIOF_NEWHANDLE_CALLBACK *lextiof_newhandle; + LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK *lextiof_disposehandle; + void *lextiof_session_arg; + LDAP_X_EXTIOF_WRITEV_CALLBACK *lextiof_writev; +}; +#define LDAP_X_EXTIO_FNS_SIZE sizeof(struct ldap_x_ext_io_fns) + +/* + * Utility functions for parsing space-separated host lists (useful for + * implementing an extended I/O CONNECT callback function). + */ +struct ldap_x_hostlist_status; +LDAP_API(int) LDAP_CALL ldap_x_hostlist_first( const char *hostlist, + int defport, char **hostp, int *portp /* host byte order */, + struct ldap_x_hostlist_status **statusp ); +LDAP_API(int) LDAP_CALL ldap_x_hostlist_next( char **hostp, + int *portp /* host byte order */, struct ldap_x_hostlist_status *status +); +LDAP_API(void) LDAP_CALL ldap_x_hostlist_statusfree( + struct ldap_x_hostlist_status *status ); + +/* + * Client side sorting of entries (an API extension -- + * LDAP_API_FEATURE_X_CLIENT_SIDE_SORT) + */ +/* + * Client side sorting callback functions: + */ +typedef const struct berval* (LDAP_C LDAP_CALLBACK + LDAP_KEYGEN_CALLBACK)( void *arg, LDAP *ld, LDAPMessage *entry ); +typedef int (LDAP_C LDAP_CALLBACK + LDAP_KEYCMP_CALLBACK)( void *arg, const struct berval*, + const struct berval* ); +typedef void (LDAP_C LDAP_CALLBACK + LDAP_KEYFREE_CALLBACK)( void *arg, const struct berval* ); +typedef int (LDAP_C LDAP_CALLBACK + LDAP_CMP_CALLBACK)(const char *val1, const char *val2); +typedef int (LDAP_C LDAP_CALLBACK + LDAP_VALCMP_CALLBACK)(const char **val1p, const char **val2p); + +/* + * Client side sorting functions: + */ +LDAP_API(int) LDAP_CALL ldap_keysort_entries( LDAP *ld, LDAPMessage **chain, + void *arg, LDAP_KEYGEN_CALLBACK *gen, LDAP_KEYCMP_CALLBACK *cmp, + LDAP_KEYFREE_CALLBACK *fre ); +LDAP_API(int) LDAP_CALL ldap_multisort_entries( LDAP *ld, LDAPMessage **chain, + char **attr, LDAP_CMP_CALLBACK *cmp ); +LDAP_API(int) LDAP_CALL ldap_sort_entries( LDAP *ld, LDAPMessage **chain, + char *attr, LDAP_CMP_CALLBACK *cmp ); +LDAP_API(int) LDAP_CALL ldap_sort_values( LDAP *ld, char **vals, + LDAP_VALCMP_CALLBACK *cmp ); +LDAP_API(int) LDAP_C LDAP_CALLBACK ldap_sort_strcasecmp( const char **a, + const char **b ); + + +/* + * Filter functions and definitions (an API extension -- + * LDAP_API_FEATURE_X_FILTER_FUNCTIONS) + */ +/* + * Structures, constants, and types for filter utility routines: + */ +typedef struct ldap_filt_info { + char *lfi_filter; + char *lfi_desc; + int lfi_scope; /* LDAP_SCOPE_BASE, etc */ + int lfi_isexact; /* exact match filter? */ + struct ldap_filt_info *lfi_next; +} LDAPFiltInfo; + +#define LDAP_FILT_MAXSIZ 1024 + +typedef struct ldap_filt_list LDAPFiltList; /* opaque filter list handle */ +typedef struct ldap_filt_desc LDAPFiltDesc; /* opaque filter desc handle */ + +/* + * Filter utility functions: + */ +LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter( char *fname ); +LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter_buf( char *buf, + long buflen ); +LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getfirstfilter( LDAPFiltDesc *lfdp, + char *tagpat, char *value ); +LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getnextfilter( LDAPFiltDesc *lfdp ); +LDAP_API(int) LDAP_CALL ldap_set_filter_additions( LDAPFiltDesc *lfdp, + char *prefix, char *suffix ); +LDAP_API(int) LDAP_CALL ldap_create_filter( char *buf, unsigned long buflen, + char *pattern, char *prefix, char *suffix, char *attr, + char *value, char **valwords ); +LDAP_API(void) LDAP_CALL ldap_getfilter_free( LDAPFiltDesc *lfdp ); + +/* + * Friendly mapping structure and routines (an API extension) + */ +typedef struct friendly { + char *f_unfriendly; + char *f_friendly; +} *FriendlyMap; +LDAP_API(char *) LDAP_CALL ldap_friendly_name( char *filename, char *name, + FriendlyMap *map ); +LDAP_API(void) LDAP_CALL ldap_free_friendlymap( FriendlyMap *map ); + +/* + * In Memory Cache (an API extension -- LDAP_API_FEATURE_X_MEMCACHE) + */ +typedef struct ldapmemcache LDAPMemCache; /* opaque in-memory cache handle */ + +LDAP_API(int) LDAP_CALL ldap_memcache_init( unsigned long ttl, + unsigned long size, char **baseDNs, struct ldap_thread_fns *thread_fns, + LDAPMemCache **cachep ); +LDAP_API(int) LDAP_CALL ldap_memcache_set( LDAP *ld, LDAPMemCache *cache ); +LDAP_API(int) LDAP_CALL ldap_memcache_get( LDAP *ld, LDAPMemCache **cachep ); +LDAP_API(void) LDAP_CALL ldap_memcache_flush( LDAPMemCache *cache, char *dn, + int scope ); +LDAP_API(void) LDAP_CALL ldap_memcache_flush_results( LDAPMemCache *cache, + char *dn, int scope ); +LDAP_API(void) LDAP_CALL ldap_memcache_destroy( LDAPMemCache *cache ); +LDAP_API(void) LDAP_CALL ldap_memcache_update( LDAPMemCache *cache ); + +/* + * Timeout value for nonblocking connect call + */ +#define LDAP_X_OPT_CONNECT_TIMEOUT (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F01) + /* 0x4000 + 0x0F01 = 0x4F01 = 20225 - API extension */ + +/* + * Socket buffer structure associated to the LDAP connection + */ +#define LDAP_X_OPT_SOCKBUF (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F03) + /* 0x4000 + 0x0F03 = 0x4F03 = 20227 - API extension */ + +/* + * Memory allocation callback functions (an API extension -- + * LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS). These are global and can + * not be set on a per-LDAP session handle basis. Install your own + * functions by making a call like this: + * ldap_set_option( NULL, LDAP_OPT_MEMALLOC_FN_PTRS, &memalloc_fns ); + * + * look in lber.h for the function typedefs themselves. + */ +#define LDAP_OPT_MEMALLOC_FN_PTRS 0x61 /* 97 - API extension */ + +struct ldap_memalloc_fns { + LDAP_MALLOC_CALLBACK *ldapmem_malloc; + LDAP_CALLOC_CALLBACK *ldapmem_calloc; + LDAP_REALLOC_CALLBACK *ldapmem_realloc; + LDAP_FREE_CALLBACK *ldapmem_free; +}; + + +/* + * Memory allocation functions (an API extension) + */ +void *ldap_x_malloc( size_t size ); +void *ldap_x_calloc( size_t nelem, size_t elsize ); +void *ldap_x_realloc( void *ptr, size_t size ); +void ldap_x_free( void *ptr ); + +/* + * Server reconnect (an API extension). + */ +#define LDAP_OPT_RECONNECT 0x62 /* 98 - API extension */ + + +/* + * Extra thread callback functions (an API extension -- + * LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS) + */ +#define LDAP_OPT_EXTRA_THREAD_FN_PTRS 0x65 /* 101 - API extension */ + +/* + * When bind is called, don't bind if there's a connection open with the same DN + */ +#define LDAP_OPT_NOREBIND 0x66 /* 102 - API extension */ + +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_TRYLOCK_CALLBACK)( void *m ); +typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_ALLOC_CALLBACK)( void ); +typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_FREE_CALLBACK)( void *s ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_WAIT_CALLBACK)( void *s ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_POST_CALLBACK)( void *s ); +typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_THREADID_CALLBACK)(void); + +struct ldap_extra_thread_fns { + LDAP_TF_MUTEX_TRYLOCK_CALLBACK *ltf_mutex_trylock; + LDAP_TF_SEMA_ALLOC_CALLBACK *ltf_sema_alloc; + LDAP_TF_SEMA_FREE_CALLBACK *ltf_sema_free; + LDAP_TF_SEMA_WAIT_CALLBACK *ltf_sema_wait; + LDAP_TF_SEMA_POST_CALLBACK *ltf_sema_post; + LDAP_TF_THREADID_CALLBACK *ltf_threadid_fn; +}; + +/* + * Debugging level (an API extension) + */ +#define LDAP_OPT_DEBUG_LEVEL 0x6E /* 110 - API extension */ +/* On UNIX, there's only one copy of ldap_debug */ +/* On NT, each dll keeps its own module_ldap_debug, which */ +/* points to the process' ldap_debug and needs initializing after load */ +#ifdef _WIN32 +extern int *module_ldap_debug; +typedef void (*set_debug_level_fn_t)(int*); +#endif + +#ifdef LDAP_DNS +#define LDAP_OPT_DNS 0x0C /* 12 - API extension */ +#endif + +/* + * UTF-8 routines (should these move into libnls?) + */ +/* number of bytes in character */ +LDAP_API(int) LDAP_CALL ldap_utf8len( const char* ); +/* find next character */ +LDAP_API(char*) LDAP_CALL ldap_utf8next( char* ); +/* find previous character */ +LDAP_API(char*) LDAP_CALL ldap_utf8prev( char* ); +/* copy one character */ +LDAP_API(int) LDAP_CALL ldap_utf8copy( char* dst, const char* src ); +/* total number of characters */ +LDAP_API(size_t) LDAP_CALL ldap_utf8characters( const char* ); +/* get one UCS-4 character, and move *src to the next character */ +LDAP_API(unsigned long) LDAP_CALL ldap_utf8getcc( const char** src ); +/* UTF-8 aware strtok_r() */ +LDAP_API(char*) LDAP_CALL ldap_utf8strtok_r( char* src, const char* brk, char** +next); + +/* like isalnum(*s) in the C locale */ +LDAP_API(int) LDAP_CALL ldap_utf8isalnum( char* s ); +/* like isalpha(*s) in the C locale */ +LDAP_API(int) LDAP_CALL ldap_utf8isalpha( char* s ); +/* like isdigit(*s) in the C locale */ +LDAP_API(int) LDAP_CALL ldap_utf8isdigit( char* s ); +/* like isxdigit(*s) in the C locale */ +LDAP_API(int) LDAP_CALL ldap_utf8isxdigit(char* s ); +/* like isspace(*s) in the C locale */ +LDAP_API(int) LDAP_CALL ldap_utf8isspace( char* s ); + +#define LDAP_UTF8LEN(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8len (s) : 1) +#define LDAP_UTF8NEXT(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8next(s) : ( s)+1) +#define LDAP_UTF8INC(s) ((0x80 & *(unsigned char*)(s)) ? s=ldap_utf8next(s) : ++s) + +#define LDAP_UTF8PREV(s) ldap_utf8prev(s) +#define LDAP_UTF8DEC(s) (s=ldap_utf8prev(s)) + +#define LDAP_UTF8COPY(d,s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8copy(d,s) : ((*(d) = *(s)), 1)) +#define LDAP_UTF8GETCC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc (&s) : *s++) +#define LDAP_UTF8GETC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc ((const char**)&s) : *s++) + +/* SASL options */ +#define LDAP_OPT_X_SASL_MECH 0x6100 +#define LDAP_OPT_X_SASL_REALM 0x6101 +#define LDAP_OPT_X_SASL_AUTHCID 0x6102 +#define LDAP_OPT_X_SASL_AUTHZID 0x6103 +#define LDAP_OPT_X_SASL_SSF 0x6104 /* read-only */ +#define LDAP_OPT_X_SASL_SSF_EXTERNAL 0x6105 /* write-only */ +#define LDAP_OPT_X_SASL_SECPROPS 0x6106 /* write-only */ +#define LDAP_OPT_X_SASL_SSF_MIN 0x6107 +#define LDAP_OPT_X_SASL_SSF_MAX 0x6108 +#define LDAP_OPT_X_SASL_MAXBUFSIZE 0x6109 + +/* ldap_interactive_bind_s Interaction flags + * Interactive: prompt always - REQUIRED + */ +#define LDAP_SASL_AUTOMATIC 0U /* only prompt for missing items not supplied as defaults */ +#define LDAP_SASL_INTERACTIVE 1U /* prompt for everything and print defaults, if any */ +#define LDAP_SASL_QUIET 2U /* no prompts - only use defaults (e.g. for non-interactive apps) */ + +/* + * 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) + */ +typedef int (LDAP_SASL_INTERACT_PROC) + (LDAP *ld, unsigned flags, void* defaults, void *interact ); + +LDAP_API(int) LDAP_CALL ldap_sasl_interactive_bind_s ( + LDAP *ld, + const char *dn, /* usually NULL */ + const char *saslMechanism, + LDAPControl **serverControls, + LDAPControl **clientControls, + + /* should be client controls */ + unsigned flags, + LDAP_SASL_INTERACT_PROC *proc, + void *defaults ); + +LDAP_API(int) LDAP_CALL ldap_sasl_interactive_bind_ext_s ( + LDAP *ld, + const char *dn, /* usually NULL */ + const char *saslMechanism, + LDAPControl **serverControls, + LDAPControl **clientControls, + + /* should be client controls */ + unsigned flags, + LDAP_SASL_INTERACT_PROC *proc, + void *defaults, + LDAPControl ***responseControls ); + +/* + * Password modify functions + */ +LDAP_API(int) LDAP_CALL ldap_passwd( LDAP *ld, struct berval *userid, + struct berval *oldpasswd, struct berval *newpasswd, + LDAPControl **serverctrls, LDAPControl **clientctrls, + int *msgidp ); + +LDAP_API(int) LDAP_CALL ldap_passwd_s( LDAP *ld, struct berval *userid, + struct berval *oldpasswd, struct berval *newpasswd, + struct berval *genpasswd, LDAPControl **serverctrls, + LDAPControl **clientctrls ); + +LDAP_API(int) LDAP_CALL ldap_parse_passwd( LDAP *ld, LDAPMessage *result, + struct berval *genpasswd ); + +/* + * in reslist.c + */ +LDAP_API(LDAPMessage *) LDAP_CALL ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e ); +LDAP_API(void) LDAP_CALL ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e ); + +#ifdef __cplusplus +} +#endif +#endif /* _LDAP_EXTENSION_H */ +
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/ldap-platform.h
Added
@@ -0,0 +1,91 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldap-platform.h - platform transparency */ + +#ifndef _LDAP_PLATFORM_H +#define _LDAP_PLATFORM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined (WIN32) || defined (_WIN32) || defined( _CONSOLE ) +#include <windows.h> +# if defined( _WINDOWS ) +# include <winsock.h> +# endif +#elif defined(macintosh) +#ifndef LDAP_TYPE_TIMEVAL_DEFINED +#include <utime.h> +#endif +#ifndef LDAP_TYPE_SOCKET_DEFINED /* API extension */ +#include "macsocket.h" +#endif +#else /* everything else, e.g., Unix */ +#ifndef LDAP_TYPE_TIMEVAL_DEFINED +#include <sys/time.h> +#endif +#ifndef LDAP_TYPE_SOCKET_DEFINED /* API extension */ +#include <sys/types.h> +#include <sys/socket.h> +#endif +#endif + +#ifdef _AIX +#include <sys/select.h> +#endif /* _AIX */ + +#ifdef XP_OS2 +#include <sys/select.h> +#endif /* XP_OS2 */ + +/* + * LDAP_API macro definition: + */ +#ifndef LDAP_API +#if defined( _WINDOWS ) || defined( _WIN32 ) +#define LDAP_API(rt) rt +#else /* _WINDOWS */ +#define LDAP_API(rt) rt +#endif /* _WINDOWS */ +#endif /* LDAP_API */ + +#ifdef __cplusplus +} +#endif +#endif /* _LDAP_PLATFORM_H */
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/ldap-standard-tmpl.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/ldap-standard-tmpl.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/ldap-to-be-deprecated.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/ldap-to-be-deprecated.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/ldap.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/ldap.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/ldap_ssl.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/ldap_ssl.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/ldaplog.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/ldaplog.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/ldappr.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/ldappr.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/ldaprot.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/ldaprot.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/ldif.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/ldif.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/portable.h
Added
@@ -0,0 +1,468 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Copyright (c) 1994 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. + */ + +#ifndef _PORTABLE_H +#define _PORTABLE_H + +/* + * portable.h for LDAP -- this is where we define common stuff to make + * life easier on various Unix systems. + * + * Unless you are porting LDAP to a new platform, you should not need to + * edit this file. + */ + +#ifndef SYSV +#if defined( hpux ) || defined( SOLARIS ) || defined ( sgi ) || defined( SVR4 ) +#define SYSV +#endif +#endif + +/* + * under System V, use sysconf() instead of getdtablesize + */ +#if !defined( USE_SYSCONF ) && defined( SYSV ) +#define USE_SYSCONF +#endif + +/* + * under System V, daemons should use setsid() instead of detaching from their + * tty themselves + */ +#if !defined( USE_SETSID ) && defined( SYSV ) +#define USE_SETSID +#endif + +/* + * System V has socket options in filio.h + */ +#if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux ) && !defined( AIX ) +#define NEED_FILIO +#endif + +/* + * use lockf() under System V + */ +#if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix )) +#define USE_LOCKF +#endif + +/* + * on many systems, we should use waitpid() instead of waitN() + */ +#if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) || defined( ultrix ) || defined( aix )) +#define USE_WAITPID +#endif + +/* + * define the wait status argument type + */ +#if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep ) +#define WAITSTATUSTYPE union wait +#else +#define WAITSTATUSTYPE int +#endif + +/* + * defined the options for openlog (syslog) + */ +#ifdef ultrix +#define OPENLOG_OPTIONS LOG_PID +#else +#define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT ) +#endif + +/* + * some systems don't have the BSD re_comp and re_exec routines + */ +#ifndef NEED_BSDREGEX +#if ( defined( SYSV ) || defined( NETBSD ) || defined( freebsd ) || defined( linux ) || defined( DARWIN )) && !defined(sgi) +#define NEED_BSDREGEX +#endif +#endif + +/* + * many systems do not have the setpwfile() library routine... we just + * enable use for those systems we know have it. + */ +#ifndef HAVE_SETPWFILE +#if defined( sunos4 ) || defined( ultrix ) || defined( OSF1 ) +#define HAVE_SETPWFILE +#endif +#endif + +/* + * Are sys_errlist and sys_nerr declared in stdio.h? + */ +#ifndef SYSERRLIST_IN_STDIO +#if defined( freebsd ) +#define SYSERRLIST_IN_STDIO +#endif +#endif + + +/* + * Is snprintf() part of the standard C runtime library? + */ +#if !defined(HAVE_SNPRINTF) +#if defined(SOLARIS) || defined(LINUX) || defined(HPUX) || defined(AIX) +#define HAVE_SNPRINTF +#endif +#if defined(_WINDOWS) +#define snprintf _snprintf +#define HAVE_SNPRINTF +#endif +#endif + + +/* + * Async IO. Use a non blocking implementation of connect() and + * dns functions + */ +#if !defined(LDAP_ASYNC_IO) +#if !defined(_WINDOWS) && !defined(macintosh) +#define LDAP_ASYNC_IO +#endif /* _WINDOWS */ +#endif + +/* + * for select() + */ +#if !defined(WINSOCK) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2) +#if defined(hpux) || defined(LINUX) || defined(SUNOS4) || defined(XP_BEOS) +#include <sys/time.h> +#else +#include <sys/select.h> +#endif +#if !defined(FD_SET) +#define NFDBITS 32 +#define FD_SETSIZE 32 +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) +#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) +#endif /* !FD_SET */ +#endif /* !WINSOCK && !_WINDOWS && !macintosh */ + + +/* + * for connect() -- must we block signals when calling connect()? This + * is necessary on some buggy UNIXes. + */ +#if !defined(NSLDAPI_CONNECT_MUST_NOT_BE_INTERRUPTED) && \ + ( defined(AIX) || defined(IRIX) || defined(HPUX) || defined(SUNOS4) \ + || defined(SOLARIS) || defined(OSF1) ||defined(freebsd)) +#define NSLDAPI_CONNECT_MUST_NOT_BE_INTERRUPTED +#endif + +/* + * On most platforms, sigprocmask() works fine even in multithreaded code. + * But not everywhere. + */ +#ifdef AIX +#define NSLDAPI_MT_SAFE_SIGPROCMASK(h,s,o) sigthreadmask(h,s,o) +#else +#define NSLDAPI_MT_SAFE_SIGPROCMASK(h,s,o) sigprocmask(h,s,o) +#endif + +/* + * toupper and tolower macros are different under bsd and sys v + */ +#if defined( SYSV ) && !defined( hpux ) +#define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c) +#define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c) +#else +#define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c) +#define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c) +#endif + +/* + * put a cover on the tty-related ioctl calls we need to use + */ +#if defined( NeXT ) || (defined(SunOS) && SunOS < 40) +#define TERMIO_TYPE struct sgttyb +#define TERMFLAG_TYPE int +#define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop)) +#define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop)) +#define GETFLAGS( tio ) (tio).sg_flags +#define SETFLAGS( tio, flags ) (tio).sg_flags = (flags) +#else +#define USE_TERMIOS +#define TERMIO_TYPE struct termios +#define TERMFLAG_TYPE tcflag_t +#define GETATTR( fd, tiop ) tcgetattr((fd), (tiop)) +#define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop)) +#define GETFLAGS( tio ) (tio).c_lflag +#define SETFLAGS( tio, flags ) (tio).c_lflag = (flags) +#endif + +#if ( !defined( HPUX9 )) && ( !defined( sunos4 )) && ( !defined( SNI )) && \ + ( !defined( HAVE_TIME_R )) +#define HAVE_TIME_R +#endif + +#if defined(SNI) || defined(LINUX1_2) +int strcasecmp(const char *, const char *); +#ifdef SNI +int strncasecmp(const char *, const char *, int); +#endif /* SNI */ +#ifdef LINUX1_2 +int strncasecmp(const char *, const char *, size_t); +#endif /* LINUX1_2 */ +#endif /* SNI || LINUX1_2 */ + +#if defined(_WINDOWS) || defined(macintosh) || defined(XP_OS2) || defined(DARWIN) +#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) +#define NSLDAPI_CTIME( c, b, l ) ctime( c ) +#define STRTOK( s1, s2, l ) strtok( s1, s2 ) +#elif defined(XP_BEOS) +#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) +#define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b ) +#define STRTOK( s1, s2, l ) strtok_r( s1, s2, l ) +#define HAVE_STRTOK_R +#else /* UNIX */ +#if (defined(AIX) && defined(_THREAD_SAFE)) || defined(OSF1) +#define NSLDAPI_NETDB_BUF_SIZE sizeof(struct protoent_data) +#else +#define NSLDAPI_NETDB_BUF_SIZE 1024 +#endif + +#if defined(sgi) || defined(HPUX9) || defined(SCOOS) || \ + defined(UNIXWARE) || defined(SUNOS4) || defined(SNI) || defined(BSDI) || \ + defined(NCR) || defined(OSF1) || defined(NEC) || defined(VMS) || \ + ( defined(HPUX10) && !defined(_REENTRANT)) || defined(HPUX11) || \ + defined(UnixWare) || defined(NETBSD) || \ + defined(FREEBSD) || defined(OPENBSD) || \ + (defined(LINUX) && __GLIBC__ < 2) || \ + (defined(AIX) && !defined(USE_REENTRANT_LIBC)) +#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) +#elif defined(AIX) +/* Maybe this is for another version of AIX? + Commenting out for AIX 4.1 for Nova + Replaced with following to lines, stolen from the #else below +#define GETHOSTBYNAME_BUF_T struct hostent_data +*/ +typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE]; +#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t +#define GETHOSTBYNAME( n, r, b, l, e ) \ + (memset (&b, 0, l), gethostbyname_r (n, r, &b) ? NULL : r) +#elif defined(HPUX10) +#define GETHOSTBYNAME_BUF_T struct hostent_data +#define GETHOSTBYNAME( n, r, b, l, e ) nsldapi_compat_gethostbyname_r( n, r, (char *)&b, l, e ) +#elif defined(LINUX) || defined(DRAGONFLY) +typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE]; +#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t +#define GETHOSTBYNAME( n, r, b, l, rp, e ) gethostbyname_r( n, r, b, l, rp, e ) +#define GETHOSTBYNAME_R_RETURNS_INT +#else +typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE]; +#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t +#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname_r( n, r, b, l, e ) +#endif +#if defined(HPUX9) || defined(LINUX1_2) || defined(LINUX2_0) || \ + defined(LINUX2_1) || defined(SUNOS4) || defined(SNI) || \ + defined(SCOOS) || defined(BSDI) || defined(NCR) || \ + defined(NEC) || ( defined(HPUX10) && !defined(_REENTRANT)) || \ + (defined(AIX) && !defined(USE_REENTRANT_LIBC)) +#define NSLDAPI_CTIME( c, b, l ) ctime( c ) +#elif defined(HPUX10) && defined(_REENTRANT) && !defined(HPUX11) +#define NSLDAPI_CTIME( c, b, l ) nsldapi_compat_ctime_r( c, b, l ) +#elif defined( IRIX6_2 ) || defined( IRIX6_3 ) || defined(UNIXWARE) \ + || defined(OSF1V4) || defined(AIX) || defined(UnixWare) \ + || defined(hpux) || defined(HPUX11) || defined(NETBSD) \ + || defined(IRIX6) || defined(FREEBSD) || defined(VMS) \ + || defined(NTO) || defined(OPENBSD) || defined(DRAGONFLY) +#define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b ) +#elif defined( OSF1V3 ) +#define NSLDAPI_CTIME( c, b, l ) (ctime_r( c, b, l ) ? NULL : b) +#else +#define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b, l ) +#endif +#if defined(hpux9) || defined(SUNOS4) || defined(SNI) || \ + defined(SCOOS) || defined(BSDI) || defined(NCR) || defined(VMS) || \ + defined(NEC) || (defined(LINUX) && __GNU_LIBRARY__ != 6) || \ + (defined(AIX) && !defined(USE_REENTRANT_LIBC)) +#define STRTOK( s1, s2, l ) strtok( s1, s2 ) +#else +#define HAVE_STRTOK_R +#ifndef strtok_r +char *strtok_r(char *, const char *, char **); +#endif +#define STRTOK( s1, s2, l ) (char *)strtok_r( s1, s2, l ) +#endif /* STRTOK */ +#endif /* UNIX */ + +#if defined( ultrix ) || defined( nextstep ) +extern char *strdup(); +#endif /* ultrix || nextstep */ + +#if defined( sunos4 ) || defined( OSF1 ) +#define BSD_TIME 1 /* for servers/slapd/log.h */ +#endif /* sunos4 || osf */ + +#if defined(XP_OS2) +#include <machine/endian.h> /* for htonl, et.al. */ +#include <arpa/inet.h> /* for inet_addr() */ +#elif !defined(_WINDOWS) && !defined(macintosh) +#include <netinet/in.h> +#if !defined(XP_BEOS) +#include <arpa/inet.h> /* for inet_addr() */ +#endif +#endif + + +/* + * Define portable 32-bit integral types. + */ +#include <limits.h> +#if UINT_MAX >= 0xffffffffU /* an int holds at least 32 bits */ + typedef signed int nsldapi_int_32; + typedef unsigned int nsldapi_uint_32; +#else /* ints are < 32 bits; use long instead */ + typedef signed long nsldapi_int_32; + typedef unsigned long nsldapi_uint_32; +#endif + +/* + * Define a portable type for IPv4 style Internet addresses (32 bits): + */ +#if defined(_IN_ADDR_T) || defined(aix) || defined(HPUX11) || defined(OSF1) +typedef in_addr_t nsldapi_in_addr_t; +#else +typedef nsldapi_uint_32 nsldapi_in_addr_t; +#endif + +#ifdef SUNOS4 +#include <pcfs/pc_dir.h> /* for toupper() */ +int fprintf(FILE *, char *, ...); +int fseek(FILE *, long, int); +int fread(char *, int, int, FILE *); +int fclose(FILE *); +int fflush(FILE *); +int rewind(FILE *); +void *memmove(void *, const void *, size_t); +int strcasecmp(char *, char *); +int strncasecmp(char *, char *, int); +time_t time(time_t *); +void perror(char *); +int fputc(char, FILE *); +int fputs(char *, FILE *); +int re_exec(char *); +int socket(int, int, int); +void bzero(char *, int); +unsigned long inet_addr(char *); +char * inet_ntoa(struct in_addr); +int getdtablesize(); +int connect(int, struct sockaddr *, int); +#endif /* SUNOS4 */ + +/* #if defined(SUNOS4) || defined(SNI) */ +#if defined(SUNOS4) +int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +#endif /* SUNOS4 || SNI */ + +/* + * SAFEMEMCPY is an overlap-safe copy from s to d of n bytes + */ +#ifdef macintosh +#define SAFEMEMCPY( d, s, n ) BlockMoveData( (Ptr)s, (Ptr)d, n ) +#else /* macintosh */ +#ifdef sunos4 +#define SAFEMEMCPY( d, s, n ) bcopy( s, d, n ) +#else /* sunos4 */ +#define SAFEMEMCPY( d, s, n ) memmove( d, s, n ) +#endif /* sunos4 */ +#endif /* macintosh */ + +#ifdef _WINDOWS + +#define strcasecmp strcmpi +#define strncasecmp _strnicmp +#define bzero(a, b) memset( a, 0, b ) +#define getpid _getpid +#define ioctl ioctlsocket +#define sleep(a) Sleep( a*1000 ) + +#define EMSGSIZE WSAEMSGSIZE +#define EWOULDBLOCK WSAEWOULDBLOCK +#define EHOSTUNREACH WSAEHOSTUNREACH + +#ifndef MAXPATHLEN +#define MAXPATHLEN _MAX_PATH +#endif + +/* We'd like this number to be prime for the hash + * into the Connection table */ +#define DS_MAX_NT_SOCKET_CONNECTIONS 2003 + +#elif defined(XP_OS2) + +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define bzero(a, b) memset( a, 0, b ) +#include <string.h> /*for strcmpi()*/ +#include <time.h> /*for ctime()*/ + +#endif /* XP_OS2 */ + +/* Define a macro to support large files */ +#ifdef _LARGEFILE64_SOURCE +#define NSLDAPI_FOPEN( filename, mode ) fopen64( filename, mode ) +#else +#define NSLDAPI_FOPEN( filename, mode ) fopen( filename, mode ) +#endif + +#if defined(LINUX) || defined(AIX) || defined(HPUX) || defined(_WINDOWS) +size_t nsldapi_compat_strlcpy(char *dst, const char *src, size_t len); +#define STRLCPY nsldapi_compat_strlcpy +#else +#define STRLCPY strlcpy +#endif + +#endif /* _PORTABLE_H */
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/proto-ntutil.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/proto-ntutil.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/regex.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/regex.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/include/srchpref.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/include/srchpref.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/Makefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/Makefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/Makefile.in
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/Makefile.in)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/genMakefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/genMakefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libiutil/Makefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libiutil/Makefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libiutil/Makefile.in
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libiutil/Makefile.in)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libiutil/README
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libiutil/README)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libiutil/iutil-lock.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libiutil/iutil-lock.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/liblber/Makefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/liblber/Makefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/liblber/Makefile.in
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/liblber/Makefile.in)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/liblber/bprint.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/liblber/bprint.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/liblber/decode.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/liblber/decode.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/liblber/dtest.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/liblber/dtest.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/liblber/encode.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/liblber/encode.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/liblber/etest.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/liblber/etest.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/liblber/idtest.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/liblber/idtest.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/liblber/io.c
Added
@@ -0,0 +1,1757 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * 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. + */ +/* io.c - ber general i/o routines */ + +#include "lber-int.h" + +#define bergetc( sb, len ) ( sb->sb_ber.ber_end > sb->sb_ber.ber_ptr ? \ + (unsigned char)*sb->sb_ber.ber_ptr++ : \ + ber_filbuf( sb, len )) + +# ifdef macintosh +/* + * MacTCP/OpenTransport + */ +# define read( s, b, l ) tcpread( s, 0, (unsigned char *)b, l, NULL ) +# define MAX_WRITE 65535 +# define BerWrite( sb, b, l ) tcpwrite( sb->sb_sd, (unsigned char *)(b), (l<MAX_WRITE)? l : MAX_WRITE ) +# else /* macintosh */ +# if defined(_WIN32) || defined(_WINDOWS) || defined(XP_OS2) +/* + * 32-bit Windows Socket API (under Windows NT or Windows 95) + */ +# define read( s, b, l ) recv( s, b, l, 0 ) +# define BerWrite( s, b, l ) send( s->sb_sd, b, l, 0 ) +# else /* _WIN32 */ +/* + * everything else (Unix/BSD 4.3 socket API) + */ +# define BerWrite( sb, b, l ) write( sb->sb_sd, b, l ) +# define udp_read( sb, b, l, al ) recvfrom(sb->sb_sd, (char *)b, l, 0, \ + (struct sockaddr *)sb->sb_fromaddr, \ + (al = sizeof(struct sockaddr), &al)) +# define udp_write( sb, b, l ) sendto(sb->sb_sd, (char *)(b), l, 0, \ + (struct sockaddr *)sb->sb_useaddr, sizeof(struct sockaddr)) +# endif /* _WIN32 */ +# endif /* macintosh */ + +#ifndef udp_read +#define udp_read( sb, b, l, al ) CLDAP NOT SUPPORTED +#define udp_write( sb, b, l ) CLDAP NOT SUPPORTED +#endif /* udp_read */ + +#define EXBUFSIZ 1024 +size_t lber_bufsize = EXBUFSIZ; + +#ifdef LDAP_DEBUG +int lber_debug; +#endif + +/* + * function prototypes + */ +static void nslberi_install_compat_io_fns( Sockbuf *sb ); +static int nslberi_extread_compat( int s, void *buf, int len, + struct lextiof_socket_private *arg ); +static int nslberi_extwrite_compat( int s, const void *buf, int len, + struct lextiof_socket_private *arg ); +static ber_tag_t get_tag( Sockbuf *sb, BerElement *ber); +static ber_len_t get_ber_len( BerElement *ber); +static ber_len_t read_len_in_ber( Sockbuf *sb, BerElement *ber); + +/* + * internal global structure for memory allocation callback functions + */ +static struct lber_memalloc_fns nslberi_memalloc_fns; + + +/* + * buffered read from "sb". + * returns value of first character read on success and -1 on error. + */ +static int +ber_filbuf( Sockbuf *sb, ber_slen_t len ) +{ + ssize_t rc; +#ifdef CLDAP + int addrlen; +#endif /* CLDAP */ + + if ( sb->sb_ber.ber_buf == NULL ) { + if ( (sb->sb_ber.ber_buf = (char *)NSLBERI_MALLOC( + READBUFSIZ )) == NULL ) { + return( -1 ); + } + sb->sb_ber.ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER; + sb->sb_ber.ber_ptr = sb->sb_ber.ber_buf; + sb->sb_ber.ber_end = sb->sb_ber.ber_buf; + } + + if ( sb->sb_naddr > 0 ) { +#ifdef CLDAP + rc = udp_read(sb, sb->sb_ber.ber_buf, READBUFSIZ, addrlen ); +#ifdef LDAP_DEBUG + if ( lber_debug ) { + char msg[80]; + sprintf( msg, "ber_filbuf udp_read %d bytes\n", + rc ); + ber_err_print( msg ); + if ( lber_debug > 1 && rc > 0 ) + lber_bprint( sb->sb_ber.ber_buf, rc ); + } +#endif /* LDAP_DEBUG */ +#else /* CLDAP */ + rc = -1; +#endif /* CLDAP */ + } else { + if ( sb->sb_ext_io_fns.lbextiofn_read != NULL ) { + rc = sb->sb_ext_io_fns.lbextiofn_read( + sb->sb_sd, sb->sb_ber.ber_buf, + ((sb->sb_options & LBER_SOCKBUF_OPT_NO_READ_AHEAD) + && (len < READBUFSIZ)) ? len : READBUFSIZ, + sb->sb_ext_io_fns.lbextiofn_socket_arg ); + } else { +#ifdef NSLDAPI_AVOID_OS_SOCKETS + return( -1 ); +#else + rc = read( sb->sb_sd, sb->sb_ber.ber_buf, + ((sb->sb_options & LBER_SOCKBUF_OPT_NO_READ_AHEAD) + && (len < READBUFSIZ)) ? len : READBUFSIZ ); +#endif + } + } + + if ( rc > 0 ) { + sb->sb_ber.ber_ptr = sb->sb_ber.ber_buf + 1; + sb->sb_ber.ber_end = sb->sb_ber.ber_buf + rc; + return( (unsigned char)*sb->sb_ber.ber_buf ); + } + + return( -1 ); +} + + +static ber_int_t +BerRead( Sockbuf *sb, char *buf, ber_slen_t len ) +{ + int c; + ber_int_t nread = 0; + + while (len > 0) + { + ber_int_t inberbuf = sb->sb_ber.ber_end - sb->sb_ber.ber_ptr; + if (inberbuf > 0) + { + size_t tocopy = len > inberbuf ? inberbuf : len; + SAFEMEMCPY(buf, sb->sb_ber.ber_ptr, tocopy); + buf += tocopy; + sb->sb_ber.ber_ptr += tocopy; + nread += tocopy; + len -= tocopy; + } + else + { + c = ber_filbuf(sb, len); + if (c < 0) + { + if (nread > 0) + break; + else + return c; + } + *buf++ = c; + nread++; + len--; + } + } + return (nread); +} + + +/* + * Note: ber_read() only uses the ber_end and ber_ptr elements of ber. + * Functions like ber_get_tag(), ber_skip_tag, and ber_peek_tag() rely on + * that fact, so if this code is changed to use any additional elements of + * the ber structure, those functions will need to be changed as well. + */ +ber_int_t +LDAP_CALL +ber_read( BerElement *ber, char *buf, ber_len_t len ) +{ + ber_len_t actuallen; + ber_uint_t nleft; + + nleft = ber->ber_end - ber->ber_ptr; + actuallen = nleft < len ? nleft : len; + + SAFEMEMCPY( buf, ber->ber_ptr, (size_t)actuallen ); + + ber->ber_ptr += actuallen; + + return( (ber_int_t)actuallen ); +} + +/* + * enlarge the ber buffer. + * return 0 on success, -1 on error. + */ +int +nslberi_ber_realloc( BerElement *ber, ber_len_t len ) +{ + ber_uint_t need, have, total; + size_t have_bytes; + Seqorset *s; + ber_int_t off; + char *oldbuf; + int freeoldbuf = 0; + + ber->ber_buf_reallocs++; + + have_bytes = ber->ber_end - ber->ber_buf; + have = have_bytes / lber_bufsize; + need = (len < lber_bufsize ? 1 : (len + (lber_bufsize - 1)) / lber_bufsize); + total = have * lber_bufsize + need * lber_bufsize * ber->ber_buf_reallocs; + + oldbuf = ber->ber_buf; + + if (ber->ber_buf == NULL) { + if ( (ber->ber_buf = (char *)NSLBERI_MALLOC( (size_t)total )) + == NULL ) { + return( -1 ); + } + ber->ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER; + } else { + if ( !(ber->ber_flags & LBER_FLAG_NO_FREE_BUFFER) ) { + freeoldbuf = 1; + } + /* transition to malloc'd buffer */ + if ( (ber->ber_buf = (char *)NSLBERI_MALLOC( + (size_t)total )) == NULL ) { + return( -1 ); + } + ber->ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER; + /* copy existing data into new malloc'd buffer */ + SAFEMEMCPY( ber->ber_buf, oldbuf, have_bytes ); + } + + ber->ber_end = ber->ber_buf + total; + + /* + * If the stinking thing was moved, we need to go through and + * reset all the sos and ber pointers. Offsets would've been + * a better idea... oh well. + */ + + if ( ber->ber_buf != oldbuf ) { + ber->ber_ptr = ber->ber_buf + (ber->ber_ptr - oldbuf); + + for ( s = ber->ber_sos; s != NULLSEQORSET; s = s->sos_next ) { + off = s->sos_first - oldbuf; + s->sos_first = ber->ber_buf + off; + + off = s->sos_ptr - oldbuf; + s->sos_ptr = ber->ber_buf + off; + } + + if ( freeoldbuf && oldbuf ) { + NSLBERI_FREE( oldbuf ); + } + } + + return( 0 ); +} + +/* + * returns "len" on success and -1 on failure. + */ +ber_int_t +LDAP_CALL +ber_write( BerElement *ber, char *buf, ber_len_t len, int nosos ) +{ + if ( nosos || ber->ber_sos == NULL ) { + if ( ber->ber_ptr + len > ber->ber_end ) { + if ( nslberi_ber_realloc( ber, len ) != 0 ) + return( -1 ); + } + SAFEMEMCPY( ber->ber_ptr, buf, (size_t)len ); + ber->ber_ptr += len; + return( len ); + } else { + if ( ber->ber_sos->sos_ptr + len > ber->ber_end ) { + if ( nslberi_ber_realloc( ber, len ) != 0 ) + return( -1 ); + } + SAFEMEMCPY( ber->ber_sos->sos_ptr, buf, (size_t)len ); + ber->ber_sos->sos_ptr += len; + ber->ber_sos->sos_clen += len; + return( len ); + } +} + +void +LDAP_CALL +ber_free( BerElement *ber, int freebuf ) +{ + if ( ber != NULL ) { + if ( freebuf && + !(ber->ber_flags & LBER_FLAG_NO_FREE_BUFFER)) { + NSLBERI_FREE(ber->ber_buf); + } + NSLBERI_FREE( (char *) ber ); + } +} + +/* + * return >= 0 on success, -1 on failure. + */ +int +LDAP_CALL +ber_flush( Sockbuf *sb, BerElement *ber, int freeit ) +{ + ssize_t nwritten = 0, towrite, rc; + int i = 0; + + if (ber->ber_rwptr == NULL) { + ber->ber_rwptr = ber->ber_buf; + } else if (ber->ber_rwptr >= ber->ber_end) { + /* we will use the ber_rwptr to continue an exited flush, + so if rwptr is not within the buffer we return an error. */ + return( -1 ); + } + + /* writev section - for iDAR only!!! */ + if (sb->sb_ext_io_fns.lbextiofn_writev != NULL) { + + /* add the sizes of the different buffers to write with writev */ + for (towrite = 0, i = 0; i < BER_ARRAY_QUANTITY; ++i) { + /* don't add lengths of null buffers - writev will ignore them */ + if (ber->ber_struct[i].ldapiov_base) { + towrite += ber->ber_struct[i].ldapiov_len; + } + } + + rc = sb->sb_ext_io_fns.lbextiofn_writev(sb->sb_sd, ber->ber_struct, BER_ARRAY_QUANTITY, + sb->sb_ext_io_fns.lbextiofn_socket_arg); + + if ( freeit ) + ber_free( ber, 1 ); + + if (rc >= 0) { + /* return the number of bytes TO BE written */ + return (towrite - rc); + } else { + /* otherwise it's an error */ + return (rc); + } + } /* end writev section */ + + towrite = ber->ber_ptr - ber->ber_rwptr; + +#ifdef LDAP_DEBUG + if ( lber_debug ) { + char msg[80]; + sprintf( msg, "ber_flush: %d bytes to sd %ld%s\n", (int)towrite, + sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)" + : "" ); + ber_err_print( msg ); + if ( lber_debug > 1 ) + lber_bprint( ber->ber_rwptr, towrite ); + } +#endif +#if !defined(macintosh) && !defined(DOS) + if ( sb->sb_options & (LBER_SOCKBUF_OPT_TO_FILE | LBER_SOCKBUF_OPT_TO_FILE_ONLY) ) { + rc = write( sb->sb_copyfd, ber->ber_buf, towrite ); + if ( sb->sb_options & LBER_SOCKBUF_OPT_TO_FILE_ONLY ) { + return( (int)rc ); + } + } +#endif + + nwritten = 0; + do { + if (sb->sb_naddr > 0) { +#ifdef CLDAP + rc = udp_write( sb, ber->ber_buf + nwritten, + (size_t)towrite ); +#else /* CLDAP */ + rc = -1; +#endif /* CLDAP */ + if ( rc <= 0 ) + return( -1 ); + /* fake error if write was not atomic */ + if (rc < towrite) { +#if !defined( macintosh ) && !defined( DOS ) + errno = EMSGSIZE; /* For Win32, see portable.h */ +#endif + return( -1 ); + } + } else { + if ( sb->sb_ext_io_fns.lbextiofn_write != NULL ) { + if ( (rc = sb->sb_ext_io_fns.lbextiofn_write( + sb->sb_sd, ber->ber_rwptr, (size_t)towrite, + sb->sb_ext_io_fns.lbextiofn_socket_arg )) + <= 0 ) { + return( -1 ); + } + } else { +#ifdef NSLDAPI_AVOID_OS_SOCKETS + return( -1 ); +#else + if ( (rc = BerWrite( sb, ber->ber_rwptr, + (size_t) towrite )) <= 0 ) { + return( -1 ); + } +#endif + } + } + towrite -= rc; + nwritten += rc; + ber->ber_rwptr += rc; + } while ( towrite > 0 ); + + if ( freeit ) + ber_free( ber, 1 ); + + return( 0 ); +} + + +/* we pre-allocate a buffer to save the extra malloc later */ +BerElement * +LDAP_CALL +ber_alloc_t( int options ) +{ + BerElement *ber; + + if ( (ber = (BerElement*)NSLBERI_CALLOC( 1, + sizeof(struct berelement) + lber_bufsize )) == NULL ) { + return( NULL ); + } + + /* + * for compatibility with the C LDAP API standard, we recognize + * LBER_USE_DER as LBER_OPT_USE_DER. See lber.h for a bit more info. + */ + if ( options & LBER_USE_DER ) { + options &= ~LBER_USE_DER; + options |= LBER_OPT_USE_DER; + } + + ber->ber_tag = LBER_DEFAULT; + ber->ber_options = options; + ber->ber_buf = (char*)ber + sizeof(struct berelement); + ber->ber_ptr = ber->ber_buf; + ber->ber_end = ber->ber_buf + lber_bufsize; + ber->ber_flags = LBER_FLAG_NO_FREE_BUFFER; + + return( ber ); +} + + +BerElement * +LDAP_CALL +ber_alloc() +{ + return( ber_alloc_t( 0 ) ); +} + +BerElement * +LDAP_CALL +der_alloc() +{ + return( ber_alloc_t( LBER_OPT_USE_DER ) ); +} + +BerElement * +LDAP_CALL +ber_dup( BerElement *ber ) +{ + BerElement *new; + + if ( (new = ber_alloc()) == NULL ) + return( NULL ); + + *new = *ber; + + return( new ); +} + + +void +LDAP_CALL +ber_init_w_nullchar( BerElement *ber, int options ) +{ + (void) memset( (char *)ber, '\0', sizeof(struct berelement) ); + ber->ber_tag = LBER_DEFAULT; + + /* + * For compatibility with the C LDAP API standard, we recognize + * LBER_USE_DER as LBER_OPT_USE_DER. See lber.h for a bit more info. + */ + if ( options & LBER_USE_DER ) { + options &= ~LBER_USE_DER; + options |= LBER_OPT_USE_DER; + } + + ber->ber_options = options; +} + +void +LDAP_CALL +ber_reset( BerElement *ber, int was_writing ) +{ + if ( was_writing ) { + ber->ber_end = ber->ber_ptr; + ber->ber_ptr = ber->ber_buf; + } else { + ber->ber_ptr = ber->ber_end; + } + + ber->ber_rwptr = NULL; + ber->ber_tag_len_read = 0; + + memset(ber->ber_struct, 0, BER_CONTENTS_STRUCT_SIZE); +} + +/* Returns the length of the ber buffer so far, + taking into account sequences/sets also. + CAUTION: Returns 0 on null buffers as well + as 0 on empty buffers! +*/ +size_t +LDAP_CALL +ber_get_buf_datalen( BerElement *ber ) +{ + size_t datalen; + + if ( ( ber == NULL) || ( ber->ber_buf == NULL) || ( ber->ber_ptr == NULL ) ) { + datalen = 0; + } else if (ber->ber_sos == NULLSEQORSET) { + /* there are no sequences or sets yet, + so just subtract ptr from the beginning of the ber buffer */ + datalen = ber->ber_ptr - ber->ber_buf; + } else { + /* sequences exist, so just take the ptr of the sequence + on top of the stack and subtract the beginning of the + buffer from it */ + datalen = ber->ber_sos->sos_ptr - ber->ber_buf; + } + + return datalen; +} + +/* + if buf is 0 then malloc a buffer of length size + returns > 0 on success, 0 otherwise +*/ +int +LDAP_CALL +ber_stack_init(BerElement *ber, int options, char * buf, + size_t size) +{ + if (NULL == ber) + return 0; + + memset(ber, 0, sizeof(*ber)); + + /* + * for compatibility with the C LDAP API standard, we recognize + * LBER_USE_DER as LBER_OPT_USE_DER. See lber.h for a bit more info. + */ + + if ( options & LBER_USE_DER ) { + options &= ~LBER_USE_DER; + options |= LBER_OPT_USE_DER; + } + + ber->ber_tag = LBER_DEFAULT; + ber->ber_options = options; + + if ( ber->ber_buf && !(ber->ber_flags & LBER_FLAG_NO_FREE_BUFFER)) { + NSLBERI_FREE(ber->ber_buf); + } + + if (buf) { + ber->ber_buf = ber->ber_ptr = buf; + ber->ber_flags = LBER_FLAG_NO_FREE_BUFFER; + } else { + ber->ber_buf = ber->ber_ptr = (char *) NSLBERI_MALLOC(size); + } + + ber->ber_end = ber->ber_buf + size; + + return ber->ber_buf != 0; +} + +/* + * This call allows to release only the data part of + * the target Sockbuf. + * Other info of this Sockbuf are kept unchanged. + */ +void +LDAP_CALL +ber_sockbuf_free_data(Sockbuf *p) +{ + if ( p != NULL ) { + if ( p->sb_ber.ber_buf != NULL && + !(p->sb_ber.ber_flags & LBER_FLAG_NO_FREE_BUFFER) ) { + NSLBERI_FREE( p->sb_ber.ber_buf ); + p->sb_ber.ber_buf = NULL; + } + } +} + +/* simply returns ber_buf in the ber ... + explicitly for DS MMR only... +*/ +char * +LDAP_CALL +ber_get_buf_databegin (BerElement * ber) +{ + if (NULL != ber) { + return ber->ber_buf; + } else { + return NULL; + } +} + +#ifdef LDAP_DEBUG + +void +ber_dump( BerElement *ber, int inout ) +{ + char msg[128]; + sprintf( msg, "ber_dump: buf 0x%p, ptr 0x%p, rwptr 0x%p, end 0x%p\n", + ber->ber_buf, ber->ber_ptr, ber->ber_rwptr, ber->ber_end ); + ber_err_print( msg ); + if ( inout == 1 ) { + sprintf( msg, " current len %ld, contents:\n", + (long)(ber->ber_end - ber->ber_ptr) ); + ber_err_print( msg ); + lber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr ); + } else { + sprintf( msg, " current len %ld, contents:\n", + (long)(ber->ber_ptr - ber->ber_buf) ); + ber_err_print( msg ); + lber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf ); + } +} + +void +ber_sos_dump( Seqorset *sos ) +{ + char msg[80]; + ber_err_print ( "*** sos dump ***\n" ); + while ( sos != NULLSEQORSET ) { + sprintf( msg, "ber_sos_dump: clen %d first 0x%p ptr 0x%p\n", + sos->sos_clen, sos->sos_first, sos->sos_ptr ); + ber_err_print( msg ); + sprintf( msg, " current len %ld contents:\n", + (long)(sos->sos_ptr - sos->sos_first) ); + ber_err_print( msg ); + lber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first ); + + sos = sos->sos_next; + } + ber_err_print( "*** end dump ***\n" ); +} + +#endif + +/* return the tag - LBER_DEFAULT returned means trouble + * assumes the tag is only one byte! */ +static ber_tag_t +get_tag( Sockbuf *sb, BerElement *ber) +{ + unsigned char xbyte; + + if ( (BerRead( sb, (char *) &xbyte, 1 )) != 1 ) { + return( LBER_DEFAULT ); + } + + /* we only handle small (one byte) tags */ + if ( (xbyte & LBER_BIG_TAG_MASK) == LBER_BIG_TAG_MASK ) { + return( LBER_DEFAULT ); + } + + ber->ber_tag_contents[0] = xbyte; + ber->ber_struct[BER_STRUCT_TAG].ldapiov_len = 1; + return((ber_tag_t)xbyte); +} + + +/* Error checking? */ +/* Takes a ber and returns the actual length */ +static ber_len_t +get_ber_len( BerElement *ber) +{ + int noctets; + ber_len_t len = 0; + char xbyte; + + xbyte = ber->ber_len_contents[0]; + + /* long form */ + if (xbyte & 0x80) { + noctets = (int) (xbyte & 0x7f); + if (noctets >= MAX_LEN_SIZE) { + return(LBER_DEFAULT); + } + SAFEMEMCPY((char*) &len + sizeof(ber_len_t) - noctets, &ber->ber_len_contents[1], noctets); + len = LBER_NTOHL(len); + return(len); + } else { + return((ber_len_t)(xbyte)); + } +} + +/* LBER_DEFAULT means trouble + reads in the length, stores it in ber->ber_struct, and returns get_ber_len */ +static ber_len_t +read_len_in_ber( Sockbuf *sb, BerElement *ber) +{ + unsigned char xbyte; + int noctets; + int rc = 0, read_result = 0; + + /* + * Next, read the length. The first byte contains the length + * of the length. If bit 8 is set, the length is the long + * form, otherwise it's the short form. We don't allow a + * length that's greater than what we can hold in a ber_int_t + */ + if ( ber->ber_tag_len_read == 1) { + /* the length of the length hasn't been read yet */ + if ( BerRead( sb, (char *) &xbyte, 1 ) != 1 ) { + return( LBER_DEFAULT ); + } + ber->ber_tag_len_read = 2; + ber->ber_len_contents[0] = xbyte; + } else { + rc = ber->ber_tag_len_read - 2; + xbyte = ber->ber_len_contents[0]; + } + + /* long form of the length value */ + if ( xbyte & 0x80 ) { + noctets = (xbyte & 0x7f); + if ( noctets >= MAX_LEN_SIZE ) + return( LBER_DEFAULT ); + while (rc < noctets) { + read_result = BerRead( sb, &(ber->ber_len_contents[1]) + rc, noctets - rc ); + if (read_result <= 0) { + ber->ber_tag_len_read = rc + 2; /* so we can continue later - include tag and lenlen */ + return( LBER_DEFAULT ); + } + rc += read_result; + } + ber->ber_tag_len_read = rc + 2; /* adds tag (1 byte) and lenlen (1 byte) */ + ber->ber_struct[BER_STRUCT_LEN].ldapiov_len = 1 + noctets; + } else { /* short form of the length value */ + ber->ber_struct[BER_STRUCT_LEN].ldapiov_len = 1; + } + return(get_ber_len(ber)); +} + + +ber_tag_t +LDAP_CALL +ber_get_next( Sockbuf *sb, ber_len_t *len, BerElement *ber ) +{ + ber_len_t newlen; + ber_len_t toread; + ber_int_t rc; + ber_len_t orig_taglen_read = 0; + char * orig_rwptr = ber->ber_rwptr ? ber->ber_rwptr : ber->ber_buf; + +#ifdef LDAP_DEBUG + if ( lber_debug ) + ber_err_print( "ber_get_next\n" ); +#endif + + /* + * When rwptr is NULL this signifies that the tag and length have not been + * read in their entirety yet. (if at all) + */ + if ( ber->ber_rwptr == NULL ) { + + /* first save the amount we previously read, so we know what to return in len. */ + orig_taglen_read = ber->ber_tag_len_read; + + /* read the tag - if tag_len_read is greater than 0, then it has already been read. */ + if (ber->ber_tag_len_read == 0) { + if ((ber->ber_tag = get_tag(sb, ber)) == LBER_DEFAULT ) { + *len = 0; + return( LBER_DEFAULT ); + } + + ber->ber_tag_contents[0] = (char)ber->ber_tag; /* we only handle 1 byte tags */ + ber->ber_tag_len_read = 1; + + /* check for validity */ + if((sb->sb_options & LBER_SOCKBUF_OPT_VALID_TAG) && + (ber->ber_tag != sb->sb_valid_tag)) { + *len = 1; /* we just read the tag so far */ + return( LBER_DEFAULT); + } + } + + /* read the length */ + if ((newlen = read_len_in_ber(sb, ber)) == LBER_DEFAULT ) { + *len = ber->ber_tag_len_read - orig_taglen_read; + return( LBER_DEFAULT ); + } + + /* + * Finally, malloc a buffer for the contents and read it in. + * It's this buffer that's passed to all the other ber decoding + * routines. + */ + +#if defined( DOS ) && !( defined( _WIN32 ) || defined(XP_OS2) ) + if ( newlen > 65535 ) { /* DOS can't allocate > 64K */ + return( LBER_DEFAULT ); + } +#endif /* DOS && !_WIN32 */ + + if ( ( sb->sb_options & LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE ) + && newlen > sb->sb_max_incoming ) { + return( LBER_DEFAULT ); + } + + /* check to see if we already have enough memory allocated */ + if ( ((ber_len_t) ber->ber_end - (ber_len_t) ber->ber_buf) < newlen) { + if ( ber->ber_buf && !(ber->ber_flags & LBER_FLAG_NO_FREE_BUFFER)) { + NSLBERI_FREE(ber->ber_buf); + } + if ( (ber->ber_buf = (char *)NSLBERI_CALLOC( 1,(size_t)newlen )) + == NULL ) { + return( LBER_DEFAULT ); + } + ber->ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER; + orig_rwptr = ber->ber_buf; + } + + + ber->ber_len = newlen; + ber->ber_ptr = ber->ber_buf; + ber->ber_end = ber->ber_buf + newlen; + ber->ber_rwptr = ber->ber_buf; + ber->ber_tag_len_read = 0; /* now that rwptr is set, this doesn't matter */ + } + + /* OK, we've malloc-ed the buffer; now read the rest of the expected length */ + toread = (ber_len_t)ber->ber_end - (ber_len_t)ber->ber_rwptr; + do { + if ( (rc = BerRead( sb, ber->ber_rwptr, (ber_int_t)toread )) <= 0 ) { + *len = (ber_len_t) ber->ber_rwptr - (ber_len_t) orig_rwptr; + return( LBER_DEFAULT ); + } + + toread -= rc; + ber->ber_rwptr += rc; + } while ( toread > 0 ); + +#ifdef LDAP_DEBUG + if ( lber_debug ) { + char msg[80]; + sprintf( msg, "ber_get_next: tag 0x%x len %d contents:\n", + ber->ber_tag, ber->ber_len ); + ber_err_print( msg ); + if ( lber_debug > 1 ) + ber_dump( ber, 1 ); + } +#endif + + *len = (ber_len_t) ber->ber_rwptr - (ber_len_t) orig_rwptr; + ber->ber_rwptr = NULL; + ber->ber_struct[BER_STRUCT_VAL].ldapiov_len = ber->ber_len; + return( ber->ber_tag ); +} + +Sockbuf * +LDAP_CALL +ber_sockbuf_alloc() +{ + return( (Sockbuf *)NSLBERI_CALLOC( 1, sizeof(struct sockbuf) ) ); +} + +void +LDAP_CALL +ber_sockbuf_free(Sockbuf *p) +{ + if ( p != NULL ) { + if ( p->sb_ber.ber_buf != NULL && + !(p->sb_ber.ber_flags & LBER_FLAG_NO_FREE_BUFFER) ) { + NSLBERI_FREE( p->sb_ber.ber_buf ); + } + NSLBERI_FREE(p); + } +} + +/* + * return 0 on success and -1 on error + */ +int +LDAP_CALL +ber_set_option( struct berelement *ber, int option, void *value ) +{ + + /* + * memory allocation callbacks are global, so it is OK to pass + * NULL for ber. Handle this as a special case. + */ + if ( option == LBER_OPT_MEMALLOC_FN_PTRS ) { + /* struct copy */ + nslberi_memalloc_fns = *((struct lber_memalloc_fns *)value); + return( 0 ); + } + + /* + * lber_debug is global, so it is OK to pass + * NULL for ber. Handle this as a special case. + */ + if ( option == LBER_OPT_DEBUG_LEVEL ) { +#ifdef LDAP_DEBUG + lber_debug = *(int *)value; +#endif + return( 0 ); + } + + /* + * lber_bufsize is global, so it is OK to pass + * NULL for ber. Handle this as a special case. + */ + if ( option == LBER_OPT_BUFSIZE ) { + if ( *(size_t *)value > EXBUFSIZ ) { + lber_bufsize = *(size_t *)value; + } + return( 0 ); + } + + /* + * all the rest require a non-NULL ber + */ + if ( !NSLBERI_VALID_BERELEMENT_POINTER( ber )) { + return( -1 ); + } + + switch ( option ) { + case LBER_OPT_USE_DER: + case LBER_OPT_TRANSLATE_STRINGS: + if ( value != NULL ) { + ber->ber_options |= option; + } else { + ber->ber_options &= ~option; + } + break; + case LBER_OPT_REMAINING_BYTES: + ber->ber_end = ber->ber_ptr + *((ber_len_t *)value); + break; + case LBER_OPT_TOTAL_BYTES: + ber->ber_end = ber->ber_buf + *((ber_len_t *)value); + break; + case LBER_OPT_BYTES_TO_WRITE: + ber->ber_ptr = ber->ber_buf + *((ber_len_t *)value); + break; + default: + return( -1 ); + } + + return( 0 ); +} + +/* + * return 0 on success and -1 on error + */ +int +LDAP_CALL +ber_get_option( struct berelement *ber, int option, void *value ) +{ + /* + * memory callocation callbacks are global, so it is OK to pass + * NULL for ber. Handle this as a special case + */ + if ( option == LBER_OPT_MEMALLOC_FN_PTRS ) { + /* struct copy */ + *((struct lber_memalloc_fns *)value) = nslberi_memalloc_fns; + return( 0 ); + } + + /* + * lber_debug is global, so it is OK to pass + * NULL for ber. Handle this as a special case. + */ + if ( option == LBER_OPT_DEBUG_LEVEL ) { +#ifdef LDAP_DEBUG + *(int *)value = lber_debug; +#endif + return( 0 ); + } + + /* + * lber_bufsize is global, so it is OK to pass + * NULL for ber. Handle this as a special case. + */ + if ( option == LBER_OPT_BUFSIZE ) { + *(size_t *)value = lber_bufsize; + return( 0 ); + } + + /* + * all the rest require a non-NULL ber + */ + if ( !NSLBERI_VALID_BERELEMENT_POINTER( ber )) { + return( -1 ); + } + + switch ( option ) { + case LBER_OPT_USE_DER: + case LBER_OPT_TRANSLATE_STRINGS: + *((int *) value) = (ber->ber_options & option); + break; + case LBER_OPT_REMAINING_BYTES: + *((ber_len_t *) value) = ber->ber_end - ber->ber_ptr; + break; + case LBER_OPT_TOTAL_BYTES: + *((ber_len_t *) value) = ber->ber_end - ber->ber_buf; + break; + case LBER_OPT_BYTES_TO_WRITE: + *((ber_len_t *) value) = ber->ber_ptr - ber->ber_buf; + break; + default: + return( -1 ); + } + + return( 0 ); +} + +/* + * return 0 on success and -1 on error + */ +int +LDAP_CALL +ber_sockbuf_set_option( Sockbuf *sb, int option, void *value ) +{ + struct lber_x_ext_io_fns *extiofns; + + if ( !NSLBERI_VALID_SOCKBUF_POINTER( sb )) { + return( -1 ); + } + + /* check for a NULL value for certain options. */ + if (NULL == value) { + switch ( option ) { + case LBER_SOCKBUF_OPT_TO_FILE: + case LBER_SOCKBUF_OPT_TO_FILE_ONLY: + case LBER_SOCKBUF_OPT_NO_READ_AHEAD: + case LBER_SOCKBUF_OPT_READ_FN: + case LBER_SOCKBUF_OPT_WRITE_FN: + case LBER_SOCKBUF_OPT_EXT_IO_FNS: + case LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE: + /* do nothing - it's OK to have a NULL value for these options */ + break; + default: + return( -1 ); + } + } + + switch ( option ) { + case LBER_SOCKBUF_OPT_VALID_TAG: + sb->sb_valid_tag= *((ber_tag_t *) value); + /* use NULL to reset */ + if ( value != NULL ) { + sb->sb_options |= option; + } else { + sb->sb_options &= ~option; + } + break; + case LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE: + if ( value != NULL ) { + sb->sb_max_incoming = *((ber_len_t *) value); + sb->sb_options |= option; + } else { + /* setting the max incoming to 0 seems to be the only + way to tell the callers of ber_sockbuf_get_option + that this option isn't set. */ + sb->sb_max_incoming = 0; + sb->sb_options &= ~option; + } + break; + case LBER_SOCKBUF_OPT_TO_FILE: + case LBER_SOCKBUF_OPT_TO_FILE_ONLY: + case LBER_SOCKBUF_OPT_NO_READ_AHEAD: + if ( value != NULL ) { + sb->sb_options |= option; + } else { + sb->sb_options &= ~option; + } + break; + case LBER_SOCKBUF_OPT_DESC: + sb->sb_sd = *((LBER_SOCKET *) value); + break; + case LBER_SOCKBUF_OPT_COPYDESC: + sb->sb_copyfd = *((LBER_SOCKET *) value); + break; + case LBER_SOCKBUF_OPT_READ_FN: + sb->sb_io_fns.lbiof_read = (LDAP_IOF_READ_CALLBACK *) value; + nslberi_install_compat_io_fns( sb ); + break; + case LBER_SOCKBUF_OPT_WRITE_FN: + sb->sb_io_fns.lbiof_write = (LDAP_IOF_WRITE_CALLBACK *) value; + nslberi_install_compat_io_fns( sb ); + break; + case LBER_SOCKBUF_OPT_EXT_IO_FNS: + extiofns = (struct lber_x_ext_io_fns *) value; + if ( extiofns == NULL ) { /* remove */ + (void)memset( (char *)&sb->sb_ext_io_fns, '\0', + sizeof(sb->sb_ext_io_fns )); + } else if ( extiofns->lbextiofn_size + == LBER_X_EXTIO_FNS_SIZE ) { + /* struct copy */ + sb->sb_ext_io_fns = *extiofns; + } else if ( extiofns->lbextiofn_size + == LBER_X_EXTIO_FNS_SIZE_REV0 ) { + /* backwards compatiblity for older struct */ + sb->sb_ext_io_fns.lbextiofn_size = + LBER_X_EXTIO_FNS_SIZE; + sb->sb_ext_io_fns.lbextiofn_read = + extiofns->lbextiofn_read; + sb->sb_ext_io_fns.lbextiofn_write = + extiofns->lbextiofn_write; + sb->sb_ext_io_fns.lbextiofn_writev = NULL; + sb->sb_ext_io_fns.lbextiofn_socket_arg = + extiofns->lbextiofn_socket_arg; + } else { + return( -1 ); + } + break; + case LBER_SOCKBUF_OPT_SOCK_ARG: + sb->sb_ext_io_fns.lbextiofn_socket_arg = + (struct lextiof_socket_private *) value; + break; + default: + return( -1 ); + } + + return( 0 ); +} + +/* + * return 0 on success and -1 on error + */ +int +LDAP_CALL +ber_sockbuf_get_option( Sockbuf *sb, int option, void *value ) +{ + struct lber_x_ext_io_fns *extiofns; + + if ( !NSLBERI_VALID_SOCKBUF_POINTER( sb ) || (NULL == value)) { + return( -1 ); + } + + switch ( option ) { + case LBER_SOCKBUF_OPT_VALID_TAG: + *((ber_tag_t *) value) = sb->sb_valid_tag; + break; + case LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE: + *((ber_len_t *) value) = sb->sb_max_incoming; + break; + case LBER_SOCKBUF_OPT_TO_FILE: + case LBER_SOCKBUF_OPT_TO_FILE_ONLY: + case LBER_SOCKBUF_OPT_NO_READ_AHEAD: + *((int *) value) = (sb->sb_options & option); + break; + case LBER_SOCKBUF_OPT_DESC: + *((LBER_SOCKET *) value) = sb->sb_sd; + break; + case LBER_SOCKBUF_OPT_COPYDESC: + *((LBER_SOCKET *) value) = sb->sb_copyfd; + break; + case LBER_SOCKBUF_OPT_READ_FN: + *((LDAP_IOF_READ_CALLBACK **) value) + = sb->sb_io_fns.lbiof_read; + break; + case LBER_SOCKBUF_OPT_WRITE_FN: + *((LDAP_IOF_WRITE_CALLBACK **) value) + = sb->sb_io_fns.lbiof_write; + break; + case LBER_SOCKBUF_OPT_EXT_IO_FNS: + extiofns = (struct lber_x_ext_io_fns *) value; + if ( extiofns == NULL ) { + return( -1 ); + } else if ( extiofns->lbextiofn_size + == LBER_X_EXTIO_FNS_SIZE ) { + /* struct copy */ + *extiofns = sb->sb_ext_io_fns; + } else if ( extiofns->lbextiofn_size + == LBER_X_EXTIO_FNS_SIZE_REV0 ) { + /* backwards compatiblity for older struct */ + extiofns->lbextiofn_read = sb->sb_ext_io_fns.lbextiofn_read; + extiofns->lbextiofn_write = sb->sb_ext_io_fns.lbextiofn_write; + extiofns->lbextiofn_socket_arg = sb->sb_ext_io_fns.lbextiofn_socket_arg; + } else { + return( -1 ); + } + break; + case LBER_SOCKBUF_OPT_SOCK_ARG: + *((struct lextiof_socket_private **)value) = sb->sb_ext_io_fns.lbextiofn_socket_arg; + break; + default: + return( -1 ); + } + + return( 0 ); +} + + +/* new dboreham code below: */ + +struct byte_buffer { + unsigned char *p; + int offset; + int length; +}; +typedef struct byte_buffer byte_buffer; + + +/* This call allocates us a BerElement structure plus some extra memory. + * It returns a pointer to the BerElement, plus a pointer to the extra memory. + * This routine also allocates a ber data buffer within the same block, thus + * saving a call to calloc later when we read data. + */ +void* +LDAP_CALL +ber_special_alloc(size_t size, BerElement **ppBer) +{ + char *mem = NULL; + + /* Make sure mem size requested is aligned */ + if (0 != ( size & 0x03 )) { + size += (sizeof(ber_int_t) - (size & 0x03)); + } + + mem = NSLBERI_MALLOC(sizeof(struct berelement) + lber_bufsize + size ); + if (NULL == mem) { + return NULL; + } + *ppBer = (BerElement*) (mem + size); + memset(*ppBer,0,sizeof(struct berelement)); + (*ppBer)->ber_tag = LBER_DEFAULT; + (*ppBer)->ber_buf = mem + size + sizeof(struct berelement); + (*ppBer)->ber_ptr = (*ppBer)->ber_buf; + (*ppBer)->ber_end = (*ppBer)->ber_buf + lber_bufsize; + (*ppBer)->ber_flags = LBER_FLAG_NO_FREE_BUFFER; + return (void*)mem; +} + +void +LDAP_CALL +ber_special_free(void* buf, BerElement *ber) +{ + if (!(ber->ber_flags & LBER_FLAG_NO_FREE_BUFFER)) { + NSLBERI_FREE(ber->ber_buf); + } + NSLBERI_FREE( buf ); +} + +/* Copy up to bytes_to_read bytes from b into return_buffer. + * Returns a count of bytes copied (always >= 0). + */ +static int +read_bytes(byte_buffer *b, unsigned char *return_buffer, int bytes_to_read) +{ + /* copy up to bytes_to_read bytes into the caller's buffer, return the number of bytes copied */ + int bytes_to_copy = 0; + + if (bytes_to_read <= (b->length - b->offset) ) { + bytes_to_copy = bytes_to_read; + } else { + bytes_to_copy = (b->length - b->offset); + } + if (1 == bytes_to_copy) { + *return_buffer = *(b->p+b->offset++); + } else if (bytes_to_copy <= 0) { + bytes_to_copy = 0; /* never return a negative result */ + } else { + SAFEMEMCPY(return_buffer,b->p+b->offset,bytes_to_copy); + b->offset += bytes_to_copy; + } + return bytes_to_copy; +} + +/* return the tag - LBER_DEFAULT returned means trouble */ +static ber_tag_t +get_buffer_tag(byte_buffer *sb ) +{ + unsigned char xbyte; + ber_tag_t tag; + char *tagp; + int i; + + if ( (i = read_bytes( sb, &xbyte, 1 )) != 1 ) { + return( LBER_DEFAULT ); + } + + if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK ) { + return( (ber_uint_t) xbyte ); + } + + tagp = (char *) &tag; + tagp[0] = xbyte; + for ( i = 1; i < sizeof(ber_int_t); i++ ) { + if ( read_bytes( sb, &xbyte, 1 ) != 1 ) + return( LBER_DEFAULT ); + + tagp[i] = xbyte; + + if ( ! (xbyte & LBER_MORE_TAG_MASK) ) + break; + } + + /* tag too big! */ + if ( i == sizeof(ber_int_t) ) + return( LBER_DEFAULT ); + + /* want leading, not trailing 0's */ + return( tag >> (sizeof(ber_int_t) - i - 1) ); +} + +/* Like ber_get_next, but from a byte buffer the caller already has. */ +/* Bytes_Scanned returns the number of bytes we actually looked at in the buffer. */ +/* ber_get_next_buffer is now implemented in terms of ber_get_next_buffer_ext */ +/* and is here for backward compatibility. This new function allows us to pass */ +/* the Sockbuf structure along */ + +ber_uint_t +LDAP_CALL +ber_get_next_buffer( void *buffer, size_t buffer_size, ber_len_t *len, + BerElement *ber, ber_uint_t *Bytes_Scanned ) +{ + return (ber_get_next_buffer_ext( buffer, buffer_size, len, ber, + Bytes_Scanned, NULL)); +} + +/* + * Returns the tag of the message or LBER_ return code if an error occurs. + * + * If there was not enough data in the buffer to complete the message this + * is a "soft" error. In this case, *Bytes_Scanned is set to a positive + * number and return code is set to LBER_DEFAULT. + * + * On overflow condition when the length is either bigger than ber_uint_t + * type or the value preset via LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE option, + * *Bytes_Scanned is set to zero and return code is set to LBER_OVERFLOW. + * + * For backward compatibility errno is also set on these error conditions: + * + * EINVAL - LBER_SOCKBUF_OPT_VALID_TAG option set but tag doesnt match. + * EMSGSIZE - an overflow condition as described above for LBER_OVERFLOW. + */ +ber_uint_t +LDAP_CALL +ber_get_next_buffer_ext( void *buffer, size_t buffer_size, ber_len_t *len, + BerElement *ber, ber_uint_t *Bytes_Scanned, Sockbuf *sock ) +{ + ber_tag_t tag = 0; + ber_len_t netlen; + ber_len_t toread; + unsigned char lc; + ssize_t rc; + int noctets, diff; + byte_buffer sb = {0}; + + + /* + * Any ber element looks like this: tag length contents. + * Assuming everything's ok, we return the tag byte (we + * can assume a single byte), return the length in len, + * and the rest of the undecoded element in buf. + * + * Assumptions: + * 1) small tags (less than 128) + * 2) definite lengths + * 3) primitive encodings used whenever possible + */ + + /* + * first time through - malloc the buffer, set up ptrs, and + * read the tag and the length and as much of the rest as we can + */ + + sb.p = buffer; + sb.length = buffer_size; + + if ( ber->ber_rwptr == NULL ) { + + /* + * First, we read the tag. + */ + + /* if we have been called before with a fragment not + * containing a complete length, we have no rwptr but + * a tag already + */ + if ( ber->ber_tag == LBER_DEFAULT ) { + if ( (tag = get_buffer_tag( &sb )) == LBER_DEFAULT ) { + goto premature_exit; + } + ber->ber_tag = tag; + } + + if((sock->sb_options & LBER_SOCKBUF_OPT_VALID_TAG) && + (ber->ber_tag != sock->sb_valid_tag)) { +#if !defined( macintosh ) && !defined( DOS ) + errno = EINVAL; +#endif + goto error_exit; + } + + /* If we have been called before with an incomplete length, + * the fragment of the length read is in ber->ber_len_contents + * ber->ber_tag_len_read is the # of bytes of the length available + * from a previous fragment + */ + + if (ber->ber_tag_len_read) { + int nbytes; + + noctets = ((ber->ber_len_contents[0]) & 0x7f); + diff = noctets + 1 /* tag */ - ber->ber_tag_len_read; + + if ( (nbytes = read_bytes( &sb, (unsigned char *) &ber->ber_len_contents[0] + + ber->ber_tag_len_read, diff )) != diff ) { + + if (nbytes > 0) + ber->ber_tag_len_read+=nbytes; + + goto premature_exit; + } + *len = get_ber_len(ber); /* cast ber->ber_len_contents to unsigned long */ + + } else { + /* + * Next, read the length. The first byte contains the length + * of the length. If bit 8 is set, the length is the long + * form, otherwise it's the short form. We don't allow a + * length that's greater than what we can hold in an unsigned + * long. + */ + + *len = netlen = 0; + if ( read_bytes( &sb, &lc, 1 ) != 1 ) { + goto premature_exit; + } + if ( lc & 0x80 ) { + int nbytes; + + noctets = (lc & 0x7f); + if ( noctets > sizeof(ber_uint_t) ) { +#if !defined( macintosh ) && !defined( DOS ) + errno = EMSGSIZE; +#endif + *Bytes_Scanned = 0; + return(LBER_OVERFLOW); + } + diff = sizeof(ber_uint_t) - noctets; + if ( (nbytes = read_bytes( &sb, (unsigned char *)&netlen + diff, + noctets )) != noctets ) { + /* + * The length is in long form and we don't get it in one + * fragment, so stash partial length in the ber element + * for later use + */ + + ber->ber_tag_len_read = nbytes + 1; + ber->ber_len_contents[0]=lc; + memset(&(ber->ber_len_contents[1]), 0, sizeof(ber_uint_t)); + SAFEMEMCPY(&(ber->ber_len_contents[1]), (unsigned char *)&netlen + diff, nbytes); + + goto premature_exit; + } + *len = LBER_NTOHL( netlen ); + } else { + *len = lc; + } + } + + ber->ber_len = *len; + /* length fully decoded */ + ber->ber_tag_len_read=0; + /* + * Finally, malloc a buffer for the contents and read it in. + * It's this buffer that's passed to all the other ber decoding + * routines. + */ + +#if defined( DOS ) && !defined( _WIN32 ) + if ( *len > 65535 ) { /* DOS can't allocate > 64K */ + goto premature_exit; + } +#endif /* DOS && !_WIN32 */ + + if ( (sock != NULL) && + ( sock->sb_options & LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE ) + && (*len > sock->sb_max_incoming) ) { +#if !defined( macintosh ) && !defined( DOS ) + errno = EMSGSIZE; +#endif + *Bytes_Scanned = 0; + return( LBER_OVERFLOW ); + } + + if ( ber->ber_buf + *len > ber->ber_end ) { + if ( nslberi_ber_realloc( ber, *len ) != 0 ) + goto error_exit; + } + ber->ber_ptr = ber->ber_buf; + ber->ber_end = ber->ber_buf + *len; + ber->ber_rwptr = ber->ber_buf; + } + + toread = (ber_len_t)ber->ber_end - (ber_len_t)ber->ber_rwptr; + do { + if ( (rc = read_bytes( &sb, (unsigned char *)ber->ber_rwptr, + (ber_int_t)toread )) <= 0 ) { + goto premature_exit; + } + + toread -= rc; + ber->ber_rwptr += rc; + } while ( toread > 0 ); + + *len = ber->ber_len; + *Bytes_Scanned = sb.offset; + return( ber->ber_tag ); + +premature_exit: + /* + * we're here because we hit the end of the buffer before seeing + * all of the PDU + */ + *Bytes_Scanned = sb.offset; + return(LBER_DEFAULT); + +error_exit: + *Bytes_Scanned = 0; + return(LBER_DEFAULT); +} + + +/* The ber_flatten routine allocates a struct berval whose contents + * are a BER encoding taken from the ber argument. The bvPtr pointer + * points to the returned berval, which must be freed using + * ber_bvfree(). This routine returns 0 on success and -1 on error. + * The use of ber_flatten on a BerElement in which all '{' and '}' + * format modifiers have not been properly matched can result in a + * berval whose contents are not a valid BER encoding. + * Note that the ber_ptr is not modified. + */ +int +LDAP_CALL +ber_flatten( BerElement *ber, struct berval **bvPtr ) +{ + struct berval *new; + ber_len_t len; + + /* allocate a struct berval */ + if ( (new = (struct berval *)NSLBERI_MALLOC( sizeof(struct berval) )) + == NULL ) { + return( -1 ); + } + + /* + * Copy everything from the BerElement's ber_buf to ber_ptr + * into the berval structure. + */ + if ( ber == NULL ) { + new->bv_val = NULL; + new->bv_len = 0; + } else { + len = ber->ber_ptr - ber->ber_buf; + if ( ( new->bv_val = (char *)NSLBERI_MALLOC( len + 1 )) == NULL ) { + ber_bvfree( new ); + return( -1 ); + } + SAFEMEMCPY( new->bv_val, ber->ber_buf, (size_t)len ); + new->bv_val[len] = '\0'; + new->bv_len = len; + } + + /* set bvPtr pointer to point to the returned berval */ + *bvPtr = new; + + return( 0 ); +} + + +/* + * The ber_init function constructs and returns a new BerElement + * containing a copy of the data in the bv argument. ber_init + * returns the null pointer on error. + */ +BerElement * +LDAP_CALL +ber_init( const struct berval *bv ) +{ + BerElement *ber; + + /* construct BerElement */ + if (( ber = ber_alloc_t( 0 )) != NULLBER ) { + /* copy data from the bv argument into BerElement */ + /* XXXmcs: had to cast unsigned long bv_len to long */ + if ( (ber_write ( ber, bv->bv_val, bv->bv_len, 0 )) + != (ber_slen_t)bv->bv_len ) { + ber_free( ber, 1 ); + return( NULL ); + } + } + + /* + * reset ber_ptr back to the beginning of buffer so that this new + * and initialized ber element can be READ + */ + ber_reset( ber, 1); + + /* + * return a ptr to a new BerElement containing a copy of the data + * in the bv argument or a null pointer on error + */ + return( ber ); +} + + +/* + * memory allocation functions. + */ +void * +nslberi_malloc( size_t size ) +{ + return( nslberi_memalloc_fns.lbermem_malloc == NULL ? + malloc( size ) : + nslberi_memalloc_fns.lbermem_malloc( size )); +} + + +void * +nslberi_calloc( size_t nelem, size_t elsize ) +{ + return( nslberi_memalloc_fns.lbermem_calloc == NULL ? + calloc( nelem, elsize ) : + nslberi_memalloc_fns.lbermem_calloc( nelem, elsize )); +} + + +void * +nslberi_realloc( void *ptr, size_t size ) +{ + return( nslberi_memalloc_fns.lbermem_realloc == NULL ? + realloc( ptr, size ) : + nslberi_memalloc_fns.lbermem_realloc( ptr, size )); +} + + +void +nslberi_free( void *ptr ) +{ + if ( nslberi_memalloc_fns.lbermem_free == NULL ) { + free( ptr ); + } else { + nslberi_memalloc_fns.lbermem_free( ptr ); + } +} + + +/* + ****************************************************************************** + * functions to bridge the gap between new extended I/O functions that are + * installed using ber_sockbuf_set_option( ..., LBER_SOCKBUF_OPT_EXT_IO_FNS, + * ... ). + * + * the basic strategy is to use the new extended arg to hold a pointer to the + * Sockbuf itself so we can find the old functions and call them. + * note that the integer socket s passed in is not used. we use the sb_sd + * from the Sockbuf itself because it is the correct type. + */ +static int +nslberi_extread_compat( int s, void *buf, int len, + struct lextiof_socket_private *arg ) +{ + Sockbuf *sb = (Sockbuf *)arg; + + return( sb->sb_io_fns.lbiof_read( sb->sb_sd, buf, len )); +} + + +static int +nslberi_extwrite_compat( int s, const void *buf, int len, + struct lextiof_socket_private *arg ) +{ + Sockbuf *sb = (Sockbuf *)arg; + + return( sb->sb_io_fns.lbiof_write( sb->sb_sd, buf, len )); +} + + +/* + * Install I/O compatiblity functions. This can't fail. + */ +static void +nslberi_install_compat_io_fns( Sockbuf *sb ) +{ + sb->sb_ext_io_fns.lbextiofn_size = LBER_X_EXTIO_FNS_SIZE; + sb->sb_ext_io_fns.lbextiofn_read = nslberi_extread_compat; + sb->sb_ext_io_fns.lbextiofn_write = nslberi_extwrite_compat; + sb->sb_ext_io_fns.lbextiofn_writev = NULL; + sb->sb_ext_io_fns.lbextiofn_socket_arg = (void *)sb; +} +/* + * end of compat I/O functions + ****************************************************************************** + */
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/liblber/lber-int.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/liblber/lber-int.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap.ex
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap.ex)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/Makefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/Makefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/Makefile.in
Added
@@ -0,0 +1,371 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is Mozilla Communicator client code, released +# March 31, 1998. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-1999 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +MOD_DEPTH = ../../.. +srcdir = @srcdir@ +topsrcdir = @top_srcdir@ +SASL_CFLAGS = @SASL_CFLAGS@ +SASL_LIBS = @SASL_LIBS@ +HAVE_SASL = @HAVE_SASL@ + +include $(MOD_DEPTH)/config/autoconf.mk +include $(topsrcdir)/build.mk + +SRCS = abandon.c \ + add.c \ + authzidctrl.c \ + bind.c \ + cache.c \ + charray.c \ + charset.c \ + compare.c \ + compat.c \ + control.c \ + countvalues.c \ + delete.c \ + disptmpl.c \ + dsparse.c \ + error.c \ + extendop.c \ + free.c \ + freevalues.c \ + friendly.c \ + getattr.c \ + getdn.c \ + getdxbyname.c \ + geteffectiverightsctrl.c \ + getentry.c \ + getfilter.c \ + getoption.c \ + getvalues.c \ + memcache.c \ + message.c \ + modify.c \ + open.c \ + os-ip.c \ + proxyauthctrl.c \ + psearch.c \ + pwmodext.c \ + pwpctrl.c \ + referral.c \ + regex.c \ + rename.c \ + request.c \ + reslist.c \ + result.c \ + saslbind.c \ + sbind.c \ + search.c \ + setoption.c \ + sort.c \ + sortctrl.c \ + srchpref.c \ + tmplout.c \ + ufn.c \ + unbind.c \ + unescape.c \ + url.c \ + userstatusctrl.c \ + utf8.c \ + vlistctrl.c \ + whoami.c + +ifeq ($(HAVE_SASL), 1) +SRCS += saslio.c +endif + +ifeq ($(OS_ARCH),WINNT) +SRCS += dllmain.c \ + mozock.c +endif +RELEASE_LIBS = $(SHARED_LIBRARY) $(DLLLDAP) + +REALOBJS = $(SRCS:.c=.$(OBJ_SUFFIX)) +OBJS = $(addprefix $(OBJDIR_NAME)/, $(REALOBJS)) + +DISTHDIR = $(DIST)/public/ldap +HDIR = $(topsrcdir)/ldap/include + +LIBLDAP = $(addprefix $(OBJDIR_NAME)/, $(LIB_PREFIX)$(LDAP_LIBNAME).$(LIB_SUFFIX)) +DLLLDAP = $(addprefix $(OBJDIR_NAME)/, $(LIB_PREFIX)$(LDAP_LIBNAME).$(DLL_SUFFIX)) + +INSTALLDIR = $(DIST)/$(OBJDIR_NAME) + +include $(topsrcdir)/config/rules.mk + +GARBAGE += $(LIBLDAP) $(DLLLDAP) + +LOCAL_INCLUDES = -I$(PUBLIC)/nspr +INCLUDES += -I$(DISTHDIR) -I$(HDIR) -I$(INSTALLDIR)/public + +ifeq ($(HAVE_SASL), 1) +INCLUDES += $(SASL_CFLAGS) +endif + +DEFINES += $(DEFS) -UMOZILLA_CLIENT + +ifdef USE_PTHREADS +DEFINES += -DUSE_PTHREADS +endif + +ifeq ($(OS_ARCH),WINNT) +PLATFORMCFLAGS = -DNEEDPROTOS +else +PLATFORMCFLAGS = -DUSE_WAITPID -DNEEDPROTOS +endif +THREADS = +THREADSLIB = + +ETCFILENAMES = ldapfilter.conf \ + ldapfriendly \ + ldapsearchprefs.conf \ + ldaptemplates.conf \ + $(NULL) + +ETCDIR = $(INSTALLDIR)/etc +ETCFILES = $(addprefix $(srcdir)/, $(ETCFILENAMES)) + +# +# if you want things to run in a different directory from where they +# are installed, set this accordingly (this path gets compiled into a +# few binaries). otherwise, leave it alone. +# +RUNTIMEETCDIR = $(ETCDIR) + +# +# shared library symbol export definitions +# +ifeq ($(USE_DLL_EXPORTS_FILE), 1) +ifeq ($(OS_ARCH), WINNT) +GENEXPORTS=cmd /c $(PERL) $(topsrcdir)/ldap/build/genexports.pl +else +GENEXPORTS=$(PERL) $(topsrcdir)/ldap/build/genexports.pl +endif + +# variable definitions for exported symbols +ifeq ($(OS_ARCH), WINNT) + LDAP_EXPORT_DEFS= $(WIN_TOP_SRC)/ldap/libraries/msdos/winsock/nsldap32.def +else +ifeq ($(OS_ARCH), OS2) + LDAP_EXPORT_DEFS= $(OBJDIR_NAME)/libldap.def +else + LDAP_EXPORT_DEFS= $(OBJDIR_NAME)/libldap.exp +endif +GARBAGE += $(LDAP_EXPORT_DEFS) +endif + +LDAP_EXPORT_FLAGS=$(addprefix $(DLLEXPORTS_PREFIX), $(LDAP_EXPORT_DEFS)) + +GENEXPARGS=$(BUILD_DEBUG) $(LDAPVERS_SUFFIX) $(LDAPVERS) +endif # USE_DLL_EXPORTS_FILE + +ifeq ($(OS_ARCH), SunOS) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) +endif + +ifeq ($(OS_ARCH), IRIX) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) $(OS_LIBS) -lc +endif + +ifeq ($(OS_ARCH), Linux) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) +endif + +ifeq ($(OS_ARCH), WINNT) +ifdef NS_USE_GCC +EXTRA_DLL_LIBS=-L$(dist_libdir) -l$(LBER_LIBNAME) +else +EXTRA_LIBS =wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib \ + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \ + rpcrt4.lib uuid.lib winmm.lib +EXTRA_LIBS += $(dist_libdir)/$(LDIF_LIBNAME).lib +EXTRA_LIBS += $(dist_libdir)/$(LBER_LIBNAME).lib +endif +endif + +ifeq ($(OS_ARCH), OS2) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) $(OS_LIBS) +endif + +ifeq ($(OS_ARCH), OSF1) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) +EXTRA_LIBS += -L/usr/lib -lcxx -lpthread -lrt -lmach -lexc +endif + +ifeq ($(OS_ARCH), AIX) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) +EXTRA_LIBS += -ldl -brtl -lpthreads -lc_r -lm +endif + +ifeq ($(OS_ARCH), HP-UX) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) +ifdef USE_PTHREADS +EXTRA_LIBS += -ldld -lm -lpthread +else +EXTRA_LIBS += -ldld -lm +endif +endif + +ifeq ($(OS_ARCH), Darwin) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) +endif + +ifeq ($(OS_ARCH), OpenVMS) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) $(OS_LIBS) +SHARED_LIBRARY_LIBS = $(dist_libdir)/lib$(LBER_LIBNAME).a +endif + +ifeq ($(OS_ARCH), BeOS) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -lbe +endif + +ifeq ($(OS_ARCH), NetBSD) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) +endif + +ifeq ($(OS_ARCH), OpenBSD) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -pthread +endif + +ifeq ($(OS_ARCH), DragonFly) +EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) +endif + +ifeq ($(HAVE_SASL), 1) +EXTRA_LIBS += $(SASL_LINK) +endif + +########################################################################### + +ifeq ($(USE_DLL_EXPORTS_FILE), 1) +# recursive gmake rule to create exported symbols file +$(LDAP_EXPORT_DEFS):: $(srcdir)/../libldap.ex +ifeq ($(OS_ARCH), WINNT) + $(GENEXPORTS) Win32 $(srcdir)/../msdos/winsock/nsldap32.tdf $< $(GENEXPARGS) > $@ +else +ifeq ($(OS_ARCH), OS2) + echo LIBRARY $(LDAP_LIBNAME) INITINSTANCE TERMINSTANCE > $@ + echo PROTMODE >> $@ + echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@ + echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@ + echo EXPORTS >> $@ + $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) >> $@ +else + $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) > $@ +endif +endif +endif # USE_DLL_EXPORTS_FILE + +versiont.c: Makefile.client Version.c + @$(RM) $@ + @(u="$${USER-root}" v="$(shell cat ../../build/version)" d="$(shell pwd)" \ + h="$(shell hostname)" t="$(shell date)"; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < Version.c > $@) + +# Set the default sources for the export target +EXPDEPS = $(OBJDIR_NAME) $(LIBDIR) $(OBJS) $(LIBLDAP) $(DLLLDAP) +# Remove the LIB source if on win32 and using MSVC +# This avoids problems with -jX builds where 'link' will make both the +# .dll and .lib files in one pass +ifeq ($(OS_ARCH), WINNT) +ifeq ($(LD),link) +EXPDEPS = $(OBJDIR_NAME) $(LIBDIR) $(OBJS) $(DLLLDAP) +endif +endif + +export:: $(EXPDEPS) + +ltest:: $(LIBLDAP) test.o + $(LINK_EXE) test.o + +$(LIBDIR): + $(MKDIR) $(LIBDIR) + +$(LIBLDAP): $(OBJS) $(LIBDIR) $(LDAP_EXPORT_DEFS) + @echo ======= making $(LIBLDAP) +ifdef SO_FILES_TO_REMOVE + -$(RM) $(SO_FILES_TO_REMOVE) +endif +ifneq (,$(filter AIX Linux HP-UX Darwin BeOS QNX NetBSD OSF1 OpenBSD, $(OS_ARCH))) + $(LINK_LIB) +else +ifeq ($(OS_ARCH),OS2) +# create import library for OS/2 + rm -f $@ + $(IMPLIB) $@ $(LDAP_EXPORT_DEFS) +else + $(LINK_LIB) +endif +endif + +$(DLLLDAP): $(OBJS) $(LIBDIR) $(LDAP_EXPORT_DEFS) + @echo ======= making $(DLLLDAP) +ifdef SO_FILES_TO_REMOVE + -$(RM) $(SO_FILES_TO_REMOVE) +endif + $(LINK_DLL) $(LDAP_EXPORT_FLAGS) $(EXTRA_LIBS) + +veryclean:: clean + +# the $(dist_bindir) line is for the mozilla client, which for reasons +# unknown wants shared libraries in /bin also +# +# Set the default sources for the export target +EXPDEPS2 = $(LIBLDAP) $(DLLLDAP) +# Remove the LIB source if on win32 and using MSVC +# This avoids problems with -jX builds where 'link' will make both the +# .dll and .lib files in one pass +ifeq ($(OS_ARCH), WINNT) +ifeq ($(LD),link) +EXPDEPS2 = $(DLLLDAP) +endif +endif + +export:: $(EXPDEPS2) +ifdef MKSHLIB + $(INSTALL) -m 444 $(LIBLDAP) $(dist_libdir) + $(INSTALL) -m 444 $(DLLLDAP) $(dist_libdir) + $(INSTALL) -m 444 $(DLLLDAP) $(dist_bindir) +endif +ifeq ($(OS_ARCH), WINNT) + $(INSTALL) -m 444 $(LIBLDAP) $(dist_libdir) + $(INSTALL) -m 444 $(DLLLDAP) $(dist_libdir) +endif + $(INSTALL) -m 444 $(ETCFILES) $(ETCDIR)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/abandon.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/abandon.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/add.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/add.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/authzidctrl.c
Added
@@ -0,0 +1,157 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Sun LDAP C SDK. + * + * The Initial Developer of the Original Code is Sun Microsystems, Inc. + * + * Portions created by Sun Microsystems, Inc are Copyright (C) 2005 + * Sun Microsystems, Inc. All Rights Reserved. + * + * Contributor(s): abobrov@sun.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "ldap-int.h" + +/* ldap_create_authzid_control: + +Parameters are + +ld LDAP pointer to the desired connection + +ctl_iscritical Indicates whether the control is critical of not. + If this field is non-zero, the operation will only be + carried out if the control is recognized by the server + and/or client + +ctrlp the address of a place to put the constructed control +*/ + +int +LDAP_CALL +ldap_create_authzid_control ( + LDAP *ld, + const char ctl_iscritical, + LDAPControl **ctrlp + ) +{ + int rc; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + return( LDAP_PARAM_ERROR ); + } + + if ( ctrlp == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return ( LDAP_PARAM_ERROR ); + } + + rc = nsldapi_build_control( LDAP_CONTROL_AUTHZID_REQ, + NULL, 0, ctl_iscritical, ctrlp ); + + LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); + return( rc ); +} + +/* ldap_parse_authzid_control: + +Parameters are + +ld LDAP pointer to the desired connection + +ctrlp An array of controls obtained from calling + ldap_parse_result on the set of results + returned by the server + +authzid authorization identity, as defined in + RFC 2829, section 9. +*/ + +int +LDAP_CALL +ldap_parse_authzid_control ( + LDAP *ld, + LDAPControl **ctrlp, + char **authzid + ) +{ + int i, foundAUTHZIDControl; + char *authzidp = NULL; + LDAPControl *AUTHZIDCtrlp = NULL; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) ) { + return( LDAP_PARAM_ERROR ); + } + + /* find the control in the list of controls if it exists */ + if ( ctrlp == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); + return ( LDAP_CONTROL_NOT_FOUND ); + } + foundAUTHZIDControl = 0; + for ( i = 0; (( ctrlp[i] != NULL ) && ( !foundAUTHZIDControl )); i++ ) { + foundAUTHZIDControl = !strcmp( ctrlp[i]->ldctl_oid, + LDAP_CONTROL_AUTHZID_RES ); + } + + /* + * The control is only included in a bind response if the resultCode + * for the bind operation is success. + */ + if ( !foundAUTHZIDControl ) { + LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); + return ( LDAP_CONTROL_NOT_FOUND ); + } else { + /* let local var point to the control */ + AUTHZIDCtrlp = ctrlp[i-1]; + } + + /* + * If the bind request succeeded and resulted in an identity (not anonymous), + * the controlValue contains the authorization identity (authzid), as + * defined in [AUTH] section 9, granted to the requestor. If the bind + * request resulted in an anonymous association, the controlValue field + * is a string of zero length. If the bind request resulted in more + * than one authzid, the primary authzid is returned in the controlValue + * field. + */ + if ( AUTHZIDCtrlp && AUTHZIDCtrlp->ldctl_value.bv_val && + AUTHZIDCtrlp->ldctl_value.bv_len ) { + authzidp = ( (char *)NSLDAPI_MALLOC( + ( AUTHZIDCtrlp->ldctl_value.bv_len + 1 ) ) ); + if ( authzidp == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); + return( LDAP_NO_MEMORY ); + } + STRLCPY( authzidp, AUTHZIDCtrlp->ldctl_value.bv_val, + ( AUTHZIDCtrlp->ldctl_value.bv_len + 1 ) ); + *authzid = authzidp; + } else { + authzid = NULL; + } + + return( LDAP_SUCCESS ); +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/bind.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/bind.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/cache.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/cache.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/charray.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/charray.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/charset.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/charset.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/cldap.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/cldap.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/compare.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/compare.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/compat.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/compat.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/control.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/control.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/countvalues.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/countvalues.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/delete.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/delete.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/disptmpl.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/disptmpl.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/dllmain.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/dllmain.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/dsparse.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/dsparse.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/error.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/error.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/extendop.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/extendop.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/fdsetsize.txt
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/fdsetsize.txt)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/free.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/free.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/freevalues.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/freevalues.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/friendly.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/friendly.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/getattr.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/getattr.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/getdn.c
Added
@@ -0,0 +1,371 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +/* + * Copyright (c) 1994 Regents of the University of Michigan. + * All rights reserved. + */ +/* + * getdn.c + */ + +#if 0 +#ifndef lint +static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; +#endif +#endif + +#include "ldap-int.h" + +char * +LDAP_CALL +ldap_get_dn( LDAP *ld, LDAPMessage *entry ) +{ + char *dn; + struct berelement tmp; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_get_dn\n", 0, 0, 0 ); + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + return( NULL ); /* punt */ + } + + if ( !NSLDAPI_VALID_LDAPMESSAGE_ENTRY_POINTER( entry )) { + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return( NULL ); + } + + tmp = *entry->lm_ber; /* struct copy */ + if ( ber_scanf( &tmp, "{a", &dn ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + return( NULL ); + } + + return( dn ); +} + +char * +LDAP_CALL +ldap_dn2ufn( const char *dn ) +{ + char *p, *ufn, *r; + size_t plen; + int state; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_dn2ufn\n", 0, 0, 0 ); + + if ( dn == NULL ) { + dn = ""; + } + + if ( ldap_is_dns_dn( dn ) || ( p = strchr( dn, '=' )) == NULL ) + return( nsldapi_strdup( (char *)dn )); + + ufn = nsldapi_strdup( ++p ); + +#define INQUOTE 1 +#define OUTQUOTE 2 + state = OUTQUOTE; + for ( p = ufn, r = ufn; *p; p += plen ) { + plen = 1; + switch ( *p ) { + case '\\': + if ( *++p == '\0' ) + plen=0; + else { + *r++ = '\\'; + r += (plen = LDAP_UTF8COPY(r,p)); + } + break; + case '"': + if ( state == INQUOTE ) + state = OUTQUOTE; + else + state = INQUOTE; + *r++ = *p; + break; + case ';': + case ',': + if ( state == OUTQUOTE ) + *r++ = ','; + else + *r++ = *p; + break; + case '=': + if ( state == INQUOTE ) + *r++ = *p; + else { + char *rsave = r; + LDAP_UTF8DEC(r); + *rsave = '\0'; + while ( !ldap_utf8isspace( r ) && *r != ';' + && *r != ',' && r > ufn ) + LDAP_UTF8DEC(r); + LDAP_UTF8INC(r); + + if ( strcasecmp( r, "c" ) + && strcasecmp( r, "o" ) + && strcasecmp( r, "ou" ) + && strcasecmp( r, "st" ) + && strcasecmp( r, "l" ) + && strcasecmp( r, "dc" ) + && strcasecmp( r, "uid" ) + && strcasecmp( r, "cn" ) ) { + r = rsave; + *r++ = '='; + } + } + break; + default: + r += (plen = LDAP_UTF8COPY(r,p)); + break; + } + } + *r = '\0'; + + return( ufn ); +} + +char ** +LDAP_CALL +ldap_explode_dns( const char *dn ) +{ + int ncomps, maxcomps; + char *s, *cpydn; + char **rdns; +#ifdef HAVE_STRTOK_R /* defined in portable.h */ + char *lasts; +#endif + + if ( dn == NULL ) { + dn = ""; + } + + if ( (rdns = (char **)NSLDAPI_MALLOC( 8 * sizeof(char *) )) == NULL ) { + return( NULL ); + } + + maxcomps = 8; + ncomps = 0; + cpydn = nsldapi_strdup( (char *)dn ); + for ( s = STRTOK( cpydn, "@.", &lasts ); s != NULL; + s = STRTOK( NULL, "@.", &lasts ) ) { + if ( ncomps == maxcomps ) { + maxcomps *= 2; + if ( (rdns = (char **)NSLDAPI_REALLOC( rdns, maxcomps * + sizeof(char *) )) == NULL ) { + NSLDAPI_FREE( cpydn ); + return( NULL ); + } + } + rdns[ncomps++] = nsldapi_strdup( s ); + } + rdns[ncomps] = NULL; + NSLDAPI_FREE( cpydn ); + + return( rdns ); +} + +#define LDAP_DN 1 +#define LDAP_RDN 2 + +static char ** +ldap_explode( const char *dn, const int notypes, const int nametype ) +{ + char *p, *q, *rdnstart, **rdns = NULL; + size_t plen = 0; + int state = 0; + int count = 0; + int startquote = 0; + int endquote = 0; + int len = 0; + int goteq = 0; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_explode\n", 0, 0, 0 ); + + if ( dn == NULL ) { + dn = ""; + } + +#if 0 + if ( ldap_is_dns_dn( dn ) ) { + return( ldap_explode_dns( dn ) ); + } +#endif + + while ( ldap_utf8isspace( (char *)dn )) { /* ignore leading spaces */ + ++dn; + } + + p = rdnstart = (char *) dn; + state = OUTQUOTE; + + do { + p += plen; + plen = 1; + switch ( *p ) { + case '\\': + if ( *++p == '\0' ) + p--; + else + plen = LDAP_UTF8LEN(p); + break; + case '"': + if ( state == INQUOTE ) + state = OUTQUOTE; + else + state = INQUOTE; + break; + case '+': if ( nametype != LDAP_RDN ) break; + case ';': + case ',': + case '\0': + if ( state == OUTQUOTE ) { + /* + * semicolon and comma are not valid RDN + * separators. + */ + if ( nametype == LDAP_RDN && + ( *p == ';' || *p == ',' || !goteq)) { + ldap_charray_free( rdns ); + return NULL; + } + if ( (*p == ',' || *p == ';') && !goteq ) { + /* If we get here, we have a case similar + * to <attr>=<value>,<string>,<attr>=<value> + * This is not a valid dn */ + ldap_charray_free( rdns ); + return NULL; + } + goteq = 0; + ++count; + if ( rdns == NULL ) { + if (( rdns = (char **)NSLDAPI_MALLOC( 8 + * sizeof( char *))) == NULL ) + return( NULL ); + } else if ( count >= 8 ) { + if (( rdns = (char **)NSLDAPI_REALLOC( + rdns, (count+1) * + sizeof( char *))) == NULL ) + return( NULL ); + } + rdns[ count ] = NULL; + endquote = 0; + if ( notypes ) { + for ( q = rdnstart; + q < p && *q != '='; ++q ) { + ; + } + if ( q < p ) { /* *q == '=' */ + rdnstart = ++q; + } + if ( *rdnstart == '"' ) { + startquote = 1; + ++rdnstart; + } + + if ( (*(p-1) == '"') && startquote ) { + endquote = 1; + --p; + } + } + + len = p - rdnstart; + if (( rdns[ count-1 ] = (char *)NSLDAPI_CALLOC( + 1, len + 1 )) != NULL ) { + SAFEMEMCPY( rdns[ count-1 ], rdnstart, + len ); + if ( !endquote ) { + /* trim trailing spaces unless + * they are properly escaped */ + while ( len > 0 && + ldap_utf8isspace( + &rdns[count-1][len-1] ) && + ((len == 1) || (rdns[count-1][len-2] != '\\'))) { + --len; + } + } + rdns[ count-1 ][ len ] = '\0'; + } + + /* + * Don't forget to increment 'p' back to where + * it should be. If we don't, then we will + * never get past an "end quote." + */ + if ( endquote == 1 ) + p++; + + rdnstart = *p ? p + 1 : p; + while ( ldap_utf8isspace( rdnstart )) + ++rdnstart; + } + break; + case '=': + if ( state == OUTQUOTE ) { + goteq = 1; + } + /* FALL */ + default: + plen = LDAP_UTF8LEN(p); + break; + } + } while ( *p ); + + return( rdns ); +} + +char ** +LDAP_CALL +ldap_explode_dn( const char *dn, const int notypes ) +{ + return( ldap_explode( dn, notypes, LDAP_DN ) ); +} + +char ** +LDAP_CALL +ldap_explode_rdn( const char *rdn, const int notypes ) +{ + return( ldap_explode( rdn, notypes, LDAP_RDN ) ); +} + +int +LDAP_CALL +ldap_is_dns_dn( const char *dn ) +{ + return( dn != NULL && dn[ 0 ] != '\0' && strchr( dn, '=' ) == NULL && + strchr( dn, ',' ) == NULL ); +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/getdxbyname.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/getdxbyname.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/geteffectiverightsctrl.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/geteffectiverightsctrl.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/getentry.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/getentry.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/getfilter.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/getfilter.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/getoption.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/getoption.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/getvalues.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/getvalues.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/ldap-int.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/ldap-int.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/ldapfilter.conf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/ldapfilter.conf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/ldapfriendly
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/ldapfriendly)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/ldapsearchprefs.conf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/ldapsearchprefs.conf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/ldaptemplates.conf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/ldaptemplates.conf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/memcache.c
Added
@@ -0,0 +1,2244 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +/* + * + * memcache.c - routines that implement an in-memory cache. + * + * To Do: 1) ber_dup_ext(). + * 2) referrals and reference? + */ + +#include <assert.h> +#include "ldap-int.h" + +/* + * Extra size allocated to BerElement. + * XXXmcs: must match EXBUFSIZ in liblber/io.c? + */ +#define EXTRA_SIZE 1024 + +/* Mode constants for function memcache_access() */ +#define MEMCACHE_ACCESS_ADD 0 +#define MEMCACHE_ACCESS_APPEND 1 +#define MEMCACHE_ACCESS_APPEND_LAST 2 +#define MEMCACHE_ACCESS_FIND 3 +#define MEMCACHE_ACCESS_DELETE 4 +#define MEMCACHE_ACCESS_DELETE_ALL 5 +#define MEMCACHE_ACCESS_UPDATE 6 +#define MEMCACHE_ACCESS_FLUSH 7 +#define MEMCACHE_ACCESS_FLUSH_ALL 8 +#define MEMCACHE_ACCESS_FLUSH_LRU 9 +#define MEMCACHE_ACCESS_FLUSH_RESULTS 10 + +/* Mode constants for function memcache_adj_size */ +#define MEMCACHE_SIZE_DEDUCT 0 +#define MEMCACHE_SIZE_ADD 1 + +#define MEMCACHE_SIZE_ENTRIES 1 +#define MEMCACHE_SIZE_NON_ENTRIES 2 + +/* Size used for calculation if given size of cache is 0 */ +#define MEMCACHE_DEF_SIZE 131072 /* 128K bytes */ + +/* Index into different list structure */ +#define LIST_TTL 0 +#define LIST_LRU 1 +#define LIST_TMP 2 +#define LIST_TOTAL 3 + +/* Macros to make code more readable */ +#define NSLDAPI_VALID_MEMCACHE_POINTER( cp ) ( (cp) != NULL ) +#define NSLDAPI_STR_NONNULL( s ) ( (s) ? (s) : "" ) +#define NSLDAPI_SAFE_STRLEN( s ) ( (s) ? strlen((s)) + 1 : 1 ) + +/* Macros dealing with mutex */ +#define LDAP_MEMCACHE_MUTEX_LOCK( c ) \ + if ( (c) && ((c)->ldmemc_lock_fns).ltf_mutex_lock ) { \ + ((c)->ldmemc_lock_fns).ltf_mutex_lock( (c)->ldmemc_lock ); \ + } + +#define LDAP_MEMCACHE_MUTEX_UNLOCK( c ) \ + if ( (c) && ((c)->ldmemc_lock_fns).ltf_mutex_unlock ) { \ + ((c)->ldmemc_lock_fns).ltf_mutex_unlock( (c)->ldmemc_lock ); \ + } + +#define LDAP_MEMCACHE_MUTEX_ALLOC( c ) \ + ((c) && ((c)->ldmemc_lock_fns).ltf_mutex_alloc ? \ + ((c)->ldmemc_lock_fns).ltf_mutex_alloc() : NULL) + +#define LDAP_MEMCACHE_MUTEX_FREE( c ) \ + if ( (c) && ((c)->ldmemc_lock_fns).ltf_mutex_free ) { \ + ((c)->ldmemc_lock_fns).ltf_mutex_free( (c)->ldmemc_lock ); \ + } + +/* Macros used for triming unnecessary spaces in a basedn */ +#define NSLDAPI_IS_SPACE( c ) \ + (((c) == ' ') || ((c) == '\t') || ((c) == '\n')) + +#define NSLDAPI_IS_SEPARATER( c ) \ + ((c) == ',') + +/* Hash table callback function pointer definition */ +typedef int (*HashFuncPtr)(int table_size, void *key); +typedef int (*PutDataPtr)(void **ppTableData, void *key, void *pData); +typedef int (*GetDataPtr)(void *pTableData, void *key, void **ppData); +typedef int (*RemoveDataPtr)(void **ppTableData, void *key, void **ppData); +typedef int (*MiscFuncPtr)(void **ppTableData, void *key, void *pData); +typedef void (*ClrTableNodePtr)(void **ppTableData, void *pData); + +/* Structure of a node in a hash table */ +typedef struct HashTableNode_struct { + void *pData; +} HashTableNode; + +/* Structure of a hash table */ +typedef struct HashTable_struct { + HashTableNode *table; + int size; + HashFuncPtr hashfunc; + PutDataPtr putdata; + GetDataPtr getdata; + MiscFuncPtr miscfunc; + RemoveDataPtr removedata; + ClrTableNodePtr clrtablenode; +} HashTable; + +/* Structure uniquely identifies a search request */ +typedef struct ldapmemcacheReqId_struct { + LDAP *ldmemcrid_ld; + int ldmemcrid_msgid; +} ldapmemcacheReqId; + +/* Structure representing a ldap handle associated to memcache */ +typedef struct ldapmemcacheld_struct { + LDAP *ldmemcl_ld; + struct ldapmemcacheld_struct *ldmemcl_next; +} ldapmemcacheld; + +/* Structure representing header of a search result */ +typedef struct ldapmemcacheRes_struct { + char *ldmemcr_basedn; + unsigned long ldmemcr_crc_key; + unsigned long ldmemcr_resSize; + unsigned long ldmemcr_timestamp; + LDAPMessage *ldmemcr_resHead; + LDAPMessage *ldmemcr_resTail; + ldapmemcacheReqId ldmemcr_req_id; + struct ldapmemcacheRes_struct *ldmemcr_next[LIST_TOTAL]; + struct ldapmemcacheRes_struct *ldmemcr_prev[LIST_TOTAL]; + struct ldapmemcacheRes_struct *ldmemcr_htable_next; +} ldapmemcacheRes; + +/* Structure for memcache statistics */ +typedef struct ldapmemcacheStats_struct { + unsigned long ldmemcstat_tries; + unsigned long ldmemcstat_hits; +} ldapmemcacheStats; + +/* Structure of a memcache object */ +struct ldapmemcache { + unsigned long ldmemc_ttl; + unsigned long ldmemc_size; + unsigned long ldmemc_size_used; + unsigned long ldmemc_size_entries; + char **ldmemc_basedns; + void *ldmemc_lock; + ldapmemcacheld *ldmemc_lds; + HashTable *ldmemc_resTmp; + HashTable *ldmemc_resLookup; + ldapmemcacheRes *ldmemc_resHead[LIST_TOTAL]; + ldapmemcacheRes *ldmemc_resTail[LIST_TOTAL]; + struct ldap_thread_fns ldmemc_lock_fns; + ldapmemcacheStats ldmemc_stats; +}; + +/* Function prototypes */ +static int memcache_exist(LDAP *ld); +static int memcache_add_to_ld(LDAP *ld, int msgid, LDAPMessage *pMsg); +static int memcache_compare_dn(const char *main_dn, const char *dn, int scope); +static int memcache_dup_message(LDAPMessage *res, int msgid, int fromcache, + LDAPMessage **ppResCopy, unsigned long *pSize); +static BerElement* memcache_ber_dup(BerElement* pBer, unsigned long *pSize); + +static void memcache_trim_basedn_spaces(char *basedn); +static int memcache_validate_basedn(LDAPMemCache *cache, const char *basedn); +static int memcache_get_ctrls_len(LDAPControl **ctrls); +static void memcache_append_ctrls(char *buf, LDAPControl **serverCtrls, + LDAPControl **clientCtrls); +static int memcache_adj_size(LDAPMemCache *cache, unsigned long size, + int usageFlags, int bAdd); +static int memcache_free_entry(LDAPMemCache *cache, ldapmemcacheRes *pRes); +static int memcache_expired(LDAPMemCache *cache, ldapmemcacheRes *pRes, + unsigned long curTime); +static int memcache_add_to_list(LDAPMemCache *cache, ldapmemcacheRes *pRes, + int index); +static int memcache_add_res_to_list(ldapmemcacheRes *pRes, LDAPMessage *pMsg, + unsigned long size); +static int memcache_free_from_list(LDAPMemCache *cache, ldapmemcacheRes *pRes, + int index); +static int memcache_search(LDAP *ld, unsigned long key, LDAPMessage **ppRes); +static int memcache_add(LDAP *ld, unsigned long key, int msgid, + const char *basedn); +static int memcache_append(LDAP *ld, int msgid, LDAPMessage *pRes); +static int memcache_append_last(LDAP *ld, int msgid, LDAPMessage *pRes); +static int memcache_remove(LDAP *ld, int msgid); +#if 0 /* function not used */ +static int memcache_remove_all(LDAP *ld); +#endif /* 0 */ +static int memcache_access(LDAPMemCache *cache, int mode, + void *pData1, void *pData2, void *pData3); +static void memcache_flush(LDAPMemCache *cache, char *dn, int scope, + int flushresults); +#ifdef LDAP_DEBUG +static void memcache_print_list( LDAPMemCache *cache, int index ); +static void memcache_report_statistics( LDAPMemCache *cache ); +#endif /* LDAP_DEBUG */ + +static int htable_calculate_size(int sizelimit); +static int htable_sizeinbytes(HashTable *pTable); +static int htable_put(HashTable *pTable, void *key, void *pData); +static int htable_get(HashTable *pTable, void *key, void **ppData); +static int htable_misc(HashTable *pTable, void *key, void *pData); +static int htable_remove(HashTable *pTable, void *key, void **ppData); +static int htable_removeall(HashTable *pTable, void *pData); +static int htable_create(int size_limit, HashFuncPtr hashf, + PutDataPtr putDataf, GetDataPtr getDataf, + RemoveDataPtr removeDataf, ClrTableNodePtr clrNodef, + MiscFuncPtr miscOpf, HashTable **ppTable); +static int htable_free(HashTable *pTable); + +static int msgid_hashf(int table_size, void *key); +static int msgid_putdata(void **ppTableData, void *key, void *pData); +static int msgid_getdata(void *pTableData, void *key, void **ppData); +static int msgid_removedata(void **ppTableData, void *key, void **ppData); +static int msgid_clear_ld_items(void **ppTableData, void *key, void *pData); +static void msgid_clearnode(void **ppTableData, void *pData); + +static int attrkey_hashf(int table_size, void *key); +static int attrkey_putdata(void **ppTableData, void *key, void *pData); +static int attrkey_getdata(void *pTableData, void *key, void **ppData); +static int attrkey_removedata(void **ppTableData, void *key, void **ppData); +static void attrkey_clearnode(void **ppTableData, void *pData); + +static unsigned long crc32_convert(char *buf, int len); + +/* Create a memcache object. */ +int +LDAP_CALL +ldap_memcache_init( unsigned long ttl, unsigned long size, + char **baseDNs, struct ldap_thread_fns *thread_fns, + LDAPMemCache **cachep ) +{ + unsigned long total_size = 0; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_init\n", 0, 0, 0 ); + + if ( cachep == NULL ) { + return( LDAP_PARAM_ERROR ); + } + + if ((*cachep = (LDAPMemCache*)NSLDAPI_CALLOC(1, + sizeof(LDAPMemCache))) == NULL) { + return ( LDAP_NO_MEMORY ); + } + + total_size += sizeof(LDAPMemCache); + + (*cachep)->ldmemc_ttl = ttl; + (*cachep)->ldmemc_size = size; + (*cachep)->ldmemc_lds = NULL; + + /* Non-zero default size needed for calculating size of hash tables */ + size = (size ? size : MEMCACHE_DEF_SIZE); + + if (thread_fns) { + memcpy(&((*cachep)->ldmemc_lock_fns), thread_fns, + sizeof(struct ldap_thread_fns)); + } else { + memset(&((*cachep)->ldmemc_lock_fns), 0, + sizeof(struct ldap_thread_fns)); + } + + (*cachep)->ldmemc_lock = LDAP_MEMCACHE_MUTEX_ALLOC( *cachep ); + + /* Cache basedns */ + if (baseDNs != NULL) { + + int i; + + for (i = 0; baseDNs[i]; i++) { + ; + } + + (*cachep)->ldmemc_basedns = (char**)NSLDAPI_CALLOC(i + 1, + sizeof(char*)); + + if ((*cachep)->ldmemc_basedns == NULL) { + ldap_memcache_destroy(*cachep); + *cachep = NULL; + return ( LDAP_NO_MEMORY ); + } + + total_size += (i + 1) * sizeof(char*); + + for (i = 0; baseDNs[i]; i++) { + (*cachep)->ldmemc_basedns[i] = nsldapi_strdup(baseDNs[i]); + total_size += strlen(baseDNs[i]) + 1; + } + + (*cachep)->ldmemc_basedns[i] = NULL; + } + + /* Create hash table for temporary cache */ + if (htable_create(size, msgid_hashf, msgid_putdata, msgid_getdata, + msgid_removedata, msgid_clearnode, msgid_clear_ld_items, + &((*cachep)->ldmemc_resTmp)) != LDAP_SUCCESS) { + ldap_memcache_destroy(*cachep); + *cachep = NULL; + return( LDAP_NO_MEMORY ); + } + + total_size += htable_sizeinbytes((*cachep)->ldmemc_resTmp); + + /* Create hash table for primary cache */ + if (htable_create(size, attrkey_hashf, attrkey_putdata, + attrkey_getdata, attrkey_removedata, attrkey_clearnode, + NULL, &((*cachep)->ldmemc_resLookup)) != LDAP_SUCCESS) { + ldap_memcache_destroy(*cachep); + *cachep = NULL; + return( LDAP_NO_MEMORY ); + } + + total_size += htable_sizeinbytes((*cachep)->ldmemc_resLookup); + + /* See if there is enough room so far */ + if (memcache_adj_size(*cachep, total_size, MEMCACHE_SIZE_NON_ENTRIES, + MEMCACHE_SIZE_ADD) != LDAP_SUCCESS) { + ldap_memcache_destroy(*cachep); + *cachep = NULL; + return( LDAP_SIZELIMIT_EXCEEDED ); + } + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_init new cache 0x%p\n", + *cachep, 0, 0 ); + + return( LDAP_SUCCESS ); +} + +/* Associates a ldap handle to a memcache object. */ +int +LDAP_CALL +ldap_memcache_set( LDAP *ld, LDAPMemCache *cache ) +{ + int nRes = LDAP_SUCCESS; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_set\n", 0, 0, 0 ); + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) ) + return( LDAP_PARAM_ERROR ); + + LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); + + if (ld->ld_memcache != cache) { + + LDAPMemCache *c = ld->ld_memcache; + ldapmemcacheld *pCur = NULL; + ldapmemcacheld *pPrev = NULL; + + /* First dissociate handle from old cache */ + + LDAP_MEMCACHE_MUTEX_LOCK( c ); + + pCur = (c ? c->ldmemc_lds : NULL); + for (; pCur; pCur = pCur->ldmemcl_next) { + if (pCur->ldmemcl_ld == ld) + break; + pPrev = pCur; + } + + if (pCur) { + + ldapmemcacheReqId reqid; + + reqid.ldmemcrid_ld = ld; + reqid.ldmemcrid_msgid = -1; + htable_misc(c->ldmemc_resTmp, (void*)&reqid, (void*)c); + + if (pPrev) + pPrev->ldmemcl_next = pCur->ldmemcl_next; + else + c->ldmemc_lds = pCur->ldmemcl_next; + NSLDAPI_FREE(pCur); + pCur = NULL; + + memcache_adj_size(c, sizeof(ldapmemcacheld), + MEMCACHE_SIZE_NON_ENTRIES, MEMCACHE_SIZE_DEDUCT); + } + + LDAP_MEMCACHE_MUTEX_UNLOCK( c ); + + ld->ld_memcache = NULL; + + /* Exit if no new cache is specified */ + if (cache == NULL) { + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + return( LDAP_SUCCESS ); + } + + /* Then associate handle with new cache */ + + LDAP_MEMCACHE_MUTEX_LOCK( cache ); + + if ((nRes = memcache_adj_size(cache, sizeof(ldapmemcacheld), + MEMCACHE_SIZE_NON_ENTRIES, MEMCACHE_SIZE_ADD)) != LDAP_SUCCESS) { + LDAP_MEMCACHE_MUTEX_UNLOCK( cache ); + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + return nRes; + } + + pCur = (ldapmemcacheld*)NSLDAPI_CALLOC(1, sizeof(ldapmemcacheld)); + if (pCur == NULL) { + memcache_adj_size(cache, sizeof(ldapmemcacheld), + MEMCACHE_SIZE_NON_ENTRIES, MEMCACHE_SIZE_DEDUCT); + nRes = LDAP_NO_MEMORY; + } else { + pCur->ldmemcl_ld = ld; + pCur->ldmemcl_next = cache->ldmemc_lds; + cache->ldmemc_lds = pCur; + ld->ld_memcache = cache; + } + + LDAP_MEMCACHE_MUTEX_UNLOCK( cache ); + } + + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + + return nRes; +} + +/* Retrieves memcache with which the ldap handle has been associated. */ +int +LDAP_CALL +ldap_memcache_get( LDAP *ld, LDAPMemCache **cachep ) +{ + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_get ld: 0x%p\n", ld, 0, 0 ); + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || cachep == NULL ) { + return( LDAP_PARAM_ERROR ); + } + + LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); + *cachep = ld->ld_memcache; + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + + return( LDAP_SUCCESS ); +} + +/* + * Function that stays inside libldap and proactively expires items from + * the given cache. This should be called from a newly created thread since + * it will not return until after ldap_memcache_destroy() is called. + */ +void +LDAP_CALL +ldap_memcache_update( LDAPMemCache *cache ) +{ + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_update: cache 0x%p\n", + cache, 0, 0 ); + + if ( !NSLDAPI_VALID_MEMCACHE_POINTER( cache )) { + return; + } + + LDAP_MEMCACHE_MUTEX_LOCK( cache ); + memcache_access(cache, MEMCACHE_ACCESS_UPDATE, NULL, NULL, NULL); + LDAP_MEMCACHE_MUTEX_UNLOCK( cache ); +} + +/* Removes specified entries from given memcache. Only clears out search + results that included search entries. */ +void +LDAP_CALL +ldap_memcache_flush( LDAPMemCache *cache, char *dn, int scope ) +{ + LDAPDebug( LDAP_DEBUG_TRACE, + "ldap_memcache_flush( cache: 0x%p, dn: %s, scope: %d)\n", + cache, ( dn == NULL ) ? "(null)" : dn, scope ); + memcache_flush(cache, dn, scope, 0 /* Don't use result flush mode */); +} + +/* Removes specified entries from given memcache, including search + results that returned no entries. */ +void +LDAP_CALL +ldap_memcache_flush_results( LDAPMemCache *cache, char *dn, int scope ) +{ + LDAPDebug( LDAP_DEBUG_TRACE, + "ldap_memcache_flush_results( cache: 0x%p, dn: %s, scope: %d)\n", + cache, ( dn == NULL ) ? "(null)" : dn, scope ); + memcache_flush(cache, dn, scope, 1 /* Use result flush mode */); +} + +/* Destroys the given memcache. */ +void +LDAP_CALL +ldap_memcache_destroy( LDAPMemCache *cache ) +{ + int i = 0; + unsigned long size = sizeof(LDAPMemCache); + ldapmemcacheld *pNode = NULL, *pNextNode = NULL; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_destroy( 0x%p )\n", + cache, 0, 0 ); + + if ( !NSLDAPI_VALID_MEMCACHE_POINTER( cache )) { + return; + } + + /* Dissociate all ldap handes from this cache. */ + LDAP_MEMCACHE_MUTEX_LOCK( cache ); + + for (pNode = cache->ldmemc_lds; pNode; pNode = pNextNode, i++) { + LDAP_MUTEX_LOCK( pNode->ldmemcl_ld, LDAP_MEMCACHE_LOCK ); + cache->ldmemc_lds = pNode->ldmemcl_next; + pNode->ldmemcl_ld->ld_memcache = NULL; + LDAP_MUTEX_UNLOCK( pNode->ldmemcl_ld, LDAP_MEMCACHE_LOCK ); + pNextNode = pNode->ldmemcl_next; + NSLDAPI_FREE(pNode); + } + + size += i * sizeof(ldapmemcacheld); + + LDAP_MEMCACHE_MUTEX_UNLOCK( cache ); + + /* Free array of basedns */ + if (cache->ldmemc_basedns) { + for (i = 0; cache->ldmemc_basedns[i]; i++) { + size += strlen(cache->ldmemc_basedns[i]) + 1; + NSLDAPI_FREE(cache->ldmemc_basedns[i]); + } + size += (i + 1) * sizeof(char*); + NSLDAPI_FREE(cache->ldmemc_basedns); + } + + /* Free hash table used for temporary cache */ + if (cache->ldmemc_resTmp) { + size += htable_sizeinbytes(cache->ldmemc_resTmp); + memcache_access(cache, MEMCACHE_ACCESS_DELETE_ALL, NULL, NULL, NULL); + htable_free(cache->ldmemc_resTmp); + } + + /* Free hash table used for primary cache */ + if (cache->ldmemc_resLookup) { + size += htable_sizeinbytes(cache->ldmemc_resLookup); + memcache_access(cache, MEMCACHE_ACCESS_FLUSH_ALL, NULL, NULL, NULL); + htable_free(cache->ldmemc_resLookup); + } + + memcache_adj_size(cache, size, MEMCACHE_SIZE_NON_ENTRIES, + MEMCACHE_SIZE_DEDUCT); + + LDAP_MEMCACHE_MUTEX_FREE( cache ); + + NSLDAPI_FREE(cache); +} + +/************************* Internal API Functions ****************************/ + +/* Creates an integer key by applying the Cyclic Reduntency Check algorithm on + a long string formed by concatenating all the search parameters plus the + current bind DN. The key is used in the cache for looking up cached + entries. It is assumed that the CRC algorithm will generate + different integers from different byte strings. */ +int +ldap_memcache_createkey(LDAP *ld, const char *base, int scope, + const char *filter, char **attrs, + int attrsonly, LDAPControl **serverctrls, + LDAPControl **clientctrls, unsigned long *keyp) +{ + int nRes, i, j, i_smallest; + int len; + int defport; + char buf[50]; + char *tmp, *defhost, *binddn, *keystr, *tmpbase; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || (keyp == NULL) ) + return( LDAP_PARAM_ERROR ); + + *keyp = 0; + + if (!memcache_exist(ld)) + return( LDAP_LOCAL_ERROR ); + + LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); + LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache ); + nRes = memcache_validate_basedn(ld->ld_memcache, base); + LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache ); + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + + if (nRes != LDAP_SUCCESS) + return nRes; + + defhost = NSLDAPI_STR_NONNULL(ld->ld_defhost); + defport = ld->ld_defport; + tmpbase = nsldapi_strdup(NSLDAPI_STR_NONNULL(base)); + memcache_trim_basedn_spaces(tmpbase); + + if ((binddn = nsldapi_get_binddn(ld)) == NULL) + binddn = ""; + + sprintf(buf, "%i\n%i\n%i\n", defport, scope, (attrsonly ? 1 : 0)); + len = NSLDAPI_SAFE_STRLEN(buf) + NSLDAPI_SAFE_STRLEN(tmpbase) + + NSLDAPI_SAFE_STRLEN(filter) + NSLDAPI_SAFE_STRLEN(defhost) + + NSLDAPI_SAFE_STRLEN(binddn); + + if (attrs) { + for (i = 0; attrs[i]; i++) { + + for (i_smallest = j = i; attrs[j]; j++) { + if (strcasecmp(attrs[i_smallest], attrs[j]) > 0) + i_smallest = j; + } + + if (i != i_smallest) { + tmp = attrs[i]; + attrs[i] = attrs[i_smallest]; + attrs[i_smallest] = tmp; + } + + len += NSLDAPI_SAFE_STRLEN(attrs[i]); + } + } else { + len += 1; + } + + len += memcache_get_ctrls_len(serverctrls) + + memcache_get_ctrls_len(clientctrls) + 1; + + if ((keystr = (char*)NSLDAPI_CALLOC(len, sizeof(char))) == NULL) { + NSLDAPI_FREE(defhost); + return( LDAP_NO_MEMORY ); + } + + sprintf(keystr, "%s\n%s\n%s\n%s\n%s\n", binddn, tmpbase, + NSLDAPI_STR_NONNULL(defhost), NSLDAPI_STR_NONNULL(filter), + NSLDAPI_STR_NONNULL(buf)); + + if (attrs) { + for (i = 0; attrs[i]; i++) { + strcat(keystr, NSLDAPI_STR_NONNULL(attrs[i])); + strcat(keystr, "\n"); + } + } else { + strcat(keystr, "\n"); + } + + for (tmp = keystr; *tmp; + *tmp += (*tmp >= 'a' && *tmp <= 'z' ? 'A'-'a' : 0), tmp++) { + ; + } + + memcache_append_ctrls(keystr, serverctrls, clientctrls); + + /* CRC algorithm */ + *keyp = crc32_convert(keystr, len); + + NSLDAPI_FREE(keystr); + NSLDAPI_FREE(tmpbase); + + return LDAP_SUCCESS; +} + +/* Searches the cache for the right cached entries, and if found, attaches + them to the given ldap handle. This function relies on locking by the + caller. */ +int +ldap_memcache_result(LDAP *ld, int msgid, unsigned long key) +{ + int nRes; + LDAPMessage *pMsg = NULL; + + LDAPDebug( LDAP_DEBUG_TRACE, + "ldap_memcache_result( ld: 0x%p, msgid: %d, key: 0x%8.8lx)\n", + ld, msgid, key ); + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || (msgid < 0) ) { + return( LDAP_PARAM_ERROR ); + } + + if (!memcache_exist(ld)) { + return( LDAP_LOCAL_ERROR ); + } + + LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); + LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache ); + + /* Search the cache and append the results to ld if found */ + ++ld->ld_memcache->ldmemc_stats.ldmemcstat_tries; + if ((nRes = memcache_search(ld, key, &pMsg)) == LDAP_SUCCESS) { + nRes = memcache_add_to_ld(ld, msgid, pMsg); + ++ld->ld_memcache->ldmemc_stats.ldmemcstat_hits; + LDAPDebug( LDAP_DEBUG_TRACE, + "ldap_memcache_result: key 0x%8.8lx found in cache\n", + key, 0, 0 ); + } else { + LDAPDebug( LDAP_DEBUG_TRACE, + "ldap_memcache_result: key 0x%8.8lx not found in cache\n", + key, 0, 0 ); + } + +#ifdef LDAP_DEBUG + memcache_print_list( ld->ld_memcache, LIST_LRU ); + memcache_report_statistics( ld->ld_memcache ); +#endif /* LDAP_DEBUG */ + + LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache ); + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + + return nRes; +} + +/* Creates a new header in the cache so that entries arriving from the + directory server can later be cached under the header. */ +int +ldap_memcache_new(LDAP *ld, int msgid, unsigned long key, const char *basedn) +{ + int nRes; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) ) { + return( LDAP_PARAM_ERROR ); + } + + LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); + + if (!memcache_exist(ld)) { + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + return( LDAP_LOCAL_ERROR ); + } + + LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache ); + nRes = memcache_add(ld, key, msgid, basedn); + LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache ); + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + + return nRes; +} + +/* Appends a chain of entries to an existing cache header. Parameter "bLast" + indicates whether there will be more entries arriving for the search in + question. */ +int +ldap_memcache_append(LDAP *ld, int msgid, int bLast, LDAPMessage *result) +{ + int nRes = LDAP_SUCCESS; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_memcache_append( ld: 0x%p, ", ld, 0, 0 ); + LDAPDebug( LDAP_DEBUG_TRACE, "msgid %d, bLast: %d, result: 0x%p)\n", + msgid, bLast, result ); + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || !result ) { + return( LDAP_PARAM_ERROR ); + } + + LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); + + if (!memcache_exist(ld)) { + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + return( LDAP_LOCAL_ERROR ); + } + + LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache ); + + if (!bLast) + nRes = memcache_append(ld, msgid, result); + else + nRes = memcache_append_last(ld, msgid, result); + + LDAPDebug( LDAP_DEBUG_TRACE, + "ldap_memcache_append: %s result for msgid %d\n", + ( nRes == LDAP_SUCCESS ) ? "added" : "failed to add", msgid , 0 ); + + LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache ); + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + + return nRes; +} + +/* Removes partially cached results for a search as a result of calling + ldap_abandon() by the client. */ +int +ldap_memcache_abandon(LDAP *ld, int msgid) +{ + int nRes; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || (msgid < 0) ) { + return( LDAP_PARAM_ERROR ); + } + + LDAP_MUTEX_LOCK( ld, LDAP_MEMCACHE_LOCK ); + + if (!memcache_exist(ld)) { + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + return( LDAP_LOCAL_ERROR ); + } + + LDAP_MEMCACHE_MUTEX_LOCK( ld->ld_memcache ); + nRes = memcache_remove(ld, msgid); + LDAP_MEMCACHE_MUTEX_UNLOCK( ld->ld_memcache ); + LDAP_MUTEX_UNLOCK( ld, LDAP_MEMCACHE_LOCK ); + + return nRes; +} + +/*************************** helper functions *******************************/ + +/* Removes extraneous spaces in a basedn so that basedns differ by only those + spaces will be treated as equal. Extraneous spaces are those that + precedes the basedn and those that follow a comma. */ +/* + * XXXmcs: this is a bit too agressive... we need to deal with the fact that + * commas and spaces may be quoted, in which case it is wrong to remove them. + */ +static void +memcache_trim_basedn_spaces(char *basedn) +{ + char *pRead, *pWrite; + + if (!basedn) + return; + + for (pWrite = pRead = basedn; *pRead; ) { + for (; *pRead && NSLDAPI_IS_SPACE(*pRead); pRead++) { + ; + } + for (; *pRead && !NSLDAPI_IS_SEPARATER(*pRead); + *(pWrite++) = *(pRead++)) { + ; + } + *(pWrite++) = (*pRead ? *(pRead++) : *pRead); + } +} + +/* Verifies whether the results of a search should be cached or not by + checking if the search's basedn falls under any of the basedns for which + the memcache is responsible. */ +static int +memcache_validate_basedn(LDAPMemCache *cache, const char *basedn) +{ + int i; + + if ( cache->ldmemc_basedns == NULL ) { + return( LDAP_SUCCESS ); + } + +#if 1 + if (basedn == NULL) { + basedn = ""; + } +#else + /* XXXmcs: I do not understand this code... */ + if (basedn == NULL) + return (cache->ldmemc_basedns && cache->ldmemc_basedns[0] ? + LDAP_OPERATIONS_ERROR : LDAP_SUCCESS); + } +#endif + + for (i = 0; cache->ldmemc_basedns[i]; i++) { + if (memcache_compare_dn(basedn, cache->ldmemc_basedns[i], + LDAP_SCOPE_SUBTREE) == LDAP_COMPARE_TRUE) { + return( LDAP_SUCCESS ); + } + } + + return( LDAP_OPERATIONS_ERROR ); +} + +/* Calculates the length of the buffer needed to concatenate the contents of + a ldap control. */ +static int +memcache_get_ctrls_len(LDAPControl **ctrls) +{ + int len = 0, i; + + if (ctrls) { + for (i = 0; ctrls[i]; i++) { + len += strlen(NSLDAPI_STR_NONNULL(ctrls[i]->ldctl_oid)) + + (ctrls[i]->ldctl_value).bv_len + 4; + } + } + + return len; +} + +/* Contenates the contents of client and server controls to a buffer. */ +static void +memcache_append_ctrls(char *buf, LDAPControl **serverCtrls, + LDAPControl **clientCtrls) +{ + int i, j; + char *pCh = buf + strlen(buf); + LDAPControl **ctrls; + + for (j = 0; j < 2; j++) { + + if ((ctrls = (j ? clientCtrls : serverCtrls)) == NULL) + continue; + + for (i = 0; ctrls[i]; i++) { + sprintf(pCh, "%s\n", NSLDAPI_STR_NONNULL(ctrls[i]->ldctl_oid)); + pCh += strlen(NSLDAPI_STR_NONNULL(ctrls[i]->ldctl_oid)) + 1; + if ((ctrls[i]->ldctl_value).bv_len > 0) { + memcpy(pCh, (ctrls[i]->ldctl_value).bv_val, + (ctrls[i]->ldctl_value).bv_len); + pCh += (ctrls[i]->ldctl_value).bv_len; + } + sprintf(pCh, "\n%i\n", (ctrls[i]->ldctl_iscritical ? 1 : 0)); + pCh += 3; + } + } +} + +/* Increases or decreases the size (in bytes) the given memcache currently + uses. If the size goes over the limit, the function returns an error. */ +static int +memcache_adj_size(LDAPMemCache *cache, unsigned long size, + int usageFlags, int bAdd) +{ + LDAPDebug( LDAP_DEBUG_TRACE, + "memcache_adj_size: attempting to %s %ld %s bytes...\n", + bAdd ? "add" : "remove", size, + ( usageFlags & MEMCACHE_SIZE_ENTRIES ) ? "entry" : "non-entry" ); + + if (bAdd) { + cache->ldmemc_size_used += size; + if ((cache->ldmemc_size > 0) && + (cache->ldmemc_size_used > cache->ldmemc_size)) { + + if (size > cache->ldmemc_size_entries) { + cache->ldmemc_size_used -= size; + LDAPDebug( LDAP_DEBUG_TRACE, + "memcache_adj_size: failed (size > size_entries %ld).\n", + cache->ldmemc_size_entries, 0, 0 ); + return( LDAP_SIZELIMIT_EXCEEDED ); + } + + while (cache->ldmemc_size_used > cache->ldmemc_size) { + if (memcache_access(cache, MEMCACHE_ACCESS_FLUSH_LRU, + NULL, NULL, NULL) != LDAP_SUCCESS) { + cache->ldmemc_size_used -= size; + LDAPDebug( LDAP_DEBUG_TRACE, + "memcache_adj_size: failed (LRU flush failed).\n", + 0, 0, 0 ); + return( LDAP_SIZELIMIT_EXCEEDED ); + } + } + } + if (usageFlags & MEMCACHE_SIZE_ENTRIES) + cache->ldmemc_size_entries += size; + } else { + cache->ldmemc_size_used -= size; + assert(cache->ldmemc_size_used >= 0); + if (usageFlags & MEMCACHE_SIZE_ENTRIES) + cache->ldmemc_size_entries -= size; + } + +#ifdef LDAP_DEBUG + if ( cache->ldmemc_size == 0 ) { /* no size limit */ + LDAPDebug( LDAP_DEBUG_TRACE, + "memcache_adj_size: succeeded (new size: %ld bytes).\n", + cache->ldmemc_size_used, 0, 0 ); + } else { + LDAPDebug( LDAP_DEBUG_TRACE, + "memcache_adj_size: succeeded (new size: %ld bytes, " + "free space: %ld bytes).\n", cache->ldmemc_size_used, + cache->ldmemc_size - cache->ldmemc_size_used, 0 ); + } +#endif /* LDAP_DEBUG */ + + return( LDAP_SUCCESS ); +} + +/* Searches the cache for results for a particular search identified by + parameter "key", which was generated ldap_memcache_createkey(). */ +static int +memcache_search(LDAP *ld, unsigned long key, LDAPMessage **ppRes) +{ + int nRes; + ldapmemcacheRes *pRes; + + *ppRes = NULL; + + if (!memcache_exist(ld)) + return LDAP_LOCAL_ERROR; + + nRes = memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_FIND, + (void*)&key, (void*)(&pRes), NULL); + + if (nRes != LDAP_SUCCESS) + return nRes; + + *ppRes = pRes->ldmemcr_resHead; + assert((pRes->ldmemcr_req_id).ldmemcrid_msgid == -1); + + return( LDAP_SUCCESS ); +} + +/* Adds a new header into the cache as a place holder for entries + arriving later. */ +static int +memcache_add(LDAP *ld, unsigned long key, int msgid, + const char *basedn) +{ + ldapmemcacheReqId reqid; + + if (!memcache_exist(ld)) + return LDAP_LOCAL_ERROR; + + reqid.ldmemcrid_msgid = msgid; + reqid.ldmemcrid_ld = ld; + + return memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_ADD, + (void*)&key, (void*)&reqid, (void*)basedn); +} + +/* Appends search entries arriving from the dir server to the cache. */ +static int +memcache_append(LDAP *ld, int msgid, LDAPMessage *pRes) +{ + ldapmemcacheReqId reqid; + + if (!memcache_exist(ld)) + return LDAP_LOCAL_ERROR; + + reqid.ldmemcrid_msgid = msgid; + reqid.ldmemcrid_ld = ld; + + return memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_APPEND, + (void*)&reqid, (void*)pRes, NULL); +} + +/* Same as memcache_append(), but the entries being appended are the + last from the dir server. Once all entries for a search have arrived, + the entries are moved from secondary to primary cache, and a time + stamp is given to the entries. */ +static int +memcache_append_last(LDAP *ld, int msgid, LDAPMessage *pRes) +{ + ldapmemcacheReqId reqid; + + if (!memcache_exist(ld)) + return LDAP_LOCAL_ERROR; + + reqid.ldmemcrid_msgid = msgid; + reqid.ldmemcrid_ld = ld; + + return memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_APPEND_LAST, + (void*)&reqid, (void*)pRes, NULL); +} + +/* Removes entries from the temporary cache. */ +static int +memcache_remove(LDAP *ld, int msgid) +{ + ldapmemcacheReqId reqid; + + if (!memcache_exist(ld)) + return LDAP_LOCAL_ERROR; + + reqid.ldmemcrid_msgid = msgid; + reqid.ldmemcrid_ld = ld; + + return memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_DELETE, + (void*)&reqid, NULL, NULL); +} + +#if 0 /* this function is not used */ +/* Wipes out everything in the temporary cache directory. */ +static int +memcache_remove_all(LDAP *ld) +{ + if (!memcache_exist(ld)) + return LDAP_LOCAL_ERROR; + + return memcache_access(ld->ld_memcache, MEMCACHE_ACCESS_DELETE_ALL, + NULL, NULL, NULL); +} +#endif /* 0 */ + +/* Returns TRUE or FALSE */ +static int +memcache_exist(LDAP *ld) +{ + return (ld->ld_memcache != NULL); +} + +/* Attaches cached entries to an ldap handle. */ +static int +memcache_add_to_ld(LDAP *ld, int msgid, LDAPMessage *pMsg) +{ + int nRes = LDAP_SUCCESS; + LDAPMessage **r; + LDAPMessage *pCopy; + + nRes = memcache_dup_message(pMsg, msgid, 1, &pCopy, NULL); + if (nRes != LDAP_SUCCESS) + return nRes; + + LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK ); + + for (r = &(ld->ld_responses); *r; r = &((*r)->lm_next)) + if ((*r)->lm_msgid == msgid) + break; + + if (*r) + for (r = &((*r)->lm_chain); *r; r = &((*r)->lm_chain)) { + ; + } + + *r = pCopy; + + LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); + + return nRes; +} + +/* Check if main_dn is included in {dn, scope} */ +static int +memcache_compare_dn(const char *main_dn, const char *dn, int scope) +{ + int nRes; + char **components = NULL; + char **main_components = NULL; + + components = ldap_explode_dn(dn, 0); + main_components = ldap_explode_dn(main_dn, 0); + + if (!components || !main_components) { + nRes = LDAP_COMPARE_TRUE; + } + else { + + int i, main_i; + + main_i = ldap_count_values(main_components) - 1; + i = ldap_count_values(components) - 1; + + for (; i >= 0 && main_i >= 0; i--, main_i--) { + if (strcasecmp(main_components[main_i], components[i])) + break; + } + + if (i >= 0 && main_i >= 0) { + nRes = LDAP_COMPARE_FALSE; + } + else if (i < 0 && main_i < 0) { + if (scope != LDAP_SCOPE_ONELEVEL) + nRes = LDAP_COMPARE_TRUE; + else + nRes = LDAP_COMPARE_FALSE; + } + else if (main_i < 0) { + nRes = LDAP_COMPARE_FALSE; + } + else { + if (scope == LDAP_SCOPE_BASE) + nRes = LDAP_COMPARE_FALSE; + else if (scope == LDAP_SCOPE_SUBTREE) + nRes = LDAP_COMPARE_TRUE; + else if (main_i == 0) + nRes = LDAP_COMPARE_TRUE; + else + nRes = LDAP_COMPARE_FALSE; + } + } + + if (components) + ldap_value_free(components); + + if (main_components) + ldap_value_free(main_components); + + return nRes; +} + +/* Dup a complete separate copy of a berelement, including the buffers + the berelement points to. */ +static BerElement* +memcache_ber_dup(BerElement* pBer, unsigned long *pSize) +{ + BerElement *p = ber_dup(pBer); + + *pSize = 0; + + if (p) { + + *pSize += sizeof(BerElement) + EXTRA_SIZE; + + if (p->ber_len <= EXTRA_SIZE) { + p->ber_flags |= LBER_FLAG_NO_FREE_BUFFER; + p->ber_buf = (char*)p + sizeof(BerElement); + } else { + p->ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER; + p->ber_buf = (char*)NSLDAPI_CALLOC(1, p->ber_len); + *pSize += (p->ber_buf ? p->ber_len : 0); + } + + if (p->ber_buf) { + p->ber_ptr = p->ber_buf + (pBer->ber_ptr - pBer->ber_buf); + p->ber_end = p->ber_buf + p->ber_len; + memcpy(p->ber_buf, pBer->ber_buf, p->ber_len); + } else { + ber_free(p, 0); + p = NULL; + *pSize = 0; + } + } + + return p; +} + +/* Dup a entry or a chain of entries. */ +static int +memcache_dup_message(LDAPMessage *res, int msgid, int fromcache, + LDAPMessage **ppResCopy, unsigned long *pSize) +{ + int nRes = LDAP_SUCCESS; + unsigned long ber_size; + LDAPMessage *pCur; + LDAPMessage **ppCurNew; + + *ppResCopy = NULL; + + if (pSize) + *pSize = 0; + + /* Make a copy of res */ + for (pCur = res, ppCurNew = ppResCopy; pCur; + pCur = pCur->lm_chain, ppCurNew = &((*ppCurNew)->lm_chain)) { + + if ((*ppCurNew = (LDAPMessage*)NSLDAPI_CALLOC(1, + sizeof(LDAPMessage))) == NULL) { + nRes = LDAP_NO_MEMORY; + break; + } + + memcpy(*ppCurNew, pCur, sizeof(LDAPMessage)); + (*ppCurNew)->lm_next = NULL; + (*ppCurNew)->lm_ber = memcache_ber_dup(pCur->lm_ber, &ber_size); + (*ppCurNew)->lm_msgid = msgid; + (*ppCurNew)->lm_fromcache = (fromcache != 0); + + if (pSize) + *pSize += sizeof(LDAPMessage) + ber_size; + } + + if ((nRes != LDAP_SUCCESS) && (*ppResCopy != NULL)) { + ldap_msgfree(*ppResCopy); + *ppResCopy = NULL; + if (pSize) + *pSize = 0; + } + + return nRes; +} + +/************************* Cache Functions ***********************/ + +/* Frees a cache header. */ +static int +memcache_free_entry(LDAPMemCache *cache, ldapmemcacheRes *pRes) +{ + if (pRes) { + + unsigned long size = sizeof(ldapmemcacheRes); + + if (pRes->ldmemcr_basedn) { + size += strlen(pRes->ldmemcr_basedn) + 1; + NSLDAPI_FREE(pRes->ldmemcr_basedn); + } + + if (pRes->ldmemcr_resHead) { + size += pRes->ldmemcr_resSize; + ldap_msgfree(pRes->ldmemcr_resHead); + } + + NSLDAPI_FREE(pRes); + + memcache_adj_size(cache, size, MEMCACHE_SIZE_ENTRIES, + MEMCACHE_SIZE_DEDUCT); + } + + return( LDAP_SUCCESS ); +} + +/* Detaches a cache header from the list of headers. */ +static int +memcache_free_from_list(LDAPMemCache *cache, ldapmemcacheRes *pRes, int index) +{ + if (pRes->ldmemcr_prev[index]) + pRes->ldmemcr_prev[index]->ldmemcr_next[index] = + pRes->ldmemcr_next[index]; + + if (pRes->ldmemcr_next[index]) + pRes->ldmemcr_next[index]->ldmemcr_prev[index] = + pRes->ldmemcr_prev[index]; + + if (cache->ldmemc_resHead[index] == pRes) + cache->ldmemc_resHead[index] = pRes->ldmemcr_next[index]; + + if (cache->ldmemc_resTail[index] == pRes) + cache->ldmemc_resTail[index] = pRes->ldmemcr_prev[index]; + + pRes->ldmemcr_prev[index] = NULL; + pRes->ldmemcr_next[index] = NULL; + + return( LDAP_SUCCESS ); +} + +/* Inserts a new cache header to a list of headers. */ +static int +memcache_add_to_list(LDAPMemCache *cache, ldapmemcacheRes *pRes, int index) +{ + if (cache->ldmemc_resHead[index]) + cache->ldmemc_resHead[index]->ldmemcr_prev[index] = pRes; + else + cache->ldmemc_resTail[index] = pRes; + + pRes->ldmemcr_prev[index] = NULL; + pRes->ldmemcr_next[index] = cache->ldmemc_resHead[index]; + cache->ldmemc_resHead[index] = pRes; + + return( LDAP_SUCCESS ); +} + +/* Appends a chain of entries to the given cache header. */ +static int +memcache_add_res_to_list(ldapmemcacheRes *pRes, LDAPMessage *pMsg, + unsigned long size) +{ + if (pRes->ldmemcr_resTail) + pRes->ldmemcr_resTail->lm_chain = pMsg; + else + pRes->ldmemcr_resHead = pMsg; + + for (pRes->ldmemcr_resTail = pMsg; + pRes->ldmemcr_resTail->lm_chain; + pRes->ldmemcr_resTail = pRes->ldmemcr_resTail->lm_chain) { + ; + } + + pRes->ldmemcr_resSize += size; + + return( LDAP_SUCCESS ); +} + + +#ifdef LDAP_DEBUG +static void +memcache_print_list( LDAPMemCache *cache, int index ) +{ + char *name; + ldapmemcacheRes *restmp; + + switch( index ) { + case LIST_TTL: + name = "TTL"; + break; + case LIST_LRU: + name = "LRU"; + break; + case LIST_TMP: + name = "TMP"; + break; + case LIST_TOTAL: + name = "TOTAL"; + break; + default: + name = "unknown"; + } + + LDAPDebug( LDAP_DEBUG_TRACE, "memcache 0x%p %s list:\n", + cache, name, 0 ); + for ( restmp = cache->ldmemc_resHead[index]; restmp != NULL; + restmp = restmp->ldmemcr_next[index] ) { + LDAPDebug( LDAP_DEBUG_TRACE, + " key: 0x%8.8lx, ld: 0x%p, msgid: %d\n", + restmp->ldmemcr_crc_key, + restmp->ldmemcr_req_id.ldmemcrid_ld, + restmp->ldmemcr_req_id.ldmemcrid_msgid ); + } + LDAPDebug( LDAP_DEBUG_TRACE, "memcache 0x%p end of %s list.\n", + cache, name, 0 ); +} +#endif /* LDAP_DEBUG */ + +/* Tells whether a cached result has expired. */ +static int +memcache_expired(LDAPMemCache *cache, ldapmemcacheRes *pRes, + unsigned long curTime) +{ + if (!cache->ldmemc_ttl) + return 0; + + return ((unsigned long)difftime( + (time_t)curTime, + (time_t)(pRes->ldmemcr_timestamp)) >= + cache->ldmemc_ttl); +} + +/* Operates the cache in a central place. */ +static int +memcache_access(LDAPMemCache *cache, int mode, + void *pData1, void *pData2, void *pData3) +{ + int nRes = LDAP_SUCCESS; + unsigned long size = 0; + + /* Add a new cache header to the cache. */ + if (mode == MEMCACHE_ACCESS_ADD) { + unsigned long key = *((unsigned long*)pData1); + char *basedn = (char*)pData3; + ldapmemcacheRes *pRes = NULL; + void* hashResult = NULL; + + nRes = htable_get(cache->ldmemc_resTmp, pData2, &hashResult); + if (nRes == LDAP_SUCCESS) + return( LDAP_ALREADY_EXISTS ); + + pRes = (ldapmemcacheRes*)NSLDAPI_CALLOC(1, sizeof(ldapmemcacheRes)); + if (pRes == NULL) + return( LDAP_NO_MEMORY ); + + pRes->ldmemcr_crc_key = key; + pRes->ldmemcr_req_id = *((ldapmemcacheReqId*)pData2); + pRes->ldmemcr_basedn = (basedn ? nsldapi_strdup(basedn) : NULL); + + size += sizeof(ldapmemcacheRes) + strlen(basedn) + 1; + nRes = memcache_adj_size(cache, size, MEMCACHE_SIZE_ENTRIES, + MEMCACHE_SIZE_ADD); + if (nRes == LDAP_SUCCESS) + nRes = htable_put(cache->ldmemc_resTmp, pData2, (void*)pRes); + if (nRes == LDAP_SUCCESS) + memcache_add_to_list(cache, pRes, LIST_TMP); + else + memcache_free_entry(cache, pRes); + } + /* Append entries to an existing cache header. */ + else if ((mode == MEMCACHE_ACCESS_APPEND) || + (mode == MEMCACHE_ACCESS_APPEND_LAST)) { + + LDAPMessage *pMsg = (LDAPMessage*)pData2; + LDAPMessage *pCopy = NULL; + ldapmemcacheRes *pRes = NULL; + void* hashResult = NULL; + + nRes = htable_get(cache->ldmemc_resTmp, pData1, &hashResult); + if (nRes != LDAP_SUCCESS) + return nRes; + + pRes = (ldapmemcacheRes*) hashResult; + nRes = memcache_dup_message(pMsg, pMsg->lm_msgid, 0, &pCopy, &size); + if (nRes != LDAP_SUCCESS) { + nRes = htable_remove(cache->ldmemc_resTmp, pData1, NULL); + assert(nRes == LDAP_SUCCESS); + memcache_free_from_list(cache, pRes, LIST_TMP); + memcache_free_entry(cache, pRes); + return nRes; + } + + nRes = memcache_adj_size(cache, size, MEMCACHE_SIZE_ENTRIES, + MEMCACHE_SIZE_ADD); + if (nRes != LDAP_SUCCESS) { + ldap_msgfree(pCopy); + nRes = htable_remove(cache->ldmemc_resTmp, pData1, NULL); + assert(nRes == LDAP_SUCCESS); + memcache_free_from_list(cache, pRes, LIST_TMP); + memcache_free_entry(cache, pRes); + return nRes; + } + + memcache_add_res_to_list(pRes, pCopy, size); + + if (mode == MEMCACHE_ACCESS_APPEND) + return( LDAP_SUCCESS ); + + nRes = htable_remove(cache->ldmemc_resTmp, pData1, NULL); + assert(nRes == LDAP_SUCCESS); + memcache_free_from_list(cache, pRes, LIST_TMP); + (pRes->ldmemcr_req_id).ldmemcrid_ld = NULL; + (pRes->ldmemcr_req_id).ldmemcrid_msgid = -1; + pRes->ldmemcr_timestamp = (unsigned long)time(NULL); + + if ((nRes = htable_put(cache->ldmemc_resLookup, + (void*)&(pRes->ldmemcr_crc_key), + (void*)pRes)) == LDAP_SUCCESS) { + memcache_add_to_list(cache, pRes, LIST_TTL); + memcache_add_to_list(cache, pRes, LIST_LRU); + } else { + memcache_free_entry(cache, pRes); + } + } + /* Search for cached entries for a particular search. */ + else if (mode == MEMCACHE_ACCESS_FIND) { + + ldapmemcacheRes **ppRes = (ldapmemcacheRes**)pData2; + + nRes = htable_get(cache->ldmemc_resLookup, pData1, (void**)ppRes); + if (nRes != LDAP_SUCCESS) + return nRes; + + if (!memcache_expired(cache, *ppRes, (unsigned long)time(0))) { + memcache_free_from_list(cache, *ppRes, LIST_LRU); + memcache_add_to_list(cache, *ppRes, LIST_LRU); + return( LDAP_SUCCESS ); + } + + nRes = htable_remove(cache->ldmemc_resLookup, pData1, NULL); + assert(nRes == LDAP_SUCCESS); + memcache_free_from_list(cache, *ppRes, LIST_TTL); + memcache_free_from_list(cache, *ppRes, LIST_LRU); + memcache_free_entry(cache, *ppRes); + nRes = LDAP_NO_SUCH_OBJECT; + *ppRes = NULL; + } + /* Remove cached entries in the temporary cache. */ + else if (mode == MEMCACHE_ACCESS_DELETE) { + + void* hashResult = NULL; + + if ((nRes = htable_remove(cache->ldmemc_resTmp, pData1, + &hashResult)) == LDAP_SUCCESS) { + ldapmemcacheRes *pCurRes = (ldapmemcacheRes*) hashResult; + memcache_free_from_list(cache, pCurRes, LIST_TMP); + memcache_free_entry(cache, pCurRes); + } + } + /* Wipe out the temporary cache. */ + else if (mode == MEMCACHE_ACCESS_DELETE_ALL) { + + nRes = htable_removeall(cache->ldmemc_resTmp, (void*)cache); + } + /* Remove expired entries from primary cache. */ + else if (mode == MEMCACHE_ACCESS_UPDATE) { + + ldapmemcacheRes *pCurRes = cache->ldmemc_resTail[LIST_TTL]; + unsigned long curTime = (unsigned long)time(NULL); + + for (; pCurRes; pCurRes = cache->ldmemc_resTail[LIST_TTL]) { + + if (!memcache_expired(cache, pCurRes, curTime)) + break; + + nRes = htable_remove(cache->ldmemc_resLookup, + (void*)&(pCurRes->ldmemcr_crc_key), NULL); + assert(nRes == LDAP_SUCCESS); + memcache_free_from_list(cache, pCurRes, LIST_TTL); + memcache_free_from_list(cache, pCurRes, LIST_LRU); + memcache_free_entry(cache, pCurRes); + } + } + /* Wipe out the primary cache. */ + else if (mode == MEMCACHE_ACCESS_FLUSH_ALL) { + + ldapmemcacheRes *pCurRes = cache->ldmemc_resHead[LIST_TTL]; + + nRes = htable_removeall(cache->ldmemc_resLookup, (void*)cache); + + for (; pCurRes; pCurRes = cache->ldmemc_resHead[LIST_TTL]) { + memcache_free_from_list(cache, pCurRes, LIST_LRU); + cache->ldmemc_resHead[LIST_TTL] = + cache->ldmemc_resHead[LIST_TTL]->ldmemcr_next[LIST_TTL]; + memcache_free_entry(cache, pCurRes); + } + cache->ldmemc_resTail[LIST_TTL] = NULL; + } + /* Remove cached entries in both primary and temporary cache. */ + else if ((mode == MEMCACHE_ACCESS_FLUSH) || + (mode == MEMCACHE_ACCESS_FLUSH_RESULTS)) { + + int i, list_id, bDone; + int scope = (int)pData2; + char *dn = (char*)pData1; + char *dnTmp; + BerElement ber; + LDAPMessage *pMsg; + ldapmemcacheRes *pRes; + + if (cache->ldmemc_basedns) { + for (i = 0; cache->ldmemc_basedns[i]; i++) { + if ((memcache_compare_dn(cache->ldmemc_basedns[i], dn, + LDAP_SCOPE_SUBTREE) == LDAP_COMPARE_TRUE) || + (memcache_compare_dn(dn, cache->ldmemc_basedns[i], + LDAP_SCOPE_SUBTREE) == LDAP_COMPARE_TRUE)) + break; + } + if (cache->ldmemc_basedns[i] == NULL) + return( LDAP_SUCCESS ); + } + + for (i = 0; i < 2; i++) { + + list_id = (i == 0 ? LIST_TTL : LIST_TMP); + + for (pRes = cache->ldmemc_resHead[list_id]; pRes != NULL; + pRes = pRes->ldmemcr_next[list_id]) { + + int foundentries = 0; + + if ((memcache_compare_dn(pRes->ldmemcr_basedn, dn, + LDAP_SCOPE_SUBTREE) != LDAP_COMPARE_TRUE) && + (memcache_compare_dn(dn, pRes->ldmemcr_basedn, + LDAP_SCOPE_SUBTREE) != LDAP_COMPARE_TRUE)) + continue; + + for (pMsg = pRes->ldmemcr_resHead, bDone = 0; + !bDone && pMsg; pMsg = pMsg->lm_chain) { + + if (!NSLDAPI_IS_SEARCH_ENTRY( pMsg->lm_msgtype )) + continue; + foundentries = 1; + ber = *(pMsg->lm_ber); + if (ber_scanf(&ber, "{a", &dnTmp) != LBER_ERROR) { + bDone = (memcache_compare_dn(dnTmp, dn, scope) == + LDAP_COMPARE_TRUE); + ldap_memfree(dnTmp); + } + } + + /* If we're in the result flush mode, and the base matched, and + there were no entries in the result, we'll flush this cache + slot, as opposed to the MEMCACHE_ACCESS_FLUSH mode which does + not flush negative results. */ + if ((mode == MEMCACHE_ACCESS_FLUSH_RESULTS) && !foundentries) { + bDone = 1; + } + + if (!bDone) + continue; + + if (list_id == LIST_TTL) { + nRes = htable_remove(cache->ldmemc_resLookup, + (void*)&(pRes->ldmemcr_crc_key), NULL); + assert(nRes == LDAP_SUCCESS); + memcache_free_from_list(cache, pRes, LIST_TTL); + memcache_free_from_list(cache, pRes, LIST_LRU); + } else { + nRes = htable_remove(cache->ldmemc_resTmp, + (void*)&(pRes->ldmemcr_req_id), NULL); + assert(nRes == LDAP_SUCCESS); + memcache_free_from_list(cache, pRes, LIST_TMP); + } + memcache_free_entry(cache, pRes); + } + } + } + /* Flush least recently used entries from cache */ + else if (mode == MEMCACHE_ACCESS_FLUSH_LRU) { + + ldapmemcacheRes *pRes = cache->ldmemc_resTail[LIST_LRU]; + + if (pRes == NULL) + return LDAP_NO_SUCH_OBJECT; + + LDAPDebug( LDAP_DEBUG_TRACE, + "memcache_access FLUSH_LRU: removing key 0x%8.8lx\n", + pRes->ldmemcr_crc_key, 0, 0 ); + nRes = htable_remove(cache->ldmemc_resLookup, + (void*)&(pRes->ldmemcr_crc_key), NULL); + assert(nRes == LDAP_SUCCESS); + memcache_free_from_list(cache, pRes, LIST_TTL); + memcache_free_from_list(cache, pRes, LIST_LRU); + memcache_free_entry(cache, pRes); + } + /* Unknown command */ + else { + nRes = LDAP_PARAM_ERROR; + } + + return nRes; +} + +static void +memcache_flush( LDAPMemCache *cache, char *dn, int scope, int flushresults ) +{ + if ( !NSLDAPI_VALID_MEMCACHE_POINTER( cache )) { + return; + } + + LDAP_MEMCACHE_MUTEX_LOCK( cache ); + + if (!dn) { + memcache_access(cache, MEMCACHE_ACCESS_FLUSH_ALL, NULL, NULL, NULL); + } else { + if (flushresults) { + memcache_access(cache, MEMCACHE_ACCESS_FLUSH_RESULTS, + (void*)dn, (void*)scope, NULL); + } else { + memcache_access(cache, MEMCACHE_ACCESS_FLUSH, + (void*)dn, (void*)scope, NULL); + } + } + + LDAP_MEMCACHE_MUTEX_UNLOCK( cache ); +} + + +#ifdef LDAP_DEBUG +static void +memcache_report_statistics( LDAPMemCache *cache ) +{ + unsigned long hitrate; + + if ( cache->ldmemc_stats.ldmemcstat_tries == 0 ) { + hitrate = 0; + } else { + hitrate = ( 100L * cache->ldmemc_stats.ldmemcstat_hits ) / + cache->ldmemc_stats.ldmemcstat_tries; + } + LDAPDebug( LDAP_DEBUG_STATS, "memcache 0x%p:\n", cache, 0, 0 ); + LDAPDebug( LDAP_DEBUG_STATS, " tries: %ld hits: %ld hitrate: %ld%%\n", + cache->ldmemc_stats.ldmemcstat_tries, + cache->ldmemc_stats.ldmemcstat_hits, hitrate ); + if ( cache->ldmemc_size <= 0 ) { /* no size limit */ + LDAPDebug( LDAP_DEBUG_STATS, " memory bytes used: %ld\n", + cache->ldmemc_size_used, 0, 0 ); + } else { + LDAPDebug( LDAP_DEBUG_STATS, " memory bytes used: %ld free: %ld\n", + cache->ldmemc_size_used, + cache->ldmemc_size - cache->ldmemc_size_used, 0 ); + } +} +#endif /* LDAP_DEBUG */ + +/************************ Hash Table Functions *****************************/ + +/* Calculates size (# of entries) of hash table given the size limit for + the cache. */ +static int +htable_calculate_size(int sizelimit) +{ + int i, j; + int size = (int)(((double)sizelimit / + (double)(sizeof(BerElement) + EXTRA_SIZE)) / 1.5); + + /* Get a prime # */ + size = (size & 0x1 ? size : size + 1); + for (i = 3, j = size / 2; i < j; i++) { + if ((size % i) == 0) { + size += 2; + i = 3; + j = size / 2; + } + } + + return size; +} + +/* Returns the size in bytes of the given hash table. */ +static int +htable_sizeinbytes(HashTable *pTable) +{ + if (!pTable) + return 0; + + return (pTable->size * sizeof(HashTableNode)); +} + +/* Inserts an item into the hash table. */ +static int +htable_put(HashTable *pTable, void *key, void *pData) +{ + int index = pTable->hashfunc(pTable->size, key); + + if (index >= 0 && index < pTable->size) + return pTable->putdata(&(pTable->table[index].pData), key, pData); + + return( LDAP_OPERATIONS_ERROR ); +} + +/* Retrieves an item from the hash table. */ +static int +htable_get(HashTable *pTable, void *key, void **ppData) +{ + int index = pTable->hashfunc(pTable->size, key); + + *ppData = NULL; + + if (index >= 0 && index < pTable->size) + return pTable->getdata(pTable->table[index].pData, key, ppData); + + return( LDAP_OPERATIONS_ERROR ); +} + +/* Performs a miscellaneous operation on a hash table entry. */ +static int +htable_misc(HashTable *pTable, void *key, void *pData) +{ + if (pTable->miscfunc) { + int index = pTable->hashfunc(pTable->size, key); + if (index >= 0 && index < pTable->size) + return pTable->miscfunc(&(pTable->table[index].pData), key, pData); + } + + return( LDAP_OPERATIONS_ERROR ); +} + +/* Removes an item from the hash table. */ +static int +htable_remove(HashTable *pTable, void *key, void **ppData) +{ + int index = pTable->hashfunc(pTable->size, key); + + if (ppData) + *ppData = NULL; + + if (index >= 0 && index < pTable->size) + return pTable->removedata(&(pTable->table[index].pData), key, ppData); + + return( LDAP_OPERATIONS_ERROR ); +} + +/* Removes everything in the hash table. */ +static int +htable_removeall(HashTable *pTable, void *pData) +{ + int i; + + for (i = 0; i < pTable->size; i++) + pTable->clrtablenode(&(pTable->table[i].pData), pData); + + return( LDAP_SUCCESS ); +} + +/* Creates a new hash table. */ +static int +htable_create(int size_limit, HashFuncPtr hashf, + PutDataPtr putDataf, GetDataPtr getDataf, + RemoveDataPtr removeDataf, ClrTableNodePtr clrNodef, + MiscFuncPtr miscOpf, HashTable **ppTable) +{ + size_limit = htable_calculate_size(size_limit); + + if ((*ppTable = (HashTable*)NSLDAPI_CALLOC(1, sizeof(HashTable))) == NULL) + return( LDAP_NO_MEMORY ); + + (*ppTable)->table = (HashTableNode*)NSLDAPI_CALLOC(size_limit, + sizeof(HashTableNode)); + if ((*ppTable)->table == NULL) { + NSLDAPI_FREE(*ppTable); + *ppTable = NULL; + return( LDAP_NO_MEMORY ); + } + + (*ppTable)->size = size_limit; + (*ppTable)->hashfunc = hashf; + (*ppTable)->putdata = putDataf; + (*ppTable)->getdata = getDataf; + (*ppTable)->miscfunc = miscOpf; + (*ppTable)->removedata = removeDataf; + (*ppTable)->clrtablenode = clrNodef; + + return( LDAP_SUCCESS ); +} + +/* Destroys a hash table. */ +static int +htable_free(HashTable *pTable) +{ + NSLDAPI_FREE(pTable->table); + NSLDAPI_FREE(pTable); + return( LDAP_SUCCESS ); +} + +/**************** Hash table callbacks for temporary cache ****************/ + +/* Hash function */ +static int +msgid_hashf(int table_size, void *key) +{ + unsigned code = (unsigned)((ldapmemcacheReqId*)key)->ldmemcrid_ld; + return (((code << 20) + (code >> 12)) % table_size); +} + +/* Called by hash table to insert an item. */ +static int +msgid_putdata(void **ppTableData, void *key, void *pData) +{ + ldapmemcacheReqId *pReqId = (ldapmemcacheReqId*)key; + ldapmemcacheRes *pRes = (ldapmemcacheRes*)pData; + ldapmemcacheRes **ppHead = (ldapmemcacheRes**)ppTableData; + ldapmemcacheRes *pCurRes = *ppHead; + ldapmemcacheRes *pPrev = NULL; + + for (; pCurRes; pCurRes = pCurRes->ldmemcr_htable_next) { + if ((pCurRes->ldmemcr_req_id).ldmemcrid_ld == pReqId->ldmemcrid_ld) + break; + pPrev = pCurRes; + } + + if (pCurRes) { + for (; pCurRes; pCurRes = pCurRes->ldmemcr_next[LIST_TTL]) { + if ((pCurRes->ldmemcr_req_id).ldmemcrid_msgid == + pReqId->ldmemcrid_msgid) + return( LDAP_ALREADY_EXISTS ); + pPrev = pCurRes; + } + pPrev->ldmemcr_next[LIST_TTL] = pRes; + pRes->ldmemcr_prev[LIST_TTL] = pPrev; + pRes->ldmemcr_next[LIST_TTL] = NULL; + } else { + if (pPrev) + pPrev->ldmemcr_htable_next = pRes; + else + *ppHead = pRes; + pRes->ldmemcr_htable_next = NULL; + } + + return( LDAP_SUCCESS ); +} + +/* Called by hash table to retrieve an item. */ +static int +msgid_getdata(void *pTableData, void *key, void **ppData) +{ + ldapmemcacheReqId *pReqId = (ldapmemcacheReqId*)key; + ldapmemcacheRes *pCurRes = (ldapmemcacheRes*)pTableData; + + *ppData = NULL; + + for (; pCurRes; pCurRes = pCurRes->ldmemcr_htable_next) { + if ((pCurRes->ldmemcr_req_id).ldmemcrid_ld == pReqId->ldmemcrid_ld) + break; + } + + if (!pCurRes) + return( LDAP_NO_SUCH_OBJECT ); + + for (; pCurRes; pCurRes = pCurRes->ldmemcr_next[LIST_TTL]) { + if ((pCurRes->ldmemcr_req_id).ldmemcrid_msgid == + pReqId->ldmemcrid_msgid) { + *ppData = (void*)pCurRes; + return( LDAP_SUCCESS ); + } + } + + return( LDAP_NO_SUCH_OBJECT ); +} + +/* Called by hash table to remove an item. */ +static int +msgid_removedata(void **ppTableData, void *key, void **ppData) +{ + ldapmemcacheRes *pHead = *((ldapmemcacheRes**)ppTableData); + ldapmemcacheRes *pCurRes = NULL; + ldapmemcacheRes *pPrev = NULL; + ldapmemcacheReqId *pReqId = (ldapmemcacheReqId*)key; + + if (ppData) + *ppData = NULL; + + for (; pHead; pHead = pHead->ldmemcr_htable_next) { + if ((pHead->ldmemcr_req_id).ldmemcrid_ld == pReqId->ldmemcrid_ld) + break; + pPrev = pHead; + } + + if (!pHead) + return( LDAP_NO_SUCH_OBJECT ); + + for (pCurRes = pHead; pCurRes; pCurRes = pCurRes->ldmemcr_next[LIST_TTL]) { + if ((pCurRes->ldmemcr_req_id).ldmemcrid_msgid == + pReqId->ldmemcrid_msgid) + break; + } + + if (!pCurRes) + return( LDAP_NO_SUCH_OBJECT ); + + if (ppData) { + pCurRes->ldmemcr_next[LIST_TTL] = NULL; + pCurRes->ldmemcr_prev[LIST_TTL] = NULL; + pCurRes->ldmemcr_htable_next = NULL; + *ppData = (void*)pCurRes; + } + + if (pCurRes != pHead) { + if (pCurRes->ldmemcr_prev[LIST_TTL]) + pCurRes->ldmemcr_prev[LIST_TTL]->ldmemcr_next[LIST_TTL] = + pCurRes->ldmemcr_next[LIST_TTL]; + if (pCurRes->ldmemcr_next[LIST_TTL]) + pCurRes->ldmemcr_next[LIST_TTL]->ldmemcr_prev[LIST_TTL] = + pCurRes->ldmemcr_prev[LIST_TTL]; + return( LDAP_SUCCESS ); + } + + if (pPrev) { + if (pHead->ldmemcr_next[LIST_TTL]) { + pPrev->ldmemcr_htable_next = pHead->ldmemcr_next[LIST_TTL]; + pHead->ldmemcr_next[LIST_TTL]->ldmemcr_htable_next = + pHead->ldmemcr_htable_next; + } else { + pPrev->ldmemcr_htable_next = pHead->ldmemcr_htable_next; + } + } else { + if (pHead->ldmemcr_next[LIST_TTL]) { + *((ldapmemcacheRes**)ppTableData) = pHead->ldmemcr_next[LIST_TTL]; + pHead->ldmemcr_next[LIST_TTL]->ldmemcr_htable_next = + pHead->ldmemcr_htable_next; + } else { + *((ldapmemcacheRes**)ppTableData) = pHead->ldmemcr_htable_next; + } + } + + return( LDAP_SUCCESS ); +} + +/* Called by hash table to remove all cached entries associated to searches + being performed using the given ldap handle. */ +static int +msgid_clear_ld_items(void **ppTableData, void *key, void *pData) +{ + LDAPMemCache *cache = (LDAPMemCache*)pData; + ldapmemcacheRes *pHead = *((ldapmemcacheRes**)ppTableData); + ldapmemcacheRes *pPrev = NULL; + ldapmemcacheRes *pCurRes = NULL; + ldapmemcacheReqId *pReqId = (ldapmemcacheReqId*)key; + + for (; pHead; pHead = pHead->ldmemcr_htable_next) { + if ((pHead->ldmemcr_req_id).ldmemcrid_ld == pReqId->ldmemcrid_ld) + break; + pPrev = pHead; + } + + if (!pHead) + return( LDAP_NO_SUCH_OBJECT ); + + if (pPrev) + pPrev->ldmemcr_htable_next = pHead->ldmemcr_htable_next; + else + *((ldapmemcacheRes**)ppTableData) = pHead->ldmemcr_htable_next; + + for (pCurRes = pHead; pHead; pCurRes = pHead) { + pHead = pHead->ldmemcr_next[LIST_TTL]; + memcache_free_from_list(cache, pCurRes, LIST_TMP); + memcache_free_entry(cache, pCurRes); + } + + return( LDAP_SUCCESS ); +} + +/* Called by hash table for removing all items in the table. */ +static void +msgid_clearnode(void **ppTableData, void *pData) +{ + LDAPMemCache *cache = (LDAPMemCache*)pData; + ldapmemcacheRes **ppHead = (ldapmemcacheRes**)ppTableData; + ldapmemcacheRes *pSubHead = *ppHead; + ldapmemcacheRes *pCurRes = NULL; + + for (; *ppHead; pSubHead = *ppHead) { + ppHead = &((*ppHead)->ldmemcr_htable_next); + for (pCurRes = pSubHead; pSubHead; pCurRes = pSubHead) { + pSubHead = pSubHead->ldmemcr_next[LIST_TTL]; + memcache_free_from_list(cache, pCurRes, LIST_TMP); + memcache_free_entry(cache, pCurRes); + } + } +} + +/********************* Hash table for primary cache ************************/ + +/* Hash function */ +static int +attrkey_hashf(int table_size, void *key) +{ + return ((*((unsigned long*)key)) % table_size); +} + +/* Called by hash table to insert an item. */ +static int +attrkey_putdata(void **ppTableData, void *key, void *pData) +{ + unsigned long attrkey = *((unsigned long*)key); + ldapmemcacheRes **ppHead = (ldapmemcacheRes**)ppTableData; + ldapmemcacheRes *pRes = *ppHead; + + for (; pRes; pRes = pRes->ldmemcr_htable_next) { + if (pRes->ldmemcr_crc_key == attrkey) + return( LDAP_ALREADY_EXISTS ); + } + + pRes = (ldapmemcacheRes*)pData; + pRes->ldmemcr_htable_next = *ppHead; + *ppHead = pRes; + + return( LDAP_SUCCESS ); +} + +/* Called by hash table to retrieve an item. */ +static int +attrkey_getdata(void *pTableData, void *key, void **ppData) +{ + unsigned long attrkey = *((unsigned long*)key); + ldapmemcacheRes *pRes = (ldapmemcacheRes*)pTableData; + + for (; pRes; pRes = pRes->ldmemcr_htable_next) { + if (pRes->ldmemcr_crc_key == attrkey) { + *ppData = (void*)pRes; + return( LDAP_SUCCESS ); + } + } + + *ppData = NULL; + + return( LDAP_NO_SUCH_OBJECT ); +} + +/* Called by hash table to remove an item. */ +static int +attrkey_removedata(void **ppTableData, void *key, void **ppData) +{ + unsigned long attrkey = *((unsigned long*)key); + ldapmemcacheRes **ppHead = (ldapmemcacheRes**)ppTableData; + ldapmemcacheRes *pRes = *ppHead; + ldapmemcacheRes *pPrev = NULL; + + for (; pRes; pRes = pRes->ldmemcr_htable_next) { + if (pRes->ldmemcr_crc_key == attrkey) { + if (ppData) + *ppData = (void*)pRes; + if (pPrev) + pPrev->ldmemcr_htable_next = pRes->ldmemcr_htable_next; + else + *ppHead = pRes->ldmemcr_htable_next; + pRes->ldmemcr_htable_next = NULL; + return( LDAP_SUCCESS ); + } + pPrev = pRes; + } + + if (ppData) + *ppData = NULL; + + return( LDAP_NO_SUCH_OBJECT ); +} + +/* Called by hash table for removing all items in the table. */ +static void +attrkey_clearnode(void **ppTableData, void *pData) +{ + ldapmemcacheRes **ppHead = (ldapmemcacheRes**)ppTableData; + ldapmemcacheRes *pRes = *ppHead; + + (void)pData; + + for (; *ppHead; pRes = *ppHead) { + ppHead = &((*ppHead)->ldmemcr_htable_next); + pRes->ldmemcr_htable_next = NULL; + } +} + +/***************************** CRC algorithm ********************************/ + +/* From http://www.faqs.org/faqs/compression-faq/part1/section-25.html */ + +/* + * Build auxiliary table for parallel byte-at-a-time CRC-32. + */ +#define NSLDAPI_CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ + +static nsldapi_uint_32 crc32_table[256] = { + 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, + 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, + 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, + 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, + 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, + 0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, + 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef, + 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, + 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, + 0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, + 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0, + 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, + 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, + 0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, + 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, + 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, + 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, + 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, + 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050, + 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, + 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, + 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, + 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1, + 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, + 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, + 0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, + 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9, + 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, + 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, + 0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, + 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71, + 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, + 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, + 0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, + 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, + 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, + 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, + 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, + 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676, + 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, + 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, + 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, + 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 }; + +/* Initialized first time "crc32()" is called. If you prefer, you can + * statically initialize it at compile time. [Another exercise.] + */ + +static unsigned long +crc32_convert(char *buf, int len) +{ + unsigned char *p; + nsldapi_uint_32 crc; + + crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ + for (p = (unsigned char *)buf; len > 0; ++p, --len) + crc = ((crc << 8) ^ crc32_table[(crc >> 24) ^ *p]) & 0xffffffff; + + return (unsigned long) ~crc; /* transmit complement, per CRC-32 spec */ +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/message.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/message.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/modify.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/modify.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/mozock.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/mozock.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/nsprthreadtest.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/nsprthreadtest.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/open.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/open.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/os-ip.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/os-ip.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/proxyauthctrl.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/proxyauthctrl.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/psearch.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/psearch.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/pthreadtest.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/pthreadtest.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/pwmodext.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/pwmodext.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/pwpctrl.c
Added
@@ -0,0 +1,315 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Sun LDAP C SDK. + * + * The Initial Developer of the Original Code is Sun Microsystems, Inc. + * + * Portions created by Sun Microsystems, Inc are Copyright (C) 2005 + * Sun Microsystems, Inc. All Rights Reserved. + * + * Contributor(s): abobrov@sun.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "ldap-int.h" + +/* ldap_create_passwordpolicy_control: + +Parameters are + +ld LDAP pointer to the desired connection + +ctrlp the address of a place to put the constructed control +*/ + +int +LDAP_CALL +ldap_create_passwordpolicy_control ( + LDAP *ld, + LDAPControl **ctrlp + ) +{ + int rc; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + return( LDAP_PARAM_ERROR ); + } + + if ( ctrlp == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return ( LDAP_PARAM_ERROR ); + } + + rc = nsldapi_build_control( LDAP_CONTROL_PASSWD_POLICY, + NULL, 0, 0, ctrlp ); + + LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); + return( rc ); +} + +/* ldap_create_passwordpolicy_control_ext: + +Parameters are + +ld LDAP pointer to the desired connection + +ctl_iscritical Indicates whether the control is critical of not. If + this field is non-zero, the operation will only be car- + ried out if the control is recognized by the server + and/or client + +ctrlp the address of a place to put the constructed control +*/ + +int +LDAP_CALL +ldap_create_passwordpolicy_control_ext ( + LDAP *ld, + const char ctl_iscritical, + LDAPControl **ctrlp + ) +{ + int rc; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + return( LDAP_PARAM_ERROR ); + } + + if ( ctrlp == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return ( LDAP_PARAM_ERROR ); + } + + rc = nsldapi_build_control( LDAP_CONTROL_PASSWD_POLICY, + NULL, 0, ctl_iscritical, ctrlp ); + + LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); + return( rc ); +} + +/* ldap_parse_passwordpolicy_control: + +Parameters are + +ld LDAP pointer to the desired connection + +ctrlp pointer to LDAPControl structure, obtained from + calling ldap_find_control() or by other means. + +exptimep result parameter is filled in with the number of seconds before + the password will expire. + +gracep result parameter is filled in with the number of grace logins + after the password has expired. + +errorcodep result parameter is filled in with the error code of the + password operation. +*/ + +int +LDAP_CALL +ldap_parse_passwordpolicy_control ( + LDAP *ld, + LDAPControl *ctrlp, + ber_int_t *expirep, + ber_int_t *gracep, + LDAPPasswordPolicyError *errorp + ) +{ + ber_len_t len; + ber_tag_t tag; + ber_int_t pp_exp = -1; + ber_int_t pp_grace = -1; + ber_int_t pp_warning = -1; + ber_int_t pp_err = PP_noError; + BerElement *ber = NULL; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) ) { + return( LDAP_PARAM_ERROR ); + } + + if ( ctrlp == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); + return ( LDAP_CONTROL_NOT_FOUND ); + } + + /* allocate a Ber element with the contents of the control's struct berval */ + if ( ( ber = ber_init( &ctrlp->ldctl_value ) ) == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); + return( LDAP_NO_MEMORY ); + } + + /* + * The control value should look like this: + * + * PasswordPolicyResponseValue ::= SEQUENCE { + * warning [0] CHOICE { + * timeBeforeExpiration [0] INTEGER (0 .. maxInt), + * graceLoginsRemaining [1] INTEGER (0 .. maxInt) } OPTIONAL + * error [1] ENUMERATED { + * passwordExpired (0), + * accountLocked (1), + * changeAfterReset (2), + * passwordModNotAllowed (3), + * mustSupplyOldPassword (4), + * insufficientPasswordQuality (5), + * passwordTooShort (6), + * passwordTooYoung (7), + * passwordInHistory (8) } OPTIONAL } + */ + + if ( ber_scanf( ber, "{" ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + + tag = ber_peek_tag( ber, &len ); + + while ( (tag != LBER_ERROR) && (tag != LBER_END_OF_SEQORSET) ) { + if ( tag == ( LBER_CONSTRUCTED | LBER_CLASS_CONTEXT ) ) { + ber_skip_tag( ber, &len ); + if ( ber_scanf( ber, "ti", &tag, &pp_warning ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + if ( tag == LBER_CLASS_CONTEXT ) { + pp_exp = pp_warning; + } else if ( tag == ( LBER_CLASS_CONTEXT | 0x01 ) ) { + pp_grace = pp_warning; + } + } else if ( tag == ( LBER_CLASS_CONTEXT | 0x01 ) ) { + if ( ber_scanf( ber, "ti", &tag, &pp_err ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + } + if ( tag == LBER_DEFAULT ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + tag = ber_skip_tag( ber, &len ); + } + + if (expirep) *expirep = pp_exp; + if (gracep) *gracep = pp_grace; + if (errorp) *errorp = pp_err; + + /* the ber encoding is no longer needed */ + ber_free( ber, 1 ); + return( LDAP_SUCCESS ); +} + +/* ldap_parse_passwordpolicy_control_ext: + +Parameters are + +ld LDAP pointer to the desired connection + +ctrlp An array of controls obtained from calling + ldap_parse_result on the set of results + returned by the server + +exptimep result parameter is filled in with the number of seconds before + the password will expire. + +gracep result parameter is filled in with the number of grace logins + after the password has expired. + +errorcodep result parameter is filled in with the error code of the + password operation. +*/ + +int +LDAP_CALL +ldap_parse_passwordpolicy_control_ext ( + LDAP *ld, + LDAPControl **ctrlp, + ber_int_t *expirep, + ber_int_t *gracep, + LDAPPasswordPolicyError *errorp + ) +{ + int i, foundPPControl; + LDAPControl *PPCtrlp = NULL; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) ) { + return( LDAP_PARAM_ERROR ); + } + + /* find the control in the list of controls if it exists */ + if ( ctrlp == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); + return ( LDAP_CONTROL_NOT_FOUND ); + } + foundPPControl = 0; + for ( i = 0; (( ctrlp[i] != NULL ) && ( !foundPPControl )); i++ ) { + foundPPControl = !strcmp( ctrlp[i]->ldctl_oid, LDAP_CONTROL_PASSWD_POLICY ); + } + if ( !foundPPControl ) { + LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); + return ( LDAP_CONTROL_NOT_FOUND ); + } else { + /* let local var point to the control */ + PPCtrlp = ctrlp[i-1]; + } + + return ( + ldap_parse_passwordpolicy_control( ld, PPCtrlp, expirep, gracep, errorp )); +} + +const char * +LDAP_CALL +ldap_passwordpolicy_err2txt( LDAPPasswordPolicyError err ) +{ + switch(err) { + case PP_passwordExpired: + return "Password expired"; + case PP_accountLocked: + return "Account locked"; + case PP_changeAfterReset: + return "Password must be changed"; + case PP_passwordModNotAllowed: + return "Policy prevents password modification"; + case PP_mustSupplyOldPassword: + return "Policy requires old password in order to change password"; + case PP_insufficientPasswordQuality: + return "Password fails quality checks"; + case PP_passwordTooShort: + return "Password is too short for policy"; + case PP_passwordTooYoung: + return "Password has been changed too recently"; + case PP_passwordInHistory: + return "New password is in list of old passwords"; + case PP_noError: + return "No error"; + default: + return "Unknown error code"; + } +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/referral.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/referral.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/regex.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/regex.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/rename.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/rename.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/request.c
Added
@@ -0,0 +1,1659 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +/* + * Copyright (c) 1995 Regents of the University of Michigan. + * All rights reserved. + */ +/* + * request.c - sending of ldap requests; handling of referrals + */ + +#if 0 +#ifndef lint +static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n"; +#endif +#endif + +#include "ldap-int.h" + +static LDAPConn *find_connection( LDAP *ld, LDAPServer *srv, int any ); +static void free_servers( LDAPServer *srvlist ); +static int chase_one_referral( LDAP *ld, LDAPRequest *lr, LDAPRequest *origreq, + char *refurl, char *desc, int *unknownp, int is_reference ); +static int re_encode_request( LDAP *ld, BerElement *origber, + int msgid, LDAPURLDesc *ludp, BerElement **berp, int is_reference ); + +#ifdef LDAP_DNS +static LDAPServer *dn2servers( LDAP *ld, char *dn ); +#endif /* LDAP_DNS */ + + +/* returns an LDAP error code and also sets error inside LDAP * */ +int +nsldapi_alloc_ber_with_options( LDAP *ld, BerElement **berp ) +{ + int err; + + LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK ); + if (( *berp = ber_alloc_t( ld->ld_lberoptions )) == NULLBER ) { + err = LDAP_NO_MEMORY; + LDAP_SET_LDERRNO( ld, err, NULL, NULL ); + } else { + err = LDAP_SUCCESS; +#ifdef STR_TRANSLATION + nsldapi_set_ber_options( ld, *berp ); +#endif /* STR_TRANSLATION */ + } + LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); + + return( err ); +} + + +void +nsldapi_set_ber_options( LDAP *ld, BerElement *ber ) +{ + ber->ber_options = ld->ld_lberoptions; +#ifdef STR_TRANSLATION + if (( ld->ld_lberoptions & LBER_OPT_TRANSLATE_STRINGS ) != 0 ) { + ber_set_string_translators( ber, + ld->ld_lber_encode_translate_proc, + ld->ld_lber_decode_translate_proc ); + } +#endif /* STR_TRANSLATION */ +} + + +/* returns the message id of the request or -1 if an error occurs */ +int +nsldapi_send_initial_request( LDAP *ld, int msgid, unsigned long msgtype, + char *dn, BerElement *ber ) +{ + LDAPServer *servers; + + LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_send_initial_request\n", 0,0,0 ); + +#ifdef LDAP_DNS + LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK ); + if (( ld->ld_options & LDAP_BITOPT_DNS ) != 0 && ldap_is_dns_dn( dn )) { + if (( servers = dn2servers( ld, dn )) == NULL ) { + ber_free( ber, 1 ); + LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); + return( -1 ); + } + +#ifdef LDAP_DEBUG + if ( ldap_debug & LDAP_DEBUG_TRACE ) { + LDAPServer *srv; + char msg[256]; + + for ( srv = servers; srv != NULL; + srv = srv->lsrv_next ) { + sprintf( msg, + "LDAP server %s: dn %s, port %d\n", + srv->lsrv_host, ( srv->lsrv_dn == NULL ) ? + "(default)" : srv->lsrv_dn, + srv->lsrv_port ); + ber_err_print( msg ); + } + } +#endif /* LDAP_DEBUG */ + } else { +#endif /* LDAP_DNS */ + /* + * use of DNS is turned off or this is an LDAP DN... + * use our default connection + */ + servers = NULL; +#ifdef LDAP_DNS + } + LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); +#endif /* LDAP_DNS */ + + return( nsldapi_send_server_request( ld, ber, msgid, NULL, + servers, NULL, ( msgtype == LDAP_REQ_BIND ) ? dn : NULL, 0 )); +} + + +/* returns the message id of the request or -1 if an error occurs */ +int +nsldapi_send_server_request( + LDAP *ld, /* session handle */ + BerElement *ber, /* message to send */ + int msgid, /* ID of message to send */ + LDAPRequest *parentreq, /* non-NULL for referred requests */ + LDAPServer *srvlist, /* servers to connect to (NULL for default) */ + LDAPConn *lc, /* connection to use (NULL for default) */ + char *bindreqdn, /* non-NULL for bind requests */ + int bind /* perform a bind after opening new conn.? */ +) +{ + LDAPRequest *lr; + int err; + int incparent; /* did we bump parent's ref count? */ + /* EPIPE and Unsolicited Response handling variables */ + int res_rc = 0; + int epipe_err = 0; + int ext_res_rc = 0; + char *ext_oid = NULL; + struct berval *ext_data = NULL; + LDAPMessage *ext_res = NULL; + + LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_send_server_request\n", 0, 0, 0 ); + + incparent = 0; + LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK ); + if ( lc == NULL ) { + if ( srvlist == NULL ) { + if ( ld->ld_defconn == NULL ) { + LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK ); + if ( bindreqdn == NULL && ( ld->ld_options + & LDAP_BITOPT_RECONNECT ) != 0 ) { + LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, + NULL, NULL ); + ber_free( ber, 1 ); + LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); + LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); + return( -1 ); + } + LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); + + if ( nsldapi_open_ldap_defconn( ld ) < 0 ) { + ber_free( ber, 1 ); + LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); + return( -1 ); + } + } + lc = ld->ld_defconn; + } else { + if (( lc = find_connection( ld, srvlist, 1 )) == + NULL ) { + if ( bind && (parentreq != NULL) ) { + /* Remember the bind in the parent */ + incparent = 1; + ++parentreq->lr_outrefcnt; + } + + lc = nsldapi_new_connection( ld, &srvlist, 0, + 1, bind ); + } + free_servers( srvlist ); + } + } + + + /* + * return a fatal error if: + * 1. no connections exists + * or + * 2. the connection is dead + * or + * 3. it is not in the connected state with normal (non async) I/O + */ + if ( lc == NULL + || ( lc->lconn_status == LDAP_CONNST_DEAD ) + || ( 0 == (ld->ld_options & LDAP_BITOPT_ASYNC) && + lc->lconn_status != LDAP_CONNST_CONNECTED) ) { + + ber_free( ber, 1 ); + if ( lc != NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, NULL, NULL ); + } + if ( incparent ) { + /* Forget about the bind */ + --parentreq->lr_outrefcnt; + } + LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); + return( -1 ); + } + + if (( lr = nsldapi_new_request( lc, ber, msgid, + 1 /* expect a response */)) == NULL + || ( bindreqdn != NULL && ( bindreqdn = + nsldapi_strdup( bindreqdn )) == NULL )) { + if ( lr != NULL ) { + NSLDAPI_FREE( lr ); + } + LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); + nsldapi_free_connection( ld, lc, NULL, NULL, 0, 0 ); + ber_free( ber, 1 ); + if ( incparent ) { + /* Forget about the bind */ + --parentreq->lr_outrefcnt; + } + LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); + return( -1 ); + } + lr->lr_binddn = bindreqdn; + + if ( parentreq != NULL ) { /* sub-request */ + if ( !incparent ) { + /* Increment if we didn't do it before the bind */ + ++parentreq->lr_outrefcnt; + } + lr->lr_origid = parentreq->lr_origid; + lr->lr_parentcnt = parentreq->lr_parentcnt + 1; + lr->lr_parent = parentreq; + if ( parentreq->lr_child != NULL ) { + lr->lr_sibling = parentreq->lr_child; + } + parentreq->lr_child = lr; + } else { /* original request */ + lr->lr_origid = lr->lr_msgid; + } + + LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); + /* add new request to the end of the list of outstanding requests */ + nsldapi_queue_request_nolock( ld, lr ); + + /* + * Issue a non-blocking poll() if we need to check this + * connection's status. + */ + if ( lc->lconn_status == LDAP_CONNST_CONNECTING || + lc->lconn_pending_requests > 0 ) { + struct timeval tv; + + tv.tv_sec = tv.tv_usec = 0; + (void)nsldapi_iostatus_poll( ld, &tv ); + } + + /* + * If the connect is pending, check to see if it has now completed. + */ + if ( lc->lconn_status == LDAP_CONNST_CONNECTING && + nsldapi_iostatus_is_write_ready( ld, lc->lconn_sb )) { + lc->lconn_status = LDAP_CONNST_CONNECTED; + + LDAPDebug( LDAP_DEBUG_TRACE, + "nsldapi_send_server_request: connection 0x%p -" + " LDAP_CONNST_CONNECTING -> LDAP_CONNST_CONNECTED\n", + lc, 0, 0 ); + } + + if ( lc->lconn_status == LDAP_CONNST_CONNECTING || + lc->lconn_pending_requests > 0 ) { + /* + * The connect is not yet complete, or there are existing + * requests that have not yet been sent to the server. + * Delay sending this request. + */ + lr->lr_status = LDAP_REQST_WRITING; + ++lc->lconn_pending_requests; + nsldapi_iostatus_interest_write( ld, lc->lconn_sb ); + + /* + * If the connection is now connected, and it is ready + * to accept some more outbound data, send as many + * pending requests as possible. + */ + if ( lc->lconn_status != LDAP_CONNST_CONNECTING + && nsldapi_iostatus_is_write_ready( ld, lc->lconn_sb )) { + if ( nsldapi_send_pending_requests_nolock( ld, lc ) + == -1 ) { /* error */ + /* + * Since nsldapi_send_pending_requests_nolock() + * sets LDAP errno, there is no need to do so + * here. + */ + LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); + LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); + return( -1 ); + } + } + + } else { + if (( err = nsldapi_send_ber_message( ld, lc->lconn_sb, + ber, 0 /* do not free ber */, + 1 /* will handle EPIPE */ )) != 0 ) { + + epipe_err = LDAP_GET_ERRNO( ld ); + if ( epipe_err == EPIPE ) { + res_rc = nsldapi_result_nolock(ld, LDAP_RES_UNSOLICITED, 1, + 1, (struct timeval *) NULL, &ext_res); + if ( ( res_rc == LDAP_RES_EXTENDED ) && ext_res ) { + ext_res_rc = ldap_parse_extended_result( ld, ext_res, + &ext_oid, &ext_data, 0 ); + if ( ext_res_rc != LDAP_SUCCESS ) { + if ( ext_res ) { + ldap_msgfree( ext_res ); + } + nsldapi_connection_lost_nolock( ld, lc->lconn_sb ); + } else { +#ifdef LDAP_DEBUG + LDAPDebug( LDAP_DEBUG_TRACE, + "nsldapi_send_server_request: Unsolicited response\n", 0, 0, 0 ); + if ( ext_oid ) { + LDAPDebug( LDAP_DEBUG_TRACE, + "nsldapi_send_server_request: Unsolicited response oid: %s\n", + ext_oid, 0, 0 ); + } + if ( ext_data && ext_data->bv_len && ext_data->bv_val ) { + LDAPDebug( LDAP_DEBUG_TRACE, + "nsldapi_send_server_request: Unsolicited response len: %d\n", + ext_data->bv_len, 0, 0 ); + LDAPDebug( LDAP_DEBUG_TRACE, + "nsldapi_send_server_request: Unsolicited response val: %s\n", + ext_data->bv_val, 0, 0 ); + } + if ( !ext_oid && !ext_data ) { + LDAPDebug( LDAP_DEBUG_TRACE, + "nsldapi_send_server_request: Unsolicited response is empty\n", + 0, 0, 0 ); + } +#endif /* LDAP_DEBUG */ + if ( ext_oid ) { + if ( strcmp ( ext_oid, + LDAP_NOTICE_OF_DISCONNECTION ) == 0 ) { + if ( ext_data ) { + ber_bvfree( ext_data ); + } + if ( ext_oid ) { + ldap_memfree( ext_oid ); + } + if ( ext_res ) { + ldap_msgfree( ext_res ); + } + nsldapi_connection_lost_nolock( ld, + lc->lconn_sb ); + nsldapi_free_request( ld, lr, 0 ); + nsldapi_free_connection( ld, lc, + NULL, NULL, 0, 0 ); + LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); + LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); + return( -1 ); + } + } + } + } else { + if ( ext_res ) { + ldap_msgfree( ext_res ); + } + nsldapi_connection_lost_nolock( ld, lc->lconn_sb ); + } + } + + /* need to continue write later */ + if (err == -2 ) { + lr->lr_status = LDAP_REQST_WRITING; + ++lc->lconn_pending_requests; + nsldapi_iostatus_interest_write( ld, lc->lconn_sb ); + } else { + LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, NULL, NULL ); + nsldapi_free_request( ld, lr, 0 ); + nsldapi_free_connection( ld, lc, NULL, NULL, 0, 0 ); + LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); + LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); + return( -1 ); + } + + } else { + if ( parentreq == NULL ) { + ber->ber_end = ber->ber_ptr; + ber->ber_ptr = ber->ber_buf; + } + + /* sent -- waiting for a response */ + if (ld->ld_options & LDAP_BITOPT_ASYNC) { + lc->lconn_status = LDAP_CONNST_CONNECTED; + } + + nsldapi_iostatus_interest_read( ld, lc->lconn_sb ); + } + } + LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); + LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); + + LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL ); + return( msgid ); +} + + +/* + * nsldapi_send_ber_message(): Attempt to send a BER-encoded message. + * If freeit is non-zero, ber is freed when the send succeeds. + * If errno is EPIPE and epipe_handler is set we let the caller + * deal with EPIPE and dont call lost_nolock here but the caller + * should call lost_nolock itself when done with handling EPIPE. + * + * Return values: + * 0: message sent successfully. + * -1: a fatal error occurred while trying to send. + * -2: async. I/O is enabled and the send would block. + */ +int +nsldapi_send_ber_message( LDAP *ld, Sockbuf *sb, BerElement *ber, int freeit, + int epipe_handler ) +{ + int rc = 0; /* optimistic */ + int async = ( 0 != (ld->ld_options & LDAP_BITOPT_ASYNC)); + int more_to_send = 1; + + while ( more_to_send) { + /* + * ber_flush() doesn't set errno on EOF, so we pre-set it to + * zero to avoid getting tricked by leftover "EAGAIN" errors + */ + LDAP_SET_ERRNO( ld, 0 ); + + if ( ber_flush( sb, ber, freeit ) == 0 ) { + more_to_send = 0; /* success */ + } else { + int terrno = LDAP_GET_ERRNO( ld ); + if ( NSLDAPI_ERRNO_IO_INPROGRESS( terrno )) { + if ( async ) { + rc = -2; + break; + } + } else { + if ( !(epipe_handler && ( terrno == EPIPE )) ) { + nsldapi_connection_lost_nolock( ld, sb ); + } + rc = -1; /* fatal error */ + break; + } + } + } + + return( rc ); +} + + +/* + * nsldapi_send_pending_requests_nolock(): Send one or more pending requests + * that are associated with connection 'lc'. + * + * Return values: 0 -- success. + * -1 -- fatal error; connection closed. + * + * Must be called with these two mutexes locked, in this order: + * LDAP_CONN_LOCK + * LDAP_REQ_LOCK + */ +int +nsldapi_send_pending_requests_nolock( LDAP *ld, LDAPConn *lc ) +{ + int err; + int waiting_for_a_response = 0; + int rc = 0; + LDAPRequest *lr; + char *logname = "nsldapi_send_pending_requests_nolock"; + + LDAPDebug( LDAP_DEBUG_TRACE, "%s\n", logname, 0, 0 ); + + for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) { + /* + * This code relies on the fact that the ld_requests list + * is in order from oldest to newest request (the oldest + * requests that have not yet been sent to the server are + * sent first). + */ + if ( lr->lr_status == LDAP_REQST_WRITING + && lr->lr_conn == lc ) { + err = nsldapi_send_ber_message( ld, lc->lconn_sb, + lr->lr_ber, 0 /* do not free ber */, + 0 /* will not handle EPIPE */ ); + if ( err == 0 ) { /* send succeeded */ + LDAPDebug( LDAP_DEBUG_TRACE, + "%s: 0x%p SENT\n", logname, lr, 0 ); + lr->lr_ber->ber_end = lr->lr_ber->ber_ptr; + lr->lr_ber->ber_ptr = lr->lr_ber->ber_buf; + lr->lr_status = LDAP_REQST_INPROGRESS; + --lc->lconn_pending_requests; + } else if ( err == -2 ) { /* would block */ + rc = 0; /* not an error */ + LDAPDebug( LDAP_DEBUG_TRACE, + "%s: 0x%p WOULD BLOCK\n", logname, lr, 0 ); + break; + } else { /* fatal error */ + LDAPDebug( LDAP_DEBUG_TRACE, + "%s: 0x%p FATAL ERROR\n", logname, lr, 0 ); + LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, + NULL, NULL ); + nsldapi_free_request( ld, lr, 0 ); + lr = NULL; + nsldapi_free_connection( ld, lc, NULL, NULL, + 0, 0 ); + lc = NULL; + rc = -1; + break; + } + } + + if (lr->lr_status == LDAP_REQST_INPROGRESS ) { + if (lr->lr_expect_resp) { + ++waiting_for_a_response; + } else { + LDAPDebug( LDAP_DEBUG_TRACE, + "%s: 0x%p NO RESPONSE EXPECTED;" + " freeing request \n", logname, lr, 0 ); + nsldapi_free_request( ld, lr, 0 ); + lr = NULL; + } + } + } + + if ( lc != NULL ) { + if ( lc->lconn_pending_requests < 1 ) { + /* no need to poll for "write ready" any longer */ + nsldapi_iostatus_interest_clear( ld, lc->lconn_sb ); + } + + if ( waiting_for_a_response ) { + /* need to poll for "read ready" */ + nsldapi_iostatus_interest_read( ld, lc->lconn_sb ); + } + } + + LDAPDebug( LDAP_DEBUG_TRACE, "%s <- %d\n", logname, rc, 0 ); + return( rc ); +} + + +LDAPConn * +nsldapi_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, + int connect, int bind ) +{ + int rc = -1; + LDAPConn *lc; + LDAPServer *prevsrv, *srv; + Sockbuf *sb = NULL; + + /* + * make a new LDAP server connection + */ + if (( lc = (LDAPConn *)NSLDAPI_CALLOC( 1, sizeof( LDAPConn ))) == NULL + || ( !use_ldsb && ( sb = ber_sockbuf_alloc()) == NULL )) { + if ( lc != NULL ) { + NSLDAPI_FREE( (char *)lc ); + } + LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); + return( NULL ); + } + + LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK ); + if ( !use_ldsb ) { + /* + * we have allocated a new sockbuf + * set I/O routines to match those in default LDAP sockbuf + */ + IFP sb_fn; + struct lber_x_ext_io_fns extiofns; + + extiofns.lbextiofn_size = LBER_X_EXTIO_FNS_SIZE; + + if ( ber_sockbuf_get_option( ld->ld_sbp, + LBER_SOCKBUF_OPT_EXT_IO_FNS, &extiofns ) == 0 ) { + ber_sockbuf_set_option( sb, + LBER_SOCKBUF_OPT_EXT_IO_FNS, &extiofns ); + } + if ( ber_sockbuf_get_option( ld->ld_sbp, + LBER_SOCKBUF_OPT_READ_FN, (void *)&sb_fn ) == 0 + && sb_fn != NULL ) { + ber_sockbuf_set_option( sb, LBER_SOCKBUF_OPT_READ_FN, + (void *)sb_fn ); + } + if ( ber_sockbuf_get_option( ld->ld_sbp, + LBER_SOCKBUF_OPT_WRITE_FN, (void *)&sb_fn ) == 0 + && sb_fn != NULL ) { + ber_sockbuf_set_option( sb, LBER_SOCKBUF_OPT_WRITE_FN, + (void *)sb_fn ); + } + } + + lc->lconn_sb = ( use_ldsb ) ? ld->ld_sbp : sb; + lc->lconn_version = ld->ld_version; /* inherited */ + LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK ); + + if ( connect ) { + prevsrv = NULL; + /* + * save the return code for later + */ + for ( srv = *srvlistp; srv != NULL; srv = srv->lsrv_next ) { + rc = nsldapi_connect_to_host( ld, lc->lconn_sb, + srv->lsrv_host, srv->lsrv_port, + ( srv->lsrv_options & LDAP_SRV_OPT_SECURE ) != 0, + &lc->lconn_krbinstance ); + if (rc != -1) { + break; + } + prevsrv = srv; + } + + if ( srv == NULL ) { + if ( !use_ldsb ) { + NSLDAPI_FREE( (char *)lc->lconn_sb ); + } + NSLDAPI_FREE( (char *)lc ); + /* nsldapi_open_ldap_connection has already set ld_errno */ + return( NULL ); + } + + if ( prevsrv == NULL ) { + *srvlistp = srv->lsrv_next; + } else { + prevsrv->lsrv_next = srv->lsrv_next; + } + lc->lconn_server = srv; + } + + if ( 0 != (ld->ld_options & LDAP_BITOPT_ASYNC)) { + /* + * Technically, the socket may already be connected but we are + * not sure. By setting the state to LDAP_CONNST_CONNECTING, we + * ensure that we will check the socket status to make sure it + * is connected before we try to send any LDAP messages. + */ + lc->lconn_status = LDAP_CONNST_CONNECTING; + } else { + lc->lconn_status = LDAP_CONNST_CONNECTED; + } + + lc->lconn_next = ld->ld_conns; + ld->ld_conns = lc; + + /* + * XXX for now, we always do a synchronous bind. This will have + * to change in the long run... + */ + if ( bind ) { + int err, lderr, freepasswd, authmethod; + char *binddn, *passwd; + LDAPConn *savedefconn; + + freepasswd = err = 0; + + if ( ld->ld_rebind_fn == NULL ) { + binddn = passwd = ""; + authmethod = LDAP_AUTH_SIMPLE; + } else { + if (( lderr = (*ld->ld_rebind_fn)( ld, &binddn, &passwd, + &authmethod, 0, ld->ld_rebind_arg )) + == LDAP_SUCCESS ) { + freepasswd = 1; + } else { + LDAP_SET_LDERRNO( ld, lderr, NULL, NULL ); + err = -1; + } + } + + + if ( err == 0 ) { + savedefconn = ld->ld_defconn; + ld->ld_defconn = lc; + ++lc->lconn_refcnt; /* avoid premature free */ + + /* + * when binding, we will back down as low as LDAPv2 + * if we get back "protocol error" from bind attempts + */ + for ( ;; ) { + /* LDAP_MUTEX_UNLOCK(ld, LDAP_CONN_LOCK); */ + if (( lderr = ldap_bind_s( ld, binddn, passwd, + authmethod )) == LDAP_SUCCESS ) { + /* LDAP_MUTEX_LOCK(ld, LDAP_CONN_LOCK); */ + break; + } + /* LDAP_MUTEX_LOCK(ld, LDAP_CONN_LOCK); */ + if ( lc->lconn_version <= LDAP_VERSION2 + || lderr != LDAP_PROTOCOL_ERROR ) { + err = -1; + break; + } + --lc->lconn_version; /* try lower version */ + } + --lc->lconn_refcnt; + ld->ld_defconn = savedefconn; + } + + if ( freepasswd ) { + (*ld->ld_rebind_fn)( ld, &binddn, &passwd, + &authmethod, 1, ld->ld_rebind_arg ); + } + + if ( err != 0 ) { + nsldapi_free_connection( ld, lc, NULL, NULL, 1, 0 ); + lc = NULL; + } + } + + return( lc ); +} + + +#define LDAP_CONN_SAMEHOST( h1, h2 ) \ + (( (h1) == NULL && (h2) == NULL ) || \ + ( (h1) != NULL && (h2) != NULL && strcasecmp( (h1), (h2) ) == 0 )) + +static LDAPConn * +find_connection( LDAP *ld, LDAPServer *srv, int any ) +/* + * return an existing connection (if any) to the server srv + * if "any" is non-zero, check for any server in the "srv" chain + */ +{ + LDAPConn *lc; + LDAPServer *ls; + + for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { + for ( ls = srv; ls != NULL; ls = ls->lsrv_next ) { + if ( LDAP_CONN_SAMEHOST( ls->lsrv_host, + lc->lconn_server->lsrv_host ) + && ls->lsrv_port == lc->lconn_server->lsrv_port + && ls->lsrv_options == + lc->lconn_server->lsrv_options ) { + return( lc ); + } + if ( !any ) { + break; + } + } + } + + return( NULL ); +} + + +void +nsldapi_free_connection( LDAP *ld, LDAPConn *lc, LDAPControl **serverctrls, + LDAPControl **clientctrls, int force, int unbind ) +{ + LDAPConn *tmplc, *prevlc; + + LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_free_connection\n", 0, 0, 0 ); + + if ( force || --lc->lconn_refcnt <= 0 ) { + nsldapi_iostatus_interest_clear( ld, lc->lconn_sb ); + if ( lc->lconn_status == LDAP_CONNST_CONNECTED ) { + if ( unbind ) { + nsldapi_send_unbind( ld, lc->lconn_sb, + serverctrls, clientctrls ); + } + } + nsldapi_close_connection( ld, lc->lconn_sb ); + prevlc = NULL; + for ( tmplc = ld->ld_conns; tmplc != NULL; + tmplc = tmplc->lconn_next ) { + if ( tmplc == lc ) { + if ( prevlc == NULL ) { + ld->ld_conns = tmplc->lconn_next; + } else { + prevlc->lconn_next = tmplc->lconn_next; + } + break; + } + prevlc = tmplc; + } + free_servers( lc->lconn_server ); + if ( lc->lconn_krbinstance != NULL ) { + NSLDAPI_FREE( lc->lconn_krbinstance ); + } + /* + * if this is the default connection (lc->lconn_sb==ld->ld_sbp) + * we do not free the Sockbuf here since it will be freed + * later inside ldap_unbind(). + */ + if ( lc->lconn_sb != ld->ld_sbp ) { + ber_sockbuf_free( lc->lconn_sb ); + lc->lconn_sb = NULL; + } + if ( lc->lconn_ber != NULLBER ) { + ber_free( lc->lconn_ber, 1 ); + } + if ( lc->lconn_binddn != NULL ) { + NSLDAPI_FREE( lc->lconn_binddn ); + } +#ifdef LDAP_SASLIO_HOOKS + if ( lc->lconn_sasl_ctx ) { /* the sasl connection context */ + sasl_dispose(&lc->lconn_sasl_ctx); + lc->lconn_sasl_ctx = NULL; + } +#endif /* LDAP_SASLIO_HOOKS */ + NSLDAPI_FREE( lc ); + LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_free_connection: actually freed\n", + 0, 0, 0 ); + } else { + lc->lconn_lastused = time( 0 ); + LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_free_connection: refcnt %d\n", + lc->lconn_refcnt, 0, 0 ); + } +} + + +#ifdef LDAP_DEBUG +void +nsldapi_dump_connection( LDAP *ld, LDAPConn *lconns, int all ) +{ + LDAPConn *lc; + char msg[256]; +/* CTIME for this platform doesn't use this. */ +#if !defined(SUNOS4) && !defined(_WIN32) && !defined(LINUX) && !defined(macintosh) + char buf[26]; +#endif + + sprintf( msg, "** Connection%s:\n", all ? "s" : "" ); + ber_err_print( msg ); + for ( lc = lconns; lc != NULL; lc = lc->lconn_next ) { + if ( lc->lconn_server != NULL ) { + sprintf( msg, "* 0x%p - host: %s port: %d secure: %s%s\n", + lc, ( lc->lconn_server->lsrv_host == NULL ) ? "(null)" + : lc->lconn_server->lsrv_host, + lc->lconn_server->lsrv_port, + ( lc->lconn_server->lsrv_options & + LDAP_SRV_OPT_SECURE ) ? "Yes" : + "No", ( lc->lconn_sb == ld->ld_sbp ) ? + " (default)" : "" ); + ber_err_print( msg ); + } + sprintf( msg, " refcnt: %d pending: %d status: %s\n", + lc->lconn_refcnt, lc->lconn_pending_requests, + ( lc->lconn_status == LDAP_CONNST_CONNECTING ) + ? "Connecting" : + ( lc->lconn_status == LDAP_CONNST_DEAD ) ? "Dead" : + "Connected" ); + ber_err_print( msg ); + sprintf( msg, " last used: %s", + NSLDAPI_CTIME( (time_t *) &lc->lconn_lastused, buf, + sizeof(buf) )); + ber_err_print( msg ); + if ( lc->lconn_ber != NULLBER ) { + ber_err_print( " partial response has been received:\n" ); + ber_dump( lc->lconn_ber, 1 ); + } + ber_err_print( "\n" ); + + if ( !all ) { + break; + } + } +} + + +void +nsldapi_dump_requests_and_responses( LDAP *ld ) +{ + LDAPRequest *lr; + LDAPMessage *lm, *l; + char msg[256]; + + ber_err_print( "** Outstanding Requests:\n" ); + LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); + if (( lr = ld->ld_requests ) == NULL ) { + ber_err_print( " Empty\n" ); + } + for ( ; lr != NULL; lr = lr->lr_next ) { + sprintf( msg, " * 0x%p - msgid %d, origid %d, status %s\n", + lr, lr->lr_msgid, lr->lr_origid, ( lr->lr_status == + LDAP_REQST_INPROGRESS ) ? "InProgress" : + ( lr->lr_status == LDAP_REQST_CHASINGREFS ) ? "ChasingRefs" : + ( lr->lr_status == LDAP_REQST_CONNDEAD ) ? "Dead" : + "Writing" ); + ber_err_print( msg ); + sprintf( msg, " outstanding referrals %d, parent count %d\n", + lr->lr_outrefcnt, lr->lr_parentcnt ); + ber_err_print( msg ); + if ( lr->lr_binddn != NULL ) { + sprintf( msg, " pending bind DN: <%s>\n", lr->lr_binddn ); + ber_err_print( msg ); + } + } + LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); + + ber_err_print( "** Response Queue:\n" ); + LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK ); + if (( lm = ld->ld_responses ) == NULLMSG ) { + ber_err_print( " Empty\n" ); + } + for ( ; lm != NULLMSG; lm = lm->lm_next ) { + sprintf( msg, " * 0x%p - msgid %d, type %d\n", + lm, lm->lm_msgid, lm->lm_msgtype ); + ber_err_print( msg ); + if (( l = lm->lm_chain ) != NULL ) { + ber_err_print( " chained responses:\n" ); + for ( ; l != NULLMSG; l = l->lm_chain ) { + sprintf( msg, + " * 0x%p - msgid %d, type %d\n", + l, l->lm_msgid, l->lm_msgtype ); + ber_err_print( msg ); + } + } + } + LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); +} +#endif /* LDAP_DEBUG */ + + +LDAPRequest * +nsldapi_new_request( LDAPConn *lc, BerElement *ber, int msgid, int expect_resp ) +{ + LDAPRequest *lr; + + lr = (LDAPRequest *)NSLDAPI_CALLOC( 1, sizeof( LDAPRequest )); + + if ( lr != NULL ) { + lr->lr_conn = lc; + lr->lr_ber = ber; + lr->lr_msgid = lr->lr_origid = msgid; + lr->lr_expect_resp = expect_resp; + lr->lr_status = LDAP_REQST_INPROGRESS; + lr->lr_res_errno = LDAP_SUCCESS; /* optimistic */ + + if ( lc != NULL ) { /* mark connection as in use */ + ++lc->lconn_refcnt; + lc->lconn_lastused = time( 0 ); + } + } + + return( lr ); +} + + +void +nsldapi_free_request( LDAP *ld, LDAPRequest *lr, int free_conn ) +{ + LDAPRequest *tmplr, *nextlr; + + LDAPDebug( LDAP_DEBUG_TRACE, + "nsldapi_free_request 0x%p (origid %d, msgid %d)\n", + lr, lr->lr_origid, lr->lr_msgid ); + + if ( lr->lr_parent != NULL ) { + /* unlink child from parent */ + lr->lr_parent->lr_child = NULL; + --lr->lr_parent->lr_outrefcnt; + } + + if ( lr->lr_status == LDAP_REQST_WRITING ) { + --lr->lr_conn->lconn_pending_requests; + } + + /* free all of our spawned referrals (child requests) */ + for ( tmplr = lr->lr_child; tmplr != NULL; tmplr = nextlr ) { + nextlr = tmplr->lr_sibling; + nsldapi_free_request( ld, tmplr, free_conn ); + } + + if ( free_conn ) { + nsldapi_free_connection( ld, lr->lr_conn, NULL, NULL, 0, 1 ); + } + + if ( lr->lr_prev == NULL ) { + ld->ld_requests = lr->lr_next; + } else { + lr->lr_prev->lr_next = lr->lr_next; + } + + if ( lr->lr_next != NULL ) { + lr->lr_next->lr_prev = lr->lr_prev; + } + + if ( lr->lr_ber != NULL ) { + ber_free( lr->lr_ber, 1 ); + } + + if ( lr->lr_res_error != NULL ) { + NSLDAPI_FREE( lr->lr_res_error ); + } + + if ( lr->lr_res_matched != NULL ) { + NSLDAPI_FREE( lr->lr_res_matched ); + } + + if ( lr->lr_binddn != NULL ) { + NSLDAPI_FREE( lr->lr_binddn ); + } + + if ( lr->lr_res_ctrls != NULL ) { + ldap_controls_free( lr->lr_res_ctrls ); + } + NSLDAPI_FREE( lr ); +} + + +/* + * Add a request to the end of the list of outstanding requests. + * This function must be called with these two locks in hand, acquired in + * this order: + * LDAP_CONN_LOCK + * LDAP_REQ_LOCK + */ +void +nsldapi_queue_request_nolock( LDAP *ld, LDAPRequest *lr ) +{ + if ( NULL == ld->ld_requests ) { + ld->ld_requests = lr; + } else { + LDAPRequest *tmplr; + + for ( tmplr = ld->ld_requests; tmplr->lr_next != NULL; + tmplr = tmplr->lr_next ) { + ; + } + tmplr->lr_next = lr; + lr->lr_prev = tmplr; + } +} + + +static void +free_servers( LDAPServer *srvlist ) +{ + LDAPServer *nextsrv; + + while ( srvlist != NULL ) { + nextsrv = srvlist->lsrv_next; + if ( srvlist->lsrv_dn != NULL ) { + NSLDAPI_FREE( srvlist->lsrv_dn ); + } + if ( srvlist->lsrv_host != NULL ) { + NSLDAPI_FREE( srvlist->lsrv_host ); + } + NSLDAPI_FREE( srvlist ); + srvlist = nextsrv; + } +} + + +/* + * Initiate chasing of LDAPv2+ (Umich extension) referrals. + * + * Returns an LDAP error code. + * + * Note that *hadrefp will be set to 1 if one or more referrals were found in + * "*errstrp" (even if we can't chase them) and zero if none were found. + * + * XXX merging of errors in this routine needs to be improved. + */ +int +nsldapi_chase_v2_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, + int *totalcountp, int *chasingcountp ) +{ + char *p, *ref, *unfollowed; + LDAPRequest *origreq; + int rc, tmprc, len, unknown; + + LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_chase_v2_referrals\n", 0, 0, 0 ); + + *totalcountp = *chasingcountp = 0; + + if ( *errstrp == NULL ) { + return( LDAP_SUCCESS ); + } + + len = strlen( *errstrp ); + for ( p = *errstrp; len >= LDAP_REF_STR_LEN; ++p, --len ) { + if (( *p == 'R' || *p == 'r' ) && strncasecmp( p, + LDAP_REF_STR, LDAP_REF_STR_LEN ) == 0 ) { + *p = '\0'; + p += LDAP_REF_STR_LEN; + break; + } + } + + if ( len < LDAP_REF_STR_LEN ) { + return( LDAP_SUCCESS ); + } + + if ( lr->lr_parentcnt >= ld->ld_refhoplimit ) { + LDAPDebug( LDAP_DEBUG_TRACE, + "more than %d referral hops (dropping)\n", + ld->ld_refhoplimit, 0, 0 ); + return( LDAP_REFERRAL_LIMIT_EXCEEDED ); + } + + /* find original request */ + for ( origreq = lr; origreq->lr_parent != NULL; + origreq = origreq->lr_parent ) { + ; + } + + unfollowed = NULL; + rc = LDAP_SUCCESS; + + /* parse out & follow referrals */ + for ( ref = p; rc == LDAP_SUCCESS && ref != NULL; ref = p ) { + if (( p = strchr( ref, '\n' )) != NULL ) { + *p++ = '\0'; + } else { + p = NULL; + } + + ++*totalcountp; + + rc = chase_one_referral( ld, lr, origreq, ref, "v2 referral", + &unknown, 0 /* not a reference */ ); + + if ( rc != LDAP_SUCCESS || unknown ) { + if (( tmprc = nsldapi_append_referral( ld, &unfollowed, + ref )) != LDAP_SUCCESS ) { + rc = tmprc; + } + } else { + ++*chasingcountp; + } + } + + NSLDAPI_FREE( *errstrp ); + *errstrp = unfollowed; + + return( rc ); +} + + +/* returns an LDAP error code */ +int +nsldapi_chase_v3_refs( LDAP *ld, LDAPRequest *lr, char **v3refs, + int is_reference, int *totalcountp, int *chasingcountp ) +{ + int rc = LDAP_SUCCESS; + int i, unknown; + LDAPRequest *origreq; + + *totalcountp = *chasingcountp = 0; + + if ( v3refs == NULL || v3refs[0] == NULL ) { + return( LDAP_SUCCESS ); + } + + *totalcountp = 1; + + if ( lr->lr_parentcnt >= ld->ld_refhoplimit ) { + LDAPDebug( LDAP_DEBUG_TRACE, + "more than %d referral hops (dropping)\n", + ld->ld_refhoplimit, 0, 0 ); + return( LDAP_REFERRAL_LIMIT_EXCEEDED ); + } + + /* find original request */ + for ( origreq = lr; origreq->lr_parent != NULL; + origreq = origreq->lr_parent ) { + ; + } + + /* + * in LDAPv3, we just need to follow one referral in the set. + * we dp this by stopping as soon as we succeed in initiating a + * chase on any referral (basically this means we were able to connect + * to the server and bind). + */ + for ( i = 0; v3refs[i] != NULL; ++i ) { + rc = chase_one_referral( ld, lr, origreq, v3refs[i], + is_reference ? "v3 reference" : "v3 referral", &unknown, + is_reference ); + if ( rc == LDAP_SUCCESS && !unknown ) { + *chasingcountp = 1; + break; + } + } + + /* XXXmcs: should we save unfollowed referrals somewhere? */ + + return( rc ); /* last error is as good as any other I guess... */ +} + + +/* + * returns an LDAP error code + * + * XXXmcs: this function used to have #ifdef LDAP_DNS code in it but I + * removed it when I improved the parsing (we don't define LDAP_DNS + * here at Netscape). + */ +static int +chase_one_referral( LDAP *ld, LDAPRequest *lr, LDAPRequest *origreq, + char *refurl, char *desc, int *unknownp, int is_reference ) +{ + int rc, tmprc, secure, msgid; + LDAPServer *srv; + BerElement *ber; + LDAPURLDesc *ludp; + + *unknownp = 0; + ludp = NULLLDAPURLDESC; + + if ( nsldapi_url_parse( refurl, &ludp, 0 ) != 0 ) { + LDAPDebug( LDAP_DEBUG_TRACE, + "ignoring unknown %s <%s>\n", desc, refurl, 0 ); + *unknownp = 1; + rc = LDAP_SUCCESS; + goto cleanup_and_return; + } + + secure = (( ludp->lud_options & LDAP_URL_OPT_SECURE ) != 0 ); + +/* XXXmcs: can't tell if secure is supported by connect callback */ + if ( secure && ld->ld_extconnect_fn == NULL ) { + LDAPDebug( LDAP_DEBUG_TRACE, + "ignoring LDAPS %s <%s>\n", desc, refurl, 0 ); + *unknownp = 1; + rc = LDAP_SUCCESS; + goto cleanup_and_return; + } + + LDAPDebug( LDAP_DEBUG_TRACE, "chasing LDAP%s %s: <%s>\n", + secure ? "S" : "", desc, refurl ); + + LDAP_MUTEX_LOCK( ld, LDAP_MSGID_LOCK ); + msgid = ++ld->ld_msgid; + LDAP_MUTEX_UNLOCK( ld, LDAP_MSGID_LOCK ); + + if (( tmprc = re_encode_request( ld, origreq->lr_ber, msgid, + ludp, &ber, is_reference )) != LDAP_SUCCESS ) { + rc = tmprc; + goto cleanup_and_return; + } + + if (( srv = (LDAPServer *)NSLDAPI_CALLOC( 1, sizeof( LDAPServer ))) + == NULL ) { + ber_free( ber, 1 ); + rc = LDAP_NO_MEMORY; + goto cleanup_and_return; + } + + if ( ludp->lud_host == NULL && ld->ld_defhost == NULL ) { + srv->lsrv_host = NULL; + } else { + if ( ludp->lud_host == NULL ) { + srv->lsrv_host = + nsldapi_strdup( origreq->lr_conn->lconn_server->lsrv_host ); + LDAPDebug( LDAP_DEBUG_TRACE, + "chase_one_referral: using hostname '%s' from original " + "request on new request\n", + srv->lsrv_host, 0, 0); + } else { + srv->lsrv_host = nsldapi_strdup( ludp->lud_host ); + LDAPDebug( LDAP_DEBUG_TRACE, + "chase_one_referral: using hostname '%s' as specified " + "on new request\n", + srv->lsrv_host, 0, 0); + } + + if ( srv->lsrv_host == NULL ) { + NSLDAPI_FREE( (char *)srv ); + ber_free( ber, 1 ); + rc = LDAP_NO_MEMORY; + goto cleanup_and_return; + } + } + + if ( ludp->lud_port == 0 && ludp->lud_host == NULL ) { + srv->lsrv_port = origreq->lr_conn->lconn_server->lsrv_port; + LDAPDebug( LDAP_DEBUG_TRACE, + "chase_one_referral: using port (%d) from original " + "request on new request\n", + srv->lsrv_port, 0, 0); + } else if ( ludp->lud_port != 0 ) { + srv->lsrv_port = ludp->lud_port; + LDAPDebug( LDAP_DEBUG_TRACE, + "chase_one_referral: using port (%d) as specified on " + "new request\n", + srv->lsrv_port, 0, 0); + } else { + srv->lsrv_port = secure ? LDAPS_PORT : LDAP_PORT; + LDAPDebug( LDAP_DEBUG_TRACE, + "chase_one_referral: using default port (%d)\n", + srv->lsrv_port, 0, 0 ); + } + + if ( secure ) { + srv->lsrv_options |= LDAP_SRV_OPT_SECURE; + } + + if ( nsldapi_send_server_request( ld, ber, msgid, + lr, srv, NULL, NULL, 1 ) < 0 ) { + rc = LDAP_GET_LDERRNO( ld, NULL, NULL ); + LDAPDebug( LDAP_DEBUG_ANY, "Unable to chase %s %s (%s)\n", + desc, refurl, ldap_err2string( rc )); + } else { + rc = LDAP_SUCCESS; + } + +cleanup_and_return: + if ( ludp != NULLLDAPURLDESC ) { + ldap_free_urldesc( ludp ); + } + + return( rc ); +} + + +/* returns an LDAP error code */ +int +nsldapi_append_referral( LDAP *ld, char **referralsp, char *s ) +{ + int first; + + if ( *referralsp == NULL ) { + first = 1; + *referralsp = (char *)NSLDAPI_MALLOC( strlen( s ) + + LDAP_REF_STR_LEN + 1 ); + } else { + first = 0; + *referralsp = (char *)NSLDAPI_REALLOC( *referralsp, + strlen( *referralsp ) + strlen( s ) + 2 ); + } + + if ( *referralsp == NULL ) { + return( LDAP_NO_MEMORY ); + } + + if ( first ) { + strcpy( *referralsp, LDAP_REF_STR ); + } else { + strcat( *referralsp, "\n" ); + } + strcat( *referralsp, s ); + + return( LDAP_SUCCESS ); +} + + + +/* returns an LDAP error code */ +static int +re_encode_request( LDAP *ld, BerElement *origber, int msgid, LDAPURLDesc *ludp, + BerElement **berp, int is_reference ) +{ +/* + * XXX this routine knows way too much about how the lber library works! + */ + ber_int_t origmsgid; + ber_tag_t tag; + ber_int_t ver; + int rc; + BerElement *ber; + struct berelement tmpber; + char *dn, *orig_dn; + /* extra stuff for search request */ + ber_int_t scope = -1; + + LDAPDebug( LDAP_DEBUG_TRACE, + "re_encode_request: new msgid %d, new dn <%s>\n", + msgid, ( ludp->lud_dn == NULL ) ? "NONE" : ludp->lud_dn, 0 ); + + tmpber = *origber; + + /* + * All LDAP requests are sequences that start with a message id. For + * everything except delete requests, this is followed by a sequence + * that is tagged with the operation code. For deletes, there is just + * a DN that is tagged with the operation code. + */ + + /* skip past msgid and get operation tag */ + if ( ber_scanf( &tmpber, "{it", &origmsgid, &tag ) == LBER_ERROR ) { + return( LDAP_DECODING_ERROR ); + } + + /* + * XXXmcs: we don't support filters in search referrals yet, + * so if present we return an error which is probably + * better than just ignoring the extra info. + * XXXrichm: we now support scopes. Supporting filters would require + * a lot more additional work to be able to read the filter from + * the ber original search request, convert to string, etc. It might + * be better and easier to change nsldapi_build_search_req to have + * some special mode by which you could tell it to skip filter and + * attrlist encoding if no filter was given - then we could just + * create a new ber search request with our new filter if present. + */ + if ( ( tag == LDAP_REQ_SEARCH ) && ( ludp->lud_filter != NULL )) { + return( LDAP_LOCAL_ERROR ); + } + + if ( tag == LDAP_REQ_BIND ) { + /* bind requests have a version number before the DN */ + rc = ber_scanf( &tmpber, "{ia", &ver, &orig_dn ); + } else if ( tag == LDAP_REQ_DELETE ) { + /* delete requests DNs are not within a sequence */ + rc = ber_scanf( &tmpber, "a", &orig_dn ); + } else if ( tag == LDAP_REQ_SEARCH ) { + /* need scope */ + rc = ber_scanf( &tmpber, "{ae", &orig_dn, &scope ); + } else { + rc = ber_scanf( &tmpber, "{a", &orig_dn ); + } + + if ( rc == LBER_ERROR ) { + return( LDAP_DECODING_ERROR ); + } + + if ( ludp->lud_dn == NULL ) { + dn = orig_dn; + } else { + dn = ludp->lud_dn; + NSLDAPI_FREE( orig_dn ); + orig_dn = NULL; + } + + if ( ludp->lud_scope != -1 ) { + scope = ludp->lud_scope; /* scope provided by ref - use it */ + } else if (is_reference) { + /* + * RFC 4511 says that the we should use scope BASE in the + * search reference if the client's original request was for scope + * ONELEVEL - since the server did not include the scope in the + * search reference returned, we must provide the correct behavior + * in the client (i.e. the correct behavior is implied) + * see RFC 4511 section 4.5.3 for more information + */ + if (scope == LDAP_SCOPE_ONELEVEL) { + scope = LDAP_SCOPE_BASE; + } + } + + /* allocate and build the new request */ + if (( rc = nsldapi_alloc_ber_with_options( ld, &ber )) + != LDAP_SUCCESS ) { + if ( orig_dn != NULL ) { + NSLDAPI_FREE( orig_dn ); + } + return( rc ); + } + + if ( tag == LDAP_REQ_BIND ) { + rc = ber_printf( ber, "{it{is", msgid, tag, ver , dn ); + } else if ( tag == LDAP_REQ_DELETE ) { + rc = ber_printf( ber, "{its}", msgid, tag, dn ); + } else if ( tag == LDAP_REQ_SEARCH ) { + rc = ber_printf( ber, "{it{se", msgid, tag, dn, scope ); + } else { + rc = ber_printf( ber, "{it{s", msgid, tag, dn ); + } + + if ( orig_dn != NULL ) { + NSLDAPI_FREE( orig_dn ); + } +/* + * can't use "dn" or "orig_dn" from this point on (they've been freed) + */ + + if ( rc == -1 ) { + ber_free( ber, 1 ); + return( LDAP_ENCODING_ERROR ); + } + + if ( tag != LDAP_REQ_DELETE && + ( ber_write( ber, tmpber.ber_ptr, ( tmpber.ber_end - + tmpber.ber_ptr ), 0 ) != ( tmpber.ber_end - tmpber.ber_ptr ) + || ber_printf( ber, "}}" ) == -1 )) { + ber_free( ber, 1 ); + return( LDAP_ENCODING_ERROR ); + } + +#ifdef LDAP_DEBUG + if ( ldap_debug & LDAP_DEBUG_PACKETS ) { + LDAPDebug( LDAP_DEBUG_ANY, "re_encode_request new request is:\n", + 0, 0, 0 ); + ber_dump( ber, 0 ); + } +#endif /* LDAP_DEBUG */ + + *berp = ber; + return( LDAP_SUCCESS ); +} + + +LDAPRequest * +nsldapi_find_request_by_msgid( LDAP *ld, int msgid ) +{ + LDAPRequest *lr; + + for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) { + if ( msgid == lr->lr_msgid ) { + break; + } + } + + return( lr ); +} + + +/* + * nsldapi_connection_lost_nolock() resets "ld" to a non-connected, known + * state. It should be called whenever a fatal error occurs on the + * Sockbuf "sb." sb == NULL means we don't know specifically where + * the problem was so we assume all connections are bad. + */ +void +nsldapi_connection_lost_nolock( LDAP *ld, Sockbuf *sb ) +{ + LDAPRequest *lr; + + /* + * change status of all pending requests that are associated with "sb + * to "connection dead." + * also change the connection status to "dead" and remove it from + * the list of sockets we are interested in. + */ + for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) { + if ( sb == NULL || + ( lr->lr_conn != NULL && lr->lr_conn->lconn_sb == sb )) { + lr->lr_status = LDAP_REQST_CONNDEAD; + if ( lr->lr_conn != NULL ) { + lr->lr_conn->lconn_status = LDAP_CONNST_DEAD; + nsldapi_iostatus_interest_clear( ld, + lr->lr_conn->lconn_sb ); + } + } + } +} + + +#ifdef LDAP_DNS +static LDAPServer * +dn2servers( LDAP *ld, char *dn ) /* dn can also be a domain.... */ +{ + char *p, *domain, *host, *server_dn, **dxs; + int i, port; + LDAPServer *srvlist, *prevsrv, *srv; + + if (( domain = strrchr( dn, '@' )) != NULL ) { + ++domain; + } else { + domain = dn; + } + + if (( dxs = nsldapi_getdxbyname( domain )) == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); + return( NULL ); + } + + srvlist = NULL; + + for ( i = 0; dxs[ i ] != NULL; ++i ) { + port = LDAP_PORT; + server_dn = NULL; + if ( strchr( dxs[ i ], ':' ) == NULL ) { + host = dxs[ i ]; + } else if ( strlen( dxs[ i ] ) >= 7 && + strncmp( dxs[ i ], "ldap://", 7 ) == 0 ) { + host = dxs[ i ] + 7; + if (( p = strchr( host, ':' )) == NULL ) { + p = host; + } else { + *p++ = '\0'; + port = atoi( p ); + } + if (( p = strchr( p, '/' )) != NULL ) { + server_dn = ++p; + if ( *server_dn == '\0' ) { + server_dn = NULL; + } + } + } else { + host = NULL; + } + + if ( host != NULL ) { /* found a server we can use */ + if (( srv = (LDAPServer *)NSLDAPI_CALLOC( 1, + sizeof( LDAPServer ))) == NULL ) { + free_servers( srvlist ); + srvlist = NULL; + break; /* exit loop & return */ + } + + /* add to end of list of servers */ + if ( srvlist == NULL ) { + srvlist = srv; + } else { + prevsrv->lsrv_next = srv; + } + prevsrv = srv; + + /* copy in info. */ + if (( srv->lsrv_host = nsldapi_strdup( host )) == NULL + || ( server_dn != NULL && ( srv->lsrv_dn = + nsldapi_strdup( server_dn )) == NULL )) { + free_servers( srvlist ); + srvlist = NULL; + break; /* exit loop & return */ + } + srv->lsrv_port = port; + } + } + + ldap_value_free( dxs ); + + if ( srvlist == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, NULL, NULL ); + } + + return( srvlist ); +} +#endif /* LDAP_DNS */
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/reslist.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/reslist.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/result.c
Added
@@ -0,0 +1,1473 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +/* + * Copyright (c) 1990 Regents of the University of Michigan. + * All rights reserved. + */ +/* + * result.c - wait for an ldap result + */ + +#if 0 +#ifndef lint +static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; +#endif +#endif + +#include "ldap-int.h" + +/* + * Special return values used by some functions (wait4msg() and read1msg()). + */ +#define NSLDAPI_RESULT_TIMEOUT 0 +#define NSLDAPI_RESULT_ERROR (-1) +#define NSLDAPI_RESULT_NOT_FOUND (-2) + +static int check_response_queue( LDAP *ld, int msgid, int all, + int do_abandon_check, LDAPMessage **result ); +static int ldap_abandoned( LDAP *ld, int msgid ); +static int ldap_mark_abandoned( LDAP *ld, int msgid ); +static int wait4msg( LDAP *ld, int msgid, int all, int unlock_permitted, + struct timeval *timeout, LDAPMessage **result ); +static int read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn **lcp, + LDAPMessage **result ); +static void check_for_refs( LDAP *ld, LDAPRequest *lr, BerElement *ber, + int ldapversion, int *totalcountp, int *chasingcountp ); +static int build_result_ber( LDAP *ld, BerElement **berp, LDAPRequest *lr ); +static void merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ); +#if defined( CLDAP ) +static int cldap_select1( LDAP *ld, struct timeval *timeout ); +#endif +static void link_pend( LDAP *ld, LDAPPend *lp ); + +/* + * ldap_result - wait for an ldap result response to a message from the + * ldap server. If msgid is -1, any message will be accepted, otherwise + * ldap_result will wait for a response with msgid. If all is 0 the + * first message with id msgid will be accepted, otherwise, ldap_result + * will wait for all responses with id msgid and then return a pointer to + * the entire list of messages. This is only useful for search responses, + * which can be of two message types (zero or more entries, followed by an + * ldap result). The type of the first message received is returned. + * When waiting, any messages that have been abandoned are discarded. + * + * Example: + * ldap_result( s, msgid, all, timeout, result ) + */ +int +LDAP_CALL +ldap_result( + LDAP *ld, + int msgid, + int all, + struct timeval *timeout, + LDAPMessage **result +) +{ + int rc; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_result\n", 0, 0, 0 ); + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + return( -1 ); /* punt */ + } + + LDAP_MUTEX_LOCK( ld, LDAP_RESULT_LOCK ); + + rc = nsldapi_result_nolock(ld, msgid, all, 1, timeout, result); + + LDAP_MUTEX_UNLOCK( ld, LDAP_RESULT_LOCK ); + + return( rc ); +} + + +int +nsldapi_result_nolock( LDAP *ld, int msgid, int all, int unlock_permitted, + struct timeval *timeout, LDAPMessage **result ) +{ + int rc; + + LDAPDebug( LDAP_DEBUG_TRACE, + "nsldapi_result_nolock (msgid=%d, all=%d)\n", msgid, all, 0 ); + + /* + * First, look through the list of responses we have received on + * this association and see if the response we're interested in + * is there. If it is, return it. If not, call wait4msg() to + * wait until it arrives or timeout occurs. + */ + + if ( result == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return( -1 ); + } + + if ( check_response_queue( ld, msgid, all, 1, result ) != 0 ) { + LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL ); + rc = (*result)->lm_msgtype; + } else { + rc = wait4msg( ld, msgid, all, unlock_permitted, timeout, + result ); + } + + /* + * XXXmcs should use cache function pointers to hook in memcache + */ + if ( ld->ld_memcache != NULL && NSLDAPI_SEARCH_RELATED_RESULT( rc ) && + !((*result)->lm_fromcache )) { + ldap_memcache_append( ld, (*result)->lm_msgid, + (all || NSLDAPI_IS_SEARCH_RESULT( rc )), *result ); + } + + return( rc ); +} + + +/* + * Look through the list of queued responses for a message that matches the + * criteria in the msgid and all parameters. msgid == LDAP_RES_ANY matches + * all ids. + * + * If an appropriate message is found, a non-zero value is returned and the + * message is dequeued and assigned to *result. + * + * If not, *result is set to NULL and this function returns 0. + */ +static int +check_response_queue( LDAP *ld, int msgid, int all, int do_abandon_check, + LDAPMessage **result ) +{ + LDAPMessage *lm, *lastlm, *nextlm; + LDAPRequest *lr; + + LDAPDebug( LDAP_DEBUG_TRACE, + "=> check_response_queue (msgid=%d, all=%d)\n", msgid, all, 0 ); + + *result = NULL; + lastlm = NULL; + LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK ); + for ( lm = ld->ld_responses; lm != NULL; lm = nextlm ) { + nextlm = lm->lm_next; + + if ( do_abandon_check && ldap_abandoned( ld, lm->lm_msgid ) ) { + ldap_mark_abandoned( ld, lm->lm_msgid ); + + if ( lastlm == NULL ) { + ld->ld_responses = lm->lm_next; + } else { + lastlm->lm_next = nextlm; + } + + ldap_msgfree( lm ); + + continue; + } + + if ( msgid == LDAP_RES_ANY || lm->lm_msgid == msgid ) { + LDAPMessage *tmp; + + if ( all == 0 + || (lm->lm_msgtype != LDAP_RES_SEARCH_RESULT + && lm->lm_msgtype != LDAP_RES_SEARCH_REFERENCE + && lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY) ) + break; + + for ( tmp = lm; tmp != NULL; tmp = tmp->lm_chain ) { + if ( tmp->lm_msgtype == LDAP_RES_SEARCH_RESULT ) + break; + } + + if ( tmp == NULL ) { + LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); + LDAPDebug( LDAP_DEBUG_TRACE, + "<= check_response_queue NOT FOUND\n", + 0, 0, 0 ); + return( 0 ); /* no message to return */ + } + + break; + } + lastlm = lm; + } + + /* + * if we did not find a message OR if the one we found is a result for + * a request that is still pending, return failure. + */ + if ( lm == NULL + || (( lr = nsldapi_find_request_by_msgid( ld, lm->lm_msgid )) + != NULL && lr->lr_outrefcnt > 0 )) { + LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); + LDAPDebug( LDAP_DEBUG_TRACE, + "<= check_response_queue NOT FOUND\n", + 0, 0, 0 ); + return( 0 ); /* no message to return */ + } + + if ( all == 0 ) { + if ( lm->lm_chain == NULL ) { + if ( lastlm == NULL ) { + ld->ld_responses = lm->lm_next; + } else { + lastlm->lm_next = lm->lm_next; + } + } else { + if ( lastlm == NULL ) { + ld->ld_responses = lm->lm_chain; + ld->ld_responses->lm_next = lm->lm_next; + } else { + lastlm->lm_next = lm->lm_chain; + lastlm->lm_next->lm_next = lm->lm_next; + } + } + } else { + if ( lastlm == NULL ) { + ld->ld_responses = lm->lm_next; + } else { + lastlm->lm_next = lm->lm_next; + } + } + + if ( all == 0 ) { + lm->lm_chain = NULL; + } + lm->lm_next = NULL; + LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); + + *result = lm; + LDAPDebug( LDAP_DEBUG_TRACE, + "<= check_response_queue returning msgid %d type %d\n", + lm->lm_msgid, lm->lm_msgtype, 0 ); + return( 1 ); /* a message was found and returned in *result */ +} + + +/* + * wait4msg(): Poll for incoming LDAP messages, respecting the timeout. + * + * Return values: + * > 0: message received; value is the tag of the message. + * NSLDAPI_RESULT_TIMEOUT timeout exceeded. + * NSLDAPI_RESULT_ERROR fatal error occurred such as connection closed. + */ +static int +wait4msg( LDAP *ld, int msgid, int all, int unlock_permitted, + struct timeval *timeout, LDAPMessage **result ) +{ + int err, rc = NSLDAPI_RESULT_NOT_FOUND, msgfound; + struct timeval tv, *tvp; + long start_time = 0, tmp_time; + LDAPConn *lc, *nextlc; + /* lr points to the specific request we are waiting for, if any */ + LDAPRequest *lr = NULL; + +#ifdef LDAP_DEBUG + if ( timeout == NULL ) { + LDAPDebug( LDAP_DEBUG_TRACE, "wait4msg (infinite timeout)\n", + 0, 0, 0 ); + } else { + LDAPDebug( LDAP_DEBUG_TRACE, "wait4msg (timeout %ld sec, %ld usec)\n", + timeout->tv_sec, (long) timeout->tv_usec, 0 ); + } +#endif /* LDAP_DEBUG */ + + /* check the cache */ + if ( ld->ld_cache_on && ld->ld_cache_result != NULL ) { + /* if ( unlock_permitted ) LDAP_MUTEX_UNLOCK( ld ); */ + LDAP_MUTEX_LOCK( ld, LDAP_CACHE_LOCK ); + rc = (ld->ld_cache_result)( ld, msgid, all, timeout, result ); + LDAP_MUTEX_UNLOCK( ld, LDAP_CACHE_LOCK ); + /* if ( unlock_permitted ) LDAP_MUTEX_LOCK( ld ); */ + if ( rc != NSLDAPI_RESULT_TIMEOUT ) { + return( rc ); + } + if ( ld->ld_cache_strategy == LDAP_CACHE_LOCALDB ) { + LDAP_SET_LDERRNO( ld, LDAP_TIMEOUT, NULL, NULL ); + return( NSLDAPI_RESULT_TIMEOUT ); + } + } + + /* + * if we are looking for a specific msgid, check to see if it is + * associated with a dead connection and return an error if so. + */ + if ( msgid != LDAP_RES_ANY && msgid != LDAP_RES_UNSOLICITED ) { + LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); + if (( lr = nsldapi_find_request_by_msgid( ld, msgid )) + == NULL ) { + LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, + nsldapi_strdup( "unknown message id" )); + return( NSLDAPI_RESULT_ERROR ); /* could not find request for msgid */ + } + if ( lr->lr_conn != NULL && + lr->lr_conn->lconn_status == LDAP_CONNST_DEAD ) { + nsldapi_free_request( ld, lr, 1 ); + LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); + LDAP_SET_LDERRNO( ld, LDAP_SERVER_DOWN, NULL, NULL ); + return( NSLDAPI_RESULT_ERROR ); /* connection dead */ + } + LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); + } + + if ( timeout == NULL ) { + tvp = NULL; + } else { + tv = *timeout; + tvp = &tv; + start_time = (long)time( NULL ); + } + + rc = NSLDAPI_RESULT_NOT_FOUND; + while ( rc == NSLDAPI_RESULT_NOT_FOUND ) { + msgfound = 0; +#ifdef LDAP_DEBUG + if ( ldap_debug & LDAP_DEBUG_TRACE ) { + nsldapi_dump_connection( ld, ld->ld_conns, 1 ); + nsldapi_dump_requests_and_responses( ld ); + } +#endif /* LDAP_DEBUG */ + + /* + * Check if we have some data in a connection's BER buffer. + * If so, use it. + */ + LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK ); + LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); + for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { + if ( lc->lconn_sb->sb_ber.ber_ptr < + lc->lconn_sb->sb_ber.ber_end ) { + /* read1msg() might free the connection. */ + rc = read1msg( ld, msgid, all, lc->lconn_sb, + &lc, result ); + /* Indicate to next segment that we've processed a message + (or several, via chased refs) this time around. */ + msgfound = 1; + break; + } + } + LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); + LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); + + if ( !msgfound ) { + /* + * There was no buffered data. Poll to check connection + * status (read/write readiness). + */ + err = nsldapi_iostatus_poll( ld, tvp ); + +#if defined( LDAP_DEBUG ) && !defined( macintosh ) && !defined( DOS ) + if ( err == -1 ) { + LDAPDebug( LDAP_DEBUG_TRACE, + "nsldapi_iostatus_poll returned -1: errno %d\n", + LDAP_GET_ERRNO( ld ), 0, 0 ); + } +#endif + +#if !defined( macintosh ) && !defined( DOS ) + /* + * If the restart option is enabled and the error + * was EINTR, try again. + */ + if ( err == -1 + && 0 != ( ld->ld_options & LDAP_BITOPT_RESTART ) + && LDAP_GET_ERRNO( ld ) == EINTR ) { + continue; + } +#endif + + /* + * Handle timeouts (no activity) and fatal errors. + */ + if ( err == -1 || err == 0 ) { + LDAP_SET_LDERRNO( ld, (err == -1 ? + LDAP_SERVER_DOWN : LDAP_TIMEOUT), NULL, + NULL ); + if ( err == -1 ) { + LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); + nsldapi_connection_lost_nolock( ld, + NULL ); + LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); + rc = NSLDAPI_RESULT_ERROR; + } else { + rc = NSLDAPI_RESULT_TIMEOUT; + } + return( rc ); + } + + /* + * Check each connection for interesting activity. + */ + LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK ); + LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK ); + for ( lc = ld->ld_conns; + rc == NSLDAPI_RESULT_NOT_FOUND && lc != NULL; + lc = nextlc ) { + nextlc = lc->lconn_next; + + /* + * For connections that are in the CONNECTING + * state, check for write ready (which + * indicates that the connection completed) and + * transition to the CONNECTED state. + */ + if ( lc->lconn_status == LDAP_CONNST_CONNECTING + && nsldapi_iostatus_is_write_ready( ld, + lc->lconn_sb ) ) { + lc->lconn_status = LDAP_CONNST_CONNECTED; + LDAPDebug( LDAP_DEBUG_TRACE, + "wait4msg: connection 0x%p -" + " LDAP_CONNST_CONNECTING ->" + " LDAP_CONNST_CONNECTED\n", + lc, 0, 0 ); + } + + if ( lc->lconn_status + != LDAP_CONNST_CONNECTED ) { + continue; + } + + /* + * For connections that are CONNECTED, check + * for read ready (which indicates that data + * from server is available), and, for + * connections with associated requests that + * have not yet been sent, write ready (okay + * to send some data to the server). + */ + if ( nsldapi_iostatus_is_read_ready( ld, + lc->lconn_sb )) { + /* read1msg() might free the connection. */ + rc = read1msg( ld, msgid, all, + lc->lconn_sb, &lc, result ); + } + + /* + * Send pending requests if possible. If there is no lc then + * it was a child connection closed by read1msg(). + */ + if ( lc && lc->lconn_pending_requests > 0 + && nsldapi_iostatus_is_write_ready( ld, + lc->lconn_sb )) { + err = nsldapi_send_pending_requests_nolock( + ld, lc ); + if ( err == -1 && + rc == NSLDAPI_RESULT_NOT_FOUND ) { + rc = NSLDAPI_RESULT_ERROR; + } + } + + } + + LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK ); + LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK ); + } + + /* + * It is possible that recursion occurred while chasing + * referrals and as a result the message we are looking + * for may have been placed on the response queue. Look + * for it there before continuing so we don't end up + * waiting on the network for a message that we already + * received! + */ + if ( rc == NSLDAPI_RESULT_NOT_FOUND && + check_response_queue( ld, msgid, all, 0, result ) != 0 ) { + LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL ); + rc = (*result)->lm_msgtype; + } + + /* + * honor the timeout if specified + */ + if ( rc == NSLDAPI_RESULT_NOT_FOUND && tvp != NULL ) { + tmp_time = (long)time( NULL ); + if (( tv.tv_sec -= ( tmp_time - start_time )) <= 0 ) { + rc = NSLDAPI_RESULT_TIMEOUT; + LDAP_SET_LDERRNO( ld, LDAP_TIMEOUT, NULL, + NULL ); + break; + } + + LDAPDebug( LDAP_DEBUG_TRACE, "wait4msg: %ld secs to go\n", + tv.tv_sec, 0, 0 ); + start_time = tmp_time; + } + } + + return( rc ); +} + + +#define NSLDAPI_REQUEST_COMPLETE( lr ) \ + ( (lr)->lr_outrefcnt <= 0 && \ + (lr)->lr_res_msgtype != LDAP_RES_SEARCH_ENTRY && \ + (lr)->lr_res_msgtype != LDAP_RES_SEARCH_REFERENCE ) + +/* + * read1msg() should be called with LDAP_CONN_LOCK and LDAP_REQ_LOCK locked. + * + * Return values: + * > 0: message received; value is the tag of the message. + * NSLDAPI_RESULT_TIMEOUT timeout exceeded. + * NSLDAPI_RESULT_ERROR fatal error occurred such as connection closed. + * NSLDAPI_RESULT_NOT_FOUND message not yet complete; keep waiting. + * + * The LDAPConn passed in my be freed by read1msg() if the reference count + * shows that it's no longer needed. + */ +static int +read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn **lcp, + LDAPMessage **result ) +{ + BerElement *ber; + LDAPMessage *new, *l, *prev, *chainprev, *tmp; + ber_int_t id; + ber_tag_t tag; + ber_len_t len; + int terrno, lderr, foundit = 0; + LDAPRequest *lr; + int rc, has_parent, message_can_be_returned; + int manufactured_result = 0; + LDAPConn *lc = *lcp; + + LDAPDebug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 ); + + message_can_be_returned = 1; /* the usual case... */ + + /* + * if we are not already in the midst of reading a message, allocate + * a ber that is associated with this connection + */ + if ( lc->lconn_ber == NULLBER && nsldapi_alloc_ber_with_options( ld, + &lc->lconn_ber ) != LDAP_SUCCESS ) { + return( NSLDAPI_RESULT_ERROR ); + } + + /* + * ber_get_next() doesn't set errno on EOF, so we pre-set it to + * zero to avoid getting tricked by leftover "EAGAIN" errors + */ + LDAP_SET_ERRNO( ld, 0 ); + + /* get the next message */ + if ( (tag = ber_get_next( sb, &len, lc->lconn_ber )) + != LDAP_TAG_MESSAGE ) { + terrno = LDAP_GET_ERRNO( ld ); + if ( terrno == EWOULDBLOCK || terrno == EAGAIN ) { + return( NSLDAPI_RESULT_NOT_FOUND ); /* try again */ + } + LDAP_SET_LDERRNO( ld, (tag == LBER_DEFAULT ? LDAP_SERVER_DOWN : + LDAP_LOCAL_ERROR), NULL, NULL ); + if ( tag == LBER_DEFAULT ) { + nsldapi_connection_lost_nolock( ld, sb ); + } + return( NSLDAPI_RESULT_ERROR ); + } + + /* + * Since we have received a complete message now, we pull this ber + * out of the connection structure and never read into it again. + */ + ber = lc->lconn_ber; + lc->lconn_ber = NULLBER; + + /* message id */ + if ( ber_get_int( ber, &id ) == LBER_ERROR ) { + ber_free( ber, 1 ); + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + return( NSLDAPI_RESULT_ERROR ); + } + + /* if it's been abandoned, toss it */ + if ( ldap_abandoned( ld, (int)id ) ) { + ber_free( ber, 1 ); + return( NSLDAPI_RESULT_NOT_FOUND ); /* continue looking */ + } + + if ( id == LDAP_RES_UNSOLICITED ) { + lr = NULL; + } else if (( lr = nsldapi_find_request_by_msgid( ld, id )) == NULL ) { + LDAPDebug( LDAP_DEBUG_ANY, + "no request for response with msgid %d (tossing)\n", + id, 0, 0 ); + ber_free( ber, 1 ); + return( NSLDAPI_RESULT_NOT_FOUND ); /* continue looking */ + } + + /* the message type */ + if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) { + ber_free( ber, 1 ); + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + return( NSLDAPI_RESULT_ERROR ); + } + LDAPDebug( LDAP_DEBUG_TRACE, "got %s msgid %d, original id %d\n", + ( tag == LDAP_RES_SEARCH_ENTRY ) ? "ENTRY" : + ( tag == LDAP_RES_SEARCH_REFERENCE ) ? "REFERENCE" : "RESULT", id, + ( lr == NULL ) ? id : lr->lr_origid ); + + if ( lr != NULL ) { + id = lr->lr_origid; + lr->lr_res_msgtype = tag; + } + rc = NSLDAPI_RESULT_NOT_FOUND; /* default is to keep looking (no response found) */ + + if ( id != LDAP_RES_UNSOLICITED && ( tag == LDAP_RES_SEARCH_REFERENCE || + tag != LDAP_RES_SEARCH_ENTRY )) { + int refchasing, reftotal, simple_request = 0; + LDAPControl **ctrls = NULL; + + check_for_refs( ld, lr, ber, lc->lconn_version, &reftotal, + &refchasing ); + + if ( refchasing > 0 || lr->lr_outrefcnt > 0 ) { + /* + * we're chasing one or more new refs... + */ + ber_free( ber, 1 ); + ber = NULLBER; + lr->lr_status = LDAP_REQST_CHASINGREFS; + message_can_be_returned = 0; + + } else if ( tag != LDAP_RES_SEARCH_REFERENCE ) { + /* + * this request is complete... + */ + has_parent = ( lr->lr_parent != NULL ); + + if ( lr->lr_outrefcnt <= 0 && !has_parent ) { + /* request without any refs */ + simple_request = ( reftotal == 0 ); + } + + /* + * If this is not a child request and it is a bind + * request, reset the connection's bind DN and + * status based on the result of the operation. + */ + if ( !has_parent && + LDAP_RES_BIND == lr->lr_res_msgtype && + lr->lr_conn != NULL ) { + if ( lr->lr_conn->lconn_binddn != NULL ) { + NSLDAPI_FREE( + lr->lr_conn->lconn_binddn ); + } + if ( LDAP_SUCCESS == nsldapi_parse_result( ld, + lr->lr_res_msgtype, ber, &lderr, NULL, + NULL, NULL, NULL ) + && LDAP_SUCCESS == lderr ) { + lr->lr_conn->lconn_bound = 1; + lr->lr_conn->lconn_binddn = + lr->lr_binddn; + lr->lr_binddn = NULL; + } else { + lr->lr_conn->lconn_bound = 0; + lr->lr_conn->lconn_binddn = NULL; + } + } + + /* + * if this response is to a child request, we toss + * the message contents and just merge error info. + * into the parent. + */ + if ( has_parent ) { + /* Extract any response controls from ber before ditching it */ + if( nsldapi_find_controls( ber, &ctrls ) != LDAP_SUCCESS ) { + ber_free( ber, 1 ); + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + return( NSLDAPI_RESULT_ERROR ); + } + + ber_free( ber, 1 ); + ber = NULLBER; + } + while ( lr->lr_parent != NULL ) { + merge_error_info( ld, lr->lr_parent, lr ); + + lr = lr->lr_parent; + --lr->lr_outrefcnt; + if ( !NSLDAPI_REQUEST_COMPLETE(lr)) { + break; + } + } + /* Stash response controls in original request so they can be baked + into the manufactured result message later */ + if( ctrls != NULL ) { + if( lr->lr_res_ctrls != NULL ) { + /* There are controls saved in original request already, + replace them with the new ones because we only save + the final controls received. + May want to arrange for merging intermediate response + controls into the array in the future */ + ldap_controls_free( lr->lr_res_ctrls ); + } + lr->lr_res_ctrls = ctrls; + } + + /* + * we recognize a request as fully complete when: + * 1) it is not a child request (NULL parent) + * 2) it has no outstanding referrals + * 3) we have received a result for the request (i.e., + * something other than an entry or a reference). + */ + if ( lr->lr_parent == NULL + && NSLDAPI_REQUEST_COMPLETE(lr)) { + id = lr->lr_msgid; + tag = lr->lr_res_msgtype; + LDAPDebug( LDAP_DEBUG_TRACE, + "request %d done\n", id, 0, 0 ); +LDAPDebug( LDAP_DEBUG_TRACE, +"res_errno: %d, res_error: <%s>, res_matched: <%s>\n", +lr->lr_res_errno, lr->lr_res_error ? lr->lr_res_error : "", +lr->lr_res_matched ? lr->lr_res_matched : "" ); + if ( !simple_request ) { + if ( ber != NULLBER ) { + ber_free( ber, 1 ); + ber = NULLBER; + } + if ( build_result_ber( ld, &ber, lr ) + != LDAP_SUCCESS ) { + rc = NSLDAPI_RESULT_ERROR; + } else { + manufactured_result = 1; + } + } + + nsldapi_free_request( ld, lr, 1 ); + /* Since we asked nsldapi_free_request() to free the + connection, lets make sure our callers know it's gone. */ + *lcp = NULL; + } else { + message_can_be_returned = 0; + } + } + } + + if ( ber == NULLBER ) { + return( rc ); + } + + /* make a new ldap message */ + if ( (new = (LDAPMessage*)NSLDAPI_CALLOC( 1, sizeof(struct ldapmsg) )) + == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); + return( NSLDAPI_RESULT_ERROR ); + } + new->lm_msgid = (int)id; + new->lm_msgtype = tag; + new->lm_ber = ber; + + /* + * if this is a search entry or if this request is complete (i.e., + * there are no outstanding referrals) then add to cache and check + * to see if we should return this to the caller right away or not. + */ + if ( message_can_be_returned ) { + if ( ld->ld_cache_on ) { + nsldapi_add_result_to_cache( ld, new ); + } + + if ( msgid == LDAP_RES_ANY || id == msgid ) { + if ( new->lm_msgtype == LDAP_RES_SEARCH_RESULT ) { + /* + * return the first response we have for this + * search request later (possibly an entire + * chain of messages). + */ + foundit = 1; + } else if ( all == 0 + || (new->lm_msgtype != LDAP_RES_SEARCH_REFERENCE + && new->lm_msgtype != LDAP_RES_SEARCH_ENTRY) ) { + *result = new; + LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, + NULL ); + return( tag ); + } + } + } + + /* + * if not, we must add it to the list of responses. if + * the msgid is already there, it must be part of an existing + * search response. + */ + + prev = NULL; + LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK ); + for ( l = ld->ld_responses; l != NULL; l = l->lm_next ) { + if ( l->lm_msgid == new->lm_msgid ) + break; + prev = l; + } + + /* not part of an existing search response */ + if ( l == NULL ) { + if ( foundit ) { + LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); + *result = new; + LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL ); + return( tag ); + } + + new->lm_next = ld->ld_responses; + ld->ld_responses = new; + LDAPDebug( LDAP_DEBUG_TRACE, + "adding new response id %d type %d (looking for id %d)\n", + new->lm_msgid, new->lm_msgtype, msgid ); + LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); + if( message_can_be_returned ) + POST( ld, new->lm_msgid, new ); + return( NSLDAPI_RESULT_NOT_FOUND ); /* continue looking */ + } + + LDAPDebug( LDAP_DEBUG_TRACE, + "adding response 0x%p - id %d type %d", + new, new->lm_msgid, new->lm_msgtype ); + LDAPDebug( LDAP_DEBUG_TRACE, " (looking for id %d)\n", msgid, 0, 0 ); + + /* + * part of a search response - add to end of list of entries + * + * the first step is to find the end of the list of entries and + * references. after the following loop is executed, tmp points to + * the last entry or reference in the chain. If there are none, + * tmp points to the search result. + */ + chainprev = NULL; + for ( tmp = l; tmp->lm_chain != NULL && + ( tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY + || tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ); + tmp = tmp->lm_chain ) { + chainprev = tmp; + } + + /* + * If this is a manufactured result message and a result is already + * queued we throw away the one that is queued and replace it with + * our new result. This is necessary so we don't end up returning + * more than one result. + */ + if ( manufactured_result && + tmp->lm_msgtype == LDAP_RES_SEARCH_RESULT ) { + /* + * the result is the only thing in the chain... replace it. + */ + new->lm_chain = tmp->lm_chain; + new->lm_next = tmp->lm_next; + if ( chainprev == NULL ) { + if ( prev == NULL ) { + ld->ld_responses = new; + } else { + prev->lm_next = new; + } + } else { + chainprev->lm_chain = new; + } + if ( l == tmp ) { + l = new; + } + ldap_msgfree( tmp ); + + } else if ( manufactured_result && tmp->lm_chain != NULL + && tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_RESULT ) { + /* + * entries or references are also present, so the result + * is the next entry after tmp. replace it. + */ + new->lm_chain = tmp->lm_chain->lm_chain; + new->lm_next = tmp->lm_chain->lm_next; + ldap_msgfree( tmp->lm_chain ); + tmp->lm_chain = new; + + } else if ( tmp->lm_msgtype == LDAP_RES_SEARCH_RESULT ) { + /* + * the result is the only thing in the chain... add before it. + */ + new->lm_chain = tmp; + if ( chainprev == NULL ) { + if ( prev == NULL ) { + ld->ld_responses = new; + } else { + prev->lm_next = new; + } + } else { + chainprev->lm_chain = new; + } + if ( l == tmp ) { + l = new; + } + + } else { + /* + * entries and/or references are present... add to the end + * of the entry/reference part of the chain. + */ + new->lm_chain = tmp->lm_chain; + tmp->lm_chain = new; + } + + /* + * return the first response or the whole chain if that's what + * we were looking for.... + */ + if ( foundit ) { + if ( all == 0 && l->lm_chain != NULL ) { + /* + * only return the first response in the chain + */ + if ( prev == NULL ) { + ld->ld_responses = l->lm_chain; + } else { + prev->lm_next = l->lm_chain; + } + l->lm_chain = NULL; + tag = l->lm_msgtype; + } else { + /* + * return all of the responses (may be a chain) + */ + if ( prev == NULL ) { + ld->ld_responses = l->lm_next; + } else { + prev->lm_next = l->lm_next; + } + } + *result = l; + LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); + LDAP_SET_LDERRNO( ld, LDAP_SUCCESS, NULL, NULL ); + return( tag ); + } + LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); + return( NSLDAPI_RESULT_NOT_FOUND ); /* continue looking */ +} + + +/* + * check for LDAPv2+ (UMich extension) or LDAPv3 referrals or references + * errors are merged in "lr". + */ +static void +check_for_refs( LDAP *ld, LDAPRequest *lr, BerElement *ber, + int ldapversion, int *totalcountp, int *chasingcountp ) +{ + int err, origerr; + char *errstr, *matcheddn, **v3refs; + + LDAPDebug( LDAP_DEBUG_TRACE, "check_for_refs\n", 0, 0, 0 ); + + *chasingcountp = *totalcountp = 0; + + if ( ldapversion < LDAP_VERSION2 || ( lr->lr_parent == NULL + && ( ld->ld_options & LDAP_BITOPT_REFERRALS ) == 0 )) { + /* referrals are not supported or are disabled */ + return; + } + + if ( lr->lr_res_msgtype == LDAP_RES_SEARCH_REFERENCE ) { + err = nsldapi_parse_reference( ld, ber, &v3refs, NULL ); + origerr = LDAP_REFERRAL; /* a small lie... */ + matcheddn = errstr = NULL; + } else { + err = nsldapi_parse_result( ld, lr->lr_res_msgtype, ber, + &origerr, &matcheddn, &errstr, &v3refs, NULL ); + } + + if ( err != LDAP_SUCCESS ) { + /* parse failed */ + return; + } + + if ( origerr == LDAP_REFERRAL ) { /* ldapv3 */ + if ( v3refs != NULL ) { + err = nsldapi_chase_v3_refs( ld, lr, v3refs, + ( lr->lr_res_msgtype == LDAP_RES_SEARCH_REFERENCE ), + totalcountp, chasingcountp ); + ldap_value_free( v3refs ); + } + } else if ( ldapversion == LDAP_VERSION2 + && origerr != LDAP_SUCCESS ) { + /* referrals may be present in the error string */ + err = nsldapi_chase_v2_referrals( ld, lr, &errstr, + totalcountp, chasingcountp ); + } + + /* set LDAP errno, message, and matched string appropriately */ + if ( lr->lr_res_error != NULL ) { + NSLDAPI_FREE( lr->lr_res_error ); + } + lr->lr_res_error = errstr; + + if ( lr->lr_res_matched != NULL ) { + NSLDAPI_FREE( lr->lr_res_matched ); + } + lr->lr_res_matched = matcheddn; + + if ( err == LDAP_SUCCESS && ( *chasingcountp == *totalcountp )) { + if ( *totalcountp > 0 && ( origerr == LDAP_PARTIAL_RESULTS + || origerr == LDAP_REFERRAL )) { + /* substitute success for referral error codes */ + lr->lr_res_errno = LDAP_SUCCESS; + } else { + /* preserve existing non-referral error code */ + lr->lr_res_errno = origerr; + } + } else if ( err != LDAP_SUCCESS ) { + /* error occurred while trying to chase referrals */ + lr->lr_res_errno = err; + } else { + /* some referrals were not recognized */ + lr->lr_res_errno = ( ldapversion == LDAP_VERSION2 ) + ? LDAP_PARTIAL_RESULTS : LDAP_REFERRAL; + } + + LDAPDebug( LDAP_DEBUG_TRACE, + "check_for_refs: new result: msgid %d, res_errno %d, ", + lr->lr_msgid, lr->lr_res_errno, 0 ); + LDAPDebug( LDAP_DEBUG_TRACE, " res_error <%s>, res_matched <%s>\n", + lr->lr_res_error ? lr->lr_res_error : "", + lr->lr_res_matched ? lr->lr_res_matched : "", 0 ); + LDAPDebug( LDAP_DEBUG_TRACE, + "check_for_refs: %d new refs(s); chasing %d of them\n", + *totalcountp, *chasingcountp, 0 ); +} + + +/* returns an LDAP error code and also sets it in LDAP * */ +static int +build_result_ber( LDAP *ld, BerElement **berp, LDAPRequest *lr ) +{ + ber_len_t len; + ber_int_t along; + BerElement *ber; + int err; + + if (( err = nsldapi_alloc_ber_with_options( ld, &ber )) + != LDAP_SUCCESS ) { + return( err ); + } + *berp = ber; + if ( ber_printf( ber, lr->lr_res_ctrls ? "{it{ess}" : "{it{ess}}", + lr->lr_msgid, (long)lr->lr_res_msgtype, lr->lr_res_errno, + lr->lr_res_matched ? lr->lr_res_matched : "", + lr->lr_res_error ? lr->lr_res_error : "" ) == -1 ) { + return( LDAP_ENCODING_ERROR ); + } + + if ( NULL != lr->lr_res_ctrls && nsldapi_put_controls( ld, + lr->lr_res_ctrls, 1 /* close seq */, ber ) != LDAP_SUCCESS ) { + return( LDAP_ENCODING_ERROR ); + } + + ber_reset( ber, 1 ); + if ( ber_skip_tag( ber, &len ) == LBER_ERROR || + ber_get_int( ber, &along ) == LBER_ERROR || + ber_peek_tag( ber, &len ) == LBER_ERROR ) { + return( LDAP_DECODING_ERROR ); + } + + return( LDAP_SUCCESS ); +} + + +static void +merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) +{ +/* + * Merge error information in "lr" with "parentr" error code and string. + */ + if ( lr->lr_res_errno == LDAP_PARTIAL_RESULTS ) { + parentr->lr_res_errno = lr->lr_res_errno; + if ( lr->lr_res_error != NULL ) { + (void)nsldapi_append_referral( ld, &parentr->lr_res_error, + lr->lr_res_error ); + } + } else if ( lr->lr_res_errno != LDAP_SUCCESS && + parentr->lr_res_errno == LDAP_SUCCESS ) { + parentr->lr_res_errno = lr->lr_res_errno; + if ( parentr->lr_res_error != NULL ) { + NSLDAPI_FREE( parentr->lr_res_error ); + } + parentr->lr_res_error = lr->lr_res_error; + lr->lr_res_error = NULL; + if ( NAME_ERROR( lr->lr_res_errno )) { + if ( parentr->lr_res_matched != NULL ) { + NSLDAPI_FREE( parentr->lr_res_matched ); + } + parentr->lr_res_matched = lr->lr_res_matched; + lr->lr_res_matched = NULL; + } + } + + LDAPDebug( LDAP_DEBUG_TRACE, "merged parent (id %d) error info: ", + parentr->lr_msgid, 0, 0 ); + LDAPDebug( LDAP_DEBUG_TRACE, "result lderrno %d, error <%s>, matched <%s>\n", + parentr->lr_res_errno, parentr->lr_res_error ? + parentr->lr_res_error : "", parentr->lr_res_matched ? + parentr->lr_res_matched : "" ); +} + +#if defined( CLDAP ) +#if !defined( macintosh ) && !defined( DOS ) && !defined( _WINDOWS ) && !defined(XP_OS2) +/* XXXmcs: was revised to support extended I/O callbacks but never compiled! */ +static int +cldap_select1( LDAP *ld, struct timeval *timeout ) +{ + int rc; + static int tblsize = 0; + NSLDAPIIOStatus *iosp = ld->ld_iostatus; + + if ( tblsize == 0 ) { +#ifdef USE_SYSCONF + tblsize = sysconf( _SC_OPEN_MAX ); +#else /* USE_SYSCONF */ + tblsize = getdtablesize(); +#endif /* USE_SYSCONF */ + } + + if ( tblsize >= FD_SETSIZE ) { + /* + * clamp value so we don't overrun the fd_set structure + */ + tblsize = FD_SETSIZE - 1; + } + + if ( NSLDAPI_IOSTATUS_TYPE_OSNATIVE == iosp->ios_type ) { + fd_set readfds; + + FD_ZERO( &readfds ); + FD_SET( ld->ld_sbp->sb_sd, &readfds ); + + /* XXXmcs: UNIX platforms should use poll() */ + rc = select( tblsize, &readfds, 0, 0, timeout ) ); + + } else if ( NSLDAPI_IOSTATUS_TYPE_CALLBACK == iosp->ios_type ) { + LDAP_X_PollFD pollfds[ 1 ]; + + pollfds[0].lpoll_fd = ld->ld_sbp->sb_sd; + pollfds[0].lpoll_arg = ld->ld_sbp->sb_arg; + pollfds[0].lpoll_events = LDAP_X_POLLIN; + pollfds[0].lpoll_revents = 0; + rc = ld->ld_extpoll_fn( pollfds, 1, nsldapi_tv2ms( timeout ), + ld->ld_ext_session_arg ); + } else { + LDAPDebug( LDAP_DEBUG_ANY, + "nsldapi_iostatus_poll: unknown I/O type %d\n", + rc = 0; /* simulate a timeout (what else to do?) */ + } + + return( rc ); +} +#endif /* !macintosh */ + + +#ifdef macintosh +static int +cldap_select1( LDAP *ld, struct timeval *timeout ) +{ + /* XXXmcs: needs to be revised to support I/O callbacks */ + return( tcpselect( ld->ld_sbp->sb_sd, timeout )); +} +#endif /* macintosh */ + + +#if (defined( DOS ) && defined( WINSOCK )) || defined( _WINDOWS ) || defined(XP_OS2) +/* XXXmcs: needs to be revised to support extended I/O callbacks */ +static int +cldap_select1( LDAP *ld, struct timeval *timeout ) +{ + fd_set readfds; + int rc; + + FD_ZERO( &readfds ); + FD_SET( ld->ld_sbp->sb_sd, &readfds ); + + if ( NSLDAPI_IO_TYPE_STANDARD == ld->ldiou_type && + NULL != ld->ld_select_fn ) { + rc = ld->ld_select_fn( 1, &readfds, 0, 0, timeout ); + } else if ( NSLDAPI_IO_TYPE_EXTENDED == ld->ldiou_type && + NULL != ld->ld_extselect_fn ) { + rc = ld->ld_extselect_fn( ld->ld_ext_session_arg, 1, &readfds, 0, + 0, timeout ) ); + } else { + /* XXXmcs: UNIX platforms should use poll() */ + rc = select( 1, &readfds, 0, 0, timeout ) ); + } + + return( rc == SOCKET_ERROR ? -1 : rc ); +} +#endif /* WINSOCK || _WINDOWS */ +#endif /* CLDAP */ + +int +LDAP_CALL +ldap_msgfree( LDAPMessage *lm ) +{ + LDAPMessage *next; + int type = 0; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_msgfree\n", 0, 0, 0 ); + + for ( ; lm != NULL; lm = next ) { + next = lm->lm_chain; + type = lm->lm_msgtype; + ber_free( lm->lm_ber, 1 ); + NSLDAPI_FREE( (char *) lm ); + } + + return( type ); +} + +/* + * ldap_msgdelete - delete a message. It returns: + * 0 if the entire message was deleted + * -1 if the message was not found, or only part of it was found + */ +int +ldap_msgdelete( LDAP *ld, int msgid ) +{ + LDAPMessage *lm, *prev; + int msgtype; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_msgdelete\n", 0, 0, 0 ); + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + return( -1 ); /* punt */ + } + + prev = NULL; + LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK ); + for ( lm = ld->ld_responses; lm != NULL; lm = lm->lm_next ) { + if ( lm->lm_msgid == msgid ) + break; + prev = lm; + } + + if ( lm == NULL ) + { + LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); + return( -1 ); + } + + if ( prev == NULL ) + ld->ld_responses = lm->lm_next; + else + prev->lm_next = lm->lm_next; + LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK ); + + msgtype = ldap_msgfree( lm ); + if ( msgtype == LDAP_RES_SEARCH_ENTRY + || msgtype == LDAP_RES_SEARCH_REFERENCE ) { + return( -1 ); + } + + return( 0 ); +} + + +/* + * return 1 if message msgid is waiting to be abandoned, 0 otherwise + */ +static int +ldap_abandoned( LDAP *ld, int msgid ) +{ + int i; + + LDAP_MUTEX_LOCK( ld, LDAP_ABANDON_LOCK ); + if ( ld->ld_abandoned == NULL ) + { + LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); + return( 0 ); + } + + for ( i = 0; ld->ld_abandoned[i] != -1; i++ ) + if ( ld->ld_abandoned[i] == msgid ) + { + LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); + return( 1 ); + } + + LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); + return( 0 ); +} + + +static int +ldap_mark_abandoned( LDAP *ld, int msgid ) +{ + int i; + + LDAP_MUTEX_LOCK( ld, LDAP_ABANDON_LOCK ); + if ( ld->ld_abandoned == NULL ) + { + LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); + return( -1 ); + } + + for ( i = 0; ld->ld_abandoned[i] != -1; i++ ) + if ( ld->ld_abandoned[i] == msgid ) + break; + + if ( ld->ld_abandoned[i] == -1 ) + { + LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); + return( -1 ); + } + + for ( ; ld->ld_abandoned[i] != -1; i++ ) { + ld->ld_abandoned[i] = ld->ld_abandoned[i + 1]; + } + + LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK ); + return( 0 ); +} + + +#ifdef CLDAP +int +cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement **ber ) +{ + int rc; + ber_tag_t tag; + ber_len_t len; + + if ( ld->ld_sbp->sb_ber.ber_ptr >= ld->ld_sbp->sb_ber.ber_end ) { + rc = cldap_select1( ld, timeout ); + if ( rc == -1 || rc == 0 ) { + LDAP_SET_LDERRNO( ld, (rc == -1 ? LDAP_SERVER_DOWN : + LDAP_TIMEOUT), NULL, NULL ); + return( rc ); + } + } + + /* get the next message */ + if ( (tag = ber_get_next( ld->ld_sbp, &len, ber )) + != LDAP_TAG_MESSAGE ) { + LDAP_SET_LDERRNO( ld, (tag == LBER_DEFAULT ? LDAP_SERVER_DOWN : + LDAP_LOCAL_ERROR), NULL, NULL ); + return( -1 ); + } + + return( tag ); +} +#endif /* CLDAP */ + +int +nsldapi_post_result( LDAP *ld, int msgid, LDAPMessage *result ) +{ + LDAPPend *lp; + + LDAPDebug( LDAP_DEBUG_TRACE, + "nsldapi_post_result(ld=0x%p, msgid=%d, result=0x%p)\n", + ld, msgid, result ); + LDAP_MUTEX_LOCK( ld, LDAP_PEND_LOCK ); + if( msgid == LDAP_RES_ANY ) { + /* + * Look for any pending request for which someone is waiting. + */ + for( lp = ld->ld_pend; lp != NULL; lp = lp->lp_next ) + { + if ( lp->lp_sema != NULL ) { + break; + } + } + /* + * If we did't find a pending request, lp is NULL at this + * point, and we will leave this function without doing + * anything more -- which is exactly what we want to do. + */ + } + else + { + /* + * Look for a pending request specific to this message id + */ + for( lp = ld->ld_pend; lp != NULL; lp = lp->lp_next ) + { + if( lp->lp_msgid == msgid ) + break; + } + + if( lp == NULL ) + { + /* + * No pending requests for this response... append to + * our pending result list. + */ + LDAPPend *newlp; + newlp = (LDAPPend *)NSLDAPI_CALLOC( 1, + sizeof( LDAPPend )); + if( newlp == NULL ) + { + LDAP_MUTEX_UNLOCK( ld, LDAP_PEND_LOCK ); + LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, + NULL ); + return (-1); + } + newlp->lp_msgid = msgid; + newlp->lp_result = result; + link_pend( ld, newlp ); + } + } + + + if( lp != NULL ) + { + /* + * Wake up a thread that is waiting for this result. + */ + lp->lp_msgid = msgid; + lp->lp_result = result; + LDAP_SEMA_POST( ld, lp ); + } + + LDAP_MUTEX_UNLOCK( ld, LDAP_PEND_LOCK ); + return (0); +} + +static void +link_pend( LDAP *ld, LDAPPend *lp ) +{ + if (( lp->lp_next = ld->ld_pend ) != NULL ) + { + lp->lp_next->lp_prev = lp; + } + ld->ld_pend = lp; + lp->lp_prev = NULL; +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/saslbind.c
Added
@@ -0,0 +1,877 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +#include "ldap-int.h" + +#ifdef LDAP_SASLIO_HOOKS +/* + * Global SASL Init data + */ + +static int +nsldapi_sasl_fail() +{ + return( SASL_FAIL ); +} + +sasl_callback_t client_callbacks[] = { + { SASL_CB_GETOPT, nsldapi_sasl_fail, NULL }, + { SASL_CB_GETREALM, NULL, NULL }, + { SASL_CB_USER, NULL, NULL }, + { SASL_CB_CANON_USER, NULL, NULL }, + { SASL_CB_AUTHNAME, NULL, NULL }, + { SASL_CB_PASS, NULL, NULL }, + { SASL_CB_ECHOPROMPT, NULL, NULL }, + { SASL_CB_NOECHOPROMPT, NULL, NULL }, + { SASL_CB_LIST_END, NULL, NULL } +}; + +int +nsldapi_sasl_cvterrno( LDAP *ld, int err, char *msg ) +{ + int rc = LDAP_LOCAL_ERROR; + + switch (err) { + case SASL_OK: + rc = LDAP_SUCCESS; + break; + case SASL_NOMECH: + rc = LDAP_AUTH_UNKNOWN; + break; + case SASL_BADSERV: + rc = LDAP_CONNECT_ERROR; + break; + case SASL_DISABLED: + case SASL_ENCRYPT: + case SASL_EXPIRED: + case SASL_NOUSERPASS: + case SASL_NOVERIFY: + case SASL_PWLOCK: + case SASL_TOOWEAK: + case SASL_UNAVAIL: + case SASL_WEAKPASS: + rc = LDAP_INAPPROPRIATE_AUTH; + break; + case SASL_BADAUTH: + case SASL_NOAUTHZ: + rc = LDAP_INVALID_CREDENTIALS; + break; + case SASL_NOMEM: + rc = LDAP_NO_MEMORY; + break; + case SASL_NOUSER: + rc = LDAP_NO_SUCH_OBJECT; + break; + case SASL_CONTINUE: + case SASL_FAIL: + case SASL_INTERACT: + default: + rc = LDAP_LOCAL_ERROR; + break; + } + + LDAP_SET_LDERRNO( ld, rc, NULL, msg ); + return( rc ); +} + +#ifdef LDAP_SASLIO_GET_MECHS_FROM_SERVER +/* + * Get available SASL Mechanisms supported by the server + */ + +static int +nsldapi_get_sasl_mechs ( LDAP *ld, char **pmech ) +{ + char *attr[] = { "supportedSASLMechanisms", NULL }; + char **values, **v, *mech, *m; + LDAPMessage *res, *e; + struct timeval timeout; + int slen, rc; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + return( LDAP_PARAM_ERROR ); + } + + timeout.tv_sec = SEARCH_TIMEOUT_SECS; + timeout.tv_usec = 0; + + rc = ldap_search_st( ld, "", LDAP_SCOPE_BASE, + "objectclass=*", attr, 0, &timeout, &res ); + + if ( rc != LDAP_SUCCESS ) { + return( LDAP_GET_LDERRNO( ld, NULL, NULL ) ); + } + + e = ldap_first_entry( ld, res ); + if ( e == NULL ) { + ldap_msgfree( res ); + if ( ld->ld_errno == LDAP_SUCCESS ) { + LDAP_SET_LDERRNO( ld, LDAP_NO_SUCH_OBJECT, NULL, NULL ); + } + return( LDAP_GET_LDERRNO( ld, NULL, NULL ) ); + } + + values = ldap_get_values( ld, e, "supportedSASLMechanisms" ); + if ( values == NULL ) { + ldap_msgfree( res ); + LDAP_SET_LDERRNO( ld, LDAP_NO_SUCH_ATTRIBUTE, NULL, NULL ); + return( LDAP_NO_SUCH_ATTRIBUTE ); + } + + slen = 0; + for(v = values; *v != NULL; v++ ) { + slen += strlen(*v) + 1; + } + if ( (mech = NSLDAPI_CALLOC(1, slen)) == NULL) { + ldap_value_free( values ); + ldap_msgfree( res ); + LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); + return( LDAP_NO_MEMORY ); + } + m = mech; + for(v = values; *v; v++) { + if (v != values) { + *m++ = ' '; + } + slen = strlen(*v); + strncpy(m, *v, slen); + m += slen; + } + *m = '\0'; + + ldap_value_free( values ); + ldap_msgfree( res ); + + *pmech = mech; + + return( LDAP_SUCCESS ); +} +#endif /* LDAP_SASLIO_GET_MECHS_FROM_SERVER */ + +int +nsldapi_sasl_secprops( + const char *in, + sasl_security_properties_t *secprops ) +{ + int i; + char **props = NULL; + char *inp; + unsigned sflags = 0; + sasl_ssf_t max_ssf = 0; + sasl_ssf_t min_ssf = 0; + unsigned maxbufsize = 0; + int got_sflags = 0; + int got_max_ssf = 0; + int got_min_ssf = 0; + int got_maxbufsize = 0; + + if (in == NULL) { + return LDAP_PARAM_ERROR; + } + inp = nsldapi_strdup(in); + if (inp == NULL) { + return LDAP_PARAM_ERROR; + } + props = ldap_str2charray( inp, "," ); + NSLDAPI_FREE( inp ); + + if( props == NULL || secprops == NULL ) { + return LDAP_PARAM_ERROR; + } + + for( i=0; props[i]; i++ ) { + if( strcasecmp(props[i], "none") == 0 ) { + got_sflags++; + + } else if( strcasecmp(props[i], "noactive") == 0 ) { + got_sflags++; + sflags |= SASL_SEC_NOACTIVE; + + } else if( strcasecmp(props[i], "noanonymous") == 0 ) { + got_sflags++; + sflags |= SASL_SEC_NOANONYMOUS; + + } else if( strcasecmp(props[i], "nodict") == 0 ) { + got_sflags++; + sflags |= SASL_SEC_NODICTIONARY; + + } else if( strcasecmp(props[i], "noplain") == 0 ) { + got_sflags++; + sflags |= SASL_SEC_NOPLAINTEXT; + + } else if( strcasecmp(props[i], "forwardsec") == 0 ) { + got_sflags++; + sflags |= SASL_SEC_FORWARD_SECRECY; + + } else if( strcasecmp(props[i], "passcred") == 0 ) { + got_sflags++; + sflags |= SASL_SEC_PASS_CREDENTIALS; + + } else if( strncasecmp(props[i], + "minssf=", sizeof("minssf")) == 0 ) { + if( isdigit( props[i][sizeof("minssf")] ) ) { + got_min_ssf++; + min_ssf = atoi( &props[i][sizeof("minssf")] ); + } else { + return LDAP_NOT_SUPPORTED; + } + + } else if( strncasecmp(props[i], + "maxssf=", sizeof("maxssf")) == 0 ) { + if( isdigit( props[i][sizeof("maxssf")] ) ) { + got_max_ssf++; + max_ssf = atoi( &props[i][sizeof("maxssf")] ); + } else { + return LDAP_NOT_SUPPORTED; + } + + } else if( strncasecmp(props[i], + "maxbufsize=", sizeof("maxbufsize")) == 0 ) { + if( isdigit( props[i][sizeof("maxbufsize")] ) ) { + got_maxbufsize++; + maxbufsize = atoi( &props[i][sizeof("maxbufsize")] ); + if( maxbufsize && + (( maxbufsize < SASL_MIN_BUFF_SIZE ) + || (maxbufsize > SASL_MAX_BUFF_SIZE ))) { + return( LDAP_PARAM_ERROR ); + } + } else { + return( LDAP_NOT_SUPPORTED ); + } + } else { + return( LDAP_NOT_SUPPORTED ); + } + } + + if(got_sflags) { + secprops->security_flags = sflags; + } + if(got_min_ssf) { + secprops->min_ssf = min_ssf; + } + if(got_max_ssf) { + secprops->max_ssf = max_ssf; + } + if(got_maxbufsize) { + secprops->maxbufsize = maxbufsize; + } + + ldap_charray_free( props ); + return( LDAP_SUCCESS ); +} +#endif /* LDAP_SASLIO_HOOKS */ + +static int +nsldapi_sasl_bind_s( + LDAP *ld, + const char *dn, + const char *mechanism, + const struct berval *cred, + LDAPControl **serverctrls, + LDAPControl **clientctrls, + struct berval **servercredp, + LDAPControl ***responsectrls +) +{ + int err, msgid; + LDAPMessage *result; + + LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_sasl_bind_s\n", 0, 0, 0 ); + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + return( LDAP_PARAM_ERROR ); + } + + if ( NSLDAPI_LDAP_VERSION( ld ) < LDAP_VERSION3 ) { + LDAP_SET_LDERRNO( ld, LDAP_NOT_SUPPORTED, NULL, NULL ); + return( LDAP_NOT_SUPPORTED ); + } + + if ( ( err = ldap_sasl_bind( ld, dn, mechanism, cred, serverctrls, + clientctrls, &msgid )) != LDAP_SUCCESS ) + return( err ); + + if ( ldap_result( ld, msgid, 1, (struct timeval *) 0, &result ) == -1 ) + return( LDAP_GET_LDERRNO( ld, NULL, NULL ) ); + + /* Get the controls sent by the server if requested */ + if ( responsectrls ) { + if ( ( err = ldap_parse_result( ld, result, &err, NULL, NULL, + NULL, responsectrls, 0 )) != LDAP_SUCCESS ) + return( err ); + } + + err = ldap_parse_sasl_bind_result( ld, result, servercredp, 0 ); + if (err != LDAP_SUCCESS && err != LDAP_SASL_BIND_IN_PROGRESS) { + ldap_msgfree( result ); + return( err ); + } + + return( ldap_result2error( ld, result, 1 ) ); +} + +#ifdef LDAP_SASLIO_HOOKS +static int +nsldapi_sasl_do_bind( LDAP *ld, const char *dn, + const char *mechs, unsigned flags, + LDAP_SASL_INTERACT_PROC *callback, void *defaults, + LDAPControl **sctrl, LDAPControl **cctrl, LDAPControl ***rctrl ) +{ + sasl_interact_t *prompts = NULL; + sasl_conn_t *ctx = NULL; + sasl_ssf_t *ssf = NULL; + const char *mech = NULL; + int saslrc, rc; + struct berval ccred; + unsigned credlen; + int stepnum = 1; + char *sasl_username = NULL; + + if (rctrl) { + /* init to NULL so we can call ldap_controls_free below */ + *rctrl = NULL; + } + + if (NSLDAPI_LDAP_VERSION( ld ) < LDAP_VERSION3) { + LDAP_SET_LDERRNO( ld, LDAP_NOT_SUPPORTED, NULL, NULL ); + return( LDAP_NOT_SUPPORTED ); + } + + /* shouldn't happen */ + if (callback == NULL) { + return( LDAP_LOCAL_ERROR ); + } + + if ( (rc = nsldapi_sasl_open(ld, NULL, &ctx, 0)) != LDAP_SUCCESS ) { + return( rc ); + } + + ccred.bv_val = NULL; + ccred.bv_len = 0; + + LDAPDebug(LDAP_DEBUG_TRACE, "Starting SASL/%s authentication\n", + (mechs ? mechs : ""), 0, 0 ); + + do { + saslrc = sasl_client_start( ctx, + mechs, + &prompts, + (const char **)&ccred.bv_val, + &credlen, + &mech ); + + LDAPDebug(LDAP_DEBUG_TRACE, "Doing step %d of client start for SASL/%s authentication\n", + stepnum, (mech ? mech : ""), 0 ); + stepnum++; + + if( saslrc == SASL_INTERACT && + (callback)(ld, flags, defaults, prompts) != LDAP_SUCCESS ) { + break; + } + } while ( saslrc == SASL_INTERACT ); + + ccred.bv_len = credlen; + + if ( (saslrc != SASL_OK) && (saslrc != SASL_CONTINUE) ) { + return( nsldapi_sasl_cvterrno( ld, saslrc, nsldapi_strdup( sasl_errdetail( ctx ) ) ) ); + } + + stepnum = 1; + + do { + struct berval *scred; + int clientstepnum = 1; + + scred = NULL; + + if (rctrl) { + /* if we're looping again, we need to free any controls set + during the previous loop */ + /* NOTE that this assumes we only care about the controls + returned by the last call to nsldapi_sasl_bind_s - if + we care about _all_ controls, we will have to figure out + some way to append them each loop go round */ + ldap_controls_free(*rctrl); + *rctrl = NULL; + } + + LDAPDebug(LDAP_DEBUG_TRACE, "Doing step %d of bind for SASL/%s authentication\n", + stepnum, (mech ? mech : ""), 0 ); + stepnum++; + + /* notify server of a sasl bind step */ + rc = nsldapi_sasl_bind_s(ld, dn, mech, &ccred, + sctrl, cctrl, &scred, rctrl); + + if ( ccred.bv_val != NULL ) { + ccred.bv_val = NULL; + } + + if ( rc != LDAP_SUCCESS && rc != LDAP_SASL_BIND_IN_PROGRESS ) { + ber_bvfree( scred ); + return( rc ); + } + + if( rc == LDAP_SUCCESS && saslrc == SASL_OK ) { + /* we're done, no need to step */ + if( scred ) { + if ( scred->bv_len == 0 ) { /* MS AD sends back empty screds */ + LDAPDebug(LDAP_DEBUG_ANY, + "SASL BIND complete - ignoring empty credential response\n", + 0, 0, 0); + ber_bvfree( scred ); + } else { + /* but server provided us with data! */ + LDAPDebug(LDAP_DEBUG_TRACE, + "SASL BIND complete but invalid because server responded with credentials - length [%u]\n", + scred->bv_len, 0, 0); + ber_bvfree( scred ); + LDAP_SET_LDERRNO( ld, LDAP_LOCAL_ERROR, + NULL, "Error during SASL handshake - invalid server credential response" ); + return( LDAP_LOCAL_ERROR ); + } + } + break; + } + + /* perform the next step of the sasl bind */ + do { + LDAPDebug(LDAP_DEBUG_TRACE, "Doing client step %d of bind step %d for SASL/%s authentication\n", + clientstepnum, stepnum, (mech ? mech : "") ); + clientstepnum++; + saslrc = sasl_client_step( ctx, + (scred == NULL) ? NULL : scred->bv_val, + (scred == NULL) ? 0 : scred->bv_len, + &prompts, + (const char **)&ccred.bv_val, + &credlen ); + + if( saslrc == SASL_INTERACT && + (callback)(ld, flags, defaults, prompts) + != LDAP_SUCCESS ) { + break; + } + } while ( saslrc == SASL_INTERACT ); + + ccred.bv_len = credlen; + ber_bvfree( scred ); + + if ( (saslrc != SASL_OK) && (saslrc != SASL_CONTINUE) ) { + return( nsldapi_sasl_cvterrno( ld, saslrc, nsldapi_strdup( sasl_errdetail( ctx ) ) ) ); + } + } while ( rc == LDAP_SASL_BIND_IN_PROGRESS ); + + if ( rc != LDAP_SUCCESS ) { + return( rc ); + } + + if ( saslrc != SASL_OK ) { + return( nsldapi_sasl_cvterrno( ld, saslrc, nsldapi_strdup( sasl_errdetail( ctx ) ) ) ); + } + + saslrc = sasl_getprop( ctx, SASL_USERNAME, (const void **) &sasl_username ); + if ( (saslrc == SASL_OK) && sasl_username ) { + LDAPDebug(LDAP_DEBUG_TRACE, "SASL identity: %s\n", sasl_username, 0, 0); + } + + saslrc = sasl_getprop( ctx, SASL_SSF, (const void **) &ssf ); + if( saslrc == SASL_OK ) { + if( ssf && *ssf ) { + LDAPDebug(LDAP_DEBUG_TRACE, + "SASL install encryption, for SSF: %lu\n", + (unsigned long) *ssf, 0, 0 ); + nsldapi_sasl_install( ld, NULL ); + } + } + + return( rc ); +} +#endif /* LDAP_SASLIO_HOOKS */ + + +/* + * ldap_sasl_bind - authenticate to the ldap server. The dn, mechanism, + * and credentials of the entry to which to bind are supplied. An LDAP + * error code is returned and if LDAP_SUCCESS is returned *msgidp is set + * to the id of the request initiated. + * + * Example: + * struct berval creds; + * LDAPControl **ctrls; + * int err, msgid; + * ... fill in creds with credentials ... + * ... fill in ctrls with server controls ... + * err = ldap_sasl_bind( ld, "cn=manager, o=university of michigan, c=us", + * "mechanismname", &creds, ctrls, NULL, &msgid ); + */ +int +LDAP_CALL +ldap_sasl_bind( + LDAP *ld, + const char *dn, + const char *mechanism, + const struct berval *cred, + LDAPControl **serverctrls, + LDAPControl **clientctrls, + int *msgidp +) +{ + BerElement *ber; + int rc, simple, msgid, ldapversion; + + /* + * The ldapv3 bind request looks like this: + * BindRequest ::= SEQUENCE { + * version INTEGER, + * name DistinguishedName, -- who + * authentication CHOICE { + * simple [0] OCTET STRING, -- passwd + * sasl [3] SaslCredentials -- v3 only + * } + * } + * SaslCredentials ::= SEQUENCE { + * mechanism LDAPString, + * credentials OCTET STRING + * } + * all wrapped up in an LDAPMessage sequence. + */ + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_sasl_bind\n", 0, 0, 0 ); + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + return( LDAP_PARAM_ERROR ); + } + + if ( msgidp == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return( LDAP_PARAM_ERROR ); + } + + if ( ( ld->ld_options & LDAP_BITOPT_RECONNECT ) != 0 ) { + nsldapi_handle_reconnect( ld ); + } + + simple = ( mechanism == LDAP_SASL_SIMPLE ); + ldapversion = NSLDAPI_LDAP_VERSION( ld ); + + /* only ldapv3 or higher can do sasl binds */ + if ( !simple && ldapversion < LDAP_VERSION3 ) { + LDAP_SET_LDERRNO( ld, LDAP_NOT_SUPPORTED, NULL, NULL ); + return( LDAP_NOT_SUPPORTED ); + } + + LDAP_MUTEX_LOCK( ld, LDAP_MSGID_LOCK ); + msgid = ++ld->ld_msgid; + LDAP_MUTEX_UNLOCK( ld, LDAP_MSGID_LOCK ); + + if ( dn == NULL ) + dn = ""; + + if ( ld->ld_cache_on && ld->ld_cache_bind != NULL ) { + LDAP_MUTEX_LOCK( ld, LDAP_CACHE_LOCK ); + if ( (rc = (ld->ld_cache_bind)( ld, msgid, LDAP_REQ_BIND, dn, + cred, LDAP_AUTH_SASL )) != 0 ) { + *msgidp = rc; + LDAP_MUTEX_UNLOCK( ld, LDAP_CACHE_LOCK ); + return( LDAP_SUCCESS ); + } + LDAP_MUTEX_UNLOCK( ld, LDAP_CACHE_LOCK ); + } + + /* create a message to send */ + if (( rc = nsldapi_alloc_ber_with_options( ld, &ber )) + != LDAP_SUCCESS ) { + return( rc ); + } + + /* fill it in */ + if ( simple ) { /* simple bind; works in LDAPv2 or v3 */ + struct berval tmpcred; + + if ( cred == NULL ) { + tmpcred.bv_val = ""; + tmpcred.bv_len = 0; + cred = &tmpcred; + } + rc = ber_printf( ber, "{it{isto}", msgid, LDAP_REQ_BIND, + ldapversion, dn, LDAP_AUTH_SIMPLE, cred->bv_val, + cred->bv_len ); + + } else { /* SASL bind; requires LDAPv3 or better */ + if ( cred == NULL || cred->bv_val == NULL || cred->bv_len == 0) { + rc = ber_printf( ber, "{it{ist{s}}", msgid, + LDAP_REQ_BIND, ldapversion, dn, LDAP_AUTH_SASL, + mechanism ); + } else { + rc = ber_printf( ber, "{it{ist{so}}", msgid, + LDAP_REQ_BIND, ldapversion, dn, LDAP_AUTH_SASL, + mechanism, cred->bv_val, + cred->bv_len ); + } + } + + if ( rc == -1 ) { + LDAP_SET_LDERRNO( ld, LDAP_ENCODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_ENCODING_ERROR ); + } + + if ( (rc = nsldapi_put_controls( ld, serverctrls, 1, ber )) + != LDAP_SUCCESS ) { + ber_free( ber, 1 ); + return( rc ); + } + + /* send the message */ + rc = nsldapi_send_initial_request( ld, msgid, LDAP_REQ_BIND, + (char *)dn, ber ); + *msgidp = rc; + return( rc < 0 ? LDAP_GET_LDERRNO( ld, NULL, NULL ) : LDAP_SUCCESS ); +} + +/* + * ldap_sasl_bind_s - bind to the ldap server using sasl authentication + * The dn, mechanism, and credentials of the entry to which to bind are + * supplied. LDAP_SUCCESS is returned upon success, the ldap error code + * otherwise. + * + * Example: + * struct berval creds; + * ... fill in creds with credentials ... + * ldap_sasl_bind_s( ld, "cn=manager, o=university of michigan, c=us", + * "mechanismname", &creds ) + */ +int +LDAP_CALL +ldap_sasl_bind_s( + LDAP *ld, + const char *dn, + const char *mechanism, + const struct berval *cred, + LDAPControl **serverctrls, + LDAPControl **clientctrls, + struct berval **servercredp +) +{ + return ( nsldapi_sasl_bind_s( ld, dn, mechanism, cred, + serverctrls, clientctrls, servercredp, NULL ) ); +} + +#ifdef LDAP_SASLIO_HOOKS +/* + * SASL Authentication Interface: ldap_sasl_interactive_bind_s + * + * This routine takes a DN, SASL mech list, and a SASL callback + * and performs the necessary sequencing to complete a SASL bind + * to the LDAP connection ld. The user provided callback can + * use an optionally provided set of default values to complete + * any necessary interactions. + * + * Currently imposes the following restrictions: + * A mech list must be provided + * LDAP_SASL_INTERACTIVE mode requires a callback + */ +int +LDAP_CALL +ldap_sasl_interactive_bind_s( LDAP *ld, const char *dn, + const char *saslMechanism, + LDAPControl **sctrl, LDAPControl **cctrl, unsigned flags, + LDAP_SASL_INTERACT_PROC *callback, void *defaults ) +{ + return ldap_sasl_interactive_bind_ext_s( ld, dn, + saslMechanism, sctrl, cctrl, flags, callback, + defaults, NULL ); +} + +/* + * ldap_sasl_interactive_bind_ext_s + * + * This function extends ldap_sasl_interactive_bind_s by allowing + * controls received from the server to be returned as rctrl. The + * caller must pass in a valid LDAPControl** pointer and free the + * array of controls when finished with them e.g. + * LDAPControl **retctrls = NULL; + * ... + * ldap_sasl_interactive_bind_ext_s(ld, ...., &retctrls); + * ... + * ldap_controls_free(retctrls); + * Only the controls from the server during the last bind step are returned - + * intermediate controls (if any, usually not) are discarded. + */ +int +LDAP_CALL +ldap_sasl_interactive_bind_ext_s( LDAP *ld, const char *dn, + const char *saslMechanism, + LDAPControl **sctrl, LDAPControl **cctrl, unsigned flags, + LDAP_SASL_INTERACT_PROC *callback, void *defaults, LDAPControl ***rctrl ) +{ +#ifdef LDAP_SASLIO_GET_MECHS_FROM_SERVER + char *smechs; +#endif + int rc; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_sasl_interactive_bind_s\n", 0, 0, 0 ); + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + return( LDAP_PARAM_ERROR ); + } + + if ((flags == LDAP_SASL_INTERACTIVE) && (callback == NULL)) { + return( LDAP_PARAM_ERROR ); + } + + LDAP_MUTEX_LOCK(ld, LDAP_SASL_LOCK ); + + if( saslMechanism == NULL || *saslMechanism == '\0' ) { +#ifdef LDAP_SASLIO_GET_MECHS_FROM_SERVER + rc = nsldapi_get_sasl_mechs( ld, &smechs ); + if( rc != LDAP_SUCCESS ) { + LDAP_MUTEX_UNLOCK(ld, LDAP_SASL_LOCK ); + return( rc ); + } + saslMechanism = smechs; +#else + LDAP_MUTEX_UNLOCK(ld, LDAP_SASL_LOCK ); + return( LDAP_PARAM_ERROR ); +#endif /* LDAP_SASLIO_GET_MECHS_FROM_SERVER */ + } + + rc = nsldapi_sasl_do_bind( ld, dn, saslMechanism, + flags, callback, defaults, sctrl, cctrl, rctrl); + + LDAP_MUTEX_UNLOCK(ld, LDAP_SASL_LOCK ); + return( rc ); +} +#else /* LDAP_SASLIO_HOOKS */ +/* stubs for platforms that do not support SASL */ +int +LDAP_CALL +ldap_sasl_interactive_bind_s( LDAP *ld, const char *dn, + const char *saslMechanism, + LDAPControl **sctrl, LDAPControl **cctrl, unsigned flags, + LDAP_SASL_INTERACT_PROC *callback, void *defaults ) +{ + return LDAP_SUCCESS; +} + +int +LDAP_CALL +ldap_sasl_interactive_bind_ext_s( LDAP *ld, const char *dn, + const char *saslMechanism, + LDAPControl **sctrl, LDAPControl **cctrl, unsigned flags, + LDAP_SASL_INTERACT_PROC *callback, void *defaults, LDAPControl ***rctrl ) +{ + return LDAP_SUCCESS; +} +#endif /* LDAP_SASLIO_HOOKS */ + + +/* returns an LDAP error code that indicates if parse succeeded or not */ +int +LDAP_CALL +ldap_parse_sasl_bind_result( + LDAP *ld, + LDAPMessage *res, + struct berval **servercredp, + int freeit +) +{ + BerElement ber; + int rc, err; + ber_int_t along; + ber_len_t len; + char *m, *e; + + LDAPDebug( LDAP_DEBUG_TRACE, "ldap_parse_sasl_bind_result\n", 0, 0, 0 ); + + /* + * the ldapv3 SASL bind response looks like this: + * + * BindResponse ::= [APPLICATION 1] SEQUENCE { + * COMPONENTS OF LDAPResult, + * serverSaslCreds [7] OCTET STRING OPTIONAL + * } + * + * all wrapped up in an LDAPMessage sequence. + */ + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || + !NSLDAPI_VALID_LDAPMESSAGE_BINDRESULT_POINTER( res )) { + return( LDAP_PARAM_ERROR ); + } + + /* only ldapv3 or higher can do sasl binds */ + if ( NSLDAPI_LDAP_VERSION( ld ) < LDAP_VERSION3 ) { + LDAP_SET_LDERRNO( ld, LDAP_NOT_SUPPORTED, NULL, NULL ); + return( LDAP_NOT_SUPPORTED ); + } + + if ( servercredp != NULL ) { + *servercredp = NULL; + } + + ber = *(res->lm_ber); /* struct copy */ + + /* skip past message id, matched dn, error message ... */ + rc = ber_scanf( &ber, "{iaa}", &along, &m, &e ); + + if ( rc != LBER_ERROR && + ber_peek_tag( &ber, &len ) == LDAP_TAG_SASL_RES_CREDS ) { + rc = ber_get_stringal( &ber, servercredp ); + } + + if ( freeit ) { + ldap_msgfree( res ); + } + + if ( rc == LBER_ERROR ) { + err = LDAP_DECODING_ERROR; + } else { + err = (int) along; + } + + LDAP_SET_LDERRNO( ld, err, m, e ); + /* this is a little kludge for the 3.0 Barracuda/hammerhead relese */ + /* the docs state that the return is either LDAP_DECODING_ERROR */ + /* or LDAP_SUCCESS. Here we match the docs... it's cleaner in 3.1 */ + + if ( LDAP_DECODING_ERROR == err ) { + return (LDAP_DECODING_ERROR); + } else { + return( LDAP_SUCCESS ); + } +} +
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/saslio.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/saslio.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/sbind.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/sbind.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/search.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/search.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/setoption.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/setoption.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/sort.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/sort.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/sortctrl.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/sortctrl.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/srchpref.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/srchpref.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/test.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/test.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/tmplout.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/tmplout.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/tmpltest.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/tmpltest.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/ufn.c
Added
@@ -0,0 +1,563 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +/* + * Copyright (c) 1990 Regents of the University of Michigan. + * All rights reserved. + */ +/* + * ufn.c + */ + +#if 0 +#ifndef lint +static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n"; +#endif +#endif + +#include "ldap-int.h" + +typedef int (LDAP_CALL *cancelptype)( void *cancelparm ); + +static int ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, + char *prefix, char **attrs, int attrsonly, + LDAPMessage **res, LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm, + char *tag1, char *tag2, char *tag3 ); +static LDAPMessage *ldap_msg_merge( LDAP *ld, LDAPMessage *a, LDAPMessage *b ); +static LDAPMessage *ldap_ufn_expand( LDAP *ld, + LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm, char **dns, + char *filter, int scope, char **attrs, int aonly, int *err ); + +/* + * ldap_ufn_search_ctx - do user friendly searching; provide cancel feature; + * specify ldapfilter.conf tags for each phase of search + * + * ld LDAP descriptor + * ufncomp the exploded user friendly name to look for + * ncomp number of elements in ufncomp + * prefix where to start searching + * attrs list of attribute types to return for matches + * attrsonly 1 => attributes only 0 => attributes and values + * res will contain the result of the search + * cancelproc routine that returns non-zero if operation should be + * cancelled. This can be NULL. If it is non-NULL, the + * routine will be called periodically. + * cancelparm void * that is passed to cancelproc + * tag[123] the ldapfilter.conf tag that will be used in phases + * 1, 2, and 3 of the search, respectively + * + * Example: + * char *attrs[] = { "mail", "title", 0 }; + * char *ufncomp[] = { "howes", "umich", "us", 0 } + * LDAPMessage *res; + * error = ldap_ufn_search_ctx( ld, ufncomp, 3, NULL, attrs, attrsonly, + * &res, acancelproc, along, "ufn first", + * "ufn intermediate", "ufn last" ); + */ + +static int +ldap_ufn_search_ctx( + LDAP *ld, + char **ufncomp, + int ncomp, + char *prefix, + char **attrs, + int attrsonly, + LDAPMessage **res, + LDAP_CANCELPROC_CALLBACK *cancelproc, + void *cancelparm, + char *tag1, + char *tag2, + char *tag3 +) +{ + char *dn, *ftag = NULL; + char **dns = NULL; + int max, i, err, scope = 0, phase, tries; + LDAPFiltInfo *fi; + LDAPMessage *tmpcand; + LDAPMessage *candidates; + static char *objattrs[] = { "objectClass", NULL }; + + /* + * look up ufn components from most to least significant. + * there are 3 phases. + * phase 1 search the root for orgs or countries + * phase 2 search for orgs + * phase 3 search for a person + * in phases 1 and 2, we are building a list of candidate DNs, + * below which we will search for the final component of the ufn. + * for each component we try the filters listed in the + * filterconfig file, first one-level (except the last compoment), + * then subtree. if any of them produce any results, we go on to + * the next component. + */ + + *res = NULL; + candidates = NULL; + phase = 1; + for ( ncomp--; ncomp != -1; ncomp-- ) { + if ( *ufncomp[ncomp] == '"' ) { + char *quote; + + if ( (quote = strrchr( ufncomp[ncomp], '"' )) != NULL ) + *quote = '\0'; + strcpy( ufncomp[ncomp], ufncomp[ncomp] + 1 ); + } + if ( ncomp == 0 ) + phase = 3; + + switch ( phase ) { + case 1: + ftag = tag1; + scope = LDAP_SCOPE_ONELEVEL; + break; + case 2: + ftag = tag2; + scope = LDAP_SCOPE_ONELEVEL; + break; + case 3: + ftag = tag3; + scope = LDAP_SCOPE_SUBTREE; + break; + } + + /* + * construct an array of DN's to search below from the + * list of candidates. + */ + + if ( candidates == NULL ) { + if ( prefix != NULL ) { + if ( (dns = (char **)NSLDAPI_MALLOC( + sizeof(char *) * 2 )) == NULL ) { + err = LDAP_NO_MEMORY; + LDAP_SET_LDERRNO( ld, err, NULL, NULL ); + return( err ); + } + dns[0] = nsldapi_strdup( prefix ); + dns[1] = NULL; + } else { + dns = NULL; + } + } else { + i = 0, max = 0; + for ( tmpcand = candidates; tmpcand != NULL && + tmpcand->lm_msgtype != LDAP_RES_SEARCH_RESULT; + tmpcand = tmpcand->lm_chain ) + { + if ( (dn = ldap_get_dn( ld, tmpcand )) == NULL ) + continue; + + if ( dns == NULL ) { + if ( (dns = (char **)NSLDAPI_MALLOC( + sizeof(char *) * 8 )) == NULL ) { + err = LDAP_NO_MEMORY; + LDAP_SET_LDERRNO( ld, err, + NULL, NULL ); + return( err ); + } + max = 8; + } else if ( i >= max ) { + if ( (dns = (char **)NSLDAPI_REALLOC( + dns, sizeof(char *) * 2 * max )) + == NULL ) { + err = LDAP_NO_MEMORY; + LDAP_SET_LDERRNO( ld, err, + NULL, NULL ); + return( err ); + } + max *= 2; + } + dns[i++] = dn; + dns[i] = NULL; + } + ldap_msgfree( candidates ); + candidates = NULL; + } + tries = 0; + tryagain: + tries++; + for ( fi = ldap_getfirstfilter( ld->ld_filtd, ftag, + ufncomp[ncomp] ); fi != NULL; + fi = ldap_getnextfilter( ld->ld_filtd ) ) + { + if ( (candidates = ldap_ufn_expand( ld, cancelproc, + cancelparm, dns, fi->lfi_filter, scope, + phase == 3 ? attrs : objattrs, + phase == 3 ? attrsonly : 1, &err )) != NULL ) + { + break; + } + + if ( err == -1 || err == LDAP_USER_CANCELLED ) { + if ( dns != NULL ) { + ldap_value_free( dns ); + dns = NULL; + } + return( err ); + } + } + + if ( candidates == NULL ) { + if ( tries < 2 && phase != 3 ) { + scope = LDAP_SCOPE_SUBTREE; + goto tryagain; + } else { + if ( dns != NULL ) { + ldap_value_free( dns ); + dns = NULL; + } + return( err ); + } + } + + /* go on to the next component */ + if ( phase == 1 ) + phase++; + if ( dns != NULL ) { + ldap_value_free( dns ); + dns = NULL; + } + } + *res = candidates; + + return( err ); +} + +int +LDAP_CALL +ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly, + LDAPMessage **res, LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm, + char *tag1, char *tag2, char *tag3 ) +{ + char **ufncomp, **prefixcomp; + char *pbuf; + int ncomp, pcomp, i, err = 0; + + /* getfilter stuff must be inited before we are called */ + if ( ld->ld_filtd == NULL ) { + err = LDAP_PARAM_ERROR; + LDAP_SET_LDERRNO( ld, err, NULL, NULL ); + return( err ); + } + + /* call ldap_explode_dn() to break the ufn into its components */ + if ( (ufncomp = ldap_explode_dn( ufn, 0 )) == NULL ) { + err = LDAP_LOCAL_ERROR; + LDAP_SET_LDERRNO( ld, err, NULL, NULL ); + return( err ); + } + for ( ncomp = 0; ufncomp[ncomp] != NULL; ncomp++ ) + ; /* NULL */ + + /* more than two components => try it fully qualified first */ + if ( ncomp > 2 || ld->ld_ufnprefix == NULL ) { + err = ldap_ufn_search_ctx( ld, ufncomp, ncomp, NULL, attrs, + attrsonly, res, cancelproc, cancelparm, tag1, tag2, tag3 ); + + if ( ldap_count_entries( ld, *res ) > 0 ) { + ldap_value_free( ufncomp ); + return( err ); + } else { + ldap_msgfree( *res ); + *res = NULL; + } + } + + if ( ld->ld_ufnprefix == NULL ) { + ldap_value_free( ufncomp ); + return( err ); + } + + /* if that failed, or < 2 components, use the prefix */ + if ( (prefixcomp = ldap_explode_dn( ld->ld_ufnprefix, 0 )) == NULL ) { + ldap_value_free( ufncomp ); + err = LDAP_LOCAL_ERROR; + LDAP_SET_LDERRNO( ld, err, NULL, NULL ); + return( err ); + } + for ( pcomp = 0; prefixcomp[pcomp] != NULL; pcomp++ ) + ; /* NULL */ + if ( (pbuf = (char *)NSLDAPI_MALLOC( strlen( ld->ld_ufnprefix ) + 1 )) + == NULL ) { + ldap_value_free( ufncomp ); + ldap_value_free( prefixcomp ); + err = LDAP_NO_MEMORY; + LDAP_SET_LDERRNO( ld, err, NULL, NULL ); + return( err ); + } + + for ( i = 0; i < pcomp; i++ ) { + int j; + + *pbuf = '\0'; + for ( j = i; j < pcomp; j++ ) { + strcat( pbuf, prefixcomp[j] ); + if ( j + 1 < pcomp ) + strcat( pbuf, "," ); + } + err = ldap_ufn_search_ctx( ld, ufncomp, ncomp, pbuf, attrs, + attrsonly, res, cancelproc, cancelparm, tag1, tag2, tag3 ); + + if ( ldap_count_entries( ld, *res ) > 0 ) { + break; + } else { + ldap_msgfree( *res ); + *res = NULL; + } + } + + ldap_value_free( ufncomp ); + ldap_value_free( prefixcomp ); + NSLDAPI_FREE( pbuf ); + + return( err ); +} + +/* + * same as ldap_ufn_search_ct, except without the ability to specify + * ldapfilter.conf tags. + */ +int +LDAP_CALL +ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs, int attrsonly, + LDAPMessage **res, LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm ) +{ + return( ldap_ufn_search_ct( ld, ufn, attrs, attrsonly, res, cancelproc, + cancelparm, "ufn first", "ufn intermediate", "ufn last" ) ); +} + +/* + * same as ldap_ufn_search_c without the cancel function + */ +int +LDAP_CALL +ldap_ufn_search_s( LDAP *ld, char *ufn, char **attrs, int attrsonly, + LDAPMessage **res ) +{ + struct timeval tv; + + tv.tv_sec = ld->ld_timelimit; + + return( ldap_ufn_search_ct( ld, ufn, attrs, attrsonly, res, + ld->ld_timelimit ? ldap_ufn_timeout : NULL, + ld->ld_timelimit ? (void *) &tv : NULL, + "ufn first", "ufn intermediate", "ufn last" ) ); +} + + +/* + * ldap_msg_merge - merge two ldap search result chains. the more + * serious of the two error result codes is kept. + */ + +static LDAPMessage * +ldap_msg_merge( LDAP *ld, LDAPMessage *a, LDAPMessage *b ) +{ + LDAPMessage *end, *aprev, *aend, *bprev, *bend; + + if ( a == NULL ) + return( b ); + + if ( b == NULL ) + return( a ); + + /* find the ends of the a and b chains */ + aprev = NULL; + for ( aend = a; aend->lm_chain != NULL; aend = aend->lm_chain ) + aprev = aend; + bprev = NULL; + for ( bend = b; bend->lm_chain != NULL; bend = bend->lm_chain ) + bprev = bend; + + /* keep result a */ + if ( ldap_result2error( ld, aend, 0 ) != LDAP_SUCCESS ) { + /* remove result b */ + ldap_msgfree( bend ); + if ( bprev != NULL ) + bprev->lm_chain = NULL; + else + b = NULL; + end = aend; + if ( aprev != NULL ) + aprev->lm_chain = NULL; + else + a = NULL; + /* keep result b */ + } else { + /* remove result a */ + ldap_msgfree( aend ); + if ( aprev != NULL ) + aprev->lm_chain = NULL; + else + a = NULL; + end = bend; + if ( bprev != NULL ) + bprev->lm_chain = NULL; + else + b = NULL; + } + + if ( (a == NULL && b == NULL) || (a == NULL && bprev == NULL) || + (b == NULL && aprev == NULL) ) + return( end ); + + if ( a == NULL ) { + bprev->lm_chain = end; + return( b ); + } else if ( b == NULL ) { + aprev->lm_chain = end; + return( a ); + } else { + bprev->lm_chain = end; + aprev->lm_chain = b; + return( a ); + } +} + +static LDAPMessage * +ldap_ufn_expand( LDAP *ld, LDAP_CANCELPROC_CALLBACK *cancelproc, + void *cancelparm, char **dns, char *filter, int scope, + char **attrs, int aonly, int *err ) +{ + LDAPMessage *tmpcand, *tmpres; + char *dn; + int i, msgid; + struct timeval tv; + + /* search for this component below the current candidates */ + tmpcand = NULL; + i = 0; + do { + if ( dns != NULL ) + dn = dns[i]; + else + dn = ""; + + if (( msgid = ldap_search( ld, dn, scope, filter, attrs, + aonly )) == -1 ) { + ldap_msgfree( tmpcand ); + tmpcand = NULL; + *err = LDAP_GET_LDERRNO( ld, NULL, NULL ); + /* + * Compiling with gcc-4.2 on Mac: + * gcc-4.2 -arch ppc -c -o ufn.o -gdwarf-2 -01 ufn.c + * having a return NULL statement here causes gcc to + * hang. Therefore set tmpcand to null (above) and break + * out of this loop to make gcc happy. + */ + break; + } + + tv.tv_sec = 0; + tv.tv_usec = 100000; /* 1/10 of a second */ + + do { + *err = ldap_result( ld, msgid, 1, &tv, &tmpres ); + if ( *err == 0 && cancelproc != NULL && + (*cancelproc)( cancelparm ) != 0 ) { + ldap_abandon( ld, msgid ); + *err = LDAP_USER_CANCELLED; + LDAP_SET_LDERRNO( ld, *err, NULL, NULL ); + } + } while ( *err == 0 ); + + if ( *err == LDAP_USER_CANCELLED || *err < 0 || + ( *err = ldap_result2error( ld, tmpres, 0 )) == -1 ) { + ldap_msgfree( tmpcand ); + return( NULL ); + } + + tmpcand = ldap_msg_merge( ld, tmpcand, tmpres ); + + i++; + } while ( dns != NULL && dns[i] != NULL ); + + /* Catch the tmpcand = NULL case as required by breaking out the loop + * to prevent gcc-4.2 hanging on Mac. + */ + if (!tmpcand) + return NULL; + + if ( ldap_count_entries( ld, tmpcand ) > 0 ) { + return( tmpcand ); + } else { + ldap_msgfree( tmpcand ); + return( NULL ); + } +} + +/* + * ldap_ufn_setfilter - set the filter config file used in ufn searching + */ + +LDAPFiltDesc * +LDAP_CALL +ldap_ufn_setfilter( LDAP *ld, char *fname ) +{ + if ( ld->ld_filtd != NULL ) + ldap_getfilter_free( ld->ld_filtd ); + + return( ld->ld_filtd = ldap_init_getfilter( fname ) ); +} + +void +LDAP_CALL +ldap_ufn_setprefix( LDAP *ld, char *prefix ) +{ + if ( ld->ld_ufnprefix != NULL ) + NSLDAPI_FREE( ld->ld_ufnprefix ); + + ld->ld_ufnprefix = nsldapi_strdup( prefix ); +} + +int +LDAP_C +ldap_ufn_timeout( void *tvparam ) +{ + struct timeval *tv; + + tv = (struct timeval *)tvparam; + + if ( tv->tv_sec != 0 ) { + tv->tv_usec = tv->tv_sec * 1000000; /* sec => micro sec */ + tv->tv_sec = 0; + } + tv->tv_usec -= 100000; /* 1/10 of a second */ + + return( tv->tv_usec <= 0 ? 1 : 0 ); +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/unbind.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/unbind.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/unescape.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/unescape.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/url.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/url.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/userstatusctrl.c
Added
@@ -0,0 +1,228 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Sun LDAP C SDK. + * + * The Initial Developer of the Original Code is Sun Microsystems, Inc. + * + * Portions created by Sun Microsystems, Inc are Copyright (C) 2005 + * Sun Microsystems, Inc. All Rights Reserved. + * + * Contributor(s): abobrov@sun.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "ldap-int.h" + +/* ldap_create_userstatus_control: + + Parameters are + + ld LDAP pointer to the desired connection + + ctl_iscritical Indicates whether the control is critical of not. If + this field is non-zero, the operation will only be car- + ried out if the control is recognized by the server + and/or client + + ctrlp the address of a place to put the constructed control +*/ + +int +LDAP_CALL +ldap_create_userstatus_control ( + LDAP *ld, + const char ctl_iscritical, + LDAPControl **ctrlp + ) +{ + int rc; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + return( LDAP_PARAM_ERROR ); + } + + if ( ctrlp == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return ( LDAP_PARAM_ERROR ); + } + + rc = nsldapi_build_control( LDAP_CONTROL_ACCOUNT_USABLE, + NULL, 0, ctl_iscritical, ctrlp ); + + LDAP_SET_LDERRNO( ld, rc, NULL, NULL ); + return( rc ); +} + +/* ldap_parse_userstatus_control: + + Parameters are + + ld LDAP pointer to the desired connection + + ctrlp An array of controls obtained from calling + ldap_parse_result on the set of results + returned by the server + + us the address of struct LDAPuserstatus + to parse control results to +*/ + +int +LDAP_CALL +ldap_parse_userstatus_control ( + LDAP *ld, + LDAPControl **ctrlp, + LDAPuserstatus *us + ) +{ + BerElement *ber = NULL; + int i, foundUSControl; + LDAPControl *USCtrlp = NULL; + ber_tag_t tag; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld ) || us == NULL ) { + return( LDAP_PARAM_ERROR ); + } + + /* find the control in the list of controls if it exists */ + if ( ctrlp == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); + return ( LDAP_CONTROL_NOT_FOUND ); + } + foundUSControl = 0; + for ( i = 0; (( ctrlp[i] != NULL ) && ( !foundUSControl )); i++ ) { + foundUSControl = !strcmp( ctrlp[i]->ldctl_oid, LDAP_CONTROL_ACCOUNT_USABLE ); + } + if ( !foundUSControl ) { + LDAP_SET_LDERRNO( ld, LDAP_CONTROL_NOT_FOUND, NULL, NULL ); + return ( LDAP_CONTROL_NOT_FOUND ); + } else { + /* let local var point to the control */ + USCtrlp = ctrlp[i-1]; + } + + /* allocate a Ber element with the contents of the control's struct berval */ + if ( ( ber = ber_init( &USCtrlp->ldctl_value ) ) == NULL ) { + LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL ); + return( LDAP_NO_MEMORY ); + } + + memset( us, 0, sizeof(struct LDAPuserstatus) ); + + /* + * The control value should look like this: + * + * ACCOUNT_USABLE_RESPONSE::= CHOICE { + * is_available [0] INTEGER, ** seconds before expiration ** + * is_not_available [1] More_info + * } + * More_info::= SEQUENCE { + * inactive [0] BOOLEAN DEFAULT FALSE, + * reset [1] BOOLEAN DEFAULT FALSE, + * expired [2] BOOLEAN DEFAULT FALSE, + * remaining_grace [3] INTEGER OPTIONAL, + * seconds_before_unlock [4] INTEGER OPTIONAL + * } + */ + + if ( ( ber_scanf( ber, "t", &tag ) ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + + tag = (( tag & LBER_CONSTRUCTED ) == LBER_CONSTRUCTED ) ? 1 : 0; + + if ( !tag ) { + us->us_available = 1; + if ( ber_scanf( ber, "i", &us->us_expire ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + } else { + us->us_available = 0; + tag = 0; + if ( ( ber_scanf( ber, "{t", &tag ) ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + while ( tag != LBER_ERROR && tag != LBER_END_OF_SEQORSET ) { + tag = tag & (~LBER_CLASS_CONTEXT); + switch (tag) + { + case 0: + if ( ber_scanf( ber, "b", &us->us_inactive ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + us->us_inactive = ( us->us_inactive != 0 ) ? 1 : 0; + break; + case 1: + if ( ber_scanf( ber, "b", &us->us_reset ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + us->us_reset = ( us->us_reset != 0 ) ? 1 : 0; + break; + case 2: + if ( ber_scanf( ber, "b", &us->us_expired ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + us->us_expired = ( us->us_expired != 0 ) ? 1 : 0; + break; + case 3: + if ( ber_scanf( ber, "i", &us->us_remaining ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + break; + case 4: + if ( ber_scanf( ber, "i", &us->us_seconds ) == LBER_ERROR ) { + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + break; + default: + LDAP_SET_LDERRNO( ld, LDAP_DECODING_ERROR, NULL, NULL ); + ber_free( ber, 1 ); + return( LDAP_DECODING_ERROR ); + } + ber_scanf( ber, "t", &tag ); + } + } + + /* the ber encoding is no longer needed */ + ber_free( ber, 1 ); + return( LDAP_SUCCESS ); +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/utf8.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/utf8.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/vlistctrl.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap/vlistctrl.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap/whoami.c
Added
@@ -0,0 +1,130 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Sun LDAP C SDK. + * + * The Initial Developer of the Original Code is Sun Microsystems, Inc. + * + * Portions created by Sun Microsystems, Inc are Copyright (C) 2005 + * Sun Microsystems, Inc. All Rights Reserved. + * + * Contributor(s): abobrov@sun.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "ldap-int.h" + +/* ldap_whoami */ +int +LDAP_CALL +ldap_whoami ( + LDAP *ld, + LDAPControl **serverctrls, + LDAPControl **clientctrls, + int *msgidp + ) +{ + int rc; + struct berval *requestdata = NULL; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return( LDAP_PARAM_ERROR ); + } + + rc = ldap_extended_operation( ld, LDAP_EXOP_WHO_AM_I, requestdata, + serverctrls, clientctrls, msgidp ); + + return( rc ); +} + +/* ldap_parse_whoami */ +int +LDAP_CALL +ldap_parse_whoami ( + LDAP *ld, + LDAPMessage *result, + struct berval **authzid + ) +{ + int rc; + char *retoidp = NULL; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return( LDAP_PARAM_ERROR ); + } + if ( !result ) { + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return( LDAP_PARAM_ERROR ); + } + + *authzid = NULL; + + rc = ldap_parse_extended_result( ld, result, &retoidp, authzid, 0 ); + + if ( rc != LDAP_SUCCESS ) { + return( rc ); + } + + ldap_memfree( retoidp ); + return( LDAP_SUCCESS ); +} + +/* ldap_whoami_s */ +int +LDAP_CALL +ldap_whoami_s ( + LDAP *ld, + struct berval **authzid, + LDAPControl **serverctrls, + LDAPControl **clientctrls + ) +{ + int rc; + int msgid; + LDAPMessage *result = NULL; + + if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) { + LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return( LDAP_PARAM_ERROR ); + } + + rc = ldap_whoami( ld, serverctrls, clientctrls, &msgid ); + if ( rc != LDAP_SUCCESS ) { + return( rc ); + } + + rc = ldap_result( ld, msgid, LDAP_MSG_ALL, NULL, &result ); + if ( rc == -1 ) { + return( LDAP_GET_LDERRNO( ld, NULL, NULL ) ); + } + + rc = ldap_parse_whoami( ld, result, authzid ); + + ldap_msgfree( result ); + + return( rc ); +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldap_ssl.ex
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldap_ssl.ex)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldif.ex
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldif.ex)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldif/Makefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldif/Makefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldif/Makefile.in
Added
@@ -0,0 +1,166 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is Mozilla Communicator client code, released +# March 31, 1998. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-1999 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +MOD_DEPTH = ../../.. +srcdir = @srcdir@ +topsrcdir = @top_srcdir@ + +include $(MOD_DEPTH)/config/autoconf.mk +include $(topsrcdir)/build.mk + +SRCS = line64.c + +RELEASE_LIBS = $(SHARED_LIBRARY) $(DLLLDIF) + +REALOBJS = $(SRCS:.c=.$(OBJ_SUFFIX)) +OBJS = $(addprefix $(OBJDIR_NAME)/, $(REALOBJS)) + +HDIR = $(topsrcdir)/ldap/include + +LIBLDIF = $(addprefix $(OBJDIR_NAME)/, $(LIB_PREFIX)$(LDIF_LIBNAME).$(LIB_SUFFIX)) +DLLLDIF = $(addprefix $(OBJDIR_NAME)/, $(LIB_PREFIX)$(LDIF_LIBNAME).$(DLL_SUFFIX)) + +INSTALLDIR = $(DIST)/$(OBJDIR_NAME) + +include $(topsrcdir)/config/rules.mk + +GARBAGE += $(LIBLDIF) $(DLLLDIF) + +LOCAL_INCLUDES = -I$(PUBLIC)/nspr +INCLUDES += -I$(HDIR) -I$(INSTALLDIR)/include -I$(DIST)/include +DEFINES += $(DEFS) + +PLATFORMCFLAGS = -DUSE_WAITPID -DNEEDPROTOS +PLATFORMLIBS = +THREADS = +THREADSLIB = + +ifeq ($(OS_ARCH), AIX) +PLATFORMLIBS += -ldl -brtl -lpthreads -lc_r -lm +endif + +# +# shared library symbol export definitions +# +ifeq ($(USE_DLL_EXPORTS_FILE), 1) +ifeq ($(OS_ARCH), WINNT) +GENEXPORTS=cmd /c $(PERL) $(topsrcdir)/ldap/build/genexports.pl +else +GENEXPORTS=$(PERL) $(topsrcdir)/ldap/build/genexports.pl +endif + +# variable definitions for exported symbols +ifeq ($(OS_ARCH), WINNT) + LDIF_EXPORT_DEFS= $(WIN_TOP_SRC)/ldap/libraries/msdos/winsock/nsldif32.def +else +ifeq ($(OS_ARCH), OS2) + LDIF_EXPORT_DEFS= $(OBJDIR_NAME)/libldif.def +else + LDIF_EXPORT_DEFS= $(OBJDIR_NAME)/libldif.exp +endif +GARBAGE += $(LDIF_EXPORT_DEFS) +endif + +LDIF_EXPORT_FLAGS=$(addprefix $(DLLEXPORTS_PREFIX), $(LDIF_EXPORT_DEFS)) + +GENEXPARGS=$(BUILD_DEBUG) $(LDIFVERS_SUFFIX) $(LDIFVERS) +endif # USE_DLL_EXPORTS_FILE + + +########################################################################### + +ifeq ($(USE_DLL_EXPORTS_FILE), 1) +# recursive gmake rule to create exported symbols file +$(LDIF_EXPORT_DEFS):: $(srcdir)/../libldif.ex +ifeq ($(OS_ARCH), WINNT) + $(GENEXPORTS) Win32 $(srcdir)/../msdos/winsock/nsldif32.tdf $< $(GENEXPARGS) > $@ +else +ifeq ($(OS_ARCH), OS2) + echo LIBRARY $(LDIF_LIBNAME) INITINSTANCE TERMINSTANCE > $@ + echo PROTMODE >> $@ + echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@ + echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@ + echo EXPORTS >> $@ + $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) >> $@ +else + $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) > $@ +endif +endif +endif # USE_DLL_EXPORTS_FILE + +versiont.c: Makefile.client Version.c + @$(RM) $@ + @(u="$${USER-root}" v="$(shell cat ../../build/version)" d="$(shell pwd)" \ + h="$(shell hostname)" t="$(shell date)"; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < Version.c > $@) + +export:: $(OBJDEST) $(LIBDIR) $(OBJS) $(LIBLDIF) + +$(LIBDIR): + $(MKDIR) $(LIBDIR) + +$(LIBLDIF): $(OBJS) $(LIBDIR) + @echo ======= making $(LIBLDIF) + + $(LINK_LIB) + +$(DLLLDIF): $(OBJS) $(LIBDIR) $(LDIF_EXPORT_DEFS) + @echo ======= making $(DLLLDIF) + +ifdef SO_FILES_TO_REMOVE + -$(RM) $(SO_FILES_TO_REMOVE) +endif + + $(LINK_DLL) $(LDIF_EXPORT_FLAGS) $(PLATFORMLIBS) $(EXTRA_LIBS) + + +veryclean:: clean + +$(OBJDEST): + $(MKDIR) $(OBJDEST) + +export:: $(DLLLDIF) $(LIBLDIF) + $(INSTALL) -m 444 $(LIBLDIF) $(dist_libdir) + +ifdef MKSHLIB + $(INSTALL) -m 444 $(LIBLDIF) $(dist_libdir) + $(INSTALL) -m 444 $(DLLLDIF) $(dist_libdir) + $(INSTALL) -m 444 $(DLLLDIF) $(dist_bindir) +endif
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libldif/line64.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libldif/line64.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libprldap/Makefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libprldap/Makefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libprldap/Makefile.in
Added
@@ -0,0 +1,250 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is Mozilla Communicator client code, released +# March 31, 1998. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-1999 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +MOD_DEPTH = ../../.. +srcdir = @srcdir@ +topsrcdir = @top_srcdir@ +NSPR_LIBS = @NSPR_LIBS@ +NSPR_CFLAGS = @NSPR_CFLAGS@ + +include $(MOD_DEPTH)/config/autoconf.mk +include $(topsrcdir)/build.mk + +SRCS = ldappr-dns.c \ + ldappr-error.c \ + ldappr-io.c \ + ldappr-public.c \ + ldappr-threads.c + +REALOBJS = $(SRCS:.c=.$(OBJ_SUFFIX)) +OBJS = $(addprefix $(OBJDIR_NAME)/, $(REALOBJS)) + +DISTHDIR = $(DIST)/public/ldap +HDIR = $(topsrcdir)/ldap/include + +ifneq (,$(filter OS2 WINNT,$(OS_ARCH))) +LIBPRLDAP = $(addprefix $(OBJDIR_NAME)/, \ + $(LIB_PREFIX)$(PRLDAP_LIBNAME).$(LIB_SUFFIX)) +else +LIBPRLDAP = +endif +DLLPRLDAP = $(addprefix $(OBJDIR_NAME)/, \ + $(LIB_PREFIX)$(PRLDAP_LIBNAME).$(DLL_SUFFIX)) + +INSTALLDIR = $(DIST)/$(OBJDIR_NAME) + +RELEASE_LIBS = $(DLLPRLDAP) + +include $(topsrcdir)/config/rules.mk + +GARBAGE += $(LIBPRLDAP) $(DLLPRLDAP) + +LOCAL_INCLUDES = +INCLUDES += -I$(DISTHDIR) -I$(HDIR) -I$(INSTALLDIR)/include \ + $(NSPR_CFLAGS) +DEFINES += $(DEFS) + +PLATFORMCFLAGS = -DUSE_WAITPID -DNEEDPROTOS +PLATFORMLIBS = +THREADS = +THREADSLIB = + +# +# shared library symbol export definitions +# +ifeq ($(USE_DLL_EXPORTS_FILE), 1) +ifeq ($(OS_ARCH), WINNT) +GENEXPORTS=cmd /c $(PERL) $(topsrcdir)/ldap/build/genexports.pl +else +GENEXPORTS=$(PERL) $(topsrcdir)/ldap/build/genexports.pl +endif + +# variable definitions for exported symbols +ifeq ($(OS_ARCH), WINNT) + PRLDAP_EXPORT_DEFS= $(WIN_TOP_SRC)/ldap/libraries/msdos/winsock/nsldappr32.def +else +ifeq ($(OS_ARCH), OS2) + PRLDAP_EXPORT_DEFS= $(OBJDIR_NAME)/libprldap.def +else + PRLDAP_EXPORT_DEFS= $(OBJDIR_NAME)/libprldap.exp +endif +GARBAGE += $(LDAP_EXPORT_DEFS) +endif + +PRLDAP_EXPORT_FLAGS=$(addprefix $(DLLEXPORTS_PREFIX), $(PRLDAP_EXPORT_DEFS)) + +GENEXPARGS=$(BUILD_DEBUG) $(PRLDAPVERS_SUFFIX) $(PRLDAPVERS) +endif # USE_DLL_EXPORTS_FILE + +ifeq ($(OS_ARCH), WINNT) +ifdef NS_USE_GCC +EXTRA_DLL_LIBS =-L$(dist_libdir) -l$(LDAP_LIBNAME) \ + $(NSPRLINK) +else +EXTRA_LIBS =wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib \ + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \ + rpcrt4.lib uuid.lib winmm.lib +EXTRA_LIBS += $(dist_libdir)/$(LDAP_LIBNAME).lib +EXTRA_LIBS += $(NSPRLINK) +endif +CUSTOM_LIBS=1 +endif + +ifeq ($(OS_ARCH),OS2) +EXTRA_LIBS = $(dist_libdir)/$(LDAP_LIBNAME).lib +EXTRA_LIBS += $(dist_libdir)/$(LBER_LIBNAME).lib +EXTRA_LIBS += $(NSPRLINK) +EXTRA_LIBS += $(OS_LIBS) +CUSTOM_LIBS=1 +endif + +ifeq ($(OS_ARCH), OSF1) +EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) +EXTRA_LIBS += $(NSPRLINK) +EXTRA_LIBS += -lcxx -lpthread -lrt -lmach -lexc +CUSTOM_LIBS=1 +endif + +ifeq ($(OS_ARCH), AIX) +EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) +EXTRA_LIBS += $(NSPRLINK) +EXTRA_LIBS += -ldl -brtl -lpthreads -lc_r -lm +CUSTOM_LIBS=1 +endif + +# no extra libs on HP-UX +ifeq ($(OS_ARCH), HP-UX) +CUSTOM_LIBS=1 +endif + +# if you need to do something extra for extra_libs or extra_dll_libs for a +# specific platform, do them above according the other ones for WINNT, OS2, etc. +# then define CUSTOM_LIBS=1 - if you just want the standard ones as defined +# below, you don't have to do anything +ifndef CUSTOM_LIBS +EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) +EXTRA_LIBS += $(NSPRLINK) +endif + +OBJDEST = $(OBJDIR_NAME) + +########################################################################### + +ifeq ($(USE_DLL_EXPORTS_FILE), 1) +# recursive gmake rule to create exported symbols file +$(PRLDAP_EXPORT_DEFS):: $(srcdir)/libprldap.ex +ifeq ($(OS_ARCH), WINNT) + $(GENEXPORTS) Win32 $(srcdir)/../msdos/winsock/nsldappr32.tdf $< $(GENEXPARGS) > $@ +else +ifeq ($(OS_ARCH), OS2) + echo LIBRARY $(PRLDAP_LIBNAME) INITINSTANCE TERMINSTANCE > $@ + echo PROTMODE >> $@ + echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@ + echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@ + echo EXPORTS >> $@ + $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) >> $@ +else + $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) > $@ +endif +endif +endif # USE_DLL_EXPORTS_FILE + +versiont.c: Makefile.client Version.c + @$(RM) $@ + @(u="$${USER-root}" v="$(shell cat ../../build/version)" d="$(shell pwd)" \ + h="$(shell hostname)" t="$(shell date)"; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < Version.c > $@) + +export:: $(OBJDEST) $(LIBDIR) $(OBJS) $(DLLPRLDAP) + +$(LIBDIR): + $(MKDIR) $(LIBDIR) + +$(LIBPRLDAP): $(OBJS) $(LIBDIR) $(PRLDAP_EXPORT_DEFS) + @echo ======= making $(LIBPRLDAP) +ifdef SO_FILES_TO_REMOVE + -$(RM) $(SO_FILES_TO_REMOVE) +endif +ifeq ($(OS_ARCH),OS2) +# create import library for OS/2 + rm -f $@ + $(IMPLIB) $@ $(PRLDAP_EXPORT_DEFS) +else + $(LINK_LIB) $(EXTRA_LIBS) +endif + +$(DLLPRLDAP): $(OBJS) $(LIBDIR) $(PRLDAP_EXPORT_DEFS) + @echo ======= making $(DLLPRLDAP) +ifdef SO_FILES_TO_REMOVE + -$(RM) $(SO_FILES_TO_REMOVE) +endif + $(LINK_DLL) $(PRLDAP_EXPORT_FLAGS) $(EXTRA_LIBS) + +veryclean:: clean + +$(OBJDEST): + $(MKDIR) $(OBJDEST) + +# the $(dist_bindir) line is for the mozilla client, which for reasons +# unknown wants shared libraries in /bin also +# +# Set the default sources for the export target +EXPDEPS2 = $(LIBPRLDAP) $(DLLPRLDAP) +# Remove the LIB source if on win32 and using MSVC +# This avoids problems with -jX builds where 'link' will make both the +# .dll and .lib files in one pass +ifeq ($(OS_ARCH), WINNT) +ifeq ($(LD),link) +EXPDEPS2 = $(DLLPRLDAP) +endif +endif + +export:: $(EXPDEPS2) +ifeq ($(OS_ARCH), WINNT) + $(INSTALL) -m 555 $(LIBPRLDAP) $(dist_libdir) + $(INSTALL) -m 555 $(DLLPRLDAP) $(dist_libdir) +endif +ifeq ($(OS_ARCH),OS2) + $(INSTALL) -m 444 $(LIBPRLDAP) $(dist_libdir) +endif +ifdef MKSHLIB + $(INSTALL) -m 555 $(DLLPRLDAP) $(dist_libdir) + $(INSTALL) -m 444 $(DLLPRLDAP) $(dist_bindir) +endif
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libprldap/ldappr-dns.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libprldap/ldappr-dns.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libprldap/ldappr-error.c
Added
@@ -0,0 +1,335 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Utilities for manageing the relationship between NSPR errors and + * OS (errno-style) errors. + * + * The overall strategy used is to map NSPR errors into OS errors. + */ + +#include "ldappr-int.h" + +void +prldap_set_system_errno( int oserrno ) +{ + PR_SetError( PR_GetError(), oserrno ); +} + + +int +prldap_get_system_errno( void ) +{ + return( PR_GetOSError()); +} + +/* + * Retrieve the NSPR error number, convert to a system error code, and return + * the result. + */ +struct prldap_errormap_entry { + PRInt32 erm_nspr; /* NSPR error code */ + int erm_system; /* corresponding system error code */ +}; + +/* XXX: not sure if this extra mapping for Windows is good or correct */ +#ifdef _WINDOWS +#ifndef ENOTSUP +#define ENOTSUP -1 +#endif +#ifndef ETIMEDOUT +#define ETIMEDOUT WSAETIMEDOUT +#endif +#ifndef EADDRNOTAVAIL +#define EADDRNOTAVAIL WSAEADDRNOTAVAIL +#endif +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#endif +#ifndef EISCONN +#define EISCONN WSAEISCONN +#endif +#ifndef EADDRINUSE +#define EADDRINUSE WSAEADDRINUSE +#endif +#ifndef ECONNREFUSED +#define ECONNREFUSED WSAECONNREFUSED +#endif +#ifndef EHOSTUNREACH +#define EHOSTUNREACH WSAEHOSTUNREACH +#endif +#ifndef ENOTCONN +#define ENOTCONN WSAENOTCONN +#endif +#ifndef ENOTSOCK +#define ENOTSOCK WSAENOTSOCK +#endif +#ifndef EPROTOTYPE +#define EPROTOTYPE WSAEPROTOTYPE +#endif +#ifndef EOPNOTSUPP +#define EOPNOTSUPP WSAEOPNOTSUPP +#endif +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#endif +#ifndef EOVERFLOW +#define EOVERFLOW -1 +#endif +#ifndef ECONNRESET +#define ECONNRESET WSAECONNRESET +#endif +#ifndef ELOOP +#define ELOOP WSAELOOP +#endif +#ifndef ENOTBLK +#define ENOTBLK -1 +#endif +#ifndef ETXTBSY +#define ETXTBSY -1 +#endif +#ifndef ENETDOWN +#define ENETDOWN WSAENETDOWN +#endif +#ifndef ESHUTDOWN +#define ESHUTDOWN WSAESHUTDOWN +#endif +#ifndef ECONNABORTED +#define ECONNABORTED WSAECONNABORTED +#endif +#endif /* _WINDOWS */ + +#if defined(macintosh) +/* + * Some Unix error defs. Under CW 7, we can't define OTUNIXERRORS because + * it generates many conflicts with errno.h. Define what we need here. + * These need to be in sync with OpenTransport.h + */ +#define EWOULDBLOCK 35 +#define ENOTSOCK 38 +#define EPROTOTYPE 41 +#define EPROTONOSUPPORT 43 +#define EOPNOTSUPP 45 +#define EADDRINUSE 48 +#define EADDRNOTAVAIL 49 +#define ENETDOWN 50 +#define ECONNABORTED 53 +#define ECONNRESET 54 +#define EISCONN 56 +#define ENOTCONN 57 +#define ESHUTDOWN 58 +#define ETIMEDOUT 60 +#define ECONNREFUSED 61 +#define EHOSTUNREACH 65 +#define EAFNOSUPPORT -1 +#define ELOOP -1 +#define ENOTBLK -1 +#define ENOTSUP -1 +#define EOVERFLOW -1 +#define ETXTBSY -1 +#endif /* macintosh */ + +#ifdef XP_OS2 +#define SOCBASEERR 0 +#endif +#ifndef ENOTSUP +#define ENOTSUP -1 +#endif +#ifndef EOVERFLOW +#define EOVERFLOW -1 +#endif +#ifndef EDEADLOCK +#define EDEADLOCK -1 +#endif +#ifndef EFAULT +#define EFAULT SOCEFAULT +#endif +#ifndef EPIPE +#define EPIPE SOCEPIPE +#endif +#ifndef EIO +#define EIO (SOCBASEERR+5) +#endif +#ifndef EDEADLK +#define EDEADLK (SOCBASEERR+11) +#endif +#ifndef ENOTBLK +#define ENOTBLK (SOCBASEERR+15) +#endif +#ifndef EBUSY +#define EBUSY (SOCBASEERR+16) +#endif +#ifndef ENOTDIR +#define ENOTDIR (SOCBASEERR+20) +#endif +#ifndef EISDIR +#define EISDIR (SOCBASEERR+21) +#endif +#ifndef ENFILE +#define ENFILE (SOCBASEERR+23) +#endif +#ifndef ETXTBSY +#define ETXTBSY (SOCBASEERR+26) +#endif +#ifndef EFBIG +#define EFBIG (SOCBASEERR+27) +#endif +#ifndef ESPIPE +#define ESPIPE (SOCBASEERR+29) +#endif +#ifndef EROFS +#define EROFS (SOCBASEERR+30) +#endif + +#ifdef BEOS +#define ENOTSUP -1 +#define ENOTBLK -1 +#define ETXTBSY -1 +#endif + +#if defined(BSDI) || defined(OPENBSD) || defined (NETBSD) +#define ENOTSUP -1 +#endif + +#if defined(OSF1) || defined(BSDI) || defined(VMS) || defined(OPENBSD) +#define EOVERFLOW -1 +#endif + +#if defined(__hpux) || defined(_AIX) || defined(OSF1) || defined(DARWIN) || \ + defined(BEOS) || defined(FREEBSD) || defined(BSDI) || defined(VMS) || \ + defined(OPENBSD) || defined(NETBSD) +#define EDEADLOCK -1 +#endif + +/* XXX: need to verify that the -1 entries are correct (no mapping) */ +static struct prldap_errormap_entry prldap_errormap[] = { + { PR_OUT_OF_MEMORY_ERROR, ENOMEM }, + { PR_BAD_DESCRIPTOR_ERROR, EBADF }, + { PR_WOULD_BLOCK_ERROR, EAGAIN }, + { PR_ACCESS_FAULT_ERROR, EFAULT }, + { PR_INVALID_METHOD_ERROR, EINVAL }, /* XXX: correct mapping ? */ + { PR_ILLEGAL_ACCESS_ERROR, EACCES }, /* XXX: correct mapping ? */ + { PR_UNKNOWN_ERROR, -1 }, + { PR_PENDING_INTERRUPT_ERROR, -1 }, + { PR_NOT_IMPLEMENTED_ERROR, ENOTSUP }, + { PR_IO_ERROR, EIO }, + { PR_IO_TIMEOUT_ERROR, ETIMEDOUT }, /* XXX: correct mapping ? */ + { PR_IO_PENDING_ERROR, -1 }, + { PR_DIRECTORY_OPEN_ERROR, ENOTDIR }, + { PR_INVALID_ARGUMENT_ERROR, EINVAL }, + { PR_ADDRESS_NOT_AVAILABLE_ERROR, EADDRNOTAVAIL }, + { PR_ADDRESS_NOT_SUPPORTED_ERROR, EAFNOSUPPORT }, + { PR_IS_CONNECTED_ERROR, EISCONN }, + { PR_BAD_ADDRESS_ERROR, EFAULT }, /* XXX: correct mapping ? */ + { PR_ADDRESS_IN_USE_ERROR, EADDRINUSE }, + { PR_CONNECT_REFUSED_ERROR, ECONNREFUSED }, + { PR_NETWORK_UNREACHABLE_ERROR, EHOSTUNREACH }, + { PR_CONNECT_TIMEOUT_ERROR, ETIMEDOUT }, + { PR_NOT_CONNECTED_ERROR, ENOTCONN }, + { PR_LOAD_LIBRARY_ERROR, -1 }, + { PR_UNLOAD_LIBRARY_ERROR, -1 }, + { PR_FIND_SYMBOL_ERROR, -1 }, + { PR_INSUFFICIENT_RESOURCES_ERROR, -1 }, + { PR_DIRECTORY_LOOKUP_ERROR, EHOSTUNREACH },/* an approximation */ + { PR_TPD_RANGE_ERROR, -1 }, + { PR_PROC_DESC_TABLE_FULL_ERROR, -1 }, + { PR_SYS_DESC_TABLE_FULL_ERROR, -1 }, + { PR_NOT_SOCKET_ERROR, ENOTSOCK }, + { PR_NOT_TCP_SOCKET_ERROR, EPROTOTYPE }, + { PR_SOCKET_ADDRESS_IS_BOUND_ERROR, -1 }, + { PR_NO_ACCESS_RIGHTS_ERROR, EACCES }, /* XXX: correct mapping ? */ + { PR_OPERATION_NOT_SUPPORTED_ERROR, EOPNOTSUPP }, + { PR_PROTOCOL_NOT_SUPPORTED_ERROR, EPROTONOSUPPORT }, + { PR_REMOTE_FILE_ERROR, -1 }, + { PR_BUFFER_OVERFLOW_ERROR, EOVERFLOW }, + { PR_CONNECT_RESET_ERROR, ECONNRESET }, + { PR_RANGE_ERROR, ERANGE }, + { PR_DEADLOCK_ERROR, EDEADLK }, + { PR_FILE_IS_LOCKED_ERROR, EDEADLOCK }, /* XXX: correct mapping ? */ + { PR_FILE_TOO_BIG_ERROR, EFBIG }, + { PR_NO_DEVICE_SPACE_ERROR, ENOSPC }, + { PR_PIPE_ERROR, EPIPE }, + { PR_NO_SEEK_DEVICE_ERROR, ESPIPE }, + { PR_IS_DIRECTORY_ERROR, EISDIR }, + { PR_LOOP_ERROR, ELOOP }, + { PR_NAME_TOO_LONG_ERROR, ENAMETOOLONG }, + { PR_FILE_NOT_FOUND_ERROR, ENOENT }, + { PR_NOT_DIRECTORY_ERROR, ENOTDIR }, + { PR_READ_ONLY_FILESYSTEM_ERROR, EROFS }, + { PR_DIRECTORY_NOT_EMPTY_ERROR, ENOTEMPTY }, + { PR_FILESYSTEM_MOUNTED_ERROR, EBUSY }, + { PR_NOT_SAME_DEVICE_ERROR, EXDEV }, + { PR_DIRECTORY_CORRUPTED_ERROR, -1 }, + { PR_FILE_EXISTS_ERROR, EEXIST }, + { PR_MAX_DIRECTORY_ENTRIES_ERROR, -1 }, + { PR_INVALID_DEVICE_STATE_ERROR, ENOTBLK }, /* XXX: correct mapping ? */ + { PR_DEVICE_IS_LOCKED_ERROR, -2 }, + { PR_NO_MORE_FILES_ERROR, ENFILE }, + { PR_END_OF_FILE_ERROR, -1 }, + { PR_FILE_SEEK_ERROR, ESPIPE }, /* XXX: correct mapping ? */ + { PR_FILE_IS_BUSY_ERROR, ETXTBSY }, + { PR_OPERATION_ABORTED_ERROR, -1 }, + { PR_IN_PROGRESS_ERROR, -1 }, + { PR_ALREADY_INITIATED_ERROR, -1 }, + { PR_GROUP_EMPTY_ERROR, -1 }, + { PR_INVALID_STATE_ERROR, -1 }, + { PR_NETWORK_DOWN_ERROR, ENETDOWN }, + { PR_SOCKET_SHUTDOWN_ERROR, ESHUTDOWN }, + { PR_CONNECT_ABORTED_ERROR, ECONNABORTED }, + { PR_HOST_UNREACHABLE_ERROR, EHOSTUNREACH }, + { PR_MAX_ERROR, -1 }, +}; + + +int +prldap_prerr2errno( void ) +{ + int oserr, i; + PRInt32 nsprerr; + + nsprerr = PR_GetError(); + + oserr = -1; /* unknown */ + for ( i = 0; prldap_errormap[i].erm_nspr != PR_MAX_ERROR; ++i ) { + if ( prldap_errormap[i].erm_nspr == nsprerr ) { + oserr = prldap_errormap[i].erm_system; + break; + } + } + + return( oserr ); +}
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libprldap/ldappr-int.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libprldap/ldappr-int.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libprldap/ldappr-io.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libprldap/ldappr-io.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libprldap/ldappr-public.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libprldap/ldappr-public.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libprldap/ldappr-threads.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libprldap/ldappr-threads.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libprldap/libprldap.ex
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libprldap/libprldap.ex)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libssldap/Makefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libssldap/Makefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libssldap/Makefile.in
Added
@@ -0,0 +1,243 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is Mozilla Communicator client code, released +# March 31, 1998. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998-1999 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +MOD_DEPTH = ../../.. +srcdir = @srcdir@ +topsrcdir = @top_srcdir@ +NSPR_LIBS = @NSPR_LIBS@ +NSPR_CFLAGS = @NSPR_CFLAGS@ +NSS_LIBS = @NSS_LIBS@ +NSS_CFLAGS = @NSS_CFLAGS@ + +include $(MOD_DEPTH)/config/autoconf.mk +include $(topsrcdir)/build.mk + +SRCS = clientinit.c \ + ldapsinit.c \ + errormap.c + +REALOBJS = $(SRCS:.c=.$(OBJ_SUFFIX)) + +SSLOBJDEST = $(OBJDIR_NAME) +OBJS = $(addprefix $(SSLOBJDEST)/, $(REALOBJS)) + +DISTHDIR = $(DIST)/public/ldap +HDIR = $(topsrcdir)/ldap/include + +LIBSSLDAP = $(addprefix $(SSLOBJDEST)/, $(LIB_PREFIX)$(SSLDAP_LIBNAME).$(LIB_SUFFIX)) +DLLSSLDAP = $(addprefix $(SSLOBJDEST)/, $(LIB_PREFIX)$(SSLDAP_LIBNAME).$(DLL_SUFFIX)) + +INSTALLDIR = $(DIST)/$(OBJDIR_NAME) + +RELEASE_LIBS = $(DLLSSLDAP) + +include $(topsrcdir)/config/rules.mk + +GARBAGE += $(LIBSSLDAP) $(DLLSSLDAP) + +LOCAL_INCLUDES = -I$(PUBLIC)/nspr +INCLUDES += -I$(DISTHDIR) -I$(HDIR) -I$(INSTALLDIR)/include \ + -I$(DIST)/include \ + $(NSS_CFLAGS) \ + $(NSPR_CFLAGS) + +DEFINES += $(DEFS) + +PLATFORMCFLAGS = -DUSE_WAITPID -DNEEDPROTOS +PLATFORMLIBS = +THREADS = +THREADSLIB = + +# +# shared library symbol export definitions +# +ifeq ($(USE_DLL_EXPORTS_FILE), 1) +ifeq ($(OS_ARCH), WINNT) +GENEXPORTS=cmd /c $(PERL) $(topsrcdir)/ldap/build/genexports.pl +else +GENEXPORTS=$(PERL) $(topsrcdir)/ldap/build/genexports.pl +endif + +# variable definitions for exported symbols +ifeq ($(OS_ARCH), WINNT) + SSLDAP_EXPORT_DEFS= $(WIN_TOP_SRC)/ldap/libraries/msdos/winsock/nsldapssl32.def +else + SSLDAP_EXPORT_DEFS= $(SSLOBJDEST)/libldap_ssl.exp +endif + +SSLDAP_EXPORT_FLAGS=$(addprefix $(DLLEXPORTS_PREFIX), $(SSLDAP_EXPORT_DEFS)) + +GENEXPARGS=$(BUILD_DEBUG) $(SSLDAPVERS_SUFFIX) $(SSLDAPVERS) +endif # USE_DLL_EXPORTS_FILE + +ifeq ($(OS_ARCH), SunOS) +EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) +# NSPR, NSS, etc. other mozilla components do not put their shared libs +# in dist_libdir but rather in $(DIST)/$(RELEASE_OBJDIR_NAME)/lib +EXTRA_LIBS += $(NSPRLINK) +endif + +ifeq ($(OS_ARCH), WINNT) +ifdef NS_USE_GCC +EXTRA_DLL_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -l$(PRLDAP_LIBNAME) \ + $(NSSLINK) $(NSPRLINK) +else +EXTRA_LIBS =wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib \ + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \ + rpcrt4.lib uuid.lib winmm.lib +EXTRA_LIBS += $(dist_libdir)/$(LDAP_LIBNAME).lib +EXTRA_LIBS += $(dist_libdir)/$(PRLDAP_LIBNAME).lib +EXTRA_LIBS += $(NSSLINK) +EXTRA_LIBS += $(NSPRLINK) +endif +CUSTOM_LIBS=1 +endif + +ifeq ($(OS_ARCH),OS2) +EXTRA_LIBS = $(OS_LIBS) +EXTRA_LIBS += $(dist_libdir)/$(LDAP_LIBNAME).lib +EXTRA_LIBS += $(dist_libdir)/$(PRLDAP_LIBNAME).lib +EXTRA_LIBS += $(NSSLINK) +EXTRA_LIBS += $(NSPRLINK) +CUSTOM_LIBS=1 +endif + +ifeq ($(OS_ARCH), OSF1) +EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) +EXTRA_LIBS += $(NSPRLINK) +EXTRA_LIBS += -lcxx -lpthread -lrt -lmach -lexc +CUSTOM_LIBS=1 +endif + +ifeq ($(OS_ARCH), AIX) +EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) +EXTRA_LIBS += $(NSPRLINK) +EXTRA_LIBS += $(NSSLINK) -l $(PRLDAP_LIBNAME) +EXTRA_LIBS += -ldl -brtl -lpthreads -lc_r -lm +CUSTOM_LIBS=1 +endif + +ifeq ($(OS_ARCH), IRIX) +EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) +EXTRA_LIBS += $(NSPRLINK) +EXTRA_LIBS += $(NSSLINK) -l $(PRLDAP_LIBNAME) +EXTRA_LIBS += $(OS_LIBS) -lc +CUSTOM_LIBS=1 +endif + +ifeq ($(OS_ARCH), Darwin) +EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -l$(PRLDAP_LIBNAME) +EXTRA_LIBS += $(NSSLINK) +EXTRA_LIBS += $(NSPRLINK) +EXTRA_LIBS += $(OS_LIBS) +CUSTOM_LIBS=1 +endif + +ifeq ($(OS_ARCH), BeOS) +EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -l$(PRLDAP_LIBNAME) +EXTRA_LIBS += $(NSSLINK) +EXTRA_LIBS += $(NSPRLINK) +EXTRA_LIBS += $(OS_LIBS) +CUSTOM_LIBS=1 +endif + +ifeq ($(OS_ARCH), HP-UX) +CUSTOM_LIBS=1 +endif + +ifndef CUSTOM_LIBS +EXTRA_LIBS = -L$(dist_libdir) -l$(LDAP_LIBNAME) -l$(PRLDAP_LIBNAME) +EXTRA_LIBS += $(NSSLINK) +EXTRA_LIBS += $(NSPRLINK) +endif + +OBJDEST = $(OBJDIR_NAME) + +########################################################################### + +ifeq ($(USE_DLL_EXPORTS_FILE), 1) +# recursive gmake rule to create exported symbols file +$(SSLDAP_EXPORT_DEFS):: ../libldap_ssl.ex +ifeq ($(OS_ARCH), WINNT) + $(GENEXPORTS) Win32 $(srcdir)/../msdos/winsock/nsldapssl32.tdf $< $(GENEXPARGS) > $@ +else + $(GENEXPORTS) $(OS_ARCH) Standard $< $(GENEXPARGS) > $@ +endif +endif # USE_DLL_EXPORTS_FILE + +versiont.c: Makefile.client Version.c + @$(RM) $@ + @(u="$${USER-root}" v="$(shell cat ../../build/version)" d="$(shell pwd)" \ + h="$(shell hostname)" t="$(shell date)"; $(SED) -e "s|%WHEN%|$${t}|" \ + -e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \ + -e "s|%VERSION%|$${v}|" \ + < Version.c > $@) + +export:: $(OBJDEST) $(LIBDIR) $(OBJS) $(DLLSSLDAP) + +$(LIBDIR): + $(MKDIR) $(LIBDIR) + +$(LIBSSLDAP): $(OBJS) $(LIBDIR) $(SSLDAP_EXPORT_DEFS) + @echo ======= making $(LIBSSLDAP) + ifdef SO_FILES_TO_REMOVE + -$(RM) $(SO_FILES_TO_REMOVE) + endif + $(LINK_LIB) $(EXTRA_LIBS) + +$(DLLSSLDAP): $(OBJS) $(LIBDIR) $(SSLDAP_EXPORT_DEFS) + @echo ======= making $(DLLSSLDAP) +ifdef SO_FILES_TO_REMOVE + -$(RM) $(SO_FILES_TO_REMOVE) +endif + $(LINK_DLL) $(SSLDAP_EXPORT_FLAGS) $(EXTRA_LIBS) + +veryclean:: clean + +$(OBJDEST): + $(MKDIR) $(OBJDEST) + +export:: $(DLLSSLDAP) +ifeq ($(OS_ARCH), WINNT) + $(INSTALL) -m 555 $(LIBSSLDAP) $(dist_libdir) + $(INSTALL) -m 555 $(DLLSSLDAP) $(dist_libdir) +endif +ifdef MKSHLIB + $(INSTALL) -m 555 $(DLLSSLDAP) $(dist_libdir) + $(INSTALL) -m 444 $(DLLSSLDAP) $(dist_bindir) +endif
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libssldap/clientinit.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libssldap/clientinit.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libssldap/errormap.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libssldap/errormap.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libssldap/ldapsinit.c
Added
@@ -0,0 +1,1580 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Sun Microsystems + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * ldapsinit.c + */ + +#if defined(NET_SSL) + +#if defined( _WINDOWS ) +#include <windows.h> +#endif + +/* XXX:mhein The following is a workaround for the redefinition of */ +/* const problem on OSF. Fix to be provided by NSS */ +/* This is a pretty benign workaround for us which */ +/* should not cause problems in the future even if */ +/* we forget to take it out :-) */ + +#ifdef OSF1V4D +#ifndef __STDC__ +# define __STDC__ +#endif /* __STDC__ */ +#endif /* OSF1V4D */ + +#include <errno.h> +#include <nspr.h> +#include <cert.h> +#include <key.h> +#include <ssl.h> +#include <sslproto.h> +#include <sslerr.h> +#include <prnetdb.h> + +#include <ldap.h> +#include <ldap_ssl.h> +#include <ldappr.h> +#include <pk11func.h> + +/* + * Macro that determines how many SSL options we support. As of June, 2002 + * NSS supports 14 options numbered 1-14 (see nss/ssl.h). We allow some + * room for expansion. + */ +#define LDAPSSL_MAX_SSL_OPTION 20 + +/* + * Data structure to hold the standard NSPR I/O function pointers set by + * libprldap. We save them in our session data structure so we can call + * them from our own I/O functions (we add functionality to support SSL + * while using libprldap's functions as much as possible). + */ +typedef struct ldapssl_std_functions { + LDAP_X_EXTIOF_CLOSE_CALLBACK *lssf_close_fn; + LDAP_X_EXTIOF_CONNECT_CALLBACK *lssf_connect_fn; + LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK *lssf_disposehdl_fn; +} LDAPSSLStdFunctions; + + + +/* + * LDAP session data structure. + */ +typedef struct ldapssl_session_info { + int lssei_using_pcks_fns; + int lssei_ssl_strength; + PRBool lssei_ssl_ready; + PRBool lssei_tls_init; /* indicates startTLS success */ + PRBool lssei_client_auth; + PRBool lssei_ssl_option_value[LDAPSSL_MAX_SSL_OPTION+1]; + PRBool lssei_ssl_option_isset[LDAPSSL_MAX_SSL_OPTION+1]; + char *lssei_certnickname; + char *lssei_keypasswd; /* if NULL, assume pre-auth. */ + LDAPSSLStdFunctions lssei_std_functions; + CERTCertDBHandle *lssei_certdbh; +} LDAPSSLSessionInfo; + + +/* + * LDAP socket data structure. + */ +typedef struct ldapssl_socket_info { + LDAPSSLSessionInfo *soi_sessioninfo; /* session info */ +} LDAPSSLSocketInfo; + + +/* + * XXXceb This is a hack until the new IO functions are done. + * this function MUST be called before ldapssl_enable_clientauth. + * right now, this function is called in ldapssl_pkcs_init(); + */ + +static int using_pkcs_functions = 0; + + +void set_using_pkcs_functions( int val ) +{ + using_pkcs_functions = val; +} + + +/* + * Utility functions: + */ +static int set_ssl_options( PRFileDesc *sslfd, PRBool *optval, + PRBool *optisset ); +static void ldapssl_free_session_info( LDAPSSLSessionInfo **ssipp ); +static void ldapssl_free_socket_info( LDAPSSLSocketInfo **soipp ); +static char *ldapssl_libldap_compat_strdup(const char *s1); + + +/* + * SSL Stuff + */ + +static int ldapssl_AuthCertificate(void *sessionarg, PRFileDesc *fd, + PRBool checkSig, PRBool isServer); + +/* + * client auth stuff + */ +static SECStatus get_clientauth_data( void *sessionarg, PRFileDesc *prfd, + CERTDistNames *caNames, CERTCertificate **pRetCert, + SECKEYPrivateKey **pRetKey ); +static SECStatus get_keyandcert( LDAPSSLSessionInfo *ssip, + CERTCertificate **pRetCert, SECKEYPrivateKey **pRetKey, + char **errmsgp ); +static SECStatus check_clientauth_nicknames_and_passwd( LDAP *ld, + LDAPSSLSessionInfo *ssip ); +static char *get_keypassword( PK11SlotInfo *slot, PRBool retry, + void *sessionarg ); + +/* + * Static variables. + */ +/* SSL strength setting for new LDAPS sessions */ +static int default_ssl_strength = LDAPSSL_AUTH_CERT; + +/* + * Arrays to track global defaults for SSL options. These are used for + * new LDAPS sessions. For each option, we track both the option value + * and a Boolean that indicates whether the value has been set using + * the ldapssl_set_option() call. If an option has not been set, we + * don't make any NSS calls to set it; that way, the default NSS option + * values are used. Similar arrays are included in the LDAPSSLSessionInfo + * structure so options can be set on a per-LDAP session basis as well. + */ +static PRBool default_ssl_option_value[LDAPSSL_MAX_SSL_OPTION+1] = {0}; +static PRBool default_ssl_option_isset[LDAPSSL_MAX_SSL_OPTION+1] = {0}; + + +/* + * Like ldap_init(), except also install I/O routines from libsec so we + * can support SSL. If defsecure is non-zero, SSL is enabled for the + * default connection as well. + */ +LDAP * +LDAP_CALL +ldapssl_init( const char *defhost, int defport, int defsecure ) +{ + LDAP *ld; + + + if (0 ==defport) + defport = LDAPS_PORT; + + if (( ld = ldap_init( defhost, defport )) == NULL ) { + return( NULL ); + } + + if ( ldapssl_install_routines( ld ) < 0 || ldap_set_option( ld, + LDAP_OPT_SSL, defsecure ? LDAP_OPT_ON : LDAP_OPT_OFF ) != 0 ) { + PR_SetError( PR_GetError(), EINVAL ); /* XXXmcs: just a guess! */ + ldap_unbind( ld ); + return( NULL ); + } + + return( ld ); +} + + +static int +ldapssl_close(int s, struct lextiof_socket_private *socketarg) +{ + PRLDAPSocketInfo soi; + LDAPSSLSocketInfo *ssoip; + LDAPSSLSessionInfo *sseip; + + memset( &soi, 0, sizeof(soi)); + soi.soinfo_size = PRLDAP_SOCKETINFO_SIZE; + if ( prldap_get_socket_info( s, socketarg, &soi ) != LDAP_SUCCESS ) { + return( -1 ); + } + + ssoip = (LDAPSSLSocketInfo *)soi.soinfo_appdata; + sseip = ssoip->soi_sessioninfo; + + ldapssl_free_socket_info( (LDAPSSLSocketInfo **)&soi.soinfo_appdata ); + + return( (*(sseip->lssei_std_functions.lssf_close_fn))( s, socketarg )); +} + + +static int +ldapssl_connect(const char *hostlist, int defport, int timeout, + unsigned long options, struct lextiof_session_private *sessionarg, + struct lextiof_socket_private **socketargp ) +{ + int intfd = -1; + PRBool secure; + PRLDAPSessionInfo sei; + PRLDAPSocketInfo soi; + LDAPSSLSocketInfo *ssoip = NULL; + LDAPSSLSessionInfo *sseip; + PRFileDesc *sslfd = NULL; + + /* + * Determine if secure option is set. Also, clear secure bit in options + * the we pass to the standard connect() function (since it doesn't know + * how to handle the secure option). + */ + if ( 0 != ( options & LDAP_X_EXTIOF_OPT_SECURE )) { + secure = PR_TRUE; + options &= ~LDAP_X_EXTIOF_OPT_SECURE; + } else { + secure = PR_FALSE; + } + + /* + * Retrieve session info. so we can store a pointer to our session info. + * in our socket info. later. + */ + memset( &sei, 0, sizeof(sei)); + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + if ( prldap_get_session_info( NULL, sessionarg, &sei ) != LDAP_SUCCESS ) { + return( -1 ); + } + sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; + + /* + * Call the standard connect() callback to make the TCP connection. If it + * succeeds, *socketargp is set. + */ + intfd = (*(sseip->lssei_std_functions.lssf_connect_fn))( hostlist, defport, + timeout, options, sessionarg, socketargp ); + if ( intfd < 0 ) { + return( intfd ); + } + + /* + * Retrieve socket info. so we have the PRFileDesc. + */ + memset( &soi, 0, sizeof(soi)); + soi.soinfo_size = PRLDAP_SOCKETINFO_SIZE; + if ( prldap_get_socket_info( intfd, *socketargp, &soi ) != LDAP_SUCCESS ) { + goto close_socket_and_exit_with_error; + } + + /* + * Allocate a structure to hold our socket-specific data. + */ + if ( NULL == ( ssoip = PR_Calloc( 1, sizeof( LDAPSSLSocketInfo )))) { + goto close_socket_and_exit_with_error; + } + ssoip->soi_sessioninfo = sseip; + + /* + * Add SSL layer and enable SSL. + */ + if (( sslfd = SSL_ImportFD( NULL, soi.soinfo_prfd )) == NULL ) { + goto close_socket_and_exit_with_error; + } + + if ( SSL_OptionSet( sslfd, SSL_SECURITY, secure ) != SECSuccess || + SSL_OptionSet( sslfd, SSL_HANDSHAKE_AS_CLIENT, secure ) + != SECSuccess || ( secure && SSL_ResetHandshake( sslfd, + PR_FALSE ) != SECSuccess )) { + goto close_socket_and_exit_with_error; + } + + /* + * Set hostname which will be retrieved (depending on ssl strength) when + * using client or server auth. + */ + if ( SSL_SetURL( sslfd, hostlist ) != SECSuccess ) { + goto close_socket_and_exit_with_error; + } + + /* + * Set any SSL options that were modified by a previous call to + * the ldapssl_set_option() function. + */ + if ( set_ssl_options( sslfd, sseip->lssei_ssl_option_value, + sseip->lssei_ssl_option_isset ) < 0 ) { + goto close_socket_and_exit_with_error; + } + + /* + * If using client auth., arrange to use a separate SSL session cache + * for each distinct local client certificate nickname. + */ + if ( sseip->lssei_client_auth && + sseip->lssei_certnickname && sseip->lssei_certnickname[0] && + SSL_SetSockPeerID( sslfd, sseip->lssei_certnickname) != SECSuccess ) { + goto close_socket_and_exit_with_error; + } + + /* + * Let the standard NSPR to LDAP layer know about the new socket and + * our own socket-specific data. + */ + soi.soinfo_prfd = sslfd; + soi.soinfo_appdata = (void *)ssoip; + if ( prldap_set_socket_info( intfd, *socketargp, &soi ) != LDAP_SUCCESS ) { + goto close_socket_and_exit_with_error; + } + sslfd = NULL; /* so we don't close the socket twice upon error */ + + /* + * Install certificate hook function. + */ + SSL_AuthCertificateHook( soi.soinfo_prfd, + (SSLAuthCertificate)ldapssl_AuthCertificate, + (void *)sseip ); + + if ( SSL_GetClientAuthDataHook( soi.soinfo_prfd, + get_clientauth_data, sseip->lssei_client_auth ? sseip : NULL ) != 0 ) { + goto close_socket_and_exit_with_error; + } + + return( intfd ); /* success */ + +close_socket_and_exit_with_error: + if ( NULL != sslfd && sslfd != soi.soinfo_prfd ) { + PR_Close( sslfd ); + } + if ( NULL != ssoip ) { + ldapssl_free_socket_info( &ssoip ); + } + if ( intfd >= 0 && NULL != *socketargp ) { + (*(sseip->lssei_std_functions.lssf_close_fn))( intfd, *socketargp ); + } + return( -1 ); +} + + +static void +ldapssl_disposehandle(LDAP *ld, struct lextiof_session_private *sessionarg) +{ + PRLDAPSessionInfo sei; + LDAPSSLSessionInfo *sseip; + LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK *disposehdl_fn; + + memset( &sei, 0, sizeof( sei )); + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + if ( prldap_get_session_info( ld, NULL, &sei ) == LDAP_SUCCESS ) { + sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; + disposehdl_fn = sseip->lssei_std_functions.lssf_disposehdl_fn; + ldapssl_free_session_info( &sseip ); + (*disposehdl_fn)( ld, sessionarg ); + } +} + +static +LDAPSSLSessionInfo * +ldapssl_alloc_sessioninfo() +{ + LDAPSSLSessionInfo *ssip; + + /* + * Allocate our own session information. + */ + if ( NULL == ( ssip = (LDAPSSLSessionInfo *)PR_Calloc( 1, + sizeof( LDAPSSLSessionInfo )))) { + return( NULL ); + } + + /* + * Initialize session info. + * XXX: it would be nice to be able to set these on a per-session basis: + * lssei_using_pcks_fns + * lssei_certdbh + */ + ssip->lssei_ssl_strength = default_ssl_strength; + memcpy( ssip->lssei_ssl_option_value, default_ssl_option_value, + sizeof(ssip->lssei_ssl_option_value)); + memcpy( ssip->lssei_ssl_option_isset, default_ssl_option_isset, + sizeof(ssip->lssei_ssl_option_isset)); + ssip->lssei_using_pcks_fns = using_pkcs_functions; + ssip->lssei_certdbh = CERT_GetDefaultCertDB(); + ssip->lssei_ssl_ready = PR_TRUE; + + return( ssip ); +} + +/* + * Install I/O routines from libsec and NSPR into libldap to allow libldap + * to do SSL. + * + * We rely on libprldap to provide most of the functions, and then we override + * a few of them to support SSL. + */ +int +LDAP_CALL +ldapssl_install_routines( LDAP *ld ) +{ + struct ldap_x_ext_io_fns iofns; + LDAPSSLSessionInfo *ssip; + PRLDAPSessionInfo sei; + + /* install standard NSPR functions */ + if ( prldap_install_routines( + ld, + 1 /* shared -- we have to assume it is */ ) + != LDAP_SUCCESS ) { + return( -1 ); + } + + /* + * Allocate session information. + */ + if ( (ssip = ldapssl_alloc_sessioninfo()) == NULL ) + { + ldap_set_lderrno( ld, LDAP_NO_MEMORY, NULL, NULL ); + return( -1 ); + } + + /* + * override a few functions, saving a pointer to the standard function + * in each case so we can call it from our SSL savvy functions. + */ + memset( &iofns, 0, sizeof(iofns)); + iofns.lextiof_size = LDAP_X_EXTIO_FNS_SIZE; + if ( ldap_get_option( ld, LDAP_X_OPT_EXTIO_FN_PTRS, (void *)&iofns ) < 0 ) { + ldapssl_free_session_info( &ssip ); + return( -1 ); + } + + /* override socket, connect, and disposehandle */ + ssip->lssei_std_functions.lssf_connect_fn = iofns.lextiof_connect; + iofns.lextiof_connect = ldapssl_connect; + ssip->lssei_std_functions.lssf_close_fn = iofns.lextiof_close; + iofns.lextiof_close = ldapssl_close; + ssip->lssei_std_functions.lssf_disposehdl_fn = iofns.lextiof_disposehandle; + iofns.lextiof_disposehandle = ldapssl_disposehandle; + + if ( ldap_set_option( ld, LDAP_X_OPT_EXTIO_FN_PTRS, (void *)&iofns ) < 0 ) { + ldapssl_free_session_info( &ssip ); + return( -1 ); + } + + /* + * Store session info. for later retrieval. + */ + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + sei.seinfo_appdata = (void *)ssip; + if ( prldap_set_session_info( ld, NULL, &sei ) != LDAP_SUCCESS ) { + ldapssl_free_session_info( &ssip ); + return( -1 ); + } + + return( 0 ); +} + +/* Sets up SSL for the NSPR layered connection (or plain Text connection + * with startTLS extended I/O request already acknowledged by the server) + * Call this function after the call to ldaptls_setup() + * + * Returns an LDAP API result code (LDAP_SUCCESS if all goes well). + */ +static int +ldaptls_complete(LDAP *ld) +{ + PRBool secure = 1; + PRLDAPSessionInfo sei; + PRLDAPSocketInfo soi; + LDAPSSLSocketInfo *ssoip = NULL; + LDAPSSLSessionInfo *sseip = NULL; + PRFileDesc *sslfd = NULL; + LBER_SOCKET intfd = -1; + int rc = LDAP_LOCAL_ERROR; + char *hostlist = NULL; + struct lextiof_socket_private *socketargp = NULL; + + /* + * Get hostlist from LDAP Handle + */ + if ( ldap_get_option(ld, LDAP_OPT_HOST_NAME, &hostlist) < 0 ) { + rc = ldap_get_lderrno( ld, NULL, NULL ); + goto close_socket_and_exit_with_error; + } + + /* + * Get File Desc from current connection + */ + if ( ldap_get_option(ld, LDAP_OPT_DESC, &intfd) < 0 ) { + rc = ldap_get_lderrno( ld, NULL, NULL ); + goto close_socket_and_exit_with_error; + } + + + /* + * Get Socket Arg Pointer + */ + if ( ldap_get_option(ld, LDAP_X_OPT_SOCKETARG, &socketargp) < 0 ) { + rc = ldap_get_lderrno( ld, NULL, NULL ); + goto close_socket_and_exit_with_error; + } + + + /* + * Retrieve session info. so we can store a pointer to our session info. + * in our socket info. later. + */ + memset( &sei, 0, sizeof(sei)); + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + if (LDAP_SUCCESS != (rc = prldap_get_session_info(ld, NULL, &sei))) { + goto close_socket_and_exit_with_error; + } + sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; + + /* + * Retrieve socket info. + */ + memset( &soi, 0, sizeof(soi)); + soi.soinfo_size = PRLDAP_SOCKETINFO_SIZE; + if (LDAP_SUCCESS != + (rc = prldap_get_socket_info(intfd, socketargp, &soi))) { + goto close_socket_and_exit_with_error; + } + + /* + * Allocate a structure to hold our socket-specific data. + */ + if ( NULL == ( ssoip = PR_Calloc( 1, sizeof( LDAPSSLSocketInfo )))) { + rc = LDAP_NO_MEMORY; + goto close_socket_and_exit_with_error; + } + ssoip->soi_sessioninfo = sseip; + + /* + * Add SSL layer and enable SSL. + */ + if (( sslfd = SSL_ImportFD( NULL, soi.soinfo_prfd )) == NULL ) { + rc = LDAP_LOCAL_ERROR; + goto close_socket_and_exit_with_error; + } + + if ( SSL_OptionSet( sslfd, SSL_SECURITY, secure ) != SECSuccess || + SSL_OptionSet( sslfd, SSL_ENABLE_TLS, secure ) != SECSuccess || + SSL_OptionSet( sslfd, SSL_HANDSHAKE_AS_CLIENT, secure ) != SECSuccess || + ( secure && SSL_ResetHandshake( sslfd, PR_FALSE ) != SECSuccess ) ) { + rc = LDAP_LOCAL_ERROR; + goto close_socket_and_exit_with_error; + } + + /* + * Set hostname which will be retrieved (depending on ssl strength) when + * using client or server auth. + */ + if ( SSL_SetURL( sslfd, hostlist ) != SECSuccess ) { + rc = LDAP_LOCAL_ERROR; + goto close_socket_and_exit_with_error; + } + ldap_memfree(hostlist); + hostlist = NULL; + + /* + * Set any SSL options that were modified by a previous call to + * the ldapssl_set_option() function. + */ + if ( set_ssl_options( sslfd, sseip->lssei_ssl_option_value, + sseip->lssei_ssl_option_isset ) < 0 ) { + rc = LDAP_LOCAL_ERROR; + goto close_socket_and_exit_with_error; + } + + /* + * If using client auth., arrange to use a separate SSL session cache + * for each distinct local client certificate nickname. + */ + if ( sseip->lssei_client_auth && + sseip->lssei_certnickname && sseip->lssei_certnickname[0] && + SSL_SetSockPeerID( sslfd, sseip->lssei_certnickname) != SECSuccess ) { + rc = LDAP_LOCAL_ERROR; + goto close_socket_and_exit_with_error; + } + + /* + * Let the standard NSPR to LDAP layer know about the new socket and + * our own socket-specific data. + */ + soi.soinfo_prfd = sslfd; + soi.soinfo_appdata = (void *)ssoip; + + if ( LDAP_SUCCESS != + (rc = prldap_set_socket_info( intfd, socketargp, &soi ))) { + goto close_socket_and_exit_with_error; + } + sslfd = NULL; /* so we don't close the socket twice upon error */ + + /* + * Install certificate hook function. + */ + SSL_AuthCertificateHook( soi.soinfo_prfd, + (SSLAuthCertificate)ldapssl_AuthCertificate, + (void *)sseip ); + + if ( SSL_GetClientAuthDataHook( soi.soinfo_prfd, + get_clientauth_data, sseip->lssei_client_auth ? sseip : NULL ) != 0 ) { + rc = LDAP_LOCAL_ERROR; + goto close_socket_and_exit_with_error; + } + + return( LDAP_SUCCESS ); /* success */ + + close_socket_and_exit_with_error: + + ldap_memfree(hostlist); + hostlist = NULL; + + if ( NULL != sslfd && sslfd != soi.soinfo_prfd ) { + PR_Close( sslfd ); + } + if ( NULL != ssoip ) { + ldapssl_free_socket_info( &ssoip ); + } + if ( intfd >= 0 && NULL != socketargp && sseip != NULL ) { + (*(sseip->lssei_std_functions.lssf_close_fn))( intfd, + socketargp ); + } + return( rc ); + +} /* ldaptls_complete() */ + + + +/* + * Install I/O routines from libsec and NSPR into libldap to allow libldap + * to do TLS. + * + * We rely on libprldap to provide most of the functions. + * Returns an LDAP API result code (LDAP_SUCCESS if all goes well). + */ +static int +ldaptls_setup( LDAP *ld ) +{ + + int rc = LDAP_LOCAL_ERROR; + LDAPSSLSessionInfo *ssip; + PRLDAPSessionInfo sei; + + /* Check for valid input parameters. */ + if ( ld == NULL ) { + ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return( LDAP_PARAM_ERROR ); + } + + /* Check if NSPR Layer is Installed */ + if ( !prldap_is_installed(ld) ) { + /* No NSPR Layer installed, + * Call prldap_import_connection() that installs the NSPR I/O layer + * and imports connection details from Clear-text connection + */ + if (LDAP_SUCCESS != (rc = prldap_import_connection( ld ))) { + return( rc ); + } + } + + memset( &sei, 0, sizeof(sei)); + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + if ( (rc = prldap_get_session_info( ld, NULL, &sei )) == LDAP_SUCCESS ) { + ssip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; + } else { + return( rc ); + } + + if ( NULL == ssip ) { + if ( (ssip = ldapssl_alloc_sessioninfo()) == NULL ) { + ldap_set_lderrno( ld, LDAP_NO_MEMORY, NULL, NULL ); + return( LDAP_NO_MEMORY ); + } + + /* + * Store session info. for later retrieval. + */ + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + sei.seinfo_appdata = (void *)ssip; + if (LDAP_SUCCESS != (rc = prldap_set_session_info( ld, NULL, &sei ))) { + ldapssl_free_session_info( &ssip ); + return( rc ); + } + } + + ssip->lssei_tls_init= PR_TRUE; + + return( LDAP_SUCCESS ); +} /* ldaptls_setup()*/ + +/* Function; ldap_start_tls_s() + * startTLS request + * Returns an LDAP API result code (LDAP_SUCCESS if all goes well). + * + */ +int +LDAP_CALL +ldap_start_tls_s(LDAP *ld, + LDAPControl **serverctrls, + LDAPControl **clientctrls) +{ + int rc = -1; + int version = LDAP_VERSION3; + + /* Error check on LDAP handle */ + if ( ld == NULL ) { + ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); + return( LDAP_PARAM_ERROR ); + } + + + /* Make sure we are dealing with LDAPv3 */ + if ( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) < 0 ) { + return( ldap_get_lderrno( ld, NULL, NULL )); + } + + /* Issue the Start TLS extended operation */ + rc = ldap_extended_operation_s( ld, LDAP_EXOP_START_TLS, NULL, serverctrls, + clientctrls, NULL, NULL ); + if ( rc != LDAP_SUCCESS ) + { + return( rc ); + } + + /* Initialize TLS and enable SSL on the LDAP session */ + if ( LDAP_SUCCESS == ( rc = ldaptls_setup( ld ) ) && + LDAP_SUCCESS == ( rc = ldaptls_complete( ld ) )) { + if (ldap_set_option( ld, LDAP_OPT_SSL, LDAP_OPT_ON ) < 0 ) { + rc = ldap_get_lderrno( ld, NULL, NULL ); + } + } + + if (LDAP_SUCCESS != rc) { + /* Allow to proceed in clear text if secure session fails */ + ldap_set_option( ld, LDAP_OPT_SSL, LDAP_OPT_OFF ); + } + + return( rc ); +} + + + +/*ARGSUSED*/ +int +LDAP_CALL +ldapssl_enable_clientauth( LDAP *ld, char *keynickname, + char *keypasswd, char *certnickname ) +{ + LDAPSSLSessionInfo *ssip; + PRLDAPSessionInfo sei; + int new_session_allocated = 0; + + /* + * Check parameters + * allow keypasswd to be NULL in case PK11_SetPasswordFunc() + * already set by the user to their own private pin callback. + * there is no proper way to test if PK11_SetPasswordFunc() + * callback is already set apart from NSS private interfaces + */ + if ( certnickname == NULL ) { + ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, + ldapssl_libldap_compat_strdup( + "A non-NULL certnickname is required" )); + return( -1 ); + } + + /* + * Get session info. data structure. + */ + memset( &sei, 0, sizeof(sei)); + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + if ( prldap_get_session_info( ld, NULL, &sei ) == LDAP_SUCCESS ) { + ssip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; + } else { + return( -1 ); + } + + if ( NULL == ssip ) { /* Failed to get ssl session info pointer */ + /* + * Allocate our own session information. + */ + if ( NULL == ( ssip = ldapssl_alloc_sessioninfo())) { + ldap_set_lderrno( ld, LDAP_NO_MEMORY, NULL, NULL ); + return( -1 ); + } + /* + * Store session info. for later retrieval. + */ + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + sei.seinfo_appdata = (void *)ssip; + if ( prldap_set_session_info( ld, NULL, &sei ) != LDAP_SUCCESS ) { + return( -1 ); + } + new_session_allocated = 1; + } + + if ( !(ssip->lssei_ssl_ready) && !new_session_allocated ) { + /* standard SSL setup has not yet done */ + ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, + ldapssl_libldap_compat_strdup( + "An SSL-ready LDAP session handle is required" )); + return( -1 ); + } + + /* + * Update session info. data structure. + */ + ssip->lssei_certnickname = PL_strdup( certnickname ); + if ( keypasswd ) { + ssip->lssei_keypasswd = PL_strdup( keypasswd ); + } else { + /* set lssei_using_pcks_fns to prevent our own PK11_SetPasswordFunc() + * callback being installed in get_keyandcert() if keypasswd is NULL + * workaround for now til NSS comes up with proper check interface + */ + ssip->lssei_using_pcks_fns = 1; + ssip->lssei_keypasswd = NULL; /* assume pre-authenticated */ + } + + if ( NULL == ssip->lssei_certnickname || + ( keypasswd && ( NULL == ssip->lssei_keypasswd ) ) ) { + ldap_set_lderrno( ld, LDAP_NO_MEMORY, NULL, NULL ); + return( -1 ); + } + + if ( check_clientauth_nicknames_and_passwd( ld, ssip ) != SECSuccess ) { + /* LDAP errno is set by check_clientauth_nicknames_and_passwd() */ + return( -1 ); + } + + /* Mark the session as client auth enabled */ + ssip->lssei_client_auth = PR_TRUE; + + return( LDAP_SUCCESS ); +} + + +/* + * Set the SSL strength for an existing SSL-enabled LDAP session handle. + * + * See the description of ldapssl_serverauth_init() above for valid + * sslstrength values. If ld is NULL, the default for new LDAP session + * handles is set. + * + * Returns 0 if all goes well and -1 if an error occurs. + */ +int +LDAP_CALL +ldapssl_set_strength( LDAP *ld, int sslstrength ) +{ + int rc = 0; /* assume success */ + + if ( sslstrength != LDAPSSL_AUTH_WEAK && + sslstrength != LDAPSSL_AUTH_CERT && + sslstrength != LDAPSSL_AUTH_CNCHECK ) { + rc = -1; + } else { + if ( NULL == ld ) { /* set default strength */ + default_ssl_strength = sslstrength; + } else { /* set session-specific strength */ + PRLDAPSessionInfo sei; + LDAPSSLSessionInfo *sseip; + + memset( &sei, 0, sizeof( sei )); + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + if ( prldap_get_session_info( ld, NULL, &sei ) == LDAP_SUCCESS ) { + sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; + sseip->lssei_ssl_strength = sslstrength; + } else { + rc = -1; + } + } + } + + return( rc ); +} + + +/* + * Set SSL options for an existing SSL-enabled LDAP session handle. + * If ld is NULL, the default options used for all future LDAP SSL sessions + * are the ones affected. The option values are specific to the underlying + * SSL provider; see ssl.h within the Network Security Services (NSS) + * distribution for the options supported by NSS (the default SSL provider). + * + * This function should be called before any LDAP connections are created. + * + * Returns: 0 if all goes well. + */ +int +LDAP_CALL +ldapssl_set_option( LDAP *ld, int option, int on ) +{ + int rc = 0; /* assume success */ + + if ( option < 0 || option > LDAPSSL_MAX_SSL_OPTION ) { + ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); + rc = -1; + } else { + if ( NULL == ld ) { + /* set default options for new LDAP sessions */ + default_ssl_option_value[option] = on; + default_ssl_option_isset[option] = PR_TRUE; + } else { + /* set session options */ + PRLDAPSessionInfo sei; + LDAPSSLSessionInfo *sseip; + + memset( &sei, 0, sizeof( sei )); + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + if ( prldap_get_session_info( ld, NULL, &sei ) == LDAP_SUCCESS ) { + sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; + sseip->lssei_ssl_option_value[option] = on; + sseip->lssei_ssl_option_isset[option] = PR_TRUE; + } else { + rc = -1; + } + } + } + + return( rc ); +} + + +/* + * Retrieve SSL options for an existing SSL-enabled LDAP session handle. + * If ld is NULL, the default options to be used for all future LDAP SSL + * sessions are retrieved. The option values are specific to the underlying + * SSL provider; see ssl.h within the Network Security Services (NSS) + * distribution for the options supported by NSS (the default SSL provider). + * + * Returns: 0 if all goes well. + */ +int +LDAP_CALL +ldapssl_get_option( LDAP *ld, int option, int *onp ) +{ + int rc = 0; /* assume success */ + + if ( option < 0 || option > LDAPSSL_MAX_SSL_OPTION || onp == NULL ) { + ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL ); + rc = -1; + } else { + int rv = 0, set_rv = 0; + + if ( NULL == ld ) { + /* return default options for new LDAP sessions */ + if ( default_ssl_option_isset[option] ) { + rv = default_ssl_option_value[option]; + set_rv = 1; + } + } else { + /* return session options */ + PRLDAPSessionInfo sei; + LDAPSSLSessionInfo *sseip; + + memset( &sei, 0, sizeof( sei )); + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + if ( prldap_get_session_info( ld, NULL, &sei ) + == LDAP_SUCCESS ) { + sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; + if ( sseip->lssei_ssl_option_isset[option] ) { + rv = sseip->lssei_ssl_option_value[option]; + set_rv = 1; + } + } else { + rc = -1; + } + } + + if ( !set_rv ) { + PRBool pron = PR_FALSE; + if ( rc == 0 && SSL_OptionGetDefault( (PRInt32)option, &pron ) + != SECSuccess ) { + rc = -1; + } + rv = pron; + } + + *onp = rv; /* always return a value */ + } + + return( rc ); +} + +#ifdef LDAPSSL_DEBUG +struct optitem { + PRInt32 om_option; + const char *om_string; +} optmap[] = { + { SSL_SECURITY, "SSL_SECURITY" }, + { SSL_SOCKS, "SSL_SOCKS" }, + { SSL_REQUEST_CERTIFICATE, "SSL_REQUEST_CERTIFICATE" }, + { SSL_HANDSHAKE_AS_CLIENT, "SSL_HANDSHAKE_AS_CLIENT" }, + { SSL_HANDSHAKE_AS_SERVER, "SSL_HANDSHAKE_AS_SERVER" }, + { SSL_ENABLE_SSL2, "SSL_ENABLE_SSL2" }, + { SSL_ENABLE_SSL3, "SSL_ENABLE_SSL3" }, + { SSL_NO_CACHE, "SSL_NO_CACHE" }, + { SSL_REQUIRE_CERTIFICATE, "SSL_REQUIRE_CERTIFICATE" }, + { SSL_ENABLE_FDX, "SSL_ENABLE_FDX" }, + { SSL_V2_COMPATIBLE_HELLO, "SSL_V2_COMPATIBLE_HELLO" }, + { SSL_ENABLE_TLS, "SSL_ENABLE_TLS" }, + { SSL_ROLLBACK_DETECTION, "SSL_ROLLBACK_DETECTION" }, + { -1, NULL }, +}; + +static const char * +sslopt2string( PRInt32 option ) +{ + int i; + const char *s = "unknown"; + + for ( i = 0; optmap[i].om_option != -1; ++i ) { + if ( optmap[i].om_option == option ) { + s = optmap[i].om_string; + break; + } + } + + return( s ); +} +#endif /* LDAPSSL_DEBUG */ + +static int +set_ssl_options( PRFileDesc *sslfd, PRBool *optval, PRBool *optisset ) +{ + SECStatus secrc = SECSuccess; + PRInt32 option; + + for ( option = 0; + ( secrc == SECSuccess ) && ( option < LDAPSSL_MAX_SSL_OPTION ); + ++option ) { + if ( optisset[ option ] ) { +#ifdef LDAPSSL_DEBUG + fprintf( stderr, + "set_ssl_options: setting option %d - %s to %d (%s)\n", + option, sslopt2string(option), optval[ option ], + optval[ option ] ? "ON" : "OFF" ); +#endif /* LDAPSSL_DEBUG */ + + secrc = SSL_OptionSet( sslfd, option, optval[ option ] ); + } + } + + if ( secrc == SECSuccess ) { + return( 0 ); + } + + PR_SetError( PR_GetError(), EINVAL ); /* set OS error only */ + return( -1 ); +} + + +static void +ldapssl_free_session_info( LDAPSSLSessionInfo **ssipp ) +{ + if ( NULL != ssipp && NULL != *ssipp ) { + if ( NULL != (*ssipp)->lssei_certnickname ) { + PL_strfree( (*ssipp)->lssei_certnickname ); + (*ssipp)->lssei_certnickname = NULL; + } + if ( NULL != (*ssipp)->lssei_keypasswd ) { + PL_strfree( (*ssipp)->lssei_keypasswd ); + (*ssipp)->lssei_keypasswd = NULL; + } + PR_Free( *ssipp ); + *ssipp = NULL; + } +} + + +static void +ldapssl_free_socket_info( LDAPSSLSocketInfo **soipp ) +{ + if ( NULL != soipp && NULL != *soipp ) { + PR_Free( *soipp ); + *soipp = NULL; + } +} + + +/* this function provides cert authentication. This is called during + * the SSL_Handshake process. Once the cert has been retrieved from + * the server, the it is checked, using VerifyCertNow(), then + * the cn is checked against the host name, set with SSL_SetURL() + */ + +static int +ldapssl_AuthCertificate(void *sessionarg, PRFileDesc *fd, PRBool checkSig, + PRBool isServer) +{ + SECStatus rv = SECFailure; + LDAPSSLSessionInfo *sseip; + CERTCertificate *cert; + SECCertUsage certUsage; + char *hostname = (char *)0; + + if (!sessionarg || !fd) { + return rv; + } + + sseip = (LDAPSSLSessionInfo *)sessionarg; + + if (LDAPSSL_AUTH_WEAK == sseip->lssei_ssl_strength ) { /* no check */ + return SECSuccess; + } + + if ( isServer ) { + certUsage = certUsageSSLClient; + } else { + certUsage = certUsageSSLServer; + } + cert = SSL_PeerCertificate( fd ); + + rv = CERT_VerifyCertNow(sseip->lssei_certdbh, cert, checkSig, + certUsage, NULL); + + if ( rv != SECSuccess || isServer ) { + /* must destroy cert to avoid mem leak */ + CERT_DestroyCertificate(cert); + return rv; + } + + if ( LDAPSSL_AUTH_CNCHECK == sseip->lssei_ssl_strength ) { + /* cert is OK. This is the client side of an SSL connection. + * Now check the name field in the cert against the desired hostname. + * NB: This is our only defense against Man-In-The-Middle (MITM) + * attacks! + */ + + hostname = SSL_RevealURL( fd ); + + if (hostname && hostname[0]) { + rv = CERT_VerifyCertName(cert, hostname); + } else { + rv = SECFailure; + } + if (hostname) { + PL_strfree(hostname); + } + if (rv != SECSuccess) { + PORT_SetError(SSL_ERROR_BAD_CERT_DOMAIN); + } + } + + /* must destroy cert to avoid mem leak */ + CERT_DestroyCertificate(cert); + return((int)rv); +} + + +/* + * called during SSL client auth. when server wants our cert and key. + * returns: SECSuccess if we succeeded and set *pRetCert and *pRetKey, + * SECFailure otherwise. + * if SECFailure is returned SSL will proceed without sending a cert. + */ +/*ARGSUSED*/ +static SECStatus +get_clientauth_data( void *sessionarg, PRFileDesc *prfd, + CERTDistNames *caNames, CERTCertificate **pRetCert, + SECKEYPrivateKey **pRetKey ) + +{ + LDAPSSLSessionInfo *ssip; + + if (( ssip = (LDAPSSLSessionInfo *)sessionarg ) == NULL ) { + return( SECFailure ); /* client auth. not enabled */ + } + + return( get_keyandcert( ssip, pRetCert, pRetKey, NULL )); +} + +static SECStatus +get_keyandcert( LDAPSSLSessionInfo *ssip, + CERTCertificate **pRetCert, SECKEYPrivateKey **pRetKey, + char **errmsgp ) +{ + CERTCertificate *cert; + SECKEYPrivateKey *key; + + if ( !ssip->lssei_using_pcks_fns && (NULL != ssip->lssei_keypasswd) ) { + /* + * XXX: This function should be called only once, and probably + * in one of the ldapssl_.*_init() calls. + */ + PK11_SetPasswordFunc( get_keypassword ); + } + + if (( cert = CERT_FindUserCertByUsage( CERT_GetDefaultCertDB(), + ssip->lssei_certnickname, certUsageSSLClient, + PR_FALSE, (void *)ssip )) == NULL ) { + if ( errmsgp != NULL ) { + *errmsgp = "unable to find certificate"; + } + return( SECFailure ); + } + + if (( key = PK11_FindKeyByAnyCert( cert, (void *)ssip )) == NULL ) { + CERT_DestroyCertificate( cert ); + if ( errmsgp != NULL ) { + *errmsgp = "bad key or key password"; + } + return( SECFailure ); + } + + *pRetCert = cert; + *pRetKey = key; + return( SECSuccess ); +} + + +/* + * This function returns the password to NSS. + * This function is enable through PK11_SetPasswordFunc + * only if pkcs functions are not being used. + */ +/*ARGSUSED*/ +static char * +get_keypassword( PK11SlotInfo *slot, PRBool retry, void *sessionarg ) +{ + LDAPSSLSessionInfo *ssip; + + if ( retry) + return (NULL); + + ssip = (LDAPSSLSessionInfo *)sessionarg; + if ( NULL == ssip || NULL == ssip->lssei_keypasswd ) { + return( NULL ); + } + + return( PL_strdup(ssip->lssei_keypasswd) ); +} + + +/* + * performs some basic checks on clientauth cert and key/password + * + * XXXmcs: could perform additional checks... see servers/slapd/ssl.c + * 1) check expiration + * 2) check that public key in cert matches private key + * see ns/netsite/ldap/servers/slapd/ssl.c:slapd_ssl_init() for example code. + */ +static SECStatus +check_clientauth_nicknames_and_passwd( LDAP *ld, LDAPSSLSessionInfo *ssip ) +{ + char *errmsg = NULL; + CERTCertificate *cert = NULL; + SECKEYPrivateKey *key = NULL; + SECStatus rv; + + rv = get_keyandcert( ssip, &cert, &key, &errmsg ); + + if ( rv != SECSuccess ) { + if ( errmsg != NULL ) { + errmsg = ldapssl_libldap_compat_strdup( errmsg ); + } + ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, errmsg ); + return( rv ); + } + + if ( cert != NULL ) { + CERT_DestroyCertificate( cert ); + } + if ( key != NULL ) { + SECKEY_DestroyPrivateKey( key ); + } + return( SECSuccess ); +} + + +/* + * A strdup() work-alike that uses libldap's memory allocator. + */ +static char * +ldapssl_libldap_compat_strdup(const char *s1) +{ + char *s2; + + if ( NULL == s1 ) { + s2 = NULL; + } else { + size_t len = strlen( s1 ); + + if ( NULL != ( s2 = (char *)ldap_x_malloc( len + 1 ))) { + strcpy( s2, s1 ); + } + } + + return s2; +} + + + +/* there are patches and kludges. this is both. force some linkers to + * link this stuff in + */ +int stubs_o_stuff( void ) +{ + PRExplodedTime exploded; + PLArenaPool pool; + + const char *name ="t"; + PRUint32 size = 0, align = 0; + + PR_ImplodeTime( &exploded ); + PL_InitArenaPool( &pool, name, size, align); + PR_Cleanup(); + PR_fprintf((PRFileDesc*)stderr, "Bad IDEA!!"); + + return 0; + +} + + +/* + * Import the file descriptor corresponding to the socket of an already + * open LDAP connection into SSL, and update the socket and session + * information accordingly. Returns 0 if all goes well. + */ +int +LDAP_CALL +ldapssl_import_fd ( LDAP *ld, int secure ) +{ + PRLDAPSessionInfo sei; + PRLDAPSocketInfo soi; + LDAPSSLSocketInfo *ssoip = NULL; + LDAPSSLSessionInfo *sseip; + PRFileDesc *sslfd = NULL; + LBER_SOCKET intfd = -1; + char *hostlist; + struct lextiof_socket_private *socketargp; + + /* + * Get hostlist from LDAP Handle + */ + if ( ldap_get_option(ld, LDAP_OPT_HOST_NAME, &hostlist) < 0 ) { + return( -1 ); + } + + /* + * Get File Desc from current connection + */ + if ( ldap_get_option(ld, LDAP_OPT_DESC, &intfd) < 0 ) { + return( -1 ); + } + + /* + * Get Socket Arg Pointer + */ + if ( ldap_get_option(ld, LDAP_X_OPT_SOCKETARG, &socketargp) < 0 ) { + return( -1 ); + } + + /* + * Retrieve session info. so we can store a pointer to our session info. + * in our socket info. later. + */ + memset( &sei, 0, sizeof(sei)); + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + if ( prldap_get_session_info( ld, NULL, &sei ) != LDAP_SUCCESS ) { + return( -1 ); + } + sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; + + + /* + * Retrieve socket info. so we have the PRFileDesc. + */ + memset( &soi, 0, sizeof(soi)); + soi.soinfo_size = PRLDAP_SOCKETINFO_SIZE; + if ( prldap_get_socket_info( intfd, socketargp, &soi ) != LDAP_SUCCESS ) { + return( -1 ); + } + + /* + * Allocate a structure to hold our socket-specific data. + */ + if ( NULL == ( ssoip = PR_Calloc( 1, sizeof( LDAPSSLSocketInfo )))) { + goto reset_socket_and_exit_with_error; + } + ssoip->soi_sessioninfo = sseip; + + /* + * Add SSL layer and let the standard NSPR to LDAP layer and enable SSL. + */ + if (( sslfd = SSL_ImportFD( NULL, soi.soinfo_prfd )) == NULL ) { + goto reset_socket_and_exit_with_error; + } + + if ( SSL_OptionSet( sslfd, SSL_SECURITY, secure ) != SECSuccess || + SSL_OptionSet( sslfd, SSL_ENABLE_TLS, secure ) || + SSL_OptionSet( sslfd, SSL_HANDSHAKE_AS_CLIENT, secure ) + != SECSuccess || ( secure && SSL_ResetHandshake( sslfd, + PR_FALSE ) != SECSuccess )) { + goto reset_socket_and_exit_with_error; + } + + /* + * Set hostname which will be retrieved (depending on ssl strength) when + * using client or server auth. + */ + if ( SSL_SetURL( sslfd, hostlist ) != SECSuccess ) { + goto reset_socket_and_exit_with_error; + } + + /* + * Set any SSL options that were modified by a previous call to + * the ldapssl_set_option() function. + */ + if ( set_ssl_options( sslfd, sseip->lssei_ssl_option_value, + sseip->lssei_ssl_option_isset ) < 0 ) { + goto reset_socket_and_exit_with_error; + } + + /* + * If using client auth., arrange to use a separate SSL session cache + * for each distinct local client certificate nickname. + */ + if ( sseip->lssei_client_auth && + sseip->lssei_certnickname && sseip->lssei_certnickname[0] && + SSL_SetSockPeerID( sslfd, sseip->lssei_certnickname) != SECSuccess ) { + goto reset_socket_and_exit_with_error; + } + + /* + * Let the standard NSPR to LDAP layer know about the new socket and + * our own socket-specific data. + */ + soi.soinfo_prfd = sslfd; + soi.soinfo_appdata = (void *)ssoip; + if ( prldap_set_default_socket_info( ld, &soi ) != LDAP_SUCCESS ) { + goto reset_socket_and_exit_with_error; + } + + /* + * Install certificate hook function. + */ + if ( SSL_AuthCertificateHook( soi.soinfo_prfd, + (SSLAuthCertificate)ldapssl_AuthCertificate, + (void *)sseip) != 0 ) { + goto reset_socket_and_exit_with_error; + } + + if ( SSL_GetClientAuthDataHook( soi.soinfo_prfd, + get_clientauth_data, sseip->lssei_certnickname ? sseip : NULL ) + != 0 ) { + goto reset_socket_and_exit_with_error; + } + + return 0; + + reset_socket_and_exit_with_error: + if ( NULL != sslfd ) { + /* + * "Unimport" the socket from SSL, i.e. get rid of the upper layer of + * the file descriptor stack, which represents SSL. + */ + soi.soinfo_prfd = sslfd; + sslfd = PR_PopIOLayer( soi.soinfo_prfd, PR_TOP_IO_LAYER ); + sslfd->dtor( sslfd ); + } + if ( NULL != ssoip ) { + ldapssl_free_socket_info( &ssoip ); + soi.soinfo_appdata = NULL; + } + prldap_set_default_socket_info( ld, &soi ); + + return( -1 ); +} + + +/* + * Reset an LDAP session from SSL to a non-secure status. Basically, + * this function undoes the work done by ldapssl_install_routines. + * Returns 0 if all goes well. + */ +int +LDAP_CALL +ldapssl_reset_to_nonsecure ( LDAP *ld ) +{ + PRLDAPSessionInfo sei; + LDAPSSLSessionInfo *sseip; + + struct ldap_x_ext_io_fns iofns; + int rc = 0; + + /* + * Retrieve session info. + */ + memset( &sei, 0, sizeof(sei)); + sei.seinfo_size = PRLDAP_SESSIONINFO_SIZE; + if ( prldap_get_session_info( ld, NULL, &sei ) != LDAP_SUCCESS ) { + return( -1 ); + } + sseip = (LDAPSSLSessionInfo *)sei.seinfo_appdata; + + if ( sseip != NULL ) { + /* + * Reset the standard extended io functions. + */ + memset( &iofns, 0, sizeof(iofns)); + iofns.lextiof_size = LDAP_X_EXTIO_FNS_SIZE; + if ( ldap_get_option( ld, LDAP_X_OPT_EXTIO_FN_PTRS, (void *)&iofns ) + < 0) { + rc = -1; + goto free_session_info; + } + + /* reset socket, connect, and ioctl */ + iofns.lextiof_connect = sseip->lssei_std_functions.lssf_connect_fn; + iofns.lextiof_close = sseip->lssei_std_functions.lssf_close_fn; + iofns.lextiof_disposehandle = + sseip->lssei_std_functions.lssf_disposehdl_fn; + + if ( ldap_set_option( ld, LDAP_X_OPT_EXTIO_FN_PTRS, (void *)&iofns ) + < 0) { + rc = -1; + goto free_session_info; + } + +free_session_info: + ldapssl_free_session_info( &sseip ); + sei.seinfo_appdata = NULL; + if ( prldap_set_session_info( ld, NULL, &sei ) != LDAP_SUCCESS ) { + rc = -1; + } + } /* if ( sseip && *sseip ) */ + + if ( ldap_set_option( ld, LDAP_OPT_SSL, LDAP_OPT_OFF ) < 0 ) { + return (-1); + } + + return rc; +} +#endif /* NET_SSL */
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libssldap/prerrstrs.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libssldap/prerrstrs.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libssldap/secerrstrs.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libssldap/secerrstrs.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libssldap/sslerrstrs.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libssldap/sslerrstrs.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libutil/Makefile.client
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libutil/Makefile.client)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libutil/Makefile.in
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libutil/Makefile.in)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/libutil/getopt.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/libutil/getopt.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/LDAPClient.exp
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/LDAPClient.exp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/LDAPClient.mcp
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/LDAPClient.mcp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/LDAPClient.xml
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/LDAPClient.xml)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/LDAPClientDebugDefs.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/LDAPClientDebugDefs.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/LDAPClientDefs.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/LDAPClientDefs.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/LDAPPRClient.exp
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/LDAPPRClient.exp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/LDAPSSLClient.exp
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/LDAPSSLClient.exp)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/getopt.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/getopt.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/kerberos-macos.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/kerberos-macos.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/ldap-macos-defs.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/ldap-macos-defs.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/ldap-macos.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/ldap-macos.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/libldap-PPC.r
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/libldap-PPC.r)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/macos-ip.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/macos-ip.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/strings.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/strings.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/tcp-univhdrs/tcp.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/tcp-univhdrs/tcp.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/macintosh/tcp-univhdrs/tcp.h
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/macintosh/tcp-univhdrs/tcp.h)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/ldap32.def
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/ldap32.def)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/ldap32.tdf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/ldap32.tdf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/ldapssl.def
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/ldapssl.def)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/ldapssl.tdf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/ldapssl.tdf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/libldap.def
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/libldap.def)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/libldap.tdf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldap.tdf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/mozock.c
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/mozock.c)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldap.def
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldap.def)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldap.rc
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldap.rc)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldap.tdf
Added
@@ -0,0 +1,49 @@ +; +; ***** BEGIN LICENSE BLOCK ***** +; Version: MPL 1.1/GPL 2.0/LGPL 2.1 +; +; The contents of this file are subject to the Mozilla Public License Version +; 1.1 (the "License"); you may not use this file except in compliance with +; the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" basis, +; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +; for the specific language governing rights and limitations under the +; License. +; +; The Original Code is Mozilla Communicator client code. +; +; The Initial Developer of the Original Code is +; Netscape Communications Corporation. +; Portions created by the Initial Developer are Copyright (C) 1996-1999 +; the Initial Developer. All Rights Reserved. +; +; Contributor(s): +; +; Alternatively, the contents of this file may be used under the terms of +; either of the GNU General Public License Version 2 or later (the "GPL"), +; or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +; in which case the provisions of the GPL or the LGPL are applicable instead +; of those above. If you wish to allow use of your version of this file only +; under the terms of either the GPL or the LGPL, and not to allow others to +; use your version of this file under the terms of the MPL, indicate your +; decision by deleting the provisions above and replace them with the notice +; and other provisions required by the GPL or the LGPL. If you do not delete +; the provisions above, a recipient may use your version of this file under +; the terms of any one of the MPL, the GPL or the LGPL. +; +; ***** END LICENSE BLOCK ***** + +LIBRARY NSLDAP +DESCRIPTION 'Lightweight Directory Access Protocol Client API for 16-bit Windows' +EXETYPE WINDOWS +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE SINGLE + +HEAPSIZE 4096 + +EXPORTS +; we need to manually assign ordinal numbers so we can add new routines +; and not disturb the ordinals and thus not require callers to relink. +$EXPORTS
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldap32.def
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldap32.def)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldap32.tdf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldap32.tdf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldappr-incl.def
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldappr-incl.def)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldappr-incl.tdf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldappr-incl.tdf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldappr32.def
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldappr32.def)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldappr32.tdf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldappr32.tdf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldapssl32.def
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldapssl32.def)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldapssl32.tdf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldapssl32.tdf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldif32.def
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldif32.def)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nsldif32.tdf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nsldif32.tdf)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nssldap32.def
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nssldap32.def)
View file
mozldap-6.0.7.tar.gz/c-sdk/ldap/libraries/msdos/winsock/nssldap32.tdf
Changed
(renamed from mozilla/directory/c-sdk/ldap/libraries/msdos/winsock/nssldap32.tdf)
View file
mozldap-6.0.7.tar.gz/c-sdk/mozldap.pc.in
Changed
(renamed from mozilla/directory/c-sdk/mozldap.pc.in)
View file
mozldap-6.0.7.tar.gz/c-sdk/mozldap.spec
Added
@@ -0,0 +1,237 @@ +%define nspr_name nspr +%define nspr_version 4.6 +%define nss_name nss +%define nss_version 3.11 +%define svrcore_name svrcore +%define svrcore_version 4.0.3 + +%define major 6 +%define minor 0 +%define submin 7 +%define libsuffix %{major}0 + +Summary: Mozilla LDAP C SDK +Name: mozldap +Version: %{major}.%{minor}.%{submin} +Release: 1%{?dist} +License: MPL/GPL/LGPL +URL: http://www.mozilla.org/directory/csdk.html +Group: System Environment/Libraries +Requires: %{nspr_name} >= %{nspr_version} +Requires: %{nss_name} >= %{nss_version} +Requires: %{svrcore_name} >= %{svrcore_version} +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: %{nspr_name}-devel >= %{nspr_version} +BuildRequires: %{nss_name}-devel >= %{nss_version} +BuildRequires: %{svrcore_name}-devel >= %{svrcore_version} +BuildRequires: gcc-c++ +BuildRequires: cyrus-sasl-devel + +Source0: ftp://ftp.mozilla.org/pub/mozilla.org/directory/c-sdk/releases/v%{version}/src/%{name}-%{version}.tar.gz + +%description +The Mozilla LDAP C SDK is a set of libraries that +allow applications to communicate with LDAP directory +servers. These libraries are derived from the University +of Michigan and Netscape LDAP libraries. They use Mozilla +NSPR and NSS for crypto. + + +%package tools +Summary: Tools for the Mozilla LDAP C SDK +Group: System Environment/Base +Requires: %{name} = %{version}-%{release} +BuildRequires: %{nspr_name}-devel >= %{nspr_version} +BuildRequires: %{nss_name}-devel >= %{nss_version} +BuildRequires: %{svrcore_name}-devel >= %{svrcore_version} + +%description tools +The mozldap-tools package provides the ldapsearch, +ldapmodify, and ldapdelete tools that use the +Mozilla LDAP C SDK libraries. + + +%package devel +Summary: Development libraries and examples for Mozilla LDAP C SDK +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: %{nspr_name}-devel >= %{nspr_version} +Requires: %{nss_name}-devel >= %{nss_version} +Requires: %{svrcore_name}-devel >= %{svrcore_version} +Requires: pkgconfig + +%description devel +Header and Library files for doing development with the Mozilla LDAP C SDK + +%prep +%setup -q + +%build +cd mozilla/directory/c-sdk + +%configure \ +%ifarch x86_64 ppc64 ia64 s390x + --enable-64bit \ +%endif + --with-sasl \ + --enable-clu \ + --with-system-svrcore \ + --enable-optimize \ + --disable-debug + +# Enable compiler optimizations and disable debugging code +BUILD_OPT=1 +export BUILD_OPT + +# Generate symbolic info for debuggers +XCFLAGS="$RPM_OPT_FLAGS" +export XCFLAGS + +PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 +PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 + +export PKG_CONFIG_ALLOW_SYSTEM_LIBS +export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS + +make \ +%ifarch x86_64 ppc64 ia64 s390x + USE_64=1 +%endif + +%install +%{__rm} -rf $RPM_BUILD_ROOT + +# Set up our package file +%{__mkdir_p} $RPM_BUILD_ROOT%{_libdir}/pkgconfig +%{__cat} mozilla/directory/c-sdk/mozldap.pc.in \ + | sed -e "s,%%libdir%%,%{_libdir},g" \ + -e "s,%%prefix%%,%{_prefix},g" \ + -e "s,%%major%%,%{major},g" \ + -e "s,%%minor%%,%{minor},g" \ + -e "s,%%submin%%,%{submin},g" \ + -e "s,%%libsuffix%%,%{libsuffix},g" \ + -e "s,%%bindir%%,%{_libdir}/%{name},g" \ + -e "s,%%exec_prefix%%,%{_prefix},g" \ + -e "s,%%includedir%%,%{_includedir}/%{name},g" \ + -e "s,%%NSPR_VERSION%%,%{nspr_version},g" \ + -e "s,%%NSS_VERSION%%,%{nss_version},g" \ + -e "s,%%SVRCORE_VERSION%%,%{svrcore_version},g" \ + -e "s,%%MOZLDAP_VERSION%%,%{version},g" \ + > $RPM_BUILD_ROOT%{_libdir}/pkgconfig/%{name}.pc + +# There is no make install target so we'll do it ourselves. + +%{__mkdir_p} $RPM_BUILD_ROOT%{_includedir}/%{name} +%{__mkdir_p} $RPM_BUILD_ROOT%{_libdir}/%{name} + +# Copy the binary libraries we want +for file in libssldap%{libsuffix}.so libprldap%{libsuffix}.so libldap%{libsuffix}.so libldif%{libsuffix}.so +do + %{__install} -m 755 mozilla/dist/lib/$file $RPM_BUILD_ROOT%{_libdir} +done + +# Copy the binaries we want +for file in ldapsearch ldapmodify ldapdelete ldapcmp ldapcompare ldappasswd +do + %{__install} -m 755 mozilla/dist/bin/$file $RPM_BUILD_ROOT%{_libdir}/%{name} +done + +# Copy the include files +for file in mozilla/dist/public/ldap/*.h +do + %{__install} -p -m 644 $file $RPM_BUILD_ROOT%{_includedir}/%{name} +done + +# Copy the developer files +%{__mkdir_p} $RPM_BUILD_ROOT%{_datadir}/%{name} +cp -r mozilla/directory/c-sdk/ldap/examples $RPM_BUILD_ROOT%{_datadir}/%{name} +%{__mkdir_p} $RPM_BUILD_ROOT%{_datadir}/%{name}/etc +%{__install} -m 644 mozilla/directory/c-sdk/ldap/examples/xmplflt.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc +%{__install} -m 644 mozilla/directory/c-sdk/ldap/libraries/libldap/ldaptemplates.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc +%{__install} -m 644 mozilla/directory/c-sdk/ldap/libraries/libldap/ldapfilter.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc +%{__install} -m 644 mozilla/directory/c-sdk/ldap/libraries/libldap/ldapsearchprefs.conf $RPM_BUILD_ROOT%{_datadir}/%{name}/etc + +%clean +%{__rm} -rf $RPM_BUILD_ROOT + + +%post -p /sbin/ldconfig + + +%postun -p /sbin/ldconfig + + +%files +%defattr(-,root,root,-) +%doc mozilla/directory/c-sdk/README.rpm +%{_libdir}/libssldap*.so +%{_libdir}/libprldap*.so +%{_libdir}/libldap*.so +%{_libdir}/libldif*.so + +%files tools +%defattr(-,root,root,-) +%dir %{_libdir}/%{name} +%{_libdir}/%{name}/ldapsearch +%{_libdir}/%{name}/ldapmodify +%{_libdir}/%{name}/ldapdelete +%{_libdir}/%{name}/ldapcmp +%{_libdir}/%{name}/ldapcompare +%{_libdir}/%{name}/ldappasswd + +%files devel +%defattr(-,root,root,-) +%{_libdir}/pkgconfig/%{name}.pc +%{_includedir}/%{name} +%{_datadir}/%{name} + +%changelog +* Wed Jun 20 2007 Rich Megginson <rmeggins@redhat.com> - 6.0.4-1 +- bump version to 6.0.4 - this version has some memory leak +- fixes for SASL related code, fixes for control handling with +- referral chasing, and packaging improvements +- use -p when installing include files to preserve timestamps + +* Thu May 24 2007 Rich Megginson <rmeggins@redhat.com> - 6.0.3-3 +- We only need cyrus-sasl-devel as a BuildRequires in the main package + +* Mon May 21 2007 Rich Megginson <rmeggins@redhat.com> - 6.0.3-2 +- added cyrus-sasl-devel and pkgconfig to devel package Requires + +* Tue Mar 13 2007 Rich Megginson <richm@stanfordalumni.org> - 6.0.3-1 +- bumped version to 6.0.3 +- minor build fixes for some platforms + +* Mon Jan 15 2007 Rich Megginson <richm@stanfordalumni.org> - 6.0.2-1 +- Fixed exports file generation for Solaris and Windows - no effect on linux +- bumped version to 6.0.2 + +* Mon Jan 9 2007 Rich Megginson <richm@stanfordalumni.org> - 6.0.1-2 +- Remove buildroot = "/" checking +- Remove buildroot removal from %%build section + +* Mon Jan 8 2007 Rich Megginson <richm@stanfordalumni.org> - 6.0.1-1 +- bump version to 6.0.1 +- added libldif and ldif.h + +* Fri Dec 8 2006 Axel Thimm <Axel.Thimm@ATrpms.net> - 6.0.0-2 +- Rename to mozldap. +- move configure step to %%build section. +- clean up excessive use of %%defines, make more Fedora like. +- fix mismatching soname issue. +- generic specfile cosmetics. + +* Thu Oct 5 2006 Rich Megginson <richm@stanforalumni.org> - 6.0.0-1 +- Bump version to 6.0.0 - add support for submit/patch level (3rd level) in version numbering + +* Tue Apr 18 2006 Richard Megginson <richm@stanforalumni.org> - 5.17-3 +- make more Fedora Core friendly - move each requires and buildrequires to a separate line +- remove --with-nss since svrcore implies it; fix some macro errors; macro-ize nspr and nss names +- fix directory attrs in devel package + +* Tue Jan 31 2006 Rich Megginson <rmeggins@redhat.com> - 5.17-2 +- use --with-system-svrcore to configure + +* Mon Dec 19 2005 Rich Megginson <rmeggins@redhat.com> - 5.17-1 +- Initial revision +
View file
mozldap-6.0.7.tar.gz/c-sdk/package.mk
Changed
(renamed from mozilla/directory/c-sdk/package.mk)
View file
mozldap-6.0.7.tar.gz/ldapsdk.mak
Added
@@ -0,0 +1,211 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +!if !defined(MOZ_TOP) +#enable builds from changed top level directories +MOZ_TOP=mozilla +!endif + +#//------------------------------------------------------------------------ +#// Figure out how to do the pull. +#//------------------------------------------------------------------------ +!if "$(MOZ_BRANCH)" != "" +CVS_BRANCH=-r $(MOZ_BRANCH) +HAVE_BRANCH=1 +!else +HAVE_BRANCH=0 +!endif + +#// +#// Temporary hardcode (while we figure out how to do this) +#// to support the Core modularity efforts... +#// + + +LDAPSDK_BRANCH =-r LDAPSDK_40_BRANCH + +!if "$(MOZ_DATE)" != "" +CVS_BRANCH=-D "$(MOZ_DATE)" +HAVE_DATE=1 +!else +HAVE_DATE=0 +!endif + +!if $(HAVE_DATE) && $(HAVE_BRANCH) +ERR_MESSAGE=$(ERR_MESSAGE)^ +Cannot specify both MOZ_BRANCH and MOZ_DATE +!endif + +NMAKE=@nmake -nologo -$(MAKEFLAGS) + +#//------------------------------------------------------------------------ +#// +#// Stuff a do complete pull and build +#// +#//------------------------------------------------------------------------ + +default:: build_all + +pull_and_build_all:: pull_all \ + build_all + +#// Do this when you pull a new tree, or else you will often get bugs +#// when replaceing an old dist with a new dist. + +pull_clobber_build_all:: pull_all \ + clobber_all \ + build_all + +clobber_build_all:: clobber_all \ + build_all + +# In theory, we should use some symbol in ns/config/liteness.mak, +# but we haven't pulled the file yet. So, refer to MOZ_LITE and +# MOZ_MEDIUM explicitly . +pull_all:: + + +# -cvs co $(LDAPSDK_BRANCH) DirectorySDKSource + + + +#pull_client_source_product: +#x-CEB-x @echo +++ client.mak: checking out the client with "$(CVS_BRANCH)" +#x-CEB-x cd $(MOZ_SRC)\. +#x-CEB-x -cvs -d ":pserver:$(USERNAME)@cvsserver:/m/pub" co $(CVS_BRANCH) MozillaSourceWin +#x-CEB-x -cvs -d ":pserver:$(USERNAME)@cvsserver:/m/pub" co $(CVS_BRANCH) mozilla/lib/libnet + +build_all: build_ldap + + + +build_ldap: + @echo +++ ldapsdk.mak: building ldap + cd $(MOZ_SRC)\mozilla\directory\c-sdk\ldap\libraries\msdos\winsock + @echo +++ ldapsdk.mak: depend step + $(NMAKE) -f nsldap.mak DEPEND=1 + @echo +++ ldapsdk.mak: build step + $(NMAKE) -f nsldap.mak + @echo +++ ldapsdk.mak: library creation + $(NMAKE) -f nsldap.mak static + $(NMAKE) -f nsldap.mak dynamic + $(NMAKE) -f nsldap.mak EXPORT=1 + +# +# remove all source files from the tree and print a report of what was missed +# +clobber_all: + cd $(MOZ_SRC)\mozilla\directory\c-sdk\ldap\libraries\msdos\winsock + $(NMAKE) -f nsldap.mak clobber_all + +depend: + -del /s /q make.dep + $(NMAKE) -f makefile.win depend + +quick: + @cd $(MOZ_SRC)\. + @cvs co ns/quickup + @cd $(MOZ_SRC)\$(MOZ_TOP)\quickup + @$(MOZ_TOOLS)\perl5\perl doupdate.pl + +#//------------------------------------------------------------------------ +#// Utility stuff... +#//------------------------------------------------------------------------ + +#//------------------------------------------------------------------------ +# Verify that MOZ_SRC is set correctly +#//------------------------------------------------------------------------ + +# Check to see if it is set at all +!if "$(MOZ_SRC)"!="" + +# +# create a temp file at the root and make sure it is visible from MOZ_SRC +# +!if [copy $(MAKEDIR)\ldapsdk.mak $(MAKEDIR)\xyzzy.tmp > NUL] == 0 +!endif + +!if !EXIST( $(MOZ_SRC)\mozilla\directory\xyzzy.tmp ) +ERR_MESSAGE=$(ERR_MESSAGE)^ +MOZ_SRC isn't set correctly: [$(MOZ_SRC)\mozilla\directory]!=[$(MAKEDIR)] +!endif + +!if [del $(MAKEDIR)\xyzzy.tmp] +!endif + +!else +# MOZ_SRC isn't set at all +ERR_MESSAGE=$(ERR_MESSAGE)^ +Environment variable MOZ_SRC isn't set. +!endif + +!if !defined(MOZ_TOOLS) +ERR_MESSAGE=$(ERR_MESSAGE)^ +Environment variable MOZ_TOOLS isn't set. +!endif + + +#//------------------------------------------------------------------------ +#// Display error +#//------------------------------------------------------------------------ + + +!if "$(ERR_MESSAGE)" != "" +ERR_MESSAGE = ^ +ldapsdk.mak: ^ +$(ERR_MESSAGE) ^ +^ +ldapsdk.mak: usage^ +^ +nmake -f ldapsdk.mak [MOZ_BRANCH=<cvs_branch_name>] ^ + [MOZ_DATE=<cvs_date>]^ + [pull_and_build_all]^ + [pull_all]^ + [build_all]^ + [build_ldap]^ + +^ +Environment variables:^ +^ +MOZ_SRC set to the directory above ns or "$(MAKEDIR)\.."^ +MOZ_TOOLS set to the directory containing the java compiler see ^ + http://warp/tools/nt^ +JAVA_HOME set to the same thing as MOZ_TOOLS^ + +!ERROR $(ERR_MESSAGE) + +!endif
View file
mozldap-6.0.7.tar.gz/ldapsdk.mk
Added
@@ -0,0 +1,87 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +# +# Static macros. Can be overridden on the command-line. +# +ifndef CVSROOT +CVSROOT = /m/src +endif + +# Allow for cvs flags +ifndef CVS_FLAGS +CVS_FLAGS = +endif + +CVS_CMD = cvs $(CVS_FLAGS) +TARGETS = export libs install +LDAP_MODULE = DirectorySDKSource + + +# +# Environment variables. +# +ifdef MOZ_DATE +CVS_BRANCH = -D "$(MOZ_DATE)" +endif + +ifdef MOZ_BRANCH +CVS_BRANCH = -r $(MOZ_BRANCH) +endif + + +ifndef MOZ_LDAPVER +MOZ_LDAPVER = -r LDAPCSDK_40_BRANCH +endif + + +all: setup build + +.PHONY: all setup build + +setup: +ifdef LDAP_MODULE + $(CVS_CMD) -q co $(MOZ_LDAPVER) $(LDAP_MODULE) +endif + +build: + cd ../nsprpub/config; $(MAKE) + $(MAKE) $(TARGETS) + + +clean: + $(MAKE) clean
View file
mozldap.dsc
Changed
@@ -2,7 +2,7 @@ Source: mozilla-ldap-sdk Binary: mozldap-tools, libmozldap-0d, libmozldap-dev, libmozldap-0d-dbg Architecture: any -Version: 6.0.5-3 +Version: 6.0.7-1 Maintainer: Michele Baldessari <michele@acksyn.org> Uploaders: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>, Paul Klos <kolab@klos2day.nl> Homepage: http://wiki.mozilla.org/LDAP_C_SDK @@ -17,5 +17,5 @@ libmozldap-dev deb libdevel optional mozldap-tools deb libs optional Files: - 00000000000000000000000000000000 0 mozldap-6.0.5.tar.gz + 00000000000000000000000000000000 0 mozldap-6.0.7.tar.gz 00000000000000000000000000000000 0 debian.tar.gz
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.