You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by gs...@locus.apache.org on 2000/12/02 17:13:51 UTC

cvs commit: apr-util/test .cvsignore Makefile.in

gstein      00/12/02 08:13:50

  Added:       .        .cvsignore Makefile.in STATUS buildconf.sh
                        configure.in
               build    .cvsignore Makefile.in install-sh rules.mk.in
               include  sdbm.h
               src      .cvsignore Makefile.in
               src/buckets .cvsignore Makefile.in
               src/crypto .cvsignore Makefile.in
               src/dbm  .cvsignore Makefile.in
               src/dbm/sdbm .cvsignore Makefile.in sdbm.c sdbm_hash.c
                        sdbm_lock.c sdbm_pair.c sdbm_pair.h sdbm_private.h
                        sdbm_tune.h
               src/encoding .cvsignore Makefile.in
               src/hooks .cvsignore Makefile.in
               src/uri  .cvsignore Makefile.in
               src/xml  .cvsignore Makefile.in
               test     .cvsignore Makefile.in
  Log:
  initial population of the APRUTIL module.
  
  *) add configure/build system
  *) add an initial directory layout (from email proposal)
  *) add the SDBM files as a quick test of the build
     [ these came from apache-2.0/src/lib/sdbm; no tag ]
  *) add an empty STATUS file for tracking the project
  
  Revision  Changes    Path
  1.1                  apr-util/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  .libs
  Makefile
  aclocal.m4
  config.cache
  config.log
  config.status
  configure
  libtool
  libaprutil.la
  
  
  
  1.1                  apr-util/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  #
  # Top-level Makefile for APRUTIL
  #
  
  TARGETS = libaprutil.la
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  SUBDIRS = src . test build
  DISTCLEAN_TARGETS = config.cache config.log config.status config.sub \
  	include/apu_config.h
  EXTRACLEAN_TARGETS = configure libtool aclocal.m4 include/apu_config.h.in
  
  ### fix this up at some point (install location)
  libdir = /usr/local/lib
  
  libaprutil.la:
  	@objects="`find src -name '*.lo'`" ; \
  	    echo $(LINK) $$objects ; \
  	    $(LINK) -rpath $(libdir) $$objects
  
  
  
  1.1                  apr-util/STATUS
  
  Index: STATUS
  ===================================================================
  APRUTIL LIBRARY STATUS:
  Last modified at [$Date: 2000/12/02 16:13:46 $]
  
  Release:
  
  RELEASE SHOWSTOPPERS:
  
      * Fill repository with code
  
  
  RELEASE NON-SHOWSTOPPERS BUT WOULD BE REAL NICE TO WRAP THESE UP:
  
  
  Documentation that needs writing:
  
      * API documentation
          Status:
  
  
  
  1.1                  apr-util/buildconf.sh
  
  Index: buildconf.sh
  ===================================================================
  #!/bin/sh
  
  #
  # Get a copy of libtool's libtool.m4 and copy it into our aclocal.m4
  #
  # If we ever have our own .m4 files, then we will want to concatenate
  # them altogether into aclocal.m4
  #
  ### we may need to get smarter with these two lines
  ltpath=`which libtoolize`
  ltpath=`dirname $ltpath`
  ltfile=`cd $ltpath/../share/aclocal ; pwd`/libtool.m4
  echo "Incorporating $ltfile into aclocal.m4 ..."
  cat $ltfile > aclocal.m4
  
  #
  # Create the libtool helper files
  #
  # Note: we always replace the files, and we copy (rather than link) them.
  #
  echo "Copying libtool helper files ..."
  $ltpath/libtoolize --force --copy
  
  #
  # Generate the autoconf header (include/apu_config.h) and ./configure
  #
  echo "Creating include/apu_config.h ..."
  autoheader
  
  echo "Creating configure ..."
  ### do some work to toss config.cache?
  autoconf
  
  
  
  1.1                  apr-util/configure.in
  
  Index: configure.in
  ===================================================================
  dnl
  dnl Process this file with autoconf to produce a configure script
  dnl
  
  AC_PREREQ(2.13)
  AC_INIT(build/rules.mk.in)
  
  AC_CONFIG_HEADER(include/apu_config.h)
  AC_CONFIG_AUX_DIR(build)
  
  AC_PROG_CC
  AC_CHECK_PROG(RM, rm, rm)
  
  dnl
  dnl figure out where APR is located
  dnl
  AC_MSG_CHECKING(for APR)
  AC_ARG_WITH(apr,
  [  --with-apr=DIR         path to APR source or the APR includes.],
  [
      if test "$withval" = "yes"; then
          AC_MSG_ERROR(You need to specify a directory with --with-apr)
      fi
      absdir="`cd $withval ; pwd`"
      if test -f "$absdir/apr_pools.h"; then
  	APR_INCLUDES="$absdir"
      elif test -f "$absdir/include/apr_pools.h"; then
  	APR_INCLUDES="$absdir/include"
      fi
  ],[
      dnl see if we can find APR
      if test -f "$srcdir/apr/include/apr_pools.h"; then
  	APR_INCLUDES="$srcdir/apr/include"
      fi
  ])
  if test -z "$APR_INCLUDES"; then
      AC_MSG_RESULT(not found)
      AC_MSG_ERROR(APR could not be located. Please use the --with-apr option.)
  fi
  AC_MSG_RESULT($APR_INCLUDES)
  
  
  dnl
  dnl compute the top directory of the build
  dnl
  top_builddir="`cd $srcdir ; pwd`"
  AC_SUBST(top_builddir)
  
  dnl
  dnl prep libtool
  dnl
  echo "performing libtool configuration..."
  AC_PROG_LIBTOOL
  
  dnl
  dnl set up the compilation flags and stuff
  dnl
  INCLUDES="-I$APR_INCLUDES -I\$(top_builddir)/include"
  
  CFLAGS="$CFLAGS $INCLUDES"
  
  
  AC_OUTPUT([
  	Makefile
  	build/Makefile
  	build/rules.mk
  	src/Makefile
  	src/buckets/Makefile
  	src/crypto/Makefile
  	src/dbm/Makefile
  	src/dbm/sdbm/Makefile
  	src/encoding/Makefile
  	src/hooks/Makefile
  	src/uri/Makefile
  	src/xml/Makefile
  	test/Makefile
  	])
  
  
  
  1.1                  apr-util/build/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  config.guess
  config.sub
  ltconfig
  ltmain.sh
  rules.mk
  
  
  
  1.1                  apr-util/build/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  EXTRACLEAN_TARGETS = config.guess config.sub ltconfig ltmain.sh rules.mk
  
  
  
  1.1                  apr-util/build/install-sh
  
  Index: install-sh
  ===================================================================
  #!/bin/sh
  ##
  ##  install.sh -- install a program, script or datafile
  ##
  ##  Based on `install-sh' from the X Consortium's X11R5 distribution
  ##  as of 89/12/18 which is freely available.
  ##  Cleaned up for Apache's Autoconf-style Interface (APACI)
  ##  by Ralf S. Engelschall <rs...@apache.org>
  ##
  #
  # This script falls under the Apache License.
  # See http://www.apache.org/docs/LICENSE
  
  
  #
  #   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}"
  
  #
  #   parse argument line
  #
  instcmd="$mvprog"
  chmodcmd=""
  chowncmd=""
  chgrpcmd=""
  stripcmd=""
  rmcmd="$rmprog -f"
  mvcmd="$mvprog"
  ext=""
  src=""
  dst=""
  while [ "x$1" != "x" ]; do
      case $1 in
          -c) instcmd="$cpprog"
              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
              ;;
          -S) stripcmd="$stripprog $2"
              shift; shift; continue
              ;;
          -e) ext="$2"
              shift; shift; continue
              ;;
          *)  if [ "x$src" = "x" ]; then
                  src=$1
              else
                  dst=$1
              fi
              shift; continue
              ;;
      esac
  done
  if [ "x$src" = "x" ]; then
       echo "install.sh: no input file specified"
       exit 1
  fi
  if [ "x$dst" = "x" ]; then
       echo "install.sh: no destination specified"
       exit 1
  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`"
  fi
  
  #  Add a possible extension (such as ".exe") to src and dst
  src="$src$ext"
  dst="$dst$ext"
  
  #  Make a temp file name in the proper directory.
  dstdir=`dirname $dst`
  dsttmp=$dstdir/#inst.$$#
  
  #  Move or copy the file name to the temp name
  $instcmd $src $dsttmp
  
  #  And set any options; do chmod last to preserve setuid bits
  if [ "x$chowncmd" != "x" ]; then $chowncmd $dsttmp; fi
  if [ "x$chgrpcmd" != "x" ]; then $chgrpcmd $dsttmp; fi
  if [ "x$stripcmd" != "x" ]; then $stripcmd $dsttmp; fi
  if [ "x$chmodcmd" != "x" ]; then $chmodcmd $dsttmp; fi
  
  #  Now rename the file to the real destination.
  $rmcmd $dst
  $mvcmd $dsttmp $dst
  
  exit 0
  
  
  
  
  1.1                  apr-util/build/rules.mk.in
  
  Index: rules.mk.in
  ===================================================================
  # ====================================================================
  # The Apache Software License, Version 1.1
  #
  # Copyright (c) 2000 The Apache Software Foundation.  All rights
  # reserved.
  #
  # Redistribution and use in source and binary forms, with or without
  # modification, are permitted provided that the following conditions
  # are met:
  #
  # 1. Redistributions of source code must retain the above copyright
  #    notice, this list of conditions and the following disclaimer.
  #
  # 2. Redistributions in binary form must reproduce the above copyright
  #    notice, this list of conditions and the following disclaimer in
  #    the documentation and/or other materials provided with the
  #    distribution.
  #
  # 3. The end-user documentation included with the redistribution,
  #    if any, must include the following acknowledgment:
  #       "This product includes software developed by the
  #        Apache Software Foundation (http://www.apache.org/)."
  #    Alternately, this acknowledgment may appear in the software itself,
  #    if and wherever such third-party acknowledgments normally appear.
  #
  # 4. The names "Apache" and "Apache Software Foundation" must
  #    not be used to endorse or promote products derived from this
  #    software without prior written permission. For written
  #    permission, please contact apache@apache.org.
  #
  # 5. Products derived from this software may not be called "Apache",
  #    nor may "Apache" appear in their name, without prior written
  #    permission of the Apache Software Foundation.
  #
  # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  # SUCH DAMAGE.
  # ====================================================================
  #
  # This software consists of voluntary contributions made by many
  # individuals on behalf of the Apache Software Foundation.  For more
  # information on the Apache Software Foundation, please see
  # <http://www.apache.org/>.
  #
  
  #
  # rules.mk: standard rules for APRUTIL
  #
  
  #
  # Configuration variables
  #
  top_builddir=@top_builddir@
  
  CC=@CC@
  LIBTOOL=@LIBTOOL@
  
  CFLAGS=@CFLAGS@
  LIBS=@LIBS@
  LDFLAGS=@LDFLAGS@
  
  RM=@RM@
  SHELL=@SHELL@
  
  ### make LTFLAGS somewhat variable?
  LTFLAGS = --silent
  
  #
  # Basic macro setup
  #
  COMPILE      = $(CC) $(CFLAGS)
  LT_COMPILE   = $(LIBTOOL) --mode=compile $(LTFLAGS) $(COMPILE) -c $< && touch $@
  
  LINK         = $(LIBTOOL) --mode=link $(LTFLAGS) $(COMPILE) $(LDFLAGS) -o $@
  
  #
  # Standard build rules
  #
  all: all-recursive
  depend: depend-recursive
  clean: clean-recursive
  distclean: distclean-recursive
  extraclean: extraclean-recursive
  
  install: all-recursive
  
  local-clean:
  	$(RM) -f *.o *.lo *.a *.la *.so $(CLEAN_TARGETS)
  	$(RM) -rf .libs
  
  
  all-recursive depend-recursive clean-recursive distclean-recursive \
    extraclean-recursive:
  	@otarget=`echo $@|sed s/-recursive//`; \
  	for i in $(SUBDIRS); do \
  	    target="$$otarget"; \
  	    echo "Making $$target in $$i"; \
  	    if test "$$i" = "."; then \
  		made_local=yes; \
  		target="local-$$target"; \
  	    fi; \
  	    (cd $$i && $(MAKE) $$target) || exit 1; \
  	done; \
          if test "$$otarget" = "all" && test -z "$(TARGETS)"; then \
  	    made_local=n/a; \
  	fi; \
  	if test -z "$$made_local"; then \
  	    $(MAKE) "local-$$otarget" || exit 1; \
  	fi
  
  # nothing to do for this target
  local-distclean: local-clean
  	$(RM) -f Makefile $(DISTCLEAN_TARGETS)
  
  local-extraclean: local-distclean
  	@if test -n "$(EXTRACLEAN_TARGETS)"; then \
  	    echo $(RM) -f $(EXTRACLEAN_TARGETS) ; \
  	    $(RM) -f $(EXTRACLEAN_TARGETS) ; \
  	fi
  
  local-all: $(TARGETS)
  
  local-depend:
  ### need something here
  
  
  #
  # Implicit rules for creating outputs from input files
  #
  .SUFFIXES:
  .SUFFIXES: .c .lo .o
  
  .c.o:
  	$(COMPILE) -c $<
  
  .c.lo:
  	$(LT_COMPILE)
  
  .PHONY: all depend clean distclean install \
  	all-recursive depend-recursive clean-recursive distclean-recursive \
  	local-all local-depend local-clean local-distclean
  
  
  
  1.1                  apr-util/include/sdbm.h
  
  Index: sdbm.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   * sdbm - ndbm work-alike hashed database library
   * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
   * author: oz@nexus.yorku.ca
   * status: ex-public domain
   */
  
  #ifndef SDBM_H
  #define SDBM_H
  
  #include "apr_errno.h"
  #include "apr_file_io.h"   /* for apr_fileperms_t */
  
  typedef struct SDBM SDBM;
  
  /* utility functions */
  int sdbm_rdonly(SDBM *db);
  int sdbm_error(SDBM *db);
  int sdbm_clearerr(SDBM *db);
  
  typedef struct {
      char *dptr;
      int dsize;
  } sdbm_datum;
  
  /* The extensions used for the database files */
  #define SDBM_DIRFEXT	".dir"
  #define SDBM_PAGFEXT	".pag"
  
  /* Standard dbm interface */
  
  apr_status_t sdbm_open(SDBM **db, const char *filename, apr_int32_t flags,
                         apr_fileperms_t perms, apr_pool_t *p);
  
  void sdbm_close(SDBM *db); /* ### should return value? */
  
  sdbm_datum sdbm_fetch(SDBM *db, sdbm_datum key);
  apr_status_t sdbm_delete(SDBM *db, const sdbm_datum key);
  
  /* * flags to sdbm_store */
  #define SDBM_INSERT	0
  #define SDBM_REPLACE	1
  apr_status_t sdbm_store(SDBM *db, sdbm_datum key, sdbm_datum value, int flags);
  sdbm_datum sdbm_firstkey(SDBM *db);
  sdbm_datum sdbm_nextkey(SDBM *db);
  
  /*
   * other
   */
  apr_status_t sdbm_prep(SDBM **db, const char *dirname, const char *pagname,
                         apr_int32_t flags, apr_fileperms_t perms,
                         apr_pool_t *pool);
  
  long sdbm_hash(const char *str, int len);
  
  #endif /* SDBM_H */
  
  
  
  1.1                  apr-util/src/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  Makefile
  
  
  
  1.1                  apr-util/src/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  SUBDIRS = buckets crypto dbm encoding hooks uri xml
  
  
  
  1.1                  apr-util/src/buckets/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  Makefile
  *.lo
  *.la
  .libs
  
  
  
  1.1                  apr-util/src/buckets/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  
  
  1.1                  apr-util/src/crypto/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  Makefile
  *.lo
  *.la
  .libs
  
  
  
  1.1                  apr-util/src/crypto/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  
  
  1.1                  apr-util/src/dbm/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  Makefile
  *.lo
  *.la
  .libs
  
  
  
  1.1                  apr-util/src/dbm/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  SUBDIRS = sdbm .
  
  
  
  1.1                  apr-util/src/dbm/sdbm/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  Makefile
  *.lo
  *.la
  .libs
  
  
  
  1.1                  apr-util/src/dbm/sdbm/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  TARGETS = sdbm.lo sdbm_hash.lo sdbm_lock.lo sdbm_pair.lo
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  
  
  1.1                  apr-util/src/dbm/sdbm/sdbm.c
  
  Index: sdbm.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   * sdbm - ndbm work-alike hashed database library
   * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
   * author: oz@nexus.yorku.ca
   * ex-public domain, ported to APR for Apache 2
   * core routines
   */
  
  
  #include "sdbm.h"
  #include "sdbm_tune.h"
  #include "sdbm_pair.h"
  #include "sdbm_private.h"
  
  #include "apr.h"
  #include "apr_file_io.h"
  #include "apr_strings.h"
  #include "apr_errno.h"
  
  #include <string.h>     /* for memset() */
  #include <stdlib.h>     /* for malloc() and free() */
  
  /*
   * forward
   */
  static int getdbit (SDBM *, long);
  static apr_status_t setdbit(SDBM *, long);
  static apr_status_t getpage(SDBM *db, long);
  static sdbm_datum getnext(SDBM *db);
  static apr_status_t makroom(SDBM *, long, int);
  
  /*
   * useful macros
   */
  #define SDBM_IOERR	0x2	       /* data base I/O error */
  
  #define bad(x)		((x).dptr == NULL || (x).dsize <= 0)
  #define exhash(item)	sdbm_hash((item).dptr, (item).dsize)
  #define ioerr(db)	((db)->flags |= SDBM_IOERR)
  
  /* ### Does anything need these externally? */
  #define sdbm_dirfno(db)	((db)->dirf)
  #define sdbm_pagfno(db)	((db)->pagf)
  
  #define OFF_PAG(off)	(apr_off_t) (off) * PBLKSIZ
  #define OFF_DIR(off)	(apr_off_t) (off) * DBLKSIZ
  
  static long masks[] = {
  	000000000000, 000000000001, 000000000003, 000000000007,
  	000000000017, 000000000037, 000000000077, 000000000177,
  	000000000377, 000000000777, 000000001777, 000000003777,
  	000000007777, 000000017777, 000000037777, 000000077777,
  	000000177777, 000000377777, 000000777777, 000001777777,
  	000003777777, 000007777777, 000017777777, 000037777777,
  	000077777777, 000177777777, 000377777777, 000777777777,
  	001777777777, 003777777777, 007777777777, 017777777777
  };
  
  const sdbm_datum sdbm_nullitem = { NULL, 0 };
  
  static apr_status_t database_cleanup(void *data)
  {
      SDBM *db = data;
  
      (void) apr_close(db->dirf);
      (void) sdbm_unlock(db);
      (void) apr_close(db->pagf);
      free(db);
  
      return APR_SUCCESS;
  }
  
  apr_status_t
  sdbm_open(SDBM **db, const char *file, apr_int32_t flags, apr_fileperms_t perms, apr_pool_t *p)
  {
      char *dirname = apr_pstrcat(p, file, SDBM_DIRFEXT, NULL);
      char *pagname = apr_pstrcat(p, file, SDBM_PAGFEXT, NULL);
      
      return sdbm_prep(db, dirname, pagname, flags, perms, p);
  }
  
  apr_status_t
  sdbm_prep(SDBM **pdb, const char *dirname, const char *pagname, 
  	  apr_int32_t flags, apr_fileperms_t perms, apr_pool_t *p)
  {
          SDBM *db;
          apr_finfo_t finfo;
  	apr_status_t status;
  
          *pdb = NULL;
  
  	db = malloc(sizeof(*db));
          memset(db, 0, sizeof(*db));
  
  	db->pool = p;
  
          /*
           * adjust user flags so that WRONLY becomes RDWR, 
           * as required by this package. Also set our internal
           * flag for RDONLY if needed.
           */
  	if (!(flags & APR_WRITE)) {
  	    db->flags = SDBM_RDONLY;
  	}
  
  	flags |= APR_BINARY | APR_READ;
  
          /*
           * open the files in sequence, and stat the dirfile.
           * If we fail anywhere, undo everything, return NULL.
           */
  
  	if ((status = apr_open(&db->pagf, pagname, flags, perms, p))
  	    != APR_SUCCESS)
              goto error;
  
          if ((status = sdbm_lock(db)) != APR_SUCCESS)
              goto error;
  
          if ((status = apr_open(&db->dirf, dirname, flags, perms, p))
              != APR_SUCCESS)
              goto error;
  
          /*
           * need the dirfile size to establish max bit number.
           */
          if ((status = apr_getfileinfo(&finfo, db->dirf)) != APR_SUCCESS)
              goto error;
  
          /*
           * zero size: either a fresh database, or one with a single,
           * unsplit data page: dirpage is all zeros.
           */
          db->dirbno = (!finfo.size) ? 0 : -1;
          db->pagbno = -1;
          db->maxbno = finfo.size * BYTESIZ;
  
          /* (apr_pcalloc zeroed the buffers) */
  
          /* make sure that we close the database at some point */
          apr_register_cleanup(p, db, database_cleanup, apr_null_cleanup);
  
          /* Done! */
          *pdb = db;
          return APR_SUCCESS;
  
    error:
          if (db->dirf != NULL)
              (void) apr_close(db->dirf);
          if (db->pagf != NULL) {
              (void) sdbm_unlock(db);
              (void) apr_close(db->dirf);
          }
          free(db);
          return status;
  }
  
  void
  sdbm_close(SDBM *db)
  {
      (void) apr_run_cleanup(db->pool, db, database_cleanup);
  }
  
  sdbm_datum
  sdbm_fetch(SDBM *db, sdbm_datum key)
  {
  	if (db == NULL || bad(key))
  		return sdbm_nullitem;
  
  	if (getpage(db, exhash(key)) == APR_SUCCESS)
  		return getpair(db->pagbuf, key);
  
  	ioerr(db);
  	return sdbm_nullitem;
  }
  
  static apr_status_t write_page(SDBM *db, const char *buf, long pagno)
  {
      apr_status_t status;
      apr_off_t off = OFF_PAG(pagno);
      
      if ((status = apr_seek(db->pagf, APR_SET, &off)) != APR_SUCCESS ||
  	(status = apr_full_write(db->pagf, buf, PBLKSIZ, NULL)) != APR_SUCCESS) {
  	ioerr(db);
  	return status;
      }
      
      return APR_SUCCESS;
  }
  
  apr_status_t
  sdbm_delete(SDBM *db, const sdbm_datum key)
  {
  	apr_status_t status;
  
  	if (db == NULL || bad(key))
  		return APR_EINVAL;
  	if (sdbm_rdonly(db))
  		return APR_EINVAL;
  
  	if (getpage(db, exhash(key)) == APR_SUCCESS) {
  		if (!delpair(db->pagbuf, key))
  			return -1;
  /*
   * update the page file
   */
  		if ((status = write_page(db, db->pagbuf, db->pagbno)) != APR_SUCCESS)
  		    return status;
  
  
  		return APR_SUCCESS;
  	}
  
  	ioerr(db);
  	return APR_EACCES;
  }
  
  apr_status_t sdbm_store(SDBM *db, sdbm_datum key, sdbm_datum val, int flags)
  {
  	int need;
  	register long hash;
  	apr_status_t status;
  
  	if (db == NULL || bad(key))
  		return APR_EINVAL;
  	if (sdbm_rdonly(db))
  		return APR_EINVAL;
  
  	need = key.dsize + val.dsize;
  /*
   * is the pair too big (or too small) for this database ??
   */
  	if (need < 0 || need > PAIRMAX)
  		return APR_EINVAL;
  
  	if ((status = getpage(db, (hash = exhash(key)))) == APR_SUCCESS) {
  
  /*
   * if we need to replace, delete the key/data pair
   * first. If it is not there, ignore.
   */
  		if (flags == SDBM_REPLACE)
  			(void) delpair(db->pagbuf, key);
  #ifdef SEEDUPS
  		else if (duppair(db->pagbuf, key))
  			return APR_EEXIST;
  #endif
  /*
   * if we do not have enough room, we have to split.
   */
  		if (!fitpair(db->pagbuf, need))
  		    if ((status = makroom(db, hash, need)) != APR_SUCCESS)
  			return status;
  /*
   * we have enough room or split is successful. insert the key,
   * and update the page file.
   */
  		(void) putpair(db->pagbuf, key, val);
  
  		if ((status = write_page(db, db->pagbuf, db->pagbno)) != APR_SUCCESS)
  		    return status;
  
  	/*
  	 * success
  	 */
  		return APR_SUCCESS;
  	}
  	
  	ioerr(db);
  	return status;
  }
  
  /*
   * makroom - make room by splitting the overfull page
   * this routine will attempt to make room for SPLTMAX times before
   * giving up.
   */
  static apr_status_t
  makroom(SDBM *db, long hash, int need)
  {
  	long newp;
  	char twin[PBLKSIZ];
  	char *pag = db->pagbuf;
  	char *new = twin;
  	register int smax = SPLTMAX;
  	apr_status_t status;
  
  	do {
  /*
   * split the current page
   */
  		(void) splpage(pag, new, db->hmask + 1);
  /*
   * address of the new page
   */
  		newp = (hash & db->hmask) | (db->hmask + 1);
  
  /*
   * write delay, read avoidence/cache shuffle:
   * select the page for incoming pair: if key is to go to the new page,
   * write out the previous one, and copy the new one over, thus making
   * it the current page. If not, simply write the new page, and we are
   * still looking at the page of interest. current page is not updated
   * here, as sdbm_store will do so, after it inserts the incoming pair.
   */
  		if (hash & (db->hmask + 1)) {
  		    if ((status = write_page(db, db->pagbuf, db->pagbno)) != APR_SUCCESS)
  			return status;
  			    
  		    db->pagbno = newp;
  		    (void) memcpy(pag, new, PBLKSIZ);
  		}
  		else {
  		    if ((status = write_page(db, new, newp)) != APR_SUCCESS)
  			return status;
  		}
  
  		if ((status = setdbit(db, db->curbit)) != APR_SUCCESS)
  		    return status;
  /*
   * see if we have enough room now
   */
  		if (fitpair(pag, need))
  		    return APR_SUCCESS;
  /*
   * try again... update curbit and hmask as getpage would have
   * done. because of our update of the current page, we do not
   * need to read in anything. BUT we have to write the current
   * [deferred] page out, as the window of failure is too great.
   */
  		db->curbit = 2 * db->curbit +
  			((hash & (db->hmask + 1)) ? 2 : 1);
  		db->hmask |= db->hmask + 1;
  		
  		if ((status = write_page(db, db->pagbuf, db->pagbno))
  		    != APR_SUCCESS)
  		    return status;
  		
  	} while (--smax);
  /*
   * if we are here, this is real bad news. After SPLTMAX splits,
   * we still cannot fit the key. say goodnight.
   */
  #if 0
  	(void) write(2, "sdbm: cannot insert after SPLTMAX attempts.\n", 44);
  #endif
  	/* ### ENOSPC not really appropriate but better than nothing */
  	return APR_ENOSPC;
  
  }
  
  /* Reads 'len' bytes from file 'f' at offset 'off' into buf.
   * 'off' is given relative to the start of the file.
   * If EOF is returned while reading, this is taken as success.
   */
  static apr_status_t read_from(apr_file_t *f, void *buf, 
  			     apr_off_t off, apr_size_t len)
  {
      apr_status_t status;
  
      if ((status = apr_seek(f, APR_SET, &off)) != APR_SUCCESS ||
  	((status = apr_full_read(f, buf, len, NULL)) != APR_SUCCESS)) {
  	/* if EOF is reached, pretend we read all zero's */
  	if (status == APR_EOF) {
  	    memset(buf, 0, len);
  	    status = APR_SUCCESS;
  	}
  	return status;
      }
  
      return APR_SUCCESS;
  }
  
  /*
   * the following two routines will break if
   * deletions aren't taken into account. (ndbm bug)
   */
  sdbm_datum
  sdbm_firstkey(SDBM *db)
  {
  /*
   * start at page 0
   */
  	if (read_from(db->pagf, db->pagbuf, OFF_PAG(0), PBLKSIZ) != APR_SUCCESS) {
  	    ioerr(db);
  	    return sdbm_nullitem;
  	}
  
  	db->pagbno = 0;
  	db->blkptr = 0;
  	db->keyptr = 0;
  
  	return getnext(db);
  }
  
  sdbm_datum
  sdbm_nextkey(SDBM *db)
  {
  	return getnext(db);
  }
  
  /*
   * all important binary tree traversal
   */
  static apr_status_t
  getpage(SDBM *db, long hash)
  {
  	register int hbit;
  	register long dbit;
  	register long pagb;
  	apr_status_t status;
  
  	dbit = 0;
  	hbit = 0;
  	while (dbit < db->maxbno && getdbit(db, dbit))
  		dbit = 2 * dbit + ((hash & (1 << hbit++)) ? 2 : 1);
  
  	debug(("dbit: %d...", dbit));
  
  	db->curbit = dbit;
  	db->hmask = masks[hbit];
  
  	pagb = hash & db->hmask;
  /*
   * see if the block we need is already in memory.
   * note: this lookaside cache has about 10% hit rate.
   */
  	if (pagb != db->pagbno) { 
  /*
   * note: here, we assume a "hole" is read as 0s.
   * if not, must zero pagbuf first.
   * ### joe: this assumption was surely never correct? but
   * ### we make it so in read_from anyway.
   */
  		if ((status = read_from(db->pagf, db->pagbuf, OFF_PAG(pagb), PBLKSIZ)) 
  		    != APR_SUCCESS) {
  		    ioerr(db);		    
  		    return status;
  		}
  
  		if (!chkpage(db->pagbuf))
  		    return APR_ENOSPC; /* ### better error? */
  		db->pagbno = pagb;
  
  		debug(("pag read: %d\n", pagb));
  	}
  	return APR_SUCCESS;
  }
  
  static int
  getdbit(SDBM *db, long dbit)
  {
  	register long c;
  	register long dirb;
  
  	c = dbit / BYTESIZ;
  	dirb = c / DBLKSIZ;
  
  	if (dirb != db->dirbno) {
  		if (read_from(db->dirf, db->dirbuf, OFF_DIR(dirb), DBLKSIZ)
  		    != APR_SUCCESS)
  		    return 0;
  
  		db->dirbno = dirb;
  
  		debug(("dir read: %d\n", dirb));
  	}
  
  	return db->dirbuf[c % DBLKSIZ] & (1 << dbit % BYTESIZ);
  }
  
  static apr_status_t
  setdbit(SDBM *db, long dbit)
  {
  	register long c;
  	register long dirb;
  	apr_status_t status;
  	apr_off_t off;
  
  	c = dbit / BYTESIZ;
  	dirb = c / DBLKSIZ;
  
  	if (dirb != db->dirbno) {
  	    if ((status = read_from(db->dirf, db->dirbuf, OFF_DIR(dirb), DBLKSIZ))
  		!= APR_SUCCESS)
  		return status;
  
  	    db->dirbno = dirb;
  	    
  	    debug(("dir read: %d\n", dirb));
  	}
  
  	db->dirbuf[c % DBLKSIZ] |= (1 << dbit % BYTESIZ);
  
  	if (dbit >= db->maxbno)
  		db->maxbno += DBLKSIZ * BYTESIZ;
  
  	off = OFF_DIR(dirb);
  	if (((status = apr_seek(db->dirf, APR_SET, &off)) != APR_SUCCESS)
  	    || (status = apr_full_write(db->dirf, db->dirbuf, DBLKSIZ,
                                         NULL)) != APR_SUCCESS) {
  	    return status;
          }
  
  	return APR_SUCCESS;
  }
  
  /*
   * getnext - get the next key in the page, and if done with
   * the page, try the next page in sequence
   */
  static sdbm_datum
  getnext(SDBM *db)
  {
  	sdbm_datum key;
  
  	for (;;) {
  		db->keyptr++;
  		key = getnkey(db->pagbuf, db->keyptr);
  		if (key.dptr != NULL)
  			return key;
  /*
   * we either run out, or there is nothing on this page..
   * try the next one... If we lost our position on the
   * file, we will have to seek.
   */
  		db->keyptr = 0;
  		if (db->pagbno != db->blkptr++) {
  		    apr_off_t off = OFF_PAG(db->blkptr);
  		    if (apr_seek(db->pagf, APR_SET, &off) != APR_SUCCESS)
  			break;
  		}
  
  		db->pagbno = db->blkptr;
  		/* ### EOF acceptable here too? */
  		if (apr_full_read(db->pagf, db->pagbuf, PBLKSIZ, NULL) != APR_SUCCESS)
  			break;
  		if (!chkpage(db->pagbuf))
  			break;
  	}
  		
  	ioerr(db);
  	return sdbm_nullitem;
  }
  
  
  int sdbm_rdonly(SDBM *db)
  {
      return ((db)->flags & SDBM_RDONLY);
  }
  
  int sdbm_error(SDBM *db)
  {
      return ((db)->flags & SDBM_IOERR);
  }
  
  int sdbm_clearerr(SDBM *db)
  {
      return ((db)->flags &= ~SDBM_IOERR);  /* ouch */
  }
  
  
  
  1.1                  apr-util/src/dbm/sdbm/sdbm_hash.c
  
  Index: sdbm_hash.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   * sdbm - ndbm work-alike hashed database library
   * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
   * author: oz@nexus.yorku.ca
   * status: ex-public domain. keep it that way.
   *
   * hashing routine
   */
  
  #include "sdbm.h"
  
  /*
   * polynomial conversion ignoring overflows
   * [this seems to work remarkably well, in fact better
   * then the ndbm hash function. Replace at your own risk]
   * use: 65599	nice.
   *      65587   even better. 
   */
  long sdbm_hash(const char *str, int len)
  {
  	register unsigned long n = 0;
  
  #define DUFF	/* go ahead and use the loop-unrolled version */
  #ifdef DUFF
  
  #define HASHC	n = *str++ + 65599 * n
  
  	if (len > 0) {
  		register int loop = (len + 8 - 1) >> 3;
  
  		switch(len & (8 - 1)) {
  		case 0:	do {
  			HASHC;	case 7:	HASHC;
  		case 6:	HASHC;	case 5:	HASHC;
  		case 4:	HASHC;	case 3:	HASHC;
  		case 2:	HASHC;	case 1:	HASHC;
  			} while (--loop);
  		}
  
  	}
  #else
  	while (len--)
  		n = *str++ + 65599 * n;
  #endif
  	return n;
  }
  
  
  
  1.1                  apr-util/src/dbm/sdbm/sdbm_lock.c
  
  Index: sdbm_lock.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr_file_io.h"
  
  #include "sdbm.h"
  #include "sdbm_private.h"
  
  /* NOTE: this function blocks until it acquires the lock */
  apr_status_t sdbm_lock(SDBM *db)
  {
      int type;
  
      if ((db->flags & SDBM_RDONLY) == 0)
          type = APR_FLOCK_EXCLUSIVE;
      else
          type = APR_FLOCK_SHARED;
  
      return apr_lock_file(db->pagf, type);
  }
  
  apr_status_t sdbm_unlock(SDBM *db)
  {
      return apr_unlock_file(db->pagf);
  }
  
  
  
  1.1                  apr-util/src/dbm/sdbm/sdbm_pair.c
  
  Index: sdbm_pair.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   * sdbm - ndbm work-alike hashed database library
   * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
   * author: oz@nexus.yorku.ca
   * status: ex-public domain.
   *
   * page-level routines
   */
  
  #include "sdbm.h"
  #include "sdbm_tune.h"
  #include "sdbm_pair.h"
  #include "sdbm_private.h"
  
  #include <string.h>	/* for memset() */
  
  
  #define exhash(item)	sdbm_hash((item).dptr, (item).dsize)
  
  /* 
   * forward 
   */
  static int seepair(char *, int, char *, int);
  
  /*
   * page format:
   *	+------------------------------+
   * ino	| n | keyoff | datoff | keyoff |
   * 	+------------+--------+--------+
   *	| datoff | - - - ---->	       |
   *	+--------+---------------------+
   *	|	 F R E E A R E A       |
   *	+--------------+---------------+
   *	|  <---- - - - | data          |
   *	+--------+-----+----+----------+
   *	|  key   | data     | key      |
   *	+--------+----------+----------+
   *
   * calculating the offsets for free area:  if the number
   * of entries (ino[0]) is zero, the offset to the END of
   * the free area is the block size. Otherwise, it is the
   * nth (ino[ino[0]]) entry's offset.
   */
  
  int
  fitpair(pag, need)
  char *pag;
  int need;
  {
  	register int n;
  	register int off;
  	register int avail;
  	register short *ino = (short *) pag;
  
  	off = ((n = ino[0]) > 0) ? ino[n] : PBLKSIZ;
  	avail = off - (n + 1) * sizeof(short);
  	need += 2 * sizeof(short);
  
  	debug(("avail %d need %d\n", avail, need));
  
  	return need <= avail;
  }
  
  void
  putpair(pag, key, val)
  char *pag;
  sdbm_datum key;
  sdbm_datum val;
  {
  	register int n;
  	register int off;
  	register short *ino = (short *) pag;
  
  	off = ((n = ino[0]) > 0) ? ino[n] : PBLKSIZ;
  /*
   * enter the key first
   */
  	off -= key.dsize;
  	(void) memcpy(pag + off, key.dptr, key.dsize);
  	ino[n + 1] = off;
  /*
   * now the data
   */
  	off -= val.dsize;
  	(void) memcpy(pag + off, val.dptr, val.dsize);
  	ino[n + 2] = off;
  /*
   * adjust item count
   */
  	ino[0] += 2;
  }
  
  sdbm_datum
  getpair(pag, key)
  char *pag;
  sdbm_datum key;
  {
  	register int i;
  	register int n;
  	sdbm_datum val;
  	register short *ino = (short *) pag;
  
  	if ((n = ino[0]) == 0)
  		return sdbm_nullitem;
  
  	if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0)
  		return sdbm_nullitem;
  
  	val.dptr = pag + ino[i + 1];
  	val.dsize = ino[i] - ino[i + 1];
  	return val;
  }
  
  #ifdef SEEDUPS
  int
  duppair(pag, key)
  char *pag;
  sdbm_datum key;
  {
  	register short *ino = (short *) pag;
  	return ino[0] > 0 && seepair(pag, ino[0], key.dptr, key.dsize) > 0;
  }
  #endif
  
  sdbm_datum
  getnkey(pag, num)
  char *pag;
  int num;
  {
  	sdbm_datum key;
  	register int off;
  	register short *ino = (short *) pag;
  
  	num = num * 2 - 1;
  	if (ino[0] == 0 || num > ino[0])
  		return sdbm_nullitem;
  
  	off = (num > 1) ? ino[num - 1] : PBLKSIZ;
  
  	key.dptr = pag + ino[num];
  	key.dsize = off - ino[num];
  
  	return key;
  }
  
  int
  delpair(pag, key)
  char *pag;
  sdbm_datum key;
  {
  	register int n;
  	register int i;
  	register short *ino = (short *) pag;
  
  	if ((n = ino[0]) == 0)
  		return 0;
  
  	if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0)
  		return 0;
  /*
   * found the key. if it is the last entry
   * [i.e. i == n - 1] we just adjust the entry count.
   * hard case: move all data down onto the deleted pair,
   * shift offsets onto deleted offsets, and adjust them.
   * [note: 0 < i < n]
   */
  	if (i < n - 1) {
  		register int m;
  		register char *dst = pag + (i == 1 ? PBLKSIZ : ino[i - 1]);
  		register char *src = pag + ino[i + 1];
  		register int   zoo = dst - src;
  
  		debug(("free-up %d ", zoo));
  /*
   * shift data/keys down
   */
  		m = ino[i + 1] - ino[n];
  
  #undef DUFF	/* just use memmove. it should be plenty fast. */
  #ifdef DUFF
  #define MOVB 	*--dst = *--src
  
  		if (m > 0) {
  			register int loop = (m + 8 - 1) >> 3;
  
  			switch (m & (8 - 1)) {
  			case 0:	do {
  				MOVB;	case 7:	MOVB;
  			case 6:	MOVB;	case 5:	MOVB;
  			case 4:	MOVB;	case 3:	MOVB;
  			case 2:	MOVB;	case 1:	MOVB;
  				} while (--loop);
  			}
  		}
  #else
  		dst -= m;
  		src -= m;
  		memmove(dst, src, m);
  #endif
  
  /*
   * adjust offset index up
   */
  		while (i < n - 1) {
  			ino[i] = ino[i + 2] + zoo;
  			i++;
  		}
  	}
  	ino[0] -= 2;
  	return 1;
  }
  
  /*
   * search for the key in the page.
   * return offset index in the range 0 < i < n.
   * return 0 if not found.
   */
  static int
  seepair(pag, n, key, siz)
  char *pag;
  register int n;
  register char *key;
  register int siz;
  {
  	register int i;
  	register int off = PBLKSIZ;
  	register short *ino = (short *) pag;
  
  	for (i = 1; i < n; i += 2) {
  		if (siz == off - ino[i] &&
  		    memcmp(key, pag + ino[i], siz) == 0)
  			return i;
  		off = ino[i + 1];
  	}
  	return 0;
  }
  
  void
  splpage(pag, new, sbit)
  char *pag;
  char *new;
  long sbit;
  {
  	sdbm_datum key;
  	sdbm_datum val;
  
  	register int n;
  	register int off = PBLKSIZ;
  	char cur[PBLKSIZ];
  	register short *ino = (short *) cur;
  
  	(void) memcpy(cur, pag, PBLKSIZ);
  	(void) memset(pag, 0, PBLKSIZ);
  	(void) memset(new, 0, PBLKSIZ);
  
  	n = ino[0];
  	for (ino++; n > 0; ino += 2) {
  		key.dptr = cur + ino[0]; 
  		key.dsize = off - ino[0];
  		val.dptr = cur + ino[1];
  		val.dsize = ino[0] - ino[1];
  /*
   * select the page pointer (by looking at sbit) and insert
   */
  		(void) putpair((exhash(key) & sbit) ? new : pag, key, val);
  
  		off = ino[1];
  		n -= 2;
  	}
  
  	debug(("%d split %d/%d\n", ((short *) cur)[0] / 2, 
  	       ((short *) new)[0] / 2,
  	       ((short *) pag)[0] / 2));
  }
  
  /*
   * check page sanity: 
   * number of entries should be something
   * reasonable, and all offsets in the index should be in order.
   * this could be made more rigorous.
   */
  int
  chkpage(pag)
  char *pag;
  {
  	register int n;
  	register int off;
  	register short *ino = (short *) pag;
  
  	if ((n = ino[0]) < 0 || n > PBLKSIZ / sizeof(short))
  		return 0;
  
  	if (n > 0) {
  		off = PBLKSIZ;
  		for (ino++; n > 0; ino += 2) {
  			if (ino[0] > off || ino[1] > off ||
  			    ino[1] > ino[0])
  				return 0;
  			off = ino[1];
  			n -= 2;
  		}
  	}
  	return 1;
  }
  
  
  
  1.1                  apr-util/src/dbm/sdbm/sdbm_pair.h
  
  Index: sdbm_pair.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef SDBM_PAIR_H
  #define SDBM_PAIR_H
  
  /* Mini EMBED (pair.c) */
  #define chkpage sdbm__chkpage
  #define delpair sdbm__delpair
  #define duppair sdbm__duppair
  #define fitpair sdbm__fitpair
  #define getnkey sdbm__getnkey
  #define getpair sdbm__getpair
  #define putpair sdbm__putpair
  #define splpage sdbm__splpage
  
  int fitpair(char *, int);
  void  putpair(char *, sdbm_datum, sdbm_datum);
  sdbm_datum getpair(char *, sdbm_datum);
  int  delpair(char *, sdbm_datum);
  int  chkpage (char *);
  sdbm_datum getnkey(char *, int);
  void splpage(char *, char *, long);
  #ifdef SEEDUPS
  int duppair(char *, sdbm_datum);
  #endif
  
  #endif /* SDBM_PAIR_H */
  
  
  
  
  1.1                  apr-util/src/dbm/sdbm/sdbm_private.h
  
  Index: sdbm_private.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   * sdbm - ndbm work-alike hashed database library
   * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
   * author: oz@nexus.yorku.ca
   */
  
  #ifndef SDBM_PRIVATE_H
  #define SDBM_PRIVATE_H
  
  #include "apr.h"
  #include "apr_pools.h"
  #include "apr_file_io.h"
  #include "apr_errno.h" /* for apr_status_t */
  
  /* increase the block/page size and what can be inserted */
  
  #if 1
  #define DBLKSIZ 16384
  #define PBLKSIZ 8192
  #define PAIRMAX 8008			/* arbitrary on PBLKSIZ-N */
  #else
  #define DBLKSIZ 4096
  #define PBLKSIZ 1024
  #define PAIRMAX 1008			/* arbitrary on PBLKSIZ-N */
  #endif
  #define SPLTMAX	10			/* maximum allowed splits */
  
  /* for SDBM.flags */
  #define SDBM_RDONLY	0x1	       /* data base open read-only */
  					/* for a single insertion */
  struct SDBM {
      apr_pool_t *pool;
      apr_file_t *dirf;		       /* directory file descriptor */
      apr_file_t *pagf;		       /* page file descriptor */
      apr_int32_t flags;		       /* status/error flags, see below */
      long maxbno;		       /* size of dirfile in bits */
      long curbit;		       /* current bit number */
      long hmask;			       /* current hash mask */
      long blkptr;		       /* current block for nextkey */
      int keyptr;			       /* current key for nextkey */
      long blkno;			       /* current page to read/write */
      long pagbno;		       /* current page in pagbuf */
      char pagbuf[PBLKSIZ];	       /* page file block buffer */
      long dirbno;		       /* current block in dirbuf */
      char dirbuf[DBLKSIZ];	       /* directory file block buffer */
  };
  
  apr_status_t sdbm_lock(SDBM *db);
  apr_status_t sdbm_unlock(SDBM *db);
  
  extern const sdbm_datum sdbm_nullitem;
  
  #endif /* SDBM_PRIVATE_H */
  
  
  
  1.1                  apr-util/src/dbm/sdbm/sdbm_tune.h
  
  Index: sdbm_tune.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   * sdbm - ndbm work-alike hashed database library
   * tuning and portability constructs [not nearly enough]
   * author: oz@nexus.yorku.ca
   */
  
  #ifndef SDBM_TUNE_H
  #define SDBM_TUNE_H
  
  #include "apr_errno.h"
  
  /* ### this might be better off as sizeof(char *) */
  #define BYTESIZ		8
  
  /*
   * important tuning parms (hah)
   */
  
  #define SEEDUPS			/* always detect duplicates */
  #define BADMESS			/* generate a message for worst case:
  				   cannot make room after SPLTMAX splits */
  /*
   * misc
   */
  #ifdef DEBUG
  #define debug(x)	printf x
  #else
  #define debug(x)
  #endif
  
  apr_status_t sdbm_fd_lock(int fd, int readonly);
  apr_status_t sdbm_fd_unlock(int fd);
  
  #endif /* SDBM_TUNE_H */
  
  
  
  1.1                  apr-util/src/encoding/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  Makefile
  *.lo
  *.la
  .libs
  
  
  
  1.1                  apr-util/src/encoding/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  
  
  1.1                  apr-util/src/hooks/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  Makefile
  *.lo
  *.la
  .libs
  
  
  
  1.1                  apr-util/src/hooks/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  
  
  1.1                  apr-util/src/uri/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  Makefile
  *.lo
  *.la
  .libs
  
  
  
  1.1                  apr-util/src/uri/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  
  
  1.1                  apr-util/src/xml/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  Makefile
  *.lo
  *.la
  .libs
  
  
  
  1.1                  apr-util/src/xml/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  
  
  1.1                  apr-util/test/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  Makefile
  *.lo
  *.la
  .libs
  
  
  
  1.1                  apr-util/test/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  top_builddir = @top_builddir@
  include $(top_builddir)/build/rules.mk
  
  
  

