--- Eterm-0.8.10/src/command.c.tim	Tue Nov  2 11:34:35 1999
+++ Eterm-0.8.10/src/command.c	Wed Dec  8 14:22:35 1999
@@ -147,6 +147,7 @@
 #include "../libmej/mem.h"
 #include "../libmej/strings.h"
 #include "string.h"
+#include "eterm_utmp.h"
 #include "graphics.h"
 #include "grkelot.h"
 #include "scrollbar.h"
@@ -511,16 +512,6 @@
 
 static void resize(void);
 
-/* extern functions referenced */
-#ifdef UTMP_SUPPORT
-extern void cleanutent(void);
-extern void makeutent(const char *, const char *);
-
-#else
-#  define cleanutent() ((void)(0))
-#  define makeutent(pty, hostname) ((void)(0))
-#endif
-
 /* extern variables referenced */
 int my_ruid, my_rgid, my_euid, my_egid;
 
@@ -1526,7 +1517,7 @@
 
 #ifdef UTMP_SUPPORT
   privileges(INVOKE);
-  cleanutent();
+  remove_utmp_entry();
   privileges(REVERT);
 #endif
 
@@ -1577,7 +1568,7 @@
 #endif /* __CYGWIN32__ */
 
 #ifdef UTMP_SUPPORT
-  cleanutent();
+  remove_utmp_entry();
 #endif
   privileges(REVERT);
 #ifdef USE_POSIX_THREADS
@@ -2369,8 +2360,9 @@
   }
 #ifdef UTMP_SUPPORT
   privileges(RESTORE);
-  if (Options & Opt_utmpLogging)
-    makeutent(ttydev, display_name);	/* stamp /etc/utmp */
+  if (Options & Opt_utmpLogging) {
+    add_utmp_entry(ttydev, display_name, ptyfd);
+  }
   privileges(IGNORE);
 #endif
 
--- Eterm-0.8.10/src/eterm_utmp.h.tim	Wed Aug 18 19:25:29 1999
+++ Eterm-0.8.10/src/eterm_utmp.h	Wed Dec  8 14:22:35 1999
@@ -23,64 +23,78 @@
  * 
  */
 
-#if !defined(ETERM_UTMP_H_) && defined(UTMP_SUPPORT)
+#ifndef ETERM_UTMP_H_
 #define ETERM_UTMP_H_
 
 #include <X11/Xfuncproto.h>
 #include <X11/Intrinsic.h>	/* Xlib, Xutil, Xresource, Xfuncproto */
 
-/************ Macros and Definitions ************/
-#ifndef UTMP_FILENAME
-#  ifdef UTMP_FILE
-#    define UTMP_FILENAME UTMP_FILE
-#  elif defined(_PATH_UTMP)
-#    define UTMP_FILENAME _PATH_UTMP
-#  else
-#    define UTMP_FILENAME "/etc/utmp"
-#  endif
-#endif
+#ifdef UTMP_SUPPORT
+# ifdef HAVE_UTEMPTER
+#  include <utempter.h>
+#  define add_utmp_entry(p, h, f)  addToUtmp(p, h, f)
+#  define remove_utmp_entry()      removeFromUtmp()
+# endif
 
-#ifndef LASTLOG_FILENAME
-# ifdef _PATH_LASTLOG
-#  define LASTLOG_FILENAME _PATH_LASTLOG
-# else
-#  define LASTLOG_FILENAME "/usr/adm/lastlog"	/* only on BSD systems */
+/************ Macros and Definitions ************/
+# ifndef UTMP_FILENAME
+#   ifdef UTMP_FILE
+#     define UTMP_FILENAME UTMP_FILE
+#   elif defined(_PATH_UTMP)
+#     define UTMP_FILENAME _PATH_UTMP
+#   else
+#     define UTMP_FILENAME "/etc/utmp"
+#   endif
 # endif
-#endif
 
-#ifndef WTMP_FILENAME
-#  ifdef WTMP_FILE
-#    define WTMP_FILENAME WTMP_FILE
-#  elif defined(_PATH_WTMP)
-#    define WTMP_FILENAME _PATH_WTMP
-#  elif defined(SYSV)
-#    define WTMP_FILENAME "/etc/wtmp"
+# ifndef LASTLOG_FILENAME
+#  ifdef _PATH_LASTLOG
+#   define LASTLOG_FILENAME _PATH_LASTLOG
 #  else
