diff --git a/src/libraries/libisc-new/.cvsignore b/src/libraries/libisc-new/.cvsignore
index a12fc1f1131a7144827122d58c34797fb12f30e7..18113ed1701bbbbd50c570aa23a67de0a6d4241a 100644
--- a/src/libraries/libisc-new/.cvsignore
+++ b/src/libraries/libisc-new/.cvsignore
@@ -1 +1,8 @@
-Topdir.make
+Makefile
+Makefile.in
+aclocal.m4
+config.cache
+config.log
+config.status
+configure
+isc-*
diff --git a/src/libraries/libisc-new/README b/src/libraries/libisc-new/README
index a89248c0e83e941978be73644be2ee9093210526..2f2f9f2d7afdc7a59763be156380005be94eac01 100644
--- a/src/libraries/libisc-new/README
+++ b/src/libraries/libisc-new/README
@@ -1,7 +1,21 @@
-This package implements a library of functions that is intendend
-to help creating client-server packages using TCP/IP or other
-file descriptor based links.
+This package implements a library of functions that was intendend to
+help creating client-server packages using TCP/IP or other file
+descriptor based links.  Use of this package for development of new
+software is not recommended.
  
-Have a look at EXAMPLE.c for a example of how it can be used.
- 
-/Peter Eriksson (pen@lysator.liu.se)
+Much of the documentation is probably outdated.  Be sure to read the
+file NEWS, and trust it more than the man pages.  Trust doc/MANUAL.sv
+even less than the man pages.
+
+This code is distributed under the GNU General Public License, except
+for src/printf.c.  See that file for all the details.  src/printf.c is
+not used unless the deprecated --enable-isc-printf switch is used.
+
+This is an interim release, that will be used as a baseline for tests
+with incorporating this library in other code such as the LysKOM
+server.  You should expect isc-1.0 to be released within a few
+man-days.  (What that translates to in calendar days is totally
+unknown.)
+
+/Peter Eriksson <pen@lysator.liu.se> and 
+ Per Cederqvist <ceder@lysator.liu.se>
diff --git a/src/libraries/libisc-new/TODO b/src/libraries/libisc-new/TODO
index 968b247471ebcf7b2c6db74691330b97140d3f94..8cfbfaaa1d25f3890068ee769f819fe9e54f733a 100644
--- a/src/libraries/libisc-new/TODO
+++ b/src/libraries/libisc-new/TODO
@@ -1,3 +1,9 @@
+* Use an autoconf check for the buggy inet_ntoa (search for __GNU__ in
+  src/isc_socket.c to see what I'm talking about).
+
+* Get rid of isc/printf.c.  Who uses it anyway?  Ah, the lyskomd
+  server...  What a pity.
+
 * Anv�nd ett IscMessage som sendbuffert
 
 * Kolla upp s� att inte tecken i sendbuf[] s�nds f�r�n isc_flush() verkligen
diff --git a/src/libraries/libisc-new/demo/Makefile.in b/src/libraries/libisc-new/demo/Makefile.in
index 8d7bd39b08dac187c22f5a3a0a88e75c9f7db5e7..05922af70cb0ad7065a1a8ccf35207ecf3f65b7a 100644
--- a/src/libraries/libisc-new/demo/Makefile.in
+++ b/src/libraries/libisc-new/demo/Makefile.in
@@ -1,19 +1,158 @@
-INCDIRS=-I$(HOME)/include
-LIBDIRS=-L$(HOME)/lib
-SOURCES=tcp.c udp.c
-CFLAGS= -g $(LIBDIRS) $(INCDIRS)
-CC=gcc
+# Makefile.in generated automatically by automake 1.3 from Makefile.am
 
-tcp:	tcp.c $(HOME)/include/isc.h $(HOME)/lib/libisc.a
-	gcc $(CFLAGS) -o tcp tcp.c -lisc -lansi
+# Copyright (C) 1994, 1995, 1996, 1997, 1998 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.
 
-udp:	udp.c $(HOME)/include/isc.h $(HOME)/lib/libisc.a
-	gcc $(CFLAGS) -o udp udp.c -lisc -lansi
+# 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.
 
-clean:
-	rm -f *~ *.o a.out core tcp udp \#*\#
 
-depend:
-	gmkdep $(INCDIRS) $(SOURCES)
+SHELL = /bin/sh
 
-# DO NOT DELETE THIS LINE -- mkdep uses it.
+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
+
+DISTDIR =
+
+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@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+CC = @CC@
+CPP = @CPP@
+LIBOBJS = @LIBOBJS@
+MAKEINFO = @MAKEINFO@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+U = @U@
+VERSION = @VERSION@
+
+EXTRA_DIST = mux.c mux.h tcp.c udp.c
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_CLEAN_FILES = 
+DIST_COMMON =  README Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP = --best
+all: Makefile
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps demo/Makefile
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) \
+	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+tags: TAGS
+TAGS:
+
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = demo
+
+distdir: $(DISTFILES)
+	@for file in $(DISTFILES); do \
+	  d=$(srcdir); \
+	  test -f $(distdir)/$$file \
+	  || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+	  || cp -p $$d/$$file $(distdir)/$$file; \
+	done
+info:
+dvi:
+check: all
+	$(MAKE)
+installcheck:
+install-exec: 
+	@$(NORMAL_INSTALL)
+
+install-data: 
+	@$(NORMAL_INSTALL)
+
+install: install-exec install-data all
+	@:
+
+uninstall: 
+
+install-strip:
+	$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
+installdirs:
+
+
+mostlyclean-generic:
+	-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+	-rm -f Makefile $(DISTCLEANFILES)
+	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+	-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+mostlyclean:  mostlyclean-generic
+
+clean:  clean-generic mostlyclean
+
+distclean:  distclean-generic clean
+	-rm -f config.status
+
+maintainer-clean:  maintainer-clean-generic distclean
+	@echo "This command is intended for maintainers to use;"
+	@echo "it deletes files that may require special tools to rebuild."
+
+.PHONY: tags distdir info dvi installcheck install-exec install-data \
+install uninstall 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:
diff --git a/src/libraries/libisc-new/doc/.cvsignore b/src/libraries/libisc-new/doc/.cvsignore
index a12fc1f1131a7144827122d58c34797fb12f30e7..282522db0342d8750454b3dc162493b5fc709cc8 100644
--- a/src/libraries/libisc-new/doc/.cvsignore
+++ b/src/libraries/libisc-new/doc/.cvsignore
@@ -1 +1,2 @@
-Topdir.make
+Makefile
+Makefile.in
diff --git a/src/libraries/libisc-new/man/.cvsignore b/src/libraries/libisc-new/man/.cvsignore
index a12fc1f1131a7144827122d58c34797fb12f30e7..282522db0342d8750454b3dc162493b5fc709cc8 100644
--- a/src/libraries/libisc-new/man/.cvsignore
+++ b/src/libraries/libisc-new/man/.cvsignore
@@ -1 +1,2 @@
-Topdir.make
+Makefile
+Makefile.in
diff --git a/src/libraries/libisc-new/src/.cvsignore b/src/libraries/libisc-new/src/.cvsignore
index a12fc1f1131a7144827122d58c34797fb12f30e7..e9955884756af11fe171e89bf99e459ac44f1a2a 100644
--- a/src/libraries/libisc-new/src/.cvsignore
+++ b/src/libraries/libisc-new/src/.cvsignore
@@ -1 +1,3 @@
-Topdir.make
+.deps
+Makefile
+Makefile.in
diff --git a/src/libraries/libisc-new/src/isc.h b/src/libraries/libisc-new/src/isc.h
index 6c447bf4843f0c485fa04013263564f43201b76c..bf0a488613a43c5dbdeed53ae1309b8252dbcfb9 100644
--- a/src/libraries/libisc-new/src/isc.h
+++ b/src/libraries/libisc-new/src/isc.h
@@ -13,12 +13,6 @@
 #ifndef __ISC_H__
 #define __ISC_H__
 