Re: use of libtool

Posted by Greg Stein <gs...@lyra.org>.
On Sat, Dec 02, 2000 at 02:59:03PM -0800, rbb@covalent.net wrote:
>...
> > Nope. The .so files are standard .so files. Anybody can use and link against
> > them, just like every other .so file.
> 
> Okay, my comments came from reading the libtool manual,

Hey... nobody can dis you for reading the manual. Most of us don't. :-)

> but if you have real-world experience with this,

Insofar as working on Subversion for the past five/six months, which also
uses libtool. That wouldn't be a big deal, but I had to wrestle with
integrating Neon and Expat(-lite) into the build, and figuring out how to
properly set up the linking against those (embedded) libs. The other
suicide-inducing involvement with libtool was trying to get a module built
and installed into Apache (as both static-link and dynamic-load). The latter
is why I believe Apache could possibly simplify module writers' experiences
by using something that only builds DSOs (rather than full shared libs).

> lets just use libtool.

Coolness.

Any other concerns out there, people?

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: use of libtool

Posted by Greg Stein <gs...@lyra.org>.
On Mon, Dec 04, 2000 at 11:42:06PM +0100, Branko Cibej wrote:
> Greg Stein wrote:
>...
> > Sure, we'd get it to work on Linux and *BSD. Possily a Solaris and AIX box.
> > But the rest? Eek.
> 
> You're an optimist. AIX already gets a few eeks from me. Non-ELF 
> platforms are mostly goblins. :-)