-#    define WTMP_FILENAME "/usr/adm/wtmp"
+#   define LASTLOG_FILENAME "/usr/adm/lastlog"	/* only on BSD systems */
 #  endif
-#endif
+# endif
 
-#ifndef TTYTAB_FILENAME
-#  ifdef TTYTAB
-#    define TTYTAB_FILENAME TTYTAB_FILENAME
-#  else
-#    define TTYTAB_FILENAME "/etc/ttytab"
-#  endif
-#endif
+# ifndef WTMP_FILENAME
+#   ifdef WTMP_FILE
+#     define WTMP_FILENAME WTMP_FILE
+#   elif defined(_PATH_WTMP)
+#     define WTMP_FILENAME _PATH_WTMP
+#   elif defined(SYSV)
+#     define WTMP_FILENAME "/etc/wtmp"
+#   else
+#     define WTMP_FILENAME "/usr/adm/wtmp"
+#   endif
+# endif
 
-#ifndef USER_PROCESS
-#  define USER_PROCESS 7
-#endif
-#ifndef DEAD_PROCESS
-#  define DEAD_PROCESS 8
-#endif
+# ifndef TTYTAB_FILENAME
+#   ifdef TTYTAB
+#     define TTYTAB_FILENAME TTYTAB_FILENAME
+#   else
+#     define TTYTAB_FILENAME "/etc/ttytab"
+#   endif
+# endif
+
+# ifndef USER_PROCESS
+#   define USER_PROCESS 7
+# endif
+# ifndef DEAD_PROCESS
+#   define DEAD_PROCESS 8
+# endif
 
 /************ Function Prototypes ************/
 _XFUNCPROTOBEGIN
 
-extern void makeutent(const char *, const char *);
-extern void cleanutent(void);
+# ifndef HAVE_UTEMPTER
+extern void add_utmp_entry(const char *, const char *, int);
+extern void remove_utmp_entry(void);
+# endif
 
 _XFUNCPROTOEND
+
+#else /* UTMP_SUPPORT */
+# define add_utmp_entry(p, h, f)  NOP
+# define remove_utmp_entry()      NOP
+#endif
 
 #endif	/* ETERM_UTMP_H_ */
--- Eterm-0.8.10/src/options.c.tim	Tue Nov  2 11:34:35 1999
+++ Eterm-0.8.10/src/options.c	Wed Dec  8 14:22:35 1999
@@ -3046,7 +3046,7 @@
   register char *loop_path;	/* -nf */
   register char *cur_path;	/* -nf */
   int ver;
-  unsigned char id;
+  unsigned char id = 0;
   file_state fs =
   {NULL, CONFIG_FILE_NAME, 1, 0};
 
--- Eterm-0.8.10/src/utmp.c.tim	Wed Sep 29 12:16:31 1999
+++ Eterm-0.8.10/src/utmp.c	Wed Dec  8 14:22:35 1999
@@ -28,77 +28,81 @@
 
 #ifdef UTMP_SUPPORT
 
-#include <stdio.h>
-#include <string.h>
+# include <stdio.h>
+# include <string.h>
 /* For some systems (HP-UX in particular), sys/types.h must be included
    before utmp*.h -- mej */
-#include <sys/types.h>
-#include <sys/stat.h>
+# include <sys/types.h>
+# include <sys/stat.h>
 /* Unsupported/broken utmpx.h on HP-UX, AIX, and glibc 2.1 */
-#if defined(_HPUX_SOURCE) || defined(_AIX) || ((__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
-#  undef HAVE_UTMPX_H
-#endif
-#ifdef HAVE_UTMPX_H
-# include <utmpx.h>
-# define USE_SYSV_UTMP
-#else
-# include <utmp.h>
-# ifdef HAVE_SETUTENT
+# if defined(_HPUX_SOURCE) || defined(_AIX) || ((__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
+#   undef HAVE_UTMPX_H
+# endif
+# ifdef HAVE_UTMPX_H
+#  include <utmpx.h>
 #  define USE_SYSV_UTMP
