]> git.sur5r.net Git - openldap/commitdiff
Merge in all devel changes since 2.0-alpha2.
authorKurt Zeilenga <kurt@openldap.org>
Fri, 10 Sep 1999 22:25:02 +0000 (22:25 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 10 Sep 1999 22:25:02 +0000 (22:25 +0000)
Move OPENLDAP_REL_ENG_2_MP forward.

505 files changed:
Makefile.in [new file with mode: 0644]
acconfig.h [new file with mode: 0644]
acinclude.m4 [new file with mode: 0644]
aclocal.m4 [new file with mode: 0644]
build/db.2.x.README [new file with mode: 0644]
build/dir.mk
build/info.mk [new file with mode: 0644]
build/install-sh [new file with mode: 0755]
build/lib-shared.mk [new file with mode: 0644]
build/lib-static.mk [new file with mode: 0644]
build/lib.mk [new file with mode: 0644]
build/man.mk
build/mkdep
build/mkrelease
build/mkversion [new file with mode: 0755]
build/mod.mk
build/openldap.m4
build/rules.mk
build/srv.mk
build/top.mk
build/version
clients/Makefile.in [new file with mode: 0644]
clients/fax500/Makefile.in
clients/fax500/fax500.h [new file with mode: 0644]
clients/fax500/faxtotpc.c
clients/fax500/main.c
clients/fax500/rp500.c
clients/finger/Makefile.in
clients/finger/main.c
clients/gopher/Makefile.in
clients/gopher/go500.c
clients/gopher/go500gw.c
clients/mail500/Makefile.in
clients/mail500/main.c
clients/rcpt500/Makefile.in
clients/rcpt500/cmds.c
clients/rcpt500/help.c
clients/rcpt500/main.c
clients/rcpt500/query.c
clients/rcpt500/rcpt500.h
clients/tools/Makefile.in
clients/tools/ldapdelete.c
clients/tools/ldapmodify.c
clients/tools/ldapmodrdn.c
clients/tools/ldappasswd.c
clients/tools/ldapsearch.c
clients/ud/Makefile.in
clients/ud/auth.c
clients/ud/edit.c
clients/ud/find.c
clients/ud/globals.c
clients/ud/group.c
clients/ud/help.c
clients/ud/main.c
clients/ud/mod.c
clients/ud/print.c
clients/ud/string_to_key.c
clients/ud/ud.h
clients/ud/util.c
configure
configure.in
doc/Makefile.in [new file with mode: 0644]
doc/man/man5/ldap.conf.5 [new file with mode: 0644]
doc/man/man8/slapd.8
doc/man/man8/slurpd.8
include/Makefile.in
include/ac/alloca.h [new file with mode: 0644]
include/ac/assert.h
include/ac/bytes.h [new file with mode: 0644]
include/ac/ctype.h [new file with mode: 0644]
include/ac/dirent.h [new file with mode: 0644]
include/ac/errno.h [new file with mode: 0644]
include/ac/krb.h [new file with mode: 0644]
include/ac/regex.h [new file with mode: 0644]
include/ac/setproctitle.h [new file with mode: 0644]
include/ac/signal.h [new file with mode: 0644]
include/ac/socket.h
include/ac/stdarg.h [new file with mode: 0644]
include/ac/stdlib.h
include/ac/string.h [new file with mode: 0644]
include/ac/sysexits.h [new file with mode: 0644]
include/ac/syslog.h [new file with mode: 0644]
include/ac/termios.h [new file with mode: 0644]
include/ac/time.h [new file with mode: 0644]
include/ac/unistd.h [new file with mode: 0644]
include/ac/wait.h [new file with mode: 0644]
include/avl.h
include/disptmpl.h
include/getopt-compat.h [new file with mode: 0644]
include/lber.h
include/lber_pvt.h [new file with mode: 0644]
include/lber_types.h.in [new file with mode: 0644]
include/lber_types.nt [new file with mode: 0644]
include/ldap.h
include/ldap_cdefs.h [new file with mode: 0644]
include/ldap_config.h.in [new file with mode: 0644]
include/ldap_config.nt [new file with mode: 0644]
include/ldap_defaults.h [new file with mode: 0644]
include/ldap_features.h.in [new file with mode: 0644]
include/ldap_features.nt [new file with mode: 0644]
include/ldap_log.h [new file with mode: 0644]
include/ldap_pvt.h
include/ldap_pvt_thread.h [new file with mode: 0644]
include/ldap_schema.h
include/ldbm.h
include/ldif.h
include/lutil.h
include/lutil_lockf.h [new file with mode: 0644]
include/lutil_md5.h [new file with mode: 0644]
include/lutil_sha1.h [new file with mode: 0644]
include/portable.h.in
include/portable.nt [new file with mode: 0644]
include/setup.dsp [new file with mode: 0644]
include/setup.mak
include/srchpref.h
include/sysexits-compat.h
libraries/Makefile.in [new file with mode: 0644]
libraries/libavl/Makefile.in [new file with mode: 0644]
libraries/libavl/avl.c
libraries/libavl/testavl.c
libraries/liblber/Makefile.in [new file with mode: 0644]
libraries/liblber/assert.c
libraries/liblber/bprint.c
libraries/liblber/decode.c
libraries/liblber/dtest.c
libraries/liblber/encode.c
libraries/liblber/etest.c
libraries/liblber/idtest.c
libraries/liblber/io.c
libraries/liblber/lber-int.h
libraries/liblber/memory.c [new file with mode: 0644]
libraries/liblber/options.c [new file with mode: 0644]
libraries/liblber/sockbuf.c
libraries/libldap/Makefile.in
libraries/libldap/abandon.c
libraries/libldap/add.c
libraries/libldap/addentry.c
libraries/libldap/apitest.c
libraries/libldap/bind.c
libraries/libldap/cache.c
libraries/libldap/charray.c [new file with mode: 0644]
libraries/libldap/charset.c
libraries/libldap/cldap.c
libraries/libldap/compare.c
libraries/libldap/controls.c [new file with mode: 0644]
libraries/libldap/delete.c
libraries/libldap/digest.c
libraries/libldap/disptmpl.c
libraries/libldap/dn.c [new file with mode: 0644]
libraries/libldap/dsparse.c
libraries/libldap/error.c
libraries/libldap/extended.c [new file with mode: 0644]
libraries/libldap/free.c
libraries/libldap/friendly.c
libraries/libldap/getattr.c
libraries/libldap/getdn.c
libraries/libldap/getdxbyname.c
libraries/libldap/getentry.c
libraries/libldap/getfilter.c
libraries/libldap/getvalues.c
libraries/libldap/init.c
libraries/libldap/kbind.c
libraries/libldap/ldap-int.h
libraries/libldap/ldap.conf [new file with mode: 0644]
libraries/libldap/ldapfilter.conf
libraries/libldap/ldapsearchprefs.conf
libraries/libldap/ldaptemplates.conf
libraries/libldap/libldap.dsp [new file with mode: 0644]
libraries/libldap/messages.c [new file with mode: 0644]
libraries/libldap/modify.c
libraries/libldap/modrdn.c
libraries/libldap/open.c
libraries/libldap/options.c
libraries/libldap/os-ip.c
libraries/libldap/print.c [new file with mode: 0644]
libraries/libldap/references.c [new file with mode: 0644]
libraries/libldap/request.c
libraries/libldap/result.c
libraries/libldap/sasl.c [new file with mode: 0644]
libraries/libldap/sbind.c
libraries/libldap/schema.c
libraries/libldap/search.c
libraries/libldap/sort.c
libraries/libldap/srchpref.c
libraries/libldap/string.c [new file with mode: 0644]
libraries/libldap/test.c
libraries/libldap/tls.c
libraries/libldap/tmplout.c
libraries/libldap/tmpltest.c
libraries/libldap/ufn.c
libraries/libldap/unbind.c
libraries/libldap/url.c
libraries/libldap/util-int.c [new file with mode: 0644]
libraries/libldap_r/Makefile.in
libraries/libldap_r/rdwr.c [new file with mode: 0644]
libraries/libldap_r/thr_cthreads.c
libraries/libldap_r/thr_lwp.c [new file with mode: 0644]
libraries/libldap_r/thr_nt.c [new file with mode: 0644]
libraries/libldap_r/thr_posix.c [new file with mode: 0644]
libraries/libldap_r/thr_pth.c [new file with mode: 0644]
libraries/libldap_r/thr_sleep.c [new file with mode: 0644]
libraries/libldap_r/thr_stub.c [new file with mode: 0644]
libraries/libldap_r/thr_thr.c [new file with mode: 0644]
libraries/libldbm/Makefile.in [new file with mode: 0644]
libraries/libldbm/ldbm.c
libraries/libldif/Makefile.in
libraries/libldif/fetch.c
libraries/libldif/line64.c
libraries/liblutil/Makefile.in
libraries/liblutil/base64.c
libraries/liblutil/debug.c
libraries/liblutil/detach.c
libraries/liblutil/getopt.c
libraries/liblutil/getpass.c
libraries/liblutil/liblutil.dsp
libraries/liblutil/lockf.c [new file with mode: 0644]
libraries/liblutil/md5.c
libraries/liblutil/memcmp.c [new file with mode: 0644]
libraries/liblutil/nt_err.c [new file with mode: 0644]
libraries/liblutil/ntservice.c
libraries/liblutil/passwd.c
libraries/liblutil/setproctitle.c [new file with mode: 0644]
libraries/liblutil/sha1.c
libraries/liblutil/sockpair.c [new file with mode: 0644]
libraries/liblutil/tempnam.c [new file with mode: 0644]
libraries/liblutil/utils.c
servers/Makefile.in
servers/slapd/Makefile.in
servers/slapd/abandon.c
servers/slapd/acl.c
servers/slapd/aclparse.c
servers/slapd/add.c
servers/slapd/attr.c
servers/slapd/ava.c
servers/slapd/back-bdb2/Makefile.in
servers/slapd/back-bdb2/abandon.c [new file with mode: 0644]
servers/slapd/back-bdb2/add.c
servers/slapd/back-bdb2/alias.c [new file with mode: 0644]
servers/slapd/back-bdb2/attr.c [new file with mode: 0644]
servers/slapd/back-bdb2/back-bdb2.h
servers/slapd/back-bdb2/bind.c [new file with mode: 0644]
servers/slapd/back-bdb2/cache.c [new file with mode: 0644]
servers/slapd/back-bdb2/close.c
servers/slapd/back-bdb2/compare.c [new file with mode: 0644]
servers/slapd/back-bdb2/config.c [new file with mode: 0644]
servers/slapd/back-bdb2/dbcache.c
servers/slapd/back-bdb2/delete.c
servers/slapd/back-bdb2/dn2id.c
servers/slapd/back-bdb2/entry.c [new file with mode: 0644]
servers/slapd/back-bdb2/external.h
servers/slapd/back-bdb2/filterindex.c
servers/slapd/back-bdb2/group.c [new file with mode: 0644]
servers/slapd/back-bdb2/id2children.c
servers/slapd/back-bdb2/id2entry.c
servers/slapd/back-bdb2/idl.c
servers/slapd/back-bdb2/index.c
servers/slapd/back-bdb2/init.c
servers/slapd/back-bdb2/kerberos.c [new file with mode: 0644]
servers/slapd/back-bdb2/modify.c
servers/slapd/back-bdb2/modrdn.c [new file with mode: 0644]
servers/slapd/back-bdb2/nextid.c
servers/slapd/back-bdb2/porter.c
servers/slapd/back-bdb2/proto-back-bdb2.h
servers/slapd/back-bdb2/search.c
servers/slapd/back-bdb2/startup.c [new file with mode: 0644]
servers/slapd/back-bdb2/timing.c [new file with mode: 0644]
servers/slapd/back-bdb2/tools.c
servers/slapd/back-bdb2/txn.c
servers/slapd/back-bdb2/txn.h
servers/slapd/back-bdb2/unbind.c [new file with mode: 0644]
servers/slapd/back-ldap/Makefile.in
servers/slapd/back-ldap/add.c [new file with mode: 0644]
servers/slapd/back-ldap/back-ldap.h [new file with mode: 0644]
servers/slapd/back-ldap/bind.c [new file with mode: 0644]
servers/slapd/back-ldap/compare.c [new file with mode: 0644]
servers/slapd/back-ldap/config.c [new file with mode: 0644]
servers/slapd/back-ldap/delete.c [new file with mode: 0644]
servers/slapd/back-ldap/external.h [new file with mode: 0644]
servers/slapd/back-ldap/init.c
servers/slapd/back-ldap/modify.c [new file with mode: 0644]
servers/slapd/back-ldap/modrdn.c [new file with mode: 0644]
servers/slapd/back-ldap/search.c [new file with mode: 0644]
servers/slapd/back-ldap/unbind.c [new file with mode: 0644]
servers/slapd/back-ldbm/Makefile.in
servers/slapd/back-ldbm/abandon.c
servers/slapd/back-ldbm/add.c
servers/slapd/back-ldbm/alias.c [new file with mode: 0644]
servers/slapd/back-ldbm/attr.c
servers/slapd/back-ldbm/back-ldbm.h
servers/slapd/back-ldbm/bind.c
servers/slapd/back-ldbm/cache.c
servers/slapd/back-ldbm/close.c
servers/slapd/back-ldbm/compare.c
servers/slapd/back-ldbm/config.c
servers/slapd/back-ldbm/dbcache.c
servers/slapd/back-ldbm/delete.c
servers/slapd/back-ldbm/dn2id.c
servers/slapd/back-ldbm/entry.c
servers/slapd/back-ldbm/external.h
servers/slapd/back-ldbm/filterindex.c
servers/slapd/back-ldbm/group.c
servers/slapd/back-ldbm/id2children.c
servers/slapd/back-ldbm/id2entry.c
servers/slapd/back-ldbm/idl.c
servers/slapd/back-ldbm/index.c
servers/slapd/back-ldbm/init.c
servers/slapd/back-ldbm/kerberos.c
servers/slapd/back-ldbm/modify.c
servers/slapd/back-ldbm/modrdn.c
servers/slapd/back-ldbm/nextid.c
servers/slapd/back-ldbm/proto-back-ldbm.h
servers/slapd/back-ldbm/search.c
servers/slapd/back-ldbm/startup.c
servers/slapd/back-ldbm/tools.c
servers/slapd/back-ldbm/unbind.c
servers/slapd/back-passwd/Makefile.in
servers/slapd/back-passwd/config.c
servers/slapd/back-passwd/external.h [new file with mode: 0644]
servers/slapd/back-passwd/init.c
servers/slapd/back-passwd/search.c
servers/slapd/back-perl/Makefile.in
servers/slapd/back-perl/add.c
servers/slapd/back-perl/bind.c [new file with mode: 0644]
servers/slapd/back-perl/close.c [new file with mode: 0644]
servers/slapd/back-perl/compare.c [new file with mode: 0644]
servers/slapd/back-perl/config.c
servers/slapd/back-perl/delete.c [new file with mode: 0644]
servers/slapd/back-perl/external.h [new file with mode: 0644]
servers/slapd/back-perl/init.c
servers/slapd/back-perl/modify.c [new file with mode: 0644]
servers/slapd/back-perl/modrdn.c [new file with mode: 0644]
servers/slapd/back-perl/perl_back.h [new file with mode: 0644]
servers/slapd/back-perl/search.c [new file with mode: 0644]
servers/slapd/back-perl/unbind.c [new file with mode: 0644]
servers/slapd/back-shell/Makefile.in
servers/slapd/back-shell/abandon.c
servers/slapd/back-shell/add.c
servers/slapd/back-shell/bind.c
servers/slapd/back-shell/compare.c
servers/slapd/back-shell/config.c
servers/slapd/back-shell/delete.c
servers/slapd/back-shell/external.h [new file with mode: 0644]
servers/slapd/back-shell/fork.c
servers/slapd/back-shell/init.c
servers/slapd/back-shell/modify.c
servers/slapd/back-shell/modrdn.c
servers/slapd/back-shell/result.c
servers/slapd/back-shell/search.c
servers/slapd/back-shell/shell.h
servers/slapd/back-shell/unbind.c
servers/slapd/back-tcl/Makefile.in
servers/slapd/back-tcl/external.h [new file with mode: 0644]
servers/slapd/back-tcl/tcl_abandon.c [new file with mode: 0644]
servers/slapd/back-tcl/tcl_add.c
servers/slapd/back-tcl/tcl_back.h [new file with mode: 0644]
servers/slapd/back-tcl/tcl_bind.c
servers/slapd/back-tcl/tcl_close.c [new file with mode: 0644]
servers/slapd/back-tcl/tcl_compare.c
servers/slapd/back-tcl/tcl_config.c [new file with mode: 0644]
servers/slapd/back-tcl/tcl_delete.c
servers/slapd/back-tcl/tcl_init.c
servers/slapd/back-tcl/tcl_modify.c
servers/slapd/back-tcl/tcl_modrdn.c
servers/slapd/back-tcl/tcl_search.c
servers/slapd/back-tcl/tcl_unbind.c [new file with mode: 0644]
servers/slapd/back-tcl/tcl_util.c
servers/slapd/backend.c
servers/slapd/bind.c
servers/slapd/ch_malloc.c
servers/slapd/charray.c
servers/slapd/compare.c
servers/slapd/config.c
servers/slapd/configinfo.c
servers/slapd/connection.c
servers/slapd/controls.c
servers/slapd/daemon.c
servers/slapd/delete.c
servers/slapd/dn.c
servers/slapd/entry.c
servers/slapd/extended.c [new file with mode: 0644]
servers/slapd/filter.c
servers/slapd/filterentry.c
servers/slapd/init.c
servers/slapd/lock.c
servers/slapd/main.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/module.c
servers/slapd/monitor.c
servers/slapd/nt_svc.c [new file with mode: 0644]
servers/slapd/operation.c
servers/slapd/phonetic.c
servers/slapd/proto-slap.h
servers/slapd/repl.c
servers/slapd/result.c
servers/slapd/root_dse.c
servers/slapd/sasl.c
servers/slapd/schema.c
servers/slapd/schema/core.schema
servers/slapd/schema/internet_mail.at.conf [new file with mode: 0644]
servers/slapd/schema/internet_mail.oc.conf [new file with mode: 0644]
servers/slapd/schema/misc.schema
servers/slapd/schema/nadf.schema [new file with mode: 0644]
servers/slapd/schema/nis.at.conf [new file with mode: 0644]
servers/slapd/schema/nis.oc.conf [new file with mode: 0644]
servers/slapd/schema/nis.schema [new file with mode: 0644]
servers/slapd/schema/others_nis.at.conf [new file with mode: 0644]
servers/slapd/schema/others_nis.oc.conf [new file with mode: 0644]
servers/slapd/schema/pilot.schema
servers/slapd/schemaparse.c
servers/slapd/search.c
servers/slapd/shell-backends/Makefile.in [new file with mode: 0644]
servers/slapd/shell-backends/passwd-shell.c
servers/slapd/shell-backends/passwd-shell.h
servers/slapd/shell-backends/pwd-Version.c
servers/slapd/shell-backends/shellutil.c
servers/slapd/shell-backends/shellutil.h
servers/slapd/slap.h
servers/slapd/slapd.at.conf
servers/slapd/slapd.conf
servers/slapd/slapd.oc.conf
servers/slapd/str2filter.c
servers/slapd/suffixalias.c [new file with mode: 0644]
servers/slapd/tools/Makefile.in
servers/slapd/tools/centipede.c
servers/slapd/tools/chlog2replog.c
servers/slapd/tools/edb2ldif.c
servers/slapd/tools/ldapsyntax.c
servers/slapd/tools/ldapsyntax.h
servers/slapd/tools/ldbmtest.c
servers/slapd/tools/ldif.c
servers/slapd/tools/mimic.c
servers/slapd/tools/sizecount.c
servers/slapd/tools/slapadd.c
servers/slapd/tools/slapcat.c
servers/slapd/tools/slapcommon.c
servers/slapd/tools/slapcommon.h
servers/slapd/tools/slapindex.c
servers/slapd/unbind.c
servers/slapd/user.c
servers/slapd/value.c
servers/slurpd/Makefile.in
servers/slurpd/admin.c
servers/slurpd/args.c
servers/slurpd/ch_malloc.c
servers/slurpd/config.c
servers/slurpd/fm.c
servers/slurpd/globals.c
servers/slurpd/globals.h
servers/slurpd/ldap_op.c
servers/slurpd/lock.c
servers/slurpd/main.c
servers/slurpd/proto-slurp.h
servers/slurpd/re.c
servers/slurpd/reject.c
servers/slurpd/replica.c
servers/slurpd/replog.c
servers/slurpd/ri.c
servers/slurpd/rq.c
servers/slurpd/sanity.c
servers/slurpd/slurp.h
servers/slurpd/st.c
tests/Makefile.in
tests/data/acl.out.master
tests/data/modify.out.master
tests/data/modrdn.out.master
tests/data/modrdn.out.master.0
tests/data/search.out.master
tests/data/slapd-acl.conf
tests/data/slapd-bdb2-acl.conf [new file with mode: 0644]
tests/data/slapd-bdb2-master.conf [new file with mode: 0644]
tests/data/slapd-bdb2-nis-master.conf [new file with mode: 0644]
tests/data/slapd-bdb2-ref-slave.conf [new file with mode: 0644]
tests/data/slapd-bdb2-repl-master.conf [new file with mode: 0644]
tests/data/slapd-bdb2-repl-slave.conf [new file with mode: 0644]
tests/data/slapd-master.conf
tests/data/slapd-nis-master.conf [new file with mode: 0644]
tests/data/slapd-passwd.conf [new file with mode: 0644]
tests/data/slapd-ref-slave.conf [new file with mode: 0644]
tests/data/slapd-repl-master.conf
tests/data/slapd-repl-slave.conf
tests/data/slapd.at.conf
tests/data/slapd.oc.conf
tests/data/test-ordered.ldif
tests/data/test.ldif
tests/progs/Makefile.in
tests/progs/slapd-addel.c
tests/progs/slapd-read.c
tests/progs/slapd-search.c
tests/progs/slapd-tester.c
tests/scripts/acfilter.sh [new file with mode: 0755]
tests/scripts/all
tests/scripts/defines.sh
tests/scripts/makeldbm.sh
tests/scripts/passwd-search [new file with mode: 0755]
tests/scripts/startup_nis_ldap_server.sh
tests/scripts/test001-ldif2ldbm [deleted file]
tests/scripts/test002-populate
tests/scripts/test003-search
tests/scripts/test004-modify
tests/scripts/test005-modrdn
tests/scripts/test006-acls
tests/scripts/test007-replication
tests/scripts/test008-concurrency
tests/scripts/test009-referral

diff --git a/Makefile.in b/Makefile.in
new file mode 100644 (file)
index 0000000..a4c7025
--- /dev/null
@@ -0,0 +1,30 @@
+# $OpenLDAP$
+# Master Makefile for OpenLDAP
+##
+## Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+## All rights reserved.
+##
+## Redistribution and use in source and binary forms are permitted only
+## as authorized by the OpenLDAP Public License.  A copy of this
+## license is available at http://www.OpenLDAP.org/license.html or
+## in file LICENSE in the top-level directory of the distribution.
+##
+
+SUBDIRS= include libraries clients servers tests doc
+CLEANDIRS= contrib
+INSTALLDIRS= 
+
+makefiles:     FORCE
+       ./config.status
+
+# force a make all before make install
+#      only done at the top-level
+install-common: all FORCE
+
+clean-local: FORCE
+       $(RM) config.log
+
+veryclean-local: FORCE
+       $(RM) config.cache config.status libtool stamp-h stamp-h.in
+
+distclean: veryclean FORCE
diff --git a/acconfig.h b/acconfig.h
new file mode 100644 (file)
index 0000000..9c89097
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _LDAP_PORTABLE_H
+#define _LDAP_PORTABLE_H
+
+/* end of preamble */
+@TOP@
+
+/* define this if needed to get reentrant functions */
+#ifndef REENTRANT
+#undef REENTRANT
+#endif
+#ifndef _REENTRANT
+#undef _REENTRANT
+#endif
+
+/* define this if needed to get threadsafe functions */
+#ifndef THREADSAFE
+#undef THREADSAFE
+#endif
+#ifndef _THREADSAFE
+#undef _THREADSAFE
+#endif
+#ifndef THREAD_SAFE
+#undef THREAD_SAFE
+#endif
+#ifndef _THREAD_SAFE
+#undef _THREAD_SAFE
+#endif
+
+#ifndef _SGI_MP_SOURCE
+#undef _SGI_MP_SOURCE
+#endif
+
+/* define this if TIOCGWINSZ is defined in sys/ioctl.h */
+#undef GWINSZ_IN_SYS_IOCTL
+
+/* These are defined in ldap_features.h */
+/*
+       LDAP_API_FEATURE_X_OPENLDAP_REENTRANT
+       LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
+       LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
+       LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
+*/
+
+/* These are defined in lber_types.h */
+/*
+       LBER_INT_T
+       LBER_LEN_T
+       LBER_SOCKET_T
+       LBER_TAG_T
+*/
+
+\f
+/* Leave that blank line there!!  Autoheader needs it. */
+
+@BOTTOM@
+/* begin of postamble */
+
+#ifndef __NEED_PROTOTYPES
+/* force LDAP_P to always include prototypes */
+#define __NEED_PROTOTYPES 1
+#endif
+
+#ifdef HAVE_STDDEF_H
+#      include <stddef.h>
+#endif
+
+#if defined(LDAP_DEVEL) && !defined(LDAP_TEST)
+#define LDAP_TEST
+#endif
+#if defined(LDAP_TEST) && !defined(LDAP_DEBUG)
+#define LDAP_DEBUG
+#endif
+
+#include "ldap_cdefs.h"
+#include "ldap_features.h"
+
+#include "ac/assert.h"
+
+#endif /* _LDAP_PORTABLE_H */
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644 (file)
index 0000000..35f9931
--- /dev/null
@@ -0,0 +1,8 @@
+dnl $OpenLDAP$
+dnl
+dnl Copyright 1998-1999 The OpenLDAP Foundation,  All Rights Reserved.
+dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file
+dnl
+dnl OpenLDAP Autoconf Macros
+dnl
+builtin(include, build/openldap.m4)dnl
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644 (file)
index 0000000..008ce71
--- /dev/null
@@ -0,0 +1,695 @@
+dnl aclocal.m4 generated automatically by aclocal 1.4a
+
+dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+dnl PARTICULAR PURPOSE.
+
+dnl $OpenLDAP$
+dnl
+dnl Copyright 1998-1999 The OpenLDAP Foundation,  All Rights Reserved.
+dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file
+dnl
+dnl OpenLDAP Autoconf Macros
+dnl
+builtin(include, build/openldap.m4)dnl
+
+# Do all the work for Automake.  This macro actually does too much --
+# some checks are only needed if your package does certain things.
+# But this isn't really a big deal.
+
+# serial 1
+
+dnl Usage:
+dnl AM_INIT_AUTOMAKE(package,version, [no-define])
+
+AC_DEFUN(AM_INIT_AUTOMAKE,
+[AC_REQUIRE([AC_PROG_INSTALL])
+dnl We require 2.13 because we rely on SHELL being computed by configure.
+AC_PREREQ([2.13])
+PACKAGE=[$1]
+AC_SUBST(PACKAGE)
+VERSION=[$2]
+AC_SUBST(VERSION)
+dnl test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+ifelse([$3],,
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
+AC_REQUIRE([AM_SANITY_CHECK])
+AC_REQUIRE([AC_ARG_PROGRAM])
+dnl FIXME This is truly gross.
+missing_dir=`cd $ac_aux_dir && pwd`
+AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
+AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
+AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
+AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
+AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
+dnl Set install_sh for make dist
+install_sh="$missing_dir/install-sh"
+test -f "$install_sh" || install_sh="$missing_dir/install.sh"
+AC_SUBST(install_sh)
+dnl We check for tar when the user configures the end package.
+dnl This is sad, since we only need this for "dist".  However,
+dnl there's no other good way to do it.  We prefer GNU tar if
+dnl we can find it.  If we can't find a tar, it doesn't really matter.
+AC_CHECK_PROGS(AMTAR, gnutar gtar tar)
+dnl We need awk for the "check" target.  The system "awk" is bad on
+dnl some platforms.
+AC_REQUIRE([AC_PROG_AWK])
+AMTARFLAGS=
+if test -n "$AMTAR"; then
+  if $SHELL -c "$AMTAR --version" > /dev/null 2>&1; then
+    dnl We have GNU tar.
+    AMTARFLAGS=o
+  fi
+fi
+AC_SUBST(AMTARFLAGS)
+AC_REQUIRE([AC_PROG_MAKE_SET])])
+
+#
+# Check to make sure that the build environment is sane.
+#
+
+AC_DEFUN(AM_SANITY_CHECK,
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+   if test "[$]*" = "X"; then
+      # -L didn't work.
+      set X `ls -t $srcdir/configure conftestfile`
+   fi
+   if test "[$]*" != "X $srcdir/configure conftestfile" \
+      && test "[$]*" != "X conftestfile $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+alias in your environment])
+   fi
+
+   test "[$]2" = conftestfile
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+rm -f conftest*
+AC_MSG_RESULT(yes)])
+
+dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
+dnl The program must properly implement --version.
+AC_DEFUN(AM_MISSING_PROG,
+[AC_MSG_CHECKING(for working $2)
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf.  Sigh.
+if ($2 --version) < /dev/null > /dev/null 2>&1; then
+   $1=$2
+   AC_MSG_RESULT(found)
+else
+   $1="$3/missing $2"
+   AC_MSG_RESULT(missing)
+fi
+AC_SUBST($1)])
+
+
+# serial 40 AC_PROG_LIBTOOL
+AC_DEFUN(AC_PROG_LIBTOOL,
+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+
+# Save cache, so that ltconfig can load it
+AC_CACHE_SAVE
+
+# Actually configure libtool.  ac_aux_dir is where install-sh is found.
+CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
+LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
+LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
+DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
+${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
+|| AC_MSG_ERROR([libtool configure failed])
+
+# Reload cache, that may have been modified by ltconfig
+AC_CACHE_LOAD
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+# Redirect the config.log output again, so that the ltconfig log is not
+# clobbered by the next message.
+exec 5>>./config.log
+])
+
+AC_DEFUN(AC_LIBTOOL_SETUP,
+[AC_PREREQ(2.13)dnl
+AC_REQUIRE([AC_ENABLE_SHARED])dnl
+AC_REQUIRE([AC_ENABLE_STATIC])dnl
+AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_RANLIB])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_LD])dnl
+AC_REQUIRE([AC_PROG_NM])dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+dnl
+
+# Check for any special flags to pass to ltconfig.
+libtool_flags="--cache-file=$cache_file"
+test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
+test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
+test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
+test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
+test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
+ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
+[libtool_flags="$libtool_flags --enable-dlopen"])
+ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
+[libtool_flags="$libtool_flags --enable-win32-dll"])
+AC_ARG_ENABLE(libtool-lock,
+  [  --disable-libtool-lock  avoid locking (might break parallel builds)])
+test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
+test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case "$host" in
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case "`/usr/bin/file conftest.o`" in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+
+ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
+[*-*-cygwin* | *-*-mingw*)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+])
+esac
+])
+
+# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
+AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
+
+# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
+AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
+
+# AC_ENABLE_SHARED - implement the --enable-shared flag
+# Usage: AC_ENABLE_SHARED[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_SHARED, [dnl
+define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(shared,
+changequote(<<, >>)dnl
+<<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+  enable_shared=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_shared=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
+])
+
+# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
+AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_SHARED(no)])
+
+# AC_ENABLE_STATIC - implement the --enable-static flag
+# Usage: AC_ENABLE_STATIC[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_STATIC, [dnl
+define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(static,
+changequote(<<, >>)dnl
+<<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+  enable_static=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_static=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
+])
+
+# AC_DISABLE_STATIC - set the default static flag to --disable-static
+AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_STATIC(no)])
+
+
+# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
+# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
+define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(fast-install,
+changequote(<<, >>)dnl
+<<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_fast_install=yes ;;
+no) enable_fast_install=no ;;
+*)
+  enable_fast_install=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_fast_install=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
+])
+
+# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
+AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_FAST_INSTALL(no)])
+
+# AC_PROG_LD - find the path to the GNU or non-GNU linker
+AC_DEFUN(AC_PROG_LD,
+[AC_ARG_WITH(gnu-ld,
+[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+ac_prog=ld
+if test "$ac_cv_prog_gcc" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by GCC])
+  ac_prog=`($CC -print-prog-name=ld) 2>&5`
+  case "$ac_prog" in
+    # Accept absolute paths.
+changequote(,)dnl
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+changequote([,])dnl
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(ac_cv_path_LD,
+[if test -z "$LD"; then
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      ac_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+       test "$with_gnu_ld" != no && break
+      else
+       test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  ac_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$ac_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_SUBST(LD)
+AC_PROG_LD_GNU
+])
+
+AC_DEFUN(AC_PROG_LD_GNU,
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  ac_cv_prog_gnu_ld=yes
+else
+  ac_cv_prog_gnu_ld=no
+fi])
+])
+
+# AC_PROG_NM - find the path to a BSD-compatible name lister
+AC_DEFUN(AC_PROG_NM,
+[AC_MSG_CHECKING([for BSD-compatible nm])
+AC_CACHE_VAL(ac_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  ac_cv_path_NM="$NM"
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+       ac_cv_path_NM="$ac_dir/nm -B"
+       break
+      elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+       ac_cv_path_NM="$ac_dir/nm -p"
+       break
+      else
+       ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
+       continue # so that we can try to find one that supports BSD flags
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
+fi])
+NM="$ac_cv_path_NM"
+AC_MSG_RESULT([$NM])
+AC_SUBST(NM)
+])
+
+# AC_CHECK_LIBM - check for math library
+AC_DEFUN(AC_CHECK_LIBM,
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case "$host" in
+*-*-beos* | *-*-cygwin*)
+  # These system don't have libm
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, main, LIBM="-lm")
+  ;;
+esac
+])
+
+# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl convenience library, adds --enable-ltdl-convenience to
+# the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
+# is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
+# to be `${top_builddir}/libltdl'.  Make sure you start DIR with
+# '${top_builddir}/' (note the single quotes!) if your package is not
+# flat, and, if you're not using automake, define top_builddir as
+# appropriate in the Makefiles.
+AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  case "$enable_ltdl_convenience" in
+  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+  "") enable_ltdl_convenience=yes
+      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
+  esac
+  LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
+  INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
+])
+
+# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl installable library, and adds --enable-ltdl-install to
+# the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
+# is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
+# to be `${top_builddir}/libltdl'.  Make sure you start DIR with
+# '${top_builddir}/' (note the single quotes!) if your package is not
+# flat, and, if you're not using automake, define top_builddir as
+# appropriate in the Makefiles.
+# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  AC_CHECK_LIB(ltdl, main,
+  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+  [if test x"$enable_ltdl_install" = xno; then
+     AC_MSG_WARN([libltdl not installed, but installation disabled])
+   else
+     enable_ltdl_install=yes
+   fi
+  ])
+  if test x"$enable_ltdl_install" = x"yes"; then
+    ac_configure_args="$ac_configure_args --enable-ltdl-install"
+    LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
+    INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
+  else
+    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+    LIBLTDL="-lltdl"
+    INCLTDL=
+  fi
+])
+
+dnl old names
+AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
+AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
+AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
+AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
+AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
+AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
+AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
+
+dnl This is just to silence aclocal about the macro not being used
+ifelse([AC_DISABLE_FAST_INSTALL])dnl
+
+
+# serial 1
+
+# @defmac AC_PROG_CC_STDC
+# @maindex PROG_CC_STDC
+# @ovindex CC
+# If the C compiler in not in ANSI C mode by default, try to add an option
+# to output variable @code{CC} to make it so.  This macro tries various
+# options that select ANSI C on some system or another.  It considers the
+# compiler to be in ANSI C mode if it handles function prototypes correctly.
+#
+# If you use this macro, you should check after calling it whether the C
+# compiler has been set to accept ANSI C; if not, the shell variable
+# @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
+# code in ANSI C, you can make an un-ANSIfied copy of it by using the
+# program @code{ansi2knr}, which comes with Ghostscript.
+# @end defmac
+
+AC_DEFUN(AM_PROG_CC_STDC,
+[AC_REQUIRE([AC_PROG_CC])
+AC_BEFORE([$0], [AC_C_INLINE])
+AC_BEFORE([$0], [AC_C_CONST])
+dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
+dnl a magic option to avoid problems with ANSI preprocessor commands
+dnl like #elif.
+dnl FIXME: can't do this because then AC_AIX won't work due to a
+dnl circular dependency.
+dnl AC_BEFORE([$0], [AC_PROG_CPP])
+AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
+AC_CACHE_VAL(am_cv_prog_cc_stdc,
+[am_cv_prog_cc_stdc=no
+ac_save_CC="$CC"
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX                  -qlanglvl=ansi
+# Ultrix and OSF/1     -std1
+# HP-UX 10.20 and later        -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4                 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  AC_TRY_COMPILE(
+[#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+], [
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+],
+[am_cv_prog_cc_stdc="$ac_arg"; break])
+done
+CC="$ac_save_CC"
+])
+if test -z "$am_cv_prog_cc_stdc"; then
+  AC_MSG_RESULT([none needed])
+else
+  AC_MSG_RESULT($am_cv_prog_cc_stdc)
+fi
+case "x$am_cv_prog_cc_stdc" in
+  x|xno) ;;
+  *) CC="$CC $am_cv_prog_cc_stdc" ;;
+esac
+])
+
+dnl From Jim Meyering.
+
+# serial 1
+
+AC_DEFUN(AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL,
+[AC_REQUIRE([AM_SYS_POSIX_TERMIOS])
+ AC_CACHE_CHECK([whether use of TIOCGWINSZ requires sys/ioctl.h],
+               am_cv_sys_tiocgwinsz_needs_sys_ioctl_h,
+  [am_cv_sys_tiocgwinsz_needs_sys_ioctl_h=no
+
+  gwinsz_in_termios_h=no
+  if test $am_cv_sys_posix_termios = yes; then
+    AC_EGREP_CPP([yes],
+    [#include <sys/types.h>
+#     include <termios.h>
+#     ifdef TIOCGWINSZ
+        yes
+#     endif
+    ], gwinsz_in_termios_h=yes)
+  fi
+
+  if test $gwinsz_in_termios_h = no; then
+    AC_EGREP_CPP([yes],
+    [#include <sys/types.h>
+#     include <sys/ioctl.h>
+#     ifdef TIOCGWINSZ
+        yes
+#     endif
+    ], am_cv_sys_tiocgwinsz_needs_sys_ioctl_h=yes)
+  fi
+  ])
+  if test $am_cv_sys_tiocgwinsz_needs_sys_ioctl_h = yes; then
+    AC_DEFINE(GWINSZ_IN_SYS_IOCTL,1,
+              [Define if TIOCGWINSZ requires sys/ioctl.h])
+  fi
+])
+
+dnl From Jim Meyering.
+
+# serial 1
+
+AC_DEFUN(AM_SYS_POSIX_TERMIOS,
+[AC_CACHE_CHECK([POSIX termios], am_cv_sys_posix_termios,
+  [AC_TRY_LINK([#include <sys/types.h>
+#include <unistd.h>
+#include <termios.h>],
+  [/* SunOS 4.0.3 has termios.h but not the library calls.  */
+   tcgetattr(0, 0);],
+  am_cv_sys_posix_termios=yes,
+  am_cv_sys_posix_termios=no)])
+])
+
+# From Ulrich Drepper.
+
+# serial 1
+
+AC_DEFUN(AM_TYPE_PTRDIFF_T,
+  [AC_CACHE_CHECK([for ptrdiff_t], am_cv_type_ptrdiff_t,
+     [AC_TRY_COMPILE([#include <stddef.h>], [ptrdiff_t p],
+                    am_cv_type_ptrdiff_t=yes, am_cv_type_ptrdiff_t=no)])
+   if test $am_cv_type_ptrdiff_t = yes; then
+     AC_DEFINE(HAVE_PTRDIFF_T,1,[Define if system has ptrdiff_t type])
+   fi
+])
+
diff --git a/build/db.2.x.README b/build/db.2.x.README
new file mode 100644 (file)
index 0000000..0b6cfdb
--- /dev/null
@@ -0,0 +1,29 @@
+Berkeley DB version 2.x and OpenLDAP running threads
+====================================================
+
+Special care has to be taken when building Berkeley DB 2.x
+for use with OpenLDAP as an slapd backend.  If OpenLDAP is used
+with threads, so must Berkeley DB.   If OpenLDAP is built without
+threads, so must Berkeley DB.  In general, you should use
+the latest Sleepycat version.
+
+The configuration tool of Sleepycat's Berkeley DB will automatically
+set appropriate options on IRIX, OSF/1, and SUN Solaris platforms
+(version 2.3.16), as well as FreeBSD (version 2.7.5).  The options
+must be manually defined on other plaforms, e.g. on LINUX.
+
+On PC-LINUX (kernel version 2.0.35, linux kernel threads as imple-
+mented by libpthreads.so.1.60.4) with gcc as the standard compiler
+the environment variable CPPFLAGS must define -D_REENTRANT, while
+building the Berkeley DB package.
+
+DO NOT USE THE -ansi CFLAG, SINCE THEN THE DB PACKAGE'S CONFIGURE
+CANNOT FIND THE X86/GCC SPINLOCKS, WHICH ARE NEEDED FOR THREAD-
+SUPPORT WITH THE BERKELEY DB.
+
+Please check carefully if your platform is not mentioned above.
+
+The OpenLDAP configure tool will most probably find the correct
+configuration itself.   No special action has to be taken
+while building the OpenLDAP package.
+
index ebf4d813e75034d4c7af226bb60db3eedcf663a3..7f163fdc0d8aa50f87958088f8ee9075e031ab81 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ## Copyright 1998,1999 The OpenLDAP Foundation
 ## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
 ## of this package for details.
diff --git a/build/info.mk b/build/info.mk
new file mode 100644 (file)
index 0000000..df9d94d
--- /dev/null
@@ -0,0 +1,10 @@
+# $OpenLDAP$
+## Copyright 1998,1999 The OpenLDAP Foundation
+## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
+## of this package for details.
+##---------------------------------------------------------------------------
+##
+## Makefile Template for Non-Source Directories
+##
+
+Makefile: $(top_srcdir)/build/info.mk
diff --git a/build/install-sh b/build/install-sh
new file mode 100755 (executable)
index 0000000..c7348ec
--- /dev/null
@@ -0,0 +1,255 @@
+#! /bin/sh
+# $OpenLDAP$
+## Copyright 1998,1999 The OpenLDAP Foundation
+## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
+## of this package for details.
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission.  M.I.T. makes no representations about the
+# suitability of this software for any purpose.  It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+       -c) instcmd="$cpprog"
+           shift
+           continue;;
+
+       -d) dir_arg=true
+           shift
+           continue;;
+
+       -m) chmodcmd="$chmodprog $2"
+           shift
+           shift
+           continue;;
+
+       -o) chowncmd="$chownprog $2"
+           shift
+           shift
+           continue;;
+
+       -g) chgrpcmd="$chgrpprog $2"
+           shift
+           shift
+           continue;;
+
+       -s) stripcmd="$stripprog"
+           shift
+           continue;;
+
+       -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+           shift
+           continue;;
+
+       -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+           shift
+           continue;;
+
+       *)  if [ x"$src" = x ]
+           then
+               src=$1
+           else
+               # this colon is to work around a 386BSD /bin/sh bug
+               :
+               dst=$1
+           fi
+           shift
+           continue;;
+    esac
+done
+
+if [ x"$src" = x ]
+then
+       echo "install:  no input file specified"
+       exit 1
+else
+       true
+fi
+
+if [ x"$dir_arg" != x ]; then
+       dst=$src
+       src=""
+       
+       if [ -d $dst ]; then
+               instcmd=:
+               chmodcmd=""
+       else
+               instcmd=$mkdirprog
+       fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad 
+# if $src (and thus $dsttmp) contains '*'.
+
+       if [ -f $src -o -d $src ]
+       then
+               true
+       else
+               echo "install:  $src does not exist"
+               exit 1
+       fi
+       
+       if [ x"$dst" = x ]
+       then
+               echo "install:  no destination specified"
+               exit 1
+       else
+               true
+       fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+       if [ -d $dst ]
+       then
+               dst="$dst"/`basename $src`
+       else
+               true
+       fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+       '
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+       pathcomp="${pathcomp}${1}"
+       shift
+
+       if [ ! -d "${pathcomp}" ] ;
+        then
+               $mkdirprog "${pathcomp}"
+       else
+               true
+       fi
+
+       pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+       $doit $instcmd $dst &&
+
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+       if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+       if [ x"$transformarg" = x ] 
+       then
+               dstfile=`basename $dst`
+       else
+               dstfile=`basename $dst $transformbasename | 
+                       sed $transformarg`$transformbasename
+       fi
+
+# don't allow the sed command to completely eliminate the filename
+
+       if [ x"$dstfile" = x ] 
+       then
+               dstfile=`basename $dst`
+       else
+               true
+       fi
+
+# Make a temp file name in the proper directory.
+
+       dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+       $doit $instcmd $src $dsttmp &&
+
+       trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+       if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+       $doit $rmcmd -f $dstdir/$dstfile &&
+       $doit $mvcmd $dsttmp $dstdir/$dstfile 
+
+fi &&
+
+
+exit 0
diff --git a/build/lib-shared.mk b/build/lib-shared.mk
new file mode 100644 (file)
index 0000000..776972a
--- /dev/null
@@ -0,0 +1,25 @@
+# $OpenLDAP$
+## Copyright 1998,1999 The OpenLDAP Foundation
+## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
+## of this package for details.
+##---------------------------------------------------------------------------
+##
+## Makefile Template for Shared Libraries
+##
+
+COMPILE = $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c
+MKDEPFLAG = -l
+
+.SUFFIXES: .c .o .lo
+
+.c.lo:
+       $(COMPILE) $<
+
+$(LIBRARY):  version.lo
+       $(LTLIBLINK) -rpath $(libdir) -o $@ $(OBJS) version.lo
+       $(RM) ../$@;    \
+       (d=`$(PWD)` ; $(LN_S) `$(BASENAME) $$d`/$@ ../$@)
+       $(RM) ../`$(BASENAME) $@ .la`.a;        \
+       (d=`$(PWD)`; t=`$(BASENAME) $@ .la`.a; $(LN_S) `$(BASENAME) $$d`/.libs/$$t ../$$t)
+
+Makefile: $(top_srcdir)/build/lib-shared.mk
diff --git a/build/lib-static.mk b/build/lib-static.mk
new file mode 100644 (file)
index 0000000..ad0d146
--- /dev/null
@@ -0,0 +1,16 @@
+# $OpenLDAP$
+## Copyright 1998,1999 The OpenLDAP Foundation
+## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
+## of this package for details.
+##---------------------------------------------------------------------------
+##
+## Makefile Template for Static Libraries
+##
+
+$(LIBRARY): version.o
+       $(AR) ru $@ $(OBJS) version.o
+       @$(RANLIB) $@;  \
+       $(RM) ../$@;    \
+       (d=`$(PWD)` ; $(LN_S) `$(BASENAME) $$d`/$@ ../$@)
+
+Makefile: $(top_srcdir)/build/lib-static.mk
diff --git a/build/lib.mk b/build/lib.mk
new file mode 100644 (file)
index 0000000..9bf542d
--- /dev/null
@@ -0,0 +1,35 @@
+# $OpenLDAP$
+## Copyright 1998,1999 The OpenLDAP Foundation
+## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
+## of this package for details.
+##---------------------------------------------------------------------------
+##
+## Makefile Template for Libraries
+##
+
+all-common: $(LIBRARY) $(PROGRAMS)
+
+version.c: $(OBJS)
+       $(RM) $@
+       $(MKVERSION) $(LIBRARY) > $@
+
+install-common: FORCE
+
+lint: lint-local FORCE
+       $(LINT) $(DEFS) $(DEFINES) $(SRCS)
+
+lint5: lint5-local FORCE
+       $(5LINT) $(DEFS) $(DEFINES) $(SRCS)
+
+clean-common:  FORCE
+       $(RM) $(LIBRARY) ../$(LIBRARY) $(XLIBRARY) \
+               $(PROGRAMS) $(XPROGRAMS) $(XSRCS) $(XXSRCS) \
+               *.o *.lo a.out core version.c .libs/*
+
+depend-common: FORCE
+       $(MKDEP) $(DEFS) $(DEFINES) $(SRCS) $(XXSRCS)
+
+lint-local: FORCE
+lint5-local: FORCE
+
+Makefile: $(top_srcdir)/build/lib.mk
index ce0015fdc9113fdb444c6affcf148a5e09523e6b..91a96065cba6d12bcc144ef65532e0fc6d02d114 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ## Copyright 1998,1999 The OpenLDAP Foundation
 ## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
 ## of this package for details.
index 006f05abbc33abde62c9bbfd188b891163989835..55ef1e4c5091e53339993ea1c07437f462268b62 100755 (executable)
@@ -1,5 +1,10 @@
-#!/bin/sh -
+#! /bin/sh -
+# $OpenLDAP$
+## Copyright 1998,1999 The OpenLDAP Foundation
+## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
+## of this package for details.
 #
+# Portions
 # Copyright (c) 1987 Regents of the University of California.
 # All rights reserved.
 #
@@ -25,29 +30,52 @@ set -e                              # exit immediately if any errors occur
 
 MAKE=Makefile                  # default makefile name is "Makefile"
 NOSLASH="no"                   # by default, / dependencies are included
-CC=cc                          # default compiler is cc
+SRCDIR=""
+SED=cat
+
+: ${CC=cc}                                     # use cc by default
+
+# We generally set these via the command line options
+: ${MKDEP_CC=$CC}                      # select default compiler to generate dependencies
+: ${MKDEP_CFLAGS="-M"} # cc -M usually produces dependencies
 
 while :
        do case "$1" in
+               # the -s flag removes dependencies to files that begin with /
+               -s)
+                       NOSLASH=yes;
+                       shift ;;
+
                # -f allows you to select a makefile name
                -f)
                        MAKE=$2
                        shift; shift ;;
 
-               # -c allows you to select a compiler to use (default is cc)
+               # -d allows you to select a VPATH directory
+               -d)
+                       SRCDIR=$2
+                       shift; shift ;;
+
+               # -c allows you to override the compiler used to generate dependencies
                -c)
-                       CC=$2
+                       MKDEP_CC=$2
+                       shift; shift ;;
+
+               # -m allows you to override the compiler flags used to generate
+               # dependencies.
+               -m)
+                       MKDEP_CFLAGS=$2
                        shift; shift ;;
 
                # the -p flag produces "program: program.c" style dependencies
                # so .o's don't get produced
                -p)
-                       SED='s;\.o;;'
+                       SED='sed -e s;\.o;;'
                        shift ;;
 
-               # the -s flag removes dependencies to files that begin with /
-               -s)
-                       NOSLASH=yes;
+               # the -l flag produces libtool compatible dependencies
+               -l)
+                       SED='sed -e s;\.o:;.lo:;'
                        shift ;;
 
 #              -*)     shift ;;
@@ -57,19 +85,19 @@ while :
        esac
 done
 
-if [ $# = 0 ] ; then
-       echo 'usage: mkdep [-p] [-f makefile] [flags] file ...'
+if test $# = 0 ; then
+       echo 'usage: mkdep [-p] [-s] [-c cc] [-m flags] [-f makefile] [-d srcdir] [cppflags] file ...'
        exit 1
 fi
 
-if [ ! -w $MAKE ]; then
+if test ! -w $MAKE ; then
        echo "mkdep: no writeable file \"$MAKE\""
        exit 1
 fi
 
 TMP=/tmp/mkdep$$
 
-trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
+trap 'rm -f $TMP.sed $TMP ; exit 1' 1 2 3 13 15
 
 cp $MAKE ${MAKE}.bak
 
@@ -89,38 +117,60 @@ _EOF_
 # egrep '^#include[    ]*".*"' /dev/null $* |
 # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
 
-$CC -M $* |
-sed "
-       s; \./; ;g
-       $SED" |
+if test "x$SRCDIR" = "x" ; then
+       files=$*
+else
+       files=
+       for i in $* ; do
+               if test -f $i ; then
+                       files="$files $i"
+               elif test -f $SRCDIR/$i ; then
+                       files="$files $SRCDIR/$i"
+               else
+                       files="$files $i"
+               fi
+       done
+
+       MKDEP_CFLAGS="$MKDEP_CFLAGS -I$SRCDIR"
+fi
+
+cat << _EOF_ >> $TMP
+
+#
+# files: $*
+# command: $MKDEP_CC $MKDEP_CFLAGS $files
+#
+
+_EOF_
+
+$MKDEP_CC $MKDEP_CFLAGS $files | \
+       sed -e 's; \./; ;g' | \
+       $SED > $TMP.sed
+# do not pipe to awk.  SGI awk wants a filename as argument.
+# (or '-', but I do not know if all other awks support that.)
 awk '
-$1 ~ /:/ {
+$1 ~ /:$/ {
        filenm=$1
-       dep=$2
+       dep=substr($0, length(filenm)+1)
 }
-$1 !~ /:/ {
-       dep=$1
+$1 !~ /:$/ {
+       dep=$0
 }
 /.*/ {
-       if ( noslash = "yes" && dep ~ /^\// ) next
-       if (filenm != prev) {
-               if (rec != "")
-                       print rec;
-               rec = filenm " " dep;
-               prev = filenm;
+       if ( length(filenm) < 2 ) next
+       if ( filenm ~ /:.*:$/ ) next
+       split(dep, depends, " ")
+       for(d in depends) {
+               dfile = depends[d]
+               if ( length(dfile) < 2 ) continue
+               if ( dfile ~ /:/ ) continue
+               if (( noslash == "yes") && (dfile ~ /^\// )) continue
+               rec = filenm " " dfile
+               print rec
        }
-       else {
-               if (length(rec dep) > 78) {
-                       print rec;
-                       rec = filenm " " dep;
-               }
-               else
-                       rec = rec " " dep
-       }
-    }
-END {
-       print rec
-}' noslash="$NOSLASH" >> $TMP
+}
+' noslash="$NOSLASH" $TMP.sed >> $TMP
+
 
 cat << _EOF_ >> $TMP
 
@@ -129,5 +179,5 @@ _EOF_
 
 # copy to preserve permissions
 cp $TMP $MAKE
-rm -f ${MAKE}.bak $TMP
+rm -f ${MAKE}.bak $TMP.sed $TMP
 exit 0
index 6cdd3d0f8d1554cc9327fa1e4076701027db8d60..c694984f3c4b5de710d5cc2fa88bb796daa73802 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# $OpenLDAP$
 ## Copyright 1998,1999 The OpenLDAP Foundation
 ## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
 ## of this package for details.
diff --git a/build/mkversion b/build/mkversion
new file mode 100755 (executable)
index 0000000..d0ba137
--- /dev/null
@@ -0,0 +1,58 @@
+#! /bin/sh
+# $OpenLDAP$
+## Copyright 1998,1999 The OpenLDAP Foundation
+## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
+## of this package for details.
+#
+# Create a version.c file
+#
+PACKAGE=OpenLDAP
+VERSION=unknown
+SYMBOL=__Version
+static=static
+const=const
+while :
+       do case "$1" in
+               -p)
+                       PACKAGE=$2
+                       shift; shift ;;
+               -v)
+                       VERSION=$2
+                       shift; shift ;;
+
+               -c)
+                       const=
+                       shift ;;
+               -n)
+                       SYMBOL=$2
+                       shift; shift ;;
+               -s)
+                       static=
+                       shift ;;
+
+#              -*) shift ;;
+               *)
+                       break ;;
+       esac
+done
+
+if test $# != 1 ; then
+       echo 'usage: mkversion [-c] [-s] [-p package] [-v version] application'
+       exit 1
+fi
+
+APPLICATION=$1
+WHEN=`date`
+WHOWHERE="$USER@`uname -n`:`pwd`"
+
+cat << __EOF__
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation
+ * COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
+ * of this package for details.
+ */
+
+$static $const char $SYMBOL[] =
+"@(#) \$$PACKAGE: $APPLICATION $VERSION ($WHEN) \$\n\t$WHOWHERE\n";
+
+__EOF__
index 9c83d23a31f6fd780ac567ede5c97ef5a7c80518..380e1dc78c4191a97c9c4938a54562beaaa5f55c 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ## Copyright 1998,1999 The OpenLDAP Foundation
 ## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
 ## of this package for details.
index 0c3b675401aaa5a258d6b36a60acdb919c1d840d..4ceadfe3e11165acdaf77673c8aaccd1fcbb4b8b 100644 (file)
@@ -1,3 +1,5 @@
+dnl $OpenLDAP$
+dnl
 dnl Copyright 1998-1999 The OpenLDAP Foundation,  All Rights Reserved.
 dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file
 dnl
@@ -605,6 +607,27 @@ fi
 ])
 dnl
 dnl ====================================================================
+dnl Check GNU Pth pthread Header
+dnl
+dnl defines ol_cv_header linux_threads to 'yes' or 'no'
+dnl            'no' implies pthreads.h is not LinuxThreads or pthreads.h
+dnl            doesn't exists.  Existance of pthread.h should separately
+dnl            checked.
+dnl 
+AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
+       AC_CACHE_CHECK([for GNU Pth pthread.h],
+               [ol_cv_header_gnu_pth_pthread_h],
+               [AC_EGREP_CPP(__gnu_pth__,
+                       [#include <pthread.h>
+#ifdef _POSIX_THREAD_IS_GNU_PTH
+       __gnu_pth__
+#endif
+],
+                       [ol_cv_header_gnu_pth_pthread_h=yes],
+                       [ol_cv_header_gnu_pth_pthread_h=no])
+               ])
+])dnl
+dnl ====================================================================
 dnl Check LinuxThreads Header
 dnl
 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
index b2d3d9f2beddbea3df1f8b30a0766b61c92560a8..4f795ff3533b8fefa33eaeeeac6fb6c8e1155b4a 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ## Copyright 1998,1999 The OpenLDAP Foundation
 ## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
 ## of this package for details.
index c72254cd1a434c0a949ec4939925e62ec6587603..ee6d5daa2741cadefa7aa9049201e0897cd6ae81 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ## Copyright 1998,1999 The OpenLDAP Foundation
 ## COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
 ## of this package for details.
index ff7fe5a46c4d022aa3e8cd3f5046a441a0725e92..9dc7dcdce0ebdcf1f33838127f3c1ee291ff2dbe 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ## Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
 ## All rights reserved.
 ##
index b981f4806c9eab1b0f48e3e1e5bbf62ed66a44cb..44640502d95a9ff7ef4be6aa62f984f5f9ca9114 100644 (file)
@@ -1 +1 @@
-2.0-Engineering
+2.0-alpha3
diff --git a/clients/Makefile.in b/clients/Makefile.in
new file mode 100644 (file)
index 0000000..29f8931
--- /dev/null
@@ -0,0 +1,7 @@
+# $OpenLDAP$
+## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
+## COPYING RESTRICTIONS APPLY, See COPYRIGHT file
+##
+## Clients Makefile.in for OpenLDAP
+
+SUBDIRS= tools ud finger gopher mail500 fax500 rcpt500
index 1955d9d4116216e1ddcf3f42666a66f24b6170a3..4520a63ef6c3cd5d7b014b270f1777e8b6732de6 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 PROGRAMS= rp500 fax500 xrpcomp.tmp
 
 SRCS= main.c faxtotpc.c rp500.c
diff --git a/clients/fax500/fax500.h b/clients/fax500/fax500.h
new file mode 100644 (file)
index 0000000..f494e10
--- /dev/null
@@ -0,0 +1,11 @@
+/* $OpenLDAP$ */
+#ifndef FAX500_H
+#define FAX500_H 1
+
+/* in faxtotpc.c */
+void  strip_nonnum ( char *str );
+char *remove_parens( char *ibuf, char *obuf );
+char *munge_phone  ( char *ibuf, char *obuf );
+char *faxtotpc     ( char *phone, char *userinfo );
+
+#endif
index d4631b43e6847c753b48c53be47063e61bc37304..1579c84fde361c4502047f8895c2034851c6f85f 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1993 Regents of the University of Michigan.
  * All rights reserved.
  * Routines for parsing the facsimileTelephoneNumber field out of
  * an X.500 entry and converting it to a "tpc.int" domain name.
  *
- * char *faxtotpc(str)
- * char *str;
+ * char *faxtotpc( char *str, char *userinfo)
  *
  * faxtotpc() returns a pointer to a string allocated with malloc(3).
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
 
-#ifdef ultrix
-extern char *strdup();
-#endif
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
 
+#include "fax500.h"
 
 #define        TPCDOMAIN       "tpc.int"
 
 /*
  * Remove everything from 'str' which is not a digit
  */
-void strip_nonnum(str)
-char *str;
+void
+strip_nonnum( char *str )
 {
        char *p, *q;
        p = q = str;
@@ -61,9 +61,8 @@ char *str;
  * Remove anything of the form (blah) where
  * "blah" contains a non-numeric character.
  */
-char *remove_parens(ibuf, obuf)
-char *ibuf;
-char *obuf;
+char *
+remove_parens( char *ibuf, char *obuf )
 {
        char *p = ibuf;
        char *q = obuf;
@@ -132,9 +131,8 @@ char *obuf;
  * 6                  93
  * 8                  99
  */
-char *munge_phone(ibuf, obuf)
-char *ibuf;
-char *obuf;
+char *
+munge_phone( char *ibuf, char *obuf )
 {
 #define        UMAREACODE      "1313"
 
@@ -176,17 +174,11 @@ char *obuf;
 
 
 
-
-
-
-
-
 /* 
  * Convert string to "tpc.int" domain name.
  */
-char *faxtotpc(phone, userinfo)
-char *phone;
-char *userinfo;
+char *
+faxtotpc( char *phone, char *userinfo )
 {
        char *p;
        char *q;
@@ -244,5 +236,4 @@ char *userinfo;
        strcat(obuf, TPCDOMAIN);        /* tack on domain name */
        p = strdup(obuf);
        return(p);
-                               
 }
index 5bc84f2fb8efed7a7f7afa7ab44f8040b994ef28..b94a1a62159c50e60dfdea8f7f559e2094a7f034 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
@@ -121,7 +122,7 @@ static void add_to(char ***list, int *nlist, char **new);
 static int  isgroup(LDAPMessage *e);
 static void add_error(Error **err, int *nerr, int code, char *addr, LDAPMessage *msg);
 static void add_group(char *dn, Group **list, int *nlist);
-static void unbind_and_exit(int rc);
+static void unbind_and_exit(int rc) LDAP_GCCATTR((noreturn));
 static int  group_loop(char *dn);
 static void send_group(Group *group, int ngroup);
 static int  has_attributes(LDAPMessage *e, char *attr1, char *attr2);
index bc8032530575d8ef452d56413400ace44a332d1d..e957483a80cc9db40dd2b4d94178eaf49398a56c 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
index 4795e639245a459764918b52b31a7acd00b49760..613bda9e409e7440cc4b1f5ccce84418cce6b7b9 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 SRCS=  main.c
 XSRCS= version.c
 OBJS=  main.o
index 63b77e9a4bf2fb8aae55d833db4da5f24daf5608..5e84fe4916bc8cca28988d0cfacaf608a9bf21f5 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990,1994 Regents of the University of Michigan.
  * All rights reserved.
index b010e426d16d62c724aa27f80a528c2b57b37150..a9d5e4ee949c4f889f3aac17290ae93f7167a745 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ##
 ## Makefile for gopher clients
 ##
index 9bf49a252c5ace7b760b13e62698405c6e9861ef..e8342fc4a61b5ca93fafaaa7610ac36af0895fcb 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
@@ -62,10 +63,10 @@ char        *templatefile = TEMPLATEFILE;
 char   myhost[MAXHOSTNAMELEN];
 int    myport;
 
-static void usage      ( char *name );
+static void usage      ( char *name ) LDAP_GCCATTR((noreturn));
 static int  set_socket (int port);
 static RETSIGTYPE wait4child(int sig);
-static void do_queries (int s);
+static void do_queries (int s)    LDAP_GCCATTR((noreturn));
 static void do_error   (FILE *fp, char *s);
 static void do_search  (LDAP *ld, FILE *fp, char *buf);
 static void do_read    (LDAP *ld, FILE *fp, char *dn);
index 24b627f02b97368fcee7e160529f8d6e7b6e4fd1..c1c5ab4a9ef47c556e3823f66d3ce195aedeb13f 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
@@ -63,10 +64,10 @@ char                *templatefile = TEMPLATEFILE;
 char           *friendlyfile = FRIENDLYFILE;
 int            rdncount = GO500GW_RDNCOUNT;
 
-static void usage      ( char *name );
+static void usage      ( char *name ) LDAP_GCCATTR((noreturn));
 static int  set_socket (int port);
 static RETSIGTYPE wait4child(int sig);
-static void do_queries (int s);
+static void do_queries (int s)    LDAP_GCCATTR((noreturn));
 static char *pick_oc   ( char **oclist );
 static int  isnonleaf  ( LDAP *ld, char **oclist, char *dn );
 static void do_menu    (LDAP *ld, FILE *fp, char *dn);
index 453d1199c76c562b448a6108f8c963d17cfffb08..38b61fd40486f51b193e893b8a1d8737711def70 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 PROGRAMS= mail500
 
 SRCS=  main.c
index 678663805d2714196c757b66697e80a88ba053a7..064ed64c348b5b6b560741c715ba937801835062 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
@@ -178,7 +179,7 @@ static void add_to( char ***list, int *nlist, char **new );
 static void add_single_to( char ***list, char *new );
 static int  isgroup( LDAPMessage *e );
 static void add_error( Error **err, int *nerr, int code, char *addr, LDAPMessage *msg );
-static void unbind_and_exit( int rc );
+static void unbind_and_exit( int rc ) LDAP_GCCATTR((noreturn));
 static void send_group( Group *group, int ngroup );
 
 static int  connect_to_x500( void );
@@ -1829,7 +1830,3 @@ unbind_and_exit( int rc )
 
        exit( rc );
 }
-
-
-
-
index fc2ddaa88d722143545f2dd3d256dda3bec4c6b5..5af6536f915447af999b9f5ea226e3a01989e691 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 PROGRAMS= rcpt500
 SRCS= main.c cmds.c help.c query.c
 XSRCS= version.c
index fe893095677d35937a3e0f4473e65f9160a5c51f..8e33658a3383966095607f60f49386aaee3965aa 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * cmds.c: command table for rcpt500 (X.500 email query responder)
  *
@@ -6,7 +7,9 @@
  * All Rights Reserved
  */
 
-#include <stdio.h>
+#include "portable.h"
+
+#include <ac/stdlib.h>
 #include "rcpt500.h"
 
 struct command cmds[] = {
index 0f541ab9be1efde1bfd59df0f6f9b195f5c6d899..76dca44f8f9f03b1654a72403f5e767975467b87 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * help.c: for rcpt500 (X.500 email query responder)
  *
@@ -6,22 +7,24 @@
  * All Rights Reserved
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <syslog.h>
-#include <string.h>
+
+#include <ac/syslog.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
+#endif
 
-#include "portable.h"
-#include "ldapconfig.h"
+#include "ldap_defaults.h"
 #include "rcpt500.h"
 
-extern int dosyslog;
-
 
 int
-help_cmd( msgp, reply )
-    struct msginfo     *msgp;
-    char               *reply;
+help_cmd(struct msginfo *msgp, char *reply)
 {
     int                fd, len;
 
index 74fe9d088d56c7cb70549ba37ba3c58c58a7ce1b..afabd89322a786d7bd609c1538fb9e7f0d529b3e 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * main.c: for rcpt500 (X.500 email query responder)
  *
index dac5f15fc92f2435b0be5aed35915443b89774e2..157b5a4bafc7eb7467fe51e7a89b12b805894f39 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * query.c: for rcpt500 (X.500 email query responder)
  *
index 537f92c1c483896d308b736deddd605ab1242212..068af6026b0b02de928029296a444521b55aab9b 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * rcpt500.h: includes for rcpt500 (X.500 email query responder)
  *
@@ -6,6 +7,10 @@
  * All Rights Reserved
  */
 
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
+
 struct msginfo {
     char       *msg_subject;
     char       *msg_replyto;   /* actually could be from From: line */
@@ -16,8 +21,9 @@ struct msginfo {
 };
 
 struct command {
-    char        *cmd_text;              /* text for command, e.g. "HELP" */
-    int        (*cmd_handler)();        /* pointer to handler function */
+       char    *cmd_text;      /* text for command, e.g. "HELP" */
+       /* pointer to handler function */
+       int     (*cmd_handler) LDAP_P((struct msginfo *msgp, char *reply));
 };
 
 
@@ -27,10 +33,28 @@ struct command {
 /*
  * functions
  */
-int    help_cmd();
-int    query_cmd();
+int    help_cmd  LDAP_P((struct msginfo *msgp, char *reply));
+int    query_cmd LDAP_P((struct msginfo *msgp, char *reply));
 
 /*
  * externs
  */
+
+/* cmds.c */
 extern struct command cmds[];
+/* main.c */
+extern int dosyslog;
+#ifdef LDAP_CONNECTIONLESS
+extern int do_cldap;
+#endif
+extern int derefaliases;
+extern int sizelimit;
+extern int rdncount;
+extern int ldapport;
+extern char *ldaphost;
+extern char *searchbase;
+extern char *dapuser;
+extern char *filterfile;
+extern char *templatefile;
+
+LDAP_END_DECL
index cfd882e58273b5176ae0f24166dfe4dca5575829..11acdd9cff0cb9d04c9c3d2b361837cca4cefd90 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ##
 ## Makefile for LDAP tools
 ##
index 4eab6b14894cb801b9426cdabda0ae15bbb97c03..54778c42c87a89c74b36a02546f03d7b3dd469c5 100644 (file)
@@ -1,4 +1,5 @@
 /* ldapdelete.c - simple program to delete an entry using LDAP */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -20,7 +21,6 @@
 
 static char    *binddn = NULL;
 static char    *passwd = NULL;
-static char    *base = NULL;
 static char    *ldaphost = NULL;
 static int     ldapport = 0;
 static int     not, verbose, contoper;
@@ -158,6 +158,9 @@ main( int argc, char **argv )
                ldap_set_option( ld, LDAP_OPT_DEREF, &deref );
        }
 
+       /* don't chase referrals */
+       ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF );
+
        if (want_bindpw)
                passwd = getpass("Enter LDAP Password: ");
 
@@ -194,12 +197,12 @@ main( int argc, char **argv )
                }
        }
 
+       rc = 0;
     if ( fp == NULL ) {
        for ( ; optind < argc; ++optind ) {
            rc = dodelete( ld, argv[ optind ] );
        }
     } else {
-       rc = 0;
        while ((rc == 0 || contoper) && fgets(buf, sizeof(buf), fp) != NULL) {
            buf[ strlen( buf ) - 1 ] = '\0';    /* remove trailing newline */
            if ( *buf != '\0' ) {
index 729a6d1cd8db56dd81a644ca2da661c62c887a63..043d3bbc3dafd888a528f3932e88298c0c25daae 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -60,7 +61,7 @@ static LDAP   *ld;
 #define T_NEWSUPSTR            "newsuperior"
 
 
-static void usage LDAP_P(( const char *prog ));
+static void usage LDAP_P(( const char *prog )) LDAP_GCCATTR((noreturn));
 static int process_ldapmod_rec LDAP_P(( char *rbuf ));
 static int process_ldif_rec LDAP_P(( char *rbuf, int count ));
 static void addmodifyop LDAP_P(( LDAPMod ***pmodsp, int modop, char *attr,
@@ -251,6 +252,8 @@ main( int argc, char **argv )
                int deref = LDAP_DEREF_NEVER;
                ldap_set_option( ld, LDAP_OPT_DEREF, &deref);
        }
+       /* don't chase referrals */
+       ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF );
 
        if (want_bindpw)
                passwd = getpass("Enter LDAP Password: ");
@@ -460,6 +463,7 @@ process_ldif_rec( char *rbuf, int count )
                goto end_line;
            } else if ( strcasecmp( type, T_MODOPREPLACESTR ) == 0 ) {
                modop = LDAP_MOD_REPLACE;
+               addmodifyop( &pmods, modop, value, NULL, 0 );
                goto end_line;
            } else if ( strcasecmp( type, T_MODOPDELETESTR ) == 0 ) {
                modop = LDAP_MOD_DELETE;
index 51b97197245dba0a1cd27ecd37bdd601567783e1..3bc2e3140df15087121fee3bdf7e95597c4cfa44 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -32,7 +33,6 @@
 
 static char    *binddn = NULL;
 static char    *passwd = NULL;
-static char    *base = NULL;
 static char    *ldaphost = NULL;
 static int     ldapport = 0;
 static int     not, verbose, contoper;
@@ -210,6 +210,9 @@ main(int argc, char **argv)
                int deref = LDAP_DEREF_NEVER;
                ldap_set_option( ld, LDAP_OPT_DEREF, &deref);
        }
+       /* don't chase referrals */
+       ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF );
+
 
        if (want_bindpw)
                passwd = getpass("Enter LDAP Password: ");
index 6ced63a274fdb2374de2756cc1f7ec3d801291cd..98aa570fedc14df6465beaaa19dfeee03ca1fea6 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -68,7 +69,7 @@ Salt;
 
 typedef struct hash_t
 {
-       char           *name;
+       const char     *name;
        unsigned int    namesz;
        char           *(*func) (const char *, Salt *);
        unsigned char   takes_salt;
@@ -89,7 +90,7 @@ static int    auto_gen_pw = 0;
  * pw_encode() essentially base64 encodes a password and its salt
  */
 
-char *
+static char *
 pw_encode (unsigned char *passwd, Salt * salt, unsigned int len)
 {
        int             salted = salt && salt->salt && salt->len;
@@ -123,7 +124,7 @@ pw_encode (unsigned char *passwd, Salt * salt, unsigned int len)
  * if you'd like to write a better salt generator, please, be my guest.
  */
 
-void
+static void
 make_salt (Salt * salt, unsigned int len)
 {
 
@@ -141,7 +142,7 @@ make_salt (Salt * salt, unsigned int len)
  * password generator
  */
 
-char *
+static char *
 gen_pass (unsigned int len)
 {
        static const unsigned char autogen[] =
@@ -160,7 +161,7 @@ gen_pass (unsigned int len)
 }
 
 #ifdef SLAPD_CLEARTEXT
-char *
+static char *
 hash_none (const char *pw_in, Salt * salt)
 {
        return (strdup (pw_in));
@@ -168,7 +169,7 @@ hash_none (const char *pw_in, Salt * salt)
 #endif
 
 #ifdef SLAPD_CRYPT
-char *
+static char *
 hash_crypt (const char *pw_in, Salt * salt)
 {
        static const unsigned char crypt64[] =
@@ -198,7 +199,7 @@ hash_crypt (const char *pw_in, Salt * salt)
 }
 #endif
 
-char *
+static char *
 hash_md5 (const char *pw_in, Salt * salt)
 {
        lutil_MD5_CTX   MD5context;
@@ -214,7 +215,7 @@ hash_md5 (const char *pw_in, Salt * salt)
        return (pw_encode (MD5digest, salt, sizeof (MD5digest)));
 }
 
-char *
+static char *
 hash_sha1 (const char *pw_in, Salt * salt)
 {
        lutil_SHA1_CTX  SHA1context;
@@ -230,7 +231,7 @@ hash_sha1 (const char *pw_in, Salt * salt)
        return (pw_encode (SHA1digest, salt, sizeof (SHA1digest)));
 }
 
-static Hash hashes[] =
+static const Hash hashes[] =
 {
 #ifdef SLAPD_CLEARTEXT
        {"none",  4, hash_none,  0, HASHTYPE_NONE,  HASHTYPE_NONE,  0},
@@ -245,7 +246,7 @@ static Hash hashes[] =
        {NULL,    0, NULL,       0, HASHTYPE_NONE,  HASHTYPE_NONE,  0}
 };
 
-int
+static int
 modify_dn (LDAP * ld, char *targetdn, char *pwattr, char *oldpw,
           char *newpw, HashTypes htype, Salt * salt)
 {
@@ -325,8 +326,8 @@ modify_dn (LDAP * ld, char *targetdn, char *pwattr, char *oldpw,
        return (ret);
 }
 
-void
-usage (char *s)
+static void
+usage(const char *s)
 {
        fprintf (stderr, "Usage: %s [options] [filter]\n", s);
        fprintf (stderr, "  -a attrib\tpassword attribute (default: " LDAP_PASSWD_ATTRIB ")\n");
@@ -623,6 +624,8 @@ main (int argc, char *argv[])
                int deref = LDAP_DEREF_NEVER;
                ldap_set_option( ld, LDAP_OPT_DEREF, &deref);
        }
+       /* don't chase referrals */
+       ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF );
 
        if (version != -1 &&
                ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) != LDAP_OPT_SUCCESS )
index d5d09d184875b1dee4e90150c86cfba059e141b8..1eba56399a33e0d4f1394a109a765ac6dae10059 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -21,7 +22,7 @@
 #define DEFSEP         "="
 
 static void
-usage( char *s )
+usage( const char *s )
 {
        fprintf( stderr,
 "usage: %s [options] filter [attributes...]\nwhere:\n"
@@ -561,7 +562,8 @@ static int dosearch(
 }
 
 
-void print_entry(
+static void
+print_entry(
        LDAP    *ld,
        LDAPMessage     *entry,
        int             attrsonly)
@@ -679,7 +681,7 @@ void print_entry(
 }
 
 
-int
+static int
 write_ldif( int type, char *name, char *value, ber_len_t vallen )
 {
        char    *ldif;
index 0eaf5667b8c077eed0b861db631166a4bb8b4420..54c16e29e13ed6144c913d3288bd85c401fdd425 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 SRCS=  main.c find.c mod.c print.c auth.c util.c help.c \
        string_to_key.c group.c edit.c globals.c
 XSRCS= version.c
index 89580347bbd3656722bce8cbe8749305db098de0..b757d78169c54226701ab71dcde79ebde0038022 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1991, 1992 Regents of the University of Michigan.
  * All rights reserved.
@@ -294,17 +295,6 @@ auth( char *who, int implicit )
 #define FIVEMINS       ( 5 * 60 )
 #define TGT            "krbtgt"
 
-static void
-str2upper( char *s )
-{
-       char    *p;
-
-       for ( p = s; *p != '\0'; ++p ) {
-               *p = TOUPPER( (unsigned char) *p );
-       }
-}
-
-
 static int
 valid_tgt( char **names )
 {
@@ -324,7 +314,7 @@ valid_tgt( char **names )
                /*
                 * realm must be uppercase for krb_ routines
                 */
-               str2upper( realm );
+               ldap_pvt_str2upper( realm );
 #endif /* HAVE_AFS_KERBEROS */
 
                /*
@@ -395,7 +385,7 @@ kinit( char *kname )
        /*
         * realm must be uppercase for krb_ routines
         */
-       str2upper( realm );
+       ldap_pvt_str2upper( realm );
 #endif /* HAVE_AFS_KERBEROS */
 
        rc = krb_get_in_tkt( name, inst, realm, TGT, realm,
index 997926c23d1f9a3977d380b5127b45fd1b368acb..67f2ed9a865c8e093c6c7852eaccf780bfe12f0b 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1994  Regents of the University of Michigan.
  * All rights reserved.
index 3551c1af6d7674dcc6153cce5a52b93072903d12..5e8b8656030c0dd473748de940b2e03ec312b768 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1991, 1992, 1993 
  * Regents of the University of Michigan.  All rights reserved.
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#ifndef __STDC__
-#include <memory.h>
-#endif
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
 #include <lber.h>
 #include <ldap.h>
+
 #include "ud.h"
 
-extern char *search_base;      /* search base */
-extern int verbose;            /* verbose mode flag */
-extern LDAP *ld;               /* our ldap descriptor */
-       
 static int num_picked = 0;     /* used when user picks entry at More prompt */
 
-#ifdef DEBUG
-extern int debug;              /* debug flag */
-#endif
 
-vrfy(dn)
-char *dn;
+int
+vrfy( char *dn )
 {
        LDAPMessage *results;
        static char *attrs[2] = { "objectClass", NULL };
+       int ld_errno = 0;
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -43,9 +43,12 @@ char *dn;
        /* verify that this DN exists in the directory */
        (void) ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", attrs, TRUE, &results);
        (void) ldap_msgfree(results);
-       if ((ld->ld_errno == LDAP_NO_SUCH_OBJECT) || (ld->ld_errno == LDAP_INVALID_DN_SYNTAX))
+
+       ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+
+       if ((ld_errno == LDAP_NO_SUCH_OBJECT) || (ld_errno == LDAP_INVALID_DN_SYNTAX))
                return(0);
-       else if (ld->ld_errno == LDAP_SUCCESS)
+       else if (ld_errno == LDAP_SUCCESS)
                return(1);
        else {
                ldap_perror(ld, "ldap_search");
@@ -54,11 +57,8 @@ char *dn;
 }
        
 
-static LDAPMessage * disambiguate( result, matches, read_attrs, who )
-LDAPMessage *result;
-int matches;
-char **read_attrs;
-char *who;
+static LDAPMessage *
+disambiguate( LDAPMessage *result, int matches, char **read_attrs, char *who )
 {
        int choice;                     /* entry that user chooses */
        int i;
@@ -66,18 +66,21 @@ char *who;
        char response[SMALL_BUF_SIZE];  /* results from user */
        char *name = NULL;              /* DN to lookup */
        LDAPMessage *mp;
-       extern void Free();
+       int ld_errno = 0;
 
 #ifdef DEBUG
        if (debug & D_TRACE)
                printf("->disambiguate(%x, %d, %x, %s)\n", result, matches, 
                                                        read_attrs, who);
 #endif
+
+       ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+
        /*
         *  If we are here, it means that we got back multiple answers.
         */
-       if ((ld->ld_errno == LDAP_TIMELIMIT_EXCEEDED)
-           || (ld->ld_errno == LDAP_SIZELIMIT_EXCEEDED)) {
+       if ((ld_errno == LDAP_TIMELIMIT_EXCEEDED)
+           || (ld_errno == LDAP_SIZELIMIT_EXCEEDED)) {
                if (verbose) {
                        printf("  Your query was too general and a limit was exceeded.  The results listed\n");
                        printf("  are not complete.  You may want to try again with a more refined query.\n\n");
@@ -150,9 +153,8 @@ char *who;
        }
 }
 
-LDAPMessage * find(who, quiet)
-char *who;
-int quiet;
+LDAPMessage *
+find( char *who, int quiet )
 {
        register int i, j, k;           /* general ints */
        int matches;                    /* from ldap_count_entries() */
@@ -166,9 +168,6 @@ int quiet;
        char response[SMALL_BUF_SIZE];
        char *cp, *dn, **rdns;
        LDAPFiltInfo *fi;
-       extern LDAPFiltDesc *lfdp;              /* LDAP filter descriptor */
-       extern struct attribute attrlist[];     /* complete list of attrs */
-       extern void Free();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -203,39 +202,45 @@ int quiet;
         *  here.  If we don't find it, treat it as NOT a UFN.
         */
        if (strchr(who, ',') != NULL) {
-               int     savederef;
+               int     savederef, deref;
 #ifdef DEBUG
                if (debug & D_FIND)
                        printf("\"%s\" appears to be a UFN\n", who);
 #endif
-               savederef = ld->ld_deref;
-               ld->ld_deref = LDAP_DEREF_FINDING;
+               ldap_get_option(ld, LDAP_OPT_DEREF, &savederef);
+               deref = LDAP_DEREF_FINDING;
+               ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
+
                if ((rc = ldap_ufn_search_s(ld, who, search_attrs, FALSE, &res)) !=
                    LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED &&
                    rc != LDAP_TIMELIMIT_EXCEEDED) {
                        ldap_perror(ld, "ldap_ufn_search_s");
-                       ld->ld_deref = savederef;
+                       ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
                        return(NULL);
                }
                if ((matches = ldap_count_entries(ld, res)) < 0) {
                        ldap_perror(ld, "ldap_count_entries");
-                       ld->ld_deref = savederef;
+                       ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
                        return(NULL);
                } else if (matches == 1) {
-                       if (ldap_search_s(ld, ldap_get_dn(ld, ldap_first_entry(ld, res)), LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res) != LDAP_SUCCESS) {
-                               if (ld->ld_errno == LDAP_UNAVAILABLE)
-                                       printf("  Could not contact the X.500 server to find \"%s\".\n", who);
+                       dn = ldap_get_dn(ld, ldap_first_entry(ld, res));
+                       rc = ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res);
+                       ldap_memfree(dn);
+                       if (rc != LDAP_SUCCESS) {
+                               int ld_errno = 0;
+                               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+                               if (ld_errno == LDAP_UNAVAILABLE)
+                                       printf("  Could not contact the LDAP server to find \"%s\".\n", who);
                                else
                                        ldap_perror(ld, "ldap_search_s");
                                return(NULL);
                        }
-                       ld->ld_deref = savederef;
+                       ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
                        return(res);
                } else if (matches > 1 ) {
-                       return( disambiguate( ld, res, matches, read_attrs,
-                           who ) );
+                       return disambiguate( res, matches, read_attrs, who );
                }
-               ld->ld_deref = savederef;
+               ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
        }
 
        /*
@@ -287,7 +292,10 @@ int quiet;
                                fflush(stdout);
                                fetch_buffer(response, sizeof(response), stdin);
                                if ((response[0] == 'n') || (response[0] == 'N'))
+                               {
+                                       ldap_memfree(dn);
                                        return(NULL);
+                               }
                        }
 #ifdef DEBUG
                        if (debug & D_FIND) {
@@ -306,9 +314,9 @@ int quiet;
                        if (ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res) != LDAP_SUCCESS) {
                                ldap_perror(ld, "ldap_search_s");
                                ldap_msgfree(res);
-                               return(NULL);
+                               res = NULL;
                        }
-                       Free(dn);
+                       ldap_memfree(dn);
                        return(res);
                }
                else if (matches > 0) {
@@ -322,8 +330,8 @@ int quiet;
        return(NULL);
 }
 
-pick_one(i)
-int i;
+int
+pick_one( int i )
 {
        int n;
        char user_pick[SMALL_BUF_SIZE];
@@ -348,13 +356,10 @@ int i;
        /* NOTREACHED */
 }
 
-print_list(list, names, matches)
-LDAPMessage *list;
-char *names[];
-int *matches;
+void
+print_list( LDAPMessage *list, char **names, int *matches )
 {
        char **rdns, **cpp;
-       extern int lpp;
        char resp[SMALL_BUF_SIZE];
        register LDAPMessage *ep;
        register int i = 1;
@@ -398,9 +403,8 @@ again:
        return;
 }
 
-find_all_subscribers(sub, group)
-char *sub[];
-char *group;
+int
+find_all_subscribers( char **sub, char *group )
 {
        int count;
        LDAPMessage *result;
@@ -416,7 +420,9 @@ char *group;
 
        sprintf(filter, "%s=%s", "memberOfGroup", group);
        if (ldap_search_s(ld, search_base, LDAP_SCOPE_SUBTREE, filter, attributes, FALSE, &result) != LDAP_SUCCESS) {
-               if (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE)
+               int ld_errno = 0;
+               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+               if (ld_errno == LDAP_NO_SUCH_ATTRIBUTE)
                        return(0);
                ldap_perror(ld, "ldap_search_s");
                return(0);
@@ -443,9 +449,8 @@ char *group;
        return(count);
 }
 
-char * fetch_boolean_value(who, attr)
-char *who;
-struct attribute attr;
+char *
+fetch_boolean_value( char *who, struct attribute attr )
 {
        LDAPMessage *result;            /* from the search below */
        register LDAPMessage *ep;       /* entry pointer */
@@ -458,7 +463,9 @@ struct attribute attr;
 #endif
        attributes[0] = attr.quipu_name;
        if (ldap_search_s(ld, who, LDAP_SCOPE_BASE, "objectClass=*", attributes, FALSE, &result) != LDAP_SUCCESS) {
-               if (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE)
+               int ld_errno = 0;
+               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+               if (ld_errno == LDAP_NO_SUCH_ATTRIBUTE)
                        return("FALSE");
                ldap_perror(ld, "ldap_search_s");
                ldap_msgfree(result);
index 121f36be21fb2a2ca666349f4d1e5839104f4c8e..5927351c5bf9c57b689b9e74a7f4cccc2f7e5f88 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1992, 1993, 1994  Regents of the University of Michigan.
  * All rights reserved.
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
+#include <ac/time.h>           /* portable.h+ldap.h needs time_t */
+#include <lber.h>
+#include <ldap.h>
 #include "ud.h"
 
-extern void    set_boolean(), 
-               change_field(), 
-#ifdef UOFM
-               set_updates(), 
-#endif
-               mod_addrDN();
-
 struct attribute attrlist[] = {
 
        /* 
@@ -28,8 +27,8 @@ struct attribute attrlist[] = {
         *  Field 3 = function used to modify this field (if any)
         *  Field 4 = Flags specifying how this field is displayed
         */
-       { "memberOfGroup", "Subscriptions", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN },
-       { "acl", "Access Control", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+       { "memberOfGroup", "Subscriptions", 0, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN },
+       { "acl", "Access Control", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
        { "cn", "Aliases", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH | ATTR_FLAG_GROUP_MOD },
        { "title", "Title", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_SEARCH | ATTR_FLAG_PERSON_MOD },
        { "postalAddress", "Business address", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD | ATTR_FLAG_IS_MULTILINE },
@@ -38,18 +37,18 @@ struct attribute attrlist[] = {
        { "member", "Members", mod_addrDN, ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN | ATTR_FLAG_GROUP_MOD },
        { "homePhone", "Home phone", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD },
        { "homePostalAddress", "Home address", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_MULTILINE },
-       { "objectClass", "Object class", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH },
+       { "objectClass", "Object class", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH },
 #ifdef UOFM
        { "multiLineDescription", "Description", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD | ATTR_FLAG_IS_MULTILINE },
 #endif
-#ifdef KERBEROS
-       { "krbName", "Kerberos name", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_READ },
+#ifdef HAVE_KERBEROS
+       { "krbName", "Kerberos name", 0, ATTR_FLAG_PERSON | ATTR_FLAG_READ },
 #endif
-       { "description", "Brief description", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+       { "description", "Brief description", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
        { "facsimileTelephoneNumber", "Fax number", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD },
        { "pager", "Pager number", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD },
-       { "uid", "Uniqname", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
-       { "userPassword", "Password", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+       { "uid", "Uniqname", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+       { "userPassword", "Password", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
 #ifdef UOFM
        { "noBatchUpdates", "No batch updates", set_updates, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
 #endif
@@ -65,7 +64,7 @@ struct attribute attrlist[] = {
        { "onVacation", "On Vacation", set_boolean, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_A_BOOL },
        { "vacationMessage", "Vacation Message", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_MULTILINE },
        { "drink", "Favorite Beverage", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
-       { "lastModifiedBy", "Last modified by", NULL, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_IS_A_DN | ATTR_FLAG_READ },
-       { "lastModifiedTime", "Last modified at", NULL, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DATE },
-       { NULL, NULL, NULL, ATTR_FLAG_NONE }
+       { "lastModifiedBy", "Last modified by", 0, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_IS_A_DN | ATTR_FLAG_READ },
+       { "lastModifiedTime", "Last modified at", 0, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DATE },
+       { NULL, NULL, 0, ATTR_FLAG_NONE }
 };
index 3b7a87fb1c3143b81ed2879df79e15b337bac1aa..950631d765073030efd897418b09cc4472cdbbc0 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1993, 1994  Regents of the University of Michigan.
  * All rights reserved.
index 2a2c96bde9beb4f317c55e9d7222141c968469f5..027e168e41577b7fb33123cb6f3c3f4623162e9e 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1992, 1993  Regents of the University of Michigan.
  * All rights reserved.
index 6be4288ae5280259ca6631c6a3b1d0b98a459807..7f0d4baa3d1b8eb6185b2e3731c5ef908e1911af 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 9f6322572e3681ae6c9c5c72f7fc54464655a264..40eea363167aad250e3a5e6b9102e1c11d330b93 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1991,1993  Regents of the University of Michigan.
  * All rights reserved.
index 4185bdaef367e3580a1911e73831b05d6a4f7331..8cb5c133dca28a33431e31c23fa2ac4b9b2d0ad8 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1991, 1993 
  * Regents of the University of Michigan.  All rights reserved.
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#ifndef __STDC__
-#include <memory.h>
-#endif
-#include <time.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
 #include <lber.h>
 #include <ldap.h>
-#include "ud.h"
 
-#ifdef DEBUG
-extern int debug;
-#endif
+#include "ud.h"
 
 struct entry Entry;
-extern LDAP *ld;
 
-extern void * Malloc();
-extern void Free();
-extern char * my_ldap_dn2ufn();
+static char *time2text(char *ldtimestr, int dateonly);
+static long            gtime(struct tm *tm);
 
 /*
  *  When displaying entries, display only these attributes, and in this
@@ -80,15 +77,14 @@ static char *group_attr_print_order[] = {
        NULL
 };
 
-parse_answer(s)
-LDAPMessage *s;
+
+void
+parse_answer( LDAPMessage *s )
 {
        int idx;
        char **rdns;
-       BerElement *cookie;
        register LDAPMessage *ep;
        register char *ap;
-       void clear_entry();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -102,6 +98,7 @@ LDAPMessage *s;
                printf(" Done clearing entry\n");
 #endif
        for (ep = ldap_first_entry(ld, s); ep != NULL; ep = ldap_next_entry(ld, ep)) {
+               BerElement *cookie = NULL;
 #ifdef DEBUG
                if (debug & D_PARSE)
                        printf(" Determining DN and name\n");
@@ -130,6 +127,10 @@ LDAPMessage *s;
                        }
                        add_value(&(Entry.attrs[idx]), ep, ap);
                }
+
+               if( cookie != NULL ) {
+                       ber_free( cookie, 0 );
+               }
        }
 #ifdef DEBUG
        if (debug & D_PARSE)
@@ -137,10 +138,8 @@ LDAPMessage *s;
 #endif
 }
 
-add_value(attr, ep, ap)
-struct attribute *attr;
-LDAPMessage *ep;
-char *ap;
+void
+add_value( struct attribute *attr, LDAPMessage *ep, char *ap )
 {
        register int i = 0;
        char **vp, **tp, **avp;
@@ -185,13 +184,12 @@ char *ap;
        ldap_value_free(vp);
 }
 
-print_an_entry()
+void
+print_an_entry( void )
 {
        int n = 0, i, idx;
        char is_a_group, **order;
        char *sub_list[MAX_VALUES], buf[SMALL_BUF_SIZE];
-       extern int col_size, isaurl(), isadn();
-       static char *time2text();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -277,8 +275,8 @@ print_an_entry()
 #define OUT_LABEL_LEN  20
 
 /* prints the values associated with an attribute */
-print_values(A)
-struct attribute A;
+void
+print_values( struct attribute A )
 {
        register int i, k;
        register char *cp, **vp;
@@ -348,7 +346,7 @@ struct attribute A;
                                        putchar('\n');
                                        for (k = lead; k > 0; k--)
                                                putchar(' ');
-                                       while (isspace(*(cp + 1)))
+                                       while (isspace((unsigned char) cp[1]))
                                                cp++;
                                }
                                else
@@ -370,13 +368,12 @@ struct attribute A;
 }
 
 /* prints the DN's associated with an attribute */
-print_DN(A)
-struct attribute A;
+void
+print_DN( struct attribute A )
 {
        int i, lead;
        register char **vp;
        char out_buf[MED_BUF_SIZE], *padding = NULL;
-       extern int col_size;
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -407,10 +404,10 @@ struct attribute A;
        return;
 }
 
-void clear_entry()
+void
+clear_entry( void )
 {
        register int i;
-       extern struct attribute attrlist[];
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -419,7 +416,7 @@ void clear_entry()
                printf(" Clearing entry \"%s\"\n", Entry.name);
 #endif
        if (Entry.DN != NULL)
-               Free(Entry.DN);
+               ldap_memfree(Entry.DN);
        if (Entry.name != NULL)
                Free(Entry.name);
        Entry.may_join = FALSE;
@@ -456,11 +453,10 @@ void clear_entry()
        }
 }
 
-attr_to_index(s)
-char *s;
+int
+attr_to_index( char *s )
 {
        register int i;
-       extern struct attribute attrlist[];
 
        for (i = 0; attrlist[i].quipu_name != NULL; i++)
                if (!strcasecmp(s, attrlist[i].quipu_name))
@@ -468,11 +464,10 @@ char *s;
        return(-1);
 }
 
-void initialize_attribute_strings()
+void
+initialize_attribute_strings( void )
 {
        register int i;
-       extern struct entry Entry;
-       extern struct attribute attrlist[];
 
        for (i = 0; attrlist[i].quipu_name != NULL; i++)
                Entry.attrs[i].quipu_name = attrlist[i].quipu_name;
@@ -481,8 +476,8 @@ void initialize_attribute_strings()
 }
 
 /* prints the URL/label pairs associated with an attribute */
-print_URL(A)
-struct attribute A;
+void
+print_URL( struct attribute A )
 {
        int i, lead;
        register char **vp;
@@ -516,25 +511,20 @@ struct attribute A;
        return;
 }
 
-print_one_URL(s, label_lead, tag, url_lead)
-char *s;
-int label_lead;
-char *tag;
-int url_lead;
+void
+print_one_URL( char *s, int label_lead, char *tag, int url_lead )
 {
        register int i;
        char c, *cp, *url;
-       extern int col_size;
-       extern void Free();
 
-       for (cp = s; !isspace(*cp) && (*cp != '\0'); cp++)
+       for (cp = s; !isspace((unsigned char)*cp) && (*cp != '\0'); cp++)
                ;
        c = *cp;
        *cp = '\0';
        url = strdup(s);
        *cp = c;
        if (*cp != '\0') {
-               for (cp++; isspace(*cp); cp++)
+               for (cp++; isspace((unsigned char)*cp); cp++)
                        ;
        }
        else
@@ -547,7 +537,7 @@ int url_lead;
 }
 
 
-#define GET2BYTENUM( p )       (( *p - '0' ) * 10 + ( *(p+1) - '0' ))
+#define GET2BYTENUM( p )       (( *(p) - '0' ) * 10 + ( *((p)+1) - '0' ))
 
 static char *
 time2text( char *ldtimestr, int dateonly )
@@ -555,21 +545,32 @@ time2text( char *ldtimestr, int dateonly )
     struct tm          t;
     char               *p, *timestr, zone, *fmterr = "badly formatted time";
     time_t             gmttime;
-    static long                gtime();
+       int ndigits;
 
-    memset( (char *)&t, 0, sizeof( struct tm ));
-    if ( strlen( ldtimestr ) < 13 ) {
-       return( fmterr );
+       if (strlen( ldtimestr ) < 12 ) {
+               return( fmterr );
+       }
+
+    for ( ndigits=0; isdigit((unsigned char) ldtimestr[ndigits]); ndigits++) {
+               ; /* EMPTY */
     }
 
-    for ( p = ldtimestr; p - ldtimestr < 12; ++p ) {
-       if ( !isdigit( *p )) {
+       if ( ndigits != 12 && ndigits != 14) {
            return( fmterr );
        }
-    }
+       
+    memset( (char *)&t, 0, sizeof( struct tm ));
 
     p = ldtimestr;
+
+       if( ndigits == 14) {
+               /* came with a century */
+               /* POSIX says tm_year should be year - 1900 */
+       t.tm_year = 100 * GET2BYTENUM( p ) - 1900;
+               p += 2;
+       }
     t.tm_year = GET2BYTENUM( p ); p += 2;
+
     t.tm_mon = GET2BYTENUM( p ) - 1; p += 2;
     t.tm_mday = GET2BYTENUM( p ); p += 2;
     t.tm_hour = GET2BYTENUM( p ); p += 2;
@@ -585,19 +586,16 @@ time2text( char *ldtimestr, int dateonly )
 
     timestr[ strlen( timestr ) - 1 ] = zone;   /* replace trailing newline */
     if ( dateonly ) {
-       strcpy( timestr + 11, timestr + 20 );
+       SAFEMEMCPY( timestr + 11, timestr + 20, strlen( timestr + 20 ) + 1 );
     }
 
-    Free ( ldtimestr );
     return( strdup( timestr ) );
 }
 
 
 /* gtime.c - inverse gmtime */
 
-#if !defined( MACOS ) && !defined( _WIN32 ) && !defined( DOS )
-#include <sys/time.h>
-#endif /* !MACOS */
+#include <ac/time.h>
 
 /* gtime(): the inverse of localtime().
        This routine was supplied by Mike Accetta at CMU many years ago.
@@ -610,11 +608,24 @@ int       dmsize[] = {
 #define        dysize(y)       \
        (((y) % 4) ? 365 : (((y) % 100) ? 366 : (((y) % 400) ? 365 : 366)))
 
-#define        YEAR(y)         ((y) >= 100 ? (y) : (y) + 1900)
+/*
+ * Y2K YEAR
+ */
+       /* per STDC & POSIX tm_year *should* be offset by 1900 */
+#define YEAR_POSIX(y)          ((y) + 1900)
+
+       /*
+        * year is < 1900, year is offset by 1900
+        */
+#define YEAR_CAREFUL(y)                ((y) < 1900 ? (y) + 1900 : (y))
+
+#define YEAR(y) YEAR_CAREFUL(y)
+
 
 /* \f */
 
-static long    gtime ( struct tm *tm )
+static long
+gtime( struct tm *tm )
 {
     register int    i,
                     sec,
index cff99b3612d25e0f5bb992027264d05637467372..8a6a5ae70f5c9882d56e95f1426b5296a1c14fbb 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 #include "portable.h"
 
 #if defined(HAVE_KERBEROS) && !defined(openbsd)
index 40b6ecff7a0e7e90b22c68ae46a4aec7a262fe40..fa07c3531d617de4d589c6b6d05d257385e21496 100644 (file)
@@ -1,3 +1,13 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
 /*
  * Copyright (c) 1991, 1992, 1993 
  * Regents of the University of Michigan.  All rights reserved.
  * is provided ``as is'' without express or implied warranty.
  */
 
-#ifdef DOS
-#include "protoud.h"
-#define strncasecmp(a, b, n)   strnicmp(a, b, n)
-#define strcasecmp(a, b)       stricmp(a, b)
-#define MAX_VALUES     8
-#else
 #define MAX_VALUES     1000
-#endif /* end of DOS ifdef */
 
 /*****************************************************************************
  **
@@ -35,7 +38,7 @@
  *  parsing names.
  */
 #define MAX_NAME_COMPS         8
-#define isnamesepartor(x)      (isspace(x))
+#define isnamesepartor(x)      (isspace((unsigned char) (x)))
 #define isignorechar(x)                (((x) == '.') || ((x) == '_'))
 
 /*
@@ -87,7 +90,7 @@
 /*
  *  Authentication method we will be using.
  */
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
 #define UD_AUTH_METHOD         LDAP_AUTH_KRBV4
 #else
 #define UD_AUTH_METHOD         LDAP_AUTH_SIMPLE
 #define ATTR_FLAG_IS_A_BOOL    0x4000
 #define ATTR_FLAG_IS_MULTILINE 0x8000
 
+LDAP_BEGIN_DECL
+
 /*
  *  These are the structures we use when parsing an answer we get from the LDAP
  *  server.
 struct attribute {
        char *quipu_name;
        char *output_string;
-       void (*mod_func)();
+       void (*mod_func) LDAP_P(( char *who, int attr_idx ));
        unsigned short flags;
        int number_of_values;
        char **values;
@@ -156,3 +161,145 @@ struct entry {
        char *name;
        struct attribute attrs[MAX_ATTRS];
 };
+
+
+
+/*
+ * Variables
+ */
+
+/* in globals.c: */
+extern struct attribute attrlist[];/* complete list of attrs */
+/* in main.c: */
+extern char copyright[];
+extern char *default_bind_object;
+extern char *bound_dn;
+extern char *group_base;
+extern char *search_base;      /* search base */
+extern int lpp;
+extern int verbose;            /* verbose mode flag */
+extern int col_size;
+extern int bind_status;
+extern LDAP *ld;               /* our ldap descriptor */
+extern LDAPFiltDesc *lfdp;     /* LDAP filter descriptor */
+#ifdef DEBUG
+extern int debug;              /* debug flag */
+#endif
+/* in print.c: */
+extern struct entry Entry;
+extern int     dmsize[];
+/* in version.c: */
+extern char Version[];
+
+
+/*
+ * Functions
+ */
+
+/* in auth.c: */
+int  auth      LDAP_P(( char *who, int implicit ));
+#if defined(HAVE_KERBEROS) && defined(_AC_KRB_H)
+int  krbgetpass LDAP_P(( char *u, char *in, char *re, char *pw, C_Block key ));
+void destroy_tickets LDAP_P(( void ));
+#endif
+
+/* in edit.c: */
+void edit      LDAP_P(( char *who ));
+
+/* in find.c: */
+int  vrfy      LDAP_P(( char *dn ));
+LDAPMessage *find      LDAP_P(( char *who, int quiet ));
+int  pick_one  LDAP_P(( int i ));
+void print_list        LDAP_P(( LDAPMessage *list, char **names, int *matches ));
+int  find_all_subscribers      LDAP_P(( char **sub, char *group ));
+char *fetch_boolean_value      LDAP_P(( char *who, struct attribute attr ));
+
+/* in globals.c: */
+
+/* in group.c: */
+void add_group LDAP_P(( char *name ));
+void remove_group      LDAP_P(( char *name ));
+void x_group   LDAP_P(( int action, char *name ));
+void bulk_load LDAP_P(( char *group ));
+void purge_group       LDAP_P(( char *group ));
+void tidy_up   LDAP_P(( void ));
+void mod_addrDN        LDAP_P(( char *group, int offset ));
+int  my_ldap_modify_s  LDAP_P(( LDAP *ldap, char *group, LDAPMod **mods ));
+void list_groups       LDAP_P(( char *who ));
+void list_memberships  LDAP_P(( char *who ));
+
+/* in help.c: */
+void print_help        LDAP_P(( char *s ));
+
+/* in main.c: */
+#ifdef DEBUG
+#endif
+
+void do_commands       LDAP_P(( void )) LDAP_GCCATTR((noreturn));
+void status    LDAP_P(( void ));
+void change_base       LDAP_P(( int type, char **base, char *s ));
+void initialize_client LDAP_P(( void ));
+RETSIGTYPE  attn       LDAP_P(( int sig ));
+#if !defined(NO_TERMCAP) && defined(TIOCGWINSZ)
+RETSIGTYPE  chwinsz    LDAP_P(( int sig ));
+#endif
+
+/* in mod.c: */
+void modify    LDAP_P(( char *who ));
+void change_field      LDAP_P(( char *who, int attr_idx ));
+char *get_value        LDAP_P(( char *id, char *prompt ));
+void set_boolean       LDAP_P(( char *who, int attr_idx ));
+#ifdef UOFM
+void set_updates       LDAP_P(( char *who, int dummy ));
+#endif
+void print_mod_list    LDAP_P(( int group ));
+int  perform_action    LDAP_P(( char *choice, char *dn, int group ));
+void mod_perror        LDAP_P(( LDAP *ld ));
+
+/* in print.c: */
+void parse_answer      LDAP_P(( LDAPMessage *s ));
+void add_value LDAP_P(( struct attribute *attr, LDAPMessage *ep, char *ap ));
+void print_an_entry    LDAP_P(( void ));
+void print_values      LDAP_P(( struct attribute A ));
+void print_DN  LDAP_P(( struct attribute A ));
+void clear_entry       LDAP_P(( void ));
+int  attr_to_index     LDAP_P(( char *s ));
+void initialize_attribute_strings      LDAP_P(( void ));
+void print_URL LDAP_P(( struct attribute A ));
+void print_one_URL     LDAP_P(( char *s, int l_lead, char *tag, int u_lead ));
+
+/* in string_to_key.c: */
+#if defined(HAVE_KERBEROS) && !defined(openbsd) && defined(_AC_KRB_H)
+#if defined(HAVE_AFS_KERBEROS) || !defined(HAVE_KERBEROS_V)
+void  des_string_to_key        LDAP_P(( char *str, des_cblock *key ));
+#endif
+#if defined(HAVE_AFS_KERBEROS)
+void ka_StringToKey LDAP_P(( char *str, char *cell, des_cblock *key ));
+#endif
+#endif
+
+/* in util.c: */
+void printbase LDAP_P(( char *lead, char *s ));
+void fetch_buffer      LDAP_P(( char *buffer, int length, FILE *where ));
+void fatal     LDAP_P(( char *s )) LDAP_GCCATTR((noreturn));
+int  isgroup   LDAP_P(( void ));
+void format    LDAP_P(( char *str, int width, int lead ));
+void format2   LDAP_P(( char *s, char *ft, char *t, int fi, int i, int w ));
+char *strip_ignore_chars       LDAP_P(( char *cp ));
+char *code_to_str      LDAP_P(( int i ));
+char *friendly_name    LDAP_P(( char *s ));
+#ifdef UOFM
+int  isauniqname       LDAP_P(( char *s ));
+#endif
+int  isadn     LDAP_P(( char *s ));
+char *my_ldap_dn2ufn   LDAP_P(( char *s ));
+int  isaurl    LDAP_P(( char *s ));
+int  isadate   LDAP_P(( char *s ));
+void *Malloc   LDAP_P(( unsigned int size ));
+void Free      LDAP_P(( void *ptr ));
+char *nextstr  LDAP_P(( char *s ));
+void free_mod_struct   LDAP_P(( LDAPMod *modp ));
+void StrFreeDup        LDAP_P(( char **ptr, char *new_value ));
+int  confirm_action    LDAP_P(( char *msg ));
+
+LDAP_END_DECL
index 2efd2895d666f7ca457662f9d2eb638d78b14ef3..27023de75990dfd1d8a96b09ae8d10e9feeb91e1 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1992, 1993  Regents of the University of Michigan.
  * All rights reserved.
index aff1b9a483936f752be773a3801b009b96caa111..214318b211c5ec6e65ea7abdd03b8a7ec7c94386 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,4 +1,13 @@
 #! /bin/sh
+# $OpenLDAP$
+# from OpenLDAP: pkg/ldap/configure.in,v 1.256 1999/09/10 00:10:20 kdz Exp  
+
+# Copyright 1998,1999 The OpenLDAP Foundation.  All Rights Reserved.
+# 
+# Redistribution and use in source and binary forms are permitted only
+# as authorized by the OpenLDAP Public License.  A copy of this
+# license is available at http://www.OpenLDAP.org/license.html or
+# in file LICENSE in the top-level directory of the distribution.
 
 # Guess values for system-dependent variables and create Makefiles.
 # Generated automatically using autoconf version 2.13.1 
@@ -23,7 +32,7 @@ ac_help="$ac_help
 ac_help="$ac_help
   --enable-cache       enable caching (yes)"
 ac_help="$ac_help
-  --enable-dns         enable V2 DNS  extension (no)"
+  --enable-dns         enable V2 DX Referrals extension (no)"
 ac_help="$ac_help
   --enable-referrals   enable V2 Referrals extension (yes)"
 ac_help="$ac_help
@@ -33,21 +42,21 @@ ac_help="$ac_help
 ac_help="$ac_help
   --enable-dmalloc     enable debug malloc support (no)"
 ac_help="$ac_help
-  --with-cyrus-sasl  with Cyrus SASL support (auto)"
+  --with-cyrus-sasl    with Cyrus SASL support (auto)"
 ac_help="$ac_help
-  --with-fetch  with fetch URL support (auto)"
+  --with-fetch         with fetch URL support (auto)"
 ac_help="$ac_help
   --with-kerberos      with Kerberos support (auto)"
 ac_help="$ac_help
-  --with-readline  with readline support (auto)"
+  --with-readline      with readline support (auto)"
 ac_help="$ac_help
   --with-threads       use threads (auto)"
 ac_help="$ac_help
-  --with-tls  with TLS/SSL support (auto)"
+  --with-tls           with TLS/SSL support (auto)"
 ac_help="$ac_help
   --with-yielding-select       with implicitly yielding select (auto)"
 ac_help="$ac_help
-SLAPD Options:"
+SLAPD (Standalone LDAP Daemon) Options:"
 ac_help="$ac_help
   --enable-slapd       enable building slapd (yes)"
 ac_help="$ac_help
@@ -64,6 +73,10 @@ ac_help="$ac_help
     --enable-quipu     build quipu migration tools (no)"
 ac_help="$ac_help
     --enable-rlookups  enable reverse lookups (auto)"
+ac_help="$ac_help
+    --enable-aci       enable per-object ACIs (no)"
+ac_help="$ac_help
+    --enable-discreteaci       enable discrete rights in ACIs (no)"
 ac_help="$ac_help
     --enable-wrappers  enable tcp wrapper support (no)"
 ac_help="$ac_help
@@ -76,10 +89,10 @@ ac_help="$ac_help
       --with-ldap-module       module type (static)"
 ac_help="$ac_help
     --enable-ldbm      enable ldbm backend (yes)"
-ac_help="$ac_help
-      --with-ldbm-module       module type (static)"
 ac_help="$ac_help
       --with-ldbm-api  use LDBM API (auto)"
+ac_help="$ac_help
+      --with-ldbm-module       module type (static)"
 ac_help="$ac_help
       --with-ldbm-type use LDBM type (auto)"
 ac_help="$ac_help
@@ -99,7 +112,7 @@ ac_help="$ac_help
 ac_help="$ac_help
       --with-tcl-module        module type (static)"
 ac_help="$ac_help
-SLURPD Options:"
+SLURPD (Replication Daemon) Options:"
 ac_help="$ac_help
   --enable-slurpd      enable building slurpd (auto)"
 ac_help="$ac_help
@@ -642,7 +655,7 @@ fi
 
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:646: checking host system type" >&5
+echo "configure:659: checking host system type" >&5
 if test "x$ac_cv_host" = "x" || (test "x$host" != "xNONE" && test "x$host" != "x$ac_cv_host_alias"); then
 
 # Make sure we can run config.sub.
@@ -683,7 +696,7 @@ host_os=$ac_cv_host_os
 
 
 echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:687: checking target system type" >&5
+echo "configure:700: checking target system type" >&5
 if test "x$ac_cv_target" = "x" || (test "x$target" != "xNONE" && test "x$target" != "x$ac_cv_target_alias"); then
 
 # Make sure we can run config.sub.
@@ -723,7 +736,7 @@ target_os=$ac_cv_target_os
 
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:727: checking build system type" >&5
+echo "configure:740: checking build system type" >&5
 if test "x$ac_cv_build" = "x" || (test "x$build" != "xNONE" && test "x$build" != "x$ac_cv_build_alias"); then
 
 # Make sure we can run config.sub.
@@ -800,7 +813,7 @@ test "$host_alias" != "$target_alias" &&
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:804: checking for a BSD compatible install" >&5
+echo "configure:817: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"\${ac_cv_path_install+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -857,7 +870,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
-echo "configure:861: checking whether build environment is sane" >&5
+echo "configure:874: checking whether build environment is sane" >&5
 # Just in case
 sleep 1
 echo timestamp > conftestfile
@@ -918,7 +931,7 @@ 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:922: checking for $ac_word" >&5
+echo "configure:935: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_prog_AWK+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -948,7 +961,7 @@ test -n "$AWK" && break
 done
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:952: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:965: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -988,7 +1001,7 @@ fi
 
 missing_dir=`cd $ac_aux_dir && pwd`
 echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
-echo "configure:992: checking for working aclocal" >&5
+echo "configure:1005: checking for working aclocal" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -1001,7 +1014,7 @@ else
 fi
 
 echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
-echo "configure:1005: checking for working autoconf" >&5
+echo "configure:1018: checking for working autoconf" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -1014,7 +1027,7 @@ else
 fi
 
 echo $ac_n "checking for working automake""... $ac_c" 1>&6
-echo "configure:1018: checking for working automake" >&5
+echo "configure:1031: checking for working automake" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -1027,7 +1040,7 @@ else
 fi
 
 echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
-echo "configure:1031: checking for working autoheader" >&5
+echo "configure:1044: checking for working autoheader" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -1040,7 +1053,7 @@ else
 fi
 
 echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
-echo "configure:1044: checking for working makeinfo" >&5
+echo "configure:1057: checking for working makeinfo" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -1060,7 +1073,7 @@ 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:1064: checking for $ac_word" >&5
+echo "configure:1077: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_prog_AMTAR+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1111,7 +1124,7 @@ EOF
 
 
 echo $ac_n "checking configure arguments""... $ac_c" 1>&6
-echo "configure:1115: checking configure arguments" >&5
+echo "configure:1128: checking configure arguments" >&5
 
 
 top_builddir=`pwd`
@@ -1409,7 +1422,7 @@ if test "${with_threads+set}" = set; then
   withval="$with_threads"
   
        ol_arg=invalid
-       for ol_val in auto posix mach lwp yes no manual  ; do
+       for ol_val in auto posix mach pth lwp yes no manual  ; do
                if test "$withval" = "$ol_val" ; then
                        ol_arg="$ol_val"
                fi
@@ -1634,6 +1647,46 @@ else
        ol_enable_rlookups="auto"
 fi
 # end --enable-rlookups
+# OpenLDAP --enable-aci
+       # Check whether --enable-aci or --disable-aci was given.
+if test "${enable_aci+set}" = set; then
+  enableval="$enable_aci"
+  
+       ol_arg=invalid
+       for ol_val in auto yes no ; do
+               if test "$enableval" = "$ol_val" ; then
+                       ol_arg="$ol_val"
+               fi
+       done
+       if test "$ol_arg" = "invalid" ; then
+               { echo "configure: error: bad value $enableval for --enable-aci" 1>&2; exit 1; }
+       fi
+       ol_enable_aci="$ol_arg"
+
+else
+       ol_enable_aci="no"
+fi
+# end --enable-aci
+# OpenLDAP --enable-discreteaci
+       # Check whether --enable-discreteaci or --disable-discreteaci was given.
+if test "${enable_discreteaci+set}" = set; then
+  enableval="$enable_discreteaci"
+  
+       ol_arg=invalid
+       for ol_val in auto yes no ; do
+               if test "$enableval" = "$ol_val" ; then
+                       ol_arg="$ol_val"
+               fi
+       done
+       if test "$ol_arg" = "invalid" ; then
+               { echo "configure: error: bad value $enableval for --enable-discreteaci" 1>&2; exit 1; }
+       fi
+       ol_enable_discreteaci="$ol_arg"
+
+else
+       ol_enable_discreteaci="no"
+fi
+# end --enable-discreteaci
 # OpenLDAP --enable-wrappers
        # Check whether --enable-wrappers or --disable-wrappers was given.
 if test "${enable_wrappers+set}" = set; then
@@ -1757,47 +1810,47 @@ else
        ol_enable_ldbm="yes"
 fi
 # end --enable-ldbm
-# OpenLDAP --with-ldbm_module
-       # Check whether --with-ldbm_module or --without-ldbm_module was given.
-if test "${with_ldbm_module+set}" = set; then
-  withval="$with_ldbm_module"
+# OpenLDAP --with-ldbm_api
+       # Check whether --with-ldbm_api or --without-ldbm_api was given.
+if test "${with_ldbm_api+set}" = set; then
+  withval="$with_ldbm_api"
   
        ol_arg=invalid
-       for ol_val in static dynamic ; do
+       for ol_val in auto db2 db mdbm gdbm ndbm manual ; do
                if test "$withval" = "$ol_val" ; then
                        ol_arg="$ol_val"
                fi
        done
        if test "$ol_arg" = "invalid" ; then
-               { echo "configure: error: bad value $withval for --with-ldbm_module" 1>&2; exit 1; }
+               { echo "configure: error: bad value $withval for --with-ldbm_api" 1>&2; exit 1; }
        fi
-       ol_with_ldbm_module="$ol_arg"
+       ol_with_ldbm_api="$ol_arg"
 
 else
-       ol_with_ldbm_module="static"
+       ol_with_ldbm_api="auto"
 fi
-# end --with-ldbm_module
+# end --with-ldbm_api
 
-# OpenLDAP --with-ldbm_api
-       # Check whether --with-ldbm_api or --without-ldbm_api was given.
-if test "${with_ldbm_api+set}" = set; then
-  withval="$with_ldbm_api"
+# OpenLDAP --with-ldbm_module
+       # Check whether --with-ldbm_module or --without-ldbm_module was given.
+if test "${with_ldbm_module+set}" = set; then
+  withval="$with_ldbm_module"
   
        ol_arg=invalid
-       for ol_val in auto db2 db mdbm gdbm ndbm manual ; do
+       for ol_val in static dynamic ; do
                if test "$withval" = "$ol_val" ; then
                        ol_arg="$ol_val"
                fi
        done
        if test "$ol_arg" = "invalid" ; then
-               { echo "configure: error: bad value $withval for --with-ldbm_api" 1>&2; exit 1; }
+               { echo "configure: error: bad value $withval for --with-ldbm_module" 1>&2; exit 1; }
        fi
-       ol_with_ldbm_api="$ol_arg"
+       ol_with_ldbm_module="$ol_arg"
 
 else
-       ol_with_ldbm_api="auto"
+       ol_with_ldbm_module="static"
 fi
-# end --with-ldbm_api
+# end --with-ldbm_module
 
 # OpenLDAP --with-ldbm_type
        # Check whether --with-ldbm_type or --without-ldbm_type was given.
@@ -2117,6 +2170,12 @@ if test $ol_enable_slapd = no ; then
        if test $ol_enable_rlookups = yes ; then
                echo "configure: warning: slapd disabled, ignoring --enable-rlookups argument" 1>&2
        fi
+       if test $ol_enable_aci = yes ; then
+               echo "configure: warning: slapd disabled, ignoring --enable-aci argument" 1>&2
+       fi
+       if test $ol_enable_discreteaci = yes ; then
+               echo "configure: warning: slapd disabled, ignoring --enable-discreteaci argument" 1>&2
+       fi
        if test $ol_with_ldbm_api != auto ; then
                echo "configure: warning: slapd disabled, ignoring --with-ldbm-api argument" 1>&2
        fi
@@ -2162,6 +2221,8 @@ if test $ol_enable_slapd = no ; then
        ol_enable_phonetic=no
        ol_enable_quipu=no
        ol_enable_rlookups=no
+       ol_enable_aci=no
+       ol_enable_discreteaci=no
        ol_enable_wrappers=no
 
        ol_with_ldbm_api=no
@@ -2303,7 +2364,6 @@ EOF
 
 
 
-
 ol_aix_threads=no
 case "$target" in
 *-*-aix*)      if test -z "$CC" ; then
@@ -2321,7 +2381,7 @@ 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:2325: checking for $ac_word" >&5
+echo "configure:2385: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2373,7 +2433,7 @@ 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:2377: checking for $ac_word" >&5
+echo "configure:2437: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2432,7 +2492,7 @@ fi
 # 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:2436: checking for $ac_word" >&5
+echo "configure:2496: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_prog_RANLIB+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2462,7 +2522,7 @@ fi
 # 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:2466: checking for $ac_word" >&5
+echo "configure:2526: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2492,7 +2552,7 @@ 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:2496: checking for $ac_word" >&5
+echo "configure:2556: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2543,7 +2603,7 @@ fi
       # 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:2547: checking for $ac_word" >&5
+echo "configure:2607: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2575,7 +2635,7 @@ fi
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:2579: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works" >&5
+echo "configure:2639: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -2586,12 +2646,12 @@ cross_compiling=$ac_cv_prog_cc_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 2590 "configure"
+#line 2650 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:2595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2655: \"$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
@@ -2617,12 +2677,12 @@ 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 $CPPFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:2621: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2681: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $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:2626: checking whether we are using GNU C" >&5
+echo "configure:2686: checking whether we are using GNU C" >&5
 if eval "test \"\${ac_cv_prog_gcc+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2631,7 +2691,7 @@ else
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2635: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2695: \"$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
@@ -2650,7 +2710,7 @@ 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:2654: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:2714: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"\${ac_cv_prog_cc_g+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2693,7 +2753,7 @@ ac_prog=ld
 if test "$ac_cv_prog_gcc" = yes; then
   # Check if gcc -print-prog-name=ld gives a path.
   echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
-echo "configure:2697: checking for ld used by GCC" >&5
+echo "configure:2757: checking for ld used by GCC" >&5
   ac_prog=`($CC -print-prog-name=ld) 2>&5`
   case "$ac_prog" in
     # Accept absolute paths.
@@ -2717,10 +2777,10 @@ echo "configure:2697: checking for ld used by GCC" >&5
   esac
 elif test "$with_gnu_ld" = yes; then
   echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
-echo "configure:2721: checking for GNU ld" >&5
+echo "configure:2781: checking for GNU ld" >&5
 else
   echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
-echo "configure:2724: checking for non-GNU ld" >&5
+echo "configure:2784: checking for non-GNU ld" >&5
 fi
 if eval "test \"\${ac_cv_path_LD+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2756,7 +2816,7 @@ fi
 test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
 
 echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
-echo "configure:2760: checking if the linker ($LD) is GNU ld" >&5
+echo "configure:2820: checking if the linker ($LD) is GNU ld" >&5
 if eval "test \"\${ac_cv_prog_gnu_ld+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2772,7 +2832,7 @@ echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6
 
 
 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
-echo "configure:2776: checking for BSD-compatible nm" >&5
+echo "configure:2836: checking for BSD-compatible nm" >&5
 if eval "test \"\${ac_cv_path_NM+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2809,7 +2869,7 @@ echo "$ac_t""$NM" 1>&6
 
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:2813: checking whether ln -s works" >&5
+echo "configure:2873: checking whether ln -s works" >&5
 if eval "test \"\${ac_cv_prog_LN_S+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2853,8 +2913,8 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
 case "$host" in
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 2857 "configure"' > conftest.$ac_ext
-  if { (eval echo configure:2858: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  echo '#line 2917 "configure"' > conftest.$ac_ext
+  if { (eval echo configure:2918: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case "`/usr/bin/file conftest.o`" in
     *32-bit*)
       LD="${LD-ld} -32"
@@ -2875,19 +2935,19 @@ case "$host" in
   SAVE_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS -belf"
   echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
-echo "configure:2879: checking whether the C compiler needs -belf" >&5
+echo "configure:2939: checking whether the C compiler needs -belf" >&5
 if eval "test \"\${lt_cv_cc_needs_belf+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2884 "configure"
+#line 2944 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2891: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2951: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   lt_cv_cc_needs_belf=yes
 else
@@ -2941,7 +3001,7 @@ 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:2945: checking for $ac_word" >&5
+echo "configure:3005: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_prog_AWK+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2972,7 +3032,7 @@ done
 
 # test for ln hardlink support
 echo $ac_n "checking whether ln works""... $ac_c" 1>&6
-echo "configure:2976: checking whether ln works" >&5
+echo "configure:3036: checking whether ln works" >&5
 if eval "test \"\${ol_cv_prog_LN_H+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2995,7 +3055,7 @@ else
 fi
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:2999: checking whether ln -s works" >&5
+echo "configure:3059: checking whether ln -s works" >&5
 if eval "test \"\${ac_cv_prog_LN_S+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3023,7 +3083,7 @@ fi
 # Extract the first word of "sendmail", so it can be a program name with args.
 set dummy sendmail; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3027: checking for $ac_word" >&5
+echo "configure:3087: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_path_SENDMAIL+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3059,7 +3119,7 @@ fi
 # Extract the first word of "vi", so it can be a program name with args.
 set dummy vi; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3063: checking for $ac_word" >&5
+echo "configure:3123: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_path_EDITOR+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3095,7 +3155,7 @@ fi
 # Extract the first word of "finger", so it can be a program name with args.
 set dummy finger; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3099: checking for $ac_word" >&5
+echo "configure:3159: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_path_FINGER+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3134,7 +3194,7 @@ if test $ol_enable_perl != no ; then
        # Extract the first word of "perl", so it can be a program name with args.
 set dummy perl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3138: checking for $ac_word" >&5
+echo "configure:3198: checking for $ac_word" >&5
 if eval "test \"\${ac_cv_path_PERLBIN+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3182,7 +3242,7 @@ fi
 fi
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:3186: checking how to run the C preprocessor" >&5
+echo "configure:3246: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -3197,13 +3257,13 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 3201 "configure"
+#line 3261 "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:3207: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3267: \"$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
   :
@@ -3214,13 +3274,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 3218 "configure"
+#line 3278 "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:3224: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3284: \"$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
   :
@@ -3231,13 +3291,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 3235 "configure"
+#line 3295 "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:3241: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3301: \"$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
   :
@@ -3275,9 +3335,9 @@ elif test $cross_compiling = yes -a $ol_enable_x_compile = no; then
 fi
 
 echo $ac_n "checking for AIX""... $ac_c" 1>&6
-echo "configure:3279: checking for AIX" >&5
+echo "configure:3339: checking for AIX" >&5
 cat > conftest.$ac_ext <<EOF
-#line 3281 "configure"
+#line 3341 "configure"
 #include "confdefs.h"
 #ifdef _AIX
   yes
@@ -3299,7 +3359,7 @@ rm -f conftest*
 
 
 echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
-echo "configure:3303: checking for POSIXized ISC" >&5
+echo "configure:3363: checking for POSIXized ISC" >&5
 if test -d /etc/conf/kconfig.d &&
   grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
 then
@@ -3321,17 +3381,17 @@ fi
 
 ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6
-echo "configure:3325: checking for minix/config.h" >&5
+echo "configure:3385: checking for minix/config.h" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3330 "configure"
+#line 3390 "configure"
 #include "confdefs.h"
 #include <minix/config.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3335: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3395: \"$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*
@@ -3370,12 +3430,12 @@ fi
 
 
 echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
-echo "configure:3374: checking for Cygwin environment" >&5
+echo "configure:3434: checking for Cygwin environment" >&5
 if eval "test \"\${ac_cv_cygwin+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3379 "configure"
+#line 3439 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3386,7 +3446,7 @@ int main() {
 return __CYGWIN__;
 ; return 0; }
 EOF
-if { (eval echo configure:3390: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3450: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_cygwin=yes
 else
@@ -3402,19 +3462,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6
 CYGWIN=
 test "$ac_cv_cygwin" = yes && CYGWIN=yes
 echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
-echo "configure:3406: checking for mingw32 environment" >&5
+echo "configure:3466: checking for mingw32 environment" >&5
 if eval "test \"\${ac_cv_mingw32+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3411 "configure"
+#line 3471 "configure"
 #include "confdefs.h"
 
 int main() {
 return __MINGW32__;
 ; return 0; }
 EOF
-if { (eval echo configure:3418: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3478: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_mingw32=yes
 else
@@ -3430,19 +3490,19 @@ echo "$ac_t""$ac_cv_mingw32" 1>&6
 MINGW32=
 test "$ac_cv_mingw32" = yes && MINGW32=yes
 echo $ac_n "checking for EMX OS/2 environment""... $ac_c" 1>&6
-echo "configure:3434: checking for EMX OS/2 environment" >&5
+echo "configure:3494: checking for EMX OS/2 environment" >&5
 if eval "test \"\${ac_cv_emxos2+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3439 "configure"
+#line 3499 "configure"
 #include "confdefs.h"
 
 int main() {
 return __EMX__;
 ; return 0; }
 EOF
-if { (eval echo configure:3446: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3506: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_emxos2=yes
 else
@@ -3461,7 +3521,7 @@ test "$ac_cv_emxos2" = yes && EMXOS2=yes
 
 
 echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
-echo "configure:3465: checking for executable suffix" >&5
+echo "configure:3525: checking for executable suffix" >&5
 if eval "test \"\${ac_cv_exeext+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3471,7 +3531,7 @@ else
   rm -f conftest*
   echo 'int main () { return 0; }' > conftest.$ac_ext
   ac_cv_exeext=
-  if { (eval echo configure:3475: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+  if { (eval echo configure:3535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
     for file in conftest.*; do
       case $file in
       *.c | *.C | *.o | *.obj | *.xcoff) ;;
@@ -3492,13 +3552,13 @@ echo "$ac_t""${ac_cv_exeext}" 1>&6
 ac_exeext=$EXEEXT
 
 echo $ac_n "checking for object suffix""... $ac_c" 1>&6
-echo "configure:3496: checking for object suffix" >&5
+echo "configure:3556: checking for object suffix" >&5
 if eval "test \"\${ac_cv_objext+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   rm -f conftest*
 echo 'int i = 1;' > conftest.$ac_ext
-if { (eval echo configure:3502: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3562: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   for ac_file in conftest.*; do
     case $ac_file in
     *.c) ;;
@@ -3522,7 +3582,7 @@ EOF
 
 
 echo $ac_n "checking for be_app in -lbe""... $ac_c" 1>&6
-echo "configure:3526: checking for be_app in -lbe" >&5
+echo "configure:3586: checking for be_app in -lbe" >&5
 ac_lib_var=`echo be'_'be_app | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3530,7 +3590,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbe -lroot -lnet $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3534 "configure"
+#line 3594 "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
@@ -3541,7 +3601,7 @@ int main() {
 be_app()
 ; return 0; }
 EOF
-if { (eval echo configure:3545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3605: \"$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
@@ -3567,7 +3627,7 @@ fi
 
 
 echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6
-echo "configure:3571: checking for ${CC-cc} option to accept ANSI C" >&5
+echo "configure:3631: checking for ${CC-cc} option to accept ANSI C" >&5
 if eval "test \"\${am_cv_prog_cc_stdc+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3584,7 +3644,7 @@ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIO
 do
   CC="$ac_save_CC $ac_arg"
   cat > conftest.$ac_ext <<EOF
-#line 3588 "configure"
+#line 3648 "configure"
 #include "confdefs.h"
 #include <stdarg.h>
 #include <stdio.h>
@@ -3621,7 +3681,7 @@ return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
 
 ; return 0; }
 EOF
-if { (eval echo configure:3625: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3685: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   am_cv_prog_cc_stdc="$ac_arg"; break
 else
@@ -3655,7 +3715,7 @@ if test -z "${MKDEP}"; then
        OL_MKDEP="${CC-cc}"
        if test -z "${MKDEP_FLAGS}"; then
                echo $ac_n "checking for ${OL_MKDEP} depend flag""... $ac_c" 1>&6
-echo "configure:3659: checking for ${OL_MKDEP} depend flag" >&5
+echo "configure:3719: checking for ${OL_MKDEP} depend flag" >&5
 if eval "test \"\${ol_cv_mkdep+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3665,7 +3725,7 @@ else
                                cat > conftest.c <<EOF
  noCode;
 EOF
-                               if { ac_try='$OL_MKDEP $flag conftest.c'; { (eval echo configure:3669: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } \
+                               if { ac_try='$OL_MKDEP $flag conftest.c'; { (eval echo configure:3729: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } \
                                        | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
                                then
                                        if test ! -f conftest."${ac_object}" ; then
@@ -3703,17 +3763,17 @@ if test $ol_enable_modules != no ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3707: checking for $ac_hdr" >&5
+echo "configure:3767: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3712 "configure"
+#line 3772 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3717: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3777: \"$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*
@@ -3746,7 +3806,7 @@ done
        fi
 
        echo $ac_n "checking for lt_dlinit in -lltdl""... $ac_c" 1>&6
-echo "configure:3750: checking for lt_dlinit in -lltdl" >&5
+echo "configure:3810: checking for lt_dlinit in -lltdl" >&5
 ac_lib_var=`echo ltdl'_'lt_dlinit | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3754,7 +3814,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lltdl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3758 "configure"
+#line 3818 "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
@@ -3765,7 +3825,7 @@ int main() {
 lt_dlinit()
 ; return 0; }
 EOF
-if { (eval echo configure:3769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3829: \"$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
@@ -3808,13 +3868,13 @@ fi
 
 # test for EBCDIC
 echo $ac_n "checking for EBCDIC""... $ac_c" 1>&6
-echo "configure:3812: checking for EBCDIC" >&5
+echo "configure:3872: checking for EBCDIC" >&5
 if eval "test \"\${ol_cv_cpp_ebcdic+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
        cat > conftest.$ac_ext <<EOF
-#line 3818 "configure"
+#line 3878 "configure"
 #include "confdefs.h"
 
 #if !('M' == 0xd4)
@@ -3823,7 +3883,7 @@ else
 
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3887: \"$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*
@@ -3847,12 +3907,12 @@ EOF
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:3851: checking for ANSI C header files" >&5
+echo "configure:3911: checking for ANSI C header files" >&5
 if eval "test \"\${ol_cv_header_stdc+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3856 "configure"
+#line 3916 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -3860,7 +3920,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3864: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3924: \"$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*
@@ -3877,7 +3937,7 @@ rm -f conftest*
 if test $ol_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 3881 "configure"
+#line 3941 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -3895,7 +3955,7 @@ fi
 if test $ol_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 3899 "configure"
+#line 3959 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -3916,7 +3976,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 3920 "configure"
+#line 3980 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #ifndef HAVE_EBCDIC
@@ -3934,7 +3994,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:3938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -3968,12 +4028,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:3972: checking for $ac_hdr that defines DIR" >&5
+echo "configure:4032: checking for $ac_hdr that defines DIR" >&5
 if eval "test \"\${ac_cv_header_dirent_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3977 "configure"
+#line 4037 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -3981,7 +4041,7 @@ int main() {
 DIR *dirp = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:3985: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4045: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_header_dirent_$ac_safe=yes"
 else
@@ -4006,7 +4066,7 @@ done
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:4010: checking for opendir in -ldir" >&5
+echo "configure:4070: checking for opendir in -ldir" >&5
 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4014,7 +4074,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldir  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4018 "configure"
+#line 4078 "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
@@ -4025,7 +4085,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:4029: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4089: \"$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
@@ -4047,7 +4107,7 @@ fi
 
 else
 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:4051: checking for opendir in -lx" >&5
+echo "configure:4111: checking for opendir in -lx" >&5
 ac_lib_var=`echo x'_'opendir | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4055,7 +4115,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lx  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4059 "configure"
+#line 4119 "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
@@ -4066,7 +4126,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:4070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4130: \"$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
@@ -4089,12 +4149,12 @@ fi
 fi
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:4093: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:4153: checking for sys/wait.h that is POSIX.1 compatible" >&5
 if eval "test \"\${ac_cv_header_sys_wait_h+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4098 "configure"
+#line 4158 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -4110,7 +4170,7 @@ wait (&s);
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:4114: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4174: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -4131,12 +4191,12 @@ EOF
 fi
 
 echo $ac_n "checking POSIX termios""... $ac_c" 1>&6
-echo "configure:4135: checking POSIX termios" >&5
+echo "configure:4195: checking POSIX termios" >&5
 if eval "test \"\${am_cv_sys_posix_termios+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4140 "configure"
+#line 4200 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <unistd.h>
@@ -4146,7 +4206,7 @@ int main() {
    tcgetattr(0, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:4150: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4210: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   am_cv_sys_posix_termios=yes
 else
@@ -4162,7 +4222,7 @@ echo "$ac_t""$am_cv_sys_posix_termios" 1>&6
 
 
  echo $ac_n "checking whether use of TIOCGWINSZ requires sys/ioctl.h""... $ac_c" 1>&6
-echo "configure:4166: checking whether use of TIOCGWINSZ requires sys/ioctl.h" >&5
+echo "configure:4226: checking whether use of TIOCGWINSZ requires sys/ioctl.h" >&5
 if eval "test \"\${am_cv_sys_tiocgwinsz_needs_sys_ioctl_h+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4171,7 +4231,7 @@ else
   gwinsz_in_termios_h=no
   if test $am_cv_sys_posix_termios = yes; then
     cat > conftest.$ac_ext <<EOF
-#line 4175 "configure"
+#line 4235 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #     include <termios.h>
@@ -4191,7 +4251,7 @@ rm -f conftest*
 
   if test $gwinsz_in_termios_h = no; then
     cat > conftest.$ac_ext <<EOF
-#line 4195 "configure"
+#line 4255 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #     include <sys/ioctl.h>
@@ -4247,7 +4307,6 @@ for ac_hdr in \
        resolv.h                \
        sgtty.h                 \
        shadow.h                \
-       stdarg.h                \
        stddef.h                \
        string.h                \
        strings.h               \
@@ -4270,17 +4329,17 @@ for ac_hdr in \
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4274: checking for $ac_hdr" >&5
+echo "configure:4333: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4279 "configure"
+#line 4338 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4284: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4343: \"$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*
@@ -4310,12 +4369,12 @@ done
 
 
 echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:4314: checking for socket" >&5
+echo "configure:4373: checking for socket" >&5
 if eval "test \"\${ac_cv_func_socket+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4319 "configure"
+#line 4378 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -4339,7 +4398,7 @@ f = socket;
 
 ; return 0; }
 EOF
-if { (eval echo configure:4343: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_socket=yes"
 else
@@ -4358,7 +4417,7 @@ else
   echo "$ac_t""no" 1>&6
        
        echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6
-echo "configure:4362: checking for main in -lsocket" >&5
+echo "configure:4421: checking for main in -lsocket" >&5
 ac_lib_var=`echo socket'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4366,14 +4425,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4370 "configure"
+#line 4429 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:4377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4436: \"$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
@@ -4401,7 +4460,7 @@ else
 fi
 
        echo $ac_n "checking for main in -lnet""... $ac_c" 1>&6
-echo "configure:4405: checking for main in -lnet" >&5
+echo "configure:4464: checking for main in -lnet" >&5
 ac_lib_var=`echo net'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4409,14 +4468,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4413 "configure"
+#line 4472 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:4420: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4479: \"$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
@@ -4444,7 +4503,7 @@ else
 fi
 
        echo $ac_n "checking for socket in -lnet""... $ac_c" 1>&6
-echo "configure:4448: checking for socket in -lnet" >&5
+echo "configure:4507: checking for socket in -lnet" >&5
 ac_lib_var=`echo net'_'socket | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4452,7 +4511,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4456 "configure"
+#line 4515 "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
@@ -4463,7 +4522,7 @@ int main() {
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:4467: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4526: \"$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
@@ -4491,7 +4550,7 @@ else
 fi
 
        echo $ac_n "checking for main in -lnsl_s""... $ac_c" 1>&6
-echo "configure:4495: checking for main in -lnsl_s" >&5
+echo "configure:4554: checking for main in -lnsl_s" >&5
 ac_lib_var=`echo nsl_s'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4499,14 +4558,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl_s  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4503 "configure"
+#line 4562 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:4510: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4569: \"$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
@@ -4534,7 +4593,7 @@ else
 fi
 
        echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6
-echo "configure:4538: checking for main in -lnsl" >&5
+echo "configure:4597: checking for main in -lnsl" >&5
 ac_lib_var=`echo nsl'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4542,14 +4601,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4546 "configure"
+#line 4605 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:4553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4612: \"$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
@@ -4577,7 +4636,7 @@ else
 fi
 
        echo $ac_n "checking for socket in -linet""... $ac_c" 1>&6
-echo "configure:4581: checking for socket in -linet" >&5
+echo "configure:4640: checking for socket in -linet" >&5
 ac_lib_var=`echo inet'_'socket | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4585,7 +4644,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-linet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4589 "configure"
+#line 4648 "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
@@ -4596,7 +4655,7 @@ int main() {
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:4600: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4659: \"$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
@@ -4624,7 +4683,7 @@ else
 fi
 
        echo $ac_n "checking for main in -lgen""... $ac_c" 1>&6
-echo "configure:4628: checking for main in -lgen" >&5
+echo "configure:4687: checking for main in -lgen" >&5
 ac_lib_var=`echo gen'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4632,14 +4691,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgen  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4636 "configure"
+#line 4695 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:4643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4702: \"$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
@@ -4671,12 +4730,12 @@ fi
 
 
 echo $ac_n "checking for select""... $ac_c" 1>&6
-echo "configure:4675: checking for select" >&5
+echo "configure:4734: checking for select" >&5
 if eval "test \"\${ac_cv_func_select+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4680 "configure"
+#line 4739 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char select(); below.  */
@@ -4700,7 +4759,7 @@ f = select;
 
 ; return 0; }
 EOF
-if { (eval echo configure:4704: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4763: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_select=yes"
 else
@@ -4722,7 +4781,7 @@ fi
 
 
 echo $ac_n "checking types of arguments for select()""... $ac_c" 1>&6
-echo "configure:4726: checking types of arguments for select()" >&5
+echo "configure:4785: checking types of arguments for select()" >&5
  if eval "test \"\${ac_cv_func_select_arg234+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4736,7 +4795,7 @@ else
      for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
       for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do
        cat > conftest.$ac_ext <<EOF
-#line 4740 "configure"
+#line 4799 "configure"
 #include "confdefs.h"
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -4755,7 +4814,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:4759: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4818: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
           ac_not_found=no ; break 3
 else
@@ -4799,17 +4858,17 @@ for ac_hdr in regex.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4803: checking for $ac_hdr" >&5
+echo "configure:4862: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4808 "configure"
+#line 4867 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4813: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4872: \"$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*
@@ -4839,12 +4898,12 @@ if test "$ac_cv_header_regex_h" != yes ; then
        { echo "configure: error: POSIX regex.h required." 1>&2; exit 1; }
 fi
 echo $ac_n "checking for regfree""... $ac_c" 1>&6
-echo "configure:4843: checking for regfree" >&5
+echo "configure:4902: checking for regfree" >&5
 if eval "test \"\${ac_cv_func_regfree+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4848 "configure"
+#line 4907 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char regfree(); below.  */
@@ -4868,7 +4927,7 @@ f = regfree;
 
 ; return 0; }
 EOF
-if { (eval echo configure:4872: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_regfree=yes"
 else
@@ -4891,7 +4950,7 @@ fi
 
 
 echo $ac_n "checking for compatible POSIX regex""... $ac_c" 1>&6
-echo "configure:4895: checking for compatible POSIX regex" >&5
+echo "configure:4954: checking for compatible POSIX regex" >&5
 if eval "test \"\${ol_cv_c_posix_regex+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4900,7 +4959,7 @@ else
   ol_cv_c_posix_regex=cross
 else
   cat > conftest.$ac_ext <<EOF
-#line 4904 "configure"
+#line 4963 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -4926,7 +4985,7 @@ main()
        return rc;
 }
 EOF
-if { (eval echo configure:4930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_c_posix_regex=yes
 else
@@ -4946,9 +5005,8 @@ if test "$ol_cv_c_posix_regex" = no ; then
        { echo "configure: error: broken POSIX regex!" 1>&2; exit 1; }
 fi
 
-
 echo $ac_n "checking for sigset in -lV3""... $ac_c" 1>&6
-echo "configure:4952: checking for sigset in -lV3" >&5
+echo "configure:5010: checking for sigset in -lV3" >&5
 ac_lib_var=`echo V3'_'sigset | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4956,7 +5014,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lV3  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4960 "configure"
+#line 5018 "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
@@ -4967,7 +5025,7 @@ int main() {
 sigset()
 ; return 0; }
 EOF
-if { (eval echo configure:4971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5029: \"$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
@@ -4996,12 +5054,12 @@ fi
 
 
 echo $ac_n "checking for res_search""... $ac_c" 1>&6
-echo "configure:5000: checking for res_search" >&5
+echo "configure:5058: checking for res_search" >&5
 if eval "test \"\${ac_cv_func_res_search+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5005 "configure"
+#line 5063 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char res_search(); below.  */
@@ -5025,7 +5083,7 @@ f = res_search;
 
 ; return 0; }
 EOF
-if { (eval echo configure:5029: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5087: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_res_search=yes"
 else
@@ -5046,7 +5104,7 @@ fi
 
 if test $ac_cv_func_res_search = no ; then 
        echo $ac_n "checking for res_search in -lbind""... $ac_c" 1>&6
-echo "configure:5050: checking for res_search in -lbind" >&5
+echo "configure:5108: checking for res_search in -lbind" >&5
 ac_lib_var=`echo bind'_'res_search | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5054,7 +5112,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5058 "configure"
+#line 5116 "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
@@ -5065,7 +5123,7 @@ int main() {
 res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:5069: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5127: \"$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
@@ -5097,7 +5155,7 @@ fi
 
 if test $ac_cv_func_res_search = no ; then 
        echo $ac_n "checking for __res_search in -lbind""... $ac_c" 1>&6
-echo "configure:5101: checking for __res_search in -lbind" >&5
+echo "configure:5159: checking for __res_search in -lbind" >&5
 ac_lib_var=`echo bind'_'__res_search | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5105,7 +5163,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5109 "configure"
+#line 5167 "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
@@ -5116,7 +5174,7 @@ int main() {
 __res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:5120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5178: \"$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
@@ -5148,7 +5206,7 @@ fi
 
 if test $ac_cv_func_res_search = no ; then 
        echo $ac_n "checking for res_search in -lresolv""... $ac_c" 1>&6
-echo "configure:5152: checking for res_search in -lresolv" >&5
+echo "configure:5210: checking for res_search in -lresolv" >&5
 ac_lib_var=`echo resolv'_'res_search | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5156,7 +5214,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5160 "configure"
+#line 5218 "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
@@ -5167,7 +5225,7 @@ int main() {
 res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:5171: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5229: \"$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
@@ -5215,17 +5273,17 @@ if test $ol_enable_quipu != no ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5219: checking for $ac_hdr" >&5
+echo "configure:5277: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5224 "configure"
+#line 5282 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5229: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5287: \"$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*
@@ -5268,17 +5326,17 @@ if test $ol_with_kerberos = auto -o $ol_with_kerberos = k5 ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5272: checking for $ac_hdr" >&5
+echo "configure:5330: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5277 "configure"
+#line 5335 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5282: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5340: \"$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*
@@ -5307,7 +5365,7 @@ done
 
        if test $ac_cv_header_kerberosIV_krb_h = yes ; then
                echo $ac_n "checking for main in -lkrb4""... $ac_c" 1>&6
-echo "configure:5311: checking for main in -lkrb4" >&5
+echo "configure:5369: checking for main in -lkrb4" >&5
 ac_lib_var=`echo krb4'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5315,14 +5373,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lkrb4 -lkrb5 -ldes425 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5319 "configure"
+#line 5377 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5326: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5384: \"$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
@@ -5353,7 +5411,7 @@ fi
                        LIBS="$KRB_LIBS $LIBS"
 
                        echo $ac_n "checking for des_debug in Kerberos libraries""... $ac_c" 1>&6
-echo "configure:5357: checking for des_debug in Kerberos libraries" >&5
+echo "configure:5415: checking for des_debug in Kerberos libraries" >&5
 if eval "test \"\${ol_cv_var_des_debug+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5361,7 +5419,7 @@ else
                                                                save_LIBS="$LIBS"
                                LIBS="$KRB_LIBS $LIBS"
                                cat > conftest.$ac_ext <<EOF
-#line 5365 "configure"
+#line 5423 "configure"
 #include "confdefs.h"
 
 #include <kerberosIV/krb.h>
@@ -5374,7 +5432,7 @@ des_debug = 1;
 
 ; return 0; }
 EOF
-if { (eval echo configure:5378: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_var_des_debug=yes
 else
@@ -5407,17 +5465,17 @@ if test $ol_with_kerberos = auto -o $ol_with_kerberos = k4 ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5411: checking for $ac_hdr" >&5
+echo "configure:5469: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5416 "configure"
+#line 5474 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5421: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5479: \"$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*
@@ -5446,7 +5504,7 @@ done
 
        if test $ac_cv_header_krb_h = yes ; then
                echo $ac_n "checking for main in -lkrb""... $ac_c" 1>&6
-echo "configure:5450: checking for main in -lkrb" >&5
+echo "configure:5508: checking for main in -lkrb" >&5
 ac_lib_var=`echo krb'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5454,14 +5512,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lkrb -ldes $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5458 "configure"
+#line 5516 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5523: \"$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
@@ -5506,17 +5564,17 @@ if test $ol_with_tls != no ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5510: checking for $ac_hdr" >&5
+echo "configure:5568: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5515 "configure"
+#line 5573 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5520: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5578: \"$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*
@@ -5545,7 +5603,7 @@ done
        
        if test $ac_cv_header_openssl_ssl_h = yes -o $ac_cv_header_ssl_h = yes ; then
                echo $ac_n "checking for SSLeay_add_ssl_algorithms in -lssl""... $ac_c" 1>&6
-echo "configure:5549: checking for SSLeay_add_ssl_algorithms in -lssl" >&5
+echo "configure:5607: checking for SSLeay_add_ssl_algorithms in -lssl" >&5
 ac_lib_var=`echo ssl'_'SSLeay_add_ssl_algorithms | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5553,7 +5611,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl -lcrypto $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5557 "configure"
+#line 5615 "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
@@ -5564,7 +5622,7 @@ int main() {
 SSLeay_add_ssl_algorithms()
 ; return 0; }
 EOF
-if { (eval echo configure:5568: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5626: \"$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
@@ -5589,7 +5647,7 @@ fi
                        
                if test $have_ssleay = no ; then
                        echo $ac_n "checking for SSL_library_init in -lssl""... $ac_c" 1>&6
-echo "configure:5593: checking for SSL_library_init in -lssl" >&5
+echo "configure:5651: checking for SSL_library_init in -lssl" >&5
 ac_lib_var=`echo ssl'_'SSL_library_init | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5597,7 +5655,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl -lcrypto $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5601 "configure"
+#line 5659 "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
@@ -5608,7 +5666,7 @@ int main() {
 SSL_library_init()
 ; return 0; }
 EOF
-if { (eval echo configure:5612: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5670: \"$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
@@ -5634,7 +5692,7 @@ fi
 
                if test $have_ssleay = no ; then
                        echo $ac_n "checking for ssl3_accept in -lssl""... $ac_c" 1>&6
-echo "configure:5638: checking for ssl3_accept in -lssl" >&5
+echo "configure:5696: checking for ssl3_accept in -lssl" >&5
 ac_lib_var=`echo ssl'_'ssl3_accept | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5642,7 +5700,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl -lcrypto -lRSAglue -lrsaref $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5646 "configure"
+#line 5704 "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
@@ -5653,7 +5711,7 @@ int main() {
 ssl3_accept()
 ; return 0; }
 EOF
-if { (eval echo configure:5657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5715: \"$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
@@ -5713,12 +5771,12 @@ for ac_func in \
 
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5717: checking for $ac_func" >&5
+echo "configure:5775: checking for $ac_func" >&5
 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5722 "configure"
+#line 5780 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5742,7 +5800,7 @@ f = $ac_func;
 
 ; return 0; }
 EOF
-if { (eval echo configure:5746: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5804: \"$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
@@ -5771,19 +5829,19 @@ if test "$ac_cv_func_ctime_r" = no ; then
        ol_cv_func_ctime_r_nargs=0
 else
        echo $ac_n "checking number of arguments of ctime_r""... $ac_c" 1>&6
-echo "configure:5775: checking number of arguments of ctime_r" >&5
+echo "configure:5833: checking number of arguments of ctime_r" >&5
 if eval "test \"\${ol_cv_func_ctime_r_nargs+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5780 "configure"
+#line 5838 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 time_t ti; char *buffer; ctime_r(&ti,buffer,32);
 ; return 0; }
 EOF
-if { (eval echo configure:5787: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5845: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_func_ctime_r_nargs=3
 else
@@ -5791,14 +5849,14 @@ else
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 5795 "configure"
+#line 5853 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 time_t ti; char *buffer; ctime_r(&ti,buffer);
 ; return 0; }
 EOF
-if { (eval echo configure:5802: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5860: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_func_ctime_r_nargs=2
 else
@@ -5824,12 +5882,12 @@ fi
 
 if test "$ac_cv_func_gethostbyname_r" = yes ; then
        echo $ac_n "checking number of arguments of gethostbyname_r""... $ac_c" 1>&6
-echo "configure:5828: checking number of arguments of gethostbyname_r" >&5
+echo "configure:5886: checking number of arguments of gethostbyname_r" >&5
 if eval "test \"\${ol_cv_func_gethostbyname_r_nargs+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5833 "configure"
+#line 5891 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -5843,7 +5901,7 @@ struct hostent hent; char buffer[BUFSIZE];
                        buffer, bufsize, &h_errno);
 ; return 0; }
 EOF
-if { (eval echo configure:5847: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5905: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_func_gethostbyname_r_nargs=5
 else
@@ -5851,7 +5909,7 @@ else
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 5855 "configure"
+#line 5913 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -5866,7 +5924,7 @@ struct hostent hent;struct hostent *rhent;
                                &rhent, &h_errno);
 ; return 0; }
 EOF
-if { (eval echo configure:5870: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5928: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_func_gethostbyname_r_nargs=6
 else
@@ -5894,12 +5952,12 @@ fi
  
 if test "$ac_cv_func_gethostbyaddr_r" = yes ; then
        echo $ac_n "checking number of arguments of gethostbyaddr_r""... $ac_c" 1>&6
-echo "configure:5898: checking number of arguments of gethostbyaddr_r" >&5
+echo "configure:5956: checking number of arguments of gethostbyaddr_r" >&5
 if eval "test \"\${ol_cv_func_gethostbyaddr_r_nargs+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5903 "configure"
+#line 5961 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -5915,7 +5973,7 @@ struct hostent hent; char buffer[BUFSIZE];
                        alen, AF_INET, &hent, buffer, bufsize, &h_errno);
 ; return 0; }
 EOF
-if { (eval echo configure:5919: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5977: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_func_gethostbyaddr_r_nargs=7
 else
@@ -5923,7 +5981,7 @@ else
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 5927 "configure"
+#line 5985 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -5941,7 +5999,7 @@ struct hostent hent;
                                &rhent, &h_errno);
 ; return 0; }
 EOF
-if { (eval echo configure:5945: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6003: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_func_gethostbyaddr_r_nargs=8
 else
@@ -5988,21 +6046,21 @@ ol_link_threads=no
 if test $ol_with_threads = auto -o $ol_with_threads = yes \
        -o $ol_with_threads = posix ; then
 
-       for ac_hdr in pthread.h sched.h
+       for ac_hdr in pthread.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5996: checking for $ac_hdr" >&5
+echo "configure:6054: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6001 "configure"
+#line 6059 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6006: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6064: \"$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*
@@ -6031,13 +6089,13 @@ done
 
        if test $ac_cv_header_pthread_h = yes ; then
                echo $ac_n "checking POSIX thread version""... $ac_c" 1>&6
-echo "configure:6035: checking POSIX thread version" >&5
+echo "configure:6093: checking POSIX thread version" >&5
 if eval "test \"\${ol_cv_pthread_version+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
        cat > conftest.$ac_ext <<EOF
-#line 6041 "configure"
+#line 6099 "configure"
 #include "confdefs.h"
 
 #              include <pthread.h>
@@ -6059,7 +6117,7 @@ rm -f conftest*
 
 
        cat > conftest.$ac_ext <<EOF
-#line 6063 "configure"
+#line 6121 "configure"
 #include "confdefs.h"
 
 #              include <pthread.h>
@@ -6112,12 +6170,12 @@ EOF
 
                
        echo $ac_n "checking for LinuxThreads pthread.h""... $ac_c" 1>&6
-echo "configure:6116: checking for LinuxThreads pthread.h" >&5
+echo "configure:6174: checking for LinuxThreads pthread.h" >&5
 if eval "test \"\${ol_cv_header_linux_threads+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6121 "configure"
+#line 6179 "configure"
 #include "confdefs.h"
 #include <pthread.h>
 EOF
@@ -6142,17 +6200,90 @@ EOF
 
        fi
 
+               
+       echo $ac_n "checking for GNU Pth pthread.h""... $ac_c" 1>&6
+echo "configure:6206: checking for GNU Pth pthread.h" >&5
+if eval "test \"\${ol_cv_header_gnu_pth_pthread_h+set}\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 6211 "configure"
+#include "confdefs.h"
+#include <pthread.h>
+#ifdef _POSIX_THREAD_IS_GNU_PTH
+       __gnu_pth__
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "__gnu_pth__" >/dev/null 2>&1; then
+  rm -rf conftest*
+  ol_cv_header_gnu_pth_pthread_h=yes
+else
+  rm -rf conftest*
+  ol_cv_header_gnu_pth_pthread_h=no
+fi
+rm -f conftest*
+
+               
+fi
+
+echo "$ac_t""$ol_cv_header_gnu_pth_pthread_h" 1>&6
+
+
+               if test $ol_cv_header_gnu_pth_pthread_h = no ; then
+                       for ac_hdr in sched.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:6240: checking for $ac_hdr" >&5
+if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 6245 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:6250: \"$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
+    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+               fi
 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                echo $ac_n "checking for pthread_create in default libraries""... $ac_c" 1>&6
-echo "configure:6149: checking for pthread_create in default libraries" >&5
+echo "configure:6280: checking for pthread_create in default libraries" >&5
 if eval "test \"\${ol_cv_pthread_create+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 6156 "configure"
+#line 6287 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6196,7 +6327,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:6200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6331: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_create=yes
 else
@@ -6208,7 +6339,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 6212 "configure"
+#line 6343 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6257,7 +6388,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:6261: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6392: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_create=yes
 else
@@ -6282,7 +6413,7 @@ echo "$ac_t""$ol_cv_pthread_create" 1>&6
 if test "$ol_link_threads" = no ; then
        # try -kthread
        echo $ac_n "checking for pthread link with -kthread""... $ac_c" 1>&6
-echo "configure:6286: checking for pthread link with -kthread" >&5
+echo "configure:6417: checking for pthread link with -kthread" >&5
 if eval "test \"\${ol_cv_pthread_kthread+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6293,7 +6424,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 6297 "configure"
+#line 6428 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6337,7 +6468,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:6341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6472: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_kthread=yes
 else
@@ -6349,7 +6480,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 6353 "configure"
+#line 6484 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6398,7 +6529,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:6402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6533: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_kthread=yes
 else
@@ -6428,7 +6559,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -pthread
        echo $ac_n "checking for pthread link with -pthread""... $ac_c" 1>&6
-echo "configure:6432: checking for pthread link with -pthread" >&5
+echo "configure:6563: checking for pthread link with -pthread" >&5
 if eval "test \"\${ol_cv_pthread_pthread+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6439,7 +6570,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 6443 "configure"
+#line 6574 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6483,7 +6614,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:6487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_pthread=yes
 else
@@ -6495,7 +6626,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 6499 "configure"
+#line 6630 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6544,7 +6675,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:6548: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_pthread=yes
 else
@@ -6574,7 +6705,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -pthreads
        echo $ac_n "checking for pthread link with -pthreads""... $ac_c" 1>&6
-echo "configure:6578: checking for pthread link with -pthreads" >&5
+echo "configure:6709: checking for pthread link with -pthreads" >&5
 if eval "test \"\${ol_cv_pthread_pthreads+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6585,7 +6716,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 6589 "configure"
+#line 6720 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6629,7 +6760,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:6633: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_pthreads=yes
 else
@@ -6641,7 +6772,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 6645 "configure"
+#line 6776 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6690,7 +6821,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:6694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_pthreads=yes
 else
@@ -6720,7 +6851,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -mthreads
        echo $ac_n "checking for pthread link with -mthreads""... $ac_c" 1>&6
-echo "configure:6724: checking for pthread link with -mthreads" >&5
+echo "configure:6855: checking for pthread link with -mthreads" >&5
 if eval "test \"\${ol_cv_pthread_mthreads+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6731,7 +6862,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 6735 "configure"
+#line 6866 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6775,7 +6906,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:6779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6910: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_mthreads=yes
 else
@@ -6787,7 +6918,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 6791 "configure"
+#line 6922 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6836,7 +6967,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:6840: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_mthreads=yes
 else
@@ -6866,7 +6997,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -thread
        echo $ac_n "checking for pthread link with -thread""... $ac_c" 1>&6
-echo "configure:6870: checking for pthread link with -thread" >&5
+echo "configure:7001: checking for pthread link with -thread" >&5
 if eval "test \"\${ol_cv_pthread_thread+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6877,7 +7008,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 6881 "configure"
+#line 7012 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6921,7 +7052,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:6925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_thread=yes
 else
@@ -6933,7 +7064,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 6937 "configure"
+#line 7068 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -6982,7 +7113,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:6986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_thread=yes
 else
@@ -7013,7 +7144,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -lpthread -lmach -lexc -lc_r
        echo $ac_n "checking for pthread link with -lpthread -lmach -lexc -lc_r""... $ac_c" 1>&6
-echo "configure:7017: checking for pthread link with -lpthread -lmach -lexc -lc_r" >&5
+echo "configure:7148: checking for pthread link with -lpthread -lmach -lexc -lc_r" >&5
 if eval "test \"\${ol_cv_pthread_lpthread_lmach_lexc_lc_r+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7024,7 +7155,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 7028 "configure"
+#line 7159 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7068,7 +7199,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:7072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_lpthread_lmach_lexc_lc_r=yes
 else
@@ -7080,7 +7211,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 7084 "configure"
+#line 7215 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7129,7 +7260,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:7133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7264: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_lpthread_lmach_lexc_lc_r=yes
 else
@@ -7159,7 +7290,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -lpthread -lmach -lexc
        echo $ac_n "checking for pthread link with -lpthread -lmach -lexc""... $ac_c" 1>&6
-echo "configure:7163: checking for pthread link with -lpthread -lmach -lexc" >&5
+echo "configure:7294: checking for pthread link with -lpthread -lmach -lexc" >&5
 if eval "test \"\${ol_cv_pthread_lpthread_lmach_lexc+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7170,7 +7301,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 7174 "configure"
+#line 7305 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7214,7 +7345,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:7218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_lpthread_lmach_lexc=yes
 else
@@ -7226,7 +7357,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 7230 "configure"
+#line 7361 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7275,7 +7406,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:7279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_lpthread_lmach_lexc=yes
 else
@@ -7306,7 +7437,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -lpthread -Wl,-woff,85
        echo $ac_n "checking for pthread link with -lpthread -Wl,-woff,85""... $ac_c" 1>&6
-echo "configure:7310: checking for pthread link with -lpthread -Wl,-woff,85" >&5
+echo "configure:7441: checking for pthread link with -lpthread -Wl,-woff,85" >&5
 if eval "test \"\${ol_cv_pthread_lib_lpthread_woff+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7317,7 +7448,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 7321 "configure"
+#line 7452 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7361,7 +7492,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:7365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_lib_lpthread_woff=yes
 else
@@ -7373,7 +7504,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 7377 "configure"
+#line 7508 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7422,7 +7553,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:7426: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7557: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_lib_lpthread_woff=yes
 else
@@ -7453,7 +7584,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -lpthread
        echo $ac_n "checking for pthread link with -lpthread""... $ac_c" 1>&6
-echo "configure:7457: checking for pthread link with -lpthread" >&5
+echo "configure:7588: checking for pthread link with -lpthread" >&5
 if eval "test \"\${ol_cv_pthread_lpthread+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7464,7 +7595,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 7468 "configure"
+#line 7599 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7508,7 +7639,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:7512: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_lpthread=yes
 else
@@ -7520,7 +7651,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 7524 "configure"
+#line 7655 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7569,7 +7700,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:7573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7704: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_lpthread=yes
 else
@@ -7599,7 +7730,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -lc_r
        echo $ac_n "checking for pthread link with -lc_r""... $ac_c" 1>&6
-echo "configure:7603: checking for pthread link with -lc_r" >&5
+echo "configure:7734: checking for pthread link with -lc_r" >&5
 if eval "test \"\${ol_cv_pthread_lc_r+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7610,7 +7741,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 7614 "configure"
+#line 7745 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7654,7 +7785,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:7658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7789: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_lc_r=yes
 else
@@ -7666,7 +7797,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 7670 "configure"
+#line 7801 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7715,7 +7846,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:7719: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_lc_r=yes
 else
@@ -7746,7 +7877,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -threads
        echo $ac_n "checking for pthread link with -threads""... $ac_c" 1>&6
-echo "configure:7750: checking for pthread link with -threads" >&5
+echo "configure:7881: checking for pthread link with -threads" >&5
 if eval "test \"\${ol_cv_pthread_threads+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7757,7 +7888,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 7761 "configure"
+#line 7892 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7801,7 +7932,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:7805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_threads=yes
 else
@@ -7813,7 +7944,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 7817 "configure"
+#line 7948 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7862,7 +7993,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:7866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_threads=yes
 else
@@ -7893,7 +8024,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -lpthreads -lmach -lexc -lc_r
        echo $ac_n "checking for pthread link with -lpthreads -lmach -lexc -lc_r""... $ac_c" 1>&6
-echo "configure:7897: checking for pthread link with -lpthreads -lmach -lexc -lc_r" >&5
+echo "configure:8028: checking for pthread link with -lpthreads -lmach -lexc -lc_r" >&5
 if eval "test \"\${ol_cv_pthread_lpthreads_lmach_lexc_lc_r+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7904,7 +8035,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 7908 "configure"
+#line 8039 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -7948,7 +8079,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:7952: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8083: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_lpthreads_lmach_lexc_lc_r=yes
 else
@@ -7960,7 +8091,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 7964 "configure"
+#line 8095 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -8009,7 +8140,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:8013: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8144: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_lpthreads_lmach_lexc_lc_r=yes
 else
@@ -8039,7 +8170,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -lpthreads -lmach -lexc
        echo $ac_n "checking for pthread link with -lpthreads -lmach -lexc""... $ac_c" 1>&6
-echo "configure:8043: checking for pthread link with -lpthreads -lmach -lexc" >&5
+echo "configure:8174: checking for pthread link with -lpthreads -lmach -lexc" >&5
 if eval "test \"\${ol_cv_pthread_lpthreads_lmach_lexc+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8050,7 +8181,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 8054 "configure"
+#line 8185 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -8094,7 +8225,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:8098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8229: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_lpthreads_lmach_lexc=yes
 else
@@ -8106,7 +8237,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 8110 "configure"
+#line 8241 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -8155,7 +8286,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:8159: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8290: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_lpthreads_lmach_lexc=yes
 else
@@ -8185,7 +8316,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -lpthreads -lexc
        echo $ac_n "checking for pthread link with -lpthreads -lexc""... $ac_c" 1>&6
-echo "configure:8189: checking for pthread link with -lpthreads -lexc" >&5
+echo "configure:8320: checking for pthread link with -lpthreads -lexc" >&5
 if eval "test \"\${ol_cv_pthread_lpthreads_lexc+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8196,7 +8327,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 8200 "configure"
+#line 8331 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -8240,7 +8371,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:8244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8375: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_lpthreads_lexc=yes
 else
@@ -8252,7 +8383,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 8256 "configure"
+#line 8387 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -8301,7 +8432,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:8305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_lpthreads_lexc=yes
 else
@@ -8332,7 +8463,7 @@ fi
 if test "$ol_link_threads" = no ; then
        # try -lpthreads
        echo $ac_n "checking for pthread link with -lpthreads""... $ac_c" 1>&6
-echo "configure:8336: checking for pthread link with -lpthreads" >&5
+echo "configure:8467: checking for pthread link with -lpthreads" >&5
 if eval "test \"\${ol_cv_pthread_lib_lpthreads+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8343,7 +8474,7 @@ else
 
                if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 8347 "configure"
+#line 8478 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -8387,7 +8518,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:8391: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8522: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_pthread_lib_lpthreads=yes
 else
@@ -8399,7 +8530,7 @@ fi
 rm -f conftest*
 else
   cat > conftest.$ac_ext <<EOF
-#line 8403 "configure"
+#line 8534 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -8448,7 +8579,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:8452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_lib_lpthreads=yes
 else
@@ -8490,12 +8621,12 @@ EOF
                                                                                                for ac_func in sched_yield pthread_yield
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8494: checking for $ac_func" >&5
+echo "configure:8625: checking for $ac_func" >&5
 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8499 "configure"
+#line 8630 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8519,7 +8650,7 @@ f = $ac_func;
 
 ; return 0; }
 EOF
-if { (eval echo configure:8523: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8654: \"$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
@@ -8547,7 +8678,7 @@ done
                        if test $ac_cv_func_sched_yield = no -a \
                                $ac_cv_func_pthread_yield = no ; then
                                                                echo $ac_n "checking for sched_yield in -lrt""... $ac_c" 1>&6
-echo "configure:8551: checking for sched_yield in -lrt" >&5
+echo "configure:8682: checking for sched_yield in -lrt" >&5
 ac_lib_var=`echo rt'_'sched_yield | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -8555,7 +8686,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lrt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 8559 "configure"
+#line 8690 "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
@@ -8566,7 +8697,7 @@ int main() {
 sched_yield()
 ; return 0; }
 EOF
-if { (eval echo configure:8570: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8701: \"$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
@@ -8598,12 +8729,12 @@ fi
                                                                                                for ac_func in thr_yield
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8602: checking for $ac_func" >&5
+echo "configure:8733: checking for $ac_func" >&5
 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8607 "configure"
+#line 8738 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8627,7 +8758,7 @@ f = $ac_func;
 
 ; return 0; }
 EOF
-if { (eval echo configure:8631: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8762: \"$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
@@ -8661,12 +8792,12 @@ done
                                                for ac_func in pthread_kill
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8665: checking for $ac_func" >&5
+echo "configure:8796: checking for $ac_func" >&5
 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8670 "configure"
+#line 8801 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8690,7 +8821,7 @@ f = $ac_func;
 
 ; return 0; }
 EOF
-if { (eval echo configure:8694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8825: \"$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
@@ -8716,13 +8847,13 @@ done
 
 
                                                                        echo $ac_n "checking for pthread_detach with <pthread.h>""... $ac_c" 1>&6
-echo "configure:8720: checking for pthread_detach with <pthread.h>" >&5
+echo "configure:8851: checking for pthread_detach with <pthread.h>" >&5
 if eval "test \"\${ol_cv_func_pthread_detach+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
                                                                cat > conftest.$ac_ext <<EOF
-#line 8726 "configure"
+#line 8857 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -8734,7 +8865,7 @@ int main() {
 pthread_detach(NULL);
 ; return 0; }
 EOF
-if { (eval echo configure:8738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8869: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_func_pthread_detach=yes
 else
@@ -8766,12 +8897,12 @@ EOF
                        
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8770: checking for $ac_func" >&5
+echo "configure:8901: checking for $ac_func" >&5
 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8775 "configure"
+#line 8906 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8795,7 +8926,7 @@ f = $ac_func;
 
 ; return 0; }
 EOF
-if { (eval echo configure:8799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8930: \"$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
@@ -8822,12 +8953,12 @@ done
 
                        
        echo $ac_n "checking for pthread_kill_other_threads_np""... $ac_c" 1>&6
-echo "configure:8826: checking for pthread_kill_other_threads_np" >&5
+echo "configure:8957: checking for pthread_kill_other_threads_np" >&5
 if eval "test \"\${ac_cv_func_pthread_kill_other_threads_np+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8831 "configure"
+#line 8962 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char pthread_kill_other_threads_np(); below.  */
@@ -8851,7 +8982,7 @@ f = pthread_kill_other_threads_np;
 
 ; return 0; }
 EOF
-if { (eval echo configure:8855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_pthread_kill_other_threads_np=yes"
 else
@@ -8871,7 +9002,7 @@ else
 fi
 
        echo $ac_n "checking for LinuxThreads implementation""... $ac_c" 1>&6
-echo "configure:8875: checking for LinuxThreads implementation" >&5
+echo "configure:9006: checking for LinuxThreads implementation" >&5
 if eval "test \"\${ol_cv_sys_linux_threads+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8884,7 +9015,7 @@ echo "$ac_t""$ol_cv_sys_linux_threads" 1>&6
        
        
        echo $ac_n "checking for LinuxThreads consistency""... $ac_c" 1>&6
-echo "configure:8888: checking for LinuxThreads consistency" >&5
+echo "configure:9019: checking for LinuxThreads consistency" >&5
 if eval "test \"\${ol_cv_linux_threads+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8909,7 +9040,7 @@ echo "$ac_t""$ol_cv_linux_threads" 1>&6
                        fi
 
                        echo $ac_n "checking if pthread_create() works""... $ac_c" 1>&6
-echo "configure:8913: checking if pthread_create() works" >&5
+echo "configure:9044: checking if pthread_create() works" >&5
 if eval "test \"\${ol_cv_pthread_create_works+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8918,7 +9049,7 @@ else
                                ol_cv_pthread_create_works=yes
 else
   cat > conftest.$ac_ext <<EOF
-#line 8922 "configure"
+#line 9053 "configure"
 #include "confdefs.h"
 /* pthread test headers */
 #include <pthread.h>
@@ -8967,7 +9098,7 @@ int main(argc, argv)
 }
 
 EOF
-if { (eval echo configure:8971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:9102: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_create_works=yes
 else
@@ -8989,7 +9120,7 @@ echo "$ac_t""$ol_cv_pthread_create_works" 1>&6
 
                                                if test $ol_with_yielding_select = auto ; then
                                echo $ac_n "checking if select yields when using pthreads""... $ac_c" 1>&6
-echo "configure:8993: checking if select yields when using pthreads" >&5
+echo "configure:9124: checking if select yields when using pthreads" >&5
 if eval "test \"\${ol_cv_pthread_select_yields+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8998,7 +9129,7 @@ else
   ol_cv_pthread_select_yields=cross
 else
   cat > conftest.$ac_ext <<EOF
-#line 9002 "configure"
+#line 9133 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -9074,7 +9205,7 @@ int main(argc, argv)
        exit(2);
 }
 EOF
-if { (eval echo configure:9078: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:9209: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_pthread_select_yields=no
 else
@@ -9118,17 +9249,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9122: checking for $ac_hdr" >&5
+echo "configure:9253: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9127 "configure"
+#line 9258 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9132: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9263: \"$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*
@@ -9158,12 +9289,12 @@ done
                ol_with_threads=found
 
                                echo $ac_n "checking for cthread_fork""... $ac_c" 1>&6
-echo "configure:9162: checking for cthread_fork" >&5
+echo "configure:9293: checking for cthread_fork" >&5
 if eval "test \"\${ac_cv_func_cthread_fork+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9167 "configure"
+#line 9298 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char cthread_fork(); below.  */
@@ -9187,7 +9318,7 @@ f = cthread_fork;
 
 ; return 0; }
 EOF
-if { (eval echo configure:9191: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_cthread_fork=yes"
 else
@@ -9209,7 +9340,7 @@ fi
 
                if test $ol_link_threads = no ; then
                                                                        echo $ac_n "checking for cthread_fork with -all_load""... $ac_c" 1>&6
-echo "configure:9213: checking for cthread_fork with -all_load" >&5
+echo "configure:9344: checking for cthread_fork with -all_load" >&5
 if eval "test \"\${ol_cv_cthread_all_load+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -9217,7 +9348,7 @@ else
                                                                save_LIBS="$LIBS"
                                LIBS="-all_load $LIBS"
                                cat > conftest.$ac_ext <<EOF
-#line 9221 "configure"
+#line 9352 "configure"
 #include "confdefs.h"
 #include <mach/cthreads.h>
 int main() {
@@ -9226,7 +9357,7 @@ int main() {
                                        
 ; return 0; }
 EOF
-if { (eval echo configure:9230: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9361: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_cthread_all_load=yes
 else
@@ -9264,6 +9395,108 @@ EOF
        fi
 fi
 
+if test $ol_with_threads = auto -o $ol_with_threads = yes \
+       -o $ol_with_threads = pth ; then
+
+       for ac_hdr in pth.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:9406: checking for $ac_hdr" >&5
+if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 9411 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:9416: \"$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
+    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+
+       if test $ac_cv_header_pth_h = yes ; then
+               echo $ac_n "checking for pth_version in -lpth""... $ac_c" 1>&6
+echo "configure:9445: checking for pth_version in -lpth" >&5
+ac_lib_var=`echo pth'_'pth_version | sed 'y%./+-:%__p__%'`
+if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lpth  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 9453 "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 pth_version();
+
+int main() {
+pth_version()
+; return 0; }
+EOF
+if { (eval echo configure:9464: \"$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
+  have_pth=yes
+else
+  echo "$ac_t""no" 1>&6
+have_pth=no
+fi
+
+
+               if test $have_pth = yes ; then
+                       cat >> confdefs.h <<\EOF
+#define HAVE_GNU_PTH 1
+EOF
+
+                       LTHREAD_LIBS="$LTHREAD_LIBS -lpth"
+                       ol_link_threads=pth
+
+                       if test $ol_with_yielding_select = auto ; then
+                               ol_with_yielding_select=yes
+                       fi
+               fi
+       fi
+fi
+
 if test $ol_with_threads = auto -o $ol_with_threads = yes \
        -o $ol_with_threads = lwp ; then
 
@@ -9271,17 +9504,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9275: checking for $ac_hdr" >&5
+echo "configure:9508: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9280 "configure"
+#line 9513 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9285: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9518: \"$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*
@@ -9309,7 +9542,7 @@ done
 
        if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then
                echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6
-echo "configure:9313: checking for thr_create in -lthread" >&5
+echo "configure:9546: checking for thr_create in -lthread" >&5
 ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -9317,7 +9550,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lthread  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 9321 "configure"
+#line 9554 "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
@@ -9328,7 +9561,7 @@ int main() {
 thr_create()
 ; return 0; }
 EOF
-if { (eval echo configure:9332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9565: \"$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
@@ -9368,12 +9601,12 @@ EOF
                        
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:9372: checking for $ac_func" >&5
+echo "configure:9605: checking for $ac_func" >&5
 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9377 "configure"
+#line 9610 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -9397,7 +9630,7 @@ f = $ac_func;
 
 ; return 0; }
 EOF
-if { (eval echo configure:9401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9634: \"$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
@@ -9428,17 +9661,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9432: checking for $ac_hdr" >&5
+echo "configure:9665: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9437 "configure"
+#line 9670 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9442: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9675: \"$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*
@@ -9466,7 +9699,7 @@ done
 
        if test $ac_cv_header_lwp_lwp_h = yes ; then
                echo $ac_n "checking for lwp_create in -llwp""... $ac_c" 1>&6
-echo "configure:9470: checking for lwp_create in -llwp" >&5
+echo "configure:9703: checking for lwp_create in -llwp" >&5
 ac_lib_var=`echo lwp'_'lwp_create | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -9474,7 +9707,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-llwp  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 9478 "configure"
+#line 9711 "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
@@ -9485,7 +9718,7 @@ int main() {
 lwp_create()
 ; return 0; }
 EOF
-if { (eval echo configure:9489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9722: \"$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
@@ -9538,17 +9771,17 @@ if test $ol_with_threads = manual ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9542: checking for $ac_hdr" >&5
+echo "configure:9775: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9547 "configure"
+#line 9780 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9552: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9785: \"$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*
@@ -9577,12 +9810,12 @@ done
        for ac_func in sched_yield pthread_yield
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:9581: checking for $ac_func" >&5
+echo "configure:9814: checking for $ac_func" >&5
 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9586 "configure"
+#line 9819 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -9606,7 +9839,7 @@ f = $ac_func;
 
 ; return 0; }
 EOF
-if { (eval echo configure:9610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9843: \"$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
@@ -9632,12 +9865,12 @@ done
 
        
        echo $ac_n "checking for LinuxThreads pthread.h""... $ac_c" 1>&6
-echo "configure:9636: checking for LinuxThreads pthread.h" >&5
+echo "configure:9869: checking for LinuxThreads pthread.h" >&5
 if eval "test \"\${ol_cv_header_linux_threads+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9641 "configure"
+#line 9874 "configure"
 #include "confdefs.h"
 #include <pthread.h>
 EOF
@@ -9667,17 +9900,17 @@ EOF
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9671: checking for $ac_hdr" >&5
+echo "configure:9904: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9676 "configure"
+#line 9909 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9681: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9914: \"$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*
@@ -9707,17 +9940,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9711: checking for $ac_hdr" >&5
+echo "configure:9944: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9716 "configure"
+#line 9949 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9721: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9954: \"$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*
@@ -9747,17 +9980,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9751: checking for $ac_hdr" >&5
+echo "configure:9984: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9756 "configure"
+#line 9989 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9761: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9994: \"$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*
@@ -9816,20 +10049,20 @@ EOF
 
 
                        echo $ac_n "checking for thread specific errno""... $ac_c" 1>&6
-echo "configure:9820: checking for thread specific errno" >&5
+echo "configure:10053: checking for thread specific errno" >&5
 if eval "test \"\${ol_cv_errno_thread_specific+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
                cat > conftest.$ac_ext <<EOF
-#line 9826 "configure"
+#line 10059 "configure"
 #include "confdefs.h"
 #include <errno.h>
 int main() {
 errno = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:9833: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10066: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_errno_thread_specific=yes
 else
 echo "$ac_t""$ol_cv_errno_thread_specific" 1>&6
 
                        echo $ac_n "checking for thread specific h_errno""... $ac_c" 1>&6
-echo "configure:9849: checking for thread specific h_errno" >&5
+echo "configure:10082: checking for thread specific h_errno" >&5
 if eval "test \"\${ol_cv_h_errno_thread_specific+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
                cat > conftest.$ac_ext <<EOF
-#line 9855 "configure"
+#line 10088 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 int main() {
 h_errno = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:9862: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_h_errno_thread_specific=yes
 else
 ol_link_ldbm=no 
 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db2 ; then
        echo $ac_n "checking for DB2 library""... $ac_c" 1>&6
-echo "configure:9913: checking for DB2 library" >&5
+echo "configure:10146: checking for DB2 library" >&5
 if eval "test \"\${ol_cv_lib_db2+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
        ol_LIBS="$LIBS"
        echo $ac_n "checking for db_open in -ldb""... $ac_c" 1>&6
-echo "configure:9919: checking for db_open in -ldb" >&5
+echo "configure:10152: checking for db_open in -ldb" >&5
 ac_lib_var=`echo db'_'db_open | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -9923,7 +10156,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldb  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 9927 "configure"
+#line 10160 "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
@@ -9934,7 +10167,7 @@ int main() {
 db_open()
 ; return 0; }
 EOF
-if { (eval echo configure:9938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10171: \"$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
@@ -9965,17 +10198,17 @@ for ac_hdr in db.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9969: checking for $ac_hdr" >&5
+echo "configure:10202: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9974 "configure"
+#line 10207 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9979: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10212: \"$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*
@@ -10003,13 +10236,13 @@ done
 
 if test $ac_cv_header_db_h = yes ; then
        echo $ac_n "checking if db.h is DB2""... $ac_c" 1>&6
-echo "configure:10007: checking if db.h is DB2" >&5
+echo "configure:10240: checking if db.h is DB2" >&5
 if eval "test \"\${ol_cv_header_db2+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
                cat > conftest.$ac_ext <<EOF
-#line 10013 "configure"
+#line 10246 "configure"
 #include "confdefs.h"
 
 #                      include <db.h>
@@ -10041,7 +10274,7 @@ fi
 
  
  echo $ac_n "checking for Berkeley DB2""... $ac_c" 1>&6
-echo "configure:10045: checking for Berkeley DB2" >&5
+echo "configure:10278: checking for Berkeley DB2" >&5
 if eval "test \"\${ol_cv_berkeley_db2+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -10092,7 +10325,7 @@ fi
 
 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db ; then
        echo $ac_n "checking for Berkeley DB library""... $ac_c" 1>&6
-echo "configure:10096: checking for Berkeley DB library" >&5
+echo "configure:10329: checking for Berkeley DB library" >&5
 if eval "test \"\${ol_cv_lib_db+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -10101,17 +10334,17 @@ else
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:10105: checking for $ac_hdr" >&5
+echo "configure:10338: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10110 "configure"
+#line 10343 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10115: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10348: \"$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*
@@ -10139,12 +10372,12 @@ done
 
        ol_LIBS="$LIBS"
        echo $ac_n "checking for dbopen""... $ac_c" 1>&6
-echo "configure:10143: checking for dbopen" >&5
+echo "configure:10376: checking for dbopen" >&5
 if eval "test \"\${ac_cv_func_dbopen+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10148 "configure"
+#line 10381 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbopen(); below.  */
@@ -10168,7 +10401,7 @@ f = dbopen;
 
 ; return 0; }
 EOF
-if { (eval echo configure:10172: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_dbopen=yes"
 else
@@ -10187,7 +10420,7 @@ else
   echo "$ac_t""no" 1>&6
 
                echo $ac_n "checking for dbopen in -ldb1""... $ac_c" 1>&6
-echo "configure:10191: checking for dbopen in -ldb1" >&5
+echo "configure:10424: checking for dbopen in -ldb1" >&5
 ac_lib_var=`echo db1'_'dbopen | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -10195,7 +10428,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldb1  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 10199 "configure"
+#line 10432 "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
@@ -10206,7 +10439,7 @@ int main() {
 dbopen()
 ; return 0; }
 EOF
-if { (eval echo configure:10210: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10443: \"$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
@@ -10226,7 +10459,7 @@ else
   echo "$ac_t""no" 1>&6
 
                        echo $ac_n "checking for dbopen in -ldb""... $ac_c" 1>&6
-echo "configure:10230: checking for dbopen in -ldb" >&5
+echo "configure:10463: checking for dbopen in -ldb" >&5
 ac_lib_var=`echo db'_'dbopen | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -10234,7 +10467,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldb  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 10238 "configure"
+#line 10471 "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
@@ -10245,7 +10478,7 @@ int main() {
 dbopen()
 ; return 0; }
 EOF
-if { (eval echo configure:10249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10482: \"$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
@@ -10283,17 +10516,17 @@ for ac_hdr in db_185.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:10287: checking for $ac_hdr" >&5
+echo "configure:10520: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10292 "configure"
+#line 10525 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10297: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10530: \"$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*
@@ -10329,7 +10562,7 @@ fi
 
  
  echo $ac_n "checking for Berkeley DB""... $ac_c" 1>&6
-echo "configure:10333: checking for Berkeley DB" >&5
+echo "configure:10566: checking for Berkeley DB" >&5
 if eval "test \"\${ol_cv_berkeley_db+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -10382,17 +10615,17 @@ if test $ol_with_ldbm_api = manual ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:10386: checking for $ac_hdr" >&5
+echo "configure:10619: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10391 "configure"
+#line 10624 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10396: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10629: \"$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*
 
 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = mdbm ; then
        echo $ac_n "checking for MDBM library""... $ac_c" 1>&6
-echo "configure:10431: checking for MDBM library" >&5
+echo "configure:10664: checking for MDBM library" >&5
 if eval "test \"\${ol_cv_lib_mdbm+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
        ol_LIBS="$LIBS"
        echo $ac_n "checking for mdbm_set_chain""... $ac_c" 1>&6
-echo "configure:10437: checking for mdbm_set_chain" >&5
+echo "configure:10670: checking for mdbm_set_chain" >&5
 if eval "test \"\${ac_cv_func_mdbm_set_chain+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10442 "configure"
+#line 10675 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char mdbm_set_chain(); below.  */
@@ -10462,7 +10695,7 @@ f = mdbm_set_chain;
 
 ; return 0; }
 EOF
-if { (eval echo configure:10466: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10699: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_mdbm_set_chain=yes"
 else
@@ -10481,7 +10714,7 @@ else
   echo "$ac_t""no" 1>&6
 
                echo $ac_n "checking for mdbm_set_chain in -lmdbm""... $ac_c" 1>&6
-echo "configure:10485: checking for mdbm_set_chain in -lmdbm" >&5
+echo "configure:10718: checking for mdbm_set_chain in -lmdbm" >&5
 ac_lib_var=`echo mdbm'_'mdbm_set_chain | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -10489,7 +10722,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lmdbm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 10493 "configure"
+#line 10726 "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
@@ -10500,7 +10733,7 @@ int main() {
 mdbm_set_chain()
 ; return 0; }
 EOF
-if { (eval echo configure:10504: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10737: \"$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
@@ -10535,17 +10768,17 @@ echo "$ac_t""$ol_cv_lib_mdbm" 1>&6
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:10539: checking for $ac_hdr" >&5
+echo "configure:10772: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10544 "configure"
+#line 10777 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10549: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10782: \"$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*
@@ -10572,7 +10805,7 @@ fi
 done
 
  echo $ac_n "checking for db""... $ac_c" 1>&6
-echo "configure:10576: checking for db" >&5
+echo "configure:10809: checking for db" >&5
 if eval "test \"\${ol_cv_mdbm+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
 
 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then
        echo $ac_n "checking for GDBM library""... $ac_c" 1>&6
-echo "configure:10609: checking for GDBM library" >&5
+echo "configure:10842: checking for GDBM library" >&5
 if eval "test \"\${ol_cv_lib_gdbm+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
        ol_LIBS="$LIBS"
        echo $ac_n "checking for gdbm_open""... $ac_c" 1>&6
-echo "configure:10615: checking for gdbm_open" >&5
+echo "configure:10848: checking for gdbm_open" >&5
 if eval "test \"\${ac_cv_func_gdbm_open+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10620 "configure"
+#line 10853 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gdbm_open(); below.  */
@@ -10640,7 +10873,7 @@ f = gdbm_open;
 
 ; return 0; }
 EOF
-if { (eval echo configure:10644: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10877: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gdbm_open=yes"
 else
@@ -10659,7 +10892,7 @@ else
   echo "$ac_t""no" 1>&6
 
                echo $ac_n "checking for gdbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:10663: checking for gdbm_open in -lgdbm" >&5
+echo "configure:10896: checking for gdbm_open in -lgdbm" >&5
 ac_lib_var=`echo gdbm'_'gdbm_open | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -10667,7 +10900,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgdbm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 10671 "configure"
+#line 10904 "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
@@ -10678,7 +10911,7 @@ int main() {
 gdbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:10682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:10915: \"$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
@@ -10713,17 +10946,17 @@ echo "$ac_t""$ol_cv_lib_gdbm" 1>&6
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:10717: checking for $ac_hdr" >&5
+echo "configure:10950: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10722 "configure"
+#line 10955 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10727: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:10960: \"$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*
@@ -10750,7 +10983,7 @@ fi
 done
 
  echo $ac_n "checking for db""... $ac_c" 1>&6
-echo "configure:10754: checking for db" >&5
+echo "configure:10987: checking for db" >&5
 if eval "test \"\${ol_cv_gdbm+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -10786,18 +11019,18 @@ if test $ol_with_ldbm_api = auto ; then
        echo "configure: warning: skipping automatic checking for NDBM, must be manually enabled." 1>&2
 elif test $ol_with_ldbm_api = ndbm ; then
        echo $ac_n "checking for NDBM library""... $ac_c" 1>&6
-echo "configure:10790: checking for NDBM library" >&5
+echo "configure:11023: checking for NDBM library" >&5
 if eval "test \"\${ol_cv_lib_ndbm+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
        ol_LIBS="$LIBS"
        echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:10796: checking for dbm_open" >&5
+echo "configure:11029: checking for dbm_open" >&5
 if eval "test \"\${ac_cv_func_dbm_open+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10801 "configure"
+#line 11034 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbm_open(); below.  */
@@ -10821,7 +11054,7 @@ f = dbm_open;
 
 ; return 0; }
 EOF
-if { (eval echo configure:10825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_dbm_open=yes"
 else
@@ -10840,7 +11073,7 @@ else
   echo "$ac_t""no" 1>&6
 
                echo $ac_n "checking for dbm_open in -lndbm""... $ac_c" 1>&6
-echo "configure:10844: checking for dbm_open in -lndbm" >&5
+echo "configure:11077: checking for dbm_open in -lndbm" >&5
 ac_lib_var=`echo ndbm'_'dbm_open | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -10848,7 +11081,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lndbm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 10852 "configure"
+#line 11085 "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
@@ -10859,7 +11092,7 @@ int main() {
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:10863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11096: \"$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
@@ -10879,7 +11112,7 @@ else
   echo "$ac_t""no" 1>&6
 
                        echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6
-echo "configure:10883: checking for dbm_open in -ldbm" >&5
+echo "configure:11116: checking for dbm_open in -ldbm" >&5
 ac_lib_var=`echo dbm'_'dbm_open | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -10887,7 +11120,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldbm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 10891 "configure"
+#line 11124 "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
@@ -10898,7 +11131,7 @@ int main() {
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:10902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11135: \"$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
@@ -10935,17 +11168,17 @@ echo "$ac_t""$ol_cv_lib_ndbm" 1>&6
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:10939: checking for $ac_hdr" >&5
+echo "configure:11172: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10944 "configure"
+#line 11177 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10949: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11182: \"$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*
@@ -10972,7 +11205,7 @@ fi
 done
 
  echo $ac_n "checking for db""... $ac_c" 1>&6
-echo "configure:10976: checking for db" >&5
+echo "configure:11209: checking for db" >&5
 if eval "test \"\${ol_cv_ndbm+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -11019,17 +11252,17 @@ if test $ol_enable_wrappers != no ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11023: checking for $ac_hdr" >&5
+echo "configure:11256: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 11028 "configure"
+#line 11261 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11033: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11266: \"$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*
@@ -11060,7 +11293,7 @@ done
                have_wrappers=no
        else
                echo $ac_n "checking for main in -lwrap""... $ac_c" 1>&6
-echo "configure:11064: checking for main in -lwrap" >&5
+echo "configure:11297: checking for main in -lwrap" >&5
 ac_lib_var=`echo wrap'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -11068,14 +11301,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lwrap  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 11072 "configure"
+#line 11305 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:11079: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11312: \"$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
@@ -11106,7 +11339,7 @@ EOF
                SLAPD_LIBS="$SLAPD_LIBS -lwrap"
 
                                                echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6
-echo "configure:11110: checking for main in -lnsl" >&5
+echo "configure:11343: checking for main in -lnsl" >&5
 ac_lib_var=`echo nsl'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -11114,14 +11347,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 11118 "configure"
+#line 11351 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:11125: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11358: \"$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
 
 if test $ol_enable_syslog != no ; then
        echo $ac_n "checking for openlog""... $ac_c" 1>&6
-echo "configure:11165: checking for openlog" >&5
+echo "configure:11398: checking for openlog" >&5
 if eval "test \"\${ac_cv_func_openlog+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 11170 "configure"
+#line 11403 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char openlog(); below.  */
@@ -11190,7 +11423,7 @@ f = openlog;
 
 ; return 0; }
 EOF
-if { (eval echo configure:11194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_openlog=yes"
 else
@@ -11220,17 +11453,17 @@ if test $ol_enable_dmalloc != no ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11224: checking for $ac_hdr" >&5
+echo "configure:11457: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 11229 "configure"
+#line 11462 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11234: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11467: \"$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*
@@ -11257,7 +11490,7 @@ fi
 done
 
        echo $ac_n "checking for dmalloc_shutdown in -ldmalloc""... $ac_c" 1>&6
-echo "configure:11261: checking for dmalloc_shutdown in -ldmalloc" >&5
+echo "configure:11494: checking for dmalloc_shutdown in -ldmalloc" >&5
 ac_lib_var=`echo dmalloc'_'dmalloc_shutdown | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -11265,7 +11498,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldmalloc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 11269 "configure"
+#line 11502 "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
@@ -11276,7 +11509,7 @@ int main() {
 dmalloc_shutdown()
 ; return 0; }
 EOF
-if { (eval echo configure:11280: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11513: \"$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
@@ -11310,17 +11543,17 @@ if test $ol_enable_tcl != no ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11314: checking for $ac_hdr" >&5
+echo "configure:11547: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 11319 "configure"
+#line 11552 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11324: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11557: \"$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*
@@ -11351,7 +11584,7 @@ done
                have_tcl=no
        else
                echo $ac_n "checking for main in -ltcl""... $ac_c" 1>&6
-echo "configure:11355: checking for main in -ltcl" >&5
+echo "configure:11588: checking for main in -ltcl" >&5
 ac_lib_var=`echo tcl'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -11359,14 +11592,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltcl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 11363 "configure"
+#line 11596 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:11370: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11603: \"$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
@@ -11390,7 +11623,7 @@ fi
 
                if test $have_tcl != yes; then
                        echo $ac_n "checking for main in -ltcl7.6""... $ac_c" 1>&6
-echo "configure:11394: checking for main in -ltcl7.6" >&5
+echo "configure:11627: checking for main in -ltcl7.6" >&5
 ac_lib_var=`echo tcl7.6'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -11398,14 +11631,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltcl7.6  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 11402 "configure"
+#line 11635 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:11409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11642: \"$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
@@ -11430,7 +11663,7 @@ fi
 
                if test $have_tcl != yes; then
                        echo $ac_n "checking for main in -ltcl8.0""... $ac_c" 1>&6
-echo "configure:11434: checking for main in -ltcl8.0" >&5
+echo "configure:11667: checking for main in -ltcl8.0" >&5
 ac_lib_var=`echo tcl8.0'_'main | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -11438,14 +11671,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltcl8.0  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 11442 "configure"
+#line 11675 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:11449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11682: \"$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
@@ -11485,17 +11718,17 @@ for ac_hdr in termcap.h ncurses.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11489: checking for $ac_hdr" >&5
+echo "configure:11722: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 11494 "configure"
+#line 11727 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11499: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11732: \"$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*
@@ -11524,7 +11757,7 @@ done
 
 if test $ol_link_termcap = no ; then
        echo $ac_n "checking for tputs in -ltermcap""... $ac_c" 1>&6
-echo "configure:11528: checking for tputs in -ltermcap" >&5
+echo "configure:11761: checking for tputs in -ltermcap" >&5
 ac_lib_var=`echo termcap'_'tputs | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -11532,7 +11765,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltermcap  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 11536 "configure"
+#line 11769 "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
@@ -11543,7 +11776,7 @@ int main() {
 tputs()
 ; return 0; }
 EOF
-if { (eval echo configure:11547: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11780: \"$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
@@ -11576,7 +11809,7 @@ fi
 
 if test $ol_link_termcap = no ; then
        echo $ac_n "checking for initscr in -lncurses""... $ac_c" 1>&6
-echo "configure:11580: checking for initscr in -lncurses" >&5
+echo "configure:11813: checking for initscr in -lncurses" >&5
 ac_lib_var=`echo ncurses'_'initscr | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -11584,7 +11817,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lncurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 11588 "configure"
+#line 11821 "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
@@ -11595,7 +11828,7 @@ int main() {
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:11599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11832: \"$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
@@ -11638,17 +11871,17 @@ ol_link_sasl=no
 if test $ol_with_cyrus_sasl != no ; then
        ac_safe=`echo "sasl.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sasl.h""... $ac_c" 1>&6
-echo "configure:11642: checking for sasl.h" >&5
+echo "configure:11875: checking for sasl.h" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 11647 "configure"
+#line 11880 "configure"
 #include "confdefs.h"
 #include <sasl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11652: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11885: \"$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*
@@ -11672,7 +11905,7 @@ fi
 
        if test $ac_cv_header_sasl_h = yes ; then
                echo $ac_n "checking for sasl_client_init in -lsasl""... $ac_c" 1>&6
-echo "configure:11676: checking for sasl_client_init in -lsasl" >&5
+echo "configure:11909: checking for sasl_client_init in -lsasl" >&5
 ac_lib_var=`echo sasl'_'sasl_client_init | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -11680,7 +11913,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsasl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 11684 "configure"
+#line 11917 "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
@@ -11691,7 +11924,7 @@ int main() {
 sasl_client_init()
 ; return 0; }
 EOF
-if { (eval echo configure:11695: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11928: \"$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
@@ -11733,13 +11966,13 @@ if test $ol_with_fetch != no ; then
        ol=$LIBS
 LIBS="-lfetch -lcom_err $LIBS"
 echo $ac_n "checking fetch(3) library""... $ac_c" 1>&6
-echo "configure:11737: checking fetch(3) library" >&5
+echo "configure:11970: checking fetch(3) library" >&5
 if eval "test \"\${ol_cv_lib_fetch+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
        cat > conftest.$ac_ext <<EOF
-#line 11743 "configure"
+#line 11976 "configure"
 #include "confdefs.h"
 
 #include <sys/param.h>
@@ -11749,7 +11982,7 @@ int main() {
 struct url *u = fetchParseURL("file:///"); 
 ; return 0; }
 EOF
-if { (eval echo configure:11753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:11986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_lib_fetch=yes
 else
@@ -11787,17 +12020,17 @@ if test $ol_with_readline != no ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11791: checking for $ac_hdr" >&5
+echo "configure:12024: checking for $ac_hdr" >&5
 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 11796 "configure"
+#line 12029 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11801: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12034: \"$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*
@@ -11828,7 +12061,7 @@ done
                save_LIBS="$LIBS"
                LIBS="$TERMCAP_LIBS $LIBS"
                echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6
-echo "configure:11832: checking for readline in -lreadline" >&5
+echo "configure:12065: checking for readline in -lreadline" >&5
 ac_lib_var=`echo readline'_'readline | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -11836,7 +12069,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lreadline  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 11840 "configure"
+#line 12073 "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
@@ -11847,7 +12080,7 @@ int main() {
 readline()
 ; return 0; }
 EOF
-if { (eval echo configure:11851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12084: \"$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
 # FreeBSD (and others) have crypt(3) in -lcrypt
 if test $ol_enable_crypt != no ; then
        echo $ac_n "checking for crypt""... $ac_c" 1>&6
-echo "configure:11894: checking for crypt" >&5
+echo "configure:12127: checking for crypt" >&5
 if eval "test \"\${ac_cv_func_crypt+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 11899 "configure"
+#line 12132 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char crypt(); below.  */
@@ -11919,7 +12152,7 @@ f = crypt;
 
 ; return 0; }
 EOF
-if { (eval echo configure:11923: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12156: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_crypt=yes"
 else
@@ -11938,7 +12171,7 @@ else
   echo "$ac_t""no" 1>&6
 
                echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:11942: checking for crypt in -lcrypt" >&5
+echo "configure:12175: checking for crypt in -lcrypt" >&5
 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -11946,7 +12179,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 11950 "configure"
+#line 12183 "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
@@ -11957,7 +12190,7 @@ int main() {
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:11961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12194: \"$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
 # FreeBSD (and others) have setproctitle(3) in -lutil
 if test $ol_enable_proctitle != no ; then
        echo $ac_n "checking for setproctitle""... $ac_c" 1>&6
-echo "configure:12005: checking for setproctitle" >&5
+echo "configure:12238: checking for setproctitle" >&5
 if eval "test \"\${ac_cv_func_setproctitle+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12010 "configure"
+#line 12243 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char setproctitle(); below.  */
@@ -12030,7 +12263,7 @@ f = setproctitle;
 
 ; return 0; }
 EOF
-if { (eval echo configure:12034: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_setproctitle=yes"
 else
@@ -12049,7 +12282,7 @@ else
   echo "$ac_t""no" 1>&6
 
                echo $ac_n "checking for setproctitle in -lutil""... $ac_c" 1>&6
-echo "configure:12053: checking for setproctitle in -lutil" >&5
+echo "configure:12286: checking for setproctitle in -lutil" >&5
 ac_lib_var=`echo util'_'setproctitle | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -12057,7 +12290,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lutil  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 12061 "configure"
+#line 12294 "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
@@ -12068,7 +12301,7 @@ int main() {
 setproctitle()
 ; return 0; }
 EOF
-if { (eval echo configure:12072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:12305: \"$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
@@ -12103,12 +12336,12 @@ EOF
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:12107: checking for uid_t in sys/types.h" >&5
+echo "configure:12340: checking for uid_t in sys/types.h" >&5
 if eval "test \"\${ac_cv_type_uid_t+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12112 "configure"
+#line 12345 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -12137,7 +12370,7 @@ EOF
 fi
 
 echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6
-echo "configure:12141: checking type of array argument to getgroups" >&5
+echo "configure:12374: checking type of array argument to getgroups" >&5
 if eval "test \"\${ac_cv_type_getgroups+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -12145,7 +12378,7 @@ else
   ac_cv_type_getgroups=cross
 else
   cat > conftest.$ac_ext <<EOF
-#line 12149 "configure"
+#line 12382 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Rendell for this test.  */
@@ -12170,7 +12403,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:12174: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:12407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
     ac_cv_type_getgroups=gid_t
 else
@@ -12184,7 +12417,7 @@ fi
 
 if test $ac_cv_type_getgroups = cross; then
         cat > conftest.$ac_ext <<EOF
-#line 12188 "configure"
+#line 12421 "configure"
 #include "confdefs.h"
 #include <unistd.h>
 EOF
@@ -12207,12 +12440,12 @@ cat >> confdefs.h <<EOF
 EOF
 
  echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:12211: checking for ANSI C header files" >&5
+echo "configure:12444: checking for ANSI C header files" >&5
 if eval "test \"\${ac_cv_header_stdc+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12216 "configure"
+#line 12449 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -12220,7 +12453,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12224: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12457: \"$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*
@@ -12237,7 +12470,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 12241 "configure"
+#line 12474 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -12255,7 +12488,7 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 12259 "configure"
+#line 12492 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -12276,7 +12509,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 12280 "configure"
+#line 12513 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -12287,7 +12520,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:12291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:12524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -12311,12 +12544,12 @@ EOF
 fi
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:12315: checking for mode_t" >&5
+echo "configure:12548: checking for mode_t" >&5
 if eval "test \"\${ac_cv_type_mode_t+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12320 "configure"
+#line 12553 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -12346,12 +12579,12 @@ EOF
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:12350: checking for off_t" >&5
+echo "configure:12583: checking for off_t" >&5
 if eval "test \"\${ac_cv_type_off_t+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12355 "configure"
+#line 12588 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -12381,12 +12614,12 @@ EOF
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:12385: checking for pid_t" >&5
+echo "configure:12618: checking for pid_t" >&5
 if eval "test \"\${ac_cv_type_pid_t+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12390 "configure"
+#line 12623 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -12416,19 +12649,19 @@ EOF
 fi
 
 echo $ac_n "checking for ptrdiff_t""... $ac_c" 1>&6
-echo "configure:12420: checking for ptrdiff_t" >&5
+echo "configure:12653: checking for ptrdiff_t" >&5
 if eval "test \"\${am_cv_type_ptrdiff_t+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12425 "configure"
+#line 12658 "configure"
 #include "confdefs.h"
 #include <stddef.h>
 int main() {
 ptrdiff_t p
 ; return 0; }
 EOF
-if { (eval echo configure:12432: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12665: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   am_cv_type_ptrdiff_t=yes
 else
@@ -12449,12 +12682,12 @@ EOF
    fi
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:12453: checking return type of signal handlers" >&5
+echo "configure:12686: checking return type of signal handlers" >&5
 if eval "test \"\${ac_cv_type_signal+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12458 "configure"
+#line 12691 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -12471,7 +12704,7 @@ int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:12475: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12708: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -12490,19 +12723,19 @@ EOF
 
 
 echo $ac_n "checking for sig_atomic_t""... $ac_c" 1>&6
-echo "configure:12494: checking for sig_atomic_t" >&5
+echo "configure:12727: checking for sig_atomic_t" >&5
 if eval "test \"\${ol_cv_type_sig_atomic_t+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12499 "configure"
+#line 12732 "configure"
 #include "confdefs.h"
 #include <signal.h>
 int main() {
 sig_atomic_t atomic;
 ; return 0; }
 EOF
-if { (eval echo configure:12506: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12739: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_type_sig_atomic_t=yes
 else
@@ -12523,12 +12756,12 @@ EOF
   fi
  
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:12527: checking for size_t" >&5
+echo "configure:12760: checking for size_t" >&5
 if eval "test \"\${ac_cv_type_size_t+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12532 "configure"
+#line 12765 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -12558,12 +12791,12 @@ EOF
 fi
 
 echo $ac_n "checking for socklen_t""... $ac_c" 1>&6
-echo "configure:12562: checking for socklen_t" >&5
+echo "configure:12795: checking for socklen_t" >&5
 if eval "test \"\${ol_cv_type_socklen_t+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12567 "configure"
+#line 12800 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_SYS_TYPES_H
@@ -12577,7 +12810,7 @@ int main() {
 socklen_t len;
 ; return 0; }
 EOF
-if { (eval echo configure:12581: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12814: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_type_socklen_t=yes
 else
@@ -12598,12 +12831,12 @@ EOF
   fi
  
 echo $ac_n "checking for member st_blksize in aggregate type struct stat""... $ac_c" 1>&6
-echo "configure:12602: checking for member st_blksize in aggregate type struct stat" >&5
+echo "configure:12835: checking for member st_blksize in aggregate type struct stat" >&5
 if eval "test \"\${ac_cv_c_struct_member_st_blksize+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12607 "configure"
+#line 12840 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -12611,7 +12844,7 @@ int main() {
 struct stat foo; foo.st_blksize;
 ; return 0; }
 EOF
-if { (eval echo configure:12615: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12848: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_struct_member_st_blksize=yes
 else
@@ -12633,12 +12866,12 @@ EOF
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:12637: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:12870: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"\${ac_cv_header_time+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12642 "configure"
+#line 12875 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -12647,7 +12880,7 @@ int main() {
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:12651: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12884: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -12668,12 +12901,12 @@ EOF
 fi
 
 echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:12672: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:12905: checking whether struct tm is in sys/time.h or time.h" >&5
 if eval "test \"\${ac_cv_struct_tm+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12677 "configure"
+#line 12910 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -12681,7 +12914,7 @@ int main() {
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:12685: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12918: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
 
 # test for pw_gecos in struct passwd
 echo $ac_n "checking struct passwd for pw_gecos""... $ac_c" 1>&6
-echo "configure:12707: checking struct passwd for pw_gecos" >&5
+echo "configure:12940: checking struct passwd for pw_gecos" >&5
 if eval "test \"\${ol_cv_struct_passwd_pw_gecos+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
        cat > conftest.$ac_ext <<EOF
-#line 12713 "configure"
+#line 12946 "configure"
 #include "confdefs.h"
 #include <pwd.h>
 int main() {
@@ -12719,7 +12952,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:12723: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12956: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_struct_passwd_pw_gecos=yes
 else
 
 # test for pw_passwd in struct passwd
 echo $ac_n "checking struct passwd for pw_passwd""... $ac_c" 1>&6
-echo "configure:12745: checking struct passwd for pw_passwd" >&5
+echo "configure:12978: checking struct passwd for pw_passwd" >&5
 if eval "test \"\${ol_cv_struct_passwd_pw_passwd+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
        cat > conftest.$ac_ext <<EOF
-#line 12751 "configure"
+#line 12984 "configure"
 #include "confdefs.h"
 #include <pwd.h>
 int main() {
@@ -12757,7 +12990,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:12761: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:12994: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_struct_passwd_pw_passwd=yes
 else
@@ -12779,7 +13012,7 @@ fi
 
 
 echo $ac_n "checking if toupper() requires islower()""... $ac_c" 1>&6
-echo "configure:12783: checking if toupper() requires islower()" >&5
+echo "configure:13016: checking if toupper() requires islower()" >&5
 if eval "test \"\${ol_cv_c_upper_lower+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -12788,7 +13021,7 @@ else
   ol_cv_c_upper_lower=safe
 else
   cat > conftest.$ac_ext <<EOF
-#line 12792 "configure"
+#line 13025 "configure"
 #include "confdefs.h"
 
 #include <ctype.h>
@@ -12800,7 +13033,7 @@ main()
                exit(1);
 }
 EOF
-if { (eval echo configure:12804: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:13037: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ol_cv_c_upper_lower=no
 else
@@ -12823,12 +13056,12 @@ EOF
 fi
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:12827: checking for working const" >&5
+echo "configure:13060: checking for working const" >&5
 if eval "test \"\${ac_cv_c_const+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12832 "configure"
+#line 13065 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -12877,7 +13110,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if { (eval echo configure:12881: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:13114: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -12898,12 +13131,12 @@ EOF
 fi
 
 echo $ac_n "checking if compiler understands volatile""... $ac_c" 1>&6
-echo "configure:12902: checking if compiler understands volatile" >&5
+echo "configure:13135: checking if compiler understands volatile" >&5
 if eval "test \"\${ol_cv_c_volatile+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 12907 "configure"
+#line 13140 "configure"
 #include "confdefs.h"
 int x, y, z;
 int main() {
@@ -12912,7 +13145,7 @@ volatile int a; int * volatile b = x ? &y : &z;
       *b = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:12916: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:13149: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_c_volatile=yes
 else
@@ -12956,14 +13189,14 @@ EOF
 
 else
        echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:12960: checking whether byte ordering is bigendian" >&5
+echo "configure:13193: checking whether byte ordering is bigendian" >&5
 if eval "test \"\${ac_cv_c_bigendian+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_bigendian=unknown
 # See if sys/param.h defines the BYTE_ORDER macro.
 cat > conftest.$ac_ext <<EOF
-#line 12967 "configure"
+#line 13200 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -12974,11 +13207,11 @@ int main() {
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:12978: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:13211: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   # It does; now see whether it defined to BIG_ENDIAN or not.
 cat > conftest.$ac_ext <<EOF
-#line 12982 "configure"
+#line 13215 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -12989,7 +13222,7 @@ int main() {
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:12993: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:13226: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_bigendian=yes
 else
@@ -13009,7 +13242,7 @@ if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 13013 "configure"
+#line 13246 "configure"
 #include "confdefs.h"
 main () {
   /* Are we little or big endian?  From Harbison&Steele.  */
@@ -13022,7 +13255,7 @@ main () {
   exit (u.c[sizeof (long) - 1] == 1);
 }
 EOF
-if { (eval echo configure:13026: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:13259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_bigendian=no
 else
@@ -13046,7 +13279,7 @@ EOF
 fi
 
        echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:13050: checking size of short" >&5
+echo "configure:13283: checking size of short" >&5
 if eval "test \"\${ac_cv_sizeof_short+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -13054,7 +13287,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 13058 "configure"
+#line 13291 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -13065,7 +13298,7 @@ main()
   exit(0);
 }
 EOF
-if { (eval echo configure:13069: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:13302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_short=`cat conftestval`
 else
@@ -13085,7 +13318,7 @@ EOF
 
  
        echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:13089: checking size of int" >&5
+echo "configure:13322: checking size of int" >&5
 if eval "test \"\${ac_cv_sizeof_int+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -13093,7 +13326,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 13097 "configure"
+#line 13330 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -13104,7 +13337,7 @@ main()
   exit(0);
 }
 EOF
-if { (eval echo configure:13108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:13341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -13124,7 +13357,7 @@ EOF
 
  
        echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:13128: checking size of long" >&5
+echo "configure:13361: checking size of long" >&5
 if eval "test \"\${ac_cv_sizeof_long+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -13132,7 +13365,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 13136 "configure"
+#line 13369 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -13143,7 +13376,7 @@ main()
   exit(0);
 }
 EOF
-if { (eval echo configure:13147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:13380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -13200,7 +13433,7 @@ EOF
 
 
 echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:13204: checking for 8-bit clean memcmp" >&5
+echo "configure:13437: checking for 8-bit clean memcmp" >&5
 if eval "test \"\${ac_cv_func_memcmp_clean+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -13208,7 +13441,7 @@ else
   ac_cv_func_memcmp_clean=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 13212 "configure"
+#line 13445 "configure"
 #include "confdefs.h"
 
 main()
@@ -13218,7 +13451,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:13222: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:13455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_memcmp_clean=yes
 else
@@ -13236,12 +13469,12 @@ echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6
 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
 
 echo $ac_n "checking for strftime""... $ac_c" 1>&6
-echo "configure:13240: checking for strftime" >&5
+echo "configure:13473: checking for strftime" >&5
 if eval "test \"\${ac_cv_func_strftime+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 13245 "configure"
+#line 13478 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char strftime(); below.  */
@@ -13265,7 +13498,7 @@ f = strftime;
 
 ; return 0; }
 EOF
-if { (eval echo configure:13269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13502: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_strftime=yes"
 else
@@ -13287,7 +13520,7 @@ else
   echo "$ac_t""no" 1>&6
 # strftime is in -lintl on SCO UNIX.
 echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6
-echo "configure:13291: checking for strftime in -lintl" >&5
+echo "configure:13524: checking for strftime in -lintl" >&5
 ac_lib_var=`echo intl'_'strftime | sed 'y%./+-:%__p__%'`
 if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -13295,7 +13528,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lintl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 13299 "configure"
+#line 13532 "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
@@ -13306,7 +13539,7 @@ int main() {
 strftime()
 ; return 0; }
 EOF
-if { (eval echo configure:13310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13543: \"$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 $ac_n "checking for inet_aton()""... $ac_c" 1>&6
-echo "configure:13338: checking for inet_aton()" >&5
+echo "configure:13571: checking for inet_aton()" >&5
 if eval "test \"\${ol_cv_func_inet_aton+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 13343 "configure"
+#line 13576 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_SYS_TYPES_H
@@ -13361,7 +13594,7 @@ struct in_addr in;
 int rc = inet_aton( "255.255.255.255", &in );
 ; return 0; }
 EOF
-if { (eval echo configure:13365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13598: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_func_inet_aton=yes
 else
@@ -13383,12 +13616,12 @@ EOF
  
 
 echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:13387: checking for vprintf" >&5
+echo "configure:13620: checking for vprintf" >&5
 if eval "test \"\${ac_cv_func_vprintf+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 13392 "configure"
+#line 13625 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char vprintf(); below.  */
@@ -13412,7 +13645,7 @@ f = vprintf;
 
 ; return 0; }
 EOF
-if { (eval echo configure:13416: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13649: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_vprintf=yes"
 else
 
 if test "$ac_cv_func_vprintf" != yes; then
 echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:13440: checking for _doprnt" >&5
+echo "configure:13673: checking for _doprnt" >&5
 if eval "test \"\${ac_cv_func__doprnt+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 13445 "configure"
+#line 13678 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char _doprnt(); below.  */
@@ -13465,7 +13698,7 @@ f = _doprnt;
 
 ; return 0; }
 EOF
-if { (eval echo configure:13469: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func__doprnt=yes"
 else
@@ -13494,12 +13727,12 @@ if test $ac_cv_func_vprintf = yes ; then
                for ac_func in vsnprintf vsprintf
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:13498: checking for $ac_func" >&5
+echo "configure:13731: checking for $ac_func" >&5
 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 13503 "configure"
+#line 13736 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -13523,7 +13756,7 @@ f = $ac_func;
 
 ; return 0; }
 EOF
-if { (eval echo configure:13527: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13760: \"$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
@@ -13568,6 +13801,7 @@ for ac_func in \
        memcpy                  \
        memmove                 \
        mkstemp                 \
+       pipe                    \
        read                    \
        recv                    \
        recvfrom                \
@@ -13577,6 +13811,7 @@ for ac_func in \
        setsid                  \
        setuid                  \
        seteuid                 \
+       sigaction               \
        signal                  \
        sigset                  \
        snprintf                \
@@ -13598,12 +13833,12 @@ for ac_func in \
 
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:13602: checking for $ac_func" >&5
+echo "configure:13837: checking for $ac_func" >&5
 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 13607 "configure"
+#line 13842 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -13627,7 +13862,7 @@ f = $ac_func;
 
 ; return 0; }
 EOF
-if { (eval echo configure:13631: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13866: \"$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
@@ -13655,12 +13890,12 @@ done
 for ac_func in getopt tempnam
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:13659: checking for $ac_func" >&5
+echo "configure:13894: checking for $ac_func" >&5
 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 13664 "configure"
+#line 13899 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -13684,7 +13919,7 @@ f = $ac_func;
 
 ; return 0; }
 EOF
-if { (eval echo configure:13688: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:13923: \"$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
@@ -13713,13 +13948,13 @@ done
 
 # Check Configuration
 echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6
-echo "configure:13717: checking declaration of sys_errlist" >&5
+echo "configure:13952: checking declaration of sys_errlist" >&5
 if eval "test \"\${ol_cv_dcl_sys_errlist+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
        cat > conftest.$ac_ext <<EOF
-#line 13723 "configure"
+#line 13958 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -13729,7 +13964,7 @@ int main() {
 char *c = (char *) *sys_errlist
 ; return 0; }
 EOF
-if { (eval echo configure:13733: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:13968: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_dcl_sys_errlist=yes
        ol_cv_have_sys_errlist=yes
@@ -13752,20 +13987,20 @@ EOF
 
 
        echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6
-echo "configure:13756: checking existence of sys_errlist" >&5
+echo "configure:13991: checking existence of sys_errlist" >&5
 if eval "test \"\${ol_cv_have_sys_errlist+set}\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
                cat > conftest.$ac_ext <<EOF
-#line 13762 "configure"
+#line 13997 "configure"
 #include "confdefs.h"
 #include <errno.h>
 int main() {
 char *c = (char *) *sys_errlist
 ; return 0; }
 EOF
-if { (eval echo configure:13769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14004: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ol_cv_have_sys_errlist=yes
 else
@@ -13866,6 +14101,18 @@ if test "$ol_enable_rlookups" != no ; then
 #define SLAPD_RLOOKUPS 1
 EOF
 
+fi
+if test "$ol_enable_aci" != no ; then
+       cat >> confdefs.h <<\EOF
+#define SLAPD_ACI_ENABLED 1
+EOF
+
+fi
+if test "$ol_enable_discreteaci" != no ; then
+       cat >> confdefs.h <<\EOF
+#define SLAPD_ACI_DISCRETE_RIGHTS 1
+EOF
+
 fi
 
 if test "$ol_link_modules" != no ; then
index 083e62b6040ca440bed5f5b592ac4c356d6607e8..e08413ddc4ab10ba0f2141780653b95b7735cd2a 100644 (file)
@@ -1,3 +1,4 @@
+dnl $OpenLDAP$
 dnl
 dnl Copyright 1998,1999 The OpenLDAP Foundation.  All Rights Reserved.
 dnl 
@@ -6,6 +7,18 @@ dnl as authorized by the OpenLDAP Public License.  A copy of this
 dnl license is available at http://www.OpenLDAP.org/license.html or
 dnl in file LICENSE in the top-level directory of the distribution.
 dnl
+define([AC_INIT_BINSH],
+[[#! /bin/sh
+# $]OpenLDAP[$
+# from] translit([$OpenLDAP$], $")] [
+
+# Copyright 1998,1999 The OpenLDAP Foundation.  All Rights Reserved.
+# 
+# Redistribution and use in source and binary forms are permitted only
+# as authorized by the OpenLDAP Public License.  A copy of this
+# license is available at http://www.OpenLDAP.org/license.html or
+# in file LICENSE in the top-level directory of the distribution.
+])dnl
 
 dnl Disable config.cache!
 define([AC_CACHE_LOAD], )dnl
@@ -71,7 +84,7 @@ dnl ol_enable_syslog=no
 OL_ARG_ENABLE(syslog,[  --enable-syslog        enable syslog support], auto)dnl
 OL_ARG_ENABLE(proctitle,[  --enable-proctitle  enable proctitle support], yes)dnl
 OL_ARG_ENABLE(cache,[  --enable-cache  enable caching], yes)dnl
-OL_ARG_ENABLE(dns,[  --enable-dns              enable V2 DNS  extension], no)dnl
+OL_ARG_ENABLE(dns,[  --enable-dns              enable V2 DX Referrals extension], no)dnl
 OL_ARG_ENABLE(referrals,[  --enable-referrals  enable V2 Referrals extension], yes)dnl
 OL_ARG_ENABLE(cldap,[  --enable-cldap  enable connectionless ldap], no)dnl
 OL_ARG_ENABLE(x_compile,[  --enable-x-compile  enable cross compiling],
@@ -80,17 +93,17 @@ OL_ARG_ENABLE(x_compile,[  --enable-x-compile       enable cross compiling],
 dnl General "with" options
 OL_ARG_ENABLE(dmalloc,[  --enable-dmalloc      enable debug malloc support], no)dnl
 
-OL_ARG_WITH(cyrus_sasl,[  --with-cyrus-sasl  with Cyrus SASL support],
+OL_ARG_WITH(cyrus_sasl,[  --with-cyrus-sasl    with Cyrus SASL support],
        auto, [auto yes no] )
-OL_ARG_WITH(fetch,[  --with-fetch  with fetch URL support],
+OL_ARG_WITH(fetch,[  --with-fetch              with fetch URL support],
        auto, [auto yes no] )
 OL_ARG_WITH(kerberos,[  --with-kerberos        with Kerberos support],
        auto, [auto k5 k4 afs yes no])
-OL_ARG_WITH(readline,[  --with-readline  with readline support],
+OL_ARG_WITH(readline,[  --with-readline        with readline support],
        auto, [auto yes no] )
 OL_ARG_WITH(threads,[  --with-threads  use threads],
-       auto, [auto posix mach lwp yes no manual] )
-OL_ARG_WITH(tls,[  --with-tls  with TLS/SSL support],
+       auto, [auto posix mach pth lwp yes no manual] )
+OL_ARG_WITH(tls,[  --with-tls          with TLS/SSL support],
        auto, [auto ssleay openssl yes no] )
 OL_ARG_WITH(yielding_select,[  --with-yielding-select  with implicitly yielding select],
        auto, [auto yes no manual] )
@@ -98,7 +111,7 @@ OL_ARG_WITH(yielding_select,[  --with-yielding-select        with implicitly yielding s
 dnl Server options
 
 dnl SLAPD OPTIONS
-AC_ARG_WITH(xxslapdoptions,[SLAPD Options:])
+AC_ARG_WITH(xxslapdoptions,[SLAPD (Standalone LDAP Daemon) Options:])
 OL_ARG_ENABLE(slapd,[  --enable-slapd  enable building slapd], yes)dnl
 OL_ARG_ENABLE(cleartext,[    --enable-cleartext        enable cleartext passwords], yes)dnl
 OL_ARG_ENABLE(crypt,[    --enable-crypt        enable crypt(3) passwords], auto)dnl
@@ -107,6 +120,8 @@ OL_ARG_ENABLE(multimaster,[    --enable-multimaster enable multimaster replicati
 OL_ARG_ENABLE(phonetic,[    --enable-phonetic  enable phonetic/soundex], no)dnl
 OL_ARG_ENABLE(quipu,[    --enable-quipu        build quipu migration tools], no)dnl
 OL_ARG_ENABLE(rlookups,[    --enable-rlookups  enable reverse lookups], auto)dnl
+OL_ARG_ENABLE(aci,[    --enable-aci    enable per-object ACIs], no)dnl
+OL_ARG_ENABLE(discreteaci,[    --enable-discreteaci    enable discrete rights in ACIs], no)dnl
 OL_ARG_ENABLE(wrappers,[    --enable-wrappers  enable tcp wrapper support], no)dnl
 
 dnl SLAPD Backend options
@@ -117,10 +132,10 @@ OL_ARG_ENABLE(ldap,[    --enable-ldap     enable ldap backend], no)dnl
 OL_ARG_WITH(ldap_module,[      --with-ldap-module      module type], static,
        [static dynamic])
 OL_ARG_ENABLE(ldbm,[    --enable-ldbm  enable ldbm backend], yes)dnl
-OL_ARG_WITH(ldbm_module,[      --with-ldbm-module      module type], static,
-       [static dynamic])
 OL_ARG_WITH(ldbm_api,[      --with-ldbm-api    use LDBM API], auto,
        [auto db2 db mdbm gdbm ndbm manual])
+OL_ARG_WITH(ldbm_module,[      --with-ldbm-module      module type], static,
+       [static dynamic])
 OL_ARG_WITH(ldbm_type,[      --with-ldbm-type  use LDBM type], auto,
        [auto btree hash])
 
@@ -138,7 +153,7 @@ OL_ARG_WITH(tcl_module,[      --with-tcl-module     module type], static,
        [static dynamic])
 
 dnl SLURPD OPTIONS
-AC_ARG_WITH(xxslurpdoptions,[SLURPD Options:])
+AC_ARG_WITH(xxslurpdoptions,[SLURPD (Replication Daemon) Options:])
 OL_ARG_ENABLE(slurpd,[  --enable-slurpd        enable building slurpd], auto)dnl
 
 AC_ARG_WITH(xxliboptions,[Library Generation & Linking Options])
@@ -199,6 +214,12 @@ if test $ol_enable_slapd = no ; then
        if test $ol_enable_rlookups = yes ; then
                AC_MSG_WARN([slapd disabled, ignoring --enable-rlookups argument])
        fi
+       if test $ol_enable_aci = yes ; then
+               AC_MSG_WARN([slapd disabled, ignoring --enable-aci argument])
+       fi
+       if test $ol_enable_discreteaci = yes ; then
+               AC_MSG_WARN([slapd disabled, ignoring --enable-discreteaci argument])
+       fi
        if test $ol_with_ldbm_api != auto ; then
                AC_MSG_WARN([slapd disabled, ignoring --with-ldbm-api argument])
        fi
@@ -244,6 +265,8 @@ if test $ol_enable_slapd = no ; then
        ol_enable_phonetic=no
        ol_enable_quipu=no
        ol_enable_rlookups=no
+       ol_enable_aci=no
+       ol_enable_discreteaci=no
        ol_enable_wrappers=no
 
        ol_with_ldbm_api=no
@@ -387,7 +410,6 @@ dnl AC_PROG_INSTALL
 
 AC_DEFINE(HAVE_MKVERSION, 1, [define this if you have mkversion])
 
-
 dnl
 dnl Determine which C translator to use
 dnl
@@ -583,7 +605,6 @@ AC_CHECK_HEADERS(   \
        resolv.h                \
        sgtty.h                 \
        shadow.h                \
-       stdarg.h                \
        stddef.h                \
        string.h                \
        strings.h               \
@@ -613,9 +634,7 @@ dnl         -lsocket [ -lnsl_s | -lnsl ]
 dnl            -linet
 
 AC_CHECK_FUNC(socket, :, [     
-dnl
 dnl hopefully we won't include too many libraries
-dnl
        AC_CHECK_LIB(socket, main)
        AC_CHECK_LIB(net, main)
        AC_CHECK_LIB(net, socket)
@@ -625,14 +644,19 @@ dnl
        AC_CHECK_LIB(gen, main)
 ])
 
+dnl require select
 AC_CHECK_FUNC(select, :, AC_MSG_ERROR([select() required.]))
+dnl AC_CHECK_FUNCS(socketpair)
 
 dnl Select arg types
 dnl (if this detection becomes permenent, it and the select() detection
 dnl should be done before the yielding select test) 
 AC_FUNC_SELECT_ARGTYPES
 
+dnl check to see if system call automatically restart
+dnl AC_SYS_RESTARTABLE_SYSCALLS
 
+dnl require POSIX regex
 AC_CHECK_HEADERS( regex.h )
 if test "$ac_cv_header_regex_h" != yes ; then
        AC_MSG_ERROR([POSIX regex.h required.])
@@ -644,7 +668,6 @@ if test "$ol_cv_c_posix_regex" = no ; then
        AC_MSG_ERROR([broken POSIX regex!])
 fi
 
-
 dnl HP-UX requires -lV3
 AC_CHECK_LIB(V3, sigset)
 
@@ -849,7 +872,7 @@ ol_link_threads=no
 if test $ol_with_threads = auto -o $ol_with_threads = yes \
        -o $ol_with_threads = posix ; then
 
-       AC_CHECK_HEADERS(pthread.h sched.h)
+       AC_CHECK_HEADERS(pthread.h)
 
        if test $ac_cv_header_pthread_h = yes ; then
                OL_POSIX_THREAD_VERSION
@@ -868,6 +891,11 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                ol_with_threads=found
 
                OL_HEADER_LINUX_THREADS
+               OL_HEADER_GNU_PTH_PTHREAD_H
+
+               if test $ol_cv_header_gnu_pth_pthread_h = no ; then
+                       AC_CHECK_HEADERS(sched.h)
+               fi
 
                dnl Now the hard part, how to link?
                dnl
@@ -1188,6 +1216,26 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
        fi
 fi
 
+if test $ol_with_threads = auto -o $ol_with_threads = yes \
+       -o $ol_with_threads = pth ; then
+
+       AC_CHECK_HEADERS(pth.h)
+
+       if test $ac_cv_header_pth_h = yes ; then
+               AC_CHECK_LIB(pth, pth_version, [have_pth=yes], [have_pth=no])
+
+               if test $have_pth = yes ; then
+                       AC_DEFINE(HAVE_GNU_PTH,1,[if you have GNU Pth])
+                       LTHREAD_LIBS="$LTHREAD_LIBS -lpth"
+                       ol_link_threads=pth
+
+                       if test $ol_with_yielding_select = auto ; then
+                               ol_with_yielding_select=yes
+                       fi
+               fi
+       fi
+fi
+
 if test $ol_with_threads = auto -o $ol_with_threads = yes \
        -o $ol_with_threads = lwp ; then
 
@@ -1766,6 +1814,7 @@ AC_CHECK_FUNCS(           \
        memcpy                  \
        memmove                 \
        mkstemp                 \
+       pipe                    \
        read                    \
        recv                    \
        recvfrom                \
@@ -1775,6 +1824,7 @@ AC_CHECK_FUNCS(           \
        setsid                  \
        setuid                  \
        seteuid                 \
+       sigaction               \
        signal                  \
        sigset                  \
        snprintf                \
@@ -1850,6 +1900,12 @@ fi
 if test "$ol_enable_rlookups" != no ; then
        AC_DEFINE(SLAPD_RLOOKUPS,1,[define to support reverse lookups])
 fi
+if test "$ol_enable_aci" != no ; then
+       AC_DEFINE(SLAPD_ACI_ENABLED,1,[define to support per-object ACIs])
+fi
+if test "$ol_enable_discreteaci" != no ; then
+       AC_DEFINE(SLAPD_ACI_DISCRETE_RIGHTS,1,[define to support discrete rights in ACIs])
+fi
 
 if test "$ol_link_modules" != no ; then
        AC_DEFINE(SLAPD_MODULES,1,[define to support modules])
diff --git a/doc/Makefile.in b/doc/Makefile.in
new file mode 100644 (file)
index 0000000..754eee7
--- /dev/null
@@ -0,0 +1,7 @@
+# $OpenLDAP$
+## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
+## COPYING RESTRICTIONS APPLY, See COPYRIGHT file
+##
+## doc Makefile.in for OpenLDAP
+
+SUBDIRS= man
diff --git a/doc/man/man5/ldap.conf.5 b/doc/man/man5/ldap.conf.5
new file mode 100644 (file)
index 0000000..00d9d4a
--- /dev/null
@@ -0,0 +1,86 @@
+.TH LDAP.CONF 5 "29 November 1998" "OpenLDAP LDVERSION"
+.UC 6
+.SH NAME
+ldap.conf \- ldap configuration file
+.SH SYNOPSIS
+ETCDIR/ldap.conf
+.SH DESCRIPTION
+The
+.I ldap.conf
+configuration file is used to set system-wide defaults to be applied when
+running
+.I ldap
+clients.  If the environment variable \fBLDAPNOINIT\fP is defined, all
+defaulting is disabled.
+.LP
+Each user may specify an optional configuration file,
+.IR .ldaprc ,
+in his/her home directory which will be used to override the system-wide
+defaults file.
+.LP
+Additional configuration files can be specified using
+the \fBLDAPCONF\fP and \fBLDAPRC\fP environment variables.
+\fBLDAPCONF\fP may be set the path of a configuration file.  This
+path can be absolute or relative to current working directory.
+The \fBLDAPRC\fP, if defined, should be a basename of a file
+in the current working directory or in the user's home directory.
+.LP
+Environmental variables may also be used to augment the file based defaults.
+The name of the option is the as listed but with a prefix of \fBLDAP\fP.
+For example, to define \fBBASE\fP via the environment, define the variable
+\fBLDAPBASE\fP to desired value.
+.SH OPTIONS
+The different configuration options are:
+.TP 1i
+\fBBASE <base>\fP
+Used to specify the default base dn to use when performing ldap operations.
+The base must be specified as a Distinguished Name in LDAP format.
+.TP 1i
+\fBHOST <name[:port] ...>\fP
+Used to specify the name(s) of an LDAP server(s) to which 
+.I ldap 
+library should connect to.  Each server's name can be specified as a
+domain-style name or an IP address and optionally followed a ':' and
+the port number the ldap server is listening on.  A space separated
+listed of host may be provided.
+.TP 1i
+\fBPORT <port>\fP
+Used to specify the port used with connecting to LDAP servers(s).
+The port may be specified as a number.
+.TP 1i
+\fBSIZELIMIT <integer>\fP
+Used to specify a size limit to use when performing searches.  The
+number should be an non-negative integer.  \fISIZELIMIT\fP of zero (0)
+specifies unlimited search size.
+.TP 1i
+\fBTIMELIMIT <integer>\fP
+Used to specify a time limit to use when performing searches.  The
+number should be an non-negative integer.  \fITIMELIMIT\fP of zero (0)
+specifies unlimited search time to be used.
+.TP 1i
+\fBDEREF <never|searching|finding|always>\fP
+Specify how aliases dereferencing is done.  \fIDEREF\fP should
+be set to one of
+.B never,
+.B always,
+.B search,
+or 
+.B find 
+to specify that aliases are never dereferenced, always dereferenced,
+dereferenced when searching, or dereferenced only when locating the
+base object for the search.  The default is to never dereference aliases.
+.SH FILES
+.I  ETCDIR/ldap.conf
+.LP
+.I  $HOME/.ldaprc
+.LP
+.I  $CWD/.ldaprc
+.SH "SEE ALSO"
+ldap(3)
+.SH AUTHOR
+Kurt Zeilenga, The OpenLDAP Project
+.SH ACKNOWLEDGEMENTS
+.B     OpenLDAP
+is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
+.B     OpenLDAP
+is derived from University of Michigan LDAP 3.3 Release.  
index be0c97d3bf58f2adacc9d61c4c04517bc4a287b6..6fc43e11baf2df2b85123dde6e8fd532939128bd 100644 (file)
@@ -1,16 +1,21 @@
-.TH SLAPD 8C "6 November 1995" "U-M LDAP LDVERSION"
+.TH SLAPD 8C "3 April 1999" "OpenLDAP LDVERSION"
 .SH NAME
 slapd \- Stand-alone LDAP Daemon
 .SH SYNOPSIS
-.B ETCDIR/slapd [\-d debug\-level]
-.B [\-f slapd\-config\-file] [\-p port\-number]
-.B [\-s syslog\-level] [\-i]
+.B LIBEXECDIR/slapd 
+.B [\-f slapd\-config\-file]
+.B [\-h URLs]
+.B [\-d debug\-level]
+.B [\-p port\-number]
+.B [\-P tls\-port\-number]
+.B [\-s syslog\-level] [\-l syslog\-local\-user]
+.B [\-u user] [\-g group]
 .B 
 .SH DESCRIPTION
 .LP
 .B Slapd
 is the stand-alone LDAP daemon. It listens for LDAP connections on
-port 389, responding
+any number of ports (default 389), responding
 to the LDAP operations it receives over these connections.
 .B slapd
 is typically invoked at boot time, usually out of
@@ -18,10 +23,22 @@ is typically invoked at boot time, usually out of
 Upon startup,
 .B slapd
 normally forks and disassociates itself from the invoking tty.
+If configured in
+.BR ETCDIR/slapd.conf ,
+the
+.B slapd
+process will print its process ID ( see
+.BR getpid (2)
+) to a 
+.B .pid
+file, as well as the command line options during invocation to an
+.B .args
+file ( see 
+.BR slapd.conf (5)
+).
 If the
 .B \-d
-flag is given and debugging is set to some non-zero
-value,
+flag is given, even with a zero argument,
 .B slapd
 will not fork and disassociate from the invoking tty.
 .LP
@@ -41,7 +58,7 @@ See "The SLAPD and SLURPD Administrator's Guide" for more details on
 .BI \-d " debug\-level"
 Turn on debugging as defined by
 .I debug\-level.
-If this option is specified,
+If this option is specified, even with a zero argument,
 .B slapd
 will not fork or disassociate from the invoking terminal.  Some general
 operation and status messages are printed for any value of \fIdebug\-level\fP.
@@ -55,21 +72,76 @@ at what level debugging statements should be logged to the
 .BR syslog (8)
 facility.
 .TP
+.BI \-l " syslog\-local\-user"
+Selects the local user of the
+.BR syslog (8)
+facility. Values can be 
+.BR LOCAL0 , 
+.BR LOCAL1 , 
+and so on, up to 
+.BR LOCAL7 . 
+The default is
+.BR LOCAL4 .
+However, this option is only permitted on systems that support
+local users with the 
+.BR syslog (8)
+facility.
+.TP
 .BI \-f " slapd\-config\-file"
 Specifies the slapd configuration file. The default is
 .BR ETCDIR/slapd.conf .
 .TP
+.BI \-h " URLlist"
+.B slapd
+will serve
+.B ldap:///
+(LDAP over TCP on all interfaces on default LDAP port).  As such,
+it will bind to INADDR_ANY, port 389.
+The
+.B \-h
+option may be used to specify LDAP (and LDAPS) URLs to serve.
+For example, if slapd is given
+.B \-h " ldap://127.0.0.1:9009/ ldaps:///", 
+It will bind 127.0.0.1:9009 for LDAP and INADDR_ANY:636 for LDAP over TLS.
+A space separated list of URLs is expected.  The URLS should be of
+LDAP (ldap://) or, if supported, LDAP over TLS (ldaps://) type without
+a DN or other optional parameters.  Hosts may be specified in either
+Internet '.' format (preferred) or by name.  Ports, if specfied,
+must be numeric.
+.TP
 .BI \-p " port\-number"
 .B slapd
-will listen on the default LDAP port (389) unless this option is given
-to override the default.
+will use on the default port (389) for LDAP URLs unless this
+option is given to override the default.
+A numeric port number is expected.
 .TP
-.B \-i
-This option tells
+.BI \-P " tls\-port\-number"
 .B slapd
-that it is being run from
-.BR inetd(8) ,
-the Internet protocol daemon.
+will use on the default port (636) for LDAPS (LDAP over TLS) URLs
+unless this option is given to override the default.  A numeric port
+number is expected.
+.TP
+.BI \-P " port\-number"
+Changes the port where 
+.B slapd
+will expect LDAP over raw TLS connections.  If this option is not given,
+the default port for this purpose (636) will be used.  A numeric port
+number is expected.
+.TP
+.BI \-u " user"
+.B slapd
+will run slapd with the specified user name or id, and that user's
+supplementary group access list as set with initgroups(3).  The group ID
+is also changed to this user's gid, unless the -g option is used to
+override.
+.TP
+.BI \-g " group"
+.B slapd
+will run with the specified group name or id.
+.LP
+Note that on some systems, running as a non-privileged user will prevent
+passwd back-ends from accessing the encrypted passwords.  Note also that
+any shell back-ends will run as the specified non-privileged user.
 .SH EXAMPLES
 To start 
 .I slapd
@@ -78,7 +150,7 @@ the LDAP databases defined in the default config file, just type:
 .LP
 .nf
 .ft tt
-       ETCDIR/slapd
+       LIBEXECDIR/slapd
 .ft
 .fi
 .LP
@@ -89,7 +161,7 @@ on voluminous debugging which will be printed on standard error, type:
 .LP
 .nf
 .ft tt
-       ETCDIR/slapd -f /usr/local/slapd/slapd.conf -d 255
+       LIBEXECDIR/slapd -f ETCDIR/slapd.conf -d 255
 .ft
 .fi
 .LP
@@ -102,3 +174,8 @@ on voluminous debugging which will be printed on standard error, type:
 .SH BUGS
 When using the LDBM database backend, the Modify RDN operation does not
 update the attribute values in the entry that are affected by the change.
+.SH ACKNOWLEDGEMENTS
+.B     OpenLDAP
+is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
+.B     OpenLDAP
+is derived from University of Michigan LDAP 3.3 Release.  
index 037584e8a1c7e27082f3917cd671a35c89805816..51c8c14b0dc71c74a6a8efee553d2f3ececfd492 100644 (file)
@@ -1,8 +1,8 @@
-.TH SLURPD 8C "6 November 1995" "U-M LDAP LDVERSION"
+.TH SLURPD 8C "22 September 1998" "OpenLDAP LDVERSION"
 .SH NAME
 slurpd \- Standalone LDAP Update Replication Daemon
 .SH SYNOPSIS
-.B ETCDIR/slurpd [\-d debug\-level]
+.B LIBEXECDIR/slurpd [\-d debug\-level]
 .B [\-f slapd\-config\-file] [\-r slapd\-replog\-file]
 .B [\-t temp\-dir] [\-o] [\-k srvtab\-file]
 .B 
@@ -62,7 +62,7 @@ for details on the standalone LDAP daemon.
 .BI \-d " debug\-level"
 Turn on debugging as defined by
 .I debug\-level.
-If this option is specified,
+If this option is specified, even with a zero argument,
 .B slurpd
 will not fork or disassociate from the invoking terminal.  Some general
 operation and status messages are printed for any value of \fIdebug\-level\fP.
@@ -126,7 +126,7 @@ just type:
 .LP
 .nf
 .ft tt
-       ETCDIR/slurpd
+       LIBEXECDIR/slurpd
 .ft
 .fi
 .LP
@@ -139,7 +139,7 @@ on voluminous debugging which will be printed on standard error, type:
 .LP
 .nf
 .ft tt
-       ETCDIR/slurpd -f /usr/local/etc/slapd.conf -d 255
+       LIBEXECDIR/slurpd -f ETCDIR/slapd.conf -d 255
 .ft
 .fi
 .LP
@@ -149,3 +149,8 @@ on voluminous debugging which will be printed on standard error, type:
 .BR slapd (8)
 .LP
 "The SLAPD and SLURPD Administrator's Guide"
+.SH ACKNOWLEDGEMENTS
+.B     OpenLDAP
+is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
+.B     OpenLDAP
+is derived from University of Michigan LDAP 3.3 Release.  
index eb7ccd560d6628bc0047a8336622a321a7d0f657..a3342c6a58aef038fcbe656e961cf9dfab196cc0 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
 ## COPYING RESTRICTIONS APPLY, See COPYRIGHT file
 ##
diff --git a/include/ac/alloca.h b/include/ac/alloca.h
new file mode 100644 (file)
index 0000000..3d04de6
--- /dev/null
@@ -0,0 +1,36 @@
+/* Generic alloca.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_ALLOCA_H
+#define _AC_ALLOCA_H
+
+#error  "alloca() not supported, use malloc()"
+
+/* AIX requires this to be the first thing in the file.  */
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+#else
+# if HAVE_ALLOCA_H
+#  include <alloca.h>
+# else
+#  ifdef _AIX
+#pragma alloca
+#  else
+#   ifndef alloca /* predefined by HP cc +Olibcalls */
+extern char *(alloca)();
+#   endif
+#  endif
+# endif
+#endif
+
+
+#endif /* _AC_ALLOCA_H */
index 6849638cfd239761b9667ae7f9df7eb7b7a00707..6c3a44ed77639592160cbcba9b31de29ec738482 100644 (file)
@@ -1,4 +1,5 @@
 /* Generic assert.h */
+/* $OpenLDAP$ */
 /*
  * Copyright 1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
diff --git a/include/ac/bytes.h b/include/ac/bytes.h
new file mode 100644 (file)
index 0000000..160f0bb
--- /dev/null
@@ -0,0 +1,66 @@
+/* Generic bytes.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_BYTES_H
+#define _AC_BYTES_H
+
+/* cross compilers should define both AC_INT{2,4}_TYPE in CPPFLAGS */
+
+#if !defined( AC_INT4_TYPE ) || !defined( AC_INT2_TYPE )
+       /* use autoconf defines to provide sized typedefs */
+#      if SIZEOF_LONG == 4
+#              define AC_INT4_TYPE long
+#      elif SIZEOF_INT == 4
+#              define AC_INT4_TYPE int
+#      else
+#              error "AC_INT4_TYPE?"
+#      endif
+
+#      if SIZEOF_SHORT == 2
+#              define AC_INT2_TYPE short
+#      elif SIZEOF_INT == 2
+#              define AC_INT2_TYPE int
+#      else
+#              error "AC_INT2_TYPE?"
+#      endif
+#endif
+    
+typedef AC_INT4_TYPE ac_int4;
+typedef signed AC_INT4_TYPE ac_sint4;
+typedef unsigned AC_INT4_TYPE ac_uint4;
+
+typedef AC_INT2_TYPE ac_int2;
+typedef signed AC_INT2_TYPE ac_sint2;
+typedef unsigned AC_INT2_TYPE ac_uint2;
+
+#ifndef BYTE_ORDER
+/* cross compilers should define BYTE_ORDER in CPPFLAGS */
+
+/*
+ * Definitions for byte order, according to byte significance from low
+ * address to high.
+ */
+#define LITTLE_ENDIAN   1234    /* LSB first: i386, vax */
+#define BIG_ENDIAN  4321        /* MSB first: 68000, ibm, net */
+#define PDP_ENDIAN  3412        /* LSB first in word, MSW first in long */
+
+/* assume autoconf's AC_C_BIGENDIAN has been ran */
+/* if it hasn't, we assume (maybe falsely) the order is LITTLE ENDIAN */
+#      ifdef WORDS_BIGENDIAN
+#              define BYTE_ORDER  BIG_ENDIAN
+#      else
+#              define BYTE_ORDER  LITTLE_ENDIAN
+#      endif
+
+#endif /* BYTE_ORDER */
+
+#endif /* _AC_BYTES_H */
diff --git a/include/ac/ctype.h b/include/ac/ctype.h
new file mode 100644 (file)
index 0000000..cfdcd92
--- /dev/null
@@ -0,0 +1,29 @@
+/* Generic ctype.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_CTYPE_H
+#define _AC_CTYPE_H
+
+#include <ctype.h>
+
+#undef TOUPPER
+#undef TOLOWER
+
+#ifdef C_UPPER_LOWER
+# define TOUPPER(c)    (islower(c) ? toupper(c) : (c))
+# define TOLOWER(c)    (isupper(c) ? tolower(c) : (c))
+#else
+# define TOUPPER(c)    toupper(c)
+# define TOLOWER(c)    tolower(c)
+#endif
+
+#endif /* _AC_CTYPE_H */
diff --git a/include/ac/dirent.h b/include/ac/dirent.h
new file mode 100644 (file)
index 0000000..53f189a
--- /dev/null
@@ -0,0 +1,33 @@
+/* Generic dirent.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_DIRENT_H
+#define _AC_DIRENT_H
+
+#if HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# if HAVE_SYS_NDIR_H
+#  include <sys/ndir.h>
+# endif
+# if HAVE_SYS_DIR_H
+#  include <sys/dir.h>
+# endif
+# if HAVE_NDIR_H
+#  include <ndir.h>
+# endif
+#endif
+
+#endif /* _AC_DIRENT_H */
diff --git a/include/ac/errno.h b/include/ac/errno.h
new file mode 100644 (file)
index 0000000..3d26e5e
--- /dev/null
@@ -0,0 +1,41 @@
+/* Generic errno.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_ERRNO_H
+#define _AC_ERRNO_H
+
+#if defined( HAVE_ERRNO_H )
+# include <errno.h>
+#elif defined( HAVE_SYS_ERRNO_H )
+# include <sys/errno.h>
+#endif
+
+#ifndef HAVE_SYS_ERRLIST
+       /* no sys_errlist */
+#      define          sys_nerr        0
+#      define          sys_errlist     ((char **)0)
+#elif DECL_SYS_ERRLIST 
+       /* have sys_errlist but need declaration */
+       extern int      sys_nerr;
+       extern char     *sys_errlist[];
+#endif
+
+#ifdef HAVE_STRERROR
+#define        STRERROR(err)   strerror(err)
+#else
+#define        STRERROR(err) \
+       ((err) > -1 && (err) < sys_nerr ? sys_errlist[(err)] : "unknown")
+#endif
+
+extern char* strerror_r();
+    
+#endif /* _AC_ERRNO_H */
diff --git a/include/ac/krb.h b/include/ac/krb.h
new file mode 100644 (file)
index 0000000..a5ffa7a
--- /dev/null
@@ -0,0 +1,31 @@
+/* Generic krb.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_KRB_H
+#define _AC_KRB_H
+
+#if defined( HAVE_KERBEROS )
+
+#if defined( HAVE_KERBEROSIV_KRB_H )
+#include <kerberosIV/krb.h>
+#elif defined( HAVE_KRB_H )
+#include <krb.h>
+#endif
+
+#if defined( HAVE_KERBEROSIV_DES_H )
+#include <kerberosIV/des.h>
+#elif defined( HAVE_DES_H )
+#include <des.h>
+#endif
+
+#endif /* HAVE_KERBEROS */
+#endif /* _AC_KRB_H */
diff --git a/include/ac/regex.h b/include/ac/regex.h
new file mode 100644 (file)
index 0000000..897f7f5
--- /dev/null
@@ -0,0 +1,36 @@
+/* Generic Regex */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+#ifndef _AC_REGEX_H_
+#define _AC_REGEX_H_
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifndef HAVE_REGEX_H
+/*     NO POSIX REGEX!!
+       you'll need to install a POSIX compatible REGEX library.
+       Either Henry Spencer's or GNU regex will do.
+
+       For NT: http://people.delphi.com/gjc/hs_regex.html
+*/
+#error "No POSIX REGEX available."
+
+#elif HAVE_GNUREGEX_H
+       /* system has GNU gnuregex.h */ 
+#      include <gnuregex.h>
+#else
+       /* have regex.h, assume it's POSIX compliant */
+#      include <regex.h>
+#endif /* regex.h */
+
+#endif /* _AC_REGEX_H_ */
diff --git a/include/ac/setproctitle.h b/include/ac/setproctitle.h
new file mode 100644 (file)
index 0000000..5bf1d2f
--- /dev/null
@@ -0,0 +1,29 @@
+/* Generic setproctitle.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_SETPROCTITLE_H
+#define _AC_SETPROCTITLE_H
+
+#ifdef LDAP_PROCTITLE
+
+#if defined( HAVE_LIBUTIL_H )
+#      include <libutil.h>
+#else
+       /* use lutil version */
+       LDAP_F(void) (setproctitle) LDAP_P((const char *fmt, ...)) \
+                                   LDAP_GCCATTR((format(printf, 1, 2)));
+       LDAP_F(int) Argc;
+       LDAP_F(char) **Argv;
+#endif
+
+#endif /* LDAP_PROCTITLE */
+#endif /* _AC_SETPROCTITLE_H */
diff --git a/include/ac/signal.h b/include/ac/signal.h
new file mode 100644 (file)
index 0000000..73f5d48
--- /dev/null
@@ -0,0 +1,65 @@
+/* Generic signal.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_SIGNAL_H
+#define _AC_SIGNAL_H
+
+#include <signal.h>
+
+#undef SIGNAL
+#ifdef HAVE_SIGSET
+#define SIGNAL sigset
+#else
+#define SIGNAL signal
+#endif
+
+#if !defined( LDAP_SIGUSR1 ) || !defined( LDAP_SIGUSR2 )
+#undef LDAP_SIGUSR1
+#undef LDAP_SIGUSR2
+
+#      ifndef HAVE_LINUX_THREADS
+#              define LDAP_SIGUSR1     SIGUSR1
+#              define LDAP_SIGUSR2     SIGUSR2
+
+#      else
+               /*
+               LinuxThreads implemented unfortunately uses the only
+               two signals reserved for user applications.  This forces
+               OpenLDAP to use, hopefullly unused, signals reserved
+               for other uses.
+               */
+           
+#              if defined( SIGSTKFLT )
+#                      define LDAP_SIGUSR1     SIGSTKFLT
+#              elif defined ( SIGSYS )
+#                      define LDAP_SIGUSR1     SIGSYS
+#              endif
+
+#              if defined( SIGUNUSED )
+#                      define LDAP_SIGUSR2     SIGUNUSED
+#              elif defined ( SIGINFO )
+#                      define LDAP_SIGUSR2     SIGINFO
+#              elif defined ( SIGEMT )
+#                      define LDAP_SIGUSR2     SIGEMT
+#              endif
+#      endif
+#endif
+
+#ifndef LDAP_SIGCHLD
+#ifdef SIGCHLD
+#define LDAP_SIGCHLD SIGCHLD
+#elif SIGCLD
+#define LDAP_SIGCHLD SIGCLD
+#endif
+#endif
+
+#endif /* _AC_SIGNAL_H */
index b85204297674e778a9a2c2d77ea3785b39338df9..fc1d533b6f6365bf62c7138e6d61c2748934e6ca 100644 (file)
@@ -1,6 +1,5 @@
-/*
- * Generic socket.h
- */
+/* Generic socket.h */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
 #define MAXHOSTNAMELEN  64
 #endif
 
+#undef sock_errno
+#undef sock_errstr
+#define sock_errno()   errno
+#define sock_errstr(e) STRERROR(e)
+
 #ifdef HAVE_WINSOCK
-#      define tcp_close( s )           closesocket( s );
+#      define tcp_close( s )           closesocket( s )
+#      define tcp_read( s, buf, len )  recv( s, buf, len, 0 )
+#      define tcp_write( s, buf, len ) send( s, buf, len, 0 )
 #      define ioctl( s, c, a )         ioctlsocket( (s), (c), (a) )
 #      define ioctl_t                          u_long
 #      define AC_SOCKET_INVALID        ((unsigned int) ~0)
 #define EINPROGRESS WSAEINPROGRESS
 #define ETIMEDOUT      WSAETIMEDOUT
 
+#undef sock_errno
+#undef sock_errstr
+#define        sock_errno()    WSAGetLastError()
+#define        sock_errstr(e)  WSAGetErrorString(e)
+
+extern char* WSAGetErrorString LDAP_P((int));
+
 #elif MACOS
 #      define tcp_close( s )           tcpclose( s )
+#      define tcp_read( s, buf, len )  tcpread( s, buf, len )
+#      define tcp_write( s, buf, len ) tcpwrite( s, buf, len )
 
 #elif DOS
 #      ifdef PCNFS
 #              define tcp_close( s )   close( s )
+#              define tcp_read( s, buf, len )  recv( s, buf, len, 0 )
+#              define tcp_write( s, buf, len ) send( s, buf, len, 0 )
 #      endif /* PCNFS */
 #      ifdef NCSA
 #              define tcp_close( s )   do { netclose( s ); netshut() } while(0)
+#              define tcp_read( s, buf, len )  nread( s, buf, len )
+#              define tcp_write( s, buf, len ) netwrite( s, buf, len )
 #      endif /* NCSA */
 
 #elif HAVE_CLOSESOCKET
 
 #else
 #      define tcp_close( s )           close( s )
+#      define tcp_read( s, buf, len)   read( s, buf, len )
+#      define tcp_write( s, buf, len)  write( s, buf, len )
+
+#ifdef HAVE_PIPE
+/*
+ * Only use pipe() on systems where file and socket descriptors 
+ * are interchangable
+ */
+#define USE_PIPE HAVE_PIPE
+#endif
+
 #endif /* MACOS */
 
 #ifndef ioctl_t
 #ifndef AC_SOCKET_INVALID
 #      define AC_SOCKET_INVALID        (-1)
 #endif
+#ifndef AC_SOCKET_ERROR
+#      define AC_SOCKET_ERROR          (-1)
+#endif
 
 #if !defined( HAVE_INET_ATON ) && !defined( inet_aton )
 #define inet_aton ldap_pvt_inet_aton
diff --git a/include/ac/stdarg.h b/include/ac/stdarg.h
new file mode 100644 (file)
index 0000000..c7b2d46
--- /dev/null
@@ -0,0 +1,24 @@
+/* Generic stdarg.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_STDARG_H
+#define _AC_STDARG_H 1
+
+/* require STDC variable argument support */
+
+#include <stdarg.h>
+
+#ifndef HAVE_STDARG
+#      define HAVE_STDARG 1
+#endif
+
+#endif /* _AC_STDARG_H */
index 6fc2f6a4d083084ce92deb923f5c42ca7f30c0a5..e8037ed496019940a72cb8899bd1a4a0f279ba1f 100644 (file)
@@ -1,4 +1,5 @@
 /* Generic stdlib.h */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
diff --git a/include/ac/string.h b/include/ac/string.h
new file mode 100644 (file)
index 0000000..980511d
--- /dev/null
@@ -0,0 +1,79 @@
+/* Generic string.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_STRING_H
+#define _AC_STRING_H
+
+#ifdef STDC_HEADERS
+#      include <string.h>
+
+#else
+#      ifdef HAVE_STRING_H
+#              include <string.h>
+#      elif HAVE_STRINGS_H
+#              include <strings.h>
+#      endif
+
+#      ifdef HAVE_MEMORY_H
+#              include <memory.h>
+#      endif
+
+#      ifndef HAVE_STRRCHR
+#              undef strchr
+#              define strchr index
+#              undef strrchr
+#              define strrchr rindex
+#      endif
+
+#      ifndef HAVE_MEMCPY
+#              undef memcpy
+#              define memcpy(d, s, n)          ((void) bcopy ((s), (d), (n)))
+#              undef memmove
+#              define memmove(d, s, n)         ((void) bcopy ((s), (d), (n)))
+#      endif
+#endif
+
+/* use ldap_pvt_strtok instead of strtok or strtok_r! */
+LDAP_F(char *) ldap_pvt_strtok LDAP_P((
+       char *str, const char *delim, char **pos ));
+
+LDAP_F(char *) ldap_pvt_strdup LDAP_P((
+       const char * s ));
+
+#ifndef HAVE_STRDUP
+       /* strdup() is missing, declare our own version */
+#      undef strdup
+#      define strdup(s) ldap_pvt_strdup(s)
+#else
+       /* some systems fail to declare strdup */
+       extern char *(strdup)();
+#endif
+
+/*
+ * some systems fail to declare strcasecmp() and strncasecmp()
+ * we need them declared so we can obtain pointers to them
+ */
+extern int (strcasecmp)();
+extern int (strncasecmp)();
+
+#ifndef SAFEMEMCPY
+#      if defined( HAVE_MEMMOVE )
+#              define SAFEMEMCPY( d, s, n )    memmove((d), (s), (n))
+#      elif defined( HAVE_BCOPY )
+#              define SAFEMEMCPY( d, s, n )    bcopy((s), (d), (n))
+#      else
+               /* nothing left but memcpy() */
+#              define SAFEMEMCPY( d, s, n )    memcpy((d), (s), (n))
+#      endif
+#endif
+
+#endif /* _AC_STRING_H */
diff --git a/include/ac/sysexits.h b/include/ac/sysexits.h
new file mode 100644 (file)
index 0000000..8d5df5f
--- /dev/null
@@ -0,0 +1,21 @@
+/* Generic sysexits */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+#ifndef _AC_SYSEXITS_H_
+#define _AC_SYSEXITS_H_
+
+#ifdef HAVE_SYSEXITS_H
+#      include <sysexits.h>
+#else
+#      include <sysexits-compat.h>
+#endif
+
+#endif /* _AC_SYSEXITS_H_ */
diff --git a/include/ac/syslog.h b/include/ac/syslog.h
new file mode 100644 (file)
index 0000000..4015fd9
--- /dev/null
@@ -0,0 +1,33 @@
+/* Generic syslog.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+#ifndef _AC_SYSLOG_H_
+#define _AC_SYSLOG_H_
+
+#if defined( HAVE_SYSLOG_H )
+#include <syslog.h>
+#elif defined ( HAVE_SYS_SYSLOG_H )
+#include <sys/syslog.h>
+#endif
+
+#if defined( LOG_NDELAY ) && defined( LOG_NOWAIT )
+#      define OPENLOG_OPTIONS ( LOG_PID | LOG_NDELAY | LOG_NOWAIT )
+#elif defined( LOG_NDELAY )
+#      define OPENLOG_OPTIONS ( LOG_PID | LOG_NDELAY )
+#elif defined( LOG_NOWAIT )
+#      define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT )
+#elif defined( LOG_PID )
+#      define OPENLOG_OPTIONS ( LOG_PID )
+#else
+#   define OPENLOG_OPTIONS ( 0 )
+#endif
+
+#endif /* _AC_SYSLOG_H_ */
diff --git a/include/ac/termios.h b/include/ac/termios.h
new file mode 100644 (file)
index 0000000..5b548a4
--- /dev/null
@@ -0,0 +1,46 @@
+/* Generic termios.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_TERMIOS_H
+#define _AC_TERMIOS_H
+
+#ifdef HAVE_POSIX_TERMIOS
+#include <termios.h>
+
+#ifdef GCWINSZ_IN_SYS_IOCTL
+#include <sys/ioctl.h>
+#endif
+
+#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))
+
+#elif defined( HAVE_SGTTY_H )
+#include <sgtty.h>
+
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+
+#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))
+
+#endif /* HAVE_SGTTY_H */
+
+#endif /* _AC_TERMIOS_H */
diff --git a/include/ac/time.h b/include/ac/time.h
new file mode 100644 (file)
index 0000000..9f8d303
--- /dev/null
@@ -0,0 +1,28 @@
+/* Generic time.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_TIME_H
+#define _AC_TIME_H
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#elif HAVE_SYS_TIME_H
+# include <sys/time.h>
+# ifdef HAVE_SYS_TIMEB_H
+#  include <sys/timeb.h>
+# endif
+#else
+# include <time.h>
+#endif
+
+#endif /* _AC_TIME_H */
diff --git a/include/ac/unistd.h b/include/ac/unistd.h
new file mode 100644 (file)
index 0000000..7c2fdfc
--- /dev/null
@@ -0,0 +1,65 @@
+/* Generic unistd.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_UNISTD_H
+#define _AC_UNISTD_H
+
+#if HAVE_SYS_TYPES_H
+#      include <sys/types.h>
+#endif
+
+#if HAVE_UNISTD_H
+#      include <unistd.h>
+#endif
+
+/* crypt() may be defined in a separate include file */
+#if HAVE_CRYPT_H
+#      include <crypt.h>
+#else
+       extern char *(crypt)();
+#endif
+
+#ifndef HAVE_GETPASS
+LDAP_F(char*)(getpass) LDAP_P((const char *getpass));
+#else
+LDAP_F(char*)(getpass)();
+#endif
+
+/* getopt() defines may be in separate include file */
+#if HAVE_GETOPT_H
+#      include <getopt.h>
+
+#elif !defined(HAVE_GETOPT)
+       /* no getopt, assume we need getopt-compat.h */
+#      include <getopt-compat.h>
+
+#else
+       /* assume we need to declare these externs */
+       extern char *optarg;
+       extern int optind, opterr, optopt;
+#endif
+
+#ifndef HAVE_TEMPNAM
+       LDAP_F(char *)(tempnam) LDAP_P((
+               const char *tmpdir,
+               const char *prefix));
+#endif
+#ifndef HAVE_MKTEMP
+       LDAP_F(char *)(mktemp) LDAP_P((char *));
+#endif
+
+/* use lutil file locking */
+#define ldap_lockf(x)  lutil_lockf(x)
+#define ldap_unlockf(x)        lutil_unlockf(x)
+#include <lutil_lockf.h>
+
+#endif /* _AC_UNISTD_H */
diff --git a/include/ac/wait.h b/include/ac/wait.h
new file mode 100644 (file)
index 0000000..12bb7d4
--- /dev/null
@@ -0,0 +1,52 @@
+/* Generic wait.h */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _AC_WAIT_H
+#define _AC_WAIT_H
+
+#include <sys/types.h>
+
+#if HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#endif
+
+#define LDAP_HI(s)     (((s) >> 8) & 0377)
+#define LDAP_LO(s)     ((s) & 0377)
+
+/* These should work on non-POSIX UNIX platforms,
+       all bets on off on non-POSIX non-UNIX platforms... */
+#ifndef WIFEXITED
+# define WIFEXITED(s)  (LDAP_LO(s) == 0)
+#endif
+#ifndef WEXITSTATUS
+# define WEXITSTATUS(s) LDAP_HI(s)
+#endif
+#ifndef WIFSIGNALED
+# define WIFSIGNALED(s) (LDAP_LO(s) > 0 && LDAP_HI(s) == 0)
+#endif
+#ifndef WTERMSIG
+# define WTERMSIG(s)   (LDAP_LO(s) & 0177)
+#endif
+#ifndef WIFSTOPPED
+# define WIFSTOPPED(s) (LDAP_LO(s) == 0177 && LDAP_HI(s) != 0)
+#endif
+#ifndef WSTOPSIG
+# define WSTOPSIG(s)   LDAP_HI(s)
+#endif
+
+#ifdef WCONTINUED
+# define WAIT_FLAGS ( WNOHANG | WUNTRACED | WCONTINUED )
+#else
+# define WAIT_FLAGS ( WNOHANG | WUNTRACED )
+#endif
+
+#endif /* _AC_WAIT_H */
index 745cc17d61ee4cfd1f55a40d6cb9c2630fba3253..ae3b44ab65f2da2656bf0d193c8fff89a2682d3b 100644 (file)
@@ -1,5 +1,14 @@
-/* avl.h - avl tree definitions */
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/* Portions
  * Copyright (c) 1993 Regents of the University of Michigan.
  * All rights reserved.
  *
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  */
+/* avl.h - avl tree definitions */
 
 
 #ifndef _AVL
 #define _AVL
 
+#include <ldap_cdefs.h>
+
 /*
  * this structure represents a generic avl tree node.
  */
 
-typedef struct avlnode {
-       caddr_t         avl_data;
-       char            avl_bf;
+LDAP_BEGIN_DECL
+
+typedef struct avlnode Avlnode;
+
+#ifdef AVL_INTERNAL
+struct avlnode {
+       void*           avl_data;
+       signed int              avl_bf;
        struct avlnode  *avl_left;
        struct avlnode  *avl_right;
-} Avlnode;
+};
 
 #define NULLAVL        ((Avlnode *) NULL)
 
 /* balance factor values */
-#define LH     -1
+#define LH     (-1)
 #define EH     0
 #define RH     1
 
 /* avl routines */
-#define avl_getone(x)  (x == 0 ? 0 : (x)->avl_data)
-#define avl_onenode(x) (x == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
-extern int             avl_insert();
-extern caddr_t         avl_delete();
-extern caddr_t         avl_find();
-extern caddr_t         avl_getfirst();
-extern caddr_t         avl_getnext();
-extern int             avl_dup_error();
-extern int             avl_apply();
+#define avl_getone(x)  ((x) == 0 ? 0 : (x)->avl_data)
+#define avl_onenode(x) ((x) == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
+
+#endif /* AVL_INTERNALS */
+
+typedef int            (*AVL_APPLY) LDAP_P((void *, void*));
+typedef int            (*AVL_CMP) LDAP_P((const void*, const void*));
+typedef int            (*AVL_DUP) LDAP_P((void*, void*));
+typedef void   (*AVL_FREE) LDAP_P((void*));
+
+LDAP_F( int )
+avl_free LDAP_P(( Avlnode *root, AVL_FREE dfree ));
+
+LDAP_F( int )
+avl_insert LDAP_P((Avlnode **, void*, AVL_CMP, AVL_DUP));
+
+LDAP_F( void* )
+avl_delete LDAP_P((Avlnode **, void*, AVL_CMP));
+
+LDAP_F( void* )
+avl_find LDAP_P((Avlnode *, const void*, AVL_CMP));
+
+LDAP_F( void* )
+avl_find_lin LDAP_P((Avlnode *, const void*, AVL_CMP));
+
+#ifdef AVL_NONREENTRANT
+LDAP_F( void* )
+avl_getfirst LDAP_P((Avlnode *));
+
+LDAP_F( void* )
+avl_getnext LDAP_P((void));
+#endif
+
+LDAP_F( int )
+avl_dup_error LDAP_P((void*, void*));
+
+LDAP_F( int )
+avl_dup_ok LDAP_P((void*, void*));
+
+LDAP_F( int )
+avl_apply LDAP_P((Avlnode *, AVL_APPLY, void*, int, int));
+
+LDAP_F( int )
+avl_prefixapply LDAP_P((Avlnode *, void*, AVL_CMP, void*, AVL_CMP, void*, int));
 
 /* apply traversal types */
 #define AVL_PREORDER   1
 #define AVL_INORDER    2
 #define AVL_POSTORDER  3
 /* what apply returns if it ran out of nodes */
-#define AVL_NOMORE     -6
+#define AVL_NOMORE     (-6)
 
-typedef int    (*IFP)();
+LDAP_END_DECL
 
 #endif /* _AVL */
index c4e06ef2fe83de567525f3444419259f41b1aa13..ba6f4bd98258bd8c761c26c213be256eb041ae73 100644 (file)
@@ -1,4 +1,14 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/* Portions
  * Copyright (c) 1993, 1994 Regents of the University of Michigan.
  * All rights reserved.
  *
 #ifndef _DISPTMPL_H
 #define _DISPTMPL_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <ldap_cdefs.h>
 
+LDAP_BEGIN_DECL
 
 #define LDAP_TEMPLATE_VERSION  1
 
@@ -123,16 +132,14 @@ struct ldap_tmplitem {
 };
 
 
-#define NULLTMPLITEM   ((struct ldap_tmplitem *)0)
-
 #define LDAP_SET_TMPLITEM_APPDATA( ti, datap ) \
-       (ti)->ti_appdata = (void *)(datap)
+       ( (ti)->ti_appdata = (void *)(datap) )
 
 #define LDAP_GET_TMPLITEM_APPDATA( ti, type )  \
-       (type)((ti)->ti_appdata)
+       ( (type)((ti)->ti_appdata) )
 
 #define LDAP_IS_TMPLITEM_OPTION_SET( ti, option )      \
-       (((ti)->ti_options & option ) != 0 )
+       ( ((ti)->ti_options & (option) ) != 0 )
 
 
 /*
@@ -143,8 +150,6 @@ struct ldap_oclist {
     struct ldap_oclist *oc_next;
 };
 
-#define NULLOCLIST     ((struct ldap_oclist *)0)
-
 
 /*
  * add defaults list
@@ -158,8 +163,6 @@ struct ldap_adddeflist {
     struct ldap_adddeflist     *ad_next;
 };
 
-#define NULLADLIST     ((struct ldap_adddeflist *)0)
-
 
 /*
  * display template global options
@@ -199,16 +202,14 @@ struct ldap_disptmpl {
     struct ldap_disptmpl       *dt_next;
 };
 
-#define NULLDISPTMPL   ((struct ldap_disptmpl *)0)
-
 #define LDAP_SET_DISPTMPL_APPDATA( dt, datap ) \
-       (dt)->dt_appdata = (void *)(datap)
+       ( (dt)->dt_appdata = (void *)(datap) )
 
 #define LDAP_GET_DISPTMPL_APPDATA( dt, type )  \
-       (type)((dt)->dt_appdata)
+       ( (type)((dt)->dt_appdata) )
 
 #define LDAP_IS_DISPTMPL_OPTION_SET( dt, option )      \
-       (((dt)->dt_options & option ) != 0 )
+       ( ((dt)->dt_options & (option) ) != 0 )
 
 #define LDAP_TMPL_ERR_VERSION  1
 #define LDAP_TMPL_ERR_MEM      2
@@ -221,110 +222,96 @@ struct ldap_disptmpl {
 #define LDAP_DTMPL_BUFSIZ      8192
 
 
-#ifndef NEEDPROTOS
-
-typedef int (*writeptype)();
+typedef int (*ldap_writeptype) LDAP_P((
+       void *writeparm, char *p, ber_len_t len ));
 
-int ldap_init_templates();
-int ldap_init_templates_buf();
-void ldap_free_templates();
-struct ldap_disptmpl *ldap_first_disptmpl();
-struct ldap_disptmpl *ldap_next_disptmpl();
-struct ldap_disptmpl *ldap_name2template();
-struct ldap_disptmpl *ldap_oc2template();
-char **ldap_tmplattrs();
-struct ldap_tmplitem *ldap_first_tmplrow();
-struct ldap_tmplitem *ldap_next_tmplrow();
-struct ldap_tmplitem *ldap_first_tmplcol();
-struct ldap_tmplitem *ldap_next_tmplcol();
-int ldap_entry2text_search();
-int ldap_entry2text();
-int ldap_vals2text();
-int ldap_entry2html_search();
-int ldap_entry2html();
-int ldap_vals2html();
+LDAP_F( int )
+ldap_init_templates LDAP_P(( char *file, struct ldap_disptmpl **tmpllistp ));
 
-#else /* !NEEDPROTOS */
+LDAP_F( int )
+ldap_init_templates_buf LDAP_P(( char *buf,
+       ber_len_t buflen,
+       struct ldap_disptmpl **tmpllistp ));
 
-typedef int (*writeptype)( void *writeparm, char *p, int len );
+LDAP_F( void )
+ldap_free_templates LDAP_P(( struct ldap_disptmpl *tmpllist ));
 
-LDAPFUNCDECL int
-ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp );
+LDAP_F( struct ldap_disptmpl * )
+ldap_first_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist ));
 
-LDAPFUNCDECL int
-ldap_init_templates_buf( char *buf, long buflen,
-       struct ldap_disptmpl **tmpllistp );
+LDAP_F( struct ldap_disptmpl * )
+ldap_next_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist,
+       struct ldap_disptmpl *tmpl ));
 
-LDAPFUNCDECL void
-ldap_free_templates( struct ldap_disptmpl *tmpllist );
+LDAP_F( struct ldap_disptmpl * )
+ldap_name2template LDAP_P(( char *name,
+       struct ldap_disptmpl *tmpllist ));
 
-LDAPFUNCDECL struct ldap_disptmpl *
-ldap_first_disptmpl( struct ldap_disptmpl *tmpllist );
+LDAP_F( struct ldap_disptmpl * )
+ldap_oc2template LDAP_P(( char **oclist,
+       struct ldap_disptmpl *tmpllist ));
 
-LDAPFUNCDECL struct ldap_disptmpl *
-ldap_next_disptmpl( struct ldap_disptmpl *tmpllist,
-       struct ldap_disptmpl *tmpl );
+LDAP_F( char ** )
+ldap_tmplattrs LDAP_P(( struct ldap_disptmpl *tmpl,
+       char **includeattrs,
+       int exclude,
+       unsigned long syntaxmask ));
 
-LDAPFUNCDECL struct ldap_disptmpl *
-ldap_name2template( char *name, struct ldap_disptmpl *tmpllist );
+LDAP_F( struct ldap_tmplitem * )
+ldap_first_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl ));
 
-LDAPFUNCDECL struct ldap_disptmpl *
-ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist );
+LDAP_F( struct ldap_tmplitem * )
+ldap_next_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl,
+       struct ldap_tmplitem *row ));
 
-LDAPFUNCDECL char **
-ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, int exclude,
-        unsigned long syntaxmask );
+LDAP_F( struct ldap_tmplitem * )
+ldap_first_tmplcol LDAP_P(( struct ldap_disptmpl *tmpl,
+       struct ldap_tmplitem *row ));
 
-LDAPFUNCDECL struct ldap_tmplitem *
-ldap_first_tmplrow( struct ldap_disptmpl *tmpl );
+LDAP_F( struct ldap_tmplitem * )
+ldap_next_tmplcol LDAP_P(( struct ldap_disptmpl *tmpl,
+       struct ldap_tmplitem *row,
+       struct ldap_tmplitem *col ));
 
-LDAPFUNCDECL struct ldap_tmplitem *
-ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
-
-LDAPFUNCDECL struct ldap_tmplitem *
-ldap_first_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
-
-LDAPFUNCDECL struct ldap_tmplitem *
-ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row,
-       struct ldap_tmplitem *col );
-
-LDAPFUNCDECL int
-ldap_entry2text( LDAP *ld, char *buf, LDAPMessage *entry,
+LDAP_F( int )
+ldap_entry2text LDAP_P(( LDAP *ld,
+       char *buf, LDAPMessage *entry,
        struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
-       writeptype writeproc, void *writeparm, char *eol, int rdncount,
-       unsigned long opts );
-
-LDAPFUNCDECL int
-ldap_vals2text( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
-       unsigned long syntaxid, writeptype writeproc, void *writeparm,
-       char *eol, int rdncount );
-
-LDAPFUNCDECL int
-ldap_entry2text_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
+       ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount,
+       unsigned long opts ));
+
+LDAP_F( int )
+ldap_vals2text LDAP_P(( LDAP *ld,
+       char *buf, char **vals, char *label, int labelwidth,
+       unsigned long syntaxid, ldap_writeptype writeproc, void *writeparm,
+       char *eol, int rdncount ));
+
+LDAP_F( int )
+ldap_entry2text_search LDAP_P(( LDAP *ld,
+       char *dn, char *base, LDAPMessage *entry,
        struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
-       writeptype writeproc, void *writeparm, char *eol, int rdncount,
-       unsigned long opts );
+       ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount,
+       unsigned long opts ));
 
-LDAPFUNCDECL int
-ldap_entry2html( LDAP *ld, char *buf, LDAPMessage *entry,
+LDAP_F( int )
+ldap_entry2html LDAP_P(( LDAP *ld,
+       char *buf, LDAPMessage *entry,
        struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
-       writeptype writeproc, void *writeparm, char *eol, int rdncount,
-       unsigned long opts, char *urlprefix, char *base );
-
-LDAPFUNCDECL int
-ldap_vals2html( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
-       unsigned long syntaxid, writeptype writeproc, void *writeparm,
-       char *eol, int rdncount, char *urlprefix );
-
-LDAPFUNCDECL int
-ldap_entry2html_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
+       ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount,
+       unsigned long opts, char *urlprefix, char *base ));
+
+LDAP_F( int )
+ldap_vals2html LDAP_P(( LDAP *ld,
+       char *buf, char **vals, char *label, int labelwidth,
+       unsigned long syntaxid, ldap_writeptype writeproc, void *writeparm,
+       char *eol, int rdncount, char *urlprefix ));
+
+LDAP_F( int )
+ldap_entry2html_search LDAP_P(( LDAP
+       *ld, char *dn, char *base, LDAPMessage *entry,
        struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
-       writeptype writeproc, void *writeparm, char *eol, int rdncount,
-       unsigned long opts, char *urlprefix );
-#endif /* !NEEDPROTOS */
-
+       ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount,
+       unsigned long opts, char *urlprefix ));
 
-#ifdef __cplusplus
-}
-#endif
+LDAP_END_DECL
 #endif /* _DISPTMPL_H */
diff --git a/include/getopt-compat.h b/include/getopt-compat.h
new file mode 100644 (file)
index 0000000..14b2a2f
--- /dev/null
@@ -0,0 +1,32 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/*
+ * getopt(3) declarations
+ */
+#ifndef _GETOPT_COMPAT_H
+#define _GETOPT_COMPAT_H
+
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
+
+extern char *optarg;
+extern int optind, opterr, optopt;
+
+LDAP_F( int )
+getopt LDAP_P((
+       int,
+       char * const [],
+       const char *));
+
+LDAP_END_DECL
+
+#endif /* _GETOPT_COMPAT_H */
index 667fc26578b356a4e26037916c256ddbd266f57e..229e97e55c7046a83f7825075b2c60850a095d59 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
diff --git a/include/lber_pvt.h b/include/lber_pvt.h
new file mode 100644 (file)
index 0000000..7e26591
--- /dev/null
@@ -0,0 +1,38 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/*
+ * lber_pvt.h - Header for ber_pvt_ functions. These are meant to be used
+ *             by the OpenLDAP distribution only.
+ */
+
+#ifndef _LBER_PVT_H
+#define _LBER_PVT_H 1
+
+#include <lber.h>
+
+LDAP_BEGIN_DECL
+
+/*
+ * bprint.c
+ */
+LDAP_F( BER_LOG_PRINT_FN ) ber_pvt_log_print;
+
+LDAP_F( int )
+ber_pvt_log_printf LDAP_P((
+       int errlvl,
+       int loglvl,
+       const char *fmt,
+       ... )) LDAP_GCCATTR((format(printf, 3, 4)));
+
+LDAP_END_DECL
+
+#endif
+
diff --git a/include/lber_types.h.in b/include/lber_types.h.in
new file mode 100644 (file)
index 0000000..6abba8f
--- /dev/null
@@ -0,0 +1,31 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/*
+ * LBER types
+ */
+
+#ifndef _LBER_TYPES_H
+#define _LBER_TYPES_H
+
+/* LBER boolean, enum, integers - 32 bits or larger*/
+#undef LBER_INT_T
+
+/* LBER tags - 32 bits or larger */
+#undef LBER_TAG_T
+
+/* LBER socket descriptor */
+#undef LBER_SOCKET_T
+
+/* LBER lengths - 32 bits or larger*/
+#undef LBER_LEN_T
+
+#endif /* _LBER_TYPES_H */
diff --git a/include/lber_types.nt b/include/lber_types.nt
new file mode 100644 (file)
index 0000000..884188e
--- /dev/null
@@ -0,0 +1,44 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/*
+ * LBER types for Windows NT
+ */
+
+#ifndef _LBER_TYPES_H_NT
+#define _LBER_TYPES_H_NT
+
+/*
+ * NT types:
+ *
+ *     bitsof(short) == 2
+ *     bitsof(int)     == 4
+ *     bitsof(long) == 4
+ *
+ *  typedef unsigned int size_t;
+ *     typedef unsigned int SOCKET;
+ *
+ *     we use native C types to avoid sucking in system headers
+ */
+
+/* LBER boolean, enum, integers - 32 bits or larger*/
+#define LBER_INT_T     int
+
+/* LBER tags - 32 bits or larger */
+#define LBER_TAG_T     long
+
+/* LBER socket descriptor */
+#define LBER_SOCKET_T  unsigned int
+
+/* LBER lengths - 32 bits or larger*/
+#define LBER_LEN_T             int
+
+#endif /* _LBER_TYPES_H_NT */
index 36221c1c1a4e6d43199345c47df0bc1a0b6e687f..8dbbd1b1ef673e7bf66171cdc3b50bd004d8ebfa 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
@@ -167,7 +168,7 @@ typedef struct ldapcontrol {
 #define LDAP_CHASE_SUBORDINATE_REFERRALS       0x0020
 #define LDAP_CHASE_EXTERNAL_REFERRALS  0x0040
 
-#define LDAP_CONTROL_MANAGEDSAIT "2.16.16.840.1.113730.3.4.2"
+#define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.2.6"
 
 /* LDAP Unsolicited Notifications */
 #define        LDAP_NOTICE_DISCONNECT  "1.3.6.1.4.1.1466.20036"
@@ -869,6 +870,27 @@ ldap_modify_s LDAP_P((
  * in modrdn.c:
  */
 LDAP_F( int )
+ldap_rename LDAP_P((
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *newrdn,
+       int deleteoldrdn,
+       LDAP_CONST char *newSuperior,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls,
+       int *msgidp ));
+
+LDAP_F( int )
+ldap_rename_s LDAP_P((
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *newrdn,
+       int deleteoldrdn,
+       LDAP_CONST char *newSuperior,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls ));
+
+LDAP_F( int )
 ldap_rename_ext LDAP_P((
        LDAP                    *ld,
        LDAP_CONST char *dn,
@@ -1034,38 +1056,38 @@ ldap_add_result_entry LDAP_P((
 /*
  * in getdn.c
  */
-LDAP_F( char *)
+LDAP_F( char * )
 ldap_get_dn LDAP_P((
        LDAP *ld,
        LDAPMessage *entry ));
 
-LDAP_F( char *)
+LDAP_F( char * )
 ldap_dn2ufn LDAP_P((
        LDAP_CONST char *dn ));
 
-LDAP_F( char **)
+LDAP_F( char ** )
 ldap_explode_dn LDAP_P((
        LDAP_CONST char *dn,
        int notypes ));
 
-LDAP_F( char **)
+LDAP_F( char ** )
 ldap_explode_rdn LDAP_P((
        LDAP_CONST char *rdn,
        int notypes ));
 
-LDAP_F( char *)
-ldap_parent_dn LDAP_P((        /* new (from slapd) */
+LDAP_F( char * )
+ldap_parent_dn LDAP_P((
        LDAP_CONST char *dn ));
 
-LDAP_F( char *)
-ldap_relative_dn LDAP_P((      /* new (from slapd) */
+LDAP_F( char * )
+ldap_relative_dn LDAP_P((
        LDAP_CONST char *dn ));
 
-LDAP_F( char *)
-ldap_normalize_dn LDAP_P((     /* new (from slapd) */
+LDAP_F( char * )
+ldap_normalize_dn LDAP_P((
        LDAP_CONST char *dn ));
 
-LDAP_F( char **)
+LDAP_F( char ** )
 ldap_explode_dns LDAP_P(( /* deprecated */
        LDAP_CONST char *dn ));
 
diff --git a/include/ldap_cdefs.h b/include/ldap_cdefs.h
new file mode 100644 (file)
index 0000000..dc5722d
--- /dev/null
@@ -0,0 +1,78 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/* LDAP C Defines */
+
+#ifndef _LDAP_CDEFS_H
+#define _LDAP_CDEFS_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+#      define LDAP_BEGIN_DECL  extern "C" {
+#      define LDAP_END_DECL    }
+#else
+#      define LDAP_BEGIN_DECL  /* begin declarations */
+#      define LDAP_END_DECL    /* end declarations */
+#endif
+
+#if !defined(__NO_PROTOTYPES) && ( defined(__NEED_PROTOTYPES) || \
+       defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) )
+
+       /* ANSI C or C++ */
+#      define LDAP_P(protos)   protos
+#      define LDAP_CONCAT1(x,y)        x ## y
+#      define LDAP_CONCAT(x,y) LDAP_CONCAT1(x,y)
+#      define LDAP_STRING(x)   #x /* stringify without expanding x */
+#      define LDAP_XSTRING(x)  LDAP_STRING(x) /* expand x, then stringify */
+
+#ifndef LDAP_CONST
+#      define LDAP_CONST       const
+#endif
+
+#else /* no prototypes */
+
+       /* traditional C */
+#      define LDAP_P(protos)   ()
+#      define LDAP_CONCAT(x,y) x/**/y
+#      define LDAP_STRING(x)   "x"
+
+#ifndef LDAP_CONST
+#      define LDAP_CONST       /* no const */
+#endif
+
+#endif /* no prototypes */
+
+#if _WIN32 && _DLL
+#      define LDAP_F_IMPORT    extern __declspec( dllimport )
+#      define LDAP_F_EXPORT    extern __declspec( dllexport )
+#else
+#      define LDAP_F_IMPORT    extern
+#      define LDAP_F_EXPORT    extern
+#endif
+
+#if (__GNUC__) * 1000 + (__GNUC_MINOR__) >= 2006
+#      define LDAP_GCCATTR(attrs)      __attribute__(attrs)
+#else
+#      define LDAP_GCCATTR(attrs)
+#endif
+
+
+#endif /* _LDAP_CDEFS_H */
+
+/* purposely allow these to be redefined */
+#ifndef LDAP_F_PRE
+#      define LDAP_F_PRE       LDAP_F_IMPORT
+#endif
+#ifndef LDAP_F_POST
+#      define LDAP_F_POST      /* no post */
+#endif
+#ifndef LDAP_F
+#define LDAP_F(type)   LDAP_F_PRE type LDAP_F_POST
+#endif
+
diff --git a/include/ldap_config.h.in b/include/ldap_config.h.in
new file mode 100644 (file)
index 0000000..a7d0f01
--- /dev/null
@@ -0,0 +1,56 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/*
+ * This file works in confunction with OpenLDAP configure system.
+ * If you do no like the values below, adjust your configure options.
+ */
+
+#ifndef _LDAP_CONFIG_H
+#define _LDAP_CONFIG_H
+
+/* directory separator */
+#ifndef LDAP_DIRSEP
+#define LDAP_DIRSEP "/"
+#endif
+
+/* directories */
+#ifndef LDAP_BINDIR
+#define LDAP_BINDIR                    "%BINDIR%"
+#endif
+#ifndef LDAP_SBINDIR
+#define LDAP_SBINDIR           "%SBINDIR%"
+#endif
+#ifndef LDAP_DATADIR
+#define LDAP_DATADIR           "%DATADIR%"
+#endif
+#ifndef LDAP_SYSCONFDIR
+#define LDAP_SYSCONFDIR                "%SYSCONFDIR%"
+#endif
+#ifndef LDAP_LIBEXECDIR
+#define LDAP_LIBEXECDIR                "%LIBEXECDIR%"
+#endif
+#ifndef LDAP_RUNDIR
+#define LDAP_RUNDIR                    "%RUNDIR%"
+#endif
+
+/* command locations */
+#ifndef LDAP_EDITOR
+#define LDAP_EDITOR                    "%EDITOR%"
+#endif
+#ifndef LDAP_FINGER
+#define LDAP_FINGER                    "%FINGER%"
+#endif
+#ifndef LDAP_SENDMAIL
+#define LDAP_SENDMAIL          "%SENDMAIL%"
+#endif
+
+#endif /* _LDAP_CONFIG_H */
diff --git a/include/ldap_config.nt b/include/ldap_config.nt
new file mode 100644 (file)
index 0000000..ce3597a
--- /dev/null
@@ -0,0 +1,59 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/*
+ * This file works in confunction with OpenLDAP configure system.
+ * If you do no like the values below, adjust your configure options.
+ */
+
+#ifndef _LDAP_CONFIG_H
+#define _LDAP_CONFIG_H
+
+/* directory separator */
+#ifndef LDAP_DIRSEP
+#define LDAP_DIRSEP "\\"
+#endif
+
+/* directories */
+#ifndef LDAP_PREFIX
+#define LDAP_PREFIX                    "C:\\OpenLDAP"
+#endif
+#ifndef LDAP_BINDIR
+#define LDAP_BINDIR                    LDAP_PREFIX "\\bin"
+#endif
+#ifndef LDAP_SBINDIR
+#define LDAP_SBINDIR           LDAP_PREFIX "\\sbin"
+#endif
+#ifndef LDAP_DATADIR
+#define LDAP_DATADIR           LDAP_PREFIX "\\share"
+#endif
+#ifndef LDAP_SYSCONFDIR
+#define LDAP_SYSCONFDIR                LDAP_PREFIX "\\sysconf"
+#endif
+#ifndef LDAP_LIBEXECDIR
+#define LDAP_LIBEXECDIR                LDAP_PREFIX "\\libexec"
+#endif
+#ifndef LDAP_RUNDIR
+#define LDAP_RUNDIR                    LDAP_PREFIX "\\run"
+#endif
+
+/* command locations */
+#ifndef LDAP_EDITOR
+#define LDAP_EDITOR                    "%EDITOR%"
+#endif
+#ifndef LDAP_FINGER
+#define LDAP_FINGER                    "%FINGER%"
+#endif
+#ifndef LDAP_SENDMAIL
+#define LDAP_SENDMAIL          "%SENDMAIL%"
+#endif
+
+#endif /* _LDAP_CONFIG_H */
diff --git a/include/ldap_defaults.h b/include/ldap_defaults.h
new file mode 100644 (file)
index 0000000..0b27fff
--- /dev/null
@@ -0,0 +1,221 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/* Portions
+ * Copyright (c) 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.
+ */
+
+/*
+ * This file controls defaults for OpenLDAP package.
+ * You should not change any of these settings.
+ */
+
+#ifndef _LDAP_DEFAULTS_H
+#define _LDAP_DEFAULTS_H
+
+
+#include <ldap_config.h>
+
+#define LDAP_CONF_FILE  LDAP_SYSCONFDIR LDAP_DIRSEP "ldap.conf"
+#define LDAP_USERRC_FILE "ldaprc"
+#define LDAP_ENV_PREFIX "LDAP"
+
+
+/*********************************************************************
+ *                                                                   *
+ * You probably do not need to edit anything below this point        *
+ *                                                                   *
+ *********************************************************************/
+
+/*
+ * SHARED DEFINITIONS - other things you can change
+ */
+       /* default attribute to use when sorting entries, NULL => sort by DN */
+#define SORT_ATTR      NULL
+       /* default count of DN components to show in entry displays */
+#define DEFAULT_RDNCOUNT       2
+       /* default config file locations */
+#define FILTERFILE     LDAP_SYSCONFDIR LDAP_DIRSEP "ldapfilter.conf"
+#define TEMPLATEFILE   LDAP_SYSCONFDIR LDAP_DIRSEP "ldaptemplates.conf"
+#define SEARCHFILE     LDAP_SYSCONFDIR LDAP_DIRSEP "ldapsearchprefs.conf"
+#define FRIENDLYFILE   LDAP_DATADIR LDAP_DIRSEP "ldapfriendly"
+
+/*
+ * FINGER DEFINITIONS
+ */
+       /* banner to print */
+#define FINGER_BANNER          "OpenLDAP Finger Service...\r\n"
+       /* who to report errors to */
+#define FINGER_ERRORS          "System Administrator"
+       /* what to say if no matches are found */
+#define FINGER_NOMATCH         "Search failed to find anything.\r\n"
+       /* what to say if the service may be unavailable */
+#define FINGER_UNAVAILABLE     \
+"The directory service may be temporarily unavailable.\r\n\
+Please try again later.\r\n"
+       /* printed if a match has no email address - for disptmp default */
+#define FINGER_NOEMAIL1        "None registered in this service."
+#define FINGER_NOEMAIL2        NULL
+#define FINGER_NOEMAIL { FINGER_NOEMAIL1, FINGER_NOEMAIL2, NULL }
+       /* maximum number of matches returned */
+#define FINGER_SIZELIMIT       50
+       /* max number of hits displayed in full before a list is presented */
+#define FINGER_LISTLIMIT       1
+       /* what to exec for "finger @host" */
+#define FINGER_CMD             LDAP_FINGER
+       /* how to treat aliases when searching */
+#define FINGER_DEREF           LDAP_DEREF_FINDING
+       /* attribute to use when sorting results */
+#define FINGER_SORT_ATTR       SORT_ATTR
+       /* enable ufn support */
+#define FINGER_UFN
+       /* timeout for searches */
+#define FINGER_TIMEOUT         60
+       /* number of DN components to show in entry displays */
+#define FINGER_RDNCOUNT                DEFAULT_RDNCOUNT        
+
+/*
+ * GO500 GOPHER GATEWAY DEFINITIONS
+ */
+       /* port on which to listen */
+#define GO500_PORT     5555
+       /* how to handle aliases */
+#define GO500_DEREF    LDAP_DEREF_FINDING
+       /* attribute to use when sorting results */
+#define GO500_SORT_ATTR        SORT_ATTR
+       /* timeout for searches */
+#define GO500_TIMEOUT  180
+       /* enable ufn support */
+#define GO500_UFN
+       /*
+        * only set and uncomment this if your hostname() does not return
+        * a fully qualified hostname
+        */
+/* #define GO500_HOSTNAME      "fully.qualified.hostname.here" */
+       /* number of DN components to show in entry displays */
+#define GO500_RDNCOUNT         DEFAULT_RDNCOUNT        
+
+/*
+ * GO500GW GOPHER GATEWAY DEFINITIONS
+ */
+       /* where the helpfile lives */
+#define GO500GW_HELPFILE       LDAP_DATADIR LDAP_DIRSEP "go500gw.help"
+       /* port on which to listen */
+#define GO500GW_PORT           7777
+       /* timeout on all searches */
+#define GO500GW_TIMEOUT                180
+       /* enable ufn support */
+#define GO500GW_UFN
+       /* attribute to use when sorting results */
+#define GO500GW_SORT_ATTR      SORT_ATTR
+       /*
+        * only set and uncomment this if your hostname() does not return
+        * a fully qualified hostname
+        */
+/* #define GO500GW_HOSTNAME    "fully.qualified.hostname.here" */
+       /* number of DN components to show in entry displays */
+#define GO500GW_RDNCOUNT       DEFAULT_RDNCOUNT        
+
+/*
+ * RCPT500 MAIL RESPONDER GATEWAY DEFINITIONS
+ */
+       /* where the helpfile lives */
+#define RCPT500_HELPFILE       LDAP_DATADIR LDAP_DIRSEP "rcpt500.help"
+       /* maximum number of matches returned */
+#define RCPT500_SIZELIMIT      50
+       /* address replies will appear to come from */
+#define RCPT500_FROM           "\"Directory Query Program\" <Dir-Query>"
+       /* command that will accept an RFC822 message text on standard
+          input, and send it.  sendmail -t does this nicely. */
+#define RCPT500_PIPEMAILCMD    LDAP_SENDMAIL " -t"
+       /* attribute to use when sorting results */
+#define RCPT500_SORT_ATTR      SORT_ATTR
+       /* max number of hits displayed in full before a list is presented */
+#define RCPT500_LISTLIMIT      1
+       /* enable ufn support */
+#define RCPT500_UFN
+       /* number of DN components to show in entry displays */
+#define RCPT500_RDNCOUNT       DEFAULT_RDNCOUNT        
+
+/*
+ * MAIL500 MAILER DEFINITIONS
+ */
+       /* max number of ambiguous matches reported */
+#define MAIL500_MAXAMBIGUOUS   10
+       /* max subscribers allowed (size limit when searching for them ) */
+#define MAIL500_MAXGROUPMEMBERS        LDAP_NO_LIMIT
+       /* timeout for all searches */
+#define MAIL500_TIMEOUT                180
+       /* sendmail location - mail500 needs to exec this */
+#define MAIL500_SENDMAIL       LDAP_SENDMAIL
+
+/*
+ * UD DEFINITIONS
+ */
+       /* ud configuration file */
+#define UD_CONFIG_FILE         LDAP_SYSCONFDIR LDAP_DIRSEP "ud.conf"
+       /* default editor */
+#define UD_DEFAULT_EDITOR      LDAP_EDITOR
+       /* default bbasename of user config file */
+#define UD_USER_CONFIG_FILE    ".udrc"
+       /* default base where groups are created */
+#define UD_WHERE_GROUPS_ARE_CREATED    ""
+       /* default base below which all groups live */
+#define UD_WHERE_ALL_GROUPS_LIVE       ""
+
+/*
+ * FAX500 DEFINITIONS
+ */
+       /* how long to wait for searches */
+#define FAX_TIMEOUT            180
+       /* maximum number of ambiguous matches reported */
+#define FAX_MAXAMBIGUOUS       10
+       /* maximum number of members allowed */
+#define FAX_MAXMEMBERS         LDAP_NO_LIMIT
+       /* program to send mail */
+#define FAX_SENDMAIL           LDAP_SENDMAIL
+
+/*
+ * RP500 DEFINITIONS
+ */
+       /* prefix to add to non-fully-qualified numbers */
+#define RP_PHONEPREFIX ""
+
+/*
+ * SLAPD DEFINITIONS
+ */
+       /* location of the default slapd config file */
+#define SLAPD_DEFAULT_CONFIGFILE       LDAP_SYSCONFDIR LDAP_DIRSEP "slapd.conf"
+       /* default max deref depth for aliases */
+#define SLAPD_DEFAULT_MAXDEREFDEPTH    15      
+       /* default sizelimit on number of entries from a search */
+#define SLAPD_DEFAULT_SIZELIMIT                500
+       /* default timelimit to spend on a search */
+#define SLAPD_DEFAULT_TIMELIMIT                3600
+       /* minimum max ids that a single index entry can map to in ldbm */
+#define SLAPD_LDBM_MIN_MAXIDS          4000
+
+/* the following DNs must be normalized and in uppercase! */
+       /* dn of the special "monitor" entry */
+#define SLAPD_MONITOR_DN               "CN=MONITOR"
+       /* dn of the special "config" entry */
+#define SLAPD_CONFIG_DN                        "CN=CONFIG"
+       /* dn of the special "schema" entry */
+#define SLAPD_SCHEMA_DN                        "CN=SCHEMA"
+
+#endif /* _LDAP_CONFIG_H */
diff --git a/include/ldap_features.h.in b/include/ldap_features.h.in
new file mode 100644 (file)
index 0000000..62c3b5a
--- /dev/null
@@ -0,0 +1,56 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/* 
+ * LDAP Features
+ */
+#ifndef _LDAP_FEATURES_H
+#define _LDAP_FEATURES_H 1
+
+/*
+** OpenLDAP reentrancy/thread-safeness should be dynamically
+** checked using ldap_get_option().
+**
+** The -lldap implementation may or may not be:
+**             LDAP_API_FEATURE_THREAD_SAFE
+**
+** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_REENTRANT can
+** be used to determine if -lldap is LDAP_API_FEATURE_THREAD_SAFE at
+** compile time.
+**
+** The -lldap_r implementation is always THREAD_SAFE but
+** may also be:
+**             LDAP_API_FEATURE_SESSION_THREAD_SAFE
+**             LDAP_API_FEATURE_OPERATION_THREAD_SAFE
+**
+** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
+** can be used to determine if -lldap_r is available at compile
+** time.  You must define LDAP_THREAD_SAFE if and only if you
+** link with -lldap_r.
+**
+** If you fail to define LDAP_THREAD_SAFE when linking with
+** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap,
+** provided header definations and declarations may be incorrect.
+**
+*/
+
+/* is -lldap reentrant or not */
+#undef LDAP_API_FEATURE_X_OPENLDAP_REENTRANT
+
+/* is threadsafe version of -lldap (ie: -lldap_r) *available* or not */
+#undef LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
+
+/* LDAP v2 DNS */
+#undef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
+
+/* LDAP v2 Referrals */
+#undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
+
+#endif /* LDAP_FEATURES */
diff --git a/include/ldap_features.nt b/include/ldap_features.nt
new file mode 100644 (file)
index 0000000..29cd0a5
--- /dev/null
@@ -0,0 +1,56 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/* 
+ * LDAP Features
+ */
+#ifndef _LDAP_FEATURES_H
+#define _LDAP_FEATURES_H 1
+
+/*
+** OpenLDAP reentrancy/thread-safeness should be dynamically
+** checked using ldap_get_option().
+**
+** The -lldap implementation may or may not be:
+**             LDAP_API_FEATURE_THREAD_SAFE
+**
+** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_REENTRANT can
+** be used to determine if -lldap is LDAP_API_FEATURE_THREAD_SAFE at
+** compile time.
+**
+** The -lldap_r implementation is always THREAD_SAFE but
+** may also be:
+**             LDAP_API_FEATURE_SESSION_THREAD_SAFE
+**             LDAP_API_FEATURE_OPERATION_THREAD_SAFE
+**
+** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
+** can be used to determine if -lldap_r is availalbe at compile
+** time.  You must define LDAP_THREAD_SAFE if and only if you
+** link with -lldap_r.
+**
+** If you fail to define LDAP_THREAD_SAFE when linking with
+** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap,
+** provided header definations and declarations may be incorrect.
+**
+*/
+
+/* is -lldap reentrant or not */
+/* #undef LDAP_API_FEATURE_X_OPENLDAP_REENTRANT */
+
+/* is threadsafe version of -lldap (ie: -lldap_r) *available* or not */
+#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE LDAP_VENDOR_VERSION
+
+/* LDAP v2 DNS */
+/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
+
+/* LDAP v2 Referrals */
+#define LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS LDAP_VENDOR_VERSION
+
+#endif /* LDAP_FEATURES */
diff --git a/include/ldap_log.h b/include/ldap_log.h
new file mode 100644 (file)
index 0000000..dfb2e7a
--- /dev/null
@@ -0,0 +1,83 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/* Portions
+ * Copyright (c) 1990 Regents of the University of Michigan.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of Michigan at Ann Arbor. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+
+#ifndef _LDAP_LOG_H
+#define _LDAP_LOG_H
+
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
+
+#define LDAP_DEBUG_TRACE       0x0001
+#define LDAP_DEBUG_PACKETS     0x0002
+#define LDAP_DEBUG_ARGS                0x0004
+#define LDAP_DEBUG_CONNS       0x0008
+#define LDAP_DEBUG_BER         0x0010
+#define LDAP_DEBUG_FILTER      0x0020
+#define LDAP_DEBUG_CONFIG      0x0040
+#define LDAP_DEBUG_ACL         0x0080
+#define LDAP_DEBUG_STATS       0x0100
+#define LDAP_DEBUG_STATS2      0x0200
+#define LDAP_DEBUG_SHELL       0x0400
+#define LDAP_DEBUG_PARSE       0x0800
+
+#define LDAP_DEBUG_DEPRECATED  0x1000
+#define LDAP_DEBUG_NONE                0x8000
+#define LDAP_DEBUG_ANY         -1
+
+/* debugging stuff */
+#ifdef LDAP_DEBUG
+
+#ifndef ldap_debug
+extern int     ldap_debug;
+#endif /* !ldap_debug */
+
+#ifdef LDAP_SYSLOG
+extern int     ldap_syslog;
+extern int     ldap_syslog_level;
+#endif /* LDAP_SYSLOG */
+
+/* this doesn't below as part of ldap.h */
+#ifdef LDAP_SYSLOG
+#define Debug( level, fmt, arg1, arg2, arg3 )  \
+       do { \
+               lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
+               if ( ldap_syslog & (level) ) \
+                       syslog( ldap_syslog_level, (fmt), (arg1), (arg2), (arg3) ); \
+       } while ( 0 )
+
+#else
+#define Debug( level, fmt, arg1, arg2, arg3 ) \
+       lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) )
+#endif
+
+#else /* LDAP_DEBUG */
+#define Debug( level, fmt, arg1, arg2, arg3 )
+#endif /* LDAP_DEBUG */
+
+LDAP_F(void) lutil_debug LDAP_P((
+       int debug, int level,
+       const char* fmt, ... )) LDAP_GCCATTR((format(printf, 3, 4)));
+
+LDAP_END_DECL
+
+#endif /* _LDAP_LOG_H */
index 3014e217ee0c32a7c8dcea437c358ba3cfc6a26d..2b20ed49298e7e524d89ed76cd2ef7c784d18c17 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
@@ -16,6 +17,7 @@
 #define _LDAP_PVT_H 1
 
 #include <ldap_cdefs.h>
+#include <lber.h>                              /* get ber_slen_t */
 
 LDAP_BEGIN_DECL
 
@@ -77,6 +79,41 @@ ldap_str2charray LDAP_P((
 void ldap_pvt_hex_unescape LDAP_P(( char *s ));
 int ldap_pvt_unhex( int c );
 
+/* these macros assume 'x' is an ASCII x */
+#define LDAP_DNSEPARATOR(c)    ((c) == ',' || (c) == ';')
+#define LDAP_SEPARATOR(c)      ((c) == ',' || (c) == ';' || (c) == '+')
+#define LDAP_SPACE(c)          ((c) == ' ' || (c) == '\n')
+
+#define LDAP_LOWER(c)          ( (c) >= 'a' && (c) <= 'z' )
+#define LDAP_UPPER(c)          ( (c) >= 'A' && (c) <= 'Z' )
+#define LDAP_ALPHA(c)          ( LDAP_LOWER(c) || LDAP_UPPER(c) )
+#define LDAP_DIGIT(c)          ( (c) >= '0' && (c) <= '9' )
+#define LDAP_ALNUM(c)          ( LDAP_ALPHA(c) || LDAP_DIGIT(c) )
+
+#define LDAP_LEADKEYCHAR(c)    ( LDAP_ALPHA(c) )
+#define LDAP_KEYCHAR(c)                ( LDAP_ALNUM(c) || (c) == '-' )
+#define LDAP_LEADOIDCHAR(c)    ( LDAP_DIGIT(c) )
+#define LDAP_OIDCHAR(c)                ( LDAP_DIGIT(c) || (c) == '.' )
+
+#define LDAP_LEADATTRCHAR(c)   ( LDAP_LEADKEYCHAR(c) || LDAP_LEADOIDCHAR(c) )
+#define LDAP_ATTRCHAR(c)               ( LDAP_KEYCHAR((c)) || (c) == '.' )
+
+#define LDAP_NEEDSESCAPE(c)    ((c) == '\\' || (c) == '"')
+
+/* search.c */
+LDAP_F( char * )
+ldap_pvt_find_wildcard LDAP_P((        char *s ));
+
+LDAP_F( ber_slen_t )
+ldap_pvt_filter_value_unescape LDAP_P(( char *filter ));
+
+/* string.c */
+LDAP_F( char * )
+ldap_pvt_str2upper LDAP_P(( char *str ));
+
+LDAP_F( char * )
+ldap_pvt_str2lower LDAP_P(( char *str ));
+
 LDAP_END_DECL
 
 #endif
diff --git a/include/ldap_pvt_thread.h b/include/ldap_pvt_thread.h
new file mode 100644 (file)
index 0000000..a006a2e
--- /dev/null
@@ -0,0 +1,308 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/* ldap_pvt_thread.h - ldap threads header file NG */
+
+#ifndef _LDAP_PVT_THREAD_H
+#define _LDAP_PVT_THREAD_H
+
+#include "ldap_cdefs.h"
+
+#if defined( HAVE_PTHREADS )
+/**********************************
+ *                                *
+ * definitions for POSIX Threads  *
+ *                                *
+ **********************************/
+
+#include <pthread.h>
+#ifdef HAVE_SCHED_H
+#include <sched.h>
+#endif
+
+LDAP_BEGIN_DECL
+
+typedef pthread_t              ldap_pvt_thread_t;
+typedef pthread_mutex_t                ldap_pvt_thread_mutex_t;
+typedef pthread_cond_t         ldap_pvt_thread_cond_t;
+
+#if defined( _POSIX_REENTRANT_FUNCTIONS ) || \
+       defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \
+       defined( _POSIX_THREADSAFE_FUNCTIONS )
+#define HAVE_REENTRANT_FUNCTIONS 1
+#endif
+
+#if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \
+       defined( HAVE_THR_GETCONCURRENCY )
+#define HAVE_GETCONCURRENCY 1
+#endif
+
+#if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \
+       defined( HAVE_THR_SETCONCURRENCY )
+#define HAVE_SETCONCURRENCY 1
+#endif
+
+LDAP_END_DECL
+
+#elif defined ( HAVE_MACH_CTHREADS )
+/**********************************
+ *                                *
+ * definitions for Mach CThreads  *
+ *                                *
+ **********************************/
+
+#include <mach/cthreads.h>
+
+LDAP_BEGIN_DECL
+
+typedef cthread_t              ldap_pvt_thread_t;
+typedef struct mutex           ldap_pvt_thread_mutex_t;
+typedef struct condition       ldap_pvt_thread_cond_t;
+
+LDAP_END_DECL
+
+#elif defined( HAVE_GNU_PTH )
+/***********************************
+ *                                 *
+ * thread definitions for GNU Pth  *
+ *                                 *
+ ***********************************/
+
+#include <pth.h>
+
+LDAP_BEGIN_DECL
+
+typedef pth_t          ldap_pvt_thread_t;
+typedef pth_mutex_t    ldap_pvt_thread_mutex_t;
+typedef pth_cond_t     ldap_pvt_thread_cond_t;
+
+LDAP_END_DECL
+
+
+#elif defined( HAVE_THR )
+/********************************************
+ *                                          *
+ * thread definitions for Solaris LWP (THR) *
+ *                                          *
+ ********************************************/
+
+#include <thread.h>
+#include <synch.h>
+
+LDAP_BEGIN_DECL
+
+typedef thread_t               ldap_pvt_thread_t;
+typedef mutex_t                        ldap_pvt_thread_mutex_t;
+typedef cond_t                 ldap_pvt_thread_cond_t;
+
+#define HAVE_REENTRANT_FUNCTIONS 1
+
+#ifdef HAVE_THR_GETCONCURRENCY
+#define HAVE_GETCONCURRENCY 1
+#endif
+#ifdef HAVE_THR_SETCONCURRENCY
+#define HAVE_SETCONCURRENCY 1
+#endif
+
+LDAP_END_DECL
+
+#elif defined( HAVE_LWP )
+/*************************************
+ *                                   *
+ * thread definitions for SunOS LWP  *
+ *                                   *
+ *************************************/
+
+#include <lwp/lwp.h>
+#include <lwp/stackdep.h>
+
+LDAP_BEGIN_DECL
+
+typedef thread_t               ldap_pvt_thread_t;
+typedef mon_t                  ldap_pvt_thread_mutex_t;
+struct ldap_pvt_thread_lwp_cv {
+       int             lcv_created;
+       cv_t            lcv_cv;
+};
+typedef struct ldap_pvt_thread_lwp_cv ldap_pvt_thread_cond_t;
+
+#define HAVE_REENTRANT_FUNCTIONS 1
+
+LDAP_END_DECL
+
+#elif HAVE_NT_THREADS
+
+LDAP_BEGIN_DECL
+
+#define WIN32_LEAN_AND_MEAN
+#include <process.h>
+#include <windows.h>
+
+typedef unsigned long  ldap_pvt_thread_t;
+typedef HANDLE ldap_pvt_thread_mutex_t;
+typedef HANDLE ldap_pvt_thread_cond_t;
+
+LDAP_END_DECL
+
+#else
+
+/***********************************
+ *                                 *
+ * thread definitions for no       *
+ * underlying library support      *
+ *                                 *
+ ***********************************/
+
+LDAP_BEGIN_DECL
+
+#ifndef NO_THREADS
+#define NO_THREADS 1
+#endif
+
+typedef int                    ldap_pvt_thread_t;
+typedef int                    ldap_pvt_thread_mutex_t;
+typedef int                    ldap_pvt_thread_cond_t;
+
+LDAP_END_DECL
+
+#endif /* no threads support */
+
+LDAP_BEGIN_DECL
+
+LDAP_F( int )
+ldap_pvt_thread_initialize LDAP_P(( void ));
+
+LDAP_F( int )
+ldap_pvt_thread_destroy LDAP_P(( void ));
+
+LDAP_F( unsigned int )
+ldap_pvt_thread_sleep LDAP_P(( unsigned int s ));
+
+#ifdef HAVE_GETCONCURRENCY
+LDAP_F( int )
+ldap_pvt_thread_get_concurrency LDAP_P(( void ));
+#endif
+
+#ifdef HAVE_SETCONCURRENCY
+#      ifndef LDAP_THREAD_CONCURRENCY
+       /* three concurrent threads should be enough */
+#      define LDAP_THREAD_CONCURRENCY  3
+#      endif
+LDAP_F( int )
+ldap_pvt_thread_set_concurrency LDAP_P(( int ));
+#endif
+
+#define LDAP_PVT_THREAD_CREATE_JOINABLE 0
+#define LDAP_PVT_THREAD_CREATE_DETACHED 1
+
+LDAP_F( int ) 
+ldap_pvt_thread_create LDAP_P((
+       ldap_pvt_thread_t * thread, 
+       int     detach,
+       void *(*start_routine)( void * ), 
+       void *arg));
+
+LDAP_F( void ) 
+ldap_pvt_thread_exit LDAP_P(( void *retval ));
+
+LDAP_F( int )
+ldap_pvt_thread_join LDAP_P(( ldap_pvt_thread_t thread, void **status ));
+
+LDAP_F( int )
+ldap_pvt_thread_kill LDAP_P(( ldap_pvt_thread_t thread, int signo ));
+
+LDAP_F( int )
+ldap_pvt_thread_yield LDAP_P(( void ));
+
+LDAP_F( int )
+ldap_pvt_thread_cond_init LDAP_P(( ldap_pvt_thread_cond_t *cond ));
+
+LDAP_F( int )
+ldap_pvt_thread_cond_destroy LDAP_P(( ldap_pvt_thread_cond_t *cond ));
+
+LDAP_F( int )
+ldap_pvt_thread_cond_signal LDAP_P(( ldap_pvt_thread_cond_t *cond ));
+
+LDAP_F( int )
+ldap_pvt_thread_cond_broadcast LDAP_P(( ldap_pvt_thread_cond_t *cond ));
+
+LDAP_F( int )
+ldap_pvt_thread_cond_wait LDAP_P((
+       ldap_pvt_thread_cond_t *cond, 
+       ldap_pvt_thread_mutex_t *mutex ));
+
+LDAP_F( int )
+ldap_pvt_thread_mutex_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
+
+LDAP_F( int )
+ldap_pvt_thread_mutex_destroy LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
+
+LDAP_F( int )
+ldap_pvt_thread_mutex_lock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
+
+LDAP_F( int )
+ldap_pvt_thread_mutex_trylock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
+
+LDAP_F( int )
+ldap_pvt_thread_mutex_unlock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
+
+typedef struct ldap_pvt_thread_rdwr_var {
+       ldap_pvt_thread_mutex_t ltrw_mutex;     
+       ldap_pvt_thread_cond_t ltrw_read;       /* wait for read */
+       ldap_pvt_thread_cond_t ltrw_write;      /* wait for write */
+       int ltrw_valid;
+#define LDAP_PVT_THREAD_RDWR_VALID 0x0bad
+       int ltrw_r_active;
+       int ltrw_w_active;
+       int ltrw_r_wait;
+       int ltrw_w_wait;
+} ldap_pvt_thread_rdwr_t;
+
+LDAP_F( int )
+ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
+
+LDAP_F( int )
+ldap_pvt_thread_rdwr_destroy LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
+
+LDAP_F( int )
+ldap_pvt_thread_rdwr_rlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
+
+LDAP_F( int )
+ldap_pvt_thread_rdwr_rtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
+
+LDAP_F( int )
+ldap_pvt_thread_rdwr_runlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
+
+LDAP_F( int )
+ldap_pvt_thread_rdwr_wlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
+
+LDAP_F( int )
+ldap_pvt_thread_rdwr_wtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
+
+LDAP_F( int )
+ldap_pvt_thread_rdwr_wunlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
+
+#ifdef LDAP_DEBUG
+LDAP_F( int )
+ldap_pvt_thread_rdwr_readers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
+
+LDAP_F( int )
+ldap_pvt_thread_rdwr_writers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
+
+LDAP_F( int )
+ldap_pvt_thread_rdwr_active LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
+#endif /* LDAP_DEBUG */
+
+#define LDAP_PVT_THREAD_EINVAL EINVAL
+#define LDAP_PVT_THREAD_EBUSY EINVAL
+
+LDAP_END_DECL
+
+#endif /* _LDAP_THREAD_H */
index 64de1b08d6bcf2d0c87fed26a1288038df01b8b2..c0c21bc88da4628f8368c64f783ea7c3be551b92 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
@@ -160,7 +161,7 @@ ldap_matchingrule2str LDAP_P((
 
 LDAP_F( char *)
 ldap_scherr2str LDAP_P((
-       int code ));
+       int code )) LDAP_GCCATTR((const));
 
 LDAP_END_DECL
 
index 10f9b3b44de3723da8b7c363558cf80fb4a4b8a6..9fd65730e39fb3908163b5df94ae23715f775146 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
index 901fb58e7083a39adfbc0a612078e25c0d933f9b..a50bbf063442a73d8dde65ac32455a0d881fd2f0 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
@@ -7,7 +8,6 @@
  * license is available at http://www.OpenLDAP.org/license.html or
  * in file LICENSE in the top-level directory of the distribution.
  */
-
 /* Portions
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
index d7eb530fcd3e91dfb1db7343649e72f527b7c796..05d6279f947eddf8bb2c1c209ecebbd291f31988 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
@@ -12,6 +13,8 @@
 #define _LUTIL_H 1
 
 #include <ldap_cdefs.h>
+#include <lber_types.h>
+
 /*
  * Include file for LDAP utility routine
  */
@@ -54,6 +57,9 @@ lutil_progname LDAP_P((
        int argc,
        char *argv[] ));
 
+/* sockpair.c */
+LDAP_F( int )
+lutil_pair( LBER_SOCKET_T sd[2] );
 
 LDAP_END_DECL
 
diff --git a/include/lutil_lockf.h b/include/lutil_lockf.h
new file mode 100644 (file)
index 0000000..728b445
--- /dev/null
@@ -0,0 +1,30 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/* File locking methods
+ *
+ * lutil_lockf() will block until an exclusive lock is acquired.
+ */
+
+#ifndef _LUTIL_LOCKF_H_
+#define _LUTIL_LOCKF_H_
+
+LDAP_BEGIN_DECL
+
+LDAP_F( int )
+lutil_lockf LDAP_P(( int fd ));
+
+LDAP_F( int )
+lutil_unlockf LDAP_P(( int fd ));
+
+LDAP_END_DECL
+
+#endif /* _LUTIL_LOCKF_H_ */
diff --git a/include/lutil_md5.h b/include/lutil_md5.h
new file mode 100644 (file)
index 0000000..6a140c9
--- /dev/null
@@ -0,0 +1,66 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/* See md5.c for explanation and copyright information.  */
+
+#ifndef _LUTIL_MD5_H_
+#define _LUTIL_MD5_H_
+
+#include <ldap_cdefs.h>
+#include <ac/bytes.h>
+
+LDAP_BEGIN_DECL
+
+/* Unlike previous versions of this code, uint32 need not be exactly
+   32 bits, merely 32 bits or more.  Choosing a data type which is 32
+   bits instead of 64 is not important; speed is considerably more
+   important.  ANSI guarantees that "unsigned long" will be big enough,
+   and always using it seems to have few disadvantages.  */
+
+#ifndef LDAP_UINT32
+#define LDAP_UINT32 1
+typedef ac_uint4 uint32;
+#endif
+
+struct lutil_MD5Context {
+       uint32 buf[4];
+       uint32 bits[2];
+       unsigned char in[64];
+};
+
+LDAP_F( void )
+lutil_MD5Init LDAP_P((
+       struct lutil_MD5Context *context));
+
+LDAP_F( void )
+lutil_MD5Update LDAP_P((
+       struct lutil_MD5Context *context,
+       unsigned char const *buf,
+       unsigned len));
+
+LDAP_F( void )
+lutil_MD5Final LDAP_P((
+       unsigned char digest[16],
+       struct lutil_MD5Context *context));
+
+LDAP_F( void )
+lutil_MD5Transform LDAP_P((
+       uint32 buf[4],
+       const unsigned char in[64]));
+
+/*
+ * This is needed to make RSAREF happy on some MS-DOS compilers.
+ */
+typedef struct lutil_MD5Context lutil_MD5_CTX;
+
+LDAP_END_DECL
+
+#endif /* _LUTIL_MD5_H_ */
diff --git a/include/lutil_sha1.h b/include/lutil_sha1.h
new file mode 100644 (file)
index 0000000..07f82fb
--- /dev/null
@@ -0,0 +1,69 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/* This version is based on:
+ *     $OpenBSD: sha1.h,v 1.8 1997/07/15 01:54:23 millert Exp $        */
+
+#ifndef _LUTIL_SHA1_H_
+#define _LUTIL_SHA1_H_
+
+#include <ldap_cdefs.h>
+#include <ac/bytes.h>
+
+LDAP_BEGIN_DECL
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ */
+
+#ifndef LDAP_UINT32
+#define LDAP_UINT32 1
+typedef ac_uint4 uint32;
+#endif
+
+typedef struct {
+    uint32 state[5];
+    uint32 count[2];  
+    unsigned char buffer[64];
+} lutil_SHA1_CTX;
+  
+LDAP_F( void )
+lutil_SHA1Transform
+       LDAP_P((uint32 state[5], const unsigned char buffer[64]));
+
+LDAP_F( void  )
+lutil_SHA1Init
+       LDAP_P((lutil_SHA1_CTX *context));
+
+LDAP_F( void  )
+lutil_SHA1Update
+       LDAP_P((lutil_SHA1_CTX *context, const unsigned char *data, uint32 len));
+
+LDAP_F( void  )
+lutil_SHA1Final
+       LDAP_P((unsigned char digest[20], lutil_SHA1_CTX *context));
+
+LDAP_F( char * )
+lutil_SHA1End
+       LDAP_P((lutil_SHA1_CTX *, char *));
+
+LDAP_F( char * )
+lutil_SHA1File
+       LDAP_P((char *, char *));
+
+LDAP_F( char * )
+lutil_SHA1Data
+       LDAP_P((const unsigned char *, size_t, char *));
+
+LDAP_END_DECL
+
+#endif /* _LUTIL_SHA1_H_ */
index 82341447b9e4a95668df6f292664c9ffb10db757..3464300ce20038b07d8ef1ca508a9cc5db9c5253 100644 (file)
 /* Define if you have the mkstemp function.  */
 #undef HAVE_MKSTEMP
 
+/* Define if you have the pipe function.  */
+#undef HAVE_PIPE
+
 /* Define if you have the pthread_getconcurrency function.  */
 #undef HAVE_PTHREAD_GETCONCURRENCY
 
 /* Define if you have the setuid function.  */
 #undef HAVE_SETUID
 
+/* Define if you have the sigaction function.  */
+#undef HAVE_SIGACTION
+
 /* Define if you have the signal function.  */
 #undef HAVE_SIGNAL
 
 /* Define if you have the <psap.h> header file.  */
 #undef HAVE_PSAP_H
 
+/* Define if you have the <pth.h> header file.  */
+#undef HAVE_PTH_H
+
 /* Define if you have the <pthread.h> header file.  */
 #undef HAVE_PTHREAD_H
 
 /* Define if you have the <ssl.h> header file.  */
 #undef HAVE_SSL_H
 
-/* Define if you have the <stdarg.h> header file.  */
-#undef HAVE_STDARG_H
-
 /* Define if you have the <stddef.h> header file.  */
 #undef HAVE_STDDEF_H
 
 /* define if you have Mach Cthreads */
 #undef HAVE_MACH_CTHREADS
 
+/* if you have GNU Pth */
+#undef HAVE_GNU_PTH
+
 /* if you have Solaris LWP (thr) package */
 #undef HAVE_THR
 
 /* define to support reverse lookups */
 #undef SLAPD_RLOOKUPS
 
+/* define to support per-object ACIs */
+#undef SLAPD_ACI_ENABLED
+
+/* define to support discrete rights in ACIs */
+#undef SLAPD_ACI_DISCRETE_RIGHTS
+
 /* define to support modules */
 #undef SLAPD_MODULES
 
 
 /* begin of postamble */
 
+#ifndef __NEED_PROTOTYPES
+/* force LDAP_P to always include prototypes */
+#define __NEED_PROTOTYPES 1
+#endif
+
 #ifdef HAVE_STDDEF_H
 #      include <stddef.h>
 #endif
diff --git a/include/portable.nt b/include/portable.nt
new file mode 100644 (file)
index 0000000..af077ef
--- /dev/null
@@ -0,0 +1,759 @@
+/* $OpenLDAP$ */
+/* include/portable.h.nt -- manually updated of MS NT (MS VC5) */
+/* synced with portable.h.in 1.24 */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#ifndef _LDAP_PORTABLE_H
+#define _LDAP_PORTABLE_H
+
+/* end of preamble */
+
+/* --------------------------------------------------- */
+/* begin of MSVC5 specific entries */
+
+#define OPENLDAP_PACKAGE "OpenLDAP"
+#define OPENLDAP_VERSION "-devel"
+#define EXEEXT ".exe"
+#define LDAP_DIRSEP "\\"
+
+/* don't suck in all of the win32 api */
+#define WIN32_LEAN_AND_MEAN
+
+#ifdef _WINNT
+/* WindowsNT specific features */
+#define HAVE_NT_SERVICE_MANAGER 1
+#define HAVE_NT_EVENT_LOG 1
+
+#elif _WIN95
+/* Windows95 specific features */
+#endif
+
+#if defined( _DEBUG ) && !defined( LDAP_DEBUG )
+/* #define LDAP_MEMORY_DEBUG 1 */
+#define LDAP_DEBUG 1
+#endif
+
+/* we installed Henry Spencer's REGEX */
+#define HAVE_REGEX_H 1
+
+/* win32 specific stuff */
+#define sleep _sleep
+
+#define strcasecmp     stricmp
+#define strncasecmp    strnicmp
+#define strdup         _strdup
+
+#define        snprintf        _snprintf
+#define vsnprintf      _vsnprintf
+/* #define vsprintf    _vsprintf */
+
+/* define type for caddr_t */
+typedef char * caddr_t;
+
+#define ssize_t signed int
+
+#define LOG_DEBUG 0
+#define openlog( a, b )
+#define closelog()
+
+#define FD_SETSIZE 1024
+
+/* we have NT threads */
+#ifdef _MT
+#define HAVE_NT_THREADS 1
+#else
+#define NO_THREADS 1
+#endif
+
+/* we have spawnlp instead of fork/execlp */
+#define HAVE_SPAWNLP 1
+
+/* we have winsock2 */
+#define HAVE_WINSOCK2 1
+
+/* we have winsock */
+#define HAVE_WINSOCK 1
+
+/* we have <conio.h> */
+#define HAVE_CONIO_H 1
+
+/* we have <direct.h> */
+#define HAVE_DIRECT_H 1
+
+/* we have <io.h> */
+#define HAVE_IO_H 1
+
+/* we have <process.h> */
+#define HAVE_PROCESS_H 1
+
+#define LDAP_SIGUSR1   SIGILL
+#define LDAP_SIGUSR2   SIGTERM
+
+#define MAXPATHLEN _MAX_PATH
+
+/* end of MSVC5 specific entries */
+/* --------------------------------------------------- */
+
+/* Define if on AIX 3.
+   System headers sometimes define this.
+   We just want to avoid a redefinition error message.  */
+#ifndef _ALL_SOURCE
+/* #undef _ALL_SOURCE */
+#endif
+
+/* Define to empty if the keyword does not work.  */
+/* #undef const */
+
+/* Define to the type of elements in the array set by `getgroups'.
+   Usually this is either `int' or `gid_t'.  */
+/* #undef GETGROUPS_T */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+#define gid_t long
+
+/* Define if you don't have vprintf but do have _doprnt.  */
+/* #undef HAVE_DOPRNT */
+
+/* Define if your struct stat has st_blksize.  */
+/* #undef HAVE_ST_BLKSIZE */
+
+/* Define if you have the strftime function.  */
+#define HAVE_STRFTIME 1
+
+/* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
+/* #undef HAVE_SYS_WAIT_H */
+
+/* Define if you have the vprintf function.  */
+#define HAVE_VPRINTF 1
+
+/* Define if on MINIX.  */
+/* #undef _MINIX */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+#define mode_t int
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #undef off_t */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+#define pid_t int
+
+/* Define if the system does not provide POSIX.1 features except
+   with this defined.  */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define if you need to in order for stat and other things to work.  */
+/* #undef _POSIX_SOURCE */
+
+/* Define as the return type of signal handlers (int or void).  */
+#define RETSIGTYPE void
+
+/* Define to `unsigned' if <sys/types.h> doesn't define.  */
+/* #undef size_t */
+
+/* Define if you have the ANSI C header files.  */
+#define STDC_HEADERS 1
+
+/* Define if you can safely include both <sys/time.h> and <time.h>.  */
+/* #undef TIME_WITH_SYS_TIME */
+
+/* Define if your <sys/time.h> declares struct tm.  */
+/* #undef TM_IN_SYS_TIME */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+#define uid_t long
+
+/* Define if your processor stores words with the most significant
+   byte first (like Motorola and SPARC, unlike Intel and VAX).  */
+/* #undef WORDS_BIGENDIAN */
+
+/* define this if needed to get reentrant functions */
+#ifndef REENTRANT
+/* #undef REENTRANT */
+#endif
+#ifndef _REENTRANT
+/* #undef _REENTRANT */
+#endif
+
+/* define this if needed to get threadsafe functions */
+#ifndef THREADSAFE
+/* #undef THREADSAFE */
+#endif
+#ifndef _THREADSAFE
+/* #undef _THREADSAFE */
+#endif
+#ifndef THREAD_SAFE
+/* #undef THREAD_SAFE */
+#endif
+#ifndef _THREAD_SAFE
+/* #undef _THREAD_SAFE */
+#endif
+
+/* define this if toupper() requires tolower() */
+#define C_UPPER_LOWER 1
+
+/* define this to the number of arguments ctime_r() expects */
+/* #undef CTIME_R_NARGS */
+
+/* define this if sys_errlist is not defined in stdio.h or errno.h */
+/* #undef DECL_SYS_ERRLIST */
+
+/* define this if sys_errlist is available */
+#define HAVE_SYS_ERRLIST 1 
+
+/* define if you have berkeley db */
+/* #undef HAVE_BERKELEY_DB */
+
+/* define if you have berkeley db2 */
+#define HAVE_BERKELEY_DB2 1
+
+/* define if you have crypt */
+/* #undef HAVE_CRYPT */
+
+/* define if you have GDBM */
+/* #undef HAVE_GDBM */
+
+/* define if you have NDBM */
+/* #undef HAVE_NDBM */
+
+/* define if you have res_search() */
+#ifdef __notdef__
+/* see second res_search define */
+/* #undef HAVE_RES_SEARCH */
+#endif
+
+/* define if you have sched_yield() */
+#ifdef __notdef__
+/* see second sched_yield define */
+/* #undef HAVE_SCHED_YIELD */
+#endif
+
+/* define if you have setproctitle() */
+/* #undef HAVE_SETPROCTITLE */
+
+/* define this for connectionless LDAP support */
+/* #undef LDAP_CONNECTIONLESS */
+
+/* define this to add debugging code */
+/* #undef LDAP_DEBUG */
+
+/* define this to remove -lldap cache support */
+/* #undef LDAP_NOCACHE */
+
+/* define this for LDAP process title support */
+/* #undef LDAP_PROCTITLE */
+
+/* define this for LDAP User Interface support */
+/* #undef LDAP_LIBUI */
+
+/* define this to add syslog code */
+/* #undef LDAP_SYSLOG */
+
+/* define this to use DBBTREE w/ LDBM backend */
+#define LDBM_USE_DBBTREE 1
+
+/* define this to use DBHASH w/ LDBM backend */
+/* #undef LDBM_USE_DBHASH */
+
+/* define this for ACL Group support */
+#define SLAPD_ACLGROUPS 1
+
+/* define this to use SLAPD Berkeley DB2 backend */
+/* #define SLAPD_BDB2 1 */
+
+/* define this for ClearText password support */
+#define SLAPD_CLEARTEXT 1
+
+/* define this for crypt(3) password support */
+/* #undef SLAPD_CRYPT */
+
+/* define this to use SLAPD LDAP backend */
+/* #undef SLAPD_LDAP */
+
+/* define this to use SLAPD LDBM backend */
+#define SLAPD_LDBM 1
+
+/* define this to use SLAPD passwd backend */
+/* #undef SLAPD_PASSWD */
+
+/* define this to use SLAPD perl backend */
+/* #undef SLAPD_PERL */
+
+/* define this for phonetic support */
+/* #undef SLAPD_PHONETIC */
+
+/* define this for Reverse Lookup support */
+#define SLAPD_RLOOKUPS 1
+
+/* define this for per-object ACIs */
+/* #undef SLAPD_ACI_ENABLED */
+
+/* define this for discrete rights in ACIs */
+/* #undef SLAPD_ACI_DISCRETE_RIGHTS */
+
+/* define this to use SLAPD shell backend */
+/* #undef SLAPD_SHELL */
+
+/* define this to be empty if your compiler doesn't support volatile */
+/* #undef volatile */
+
+/* define this if sig_atomic_t isn't defined in signal.h */
+/* #undef sig_atomic_t */
+
+/* define this if socklen_t isn't defined in sys/types.h or sys/socket.h */
+#define socklen_t int
+
+/* These are defined in ldap_features.h */
+/*
+ LDAP_API_FEATURE_X_OPENLDAP_REENTRANT
+ LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
+ LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
+ LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
+*/
+
+/* The number of bytes in a int.  */ 
+#define SIZEOF_INT 4
+
+/* The number of bytes in a long.  */ 
+#define SIZEOF_LONG 4
+  
+/* The number of bytes in a short.  */
+#define SIZEOF_SHORT 2
+
+/* Define if you have the bcopy function.  */
+/* #undef HAVE_BCOPY */
+
+/* Define if you have the ctime_r function.  */
+/* #undef HAVE_CTIME_R */
+
+/* Define if you have the flock function.  */
+/* #undef HAVE_FLOCK */
+
+/* Define if you have the getdtablesize function.  */
+/* #undef HAVE_GETDTABLESIZE */
+
+/* Define if you have the gethostbyaddr_r function.  */
+/* #undef HAVE_GETHOSTBYADDR_R */
+
+/* Define if you have the gethostbyname_r function.  */
+/* #undef HAVE_GETHOSTBYNAME_R */
+
+/* Define if you have the gethostname function.  */
+#define HAVE_GETHOSTNAME 1
+
+/* define if you have the getopt function */
+/* #undef HAVE_GETOPT */
+
+/* Define if you have the getpwuid function.  */
+/* #undef HAVE_GETPWUID */
+
+/* Define if you have the gettimeofday function.  */
+/* #undef HAVE_GETTIMEOFDAY */
+
+/* Define if you have the lockf function.  */
+/* #undef HAVE_LOCKF */
+
+/* Define if you have the memcpy function.  */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the memmove function.  */
+#define HAVE_MEMMOVE 1
+
+/* Define if you have the mkstemp function.  */
+/* #undef HAVE_MKSTEMP */
+
+/* Define if you have the pthread_getconcurrency function.  */
+/* #undef HAVE_PTHREAD_GETCONCURRENCY */
+
+/* Define if you have the pthread_kill function.  */
+/* #undef HAVE_PTHREAD_KILL */
+
+/* Define if you have the pthread_setconcurrency function.  */
+/* #undef HAVE_PTHREAD_SETCONCURRENCY */
+
+/* Define if you have the pthread_yield function.  */
+/* #undef HAVE_PTHREAD_YIELD */
+
+/* Define if you have the res_search function.  */
+/* #undef HAVE_RES_SEARCH */
+
+/* Define if you have the sched_yield function.  */
+/* #undef HAVE_SCHED_YIELD */
+
+/* Define if you have the select function.  */
+#define HAVE_SELECT 1
+
+/* Define if you have the setpwfile function.  */
+/* #undef HAVE_SETPWFILE */
+
+/* Define if you have the setsid function.  */
+/* #undef HAVE_SETSID */
+
+/* Define if you have the signal function.  */
+#define HAVE_SIGNAL 1
+
+/* Define if you have the sigset function.  */
+/* #undef HAVE_SIGSET */
+
+/* Define if you have the snprintf function.  */
+/* #undef HAVE_SNPRINTF */
+
+/* Define if you have the socket function.  */
+#define HAVE_SOCKET 1
+
+/* Define if you have the strdup function.  */
+#define HAVE_STRDUP 1
+
+/* Define if you have the strerror function.  */
+#define HAVE_STRERROR 1
+
+/* Define if you have the strpbrk function.  */
+#define HAVE_STRPBRK 1
+
+/* Define if you have the strrchr function.  */
+#define HAVE_STRRCHR 1
+
+/* Define if you have the strsep function.  */
+/* #undef HAVE_STRSEP */
+
+/* Define if you have the strspn function.  */
+#define HAVE_STRSPN 1
+
+/* Define if you have the strstr function.  */
+#define HAVE_STRSTR 1
+
+/* Define if you have the strtok function.  */
+#define HAVE_STRTOK 1
+
+/* Define if you have the strtok_r function.  */
+/* #undef HAVE_STRTOK_R */
+
+/* Define if you have the strtol function.  */
+#define HAVE_STRTOL 1
+
+/* Define if you have the strtoul function.  */
+#define HAVE_STRTOUL 1
+
+/* Define if you have the sysconf function.  */
+/* #undef HAVE_SYSCONF */
+
+/* Define if you have the tempnam function.  */
+/* #undef HAVE_TEMPNAM */
+
+/* Define if you have the thr_getconcurrency function.  */
+/* #undef HAVE_THR_GETCONCURRENCY */
+
+/* Define if you have the thr_setconcurrency function.  */
+/* #undef HAVE_THR_SETCONCURRENCY */
+
+/* Define if you have the thr_yield function.  */
+/* #undef HAVE_THR_YIELD */
+
+/* Define if you have the vsnprintf function.  */
+#define HAVE_VSNPRINTF 1
+
+/* Define if you have the vsprintf function.  */
+#define HAVE_VSPRINTF 1
+
+/* Define if you have the waitpid function.  */
+/* #undef HAVE_WAITPID 1 */
+
+/* Define if you have the <arpa/nameser.h> header file.  */
+/* #undef HAVE_ARPA_NAMESER_H */
+
+/* Define if you have the <crypt.h> header file.  */
+/* #undef HAVE_CRYPT_H */
+
+/* Define if you have the <db.h> header file.  */
+#define HAVE_DB_H 1
+
+/* Define if you have the <db_185.h> header file.  */
+/* #undef HAVE_DB_185_H */
+
+/* Define if you have the <des.h> header file.  */
+/* #undef HAVE_DES_H */
+
+/* Define if you have the <dirent.h> header file.  */
+/* #undef HAVE_DIRENT_H */
+
+/* Define if you have the <dmalloc.h> header file.  */
+/* #undef HAVE_DMALLOC_H */
+
+/* Define if you have the <errno.h> header file.  */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file.  */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <filio.h> header file.  */
+/* #undef HAVE_FILIO_H */
+
+/* Define if you have the <gdbm.h> header file.  */
+/* #undef HAVE_GDBM_H */
+
+/* Define if you have the <getopt.h> header file.  */
+/* #undef HAVE_GETOPT_H */
+
+/* Define if you have the <kerberosIV/des.h> header file.  */
+/* #undef HAVE_KERBEROSIV_DES_H */
+
+/* Define if you have the <kerberosIV/krb.h> header file.  */
+/* #undef HAVE_KERBEROSIV_KRB_H */
+
+/* Define if you have the <krb.h> header file.  */
+/* #undef HAVE_KRB_H */
+
+/* Define if you have the <libutil.h> header file.  */
+/* #undef HAVE_LIBUTIL_H */
+
+/* Define if you have the <limits.h> header file.  */
+#define HAVE_LIMITS_H 1
+
+/* Define if you have the <lwp/lwp.h> header file.  */
+/* #undef HAVE_LWP_LWP_H */
+
+/* Define if you have the <mach/cthreads.h> header file.  */
+/* #undef HAVE_MACH_CTHREADS_H */
+
+/* Define if you have the <malloc.h> header file.  */
+#define HAVE_MALLOC_H 1
+
+/* Define if you have the <memory.h> header file.  */
+/* #define HAVE_MEMORY_H */
+
+/* Define if you have the <ncurses.h> header file.  */
+/* #undef HAVE_NCURSES_H */
+
+/* Define if you have the <ndbm.h> header file.  */
+/* #undef HAVE_NDBM_H */
+
+/* Define if you have the <ndir.h> header file.  */
+/* #undef HAVE_NDIR_H */
+
+/* Define if you have the <psap.h> header file.  */
+/* #undef HAVE_PSAP_H */
+
+/* Define if you have the <pthread.h> header file.  */
+/* #undef HAVE_PTHREAD_H */
+
+/* Define if you have the <pwd.h> header file.  */
+/* #undef HAVE_PWD_H */
+
+/* Define if you have the <regex.h> header file.  */
+/* #undef HAVE_REGEX_H */
+
+/* Define if you have the <resolv.h> header file.  */
+/* #undef HAVE_RESOLV_H */
+
+/* Define if you have the <sched.h> header file.  */
+/* #undef HAVE_SCHED_H */
+
+/* Define if you have the <sgtty.h> header file.  */
+/* #undef HAVE_SGTTY_H */
+
+/* Define if you have the <stdarg.h> header file.  */
+#define HAVE_STDARG_H 1
+
+/* Define if you have the <stddef.h> header file.  */
+#define HAVE_STDDEF_H 1
+
+/* Define if you have the <string.h> header file.  */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <strings.h> header file.  */
+/* #undef HAVE_STRINGS_H */
+
+/* Define if you have the <synch.h> header file.  */
+/* #undef HAVE_SYNCH_H */
+
+/* Define if you have the <sys/dir.h> header file.  */
+/* #undef HAVE_SYS_DIR_H */
+
+/* Define if you have the <sys/errno.h> header file.  */
+/* #undef HAVE_SYS_ERRNO_H */
+
+/* Define if you have the <sys/file.h> header file.  */
+/* #undef HAVE_SYS_FILE_H */
+
+/* Define if you have the <sys/filio.h> header file.  */
+/* #undef HAVE_SYS_FILIO_H */
+
+/* Define if you have the <sys/ioctl.h> header file.  */
+/* #undef HAVE_SYS_IOCTL_H */
+
+/* Define if you have the <sys/ndir.h> header file.  */
+/* #undef HAVE_SYS_NDIR_H */
+
+/* Define if you have the <sys/param.h> header file.  */
+/* #undef HAVE_SYS_PARAM_H */
+
+/* Define if you have the <sys/resource.h> header file.  */
+/* #undef HAVE_SYS_RESOURCE_H */
+
+/* Define if you have the <sys/socket.h> header file.  */
+/* #undef HAVE_SYS_SOCKET_H */
+
+/* Define if you have the <sys/syslog.h> header file.  */
+/* #undef HAVE_SYS_SYSLOG_H */
+
+/* Define if you have the <sys/time.h> header file.  */
+/* #undef HAVE_SYS_TIME_H */
+
+/* Define if you have the <sys/types.h> header file.  */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define if you have the <sysexits.h> header file.  */
+/* #undef HAVE_SYSEXITS_H */
+
+/* Define if you have the <syslog.h> header file.  */
+/* #undef HAVE_SYSLOG_H */
+
+/* Define if you have the <tcpd.h> header file.  */
+/* #undef HAVE_TCPD_H */
+
+/* Define if you have the <termcap.h> header file.  */
+/* #undef HAVE_TERMCAP_H */
+
+/* Define if you have the <termios.h> header file.  */
+/* #undef HAVE_TERMIOS_H */
+
+/* Define if you have the <thread.h> header file.  */
+/* #undef HAVE_THREAD_H */
+
+/* Define if you have the <unistd.h> header file.  */
+/* #undef HAVE_UNISTD_H */
+
+/* Define if you have the V3 library (-lV3).  */
+/* #undef HAVE_LIBV3 */
+
+/* Define if you have the bind library (-lbind).  */
+/* #undef HAVE_LIBBIND */
+
+/* Define if you have the dmalloc library (-ldmalloc).  */
+/* #undef HAVE_LIBDMALLOC */
+
+/* Define if you have the gen library (-lgen).  */
+/* #undef HAVE_LIBGEN */
+
+/* Define if you have the inet library (-linet).  */
+/* #undef HAVE_LIBINET */
+
+/* Define if you have the net library (-lnet).  */
+/* #undef HAVE_LIBNET */
+
+/* Define if you have the nsl library (-lnsl).  */
+/* #undef HAVE_LIBNSL */
+
+/* Define if you have the nsl_s library (-lnsl_s).  */
+/* #undef HAVE_LIBNSL_S */
+
+/* Define if you have the resolv library (-lresolv).  */
+/* #undef HAVE_LIBRESOLV */
+
+/* Define if you have the socket library (-lsocket).  */
+/* #undef HAVE_LIBSOCKET */
+
+/* define if you have -lxtpp */
+/* #undef HAVE_XTPP */
+
+/* define if you have -ldsap */
+/* #undef HAVE_DSAP */
+
+/* define if you have -lisode */
+/* #undef HAVE_ISODE */
+
+/* define if you have -lpp */
+/* #undef HAVE_PP */
+
+/* define if you have Kerberos des_debug */
+/* #undef HAVE_DES_DEBUG */
+
+/* define if you have Kerberos */
+/* #undef HAVE_KERBEROS */
+
+/* define if pthreads API compatible with final spec */
+/* #undef HAVE_PTHREADS_FINAL */
+
+/* define if pthreads API compatible with draft4 spec */
+/* #undef HAVE_PTHREADS_D4 */
+
+/* define if you have LinuxThreads */
+/* #undef HAVE_LINUX_THREADS */
+
+/* define if you have POSIX Threads */
+/* #undef HAVE_PTHREADS */
+
+/* define if you have pthread_detach function */
+/* #undef HAVE_PTHREAD_DETACH */
+
+/* define if you have Mach Cthreads */
+/* #undef HAVE_MACH_CTHREADS */
+
+/* if you have Solaris LWP (thr) package */
+/* #undef HAVE_THR */
+
+/* if you have SunOS LWP package */
+/* #undef HAVE_LWP */
+
+/* define if select implicitly yields */
+#define HAVE_YIELDING_SELECT 1
+
+/* define if you have (or want) no threads */
+/* #undef NO_THREADS */
+
+/* define if you have -lwrap */
+/* #undef HAVE_TCPD */
+
+/* define if you have -ltermcap */
+/* #undef HAVE_TERMCAP */
+
+/* define if you have -lncurses */
+/* #undef HAVE_NCURSES */
+
+/* define if you have no termcap support */
+#define NO_TERMCAP 1
+
+/* Define if TIOCGWINSZ requires sys/ioctl.h */
+/* #undef GWINSZ_IN_SYS_IOCTL */
+
+/* define if you have POSIX termios */
+/* #undef HAVE_POSIX_TERMIOS */
+
+/* Define if system has ptrdiff_t type */
+#define HAVE_PTRDIFF_T 1
+
+/* define if cross compiling */
+/* #undef CROSS_COMPILING */
+
+/* begin of postamble */
+
+#ifndef __NEED_PROTOTYPES
+/* force LDAP_P to always include prototypes */
+#define __NEED_PROTOTYPES 1 
+#endif
+
+#ifdef HAVE_STDDEF_H
+#      include <stddef.h>
+#endif
+
+#if defined(LDAP_DEVEL) && !defined(LDAP_TEST)
+#define LDAP_TEST
+#endif
+#if defined(LDAP_TEST) && !defined(LDAP_DEBUG)
+#define LDAP_DEBUG
+#endif
+
+#include "ldap_cdefs.h"
+#include "ldap_features.h"
+
+#include <ac/assert.h>
+
+#endif /* _LDAP_PORTABLE_H */
diff --git a/include/setup.dsp b/include/setup.dsp
new file mode 100644 (file)
index 0000000..2114f72
--- /dev/null
@@ -0,0 +1,100 @@
+# Microsoft Developer Studio Project File - Name="setup" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) External Target" 0x0106
+
+CFG=setup - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "setup.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "setup.mak" CFG="setup - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "setup - Win32 Release" (based on "Win32 (x86) External Target")
+!MESSAGE "setup - Win32 Debug" (based on "Win32 (x86) External Target")
+!MESSAGE 
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+
+!IF  "$(CFG)" == "setup - Win32 Release"
+
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Cmd_Line "NMAKE /f setup.mak"
+# PROP BASE Rebuild_Opt "/a"
+# PROP BASE Target_File "setup.txt"
+# PROP BASE Bsc_Name "setup.bsc"
+# PROP BASE Target_Dir ""
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Cmd_Line "NMAKE /f setup.mak"
+# PROP Rebuild_Opt "/a"
+# PROP Target_File "setup.txt"
+# PROP Bsc_Name "setup.bsc"
+# PROP Target_Dir ""
+
+!ELSEIF  "$(CFG)" == "setup - Win32 Debug"
+
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Cmd_Line "NMAKE /f setup.mak"
+# PROP BASE Rebuild_Opt "/a"
+# PROP BASE Target_File "setup.txt"
+# PROP BASE Bsc_Name "setup.bsc"
+# PROP BASE Target_Dir ""
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Cmd_Line "NMAKE /f setup.mak"
+# PROP Rebuild_Opt "/a"
+# PROP Target_File "setup.txt"
+# PROP Bsc_Name "setup.bsc"
+# PROP Target_Dir ""
+
+!ENDIF 
+
+# Begin Target
+
+# Name "setup - Win32 Release"
+# Name "setup - Win32 Debug"
+
+!IF  "$(CFG)" == "setup - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "setup - Win32 Debug"
+
+!ENDIF 
+
+# Begin Source File
+
+SOURCE=.\lber_types.nt
+# End Source File
+# Begin Source File
+
+SOURCE=.\ldap_config.nt
+# End Source File
+# Begin Source File
+
+SOURCE=.\ldap_features.nt
+# End Source File
+# Begin Source File
+
+SOURCE=.\portable.nt
+# End Source File
+# Begin Source File
+
+SOURCE=.\setup.mak
+# End Source File
+# End Target
+# End Project
index ad8ddaa022226c787ddf1fccfffdc1a11f43bdbe..9e3b1c3a53f4b2580f621e4b2401507db1767286 100644 (file)
@@ -1,21 +1,20 @@
+# $OpenLDAP$
 #
 # Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
 # COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 #
 
-all: setup.txt
-
-setup.txt: lber_types.h ldap_config.h ldap_features.h portable.h
-        copy setup.mak setup.txt
+.SUFFIXES: .nt
 
-lber_types.h: lber_types.h.nt
-       copy lber_types.h.nt lber_types.h
+.nt.h:
+       copy $*.nt $*.h
 
-ldap_config.h: ldap_config.h.nt
-       copy ldap_config.h.nt ldap_config.h
+all: setup.txt
 
-ldap_features.h: ldap_features.h.nt
-       copy ldap_features.h.nt ldap_features.h
+setup.txt: lber_types.h ldap_config.h ldap_features.h portable.h setup.mak
+       copy setup.mak setup.txt
 
-portable.h: portable.h.nt
-       copy portable.h.nt portable.h
+lber_types.h: lber_types.nt
+ldap_config.h: ldap_config.nt
+ldap_features.h: ldap_features.nt
+portable.h: portable.nt
index a1d65cffb0a4e0ea1281ab90ac245b12107e5f5d..e3523b005175e6379329c9360cc55f80e419f42d 100644 (file)
@@ -1,4 +1,14 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/* Portions
  * Copyright (c) 1993, 1994 Regents of the University of Michigan.
  * All rights reserved.
  *
 #ifndef _SRCHPREF_H
 #define _SRCHPREF_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <ldap_cdefs.h>
 
+LDAP_BEGIN_DECL
 
 struct ldap_searchattr {
        char                            *sa_attrlabel;
@@ -52,15 +61,13 @@ struct ldap_searchobj {
        struct ldap_searchobj           *so_next;
 };
 
-#define NULLSEARCHOBJ                  ((struct ldap_searchobj *)0)
-
 /*
  * global search object options
  */
 #define LDAP_SEARCHOBJ_OPT_INTERNAL    0x00000001
 
 #define LDAP_IS_SEARCHOBJ_OPTION_SET( so, option )     \
-       (((so)->so_options & option ) != 0 )
+       (((so)->so_options & (option) ) != 0 )
 
 #define LDAP_SEARCHPREF_VERSION_ZERO   0
 #define LDAP_SEARCHPREF_VERSION                1
@@ -71,36 +78,26 @@ struct ldap_searchobj {
 #define LDAP_SEARCHPREF_ERR_FILE       4
 
 
-#ifndef NEEDPROTOS
-int                    ldap_init_searchprefs();
-int                    ldap_init_searchprefs_buf();
-void                   ldap_free_searchprefs();
-struct ldap_searchobj  *ldap_first_searchobj();
-struct ldap_searchobj  *ldap_next_searchobj();
-
-#else /* !NEEDPROTOS */
-
-LDAPFUNCDECL int
-ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp );
+LDAP_F( int )
+ldap_init_searchprefs LDAP_P(( char *file,
+       struct ldap_searchobj **solistp ));
 
-LDAPFUNCDECL int
-ldap_init_searchprefs_buf( char *buf, long buflen,
-       struct ldap_searchobj **solistp );
+LDAP_F( int )
+ldap_init_searchprefs_buf LDAP_P(( char *buf,
+       ber_len_t buflen,
+       struct ldap_searchobj **solistp ));
 
-LDAPFUNCDECL void
-ldap_free_searchprefs( struct ldap_searchobj *solist );
+LDAP_F( void )
+ldap_free_searchprefs LDAP_P(( struct ldap_searchobj *solist ));
 
-LDAPFUNCDECL struct ldap_searchobj *
-ldap_first_searchobj( struct ldap_searchobj *solist );
+LDAP_F( struct ldap_searchobj * )
+ldap_first_searchobj LDAP_P(( struct ldap_searchobj *solist ));
 
-LDAPFUNCDECL struct ldap_searchobj *
-ldap_next_searchobj( struct ldap_searchobj *sollist,
-       struct ldap_searchobj *so );
+LDAP_F( struct ldap_searchobj * )
+ldap_next_searchobj LDAP_P(( struct ldap_searchobj *sollist,
+       struct ldap_searchobj *so ));
 
-#endif /* !NEEDPROTOS */
 
+LDAP_END_DECL
 
-#ifdef __cplusplus
-}
-#endif
 #endif /* _SRCHPREF_H */
index 9be67fa417304543997abb77282a833fcd71a857..48551549800880a8a1fbf41c3e7e856d945cfbec 100644 (file)
@@ -1,4 +1,14 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+/* Portions
  * Copyright (c) 1987 Regents of the University of California.
  * All rights reserved.
  *
diff --git a/libraries/Makefile.in b/libraries/Makefile.in
new file mode 100644 (file)
index 0000000..d911128
--- /dev/null
@@ -0,0 +1,8 @@
+# $OpenLDAP$
+## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
+## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+##
+## Libraries Makefile for OpenLDAP
+
+SUBDIRS= liblutil libldif liblber libldap libavl libldbm libldap_r
+
diff --git a/libraries/libavl/Makefile.in b/libraries/libavl/Makefile.in
new file mode 100644 (file)
index 0000000..92af71f
--- /dev/null
@@ -0,0 +1,18 @@
+# $OpenLDAP$
+##
+## LIBAVL
+##
+
+SRCS = avl.c testavl.c
+XSRCS = version.c
+OBJS = avl.o
+
+LDAP_INCDIR= ../../include       
+LDAP_LIBDIR= ../../libraries
+
+LIBRARY = libavl.a
+PROGRAMS       = testavl
+XLIBS = -lavl
+
+testavl:       $(LIBRARY) testavl.o
+       $(LTLINK) $(LDFLAGS) -o $@ testavl.o $(LIBS)
index 3b6c113ccc65622020cfdf060c8d492bd1bd5a7b..eb30049ef44aae764f7299d5aa1680fc2f0bcecf 100644 (file)
@@ -1,4 +1,5 @@
 /* avl.c - routines to implement an avl tree */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index bd6d35bf01edd5e1ea3e03be6ff0b610d06affdc..94540c304d60d8e7303fce95355dbcb113276818 100644 (file)
@@ -1,4 +1,5 @@
 /* testavl.c - Test Tim Howes AVL code */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
diff --git a/libraries/liblber/Makefile.in b/libraries/liblber/Makefile.in
new file mode 100644 (file)
index 0000000..4808224
--- /dev/null
@@ -0,0 +1,35 @@
+# $OpenLDAP$
+## Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+##
+## LIBLBER
+##
+
+LIBRARY = liblber.la
+XLIBRARY = ../liblber.a
+
+SRCS= assert.c decode.c encode.c io.c bprint.c \
+       memory.c options.c sockbuf.c
+OBJS= assert.lo decode.lo encode.lo io.lo bprint.lo \
+       memory.lo options.lo sockbuf.lo
+XSRCS= version.c
+
+PROGRAMS= dtest etest idtest
+
+LDAP_INCDIR= ../../include       
+LDAP_LIBDIR= ../../libraries       
+
+XLIBS = -llber
+XXLIBS = 
+
+dtest:    $(LIBRARY) dtest.o
+       $(LTLINK) $(LDFLAGS) -o $@ dtest.o $(LIBS)
+etest:  $(LIBRARY) etest.o
+       $(LTLINK) $(LDFLAGS) -o $@ etest.o $(LIBS)
+idtest:  $(LIBRARY) idtest.o
+       $(LTLINK) $(LDFLAGS) -o $@ idtest.o $(LIBS)
+
+install-local: FORCE
+       -$(MKDIR) $(libdir)
+       $(LTINSTALL) $(INSTALLFLAGS) -m 644 $(LIBRARY) $(libdir)
+
index f71df23435e59a860432a61489e0d1bf4e10d309..50b70dd53b1a0cfba52da14ee357ef7d60d375bd 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
index e4b6fd27ea2b9ee5def85b5ab39d3c5eef286e19..eb8808563cb793b781ae7a11edf8cddc14d71d9f 100644 (file)
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include "lber.h"
+
+#include <ac/ctype.h>
+#include <ac/stdarg.h>
+#include <ac/string.h>
+
+#undef LDAP_F_PRE
+#define LDAP_F_PRE LDAP_F_EXPORT
+
+#include "lber-int.h"
+
+/*
+ * Print stuff
+ */
+static void
+ber_error_print( char *data )
+{
+       assert( data != NULL );
+
+       fputs( data, stderr );
+       fflush( stderr );
+}
+
+BER_LOG_PRINT_FN ber_pvt_log_print = ber_error_print;
+
+/*
+ * lber log 
+ */
+
+static int ber_log_check( int errlvl, int loglvl )
+{
+       return errlvl & loglvl ? 1 : 0;
+}
+
+int ber_pvt_log_printf( int errlvl, int loglvl, const char *fmt, ... )
+{
+       char buf[ 1024 ];
+       va_list ap;
+
+       assert( fmt != NULL );
+
+       if ( !ber_log_check( errlvl, loglvl )) {
+               return 0;
+       }
+
+       va_start( ap, fmt );
+
+#ifdef HAVE_VSNPRINTF
+       buf[sizeof(buf) - 1] = '\0';
+       vsnprintf( buf, sizeof(buf)-1, fmt, ap );
+#elif HAVE_VSPRINTF
+       vsprintf( buf, fmt, ap ); /* hope it's not too long */
+#else
+       /* use doprnt() */
+#error "vsprintf() required."
+#endif
+
+       va_end(ap);
+
+       (*ber_pvt_log_print)( buf );
+       return 1;
+}
+
+static int ber_log_puts(int errlvl, int loglvl, char *buf)
+{
+       assert( buf != NULL );
+
+       if ( !ber_log_check( errlvl, loglvl )) {
+               return 0;
+       }
+
+       (*ber_pvt_log_print)( buf );
+       return 1;
+}
 
 /*
  * Print arbitrary stuff, for debugging.
  */
 
-#ifdef LDAP_DEBUG
+int
+ber_log_bprint(int errlvl,
+       int loglvl,
+       const char *data,
+       ber_len_t len )
+{
+       assert( data != NULL );
 
-#ifndef NO_USERINTERFACE
-#define BPLEN  48
+       if ( !ber_log_check( errlvl, loglvl )) {
+               return 0;
+       }
+
+       ber_bprint(data, len);
+       return 1;
+}
 
 void
-lber_bprint( char *data, int len )
+ber_bprint(
+       LDAP_CONST char *data,
+       ber_len_t len )
 {
-    static char        hexdig[] = "0123456789abcdef";
+    static const char  hexdig[] = "0123456789abcdef";
+#define BPLEN  48
     char       out[ BPLEN ];
+    char       buf[ BPLEN + sizeof("\t%s\n") ];
     int                i = 0;
 
+       assert( data != NULL );
+
     memset( out, 0, BPLEN );
     for ( ;; ) {
        if ( len < 1 ) {
-           fprintf( stderr, "\t%s\n", ( i == 0 ) ? "(end)" : out );
+           sprintf( buf, "\t%s\n", ( i == 0 ) ? "(end)" : out );
+               (*ber_pvt_log_print)( buf );
            break;
        }
 
-#ifndef HEX
+#ifndef LDAP_HEX
        if ( isgraph( (unsigned char)*data )) {
            out[ i ] = ' ';
            out[ i+1 ] = *data;
        } else {
 #endif
-           out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
-           out[ i+1 ] = hexdig[ *data & 0x0f ];
-#ifndef HEX
+           out[ i ] = hexdig[ ( *data & 0xf0U ) >> 4 ];
+           out[ i+1 ] = hexdig[ *data & 0x0fU ];
+#ifndef LDAP_HEX
        }
 #endif
        i += 2;
@@ -42,7 +138,9 @@ lber_bprint( char *data, int len )
        data++;
 
        if ( i > BPLEN - 2 ) {
-           fprintf( stderr, "\t%s\n", out );
+               char data[128 + BPLEN];
+           sprintf( data, "\t%s\n", out );
+               (*ber_pvt_log_print)(data);
            memset( out, 0, BPLEN );
            i = 0;
            continue;
@@ -50,11 +148,96 @@ lber_bprint( char *data, int len )
        out[ i++ ] = ' ';
     }
 }
-#else /* NO_USERINTERFACE */
+
+int
+ber_log_dump(
+       int errlvl,
+       int loglvl,
+       const BerElement *ber,
+       int inout )
+{
+       assert( ber != NULL );
+       assert( BER_VALID( ber ) );
+
+       if ( !ber_log_check( errlvl, loglvl )) {
+               return 0;
+       }
+
+       ber_dump(ber, inout);
+       return 1;
+}
+
 void
-lber_bprint( char *data, int len )
+ber_dump(
+       LDAP_CONST BerElement *ber,
+       int inout )
+{
+       char buf[132];
+
+       assert( ber != NULL );
+       assert( BER_VALID( ber ) );
+
+       sprintf( buf, "ber_dump: buf 0x%lx, ptr 0x%lx, end 0x%lx\n",
+           (long) ber->ber_buf,
+               (long) ber->ber_ptr,
+               (long) ber->ber_end );
+
+       (*ber_pvt_log_print)( buf );
+
+       if ( inout == 1 ) {
+               sprintf( buf, "          current len %ld, contents:\n",
+                   (long) (ber->ber_end - ber->ber_ptr) );
+               ber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr );
+
+       } else {
+               sprintf( buf, "          current len %ld, contents:\n",
+                   (long) (ber->ber_ptr - ber->ber_buf) );
+
+               ber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf );
+       }
+}
+
+int
+ber_log_sos_dump(
+       int errlvl,
+       int loglvl,
+       const Seqorset *sos )
 {
+       assert( sos != NULL );
+
+       if ( !ber_log_check( errlvl, loglvl )) {
+               return 0;
+       }
+
+       ber_sos_dump( sos );
+       return 1;
 }
-#endif /* NO_USERINTERFACE */
 
-#endif
+void
+ber_sos_dump(
+       LDAP_CONST Seqorset *sos )
+{
+       char buf[132];
+
+       assert( sos != NULL );
+
+       (*ber_pvt_log_print)( "*** sos dump ***\n" );
+
+       while ( sos != NULL ) {
+               sprintf( buf, "ber_sos_dump: clen %ld first 0x%lx ptr 0x%lx\n",
+                   (long) sos->sos_clen,
+                       (long) sos->sos_first,
+                       (long) sos->sos_ptr );
+               (*ber_pvt_log_print)( buf );
+
+               sprintf( buf, "              current len %ld contents:\n",
+                   (long) (sos->sos_ptr - sos->sos_first) );
+               (*ber_pvt_log_print)( buf );
+
+               ber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first );
+
+               sos = sos->sos_next;
+       }
+
+       (*ber_pvt_log_print)( "*** end dump ***\n" );
+}
index 6b029b3cd62216ef8e138db0530214ff711de333..e2c204d7937e0abc55a836512e6ce0370b27ac41 100644 (file)
@@ -1,4 +1,5 @@
 /* decode.c - ber input decoding routines */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -486,21 +487,11 @@ ber_next_element(
 
 /* VARARGS */
 ber_tag_t
-ber_scanf
-#if HAVE_STDARG
-       ( BerElement *ber,
+ber_scanf ( BerElement *ber,
        LDAP_CONST char *fmt,
        ... )
-#else
-       ( va_alist )
-va_dcl
-#endif
 {
        va_list         ap;
-#ifndef HAVE_STDARG
-       BerElement      *ber;
-       char            *fmt;
-#endif
        LDAP_CONST char         *fmt_reset;
        char            *last;
        char            *s, **ss, ***sss;
@@ -512,13 +503,7 @@ va_dcl
        ber_tag_t       rc, tag;
        ber_len_t       len;
 
-#ifdef HAVE_STDARG
        va_start( ap, fmt );
-#else
-       va_start( ap );
-       ber = va_arg( ap, BerElement * );
-       fmt = va_arg( ap, char * );
-#endif
 
        assert( ber != NULL );
        assert( fmt != NULL );
@@ -672,13 +657,7 @@ va_dcl
             * Error.  Reclaim malloced memory that was given to the caller.
             * Set allocated pointers to NULL, "data length" outvalues to 0.
             */
-#ifdef HAVE_STDARG
            va_start( ap, fmt );
-#else
-           va_start( ap );
-           (void) va_arg( ap, BerElement * );
-           (void) va_arg( ap, char * );
-#endif
 
            for ( ; fmt_reset < fmt; fmt_reset++ ) {
                switch ( *fmt_reset ) {
index 30d803eb93a70076b2687218c500ad6dbdfcb839..749958b1ee708640bb02095eb34f3fd68242d251 100644 (file)
@@ -1,4 +1,5 @@
 /* dtest.c - lber decoding test program */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 0d95239544bb1321d1d32dd280b82405f5a9bc4c..ef515a3369718935030921256c877f41d5a7fea5 100644 (file)
@@ -1,4 +1,5 @@
 /* encode.c - ber output encoding routines */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -619,40 +620,22 @@ ber_put_set( BerElement *ber )
 
 /* VARARGS */
 int
-ber_printf
-#ifdef HAVE_STDARG
-       ( BerElement *ber,
-       LDAP_CONST char *fmt,
-       ... )
-#else
-       ( va_alist )
-va_dcl
-#endif
+ber_printf( BerElement *ber, LDAP_CONST char *fmt, ... )
 {
        va_list         ap;
-#ifndef HAVE_STDARG
-       BerElement      *ber;
-       char            *fmt;
-#endif
        char            *s, **ss;
        struct berval   *bv, **bvp;
        int             rc;
        ber_int_t       i;
        ber_len_t       len;
 
-#ifdef HAVE_STDARG
-       va_start( ap, fmt );
-#else
-       va_start( ap );
-       ber = va_arg( ap, BerElement * );
-       fmt = va_arg( ap, char * );
-#endif
-
        assert( ber != NULL );
        assert( fmt != NULL );
 
        assert( BER_VALID( ber ) );
 
+       va_start( ap, fmt );
+
        for ( rc = 0; *fmt && rc != -1; fmt++ ) {
                switch ( *fmt ) {
                case '!': { /* hook */
index 50ac00d4bfb8f46dd17559f001a62f2b8b663d8f..9d235b8554e3cc534843d7942f8847616d39d1e6 100644 (file)
 /* test.c - lber encoding test program */
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* Portions
  * Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include <unix.h>
-#include <fcntl.h>
+
+#include <ac/stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_CONSOLE_H
 #include <console.h>
-#else /* MACOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* MACOS */
+#endif /* HAVE_CONSOLE_H */
+
 #include "lber.h"
 
-static usage( char *name )
+static void usage( char *name )
 {
        fprintf( stderr, "usage: %s fmtstring\n", name );
 }
 
+static char* getbuf() {
+       char *p;
+       static char buf[128];
+
+       if ( fgets( buf, sizeof(buf), stdin ) == NULL )
+               return NULL;
+
+       if ( (p = strchr( buf, '\n' )) != NULL )
+               *p = '\0';
+
+       return buf;
+}
+
+int
 main( int argc, char **argv )
 {
-       int             i, num, len;
-       char            *s, *p;
-       Seqorset        *sos = NULLSEQORSET;
+       char    *s;
+
+       int                     fd, rc;
        BerElement      *ber;
-       Sockbuf         sb;
-       extern char     *optarg;
+       Sockbuf         *sb;
+
+       /* enable debugging */
+       int ival = -1;
+       ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &ival );
 
        if ( argc < 2 ) {
                usage( argv[0] );
-               exit( 1 );
+               return( EXIT_FAILURE );
        }
 
-       bzero( &sb, sizeof(sb) );
-       sb.sb_sd = 1;
-       sb.sb_ber.ber_buf = NULL;
-
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
        ccommand( &argv );
        cshow( stdout );
 
-       if (( sb.sb_sd = open( "lber-test", O_WRONLY|O_CREAT|O_TRUNC|O_BINARY ))
+       if (( fd = open( "lber-test", O_WRONLY|O_CREAT|O_TRUNC|O_BINARY ))
                < 0 ) {
            perror( "open" );
-           exit( 1 );
+           return( EXIT_FAILURE );
        }
-#endif /* MACOS */
 
-       if ( (ber = ber_alloc()) == NULLBER ) {
-               perror( "ber_alloc" );
-               exit( 1 );
+#else
+       fd = fileno(stdout);
+#endif
+
+       sb = ber_sockbuf_alloc_fd( fd );
+
+       if( sb == NULL ) {
+               perror( "ber_sockbuf_alloc_fd" );
+               return( EXIT_FAILURE );
        }
 
-       num = 7;
-       if ( ber_printf( ber, "{ti}", 0x1f44, num ) == -1 ) {
-               fprintf( stderr, "ber_printf returns -1" );
-               exit( 1 );
+       if ( (ber = ber_alloc_t( LBER_USE_DER )) == NULL ) {
+               perror( "ber_alloc" );
+               return( EXIT_FAILURE );
        }
 
-       if ( ber_flush( &sb, ber, 1 ) == -1 ) {
-               perror( "ber_flush" );
-               exit( 1 );
+       fprintf(stderr, "encode: start\n" );
+       if( ber_printf( ber, "{" /*}*/ ) ) {
+               perror( "ber_printf {" /*}*/ );
+               return( EXIT_FAILURE );
        }
-#ifdef notdef
+
        for ( s = argv[1]; *s; s++ ) {
-               if ( fgets( buf, sizeof(buf), stdin ) == NULL )
-                       break;
-               if ( (p = strchr( buf, '\n' )) != NULL )
-                       *p = '\0';
+               char *buf;
+               char fmt[2];
 
+               fmt[0] = *s;
+               fmt[1] = '\0';
+
+               fprintf(stderr, "encode: %s\n", fmt );
                switch ( *s ) {
                case 'i':       /* int */
                case 'b':       /* boolean */
-                       i = atoi( buf );
-                       if ( ber_printf( ber, "i", i ) == -1 ) {
-                               fprintf( stderr, "ber_printf i\n" );
-                               exit( 1 );
-                       }
-                       break;
-
                case 'e':       /* enumeration */
-                       i = va_arg( ap, int );
-                       rc = ber_put_enum( ber, i, (char)ber->ber_tag );
+                       buf = getbuf();
+                       rc = ber_printf( ber, fmt, atoi(buf) );
                        break;
 
                case 'n':       /* null */
-                       rc = ber_put_null( ber, (char)ber->ber_tag );
+               case '{':       /* begin sequence */
+               case '}':       /* end sequence */
+               case '[':       /* begin set */
+               case ']':       /* end set */
+                       rc = ber_printf( ber, fmt );
                        break;
 
                case 'o':       /* octet string (non-null terminated) */
-                       s = va_arg( ap, char * );
-                       len = va_arg( ap, int );
-                       rc = ber_put_ostring( ber, s, len, (char)ber->ber_tag );
-                       break;
-
-               case 's':       /* string */
-                       s = va_arg( ap, char * );
-                       rc = ber_put_string( ber, s, (char)ber->ber_tag );
-                       break;
-
                case 'B':       /* bit string */
-                       s = va_arg( ap, char * );
-                       len = va_arg( ap, int );        /* in bits */
-                       rc = ber_put_bitstring( ber, s, len, (char)ber->ber_tag );
+                       buf = getbuf();
+                       rc = ber_printf( ber, fmt, buf, strlen(buf) );
                        break;
 
+               case 's':       /* string */
                case 't':       /* tag for the next element */
-                       ber->ber_tag = va_arg( ap, int );
-                       ber->ber_usertag = 1;
-                       break;
-
-               case 'v':       /* vector of strings */
-                       if ( (ss = va_arg( ap, char ** )) == NULL )
-                               break;
-                       for ( i = 0; ss[i] != NULL; i++ ) {
-                               if ( (rc = ber_put_string( ber, ss[i],
-                                   (char)ber->ber_tag )) == -1 )
-                                       break;
-                       }
-                       break;
-
-               case 'V':       /* sequences of strings + lengths */
-                       if ( (bv = va_arg( ap, struct berval ** )) == NULL )
-                               break;
-                       for ( i = 0; bv[i] != NULL; i++ ) {
-                               if ( (rc = ber_put_ostring( ber, bv[i]->bv_val,
-                                   bv[i]->bv_len, (char)ber->ber_tag )) == -1 )
-                                       break;
-                       }
-                       break;
-
-               case '{':       /* begin sequence */
-                       rc = ber_start_seq( ber, (char)ber->ber_tag );
-                       break;
-
-               case '}':       /* end sequence */
-                       rc = ber_put_seqorset( ber );
-                       break;
-
-               case '[':       /* begin set */
-                       rc = ber_start_set( ber, (char)ber->ber_tag );
-                       break;
-
-               case ']':       /* end set */
-                       rc = ber_put_seqorset( ber );
+                       buf = getbuf();
+                       rc = ber_printf( ber, fmt, buf );
                        break;
 
                default:
-#ifndef NO_USERINTERFACE
-                       fprintf( stderr, "unknown fmt %c\n", *fmt );
-#endif /* NO_USERINTERFACE */
+                       fprintf( stderr, "encode: unknown fmt %c\n", *fmt );
                        rc = -1;
                        break;
                }
+
+               if( rc == -1 ) {
+                       perror( "ber_printf" );
+                       return( EXIT_FAILURE );
                }
        }
 
-#endif
+       fprintf(stderr, "encode: end\n" );
+       if( ber_printf( ber, /*{*/ "}" ) == -1 ) {
+               perror( /*{*/ "ber_printf }" );
+               return( EXIT_FAILURE );
+       }
+
+       if ( ber_flush( sb, ber, 1 ) == -1 ) {
+               perror( "ber_flush" );
+               return( EXIT_FAILURE );
+       }
 
-       return( 0 );
+       ber_sockbuf_free( sb );
+       return( EXIT_SUCCESS );
 }
index 83d8ec7ace3d1aa665a12abe5e2e9019c1208f4b..2bc6822971bb27e95d6713facf7c6df12ceaac79 100644 (file)
@@ -1,4 +1,5 @@
 /* idtest.c - ber decoding test program using isode libraries */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 081f386794a6a08b2ed5ca4225bf200556ca7a4f..830c16e5f01f66cdb4b45b36379c9ae0f2b828c0 100644 (file)
@@ -1,5 +1,10 @@
 /* io.c - ber general i/o routines */
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* Portions
  * Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
  *
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <ctype.h>
-
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#endif /* DOS || _WIN32 */
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined(NeXT) || defined(VMS)
-#include <stdlib.h>
-#else /* next || vms */
-#include <malloc.h>
-#endif /* next || vms */
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#ifdef PCNFS
-#include <tklib.h>
-#endif /* PCNFS */
-#endif /* MACOS */
-
-#ifndef VMS
-#include <memory.h>
-#endif
-#include <string.h>
-#include "lber.h"
 
-#ifdef _WIN32
-#include <winsock.h>
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/errno.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_IO_H
 #include <io.h>
-#endif /* _WIN32 */
-
-#ifdef NEEDPROTOS
-static int ber_realloc( BerElement *ber, unsigned long len );
-static int ber_filbuf( Sockbuf *sb, long len );
-static long BerRead( Sockbuf *sb, char *buf, long len );
-#ifdef PCNFS
-static int BerWrite( Sockbuf *sb, char *buf, long len );
-#endif /* PCNFS */
-#else
-int ber_filbuf();
-long BerRead();
-static int ber_realloc();
-#endif /* NEEDPROTOS */
-
-#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 MACOS
-/*
- * 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 /* MACOS */
-#ifdef DOS
-#ifdef PCNFS
-/*
- * PCNFS (under DOS)
- */
-#define read( s, b, l ) recv( s, b, l, 0 )
-#define BerWrite( s, b, l ) send( s->sb_sd, b, (int) l, 0 )
-#endif /* PCNFS */
-#ifdef NCSA
-/*
- * NCSA Telnet TCP/IP stack (under DOS)
- */
-#define read( s, b, l ) nread( s, b, l )
-#define BerWrite( s, b, l ) netwrite( s->sb_sd, b, l )
-#endif /* NCSA */
-#ifdef WINSOCK
-/*
- * Windows Socket API (under DOS/Windows 3.x)
- */
-#define read( s, b, l ) recv( s, b, l, 0 )
-#define BerWrite( s, b, l ) send( s->sb_sd, b, l, 0 )
-#endif /* WINSOCK */
-#else /* DOS */
-#ifdef _WIN32
-/*
- * 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 */
-#ifdef VMS
-/*
- * VMS -- each write must be 64K or smaller
- */
-#define MAX_WRITE 65535
-#define BerWrite( sb, b, l ) write( sb->sb_sd, b, (l<MAX_WRITE)? l : MAX_WRITE)
-#else /* VMS */
-/*
- * everything else (Unix/BSD 4.3 socket API)
- */
-#define BerWrite( sb, b, l )   write( sb->sb_sd, b, l )
-#endif /* VMS */
-#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 /* DOS */
-#endif /* MACOS */
-
-#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 */
+#endif
 
-#define EXBUFSIZ       1024
+#undef LDAP_F_PRE
+#define LDAP_F_PRE LDAP_F_EXPORT
 
-int
-ber_filbuf( Sockbuf *sb, long len )
-{
-       short   rc;
-#ifdef CLDAP
-       int     addrlen;
-#endif /* CLDAP */
-
-       if ( sb->sb_ber.ber_buf == NULL ) {
-               if ( (sb->sb_ber.ber_buf = (char *) malloc( READBUFSIZ )) ==
-                   NULL )
-                       return( -1 );
-               sb->sb_ber.ber_ptr = sb->sb_ber.ber_buf;
-               sb->sb_ber.ber_end = sb->sb_ber.ber_buf;
-       }
+#include "lber-int.h"
 
-       if ( sb->sb_naddr > 0 ) {
-#ifdef CLDAP
-               rc = udp_read(sb, sb->sb_ber.ber_buf, READBUFSIZ, addrlen );
-#ifdef LDAP_DEBUG
-               if ( lber_debug ) {
-                       fprintf( stderr, "ber_filbuf udp_read %d bytes\n",
-                               rc );
-                       if ( lber_debug > 1 && rc > 0 )
-                               lber_bprint( sb->sb_ber.ber_buf, rc );
-               }
-#endif /* LDAP_DEBUG */
-#else /* CLDAP */
-               rc = -1;
-#endif /* CLDAP */
-       } else {
-               rc = read( sb->sb_sd, sb->sb_ber.ber_buf,
-                   ((sb->sb_options & LBER_NO_READ_AHEAD) &&
-                   (len < READBUFSIZ)) ?
-                   len : READBUFSIZ );
-       }
+static ber_slen_t BerRead LDAP_P((
+       Sockbuf *sb,
+       char *buf,
+       ber_len_t len ));
 
-       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 );
-       }
+static int ber_realloc LDAP_P((
+       BerElement *ber,
+       ber_len_t len ));
 
-       return( -1 );
-}
+#define EXBUFSIZ       1024
 
+/* probably far too large... */
+#define MAX_BERBUFSIZE (128*1024)
 
-long
-BerRead( Sockbuf *sb, char *buf, long len )
+#if defined( DOS ) && !defined( _WIN32 ) && (MAX_BERBUFSIZE > 65535)
+# undef MAX_BERBUFSIZE
+# define MAX_BERBUFSIZE 65535
+#endif
+
+static ber_slen_t
+BerRead(
+       Sockbuf *sb,
+       char *buf,
+       ber_len_t len )
 {
-       int     c;
-       long    nread = 0;
+       ber_slen_t      c;
+       ber_slen_t      nread = 0;
+
+       assert( sb != NULL );
+       assert( buf != NULL );
+
+       assert( SOCKBUF_VALID( sb ) );
 
        while ( len > 0 ) {
-               if ( (c = bergetc( sb, len )) < 0 ) {
+               if ( (c = ber_pvt_sb_read( sb, buf, len )) <= 0 ) {
                        if ( nread > 0 )
                                break;
                        return( c );
                }
-               *buf++ = c;
-               nread++;
-               len--;
+               buf+= c;
+               nread+=c;
+               len-=c;
        }
 
        return( nread );
 }
 
-
-long
-ber_read( BerElement *ber, char *buf, unsigned long len )
+ber_slen_t
+ber_read(
+       BerElement *ber,
+       char *buf,
+       ber_len_t len )
 {
-       unsigned long   actuallen, nleft;
+       ber_len_t       actuallen, nleft;
+
+       assert( ber != NULL );
+       assert( buf != NULL );
+
+       assert( BER_VALID( ber ) );
 
        nleft = ber->ber_end - ber->ber_ptr;
        actuallen = nleft < len ? nleft : len;
 
-       SAFEMEMCPY( buf, ber->ber_ptr, (size_t)actuallen );
+       SAFEMEMCPY( buf, ber->ber_ptr, actuallen );
 
        ber->ber_ptr += actuallen;
 
-       return( (long)actuallen );
+       return( (ber_slen_t) actuallen );
 }
 
-long
-ber_write( BerElement *ber, char *buf, unsigned long len, int nosos )
+ber_slen_t
+ber_write(
+       BerElement *ber,
+       LDAP_CONST char *buf,
+       ber_len_t len,
+       int nosos )
 {
+       assert( ber != NULL );
+       assert( buf != NULL );
+
+       assert( BER_VALID( ber ) );
+
        if ( nosos || ber->ber_sos == NULL ) {
                if ( ber->ber_ptr + len > ber->ber_end ) {
                        if ( ber_realloc( ber, len ) != 0 )
@@ -223,7 +126,8 @@ ber_write( BerElement *ber, char *buf, unsigned long len, int nosos )
                }
                SAFEMEMCPY( ber->ber_ptr, buf, (size_t)len );
                ber->ber_ptr += len;
-               return( len );
+               return( (ber_slen_t) len );
+
        } else {
                if ( ber->ber_sos->sos_ptr + len > ber->ber_end ) {
                        if ( ber_realloc( ber, len ) != 0 )
@@ -232,30 +136,35 @@ ber_write( BerElement *ber, char *buf, unsigned long len, int nosos )
                SAFEMEMCPY( ber->ber_sos->sos_ptr, buf, (size_t)len );
                ber->ber_sos->sos_ptr += len;
                ber->ber_sos->sos_clen += len;
-               return( len );
+               return( (ber_slen_t) len );
        }
 }
 
 static int
-ber_realloc( BerElement *ber, unsigned long len )
+ber_realloc( BerElement *ber, ber_len_t len )
 {
-       unsigned long   need, have, total;
+       ber_len_t       need, have, total;
        Seqorset        *s;
        long            off;
        char            *oldbuf;
 
+       assert( ber != NULL );
+       assert( len > 0 );
+
+       assert( BER_VALID( ber ) );
+
        have = (ber->ber_end - ber->ber_buf) / EXBUFSIZ;
        need = (len < EXBUFSIZ ? 1 : (len + (EXBUFSIZ - 1)) / EXBUFSIZ);
        total = have * EXBUFSIZ + need * EXBUFSIZ;
 
        oldbuf = ber->ber_buf;
 
+       ber->ber_buf = (char *) LBER_REALLOC( ber->ber_buf, total );
+       
        if ( ber->ber_buf == NULL ) {
-               if ( (ber->ber_buf = (char *) malloc( (size_t)total )) == NULL )
-                       return( -1 );
-       } else if ( (ber->ber_buf = (char *) realloc( ber->ber_buf,
-           (size_t)total )) == NULL )
+               ber->ber_buf = oldbuf;
                return( -1 );
+       }
 
        ber->ber_end = ber->ber_buf + total;
 
@@ -268,7 +177,7 @@ ber_realloc( BerElement *ber, unsigned long len )
        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 ) {
+               for ( s = ber->ber_sos; s != NULL; s = s->sos_next ) {
                        off = s->sos_first - oldbuf;
                        s->sos_first = ber->ber_buf + off;
 
@@ -283,62 +192,67 @@ ber_realloc( BerElement *ber, unsigned long len )
 void
 ber_free( BerElement *ber, int freebuf )
 {
+#ifdef LDAP_MEMORY_DEBUG
+       assert( ber != NULL );
+#endif
+
+       if( ber == NULL ) {
+               return;
+       }
+
+       assert( BER_VALID( ber ) );
+
        if ( freebuf && ber->ber_buf != NULL )
-               free( ber->ber_buf );
-       free( (char *) ber );
+               LBER_FREE( ber->ber_buf );
+
+       ber->ber_buf = NULL;
+       ber->ber_valid = LBER_UNINITIALIZED;
+
+       LBER_FREE( (char *) ber );
 }
 
 int
 ber_flush( Sockbuf *sb, BerElement *ber, int freeit )
 {
-       long    nwritten, towrite, rc;
+       ber_len_t       nwritten, towrite;
+       ber_slen_t      rc;     
+
+       assert( sb != NULL );
+       assert( ber != NULL );
+
+       assert( SOCKBUF_VALID( ber ) );
+       assert( BER_VALID( ber ) );
 
        if ( ber->ber_rwptr == NULL ) {
                ber->ber_rwptr = ber->ber_buf;
        }
        towrite = ber->ber_ptr - ber->ber_rwptr;
 
-#ifdef LDAP_DEBUG
-       if ( lber_debug ) {
-               fprintf( stderr, "ber_flush: %ld bytes to sd %ld%s\n", towrite,
-                   sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)"
+       if ( sb->sb_debug ) {
+               ber_log_printf( LDAP_DEBUG_ANY, sb->sb_debug,
+                       "ber_flush: %ld bytes to sd %ld%s\n", towrite,
+                   (long) sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)"
                    : "" );
-               if ( lber_debug > 1 )
-                       lber_bprint( ber->ber_rwptr, towrite );
+               ber_log_bprint( LDAP_DEBUG_PACKETS, sb->sb_debug,
+                       ber->ber_rwptr, towrite );
        }
-#endif
-#if !defined(MACOS) && !defined(DOS)
+
+#if HAVE_WRITE
        if ( sb->sb_options & (LBER_TO_FILE | LBER_TO_FILE_ONLY) ) {
-               rc = write( sb->sb_fd, ber->ber_buf, towrite );
+               rc = write( sb->sb_fd, ber->ber_rwptr, towrite );
                if ( sb->sb_options & LBER_TO_FILE_ONLY ) {
+                       if ( freeit )
+                               ber_free( ber, 1 );
                        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( MACOS ) && !defined( DOS )
-                           errno = EMSGSIZE;
-#endif
-                           return( -1 );
-                       }
-               } else {
-                       if ( (rc = BerWrite( sb, ber->ber_rwptr,
-                           (size_t) towrite )) <= 0 ) {
-                               return( -1 );
-                       }
+               rc = ber_pvt_sb_write( sb, ber->ber_rwptr, towrite );
+               if (rc<=0) {
+                       return -1;
                }
                towrite -= rc;
                nwritten += rc;
@@ -356,118 +270,191 @@ ber_alloc_t( int options )
 {
        BerElement      *ber;
 
-       if ( (ber = (BerElement *) calloc( 1, sizeof(BerElement) )) == NULLBER )
-               return( NULLBER );
+    ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+       ber = (BerElement *) LBER_CALLOC( 1, sizeof(BerElement) );
+
+       if ( ber == NULL )
+               return( NULL );
+
+       ber->ber_valid = LBER_VALID_BERELEMENT;
        ber->ber_tag = LBER_DEFAULT;
        ber->ber_options = options;
+       ber->ber_debug = ber_int_debug;
 
+       assert( BER_VALID( ber ) );
        return( ber );
 }
 
 BerElement *
-ber_alloc()
+ber_alloc( void )      /* deprecated */
 {
        return( ber_alloc_t( 0 ) );
 }
 
 BerElement *
-der_alloc()
+der_alloc( void )      /* deprecated */
 {
        return( ber_alloc_t( LBER_USE_DER ) );
 }
 
 BerElement *
-ber_dup( BerElement *ber )
+ber_dup( LDAP_CONST BerElement *ber )
 {
        BerElement      *new;
 
-       if ( (new = ber_alloc()) == NULLBER )
-               return( NULLBER );
+       assert( ber != NULL );
+       assert( BER_VALID( ber ) );
+
+       if ( (new = ber_alloc_t( ber->ber_options )) == NULL ) {
+               return( NULL );
+       }
 
        *new = *ber;
 
+       assert( BER_VALID( new ) );
        return( new );
 }
 
 
+/* OLD U-Mich ber_init() */
 void
-ber_init( BerElement *ber, int options )
+ber_init_w_nullc( BerElement *ber, int options )
 {
+       assert( ber != NULL );
+
+    ber_int_options.lbo_valid = LBER_INITIALIZED;
+
        (void) memset( (char *)ber, '\0', sizeof( BerElement ));
+       ber->ber_valid = LBER_VALID_BERELEMENT;
        ber->ber_tag = LBER_DEFAULT;
-       ber->ber_options = options;
-}
+       ber->ber_options = (char) options;
+       ber->ber_debug = ber_int_debug;
 
+       assert( BER_VALID( ber ) );
+}
 
-void
-ber_reset( BerElement *ber, int was_writing )
+/* New C-API ber_init() */
+/* This function constructs a BerElement containing a copy
+** of the data in the bv argument.
+*/
+BerElement *
+ber_init( struct berval *bv )
 {
-       if ( was_writing ) {
-               ber->ber_end = ber->ber_ptr;
-               ber->ber_ptr = ber->ber_buf;
-       } else {
-               ber->ber_ptr = ber->ber_end;
+       BerElement *ber;
+
+       assert( bv != NULL );
+
+    ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+       if ( bv == NULL ) {
+               return NULL;
        }
 
-       ber->ber_rwptr = NULL;
-}
+       ber = ber_alloc_t( 0 );
 
+       if( ber == NULL ) {
+               /* allocation failed */
+               return ( NULL );
+       }
 
-#ifdef LDAP_DEBUG
+       /* copy the data */
+       if ( ( (ber_len_t) ber_write ( ber, bv->bv_val, bv->bv_len, 0 )) != bv->bv_len ) {
+               /* write failed, so free and return NULL */
+               ber_free( ber, 1 );
+               return( NULL );
+       }
 
-void
-ber_dump( BerElement *ber, int inout )
+       ber_reset( ber, 1 );    /* reset the pointer to the start of the buffer */
+
+       return ( ber );
+}
+
+/* New C-API ber_flatten routine */
+/* This routine allocates a struct berval whose contents are a BER
+** encoding taken from the ber argument.  The bvPtr pointer pointers to
+** the returned berval.
+*/
+int ber_flatten(
+       LDAP_CONST BerElement *ber,
+       struct berval **bvPtr)
 {
-       fprintf( stderr, "ber_dump: buf 0x%lx, ptr 0x%lx, end 0x%lx\n",
-           ber->ber_buf, ber->ber_ptr, ber->ber_end );
-       if ( inout == 1 ) {
-               fprintf( stderr, "          current len %ld, contents:\n",
-                   ber->ber_end - ber->ber_ptr );
-               lber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr );
+       struct berval *bv;
+       assert( bvPtr != NULL );
+
+    ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+       if(bvPtr == NULL) {
+               return( -1 );
+       }
+
+       if ( (bv = LBER_MALLOC( sizeof(struct berval))) == NULL ) {
+               return( -1 );
+       }
+
+       if ( ber == NULL ) {
+               /* ber is null, create an empty berval */
+               bv->bv_val = NULL;
+               bv->bv_len = 0;
+
        } else {
-               fprintf( stderr, "          current len %ld, contents:\n",
-                   ber->ber_ptr - ber->ber_buf );
-               lber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf );
+               /* copy the berval */
+               ber_len_t len = ber->ber_ptr - ber->ber_buf;
+
+               if ( (bv->bv_val = (char *) LBER_MALLOC( len + 1 )) == NULL ) {
+                       ber_bvfree( bv );
+                       return( -1 );
+               }
+
+               SAFEMEMCPY( bv->bv_val, ber->ber_buf, len );
+               bv->bv_val[len] = '\0';
+               bv->bv_len = len;
        }
+    
+       *bvPtr = bv;
+       return( 0 );
 }
 
 void
-ber_sos_dump( Seqorset *sos )
+ber_reset( BerElement *ber, int was_writing )
 {
-       fprintf( stderr, "*** sos dump ***\n" );
-       while ( sos != NULLSEQORSET ) {
-               fprintf( stderr, "ber_sos_dump: clen %ld first 0x%lx ptr 0x%lx\n",
-                   sos->sos_clen, sos->sos_first, sos->sos_ptr );
-               fprintf( stderr, "              current len %ld contents:\n",
-                   sos->sos_ptr - sos->sos_first );
-               lber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first );
-
-               sos = sos->sos_next;
+       assert( ber != NULL );
+       assert( BER_VALID( ber ) );
+
+       if ( was_writing ) {
+               ber->ber_end = ber->ber_ptr;
+               ber->ber_ptr = ber->ber_buf;
+       } else {
+               ber->ber_ptr = ber->ber_end;
        }
-       fprintf( stderr, "*** end dump ***\n" );
-}
 
-#endif
+       ber->ber_rwptr = NULL;
+}
 
+#if 0
 /* return the tag - LBER_DEFAULT returned means trouble */
-static unsigned long
+static ber_tag_t
 get_tag( Sockbuf *sb )
 {
        unsigned char   xbyte;
-       unsigned long   tag;
+       ber_tag_t       tag;
        char            *tagp;
-       int             i;
+       unsigned int    i;
+
+       assert( sb != NULL );
+       assert( SOCKBUF_VALID( sb ) );
 
-       if ( BerRead( sb, (char *) &xbyte, 1 ) != 1 )
+       if ( ber_pvt_sb_read( sb, (char *) &xbyte, 1 ) != 1 )
                return( LBER_DEFAULT );
 
        if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK )
-               return( (unsigned long) xbyte );
+               return( (ber_tag_t) xbyte );
 
        tagp = (char *) &tag;
        tagp[0] = xbyte;
-       for ( i = 1; i < sizeof(long); i++ ) {
-               if ( BerRead( sb, (char *) &xbyte, 1 ) != 1 )
+       for ( i = 1; i < sizeof(ber_tag_t); i++ ) {
+               if ( ber_pvt_sb_read( sb, (char *) &xbyte, 1 ) != 1 )
                        return( LBER_DEFAULT );
 
                tagp[i] = xbyte;
@@ -477,25 +464,35 @@ get_tag( Sockbuf *sb )
        }
 
        /* tag too big! */
-       if ( i == sizeof(long) )
+       if ( i == sizeof(ber_tag_t) )
                return( LBER_DEFAULT );
 
        /* want leading, not trailing 0's */
-       return( tag >> (sizeof(long) - i - 1) );
+       return( tag >> (sizeof(ber_tag_t) - i - 1) );
 }
+#endif
 
-unsigned long
-ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber )
+/*
+ * A rewrite of ber_get_next that can safely be called multiple times 
+ * for the same packet. It will simply continue were it stopped until
+ * a full packet is read.
+ */
+
+ber_tag_t
+ber_get_next(
+       Sockbuf *sb,
+       ber_len_t *len,
+       BerElement *ber )
 {
-       unsigned long   tag, netlen, toread;
-       unsigned char   lc;
-       long            rc;
-       int             noctets, diff;
-
-#ifdef LDAP_DEBUG
-       if ( lber_debug )
-               fprintf( stderr, "ber_get_next\n" );
-#endif
+       assert( sb != NULL );
+       assert( len != NULL );
+       assert( ber != NULL );
+
+       assert( SOCKBUF_VALID( sb ) );
+       assert( BER_VALID( ber ) );
+
+       ber_log_printf( LDAP_DEBUG_TRACE, ber->ber_debug,
+               "ber_get_next\n" );
 
        /*
         * Any ber element looks like this: tag length contents.
@@ -508,94 +505,132 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber )
         *      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
-        */
-
-       if ( ber->ber_rwptr == NULL ) {
-               /*
-                * First, we read the tag.
-                */
-
-               if ( (tag = get_tag( sb )) == LBER_DEFAULT ) {
-                       return( LBER_DEFAULT );
-               }
-               ber->ber_tag = tag;
-
-               /*
-                * 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.
+       
+       if (ber->ber_rwptr == NULL) {
+               /* XXYYZ
+                * dtest does like this assert.
                 */
+               /* assert( ber->ber_buf == NULL ); */
+               ber->ber_rwptr = (char *) &ber->ber_tag;
+               ber->ber_tag = 0;
+       }
 
-               *len = netlen = 0;
-               if ( BerRead( sb, (char *) &lc, 1 ) != 1 ) {
-                       return( LBER_DEFAULT );
+#define PTR_IN_VAR( ptr, var )\
+(((ptr)>=(char *) &(var)) && ((ptr)< (char *) &(var)+sizeof(var)))
+       
+       if (PTR_IN_VAR(ber->ber_rwptr, ber->ber_tag)) {
+               if (ber->ber_rwptr == (char *) &ber->ber_tag) {
+                       if (ber_pvt_sb_read( sb, ber->ber_rwptr, 1)<=0)
+                               return LBER_DEFAULT;
+                       if ((ber->ber_rwptr[0] & LBER_BIG_TAG_MASK)
+                               != LBER_BIG_TAG_MASK) {
+                               ber->ber_tag = ber->ber_rwptr[0];
+                               ber->ber_rwptr = (char *) &ber->ber_usertag;
+                               goto get_lenbyte;
+                       }
+                       ber->ber_rwptr++;
                }
-               if ( lc & 0x80 ) {
-                       noctets = (lc & 0x7f);
-                       if ( noctets > sizeof(unsigned long) )
-                               return( LBER_DEFAULT );
-                       diff = sizeof(unsigned long) - noctets;
-                       if ( BerRead( sb, (char *) &netlen + diff, noctets ) !=
-                           noctets ) {
-                               return( LBER_DEFAULT );
+               do {
+                       /* reading the tag... */
+                       if (ber_pvt_sb_read( sb, ber->ber_rwptr, 1)<=0)
+                               return LBER_DEFAULT;
+                       if (! (ber->ber_rwptr[0] & LBER_MORE_TAG_MASK) ) {
+                               ber->ber_tag>>=sizeof(ber->ber_tag) -
+                                 ((char *) &ber->ber_tag - ber->ber_rwptr);
+                               ber->ber_rwptr = (char *) &ber->ber_usertag;
+                               goto get_lenbyte;
+                       }
+               } while (PTR_IN_VAR(ber->ber_rwptr,ber->ber_tag));
+               errno = ERANGE; /* this is a serious error. */
+               return LBER_DEFAULT;
+       }
+get_lenbyte:
+       if (ber->ber_rwptr==(char *) &ber->ber_usertag) {
+               unsigned char c;
+               if (ber_pvt_sb_read( sb, (char *) &c, 1)<=0)
+                       return LBER_DEFAULT;
+               if (c & 0x80U) {
+                       int len = c & 0x7fU;
+                       if ( (len==0) || ( len>sizeof( ber->ber_len ) ) ) {
+                               errno = ERANGE;
+                               return LBER_DEFAULT;
                        }
-                       *len = LBER_NTOHL( netlen );
+                       ber->ber_rwptr = (char *) &ber->ber_len +
+                               sizeof(ber->ber_len) - len;
+                       ber->ber_len = 0;
                } else {
-                       *len = lc;
-               }
-               ber->ber_len = *len;
-
-               /*
-                * 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 */
-                   return( LBER_DEFAULT );
+                       ber->ber_len = c;
+                       goto fill_buffer;
                }
-#endif /* DOS && !_WIN32 */
-
-               if ( ( sb->sb_options & LBER_MAX_INCOMING_SIZE ) &&
-                   *len > sb->sb_max_incoming ) {
-                       return( LBER_DEFAULT );
+       }
+       if (PTR_IN_VAR(ber->ber_rwptr, ber->ber_len)) {
+               ber_slen_t res;
+               ber_slen_t to_go;
+               to_go = (char *) &ber->ber_len + sizeof( ber->ber_len ) -
+                       ber->ber_rwptr;
+               assert( to_go > 0 );
+               res = ber_pvt_sb_read( sb, ber->ber_rwptr, to_go );
+               if (res <=0)
+                       return LBER_DEFAULT;
+               ber->ber_rwptr += res;
+               if (res==to_go) {
+                       /* convert length. */
+                       ber->ber_len = LBER_LEN_NTOH( ber->ber_len );
+                       goto fill_buffer;
+               } else {
+#if defined( EWOULDBLOCK )
+                       errno = EWOULDBLOCK;
+#elif defined( EAGAIN )
+                       errno = EAGAIN;
+#endif                 
+                       return LBER_DEFAULT;
                }
-
-               if ( (ber->ber_buf = (char *) malloc( (size_t)*len )) == NULL ) {
-                       return( LBER_DEFAULT );
+       }
+fill_buffer:   
+       /* now fill the buffer. */
+       if (ber->ber_buf==NULL) {
+               if (ber->ber_len > MAX_BERBUFSIZE) {
+                       errno = ERANGE;
+                       return LBER_DEFAULT;
                }
-               ber->ber_ptr = ber->ber_buf;
-               ber->ber_end = ber->ber_buf + *len;
+               ber->ber_buf = (char *) LBER_MALLOC( ber->ber_len );
+               if (ber->ber_buf==NULL)
+                       return LBER_DEFAULT;
                ber->ber_rwptr = ber->ber_buf;
+               ber->ber_ptr = ber->ber_buf;
+               ber->ber_end = ber->ber_buf + ber->ber_len;
        }
-
-       toread = (unsigned long)ber->ber_end - (unsigned long)ber->ber_rwptr;
-       do {
-               if ( (rc = BerRead( sb, ber->ber_rwptr, (long)toread )) <= 0 ) {
-                       return( LBER_DEFAULT );
+       if ((ber->ber_rwptr>=ber->ber_buf) && (ber->ber_rwptr<ber->ber_end)) {
+               ber_slen_t res;
+               ber_slen_t to_go;
+               
+               to_go = ber->ber_end - ber->ber_rwptr;
+               assert( to_go > 0 );
+               
+               res = ber_pvt_sb_read( sb, ber->ber_rwptr, to_go );
+               if (res<=0)
+                       return LBER_DEFAULT;
+               ber->ber_rwptr+=res;
+               
+               if (res<to_go) {
+#if defined( EWOULDBLOCK )
+                       errno = EWOULDBLOCK;
+#elif defined( EAGAIN )
+                       errno = EAGAIN;
+#endif                 
+                       return LBER_DEFAULT;
                }
-
-               toread -= rc;
-               ber->ber_rwptr += rc;
-       } while ( toread > 0 );
-
-#ifdef LDAP_DEBUG
-       if ( lber_debug ) {
-               fprintf( stderr, "ber_get_next: tag 0x%lx len %ld contents:\n",
-                   tag, ber->ber_len );
-               if ( lber_debug > 1 )
-                       ber_dump( ber, 1 );
+               
+               ber->ber_rwptr = NULL;
+               *len = ber->ber_len;
+               if ( ber->ber_debug ) {
+                       ber_log_printf( LDAP_DEBUG_TRACE, ber->ber_debug,
+                               "ber_get_next: tag 0x%lx len %ld contents:\n",
+                               ber->ber_tag, ber->ber_len );
+                       ber_log_dump( LDAP_DEBUG_BER, ber->ber_debug, ber, 1 );
+               }
+               return (ber->ber_tag);
        }
-#endif
-
-       *len = ber->ber_len;
-       ber->ber_rwptr = NULL;
-       return( ber->ber_tag );
+       assert( 0 ); /* ber structure is messed up ?*/
+       return LBER_DEFAULT;
 }
index c1a8675eba89af57fb34be9590e3b1aea08598dd..7d080349f58dccf4689ebeb3523a081e011570fa 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
diff --git a/libraries/liblber/memory.c b/libraries/liblber/memory.c
new file mode 100644 (file)
index 0000000..604e8cc
--- /dev/null
@@ -0,0 +1,320 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+#include "portable.h"
+
+#include <ac/stdlib.h>
+#include <ac/string.h>
+
+#undef LDAP_F_PRE
+#define LDAP_F_PRE LDAP_F_EXPORT
+
+#include "lber-int.h"
+
+#if LDAP_MEMORY_DEBUG
+struct ber_mem_hdr {
+       union bmu_align_u {
+               ber_len_t       bmu_len_t;
+               ber_tag_t       bmu_tag_t;
+               ber_int_t       bmu_int_t;
+
+               size_t  bmu_size_t;
+               void *  bmu_voidp;
+               double  bmu_double;
+               long    bmu_long;
+               long    (*bmu_funcp)( double );
+               char    bmu_char[4];
+       } ber_align;
+#define bm_junk        ber_align.bmu_len_t
+#define bm_data        ber_align.bmu_char[1]
+};
+#define BER_MEM_JUNK 0xddeeddeeU
+static const struct ber_mem_hdr ber_int_mem_hdr = { BER_MEM_JUNK };
+#define BER_MEM_BADADDR        ((void *) &ber_int_mem_hdr.bm_data)
+#define BER_MEM_VALID(p)       do { \
+               assert( (p) != BER_MEM_BADADDR );       \
+               assert( (p) != (void *) &ber_int_mem_hdr );     \
+       } while(0)
+#else
+#define BER_MEM_VALID(p)       /* no-op */
+#endif
+
+BerMemoryFunctions *ber_int_memory_fns = NULL;
+
+#if 0 && defined( LDAP_MEMORY_DEBUG )
+void
+ber_int_memfree( void **p )
+{
+       assert( p != NULL );
+       BER_MEM_VALID( *p );
+
+       ber_memfree( p );
+
+       *p = BER_MEM_BADADDR;
+}
+#endif
+
+void
+ber_memfree( void *p )
+{
+    ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+       if( p == NULL ) {
+               return;
+       }
+
+       BER_MEM_VALID( p );
+
+       if( ber_int_memory_fns == NULL ) {
+#ifdef LDAP_MEMORY_DEBUG
+               struct ber_mem_hdr *mh = (struct ber_mem_hdr *)
+                       ((char *)p - sizeof(struct ber_mem_hdr));
+
+               assert( mh->bm_junk == BER_MEM_JUNK );                          
+               mh->bm_junk = ~BER_MEM_JUNK;
+               free( mh );
+#else
+               free( p );
+#endif
+               return;
+       }
+
+       assert( ber_int_memory_fns->bmf_free );
+
+               
+       (*ber_int_memory_fns->bmf_free)( p );
+}
+
+
+void
+ber_memvfree( void **vec )
+{
+       int     i;
+
+    ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+       if( vec == NULL ) {
+               return;
+       }
+
+       BER_MEM_VALID( vec );
+
+       for ( i = 0; vec[i] != NULL; i++ ) {
+               LBER_FREE( vec[i] );
+       }
+
+       LBER_FREE( vec );
+}
+
+
+void *
+ber_memalloc( ber_len_t s )
+{
+    ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+#ifdef LDAP_MEMORY_DEBUG
+       assert( s != 0 );
+#endif
+
+       if( s == 0 ) {
+               return NULL;
+       }
+
+       if( ber_int_memory_fns == NULL ) {
+#ifdef LDAP_MEMORY_DEBUG
+               struct ber_mem_hdr *mh = malloc(s + sizeof(struct ber_mem_hdr));
+
+               if( mh == NULL ) return NULL;
+
+               mh->bm_junk = BER_MEM_JUNK;
+
+               BER_MEM_VALID( &mh[1] );
+               return &mh[1];
+#else
+               return malloc( s );
+#endif
+       }
+
+       assert( ber_int_memory_fns->bmf_malloc );
+
+       return (*ber_int_memory_fns->bmf_malloc)( s );
+}
+
+
+void *
+ber_memcalloc( ber_len_t n, ber_len_t s )
+{
+    ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+#ifdef LDAP_MEMORY_DEBUG
+       assert( n != 0 && s != 0);
+#endif
+
+       if( n == 0 || s == 0 ) {
+               return NULL;
+       }
+
+       if( ber_int_memory_fns == NULL ) {
+#ifdef LDAP_MEMORY_DEBUG
+               struct ber_mem_hdr *mh = calloc(1,
+                       (n * s) + sizeof(struct ber_mem_hdr) );
+
+               mh->bm_junk = BER_MEM_JUNK;
+
+               BER_MEM_VALID( &mh[1] );
+               return &mh[1];
+#else
+               return calloc( n, s );
+#endif
+       }
+
+       assert( ber_int_memory_fns->bmf_calloc );
+
+       return (*ber_int_memory_fns->bmf_calloc)( n, s );
+}
+
+
+void *
+ber_memrealloc( void* p, ber_len_t s )
+{
+    ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+       /* realloc(NULL,s) -> malloc(s) */
+       if( p == NULL ) {
+               return ber_memalloc( s );
+       }
+       
+       /* realloc(p,0) -> free(p) */
+       if( s == 0 ) {
+               ber_memfree( p );
+               return NULL;
+       }
+
+       BER_MEM_VALID( p );
+
+       if( ber_int_memory_fns == NULL ) {
+#ifdef LDAP_MEMORY_DEBUG
+               struct ber_mem_hdr *mh = (struct ber_mem_hdr *)
+                       ((char *)p - sizeof(struct ber_mem_hdr));
+               assert( mh->bm_junk == BER_MEM_JUNK );
+
+               p = realloc( mh, s + sizeof(struct ber_mem_hdr) );
+
+               if( p == NULL ) return NULL;
+
+               mh = p;
+
+               assert( mh->bm_junk == BER_MEM_JUNK );
+
+               BER_MEM_VALID( &mh[1] );
+               return &mh[1];
+#else
+               return realloc( p, s );
+#endif
+       }
+
+       assert( ber_int_memory_fns->bmf_realloc );
+
+       return (*ber_int_memory_fns->bmf_realloc)( p, s );
+}
+
+
+void
+ber_bvfree( struct berval *bv )
+{
+       ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+       if( bv == NULL ) {
+               return;
+       }
+
+       BER_MEM_VALID( bv );
+
+       if ( bv->bv_val != NULL )
+               LBER_FREE( bv->bv_val );
+
+       LBER_FREE( (char *) bv );
+}
+
+
+void
+ber_bvecfree( struct berval **bv )
+{
+       int     i;
+
+       ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+       if( bv == NULL ) {
+               return;
+       }
+
+       BER_MEM_VALID( bv );
+
+       for ( i = 0; bv[i] != NULL; i++ )
+               ber_bvfree( bv[i] );
+
+       LBER_FREE( (char *) bv );
+}
+
+
+struct berval *
+ber_bvdup(
+       LDAP_CONST struct berval *bv )
+{
+       struct berval *new;
+
+       ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+       if( bv == NULL ) {
+               return NULL;
+       }
+
+       if(( new = LBER_MALLOC( sizeof(struct berval) )) == NULL ) {
+               return NULL;
+       }
+
+       if ( bv->bv_val == NULL ) {
+               new->bv_val = NULL;
+               new->bv_len = 0;
+               return new;
+       }
+
+       if(( new->bv_val = LBER_MALLOC( bv->bv_len + 1 )) == NULL ) {
+               LBER_FREE( new );
+               return NULL;
+       }
+
+       SAFEMEMCPY( new->bv_val, bv->bv_val, bv->bv_len );
+       new->bv_val[bv->bv_len] = '\0';
+       new->bv_len = bv->bv_len;
+
+       return( new );
+}
+
+char *
+ber_strdup( LDAP_CONST char *s )
+{
+       char    *p;
+       size_t  len;
+       
+       ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+#ifdef LDAP_MEMORY_DEBUG
+       assert(s != NULL);                      /* bv damn better point to something */
+#endif
+
+       if( s == NULL ) {
+               return( NULL );
+       }
+
+       len = strlen( s ) + 1;
+
+       if ( (p = LBER_MALLOC( len )) == NULL ) {
+               return( NULL );
+       }
+
+       SAFEMEMCPY( p, s, len );
+       return( p );
+}
diff --git a/libraries/liblber/options.c b/libraries/liblber/options.c
new file mode 100644 (file)
index 0000000..4ffea28
--- /dev/null
@@ -0,0 +1,143 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+#include "portable.h"
+
+#include <ac/stdlib.h>
+#include <ac/string.h>
+
+#undef LDAP_F_PRE
+#define LDAP_F_PRE LDAP_F_EXPORT
+
+#include "lber-int.h"
+
+struct lber_options ber_int_options = {
+       LBER_UNINITIALIZED, 0, 0 };
+
+int
+ber_get_option(
+       LDAP_CONST void *item,
+       int             option,
+       void    *outvalue)
+{
+       LDAP_CONST BerElement *ber;
+       LDAP_CONST Sockbuf *sb;
+
+       ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+       if(outvalue == NULL) {
+               /* no place to get to */
+               return LBER_OPT_ERROR;
+       }
+
+       if(item == NULL) {
+               if(option == LBER_OPT_BER_DEBUG) {
+                       * (int *) outvalue = ber_int_debug;
+                       return LBER_OPT_SUCCESS;
+               }
+
+               return LBER_OPT_ERROR;
+       }
+
+       ber = item;
+       sb = item;
+
+       switch(option) {
+       case LBER_OPT_BER_OPTIONS:
+               assert( BER_VALID( ber ) );
+               * (int *) outvalue = ber->ber_options;
+               return LBER_OPT_SUCCESS;
+
+       case LBER_OPT_BER_DEBUG:
+               assert( BER_VALID( ber ) );
+               * (int *) outvalue = ber->ber_debug;
+               return LBER_OPT_SUCCESS;
+
+       default:
+               /* bad param */
+               break;
+       }
+
+       return LBER_OPT_ERROR;
+}
+
+int
+ber_set_option(
+       void    *item,
+       int             option,
+       LDAP_CONST void *invalue)
+{
+       BerElement *ber;
+       Sockbuf *sb;
+
+       if( (ber_int_options.lbo_valid == LBER_UNINITIALIZED)
+               && ( ber_int_memory_fns == NULL )
+               && ( option == LBER_OPT_MEMORY_FNS )
+               && ( invalue != NULL ))
+       {
+               const BerMemoryFunctions *f =
+                       (const BerMemoryFunctions *) invalue;
+
+               /* make sure all functions are provided */
+               if(!( f->bmf_malloc && f->bmf_calloc
+                       && f->bmf_realloc && f->bmf_free ))
+               {
+                       return LBER_OPT_ERROR;
+               }
+
+               ber_int_memory_fns = (BerMemoryFunctions *)
+                       (*(f->bmf_malloc))(sizeof(BerMemoryFunctions));
+
+               if ( ber_int_memory_fns == NULL ) {
+                       return LBER_OPT_ERROR;
+               }
+
+               memcpy(ber_int_memory_fns, f, sizeof(BerMemoryFunctions));
+
+               ber_int_options.lbo_valid = LBER_INITIALIZED;
+               return LBER_OPT_SUCCESS;
+       }
+
+       ber_int_options.lbo_valid = LBER_INITIALIZED;
+
+       if(invalue == NULL) {
+               /* no place to set from */
+               return LBER_OPT_ERROR;
+       }
+
+       if(item == NULL) {
+               if(option == LBER_OPT_BER_DEBUG) {
+                       ber_int_debug = * (const int *) invalue;
+                       return LBER_OPT_SUCCESS;
+
+               } else if(option == LBER_OPT_LOG_PRINT_FN) {
+                       ber_pvt_log_print = (BER_LOG_PRINT_FN) invalue;
+                       return LBER_OPT_SUCCESS;
+               }
+
+               return LBER_OPT_ERROR;
+       }
+
+       ber = item;
+       sb = item;
+
+       switch(option) {
+       case LBER_OPT_BER_OPTIONS:
+               assert( BER_VALID( ber ) );
+               ber->ber_options = * (const int *) invalue;
+               return LBER_OPT_SUCCESS;
+
+       case LBER_OPT_BER_DEBUG:
+               assert( BER_VALID( ber ) );
+               ber->ber_debug = * (const int *) invalue;
+               return LBER_OPT_SUCCESS;
+
+       default:
+               /* bad param */
+               break;
+       }
+
+       return LBER_OPT_ERROR;
+}
index 52b32040814001e76cd979e07216df9b284768e3..30bceb6bedcb4197e4b79c478a7d8478aa2a6eff 100644 (file)
@@ -1,4 +1,5 @@
 /* sockbuf.c - i/o routines with support for adding i/o layers. */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -104,7 +105,7 @@ status_is_ok( Sockbuf *sb )
 
 #ifdef USE_SASL
 static ber_len_t
-packet_length( char *buf )
+packet_length( Sockbuf *sb, const char *buf )
 {
    ber_len_t size;
 
@@ -115,11 +116,11 @@ packet_length( char *buf )
      (((ber_len_t)buf[2])<<8)|
      (((ber_len_t)buf[3]));
    
-   if ((size<0) || (size>MAX_BUF_SIZE))        {
+   if ( size > MAX_BUF_SIZE ) {
       /* somebody is trying to mess me up. */
-      lber_log_printf( LDAP_DEBUG_SASL, sb->sb_debug,
-                     "SASL: received packet length of %d bytes\n",
-                     size );      
+      ber_log_printf( LDAP_DEBUG_SASL, sb->sb_debug,
+                     "SASL: received packet length of %lu bytes\n",
+                     (unsigned long) size );      
       size = 16; /* this should lead to an error. */
    }
    
@@ -228,7 +229,7 @@ sockbuf_sec_release( Sockbuf *sb, char *buf, ber_len_t len )
       ptr+=size;
       
       if (ptr+4<=end)
-       size = packet_length( ptr ); 
+       size = packet_length( sb, ptr ); 
       /* size is always at least 4, so the loop condition is always OK !!*/
       assert( size>=4 );
       
@@ -444,14 +445,14 @@ ber_pvt_sb_read( Sockbuf *sb, void *buf_arg, ber_len_t len )
            }
            /* calculate the packet length. */
            sb->sb_sec_buf_in.buf_end = 
-              packet_length(sb->sb_sec_buf_in.buf_base );
+              packet_length(sb, sb->sb_sec_buf_in.buf_base );
            if ((sb->sb_sec_buf_in.buf_end > sb->sb_sec_buf_in.buf_size) &&
                (grow_buffer( &(sb->sb_sec_buf_in), sb->sb_sec_buf_in.buf_end)<0)) {
               /* buffer has to be to big. exit with error. */
               ret = -1;
               goto do_return;
            }
-           if (sb->sb_sec_buf_in.buf_ptr >= sb_sec_buf_in.buf_end) {
+           if (sb->sb_sec_buf_in.buf_ptr >= sb->sb_sec_buf_in.buf_end) {
               /* finished packet. decode it. */
               goto decode_packet;
            }
@@ -531,6 +532,7 @@ do_return:
 long sockbuf_do_write( Sockbuf *sb )
 {
    long to_go;
+   ber_slen_t   ret;
 
    assert( sb != NULL );
        assert( SOCKBUF_VALID( sb ) );
@@ -782,10 +784,10 @@ int ber_pvt_sb_set_sec( Sockbuf *sb, Sockbuf_Sec * sec, void *arg )
       memcpy( sb->sb_sec_buf_in.buf_base, 
             sb->sb_buf.buf_base + sb->sb_buf.buf_ptr, len );
       sb->sb_sec_buf_in.buf_ptr = len;
-      sb->sb_sec_buf_in.buf_end = (len>4) ? packet_length( sb->sb_sec_buf_in ) : 0;
+      sb->sb_sec_buf_in.buf_end = (len>4) ? packet_length( sb, sb->sb_sec_buf_in ) : 0;
       sb->sb_buf.buf_ptr = sb->sb_buf.buf_end = 0;
    }
-   update_status();
+   update_status( sb );
    return 0;
 }
 
@@ -1026,8 +1028,8 @@ dgram_read( Sockbuf *sb, void *buf, ber_len_t len )
    
    if ( sb->sb_debug ) {
       ber_log_printf( LDAP_DEBUG_ANY, sb->sb_debug,
-                     "dgram_read udp_read %d bytes\n",
-                     rc );
+                     "dgram_read udp_read %ld bytes\n",
+                     (long) rc );
       if ( rc > 0 )
        ber_log_bprint( LDAP_DEBUG_PACKETS, sb->sb_debug,
                        buf, rc );
index 2603785cea2ee095895928ad98adf9d3bbc357f0..1ee85ec934ca6569c50e67f477bd3faa4b6f97f0 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ## Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
 ## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 ##
@@ -16,7 +17,7 @@ SRCS  = bind.c open.c result.c error.c compare.c search.c \
        getdn.c getentry.c getattr.c getvalues.c addentry.c \
        request.c getdxbyname.c os-ip.c url.c charset.c \
        init.c options.c print.c string.c util-int.c schema.c \
-       charray.c digest.c tls.c
+       charray.c digest.c tls.c dn.c
 OBJS   = bind.lo open.lo result.lo error.lo compare.lo search.lo \
        controls.lo messages.lo references.lo extended.lo \
        modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \
@@ -25,7 +26,7 @@ OBJS  = bind.lo open.lo result.lo error.lo compare.lo search.lo \
        getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
        request.lo getdxbyname.lo os-ip.lo url.lo charset.lo \
        init.lo options.lo print.lo string.lo util-int.lo schema.lo \
-       charray.lo digest.lo tls.lo
+       charray.lo digest.lo tls.lo dn.lo
 
 LDAP_INCDIR= ../../include       
 LDAP_LIBDIR= ../../libraries
index 18324260bd0f06edea8dfb01814772a6c474e2d6..0541dd93cc6e34934c65d02f0bbd62bf756de469 100644 (file)
@@ -1,43 +1,69 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  abandon.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+/*
+ * An abandon request looks like this:
+ *     AbandonRequest ::= MessageID
+ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
 
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#endif /* DOS */
+#include <ac/stdlib.h>
 
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#endif /* MACOS */
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
 
-#include "lber.h"
-#include "ldap.h"
 #include "ldap-int.h"
 
-#ifdef NEEDPROTOS
-static int do_abandon( LDAP *ld, int origid, int msgid );
-#else /* NEEDPROTOS */
-static int do_abandon();
-#endif /* NEEDPROTOS */
+static int do_abandon LDAP_P((
+       LDAP *ld,
+       ber_int_t origid,
+       ber_int_t msgid,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls));
+
 /*
- * ldap_abandon - perform an ldap (and X.500) abandon operation. Parameters:
+ * ldap_abandon_ext - perform an ldap extended abandon operation.
+ *
+ * Parameters:
+ *     ld                      LDAP descriptor
+ *     msgid           The message id of the operation to abandon
+ *     scntrls         Server Controls
+ *     ccntrls         Client Controls
+ *
+ * ldap_abandon_ext returns a LDAP error code.
+ *             (LDAP_SUCCESS if everything went ok)
+ *
+ * Example:
+ *     ldap_abandon_ext( ld, msgid, scntrls, ccntrls );
+ */
+int
+ldap_abandon_ext(
+       LDAP *ld,
+       int msgid,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls )
+{
+       Debug( LDAP_DEBUG_TRACE, "ldap_abandon_ext %d\n", msgid, 0, 0 );
+
+       return do_abandon( ld, msgid, msgid, sctrls, cctrls );
+}
+
+
+/*
+ * ldap_abandon - perform an ldap abandon operation. Parameters:
  *
  *     ld              LDAP descriptor
  *     msgid           The message id of the operation to abandon
@@ -51,38 +77,38 @@ int
 ldap_abandon( LDAP *ld, int msgid )
 {
        Debug( LDAP_DEBUG_TRACE, "ldap_abandon %d\n", msgid, 0, 0 );
-       return( do_abandon( ld, msgid, msgid ));
+       return do_abandon( ld, msgid, msgid, NULL, NULL ) == LDAP_SUCCESS
+               ? 0 : -1;
 }
 
 
 static int
-do_abandon( LDAP *ld, int origid, int msgid )
+do_abandon(
+       LDAP *ld,
+       ber_int_t origid,
+       ber_int_t msgid,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls)
 {
        BerElement      *ber;
        int             i, err, sendabandon;
+       ber_int_t *old_abandon;
        Sockbuf         *sb;
-#ifdef LDAP_REFERRALS
        LDAPRequest     *lr;
-#endif /* LDAP_REFERRALS */
-
-       /*
-        * An abandon request looks like this:
-        *      AbandonRequest ::= MessageID
-        */
 
        Debug( LDAP_DEBUG_TRACE, "do_abandon origid %d, msgid %d\n",
                origid, msgid, 0 );
 
        sendabandon = 1;
 
-#ifdef LDAP_REFERRALS
        /* find the request that we are abandoning */
        for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
                if ( lr->lr_msgid == msgid ) {  /* this message */
                        break;
                }
-               if ( lr->lr_origid == msgid ) { /* child:  abandon it */
-                       do_abandon( ld, msgid, lr->lr_msgid );
+               if ( lr->lr_origid == msgid ) {/* child:  abandon it */
+                       (void) do_abandon( ld,
+                               msgid, lr->lr_msgid, sctrls, cctrls );
                }
        }
 
@@ -90,54 +116,73 @@ do_abandon( LDAP *ld, int origid, int msgid )
                if ( origid == msgid && lr->lr_parent != NULL ) {
                        /* don't let caller abandon child requests! */
                        ld->ld_errno = LDAP_PARAM_ERROR;
-                       return( -1 );
+                       return( LDAP_PARAM_ERROR );
                }
                if ( lr->lr_status != LDAP_REQST_INPROGRESS ) {
                        /* no need to send abandon message */
                        sendabandon = 0;
                }
        }
-#endif /* LDAP_REFERRALS */
 
        if ( ldap_msgdelete( ld, msgid ) == 0 ) {
                ld->ld_errno = LDAP_SUCCESS;
-               return( 0 );
+               return LDAP_SUCCESS;
        }
 
        err = 0;
        if ( sendabandon ) {
                /* create a message to send */
-               if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
+               if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
                        err = -1;
                        ld->ld_errno = LDAP_NO_MEMORY;
+
                } else {
-#ifdef CLDAP
-                       if ( ld->ld_sb.sb_naddr > 0 ) {
-                               err = ber_printf( ber, "{isti}",
+#ifdef LDAP_CONNECTIONLESS
+                       if ( ld->ld_cldapnaddr > 0 ) {
+                               err = ber_printf( ber, "{isti", /* '}' */
                                    ++ld->ld_msgid, ld->ld_cldapdn,
                                    LDAP_REQ_ABANDON, msgid );
-                       } else {
-#endif /* CLDAP */
-                               err = ber_printf( ber, "{iti}", ++ld->ld_msgid,
+                       } else
+#endif /* LDAP_CONNECTIONLESS */
+                       {
+                               err = ber_printf( ber, "{iti",  /* '}' */
+                                       ++ld->ld_msgid,
                                    LDAP_REQ_ABANDON, msgid );
-#ifdef CLDAP
                        }
-#endif /* CLDAP */
 
-                       if ( err == -1 ) {
+                       if( err == -1 ) {
+                               /* encoding error */
                                ld->ld_errno = LDAP_ENCODING_ERROR;
+
+                       } else {
+                               /* Put Server Controls */
+                               if ( ldap_int_put_controls( ld, sctrls, ber )
+                                       != LDAP_SUCCESS )
+                               {
+                                       err = -1;
+
+                               } else {
+                                       /* close '{' */
+                                       err = ber_printf( ber, /*{*/ "}" );
+
+                                       if( err == -1 ) {
+                                               /* encoding error */
+                                               ld->ld_errno = LDAP_ENCODING_ERROR;
+                                       }
+                               }
+                       }
+
+                       if ( err == -1 ) {
                                ber_free( ber, 1 );
+
                        } else {
                                /* send the message */
-#ifdef LDAP_REFERRALS
                                if ( lr != NULL ) {
                                        sb = lr->lr_conn->lconn_sb;
                                } else {
                                        sb = &ld->ld_sb;
                                }
-#else /* LDAP_REFERRALS */
-                               sb = &ld->ld_sb;
-#endif /* LDAP_REFERRALS */
+
                                if ( ber_flush( sb, ber, 1 ) != 0 ) {
                                        ld->ld_errno = LDAP_SERVER_DOWN;
                                        err = -1;
@@ -148,39 +193,38 @@ do_abandon( LDAP *ld, int origid, int msgid )
                }
        }
 
-#ifdef LDAP_REFERRALS
        if ( lr != NULL ) {
                if ( sendabandon ) {
-                       free_connection( ld, lr->lr_conn, 0, 1 );
+                       ldap_free_connection( ld, lr->lr_conn, 0, 1 );
                }
                if ( origid == msgid ) {
-                       free_request( ld, lr );
+                       ldap_free_request( ld, lr );
                }
        }
-#endif /* LDAP_REFERRALS */
 
+       i = 0;
+       if ( ld->ld_abandoned != NULL ) {
+               for ( ; ld->ld_abandoned[i] != -1; i++ )
+                       ;       /* NULL */
+       }
+
+       old_abandon = ld->ld_abandoned;
 
+       ld->ld_abandoned = (ber_int_t *) LDAP_REALLOC( (char *)
+               ld->ld_abandoned, (i + 2) * sizeof(ber_int_t) );
+               
        if ( ld->ld_abandoned == NULL ) {
-               if ( (ld->ld_abandoned = (int *) malloc( 2 * sizeof(int) ))
-                   == NULL ) {
-                       ld->ld_errno = LDAP_NO_MEMORY;
-                       return( -1 );
-               }
-               i = 0;
-       } else {
-               for ( i = 0; ld->ld_abandoned[i] != -1; i++ )
-                       ;       /* NULL */
-               if ( (ld->ld_abandoned = (int *) realloc( (char *)
-                   ld->ld_abandoned, (i + 2) * sizeof(int) )) == NULL ) {
-                       ld->ld_errno = LDAP_NO_MEMORY;
-                       return( -1 );
-               }
+               ld->ld_abandoned = old_abandon;
+               ld->ld_errno = LDAP_NO_MEMORY;
+               return( ld->ld_errno );
        }
+
        ld->ld_abandoned[i] = msgid;
        ld->ld_abandoned[i + 1] = -1;
 
        if ( err != -1 ) {
                ld->ld_errno = LDAP_SUCCESS;
        }
-       return( err );
+
+       return( ld->ld_errno );
 }
index b79cd09b9d4a4eddf1f07cab297b3d55a6a3d797..aa69653572ba4ce2a34f4846c182b829bf0eae13 100644 (file)
@@ -1,37 +1,38 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  add.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
+/*
+ * An add request looks like this:
+ *     AddRequest ::= SEQUENCE {
+ *             entry   DistinguishedName,
+ *             attrs   SEQUENCE OF SEQUENCE {
+ *                     type    AttributeType,
+ *                     values  SET OF AttributeValue
+ *             }
+ *     }
+ */
 
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
+#include "portable.h"
 
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#endif /* DOS */
+#include <stdio.h>
 
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* !MACOS && !DOS */
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
 
-#include "lber.h"
-#include "ldap.h"
 #include "ldap-int.h"
 
 /*
- * ldap_add - initiate an ldap (and X.500) add operation.  Parameters:
+ * ldap_add - initiate an ldap add operation.  Parameters:
  *
  *     ld              LDAP descriptor
  *     dn              DN of the entry to add
@@ -50,34 +51,73 @@ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of
  *     msgid = ldap_add( ld, dn, attrs );
  */
 int
-ldap_add( LDAP *ld, char *dn, LDAPMod **attrs )
+ldap_add( LDAP *ld, LDAP_CONST char *dn, LDAPMod **attrs )
+{
+       int rc;
+       int msgid;
+
+       rc = ldap_add_ext( ld, dn, attrs, NULL, NULL, &msgid );
+
+       if ( rc != LDAP_SUCCESS )
+               return -1;
+
+       return msgid;
+}
+
+
+/*
+ * ldap_add_ext - initiate an ldap extended add operation.  Parameters:
+ *
+ *     ld              LDAP descriptor
+ *     dn              DN of the entry to add
+ *     mods            List of attributes for the entry.  This is a null-
+ *                     terminated array of pointers to LDAPMod structures.
+ *                     only the type and values in the structures need be
+ *                     filled in.
+ *     sctrl   Server Controls
+ *     cctrl   Client Controls
+ *     msgidp  Message ID pointer
+ *
+ * Example:
+ *     LDAPMod *attrs[] = { 
+ *                     { 0, "cn", { "babs jensen", "babs", 0 } },
+ *                     { 0, "sn", { "jensen", 0 } },
+ *                     { 0, "objectClass", { "person", 0 } },
+ *                     0
+ *             }
+ *     rc = ldap_add_ext( ld, dn, attrs, NULL, NULL, &msgid );
+ */
+int
+ldap_add_ext(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAPMod **attrs,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls,
+       int     *msgidp )
 {
        BerElement      *ber;
        int             i, rc;
 
-       /*
-        * An add request looks like this:
-        *      AddRequest ::= SEQUENCE {
-        *              entry   DistinguishedName,
-        *              attrs   SEQUENCE OF SEQUENCE {
-        *                      type    AttributeType,
-        *                      values  SET OF AttributeValue
-        *              }
-        *      }
-        */
-
        Debug( LDAP_DEBUG_TRACE, "ldap_add\n", 0, 0, 0 );
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( dn != NULL );
+       assert( msgidp != NULL );
 
        /* create a message to send */
-       if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
-               return( -1 );
+       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               ld->ld_errno = LDAP_NO_MEMORY;
+               return ld->ld_errno;
        }
 
-       if ( ber_printf( ber, "{it{s{", ++ld->ld_msgid, LDAP_REQ_ADD, dn )
-           == -1 ) {
+       rc = ber_printf( ber, "{it{s{", /* '}}}' */
+               ++ld->ld_msgid, LDAP_REQ_ADD, dn );
+
+       if ( rc == -1 ) {
                ld->ld_errno = LDAP_ENCODING_ERROR;
                ber_free( ber, 1 );
-               return( -1 );
+               return ld->ld_errno;
        }
 
        /* for each attribute in the entry... */
@@ -92,28 +132,52 @@ ldap_add( LDAP *ld, char *dn, LDAPMod **attrs )
                if ( rc == -1 ) {
                        ld->ld_errno = LDAP_ENCODING_ERROR;
                        ber_free( ber, 1 );
-                       return( -1 );
+                       return ld->ld_errno;
                }
        }
 
-       if ( ber_printf( ber, "}}}" ) == -1 ) {
+       if ( ber_printf( ber, /*{{*/ "}}" ) == -1 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free( ber, 1 );
+               return ld->ld_errno;
+       }
+
+       /* Put Server Controls */
+       if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
+               ber_free( ber, 1 );
+               return ld->ld_errno;
+       }
+
+       if ( ber_printf( ber, /*{*/ "}" ) == -1 ) {
                ld->ld_errno = LDAP_ENCODING_ERROR;
                ber_free( ber, 1 );
-               return( -1 );
+               return ld->ld_errno;
        }
 
        /* send the message */
-       return( send_initial_request( ld, LDAP_REQ_ADD, dn, ber ));
+       *msgidp = ldap_send_initial_request( ld, LDAP_REQ_ADD, dn, ber );
+
+       if(*msgidp < 0)
+               return ld->ld_errno;
+
+       return LDAP_SUCCESS;
 }
 
 int
-ldap_add_s( LDAP *ld, char *dn, LDAPMod **attrs )
+ldap_add_ext_s(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAPMod **attrs,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls )
 {
-       int             msgid;
+       int             msgid, rc;
        LDAPMessage     *res;
 
-       if ( (msgid = ldap_add( ld, dn, attrs )) == -1 )
-               return( ld->ld_errno );
+       rc = ldap_add_ext( ld, dn, attrs, sctrls, cctrls, &msgid );
+
+       if ( rc != LDAP_SUCCESS )
+               return( rc );
 
        if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
                return( ld->ld_errno );
@@ -121,3 +185,9 @@ ldap_add_s( LDAP *ld, char *dn, LDAPMod **attrs )
        return( ldap_result2error( ld, res, 1 ) );
 }
 
+int
+ldap_add_s( LDAP *ld, LDAP_CONST char *dn, LDAPMod **attrs )
+{
+       return ldap_add_ext_s( ld, dn, attrs, NULL, NULL );
+}
+
index a0fc4174e6cb133d41399606c6835db21a1fa5d6..1249157f0d3546f8efec0ca55d71c78a91309fdb 100644 (file)
@@ -1,38 +1,36 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  addentry.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+#include "portable.h"
 
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
 
 LDAPMessage *
 ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e )
 {
        LDAPMessage     *tmp, *prev = NULL;
 
+       assert( list != NULL );
+       assert( e != NULL );
+
        for ( tmp = *list; tmp != NULL && tmp != e; tmp = tmp->lm_chain )
                prev = tmp;
 
@@ -51,6 +49,9 @@ ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e )
 void
 ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e )
 {
+       assert( list != NULL );
+       assert( e != NULL );
+
        e->lm_chain = *list;
        *list = e;
 }
index 94ba779400adfb3f8163fedee11d4d1ce9d943a9..b14f563d4bfdf62671a2efa8d811193ba9a19f60 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 0a0487349eac0d66780f8a90517aca6e1e685b85..b9579f2b4a9c7b6530c0cbb9e74e9e9ea7d21dd7 100644 (file)
@@ -1,34 +1,47 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  bind.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
+/*
+ *     BindRequest ::= SEQUENCE {
+ *             version         INTEGER,
+ *             name            DistinguishedName,       -- who
+ *             authentication  CHOICE {
+ *                     simple          [0] OCTET STRING -- passwd
+#ifdef HAVE_KERBEROS
+ *                     krbv42ldap      [1] OCTET STRING
+ *                     krbv42dsa       [2] OCTET STRING
 #endif
+ *                     sasl            [3] SaslCredentials     -- LDAPv3
+ *             }
+ *     }
+ *
+ *     BindResponse ::= SEQUENCE {
+ *             COMPONENTS OF LDAPResult,
+ *             serverSaslCreds         OCTET STRING OPTIONAL -- LDAPv3
+ *     }
+ *
+ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include "msdos.h"
-#ifdef NCSA
-#include "externs.h"
-#endif /* NCSA */
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+
+#include <ac/stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
 
 
 /*
@@ -45,31 +58,15 @@ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of
  */
 
 int
-ldap_bind( LDAP *ld, char *dn, char *passwd, int authmethod )
+ldap_bind( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd, int authmethod )
 {
-       /*
-        * The bind request looks like this:
-        *      BindRequest ::= SEQUENCE {
-        *              version         INTEGER,
-        *              name            DistinguishedName,       -- who
-        *              authentication  CHOICE {
-        *                      simple          [0] OCTET STRING -- passwd
-#ifdef KERBEROS
-        *                      krbv42ldap      [1] OCTET STRING
-        *                      krbv42dsa       [2] OCTET STRING
-#endif
-        *              }
-        *      }
-        * all wrapped up in an LDAPMessage sequence.
-        */
-
        Debug( LDAP_DEBUG_TRACE, "ldap_bind\n", 0, 0, 0 );
 
        switch ( authmethod ) {
        case LDAP_AUTH_SIMPLE:
                return( ldap_simple_bind( ld, dn, passwd ) );
 
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
        case LDAP_AUTH_KRBV41:
                return( ldap_kerberos_bind1( ld, dn ) );
 
@@ -77,6 +74,10 @@ ldap_bind( LDAP *ld, char *dn, char *passwd, int authmethod )
                return( ldap_kerberos_bind2( ld, dn ) );
 #endif
 
+       case LDAP_AUTH_SASL:
+               /* user must use ldap_sasl_bind */
+               /* FALL-THRU */
+
        default:
                ld->ld_errno = LDAP_AUTH_UNKNOWN;
                return( -1 );
@@ -98,7 +99,11 @@ ldap_bind( LDAP *ld, char *dn, char *passwd, int authmethod )
  *         NULL, LDAP_AUTH_KRBV4 )
  */
 int
-ldap_bind_s( LDAP *ld, char *dn, char *passwd, int authmethod )
+ldap_bind_s(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *passwd,
+       int authmethod )
 {
        Debug( LDAP_DEBUG_TRACE, "ldap_bind_s\n", 0, 0, 0 );
 
@@ -106,7 +111,7 @@ ldap_bind_s( LDAP *ld, char *dn, char *passwd, int authmethod )
        case LDAP_AUTH_SIMPLE:
                return( ldap_simple_bind_s( ld, dn, passwd ) );
 
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
        case LDAP_AUTH_KRBV4:
                return( ldap_kerberos_bind_s( ld, dn ) );
 
@@ -117,17 +122,22 @@ ldap_bind_s( LDAP *ld, char *dn, char *passwd, int authmethod )
                return( ldap_kerberos_bind2_s( ld, dn ) );
 #endif
 
+       case LDAP_AUTH_SASL:
+               /* user must use ldap_sasl_bind */
+               /* FALL-THRU */
+
        default:
                return( ld->ld_errno = LDAP_AUTH_UNKNOWN );
        }
 }
 
 
-#ifdef LDAP_REFERRALS
 void
 ldap_set_rebind_proc( LDAP *ld, int (*rebindproc)( LDAP *ld, char **dnp,
        char **passwdp, int *authmethodp, int freeit ))
 {
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+
        ld->ld_rebindproc = rebindproc;
 }
-#endif /* LDAP_REFERRALS */
index 197f4fb9e38182c3b7cd36b4ed6e0d05ec828ffe..0e01394a90202358455bb247f6c1b4c71ef90444 100644 (file)
@@ -1,66 +1,46 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1993 The Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  cache.c - local caching support for LDAP
  */
 
-#ifndef NO_CACHE
-
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1993 The Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include <time.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#ifdef NCSA
-#include "externs.h"
-#endif /* NCSA */
-#ifdef WINSOCK
-#include <time.h>
-#endif /* WINSOCK */
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-#include "lber.h"
-#include "ldap.h"
+
+#include <ac/stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
 #include "ldap-int.h"
 
-#ifdef NEEDPROTOS
-static int             cache_hash( BerElement *ber );
-static LDAPMessage     *msg_dup( LDAPMessage *msg );
-static int             request_cmp( BerElement *req1, BerElement *req2 );
-static int             chain_contains_dn( LDAPMessage *msg, char *dn );
-static long            msg_size( LDAPMessage *msg );
-static void            check_cache_memused( LDAPCache *lc );
-static void            uncache_entry_or_req( LDAP *ld, char *dn, int msgid );
-#else /* NEEDPROTOS */
-static int             cache_hash();
-static LDAPMessage     *msg_dup();
-static int             request_cmp();
-static int             chain_contains_dn();
-static long            msg_size();
-static void            check_cache_memused();
-static void            uncache_entry_or_req();
-#endif /* NEEDPROTOS */
+#ifndef LDAP_NOCACHE
 
+static int             cache_hash LDAP_P(( BerElement *ber ));
+static LDAPMessage     *msg_dup LDAP_P(( LDAPMessage *msg ));
+static int             request_cmp LDAP_P(( BerElement *req1, BerElement *req2 ));
+static int             chain_contains_dn LDAP_P(( LDAPMessage *msg, LDAP_CONST char *dn ));
+static ber_len_t       msg_size LDAP_P(( LDAPMessage *msg ));
+static void            check_cache_memused LDAP_P(( LDAPCache *lc ));
+static void            uncache_entry_or_req LDAP_P(( LDAP *ld, LDAP_CONST char *dn, ber_int_t msgid ));
+
+#endif
 
 int
-ldap_enable_cache( LDAP *ld, long timeout, long maxmem )
+ldap_enable_cache( LDAP *ld, long timeout, ber_len_t maxmem )
 {
-       if ( ld->ld_cache == NULLLDCACHE ) {
-               if (( ld->ld_cache = (LDAPCache *)malloc( sizeof( LDAPCache )))
-                   == NULLLDCACHE ) {
+#ifndef LDAP_NOCACHE
+       if ( ld->ld_cache == NULL ) {
+               if (( ld->ld_cache = (LDAPCache *)LDAP_MALLOC( sizeof( LDAPCache )))
+                   == NULL ) {
                        ld->ld_errno = LDAP_NO_MEMORY;
                        return( -1 );
                }
@@ -73,15 +53,20 @@ ldap_enable_cache( LDAP *ld, long timeout, long maxmem )
        check_cache_memused( ld->ld_cache );
        ld->ld_cache->lc_enabled = 1;
        return( 0 );
+#else 
+       return( -1 );
+#endif
 }
 
 
 void
 ldap_disable_cache( LDAP *ld )
 {
-       if ( ld->ld_cache != NULLLDCACHE ) {
+#ifndef LDAP_NOCACHE
+       if ( ld->ld_cache != NULL ) {
                ld->ld_cache->lc_enabled = 0;
        }
+#endif
 }
 
 
@@ -89,96 +74,108 @@ ldap_disable_cache( LDAP *ld )
 void
 ldap_set_cache_options( LDAP *ld, unsigned long opts )
 {
-       if ( ld->ld_cache != NULLLDCACHE ) {
+#ifndef LDAP_NOCACHE
+       if ( ld->ld_cache != NULL ) {
                ld->ld_cache->lc_options = opts;
        }
+#endif
 }
        
 
 void
 ldap_destroy_cache( LDAP *ld )
 {
-       if ( ld->ld_cache != NULLLDCACHE ) {
+#ifndef LDAP_NOCACHE
+       if ( ld->ld_cache != NULL ) {
                ldap_flush_cache( ld );
-               free( (char *)ld->ld_cache );
-               ld->ld_cache = NULLLDCACHE;
+               LDAP_FREE( (char *)ld->ld_cache );
+               ld->ld_cache = NULL;
        }
+#endif
 }
 
 
 void
 ldap_flush_cache( LDAP *ld )
 {
+#ifndef LDAP_NOCACHE
        int             i;
        LDAPMessage     *m, *next;
 
        Debug( LDAP_DEBUG_TRACE, "ldap_flush_cache\n", 0, 0, 0 );
 
-       if ( ld->ld_cache != NULLLDCACHE ) {
+       if ( ld->ld_cache != NULL ) {
                /* delete all requests in the queue */
-               for ( m = ld->ld_cache->lc_requests; m != NULLMSG; m = next ) {
+               for ( m = ld->ld_cache->lc_requests; m != NULL; m = next ) {
                        next = m->lm_next;
                        ldap_msgfree( m );
                }
-               ld->ld_cache->lc_requests = NULLMSG;
+               ld->ld_cache->lc_requests = NULL;
 
                /* delete all messages in the cache */
                for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) {
                        for ( m = ld->ld_cache->lc_buckets[ i ];
-                           m != NULLMSG; m = next ) {
+                           m != NULL; m = next ) {
                                next = m->lm_next;
                                ldap_msgfree( m );
                        }
-                       ld->ld_cache->lc_buckets[ i ] = NULLMSG;
+                       ld->ld_cache->lc_buckets[ i ] = NULL;
                }
                ld->ld_cache->lc_memused = sizeof( LDAPCache );
        }
+#endif
 }
 
 
 void
 ldap_uncache_request( LDAP *ld, int msgid )
 {
-       Debug( LDAP_DEBUG_TRACE, "ldap_uncache_request %d ld_cache %x\n",
-           msgid, ld->ld_cache, 0 );
+#ifndef LDAP_NOCACHE
+       Debug( LDAP_DEBUG_TRACE, "ldap_uncache_request %d ld_cache %lx\n",
+           msgid, (long) ld->ld_cache, 0 );
 
        uncache_entry_or_req( ld, NULL, msgid );
+#endif
 }
 
 
 void
-ldap_uncache_entry( LDAP *ld, char *dn )
+ldap_uncache_entry( LDAP *ld, LDAP_CONST char *dn )
 {
-       Debug( LDAP_DEBUG_TRACE, "ldap_uncache_entry %s ld_cache %x\n",
-           dn, ld->ld_cache, 0 );
+#ifndef LDAP_NOCACHE
+       Debug( LDAP_DEBUG_TRACE, "ldap_uncache_entry %s ld_cache %lx\n",
+           dn, (long) ld->ld_cache, 0 );
 
        uncache_entry_or_req( ld, dn, 0 );
+#endif
 }
 
 
+#ifndef LDAP_NOCACHE
+
 static void
 uncache_entry_or_req( LDAP *ld,
-       char *dn,               /* if non-NULL, uncache entry */
-       int msgid )             /* request to uncache (if dn == NULL) */
+       const char *dn,         /* if non-NULL, uncache entry */
+       ber_int_t msgid )               /* request to uncache (if dn == NULL) */
 {
        int             i;
        LDAPMessage     *m, *prev, *next;
 
        Debug( LDAP_DEBUG_TRACE,
-           "ldap_uncache_entry_or_req  dn %s  msgid %d  ld_cache %x\n",
-           dn, msgid, ld->ld_cache );
+           "ldap_uncache_entry_or_req  dn %s  msgid %ld  ld_cache %lx\n",
+           dn, (long) msgid, (long) ld->ld_cache );
 
-       if ( ld->ld_cache == NULLLDCACHE ) {
+       if ( ld->ld_cache == NULL ) {
            return;
        }
 
        /* first check the request queue */
-       prev = NULLMSG;
-       for ( m = ld->ld_cache->lc_requests; m != NULLMSG; m = next ) {
+       prev = NULL;
+       for ( m = ld->ld_cache->lc_requests; m != NULL; m = next ) {
                next = m->lm_next;
                if (( dn != NULL && chain_contains_dn( m, dn )) ||
                        ( dn == NULL && m->lm_msgid == msgid )) {
-                       if ( prev == NULLMSG ) {
+                       if ( prev == NULL ) {
                                ld->ld_cache->lc_requests = next;
                        } else {
                                prev->lm_next = next;
@@ -192,13 +189,13 @@ uncache_entry_or_req( LDAP *ld,
 
        /* now check the rest of the cache */
        for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) {
-               prev = NULLMSG;
-               for ( m = ld->ld_cache->lc_buckets[ i ]; m != NULLMSG;
+               prev = NULL;
+               for ( m = ld->ld_cache->lc_buckets[ i ]; m != NULL;
                    m = next ) {
                        next = m->lm_next;
                        if (( dn != NULL && chain_contains_dn( m, dn )) ||
                                ( dn == NULL && m->lm_msgid == msgid )) {
-                               if ( prev == NULLMSG ) {
+                               if ( prev == NULL ) {
                                        ld->ld_cache->lc_buckets[ i ] = next;
                                } else {
                                        prev->lm_next = next;
@@ -212,32 +209,34 @@ uncache_entry_or_req( LDAP *ld,
        }
 }
 
+#endif
 
 void
-add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
+ldap_add_request_to_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
 {
+#ifndef LDAP_NOCACHE
        LDAPMessage     *new;
-       long            len;
+       ber_len_t       len;
 
-       Debug( LDAP_DEBUG_TRACE, "add_request_to_cache\n", 0, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "ldap_add_request_to_cache\n", 0, 0, 0 );
 
        ld->ld_errno = LDAP_SUCCESS;
-       if ( ld->ld_cache == NULLLDCACHE ||
+       if ( ld->ld_cache == NULL ||
            ( ld->ld_cache->lc_enabled == 0 )) {
                return;
        }
 
-       if (( new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) ))
+       if (( new = (LDAPMessage *) LDAP_CALLOC( 1, sizeof(LDAPMessage) ))
            != NULL ) {
-               if (( new->lm_ber = alloc_ber_with_options( ld )) == NULLBER ) {
-                       free( (char *)new );
+               if (( new->lm_ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+                       LDAP_FREE( (char *)new );
                        return;
                }
                len = request->ber_ptr - request->ber_buf;
-               if (( new->lm_ber->ber_buf = (char *) malloc( (size_t)len ))
+               if (( new->lm_ber->ber_buf = (char *) ber_memalloc( (size_t)len ))
                    == NULL ) {
                        ber_free( new->lm_ber, 0 );
-                       free( (char *)new );
+                       LDAP_FREE( (char *)new );
                        ld->ld_errno = LDAP_NO_MEMORY;
                        return;
                }
@@ -252,25 +251,28 @@ add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
        } else {
                ld->ld_errno = LDAP_NO_MEMORY;
        }
+#endif
 }
 
 
 void
-add_result_to_cache( LDAP *ld, LDAPMessage *result )
+ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result )
 {
+#ifndef LDAP_NOCACHE
        LDAPMessage     *m, **mp, *req, *new, *prev;
        int             err, keep;
 
-       Debug( LDAP_DEBUG_TRACE, "add_result_to_cache: id %d, type %d\n", 
-               result->lm_msgid, result->lm_msgtype, 0 );
+       Debug( LDAP_DEBUG_TRACE, "ldap_add_result_to_cache: id %ld, type %ld\n", 
+               (long) result->lm_msgid, (long) result->lm_msgtype, 0 );
 
-       if ( ld->ld_cache == NULLLDCACHE ||
+       if ( ld->ld_cache == NULL ||
            ( ld->ld_cache->lc_enabled == 0 )) {
                Debug( LDAP_DEBUG_TRACE, "artc: cache disabled\n", 0, 0, 0 );
                return;
        }
 
        if ( result->lm_msgtype != LDAP_RES_SEARCH_ENTRY &&
+           result->lm_msgtype != LDAP_RES_SEARCH_REFERENCE &&
            result->lm_msgtype != LDAP_RES_SEARCH_RESULT &&
            result->lm_msgtype != LDAP_RES_COMPARE ) {
                /*
@@ -286,7 +288,7 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result )
         * result to it.  if this result completes the results for the
         * request, add the request/result chain to the cache proper.
         */
-       prev = NULLMSG;
+       prev = NULL;
        for ( m = ld->ld_cache->lc_requests; m != NULL; m = m->lm_next ) {
                if ( m->lm_msgid == result->lm_msgid ) {
                        break;
@@ -294,12 +296,12 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result )
                prev = m;
        }
 
-       if ( m != NULLMSG ) {   /* found request; add to end of chain */
+       if ( m != NULL ) {      /* found request; add to end of chain */
                req = m;
-               for ( ; m->lm_chain != NULLMSG; m = m->lm_chain )
+               for ( ; m->lm_chain != NULL; m = m->lm_chain )
                        ;
-               if (( new = msg_dup( result )) != NULLMSG ) {
-                       new->lm_chain = NULLMSG;
+               if (( new = msg_dup( result )) != NULL ) {
+                       new->lm_chain = NULL;
                        m->lm_chain = new;
                        Debug( LDAP_DEBUG_TRACE,
                            "artc: result added to cache request chain\n",
@@ -330,7 +332,7 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result )
                                keep = 1;
                        }
 
-                       if ( prev == NULLMSG ) {
+                       if ( prev == NULL ) {
                                ld->ld_cache->lc_requests = req->lm_next;
                        } else {
                                prev->lm_next = req->lm_next;
@@ -358,6 +360,7 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result )
                Debug( LDAP_DEBUG_TRACE, "artc: msgid not in request list\n",
                    0, 0, 0 );
        }
+#endif
 }
 
 
@@ -369,16 +372,17 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result )
  * will find them.
  */
 int
-check_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
+ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
 {
+#ifndef LDAP_NOCACHE
        LDAPMessage     *m, *new, *prev, *next;
        BerElement      reqber;
        int             first, hash;
-       unsigned long   validtime;
+       time_t  c_time;
 
-       Debug( LDAP_DEBUG_TRACE, "check_cache\n", 0, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "ldap_check_cache\n", 0, 0, 0 );
 
-       if ( ld->ld_cache == NULLLDCACHE ||
+       if ( ld->ld_cache == NULL ||
            ( ld->ld_cache->lc_enabled == 0 )) {
                return( -1 );
        }
@@ -386,14 +390,14 @@ check_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
        reqber.ber_buf = reqber.ber_ptr = request->ber_buf;
        reqber.ber_end = request->ber_ptr;
 
-       validtime = (long)time( NULL ) - ld->ld_cache->lc_timeout;
+       c_time = time( NULL );
 
-       prev = NULLMSG;
+       prev = NULL;
        hash = cache_hash( &reqber );
-       for ( m = ld->ld_cache->lc_buckets[ hash ]; m != NULLMSG; m = next ) {
-               Debug( LDAP_DEBUG_TRACE,"cc: examining id %d,type %d\n",
-                   m->lm_msgid, m->lm_msgtype, 0 );
-               if ( m->lm_time < validtime ) {
+       for ( m = ld->ld_cache->lc_buckets[ hash ]; m != NULL; m = next ) {
+               Debug( LDAP_DEBUG_TRACE,"cc: examining id %ld,type %ld\n",
+                   (long) m->lm_msgid, (long) m->lm_msgtype, 0 );
+               if ( difftime(c_time, m->lm_time) > ld->ld_cache->lc_timeout ) {
                        /* delete expired message */
                        next = m->lm_next;
                        if ( prev == NULL ) {
@@ -415,7 +419,7 @@ check_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
                }
        }
 
-       if ( m == NULLMSG ) {
+       if ( m == NULL ) {
                return( -1 );
        }
 
@@ -423,13 +427,13 @@ check_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
         * add duplicates of responses to incoming queue
         */
        first = 1;
-       for ( m = m->lm_chain; m != NULLMSG; m = m->lm_chain ) {
-               if (( new = msg_dup( m )) == NULLMSG ) {
+       for ( m = m->lm_chain; m != NULL; m = m->lm_chain ) {
+               if (( new = msg_dup( m )) == NULL ) {
                        return( -1 );
                }
 
                new->lm_msgid = ld->ld_msgid;
-               new->lm_chain = NULLMSG;
+               new->lm_chain = NULL;
                if ( first ) {
                        new->lm_next = ld->ld_responses;
                        ld->ld_responses = new;
@@ -438,20 +442,24 @@ check_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
                        prev->lm_chain = new;
                }
                prev = new;
-               Debug( LDAP_DEBUG_TRACE, "cc: added type %d\n",
-                   new->lm_msgtype, 0, 0 );
+               Debug( LDAP_DEBUG_TRACE, "cc: added type %ld\n",
+                   (long) new->lm_msgtype, 0, 0 );
        }
 
        Debug( LDAP_DEBUG_TRACE, "cc: result returned from cache\n", 0, 0, 0 );
        return( 0 );
+#else
+       return( -1 );
+#endif
 }
 
+#ifndef LDAP_NOCACHE
 
 static int
 cache_hash( BerElement *ber )
 {
        BerElement      bercpy;
-       unsigned long   len;
+       ber_len_t       len;
 
        /*
          * just take the length of the packet and mod with # of buckets
@@ -474,20 +482,20 @@ static LDAPMessage *
 msg_dup( LDAPMessage *msg )
 {
        LDAPMessage     *new;
-       long            len;
+       ber_len_t       len;
 
-       if (( new = (LDAPMessage *)malloc( sizeof(LDAPMessage))) != NULL ) {
+       if (( new = (LDAPMessage *)LDAP_MALLOC( sizeof(LDAPMessage))) != NULL ) {
                *new = *msg;    /* struct copy */
-               if (( new->lm_ber = ber_dup( msg->lm_ber )) == NULLBER ) {
-                       free( (char *)new );
-                       return( NULLMSG );
+               if (( new->lm_ber = ber_dup( msg->lm_ber )) == NULL ) {
+                       LDAP_FREE( (char *)new );
+                       return( NULL );
                }
                len = msg->lm_ber->ber_end - msg->lm_ber->ber_buf;
-               if (( new->lm_ber->ber_buf = (char *) malloc(
+               if (( new->lm_ber->ber_buf = (char *) ber_memalloc(
                    (size_t)len )) == NULL ) {
                        ber_free( new->lm_ber, 0 );
-                       free( (char *)new );
-                       return( NULLMSG );
+                       LDAP_FREE( (char *)new );
+                       return( NULL );
                }
                SAFEMEMCPY( new->lm_ber->ber_buf, msg->lm_ber->ber_buf,
                    (size_t)len );
@@ -503,7 +511,7 @@ msg_dup( LDAPMessage *msg )
 static int
 request_cmp( BerElement *req1, BerElement *req2 )
 {
-       unsigned long   len;
+       ber_len_t       len;
        BerElement      r1, r2;
 
        r1 = *req1;     /* struct copies */
@@ -524,7 +532,9 @@ request_cmp( BerElement *req1, BerElement *req2 )
        /*
         * check remaining length and bytes if necessary
         */
-       if (( len = r1.ber_end - r1.ber_ptr ) != r2.ber_end - r2.ber_ptr ) {
+       if (( len = r1.ber_end - r1.ber_ptr ) !=
+               (ber_len_t) (r2.ber_end - r2.ber_ptr) )
+       {
                return( -1 );   /* different lengths */
        }
        return( memcmp( r1.ber_ptr, r2.ber_ptr, (size_t)len ));
@@ -532,11 +542,11 @@ request_cmp( BerElement *req1, BerElement *req2 )
 
 
 static int
-chain_contains_dn( LDAPMessage *msg, char *dn )
+chain_contains_dn( LDAPMessage *msg, const char *dn )
 {
        LDAPMessage     *m;
        BerElement      ber;
-       long            msgid;
+       ber_int_t               msgid;
        char            *s;
        int             rc;
 
@@ -545,9 +555,9 @@ chain_contains_dn( LDAPMessage *msg, char *dn )
         * first check the base or dn of the request
         */
        ber = *msg->lm_ber;     /* struct copy */
-       if ( ber_scanf( &ber, "{i{a", &msgid, &s ) != LBER_ERROR ) {
+       if ( ber_scanf( &ber, "{i{a" /*}}*/, &msgid, &s ) != LBER_ERROR ) {
            rc = ( strcasecmp( dn, s ) == 0 ) ? 1 : 0;
-           free( s );
+           LDAP_FREE( s );
            if ( rc != 0 ) {
                return( rc );
            }
@@ -561,14 +571,14 @@ chain_contains_dn( LDAPMessage *msg, char *dn )
         * now check the dn of each search result
         */
        rc = 0;
-       for ( m = msg->lm_chain; m != NULLMSG && rc == 0 ; m = m->lm_chain ) {
+       for ( m = msg->lm_chain; m != NULL && rc == 0 ; m = m->lm_chain ) {
                if ( m->lm_msgtype != LDAP_RES_SEARCH_ENTRY ) {
                        continue;
                }
                ber = *m->lm_ber;       /* struct copy */
-               if ( ber_scanf( &ber, "{a", &s ) != LBER_ERROR ) {
+               if ( ber_scanf( &ber, "{a" /*}*/, &s ) != LBER_ERROR ) {
                        rc = ( strcasecmp( dn, s ) == 0 ) ? 1 : 0;
-                       free( s );
+                       LDAP_FREE( s );
                }
        }
 
@@ -576,14 +586,14 @@ chain_contains_dn( LDAPMessage *msg, char *dn )
 }
 
 
-static long
+static ber_len_t
 msg_size( LDAPMessage *msg )
 {
        LDAPMessage     *m;
-       long            size;
+       ber_len_t       size;
 
        size = 0;
-       for ( m = msg; m != NULLMSG; m = m->lm_chain ) {
+       for ( m = msg; m != NULL; m = m->lm_chain ) {
                size += ( sizeof( LDAPMessage ) + m->lm_ber->ber_end -
                    m->lm_ber->ber_buf );
        }
@@ -609,27 +619,28 @@ check_cache_memused( LDAPCache *lc )
  *    } while ( cache size is > SIZE_FACTOR * lc_maxmem )
  */
        int             i;
-       unsigned long   remove_threshold, validtime;
+       unsigned long   remove_threshold;
+       time_t c_time;
        LDAPMessage     *m, *prev, *next;
 
        Debug( LDAP_DEBUG_TRACE, "check_cache_memused: %ld bytes in use (%ld max)\n",
            lc->lc_memused, lc->lc_maxmem, 0 );
 
-       if ( lc->lc_maxmem <= sizeof( LDAPCache )
+       if ( (unsigned) lc->lc_maxmem <= sizeof( LDAPCache )
            || lc->lc_memused <= lc->lc_maxmem * SIZE_FACTOR ) {
                return;
        }
 
        remove_threshold = lc->lc_timeout;
        while ( lc->lc_memused > lc->lc_maxmem * SIZE_FACTOR ) {
-               validtime = (long)time( NULL ) - remove_threshold;
+               c_time = time( NULL );
                for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) {
-                       prev = NULLMSG;
-                       for ( m = lc->lc_buckets[ i ]; m != NULLMSG;
+                       prev = NULL;
+                       for ( m = lc->lc_buckets[ i ]; m != NULL;
                            m = next ) {
                                next = m->lm_next;
-                               if ( m->lm_time < validtime ) {
-                                       if ( prev == NULLMSG ) {
+                               if ( difftime(c_time, m->lm_time) > remove_threshold) {
+                                       if ( prev == NULL ) {
                                                lc->lc_buckets[ i ] = next;
                                        } else {
                                                prev->lm_next = next;
diff --git a/libraries/libldap/charray.c b/libraries/libldap/charray.c
new file mode 100644 (file)
index 0000000..6be3152
--- /dev/null
@@ -0,0 +1,219 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* charray.c - routines for dealing with char * arrays */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "ldap-int.h"
+
+int
+ldap_charray_add(
+    char       ***a,
+    char       *s
+)
+{
+       int     n;
+
+       if ( *a == NULL ) {
+               *a = (char **) LDAP_MALLOC( 2 * sizeof(char *) );
+               n = 0;
+
+               if( *a == NULL ) {
+                       return -1;
+               }
+
+       } else {
+               char **new;
+
+               for ( n = 0; *a != NULL && (*a)[n] != NULL; n++ ) {
+                       ;       /* NULL */
+               }
+
+               new = (char **) LDAP_REALLOC( (char *) *a,
+                   (n + 2) * sizeof(char *) );
+
+               if( new == NULL ) {
+                       /* caller is required to call ldap_charray_free(*a) */
+                       return -1;
+               }
+
+               *a = new;
+       }
+
+       (*a)[n] = LDAP_STRDUP(s);
+
+       if( (*a)[n] == NULL ) {
+               return 1;
+       }
+
+       (*a)[++n] = NULL;
+
+       return 0;
+}
+
+int
+ldap_charray_merge(
+    char       ***a,
+    char       **s
+)
+{
+       int     i, n, nn;
+       char **aa;
+
+       for ( n = 0; *a != NULL && (*a)[n] != NULL; n++ ) {
+               ;       /* NULL */
+       }
+       for ( nn = 0; s[nn] != NULL; nn++ ) {
+               ;       /* NULL */
+       }
+
+       aa = (char **) LDAP_REALLOC( (char *) *a, (n + nn + 1) * sizeof(char *) );
+
+       if( aa == NULL )
+               return -1;
+
+       *a = aa;
+
+       for ( i = 0; i < nn; i++ ) {
+               (*a)[n + i] = LDAP_STRDUP(s[i]);
+
+               if( (*a)[n + i] == NULL ) {
+                       for( --i ; i >= 0 ; i-- ) {
+                               LDAP_FREE( (*a)[n + i] );
+                               (*a)[n + i] = NULL;
+                       }
+                       return -1;
+               }
+       }
+
+       (*a)[n + nn] = NULL;
+       return 0;
+}
+
+void
+ldap_charray_free( char **a )
+{
+       char    **p;
+
+       if ( a == NULL ) {
+               return;
+       }
+
+       for ( p = a; *p != NULL; p++ ) {
+               if ( *p != NULL ) {
+                       LDAP_FREE( *p );
+               }
+       }
+
+       LDAP_FREE( (char *) a );
+}
+
+int
+ldap_charray_inlist(
+    char       **a,
+    char       *s
+)
+{
+       int     i;
+
+       for ( i = 0; a[i] != NULL; i++ ) {
+               if ( strcasecmp( s, a[i] ) == 0 ) {
+                       return( 1 );
+               }
+       }
+
+       return( 0 );
+}
+
+char **
+ldap_charray_dup( char **a )
+{
+       int     i;
+       char    **new;
+
+       for ( i = 0; a[i] != NULL; i++ )
+               ;       /* NULL */
+
+       new = (char **) LDAP_MALLOC( (i + 1) * sizeof(char *) );
+
+       if( new == NULL ) {
+               return NULL;
+       }
+
+       for ( i = 0; a[i] != NULL; i++ ) {
+               new[i] = LDAP_STRDUP( a[i] );
+
+               if( new[i] == NULL ) {
+                       for( --i ; i >= 0 ; i-- ) {
+                               LDAP_FREE( new[i] );
+                       }
+                       LDAP_FREE( new );
+                       return NULL;
+               }
+       }
+       new[i] = NULL;
+
+       return( new );
+}
+
+char **
+ldap_str2charray( char *str, char *brkstr )
+{
+       char    **res;
+       char    *s;
+       char    *lasts;
+       int     i;
+
+       /* protect the input string from strtok */
+       str = LDAP_STRDUP( str );
+       if( str == NULL ) {
+               return NULL;
+       }
+
+       i = 1;
+       for ( s = str; *s; s++ ) {
+               if ( strchr( brkstr, *s ) != NULL ) {
+                       i++;
+               }
+       }
+
+       res = (char **) LDAP_MALLOC( (i + 1) * sizeof(char *) );
+
+       if( res == NULL ) {
+               LDAP_FREE( str );
+               return NULL;
+       }
+
+       i = 0;
+
+       for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
+               s != NULL;
+               s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
+       {
+               res[i] = LDAP_STRDUP( s );
+
+               if(res[i] == NULL) {
+                       for( --i ; i >= 0 ; i-- ) {
+                               LDAP_FREE( res[i] );
+                       }
+                       LDAP_FREE( res );
+                       LDAP_FREE( str );
+                       return NULL;
+               }
+
+               i++;
+       }
+
+       res[i] = NULL;
+
+       LDAP_FREE( str );
+       return( res );
+}
index d5b74006f561a78f590fb970600163f4e8218643..7d85f5ad794709691c048205d090c8eb15dc6cd0 100644 (file)
@@ -1,40 +1,31 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1995 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  charset.c
  */
 
-#if defined( DOS ) || defined( _WIN32 )
-/*
- * This MUST precede "#ifdef STR_TRANSLATION"
- * because STR_TRANSLATION and friends are defined in msdos.h.
- */
-#include "msdos.h"
-#endif /* DOS */
+#include "portable.h"
 
 #ifdef STR_TRANSLATION
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
 #include <stdio.h>
-#include <string.h>
 
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#endif /* MACOS */
+#include <ac/stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
 
-#if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 ) && !defined(VMS)
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
-#include "lber.h"
-#include "ldap.h"
+
 #include "ldap-int.h"
 
 
@@ -50,9 +41,9 @@ ldap_set_string_translators( LDAP *ld, BERTranslateProc encode_proc,
 void
 ldap_enable_translation( LDAP *ld, LDAPMessage *entry, int enable )
 {
-       char    *optionsp;
+       unsigned short  *optionsp;
 
-       optionsp = ( entry == NULLMSG ) ? &ld->ld_lberoptions :
+       optionsp = ( entry == NULL ) ? &ld->ld_lberoptions :
            &entry->lm_ber->ber_options;
                
        if ( enable ) {
@@ -64,10 +55,10 @@ ldap_enable_translation( LDAP *ld, LDAPMessage *entry, int enable )
 
 
 int
-ldap_translate_from_t61( LDAP *ld, char **bufp, unsigned long *lenp,
+ldap_translate_from_t61( LDAP *ld, char **bufp, ber_len_t *lenp,
     int free_input )
 {
-       if ( ld->ld_lber_decode_translate_proc == NULL ) {
+       if ( ld->ld_lber_decode_translate_proc == 0 ) {
                return( LDAP_SUCCESS );
        }
            
@@ -76,10 +67,10 @@ ldap_translate_from_t61( LDAP *ld, char **bufp, unsigned long *lenp,
 
 
 int
-ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp,
+ldap_translate_to_t61( LDAP *ld, char **bufp, ber_len_t *lenp,
     int free_input )
 {
-       if ( ld->ld_lber_encode_translate_proc == NULL ) {
+       if ( ld->ld_lber_encode_translate_proc == 0 ) {
                return( LDAP_SUCCESS );
        }
            
@@ -158,8 +149,8 @@ ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp,
 
 
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <ac/stdlib.h>
+#include <ac/string.h>
 
 /* Character set used: ISO 8859-1, ISO 8859-2, ISO 8859-3, ... */
 /* #define  ISO_8859      1 */
@@ -171,17 +162,12 @@ ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp,
 typedef unsigned char  Byte;
 typedef struct { Byte  a, b; } Couple;
 
-#ifdef NEEDPROTOS
-static Byte *c_to_hh( Byte *o, Byte c );
-static Byte *c_to_cc( Byte *o, Couple *cc, Byte c );
-static int hh_to_c( Byte *h );
-static Byte *cc_to_t61( Byte *o, Byte *s );
-#else /* NEEDPROTOS */
-static Byte *c_to_hh();
-static Byte *c_to_cc();
-static int hh_to_c();
-static Byte *cc_to_t61();
-#endif /* NEEDPROTOS */
+/* Prototypes without LDAP_P():
+ * 'Byte' in definition incompatible with unprototyped declaration. */
+static Byte *c_to_hh   ( Byte *o, Byte c );
+static Byte *c_to_cc   ( Byte *o, const Couple *cc, Byte c );
+static int   hh_to_c   ( const Byte *h );
+static Byte *cc_to_t61 ( Byte *o, const Byte *s );
 
 /*
    Character choosed as base in diacritics alone: NO-BREAK SPACE.
@@ -189,7 +175,7 @@ static Byte *cc_to_t61();
 */
 #define  ALONE  0xA0
 
-static Couple diacritic[16] = {
+static const Couple diacritic[16] = {
 #if (ISO_8859 == 1) || (ISO_8859 == 9)
        {0,0},       {'`',0},     {0xb4,0},    {'^',0},
        {'~',0},     {0xaf,0},    {'(',ALONE}, {'.',ALONE},
@@ -224,7 +210,7 @@ static Couple diacritic[16] = {
        L,   N,   O,   R,   S,   T,   U,   W,   Y,   Z.
    -----------------------------------------------------------------------
 */
-static int letter_w_diacritic[16][38] = {
+static const int letter_w_diacritic[16][38] = {
 #if (ISO_8859 == 1)
        0,   0,   0,   0,   0,   0,   0,   0,   0,
        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
@@ -686,7 +672,7 @@ static int letter_w_diacritic[16][38] = {
 /*
 --- T.61 characters [0xA0 .. 0xBF] -----------------
 */
-static Couple trans_t61a_iso8859[32] = {
+static const Couple trans_t61a_iso8859[32] = {
 #if (ISO_8859 == 1) || (ISO_8859 == 9)
        {'N','S'}, {0xa1,0},  {0xa2,0},  {0xa3,0},
        {'D','O'}, {0xa5,0},  {'C','u'}, {0xa7,0},
@@ -738,7 +724,7 @@ static Couple trans_t61a_iso8859[32] = {
 /*
 --- T.61 characters [0xE0 .. 0xFF] -----------------
 */
-static Couple trans_t61b_iso8859[48] = {
+static const Couple trans_t61b_iso8859[48] = {
 #if (ISO_8859 == 1)
        {'-','M'}, {0xb9,0},  {0xae,0},  {0xa9,0},
        {'T','M'}, {'M','8'}, {0xac,0},  {0xa6,0},
@@ -837,7 +823,7 @@ static Couple trans_t61b_iso8859[48] = {
 --- ISO 8859-n characters <0xA0 .. 0xFF> -------------------
 */
 #if (ISO_8859 == 1)
-static Couple trans_iso8859_t61[96] = {
+static const Couple trans_iso8859_t61[96] = {
        {0xa0,0},     {0xa1,0},     {0xa2,0},     {0xa3,0},
        {0xa8,0},     {0xa5,0},     {0xd7,0},     {0xa7,0},
        {0xc8,ALONE}, {0xd3,0},     {0xe3,0},     {0xab,0},
@@ -864,7 +850,7 @@ static Couple trans_iso8859_t61[96] = {
        {0xc8,'u'},   {0xc2,'y'},   {0xfc,0},     {0xc8,'y'}
 };
 #elif (ISO_8859 == 2)
-static Couple trans_iso8859_t61[96] = {
+static const Couple trans_iso8859_t61[96] = {
        {0xa0,0},     {0xce,'A'},   {0xc6,ALONE}, {0xe8,0},
        {0xa8,0},     {0xcf,'L'},   {0xc2,'S'},   {0xa7,0},
        {0xc8,ALONE}, {0xcf,'S'},   {0xcb,'S'},   {0xcf,'T'},
@@ -891,7 +877,7 @@ static Couple trans_iso8859_t61[96] = {
        {0xc8,'u'},   {0xc2,'y'},   {0xcb,'t'},   {0xc7,ALONE}
 };
 #elif (ISO_8859 == 3)
-static Couple trans_iso8859_t61[96] = {
+static const Couple trans_iso8859_t61[96] = {
        {0xa0,0},     {0xe4,0},     {0xc6,ALONE}, {0xa3,0},
        {0xa8,0},     {0,0},        {0xc3,'H'},   {0xa7,0},
        {0xc8,ALONE}, {0xc7,'I'},   {0xcb,'S'},   {0xc6,'G'},
@@ -918,7 +904,7 @@ static Couple trans_iso8859_t61[96] = {
        {0xc8,'u'},   {0xc6,'u'},   {0xc3,'s'},   {0xc7,ALONE}
 };
 #elif (ISO_8859 == 4)
-static Couple trans_iso8859_t61[96] = {
+static const Couple trans_iso8859_t61[96] = {
        {0xa0,0},     {0xce,'A'},   {0xf0,0},     {0xcb,'R'},
        {0xa8,0},     {0xc4,'I'},   {0xcb,'L'},   {0xa7,0},
        {0xc8,ALONE}, {0xcf,'S'},   {0xc5,'E'},   {0xcb,'G'},
@@ -945,7 +931,7 @@ static Couple trans_iso8859_t61[96] = {
        {0xc8,'u'},   {0xc4,'u'},   {0xc5,'u'},   {0xc7,ALONE}
 };
 #elif (ISO_8859 == 9)
-static Couple trans_iso8859_t61[96] = {
+static const Couple trans_iso8859_t61[96] = {
        {0xa0,0},     {0xa1,0},     {0xa2,0},     {0xa3,0},
        {0xa8,0},     {0xa5,0},     {0xd7,0},     {0xa7,0},
        {0xc8,ALONE}, {0xd3,0},     {0xe3,0},     {0xab,0},
@@ -972,7 +958,7 @@ static Couple trans_iso8859_t61[96] = {
        {0xc8,'u'},   {0xf5,0},     {0xcb,'s'},   {0xc8,'y'}
 };
 #elif (ISO_8859 == 10)
-static Couple trans_iso8859_t61[96] = {
+static const Couple trans_iso8859_t61[96] = {
        {0xa0,0},     {0xce,'A'},   {0xc5,'E'},   {0xcb,'G'},
        {0xc5,'I'},   {0xc4,'I'},   {0xcb,'K'},   {0xa7,0},
        {0xcb,'L'},   {0xe2,0},     {0xcf,'S'},   {0xed,0},
@@ -1017,7 +1003,7 @@ c_to_hh( Byte *o, Byte c )
 
 
 static Byte *
-c_to_cc( Byte *o, Couple *cc, Byte c )
+c_to_cc( Byte *o, const Couple *cc, Byte c )
 {
   if ( (*cc).a != 0 ) {
     if ( (*cc).b == 0 )
@@ -1037,13 +1023,12 @@ c_to_cc( Byte *o, Couple *cc, Byte c )
 /* --- routine to convert from T.61 to ISO 8859-n --- */
 
 int
-ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input )
+ldap_t61_to_8859( char **bufp, ber_len_t *buflenp, int free_input )
 {
   Byte         *s, *oo, *o;
   unsigned int  n;
   int           c;
-  unsigned long len;
-  Couple        *cc;
+  ber_len_t len;
 
   Debug( LDAP_DEBUG_TRACE, "ldap_t61_to_8859 input length: %ld\n",
        *buflenp, 0, 0 );
@@ -1051,7 +1036,7 @@ ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input )
   len = *buflenp;
   s = (Byte *) *bufp;
 
-  if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) {
+  if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * len + 64 )) == NULL ) {
         return( 1 );
   }
 
@@ -1153,13 +1138,13 @@ ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input )
   len = o - oo;
   o = oo;
 
-  if ( (oo = (Byte *)realloc( o, len )) == NULL ) {
-    free( o );
+  if ( (oo = (Byte *)LDAP_REALLOC( o, len )) == NULL ) {
+    LDAP_FREE( o );
     return( 1 );
   }
 
   if ( free_input ) {
-    free( *bufp );
+    LDAP_FREE( *bufp );
   }
   *bufp = (char *) oo;
   *buflenp = len;
@@ -1168,7 +1153,7 @@ ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input )
 
 
 static int
-hh_to_c( Byte *h )
+hh_to_c( const Byte *h )
 {
   Byte c;
 
@@ -1189,7 +1174,7 @@ hh_to_c( Byte *h )
 
 
 static Byte *
-cc_to_t61( Byte *o, Byte *s )
+cc_to_t61( Byte *o, const Byte *s )
 {
   int n, c = 0;
 
@@ -1575,12 +1560,12 @@ cc_to_t61( Byte *o, Byte *s )
 /* --- routine to convert from ISO 8859-n to T.61 --- */
 
 int
-ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input )
+ldap_8859_to_t61( char **bufp, ber_len_t *buflenp, int free_input )
 {
   Byte         *s, *oo, *o, *aux;
   int          c;
-  unsigned long len; 
-  Couple       *cc;
+  ber_len_t len; 
+  const Couple *cc;
 
   Debug( LDAP_DEBUG_TRACE, "ldap_8859_to_t61 input length: %ld\n",
        *buflenp, 0, 0 );
@@ -1588,7 +1573,7 @@ ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input )
   len = *buflenp;
   s = (Byte *) *bufp;
 
-  if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) {
+  if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * len + 64 )) == NULL ) {
         return( 1 );
   }
 
@@ -1667,13 +1652,13 @@ ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input )
   len = o - oo;
   o = oo;
 
-  if ( (oo = (Byte *)realloc( o, len )) == NULL ) {
-    free( o );
+  if ( (oo = (Byte *)LDAP_REALLOC( o, len )) == NULL ) {
+    LDAP_FREE( o );
     return( 1 );
   }
 
   if ( free_input ) {
-    free( *bufp );
+    LDAP_FREE( *bufp );
   }
   *bufp = (char *) oo;
   *buflenp = len;
@@ -1692,7 +1677,7 @@ char      *s;
 
   while ( *s ) {
     if ( *s == '\\' ) {
-      if ( (c = hh_to_c( ++s )) != -1 ) {
+      if ( (c = hh_to_c( (Byte *) ++s )) != -1 ) {
        *o++ = c;
        s += 2;
       } else
@@ -1706,12 +1691,12 @@ char    *s;
 /* --- routine to convert 8bits characters to the "escaped" (\hh) form --- */
 
 char *convert_8bit_to_escaped( s )
-Byte  *s;
+const Byte  *s;
 {
   Byte *o, *oo;
   Byte n;
 
-  if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) {
+  if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * strlen( s ) + 64 )) == NULL ) {
         return( NULL );
   }
 
@@ -1730,8 +1715,8 @@ Byte  *s;
 
   o = oo;
 
-  if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) {
-    free( o );
+  if ( (oo = (Byte *)LDAP_REALLOC( o, strlen( o ) + 1 )) == NULL ) {
+    LDAP_FREE( o );
     return( NULL );
   }
 
@@ -1747,7 +1732,7 @@ Byte  *s;
    that conversion is language dependent.
 */
 
-static Couple last_t61_printabled[32] = {
+static const Couple last_t61_printabled[32] = {
        {0,0},     {'A','E'}, {'D',0},   {0,0},
        {'H',0},   {0,0},     {'I','J'}, {'L',0},
        {'L',0},   {'O',0},   {'O','E'}, {0,0},
@@ -1763,9 +1748,9 @@ Byte  *s;
 {
   Byte   *o, *oo;
   Byte   n;
-  Couple *cc;
+  const Couple *cc;
 
-  if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) {
+  if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * strlen( s ) + 64 )) == NULL ) {
         return( NULL );
   }
 
@@ -1808,8 +1793,8 @@ Byte  *s;
 
   o = oo;
 
-  if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) {
-    free( o );
+  if ( (oo = (Byte *)LDAP_REALLOC( o, strlen( o ) + 1 )) == NULL ) {
+    LDAP_FREE( o );
     return( NULL );
   }
 
index 19782f77d898a18ac23f97c874b055fcf393ea1e..de6208136b3d5f89b6d1c0df4b3b531a6239c800 100644 (file)
@@ -1,46 +1,34 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990, 1994 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  cldap.c - synchronous, retrying interface to the cldap protocol
  */
 
+#include "portable.h"
 
-#ifdef CLDAP
-
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990, 1994 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+#ifdef LDAP_CONNECTIONLESS
 
 #include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include "msdos.h"
-#else /* DOS */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+
+#include <ac/stdlib.h>
+
+#include <ac/errno.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
 #include "ldap-int.h"
 
 #define DEF_CLDAP_TIMEOUT      3
 #define DEF_CLDAP_TRIES                4
 
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK        ((unsigned long) 0x7f000001)
-#endif
-
 
 struct cldap_retinfo {
        int             cri_maxtries;
@@ -49,17 +37,14 @@ struct cldap_retinfo {
        long            cri_timeout;
 };
 
-#ifdef NEEDPROTOS
-static int add_addr( LDAP *ld, struct sockaddr *sap );
-static int cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
-       struct cldap_retinfo *crip, char *base );
-static int cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
-       LDAPMessage **res, char *base );
-#else /* NEEDPROTOS */
-static int add_addr();
-static int cldap_result();
-static int cldap_parsemsg();
-#endif /* NEEDPROTOS */
+static int add_addr LDAP_P((
+       LDAP *ld, struct sockaddr *sap ));
+static int cldap_result LDAP_P((
+       LDAP *ld, int msgid, LDAPMessage **res,
+       struct cldap_retinfo *crip, const char *base ));
+static int cldap_parsemsg LDAP_P((
+       LDAP *ld, int msgid, BerElement *ber,
+       LDAPMessage **res, const char *base ));
 
 /*
  * cldap_open - initialize and connect to an ldap server.  A magic cookie to
@@ -71,7 +56,7 @@ static int cldap_parsemsg();
  */
 
 LDAP *
-cldap_open( char *host, int port )
+cldap_open( LDAP_CONST char *host, int port )
 {
     int                s;
     unsigned long      address;
@@ -81,11 +66,14 @@ cldap_open( char *host, int port )
     char               *p;
     int                        i;
 
-    Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 );
+    /* buffers for ldap_pvt_gethostbyname_a ... */
+    struct hostent      he_buf;
+    int                 local_h_errno;
+    char               *ha_buf=NULL;
 
-    if ( port == 0 ) {
-           port = LDAP_PORT;
-    }
+#define DO_RETURN(x) if (ha_buf) LDAP_FREE(ha_buf); return (x);
+   
+    Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 );
 
     if ( (s = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 ) {
        return( NULL );
@@ -95,23 +83,23 @@ cldap_open( char *host, int port )
     sock.sin_family = AF_INET;
     sock.sin_port = 0;
     if ( bind(s, (struct sockaddr *) &sock, sizeof(sock)) < 0)  {
-       close( s );
+       tcp_close( s );
        return( NULL );
     }
-
     if (( ld = ldap_init( host, port )) == NULL ) {
-       close( s );
+       tcp_close( s );
        return( NULL );
     }
-    if ( (ld->ld_sb.sb_fromaddr = (void *) calloc( 1,
-           sizeof( struct sockaddr ))) == NULL ) {
-       free( ld );
-       close( s );
-       return( NULL );
-    }  
-    ld->ld_sb.sb_sd = s;
-    ld->ld_sb.sb_naddr = 0;
-    ld->ld_version = LDAP_VERSION;
+       
+    ld->ld_cldapnaddr = 0;
+    ld->ld_cldapaddrs = NULL;
+
+    if (ber_pvt_sb_set_io( &(ld->ld_sb), &ber_pvt_sb_io_udp, NULL )<0) {
+       ldap_ld_free(ld, 1, NULL, NULL );
+       return NULL;
+    }
+       
+    ld->ld_version = LDAP_VERSION2;
 
     sock.sin_family = AF_INET;
     sock.sin_port = htons( port );
@@ -120,6 +108,8 @@ cldap_open( char *host, int port )
      * 'host' may be a space-separated list.
      */
     if ( host != NULL ) {
+       char *host_dup = LDAP_STRDUP( host );
+       host = host_dup;
        for ( ; host != NULL; host = p ) {
            if (( p = strchr( host, ' ' )) != NULL ) {
                for (*p++ = '\0'; *p == ' '; p++) {
@@ -127,10 +117,15 @@ cldap_open( char *host, int port )
                }
            }
 
-           if ( (address = inet_addr( host )) == -1 ) {
-               if ( (hp = gethostbyname( host )) == NULL ) {
-                   errno = EHOSTUNREACH;
-                   continue;
+           address = inet_addr( host );
+           /* This was just a test for -1 until OSF1 let inet_addr return
+              unsigned int, which is narrower than 'unsigned long address' */
+           if ( address == 0xffffffff || address == (unsigned long) -1 ) {
+               if ((ldap_pvt_gethostbyname_a( host, &he_buf, &ha_buf,
+                                             &hp,&local_h_errno)<0) || 
+                   (hp==NULL)) {
+                  errno = EHOSTUNREACH;
+                  continue;
                }
 
                for ( i = 0; hp->h_addr_list[ i ] != 0; ++i ) {
@@ -138,66 +133,63 @@ cldap_open( char *host, int port )
                            (char *)hp->h_addr_list[ i ],
                            sizeof(sock.sin_addr.s_addr));
                    if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
-                       close( s );
-                       free( ld );
-                       return( NULL );
+                       ldap_ld_free( ld, 1, NULL, NULL );
+                       LDAP_FREE( host_dup );
+                       DO_RETURN( NULL );
                    }
                }
 
            } else {
                sock.sin_addr.s_addr = address;
                if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
-                   close( s );
-                   free( ld );
-                   return( NULL );
+                   ldap_ld_free( ld, 1, NULL, NULL );
+                   LDAP_FREE( host_dup );
+                   DO_RETURN( NULL );
                }
            }
 
            if ( ld->ld_host == NULL ) {
-                   ld->ld_host = strdup( host );
+                   ld->ld_host = LDAP_STRDUP( host );
            }
        }
-
+       LDAP_FREE( host_dup );
     } else {
-       address = INADDR_LOOPBACK;
-       sock.sin_addr.s_addr = htonl( address );
+       sock.sin_addr.s_addr = htonl( INADDR_LOOPBACK );
        if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
-           close( s );
-           free( ld );
-           return( NULL );
+           ldap_ld_free( ld, 1, NULL, NULL );
+           DO_RETURN( NULL );
        }
     }
 
-    if ( ld->ld_sb.sb_addrs == NULL
-#ifdef LDAP_REFERRALS
-           || ( ld->ld_defconn = new_connection( ld, NULL, 1,0,0 )) == NULL
-#endif /* LDAP_REFERRALS */
+    if ( ld->ld_cldapaddrs == NULL
+           || ( ld->ld_defconn = ldap_new_connection( ld, NULL, 1,0,0 )) == NULL
            ) {
-       free( ld );
-       return( NULL );
+       ldap_ld_free( ld, 0, NULL, NULL );
+       DO_RETURN( NULL );
     }
 
-    ld->ld_sb.sb_useaddr = ld->ld_sb.sb_addrs[ 0 ];
+    ber_pvt_sb_udp_set_dst( &ld->ld_sb, ld->ld_cldapaddrs[0] );
+
     cldap_setretryinfo( ld, 0, 0 );
 
 #ifdef LDAP_DEBUG
     putchar( '\n' );
-    for ( i = 0; i < ld->ld_sb.sb_naddr; ++i ) {
+    for ( i = 0; i < ld->ld_cldapnaddr; ++i ) {
        Debug( LDAP_DEBUG_TRACE, "end of cldap_open address %d is %s\n",
                i, inet_ntoa( ((struct sockaddr_in *)
-               ld->ld_sb.sb_addrs[ i ])->sin_addr ), 0 );
+               ld->ld_cldapaddrs[ i ])->sin_addr ), 0 );
     }
 #endif
 
-    return( ld );
+    DO_RETURN( ld );
 }
 
-
+#undef DO_RETURN
 
 void
 cldap_close( LDAP *ld )
 {
-       ldap_ld_free( ld, 0 );
+       ldap_ld_free( ld, 0, NULL, NULL );
 }
 
 
@@ -210,13 +202,19 @@ cldap_setretryinfo( LDAP *ld, int tries, int timeout )
 
 
 int
-cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs,
-       int attrsonly, LDAPMessage **res, char *logdn )
+cldap_search_s( LDAP *ld,
+       LDAP_CONST char *base,
+       int scope,
+       LDAP_CONST char *filter,
+       char **attrs,
+       int attrsonly,
+       LDAPMessage **res,
+       char *logdn )
 {
     int                                ret, msgid;
     struct cldap_retinfo       cri;
 
-    *res = NULLMSG;
+    *res = NULL;
 
     (void) memset( &cri, 0, sizeof( cri ));
 
@@ -230,17 +228,19 @@ cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs,
        if ( cri.cri_try != 0 ) {
                --ld->ld_msgid; /* use same id as before */
        }
-       ld->ld_sb.sb_useaddr = ld->ld_sb.sb_addrs[ cri.cri_useaddr ];
+           
+       ber_pvt_sb_udp_set_dst( &(ld->ld_sb), 
+                       ld->ld_cldapaddrs[ cri.cri_useaddr ] );
 
        Debug( LDAP_DEBUG_TRACE, "cldap_search_s try %d (to %s)\n",
            cri.cri_try, inet_ntoa( ((struct sockaddr_in *)
-           ld->ld_sb.sb_useaddr)->sin_addr ), 0 );
+           ld->ld_cldapaddrs[ cri.cri_useaddr ])->sin_addr), 0 );
 
            if ( (msgid = ldap_search( ld, base, scope, filter, attrs,
                attrsonly )) == -1 ) {
                    return( ld->ld_errno );
            }
-#ifndef NO_CACHE
+#ifndef LDAP_NOCACHE
            if ( ld->ld_cache != NULL && ld->ld_responses != NULL ) {
                Debug( LDAP_DEBUG_TRACE, "cldap_search_s res from cache\n",
                        0, 0, 0 );
@@ -248,7 +248,7 @@ cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs,
                ld->ld_responses = ld->ld_responses->lm_next;
                return( ldap_result2error( ld, *res, 0 ));
            }
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
            ret = cldap_result( ld, msgid, res, &cri, base );
        } while (ret == -1);
 
@@ -261,62 +261,59 @@ add_addr( LDAP *ld, struct sockaddr *sap )
 {
     struct sockaddr    *newsap, **addrs;
 
-    if (( newsap = (struct sockaddr *)malloc( sizeof( struct sockaddr )))
+    if (( newsap = (struct sockaddr *)LDAP_MALLOC( sizeof( struct sockaddr )))
            == NULL ) {
        ld->ld_errno = LDAP_NO_MEMORY;
        return( -1 );
     }
-
-    if ( ld->ld_sb.sb_naddr == 0 ) {
-       addrs = (struct sockaddr **)malloc( sizeof(struct sockaddr *));
-    } else {
-       addrs = (struct sockaddr **)realloc( ld->ld_sb.sb_addrs,
-               ( ld->ld_sb.sb_naddr + 1 ) * sizeof(struct sockaddr *));
-    }
+       
+       addrs = (struct sockaddr **)LDAP_REALLOC( ld->ld_cldapaddrs,
+               ( ld->ld_cldapnaddr + 1 ) * sizeof(struct sockaddr *));
 
     if ( addrs == NULL ) {
-       free( newsap );
+       LDAP_FREE( newsap );
        ld->ld_errno = LDAP_NO_MEMORY;
        return( -1 );
     }
 
     SAFEMEMCPY( (char *)newsap, (char *)sap, sizeof( struct sockaddr ));
-    addrs[ ld->ld_sb.sb_naddr++ ] = newsap;
-    ld->ld_sb.sb_addrs = (void **)addrs;
+    addrs[ ld->ld_cldapnaddr++ ] = newsap;
+    ld->ld_cldapaddrs = (void **)addrs;
     return( 0 );
 }
 
 
 static int
 cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
-       struct cldap_retinfo *crip, char *base )
+       struct cldap_retinfo *crip, const char *base )
 {
     Sockbuf            *sb = &ld->ld_sb;
     BerElement         ber;
     char               *logdn;
-    int                        ret, id, fromaddr, i;
+    int                        ret, fromaddr, i;
+       ber_int_t       id;
     struct timeval     tv;
 
     fromaddr = -1;
 
     if ( crip->cri_try == 0 ) {
-       crip->cri_maxtries = ld->ld_cldaptries * sb->sb_naddr;
+       crip->cri_maxtries = ld->ld_cldaptries * ld->ld_cldapnaddr;
        crip->cri_timeout = ld->ld_cldaptimeout;
        crip->cri_useaddr = 0;
        Debug( LDAP_DEBUG_TRACE, "cldap_result tries %d timeout %d\n",
                ld->ld_cldaptries, ld->ld_cldaptimeout, 0 );
     }
 
-    if ((tv.tv_sec = crip->cri_timeout / sb->sb_naddr) < 1 ) {
+    if ((tv.tv_sec = crip->cri_timeout / ld->ld_cldapnaddr) < 1 ) {
        tv.tv_sec = 1;
     }
     tv.tv_usec = 0;
 
     Debug( LDAP_DEBUG_TRACE,
-           "cldap_result waiting up to %d seconds for a response\n",
-           tv.tv_sec, 0, 0 );
-    ber_init( &ber, 0 );
-    set_ber_options( ld, &ber );
+           "cldap_result waiting up to %ld seconds for a response\n",
+           (long) tv.tv_sec, 0, 0 );
+    ber_init_w_nullc( &ber, 0 );
+    ldap_set_ber_options( ld, &ber );
 
     if ( cldap_getmsg( ld, &tv, &ber ) == -1 ) {
        ret = ld->ld_errno;
@@ -332,7 +329,7 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
            ret = LDAP_TIMEOUT;
            --crip->cri_try;
        } else {
-           if ( ++crip->cri_useaddr >= sb->sb_naddr ) {
+           if ( ++crip->cri_useaddr >= ld->ld_cldapnaddr ) {
                /*
                 * new round: reset address to first one and
                 * double the timeout
@@ -351,38 +348,41 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
        logdn = NULL;
 
        if ( ber_scanf( &ber, "ia", &id, &logdn ) == LBER_ERROR ) {
-           free( ber.ber_buf );        /* gack! */
+           LDAP_FREE( ber.ber_buf );   /* gack! */
            ret = LDAP_DECODING_ERROR;
            Debug( LDAP_DEBUG_TRACE,
                    "cldap_result: ber_scanf returned LBER_ERROR (%d)\n",
                    ret, 0, 0 );
        } else if ( id != msgid ) {
-           free( ber.ber_buf );        /* gack! */
+           LDAP_FREE( ber.ber_buf );   /* gack! */
            Debug( LDAP_DEBUG_TRACE,
                    "cldap_result: looking for msgid %d; got %d\n",
                    msgid, id, 0 );
            ret = -1;   /* ignore and keep looking */
        } else {
+           struct sockaddr_in * src;
            /*
             * got a result: determine which server it came from
             * decode into ldap message chain
             */
-           for ( fromaddr = 0; fromaddr < sb->sb_naddr; ++fromaddr ) {
+           src = (struct sockaddr_in *) ber_pvt_sb_udp_get_src( sb );
+               
+           for ( fromaddr = 0; fromaddr < ld->ld_cldapnaddr; ++fromaddr ) {
                    if ( memcmp( &((struct sockaddr_in *)
-                           sb->sb_addrs[ fromaddr ])->sin_addr,
-                           &((struct sockaddr_in *)sb->sb_fromaddr)->sin_addr,
+                           ld->ld_cldapaddrs[ fromaddr ])->sin_addr,
+                           &(src->sin_addr),
                            sizeof( struct in_addr )) == 0 ) {
                        break;
                    }
            }
            ret = cldap_parsemsg( ld, msgid, &ber, res, base );
-           free( ber.ber_buf );        /* gack! */
+           LDAP_FREE( ber.ber_buf );   /* gack! */
            Debug( LDAP_DEBUG_TRACE,
                "cldap_result got result (%d)\n", ret, 0, 0 );
        }
 
        if ( logdn != NULL ) {
-               free( logdn );
+               LDAP_FREE( logdn );
        }
     }
     
@@ -393,18 +393,19 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
      */
     if ( ret != -1 ) {
        i = crip->cri_try;
-       if ( i >= sb->sb_naddr ) {
-           i = sb->sb_naddr - 1;
+       if ( i >= ld->ld_cldapnaddr ) {
+           i = ld->ld_cldapnaddr - 1;
        }
 
        for ( ; i >= 0; --i ) {
            if ( i == fromaddr ) {
                continue;
            }
-           sb->sb_useaddr = sb->sb_addrs[ i ];
+           ber_pvt_sb_udp_set_dst( sb, ld->ld_cldapaddrs[i] );
+
            Debug( LDAP_DEBUG_TRACE, "cldap_result abandoning id %d (to %s)\n",
                msgid, inet_ntoa( ((struct sockaddr_in *)
-               sb->sb_useaddr)->sin_addr ), 0 );
+               ld->ld_cldapaddrs[i])->sin_addr ), 0 );
            (void) ldap_abandon( ld, msgid );
        }
     }
@@ -415,25 +416,27 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
 
 static int
 cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
-       LDAPMessage **res, char *base )
+       LDAPMessage **res, const char *base )
 {
-    unsigned long      tag, len;
-    int                        baselen, slen, rc;
+    ber_tag_t  tag;
+       ber_len_t       len;
+    int                        baselen, slen;
+       ber_tag_t       rc;
     char               *dn, *p, *cookie;
     LDAPMessage                *chain, *prev, *ldm;
     struct berval      *bv;
 
     rc = LDAP_DECODING_ERROR;  /* pessimistic */
-    ldm = chain = prev = NULLMSG;
+    ldm = chain = prev = NULL;
     baselen = ( base == NULL ) ? 0 : strlen( base );
     bv = NULL;
 
     for ( tag = ber_first_element( ber, &len, &cookie );
            tag != LBER_DEFAULT && rc != LDAP_SUCCESS;
            tag = ber_next_element( ber, &len, cookie )) {
-       if (( ldm = (LDAPMessage *)calloc( 1, sizeof(LDAPMessage)))
-               == NULL || ( ldm->lm_ber = alloc_ber_with_options( ld ))
-               == NULLBER ) {
+       if (( ldm = (LDAPMessage *)LDAP_CALLOC( 1, sizeof(LDAPMessage)))
+               == NULL || ( ldm->lm_ber = ldap_alloc_ber_with_options( ld ))
+               == NULL ) {
            rc = LDAP_NO_MEMORY;
            break;      /* return w/error*/
        }
@@ -448,8 +451,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
                break;  /* return w/error */
            }
 
-           if ( ber_printf( ldm->lm_ber, "to", tag, bv->bv_val,
-                   bv->bv_len ) == -1 ) {
+           if ( ber_printf( ldm->lm_ber, "tO", tag, bv ) == -1 ) {
                break;  /* return w/error */
            }
            ber_bvfree( bv );
@@ -457,7 +459,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
            rc = LDAP_SUCCESS;
 
        } else if ( tag == LDAP_RES_SEARCH_ENTRY ) {
-           if ( ber_scanf( ber, "{aO", &dn, &bv ) == LBER_ERROR ) {
+           if ( ber_scanf( ber, "{aO" /*}*/, &dn, &bv ) == LBER_ERROR ) {
                break;  /* return w/error */
            }
            Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg entry %s\n", dn, 0, 0 );
@@ -466,14 +468,14 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
                /*
                 * substitute original searchbase for trailing '*'
                 */
-               if (( p = (char *)malloc( slen + baselen )) == NULL ) {
+               if (( p = (char *)LDAP_MALLOC( slen + baselen )) == NULL ) {
                    rc = LDAP_NO_MEMORY;
-                   free( dn );
+                   LDAP_FREE( dn );
                    break;      /* return w/error */
                }
                strcpy( p, dn );
                strcpy( p + slen - 1, base );
-               free( dn );
+               LDAP_FREE( dn );
                dn = p;
            }
 
@@ -481,14 +483,17 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
                    bv->bv_len ) == -1 ) {
                break;  /* return w/error */
            }
-           free( dn );
+           LDAP_FREE( dn );
            ber_bvfree( bv );
            bv = NULL;
                
+#ifdef notyet
+       } else if ( tag == LDAP_RES_SEARCH_REFERENCE ) {
+#endif
        } else {
-           Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %d\n",
+           Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %lu\n",
                    tag, 0, 0 );
-           rc = LDAP_PROTOCOL_ERROR;
+           rc = LDAP_DECODING_ERROR;
            break;      /* return w/error */
        }
 
@@ -498,17 +503,17 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
 
 #ifdef LDAP_DEBUG
        if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
-           fprintf( stderr, "cldap_parsemsg add message id %d type %d:\n",
-                   ldm->lm_msgid, ldm->lm_msgtype  );
-           ber_dump( ldm->lm_ber, 1 );
+           fprintf( stderr, "cldap_parsemsg add message id %ld type %ld:\n",
+                   (long) ldm->lm_msgid, (long) ldm->lm_msgtype  );
+           ber_log_dump( LDAP_DEBUG_BER, ldap_debug, ldm->lm_ber, 1 );
        }
 #endif /* LDAP_DEBUG */
 
-#ifndef NO_CACHE
+#ifndef LDAP_NOCACHE
            if ( ld->ld_cache != NULL ) {
-               add_result_to_cache( ld, ldm );
+               ldap_add_result_to_cache( ld, ldm );
            }
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
 
        if ( chain == NULL ) {
            chain = ldm;
@@ -521,10 +526,10 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
 
     /* dispose of any leftovers */
     if ( ldm != NULL ) {
-       if ( ldm->lm_ber != NULLBER ) {
+       if ( ldm->lm_ber != NULL ) {
            ber_free( ldm->lm_ber, 1 );
        }
-       free( ldm );
+       LDAP_FREE( ldm );
     }
     if ( bv != NULL ) {
        ber_bvfree( bv );
@@ -532,6 +537,6 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
 
     /* return chain, calling result2error if we got anything at all */
     *res = chain;
-    return(( *res == NULLMSG ) ? rc : ldap_result2error( ld, *res, 0 ));
+    return(( *res == NULL ) ? rc : ldap_result2error( ld, *res, 0 ));
 }
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
index 74388f1ceaee99faf49eb85bf54c9d81e2372958..e7ddcc70aac449274a05c298b224a0d1595cf632 100644 (file)
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  compare.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+/* The compare request looks like this:
+ *     CompareRequest ::= SEQUENCE {
+ *             entry   DistinguishedName,
+ *             ava     SEQUENCE {
+ *                     type    AttributeType,
+ *                     value   AttributeValue
+ *             }
+ *     }
+ */
 
-#include <stdio.h>
-#include <string.h>
+#include "portable.h"
 
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
+#include <stdio.h>
 
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
 
-#include "lber.h"
-#include "ldap.h"
 #include "ldap-int.h"
 
 /*
- * ldap_compare - perform an ldap (and X.500) compare operation.  The dn
+ * ldap_compare_ext - perform an ldap extended compare operation.  The dn
  * of the entry to compare to and the attribute and value to compare (in
  * attr and value) are supplied.  The msgid of the response is returned.
  *
  * Example:
- *     ldap_compare( ld, "c=us@cn=bob", "userPassword", "secret" )
+ *     struct berval bvalue = { "secret", strlen("secret") };
+ *     rc = ldap_compare( ld, "c=us@cn=bob",
+ *             "userPassword", &bvalue,
+ *             sctrl, cctrl, &msgid )
  */
 int
-ldap_compare( LDAP *ld, char *dn, char *attr, char *value )
+ldap_compare_ext(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *attr,
+       struct berval *bvalue,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls,
+       int     *msgidp )
 {
        BerElement      *ber;
 
-       /* The compare request looks like this:
-        *      CompareRequest ::= SEQUENCE {
-        *              entry   DistinguishedName,
-        *              ava     SEQUENCE {
-        *                      type    AttributeType,
-        *                      value   AttributeValue
-        *              }
-        *      }
-        * and must be wrapped in an LDAPMessage.
-        */
-
        Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 );
 
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( dn != NULL );
+       assert( attr != NULL );
+       assert( msgidp != NULL );
+
        /* create a message to send */
-       if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
-               return( -1 );
+       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               return( LDAP_NO_MEMORY );
+       }
+
+       if ( ber_printf( ber, "{it{s{sO}}", /* '}' */
+               ++ld->ld_msgid,
+               LDAP_REQ_COMPARE, dn, attr, &bvalue ) == -1 )
+       {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free( ber, 1 );
+               return( ld->ld_errno );
+       }
+
+       /* Put Server Controls */
+       if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
+               ber_free( ber, 1 );
+               return ld->ld_errno;
        }
 
-       if ( ber_printf( ber, "{it{s{ss}}}", ++ld->ld_msgid, LDAP_REQ_COMPARE,
-           dn, attr, value ) == -1 ) {
+       if( ber_printf( ber, /*{*/ "}" ) == -1 ) {
                ld->ld_errno = LDAP_ENCODING_ERROR;
                ber_free( ber, 1 );
-               return( -1 );
+               return( ld->ld_errno );
        }
 
-#ifndef NO_CACHE
+#ifndef LDAP_NOCACHE
        if ( ld->ld_cache != NULL ) {
-               if ( check_cache( ld, LDAP_REQ_COMPARE, ber ) == 0 ) {
+               if ( ldap_check_cache( ld, LDAP_REQ_COMPARE, ber ) == 0 ) {
                        ber_free( ber, 1 );
                        ld->ld_errno = LDAP_SUCCESS;
-                       return( ld->ld_msgid );
+                       *msgidp = ld->ld_msgid;
+                       return( ld->ld_errno );
                }
-               add_request_to_cache( ld, LDAP_REQ_COMPARE, ber );
+               ldap_add_request_to_cache( ld, LDAP_REQ_COMPARE, ber );
        }
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
 
        /* send the message */
-       return ( send_initial_request( ld, LDAP_REQ_COMPARE, dn, ber ));
+       *msgidp = ldap_send_initial_request( ld, LDAP_REQ_COMPARE, dn, ber );
+       return ( *msgidp < 0 ? ld->ld_errno : LDAP_SUCCESS );
+}
+
+/*
+ * ldap_compare_ext - perform an ldap extended compare operation.  The dn
+ * of the entry to compare to and the attribute and value to compare (in
+ * attr and value) are supplied.  The msgid of the response is returned.
+ *
+ * Example:
+ *     msgid = ldap_compare( ld, "c=us@cn=bob", "userPassword", "secret" )
+ */
+int
+ldap_compare(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *attr,
+       LDAP_CONST char *value )
+{
+       int msgid;
+       struct berval bvalue;
+
+       bvalue.bv_val = (char *) value;
+       bvalue.bv_len = (value == NULL) ? 0 : strlen( value );
+
+       return ldap_compare_ext( ld, dn, attr, &bvalue, NULL, NULL, &msgid ) == LDAP_SUCCESS
+               ? msgid : -1;
 }
 
 int
-ldap_compare_s( LDAP *ld, char *dn, char *attr, char *value )
+ldap_compare_ext_s(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *attr,
+       struct berval *bvalue,
+       LDAPControl **sctrl,
+       LDAPControl **cctrl )
 {
+       int             rc;
        int             msgid;
        LDAPMessage     *res;
 
-       if ( (msgid = ldap_compare( ld, dn, attr, value )) == -1 )
-               return( ld->ld_errno );
+       rc = ldap_compare_ext( ld, dn, attr, bvalue, sctrl, cctrl, &msgid );
+
+       if (  rc != LDAP_SUCCESS )
+               return( rc );
 
        if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
                return( ld->ld_errno );
 
        return( ldap_result2error( ld, res, 1 ) );
 }
+
+int
+ldap_compare_s(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *attr,
+       LDAP_CONST char *value )
+{
+       struct berval bvalue;
+
+       bvalue.bv_val = (char *) value;
+       bvalue.bv_len = (value == NULL) ? 0 : strlen( value );
+
+       return ldap_compare_ext_s( ld, dn, attr, &bvalue, NULL, NULL );
+}
diff --git a/libraries/libldap/controls.c b/libraries/libldap/controls.c
new file mode 100644 (file)
index 0000000..cc07664
--- /dev/null
@@ -0,0 +1,359 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+/* LDAPv3 Controls (RFC2251)
+ *
+ *     Controls ::= SEQUENCE OF Control  
+ *
+ *     Control ::= SEQUENCE { 
+ *             controlType             LDAPOID,
+ *             criticality             BOOLEAN DEFAULT FALSE,
+ *             controlValue    OCTET STRING OPTIONAL
+ *     }
+ */
+
+#include "portable.h"
+
+#include <ac/stdlib.h>
+
+#include <ac/time.h>
+#include <ac/string.h>
+
+#include "ldap-int.h"
+
+
+/*
+ * ldap_int_put_controls
+ */
+
+int
+ldap_int_put_controls(
+       LDAP *ld,
+       LDAPControl *const *ctrls,
+       BerElement *ber )
+{
+       LDAPControl *const *c;
+
+       assert( ld != NULL );
+       assert( ber != NULL );
+
+       if( ctrls == NULL ) {
+               /* use default server controls */
+               ctrls = ld->ld_sctrls;
+       }
+
+       if( ctrls == NULL || *ctrls == NULL ) {
+               return LDAP_SUCCESS;
+       }
+
+       if ( ld->ld_version < LDAP_VERSION3 ) {
+               /* LDAPv2 doesn't support controls,
+                * error if any control is critical
+                */
+               for( c = ctrls ; *c != NULL; c++ ) {
+                       if( (*c)->ldctl_iscritical ) {
+                               ld->ld_errno = LDAP_NOT_SUPPORTED;
+                               return ld->ld_errno;
+                       }
+               }
+
+               return LDAP_SUCCESS;
+       }
+
+       /* Controls are encoded as a sequence of sequences */
+       if( ber_printf( ber, "t{"/*}*/, LDAP_TAG_CONTROLS ) == -1 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               return ld->ld_errno;
+       }
+
+       for( c = ctrls ; *c != NULL; c++ ) {
+               if ( ber_printf( ber, "{s" /*}*/,
+                       (*c)->ldctl_oid ) == -1 )
+               {
+                       ld->ld_errno = LDAP_ENCODING_ERROR;
+                       return ld->ld_errno;
+               }
+
+               if( (*c)->ldctl_iscritical /* only if true */
+                       &&  ( ber_printf( ber, "b",
+                               (ber_int_t) (*c)->ldctl_iscritical ) == -1 ) )
+               {
+                       ld->ld_errno = LDAP_ENCODING_ERROR;
+                       return ld->ld_errno;
+               }
+
+               if( (*c)->ldctl_value.bv_val != NULL /* only if we have a value */
+                       &&  ( ber_printf( ber, "O",
+                               &((*c)->ldctl_value) ) == -1 ) )
+               {
+                       ld->ld_errno = LDAP_ENCODING_ERROR;
+                       return ld->ld_errno;
+               }
+
+
+               if( ber_printf( ber, /*{*/"}" ) == -1 ) {
+                       ld->ld_errno = LDAP_ENCODING_ERROR;
+                       return ld->ld_errno;
+               }
+       }
+
+
+       if( ber_printf( ber, /*{*/"}" ) == -1 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               return ld->ld_errno;
+       }
+
+       return LDAP_SUCCESS;
+}
+
+int ldap_int_get_controls(
+       BerElement *ber,
+       LDAPControl ***ctrls )
+{
+       int nctrls;
+       ber_tag_t tag;
+       ber_len_t len;
+       char *opaque;
+
+       assert( ber != NULL );
+
+       if( ctrls == NULL ) {
+               return LDAP_SUCCESS;
+       }
+       *ctrls = NULL;
+
+       len = ber_pvt_ber_remaining(ber);
+
+       if( len == 0) {
+               /* no controls */
+               return LDAP_SUCCESS;
+       }
+
+
+       if(( tag = ber_peek_tag( ber, &len )) != LDAP_TAG_CONTROLS ) {
+               if( tag == LBER_ERROR ) {
+                       /* decoding error */
+                       return LDAP_DECODING_ERROR;
+               }
+
+               /* ignore unexpected input */
+               return LDAP_SUCCESS;
+       }
+
+       /* set through each element */
+       nctrls = 0;
+       *ctrls = LDAP_MALLOC( 1 * sizeof(LDAPControl *) );
+
+       if( *ctrls == NULL ) {
+               return LDAP_NO_MEMORY;
+       }
+
+       ctrls[nctrls] = NULL;
+
+       for( tag = ber_first_element( ber, &len, &opaque );
+               tag != LBER_ERROR;
+               tag = ber_next_element( ber, &len, opaque ) )
+       {
+               LDAPControl *tctrl;
+               LDAPControl **tctrls;
+
+               tctrl = LDAP_CALLOC( 1, sizeof(LDAPControl) );
+
+               /* allocate pointer space for current controls (nctrls)
+                * + this control + extra NULL
+                */
+               tctrls = (tctrl == NULL) ? NULL :
+                       LDAP_REALLOC(*ctrls, (nctrls+2) * sizeof(LDAPControl *));
+
+               if( tctrls == NULL ) {
+                       /* one of the above allocation failed */
+
+                       if( tctrl != NULL ) {
+                               LDAP_FREE( tctrl );
+                       }
+
+                       ldap_controls_free(*ctrls);
+                       *ctrls = NULL;
+
+                       return LDAP_NO_MEMORY;
+               }
+
+
+               tctrls[nctrls++] = tctrl;
+               tctrls[nctrls] = NULL;
+
+               tag = ber_scanf( ber, "{a" /*}*/, &tctrl->ldctl_oid );
+
+               if( tag != LBER_ERROR ) {
+                       tag = ber_peek_tag( ber, &len );
+               }
+
+               if( tag == LBER_BOOLEAN ) {
+                       ber_int_t crit;
+                       tag = ber_scanf( ber, "b", &crit );
+                       tctrl->ldctl_iscritical = crit ? (char) 0 : (char) ~0;
+               }
+
+               if( tag != LBER_ERROR ) {
+                       tag = ber_peek_tag( ber, &len );
+               }
+
+               if( tag == LBER_OCTETSTRING ) {
+                       tag = ber_scanf( ber, "o", &tctrl->ldctl_value );
+
+               } else {
+                       tctrl->ldctl_value.bv_val = NULL;
+               }
+
+               if( tag == LBER_ERROR ) {
+                       *ctrls = NULL;
+                       ldap_controls_free( tctrls );
+                       return LDAP_DECODING_ERROR;
+               }
+
+               *ctrls = tctrls;
+       }
+               
+       return LDAP_SUCCESS;
+}
+
+/*
+ * Free a LDAPControl
+ */
+void
+ldap_control_free( LDAPControl *c )
+{
+       assert( c != NULL );
+
+       if ( c != NULL ) {
+               if( c->ldctl_oid != NULL) {
+                       LDAP_FREE( c->ldctl_oid );
+               }
+
+               if( c->ldctl_value.bv_val != NULL ) {
+                       LDAP_FREE( c->ldctl_value.bv_val );
+               }
+
+               LDAP_FREE( c );
+       }
+}
+
+/*
+ * Free an array of LDAPControl's
+ */
+void
+ldap_controls_free( LDAPControl **controls )
+{
+       assert( controls != NULL );
+
+       if ( controls != NULL ) {
+               int i;
+
+               for( i=0; controls[i] != NULL; i++) {
+                       ldap_control_free( controls[i] );
+               }
+
+               LDAP_FREE( controls );
+       }
+}
+
+/*
+ * Duplicate an array of LDAPControl
+ */
+LDAPControl **
+ldap_controls_dup( LDAPControl *const *controls )
+{
+       LDAPControl **new;
+       int i;
+
+       if ( controls == NULL ) {
+               return NULL;
+       }
+
+       /* count the controls */
+       for(i=0; controls[i] != NULL; i++) /* empty */ ;
+
+       if( i < 1 ) {
+               /* no controls to duplicate */
+               return NULL;
+       }
+
+       new = (LDAPControl **) LDAP_MALLOC( i * sizeof(LDAPControl *) );
+
+       if( new == NULL ) {
+               /* memory allocation failure */
+               return NULL;
+       }
+
+       /* duplicate the controls */
+       for(i=0; controls[i] != NULL; i++) {
+               new[i] = ldap_control_dup( controls[i] );
+
+               if( new[i] == NULL ) {
+                       ldap_controls_free( new );
+                       return NULL;
+               }
+       }
+
+       new[i] = NULL;
+
+       return new;
+}
+
+/*
+ * Duplicate a LDAPControl
+ */
+LDAPControl *
+ldap_control_dup( const LDAPControl *c )
+{
+       LDAPControl *new;
+
+       if ( c == NULL ) {
+               return NULL;
+       }
+
+       new = (LDAPControl *) LDAP_MALLOC( sizeof(LDAPControl) );
+
+       if( new == NULL ) {
+               return NULL;
+       }
+
+       if( c->ldctl_oid != NULL ) {
+               new->ldctl_oid = LDAP_STRDUP( c->ldctl_oid );
+
+               if(new->ldctl_oid == NULL) {
+                       LDAP_FREE( new );
+                       return NULL;
+               }
+
+       } else {
+               new->ldctl_oid = NULL;
+       }
+
+       if( c->ldctl_value.bv_len > 0 ) {
+               new->ldctl_value.bv_val = (char *) LDAP_MALLOC( c->ldctl_value.bv_len );
+
+               if(new->ldctl_value.bv_val == NULL) {
+                       if(new->ldctl_oid != NULL) {
+                               LDAP_FREE( new->ldctl_oid );
+                       }
+                       LDAP_FREE( new );
+                       return NULL;
+               }
+               
+               SAFEMEMCPY( new->ldctl_value.bv_val, c->ldctl_value.bv_val, 
+                       c->ldctl_value.bv_len );
+
+               new->ldctl_value.bv_len = c->ldctl_value.bv_len;
+
+       } else {
+               new->ldctl_value.bv_len = 0;
+               new->ldctl_value.bv_val = NULL;
+       }
+
+       new->ldctl_iscritical = c->ldctl_iscritical;
+       return new;
+}
index 47e240ea6a9bae564f909200967bd18d732217fc..6d463e17f6ef8c540e909609502cc6e71711d896 100644 (file)
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  delete.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
+/*
+ * A delete request looks like this:
+ *     DelRequet ::= DistinguishedName,
+ */
 
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
+#include "portable.h"
 
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#endif /* DOS */
+#include <stdio.h>
 
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
 
-#include "lber.h"
-#include "ldap.h"
 #include "ldap-int.h"
 
 /*
- * ldap_delete - initiate an ldap (and X.500) delete operation. Parameters:
+ * ldap_delete_ext - initiate an ldap extended delete operation. Parameters:
  *
  *     ld              LDAP descriptor
  *     dn              DN of the object to delete
+ *     sctrls  Server Controls
+ *     cctrls  Client Controls
+ *     msgidp  Message Id Pointer
  *
  * Example:
- *     msgid = ldap_delete( ld, dn );
+ *     rc = ldap_delete( ld, dn, sctrls, cctrls, msgidp );
  */
 int
-ldap_delete( LDAP *ld, char *dn )
+ldap_delete_ext(
+       LDAP *ld,
+       LDAP_CONST char* dn,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls,
+       int *msgidp )
 {
        BerElement      *ber;
 
-       /*
-        * A delete request looks like this:
-        *      DelRequet ::= DistinguishedName,
-        */
-
        Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 );
 
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( dn != NULL );
+       assert( msgidp != NULL );
+
        /* create a message to send */
-       if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
-               return( -1 );
+       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               ld->ld_errno = LDAP_NO_MEMORY;
+               return( ld->ld_errno );
        }
 
-       if ( ber_printf( ber, "{its}", ++ld->ld_msgid, LDAP_REQ_DELETE, dn )
-           == -1 ) {
+       if ( ber_printf( ber, "{its", /* '}' */
+               ++ld->ld_msgid, LDAP_REQ_DELETE, dn ) == -1 )
+       {
                ld->ld_errno = LDAP_ENCODING_ERROR;
                ber_free( ber, 1 );
-               return( -1 );
+               return( ld->ld_errno );
+       }
+
+       /* Put Server Controls */
+       if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
+               ber_free( ber, 1 );
+               return ld->ld_errno;
+       }
+
+       if ( ber_printf( ber, /*{*/ "}" ) == -1 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free( ber, 1 );
+               return( ld->ld_errno );
        }
 
        /* send the message */
-       return ( send_initial_request( ld, LDAP_REQ_DELETE, dn, ber ));
-}
+       *msgidp = ldap_send_initial_request( ld, LDAP_REQ_DELETE, dn, ber );
+
+       if(*msgidp < 0)
+               return ld->ld_errno;
 
+       return LDAP_SUCCESS;
+}
 
 int
-ldap_delete_s( LDAP *ld, char *dn )
+ldap_delete_ext_s(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls )
 {
-       int             msgid;
+       int     msgid;
+       int rc;
        LDAPMessage     *res;
 
-       if ( (msgid = ldap_delete( ld, dn )) == -1 )
+       rc = ldap_delete_ext( ld, dn, sctrls, cctrls, &msgid );
+       
+       if( rc != LDAP_SUCCESS )
                return( ld->ld_errno );
 
        if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
@@ -81,3 +110,34 @@ ldap_delete_s( LDAP *ld, char *dn )
 
        return( ldap_result2error( ld, res, 1 ) );
 }
+/*
+ * ldap_delete - initiate an ldap (and X.500) delete operation. Parameters:
+ *
+ *     ld              LDAP descriptor
+ *     dn              DN of the object to delete
+ *
+ * Example:
+ *     msgid = ldap_delete( ld, dn );
+ */
+int
+ldap_delete( LDAP *ld, LDAP_CONST char *dn )
+{
+       int msgid;
+
+       /*
+        * A delete request looks like this:
+        *      DelRequet ::= DistinguishedName,
+        */
+
+       Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 );
+
+       return ldap_delete_ext( ld, dn, NULL, NULL, &msgid ) == LDAP_SUCCESS
+               ? msgid : -1 ;
+}
+
+
+int
+ldap_delete_s( LDAP *ld, LDAP_CONST char *dn )
+{
+       return ldap_delete_ext_s( ld, dn, NULL, NULL );
+}
index e3c784b3e9c142ca69a8210fa719a7c66368cb65..69aa80c1200e173923867135a34fa9f7e417a490 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index be418309e982a74b6d594fa808fd69e5ac825a4d..40c2b7734337a160d659089fc0d1fd1e1103f268 100644 (file)
@@ -1,4 +1,9 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  * Copyright (c) 1993, 1994 Regents of the University of Michigan.
  * All rights reserved.
  *
  * 7 March 1994 by Mark C Smith
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#ifdef MACOS
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
-#ifndef VMS
-#include <unistd.h>
-#endif /* VMS */
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+#endif
+
+#include "ldap-int.h"
 #include "disptmpl.h"
 
-#ifndef NEEDPROTOS
-static void free_disptmpl();
-static int read_next_tmpl();
-int next_line_tokens();
-void free_strarray();
-#else /* !NEEDPROTOS */
-static void free_disptmpl( struct ldap_disptmpl *tmpl );
-static int read_next_tmpl( char **bufp, long *blenp,
-       struct ldap_disptmpl **tmplp, int dtversion );
-int next_line_tokens( char **bufp, long *blenp, char ***toksp );
-void free_strarray( char **sap );
-#endif /* !NEEDPROTOS */
-
-static char            *tmploptions[] = {
+static void free_disptmpl LDAP_P(( struct ldap_disptmpl *tmpl ));
+static int read_next_tmpl LDAP_P(( char **bufp, ber_len_t *blenp,
+       struct ldap_disptmpl **tmplp, int dtversion ));
+
+static const char *const       tmploptions[] = {
     "addable", "modrdn",
     "altview",
     NULL
 };
 
 
-static unsigned long   tmploptvals[] = {
+static const unsigned long     tmploptvals[] = {
     LDAP_DTMPL_OPT_ADDABLE, LDAP_DTMPL_OPT_ALLOWMODRDN,
     LDAP_DTMPL_OPT_ALTVIEW,
 };
 
 
-static char            *itemtypes[] = {
+static const char *const       itemtypes[] = {
     "cis",                     "mls",                  "dn",
     "bool",                    "jpeg",                 "jpegbtn",
     "fax",                     "faxbtn",               "audiobtn",
@@ -72,7 +63,7 @@ static char           *itemtypes[] = {
     NULL
 };
 
-static unsigned long   itemsynids[] = {
+static const unsigned long     itemsynids[] = {
     LDAP_SYN_CASEIGNORESTR,    LDAP_SYN_MULTILINESTR,  LDAP_SYN_DN,
     LDAP_SYN_BOOLEAN,          LDAP_SYN_JPEGIMAGE,     LDAP_SYN_JPEGBUTTON,
     LDAP_SYN_FAXIMAGE,         LDAP_SYN_FAXBUTTON,     LDAP_SYN_AUDIOBUTTON,
@@ -82,7 +73,7 @@ static unsigned long  itemsynids[] = {
 };
 
 
-static char            *itemoptions[] = {
+static const char *const       itemoptions[] = {
     "ro",                              "sort",
     "1val",                            "hide",
     "required",                                "hideiffalse",
@@ -90,7 +81,7 @@ static char           *itemoptions[] = {
 };
 
 
-static unsigned long   itemoptvals[] = {
+static const unsigned long     itemoptvals[] = {
     LDAP_DITEM_OPT_READONLY,           LDAP_DITEM_OPT_SORTVALUES,
     LDAP_DITEM_OPT_SINGLEVALUED,       LDAP_DITEM_OPT_HIDEIFEMPTY,
     LDAP_DITEM_OPT_VALUEREQUIRED,      LDAP_DITEM_OPT_HIDEIFFALSE,
@@ -109,7 +100,7 @@ ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp )
     long       rlen, len;
     int                rc, eof;
 
-    *tmpllistp = NULLDISPTMPL;
+    *tmpllistp = NULL;
 
     if (( fp = fopen( file, "r" )) == NULL ) {
        return( LDAP_TMPL_ERR_FILE );
@@ -127,7 +118,7 @@ ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp )
        return( LDAP_TMPL_ERR_FILE );
     }
 
-    if (( buf = malloc( (size_t)len )) == NULL ) {
+    if (( buf = LDAP_MALLOC( (size_t)len )) == NULL ) {
        fclose( fp );
        return( LDAP_TMPL_ERR_MEM );
     }
@@ -137,26 +128,26 @@ ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp )
     fclose( fp );
 
     if ( rlen != len && !eof ) {       /* error:  didn't get the whole file */
-       free( buf );
+       LDAP_FREE( buf );
        return( LDAP_TMPL_ERR_FILE );
     }
 
     rc = ldap_init_templates_buf( buf, rlen, tmpllistp );
-    free( buf );
+    LDAP_FREE( buf );
 
     return( rc );
 }
 
 
 int
-ldap_init_templates_buf( char *buf, long buflen,
+ldap_init_templates_buf( char *buf, ber_len_t buflen,
        struct ldap_disptmpl **tmpllistp )
 {
-    int                                rc, version;
+    int                                rc=-1, version;
     char                       **toks;
     struct ldap_disptmpl       *prevtmpl, *tmpl;
 
-    *tmpllistp = prevtmpl = NULLDISPTMPL;
+    *tmpllistp = prevtmpl = NULL;
 
     if ( next_line_tokens( &buf, &buflen, &toks ) != 2 ||
            strcasecmp( toks[ 0 ], "version" ) != 0 ) {
@@ -170,8 +161,8 @@ ldap_init_templates_buf( char *buf, long buflen,
     }
 
     while ( buflen > 0 && ( rc = read_next_tmpl( &buf, &buflen, &tmpl,
-           version )) == 0 && tmpl != NULLDISPTMPL ) {
-       if ( prevtmpl == NULLDISPTMPL ) {
+           version )) == 0 && tmpl != NULL ) {
+       if ( prevtmpl == NULL ) {
            *tmpllistp = tmpl;
        } else {
            prevtmpl->dt_next = tmpl;
@@ -207,27 +198,27 @@ free_disptmpl( struct ldap_disptmpl *tmpl )
 {
     if ( tmpl != NULL ) {
        if ( tmpl->dt_name != NULL ) {
-           free(  tmpl->dt_name );
+           LDAP_FREE(  tmpl->dt_name );
        }
 
        if ( tmpl->dt_pluralname != NULL ) {
-           free( tmpl->dt_pluralname );
+           LDAP_FREE( tmpl->dt_pluralname );
        }
 
        if ( tmpl->dt_iconname != NULL ) {
-           free( tmpl->dt_iconname );
+           LDAP_FREE( tmpl->dt_iconname );
        }
 
        if ( tmpl->dt_authattrname != NULL ) {
-           free( tmpl->dt_authattrname );
+           LDAP_FREE( tmpl->dt_authattrname );
        }
 
        if ( tmpl->dt_defrdnattrname != NULL ) {
-           free( tmpl->dt_defrdnattrname );
+           LDAP_FREE( tmpl->dt_defrdnattrname );
        }
 
        if ( tmpl->dt_defaddlocation != NULL ) {
-           free( tmpl->dt_defaddlocation );
+           LDAP_FREE( tmpl->dt_defaddlocation );
        }
 
        if (  tmpl->dt_oclist != NULL ) {
@@ -236,7 +227,7 @@ free_disptmpl( struct ldap_disptmpl *tmpl )
            for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = nextocp ) {
                nextocp = ocp->oc_next;
                free_strarray( ocp->oc_objclasses );
-               free( ocp );
+               LDAP_FREE( ocp );
            }
        }
 
@@ -246,12 +237,12 @@ free_disptmpl( struct ldap_disptmpl *tmpl )
            for ( adp = tmpl->dt_adddeflist; adp != NULL; adp = nextadp ) {
                nextadp = adp->ad_next;
                if( adp->ad_attrname != NULL ) {
-                   free( adp->ad_attrname );
+                   LDAP_FREE( adp->ad_attrname );
                }
                if( adp->ad_value != NULL ) {
-                   free( adp->ad_value );
+                   LDAP_FREE( adp->ad_value );
                }
-               free( adp );
+               LDAP_FREE( adp );
            }
        }
 
@@ -263,20 +254,20 @@ free_disptmpl( struct ldap_disptmpl *tmpl )
                for ( colp = rowp; colp != NULL; colp = nextcolp ) {
                    nextcolp = colp->ti_next_in_row;
                    if ( colp->ti_attrname != NULL ) {
-                       free( colp->ti_attrname );
+                       LDAP_FREE( colp->ti_attrname );
                    }
                    if ( colp->ti_label != NULL ) {
-                       free( colp->ti_label );
+                       LDAP_FREE( colp->ti_label );
                    }
                    if ( colp->ti_args != NULL ) {
                        free_strarray( colp->ti_args );
                    }
-                   free( colp );
+                   LDAP_FREE( colp );
                }
            }
        }
 
-       free( tmpl );
+       LDAP_FREE( tmpl );
     }
 }
 
@@ -292,7 +283,7 @@ struct ldap_disptmpl *
 ldap_next_disptmpl( struct ldap_disptmpl *tmpllist,
        struct ldap_disptmpl *tmpl )
 {
-    return( tmpl == NULLDISPTMPL ? tmpl : tmpl->dt_next );
+    return( tmpl == NULL ? tmpl : tmpl->dt_next );
 }
 
 
@@ -301,14 +292,14 @@ ldap_name2template( char *name, struct ldap_disptmpl *tmpllist )
 {
     struct ldap_disptmpl       *dtp;
 
-    for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULLDISPTMPL;
+    for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULL;
            dtp = ldap_next_disptmpl( tmpllist, dtp )) {
        if ( strcasecmp( name, dtp->dt_name ) == 0 ) {
            return( dtp );
        }
     }
 
-    return( NULLDISPTMPL );
+    return( NULL );
 }
 
 
@@ -320,12 +311,12 @@ ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist )
     int                                i, j, needcnt, matchcnt;
 
     if ( tmpllist == NULL || oclist == NULL || oclist[ 0 ] == NULL ) {
-       return( NULLDISPTMPL );
+       return( NULL );
     }
 
-    for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULLDISPTMPL;
+    for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULL;
                dtp = ldap_next_disptmpl( tmpllist, dtp )) {
-       for ( oclp = dtp->dt_oclist; oclp != NULLOCLIST;
+       for ( oclp = dtp->dt_oclist; oclp != NULL;
                oclp = oclp->oc_next ) {
            needcnt = matchcnt = 0;
            for ( i = 0; oclp->oc_objclasses[ i ] != NULL; ++i ) {
@@ -344,7 +335,7 @@ ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist )
        }
     }
 
-    return( NULLDISPTMPL );
+    return( NULL );
 }
 
 
@@ -358,7 +349,7 @@ ldap_first_tmplrow( struct ldap_disptmpl *tmpl )
 struct ldap_tmplitem *
 ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row )
 {
-    return( row == NULLTMPLITEM ? row : row->ti_next_in_col );
+    return( row == NULL ? row : row->ti_next_in_col );
 }
 
 
@@ -373,7 +364,7 @@ struct ldap_tmplitem *
 ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row,
        struct ldap_tmplitem *col )
 {
-    return( col == NULLTMPLITEM ? col : col->ti_next_in_row );
+    return( col == NULL ? col : col->ti_next_in_row );
 }
 
 
@@ -391,15 +382,15 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
     attrcnt = 0;
     memerr = 0;
 
-    if (( attrs = (char **)malloc( sizeof( char * ))) == NULL ) {
+    if (( attrs = (char **)LDAP_MALLOC( sizeof( char * ))) == NULL ) {
        return( NULL );
     }
 
     if ( includeattrs != NULL ) {
        for ( i = 0; !memerr && includeattrs[ i ] != NULL; ++i ) {
-           if (( attrs = (char **)realloc( attrs, ( attrcnt + 2 ) *
+           if (( attrs = (char **)LDAP_REALLOC( attrs, ( attrcnt + 2 ) *
                    sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] =
-                   strdup( includeattrs[ i ] )) == NULL ) {
+                   LDAP_STRDUP( includeattrs[ i ] )) == NULL ) {
                memerr = 1;
            } else {
                attrs[ attrcnt ] = NULL;
@@ -408,10 +399,10 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
     }
 
     for ( tirowp = ldap_first_tmplrow( tmpl );
-           !memerr && tirowp != NULLTMPLITEM;
+           !memerr && tirowp != NULL;
            tirowp = ldap_next_tmplrow( tmpl, tirowp )) {
        for ( ticolp = ldap_first_tmplcol( tmpl, tirowp );
-               ticolp != NULLTMPLITEM;
+               ticolp != NULL;
                ticolp = ldap_next_tmplcol( tmpl, tirowp, ticolp )) {
 
            if ( syntaxmask != 0 ) {
@@ -424,9 +415,9 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
            }
 
            if ( ticolp->ti_attrname != NULL ) {
-               if (( attrs = (char **)realloc( attrs, ( attrcnt + 2 ) *
+               if (( attrs = (char **)LDAP_REALLOC( attrs, ( attrcnt + 2 ) *
                        sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] =
-                       strdup( ticolp->ti_attrname )) == NULL ) {
+                       LDAP_STRDUP( ticolp->ti_attrname )) == NULL ) {
                    memerr = 1;
                } else {
                    attrs[ attrcnt ] = NULL;
@@ -438,11 +429,11 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
     if ( memerr || attrcnt == 0 ) {
        for ( i = 0; i < attrcnt; ++i ) {
            if ( attrs[ i ] != NULL ) {
-               free( attrs[ i ] );
+               LDAP_FREE( attrs[ i ] );
            }
        }
 
-       free( (char *)attrs );
+       LDAP_FREE( (char *)attrs );
        return( NULL );
     }
 
@@ -451,15 +442,15 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
 
 
 static int
-read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
+read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp,
        int dtversion )
 {
     int                                i, j, tokcnt, samerow, adsource;
     char                       **toks, *itemopts;
     struct ldap_disptmpl       *tmpl;
-    struct ldap_oclist         *ocp, *prevocp;
-    struct ldap_adddeflist     *adp, *prevadp;
-    struct ldap_tmplitem       *rowp, *ip, *previp;
+    struct ldap_oclist         *ocp, *prevocp = NULL;
+    struct ldap_adddeflist     *adp, *prevadp = NULL;
+    struct ldap_tmplitem       *rowp = NULL, *ip, *previp = NULL;
 
     *tmplp = NULL;
 
@@ -471,13 +462,13 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
        return( tokcnt == 0 ? 0 : LDAP_TMPL_ERR_SYNTAX );
     }
 
-    if (( tmpl = (struct ldap_disptmpl *)calloc( 1,
+    if (( tmpl = (struct ldap_disptmpl *)LDAP_CALLOC( 1,
            sizeof( struct ldap_disptmpl ))) == NULL ) {
        free_strarray( toks );
        return(  LDAP_TMPL_ERR_MEM );
     }
     tmpl->dt_name = toks[ 0 ];
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * template plural name comes next
@@ -488,7 +479,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
        return( LDAP_TMPL_ERR_SYNTAX );
     }
     tmpl->dt_pluralname = toks[ 0 ];
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * template icon name is next
@@ -499,7 +490,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
        return( LDAP_TMPL_ERR_SYNTAX );
     }
     tmpl->dt_iconname = toks[ 0 ];
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * template options come next
@@ -522,7 +513,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
      * object class list is next
      */
     while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) {
-       if (( ocp = (struct ldap_oclist *)calloc( 1,
+       if (( ocp = (struct ldap_oclist *)LDAP_CALLOC( 1,
                sizeof( struct ldap_oclist ))) == NULL ) {
            free_strarray( toks );
            free_disptmpl( tmpl );
@@ -552,9 +543,9 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
     if ( toks[ 0 ][ 0 ] != '\0' ) {
        tmpl->dt_authattrname = toks[ 0 ];
     } else {
-       free( toks[ 0 ] );
+       LDAP_FREE( toks[ 0 ] );
     }
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * read default attribute to use for RDN
@@ -565,7 +556,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
        return( LDAP_TMPL_ERR_SYNTAX );
     }
     tmpl->dt_defrdnattrname = toks[ 0 ];
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * read default location for new entries
@@ -578,9 +569,9 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
     if ( toks[ 0 ][ 0 ] != '\0' ) {
        tmpl->dt_defaddlocation = toks[ 0 ];
     } else {
-       free( toks[ 0 ] );
+       LDAP_FREE( toks[ 0 ] );
     }
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * read list of rules used to define default values for new entries
@@ -601,7 +592,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
            return( LDAP_TMPL_ERR_SYNTAX );
        }
                
-       if (( adp = (struct ldap_adddeflist *)calloc( 1,
+       if (( adp = (struct ldap_adddeflist *)LDAP_CALLOC( 1,
                sizeof( struct ldap_adddeflist ))) == NULL ) {
            free_strarray( toks );
            free_disptmpl( tmpl );
@@ -612,8 +603,8 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
        if ( adsource == LDAP_ADSRC_CONSTANTVALUE ) {
            adp->ad_value = toks[ 2 ];
        }
-       free( toks[ 0 ] );
-       free( (char *)toks );
+       LDAP_FREE( toks[ 0 ] );
+       LDAP_FREE( (char *)toks );
 
        if ( tmpl->dt_adddeflist == NULL ) {
            tmpl->dt_adddeflist = adp;
@@ -635,7 +626,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
                return( LDAP_TMPL_ERR_SYNTAX );
            }
 
-           if (( ip = (struct ldap_tmplitem *)calloc( 1,
+           if (( ip = (struct ldap_tmplitem *)LDAP_CALLOC( 1,
                    sizeof( struct ldap_tmplitem ))) == NULL ) {
                free_strarray( toks );
                free_disptmpl( tmpl );
@@ -671,13 +662,13 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
                return( LDAP_TMPL_ERR_SYNTAX );
            }
 
-           free( toks[ 0 ] );
-           free( toks[ 1 ] );
+           LDAP_FREE( toks[ 0 ] );
+           LDAP_FREE( toks[ 1 ] );
            ip->ti_syntaxid = itemsynids[ i ];
            ip->ti_label = toks[ 2 ];
            if ( toks[ 3 ][ 0 ] == '\0' ) {
                ip->ti_attrname = NULL;
-               free( toks[ 3 ] );
+               LDAP_FREE( toks[ 3 ] );
            } else {
                ip->ti_attrname = toks[ 3 ];
            }
@@ -685,7 +676,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
                for ( i = 0; toks[ i + 4 ] != NULL; ++i ) {
                    ;
                }
-               if (( ip->ti_args = (char **) calloc( i + 1, sizeof( char * )))
+               if (( ip->ti_args = (char **) LDAP_CALLOC( i + 1, sizeof( char * )))
                        == NULL ) {
                    free_disptmpl( tmpl );
                    return( LDAP_TMPL_ERR_MEM );
@@ -694,7 +685,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
                    ip->ti_args[ i ] = toks[ i + 4 ];
                }
            }
-           free( (char *)toks );
+           LDAP_FREE( (char *)toks );
 
            if ( tmpl->dt_items == NULL ) {
                tmpl->dt_items = rowp = ip;
diff --git a/libraries/libldap/dn.c b/libraries/libldap/dn.c
new file mode 100644 (file)
index 0000000..fc1c6ea
--- /dev/null
@@ -0,0 +1,339 @@
+/* dn.c - routines for dealing with distinguished names */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+#if 0
+/* this should wait for UTF-8 routines */
+
+#define B4LEADTYPE             0
+#define B4TYPE                 1
+#define INOIDTYPE              2
+#define INKEYTYPE              3
+#define B4EQUAL                        4
+#define B4VALUE                        5
+#define INVALUE                        6
+#define INQUOTEDVALUE  7
+#define B4SEPARATOR            8
+
+/*
+ * ldap_dn_normalize - put dn into a canonical format
+ * and return it.
+ */
+
+char *
+ldap_dn_normalize( const char *dn )
+{
+       char    *d, *s;
+       int     state, gotesc;
+       char *ndn;
+
+       if( dn == NULL ) {
+               return NULL;
+       }
+
+       ndn = LDAP_STRDUP( dn );
+
+       if( ndn == NULL ) {
+               return NULL;
+       }
+
+       gotesc = 0;
+       state = B4LEADTYPE;
+       for ( d = s = ndn; *s; s++ ) {
+               switch ( state ) {
+               case B4LEADTYPE:
+               case B4TYPE:
+                       if ( LDAP_LEADOIDCHAR(*s) ) {
+                               state = INOIDTYPE;
+                               *d++ = *s;
+                       } else if ( LDAP_LEADKEYCHAR(*s) ) {
+                               state = INKEYTYPE;
+                               *d++ = *s;
+                       } else if ( ! LDAP_SPACE( *s ) ) {
+                               dn = NULL;
+                               state = INKEYTYPE;
+                               *d++ = *s;
+                       }
+                       break;
+
+               case INOIDTYPE:
+                       if ( LDAP_OIDCHAR(*s) ) {
+                               *d++ = *s;
+                       } else if ( *s == '=' ) {
+                               state = B4VALUE;
+                               *d++ = *s;
+                       } else if ( LDAP_SPACE( *s ) ) {
+                               state = B4EQUAL;
+                       } else {
+                               dn = NULL;
+                               *d++ = *s;
+                       }
+                       break;
+
+               case INKEYTYPE:
+                       if ( LDAP_KEYCHAR(*s) ) {
+                               *d++ = *s;
+                       } else if ( *s == '=' ) {
+                               state = B4VALUE;
+                               *d++ = *s;
+                       } else if ( LDAP_SPACE( *s ) ) {
+                               state = B4EQUAL;
+                       } else {
+                               dn = NULL;
+                               *d++ = *s;
+                       }
+                       break;
+
+               case B4EQUAL:
+                       if ( *s == '=' ) {
+                               state = B4VALUE;
+                               *d++ = *s;
+                       } else if ( ! LDAP_SPACE( *s ) ) {
+                               /* not a valid dn - but what can we do here? */
+                               *d++ = *s;
+                               dn = NULL;
+                       }
+                       break;
+
+               case B4VALUE:
+                       if ( *s == '"' ) {
+                               state = INQUOTEDVALUE;
+                               *d++ = *s;
+                       } else if ( ! LDAP_SPACE( *s ) ) { 
+                               state = INVALUE;
+                               *d++ = *s;
+                       }
+                       break;
+
+               case INVALUE:
+                       if ( !gotesc && LDAP_SEPARATOR( *s ) ) {
+                               while ( LDAP_SPACE( *(d - 1) ) )
+                                       d--;
+                               state = B4TYPE;
+                               if ( *s == '+' ) {
+                                       *d++ = *s;
+                               } else {
+                                       *d++ = ',';
+                               }
+                       } else if ( gotesc && !LDAP_NEEDSESCAPE( *s ) &&
+                           !LDAP_SEPARATOR( *s ) ) {
+                               *--d = *s;
+                               d++;
+                       } else {
+                               *d++ = *s;
+                       }
+                       break;
+
+               case INQUOTEDVALUE:
+                       if ( !gotesc && *s == '"' ) {
+                               state = B4SEPARATOR;
+                               *d++ = *s;
+                       } else if ( gotesc && !LDAP_NEEDSESCAPE( *s ) ) {
+                               *--d = *s;
+                               d++;
+                       } else {
+                               *d++ = *s;
+                       }
+                       break;
+               case B4SEPARATOR:
+                       if ( LDAP_SEPARATOR( *s ) ) {
+                               state = B4TYPE;
+                               *d++ = *s;
+                       }
+                       break;
+               default:
+                       dn = NULL;
+                       Debug( LDAP_DEBUG_ANY,
+                           "dn_normalize - unknown state %d\n", state, 0, 0 );
+                       break;
+               }
+               if ( *s == '\\' ) {
+                       gotesc = 1;
+               } else {
+                       gotesc = 0;
+               }
+       }
+       *d = '\0';
+
+       if( gotesc ) {
+               /* shouldn't be left in escape */
+               dn = NULL;
+       }
+
+       /* check end state */
+       switch( state ) {
+       case B4LEADTYPE:        /* looking for first type */
+       case B4SEPARATOR:       /* looking for separator */
+       case INVALUE:           /* inside value */
+               break;
+       default:
+               dn = NULL;
+       }
+
+       if( dn == NULL ) {
+               return( ndn );
+               ndn = NULL;
+       }
+
+       return( ndn );
+}
+
+/*
+ * ldap_dn_parent - return a copy of the dn of dn's parent
+ */
+
+char *
+ldap_dn_parent(
+    const char *dn
+)
+{
+       const char      *s;
+       int     inquote;
+
+       if( dn == NULL ) {
+               return NULL;
+       }
+
+       while(*dn && LDAP_SPACE(*dn)) {
+               dn++;
+       }
+
+       if( *dn == '\0' ) {
+               return( NULL );
+       }
+
+       /*
+        * no =, assume it is a dns name, like blah@some.domain.name
+        * if the blah@ part is there, return some.domain.name.  if
+        * it's just some.domain.name, return domain.name.
+        */
+       if ( strchr( dn, '=' ) == NULL ) {
+               if ( (s = strchr( dn, '@' )) == NULL ) {
+                       if ( (s = strchr( dn, '.' )) == NULL ) {
+                               return( NULL );
+                       }
+               }
+               if ( *(s + 1) == '\0' ) {
+                       return( NULL );
+               } else {
+                       return( LDAP_STRDUP( &s[1] ) );
+               }
+       }
+
+       /*
+        * else assume it is an X.500-style name, which looks like
+        * foo=bar,sha=baz,...
+        */
+
+       inquote = 0;
+       for ( s = dn; *s; s++ ) {
+               if ( *s == '\\' ) {
+                       if ( *(s + 1) ) {
+                               s++;
+                       }
+                       continue;
+               }
+               if ( inquote ) {
+                       if ( *s == '"' ) {
+                               inquote = 0;
+                       }
+               } else {
+                       if ( *s == '"' ) {
+                               inquote = 1;
+                       } else if ( LDAP_DNSEPARATOR( *s ) ) {
+                               return( LDAP_STRDUP( &s[1] ) );
+                       }
+               }
+       }
+
+       return( LDAP_STRDUP( "" ) );
+}
+
+char * ldap_dn_rdn( 
+    const char *dn )
+{
+       char    *s;
+       char    *rdn;
+       int     inquote;
+
+       if( dn == NULL ) {
+               return NULL;
+       }
+
+       while(*dn && LDAP_SPACE(*dn)) {
+               dn++;
+       }
+
+       if( *dn == '\0' ) {
+               return( NULL );
+       }
+
+       rdn = LDAP_STRDUP( dn );
+
+       if( rdn == NULL ) {
+               return NULL;
+       }
+
+#ifdef DNS_DN
+       /*
+        * no =, assume it is a dns name, like blah@some.domain.name
+        * if the blah@ part is there, return some.domain.name.  if
+        * it's just some.domain.name, return domain.name.
+        */
+       if ( strchr( rdn, '=' ) == NULL ) {
+               if ( (s = strchr( rdn, '@' )) == NULL ) {
+                       if ( (s = strchr( rdn, '.' )) == NULL ) {
+                               return( rdn );
+                       }
+               }
+               *s = '\0';
+               return( rdn );
+       }
+#endif
+
+       /*
+        * else assume it is an X.500-style name, which looks like
+        * foo=bar,sha=baz,...
+        */
+
+       inquote = 0;
+
+       for ( s = rdn; *s; s++ ) {
+               if ( *s == '\\' ) {
+                       if ( *(s + 1) ) {
+                               s++;
+                       }
+                       continue;
+               }
+               if ( inquote ) {
+                       if ( *s == '"' ) {
+                               inquote = 0;
+                       }
+               } else {
+                       if ( *s == '"' ) {
+                               inquote = 1;
+                       } else if ( LDAP_DNSEPARATOR( *s ) ) {
+                               *s = '\0';
+                               return( rdn );
+                       }
+               }
+       }
+
+       return( rdn );
+}
+
+#endif
index 1771d7283e73f6a17d186f8f1012807d679e1c92..336025db559ded4e89ec37e2353909720434816c 100644 (file)
@@ -1,4 +1,9 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  * Copyright (c) 1993, 1994 Regents of the University of Michigan.
  * All rights reserved.
  *
  * 7 March 1994 by Mark C Smith
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
-#include <stdlib.h>
-#endif /* DOS */
-#endif /* MACOS */
+#endif
 
-#include "lber.h"
-#include "ldap.h"
+#include "ldap-int.h"
 
-#ifndef NEEDPROTOS
-int next_line_tokens();
-void free_strarray();
-static int next_line();
-static char *next_token();
-#else /* !NEEDPROTOS */
-int next_line_tokens( char **bufp, long *blenp, char ***toksp );
-void free_strarray( char **sap );
-static int next_line( char **bufp, long *blenp, char **linep );
-static char *next_token( char ** sp );
-#endif /* !NEEDPROTOS */
+static int next_line LDAP_P(( char **bufp, ber_len_t *blenp, char **linep ));
+static char *next_token LDAP_P(( char ** sp ));
 
 
 
 int
-next_line_tokens( char **bufp, long *blenp, char ***toksp )
+next_line_tokens( char **bufp, ber_len_t *blenp, char ***toksp )
 {
     char       *p, *line, *token, **toks;
     int                rc, tokcnt;
@@ -61,18 +52,18 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp )
        return( rc );
     }
 
-    if (( toks = (char **)calloc( 1, sizeof( char * ))) == NULL ) {
-       free( line );
+    if (( toks = (char **)LDAP_CALLOC( 1, sizeof( char * ))) == NULL ) {
+       LBER_FREE( line );
        return( -1 );
     }
     tokcnt = 0;
 
     p = line;
     while (( token = next_token( &p )) != NULL ) {
-       if (( toks = (char **)realloc( toks, ( tokcnt + 2 ) *
+       if (( toks = (char **)LDAP_REALLOC( toks, ( tokcnt + 2 ) *
                sizeof( char * ))) == NULL ) {
-           free( (char *)toks );
-           free( line );
+           LBER_FREE( (char *)toks );
+           LBER_FREE( line );
            return( -1 );
        }
        toks[ tokcnt ] = token;
@@ -85,11 +76,11 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp )
        toks = NULL;
     }
 
-    free( line );
+    LBER_FREE( line );
 
     if ( tokcnt == 0 ) {
        if ( toks != NULL ) {
-           free( (char *)toks );
+           LBER_FREE( (char *)toks );
        }
     } else {
        *toksp = toks;
@@ -100,10 +91,10 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp )
 
 
 static int
-next_line( char **bufp, long *blenp, char **linep )
+next_line( char **bufp, ber_len_t *blenp, char **linep )
 {
     char       *linestart, *line, *p;
-    long       plen;
+    ber_slen_t plen;
 
     linestart = *bufp;
     p = *bufp;
@@ -141,7 +132,7 @@ next_line( char **bufp, long *blenp, char **linep )
        return( 0 );    /* end of file */
     }
 
-    if (( line = malloc( p - linestart )) == NULL ) {
+    if (( line = LDAP_MALLOC( p - linestart )) == NULL ) {
        *linep = NULL;
        return( -1 );   /* fatal error */
     }
@@ -165,7 +156,7 @@ next_token( char **sp )
 
     p = *sp;
 
-    while ( isspace( *p )) {           /* skip leading white space */
+    while ( isspace( (unsigned char) *p )) {   /* skip leading white space */
        ++p;
     }
 
@@ -180,7 +171,7 @@ next_token( char **sp )
     t = tokstart = p;
 
     for ( ;; ) {
-       if ( *p == '\0' || ( isspace( *p ) && !in_quote )) {
+       if ( *p == '\0' || ( isspace( (unsigned char) *p ) && !in_quote )) {
            if ( *p != '\0' ) {
                ++p;
            }
@@ -202,7 +193,7 @@ next_token( char **sp )
        return( NULL );
     }
 
-    return( strdup( tokstart ));
+    return( LDAP_STRDUP( tokstart ));
 }
 
 
@@ -213,8 +204,8 @@ free_strarray( char **sap )
 
     if ( sap != NULL ) {
        for ( i = 0; sap[ i ] != NULL; ++i ) {
-           free( sap[ i ] );
+           LBER_FREE( sap[ i ] );
        }
-       free( (char *)sap );
+       LBER_FREE( (char *)sap );
     }
 }
index ad1bcd771092beff072315fbbfcf1c097944ba1d..ff15bfe4620da3609bd89dfb66250366d9ea2a03 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
diff --git a/libraries/libldap/extended.c b/libraries/libldap/extended.c
new file mode 100644 (file)
index 0000000..e284b48
--- /dev/null
@@ -0,0 +1,267 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+/*
+ * LDAPv3 Extended Operation Request
+ *     ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ *             requestName      [0] LDAPOID,
+ *             requestValue     [1] OCTET STRING OPTIONAL
+ *     }
+ *
+ * LDAPv3 Extended Operation Response
+ *     ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+ *             COMPONENTS OF LDAPResult,
+ *             responseName     [10] LDAPOID OPTIONAL,
+ *             response         [11] OCTET STRING OPTIONAL
+ *     }
+ *
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+int
+ldap_extended_operation(
+       LDAP                    *ld,
+       LDAP_CONST char *reqoid,
+       struct berval   *reqdata,
+       LDAPControl             **sctrls,
+       LDAPControl             **cctrls,
+       int                             *msgidp )
+{
+       BerElement *ber;
+       int rc;
+
+       Debug( LDAP_DEBUG_TRACE, "ldap_extended_operation\n", 0, 0, 0 );
+
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( reqoid != NULL || *reqoid == '\0' );
+       assert( msgidp != NULL );
+
+       /* must be version 3 (or greater) */
+       if ( ld->ld_version < LDAP_VERSION3 ) {
+               ld->ld_errno = LDAP_NOT_SUPPORTED;
+               return( ld->ld_errno );
+       }
+
+       if( reqoid == NULL || *reqoid == '\0' || msgidp == NULL ) {
+               ld->ld_errno = LDAP_PARAM_ERROR;
+               return( ld->ld_errno );
+       }
+
+       /* create a message to send */
+       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               ld->ld_errno = LDAP_NO_MEMORY;
+               return( ld->ld_errno );
+       }
+
+       if ( reqdata != NULL ) {
+               rc = ber_printf( ber, "{it{tstO}", /* '}' */
+                       ++ld->ld_msgid, LDAP_REQ_EXTENDED,
+                       LDAP_TAG_EXOP_REQ_OID, reqoid,
+                       LDAP_TAG_EXOP_REQ_VALUE, reqdata );
+
+       } else {
+               rc = ber_printf( ber, "{it{ts}", /* '}' */
+                       ++ld->ld_msgid, LDAP_REQ_EXTENDED,
+                       LDAP_TAG_EXOP_REQ_OID, reqoid );
+       }
+
+       if( rc == -1 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free( ber, 1 );
+               return( ld->ld_errno );
+       }
+
+       /* Put Server Controls */
+       if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
+               ber_free( ber, 1 );
+               return ld->ld_errno;
+       }
+
+       if ( ber_printf( ber, /*{*/ "}" ) == -1 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free( ber, 1 );
+               return( ld->ld_errno );
+       }
+
+       /* send the message */
+       *msgidp = ldap_send_initial_request( ld, LDAP_REQ_EXTENDED, NULL, ber );
+
+       return( *msgidp < 0 ? ld->ld_errno : LDAP_SUCCESS );
+}
+
+int
+ldap_extended_operation_s(
+       LDAP                    *ld,
+       LDAP_CONST char *reqoid,
+       struct berval   *reqdata,
+       LDAPControl             **sctrls,
+       LDAPControl             **cctrls,
+       char                    **retoidp,
+       struct berval   **retdatap )
+{
+    int     rc;
+    int     msgid;
+    LDAPMessage *res;
+
+       Debug( LDAP_DEBUG_TRACE, "ldap_extended_operation_s\n", 0, 0, 0 );
+
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( reqoid != NULL || *reqoid == '\0' );
+       assert( retoidp != NULL || retdatap != NULL );
+
+       if( retoidp == NULL || retdatap == NULL ) {
+               ld->ld_errno = LDAP_PARAM_ERROR;
+               return( ld->ld_errno );
+       }
+
+    rc = ldap_extended_operation( ld, reqoid, reqdata,
+               sctrls, cctrls, &msgid );
+        
+    if ( rc != LDAP_SUCCESS ) {
+        return( rc );
+       }
+    if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) {
+        return( ld->ld_errno );
+       }
+
+       *retoidp = NULL;
+       *retdatap = NULL;
+
+       rc = ldap_parse_extended_result( ld, res, retoidp, retdatap, 0 );
+
+       if( rc != LDAP_SUCCESS ) {
+               ldap_msgfree( res );
+               return rc;
+       }
+
+    return( ldap_result2error( ld, res, 1 ) );
+}
+
+/* Parse an extended result */
+int
+ldap_parse_extended_result (
+       LDAP                    *ld,
+       LDAPMessage             *res,
+       char                    **retoidp,
+       struct berval   **retdatap,
+       int                             freeit )
+{
+       BerElement *ber;
+       ber_tag_t rc;
+       ber_tag_t tag;
+       ber_len_t len;
+       struct berval *resdata;
+       ber_int_t errcode;
+       char *resoid;
+
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( res != NULL );
+
+       Debug( LDAP_DEBUG_TRACE, "ldap_parse_extended_result\n", 0, 0, 0 );
+
+       if( ld->ld_version < LDAP_VERSION3 ) {
+               ld->ld_errno = LDAP_NOT_SUPPORTED;
+               return ld->ld_errno;
+       }
+
+       if( res->lm_msgtype == LDAP_RES_EXTENDED ) {
+               ld->ld_errno = LDAP_PARAM_ERROR;
+               return ld->ld_errno;
+       }
+
+       if( retoidp != NULL ) *retoidp = NULL;
+       if( retdatap != NULL ) *retdatap = NULL;
+
+       ber = ber_dup( res->lm_ber );
+
+       if ( ld->ld_error ) {
+               LDAP_FREE( ld->ld_error );
+               ld->ld_error = NULL;
+       }
+
+       if ( ld->ld_matched ) {
+               LDAP_FREE( ld->ld_matched );
+               ld->ld_matched = NULL;
+       }
+
+       rc = ber_scanf( ber, "{iaa" /*}*/, &errcode,
+               &ld->ld_matched, &ld->ld_matched );
+
+       if( rc == LBER_ERROR ) {
+               ld->ld_errno = LDAP_DECODING_ERROR;
+               ber_free( ber, 0 );
+               return ld->ld_errno;
+       }
+
+       resoid = NULL;
+       resdata = NULL;
+
+       tag = ber_peek_tag( ber, &len );
+
+       if( tag == LDAP_TAG_REFERRAL ) {
+               /* skip over referral */
+               tag = ber_scanf( ber, "x" );
+
+               if( tag != LBER_ERROR ) {
+                       tag = ber_peek_tag( ber, &len );
+               }
+       }
+
+       if( tag == LDAP_TAG_EXOP_RES_OID ) {
+               /* we have a resoid */
+               if( ber_scanf( ber, "a", &resoid ) == LBER_ERROR ) {
+                       ld->ld_errno = LDAP_DECODING_ERROR;
+                       ber_free( ber, 0 );
+                       return ld->ld_errno;
+               }
+
+               tag = ber_peek_tag( ber, &len );
+       }
+
+       if( tag == LDAP_TAG_EXOP_RES_VALUE ) {
+               /* we have a resdata */
+               if( ber_scanf( ber, "O", &resoid ) == LBER_ERROR ) {
+                       ld->ld_errno = LDAP_DECODING_ERROR;
+                       ber_free( ber, 0 );
+                       if( resoid != NULL ) LDAP_FREE( resoid );
+                       return ld->ld_errno;
+               }
+       }
+
+       if( retoidp != NULL ) {
+               *retoidp = resoid;
+       } else {
+               LDAP_FREE( resoid );
+       }
+
+       if( retdatap != NULL ) {
+               *retdatap = resdata;
+       } else {
+               ber_bvfree( resdata );
+       }
+
+       ld->ld_errno = errcode;
+
+       if( freeit ) {
+               ldap_msgfree( res );
+       }
+
+       return LDAP_SUCCESS;
+}
index d7a13228e6db9c5245e2fd95313aa4233533fd03..120e1605b0cf5fa7e54f90eb070ec7e590ade7e8 100644 (file)
@@ -1,4 +1,9 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1994 The Regents of the University of Michigan.
  *  All rights reserved.
  *
  *           link in lots of extra code when not using certain features
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1994 The Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <stdlib.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+/*
+ * C-API deallocator
+ */
+void
+ldap_memfree( void *p )
+{
+       LDAP_FREE( p );
+}
+
+void
+ldap_memvfree( void **v )
+{
+       LDAP_VFREE( v );
+}
+
+void *
+ldap_memalloc( ber_len_t s )
+{
+       return LDAP_MALLOC( s );
+}
+
+void *
+ldap_memcalloc( ber_len_t n, ber_len_t s )
+{
+       return LDAP_CALLOC( n, s );
+}
+
+void *
+ldap_memrealloc( void* p, ber_len_t s )
+{
+       return LDAP_REALLOC( p, s );
+}
+
+char *
+ldap_strdup( LDAP_CONST char *p )
+{
+       return LDAP_STRDUP( p );
+}
 
 void
 ldap_getfilter_free( LDAPFiltDesc *lfdp )
@@ -39,31 +70,31 @@ ldap_getfilter_free( LDAPFiltDesc *lfdp )
     for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = nextflp ) {
        for ( fip = flp->lfl_ilist; fip != NULL; fip = nextfip ) {
            nextfip = fip->lfi_next;
-           free( fip->lfi_filter );
-           free( fip->lfi_desc );
-           free( fip );
+           LDAP_FREE( fip->lfi_filter );
+           LDAP_FREE( fip->lfi_desc );
+           LDAP_FREE( fip );
        }
        nextflp = flp->lfl_next;
-       free( flp->lfl_pattern );
-       free( flp->lfl_delims );
-       free( flp->lfl_tag );
-       free( flp );
+       LDAP_FREE( flp->lfl_pattern );
+       LDAP_FREE( flp->lfl_delims );
+       LDAP_FREE( flp->lfl_tag );
+       LDAP_FREE( flp );
     }
 
     if ( lfdp->lfd_curvalcopy != NULL ) {
-       free( lfdp->lfd_curvalcopy );
+       LDAP_FREE( lfdp->lfd_curvalcopy );
     }
     if ( lfdp->lfd_curvalwords != NULL ) {
-       free( lfdp->lfd_curvalwords );
+       LDAP_FREE( lfdp->lfd_curvalwords );
     }
     if ( lfdp->lfd_filtprefix != NULL ) {
-       free( lfdp->lfd_filtprefix );
+       LDAP_FREE( lfdp->lfd_filtprefix );
     }
     if ( lfdp->lfd_filtsuffix != NULL ) {
-       free( lfdp->lfd_filtsuffix );
+       LDAP_FREE( lfdp->lfd_filtsuffix );
     }
 
-    free( lfdp );
+    LDAP_FREE( lfdp );
 }
 
 /*
@@ -82,13 +113,21 @@ ldap_mods_free( LDAPMod **mods, int freemods )
 
        for ( i = 0; mods[i] != NULL; i++ ) {
                if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) {
-                       ber_bvecfree( mods[i]->mod_bvalues );
-               } else {
-                       ldap_value_free( mods[i]->mod_values );
+                       if( mods[i]->mod_bvalues != NULL )
+                               ber_bvecfree( mods[i]->mod_bvalues );
+
+               } else if( mods[i]->mod_values != NULL ) {
+                       LDAP_VFREE( mods[i]->mod_values );
                }
-               free( (char *) mods[i] );
+
+               if ( mods[i]->mod_type != NULL ) {
+                       LDAP_FREE( mods[i]->mod_type );
+               }
+
+               LDAP_FREE( (char *) mods[i] );
        }
 
-       if ( freemods )
-               free( (char *) mods );
+       if ( freemods ) {
+               LDAP_FREE( (char *) mods );
+       }
 }
index 5d77f0be1cd0bf7b5851bb3aa5166c44ccf33387..ec37982a70b27393d3b424ee481d843452822e12 100644 (file)
@@ -1,38 +1,33 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  friendly.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+#include "portable.h"
 
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#endif /* MACOS */
-
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#endif /* DOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/errno.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
 
 char *
-ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
+ldap_friendly_name(
+       LDAP_CONST char *filename,
+       /* LDAP_CONST */ char *uname,
+       LDAPFriendlyMap **map )
 {
        int     i, entries;
        FILE    *fp;
@@ -40,9 +35,7 @@ ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
        char    buf[BUFSIZ];
 
        if ( map == NULL ) {
-#if !defined( MACOS ) && !defined( DOS )
                errno = EINVAL;
-#endif
                return( uname );
        }
 
@@ -57,8 +50,8 @@ ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
                }
                rewind( fp );
 
-               if ( (*map = (FriendlyMap *) malloc( (entries + 1) *
-                   sizeof(FriendlyMap) )) == NULL ) {
+               if ( (*map = (LDAPFriendlyMap *) LDAP_MALLOC( (entries + 1) *
+                   sizeof(LDAPFriendlyMap) )) == NULL ) {
                        fclose( fp );
                        return( uname );
                }
@@ -94,37 +87,37 @@ ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
                                }
                        }
 
-                       (*map)[i].f_unfriendly = strdup( buf );
-                       (*map)[i].f_friendly = strdup( s );
+                       (*map)[i].lf_unfriendly = LDAP_STRDUP( buf );
+                       (*map)[i].lf_friendly   = LDAP_STRDUP( s );
                        i++;
                }
 
                fclose( fp );
-               (*map)[i].f_unfriendly = NULL;
+               (*map)[i].lf_unfriendly = NULL;
        }
 
-       for ( i = 0; (*map)[i].f_unfriendly != NULL; i++ ) {
-               if ( strcasecmp( uname, (*map)[i].f_unfriendly ) == 0 )
-                       return( (*map)[i].f_friendly );
+       for ( i = 0; (*map)[i].lf_unfriendly != NULL; i++ ) {
+               if ( strcasecmp( uname, (*map)[i].lf_unfriendly ) == 0 )
+                       return( (*map)[i].lf_friendly );
        }
        return( uname );
 }
 
 
 void
-ldap_free_friendlymap( FriendlyMap **map )
+ldap_free_friendlymap( LDAPFriendlyMap **map )
 {
-       struct friendly* pF = *map;
+       LDAPFriendlyMap* pF = *map;
 
        if ( pF == NULL )
                return;
 
-       while ( pF->f_unfriendly )
+       while ( pF->lf_unfriendly )
        {
-               free( pF->f_unfriendly );
-               free( pF->f_friendly );
+               LDAP_FREE( pF->lf_unfriendly );
+               LDAP_FREE( pF->lf_friendly );
                pF++;
        }
-       free( *map );
+       LDAP_FREE( *map );
        *map = NULL;
 }
index 50caa774c5330cf05e4d547f2c329333b43f2015..079db4b9f3beddc2ac6fa22a23201e00e8fb2124 100644 (file)
@@ -1,42 +1,41 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  getattr.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+#include "portable.h"
 
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
 #include "ldap-int.h"
 
 char *
 ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber )
 {
-       long    len;
+       char *attr;
 
        Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
 
-       if ( (*ber = alloc_ber_with_options( ld )) == NULLBER ) {
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( entry != NULL );
+       assert( ber != NULL );
+
+       if ( (*ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               *ber = NULL;
                return( NULL );
        }
 
@@ -48,33 +47,36 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber )
         * positioned right before the next attribute type/value sequence.
         */
 
-       len = LDAP_MAX_ATTR_LEN;
-       if ( ber_scanf( *ber, "{x{{sx}", ld->ld_attrbuffer, &len )
+       if ( ber_scanf( *ber, "{x{{ax}" /*}}*/, &attr )
            == LBER_ERROR ) {
                ld->ld_errno = LDAP_DECODING_ERROR;
                ber_free( *ber, 0 );
+               *ber = NULL;
                return( NULL );
        }
 
-       return( ld->ld_attrbuffer );
+       return( attr );
 }
 
 /* ARGSUSED */
 char *
 ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
 {
-       long    len;
+       char *attr;
 
        Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
 
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( entry != NULL );
+       assert( ber != NULL );
+
        /* skip sequence, snarf attribute type, skip values */
-       len = LDAP_MAX_ATTR_LEN;
-       if ( ber_scanf( ber, "{sx}", ld->ld_attrbuffer, &len ) 
+       if ( ber_scanf( ber, "{ax}", &attr ) 
            == LBER_ERROR ) {
                ld->ld_errno = LDAP_DECODING_ERROR;
-               ber_free( ber, 0 );
                return( NULL );
        }
 
-       return( ld->ld_attrbuffer );
+       return( attr );
 }
index 2ea0d037c4eabcf78c9b76a441c8d589a86770ba..0110e298e719649340db1af1513c6c3e8072fc37 100644 (file)
@@ -1,32 +1,29 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1994 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  getdn.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+#include "portable.h"
 
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+static char **explode_name( const char *name, int notypes, int is_dn );
 
 char *
 ldap_get_dn( LDAP *ld, LDAPMessage *entry )
@@ -42,7 +39,7 @@ ldap_get_dn( LDAP *ld, LDAPMessage *entry )
        }
 
        tmp = *entry->lm_ber;   /* struct copy */
-       if ( ber_scanf( &tmp, "{a", &dn ) == LBER_ERROR ) {
+       if ( ber_scanf( &tmp, "{a" /*}*/, &dn ) == LBER_ERROR ) {
                ld->ld_errno = LDAP_DECODING_ERROR;
                return( NULL );
        }
@@ -51,17 +48,25 @@ ldap_get_dn( LDAP *ld, LDAPMessage *entry )
 }
 
 char *
-ldap_dn2ufn( char *dn )
+ldap_dn2ufn( LDAP_CONST char *dn )
 {
        char    *p, *ufn, *r;
        int     state;
 
        Debug( LDAP_DEBUG_TRACE, "ldap_dn2ufn\n", 0, 0, 0 );
 
-       if ( ldap_is_dns_dn( dn ) || ( p = strchr( dn, '=' )) == NULL )
-               return( strdup( dn ));
+       if( dn == NULL ) {
+               return NULL;
+       }
+
+       if ( ldap_is_dns_dn( dn ) ||
+               ( p = strchr( dn, '=' ) ) == NULL )
+       {
+               return( LDAP_STRDUP( dn ) );
+       }
+
 
-       ufn = strdup( ++p );
+       ufn = LDAP_STRDUP( ++p );
 
 #define INQUOTE                1
 #define OUTQUOTE       2
@@ -97,8 +102,8 @@ ldap_dn2ufn( char *dn )
                                char    *rsave = r;
 
                                *r-- = '\0';
-                               while ( !isspace( *r ) && *r != ';'
-                                   && *r != ',' && r > ufn )
+                               while ( !isspace( (unsigned char) *r )
+                                       && *r != ';' && *r != ',' && r > ufn )
                                        r--;
                                r++;
 
@@ -124,47 +129,75 @@ ldap_dn2ufn( char *dn )
 }
 
 char **
-ldap_explode_dns( char *dn )
+ldap_explode_dns( LDAP_CONST char *dn_in )
 {
-       int     ncomps, maxcomps;
        char    *s;
        char    **rdns;
+       char    *tok_r;
+       char    *dn;
 
-       if ( (rdns = (char **) malloc( 8 * sizeof(char *) )) == NULL ) {
+       int ncomps;
+       int maxcomps = 8;
+
+       if ( (dn = LDAP_STRDUP( dn_in )) == NULL ) {
+               return( NULL );
+       }
+
+       if ( (rdns = (char **) LDAP_MALLOC( maxcomps * sizeof(char *) )) == NULL ) {
+               LDAP_FREE( dn );
                return( NULL );
        }
 
-       maxcomps = 8;
        ncomps = 0;
-       for ( s = strtok( dn, "@." ); s != NULL; s = strtok( NULL, "@." ) ) {
+       for ( s = ldap_pvt_strtok( dn, "@.", &tok_r ); s != NULL; 
+             s = ldap_pvt_strtok( NULL, "@.", &tok_r ) )
+       {
                if ( ncomps == maxcomps ) {
                        maxcomps *= 2;
-                       if ( (rdns = (char **) realloc( rdns, maxcomps *
-                           sizeof(char *) )) == NULL ) {
-                               return( NULL );
+                       if ( (rdns = (char **) LDAP_REALLOC( rdns, maxcomps *
+                           sizeof(char *) )) == NULL )
+                       {
+                               LDAP_FREE( dn );
+                               return NULL;
                        }
                }
-               rdns[ncomps++] = strdup( s );
+               rdns[ncomps++] = LDAP_STRDUP( s );
        }
+       LDAP_FREE(dn);
+
        rdns[ncomps] = NULL;
 
+       /* trim rdns */
+       rdns = (char **) LDAP_REALLOC( rdns, (ncomps+1) * sizeof(char*) );
        return( rdns );
 }
 
 char **
-ldap_explode_dn( char *dn, int notypes )
+ldap_explode_dn( LDAP_CONST char *dn, int notypes )
 {
-       char    *p, *q, *rdnstart, **rdns = NULL;
-       int     state, count = 0, endquote, len;
-
        Debug( LDAP_DEBUG_TRACE, "ldap_explode_dn\n", 0, 0, 0 );
 
        if ( ldap_is_dns_dn( dn ) ) {
                return( ldap_explode_dns( dn ) );
        }
+       return explode_name( dn, notypes, 1 );
+}
 
-       rdnstart = dn;
-       p = dn-1;
+char **
+ldap_explode_rdn( LDAP_CONST char *rdn, int notypes )
+{
+       Debug( LDAP_DEBUG_TRACE, "ldap_explode_rdn\n", 0, 0, 0 );
+       return explode_name( rdn, notypes, 0 );
+}
+
+static char **
+explode_name( const char *name, int notypes, int is_dn )
+{
+       const char *p, *q;
+       char **parts = NULL;
+       int     state, count = 0, endquote, len;
+
+       p = name-1;
        state = OUTQUOTE;
 
        do {
@@ -181,33 +214,41 @@ ldap_explode_dn( char *dn, int notypes )
                        else
                                state = INQUOTE;
                        break;
+               case '+':
+                       if (!is_dn)
+                               goto end_part;
+                       break;
                case ';':
                case ',':
+                       if (!is_dn)
+                               break;
+                       goto end_part;
                case '\0':
+               end_part:
                        if ( state == OUTQUOTE ) {
                                ++count;
-                               if ( rdns == NULL ) {
-                                       if (( rdns = (char **)malloc( 8
+                               if ( parts == NULL ) {
+                                       if (( parts = (char **)LDAP_MALLOC( 8
                                                 * sizeof( char *))) == NULL )
                                                return( NULL );
                                } else if ( count >= 8 ) {
-                                       if (( rdns = (char **)realloc( rdns,
+                                       if (( parts = (char **)LDAP_REALLOC( parts,
                                                (count+1) * sizeof( char *)))
                                                == NULL )
                                                return( NULL );
                                }
-                               rdns[ count ] = NULL;
+                               parts[ count ] = NULL;
                                endquote = 0;
                                if ( notypes ) {
-                                       for ( q = rdnstart;
+                                       for ( q = name;
                                            q < p && *q != '='; ++q ) {
                                                ;
                                        }
                                        if ( q < p ) {
-                                               rdnstart = ++q;
+                                               name = ++q;
                                        }
-                                       if ( *rdnstart == '"' ) {
-                                               ++rdnstart;
+                                       if ( *name == '"' ) {
+                                               ++name;
                                        }
                                        
                                        if ( *(p-1) == '"' ) {
@@ -216,12 +257,12 @@ ldap_explode_dn( char *dn, int notypes )
                                        }
                                }
 
-                               len = p - rdnstart;
-                               if (( rdns[ count-1 ] = (char *)calloc( 1,
+                               len = p - name;
+                               if (( parts[ count-1 ] = (char *)LDAP_CALLOC( 1,
                                    len + 1 )) != NULL ) {
-                                       SAFEMEMCPY( rdns[ count-1 ], rdnstart,
+                                       SAFEMEMCPY( parts[ count-1 ], name,
                                            len );
-                                       rdns[ count-1 ][ len ] = '\0';
+                                       parts[ count-1 ][ len ] = '\0';
                                }
 
                                /*
@@ -232,38 +273,24 @@ ldap_explode_dn( char *dn, int notypes )
                                if ( endquote == 1 )
                                        p++;
 
-                               rdnstart = *p ? p + 1 : p;
-                               while ( isspace( *rdnstart ))
-                                       ++rdnstart;
+                               name = *p ? p + 1 : p;
+                               while ( isascii( *name ) && isspace( *name ) )
+                                       ++name;
                        }
                        break;
                }
        } while ( *p );
 
-       return( rdns );
+       return( parts );
 }
 
 
 int
-ldap_is_dns_dn( char *dn )
+ldap_is_dns_dn( LDAP_CONST char *dn )
 {
-       return( dn[ 0 ] != '\0' && strchr( dn, '=' ) == NULL &&
-           strchr( dn, ',' ) == NULL );
-}
-
-
-#if defined( ultrix ) || defined( NeXT )
-
-char *strdup( char *s )
-{
-       char    *p;
-
-       if ( (p = (char *) malloc( strlen( s ) + 1 )) == NULL )
-               return( NULL );
-
-       strcpy( p, s );
-
-       return( p );
+       return( dn[ 0 ] != '\0'
+               && strchr( dn, '=' ) == NULL
+               && strchr( dn, ',' ) == NULL
+               && strchr( dn, ';' ) == NULL );
 }
 
-#endif /* ultrix */
index 4543e88e45a9d96ea1cae3946910d431a8faf616..602721a05ed11124989aefae3565904aeac102c6 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -123,7 +124,7 @@ decode_answer( unsigned char *answer, ber_len_t len )
        rr_len = _getshort( p );
        p += INT16SZ;
        if ( class == C_IN && type == T_TXT ) {
-           int         i, n, pref, txt_len;
+           int         pref, txt_len;
            char        *q, *r;
 
            q = (char *)p;
index f3f896e7b8675eed8abe012c6a4f80c5d95b868a..09721f1d8e991fcc90b570db2c8e03db53f89270 100644 (file)
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  getentry.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+#include "portable.h"
 
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
 
 /* ARGSUSED */
 LDAPMessage *
 ldap_first_entry( LDAP *ld, LDAPMessage *chain )
 {
-       return( chain == NULLMSG || chain->lm_msgtype == LDAP_RES_SEARCH_RESULT
-           ? NULLMSG : chain );
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( chain != NULL );
+
+       if( ld == NULL || chain == NULL ) {
+               return NULL;
+       }
+
+       return chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY
+               ? chain
+               : ldap_next_entry( ld, chain );
 }
 
-/* ARGSUSED */
-LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry )
+LDAPMessage *
+ldap_next_entry( LDAP *ld, LDAPMessage *entry )
 {
-       if ( entry == NULLMSG || entry->lm_chain == NULLMSG
-           || entry->lm_chain->lm_msgtype == LDAP_RES_SEARCH_RESULT )
-               return( NULLMSG );
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( entry != NULL );
 
-       return( entry->lm_chain );
+       if ( ld == NULL || entry == NULL ) {
+               return NULL;
+       }
+
+       for (
+               entry = entry->lm_chain;
+               entry != NULL;
+               entry = entry->lm_chain )
+       {
+               if( entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
+                       return( entry );
+               }
+       }
+
+       return( NULL );
 }
 
-/* ARGSUSED */
 int
 ldap_count_entries( LDAP *ld, LDAPMessage *chain )
 {
        int     i;
 
-       for ( i = 0; chain != NULL && chain->lm_msgtype
-           != LDAP_RES_SEARCH_RESULT; chain = chain->lm_chain )
-               i++;
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+
+       if ( ld == NULL ) {
+               return -1;
+       }
+
+       for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
+               if( chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
+                       i++;
+               }
+       }
 
        return( i );
 }
+
+int
+ldap_get_entry_controls(
+       LDAP *ld,
+       LDAPMessage *entry, 
+       LDAPControl ***sctrls )
+{
+       int rc;
+       BerElement be;
+
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( entry != NULL );
+       assert( sctrls != NULL );
+
+       if ( ld == NULL || sctrls == NULL ||
+               entry == NULL || entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY )
+       {
+               return LDAP_PARAM_ERROR;
+       }
+
+       /* make a local copy of the BerElement */
+       SAFEMEMCPY(&be, entry->lm_ber, sizeof(be));
+
+       if ( ber_scanf( &be, "{xx" /*}*/ ) == LBER_ERROR ) {
+               rc = LDAP_DECODING_ERROR;
+               goto cleanup_and_return;
+       }
+
+       rc = ldap_int_get_controls( &be, sctrls );
+
+cleanup_and_return:
+       if( rc != LDAP_SUCCESS ) {
+               ld->ld_errno = rc;
+
+               if( ld->ld_matched != NULL ) {
+                       LDAP_FREE( ld->ld_matched );
+                       ld->ld_matched = NULL;
+               }
+
+               if( ld->ld_error != NULL ) {
+                       LDAP_FREE( ld->ld_error );
+                       ld->ld_error = NULL;
+               }
+       }
+
+       return rc;
+}
index b0a181a8ef4185c57739d7936da8dd1ebcc9f5bd..efafeb5067658b1e2ff937a6fd4cb163a5a13542 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -243,17 +244,17 @@ ldap_getfirstfilter(
 
        for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = flp->lfl_next ) {
                /* compile tagpat, continue if we fail */
-               if (regcomp(&re, tagpat, 0) != 0)
+               if (regcomp(&re, tagpat, REG_EXTENDED|REG_NOSUB) != 0)
                        continue;
 
-               /* match tagpatern and tag, continue if we fail */
+               /* match tagpattern and tag, continue if we fail */
                rc = regexec(&re, flp->lfl_tag, 0, NULL, 0);
                regfree(&re);
                if (rc != 0)
                        continue;
 
                /* compile flp->ifl_pattern, continue if we fail */
-               if (regcomp(&re, flp->lfl_pattern, 0) != 0)
+               if (regcomp(&re, flp->lfl_pattern, REG_EXTENDED|REG_NOSUB) != 0)
                        continue;
 
                /* match ifl_pattern and lfd_curval, continue if we fail */
index 55102be8ab6f1c753b218fe137732169b27c69b8..a5d5f0ee9d0caa5bab5d01959c600284671ae38b 100644 (file)
@@ -1,49 +1,47 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  getvalues.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+#include "portable.h"
 
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
 
 char **
-ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
+ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
 {
        BerElement      ber;
-       char            attr[LDAP_MAX_ATTR_LEN];
+       char            *attr;
        int             found = 0;
-       long            len;
        char            **vals;
 
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( entry != NULL );
+       assert( target != NULL );
+
        Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 );
 
        ber = *entry->lm_ber;
 
        /* skip sequence, dn, sequence of, and snag the first attr */
-       len = sizeof(attr);
-       if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
+       if ( ber_scanf( &ber, "{x{{a" /*}}}*/, &attr ) == LBER_ERROR ) {
                ld->ld_errno = LDAP_DECODING_ERROR;
                return( NULL );
        }
@@ -53,16 +51,22 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
 
        /* break out on success, return out on error */
        while ( ! found ) {
-               len = sizeof(attr);
-               if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
+               LDAP_FREE(attr);
+               attr = NULL;
+
+               if ( ber_scanf( &ber, /*{*/ "x}{a" /*}*/, &attr ) == LBER_ERROR ) {
                        ld->ld_errno = LDAP_DECODING_ERROR;
                        return( NULL );
                }
 
                if ( strcasecmp( target, attr ) == 0 )
                        break;
+
        }
 
+       LDAP_FREE(attr);
+       attr = NULL;
+
        /* 
         * if we get this far, we've found the attribute and are sitting
         * just before the set of values.
@@ -77,21 +81,24 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
 }
 
 struct berval **
-ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
+ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
 {
        BerElement      ber;
-       char            attr[LDAP_MAX_ATTR_LEN];
+       char            *attr;
        int             found = 0;
-       long            len;
        struct berval   **vals;
 
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( entry != NULL );
+       assert( target != NULL );
+
        Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 );
 
        ber = *entry->lm_ber;
 
        /* skip sequence, dn, sequence of, and snag the first attr */
-       len = sizeof(attr);
-       if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
+       if ( ber_scanf( &ber, "{x{{a" /* }}} */, &attr ) == LBER_ERROR ) {
                ld->ld_errno = LDAP_DECODING_ERROR;
                return( NULL );
        }
@@ -101,8 +108,10 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
 
        /* break out on success, return out on error */
        while ( ! found ) {
-               len = sizeof(attr);
-               if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
+               LDAP_FREE( attr );
+               attr = NULL;
+
+               if ( ber_scanf( &ber, /*{*/ "x}{a" /*}*/, &attr ) == LBER_ERROR ) {
                        ld->ld_errno = LDAP_DECODING_ERROR;
                        return( NULL );
                }
@@ -111,6 +120,9 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
                        break;
        }
 
+       LDAP_FREE( attr );
+       attr = NULL;
+
        /* 
         * if we get this far, we've found the attribute and are sitting
         * just before the set of values.
@@ -147,25 +159,11 @@ ldap_count_values_len( struct berval **vals )
 void
 ldap_value_free( char **vals )
 {
-       int     i;
-
-       if ( vals == NULL )
-               return;
-       for ( i = 0; vals[i] != NULL; i++ )
-               free( vals[i] );
-       free( (char *) vals );
+       LDAP_VFREE( vals );
 }
 
 void
 ldap_value_free_len( struct berval **vals )
 {
-       int     i;
-
-       if ( vals == NULL )
-               return;
-       for ( i = 0; vals[i] != NULL; i++ ) {
-               free( vals[i]->bv_val );
-               free( vals[i] );
-       }
-       free( (char *) vals );
+       ber_bvecfree( vals );
 }
index 8546a348e0306513c11ce9dfeb8c8287c12153f5..69ffdec8efc49d5796ceb017b7457c10d7e25271 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index ce4a8a7f6d54bef4eba2f1bae0a96f164d7f7aaa..731a8b5fc6c25c5b43df0c5efc47a78bf71e3f10 100644 (file)
@@ -1,39 +1,49 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1993 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  kbind.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
+/*
+ *     BindRequest ::= SEQUENCE {
+ *             version         INTEGER,
+ *             name            DistinguishedName,       -- who
+ *             authentication  CHOICE {
+ *                     simple          [0] OCTET STRING -- passwd
+#ifdef HAVE_KERBEROS
+ *                     krbv42ldap      [1] OCTET STRING
+ *                     krbv42dsa       [2] OCTET STRING
 #endif
+ *                     sasl            [3] SaslCredentials     -- LDAPv3
+ *             }
+ *     }
+ *
+ *     BindResponse ::= SEQUENCE {
+ *             COMPONENTS OF LDAPResult,
+ *             serverSaslCreds         OCTET STRING OPTIONAL -- LDAPv3
+ *     }
+ *
+ */
 
-#ifdef KERBEROS
+#include "portable.h"
+
+#ifdef HAVE_KERBEROS
 
 #include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include "msdos.h"
-#endif /* DOS */
-#include <krb.h>
-#include <stdlib.h>
-#if !defined(DOS) && !defined( _WIN32 )
-#include <sys/types.h>
-#endif /* !DOS && !_WIN32 */
-#include <sys/time.h>
-#include <sys/socket.h>
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-int.h"
+#include <ac/stdlib.h>
 
+#include <ac/krb.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
 
 
 /*
@@ -47,42 +57,29 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of
  *     ldap_kerberos_bind1( ld, "cn=manager, o=university of michigan, c=us" )
  */
 int
-ldap_kerberos_bind1( LDAP *ld, char *dn )
+ldap_kerberos_bind1( LDAP *ld, LDAP_CONST char *dn )
 {
        BerElement      *ber;
        char            *cred;
-       int             rc, credlen;
-       char            *get_kerberosv4_credentials();
+       int             rc;
+       ber_len_t credlen;
 #ifdef STR_TRANSLATION
        int             str_translation_on;
 #endif /* STR_TRANSLATION */
 
-       /*
-        * The bind request looks like this:
-        *      BindRequest ::= SEQUENCE {
-        *              version         INTEGER,
-        *              name            DistinguishedName,
-        *              authentication  CHOICE {
-        *                      krbv42ldap      [1] OCTET STRING
-        *                      krbv42dsa       [2] OCTET STRING
-        *              }
-        *      }
-        * all wrapped up in an LDAPMessage sequence.
-        */
-
        Debug( LDAP_DEBUG_TRACE, "ldap_kerberos_bind1\n", 0, 0, 0 );
 
        if ( dn == NULL )
                dn = "";
 
-       if ( (cred = get_kerberosv4_credentials( ld, dn, "ldapserver",
+       if ( (cred = ldap_get_kerberosv4_credentials( ld, dn, "ldapserver",
            &credlen )) == NULL ) {
                return( -1 );   /* ld_errno should already be set */
        }
 
        /* create a message to send */
-       if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
-               free( cred );
+       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               LDAP_FREE( cred );
                return( -1 );
        }
 
@@ -104,26 +101,26 @@ ldap_kerberos_bind1( LDAP *ld, char *dn )
 #endif /* STR_TRANSLATION */
 
        if ( rc == -1 ) {
-               free( cred );
+               LDAP_FREE( cred );
                ber_free( ber, 1 );
                ld->ld_errno = LDAP_ENCODING_ERROR;
                return( -1 );
        }
 
-       free( cred );
+       LDAP_FREE( cred );
 
-#ifndef NO_CACHE
+#ifndef LDAP_NOCACHE
        if ( ld->ld_cache != NULL ) {
                ldap_flush_cache( ld );
        }
-#endif /* !NO_CACHE */
+#endif /* !LDAP_NOCACHE */
 
        /* send the message */
-       return ( send_initial_request( ld, LDAP_REQ_BIND, dn, ber ));
+       return ( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber ));
 }
 
 int
-ldap_kerberos_bind1_s( LDAP *ld, char *dn )
+ldap_kerberos_bind1_s( LDAP *ld, LDAP_CONST char *dn )
 {
        int             msgid;
        LDAPMessage     *res;
@@ -154,12 +151,12 @@ ldap_kerberos_bind1_s( LDAP *ld, char *dn )
  *     ldap_kerberos_bind2( ld, "cn=manager, o=university of michigan, c=us" )
  */
 int
-ldap_kerberos_bind2( LDAP *ld, char *dn )
+ldap_kerberos_bind2( LDAP *ld, LDAP_CONST char *dn )
 {
        BerElement      *ber;
        char            *cred;
-       int             rc, credlen;
-       char            *get_kerberosv4_credentials();
+       int             rc;
+       ber_len_t credlen;
 #ifdef STR_TRANSLATION
        int             str_translation_on;
 #endif /* STR_TRANSLATION */
@@ -169,14 +166,14 @@ ldap_kerberos_bind2( LDAP *ld, char *dn )
        if ( dn == NULL )
                dn = "";
 
-       if ( (cred = get_kerberosv4_credentials( ld, dn, "x500dsa", &credlen ))
+       if ( (cred = ldap_get_kerberosv4_credentials( ld, dn, "x500dsa", &credlen ))
            == NULL ) {
                return( -1 );   /* ld_errno should already be set */
        }
 
        /* create a message to send */
-       if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
-               free( cred );
+       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               LDAP_FREE( cred );
                return( -1 );
        }
 
@@ -198,7 +195,7 @@ ldap_kerberos_bind2( LDAP *ld, char *dn )
        }
 #endif /* STR_TRANSLATION */
 
-       free( cred );
+       LDAP_FREE( cred );
 
        if ( rc == -1 ) {
                ber_free( ber, 1 );
@@ -207,12 +204,12 @@ ldap_kerberos_bind2( LDAP *ld, char *dn )
        }
 
        /* send the message */
-       return ( send_initial_request( ld, LDAP_REQ_BIND, dn, ber ));
+       return ( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber ));
 }
 
 /* synchronous bind to DSA using kerberos */
 int
-ldap_kerberos_bind2_s( LDAP *ld, char *dn )
+ldap_kerberos_bind2_s( LDAP *ld, LDAP_CONST char *dn )
 {
        int             msgid;
        LDAPMessage     *res;
@@ -234,7 +231,7 @@ ldap_kerberos_bind2_s( LDAP *ld, char *dn )
 
 /* synchronous bind to ldap and DSA using kerberos */
 int
-ldap_kerberos_bind_s( LDAP *ld, char *dn )
+ldap_kerberos_bind_s( LDAP *ld, LDAP_CONST char *dn )
 {
        int     err;
 
@@ -249,45 +246,45 @@ ldap_kerberos_bind_s( LDAP *ld, char *dn )
 
 #ifndef AUTHMAN
 /*
- * get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap.
+ * ldap_get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap.
  * The dn of the entry to which to bind is supplied.  It's assumed the
  * user already has a tgt.
  */
 
 char *
-get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len )
+ldap_get_kerberosv4_credentials(
+       LDAP *ld,
+       LDAP_CONST char *who,
+       LDAP_CONST char *service,
+       ber_len_t *len )
 {
        KTEXT_ST        ktxt;
        int             err;
        char            realm[REALM_SZ], *cred, *krbinstance;
 
-       Debug( LDAP_DEBUG_TRACE, "get_kerberosv4_credentials\n", 0, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "ldap_get_kerberosv4_credentials\n", 0, 0, 0 );
 
        if ( (err = krb_get_tf_realm( tkt_string(), realm )) != KSUCCESS ) {
-#ifndef NO_USERINTERFACE
+#ifdef LDAP_LIBUI
                fprintf( stderr, "krb_get_tf_realm failed (%s)\n",
                    krb_err_txt[err] );
-#endif /* NO_USERINTERFACE */
+#endif /* LDAP_LIBUI */
                ld->ld_errno = LDAP_INVALID_CREDENTIALS;
                return( NULL );
        }
 
-#ifdef LDAP_REFERRALS
        krbinstance = ld->ld_defconn->lconn_krbinstance;
-#else /* LDAP_REFERRALS */
-       krbinstance = ld->ld_host;
-#endif /* LDAP_REFERRALS */
 
        if ( (err = krb_mk_req( &ktxt, service, krbinstance, realm, 0 ))
            != KSUCCESS ) {
-#ifndef NO_USERINTERFACE
+#ifdef LDAP_LIBUI
                fprintf( stderr, "krb_mk_req failed (%s)\n", krb_err_txt[err] );
-#endif /* NO_USERINTERFACE */
+#endif /* LDAP_LIBUI */
                ld->ld_errno = LDAP_INVALID_CREDENTIALS;
                return( NULL );
        }
 
-       if ( ( cred = malloc( ktxt.length )) == NULL ) {
+       if ( ( cred = LDAP_MALLOC( ktxt.length )) == NULL ) {
                ld->ld_errno = LDAP_NO_MEMORY;
                return( NULL );
        }
@@ -299,4 +296,4 @@ get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len )
 }
 
 #endif /* !AUTHMAN */
-#endif /* KERBEROS */
+#endif /* HAVE_KERBEROS */
index e9146db127075b985e0816da0e673d53345672a7..ab446da5a979dacc96cdb5281d0c52201a55f3d5 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -299,7 +300,8 @@ void ldap_int_utils_init LDAP_P(( void ));
 /*
  * in print.c
  */
-int ldap_log_printf LDAP_P((LDAP *ld, int level, const char *fmt, ...));
+int ldap_log_printf LDAP_P((LDAP *ld, int level, const char *fmt, ...))
+                    LDAP_GCCATTR((format(printf, 3, 4)));
 
 /*
  * in cache.c
diff --git a/libraries/libldap/ldap.conf b/libraries/libldap/ldap.conf
new file mode 100644 (file)
index 0000000..1d1b786
--- /dev/null
@@ -0,0 +1,17 @@
+# $OpenLDAP$
+#
+# LDAP Defaults
+#
+
+# See ldap.conf(5) for details
+# This file should be world readable.
+
+#BASE  dc=OpenLDAP, dc=Org
+#HOST  ldap.openldap.org
+
+#HOST  ldap.openldap.org ldap-master.openldap.org:666
+#PORT  389
+
+#SIZELIMIT     12
+#TIMELIMIT     15
+#DEREF         never
index c602f7d2e716dc5331a8598e1f92d27a249a44a6..fad388e4d8a1a01619180566d9ca555662b95a44 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+#
 # ldap filter file
 #
 # lines like this that start with # or empty lines are ignored
 #
 
 "finger and ud and go500 and go500gw subtree and web500gw subtree and rp500 and rcpt500 and ufn last"
+    "^$"    ""  "(objectclass=*)"   "default filter"
     "="                " "     "%v"                            "arbitrary filter"
 
-    "^[0-9][0-9-]*$"   " "     "(telephoneNumber=*%v)" "phone number"
+    "^[0-9][0-9\-]*$"  " "     "(telephoneNumber=*%v)"         "phone number"
 
     "@"                " "     "(mail=%v)"                     "email address"
                        "(mail=%v*)"                    "start of email address"
 
-    "^.[. _].*"        ". _"   "(cn=%v1* %v2-)"                "first initial"
+    "^.[\. _].*"       ". _"   "(cn=%v1* %v2-)"                "first initial"
 
     ".*[. _].$"        ". _"   "(cn=%v1-*)"                    "last initial"
 
     "[. _]"    ". _"   "(|(sn=%v1-)(cn=%v1-))"         "exact"
                        "(|(sn~=%v1-)(cn~=%v1-))"       "approximate"
 
-    ".*"       ". "    "(|(cn=%v1)(sn=%v1)(uid=%v1))"  "exact"
-                       "(|(cn~=%v1)(sn~=%v1))"         "approximate"
+    ".*"       ". "    "(|(cn=%v1)(sn=%v1)(ou=%v1))"   "exact"
+                       "(|(cn~=%v1)(sn~=%v1)(ou~=%v1))"        "approximate"
 
 "go500gw onelevel and web500gw onelevel and ufn first and ufn intermediate"
+    "^$"    ""  "(!(objectclass=dSA))"   "default filter"
     "="                " "     "%v"                            "arbitrary filter"
 
-    "^..$"     " "     "(|(o=%v)(c=%v)(l=%v)(co=%v))"          "exact"
-                       "(|(o~=%v)(c~=%v)(l~=%v)(co~=%v))"      "approximate"
+    "^..$"     " "     "(|(o=%v)(c=%v)(l=%v)(co=%v))"          "exact2"
+                       "(|(o~=%v)(c~=%v)(l~=%v)(co~=%v))"      "approximate2"
 
     " "                " "     "(|(o=%v)(l=%v)(co=%v)(ou=%v))"         "exact"
                        "(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))"     "approximate"
 
-    "\."       " "     "(associatedDomain=%v)"                 "exact"
+    "\."       " "     "(associatedDomain=%v)"         "exact"
 
     ".*"       " "     "(|(o=%v)(l=%v)(co=%v)(ou=%v))"         "exact"
                        "(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))"     "approximate"
index 74be091d4c3cf41e10e50592c84ae5bfb220d874..4dfb7a8b45e289bfc6a1a60e2b31941acb53fe08 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 # Version should be 1 now
 Version 1
 #
index f08e3b2757123a2aad34bc6bac213ffe60b3d333..40c1d8bbae0f10b3879a9e641ba79d9fccc802f1 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ##########################################################################
 # LDAP display templates
 ##########################################################################
diff --git a/libraries/libldap/libldap.dsp b/libraries/libldap/libldap.dsp
new file mode 100644 (file)
index 0000000..48692fe
--- /dev/null
@@ -0,0 +1,365 @@
+# Microsoft Developer Studio Project File - Name="libldap" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=libldap - Win32 Single Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "libldap.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "libldap.mak" CFG="libldap - Win32 Single Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "libldap - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "libldap - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE "libldap - Win32 Single Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE "libldap - Win32 Single Release" (based on\
+ "Win32 (x86) Static Library")
+!MESSAGE 
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+
+!IF  "$(CFG)" == "libldap - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\Release"
+# PROP Intermediate_Dir "Release\libldap"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_WINDOWS" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"..\Release\oldap32.lib"
+
+!ELSEIF  "$(CFG)" == "libldap - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\Debug"
+# PROP Intermediate_Dir "Debug\libldap"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"..\Debug\oldap32.lib"
+
+!ELSEIF  "$(CFG)" == "libldap - Win32 Single Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "libldap_"
+# PROP BASE Intermediate_Dir "libldap_"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\SDebug"
+# PROP Intermediate_Dir "SDebug\libldap"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo /out:"..\Debug\oldap32.lib"
+# ADD LIB32 /nologo /out:"..\SDebug\oldap32.lib"
+
+!ELSEIF  "$(CFG)" == "libldap - Win32 Single Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "libldap0"
+# PROP BASE Intermediate_Dir "libldap0"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\SRelease"
+# PROP Intermediate_Dir "SRelease\libldap"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_WINDOWS" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo /out:"..\Release\oldap32.lib"
+# ADD LIB32 /nologo /out:"..\SRelease\oldap32.lib"
+
+!ENDIF 
+
+# Begin Target
+
+# Name "libldap - Win32 Release"
+# Name "libldap - Win32 Debug"
+# Name "libldap - Win32 Single Debug"
+# Name "libldap - Win32 Single Release"
+# Begin Source File
+
+SOURCE=.\abandon.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\add.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\addentry.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\bind.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\cache.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\charray.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\charset.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\cldap.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\compare.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\controls.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\delete.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\digest.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\disptmpl.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\disptmpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\dn.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\dsparse.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\error.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\extended.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\free.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\friendly.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\getattr.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\getdn.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\getdxbyname.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\getentry.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\getfilter.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\getvalues.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\init.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\kbind.c
+# End Source File
+# Begin Source File
+
+SOURCE=".\ldap-int.h"
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ldap.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ldap_cdefs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ldap_config.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ldap_defaults.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ldap_features.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ldap_log.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ldap_pvt.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ldap_schema.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\messages.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\modify.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\modrdn.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\open.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\options.c
+# End Source File
+# Begin Source File
+
+SOURCE=".\os-ip.c"
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\portable.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\print.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\references.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\request.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\result.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\sasl.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\sbind.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\schema.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\search.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\sort.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\srchpref.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\srchpref.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\string.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\ufn.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\unbind.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\url.c
+# End Source File
+# Begin Source File
+
+SOURCE=".\util-int.c"
+# End Source File
+# End Target
+# End Project
diff --git a/libraries/libldap/messages.c b/libraries/libldap/messages.c
new file mode 100644 (file)
index 0000000..57e331d
--- /dev/null
@@ -0,0 +1,66 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*
+ *  messages.c
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+LDAPMessage *
+ldap_first_message( LDAP *ld, LDAPMessage *chain )
+{
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+
+       if ( ld == NULL || chain == NULL ) {
+               return NULL;
+       }
+       
+       return chain;
+}
+
+LDAPMessage *
+ldap_next_message( LDAP *ld, LDAPMessage *msg )
+{
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+
+       if ( ld == NULL || msg == NULL || msg->lm_chain == NULL ) {
+               return NULL;
+       }
+
+       return( msg->lm_chain );
+}
+
+int
+ldap_count_messages( LDAP *ld, LDAPMessage *chain )
+{
+       int     i;
+
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+
+       if ( ld == NULL ) {
+               return -1;
+       }
+
+       for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
+               i++;
+       }
+
+       return( i );
+}
index 316dde787f7af9c61d80837fb169c542788ada09..a758fc160798fe3e844da0a38f52060ce0604df7 100644 (file)
@@ -1,38 +1,38 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  modify.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
 
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
 
-#include "lber.h"
-#include "ldap.h"
 #include "ldap-int.h"
 
 /*
- * ldap_modify - initiate an ldap (and X.500) modify operation.  Parameters:
+ * ldap_modify_ext - initiate an ldap extended modify operation.
+ *
+ * Parameters:
  *
  *     ld              LDAP descriptor
  *     dn              DN of the object to modify
  *     mods            List of modifications to make.  This is null-terminated
  *                     array of struct ldapmod's, specifying the modifications
  *                     to perform.
+ *     sctrls  Server Controls
+ *     cctrls  Client Controls
+ *     msgidp  Message ID pointer
  *
  * Example:
  *     LDAPMod *mods[] = { 
@@ -40,10 +40,15 @@ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of
  *                     { LDAP_MOD_REPLACE, "sn", { "jensen", 0 } },
  *                     0
  *             }
- *     msgid = ldap_modify( ld, dn, mods );
+ *     rc=  ldap_modify_ext( ld, dn, mods, sctrls, cctrls, &msgid );
  */
 int
-ldap_modify( LDAP *ld, char *dn, LDAPMod **mods )
+ldap_modify_ext( LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAPMod **mods,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls,
+       int *msgidp )
 {
        BerElement      *ber;
        int             i, rc;
@@ -66,56 +71,108 @@ ldap_modify( LDAP *ld, char *dn, LDAPMod **mods )
         *      }
         */
 
-       Debug( LDAP_DEBUG_TRACE, "ldap_modify\n", 0, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "ldap_modify_ext\n", 0, 0, 0 );
 
        /* create a message to send */
-       if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
-               return( -1 );
+       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               return( LDAP_NO_MEMORY );
        }
 
-       if ( ber_printf( ber, "{it{s{", ++ld->ld_msgid, LDAP_REQ_MODIFY, dn )
+       if ( ber_printf( ber, "{it{s{" /*}}}*/, ++ld->ld_msgid, LDAP_REQ_MODIFY, dn )
            == -1 ) {
                ld->ld_errno = LDAP_ENCODING_ERROR;
                ber_free( ber, 1 );
-               return( -1 );
+               return( ld->ld_errno );
        }
 
        /* for each modification to be performed... */
        for ( i = 0; mods[i] != NULL; i++ ) {
                if (( mods[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) {
                        rc = ber_printf( ber, "{e{s[V]}}",
-                           mods[i]->mod_op & ~LDAP_MOD_BVALUES,
+                           (ber_int_t) ( mods[i]->mod_op & ~LDAP_MOD_BVALUES ),
                            mods[i]->mod_type, mods[i]->mod_bvalues );
                } else {
-                       rc = ber_printf( ber, "{e{s[v]}}", mods[i]->mod_op,
+                       rc = ber_printf( ber, "{e{s[v]}}",
+                               (ber_int_t) mods[i]->mod_op,
                            mods[i]->mod_type, mods[i]->mod_values );
                }
 
                if ( rc == -1 ) {
                        ld->ld_errno = LDAP_ENCODING_ERROR;
                        ber_free( ber, 1 );
-                       return( -1 );
+                       return( ld->ld_errno );
                }
        }
 
-       if ( ber_printf( ber, "}}}" ) == -1 ) {
+       if ( ber_printf( ber, /*{{*/ "}}" ) == -1 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free( ber, 1 );
+               return( ld->ld_errno );
+       }
+
+       /* Put Server Controls */
+       if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
+               ber_free( ber, 1 );
+               return ld->ld_errno;
+       }
+
+       if ( ber_printf( ber, /*{*/ "}" ) == -1 ) {
                ld->ld_errno = LDAP_ENCODING_ERROR;
                ber_free( ber, 1 );
-               return( -1 );
+               return( ld->ld_errno );
        }
 
        /* send the message */
-       return( send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber ));
+       *msgidp = ldap_send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber );
+       return( *msgidp < 0 ? ld->ld_errno : LDAP_SUCCESS );
 }
 
+/*
+ * ldap_modify - initiate an ldap modify operation.
+ *
+ * Parameters:
+ *
+ *     ld              LDAP descriptor
+ *     dn              DN of the object to modify
+ *     mods            List of modifications to make.  This is null-terminated
+ *                     array of struct ldapmod's, specifying the modifications
+ *                     to perform.
+ *
+ * Example:
+ *     LDAPMod *mods[] = { 
+ *                     { LDAP_MOD_ADD, "cn", { "babs jensen", "babs", 0 } },
+ *                     { LDAP_MOD_REPLACE, "sn", { "jensen", 0 } },
+ *                     0
+ *             }
+ *     msgid = ldap_modify( ld, dn, mods );
+ */
 int
-ldap_modify_s( LDAP *ld, char *dn, LDAPMod **mods )
+ldap_modify( LDAP *ld, LDAP_CONST char *dn, LDAPMod **mods )
 {
+       int rc, msgid;
+
+       Debug( LDAP_DEBUG_TRACE, "ldap_modify\n", 0, 0, 0 );
+
+       rc = ldap_modify_ext( ld, dn, mods, NULL, NULL, &msgid );
+
+       if ( rc != LDAP_SUCCESS )
+               return -1;
+
+       return msgid;
+}
+
+int
+ldap_modify_ext_s( LDAP *ld, LDAP_CONST char *dn,
+       LDAPMod **mods, LDAPControl **sctrl, LDAPControl **cctrl )
+{
+       int             rc;
        int             msgid;
        LDAPMessage     *res;
 
-       if ( (msgid = ldap_modify( ld, dn, mods )) == -1 )
-               return( ld->ld_errno );
+       rc = ldap_modify_ext( ld, dn, mods, sctrl, cctrl, &msgid );
+
+       if ( rc != LDAP_SUCCESS )
+               return( rc );
 
        if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
                return( ld->ld_errno );
@@ -123,3 +180,9 @@ ldap_modify_s( LDAP *ld, char *dn, LDAPMod **mods )
        return( ldap_result2error( ld, res, 1 ) );
 }
 
+int
+ldap_modify_s( LDAP *ld, LDAP_CONST char *dn, LDAPMod **mods )
+{
+       return ldap_modify_ext_s( ld, dn, mods, NULL, NULL );
+}
+
index f4624a919a0b222c76baac3a4a4f06082f6ee9c7..209ec4315ad3814b6f1d3a125aad70c58edb488f 100644 (file)
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  modrdn.c
  */
+/*
+ * Support for MODIFYDN REQUEST V3 (newSuperior) by:
+ *
+ * Copyright 1999, Juan C. Gomez, All rights reserved.
+ * This software is not subject to any license of Silicon Graphics 
+ * Inc. or Purdue University.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * without restriction or fee of any kind as long as this notice
+ * is preserved.
+ */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+/*
+ * A modify rdn request looks like this:
+ *     ModifyRDNRequest ::= SEQUENCE {
+ *             entry           DistinguishedName,
+ *             newrdn          RelativeDistinguishedName,
+ *             deleteoldrdn    BOOLEAN
+ *             newSuperior     [0] DistinguishedName   [v3 only]
+ *     }
+ */
 
-#include <stdio.h>
-#include <string.h>
+#include "portable.h"
 
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
+#include <stdio.h>
 
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
 
-#include "lber.h"
-#include "ldap.h"
 #include "ldap-int.h"
 
 /*
- * ldap_modrdn2 - initiate an ldap (and X.500) modifyRDN operation. Parameters:
+ * ldap_rename - initiate an ldap extended modifyDN operation.
  *
- *     ld              LDAP descriptor
- *     dn              DN of the object to modify
- *     newrdn          RDN to give the object
+ * Parameters:
+ *     ld                              LDAP descriptor
+ *     dn                              DN of the object to modify
+ *     newrdn                  RDN to give the object
  *     deleteoldrdn    nonzero means to delete old rdn values from the entry
+ *     newSuperior             DN of the new parent if applicable
  *
- * Example:
- *     msgid = ldap_modrdn( ld, dn, newrdn );
+ * Returns the LDAP error code.
  */
+
 int
-ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
+ldap_rename(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *newrdn,
+       int deleteoldrdn,
+       LDAP_CONST char *newSuperior,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls,
+       int *msgidp )
 {
        BerElement      *ber;
+       int rc;
 
-       /*
-        * A modify rdn request looks like this:
-        *      ModifyRDNRequest ::= SEQUENCE {
-        *              entry           DistinguishedName,
-        *              newrdn          RelativeDistinguishedName,
-        *              deleteoldrdn    BOOLEAN
-        *      }
-        */
-
-       Debug( LDAP_DEBUG_TRACE, "ldap_modrdn\n", 0, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "ldap_rename\n", 0, 0, 0 );
 
        /* create a message to send */
-       if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
-               return( -1 );
+       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               return( LDAP_NO_MEMORY );
+       }
+
+       if( newSuperior != NULL ) {
+               /* must be version 3 (or greater) */
+               if ( ld->ld_version < LDAP_VERSION3 ) {
+                       ld->ld_errno = LDAP_NOT_SUPPORTED;
+                       ber_free( ber, 1 );
+                       return( ld->ld_errno );
+               }
+
+               rc = ber_printf( ber, "{it{ssbts}", /* '}' */ 
+                       ++ld->ld_msgid, LDAP_REQ_MODDN,
+                       dn, newrdn, (ber_int_t) deleteoldrdn,
+                       LDAP_TAG_NEWSUPERIOR, newSuperior );
+
+       } else {
+               rc = ber_printf( ber, "{it{ssb}", /* '}' */ 
+                       ++ld->ld_msgid, LDAP_REQ_MODDN,
+                       dn, newrdn, (ber_int_t) deleteoldrdn );
        }
 
-       if ( ber_printf( ber, "{it{ssb}}", ++ld->ld_msgid, LDAP_REQ_MODRDN, dn,
-           newrdn, deleteoldrdn ) == -1 ) {
+       if ( rc < 0 ) {
                ld->ld_errno = LDAP_ENCODING_ERROR;
                ber_free( ber, 1 );
-               return( -1 );
+               return( ld->ld_errno );
+       }
+
+       /* Put Server Controls */
+       if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
+               ber_free( ber, 1 );
+               return ld->ld_errno;
+       }
+
+       rc = ber_printf( ber, /*{*/ "}" );
+       if ( rc < 0 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free( ber, 1 );
+               return( ld->ld_errno );
        }
 
        /* send the message */
-       return ( send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber ));
+       *msgidp = ldap_send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber );
+       
+       if( *msgidp < 0 ) {
+               return( ld->ld_errno );
+       }
+
+       return LDAP_SUCCESS;
 }
 
+
+/*
+ * ldap_rename2 - initiate an ldap (and X.500) modifyDN operation. Parameters:
+ *     (LDAP V3 MODIFYDN REQUEST)
+ *     ld              LDAP descriptor
+ *     dn              DN of the object to modify
+ *     newrdn          RDN to give the object
+ *     deleteoldrdn    nonzero means to delete old rdn values from the entry
+ *     newSuperior     DN of the new parent if applicable
+ *
+ * ldap_rename2 uses a U-Mich Style API.  It returns the msgid.
+ */
+
 int
-ldap_modrdn( LDAP *ld, char *dn, char *newrdn )
+ldap_rename2(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *newrdn,
+       int deleteoldrdn,
+       LDAP_CONST char *newSuperior )
 {
-       return( ldap_modrdn2( ld, dn, newrdn, 1 ) );
+       int msgid;
+       int rc;
+
+       Debug( LDAP_DEBUG_TRACE, "ldap_rename2\n", 0, 0, 0 );
+
+       rc = ldap_rename( ld, dn, newrdn, deleteoldrdn, newSuperior,
+               NULL, NULL, &msgid );
+
+       return rc == LDAP_SUCCESS ? msgid : -1;
 }
 
+
+/*
+ * ldap_modrdn2 - initiate an ldap modifyRDN operation. Parameters:
+ *
+ *     ld              LDAP descriptor
+ *     dn              DN of the object to modify
+ *     newrdn          RDN to give the object
+ *     deleteoldrdn    nonzero means to delete old rdn values from the entry
+ *
+ * Example:
+ *     msgid = ldap_modrdn( ld, dn, newrdn );
+ */
 int
-ldap_modrdn2_s( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
+ldap_modrdn2( LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *newrdn,
+       int deleteoldrdn )
 {
-       int             msgid;
-       LDAPMessage     *res;
+       return ldap_rename2( ld, dn, newrdn, deleteoldrdn, NULL );
+}
 
-       if ( (msgid = ldap_modrdn2( ld, dn, newrdn, deleteoldrdn )) == -1 )
-               return( ld->ld_errno );
+int
+ldap_modrdn( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn )
+{
+       return( ldap_rename2( ld, dn, newrdn, 1, NULL ) );
+}
 
-       if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
-               return( ld->ld_errno );
 
-       return( ldap_result2error( ld, res, 1 ) );
+int
+ldap_rename_s(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *newrdn,
+       int deleteoldrdn,
+       LDAP_CONST char *newSuperior,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls )
+{
+       int rc;
+       int msgid;
+       LDAPMessage *res;
+
+       rc = ldap_rename( ld, dn, newrdn, deleteoldrdn,
+               newSuperior, sctrls, cctrls, &msgid );
+
+       if( rc != LDAP_SUCCESS ) {
+               return rc;
+       }
+
+       rc = ldap_result( ld, msgid, 1, NULL, &res );
+
+       if( rc == -1 ) {
+               return ld->ld_errno;
+       }
+
+       return ldap_result2error( ld, res, 1 );
 }
 
 int
-ldap_modrdn_s( LDAP *ld, char *dn, char *newrdn )
+ldap_rename2_s(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *newrdn,
+       int deleteoldrdn,
+       LDAP_CONST char *newSuperior )
 {
-       return( ldap_modrdn2_s( ld, dn, newrdn, 1 ) );
+       return ldap_rename_s( ld, dn, newrdn, deleteoldrdn, newSuperior, NULL, NULL );
 }
+
+int
+ldap_modrdn2_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn, int deleteoldrdn )
+{
+       return ldap_rename_s( ld, dn, newrdn, deleteoldrdn, NULL, NULL, NULL );
+}
+
+int
+ldap_modrdn_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn )
+{
+       return ldap_rename_s( ld, dn, newrdn, 1, NULL, NULL, NULL );
+}
+
index 93019b0915c52b2e55bfb5d9d73f9035cbf2fc81..e8785387f5507c4cb7b6f3328e1953b70d51ef4e 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 0d978e3274448773bd443a692a5e53c8a9156c80..12edf629fcfc1852df3c05b2d292bae35fbe0429 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 42460cccecc85facb39faa45d3197a86a4265eab..2eb1c02eff228ad67b32453ea7679677b77770d7 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -187,8 +188,8 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_in *sin, int async)
                tv.tv_sec = opt_tv->tv_sec;
        }
 
-       osip_debug(ld, "ldap_connect_timeout: fd: %d tm: %d async: %d\n",
-                       s, opt_tv ? tv.tv_sec : -1, async);
+       osip_debug(ld, "ldap_connect_timeout: fd: %d tm: %ld async: %d\n",
+                       s, opt_tv ? tv.tv_sec : -1L, async);
 
        if ( ldap_pvt_ndelay_on(ld, s) == -1 )
                return ( -1 );
diff --git a/libraries/libldap/print.c b/libraries/libldap/print.c
new file mode 100644 (file)
index 0000000..a6616c5
--- /dev/null
@@ -0,0 +1,60 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/ctype.h>
+#include <ac/stdarg.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+/*
+ * ldap log 
+ */
+
+static int ldap_log_check( LDAP *ld, int loglvl )
+{
+       int errlvl;
+
+       if(ld == NULL) {
+               errlvl = ldap_debug;
+       } else {
+               errlvl = ld->ld_errno;
+       }
+
+       return errlvl & loglvl ? 1 : 0;
+}
+
+int ldap_log_printf( LDAP *ld, int loglvl, const char *fmt, ... )
+{
+       char buf[ 1024 ];
+       va_list ap;
+
+       if ( !ldap_log_check( ld, loglvl )) {
+               return 0;
+       }
+
+       va_start( ap, fmt );
+
+#ifdef HAVE_VSNPRINTF
+       buf[sizeof(buf) - 1] = '\0';
+       vsnprintf( buf, sizeof(buf)-1, fmt, ap );
+#elif HAVE_VSPRINTF
+       vsprintf( buf, fmt, ap ); /* hope it's not too long */
+#else
+       /* use doprnt() */
+       chokeme = "choke me! I don't have a doprnt manual handy!";
+#endif
+
+       va_end(ap);
+
+       (*ber_pvt_log_print)( buf );
+       return 1;
+}
diff --git a/libraries/libldap/references.c b/libraries/libldap/references.c
new file mode 100644 (file)
index 0000000..371919d
--- /dev/null
@@ -0,0 +1,157 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*
+ *  references.c
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+LDAPMessage *
+ldap_first_reference( LDAP *ld, LDAPMessage *chain )
+{
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( chain !=  NULL );
+
+       if ( ld == NULL || chain == NULL ) {
+               return NULL;
+       }
+
+       return chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE
+               ? chain
+               : ldap_next_reference( ld, chain );
+}
+
+LDAPMessage *
+ldap_next_reference( LDAP *ld, LDAPMessage *ref )
+{
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( ref !=  NULL );
+
+       if ( ld == NULL || ref == NULL ) {
+               return NULL;
+       }
+
+       for (
+               ref = ref->lm_chain;
+               ref != NULL;
+               ref = ref->lm_chain )
+       {
+               if( ref->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
+                       return( ref );
+               }
+       }
+
+       return( NULL );
+}
+
+int
+ldap_count_references( LDAP *ld, LDAPMessage *chain )
+{
+       int     i;
+
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( chain !=  NULL );
+
+       if ( ld == NULL ) {
+               return -1;
+       }
+
+       
+       for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
+               if( chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
+                       i++;
+               }
+       }
+
+       return( i );
+}
+
+int
+ldap_parse_reference( 
+       LDAP            *ld,    
+       LDAPMessage     *ref,
+       char            ***referralsp,
+       LDAPControl     ***serverctrls,
+       int             freeit)
+{
+       BerElement be;
+       char **refs = NULL;
+       int rc;
+
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( ref !=  NULL );
+
+       if( ld == NULL || ref == NULL ||
+               ref->lm_msgtype != LDAP_RES_SEARCH_REFERENCE )
+       {
+               return LDAP_PARAM_ERROR;
+       }
+
+       /* make a private copy of BerElement */
+       SAFEMEMCPY(&be, ref->lm_ber, sizeof(be));
+       
+       if ( ber_scanf( &be, "{v" /*}*/, &refs ) == LBER_ERROR ) {
+               rc = LDAP_DECODING_ERROR;
+               goto free_and_return;
+       }
+
+       if ( serverctrls == NULL ) {
+               rc = LDAP_SUCCESS;
+               goto free_and_return;
+       }
+
+       if ( ber_scanf( &be, /*{*/ "}" ) == LBER_ERROR ) {
+               rc = LDAP_DECODING_ERROR;
+               goto free_and_return;
+       }
+
+       rc = ldap_int_get_controls( &be, serverctrls );
+
+free_and_return:
+
+       if( referralsp != NULL ) {
+               /* provide references regradless of return code */
+               *referralsp = refs;
+
+       } else {
+               ldap_value_free( refs );
+       }
+
+       if( freeit ) {
+               ldap_msgfree( ref );
+       }
+
+       if( rc != LDAP_SUCCESS ) {
+               ld->ld_errno = rc;
+
+               if( ld->ld_matched != NULL ) {
+                       LDAP_FREE( ld->ld_matched );
+                       ld->ld_matched = NULL;
+               }
+
+               if( ld->ld_error != NULL ) {
+                       LDAP_FREE( ld->ld_error );
+                       ld->ld_error = NULL;
+               }
+       }
+
+       return rc;
+}
index a807d9c2e0452c46e97ae6f2ac26669af76c2825..07da8e9bcec79d63a8c3a8c9dc862afc6082c72f 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 3f8408df18f7ae7b590de4a83f44a95299fad68c..a47e0577e97b557058ea13bbcf557a01f6b94564 100644 (file)
@@ -1,88 +1,50 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  result.c - wait for an ldap result
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+/*
+ * LDAPv3 (RFC2251)
+ *     LDAPResult ::= SEQUENCE {
+ *             resultCode              ENUMERATED { ... },
+ *             matchedDN               LDAPDN,
+ *             errorMessage    LDAPString,
+ *             referral                Referral OPTIONAL
+ *     }
+ *     Referral ::= SEQUENCE OF LDAPURL        (one or more)
+ *     LDAPURL ::= LDAPString                          (limited to URL chars)
+ */
 
-#include <stdio.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include <time.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <time.h>
-#include "msdos.h"
-#ifdef PCNFS
-#include <tklib.h>
-#include <tk_errno.h>
-#include <bios.h>
-#endif /* PCNFS */
-#ifdef NCSA
-#include "externs.h"
-#endif /* NCSA */
-#else /* DOS */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#ifdef _AIX
-#include <sys/select.h>
-#endif /* _AIX */
 #include "portable.h"
-#endif /* DOS */
-#endif /* MACOS */
-#ifdef VMS
-#include "ucx_select.h"
-#endif
-#include "lber.h"
-#include "ldap.h"
+
+#include <stdio.h>
+
+#include <ac/stdlib.h>
+
+#include <ac/errno.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
 #include "ldap-int.h"
 
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-
-#ifdef NEEDPROTOS
-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, struct timeval *timeout,
-       LDAPMessage **result );
-#ifdef LDAP_REFERRALS
-static int read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc,
-       LDAPMessage **result );
-static int build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr );
-static void merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr );
-#else /* LDAP_REFERRALS */
-static int read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
-       LDAPMessage **result );
-#endif /* LDAP_REFERRALS */
-#if defined( CLDAP ) || !defined( LDAP_REFERRALS )
-static int ldap_select1( LDAP *ld, struct timeval *timeout );
-#endif
-#else /* NEEDPROTOS */
-static int ldap_abandoned();
-static int ldap_mark_abandoned();
-static int wait4msg();
-static int read1msg();
-#ifdef LDAP_REFERRALS
-static int build_result_ber();
-static void merge_error_info();
-#endif /* LDAP_REFERRALS */
-#if defined( CLDAP ) || !defined( LDAP_REFERRALS )
-static int ldap_select1();
-#endif
-#endif /* NEEDPROTOS */
 
-#if !defined( MACOS ) && !defined( DOS )
-extern int     errno;
-#endif
+static int ldap_abandoned LDAP_P(( LDAP *ld, ber_int_t msgid ));
+static int ldap_mark_abandoned LDAP_P(( LDAP *ld, ber_int_t msgid ));
+static int wait4msg LDAP_P(( LDAP *ld, ber_int_t msgid, int all, struct timeval *timeout,
+       LDAPMessage **result ));
+static ber_tag_t try_read1msg LDAP_P(( LDAP *ld, ber_int_t msgid,
+       int all, Sockbuf *sb, LDAPConn *lc, LDAPMessage **result ));
+static ber_tag_t build_result_ber LDAP_P(( LDAP *ld, BerElement **bp, LDAPRequest *lr ));
+static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ));
 
 
 /*
@@ -100,11 +62,29 @@ extern int errno;
  *     ldap_result( s, msgid, all, timeout, result )
  */
 int
-ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout,
+ldap_result(
+       LDAP *ld,
+       int msgid,
+       int all,
+       struct timeval *timeout,
        LDAPMessage **result )
 {
        LDAPMessage     *lm, *lastlm, *nextlm;
 
+       assert( ld != NULL );
+       assert( result != NULL );
+
+       Debug( LDAP_DEBUG_TRACE, "ldap_result\n", 0, 0, 0 );
+
+       if( ld == NULL ) {
+               return -1;
+       }
+
+       if( result == NULL ) {
+               ld->ld_errno = LDAP_PARAM_ERROR;
+               return -1;
+       }
+
        /*
         * First, look through the list of responses we have received on
         * this association and see if the response we're interested in
@@ -112,17 +92,15 @@ ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout,
         * wait until it arrives or timeout occurs.
         */
 
-       Debug( LDAP_DEBUG_TRACE, "ldap_result\n", 0, 0, 0 );
-
-       *result = NULLMSG;
-       lastlm = NULLMSG;
-       for ( lm = ld->ld_responses; lm != NULLMSG; lm = nextlm ) {
+       *result = NULL;
+       lastlm = NULL;
+       for ( lm = ld->ld_responses; lm != NULL; lm = nextlm ) {
                nextlm = lm->lm_next;
 
                if ( ldap_abandoned( ld, lm->lm_msgid ) ) {
                        ldap_mark_abandoned( ld, lm->lm_msgid );
 
-                       if ( lastlm == NULLMSG ) {
+                       if ( lastlm == NULL ) {
                                ld->ld_responses = lm->lm_next;
                        } else {
                                lastlm->lm_next = nextlm;
@@ -138,37 +116,37 @@ ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout,
 
                        if ( all == 0
                            || (lm->lm_msgtype != LDAP_RES_SEARCH_RESULT
+                           && lm->lm_msgtype != LDAP_RES_SEARCH_REFERENCE      /* LDAPv3 */
                            && lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY) )
                                break;
 
-                       for ( tmp = lm; tmp != NULLMSG; tmp = tmp->lm_chain ) {
+                       for ( tmp = lm; tmp != NULL; tmp = tmp->lm_chain ) {
                                if ( tmp->lm_msgtype == LDAP_RES_SEARCH_RESULT )
                                        break;
                        }
 
-                       if ( tmp == NULLMSG ) {
-                               return( wait4msg( ld, msgid, all, timeout,
-                                   result ) );
+                       if ( tmp == NULL ) {
+                               lm = NULL;
                        }
 
                        break;
                }
                lastlm = lm;
        }
-       if ( lm == NULLMSG ) {
+       if ( lm == NULL ) {
                return( wait4msg( ld, msgid, all, timeout, result ) );
        }
 
-       if ( lastlm == NULLMSG ) {
-               ld->ld_responses = (all == 0 && lm->lm_chain != NULLMSG
+       if ( lastlm == NULL ) {
+               ld->ld_responses = (all == 0 && lm->lm_chain != NULL
                    ? lm->lm_chain : lm->lm_next);
        } else {
-               lastlm->lm_next = (all == 0 && lm->lm_chain != NULLMSG
+               lastlm->lm_next = (all == 0 && lm->lm_chain != NULL
                    ? lm->lm_chain : lm->lm_next);
        }
        if ( all == 0 )
-               lm->lm_chain = NULLMSG;
-       lm->lm_next = NULLMSG;
+               lm->lm_chain = NULL;
+       lm->lm_next = NULL;
 
        *result = lm;
        ld->ld_errno = LDAP_SUCCESS;
@@ -176,15 +154,21 @@ ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout,
 }
 
 static int
-wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
+wait4msg(
+       LDAP *ld,
+       ber_int_t msgid,
+       int all,
+       struct timeval *timeout,
        LDAPMessage **result )
 {
        int             rc;
        struct timeval  tv, *tvp;
-       long            start_time, tmp_time;
-#ifdef LDAP_REFERRALS
+       time_t          start_time = 0;
+       time_t          tmp_time;
        LDAPConn        *lc, *nextlc;
-#endif /* LDAP_REFERRALS */
+
+       assert( ld != NULL );
+       assert( result != NULL );
 
 #ifdef LDAP_DEBUG
        if ( timeout == NULL ) {
@@ -192,7 +176,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                    0, 0, 0 );
        } else {
                Debug( LDAP_DEBUG_TRACE, "wait4msg (timeout %ld sec, %ld usec)\n",
-                   timeout->tv_sec, timeout->tv_usec, 0 );
+                      (long) timeout->tv_sec, (long) timeout->tv_usec, 0 );
        }
 #endif /* LDAP_DEBUG */
 
@@ -201,44 +185,20 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
        } else {
                tv = *timeout;
                tvp = &tv;
-               start_time = (long)time( NULL );
+               start_time = time( NULL );
        }
                    
        rc = -2;
        while ( rc == -2 ) {
-#ifndef LDAP_REFERRALS
-               /* hack attack */
-               if ( ld->ld_sb.sb_ber.ber_ptr >= ld->ld_sb.sb_ber.ber_end ) {
-                       rc = ldap_select1( ld, tvp );
-
-#if !defined( MACOS ) && !defined( DOS )
-                       if ( rc == 0 || ( rc == -1 && (( ld->ld_options &
-                           LDAP_OPT_RESTART ) == 0 || errno != EINTR ))) {
-#else
-                       if ( rc == -1 || rc == 0 ) {
-#endif
-                               ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :
-                                   LDAP_TIMEOUT);
-                               return( rc );
-                       }
-
-               }
-               if ( rc == -1 ) {
-                       rc = -2;        /* select interrupted: loop */
-               } else {
-                       rc = read1msg( ld, msgid, all, &ld->ld_sb, result );
-               }
-#else /* !LDAP_REFERRALS */
 #ifdef LDAP_DEBUG
                if ( ldap_debug & LDAP_DEBUG_TRACE ) {
-                       dump_connection( ld, ld->ld_conns, 1 );
-                       dump_requests_and_responses( ld );
+                       ldap_dump_connection( ld, ld->ld_conns, 1 );
+                       ldap_dump_requests_and_responses( ld );
                }
 #endif /* LDAP_DEBUG */
                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 ) {
-                               rc = read1msg( ld, msgid, all, lc->lconn_sb,
+                       if ( ber_pvt_sb_data_ready(lc->lconn_sb) ) {
+                               rc = try_read1msg( ld, msgid, all, lc->lconn_sb,
                                    lc, result );
                                break;
                        }
@@ -248,7 +208,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                        rc = do_ldap_select( ld, tvp );
 
 
-#if defined( LDAP_DEBUG ) && !defined( MACOS ) && !defined( DOS )
+#ifdef LDAP_DEBUG
                        if ( rc == -1 ) {
                            Debug( LDAP_DEBUG_TRACE,
                                    "do_ldap_select returned -1: errno %d\n",
@@ -256,12 +216,10 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                        }
 #endif
 
-#if !defined( MACOS ) && !defined( DOS )
-                       if ( rc == 0 || ( rc == -1 && (( ld->ld_options &
-                           LDAP_OPT_RESTART ) == 0 || errno != EINTR ))) {
-#else
-                       if ( rc == -1 || rc == 0 ) {
-#endif
+                       if ( rc == 0 || ( rc == -1 && (
+                               !LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART)
+                               || errno != EINTR )))
+                       {
                                ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :
                                    LDAP_TIMEOUT);
                                return( rc );
@@ -276,18 +234,17 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                                        nextlc = lc->lconn_next;
                                        if ( lc->lconn_status ==
                                            LDAP_CONNST_CONNECTED &&
-                                           is_read_ready( ld,
+                                           ldap_is_read_ready( ld,
                                            lc->lconn_sb )) {
-                                               rc = read1msg( ld, msgid, all,
+                                               rc = try_read1msg( ld, msgid, all,
                                                    lc->lconn_sb, lc, result );
                                        }
                                }
                        }
                }
-#endif /* !LDAP_REFERRALS */
 
                if ( rc == -2 && tvp != NULL ) {
-                       tmp_time = (long)time( NULL );
+                       tmp_time = time( NULL );
                        if (( tv.tv_sec -=  ( tmp_time - start_time )) <= 0 ) {
                                rc = 0; /* timed out */
                                ld->ld_errno = LDAP_TIMEOUT;
@@ -295,7 +252,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
                        }
 
                        Debug( LDAP_DEBUG_TRACE, "wait4msg:  %ld secs to go\n",
-                               tv.tv_sec, 0, 0 );
+                              (long) tv.tv_sec, 0, 0 );
                        start_time = tmp_time;
                }
        }
@@ -304,71 +261,104 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
 }
 
 
-static int
-read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
-#ifdef LDAP_REFERRALS
+static ber_tag_t
+try_read1msg(
+       LDAP *ld,
+       ber_int_t msgid,
+       int all,
+       Sockbuf *sb,
     LDAPConn *lc,
-#endif /* LDAP_REFERRALS */
-    LDAPMessage **result )
+       LDAPMessage **result )
 {
-       BerElement      ber;
+       BerElement      *ber;
        LDAPMessage     *new, *l, *prev, *tmp;
-       long            id;
-       unsigned long   tag, len;
+       ber_int_t       id;
+       ber_tag_t       tag;
+       ber_len_t       len;
        int             foundit = 0;
-#ifdef LDAP_REFERRALS
        LDAPRequest     *lr;
        BerElement      tmpber;
        int             rc, refer_cnt, hadref, simple_request;
-       unsigned long   lderr;
-#endif /* LDAP_REFERRALS */
+       ber_int_t       lderr;
 
+       assert( ld != NULL );
+       assert( lc != NULL );
+       
        Debug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 );
 
-       ber_init( &ber, 0 );
-       set_ber_options( ld, &ber );
+    if ( lc->lconn_ber == NULL ) {
+               lc->lconn_ber = ldap_alloc_ber_with_options(ld);
+
+               if( lc->lconn_ber == NULL ) {
+                       return -1;
+               }
+    }
+
+       ber = lc->lconn_ber;
+       assert( BER_VALID (ber) );
 
        /* get the next message */
-       if ( (tag = ber_get_next( sb, &len, &ber ))
+       errno = 0;
+       if ( (tag = ber_get_next( sb, &len, ber ))
            != LDAP_TAG_MESSAGE ) {
-               ld->ld_errno = (tag == LBER_DEFAULT ? LDAP_SERVER_DOWN :
-                   LDAP_LOCAL_ERROR);
-               return( -1 );
+               if ( tag == LBER_DEFAULT) {
+#ifdef LDAP_DEBUG                 
+                       Debug( LDAP_DEBUG_CONNS,
+                             "ber_get_next failed.\n", 0, 0, 0 );
+#endif            
+#ifdef EWOULDBLOCK                     
+                       if (errno==EWOULDBLOCK) return -2;
+#endif
+#ifdef EAGAIN
+                       if (errno == EAGAIN) return -2;
+#endif
+                       ld->ld_errno = LDAP_SERVER_DOWN;
+                       return -1;
+               }
+               ld->ld_errno = LDAP_LOCAL_ERROR;
+               return -1;
        }
 
+       /*
+     * We read a complete message.
+        * The connection should no longer need this ber.
+        */
+    lc->lconn_ber = NULL;
+
        /* message id */
-       if ( ber_get_int( &ber, &id ) == LBER_ERROR ) {
+       if ( ber_get_int( ber, &id ) == LBER_ERROR ) {
+               ber_free( ber, 1 );
                ld->ld_errno = LDAP_DECODING_ERROR;
                return( -1 );
        }
 
        /* if it's been abandoned, toss it */
-       if ( ldap_abandoned( ld, (int)id ) ) {
-               free( ber.ber_buf );    /* gack! */
+       if ( ldap_abandoned( ld, id ) ) {
+               ber_free( ber, 1 );
                return( -2 );   /* continue looking */
        }
 
-#ifdef LDAP_REFERRALS
-       if (( lr = find_request_by_msgid( ld, id )) == NULL ) {
+       if (( lr = ldap_find_request_by_msgid( ld, id )) == NULL ) {
                Debug( LDAP_DEBUG_ANY,
                    "no request for response with msgid %ld (tossing)\n",
-                   id, 0, 0 );
-               free( ber.ber_buf );    /* gack! */
+                   (long) id, 0, 0 );
+               ber_free( ber, 1 );
                return( -2 );   /* continue looking */
        }
-       Debug( LDAP_DEBUG_TRACE, "got %s msgid %ld, original id %d\n",
-           ( tag == LDAP_RES_SEARCH_ENTRY ) ? "entry" : "result", id,
-           lr->lr_origid );
-       id = lr->lr_origid;
-#endif /* LDAP_REFERRALS */
 
        /* the message type */
-       if ( (tag = ber_peek_tag( &ber, &len )) == LBER_ERROR ) {
+       if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) {
                ld->ld_errno = LDAP_DECODING_ERROR;
+               ber_free( ber, 1 );
                return( -1 );
        }
 
-#ifdef LDAP_REFERRALS
+       Debug( LDAP_DEBUG_TRACE, "ldap_read: %s msgid %ld, original id %ld\n",
+           ( tag == LDAP_RES_SEARCH_ENTRY ) ? "entry" : 
+               ( tag == LDAP_RES_SEARCH_REFERENCE ) ? "reference" : "result",
+               (long) id, (long) lr->lr_origid );
+
+       id = lr->lr_origid;
        refer_cnt = 0;
        hadref = simple_request = 0;
        rc = -2;        /* default is to keep looking (no response found) */
@@ -376,15 +366,16 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
 
        if ( tag != LDAP_RES_SEARCH_ENTRY ) {
                if ( ld->ld_version >= LDAP_VERSION2 &&
-                           ( lr->lr_parent != NULL ||
-                           ( ld->ld_options & LDAP_OPT_REFERRALS ) != 0 )) {
-                       tmpber = ber;   /* struct copy */
+                       ( lr->lr_parent != NULL ||
+                       LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) ) )
+               {
+                       tmpber = *ber;  /* struct copy */
                        if ( ber_scanf( &tmpber, "{iaa}", &lderr,
                            &lr->lr_res_matched, &lr->lr_res_error )
                            != LBER_ERROR ) {
                                if ( lderr != LDAP_SUCCESS ) {
                                        /* referrals are in error string */
-                                       refer_cnt = chase_referrals( ld, lr,
+                                       refer_cnt = ldap_chase_referrals( ld, lr,
                                            &lr->lr_res_error, &hadref );
                                }
 
@@ -409,8 +400,8 @@ Debug( LDAP_DEBUG_TRACE,
                    "read1msg:  %d new referrals\n", refer_cnt, 0, 0 );
 
                if ( refer_cnt != 0 ) { /* chasing referrals */
-                       free( ber.ber_buf );    /* gack! */
-                       ber.ber_buf = NULL;
+                       ber_free( ber, 1 );
+                       ber = NULL;
                        if ( refer_cnt < 0 ) {
                                return( -1 );   /* fatal error */
                        }
@@ -421,8 +412,8 @@ Debug( LDAP_DEBUG_TRACE,
                                simple_request = ( hadref ? 0 : 1 );
                        } else {
                                /* request with referrals or child request */
-                               free( ber.ber_buf );    /* gack! */
-                               ber.ber_buf = NULL;
+                               ber_free( ber, 1 );
+                               ber = NULL;
                        }
 
                        while ( lr->lr_parent != NULL ) {
@@ -438,52 +429,48 @@ Debug( LDAP_DEBUG_TRACE,
                                id = lr->lr_msgid;
                                tag = lr->lr_res_msgtype;
                                Debug( LDAP_DEBUG_ANY, "request %ld done\n",
-                                   id, 0, 0 );
+                                   (long) id, 0, 0 );
 Debug( 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.ber_buf != NULL ) {
-                                               free( ber.ber_buf ); /* gack! */
-                                               ber.ber_buf = NULL;
-                                       }
+                                       ber_free( ber, 1 );
+                                       ber = NULL;
                                        if ( build_result_ber( ld, &ber, lr )
                                            == LBER_ERROR ) {
-                                               ld->ld_errno = LDAP_NO_MEMORY;
                                                rc = -1; /* fatal error */
                                        }
                                }
 
-                               free_request( ld, lr );
+                               ldap_free_request( ld, lr );
                        }
 
                        if ( lc != NULL ) {
-                               free_connection( ld, lc, 0, 1 );
+                               ldap_free_connection( ld, lc, 0, 1 );
                        }
                }
        }
 
-       if ( ber.ber_buf == NULL ) {
+       if ( ber == NULL ) {
                return( rc );
        }
 
-#endif /* LDAP_REFERRALS */
        /* make a new ldap message */
-       if ( (new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) ))
+       if ( (new = (LDAPMessage *) LDAP_CALLOC( 1, sizeof(LDAPMessage) ))
            == NULL ) {
                ld->ld_errno = LDAP_NO_MEMORY;
                return( -1 );
        }
        new->lm_msgid = (int)id;
        new->lm_msgtype = tag;
-       new->lm_ber = ber_dup( &ber );
+       new->lm_ber = ber;
 
-#ifndef NO_CACHE
+#ifndef LDAP_NOCACHE
                if ( ld->ld_cache != NULL ) {
-                       add_result_to_cache( ld, new );
+                       ldap_add_result_to_cache( ld, new );
                }
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
 
        /* is this the one we're looking for? */
        if ( msgid == LDAP_RES_ANY || id == msgid ) {
@@ -504,15 +491,15 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
         * search response.
         */
 
-       prev = NULLMSG;
-       for ( l = ld->ld_responses; l != NULLMSG; l = l->lm_next ) {
+       prev = NULL;
+       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 == NULLMSG ) {
+       if ( l == NULL ) {
                if ( foundit ) {
                        *result = new;
                        ld->ld_errno = LDAP_SUCCESS;
@@ -524,11 +511,11 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
                return( -2 );   /* continue looking */
        }
 
-       Debug( LDAP_DEBUG_TRACE, "adding response id %d type %d:\n",
-           new->lm_msgid, new->lm_msgtype, 0 );
+       Debug( LDAP_DEBUG_TRACE, "adding response id %ld type %ld:\n",
+           (long) new->lm_msgid, (long) new->lm_msgtype, 0 );
 
        /* part of a search response - add to end of list of entries */
-       for ( tmp = l; tmp->lm_chain != NULLMSG &&
+       for ( tmp = l; tmp->lm_chain != NULL &&
            tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY;
            tmp = tmp->lm_chain )
                ;       /* NULL */
@@ -536,45 +523,80 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
 
        /* return the whole chain if that's what we were looking for */
        if ( foundit ) {
-               if ( prev == NULLMSG )
+               if ( prev == NULL )
                        ld->ld_responses = l->lm_next;
                else
                        prev->lm_next = l->lm_next;
                *result = l;
                ld->ld_errno = LDAP_SUCCESS;
+#ifdef LDAP_WORLD_P16
+               /*
+                * XXX questionable fix; see text for [P16] on
+                * http://www.critical-angle.com/ldapworld/patch/
+                *
+                * inclusion of this patch causes searchs to hang on
+                * multiple platforms
+                */
+               return( l->lm_msgtype );
+#else  /* LDAP_WORLD_P16 */
                return( tag );
+#endif /* !LDAP_WORLD_P16 */
        }
 
        return( -2 );   /* continue looking */
 }
 
 
-#ifdef LDAP_REFERRALS
-static int
-build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr )
+static ber_tag_t
+build_result_ber( LDAP *ld, BerElement **bp, LDAPRequest *lr )
 {
-       unsigned long   len;
-       long            along;
+       ber_len_t       len;
+       ber_int_t       tag;
+       ber_int_t       along;
+       BerElement *ber;
+
+       *bp = NULL;
+       ber = ldap_alloc_ber_with_options( ld );
+
+       if( ber == NULL ) {
+               ld->ld_errno = LDAP_NO_MEMORY;
+               return LBER_ERROR;
+       }
 
-       ber_init( ber, 0 );
-       set_ber_options( ld, ber );
        if ( ber_printf( ber, "{it{ess}}", lr->lr_msgid,
-           (long)lr->lr_res_msgtype, lr->lr_res_errno,
+           lr->lr_res_msgtype, lr->lr_res_errno,
            lr->lr_res_matched ? lr->lr_res_matched : "",
-           lr->lr_res_error ? lr->lr_res_error : "" ) == LBER_ERROR ) {
+           lr->lr_res_error ? lr->lr_res_error : "" ) == -1 ) {
+
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free(ber, 1);
                return( LBER_ERROR );
        }
 
        ber_reset( ber, 1 );
+
        if ( ber_skip_tag( ber, &len ) == LBER_ERROR ) {
+               ld->ld_errno = LDAP_DECODING_ERROR;
+               ber_free(ber, 1);
                return( LBER_ERROR );
        }
 
        if ( ber_get_int( ber, &along ) == LBER_ERROR ) {
+               ld->ld_errno = LDAP_DECODING_ERROR;
+               ber_free(ber, 1);
                return( LBER_ERROR );
        }
 
-       return( ber_peek_tag( ber, &len ));
+       tag = ber_peek_tag( ber, &len );
+
+       if ( tag == LBER_ERROR ) {
+               ld->ld_errno = LDAP_DECODING_ERROR;
+               ber_free(ber, 1);
+               return( LBER_ERROR );
+       }
+
+       *bp = ber;
+       return tag;
 }
 
 
@@ -587,20 +609,20 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )
        if ( lr->lr_res_errno == LDAP_PARTIAL_RESULTS ) {
                parentr->lr_res_errno = lr->lr_res_errno;
                if ( lr->lr_res_error != NULL ) {
-                       (void)append_referral( ld, &parentr->lr_res_error,
+                       (void)ldap_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 ) {
-                       free( parentr->lr_res_error );
+                       LDAP_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 ( LDAP_NAME_ERROR( lr->lr_res_errno )) {
                        if ( parentr->lr_res_matched != NULL ) {
-                               free( parentr->lr_res_matched );
+                               LDAP_FREE( parentr->lr_res_matched );
                        }
                        parentr->lr_res_matched = lr->lr_res_matched;
                        lr->lr_res_matched = NULL;
@@ -614,103 +636,24 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )
            parentr->lr_res_error : "", parentr->lr_res_matched ?
            parentr->lr_res_matched : "" );
 }
-#endif /* LDAP_REFERRALS */
-
 
 
-#if defined( CLDAP ) || !defined( LDAP_REFERRALS )
-#if !defined( MACOS ) && !defined( DOS ) && !defined( _WIN32 )
-static int
-ldap_select1( LDAP *ld, struct timeval *timeout )
-{
-       fd_set          readfds;
-       static int      tblsize;
-
-       if ( tblsize == 0 ) {
-#ifdef USE_SYSCONF
-               tblsize = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
-               tblsize = getdtablesize();
-#endif /* USE_SYSCONF */
-       }
-
-       FD_ZERO( &readfds );
-       FD_SET( ld->ld_sb.sb_sd, &readfds );
-
-       return( select( tblsize, &readfds, 0, 0, timeout ) );
-}
-#endif /* !MACOS */
 
-
-#ifdef MACOS
-static int
-ldap_select1( LDAP *ld, struct timeval *timeout )
-{
-       return( tcpselect( ld->ld_sb.sb_sd, timeout ));
-}
-#endif /* MACOS */
-
-
-#if ( defined( DOS ) && defined( WINSOCK )) || defined( _WIN32 )
-static int
-ldap_select1( LDAP *ld, struct timeval *timeout )
+int
+ldap_msgtype( LDAPMessage *lm )
 {
-    fd_set          readfds;
-    int             rc;
-
-    FD_ZERO( &readfds );
-    FD_SET( ld->ld_sb.sb_sd, &readfds );
-
-    rc = select( 1, &readfds, 0, 0, timeout );
-    return( rc == SOCKET_ERROR ? -1 : rc );
+       assert( lm != NULL );
+       return ( lm == NULL ) ? lm->lm_msgtype : -1;
 }
-#endif /* WINSOCK || _WIN32 */
-
 
-#ifdef DOS
-#ifdef PCNFS
-static int
-ldap_select1( LDAP *ld, struct timeval *timeout )
-{
-       fd_set  readfds;
-       int     res;
-
-       FD_ZERO( &readfds );
-       FD_SET( ld->ld_sb.sb_sd, &readfds );
-
-       res = select( FD_SETSIZE, &readfds, NULL, NULL, timeout );
-       if ( res == -1 && errno == EINTR) {
-               /* We've been CTRL-C'ed at this point.  It'd be nice to
-                  carry on but PC-NFS currently won't let us! */
-               printf("\n*** CTRL-C ***\n");
-               exit(-1);
-       }
-       return( res );
-}
-#endif /* PCNFS */
 
-#ifdef NCSA
-static int
-ldap_select1( LDAP *ld, struct timeval *timeout )
+int
+ldap_msgid( LDAPMessage *lm )
 {
-       int rc;
-       clock_t endtime;
-
-       if ( timeout != NULL ) {
-               endtime = timeout->tv_sec * CLK_TCK +
-                       timeout->tv_usec * CLK_TCK / 1000000 + clock();
-       }
-
-       do {
-               Stask();
-               rc = netqlen( ld->ld_sb.sb_sd );
-       } while ( rc <= 0 && ( timeout == NULL || clock() < endtime ));
+       assert( lm != NULL );
 
-       return( rc > 0 ? 1 : 0 );
+       return ( lm == NULL ) ? lm->lm_msgid : -1;
 }
-#endif /* NCSA */
-#endif /* DOS */
-#endif /* !LDAP_REFERRALS */
 
 
 int
@@ -719,13 +662,15 @@ ldap_msgfree( LDAPMessage *lm )
        LDAPMessage     *next;
        int             type = 0;
 
+       assert( lm != NULL );
+
        Debug( LDAP_DEBUG_TRACE, "ldap_msgfree\n", 0, 0, 0 );
 
-       for ( ; lm != NULLMSG; lm = next ) {
+       for ( ; lm != NULL; lm = next ) {
                next = lm->lm_chain;
                type = lm->lm_msgtype;
                ber_free( lm->lm_ber, 1 );
-               free( (char *) lm );
+               LDAP_FREE( (char *) lm );
        }
 
        return( type );
@@ -741,19 +686,21 @@ ldap_msgdelete( LDAP *ld, int msgid )
 {
        LDAPMessage     *lm, *prev;
 
+       assert( ld != NULL );
+
        Debug( LDAP_DEBUG_TRACE, "ldap_msgdelete\n", 0, 0, 0 );
 
-       prev = NULLMSG;
-       for ( lm = ld->ld_responses; lm != NULLMSG; lm = lm->lm_next ) {
+       prev = NULL;
+       for ( lm = ld->ld_responses; lm != NULL; lm = lm->lm_next ) {
                if ( lm->lm_msgid == msgid )
                        break;
                prev = lm;
        }
 
-       if ( lm == NULLMSG )
+       if ( lm == NULL )
                return( -1 );
 
-       if ( prev == NULLMSG )
+       if ( prev == NULL )
                ld->ld_responses = lm->lm_next;
        else
                prev->lm_next = lm->lm_next;
@@ -769,7 +716,7 @@ ldap_msgdelete( LDAP *ld, int msgid )
  * return 1 if message msgid is waiting to be abandoned, 0 otherwise
  */
 static int
-ldap_abandoned( LDAP *ld, int msgid )
+ldap_abandoned( LDAP *ld, ber_int_t msgid )
 {
        int     i;
 
@@ -785,7 +732,7 @@ ldap_abandoned( LDAP *ld, int msgid )
 
 
 static int
-ldap_mark_abandoned( LDAP *ld, int msgid )
+ldap_mark_abandoned( LDAP *ld, ber_int_t msgid )
 {
        int     i;
 
@@ -807,15 +754,23 @@ ldap_mark_abandoned( LDAP *ld, int msgid )
 }
 
 
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
 int
 cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber )
 {
-       int             rc;
-       unsigned long   tag, len;
+       int     rc;
+       ber_tag_t       tag;
+       ber_len_t       len;
+
+       if ( ! ber_pvt_sb_data_ready(&ld->ld_sb) ) {
+               /* restored from ldap_select1() in result.c version 1.24 */
+               fd_set  readfds;
+               if ( ldap_int_tblsize == 0 )
+                       ldap_int_ip_init();
+               FD_ZERO( &readfds );
+               FD_SET( ber_pvt_sb_get_desc(&ld->ld_sb), &readfds );
+               rc = select( ldap_int_tblsize, &readfds, 0, 0, timeout );
 
-       if ( ld->ld_sb.sb_ber.ber_ptr >= ld->ld_sb.sb_ber.ber_end ) {
-               rc = ldap_select1( ld, timeout );
                if ( rc == -1 || rc == 0 ) {
                        ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :
                            LDAP_TIMEOUT);
@@ -831,6 +786,6 @@ cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber )
                return( -1 );
        }
 
-       return( tag );
+       return( 0 );
 }
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
diff --git a/libraries/libldap/sasl.c b/libraries/libldap/sasl.c
new file mode 100644 (file)
index 0000000..a397288
--- /dev/null
@@ -0,0 +1,334 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+/*
+ *     BindRequest ::= SEQUENCE {
+ *             version         INTEGER,
+ *             name            DistinguishedName,       -- who
+ *             authentication  CHOICE {
+ *                     simple          [0] OCTET STRING -- passwd
+#ifdef HAVE_KERBEROS
+ *                     krbv42ldap      [1] OCTET STRING
+ *                     krbv42dsa       [2] OCTET STRING
+#endif
+ *                     sasl            [3] SaslCredentials     -- LDAPv3
+ *             }
+ *     }
+ *
+ *     BindResponse ::= SEQUENCE {
+ *             COMPONENTS OF LDAPResult,
+ *             serverSaslCreds         OCTET STRING OPTIONAL -- LDAPv3
+ *     }
+ *
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+
+/*
+ * ldap_sasl_bind - bind to the ldap server (and X.500).  The dn, mechanism, and
+ * credentials of the entry to which to bind are supplied.  The message id
+ * of the request initiated is provided upon successful (LDAP_SUCCESS) return.
+ *
+ * Example:
+ *     ldap_sasl_bind( ld, "cn=manager, o=university of michigan, c=us",
+ *         "mechanism", "secret", NULL, NULL, &msgid )
+ */
+
+int
+ldap_sasl_bind(
+       LDAP                    *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *mechanism,
+       struct berval   *cred,
+       LDAPControl             **sctrls,
+       LDAPControl             **cctrls,
+       int                             *msgidp )
+{
+       BerElement      *ber;
+       int rc;
+
+       Debug( LDAP_DEBUG_TRACE, "ldap_sasl_bind\n", 0, 0, 0 );
+
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( msgidp != NULL );
+
+       if( msgidp == NULL ) {
+               ld->ld_errno = LDAP_PARAM_ERROR;
+               return ld->ld_errno;
+       }
+
+       if( mechanism != LDAP_SASL_SIMPLE
+               && ld->ld_version < LDAP_VERSION3)
+       {
+               ld->ld_errno = LDAP_NOT_SUPPORTED;
+               return ld->ld_errno;
+       }
+
+       if ( dn == NULL )
+               dn = "";
+
+       /* create a message to send */
+       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               ld->ld_errno = LDAP_NO_MEMORY;
+               return ld->ld_errno;
+       }
+
+       assert( BER_VALID( ber ) );
+
+       if( mechanism == LDAP_SASL_SIMPLE ) {
+               /* simple bind */
+               rc = ber_printf( ber, "{it{istO}" /*}*/,
+                       ++ld->ld_msgid, LDAP_REQ_BIND,
+                       ld->ld_version, dn, LDAP_AUTH_SIMPLE,
+                       cred );
+               
+       } else if ( cred == NULL ) {
+               /* SASL bind w/o creditials */
+               rc = ber_printf( ber, "{it{ist{s}}" /*}*/,
+                       ++ld->ld_msgid, LDAP_REQ_BIND,
+                       ld->ld_version, dn, LDAP_AUTH_SASL,
+                       mechanism );
+
+       } else {
+               /* SASL bind w/ creditials */
+               rc = ber_printf( ber, "{it{ist{sO}}" /*}*/,
+                       ++ld->ld_msgid, LDAP_REQ_BIND,
+                       ld->ld_version, dn, LDAP_AUTH_SASL,
+                       mechanism, cred );
+       }
+
+       if( rc == -1 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free( ber, 1 );
+               return( -1 );
+       }
+
+       /* Put Server Controls */
+       if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
+               ber_free( ber, 1 );
+               return ld->ld_errno;
+       }
+
+       if ( ber_printf( ber, /*{*/ "}" ) == -1 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free( ber, 1 );
+               return ld->ld_errno;
+       }
+
+#ifndef LDAP_NOCACHE
+       if ( ld->ld_cache != NULL ) {
+               ldap_flush_cache( ld );
+       }
+#endif /* !LDAP_NOCACHE */
+
+       /* send the message */
+       *msgidp = ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber );
+
+       if(*msgidp < 0)
+               return ld->ld_errno;
+
+       return LDAP_SUCCESS;
+}
+
+/*
+ * ldap_sasl_bind_s - bind to the ldap server (and X.500) using simple
+ * authentication.  The dn and password of the entry to which to bind are
+ * supplied.  LDAP_SUCCESS is returned upon success, the ldap error code
+ * otherwise.
+ *
+ * Example:
+ *     ldap_sasl_bind_s( ld, "cn=manager, o=university of michigan, c=us",
+ *         "mechanism", "secret", NULL, NULL, &servercred )
+ */
+
+int
+ldap_sasl_bind_s(
+       LDAP                    *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *mechanism,
+       struct berval   *cred,
+       LDAPControl             **sctrls,
+       LDAPControl             **cctrls,
+       struct berval   **servercredp )
+{
+       int     rc, msgid;
+       LDAPMessage     *result;
+       struct berval   *scredp = NULL;
+
+       Debug( LDAP_DEBUG_TRACE, "ldap_sasl_bind_s\n", 0, 0, 0 );
+
+       /* do a quick !LDAPv3 check... ldap_sasl_bind will do the rest. */
+       if( servercredp != NULL ) {
+               if (ld->ld_version < LDAP_VERSION3) {
+                       ld->ld_errno = LDAP_NOT_SUPPORTED;
+                       return ld->ld_errno;
+               }
+               *servercredp = NULL;
+       }
+
+       rc = ldap_sasl_bind( ld, dn, mechanism, cred, sctrls, cctrls, &msgid );
+
+       if ( rc != LDAP_SUCCESS ) {
+               return( rc );
+       }
+
+       if ( ldap_result( ld, msgid, 1, NULL, &result ) == -1 ) {
+               return( ld->ld_errno ); /* ldap_result sets ld_errno */
+       }
+
+       /* parse the results */
+       scredp = NULL;
+       if( servercredp != NULL ) {
+               rc = ldap_parse_sasl_bind_result( ld, result, &scredp, 0 );
+       }
+
+       if( rc != LDAP_SUCCESS ) {
+               ldap_msgfree( result );
+               return( rc );
+       }
+
+       rc = ldap_result2error( ld, result, 1 );
+
+       if( rc == LDAP_SUCCESS ) {
+               if( servercredp != NULL ) {
+                       *servercredp = scredp;
+               }
+
+       } else if (scredp != NULL ) {
+               ber_bvfree(scredp);
+       }
+
+       return rc;
+}
+
+
+/*
+ * Parse BindResponse:
+ *
+ *   BindResponse ::= [APPLICATION 1] SEQUENCE {
+ *     COMPONENTS OF LDAPResult,
+ *     serverSaslCreds  [7] OCTET STRING OPTIONAL }
+ *
+ *   LDAPResult ::= SEQUENCE {
+ *     resultCode      ENUMERATED,
+ *     matchedDN       LDAPDN,
+ *     errorMessage    LDAPString,
+ *     referral        [3] Referral OPTIONAL }
+ */
+
+int
+ldap_parse_sasl_bind_result(
+       LDAP                    *ld,
+       LDAPMessage             *res,
+       struct berval   **servercredp,
+       int                             freeit )
+{
+       ber_int_t errcode;
+       struct berval* scred;
+
+       ber_tag_t tag;
+       BerElement      *ber;
+
+       Debug( LDAP_DEBUG_TRACE, "ldap_parse_sasl_bind_result\n", 0, 0, 0 );
+
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( res != NULL );
+
+       if ( ld == NULL || res == NULL ) {
+               return LDAP_PARAM_ERROR;
+       }
+
+       if(servercredp != NULL) {
+               if( ld->ld_version < LDAP_VERSION2 ) {
+                       return LDAP_NOT_SUPPORTED;
+               }
+               *servercredp = NULL;
+       }
+
+       if( res->lm_msgtype == LDAP_RES_BIND ) {
+               ld->ld_errno = LDAP_PARAM_ERROR;
+               return ld->ld_errno;
+       }
+
+       errcode = LDAP_SUCCESS;
+       scred = NULL;
+
+       if ( ld->ld_error ) {
+               LDAP_FREE( ld->ld_error );
+               ld->ld_error = NULL;
+       }
+       if ( ld->ld_matched ) {
+               LDAP_FREE( ld->ld_matched );
+               ld->ld_matched = NULL;
+       }
+
+       /* parse results */
+
+       ber = ber_dup( res->lm_ber );
+
+       if ( ld->ld_version < LDAP_VERSION2 ) {
+               tag = ber_scanf( ber, "{ia}",
+                       &errcode, &ld->ld_error );
+
+       } else {
+               ber_len_t len;
+
+               tag = ber_scanf( ber, "{iaa" /*}*/,
+                       &errcode, &ld->ld_matched, &ld->ld_error );
+
+               if( tag != LBER_ERROR ) {
+                       tag = ber_peek_tag(ber, &len);
+               }
+
+               if( tag == LDAP_TAG_REFERRAL ) {
+                       /* skip 'em */
+                       tag = ber_scanf( ber, "x" );
+
+                       if( tag != LBER_ERROR ) {
+                               tag = ber_peek_tag(ber, &len);
+                       }
+               }
+
+               /* need to clean out misc items */
+               if( tag == LDAP_TAG_SASL_RES_CREDS ) {
+                       tag = ber_scanf( ber, "O", &scred );
+               }
+       }
+
+       if ( tag == LBER_ERROR ) {
+               errcode = LDAP_DECODING_ERROR;
+       }
+
+       if( ber != NULL ) {
+               ber_free( ber, 0 );
+       }
+
+       /* return */
+       if ( errcode == LDAP_SUCCESS && servercredp != NULL ) {
+               *servercredp = scred;
+
+       } else if ( scred != NULL ) {
+               ber_bvfree( scred );
+       }
+
+       if ( freeit ) {
+               ldap_msgfree( res );
+       }
+
+       ld->ld_errno = errcode;
+       return( ld->ld_errno );
+}
index 656c722f155fcbc3e9b119da616154c6c19bea0b..96d9a7843359397de12f257c623c5ebc8cd561a8 100644 (file)
@@ -1,28 +1,44 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1993 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  sbind.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
+/*
+ *     BindRequest ::= SEQUENCE {
+ *             version         INTEGER,
+ *             name            DistinguishedName,       -- who
+ *             authentication  CHOICE {
+ *                     simple          [0] OCTET STRING -- passwd
+#ifdef HAVE_KERBEROS
+ *                     krbv42ldap      [1] OCTET STRING
+ *                     krbv42dsa       [2] OCTET STRING
 #endif
+ *                     sasl            [3] SaslCredentials     -- LDAPv3
+ *             }
+ *     }
+ *
+ *     BindResponse ::= SEQUENCE {
+ *             COMPONENTS OF LDAPResult,
+ *             serverSaslCreds         OCTET STRING OPTIONAL -- LDAPv3
+ *     }
+ *
+ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
 
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
 
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
 #include "ldap-int.h"
 
 
@@ -37,50 +53,32 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of
  */
 
 int
-ldap_simple_bind( LDAP *ld, char *dn, char *passwd )
+ldap_simple_bind(
+       LDAP *ld,
+       LDAP_CONST char *dn,
+       LDAP_CONST char *passwd )
 {
-       BerElement      *ber;
-
-       /*
-        * The bind request looks like this:
-        *      BindRequest ::= SEQUENCE {
-        *              version         INTEGER,
-        *              name            DistinguishedName,       -- who
-        *              authentication  CHOICE {
-        *                      simple          [0] OCTET STRING -- passwd
-        *              }
-        *      }
-        * all wrapped up in an LDAPMessage sequence.
-        */
+       int rc;
+       int msgid;
+       struct berval cred;
 
        Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind\n", 0, 0, 0 );
 
-       if ( dn == NULL )
-               dn = "";
-       if ( passwd == NULL )
-               passwd = "";
-
-       /* create a message to send */
-       if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
-               return( -1 );
-       }
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
 
-       /* fill it in */
-       if ( ber_printf( ber, "{it{ists}}", ++ld->ld_msgid, LDAP_REQ_BIND,
-           ld->ld_version, dn, LDAP_AUTH_SIMPLE, passwd ) == -1 ) {
-               ld->ld_errno = LDAP_ENCODING_ERROR;
-               ber_free( ber, 1 );
-               return( -1 );
+       if ( passwd != NULL ) {
+               cred.bv_val = (char *) passwd;
+               cred.bv_len = strlen( passwd );
+       } else {
+               cred.bv_val = "";
+               cred.bv_len = 0;
        }
 
-#ifndef NO_CACHE
-       if ( ld->ld_cache != NULL ) {
-               ldap_flush_cache( ld );
-       }
-#endif /* !NO_CACHE */
+       rc = ldap_sasl_bind( ld, dn, LDAP_SASL_SIMPLE, &cred,
+               NULL, NULL, &msgid );
 
-       /* send the message */
-       return( send_initial_request( ld, LDAP_REQ_BIND, dn, ber ));
+       return rc == LDAP_SUCCESS ? msgid : -1;
 }
 
 /*
@@ -95,18 +93,20 @@ ldap_simple_bind( LDAP *ld, char *dn, char *passwd )
  */
 
 int
-ldap_simple_bind_s( LDAP *ld, char *dn, char *passwd )
+ldap_simple_bind_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd )
 {
-       int             msgid;
-       LDAPMessage     *result;
+       struct berval cred;
 
        Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind_s\n", 0, 0, 0 );
 
-       if ( (msgid = ldap_simple_bind( ld, dn, passwd )) == -1 )
-               return( ld->ld_errno );
-
-       if ( ldap_result( ld, msgid, 1, (struct timeval *) 0, &result ) == -1 )
-               return( ld->ld_errno ); /* ldap_result sets ld_errno */
+       if ( passwd != NULL ) {
+               cred.bv_val = (char *) passwd;
+               cred.bv_len = strlen( passwd );
+       } else {
+               cred.bv_val = "";
+               cred.bv_len = 0;
+       }
 
-       return( ldap_result2error( ld, result, 1 ) );
+       return ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &cred,
+               NULL, NULL, NULL );
 }
index 33f8f2674a20f9e6a3f76e8a7d3a3aa39c9236e7..78fbe8a3fa25079f7ee5a5e89017a1076b53a066 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -1260,9 +1261,6 @@ ldap_str2attributetype( const char * s, int * code, const char ** errp )
        int seen_substr = 0;
        int seen_syntax = 0;
        int seen_usage = 0;
-       int seen_kind = 0;
-       int seen_must = 0;
-       int seen_may = 0;
        LDAP_ATTRIBUTE_TYPE * at;
        char ** ssdummy;
        const char * savepos;
@@ -1837,7 +1835,7 @@ ldap_str2objectclass( const char * s, int * code, const char ** errp )
        }
 }
 
-static char *err2text[] = {
+static char *const err2text[] = {
        "",
        "Out of memory",
        "Unexpected token",
index e120b49e0d2bad14ad9fdc65dd9b10bbd5be1adc..f6d84d10d1041874e0b730011c892e04333cf03e 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -31,15 +32,9 @@ static int ldap_is_attr_desc LDAP_P((
 static int hex2value LDAP_P((
        int c ));
 
-static ber_slen_t filter_value_unescape LDAP_P((
-       char *filter ));
-
 static char *find_right_paren LDAP_P((
        char *s ));
 
-static char *find_wildcard LDAP_P((
-       char *s ));
-
 static char *put_complex_filter LDAP_P((
        BerElement *ber,
        char *str,
@@ -222,7 +217,7 @@ ldap_search(
 BerElement *
 ldap_build_search_req(
        LDAP *ld,
-       LDAP_CONST char *base_in,
+       LDAP_CONST char *base,
        ber_int_t scope,
        LDAP_CONST char *filter_in,
        char **attrs,
@@ -234,7 +229,6 @@ ldap_build_search_req(
 {
        BerElement      *ber;
        int             err;
-       char    *base;
        char    *filter;
 
        /*
@@ -266,16 +260,14 @@ ldap_build_search_req(
                return( NULL );
        }
 
-       if ( base_in == NULL ) {
+       if ( base == NULL ) {
                /* no base provided, use session default base */
                base = ld->ld_options.ldo_defbase;
-       } else {
-               base = (char *) base_in;
-       }
 
-       if ( base == NULL ) {
-               /* no session default base, use top */
-           base = "";
+               if ( base == NULL ) {
+                       /* no session default base, use top */
+                       base = "";
+               }
        }
 
 #ifdef LDAP_CONNECTIONLESS
@@ -333,11 +325,11 @@ ldap_build_search_req(
        return( ber );
 }
 
-static int ldap_is_attr_oid LDAP_P(( const char *attr ))
+static int ldap_is_attr_oid ( const char *attr )
 {
        int i, c, digit=0;
 
-       for( i=0 ; c = attr[i] ; i++ ) {
+       for( i = 0; (c = attr[i]) != 0; i++ ) {
                if( c >= '0' && c <= '9' ) {
                        digit=1;
 
@@ -359,12 +351,12 @@ static int ldap_is_attr_oid LDAP_P(( const char *attr ))
 
 }
 
-static int ldap_is_attr_desc LDAP_P(( const char *attr ))
+static int ldap_is_attr_desc ( const char *attr )
 {
        /* cheap attribute description check */
        int i, c;
 
-       for( i=0; c = attr[i]; i++ ) {
+       for( i = 0; (c = attr[i]) != 0; i++ ) {
                if (( c >= '0' && c <= '9' )
                        || ( c >= 'A' && c <= 'Z' )
                        || ( c >= 'a' && c <= 'z' )
@@ -419,8 +411,8 @@ static int hex2value( int c )
        return -1;
 }
 
-static char *
-find_wildcard( char *s )
+char *
+ldap_pvt_find_wildcard( char *s )
 {
        for( ; *s != '\0' ; s++ ) {
                switch( *s ) {
@@ -429,10 +421,8 @@ find_wildcard( char *s )
 
                case '\\':
                        s++; /* skip over escape */
-                       if( hex2value( s[0] ) >= 0 && hex2value( s[1] ) >= 0 ) {
-                               /* skip over lead digit of two hex digit code */
-                               s++;
-                       }
+                       if ( *s == '\0' )
+                               return NULL;    /* escape at end of string */
                }
        }
 
@@ -442,8 +432,8 @@ find_wildcard( char *s )
 /* unescape filter value */
 /* support both LDAP v2 and v3 escapes */
 /* output can include nul characters */
-static ber_slen_t
-filter_value_unescape( char *fval )
+ber_slen_t
+ldap_pvt_filter_value_unescape( char *fval )
 {
        ber_slen_t r, v;
        int v1, v2;
@@ -458,7 +448,9 @@ filter_value_unescape( char *fval )
                                /* escape at end of string */
                                return -1;
 
-                       } else if (( v1 = hex2value( fval[v] )) < 0 )  {
+                       }
+
+                       if (( v1 = hex2value( fval[v] )) >= 0 ) {
                                /* LDAPv3 escape */
 
                                if (( v2 = hex2value( fval[v+1] )) < 0 ) {
@@ -804,7 +796,7 @@ put_simple_filter(
                        }
 
                        if( rc != -1 ) {
-                               ber_slen_t len = filter_value_unescape( value );
+                               ber_slen_t len = ldap_pvt_filter_value_unescape( value );
 
                                if( len >= 0 ) {
                                        rc = ber_printf( ber, "totb}",
@@ -818,7 +810,7 @@ put_simple_filter(
                break;
 
        default:
-               if ( find_wildcard( value ) == NULL ) {
+               if ( ldap_pvt_find_wildcard( value ) == NULL ) {
                        ftype = LDAP_FILTER_EQUALITY;
                } else if ( strcmp( value, "*" ) == 0 ) {
                        ftype = LDAP_FILTER_PRESENT;
@@ -833,7 +825,7 @@ put_simple_filter(
                rc = ber_printf( ber, "ts", ftype, str );
 
        } else {
-               ber_slen_t len = filter_value_unescape( value );
+               ber_slen_t len = ldap_pvt_filter_value_unescape( value );
 
                if( len >= 0 ) {
                        rc = ber_printf( ber, "t{so}",
@@ -861,7 +853,7 @@ put_substring_filter( BerElement *ber, char *type, char *val )
                return( -1 );
 
        for( ; val != NULL; val=nextstar ) {
-               if ( (nextstar = find_wildcard( val )) != NULL )
+               if ( (nextstar = ldap_pvt_find_wildcard( val )) != NULL )
                        *nextstar++ = '\0';
 
                if ( gotstar == 0 ) {
@@ -873,7 +865,7 @@ put_substring_filter( BerElement *ber, char *type, char *val )
                }
 
                if ( *val != '\0' ) {
-                       ber_slen_t len = filter_value_unescape( val );
+                       ber_slen_t len = ldap_pvt_filter_value_unescape( val );
 
                        if ( len < 0  ) {
                                return -1;
index ee5d549c895f9d459d99b1febd98553aa37a45f7..c62961b7731f6cc9367d45d88f949a6d33f4e273 100644 (file)
@@ -1,4 +1,9 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* Portions
  * Copyright (c) 1994 Regents of the University of Michigan.
  * All rights reserved.
  *
  * sort.c:  LDAP library entry and value sort routines
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#ifdef MACOS
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+
+#include "ldap-int.h"
 
 struct entrything {
        char            **et_vals;
        LDAPMessage     *et_msg;
+       int             (*et_cmp_fn) LDAP_P((const char *a, const char *b));
 };
 
-#ifndef NEEDPROTOS
-static int     (*et_cmp_fn)();
-static int     et_cmp();
-#else /* !NEEDPROTOS */
-static int     (*et_cmp_fn)( char *a, char *b );
-static int     et_cmp( void *aa, void *bb);
-#endif /* !NEEDPROTOS */
+static int     et_cmp LDAP_P(( const void *aa, const void *bb));
+
 
 int
 ldap_sort_strcasecmp(
-    char       **a,
-    char       **b
+       const void      *a,
+       const void      *b
 )
 {
-       return( strcasecmp( *a, *b ) );
+       return( strcasecmp( *(char *const *)a, *(char *const *)b ) );
 }
 
 static int
 et_cmp(
-       void    *aa,
-       void    *bb
+       const void      *aa,
+       const void      *bb
 )
 {
        int                     i, rc;
-       struct entrything       *a = (struct entrything *)aa;
-       struct entrything       *b = (struct entrything *)bb;
+       const struct entrything *a = (const struct entrything *)aa;
+       const struct entrything *b = (const struct entrything *)bb;
 
        if ( a->et_vals == NULL && b->et_vals == NULL )
                return( 0 );
@@ -68,8 +65,7 @@ et_cmp(
                return( 1 );
 
        for ( i = 0; a->et_vals[i] && b->et_vals[i]; i++ ) {
-               if ( (rc = (*et_cmp_fn)( a->et_vals[i], b->et_vals[i] ))
-                   != 0 ) {
+               if ( (rc = a->et_cmp_fn( a->et_vals[i], b->et_vals[i] )) != 0 ) {
                        return( rc );
                }
        }
@@ -85,8 +81,8 @@ int
 ldap_sort_entries(
     LDAP       *ld,
     LDAPMessage        **chain,
-    char       *attr,          /* NULL => sort by DN */
-    int                (*cmp)()
+    LDAP_CONST char    *attr,          /* NULL => sort by DN */
+    int                (*cmp) (LDAP_CONST  char *, LDAP_CONST char *)
 )
 {
        int                     i, count;
@@ -96,7 +92,19 @@ ldap_sort_entries(
 
        count = ldap_count_entries( ld, *chain );
 
-       if ( (et = (struct entrything *) malloc( count *
+
+       if ( count < 0 ) {
+               if( ld != NULL ) {
+                       ld->ld_errno = LDAP_PARAM_ERROR;
+               }
+               return -1;
+
+       } else if ( count < 2 ) {
+               /* zero or one entries -- already sorted! */
+               return 0;
+       }
+
+       if ( (et = (struct entrything *) LDAP_MALLOC( count *
            sizeof(struct entrything) )) == NULL ) {
                ld->ld_errno = LDAP_NO_MEMORY;
                return( -1 );
@@ -104,13 +112,14 @@ ldap_sort_entries(
 
        e = *chain;
        for ( i = 0; i < count; i++ ) {
+               et[i].et_cmp_fn = cmp;
                et[i].et_msg = e;
                if ( attr == NULL ) {
                        char    *dn;
 
                        dn = ldap_get_dn( ld, e );
                        et[i].et_vals = ldap_explode_dn( dn, 1 );
-                       free( dn );
+                       LDAP_FREE( dn );
                } else {
                        et[i].et_vals = ldap_get_values( ld, e, attr );
                }
@@ -119,8 +128,7 @@ ldap_sort_entries(
        }
        last = e;
 
-       et_cmp_fn = cmp;
-       qsort( et, count, sizeof(struct entrything), (void *) et_cmp );
+       qsort( et, count, sizeof(struct entrything), et_cmp );
 
        ep = chain;
        for ( i = 0; i < count; i++ ) {
@@ -130,7 +138,7 @@ ldap_sort_entries(
                ldap_value_free( et[i].et_vals );
        }
        *ep = last;
-       free( (char *) et );
+       LDAP_FREE( (char *) et );
 
        return( 0 );
 }
@@ -139,7 +147,7 @@ int
 ldap_sort_values(
     LDAP       *ld,
     char       **vals,
-    int                (*cmp)()
+    int                (*cmp) (const void *, const void *)
 )
 {
        int     nel;
index 88c094ce76a6b65de98b66cc8a0df299fcc9a987..adfca3de1072f08e683319ff77c91aebd978b9d3 100644 (file)
@@ -1,4 +1,9 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* Portions
  * Copyright (c) 1993, 1994 Regents of the University of Michigan.
  * All rights reserved.
  *
  * 17 May 1994 by Gordon Good
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#ifdef MACOS
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
-#ifndef VMS
-#include <unistd.h>
-#endif /* VMS */
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+#endif
+
+#include "ldap-int.h"
 #include "srchpref.h"
 
-#ifndef NEEDPROTOS
-int next_line_tokens();
-void free_strarray();
-static void free_searchobj();
-static int read_next_searchobj();
-#else /* !NEEDPROTOS */
-int next_line_tokens( char **bufp, long *blenp, char ***toksp );
-void free_strarray( char **sap );
-static void free_searchobj( struct ldap_searchobj *so );
-static int read_next_searchobj( char **bufp, long *blenp,
-       struct ldap_searchobj **sop, int soversion );
-#endif /* !NEEDPROTOS */
-
-
-static char            *sobjoptions[] = {
+#include "ldap-int.h"
+
+static void free_searchobj LDAP_P(( struct ldap_searchobj *so ));
+static int read_next_searchobj LDAP_P(( char **bufp, ber_len_t *blenp,
+       struct ldap_searchobj **sop, int soversion ));
+
+
+static const char *const       sobjoptions[] = {
     "internal",
     NULL
 };
 
 
-static unsigned long   sobjoptvals[] = {
+static const unsigned long     sobjoptvals[] = {
     LDAP_SEARCHOBJ_OPT_INTERNAL,
 };
 
@@ -85,7 +78,7 @@ ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp )
        return( LDAP_SEARCHPREF_ERR_FILE );
     }
 
-    if (( buf = malloc( (size_t)len )) == NULL ) {
+    if (( buf = LDAP_MALLOC( (size_t)len )) == NULL ) {
        fclose( fp );
        return( LDAP_SEARCHPREF_ERR_MEM );
     }
@@ -95,26 +88,28 @@ ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp )
     fclose( fp );
 
     if ( rlen != len && !eof ) {       /* error:  didn't get the whole file */
-       free( buf );
+       LDAP_FREE( buf );
        return( LDAP_SEARCHPREF_ERR_FILE );
     }
 
     rc = ldap_init_searchprefs_buf( buf, rlen, solistp );
-    free( buf );
+    LDAP_FREE( buf );
 
     return( rc );
 }
 
 
 int
-ldap_init_searchprefs_buf( char *buf, long buflen,
+ldap_init_searchprefs_buf(
+       char *buf,
+       ber_len_t buflen,
        struct ldap_searchobj **solistp )
 {
-    int                                rc, version;
+    int                                rc = -1, version;
     char                       **toks;
     struct ldap_searchobj      *prevso, *so;
 
-    *solistp = prevso = NULLSEARCHOBJ;
+    *solistp = prevso = NULL;
 
     if ( next_line_tokens( &buf, &buflen, &toks ) != 2 ||
            strcasecmp( toks[ 0 ], "version" ) != 0 ) {
@@ -129,8 +124,8 @@ ldap_init_searchprefs_buf( char *buf, long buflen,
     }
 
     while ( buflen > 0 && ( rc = read_next_searchobj( &buf, &buflen, &so,
-           version )) == 0 && so != NULLSEARCHOBJ ) {
-       if ( prevso == NULLSEARCHOBJ ) {
+           version )) == 0 && so != NULL ) {
+       if ( prevso == NULL ) {
            *solistp = so;
        } else {
            prevso->so_next = so;
@@ -167,40 +162,40 @@ free_searchobj( struct ldap_searchobj *so )
 {
     if ( so != NULL ) {
        if ( so->so_objtypeprompt != NULL ) {
-           free(  so->so_objtypeprompt );
+           LDAP_FREE(  so->so_objtypeprompt );
        }
        if ( so->so_prompt != NULL ) {
-           free(  so->so_prompt );
+           LDAP_FREE(  so->so_prompt );
        }
        if ( so->so_filterprefix != NULL ) {
-           free(  so->so_filterprefix );
+           LDAP_FREE(  so->so_filterprefix );
        }
        if ( so->so_filtertag != NULL ) {
-           free(  so->so_filtertag );
+           LDAP_FREE(  so->so_filtertag );
        }
        if ( so->so_defaultselectattr != NULL ) {
-           free(  so->so_defaultselectattr );
+           LDAP_FREE(  so->so_defaultselectattr );
        }
        if ( so->so_defaultselecttext != NULL ) {
-           free(  so->so_defaultselecttext );
+           LDAP_FREE(  so->so_defaultselecttext );
        }
        if ( so->so_salist != NULL ) {
            struct ldap_searchattr *sa, *nextsa;
            for ( sa = so->so_salist; sa != NULL; sa = nextsa ) {
                nextsa = sa->sa_next;
                if ( sa->sa_attrlabel != NULL ) {
-                   free( sa->sa_attrlabel );
+                   LDAP_FREE( sa->sa_attrlabel );
                }
                if ( sa->sa_attr != NULL ) {
-                   free( sa->sa_attr );
+                   LDAP_FREE( sa->sa_attr );
                }
                if ( sa->sa_selectattr != NULL ) {
-                   free( sa->sa_selectattr );
+                   LDAP_FREE( sa->sa_selectattr );
                }
                if ( sa->sa_selecttext != NULL ) {
-                   free( sa->sa_selecttext );
+                   LDAP_FREE( sa->sa_selecttext );
                }
-               free( sa );
+               LDAP_FREE( sa );
            }
        }
        if ( so->so_smlist != NULL ) {
@@ -208,15 +203,15 @@ free_searchobj( struct ldap_searchobj *so )
            for ( sm = so->so_smlist; sm != NULL; sm = nextsm ) {
                nextsm = sm->sm_next;
                if ( sm->sm_matchprompt != NULL ) {
-                   free( sm->sm_matchprompt );
+                   LDAP_FREE( sm->sm_matchprompt );
                }
                if ( sm->sm_filter != NULL ) {
-                   free( sm->sm_filter );
+                   LDAP_FREE( sm->sm_filter );
                }
-               free( sm );
+               LDAP_FREE( sm );
            }
        }
-       free( so );
+       LDAP_FREE( so );
     }
 }
 
@@ -232,13 +227,16 @@ ldap_first_searchobj( struct ldap_searchobj *solist )
 struct ldap_searchobj *
 ldap_next_searchobj( struct ldap_searchobj *solist, struct ldap_searchobj *so )
 {
-    return( so == NULLSEARCHOBJ ? so : so->so_next );
+    return( so == NULL ? so : so->so_next );
 }
 
 
 
 static int
-read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
+read_next_searchobj(
+       char **bufp,
+       ber_len_t *blenp,
+       struct ldap_searchobj **sop,
        int soversion )
 {
     int                                i, j, tokcnt;
@@ -257,13 +255,13 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
        return( tokcnt == 0 ? 0 : LDAP_SEARCHPREF_ERR_SYNTAX );
     }
 
-    if (( so = (struct ldap_searchobj *)calloc( 1,
+    if (( so = (struct ldap_searchobj *)LDAP_CALLOC( 1,
            sizeof( struct ldap_searchobj ))) == NULL ) {
        free_strarray( toks );
        return(  LDAP_SEARCHPREF_ERR_MEM );
     }
     so->so_objtypeprompt = toks[ 0 ];
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * if this is post-version zero, options come next
@@ -293,7 +291,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
        return( LDAP_SEARCHPREF_ERR_SYNTAX );
     }
     so->so_prompt = toks[ 0 ];
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * Filter prefix for "More Choices" searching is next
@@ -304,7 +302,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
        return( LDAP_SEARCHPREF_ERR_SYNTAX );
     }
     so->so_filterprefix = toks[ 0 ];
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * "Fewer Choices" filter tag comes next
@@ -315,7 +313,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
        return( LDAP_SEARCHPREF_ERR_SYNTAX );
     }
     so->so_filtertag = toks[ 0 ];
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * Selection (disambiguation) attribute comes next
@@ -326,7 +324,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
        return( LDAP_SEARCHPREF_ERR_SYNTAX );
     }
     so->so_defaultselectattr = toks[ 0 ];
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * Label for selection (disambiguation) attribute
@@ -337,7 +335,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
        return( LDAP_SEARCHPREF_ERR_SYNTAX );
     }
     so->so_defaultselecttext = toks[ 0 ];
-    free( (char *)toks );
+    LDAP_FREE( (char *)toks );
 
     /*
      * Search scope is next
@@ -370,7 +368,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
            ldap_free_searchprefs( so );
            return( LDAP_SEARCHPREF_ERR_SYNTAX );
        }
-       if (( *sa = ( struct ldap_searchattr * ) calloc( 1,
+       if (( *sa = ( struct ldap_searchattr * ) LDAP_CALLOC( 1,
                sizeof( struct ldap_searchattr ))) == NULL ) {
            free_strarray( toks );
            ldap_free_searchprefs( so );
@@ -387,8 +385,8 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
                ( *sa )->sa_matchtypebitmap |= (1 << j);
            }
        }
-       free( toks[ 2 ] );
-       free( ( char * ) toks );
+       LDAP_FREE( toks[ 2 ] );
+       LDAP_FREE( ( char * ) toks );
        sa = &(( *sa )->sa_next);
     }
     *sa = NULL;
@@ -403,7 +401,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
            ldap_free_searchprefs( so );
            return( LDAP_SEARCHPREF_ERR_SYNTAX );
        }
-       if (( *sm = ( struct ldap_searchmatch * ) calloc( 1,
+       if (( *sm = ( struct ldap_searchmatch * ) LDAP_CALLOC( 1,
                sizeof( struct ldap_searchmatch ))) == NULL ) {
            free_strarray( toks );
            ldap_free_searchprefs( so );
@@ -411,7 +409,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop,
        }
        ( *sm )->sm_matchprompt = toks[ 0 ];
        ( *sm )->sm_filter = toks[ 1 ];
-       free( ( char * ) toks );
+       LDAP_FREE( ( char * ) toks );
        sm = &(( *sm )->sm_next );
     }
     *sm = NULL;
diff --git a/libraries/libldap/string.c b/libraries/libldap/string.c
new file mode 100644 (file)
index 0000000..cd9994a
--- /dev/null
@@ -0,0 +1,133 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <ac/stdlib.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/ctype.h>
+
+#include "ldap-int.h"
+
+
+#if defined ( HAVE_STRSPN )
+#define int_strspn strspn
+#else
+static int int_strspn( const char *str, const char *delim )
+{
+       int pos;
+       const char *p=delim;
+
+       for( pos=0; (*str) ; pos++,str++) {
+               if (*str!=*p) {
+                       for( p=delim; (*p) ; p++ ) {
+                               if (*str==*p) {
+                                       break;
+                               }
+                       }
+               }
+
+               if (*p=='\0') {
+                       return pos;
+               }
+       }
+       return pos;
+}
+#endif
+
+#if defined( HAVE_STRPBRK )
+#define int_strpbrk strpbrk
+#else
+static char *(int_strpbrk)( const char *str, const char *accept )
+{
+       const char *p;
+
+       for( ; (*str) ; str++ ) {
+               for( p=accept; (*p) ; p++) {
+                       if (*str==*p) {
+                               return str;
+                       }
+               }
+       }
+
+       return NULL;
+}
+#endif
+
+char *(ldap_pvt_strtok)( char *str, const char *delim, char **pos )
+{
+       char *p;
+
+       if (pos==NULL) {
+               return NULL;
+       }
+
+       if (str==NULL) {
+               if (*pos==NULL) {
+                       return NULL;
+               }
+
+               str=*pos;
+       }
+
+       /* skip any initial delimiters */
+       str += int_strspn( str, delim );
+       if (*str == '\0') {
+               return NULL;
+       }
+
+       p = int_strpbrk( str, delim );
+       if (p==NULL) {
+               *pos = NULL;
+
+       } else {
+               *p ='\0';
+               *pos = p+1;
+       }
+
+       return str;
+}
+
+char *
+(ldap_pvt_strdup)( const char *s )
+{
+       char    *p;
+       size_t  len = strlen( s ) + 1;
+
+       if ( (p = (char *) malloc( len )) == NULL ) {
+               return( NULL );
+       }
+
+       memcpy( p, s, len );
+       return( p );
+}
+
+char *
+ldap_pvt_str2upper( char *str )
+{
+       char    *s;
+
+       /* to upper */
+       for ( s = str; *s; s++ ) {
+               *s = TOUPPER( (unsigned char) *s );
+       }
+
+       return( str );
+}
+
+char *
+ldap_pvt_str2lower( char *str )
+{
+       char    *s;
+
+       /* to lower */
+       for ( s = str; *s; s++ ) {
+               *s = TOLOWER( (unsigned char) *s );
+       }
+
+       return( str );
+}
index e5178bbdc6e6dedfda65d188c8aff896122674b7..d52859042b85d5ae88243885531cbc12a712c52a 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 1ac30e5496f50e9f5101d413b292ee54ced98a65..0a6f47fe2281e5624f7f0d15f7d3678e34caf7e5 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -414,19 +415,19 @@ ldap_pvt_tls_get_option( struct ldapoptions *lo, int option, void *arg )
                break;
        case LDAP_OPT_X_TLS_CACERTFILE:
                *(char **)arg = tls_opt_cacertfile ?
-                       strdup( tls_opt_cacertfile ) : NULL;
+                       LDAP_STRDUP( tls_opt_cacertfile ) : NULL;
                break;
        case LDAP_OPT_X_TLS_CACERTDIR:
                *(char **)arg = tls_opt_cacertdir ?
-                       strdup( tls_opt_cacertdir ) : NULL;
+                       LDAP_STRDUP( tls_opt_cacertdir ) : NULL;
                break;
        case LDAP_OPT_X_TLS_CERTFILE:
                *(char **)arg = tls_opt_certfile ?
-                       strdup( tls_opt_certfile ) : NULL;
+                       LDAP_STRDUP( tls_opt_certfile ) : NULL;
                break;
        case LDAP_OPT_X_TLS_KEYFILE:
                *(char **)arg = tls_opt_keyfile ?
-                       strdup( tls_opt_keyfile ) : NULL;
+                       LDAP_STRDUP( tls_opt_keyfile ) : NULL;
                break;
        case LDAP_OPT_X_TLS_REQUIRE_CERT:
                *(int *)arg = tls_opt_require_cert;
@@ -466,26 +467,26 @@ ldap_pvt_tls_set_option( struct ldapoptions *lo, int option, void *arg )
        switch( option ) {
        case LDAP_OPT_X_TLS_CACERTFILE:
                if ( tls_opt_cacertfile ) free( tls_opt_cacertfile );
-               tls_opt_cacertfile = arg ? strdup( (char *) arg ) : NULL;
+               tls_opt_cacertfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
                break;
        case LDAP_OPT_X_TLS_CACERTDIR:
                if ( tls_opt_cacertdir ) free( tls_opt_cacertdir );
-               tls_opt_cacertdir = arg ? strdup( (char *) arg ) : NULL;
+               tls_opt_cacertdir = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
                break;
        case LDAP_OPT_X_TLS_CERTFILE:
                if ( tls_opt_certfile ) free( tls_opt_certfile );
-               tls_opt_certfile = arg ? strdup( (char *) arg ) : NULL;
+               tls_opt_certfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
                break;
        case LDAP_OPT_X_TLS_KEYFILE:
                if ( tls_opt_keyfile ) free( tls_opt_keyfile );
-               tls_opt_keyfile = arg ? strdup( (char *) arg ) : NULL;
+               tls_opt_keyfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
                break;
        case LDAP_OPT_X_TLS_REQUIRE_CERT:
                tls_opt_require_cert = * (int *) arg;
                break;
        case LDAP_OPT_X_TLS_CIPHER_SUITE:
                if ( tls_opt_ciphersuite ) free( tls_opt_ciphersuite );
-               tls_opt_ciphersuite = arg ? strdup( (char *) arg ) : NULL;
+               tls_opt_ciphersuite = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
                break;
        default:
                return -1;
index 06c8fe33cdeb711e6deb63670c4d42dcb5bb3889..8b480a3ef568a1da8a53c0336843c22078e7cb97 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index b7969334888eb524c325229faa48174dd89b1ae9..bbdae7fa1af49809de64d833c54d37982816d62b 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 9596adf131dcee892fb90b5dea07a43cfd14919f..9d215cdec999aa45eb2333482374cbee70225c60 100644 (file)
@@ -1,55 +1,40 @@
+/* $OpenLDAP$ */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  ufn.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#else /* DOS */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-
-#ifdef NEEDPROTOS
-typedef int (*cancelptype)( void *cancelparm );
-#else /* NEEDPROTOS */
-typedef int (*cancelptype)();
-#endif /* NEEDPROTOS */
-
-#ifdef NEEDPROTOS
-static int ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, 
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+#include "ldap_defaults.h"
+
+typedef int (*cancelptype) LDAP_P(( void *cancelparm ));
+
+/* local functions */
+static int ldap_ufn_search_ctx LDAP_P(( LDAP *ld, char **ufncomp, int ncomp, 
        char *prefix, char **attrs, int attrsonly, LDAPMessage **res, 
        cancelptype 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, cancelptype cancelproc,
+       char *tag3 ));
+static LDAPMessage *ldap_msg_merge LDAP_P(( LDAP *ld, LDAPMessage *a, LDAPMessage *b ));
+static LDAPMessage *ldap_ufn_expand LDAP_P(( LDAP *ld, cancelptype cancelproc,
        void *cancelparm, char **dns, char *filter, int scope,
-       char **attrs, int aonly, int *err );
-LDAPFiltDesc *ldap_ufn_setfilter( LDAP *ld, char *fname );
-#else /* NEEDPROTOS */
-static LDAPMessage *ldap_msg_merge();
-static LDAPMessage *ldap_ufn_expand();
-LDAPFiltDesc *ldap_ufn_setfilter();
-#endif /* NEEDPROTOS */
+       char **attrs, int aonly, int *err ));
 
 /*
  * ldap_ufn_search_ctx - do user friendly searching; provide cancel feature;
@@ -63,8 +48,8 @@ LDAPFiltDesc *ldap_ufn_setfilter();
  *     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.
+ *                     cancelled.  This can be a null function pointer.  If
+ *                     it is not 0, 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
@@ -83,13 +68,12 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
        char **attrs, int attrsonly, LDAPMessage **res, cancelptype cancelproc,
        void *cancelparm, char *tag1, char *tag2, char *tag3 )
 {
-       char            *dn, *ftag;
-       char            **dns;
-       int             max, i, err, scope, phase, tries;
+       char            *dn, *ftag = NULL;
+       char            **dns = NULL;
+       int             max, i, err, scope = 0, phase, tries;
        LDAPFiltInfo    *fi;
        LDAPMessage     *tmpcand;
        LDAPMessage     *candidates;
-       LDAPMessage     *ldap_msg_merge(), *ldap_ufn_expand();
        static char     *objattrs[] = { "objectClass", NULL };
 
        /* 
@@ -115,7 +99,8 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
 
                        if ( (quote = strrchr( ufncomp[ncomp], '"' )) != NULL )
                                *quote = '\0';
-                       strcpy( ufncomp[ncomp], ufncomp[ncomp] + 1 );
+                       SAFEMEMCPY( ufncomp[ncomp], ufncomp[ncomp] + 1,
+                                   strlen( ufncomp[ncomp] + 1 ) + 1 );
                }
                if ( ncomp == 0 )
                        phase = 3;
@@ -142,11 +127,11 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
 
                if ( candidates == NULL ) {
                        if ( prefix != NULL ) {
-                               if ( (dns = (char **) malloc( sizeof(char *)
+                               if ( (dns = (char **) LDAP_MALLOC( sizeof(char *)
                                    * 2 )) == NULL ) {
                                        return( ld->ld_errno = LDAP_NO_MEMORY );
                                }
-                               dns[0] = strdup( prefix );
+                               dns[0] = LDAP_STRDUP( prefix );
                                dns[1] = NULL;
                        } else {
                                dns = NULL;
@@ -161,14 +146,14 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
                                        continue;
 
                                if ( dns == NULL ) {
-                                       if ( (dns = (char **) malloc(
+                                       if ( (dns = (char **) LDAP_MALLOC(
                                            sizeof(char *) * 8 )) == NULL ) {
                                                ld->ld_errno = LDAP_NO_MEMORY;
                                                return( LDAP_NO_MEMORY );
                                        }
                                        max = 8;
                                } else if ( i >= max ) {
-                                       if ( (dns = (char **) realloc( dns,
+                                       if ( (dns = (char **) LDAP_REALLOC( dns,
                                            sizeof(char *) * 2 * max ))
                                            == NULL )
                                        {
@@ -234,13 +219,14 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
 }
 
 int
-ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly,
+ldap_ufn_search_ct(
+       LDAP *ld, LDAP_CONST char *ufn, char **attrs, int attrsonly,
        LDAPMessage **res, cancelptype cancelproc, void *cancelparm,
        char *tag1, char *tag2, char *tag3 )
 {
        char    **ufncomp, **prefixcomp;
        char    *pbuf;
-       int     ncomp, pcomp, i, err;
+       int     ncomp, pcomp, i, err = 0;
 
        /* initialize the getfilter stuff if it's not already */
        if ( ld->ld_filtd == NULL && ldap_ufn_setfilter( ld, FILTERFILE )
@@ -280,7 +266,7 @@ ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly,
        }
        for ( pcomp = 0; prefixcomp[pcomp] != NULL; pcomp++ )
                ;       /* NULL */
-       if ( (pbuf = (char *) malloc( strlen( ld->ld_ufnprefix ) + 1 ))
+       if ( (pbuf = (char *) LDAP_MALLOC( strlen( ld->ld_ufnprefix ) + 1 ))
            == NULL ) { 
                ldap_value_free( ufncomp );
                ldap_value_free( prefixcomp );
@@ -309,7 +295,7 @@ ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly,
 
        ldap_value_free( ufncomp );
        ldap_value_free( prefixcomp );
-       free( pbuf );
+       LDAP_FREE( pbuf );
 
        return( err );
 }
@@ -319,7 +305,8 @@ ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly,
  * ldapfilter.conf tags.
  */
 int
-ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs, int attrsonly,
+ldap_ufn_search_c(
+       LDAP *ld, LDAP_CONST char *ufn, char **attrs, int attrsonly,
        LDAPMessage **res, cancelptype cancelproc, void *cancelparm )
 {
        return( ldap_ufn_search_ct( ld, ufn, attrs, attrsonly, res, cancelproc,
@@ -330,7 +317,8 @@ ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs, int attrsonly,
  * same as ldap_ufn_search_c without the cancel function
  */
 int
-ldap_ufn_search_s( LDAP *ld, char *ufn, char **attrs, int attrsonly,
+ldap_ufn_search_s(
+       LDAP *ld, LDAP_CONST char *ufn, char **attrs, int attrsonly,
        LDAPMessage **res )
 {
        struct timeval  tv;
@@ -444,7 +432,7 @@ ldap_ufn_expand( LDAP *ld, cancelptype cancelproc, void *cancelparm,
 
                do {
                        *err = ldap_result( ld, msgid, 1, &tv, &tmpres );
-                       if ( *err == 0 && cancelproc != NULL &&
+                       if ( *err == 0 && cancelproc != 0 &&
                            (*cancelproc)( cancelparm ) != 0 ) {
                                ldap_abandon( ld, msgid );
                                *err = LDAP_USER_CANCELLED;
@@ -476,7 +464,7 @@ ldap_ufn_expand( LDAP *ld, cancelptype cancelproc, void *cancelparm,
  */
 
 LDAPFiltDesc *
-ldap_ufn_setfilter( LDAP *ld, char *fname )
+ldap_ufn_setfilter( LDAP *ld, LDAP_CONST char *fname )
 {
        if ( ld->ld_filtd != NULL )
                ldap_getfilter_free( ld->ld_filtd );
@@ -485,12 +473,12 @@ ldap_ufn_setfilter( LDAP *ld, char *fname )
 }
 
 void
-ldap_ufn_setprefix( LDAP *ld, char *prefix )
+ldap_ufn_setprefix( LDAP *ld, LDAP_CONST char *prefix )
 {
        if ( ld->ld_ufnprefix != NULL )
-               free( ld->ld_ufnprefix );
+               LDAP_FREE( ld->ld_ufnprefix );
 
-       ld->ld_ufnprefix = strdup( prefix );
+       ld->ld_ufnprefix = LDAP_STRDUP( prefix );
 }
 
 int
index 93ce360d754fb1039499e750eb5336e8fe5cd88d..852926f785304f7c45660f9dcbb91e8ff55d20d7 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 988bac7d459b60c0ff879cda348948d7a76242fb..b632c688f8da78a9b5014bf506d60ab48bef76a9 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
diff --git a/libraries/libldap/util-int.c b/libraries/libldap/util-int.c
new file mode 100644 (file)
index 0000000..a3128e6
--- /dev/null
@@ -0,0 +1,372 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*
+ * util-int.c  Various functions to replace missing threadsafe ones.
+ *                               Without the real *_r funcs, things will
+ *                               work, but might not be threadsafe. 
+ * 
+ * Written by Bart Hartgers.
+ *
+ * Copyright 1998, A. Hartgers, All rights reserved.
+ * This software is not subject to any license of Eindhoven University of
+ * Technology, since it was written in my spare time.
+ *                     
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */ 
+
+
+#include "portable.h"
+
+#include <ac/stdlib.h>
+
+#include <ac/errno.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+
+#if defined( LDAP_R_COMPILE )
+# include <ldap_pvt_thread.h>
+#else
+# undef HAVE_REENTRANT_FUNCTIONS
+#endif
+
+#if (defined( HAVE_CTIME_R ) || defined( HAVE_REENTRANT_FUNCTIONS)) \
+       && defined( CTIME_R_NARGS )
+#      define USE_CTIME_R
+#endif
+
+#if defined(HAVE_GETHOSTBYNAME_R) && \
+    (GETHOSTBYNAME_R_NARGS > 6 || GETHOSTBYNAME_R_NARGS < 5)
+       /* Don't know how to handle this version, pretend it's not there */
+#      undef HAVE_GETHOSTBYNAME_R
+#endif
+#if defined(HAVE_GETHOSTBYADDR_R) && \
+    (GETHOSTBYADDR_R_NARGS > 8 || GETHOSTBYADDR_R_NARGS < 7)
+       /* Don't know how to handle this version, pretend it's not there */
+#      undef HAVE_GETHOSTBYADDR_R
+#endif
+
+#ifdef LDAP_R_COMPILE
+# ifndef USE_CTIME_R
+       static ldap_pvt_thread_mutex_t ldap_int_ctime_mutex;
+# endif
+# ifndef HAVE_GETHOSTBYNAME_R
+       static ldap_pvt_thread_mutex_t ldap_int_gethostbyname_mutex;
+# endif
+# ifndef HAVE_GETHOSTBYADDR_R
+       static ldap_pvt_thread_mutex_t ldap_int_gethostbyaddr_mutex;
+# endif
+#endif /* LDAP_R_COMPILE */
+
+char *ldap_pvt_ctime( const time_t *tp, char *buf )
+{
+#ifdef USE_CTIME_R
+# if (CTIME_R_NARGS > 3) || (CTIME_R_NARGS < 2)
+#      error "CTIME_R_NARGS should be 2 or 3"
+# elif CTIME_R_NARGS > 2 && defined(CTIME_R_RETURNS_INT)
+       return( ctime_r(tp,buf,26) < 0 ? 0 : buf );
+# elif CTIME_R_NARGS > 2
+       return ctime_r(tp,buf,26);
+# else
+       return ctime_r(tp,buf);
+# endif          
+
+#else
+# ifdef LDAP_R_COMPILE
+       ldap_pvt_thread_mutex_lock( &ldap_int_ctime_mutex );
+# endif
+       memcpy( buf, ctime(tp), 26 );
+# ifdef LDAP_R_COMPILE
+       ldap_pvt_thread_mutex_unlock( &ldap_int_ctime_mutex );
+# endif
+       return buf;
+#endif 
+}
+
+#define BUFSTART 1024
+#define BUFMAX (32*1024)
+
+static char *safe_realloc( char **buf, int len );
+static int copy_hostent( struct hostent *res, char **buf, struct hostent * src );
+
+int ldap_pvt_gethostbyname_a(
+       const char *name, 
+       struct hostent *resbuf,
+       char **buf,
+       struct hostent **result,
+       int *herrno_ptr )
+{
+#if defined( HAVE_GETHOSTBYNAME_R )
+
+# define NEED_SAFE_REALLOC 1   
+       int r=-1;
+       int buflen=BUFSTART;
+       *buf = NULL;
+       for(;buflen<BUFMAX;) {
+               if (safe_realloc( buf, buflen )==NULL)
+                       return r;
+
+#if (GETHOSTBYNAME_R_NARGS < 6)
+               r = ((*result=gethostbyname_r( name, resbuf, *buf,
+                                              buflen, herrno_ptr ))== NULL) ?
+                   -1 : 0;
+#else
+               r = gethostbyname_r( name, resbuf, *buf,
+                       buflen, result, herrno_ptr );
+#endif
+
+               Debug( LDAP_DEBUG_TRACE, "ldap_pvt_gethostbyname_a: host=%s, r=%d\n",
+                      name, r, 0 );
+
+#ifdef NETDB_INTERNAL
+               if ((r<0) &&
+                       (*herrno_ptr==NETDB_INTERNAL) &&
+                       (errno==ERANGE))
+               {
+                       buflen*=2;
+                       continue;
+               }
+#endif
+               return r;
+       }
+       return -1;
+#elif defined( LDAP_R_COMPILE )
+# define NEED_COPY_HOSTENT   
+       struct hostent *he;
+       int     retval;
+       
+       ldap_pvt_thread_mutex_lock( &ldap_int_gethostbyname_mutex );
+       
+       he = gethostbyname( name );
+       
+       if (he==NULL) {
+               *herrno_ptr = h_errno;
+               retval = -1;
+       } else if (copy_hostent( resbuf, buf, he )<0) {
+               *herrno_ptr = -1;
+               retval = -1;
+       } else {
+               *result = resbuf;
+               retval = 0;
+       }
+       
+       ldap_pvt_thread_mutex_unlock( &ldap_int_gethostbyname_mutex );
+       
+       return retval;
+#else  
+       *result = gethostbyname( name );
+
+       if (*result!=NULL) {
+               return 0;
+       }
+
+       *herrno_ptr = h_errno;
+       
+       return -1;
+#endif 
+}
+        
+int ldap_pvt_gethostbyaddr_a(
+       const char *addr,
+       int len,
+       int type,
+       struct hostent *resbuf,
+       char **buf,
+       struct hostent **result,
+       int *herrno_ptr )
+{
+#if defined( HAVE_GETHOSTBYADDR_R )
+
+# undef NEED_SAFE_REALLOC
+# define NEED_SAFE_REALLOC   
+       int r=-1;
+       int buflen=BUFSTART;
+       *buf = NULL;   
+       for(;buflen<BUFMAX;) {
+               if (safe_realloc( buf, buflen )==NULL)
+                       return r;
+#if (GETHOSTBYADDR_R_NARGS < 8)
+               r = ((*result=gethostbyaddr_r( addr, len, type,
+                                              resbuf, *buf, buflen, 
+                                              herrno_ptr )) == NULL) ?
+                   -1 : 0;
+#else
+               r = gethostbyaddr_r( addr, len, type,
+                       resbuf, *buf, buflen, 
+                       result, herrno_ptr );
+#endif
+
+#ifdef NETDB_INTERNAL
+               if ((r<0) &&
+                       (*herrno_ptr==NETDB_INTERNAL) &&
+                       (errno==ERANGE))
+               {
+                       buflen*=2;
+                       continue;
+               }
+#endif
+               return r;
+       }
+       return -1;
+#elif defined( LDAP_R_COMPILE )
+# undef NEED_COPY_HOSTENT
+# define NEED_COPY_HOSTENT   
+       struct hostent *he;
+       int     retval;
+       
+       ldap_pvt_thread_mutex_lock( &ldap_int_gethostbyaddr_mutex );
+       
+       he = gethostbyaddr( addr, len, type );
+       
+       if (he==NULL) {
+               *herrno_ptr = h_errno;
+               retval = -1;
+       } else if (copy_hostent( resbuf, buf, he )<0) {
+               *herrno_ptr = -1;
+               retval = -1;
+       } else {
+               *result = resbuf;
+               retval = 0;
+       }
+       
+       ldap_pvt_thread_mutex_unlock( &ldap_int_gethostbyaddr_mutex );
+       
+       return retval;   
+#else /* gethostbyaddr() */
+       *result = gethostbyaddr( addr, len, type );
+
+       if (*result!=NULL) {
+               return 0;
+       }
+       return -1;
+#endif 
+}
+/* 
+ * ldap_int_utils_init() should be called before any other function.
+ */
+
+void ldap_int_utils_init( void )
+{
+       static int done=0;
+       if (done)
+         return;
+       done=1;
+
+#ifdef LDAP_R_COMPILE
+
+#if !defined( USE_CTIME_R ) && !defined( HAVE_REENTRANT_FUNCTIONS )
+       ldap_pvt_thread_mutex_init( &ldap_int_ctime_mutex );
+#endif
+
+#if !defined( HAVE_GETHOSTBYNAME_R )
+       ldap_pvt_thread_mutex_init( &ldap_int_gethostbyname_mutex );
+#endif
+
+#if !defined( HAVE_GETHOSTBYADDR_R )
+       ldap_pvt_thread_mutex_init( &ldap_int_gethostbyaddr_mutex );
+#endif
+
+       /* call other module init functions here... */
+#endif
+}
+
+#if defined( NEED_COPY_HOSTENT )
+# undef NEED_SAFE_REALLOC
+#define NEED_SAFE_REALLOC
+
+static char *cpy_aliases( char ***tgtio, char *buf, char **src )
+{
+       int len;
+       char **tgt=*tgtio;
+       for( ; (*src) ; src++ ) {
+               len = strlen( *src ) + 1;
+               memcpy( buf, *src, len );
+               *tgt++=buf;
+               buf+=len;
+       }
+       *tgtio=tgt;   
+       return buf;
+}
+
+static char *cpy_addresses( char ***tgtio, char *buf, char **src, int len )
+{
+       char **tgt=*tgtio;
+       for( ; (*src) ; src++ ) {
+               memcpy( buf, *src, len );
+               *tgt++=buf;
+               buf+=len;
+       }
+       *tgtio=tgt;      
+       return buf;
+}
+
+static int copy_hostent( struct hostent *res, char **buf, struct hostent * src )
+{
+       char    **p;
+       char    **tp;
+       char    *tbuf;
+       int     name_len;
+       int     n_alias;
+       int     total_alias_len;
+       int     n_addr;
+       int     total_addr_len;
+       int     total_len;
+         
+       /* calculate the size needed for the buffer */
+       name_len = strlen( src->h_name ) + 1;
+       
+       for( n_alias=total_alias_len=0, p=src->h_aliases; (*p) ; p++ ) {
+               total_alias_len += strlen( *p ) + 1;
+               n_alias++; 
+       }
+
+       for( n_addr=0, p=src->h_addr_list; (*p) ; p++ ) {
+               n_addr++;
+       }
+       total_addr_len = n_addr * src->h_length;
+       
+       total_len = (n_alias + n_addr + 2) * sizeof( char * ) +
+               total_addr_len + total_alias_len + name_len;
+       
+       if (safe_realloc( buf, total_len )) {                    
+               tp = (char **) *buf;
+               tbuf = *buf + (n_alias + n_addr + 2) * sizeof( char * );
+               memcpy( res, src, sizeof( struct hostent ) );
+               /* first the name... */
+               memcpy( tbuf, src->h_name, name_len );
+               res->h_name = tbuf; tbuf+=name_len;
+               /* now the aliases */
+               res->h_aliases = tp;
+               tbuf = cpy_aliases( &tp, tbuf, src->h_aliases );
+               *tp++=NULL;
+               /* finally the addresses */
+               res->h_addr_list = tp;
+               tbuf = cpy_addresses( &tp, tbuf, src->h_addr_list, src->h_length );
+               *tp++=NULL;
+               return 0;
+       }
+       return -1;
+}
+#endif
+
+#if defined( NEED_SAFE_REALLOC )
+static char *safe_realloc( char **buf, int len )
+{
+       char *tmpbuf;
+       tmpbuf = LDAP_REALLOC( *buf, len );
+       if (tmpbuf) {
+               *buf=tmpbuf;
+       } 
+       return tmpbuf;
+}
+#endif
+
+
index a305b7d20e4ccc450a006097e8cc26d142a0d96d..fba054ecb0ee7536afd0441c958ff3a3e9acbef3 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ##
 ## Makefile.in for LDAP -lldap
 ##
@@ -15,9 +16,9 @@ XXSRCS        = apitest.c test.c tmpltest.c extended.c \
        getdn.c getentry.c getattr.c getvalues.c addentry.c \
        request.c getdxbyname.c os-ip.c url.c charset.c \
        init.c options.c print.c string.c util-int.c schema.c \
-       charray.c digest.c tls.c
+       charray.c digest.c tls.c dn.c
 SRCS   = thr_posix.c thr_cthreads.c thr_thr.c thr_lwp.c thr_nt.c \
-       thr_sleep.c thr_stub.c rdwr.c
+       thr_pth.c thr_sleep.c thr_stub.c rdwr.c
 OBJS   = extended.lo \
        bind.lo controls.lo open.lo result.lo error.lo compare.lo search.lo \
        modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \
@@ -27,8 +28,8 @@ OBJS  = extended.lo \
        request.lo getdxbyname.lo os-ip.lo url.lo charset.lo \
        init.lo options.lo print.lo string.lo util-int.lo schema.lo \
        thr_posix.lo thr_cthreads.lo thr_thr.lo thr_lwp.lo thr_nt.lo \
-       thr_sleep.lo thr_stub.lo rdwr.lo \
-       charray.lo digest.lo tls.lo
+       thr_pth.lo thr_sleep.lo thr_stub.lo rdwr.lo \
+       charray.lo digest.lo tls.lo dn.lo
 
 LDAP_INCDIR= ../../include       
 LDAP_LIBDIR= ../../libraries
diff --git a/libraries/libldap_r/rdwr.c b/libraries/libldap_r/rdwr.c
new file mode 100644 (file)
index 0000000..ab31f42
--- /dev/null
@@ -0,0 +1,262 @@
+/* $OpenLDAP$ */
+/*
+** This is an improved implementation of Reader/Writer locks does
+** not protect writers from starvation.  That is, if a writer is
+** currently waiting on a reader, any new reader will get
+** the lock before the writer.
+**
+** Does not support cancellation nor does any status checking.
+*/
+
+/********************************************************
+ * Adapted from:
+ *     "Programming with Posix Threads"
+ *             by David R Butenhof
+ *             Addison-Wesley 
+ ********************************************************
+ */
+
+#include "portable.h"
+
+#include <ac/stdlib.h>
+
+#include <ac/errno.h>
+#include <ac/string.h>
+
+#include "ldap_pvt_thread.h"
+
+int 
+ldap_pvt_thread_rdwr_init( ldap_pvt_thread_rdwr_t *rw )
+{
+       assert( rw != NULL );
+
+       memset( rw, 0, sizeof(ldap_pvt_thread_rdwr_t) );
+
+       /* we should check return results */
+       ldap_pvt_thread_mutex_init( &rw->ltrw_mutex );
+       ldap_pvt_thread_cond_init( &rw->ltrw_read );
+       ldap_pvt_thread_cond_init( &rw->ltrw_write );
+
+       rw->ltrw_valid = LDAP_PVT_THREAD_RDWR_VALID;
+       return 0;
+}
+
+int 
+ldap_pvt_thread_rdwr_destroy( ldap_pvt_thread_rdwr_t *rw )
+{
+       assert( rw != NULL );
+       assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID );
+
+       if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID )
+               return LDAP_PVT_THREAD_EINVAL;
+
+       ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex );
+
+       /* active threads? */
+       if( rw->ltrw_r_active > 0 || rw->ltrw_w_active > 1) {
+               ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex );
+               return LDAP_PVT_THREAD_EBUSY;
+       }
+
+       /* waiting threads? */
+       if( rw->ltrw_r_wait > 0 || rw->ltrw_w_wait > 0) {
+               ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex );
+               return LDAP_PVT_THREAD_EBUSY;
+       }
+
+       rw->ltrw_valid = 0;
+
+       ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex );
+
+       ldap_pvt_thread_mutex_destroy( &rw->ltrw_mutex );
+       ldap_pvt_thread_cond_destroy( &rw->ltrw_read );
+       ldap_pvt_thread_cond_destroy( &rw->ltrw_write );
+
+       return 0;
+}
+
+int ldap_pvt_thread_rdwr_rlock( ldap_pvt_thread_rdwr_t *rw )
+{
+       assert( rw != NULL );
+       assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID );
+
+       if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID )
+               return LDAP_PVT_THREAD_EINVAL;
+
+       ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex );
+
+       if( rw->ltrw_w_active > 1 ) {
+               /* writer is active */
+
+               rw->ltrw_r_wait++;
+
+               do {
+                       ldap_pvt_thread_cond_wait(
+                               &rw->ltrw_read, &rw->ltrw_mutex );
+               } while( rw->ltrw_w_active > 1 );
+
+               rw->ltrw_r_wait--;
+       }
+
+       rw->ltrw_r_active++;
+
+       ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex );
+
+       return 0;
+}
+
+int ldap_pvt_thread_rdwr_rtrylock( ldap_pvt_thread_rdwr_t *rw )
+{
+       assert( rw != NULL );
+       assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID );
+
+       if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID )
+               return LDAP_PVT_THREAD_EINVAL;
+
+       ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex );
+
+       if( rw->ltrw_w_active > 1) {
+               ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex );
+               return LDAP_PVT_THREAD_EBUSY;
+       }
+
+       rw->ltrw_r_active++;
+
+       ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex );
+
+       return 0;
+}
+
+int ldap_pvt_thread_rdwr_runlock( ldap_pvt_thread_rdwr_t *rw )
+{
+       assert( rw != NULL );
+       assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID );
+
+       if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID )
+               return LDAP_PVT_THREAD_EINVAL;
+
+       ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex );
+
+       rw->ltrw_r_active--;
+
+       if (rw->ltrw_r_active == 0 && rw->ltrw_w_wait > 0 ) {
+               ldap_pvt_thread_cond_signal( &rw->ltrw_write );
+       }
+
+       ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex );
+
+       return 0;
+}
+
+int ldap_pvt_thread_rdwr_wlock( ldap_pvt_thread_rdwr_t *rw )
+{
+       assert( rw != NULL );
+       assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID );
+
+       if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID )
+               return LDAP_PVT_THREAD_EINVAL;
+
+       ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex );
+
+       if ( rw->ltrw_w_active > 0 || rw->ltrw_r_active > 0 ) {
+               rw->ltrw_w_wait++;
+
+               do {
+                       ldap_pvt_thread_cond_wait(
+                               &rw->ltrw_write, &rw->ltrw_mutex );
+               } while ( rw->ltrw_w_active > 0 || rw->ltrw_r_active > 0 );
+
+               rw->ltrw_w_wait--;
+       }
+
+       rw->ltrw_w_active++;
+
+       ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex );
+
+       return 0;
+}
+
+int ldap_pvt_thread_rdwr_wtrylock( ldap_pvt_thread_rdwr_t *rw )
+{
+       assert( rw != NULL );
+       assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID );
+
+       if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID )
+               return LDAP_PVT_THREAD_EINVAL;
+
+       ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex );
+
+       if ( rw->ltrw_w_active > 0 || rw->ltrw_r_active > 0 ) {
+               ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex );
+               return LDAP_PVT_THREAD_EBUSY;
+       }
+
+       rw->ltrw_w_active++;
+
+       ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex );
+
+       return 0;
+}
+
+int ldap_pvt_thread_rdwr_wunlock( ldap_pvt_thread_rdwr_t *rw )
+{
+       assert( rw != NULL );
+       assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID );
+
+       if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID )
+               return LDAP_PVT_THREAD_EINVAL;
+
+       ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex );
+
+       rw->ltrw_w_active--;
+
+       if (rw->ltrw_r_wait > 0) {
+               ldap_pvt_thread_cond_broadcast( &rw->ltrw_read );
+
+       } else if (rw->ltrw_w_wait > 0) {
+               ldap_pvt_thread_cond_signal( &rw->ltrw_write );
+       }
+
+       ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex );
+
+       return 0;
+}
+
+#ifdef LDAP_DEBUG
+
+/* just for testing, 
+ * return 0 if false, suitable for assert(ldap_pvt_thread_rdwr_Xchk(rdwr))
+ * 
+ * Currently they don't check if the calling thread is the one 
+ * that has the lock, just that there is a reader or writer.
+ *
+ * Basically sufficent for testing that places that should have
+ * a lock are caught.
+ */
+
+int ldap_pvt_thread_rdwr_readers(ldap_pvt_thread_rdwr_t *rw)
+{
+       assert( rw != NULL );
+       assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID );
+
+       return( rw->ltrw_r_active );
+}
+
+int ldap_pvt_thread_rdwr_writers(ldap_pvt_thread_rdwr_t *rw)
+{
+       assert( rw != NULL );
+       assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID );
+
+       return( rw->ltrw_w_active );
+}
+
+int ldap_pvt_thread_rdwr_active(ldap_pvt_thread_rdwr_t *rw)
+{
+       assert( rw != NULL );
+       assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID );
+
+       return(ldap_pvt_thread_rdwr_readers(rw) +
+              ldap_pvt_thread_rdwr_writers(rw));
+}
+
+#endif /* LDAP_DEBUG */
index 5eda39c798f291dd0bfe42a4e941ed04faf95400..8d3949aa989aba76efaf07bf3df019538b2bcd0f 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
diff --git a/libraries/libldap_r/thr_lwp.c b/libraries/libldap_r/thr_lwp.c
new file mode 100644 (file)
index 0000000..3c1dff3
--- /dev/null
@@ -0,0 +1,363 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/* thr_lwp.c - wrappers around SunOS LWP threads */
+
+/* BUGS:
+ * - slurpd calls the get_stack/free_stack functions. Should be fixed, so
+ *   they can become static.
+ */
+
+#include "portable.h"
+
+#if defined( HAVE_LWP )
+
+/*************
+ *           *
+ * SunOS LWP *
+ *           *
+ *************/
+
+/* This implementation NEEDS WORK.   It currently does not compile */
+
+#include <stdio.h>
+
+#include <ac/time.h>
+#include <ac/socket.h>
+
+#include "ldap-int.h"
+
+#include "ldap_pvt_thread.h"
+
+#include <lwp/lwp.h>
+#include <lwp/stackdep.h>
+
+#define MAX_STACK      51200
+#define MAX_THREADS    20
+
+/*
+ * Initialize LWP by spinning of a schedular
+ */
+int
+ldap_pvt_thread_initialize( void )
+{
+       thread_t                tid;
+       stkalign_t              *stack;
+       int                     stackno;
+
+       if (( stack = get_stack( &stackno )) == NULL ) {
+               return -1;
+       }
+
+       lwp_create( &tid, lwp_scheduler, MINPRIO, 0, stack, 1, stackno );
+       return 0;
+}
+
+int
+ldap_pvt_thread_destroy( void )
+{
+       /* need to destory lwp_scheduler thread and clean up private
+               variables */
+       return 0;
+}
+
+struct stackinfo {
+       int             stk_inuse;
+       stkalign_t      *stk_stack;
+};
+
+static struct stackinfo        *stacks;
+
+static stkalign_t * ldap_pvt_thread_get_stack( int *stacknop )
+{
+       int     i;
+
+       if ( stacks == NULL ) {
+               stacks = (struct stackinfo *) LDAP_CALLOC( 1, MAX_THREADS *
+                   sizeof(struct stackinfo) );
+
+               if( stacks == NULL ) {
+                       Debug( LDAP_DEBUG_ANY, "stacks allocation failed",
+                               0, 0, 0 );
+                       return NULL;
+               }
+       }
+
+       for ( i = 0; i < MAX_THREADS; i++ ) {
+               if ( stacks[i].stk_inuse == 0 ) {
+                       break;
+               }
+       }
+
+       if ( i == MAX_THREADS ) {
+               Debug( LDAP_DEBUG_ANY,
+                   "no more stacks (max %d) - increase MAX_THREADS for more",
+                   MAX_THREADS, 0, 0 );
+               return( NULL );
+       }
+
+       if ( stacks[i].stk_stack == NULL ) {
+               stacks[i].stk_stack = (stkalign_t *) LDAP_MALLOC(
+                   (MAX_STACK / sizeof(stkalign_t) + 1 )
+                   * sizeof(stkalign_t) );
+
+               if( stacks[i].stk_stack == NULL ) {
+                       Debug( LDAP_DEBUG_ANY, "stack allocation failed",
+                               0, 0, 0 );
+                       return( NULL );
+               }
+       }
+
+       *stacknop = i;
+       stacks[i].stk_inuse = 1;
+       return( stacks[i].stk_stack + MAX_STACK / sizeof(stkalign_t) );
+}
+
+static void
+ldap_pvt_thread_free_stack( int        stackno )
+{
+       if ( stackno < 0 || stackno > MAX_THREADS ) {
+               Debug( LDAP_DEBUG_ANY, "free_stack of bogus stack %d\n",
+                   stackno, 0, 0 );
+       }
+
+       stacks[stackno].stk_inuse = 0;
+}
+
+static void
+lwp_create_stack( void *(*func)(), void *arg, int stackno )
+{
+       (*func)( arg );
+
+       ldap_pvt_thread_free_stack( stackno );
+}
+
+int 
+ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
+       int detach,
+       void *(*start_routine)( void *),
+       void *arg)
+{
+       stkalign_t      *stack;
+       int             stackno;
+
+       if ( (stack = ldap_pvt_thread_get_stack( &stackno )) == NULL ) {
+               return( -1 );
+       }
+       return( lwp_create( thread, lwp_create_stack, MINPRIO, 0, 
+                          stack, 3, start_routine, arg, stackno ) );
+}
+
+void 
+ldap_pvt_thread_exit( void *retval )
+{
+       lwp_destroy( SELF );
+}
+
+unsigned int
+ldap_pvt_thread_sleep(
+       unsigned int interval
+)
+{
+       thread_t                mylwp;
+       tl_t            *t, *nt;
+       time_t          now;
+
+
+       if ( lwp_self( &mylwp ) < 0 ) {
+               return -1;
+       }
+
+       time( &now );
+
+       mon_enter( &sglob->tsl_mon );
+
+       if ( sglob->tsl_list != NULL ) {
+               for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) {
+                       if ( SAMETHREAD( t->tl_tid, mylwp )) {
+                               /* We're already sleeping? */
+                               t->tl_wake = now + interval;
+                               mon_exit( &sglob->tsl_mon );
+                               lwp_suspend( mylwp );
+                               return 0;
+                       }
+               }
+       }
+
+       nt = (tl_t *) LDAP_MALLOC( sizeof( tl_t ));
+
+       if( nt == NULL ) return -1;
+
+       nt->tl_next = sglob->tsl_list;
+       nt->tl_wake = now + interval;
+       nt->tl_tid = mylwp;
+       sglob->tsl_list = nt;
+
+       mon_exit( &sglob->tsl_mon );
+
+       lwp_suspend( mylwp );
+       return 0;
+}
+
+/*
+ * The lwp_scheduler thread periodically checks to see if any threads
+ * are due to be resumed.  If there are, it resumes them.  Otherwise,
+ * it computes the lesser of ( 1 second ) or ( the minimum time until
+ * a thread need to be resumed ) and puts itself to sleep for that amount
+ * of time.
+ */
+static void
+lwp_scheduler(
+       int             stackno
+)
+{
+       time_t                  now, min;
+       struct timeval          interval;
+       tl_t                    *t;
+
+       while ( !sglob->slurpd_shutdown ) {
+               mon_enter( &sglob->tsl_mon );
+
+               time( &now );
+               min = 0L;
+               if ( sglob->tsl_list != NULL ) {
+                       for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) {
+                               if (( t->tl_wake  > 0L ) && ( t->tl_wake < now )) {
+                                       lwp_resume( t->tl_tid );
+                                       t->tl_wake = 0L;
+                               }
+
+                               if (( t->tl_wake > now ) && ( t->tl_wake < min )) {
+                                       min =  t->tl_wake;
+                               }
+                       }
+               }
+
+               mon_exit( &sglob->tsl_mon );
+
+               interval.tv_usec = 0L;
+               if ( min == 0L ) {
+                       interval.tv_sec = 1L;
+               } else {
+                       interval.tv_sec = min;
+               }
+
+               lwp_sleep( &interval );
+       }
+
+       mon_enter( &sglob->tsl_mon );
+
+       for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) {
+               lwp_resume( t->tl_tid );
+       }
+
+       mon_exit( &sglob->tsl_mon );
+
+       free_stack( stackno );
+}
+
+int 
+ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
+{
+       lwp_join( thread );
+       return 0;
+}
+
+int 
+ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_yield( void )
+{
+       lwp_yield( SELF );
+       return 0;
+}
+
+int 
+ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
+{
+       /*
+        * lwp cv_create requires the monitor id be passed in
+        * when the cv is created, pthreads passes it when the
+        * condition is waited for.  so, we fake the creation
+        * here and actually do it when the cv is waited for
+        * later.
+        */
+
+       cond->lcv_created = 0;
+
+       return( 0 );
+}
+
+int 
+ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
+{
+       return( cond->lcv_created ? cv_notify( cv->lcv_cv ) : 0 );
+}
+
+int 
+ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
+                     ldap_pvt_thread_mutex_t *mutex )
+{
+       if ( ! cond->lcv_created ) {
+               cv_create( &cond->lcv_cv, *mutex );
+               cond->lcv_created = 1;
+       }
+
+       return( cv_wait( cond->lcv_cv ) );      
+}
+
+int 
+ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( mon_create( mutex ) );
+}
+
+int 
+ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( mon_destroy( *mutex ) );
+}
+
+int 
+ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( mon_enter( *mutex ) );
+}
+
+int 
+ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( mon_exit( *mutex ) );
+}
+
+int
+ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp )
+{
+       return( mon_cond_enter( *mp ) );
+}
+
+int
+ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
+{
+       return( cv->lcv_created ? cv_destroy( cv->lcv_cv ) : 0 );
+}
+
+int
+ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv )
+{
+       return( cv->lcv_created ? cv_broadcast( cv->lcv_cv ) : 0 );
+}
+
+#endif /* HAVE_LWP */
diff --git a/libraries/libldap_r/thr_nt.c b/libraries/libldap_r/thr_nt.c
new file mode 100644 (file)
index 0000000..20cca30
--- /dev/null
@@ -0,0 +1,151 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/* thr_nt.c - wrapper around NT threads */
+
+#include "portable.h"
+
+#if defined( HAVE_NT_THREADS )
+
+#include "ldap_pvt_thread.h"
+
+int
+ldap_pvt_thread_initialize( void )
+{
+       return 0;
+}
+
+int
+ldap_pvt_thread_destroy( void )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
+       int detach,
+       void *(*start_routine)( void *),
+       void *arg)
+{
+       *thread = (ldap_pvt_thread_t)_beginthread( (void *) start_routine, 
+                                               0, arg );
+        return ( (unsigned long)*thread == -1 ? -1 : 0 );
+}
+       
+void 
+ldap_pvt_thread_exit( void *retval )
+{
+       _endthread( );
+}
+
+int 
+ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
+{
+       DWORD status;
+       status = WaitForSingleObject( (HANDLE) thread, INFINITE );
+       if (status == WAIT_FAILED) {
+               return -1;
+       }
+       return 0;
+}
+
+int 
+ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_yield( void )
+{
+       Sleep( 0 );
+       return 0;
+}
+
+int 
+ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
+{
+       *cond = CreateEvent( NULL, FALSE, FALSE, NULL );
+       return( 0 );
+}
+
+int
+ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
+{
+       CloseHandle( *cv );
+       return( 0 );
+}
+
+int 
+ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
+{
+       SetEvent( *cond );
+       return( 0 );
+}
+
+int 
+ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
+                         ldap_pvt_thread_mutex_t *mutex )
+{
+       ReleaseMutex( *mutex );
+       WaitForSingleObject( *cond, INFINITE );
+       WaitForSingleObject( *mutex, INFINITE );
+       return( 0 );
+}
+
+int
+ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv )
+{
+       SetEvent( *cv );
+       return( 0 );
+}
+
+int 
+ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
+{
+       *mutex = CreateMutex( NULL, 0, NULL );
+       return ( 0 );
+}
+
+int 
+ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
+{
+       CloseHandle( *mutex );
+       return ( 0 );   
+}
+
+int 
+ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
+{
+       WaitForSingleObject( *mutex, INFINITE );
+       return ( 0 );
+}
+
+int 
+ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
+{
+       ReleaseMutex( *mutex );
+       return ( 0 );
+}
+
+int
+ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp )
+{
+       DWORD status;
+
+       status = WaitForSingleObject( *mp, 0 );
+       if ( (status == WAIT_FAILED) || (status == WAIT_TIMEOUT) )
+               return 0;
+       else
+               return 1;
+}
+
+#endif
diff --git a/libraries/libldap_r/thr_posix.c b/libraries/libldap_r/thr_posix.c
new file mode 100644 (file)
index 0000000..c44bee4
--- /dev/null
@@ -0,0 +1,205 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/* thr_posix.c - wrapper around posix and posixish thread implementations.
+ */
+
+#include "portable.h"
+
+#if defined( HAVE_PTHREADS )
+
+#include <ac/errno.h>
+
+#include "ldap_pvt_thread.h"
+
+
+#if HAVE_PTHREADS_D4
+#  define LDAP_PVT_THREAD_ATTR_DEFAULT         pthread_attr_default
+#  define LDAP_PVT_THREAD_CONDATTR_DEFAULT     pthread_condattr_default
+#  define LDAP_PVT_THREAD_MUTEXATTR_DEFAULT    pthread_mutexattr_default
+#else
+#  define LDAP_PVT_THREAD_ATTR_DEFAULT         NULL
+#  define LDAP_PVT_THREAD_CONDATTR_DEFAULT     NULL
+#  define LDAP_PVT_THREAD_MUTEXATTR_DEFAULT    NULL
+#endif
+
+
+int
+ldap_pvt_thread_initialize( void )
+{
+#if defined( LDAP_THREAD_CONCURRENCY ) && HAVE_PTHREAD_SETCONCURRENCY
+       ldap_pvt_thread_set_concurrency( LDAP_THREAD_CONCURRENCY );
+#endif
+       return 0;
+}
+
+int
+ldap_pvt_thread_destroy( void )
+{
+       return 0;
+}
+
+#ifdef HAVE_PTHREAD_SETCONCURRENCY
+int
+ldap_pvt_thread_set_concurrency(int n)
+{
+#ifdef HAVE_PTHREAD_SETCONCURRENCY
+       return pthread_setconcurrency( n );
+#elif HAVE_THR_SETCONCURRENCY
+       return pthread_setconcurrency( n );
+#else
+       return 0;
+#endif
+}
+#endif
+
+#ifdef HAVE_PTHREAD_GETCONCURRENCY
+int
+ldap_pvt_thread_get_concurrency(void)
+{
+#ifdef HAVE_PTHREAD_GETCONCURRENCY
+       return pthread_getconcurrency();
+#elif HAVE_THR_GETCONCURRENCY
+       return pthread_getconcurrency();
+#else
+       return 0;
+#endif
+}
+#endif
+
+int 
+ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
+       int detach,
+       void *(*start_routine)( void * ),
+       void *arg)
+{
+       int rtn = pthread_create( thread, LDAP_PVT_THREAD_ATTR_DEFAULT,
+                                 start_routine, arg );
+
+       if( detach ) {
+#ifdef HAVE_PTHREADS_FINAL
+               pthread_detach( *thread );
+#else
+               pthread_detach( thread );
+#endif
+       }
+       return rtn;
+}
+
+void 
+ldap_pvt_thread_exit( void *retval )
+{
+       pthread_exit( retval );
+}
+
+int 
+ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
+{
+#if !defined( HAVE_PTHREADS_FINAL )
+       void *dummy;
+       if (thread_return==NULL)
+         thread_return=&dummy;
+#endif 
+       return pthread_join( thread, thread_return );
+}
+
+int 
+ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
+{
+#ifdef HAVE_PTHREAD_KILL
+       return pthread_kill( thread, signo );
+#else
+       /* pthread package with DCE */
+       if (kill( getpid(), signo )<0)
+               return errno;
+       return 0;
+#endif
+}
+
+int 
+ldap_pvt_thread_yield( void )
+{
+#ifdef _POSIX_THREAD_IS_GNU_PTH
+       sched_yield();
+       return 0;
+
+#elif HAVE_SCHED_YIELD
+       return sched_yield();
+
+#elif HAVE_PTHREAD_YIELD
+       pthread_yield();
+       return 0;
+
+#elif HAVE_THR_YIELD
+       return thr_yield();
+
+#else
+       return 0;
+#endif   
+}
+
+int 
+ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
+{
+       return pthread_cond_init( cond, LDAP_PVT_THREAD_CONDATTR_DEFAULT );
+}
+
+int 
+ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond )
+{
+       return pthread_cond_destroy( cond );
+}
+       
+int 
+ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
+{
+       return pthread_cond_signal( cond );
+}
+
+int
+ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
+{
+       return pthread_cond_broadcast( cond );
+}
+
+int 
+ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
+                     ldap_pvt_thread_mutex_t *mutex )
+{
+       return pthread_cond_wait( cond, mutex );
+}
+
+int 
+ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
+{
+       return pthread_mutex_init( mutex, LDAP_PVT_THREAD_MUTEXATTR_DEFAULT );
+}
+
+int 
+ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
+{
+       return pthread_mutex_destroy( mutex );
+}
+
+int 
+ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
+{
+       return pthread_mutex_lock( mutex );
+}
+
+int 
+ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
+{
+       return pthread_mutex_unlock( mutex );
+}
+
+#endif /* HAVE_PTHREADS */
+
diff --git a/libraries/libldap_r/thr_pth.c b/libraries/libldap_r/thr_pth.c
new file mode 100644 (file)
index 0000000..132644c
--- /dev/null
@@ -0,0 +1,143 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/* thr_thr.c - wrappers around solaris threads */
+
+#include "portable.h"
+
+#if defined( HAVE_GNU_PTH )
+
+#include "ldap_pvt_thread.h"
+
+/*******************
+ *                 *
+ * GNU Pth Threads *
+ *                 *
+ *******************/
+
+static pth_attr_t detach_attr;
+
+int
+ldap_pvt_thread_initialize( void )
+{
+       detach_attr = pth_attr_new();
+       pth_attr_set( detach_attr, PTH_ATTR_JOINABLE, FALSE );
+       return pth_init();
+}
+
+int
+ldap_pvt_thread_destroy( void )
+{
+       pth_attr_destroy(detach_attr);
+       pth_kill();
+       return 0;
+}
+
+int 
+ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
+       int detach,
+       void *(*start_routine)( void *),
+       void *arg)
+{
+       *thread = pth_spawn( detach ? detach_attr : PTH_ATTR_DEFAULT,
+               start_routine, arg );
+
+       return *thread == NULL;
+}
+
+void 
+ldap_pvt_thread_exit( void *retval )
+{
+       pth_exit( retval );
+}
+
+int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
+{
+       pth_join( thread, thread_return );
+       return 0;
+}
+
+int 
+ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
+{
+       pth_raise( thread, signo );
+       return 0;
+}
+       
+int 
+ldap_pvt_thread_yield( void )
+{
+       pth_yield(NULL);
+       return 0;
+}
+
+int 
+ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
+{
+       return( pth_cond_init( cond ) );
+}
+
+int 
+ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
+{
+       return( pth_cond_notify( cond, 0 ) );
+}
+
+int
+ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
+{
+       return( pth_cond_notify( cond, 1 ) );
+}
+
+int 
+ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
+                         ldap_pvt_thread_mutex_t *mutex )
+{
+       return( pth_cond_await( cond, mutex, NULL ) );
+}
+
+int
+ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( pth_mutex_init( mutex ) );
+}
+
+int 
+ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( pth_mutex_acquire( mutex, 0, NULL ) );
+}
+
+int 
+ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( pth_mutex_release( mutex ) );
+}
+
+int
+ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( pth_mutex_acquire( mutex, 1, NULL ) );
+}
+
+#endif /* HAVE_GNU_PTH */
diff --git a/libraries/libldap_r/thr_sleep.c b/libraries/libldap_r/thr_sleep.c
new file mode 100644 (file)
index 0000000..fac90d0
--- /dev/null
@@ -0,0 +1,57 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright (c) 1996 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.
+ */
+
+/*
+ * ldap_pvt_thread_sleep.c - allow a thread to sleep without putting
+ * the whole process (e.g. pod under lwp) to sleep.
+ *
+ * Contains platform-specific code to allow this:
+ *
+ * Under non-preemptive threads packages like SunOS lwp, tsleep() adds
+ * the thread to a list of sleepers.  The lwp_scheduler process takes
+ * care of resuming suspended threads.
+ *
+ * Under a fully-preemptive threads package, like Solaris threads,
+ * tsleep just calls sleep(), and there is no scheduler thread.  Life
+ * is so much simpler...
+ */
+
+#include "portable.h"
+
+#if !defined( HAVE_LWP )
+
+#include <stdio.h>
+#include <ac/stdlib.h>
+#include <ac/unistd.h>                 /* get sleep() */
+
+#include "ldap_pvt_thread.h"
+
+
+/*
+ * Here we assume we have fully preemptive threads and that sleep()
+ * does the right thing.
+ */
+unsigned int
+ldap_pvt_thread_sleep(
+       unsigned int interval
+)
+{
+       sleep( interval );
+       return 0;
+}
+
+#else
+
+/* LWP implementation of sleep can be found in thr_lwp.c */
+
+#endif /* HAVE_LWP */
diff --git a/libraries/libldap_r/thr_stub.c b/libraries/libldap_r/thr_stub.c
new file mode 100644 (file)
index 0000000..60da3ce
--- /dev/null
@@ -0,0 +1,135 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/* thr_stub.c - stubs for the threads */
+
+#include "portable.h"
+
+#if defined( NO_THREADS )
+
+#include "ldap_pvt_thread.h"
+
+/***********************************************************************
+ *                                                                     *
+ * no threads package defined for this system - fake ok returns from   *
+ * all threads routines (making it single-threaded).                   *
+ *                                                                     *
+ ***********************************************************************/
+
+int
+ldap_pvt_thread_initialize( void )
+{
+       return 0;
+}
+
+int
+ldap_pvt_thread_destroy( void )
+{
+       return 0;
+}
+
+static void* ldap_int_status = NULL;
+
+int 
+ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
+       int detach,
+       void *(*start_routine)(void *),
+       void *arg)
+{
+       if( ! detach ) ldap_int_status = NULL;
+       start_routine( arg );
+       return 0;
+}
+
+void 
+ldap_pvt_thread_exit( void *retval )
+{
+       if( retval != NULL ) {
+               ldap_int_status = retval;
+       }
+       return;
+}
+
+int 
+ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **status )
+{
+       if(status != NULL) *status = ldap_int_status;
+       return 0;
+}
+
+int 
+ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_yield( void )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond,
+                         ldap_pvt_thread_mutex_t *mutex )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
+{
+       return 0;
+}
+
+int 
+ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
+{
+       return 0;
+}
+
+#endif /* NO_THREADS */
diff --git a/libraries/libldap_r/thr_thr.c b/libraries/libldap_r/thr_thr.c
new file mode 100644 (file)
index 0000000..bb3b10d
--- /dev/null
@@ -0,0 +1,151 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/* thr_thr.c - wrappers around solaris threads */
+
+#include "portable.h"
+
+#if defined( HAVE_THR )
+
+#include "ldap_pvt_thread.h"
+
+/*******************
+ *                 *
+ * Solaris Threads *
+ *                 *
+ *******************/
+
+int
+ldap_pvt_thread_initialize( void )
+{
+#ifdef LDAP_THREAD_CONCURRENCY
+       thr_setconcurrency( LDAP_THREAD_CONCURRENCY );
+#endif
+       return 0;
+}
+
+int
+ldap_pvt_thread_destroy( void )
+{
+       return 0;
+}
+
+int
+ldap_pvt_thread_set_concurrency(int n)
+{
+       return thr_setconcurrency( n );
+}
+
+int
+ldap_pvt_thread_get_concurrency(void)
+{
+       return thr_getconcurrency();
+}
+
+int 
+ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
+       int detach,
+       void *(*start_routine)( void *),
+       void *arg)
+{
+       return( thr_create( NULL, 0, start_routine, arg,
+               detach ? THR_DETACHED : 0,
+               thread ) );
+}
+
+void 
+ldap_pvt_thread_exit( void *retval )
+{
+       thr_exit( NULL );
+}
+
+int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
+{
+       thr_join( thread, NULL, thread_return );
+       return 0;
+}
+
+int 
+ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
+{
+       thr_kill( thread, signo );
+       return 0;
+}
+       
+int 
+ldap_pvt_thread_yield( void )
+{
+       thr_yield();
+       return 0;
+}
+
+int 
+ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
+{
+       return( cond_init( cond, USYNC_THREAD, NULL ) );
+}
+
+int 
+ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
+{
+       return( cond_signal( cond ) );
+}
+
+int
+ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv )
+{
+       return( cond_broadcast( cv ) );
+}
+
+int 
+ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
+                         ldap_pvt_thread_mutex_t *mutex )
+{
+       return( cond_wait( cond, mutex ) );
+}
+
+int
+ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
+{
+       return( cond_destroy( cv ) );
+}
+
+int 
+ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( mutex_init( mutex, USYNC_THREAD, NULL ) );
+}
+
+int 
+ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( mutex_destroy( mutex ) );
+}
+
+int 
+ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( mutex_lock( mutex ) );
+}
+
+int 
+ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
+{
+       return( mutex_unlock( mutex ) );
+}
+
+int
+ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp )
+{
+       return( mutex_trylock( mp ) );
+}
+
+#endif /* HAVE_THR */
diff --git a/libraries/libldbm/Makefile.in b/libraries/libldbm/Makefile.in
new file mode 100644 (file)
index 0000000..7926c36
--- /dev/null
@@ -0,0 +1,18 @@
+# $OpenLDAP$
+##
+## Makefile for -lldbm
+##
+
+LIBRARY                = libldbm.a
+XPROGRAMS      = testldbm
+SRCS           = ldbm.c
+OBJS           = ldbm.o
+
+LDAP_INCDIR= ../../include       
+LDAP_LIBDIR= ../../libraries
+
+XLIBS          = -lldbm -lavl
+XXLIBS         = $(LDBM_LIBS)
+
+testldbm:      libldbm.a testldbm.o
+       $(CC) $(LDFLAGS) -o $@ testldbm.o $(LIBS)
index e9091a9a106af873a9a8b3eb210336f27897b164..461db8657e84964619db4b9a33a49a57c210c955 100644 (file)
@@ -1,4 +1,5 @@
 /* ldbm.c - ldap dbm compatibility routines */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -114,7 +115,7 @@ DB_ENV           *ldbm_Env = NULL;
 int ldbm_initialize( void )
 {
        int     err;
-       int     envFlags;
+       u_int32_t       envFlags;
 
        if(ldbm_initialized++) return 1;
 
@@ -441,12 +442,16 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize )
 
 #ifdef HAVE_ST_BLKSIZE
        if ( dbcachesize > 0 && stat( name, &st ) == 0 ) {
-               dbcachesize = (dbcachesize / st.st_blksize);
+               dbcachesize /= st.st_blksize;
+               if( dbcachesize == 0 ) dbcachesize = 1;
                gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) );
        }
 #else
-       dbcachesize = (dbcachesize / 4096);
-       gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) );
+       if ( dbcachesize > 0 ) {
+               dbcachesize /= 4096;
+               if( dbcachesize == 0 ) dbcachesize = 1;
+               gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) );
+       }
 #endif
 
        LDBM_UNLOCK;
index 9b7e6b9a4ade73b3b67a272148188d13f76f4fec..020e16d816380a3583e65767ff5dfd061ab92e85 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ##
 ## Makefile for -lldif
 ##
index 69c15b77493e22f61a46525a64d240fbf837de91..94d08614552668a42a52c28177a3eab6c7c9e6c9 100644 (file)
@@ -1,4 +1,5 @@
 /* line64.c - routines for dealing with the slapd line format */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -71,7 +72,7 @@ ldif_fetch_url(
 
        total = 0;
 
-       while( bytes = fread( buffer, 1, sizeof(buffer), url ) ) {
+       while( (bytes = fread( buffer, 1, sizeof(buffer), url )) != 0 ) {
                char *newp = ber_memrealloc( p, total + bytes );
                if( newp == NULL ) {
                        ber_memfree( p );
@@ -90,4 +91,3 @@ ldif_fetch_url(
 
        return 0;
 }
-
index cd84e3d26b9719d93ba7b02968774f6421981226..f2a8e995ed055f28793cb7614ffa7d2497a09084 100644 (file)
@@ -1,4 +1,5 @@
 /* line64.c - routines for dealing with the slapd line format */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -110,6 +111,9 @@ ldif_parse_line(
        }
        *s++ = '\0';
 
+       url = 0;
+       b64 = 0;
+
        if ( *s == '\0' ) {
                /* no value */
                value = NULL;
@@ -117,9 +121,6 @@ ldif_parse_line(
                goto done;
        }
                
-       url = 0;
-       b64 = 0;
-
        if ( *s == '<' ) {
                s++;
                url = 1;
@@ -341,11 +342,12 @@ ldif_sput(
                        len++;
                }
 
+       }
 #ifdef LDAP_DEBUG
-       else {
+       else {
                assert( type == LDIF_PUT_COMMENT );
-#endif
        }
+#endif
 
        switch( type ) {
        case LDIF_PUT_NOVALUE:
@@ -552,7 +554,7 @@ ldif_read_record(
        char        **bufp,     /* ptr to malloced output buffer           */
        int         *buflenp )  /* ptr to length of *bufp                  */
 {
-       char        linebuf[BUFSIZ], *line;
+       char        linebuf[BUFSIZ], *line, *nbufp;
        ber_len_t   lcur = 0, len, linesize;
        int         last_ch = '\n', found_entry = 0, stop;
 
@@ -588,7 +590,8 @@ ldif_read_record(
                }
 
                if ( *buflenp - lcur <= len ) {
-                       char *nbufp = ber_memrealloc( *bufp, *buflenp += len + BUFSIZ );
+                       *buflenp += len + BUFSIZ;
+                       nbufp = ber_memrealloc( *bufp, *buflenp );
                        if( nbufp == NULL ) {
                                return 0;
                        }
index 189f2f66236215fd377ecee626d12f9688ebcd20..31e3aa9d8d498bc81e47bd1f792181fcd98a8a6e 100644 (file)
@@ -1,12 +1,13 @@
+# $OpenLDAP$
 ##
 ## Makefile for -lutil
 ##
 
 LIBRARY        = liblutil.a
 SRCS   = base64.c debug.c detach.c \
-       md5.c passwd.c sha1.c getpass.c lockf.c utils.c
+       md5.c passwd.c sha1.c getpass.c lockf.c utils.c sockpair.c
 OBJS   = base64.o debug.o detach.o \
-       md5.o passwd.o sha1.o getpass.o lockf.o utils.o \
+       md5.o passwd.o sha1.o getpass.o lockf.o utils.o sockpair.o \
        @LIBOBJS@
 
 LDAP_INCDIR= ../../include       
index e837088347682ce3af7926b9497bc5ed3c7b1f34..d4e107b621eed0ce4d1be734de534e1a2396413d 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index f6b9979060b6de9572387ede8446075400c6018c..a6fc5064d2d9d7861461bc5753b60e9658e56b02 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -33,7 +34,7 @@ static FILE *log_file;
 
 int lutil_debug_file( FILE *file )
 {
-       log_file = log_file;
+       log_file = file;
 
        return 0;
 }
index a398ed356a3fc9ef41f7f73e15bfa58e406b4391..c4f2aa4478eb6db60d4ec83cb3c0b0b6fa85aa41 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990, 1994 Regents of the University of Michigan.
  * All rights reserved.
index 2294dcf519dfc69cbf7ab741ddfb8c002de82b45..3b0ca476a5b59a55099101733c5eb95d4a854d4a 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 6efd3f00d4068917e9476740c7b452511c3d0b5d..ce8f6de8c800a94b7dc021b048ffb722543afe96 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 539fc479c09a2dd37bda42c8de9a040a572aed88..54800a3eca9624342415670af3cfa653dab405a3 100644 (file)
@@ -255,6 +255,10 @@ InputPath=.\slapdmsg.mc
 # End Source File
 # Begin Source File
 
+SOURCE=.\sockpair.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\utils.c
 # End Source File
 # End Target
diff --git a/libraries/liblutil/lockf.c b/libraries/liblutil/lockf.c
new file mode 100644 (file)
index 0000000..a3424ba
--- /dev/null
@@ -0,0 +1,114 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/*
+ * File Locking Routines
+ *
+ * Implementations (in order of preference)
+ *     - lockf
+ *     - fcntl
+ *  - flock
+ *
+ * Other implementations will be added as needed.
+ *
+ * NOTE: lutil_lockf() MUST block until an exclusive lock is acquired.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/unistd.h>
+
+#undef LOCK_API
+
+#if HAVE_LOCKF && defined(F_LOCK)
+#      define USE_LOCKF 1
+#      define LOCK_API "lockf"
+#endif
+
+#if !defined(LOCK_API) && HAVE_FCNTL
+#      ifdef HAVE_FCNTL_H
+#              include <fcntl.h>
+#      endif
+#      ifdef F_WRLCK
+#              define USE_FCNTL 1
+#              define LOCK_API "fcntl"
+#      endif
+#endif
+
+#if !defined(LOCK_API) && HAVE_FLOCK
+#      if HAVE_SYS_FILE_H
+#              include <sys/file.h>
+#      endif
+#      define USE_FLOCK 1
+#      define LOCK_API "flock"
+#endif
+
+#if !defined(USE_LOCKF) && !defined(USE_FCNTL) && !defined(USE_FLOCK)
+int lutil_lockf ( int fd ) {
+    fd = fd;
+    return 0;
+}
+
+int lutil_unlockf ( int fd ) {
+    fd = fd;
+    return 0;
+}
+#endif
+
+#ifdef USE_LOCKF
+int lutil_lockf ( int fd ) {
+       /* use F_LOCK instead of F_TLOCK, ie: block */
+       return lockf( fd, F_LOCK, 0 );
+}
+
+int lutil_unlockf ( int fd ) {
+       return lockf( fd, F_ULOCK, 0 );
+}
+#endif
+
+#ifdef USE_FCNTL
+int lutil_lockf ( int fd ) {
+       struct flock file_lock;
+
+       memset( &file_lock, 0, sizeof( file_lock ) );
+       file_lock.l_type = F_WRLCK;
+       file_lock.l_whence = SEEK_SET;
+       file_lock.l_start = 0;
+       file_lock.l_len = 0;
+
+       /* use F_SETLKW instead of F_SETLK, ie: block */
+       return( fcntl( fd, F_SETLKW, &file_lock ) );
+}
+
+int lutil_unlockf ( int fd ) {
+       struct flock file_lock;
+
+       memset( &file_lock, 0, sizeof( file_lock ) );
+       file_lock.l_type = F_UNLCK;
+       file_lock.l_whence = SEEK_SET;
+       file_lock.l_start = 0;
+       file_lock.l_len = 0;
+
+       return( fcntl ( fd, F_SETLKW, &file_lock ) );
+}
+#endif
+
+#ifdef USE_FLOCK
+int lutil_lockf ( int fd ) {
+       /* use LOCK_EX instead of LOCK_EX|LOCK_NB, ie: block */
+       return flock( fd, LOCK_EX );
+}
+
+int lutil_unlockf ( int fd ) {
+       return flock( fd, LOCK_UN );
+}
+#endif
index 0109b1c652e35f981dc41108ebccff0133134618..6758de02409af77e40adb6296de2dcd71fac60a7 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
diff --git a/libraries/liblutil/memcmp.c b/libraries/liblutil/memcmp.c
new file mode 100644 (file)
index 0000000..eed4b89
--- /dev/null
@@ -0,0 +1,20 @@
+/* $OpenLDAP$ */
+#include "portable.h"
+
+#include <ac/string.h>
+
+/* 
+ * Memory Compare
+ */
+int
+(memcmp)(const void *v1, const void *v2, int n) 
+{
+    if (n != 0) {
+               const unsigned char *s1=v1, *s2=v2;
+        do {
+            if (*s1++ != *s2++)
+                return (*--s1 - *--s2);
+        } while (--n != 0);
+    }
+    return (0);
+} 
diff --git a/libraries/liblutil/nt_err.c b/libraries/liblutil/nt_err.c
new file mode 100644 (file)
index 0000000..6d119d2
--- /dev/null
@@ -0,0 +1,108 @@
+/* $OpenLDAP$ */
+#include "portable.h"
+
+#ifdef HAVE_WINSOCK2
+#include <winsock2.h>
+
+#define __RETSTR( x ) case x: return #x;
+
+char *WSAGetErrorString( int err )
+{
+       switch( err )
+       {
+               __RETSTR( WSAEINTR )
+               __RETSTR( WSAEBADF )
+               __RETSTR( WSAEACCES )
+               __RETSTR( WSAEFAULT )
+               __RETSTR( WSAEINVAL )
+               __RETSTR( WSAEMFILE )
+               __RETSTR( WSAEWOULDBLOCK )
+               __RETSTR( WSAEINPROGRESS )
+               __RETSTR( WSAEALREADY )
+               __RETSTR( WSAENOTSOCK )
+               __RETSTR( WSAEDESTADDRREQ )
+               __RETSTR( WSAEMSGSIZE )
+               __RETSTR( WSAEPROTOTYPE )
+               __RETSTR( WSAENOPROTOOPT )
+               __RETSTR( WSAEPROTONOSUPPORT )
+               __RETSTR( WSAESOCKTNOSUPPORT )
+               __RETSTR( WSAEOPNOTSUPP )
+               __RETSTR( WSAEPFNOSUPPORT )
+               __RETSTR( WSAEAFNOSUPPORT )
+               __RETSTR( WSAEADDRINUSE )
+               __RETSTR( WSAEADDRNOTAVAIL )
+               __RETSTR( WSAENETDOWN )
+               __RETSTR( WSAENETUNREACH )
+               __RETSTR( WSAENETRESET )
+               __RETSTR( WSAECONNABORTED )
+               __RETSTR( WSAECONNRESET )
+               __RETSTR( WSAENOBUFS )
+               __RETSTR( WSAEISCONN )
+               __RETSTR( WSAENOTCONN )
+               __RETSTR( WSAESHUTDOWN )
+               __RETSTR( WSAETOOMANYREFS )
+               __RETSTR( WSAETIMEDOUT )
+               __RETSTR( WSAECONNREFUSED )
+               __RETSTR( WSAELOOP )
+               __RETSTR( WSAENAMETOOLONG )
+               __RETSTR( WSAEHOSTDOWN )
+               __RETSTR( WSAEHOSTUNREACH )
+               __RETSTR( WSAENOTEMPTY )
+               __RETSTR( WSAEPROCLIM )
+               __RETSTR( WSAEUSERS )
+               __RETSTR( WSAEDQUOT )
+               __RETSTR( WSAESTALE )
+               __RETSTR( WSAEREMOTE )
+               __RETSTR( WSASYSNOTREADY )
+               __RETSTR( WSAVERNOTSUPPORTED )
+               __RETSTR( WSANOTINITIALISED )
+               __RETSTR( WSAEDISCON )
+               __RETSTR( WSAENOMORE )
+               __RETSTR( WSAECANCELLED )
+               __RETSTR( WSAEINVALIDPROCTABLE )
+               __RETSTR( WSAEINVALIDPROVIDER )
+               __RETSTR( WSASYSCALLFAILURE )
+               __RETSTR( WSASERVICE_NOT_FOUND )
+               __RETSTR( WSATYPE_NOT_FOUND )
+               __RETSTR( WSA_E_NO_MORE )
+               __RETSTR( WSA_E_CANCELLED )
+               __RETSTR( WSAEREFUSED )
+
+               __RETSTR( WSAHOST_NOT_FOUND )
+               __RETSTR( WSATRY_AGAIN )
+               __RETSTR( WSANO_RECOVERY )
+               __RETSTR( WSANO_DATA )
+       }
+       return "unknown";
+}
+
+char *WSAGetLastErrorString( void )
+{
+       return WSAGetErrorString( WSAGetLastError() );
+}
+
+#undef __RETSTR
+
+#endif /* HAVE_WINSOCK2 */
+
+
+char *GetErrorString( int err )
+{
+       static char msgBuf[1024];
+
+       FormatMessage(
+               FORMAT_MESSAGE_FROM_SYSTEM,
+               NULL,
+               err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+               msgBuf, 1024, NULL );
+
+       return msgBuf;
+}
+
+char *GetLastErrorString( void )
+{
+       return GetErrorString( GetLastError() );
+}
+
+
+
index 57ab8c89f950c0ea75af7710be17b037c5ed6fef..e1554a5cb46bf547f7cd69105cd904487e33965c 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 8fc16c2a01abcfe77be69fd3dcdb458f9a9dbfb5..d350770ef94e47d5497d383776efb88618423306 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
diff --git a/libraries/liblutil/setproctitle.c b/libraries/liblutil/setproctitle.c
new file mode 100644 (file)
index 0000000..6d1ab6a
--- /dev/null
@@ -0,0 +1,73 @@
+/* $OpenLDAP$ */
+#include "portable.h"
+
+#ifndef HAVE_SETPROCTITLE
+
+#include <stdio.h>
+
+#include <ac/stdlib.h>
+
+#include <ac/setproctitle.h>
+#include <ac/string.h>
+#include <ac/stdarg.h>
+
+/*
+ * Copyright (c) 1990,1991 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.
+ */
+
+char   **Argv;         /* pointer to original (main's) argv */
+int    Argc;           /* original argc */
+
+/*
+ * takes a printf-style format string (fmt) and up to three parameters (a,b,c)
+ * this clobbers the original argv...
+ */
+
+/* VARARGS */
+void setproctitle( const char *fmt, ... )
+{
+       static char *endargv = (char *)0;
+       char    *s;
+       int             i;
+       char    buf[ 1024 ];
+       va_list ap;
+
+       va_start(ap, fmt);
+
+#ifdef HAVE_VSNPRINTF
+       buf[sizeof(buf) - 1] = '\0';
+       vsnprintf( buf, sizeof(buf)-1, fmt, ap );
+#elif HAVE_VPRINTF
+       vsprintf( buf, fmt, ap ); /* hope it's not too long */
+#else
+       /* use doprnt() */
+       chokeme = "choke me!  I don't have a doprnt() manual handy";
+#endif
+
+       va_end(ap);
+
+       if ( endargv == (char *)0 ) {
+               /* set pointer to end of original argv */
+               endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] );
+       }
+       /* make ps print "([prog name])" */
+       s = Argv[0];
+       *s++ = '-';
+       i = strlen( buf );
+       if ( i > endargv - s - 2 ) {
+               i = endargv - s - 2;
+               buf[ i ] = '\0';
+       }
+       strcpy( s, buf );
+       s += i;
+       while ( s < endargv ) *s++ = ' ';
+}
+#endif /* NOSETPROCTITLE */
index bdaafda16288b7f88288595ce57709f3f7692562..f8c38a1a66501eb2b14b9f8f44e8ff4b1815f95f 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
diff --git a/libraries/liblutil/sockpair.c b/libraries/liblutil/sockpair.c
new file mode 100644 (file)
index 0000000..39bcde0
--- /dev/null
@@ -0,0 +1,62 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
+#include <lutil.h>
+
+/* Return a pair of socket descriptors that are connected to each other.
+ * The returned descriptors are suitable for use with select(). The two
+ * descriptors may or may not be identical; the function may return
+ * the same descriptor number in both slots. It is guaranteed that
+ * data written on sds[1] will be readable on sds[0]. The returned
+ * descriptors may be datagram oriented, so data should be written
+ * in reasonably small pieces and read all at once. On Unix systems
+ * this function is best implemented using a single pipe() call.
+ */
+
+int lutil_pair( LBER_SOCKET_T sds[2] )
+{
+#ifdef USE_PIPE
+       return pipe( sds );
+#else
+       struct sockaddr_in si;
+       int rc, len = sizeof(si);
+       LBER_SOCKET_T sd;
+
+       sd = socket( AF_INET, SOCK_DGRAM, 0 );
+       if ( sd == AC_SOCKET_INVALID )
+               return sd;
+       
+       (void) memset( (void*) &si, 0, len );
+       si.sin_family = AF_INET;
+       si.sin_port = 0;
+       si.sin_addr.s_addr = htonl( INADDR_LOOPBACK );
+
+       rc = bind( sd, (struct sockaddr *)&si, len );
+       if ( rc == AC_SOCKET_ERROR ) {
+               tcp_close(sd);
+               return rc;
+       }
+
+       rc = getsockname( sd, (struct sockaddr *)&si, &len );
+       if ( rc == AC_SOCKET_ERROR ) {
+               tcp_close(sd);
+               return rc;
+       }
+
+       rc = connect( sd, (struct sockaddr *)&si, len );
+       if ( rc == AC_SOCKET_ERROR ) {
+               tcp_close(sd);
+               return rc;
+       }
+
+       sds[0] = sds[1] = sd;
+       return 0;
+#endif
+}
diff --git a/libraries/liblutil/tempnam.c b/libraries/liblutil/tempnam.c
new file mode 100644 (file)
index 0000000..024f1fd
--- /dev/null
@@ -0,0 +1,46 @@
+/* $OpenLDAP$ */
+#include "portable.h"
+
+#ifndef HAVE_TEMPNAM
+
+#include <stdio.h>
+
+#include <ac/stdlib.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#include "lutil.h"
+
+char *
+(tempnam)( const char *dir, const char *pfx )
+{
+    char       *s;
+
+    if ( dir == NULL ) {
+       dir = "/tmp";
+    }
+
+/*
+ * allocate space for dir + '/' + pfx (up to 5 chars) + 6 trailing 'X's + 0 byte
+ */
+    if (( s = (char *)malloc( strlen( dir ) + 14 )) == NULL ) {
+       return( NULL );
+    }
+
+    strcpy( s, dir );
+    strcat( s, "/" );
+    if ( pfx != NULL ) {
+       strcat( s, pfx );
+    }
+    strcat( s, "XXXXXX" );
+    mktemp( s );
+
+    if ( *s == '\0' ) {
+       free( s );
+       s = NULL;
+    }
+
+    return( s );
+}
+
+#endif /* TEMPNAM */
index 8bd298facfceadf7632c1da70d39c4eb82fa6a92..0f0f3704a2b7d7138fca3fce03b9d2af2d33e8f4 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 3fa1332f8b5f6e70a113cda68c562c01307f9445..9cf821cda514b9e62ffc752f9bde648084067d71 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
 ## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 ##
index 05744d04cad145895dba9de03dee5e776d7dcebe..8752f3f40c41c2617c38bd56a4b31d51264aea6c 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ##
 ## Makefile.in for slapd
 ##
index 0d312091483d6a302152836eff29a66337a5416c..3340bc70f7b69308aad7b8e45fa7737037ed5052 100644 (file)
@@ -1,4 +1,5 @@
 /* abandon.c - decode and handle an ldap abandon operation */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -99,7 +100,7 @@ done:
        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
 
        Debug( LDAP_DEBUG_TRACE, "do_abandon: op=%ld %sfound\n",
-               id, notfound ? "not " : "", 0 );
+              (long) id, notfound ? "not " : "", 0 );
 
        return LDAP_SUCCESS;
 }
index 76e54530c6ad935ab5b476facf5778b05f7b7f9f..99b42832666cfed348a92eb0fac644ac35c7320b 100644 (file)
@@ -1,4 +1,5 @@
 /* acl.c - routines to parse and check acl's */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 
 #include "slap.h"
 
+#ifdef SLAPD_ACI_ENABLED
+int aci_access_allowed (struct berval *aci, char *attr, Backend *be, Entry *e,
+                                       Operation *op, int access, char *edn, regmatch_t *matches);
+#endif
+
 static int     regex_matches(char *pat, char *str, char *buf, regmatch_t *matches);
 static void    string_expand(char *newbuf, int bufsiz, char *pattern,
                              char *match, regmatch_t *matches);
@@ -83,7 +89,7 @@ access_allowed(
                }
        }
 
-       rc = acl_access_allowed( a, be, conn, e, val, op, access, edn, matches );
+       rc = acl_access_allowed( a, attr, be, conn, e, val, op, access, edn, matches );
 
        Debug( LDAP_DEBUG_ACL, "\n=> access_allowed: exit (%s) attr (%s)\n",
                e->e_dn, attr, 0);
@@ -208,6 +214,7 @@ acl_get_applicable(
 int
 acl_access_allowed(
     AccessControl      *a,
+    char               *attr,
     Backend            *be,
     Connection         *conn,
     Entry              *e,
@@ -376,6 +383,52 @@ acl_access_allowed(
                        }
                }
 
+#ifdef SLAPD_ACI_ENABLED
+               if ( b->a_aci_at != NULL ) {                            
+                       Attribute       *at;
+
+                       /* this case works different from the others above.
+                        * since aci's themselves give permissions, we need
+                        * to first check b->a_access, the ACL's access level.
+                        */
+
+                       if( op->o_ndn == NULL || op->o_ndn[0] == '\0' ) {
+                               continue;
+                       }
+
+                       if ( e->e_dn == NULL ) {
+                               continue;
+                       }
+
+                       /* first check if the right being requested is
+                        * higher than allowed by the ACL clause.
+                        */
+                       if ( ! ACL_GRANT( b->a_access, access ) ) {
+                               continue;
+                       }
+
+                       /* get the aci attribute */
+                       at = attr_find( e->e_attrs, b->a_aci_at );
+                       if ( at == NULL ) {
+                               continue;
+                       }
+
+                       /* the aci is an multi-valued attribute.  The
+                        * rights are determined by OR'ing the individual
+                        * rights given by the acis.
+                        */
+                       for ( i = 0; at->a_vals[i] != NULL; i++ ) {
+                               if ( aci_access_allowed( at->a_vals[i], attr, be, e, op, access, edn, matches ) ) {
+                                       Debug( LDAP_DEBUG_ACL,
+                                               "<= acl_access_allowed: matched by clause #%d access granted\n",
+                                               i, 0, 0 );
+                                       return(1);
+                               }
+                       }
+                       continue;
+               }
+#endif
+
                Debug( LDAP_DEBUG_ACL,
                        "<= acl_access_allowed: matched by clause #%d access %s\n",
                        i,
@@ -433,7 +486,7 @@ acl_check_modlist(
                                break;
                        }
                        for ( i = 0; mlist->ml_bvalues[i] != NULL; i++ ) {
-                               if ( ! acl_access_allowed( a, be, conn, e, mlist->ml_bvalues[i], 
+                               if ( ! acl_access_allowed( a, mlist->ml_type, be, conn, e, mlist->ml_bvalues[i], 
                                        op, ACL_WRITE, edn, matches) ) 
                                {
                                        return( LDAP_INSUFFICIENT_ACCESS );
@@ -443,7 +496,7 @@ acl_check_modlist(
 
                case LDAP_MOD_DELETE:
                        if ( mlist->ml_bvalues == NULL ) {
-                               if ( ! acl_access_allowed( a, be, conn, e,
+                               if ( ! acl_access_allowed( a, mlist->ml_type, be, conn, e,
                                        NULL, op, ACL_WRITE, edn, matches) ) 
                                {
                                        return( LDAP_INSUFFICIENT_ACCESS );
@@ -451,7 +504,7 @@ acl_check_modlist(
                                break;
                        }
                        for ( i = 0; mlist->ml_bvalues[i] != NULL; i++ ) {
-                               if ( ! acl_access_allowed( a, be, conn, e, mlist->ml_bvalues[i], 
+                               if ( ! acl_access_allowed( a, mlist->ml_type, be, conn, e, mlist->ml_bvalues[i], 
                                        op, ACL_WRITE, edn, matches) ) 
                                {
                                        return( LDAP_INSUFFICIENT_ACCESS );
@@ -464,6 +517,333 @@ acl_check_modlist(
        return( LDAP_SUCCESS );
 }
 
+#ifdef SLAPD_ACI_ENABLED
+static char *
+aci_bvstrdup (struct berval *bv)
+{
+       char *s;
+
+       s = (char *)ch_malloc(bv->bv_len + 1);
+       if (s != NULL) {
+               memcpy(s, bv->bv_val, bv->bv_len);
+               s[bv->bv_len] = 0;
+       }
+       return(s);
+}
+
+static int
+aci_strbvcmp (char *s, struct berval *bv)
+{
+       int res, len;
+
+       res = strncasecmp( s, bv->bv_val, bv->bv_len );
+       if (res)
+               return(res);
+       len = strlen(s);
+       if (len > bv->bv_len)
+               return(1);
+       if (len < bv->bv_len)
+               return(-1);
+       return(0);
+}
+
+static int
+aci_get_part (struct berval *list, int ix, char sep, struct berval *bv)
+{
+       int len;
+       char *p;
+
+       if (bv) {
+               bv->bv_len = 0;
+               bv->bv_val = NULL;
+       }
+       len = list->bv_len;
+       p = list->bv_val;
+       while (len >= 0 && --ix >= 0) {
+               while (--len >= 0 && *p++ != sep) ;
+       }
+       while (len >= 0 && *p == ' ') {
+               len--;
+               p++;
+       }
+       if (len < 0)
+               return(-1);
+
+       if (!bv)
+               return(0);
+
+       bv->bv_val = p;
+       while (--len >= 0 && *p != sep) {
+               bv->bv_len++;
+               p++;
+       }
+       while (bv->bv_len > 0 && *--p == ' ')
+               bv->bv_len--;
+       return(bv->bv_len);
+}
+
+static int
+aci_list_has_right (struct berval *list, int access, int action)
+{
+       struct berval bv;
+       int i, right;
+
+       for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) {
+               if (bv.bv_len <= 0)
+                       continue;
+               switch (*bv.bv_val) {
+               case 'c':
+                       right = ACL_COMPARE;
+                       break;
+               case 's':
+                       /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt defines
+                        * the right 's' to mean "set", but in the examples states
+                        * that the right 's' means "search".  The latter definition
+                        * is used here.
+                        */
+                       right = ACL_SEARCH;
+                       break;
+               case 'r':
+                       right = ACL_READ;
+                       break;
+               case 'w':
+                       right = ACL_WRITE;
+                       break;
+               case 'x':
+                       /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt does not 
+                        * define any equivalent to the AUTH right, so I've just used
+                        * 'x' for now.
+                        */
+                       right = ACL_AUTH;
+                       break;
+               default:
+                       right = 0;
+                       break;
+               }
+#ifdef SLAPD_ACI_DISCRETE_RIGHTS
+               if (right & access) {
+                       return(action);
+               }
+       }
+       return(!action);
+#else
+               if (action != 0) {
+                       /* check granted */
+                       if (ACL_GRANT(right, access))
+                               return(1);
+               } else {
+                       /* check denied */
+                       if (right <= access)
+                               return(1);
+               }
+       }
+       return(0);
+#endif
+}
+
+static int
+aci_list_has_attr (struct berval *list, char *attr)
+{
+       struct berval bv;
+       int i;
+
+       for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) {
+               if (aci_strbvcmp(attr, &bv) == 0) {
+                       return(1);
+               }
+       }
+       return(0);
+}
+
+static int
+aci_list_has_attr_right (struct berval *list, char *attr, int access, int action)
+{
+    struct berval bv;
+    int i, found;
+
+       /* loop through each rights/attr pair, skip first part (action) */
+       found = -1;
+       for (i = 1; aci_get_part(list, i + 1, ';', &bv) >= 0; i += 2) {
+               if (aci_list_has_attr(&bv, attr) == 0)
+                       continue;
+               found = 0;
+               if (aci_get_part(list, i, ';', &bv) < 0)
+                       continue;
+               if (aci_list_has_right(&bv, access, action) != 0)
+                       return(1);
+       }
+       return(found);
+}
+
+static int
+aci_list_has_permission (struct berval *list, char *attr, int access)
+{
+    struct berval perm, actn;
+    int i, action, specific, general;
+
+       if (attr == NULL || *attr == 0 || strcasecmp(attr, "entry") == 0) {
+               attr = "[entry]";
+       }
+
+       /* loop through each permissions clause */
+       for (i = 0; aci_get_part(list, i, '$', &perm) >= 0; i++) {
+               if (aci_get_part(&perm, 0, ';', &actn) < 0)
+                       continue;
+               if (aci_strbvcmp( "grant", &actn ) == 0) {
+                       action = 1;
+               } else if (aci_strbvcmp( "deny", &actn ) == 0) {
+                       action = 0;
+               } else {
+                       continue;
+               }
+
+               specific = aci_list_has_attr_right(&perm, attr, access, action);
+               if (specific >= 0)
+                       return(specific);
+
+               general = aci_list_has_attr_right(&perm, "[all]", access, action);
+               if (general >= 0)
+                       return(general);
+       }
+       return(0);
+}
+
+static int
+aci_group_member (
+       struct berval *subj,
+       char *grpoc,
+       char *grpat,
+    Backend            *be,
+    Entry              *e,
+    Operation          *op,
+       char            *edn,
+       regmatch_t      *matches
+)
+{
+       struct berval bv;
+       char *subjdn, *grpdn;
+       int rc = 0;
+
+       /* format of string is "group/objectClassValue/groupAttrName" */
+       if (aci_get_part(subj, 0, '/', &bv) < 0)
+               return(0);
+       subjdn = aci_bvstrdup(&bv);
+       if (subjdn == NULL)
+               return(0);
+
+       if (aci_get_part(subj, 1, '/', &bv) < 0)
+               grpoc = ch_strdup(grpoc);
+       else
+               grpoc = aci_bvstrdup(&bv);
+
+       if (aci_get_part(subj, 2, '/', &bv) < 0)
+               grpat = ch_strdup(grpat);
+       else
+               grpat = aci_bvstrdup(&bv);
+
+       grpdn = (char *)ch_malloc(1024);
+       if (grpoc != NULL && grpat != NULL && grpdn != NULL) {
+               string_expand(grpdn, 1024, subjdn, edn, matches);
+               if ( dn_normalize_case(grpdn) != NULL ) {
+                       rc = (backend_group(be, e, grpdn, op->o_ndn, grpoc, grpat) == 0);
+               }
+               ch_free(grpdn);
+       }
+       if (grpat != NULL)
+               ch_free(grpat);
+       if (grpoc != NULL)
+               ch_free(grpoc);
+       ch_free(subjdn);
+       return(rc);
+}
+
+int
+aci_access_allowed (
+    struct berval      *aci,
+    char                       *attr,
+    Backend                    *be,
+    Entry                      *e,
+    Operation          *op,
+    int                                access,
+       char                    *edn,
+       regmatch_t              *matches
+)
+{
+    struct berval bv, perms, sdn;
+    char *subjdn;
+       int rc;
+
+       Debug( LDAP_DEBUG_ACL,
+               "\n=> aci_access_allowed: %s access to entry \"%s\"\n",
+               access2str( access ), e->e_dn, 0 );
+
+       Debug( LDAP_DEBUG_ACL,
+               "\n=> aci_access_allowed: %s access to attribute \"%s\" by \"%s\"\n",
+           access2str( access ),
+               attr,
+               op->o_ndn ? op->o_ndn : "" );
+
+       /* parse an aci of the form:
+               oid#scope#action;rights;attr;rights;attr$action;rights;attr;rights;attr#dnType#subjectDN
+
+          See draft-ietf-ldapext-aci-model-0.3.txt section 9.1 for
+          a full description of the format for this attribute.
+
+          For now, this routine only supports scope=entry.
+        */
+
+       /* check that the aci has all 5 components */
+       if (aci_get_part(aci, 4, '#', NULL) < 0)
+               return(0);
+
+       /* check that the scope is "entry" */
+       if (aci_get_part(aci, 1, '#', &bv) < 0
+               || aci_strbvcmp( "entry", &bv ) != 0)
+       {
+               return(0);
+       }
+
+       /* get the list of permissions clauses, bail if empty */
+       if (aci_get_part(aci, 2, '#', &perms) <= 0)
+               return(0);
+
+       /* check if any permissions allow desired access */
+       if (aci_list_has_permission(&perms, attr, access) == 0)
+               return(0);
+
+       /* see if we have a DN match */
+       if (aci_get_part(aci, 3, '#', &bv) < 0)
+               return(0);
+
+       if (aci_get_part(aci, 4, '#', &sdn) < 0)
+               return(0);
+       if (aci_strbvcmp( "access-id", &bv ) == 0) {
+               subjdn = aci_bvstrdup(&sdn);
+               if (subjdn == NULL)
+                       return(0);
+               rc = 0;
+               if (dn_normalize_case(subjdn) != NULL)
+                       rc = (strcasecmp(op->o_ndn, subjdn) == 0);
+               ch_free(subjdn);
+               return(rc);
+       }
+
+       if (aci_strbvcmp( "self", &bv ) == 0) {
+               return(strcasecmp(op->o_ndn, edn) == 0);
+       }
+
+       if (aci_strbvcmp( "group", &bv ) == 0) {
+               return(aci_group_member(&sdn, "groupOfNames", "member", be, e, op, edn, matches));
+       }
+
+       if (aci_strbvcmp( "role", &bv ) == 0) {
+               return(aci_group_member(&sdn, "organizationalRole", "roleOccupant", be, e, op, edn, matches));
+       }
+
+       return(0);
+}
+#endif /* SLAPD_ACI_ENABLED */
+
 static void
 string_expand(
        char *newbuf,
index f31993f2d2c3321dd1a634d37b9f79e206e3cc10..a1345069089da7475d18e452ab64983a2f2d8650 100644 (file)
@@ -1,4 +1,5 @@
 /* acl.c - routines to parse and check acl's */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 static void            split(char *line, int splitchar, char **left, char **right);
 static void            acl_append(AccessControl **l, AccessControl *a);
 static void            access_append(Access **l, Access *a);
-static void            acl_usage(void);
+static void            acl_usage(void) LDAP_GCCATTR((noreturn));
 #ifdef LDAP_DEBUG
 static void            print_acl(AccessControl *a);
 static void            print_access(Access *b);
 #endif
 
 static int
-regtest(char *fname, int lineno, char *pat) {
+regtest(const char *fname, int lineno, char *pat) {
        int e;
        regex_t re;
 
@@ -64,7 +65,7 @@ regtest(char *fname, int lineno, char *pat) {
        if ( size >= (sizeof(buf)-1) ) {
                fprintf( stderr,
                        "%s: line %d: regular expression \"%s\" too large\n",
-                       fname, lineno, pat, 0 );
+                       fname, lineno, pat );
                acl_usage();
        }
 
@@ -84,7 +85,7 @@ regtest(char *fname, int lineno, char *pat) {
 void
 parse_acl(
     Backend    *be,
-    char       *fname,
+    const char *fname,
     int                lineno,
     int                argc,
     char       **argv
@@ -106,6 +107,11 @@ parse_acl(
                                acl_usage();
                        }
                        a = (AccessControl *) ch_calloc( 1, sizeof(AccessControl) );
+                       a->acl_filter = NULL;
+                       a->acl_dn_pat = NULL;
+                       a->acl_attrs  = NULL;
+                       a->acl_access = NULL;
+                       a->acl_next   = NULL;
                        for ( ++i; i < argc; i++ ) {
                                if ( strcasecmp( argv[i], "by" ) == 0 ) {
                                        i--;
@@ -135,20 +141,7 @@ parse_acl(
                                        }
 
                                } else if ( strcasecmp( left, "dn" ) == 0 ) {
-                                       int e;
-
-                                       if ((e = regcomp(&a->acl_dn_re, right,
-                                               REG_EXTENDED|REG_ICASE))) {
-                                               char buf[512];
-                                               regerror(e, &a->acl_dn_re, buf, sizeof(buf));
-                                               fprintf( stderr,
-                               "%s: line %d: regular expression \"%s\" bad because of %s\n",
-                                                       fname, lineno, right, buf );
-                                               acl_usage();
-
-                                       } else {
                                                a->acl_dn_pat = ch_strdup( right );
-                                       }
 
                                } else if ( strncasecmp( left, "attr", 4 ) == 0 ) {
                                        char    **alist;
@@ -165,6 +158,19 @@ parse_acl(
                                }
                        }
 
+                       if ( a->acl_dn_pat != NULL ) {
+                               int e = regcomp( &a->acl_dn_re, a->acl_dn_pat,
+                                                REG_EXTENDED | REG_ICASE );
+                               if ( e ) {
+                                       char buf[512];
+                                       regerror( e, &a->acl_dn_re, buf, sizeof(buf) );
+                                       fprintf( stderr,
+                               "%s: line %d: regular expression \"%s\" bad because of %s\n",
+                                                fname, lineno, right, buf );
+                                       acl_usage();
+                               }
+                       }
+
                /* by clause - select who has what access to entries */
                } else if ( strcasecmp( argv[i], "by" ) == 0 ) {
                        if ( a == NULL ) {
@@ -321,6 +327,23 @@ parse_acl(
                                        continue;
                                }
 
+#ifdef SLAPD_ACI_ENABLED
+                               if ( strcasecmp( left, "aci" ) == 0 ) {
+                                       if( b->a_aci_at != NULL ) {
+                                               fprintf( stderr,
+                                                       "%s: line %d: aci attribute already specified.\n",
+                                                       fname, lineno );
+                                               acl_usage();
+                                       }
+
+                                       if ( right != NULL && *right != '\0' )
+                                               b->a_aci_at = ch_strdup( right );
+                                       else
+                                               b->a_aci_at = ch_strdup( SLAPD_ACI_DEFAULT_ATTR );
+                                       continue;
+                               }
+#endif
+
                                /* get <access> */
                                if ( ACL_IS_INVALID(ACL_SET(b->a_access, str2access( left ))) ) {
                                        fprintf( stderr,
@@ -441,6 +464,9 @@ acl_usage( void )
                        "\t[group[/<objectclass>[/<attrname>]]=<regex>]\n"
                        "\t[peername=<regex>] [sockname=<regex>]\n"
                        "\t[domain=<regex>] [sockurl=<regex>]\n"
+#ifdef SLAPD_ACI_ENABLED
+                       "\t[aci=<attrname>]\n"
+#endif
                "<access> ::= [self]{none|auth|compare|search|read|write}\n"
                );
        exit( EXIT_FAILURE );
@@ -528,6 +554,12 @@ print_access( Access *b )
                fprintf( stderr, " sockurl=%s", b->a_sockurl_pat );
        }
 
+#ifdef SLAPD_ACI_ENABLED
+       if ( b->a_aci_at != NULL ) {
+               fprintf( stderr, " aci=%s", b->a_aci_at );
+       }
+#endif
+
        fprintf( stderr, "\n" );
 }
 
index 1d37dad4e35cc0ab3fcab2d781754ae798cd7f39..388ad9d629960ca608cca10e26f7600babd74cc6 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -145,6 +146,15 @@ do_add( Connection *conn, Operation *op )
                return rc;
        }
 
+       if ( global_readonly || be->be_readonly ) {
+               Debug( LDAP_DEBUG_ANY, "do_add: database is read-only\n",
+                      0, 0, 0 );
+               entry_free( e );
+               send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
+                                 NULL, "database is read-only", NULL, NULL );
+               return LDAP_UNWILLING_TO_PERFORM;
+       }
+
        /*
         * do the add if 1 && (2 || 3)
         * 1) there is an add function implemented in this backend;
index 74e5c241c5d5efb2e8e66b300375bac690eb5556..8a5f5358cb2f8d263937370fe0bdf455da94dbef 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -22,7 +23,7 @@
 #include <sys/param.h>
 #endif
 
-#include "ldap_defaults.h"
+#include "ldap_pvt.h"
 #include "slap.h"
 
 #ifdef LDAP_DEBUG
@@ -67,6 +68,8 @@ Attribute *attr_dup( Attribute *a )
 
                for( i=0; a->a_vals[i] != NULL; i++ ) {
                        tmp->a_vals[i] = ber_bvdup( a->a_vals[i] );
+
+                       if( tmp->a_vals[i] == NULL ) break;
                }
 
                tmp->a_vals[i] = NULL;
@@ -109,7 +112,7 @@ attr_normalize( char *s )
 {
        assert( s != NULL );
 
-       return( str2lower( s ) );
+       return( ldap_pvt_str2lower( s ) );
 }
 
 /*
@@ -191,7 +194,7 @@ attr_merge(
 Attribute *
 attr_find(
     Attribute  *a,
-    char       *type
+    const char *type
 )
 {
        for ( ; a != NULL; a = a->a_next ) {
@@ -213,7 +216,7 @@ attr_find(
 int
 attr_delete(
     Attribute  **attrs,
-    char       *type
+    const char *type
 )
 {
        Attribute       **a;
@@ -261,7 +264,7 @@ attr_syntax( char *type )
 
 void
 attr_syntax_config(
-    char       *fname,
+    const char *fname,
     int                lineno,
     int                argc,
     char       **argv
@@ -693,8 +696,8 @@ at_schema_info( Entry *e )
                val.bv_val = ldap_attributetype2str( &at->sat_atype );
                if ( val.bv_val ) {
                        val.bv_len = strlen( val.bv_val );
-                       Debug( LDAP_DEBUG_TRACE, "Merging at [%d] %s\n",
-                              val.bv_len, val.bv_val, 0 );
+                       Debug( LDAP_DEBUG_TRACE, "Merging at [%ld] %s\n",
+                              (long) val.bv_len, val.bv_val, 0 );
                        attr_merge( e, "attributeTypes", vals );
                        ldap_memfree( val.bv_val );
                } else {
index dcb4ba8d7b46829a5620589421575cf865efc049..b3f314050abd88193ed4196eba1acfdf06485ff3 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 08e30bea3458aa2eedd49126fb03be14351edda4..fd25b63bcb8eb26eca4913c14e4c87e1186be454 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 SRCS   = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c id2entry.c \
                index.c id2children.c nextid.c abandon.c compare.c group.c \
                modify.c modrdn.c delete.c init.c config.c bind.c attr.c \
diff --git a/servers/slapd/back-bdb2/abandon.c b/servers/slapd/back-bdb2/abandon.c
new file mode 100644 (file)
index 0000000..a062487
--- /dev/null
@@ -0,0 +1,47 @@
+/* abandon.c - ldbm backend abandon routine */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+
+
+/*ARGSUSED*/
+static int
+bdb2i_back_abandon_internal(
+       BackendDB    *be,
+       Connection *c,
+       Operation  *o,
+       int        msgid )
+{
+       return 0;
+}
+
+
+int
+bdb2_back_abandon(
+       BackendDB    *be,
+       Connection *conn,
+       Operation  *op,
+       int        msgid )
+{
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( be->bd_info, &time1 );
+
+       ret = bdb2i_back_abandon_internal( be, conn, op, msgid );
+
+       bdb2i_stop_timing( be->bd_info, time1, "ABND", conn, op );
+
+       return( ret );
+}
+
+
index 7324cc2e137b25ce3428b848d72093d9f5f7bde7..b72dc515129b92902ca5bb7ada826df9d115f6b5 100644 (file)
@@ -1,4 +1,5 @@
 /* add.c - ldap bdb2 back-end add routine */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
@@ -243,7 +244,7 @@ bdb2i_back_add_internal(
        if ( bdb2i_id2entry_add( be, e ) != 0 ) {
                Debug( LDAP_DEBUG_TRACE, "bdb2i_id2entry_add failed\n", 0,
                    0, 0 );
-               (void) bdb2i_dn2id_delete( be, e->e_ndn );
+               (void) bdb2i_dn2id_delete( be, e->e_ndn, e->e_id );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
                        NULL, NULL, NULL, NULL );
 
diff --git a/servers/slapd/back-bdb2/alias.c b/servers/slapd/back-bdb2/alias.c
new file mode 100644 (file)
index 0000000..3de54b9
--- /dev/null
@@ -0,0 +1,285 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/string.h>
+#include <ac/socket.h>
+#include "slap.h"
+#include "back-bdb2.h"
+#include "proto-back-bdb2.h"
+
+static char* get_alias_dn(
+       Entry *e,
+       int *err,
+       char **errmsg );
+
+static char* new_superior(
+       char *dn,
+       char *oldSup,
+       char *newSup );
+
+static int dnlist_subordinate(
+       char** dnlist,
+       char *dn );
+
+Entry *bdb2i_deref_r(
+       Backend*        be,
+       Entry*          alias,
+       char*           dn,
+       int*            err,
+       Entry**         matched,
+       char**          text )
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       Entry *entry;
+       Entry *sup;
+       unsigned depth;
+       char **dnlist;
+
+       assert( ( alias != NULL && dn == NULL ) || ( alias == NULL && dn != NULL ) );
+
+       *matched = NULL;
+       *err = LDAP_SUCCESS;
+       *text = NULL;
+
+       if( alias == NULL ) {
+               dn = ch_strdup( dn );
+               entry = bdb2i_dn2entry_r( be, dn, &sup );
+
+       } else {
+               dn = ch_strdup( alias->e_ndn );
+               entry = alias;
+               sup = NULL;
+       }
+
+       dnlist = NULL;
+       charray_add( &dnlist, dn );
+
+       for( depth=0 ; ; depth++ ) {
+               if( entry != NULL ) {
+                       Entry *newe;
+                       char *aliasDN;
+
+                       /* have entry, may be an alias */
+
+                       if( !is_entry_alias( entry ) ) {
+                               /* entry is not an alias */
+                               break;
+                       }
+
+                       /* entry is alias */
+                       if( depth > be->be_max_deref_depth ) {
+                               *matched = entry;
+                               entry = NULL;
+                               *err = LDAP_ALIAS_DEREF_PROBLEM;
+                               *text = "maximum deref depth exceeded";
+                               break;
+                       }
+
+                       /* deref entry */
+                       aliasDN = get_alias_dn( entry, err, text );
+
+                       if( aliasDN == NULL ) {
+                               *matched = entry;
+                               entry = NULL;
+                               break;
+                       }
+
+                       /* check if aliasDN is a subordinate of any DN in our list */
+                       if( dnlist_subordinate( dnlist, aliasDN ) ) {
+                               *matched = entry;
+                               entry = NULL;
+                               *err = LDAP_ALIAS_PROBLEM;
+                               *text = "circular alias";
+                               break;
+                       }
+
+                       /* attempt to dereference alias */
+
+                       newe = bdb2i_dn2entry_r( be, aliasDN, &sup );
+
+                       if( newe != NULL ) {
+                               free( dn );
+                               bdb2i_cache_return_entry_r(&li->li_cache, entry );
+                               entry = newe;
+                               dn = ch_strdup( entry->e_ndn );
+                               charray_add( &dnlist, dn );
+                               continue;
+
+                       }
+                       
+                       if ( sup != NULL ) {
+                               bdb2i_cache_return_entry_r(&li->li_cache, entry );
+                               entry = NULL;
+                               continue;
+                       }
+
+                       /* no newe and no superior, we're done */
+                       break;
+
+               } else if( sup != NULL ) {
+                       /* have superior, may be an alias */
+                       Entry *newe;
+                       Entry *newSup;
+                       char *supDN;
+                       char *aliasDN;
+
+                       if( !is_entry_alias( sup ) ) {
+                               /* entry is not an alias */
+                               *matched = sup;
+                               sup = NULL;
+                               break;
+                       }
+
+                       /* entry is alias */
+                       if( depth > be->be_max_deref_depth ) {
+                               *matched = sup;
+                               entry = NULL;
+                               *err = LDAP_ALIAS_DEREF_PROBLEM;
+                               *text = "maximum deref depth exceeded";
+                               break;
+                       }
+
+                       /* deref entry */
+                       supDN = get_alias_dn( sup, err, text );
+
+                       if( supDN == NULL ) {
+                               *matched = sup;
+                               break;
+                       }
+
+                       aliasDN = new_superior( dn, sup->e_ndn, supDN );
+
+                       if( aliasDN == NULL ) {
+                               free(aliasDN);
+                               *matched = sup;
+                               *err = LDAP_ALIAS_PROBLEM;
+                               *text = "superior alias problem";
+                               break;
+                       }
+
+                       /* check if aliasDN is a subordinate of any DN in our list */
+                       if( dnlist_subordinate( dnlist, aliasDN ) ) {
+                               free(aliasDN);
+                               *matched = entry;
+                               entry = NULL;
+                               *err = LDAP_ALIAS_PROBLEM;
+                               *text = "subordinate circular alias";
+                               break;
+                       }
+
+                       /* attempt to dereference alias */
+                       newe = bdb2i_dn2entry_r( be, aliasDN, &newSup );
+
+                       if( newe != NULL ) {
+                               free(aliasDN);
+                               free( dn );
+                               bdb2i_cache_return_entry_r(&li->li_cache, sup );
+                               entry = newe;
+                               dn = ch_strdup( entry->e_ndn );
+                               charray_add( &dnlist, dn );
+                               continue;
+
+                       }
+                       
+                       if ( newSup != NULL ) {
+                               free( dn );
+                               bdb2i_cache_return_entry_r(&li->li_cache, sup );
+                               sup = newSup;
+                               dn = aliasDN;
+                               continue;
+                       }
+
+                       break;
+
+               } else {
+                       /* no newe and no superior, we're done */
+                       break;
+               }
+       }
+
+       free( dn );
+       return entry;
+}
+
+
+static char* get_alias_dn(
+       Entry *e,
+       int *err,
+       char **errmsg )
+{      
+       Attribute *a = attr_find( e->e_attrs, "aliasedobjectname" );
+
+       if( a == NULL ) {
+               /*
+                * there was an aliasedobjectname defined but no data.
+                */
+               *err = LDAP_ALIAS_PROBLEM;
+               *errmsg = "alias missing aliasedObjectName attribute";
+               return NULL;
+       }
+
+       /* 
+        * aliasedObjectName should be SINGLE-VALUED with a single value. 
+        */                     
+       if ( a->a_vals[0] == NULL || a->a_vals[0]->bv_val == NULL ) {
+               /*
+                * there was an aliasedobjectname defined but no data.
+                */
+               *err = LDAP_ALIAS_PROBLEM;
+               *errmsg = "alias missing aliasedObjectName value";
+               return NULL;
+       }
+
+       if( a->a_vals[1] != NULL ) {
+               *err = LDAP_ALIAS_PROBLEM;
+               *errmsg = "alias has multivalued aliasedObjectName";
+               return NULL;
+       }
+
+       return a->a_vals[0]->bv_val;
+}
+
+static char* new_superior(
+       char *dn,
+       char *oldSup,
+       char *newSup )
+{
+       char *newDN;
+       size_t dnlen, olen, nlen;
+       assert( dn && oldSup && newSup );
+
+       dnlen = strlen( dn );
+       olen = strlen( oldSup );
+       nlen = strlen( newSup );
+
+       newDN = ch_malloc( dnlen - olen + nlen + 1 );
+
+       memcpy( newDN, dn, dnlen - olen );
+       memcpy( &newDN[dnlen - olen], newSup, nlen );
+       newDN[dnlen - olen + nlen] = '\0';
+
+       return newDN;
+}
+
+static int dnlist_subordinate(
+       char** dnlist,
+       char *dn )
+{
+       int i;
+       assert( dnlist );
+
+       for( i = 0; dnlist[i] != NULL; i++ ) {
+               if( dn_issuffix( dnlist[i], dn ) ) {
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
diff --git a/servers/slapd/back-bdb2/attr.c b/servers/slapd/back-bdb2/attr.c
new file mode 100644 (file)
index 0000000..7fa5988
--- /dev/null
@@ -0,0 +1,174 @@
+/* attr.c - backend routines for dealing with attributes */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+
+static int
+ainfo_type_cmp(
+    char               *type,
+    struct attrinfo    *a
+)
+{
+       return( strcasecmp( type, a->ai_type ) );
+}
+
+static int
+ainfo_cmp(
+    struct attrinfo    *a,
+    struct attrinfo    *b
+)
+{
+       return( strcasecmp( a->ai_type, b->ai_type ) );
+}
+
+/*
+ * Called when a duplicate "index" line is encountered.
+ *
+ * returns 1 => original from init code, indexmask updated
+ *        2 => original not from init code, warn the user
+ */
+
+static int
+ainfo_dup(
+    struct attrinfo    *a,
+    struct attrinfo    *b
+)
+{
+       /*
+        * if the duplicate definition is because we initialized the attr,
+        * just add what came from the config file. otherwise, complain.
+        */
+       if ( a->ai_indexmask & INDEX_FROMINIT ) {
+               a->ai_indexmask |= b->ai_indexmask;
+
+               return( 1 );
+       }
+
+       return( 2 );
+}
+
+void
+bdb2i_attr_masks(
+    struct ldbminfo    *li,
+    char               *type,
+    int                        *indexmask,
+    int                        *syntaxmask
+)
+{
+       struct attrinfo *a;
+
+       *indexmask = 0;
+       *syntaxmask = 0;
+       if ( (a = (struct attrinfo *) avl_find( li->li_attrs, type,
+           (AVL_CMP) ainfo_type_cmp )) == NULL ) {
+               if ( (a = (struct attrinfo *) avl_find( li->li_attrs, "default",
+                   (AVL_CMP) ainfo_type_cmp )) == NULL ) {
+                       return;
+               }
+       }
+       *indexmask = a->ai_indexmask;
+       if ( strcasecmp( a->ai_type, "default" ) == 0 ) {
+               *syntaxmask = attr_syntax( type );
+       } else {
+               *syntaxmask = a->ai_syntaxmask;
+       }
+}
+
+
+/*  BDB2 changed  */
+void
+bdb2i_attr_index_config(
+    struct ldbminfo    *li,
+    const char         *fname,
+    int                        lineno,
+    int                        argc,
+    char               **argv,
+    int                        init
+)
+{
+       int             i, j;
+       char            **attrs, **indexes;
+       struct attrinfo *a;
+
+       attrs = str2charray( argv[0], "," );
+       if ( argc > 1 ) {
+               indexes = str2charray( argv[1], "," );
+       }
+       for ( i = 0; attrs[i] != NULL; i++ ) {
+               a = (struct attrinfo *) ch_malloc( sizeof(struct attrinfo) );
+               a->ai_type = ch_strdup( attrs[i] );
+               a->ai_syntaxmask = attr_syntax( a->ai_type );
+               if ( argc == 1 ) {
+                       a->ai_indexmask = (INDEX_PRESENCE | INDEX_EQUALITY |
+                           INDEX_APPROX | INDEX_SUB);
+               } else {
+                       a->ai_indexmask = 0;
+                       for ( j = 0; indexes[j] != NULL; j++ ) {
+                               if ( strncasecmp( indexes[j], "pres", 4 )
+                                   == 0 ) {
+                                       a->ai_indexmask |= INDEX_PRESENCE;
+                               } else if ( strncasecmp( indexes[j], "eq", 2 )
+                                   == 0 ) {
+                                       a->ai_indexmask |= INDEX_EQUALITY;
+                               } else if ( strncasecmp( indexes[j], "approx",
+                                   6 ) == 0 ) {
+                                       a->ai_indexmask |= INDEX_APPROX;
+                               } else if ( strncasecmp( indexes[j], "sub", 3 )
+                                   == 0 ) {
+                                       a->ai_indexmask |= INDEX_SUB;
+                               } else if ( strncasecmp( indexes[j], "none", 4 )
+                                   == 0 ) {
+                                       if ( a->ai_indexmask != 0 ) {
+                                               fprintf( stderr,
+"%s: line %d: index type \"none\" cannot be combined with other types\n",
+                                                   fname, lineno );
+                                       }
+                                       a->ai_indexmask = 0;
+                               } else {
+                                       fprintf( stderr,
+                       "%s: line %d: unknown index type \"%s\" (ignored)\n",
+                                           fname, lineno, indexes[j] );
+                                       fprintf( stderr,
+       "valid index types are \"pres\", \"eq\", \"approx\", or \"sub\"\n" );
+                               }
+                       }
+               }
+               if ( init ) {
+                       a->ai_indexmask |= INDEX_FROMINIT;
+               } else {
+                       if ( a->ai_indexmask )
+                               bdb2i_txn_attr_config( li, a->ai_type, 0 );
+               }
+
+               switch (avl_insert( &li->li_attrs, (caddr_t) a,
+                       (AVL_CMP) ainfo_cmp, (AVL_DUP) ainfo_dup ))
+               {
+               case 1:         /* duplicate - updating init version */
+                       free( a->ai_type );
+                       free( (char *) a );
+                       break;
+
+               case 2:         /* user duplicate - ignore and warn */
+                       fprintf( stderr,
+    "%s: line %d: duplicate index definition for attr \"%s\" (ignored)\n",
+                           fname, lineno, a->ai_type );
+                       free( a->ai_type );
+                       free( (char *) a );
+                       break;
+
+               default:;       /* inserted ok */
+                       /* FALL */
+               }
+       }
+       charray_free( attrs );
+       if ( argc > 1 )
+               charray_free( indexes );
+}
index 758318c080772049cc7474f35f362f03a8184034..4ebc54422c467322d91658eb87a83e9731da2ca5 100644 (file)
@@ -1,4 +1,5 @@
 /* back-bdb2.h - ldap bdb2 back-end header file */
+/* $OpenLDAP$ */
 
 #ifndef _BACK_BDB2_H_
 #define _BACK_BDB2_H_
diff --git a/servers/slapd/back-bdb2/bind.c b/servers/slapd/back-bdb2/bind.c
new file mode 100644 (file)
index 0000000..e022a55
--- /dev/null
@@ -0,0 +1,347 @@
+/* bind.c - bdb2 backend bind and unbind routines */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/krb.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+#include "proto-back-bdb2.h"
+
+#include <lutil.h>
+
+#ifdef HAVE_KERBEROS
+extern int     bdb2i_krbv4_ldap_auth();
+#endif
+
+static int
+crypted_value_find(
+       struct berval       **vals,
+       struct berval       *v,
+       int                 syntax,
+       int                 normalize,
+       struct berval           *cred
+)
+{
+       int     i;
+       for ( i = 0; vals[i] != NULL; i++ ) {
+               if ( syntax != SYNTAX_BIN ) {
+                       int result;
+
+#ifdef SLAPD_CRYPT
+                       ldap_pvt_thread_mutex_lock( &crypt_mutex );
+#endif
+
+                       result = lutil_passwd(
+                               (char*) cred->bv_val,
+                               (char*) vals[i]->bv_val,
+                               NULL );
+
+#ifdef SLAPD_CRYPT
+                       ldap_pvt_thread_mutex_unlock( &crypt_mutex );
+#endif
+
+                       return result;
+
+               } else {
+                if ( value_cmp( vals[i], v, syntax, normalize ) == 0 ) {
+                        return( 0 );
+                }
+        }
+       }
+
+       return( 1 );
+}
+
+static int
+bdb2i_back_bind_internal(
+    BackendDB          *be,
+    Connection         *conn,
+    Operation          *op,
+    char               *dn,
+    int                        method,
+       char            *mech,
+    struct berval      *cred,
+       char**  edn
+)
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       Entry           *e;
+       Attribute       *a;
+       int             rc;
+       Entry           *matched;
+#ifdef HAVE_KERBEROS
+       char            krbname[MAX_K_NAME_SZ + 1];
+       AUTH_DAT        ad;
+#endif
+
+       Debug(LDAP_DEBUG_ARGS, "==> bdb2_back_bind: dn: %s\n", dn, 0, 0);
+
+       *edn = NULL;
+
+       /* get entry with reader lock */
+       if ( (e = bdb2i_dn2entry_r( be, dn, &matched )) == NULL ) {
+               char *matched_dn = NULL;
+               struct berval **refs = NULL;
+
+               if ( matched != NULL ) {
+                       matched_dn = ch_strdup( matched->e_dn );
+                       refs = is_entry_referral( matched )
+                               ? get_entry_referrals( be, conn, op, matched )
+                               : NULL;
+                       bdb2i_cache_return_entry_r( &li->li_cache, matched );
+               } else {
+                       refs = default_referral;
+               }
+
+               /* allow noauth binds */
+               rc = 1;
+               if ( method == LDAP_AUTH_SIMPLE ) {
+                       if( cred->bv_len == 0 ) {
+                               /* SUCCESS */
+                               send_ldap_result( conn, op, LDAP_SUCCESS,
+                                       NULL, NULL, NULL, NULL );
+
+                       } else if ( be_isroot_pw( be, dn, cred ) ) {
+                               /* front end will send result */
+                               *edn = ch_strdup( be_root_dn( be ) );
+                               rc = 0;
+
+                       } else {
+                               send_ldap_result( conn, op, LDAP_REFERRAL,
+                                       matched_dn, NULL, refs, NULL );
+                       }
+
+               } else if ( method == LDAP_AUTH_SASL ) {
+                       if( mech != NULL && strcasecmp(mech,"DIGEST-MD5") == 0 ) {
+                               /* insert DIGEST calls here */
+                               send_ldap_result( conn, op, LDAP_AUTH_METHOD_NOT_SUPPORTED,
+                                       NULL, NULL, NULL, NULL );
+
+                       } else {
+                               send_ldap_result( conn, op, LDAP_AUTH_METHOD_NOT_SUPPORTED,
+                                       NULL, NULL, NULL, NULL );
+                       }
+
+               } else {
+                       send_ldap_result( conn, op, LDAP_REFERRAL,
+                               matched_dn, NULL, refs, NULL );
+                       rc = 1;
+               }
+
+               if ( matched != NULL ) {
+                       ber_bvecfree( refs );
+                       free( matched_dn );
+               }
+               return( rc );
+       }
+
+       *edn = ch_strdup( e->e_dn );
+
+       /* check for deleted */
+
+       if ( ! access_allowed( be, conn, op, e,
+               "entry", NULL, ACL_AUTH ) )
+       {
+               send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
+                       NULL, NULL, NULL, NULL );
+               rc = 1;
+               goto return_results;
+       }
+
+       if ( is_entry_alias( e ) ) {
+               /* entry is a alias, don't allow bind */
+               Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
+                       0, 0 );
+
+               send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM,
+                       NULL, NULL, NULL, NULL );
+
+               rc = 1;
+               goto return_results;
+       }
+
+
+       if ( is_entry_referral( e ) ) {
+               /* entry is a referral, don't allow bind */
+               struct berval **refs = get_entry_referrals( be,
+                       conn, op, e );
+
+               Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
+                       0, 0 );
+
+               send_ldap_result( conn, op, LDAP_REFERRAL,
+                       e->e_dn, NULL, refs, NULL );
+
+               ber_bvecfree( refs );
+
+               rc = 1;
+               goto return_results;
+       }
+
+       switch ( method ) {
+       case LDAP_AUTH_SIMPLE:
+               if ( cred->bv_len == 0 ) {
+                       send_ldap_result( conn, op, LDAP_SUCCESS,
+                               NULL, NULL, NULL, NULL );
+
+                       /* stop front end from sending result */
+                       rc = 1;
+                       goto return_results;
+               }
+
+               /* check for root dn/passwd */
+               if ( be_isroot_pw( be, dn, cred ) ) {
+                       /* front end will send result */
+                       if( *edn != NULL ) free( *edn );
+                       *edn = ch_strdup( be_root_dn( be ) );
+                       rc = 0;
+                       goto return_results;
+               }
+
+               if ( ! access_allowed( be, conn, op, e,
+                       "userpassword", NULL, ACL_AUTH ) )
+               {
+                       send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
+                               NULL, NULL, NULL, NULL);
+                       rc = 1;
+                       goto return_results;
+               }
+
+               if ( (a = attr_find( e->e_attrs, "userpassword" )) == NULL ) {
+                       send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
+                               NULL, NULL, NULL, NULL);
+
+                       /* stop front end from sending result */
+                       rc = 1;
+                       goto return_results;
+               }
+
+               if ( crypted_value_find( a->a_vals, cred, a->a_syntax, 0, cred ) != 0 )
+               {
+                       send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
+                               NULL, NULL, NULL, NULL);
+                       /* stop front end from sending result */
+                       rc = 1;
+                       goto return_results;
+               }
+               rc = 0;
+               break;
+
+#ifdef HAVE_KERBEROS
+       case LDAP_AUTH_KRBV41:
+               if ( bdb2i_krbv4_ldap_auth( be, cred, &ad ) != LDAP_SUCCESS ) {
+                       send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
+                               NULL, NULL, NULL, NULL);
+                       rc = 1;
+                       goto return_results;
+               }
+
+               if ( ! access_allowed( be, conn, op, e,
+                       "krbname", NULL, ACL_AUTH ) )
+               {
+                       send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
+                               NULL, NULL, NULL, NULL);
+                       rc = 1;
+                       goto return_results;
+               }
+
+               sprintf( krbname, "%s%s%s@%s", ad.pname, *ad.pinst ? "."
+                   : "", ad.pinst, ad.prealm );
+
+               if ( (a = attr_find( e->e_attrs, "krbname" )) == NULL ) {
+                       /*
+                        * no krbName values present:  check against DN
+                        */
+                       if ( strcasecmp( dn, krbname ) == 0 ) {
+                               rc = 0; /* XXX wild ass guess */
+                               break;
+                       }
+                       send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
+                               NULL, NULL, NULL, NULL);
+                       rc = 1;
+                       goto return_results;
+               } else {        /* look for krbName match */
+                       struct berval   krbval;
+
+                       krbval.bv_val = krbname;
+                       krbval.bv_len = strlen( krbname );
+
+                       if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 ) != 0 ) {
+                               send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
+                                       NULL, NULL, NULL, NULL);
+                               rc = 1;
+                               goto return_results;
+                       }
+               }
+               rc = 0;
+               break;
+
+       case LDAP_AUTH_KRBV42:
+               send_ldap_result( conn, op, LDAP_SUCCESS,
+                       NULL, NULL, NULL, NULL );
+               /* stop front end from sending result */
+               rc = 1;
+               goto return_results;
+#endif
+
+       case LDAP_AUTH_SASL:
+               /* insert sasl code here */
+
+       default:
+               send_ldap_result( conn, op, LDAP_STRONG_AUTH_NOT_SUPPORTED,
+                   NULL, "auth method not supported", NULL, NULL );
+               rc = 1;
+               goto return_results;
+       }
+
+return_results:;
+       /* free entry and reader lock */
+       bdb2i_cache_return_entry_r( &li->li_cache, e );
+
+       /* front end with send result on success (rc==0) */
+       return( rc );
+}
+
+
+int
+bdb2_back_bind(
+    BackendDB          *be,
+    Connection         *conn,
+    Operation          *op,
+    char               *dn,
+    int                        method,
+       char            *mech,
+    struct berval      *cred,
+       char**  edn
+)
+{
+       DB_LOCK         lock;
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( be->bd_info, &time1 );
+
+       if ( bdb2i_enter_backend_r( &lock ) != 0 ) {
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               return( 1 );
+       }
+
+       ret = bdb2i_back_bind_internal( be, conn, op, dn, method, mech, cred, edn );
+
+       (void) bdb2i_leave_backend_r( lock );
+
+       bdb2i_stop_timing( be->bd_info, time1, "BIND", conn, op );
+
+       return( ret );
+}
+
+
diff --git a/servers/slapd/back-bdb2/cache.c b/servers/slapd/back-bdb2/cache.c
new file mode 100644 (file)
index 0000000..4c44dbc
--- /dev/null
@@ -0,0 +1,590 @@
+/* cache.c - routines to maintain an in-core cache of entries */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/errno.h>
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+
+#include "back-bdb2.h"
+
+/* LDBM backend specific entry info -- visible only to the cache */
+struct ldbm_entry_info {
+       /*
+        * These items are specific to the LDBM backend and should
+        * be hidden.
+        */
+       int             lei_state;      /* for the cache */
+#define CACHE_ENTRY_UNDEFINED  0
+#define CACHE_ENTRY_CREATING   1
+#define CACHE_ENTRY_READY              2
+#define CACHE_ENTRY_DELETED            3
+
+       int             lei_refcnt;     /* # threads ref'ing this entry */
+       Entry   *lei_lrunext;   /* for cache lru list */
+       Entry   *lei_lruprev;
+};
+#define LEI(e) ((struct ldbm_entry_info *) ((e)->e_private))
+
+static int     cache_delete_entry_internal(struct cache *cache, Entry *e);
+#ifdef LDAP_DEBUG
+static void    lru_print(struct cache *cache);
+#endif
+
+static int
+cache_entry_private_init( Entry*e )
+{
+       assert( e->e_private == NULL );
+
+       if( e->e_private != NULL ) {
+               /* this should never happen */
+               return 1;
+       }
+
+       e->e_private = ch_calloc(1, sizeof(struct ldbm_entry_info));
+
+       return 0;
+}
+
+static int
+cache_entry_private_destroy( Entry*e )
+{
+       assert( e->e_private );
+
+       free( e->e_private );
+       e->e_private = NULL;
+       return 0;
+}
+
+void
+bdb2i_cache_return_entry_rw( struct cache *cache, Entry *e, int rw )
+{
+       /* set cache mutex */
+       ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+
+       assert( e->e_private );
+
+       LEI(e)->lei_refcnt--;
+
+       if ( LEI(e)->lei_state == CACHE_ENTRY_CREATING ) {
+               Debug( LDAP_DEBUG_TRACE,
+                       "====> bdb2i_cache_return_entry_%s( %ld ): created (%d)\n",
+                       rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt );
+
+               LEI(e)->lei_state = CACHE_ENTRY_READY;
+
+       } else if ( LEI(e)->lei_state == CACHE_ENTRY_DELETED ) {
+               if( LEI(e)->lei_refcnt > 0 ) {
+                       Debug( LDAP_DEBUG_TRACE,
+                       "====> bdb2i_cache_return_entry_%s( %ld ): delete pending (%d)\n",
+                               rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt );
+
+               } else {
+                       Debug( LDAP_DEBUG_TRACE,
+                               "====> bdb2i_cache_return_entry_%s( %ld ): deleted (%d)\n",
+                               rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt );
+
+                       cache_entry_private_destroy( e );
+                       entry_free( e );
+               }
+
+       } else {
+               Debug( LDAP_DEBUG_TRACE,
+                       "====> bdb2i_cache_return_entry_%s( %ld ): returned (%d)\n",
+                       rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt);
+       }
+
+       /* free cache mutex */
+       ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+}
+
+#define LRU_DELETE( cache, e ) { \
+       if ( LEI(e)->lei_lruprev != NULL ) { \
+               LEI(LEI(e)->lei_lruprev)->lei_lrunext = LEI(e)->lei_lrunext; \
+       } else { \
+               (cache)->c_lruhead = LEI(e)->lei_lrunext; \
+       } \
+       if ( LEI(e)->lei_lrunext != NULL ) { \
+               LEI(LEI(e)->lei_lrunext)->lei_lruprev = LEI(e)->lei_lruprev; \
+       } else { \
+               (cache)->c_lrutail = LEI(e)->lei_lruprev; \
+       } \
+}
+
+#define LRU_ADD( cache, e ) { \
+       LEI(e)->lei_lrunext = (cache)->c_lruhead; \
+       if ( LEI(e)->lei_lrunext != NULL ) { \
+               LEI(LEI(e)->lei_lrunext)->lei_lruprev = (e); \
+       } \
+       (cache)->c_lruhead = (e); \
+       LEI(e)->lei_lruprev = NULL; \
+       if ( (cache)->c_lrutail == NULL ) { \
+               (cache)->c_lrutail = (e); \
+       } \
+}
+
+/*
+ * bdb2i_cache_add_entry_rw - create and lock an entry in the cache
+ * returns:    0       entry has been created and locked
+ *             1       entry already existed
+ *             -1      something bad happened
+ */
+int
+bdb2i_cache_add_entry_rw(
+    struct cache       *cache,
+    Entry              *e,
+       int             rw
+)
+{
+       int     i;
+       Entry   *ee;
+
+       /* set cache mutex */
+       ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+
+       assert( e->e_private == NULL );
+
+       if( cache_entry_private_init(e) != 0 ) {
+               /* free cache mutex */
+               ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+
+               Debug( LDAP_DEBUG_ANY,
+               "====> bdb2i_cache_add_entry( %ld ): \"%s\": private init failed!\n",
+                   e->e_id, e->e_dn, 0 );
+
+               return( -1 );
+       }
+
+       if ( avl_insert( &cache->c_dntree, (caddr_t) e,
+               (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 )
+       {
+               Debug( LDAP_DEBUG_TRACE,
+               "====> bdb2i_cache_add_entry( %ld ): \"%s\": already in dn cache\n",
+                   e->e_id, e->e_dn, 0 );
+
+               cache_entry_private_destroy(e);
+
+               /* free cache mutex */
+               ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+               return( 1 );
+       }
+
+       /* id tree */
+       if ( avl_insert( &cache->c_idtree, (caddr_t) e,
+               (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 )
+       {
+               Debug( LDAP_DEBUG_ANY,
+               "====> bdb2i_cache_add_entry( %ld ): \"%s\": already in id cache\n",
+                   e->e_id, e->e_dn, 0 );
+
+               /* delete from dn tree inserted above */
+               if ( avl_delete( &cache->c_dntree, (caddr_t) e,
+                       (AVL_CMP) entry_dn_cmp ) == NULL )
+               {
+                       Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n",
+                           0, 0, 0 );
+               }
+
+               cache_entry_private_destroy(e);
+
+               /* free cache mutex */
+               ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+               return( -1 );
+       }
+
+       /* put the entry into 'CREATING' state */
+       /* will be marked after when entry is returned */
+       LEI(e)->lei_state = CACHE_ENTRY_CREATING;
+       LEI(e)->lei_refcnt = 1;
+
+       /* lru */
+       LRU_ADD( cache, e );
+       if ( ++cache->c_cursize > cache->c_maxsize ) {
+               /*
+                * find the lru entry not currently in use and delete it.
+                * in case a lot of entries are in use, only look at the
+                * first 10 on the tail of the list.
+                */
+               i = 0;
+               while ( cache->c_lrutail != NULL &&
+                       LEI(cache->c_lrutail)->lei_refcnt != 0 &&
+                       i < 10 )
+               {
+                       /* move this in-use entry to the front of the q */
+                       ee = cache->c_lrutail;
+                       LRU_DELETE( cache, ee );
+                       LRU_ADD( cache, ee );
+                       i++;
+               }
+
+               /*
+                * found at least one to delete - try to get back under
+                * the max cache size.
+                */
+               while ( cache->c_lrutail != NULL &&
+                       LEI(cache->c_lrutail)->lei_refcnt == 0 &&
+                       cache->c_cursize > cache->c_maxsize )
+               {
+                       e = cache->c_lrutail;
+
+                       /* delete from cache and lru q */
+                       cache_delete_entry_internal( cache, e );
+                       cache_entry_private_destroy( e );
+                       entry_free( e );
+               }
+       }
+
+       /* free cache mutex */
+       ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+       return( 0 );
+}
+
+/*
+ * cache_update_entry - update a LOCKED entry which has been deleted.
+ * returns:    0       entry has been created and locked
+ *             1       entry already existed
+ *             -1      something bad happened
+ */
+int
+bdb2i_cache_update_entry(
+    struct cache       *cache,
+    Entry              *e
+)
+{
+       int     i;
+       Entry   *ee;
+
+       /* set cache mutex */
+       ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+
+       assert( e->e_private );
+
+       if ( avl_insert( &cache->c_dntree, (caddr_t) e,
+               (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 )
+       {
+               Debug( LDAP_DEBUG_TRACE,
+               "====> bdb2i_cache_add_entry( %ld ): \"%s\": already in dn cache\n",
+                   e->e_id, e->e_dn, 0 );
+
+               /* free cache mutex */
+               ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+               return( 1 );
+       }
+
+       /* id tree */
+       if ( avl_insert( &cache->c_idtree, (caddr_t) e,
+               (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 )
+       {
+               Debug( LDAP_DEBUG_ANY,
+               "====> bdb2i_cache_update_entry( %ld ): \"%s\": already in id cache\n",
+                   e->e_id, e->e_dn, 0 );
+
+               /* delete from dn tree inserted above */
+               if ( avl_delete( &cache->c_dntree, (caddr_t) e,
+                       (AVL_CMP) entry_dn_cmp ) == NULL )
+               {
+                       Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n",
+                           0, 0, 0 );
+               }
+
+               /* free cache mutex */
+               ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+               return( -1 );
+       }
+
+       /* put the entry into 'CREATING' state */
+       /* will be marked after when entry is returned */
+       LEI(e)->lei_state = CACHE_ENTRY_CREATING;
+
+       /* lru */
+       LRU_ADD( cache, e );
+       if ( ++cache->c_cursize > cache->c_maxsize ) {
+               /*
+                * find the lru entry not currently in use and delete it.
+                * in case a lot of entries are in use, only look at the
+                * first 10 on the tail of the list.
+                */
+               i = 0;
+               while ( cache->c_lrutail != NULL &&
+                       LEI(cache->c_lrutail)->lei_refcnt != 0 &&
+                       i < 10 )
+               {
+                       /* move this in-use entry to the front of the q */
+                       ee = cache->c_lrutail;
+                       LRU_DELETE( cache, ee );
+                       LRU_ADD( cache, ee );
+                       i++;
+               }
+
+               /*
+                * found at least one to delete - try to get back under
+                * the max cache size.
+                */
+               while ( cache->c_lrutail != NULL &&
+                       LEI(cache->c_lrutail)->lei_refcnt == 0 &&
+                       cache->c_cursize > cache->c_maxsize )
+               {
+                       e = cache->c_lrutail;
+
+                       /* delete from cache and lru q */
+                       cache_delete_entry_internal( cache, e );
+                       cache_entry_private_destroy( e );
+                       entry_free( e );
+               }
+       }
+
+       /* free cache mutex */
+       ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+       return( 0 );
+}
+
+/*
+ * bdb2i_cache_find_entry_dn2id - find an entry in the cache, given dn
+ */
+
+ID
+bdb2i_cache_find_entry_dn2id(
+       BackendDB               *be,
+    struct cache       *cache,
+    const char         *dn
+)
+{
+       Entry           e, *ep;
+       ID                      id;
+       int             count = 0;
+
+       e.e_dn = (char *) dn;
+       e.e_ndn = ch_strdup( dn );
+       (void) dn_normalize_case( e.e_ndn );
+
+try_again:
+       /* set cache mutex */
+       ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+
+       if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
+               (AVL_CMP) entry_dn_cmp )) != NULL )
+       {
+               int state;
+               count++;
+
+               /*
+                * ep now points to an unlocked entry
+                * we do not need to lock the entry if we only
+                * check the state, refcnt, LRU, and id.
+                */
+
+               assert( ep->e_private );
+
+               /* save id */
+               id = ep->e_id;
+               state = LEI(ep)->lei_state;
+
+               /*
+                * entry is deleted or not fully created yet
+                */
+               if ( state != CACHE_ENTRY_READY ) {
+                       assert(state != CACHE_ENTRY_UNDEFINED);
+
+                       /* free cache mutex */
+                       ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+
+                       Debug(LDAP_DEBUG_TRACE,
+                       "====> bdb2i_cache_find_entry_dn2id(\"%s\"): %ld (not ready) %d\n",
+                               dn, id, state);
+
+                       ldap_pvt_thread_yield();
+                       goto try_again;
+               }
+
+               /* lru */
+               LRU_DELETE( cache, ep );
+               LRU_ADD( cache, ep );
+
+               /* free cache mutex */
+               ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+
+               Debug(LDAP_DEBUG_TRACE,
+                       "====> bdb2i_cache_find_entry_dn2id(\"%s\"): %ld (%d tries)\n",
+                       dn, id, count);
+
+       } else {
+               /* free cache mutex */
+               ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+
+               id = NOID;
+       }
+
+       free(e.e_ndn);
+
+       return( id );
+}
+
+/*
+ * cache_find_entry_id - find an entry in the cache, given id
+ */
+
+Entry *
+bdb2i_cache_find_entry_id(
+       struct cache    *cache,
+       ID                              id,
+       int                             rw
+)
+{
+       Entry   e;
+       Entry   *ep;
+       int count=0;
+
+       e.e_id = id;
+
+try_again:
+       /* set cache mutex */
+       ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+
+       if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
+               (AVL_CMP) entry_id_cmp )) != NULL )
+       {
+               int state;
+
+               assert( ep->e_private );
+
+               state = LEI(ep)->lei_state;
+
+               /*
+                * entry is deleted or not fully created yet
+                */
+               if ( state != CACHE_ENTRY_READY ) {
+                       ID ep_id = ep->e_id;
+
+                       assert(state != CACHE_ENTRY_UNDEFINED);
+
+                       /* free cache mutex */
+                       ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+
+                       Debug(LDAP_DEBUG_TRACE,
+                               "====> bdb2i_cache_find_entry_id( %ld ): %ld (not ready) %d\n",
+                               id, ep_id, state);
+
+                       ldap_pvt_thread_yield();
+                       goto try_again;
+               }
+
+               /* lru */
+               LRU_DELETE( cache, ep );
+               LRU_ADD( cache, ep );
+                
+               LEI(ep)->lei_refcnt++;
+
+               /* free cache mutex */
+               ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+
+               Debug(LDAP_DEBUG_TRACE,
+                       "====> bdb2i_cache_find_entry_id( %ld ) \"%s\" (found) (%d tries)\n",
+                       id, ep->e_dn, count);
+
+               return( ep );
+       }
+
+       /* free cache mutex */
+       ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+
+       return( NULL );
+}
+
+/*
+ * cache_delete_entry - delete the entry e from the cache.  the caller
+ * should have obtained e (increasing its ref count) via a call to one
+ * of the cache_find_* routines.  the caller should *not* call the
+ * cache_return_entry() routine prior to calling cache_delete_entry().
+ * it performs this function.
+ *
+ * returns:    0       e was deleted ok
+ *             1       e was not in the cache
+ *             -1      something bad happened
+ */
+int
+bdb2i_cache_delete_entry(
+    struct cache       *cache,
+    Entry              *e
+)
+{
+       int     rc;
+
+       /* set cache mutex */
+       ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+
+       assert( e->e_private );
+
+       Debug( LDAP_DEBUG_TRACE, "====> bdb2i_cache_delete_entry( %ld )\n",
+               e->e_id, 0, 0 );
+
+       rc = cache_delete_entry_internal( cache, e );
+
+       /* free cache mutex */
+       ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+       return( rc );
+}
+
+static int
+cache_delete_entry_internal(
+    struct cache       *cache,
+    Entry              *e
+)
+{
+       int rc = 0;     /* return code */
+
+       /* dn tree */
+       if ( avl_delete( &cache->c_dntree, (caddr_t) e, (AVL_CMP) entry_dn_cmp )
+               == NULL )
+       {
+               rc = -1;
+       }
+
+       /* id tree */
+       if ( avl_delete( &cache->c_idtree, (caddr_t) e, (AVL_CMP) entry_id_cmp )
+               == NULL )
+       {
+               rc = -1;
+       }
+
+       if (rc != 0) {
+               return rc;
+       }
+
+       /* lru */
+       LRU_DELETE( cache, e );
+       cache->c_cursize--;
+
+       /*
+        * flag entry to be freed later by a call to cache_return_entry()
+        */
+       LEI(e)->lei_state = CACHE_ENTRY_DELETED;
+
+       return( 0 );
+}
+
+#ifdef LDAP_DEBUG
+
+static void
+lru_print( struct cache *cache )
+{
+       Entry   *e;
+
+       fprintf( stderr, "LRU queue (head to tail):\n" );
+       for ( e = cache->c_lruhead; e != NULL; e = LEI(e)->lei_lrunext ) {
+               fprintf( stderr, "\tdn \"%20s\" id %ld refcnt %d\n",
+                       e->e_dn, e->e_id, LEI(e)->lei_refcnt );
+       }
+       fprintf( stderr, "LRU queue (tail to head):\n" );
+       for ( e = cache->c_lrutail; e != NULL; e = LEI(e)->lei_lruprev ) {
+               fprintf( stderr, "\tdn \"%20s\" id %ld refcnt %d\n",
+                       e->e_dn, e->e_id, LEI(e)->lei_refcnt );
+       }
+}
+
+#endif
+
index 894e4dfadca9158c88768c6b94363b3c6ad9af9a..98d68c7c68e3a5c3eeba8325f7b68e1657b1bb36 100644 (file)
@@ -1,4 +1,5 @@
 /* close.c - close bdb2 backend database */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
diff --git a/servers/slapd/back-bdb2/compare.c b/servers/slapd/back-bdb2/compare.c
new file mode 100644 (file)
index 0000000..46093d6
--- /dev/null
@@ -0,0 +1,136 @@
+/* compare.c - bdb2 backend compare routine */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+#include "proto-back-bdb2.h"
+
+static int
+bdb2i_back_compare_internal(
+    BackendDB  *be,
+    Connection *conn,
+    Operation  *op,
+    char       *dn,
+    Ava                *ava
+)
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       Entry           *matched;
+       Entry           *e;
+       Attribute       *a;
+       int             rc;
+       int             manageDSAit = get_manageDSAit( op );
+
+       /* get entry with reader lock */
+       if ( (e = bdb2i_dn2entry_r( be, dn, &matched )) == NULL ) {
+               char *matched_dn = NULL;
+               struct berval **refs = NULL;
+
+               if ( matched != NULL ) {
+                       matched_dn = ch_strdup( matched->e_dn );
+                       refs = is_entry_referral( matched )
+                               ? get_entry_referrals( be, conn, op, matched )
+                               : NULL;
+                       bdb2i_cache_return_entry_r( &li->li_cache, matched );
+               } else {
+                       refs = default_referral;
+               }
+
+               send_ldap_result( conn, op, LDAP_REFERRAL,
+                       matched_dn, NULL, refs, NULL );
+
+               if( matched != NULL ) {
+                       ber_bvecfree( refs );
+                       free( matched_dn );
+               }
+
+               return( 1 );
+       }
+
+       if (!manageDSAit && is_entry_referral( e ) ) {
+               /* entry is a referral, don't allow add */
+               struct berval **refs = get_entry_referrals( be,
+                       conn, op, e );
+
+               Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
+                       0, 0 );
+
+               send_ldap_result( conn, op, LDAP_REFERRAL,
+                       e->e_dn, NULL, refs, NULL );
+
+               ber_bvecfree( refs );
+
+               rc = 1;
+               goto return_results;
+       }
+
+       if ( ! access_allowed( be, conn, op, e,
+               ava->ava_type, &ava->ava_value, ACL_COMPARE ) )
+       {
+               send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
+                       NULL, NULL, NULL, NULL );
+               rc = 1;
+               goto return_results;
+       }
+
+       if ( (a = attr_find( e->e_attrs, ava->ava_type )) == NULL ) {
+               send_ldap_result( conn, op, LDAP_NO_SUCH_ATTRIBUTE,
+                       NULL, NULL, NULL, NULL );
+               rc = 1;
+               goto return_results;
+       }
+
+       if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 ) 
+               send_ldap_result( conn, op, LDAP_COMPARE_TRUE,
+                       NULL, NULL, NULL, NULL );
+       else
+               send_ldap_result( conn, op, LDAP_COMPARE_FALSE,
+                       NULL, NULL, NULL, NULL );
+
+       rc = 0;
+
+return_results:;
+       bdb2i_cache_return_entry_r( &li->li_cache, e );
+       return( rc );
+}
+
+
+int
+bdb2_back_compare(
+    BackendDB  *be,
+    Connection *conn,
+    Operation  *op,
+    char       *dn,
+    Ava                *ava
+)
+{
+       DB_LOCK         lock;
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( be->bd_info, &time1 );
+
+       if ( bdb2i_enter_backend_r( &lock ) != 0 ) {
+
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               return( 1 );
+
+       }
+
+       ret = bdb2i_back_compare_internal( be, conn, op, dn, ava );
+       (void) bdb2i_leave_backend_r( lock );
+       bdb2i_stop_timing( be->bd_info, time1, "CMP", conn, op );
+
+       return( ret );
+}
+
+
diff --git a/servers/slapd/back-bdb2/config.c b/servers/slapd/back-bdb2/config.c
new file mode 100644 (file)
index 0000000..87d7392
--- /dev/null
@@ -0,0 +1,202 @@
+/* config.c - bdb2 backend configuration file routine */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+
+static int
+bdb2i_back_config_internal(
+    BackendInfo        *bi,
+    const char         *fname,
+    int                        lineno,
+    int                        argc,
+    char               **argv
+)
+{
+       struct ldbtype  *lty = (struct ldbtype *) bi->bi_private;
+
+       if ( lty == NULL ) {
+               fprintf( stderr, "%s: line %d: ldbm backend type info is null!\n",
+                   fname, lineno );
+               return( 1 );
+       }
+
+       /* directory where DB control files live */
+       if ( strcasecmp( argv[0], "home" ) == 0 ) {
+               if ( argc < 2 ) {
+                       fprintf( stderr,
+               "%s: line %d: missing dir in \"home <dir>\" line\n",
+                           fname, lineno );
+                       return( 1 );
+               }
+               lty->lty_dbhome = ch_strdup( argv[1] );
+
+       /* size of the DB memory pool */
+       } else if ( strcasecmp( argv[0], "mpoolsize" ) == 0 ) {
+               if ( argc < 2 ) {
+                       fprintf( stderr,
+                       "%s: line %d: missing size in \"mpoolsize <size>\" line\n",
+                           fname, lineno );
+                       return( 1 );
+               }
+               lty->lty_mpsize = (size_t) atoi( argv[1] );
+               /*  we should at least have the suggested 128k  */
+               if ( lty->lty_mpsize < DEFAULT_DBCACHE_SIZE )
+                       lty->lty_mpsize = DEFAULT_DBCACHE_SIZE;
+
+       /* anything else */
+       } else {
+               fprintf( stderr,
+"%s: line %d: unknown directive \"%s\" in ldbm backend definition (ignored)\n",
+                   fname, lineno, argv[0] );
+       }
+
+       return 0;
+}
+
+
+int
+bdb2_back_config(
+    BackendInfo        *bi,
+    const char *fname,
+    int                lineno,
+    int                argc,
+    char       **argv
+)
+{
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( bi, &time1 );
+
+       ret = bdb2i_back_config_internal( bi, fname, lineno, argc, argv );
+       bdb2i_stop_timing( bi, time1, "BE-CONFIG", NULL, NULL );
+
+       return( ret );
+}
+
+
+static int
+bdb2i_back_db_config_internal(
+    BackendDB  *be,
+    const char *fname,
+    int                lineno,
+    int                argc,
+    char       **argv
+)
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+
+       if ( li == NULL ) {
+               fprintf( stderr, "%s: line %d: ldbm database info is null!\n",
+                   fname, lineno );
+               return( 1 );
+       }
+
+       /* directory where database files live */
+       if ( strcasecmp( argv[0], "directory" ) == 0 ) {
+               if ( argc < 2 ) {
+                       fprintf( stderr,
+               "%s: line %d: missing dir in \"directory <dir>\" line\n",
+                           fname, lineno );
+                       return( 1 );
+               }
+               li->li_directory = ch_strdup( argv[1] );
+
+               li->li_nextid_file =
+                       ch_malloc( strlen(li->li_directory) + sizeof("/NEXTID") + 1 );
+
+               strcpy(li->li_nextid_file, li->li_directory);
+               strcat(li->li_nextid_file, "/NEXTID");
+
+       /* mode with which to create new database files */
+       } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
+               if ( argc < 2 ) {
+                       fprintf( stderr,
+                       "%s: line %d: missing mode in \"mode <mode>\" line\n",
+                           fname, lineno );
+                       return( 1 );
+               }
+               li->li_mode = strtol( argv[1], NULL, 0 );
+
+       /* attribute to index */
+       } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
+               if ( argc < 2 ) {
+                       fprintf( stderr,
+"%s: line %d: missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
+                           fname, lineno );
+                       return( 1 );
+               } else if ( argc > 3 ) {
+                       fprintf( stderr,
+"%s: line %d: extra junk after \"index <attr> [pres,eq,approx,sub]\" line (ignored)\n",
+                           fname, lineno );
+               }
+               bdb2i_attr_index_config( li, fname, lineno, argc - 1, &argv[1], 0 );
+
+       /* size of the cache in entries */
+       } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
+               if ( argc < 2 ) {
+                       fprintf( stderr,
+               "%s: line %d: missing size in \"cachesize <size>\" line\n",
+                           fname, lineno );
+                       return( 1 );
+               }
+               li->li_cache.c_maxsize = atoi( argv[1] );
+
+       /* size of each dbcache in bytes */
+       } else if ( strcasecmp( argv[0], "dbcachesize" ) == 0 ) {
+               if ( argc < 2 ) {
+                       fprintf( stderr,
+               "%s: line %d: missing size in \"dbcachesize <size>\" line\n",
+                           fname, lineno );
+                       return( 1 );
+               }
+               li->li_dbcachesize = atoi( argv[1] );
+               /*  we should at least have the suggested 128k  */
+               if ( li->li_dbcachesize < DEFAULT_DBCACHE_SIZE )
+                       li->li_dbcachesize = DEFAULT_DBCACHE_SIZE;
+
+       /* no write sync */
+       } else if ( strcasecmp( argv[0], "dbcachenowsync" ) == 0 ) {
+               li->li_dbcachewsync = 0;
+
+       /* anything else */
+       } else {
+               fprintf( stderr,
+"%s: line %d: unknown directive \"%s\" in ldbm database definition (ignored)\n",
+                   fname, lineno, argv[0] );
+       }
+
+       return 0;
+}
+
+
+int
+bdb2_back_db_config(
+    BackendDB  *be,
+    const char *fname,
+    int                lineno,
+    int                argc,
+    char       **argv
+)
+{
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( be->bd_info, &time1 );
+
+       ret = bdb2i_back_db_config_internal( be, fname, lineno, argc, argv );
+
+       bdb2i_stop_timing( be->bd_info, time1, "DB-CONFIG", NULL, NULL );
+
+       return( ret );
+}
+
+
index d77e1e772e78e0fe044ae238d5feec61e42e089a..6a1a0ef3d8e9cabb00386fdddaa9bf4c2961098c 100644 (file)
@@ -1,4 +1,5 @@
 /* ldbmcache.c - maintain a cache of open bdb2 files */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
@@ -15,7 +16,6 @@
 #include <sys/param.h>
 #endif
 
-#include "ldap_defaults.h"
 #include "slap.h"
 #include "back-bdb2.h"
 
index d80d2dceb2bf1482ccd7624b873d22289e20a690..eee7b6d914730e55bc695c5404387373ea953f55 100644 (file)
@@ -1,4 +1,5 @@
 /* delete.c - bdb2 backend delete routine */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
@@ -126,7 +127,7 @@ bdb2i_back_delete_internal(
        }
 
        /* delete from dn2id mapping */
-       if ( bdb2i_dn2id_delete( be, e->e_ndn ) != 0 ) {
+       if ( bdb2i_dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
                Debug(LDAP_DEBUG_ARGS,
                        "<=- bdb2i_back_delete: operations error %s\n",
                        dn, 0, 0);
index 43707b77d9f08ce8c0b3070869aaafb29f83122e..1d4599a826a87b38f0a05cbc7c81495fc161781e 100644 (file)
@@ -1,4 +1,5 @@
 /* dn2id.c - routines to deal with the dn2id index */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
@@ -14,7 +15,7 @@
 int
 bdb2i_dn2id_add(
     BackendDB  *be,
-    char       *dn,
+    const char *dn,
     ID         id
 )
 {
@@ -91,7 +92,7 @@ bdb2i_dn2id_add(
 ID
 bdb2i_dn2id(
     BackendDB  *be,
-    char       *dn
+    const char *dn
 )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
@@ -143,7 +144,7 @@ bdb2i_dn2id(
 ID_BLOCK *
 bdb2i_dn2idl(
     BackendDB  *be,
-    char       *dn,
+    const char *dn,
        int     prefix )
 {
        struct dbcache  *db;
@@ -178,14 +179,16 @@ bdb2i_dn2idl(
 int
 bdb2i_dn2id_delete(
     BackendDB  *be,
-    char       *dn
+    const char *dn,
+       ID id
 )
 {
        struct dbcache  *db;
        Datum           key;
        int             rc;
 
-       Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2id_delete( \"%s\" )\n", dn, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2id_delete( \"%s\", %ld )\n",
+               dn, id, 0 );
 
        if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX, LDBM_WRCREAT ))
            == NULL ) {
@@ -195,6 +198,40 @@ bdb2i_dn2id_delete(
                return( -1 );
        }
 
+       {
+               char *pdn = dn_parent( NULL, dn );
+
+               if( pdn != NULL ) {
+                       ldbm_datum_init( key );
+                       key.dsize = strlen( pdn ) + 2;
+                       key.dptr = ch_malloc( key.dsize );
+                       sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, pdn );
+                       (void) bdb2i_idl_delete_key( be, db, key, id );
+                       free( key.dptr );
+                       free( pdn );
+               }
+       }
+
+       {
+               char **subtree = dn_subtree( NULL, dn );
+
+               if( subtree != NULL ) {
+                       int i;
+                       for( i=0; subtree[i] != NULL; i++ ) {
+                               ldbm_datum_init( key );
+                               key.dsize = strlen( subtree[i] ) + 2;
+                               key.dptr = ch_malloc( key.dsize );
+                               sprintf( key.dptr, "%c%s", DN_SUBTREE_PREFIX, subtree[i] );
+
+                               (void) bdb2i_idl_delete_key( be, db, key, id );
+
+                               free( key.dptr );
+                       }
+
+                       charray_free( subtree );
+               }
+       }
+
        ldbm_datum_init( key );
 
        key.dsize = strlen( dn ) + 2;
@@ -219,7 +256,7 @@ bdb2i_dn2id_delete(
 Entry *
 bdb2i_dn2entry_rw(
     BackendDB  *be,
-    char       *dn,
+    const char *dn,
     Entry      **matched,
     int         rw
 )
diff --git a/servers/slapd/back-bdb2/entry.c b/servers/slapd/back-bdb2/entry.c
new file mode 100644 (file)
index 0000000..9238b1c
--- /dev/null
@@ -0,0 +1,30 @@
+/* entry.c - ldbm backend entry_release routine */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+#include "proto-back-bdb2.h"
+
+
+int
+bdb2_back_entry_release_rw(
+       BackendDB *be,
+       Entry   *e,
+       int     rw
+)
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+
+       /* free entry and reader or writer lock */
+       bdb2i_cache_return_entry_rw( &li->li_cache, e, rw ); 
+       bdb2i_release_add_lock();
+
+       return 0;
+}
index 58da13d2248f7f126720b73013d0e5a56709321d..9af5a84ed6430654d68f863d860f758cf1190588 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 #ifndef _BDB2_EXTERNAL_H
 #define _BDB2_EXTERNAL_H
 
@@ -9,7 +10,7 @@ extern int     bdb2_back_close LDAP_P(( BackendInfo *bi ));
 extern int     bdb2_back_destroy LDAP_P(( BackendInfo *bi ));
 
 extern int     bdb2_back_config LDAP_P(( BackendInfo *bt,
-       char *fname, int lineno, int argc, char **argv ));
+       const char *fname, int lineno, int argc, char **argv ));
 
 extern int     bdb2_back_db_init LDAP_P(( BackendDB *bd ));
 extern int     bdb2_back_db_open LDAP_P(( BackendDB *bd ));
@@ -17,7 +18,7 @@ extern int    bdb2_back_db_close LDAP_P(( BackendDB *bd ));
 extern int     bdb2_back_db_destroy LDAP_P(( BackendDB *bd ));
 
 extern int     bdb2_back_db_config LDAP_P(( BackendDB *bd,
-       char *fname, int lineno, int argc, char **argv ));
+       const char *fname, int lineno, int argc, char **argv ));
 
 extern int bdb2_back_bind LDAP_P(( BackendDB *bd,
        Connection *conn, Operation *op,
@@ -55,8 +56,8 @@ extern int    bdb2_back_abandon LDAP_P(( BackendDB *bd,
        Connection *conn, Operation *op, int msgid ));
 
 extern int     bdb2_back_group LDAP_P(( BackendDB *bd,
-       Entry *target, char* gr_ndn, char* op_ndn,
-       char* objectclassValue, char* groupattrName));
+       Entry *target, const char* gr_ndn, const char* op_ndn,
+       const char* objectclassValue, const char* groupattrName));
 
 /* hooks for slap tools */
 extern int bdb2_tool_entry_open LDAP_P(( BackendDB *be, int mode ));
index ad546caa485f21125a11cc7e01ab9bd2c5861061..a9f7452cf430efe0f47e3e3140d3a38ab1f21709 100644 (file)
@@ -1,4 +1,5 @@
 /* filterindex.c - generate the list of candidate entries from a filter */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
diff --git a/servers/slapd/back-bdb2/group.c b/servers/slapd/back-bdb2/group.c
new file mode 100644 (file)
index 0000000..4bc4fc9
--- /dev/null
@@ -0,0 +1,182 @@
+/* group.c - bdb2 backend acl group routine */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+#include "proto-back-bdb2.h"
+
+
+/* return 0 IFF op_dn is a value in member attribute
+ * of entry with gr_dn AND that entry has an objectClass
+ * value of groupOfNames
+ */
+static int
+bdb2i_back_group_internal(
+       BackendDB       *be,
+       Entry   *target,
+       const char      *gr_ndn,
+       const char      *op_ndn,
+       const char      *objectclassValue,
+       const char      *groupattrName
+)
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;    
+       Entry *e;
+       int rc = 1;
+       Attribute *attr;
+       struct berval bv;
+
+       Debug( LDAP_DEBUG_ARGS,
+               "=> bdb2i_back_group: gr dn: \"%s\"\n",
+               gr_ndn, 0, 0 ); 
+       Debug( LDAP_DEBUG_ARGS,
+               "=> bdb2i_back_group: op dn: \"%s\"\n",
+               op_ndn, 0, 0 ); 
+       Debug( LDAP_DEBUG_ARGS,
+               "=> bdb2i_back_group: objectClass: \"%s\" attrName: \"%s\"\n", 
+               objectclassValue, groupattrName, 0 ); 
+
+       Debug( LDAP_DEBUG_ARGS,
+               "=> bdb2i_back_group: tr dn: \"%s\"\n",
+               target->e_ndn, 0, 0 ); 
+
+       if (strcmp(target->e_ndn, gr_ndn) == 0) {
+               /* we already have a LOCKED copy of the entry */
+               e = target;
+               Debug( LDAP_DEBUG_ARGS,
+                       "=> bdb2i_back_group: target is group: \"%s\"\n",
+                       gr_ndn, 0, 0 ); 
+
+       } else {
+               /* can we find group entry with reader lock */
+               if ((e = bdb2i_dn2entry_r(be, gr_ndn, NULL )) == NULL) {
+                       Debug( LDAP_DEBUG_ACL,
+                               "=> bdb2i_back_group: cannot find group: \"%s\"\n",
+                                       gr_ndn, 0, 0 ); 
+                       return( 1 );
+               }
+
+               Debug( LDAP_DEBUG_ACL,
+                       "=> bdb2i_back_group: found group: \"%s\"\n",
+                       gr_ndn, 0, 0 ); 
+       }
+
+       /* find it's objectClass and member attribute values
+        * make sure this is a group entry
+        * finally test if we can find op_dn in the member attribute value list
+        */
+        
+       rc = 1;
+
+       if ((attr = attr_find(e->e_attrs, "objectclass")) == NULL)  {
+               Debug( LDAP_DEBUG_ACL,
+                       "<= bdb2i_back_group: failed to find objectClass\n", 0, 0, 0 ); 
+               goto return_results;
+       }
+
+       bv.bv_val = "ALIAS";
+       bv.bv_len = sizeof("ALIAS")-1;
+
+       if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
+               Debug( LDAP_DEBUG_ACL,
+                       "<= bdb2i_back_group: group is an alias\n", 0, 0, 0 ); 
+               goto return_results;
+       }
+
+       bv.bv_val = "REFERRAL";
+       bv.bv_len = sizeof("REFERRAL")-1;
+
+       if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
+               Debug( LDAP_DEBUG_ACL,
+                       "<= bdb2i_back_group: group is a referral\n", 0, 0, 0 ); 
+               goto return_results;
+       }
+
+       bv.bv_val = (char *) objectclassValue;
+       bv.bv_len = strlen( bv.bv_val );
+
+       if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
+               Debug( LDAP_DEBUG_ACL,
+                       "<= bdb2i_back_group: failed to find %s in objectClass\n",
+                       objectclassValue, 0, 0 ); 
+               goto return_results;
+       }
+
+       if ((attr = attr_find(e->e_attrs, groupattrName)) == NULL) {
+               Debug( LDAP_DEBUG_ACL,
+                       "<= bdb2i_back_group: failed to find %s\n",
+                       groupattrName, 0, 0 ); 
+               goto return_results;
+       }
+
+       Debug( LDAP_DEBUG_ACL,
+               "<= bdb2i_back_group: found objectClass %s and %s\n",
+               objectclassValue, groupattrName, 0 ); 
+
+
+       bv.bv_val = (char *) op_ndn;
+       bv.bv_len = strlen( op_ndn );         
+
+       if (value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 ) {
+               Debug( LDAP_DEBUG_ACL,
+                       "<= bdb2i_back_group: \"%s\" not in \"%s\": %s\n", 
+                       op_ndn, gr_ndn, groupattrName ); 
+               goto return_results;
+       }
+
+       Debug( LDAP_DEBUG_ACL,
+               "<= bdb2i_back_group: \"%s\" is in \"%s\": %s\n", 
+               op_ndn, gr_ndn, groupattrName ); 
+       rc = 0;
+
+return_results:
+       if( target != e ) {
+               /* free entry and reader lock */
+               bdb2i_cache_return_entry_r( &li->li_cache, e );                 
+       }
+
+       Debug( LDAP_DEBUG_ARGS, "bdb2i_back_group: rc: %d\n", rc, 0, 0 ); 
+       return(rc);
+}
+
+
+int
+bdb2_back_group(
+       BackendDB       *be,
+       Entry   *target,
+       const char      *gr_ndn,
+       const char      *op_ndn,
+       const char      *objectclassValue,
+       const char      *groupattrName
+)
+{
+       DB_LOCK         lock;
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( be->bd_info, &time1 );
+
+       if ( bdb2i_enter_backend_r( &lock ) != 0 ) {
+
+               return( 1 );
+
+       }
+
+       ret = bdb2i_back_group_internal( be, target, gr_ndn, op_ndn,
+                                       objectclassValue, groupattrName );
+
+       (void) bdb2i_leave_backend_r( lock );
+       bdb2i_stop_timing( be->bd_info, time1, "GRP", NULL, NULL );
+
+       return( ret );
+}
+
+
index 903418daa6be04b03adfb04a992983357cfe060d..8db5c188b32b60e36f2697d76a89b497d63b16aa 100644 (file)
@@ -1,4 +1,5 @@
 /* id2children.c - routines to deal with the id2children index */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
index c7bf18e5c02f773a4569251af1b9290afb52e1c2..1a151fb1d6aa18d10a80f7dbe3758fe849440848 100644 (file)
@@ -1,4 +1,5 @@
 /* id2entry.c - routines to deal with the id2entry index */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
index f6718dc4b438c90976ed64ed0b51f676031086fc..c062642d8e525227b29180e0eb2e3402b57d31f7 100644 (file)
@@ -1,4 +1,5 @@
 /* idl.c - ldap id list handling routines */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
@@ -7,7 +8,6 @@
 #include <ac/string.h>
 #include <ac/socket.h>
 
-#include "ldap_defaults.h"
 #include "slap.h"
 #include "back-bdb2.h"
 
@@ -467,7 +467,8 @@ bdb2i_idl_insert_key(
                rc = idl_change_first( be, db, key, idl, i, k2, tmp );
                break;
 
-       case 2:         /* id not inserted - already there */
+       case 2:         /* id not inserted - already there, do nothing */
+               rc = 0;
                break;
 
        case 3:         /* id not inserted - block is full */
@@ -488,7 +489,8 @@ bdb2i_idl_insert_key(
                                Debug( LDAP_DEBUG_ANY,
                                    "idl_fetch_one (%s) returns NULL\n",
                                    k2.dptr, 0, 0 );
-                               break;
+                               /* split the original block */
+                               goto split;
                        }
 
                        switch ( (rc = bdb2i_idl_insert( &tmp2, id,
@@ -514,14 +516,19 @@ bdb2i_idl_insert_key(
                        case 3:         /* split the original block */
                                break;
                        }
+
                        bdb2i_idl_free( tmp2 );
                }
 
+split:
                /*
                 * must split the block, write both new blocks + update
                 * and write the indirect header block.
                 */
 
+               rc = 0; /* optimistic */
+
+
                /* count how many indirect blocks *//* XXX linear count XXX */
                for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ )
                        ;       /* NULL */
@@ -618,7 +625,7 @@ bdb2i_idl_insert_key(
 int
 bdb2i_idl_insert( ID_BLOCK **idl, ID id, unsigned int maxids )
 {
-       unsigned int    i, j;
+       unsigned int    i;
 
        if ( ID_BLOCK_ALLIDS( *idl ) ) {
                return( 2 );    /* already there */
@@ -648,8 +655,8 @@ bdb2i_idl_insert( ID_BLOCK **idl, ID id, unsigned int maxids )
        }
 
        /* make a slot for the new id */
-       SAFEMEMCPY( &ID_BLOCK_ID(*idl, i), &ID_BLOCK_ID(*idl, i+1),
-               ID_BLOCK_NIDS(*idl) - i );
+       SAFEMEMCPY( &ID_BLOCK_ID(*idl, i+1), &ID_BLOCK_ID(*idl, i),
+                   (ID_BLOCK_NIDS(*idl) - i) * sizeof(ID) );
 
        ID_BLOCK_ID(*idl, i) = id;
        ID_BLOCK_NIDS(*idl)++;
index 0338712c704323d6a4d1525648677a50d7fe31b1..6ef1ca2f73721c67ff4c661c4ea7566f033583f1 100644 (file)
@@ -1,4 +1,5 @@
 /* index.c - routines for dealing with attribute indexes */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
index 3977fc5e20bf8349dd48b1cf1a96e45a4f65a7d9..0eb5080460de57ce218991167f28474f2691f9bf 100644 (file)
@@ -1,4 +1,5 @@
 /* init.c - initialize bdb2 backend */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
diff --git a/servers/slapd/back-bdb2/kerberos.c b/servers/slapd/back-bdb2/kerberos.c
new file mode 100644 (file)
index 0000000..61a9db0
--- /dev/null
@@ -0,0 +1,49 @@
+/* kerberos.c - bdb2 backend kerberos bind routines */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#ifdef HAVE_KERBEROS
+
+#include <stdio.h>
+
+#include <ac/krb.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+
+#define LDAP_KRB_PRINCIPAL     "ldapserver"
+
+extern char            *ldap_srvtab;
+extern Attribute       *attr_find();
+
+bdb2i_krbv4_ldap_auth(
+    BackendDB          *be,
+    struct berval      *cred,
+    AUTH_DAT           *ad
+)
+{
+       KTEXT_ST        k;
+       KTEXT           ktxt = &k;
+       char            instance[INST_SZ];
+       int             err;
+
+       Debug( LDAP_DEBUG_TRACE, "=> kerberosv4_ldap_auth\n", 0, 0, 0 );
+
+       SAFEMEMCPY( ktxt->dat, cred->bv_val, cred->bv_len );
+       ktxt->length = cred->bv_len;
+
+       strcpy( instance, "*" );
+       if ( (err = krb_rd_req( ktxt, LDAP_KRB_PRINCIPAL, instance, 0L, ad,
+           ldap_srvtab )) != KSUCCESS ) {
+               Debug( LDAP_DEBUG_ANY, "krb_rd_req failed (%s)\n",
+                   krb_err_txt[err], 0, 0 );
+               return( LDAP_INVALID_CREDENTIALS );
+       }
+
+       return( LDAP_SUCCESS );
+}
+
+#endif /* kerberos */
index 1e4a62d9a363f5ed596ec35cd2c0d93d8036c6cc..817d3ba26f6afe5c9b7e29aca62c5b1ffbf27b65 100644 (file)
@@ -1,4 +1,5 @@
 /* modify.c - bdb2 backend modify routine */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
diff --git a/servers/slapd/back-bdb2/modrdn.c b/servers/slapd/back-bdb2/modrdn.c
new file mode 100644 (file)
index 0000000..47c260f
--- /dev/null
@@ -0,0 +1,510 @@
+/* modrdn.c - bdb2 backend modrdn routine */
+/* $OpenLDAP$ */
+
+/*
+ * LDAP v3 newSuperior support.
+ *
+ * Copyright 1999, Juan C. Gomez, All rights reserved.
+ * This software is not subject to any license of Silicon Graphics 
+ * Inc. or Purdue University.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * without restriction or fee of any kind as long as this notice
+ * is preserved.
+ *
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+#include "proto-back-bdb2.h"
+
+static int
+bdb2i_back_modrdn_internal(
+    BackendDB  *be,
+    Connection *conn,
+    Operation  *op,
+    char       *dn,
+    char       *newrdn,
+    int                deleteoldrdn,
+    char       *newSuperior
+)
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       Entry           *matched = NULL;
+       char            *p_dn = NULL, *p_ndn = NULL;
+       char            *new_dn = NULL, *new_ndn = NULL;
+       char            sep[2];
+       Entry           *e, *p = NULL;
+       int                     rc = -1, manageDSAit;
+       /* Added to support LDAP v2 correctly (deleteoldrdn thing) */
+       char            *new_rdn_val = NULL;    /* Val of new rdn */
+       char            *new_rdn_type = NULL;   /* Type of new rdn */
+       char            *old_rdn = NULL;        /* Old rdn's attr type & val */
+       char            *old_rdn_type = NULL;   /* Type of old rdn attr. */
+       char            *old_rdn_val = NULL;    /* Old rdn attribute value */
+       struct berval   add_bv;                 /* Stores new rdn att */
+       struct berval   *add_bvals[2];          /* Stores new rdn att */
+       struct berval   del_bv;                 /* Stores old rdn att */
+       struct berval   *del_bvals[2];          /* Stores old rdn att */
+       LDAPModList     mod[2];                 /* Used to delete old rdn */
+       /* Added to support newSuperior */ 
+       Entry           *np = NULL;     /* newSuperior Entry */
+       char            *np_dn = NULL;  /* newSuperior dn */
+       char            *np_ndn = NULL; /* newSuperior ndn */
+       char            *new_parent_dn = NULL;  /* np_dn, p_dn, or NULL */
+
+       Debug( LDAP_DEBUG_TRACE, "==>ldbm_back_modrdn(newSuperior=%s)\n",
+              (newSuperior ? newSuperior : "NULL"),
+              0, 0 );
+
+       /* get entry with writer lock */
+       if ( (e = bdb2i_dn2entry_w( be, dn, &matched )) == NULL ) {
+               char *matched_dn = NULL;
+               struct berval **refs = NULL;
+
+               if ( matched != NULL ) {
+                       matched_dn = ch_strdup( matched->e_dn );
+                       refs = is_entry_referral( matched )
+                               ? get_entry_referrals( be, conn, op, matched )
+                               : NULL;
+                       bdb2i_cache_return_entry_r( &li->li_cache, matched );
+               } else {
+                       refs = default_referral;
+               }
+
+               send_ldap_result( conn, op, LDAP_REFERRAL,
+                       matched_dn, NULL, refs, NULL );
+
+               if( matched != NULL ) {
+                       ber_bvecfree( refs );
+                       free( matched_dn );
+               }
+
+               return( -1 );
+       }
+
+       if (!manageDSAit && is_entry_referral( e ) ) {
+               /* entry is a referral, don't allow add */
+               struct berval **refs = get_entry_referrals( be,
+                       conn, op, e );
+
+               Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
+                       0, 0 );
+
+               send_ldap_result( conn, op, LDAP_REFERRAL,
+                       e->e_dn, NULL, refs, NULL );
+
+               ber_bvecfree( refs );
+
+               goto return_results;
+       }
+
+#ifdef SLAPD_CHILD_MODIFICATION_WITH_ENTRY_ACL
+               /* check parent for "children" acl */
+       if ( ! access_allowed( be, conn, op, e,
+               "entry", NULL, ACL_WRITE ) )
+       {
+               Debug( LDAP_DEBUG_TRACE, "no access to entry\n", 0,
+                       0, 0 );
+               send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
+                       NULL, NULL, NULL, NULL );
+               goto return_results;
+       }
+#endif
+
+       if ( (p_ndn = dn_parent( be, e->e_ndn )) != NULL ) {
+               /* parent + rdn + separator(s) + null */
+               if( (p = bdb2i_dn2entry_w( be, p_ndn, &matched )) == NULL) {
+                       Debug( LDAP_DEBUG_TRACE, "parent does not exist\n",
+                               0, 0, 0);
+                       send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                               NULL, NULL, NULL, NULL );
+                       goto return_results;
+               }
+
+               /* check parent for "children" acl */
+               if ( ! access_allowed( be, conn, op, p,
+                       "children", NULL, ACL_WRITE ) )
+               {
+                       Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0,
+                               0, 0 );
+                       send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
+                               NULL, NULL, NULL, NULL );
+                       goto return_results;
+               }
+
+               p_dn = dn_parent( be, e->e_dn );
+
+               Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: parent dn=%s\n",
+                      p_dn, 0, 0 );
+
+
+       } else {
+               /* no parent, modrdn entry directly under root */
+               if( ! be_isroot( be, op->o_ndn ) ) {
+                       Debug( LDAP_DEBUG_TRACE, "no parent & not root\n",
+                               0, 0, 0);
+                       send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
+                               NULL, NULL, NULL, NULL );
+                       goto return_results;
+               }
+
+               Debug( LDAP_DEBUG_TRACE,
+                      "ldbm_back_modrdn: no parent!, working on root\n",
+                      0, 0, 0 );
+
+       }
+
+       new_parent_dn = p_dn;   /* New Parent unless newSuperior given */
+
+       if ( (np_dn = newSuperior) != NULL) {
+
+
+               Debug( LDAP_DEBUG_TRACE, 
+                      "ldbm_back_modrdn: new parent requested...\n",
+                      0, 0, 0 );
+
+               np_ndn = ch_strdup( np_dn );
+               (void) dn_normalize_case( np_ndn );
+
+               /* newSuperior == oldParent?, if so ==> ERROR */
+
+               /* newSuperior == entry being moved?, if so ==> ERROR */
+
+               /* Get Entry with dn=newSuperior. Does newSuperior exist? */
+
+               if( (np = bdb2i_dn2entry_w( be, np_ndn, &matched )) == NULL) {
+
+                       Debug( LDAP_DEBUG_TRACE,
+                              "ldbm_back_modrdn: newSup(ndn=%s) not here!\n",
+                              np_ndn, 0, 0);
+                       send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                               NULL, NULL, NULL, NULL );
+                       goto return_results;
+               }
+
+               Debug( LDAP_DEBUG_TRACE,
+                      "ldbm_back_modrdn: wr to new parent OK np=%p, id=%d\n",
+                      np, np->e_id, 0 );
+           
+               /* check newSuperior for "children" acl */
+               if ( !access_allowed( be, conn, op, np, "children", NULL,
+                                     ACL_WRITE ) )
+               {
+                       Debug( LDAP_DEBUG_TRACE,
+                              "ldbm_back_modrdn: no wr to newSup children\n",
+                              0, 0, 0 );
+                       send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
+                               NULL, NULL, NULL, NULL );
+                       goto return_results;
+               }
+
+               Debug( LDAP_DEBUG_TRACE,
+                      "ldbm_back_modrdn: wr to new parent's children OK\n",
+                      0, 0 , 0 );
+
+
+               new_parent_dn = np_dn;
+
+       }
+       
+       /* Build target dn and make sure target entry doesn't exist already. */
+
+       build_new_dn( &new_dn, e->e_dn, new_parent_dn, newrdn ); 
+
+
+       new_ndn = ch_strdup( new_dn );
+       (void) dn_normalize_case( new_ndn );
+
+       Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n",
+              new_ndn, 0, 0 );
+
+       /* check for abandon */
+       ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
+       if ( op->o_abandon ) {
+               ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+               goto return_results;
+       }
+       ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+
+       if ( (bdb2i_dn2id ( be, new_ndn ) ) != NOID ) {
+               send_ldap_result( conn, op, LDAP_ALREADY_EXISTS,
+                       NULL, NULL, NULL, NULL );
+               goto return_results;
+       }
+
+       /* Get attribute type and attribute value of our new rdn, we will
+        * need to add that to our new entry
+        */
+
+       if ( (new_rdn_type = rdn_attr_type( newrdn )) == NULL ) {
+           
+               Debug( LDAP_DEBUG_TRACE,
+                      "ldbm_back_modrdn: can't figure out type of newrdn\n",
+                      0, 0, 0 );
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               goto return_results;            
+
+       }
+
+       if ( (new_rdn_val = rdn_attr_value( newrdn )) == NULL ) {
+           
+               Debug( LDAP_DEBUG_TRACE,
+                      "ldbm_back_modrdn: can't figure out val of newrdn\n",
+                      0, 0, 0 );
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               goto return_results;            
+
+       }
+
+       Debug( LDAP_DEBUG_TRACE,
+              "ldbm_back_modrdn: new_rdn_val=%s, new_rdn_type=%s\n",
+              new_rdn_val, new_rdn_type, 0 );
+
+       /* Retrieve the old rdn from the entry's dn */
+
+       if ( (old_rdn = dn_rdn( be, dn )) == NULL ) {
+
+               Debug( LDAP_DEBUG_TRACE,
+                      "ldbm_back_modrdn: can't figure out old_rdn from dn\n",
+                      0, 0, 0 );
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               goto return_results;            
+
+       }
+
+       if ( (old_rdn_type = rdn_attr_type( old_rdn )) == NULL ) {
+           
+               Debug( LDAP_DEBUG_TRACE,
+                      "ldbm_back_modrdn: can't figure out the old_rdn type\n",
+                      0, 0, 0 );
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               goto return_results;            
+               
+       }
+       
+       if ( strcasecmp( old_rdn_type, new_rdn_type ) != 0 ) {
+
+           /* Not a big deal but we may say something */
+           Debug( LDAP_DEBUG_TRACE,
+                  "ldbm_back_modrdn: old_rdn_type=%s, new_rdn_type=%s!\n",
+                  old_rdn_type, new_rdn_type, 0 );
+           
+       }               
+
+#ifdef DNS_DN
+       if ( dn_type( old_rdn ) == DN_X500 ) {
+#endif
+
+               Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: DN_X500\n",
+                      0, 0, 0 );
+
+               /* Add new attribute value to the entry.
+                */
+
+               add_bvals[0] = &add_bv;         /* Array of bervals */
+               add_bvals[1] = NULL;
+
+               add_bv.bv_val = new_rdn_val;
+               add_bv.bv_len = strlen(new_rdn_val);
+               
+               mod[0].ml_type = new_rdn_type;  
+               mod[0].ml_bvalues = add_bvals;
+               mod[0].ml_op = LDAP_MOD_SOFTADD;
+               mod[0].ml_next = NULL;
+               
+               Debug( LDAP_DEBUG_TRACE,
+                      "ldbm_back_modrdn: adding new rdn attr val =%s\n",
+                      new_rdn_val, 0, 0 );
+               
+               /* Remove old rdn value if required */
+
+               if (deleteoldrdn) {
+
+                       del_bvals[0] = &del_bv;         /* Array of bervals */
+                       del_bvals[1] = NULL;
+                       /* Get value of old rdn */
+       
+                       if ((old_rdn_val = rdn_attr_value( old_rdn ))
+                           == NULL) {
+                           
+                               Debug( LDAP_DEBUG_TRACE,
+                                      "ldbm_back_modrdn: can't figure out old_rdn_val from old_rdn\n",
+                                      0, 0, 0 );
+                               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                                       NULL, NULL, NULL, NULL );
+                               goto return_results;            
+
+
+                       }
+
+                       /* Remove old value of rdn as an attribute. */
+                   
+                       del_bv.bv_val = old_rdn_val;
+                       del_bv.bv_len = strlen(old_rdn_val);
+                       
+                       mod[0].ml_next = &mod[1];
+                       mod[1].ml_type = old_rdn_type;  
+                       mod[1].ml_bvalues = del_bvals;
+                       mod[1].ml_op = LDAP_MOD_DELETE;
+                       mod[1].ml_next = NULL;
+
+
+                       Debug( LDAP_DEBUG_TRACE,
+                              "ldbm_back_modrdn: removing old_rdn_val=%s\n",
+                              old_rdn_val, 0, 0 );
+               
+               }/* if (deleteoldrdn) */
+
+#ifdef DNS_DN
+       } else {
+           
+
+               Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: DNS DN\n",
+                      0, 0, 0 );
+               /* XXXV3: not sure of what to do here */
+               Debug( LDAP_DEBUG_TRACE,
+                      "ldbm_back_modrdn: not fully implemented...\n",
+                      0, 0, 0 );  
+
+       }
+#endif
+
+       /* check for abandon */
+       ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
+       if ( op->o_abandon ) {
+               ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+               goto return_results;
+       }
+       ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+
+       /* delete old one */
+       if ( bdb2i_dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               goto return_results;
+       }
+
+       (void) bdb2i_cache_delete_entry( &li->li_cache, e );
+
+       free( e->e_dn );
+       free( e->e_ndn );
+       e->e_dn = new_dn;
+       e->e_ndn = new_ndn;
+       new_dn = NULL;
+       new_ndn = NULL;
+
+       /* add new one */
+       if ( bdb2i_dn2id_add( be,  e->e_ndn, e->e_id ) != 0 ) {
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               goto return_results;
+       }
+
+       /* modify memory copy of entry */
+       if ( bdb2i_back_modify_internal( be, conn, op, dn, &mod[0], e )
+            != 0 ) {
+           
+               goto return_results;
+                       
+       }
+       
+       (void) bdb2i_cache_update_entry( &li->li_cache, e );
+
+       /* NOTE: after this you must not free new_dn or new_ndn!
+        * They are used by cache.
+        */
+
+       /* id2entry index */
+       if ( bdb2i_id2entry_add( be, e ) != 0 ) {
+               entry_free( e );
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               goto return_results;
+       }
+
+       send_ldap_result( conn, op, LDAP_SUCCESS,
+               NULL, NULL, NULL, NULL );
+       rc = 0;
+
+return_results:
+       if( new_dn != NULL ) free( new_dn );
+       if( new_ndn != NULL ) free( new_ndn );
+
+       /* NOTE:
+        * new_dn and new_ndn are not deallocated because they are used by
+        * the cache entry.
+        */
+       if( p_dn != NULL ) free( p_dn );
+       if( p_ndn != NULL ) free( p_ndn );
+
+       /* LDAP v2 supporting correct attribute handling. */
+       if( new_rdn_type != NULL ) free(new_rdn_type);
+       if( new_rdn_val != NULL ) free(new_rdn_val);
+       if( old_rdn != NULL ) free(old_rdn);
+       if( old_rdn_type != NULL ) free(old_rdn_type);
+       if( old_rdn_val != NULL ) free(old_rdn_val);
+
+       /* LDAP v3 Support */
+       if ( np_dn != NULL ) free( np_dn );
+       if ( np_ndn != NULL ) free( np_ndn );
+
+       if( p != NULL ) {
+               /* free parent and writer lock */
+               bdb2i_cache_return_entry_w( &li->li_cache, p );
+
+       }
+
+       /* free entry and writer lock */
+       bdb2i_cache_return_entry_w( &li->li_cache, e );
+       return( rc );
+}
+
+
+int
+bdb2_back_modrdn(
+    BackendDB  *be,
+    Connection *conn,
+    Operation  *op,
+    char       *dn,
+    char       *newrdn,
+    int                deleteoldrdn,
+    char       *newSuperior
+)
+{
+       DB_LOCK         lock;
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( be->bd_info, &time1 );
+
+       if ( bdb2i_enter_backend_w( &lock ) != 0 ) {
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               return( -1 );
+
+       }
+
+       ret = bdb2i_back_modrdn_internal( be, conn, op, dn,
+                                       newrdn, deleteoldrdn,
+                                       newSuperior );
+
+       (void) bdb2i_leave_backend_w( lock );
+       bdb2i_stop_timing( be->bd_info, time1, "MODRDN", conn, op );
+
+       return( ret );
+}
+
+
index 91cb5e360aace0b902a0edb5feaf1b0a2716365b..c00c67d11d9272af790ac0b9cc87f6a0dfad42d6 100644 (file)
@@ -1,4 +1,5 @@
 /* id.c - keep track of the next id to be given out */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
index 8dba543e7cad77f71a1618c1e69aea42e1b97694..55f87a63d3e16e3e069171085a9358374b239988 100644 (file)
@@ -1,4 +1,5 @@
 /* porter.c - port functions of the bdb2 backend */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
index 7f1042202d171b52b09dd5de786ef7a42fc2f3b9..befba8b8abc33e1596444301a06c6dd304358a68 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 #ifndef _PROTO_BACK_BDB2
 #define _PROTO_BACK_BDB2
 
@@ -37,7 +38,8 @@ Entry * bdb2i_deref_r LDAP_P((
 
 void bdb2i_attr_masks LDAP_P(( struct ldbminfo *li, char *type, int *indexmask,
  int *syntaxmask ));
-void bdb2i_attr_index_config LDAP_P(( struct ldbminfo *li, char *fname,
+void bdb2i_attr_index_config LDAP_P(( struct ldbminfo *li,
+ const char *fname,
  int lineno, int argc, char **argv, int init ));
 
 /*
@@ -52,7 +54,7 @@ void bdb2i_cache_return_entry_rw LDAP_P(( struct cache *cache, Entry *e,
 #define bdb2i_cache_return_entry_w(c, e) bdb2i_cache_return_entry_rw((c), (e), 1)
 
 ID bdb2i_cache_find_entry_dn2id LDAP_P(( BackendDB *be, struct cache *cache,
- char *dn ));
+ const char *dn ));
 Entry * bdb2i_cache_find_entry_id LDAP_P(( struct cache *cache, ID id, int rw ));
 int bdb2i_cache_delete_entry LDAP_P(( struct cache *cache, Entry *e ));
 
@@ -73,19 +75,19 @@ int bdb2i_cache_delete LDAP_P(( struct dbcache *db, Datum key ));
  * dn2id.c
  */
 
-int bdb2i_dn2id_add LDAP_P(( BackendDB *be, char *dn, ID id ));
-ID bdb2i_dn2id LDAP_P(( BackendDB *be, char *dn ));
-int bdb2i_dn2id_delete LDAP_P(( BackendDB *be, char *dn ));
+int bdb2i_dn2id_add LDAP_P(( BackendDB *be, const char *dn, ID id ));
+ID bdb2i_dn2id LDAP_P(( BackendDB *be, const char *dn ));
+int bdb2i_dn2id_delete LDAP_P(( BackendDB *be, const char *dn, ID id ));
 
 ID_BLOCK *
 bdb2i_dn2idl LDAP_P((
     BackendDB  *be,
-    char       *dn,
+    const char *dn,
        int     prefix ));
 
 Entry * bdb2i_dn2entry_rw LDAP_P((
        BackendDB *be,
-       char *dn,
+       const char *dn,
        Entry **matched,
        int rw ));
 
index 9b5dc6d3de2adcb7cb74e3a55169482e432c254d..4bec697151f942d1d814c59bc87c5a00047e0c94 100644 (file)
@@ -1,4 +1,5 @@
 /* search.c - bdb2 backend search function */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
diff --git a/servers/slapd/back-bdb2/startup.c b/servers/slapd/back-bdb2/startup.c
new file mode 100644 (file)
index 0000000..3bf3b09
--- /dev/null
@@ -0,0 +1,260 @@
+/* startup.c - startup/shutdown bdb2 backend */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#ifdef HAVE_DIRECT_H
+#include <direct.h>
+#endif
+
+#include "slap.h"
+#include "back-bdb2.h"
+
+#include "db.h"
+
+static void remove_old_locks( char *home );
+
+
+static void
+bdb2i_db_errcall( const char *prefix, char *message )
+{
+       Debug( LDAP_DEBUG_ANY, "bdb2_db_errcall(): %s %s", prefix, message, 0 );
+}
+
+
+/*  startup/shutdown per backend type  */
+
+static int
+bdb2i_back_startup_internal(
+    BackendInfo        *bi
+)
+{
+       struct ldbtype  *lty = (struct ldbtype *) bi->bi_private;
+       u_int32_t               envFlags;
+       int             err      = 0;
+       char            *home;
+
+       /*  set the flags for a full-feldged transaction schema  */
+       envFlags = ( DB_CREATE | DB_THREAD | DB_INIT_TXN | DB_INIT_LOG |
+                                       DB_INIT_LOCK | DB_INIT_MPOOL );
+
+       /*  make sure, dbhome is an absolute path  */
+       if ( *lty->lty_dbhome != *LDAP_DIRSEP ) {
+               char   cwd[MAXPATHLEN];
+
+               (void) getcwd( cwd, MAXPATHLEN );
+               sprintf( cwd, "%s" LDAP_DIRSEP "%s",
+                       cwd, lty->lty_dbhome );
+               free( lty->lty_dbhome );
+               lty->lty_dbhome = ch_strdup( cwd );
+
+       }
+       home = lty->lty_dbhome;
+
+       /*  general initialization of the environment  */
+       memset( &bdb2i_dbEnv, 0, sizeof( DB_ENV ));
+       bdb2i_dbEnv.db_errcall = bdb2i_db_errcall;
+       bdb2i_dbEnv.db_errpfx  = "==>";
+
+       /*  initialize the lock subsystem  */
+       bdb2i_dbEnv.lk_max     = 0;
+
+       /*  remove old locking tables  */
+       remove_old_locks( home );
+
+       /*  initialize the mpool subsystem  */
+       bdb2i_dbEnv.mp_size   = lty->lty_mpsize;
+
+       /*  now do the db_appinit  */
+       if ( ( err = db_appinit( home, NULL, &bdb2i_dbEnv, envFlags )) ) {
+               char  error[BUFSIZ];
+
+               if ( err < 0 ) sprintf( error, "%ld\n", (long) err );
+               else           sprintf( error, "%s\n", strerror( err ));
+
+               Debug( LDAP_DEBUG_ANY,
+                               "bdb2i_back_startup(): FATAL error in db_appinit() : %s\n",
+                               error, 0, 0 );
+               return( 1 );
+
+       }
+
+       return 0;
+}
+
+
+static int
+bdb2i_back_shutdown_internal(
+    BackendInfo        *bi
+)
+{
+       struct ldbtype  *lty = (struct ldbtype *) bi->bi_private;
+       int              err;
+
+       /*  remove old locking tables  */
+       bdb2i_dbEnv.db_errpfx  = "bdb2i_back_shutdown(): lock_unlink:";
+       if ( ( err = lock_unlink( NULL, 1, &bdb2i_dbEnv )) != 0 )
+               Debug( LDAP_DEBUG_ANY, "bdb2i_back_shutdown(): lock_unlink: %s\n",
+                                       strerror( err ), 0, 0);
+
+       /*  remove old memory pool  */
+       bdb2i_dbEnv.db_errpfx  = "bdb2i_back_shutdown(): memp_unlink:";
+       if ( ( err = memp_unlink( NULL, 1, &bdb2i_dbEnv )) != 0 )
+               Debug( LDAP_DEBUG_ANY, "bdb2i_back_shutdown(): memp_unlink: %s\n",
+                                       strerror( err ), 0, 0);
+
+       (void) db_appexit( &bdb2i_dbEnv );
+
+       return( 0 );
+}
+
+
+int
+bdb2i_back_startup(
+    BackendInfo        *bi
+)
+{
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( bi, &time1 );
+
+       ret = bdb2i_back_startup_internal( bi );
+       bdb2i_stop_timing( bi, time1, "BE-START", NULL, NULL );
+
+       return( ret );
+}
+
+
+int
+bdb2i_back_shutdown(
+    BackendInfo        *bi
+)
+{
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( bi, &time1 );
+
+       ret = bdb2i_back_shutdown_internal( bi );
+       bdb2i_stop_timing( bi, time1, "BE-SHUTDOWN", NULL, NULL );
+
+       return( ret );
+}
+
+
+/*  startup/shutdown per backend database  */
+
+static int
+bdb2i_back_db_startup_internal(
+    BackendDB  *be
+)
+{
+       struct ldbminfo  *li = (struct ldbminfo *) be->be_private;
+
+       /*  if the data directory is not an absolute path, have it relative
+        to the current working directory (which should not be configured !)  */
+       if ( *li->li_directory != *LDAP_DIRSEP ) {
+               char   cwd[MAXPATHLEN];
+
+               (void) getcwd( cwd, MAXPATHLEN );
+               sprintf( cwd, "%s" LDAP_DIRSEP "%s",
+                       cwd, li->li_directory );
+
+               free( li->li_directory );
+               li->li_directory = ch_strdup( cwd );
+
+       }
+
+       /*  if there are more index files, add them to the DB file list  */
+       if ( bdb2i_check_additional_attr_index( li ) != 0 )
+               return 1;
+
+       /*  now open all DB files  */
+       if ( bdb2i_txn_open_files( be ) != 0 )
+               return 1;
+
+       return 0;
+}
+
+
+static int
+bdb2i_back_db_shutdown_internal(
+    BackendDB  *be
+)
+{
+       return 0;
+}
+
+
+int
+bdb2_back_db_startup(
+    BackendDB  *be
+)
+{
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( be->bd_info, &time1 );
+
+       ret = bdb2i_back_db_startup_internal( be );
+       bdb2i_stop_timing( be->bd_info, time1, "DB-START", NULL, NULL );
+
+       return( ret );
+}
+
+
+int
+bdb2_back_db_shutdown(
+    BackendDB  *be
+)
+{
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( be->bd_info, &time1 );
+
+       ret = bdb2i_back_db_shutdown_internal( be );
+       bdb2i_stop_timing( be->bd_info, time1, "DB-SHUTDOWN", NULL, NULL );
+
+       return( ret );
+}
+
+
+static void
+remove_old_locks( char *home )
+{
+       DB_ENV  dbEnv;
+       int     err;
+
+       memset( &dbEnv, 0, sizeof( DB_ENV ));
+       dbEnv.db_errcall = bdb2i_db_errcall;
+       dbEnv.db_errpfx  = "remove_old_locks(): db_appinit:";
+       dbEnv.lk_max     = 0;
+
+       if ( ( err = db_appinit( home, NULL, &dbEnv, 0 )) != 0 )
+               Debug( LDAP_DEBUG_ANY, "remove_old_locks(): db_appinit: %s\n",
+                                       strerror( err ), 0, 0);
+
+       dbEnv.db_errpfx  = "remove_old_locks(): lock_unlink:";
+       if ( ( err = lock_unlink( NULL, 1, &dbEnv )) != 0 )
+               Debug( LDAP_DEBUG_ANY, "remove_old_locks(): lock_unlink: %s\n",
+                                       strerror( err ), 0, 0);
+
+       dbEnv.db_errpfx  = "remove_old_locks(): db_appexit:";
+       if ( ( err = db_appexit( &dbEnv )) != 0 )
+               Debug( LDAP_DEBUG_ANY, "remove_old_locks(): db_appexit: %s\n",
+                                       strerror( err ), 0, 0);
+
+}
+
+
diff --git a/servers/slapd/back-bdb2/timing.c b/servers/slapd/back-bdb2/timing.c
new file mode 100644 (file)
index 0000000..c1d6605
--- /dev/null
@@ -0,0 +1,70 @@
+/* timing.c - timing bdb2 backend */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+
+
+static char *
+bdb2i_elapsed( struct timeval firsttime,  struct timeval secondtime )
+{
+    long int elapsedmicrosec, elapsedsec;
+    char elapsed_string[BUFSIZ];
+    
+    elapsedsec = secondtime.tv_sec - firsttime.tv_sec;
+    elapsedmicrosec = secondtime.tv_usec - firsttime.tv_usec;
+    if(elapsedmicrosec < 0) {
+        elapsedmicrosec += 1000000;
+        elapsedsec -= 1;
+    }
+
+    sprintf( elapsed_string, "%ld.%.6ld", elapsedsec, elapsedmicrosec );
+    return( ch_strdup( elapsed_string ));
+}
+
+
+void
+bdb2i_uncond_start_timing(
+       struct timeval  *time1
+)
+{
+       gettimeofday( time1, NULL );
+}
+
+
+void
+bdb2i_uncond_stop_timing(
+       struct timeval  time1,
+       char            *func,
+       Connection      *conn,
+       Operation       *op,
+       int             level
+)
+{
+       struct timeval  time2;
+       char            *elapsed_time;
+       char            buf[BUFSIZ];
+
+       *buf = '\0';
+
+       gettimeofday( &time2, NULL);
+       elapsed_time = bdb2i_elapsed( time1, time2 );
+
+       if ( conn != NULL ) sprintf( buf, "conn=%d ", conn->c_connid );
+       if ( op != NULL )   sprintf( buf, "%sop=%d ", buf, op->o_opid );
+
+       Debug( level, "%s%s elapsed=%s\n", buf, func, elapsed_time );
+
+       free( elapsed_time );
+
+}
+
+
index 66b018a03a079ff20df3b23cafff1bdaff0b0290..662381dfb09f8b4b4929828585c2f711e5ccc032 100644 (file)
@@ -1,4 +1,5 @@
 /* tools.c - tools for slap tools */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -184,7 +185,7 @@ ID bdb2_tool_entry_put(
        rc = bdb2i_cache_store( id2entry, key, data, LDBM_REPLACE );
 
        if( rc != 0 ) {
-               (void) bdb2i_dn2id_delete( be, e->e_ndn );
+               (void) bdb2i_dn2id_delete( be, e->e_ndn, e->e_id );
                return NOID;
        }
 
index 747a754ccef2c08000e3a97497bb1c3f9d7e9181..2a711385d13e8c217137bafaf7550618f025ac3c 100644 (file)
@@ -1,4 +1,5 @@
 /* txn.c - TP support functions of the bdb2 backend */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
index 93a43ebc2116874978a13c3a8110f1cf64df67c1..9093127ae28622e0b492854ddca7ba2bf5cc8c88 100644 (file)
@@ -1,4 +1,5 @@
 /* txn.h - Header for TP support functions of the bdb2 backend */
+/* $OpenLDAP$ */
 
 #ifndef _BDB2_TXN_H_
 #define _BDB2_TXN_H_
@@ -16,7 +17,6 @@
 #include <ac/time.h>
 #include <ac/unistd.h>
 
-#include "ldap_defaults.h"
 #include "slap.h"
 #include "back-bdb2.h"
 
diff --git a/servers/slapd/back-bdb2/unbind.c b/servers/slapd/back-bdb2/unbind.c
new file mode 100644 (file)
index 0000000..b2c179d
--- /dev/null
@@ -0,0 +1,39 @@
+/* unbind.c - handle an ldap unbind operation */
+/* $OpenLDAP$ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+
+static int
+bdb2i_back_unbind_internal(
+       BackendDB     *be,
+       Connection  *conn,
+       Operation   *op
+)
+{
+       return( 0 );
+}
+
+
+int
+bdb2_back_unbind(
+       BackendDB     *be,
+       Connection  *conn,
+       Operation   *op
+)
+{
+       struct timeval  time1;
+       int             ret;
+
+       bdb2i_start_timing( be->bd_info, &time1 );
+
+       ret = bdb2i_back_unbind_internal( be, conn, op );
+       bdb2i_stop_timing( be->bd_info, time1, "UNBIND", conn, op );
+
+       return( ret );
+}
index 208c16785f1231732e7d6efb4c14640e8086d8ac..fe015081fca66f321aa684010a1ac0b4c4443cc8 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 SRCS   = init.c config.c search.c bind.c unbind.c add.c compare.c \
                delete.c modify.c modrdn.c
 OBJS   = init.lo config.lo search.lo bind.lo unbind.lo add.lo compare.lo \
diff --git a/servers/slapd/back-ldap/add.c b/servers/slapd/back-ldap/add.c
new file mode 100644 (file)
index 0000000..2ff2b75
--- /dev/null
@@ -0,0 +1,79 @@
+/* add.c - ldap backend add function */
+/* $OpenLDAP$ */
+
+/*
+ * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
+ * 
+ * Permission is granted to anyone to use this software for any purpose
+ * on any computer system, and to alter it and redistribute it, subject
+ * to the following restrictions:
+ * 
+ * 1. The author is not responsible for the consequences of use of this
+ *    software, no matter how awful, even if they arise from flaws in it.
+ * 
+ * 2. The origin of this software must not be misrepresented, either by
+ *    explicit claim or by omission.  Since few users ever read sources,
+ *    credits should appear in the documentation.
+ * 
+ * 3. Altered versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.  Since few users
+ *    ever read sources, credits should appear in the documentation.
+ * 
+ * 4. This notice may not be removed or altered.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-ldap.h"
+
+int
+ldap_back_add(
+    Backend    *be,
+    Connection *conn,
+    Operation  *op,
+    Entry      *e
+)
+{
+       struct ldapinfo *li = (struct ldapinfo *) be->be_private;
+       struct ldapconn *lc;
+       int i;
+       Attribute *a;
+       LDAPMod **attrs;
+
+       lc = ldap_back_getconn(li, conn, op);
+       if (!lc)
+               return( -1 );
+
+       if (!lc->bound) {
+               ldap_back_dobind(lc, op);
+               if (!lc->bound)
+                       return( -1 );
+       }
+
+       /* Count number of attributes in entry */
+       for (i=1, a=e->e_attrs; a; i++, a=a->a_next)
+               ;
+       
+       /* Create array of LDAPMods for ldap_add() */
+       attrs = (LDAPMod **)ch_malloc(sizeof(LDAPMod *)*i);
+       attrs[i-1] = 0;
+
+       for (i=0, a=e->e_attrs; a; i++, a=a->a_next) {
+               attrs[i] = (LDAPMod *)ch_malloc(sizeof(LDAPMod));
+               attrs[i]->mod_op = LDAP_MOD_BVALUES;
+               attrs[i]->mod_type = a->a_type;
+               attrs[i]->mod_vals.modv_bvals = a->a_vals;
+       }
+
+       ldap_add_s(lc->ld, e->e_dn, attrs);
+       for (--i; i>= 0; --i)
+               free(attrs[i]);
+       free(attrs);
+       return( ldap_back_op_result( lc, op ));
+}
diff --git a/servers/slapd/back-ldap/back-ldap.h b/servers/slapd/back-ldap/back-ldap.h
new file mode 100644 (file)
index 0000000..f3063a8
--- /dev/null
@@ -0,0 +1,58 @@
+/* back-ldap.h - ldap backend header file */
+/* $OpenLDAP$ */
+
+/*
+ * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
+ * 
+ * Permission is granted to anyone to use this software for any purpose
+ * on any computer system, and to alter it and redistribute it, subject
+ * to the following restrictions:
+ * 
+ * 1. The author is not responsible for the consequences of use of this
+ *    software, no matter how awful, even if they arise from flaws in it.
+ * 
+ * 2. The origin of this software must not be misrepresented, either by
+ *    explicit claim or by omission.  Since few users ever read sources,
+ *    credits should appear in the documentation.
+ * 
+ * 3. Altered versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.  Since few users
+ *    ever read sources, credits should appear in the documentation.
+ * 
+ * 4. This notice may not be removed or altered.
+ */
+
+#ifndef SLAPD_LDAP_H
+#define SLAPD_LDAP_H
+
+#include "external.h"
+
+LDAP_BEGIN_DECL
+
+struct slap_conn;
+struct slap_op;
+
+struct ldapconn {
+       struct ldapconn *next;
+       struct slap_conn        *conn;
+       LDAP            *ld;
+       int             bound;
+};
+
+struct ldapinfo {
+       char *host;
+       int port;
+       char *suffix;
+       ldap_pvt_thread_mutex_t         conn_mutex;
+       struct ldapconn *lcs;
+};
+
+struct ldapconn *ldap_back_getconn(struct ldapinfo *li, struct slap_conn *conn,
+       struct slap_op *op);
+void ldap_back_dobind(struct ldapconn *lc, Operation *op);
+int ldap_back_op_result(struct ldapconn *lc, Operation *op);
+int    back_ldap_LTX_init_module(int argc, char *argv[]);
+
+LDAP_END_DECL
+
+#endif
diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c
new file mode 100644 (file)
index 0000000..45f9df5
--- /dev/null
@@ -0,0 +1,122 @@
+/* bind.c - ldap backend bind function */
+/* $OpenLDAP$ */
+
+/*
+ * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
+ * 
+ * Permission is granted to anyone to use this software for any purpose
+ * on any computer system, and to alter it and redistribute it, subject
+ * to the following restrictions:
+ * 
+ * 1. The author is not responsible for the consequences of use of this
+ *    software, no matter how awful, even if they arise from flaws in it.
+ * 
+ * 2. The origin of this software must not be misrepresented, either by
+ *    explicit claim or by omission.  Since few users ever read sources,
+ *    credits should appear in the documentation.
+ * 
+ * 3. Altered versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.  Since few users
+ *    ever read sources, credits should appear in the documentation.
+ * 
+ * 4. This notice may not be removed or altered.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "slap.h"
+#include "back-ldap.h"
+
+int
+ldap_back_bind(
+    Backend            *be,
+    Connection         *conn,
+    Operation          *op,
+    char               *dn,
+    int                        method,
+       char            *mech,
+    struct berval      *cred,
+       char            **edn
+)
+{
+       struct ldapinfo *li = (struct ldapinfo *) be->be_private;
+       struct ldapconn *lc;
+
+       *edn = NULL;
+
+       lc = ldap_back_getconn(li, conn, op);
+       if (!lc)
+               return( -1 );
+
+       if (ldap_bind_s(lc->ld, dn, cred->bv_val, method) != LDAP_SUCCESS)
+               return( ldap_back_op_result(lc, op) );
+
+       lc->bound = 1;
+       return( 0 );
+}
+
+struct ldapconn *
+ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op)
+{
+       struct ldapconn *lc;
+       LDAP *ld;
+
+       ldap_pvt_thread_mutex_lock( &li->conn_mutex );
+       for (lc = li->lcs; lc; lc=lc->next)
+               if (lc->conn == conn)
+                       break;
+       ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
+
+       /* Looks like we didn't get a bind. Open a new session... */
+       if (!lc) {
+               ld = ldap_init(li->host, li->port);
+               if (!ld) {
+                       send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                               NULL, "ldap_init failed", NULL, NULL );
+                       return( NULL );
+               }
+               lc = (struct ldapconn *)ch_malloc(sizeof(struct ldapconn));
+               lc->conn = conn;
+               lc->ld = ld;
+               lc->bound = 0;
+               ldap_pvt_thread_mutex_lock( &li->conn_mutex );
+               lc->next = li->lcs;
+               li->lcs = lc;
+               ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
+       }
+       return( lc );
+}
+
+void
+ldap_back_dobind(struct ldapconn *lc, Operation *op)
+{
+       if (lc->bound)
+               return;
+
+       if (ldap_bind_s(lc->ld, lc->conn->c_cdn, NULL, LDAP_AUTH_SIMPLE) !=
+               LDAP_SUCCESS)
+               ldap_back_op_result(lc, op);
+       else
+               lc->bound = 1;
+}
+
+int
+ldap_back_op_result(struct ldapconn *lc, Operation *op)
+{
+       int err;
+       char *msg;
+       char *match;
+
+       ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, &err);
+       ldap_get_option(lc->ld, LDAP_OPT_ERROR_STRING, &msg);
+       ldap_get_option(lc->ld, LDAP_OPT_MATCHED_DN, &match);
+       send_ldap_result( lc->conn, op, err, match, msg, NULL, NULL );
+       free(match);
+       free(msg);
+       return( (err==LDAP_SUCCESS) ? 0 : -1 );
+}
diff --git a/servers/slapd/back-ldap/compare.c b/servers/slapd/back-ldap/compare.c
new file mode 100644 (file)
index 0000000..206437d
--- /dev/null
@@ -0,0 +1,59 @@
+/* compare.c - ldap backend compare function */
+/* $OpenLDAP$ */
+
+/*
+ * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
+ * 
+ * Permission is granted to anyone to use this software for any purpose
+ * on any computer system, and to alter it and redistribute it, subject
+ * to the following restrictions:
+ * 
+ * 1. The author is not responsible for the consequences of use of this
+ *    software, no matter how awful, even if they arise from flaws in it.
+ * 
+ * 2. The origin of this software must not be misrepresented, either by
+ *    explicit claim or by omission.  Since few users ever read sources,
+ *    credits should appear in the documentation.
+ * 
+ * 3. Altered versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.  Since few users
+ *    ever read sources, credits should appear in the documentation.
+ * 
+ * 4. This notice may not be removed or altered.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-ldap.h"
+
+int
+ldap_back_compare(
+    Backend    *be,
+    Connection *conn,
+    Operation  *op,
+    char       *dn,
+    Ava                *ava
+)
+{
+       struct ldapinfo *li = (struct ldapinfo *) be->be_private;
+       struct ldapconn *lc;
+
+       lc = ldap_back_getconn(li, conn, op);
+       if (!lc)
+               return( -1 );
+
+       if (!lc->bound) {
+               ldap_back_dobind(lc, op);
+               if (!lc->bound)
+                       return( -1 );
+       }
+
+       ldap_compare_s( lc->ld, dn, ava->ava_type, ava->ava_value.bv_val );
+       return( ldap_back_op_result( lc, op ) );
+}
diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c
new file mode 100644 (file)
index 0000000..6326116
--- /dev/null
@@ -0,0 +1,74 @@
+/* config.c - ldap backend configuration file routine */
+/* $OpenLDAP$ */
+
+/*
+ * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
+ * 
+ * Permission is granted to anyone to use this software for any purpose
+ * on any computer system, and to alter it and redistribute it, subject
+ * to the following restrictions:
+ * 
+ * 1. The author is not responsible for the consequences of use of this
+ *    software, no matter how awful, even if they arise from flaws in it.
+ * 
+ * 2. The origin of this software must not be misrepresented, either by
+ *    explicit claim or by omission.  Since few users ever read sources,
+ *    credits should appear in the documentation.
+ * 
+ * 3. Altered versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.  Since few users
+ *    ever read sources, credits should appear in the documentation.
+ * 
+ * 4. This notice may not be removed or altered.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-ldap.h"
+
+int
+ldap_back_db_config(
+    BackendDB  *be,
+    const char *fname,
+    int                lineno,
+    int                argc,
+    char       **argv
+)
+{
+       struct ldapinfo *li = (struct ldapinfo *) be->be_private;
+       char *port;
+
+       if ( li == NULL ) {
+               fprintf( stderr, "%s: line %d: ldap backend info is null!\n",
+                   fname, lineno );
+               return( 1 );
+       }
+
+       /* server address to query */
+       if ( strcasecmp( argv[0], "server" ) == 0 ) {
+               if (argc != 2) {
+                       fprintf( stderr,
+       "%s: line %d: missing address in \"server <address>\" line\n",
+                           fname, lineno );
+                       return( 1 );
+               }
+               port=strchr(argv[1],':');
+               if (port) {
+                       *port++ = '\0';
+                       li->port = atoi(port);
+               }
+               li->host = ch_strdup(argv[1]);
+       /* anything else */
+       } else {
+               fprintf( stderr,
+"%s: line %d: unknown directive \"%s\" in ldap database definition (ignored)\n",
+                   fname, lineno, argv[0] );
+       }
+       return 0;
+}
diff --git a/servers/slapd/back-ldap/delete.c b/servers/slapd/back-ldap/delete.c
new file mode 100644 (file)
index 0000000..b5e00cc
--- /dev/null
@@ -0,0 +1,58 @@
+/* delete.c - ldap backend delete function */
+/* $OpenLDAP$ */
+
+/*
+ * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
+ * 
+ * Permission is granted to anyone to use this software for any purpose
+ * on any computer system, and to alter it and redistribute it, subject
+ * to the following restrictions:
+ * 
+ * 1. The author is not responsible for the consequences of use of this
+ *    software, no matter how awful, even if they arise from flaws in it.
+ * 
+ * 2. The origin of this software must not be misrepresented, either by
+ *    explicit claim or by omission.  Since few users ever read sources,
+ *    credits should appear in the documentation.
+ * 
+ * 3. Altered versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.  Since few users
+ *    ever read sources, credits should appear in the documentation.
+ * 
+ * 4. This notice may not be removed or altered.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-ldap.h"
+
+int
+ldap_back_delete(
+    Backend    *be,
+    Connection *conn,
+    Operation  *op,
+    char       *dn
+)
+{
+       struct ldapinfo *li = (struct ldapinfo *) be->be_private;
+       struct ldapconn *lc;
+
+       lc = ldap_back_getconn( li, conn, op );
+       if (!lc)
+               return( -1 );
+
+       if (!lc->bound) {
+               ldap_back_dobind(lc, op);
+               if (!lc->bound)
+                       return( -1 );
+       }
+
+       ldap_delete_s( lc->ld, dn );
+       return( ldap_back_op_result( lc, op ) );
+}
diff --git a/servers/slapd/back-ldap/external.h b/servers/slapd/back-ldap/external.h
new file mode 100644 (file)
index 0000000..58b5e77
--- /dev/null
@@ -0,0 +1,56 @@
+/* $OpenLDAP$ */
+#ifndef _LDAP_EXTERNAL_H
+#define _LDAP_EXTERNAL_H
+
+LDAP_BEGIN_DECL
+
+extern int     ldap_back_initialize LDAP_P(( BackendInfo *bi ));
+extern int     ldap_back_open LDAP_P(( BackendInfo *bi ));
+extern int     ldap_back_close LDAP_P(( BackendInfo *bi ));
+extern int     ldap_back_destroy LDAP_P(( BackendInfo *bi ));
+
+extern int     ldap_back_db_init LDAP_P(( BackendDB *bd ));
+extern int     ldap_back_db_destroy LDAP_P(( BackendDB *bd ));
+
+extern int     ldap_back_db_config LDAP_P(( BackendDB *bd,
+       const char *fname, int lineno, int argc, char **argv ));
+
+extern int ldap_back_bind LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, int method, char* mech,
+       struct berval *cred, char** edn ));
+
+extern int     ldap_back_conn_destroy LDAP_P(( BackendDB *bd,
+       Connection *conn ));
+
+extern int     ldap_back_search LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *base, int scope, int deref, int sizelimit, int timelimit,
+       Filter *filter, char *filterstr, char **attrs, int attrsonly ));
+
+extern int     ldap_back_compare LDAP_P((BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, Ava   *ava ));
+
+extern int     ldap_back_modify LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, LDAPModList *ml ));
+
+extern int     ldap_back_modrdn LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, char*newrdn, int deleteoldrdn,
+        char *newSuperior ));
+
+extern int     ldap_back_add LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op, Entry *e ));
+
+extern int     ldap_back_delete LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op, char *dn ));
+
+extern int     ldap_back_abandon LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op, int msgid ));
+
+LDAP_END_DECL
+
+#endif /* _LDAP_EXTERNAL_H */
+
index ce0c020fa358655d9b6aac7ae61438f9f43853fe..e1d80f76e68bd9277e8b13414705f9eb881ddca7 100644 (file)
@@ -1,4 +1,5 @@
 /* init.c - initialize ldap backend */
+/* $OpenLDAP$ */
 
 /*
  * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c
new file mode 100644 (file)
index 0000000..c1b7df0
--- /dev/null
@@ -0,0 +1,71 @@
+/* modify.c - ldap backend modify function */
+/* $OpenLDAP$ */
+
+/*
+ * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
+ * 
+ * Permission is granted to anyone to use this software for any purpose
+ * on any computer system, and to alter it and redistribute it, subject
+ * to the following restrictions:
+ * 
+ * 1. The author is not responsible for the consequences of use of this
+ *    software, no matter how awful, even if they arise from flaws in it.
+ * 
+ * 2. The origin of this software must not be misrepresented, either by
+ *    explicit claim or by omission.  Since few users ever read sources,
+ *    credits should appear in the documentation.
+ * 
+ * 3. Altered versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.  Since few users
+ *    ever read sources, credits should appear in the documentation.
+ * 
+ * 4. This notice may not be removed or altered.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-ldap.h"
+
+int
+ldap_back_modify(
+    Backend    *be,
+    Connection *conn,
+    Operation  *op,
+    char       *dn,
+    LDAPModList        *ml
+)
+{
+       struct ldapinfo *li = (struct ldapinfo *) be->be_private;
+       struct ldapconn *lc;
+       LDAPMod **mods;
+       LDAPModList *m;
+       int i;
+
+       lc = ldap_back_getconn(li, conn, op);
+       if (!lc)
+               return( -1 );
+
+       if (!lc->bound) {
+               ldap_back_dobind(lc, op);
+               if (!lc->bound)
+                       return( -1 );
+       }
+
+       for (i=1, m=ml->ml_next; m; i++,m=m->ml_next)
+               ;
+       mods = (LDAPMod **)ch_malloc((i+1)*sizeof(LDAPMod *));
+       mods[i] = 0;
+
+       for (i=0, m=ml; m; i++, m=m->ml_next)
+               mods[i] = &m->ml_mod;
+
+       ldap_modify_s( lc->ld, dn, mods );
+       free(mods);     
+       return( ldap_back_op_result( lc, op ));
+}
diff --git a/servers/slapd/back-ldap/modrdn.c b/servers/slapd/back-ldap/modrdn.c
new file mode 100644 (file)
index 0000000..b2c4cec
--- /dev/null
@@ -0,0 +1,66 @@
+/* modrdn.c - ldap backend modrdn function */
+/* $OpenLDAP$ */
+
+/*
+ * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
+ * 
+ * Permission is granted to anyone to use this software for any purpose
+ * on any computer system, and to alter it and redistribute it, subject
+ * to the following restrictions:
+ * 
+ * 1. The author is not responsible for the consequences of use of this
+ *    software, no matter how awful, even if they arise from flaws in it.
+ * 
+ * 2. The origin of this software must not be misrepresented, either by
+ *    explicit claim or by omission.  Since few users ever read sources,
+ *    credits should appear in the documentation.
+ * 
+ * 3. Altered versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.  Since few users
+ *    ever read sources, credits should appear in the documentation.
+ * 
+ * 4. This notice may not be removed or altered.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "slap.h"
+#include "back-ldap.h"
+
+int
+ldap_back_modrdn(
+    Backend    *be,
+    Connection *conn,
+    Operation  *op,
+    char       *dn,
+    char       *newrdn,
+    int                deleteoldrdn,
+    char       *newSuperior
+)
+{
+       struct ldapinfo *li = (struct ldapinfo *) be->be_private;
+       struct ldapconn *lc;
+
+       lc = ldap_back_getconn( li, conn, op );
+       if (!lc)
+               return( -1 );
+
+       if (newSuperior) {
+               int version = LDAP_VERSION3;
+               ldap_set_option( lc->ld, LDAP_OPT_PROTOCOL_VERSION, &version);
+       }
+
+       if (!lc->bound) {
+               ldap_back_dobind(lc, op);
+               if (!lc->bound)
+                       return( -1 );
+       }
+
+       ldap_rename2_s( lc->ld, dn, newrdn, deleteoldrdn, newSuperior );
+       return( ldap_back_op_result( lc, op ) );
+}
diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c
new file mode 100644 (file)
index 0000000..8eb4a31
--- /dev/null
@@ -0,0 +1,179 @@
+/* search.c - ldap backend search function */
+/* $OpenLDAP$ */
+
+/*
+ * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
+ * 
+ * Permission is granted to anyone to use this software for any purpose
+ * on any computer system, and to alter it and redistribute it, subject
+ * to the following restrictions:
+ * 
+ * 1. The author is not responsible for the consequences of use of this
+ *    software, no matter how awful, even if they arise from flaws in it.
+ * 
+ * 2. The origin of this software must not be misrepresented, either by
+ *    explicit claim or by omission.  Since few users ever read sources,
+ *    credits should appear in the documentation.
+ * 
+ * 3. Altered versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.  Since few users
+ *    ever read sources, credits should appear in the documentation.
+ * 
+ * 4. This notice may not be removed or altered.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "slap.h"
+#include "back-ldap.h"
+
+static void ldap_send_entry( Backend *be, Operation *op, struct ldapconn *lc,
+                             LDAPMessage *e, char **attrs, int attrsonly );
+
+int
+ldap_back_search(
+    Backend    *be,
+    Connection *conn,
+    Operation  *op,
+    char       *base,
+    int                scope,
+    int                deref,
+    int                size,
+    int                time,
+    Filter     *filter,
+    char       *filterstr,
+    char       **attrs,
+    int                attrsonly
+)
+{
+       struct ldapinfo *li = (struct ldapinfo *) be->be_private;
+       struct ldapconn *lc;
+       struct timeval  tv;
+       LDAPMessage             *res, *e;
+       int                     i, rc, msgid, sres = LDAP_SUCCESS; 
+       char *match = NULL, *err = NULL;
+
+       lc = ldap_back_getconn(li, conn, op);
+       if (!lc)
+               return( -1 );
+
+       if (deref != -1)
+               ldap_set_option( lc->ld, LDAP_OPT_DEREF, (void *)&deref);
+       if (time != -1)
+               ldap_set_option( lc->ld, LDAP_OPT_TIMELIMIT, (void *)&time);
+       if (size != -1)
+               ldap_set_option( lc->ld, LDAP_OPT_SIZELIMIT, (void *)&size);
+       if (!lc->bound) {
+               ldap_back_dobind(lc, op);
+               if (!lc->bound)
+                       return( -1 );
+       }
+
+       if ((msgid = ldap_search(lc->ld, base, scope, filterstr, attrs,
+               attrsonly)) == -1)
+fail:          return( ldap_back_op_result(lc, op) );
+
+       /* We pull apart the ber result, stuff it into a slapd entry, and
+        * let send_search_entry stuff it back into ber format. Slow & ugly,
+        * but this is necessary for version matching, and for ACL processing.
+        */
+       
+       for (i=0, rc=0; rc != -1;
+               rc = ldap_result(lc->ld, LDAP_RES_ANY, 0, &tv, &res)) {
+               int ab;
+
+               /* check for abandon */
+               ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
+               ab = op->o_abandon;
+               ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+
+               if (ab) {
+                       ldap_abandon(lc->ld, msgid);
+               } else if (rc == 0) {
+                       tv.tv_sec = 0;
+                       tv.tv_usec = 100000;
+                       ldap_pvt_thread_yield();
+                       continue;
+               } else if (rc == LDAP_RES_SEARCH_ENTRY) {
+                       e = ldap_first_entry(lc->ld,res);
+                       ldap_send_entry(be, op, lc, e, attrs, attrsonly);
+                       i++;
+                       ldap_msgfree(res);
+               } else {
+                       sres = ldap_result2error(lc->ld, res, 1);
+                       ldap_get_option(lc->ld, LDAP_OPT_ERROR_STRING, &err);
+                       ldap_get_option(lc->ld, LDAP_OPT_MATCHED_DN, &match);
+                       rc = 0;
+               }
+               if (ab)
+                       return (0);
+               else if (rc == 0)
+                       break;
+       }
+
+       if (rc == -1)
+               goto fail;
+
+       send_search_result( conn, op, sres,
+               match, err, NULL, NULL, i );
+       if (match)
+               free(match);
+       if (err)
+               free(err);
+       return( 0 );
+}
+
+static void
+ldap_send_entry(
+       Backend *be,
+       Operation *op,
+       struct ldapconn *lc,
+       LDAPMessage *e,
+       char **attrs,
+       int attrsonly
+)
+{
+       char *a;
+       Entry ent;
+       BerElement *ber = NULL;
+       Attribute *attr, **attrp;
+       struct berval *dummy = NULL;
+
+       ent.e_dn = ldap_get_dn(lc->ld, e);
+       ent.e_ndn = ch_strdup( ent.e_dn);
+       (void) dn_normalize_case( ent.e_ndn );
+       ent.e_id = 0;
+       ent.e_attrs = 0;
+       ent.e_private = 0;
+       attrp = &ent.e_attrs;
+
+       for (a = ldap_first_attribute(lc->ld, e, &ber); a;
+               a = ldap_next_attribute(lc->ld, e, ber)) {
+               attr = (Attribute *)ch_malloc( sizeof(Attribute) );
+               attr->a_next = 0;
+               attr->a_type = ch_strdup(a);
+               attr->a_syntax = attr_syntax(a);
+               attr->a_vals = ldap_get_values_len(lc->ld, e, a);
+               if (!attr->a_vals)
+                       attr->a_vals = &dummy;
+               *attrp = attr;
+               attrp = &attr->a_next;
+       }
+       send_search_entry( be, lc->conn, op, &ent, attrs, attrsonly, NULL );
+       for (;ent.e_attrs;) {
+               attr=ent.e_attrs;
+               ent.e_attrs = attr->a_next;
+               free(attr->a_type);
+               if (attr->a_vals != &dummy)
+                       ber_bvecfree(attr->a_vals);
+               free(attr);
+       }
+       if (ber)
+               ber_free(ber,0);
+}
diff --git a/servers/slapd/back-ldap/unbind.c b/servers/slapd/back-ldap/unbind.c
new file mode 100644 (file)
index 0000000..ac1adcb
--- /dev/null
@@ -0,0 +1,62 @@
+/* unbind.c - ldap backend unbind function */
+/* $OpenLDAP$ */
+
+/*
+ * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
+ * 
+ * Permission is granted to anyone to use this software for any purpose
+ * on any computer system, and to alter it and redistribute it, subject
+ * to the following restrictions:
+ * 
+ * 1. The author is not responsible for the consequences of use of this
+ *    software, no matter how awful, even if they arise from flaws in it.
+ * 
+ * 2. The origin of this software must not be misrepresented, either by
+ *    explicit claim or by omission.  Since few users ever read sources,
+ *    credits should appear in the documentation.
+ * 
+ * 3. Altered versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.  Since few users
+ *    ever read sources, credits should appear in the documentation.
+ * 
+ * 4. This notice may not be removed or altered.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "slap.h"
+#include "back-ldap.h"
+
+int
+ldap_back_conn_destroy(
+    Backend            *be,
+    Connection         *conn
+)
+{
+       struct ldapinfo *li = (struct ldapinfo *) be->be_private;
+       struct ldapconn *lc, *lp;
+
+       ldap_pvt_thread_mutex_lock( &li->conn_mutex );
+       for (lc = li->lcs, lp = (struct ldapconn *)&li->lcs; lc;
+               lp=lc, lc=lc->next)
+               if (lc->conn == conn) {
+                       lp->next = lc->next;
+                       break;
+               }
+       ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
+
+       if (lc) {
+               if (lc->bound)
+                       ldap_unbind(lc->ld);
+               free(lc);
+       }
+
+       /* no response to unbind */
+
+       return 0;
+}
index 3a88ae1c3bc90543431ed4d7fde51e4d50b7fe73..d6ce0169041cd47ed99f3501746fe63deac9793a 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 SRCS = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c id2entry.c \
                index.c id2children.c nextid.c abandon.c compare.c group.c \
                modify.c modrdn.c delete.c init.c config.c bind.c attr.c \
index 4fe70427b572be1c8b9be52579807f45a1b24ba7..27ace1a927064fea6e62dc4c29a09bb6d31a1fd9 100644 (file)
@@ -1,4 +1,5 @@
 /* abandon.c - ldbm backend abandon routine */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 8775e2951454d8f1f3791526e10ec4a356835c88..edeaf57a10062c0a28be9291182a0e6ef364075b 100644 (file)
@@ -1,4 +1,5 @@
 /* add.c - ldap ldbm back-end add routine */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -252,7 +253,7 @@ ldbm_back_add(
        if ( id2entry_add( be, e ) != 0 ) {
                Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0,
                    0, 0 );
-               (void) dn2id_delete( be, e->e_ndn );
+               (void) dn2id_delete( be, e->e_ndn, e->e_id );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
                        NULL, NULL, NULL, NULL );
 
diff --git a/servers/slapd/back-ldbm/alias.c b/servers/slapd/back-ldbm/alias.c
new file mode 100644 (file)
index 0000000..ccc6880
--- /dev/null
@@ -0,0 +1,286 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/string.h>
+#include <ac/socket.h>
+#include "slap.h"
+#include "back-ldbm.h"
+#include "proto-back-ldbm.h"
+
+
+static char* get_alias_dn(
+       Entry *e,
+       int *err,
+       char **errmsg );
+
+static char* new_superior(
+       char *dn,
+       char *oldSup,
+       char *newSup );
+
+static int dnlist_subordinate(
+       char** dnlist,
+       char *dn );
+
+Entry *deref_internal_r(
+       Backend*        be,
+       Entry*          alias,
+       char*           dn,
+       int*            err,
+       Entry**         matched,
+       char**          text )
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       Entry *entry;
+       Entry *sup;
+       unsigned depth;
+       char **dnlist;
+
+       assert( ( alias != NULL && dn == NULL ) || ( alias == NULL && dn != NULL ) );
+
+       *matched = NULL;
+       *err = LDAP_SUCCESS;
+       *text = NULL;
+
+       if( alias == NULL ) {
+               dn = ch_strdup( dn );
+               entry = dn2entry_r( be, dn, &sup );
+
+       } else {
+               dn = ch_strdup( alias->e_ndn );
+               entry = alias;
+               sup = NULL;
+       }
+
+       dnlist = NULL;
+       charray_add( &dnlist, dn );
+
+       for( depth=0 ; ; depth++ ) {
+               if( entry != NULL ) {
+                       Entry *newe;
+                       char *aliasDN;
+
+                       /* have entry, may be an alias */
+
+                       if( !is_entry_alias( entry ) ) {
+                               /* entry is not an alias */
+                               break;
+                       }
+
+                       /* entry is alias */
+                       if( depth > be->be_max_deref_depth ) {
+                               *matched = entry;
+                               entry = NULL;
+                               *err = LDAP_ALIAS_DEREF_PROBLEM;
+                               *text = "maximum deref depth exceeded";
+                               break;
+                       }
+
+                       /* deref entry */
+                       aliasDN = get_alias_dn( entry, err, text );
+
+                       if( aliasDN == NULL ) {
+                               *matched = entry;
+                               entry = NULL;
+                               break;
+                       }
+
+                       /* check if aliasDN is a subordinate of any DN in our list */
+                       if( dnlist_subordinate( dnlist, aliasDN ) ) {
+                               *matched = entry;
+                               entry = NULL;
+                               *err = LDAP_ALIAS_PROBLEM;
+                               *text = "circular alias";
+                               break;
+                       }
+
+                       /* attempt to dereference alias */
+
+                       newe = dn2entry_r( be, aliasDN, &sup );
+
+                       if( newe != NULL ) {
+                               free( dn );
+                               cache_return_entry_r(&li->li_cache, entry );
+                               entry = newe;
+                               dn = ch_strdup( entry->e_ndn );
+                               charray_add( &dnlist, dn );
+                               continue;
+
+                       }
+                       
+                       if ( sup != NULL ) {
+                               cache_return_entry_r(&li->li_cache, entry );
+                               entry = NULL;
+                               continue;
+                       }
+
+                       /* no newe and no superior, we're done */
+                       break;
+
+               } else if( sup != NULL ) {
+                       /* have superior, may be an alias */
+                       Entry *newe;
+                       Entry *newSup;
+                       char *supDN;
+                       char *aliasDN;
+
+                       if( !is_entry_alias( sup ) ) {
+                               /* entry is not an alias */
+                               *matched = sup;
+                               sup = NULL;
+                               break;
+                       }
+
+                       /* entry is alias */
+                       if( depth > be->be_max_deref_depth ) {
+                               *matched = sup;
+                               entry = NULL;
+                               *err = LDAP_ALIAS_DEREF_PROBLEM;
+                               *text = "maximum deref depth exceeded";
+                               break;
+                       }
+
+                       /* deref entry */
+                       supDN = get_alias_dn( sup, err, text );
+
+                       if( supDN == NULL ) {
+                               *matched = sup;
+                               break;
+                       }
+
+                       aliasDN = new_superior( dn, sup->e_ndn, supDN );
+
+                       if( aliasDN == NULL ) {
+                               free(aliasDN);
+                               *matched = sup;
+                               *err = LDAP_ALIAS_PROBLEM;
+                               *text = "superior alias problem";
+                               break;
+                       }
+
+                       /* check if aliasDN is a subordinate of any DN in our list */
+                       if( dnlist_subordinate( dnlist, aliasDN ) ) {
+                               free(aliasDN);
+                               *matched = entry;
+                               entry = NULL;
+                               *err = LDAP_ALIAS_PROBLEM;
+                               *text = "subordinate circular alias";
+                               break;
+                       }
+
+                       /* attempt to dereference alias */
+                       newe = dn2entry_r( be, aliasDN, &newSup );
+
+                       if( newe != NULL ) {
+                               free(aliasDN);
+                               free( dn );
+                               cache_return_entry_r(&li->li_cache, sup );
+                               entry = newe;
+                               dn = ch_strdup( entry->e_ndn );
+                               charray_add( &dnlist, dn );
+                               continue;
+
+                       }
+                       
+                       if ( newSup != NULL ) {
+                               free( dn );
+                               cache_return_entry_r(&li->li_cache, sup );
+                               sup = newSup;
+                               dn = aliasDN;
+                               continue;
+                       }
+
+                       break;
+
+               } else {
+                       /* no newe and no superior, we're done */
+                       break;
+               }
+       }
+
+       free( dn );
+       return entry;
+}
+
+
+static char* get_alias_dn(
+       Entry *e,
+       int *err,
+       char **errmsg )
+{      
+       Attribute *a = attr_find( e->e_attrs, "aliasedobjectname" );
+
+       if( a == NULL ) {
+               /*
+                * there was an aliasedobjectname defined but no data.
+                */
+               *err = LDAP_ALIAS_PROBLEM;
+               *errmsg = "alias missing aliasedObjectName attribute";
+               return NULL;
+       }
+
+       /* 
+        * aliasedObjectName should be SINGLE-VALUED with a single value. 
+        */                     
+       if ( a->a_vals[0] == NULL || a->a_vals[0]->bv_val == NULL ) {
+               /*
+                * there was an aliasedobjectname defined but no data.
+                */
+               *err = LDAP_ALIAS_PROBLEM;
+               *errmsg = "alias missing aliasedObjectName value";
+               return NULL;
+       }
+
+       if( a->a_vals[1] != NULL ) {
+               *err = LDAP_ALIAS_PROBLEM;
+               *errmsg = "alias has multivalued aliasedObjectName";
+               return NULL;
+       }
+
+       return a->a_vals[0]->bv_val;
+}
+
+char* new_superior(
+       char *dn,
+       char *oldSup,
+       char *newSup )
+{
+       char *newDN;
+       size_t dnlen, olen, nlen;
+       assert( dn && oldSup && newSup );
+
+       dnlen = strlen( dn );
+       olen = strlen( oldSup );
+       nlen = strlen( newSup );
+
+       newDN = ch_malloc( dnlen - olen + nlen + 1 );
+
+       memcpy( newDN, dn, dnlen - olen );
+       memcpy( &newDN[dnlen - olen], newSup, nlen );
+       newDN[dnlen - olen + nlen] = '\0';
+
+       return newDN;
+}
+
+static int dnlist_subordinate(
+       char** dnlist,
+       char *dn )
+{
+       int i;
+       assert( dnlist );
+
+       for( i = 0; dnlist[i] != NULL; i++ ) {
+               if( dn_issuffix( dnlist[i], dn ) ) {
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
index ea7f85da1b4a00bc2aa5ae65967a15ae33e57263..37a5cf94b34b929be3ca297594108ad4982f2a21 100644 (file)
@@ -1,4 +1,5 @@
 /* attr.c - backend routines for dealing with attributes */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -88,7 +89,7 @@ attr_masks(
 void
 attr_index_config(
     struct ldbminfo    *li,
-    char               *fname,
+    const char         *fname,
     int                        lineno,
     int                        argc,
     char               **argv,
index 9a68e0e2d180c0c2c3300f7603ba47190d558b73..cf381da96f4f0627df6e0cf0a347c32b568de4cc 100644 (file)
@@ -1,4 +1,5 @@
 /* back-ldbm.h - ldap ldbm back-end header file */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 6a2efc8f0cb2d5234022d022c4acb27167d23149..1880a8a8ccb10f147dd00b96a0c13570917a42c5 100644 (file)
@@ -1,4 +1,5 @@
 /* bind.c - ldbm backend bind and unbind routines */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 66ecb5ba9b47e94ccf21099ad0cb778da25a78ea..0ef36d7d349325b1b1fcc70a995c4651d6624c9a 100644 (file)
@@ -1,4 +1,5 @@
 /* cache.c - routines to maintain an in-core cache of entries */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -435,14 +436,14 @@ ID
 cache_find_entry_dn2id(
        Backend         *be,
     Cache      *cache,
-    char               *dn
+    const char         *dn
 )
 {
        Entry           e, *ep;
        ID                      id;
        int count = 0;
 
-       e.e_dn = dn;
+       e.e_dn = (char *) dn;
        e.e_ndn = ch_strdup( dn );
        (void) dn_normalize_case( e.e_ndn );
 
index 37a5235780d4f94a7fcd4af65de17757edaa7f1e..9aa2ca4169d22438a172e4ac28f59e076581141b 100644 (file)
@@ -1,4 +1,5 @@
 /* close.c - close ldbm backend */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 278a806d6fdd7ed034c7d30e554fffe0a102c001..96932cecfc49e15e9276daee84c1f2cca3b6e164 100644 (file)
@@ -1,4 +1,5 @@
 /* compare.c - ldbm backend compare routine */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 80cabd6a477c7c71e541a6cbca4910516677e1bb..ef06a4fcc729e66300479246e1f5d41227fa3ed5 100644 (file)
@@ -1,4 +1,5 @@
 /* config.c - ldbm backend configuration file routine */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -18,7 +19,7 @@
 int
 ldbm_back_db_config(
     Backend    *be,
-    char       *fname,
+    const char *fname,
     int                lineno,
     int                argc,
     char       **argv
index 3bec93a5296192b6c3c17b435d6d1a9a2688863c..eecf2c954b3f39690dd24b7bc4e2afc9e8f21186 100644 (file)
@@ -1,4 +1,5 @@
 /* ldbmcache.c - maintain a cache of open ldbm files */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -19,7 +20,6 @@
 #include <sys/param.h>
 #endif
 
-#include "ldap_defaults.h"
 #include "slap.h"
 #include "back-ldbm.h"
 
index 7db49948bb07c7f90472e70b7158d5ca4cf6b6ef..eb3ed850e2006ca68242d68ec01117f87b3b1be6 100644 (file)
@@ -1,4 +1,5 @@
 /* delete.c - ldbm backend delete routine */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -24,7 +25,7 @@ ldbm_back_delete(
 )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
-       Entry   *matched = NULL;
+       Entry   *matched;
        char    *pdn = NULL;
        Entry   *e, *p = NULL;
        int rootlock = 0;
@@ -104,7 +105,7 @@ ldbm_back_delete(
 
        /* delete from parent's id2children entry */
        if( (pdn = dn_parent( be, e->e_ndn )) != NULL ) {
-               if( (p = dn2entry_w( be, pdn, &matched )) == NULL) {
+               if( (p = dn2entry_w( be, pdn, NULL )) == NULL) {
                        Debug( LDAP_DEBUG_TRACE,
                                "<=- ldbm_back_delete: parent does not exist\n",
                                0, 0, 0);
@@ -141,7 +142,7 @@ ldbm_back_delete(
        }
 
        /* delete from dn2id mapping */
-       if ( dn2id_delete( be, e->e_ndn ) != 0 ) {
+       if ( dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
                Debug(LDAP_DEBUG_ARGS,
                        "<=- ldbm_back_delete: operations error %s\n",
                        dn, 0, 0);
@@ -180,7 +181,5 @@ return_results:;
        /* free entry and writer lock */
        cache_return_entry_w( &li->li_cache, e );
 
-       if ( matched != NULL ) free(matched);
-
        return rc;
 }
index 2e1238ec9f78b9208338b8c8c59f19a32c832479..afa1c27de6d4c9c18e8b8321af44bba3eaabb32f 100644 (file)
@@ -1,4 +1,5 @@
 /* dn2id.c - routines to deal with the dn2id index */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -18,7 +19,7 @@
 int
 dn2id_add(
     Backend    *be,
-    char       *dn,
+    const char *dn,
     ID         id
 )
 {
@@ -28,6 +29,7 @@ dn2id_add(
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
 
        Debug( LDAP_DEBUG_TRACE, "=> dn2id_add( \"%s\", %ld )\n", dn, id, 0 );
+       assert( id != NOID );
 
        if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT ))
            == NULL ) {
@@ -87,7 +89,6 @@ dn2id_add(
 
                        charray_free( subtree );
                }
-
        }
 
        ldbm_cache_close( be, db );
@@ -99,7 +100,7 @@ dn2id_add(
 ID
 dn2id(
     Backend    *be,
-    char       *dn
+    const char *dn
 )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
@@ -142,6 +143,8 @@ dn2id(
 
        (void) memcpy( (char *) &id, data.dptr, sizeof(ID) );
 
+       assert( id != NOID );
+
        ldbm_datum_free( db->dbc_db, data );
 
        Debug( LDAP_DEBUG_TRACE, "<= dn2id %ld\n", id, 0, 0 );
@@ -151,7 +154,7 @@ dn2id(
 ID_BLOCK *
 dn2idl(
     Backend    *be,
-    char       *dn,
+    const char *dn,
        int             prefix
 )
 {
@@ -187,14 +190,17 @@ dn2idl(
 int
 dn2id_delete(
     Backend    *be,
-    char       *dn
+    const char *dn,
+       ID id
 )
 {
        DBCache *db;
        Datum           key;
        int             rc;
 
-       Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\" )\n", dn, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\", %ld )\n", dn, id, 0 );
+
+       assert( id != NOID );
 
        if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT ))
            == NULL ) {
@@ -204,6 +210,44 @@ dn2id_delete(
                return( -1 );
        }
 
+
+       {
+               char *pdn = dn_parent( NULL, dn );
+
+               if( pdn != NULL ) {
+                       ldbm_datum_init( key );
+                       key.dsize = strlen( pdn ) + 2;
+                       key.dptr = ch_malloc( key.dsize );
+                       sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, pdn );
+
+                       (void) idl_delete_key( be, db, key, id );
+
+                       free( key.dptr );
+                       free( pdn );
+               }
+       }
+
+       {
+               char **subtree = dn_subtree( NULL, dn );
+
+               if( subtree != NULL ) {
+                       int i;
+                       for( i=0; subtree[i] != NULL; i++ ) {
+                               ldbm_datum_init( key );
+                               key.dsize = strlen( subtree[i] ) + 2;
+                               key.dptr = ch_malloc( key.dsize );
+                               sprintf( key.dptr, "%c%s",
+                                       DN_SUBTREE_PREFIX, subtree[i] );
+
+                               (void) idl_delete_key( be, db, key, id );
+
+                               free( key.dptr );
+                       }
+
+                       charray_free( subtree );
+               }
+       }
+
        ldbm_datum_init( key );
 
        key.dsize = strlen( dn ) + 2;
@@ -228,12 +272,11 @@ dn2id_delete(
 Entry *
 dn2entry_rw(
     Backend    *be,
-    char       *dn,
+    const char *dn,
     Entry      **matched,
     int         rw
 )
 {
-       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        ID              id;
        Entry           *e = NULL;
        char            *pdn;
index 503aab692a8a4ff6808490c5fb00b825e5689682..7ff873b85550f101b873e1664fc8b3c106d3c533 100644 (file)
@@ -1,4 +1,5 @@
 /* entry.c - ldbm backend entry_release routine */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index c35e612d116e84af563a055df1f2b985a638fe3a..e1b8696db6dafa39ff88df9f90cf520e14bdfb7a 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -19,7 +20,7 @@ extern int    ldbm_back_db_close LDAP_P(( BackendDB *bd ));
 extern int     ldbm_back_db_destroy LDAP_P(( BackendDB *bd ));
 
 extern int     ldbm_back_db_config LDAP_P(( BackendDB *bd,
-       char *fname, int lineno, int argc, char **argv ));
+       const char *fname, int lineno, int argc, char **argv ));
 
 extern int ldbm_back_bind LDAP_P(( BackendDB *bd,
        Connection *conn, Operation *op,
@@ -57,8 +58,8 @@ extern int    ldbm_back_abandon LDAP_P(( BackendDB *bd,
        Connection *conn, Operation *op, ber_int_t msgid ));
 
 extern int     ldbm_back_group LDAP_P(( BackendDB *bd,
-       Entry *target, char* gr_ndn, char* op_ndn,
-       char* objectclassValue, char* groupattrName));
+       Entry *target, const char* gr_ndn, const char* op_ndn,
+       const char* objectclassValue, const char* groupattrName));
 
 
 /* hooks for slap tools */
index 1db64e44806de6f1efd5b66fea62e9393f3208e4..81deb55a608c602e271bed5abdc77ba2f132f703 100644 (file)
@@ -1,4 +1,5 @@
 /* filterindex.c - generate the list of candidate entries from a filter */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 252b584166d024f8560a7e7e72662a4323c579cc..8dbe75922a4ad251cc7c1cb04dec006a6c5ef916 100644 (file)
@@ -1,4 +1,5 @@
 /* group.c - ldbm backend acl group routine */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -24,10 +25,10 @@ int
 ldbm_back_group(
        Backend *be,
        Entry   *target,
-       char    *gr_ndn,
-       char    *op_ndn,
-       char    *objectclassValue,
-       char    *groupattrName
+       const char      *gr_ndn,
+       const char      *op_ndn,
+       const char      *objectclassValue,
+       const char      *groupattrName
 )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;    
@@ -104,7 +105,7 @@ ldbm_back_group(
                goto return_results;
        }
 
-       bv.bv_val = objectclassValue;
+       bv.bv_val = (char *) objectclassValue;
        bv.bv_len = strlen( bv.bv_val );         
 
        if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
@@ -125,7 +126,7 @@ ldbm_back_group(
                "<= ldbm_back_group: found objectClass %s and %s\n",
                objectclassValue, groupattrName, 0 ); 
 
-       bv.bv_val = op_ndn;
+       bv.bv_val = (char *) op_ndn;
        bv.bv_len = strlen( op_ndn );         
 
        if( value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 )
index 00d5bf6988e2227ff443cad15282b90783016477..acbab8fd77a88bf6b5b0b69bff8caf9fccc7ba74 100644 (file)
@@ -1,4 +1,5 @@
 /* id2children.c - routines to deal with the id2children index */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 982e816d6b57a8aec8fa9a59bf20cc9660d419f3..53f52d85a52e6a1263627375869f1daac6078f33 100644 (file)
@@ -1,4 +1,5 @@
 /* id2entry.c - routines to deal with the id2entry index */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 47c8a305cc6fa5399c6142f1ee6f4989eb555e6e..f528fa8665f044e43e00fdfc1dd16d81058f25c7 100644 (file)
@@ -1,4 +1,5 @@
 /* idl.c - ldap id list handling routines */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -11,7 +12,6 @@
 #include <ac/string.h>
 #include <ac/socket.h>
 
-#include "ldap_defaults.h"
 #include "slap.h"
 #include "back-ldbm.h"
 
@@ -79,10 +79,11 @@ idl_fetch_one(
                return NULL;
        }
 
-       idl = idl_dup( (ID_BLOCK *) data.dptr);
+       idl = idl_dup((ID_BLOCK *) data.dptr);
+
        ldbm_datum_free( db->dbc_db, data );
 
-       return( idl );
+       return idl;
 }
 
 
@@ -470,7 +471,8 @@ idl_insert_key(
                rc = idl_change_first( be, db, key, idl, i, k2, tmp );
                break;
 
-       case 2:         /* id not inserted - already there */
+       case 2:         /* id not inserted - already there, do nothing */
+               rc = 0;
                break;
 
        case 3:         /* id not inserted - block is full */
@@ -491,7 +493,8 @@ idl_insert_key(
                                Debug( LDAP_DEBUG_ANY,
                                    "idl_fetch_one (%s) returns NULL\n",
                                    k2.dptr, 0, 0 );
-                               break;
+                               /* split the original block */
+                               goto split;
                        }
 
                        switch ( (rc = idl_insert( &tmp2, id,
@@ -517,14 +520,19 @@ idl_insert_key(
                        case 3:         /* split the original block */
                                break;
                        }
+
                        idl_free( tmp2 );
                }
 
+split:
                /*
                 * must split the block, write both new blocks + update
                 * and write the indirect header block.
                 */
 
+               rc = 0; /* optimistic */
+
+
                /* count how many indirect blocks *//* XXX linear count XXX */
                for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ )
                        ;       /* NULL */
@@ -651,8 +659,8 @@ idl_insert( ID_BLOCK **idl, ID id, unsigned int maxids )
        }
 
        /* make a slot for the new id */
-       SAFEMEMCPY( &ID_BLOCK_ID(*idl, i), &ID_BLOCK_ID(*idl, i+1), 
-               ID_BLOCK_NIDS(*idl) - i );
+       SAFEMEMCPY( &ID_BLOCK_ID(*idl, i+1), &ID_BLOCK_ID(*idl, i),
+                   (ID_BLOCK_NIDS(*idl) - i) * sizeof(ID) );
 
        ID_BLOCK_ID(*idl, i) = id;
        ID_BLOCK_NIDS(*idl)++;
@@ -674,7 +682,7 @@ idl_delete_key (
 )
 {
        Datum  data;
-       ID_BLOCK *idl, *tmp;
+       ID_BLOCK *idl;
        unsigned i;
        int j, nids;
        char    *kstr;
@@ -725,6 +733,7 @@ idl_delete_key (
 
        for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ ) 
        {
+               ID_BLOCK *tmp;
                ldbm_datum_init( data );
                sprintf( kstr, "%c%ld%s", CONT_PREFIX,
                        ID_BLOCK_ID(idl, j), key.dptr );
index b44ffab75650d0102ee2963d628e7ce10360762a..12db542582c9d05017050f3ff771b1f21de44a80 100644 (file)
@@ -1,4 +1,5 @@
 /* index.c - routines for dealing with attribute indexes */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index ab29410fb6c7761ac53adf5e99395338b773dce9..d7b6345e9fe2da2ac4b06367850756c975980629 100644 (file)
@@ -1,4 +1,5 @@
 /* init.c - initialize ldbm backend */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index c8e4a54a0a305af600767ebec29ab3d8ee117dfe..7a80877240569e60070733f38758c0fcfa649cc2 100644 (file)
@@ -1,4 +1,5 @@
 /* kerberos.c - ldbm backend kerberos bind routines */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 267222b01c50b243e49cf1174fae634e70e40381..770be8dbc2632057140251b1fa6691b8b19a116b 100644 (file)
@@ -1,4 +1,5 @@
 /* modify.c - ldbm backend modify routine */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index fae002cec01f706798327c1841df88f53f1f8a7f..08300fbf6834af17cb59a6e134f4b03aa7968352 100644 (file)
@@ -1,4 +1,5 @@
 /* modrdn.c - ldbm backend modrdn routine */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -46,13 +47,13 @@ ldbm_back_modrdn(
        char            *p_dn = NULL, *p_ndn = NULL;
        char            *new_dn = NULL, *new_ndn = NULL;
        Entry           *e, *p = NULL;
-       Entry           *matched = NULL;
+       Entry           *matched;
        int                     rootlock = 0;
        int                     rc = -1;
        /* Added to support LDAP v2 correctly (deleteoldrdn thing) */
        char            *new_rdn_val = NULL;    /* Val of new rdn */
        char            *new_rdn_type = NULL;   /* Type of new rdn */
-       char            *old_rdn;               /* Old rdn's attr type & val */
+       char            *old_rdn = NULL;        /* Old rdn's attr type & val */
        char            *old_rdn_type = NULL;   /* Type of old rdn attr. */
        char            *old_rdn_val = NULL;    /* Old rdn attribute value */
        /* Added to support newSuperior */ 
@@ -133,7 +134,7 @@ ldbm_back_modrdn(
                 * children.
                 */
 
-               if( (p = dn2entry_w( be, p_ndn, &matched )) == NULL) {
+               if( (p = dn2entry_w( be, p_ndn, NULL )) == NULL) {
                        Debug( LDAP_DEBUG_TRACE, "parent does not exist\n",
                                0, 0, 0);
                        send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
@@ -195,7 +196,7 @@ ldbm_back_modrdn(
                /* newSuperior == entry being moved?, if so ==> ERROR */
                /* Get Entry with dn=newSuperior. Does newSuperior exist? */
 
-               if( (np = dn2entry_w( be, np_ndn, &matched )) == NULL) {
+               if( (np = dn2entry_w( be, np_ndn, NULL )) == NULL) {
                        Debug( LDAP_DEBUG_TRACE,
                               "ldbm_back_modrdn: newSup(ndn=%s) not here!\n",
                               np_ndn, 0, 0);
@@ -205,7 +206,7 @@ ldbm_back_modrdn(
                }
 
                Debug( LDAP_DEBUG_TRACE,
-                      "ldbm_back_modrdn: wr to new parent OK np=%p, id=%d\n",
+                      "ldbm_back_modrdn: wr to new parent OK np=%p, id=%ld\n",
                       np, np->e_id, 0 );
            
                /* check newSuperior for "children" acl */
@@ -261,44 +262,23 @@ ldbm_back_modrdn(
        Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n",
               new_ndn, 0, 0 );
 
-       if (dn2id ( be, new_ndn ) != NOID) {
-               send_ldap_result( conn, op, LDAP_ALREADY_EXISTS,
-                       NULL, NULL, NULL, NULL );
-               goto return_results;
-       }
-
-       Debug( LDAP_DEBUG_TRACE,
-              "ldbm_back_modrdn: new ndn=%s does not exist\n",
-              new_ndn, 0, 0 );
-
        /* check for abandon */
        ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
        if ( op->o_abandon ) {
                ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
                goto return_results;
        }
-       ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
-
-       /* delete old one */
-       if ( dn2id_delete( be, e->e_ndn ) != 0 ) {
-               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
-                       NULL, NULL, NULL, NULL );
-               goto return_results;
-       }
 
-       (void) cache_delete_entry( &li->li_cache, e );
-       free( e->e_dn );
-       free( e->e_ndn );
-       e->e_dn = new_dn;
-       e->e_ndn = new_ndn;
-
-       /* add new one */
-       if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) {
-               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+       ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+       if (dn2id ( be, new_ndn ) != NOID) {
+               send_ldap_result( conn, op, LDAP_ALREADY_EXISTS,
                        NULL, NULL, NULL, NULL );
                goto return_results;
        }
 
+       Debug( LDAP_DEBUG_TRACE,
+              "ldbm_back_modrdn: new ndn=%s does not exist\n",
+              new_ndn, 0, 0 );
 
        /* Get attribute type and attribute value of our new rdn, we will
         * need to add that to our new entry
@@ -438,12 +418,44 @@ ldbm_back_modrdn(
        }
 #endif
 
+       /* check for abandon */
+       ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
+       if ( op->o_abandon ) {
+               ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+               goto return_results;
+       }
+       ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+
+       /* delete old one */
+       if ( dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               goto return_results;
+       }
+
+       (void) cache_delete_entry( &li->li_cache, e );
+
+       /* XXX: there is no going back! */
+
+       free( e->e_dn );
+       free( e->e_ndn );
+       e->e_dn = new_dn;
+       e->e_ndn = new_ndn;
+       new_dn = NULL;
+       new_ndn = NULL;
+
+       /* add new one */
+       if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) {
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+               goto return_results;
+       }
+
        /* modify memory copy of entry */
        if ( ldbm_modify_internal( be, conn, op, dn, &mod[0], e )
             != 0 ) {
            
            goto return_results;
-           
        }
        
        (void) cache_update_entry( &li->li_cache, e );
@@ -457,28 +469,20 @@ ldbm_back_modrdn(
                entry_free( e );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
                        NULL, NULL, NULL, NULL );
-               goto return_results_after;
+               goto return_results;
        }
 
        send_ldap_result( conn, op, LDAP_SUCCESS,
                NULL, NULL, NULL, NULL );
        rc = 0;
-       goto return_results_after;      
 
 return_results:
        if( new_dn != NULL ) free( new_dn );
        if( new_ndn != NULL ) free( new_ndn );
 
-return_results_after:
-       /* NOTE:
-        * new_dn and new_ndn are not deallocated because they are used by
-        * the cache entry.
-        */
        if( p_dn != NULL ) free( p_dn );
        if( p_ndn != NULL ) free( p_ndn );
 
-       if( matched != NULL ) free( matched );
-
        /* LDAP v2 supporting correct attribute handling. */
        if( new_rdn_type != NULL ) free(new_rdn_type);
        if( new_rdn_val != NULL ) free(new_rdn_val);
index 7287b3c5ab85e2a49fede14afa382c59f40073b4..ebe6f3897119b5cbab989be08a2c4f497ee0850c 100644 (file)
@@ -1,4 +1,5 @@
 /* nextid.c - keep track of the next id to be given out */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -21,7 +22,6 @@
 static ID
 next_id_read( Backend *be )
 {
-       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        ID id = NOID;
        Datum key, data;
        DBCache *db;
index 90ea6281d2cf1707609a224030e8cc0ad59b8059..1b466f4eb69f87bbe73ed403a0030c23a61747ea 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -34,8 +35,9 @@ Entry *deref_internal_r LDAP_P((
 
 void attr_masks LDAP_P(( struct ldbminfo *li, char *type, int *indexmask,
  int *syntaxmask ));
-void attr_index_config LDAP_P(( struct ldbminfo *li, char *fname, int lineno,
- int argc, char **argv, int init ));
+void attr_index_config LDAP_P(( struct ldbminfo *li,
+       const char *fname, int lineno,
+       int argc, char **argv, int init ));
 void attr_index_destroy LDAP_P(( Avlnode *tree ));
 
 /*
@@ -48,7 +50,7 @@ void cache_return_entry_rw LDAP_P(( Cache *cache, Entry *e, int rw ));
 #define cache_return_entry_r(c, e) cache_return_entry_rw((c), (e), 0)
 #define cache_return_entry_w(c, e) cache_return_entry_rw((c), (e), 1)
 
-ID cache_find_entry_dn2id LDAP_P(( Backend *be, Cache *cache, char *dn ));
+ID cache_find_entry_dn2id LDAP_P(( Backend *be, Cache *cache, const char *dn ));
 Entry * cache_find_entry_id LDAP_P(( Cache *cache, ID id, int rw ));
 int cache_delete_entry LDAP_P(( Cache *cache, Entry *e ));
 void cache_release_all LDAP_P(( Cache *cache ));
@@ -70,12 +72,12 @@ int ldbm_cache_delete LDAP_P(( DBCache *db, Datum key ));
  * dn2id.c
  */
 
-int dn2id_add LDAP_P(( Backend *be, char *dn, ID id ));
-ID dn2id LDAP_P(( Backend *be, char *dn ));
-ID_BLOCK *dn2idl LDAP_P(( Backend *be, char *dn, int prefix ));
-int dn2id_delete LDAP_P(( Backend *be, char *dn ));
+int dn2id_add LDAP_P(( Backend *be, const char *dn, ID id ));
+ID dn2id LDAP_P(( Backend *be, const char *dn ));
+ID_BLOCK *dn2idl LDAP_P(( Backend *be, const char *dn, int prefix ));
+int dn2id_delete LDAP_P(( Backend *be, const char *dn, ID id ));
 
-Entry * dn2entry_rw LDAP_P(( Backend *be, char *dn, Entry **matched, int rw ));
+Entry * dn2entry_rw LDAP_P(( Backend *be, const char *dn, Entry **matched, int rw ));
 #define dn2entry_r(be, dn, m) dn2entry_rw((be), (dn), (m), 0)
 #define dn2entry_w(be, dn, m) dn2entry_rw((be), (dn), (m), 1)
 
index 32028a6544532332576a8554b654736351a32431..2858e249610486af8ab6af19568ee75175f87bd5 100644 (file)
@@ -1,4 +1,5 @@
 /* search.c - ldbm backend search function */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -317,7 +318,8 @@ loop_continue:
        rc = 0;
 
 done:
-       idl_free( candidates );
+       if( candidates != NULL )
+               idl_free( candidates );
 
        ber_bvecfree( v2refs );
        if( realbase ) free( realbase );
@@ -352,7 +354,6 @@ search_candidates(
        int             manageDSAit
 )
 {
-       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        ID_BLOCK                *candidates;
        Filter          *f, *rf, *af, *lf;
 
index ec4c9faf1b608555042046abc043ffd1ff0a8bfa..8137e0bd1b01c4d56a96486a32b240de43d5ca86 100644 (file)
@@ -1,4 +1,5 @@
 /* startup.c - startup ldbm backend */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -12,7 +13,6 @@
 #include <ac/string.h>
 #include <ac/socket.h>
 
-#include "ldap_defaults.h"
 #include "slap.h"
 #include "back-ldbm.h"
 
@@ -49,7 +49,7 @@ ldbm_back_startup(
 #else
        struct ldbminfo  *li = (struct ldbminfo *) be->be_private;
        DB_ENV           *dbEnv = &li->li_db_env;
-       int    envFlags = DB_CREATE | DB_THREAD;
+       u_int32_t    envFlags = DB_CREATE | DB_THREAD;
        int    err      = 0;
        char   *home;
 
index 889be2508e366bf1fb6308c061ad7786fabda293..840449e473d87fa702cb6a9ea688fe55d6cd959c 100644 (file)
@@ -1,4 +1,5 @@
 /* tools.c - tools for slap tools */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -184,7 +185,7 @@ ID ldbm_tool_entry_put(
        rc = ldbm_cache_store( id2entry, key, data, LDBM_REPLACE );
 
        if( rc != 0 ) {
-               (void) dn2id_delete( be, e->e_ndn );
+               (void) dn2id_delete( be, e->e_ndn, e->e_id );
                return NOID;
        }
 
index abf7fdf1c2a41c4da15b0d83f666a83d9db1ac4d..69538da67bb7c198b4f3a166a79225d6d52e04b8 100644 (file)
@@ -1,4 +1,5 @@
 /* unbind.c - handle an ldap unbind operation */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index cc329172e708e7b7635e2673c682156cc1b84fbe..090ff008a0ba322ce5507d936e8f5cc9e9fb1d37 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 SRCS   = search.c config.c init.c
 OBJS   = search.lo config.lo init.lo
 
index 5a26ff0fb61e6a401c5fb522ef8ca5d45815f1a7..d9768560894b5af93b85419cc5e3b480a7236663 100644 (file)
@@ -1,16 +1,21 @@
 /* config.c - passwd backend configuration file routine */
+/* $OpenLDAP$ */
 
-#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
 #include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
 #include "slap.h"
+#include "external.h"
 
-passwd_back_config(
-    Backend    *be,
-    char       *fname,
+int
+passwd_back_db_config(
+    BackendDB  *be,
+    const char *fname,
     int                lineno,
     int                argc,
     char       **argv
@@ -23,9 +28,9 @@ passwd_back_config(
                        fprintf( stderr,
                "%s: line %d: missing filename in \"file <filename>\" line\n",
                            fname, lineno );
-                       exit( 1 );
+                       return( 1 );
                }
-               be->be_private = strdup( argv[1] );
+               be->be_private = ch_strdup( argv[1] );
 #else /* HAVE_SETPWFILE */
                fprintf( stderr,
     "%s: line %d: ignoring \"file\" option (not supported on this platform)\n",
@@ -38,4 +43,6 @@ passwd_back_config(
 "%s: line %d: unknown directive \"%s\" in passwd database definition (ignored)\n",
                    fname, lineno, argv[0] );
        }
+
+       return( 0 );
 }
diff --git a/servers/slapd/back-passwd/external.h b/servers/slapd/back-passwd/external.h
new file mode 100644 (file)
index 0000000..92dd26e
--- /dev/null
@@ -0,0 +1,20 @@
+/* $OpenLDAP$ */
+#ifndef _PASSWD_EXTERNAL_H
+#define _PASSWD_EXTERNAL_H
+
+LDAP_BEGIN_DECL
+
+extern int     passwd_back_initialize LDAP_P(( BackendInfo *bi ));
+
+extern int  passwd_back_search LDAP_P(( BackendDB *be,
+       Connection *c, Operation *o,
+       char *base, int scope, int deref, int slimit, int tlimit,
+       Filter *f, char *filterstr, char **attrs, int attrsonly));
+
+extern int passwd_back_db_config LDAP_P((BackendDB *bd,
+       const char *fname, int lineno, int argc, char **argv ));
+
+LDAP_END_DECL
+
+#endif /* _PASSWD_EXTERNAL_H */
+
index ea500d7b3cea4b35e113ae16a520f9b99250ce4e..609231dba429661ea69646c9ea0d694108c0bb54 100644 (file)
@@ -1,4 +1,5 @@
 /* init.c - initialize passwd backend */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
index 11c1d8e7192424712a5acd60e0e9f6592fc0a722..68af4b3fa44ed6f670cc83a7c51cbd58e3cb0581 100644 (file)
@@ -1,18 +1,25 @@
 /* search.c - /etc/passwd backend search function */
+/* $OpenLDAP$ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
 #include <pwd.h>
-#include "portable.h"
-#include "slap.h"
 
-extern time_t          currenttime;
-extern pthread_mutex_t currenttime_mutex;
+#include "slap.h"
+#include "external.h"
+#include <ldap_pvt.h>
 
-static Entry   *pw2entry();
+static Entry *pw2entry(
+       Backend *be,
+       struct passwd *pw,
+       char *rdn);
 
 int
 passwd_back_search(
@@ -35,87 +42,184 @@ passwd_back_search(
        char            *s;
        time_t          stoptime;
 
+       int sent = 0;
+       int err = LDAP_SUCCESS;
+
+       char *rdn = NULL;
+       char *parent = NULL;
+       char *matched = NULL;
+       char *user = NULL;
+
        tlimit = (tlimit > be->be_timelimit || tlimit < 1) ? be->be_timelimit
            : tlimit;
        stoptime = op->o_time + tlimit;
        slimit = (slimit > be->be_sizelimit || slimit < 1) ? be->be_sizelimit
            : slimit;
 
+       endpwent();
+
 #ifdef HAVE_SETPWFILE
        if ( be->be_private != NULL ) {
-               endpwent();
                (void) setpwfile( (char *) be->be_private );
        }
 #endif /* HAVE_SETPWFILE */
 
-       if ( scope == LDAP_SCOPE_BASE ) {
-               if ( (s = strchr( base, '@' )) != NULL ) {
-                       *s = '\0';
-               }
+       /* Handle a query for the base of this backend */
+       if ( be_issuffix( be,  base ) ) {
+               struct berval   val, *vals[2];
 
-               if ( (pw = getpwnam( base )) == NULL ) {
-                       send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
-                           s != NULL ? s + 1 : NULL, NULL );
-                       return( -1 );
-               }
+               vals[0] = &val;
+               vals[1] = NULL;
 
-               e = pw2entry( be, pw );
-               if ( test_filter( be, conn, op, e, filter ) == 0 ) {
-                       send_search_entry( be, conn, op, e, attrs, attrsonly );
+               matched = ch_strdup( base );
+
+               if( scope != LDAP_SCOPE_ONELEVEL ) {
+                       /* Create an entry corresponding to the base DN */
+                       e = (Entry *) ch_calloc(1, sizeof(Entry));
+                       e->e_attrs = NULL;
+                       e->e_dn = ch_strdup( base );
+
+                       /* Use the first attribute of the DN
+                       * as an attribute within the entry itself.
+                       */
+                       rdn = dn_rdn(NULL, base);
+
+                       if( rdn == NULL || (s = strchr(rdn, '=')) == NULL ) {
+                               err = LDAP_INVALID_DN_SYNTAX;
+                               goto done;
+                       }
+
+                       val.bv_val = rdn_attr_value(rdn);
+                       val.bv_len = strlen( val.bv_val );
+                       attr_merge( e, rdn_attr_type(rdn), vals );
+
+                       free(rdn);
+                       rdn = NULL;
+
+                       /* Every entry needs an objectclass. We don't really
+                        * know if our hardcoded choice here agrees with the
+                        * DN that was configured for this backend, but it's
+                        * better than nothing.
+                        *
+                        * should be a configuratable item
+                        */
+                       val.bv_val = "organizationalUnit";
+                       val.bv_len = strlen( val.bv_val );
+                       attr_merge( e, "objectClass", vals );
+       
+                       if ( test_filter( be, conn, op, e, filter ) == 0 ) {
+                               send_search_entry( be, conn, op,
+                                       e, attrs, attrsonly, NULL );
+                               sent++;
+                       }
                }
-               entry_free( e );
 
-               send_ldap_result( conn, op, LDAP_SUCCESS, "", "" );
+               if ( scope != LDAP_SCOPE_BASE ) {
+                       /* check all our "children" */
 
-               return( 0 );
-       }
+                       for ( pw = getpwent(); pw != NULL; pw = getpwent() ) {
+                               /* check for abandon */
+                               ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
+                               if ( op->o_abandon ) {
+                                       ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+                                       endpwent();
+                                       return( -1 );
+                               }
+                               ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+
+                               /* check time limit */
+                               if ( slap_get_time() > stoptime ) {
+                                       send_ldap_result( conn, op, LDAP_TIMELIMIT_EXCEEDED,
+                                       NULL, NULL, NULL, NULL );
+                                       endpwent();
+                                       return( 0 );
+                               }
+
+                               e = pw2entry( be, pw, NULL );
+
+                               if ( test_filter( be, conn, op, e, filter ) == 0 ) {
+                                       /* check size limit */
+                                       if ( --slimit == -1 ) {
+                                               send_ldap_result( conn, op, LDAP_SIZELIMIT_EXCEEDED,
+                                               NULL, NULL, NULL, NULL );
+                                               endpwent();
+                                               return( 0 );
+                                       }
 
-       for ( pw = getpwent(); pw != NULL; pw = getpwent() ) {
-               /* check for abandon */
-               pthread_mutex_lock( &op->o_abandonmutex );
-               if ( op->o_abandon ) {
-                       pthread_mutex_unlock( &op->o_abandonmutex );
+                                       send_search_entry( be, conn, op,
+                                               e, attrs, attrsonly, NULL );
+                                       sent++;
+                               }
+
+                               entry_free( e );
+                       }
                        endpwent();
-                       return( -1 );
                }
-               pthread_mutex_unlock( &op->o_abandonmutex );
 
-               /* check size limit */
-               if ( --slimit == -1 ) {
-                       send_ldap_result( conn, op, LDAP_SIZELIMIT_EXCEEDED,
-                           NULL, NULL );
-                       endpwent();
-                       return( 0 );
+       } else {
+               parent = dn_parent( be, base );
+
+               /* This backend is only one layer deep. Don't answer requests for
+                * anything deeper than that.
+                */
+               if( !be_issuffix( be, parent ) ) {
+                       int i;
+                       for( i=0; be->be_suffix[i] != NULL; i++ ) {
+                               if( dn_issuffix( base, be->be_suffix[i] ) ) {
+                                       matched = ch_strdup( be->be_suffix[i] );
+                                       break;
+                               }
+                       }
+                       err = LDAP_NO_SUCH_OBJECT;
+                       goto done;
                }
 
-               /* check time limit */
-               pthread_mutex_lock( &currenttime_mutex );
-               time( &currenttime );
-               if ( currenttime > stoptime ) {
-                       pthread_mutex_unlock( &currenttime_mutex );
-                       send_ldap_result( conn, op, LDAP_TIMELIMIT_EXCEEDED,
-                           NULL, NULL );
-                       endpwent();
-                       return( 0 );
+               if( scope == LDAP_SCOPE_ONELEVEL ) {
+                       goto done;
+               }
+
+               rdn = dn_rdn( NULL, base );
+
+               if ( (user = rdn_attr_value(rdn)) == NULL) {
+                       err = LDAP_OPERATIONS_ERROR;
+                       goto done;
                }
-               pthread_mutex_unlock( &currenttime_mutex );
 
-               e = pw2entry( be, pw );
+               user = ldap_pvt_str2lower( user );
+
+               if ( (pw = getpwnam( user )) == NULL ) {
+                       matched = parent;
+                       parent = NULL;
+                       err = LDAP_NO_SUCH_OBJECT;
+                       goto done;
+               }
+
+               e = pw2entry( be, pw, rdn );
 
                if ( test_filter( be, conn, op, e, filter ) == 0 ) {
-                       send_search_entry( be, conn, op, e, attrs, attrsonly );
+                       send_search_entry( be, conn, op,
+                               e, attrs, attrsonly, NULL );
+                       sent++;
                }
 
                entry_free( e );
        }
-       endpwent();
-       send_ldap_result( conn, op, LDAP_SUCCESS, "", "" );
+
+done:
+       send_ldap_result( conn, op,
+               err, err == LDAP_NO_SUCH_OBJECT ? matched : NULL, NULL,
+               NULL, NULL );
+
+       if( matched != NULL ) free( matched );
+       if( parent != NULL ) free( parent );
+       if( rdn != NULL ) free( rdn );
+       if( user != NULL ) free( user );
 
        return( 0 );
 }
 
 static Entry *
-pw2entry( Backend *be, struct passwd *pw )
+pw2entry( Backend *be, struct passwd *pw, char *rdn )
 {
        Entry           *e;
        char            buf[256];
@@ -126,28 +230,69 @@ pw2entry( Backend *be, struct passwd *pw )
        vals[1] = NULL;
 
        /*
-        * from pw we get pw_name and make it uid and cn and sn and
-        * we get pw_gecos and make it cn and we give it an objectclass
-        * of person.
+        * from pw we get pw_name and make it cn
+        * give it an objectclass of person.
         */
 
        e = (Entry *) ch_calloc( 1, sizeof(Entry) );
        e->e_attrs = NULL;
 
-       sprintf( buf, "%s@%s", pw->pw_name, be->be_suffix[0] );
-       e->e_dn = strdup( buf );
+       /* rdn attribute type should be a configuratable item */
+       sprintf( buf, "uid=%s,%s", pw->pw_name, be->be_suffix[0] );
+       e->e_dn = ch_strdup( buf );
+       e->e_ndn = ch_strdup( buf );
+       (void) dn_normalize_case( e->e_ndn );
 
        val.bv_val = pw->pw_name;
        val.bv_len = strlen( pw->pw_name );
-       attr_merge( e, "cn", vals );
-       attr_merge( e, "sn", vals );
-       attr_merge( e, "uid", vals );
-       val.bv_val = pw->pw_gecos;
-       val.bv_len = strlen( pw->pw_gecos );
-       attr_merge( e, "cn", vals );
+       attr_merge( e, "uid", vals );   /* required by uidObject */
+       attr_merge( e, "cn", vals );    /* required by person */
+       attr_merge( e, "sn", vals );    /* required by person */
+
+#ifdef HAVE_PW_GECOS
+       /*
+        * if gecos is present, add it as a cn. first process it
+        * according to standard BSD usage. If the processed cn has
+        * a space, use the tail as the surname.
+        */
+       if (pw->pw_gecos[0]) {
+               char *s;
+
+               val.bv_val = pw->pw_gecos;
+               val.bv_len = strlen(val.bv_val);
+               attr_merge(e, "description", vals);
+
+               s = strchr(val.bv_val, ',');
+               if (s)
+                       *s = '\0';
+               s = strchr(val.bv_val, '&');
+               if (s) {
+                       int i = s - val.bv_val;
+                       strncpy(buf, val.bv_val, i);
+                       s = buf+i;
+                       strcpy(s, pw->pw_name);
+                       *s = TOUPPER(*s);
+                       strcat(s, val.bv_val+i+1);
+                       val.bv_val = buf;
+               }
+               val.bv_len = strlen(val.bv_val);
+               if ( strcmp( val.bv_val, pw->pw_name ))
+                       attr_merge( e, "cn", vals );
+               if ( (s=strrchr(val.bv_val, ' '))) {
+                       val.bv_val = s + 1;
+                       val.bv_len = strlen(val.bv_val);
+                       attr_merge(e, "sn", vals);
+               }
+       }
+#endif
+
+       /* objectclasses should be configuratable items */
        val.bv_val = "person";
        val.bv_len = strlen( val.bv_val );
        attr_merge( e, "objectclass", vals );
 
+       val.bv_val = "uidObject";
+       val.bv_len = strlen( val.bv_val );
+       attr_merge( e, "objectclass", vals );
        return( e );
 }
index ac304be956f31a510b8142195f175b26d944c264..aaaf32df41550b8165352484da3e76670e46d08f 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ########################################################################### 
 # 
 #    Copyright 1999, John C. Quillan, All rights reserved.
index ed30475ac9fa2eab7b87dc68beb104246fcef774..707b140f94e711a74e548a00a652d52edd0f40d0 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  *      Copyright 1999, John C. Quillan, All rights reserved.
  *
diff --git a/servers/slapd/back-perl/bind.c b/servers/slapd/back-perl/bind.c
new file mode 100644 (file)
index 0000000..9d20afd
--- /dev/null
@@ -0,0 +1,82 @@
+/* $OpenLDAP$ */
+/*
+ *      Copyright 1999, John C. Quillan, All rights reserved.
+ *
+ *      Redistribution and use in source and binary forms are permitted only
+ *      as authorized by the OpenLDAP Public License.  A copy of this
+ *      license is available at http://www.OpenLDAP.org/license.html or
+ *      in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include "portable.h"
+/* init.c - initialize shell backend */
+       
+#include <stdio.h>
+/*     #include <ac/types.h>
+       #include <ac/socket.h>
+*/
+
+#include <EXTERN.h>
+#include <perl.h>
+
+#include "slap.h"
+#include "perl_back.h"
+
+
+/**********************************************************
+ *
+ * Bind
+ *
+ **********************************************************/
+int
+perl_back_bind(
+       Backend *be,
+       Connection *conn,
+       Operation *op,
+       char *dn,
+       int method,
+       char            *mech,
+       struct berval *cred,
+       char** edn
+)
+{
+       int return_code;
+       int count;
+
+       PerlBackend *perl_back = (PerlBackend *) be->be_private;
+
+       *edn = NULL;
+
+       ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
+
+       {
+               dSP; ENTER; SAVETMPS;
+
+               PUSHMARK(sp);
+               XPUSHs( perl_back->pb_obj_ref );
+               XPUSHs(sv_2mortal(newSVpv( dn , 0)));
+               XPUSHs(sv_2mortal(newSVpv( cred->bv_val , cred->bv_len)));
+               PUTBACK;
+
+               count = perl_call_method("bind", G_SCALAR);
+
+               SPAGAIN;
+
+               if (count != 1) {
+                       croak("Big trouble in back_search\n");
+               }
+
+               return_code = POPi;
+                                                        
+
+               PUTBACK; FREETMPS; LEAVE;
+       }
+
+       ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );        
+
+       Debug( LDAP_DEBUG_ANY, "Perl BIND\n", 0, 0, 0 );
+
+       return ( return_code );
+}
+
+
diff --git a/servers/slapd/back-perl/close.c b/servers/slapd/back-perl/close.c
new file mode 100644 (file)
index 0000000..79b62af
--- /dev/null
@@ -0,0 +1,65 @@
+/* $OpenLDAP$ */
+/*
+ *      Copyright 1999, John C. Quillan, All rights reserved.
+ *
+ *      Redistribution and use in source and binary forms are permitted only
+ *      as authorized by the OpenLDAP Public License.  A copy of this
+ *      license is available at http://www.OpenLDAP.org/license.html or
+ *      in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include "portable.h"
+/* init.c - initialize shell backend */
+       
+#include <stdio.h>
+/*     #include <ac/types.h>
+       #include <ac/socket.h>
+*/
+
+#include <EXTERN.h>
+#include <perl.h>
+
+#include "slap.h"
+#include "perl_back.h"
+
+/**********************************************************
+ *
+ * Close
+ *
+ **********************************************************/
+
+int
+perl_back_close(
+       BackendInfo *bd
+)
+{
+       ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
+
+       perl_destruct(perl_interpreter);
+
+       ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );        
+
+       return 0;
+}
+
+int
+perl_back_destroy(
+       BackendInfo *bd
+)
+{
+       perl_free(perl_interpreter);
+       perl_interpreter = NULL;
+
+       ldap_pvt_thread_mutex_destroy( &perl_interpreter_mutex );       
+
+       return 0;
+}
+
+int
+perl_back_db_destroy(
+       BackendDB *be
+)
+{
+       free( be->be_private );
+       be->be_private = NULL;
+}
diff --git a/servers/slapd/back-perl/compare.c b/servers/slapd/back-perl/compare.c
new file mode 100644 (file)
index 0000000..4c9f390
--- /dev/null
@@ -0,0 +1,85 @@
+/* $OpenLDAP$ */
+/*
+ *      Copyright 1999, John C. Quillan, All rights reserved.
+ *
+ *      Redistribution and use in source and binary forms are permitted only
+ *      as authorized by the OpenLDAP Public License.  A copy of this
+ *      license is available at http://www.OpenLDAP.org/license.html or
+ *      in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+/*     #include <ac/types.h>
+       #include <ac/socket.h>
+*/
+
+#include <EXTERN.h>
+#include <perl.h>
+
+#include "slap.h"
+#include "perl_back.h"
+
+/**********************************************************
+ *
+ * Compare
+ *
+ **********************************************************/
+
+perl_back_compare(
+       Backend *be,
+       Connection      *conn,
+       Operation       *op,
+       char    *dn,
+       Ava             *ava
+)
+{
+       int return_code;
+       int count;
+
+       PerlBackend *perl_back = (PerlBackend *)be->be_private;
+
+       send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
+               NULL, "not yet implemented", NULL, NULL );
+
+#ifdef notdef
+       ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
+
+       {
+               dSP; ENTER; SAVETMPS;
+
+               PUSHMARK(sp);
+               XPUSHs( perl_back->pb_obj_ref );
+               XPUSHs(sv_2mortal(newSVpv( dn , 0)));
+               /* XPUSHs(sv_2mortal(newSVpv( cred->bv_val , cred->bv_len))); */
+               PUTBACK;
+
+               count = perl_call_method("bind", G_SCALAR);
+
+               SPAGAIN;
+
+               if (count != 1) {
+                       croak("Big trouble in back_search\n");
+               }
+
+               return_code = POPi;
+                                                        
+               PUTBACK; FREETMPS; LEAVE;
+       }
+
+       ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );        
+
+       if( return_code != 0 ) {
+               send_ldap_result( conn, op, LDAP_COMPARE_TRUE, NULL, NULL );
+
+       } else {
+               send_ldap_result( conn, op, LDAP_COMPARE_FALSE, NULL, NULL );
+       }
+#endif
+
+       Debug( LDAP_DEBUG_ANY, "Here BIND\n", 0, 0, 0 );
+
+       return (0);
+}
+
index 83067e5c241c0732f30bdaa323759679ae8668a0..f68a0a1282d380df62fe23a2b1c669c07a98aabd 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  *      Copyright 1999, John C. Quillan, All rights reserved.
  *
@@ -30,7 +31,7 @@
 int
 perl_back_db_config(
         BackendDB *be,
-        char *fname,
+        const char *fname,
         int lineno,
         int argc,
         char **argv
diff --git a/servers/slapd/back-perl/delete.c b/servers/slapd/back-perl/delete.c
new file mode 100644 (file)
index 0000000..19d2346
--- /dev/null
@@ -0,0 +1,74 @@
+/* $OpenLDAP$ */
+/*
+ *      Copyright 1999, John C. Quillan, All rights reserved.
+ *
+ *      Redistribution and use in source and binary forms are permitted only
+ *      as authorized by the OpenLDAP Public License.  A copy of this
+ *      license is available at http://www.OpenLDAP.org/license.html or
+ *      in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+/* #include <ac/types.h>
+#include <ac/socket.h>
+*/
+
+#include <EXTERN.h>
+#include <perl.h>
+
+#include "slap.h"
+#include "perl_back.h"
+
+perl_back_delete(
+       Backend *be,
+       Connection      *conn,
+       Operation       *op,
+       char    *dn
+)
+{
+       int len;
+       int count;
+       int return_code;
+
+       PerlBackend *perl_back = (PerlBackend *) be->be_private;
+
+       ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
+
+       {
+               dSP; ENTER; SAVETMPS;
+
+               PUSHMARK(sp);
+               XPUSHs( perl_back->pb_obj_ref );
+               XPUSHs(sv_2mortal(newSVpv( dn , 0 )));
+
+               PUTBACK;
+
+               count = perl_call_method("delete", G_SCALAR);
+
+               SPAGAIN;
+
+               if (count != 1) {
+                       croak("Big trouble in perl-back_delete\n");
+               }
+                                                        
+               return_code = POPi;
+
+               PUTBACK; FREETMPS; LEAVE;
+       }
+
+       ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );        
+
+       if( return_code != 0 ) {
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+
+       } else {
+               send_ldap_result( conn, op, LDAP_SUCCESS,
+                       NULL, NULL, NULL, NULL );
+       }
+
+       Debug( LDAP_DEBUG_ANY, "Here DELETE\n", 0, 0, 0 );
+       return( 0 );
+}
diff --git a/servers/slapd/back-perl/external.h b/servers/slapd/back-perl/external.h
new file mode 100644 (file)
index 0000000..d41fb13
--- /dev/null
@@ -0,0 +1,53 @@
+/* $OpenLDAP$ */
+#ifndef _PERL_EXTERNAL_H
+#define _PERL_EXTERNAL_H
+
+LDAP_BEGIN_DECL
+
+extern int     perl_back_initialize LDAP_P(( BackendInfo *bi ));
+extern int     perl_back_open LDAP_P(( BackendInfo *bi ));
+extern int     perl_back_close LDAP_P(( BackendInfo *bi ));
+extern int     perl_back_destroy LDAP_P(( BackendInfo *bi ));
+
+extern int     perl_back_db_init LDAP_P(( BackendDB *bd ));
+extern int     perl_back_db_destroy LDAP_P(( BackendDB *bd ));
+
+extern int     perl_back_db_config LDAP_P(( BackendDB *bd,
+       const char *fname, int lineno, int argc, char **argv ));
+
+extern int perl_back_bind LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, int method, char* mech,
+       struct berval *cred, char** edn ));
+
+extern int     perl_back_unbind LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op ));
+
+extern int     perl_back_search LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *base, int scope, int deref, int sizelimit, int timelimit,
+       Filter *filter, char *filterstr, char **attrs, int attrsonly ));
+
+extern int     perl_back_compare LDAP_P((BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, Ava   *ava ));
+
+extern int     perl_back_modify LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, LDAPModList *ml ));
+
+extern int     perl_back_modrdn LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, char*newrdn, int deleteoldrdn,
+       char *newSuperior ));
+
+extern int     perl_back_add LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op, Entry *e ));
+
+extern int     perl_back_delete LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op, char *dn ));
+
+LDAP_END_DECL
+
+#endif /* _PERL_EXTERNAL_H */
+
index c9f30913afc5bc67c9958f755bdbd6578095f362..e215acd2e6640032f27be17807a95719a2c0ed42 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  *      Copyright 1999, John C. Quillan, All rights reserved.
  *
diff --git a/servers/slapd/back-perl/modify.c b/servers/slapd/back-perl/modify.c
new file mode 100644 (file)
index 0000000..028b42e
--- /dev/null
@@ -0,0 +1,108 @@
+/* $OpenLDAP$ */
+/*
+ *      Copyright 1999, John C. Quillan, All rights reserved.
+ *
+ *      Redistribution and use in source and binary forms are permitted only
+ *      as authorized by the OpenLDAP Public License.  A copy of this
+ *      license is available at http://www.OpenLDAP.org/license.html or
+ *      in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+/* #include <ac/types.h>
+       #include <ac/socket.h>
+*/
+
+#include <EXTERN.h>
+#include <perl.h>
+
+#include "slap.h"
+#include "perl_back.h"
+
+int
+perl_back_modify(
+       Backend *be,
+       Connection      *conn,
+       Operation       *op,
+       char    *dn,
+       LDAPModList     *modlist
+)
+{
+       char test[500];
+       int return_code;
+       int count;
+       int i;
+       int err = 0;
+       char *matched = NULL, *info = NULL;
+
+       PerlBackend *perl_back = (PerlBackend *)be->be_private;
+
+       ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
+
+       {
+               dSP; ENTER; SAVETMPS;
+               
+               PUSHMARK(sp);
+               XPUSHs( perl_back->pb_obj_ref );
+               XPUSHs(sv_2mortal(newSVpv( dn , 0)));
+
+               for (; modlist != NULL; modlist = modlist->ml_next ) {
+                       LDAPMod *mods = &modlist->ml_mod;
+
+                       switch ( mods->mod_op & ~LDAP_MOD_BVALUES ) {
+                       case LDAP_MOD_ADD:
+                               XPUSHs(sv_2mortal(newSVpv("ADD", 0 )));
+                               break;
+                               
+                       case LDAP_MOD_DELETE:
+                               XPUSHs(sv_2mortal(newSVpv("DELETE", 0 )));
+                               break;
+                               
+                       case LDAP_MOD_REPLACE:
+                               XPUSHs(sv_2mortal(newSVpv("REPLACE", 0 )));
+                               break;
+                       }
+
+                       
+                       XPUSHs(sv_2mortal(newSVpv( mods->mod_type, 0 )));
+
+                       for ( i = 0;
+                               mods->mod_bvalues != NULL && mods->mod_bvalues[i] != NULL;
+                               i++ )
+                       {
+                               XPUSHs(sv_2mortal(newSVpv( mods->mod_bvalues[i]->bv_val, 0 )));
+                       }
+               }
+
+               PUTBACK;
+
+               count = perl_call_method("modify", G_SCALAR);
+
+               SPAGAIN;
+
+               if (count != 1) {
+                       croak("Big trouble in back_search\n");
+               }
+                                                        
+               return_code = POPi;
+
+               PUTBACK; FREETMPS; LEAVE;
+       }
+
+       ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );
+
+       if( return_code != 0 ) {
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+
+       } else {
+               send_ldap_result( conn, op, LDAP_SUCCESS,
+                       NULL, NULL, NULL, NULL );
+       }
+
+       Debug( LDAP_DEBUG_ANY, "Perl MODIFY\n", 0, 0, 0 );
+       return( 0 );
+}
+
diff --git a/servers/slapd/back-perl/modrdn.c b/servers/slapd/back-perl/modrdn.c
new file mode 100644 (file)
index 0000000..d747014
--- /dev/null
@@ -0,0 +1,97 @@
+/* $OpenLDAP$ */
+/*
+ *      Copyright 1999, John C. Quillan, All rights reserved.
+ *
+ *      Redistribution and use in source and binary forms are permitted only
+ *      as authorized by the OpenLDAP Public License.  A copy of this
+ *      license is available at http://www.OpenLDAP.org/license.html or
+ *      in file LICENSE in the top-level directory of the distribution.
+ */
+
+/*
+ * LDAP v3 newSuperior support.
+ *
+ * Copyright 1999, Juan C. Gomez, All rights reserved.
+ * This software is not subject to any license of Silicon Graphics 
+ * Inc. or Purdue University.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * without restriction or fee of any kind as long as this notice
+ * is preserved.
+ *
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+/*     #include <ac/types.h>
+       #include <ac/socket.h>
+*/
+
+#include <EXTERN.h>
+#include <perl.h>
+
+#include "slap.h"
+#include "perl_back.h"
+
+int
+perl_back_modrdn(
+       Backend *be,
+       Connection      *conn,
+       Operation       *op,
+       char    *dn,
+       char    *newrdn,
+       int             deleteoldrdn,
+       char    *newSuperior
+)
+{
+       int len;
+       int count;
+       int return_code;
+
+       PerlBackend *perl_back = (PerlBackend *) be->be_private;
+
+       ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
+
+       {
+               dSP; ENTER; SAVETMPS;
+               
+               PUSHMARK(sp) ;
+               XPUSHs( perl_back->pb_obj_ref );
+               XPUSHs(sv_2mortal(newSVpv( dn , 0 )));
+               XPUSHs(sv_2mortal(newSVpv( newrdn , 0 )));
+               XPUSHs(sv_2mortal(newSViv( deleteoldrdn )));
+               if ( newSuperior != NULL ) {
+                       XPUSHs(sv_2mortal(newSVpv( newSuperior , 0 )));
+               }
+               PUTBACK ;
+
+               count = perl_call_method("modrdn", G_SCALAR);
+
+               SPAGAIN ;
+
+               if (count != 1) {
+                       croak("Big trouble in back_search\n") ;
+               }
+                                                        
+               return_code = POPi;
+
+               PUTBACK; FREETMPS; LEAVE ;
+       }
+
+       ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );
+       
+       if( return_code != 0 ) {
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+
+       } else {
+               send_ldap_result( conn, op, LDAP_SUCCESS,
+                       NULL, NULL, NULL, NULL );
+       }
+
+       Debug( LDAP_DEBUG_ANY, "Perl MODRDN\n", 0, 0, 0 );
+       return( 0 );
+}
+
+
diff --git a/servers/slapd/back-perl/perl_back.h b/servers/slapd/back-perl/perl_back.h
new file mode 100644 (file)
index 0000000..6e53a7f
--- /dev/null
@@ -0,0 +1,23 @@
+/* $OpenLDAP$ */
+#ifndef PERL_BACK_H
+#define PERL_BACK_H 1
+
+LDAP_BEGIN_DECL
+
+/*
+ */
+#define EVAL_BUF_SIZE 500
+
+extern PerlInterpreter *perl_interpreter;
+extern ldap_pvt_thread_mutex_t  perl_interpreter_mutex;
+
+typedef struct perl_backend_instance {
+  char *pb_module_name;
+  SV   *pb_obj_ref;
+} PerlBackend;
+
+LDAP_END_DECL
+
+#include "external.h"
+
+#endif
diff --git a/servers/slapd/back-perl/search.c b/servers/slapd/back-perl/search.c
new file mode 100644 (file)
index 0000000..0feb288
--- /dev/null
@@ -0,0 +1,125 @@
+/* $OpenLDAP$ */
+/*
+ *      Copyright 1999, John C. Quillan, All rights reserved.
+ *
+ *      Redistribution and use in source and binary forms are permitted only
+ *      as authorized by the OpenLDAP Public License.  A copy of this
+ *      license is available at http://www.OpenLDAP.org/license.html or
+ *      in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+/*     #include <ac/types.h>
+       #include <ac/socket.h>
+*/
+
+#include <EXTERN.h>
+#include <perl.h>
+
+#include "slap.h"
+#include "perl_back.h"
+
+/**********************************************************
+ *
+ * Search
+ *
+ **********************************************************/
+int
+perl_back_search(
+       Backend *be,
+       Connection *conn,
+       Operation *op,
+       char *base,
+       int scope,
+       int deref,
+       int sizelimit,
+       int timelimit,
+       Filter *filter,
+       char *filterstr,
+       char **attrs,
+       int attrsonly
+       )
+{
+       char test[500];
+       int count ;
+       int err = 0;
+       char *matched = NULL, *info = NULL;
+       PerlBackend *perl_back = (PerlBackend *)be->be_private;
+       Entry   *e;
+       char *buf;
+       int i;
+       int return_code;
+
+       ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
+
+       {
+               dSP; ENTER; SAVETMPS;
+
+               PUSHMARK(sp) ;
+               XPUSHs( perl_back->pb_obj_ref );
+               XPUSHs(sv_2mortal(newSVpv( filterstr , 0)));
+               XPUSHs(sv_2mortal(newSViv( sizelimit )));
+               XPUSHs(sv_2mortal(newSViv( timelimit )));
+               XPUSHs(sv_2mortal(newSViv( attrsonly )));
+
+               for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
+                       XPUSHs(sv_2mortal(newSVpv( attrs[i] , 0)));
+               }
+               PUTBACK;
+
+               count = perl_call_method("search", G_ARRAY );
+
+               SPAGAIN;
+
+               if (count < 1) {
+                       croak("Big trouble in back_search\n") ;
+               }
+
+               if ( count > 1 ) {
+                                                        
+                       for ( i = 1; i < count; i++ ) {
+
+                               buf = POPp;
+
+                               if ( (e = str2entry( buf )) == NULL ) {
+                                       Debug( LDAP_DEBUG_ANY, "str2entry(%s) failed\n", buf, 0, 0 );
+
+                               } else {
+                                       send_search_entry( be, conn, op,
+                                               e, attrs, attrsonly, NULL );
+                                                        
+                                       entry_free( e );
+                               }
+                       }
+               }
+
+               /*
+                * We grab the return code last because the stack comes
+                * from perl in reverse order. 
+                *
+                * ex perl: return ( 0, $res_1, $res_2 );
+                *
+                * ex stack: <$res_2> <$res_1> <0>
+                */
+
+               return_code = POPi;
+
+
+
+               PUTBACK; FREETMPS; LEAVE;
+       }
+
+       ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );        
+
+       if( return_code != 0 ) {
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                       NULL, NULL, NULL, NULL );
+
+       } else {
+               send_ldap_result( conn, op, LDAP_SUCCESS,
+                       NULL, NULL, NULL, NULL );
+       }
+}
+
diff --git a/servers/slapd/back-perl/unbind.c b/servers/slapd/back-perl/unbind.c
new file mode 100644 (file)
index 0000000..a79f906
--- /dev/null
@@ -0,0 +1,41 @@
+/* $OpenLDAP$ */
+/*
+ *   Copyright 1999, John C. Quillan, All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms are permitted only
+ *   as authorized by the OpenLDAP Public License.  A copy of this
+ *   license is available at http://www.OpenLDAP.org/license.html or
+ *   in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include "portable.h"
+ /* init.c - initialize shell backend */
+  
+#include <stdio.h>
+/*     #include <ac/types.h>
+       #include <ac/socket.h>
+*/
+
+#include <EXTERN.h>
+#include <perl.h>
+
+#include "slap.h"
+#include "perl_back.h"
+
+
+/**********************************************************
+ *
+ * UnBind
+ *
+ **********************************************************/
+int
+perl_back_unbind(
+       Backend *be,
+       Connection *conn,
+       Operation *op
+)
+{
+       Debug( LDAP_DEBUG_TRACE, "Perl UNBIND\n", 0, 0, 0 );
+       return 0;
+}
+
index a84238bd12d3d5e7f8641182ec30004c181a18ad..e0c052cc3d26059373147da9a6be550df899d4e0 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 SRCS   = init.c config.c fork.c search.c bind.c unbind.c add.c delete.c \
                modify.c modrdn.c compare.c abandon.c result.c
 OBJS   = init.lo config.lo fork.lo search.lo bind.lo unbind.lo add.lo delete.lo \
index fc9d6a40b6162512a9c620e67aef97f72a87c083..4f2932793ecdfa2b16a027de2ed14d760e179a4c 100644 (file)
@@ -1,14 +1,18 @@
 /* abandon.c - shell backend abandon function */
+/* $OpenLDAP$ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <signal.h>
+
+#include <ac/signal.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "shell.h"
 
-void
+int
 shell_back_abandon(
     Backend    *be,
     Connection *conn,
@@ -18,34 +22,42 @@ shell_back_abandon(
 {
        struct shellinfo        *si = (struct shellinfo *) be->be_private;
        FILE                    *rfp, *wfp;
-       int                     pid;
+       pid_t                   pid;
        Operation               *o;
 
        /* no abandon command defined - just kill the process handling it */
        if ( si->si_abandon == NULL ) {
-               pthread_mutex_lock( &conn->c_opsmutex );
+               ldap_pvt_thread_mutex_lock( &conn->c_mutex );
                pid = -1;
                for ( o = conn->c_ops; o != NULL; o = o->o_next ) {
                        if ( o->o_msgid == msgid ) {
-                               pid = o->o_private;
+                               pid = (pid_t) o->o_private;
                                break;
                        }
                }
-               pthread_mutex_unlock( &conn->c_opsmutex );
+               if( pid == -1 ) {
+                       for ( o = conn->c_pending_ops; o != NULL; o = o->o_next ) {
+                               if ( o->o_msgid == msgid ) {
+                                       pid = (pid_t) o->o_private;
+                                       break;
+                               }
+                       }
+               }
+               ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
 
                if ( pid != -1 ) {
-                       Debug( LDAP_DEBUG_ARGS, "shell killing pid %d\n", pid,
-                           0, 0 );
+                       Debug( LDAP_DEBUG_ARGS, "shell killing pid %d\n",
+                              (int) pid, 0, 0 );
                        kill( pid, SIGTERM );
                } else {
                        Debug( LDAP_DEBUG_ARGS, "shell could not find op %d\n",
                            msgid, 0, 0 );
                }
-               return;
+               return 0;
        }
 
        if ( forkandexec( si->si_abandon, &rfp, &wfp ) == -1 ) {
-               return;
+               return 0;
        }
 
        /* write out the request to the abandon process */
@@ -56,4 +68,6 @@ shell_back_abandon(
 
        /* no result from abandon */
        fclose( rfp );
+
+       return 0;
 }
index 1c189a96d4b63f4dbbb1fce95a9137b881b3a256..293f3a8709a3f326010a0471ffef3ed6a630833e 100644 (file)
@@ -1,4 +1,5 @@
 /* add.c - shell backend add function */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
@@ -36,7 +37,7 @@ shell_back_add(
 
        /* write out the request to the add process */
        fprintf( wfp, "ADD\n" );
-       fprintf( wfp, "msgid: %ld\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
        print_suffixes( wfp, be );
        ldap_pvt_thread_mutex_lock( &entry2str_mutex );
        fprintf( wfp, "%s", entry2str( e, &len ) );
index dea149e4106fc4779706c3a065000fd7e976a1e5..44bd6cd5e2ca9ea06f9feb7663deceebd9cd3b49 100644 (file)
@@ -1,9 +1,13 @@
 /* bind.c - shell backend bind function */
+/* $OpenLDAP$ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "shell.h"
 
@@ -14,33 +18,37 @@ shell_back_bind(
     Operation          *op,
     char               *dn,
     int                        method,
-    struct berval      *cred
+       char            *mech,
+    struct berval      *cred,
+       char            **edn
 )
 {
        struct shellinfo        *si = (struct shellinfo *) be->be_private;
        FILE                    *rfp, *wfp;
        int                     rc;
 
+       *edn = NULL;
+
        if ( si->si_bind == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                   "bind not implemented" );
-               return;
+                   "bind not implemented", NULL, NULL );
+               return( -1 );
        }
 
-       if ( (op->o_private = forkandexec( si->si_bind, &rfp, &wfp ))
-           == -1 ) {
+       if ( (op->o_private = (void *) forkandexec( si->si_bind, &rfp, &wfp ))
+           == (void *) -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
-                   "could not fork/exec" );
-               return;
+                   "could not fork/exec", NULL, NULL );
+               return( -1 );
        }
 
        /* write out the request to the bind process */
        fprintf( wfp, "BIND\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "dn: %s\n", dn );
        fprintf( wfp, "method: %d\n", method );
-       fprintf( wfp, "credlen: %d\n", cred->bv_len );
+       fprintf( wfp, "credlen: %lu\n", cred->bv_len );
        fprintf( wfp, "cred: %s\n", cred->bv_val ); /* XXX */
        fclose( wfp );
 
index 48dfbb553be6719c9b9c9e9d858a5f80e2996f3f..940f213fc5a927a8ff8681a3922344a06753f256 100644 (file)
@@ -1,13 +1,17 @@
 /* compare.c - shell backend compare function */
+/* $OpenLDAP$ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 #include "shell.h"
 
-void
+int
 shell_back_compare(
     Backend    *be,
     Connection *conn,
@@ -21,20 +25,20 @@ shell_back_compare(
 
        if ( si->si_compare == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                   "compare not implemented" );
-               return;
+                   "compare not implemented", NULL, NULL );
+               return( -1 );
        }
 
-       if ( (op->o_private = forkandexec( si->si_compare, &rfp, &wfp ))
-           == -1 ) {
+       if ( (op->o_private = (void *) forkandexec( si->si_compare, &rfp, &wfp ))
+           == (void *) -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
-                   "could not fork/exec" );
-               return;
+                   "could not fork/exec", NULL, NULL );
+               return( -1 );
        }
 
        /* write out the request to the compare process */
        fprintf( wfp, "COMPARE\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "dn: %s\n", dn );
        fprintf( wfp, "%s: %s\n", ava->ava_type, ava->ava_value.bv_val );
@@ -44,4 +48,5 @@ shell_back_compare(
        read_and_send_results( be, conn, op, rfp, NULL, 0 );
 
        fclose( rfp );
+       return( 0 );
 }
index 5d2fa1c19a4299a386eaa4703ddc16486a8b00d0..03c7b7da76516ccd5251ab94a0ba29746eb05c73 100644 (file)
@@ -1,17 +1,20 @@
 /* config.c - shell backend configuration file routine */
+/* $OpenLDAP$ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 #include "shell.h"
 
-extern char    **charray_dup();
-
-shell_back_config(
-    Backend    *be,
-    char       *fname,
+int
+shell_back_db_config(
+    BackendDB  *be,
+    const char *fname,
     int                lineno,
     int                argc,
     char       **argv
@@ -22,7 +25,7 @@ shell_back_config(
        if ( si == NULL ) {
                fprintf( stderr, "%s: line %d: shell backend info is null!\n",
                    fname, lineno );
-               exit( 1 );
+               return( 1 );
        }
 
        /* command + args to exec for binds */
@@ -31,7 +34,7 @@ shell_back_config(
                        fprintf( stderr,
        "%s: line %d: missing executable in \"bind <executable>\" line\n",
                            fname, lineno );
-                       exit( 1 );
+                       return( 1 );
                }
                si->si_bind = charray_dup( &argv[1] );
 
@@ -41,7 +44,7 @@ shell_back_config(
                        fprintf( stderr,
        "%s: line %d: missing executable in \"unbind <executable>\" line\n",
                            fname, lineno );
-                       exit( 1 );
+                       return( 1 );
                }
                si->si_unbind = charray_dup( &argv[1] );
 
@@ -51,7 +54,7 @@ shell_back_config(
                        fprintf( stderr,
        "%s: line %d: missing executable in \"search <executable>\" line\n",
                            fname, lineno );
-                       exit( 1 );
+                       return( 1 );
                }
                si->si_search = charray_dup( &argv[1] );
 
@@ -61,7 +64,7 @@ shell_back_config(
                        fprintf( stderr,
        "%s: line %d: missing executable in \"compare <executable>\" line\n",
                            fname, lineno );
-                       exit( 1 );
+                       return( 1 );
                }
                si->si_compare = charray_dup( &argv[1] );
 
@@ -71,7 +74,7 @@ shell_back_config(
                        fprintf( stderr,
        "%s: line %d: missing executable in \"modify <executable>\" line\n",
                            fname, lineno );
-                       exit( 1 );
+                       return( 1 );
                }
                si->si_modify = charray_dup( &argv[1] );
 
@@ -81,7 +84,7 @@ shell_back_config(
                        fprintf( stderr,
        "%s: line %d: missing executable in \"modrdn <executable>\" line\n",
                            fname, lineno );
-                       exit( 1 );
+                       return( 1 );
                }
                si->si_modrdn = charray_dup( &argv[1] );
 
@@ -91,7 +94,7 @@ shell_back_config(
                        fprintf( stderr,
        "%s: line %d: missing executable in \"add <executable>\" line\n",
                            fname, lineno );
-                       exit( 1 );
+                       return( 1 );
                }
                si->si_add = charray_dup( &argv[1] );
 
@@ -101,7 +104,7 @@ shell_back_config(
                        fprintf( stderr,
        "%s: line %d: missing executable in \"delete <executable>\" line\n",
                            fname, lineno );
-                       exit( 1 );
+                       return( 1 );
                }
                si->si_delete = charray_dup( &argv[1] );
 
@@ -111,7 +114,7 @@ shell_back_config(
                        fprintf( stderr,
        "%s: line %d: missing executable in \"abandon <executable>\" line\n",
                            fname, lineno );
-                       exit( 1 );
+                       return( 1 );
                }
                si->si_abandon = charray_dup( &argv[1] );
 
@@ -121,4 +124,6 @@ shell_back_config(
 "%s: line %d: unknown directive \"%s\" in shell database definition (ignored)\n",
                    fname, lineno, argv[0] );
        }
+
+       return 0;
 }
index 0dc3439c008ce53ea77a642f8cafa2313585a2f6..27f67a2c6375de5516df322355675da3c396bcfb 100644 (file)
@@ -1,13 +1,17 @@
 /* delete.c - shell backend delete function */
+/* $OpenLDAP$ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 #include "shell.h"
 
-void
+int
 shell_back_delete(
     Backend    *be,
     Connection *conn,
@@ -20,20 +24,20 @@ shell_back_delete(
 
        if ( si->si_delete == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                   "delete not implemented" );
-               return;
+                   "delete not implemented", NULL, NULL );
+               return( -1 );
        }
 
-       if ( (op->o_private = forkandexec( si->si_delete, &rfp, &wfp ))
-           == -1 ) {
+       if ( (op->o_private = (void *) forkandexec( si->si_delete, &rfp, &wfp ))
+           == (void *) -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
-                   "could not fork/exec" );
-               return;
+                   "could not fork/exec", NULL, NULL );
+               return( -1 );
        }
 
        /* write out the request to the delete process */
        fprintf( wfp, "DELETE\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "dn: %s\n", dn );
        fclose( wfp );
@@ -41,4 +45,5 @@ shell_back_delete(
        /* read in the results and send them along */
        read_and_send_results( be, conn, op, rfp, NULL, 0 );
        fclose( rfp );
+       return( 0 );
 }
diff --git a/servers/slapd/back-shell/external.h b/servers/slapd/back-shell/external.h
new file mode 100644 (file)
index 0000000..64c2dce
--- /dev/null
@@ -0,0 +1,56 @@
+/* $OpenLDAP$ */
+#ifndef _SHELL_EXTERNAL_H
+#define _SHELL_EXTERNAL_H
+
+LDAP_BEGIN_DECL
+
+extern int     shell_back_initialize LDAP_P(( BackendInfo *bi ));
+extern int     shell_back_open LDAP_P(( BackendInfo *bi ));
+extern int     shell_back_close LDAP_P(( BackendInfo *bi ));
+extern int     shell_back_destroy LDAP_P(( BackendInfo *bi ));
+
+extern int     shell_back_db_init LDAP_P(( BackendDB *bd ));
+extern int     shell_back_db_destroy LDAP_P(( BackendDB *bd ));
+
+extern int     shell_back_db_config LDAP_P(( BackendDB *bd,
+       const char *fname, int lineno, int argc, char **argv ));
+
+extern int shell_back_bind LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, int method, char* mech,
+       struct berval *cred, char** edn ));
+
+extern int     shell_back_unbind LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op ));
+
+extern int     shell_back_search LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *base, int scope, int deref, int sizelimit, int timelimit,
+       Filter *filter, char *filterstr, char **attrs, int attrsonly ));
+
+extern int     shell_back_compare LDAP_P((BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, Ava   *ava ));
+
+extern int     shell_back_modify LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, LDAPModList *ml ));
+
+extern int     shell_back_modrdn LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op,
+       char *dn, char*newrdn, int deleteoldrdn,
+        char *newSuperior ));
+
+extern int     shell_back_add LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op, Entry *e ));
+
+extern int     shell_back_delete LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op, char *dn ));
+
+extern int     shell_back_abandon LDAP_P(( BackendDB *bd,
+       Connection *conn, Operation *op, int msgid ));
+
+LDAP_END_DECL
+
+#endif /* _SHELL_EXTERNAL_H */
+
index 1f08097b1a41aaed8604eb7849782d61c0a5dfad..34adf8b5a33e4cdd693b1b08a9a65c4100af65a7 100644 (file)
@@ -1,4 +1,5 @@
 /* fork.c - fork and exec a process, connecting stdin/out w/pipes */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
index 1b15c778c8b8314d45fc5912e34bdf01d3c23b25..57c3742c4eae7c6c635b6272f88f7ac8074ca363 100644 (file)
@@ -1,4 +1,5 @@
 /* init.c - initialize shell backend */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
index d05b79639df7f024d2c95461e996608f6aefa6fe..154bd2a6eb5c15cfbcae6d9e26949f6b5030f9a0 100644 (file)
@@ -1,19 +1,23 @@
 /* modify.c - shell backend modify function */
+/* $OpenLDAP$ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 #include "shell.h"
 
-void
+int
 shell_back_modify(
     Backend    *be,
     Connection *conn,
     Operation  *op,
     char       *dn,
-    LDAPMod    *mods
+    LDAPModList        *ml
 )
 {
        struct shellinfo        *si = (struct shellinfo *) be->be_private;
@@ -22,41 +26,41 @@ shell_back_modify(
 
        if ( si->si_modify == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                   "modify not implemented" );
-               return;
+                   "modify not implemented", NULL, NULL );
+               return( -1 );
        }
 
-       if ( (op->o_private = forkandexec( si->si_modify, &rfp, &wfp ))
-           == -1 ) {
+       if ( (op->o_private = (void *) forkandexec( si->si_modify, &rfp, &wfp ))
+           == (void *) -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
-                   "could not fork/exec" );
-               return;
+                   "could not fork/exec", NULL, NULL );
+               return( -1 );
        }
 
        /* write out the request to the modify process */
        fprintf( wfp, "MODIFY\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "dn: %s\n", dn );
-       for ( ; mods != NULL; mods = mods->mod_next ) {
-               switch ( mods->mod_op & ~LDAP_MOD_BVALUES ) {
+       for ( ; ml != NULL; ml = ml->ml_next ) {
+               switch ( ml->ml_op & ~LDAP_MOD_BVALUES ) {
                case LDAP_MOD_ADD:
-                       fprintf( wfp, "add: %s", mods->mod_type );
+                       fprintf( wfp, "add: %s\n", ml->ml_type );
                        break;
 
                case LDAP_MOD_DELETE:
-                       fprintf( wfp, "delete: %s", mods->mod_type );
+                       fprintf( wfp, "delete: %s\n", ml->ml_type );
                        break;
 
                case LDAP_MOD_REPLACE:
-                       fprintf( wfp, "replace: %s", mods->mod_type );
+                       fprintf( wfp, "replace: %s\n", ml->ml_type );
                        break;
                }
 
-               for ( i = 0; mods->mod_bvalues != NULL && mods->mod_bvalues[i]
+               for ( i = 0; ml->ml_bvalues != NULL && ml->ml_bvalues[i]
                    != NULL; i++ ) {
-                       fprintf( wfp, "%s: %s\n", mods->mod_type,
-                           mods->mod_bvalues[i]->bv_val );
+                       fprintf( wfp, "%s: %s\n", ml->ml_type,
+                           ml->ml_bvalues[i]->bv_val );
                }
        }
        fclose( wfp );
@@ -64,4 +68,6 @@ shell_back_modify(
        /* read in the results and send them along */
        read_and_send_results( be, conn, op, rfp, NULL, 0 );
        fclose( rfp );
+       return( 0 );
+
 }
index 9fd793317d19e6de0f0cf1d64722c60f4047512e..1df37d579c90b5609a418d3b3b513278eda0fc2a 100644 (file)
@@ -1,20 +1,38 @@
 /* modrdn.c - shell backend modrdn function */
+/* $OpenLDAP$ */
+
+/*
+ * LDAP v3 newSuperior support.
+ *
+ * Copyright 1999, Juan C. Gomez, All rights reserved.
+ * This software is not subject to any license of Silicon Graphics 
+ * Inc. or Purdue University.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * without restriction or fee of any kind as long as this notice
+ * is preserved.
+ *
+ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "shell.h"
 
-void
+int
 shell_back_modrdn(
     Backend    *be,
     Connection *conn,
     Operation  *op,
     char       *dn,
     char       *newrdn,
-    int                deleteoldrdn
+    int                deleteoldrdn,
+    char       *newSuperior
 )
 {
        struct shellinfo        *si = (struct shellinfo *) be->be_private;
@@ -22,27 +40,31 @@ shell_back_modrdn(
 
        if ( si->si_modrdn == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                   "modrdn not implemented" );
-               return;
+                   "modrdn not implemented", NULL, NULL );
+               return( -1 );
        }
 
-       if ( (op->o_private = forkandexec( si->si_modrdn, &rfp, &wfp ))
-           == -1 ) {
+       if ( (op->o_private = (void *) forkandexec( si->si_modrdn, &rfp, &wfp ))
+           == (void *) -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
-                   "could not fork/exec" );
-               return;
+                   "could not fork/exec", NULL, NULL );
+               return( -1 );
        }
 
        /* write out the request to the modrdn process */
        fprintf( wfp, "MODRDN\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "dn: %s\n", dn );
        fprintf( wfp, "newrdn: %s\n", newrdn );
        fprintf( wfp, "deleteoldrdn: %d\n", deleteoldrdn ? 1 : 0 );
+       if (newSuperior != NULL) {
+               fprintf( wfp, "newSuperior: %s\n", newSuperior );
+       }
        fclose( wfp );
 
        /* read in the results and send them along */
        read_and_send_results( be, conn, op, rfp, NULL, 0 );
        fclose( rfp );
+       return( 0 );
 }
index a10891c212b7645604071987647d1173797bebc3..4d9f39c2f557b093fe63952e874ee4790c680604 100644 (file)
@@ -1,4 +1,5 @@
 /* result.c - shell backend result reading function */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
index 749b112a9401238704bb7b9c4fc5606483ef1cc7..b2b6587719ba9fd30fa4fcebb6d4190d7a6da487 100644 (file)
@@ -1,15 +1,17 @@
 /* search.c - shell backend search function */
+/* $OpenLDAP$ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "shell.h"
 
-extern Entry   *str2entry();
-
-void
+int
 shell_back_search(
     Backend    *be,
     Connection *conn,
@@ -26,27 +28,25 @@ shell_back_search(
 )
 {
        struct shellinfo        *si = (struct shellinfo *) be->be_private;
-       int                     i, rc, bsize, len;
-       int                     err;
-       char                    *matched, *info;
+       int                     i;
        FILE                    *rfp, *wfp;
 
        if ( si->si_search == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                   "search not implemented" );
-               return;
+                   "search not implemented", NULL, NULL );
+               return( -1 );
        }
 
-       if ( (op->o_private = forkandexec( si->si_search, &rfp, &wfp ))
-           == -1 ) {
+       if ( (op->o_private = (void *) forkandexec( si->si_search, &rfp, &wfp ))
+           == (void *) -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
-                   "could not fork/exec" );
-               return;
+                   "could not fork/exec", NULL, NULL );
+               return( -1 );
        }
 
        /* write out the request to the search process */
        fprintf( wfp, "SEARCH\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "base: %s\n", base );
        fprintf( wfp, "scope: %d\n", scope );
@@ -66,4 +66,5 @@ shell_back_search(
        read_and_send_results( be, conn, op, rfp, attrs, attrsonly );
 
        fclose( rfp );
+       return( 0 );
 }
index 5ef493c0458ac4e7b4c9304156ed74f629d79341..573f485e8d2b4cf79049cec3c6f0ff9c115170b5 100644 (file)
@@ -1,4 +1,12 @@
 /* shell.h - shell backend header file */
+/* $OpenLDAP$ */
+
+#ifndef SLAPD_SHELL_H
+#define SLAPD_SHELL_H
+
+#include "external.h"
+
+LDAP_BEGIN_DECL
 
 struct shellinfo {
        char    **si_bind;      /* cmd + args to exec for bind    */
@@ -11,3 +19,28 @@ struct shellinfo {
        char    **si_delete;    /* cmd + args to exec for delete  */
        char    **si_abandon;   /* cmd + args to exec for abandon */
 };
+
+struct slap_backend_db;
+struct slap_conn;
+struct slap_op;
+
+extern pid_t forkandexec LDAP_P((
+       char **args,
+       FILE **rfp,
+       FILE **wfp));
+
+extern void print_suffixes LDAP_P((
+       FILE *fp,
+       struct slap_backend_db *bd));
+
+extern int read_and_send_results LDAP_P((
+       struct slap_backend_db *bd,
+       struct slap_conn *conn,
+       struct slap_op *op,
+       FILE *fp,
+       char **attrs,
+       int attrsonly));
+
+LDAP_END_DECL
+
+#endif
index 649fe96c137703e0759a2992aa6663f11622e19f..ca091da4361990c75f316340cf8d4efddb15f420 100644 (file)
@@ -1,20 +1,21 @@
 /* unbind.c - shell backend unbind function */
+/* $OpenLDAP$ */
+
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "shell.h"
 
-void
+int
 shell_back_unbind(
     Backend            *be,
     Connection         *conn,
-    Operation          *op,
-    char               *dn,
-    int                        method,
-    struct berval      *cred
+    Operation          *op
 )
 {
        struct shellinfo        *si = (struct shellinfo *) be->be_private;
@@ -22,24 +23,26 @@ shell_back_unbind(
 
        if ( si->si_unbind == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                   "unbind not implemented" );
-               return;
+                   "unbind not implemented", NULL, NULL );
+               return 0;
        }
 
-       if ( (op->o_private = forkandexec( si->si_unbind, &rfp, &wfp ))
-           == -1 ) {
+       if ( (op->o_private = (void *) forkandexec( si->si_unbind, &rfp, &wfp ))
+           == (void *) -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
-                   "could not fork/exec" );
-               return;
+                   "could not fork/exec", NULL, NULL );
+               return 0;
        }
 
        /* write out the request to the unbind process */
        fprintf( wfp, "UNBIND\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
        print_suffixes( wfp, be );
-       fprintf( wfp, "dn: %s\n", dn );
+       fprintf( wfp, "dn: %s\n", (conn->c_dn ? conn->c_dn : "") );
        fclose( wfp );
 
        /* no response to unbind */
        fclose( rfp );
+
+       return 0;
 }
index 48de79146080d158b82e782cb5b30cd4b25f2727..6a565402e61f0b70a8ff158fc6042a2c743f8750 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ########################################################################### 
 # 
 # Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
diff --git a/servers/slapd/back-tcl/external.h b/servers/slapd/back-tcl/external.h
new file mode 100644 (file)
index 0000000..ece4c51
--- /dev/null
@@ -0,0 +1,58 @@
+/* $OpenLDAP$ */
+
+#ifndef _TCL_EXTERNAL_H
+#define _TCL_EXTERNAL_H
+
+LDAP_BEGIN_DECL
+
+extern int tcl_back_initialize LDAP_P ((BackendInfo * bi));
+extern int tcl_back_open LDAP_P ((BackendInfo * bi));
+extern int tcl_back_close LDAP_P ((BackendInfo * bi));
+extern int tcl_back_destroy LDAP_P ((BackendInfo * bi));
+
+extern int tcl_back_db_init LDAP_P ((BackendDB * bd));
+extern int tcl_back_db_open LDAP_P ((BackendDB * bd));
+extern int tcl_back_db_close LDAP_P ((BackendDB * bd));
+extern int tcl_back_db_destroy LDAP_P ((BackendDB * bd));
+
+extern int tcl_back_db_config LDAP_P ((BackendDB * bd,
+               const char *fname, int lineno, int argc, char **argv));
+
+extern int tcl_back_bind LDAP_P ((BackendDB * bd,
+               Connection * conn, Operation * op,
+               char *dn, int method, char *mech,
+               struct berval * cred, char **edn));
+
+extern int tcl_back_unbind LDAP_P ((BackendDB * bd,
+               Connection * conn, Operation * op));
+
+extern int tcl_back_search LDAP_P ((BackendDB * bd,
+               Connection * conn, Operation * op,
+               char *base, int scope, int deref, int sizelimit, int timelimit,
+               Filter * filter, char *filterstr, char **attrs, int attrsonly));
+
+extern int tcl_back_compare LDAP_P ((BackendDB * bd,
+               Connection * conn, Operation * op,
+               char *dn, Ava * ava));
+
+extern int tcl_back_modify LDAP_P ((BackendDB * bd,
+               Connection * conn, Operation * op,
+               char *dn, LDAPModList * ml));
+
+extern int tcl_back_modrdn LDAP_P ((BackendDB * bd,
+               Connection * conn, Operation * op,
+               char *dn, char *newrdn, int deleteoldrdn,
+               char *newSuperior));
+
+extern int tcl_back_add LDAP_P ((BackendDB * bd,
+               Connection * conn, Operation * op, Entry * e));
+
+extern int tcl_back_delete LDAP_P ((BackendDB * bd,
+               Connection * conn, Operation * op, char *dn));
+
+extern int tcl_back_abandon LDAP_P ((BackendDB * bd,
+               Connection * conn, Operation * op, int msgid));
+
+LDAP_END_DECL
+
+#endif /* _TCL_EXTERNAL_H */
diff --git a/servers/slapd/back-tcl/tcl_abandon.c b/servers/slapd/back-tcl/tcl_abandon.c
new file mode 100644 (file)
index 0000000..5fcf8c5
--- /dev/null
@@ -0,0 +1,58 @@
+/* $OpenLDAP$ */
+/* abandon.c - tcl abandon routine
+ *
+ * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include "slap.h"
+#include "tcl_back.h"
+
+int
+tcl_back_abandon (
+       Backend * be,
+       Connection * conn,
+       Operation * op,
+       int msgid
+)
+{
+       char *suf_tcl, *results, *command;
+       int i, code, err = 0;
+       struct tclinfo *ti = (struct tclinfo *) be->be_private;
+
+       if (ti->ti_abandon == NULL) {
+               return (-1);
+       }
+
+       for (i = 0; be->be_suffix[i] != NULL; i++);
+       suf_tcl = Tcl_Merge (i, be->be_suffix);
+
+       command = (char *) ch_malloc (strlen (ti->ti_abandon) + strlen (suf_tcl)
+               + 20);
+       sprintf (command, "%s ABANDON {%ld} {%s}",
+               ti->ti_abandon, op->o_msgid, suf_tcl);
+       Tcl_Free (suf_tcl);
+
+       ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex);
+       code = Tcl_GlobalEval (ti->ti_ii->interp, command);
+       results = (char *) ch_strdup (ti->ti_ii->interp->result);
+       ldap_pvt_thread_mutex_unlock (&tcl_interpreter_mutex);
+       free (command);
+
+       if (code != TCL_OK) {
+               err = LDAP_OPERATIONS_ERROR;
+               Debug (LDAP_DEBUG_SHELL, "tcl_abandon_error: %s\n", results,
+                       0, 0);
+       }
+
+       free (results);
+       return (err);
+}
index e7c83ee0369784c5ba84b032117bfdee840af4a6..e2d324bba63fb996759f574cd6226946b41e3ade 100644 (file)
@@ -1,6 +1,5 @@
+/* $OpenLDAP$ */
 /* add.c - tcl add routine
- *
- * $Id: tcl_add.c,v 1.7 1999/08/02 23:38:43 hallvard Exp $
  *
  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
  *
diff --git a/servers/slapd/back-tcl/tcl_back.h b/servers/slapd/back-tcl/tcl_back.h
new file mode 100644 (file)
index 0000000..cba34eb
--- /dev/null
@@ -0,0 +1,64 @@
+/* $OpenLDAP$ */
+/* tcl_back.h - tcl backend header (structs, functions)
+ *
+ * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include <tcl.h>
+
+#ifndef SLAPD_TCL_H
+#define SLAPD_TCL_H
+
+#include <ldap_cdefs.h>
+#include "external.h"
+
+extern ldap_pvt_thread_mutex_t tcl_interpreter_mutex;
+
+struct i_info {
+       Tcl_Interp *interp;
+       char *name;
+       struct i_info *next;
+       int count;
+};
+
+extern struct i_info *global_i;
+
+struct tclinfo {
+       char *script_path;
+       struct i_info *ti_ii;
+       char *ti_bind;
+       char *ti_unbind;
+       char *ti_search;
+       char *ti_compare;
+       char *ti_modify;
+       char *ti_modrdn;
+       char *ti_add;
+       char *ti_delete;
+       char *ti_abandon;
+};
+
+void readtclscript (char *script, Tcl_Interp * my_tcl);
+char *tcl_clean_entry (Entry * e);
+
+int tcl_ldap_debug (
+       ClientData clientData,
+       Tcl_Interp * interp,
+       int argc,
+       char *argv[]
+);
+
+int interp_send_results (
+       Backend * be,
+       Connection * conn,
+       Operation * op,
+       char *result,
+       char **attrs,
+       int attrsonly
+);
+
+#endif
index dffb75722c7c227bac3dc32f4835da5d2bbd7e41..a26da559f9ce7b3e970e63d6b7a35129d77a8d24 100644 (file)
@@ -1,6 +1,5 @@
+/* $OpenLDAP$ */
 /* bind.c - tcl bind routines
- *
- * $Id: tcl_bind.c,v 1.8 1999/08/02 23:38:43 hallvard Exp $
  *
  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
  *
diff --git a/servers/slapd/back-tcl/tcl_close.c b/servers/slapd/back-tcl/tcl_close.c
new file mode 100644 (file)
index 0000000..4fb893a
--- /dev/null
@@ -0,0 +1,82 @@
+/* $OpenLDAP$ */
+/* close.c - tcl close routines
+ *
+ * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include "slap.h"
+#include "tcl_back.h"
+
+int
+tcl_back_close (
+       BackendInfo * bi
+)
+{
+       Tcl_DeleteInterp (global_i->interp);
+
+       return (0);
+}
+
+int
+tcl_back_destroy (
+       BackendInfo * bi
+)
+{
+       free (global_i->interp);
+       free (global_i);
+       ldap_pvt_thread_mutex_destroy (&tcl_interpreter_mutex);
+
+       return (0);
+}
+
+int
+tcl_back_db_close (
+       BackendDB * bd
+)
+{
+       struct tclinfo *ti = (struct tclinfo *) bd->be_private;
+       struct i_info *ti_tmp;
+
+       /* Disable the interp and associated struct */
+       ti->ti_ii->count--;
+       if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) {
+               /* no more db's using this and it's not the default */
+               for (ti_tmp = global_i; ti_tmp->next != ti->ti_ii; ti_tmp
+                       = ti_tmp->next);
+               /* This bypasses this interp struct in the global hash */
+               ti_tmp->next = ti->ti_ii->next;
+               Tcl_DeleteInterp (ti->ti_ii->interp);
+       }
+       return (0);
+}
+
+int
+tcl_back_db_destroy (
+       BackendDB * bd
+)
+{
+       struct tclinfo *ti = (struct tclinfo *) bd->be_private;
+
+       /*
+        * Now free up the allocated memory used
+        */
+       ti->ti_ii->count--;
+       if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) {
+               free (ti->ti_ii->interp);
+               free (ti->ti_ii);
+               free (ti);
+       }
+       free (bd->be_private);
+       bd->be_private = NULL;
+
+       return (0);
+}
index 9e587ad748166453aaacc51566d17c9327410e07..06d23f54de9549da83ab8e1ee47e768ed90b92a9 100644 (file)
@@ -1,6 +1,5 @@
+/* $OpenLDAP$ */
 /* compare.c - tcl compare routines
- *
- * $Id: tcl_compare.c,v 1.7 1999/08/02 23:38:43 hallvard Exp $
  *
  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
  *
diff --git a/servers/slapd/back-tcl/tcl_config.c b/servers/slapd/back-tcl/tcl_config.c
new file mode 100644 (file)
index 0000000..64174bc
--- /dev/null
@@ -0,0 +1,182 @@
+/* $OpenLDAP$ */
+/* config.c - tcl backend configuration file routine
+ *
+ * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include "slap.h"
+#include "tcl_back.h"
+
+struct i_info *global_i;
+
+int
+tcl_back_db_config (
+       BackendDB * bd,
+       const char *fname,
+       int lineno,
+       int argc,
+       char **argv
+)
+{
+       struct tclinfo *ti = (struct tclinfo *) bd->be_private;
+       int script_loaded = 0;
+
+       if (ti == NULL) {
+               fprintf (stderr,
+                       "%s: line %d: tcl backend info is null!\n", fname,
+                       lineno);
+               return (1);
+       }
+       if (ti->ti_ii == NULL) {
+               ti->ti_ii = global_i;
+       }
+
+       /* Script to load */
+       if (strcasecmp (argv[0], "scriptpath") == 0) {
+               if (argc < 2) {
+                       Debug (LDAP_DEBUG_CONFIG,
+                               "%s: line %d: missing script in \"scriptpath <script>\" line\n",
+                               fname, lineno, 0);
+                       return (1);
+               }
+               ti->script_path = (char *) ch_strdup (argv[1]);
+
+               /* use local interpreter */
+       } else if (strcasecmp (argv[0], "tclrealm") == 0) {
+               struct i_info *ii;
+
+               if (argc < 2) {
+                       Debug (LDAP_DEBUG_CONFIG,
+                               "%s: line %d: missing script in \"tclrealm <name>\" line\n",
+                               fname, lineno, 0);
+                       return (1);
+               }
+               ti->ti_ii = NULL;
+
+               ii = global_i;
+               /* Try to see if it already exists */
+               do {
+                       if (ii != NULL && !strcasecmp (ii->name, argv[1]))
+                               ti->ti_ii = ii;
+                       if (ii->next != NULL)
+                               ii = ii->next;
+               } while (ii->next != NULL);
+
+               if (ti->ti_ii == NULL) {        /* we need to make a new one */
+                       ii->next = (struct i_info *) ch_malloc
+                               (sizeof (struct i_info));
+
+                       ii->next->count = 0;
+                       ii->next->name = (char *) ch_strdup (argv[1]);
+                       ii->next->interp = NULL;
+                       ii->next->next = NULL;
+                       ti->ti_ii = ii->next;
+               }
+
+               /* proc for binds */
+       } else if (strcasecmp (argv[0], "bind") == 0) {
+               if (argc < 2) {
+                       Debug (LDAP_DEBUG_CONFIG,
+                               "%s: line %d: missing proc in \"bind <proc>\" line\n",
+                               fname, lineno, 0);
+                       return (1);
+               }
+               ti->ti_bind = (char *) ch_strdup (argv[1]);
+
+               /* proc for unbinds */
+       } else if (strcasecmp (argv[0], "unbind") == 0) {
+               if (argc < 2) {
+                       Debug (LDAP_DEBUG_CONFIG,
+                               "%s: line %d: missing proc in \"unbind <proc>\" line\n",
+                               fname, lineno, 0);
+                       return (1);
+               }
+               ti->ti_unbind = (char *) ch_strdup (argv[1]);
+
+               /* proc for search */
+       } else if (strcasecmp (argv[0], "search") == 0) {
+               if (argc < 2) {
+                       Debug (LDAP_DEBUG_CONFIG,
+                               "%s: line %d: missing proc in \"search <proc>\" line\n",
+                               fname, lineno, 0);
+                       return (1);
+               }
+               ti->ti_search = (char *) ch_strdup (argv[1]);
+
+               /* proc for compares */
+       } else if (strcasecmp (argv[0], "compare") == 0) {
+               if (argc < 2) {
+                       Debug (LDAP_DEBUG_CONFIG,
+                               "%s: line %d: missing proc in \"compare <proc>\" line\n",
+                               fname, lineno, 0);
+                       return (1);
+               }
+               ti->ti_compare = (char *) ch_strdup (argv[1]);
+
+               /* proc for modify */
+       } else if (strcasecmp (argv[0], "modify") == 0) {
+               if (argc < 2) {
+                       Debug (LDAP_DEBUG_CONFIG,
+                               "%s: line %d: missing proc in \"modify <proc>\" line\n",
+                               fname, lineno, 0);
+                       return (1);
+               }
+               ti->ti_modify = (char *) ch_strdup (argv[1]);
+
+               /* proc for modrdn */
+       } else if (strcasecmp (argv[0], "modrdn") == 0) {
+               if (argc < 2) {
+                       Debug (LDAP_DEBUG_CONFIG,
+                               "%s: line %d: missing proc in \"modrdn <proc>\" line\n",
+                               fname, lineno, 0);
+                       return (1);
+               }
+               ti->ti_modrdn = (char *) ch_strdup (argv[1]);
+
+               /* proc for add */
+       } else if (strcasecmp (argv[0], "add") == 0) {
+               if (argc < 2) {
+                       Debug (LDAP_DEBUG_CONFIG,
+                               "%s: line %d: missing proc in \"add <proc>\" line\n",
+                               fname, lineno, 0);
+                       return (1);
+               }
+               ti->ti_add = (char *) ch_strdup (argv[1]);
+
+               /* proc for delete */
+       } else if (strcasecmp (argv[0], "delete") == 0) {
+               if (argc < 2) {
+                       Debug (LDAP_DEBUG_CONFIG,
+                               "%s: line %d: missing proc in \"delete <proc>\" line\n",
+                               fname, lineno, 0);
+                       return (1);
+               }
+               ti->ti_delete = (char *) ch_strdup (argv[1]);
+
+               /* proc for abandon */
+       } else if (strcasecmp (argv[0], "abandon") == 0) {
+               if (argc < 2) {
+                       Debug (LDAP_DEBUG_CONFIG,
+                               "%s: line %d: missing proc in \"abandon <proc>\" line\n",
+                               fname, lineno, 0);
+                       return (1);
+               }
+               ti->ti_search = (char *) ch_strdup (argv[1]);
+
+       } else {
+               Debug (LDAP_DEBUG_CONFIG,
+                       "Unknown tcl backend config: %s\n", argv[0], 0, 0);
+               return (1);
+       }
+
+       return 0;
+}
index 7d82c3f7ca0ac47c91746cb33832685c14aa293b..53946ec63c7f20e7486e3508c59b5fcf8e4e9744 100644 (file)
@@ -1,6 +1,5 @@
+/* $OpenLDAP$ */
 /* delete.c - tcl delete routines
- *
- * $Id: tcl_delete.c,v 1.7 1999/08/02 23:38:43 hallvard Exp $
  *
  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
  *
index fc3bc1ebf0f730d22f094418d265a25fbb0c952f..8acaa3c4dc8315aeb58ffda2ea361f29912a2515 100644 (file)
@@ -1,6 +1,5 @@
+/* $OpenLDAP$ */
 /* tcl_init.c - tcl backend initialization
- *
- * $Id: tcl_init.c,v 1.11 1999/08/07 09:37:45 hyc Exp $
  *
  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
  *
index 569ee2ea91fee3f8b744efbfd0eb32725d662734..e79bc943d83db4ab06c0bdeea3fdc7340c4092be 100644 (file)
@@ -1,6 +1,5 @@
+/* $OpenLDAP$ */
 /* modify.c - tcl modify routines
- *
- * $Id: tcl_modify.c,v 1.7 1999/08/02 23:38:43 hallvard Exp $
  *
  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
  *
index 2c98f92864804985f1d6478030ce3a512b7803e7..d6aa9fbdf347246dec5006ae9fa4144615aebac7 100644 (file)
@@ -1,6 +1,5 @@
+/* $OpenLDAP$ */
 /* modrdn.c - tcl modify rdn routines
- *
- * $Id: tcl_modrdn.c,v 1.9 1999/08/02 23:38:43 hallvard Exp $
  *
  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
  *
index 7463c62d515e1cf477537e46e4c5c5bc2ec24498..a26c4820f7311dde3bffd370b3970e495b16cc55 100644 (file)
@@ -1,6 +1,5 @@
+/* $OpenLDAP$ */
 /* search.c - tcl search routines
- *
- * $Id: tcl_search.c,v 1.7 1999/08/02 23:38:43 hallvard Exp $
  *
  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
  *
diff --git a/servers/slapd/back-tcl/tcl_unbind.c b/servers/slapd/back-tcl/tcl_unbind.c
new file mode 100644 (file)
index 0000000..a4f5477
--- /dev/null
@@ -0,0 +1,57 @@
+/* $OpenLDAP$ */
+/* unbind.c - tcl unbind routines
+ *
+ * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include "slap.h"
+#include "tcl_back.h"
+
+int
+tcl_back_unbind (
+       Backend * be,
+       Connection * conn,
+       Operation * op
+)
+{
+       char *command, *suf_tcl, *results;
+       int i, code, err = 0;
+       struct tclinfo *ti = (struct tclinfo *) be->be_private;
+
+       if (ti->ti_unbind == NULL) {
+               return (-1);
+       }
+
+       for (i = 0; be->be_suffix[i] != NULL; i++);
+       suf_tcl = Tcl_Merge (i, be->be_suffix);
+
+       command = (char *) ch_malloc (strlen (ti->ti_unbind) + strlen (suf_tcl)
+               + strlen (conn->c_dn ? conn->c_dn : "") + 64);
+       sprintf (command, "%s UNBIND {%ld} {%s} {%s}",
+               ti->ti_unbind, op->o_msgid, suf_tcl, conn->c_dn ?
+               conn->c_dn : "");
+       Tcl_Free (suf_tcl);
+
+       ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex);
+       code = Tcl_GlobalEval (ti->ti_ii->interp, command);
+       results = (char *) ch_strdup (ti->ti_ii->interp->result);
+       ldap_pvt_thread_mutex_unlock (&tcl_interpreter_mutex);
+       free (command);
+
+       if (code != TCL_OK) {
+               Debug (LDAP_DEBUG_SHELL, "tcl_unbind_error: %s\n", results,
+                       0, 0);
+       }
+
+       free (results);
+       return (err);
+}
index 290a672d3dafd2feee5ae4c843c4adf7b7cf2f74..4e57669d315d72d90eab0e1defbbfe5e0a4e8169 100644 (file)
@@ -1,6 +1,5 @@
+/* $OpenLDAP$ */
 /* result.c - tcl backend utility functions
- *
- * $Id: tcl_util.c,v 1.9 1999/08/17 17:01:02 kdz Exp $
  *
  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
  *
index 7e8a1cf327caebe660b2169e5130432310e776b7..39c3fdb8a99a097113073b70976597a14960e629 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -17,8 +18,6 @@
 #include "slap.h"
 #include "lutil.h"
 
-#include "ldap_defaults.h"
-
 #ifdef SLAPD_LDAP
 #include "back-ldap/external.h"
 #endif
@@ -277,8 +276,6 @@ int backend_shutdown( Backend *be )
 
        /* close each backend database */
        for( i = 0; i < nBackendDB; i++ ) {
-               BackendInfo  *bi;
-
                if ( backendDB[i].bd_info->bi_db_close ) {
                        backendDB[i].bd_info->bi_db_close(
                                &backendDB[i] );
@@ -287,7 +284,7 @@ int backend_shutdown( Backend *be )
                if(rc != 0) {
                        Debug( LDAP_DEBUG_ANY,
                                "backend_close: bi_close %s failed!\n",
-                               bi->bi_type, 0, 0 );
+                               backendDB[i].be_type, 0, 0 );
                }
        }
 
@@ -339,7 +336,7 @@ int backend_destroy(void)
        return 0;
 }
 
-BackendInfo* backend_info(char *type)
+BackendInfo* backend_info(const char *type)
 {
        int i;
 
@@ -356,7 +353,7 @@ BackendInfo* backend_info(char *type)
 
 BackendDB *
 backend_db_init(
-    char       *type
+    const char *type
 )
 {
        Backend *be;
@@ -380,6 +377,9 @@ backend_db_init(
        be->be_sizelimit = defsize;
        be->be_timelimit = deftime;
 
+       /* assign a default depth limit for alias deref */
+       be->be_max_deref_depth = SLAPD_DEFAULT_MAXDEREFDEPTH; 
+
        be->be_realm = global_realm != NULL
                ? ch_strdup( global_realm ) : NULL;
 
@@ -410,7 +410,7 @@ be_db_close( void )
 }
 
 Backend *
-select_backend( char * dn )
+select_backend( const char * dn )
 {
        int     i, j, len, dnlen;
 
@@ -452,7 +452,7 @@ select_backend( char * dn )
 int
 be_issuffix(
     Backend    *be,
-    char       *suffix
+    const char *suffix
 )
 {
        int     i;
@@ -467,7 +467,7 @@ be_issuffix(
 }
 
 int
-be_isroot( Backend *be, char *ndn )
+be_isroot( Backend *be, const char *ndn )
 {
        int rc;
 
@@ -491,7 +491,7 @@ be_root_dn( Backend *be )
 }
 
 int
-be_isroot_pw( Backend *be, char *ndn, struct berval *cred )
+be_isroot_pw( Backend *be, const char *ndn, struct berval *cred )
 {
        int result;
 
@@ -578,10 +578,10 @@ int
 backend_group(
        Backend *be,
        Entry   *target,
-       char    *gr_ndn,
-       char    *op_ndn,
-       char    *objectclassValue,
-       char    *groupattrName
+       const char      *gr_ndn,
+       const char      *op_ndn,
+       const char      *objectclassValue,
+       const char      *groupattrName
 )
 {
        if (be->be_group)
index 196fa67cf32957ceb0bb4e72fa00f313586d88fb..d42080d70f6954ff0439cfe66af722ece03e648c 100644 (file)
@@ -1,4 +1,5 @@
 /* bind.c - decode an ldap bind operation and pass it to a backend db */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -35,7 +36,8 @@ do_bind(
        ber_int_t               version;
        ber_tag_t method;
        char            *mech;
-       char            *dn, *ndn;
+       char            *dn;
+       char *ndn;
        ber_tag_t       tag;
        int                     rc = LDAP_SUCCESS;
        struct berval   cred;
index 5c57c7c021e3b070d7967082952d46fc05f521e1..72d63b69e23a839cb10426715b7d73bda4e7610d 100644 (file)
@@ -1,4 +1,5 @@
 /* ch_malloc.c - malloc routines that test returns from malloc and friends */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index c7902bb844117499f0c8a99459be7472916779e5..60c212e509042940ba3cf8d3539516f9f5838ef0 100644 (file)
@@ -1,4 +1,5 @@
 /* charray.c - routines for dealing with char * arrays */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -16,7 +17,7 @@
 void
 charray_add(
     char       ***a,
-    char       *s
+    const char *s
 )
 {
        int     n;
@@ -80,7 +81,7 @@ charray_free( char **array )
 int
 charray_inlist(
     char       **a,
-    char       *s
+    const char *s
 )
 {
        int     i;
@@ -143,15 +144,16 @@ charray2str( char **a )
 
 
 char **
-str2charray( char *str, char *brkstr )
+str2charray( const char *str_in, const char *brkstr )
 {
+       char    *str;
        char    **res;
        char    *s;
        char    *lasts;
        int     i;
 
        /* protect the input string from strtok */
-       str = ch_strdup( str );
+       str = ch_strdup( str_in );
 
        i = 1;
        for ( s = str; *s; s++ ) {
index e0625f20bc91e4a0a3b2e429b5be70aa21291993..1176265b413fbca6012f07699e2f82c3d826eab1 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 294b8ed06ff19282e9a09c16cccb9012f18ca1e5..493045cdf2dfe24ad6494fe0a107b042170c8613 100644 (file)
@@ -1,4 +1,5 @@
 /* config.c - configuration file handling routines */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -15,7 +16,7 @@
 #include <ac/ctype.h>
 #include <ac/socket.h>
 
-#include "ldap_defaults.h"
+#include "ldap_pvt.h"
 #include "slap.h"
 
 #define MAXARGS        100
@@ -27,6 +28,7 @@ int           defsize = SLAPD_DEFAULT_SIZELIMIT;
 int            deftime = SLAPD_DEFAULT_TIMELIMIT;
 AccessControl  *global_acl = NULL;
 int            global_default_access = ACL_READ;
+int            global_readonly = 0;
 char           *replogfile;
 int            global_lastmod = ON;
 int            global_idletimeout = 0;
@@ -43,7 +45,7 @@ static int    fp_parse_line(char *line, int *argcp, char **argv);
 static char    *strtok_quote(char *line, char *sep);
 
 int
-read_config( char *fname )
+read_config( const char *fname )
 {
        FILE    *fp;
        char    *line, *savefname, *saveline;
@@ -132,9 +134,6 @@ read_config( char *fname )
                        bi = NULL;
                        be = backend_db_init( cargv[1] );
 
-               /* assign a default depth limit for alias deref */
-               be->be_max_deref_depth = SLAPD_DEFAULT_MAXDEREFDEPTH; 
-
                /* get pid file name */
                } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
                        if ( cargc < 2 ) {
@@ -235,7 +234,7 @@ read_config( char *fname )
                                char *dn = ch_strdup( cargv[1] );
                                (void) dn_normalize( dn );
                                charray_add( &be->be_suffix, dn );
-                               (void) str2upper( dn );
+                               (void) ldap_pvt_str2upper( dn );
                                charray_add( &be->be_nsuffix, dn );
                                free( dn );
                        }
@@ -368,9 +367,7 @@ read_config( char *fname )
                                return( 1 );
                        }
                        if ( be == NULL ) {
-                               Debug( LDAP_DEBUG_ANY,
-"%s: line %d: readonly line must appear inside a database definition (ignored)\n",
-                                   fname, lineno, 0 );
+                               global_readonly = (strcasecmp( cargv[1], "on" ) == 0);
                        } else {
                                if ( strcasecmp( cargv[1], "on" ) == 0 ) {
                                        be->be_readonly = 1;
index 9a70a9abdcf281ea8368d781eed85fb9bd5018dd..692b8575f203f33b8375fd88017fd2faa3372772 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -21,7 +22,6 @@
 #include <ac/string.h>
 #include <ac/socket.h>
 
-#include "ldap_defaults.h"
 #include "slap.h"
 
 #if defined( SLAPD_CONFIG_DN )
index 4a23bb56bda55baae3448d16355192ced4fddfce..9c6e61d593bf335b4d0674d67ce3e9a6adefd1d8 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -35,7 +36,9 @@ static unsigned long conn_nextid = 0;
 #define SLAP_C_BINDING                 0x03    /* binding */
 #define SLAP_C_CLOSING                 0x04    /* closing */
 
-char* connection_state2str( int state ) {
+const char *
+connection_state2str( int state )
+{
        switch( state ) {
        case SLAP_C_INVALID:    return "!";             
        case SLAP_C_INACTIVE:   return "|";             
@@ -348,8 +351,6 @@ long connection_init(
 #endif
 
     assert( c != NULL );
-    assert( c->c_struct_state != SLAP_C_USED );
-    assert( c->c_conn_state == SLAP_C_INVALID );
 
     if( c->c_struct_state == SLAP_C_UNINITIALIZED ) {
         c->c_dn = NULL;
@@ -370,6 +371,7 @@ long connection_init(
 #endif
 
         c->c_sb = ber_sockbuf_alloc( );
+               c->c_currentber = NULL;
 
         /* should check status of thread calls */
         ldap_pvt_thread_mutex_init( &c->c_mutex );
@@ -395,6 +397,7 @@ long connection_init(
 #ifdef HAVE_CYRUS_SASL
        assert( c->c_sasl_context == NULL );
 #endif
+       assert( c->c_currentber == NULL );
 
        c->c_listener_url = ch_strdup( url  );
        c->c_peer_domain = ch_strdup( dnsname  );
@@ -502,6 +505,11 @@ connection_destroy( Connection *c )
        }
 #endif
 
+       if ( c->c_currentber != NULL ) {
+               ber_free( c->c_currentber, 1 );
+               c->c_currentber = NULL;
+       }
+
        if ( ber_pvt_sb_in_use(c->c_sb) ) {
                int sd = ber_pvt_sb_get_desc(c->c_sb);
 
@@ -916,8 +924,7 @@ connection_input(
 
                Debug( LDAP_DEBUG_TRACE,
                        "ber_get_next on fd %d failed errno=%d (%s)\n",
-                       ber_pvt_sb_get_desc( conn->c_sb ), err,
-                       err > -1 && err < sys_nerr ?  sys_errlist[err] : "unknown" );
+                       ber_pvt_sb_get_desc( conn->c_sb ), err, STRERROR(err) );
                Debug( LDAP_DEBUG_TRACE,
                        "\t*** got %ld of %lu so far\n",
                        (long)(conn->c_currentber->ber_rwptr - conn->c_currentber->ber_buf),
index b60af869aedefd72ff395a23eab36354503483c1..03100eb05bedd4ffc5bcbb80c774be1ad534a3a8 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /* 
  * Copyright 1999 The OpenLDAP Foundation.
  * All rights reserved.
index 666b6cf20d95cec6a2b158ac85d02bc561f06130..b5e55316907db793a7cfa7f98f5ae28a3a5db47c 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -15,7 +16,8 @@
 #include <ac/time.h>
 #include <ac/unistd.h>
 
-#include "ldap_defaults.h"
+#include "ldap_pvt.h"
+#include "lutil.h"
 #include "slap.h"
 
 #ifdef HAVE_TCPD
@@ -41,30 +43,14 @@ typedef struct slap_listener {
 
 Listener **slap_listeners = NULL;
 
+static ber_socket_t wake_sds[2];
+
+#define WAKE_LISTENER(w) \
+do { if (w) tcp_write( wake_sds[1], "0", 1 ); } while(0)
+
 #ifdef HAVE_WINSOCK2
 /* in nt_main.c */
 extern ldap_pvt_thread_cond_t                  started_event;
-
-/* forward reference */
-static void hit_socket(void);
-/* In wsa_err.c */
-char *WSAGetLastErrorString();
-static ldap_pvt_thread_t hit_tid;
-
-#define WAKE_LISTENER(w) \
-do {\
-    if( w ) {\
-        ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );\
-        hit_socket(); \
-    }\
-} while(0)
-#else
-#define WAKE_LISTENER(w) \
-do {\
-    if( w ) {\
-        ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );\
-    }\
-} while(0)
 #endif
 
 #ifndef HAVE_WINSOCK
@@ -73,7 +59,6 @@ static
 volatile sig_atomic_t slapd_shutdown = 0;
 
 static ldap_pvt_thread_t       listener_tid;
-static volatile sig_atomic_t slapd_listener = 0;
 
 static struct slap_daemon {
        ldap_pvt_thread_mutex_t sd_mutex;
@@ -123,7 +108,6 @@ static void slapd_add(ber_socket_t s) {
  */
 void slapd_remove(ber_socket_t s, int wake) {
        ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
-       WAKE_LISTENER(wake);
 
        Debug( LDAP_DEBUG_CONNS, "daemon: removing %ld%s%s\n",
                (long) s,
@@ -135,62 +119,47 @@ void slapd_remove(ber_socket_t s, int wake) {
        FD_CLR( s, &slap_daemon.sd_writers );
 
        ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
+       WAKE_LISTENER(wake);
 }
 
 void slapd_clr_write(ber_socket_t s, int wake) {
        ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
-       WAKE_LISTENER(wake);
 
        assert( FD_ISSET( s, &slap_daemon.sd_actives) );
        FD_CLR( s, &slap_daemon.sd_writers );
 
        ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
-
-       if( wake ) {
-               ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );
-       }
+       WAKE_LISTENER(wake);
 }
 
 void slapd_set_write(ber_socket_t s, int wake) {
        ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
-    WAKE_LISTENER(wake);
 
        assert( FD_ISSET( s, &slap_daemon.sd_actives) );
        FD_SET( (unsigned) s, &slap_daemon.sd_writers );
 
        ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
-
-       if( wake ) {
-               ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );
-       }
+       WAKE_LISTENER(wake);
 }
 
 void slapd_clr_read(ber_socket_t s, int wake) {
        ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
-    WAKE_LISTENER(wake);
 
        assert( FD_ISSET( s, &slap_daemon.sd_actives) );
        FD_CLR( s, &slap_daemon.sd_readers );
 
        ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
-
-       if( wake ) {
-               ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );
-       }
+       WAKE_LISTENER(wake);
 }
 
 void slapd_set_read(ber_socket_t s, int wake) {
        ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
-    WAKE_LISTENER(wake);
 
        assert( FD_ISSET( s, &slap_daemon.sd_actives) );
        FD_SET( s, &slap_daemon.sd_readers );
 
        ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
-
-       if( wake ) {
-               ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );
-       }
+       WAKE_LISTENER(wake);
 }
 
 static void slapd_close(ber_socket_t s) {
@@ -200,7 +169,7 @@ static void slapd_close(ber_socket_t s) {
 }
 
 
-Listener *
+static Listener *
 open_listener(
        const char* url,
        int port,
@@ -274,18 +243,10 @@ open_listener(
 
 
        if ( (l.sl_sd = socket( AF_INET, SOCK_STREAM, 0 )) == AC_SOCKET_INVALID ) {
-#ifndef HAVE_WINSOCK
-               int err = errno;
+               int err = sock_errno();
                Debug( LDAP_DEBUG_ANY,
                        "daemon: socket() failed errno=%d (%s)\n", err,
-               err > -1 && err < sys_nerr ? sys_errlist[err] :
-               "unknown", 0 );
-#else
-               Debug( LDAP_DEBUG_ANY, 
-                       "daemon: socket() failed errno=%d (%s)\n",
-                       WSAGetLastError(),
-               WSAGetLastErrorString(), 0 );
-#endif
+                       sock_errstr(err), 0 );
                return NULL;
        }
 
@@ -302,52 +263,45 @@ open_listener(
 #ifdef SO_REUSEADDR
        /* enable address reuse */
        tmp = 1;
-       if ( setsockopt( l.sl_sd, SOL_SOCKET, SO_REUSEADDR,
-               (char *) &tmp, sizeof(tmp) ) == -1 )
-       {
-               int err = errno;
+       rc = setsockopt( l.sl_sd, SOL_SOCKET, SO_REUSEADDR,
+               (char *) &tmp, sizeof(tmp) );
+       if ( rc == AC_SOCKET_ERROR ) {
+               int err = sock_errno();
                Debug( LDAP_DEBUG_ANY,
               "slapd(%ld): setsockopt(SO_REUSEADDR) failed errno=%d (%s)\n",
-               (long) l.sl_sd, err,
-                       err > -1 && err < sys_nerr
-                               ? sys_errlist[err] : "unknown" );
+               (long) l.sl_sd, err, sock_errstr(err) );
        }
 #endif
 #ifdef SO_KEEPALIVE
        /* enable keep alives */
        tmp = 1;
-       if ( setsockopt( l.sl_sd, SOL_SOCKET, SO_KEEPALIVE,
-               (char *) &tmp, sizeof(tmp) ) == -1 )
-       {
-               int err = errno;
+       rc = setsockopt( l.sl_sd, SOL_SOCKET, SO_KEEPALIVE,
+               (char *) &tmp, sizeof(tmp) );
+       if ( rc == AC_SOCKET_ERROR ) {
+               int err = sock_errno();
                Debug( LDAP_DEBUG_ANY,
                        "slapd(%ld): setsockopt(SO_KEEPALIVE) failed errno=%d (%s)\n",
-               (long) l.sl_sd, err,
-                       err > -1 && err < sys_nerr
-                               ? sys_errlist[err] : "unknown" );
+               (long) l.sl_sd, err, sock_errstr(err) );
        }
 #endif
 #ifdef TCP_NODELAY
        /* enable no delay */
        tmp = 1;
-       if ( setsockopt( l.sl_sd, IPPROTO_TCP, TCP_NODELAY,
-               (char *)&tmp, sizeof(tmp) ) )
-       {
-               int err = errno;
+       rc = setsockopt( l.sl_sd, IPPROTO_TCP, TCP_NODELAY,
+               (char *)&tmp, sizeof(tmp) );
+       if ( rc == AC_SOCKET_ERROR ) {
+               int err = sock_errno();
                Debug( LDAP_DEBUG_ANY,
                        "slapd(%ld): setsockopt(TCP_NODELAY) failed errno=%d (%s)\n",
-               (long) l.sl_sd, err,
-                       err > -1 && err < sys_nerr
-                               ? sys_errlist[err] : "unknown" );
+               (long) l.sl_sd, err, sock_errstr(err) );
        }
 #endif
 
-       if ( bind( l.sl_sd, (struct sockaddr *) &l.sl_addr, sizeof(l.sl_addr) ) == -1 ) {
-               int err = errno;
+       rc = bind( l.sl_sd, (struct sockaddr *) &l.sl_addr, sizeof(l.sl_addr) );
+       if ( rc == AC_SOCKET_ERROR ) {
+               int err = sock_errno();
                Debug( LDAP_DEBUG_ANY, "daemon: bind(%ld) failed errno=%d (%s)\n",
-               (long) l.sl_sd, err,
-                       err > -1 && err < sys_nerr
-                               ? sys_errlist[err] : "unknown" );
+               (long) l.sl_sd, err, sock_errstr(err) );
                tcp_close( l.sl_sd );
                return NULL;
        }
@@ -383,7 +337,7 @@ int slapd_daemon_init(char *urls, int port, int tls_port )
        Debug( LDAP_DEBUG_ARGS, "daemon_init: %s (%d/%d)\n",
                urls ? urls : "<null>", port, tls_port );
 
-       if( rc = sockinit() ) {
+       if( (rc = sockinit()) != 0 ) {
                return rc;
        }
 
@@ -401,6 +355,17 @@ int slapd_daemon_init(char *urls, int port, int tls_port )
        }
 #endif /* !FD_SETSIZE */
 
+       /* open a pipe (or something equivalent connected to itself).
+        * we write a byte on this fd whenever we catch a signal. The main
+        * loop will be select'ing on this socket, and will wake up when
+        * this byte arrives.
+        */
+       if( (rc = lutil_pair( wake_sds )) < 0 ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "daemon: lutil_pair() failed rc=%d\n", rc, 0, 0 );
+               return rc;
+       }
+
        FD_ZERO( &slap_daemon.sd_readers );
        FD_ZERO( &slap_daemon.sd_writers );
 
@@ -457,6 +422,8 @@ int
 slapd_daemon_destroy(void)
 {
        connections_destroy();
+       tcp_close( wake_sds[1] );
+       tcp_close( wake_sds[0] );
        sockdestroy();
        return 0;
 }
@@ -468,7 +435,7 @@ slapd_daemon_task(
 )
 {
        int l;
-
+       time_t  last_idle_check = slap_get_time();
        time( &starttime );
 
        for ( l = 0; slap_listeners[l] != NULL; l++ ) {
@@ -476,13 +443,11 @@ slapd_daemon_task(
                        continue;
 
                if ( listen( slap_listeners[l]->sl_sd, 5 ) == -1 ) {
-                       int err = errno;
+                       int err = sock_errno();
                        Debug( LDAP_DEBUG_ANY,
                                "daemon: listen(%s, 5) failed errno=%d (%s)\n",
-                                       (long) slap_listeners[l]->sl_url, err,
-                                       err > -1 && err < sys_nerr
-                                       ? sys_errlist[err] : "unknown" );
-
+                                       slap_listeners[l]->sl_url, err,
+                                       sock_errstr(err) );
                        return( (void*)-1 );
                }
 
@@ -505,8 +470,7 @@ slapd_daemon_task(
                int ebadf = 0;
 
 #define SLAPD_IDLE_CHECK_LIMIT 4
-               time_t  last_idle_check = slap_get_time();
-               time_t  now;
+               time_t  now = slap_get_time();
 
 
                fd_set                  readfds;
@@ -536,17 +500,18 @@ slapd_daemon_task(
 
 #ifdef FD_SET_MANUAL_COPY
                for( s = 0; s < nfds; s++ ) {
-                       if(FD_ISSET( &slap_sd_writers, s )) {
-                               FD_SET( &writefds, s );
+                       if(FD_ISSET( &slap_sd_readers, s )) {
+                               FD_SET( s, &readfds );
                        }
                        if(FD_ISSET( &slap_sd_writers, s )) {
-                               FD_SET( &writefds, s );
+                               FD_SET( s, &writefds );
                        }
                }
 #else
                memcpy( &readfds, &slap_daemon.sd_readers, sizeof(fd_set) );
                memcpy( &writefds, &slap_daemon.sd_writers, sizeof(fd_set) );
 #endif
+               FD_SET( wake_sds[0], &readfds );
 
                for ( l = 0; slap_listeners[l] != NULL; l++ ) {
                        if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
@@ -592,11 +557,7 @@ slapd_daemon_task(
                        NULL, tvp ))
                {
                case -1: {      /* failure - try again */
-#ifdef HAVE_WINSOCK
-                               int err = WSAGetLastError();
-#else
-                               int err = errno;
-#endif
+                               int err = sock_errno();
 
                                if( err == EBADF && ++ebadf < SLAPD_EBADF_LIMIT) {
                                        continue;
@@ -605,13 +566,9 @@ slapd_daemon_task(
                                if( err != EINTR ) {
                                        Debug( LDAP_DEBUG_CONNS,
                                                "daemon: select failed (%d): %s\n",
-                                               err,
-                                               err >= 0 && err < sys_nerr
-                                                       ? sys_errlist[err] : "unknown",
-                                               0 );
+                                               err, sock_errstr(err), 0 );
 
-
-                               slapd_shutdown = -1;
+                                       slapd_shutdown = -1;
                                }
                        }
                        continue;
@@ -630,6 +587,12 @@ slapd_daemon_task(
                        /* FALL THRU */
                }
 
+               if( FD_ISSET( wake_sds[0], &readfds ) ) {
+                       char c;
+                       tcp_read( wake_sds[0], &c, 1 );
+                       continue;
+               }
+
                for ( l = 0; slap_listeners[l] != NULL; l++ ) {
                        ber_int_t s;
                        socklen_t len = sizeof(from);
@@ -649,12 +612,11 @@ slapd_daemon_task(
                        if ( (s = accept( slap_listeners[l]->sl_sd,
                                (struct sockaddr *) &from, &len )) == AC_SOCKET_INVALID )
                        {
-                               int err = errno;
+                               int err = sock_errno();
                                Debug( LDAP_DEBUG_ANY,
-                                   "daemon: accept(%ld) failed errno=%d (%s)\n", err,
-                                   (long) slap_listeners[l]->sl_sd,
-                                   err >= 0 && err < sys_nerr ?
-                                   sys_errlist[err] : "unknown");
+                                   "daemon: accept(%ld) failed errno=%d (%s)\n",
+                                   (long) slap_listeners[l]->sl_sd, err,
+                                   sock_errstr(err) );
                                continue;
                        }
 
@@ -687,12 +649,10 @@ slapd_daemon_task(
                        len = sizeof(from);
 
                        if ( getpeername( s, (struct sockaddr *) &from, &len ) != 0 ) {
-                               int err = errno;
+                               int err = sock_errno();
                                Debug( LDAP_DEBUG_ANY,
                                        "daemon: getpeername( %ld ) failed: errno=%d (%s)\n",
-                                       (long) s, err,
-                                   err >= 0 && err < sys_nerr ?
-                                   sys_errlist[err] : "unknown" );
+                                       (long) s, err, sock_errstr(err) );
                                slapd_close(s);
                                continue;
                        }
@@ -708,7 +668,7 @@ slapd_daemon_task(
                            sizeof(from.sin_addr.s_addr), AF_INET );
 
                        if(hp) {
-                               dnsname = str2lower( hp->h_name );
+                               dnsname = ldap_pvt_str2lower( hp->h_name );
 
                        } else {
                                dnsname = NULL;
@@ -781,7 +741,7 @@ slapd_daemon_task(
                }
 #else
                for ( i = 0; i < nfds; i++ ) {
-                       int     a, r, w;
+                       int     r, w;
                        int     is_listener = 0;
 
                        for ( l = 0; slap_listeners[l] != NULL; l++ ) {
@@ -1000,38 +960,10 @@ int sockdestroy(void)
        return 0;
 }
 
-void hit_socket(void)
-{
-       ber_socket_t s;
-       int on = 1;
-       extern struct sockaddr_in       bind_addr;
-
-       /* throw something at the socket to terminate the select() in the daemon thread. */
-       if (( s = socket( AF_INET, SOCK_STREAM, 0 )) == AC_SOCKET_INVALID )
-               Debug( LDAP_DEBUG_ANY,
-                       "slap_set_shutdown: socket failed\n\tWSAGetLastError=%d (%s)\n",
-                       WSAGetLastError(), WSAGetLastErrorString(), 0 );
-
-       if ( ioctlsocket( s, FIONBIO, &on ) == -1 ) 
-               Debug( LDAP_DEBUG_ANY,
-                       "slap_set_shutdown:FIONBIO ioctl on %d faled\n\tWSAGetLastError=%d (%s)\n",
-                       s, WSAGetLastError(), WSAGetLastError() );
-       
-       bind_addr.sin_addr.s_addr = htonl( INADDR_LOOPBACK );
-
-       if ( connect( s, (struct sockaddr *)&bind_addr, sizeof( struct sockaddr_in )) == SOCKET_ERROR ) {
-               Debug( LDAP_DEBUG_ANY,
-                       "hit_socket: error on connect: %d\n",
-                       WSAGetLastError(), 0, 0 );
-               /* we can probably expect some error to occur here, mostly WSAEWOULDBLOCK */
-       }
-
-       tcp_close(s);
-}
-
 #elif HAVE_WINSOCK
 static int sockinit(void)
-{      WSADATA wsaData;
+{
+       WSADATA wsaData;
        if ( WSAStartup( 0x0101, &wsaData ) != 0 ) {
            return -1;
        }
@@ -1054,32 +986,21 @@ static int sockdestroy(void)
 }
 #endif
 
-void
-slap_set_shutdown( int sig )
+RETSIGTYPE
+slap_sig_shutdown( int sig )
 {
-       int l;
        slapd_shutdown = sig;
-#ifndef HAVE_WINSOCK
-       if(slapd_listener) {
-               ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );
-       }
-#else
-       /* trying to "hit" the socket seems to always get a */
-       /* EWOULDBLOCK error, so just close the listen socket to */
-       /* break out of the select since we're shutting down anyway */
-       for ( l = 0; slap_listeners[l] != NULL; l++ ) {
-               if ( slap_listeners[l]->sl_sd >= 0 ) {
-                       tcp_close( slap_listeners[l]->sl_sd );
-               }
-       }
-#endif
+       WAKE_LISTENER(1);
+
        /* reinstall self */
-       (void) SIGNAL( sig, slap_set_shutdown );
+       (void) SIGNAL( sig, slap_sig_shutdown );
 }
 
-void
-slap_do_nothing( int sig )
+RETSIGTYPE
+slap_sig_wake( int sig )
 {
+       WAKE_LISTENER(1);
+
        /* reinstall self */
-       (void) SIGNAL( sig, slap_do_nothing );
+       (void) SIGNAL( sig, slap_sig_wake );
 }
index 03d9c16ab58578b981b92ab38258d2bf8be76e4d..292e1019e4c23b6e5255f156347aaba1411ac620 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -85,6 +86,15 @@ do_delete(
                return rc;
        }
 
+       if ( global_readonly || be->be_readonly ) {
+               Debug( LDAP_DEBUG_ANY, "do_delete: database is read-only\n",
+                      0, 0, 0 );
+               free( ndn );
+               send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
+                                 NULL, "database is read-only", NULL, NULL );
+               return LDAP_UNWILLING_TO_PERFORM;
+       }
+
        /* deref suffix alias if appropriate */
        ndn = suffix_alias( be, ndn );
 
index c74ff919b118ff73ca812acdd42b2f2743c8f98c..d2a7daa8e8d57f5a7792d1aba330c526ba0114b6 100644 (file)
@@ -1,4 +1,5 @@
 /* dn.c - routines for dealing with distinguished names */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -13,6 +14,8 @@
 #include <ac/string.h>
 #include <ac/time.h>
 
+#include "ldap_pvt.h"
+
 #include "slap.h"
 
 #define B4LEADTYPE             0
@@ -181,7 +184,7 @@ dn_normalize( char *dn )
 char *
 dn_normalize_case( char *dn )
 {
-       str2upper( dn );
+       ldap_pvt_str2upper( dn );
 
        /* normalize format */
        dn = dn_normalize( dn );
@@ -197,10 +200,10 @@ dn_normalize_case( char *dn )
 char *
 dn_parent(
     Backend    *be,
-    char       *dn
+    const char *dn
 )
 {
-       char    *s;
+       const char      *s;
        int     inquote;
 
        if( dn == NULL ) {
@@ -219,6 +222,7 @@ dn_parent(
                return( NULL );
        }
 
+#ifdef DNS_DN
        /*
         * no =, assume it is a dns name, like blah@some.domain.name
         * if the blah@ part is there, return some.domain.name.  if
@@ -236,6 +240,7 @@ dn_parent(
                        return( ch_strdup( &s[1] ) );
                }
        }
+#endif
 
        /*
         * else assume it is an X.500-style name, which looks like
@@ -345,21 +350,19 @@ char * dn_rdn(
  */
 char **dn_subtree(
        Backend *be,
-    char       *dn )
+    const char *dn )
 {
        char *child, *parent;
        char **subtree = NULL;
        
-       child = dn;
+       child = ch_strdup( dn );
 
        do {
                charray_add( &subtree, child );
 
                parent = dn_parent( be, child );
 
-               if( child != dn ) {
-                       free( child );
-               }
+               free( child );
 
                child = parent;
        } while ( child != NULL );
@@ -409,33 +412,6 @@ dn_type( char *dn )
 }
 #endif
 
-char *
-str2upper( char *str )
-{
-       char    *s;
-
-       /* normalize case */
-       for ( s = str; *s; s++ ) {
-               *s = TOUPPER( (unsigned char) *s );
-       }
-
-       return( str );
-}
-
-char *
-str2lower( char *str )
-{
-       char    *s;
-
-       /* normalize case */
-       for ( s = str; *s; s++ ) {
-               *s = TOLOWER( (unsigned char) *s );
-       }
-
-       return( str );
-}
-
-
 /*
  * get_next_substring(), rdn_attr_type(), rdn_attr_value(), and
  * build_new_dn().
@@ -551,7 +527,10 @@ int rdn_validate( const char * rdn )
  */
 
 void
-build_new_dn( char ** new_dn, char *e_dn, char * p_dn, char * newrdn )
+build_new_dn( char ** new_dn,
+       const char *e_dn,
+       const char * p_dn,
+       const char * newrdn )
 {
 
     if ( p_dn == NULL ) {
index 849aece201a9fe8183010004612b3a3fe950908b..d530e5200228849182b00b1d9b62a517cffde814 100644 (file)
@@ -1,4 +1,5 @@
 /* entry.c - routines for dealing with entries */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
diff --git a/servers/slapd/extended.c b/servers/slapd/extended.c
new file mode 100644 (file)
index 0000000..fd9573c
--- /dev/null
@@ -0,0 +1,113 @@
+/* $OpenLDAP$ */
+/* 
+ * Copyright 1999 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted only
+ * as authorized by the OpenLDAP Public License.  A copy of this
+ * license is available at http://www.OpenLDAP.org/license.html or
+ * in file LICENSE in the top-level directory of the distribution.
+ */
+
+/*
+ * LDAPv3 Extended Operation Request
+ *     ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ *             requestName      [0] LDAPOID,
+ *             requestValue     [1] OCTET STRING OPTIONAL
+ *     }
+ *
+ * LDAPv3 Extended Operation Response
+ *     ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+ *             COMPONENTS OF LDAPResult,
+ *             responseName     [10] LDAPOID OPTIONAL,
+ *             response         [11] OCTET STRING OPTIONAL
+ *     }
+ *
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+
+char *supportedExtensions[] = {
+       NULL
+};
+
+
+int
+do_extended(
+    Connection *conn,
+    Operation  *op
+)
+{
+       int rc = LDAP_SUCCESS;
+       char* reqoid ;
+       struct berval reqdata;
+       ber_tag_t tag;
+       ber_len_t len;
+
+       Debug( LDAP_DEBUG_TRACE, "do_extended\n", 0, 0, 0 );
+
+       reqoid = NULL;
+       reqdata.bv_val = NULL;
+
+       if( op->o_protocol < LDAP_VERSION3 ) {
+               Debug( LDAP_DEBUG_ANY, "do_extended: protocol version (%d) too low\n",
+                       op->o_protocol, 0 ,0 );
+               send_ldap_disconnect( conn, op,
+                       LDAP_PROTOCOL_ERROR, "requires LDAPv3" );
+               rc = -1;
+               goto done;
+       }
+
+       if ( ber_scanf( op->o_ber, "a", &reqoid ) == LBER_ERROR ) {
+               Debug( LDAP_DEBUG_ANY, "do_extended: ber_scanf failed\n", 0, 0 ,0 );
+               send_ldap_disconnect( conn, op,
+                       LDAP_PROTOCOL_ERROR, "decoding error" );
+               rc = -1;
+               goto done;
+       }
+
+       if( !charray_inlist( supportedExtensions, reqoid ) ) {
+               Debug( LDAP_DEBUG_ANY, "do_extended: unsupported operation \"%s\"\n",
+                       reqoid, 0 ,0 );
+               send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
+                       NULL, "unsuppored extended operation", NULL, NULL );
+               goto done;
+       }
+
+       tag = ber_peek_tag( op->o_ber, &len );
+       
+       if( ber_peek_tag( op->o_ber, &len ) == LDAP_TAG_EXOP_REQ_VALUE ) {
+               if( ber_scanf( op->o_ber, "o", &reqdata ) != LBER_ERROR ) {
+                       Debug( LDAP_DEBUG_ANY, "do_extended: ber_scanf failed\n", 0, 0 ,0 );
+                       send_ldap_disconnect( conn, op,
+                               LDAP_PROTOCOL_ERROR, "decoding error" );
+                       rc = -1;
+                       goto done;
+               }
+       }
+
+       if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
+               Debug( LDAP_DEBUG_ANY, "do_extended: get_ctrls failed\n", 0, 0 ,0 );
+               return rc;
+       } 
+
+       Debug( LDAP_DEBUG_ARGS, "do_extended: oid \"%s\"\n", reqoid, 0 ,0 );
+
+       send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
+               NULL, "unsupported extended operation", NULL, NULL );
+
+done:
+       if ( reqoid != NULL ) {
+               free( reqoid );
+       }
+       if ( reqdata.bv_val != NULL ) {
+               free( reqdata.bv_val );
+       }
+
+       return rc;
+}
index cb830de01413856a9ecfdf115da45999701e8a35..35604cf6b9bc1b371e23e0db18f536a7f8bbe082 100644 (file)
@@ -1,4 +1,5 @@
 /* filter.c - routines for parsing and dealing with filters */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index dd6da92f64142f76849be1a3e248402e353e6352..c1abb4555d4b7a2b5d9be305671e0828fd9e664b 100644 (file)
@@ -1,4 +1,5 @@
 /* filterentry.c - apply a filter to an entry */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -283,18 +284,24 @@ test_filter_list(
 }
 
 static void
-strcpy_special( char *d, char *s )
+strcpy_regex( char *d, char *s )
 {
        for ( ; *s; s++ ) {
                switch ( *s ) {
+               case '^':
                case '.':
-               case '\\':
                case '[':
-               case ']':
+               case ']': /* ? */
+               case '$':
+               case '(':
+               case ')': /* ? */
+               case '|':
                case '*':
                case '+':
-               case '^':
-               case '$':
+               case '?':
+               case '{':
+               case '}': /* ? */
+               case '\\':
                        *d++ = '\\';
                        /* FALL */
                default:
@@ -356,7 +363,7 @@ test_substring_filter(
                            0, 0, 0 );
                        return( -1 );
                }
-               strcpy_special( p, f->f_sub_initial );
+               strcpy_regex( p, f->f_sub_initial );
                p = strchr( p, '\0' );
        }
        if ( f->f_sub_any != NULL ) {
@@ -369,7 +376,7 @@ test_substring_filter(
                        }
                        strcpy( p, ".*" );
                        p = strchr( p, '\0' );
-                       strcpy_special( p, f->f_sub_any[i] );
+                       strcpy_regex( p, f->f_sub_any[i] );
                        p = strchr( p, '\0' );
                }
        }
@@ -382,7 +389,7 @@ test_substring_filter(
                }
                strcpy( p, ".*" );
                p = strchr( p, '\0' );
-               strcpy_special( p, f->f_sub_final );
+               strcpy_regex( p, f->f_sub_final );
                p = strchr( p, '\0' );
                strcpy( p, "$" );
        }
@@ -390,7 +397,7 @@ test_substring_filter(
        /* compile the regex */
        Debug( LDAP_DEBUG_FILTER, "test_substring_filter: regcomp pat: %s\n",
                pat, 0, 0 );
-       if ((rc = regcomp(&re, pat, 0))) {
+       if ((rc = regcomp(&re, pat, REG_EXTENDED|REG_NOSUB))) {
                char error[512];
 
                regerror(rc, &re, error, sizeof(error));
index d46b90d3c7d3f9fecc187236562582a32ad7e15b..f6e2cf9fc7bf40711b9b8b266999415e889dbb21 100644 (file)
@@ -1,4 +1,5 @@
 /* init.c - initialize various things */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index ac109065a2229f5b9a36726baa4047f3be1865d1..e9f5fda164383f1948fd6279e831ea324d2b8c59 100644 (file)
@@ -1,4 +1,5 @@
 /* lock.c - routines to open and apply an advisory lock to a file */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -22,7 +23,7 @@
 #include "slap.h"
 
 FILE *
-lock_fopen( char *fname, char *type, FILE **lfp )
+lock_fopen( const char *fname, const char *type, FILE **lfp )
 {
        FILE    *fp;
        char    buf[MAXPATHLEN];
index 53398e99933097c65ec6cb17fed3d6352a20a40a..a797cf621d126a3d9426196dad677f81b91a54f3 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -15,7 +16,6 @@
 #include <ac/signal.h>
 #include <ac/errno.h>
 
-#include "ldap_defaults.h"
 #include "slap.h"
 #include "lutil.h"
 
@@ -75,15 +75,15 @@ typedef struct _str2intDispatch {
 
 /* table to compute syslog-options to integer */
 static STRDISP  syslog_types[] = {
-    { "LOCAL0",         6, LOG_LOCAL0 },
-    { "LOCAL1",         6, LOG_LOCAL1 },
-    { "LOCAL2",         6, LOG_LOCAL2 },
-    { "LOCAL3",         6, LOG_LOCAL3 },
-    { "LOCAL4",         6, LOG_LOCAL4 },
-    { "LOCAL5",         6, LOG_LOCAL5 },
-    { "LOCAL6",         6, LOG_LOCAL6 },
-    { "LOCAL7",         6, LOG_LOCAL7 },
-    { NULL }
+       { "LOCAL0", sizeof("LOCAL0"), LOG_LOCAL0 },
+       { "LOCAL1", sizeof("LOCAL1"), LOG_LOCAL1 },
+       { "LOCAL2", sizeof("LOCAL2"), LOG_LOCAL2 },
+       { "LOCAL3", sizeof("LOCAL3"), LOG_LOCAL3 },
+       { "LOCAL4", sizeof("LOCAL4"), LOG_LOCAL4 },
+       { "LOCAL5", sizeof("LOCAL5"), LOG_LOCAL5 },
+       { "LOCAL6", sizeof("LOCAL6"), LOG_LOCAL6 },
+       { "LOCAL7", sizeof("LOCAL7"), LOG_LOCAL7 },
+       { NULL }
 };
 
 static int   cnvt_str2int( char *, STRDISP_P, int );
@@ -133,7 +133,7 @@ void WINAPI ServiceMain( DWORD argc, LPTSTR *argv )
 int main( int argc, char **argv )
 #endif
 {
-       int             i;
+       int             i, no_detach = 0;
        int             rc;
        char *urls = NULL;
 #if defined(HAVE_SETUID) && defined(HAVE_SETGID)
@@ -173,7 +173,11 @@ int main( int argc, char **argv )
        {
                int *i;
                char *newConfigFile;
-               if ( is_NT_Service ) CommenceStartupProcessing( NTservice, slap_set_shutdown );
+
+               if ( is_NT_Service ) {
+                       CommenceStartupProcessing( NTservice, slap_sig_shutdown );
+               }
+
                i = (int*)getRegParam( NULL, "Port" );
                if ( i != NULL )
                {
@@ -226,19 +230,20 @@ int main( int argc, char **argv )
                             )) != EOF ) {
                switch ( i ) {
                case 'h':       /* listen URLs */
+                       if ( urls != NULL ) free( urls );
                        urls = ch_strdup( optarg );
             break;
 
+               case 'd':       /* set debug level and 'do not detach' flag */
+                       no_detach = 1;
 #ifdef LDAP_DEBUG
-               case 'd':       /* turn on debugging */
                        slap_debug |= atoi( optarg );
-                       break;
 #else
-               case 'd':       /* turn on debugging */
-                       fprintf( stderr,
-                           "must compile with LDAP_DEBUG for debugging\n" );
-                       break;
+                       if ( atoi( optarg ) != 0 )
+                               fputs( "must compile with LDAP_DEBUG for debugging\n",
+                                      stderr );
 #endif
+                       break;
 
                case 'f':       /* read config file */
                        configfile = ch_strdup( optarg );
@@ -365,30 +370,27 @@ int main( int argc, char **argv )
        ldap_pvt_tls_init_def_ctx();
 #endif
 
-       (void) SIGNAL( LDAP_SIGUSR1, slap_do_nothing );
-       (void) SIGNAL( LDAP_SIGUSR2, slap_set_shutdown );
+       (void) SIGNAL( LDAP_SIGUSR1, slap_sig_wake );
+       (void) SIGNAL( LDAP_SIGUSR2, slap_sig_shutdown );
+
 #ifdef SIGPIPE
        (void) SIGNAL( SIGPIPE, SIG_IGN );
 #endif
 #ifdef SIGHUP
-       (void) SIGNAL( SIGHUP, slap_set_shutdown );
+       (void) SIGNAL( SIGHUP, slap_sig_shutdown );
 #endif
-       (void) SIGNAL( SIGINT, slap_set_shutdown );
-       (void) SIGNAL( SIGTERM, slap_set_shutdown );
+       (void) SIGNAL( SIGINT, slap_sig_shutdown );
+       (void) SIGNAL( SIGTERM, slap_sig_shutdown );
 #ifdef LDAP_SIGCHLD
        (void) SIGNAL( LDAP_SIGCHLD, wait4child );
 #endif
 #ifdef SIGBREAK
        /* SIGBREAK is generated when Ctrl-Break is pressed. */
-       (void) SIGNAL( SIGBREAK, slap_set_shutdown );
+       (void) SIGNAL( SIGBREAK, slap_sig_shutdown );
 #endif
 
 #ifndef HAVE_WINSOCK
-#ifdef LDAP_DEBUG
-               lutil_detach( ldap_debug, 0 );
-#else
-               lutil_detach( 0, 0 );
-#endif
+               lutil_detach( no_detach, 0 );
 #endif /* HAVE_WINSOCK */
 
 #ifdef CSRIMALLOC
index 1316668523a109401505a491236c4e6c93e8356d..8e3521bfac690c7c0d7dcce6f9ee5393085af629 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -123,6 +124,9 @@ do_modify(
                    (*modtail)->ml_op != LDAP_MOD_DELETE &&
                    (*modtail)->ml_op != LDAP_MOD_REPLACE )
                {
+                       Debug( LDAP_DEBUG_ANY,
+                               "do_modify: invalid modify operation (%ld)\n",
+                               (long) (*modtail)->ml_op, 0, 0 );
                        send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
                            NULL, "unrecognized modify operation", NULL, NULL );
                        free( ndn );
@@ -130,11 +134,16 @@ do_modify(
                        return LDAP_PROTOCOL_ERROR;
                }
 
-               if ( (*modtail)->ml_bvalues == NULL
-                       && (*modtail)->ml_op != LDAP_MOD_DELETE )
+               if ( (*modtail)->ml_bvalues == NULL && (
+                       (*modtail)->ml_op != LDAP_MOD_REPLACE &&
+                       (*modtail)->ml_op != LDAP_MOD_DELETE ) )
                {
+                       Debug( LDAP_DEBUG_ANY,
+                               "do_modify: invalid modify operation (%ld) without values\n",
+                               (long) (*modtail)->ml_op, 0, 0 );
                        send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
-                           NULL, "unrecognized modify operation", NULL, NULL );
+                           NULL, "unrecognized modify operation without values",
+                               NULL, NULL );
                        free( ndn );
                        modlist_free( modlist );
                        return LDAP_PROTOCOL_ERROR;
@@ -178,6 +187,14 @@ do_modify(
                return rc;
        }
 
+       if ( global_readonly || be->be_readonly ) {
+               Debug( LDAP_DEBUG_ANY, "do_modify: database is read-only\n",
+                      0, 0, 0 );
+               send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
+                                 NULL, "database is read-only", NULL, NULL );
+               goto done;
+       }
+
        /* deref suffix alias if appropriate */
        ndn = suffix_alias( be, ndn );
 
@@ -235,6 +252,7 @@ do_modify(
                    NULL, "Function not implemented", NULL, NULL );
        }
 
+done:
        free( ndn );
        modlist_free( modlist );
        return rc;
index 578751613934889b98ca41d9d95ffb1902ba5b4b..14d643545b85dc16f4410783698323ed355f7c83 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -111,16 +112,20 @@ do_modrdn(
                               0, 0, 0 );
                        send_ldap_disconnect( conn, op,
                                LDAP_PROTOCOL_ERROR, "newSuperior requires LDAPv3" );
+                       free( ndn );
+                       free( newrdn );
                        return -1;
                }
 
                if ( ber_scanf( op->o_ber, "a", &newSuperior ) 
                     == LBER_ERROR ) {
 
-                   Debug( LDAP_DEBUG_ANY, "ber_scanf(\"a\"}) failed\n",
+                   Debug( LDAP_DEBUG_ANY, "ber_scanf(\"a\") failed\n",
                           0, 0, 0 );
                        send_ldap_disconnect( conn, op,
                                LDAP_PROTOCOL_ERROR, "decoding error" );
+                       free( ndn );
+                       free( newrdn );
                    return -1;
                }
 
@@ -131,9 +136,7 @@ do_modrdn(
                                newSuperior, 0, 0 );
                        send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                                "invalid (new superior) DN", NULL, NULL );
-                       free( ndn );
-                       free( newrdn );
-                       return rc;
+                       goto done;
                }
 
        }
@@ -155,11 +158,9 @@ do_modrdn(
        }
 
        if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
-               free( ndn );
-               free( newrdn ); 
-               free( newSuperior );
                Debug( LDAP_DEBUG_ANY, "do_modrdn: get_ctrls failed\n", 0, 0, 0 );
-               return rc;
+               /* get_ctrls has sent results.  Now clean up. */
+               goto done;
        } 
 
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d MODRDN dn=\"%s\"\n",
@@ -181,6 +182,14 @@ do_modrdn(
                return rc;
        }
 
+       if ( global_readonly || be->be_readonly ) {
+               Debug( LDAP_DEBUG_ANY, "do_modrdn: database is read-only\n",
+                      0, 0, 0 );
+               send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
+                                 NULL, "database is read-only", NULL, NULL );
+               goto done;
+       }
+
        /* Make sure that the entry being changed and the newSuperior are in 
         * the same backend, otherwise we return an error.
         */
@@ -247,6 +256,7 @@ do_modrdn(
                        NULL, "Function not implemented", NULL, NULL );
        }
 
+done:
        free( ndn );
        free( newrdn ); 
        free( newSuperior );
index 3768f38b7cf52aab7f04efc1a9b3144e8ea1909f..7dd253a8063d1d33c50a6ac2d5cde7895a561484 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 #include "portable.h"
 #include <stdio.h>
 #include "slap.h"
index 9cc63754ef8d5703588e6e3906461d0972804ec0..9ad7fbc0806d78b7ad3c5427a3a281427181e7a3 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -22,7 +23,6 @@
 #include <ac/string.h>
 #include <ac/time.h>
 
-#include "ldap_defaults.h"
 #include "slap.h"
 
 #if defined( SLAPD_MONITOR_DN )
diff --git a/servers/slapd/nt_svc.c b/servers/slapd/nt_svc.c
new file mode 100644 (file)
index 0000000..3056262
--- /dev/null
@@ -0,0 +1,89 @@
+/* $OpenLDAP$ */
+// nt_main.c
+#include "portable.h"
+#include <stdio.h>
+
+#include <ac/string.h>
+
+#include "slap.h"
+
+ldap_pvt_thread_cond_t started_event,          stopped_event;
+ldap_pvt_thread_t              start_status_tid,       stop_status_tid;
+
+
+/* in main.c */
+void WINAPI ServiceMain( DWORD argc, LPTSTR *argv );
+
+/* in ntservice.c */
+int srv_install( char* service, char* filename );
+int srv_remove ( char* service, char* filename );
+
+int main( DWORD argc, LPTSTR *argv )
+{
+       int             length;
+       char    filename[MAX_PATH], *fname_start;
+       extern int is_NT_Service;
+
+       SERVICE_TABLE_ENTRY             DispatchTable[] = {
+               {       SERVICE_NAME,   (LPSERVICE_MAIN_FUNCTION) ServiceMain   },
+               {       NULL,                   NULL    }
+       };
+
+       /*
+       // set the service's current directory to being the installation directory for the service.
+       // this way we don't have to write absolute paths in the configuration files
+       */
+       GetModuleFileName( NULL, filename, sizeof( filename ) );
+       fname_start = strrchr( filename, *LDAP_DIRSEP );
+       *fname_start = '\0';
+       SetCurrentDirectory( filename );
+
+       if ( argc > 1 ) {
+               if ( _stricmp( "install", argv[1] ) == 0 ) 
+               {
+                       char *svcName = SERVICE_NAME;
+                       if ( (argc > 2) && (argv[2] != NULL) )
+                               svcName = argv[2];
+                       if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 ) 
+                       {
+                               fputs( "unable to retrieve file name for the service.\n", stderr  );
+                               return EXIT_FAILURE;
+                       }
+                       if ( !srv_install(svcName, filename) ) 
+                       {
+                               fputs( "service failed installation ...\n", stderr  );
+                               return EXIT_FAILURE;
+                       }
+                       fputs( "service has been installed ...\n", stderr  );
+                       return EXIT_SUCCESS;
+               }
+
+               if ( _stricmp( "remove", argv[1] ) == 0 ) 
+               {
+                       char *svcName = SERVICE_NAME;
+                       if ( (argc > 2) && (argv[2] != NULL) )
+                               svcName = argv[2];
+                       if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 ) 
+                       {
+                               fputs( "unable to retrieve file name for the service.\n", stderr  );
+                               return EXIT_FAILURE;
+                       }
+                       if ( !srv_remove(svcName, filename) ) 
+                       {
+                               fputs( "failed to remove the service ...\n", stderr  );
+                               return EXIT_FAILURE;
+                       }
+                       fputs( "service has been removed ...\n", stderr );
+                       return EXIT_SUCCESS;
+               }
+       }
+
+       puts( "starting slapd..." );
+       if ( !StartServiceCtrlDispatcher(DispatchTable) )
+       {
+               is_NT_Service = 0;
+               ServiceMain( argc, argv );
+       }
+
+       return EXIT_SUCCESS;
+}
index a4401bced5a7a47ebedebe1518a72ec7aa5daa8f..dff00fcf7791a5840d7faf565b826dfa116e2b4d 100644 (file)
@@ -1,4 +1,5 @@
 /* operation.c - routines to deal with pending ldap operations */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -96,7 +97,7 @@ slap_op_remove( Operation **olist, Operation *op )
 
        if ( *tmp == NULL ) {
                Debug( LDAP_DEBUG_ANY, "op_delete: can't find op %ld\n",
-                   op->o_msgid, 0, 0 );
+                      (long) op->o_msgid, 0, 0 );
                return -1; 
        }
 
index f5e402f33039344b794c9c8a665f9f8a912bff10..5d58ca0a35732eb7aa9841420c40c79d635d1136 100644 (file)
@@ -1,4 +1,5 @@
 /* phonetic.c - routines to do phonetic matching */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index a8dfa588e2939307103b3a3fc09261411c2db15c..1e95a2805217b949b945cf815faed4deaaada5af 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -22,7 +23,7 @@ AccessControl * acl_get_applicable LDAP_P(( Backend *be,
        char *attr, int nmatches, regmatch_t *matches ));
 
 int acl_access_allowed LDAP_P((
-       AccessControl *a, Backend *be, Connection *conn, Entry *e,
+       AccessControl *a, char *attr, Backend *be, Connection *conn, Entry *e,
        struct berval *val, Operation *op, int  access, char *edn,
        regmatch_t *matches ));
 
@@ -36,7 +37,10 @@ int acl_check_modlist LDAP_P(( Backend *be,
  * aclparse.c
  */
 
-void parse_acl LDAP_P(( Backend *be, char *fname, int lineno, int argc, char **argv ));
+void parse_acl LDAP_P(( Backend *be,
+       const char *fname,
+       int lineno,
+       int argc, char **argv ));
 char * access2str LDAP_P(( int access ));
 int str2access LDAP_P(( char *str ));
 
@@ -50,10 +54,10 @@ char * attr_normalize LDAP_P(( char *s ));
 int attr_merge_fast LDAP_P(( Entry *e, char *type, struct berval **vals, int  nvals,
        int  naddvals, int  *maxvals, Attribute ***a ));
 int attr_merge LDAP_P(( Entry *e, char *type, struct berval **vals ));
-Attribute * attr_find LDAP_P(( Attribute *a, char *type ));
-int attr_delete LDAP_P(( Attribute **attrs, char *type ));
+Attribute * attr_find LDAP_P(( Attribute *a, const char *type ));
+int attr_delete LDAP_P(( Attribute **attrs, const char *type ));
 int attr_syntax LDAP_P(( char *type ));
-void attr_syntax_config LDAP_P(( char *fname, int lineno, int argc, char **argv ));
+void attr_syntax_config LDAP_P(( const char *fname, int lineno, int argc, char **argv ));
 AttributeType * at_find LDAP_P(( const char *name ));
 int at_find_in_list LDAP_P(( AttributeType *sat, AttributeType **list ));
 int at_append_to_list LDAP_P(( AttributeType *sat, AttributeType ***listp ));
@@ -84,14 +88,14 @@ int backend_startup LDAP_P((Backend *be));
 int backend_shutdown LDAP_P((Backend *be));
 int backend_destroy LDAP_P((void));
 
-BackendInfo * backend_info LDAP_P(( char *type ));
-BackendDB * backend_db_init LDAP_P(( char *type ));
+BackendInfo * backend_info LDAP_P(( const char *type ));
+BackendDB * backend_db_init LDAP_P(( const char *type ));
 
-BackendDB * select_backend LDAP_P(( char * dn ));
+BackendDB * select_backend LDAP_P(( const char * dn ));
 
-int be_issuffix LDAP_P(( Backend *be, char *suffix ));
-int be_isroot LDAP_P(( Backend *be, char *ndn ));
-int be_isroot_pw LDAP_P(( Backend *be, char *ndn, struct berval *cred ));
+int be_issuffix LDAP_P(( Backend *be, const char *suffix ));
+int be_isroot LDAP_P(( Backend *be, const char *ndn ));
+int be_isroot_pw LDAP_P(( Backend *be, const char *ndn, struct berval *cred ));
 char* be_root_dn LDAP_P(( Backend *be ));
 int be_entry_release_rw LDAP_P(( Backend *be, Entry *e, int rw ));
 #define be_entry_release_r( be, e ) be_entry_release_rw( be, e, 0 )
@@ -105,8 +109,10 @@ extern int backend_connection_destroy LDAP_P((Connection *conn));
 
 extern int     backend_group LDAP_P((Backend *be,
        Entry *target,
-       char *gr_ndn, char *op_ndn,
-       char *objectclassValue, char *groupattrName));
+       const char *gr_ndn,
+       const char *op_ndn,
+       const char *objectclassValue,
+       const char *groupattrName));
 
 #ifdef SLAPD_SCHEMA_DN
 /* temporary extern for temporary routine*/
@@ -142,12 +148,12 @@ void   ch_free LDAP_P(( void * ));
  * charray.c
  */
 
-void charray_add LDAP_P(( char ***a, char *s ));
+void charray_add LDAP_P(( char ***a, const char *s ));
 void charray_merge LDAP_P(( char ***a, char **s ));
 void charray_free LDAP_P(( char **array ));
-int charray_inlist LDAP_P(( char **a, char *s ));
+int charray_inlist LDAP_P(( char **a, const char *s ));
 char ** charray_dup LDAP_P(( char **a ));
-char ** str2charray LDAP_P(( char *str, char *brkstr ));
+char ** str2charray LDAP_P(( const char *str, const char *brkstr ));
 char * charray2str LDAP_P(( char **a ));
 
 /*
@@ -164,7 +170,7 @@ int get_manageDSAit LDAP_P(( Operation *op ));
  * config.c
  */
 
-int read_config LDAP_P(( char *fname ));
+int read_config LDAP_P(( const char *fname ));
 
 /*
  * connection.c
@@ -184,7 +190,7 @@ long connection_init LDAP_P((
 
 void connection_closing LDAP_P(( Connection *c ));
 int connection_state_closing LDAP_P(( Connection *c ));
-char *connection_state2str LDAP_P(( int state ));
+const char *connection_state2str LDAP_P(( int state )) LDAP_GCCATTR((const));
 
 int connection_write LDAP_P((ber_socket_t s));
 int connection_read LDAP_P((ber_socket_t s));
@@ -201,20 +207,21 @@ void connection_done LDAP_P((Connection *));
 
 char * dn_normalize LDAP_P(( char *dn ));
 char * dn_normalize_case LDAP_P(( char *dn ));
-char * dn_parent LDAP_P(( Backend *be, char *dn ));
-char ** dn_subtree LDAP_P(( Backend *be, char *dn ));
+char * dn_parent LDAP_P(( Backend *be, const char *dn ));
+char ** dn_subtree LDAP_P(( Backend *be, const char *dn ));
 char * dn_rdn LDAP_P(( Backend *be, char *dn ));
 int dn_issuffix LDAP_P(( char *dn, char *suffix ));
 #ifdef DNS_DN
 int dn_type LDAP_P(( char *dn ));
 #endif
-char * str2upper LDAP_P(( char *str ));
-char * str2lower LDAP_P(( char *str ));
 int rdn_validate LDAP_P(( const char* str ));
 char * rdn_attr_value LDAP_P(( char * rdn ));
 char * rdn_attr_type LDAP_P(( char * rdn ));
-void build_new_dn LDAP_P(( char ** new_dn, char *e_dn, char * p_dn,
-                          char * newrdn ));
+
+void build_new_dn LDAP_P(( char ** new_dn,
+       const char *e_dn,
+       const char * p_dn,
+       const char * newrdn ));
 /*
  * entry.c
  */
@@ -248,7 +255,7 @@ int test_filter LDAP_P(( Backend *be, Connection *conn, Operation *op, Entry *e,
  * lock.c
  */
 
-FILE * lock_fopen LDAP_P(( char *fname, char *type, FILE **lfp ));
+FILE * lock_fopen LDAP_P(( const char *fname, const char *type, FILE **lfp ));
 int lock_fclose LDAP_P(( FILE *fp, FILE *lfp ));
 
 /*
@@ -310,17 +317,17 @@ struct berval **get_entry_referrals LDAP_P((
 
 void send_ldap_result LDAP_P((
        Connection *conn, Operation *op,
-       int err, char *matched, char *text,
+       int err, const char *matched, const char *text,
        struct berval **refs,
        LDAPControl **ctrls ));
 
 void send_ldap_disconnect LDAP_P((
        Connection *conn, Operation *op,
-       int err, char *text ));
+       int err, const char *text ));
 
 void send_search_result LDAP_P((
        Connection *conn, Operation *op,
-       int err, char *matched, char *text,
+       int err, const char *matched, const char *text,
        struct berval **refs,
        LDAPControl **ctrls,
        int nentries ));
@@ -352,9 +359,9 @@ int sasl_destroy(void);
  */
 
 int oc_schema_check LDAP_P(( Entry *e ));
-int oc_check_operational_attr LDAP_P(( char *type ));
-int oc_check_usermod_attr LDAP_P(( char *type ));
-int oc_check_no_usermod_attr LDAP_P(( char *type ));
+int oc_check_operational_attr LDAP_P(( const char *type ));
+int oc_check_usermod_attr LDAP_P(( const char *type ));
+int oc_check_no_usermod_attr LDAP_P(( const char *type ));
 ObjectClass *oc_find LDAP_P((const char *ocname));
 int oc_add LDAP_P((LDAP_OBJECT_CLASS *oc, const char **err));
 Syntax *syn_find LDAP_P((const char *synname));
@@ -362,10 +369,13 @@ Syntax *syn_find_desc LDAP_P((const char *syndesc, int *slen));
 int syn_add LDAP_P((LDAP_SYNTAX *syn, slap_syntax_check_func *check, const char **err));
 MatchingRule *mr_find LDAP_P((const char *mrname));
 int mr_add LDAP_P((LDAP_MATCHING_RULE *mr, slap_mr_normalize_func *normalize, slap_mr_compare_func *compare, const char **err));
+int case_ignore_normalize LDAP_P((struct berval *val, struct berval **normalized));
+int register_syntax LDAP_P((char *desc,        slap_syntax_check_func *check ));
+int register_matching_rule LDAP_P((char * desc,        slap_mr_normalize_func *normalize, slap_mr_compare_func *compare));
 void schema_info LDAP_P((Connection *conn, Operation *op, char **attrs, int attrsonly));
 int schema_init LDAP_P((void));
 
-int is_entry_objectclass LDAP_P(( Entry *, char* objectclass ));
+int is_entry_objectclass LDAP_P(( Entry *, const char* objectclass ));
 #define is_entry_alias(e)              is_entry_objectclass((e), "ALIAS")
 #define is_entry_referral(e)   is_entry_objectclass((e), "REFERRAL")
 
@@ -374,12 +384,12 @@ int is_entry_objectclass LDAP_P(( Entry *, char* objectclass ));
  * schemaparse.c
  */
 
-void parse_oc_old LDAP_P(( Backend *be, char *fname, int lineno, int argc, char **argv ));
-void parse_oc LDAP_P(( char *fname, int lineno, char *line, char **argv ));
-void parse_at LDAP_P(( char *fname, int lineno, char *line, char **argv ));
-void parse_oidm LDAP_P(( char *fname, int lineno, int argc, char **argv ));
-char *scherr2str LDAP_P((int code));
-int dscompare LDAP_P(( char *s1, char *s2del, char delim ));
+void parse_oc_old LDAP_P(( Backend *be, const char *fname, int lineno, int argc, char **argv ));
+void parse_oc LDAP_P(( const char *fname, int lineno, char *line, char **argv ));
+void parse_at LDAP_P(( const char *fname, int lineno, char *line, char **argv ));
+void parse_oidm LDAP_P(( const char *fname, int lineno, int argc, char **argv ));
+char *scherr2str LDAP_P((int code)) LDAP_GCCATTR((const));
+int dscompare LDAP_P(( const char *s1, const char *s2del, char delim ));
 /*
  * str2filter.c
  */
@@ -423,6 +433,7 @@ extern int          defsize;
 extern int             deftime;
 extern int             g_argc;
 extern int             global_default_access;
+extern int             global_readonly;
 extern int             global_lastmod;
 extern int             global_idletimeout;
 extern int             global_schemacheck;
@@ -478,8 +489,8 @@ extern void slapd_clr_read LDAP_P((ber_socket_t s, int wake));
 
 extern void slapd_remove LDAP_P((ber_socket_t s, int wake));
 
-extern void    slap_set_shutdown LDAP_P((int sig));
-extern void    slap_do_nothing   LDAP_P((int sig));
+extern RETSIGTYPE slap_sig_shutdown LDAP_P((int sig));
+extern RETSIGTYPE slap_sig_wake LDAP_P((int sig));
 
 extern void    config_info LDAP_P((
        Connection *conn,
index 39e4e7121843c750f05ed2169ce7d5dab5459a3d..7477e8406e1f5c41ff555833ac9d704e72c958f7 100644 (file)
@@ -1,4 +1,5 @@
 /* repl.c - log modifications for replication purposes */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 6f3434276d82b02533cf00e3e3ab72354451f26b..9e316669bc0f565a13d59e2a9b9a38f30b3750af 100644 (file)
@@ -1,4 +1,5 @@
 /* result.c - routines to send ldap results, errors, and referrals */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
@@ -12,7 +13,6 @@
 #include <ac/time.h>
 #include <ac/unistd.h>
 
-#include "ldap_defaults.h"
 #include "slap.h"
 
 /* we need LBER internals */
@@ -79,13 +79,13 @@ static void trim_refs_urls(
        if( refs == NULL ) return;
 
        for( i=0; refs[i] != NULL; i++ ) {
-               if(     refs[i]->bv_len > sizeof("ldap://") &&
+               if(     refs[i]->bv_len > sizeof("ldap://")-1 &&
                        strncasecmp( refs[i]->bv_val, "ldap://",
                                sizeof("ldap://")-1 ) == 0 )
                {
                        unsigned j;
-                       for( j=sizeof("ldap://"); j<refs[i]->bv_len ; j++ ) {
-                               if( refs[i]->bv_val[j] = '/' ) {
+                       for( j=sizeof("ldap://")-1; j<refs[i]->bv_len ; j++ ) {
+                               if( refs[i]->bv_val[j] == '/' ) {
                                        refs[i]->bv_val[j] = '\0';
                                        refs[i]->bv_len = j;
                                        break;
@@ -169,10 +169,11 @@ static long send_ldap_ber(
                if ( connection_state_closing( conn ) ) {
                        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
                        ldap_pvt_thread_mutex_unlock( &conn->c_write_mutex );
+
                        return 0;
                }
 
-               if ( ber_flush( conn->c_sb, ber, 1 ) == 0 ) {
+               if ( ber_flush( conn->c_sb, ber, 0 ) == 0 ) {
                        break;
                }
 
@@ -185,14 +186,14 @@ static long send_ldap_ber(
                 */
 
                Debug( LDAP_DEBUG_CONNS, "ber_flush failed errno=%d reason=\"%s\"\n",
-                   err, err > -1 && err < sys_nerr ? sys_errlist[err]
-                   : "unknown", 0 );
+                   err, STRERROR(err), 0 );
 
                if ( err != EWOULDBLOCK && err != EAGAIN ) {
                        connection_closing( conn );
 
                        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
                        ldap_pvt_thread_mutex_unlock( &conn->c_write_mutex );
+
                        return( -1 );
                }
 
@@ -217,10 +218,10 @@ send_ldap_response(
        ber_tag_t       tag,
        ber_int_t       msgid,
     ber_int_t  err,
-    char       *matched,
-    char       *text,
+    const char *matched,
+    const char *text,
        struct berval   **ref,
-       char    *resoid,
+       const char      *resoid,
        struct berval   *resdata,
        LDAPControl **ctrls
 )
@@ -273,11 +274,13 @@ send_ldap_response(
 
        if ( rc == -1 ) {
                Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
+               ber_free( ber, 1 );
                return;
        }
 
        /* send BER */
        bytes = send_ldap_ber( conn, ber );
+       ber_free( ber, 1 );
 
        if ( bytes < 0 ) {
                Debug( LDAP_DEBUG_ANY,
@@ -299,7 +302,7 @@ send_ldap_disconnect(
     Connection *conn,
     Operation  *op,
     ber_int_t  err,
-    char       *text
+    const char *text
 )
 {
        ber_tag_t tag;
@@ -353,8 +356,8 @@ send_ldap_result(
     Connection *conn,
     Operation  *op,
     ber_int_t  err,
-    char       *matched,
-    char       *text,
+    const char *matched,
+    const char *text,
        struct berval **ref,
        LDAPControl **ctrls
 )
@@ -381,7 +384,8 @@ send_ldap_result(
                        err = LDAP_NO_SUCH_OBJECT;
                } else if ( op->o_protocol < LDAP_VERSION3 ) {
                        err = LDAP_PARTIAL_RESULTS;
-                       tmp = text = v2ref( ref );
+                       tmp = v2ref( ref );
+                       text = tmp;
                        ref = NULL;
                }
        }
@@ -420,8 +424,8 @@ send_search_result(
     Connection *conn,
     Operation  *op,
     ber_int_t  err,
-    char       *matched,
-       char    *text,
+    const char *matched,
+       const char      *text,
     struct berval **refs,
        LDAPControl **ctrls,
     int                nentries
@@ -445,7 +449,8 @@ send_search_result(
                        err = LDAP_PARTIAL_RESULTS;
                }
 
-               tmp = text = v2ref( refs );
+               tmp = v2ref( refs );
+               text = tmp;
                refs = NULL;
 
        } else {
@@ -463,7 +468,7 @@ send_search_result(
 
 #ifdef LDAP_CONNECTIONLESS
        if ( op->o_cldap ) {
-               ber_pvt_sb_udp_set_dst( &conn->c_sb, &op->o_clientaddr );
+               ber_pvt_sb_udp_set_dst( conn->c_sb, &op->o_clientaddr );
                Debug( LDAP_DEBUG_TRACE, "UDP response to %s port %d\n", 
                    inet_ntoa(((struct sockaddr_in *)
                    &op->o_clientaddr)->sin_addr ),
@@ -570,7 +575,7 @@ send_search_entry(
                acl = acl_get_applicable( be, op, e, a->a_type,
                        MAXREMATCHES, matches );
 
-               if ( ! acl_access_allowed( acl, be, conn, e,
+               if ( ! acl_access_allowed( acl, a->a_type, be, conn, e,
                        NULL, op, ACL_READ, edn, matches ) ) 
                {
                        continue;
@@ -587,7 +592,7 @@ send_search_entry(
                if ( ! attrsonly ) {
                        for ( i = 0; a->a_vals[i] != NULL; i++ ) {
                                if ( a->a_syntax & SYNTAX_DN && 
-                                       ! acl_access_allowed( acl, be, conn, e, a->a_vals[i], op,
+                                       ! acl_access_allowed( acl, a->a_type, be, conn, e, a->a_vals[i], op,
                                                ACL_READ, edn, matches) )
                                {
                                        continue;
@@ -645,7 +650,7 @@ send_search_entry(
                acl = acl_get_applicable( be, op, e, a->a_type,
                        MAXREMATCHES, matches );
 
-               if ( ! acl_access_allowed( acl, be, conn, e,
+               if ( ! acl_access_allowed( acl, a->a_type, be, conn, e,
                        NULL, op, ACL_READ, edn, matches ) ) 
                {
                        continue;
@@ -662,7 +667,7 @@ send_search_entry(
                if ( ! attrsonly ) {
                        for ( i = 0; a->a_vals[i] != NULL; i++ ) {
                                if ( a->a_syntax & SYNTAX_DN && 
-                                       ! acl_access_allowed( acl, be, conn, e, a->a_vals[i], op,
+                                       ! acl_access_allowed( acl, a->a_type, be, conn, e, a->a_vals[i], op,
                                                ACL_READ, edn, matches) )
                                {
                                        continue;
@@ -700,6 +705,7 @@ send_search_entry(
        }
 
        bytes = send_ldap_ber( conn, ber );
+       ber_free( ber, 1 );
 
        if ( bytes < 0 ) {
                Debug( LDAP_DEBUG_ANY,
@@ -799,6 +805,7 @@ send_search_reference(
        }
 
        bytes = send_ldap_ber( conn, ber );
+       ber_free( ber, 1 );
 
        ldap_pvt_thread_mutex_lock( &num_sent_mutex );
        num_bytes_sent += bytes;
index 98b4511bd9dce6d691b53565dcf3ccc3bc165378..919830f6dee18fb7a3b2270d58adfd5254a068ee 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /* root_dse.c - Provides the ROOT DSA-Specific Entry
  *
  * Copyright 1999 The OpenLDAP Foundation.
@@ -15,7 +16,6 @@
 
 #include <ac/string.h>
 
-#include "ldap_defaults.h"
 #include "slap.h"
 
 void
index 8c348193ec15c052874272ad70442f39d165add4..6eb8eea57034f81b0840df2585ae18c3fe5ee995 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index b14680fda0677ef931d0fac47ca717d0c5f10576..0462243dabdd454b5c507dcbbdce25678d89cc7d 100644 (file)
@@ -1,4 +1,5 @@
 /* schema.c - routines to enforce schema definitions */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -12,7 +13,6 @@
 #include <ac/string.h>
 #include <ac/socket.h>
 
-#include "ldap_defaults.h"
 #include "slap.h"
 
 static char *  oc_check_required(Entry *e, char *ocname);
@@ -28,9 +28,11 @@ int
 oc_schema_check( Entry *e )
 {
        Attribute       *a, *aoc;
+       ObjectClass *oc;
        int             i;
        int             ret = 0;
 
+
        /* find the object class attribute - could error out here */
        if ( (aoc = attr_find( e->e_attrs, "objectclass" )) == NULL ) {
                Debug( LDAP_DEBUG_ANY, "No object class for entry (%s)\n",
@@ -40,13 +42,21 @@ oc_schema_check( Entry *e )
 
        /* check that the entry has required attrs for each oc */
        for ( i = 0; aoc->a_vals[i] != NULL; i++ ) {
-               char *s = oc_check_required( e, aoc->a_vals[i]->bv_val );
-
-               if (s != NULL) {
+               if ( (oc = oc_find( aoc->a_vals[i]->bv_val )) == NULL ) {
                        Debug( LDAP_DEBUG_ANY,
-                           "Entry (%s), oc \"%s\" requires attr \"%s\"\n",
-                           e->e_dn, aoc->a_vals[i]->bv_val, s );
-                       ret = 1;
+                               "Objectclass \"%s\" not defined",
+                               aoc->a_vals[i]->bv_val, 0, 0 );
+               }
+               else
+               {
+                       char *s = oc_check_required( e, aoc->a_vals[i]->bv_val );
+
+                       if (s != NULL) {
+                               Debug( LDAP_DEBUG_ANY,
+                                       "Entry (%s), oc \"%s\" requires attr \"%s\"\n",
+                                       e->e_dn, aoc->a_vals[i]->bv_val, s );
+                               ret = 1;
+                       }
                }
        }
 
@@ -180,7 +190,7 @@ static char *oc_no_usermod_attrs[] = {
  * check to see if attribute is 'operational' or not.
  */
 int
-oc_check_operational_attr( char *type )
+oc_check_operational_attr( const char *type )
 {
        return charray_inlist( oc_operational_attrs, type )
                || charray_inlist( oc_usermod_attrs, type )
@@ -191,7 +201,7 @@ oc_check_operational_attr( char *type )
  * check to see if attribute can be user modified or not.
  */
 int
-oc_check_usermod_attr( char *type )
+oc_check_usermod_attr( const char *type )
 {
        return charray_inlist( oc_usermod_attrs, type );
 }
@@ -200,7 +210,7 @@ oc_check_usermod_attr( char *type )
  * check to see if attribute is 'no user modification' or not.
  */
 int
-oc_check_no_usermod_attr( char *type )
+oc_check_no_usermod_attr( const char *type )
 {
        return charray_inlist( oc_no_usermod_attrs, type );
 }
@@ -434,13 +444,14 @@ oc_add_sups(
                        code = oc_add_sups(soc,soc1->soc_sup_oids, err);
                        if ( code )
                                return code;
-                       
-                       if ( code = oc_create_required(soc,
-                               soc1->soc_at_oids_must,err) )
+
+                       code = oc_create_required(soc,soc1->soc_at_oids_must,err);
+                       if ( code )
                                return code;
-                       if ( code = oc_create_allowed(soc,
-                               soc1->soc_at_oids_may,err) )
+                       code = oc_create_allowed(soc,soc1->soc_at_oids_may,err);
+                       if ( code )
                                return code;
+
                        nsups++;
                        sups1++;
                }
@@ -511,11 +522,11 @@ oc_add(
 
        soc = (ObjectClass *) ch_calloc( 1, sizeof(ObjectClass) );
        memcpy( &soc->soc_oclass, oc, sizeof(LDAP_OBJECT_CLASS));
-       if ( code = oc_add_sups(soc,soc->soc_sup_oids,err) )
+       if ( (code = oc_add_sups(soc,soc->soc_sup_oids,err)) != 0 )
                return code;
-       if ( code = oc_create_required(soc,soc->soc_at_oids_must,err) )
+       if ( (code = oc_create_required(soc,soc->soc_at_oids_must,err)) != 0 )
                return code;
-       if ( code = oc_create_allowed(soc,soc->soc_at_oids_may,err) )
+       if ( (code = oc_create_allowed(soc,soc->soc_at_oids_may,err)) != 0 )
                return code;
        code = oc_insert(soc,err);
        return code;
@@ -565,7 +576,7 @@ syn_find_desc( const char *syndesc, int *len )
        Syntax          *synp;
 
        for (synp = syn_list; synp; synp = synp->ssyn_next)
-               if ((*len = dscompare( synp->ssyn_syn.syn_desc, (char *)syndesc, '{')))
+               if ((*len = dscompare( synp->ssyn_syn.syn_desc, syndesc, '{')))
                        return synp;
        return( NULL );
 }
@@ -1056,8 +1067,8 @@ syn_schema_info( Entry *e )
                val.bv_val = ldap_syntax2str( &syn->ssyn_syn );
                if ( val.bv_val ) {
                        val.bv_len = strlen( val.bv_val );
-                       Debug( LDAP_DEBUG_TRACE, "Merging syn [%d] %s\n",
-                              val.bv_len, val.bv_val, 0 );
+                       Debug( LDAP_DEBUG_TRACE, "Merging syn [%ld] %s\n",
+                              (long) val.bv_len, val.bv_val, 0 );
                        attr_merge( e, "ldapSyntaxes", vals );
                        ldap_memfree( val.bv_val );
                } else {
@@ -1081,8 +1092,8 @@ mr_schema_info( Entry *e )
                val.bv_val = ldap_matchingrule2str( &mr->smr_mrule );
                if ( val.bv_val ) {
                        val.bv_len = strlen( val.bv_val );
-                       Debug( LDAP_DEBUG_TRACE, "Merging mr [%d] %s\n",
-                              val.bv_len, val.bv_val, 0 );
+                       Debug( LDAP_DEBUG_TRACE, "Merging mr [%ld] %s\n",
+                              (long) val.bv_len, val.bv_val, 0 );
                        attr_merge( e, "matchingRules", vals );
                        ldap_memfree( val.bv_val );
                } else {
@@ -1106,8 +1117,8 @@ oc_schema_info( Entry *e )
                val.bv_val = ldap_objectclass2str( &oc->soc_oclass );
                if ( val.bv_val ) {
                        val.bv_len = strlen( val.bv_val );
-                       Debug( LDAP_DEBUG_TRACE, "Merging oc [%d] %s\n",
-                              val.bv_len, val.bv_val, 0 );
+                       Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n",
+                              (long) val.bv_len, val.bv_val, 0 );
                        attr_merge( e, "objectClasses", vals );
                        ldap_memfree( val.bv_val );
                } else {
@@ -1225,7 +1236,7 @@ oc_print( ObjectClass *oc )
 
 int is_entry_objectclass(
        Entry*  e,
-       char*   oc)
+       const char*     oc)
 {
        Attribute *attr;
        struct berval bv;
@@ -1243,7 +1254,7 @@ int is_entry_objectclass(
                return 0;
        }
 
-       bv.bv_val = oc;
+       bv.bv_val = (char *) oc;
        bv.bv_len = strlen( bv.bv_val );
 
        if( value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
index 3738b7478fd8bee4d20a365396266d846a2cd5d3..37cccba5820683910a4ef62a09dc8ff4c0f6c673 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+#
 # OpenLDAP Core schema
 #
 # Includes "standard" schema items from:
diff --git a/servers/slapd/schema/internet_mail.at.conf b/servers/slapd/schema/internet_mail.at.conf
new file mode 100644 (file)
index 0000000..e67ea79
--- /dev/null
@@ -0,0 +1,71 @@
+# $OpenLDAP$
+#
+# By:          Juan C. Gomez / gomez@engr.sgi.com
+# Date:                May/1999
+# Source:      draft-lachman-ldap-mail-routing-03.txt
+# ---------------------------------------------------------
+#
+# Written by Juan C. Gomez and placed into the public domain.
+# This file is not subject to any license of SGI.
+#
+# ---------------------------------------------------------
+#
+# Attribute specifications for using LDAP as a back-end
+# for mail routing. As specified in:
+#
+# *********************************************************
+# draft-lachman-ldap-mail-routing-03.txt
+# By   :       H. Lachman @ Netscape Communications Corp.
+# Date :       October 1998
+#      "LDAP Schema Definitions for Intranet Mail Routing -
+#       The mailRecipient Object Class"
+# *********************************************************
+#
+
+
+
+
+#
+# This is here because, perhaps in the future, we will have
+# richer schema support in OpenLDAP.
+#
+# ----------------------FORMAL DESCRIPTION-----------------
+#
+# OID          0.9.2342.19200300.100.1.3
+# NAME         'mail'
+# DESC         'RFC 822 email address of this recipient'
+# EQUALITY     caseIgnoreIA5Match
+# SYNTAX       '1.3.6.1.4.1.1466.115.121.1.26{256}' SINGLE-VALUE
+#
+#
+# OID          2.16.840.1.113730.3.1.13
+# NAME         'mailAlternateAddress'
+# DESC         'alternate RFC 822 email address of this recipient'
+# EQUALITY     caseIgnoreIA5Match
+# SYNTAX       '1.3.6.1.4.1.1466.115.121.1.26{256}'
+#
+#
+# OID          2.16.840.1.113730.3.1.18
+# NAME         'mailHost'
+# DESC         'fully qualified hostname of the SMTP MTA that
+#               handles messages for this recipient'
+# EQUALITY     caseIgnoreIA5Match
+# SYNTAX       '1.3.6.1.4.1.1466.115.121.1.26{256}' SINGLE-VALUE
+#
+#
+# OID          2.16.840.1.113730.3.1.47
+# NAME         'mailRoutingAddress'
+# DESC         'RFC 822 address to use when routing messages to
+#                the SMTP MTA of this recipient'
+# EQUALITY     caseIgnoreIA5Match
+# SYNTAX       '1.3.6.1.4.1.1466.115.121.1.26{256}' SINGLE-VALUE
+#
+# ----------------------END FORMAL DESCRIPTION-----------------
+
+
+
+
+attribute      mail                    cis
+attribute      mailAlternateAddress    cis
+attribute      mailHost                cis
+attribute      mailRoutingAddress      cis
diff --git a/servers/slapd/schema/internet_mail.oc.conf b/servers/slapd/schema/internet_mail.oc.conf
new file mode 100644 (file)
index 0000000..a707778
--- /dev/null
@@ -0,0 +1,50 @@
+# $OpenLDAP$
+#
+# By:          Juan C. Gomez / gomez@engr.sgi.com
+# Date:                May/1999
+# Source:      draft-lachman-ldap-mail-routing-03.txt
+# ---------------------------------------------------------
+#
+# Written by Juan C. Gomez and placed into the public domain.
+# This file is not subject to any license of SGI.
+#
+# ---------------------------------------------------------
+#
+# Object class specifications for using LDAP as a back-end 
+# for mail routing. As specified in:
+#
+# *********************************************************
+# draft-lachman-ldap-mail-routing-03.txt
+# By   :       H. Lachman @ Netscape Communications Corp.
+# Date :       October 1998
+#      "LDAP Schema Definitions for Intranet Mail Routing -
+#       The mailRecipient Object Class"
+# *********************************************************
+#
+
+
+
+
+#
+# This is here because, perhaps in the future, we will have
+# richer schema support in OpenLDAP.
+#
+# ----------------------FORMAL DESCRIPTION-----------------
+#
+#
+# OID  2.16.840.1.113730.3.2.3
+# NAME  'mailRecipient' SUP top AUXILIARY
+# MAY  ( cn $ mail $ mailAlternateAddress $ mailHost $
+#      mailRoutingAddress )
+#
+# ----------------------END FORMAL DESCRIPTION-------------
+
+objectclass    mailRecipient
+       requires
+               objectClass
+       allows
+               cn,
+               mail,
+               mailAlternateAddress,
+               mailHost,
+               mailRoutingAddress
index 75cdbcc65c2dea960c411b152840eb9322d8672e..c5cfb497bc90446e339e6741e199361c9f52f843 100644 (file)
@@ -1,4 +1,5 @@
 # Assorted definitions from several sources
+# $OpenLDAP$
 
 #
 # RFC2247
diff --git a/servers/slapd/schema/nadf.schema b/servers/slapd/schema/nadf.schema
new file mode 100644 (file)
index 0000000..2daca76
--- /dev/null
@@ -0,0 +1,178 @@
+# $OpenLDAP$
+
+# These are definitions from the North American Directory Forum
+# They were taken from ftp://ftp.gte.com/pub/nadf/nadf-docs/sd-04.ps
+# Our thanks to Harald T. Alvestrand that provided the pointer.
+
+# Some attribute types and object classes defined in the spec
+# and that we did not have are not included in this file.
+
+# This is a preliminary version and is likely to be incorrect in
+# a number of areas
+
+# The root for OIDs is joint-iso-ccitt mhs-motis(6) group(6) grimstad(5)
+# nadf(2).  In othor words, barring any error, 2.6.6.5.2.  Then,
+# nadfOink ::= 2.6.6.5.2.0
+# nadfModule ::= 2.6.6.5.2.1
+# nadfAttributeType ::= 2.6.6.5.2.4
+# nadfObjectClass ::= 2.6.6.5.2.6
+
+# Attribute Type Definition
+
+# The spec says "leading zero is significant".  Is this really a
+# numeric string?
+
+attribute ( 2.6.6.5.2.4.1 NAME 'fipsStateNumericCode'
+       EQUALITY numericStringMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.36{2} )
+
+# It is probably inconvenient to give this attribute that syntax
+# (Printable String) instead of Directory String.
+
+attribute ( 2.6.6.5.2.4.2 NAME 'fipsStateAlphaCode'
+       EQUALITY caseIgnoreMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{2} )
+
+# The spec says "leading zeros are significant".  Is this really a
+# numeric string?
+
+attribute ( 2.6.6.5.2.4.3 NAME 'fipsCountyNumericCode'
+       EQUALITY numericStringMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.36{5} )
+
+# It seems that fips55 is fipsPlaceNumericCode, is this so?
+
+# The spec says "leading zeros are significant".  Is this really a
+# numeric string?
+
+attribute ( 2.6.6.5.2.4.4 NAME ( 'fipsPlaceNumericCode' 'fips55' )
+       EQUALITY numericStringMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.36{5} )
+
+attribute ( 2.6.6.5.2.4.5 NAME 'ansiOrgNumericCode'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
+
+# Apparently, 'ad' is an alias for 'addmdName'
+
+attribute ( 2.6.6.5.2.4.6 NAME ( 'addmdName' 'ad' )
+       EQUALITY caseIgnoreMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
+
+# I don't know what syntax to give this.  I will use binary for the
+# time being.
+
+attribute ( 2.6.6.5.2.4.7 NAME 'nadfSearchGuide'
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 )
+
+attribute ( 2.6.6.5.2.4.8 NAME 'supplementaryInformation'
+       EQUALITY caseIgnoreMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{76} )
+
+attribute ( 2.6.6.5.2.4.9 NAME 'namingLink'
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
+
+attribute ( 2.6.6.5.2.4.10 NAME 'reciprocalNamingLink'
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.12
+       SINGLE-VALUE )
+
+# Numbers 11 to 14 are obsolete
+
+# Next one is unused.  BTW, this attribute is supposed to be
+# case-exact match, but we cannot make that match unless we
+# define the string with IA5 syntax and we don't have a
+# clear base for this.
+
+attribute ( 2.6.6.5.2.4.15 NAME 'logicalDSAReference'
+       EQUALITY caseIgnoreMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
+
+attribute ( 2.6.6.5.2.4.16 NAME 'multiMediaInformation'
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 )
+
+# Number 17, 18 and 19 are EDI-related attributes for the nadfEDIUser
+# class that we did not have and has been left out below.
+
+# Object classes
+
+# According to the intended use described in section 3.3.1 in the spec,
+# this can only be AUXILIARY.
+# We had lastModifiedTime as 'allows', but sd-04 has it as MUST.
+# We did not have multiMediaInformation neither on this class nor
+# on any of its derived classes.
+
+objectclass ( 2.6.6.5.2.6.7 NAME 'nadfObject' SUP top AUXILIARY
+       MUST lastModifiedTime
+       MAY ( multiMediaInformation $ nadfSearchGuide $
+       supplementaryInformation ) )
+
+# I think all classes derived from locality should be considered
+# STRUCTURAL, since locality is.
+
+objectclass ( 2.6.6.5.2.6.1 NAME 'usStateOrEquivalent'
+       SUP ( locality $ nadfObject ) STRUCTURAL
+       MUST ( l $ fipsStateNumericCode $ fipsStateAlphaCode $ st ) )
+
+objectclass ( 2.6.6.5.2.6.2 NAME 'usPlace'
+       SUP ( locality $ nadfObject ) STRUCTURAL
+       MUST ( l $ fipsPlaceNumericCode ) )
+
+objectclass ( 2.6.6.5.2.6.3 NAME 'usCountyOrEquivalent' SUP usPlace STRUCTURAL
+       MUST fipsCountyNumericCode )
+
+# applicationEntity is STRUCTURAL, so we will declare this one the same
+
+objectclass ( 2.6.6.5.2.6.5 NAME 'nadfApplicationEntity'
+       SUP applicationEntity STRUCTURAL
+       MUST supportedApplicationContext )
+
+# Following our heuristic, this one will be STRUCTURAL since organization
+# is too.  We did not have 'o' as 'requires', but if this is really a
+# subclass of organization, then 'o' becomes MUST by inheritance
+
+objectclass ( 2.6.6.5.2.6.6 NAME 'nadfADDMD'
+       SUP ( organization $ nadfObject ) STRUCTURAL
+       MUST addmdName )
+
+# Number 7 is nadfObject described above.
+
+# This one quacks like an AUXILIARY object class
+
+objectclass ( 2.6.6.5.2.6.8 NAME 'publicObject' SUP top AUXILIARY
+       MUST namingLink )
+
+# And so does this one
+
+objectclass ( 2.6.6.5.2.6.9 NAME 'providerObject' SUP top AUXILIARY
+       MUST reciprocalNamingLink )
+
+# The spec says number 10 is obsolete
+
+# This one also strongly smells like AUXILIARY
+
+objectclass ( 2.6.6.5.2.6.11 NAME 'fips55Object' SUP top AUXILIARY
+       MUST fipsPlaceNumericCode
+       MAY st )
+
+# The spec says numbers 12 to 18 are obsolete
+
+# Another obviously AUXILIARY class
+
+objectclass ( 2.6.6.5.2.6.19 NAME 'nationalObject' SUP top AUXILIARY
+       MUST c )
+
+# So is this one
+
+objectclass ( 2.6.6.5.2.6.20 NAME 'ansiOrgObject' SUP top AUXILIARY
+       MUST ansiOrgNumericCode )
+
+# We did not have the next one, but it is innocuous
+
+objectclass ( 2.6.6.5.2.6.21 NAME 'caProvinceOrTerritory'
+       SUP ( locality $ nadfObject ) STRUCTURAL
+       MUST st )
+
+# According to the spec, numbers 22, 23 and 24 are obsolete
+
+# Number 25 was nadfEDIuser as a subclass of edi-user.  Sorry we cannot
+# deal with this one and we did not have it anyway.
diff --git a/servers/slapd/schema/nis.at.conf b/servers/slapd/schema/nis.at.conf
new file mode 100644 (file)
index 0000000..1331c3c
--- /dev/null
@@ -0,0 +1,297 @@
+# $OpenLDAP$
+#
+# By:          Juan C. Gomez / gomez@engr.sgi.com
+# Date:                May/1999
+# Source:      RFC-2307
+# ---------------------------------------------------------
+#
+# Written by Juan C. Gomez and placed into the public domain.
+# This file is not subject to any license of SGI.
+#
+# ---------------------------------------------------------
+#
+# Attribute definitions for using LDAP as a back-end for 
+# Network Information Services (NIS) with OpenLDAP server. 
+#
+# I am adding the whole description here because, perhaps,
+# we will move towards better schema support in the future
+# and will have all the keywords to express the attribute
+# description more accurately.
+#
+# nisSchema OID = 1.3.6.1.1.1
+#                iso.org.dod.internet.directory.nisSchema
+#
+# NOTES:
+#
+# 1.- Two attributes have as a super-type the name attribute
+#     described in RFC-2256. The 'name' attribute has the 
+#     following description: (see X.520 for further details)
+#
+#      OID             2.5.4.41
+#      NAME            name
+#      SUBSTRINGS      caseIgnoreSubstringsMatch
+#      SYNTAX          DirectoryString{32768}
+# 
+#     DirectoryString Syntax (OID=1.3.6.1.4.1.1466.115.121.1.15)
+#     is described in RFC-2252, basically a UTF-8 (Unicode
+#     Superset) encoded string.
+#
+# 2.- The syntax for nisNetgroupTriple is 'nisNetgroupTripleSyntax',
+#     defined as:
+#
+#      OID             nisSchema.0.0
+#      NAME            'nisNetgroupTripleSyntax'
+#      DESC            'NIS netgroup triple'
+#      
+#     Where values in this syntax can be described as:
+#
+#      nisNetgroupTripleSyntax ::= SEQUENCE {
+#              hostname        [0] IA5String OPTIONAL,
+#              username        [1] IA5String OPTIONAL,
+#              domainname      [2] IA5String OPTIONAL
+#      }
+#     
+#     (These values are encoded as strings in LDAP servers)
+#
+# 3.- The syntax for bootParameter is 'bootParameterSyntax',
+#     defined as :
+#
+#      OID             nisSchema.0.1
+#      NAME            'bootParameterSyntax'
+#      DESC            'Boot Parameter'
+# 
+#     Where values in this syntax can be described as:
+#
+#      bootParameterSyntax ::= SEQUENCE {
+#              key      IA5String,
+#              server   IA5String,
+#              path     IA5String
+#      }
+#
+#     (These values are encoded as strings in LDAP servers)
+#
+
+
+# ----------------------FORMAL DESCRIPTION--------------------
+# OID          nisSchema.1.0
+# NAME         uidNumber
+# DESC         'An integer uniquely identifying a user in an
+#              administrative domain'
+# EQUALITY     integerMatch
+# SYNTAX       'INTEGER'       SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.1
+# NAME         gidNumber
+# DESC         'An integer uniquely identifying a group in an
+#              administrative domain'
+# EQUALITY     integerMatch
+# SYNTAX       'INTEGER'       SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.2
+# NAME         gecos
+# DESC         'The GECOS field; the common name'
+# EQUALITY     caseIgnoreIA5Match
+# SUBSTRINGS   caseIgnoreIA5SubstringsMatch
+# SYNTAX       'IA5String'      SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.3
+# NAME         homeDirectory
+# DESC         'The absolute path to the home directory'
+# EQUALITY     caseExactIA5Match
+# SYNTAX       'IA5String'      SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.4
+# NAME         loginShell
+# DESC         'The path to the login shell'
+# EQUALITY     caseExactIA5Match
+# SYNTAX       'IA5String'      SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.5
+# NAME         shadowLastChange
+# DESC         ''
+# EQUALITY     integerMatch
+# SYNTAX       'INTEGER'        SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.6
+# NAME         shadowMin
+# DESC         ''
+# EQUALITY     integerMatch
+# SYNTAX       'INTEGER'        SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.7
+# NAME         shadowMax
+# DESC         ''
+# EQUALITY     integerMatch
+# SYNTAX       'INTEGER'        SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.8
+# NAME         shadowWarning
+# DESC         ''
+# EQUALITY     integerMatch
+# SYNTAX       'INTEGER'        SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.9
+# NAME         shadowInactive
+# DESC         ''
+# EQUALITY     integerMatch
+# SYNTAX       'INTEGER'        SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.10
+# NAME         shadowExpire
+# DESC         ''
+# EQUALITY     integerMatch
+# SYNTAX       'INTEGER'        SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.11
+# NAME         shadowFlag
+# DESC         ''
+# EQUALITY     integerMatch
+# SYNTAX       'INTEGER'        SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.12
+# NAME         memberUid
+# DESC         ''
+# EQUALITY     caseExactIA5Match
+# SUBSTRINGS   caseExactIA5SubstringsMatch
+# SYNTAX       'IA5String'
+#
+#
+# OID          nisSchema.1.13
+# NAME         memberNisNetgroup
+# DESC         ''
+# EQUALITY     caseExactIA5Match
+# SUBSTRINGS   caseExactIA5SubstringsMatch
+# SYNTAX       'IA5String'
+#
+#
+# OID          nisSchema.1.14
+# NAME         memberNisNetgroup
+# DESC         'Netgroup triple'
+# SYNTAX       'nisNetgroupTripleSyntax'
+#
+#
+# OID          nisSchema.1.15
+# NAME         ipServicePort
+# DESC         ''
+# EQUALITY     integerMatch
+# SYNTAX       'INSTEGER'      SINGLE-VALUE    
+#
+#
+# OID          nisSchema.1.16
+# NAME         ipServiceProtocol
+# SUP          name
+#
+#
+# OID          nisSchema.1.17
+# NAME         ipServiceNUmber
+# EQUALITY     integerMatch
+# SYNTAX       'INSTEGER'      SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.18
+# NAME         oncRpcNumber
+# EQUALITY     integerMatch
+# SYNTAX       'INSTEGER'      SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.19
+# NAME         ipHostNumber
+# DESC         'IP address as a dotted decimal, eg. 192.168.1.1
+#              omitting leading zeros'
+# EQUALITY     caseIgnoreIA5Match
+# SYNTAX       'IA5String{128}'
+#
+#
+# OID          nisSchema.1.20
+# NAME         ipNetworkNumber
+# DESC         'IP network as a dotted decimal, eg. 192.168,
+#              omitting leading zeros'
+# EQUALITY     caseIgnoreIA5Match
+# SYNTAX       'IA5String{128}'        SINGLE-VALUE
+#
+#
+# OID          nisSchema.1.21
+# NAME         ipNetmaskNumber
+# DESC         'IP netmask as a dotted decimal, eg. 255.255.255.0,
+#              omitting leading zeros'
+# EQUALITY     caseIgnoreIA5Match      
+# SYNTAX       'IA5String{128}'        SINGLE-VALUE    
+#
+#
+# OID          nisSchema.1.22
+# NAME         macAddress
+# DESC         'MAC address in maximal, colon separated hex notation, 
+#              eg. 00:00:92:90:ee:e2'
+# EQUALITY     caseIgnoreIA5Match
+# SYNTAX       'IA5String{128}'
+#
+#
+# OID          nisSchema.1.23
+# NAME         bootParameter
+# DESC         'rpc.bootparamd parameter'
+# SYNTAX       'bootParameterSyntax'
+#
+#
+# OID          nisSchema.1.24
+# NAME         bootFile
+# DESC         'Boot image name'
+# EQUALITY     caseExactIA5Match
+# SYNTAX       'IA5String'
+#
+#
+# OID          nisSchema.1.26
+# NAME         nisMapName
+# DESC         ''
+# SUP          name
+#
+#
+# OID          nisSchema.1.27
+# NAME         nisMapEntry
+# DESC         ''
+# EQUALITY     caseExactIA5Match
+# SUBSTRINGS   caseExactIA5SubstringMatch
+# SYNTAX       'IA5String{1024}'       SINGLE-VALUE
+#
+# ----------------------END FORMAL DESCRIPTION-------------
+
+
+
+attribute      uidNumber               ces
+attribute      gidNumber               ces
+attribute      gecos                   cis
+attribute      homeDirectory           ces
+attribute      loginShell              ces
+attribute      shadowLastChange        ces
+attribute      shadowMin               ces
+attribute      shadowMax               ces
+attribute      shadowWarning           ces
+attribute      shadowInactive          ces
+attribute      shadowExpire            ces
+attribute      shadowFlag              ces
+attribute      memberUid               ces
+attribute      memberNisNetgroup       ces
+attribute      nisNetgroupTriple       ces
+attribute      ipServicePort           ces
+attribute      ipServiceProtocol       cis
+attribute      ipProtocolNumber        ces
+attribute      oncRpcNumber            ces
+attribute      ipHostNumber            cis
+attribute      ipNetworkNumber         cis
+attribute      ipNetmaskNumber         cis
+attribute      macAddress              cis
+attribute      bootParameter           ces
+attribute      bootFile                ces
+attribute      nisMapName              cis
+attribute      nisMapEntry             ces
diff --git a/servers/slapd/schema/nis.oc.conf b/servers/slapd/schema/nis.oc.conf
new file mode 100644 (file)
index 0000000..fe8a110
--- /dev/null
@@ -0,0 +1,244 @@
+# $OpenLDAP$
+#
+# By:          Juan C. Gomez / gomez@engr.sgi.com
+# Date:                May/1999
+# Source:      RFC-2307
+# ---------------------------------------------------------
+#
+# Written by Juan C. Gomez and placed into the public domain.
+# This file is not subject to any license of SGI.
+#
+# ---------------------------------------------------------
+#
+# Object Classes for using LDAP as a backend for Network
+# Information Services (NIS).
+# (As Proposed in RFC-2307)
+# 
+
+
+
+
+# ----------------------FORMAL DESCRIPTION--------------------
+# OID  nisSchema.2.0 
+# NAME 'posixAccount' SUP top AUXILIARY
+# DESC 'Abstraction of an account with POSIX attributes'
+# MUST ( cn $ uid $ uidNumber $ gidNumber $ homeDirectory )
+# MAY  ( userPassword $ loginShell $ gecos $ description ) )
+#
+#
+# OID  nisSchema.2.1
+# NAME 'shadowAccount' SUP top AUXILIARY
+# DESC 'Additional attributes for shadow passwords'
+# MUST uid
+# MAY ( userPassword $ shadowLastChange $ shadowMin
+#       shadowMax $ shadowWarning $ shadowInactive $
+#       shadowExpire $ shadowFlag $ description )
+#
+#
+# OID  nisSchema.2.2 NAME 'posixGroup' SUP top STRUCTURAL
+# DESC  'Abstraction of a group of accounts'
+# MUST ( cn $ gidNumber )
+# MAY ( userPassword $ memberUid $ description ) )
+#
+#
+# OID          nisSchema.2.3 NAME 'ipService' SUP top STRUCTURAL
+# DESC         'Abstraction an Internet Protocol service.
+#               Maps an IP port and protocol (such as tcp or udp)
+#               to one or more names; the distinguished value of
+#               the cn attribute denotes the service's canonical
+#               name'
+# MUST         ( cn $ ipServicePort $ ipServiceProtocol )
+# MAY          ( description )
+#
+#
+# OID          nisSchema.2.4 NAME 'ipProtocol' SUP top STRUCTURAL
+# DESC         'Abstraction of an IP protocol. Maps a protocol number
+#               to one or more names. The distinguished value of the cn
+#               attribute denotes the protocol's canonical name'
+# MUST         ( cn $ ipProtocolNumber $ description )
+# MAY          description 
+#
+#
+# OID  nisSchema.2.5 NAME 'oncRpc' SUP top STRUCTURAL
+# DESC 'Abstraction of an Open Network Computing (ONC)
+#       [RFC1057] Remote Procedure Call (RPC) binding.
+#       This class maps an ONC RPC number to a name.
+#       The distinguished value of the cn attribute denotes
+#        the RPC service's canonical name'
+# MUST ( cn $ oncRpcNumber $ description )
+# MAY  description
+#
+#
+# OID  nisSchema.2.6 NAME 'ipHost' SUP top AUXILIARY
+# DESC 'Abstraction of a host, an IP device. The distinguished
+#        value of the cn attribute denotes the host's canonical
+#        name. Device SHOULD be used as a structural class'
+# MUST ( cn $ ipHostNumber )
+# MAY  ( l $ description $ manager ) )
+#
+#
+# OID  nisSchema.2.7 NAME 'ipNetwork' SUP top STRUCTURAL
+# DESC 'Abstraction of a network. The distinguished value of
+#       the cn attribute denotes the network's canonical name'
+# MUST ( cn $ ipNetworkNumber )
+# MAY  ( ipNetmaskNumber $ l $ description $ manager ) )
+#
+#
+# OID  nisSchema.2.8 NAME 'nisNetgroup' SUP top STRUCTURAL
+# DESC 'Abstraction of a netgroup. May refer to other netgroups'
+# MUST cn
+# MAY  ( nisNetgroupTriple $ memberNisNetgroup $ description )
+#
+#
+# OID  nisSchema.2.09 NAME 'nisMap' SUP top STRUCTURAL
+# DESC 'A generic abstraction of a NIS map'
+# MUST nisMapName
+# MAY  description
+#
+#
+# OID  nisSchema.2.10 NAME 'nisObject' SUP top STRUCTURAL
+# DESC 'An entry in a NIS map'
+# MUST ( cn $ nisMapEntry $ nisMapName )
+# MAY  description
+#
+#
+# OID  nisSchema.2.11 NAME 'ieee802Device' SUP top AUXILIARY
+# DESC 'A device with a MAC address; device SHOULD be
+#      used as a structural class'
+# MAY macAddress
+#
+#
+# OID  nisSchema.2.12 NAME 'bootableDevice' SUP top AUXILIARY
+# DESC 'A device with boot parameters; device SHOULD be
+#      used as a structural class'
+# MAY  ( bootFile $ bootParameter )
+#
+# ----------------------END FORMAL DESCRIPTION-------------
+
+
+
+
+objectclass    posixAccount
+       requires
+               objectClass,
+               cn,
+               uid,
+               uidNumber,
+               gidNumber,
+               homeDirectory
+       allows
+               userPassword,
+               loginShell,
+               gecos,
+               description
+       
+objectclass    shadowAccount
+       requires
+               objectClass,
+               uid
+       allows
+               userPassword,
+               shadowLastChange,
+               shadowMin,
+               shadowMax,
+               shadowWarning,
+               shadowInactive,
+               shadowExpire,
+               shadowFlag,
+               description
+
+objectclass    posixGroup
+       requires
+               objectClass,
+               cn,
+               gidNumber
+       allows
+               userPassword,
+               memberUid,
+               description
+
+objectclass    ipService
+       requires
+               objectClass,
+               cn,
+               ipServicePort,
+               ipServiceProtocol
+       allows
+               description
+
+objectclass    ipProtocol
+       requires
+               objectClass,
+               cn,
+               ipProtocolNumber,
+               description
+       allows
+               description
+
+objectclass    oncRpc
+       requires
+               objectClass,
+               cn,
+               oncRpcNumber,
+               description
+       allows
+               description
+
+objectclass    ipHost
+       requires
+               objectClass,
+               cn,
+               ipHostNumber
+       allows
+               l,
+               description,
+               manager
+
+objectclass    ipNetwork
+       requires
+               objectClass,
+               cn,
+               ipNetworkNumber
+       allows
+               ipNetmaskNumber,
+               l,
+               description,
+               manager
+
+objectclass    nisNetgroup
+       requires
+               objectClass,
+               cn
+       allows
+               nisNetgroupTriple,
+               memberNisNetgroup,
+               description
+
+objectclass    nisMap
+       requires
+               objectClass,
+               nisMapName
+       allows
+               description
+
+objectclass    nisObject
+       requires
+               objectClass,
+               cn,
+               nisMapEntry,
+               nisMapName
+       allows
+               description
+
+objectclass    ieee802Device
+       requires
+               objectClass
+       allows
+               macAddress
+
+objectclass    bootableDevice
+       requires
+               objectClass
+       allows
+               bootFile,
+               bootParameter
diff --git a/servers/slapd/schema/nis.schema b/servers/slapd/schema/nis.schema
new file mode 100644 (file)
index 0000000..7c5ccf2
--- /dev/null
@@ -0,0 +1,232 @@
+# $OpenLDAP$
+# Definitions from RFC2307
+
+# Note: The definitions in RFC2307 are given in syntaxes closely related
+# to those in RFC2252, however, some liberties are taken that are not
+# supported by RFC2252.  This file has been written following RFC2252
+# strictly.
+
+# OID Base is iso(1) org(3) dod(6) internet(1) directory(1) nisSchema(1).
+# i.e. nisSchema in RFC2307 is 1.3.6.1.1.1
+#
+# Syntaxes are under 1.3.6.1.1.1.0 (two new syntaxes are defined)
+# Attribute types are under 1.3.6.1.1.1.1
+# Object classes are under 1.3.6.1.1.1.2
+
+# Attribute Type Definitions
+
+attribute ( 1.3.6.1.1.1.1.0 NAME 'uidNumber'
+       DESC 'An integer uniquely identifying a user in an administrative domain'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.1 NAME 'gidNumber'
+       DESC 'An integer uniquely identifying a group in an administrative domain'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+# TBC: caseIgnoreIA5SubstringsMatch is not defined
+
+attribute ( 1.3.6.1.1.1.1.2 NAME 'gecos'
+       DESC 'The GECOS field; the common name'
+       EQUALITY caseIgnoreIA5Match
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.3 NAME 'homeDirectory'
+       DESC 'The absolute path to the home directory'
+       EQUALITY caseExactIA5Match
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.4 NAME 'loginShell'
+       DESC 'The path to the login shell'
+       EQUALITY caseExactIA5Match
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.5 NAME 'shadowLastChange'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.6 NAME 'shadowMin'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.7 NAME 'shadowMax'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.8 NAME 'shadowWarning'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.9 NAME 'shadowInactive'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.10 NAME 'shadowExpire'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.11 NAME 'shadowFlag'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+# TBC: caseIgnoreIA5SubstringsMatch is not defined
+
+attribute ( 1.3.6.1.1.1.1.12 NAME 'memberUid'
+       EQUALITY caseExactIA5Match
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
+
+# TBC: caseIgnoreIA5SubstringsMatch is not defined
+
+attribute ( 1.3.6.1.1.1.1.13 NAME 'memberNisNetgroup'
+       EQUALITY caseExactIA5Match
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
+
+attribute ( 1.3.6.1.1.1.1.14 NAME 'nisNetgroupTriple'
+       DESC 'Netgroup triple'
+       SYNTAX 1.3.6.1.1.1.0.0 )
+
+attribute ( 1.3.6.1.1.1.1.15 NAME 'ipServicePort'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.16 NAME 'ipServiceProtocol'
+       SUP name )
+
+attribute ( 1.3.6.1.1.1.1.17 NAME 'ipProtocolNumber'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.18 NAME 'oncRpcNumber'
+       EQUALITY integerMatch
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.19 NAME 'ipHostNumber'
+       DESC 'IP address as a dotted decimal, eg. 192.168.1.1, omitting leading zeros'
+       EQUALITY caseIgnoreIA5Match
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{128} )
+
+attribute ( 1.3.6.1.1.1.1.20 NAME 'ipNetworkNumber'
+       DESC 'IP network as a dotted decimal, eg. 192.168, omitting leading zeros'
+       EQUALITY caseIgnoreIA5Match
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{128} SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.21 NAME 'ipNetmaskNumber'
+       DESC 'IP netmask as a dotted decimal, eg. 255.255.255.0, omitting leading zeros'
+       EQUALITY caseIgnoreIA5Match
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{128} SINGLE-VALUE )
+
+attribute ( 1.3.6.1.1.1.1.22 NAME 'macAddress'
+       DESC 'MAC address in maximal, colon separated hex notation, eg. 00:00:92:90:ee:e2'
+       EQUALITY caseIgnoreIA5Match
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{128} )
+
+attribute ( 1.3.6.1.1.1.1.23 NAME 'bootParameter'
+       DESC 'rpc.bootparamd parameter'
+       SYNTAX 1.3.6.1.1.1.0.1 )
+
+attribute ( 1.3.6.1.1.1.1.24 NAME 'bootFile'
+       DESC 'Boot image name'
+       EQUALITY caseExactIA5Match
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
+
+attribute ( 1.3.6.1.1.1.1.26 NAME 'nisMapName'
+       SUP name )
+
+# TBC: caseIgnoreIA5SubstringsMatch is not defined
+
+attribute ( 1.3.6.1.1.1.1.27 NAME 'nisMapEntry'
+       EQUALITY caseExactIA5Match
+       SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{1024} SINGLE-VALUE )
+
+# Object Class Definitions
+
+objectclass ( 1.3.6.1.1.1.2.0 NAME 'posixAccount' SUP top AUXILIARY
+       DESC 'Abstraction of an account with POSIX attributes'
+       MUST ( cn $ uid $ uidNumber $ gidNumber $ homeDirectory )
+       MAY ( userPassword $ loginShell $ gecos $ description ) )
+
+objectclass ( 1.3.6.1.1.1.2.1 NAME 'shadowAccount' SUP top AUXILIARY
+       DESC 'Additional attributes for shadow passwords'
+       MUST uid
+       MAY ( userPassword $ shadowLastChange $ shadowMin $
+             shadowMax $ shadowWarning $ shadowInactive $
+             shadowExpire $ shadowFlag $ description ) )
+
+objectclass ( 1.3.6.1.1.1.2.2 NAME 'posixGroup' SUP top STRUCTURAL
+       DESC 'Abstraction of a group of accounts'
+       MUST ( cn $ gidNumber )
+       MAY ( userPassword $ memberUid $ description ) )
+
+# TBC: quotes in quoted strings
+
+objectclass ( 1.3.6.1.1.1.2.3 NAME 'ipService' SUP top STRUCTURAL
+       DESC 'Abstraction an Internet Protocol service.
+             Maps an IP port and protocol (such as tcp or udp)
+             to one or more names; the distinguished value of
+             the cn attribute denotes the service"s canonical
+             name'
+       MUST ( cn $ ipServicePort $ ipServiceProtocol )
+       MAY ( description ) )
+
+# TBC: quotes in quoted strings
+
+objectclass ( 1.3.6.1.1.1.2.4 NAME 'ipProtocol' SUP top STRUCTURAL
+       DESC 'Abstraction of an IP protocol. Maps a protocol number
+             to one or more names. The distinguished value of the cn
+             attribute denotes the protocol"s canonical name'
+       MUST ( cn $ ipProtocolNumber $ description )
+       MAY description )
+
+# TBC: quotes in quoted strings
+
+objectclass ( 1.3.6.1.1.1.2.5 NAME 'oncRpc' SUP top STRUCTURAL
+       DESC 'Abstraction of an Open Network Computing (ONC)
+             [RFC1057] Remote Procedure Call (RPC) binding.
+             This class maps an ONC RPC number to a name.
+             The distinguished value of the cn attribute denotes
+             the RPC service"s canonical name'
+       MUST ( cn $ oncRpcNumber $ description )
+       MAY description )
+
+# TBC: quotes in quoted strings
+
+objectclass ( 1.3.6.1.1.1.2.6 NAME 'ipHost' SUP top AUXILIARY
+       DESC 'Abstraction of a host, an IP device. The distinguished
+             value of the cn attribute denotes the host"s canonical
+             name. Device SHOULD be used as a structural class'
+       MUST ( cn $ ipHostNumber )
+       MAY ( l $ description $ manager ) )
+
+# TBC: quotes in quoted strings
+
+objectclass ( 1.3.6.1.1.1.2.7 NAME 'ipNetwork' SUP top STRUCTURAL
+       DESC 'Abstraction of a network. The distinguished value of
+             the cn attribute denotes the network"s canonical name'
+       MUST ( cn $ ipNetworkNumber )
+       MAY ( ipNetmaskNumber $ l $ description $ manager ) )
+
+objectclass ( 1.3.6.1.1.1.2.8 NAME 'nisNetgroup' SUP top STRUCTURAL
+       DESC 'Abstraction of a netgroup. May refer to other netgroups'
+       MUST cn
+       MAY ( nisNetgroupTriple $ memberNisNetgroup $ description ) )
+
+objectclass ( 1.3.6.1.1.1.2.9 NAME 'nisMap' SUP top STRUCTURAL
+       DESC 'A generic abstraction of a NIS map'
+       MUST nisMapName
+       MAY description )
+
+objectclass ( 1.3.6.1.1.1.2.10 NAME 'nisObject' SUP top STRUCTURAL
+       DESC 'An entry in a NIS map'
+       MUST ( cn $ nisMapEntry $ nisMapName )
+       MAY description )
+
+objectclass ( 1.3.6.1.1.1.2.11 NAME 'ieee802Device' SUP top AUXILIARY
+       DESC 'A device with a MAC address; device SHOULD be
+             used as a structural class'
+       MAY macAddress )
+
+objectclass ( 1.3.6.1.1.1.2.12 NAME 'bootableDevice' SUP top AUXILIARY
+       DESC 'A device with boot parameters; device SHOULD be
+             used as a structural class'
+       MAY ( bootFile $ bootParameter ) )
diff --git a/servers/slapd/schema/others_nis.at.conf b/servers/slapd/schema/others_nis.at.conf
new file mode 100644 (file)
index 0000000..1c6d91e
--- /dev/null
@@ -0,0 +1,283 @@
+# $OpenLDAP$
+#
+# By:          Juan C. Gomez / gomez@engr.sgi.com
+# Date:                May/1999
+# Source:      RFC-2307
+# ------------------------------------------------------------
+# Attribute definitions for using LDAP as a back-end for Network
+# Information Services (NIS) with an OpenLDAP server. 
+# This file holds the definitions of those attributes used in 
+# RFC-2307, which are defined in other RFCs or X500 standards. 
+# You may not need to include this file if you already have 
+# these definitions in your default configuration files (i.e. 
+# slapd.at.conf).
+#
+
+
+
+#
+# ----------------------FORMAL DESCRIPTION--------------------
+#
+# RFC-2256     ( 2.5.4.23 NAME 'facsimileTelephoneNumber'
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.22 )
+# RFC-1274     facsimileTelephoneNumber ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX FacsimileTelephoneNumber
+#              ::= {attributeType 23}
+#
+#
+# RFC-2256     ( 2.5.4.14 NAME 'searchGuide'
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.25 )
+# RFC-1274     searchGuide ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX Guide
+#              ::= {attributeType 14}
+#
+#
+# RFC-2256     ( 2.5.4.15 NAME 'businessCategory' EQUALITY caseIgnoreMatch
+#              SUBSTR caseIgnoreSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )
+# RFC-1274     businessCategory ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX caseIgnoreStringSyntax
+#              (SIZE (1..ub-business-category))
+#              ::= {attributeType 15}
+#
+#  
+# RFC-2256     ( 2.5.4.24 NAME 'x121Address' EQUALITY numericStringMatch
+#              SUBSTR numericStringSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.36{15} )
+# RFC-1274     x121Address ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX NumericString
+#              (SIZE (1..ub-x121-address))
+#              ::= {attributeType 24}
+#
+# 
+# RFC-2256     ( 2.5.4.26 NAME 'registeredAddress' SUP postalAddress
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )
+# RFC-1274     registeredAddress ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX PostalAddress
+#              ::= {attributeType 26}
+#
+#
+# RFC-2256     ( 2.5.4.27 NAME 'destinationIndicator' EQUALITY caseIgnoreMatch
+#              SUBSTR caseIgnoreSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{128} )
+# RFC-1274     destinationIndicator ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX PrintableString
+#              (SIZE (1..ub-destination-indicator))
+#              MATCHES FOR EQUALITY SUBSTRINGS
+#              ::= {attributeType 27}
+#
+# 
+# RFC-2256     ( 2.5.4.28 NAME 'preferredDeliveryMethod'
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.14
+#              SINGLE-VALUE )
+# RFC-1274     preferredDeliveryMethod ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX deliveryMethod
+#              ::= {attributeType 28}
+#
+# 
+# RFC-2256     ( 2.5.4.21 NAME 'telexNumber'
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.52 )
+# RFC-1274     telexNumber ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX TelexNumber
+#              (SIZE (1..ub-telex))
+#              ::= {attributeType 21}
+#
+#
+# RFC-2256     ( 2.5.4.22 NAME 'teletexTerminalIdentifier'
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.51 )
+# RFC-1274     teletexTerminalIdentifier ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX TeletexTerminalIdentifier
+#              (SIZE (1..ub-teletex-terminal-id))
+#              ::= {attributeType 22}
+#
+#
+# RFC-2256     ( 2.5.4.20 NAME 'telephoneNumber' EQUALITY telephoneNumberMatch
+#              SUBSTR telephoneNumberSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.50{32} )
+# RFC-1274      telephoneNumber ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX telephoneNumberSyntax
+#              (SIZE (1..ub-telephone-number))
+#
+# 
+# RFC-2256     ( 2.5.4.25 NAME 'internationaliSDNNumber' 
+#              EQUALITY numericStringMatch
+#              SUBSTR numericStringSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.36{16} )
+# RFC-1274      internationaliSDNNumber ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX NumericString
+#              (SIZE (1..ub-isdn-address))
+#              ::= {attributeType 2
+#
+#
+# RFC-2256     ( 2.5.4.9 NAME 'street' EQUALITY caseIgnoreMatch
+#              SUBSTR caseIgnoreSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )
+# RFC-1274     streetAddress ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX caseIgnoreStringSyntax
+#              (SIZE (1..ub-street-address))
+#              ::= {attributeType 9}
+#
+# 
+#  RFC-2256    ( 2.5.4.18 NAME 'postOfficeBox' EQUALITY caseIgnoreMatch
+#              SUBSTR caseIgnoreSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{40} )
+#  RFC-1274     postOfficeBox ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX caseIgnoreStringSyntax
+#              (SIZE (1..ub-post-office-box))
+#              ::= {attributeType 18}
+# 
+#
+#  RFC-2256    ( 2.5.4.17 NAME 'postalCode' EQUALITY caseIgnoreMatch
+#              SUBSTR caseIgnoreSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{40} )
+#  RFC-1274    postalCode ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX caseIgnoreStringSyntax
+#              (SIZE (1..ub-postal-code))
+#              ::= {attributeType 17}
+#
+#
+#  RFC-2256    ( 2.5.4.16 NAME 'postalAddress' EQUALITY caseIgnoreListMatch
+#              SUBSTR caseIgnoreListSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )
+#  RFC-1274     postalAddress ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX PostalAddress
+#              MATCHES FOR EQUALITY
+#              ::= {attributeType 16}
+#
+#
+#  RFC-2256    ( 2.5.4.19 NAME 'physicalDeliveryOfficeName'
+#              EQUALITY caseIgnoreMatch
+#              SUBSTR caseIgnoreSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )
+#  RFC-1274     physicalDeliveryOfficeName ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX caseIgnoreStringSyntax
+#              (SIZE (1..ub-physical-office-name))
+#              ::= {attributeType 19}
+#
+#
+#  RFC-2256    ( 2.5.4.8 NAME 'st' SUP name )
+#  RFC-1274    stateOrProvinceName ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX caseIgnoreStringSyntax
+#              (SIZE (1..ub-state-name))
+#              ::= {attributeType 8}
+#
+#
+#  RFC-2256    ( 2.5.4.0 NAME 'objectClass' EQUALITY objectIdentifierMatch
+#                SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )
+#  RFC-1274    objectClass ObjectClass
+#              ::= {attributeType 0}
+#
+#
+#  RFC-2256 ( 2.5.4.3 NAME 'cn' SUP name )
+#  RFC-1274    commonName ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX caseIgnoreStringSyntax
+#              (SIZE (1..ub-common-name))
+#              ::= {attributeType 3}
+#
+#
+# RFC-1274     userid ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX
+#              caseIgnoreStringSyntax
+#              (SIZE (1 .. ub-user-identifier))
+#              ::= {pilotAttributeType 1}
+#
+#
+#  RFC-2256    ( 2.5.4.35 NAME 'userPassword' EQUALITY octetStringMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128} )
+#  RFC-1274    userPassword ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX Userpassword
+#              ::= {attributeType 35}
+#
+#
+#  RFC-2256    ( 2.5.4.13 NAME 'description' EQUALITY caseIgnoreMatch
+#              SUBSTR caseIgnoreSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )
+#
+#
+#  RFC-2256    ( 2.5.4.7 NAME 'l' SUP name )
+#
+#
+#  RFC-1274    manager ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX
+#              distinguishedNameSyntax
+#              ::= {pilotAttributeType 10}
+#
+#
+#  RFC-2256    ( 2.5.4.5 NAME 'serialNumber' EQUALITY caseIgnoreMatch
+#              SUBSTR caseIgnoreSubstringsMatch
+#              SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{64} )
+#  RFC-1274    serialNumber ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX printableStringSyntax
+#              (SIZE (1..ub-serial-number))
+#              ::= {attributeType 5}
+#
+#
+#  RFC-2256    ( 2.5.4.10 NAME 'o' SUP name )
+#
+#
+#  RFC-2256    ( 2.5.4.11 NAME 'ou' SUP name )
+#
+#
+#  RFC-2256    ( 2.5.4.6 NAME 'c' SUP name SINGLE-VALUE )
+#  RFC-1274    countryName ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX PrintableString
+#              (SIZE (1..ub-country-code))
+#              SINGLE VALUE
+#              ::= {attributeType 6}
+#
+#
+#  RFC-2256    ( 2.5.4.34 NAME 'seeAlso' SUP distinguishedName )
+#  RFC-1274    seeAlso ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX distinguishedNameSyntax
+#              ::= {attributeType 34}
+#
+#
+#  RFC-1274     host ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX
+#              caseIgnoreStringSyntax
+#              (SIZE (1 .. ub-host))
+#              ::= {pilotAttributeType 9}
+#
+#
+#  RFC-2256    ( 2.5.4.32 NAME 'owner' SUP distinguishedName )
+#  RFC-1274    owner ATTRIBUTE
+#              WITH ATTRIBUTE-SYNTAX distinguishedNameSyntax
+#              ::= {attributeType 32}
+#
+# ----------------------END FORMAL DESCRIPTION-------------
+#
+
+
+
+
+attribute      facsimileTelephoneNumber        fax     tel
+attribute      searchGuide                             cis
+attribute      businessCategory                        cis
+attribute      x121Address                             cis
+attribute      registeredAddress                       cis
+attribute      destinationIndicator                    cis
+attribute      preferredDeliveryMethod                 cis
+attribute      telexNumber                             cis
+attribute      teletexTerminalIdentifier               cis
+attribute      telephoneNumber                         tel
+attribute      internationaliSDNNumber                 ces
+attribute      street                                  cis
+attribute      postOfficeBox                           cis
+attribute      postalCode                              cis
+attribute      postalAddress                           cis
+attribute      physicalDeliveryOfficeName              cis
+attribute      st                                      cis
+attribute      objectClass                             cis
+attribute      cn      commonName                      cis
+attribute      uid     userid                          cis
+attribute      userPassword                            ces
+attribute      description                             cis
+attribute      l       localityName                    cis
+attribute      manager                                 dn
+attribute      serialNumber                            cis
+attribute      o       organizationName                cis
+attribute      ou      organizationalUnitName          cis
+attribute      c       countryName                     cis
+attribute      seeAlso                                 dn
+attribute      host                                    cis
+attribute      owner                                   dn
diff --git a/servers/slapd/schema/others_nis.oc.conf b/servers/slapd/schema/others_nis.oc.conf
new file mode 100644 (file)
index 0000000..ad3833e
--- /dev/null
@@ -0,0 +1,137 @@
+# $OpenLDAP$
+#
+# By:          Juan C. Gomez
+# Date:                05/04/1999
+# Source:      RFC-2307
+# ------------------------------------------------------------
+# Object class definitions for using LDAP as a back-end for Network
+# Information Services (NIS) with an OpenLDAP server. 
+# This file holds the definitions of those attributes used in 
+# RFC-2307, which are defined in other RFCs or X500 standards. 
+# You may not need to include this file if you already have these 
+# definitions in your default configuration files (i.e. 
+# slapd.oc.conf).
+#
+
+
+
+
+#
+# ----------------------FORMAL DESCRIPTION--------------------
+#
+# RFC-2256     ( 2.5.6.0 NAME 'top' ABSTRACT MUST objectClass )
+# RFC-1274     top OBJECT-CLASS
+#              MUST CONTAIN {
+#              objectClass}
+#              ::= {objectClass 0}
+#
+#
+# RFC-2256     ( 2.5.6.4 NAME 'organization' SUP top STRUCTURAL MUST o
+#              MAY ( userPassword $ searchGuide $ seeAlso $ businessCategory $
+#              x121Address $ registeredAddress $ destinationIndicator $
+#              preferredDeliveryMethod $ telexNumber $ 
+#              teletexTerminalIdentifier $ telephoneNumber $
+#              internationaliSDNNumber $ facsimileTelephoneNumber $
+#              street $ postOfficeBox $ postalCode $ postalAddress $
+#              physicalDeliveryOfficeName $ st $ l $ description ) )
+# RFC-1274     organization OBJECT-CLASS
+#              SUBCLASS OF top
+#              MUST CONTAIN {
+#              organizationName}
+#              MAY CONTAIN {
+#              organizationalAttributeSet}
+#              ::= {objectClass 4}
+#  
+#
+# RFC-1274     account OBJECT-CLASS
+#              SUBCLASS OF top
+#              MUST CONTAIN {
+#              userid}
+#              MAY CONTAIN {
+#              description,
+#              seeAlso,
+#              localityName,
+#               organizationName,
+#               organizationalUnitName,
+#               host}
+#               ::= {pilotObjectClass 5}
+#
+#
+# RFC-2256     ( 2.5.6.14 NAME 'device' SUP top STRUCTURAL MUST cn
+#               MAY ( serialNumber $ seeAlso $ owner $ ou $ o $ l $
+#               description ) )
+# RFC-1274     device OBJECT-CLASS
+#              SUBCLASS OF top
+#              MUST CONTAIN {
+#               commonName}
+#               MAY CONTAIN {
+#               description,
+#              localityName,
+#               organizationName,
+#               organizationalUnitName,
+#               owner,
+#               seeAlso,
+#               serialNumber}
+#               ::= {objectClass 14}
+#
+# ----------------------END FORMAL DESCRIPTION-------------
+#
+
+
+
+
+objectclass    top
+       requires
+               objectClass
+
+objectclass    organization
+       requires
+               objectClass,
+               o
+       allows
+               userPassword,
+               searchGuide,
+               seeAlso,
+               businessCategory,
+               x121Address,
+               registeredAddress,
+               destinationIndicator,
+               preferredDeliveryMethod,
+               telexNumber,
+               teletexTerminalIdentifier,
+               telephoneNumber,
+               internationaliSDNNumber,
+               facsimileTelephoneNumber,
+               street,
+               postOfficeBox,
+               postalCode,
+               postalAddress,
+               physicalDeliveryOfficeName,
+               st,
+               l,
+               description
+
+objectclass    account
+       requires
+               objectClass,
+               uid
+       allows
+               description,
+               seeAlso,
+               l,
+               o,
+               ou,
+               host
+
+objectclass    device
+       requires
+               objectClass,
+               cn      
+       allows
+               description,
+               l,
+               o,
+                ou,
+                owner,
+                seeAlso,
+                serialNumber
index d807f78419e560cf065ade4fa6d81614d4bc75f6..2a205798b246b2c1d31aa666e785497d1193c548 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 # These come from RFC1274 and are in ASN.1 syntax.  They have been
 # translated with some imagination.  Only attributes and classes we
 # already had are here.  In general, the matching rules in the
index a2e3514a4181a2107d2e8721e2dd7227ddf06239..14fef80d1daefe081ed1b690c0ea45d13dbcf873 100644 (file)
@@ -1,4 +1,5 @@
 /* schemaparse.c - routines to parse config file objectclass definitions */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 #include "slap.h"
 #include "ldap_schema.h"
 
-static Avlnode         *object_classes = NULL;
-
 int    global_schemacheck = 1; /* schemacheck on is default */
 
-static void            oc_usage_old(void);
-static void            oc_usage(void);
+static void            oc_usage_old(void) LDAP_GCCATTR((noreturn));
+static void            oc_usage(void)     LDAP_GCCATTR((noreturn));
+static void            at_usage(void)     LDAP_GCCATTR((noreturn));
 
-static char *err2text[] = {
+static char *const err2text[] = {
        "",
        "Out of memory",
        "Objectclass not found",
@@ -51,7 +51,7 @@ scherr2str(int code)
 void
 parse_oc_old(
     Backend    *be,
-    char       *fname,
+    const char *fname,
     int                lineno,
     int                argc,
     char       **argv
@@ -151,9 +151,9 @@ parse_oc_old(
  * matched, otherwise return length matched.
  */
 int
-dscompare(char *s1, char *s2, char delim)
+dscompare(const char *s1, const char *s2, char delim)
 {
-       char *orig = s1;
+       const char *orig = s1;
        while (*s1++ == *s2++)
                if (!s1[-1]) break;
        --s1;
@@ -202,7 +202,7 @@ find_oidm(char *oid)
 
 void
 parse_oidm(
-    char       *fname,
+    const char *fname,
     int                lineno,
     int                argc,
     char       **argv
@@ -233,7 +233,7 @@ usage:              fprintf( stderr, "ObjectIdentifier <name> <oid>\n");
 
 void
 parse_oc(
-    char       *fname,
+    const char *fname,
     int                lineno,
     char       *line,
     char       **argv
@@ -337,7 +337,7 @@ at_usage( void )
 
 void
 parse_at(
-    char       *fname,
+    const char *fname,
     int                lineno,
     char       *line,
     char       **argv
index e2ecd1ad10f75d887ec524e65bdcf9592d218d72..32a797d249da8f553f28b729d2562f73f285b5f0 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1995 Regents of the University of Michigan.
  * All rights reserved.
@@ -17,7 +18,6 @@
 #include <ac/string.h>
 #include <ac/socket.h>
 
-#include "ldap_defaults.h"
 #include "slap.h"
 
 
@@ -125,6 +125,7 @@ do_search(
                        send_ldap_result( conn, op, err,
                                NULL, "Bad search filter", NULL, NULL );
                }
+               rc = -1;
                goto return_results;
        }
 
diff --git a/servers/slapd/shell-backends/Makefile.in b/servers/slapd/shell-backends/Makefile.in
new file mode 100644 (file)
index 0000000..6935c5f
--- /dev/null
@@ -0,0 +1,22 @@
+# $OpenLDAP$
+
+PROGRAMS = passwd-shell
+
+SRCS = passwd-shell.c shellutil.c
+XSRCS = pwd-version.c
+OBJS = passwd-shell.o shellutil.o
+
+LDAP_INCDIR= ../../../include       
+LDAP_LIBDIR= ../../../libraries
+
+BUILD_OPT = "--enable-shell"
+BUILD_SRV = @BUILD_SHELL@
+
+all-local-srv: $(PROGRAMS)
+
+passwd-shell:  pwd-version.o
+       $(CC) $(LDFLAGS) -o $@ $(OBJS) pwd-version.o $(LIBS)
+
+pwd-version.c: $(OBJS) $(LDAP_LIBDEPEND)
+       @-$(RM) $@
+       $(MKVERSION) passwd-shell > $@
index c62b5d058f88305881df1beeed883065251f3d90..d7f7b191cfb807f45bf14a8960960f707f63afd5 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  passwd-shell.c - /etc/passwd shell-based backend for standalone ldap server
 
index a90e021edcadade41cddc943d81ddc01e000e808..227fd6041f339ff308bea256f30dfc7d9a34f651 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  passwd-shell.h
 
index 51d88f19d72e0efbc59d90960a98fc2469780f73..79a476659c1dfb20c9728d93314c18720c6d84c0 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1995 Regents of the University of Michigan.
  * All rights reserved.
index 4ba1213fa2fa11e833df5abb1671ce401de9b4d4..d05ec738959ea8f05eb941cf809f99f9fbb96e28 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  shellutil.c - common routines useful when building shell-based backends
                 for the standalone ldap server
@@ -320,26 +321,12 @@ ecalloc( unsigned nelem, unsigned elsize )
 
 /* VARARGS */
 void
-debug_printf
-#if HAVE_STDARG
-       ( char *fmt, ... )
-#else
-       ( va_alist )
-    va_dcl
-#endif
+debug_printf( const char *fmt, ... )
 {
     va_list    ap;
-#if !HAVE_STDARG
-    char       *fmt;
-#endif
 
        if ( debugflg ) {
-#if HAVE_STDARG
                va_start( ap, fmt );
-#else
-               va_start( ap );
-               fmt = va_arg( ap, char * );
-#endif
                fprintf( stderr, "%s: ", progname );
                vfprintf( stderr, fmt, ap );
                va_end( ap );
index 7ea0db057cbae98961b67a628fadf0ab8b7b4125..28713094bb50af3c9cdf9bf9b152d8665852df1f 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  shellutil.h
 
  is provided ``as is'' without express or implied warranty.
 */
 
+#ifndef SHELLUTIL_H
+#define SHELLUTIL_H
+
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
 
 #define MAXLINELEN     512
 
@@ -49,7 +56,7 @@ struct ldop {
 #define LDOP_SEARCH    0x01
     char       **ldop_suffixes;
     char       *ldop_dn;
-    union {
+    union ldapop_params_u {
                    struct ldsrchparms LDsrchparams;
          }     ldop_params;
 #define ldop_srch      ldop_params.LDsrchparams
@@ -69,9 +76,9 @@ struct ldentry {
 
 
 #ifdef LDAP_DEBUG
-void debug_printf();
+void   debug_printf(const char *, ...) LDAP_GCCATTR((format(printf, 1, 2)));
 #else /* LDAP_DEBUG */
-#define debug_printf()
+#define        debug_printf    (void) /* Ignore "arguments" */
 #endif /* LDAP_DEBUG */
 
 /*
@@ -88,9 +95,14 @@ void add_strval( char ***sp, char *val );
 char *ecalloc( unsigned nelem, unsigned elsize );
 void *erealloc( void *s, unsigned size );
 char *estrdup( char *s );
+extern void dump_ldop (struct ldop *op);
+
 
 /*
  * global variables
  */
 extern int     debugflg;
 extern char    *progname;
+
+LDAP_END_DECL
+#endif
index 4f544f4ca6162d4166a62c0ea6d1580300309893..7cec633145cf1b596dbef466c2eab059ff09f3ec 100644 (file)
@@ -1,4 +1,5 @@
 /* slap.h - stand alone ldap server include file */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -7,6 +8,8 @@
 #ifndef _SLDAPD_H_
 #define _SLDAPD_H_
 
+#include "ldap_defaults.h"
+
 #include <ac/stdlib.h>
 
 #include <sys/types.h>
@@ -96,6 +99,8 @@ LDAP_BEGIN_DECL
 #define SLAP_SCHERR_SYN_NOT_FOUND      11
 #define SLAP_SCHERR_MR_INCOMPLETE      12
 
+#define SLAPD_ACI_DEFAULT_ATTR         "aci"
+
 extern int slap_debug;
 
 struct slap_op;
@@ -271,6 +276,10 @@ typedef struct slap_access {
        char            *a_domain_pat;
        char            *a_sockurl_pat;
 
+#ifdef SLAPD_ACI_ENABLED
+       char            *a_aci_at;
+#endif
+
        /* ACL Groups */
        char            *a_group_pat;
        char            *a_group_oc;
@@ -497,7 +506,7 @@ struct slap_backend_info {
         */
        int (*bi_init)  LDAP_P((BackendInfo *bi));
        int     (*bi_config) LDAP_P((BackendInfo *bi,
-               char *fname, int lineno, int argc, char **argv ));
+               const char *fname, int lineno, int argc, char **argv ));
        int (*bi_open) LDAP_P((BackendInfo *bi));
        int (*bi_close) LDAP_P((BackendInfo *bi));
        int (*bi_destroy) LDAP_P((BackendInfo *bi));
@@ -525,7 +534,7 @@ struct slap_backend_info {
         */
        int (*bi_db_init) LDAP_P((Backend *bd));
        int     (*bi_db_config) LDAP_P((Backend *bd,
-               char *fname, int lineno, int argc, char **argv ));
+               const char *fname, int lineno, int argc, char **argv ));
        int (*bi_db_open) LDAP_P((Backend *bd));
        int (*bi_db_close) LDAP_P((Backend *bd));
        int (*bi_db_destroy) LDAP_P((Backend *db));
@@ -567,8 +576,8 @@ struct slap_backend_info {
        int     (*bi_entry_release_rw) LDAP_P((BackendDB *bd, Entry *e, int rw));
 
        int     (*bi_acl_group)  LDAP_P((Backend *bd,
-               Entry *e, char *bdn, char *edn,
-               char *objectclassValue, char *groupattrName ));
+               Entry *e, const char *bdn, const char *edn,
+               const char *objectclassValue, const char *groupattrName ));
 
        int     (*bi_connection_init) LDAP_P((BackendDB *bd,
                struct slap_conn *c));
index c3c8b136b0d79050ed64f1740278ad4c0b716adc..0191d2b65218ae30082d19b84f8c7dd6e86dee0c 100644 (file)
@@ -1,8 +1,10 @@
+# $OpenLDAP$
 attribute      photo                                   bin
 attribute      personalsignature                       bin
 attribute      jpegphoto                               bin
 attribute      audio                                   bin
 attribute      labeledurl                              ces
+attribute      ref                                             ces
 attribute      userpassword                            ces
 attribute      telephonenumber                         tel
 attribute      facsimiletelephonenumber        fax     tel
index c609a793d021dd9281d2c38dcd5e41946158a2b8..59be805b5b31d073ccf51b40dd8718e53769d216 100644 (file)
@@ -1,14 +1,29 @@
-include                %ETCDIR%/slapd.at.conf
-include                %ETCDIR%/slapd.oc.conf
+# $OpenLDAP$
+#
+# See slapd.conf(5) for details on configuration options.
+# This file should NOT be world readable.
+#
+include                %SYSCONFDIR%/slapd.at.conf
+include                %SYSCONFDIR%/slapd.oc.conf
 schemacheck    off
-referral       ldap://ldap.itd.umich.edu
+
+#referral      ldap://root.openldap.org
+
+pidfile                %LOCALSTATEDIR%/slapd.pid
+argsfile       %LOCALSTATEDIR%/slapd.args
 
 #######################################################################
 # ldbm database definitions
 #######################################################################
 
 database       ldbm
-suffix         "o=Your Organization Name, c=US"
+suffix         "dc=your-domain, dc=com"
+#suffix                "o=Your Organization Name, c=US"
 directory      /usr/tmp
-rootdn         "cn=root, o=Your Organization Name, c=US"
+rootdn         "cn=root, dc=your-domain, dc=com"
+#rootdn                "cn=root, o=Your Organization Name, c=US"
 rootpw         secret
+# cleartext passwords, especially for the rootdn, should
+# be avoid.  See slapd.conf(5) for details.
+
+
index 8a143c0316abb15d3e534546aca577c2e3d7bc6a..c74c1f834bea29ed9506c07600f61d4bb01348d8 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 objectclass top
        requires
                objectClass
index 3c1a3e78fe67a106853f2cd727f24e86a598a15e..cc98593519548c68ed085d21eaa82616b8157f37 100644 (file)
@@ -1,4 +1,5 @@
 /* str2filter.c - parse an rfc 1588 string filter */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -13,6 +14,7 @@
 #include <ac/socket.h>
 
 #include "slap.h"
+#include <ldap_pvt.h>
 
 static char    *find_matching_paren(char *s);
 static Filter  *str2list(char *str, long unsigned int ftype);
@@ -23,7 +25,7 @@ Filter *
 str2filter( char *str )
 {
        Filter  *f = NULL;
-       char    *end;
+       char    *end, *freeme;
 
        Debug( LDAP_DEBUG_FILTER, "str2filter \"%s\"\n", str, 0, 0 );
 
@@ -31,10 +33,13 @@ str2filter( char *str )
                return( NULL );
        }
 
+       str = freeme = ch_strdup( str );
+
        switch ( *str ) {
        case '(':
                if ( (end = find_matching_paren( str )) == NULL ) {
                        filter_free( f );
+                       free( freeme );
                        return( NULL );
                }
                *end = '\0';
@@ -83,6 +88,7 @@ str2filter( char *str )
                break;
        }
 
+       free( freeme );
        return( f );
 }
 
@@ -165,7 +171,7 @@ str2simple( char *str )
                *s = '\0';
                break;
        default:
-               if ( strchr( value, '*' ) == NULL ) {
+               if ( ldap_pvt_find_wildcard( value ) == NULL ) {
                        f->f_choice = LDAP_FILTER_EQUALITY;
                } else if ( strcmp( value, "*" ) == 0 ) {
                        f->f_choice = LDAP_FILTER_PRESENT;
@@ -188,6 +194,7 @@ str2simple( char *str )
        } else {
                f->f_avtype = ch_strdup( str );
                f->f_avvalue.bv_val = ch_strdup( value );
+               ldap_pvt_filter_value_unescape( f->f_avvalue.bv_val );
                f->f_avvalue.bv_len = strlen( value );
        }
 
@@ -199,30 +206,31 @@ str2simple( char *str )
 static int
 str2subvals( char *val, Filter *f )
 {
-       char    *nextstar;
+       char    *nextstar, *freeme;
        int     gotstar;
 
        Debug( LDAP_DEBUG_FILTER, "str2subvals \"%s\"\n", val, 0, 0 );
 
+       val = freeme = ch_strdup( val );
        gotstar = 0;
        while ( val != NULL && *val ) {
-               if ( (nextstar = strchr( val, '*' )) != NULL )
+               if ( (nextstar = ldap_pvt_find_wildcard( val )) != NULL )
                        *nextstar++ = '\0';
 
+               ldap_pvt_filter_value_unescape( val );
                if ( gotstar == 0 ) {
                        f->f_sub_initial = ch_strdup( val );
                } else if ( nextstar == NULL ) {
                        f->f_sub_final = ch_strdup( val );
                } else {
-                       charray_add( &f->f_sub_any, ch_strdup( val ) );
+                       charray_add( &f->f_sub_any, val );
                }
 
                gotstar = 1;
-               if ( nextstar != NULL )
-                       *(nextstar-1) = '*';
                val = nextstar;
        }
 
+       free( freeme );
        return( 0 );
 }
 
diff --git a/servers/slapd/suffixalias.c b/servers/slapd/suffixalias.c
new file mode 100644 (file)
index 0000000..2e4120e
--- /dev/null
@@ -0,0 +1,75 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1999 The OpenLDAP Foundation, All Rights Reserved.
+ *
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file in the top level
+ * directory of this package.
+ */
+/* Portions
+ * Copyright (c) 1998 Will Ballantyne, ITSD, Government of BC
+ * 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 ITSD, Government of BC. The name of ITSD
+ * 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.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/string.h>
+#include <ac/socket.h>
+#include "slap.h"
+
+/* 
+ * given a normalized uppercased dn (or root part),
+ * return an aliased dn if any of the alias suffixes match
+ */
+char *suffix_alias(
+       Backend *be,
+       char *dn )
+{
+       int     i, dnLength;
+
+       if(dn == NULL) return NULL;
+       if(be == NULL) return dn;
+
+       dnLength = strlen ( dn );
+
+       for ( i = 0;
+               be->be_suffixAlias != NULL && be->be_suffixAlias[i] != NULL;
+               i += 2 )
+       {
+               int aliasLength = strlen (be->be_suffixAlias[i]);
+               int diff = dnLength - aliasLength;
+
+               if ( diff < 0 ) {
+                       /* alias is longer than dn */
+                       continue;
+               } else if ( diff > 0 ) {
+                       if ( ! DNSEPARATOR(dn[diff-1]) ) {
+                               /* boundary is not at a DN separator */
+                               continue;
+                       }
+                       /* At a DN Separator */
+                       /* XXX or an escaped separator... oh well */
+               }
+
+               if (!strcmp(be->be_suffixAlias[i], &dn[diff])) {
+                       char *oldDN = dn;
+                       dn = ch_malloc( diff + strlen(be->be_suffixAlias[i+1]) + 1 );
+                       strncpy( dn, oldDN, diff );
+                       strcpy( &dn[diff], be->be_suffixAlias[i+1] );
+                       Debug( LDAP_DEBUG_ARGS,
+                               "suffix_alias: converted \"%s\" to \"%s\"\n",
+                               oldDN, dn, 0);
+                       free (oldDN);
+                       break;
+               }
+       }
+
+       return dn;
+}
index 89afb06d6a24c6daec88c2eb676c847d684e54b6..5e6c8719ffb00761c615076bf7bdd04c459baa82 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 #-----------------------------------------------------------------------------
 # Copyright (c) 1995 Regents of the University of Michigan.
 # All rights reserved.
index be3f03baabd4bf40443b91c1927f262ade1dfe55..732c8405dc034a6c6872b4f6cfba6c38ae6e8755 100644 (file)
@@ -1,4 +1,5 @@
 /* centipede.c - generate and install indexing information (view w/tabstop=4) */
+/* $OpenLDAP$ */
 
 #include "portable.h"
 
@@ -556,8 +557,10 @@ diff_centroids(
     int                nentries
 )
 {
+#ifdef LDBM_ORDERED
        Datum   okey, nkey;
        Datum   olast, nlast;
+#endif
        Datum   lastkey, key;
        Datum   data;
        LDAPMod **mods;
@@ -573,10 +576,6 @@ diff_centroids(
                fflush( stdout );
        }
 
-       ldbm_datum_init( okey );
-       ldbm_datum_init( nkey );
-       ldbm_datum_init( olast );
-       ldbm_datum_init( nlast );
        ldbm_datum_init( lastkey );
        ldbm_datum_init( key );
        ldbm_datum_init( data );
@@ -618,6 +617,11 @@ diff_centroids(
         * dual traversal, yielding O(N) performance.
         */
 
+       ldbm_datum_init( okey );
+       ldbm_datum_init( nkey );
+       ldbm_datum_init( olast );
+       ldbm_datum_init( nlast );
+
        olast.dptr = NULL;
        nlast.dptr = NULL;
 
index ec31ed457fdc521e6c656045e40d0a55d0143a04..2d77aa67d5b91b3f8171bb760e7ae1a2493573b6 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990, 1995 Regents of the University of Michigan.
  * All rights reserved.
index 8fe0ac64c96654d3550ac48c4d0fbe15ea057b0e..0ef3fb8edcab60c4532487aea4a42ab9577b33da 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1995 Regents of the University of Michigan.
  * All rights reserved.
index 5de70187f29f8fcff786aeae44dd47e7864c25da..04bba0fd16bafe231152dbf311c0f4b40a090eef 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1995 Regents of the University of Michigan.
  * All rights reserved.
index ddcf1f2b3e837c1a6591cdb117bafceeb7a2026d..f42934039cd9c31d91e6db6d2522b7844f1b3827 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1995 Regents of the University of Michigan.
  * All rights reserved.
  * is provided ``as is'' without express or implied warranty.
  */
 
+#ifndef LDAPSYNTAX_H
+#define LDAPSYNTAX_H 1
+
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
 
 /* XXX: the "master" LINE_WIDTH #define is in ../slap.h */
 #define LINE_WIDTH     76      /* for lines in string rep of an entry */
 
-#ifdef NEEDPROTOS
 /*
  * function prototypes
  */
 
-int init_syntaxes( void );
-int av2ldif( FILE *outfp, AV_Sequence av, DN dn, short syntax,
-    char *attrname, PS str_ps );
+int init_syntaxes LDAP_P(( void ));
+int av2ldif LDAP_P(( FILE *outfp, AV_Sequence av, DN dn, short syntax,
+    char *attrname, PS str_ps ));
 
-#endif /* NEEDPROTOS */
+LDAP_END_DECL
+#endif
index ad666a9ddb8b6299c9dca208e1a0949d4cf7aa1d..1897c0245b83721dc97f7148e26e8ccee9de4cae 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -31,7 +32,6 @@
 #include <io.h>
 #endif
 
-#include "ldap_defaults.h"
 #include "../slap.h"
 #include "../back-ldbm/back-ldbm.h"
 
index 17c6187c28e999405802e374bf805020e6b5c733..4618fc62aadd75e520bb014d28e6dfdbe84141f3 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -40,10 +41,9 @@ main( int argc, char **argv )
        if ( argc == 3 ) {
                if ( strcmp( argv[1], "-b" ) != 0 ) {
                        usage( argv[0] );
-               } else {
-                       binary = 1;
-                       type = argv[2];
                }
+               binary = 1;
+               type = argv[2];
        } else {
                if ( strcmp( argv[1], "-b" ) == 0 ) {
                        usage( argv[0] );
index aa7d1dc41bc9a989332025a797330936c583510e..5aafbdbdae83822c5e9970d77ee35947318fe02c 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -32,7 +33,7 @@ send_ldap_disconnect(
     Connection *conn,
     Operation  *op,
     ber_int_t  err,
-    char       *text
+    const char *text
 )
 {
        assert(0);
@@ -43,8 +44,8 @@ send_ldap_result(
        Connection  *conn, 
        Operation   *op,
        int     err,
-       char    *matched,
-       char    *text,
+       const char    *matched,
+       const char    *text,
        struct berval **refs,
        LDAPControl **ctrls
 )        
@@ -57,8 +58,8 @@ send_search_result(
        Connection  *conn, 
        Operation   *op,
        int     err,
-       char    *matched,
-       char    *text,
+       const char    *matched,
+       const char    *text,
        struct berval **refs,
        LDAPControl **ctrls,
        int             nentries
index 52f19d20eb91201ae1cdf1daddab1697c65a7f35..8eca6bf1a639f74e537c6e45e24fb1d9c021b1ff 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 #include "portable.h"
 
 #include <stdio.h>
@@ -89,12 +90,8 @@ main( int argc, char **argv )
                        scount = 0; ssize = 0;
                        if ( (bvals = ldap_get_values_len( ld, e, attrs[i] )) != NULL ) {
                                for ( j = 0; bvals[j] != NULL; j++ ) {
-                                       Datum   key, data;
                                        char    *w;
 
-                                       ldbm_datum_init( key );
-                                       ldbm_datum_init( data );
-
                                        /* update value count */
                                        vcount++;
                                        vsize += bvals[j]->bv_len;
index 147d06def1f79ee4bb1bb3457db4c22bbc2cd639..606a2f4aac5ee14c30ffac931c26cf05a568e643 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -36,6 +37,7 @@ main( int argc, char **argv )
 
        buf = NULL;
        lmax = 0;
+       lineno = 0;
 
        if( be->be_entry_open( be, 1 ) != 0 ) {
                fprintf( stderr, "%s: could not open database.\n",
@@ -68,7 +70,7 @@ main( int argc, char **argv )
 
                        /* check schema */
                        if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
-                               fprintf( stderr, "%s: entry dn=\"%s\" violates schema violation (line=%d)\n",
+                               fprintf( stderr, "%s: schema violation in entry dn=\"%s\" (line=%d)\n",
                                        progname, e->e_dn, lineno );
                                rc = EXIT_FAILURE;
                                entry_free( e );
index 80e698cba317089dbaa8bfd293b062c68148e6f3..f2103878167937bed894a7d11c7e95dadb3ce025 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 19fca636040e9834cc8a7f975120a811de2762e8..8b41f223233c4f3bd28490914dac2b177892427b 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index ffa400786121ea67f92698b0b93933a4309678db..d965bf754c3069c413f3aaffcdf53af78a07493f 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -8,7 +9,6 @@
 #define SLAPCOMMON_H_ 1
 
 #define SLAPD_TOOLS 1
-#include "ldap_defaults.h"
 #include "../slap.h"
 
 enum slaptool {
index 77abcd9798a763700db69e061ceb031041d0a2cf..ba63e7079950a4be29311b1b06d449d42d7f8499 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -55,7 +56,6 @@ main( int argc, char **argv )
                id != NOID;
                id = be->be_entry_next( be ) )
        {
-               Attribute *attr;
                struct berval **values;
                Entry* e = be->be_entry_get( be, id );
                struct berval bv;
@@ -75,7 +75,15 @@ main( int argc, char **argv )
                }
 
                if( strcasecmp( type, "dn" ) == 0 ) {
-                       attr = attr_find( e->e_attrs, type );
+                       bv.bv_val = e->e_ndn;
+                       bv.bv_len = strlen( bv.bv_val );
+                       bvals[0] = &bv;
+                       bvals[1] = NULL;
+
+                       values = bvals;
+
+               } else {
+                       Attribute *attr = attr_find( e->e_attrs, type );
 
                        if( attr == NULL ) {
                                entry_free( e );
@@ -83,18 +91,10 @@ main( int argc, char **argv )
                        }
 
                        values = attr->a_vals;
-
-               } else {
-                       bv.bv_val = e->e_ndn;
-                       bv.bv_len = strlen( bv.bv_val );
-                       bvals[0] = &bv;
-                       bvals[1] = NULL;
-
-                       values = bvals;
                }
 
                if ( be->be_index_change( be,
-                       type, attr->a_vals, id, SLAP_INDEX_ADD_OP ) )
+                       type, values, id, SLAP_INDEX_ADD_OP ) )
                {
                        rc = EXIT_FAILURE;
 
index 2e3437429bcc6419443cc4938eefcd92087f2436..14619b8f740b669a547cbbf38f0cd650b558c00c 100644 (file)
@@ -1,4 +1,5 @@
 /* unbind.c - decode an ldap unbind operation and pass it to a backend db */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
index 2613fbcfa42c8095cf77714973a2a3acd4d888d6..a309e0e80b89f585f60d23507f72cf066bd70a0b 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -120,13 +121,13 @@ slap_init_user( char *user, char *group )
     if ( got_gid ) {
        if ( setgid( gid ) != 0 ) {
            Debug( LDAP_DEBUG_ANY, "Could not set real group id to %d\n",
-                  gid, 0, 0 );
+                      (int) gid, 0, 0 );
            exit( EXIT_FAILURE );
        }
 #ifdef HAVE_SETEGID
        if ( setegid( gid ) != 0 ) {
            Debug( LDAP_DEBUG_ANY, "Could not set effective group id to %d\n",
-                  gid, 0, 0 );
+                      (int) gid, 0, 0 );
            exit( EXIT_FAILURE );
        }
 #endif
@@ -135,13 +136,13 @@ slap_init_user( char *user, char *group )
     if ( got_uid ) {
        if ( setuid( uid ) != 0 ) {
            Debug( LDAP_DEBUG_ANY, "Could not set real user id to %d\n",
-                  uid, 0, 0 );
+                      (int) uid, 0, 0 );
            exit( EXIT_FAILURE );
        }
 #ifdef HAVE_SETEUID
        if ( seteuid( uid ) != 0 ) {
            Debug( LDAP_DEBUG_ANY, "Could not set effective user id to %d\n",
-                  uid, 0, 0 );
+                      (int) uid, 0, 0 );
            exit( EXIT_FAILURE );
        }
 #endif
index c5564935984c3f9804b92bb37bf6964a09ee6600..1405fd176e60d215bd548e13ca0b1e3a703d5b6e 100644 (file)
@@ -1,4 +1,5 @@
 /* value.c - routines for dealing with values */
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -41,6 +42,7 @@ value_add_fast(
        for ( i = 0, j = 0; i < naddvals; i++, j++ ) {
                if ( addvals[i]->bv_len > 0 ) {
                        (*vals)[nvals + j] = ber_bvdup( addvals[i] );
+                       if( (*vals)[nvals + j] == NULL ) break;
                }
        }
        (*vals)[nvals + j] = NULL;
@@ -72,7 +74,8 @@ value_add(
 
        for ( i = 0, j = 0; i < nn; i++ ) {
                if ( addvals[i]->bv_len > 0 ) {
-                       (*vals)[n + j++] = ber_bvdup( addvals[i] );
+                       (*vals)[n + j] = ber_bvdup( addvals[i] );
+                       if( (*vals)[n + j++] == NULL ) break;
                }
        }
        (*vals)[n + j] = NULL;
@@ -137,6 +140,7 @@ value_cmp(
                rc = strcmp( v1->bv_val, v2->bv_val );
                break;
 
+       default:        /* Unknown syntax */
        case SYNTAX_BIN:
                rc = (v1->bv_len == v2->bv_len
                      ? memcmp( v1->bv_val, v2->bv_val, v1->bv_len )
index f171c2a7b4f08b6c8bbaae84b81016cec59ca092..3b244dace5d5cea7afc430f8a18952442f0149f4 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ##
 ## Makefile.in for slurpd
 ##
index 6a58b40c4c34f044f7072fc9dea3faf174b47469..d3017932e12c19b190bba068ed031082b4ca3cc9 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  * reconfiguration of slurpd.
  */
 
+#include "portable.h"
 
 #include <stdio.h>
-#include <signal.h>
+
+#include <ac/signal.h>
 
 #include "slurp.h"
 #include "globals.h"
@@ -33,9 +36,9 @@
  * slurpd receives a USR2 signal, it will dump its replication 
  * queue to the disk file given by SLURPD_DUMPFILE.
  */
-void
-do_admin()
+RETSIGTYPE
+do_admin( int sig )
 {
     sglob->rq->rq_dump( sglob->rq );
-    (void) SIGNAL( SIGUSR2, (void *) do_admin );
+    (void) SIGNAL( sig, do_admin );
 }
index b3cc935df8ece477c1cfc25ea772f6124906ba1e..81b45df4eb68e2ae55afc5a711ec494d80a3e9f0 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  * args.c - process command-line arguments, and set appropriate globals.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
+
+#include <ac/stdlib.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
 
 #include <lber.h>
 #include <ldap.h>
 #include "globals.h"
 
 
-static int
+static void
 usage( char *name )
 {
     fprintf( stderr, "usage: %s\t[-d debug-level] [-s syslog-level]\n", name );
     fprintf( stderr, "\t\t[-f slapd-config-file] [-r replication-log-file]\n" );
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
     fprintf( stderr, "\t\t[-t tmp-dir] [-o] [-k srvtab-file]\n" );
-#else /* KERBEROS */
+#else /* HAVE_KERBEROS */
     fprintf( stderr, "\t\t[-t tmp-dir] [-o]\n" );
-#endif /* KERBEROS */
+#endif /* HAVE_KERBEROS */
 }
 
 
@@ -49,7 +56,6 @@ doargs(
 )
 {
     int                i;
-    extern char        *optarg;
     int                rflag = 0;
 
     if ( (g->myname = strrchr( argv[0], '/' )) == NULL ) {
@@ -60,9 +66,10 @@ doargs(
 
     while ( (i = getopt( argc, argv, "hd:f:r:t:k:o" )) != EOF ) {
        switch ( i ) {
-#ifdef LDAP_DEBUG
-       case 'd':       /* turn on debugging */
+       case 'd':       /* set debug level and 'do not detach' flag */
+           g->no_detach = 1;
            if ( optarg[0] == '?' ) {
+#ifdef LDAP_DEBUG
                printf( "Debug levels:\n" );
                printf( "\tLDAP_DEBUG_TRACE\t%d\n",
                        LDAP_DEBUG_TRACE );
@@ -82,16 +89,20 @@ doargs(
                        LDAP_DEBUG_ACL );
                printf( "\tLDAP_DEBUG_ANY\t\t%d\n",
                        LDAP_DEBUG_ANY );
+               puts( "\tThe -d flag also prevents slurpd from detaching." );
+#endif /* LDAP_DEBUG */
+               puts( "\tDebugging is disabled.  -d 0 prevents slurpd from detaching." );
                return( -1 );
-           } else {
-               ldap_debug = atoi( optarg );
            }
-           break;
-#else /* LDAP_DEBUG */
-       case 'd':       /* can't enable debugging - not built with debug code */
-           fprintf( stderr, "must compile with LDAP_DEBUG for debugging\n" );
-           break;
+#ifdef LDAP_DEBUG
+           ldap_debug |= atoi( optarg );
+#else /* !LDAP_DEBUG */
+           if ( atoi( optarg ) != 0 )
+               /* can't enable debugging - not built with debug code */
+               fputs( "must compile with LDAP_DEBUG for debugging\n",
+                      stderr );
 #endif /* LDAP_DEBUG */
+           break;
        case 'f':       /* slapd config file */
            g->slapd_configfile = strdup( optarg );
            break;
@@ -103,11 +114,11 @@ doargs(
            g->slurpd_rdir = strdup( optarg );
            break;
        case 'k':       /* name of kerberos srvtab file */
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
            g->default_srvtab = strdup( optarg );
-#else /* KERBEROS */
+#else /* HAVE_KERBEROS */
            fprintf( stderr, "must compile with KERBEROS to use -k option\n" );
-#endif /* KERBEROS */
+#endif /* HAVE_KERBEROS */
            break;
        case 'h':
            usage( g->myname );
@@ -135,6 +146,10 @@ doargs(
     sprintf( g->slurpd_status_file, "%s/%s", g->slurpd_rdir,
            DEFAULT_SLURPD_STATUS_FILE );
 
+       ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &ldap_debug);
+       ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &ldap_debug);
+       ldif_debug = ldap_debug;
+
 #ifdef LOG_LOCAL4
     openlog( g->myname, OPENLOG_OPTIONS, LOG_LOCAL4 );
 #else
index 41bad34005f06ce4d5ab05a8151373d690f85e66..1c6e29290b8f06b8aae8c3802b5c6a9e5e99ac2a 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
index 38802e4422f797b15b2ade857214ac453cc24b24..8a12eec1fac3b984f2f19b12e9ede0fa1884fd53 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
index 2d36838bb549dc4ed3086f44bcf955af03d370a6..75c1afed027b74da2036f8bc638b748c3adeab35 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  * fm.c - file management routines.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <signal.h>
+
+#include <ac/stdlib.h>
+#include <ac/string.h>
+#include <ac/signal.h>
 
 #include "slurp.h"
 #include "globals.h"
 
-extern void do_admin();
-
-static void set_shutdown();
-void do_nothing();
-
-/*
- * Externs
- */
-#ifdef NEEDPROTOS
-extern int file_nonempty( char * );
-extern int acquire_lock(char *, FILE **, FILE ** );
-extern int relinquish_lock(char *, FILE *, FILE * );
-#else /* NEEDPROTOS */
-extern int file_nonempty();
-extern int acquire_lock();
-extern int relinquish_lock();
-#endif /* NEEDPROTOS */
 
 /*
  * Forward references
  */
-#ifdef NEEDPROTOS
-static char *get_record( FILE * );
-static void populate_queue( char *f );
-static void set_shutdown();
-void do_nothing();
-#else /* NEEDPROTOS */
-static char *get_record();
-static void populate_queue();
-static void set_shutdown();
-void do_nothing();
-#endif /* NEEDPROTOS */
-
-#ifndef SYSERRLIST_IN_STDIO
-extern char *sys_errlist[];
-#endif /* SYSERRLIST_IN_STDIO */
-
+static char *get_record LDAP_P(( FILE * ));
+static void populate_queue LDAP_P(( char *f ));
+static RETSIGTYPE set_shutdown LDAP_P((int));
 
 
 /*
@@ -68,7 +43,7 @@ extern char *sys_errlist[];
  *  - adds items to the internal queue of replication work to do
  *  - signals the replication threads to let them know new work has arrived.
  */
-void
+void *
 fm(
     void *arg
 )
@@ -77,15 +52,16 @@ fm(
 
     /* Set up our signal handlers:
      * SIG{TERM,INT,HUP} causes a shutdown
-     * SIGUSR1 - does nothing, used to wake up sleeping threads.
-     * SIGUSR2 - causes slurpd to read its administrative interface file.
-     *           (not yet implemented).
+     * LDAP_SIGUSR1 - does nothing, used to wake up sleeping threads.
+        * LDAP_SIGUSR2 - causes a shutdown
      */
-    (void) SIGNAL( SIGUSR1, (void *) do_nothing );
-    (void) SIGNAL( SIGUSR2, (void *) do_admin );
-    (void) SIGNAL( SIGTERM, (void *) set_shutdown );
-    (void) SIGNAL( SIGINT, (void *) set_shutdown );
-    (void) SIGNAL( SIGHUP, (void *) set_shutdown );
+    (void) SIGNAL( LDAP_SIGUSR1, do_nothing );
+    (void) SIGNAL( LDAP_SIGUSR2, set_shutdown );
+    (void) SIGNAL( SIGTERM, set_shutdown );
+    (void) SIGNAL( SIGINT, set_shutdown );
+#ifdef SIGHUP
+    (void) SIGNAL( SIGHUP, set_shutdown );
+#endif
 
     if ( sglob->one_shot_mode ) {
        if ( file_nonempty( sglob->slapd_replogfile )) {
@@ -96,7 +72,7 @@ fm(
                sglob->rq->rq_getcount( sglob->rq, RQ_COUNT_ALL ));
        printf( "%d replication records to process.\n",
                sglob->rq->rq_getcount( sglob->rq, RQ_COUNT_NZRC ));
-       return;
+       return NULL;
     }
     /*
      * There may be some leftover replication records in our own
@@ -125,7 +101,7 @@ fm(
                }
            }
        } else {
-           tsleep( sglob->no_work_interval );
+           ldap_pvt_thread_sleep( sglob->no_work_interval );
        }
 
        /* Garbage-collect queue */
@@ -146,6 +122,7 @@ fm(
        }
     }
     Debug( LDAP_DEBUG_ARGS, "fm: exiting\n", 0, 0, 0 );
+    return NULL;
 }
 
 
@@ -154,22 +131,20 @@ fm(
 /*
  * Set a global flag which signals that we're shutting down.
  */
-static void
-set_shutdown()
+static RETSIGTYPE
+set_shutdown(int sig)
 {
     int        i;
 
     sglob->slurpd_shutdown = 1;                                /* set flag */
-    pthread_kill( sglob->fm_tid, SIGUSR1 );            /* wake up file mgr */
+    ldap_pvt_thread_kill( sglob->fm_tid, LDAP_SIGUSR1 );       /* wake up file mgr */
     sglob->rq->rq_lock( sglob->rq );                   /* lock queue */
-    pthread_cond_broadcast( &(sglob->rq->rq_more) );   /* wake repl threads */
+    ldap_pvt_thread_cond_broadcast( &(sglob->rq->rq_more) );   /* wake repl threads */
     for ( i = 0; i < sglob->num_replicas; i++ ) {
        (sglob->replicas[ i ])->ri_wake( sglob->replicas[ i ]);
     }
     sglob->rq->rq_unlock( sglob->rq );                 /* unlock queue */
-    (void) SIGNAL( SIGTERM, (void *) set_shutdown );   /* reinstall handlers */
-    (void) SIGNAL( SIGINT, (void *) set_shutdown );
-    (void) SIGNAL( SIGHUP, (void *) set_shutdown );
+    (void) SIGNAL( sig, set_shutdown );        /* reinstall handlers */
 }
 
 
@@ -178,10 +153,10 @@ set_shutdown()
 /*
  * A do-nothing signal handler.
  */
-void
-do_nothing()
+RETSIGTYPE
+do_nothing(int sig)
 {
-    (void) SIGNAL( SIGUSR1, (void *) do_nothing );
+    (void) SIGNAL( sig, do_nothing );
 }
 
 
@@ -197,7 +172,6 @@ populate_queue(
 )
 {
     FILE       *fp, *lfp;
-    Rq         *rq = sglob->rq;
     char       *p;
 
     if ( acquire_lock( f, &fp, &lfp ) < 0 ) {
@@ -215,8 +189,7 @@ populate_queue(
        Debug( LDAP_DEBUG_ANY,
                "error: can't seek to offset %ld in file \"%s\"\n",
                sglob->srpos, f, 0 );
-       return;
-    }
+    } else {
     while (( p = get_record( fp )) != NULL ) {
        if ( sglob->rq->rq_add( sglob->rq, p ) < 0 ) {
            char *t;
@@ -229,9 +202,10 @@ populate_queue(
                    p, 0, 0 );
        }
        free( p );
-       pthread_yield();
+       ldap_pvt_thread_yield();
     }
     sglob->srpos = ftell( fp );
+    }
     (void) relinquish_lock( f, fp, lfp );
 }
     
@@ -256,13 +230,13 @@ get_record(
 
     while (( fgets( line, sizeof(line), fp ) != NULL ) &&
            (( len = strlen( line )) > 1 )) {
-       while ( lcur + len + 1 > lmax ) {
-           lmax += BUFSIZ;
-           buf = (char *) ch_realloc( buf, lmax );
-       }
-       strcpy( buf + lcur, line );
-       lcur += len;
+
+               while ( lcur + len + 1 > lmax ) {
+                   lmax += BUFSIZ;
+                   buf = (char *) ch_realloc( buf, lmax );
+               }
+               strcpy( buf + lcur, line );
+               lcur += len;
     }
     return( buf );
 }
-
index 1871085b668f53db4bd085bd51334e3b97c3fe20..18f5a12fdb68d35d3245966a082650b25d36b363 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
@@ -55,6 +56,7 @@ init_globals( void )
     g->slurpd_replogfile[ 0 ] = '\0';
     g->slurpd_status_file[ 0 ] = '\0';
     g->one_shot_mode = 0;
+    g->no_detach = 0;
     g->myname = NULL;
     g->srpos = 0L;
     if ( St_init( &(g->st)) < 0 ) {
index 5d976ff8a4dbb3925eccb64e4a79fa654e91c873..645cf0593ab0887b16ebfbdc252b65aab66d4eda 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
@@ -10,6 +11,8 @@
  * is provided ``as is'' without express or implied warranty.
  */
 
+#ifndef SLURPD_GLOBALS_H
+#define SLURPD_GLOBALS_H 1
 
 /*
  * globals.h - definition of structure holding global data.
 
 #include "slurp.h"
 
+LDAP_BEGIN_DECL
+
 typedef struct globals {
     /* Thread ID for file manager thread */
-    pthread_t fm_tid;
+    ldap_pvt_thread_t fm_tid;
     /* The name of the slapd config file (which is also our config file) */
     char *slapd_configfile;
     /* How long the master slurpd sleeps when there's no work to do */
     int        no_work_interval;
     /* We keep running until slurpd_shutdown is nonzero.  HUP signal set this */
-    int        slurpd_shutdown;
+    sig_atomic_t slurpd_shutdown;
     /* Number of replicas we're servicing */
     int num_replicas;
     /* Array of pointers to replica info */
@@ -40,25 +45,27 @@ typedef struct globals {
     char slurpd_replogfile[ MAXPATHLEN ];
     /* Non-zero if we were given a replog file to process on command-line */
     int        one_shot_mode;
+    /* Non-zero if we should not detach the process */
+    int no_detach;
     /* Name of program */
     char *myname;
     /* Current offset into slurpd replica logfile */
     off_t srpos;
     /* mutex to serialize access to reject file */
-    pthread_mutex_t rej_mutex;
+    ldap_pvt_thread_mutex_t rej_mutex;
     /* pointer to status struct */
     St *st;
     /* Pointer to replication queue */
     Rq *rq;
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
     /* Default name of kerberos srvtab file */
     char *default_srvtab;
-#endif /* KERBEROS */
-#if defined( THREAD_SUNOS4_LWP )
-    tl_t *tsl_list;
-    mon_t tsl_mon;
-#endif /* THREAD_SUNOS4_LWP */
+#endif /* HAVE_KERBEROS */
 } Globals;
 
 
 extern Globals *sglob;
+
+LDAP_END_DECL
+
+#endif /* SLURPD_GLOBALS_H */
index e8663c26f60716aed8f6b3b86366d1853b4a471b..a6873045dabfefbaa19cec6371fd9d19392c86bb 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
@@ -50,7 +51,9 @@ static void free_ldmarr LDAP_P(( LDAPMod ** ));
 static int getmodtype LDAP_P(( char * ));
 static void dump_ldm_array LDAP_P(( LDAPMod ** ));
 static char **read_krbnames LDAP_P(( Ri * ));
+#ifdef HAVE_KERBEROS
 static void upcase LDAP_P(( char * ));
+#endif
 static int do_bind LDAP_P(( Ri *, int * ));
 static int do_unbind LDAP_P(( Ri * ));
 
@@ -885,6 +888,7 @@ read_krbnames(
 }
 
 
+#ifdef HAVE_KERBEROS
 
 /*
  * upcase a string
@@ -900,3 +904,5 @@ upcase(
            *p = TOUPPER( (unsigned char) *p );
     }
 }
+
+#endif /* HAVE_KERBEROS */
index 62aab06784b37f5acd99621aa00da0c789b69a70..eb957c288b557d7975b4e6fd61e02e8358f84733 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  * lock.c - routines to open and apply an advisory lock to a file
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <sys/time.h>
-#include <sys/types.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
-#include <sys/socket.h>
-#include "portable.h"
-#ifdef USE_LOCKF
-#include <unistd.h>
 #endif
-#include "../slapd/slap.h"
 
+#include "slurp.h"
 
 
 FILE *
 lock_fopen(
-    char       *fname,
-    char       *type,
+    const char *fname,
+    const char *type,
     FILE       **lfp
 )
 {
@@ -48,23 +54,15 @@ lock_fopen(
        }
 
        /* acquire the lock */
-#ifdef USE_LOCKF
-       while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 ) {
-#else
-       while ( flock( fileno( *lfp ), LOCK_EX ) != 0 ) {
-#endif
-               ;       /* NULL */
-       }
+       ldap_lockf( fileno(*lfp) );
 
        /* open the log file */
        if ( (fp = fopen( fname, type )) == NULL ) {
                Debug( LDAP_DEBUG_ANY,
                        "Error: could not open \"%s\"\n", fname, 0, 0 );
-#ifdef USE_LOCKF
-               lockf( fileno( *lfp ), F_ULOCK, 0 );
-#else
-               flock( fileno( *lfp ), LOCK_UN );
-#endif
+               ldap_unlockf( fileno(*lfp) );
+               fclose( *lfp );
+               *lfp = NULL;
                return( NULL );
        }
 
@@ -80,11 +78,7 @@ lock_fclose(
 )
 {
        /* unlock */
-#ifdef USE_LOCKF
-       lockf( fileno( lfp ), F_ULOCK, 0 );
-#else
-       flock( fileno( lfp ), LOCK_UN );
-#endif
+       ldap_unlockf( fileno(lfp) );
        fclose( lfp );
 
        return( fclose( fp ) );
@@ -97,15 +91,15 @@ lock_fclose(
  */
 int
 acquire_lock(
-    char       *file,
+    const char *file,
     FILE       **rfp,
     FILE       **lfp
 )
 {
     if (( *rfp = lock_fopen( file, "r+", lfp )) == NULL ) {
        Debug( LDAP_DEBUG_ANY,
-               "Error: acquire_lock(%d): Could not acquire lock on \"%s\"\n",
-               getpid(), file, 0);
+               "Error: acquire_lock(%ld): Could not acquire lock on \"%s\"\n",
+               (long) getpid(), file, 0);
        return( -1 );
     }
     return( 0 );
@@ -119,15 +113,15 @@ acquire_lock(
  */
 int
 relinquish_lock(
-    char       *file,
+    const char *file,
     FILE       *rfp,
     FILE       *lfp
 )
 {
     if ( lock_fclose( rfp, lfp ) == EOF ) {
        Debug( LDAP_DEBUG_ANY,
-               "Error: relinquish_lock (%d): Error closing \"%s\"\n",
-               getpid(), file, 0 );
+               "Error: relinquish_lock (%ld): Error closing \"%s\"\n",
+               (long) getpid(), file, 0 );
        return( -1 );
     }
     return( 0 );
index c2a71484faf40b8c50498d846e7178ad74047e62..2aa86e75c9bb3789fd0c5d5a7198c741bfd46399 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
@@ -87,14 +88,10 @@ main(
     }
 
     /*
-     * Detach from the controlling terminal, if debug level = 0,
-     * and if not in one-shot mode.
+     * Detach from the controlling terminal
+     * unless the -d flag is given or in one-shot mode.
      */
-#ifdef LDAP_DEBUG
-    if (( ldap_debug == 0 )  && !sglob->one_shot_mode )
-#else /* LDAP_DEBUG */
-    if ( !sglob->one_shot_mode )
-#endif /* LDAP_DEBUG */
+    if ( ! (sglob->no_detach || sglob->one_shot_mode) )
        lutil_detach( 0, 0 );
 
     /*
index 2d314cdd3a0588c87eece32bfdddf74198d219c2..2d4adca3069f866a0e5124f46c8a4c9ff44591bc 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 #ifndef _PROTO_SLURP
 #define _PROTO_SLURP
 
@@ -45,10 +46,10 @@ extern struct globals *init_globals LDAP_P((void));
 int do_ldap    LDAP_P((Ri *ri, Re *re, char **errmsg));
 
 /* lock.c */
-FILE *lock_fopen       LDAP_P((char *fname, char *type, FILE **lfp));
+FILE *lock_fopen       LDAP_P((const char *fname, const char *type, FILE **lfp));
 int lock_fclose        LDAP_P((FILE *fp, FILE *lfp));
-int acquire_lock       LDAP_P((char *file, FILE **rfp, FILE **lfp));
-int relinquish_lock    LDAP_P((char *file, FILE *rfp, FILE *lfp));
+int acquire_lock       LDAP_P((const char *file, FILE **rfp, FILE **lfp));
+int relinquish_lock    LDAP_P((const char *file, FILE *rfp, FILE *lfp));
 
 /* reject.c */
 void write_reject      LDAP_P((Ri *ri, Re *re, int lderr, char *errmsg));
index fa171ca1593ac2fa325cf893cf13a8a2714f3883..df1780c49e060c902ff1d806ce7a1509af56f481 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
@@ -192,9 +193,15 @@ Re_parse(
                Debug( LDAP_DEBUG_ANY,
                        "Error: Re_parse: bad type <%s>\n",
                        type, 0, 0 );
+               free( type );
+               if ( value != NULL )
+                       free( value );
                return -1;
            }
        }
+       free( type );
+       if ( value != NULL )
+               free( value );
     }
 
     if ( state != GOT_ALL ) {
@@ -205,12 +212,14 @@ Re_parse(
     }
 
     for (;;) {
+       char *const dash = "-";
+
        if (( buf = ldif_getline( &rp )) == NULL ) {
            break;
        }
        buflen = strlen( buf );
        if (( buflen == 1 ) && ( buf[ 0 ] == '-' )) {
-           type = "-";
+           type  = dash;
            value = NULL;
        } else {
            if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) {
@@ -235,6 +244,11 @@ Re_parse(
        re->re_mods[ nml + 1 ].mi_type = NULL;
        re->re_mods[ nml + 1 ].mi_val = NULL;
        nml++;
+
+       if ( type != dash )
+               free( type );
+       if ( value != NULL )
+               free( value );
     }
     return 0;
 }
@@ -256,7 +270,6 @@ get_repl_hosts(
     char       **r_rp
 )
 {
-    char               buf[ LDIF_LINE_WIDTH + 1 ];
     char               *type, *value, *line, *p;
     Rh                 *rh = NULL;
     int                        nreplicas;
@@ -314,8 +327,11 @@ get_repl_hosts(
                break;
            }
        }
+       free( type );
        if ( !repl_ok ) {
            warn_unknown_replica( value, port );
+           if ( value != NULL )
+               free( value );
            continue;
        }
 
@@ -328,6 +344,9 @@ get_repl_hosts(
        rh[ nreplicas ].rh_hostname = strdup( value );
        rh[ nreplicas ].rh_port = port;
        nreplicas++;
+
+       if ( value != NULL )
+               free( value );
     }
 
     if ( nreplicas == 0 ) {
index 8ae0dc63635728ca298566a8cced943f1ff4d134..e5ce9a76b66f2d3954e816c74a2ea333afc6eab7 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  * to a replica LDAP server.
  */
 
+#include "portable.h"
 
 #include <stdio.h>
-#include <sys/types.h>
+
+#include <ac/errno.h>
+#include <ac/unistd.h>
+
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <unistd.h>
 
 #include "slurp.h"
 #include "globals.h"
 
-#ifndef SYSERRLIST_IN_STDIO
-extern char *sys_errlist[];
-#endif /* SYSERRLIST_IN_STDIO */
-
-
 /*
  * Write a replication record to a reject file.  The reject file has the
  * same name as the replica's private copy of the file but with ".rej"
@@ -52,7 +51,7 @@ write_reject(
     FILE       *rfp, *lfp;
     int                rc;
 
-    pthread_mutex_lock( &sglob->rej_mutex );
+    ldap_pvt_thread_mutex_lock( &sglob->rej_mutex );
     sprintf( rejfile, "%s/%s:%d.rej", sglob->slurpd_rdir,
            ri->ri_hostname, ri->ri_port );
 
@@ -64,7 +63,7 @@ write_reject(
            Debug( LDAP_DEBUG_ANY,
                "Error: write_reject: Cannot create \"%s\": %s\n",
                rejfile, sys_errlist[ errno ], 0 );
-           pthread_mutex_unlock( &sglob->rej_mutex );
+           ldap_pvt_thread_mutex_unlock( &sglob->rej_mutex );
            return;
        } else {
            close( rjfd );
@@ -90,7 +89,7 @@ write_reject(
                "Error: ldap operation failed, data written to \"%s\"\n",
                rejfile, 0, 0 );
     }
-    pthread_mutex_unlock( &sglob->rej_mutex );
+    ldap_pvt_thread_mutex_unlock( &sglob->rej_mutex );
     return;
 }
 
index ed25a629077031feed19d6dee387adaea5b66f1b..50aca4e77ef72525b543b732f56e4f96f3dda049 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
@@ -15,6 +16,7 @@
  * replica.c - code to start up replica threads.
  */
 
+#include "portable.h"
 
 #include <stdio.h>
 
  * Just invoke the Ri's process() member function, and log the start and
  * finish.
  */
-void
+static void *
 replicate(
-    Ri *ri
+    void       *ri_arg
 )
 {
-    int i;
-    unsigned long seq;
+    Ri         *ri = (Ri *) ri_arg;
 
     Debug( LDAP_DEBUG_ARGS, "begin replication thread for %s:%d\n",
-           ri->ri_hostname, ri->ri_port, 0 );
+           ((Ri *)ri)->ri_hostname, ((Ri *)ri)->ri_port, 0 );
 
     ri->ri_process( ri );
 
     Debug( LDAP_DEBUG_ARGS, "end replication thread for %s:%d\n",
            ri->ri_hostname, ri->ri_port, 0 );
-    return;
+    return NULL;
 }
 
 
@@ -54,18 +55,13 @@ start_replica_thread(
     Ri *ri
 )
 {
-    pthread_attr_t     attr;
-
-    pthread_attr_init( &attr );
-    pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
-
-    if ( pthread_create( &(ri->ri_tid), attr, (void *) replicate,
+    /* POSIX_THREADS or compatible */
+    if ( ldap_pvt_thread_create( &(ri->ri_tid), 0, replicate,
            (void *) ri ) != 0 ) {
-       Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n",
+       Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" ldap_pvt_thread_create failed\n",
                ri->ri_hostname, ri->ri_port, 0 );
-       pthread_attr_destroy( &attr );
        return -1;
     }
-    pthread_attr_destroy( &attr );
+
     return 0;
 }
index c3a855cffecbc626a00d2c67b443c74213c40e73..f4c738061a339f47656ff3a62f3a3b18888b8ff1 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  * replog.c - routines which read and write replication log files.
  */
 
-
-#include <errno.h>
-#include <stdio.h>
-#include <syslog.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-
 #include "portable.h"
-#include "slurp.h"
-#include "globals.h"
 
-/*
- * Externs
- */
-#ifdef NEEDPROTOS
-extern FILE *lock_fopen( char *, char *, FILE ** );
-extern char *ch_malloc( unsigned long );
-#else /* NEEDPROTOS */
-extern FILE *lock_fopen();
-extern char *ch_malloc();
-#endif /* NEEDPROTOS */
+#include <stdio.h>
 
-/*
- * Forward declarations
- */
-#ifdef NEEDPROTOS
-int file_nonempty( char * );
-#else /* NEEDPROTOS */
-int file_nonempty();
-#endif /* NEEDPROTOS */
+#include <ac/errno.h>
+#include <ac/string.h>
+#include <ac/syslog.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
 
+#include <sys/stat.h>
 
-#ifndef SYSERRLIST_IN_STDIO
-extern char *sys_errlist[];
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
 #endif
 
-/*
- * Forward declarations
- */
-static int duplicate_replog( char *, char * );
-
-
+#include <fcntl.h>
 
+#include "slurp.h"
+#include "globals.h"
 
 /*
  * Copy the replication log.  Returns 0 on success, 1 if a temporary
@@ -99,8 +72,8 @@ copy_replog(
     }
     if ( access( buf, W_OK ) < 0 ) {
        Debug( LDAP_DEBUG_ANY,
-               "Error: copy_replog (%d): Directory %s is not writable\n",
-               getpid(), buf, 0 );
+               "Error: copy_replog (%ld): Directory %s is not writable\n",
+               (long) getpid(), buf, 0 );
        return( -1 );
     }
     strcpy( buf, dst );
@@ -111,8 +84,8 @@ copy_replog(
     }
     if ( access( buf, W_OK ) < 0 ) {
        Debug( LDAP_DEBUG_ANY,
-               "Error: copy_replog (%d): Directory %s is not writable\n",
-               getpid(), buf, 0 );
+               "Error: copy_replog (%ld): Directory %s is not writable\n",
+               (long) getpid(), buf, 0 );
        return( -1 );
     }
 
@@ -131,7 +104,7 @@ copy_replog(
        Debug( LDAP_DEBUG_ANY,
                "Error: copy_replog: Can't lock replog \"%s\" for write: %s\n",
                src, sys_errlist[ errno ], 0 );
-       lock_fclose( rfp );
+       lock_fclose( rfp, lfp );
        return( 1 );
     }
 
@@ -147,12 +120,12 @@ copy_replog(
        truncate( src, (off_t) 0 );
     }
 
-    if ( lock_fclose( rfp, lfp ) == EOF ) {
+    if ( lock_fclose( dfp, dlfp ) == EOF ) {
        Debug( LDAP_DEBUG_ANY,
                "Error: copy_replog: Error closing \"%s\"\n",
                src, 0, 0 );
     }
-    if ( lock_fclose( dfp, dlfp ) == EOF ) {
+    if ( lock_fclose( rfp, lfp ) == EOF ) {
        Debug( LDAP_DEBUG_ANY,
                "Error: copy_replog: Error closing \"%s\"\n",
                src, 0, 0 );
index cc478d1e6a77386007feb94078d5b432e56bfd87..5335943ff534d4bdccc0606f06de851b2d17a88e 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  */
 
 
+#include "portable.h"
 
 #include <stdio.h>
-#include <signal.h>
+
+#include <ac/stdlib.h>
+#include <ac/string.h>
+#include <ac/signal.h>
 
 #include "slurp.h"
 #include "globals.h"
 
 
-/* External references */
-#ifdef NEEDPROTOS
-extern void write_reject( Ri *, Re *, int, char * );
-extern void do_nothing();
-#else /* NEEDPROTOS */
-extern void write_reject();
-extern void do_nothing();
-#endif /* NEEDPROTOS */
-
 /* Forward references */
-#ifdef NEEDPROTOS
-static int ismine( Ri  *, Re  * );
-static int isnew( Ri  *, Re  * );
-void tsleep( time_t );
-#else /* NEEDPROTOS */
-static int ismine();
-static int isnew();
-void tsleep();
-#endif /* NEEDPROTOS */
+static int ismine LDAP_P(( Ri  *, Re  * ));
+static int isnew LDAP_P(( Ri  *, Re  * ));
 
 
 /*
@@ -56,11 +45,10 @@ Ri_process(
 {
     Rq         *rq = sglob->rq;
     Re         *re, *new_re;
-    int                i;
     int                rc ;
     char       *errmsg;
 
-    (void) SIGNAL( SIGUSR1, (void *) do_nothing );
+    (void) SIGNAL( LDAP_SIGUSR1, do_nothing );
     (void) SIGNAL( SIGPIPE, SIG_IGN );
     if ( ri == NULL ) {
        Debug( LDAP_DEBUG_ANY, "Error: Ri_process: ri == NULL!\n", 0, 0, 0 );
@@ -75,7 +63,7 @@ Ri_process(
     while ( !sglob->slurpd_shutdown &&
            (( re = rq->rq_gethead( rq )) == NULL )) {
        /* No work - wait on condition variable */
-       pthread_cond_wait( &rq->rq_more, &rq->rq_mutex );
+       ldap_pvt_thread_cond_wait( &rq->rq_more, &rq->rq_mutex );
     }
 
     /*
@@ -99,20 +87,22 @@ Ri_process(
                rc = do_ldap( ri, re, &errmsg );
                switch ( rc ) {
                case DO_LDAP_ERR_RETRYABLE:
-                   tsleep( RETRY_SLEEP_TIME );
+                   ldap_pvt_thread_sleep( RETRY_SLEEP_TIME );
                    Debug( LDAP_DEBUG_ANY,
                            "Retrying operation for DN %s on replica %s:%d\n",
                            re->re_dn, ri->ri_hostname, ri->ri_port );
                    continue;
                    break;
-               case DO_LDAP_ERR_FATAL:
+               case DO_LDAP_ERR_FATAL: {
                    /* Non-retryable error.  Write rejection log. */
-                   write_reject( ri, re, ri->ri_ldp->ld_errno, errmsg );
+                       int ld_errno = 0;
+                       ldap_get_option(ri->ri_ldp, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+                   write_reject( ri, re, ld_errno, errmsg );
                    /* Update status ... */
                    (void) sglob->st->st_update( sglob->st, ri->ri_stel, re );
                    /* ... and write to disk */
                    (void) sglob->st->st_write( sglob->st );
-                   break;
+                   break;
                default:
                    /* LDAP op completed ok - update status... */
                    (void) sglob->st->st_update( sglob->st, ri->ri_stel, re );
@@ -129,10 +119,11 @@ Ri_process(
        while ( !sglob->slurpd_shutdown &&
                ((new_re = re->re_getnext( re )) == NULL )) {
            if ( sglob->one_shot_mode ) {
+               rq->rq_unlock( rq );
                return 0;
            }
            /* No work - wait on condition variable */
-           pthread_cond_wait( &rq->rq_more, &rq->rq_mutex );
+           ldap_pvt_thread_cond_wait( &rq->rq_more, &rq->rq_mutex );
        }
        re->re_decrefcnt( re );
        re = new_re;
@@ -146,7 +137,8 @@ Ri_process(
 
 
 /*
- * Wake a replication thread which may be sleeping.  Send it a SIGUSR1.
+ * Wake a replication thread which may be sleeping.
+ * Send it a LDAP_SIGUSR1.
  */
 static void
 Ri_wake(
@@ -156,8 +148,7 @@ Ri_wake(
     if ( ri == NULL ) {
        return;
     }
-    pthread_kill( ri->ri_tid, SIGUSR1 );
-    (void) SIGNAL( SIGUSR1, (void *) do_nothing );
+    ldap_pvt_thread_kill( ri->ri_tid, LDAP_SIGUSR1 );
 }
 
 
@@ -262,5 +253,3 @@ isnew(
     sglob->st->st_unlock( sglob->st );
     return ret;
 }
-
-
index 54adb4da1af77e4fd26db6da62d375ea781e94c6..0dd599ba6db120d5d278d2fd71eb5c698322cacd 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  *
  */
 
+#include "portable.h"
+
 #include <stdio.h>
 
+#include <ac/stdlib.h>
+#include <ac/string.h>
+#include <ac/unistd.h>         /* get ftruncate() */
+
 #include "slurp.h"
 #include "globals.h"
 
 
-/* externs */
-#ifdef NEEDPROTOS
-extern void Re_dump( Re *re );
-#else /* NEEDPROTOS */
-extern void Re_dump();
-#endif /* NEEDPROTOS */
-
-
-extern char *sys_errlist[];
-
-
 /*
  * Lock the replication queue.
  */
@@ -56,13 +52,10 @@ Rq_lock(
     Rq *rq
 )
 {
-    return( pthread_mutex_lock( &rq->rq_mutex ));
+    return( ldap_pvt_thread_mutex_lock( &rq->rq_mutex ));
 }
 
 
-
-
-
 /*
  * Unlock the replication queue.
  */
@@ -71,7 +64,7 @@ Rq_unlock(
     Rq *rq
 )
 {
-    return( pthread_mutex_unlock( &rq->rq_mutex ));
+    return( ldap_pvt_thread_mutex_unlock( &rq->rq_mutex ));
 }
 
 
@@ -89,8 +82,6 @@ Rq_gethead(
 }
 
 
-
-
 /*
  * Return the next item in the queue.  Callers should lock the queue before
  * calling this routine.
@@ -108,8 +99,6 @@ Rq_getnext(
 }
 
 
-
-
 /*
  * Delete the item at the head of the list.  The queue should be locked
  * by the caller before calling this routine.
@@ -144,8 +133,6 @@ Rq_delhead(
 }
 
 
-
-
 /* 
  * Add an entry to the tail of the replication queue.  Locking is handled
  * internally.  When items are added to the queue, this routine wakes
@@ -200,7 +187,7 @@ Rq_add(
     /* Increment count of items in queue */
     rq->rq_nre++;
     /* wake up any threads waiting for more work */
-    pthread_cond_broadcast( &rq->rq_more );
+    ldap_pvt_thread_cond_broadcast( &rq->rq_more );
 
     /* ... and unlock the queue */
     rq->rq_unlock( rq );
@@ -209,8 +196,6 @@ Rq_add(
 }
 
 
-
-
 /*
  * Garbage-collect the replication queue.  Locking is handled internally.
  */
@@ -234,7 +219,6 @@ Rq_gc(
 }
 
 
-
 /*
  * For debugging: dump the contents of the replication queue to a file.
  * Locking is handled internally.
@@ -268,7 +252,6 @@ Rq_dump(
 }
 
 
-
 /*
  * Write the contents of a replication queue to a file.  Returns zero if
  * successful, -1 if not.  Handles queue locking internally.  Callers should
@@ -317,8 +300,6 @@ Rq_write(
 }
 
 
-
-
 /*
  * Check to see if the private slurpd replication log needs trimming.
  * The current criteria are:
@@ -335,8 +316,6 @@ Rq_needtrim(
 )
 {
     int                rc = 0;
-    Re         *re;
-    int                nzrc = 0;       /* nzrc is count of entries with refcnt == 0 */
     time_t     now;
 
     if ( rq == NULL ) {
@@ -391,8 +370,6 @@ Rq_getcount(
 }
 
 
-
-
 /* 
  * Allocate and initialize an Rq object.
  */
@@ -421,8 +398,8 @@ Rq_init(
     (*rq)->rq_getcount = Rq_getcount;
 
     /* Initialize private data */
-    pthread_mutex_init( &((*rq)->rq_mutex), pthread_mutexattr_default );
-    pthread_cond_init( &((*rq)->rq_more), pthread_condattr_default );
+    ldap_pvt_thread_mutex_init( &((*rq)->rq_mutex) );
+    ldap_pvt_thread_cond_init( &((*rq)->rq_more) );
     (*rq)->rq_head = NULL;
     (*rq)->rq_tail = NULL;
     (*rq)->rq_nre = 0;
@@ -431,4 +408,3 @@ Rq_init(
 
     return 0;
 }
-
index 04be7db86af87d728e9f03c83735cd62d3587613..56886ff420ccef02d05a09bdfbf58b8b59d49cb4 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  * feedback to the users.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <unistd.h>
-#include <string.h>
+
+#include <ac/unistd.h>
+#include <ac/string.h>
 
 #include "slurp.h"
 #include "globals.h"
-#include "portable.h"
 
 #define FC_DIRBAD      1
 #define FC_DIRUNREAD   2
 /*
  * Forward declarations
  */
-#ifdef NEEDPROTOS
-static unsigned int filecheck( char * );
-#else /* NEEDPROTOS */
-static unsigned int filecheck();
-#endif /* NEEDPROTOS */
+static unsigned int filecheck LDAP_P(( char * ));
 
 
 
@@ -58,7 +57,7 @@ static unsigned int filecheck();
  */
 
 int
-sanity()
+sanity( void )
 {
     int        err = 0;
     int rc;
@@ -201,4 +200,3 @@ filecheck(
 
     return ret;
 }
-
index 4573a71f246f906ffef9bcec7cff7590319a7dad..19a6c9d58b9c26ee74d6f398794759c0903da2fd 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
index 610b29585342e2b4205d82ed080288b4448f2934..8a76b0b181d04d239c82ada31e47b627dc3e38fd 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  * writing status information to disk.
  */
 
-
+#include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <unistd.h>
+
+#include <ac/stdlib.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
 
 #include "slurp.h"
 #include "globals.h"
 
-#ifndef SYSERRLIST_IN_STDIO
-extern char *sys_errlist[];
-#endif /* SYSERRLIST_IN_STDIO */
-
 /*
  * Add information about replica host specified by Ri to list
  * of hosts.
@@ -46,20 +45,19 @@ St_add(
     }
 
     /* Serialize access to the St struct */
-    pthread_mutex_lock( &(st->st_mutex ));
+    ldap_pvt_thread_mutex_lock( &(st->st_mutex ));
 
     st->st_nreplicas++;
     ind = st->st_nreplicas - 1;
     st->st_data = ( Stel ** ) ch_realloc( st->st_data, 
            ( st->st_nreplicas * sizeof( Stel * )));
     if ( st->st_data == NULL ) {
-       pthread_mutex_unlock( &(st->st_mutex ));
+       ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
        return NULL;
     }
-    st->st_data[ ind ]  = ( Stel * ) ch_malloc( st->st_data,
-           sizeof( Stel ));
+    st->st_data[ ind ]  = ( Stel * ) ch_malloc( sizeof( Stel ) );
     if ( st->st_data[ ind ] == NULL ) {
-       pthread_mutex_unlock( &(st->st_mutex ));
+       ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
        return NULL;
     }
 
@@ -68,7 +66,7 @@ St_add(
     memset( st->st_data[ ind ]->last, 0, sizeof( st->st_data[ ind ]->last )); 
     st->st_data[ ind ]->seq = 0;
 
-    pthread_mutex_unlock( &(st->st_mutex ));
+    ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
     return st->st_data[ ind ];
 }
 
@@ -89,7 +87,7 @@ St_write (
     if ( st == NULL ) {
        return -1;
     }
-    pthread_mutex_lock( &(st->st_mutex ));
+    ldap_pvt_thread_mutex_lock( &(st->st_mutex ));
     if ( st->st_fp == NULL ) {
        /* Open file */
        if (( rc = acquire_lock( sglob->slurpd_status_file, &(st->st_fp),
@@ -99,7 +97,7 @@ St_write (
                        "Error: cannot open status file \"%s\": %s\n",
                        sglob->slurpd_status_file, sys_errlist[ errno ], 0 );
                st->st_err_logged = 1;
-               pthread_mutex_unlock( &(st->st_mutex ));
+               ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
                return -1;
            }
        } else {
@@ -117,7 +115,7 @@ St_write (
     }
     fflush( st->st_fp );
 
-    pthread_mutex_unlock( &(st->st_mutex ));
+    ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
 
     return 0;
 }
@@ -139,10 +137,10 @@ St_update(
        return -1;
     }
 
-    pthread_mutex_lock( &(st->st_mutex ));
+    ldap_pvt_thread_mutex_lock( &(st->st_mutex ));
     strcpy( stel->last, re->re_timestamp );
     stel->seq = re->re_seq;
-    pthread_mutex_unlock( &(st->st_mutex ));
+    ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
     return 0;
 }
 
@@ -168,7 +166,7 @@ St_read(
     if ( st == NULL ) {
        return -1;
     }
-    pthread_mutex_lock( &(st->st_mutex ));
+    ldap_pvt_thread_mutex_lock( &(st->st_mutex ));
     if ( access( sglob->slurpd_status_file, F_OK ) < 0 ) {
        /*
         * File doesn't exist, so create it and return.
@@ -176,16 +174,17 @@ St_read(
        if (( fp = fopen( sglob->slurpd_status_file, "w" )) == NULL ) {
            Debug( LDAP_DEBUG_ANY, "Error: cannot create status file \"%s\"\n",
                    sglob->slurpd_status_file, 0, 0 );
-           pthread_mutex_unlock( &(st->st_mutex ));
+           ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
            return -1;
        }
        (void) fclose( fp );
-       pthread_mutex_unlock( &(st->st_mutex ));
+       ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
        Debug( LDAP_DEBUG_ARGS, "No status file found, defaulting values\n",
                0, 0, 0 );
        return 0;
     }
     if (( rc = acquire_lock( sglob->slurpd_status_file, &fp, &lfp)) < 0 ) {
+       ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
        return 0;
     }
     while ( fgets( buf, sizeof( buf ), fp ) != NULL ) {
@@ -235,12 +234,12 @@ St_read(
        }
     }
     (void) relinquish_lock( sglob->slurpd_status_file, fp, lfp);
-    pthread_mutex_unlock( &(st->st_mutex ));
+    ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
     return 0;
 
 bad:
     (void) relinquish_lock( sglob->slurpd_status_file, fp, lfp);
-    pthread_mutex_unlock( &(st->st_mutex ));
+    ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
     return -1;
 }
     
@@ -255,7 +254,7 @@ St_lock(
     St *st
 )
 {
-    return( pthread_mutex_lock( &st->st_mutex ));
+    return( ldap_pvt_thread_mutex_lock( &st->st_mutex ));
 }
 
 
@@ -269,7 +268,7 @@ St_unlock(
     St *st
 )
 {
-    return( pthread_mutex_unlock( &st->st_mutex ));
+    return( ldap_pvt_thread_mutex_unlock( &st->st_mutex ));
 }
 
 
@@ -292,7 +291,7 @@ St_init(
        return -1;
     }
 
-    pthread_mutex_init( &((*st)->st_mutex), pthread_mutexattr_default );
+    ldap_pvt_thread_mutex_init( &((*st)->st_mutex) );
     (*st)->st_data = NULL;
     (*st)->st_fp = NULL;
     (*st)->st_lfp = NULL;
index 4a66102e7d41d348de1119610cb62620c50c78e9..d469c700ebde250d80f2f91fc3f901d9f786fd03 100644 (file)
@@ -1,3 +1,4 @@
+# $OpenLDAP$
 ## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
 ## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 ##
index 7f673545c76628892fb6f72e9088829d932f2c68..d88eaa12451cfa70fd906269702432d6c1bc1b68 100644 (file)
@@ -80,8 +80,6 @@ objectclass: rfc822mailgroup
 dn: ou=Alumni Association, ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Alumni Association
 
 dn: cn=Barbara Jensen, ou=Information Technology Division, ou=People, o=Univer
@@ -142,16 +140,12 @@ telephonenumber: +1 313 555 0355
 dn: ou=Groups, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Groups
 
 dn: ou=Information Technology Division, ou=People, o=University of Michigan, c
  =US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Information Technology Divisio
 
 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
@@ -229,7 +223,6 @@ telephonenumber: +1 313 555 9394
 dn: cn=Manager, o=University of Michigan, c=US
 objectclass: top
 objectclass: person
-objectclass: quipuObject
 objectclass: kerberosSecurityObject
 cn: Manager
 cn: Directory Manager
@@ -241,16 +234,12 @@ krbname: bjensen@umich.edu
 dn: ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: People
 
 dn: o=University of Michigan, c=US
 objectclass: top
 objectclass: organization
 objectclass: domainRelatedObject
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 l: Ann Arbor, Michigan
 st: Michigan
 streetaddress: 535 West William St.
index 451183179d5eb76bdf1058294cd554b2f8181d43..69e72cd274b0e1597adb41c587ff1cce74f2230a 100644 (file)
@@ -34,8 +34,6 @@ objectclass: rfc822mailgroup
 dn: ou=Alumni Association, ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Alumni Association
 
 dn: cn=Barbara Jensen, ou=Information Technology Division, ou=People, o=Univer
@@ -147,16 +145,12 @@ homephone: +1 313 555 8844
 dn: ou=Groups, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Groups
 
 dn: ou=Information Technology Division, ou=People, o=University of Michigan, c
  =US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Information Technology Divisio
 
 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
@@ -284,7 +278,6 @@ telephonenumber: +1 313 555 9394
 dn: cn=Manager, o=University of Michigan, c=US
 objectclass: top
 objectclass: person
-objectclass: quipuObject
 objectclass: kerberosSecurityObject
 cn: Manager
 cn: Directory Manager
@@ -322,16 +315,12 @@ telephonenumber: +1 313 555 4177
 dn: ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: People
 
 dn: o=University of Michigan, c=US
 objectclass: top
 objectclass: organization
 objectclass: domainRelatedObject
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 l: Ann Arbor, Michigan
 st: Michigan
 streetaddress: 535 West William St.
index 1e557aeec663e5462c69dbd2f4ac6125e7c756f7..8ec913d040321bcd59b54502bf0e8c44d594e63a 100644 (file)
@@ -55,8 +55,6 @@ objectclass: rfc822mailgroup
 dn: ou=Alumni Association, ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Alumni Association
 
 dn: cn=Barbara Jensen, ou=Information Technology Division, ou=People, o=Univer
@@ -144,16 +142,12 @@ homephone: +1 313 555 0454
 dn: ou=Groups, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Groups
 
 dn: ou=Information Technology Division, ou=People, o=University of Michigan, c
  =US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Information Technology Divisio
 
 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
@@ -307,7 +301,6 @@ telephonenumber: +1 313 555 9394
 dn: cn=Manager, o=University of Michigan, c=US
 objectclass: top
 objectclass: person
-objectclass: quipuObject
 objectclass: kerberosSecurityObject
 cn: Manager
 cn: Directory Manager
@@ -345,16 +338,12 @@ telephonenumber: +1 313 555 4177
 dn: ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: People
 
 dn: o=University of Michigan, c=US
 objectclass: top
 objectclass: organization
 objectclass: domainRelatedObject
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 l: Ann Arbor, Michigan
 st: Michigan
 streetaddress: 535 West William St.
index 1e557aeec663e5462c69dbd2f4ac6125e7c756f7..8ec913d040321bcd59b54502bf0e8c44d594e63a 100644 (file)
@@ -55,8 +55,6 @@ objectclass: rfc822mailgroup
 dn: ou=Alumni Association, ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Alumni Association
 
 dn: cn=Barbara Jensen, ou=Information Technology Division, ou=People, o=Univer
@@ -144,16 +142,12 @@ homephone: +1 313 555 0454
 dn: ou=Groups, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Groups
 
 dn: ou=Information Technology Division, ou=People, o=University of Michigan, c
  =US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Information Technology Divisio
 
 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
@@ -307,7 +301,6 @@ telephonenumber: +1 313 555 9394
 dn: cn=Manager, o=University of Michigan, c=US
 objectclass: top
 objectclass: person
-objectclass: quipuObject
 objectclass: kerberosSecurityObject
 cn: Manager
 cn: Directory Manager
@@ -345,16 +338,12 @@ telephonenumber: +1 313 555 4177
 dn: ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: People
 
 dn: o=University of Michigan, c=US
 objectclass: top
 objectclass: organization
 objectclass: domainRelatedObject
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 l: Ann Arbor, Michigan
 st: Michigan
 streetaddress: 535 West William St.
index 310cdf864d6b169bccaccca9c64d9392123f387b..4274c59fd0bb6d97e31230e280052a973720014c 100644 (file)
@@ -262,23 +262,17 @@ objectclass: rfc822mailgroup
 dn: ou=Alumni Association, ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Alumni Association
 
 dn: ou=Groups, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Groups
 
 dn: ou=Information Technology Division, ou=People, o=University of Michigan, c
  =US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Information Technology Divisio
 
 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
@@ -302,16 +296,12 @@ labeledurl: http://www.itd.umich.edu ITD Home Page
 dn: ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: People
 
 dn: o=University of Michigan, c=US
 objectclass: top
 objectclass: organization
 objectclass: domainRelatedObject
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 l: Ann Arbor, Michigan
 st: Michigan
 streetaddress: 535 West William St.
index 5e56dea19c4f65759ed6425af7d0d5b2bed06481..feb3846ceab7779b845b6e344bc56ed29a6ba959 100644 (file)
@@ -1,15 +1,19 @@
+# $OpenLDAP$
 #
 # master slapd config -- for testing
 #
 include                ./data/slapd.at.conf
 include                ./data/slapd.oc.conf
 schemacheck    off
+pidfile     ./test-db/slapd.pid
+argsfile    ./test-db/slapd.args
 
 #######################################################################
 # ldbm database definitions
 #######################################################################
 
 database       ldbm
+cachesize      0
 suffix         "o=University of Michigan, c=US"
 directory      ./test-db
 rootdn         "cn=Manager, o=University of Michigan, c=US"
@@ -18,19 +22,31 @@ index               cn,sn,uid       pres,eq,approx
 index          default         none
 lastmod                on
 defaultaccess  none
+
+#
+# normal installations should protect root dse,
+# cn=monitor, cn=schema, and cn=config
+#
+
 access         to attr=objectclass
                by * read
-access         to attr=userpassword
+
+access         to filter="objectclass=person" attr=userpassword
                by self write
-               by * compare
-access         to dn=".*,ou=Alumni Association,ou=People,o=University of Michigan,c=US"
-               by dn=".*,o=University of Michigan,c=US"
-               read
+               by anonymous auth
                by * none
+
+access         to dn="^.*,ou=Alumni Association,ou=People,o=University of Michigan,c=US$"
+               by dn="^.*,o=University of Michigan,c=US$" read
+               by anonymous auth
+               by * none
+
 access         to attr=member
                by dnattr=member selfwrite
                by * read
+
 access         to filter="objectclass=rfc822mailgroup"
                by dn="Bjorn Jensen,ou=Information Technology Division,ou=People,o=University of Michigan,c=US" write
                by * read
+
 access         to * by * read
diff --git a/tests/data/slapd-bdb2-acl.conf b/tests/data/slapd-bdb2-acl.conf
new file mode 100644 (file)
index 0000000..50769f3
--- /dev/null
@@ -0,0 +1,50 @@
+# $OpenLDAP$
+#
+# master slapd config -- for testing
+#
+include                ./data/slapd.at.conf
+include                ./data/slapd.oc.conf
+schemacheck    off
+pidfile     ./test-db/slapd.pid
+argsfile    ./test-db/slapd.args
+
+#######################################################################
+# ldbm database definitions
+#######################################################################
+
+backend     bdb2
+home        ./test-db
+
+database       bdb2
+cachesize      0
+suffix         "o=University of Michigan, c=US"
+directory      ./test-db
+rootdn         "cn=Manager, o=University of Michigan, c=US"
+rootpw         secret
+index          cn,sn,uid       pres,eq,approx
+index          default         none
+lastmod                on
+defaultaccess  none
+
+access         to attr=objectclass
+               by * read
+
+access         to filter="objectclass=person" attr=userpassword
+               by self write
+               by anonymous auth
+               by * none
+
+access         to dn=".*,ou=Alumni Association,ou=People,o=University of Michigan,c=US"
+               by dn=".*,o=University of Michigan,c=US" read
+               by anonymous auth
+               by * none
+
+access         to attr=member
+               by dnattr=member selfwrite
+               by * read
+
+access         to filter="objectclass=rfc822mailgroup"
+               by dn="Bjorn Jensen,ou=Information Technology Division,ou=People,o=University of Michigan,c=US" write
+               by * read
+
+access         to * by * read
diff --git a/tests/data/slapd-bdb2-master.conf b/tests/data/slapd-bdb2-master.conf
new file mode 100644 (file)
index 0000000..2c2f0da
--- /dev/null
@@ -0,0 +1,26 @@
+# $OpenLDAP$
+#
+# master slapd config -- for testing
+#
+include                ./data/slapd.at.conf
+include                ./data/slapd.oc.conf
+schemacheck    on
+pidfile     ./test-db/slapd.pid
+argsfile    ./test-db/slapd.args
+
+#######################################################################
+# ldbm database definitions
+#######################################################################
+
+backend                bdb2
+home           ./test-db
+mpoolsize      21000000
+
+database       bdb2
+suffix         "o=University of Michigan, c=US"
+directory      ./test-db
+rootdn         "cn=Manager, o=University of Michigan, c=US"
+rootpw         secret
+index          cn,sn,uid       pres,eq,approx
+index          default         none
+lastmod                on
diff --git a/tests/data/slapd-bdb2-nis-master.conf b/tests/data/slapd-bdb2-nis-master.conf
new file mode 100644 (file)
index 0000000..3380ca6
--- /dev/null
@@ -0,0 +1,42 @@
+# $OpenLDAP$
+#
+# master slapd config -- for testing
+#
+include                ../servers/slapd/schema/others_nis.at.conf
+include                ../servers/slapd/schema/others_nis.oc.conf
+include                ../servers/slapd/schema/nis.at.conf
+include                ../servers/slapd/schema/nis.oc.conf
+include                ../servers/slapd/schema/internet_mail.at.conf
+include                ../servers/slapd/schema/internet_mail.oc.conf
+schemacheck    on
+pidfile     ./test-db/slapd.pid
+argsfile    ./test-db/slapd.args
+
+#######################################################################
+# ldbm database definitions
+#######################################################################
+
+backend                bdb2
+home           ./test-db
+mpoolsize      21000000
+
+database       bdb2
+cachesize      4
+suffix         "o=SGI, c=US"
+directory      ./test-db
+rootdn         "cn=Manager, o=SGI, c=US"
+rootpw         secret
+index          uid                     pres,eq,approx
+index          gidNumber               pres,eq,approx
+index          uidNumber               pres,eq,approx
+index          cn                      pres,eq,approx
+index          memberUid               pres,eq,approx
+index          macAddress              pres,eq,approx
+index          ipServiceProtocol       pres,eq,approx
+index          ipServicePort           pres,eq,approx
+index          oncRpcNumber            pres,eq,approx
+index          ipHostNumber            pres,eq,approx
+index          ipNetworkNumber         pres,eq,approx
+index          ipProtocolNumber        pres,eq,approx
+index          default         none
+lastmod                on
diff --git a/tests/data/slapd-bdb2-ref-slave.conf b/tests/data/slapd-bdb2-ref-slave.conf
new file mode 100644 (file)
index 0000000..7a0c819
--- /dev/null
@@ -0,0 +1,29 @@
+# $OpenLDAP$
+#
+# slave slapd config -- for default referral testing
+#
+include                ./data/slapd.at.conf
+include                ./data/slapd.oc.conf
+schemacheck    off
+pidfile     ./test-repl/slapd.pid
+argsfile    ./test-repl/slapd.args
+
+#######################################################################
+# ldbm database definitions
+#######################################################################
+
+referral       "ldap://localhost:9009/"
+
+backend     bdb2
+home        ./test-db
+
+database       bdb2
+cachesize      0
+suffix         "o=University of Mich, c=US"
+directory      ./test-repl
+rootdn         "cn=Manager, o=University of Mich, c=US"
+rootpw         secret
+index          cn,sn,uid       pres,eq,approx
+index          default         none
+# index                default         pres,eq,approx
+lastmod                on
diff --git a/tests/data/slapd-bdb2-repl-master.conf b/tests/data/slapd-bdb2-repl-master.conf
new file mode 100644 (file)
index 0000000..bf0ddf7
--- /dev/null
@@ -0,0 +1,34 @@
+# $OpenLDAP$
+#
+# master slapd config -- for testing of replication
+#
+include                ./data/slapd.at.conf
+include                ./data/slapd.oc.conf
+schemacheck    off
+pidfile     ./test-db/slapd.pid
+argsfile    ./test-db/slapd.args
+
+#######################################################################
+# ldbm database definitions
+#######################################################################
+
+backend                bdb2
+home           ./test-db
+
+database       bdb2
+cachesize      0
+suffix         "o=University of Michigan, c=US"
+directory      ./test-db
+rootdn         "cn=Manager, o=University of Michigan, c=US"
+rootpw         secret
+index          cn,sn,uid       pres,eq,approx
+index          default         none
+# index                default         pres,eq,approx
+lastmod                on
+
+replogfile     ./test-db/slapd.replog
+
+replica                host=localhost:9010
+               binddn="cn=Replica, o=University of Michigan, c=US"
+               bindmethod=simple
+               credentials=secret
diff --git a/tests/data/slapd-bdb2-repl-slave.conf b/tests/data/slapd-bdb2-repl-slave.conf
new file mode 100644 (file)
index 0000000..7e2ad2c
--- /dev/null
@@ -0,0 +1,32 @@
+# $OpenLDAP$
+#
+# master slapd config -- for testing of replication
+#
+include                ./data/slapd.at.conf
+include                ./data/slapd.oc.conf
+schemacheck    off
+pidfile     ./test-repl/slapd.pid
+argsfile    ./test-repl/slapd.args
+
+referral    "ldap://localhost:9009/"
+
+#######################################################################
+# ldbm database definitions
+#######################################################################
+
+backend     bdb2
+home        ./test-repl
+
+database       bdb2
+cachesize      0
+suffix         "o=University of Michigan, c=US"
+directory      ./test-repl
+rootdn         "cn=Replica, o=University of Michigan, c=US"
+rootpw         secret
+updatedn       "cn=Replica, o=University of Michigan, c=US"
+updateref   "ldap://localhost:9009/o=University%20of%20Michigan,c=US"
+index          cn,sn,uid       pres,eq,approx
+index          default         none
+# index                default         pres,eq,approx
+lastmod                on
+dbcachenowsync
index 2b936ab605f9f3fb83ae7dac84c95e2b39051551..d1c2387e20f6ec09c7365a2ae2d0a8a86644b8e2 100644 (file)
@@ -1,9 +1,12 @@
+# $OpenLDAP$
 #
 # master slapd config -- for testing
 #
 include                ./data/slapd.at.conf
 include                ./data/slapd.oc.conf
-schemacheck    off
+schemacheck    on
+pidfile     ./test-db/slapd.pid
+argsfile    ./test-db/slapd.args
 
 #######################################################################
 # ldbm database definitions
@@ -17,3 +20,4 @@ rootpw                secret
 index          cn,sn,uid       pres,eq,approx
 index          default         none
 lastmod                on
+dbcachenowsync
diff --git a/tests/data/slapd-nis-master.conf b/tests/data/slapd-nis-master.conf
new file mode 100644 (file)
index 0000000..b6d152b
--- /dev/null
@@ -0,0 +1,38 @@
+# $OpenLDAP$
+#
+# master slapd config -- for testing
+#
+include                ../servers/slapd/schema/others_nis.at.conf
+include                ../servers/slapd/schema/others_nis.oc.conf
+include                ../servers/slapd/schema/nis.at.conf
+include                ../servers/slapd/schema/nis.oc.conf
+include                ../servers/slapd/schema/internet_mail.at.conf
+include                ../servers/slapd/schema/internet_mail.oc.conf
+schemacheck    on
+pidfile     ./test-db/slapd.pid
+argsfile    ./test-db/slapd.args
+
+#######################################################################
+# ldbm database definitions
+#######################################################################
+
+database       ldbm
+cachesize      4
+suffix         "o=SGI, c=US"
+directory      ./test-db
+rootdn         "cn=Manager, o=SGI, c=US"
+rootpw         secret
+index          uid                     pres,eq,approx
+index          gidNumber               pres,eq,approx
+index          uidNumber               pres,eq,approx
+index          cn                      pres,eq,approx
+index          memberUid               pres,eq,approx
+index          macAddress              pres,eq,approx
+index          ipServiceProtocol       pres,eq,approx
+index          ipServicePort           pres,eq,approx
+index          oncRpcNumber            pres,eq,approx
+index          ipHostNumber            pres,eq,approx
+index          ipNetworkNumber         pres,eq,approx
+index          ipProtocolNumber        pres,eq,approx
+index          default         none
+lastmod                on
diff --git a/tests/data/slapd-passwd.conf b/tests/data/slapd-passwd.conf
new file mode 100644 (file)
index 0000000..10925e5
--- /dev/null
@@ -0,0 +1,19 @@
+# $OpenLDAP$
+#
+# master slapd config -- for testing
+#
+include                ./data/slapd.at.conf
+include                ./data/slapd.oc.conf
+schemacheck    on
+pidfile     ./test-db/slapd.pid
+argsfile    ./test-db/slapd.args
+
+#######################################################################
+# ldbm database definitions
+#######################################################################
+
+database       passwd
+suffix         "o=University of Michigan, c=US"
+rootdn         "cn=Manager, o=University of Michigan, c=US"
+rootpw         secret
+#file          ./data/passwd
diff --git a/tests/data/slapd-ref-slave.conf b/tests/data/slapd-ref-slave.conf
new file mode 100644 (file)
index 0000000..c10b036
--- /dev/null
@@ -0,0 +1,26 @@
+# $OpenLDAP$
+#
+# slave slapd config -- for default referral testing
+#
+include                ./data/slapd.at.conf
+include                ./data/slapd.oc.conf
+schemacheck    off
+pidfile     ./test-repl/slapd.pid
+argsfile    ./test-repl/slapd.args
+
+#######################################################################
+# ldbm database definitions
+#######################################################################
+
+referral       "ldap://localhost:9009/"
+
+database       ldbm
+cachesize      0
+suffix         "o=University of Mich, c=US"
+directory      ./test-repl
+rootdn         "cn=Manager, o=University of Mich, c=US"
+rootpw         secret
+index          cn,sn,uid       pres,eq,approx
+index          default         none
+# index                default         pres,eq,approx
+lastmod                on
index bce1d6821cd41854f1c05dc8f748bc6fb218e202..d4f702f78b8c0ace24d78f5abe5433e182a6b07d 100644 (file)
@@ -1,26 +1,31 @@
+# $OpenLDAP$
 #
 # master slapd config -- for testing of replication
 #
 include                ./data/slapd.at.conf
 include                ./data/slapd.oc.conf
 schemacheck    off
+pidfile     ./test-db/slapd.pid
+argsfile    ./test-db/slapd.args
 
 #######################################################################
 # ldbm database definitions
 #######################################################################
 
 database       ldbm
+cachesize      0
 suffix         "o=University of Michigan, c=US"
 directory      ./test-db
 rootdn         "cn=Manager, o=University of Michigan, c=US"
 rootpw         secret
 index          cn,sn,uid       pres,eq,approx
 index          default         none
+# index                default         pres,eq,approx
 lastmod                on
 
 replogfile     ./test-db/slapd.replog
 
 replica                host=localhost:9010
-               binddn="cn=Manager, o=University of Michigan, c=US"
+               binddn="cn=Replica, o=University of Michigan, c=US"
                bindmethod=simple
                credentials=secret
index ca81b76529d5c2443970cebe24581ea05b68bc90..e9f0bb3ee76e8ddcc66023633cf523c94f160ce5 100644 (file)
@@ -1,20 +1,28 @@
+# $OpenLDAP$
 #
 # master slapd config -- for testing of replication
 #
 include                ./data/slapd.at.conf
 include                ./data/slapd.oc.conf
 schemacheck    off
+pidfile     ./test-repl/slapd.pid
+argsfile    ./test-repl/slapd.args
+
+referral       "ldap://localhost:9009/"
 
 #######################################################################
 # ldbm database definitions
 #######################################################################
 
 database       ldbm
+cachesize      0
 suffix         "o=University of Michigan, c=US"
 directory      ./test-repl
-rootdn         "cn=Manager, o=University of Michigan, c=US"
+rootdn         "cn=Replica, o=University of Michigan, c=US"
 rootpw         secret
-updatedn       "cn=Manager, o=University of Michigan, c=US"
+updatedn       "cn=Replica, o=University of Michigan, c=US"
+updateref      "ldap://localhost:9009/o=University%20of%20Michigan,c=US"
 index          cn,sn,uid       pres,eq,approx
 index          default         none
+# index                default         pres,eq,approx
 lastmod                on
index c3c8b136b0d79050ed64f1740278ad4c0b716adc..0191d2b65218ae30082d19b84f8c7dd6e86dee0c 100644 (file)
@@ -1,8 +1,10 @@
+# $OpenLDAP$
 attribute      photo                                   bin
 attribute      personalsignature                       bin
 attribute      jpegphoto                               bin
 attribute      audio                                   bin
 attribute      labeledurl                              ces
+attribute      ref                                             ces
 attribute      userpassword                            ces
 attribute      telephonenumber                         tel
 attribute      facsimiletelephonenumber        fax     tel
index 94f2349ba5f8ba1268c33299979d154f2431de4f..fc63fa4fc8ba1820695b7d2e9e01ddc57990ab88 100644 (file)
@@ -1,3 +1,5 @@
+# $OpenLDAP$
+
 objectclass top
        requires
                objectClass
@@ -7,6 +9,11 @@ objectclass alias
                aliasedObjectName,
                objectClass
 
+objectclass referral
+       requires
+               ref,
+               objectClass
+
 objectclass country
        requires
                objectClass,
@@ -83,18 +90,17 @@ objectclass organizationalUnit
 objectclass person
        requires
                objectClass,
-               sn,
                cn
        allows
                description,
                seeAlso,
+               sn,
                telephoneNumber,
                userPassword
 
 objectclass organizationalPerson
        requires
                objectClass,
-               sn,
                cn
        allows
                description,
@@ -110,6 +116,7 @@ objectclass organizationalPerson
                preferredDeliveryMethod,
                registeredAddress,
                seeAlso,
+               sn,
                st,
                streetAddress,
                telephoneNumber,
@@ -161,7 +168,6 @@ objectclass groupOfNames
 objectclass residentialPerson
        requires
                objectClass,
-               sn,
                cn,
                l
        allows
@@ -178,6 +184,7 @@ objectclass residentialPerson
                preferredDeliveryMethod,
                registeredAddress,
                seeAlso,
+               sn,
                st,
                streetAddress,
                telephoneNumber,
@@ -261,7 +268,6 @@ objectclass pilotObject
 objectclass newPilotPerson
        requires
                objectClass,
-               sn,
                cn
        allows
                businessCategory,
@@ -270,6 +276,8 @@ objectclass newPilotPerson
                homePhone,
                homePostalAddress,
                janetMailbox,
+               lastModifiedBy,
+               lastModifiedTime,
                mail,
                mailPreferenceOption,
                mobile,
@@ -282,6 +290,7 @@ objectclass newPilotPerson
                roomNumber,
                secretary,
                seeAlso,
+               sn,
                telephoneNumber,
                textEncodedORaddress,
                uid,
@@ -663,9 +672,7 @@ objectclass kerberosSecurityObject
 objectclass umichPerson
        requires
                objectClass,
-               sn,
-               cn,
-               universityID
+               cn
        allows
                affiliationCode,
                audio,
@@ -714,6 +721,7 @@ objectclass umichPerson
                roomNumber,
                secretary,
                seeAlso,
+               sn,
                st,
                streetAddress,
                telephoneNumber,
@@ -722,6 +730,7 @@ objectclass umichPerson
                textEncodedORaddress,
                title,
                uid,
+               universityID,
                updateSource,
                userCertificate,
                userClass,
index 80011669882d552b7416d08f7edb91999f61758b..3db5bb98ec91db7634427fad8ee19b25502ca265 100644 (file)
@@ -2,8 +2,6 @@ dn: o=University of Michigan, c=US
 objectclass: top
 objectclass: organization
 objectclass: domainRelatedObject
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 l: Ann Arbor, Michigan
 st: Michigan
 streetaddress: 535 West William St.
@@ -21,30 +19,22 @@ associateddomain: umich.edu
 dn: ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: People
 
 dn: ou=Groups, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Groups
 
 dn: ou=Alumni Association, ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Alumni Association
 
 dn: ou=Information Technology Division, ou=People, o=University of Michigan, c
  =US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Information Technology Divisio
 
 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
@@ -333,7 +323,6 @@ telephonenumber: +1 313 555 9394
 dn: cn=Manager, o=University of Michigan, c=US
 objectclass: top
 objectclass: person
-objectclass: quipuObject
 objectclass: kerberosSecurityObject
 cn: Manager
 cn: Directory Manager
index e68250771553b080afc9739e5ff6b02575a7d2b0..e658ae0db10d8bcbfc48eda734f5a3f70fa69fb9 100644 (file)
@@ -55,8 +55,6 @@ objectclass: rfc822mailgroup
 dn: ou=Alumni Association, ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Alumni Association
 
 dn: cn=Barbara Jensen, ou=Information Technology Division, ou=People, o=Univer
@@ -144,16 +142,12 @@ homephone: +1 313 555 0454
 dn: ou=Groups, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Groups
 
 dn: ou=Information Technology Division, ou=People, o=University of Michigan, c
  =US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: Information Technology Divisio
 
 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
@@ -306,7 +300,6 @@ telephonenumber: +1 313 555 9394
 dn: cn=Manager, o=University of Michigan, c=US
 objectclass: top
 objectclass: person
-objectclass: quipuObject
 objectclass: kerberosSecurityObject
 cn: Manager
 cn: Directory Manager
@@ -344,16 +337,12 @@ telephonenumber: +1 313 555 4177
 dn: ou=People, o=University of Michigan, c=US
 objectclass: top
 objectclass: organizationalUnit
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 ou: People
 
 dn: o=University of Michigan, c=US
 objectclass: top
 objectclass: organization
 objectclass: domainRelatedObject
-objectclass: quipuObject
-objectclass: quipuNonLeafObject
 l: Ann Arbor, Michigan
 st: Michigan
 streetaddress: 535 West William St.
index 842f8efb617d1e67701bbc79635dcea465a4a9a8..16c0a66dea2cd5de33baf04bb9468636b4e2c061 100644 (file)
@@ -1,4 +1,5 @@
-## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
+# $OpenLDAP$
+## Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
 ## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 ##
 ## tests Makefile.in for OpenLDAP
index b5a2a2177e733e30f257197b2be0a9404099f55f..3497439af3e4a05dc3f4570979ba92773a9fbc74 100644 (file)
@@ -1,3 +1,8 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 #include "portable.h"
 
 #include <stdio.h>
index 124eea6c887b4470c57bd3d6b3273fde5fe8ca4f..0446534f0d95c6f2619a692da944e5ffedefb3ff 100644 (file)
@@ -1,3 +1,8 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 #include "portable.h"
 
 #include <stdio.h>
index fd0a533896e994bd486d622989057ac526def6ac..fc5745e797848297d67834ecbe5497e887fb7784 100644 (file)
@@ -1,3 +1,8 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 #include "portable.h"
 
 #include <stdio.h>
index cadd3df89dec75d8d95f8bca4a29ec55e645a274..d1a44e79b1a036f212243df33daa3b6fec1480cb 100644 (file)
@@ -1,3 +1,8 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 #include "portable.h"
 
 #include <stdio.h>
diff --git a/tests/scripts/acfilter.sh b/tests/scripts/acfilter.sh
new file mode 100755 (executable)
index 0000000..7e3659e
--- /dev/null
@@ -0,0 +1,6 @@
+#! /bin/sh
+# $OpenLDAP$
+#
+# Strip operational attributes
+#
+egrep -iv '^modifiersname:|^modifytimestamp:|^creatorsname:|^createtimestamp'
index 0b48a448297028aad407d47f7ac2323d40dd7125..bbbcad5c59ca86ae53fcc3d45aeec438e6e1af8f 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# $OpenLDAP$
 
 # disable LDAP initialization
 LDAPNOINIT=true; export LDAPNOINIT
index 8e3f6b1ed3f29440e09015db0e3def652e2dd6ee..383657603c1c54d06dfaacd28eabbcd508d005fa 100755 (executable)
@@ -1,3 +1,5 @@
+#! /bin/sh
+# $OpenLDAP$
 
 DATADIR=$SRCDIR/data
 PROGDIR=./progs
@@ -60,6 +62,7 @@ LDIFFLT=$DBDIR/ldif.flt
 MASTEROUT=$DBDIR/master.out
 SLAVEOUT=$DBDIR/slave.out
 TESTOUT=$DBDIR/test.out
+INITOUT=$DBDIR/init.out
 SEARCHOUTMASTER=$DATADIR/search.out.master
 MODIFYOUTMASTER=$DATADIR/modify.out.master
 ADDDELOUTMASTER=$DATADIR/adddel.out.master
index 4107012e97a7f3c99de5a619faa4bfa566773844..68152bd857022b228f21fcd2f79efc91537bde54 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# $OpenLDAP$
 
 . scripts/defines.sh
 
@@ -6,10 +7,10 @@ echo "Cleaning up in $DBDIR..."
 
 rm -f $DBDIR/[!C]*
 
-echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $CONF -l $LDIF
+echo "Running slapadd to build slapd database..."
+$slapadd -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldif2ldbm failed!"
+       echo "slapadd failed!"
        exit $RC
 fi
diff --git a/tests/scripts/passwd-search b/tests/scripts/passwd-search
new file mode 100755 (executable)
index 0000000..529ad83
--- /dev/null
@@ -0,0 +1,109 @@
+#! /bin/sh
+# $OpenLDAP$
+
+if test $# -eq 0 ; then
+       SRCDIR="."
+else
+       SRCDIR=$1; shift
+fi
+if test $# -eq 1 ; then
+       BACKEND=$1; shift
+fi
+
+echo "running defines.sh $SRCDIR $BACKEND"
+. $SRCDIR/scripts/defines.sh
+
+echo "Cleaning up in $DBDIR..."
+
+rm -f $DBDIR/[!C]*
+
+echo "Starting slapd on TCP/IP port $PORT..."
+$SLAPD -f $PASSWDCONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
+PID=$!
+
+echo "Testing slapd searching..."
+for i in 0 1 2 3 4 5; do
+       $LDAPSEARCH -L -b "$BASEDN" -h localhost -p $PORT \
+               'objectclass=*' > /dev/null 2>&1
+       RC=$?
+       if test $RC = 1 ; then
+               echo "Waiting 5 seconds for slapd to start..."
+               sleep 5
+       fi
+done
+
+if test $RC != 0 ; then
+       echo "ldapsearch failed!"
+       kill -HUP $PID
+       exit $RC
+fi
+
+cat /dev/null > $TESTOUT
+
+echo "Testing base suffix searching..."
+$LDAPSEARCH -L -S "" -b "$BASEDN" -s base -h localhost -p $PORT \
+       '(objectclass=*)' >> $TESTOUT 2>&1
+if test $RC != 0 ; then
+       echo "ldapsearch failed!"
+       kill -HUP $PID
+       exit $RC
+fi
+
+echo " ------------ " >> $TESTOUT
+
+echo "Testing user searching..."
+$LDAPSEARCH -L -S "" -b "uid=root,$BASEDN" -s base -h localhost -p $PORT \
+       '(objectclass=*)' >> $TESTOUT 2>&1
+if test $RC != 0 ; then
+       echo "ldapsearch failed!"
+       kill -HUP $PID
+       exit $RC
+fi
+
+echo " ------------ " >> $TESTOUT
+
+echo "Testing exact searching..."
+$LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
+       '(uid=root)' >> $TESTOUT 2>&1
+if test $RC != 0 ; then
+       echo "ldapsearch failed!"
+       kill -HUP $PID
+       exit $RC
+fi
+
+echo " ------------ " >> $TESTOUT
+
+echo "Testing OR searching..."
+$LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
+       '(|(objectclass=person)(cn=root))' >> $TESTOUT 2>&1
+if test $RC != 0 ; then
+       echo "ldapsearch failed!"
+       kill -HUP $PID
+       exit $RC
+fi
+
+echo " ------------ " >> $TESTOUT
+
+echo "Testing AND searching..."
+$LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
+       '(&(objectclass=person)(cn=root))' >> $TESTOUT 2>&1
+if test $RC != 0 ; then
+       echo "ldapsearch failed!"
+       kill -HUP $PID
+       exit $RC
+fi
+
+kill -HUP $PID
+
+echo "Assuming everything is fine."
+#echo "Comparing results"
+#cmp $TESTOUT $SEARCHOUTMASTER
+#if test $? != 0 ; then
+#      echo "Comparison failed"
+#      exit 1
+#fi
+
+echo ">>>>> Test succeeded"
+
+
+exit 0
index 06391bb48cecb55b5d3ed21bc70f0a0ff7ffa823..442c62fa1cac5dbf2b3eba287108ae05cdb673bc 100755 (executable)
@@ -1,5 +1,5 @@
-#!/bin/sh
-
+#! /bin/sh
+# $OpenLDAP$
 
 if [ $# -eq 0 ]; then
        SRCDIR="."
@@ -26,11 +26,11 @@ echo "Cleaning up in $DBDIR..."
 
 rm -f $DBDIR/[!C]*
 
-echo "Running ldif2ldbm to build slapd database..."
+echo "Running slapadd to build slapd database..."
 $LDIF2LDBM -f $NIS_CONF -l $NIS_LDIF
 RC=$?
 if [ $RC != 0 ]; then
-       echo "ldif2ldbm failed!"
+       echo "slapadd failed!"
        exit $RC
 fi
 
diff --git a/tests/scripts/test001-ldif2ldbm b/tests/scripts/test001-ldif2ldbm
deleted file mode 100755 (executable)
index 8fde6c4..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#! /bin/sh
-
-if test $# -eq 0 ; then
-       SRCDIR="."
-else
-       SRCDIR=$1; shift
-fi
-if test $# -eq 1 ; then
-       BACKEND=$1; shift
-fi
-
-echo "running defines.sh $SRCDIR $BACKEND"
-
-. $SRCDIR/scripts/defines.sh
-
-echo "Datadir is $DATADIR"
-
-echo "Cleaning up in $DBDIR..."
-
-rm -f $DBDIR/[!C]*
-
-echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $CONF -l $LDIF
-RC=$?
-if test $RC != 0 ; then
-       echo "ldif2ldbm failed!"
-       exit $RC
-fi
-
-echo "Starting slapd on TCP/IP port $PORT..."
-$SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
-PID=$!
-
-echo "Using ldapsearch to retrieve all the entries..."
-for i in 0 1 2 3 4 5; do
-       $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
-               'objectClass=*' > $SEARCHOUT 2>&1
-       RC=$?
-       if test $RC = 1 ; then
-               echo "Waiting 5 seconds for slapd to start..."
-               sleep 5
-       fi
-done
-
-kill -HUP $PID
-
-if test $RC != 0 ; then
-       echo "ldapsearch failed!"
-       exit $RC
-fi
-
-echo "Filtering ldapsearch results..."
-. $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
-echo "Filtering original ldif used to create database..."
-. $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
-echo "Comparing filter output..."
-cmp $SEARCHFLT $LDIFFLT
-
-if test $? != 0 ; then
-       echo "comparison failed - database was not created correctly"
-       exit 1
-fi
-
-echo ">>>>> Test succeeded"
-
-
-exit 0
index 252ce1faa0892284ca66c3a392a2c8b2974b3274..dc358a980e651ef49dce047b40275d55d866a3d3 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# $OpenLDAP$
 
 if test $# -eq 0 ; then
        SRCDIR="."
index de58905d9e252425b5229ac32cd68e918bf3d030..9fcf18b711181ddfa70e28f1347ec771a18d81a3 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# $OpenLDAP$
 
 if test $# -eq 0 ; then
        SRCDIR="."
@@ -16,11 +17,11 @@ echo "Cleaning up in $DBDIR..."
 
 rm -f $DBDIR/[!C]*
 
-echo "Running ldif2ldbm to build slapd database..."
+echo "Running slapadd to build slapd database..."
 $LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldif2ldbm failed!"
+       echo "slapadd failed!"
        exit $RC
 fi
 
index c9fbd0902911656b562b31eb14f43a093f519613..beb69b038fb4b91324d4a24b76bc3207ba017c87 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# $OpenLDAP$
 
 if test $# -eq 0 ; then
        SRCDIR="."
@@ -16,11 +17,11 @@ echo "Cleaning up in $DBDIR..."
 
 rm -f $DBDIR/[!C]*
 
-echo "Running ldif2ldbm to build slapd database..."
+echo "Running slapadd to build slapd database..."
 $LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldif2ldbm failed!"
+       echo "slapadd failed!"
        exit $RC
 fi
 
index caf0df4f8a57380dfd6b91fb357c22e869b13484..d53673ed1ca0cfef16db2ec9472528d500f79804 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# $OpenLDAP$
 
 if test $# -eq 0 ; then
        SRCDIR="."
@@ -16,11 +17,11 @@ echo "Cleaning up in $DBDIR..."
 
 rm -f $DBDIR/[!C]*
 
-echo "Running ldif2ldbm to build slapd database..."
+echo "Running slapadd to build slapd database..."
 $LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldif2ldbm failed!"
+       echo "slapadd failed!"
        exit $RC
 fi
 
@@ -31,8 +32,8 @@ echo "Testing slapd modrdn operations..."
 
 # Make sure we can search the database
 for i in 0 1 2 3 4 5; do
-       $LDAPSEARCH -s base -b "$MONITOR" -h localhost -p $PORT \
-               'objectclass=*' > /dev/null 2>&1
+       $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
+           'objectClass=*' > $INITOUT 2>&1
        RC=$?
        if test $RC = 1 ; then
                echo "Waiting 5 seconds for slapd to start..."
@@ -74,8 +75,7 @@ fi
 
 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones III)..."
 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
-           'cn=James A Jones III' | egrep -iv '^createtimestamp:|^modifytimestamp:' \
-           > $SEARCHOUT 2>&1
+           'cn=James A Jones III' > $SEARCHOUT 2>&1
 RC=$?
 if test $RC != 0 ; then
        echo "ldapsearch failed!"
@@ -102,8 +102,7 @@ fi
 
 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones II)..."
 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
-           'cn=James A Jones II' | egrep -iv '^createtimestamp:|^modifytimestamp:' \
-           >  $SEARCHOUT 2>&1
+           'cn=James A Jones II' > $SEARCHOUT 2>&1
 RC=$?
 if test $RC != 0 ; then
        echo "ldapsearch failed!"
@@ -132,14 +131,19 @@ fi
 
 echo "Using ldapsearch to retrieve entries using removed rdn (cn=James A Jones 2)..."
 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
-           'cn=James A Jones 2' | egrep -iv '^createtimestamp:|^modifytimestamp:' \
-           > /dev/null 2>&1
+           'cn=James A Jones 2' > $SEARCHOUT 2>&1
 RC=$?
-if test $RC = 0 ; then
-       echo "failure: ldapsearch found attribute that was to be removed!"
+if test $RC != 0 ; then
        kill -HUP $PID
+       echo "ldapsearch failed!"
        exit $RC
 fi
+cmp $SEARCHOUT /dev/null
+if test $? != 0 ; then
+       echo "failure: ldapsearch found attribute that was to be removed!"
+       kill -HUP $PID
+       exit 1
+fi
 
 echo "Using ldapsearch to retrieve all the entries..."
 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
@@ -183,8 +187,7 @@ fi
 
 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones 1)..."
 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
-           'cn=James A Jones 1' | egrep -iv '^createtimestamp:|^modifytimestamp:' \
-           >  $SEARCHOUT 2>&1
+           'cn=James A Jones 1' > $SEARCHOUT 2>&1
 RC=$?
 if test $RC != 0 ; then
        echo "ldapsearch failed!"
index ad866b7f1aa5f4b4ed3d8aa9e28a9a590927efd4..4b2f5b5fc0a7cb8feda5a5dfd610b4a9bcbd8df1 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# $OpenLDAP$
 
 if test $# -eq 0 ; then
        SRCDIR="."
@@ -16,11 +17,11 @@ echo "Cleaning up in $DBDIR..."
 
 rm -f $DBDIR/[!C]*
 
-echo "Running ldif2ldbm to build slapd database..."
+echo "Running slapadd to build slapd database..."
 $LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldif2ldbm failed!"
+       echo "slapadd failed!"
        exit $RC
 fi
 
index f42683199b7a56a0e35d28538b09004493bbe526..3dd64a892de511af1f43119d2f69859964bed663 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# $OpenLDAP$
 
 #
 # Test replication:
index 9644566ee760fa761a6032d39985c8228a0c4e23..ce874511aaf1bce9a7e2636ac3affcddbe2265d5 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# $OpenLDAP$
 
 if test $# -eq 0 ; then
        SRCDIR="."
@@ -19,15 +20,15 @@ echo "Cleaning up in $DBDIR..."
 
 rm -f $DBDIR/[!C]*
 
-echo "Running ldif2ldbm to build slapd database..."
+echo "Running slapadd to build slapd database..."
 $LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldif2ldbm failed!"
+       echo "slapadd failed!"
        exit $RC
 fi
 
-echo "Waiting 5 seconds for ldif2ldbm to build slapd database..."
+echo "Waiting 5 seconds for slapadd to build slapd database..."
 sleep 5
 
 echo "Starting slapd on TCP/IP port $PORT..."
index 3bc69ea74fd76e13306f8f4edc561fc0a3bf9e30..ccd848444e5682ad0117dee671e766b2c2748560 100755 (executable)
@@ -1,4 +1,5 @@
 #! /bin/sh
+# $OpenLDAP$
 
 #
 # Test default referral
@@ -21,11 +22,11 @@ echo "Cleaning up in $DBDIR and $REPLDIR ..."
 rm -f $DBDIR/[!C]*
 rm -f $REPLDIR/[!C]*
 
-echo "Running ldif2ldbm to build slapd database..."
+echo "Running slapadd to build slapd database..."
 $LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
-       echo "ldif2ldbm failed!"
+       echo "slapadd failed!"
        exit $RC
 fi