Oh, I completely agree with you. But we'd end up with AIX support because a
good number of Apache/APR developers are at IBM and they keep the AIX stuff
running properly.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: use of libtool

Posted by Branko Čibej <br...@xbc.nu>.
Greg Stein wrote:

> I think we're going to have to / want to use libtool there, too. libtool
> already does it correctly for each platform, and I would *not* be confident
> in the slightest of us getting it right. It wouldn't be "a simple shell
> script"... I know that much.

+1 on using libtool. I have the same experiences as Greg here -- an 
embedder can always use the files in .libs. Let's not reinvent the wheel 
here.

> Sure, we'd get it to work on Linux and *BSD. Possily a Solaris and AIX box.
> But the rest? Eek.

You're an optimist. AIX already gets a few eeks from me. Non-ELF 
platforms are mostly goblins. :-)

-- 
Brane Čibej
    home:   <br...@xbc.nu>             http://www.xbc.nu/brane/
    work:   <br...@hermes.si>   http://www.hermes-softlab.com/
     ACM:   <br...@acm.org>            http://www.acm.org/



Re: use of libtool

Posted by rb...@covalent.net.
> > The problem is that a libtool .so file, AFAIK, is not the same as a
> > regular .so file.
> 
> It is the same as a .so file:
> 
> [gstein@kurgan apr-util]$ file .libs/libaprutil.so.0.0.0
> .libs/libaprutil.so.0.0.0: ELF 32-bit LSB shared object, Intel 80386, version 1, not stripped
> [gstein@kurgan apr-util]$
> 
> > It is a hack so that the same thing works on all
> > platforms.
> 
> They do a bunch of stuff to get shared libs working wherever possible. On
> platforms that don't support them at all, then some magic occurs. Don't ask
> me what because I haven't seen that (because those platforms are relatively
> rare nowadays). The libtool manual probably describes this well.
> 
> > I do not believe that libtool .so files work when the program
> > using them is not using libtool, so this would limit apr-utils usefulness
> > to just programs using libtool.  I would much prefer to not have that
> > limitation.
> 
> Nope. The .so files are standard .so files. Anybody can use and link against
> them, just like every other .so file.