-#include <time.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-
 
 /*
 ** Give the poor user a chance to change it
@@ -149,6 +143,7 @@ typedef enum
   ISC_STATE_RUNNING,
   ISC_STATE_DISABLED,
   ISC_STATE_CLOSING,
+  ISC_STATE_CLOSING2,		/* An ISC_EVENT_LOGOUT has been generated. */
   ISC_STATE_LISTENING
 } IscSessionState;
 
@@ -268,7 +263,7 @@ IscSession
   IscSessionState     state;
   int                 fd;
   int		      mode;
-  int		      errno;
+  int		      isc_errno;
   
   IscMsgQueue       * rd_msg_q;
   IscMsgQueue       * wr_msg_q;
@@ -365,6 +360,7 @@ IscEvent
   IscEventType      event;
   IscSession      * session;
   IscMessage      * msg;
+  IscSession	  * listen_session;
 };
 
 
@@ -463,6 +459,12 @@ isc_getnextevent(IscMaster  * mcb,
 
 
 
+/*
+** Wait for pending connections.
+*/
+IscEvent *
+isc_wait(IscMaster *mcb, long timeout);
+ 
 /*
 ** This should be used to discard an event when it has been processed.
 */
@@ -511,6 +513,11 @@ isc_putc(int           chr,
 
 
 
+#ifdef ISC_PRINTF_SUPPORT
+#  ifndef HAVE_STDARG_H
+#    error isc_printf is not available on systems that lack stdarg.h.
+#  else
+
 /*
 ** Put a formatted string on the transmit queue
 */
@@ -524,6 +531,8 @@ isc_vprintf(IscSession  * scb,
 	    const char  * format,
 	    va_list       AP);
 
+#  endif
+#endif
 
 
 /*
diff --git a/src/libraries/libisc-new/src/isc_abort.c b/src/libraries/libisc-new/src/isc_abort.c
index 8e1ac120cf5cd9e746fd202fa6e3202ce153175f..cee65280e1206b75beb191b71a2b123ba8d93733 100644
--- a/src/libraries/libisc-new/src/isc_abort.c
+++ b/src/libraries/libisc-new/src/isc_abort.c
@@ -9,20 +9,23 @@
 */
 
 #include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
+#ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#endif
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <time.h>
+
 #include "isc.h"
 #include "intern.h"
 
-/*
-** External function declarations
-*/
-extern int fprintf(FILE *, char *, ...);
-#if defined(__sun__) && !defined(__stdlib_h)
-extern void abort(void);
-#endif
-
-static void (*isc_abortfn)(const char *msg) = (void (*)(const char *))NULL;
+static void (*isc_abortfn)(const char *msg) = NULL;
 
   
 void
diff --git a/src/libraries/libisc-new/src/isc_alloc.c b/src/libraries/libisc-new/src/isc_alloc.c
index 6e999fa746b4e80d61ab43ec15a0172e2b01f011..054628f661fac23d1f33225f2f6420c027471c53 100644
--- a/src/libraries/libisc-new/src/isc_alloc.c
+++ b/src/libraries/libisc-new/src/isc_alloc.c
@@ -8,9 +8,26 @@
 ** 910305 pen      moved into separate file
 */
 
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
+#ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#endif
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#else
+#  include <strings.h>
+#endif
+#ifndef NULL
+#  include <stdio.h>
+#endif
+
 #include "isc.h"
 #include "intern.h"
 
@@ -21,27 +38,12 @@
 #define ISC_MAGIC_FREE  0xEE47A37F
 
 
-/*
-** External declarations
-*/
-#if defined(__sun__) && !defined(__stdlib_h)
-extern void *malloc(size_t);
-extern void *calloc(int, size_t);
-extern void *realloc(void *, size_t);
-extern void free(void *);
-#endif
-
 /*
 ** Pointers to functions to handle storage allocation
 */
-static void * (*isc_mallocfn)(size_t size) =
-    (void * (*)(size_t)) NULL;
-  
-static void * (*isc_reallocfn)(void *bufp, size_t size) =
-    (void * (*)(void *, size_t)) NULL;
-     
-static void (*isc_freefn)(void *bufp) =
-     (void (*)(void *)) NULL;
+static void * (*isc_mallocfn)(size_t size) = NULL;
+static void * (*isc_reallocfn)(void *bufp, size_t size) = NULL;
+static void (*isc_freefn)(void *bufp) = NULL;
 
 
 /*
@@ -62,14 +64,14 @@ isc_setallocfn(void * (*mallocfn)(size_t size),
 void *
 isc_malloc(size_t size)
 {
-  unsigned int  * buf;
+  unsigned long  * buf;
 
 
   if (isc_mallocfn)
-    buf = (unsigned int *) (*isc_mallocfn)(size + sizeof(unsigned int));
+    buf = (unsigned long *) (*isc_mallocfn)(size + sizeof(unsigned long));
   else
   {
-    buf = (unsigned int *) malloc(size + sizeof(unsigned int));
+    buf = (unsigned long *) malloc(size + sizeof(unsigned long));
     if (!buf)
       isc_abort("isc_malloc");
   }
@@ -83,33 +85,24 @@ isc_malloc(size_t size)
 void *
 isc_realloc(void *oldbuf, size_t size)
 {
-  unsigned int *buf;
+  unsigned long *buf;
 
 
   if (!oldbuf)
     return isc_malloc(size);
 
-  buf = (unsigned int *) oldbuf;
-  switch (*--buf)
-  {
-    case ISC_MAGIC_ALLOC:
-      break;
-
-    case ISC_MAGIC_FREE:
-      isc_abort("isc_realloc");
-
-    default:
-      isc_abort("isc_realloc");
-  }
+  buf = (unsigned long *) oldbuf;
+  if (*--buf != ISC_MAGIC_ALLOC)
+    isc_abort("isc_realloc");
 
   *buf = ISC_MAGIC_FREE;
   
   if (isc_reallocfn)
-    buf = (unsigned int *) (*isc_reallocfn)((void *) buf,
-					    size + sizeof(unsigned int));
+    buf = (unsigned long *) (*isc_reallocfn)((void *) buf,
+					     size + sizeof(unsigned long));
   else
   {
-    buf = (void *) realloc((void *) buf, size + sizeof(unsigned int));
+    buf = (void *) realloc((void *) buf, size + sizeof(unsigned long));
     if (!buf)
       isc_abort("isc_realloc");
   }
@@ -123,24 +116,15 @@ isc_realloc(void *oldbuf, size_t size)
 void
 isc_free(void *buf)
 {
-  unsigned int *ibuf;
+  unsigned long *ibuf;
 
   
   if (!buf)
     isc_abort("isc_free");
     
-  ibuf = (unsigned int *) buf;
-  switch (*--ibuf)
-  {
-    case ISC_MAGIC_ALLOC:
-      break;
-
-    case ISC_MAGIC_FREE:
-      isc_abort("isc_free");
-
-    default:
-      isc_abort("isc_free");
-  }
+  ibuf = (unsigned long *) buf;
+  if (*--ibuf != ISC_MAGIC_ALLOC)
+    isc_abort("isc_free");
 
   *ibuf = ISC_MAGIC_FREE;
   
diff --git a/src/libraries/libisc-new/src/isc_event.c b/src/libraries/libisc-new/src/isc_event.c
index cd359505f27dd20cc9dd05b6cde1dbc98dc77826..603ff257a6c20d0a9b588d99ddff67ac3d6a3967 100644
--- a/src/libraries/libisc-new/src/isc_event.c
+++ b/src/libraries/libisc-new/src/isc_event.c
@@ -15,31 +15,34 @@
 */
 
 #include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <time.h>
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
+#ifdef TIME_WITH_SYS_TIME
+#  include <time.h>
+#endif
 #include <sys/types.h>
 #include <sys/time.h>
+#include <sys/socket.h>
 #include <errno.h>
-#include <stddef.h>
-#include <string.h>
+#ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#endif
+#ifdef HAVE_SYS_SELECT_H
+#  include <sys/select.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>	/* Needed on NetBSD1.1/SPARC due to select */
+#endif
+#ifdef HAVE_STRING_H
+#  include <string.h>	/* Needed on NetBSD1.1/SPARC due to bzero */
+#endif
 
 #include "isc.h"
 #include "intern.h"
 
 
 
-/*
- * External function declarations.
- */
-extern void *bzero(void *buf, unsigned length);
-extern time_t time(time_t *buf);
-extern int select(int setsize,
-		  fd_set *rs, fd_set *rw, fd_set *es,
-		  struct timeval *wait);
-
-
-
 IscEvent *
 isc_getnextevent(IscMaster *mcb, long timeout)
 {
@@ -62,6 +65,7 @@ isc_getnextevent(IscMaster *mcb, long timeout)
   ISC_XNEW(event);
   event->msg     = NULL;
   event->session = NULL;
+  event->listen_session = NULL;
 
 RETRY:
   /* Set up the list of file descriptors to wait on */
@@ -101,12 +105,15 @@ RETRY:
 	if (scb->fd == -1 || !isc_pollqueue(scb->wr_msg_q))
 	{
 	  event->event = ISC_EVENT_LOGOUT;
+	  scb->state = ISC_STATE_CLOSING2;
 	
 	  /* Move the session pointer to the next in the circular queue */
 	  mcb->sessions = mcb->sessions->next;
 	  
 	  return event;
 	}
+        else
+	  event->session = NULL;
     }
       
     /*
@@ -191,7 +198,7 @@ RETRY:
 	     * Connect request failed
 	     */
 	    scb->state = ISC_STATE_CLOSING;
-	    scb->errno = errno;
+	    scb->isc_errno = errno;
 	    event->event = ISC_EVENT_REJECTED;
 	    event->session = scb;
 	  }
@@ -259,7 +266,7 @@ RETRY:
       else
       {
 	scb->state = ISC_STATE_CLOSING;
-	scb->errno = errno;
+	scb->isc_errno = errno;
       }
     }
     