+# else
+#  include <utmp.h>
+#  ifdef HAVE_SETUTENT
+#   define USE_SYSV_UTMP
+#  endif
 # endif
-#endif
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# ifdef HAVE_SYS_TIME_H
+# ifdef TIME_WITH_SYS_TIME
 #  include <sys/time.h>
-# else
 #  include <time.h>
+# else
+#  ifdef HAVE_SYS_TIME_H
+#   include <sys/time.h>
+#  else
+#   include <time.h>
+#  endif
+# endif
+# ifdef HAVE_UNISTD_H
+#  include <unistd.h>
 # endif
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#include <pwd.h>
-#include <errno.h>
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-#ifdef HAVE_LASTLOG_H
-# include <lastlog.h>
-#endif
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
-# include <ttyent.h>
-#endif
-
-#include "eterm_utmp.h"
-#include "debug.h"
-#include "../libmej/debug.h"
-#include "command.h"
-#include "screen.h"
-#include "system.h"
+# include <pwd.h>
+# include <errno.h>
+# ifdef HAVE_FCNTL_H
+#  include <fcntl.h>
+# endif
+# ifdef HAVE_LASTLOG_H
+#  include <lastlog.h>
+# endif
+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+#  include <ttyent.h>
+# endif
+
+# include "eterm_utmp.h"
+# include "debug.h"
+# include "../libmej/debug.h"
+# include "command.h"
+# include "screen.h"
+# include "system.h"
 
 /* screen.h includes config.h again, so re-fix these.  Pointed out by Sung-Hyun Nam <namsh@lgic.co.kr> */
-#if defined(_HPUX_SOURCE) || defined(_AIX) || ((__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
-#  undef HAVE_UTMPX_H
-#endif
+# if defined(_HPUX_SOURCE) || defined(_AIX) || ((__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
+#   undef HAVE_UTMPX_H
+# endif
 
 /* don't go off end of ut_id & remember if an entry has been made */
-#if defined(USE_SYSV_UTMP) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
+
+# ifndef HAVE_UTEMPTER
+#  if defined(USE_SYSV_UTMP) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
 static char ut_id[5];		/* remember if entry to utmp made */
-#else
+#  else
 static int utmp_pos;		/* BSD position of utmp-stamp */
-#endif
+#  endif
+# endif
 
-#ifdef USE_SYSV_UTMP
+# ifdef USE_SYSV_UTMP
 
 #  ifdef HAVE_UTMPX_H
-#    undef WTMP_FILENAME
-#    define WTMP_FILENAME WTMPX_FILE
-#    define update_wtmp updwtmpx
-#  else				/* HAVE_UTMPX_H */
+#   undef WTMP_FILENAME
+#   define WTMP_FILENAME WTMPX_FILE
+#   define update_wtmp updwtmpx
+#  else
 
+#   ifndef HAVE_UTEMPTER
 static void
 update_wtmp(char *fname, struct utmp *putmp)
 {
@@ -134,29 +138,29 @@
 
   close(fd);
 }
+#   endif /* ifndef HAVE_UTEMPTER */
+#  endif /* HAVE_UTMPX_H */
 
-#  endif			/* HAVE_UTMPX_H */
-
-/* makeutent() - make a utmp entry */
+#  ifndef HAVE_UTEMPTER
 void