Okay, my comments came from reading the libtool manual, but if you have
real-world experience with this, lets just use libtool.

Ryan


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: use of libtool

Posted by Greg Stein <gs...@lyra.org>.
On Sat, Dec 02, 2000 at 02:09:29PM -0800, rbb@covalent.net wrote:
>...
> > Well, unlike Apache, we need to be able to create a shared library for
> > consumption by other programs. (Apache only needs dynamic-load modules) To
> > build a shared library, libtool is the best available option.
> > 
> > At install time, libtool will spit out the right files: there will be a .a
> > file, a versioned .so file (e.g. libaprutil.so.x.y.z), and the symlinks for
> > the other .so files (libaprutil.so.x and libaprutil.so). It will also drop a
> > .la file into the install area, but that isn't a big deal.
> 
> The problem is that a libtool .so file, AFAIK, is not the same as a
> regular .so file.

It is the same as a .so file:

[gstein@kurgan apr-util]$ file .libs/libaprutil.so.0.0.0
.libs/libaprutil.so.0.0.0: ELF 32-bit LSB shared object, Intel 80386, version 1, not stripped
[gstein@kurgan apr-util]$

> It is a hack so that the same thing works on all
> platforms.

They do a bunch of stuff to get shared libs working wherever possible. On
platforms that don't support them at all, then some magic occurs. Don't ask
me what because I haven't seen that (because those platforms are relatively
rare nowadays). The libtool manual probably describes this well.