@@ -290,6 +297,7 @@ RETRY:
       /* Fill in the event info structure */
       event->session = new_scb;
       event->event   = ISC_EVENT_LOGIN;
+      event->listen_session = scb;
 
       /* Move the session pointer to the next in the circular queue */
       mcb->sessions = mcb->sessions->next;
@@ -323,7 +331,7 @@ RETRY:
       break;
   }
 
-  goto RETRY; /* This happens if/when only transmits where pending.. */
+  goto RETRY; /* This happens if/when only transmits were pending... */
 }
 
 
diff --git a/src/libraries/libisc-new/src/isc_handler.c b/src/libraries/libisc-new/src/isc_handler.c
index c0a18671a1f4604da77de02d2f4d2c50d9f5bfb4..853c8d196d9ab478a277f9badd50130c2ad3940b 100644
--- a/src/libraries/libisc-new/src/isc_handler.c
+++ b/src/libraries/libisc-new/src/isc_handler.c
@@ -9,6 +9,12 @@
 */
 
 #include <stdio.h>
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <time.h>
 
 #include "isc.h"
 #include "intern.h"
diff --git a/src/libraries/libisc-new/src/isc_master.c b/src/libraries/libisc-new/src/isc_master.c
index 3801263109df6a0565347925f674334b3593157e..262d73c47884c59133738886d8c5e6e1fcb498e2 100644
--- a/src/libraries/libisc-new/src/isc_master.c
+++ b/src/libraries/libisc-new/src/isc_master.c
@@ -9,9 +9,22 @@
 */
 
 #include <errno.h>