-makeutent(const char *pty, const char *hostname)
+add_utmp_entry(const char *pty, const char *hostname, int fd)
 {
   struct passwd *pwent = getpwuid(my_ruid);
 
-#ifdef HAVE_UTMPX_H
+#   ifdef HAVE_UTMPX_H
   struct utmpx utmp;
   struct utmp utmp2;
   MEMSET(&utmp, 0, sizeof(struct utmpx));
 
-#else
+#   else
   struct utmp utmp;
   MEMSET(&utmp, 0, sizeof(struct utmp));
 
-#endif
+#   endif
 
-#ifdef WITH_DMALLOC
+#   ifdef WITH_DMALLOC
   return;
-#endif
+#   endif
 
   if (!strncmp(pty, "/dev/", 5))
     pty += 5;			/* skip /dev/ prefix */
@@ -177,12 +181,12 @@
   utmp.ut_type = DEAD_PROCESS;
 
   privileges(INVOKE);
-#ifdef HAVE_UTMPX_H
+#   ifdef HAVE_UTMPX_H
   getutmp(&utmp, &utmp2);
   getutid(&utmp2);		/* position to entry in utmp file */
-#else
+#   else
   getutid(&utmp);		/* position to entry in utmp file */
-#endif
+#   endif
 
   /* set up the new entry */
   strncpy(utmp.ut_id, ut_id, sizeof(utmp.ut_id));
@@ -192,35 +196,36 @@
   strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
   utmp.ut_type = USER_PROCESS;
   utmp.ut_pid = getpid();
-#ifdef HAVE_UTMPX_H
+#   ifdef HAVE_UTMPX_H
   utmp.ut_session = getsid(0);
   utmp.ut_xtime = time(NULL);
   utmp.ut_tv.tv_usec = 0;
-#else
+#   else
   utmp.ut_time = time(NULL);
-#endif
+#   endif
 
   /*
    * write a utmp entry to the utmp file
    */
   utmpname(UTMP_FILENAME);
-#ifdef HAVE_UTMPX_H
+#   ifdef HAVE_UTMPX_H
   getutmp(&utmp, &utmp2);
   pututline(&utmp2);
   pututxline(&utmp);
-#else
+#   else
   pututline(&utmp);
-#endif
+#   endif
   update_wtmp(WTMP_FILENAME, &utmp);
   endutent();			/* close the file */
   privileges(REVERT);
+  return;
+  fd = 0;
 }
 
-/* cleanutent() - remove a utmp entry */
 void
-cleanutent(void)
+remove_utmp_entry(void)
 {
-#ifdef HAVE_UTMPX_H
+#   ifdef HAVE_UTMPX_H
   struct utmp utmp;
   struct utmpx utmpx;
 
@@ -240,7 +245,7 @@
   endutent();
   privileges(REVERT);
 
-#else /* HAVE_UTMPX_H */
+#   else /* HAVE_UTMPX_H */
   struct utmp *putmp;
   pid_t pid = getpid();
 
@@ -267,13 +272,14 @@
   }
   endutent();
   privileges(REVERT);
-#endif /* HAVE_UTMPX_H */
+#   endif /* HAVE_UTMPX_H */
 }
+#  endif /* ifndef HAVE_UTEMPTER */
 
-#else /* USE_SYSV_UTMP */
+# else /* USE_SYSV_UTMP */
 /* BSD utmp support */
 
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+#  if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
 
 /* used to hold the line we are using */
 static char ut_line[32];
@@ -321,7 +327,7 @@
   }
 }
 
-#else /* __FreeBSD__ || NetBSD || BSDI */
+#  else /* __FreeBSD__ || NetBSD || BSDI */
 static int utmp_pos = 0;	/* position of utmp-stamp */
 
 /*----------------------------------------------------------------------*
@@ -379,13 +385,10 @@
   return rval;
 }
 
-#endif /* __FreeBSD__ || NetBSD || BSDI */
+#  endif /* __FreeBSD__ || NetBSD || BSDI */
 
-/*
- * make a utmp entry
- */
 void
-makeutent(const char *pty, const char *hostname)
+add_utmp_entry(const char *pty, const char *hostname, int fd)
 {
   struct passwd *pwent = getpwuid(my_ruid);
   struct utmp utmp;
@@ -402,7 +405,7 @@
     return;
   }
 
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+#  if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
   strncpy(ut_line, pty, 31);
 
   strncpy(utmp.ut_line, pty, UT_LINESIZE);
@@ -411,7 +414,7 @@
   utmp.ut_time = time(NULL);
 
   b_login(&utmp);
-#else /* __FreeBSD__ || NetBSD || BSDI */
+#  else /* __FreeBSD__ || NetBSD || BSDI */
   strncpy(utmp.ut_line, ut_id, sizeof(utmp.ut_line));
   strncpy(utmp.ut_name, pwent->pw_name, sizeof(utmp.ut_name));
   strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
@@ -419,19 +422,21 @@
 
   if (write_utmp(&utmp) < 0)
     ut_id[0] = '\0';		/* entry not made */