> I do not believe that libtool .so files work when the program
> using them is not using libtool, so this would limit apr-utils usefulness
> to just programs using libtool.  I would much prefer to not have that
> limitation.

Nope. The .so files are standard .so files. Anybody can use and link against
them, just like every other .so file.

> APR is going to need to build a shared library at some point,

Yup. Most definitely. (this is also the basis of some of my complains with
OtherBill's unicode-fs stuff, but I think we worked out what to do)

> and I hope
> we don't use libtool there either.  I would prefer to invest the
> time/energy into just doing this correctly on each platform.  I would
> think this could be accomplished with a simple shell script to call the
> correct programs from within the Makefiles.

I think we're going to have to / want to use libtool there, too. libtool
already does it correctly for each platform, and I would *not* be confident
in the slightest of us getting it right. It wouldn't be "a simple shell
script"... I know that much.

Sure, we'd get it to work on Linux and *BSD. Possily a Solaris and AIX box.
But the rest? Eek.

> I dislike forcing people to use a work around to embed our library in
> their project.  Didn't Apache 1.3 solve this problem once?  Can we
> leverage that code?

Apache 1.3 never builds as a shared library, so I'm not sure whether the
situation is analogous. Note: I wouldn't call it a "workaround". It is
straightforward if your app uses libtool, or you look in apr-util/.libs/ if
you don't use libtool. Nothing fancy or awkward.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: use of libtool (was: Re: cvs commit: apr-util/test .cvsignore Makefile.in)

Posted by rb...@covalent.net.
> > > Note that it uses autoconf and libtool. It isn't complicated enough for
> > > automake, so I didn't bother. The build stuff is also greatly simplified
> > > over those in APR and Apache. A single build/rules.mk and teeny makefiles
> > > throughout.
> > 
> > I would really prefer to not use libtool.  This is meant to be a library
> > that is useful to external projects.  Apache has had some real problems
> > using libtool, and it is impossible for non-libtool projects to use a
> > libtool library.
> 
> Well, unlike Apache, we need to be able to create a shared library for
> consumption by other programs. (Apache only needs dynamic-load modules) To
> build a shared library, libtool is the best available option.
> 
> At install time, libtool will spit out the right files: there will be a .a
> file, a versioned .so file (e.g. libaprutil.so.x.y.z), and the symlinks for
> the other .so files (libaprutil.so.x and libaprutil.so). It will also drop a
> .la file into the install area, but that isn't a big deal.

The problem is that a libtool .so file, AFAIK, is not the same as a
regular .so file.  It is a hack so that the same thing works on all
platforms.  I do not believe that libtool .so files work when the program
using them is not using libtool, so this would limit apr-utils usefulness
to just programs using libtool.  I would much prefer to not have that
limitation.

APR is going to need to build a shared library at some point, and I hope
we don't use libtool there either.  I would prefer to invest the
time/energy into just doing this correctly on each platform.  I would
think this could be accomplished with a simple shell script to call the
correct programs from within the Makefiles.

I dislike forcing people to use a work around to embed our library in
their project.  Didn't Apache 1.3 solve this problem once?  Can we
leverage that code?
 
> If aprutil is used in a non-install scenario (e.g. built within another
> source tree, such as Apache), then the use of libtool is not a problem as
> long as the embeddor also uses libtool. If the embeddor does *not* use
> libtool, then it will be best for them to simply not embed, but to
> build/install, then refer to it; another option is to refer directly to the
> .a or .so files in apr-util/.libs/. I've used both of these methods for
> embedding a libtool-based library within an app, and both work quite fine.
> 
> The big reason for libtool is to build shared libraries. If it were not for
> that, then I'd be with you all the way and punt it! :-)

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------



use of libtool (was: Re: cvs commit: apr-util/test .cvsignore Makefile.in)

Posted by Greg Stein <gs...@lyra.org>.
On Sat, Dec 02, 2000 at 09:18:12AM -0800, rbb@covalent.net wrote:
> > Note that it uses autoconf and libtool. It isn't complicated enough for
> > automake, so I didn't bother. The build stuff is also greatly simplified
> > over those in APR and Apache. A single build/rules.mk and teeny makefiles
> > throughout.
> 
> I would really prefer to not use libtool.  This is meant to be a library
> that is useful to external projects.  Apache has had some real problems
> using libtool, and it is impossible for non-libtool projects to use a
> libtool library.

Well, unlike Apache, we need to be able to create a shared library for
consumption by other programs. (Apache only needs dynamic-load modules) To
build a shared library, libtool is the best available option.

At install time, libtool will spit out the right files: there will be a .a
file, a versioned .so file (e.g. libaprutil.so.x.y.z), and the symlinks for
the other .so files (libaprutil.so.x and libaprutil.so). It will also drop a
.la file into the install area, but that isn't a big deal.

If aprutil is used in a non-install scenario (e.g. built within another
source tree, such as Apache), then the use of libtool is not a problem as
long as the embeddor also uses libtool. If the embeddor does *not* use
libtool, then it will be best for them to simply not embed, but to
build/install, then refer to it; another option is to refer directly to the
.a or .so files in apr-util/.libs/. I've used both of these methods for
embedding a libtool-based library within an app, and both work quite fine.

The big reason for libtool is to build shared libraries. If it were not for
that, then I'd be with you all the way and punt it! :-)

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: copying files from other repositores (was: Re: cvs commit: apr-util/test .cvsignore Makefile.in)

Posted by Greg Stein <gs...@lyra.org>.
On Sat, Dec 02, 2000 at 02:01:57PM -0800, rbb@covalent.net wrote:
> 
> > > > The big step, of course, is deciding how we'll move files from other
> > > > repositories, then going and doing it. Here are the move options, let's see
> > > > some voting:
> > > > 
> > > > 1) copy the ,v files then remove tags on the new files.
> > > > 2) "cvs add" the head of the old file with a reference to the location/tag
> > > 
> > > #1.  We are talking about completely re-organizing the Apache tree, which
> > > means that the history won't be easily accessible for any of those
> > > files.  Plus these files are actually going to live in apr-util for a long
> > > time, so we want as much history as we can have there.
> > 
> > Argh! You are quite right!
> > 
> > Okay. I'm with you and would advocate option (2). Everybody: are there any
> > objections to going that route?  (we have two +1 votes for (1))
> 
> Please tell me you meant 1.  I am perfectly willing to agree that usually
> we should use option #2, but this is a special case.