-#include <stdlib.h>
-#include <stddef.h>
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
+#ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#endif
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
+#include <sys/types.h>
 #include <sys/file.h>
+#include <sys/socket.h>
+#ifndef NULL
+#  include <stdio.h>
+#endif
+
 #include "isc.h"
 #include "intern.h"
 
diff --git a/src/libraries/libisc-new/src/isc_message.c b/src/libraries/libisc-new/src/isc_message.c
index 5b22f19365bc0a52e4febe4ac34abd550794a4fc..8d311af08199c71e6d886c6c803591b93c34c2a1 100644
--- a/src/libraries/libisc-new/src/isc_message.c
+++ b/src/libraries/libisc-new/src/isc_message.c
@@ -9,14 +9,25 @@
 ** 920102 pen      added isc_copymsg()
 */
 
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
+#ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#endif
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#endif
+#ifndef NULL
+#  include <stdio.h>
+#endif
+#include <time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
 #include "isc.h"
 #include "intern.h"
 
-extern void *memcpy(void *, const void *, int);
-
 
 IscMessage *
 isc_allocmsg(size_t size)
diff --git a/src/libraries/libisc-new/src/isc_output.c b/src/libraries/libisc-new/src/isc_output.c
index 3ef8bd8114e48fe15f147995887fa631a3fa3ce8..bd7292c5c6c63d8b99879176586108ef61336d2f 100644
--- a/src/libraries/libisc-new/src/isc_output.c
+++ b/src/libraries/libisc-new/src/isc_output.c
@@ -9,28 +9,35 @@
 ** 910310 pen      added isc_send()
 */
 
-#include <stdlib.h>
-#include <stddef.h>
+#ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#endif
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
 #include <errno.h>
-#include <string.h>
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#endif
 #include <sys/file.h>
 #include <errno.h>
+#ifndef NULL
+#  include <stdio.h>
+#endif
+#include <sys/types.h>
+#include <sys/socket.h>
+
 #include "isc.h"
 #include "intern.h"
 
 