-#endif
+#  endif
+  return;
+  fd = 0;
 }
 
 /*
  * remove a utmp entry
  */
 void
-cleanutent(void)
+remove_utmp_entry(void)
 {
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+#  if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
   logout(ut_line);
   logwtmp(ut_line, "", "");
-#else /* __FreeBSD__ */
+#  else /* __FreeBSD__ */
   FILE *fd;
 
   privileges(INVOKE);
@@ -445,9 +450,9 @@
     fclose(fd);
   }
   privileges(REVERT);
-#endif /* __FreeBSD__ || NetBSD || BSDI */
+#  endif /* __FreeBSD__ || NetBSD || BSDI */
 }
 
-#endif /* USE_SYSV_UTMP */
+# endif /* USE_SYSV_UTMP */
 
 #endif /* UTMP_SUPPORT */
--- Eterm-0.8.10/themes/Makefile.am.tim	Wed Oct 27 08:52:57 1999
+++ Eterm-0.8.10/themes/Makefile.am	Wed Dec  8 14:22:35 1999
@@ -4,10 +4,13 @@
 
 EXTRA_DIST = Eterm/Eterm.menu Eterm/MAIN.in irc/MAIN.in irc/irc.menu active.tags chooser/chooser.menu chooser/MAIN.in emacs/MAIN.in emacs/emacs.menu mutt/MAIN.in mutt/mutt.menu tn3270/MAIN.in trans/MAIN.in trans/trans.menu
 
-install-data-hook:
+all: Makefile
 	-@for i in $(THEMES) ; do \
+	  echo "Generating MAIN file for $$i theme." ; \
 	  $(SED) -e 's%@''PREFIX''@%${prefix}%g' -e 's%@''DATADIR''@%${datadir}%g' -e 's%@''THEME''@%'$$i'%g' $(srcdir)/$$i/MAIN.in > $(srcdir)/$$i/MAIN ; \
 	done
+
+install-data-hook:
 	$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/themes
 	-@for i in $(THEMES) ; do \
 	  if test ! -d $(DESTDIR)$(pkgdatadir)/themes/$$i ; then \
--- Eterm-0.8.10/doc/Makefile.am.tim	Fri Nov  5 13:55:36 1999
+++ Eterm-0.8.10/doc/Makefile.am	Wed Dec  8 14:22:35 1999
@@ -8,7 +8,7 @@
 	$(SED) -e 's%@''VERSION''@%$(VERSION)%g' -e 's%@''DATE''@%$(DATE)%g' -e 's%@THEMEDIR@%$(pkgdatadir)/themes%g' $(top_srcdir)/doc/$@.in > $@
 
 Eterm.1.html: Eterm.1
-	-nroff -man $< | man2html > $@
+	-nroff -man $< | man2html -title Eterm > $@
 
 EXTRA_DIST = Eterm.1.in Eterm_reference.html Eterm.tcap Eterm.ti Makefile.am Makefile.in
 
--- Eterm-0.8.10/acconfig.h.tim	Wed Aug 18 18:46:28 1999
+++ Eterm-0.8.10/acconfig.h	Wed Dec  8 14:22:35 1999
@@ -287,6 +287,7 @@
 #undef HAVE_X_SHAPE_EXT
 
 #undef AUTHORS
+#undef HAVE_UTEMPTER
 
 
 /* Leave that blank line there!!  Autoheader needs it.
--- Eterm-0.8.10/configure.in.tim	Mon Sep 27 17:29:09 1999
+++ Eterm-0.8.10/configure.in	Wed Dec  8 14:22:35 1999
@@ -153,6 +153,10 @@
   AC_DEFINE(HAVE_LOGOUT)
 ))
 AC_CHECK_FUNC(getpwuid, , AC_CHECK_LIB(sun, getpwuid, LIBS="$LIBS -lsun"))
+AC_CHECK_LIB(utempter, addToUtmp,
+             AC_DEFINE(HAVE_UTEMPTER)
+             LIBS="$LIBS -lutempter"
+            )
 
 dnl# Check for POSIX threads library
 dnl# Don't comment this back in before multithreading actually works,