Aw, crap. YES, I meant option (1)... feh.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: copying files from other repositores (was: Re: cvs commit: apr-util/test .cvsignore Makefile.in)

Posted by rb...@covalent.net.
> > > The big step, of course, is deciding how we'll move files from other
> > > repositories, then going and doing it. Here are the move options, let's see
> > > some voting:
> > > 
> > > 1) copy the ,v files then remove tags on the new files.
> > > 2) "cvs add" the head of the old file with a reference to the location/tag
> > 
> > #1.  We are talking about completely re-organizing the Apache tree, which
> > means that the history won't be easily accessible for any of those
> > files.  Plus these files are actually going to live in apr-util for a long
> > time, so we want as much history as we can have there.
> 
> Argh! You are quite right!
> 
> Okay. I'm with you and would advocate option (2). Everybody: are there any
> objections to going that route?  (we have two +1 votes for (1))

Please tell me you meant 1.  I am perfectly willing to agree that usually
we should use option #2, but this is a special case.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------



copying files from other repositores (was: Re: cvs commit: apr-util/test .cvsignore Makefile.in)

Posted by Greg Stein <gs...@lyra.org>.
On Sat, Dec 02, 2000 at 09:18:12AM -0800, rbb@covalent.net wrote:
>...
> > The big step, of course, is deciding how we'll move files from other
> > repositories, then going and doing it. Here are the move options, let's see
> > some voting:
> > 
> > 1) copy the ,v files then remove tags on the new files.
> > 2) "cvs add" the head of the old file with a reference to the location/tag
> 
> #1.  We are talking about completely re-organizing the Apache tree, which
> means that the history won't be easily accessible for any of those
> files.  Plus these files are actually going to live in apr-util for a long
> time, so we want as much history as we can have there.