-/*
- * External function declarations
- */
-extern void *memcpy(void *, const void *, int);
-extern char *strerror(int);
-
 
 void isc_flush(IscSession *scb)
 {
   switch (scb->state)
   {
     case ISC_STATE_CLOSING:
+    case ISC_STATE_CLOSING2:
       if (scb->wr_msg_q)
       {
 	isc_killqueue(scb->wr_msg_q);
@@ -71,7 +78,7 @@ void isc_oflush(IscSession *scb)
     if (isc_sizequeue(scb->wr_msg_q) >= scb->cfg->max.queuedsize)
     {
       scb->state = ISC_STATE_CLOSING;
-      scb->errno = E2BIG;
+      scb->isc_errno = E2BIG;
       scb->sendindex = 0; /* And lets fake a write */
       return;
     }
@@ -85,7 +92,8 @@ void isc_oflush(IscSession *scb)
 
   /* We only try to transmit messages for RUNNING or CLOSING sessions */
   if ((scb->state != ISC_STATE_RUNNING &&
-      scb->state != ISC_STATE_CLOSING) || scb->fd == -1)
+       scb->state != ISC_STATE_CLOSING &&
+       scb->state != ISC_STATE_CLOSING2) || scb->fd == -1)
     return;
   
   /* Queued entries? Send as much as possible */
@@ -106,12 +114,12 @@ void isc_oflush(IscSession *scb)
 
         case EPIPE:
 	  scb->state = ISC_STATE_CLOSING;
-	  scb->errno = errno;
+	  scb->isc_errno = errno;
 	  return;
 
         default:
 	  scb->state = ISC_STATE_CLOSING;
-	  scb->errno = errno;
+	  scb->isc_errno = errno;
           scb->sendindex = 0;
 	  return;
       }
diff --git a/src/libraries/libisc-new/src/isc_queue.c b/src/libraries/libisc-new/src/isc_queue.c
index 9ef41e16d5abf64e8c8bbb00fa5128c0bef97870..6b253425ad55aaa406c2d36f9bbdcd0a898fae4a 100644
--- a/src/libraries/libisc-new/src/isc_queue.c
+++ b/src/libraries/libisc-new/src/isc_queue.c
@@ -8,8 +8,19 @@
 ** 910305 pen      moved to separate file
 */
 
-#include <stdlib.h>
-#include <stddef.h>
+#ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#endif
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
+#ifndef NULL
+#  include <stdio.h>
+#endif
+#include <time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
 #include "isc.h"
 #include "intern.h"
 
diff --git a/src/libraries/libisc-new/src/isc_session.c b/src/libraries/libisc-new/src/isc_session.c
index dd299c3688649d4a55164cd520a9022051bbf97c..2dd2904ebfa71d7cba8eb950875338f9f7682c7a 100644
--- a/src/libraries/libisc-new/src/isc_session.c
+++ b/src/libraries/libisc-new/src/isc_session.c
@@ -13,32 +13,32 @@
 */
 
 #include <sys/types.h>
+#include <sys/socket.h>
 #include <errno.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
+#ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#endif
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
 #include <fcntl.h>
+#ifndef NULL
+#  include <stdio.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
 
 #include "isc.h"
 #include "intern.h"
-
-
-
-/*
-** External function declarations
-*/
-extern void *memset(void *, int, int);
-extern int close(int);
-extern time_t time(time_t *);
-extern int read(int fd, char *buf, int len);
-extern int write(int, char *, int);
+#include "unused.h"
 
 
 
 /*
 ** ISC-Internal default function to read data
 */
