changeset 0:2fbf657d0af2

Initial revision
author Simon Horman <horms@verge.net.au>
date Mon, 13 May 2002 14:19:35 +0900
parents
children c06480deb43d
files .cvsignore AUTHORS ChangeLog INSTALL.in Makefile.am NEWS README acconfig.h autogen.sh configure.in pbs/Makefile.am pbs/Makefile.in pbs/pbs.c pbs/pbs_db.c pbs/pbs_db.h pbs/pbs_log.h pbs/pbs_option.c pbs/pbs_option.h pbs/pbs_record.c pbs/pbs_record.h
diffstat 18 files changed, 2152 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.cvsignore	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,18 @@
+.depend
+remove
+libtool
+CODING_LOCATIONS
+INSTALL
+config.*
+configure
+Makefile.in
+aclocal.m4
+perdition.spec
+*.tar.gz
+stamp-h*
+Makefile
+.*.swp
+autooption
+logfile
+*.tar.gz
+tags
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AUTHORS	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,9 @@
+AUTHORS
+
+perdition-pbs
+Pop Before SMTP Tools
+Copyright (C) 1999-2002  Horms <horms@vergenet.net>
+----------------------------------------------------------------------
+
+Horms: <horms@vergenet.net>
+       aka. Simon Horman
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ChangeLog	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,11 @@
+Change Log
+
+perdition-pbs
+Pop Before SMTP Tools
+Copyright (C) 2002  Horms <horms@vergenet.net>
+----------------------------------------------------------------------
+
+XXX
+(Horms)
+
+  * XXX
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/INSTALL.in	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,79 @@
+INSTALL
+
+perdition-pbs
+Pop Before SMTP Tools
+Copyright (C) 2002  Horms <horms@vergenet.net>
+----------------------------------------------------------------------
+
+To install perdition-bps
+------------------------
+
+tar zxf perdition-pbs-@VERSION@.tar.gz
+cd perdition-pbs-@VERSION@
+./configure [--prefix=/usr]
+make
+make install
+
+
+To build RPMS
+-------------
+
+rpm -ta perdition-pbs-@VERSION@.tar.gz
+
+or
+
+cd perdition-@VERSION@
+./configure --prefix=/usr
+make distcheck
+rpm -ta perdition-@VERSION@.tar.gz
+
+
+To build Debian Packages
+------------------------
+
+dpkg-build [-us] [-uc]
+
+You will need to create a popmap and decide on your invocation method.
+For depbss on this please see the README
+
+
+To install on Solaris 8
+-----------------------
+
+You may need to set some envirnoment variables to aid the build process.
+The following worked for me using a bourne shell. Make apropriate
+adjustments if you are using a C shell.
+
+CPPFLAGS="-I/usr/local/include/"
+export CPPFLAGS
+LDFLAGS="-L/usr/local/lib/"
+export LDFLAGS
+
+cd perdition-pbs-@VERSION@
+./configure [--prefix=/usr]
+make
+make install
+
+
+To install on FreeBSD 4.2-RELEASE
+---------------------------------
+
+You may need to set some envirnoment variables to aid the build process.
+The following worked for me using a bourne shell. Make apropriate
+adjustments if you are using a C shell.
+
+CPPFLAGS="-I/usr/local/include/"
+export CPPFLAGS
+LDFLAGS="-L/usr/local/lib/"
+export LDFLAGS
+
+The Makefiles that are generated may not work with make so use
+gmake instead.
+
+cd perdition-pbs-@VERSION@
+./configure [--prefix=/usr]
+gmake
+gmake install
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.am	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,38 @@
+######################################################################
+# Makefile.am                                            February 2000
+# Horms                                             horms@vergenet.net
+#
+# perdition
+# Mail retrieval proxy server
+# Copyright (C) 1999-2002  Horms <horms@vergenet.net>
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more depbss.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307  USA
+#
+######################################################################
+
+SUBDIRS = pbs
+
+EXTRA_DIST = \
+configure \
+configure.in \
+README \
+TODO \
+autogen.sh \
+INSTALL.in \
+INSTALL
+
+clean-local:
+	rm -f build-stamp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/acconfig.h	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,2 @@
+/* Should we use DMALLOC */
+/* #define WITH_DMALLOC 1 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/autogen.sh	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# Run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+THEDIR=`pwd`
+cd $srcdir
+
+DIE=0
+
+(autoconf --version) < /dev/null > /dev/null 2>&1 || {
+	echo
+	echo "You must have autoconf installed to compile perdition-pbs."
+	echo "Download the appropriate package for your distribution,"
+	echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+	DIE=1
+}
+
+(automake --version) < /dev/null > /dev/null 2>&1 || {
+	echo
+	echo "You must have automake installed to compile perdition-pbs."
+	echo "Get ftp://ftp.cygnus.com/pub/home/tromey/automake-1.2d.tar.gz"
+	echo "(or a newer version if it is available)"
+	DIE=1
+}
+
+if test "$DIE" -eq 1; then
+	exit 1
+fi
+
+if test -z "$*"; then
+	echo "I am going to run ./configure with no arguments - if you wish "
+        echo "to pass any to it, please specify them on the $0 command line."
+fi
+
+case $CC in
+xlc )
+    am_opt=--include-deps;;
+esac
+
+aclocal $ACLOCAL_FLAGS
+(autoheader --version)  < /dev/null > /dev/null 2>&1 && autoheader
+automake --add-missing $am_opt
+autoconf
+cd $THEDIR
+
+$srcdir/configure "$@"
+
+echo 
+echo "Now type 'make' to compile perdition-pbs."
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configure.in	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,55 @@
+# Process this file with autoconf to produce a configure script.
+AC_INIT(pbs/pbs_log.h)
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(perdition-pbs, 0.0.0)
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_AWK
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AC_PROG_RANLIB
+
+# Checks for libraries.
+# FIXME: Replace `main' with a function in `-ldb':
+AC_CHECK_LIB([db], [db_create])
+# FIXME: Replace `main' with a function in `-lpopt':
+AC_CHECK_LIB([popt], [poptGetContext])
+# FIXME: Replace `main' with a function in `-lvanessa_logger':
+AC_CHECK_LIB([vanessa_logger], [vanessa_logger_change_max_priority])
+# FIXME: Replace `main' with a function in `-lvanessa_socket':
+AC_CHECK_LIB([vanessa_socket], [vanessa_socket_daemon_process])
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([fcntl.h locale.h stdlib.h string.h sys/time.h syslog.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+AC_STRUCT_TM
+
+# Checks for library functions.
+AC_TYPE_SIGNAL
+AC_FUNC_STRFTIME
+AC_CHECK_FUNCS([localtime_r memset regcomp setenv setlocale strcasecmp strchr strerror])
+
+######################################################################
+# Dmalloc debugging
+
+dmalloc_lib=""
+AC_ARG_WITH(
+  dmalloc,
+  [  --with-dmalloc          Compile with dmalloc debugging  ],
+  [ dmalloc_lib="-ldmalloc"
+    AC_SUBST(dmalloc_lib)
+    AC_DEFINE(WITH_DMALLOC, 1, Should we use DMALLOC) ],
+
+)
+
+
+AC_OUTPUT(Makefile pbs/Makefile INSTALL)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pbs/Makefile.am	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,41 @@
+######################################################################
+# Makefile.am                                            February 2000
+# Horms                                             horms@vergenet.net
+#
+# perdition
+# Mail retrieval proxy server
+# Copyright (C) 1999-2002  Horms
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more depbss.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307  USA
+#
+######################################################################
+
+sbin_PROGRAMS = perdition-pbs
+
+perdition_pbs_SOURCES = \
+pbs.c \
+pbs_db.c pbs_db.h \
+pbs_log.h \
+pbs_option.c pbs_option.h \
+pbs_record.c pbs_record.h 
+
+#INCLUDES= 
+
+# Removed because Debian doesn't like it
+#LDFLAGS = -Wl,--rpath -Wl,@prefix@
+
+LDADD = -ldb -lpopt \
+-lvanessa_logger -lvanessa_socket @dmalloc_lib@
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pbs/Makefile.in	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,351 @@
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+######################################################################
+# Makefile.am                                            February 2000
+# Horms                                             horms@vergenet.net
+#
+# perdition
+# Mail retrieval proxy server
+# Copyright (C) 1999-2002  Horms
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more depbss.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307  USA
+#
+######################################################################
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+AWK = @AWK@
+CC = @CC@
+CPP = @CPP@
+CXX = @CXX@
+LN_S = @LN_S@
+MAKEINFO = @MAKEINFO@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+VERSION = @VERSION@
+dmalloc_lib = @dmalloc_lib@
+
+sbin_PROGRAMS = perdition-pbs
+
+perdition_pbs_SOURCES =  pbs.c pbs_db.c pbs_db.h pbs_log.h pbs_option.c pbs_option.h pbs_record.c pbs_record.h 
+
+
+#INCLUDES= 
+
+# Removed because Debian doesn't like it
+#LDFLAGS = -Wl,--rpath -Wl,@prefix@
+
+LDADD = -ldb -lpopt -lvanessa_logger -lvanessa_socket @dmalloc_lib@
+
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = ../config.h
+CONFIG_CLEAN_FILES = 
+PROGRAMS =  $(sbin_PROGRAMS)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I..
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+perdition_pbs_OBJECTS =  pbs.o pbs_db.o pbs_option.o pbs_record.o
+perdition_pbs_LDADD = $(LDADD)
+perdition_pbs_DEPENDENCIES = 
+perdition_pbs_LDFLAGS = 
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON =  Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+DEP_FILES =  .deps/pbs.P .deps/pbs_db.P .deps/pbs_option.P \
+.deps/pbs_record.P
+SOURCES = $(perdition_pbs_SOURCES)
+OBJECTS = $(perdition_pbs_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .o .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
+	cd $(top_srcdir) && $(AUTOMAKE) --gnu pbs/Makefile
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status $(BUILT_SOURCES)
+	cd $(top_builddir) \
+	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-sbinPROGRAMS:
+
+clean-sbinPROGRAMS:
+	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+
+distclean-sbinPROGRAMS:
+
+maintainer-clean-sbinPROGRAMS:
+
+install-sbinPROGRAMS: $(sbin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	$(mkinstalldirs) $(DESTDIR)$(sbindir)
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    echo "  $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
+	     $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	  else :; fi; \
+	done
+
+uninstall-sbinPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	done
+
+.s.o:
+	$(COMPILE) -c $<
+
+.S.o:
+	$(COMPILE) -c $<
+
+mostlyclean-compile:
+	-rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+	-rm -f *.tab.c
+
+maintainer-clean-compile:
+
+perdition-pbs: $(perdition_pbs_OBJECTS) $(perdition_pbs_DEPENDENCIES)
+	@rm -f perdition-pbs
+	$(LINK) $(perdition_pbs_LDFLAGS) $(perdition_pbs_OBJECTS) $(perdition_pbs_LDADD) $(LIBS)
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+	list='$(SOURCES) $(HEADERS)'; \
+	unique=`for i in $$list; do echo $$i; done | \
+	  awk '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	here=`pwd` && cd $(srcdir) \
+	  && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)'; \
+	unique=`for i in $$list; do echo $$i; done | \
+	  awk '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+	-rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = pbs
+
+distdir: $(DISTFILES)
+	here=`cd $(top_builddir) && pwd`; \
+	top_distdir=`cd $(top_distdir) && pwd`; \
+	distdir=`cd $(distdir) && pwd`; \
+	cd $(top_srcdir) \
+	  && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu pbs/Makefile
+	@for file in $(DISTFILES); do \
+	  d=$(srcdir); \
+	  if test -d $$d/$$file; then \
+	    cp -pr $$d/$$file $(distdir)/$$file; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	  fi; \
+	done
+
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+
+-include $(DEP_FILES)
+
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+	-rm -rf .deps
+
+maintainer-clean-depend:
+
+%.o: %.c
+	@echo '$(COMPILE) -c $<'; \
+	$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+	@-cp .deps/$(*F).pp .deps/$(*F).P; \
+	tr ' ' '\012' < .deps/$(*F).pp \
+	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+	    >> .deps/$(*F).P; \
+	rm .deps/$(*F).pp
+
+%.lo: %.c
+	@echo '$(LTCOMPILE) -c $<'; \
+	$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+	@-sed -e 's/^\([^:]*\)\.o[ 	]*:/\1.lo \1.o :/' \
+	  < .deps/$(*F).pp > .deps/$(*F).P; \
+	tr ' ' '\012' < .deps/$(*F).pp \
+	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+	    >> .deps/$(*F).P; \
+	rm -f .deps/$(*F).pp
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am: install-sbinPROGRAMS
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-sbinPROGRAMS
+uninstall: uninstall-am
+all-am: Makefile $(PROGRAMS)
+all-redirect: all-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+	$(mkinstalldirs)  $(DESTDIR)$(sbindir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-rm -f Makefile $(CONFIG_CLEAN_FILES)
+	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am:  mostlyclean-sbinPROGRAMS mostlyclean-compile \
+		mostlyclean-tags mostlyclean-depend mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am:  clean-sbinPROGRAMS clean-compile clean-tags clean-depend \
+		clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am:  distclean-sbinPROGRAMS distclean-compile distclean-tags \
+		distclean-depend distclean-generic clean-am
+
+distclean: distclean-am
+
+maintainer-clean-am:  maintainer-clean-sbinPROGRAMS \
+		maintainer-clean-compile maintainer-clean-tags \
+		maintainer-clean-depend maintainer-clean-generic \
+		distclean-am
+	@echo "This command is intended for maintainers to use;"
+	@echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-sbinPROGRAMS distclean-sbinPROGRAMS \
+clean-sbinPROGRAMS maintainer-clean-sbinPROGRAMS uninstall-sbinPROGRAMS \
+install-sbinPROGRAMS mostlyclean-compile distclean-compile \
+clean-compile maintainer-clean-compile tags mostlyclean-tags \
+distclean-tags clean-tags maintainer-clean-tags distdir \
+mostlyclean-depend distclean-depend clean-depend \
+maintainer-clean-depend info-am info dvi-am dvi check check-am \
+installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pbs/pbs.c	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,661 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <regex.h>
+#include <signal.h>
+#include <time.h>
+#include <locale.h>
+#include <vanessa_logger.h>
+#include <vanessa_socket.h>
+
+#include "pbs_log.h"
+#include "pbs_db.h"
+#include "pbs_option.h"
+#include "pbs_record.h"
+
+#ifdef DMALLOC
+#include <dmalloc.h>
+#endif
+
+#define PBS_BUFFER_SIZE 4096
+
+vanessa_logger_t *pbs_vl;
+
+static int pbs_file_open(const char *filename, const int retry);
+static int pbs_read_line(int fd, char **current);
+static int pbs_consume_line(regex_t *preg, char *line, pbs_db_t *db,
+		time_t timeout, const char *prefix_len);
+
+static void pbs_exit_handler(int sig);
+static void pbs_reread_handler(int sig);
+
+static int do_mode_list(pbs_db_t *db, const char **key, const char *prefix);
+static int do_mode_insert(pbs_db_t *db, const char **key, const char *prefix,
+		time_t timeout, int quiet);
+static int do_mode_remove(pbs_db_t *db, const char **key, const char *prefix,
+		int quiet);
+static int do_mode_purge(pbs_db_t *db, int quiet);
+static int do_mode_setenv(pbs_db_t *db, const char **key);
+
+static int pbs_exit_now = 0;
+static int pbs_reread_now = 0;
+
+int main(int argc, char **argv) {
+	pbs_options_t *opt;
+	int fd;
+	int status;
+	int exit_status = -1;
+	struct stat stat_buf;
+	char *line = NULL;
+	off_t file_size;
+	off_t old_file_size;
+	regex_t pregex;
+	pbs_db_t *db = NULL;
+	time_t now;
+	time_t expire_now = 0;
+
+	setlocale(LC_ALL, "");
+
+	pbs_vl=vanessa_logger_openlog_filehandle(stdout, LOG_IDENT, 
+		LOG_DEBUG, LOG_CONS);
+	if(pbs_vl == NULL) {
+		fprintf(stderr, "main: vanessa_logger_openlog_syslog\n"
+			"Fatal error opening logger.  Exiting.\n");
+		goto leave;
+	}
+
+	opt = pbs_options_parse(argc, argv);
+	if(opt == NULL) {
+		PBS_DEBUG("pbs_options_parse");	
+		PBS_ERR("Fatal error parsing options. Exiting");
+		goto leave;
+	}
+
+	/* Update Logger */
+	if(opt->mode == PBS_MODE_DAEMON){
+  		vanessa_logger_closelog(pbs_vl);
+		vanessa_socket_daemon_process();
+		pbs_vl=vanessa_logger_openlog_syslog_byname(
+				opt->log_facility, LOG_IDENT, 
+				opt->log_level, LOG_CONS);
+		if(pbs_vl == NULL) {
+			fprintf(stderr, 
+				"main: vanessa_logger_openlog_syslog\n"
+				"Fatal error opening logger. Exiting.\n");
+			goto leave;
+		}
+	}
+	else {
+		vanessa_socket_daemon_inetd_process();
+		vanessa_logger_change_max_priority(pbs_vl, opt->log_level);
+	}
+
+	if(opt->mode == PBS_MODE_DAEMON || 
+			opt->log_level == PBS_LOG_LEVEL_DEBUG) {
+		pbs_options_log(opt);
+	}
+
+	/*Set signal handlers*/
+	signal(SIGHUP,    pbs_reread_handler);
+	signal(SIGINT,    pbs_exit_handler);
+	signal(SIGQUIT,   pbs_exit_handler);
+	signal(SIGILL,    pbs_exit_handler);
+	signal(SIGTRAP,   pbs_exit_handler);
+	signal(SIGIOT,    pbs_exit_handler);
+	signal(SIGBUS,    pbs_exit_handler);
+	signal(SIGFPE,    pbs_exit_handler);
+	signal(SIGUSR1,   SIG_IGN);
+	signal(SIGSEGV,   pbs_exit_handler);
+	signal(SIGUSR2,   SIG_IGN);
+	signal(SIGPIPE,   SIG_IGN);
+	signal(SIGALRM,   pbs_exit_handler);
+	signal(SIGTERM,   pbs_exit_handler);
+	signal(SIGCHLD,   SIG_IGN);
+	signal(SIGURG,    pbs_exit_handler);
+	signal(SIGXCPU,   pbs_exit_handler);
+	signal(SIGXFSZ,   pbs_exit_handler);
+	signal(SIGVTALRM, pbs_exit_handler);
+	signal(SIGPROF,   pbs_exit_handler);
+	signal(SIGWINCH,  pbs_exit_handler);
+	signal(SIGIO,     pbs_exit_handler);
+
+	if(regcomp(&pregex, opt->regex, REG_EXTENDED|REG_NEWLINE) != 0) {
+		PBS_DEBUG_ERRNO("regcomp");
+		PBS_ERR_UNSAFE("Fatal error compiling regular expression "
+				"\"%s\". Exiting");
+		goto leave;
+	}
+
+	db = pbs_db_open(opt->db_filename, 0664);
+	if(db == NULL) {
+		PBS_DEBUG("pbs_db_open");
+		PBS_ERR_UNSAFE("Fatal error opening database \"%s\". Exiting",
+				opt->db_filename);
+		goto leave;
+	}
+
+	if(opt->mode == PBS_MODE_SETENV) {
+		status = do_mode_setenv(db, opt->leftover);
+		if(status == -2) {
+			PBS_ERR("There must be at least one argument "
+					"to setenv");
+		}
+		else if(status < 0) {
+			PBS_DEBUG("do_mode_setenv");
+			PBS_ERR("Fatal error doing setenv. Exiting");
+		}
+		goto leave;
+		goto leave;
+	}
+
+	if(opt->mode == PBS_MODE_LIST) {
+		if(do_mode_list(db, opt->leftover, opt->prefix) < 0) {
+			PBS_DEBUG("do_mode_list");
+			PBS_ERR("Fatal error listing database. Exiting");
+		}
+		goto leave;
+	}
+
+	if(opt->mode == PBS_MODE_INSERT) {
+		status = do_mode_insert(db, opt->leftover, opt->prefix, 
+					opt->timeout, 
+					opt->log_level==PBS_LOG_LEVEL_QUIET);
+		if(status == -2) {
+			PBS_ERR("There must be at least one key to insert");
+		}
+		else if(status < 0) {
+			PBS_DEBUG("do_mode_insert");
+			PBS_ERR("Fatal error inserting entries. Exiting");
+		}
+		goto leave;
+	}
+
+	if(opt->mode == PBS_MODE_REMOVE) {
+		status = do_mode_remove(db, opt->leftover, opt->prefix, 
+					opt->log_level==PBS_LOG_LEVEL_QUIET);
+		if(status == -2) {
+			PBS_ERR("There must be at least one key to remove");
+		}
+		else if(status < 0) {
+			PBS_DEBUG("do_mode_insert");
+			PBS_ERR("Fatal error inserting entries. Exiting");
+		}
+		goto leave;
+	}
+
+	if(opt->mode == PBS_MODE_PURGE) {
+		if(do_mode_purge(db, 
+				opt->log_level==PBS_LOG_LEVEL_QUIET) < 0) {
+			PBS_DEBUG("do_mode_purge");
+			PBS_ERR("Fatal error purging database. Exiting");
+		}
+		goto leave;
+	}
+
+	fd = pbs_file_open(opt->log_filename, 0);
+	if(fd < 0) {
+		PBS_DEBUG_UNSAFE("pbs_file_open \"%s\"", opt->log_filename);	
+		PBS_ERR_UNSAFE("Fatal error opening log file \"%s\". Exiting",
+				opt->log_filename);
+		goto leave;
+	}
+
+	if(fstat(fd, &stat_buf) < 0) {
+		PBS_DEBUG_ERRNO("fstat");
+		PBS_ERR("Fatal error determining log size. Exiting");
+		goto leave;
+	}
+	file_size=stat_buf.st_size;
+
+	while(1) {
+		if(pbs_exit_now) {
+			PBS_ERR_UNSAFE("Exiting on Signal %d", pbs_exit_now);
+			goto leave;
+		}
+
+		now = time(NULL);
+		if(now > expire_now) {
+			if(pbs_db_traverse(db, 
+					pbs_db_traverse_func_expire_record, 
+					&now) < 0) {
+				PBS_DEBUG("pbs_db_traverse "
+						"pbs_db_expire_record");
+
+				PBS_ERR("Fatal error expiring keys from "
+						"database. Exiting");
+				goto leave;
+			}
+			expire_now = now + opt->timeout / 10;
+		}
+
+		if(fstat(fd, &stat_buf) < 0) {
+			PBS_DEBUG_ERRNO("fstat");
+			PBS_ERR("Fatal error determining log size. "
+					"Exiting");
+			goto leave;
+		}
+		old_file_size = file_size;
+		file_size=stat_buf.st_size;
+
+		if(pbs_reread_now || old_file_size > file_size) {
+			PBS_INFO_UNSAFE("Reopening log file \"%s\"", 
+					opt->log_filename);
+			if(close(fd) < 0) {
+				PBS_DEBUG_ERRNO("close");
+				PBS_ERR("Fatal error closing log file. "
+						"Exiting");
+				goto leave;
+			}
+			fd =pbs_file_open(opt->log_filename, 1);
+			if(fd < 0) {
+				PBS_DEBUG("pbs_file_open");	
+				PBS_ERR("Fatal error opening log file. "
+						"Exiting");
+				goto leave;
+			}
+			pbs_reread_now = 0;
+			continue;
+		}
+
+		if(old_file_size == file_size) {
+			sleep(1);
+			continue;
+		}
+			
+		while(1) {
+			status = pbs_read_line(fd, &line);
+			if(status < 0) {
+				PBS_DEBUG("pbs_read_line");
+				PBS_ERR("Fatal error reading log file. "
+						"Exiting");
+				goto leave;
+			}
+			if(status == 0) {
+				break;
+			}
+			if(status == 1) {
+				continue;
+			}
+			if(pbs_consume_line(&pregex, line, db, opt->timeout,
+					opt->prefix) < 0) {
+				PBS_DEBUG("pbs_consume_line");
+				PBS_ERR("Fatal error processing line from "
+						"log file. Exiting");
+				goto leave;
+			}
+			free(line);
+			line = NULL;
+		}
+	}
+
+	exit_status = 0;
+leave:
+	if(db != NULL) {
+		pbs_db_close(db);
+	}
+	return(exit_status);
+}
+
+int pbs_file_open(const char *filename, const int retry) {
+	int fd = -1;
+	int pause=2;
+	int loop = 1;
+
+	while(loop) {
+		fd = open(filename, O_RDONLY);
+		if(fd >=0 ) {
+			break;
+		}
+
+		PBS_DEBUG_ERRNO("open");	
+		if((errno != EACCES && errno != ENOENT && errno != ELOOP)
+				|| !retry) {
+			return(-1);
+		}
+		
+		PBS_ERR_UNSAFE("Transient error opening file, will retry "
+				"in %d seconds\n", pause);	
+		sleep(pause);
+		if(pbs_exit_now) {
+			/* An exit signal has been recieved, just
+			 * return a dummy file handle, as it won't get
+			 * used anyway */
+			return(0);
+		}
+		pause = (pause*2)%65;
+	}
+
+	if(lseek(fd, 0, SEEK_END) < 0) {
+		PBS_DEBUG_ERRNO("fstat");
+		return(-1);
+	}
+
+	return(fd);
+}
+
+
+static char __pbs_read_line_buffer[PBS_BUFFER_SIZE];
+static ssize_t __pbs_read_line_offset = 0;
+static ssize_t __pbs_read_line_bytes = 0;
+
+static ssize_t fill_buffer(int fd, char **buffer) {
+	if(__pbs_read_line_bytes > 0) {
+		*buffer=__pbs_read_line_buffer+__pbs_read_line_offset;
+		return(__pbs_read_line_bytes);
+	}
+	memset(__pbs_read_line_buffer, '\0', PBS_BUFFER_SIZE);
+	__pbs_read_line_bytes = read(fd, __pbs_read_line_buffer, 
+			PBS_BUFFER_SIZE-1);
+	if(__pbs_read_line_bytes < 0) {
+		PBS_DEBUG_ERRNO("read");
+		return(-1);
+	}
+	__pbs_read_line_offset = 0;
+	*buffer=__pbs_read_line_buffer;
+
+	return(__pbs_read_line_bytes);
+}
+
+static int pbs_read_line(int fd, char **current) {
+	ssize_t bytes;
+	size_t cpy_length;
+	size_t current_length;
+	size_t alloc_length;
+	char *this_line;
+	char *next_line;
+	char c;
+	
+	bytes = fill_buffer(fd, &this_line);
+	if(bytes < 0) {
+		PBS_DEBUG("fill_buffer");
+		return(-1);
+	}
+	if(bytes == 0) {
+		return(0);
+	}
+
+	next_line = strchr(this_line, '\n');
+	cpy_length = (next_line == NULL)?bytes:next_line-this_line;
+	current_length = (*current == NULL)?0:strlen(*current);
+	alloc_length = cpy_length+current_length;
+	
+	*current = realloc(*current, alloc_length + 1);
+	if(*current == NULL) {
+		PBS_DEBUG_ERRNO("realloc");
+		return(-1);
+	}
+
+	memset(*current+current_length, '\0', cpy_length + 1);
+	memcpy(*current+current_length, this_line, cpy_length);
+
+	__pbs_read_line_offset += cpy_length;
+	__pbs_read_line_bytes -= cpy_length;
+	while(1) {
+		c = *(__pbs_read_line_buffer+__pbs_read_line_offset);
+		if(c == '\n' || c == '\r') {
+			__pbs_read_line_offset++;
+			__pbs_read_line_bytes--;
+		}
+		else {
+			break;
+		}
+	}
+
+	return((next_line == NULL)?1:2);
+}
+
+#define PBS_NMATCH 3
+static int pbs_consume_line(regex_t *preg, char *line, pbs_db_t *db,
+		time_t timeout, const char *prefix){
+	regmatch_t pmatch[PBS_NMATCH];
+	char *user = NULL;
+	char *ip = NULL;
+	size_t len;
+	size_t prefix_len;
+	time_t expire;
+	int status = 0;
+
+	if(regexec(preg, line, PBS_NMATCH, pmatch, 0) != 0) {
+		printf("consume: no match\n");
+		return(-1);
+	}
+	
+	if(pmatch[1].rm_so == -1 || pmatch[1].rm_eo == -1 ||
+			pmatch[1].rm_so >= pmatch[1].rm_eo) {
+		PBS_DEBUG("ip not found");
+		return(-1);
+	}
+	len = pmatch[1].rm_eo - pmatch[1].rm_so;
+	prefix_len=(prefix != NULL)?strlen(prefix):0;
+	ip = malloc(len + +prefix_len + 1);
+	if(ip == NULL) {
+		PBS_DEBUG_ERRNO("malloc ip");
+		return(-1);
+	}
+	memset(ip, '\0', len + prefix_len + 1);
+	if(prefix != NULL) {
+		memcpy(ip, prefix, prefix_len);
+	}
+	memcpy(ip + prefix_len, line+pmatch[1].rm_so, len);
+
+	if(pmatch[2].rm_so != -1 && pmatch[2].rm_eo != -1 &&
+			pmatch[2].rm_so < pmatch[2].rm_eo) {
+		len = pmatch[2].rm_eo - pmatch[2].rm_so;
+		user = malloc(len + 1);
+		if(user == NULL) {
+			free(ip);
+			PBS_DEBUG_ERRNO("malloc user");
+			return(-1);
+		}
+		memset(user, '\0', len+1);
+		memcpy(user, line+pmatch[2].rm_so, len);
+	}
+
+	expire = time(NULL) + timeout;
+	if(pbs_db_put(db, ip, strlen(ip)+1, &expire, sizeof(expire)) < 0) {
+		PBS_DEBUG("pbs_db_put");
+		status = -1;
+	}
+
+	PBS_INFO_UNSAFE("Added: \"%s\" for \"%s\"\n", ip, user);
+
+	free(ip);
+	free(user);
+	return(status);
+}
+
+static void pbs_exit_handler(int sig) {
+	pbs_exit_now = sig;
+}
+
+static void pbs_reread_handler(int sig) {
+	pbs_reread_now = sig;
+}
+
+static int do_mode_list(pbs_db_t *db, const char **key, const char *prefix) {
+	size_t width;
+	time_t *time;
+	size_t len;
+	size_t buf_len = 0;
+	const char **k;
+	const char *k_fixed;
+	char *buf = NULL;
+
+	width = pbs_key_width(prefix);
+
+	if(pbs_record_top(width) < 0) {
+		PBS_DEBUG("pbs_record_hrule");
+		return(-1);
+	}
+
+	if(key == NULL) {
+		if(pbs_db_traverse(db, pbs_db_traverse_func_show_record, 
+					&width) < 0) {
+			PBS_DEBUG("pbs_db_traverse pbs_db_show_record");
+			return(-1);
+		}
+		return(0);
+	}
+
+
+	for(k = key ; *k != NULL; k++) {
+		k_fixed = pbs_record_fix_key(*k, prefix, &buf, &buf_len);
+		if(k_fixed == NULL) {
+			PBS_DEBUG("pbs_record_fix_key");
+			return(-1);
+		}
+		pbs_db_get(db, (char *)k_fixed, strlen(k_fixed)+1, 
+				(void **)&time, &len);
+		if(time == NULL || len == 0) {
+			pbs_record_show_str((char *)*k, "Not found", width);
+		}
+		else {
+			pbs_record_show((char *)*k, *time, width);
+		}
+	}
+
+	if(buf != NULL) {
+		free(buf);
+	}
+
+	return(0);
+}
+
+
+
+static int do_mode_remove(pbs_db_t *db, const char **key, const char *prefix,
+		int quiet) {
+	size_t width;
+	size_t buf_len = 0;
+	const char **k;
+	const char *k_fixed;
+	char *buf = NULL;
+	char *response;
+
+	if(key == NULL) {
+		PBS_DEBUG("no key");
+		return(-2);
+	}
+
+	width = pbs_key_width(prefix);
+
+	if(!quiet && pbs_record_top(width) < 0) {
+		PBS_DEBUG("pbs_record_hrule");
+		return(-1);
+	}
+
+	for(k = key ; *k != NULL; k++) {
+
+		k_fixed = pbs_record_fix_key(*k, prefix, &buf, &buf_len);
+		if(k_fixed == NULL) {
+			PBS_DEBUG("pbs_record_fix_key");
+			return(-1);
+		}
+		if(pbs_db_del(db, (char *)k_fixed, strlen(k_fixed)+1) < 0) {
+			response = "Not found";
+		}
+		else {
+			response = "Deleted";
+		}
+		if(!quiet) {
+			pbs_record_show_str((char *)*k, response, width);
+		}
+	}
+
+	if(buf != NULL) {
+		free(buf);
+	}
+
+	return(0);
+}
+
+
+static int do_mode_insert(pbs_db_t *db, const char **key, const char *prefix,
+		time_t timeout, int quiet) {
+	size_t width;
+	time_t expire;
+	size_t buf_len = 0;
+	const char **k;
+	const char *k_fixed;
+	char *buf = NULL;
+
+	if(key == NULL) {
+		PBS_DEBUG("no key");
+		return(-2);
+	}
+
+	width = pbs_key_width(prefix);
+
+	if(!quiet && pbs_record_top(width) < 0) {
+		PBS_DEBUG("pbs_record_hrule");
+		return(-1);
+	}
+
+	for(k = key ; *k != NULL; k++) {
+
+		k_fixed = pbs_record_fix_key(*k, prefix, &buf, &buf_len);
+		if(k_fixed == NULL) {
+			PBS_DEBUG("pbs_record_fix_key");
+			return(-1);
+		}
+		expire = time(NULL) + timeout;
+		if(pbs_db_put(db, (char *)k_fixed, strlen(k_fixed)+1,
+					&expire, sizeof(expire)) < 0) {
+			PBS_DEBUG("pbs_db_put");
+			return(-1);
+		}
+		if(!quiet) {
+			pbs_record_show((char *)*k, expire, width);
+		}
+	}
+
+	if(buf != NULL) {
+		free(buf);
+	}
+
+	return(0);
+}
+
+
+static int do_mode_purge(pbs_db_t *db, int quiet) {
+	time_t expire;
+
+	expire = ~0;
+
+	if(pbs_db_traverse(db, pbs_db_traverse_func_expire_record, 
+				&expire) < 0) {
+		PBS_DEBUG("pbs_db_traverse "
+				"pbs_db_expire_record");
+		return(-1);
+	}
+
+	if(!quiet) {
+		printf("Purged database\n");
+	}
+
+	return(0);
+}
+
+
+static int do_mode_setenv(pbs_db_t *db, const char **key) {
+	char value = '\0';
+
+	PBS_ERR("You need to check the source IP address!!");
+
+	if(key == NULL) {
+		PBS_DEBUG("no key");
+		return(-2);
+	}
+
+	setenv("RELAYCLIENT", &value, 0);
+	execv(key[0], (char **const)key);
+	PBS_DEBUG_ERRNO("execl");	
+	return(-1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pbs/pbs_db.c	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,236 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <db.h>
+#include <time.h>
+
+#include "pbs_db.h"
+#include "pbs_option.h"
+#include "pbs_log.h"
+#include "pbs_record.h"
+
+#ifdef DMALLOC
+#include <dmalloc.h>
+#endif
+
+pbs_db_t *pbs_db_open(const char *filename, const int mode){
+	DB *dbp;
+	int status;
+
+	status = db_create(&dbp, NULL, 0);
+	if(status != 0) {
+		PBS_DEBUG_DB("db_create", status);
+		return(NULL);
+	}
+	
+
+	status = dbp->open(dbp, filename, NULL, DB_HASH, DB_CREATE, mode);
+	if(status != 0) {
+		PBS_DEBUG_DB("dbp->open", status);
+		dbp->close(dbp, 0);
+		return(NULL);
+	}
+
+	return((pbs_db_t *)dbp);
+}
+
+int pbs_db_close(pbs_db_t *db) {
+	DB *dbp;
+	int status;
+
+	dbp = (DB *)db;
+	status = dbp->close(dbp, 0);
+	if(status != 0) {
+		PBS_DEBUG_DB("dbp->close", status);
+		return(-1);
+	}
+
+	return(0);
+}
+
+int pbs_db_put(pbs_db_t *db, void *key, size_t key_len, void *data, 
+		size_t data_len)
+{
+	DB *dbp;
+	DBT keyp;
+	DBT datap;
+	int status;
+
+	memset(&keyp, 0, sizeof(keyp));
+	keyp.data = key;
+	keyp.size = key_len;
+
+	memset(&datap, 0, sizeof(datap));
+	datap.data = data;
+	datap.size = data_len;
+
+	dbp = (DB *)db;
+
+	status = dbp->put(dbp, NULL, &keyp, &datap, 0);
+	if(status != 0) {
+		PBS_DEBUG_DB("dbp->put", status);
+		return(-1);
+	}
+
+	return(0);
+}
+
+int pbs_db_get(pbs_db_t *db, void *key, size_t key_len, 
+		void **data, size_t *data_len)
+{
+	DB *dbp;
+	DBT keyp;
+	DBT datap;
+	int status;
+
+	memset(&keyp, 0, sizeof(keyp));
+	keyp.data = key;
+	keyp.size = key_len;
+
+	memset(&datap, 0, sizeof(datap));
+
+	dbp = (DB *)db;
+
+	status = dbp->get(dbp, NULL, &keyp, &datap, 0);
+	if(status != 0) {
+		*data = NULL;
+		*data_len = 0;
+		PBS_DEBUG_DB("dbp->get", status);
+		return(-1);
+	}
+
+	*data = datap.data;
+	*data_len = datap.size;
+
+	return(0);
+}
+
+int pbs_db_del(pbs_db_t *db, void *key, size_t key_len)
+{
+	DB *dbp;
+	DBT keyp;
+	int status;
+
+	memset(&keyp, 0, sizeof(keyp));
+	keyp.data = key;
+	keyp.size = key_len;
+
+	dbp = (DB *)db;
+
+	status = dbp->del(dbp, NULL, &keyp, 0);
+	if(status != 0) {
+		PBS_DEBUG_DB("dbp->get", status);
+		return(-1);
+	}
+
+	return(0);
+}
+
+int pbs_db_traverse(pbs_db_t *db, 
+		int(*func)(void *db, void *key, size_t key_len,
+			void *data, size_t data_len, void *func_data), 
+		void *func_data)
+{
+	DB *dbp;
+	DBC *cursorp;
+	DBT keyp;
+	DBT datap;
+	int status;
+	int return_status = 0;
+
+	dbp = (DB *)db;
+
+	status = dbp->cursor(dbp, NULL, &cursorp, 0);
+	if(status != 0) {
+		PBS_DEBUG_DB("db->cursor", status);
+		return(-1);
+	}
+
+
+	while(1) {
+		memset(&keyp, 0, sizeof(keyp));
+		memset(&datap, 0, sizeof(datap));
+		status = cursorp->c_get(cursorp, &keyp, &datap, DB_NEXT);
+		if(status == DB_NOTFOUND) {
+			break;
+		}
+		else if(status != 0) {
+			PBS_DEBUG_DB("cursor->c_get", status);
+			return_status = -1;
+			break;
+		}
+
+		if(func(cursorp, keyp.data, keyp.size, datap.data, datap.size,
+					func_data) < 0) {
+			PBS_DEBUG("func");
+			return_status=-1;
+			break;
+		}
+	}
+
+	status = cursorp->c_close(cursorp);
+	if(status != 0) {
+		PBS_DEBUG_DB("cursor->c_close", status);
+		return_status = -1;
+	}
+	
+	return(0);
+}
+
+int pbs_db_traverse_func_show_record(void *db, void *key, size_t key_len,
+		void *data, size_t data_len, void *func_data) 
+{
+	time_t time;
+	char *ip;
+	int width;
+
+	time=*(time_t *)data;
+	ip=(char *)key;
+	width=(func_data==NULL)?0:*(int *)func_data;
+
+	if(pbs_record_show(ip, time, width) < 0) {
+		PBS_DEBUG("pbs_record_show");
+		return(-1);
+	}
+
+	return(0);
+}
+
+
+int pbs_db_traverse_func_expire_record(void *db, void *key, size_t key_len,
+		void *data, size_t data_len, void *func_data) 
+{
+	DBC *cursorp;
+	time_t expire;
+	time_t now;
+	char *ip;
+	int status;
+
+	cursorp = (DBC *)db;
+
+	expire=*(time_t *)data;
+	ip=(char *)key;
+	now=*(time_t *)func_data;
+
+
+	if(expire > now && now != ~0) {
+		return(0);
+	}
+
+	status = cursorp->c_del(cursorp, 0);
+	if(status != 0) {
+		PBS_DEBUG_DB("cursor->c_del", status);
+		return(-1);
+	}
+
+	PBS_INFO_UNSAFE("Expired %s\n", ip);
+
+	return(0);
+}
+
+
+char *pbs_db_strerror(int error) {
+	return(db_strerror(error));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pbs/pbs_db.h	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,38 @@
+#ifndef __PBS_DB_H
+#define __PBS_DB_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <db.h>
+
+typedef DB pbs_db_t;
+
+pbs_db_t *pbs_db_open(const char *filename, const int mode);
+
+int pbs_db_close(pbs_db_t *db);
+
+int pbs_db_put(pbs_db_t *db, void *keyp, size_t key_len, void *datap, 
+		size_t data_len);
+
+int pbs_db_get(pbs_db_t *db, void *keyp, size_t key_len, 
+		void **datap, size_t *data_len);
+
+int pbs_db_del(pbs_db_t *db, void *key, size_t key_len);
+
+int pbs_db_traverse(pbs_db_t *db,
+	int(*func)(void *db, void *key, size_t key_len,
+		void *data, size_t data_len, void *func_data),
+	void *func_data);
+
+int pbs_db_traverse_func_show_record(void *db, void *key, size_t key_len,
+	void *data, size_t data_len, void *func_data);
+
+int pbs_db_traverse_func_expire_record(void *db, void *key, size_t key_len,
+	void *data, size_t data_len, void *func_data);
+
+char *pbs_db_strerror(int error);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pbs/pbs_log.h	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,91 @@
+/**********************************************************************
+ * pbs_log.h                                                 September 2000
+ * Horms                                             horms@vergenet.net
+ *
+ * Defines for logging
+ *
+ * perdition
+ * Mail retrieval proxy server
+ * Copyright (C) 1999-2002  Horms
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more depbss.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307  USA
+ *
+ **********************************************************************/
+
+#ifndef SYSLOG_BERT
+#define SYSLOG_BERT
+
+#ifdef HAVE_CONFIG_H
+#include "../config.h"
+#endif
+
+#include <vanessa_logger.h>
+#include <syslog.h>
+#include <string.h>
+#include <errno.h>
+
+#include "pbs_db.h"
+
+#define LOG_IDENT "pbs"
+
+extern vanessa_logger_t *pbs_vl;
+extern int errno;
+
+
+/*
+ * Hooray for format string problems!
+ *
+ * Each of the logging macros have two versions. The UNSAFE version will
+ * accept a format string. You should _NOT_ use the UNSAFE versions if the
+ * first argument, the format string, is derived from user input. The safe
+ * versions (versions that do not have the "_UNSAFE" suffix) do not accept
+ * a format string and only accept one argument, the string to log. These
+ * should be safe to use with user derived input.
+ */
+
+#define PBS_LOG_UNSAFE(priority, fmt, args...) \
+  vanessa_logger_log(pbs_vl, priority, fmt, ## args)
+
+#define PBS_LOG(priority, str) \
+  vanessa_logger_log(pbs_vl, priority, "%s", str)
+
+#define PBS_INFO_UNSAFE(fmt, args...) \
+  vanessa_logger_log(pbs_vl, LOG_INFO, fmt, ## args)
+
+#define PBS_INFO(str) \
+  vanessa_logger_log(pbs_vl, LOG_INFO, "%s", str)
+
+#define PBS_ERR_UNSAFE(fmt, args...) \
+  vanessa_logger_log(pbs_vl, LOG_ERR, fmt, ## args)
+
+#define PBS_ERR(str) \
+  vanessa_logger_log(pbs_vl, LOG_ERR, "%s", str)
+
+#define PBS_DEBUG_UNSAFE(fmt, args...) \
+  vanessa_logger_log(pbs_vl, LOG_DEBUG, __FUNCTION__ ": " fmt, ## args)
+
+#define PBS_DEBUG(str) \
+  vanessa_logger_log(pbs_vl, LOG_DEBUG, __FUNCTION__ ": %s", str)
+
+#define PBS_DEBUG_ERRNO(s) \
+  vanessa_logger_log(pbs_vl, LOG_DEBUG, "%s: %s: %s", \
+    __FUNCTION__, s, strerror(errno))
+
+#define PBS_DEBUG_DB(s, err) \
+  vanessa_logger_log(pbs_vl, LOG_DEBUG, "%s: %s: %s", \
+    __FUNCTION__, s, pbs_db_strerror(err))
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pbs/pbs_option.c	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,268 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <regex.h>
+#include <signal.h>
+#include <time.h>
+#include <popt.h>
+#include <vanessa_logger.h>
+#include <vanessa_socket.h>
+
+#include "pbs_log.h"
+#include "pbs_option.h"
+
+#ifdef DMALLOC
+#include <dmalloc.h>
+#endif
+
+#define STR_NULL "(null)"
+#define STR_NULL_SAFE(string) (string==NULL)?STR_NULL:string
+#define BIN_OPT_STR(opt) ((opt)?"on":"off")
+
+pbs_options_t *pbs_options_parse(int argc, char **argv) {
+	char c;
+	pbs_options_t *opt;
+	poptContext context;
+
+	static struct poptOption options[] =
+	{
+		{"db_file",       'D', POPT_ARG_STRING, NULL, 'D'},
+		{"debug",        'd',  POPT_ARG_NONE,   NULL, 'd'},
+		{"log_facility", 'F',  POPT_ARG_NONE,   NULL, 'F'},
+		{"help",         'h',  POPT_ARG_NONE,   NULL, 'h'},
+		{"log_file",      'L', POPT_ARG_STRING, NULL, 'L'},
+		{"mode",          'm', POPT_ARG_STRING, NULL, 'm'},
+		{"no_daemon",     'n', POPT_ARG_NONE,   NULL, 'n'},
+		{"perfix",        'p', POPT_ARG_STRING, NULL, 'p'},
+		{"quiet",         'q', POPT_ARG_NONE,   NULL, 'q'},
+		{"regex",         'r', POPT_ARG_STRING, NULL, 'r'},
+		{NULL,             0,  0,               NULL,  0 }
+	};
+
+	opt = malloc(sizeof(pbs_options_t));
+	if(opt == NULL) {
+		PBS_DEBUG_ERRNO("malloc");	
+		return(NULL);
+	}
+
+	memset(opt, 0, sizeof(pbs_options_t));
+
+	/* Set defaults */
+	opt->log_filename = PBS_DEFAULT_LOG_FILENAME;
+	opt->db_filename = PBS_DEFAULT_DB_FILENAME;
+	opt->log_facility = PBS_DEFAULT_LOG_FACILITY;
+	opt->regex = PBS_DEFAULT_REGEX;
+	opt->timeout = PBS_DEFAULT_TIMEOUT;
+	opt->prefix = PBS_DEFAULT_PREFIX;
+	opt->log_level = PBS_DEFAULT_LOG_LEVEL;
+	opt->mode = PBS_DEFAULT_MODE;
+
+  	if(argc==0 || argv==NULL) return(opt);
+
+  	context = poptGetContext(LOG_IDENT, argc, (const char **)argv, 
+			options, 0);
+
+	while ((c=poptGetNextOpt(context)) >= 0){
+		optarg=(char *)poptGetOptArg(context);
+		switch (c){
+			case 'd':
+				opt->log_level = PBS_LOG_LEVEL_DEBUG;
+				break;
+			case 'D':
+				opt->db_filename = optarg;
+				break;
+			case 'F':
+				opt->log_facility = optarg;
+				break;
+			case 'h':
+				pbs_usage(0);
+				break;
+			case 'L':
+				opt->log_filename = optarg;
+				break;
+			case 'm':
+				opt->mode = pbs_mode_int(optarg);
+				if(opt->mode < 0) {
+					pbs_usage(-1);
+				}
+				break;
+			case 'n':
+				opt->no_daemon = 1;
+				break;
+			case 'p':
+				opt->prefix = optarg;
+				break;
+			case 'q':
+				opt->log_level = PBS_LOG_LEVEL_QUIET;
+				break;
+			case 'r':
+				opt->regex = optarg;
+				break;
+		}
+	}
+	
+	if (c < -1) {
+		fprintf(stderr, 
+			"options: %s: %s\n",
+			poptBadOption(context, POPT_BADOPTION_NOALIAS),
+			poptStrerror(c));
+		pbs_usage(-1);
+	}
+
+	opt->leftover = poptGetArgs(context);
+	if(opt->leftover != NULL && *(opt->leftover) == NULL) {
+		opt->leftover = NULL;
+	}
+
+	/* Lame-o-rama
+	 * If we call poptFreeContext() then the value returned
+	 * by poptGetArgs() becomes NULL */
+	if(opt->leftover == NULL) {
+		poptFreeContext(context);
+	}
+	
+	return(opt);
+}
+
+
+/**********************************************************************
+ * usage
+ * Display usage information and exit
+ * Prints to stdout if exit_status=0, stderr otherwise
+ **********************************************************************/
+
+void pbs_usage(int exit_status){
+	FILE *stream;
+
+	if(exit_status!=0){
+		stream=stderr;
+	}
+	else{
+		stream=stdout;
+	}
+
+    
+	fprintf(stream, 
+	"perdition version " VERSION " Copyright Horms\n"
+	"\n"
+	"Usage: " LOG_IDENT " [-m|--mode daemon|purge] [options]\n"
+	"Usage: " LOG_IDENT " -m|--mode list [options] [--] [key...]\n"
+	"Usage: " LOG_IDENT " -m|--mode insert|remove [options] [--] key...\n"
+	"Usage: " LOG_IDENT " -m|--mode setenv [options] [--] arg...\n"
+	"\n"
+	"  -m, --mode: MODE: Mode to run in.\n"
+	"                    One of: \"daemon\", \"list\", \"insert\",\n"
+	"                            \"remove\", \"setenv\" or \"purge\".\n"
+	"                    (default \"%s\")\n"
+	"\n"
+	"  options:\n"
+	"    -h, --help: print this message\n"
+	"    -D, --db_file FILE:  Database file to access\n"
+	"                         (default \"%s\")\n"
+	"    -d, --debug:         Verbose error messages\n"
+	"    -F, --log_facility FACILITY:\n"
+	"                         Syslog facility to log to. If the faclilty\n"
+	"                         has a leading '/' then it will be treated\n"
+	"                         as a file to log to.\n"
+	"                         (default \"%s\")\n"
+	"    -L, --log_file FILE: Log file to monitor\n"
+	"                         (default \"%s\")\n"
+	"    --no_daemon:         Do not detach from terminal when in\n"
+	"                         daemon mode\n"
+	"    -p, --prefix STRING: Prefix to prepend to keys to be\n"
+	"                         (default \"%s\")\n"
+	"                         stored in or retrieved from the database\n"
+	"    -q, --quiet:         Supress all but critical log messages\n"
+	"    -r, --regex: REGEX   Regular expression to use when parsing\n"
+	"                         log file. Should match the ip address as\n"
+	"                         the first result, and optionally the\n"
+	"                         username as the second result\n"
+	"                         (default \"%s\")\n"
+	"\n"
+	"Notes: Default for binary flags is off\n"
+	"       Keys are not used in \"daemon\" or \"purge\" mode.\n",
+	STR_NULL_SAFE(pbs_mode_str(PBS_DEFAULT_MODE)),
+	STR_NULL_SAFE(PBS_DEFAULT_DB_FILENAME),
+	STR_NULL_SAFE(PBS_DEFAULT_LOG_FACILITY),
+	STR_NULL_SAFE(PBS_DEFAULT_LOG_FILENAME),
+	STR_NULL_SAFE(PBS_DEFAULT_PREFIX),
+	STR_NULL_SAFE(PBS_DEFAULT_REGEX)
+	);
+
+  	exit(exit_status);
+}
+
+void pbs_options_log(pbs_options_t *opt){
+	PBS_INFO_UNSAFE(
+		"db_file=\"%s\" "
+		"debug=\"%s\" "
+		"log_facility=\"%s\" "
+		"log_file=\"%s\" "
+		"mode=\"%s\" "
+		"no_daemon=\"%s\" "
+		"prefix=\"%s\" "
+		"quiet=\"%s\" "
+		"regex=\"%s\"",
+		STR_NULL_SAFE(opt->db_filename),
+		BIN_OPT_STR(opt->log_level == PBS_LOG_LEVEL_DEBUG),
+		STR_NULL_SAFE(opt->log_facility),
+		STR_NULL_SAFE(opt->log_filename),
+		STR_NULL_SAFE(pbs_mode_str(opt->mode)),
+		BIN_OPT_STR(opt->no_daemon),
+		STR_NULL_SAFE(opt->prefix),
+		BIN_OPT_STR(opt->log_level == PBS_LOG_LEVEL_QUIET),
+		STR_NULL_SAFE(opt->regex)
+	);
+}
+
+
+int pbs_mode_int(const char *mode) {
+	if(strcasecmp(mode, PBS_MODE_DAEMON_STR) == 0) {
+		return(PBS_MODE_DAEMON);
+	}
+	if(strcasecmp(mode, PBS_MODE_LIST_STR) == 0) {
+		return(PBS_MODE_LIST);
+	}
+	if(strcasecmp(mode, PBS_MODE_INSERT_STR) == 0) {
+		return(PBS_MODE_INSERT);
+	}
+	if(strcasecmp(mode, PBS_MODE_REMOVE_STR) == 0) {
+		return(PBS_MODE_REMOVE);
+	}
+	if(strcasecmp(mode, PBS_MODE_PURGE_STR) == 0) {
+		return(PBS_MODE_PURGE);
+	}
+	if(strcasecmp(mode, PBS_MODE_SETENV_STR) == 0) {
+		return(PBS_MODE_SETENV);
+	}
+
+	PBS_DEBUG_UNSAFE("unknown mode: \"%s\"", mode);
+	return(-1);
+}
+
+
+const char *pbs_mode_str(const int mode) {
+	switch(mode) {
+		case PBS_MODE_DAEMON:
+		      return(PBS_MODE_DAEMON_STR);
+		case PBS_MODE_LIST:
+		      return(PBS_MODE_LIST_STR);
+		case PBS_MODE_INSERT:
+		      return(PBS_MODE_INSERT_STR);
+		case PBS_MODE_REMOVE:
+		      return(PBS_MODE_REMOVE_STR);
+		case PBS_MODE_PURGE:
+		      return(PBS_MODE_PURGE_STR);
+		case PBS_MODE_SETENV:
+		      return(PBS_MODE_SETENV_STR);
+	}
+	PBS_DEBUG_UNSAFE("unkown mode: %d", mode);
+	return(NULL);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pbs/pbs_option.h	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,65 @@
+#ifndef __PBS_OPTIONS_H
+#define __PBS_OPTIONS_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef DMALLOC
+#include <dmalloc.h>
+#endif
+
+#define PBS_LOG_LEVEL_QUIET  LOG_ERR
+#define PBS_LOG_LEVEL_NORMAL LOG_INFO
+#define PBS_LOG_LEVEL_DEBUG  LOG_DEBUG
+
+#define PBS_MODE_DAEMON     0x01
+#define PBS_MODE_DAEMON_STR "daemon"
+#define PBS_MODE_LIST       0x02
+#define PBS_MODE_LIST_STR   "list"
+#define PBS_MODE_INSERT     0x04
+#define PBS_MODE_INSERT_STR "insert"
+#define PBS_MODE_REMOVE     0x08
+#define PBS_MODE_REMOVE_STR "remove"
+#define PBS_MODE_PURGE      0x10
+#define PBS_MODE_PURGE_STR "purge"
+#define PBS_MODE_SETENV      0x20
+#define PBS_MODE_SETENV_STR "setenv"
+
+#ifndef PBS_DEFAULT_LOG_FILENAME
+#define PBS_DEFAULT_LOG_FILENAME "/var/log/mail.log"
+#endif
+#ifndef PBS_DEFAULT_DB_FILENAME
+#define PBS_DEFAULT_DB_FILENAME "/etc/mail/popauth.db"
+#endif
+#ifndef PBS_DEFAULT_PREFIX
+#define PBS_DEFAULT_PREFIX "POP:"
+#endif
+#define PBS_DEFAULT_REGEX "perdition.*Auth: ([^-]+)->[^-]+ user=\"([^\"]+)\" "
+#define PBS_DEFAULT_TIMEOUT 3600 /* In seconds */
+#define PBS_DEFAULT_MODE PBS_MODE_DAEMON
+#define PBS_DEFAULT_LOG_LEVEL PBS_LOG_LEVEL_NORMAL
+#define PBS_DEFAULT_LOG_FACILITY "mail"
+
+
+typedef struct {
+	const char *log_filename;
+	const char *db_filename;
+	int no_daemon;
+	const char *regex;
+	const char *prefix;
+	time_t timeout;
+	const char *log_facility;
+	int log_level;
+	int mode;
+	const char **leftover;
+} pbs_options_t;
+
+pbs_options_t *pbs_options_parse(int argc, char **argv);
+void pbs_usage(int exit_status);
+
+int pbs_mode_int(const char *mode);
+const char *pbs_mode_str(const int mode);
+void pbs_options_log(pbs_options_t *opt);
+
+#endif /* __PBS_OPTIONS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pbs/pbs_record.c	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,113 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <time.h>
+#include <stdlib.h>
+
+#include "pbs_log.h"
+#include "pbs_record.h"
+
+#ifdef DMALLOC
+#include <dmalloc.h>
+#endif
+
+#define PBS_DATE_WIDTH 40
+#define PBS_IP_WIDTH   15
+
+int pbs_record_show_str(char *ip, char *str, size_t width) {
+	printf("%-*s | %s\n", width, ip, str);
+	return(0);
+}
+
+int pbs_record_show(char *ip, time_t time, size_t width) {
+	struct tm tm;
+	char buf[PBS_DATE_WIDTH];
+
+	if(localtime_r(&time, &tm) == NULL) {
+		PBS_DEBUG_ERRNO("localtime_r");
+		return(-1);
+	}
+	strftime(buf, PBS_DATE_WIDTH-1, "%c", &tm);
+	printf("%-*s | %s\n", width, ip, buf);
+	return(0);
+}
+
+int pbs_record_hrule(size_t width) {
+	size_t rule_width;
+	char *buffer;
+
+	rule_width = width + PBS_DATE_WIDTH + 2;
+
+	buffer = malloc(rule_width+1);
+	if(buffer == NULL) {
+		PBS_DEBUG_ERRNO("malloc");
+		return(-1);
+	}
+
+	memset(buffer, '-', rule_width);
+	*(buffer+rule_width)='\0';
+	*(buffer+width+1)='+';
+
+	printf("%s\n", buffer);
+	free(buffer);
+
+	return(0);
+}
+
+int pbs_record_title(size_t width) {
+	printf("%-*s | %s\n", width, "Key", "Expires");
+	return(0);
+}
+
+int pbs_record_top(size_t width) {
+	if(pbs_record_title(width) < 0) {
+		PBS_DEBUG("pbs_record_title");
+		return(-1);
+	}
+	if(pbs_record_hrule(width) < 0) {
+		PBS_DEBUG("pbs_record_title");
+		return(-1);
+	}
+
+	return(0);
+}
+
+size_t pbs_key_width(const char *prefix) {
+	size_t width = PBS_IP_WIDTH;
+
+	if(prefix != NULL) {
+		width += strlen(prefix);
+	}
+
+	return(width);
+}
+
+
+const char *pbs_record_fix_key(const char *key, const char *prefix,
+		char **buf, size_t *buf_len) {
+	size_t prefix_len;
+	size_t k_len;
+
+	prefix_len = strlen(prefix); /* :( */
+
+	if(strncmp(key, prefix, prefix_len) == 0) {
+		return(key);
+	}
+
+	k_len = strlen(key);
+	if(*buf_len < prefix_len +k_len + 1) {
+		*buf_len = prefix_len + k_len + 1;
+		*buf = realloc(*buf, *buf_len);
+		if(buf == NULL) {
+			PBS_DEBUG_ERRNO("realloc");
+			return(NULL);
+		}
+	}
+	memset(*buf, 0, *buf_len);
+	memcpy(*buf, prefix, prefix_len);
+	memcpy(*buf+prefix_len, key, k_len);
+	
+	return(*buf);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pbs/pbs_record.h	Mon May 13 14:19:35 2002 +0900
@@ -0,0 +1,24 @@
+#ifndef __PBS_TIME_H
+#define __PBS_TIME_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <time.h>
+
+#ifdef DMALLOC
+#include <dmalloc.h>
+#endif
+
+int pbs_record_show_str(char *ip, char *str, size_t width);
+int pbs_record_show(char *ip, time_t time, size_t width);
+int pbs_record_hrule(size_t width);
+int pbs_record_title(size_t width);
+int pbs_record_top(size_t width);
+size_t pbs_key_width(const char *prefix);
+const char *pbs_record_fix_key(const char *key, const char *prefix,
+		                char **buf, size_t *buf_len);
+
+#endif /* __PBS_TIME_H */