Argh! You are quite right!

Okay. I'm with you and would advocate option (2). Everybody: are there any
objections to going that route?  (we have two +1 votes for (1))

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: cvs commit: apr-util/test .cvsignore Makefile.in

Posted by rb...@covalent.net.
> Note that it uses autoconf and libtool. It isn't complicated enough for
> automake, so I didn't bother. The build stuff is also greatly simplified
> over those in APR and Apache. A single build/rules.mk and teeny makefiles
> throughout.

I would really prefer to not use libtool.  This is meant to be a library
that is useful to external projects.  Apache has had some real problems
using libtool, and it is impossible for non-libtool projects to use a
libtool library.

> The big step, of course, is deciding how we'll move files from other
> repositories, then going and doing it. Here are the move options, let's see
> some voting:
> 
> 1) copy the ,v files then remove tags on the new files.
> 2) "cvs add" the head of the old file with a reference to the location/tag

#1.  We are talking about completely re-organizing the Apache tree, which
means that the history won't be easily accessible for any of those
files.  Plus these files are actually going to live in apr-util for a long
time, so we want as much history as we can have there.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: cvs commit: apr-util/test .cvsignore Makefile.in

Posted by Greg Stein <gs...@lyra.org>.
On Sat, Dec 02, 2000 at 04:13:51PM -0000, gstein@locus.apache.org wrote:
> gstein      00/12/02 08:13:50
> 
>   Added:       .        .cvsignore Makefile.in STATUS buildconf.sh
>                         configure.in
>                build    .cvsignore Makefile.in install-sh rules.mk.in
>                include  sdbm.h
>                src      .cvsignore Makefile.in
>                src/buckets .cvsignore Makefile.in
>                src/crypto .cvsignore Makefile.in
>                src/dbm  .cvsignore Makefile.in
>                src/dbm/sdbm .cvsignore Makefile.in sdbm.c sdbm_hash.c
>                         sdbm_lock.c sdbm_pair.c sdbm_pair.h sdbm_private.h
>                         sdbm_tune.h
>                src/encoding .cvsignore Makefile.in
>                src/hooks .cvsignore Makefile.in
>                src/uri  .cvsignore Makefile.in
>                src/xml  .cvsignore Makefile.in
>                test     .cvsignore Makefile.in
>   Log:
>   initial population of the APRUTIL module.
>...

Well... here is the first cut, people. I'd suggest that we tag the apache
and apr repositories with something like "PRE_APRUTIL_MOVE" and then commit
the files into the new tree.

I wouldn't recommend any repository monkeywork, but just committing the HEAD
from the old tree into the new tree. Of course, I'm sure people will have
different opinions here, so we'll probably want a short discussion...

The layout of directories is what I proposed in my email early this week.
The purpose should be reasonably self-evident.

Note that it uses autoconf and libtool. It isn't complicated enough for
automake, so I didn't bother. The build stuff is also greatly simplified
over those in APR and Apache. A single build/rules.mk and teeny makefiles
throughout.

etc etc ... there isn't much there yet, so I'll skip the length
explanations... a quick review should tell you whatever you want.

The big step, of course, is deciding how we'll move files from other
repositories, then going and doing it. Here are the move options, let's see
some voting:

1) copy the ,v files then remove tags on the new files.
2) "cvs add" the head of the old file with a reference to the location/tag

Choose! :-)

[ both options will simply "cvs rm" the files from their old repository ]

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/