-IscMessage *isc_default_read_fn(IscHandlerList *hl, IscSession *scb)
+IscMessage *isc_default_read_fn(IscHandlerList *UNUSED(hl), IscSession *scb)
 {
   int status;
   IscMessage *msg;
@@ -63,7 +63,7 @@ IscMessage *isc_default_read_fn(IscHandlerList *hl, IscSession *scb)
 
 
 
-int isc_default_write_fn(IscHandlerList *hl,
+int isc_default_write_fn(IscHandlerList *UNUSED(hl),
 			 IscSession *scb,
 			 IscMessage *msg)
 {
@@ -72,7 +72,7 @@ int isc_default_write_fn(IscHandlerList *hl,
 
 
 
-int isc_default_close_fn(IscHandlerList *hl,
+int isc_default_close_fn(IscHandlerList *UNUSED(hl),
 			 IscSession *scb)
 {
   int code = 0;
@@ -220,7 +220,7 @@ isc_create(IscSessionConfig *cfg, IscHandler *fun)
   scb->fd       = -1;
   scb->type     = ISC_TYPE_UNKNOWN;
   scb->state    = ISC_STATE_UNKNOWN;
-  scb->errno    = 0;
+  scb->isc_errno= 0;
   scb->rd_msg_q = NULL;
   scb->wr_msg_q = NULL; 
   scb->handlers = NULL;
@@ -364,8 +364,12 @@ isc_openfd(IscMaster *mcb,
     close(fd);
     return NULL;
   }
-  
-  if (fcntl(fd, F_SETFL, res | FNDELAY) == -1)
+
+  /* If compilation fails on the next line, please report it as a bug
+     to ceder@lysator.liu.se.  I'd like to talk to you so that you can
+     test an autoconf solution to this problem.  As a workaround, you
+     can change "O_NONBLOCK" to "FNDELAY". */
+  if (fcntl(fd, F_SETFL, res | O_NONBLOCK) == -1)
   {
     close(fd);
     return NULL;
@@ -387,7 +391,7 @@ isc_openfd(IscMaster *mcb,
 
 
 static void
-isc_file_destroy_fn(IscHandlerList *hl,
+isc_file_destroy_fn(IscHandlerList *UNUSED(hl),
 		    IscSession *scb)
 {
   if (scb->info.file.pathname)
diff --git a/src/libraries/libisc-new/src/isc_socket.c b/src/libraries/libisc-new/src/isc_socket.c
index 9285ed8ed3ddc91fb61bf9e087d594cec41a9733..6de9ae642d79c81495a98f45c4cbecf313ac4f84 100644
--- a/src/libraries/libisc-new/src/isc_socket.c
+++ b/src/libraries/libisc-new/src/isc_socket.c
@@ -9,43 +9,34 @@
 */
 
 #include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <time.h>
+#ifdef TIME_WITH_SYS_TIME
+#  include <time.h>
+#endif
 #include <sys/types.h>
 #include <sys/time.h>
 #include <netinet/in.h>
-#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
+#include <sys/socket.h>
 #include <errno.h>
 #include <netdb.h>
-#include <stddef.h>
-#include <string.h>
+#ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#endif
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#endif
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
 #include <fcntl.h>
-#include <sys/file.h>
 
 #include "isc.h"
 #include "intern.h"
 
 
 
-/*
- * External function declarations.
- */
-extern void *bzero(void *buf, unsigned length);
-extern void *memcpy(void *, const void *, int);
-extern int getsockname(int fd, struct sockaddr *, int *);
-extern int getpeername(int fd, struct sockaddr *, int *);
-extern time_t time(time_t *buf);
-extern int select(int setsize,
-		  fd_set *rs, fd_set *rw, fd_set *es,
-		  struct timeval *wait);
-extern int accept(int fd, struct sockaddr *sock, int *len);
-
-
-
 #if defined(__GNUC__) && defined(__sparc__)
 /*
 ** inet_ntoa() is buggy on SPARCs running SunOS 4.1.1, so
@@ -179,6 +170,10 @@ char *isc_gethostname(IscAddress *ia, char *buf, int len)
   struct sockaddr_in *addr;
   struct hostent *hp;
   
+  if (ia == NULL)
+  {
+    return NULL;
+  }
 
   if (!buf)
   {
@@ -188,7 +183,7 @@ char *isc_gethostname(IscAddress *ia, char *buf, int len)
   
   addr = (struct sockaddr_in *) &ia->ip.saddr;
   
-  hp = gethostbyaddr(&addr->sin_addr,sizeof(struct in_addr),AF_INET);
+  hp = gethostbyaddr((char*)&addr->sin_addr, sizeof(struct in_addr), AF_INET);
   if (!hp)
     return NULL;
   
diff --git a/src/libraries/libisc-new/src/isc_stdout.c b/src/libraries/libisc-new/src/isc_stdout.c
index 95f6aece23d4e699bd1acdd3e32117ca1ca189d7..8c5bec104f4275f875c38d016524c88945aa4df9 100644
--- a/src/libraries/libisc-new/src/isc_stdout.c
+++ b/src/libraries/libisc-new/src/isc_stdout.c
@@ -9,13 +9,21 @@
 */
 
 #include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include "isc.h"
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#endif
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
+#include <time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 
+#include "isc.h"
 
-extern int _printf( int (*fctn)(int chr), const char *format, ...);
-extern void *memcpy(void *, const void *, int);
+#ifdef ISC_PRINTF_SUPPORT
+extern int UCB_printf( int (*fctn)(int chr), const char *format, ...);
+#endif
 
 int
 isc_putc(int           chr,
@@ -75,6 +83,8 @@ isc_write(IscSession  * scb,
 
 
 
+#ifdef ISC_PRINTF_SUPPORT
+
 static IscSession  * send_scb;  /* Used by isc_printf */
 
 static int send_putc(int c)
@@ -90,7 +100,7 @@ isc_vprintf(IscSession  * scb,
 {
   send_scb = scb;
   
-  return _printf(send_putc, format, AP);
+  return UCB_printf(send_putc, format, AP);
 }
 
 
@@ -107,9 +117,11 @@ isc_printf(IscSession  * scb,
 
   send_scb = scb;
   
-  cnt = _printf(send_putc, format, AP);
+  cnt = UCB_printf(send_putc, format, AP);
 
   va_end(AP);
 
   return cnt;
 }
+
+#endif /* ISC_PRINTF_SUPPORT */
diff --git a/src/libraries/libisc-new/src/isc_tcp.c b/src/libraries/libisc-new/src/isc_tcp.c
index 1feb3fe370a9809a52f261b54ebbd581dc5a4e49..00aba05396c0ece3843cc9f618699ed74f4613d1 100644
--- a/src/libraries/libisc-new/src/isc_tcp.c
+++ b/src/libraries/libisc-new/src/isc_tcp.c
@@ -9,45 +9,43 @@
 */
 
 #include <errno.h>
-#include <stdlib.h>
-#include <stddef.h>
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
+#ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#endif
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
 #include <ctype.h>
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
+#include <sys/socket.h>
 #include <netdb.h>
-#include <string.h>
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#endif
 #include <fcntl.h>
+#ifndef NULL
+#  include <stdio.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
 
 #include "isc.h"
 #include "intern.h"
+#include "unused.h"
 
 
-
-/*
-** External function declarations
-*/
-extern void *memset(void *, int, int);
-extern void *memcpy(void *, const void *, int);
-extern int socket(int, int, int);
-extern int setsockopt(int, int, int, char *, int);
-extern int listen(int, int);
-extern int connect(int, struct sockaddr *, int);
-extern int bind(int, struct sockaddr *, int);
-extern int close(int);
-extern int atoi(const char *str);
-extern time_t sleep(time_t);
-extern int accept(int fd, struct sockaddr *sock, int *len);
-
-
-
-IscSession *
-isc_tcp_accept_fn(IscHandlerList *hl,
+static IscSession *
+isc_tcp_accept_fn(IscHandlerList *UNUSED(hl),
 		  IscSession *scb,
-		  IscMessage *msg)
+		  IscMessage *UNUSED(msg))
 {
   IscSession *new_scb;
   int fd;
@@ -79,8 +77,8 @@ isc_tcp_accept_fn(IscHandlerList *hl,
 
 
 
-void
-isc_tcp_destroy_fn(IscHandlerList *hl,
+static void
+isc_tcp_destroy_fn(IscHandlerList *UNUSED(hl),
 		   IscSession *scb)
 {
   if (scb->info.tcp.raddr)
@@ -94,7 +92,6 @@ isc_tcp_destroy_fn(IscHandlerList *hl,
     isc_freeaddress(scb->info.tcp.laddr);
     scb->info.tcp.laddr = NULL;
   }
-
 }
 
 
@@ -118,7 +115,7 @@ static IscHandler isc_tcp_funs =
 /*
 ** Create a TCP Session Address
 */
-IscAddress *
+static IscAddress *
 isc_mktcpaddress(const char *address,
 		 const char *service)
 {
@@ -135,7 +132,7 @@ isc_mktcpaddress(const char *address,
     addr.sin_family = AF_INET;
     addr.sin_addr.s_addr = htonl(INADDR_ANY);
   }
-  else if (isdigit(address[0]))
+  else if (isdigit((int)(unsigned char)address[0]))
   {
     addr.sin_family = AF_INET;
     addr.sin_addr.s_addr = inet_addr(address);
@@ -150,7 +147,7 @@ isc_mktcpaddress(const char *address,
     memcpy(&addr.sin_addr, hp->h_addr, sizeof(addr.sin_addr));
   }
   
-  if (isdigit(service[0]))
+  if (isdigit((int)(unsigned char)service[0]))
     addr.sin_port = htons(atoi(service));
   else if ((sp = getservbyname(service, "tcp")) == NULL)
     return NULL;
@@ -170,6 +167,8 @@ isc_createtcp(IscSessionConfig *cfg, int fd)
 {
   IscSession *scb;
   int res;
+  int flag;
+  struct linger ling;
   
 
   if (fd == -1)
@@ -183,14 +182,29 @@ isc_createtcp(IscSessionConfig *cfg, int fd)
     return NULL;
   }
     
-  if (fcntl(fd, F_SETFL, res | FNDELAY) == -1)
+  /* If compilation fails on the next line, please report it as a bug
+     to ceder@lysator.liu.se.  I'd like to talk to you so that you can
+     test an autoconf solution to this problem.  As a workaround, you
+     can change "O_NONBLOCK" to "FNDELAY". */
+  if (fcntl(fd, F_SETFL, res | O_NONBLOCK) == -1)
   {
     close(fd);
     return NULL;
   }
-  
+
+#if 0
+  /* The setsockopt calls below used to look like this, but this style is
+     apparently now obsolete.  It doesn't work on some Linux boxes. */
   setsockopt(fd, SOL_SOCKET, SO_DONTLINGER, 0, 0); 
   setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, 0, 0);
+#else
+  /* This is the modern way to turn off linger and turn on reuseaddr. */
+  ling.l_onoff = 0;
+  ling.l_linger = 0;
+  setsockopt(fd, SOL_SOCKET, SO_LINGER, &ling, sizeof(ling)); 
+  flag = 1;
+  setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
+#endif
   
   scb = isc_create(cfg, &isc_tcp_funs);
   if (!scb)
@@ -320,10 +334,12 @@ isc_listentcp(IscMaster  *mcb,
   if (!scb)
     return NULL;
 
-  errno = 0;
   for (retries = 0; retries < scb->cfg->max.openretries; sleep(1), retries++)
+  {
+    errno = 0;
     if (isc_bindtcp(scb, address, service) >= 0 || errno != EADDRINUSE)
       break;
+  }
 
   if (retries >= scb->cfg->max.openretries || errno != 0)
   {
diff --git a/src/libraries/libisc-new/src/isc_udp.c b/src/libraries/libisc-new/src/isc_udp.c
index 01a42ac4f8e6fc8eb0fe0a24adb3839951579bf4..05cbe8bb6cc813f65359cb069f3b59b4bdfc4c73 100644
--- a/src/libraries/libisc-new/src/isc_udp.c
+++ b/src/libraries/libisc-new/src/isc_udp.c
@@ -10,44 +10,45 @@
 
 #include <sys/types.h>
 #include <errno.h>
-#include <stdlib.h>
-#include <stddef.h>
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
+#ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#endif
+#ifdef HAVE_STDARG_H
+#  include <stdarg.h>
+#endif
 #include <ctype.h>
 #include <netinet/in.h>
-#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
+#include <sys/socket.h>
 #include <netdb.h>
-#include <string.h>
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#endif
 #include <fcntl.h>
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+#ifndef NULL
+#  include <stdio.h>
+#endif
 
 #include "isc.h"
 #include "intern.h"
-
-
-
-extern void *memset(void *, int, int);
-extern void *memcpy(void *, const void *, int);
-extern int socket(int, int, int);
-extern int setsockopt(int, int, int, char *, int);
-extern int connect(int, struct sockaddr *, int);
-extern int bind(int, struct sockaddr *, int);
-extern int close(int);
-extern int atoi(const char *str);
-extern int recvfrom(int fd, char *buf, int len, int flags,
-		    struct sockaddr *from, int *flen);
-extern int sendto(int fd, char *buf, int len, int flags,
-		  struct sockaddr *from, int flen);
-extern int sprintf(char *, const char *, ...);
+#include "unused.h"
 
 
 
 /*
 ** Receive an UDP message and put it into an IscMessage
 */
-IscMessage *isc_udp_read_fn(IscHandlerList *hl,
-			    IscSession *scb)
+static IscMessage *
+isc_udp_read_fn(IscHandlerList *UNUSED(hl),
+		IscSession *scb)
 {
   IscMessage *msg;
   struct sockaddr addr;
@@ -80,9 +81,10 @@ IscMessage *isc_udp_read_fn(IscHandlerList *hl,
 /*
 ** Transmit an UDP message to a remote service
 */
-int isc_udp_write_fn(IscHandlerList *hl,
-		     IscSession *scb,
-		     IscMessage *msg)
+static int
+isc_udp_write_fn(IscHandlerList *hl,
+		 IscSession *scb,
+		 IscMessage *msg)
 {
   /* No target and no default target? Then fail. */
   if (!msg->address && !scb->info.udp.raddr)
@@ -103,8 +105,8 @@ int isc_udp_write_fn(IscHandlerList *hl,
 
 
 
-void
-isc_udp_destroy_fn(IscHandlerList *hl,
+static void
+isc_udp_destroy_fn(IscHandlerList *UNUSED(hl),
 		   IscSession *scb)
 {
   if (scb->info.udp.raddr)
@@ -125,7 +127,7 @@ isc_udp_destroy_fn(IscHandlerList *hl,
 /*
 ** Create an UDP Session Address
 */
-IscAddress *
+static IscAddress *
 isc_mkudpaddress(const char *address,
 		 const char *service)
 {
@@ -148,7 +150,7 @@ isc_mkudpaddress(const char *address,
     addr.sin_family = AF_INET;
     addr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
   }
-  else if (isdigit(address[0]))
+  else if (isdigit((int)(unsigned char)address[0]))
   {
     addr.sin_family = AF_INET;
     addr.sin_addr.s_addr = inet_addr(address);
@@ -163,7 +165,7 @@ isc_mkudpaddress(const char *address,
     memcpy(&addr.sin_addr, hp->h_addr, sizeof(addr.sin_addr));
   }
   
-  if (isdigit(service[0]))
+  if (isdigit((int)(unsigned char)service[0]))
     addr.sin_port = htons(atoi(service));
   else if ((sp = getservbyname(service, "udp")) == NULL)
     return NULL;
@@ -196,7 +198,8 @@ isc_createudp(IscSessionConfig *cfg)
 {
   IscSession *scb;
   int fd, res;
-  
+  int flag;
+  struct linger ling;
   
   if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
     return NULL;
@@ -208,14 +211,29 @@ isc_createudp(IscSessionConfig *cfg)
     return NULL;
   }
     
-  if (fcntl(fd, F_SETFL, res | FNDELAY) == -1)
+  /* If compilation fails on the next line, please report it as a bug
+     to ceder@lysator.liu.se.  I'd like to talk to you so that you can
+     test an autoconf solution to this problem.  As a workaround, you
+     can change "O_NONBLOCK" to "FNDELAY". */
+  if (fcntl(fd, F_SETFL, res | O_NONBLOCK) == -1)
   {
     close(fd);
     return NULL;
   }
   
+#if 0
+  /* The setsockopt calls below used to look like this, but this style is
+     apparently now obsolete.  It doesn't work on some Linux boxes. */
   setsockopt(fd, SOL_SOCKET, SO_DONTLINGER, 0, 0); 
   setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, 0, 0);
+#else
+  /* This is the modern way to turn off linger and turn on reuseaddr. */
+  ling.l_onoff = 0;
+  ling.l_linger = 0;
+  setsockopt(fd, SOL_SOCKET, SO_LINGER, &ling, sizeof(ling)); 
+  flag = 1;
+  setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
+#endif
   
   scb = isc_create(cfg, &isc_udp_funs);
   if (!scb)
diff --git a/src/libraries/libisc-new/src/printf.c b/src/libraries/libisc-new/src/printf.c
index 87c321e8d7051a27a512e4ab043e474a7b57b57e..121af126c6eac072927c42228e1e35fc402b01d9 100644
--- a/src/libraries/libisc-new/src/printf.c
+++ b/src/libraries/libisc-new/src/printf.c
@@ -51,17 +51,15 @@ static char sccsid[] = "@(#)doprnt.c	5.39 (Berkeley) 6/28/90";
 #include <varargs.h>
 #include <stdio.h>
 #include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
 #include <math.h>
 
 
-/*
- * External function declarations
- */
-extern char *memchr(char *, int, int);
-
-
 /* 11-bit exponent (VAX G floating point) is 308 decimal digits */
 #define	MAXEXP		308
 /* 128 bit fraction takes up 39 decimal digits; max reasonable precision */
@@ -99,7 +97,7 @@ static char *exponent(char *, int, u_char);
 #define	ZEROPAD		0x20		/* zero (as opposed to blank) pad */
 #define	HEXPREFIX	0x40		/* add 0x or 0X prefix */
 
-int _printf(pr_chr, fmt0, argp)
+int UCB_printf(pr_chr, fmt0, argp)
   int (*pr_chr)();
   u_char *fmt0;
   va_list argp;