about summary refs log tree commit diff stats
path: root/WWW/Library
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1998-08-06 13:04:14 -0400
committerThomas E. Dickey <dickey@invisible-island.net>1998-08-06 13:04:14 -0400
commitd7e8d7e419ae58610a9988ff09910670a59526ff (patch)
treea7c02ce435a282a5f60b1a297b5dd4d053b92d67 /WWW/Library
parente6ba2a01f70f84d9133cf305e4b493c9d656cb21 (diff)
downloadlynx-snapshots-d7e8d7e419ae58610a9988ff09910670a59526ff.tar.gz
snapshot of project "lynx", label v2-8-1dev_20
Diffstat (limited to 'WWW/Library')
-rw-r--r--WWW/Library/Implementation/HTAABrow.c1
-rw-r--r--WWW/Library/Implementation/HTAABrow.h4
-rw-r--r--WWW/Library/Implementation/HTAAFile.c6
-rw-r--r--WWW/Library/Implementation/HTAAFile.h3
-rw-r--r--WWW/Library/Implementation/HTAAProt.c1
-rw-r--r--WWW/Library/Implementation/HTAAProt.h3
-rw-r--r--WWW/Library/Implementation/HTAAServ.c2
-rw-r--r--WWW/Library/Implementation/HTAAServ.h3
-rw-r--r--WWW/Library/Implementation/HTAAUtil.c3
-rw-r--r--WWW/Library/Implementation/HTAAUtil.h44
-rw-r--r--WWW/Library/Implementation/HTACL.c3
-rw-r--r--WWW/Library/Implementation/HTACL.h3
-rw-r--r--WWW/Library/Implementation/HTAccess.c24
-rw-r--r--WWW/Library/Implementation/HTAccess.h4
-rw-r--r--WWW/Library/Implementation/HTAnchor.c8
-rw-r--r--WWW/Library/Implementation/HTAssoc.c3
-rw-r--r--WWW/Library/Implementation/HTAssoc.h4
-rw-r--r--WWW/Library/Implementation/HTAtom.c15
-rw-r--r--WWW/Library/Implementation/HTAtom.h3
-rw-r--r--WWW/Library/Implementation/HTAuth.c1
-rw-r--r--WWW/Library/Implementation/HTAuth.h3
-rw-r--r--WWW/Library/Implementation/HTBTree.c88
-rw-r--r--WWW/Library/Implementation/HTBTree.h9
-rw-r--r--WWW/Library/Implementation/HTCJK.h2
-rw-r--r--WWW/Library/Implementation/HTChunk.c2
-rw-r--r--WWW/Library/Implementation/HTChunk.h8
-rw-r--r--WWW/Library/Implementation/HTDOS.c4
-rw-r--r--WWW/Library/Implementation/HTFTP.c3
-rw-r--r--WWW/Library/Implementation/HTFTP.h3
-rw-r--r--WWW/Library/Implementation/HTFWriter.c2
-rw-r--r--WWW/Library/Implementation/HTFWriter.h3
-rw-r--r--WWW/Library/Implementation/HTFile.c16
-rw-r--r--WWW/Library/Implementation/HTFinger.c3
-rw-r--r--WWW/Library/Implementation/HTFormat.c3
-rw-r--r--WWW/Library/Implementation/HTFormat.h3
-rw-r--r--WWW/Library/Implementation/HTGopher.c5
-rw-r--r--WWW/Library/Implementation/HTGroup.c3
-rw-r--r--WWW/Library/Implementation/HTGroup.h3
-rw-r--r--WWW/Library/Implementation/HTHistory.c1
-rw-r--r--WWW/Library/Implementation/HTInit.h10
-rw-r--r--WWW/Library/Implementation/HTLex.c1
-rw-r--r--WWW/Library/Implementation/HTLex.h7
-rw-r--r--WWW/Library/Implementation/HTList.c3
-rw-r--r--WWW/Library/Implementation/HTList.h4
-rw-r--r--WWW/Library/Implementation/HTMIME.c2
-rw-r--r--WWW/Library/Implementation/HTMLDTD.h3
-rw-r--r--WWW/Library/Implementation/HTMLGen.c3
-rw-r--r--WWW/Library/Implementation/HTNews.c5
-rw-r--r--WWW/Library/Implementation/HTParse.c3
-rw-r--r--WWW/Library/Implementation/HTParse.h2
-rw-r--r--WWW/Library/Implementation/HTPasswd.c4
-rw-r--r--WWW/Library/Implementation/HTPasswd.h3
-rw-r--r--WWW/Library/Implementation/HTPlain.c4
-rw-r--r--WWW/Library/Implementation/HTRules.c5
-rw-r--r--WWW/Library/Implementation/HTRules.h2
-rw-r--r--WWW/Library/Implementation/HTStream.h2
-rw-r--r--WWW/Library/Implementation/HTString.c5
-rw-r--r--WWW/Library/Implementation/HTString.h2
-rw-r--r--WWW/Library/Implementation/HTStyle.c3
-rw-r--r--WWW/Library/Implementation/HTStyle.h3
-rw-r--r--WWW/Library/Implementation/HTTCP.c3
-rw-r--r--WWW/Library/Implementation/HTTCP.h6
-rw-r--r--WWW/Library/Implementation/HTTP.c2
-rw-r--r--WWW/Library/Implementation/HTTelnet.c3
-rw-r--r--WWW/Library/Implementation/HTUU.h5
-rw-r--r--WWW/Library/Implementation/HTUtils.h36
-rw-r--r--WWW/Library/Implementation/HTVMSUtils.c10
-rw-r--r--WWW/Library/Implementation/HTVMSUtils.h8
-rw-r--r--WWW/Library/Implementation/HTVMS_WaisProt.c81
-rw-r--r--WWW/Library/Implementation/HTVMS_WaisProt.h124
-rw-r--r--WWW/Library/Implementation/HTVMS_WaisUI.c534
-rw-r--r--WWW/Library/Implementation/HTVMS_WaisUI.h230
-rw-r--r--WWW/Library/Implementation/HTWAIS.c3
-rw-r--r--WWW/Library/Implementation/HTWAIS.h3
-rw-r--r--WWW/Library/Implementation/HTWSRC.c3
-rw-r--r--WWW/Library/Implementation/HTWSRC.h4
-rw-r--r--WWW/Library/Implementation/HTWriter.c4
-rw-r--r--WWW/Library/Implementation/LYLeaks.h1
-rw-r--r--WWW/Library/Implementation/LYexit.h1
-rw-r--r--WWW/Library/Implementation/SGML.c4
-rw-r--r--WWW/Library/Implementation/SGML.h3
-rw-r--r--WWW/Library/Implementation/UCAux.h2
-rw-r--r--WWW/Library/Implementation/UCDefs.h2
-rw-r--r--WWW/Library/Implementation/UCMap.h4
-rw-r--r--WWW/Library/Implementation/crypt.c2
-rw-r--r--WWW/Library/Implementation/crypt_util.c2
-rw-r--r--WWW/Library/Implementation/entities.h8
-rw-r--r--WWW/Library/Implementation/getline.c3
-rw-r--r--WWW/Library/Implementation/tcp.h19
89 files changed, 635 insertions, 853 deletions
diff --git a/WWW/Library/Implementation/HTAABrow.c b/WWW/Library/Implementation/HTAABrow.c
index 3bba7f3f..f4a00dca 100644
--- a/WWW/Library/Implementation/HTAABrow.c
+++ b/WWW/Library/Implementation/HTAABrow.c
@@ -51,7 +51,6 @@
 */
 
 #include <HTUtils.h>
-#include <string.h>		/* strchr() */
 #include <HTString.h>
 #include <HTParse.h>		/* URL parsing function		*/
 #include <HTList.h>		/* HTList object		*/
diff --git a/WWW/Library/Implementation/HTAABrow.h b/WWW/Library/Implementation/HTAABrow.h
index c62a3c4c..49351cd2 100644
--- a/WWW/Library/Implementation/HTAABrow.h
+++ b/WWW/Library/Implementation/HTAABrow.h
@@ -31,12 +31,8 @@
 #ifndef HTAABROW_H
 #define HTAABROW_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>            /* BOOL, PARAMS, ARGS */
-#endif /* HTUTILS_H */
 #include <HTAAUtil.h>           /* Common parts of AA */
 
-
 #ifdef SHORT_NAMES
 #define HTAAcoAu        HTAA_composeAuth
 #define HTAAsRWA        HTAA_shouldRetryWithAuth
diff --git a/WWW/Library/Implementation/HTAAFile.c b/WWW/Library/Implementation/HTAAFile.c
index 53dde21a..82da7af9 100644
--- a/WWW/Library/Implementation/HTAAFile.c
+++ b/WWW/Library/Implementation/HTAAFile.c
@@ -1,4 +1,3 @@
-
 /* MODULE							HTAAFile.c
 **		FILE ROUTINES FOR AUTHENTICATION
 **		(PASSWD AND GROUP FILES) AND
@@ -14,13 +13,8 @@
 **
 */
 
-
-#ifndef HTUTILS_H
 #include <HTUtils.h>
-#endif /* HTUTILS_H */
 
-#include <tcp.h>		/* Macro FROMASCII() */
-#include <string.h>
 #include <HTAAUtil.h>		/* Common utilities used in AA */
 #include <HTAAFile.h>		/* Implemented here */
 
diff --git a/WWW/Library/Implementation/HTAAFile.h b/WWW/Library/Implementation/HTAAFile.h
index 8549f89f..8986b593 100644
--- a/WWW/Library/Implementation/HTAAFile.h
+++ b/WWW/Library/Implementation/HTAAFile.h
@@ -15,9 +15,6 @@
 #ifndef HTAAFILE_H
 #define HTAAFILE_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>            /* BOOL, PARAMS, ARGS */
-#endif /* HTUTILS_H */
 #include <HTList.h>             /* HTList */
 
 #ifdef SHORT_NAMES
diff --git a/WWW/Library/Implementation/HTAAProt.c b/WWW/Library/Implementation/HTAAProt.c
index 0c8dac86..773474a9 100644
--- a/WWW/Library/Implementation/HTAAProt.c
+++ b/WWW/Library/Implementation/HTAAProt.c
@@ -19,7 +19,6 @@
 
 #include <HTUtils.h>
 
-#include <string.h>
 #ifndef VMS
 #ifndef NOUSERS
 #include <pwd.h>	/* Unix password file routine: getpwnam()	*/
diff --git a/WWW/Library/Implementation/HTAAProt.h b/WWW/Library/Implementation/HTAAProt.h
index b4d00f49..ed36f656 100644
--- a/WWW/Library/Implementation/HTAAProt.h
+++ b/WWW/Library/Implementation/HTAAProt.h
@@ -5,9 +5,6 @@
 #ifndef HTAAPROT_H
 #define HTAAPROT_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTGroup.h>
 #include <HTAssoc.h>
 
diff --git a/WWW/Library/Implementation/HTAAServ.c b/WWW/Library/Implementation/HTAAServ.c
index 674c6dc3..c081a3fa 100644
--- a/WWW/Library/Implementation/HTAAServ.c
+++ b/WWW/Library/Implementation/HTAAServ.c
@@ -43,8 +43,6 @@
 
 #include <HTUtils.h>
 
-#include <string.h>		/* strchr() */
-
 #include <HTString.h>
 #include <HTAccess.h>		/* HTSecure			*/
 #include <HTFile.h>		/* HTLocalName			*/
diff --git a/WWW/Library/Implementation/HTAAServ.h b/WWW/Library/Implementation/HTAAServ.h
index 6e300032..a2946ec4 100644
--- a/WWW/Library/Implementation/HTAAServ.h
+++ b/WWW/Library/Implementation/HTAAServ.h
@@ -31,9 +31,6 @@
 #ifndef HTAASERV_H
 #define HTAASERV_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>            /* BOOL, PARAMS, ARGS   */
-#endif /* HTUTILS_H */
 #include <HTRules.h>            /* This module interacts with rule system */
 #include <HTAAUtil.h>           /* Common parts of AA   */
 #include <HTAuth.h>             /* Authentication       */
diff --git a/WWW/Library/Implementation/HTAAUtil.c b/WWW/Library/Implementation/HTAAUtil.c
index 7653c312..05726a8e 100644
--- a/WWW/Library/Implementation/HTAAUtil.c
+++ b/WWW/Library/Implementation/HTAAUtil.c
@@ -44,8 +44,7 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>	/* NETREAD() etc.	*/
-#include <string.h>
+
 #include <HTAAUtil.h>	/* Implemented here	*/
 #include <HTAssoc.h>	/* Assoc list		*/
 #include <HTTCP.h>
diff --git a/WWW/Library/Implementation/HTAAUtil.h b/WWW/Library/Implementation/HTAAUtil.h
index de6878e6..059d5b03 100644
--- a/WWW/Library/Implementation/HTAAUtil.h
+++ b/WWW/Library/Implementation/HTAAUtil.h
@@ -1,39 +1,35 @@
 /*                                            Utilities for the Authorization parts of libwww
              COMMON PARTS OF AUTHORIZATION MODULE TO BOTH SERVER AND BROWSER
-                                             
+
    This module is the interface to the common parts of Access Authorization (AA) package
    for both server and browser. Important to know about memory allocation:
-   
+
    Routines in this module use dynamic allocation, but free automatically all the memory
    reserved by them.
-   
+
    Therefore the caller never has to (and never should) free() any object returned by
    these functions.
-   
+
    Therefore also all the strings returned by this package are only valid until the next
    call to the same function is made. This approach is selected, because of the nature of
    access authorization: no string returned by the package needs to be valid longer than
    until the next call.
-   
+
    This also makes it easy to plug the AA package in: you don't have to ponder whether to
    free() something here or is it done somewhere else (because it is always done somewhere
    else).
-   
+
    The strings that the package needs to store are copied so the original strings given as
    parameters to AA functions may be freed or modified with no side effects.
-   
+
    Also note: The AA package does not free() anything else than what it has itself
    allocated.
-   
+
  */
 
 #ifndef HTAAUTIL_H
 #define HTAAUTIL_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>            /* BOOL, PARAMS, ARGS */
-#endif /* HTUTILS_H */
-#include <tcp.h>
 #include <HTList.h>
 
 #ifdef SHORT_NAMES
@@ -76,22 +72,17 @@ Default filenames
 #define MAX_FIELDNAME_LEN       16      /* @@ Longest field name in       */
                                         /* protection setup file          */
 #define MAX_PATHNAME_LEN        80      /* @@ Longest passwd/group file   */
-                                        /* patname to allow               */
-
-/*
-** Helpful macros
-*/
-#define FREE(x) if (x) {free(x); x = NULL;}
+                                        /* pathname to allow               */
 
 /*
 
 Datatype definitions
 
   HTAASCHEME
-  
+
    The enumeration HTAAScheme represents the possible authentication schemes used by the
    WWW Access Authorization.
-   
+
  */
 
 typedef enum {
@@ -107,7 +98,7 @@ typedef enum {
 /*
 
   ENUMERATION TO REPRESENT HTTP METHODS
-  
+
  */
 
 typedef enum {
@@ -206,11 +197,11 @@ Match Template Against Filename
 **
 ** ON ENTRY:
 **      template        is a template string to match the file name
-**                      agaist, may contain a single wildcard
+**                      against, may contain a single wildcard
 **                      character * which matches zero or more
 **                      arbitrary characters.
 **      filename        is the filename (or pathname) to be matched
-**                      agaist the template.
+**                      against the template.
 **
 ** ON EXIT:
 **      returns         YES, if filename matches the template.
@@ -232,11 +223,11 @@ PUBLIC BOOL HTAA_templateMatch PARAMS((CONST char * template,
 **
 ** ON ENTRY:
 **      template        is a template string to match the file name
-**                      agaist, may contain a single wildcard
+**                      against, may contain a single wildcard
 **                      character * which matches zero or more
 **                      arbitrary characters.
 **      filename        is the filename (or pathname) to be matched
-**                      agaist the template.
+**                      against the template.
 **
 ** ON EXIT:
 **      returns         YES, if filename matches the template.
@@ -355,6 +346,3 @@ PUBLIC void HTAA_setupReader PARAMS((char *     start_of_headers,
 PUBLIC char *HTAA_getUnfoldedLine NOPARAMS;
 
 #endif  /* NOT HTAAUTIL_H */
-/*
-
-   End of file HTAAUtil.h. */
diff --git a/WWW/Library/Implementation/HTACL.c b/WWW/Library/Implementation/HTACL.c
index ad6ff3e0..cca7753f 100644
--- a/WWW/Library/Implementation/HTACL.c
+++ b/WWW/Library/Implementation/HTACL.c
@@ -17,9 +17,6 @@
 
 
 #include <HTUtils.h>
-
-#include <string.h>
-
 #include <HTAAFile.h>	/* File routines	*/
 #include <HTGroup.h>	/* GroupDef		*/
 #include <HTACL.h>	/* Implemented here	*/
diff --git a/WWW/Library/Implementation/HTACL.h b/WWW/Library/Implementation/HTACL.h
index 3dfef27c..d1431b34 100644
--- a/WWW/Library/Implementation/HTACL.h
+++ b/WWW/Library/Implementation/HTACL.h
@@ -5,9 +5,6 @@
 #ifndef HTACL_H
 #define HTACL_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTAAUtil.h>
 #include <HTGroup.h>
 
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index 0380bd9e..f98a14bf 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -63,8 +63,6 @@
 #include <LYexit.h>
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 extern HTCJKlang HTCJK;
 
 /*
@@ -331,10 +329,10 @@ PUBLIC BOOL override_proxy ARGS1(
 **
 **  On entry,
 **	addr		must point to the fully qualified hypertext reference.
-**	anchor		a pareent anchor with whose address is addr
+**	anchor		a parent anchor with whose address is addr
 **
 **  On exit,
-**	returns 	HT_NO_ACCESS		Error has occured.
+**	returns 	HT_NO_ACCESS		Error has occurred.
 **			HT_OK			Success
 */
 PRIVATE int get_physical ARGS2(
@@ -578,13 +576,13 @@ PRIVATE int LYUCPopAssumed NOARGS
 **
 **  On entry,
 **	addr		must point to the fully qualified hypertext reference.
-**	anchor		a pareent anchor with whose address is addr
+**	anchor		a parent anchor with whose address is addr
 **
 **  On exit,
-**	returns 	<0		Error has occured.
+**	returns 	<0		Error has occurred.
 **			HT_LOADED	Success
 **			HT_NO_DATA	Success, but no document loaded.
-**					(telnet sesssion started etc)
+**					(telnet session started etc)
 */
 PRIVATE int HTLoad ARGS4(
 	CONST char *,		addr,
@@ -775,12 +773,12 @@ PRIVATE BOOL HTLoadDocument ARGS4(
 	*    If DONT_TRACK_INTERNAL_LINKS is defined, HText_AreDifferent()
 	*    is used to determine whether (3) applies.	If the target address
 	*    differs from that of the current document only by a fragment
-	*    and the taget address has an appended fragment, repositioning
+	*    and the target address has an appended fragment, repositioning
 	*    without reloading is always assumed.
 	*    Note that HText_AreDifferent() currently always returns TRUE
 	*    if the target has a LYNXIMGMAP URL, so that an internally
 	*    generated pseudo-document will normally not be re-used unless
-	*    condition (2) appplies. (Condition (1) cannot apply since in
+	*    condition (2) applies. (Condition (1) cannot apply since in
 	*    LYMap.c, no_cache is always set in the anchor object).  This
 	*    doesn't guarantee that the resource from which the MAP element
 	*    is taken will be read again (reloaded) when the list of links
@@ -971,7 +969,7 @@ PRIVATE BOOL HTLoadDocument ARGS4(
     if (status > 0) {
 	/*
 	**	If you get this, then please find which routine is returning
-	**	a positive unrecognised error code!
+	**	a positive unrecognized error code!
 	*/
 	fprintf(stderr,
  "**** HTAccess: socket or file number returned by obsolete load routine!\n");
@@ -1089,7 +1087,7 @@ PUBLIC BOOL HTLoadRelative ARGS2(
 **	----------------------------------------
 **
 **  On Entry,
-**	  destination		    The child or parenet anchor to be loaded.
+**	  destination		    The child or parent anchor to be loaded.
 **
 **  On Exit,
 **	  returns    YES     Success
@@ -1105,7 +1103,7 @@ PUBLIC BOOL HTLoadAnchor ARGS1(
 
     parent = HTAnchor_parent(destination);
 
-    if (HTAnchor_document(parent) == NULL) {	/* If not alread loaded */
+    if (HTAnchor_document(parent) == NULL) {	/* If not already loaded */
 						/* TBL 921202 */
 	BOOL result;
 	char * address = HTAnchor_address((HTAnchor*) parent);
@@ -1258,7 +1256,7 @@ PUBLIC BOOL HTSearchAbsolute ARGS2(
 **	As it involves file access, this should only be done once
 **	when the program first runs.
 **	This is a default algorithm -- browser don't HAVE to use this.
-**	But consistency betwen browsers is STRONGLY recommended!
+**	But consistency between browsers is STRONGLY recommended!
 **
 **  Priority order is:
 **		1	WWW_HOME environment variable (logical name, etc)
diff --git a/WWW/Library/Implementation/HTAccess.h b/WWW/Library/Implementation/HTAccess.h
index b168dfba..32d8e562 100644
--- a/WWW/Library/Implementation/HTAccess.h
+++ b/WWW/Library/Implementation/HTAccess.h
@@ -15,10 +15,6 @@ extern char * use_this_url_instead;
 
 /*      Definition uses:
 */
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
-#include <tcp.h>
 #include <HTAnchor.h>
 #include <HTFormat.h>
 
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index 9adf69ce..ef76ee1b 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -7,7 +7,7 @@
 ** History
 **
 **	   Nov 1990  Written in Objective-C for the NeXT browser (TBL)
-**	24-Oct-1991 (JFG), written in C, browser-independant
+**	24-Oct-1991 (JFG), written in C, browser-independent
 **	21-Nov-1991 (JFG), first complete version
 **
 **	(c) Copyright CERN 1991 - See Copyright.html
@@ -16,8 +16,6 @@
 #define HASH_SIZE 101		/* Arbitrary prime. Memory/speed tradeoff */
 
 #include <HTUtils.h>
-#include <tcp.h>
-#include <ctype.h>
 #include <HTAnchor.h>
 #include <HTParse.h>
 #include <UCAux.h>
@@ -26,8 +24,6 @@
 #include <LYCharSets.h>
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 #ifdef NOT_DEFINED
 /*
  *	This is the hashing function used to determine which list in the
@@ -84,7 +80,7 @@ PRIVATE HTParentAnchor * HTParentAnchor_new NOARGS
     newAnchor->no_cache = FALSE;	/* no-cache? - FM */
     newAnchor->content_type = NULL;	/* Content-Type. - FM */
     newAnchor->content_language = NULL; /* Content-Language. - FM */
-    newAnchor->content_encoding = NULL; /* Compression algorith. - FM */
+    newAnchor->content_encoding = NULL; /* Compression algorithm. - FM */
     newAnchor->content_base = NULL;	/* Content-Base. - FM */
     newAnchor->content_disposition = NULL; /* Content-Disposition. - FM */
     newAnchor->content_location = NULL; /* Content-Location. - FM */
diff --git a/WWW/Library/Implementation/HTAssoc.c b/WWW/Library/Implementation/HTAssoc.c
index dff739be..f5dcbf11 100644
--- a/WWW/Library/Implementation/HTAssoc.c
+++ b/WWW/Library/Implementation/HTAssoc.c
@@ -16,11 +16,8 @@
 **
 */
 
-
 #include <HTUtils.h>
 
-#include <string.h>
-
 #include <HTAAUtil.h>
 #include <HTAssoc.h>
 #include <HTString.h>
diff --git a/WWW/Library/Implementation/HTAssoc.h b/WWW/Library/Implementation/HTAssoc.h
index 79cbe557..93183302 100644
--- a/WWW/Library/Implementation/HTAssoc.h
+++ b/WWW/Library/Implementation/HTAssoc.h
@@ -7,12 +7,8 @@
 #ifndef HTASSOC_H
 #define HTASSOC_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTList.h>
 
-
 #ifdef SHORT_NAMES
 #define HTAL_new        HTAssocList_new
 #define HTAL_del        HTAssocList_delete
diff --git a/WWW/Library/Implementation/HTAtom.c b/WWW/Library/Implementation/HTAtom.c
index 48823651..e4af2962 100644
--- a/WWW/Library/Implementation/HTAtom.c
+++ b/WWW/Library/Implementation/HTAtom.c
@@ -12,20 +12,17 @@
 **	(c) Copyright CERN 1991 - See Copyright.html
 **
 */
+
 #include <HTUtils.h>
 
 #define HASH_SIZE	101		/* Tunable */
 #include <HTAtom.h>
 
-#include <string.h>
-
 #include <HTList.h>
 
 #include <LYexit.h>
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 PRIVATE HTAtom * hash_table[HASH_SIZE];
 PRIVATE BOOL initialised = NO;
 
@@ -43,7 +40,7 @@ PUBLIC HTAtom * HTAtom_for ARGS1(CONST char *, string)
 {
     int hash;
     HTAtom * a;
-    
+
     /*		First time around, clear hash table
     */
     /*
@@ -57,11 +54,11 @@ PUBLIC HTAtom * HTAtom_for ARGS1(CONST char *, string)
 	initialised = YES;
 	atexit(free_atoms);
     }
-    
+
     /*		Generate hash function
     */
     hash = HASH_FUNCTION(string);
-    
+
     /*		Search for the string in the list
     */
     for (a = hash_table[hash]; a; a = a->next) {
@@ -70,7 +67,7 @@ PUBLIC HTAtom * HTAtom_for ARGS1(CONST char *, string)
 	    return a;				/* Found: return it */
 	}
     }
-    
+
     /*		Generate a new entry
     */
     a = (HTAtom *)malloc(sizeof(*a));
@@ -144,7 +141,7 @@ PRIVATE BOOL mime_match ARGS2(CONST char *, name,
     }
     return NO;
 }
-	
+
 
 PUBLIC HTList *HTAtom_templateMatches ARGS1(CONST char *, templ)
 {
diff --git a/WWW/Library/Implementation/HTAtom.h b/WWW/Library/Implementation/HTAtom.h
index c3319a3d..fda46b86 100644
--- a/WWW/Library/Implementation/HTAtom.h
+++ b/WWW/Library/Implementation/HTAtom.h
@@ -21,9 +21,6 @@
 #ifndef HTATOM_H
 #define HTATOM_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTList.h>
 
 #ifdef SHORT_NAMES
diff --git a/WWW/Library/Implementation/HTAuth.c b/WWW/Library/Implementation/HTAuth.c
index 9f2185c7..f1e7efd5 100644
--- a/WWW/Library/Implementation/HTAuth.c
+++ b/WWW/Library/Implementation/HTAuth.c
@@ -14,7 +14,6 @@
 */
 
 #include <HTUtils.h>
-#include <string.h>
 #include <HTPasswd.h>	/* Password file routines	*/
 #include <HTAssoc.h>
 #include <HTAuth.h>	/* Implemented here		*/
diff --git a/WWW/Library/Implementation/HTAuth.h b/WWW/Library/Implementation/HTAuth.h
index f81eb1eb..0e88131c 100644
--- a/WWW/Library/Implementation/HTAuth.h
+++ b/WWW/Library/Implementation/HTAuth.h
@@ -8,9 +8,6 @@
 #ifndef HTAUTH_H
 #define HTAUTH_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTAAUtil.h>
 #include <HTAAProt.h>
 
diff --git a/WWW/Library/Implementation/HTBTree.c b/WWW/Library/Implementation/HTBTree.c
index 986dfc8b..c545eb0e 100644
--- a/WWW/Library/Implementation/HTBTree.c
+++ b/WWW/Library/Implementation/HTBTree.c
@@ -12,18 +12,14 @@
 #ifndef __STRICT_BSD__
 #include <stdlib.h>
 #endif
-#include <string.h>
 
 #define MAXIMUM(a,b) ((a)>(b)?(a):(b))
 
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
-
 PUBLIC HTBTree * HTBTree_new ARGS1(HTComparer, comp)
     /*********************************************************
-    ** This function returns an HTBTree with memory allocated 
+    ** This function returns an HTBTree with memory allocated
     ** for it when given a mean to compare things
     */
 {
@@ -73,7 +69,7 @@ PRIVATE void HTBTElementAndObject_free ARGS1(HTBTElement*, element)
     if (element) {     /* Just in case nothing was in the tree anyway */
         if (element->left != NULL)
 	    HTBTElementAndObject_free(element->left);
-	if (element->right != NULL)    
+	if (element->right != NULL)
 	    HTBTElementAndObject_free(element->right);
 	FREE(element->object);
 	FREE(element);
@@ -110,12 +106,12 @@ PUBLIC void HTBTree_add ARGS2(
     int depth,depth2,corrections;
         /* father_of_element is a pointer to the structure that is the father of the
         ** new object "object".
-        ** added_element is a pointer to the structure that contains or will contain 
+        ** added_element is a pointer to the structure that contains or will contain
         ** the new object "object".
         ** father_of_forefather and forefather_of_element are pointers that are used
         ** to modify the depths of upper elements, when needed.
         **
-        ** father_found indicates by a value NO when the future father of "object" 
+        ** father_found indicates by a value NO when the future father of "object"
         ** is found.
         ** top_found indicates by a value NO when, in case of a difference of depths
         **  < 2, the top of the tree is encountered and forbids any further try to
@@ -146,24 +142,24 @@ PUBLIC void HTBTree_add ARGS2(
         tree->top->right_depth = 0;
     }
     else
-    {   
+    {
         father_found = YES;
         father_of_element = tree->top;
         added_element = NULL;
         father_of_forefather = NULL;
-        forefather_of_element = NULL;      
+        forefather_of_element = NULL;
         while (father_found)
         {
             if (tree->compare(object,father_of_element->object)<0)
 	    {
                 if (father_of_element->left != NULL)
                     father_of_element = father_of_element->left;
-                else 
+                else
 	        {
                     father_found = NO;
-                    father_of_element->left = 
+                    father_of_element->left =
                         (HTBTElement *)malloc(sizeof(HTBTElement));
-                    if (father_of_element->left==NULL) 
+                    if (father_of_element->left==NULL)
                         outofmem(__FILE__, "HTBTree_add");
                     added_element = father_of_element->left;
                     added_element->up = father_of_element;
@@ -176,14 +172,14 @@ PUBLIC void HTBTree_add ARGS2(
    	    }
             if (tree->compare(object,father_of_element->object)>=0)
             {
-                if (father_of_element->right != NULL) 
+                if (father_of_element->right != NULL)
                     father_of_element = father_of_element->right;
-                else 
-                {  
+                else
+                {
                     father_found = NO;
-                    father_of_element->right = 
+                    father_of_element->right =
                         (HTBTElement *)malloc(sizeof(HTBTElement));
-                    if (father_of_element->right==NULL) 
+                    if (father_of_element->right==NULL)
                         outofmem(__FILE__, "HTBTree_add");
                     added_element = father_of_element->right;
                     added_element->up = father_of_element;
@@ -191,7 +187,7 @@ PUBLIC void HTBTree_add ARGS2(
                     added_element->left = NULL;
                     added_element->left_depth = 0;
                     added_element->right = NULL;
-                    added_element->right_depth = 0;       
+                    added_element->right_depth = 0;
     	        }
             }
 	}
@@ -205,7 +201,7 @@ PUBLIC void HTBTree_add ARGS2(
             if (father_of_forefather->left == forefather_of_element)
             {
                 depth = father_of_forefather->left_depth;
-                father_of_forefather->left_depth = 1 
+                father_of_forefather->left_depth = 1
                             + MAXIMUM(forefather_of_element->right_depth,
                                   forefather_of_element->left_depth);
                 depth2 = father_of_forefather->left_depth;
@@ -221,7 +217,7 @@ PUBLIC void HTBTree_add ARGS2(
             forefather_of_element = father_of_forefather;
             father_of_forefather = father_of_forefather->up;
         } while ((depth != depth2) && (father_of_forefather != NULL));
-        
+
 
 
             /*
@@ -234,7 +230,7 @@ PUBLIC void HTBTree_add ARGS2(
             if ((abs(father_of_element->left_depth
                       - father_of_element->right_depth)) < 2)
 	    {
-                if (father_of_element->up != NULL) 
+                if (father_of_element->up != NULL)
                     father_of_element = father_of_element->up;
                 else top_found = NO;
 	    }
@@ -242,8 +238,8 @@ PUBLIC void HTBTree_add ARGS2(
  	    {                /* We start the process of balancing */
 
                 corrections = corrections + 1;
-                    /* 
-                    ** corrections is an integer used to avoid infinite 
+                    /*
+                    ** corrections is an integer used to avoid infinite
                     ** loops in cases such as:
                     **
                     **             3                        3
@@ -251,22 +247,22 @@ PUBLIC void HTBTree_add ARGS2(
                     **           5                            5
                     **
                     ** 3 is used to show that it need not be the top of the tree
-		    ** But let's avoid these two exceptions anyhow 
+		    ** But let's avoid these two exceptions anyhow
 		    ** with the two following conditions (4 March 94 - AS)
                     */
 
-		if ((father_of_element->left == NULL) 
-		    && (father_of_element->right->right == NULL) 
-		    && (father_of_element->right->left->left == NULL) 
-		    && (father_of_element->right->left->right == NULL)) 
+		if ((father_of_element->left == NULL)
+		    && (father_of_element->right->right == NULL)
+		    && (father_of_element->right->left->left == NULL)
+		    && (father_of_element->right->left->right == NULL))
 		    corrections = 7;
 
-		if ((father_of_element->right == NULL) 
-		    && (father_of_element->left->left == NULL) 
-		    && (father_of_element->left->right->right == NULL) 
+		if ((father_of_element->right == NULL)
+		    && (father_of_element->left->left == NULL)
+		    && (father_of_element->left->right->right == NULL)
 		    && (father_of_element->left->right->left == NULL))
 		    corrections = 7;
- 
+
 
                 if (father_of_element->left_depth > father_of_element->right_depth)
 	        {
@@ -283,7 +279,7 @@ PUBLIC void HTBTree_add ARGS2(
                         father_of_forefather = father_of_element->up;
                         forefather_of_element = added_element;
 			first_time = YES;
-                        do 
+                        do
                         {
                             if (father_of_forefather->left
                                  == forefather_of_element->up)
@@ -312,7 +308,7 @@ PUBLIC void HTBTree_add ARGS2(
 				      + MAXIMUM(forefather_of_element->left_depth,
 					       forefather_of_element->right_depth);
 				    first_time = NO;
-				}				
+				}
 				else
 				    father_of_forefather->right_depth = 1
 				      + MAXIMUM(forefather_of_element->up->left_depth,
@@ -321,7 +317,7 @@ PUBLIC void HTBTree_add ARGS2(
 			    }
                             forefather_of_element = forefather_of_element->up;
                             father_of_forefather = father_of_forefather->up;
-			} while ((depth != depth2) && 
+			} while ((depth != depth2) &&
 				 (father_of_forefather != NULL));
                         father_of_forefather = father_of_element->up;
                         if (father_of_forefather->left == father_of_element)
@@ -334,7 +330,7 @@ PUBLIC void HTBTree_add ARGS2(
                             **
                             ** 3 is used to show that it may not be the top of the
                             ** tree.
-                            */ 
+                            */
                             father_of_forefather->left = added_element;
                             father_of_element->left = added_element->right;
                             added_element->right = father_of_element;
@@ -364,7 +360,7 @@ PUBLIC void HTBTree_add ARGS2(
                         ** When tree   2   3        becomes    4    1
                         **            4 5                          5 3
                         **
-                        ** 1 is used to show that it is the top of the tree    
+                        ** 1 is used to show that it is the top of the tree
                         */
                         added_element->up = NULL;
                         father_of_element->left = added_element->right;
@@ -378,7 +374,7 @@ PUBLIC void HTBTree_add ARGS2(
 	        {
                     added_element = father_of_element->right;
                     father_of_element->right_depth = added_element->left_depth;
-                    added_element->left_depth = 1 + 
+                    added_element->left_depth = 1 +
                             MAXIMUM(father_of_element->right_depth,
                                 father_of_element->left_depth);
                     if (father_of_element->up != NULL)
@@ -389,9 +385,9 @@ PUBLIC void HTBTree_add ARGS2(
                         father_of_forefather = father_of_element->up;
                         forefather_of_element = added_element;
 			first_time = YES;
-                        do 
+                        do
                         {
-                            if (father_of_forefather->left 
+                            if (father_of_forefather->left
 				== forefather_of_element->up)
                             {
                                 depth = father_of_forefather->left_depth;
@@ -426,7 +422,7 @@ PUBLIC void HTBTree_add ARGS2(
 			    }
                             father_of_forefather = father_of_forefather->up;
                             forefather_of_element = forefather_of_element->up;
-			} while ((depth != depth2) && 
+			} while ((depth != depth2) &&
 				 (father_of_forefather != NULL));
                         father_of_forefather = father_of_element->up;
                         if (father_of_forefather->left == father_of_element)
@@ -496,7 +492,7 @@ PUBLIC HTBTElement * HTBTree_next ARGS2(
                                HTBTElement*,   ele)
     /**************************************************************************
     ** this function returns a pointer to the leftmost element if ele is NULL,
-    ** and to the next object to the right otherways.
+    ** and to the next object to the right otherwise.
     ** If no elements left, returns a pointer to NULL.
     */
 {
@@ -522,7 +518,7 @@ PUBLIC HTBTElement * HTBTree_next ARGS2(
         else
 	{
             father_of_forefather = father_of_element->up;
-	        while (father_of_forefather && 
+	        while (father_of_forefather &&
 		       (father_of_forefather->right == father_of_element))
       	        {
                     father_of_element = father_of_forefather;
@@ -544,7 +540,7 @@ PUBLIC HTBTElement * HTBTree_next ARGS2(
         else printf("Pas de Pere\n");
         if (father_of_element->left != NULL)
             printf("Objet du fils gauche = %s\t",
-		   (char *)father_of_element->left->object); 
+		   (char *)father_of_element->left->object);
         else printf("Pas de fils gauche\t");
         if (father_of_element->right != NULL)
             printf("Objet du fils droit = %s\n",
@@ -567,7 +563,7 @@ main ()
 {
     HTBTree * tree;
     HTBTElement * next_element;
-    
+
     tree = HTBTree_new((HTComparer)strcasecomp);
     HTBTree_add(tree,"hypertext");
     HTBTree_add(tree,"Addressing");
diff --git a/WWW/Library/Implementation/HTBTree.h b/WWW/Library/Implementation/HTBTree.h
index 55bfe6ab..6facd048 100644
--- a/WWW/Library/Implementation/HTBTree.h
+++ b/WWW/Library/Implementation/HTBTree.h
@@ -9,6 +9,11 @@
    part of libWWW
    
  */
+#ifndef HTBTREE_H
+#define HTBTREE_H 1
+
+#include <HTUtils.h>
+
 #ifdef SHORT_NAMES
 #define HTBTree_new             HTBTNew
 #define HTBTree_free            HTBTFree
@@ -99,6 +104,4 @@ Find next element in depth-first order
  */
 extern HTBTElement * HTBTree_next PARAMS((HTBTree* tree, HTBTElement * ele));
 
-/*
-
-   end  */
+#endif /* HTBTREE_H */
diff --git a/WWW/Library/Implementation/HTCJK.h b/WWW/Library/Implementation/HTCJK.h
index 19c8fa66..bc2c3aac 100644
--- a/WWW/Library/Implementation/HTCJK.h
+++ b/WWW/Library/Implementation/HTCJK.h
@@ -11,6 +11,8 @@
 #ifndef HTCJK_H
 #define HTCJK_H
 
+#include <HTUtils.h>
+
 /*
 **	STATUS CHANGE CODES
 */
diff --git a/WWW/Library/Implementation/HTChunk.c b/WWW/Library/Implementation/HTChunk.c
index 5a741a54..7cab693c 100644
--- a/WWW/Library/Implementation/HTChunk.c
+++ b/WWW/Library/Implementation/HTChunk.c
@@ -8,8 +8,6 @@
 
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 /*	Create a chunk with a certain allocation unit
 **	--------------
 */
diff --git a/WWW/Library/Implementation/HTChunk.h b/WWW/Library/Implementation/HTChunk.h
index 84c12de7..2afcdd9d 100644
--- a/WWW/Library/Implementation/HTChunk.h
+++ b/WWW/Library/Implementation/HTChunk.h
@@ -7,6 +7,10 @@
    automatically reallocating them as necessary.
    
  */
+#ifndef HTCHUNK_H
+#define HTCHUNK_H 1
+
+#include <HTUtils.h>
 #include <UCMap.h>
 
 typedef struct {
@@ -166,6 +170,4 @@ Append a zero character to a  chunk
 
 extern void HTChunkTerminate PARAMS((HTChunk * ch));
 
-/*
-
-   end */
+#endif /* HTCHUNK_H */
diff --git a/WWW/Library/Implementation/HTDOS.c b/WWW/Library/Implementation/HTDOS.c
index 37e15962..c946d0c4 100644
--- a/WWW/Library/Implementation/HTDOS.c
+++ b/WWW/Library/Implementation/HTDOS.c
@@ -2,9 +2,7 @@
 
  */
 
-#include <mem.h>
-#include <dos.h>
-
+#include <HTUtils.h>
 
 /* PUBLIC							HTDOS_wwwName()
 **		CONVERTS DOS Name into WWW Name
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index 8e581838..bd5a2ce7 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -76,7 +76,6 @@ BUGS:	@@@	Limit connection cache size!
 #endif
 
 #include <HTUtils.h>
-#include <tcp.h>
 
 #include <HTAlert.h>
 
@@ -140,8 +139,6 @@ struct _HTStructured {
 	/* ... */
 };
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 /*	Global Variables
 **	---------------------
 */
diff --git a/WWW/Library/Implementation/HTFTP.h b/WWW/Library/Implementation/HTFTP.h
index db26104a..7b857076 100644
--- a/WWW/Library/Implementation/HTFTP.h
+++ b/WWW/Library/Implementation/HTFTP.h
@@ -10,9 +10,6 @@
 #ifndef HTFTP_H
 #define HTFTP_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTAnchor.h>
 #include <HTStream.h>
 #include <HTParse.h>
diff --git a/WWW/Library/Implementation/HTFWriter.c b/WWW/Library/Implementation/HTFWriter.c
index 74d09866..f30461c9 100644
--- a/WWW/Library/Implementation/HTFWriter.c
+++ b/WWW/Library/Implementation/HTFWriter.c
@@ -18,8 +18,6 @@
 
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 /*		Stream Object
 **		------------
 */
diff --git a/WWW/Library/Implementation/HTFWriter.h b/WWW/Library/Implementation/HTFWriter.h
index 4dd9bb0a..089ad0fb 100644
--- a/WWW/Library/Implementation/HTFWriter.h
+++ b/WWW/Library/Implementation/HTFWriter.h
@@ -8,9 +8,6 @@
 #ifndef HTFWRITE_H
 #define HTFWRITE_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTStream.h>
 #include <HTFormat.h>
 
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index a703fd45..c530db85 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -20,6 +20,8 @@
 **			 the device or top directory.
 */
 
+#include <HTUtils.h>
+
 #ifndef VMS
 /* #define LONG_LIST */ /* Define this for long style unix listings (ls -l) */
 /* #define NO_PARENT_DIR_REFERENCE */ /* Define this for no parent links */
@@ -31,8 +33,6 @@
 #include <HTDOS.h>
 #endif /* DOSPATH */
 
-#include <HTUtils.h>
-#include <tcp.h>
 #include <HTFile.h>		/* Implemented here */
 #ifdef VMS
 #include <stat.h>
@@ -54,8 +54,6 @@
 
 #define HT_EM_SPACE ((char)2)
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 #ifdef VMS
 #include <HTVMSUtils.h>
 #endif /* VMS */
@@ -237,7 +235,7 @@ PRIVATE void LYListFmtParse ARGS5(
 			PUTS(buf);
 			END(HTML_A);
 #ifdef S_IFLNK
-			if (c != 'A' && (st.st_mode & S_IFMT) == S_IFLNK &&
+			if (c != 'A' && S_ISLNK(st.st_mode) &&
 			    (len = readlink(file, buf, sizeof(buf))) >= 0) {
 				PUTS(" -> ");
 				buf[len] = '\0';
@@ -271,7 +269,7 @@ PRIVATE void LYListFmtParse ARGS5(
 			break;
 
 		case 'K':	/* size in Kilobytes but not for directories */
-			if ((st.st_mode & S_IFMT) == S_IFDIR) {
+			if (S_ISDIR(st.st_mode)) {
 				sprintf(fmt, "%%%ss ", start);
 				sprintf(buf, fmt, "");
 				break;
@@ -1532,7 +1530,7 @@ PUBLIC int HTLoadFile ARGS4(
     if (HTStat(filename, &stat_info) == -1) {
 	CTRACE(tfp, "HTLoadFile: Can't stat %s\n", filename);
     } else {
-	if (((stat_info.st_mode) & S_IFMT) == S_IFDIR) {
+	if (S_ISDIR(stat_info.st_mode)) {
 	    if (HTDirAccess == HT_DIR_FORBID) {
 		FREE(filename);
 		FREE(nodename);
@@ -1896,7 +1894,7 @@ PUBLIC int HTLoadFile ARGS4(
 	    if (stat(localname,&dir_info) == -1) dir_info.st_mode = S_IFDIR;
 #endif
 
-	    if (((dir_info.st_mode) & S_IFMT) == S_IFDIR) {
+	    if (S_ISDIR(dir_info.st_mode)) {
 		/*
 		**  If localname is a directory.
 		*/
@@ -2058,7 +2056,7 @@ PUBLIC int HTLoadFile ARGS4(
 
 			StrAllocCat(tmpfilename, dirbuf->d_name);
 			stat(tmpfilename, &file_info);
-			if (((file_info.st_mode) & S_IFMT) == S_IFDIR)
+			if (S_ISDIR(file_info.st_mode))
 #ifndef DIRED_SUPPORT
 			    sprintf((char *)dirname, "D%s",dirbuf->d_name);
 			else
diff --git a/WWW/Library/Implementation/HTFinger.c b/WWW/Library/Implementation/HTFinger.c
index 89c5540c..0932b4d2 100644
--- a/WWW/Library/Implementation/HTFinger.c
+++ b/WWW/Library/Implementation/HTFinger.c
@@ -26,7 +26,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>
 #include <HTAlert.h>
 #include <HTML.h>
 #include <HTParse.h>
@@ -40,8 +39,6 @@
 #define FINGER_PORT 79		/* See rfc742 */
 #define BIG 1024		/* Bug */
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 #define PUTC(c) (*targetClass.put_character)(target, c)
 #define PUTS(s) (*targetClass.put_string)(target, s)
 #define START(e) (*targetClass.start_element)(target, e, 0, 0, -1, 0)
diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c
index 4b69e1d4..3c20fc0a 100644
--- a/WWW/Library/Implementation/HTFormat.c
+++ b/WWW/Library/Implementation/HTFormat.c
@@ -11,7 +11,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>
 #include <HTAccess.h>
 
 /* Implements:
@@ -52,8 +51,6 @@ PUBLIC long int HTMaxBytes  = 0;	/* No effective limit */
 #include <LYGlobalDefs.h>
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 PUBLIC	BOOL HTOutputSource = NO;	/* Flag: shortcut parser to stdout */
 /* extern  BOOL interactive; LJM */
 
diff --git a/WWW/Library/Implementation/HTFormat.h b/WWW/Library/Implementation/HTFormat.h
index 866174a9..0e5c4634 100644
--- a/WWW/Library/Implementation/HTFormat.h
+++ b/WWW/Library/Implementation/HTFormat.h
@@ -14,9 +14,6 @@ Preamble
 #ifndef HTFORMAT_H
 #define HTFORMAT_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTStream.h>
 #include <HTAtom.h>
 #include <HTList.h>
diff --git a/WWW/Library/Implementation/HTGopher.c b/WWW/Library/Implementation/HTGopher.c
index 734b6f2f..9bfac99c 100644
--- a/WWW/Library/Implementation/HTGopher.c
+++ b/WWW/Library/Implementation/HTGopher.c
@@ -16,7 +16,6 @@
 */
 
 #include <HTUtils.h>		/* Coding convention macros */
-#include <tcp.h>
 #include <HTAlert.h>
 #include <HTParse.h>
 #include <HTTCP.h>
@@ -61,14 +60,10 @@
 #define GOPHER_PLUS_SOUND	'<'
 #define GOPHER_PLUS_PDF 	'P'
 
-#include <ctype.h>
-
 #include <HTParse.h>
 #include <HTFormat.h>
 #include <HTTCP.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 /*
 **  Hypertext object building machinery.
 */
diff --git a/WWW/Library/Implementation/HTGroup.c b/WWW/Library/Implementation/HTGroup.c
index 71fd1445..a1b6fa4a 100644
--- a/WWW/Library/Implementation/HTGroup.c
+++ b/WWW/Library/Implementation/HTGroup.c
@@ -42,9 +42,8 @@
 */
 
 
-
 #include <HTUtils.h>
-#include <string.h>
+
 #include <HTAAUtil.h>
 #include <HTLex.h>	/* Lexical analysor	*/
 #include <HTGroup.h>	/* Implemented here	*/
diff --git a/WWW/Library/Implementation/HTGroup.h b/WWW/Library/Implementation/HTGroup.h
index 398aa0bf..c578d3c3 100644
--- a/WWW/Library/Implementation/HTGroup.h
+++ b/WWW/Library/Implementation/HTGroup.h
@@ -5,9 +5,6 @@
 #ifndef HTGROUP_H
 #define HTGROUP_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTList.h>
 
 #ifdef SHORT_NAMES
diff --git a/WWW/Library/Implementation/HTHistory.c b/WWW/Library/Implementation/HTHistory.c
index bbb87d0a..fab1edc5 100644
--- a/WWW/Library/Implementation/HTHistory.c
+++ b/WWW/Library/Implementation/HTHistory.c
@@ -1,5 +1,4 @@
 #include <HTUtils.h>
-#include <tcp.h>		/* for standard io */
 
 #include <HTHistory.h>
 
diff --git a/WWW/Library/Implementation/HTInit.h b/WWW/Library/Implementation/HTInit.h
index a003a6b5..4785f3e8 100644
--- a/WWW/Library/Implementation/HTInit.h
+++ b/WWW/Library/Implementation/HTInit.h
@@ -10,14 +10,14 @@
    Implemented by HTInit.c by default.
    
  */
-#ifndef HTUTILS_H
+
+#ifndef HTINIT_H
+#define HTINIT_H 1
+
 #include <HTUtils.h>
-#endif /* HTUTILS_H */
 
 extern void HTFormatInit NOPARAMS;
 extern void HTPreparsedFormatInit NOPARAMS;
 extern void HTFileInit NOPARAMS;
 
-/*
-
-    */
+#endif /* HTINIT_H */
diff --git a/WWW/Library/Implementation/HTLex.c b/WWW/Library/Implementation/HTLex.c
index 56b1fdae..e7568ea6 100644
--- a/WWW/Library/Implementation/HTLex.c
+++ b/WWW/Library/Implementation/HTLex.c
@@ -14,6 +14,7 @@
 */
 
 #include <HTUtils.h>
+
 #include <HTAAUtil.h>
 #include <HTLex.h>	/* Implemented here */
 
diff --git a/WWW/Library/Implementation/HTLex.h b/WWW/Library/Implementation/HTLex.h
index dd02c3ae..205d6b19 100644
--- a/WWW/Library/Implementation/HTLex.h
+++ b/WWW/Library/Implementation/HTLex.h
@@ -5,16 +5,12 @@
 #ifndef HTLEX_H
 #define HTLEX_H
 
-#ifndef HTUTILS_H
 #include <HTUtils.h>
-#endif /* HTUTILS_H */
-
 
 #ifdef SHORT_NAMES
 #define lex_verb        lex_verbose
 #endif /*SHORT_NAMES*/
 
-
 typedef enum {
     LEX_NONE,		/* Internally used      */
     LEX_EOF,		/* End of file          */
@@ -59,6 +55,3 @@ PUBLIC char *lex_verbose PARAMS((LexItem lex_item));
  */
 
 #endif /* not HTLEX_H */
-/*
-
-   End of file HTLex.h.  */
diff --git a/WWW/Library/Implementation/HTList.c b/WWW/Library/Implementation/HTList.c
index 2cb89389..939af95b 100644
--- a/WWW/Library/Implementation/HTList.c
+++ b/WWW/Library/Implementation/HTList.c
@@ -11,9 +11,6 @@
 
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
-
 /*	Create list.
 */
 PUBLIC HTList * HTList_new NOARGS
diff --git a/WWW/Library/Implementation/HTList.h b/WWW/Library/Implementation/HTList.h
index 095308c1..c02c58af 100644
--- a/WWW/Library/Implementation/HTList.h
+++ b/WWW/Library/Implementation/HTList.h
@@ -7,9 +7,7 @@
 #ifndef HTLIST_H
 #define HTLIST_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>  /* for BOOL type and PARAMS and ARGS*/
-#endif /* HTUTILS_H */
+#include <HTUtils.h>
 
 typedef struct _HTList HTList;
 
diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c
index 21b865ec..82c0c8f1 100644
--- a/WWW/Library/Implementation/HTMIME.c
+++ b/WWW/Library/Implementation/HTMIME.c
@@ -23,8 +23,6 @@
 #include <LYStrings.h>
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 extern CONST char *LYchar_set_names[];
 extern BOOLEAN LYRawMode;
 extern BOOL HTPassEightBitRaw;
diff --git a/WWW/Library/Implementation/HTMLDTD.h b/WWW/Library/Implementation/HTMLDTD.h
index 87c2bb76..a112b7e5 100644
--- a/WWW/Library/Implementation/HTMLDTD.h
+++ b/WWW/Library/Implementation/HTMLDTD.h
@@ -12,9 +12,6 @@
 #ifndef HTMLDTD_H
 #define HTMLDTD_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <SGML.h>
 
 /*
diff --git a/WWW/Library/Implementation/HTMLGen.c b/WWW/Library/Implementation/HTMLGen.c
index f1f89173..9581081f 100644
--- a/WWW/Library/Implementation/HTMLGen.c
+++ b/WWW/Library/Implementation/HTMLGen.c
@@ -13,7 +13,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>
 
 #define BUFFER_SIZE    200	/* Line buffer attempts to make neat breaks */
 #define MAX_CLEANNESS	20
@@ -29,8 +28,6 @@
 
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 #define PUTC(c) (*me->targetClass.put_character)(me->target, c)
 /* #define PUTS(s) (*me->targetClass.put_string)(me->target, s) */
 #define PUTB(s,l) (*me->targetClass.put_block)(me->target, s, l)
diff --git a/WWW/Library/Implementation/HTNews.c b/WWW/Library/Implementation/HTNews.c
index d450d901..2b547783 100644
--- a/WWW/Library/Implementation/HTNews.c
+++ b/WWW/Library/Implementation/HTNews.c
@@ -7,7 +7,6 @@
 */
 
 #include <HTUtils.h>		/* Coding convention macros */
-#include <tcp.h>
 
 /* Implements:
 */
@@ -17,8 +16,6 @@
 #include <HTMIME.h>
 #include <HTTCP.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 /* this define should be in HTFont.h :( */
 #define HT_NON_BREAK_SPACE ((char)1)   /* For now */
 
@@ -39,8 +36,6 @@ PUBLIC int HTNewsMaxChunk = 40; /* Largest number of articles in one window */
 #define NEWS_NETCLOSE  NETCLOSE
 #define NEXT_CHAR HTGetCharacter()
 
-#include <ctype.h>
-
 #include <HTML.h>
 #include <HTParse.h>
 #include <HTFormat.h>
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c
index d75b1fde..d25157b3 100644
--- a/WWW/Library/Implementation/HTParse.c
+++ b/WWW/Library/Implementation/HTParse.c
@@ -3,13 +3,10 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>
 #include <HTParse.h>
 
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 #define HEX_ESCAPE '%'
 
 struct struct_parts {
diff --git a/WWW/Library/Implementation/HTParse.h b/WWW/Library/Implementation/HTParse.h
index cf42d97b..bea789d0 100644
--- a/WWW/Library/Implementation/HTParse.h
+++ b/WWW/Library/Implementation/HTParse.h
@@ -8,9 +8,7 @@
 #ifndef HTPARSE_H
 #define HTPARSE_H
 
-#ifndef HTUTILS_H
 #include <HTUtils.h>
-#endif /* HTUTILS_H */
 
 /*
 **  The following are flag bits which may be ORed together to form
diff --git a/WWW/Library/Implementation/HTPasswd.c b/WWW/Library/Implementation/HTPasswd.c
index 27efb02f..764882d4 100644
--- a/WWW/Library/Implementation/HTPasswd.c
+++ b/WWW/Library/Implementation/HTPasswd.c
@@ -15,10 +15,8 @@
 **
 */
 
-
 #include <HTUtils.h>
-#include <tcp.h>	/* FROMASCII()		*/
-#include <string.h>
+
 #include <HTAAUtil.h>	/* Common parts of AA	*/
 #include <HTAAFile.h>	/* File routines	*/
 #include <HTAAServ.h>	/* Server routines	*/
diff --git a/WWW/Library/Implementation/HTPasswd.h b/WWW/Library/Implementation/HTPasswd.h
index b82d1d4e..09007192 100644
--- a/WWW/Library/Implementation/HTPasswd.h
+++ b/WWW/Library/Implementation/HTPasswd.h
@@ -5,9 +5,6 @@
 #ifndef HTPASSWD_H
 #define HTPASSWD_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTList.h>
 
 #ifdef SHORT_NAMES
diff --git a/WWW/Library/Implementation/HTPlain.c b/WWW/Library/Implementation/HTPlain.c
index b7b457d7..2744b7df 100644
--- a/WWW/Library/Implementation/HTPlain.c
+++ b/WWW/Library/Implementation/HTPlain.c
@@ -7,8 +7,8 @@
 **	Bugs:
 **		strings written must be less than buffer size.
 */
+
 #include <HTUtils.h>
-#include <tcp.h>
 
 #include <HTPlain.h>
 
@@ -31,8 +31,6 @@
 #include <LYCharSets.h>
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 extern BOOL HTPassEightBitRaw;
 extern BOOL HTPassHighCtrlRaw;
 extern HTCJKlang HTCJK;
diff --git a/WWW/Library/Implementation/HTRules.c b/WWW/Library/Implementation/HTRules.c
index 91596190..e666618f 100644
--- a/WWW/Library/Implementation/HTRules.c
+++ b/WWW/Library/Implementation/HTRules.c
@@ -18,11 +18,11 @@
 **
 */
 
+#include <HTUtils.h>
+
 /* (c) CERN WorldWideWeb project 1990,91. See Copyright.html for details */
 #include <HTRules.h>
 
-#include <HTUtils.h>
-#include <tcp.h>
 #include <HTFile.h>
 #include <HTAAServ.h>	/* Access Authorization */
 
@@ -284,7 +284,6 @@ char * HTTranslate(required)
 		CTRACE(tfp, "HTRule: *** FAIL `%s'\n",
 			    current);
 		return (char *)0;
-
 	} /* if tail matches ... switch operation */
 
     } /* loop over rules */
diff --git a/WWW/Library/Implementation/HTRules.h b/WWW/Library/Implementation/HTRules.h
index d19b8a4b..3eb37169 100644
--- a/WWW/Library/Implementation/HTRules.h
+++ b/WWW/Library/Implementation/HTRules.h
@@ -16,9 +16,7 @@
 #ifndef HTRULE_H
 #define HTRULE_H
 
-#ifndef HTUTILS_H
 #include <HTUtils.h>
-#endif /* HTUTILS_H */
 
 typedef enum _HTRuleOp {
         HT_Invalid,
diff --git a/WWW/Library/Implementation/HTStream.h b/WWW/Library/Implementation/HTStream.h
index 5892a1a1..4588568e 100644
--- a/WWW/Library/Implementation/HTStream.h
+++ b/WWW/Library/Implementation/HTStream.h
@@ -13,9 +13,7 @@
 #ifndef HTSTREAM_H
 #define HTSTREAM_H
 
-#ifndef HTUTILS_H
 #include <HTUtils.h>
-#endif /* HTUTILS_H */
 
 typedef struct _HTStream HTStream;
 
diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c
index b669c379..00f70a6c 100644
--- a/WWW/Library/Implementation/HTString.c
+++ b/WWW/Library/Implementation/HTString.c
@@ -6,15 +6,12 @@
 **	23 Jan 92 (TBL) Changed strallocc* to 8 char HTSAC* for VM and suchlike
 **	 6 Oct 92 (TBL) Moved WWW_TraceFlag in here to be in library
 */
-#include <ctype.h>
+
 #include <HTUtils.h>
-#include <tcp.h>
 
 #include <LYLeaks.h>
 #include <LYStrings.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 PUBLIC int WWW_TraceFlag = 0;	/* Global trace flag for ALL W3 code */
 
 #ifndef VC
diff --git a/WWW/Library/Implementation/HTString.h b/WWW/Library/Implementation/HTString.h
index 25c57002..0609cb00 100644
--- a/WWW/Library/Implementation/HTString.h
+++ b/WWW/Library/Implementation/HTString.h
@@ -7,9 +7,7 @@
 #ifndef HTSTRING_H
 #define HTSTRING_H
 
-#ifndef HTUTILS_H
 #include <HTUtils.h>
-#endif /* HTUTILS_H */
 
 extern int WWW_TraceFlag;       /* Global flag for all W3 trace */
 
diff --git a/WWW/Library/Implementation/HTStyle.c b/WWW/Library/Implementation/HTStyle.c
index 963303d9..3469e44a 100644
--- a/WWW/Library/Implementation/HTStyle.c
+++ b/WWW/Library/Implementation/HTStyle.c
@@ -8,13 +8,12 @@
 **	translation necessary to
 **	represent a document. It is a linked list of styles.
 */
+
 #include <HTUtils.h>
 #include <HTStyle.h>
 
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 /*	Create a new style
 */
 PUBLIC HTStyle* HTStyleNew NOARGS
diff --git a/WWW/Library/Implementation/HTStyle.h b/WWW/Library/Implementation/HTStyle.h
index ae3e5d54..b4fcedaa 100644
--- a/WWW/Library/Implementation/HTStyle.h
+++ b/WWW/Library/Implementation/HTStyle.h
@@ -32,9 +32,6 @@ Overriding this module
 #ifndef HTStyle_H
 #define HTStyle_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTAnchor.h>
 
 typedef long int HTFont;        /* Dummy definition instead */
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index 0cd62330..2eb3b458 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -17,7 +17,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>		/* Defines SHORT_NAMES if necessary */
 #include <HTAccess.h>
 #include <HTParse.h>
 #include <HTAlert.h>
@@ -29,8 +28,6 @@
 #include <sys/wait.h>
 #endif /* NSL_FORK */
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 #define OK_HOST(p) ((p) != 0 && (p->h_length) != 0)
 
 #ifdef SVR4_BSDSELECT
diff --git a/WWW/Library/Implementation/HTTCP.h b/WWW/Library/Implementation/HTTCP.h
index c7f16dcc..05e8278f 100644
--- a/WWW/Library/Implementation/HTTCP.h
+++ b/WWW/Library/Implementation/HTTCP.h
@@ -7,10 +7,7 @@
 #ifndef HTTCP_H
 #define HTTCP_H
 
-#ifndef HTUTILS_H
 #include <HTUtils.h>
-#endif /* HTUTILS_H */
-#include <tcp.h>
 
 #ifdef SHORT_NAMES
 #define HTInetStatus            HTInStat
@@ -115,6 +112,3 @@ extern int HTDoRead PARAMS((
 	unsigned 	nbyte));
 
 #endif   /* HTTCP_H */
-/*
-
-   End.  */
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index bee88b13..026d6c31 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -7,7 +7,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>
 
 #include <HTTP.h>
 
@@ -25,7 +24,6 @@
 #include <HTTCP.h>
 #include <HTFormat.h>
 #include <HTFile.h>
-#include <ctype.h>
 #include <HTAlert.h>
 #include <HTMIME.h>
 #include <HTML.h>
diff --git a/WWW/Library/Implementation/HTTelnet.c b/WWW/Library/Implementation/HTTelnet.c
index 2ee009b9..6ed9a738 100644
--- a/WWW/Library/Implementation/HTTelnet.c
+++ b/WWW/Library/Implementation/HTTelnet.c
@@ -14,7 +14,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>
 
 /* Implements:
 */
@@ -34,8 +33,6 @@
 
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 #define HT_NO_DATA -9999
 
 
diff --git a/WWW/Library/Implementation/HTUU.h b/WWW/Library/Implementation/HTUU.h
index 9c72a115..3594b276 100644
--- a/WWW/Library/Implementation/HTUU.h
+++ b/WWW/Library/Implementation/HTUU.h
@@ -11,9 +11,7 @@
 #ifndef HTUU_H
 #define HTUU_H
 
-#ifndef HTUTILS_H
 #include <HTUtils.h>
-#endif /* HTUTILS_H */
 
 PUBLIC int HTUU_encode PARAMS((unsigned char *bufin,
                                unsigned int nbytes,
@@ -24,6 +22,3 @@ PUBLIC int HTUU_decode PARAMS((char *bufcoded,
                                int outbufsize));
 
 #endif
-/*
-
-   End of file.  */
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index 5b9ad930..d1cdf51f 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -1,9 +1,7 @@
-/*                                                    Utitlity macros for the W3 code library
+/*                                       Utility macros for the W3 code library
                                   MACROS FOR GENERAL USE
                                              
-   Generates: HTUtils.h
-   
-   See also: the system dependent file "tcp.h"
+   See also: the system dependent file "tcp.h", which is included here.
    
  */
 
@@ -19,18 +17,6 @@
 #include <sys/types.h>
 #include <stdio.h>
 
-/*
- * We force this include-ordering since socks.h contains redefinitions of
- * functions that probably are prototyped via other includes.  The socks.h
- * definitions have to be included everywhere, since they're making wrappers
- * for the stdio functions as well as the network functions.
- */
-#if defined(USE_SOCKS5) && !defined(DONT_USE_SOCKS5)
-#define SOCKS4TO5
-#define SHORTENED_RBIND
-#include <socks.h>
-#endif /* USE_SOCKS5 */
-
 #else
 
 #include <stdio.h>
@@ -183,7 +169,6 @@ Standard C library for malloc() etc
 
 #include <stdlib.h>
 #include <unixlib.h>
-#include <ctype.h>
 #if defined(VAXC) && !defined(__DECC)
 #define malloc	VAXC$MALLOC_OPT
 #define calloc	VAXC$CALLOC_OPT
@@ -322,6 +307,7 @@ Sucess (>=0) and failure (<0) codes
 
 #define HT_ERROR                -1      /* Generic failure */
 
+#define HT_CANNOT_TRANSLATE -4
 #define HT_NO_ACCESS    -10             /* Access not available */
 #define HT_FORBIDDEN    -11             /* Access forbidden */
 #define HT_INTERNAL     -12             /* Weird -- should never happen. */
@@ -370,6 +356,8 @@ Upper- and Lowercase macros
 #define TOUPPER(c) (islower((unsigned char)c) ? toupper((unsigned char)c) : ((unsigned char)c))
 #endif /* TOLOWER */
 
+#define FREE(x) if (x) {free(x); x = NULL;}
+
 /*
 
 The local equivalents of CR and LF
@@ -387,8 +375,18 @@ The local equivalents of CR and LF
 
 extern FILE *TraceFP NOPARAMS;
 
-#endif /* HTUTILS_H */
+#include <tcp.h>
 
 /*
+ * We force this include-ordering since socks.h contains redefinitions of
+ * functions that probably are prototyped via other includes.  The socks.h
+ * definitions have to be included everywhere, since they're making wrappers
+ * for the stdio functions as well as the network functions.
+ */
+#if defined(USE_SOCKS5) && !defined(DONT_USE_SOCKS5)
+#define SOCKS4TO5
+#define SHORTENED_RBIND
+#include <socks.h>
+#endif /* USE_SOCKS5 */
 
-   end of utilities */
+#endif /* HTUTILS_H */
diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c
index a8ec136b..d2e981a9 100644
--- a/WWW/Library/Implementation/HTVMSUtils.c
+++ b/WWW/Library/Implementation/HTVMSUtils.c
@@ -14,7 +14,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>
 #include <HTFormat.h>
 #include <HTStream.h>
 #include <UCDefs.h>
@@ -377,7 +376,7 @@ PUBLIC char * HTVMS_name ARGS2(
 */
 PUBLIC int HTStat ARGS2(
 	CONST char *, filename, 
-	stat_t *, info)
+	struct stat *, info)
 {
    /* 
       the following stuff does not work in VMS with a normal stat...
@@ -473,9 +472,6 @@ char Name[256];
    return(Result);
 }
 
-/*** "dirent.h" ***/
-/* #include <types.h>	already in tcp.h */
-
 #ifndef	_POSIX_SOURCE
 #define	d_ino	d_fileno	/* compatability */
 #ifndef	NULL
@@ -1107,7 +1103,7 @@ PUBLIC int HTVMSBrowseDir ARGS4(
 	    StrAllocCopy(entry_info->type, cp);
 
 	    StrAllocCopy(entry_info->filename, dirbuf->d_name);
-	    if ((file_info.st_mode & S_IFMT) == S_IFDIR) {
+	    if (S_ISDIR(file_info.st_mode)) {
 	        /* strip .DIR part... */
                 char *dot;
                 dot = strstr(entry_info->filename, ".DIR");
@@ -1157,7 +1153,7 @@ PUBLIC int HTVMSBrowseDir ARGS4(
 	    }
 
 	    /* Get the size */
-	    if ((file_info.st_mode & S_IFMT) != S_IFDIR)
+	    if (!S_ISDIR(file_info.st_mode))
 	        entry_info->size = (unsigned int)file_info.st_size;
 	    else
 	        entry_info->size = 0;
diff --git a/WWW/Library/Implementation/HTVMSUtils.h b/WWW/Library/Implementation/HTVMSUtils.h
index e055d672..da6b9432 100644
--- a/WWW/Library/Implementation/HTVMSUtils.h
+++ b/WWW/Library/Implementation/HTVMSUtils.h
@@ -5,7 +5,8 @@
 #ifndef HTVMSUTIL_H
 #define HTVMSUTIL_H
 
-#include <stat.h>
+#include <HTUtils.h>
+#include <HTAnchor.h>
 
 extern BOOL HTVMSFileVersions;	/* Include version numbers in listing? */
 
@@ -102,7 +103,7 @@ PUBLIC char * HTVMS_name PARAMS((
 
 PUBLIC int HTStat PARAMS((
 	CONST char * filename,
-        stat_t * info));
+        struct stat * info));
 
 PUBLIC int HTVMSBrowseDir PARAMS((
 	CONST char * address,
@@ -111,6 +112,3 @@ PUBLIC int HTVMSBrowseDir PARAMS((
 	HTStream * sink));
 
 #endif /* not HTVMSUTIL_H */
-/*
-
-   End of file HTVMSUtil.h.  */
diff --git a/WWW/Library/Implementation/HTVMS_WaisProt.c b/WWW/Library/Implementation/HTVMS_WaisProt.c
index 543de7ad..76081407 100644
--- a/WWW/Library/Implementation/HTVMS_WaisProt.c
+++ b/WWW/Library/Implementation/HTVMS_WaisProt.c
@@ -32,7 +32,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>
 #include <HTVMS_WaisUI.h>
 #include <HTVMS_WaisProt.h>
 
@@ -58,7 +57,7 @@
 
 /*----------------------------------------------------------------------*/
 
-static unsigned long userInfoTagSize _AP((data_tag tag,
+static unsigned long userInfoTagSize PARAMS((data_tag tag,
 					  unsigned long length));
 
 static unsigned long
@@ -80,7 +79,7 @@ unsigned long length;
 
 /*----------------------------------------------------------------------*/
 
-static char* writeUserInfoHeader _AP((data_tag tag,long infoSize,	
+static char* writeUserInfoHeader PARAMS((data_tag tag,long infoSize,	
 				      long estHeaderSize,char* buffer,
 				      long* len));
 
@@ -127,7 +126,7 @@ long* len;
 
 /*----------------------------------------------------------------------*/
 
-static char* readUserInfoHeader _AP((data_tag* tag,unsigned long* num,
+static char* readUserInfoHeader PARAMS((data_tag* tag,unsigned long* num,
 				     char* buffer));
 
 static char*
@@ -228,8 +227,8 @@ char* buffer;
   char* buf = buffer;
   unsigned long size; 
   unsigned long headerSize;
-  data_tag tag;
   long chunkCode,chunkIDLen;
+  data_tag tag1;
   char* chunkMarker = NULL;
   char* highlightMarker = NULL;
   char* deHighlightMarker = NULL;
@@ -237,7 +236,7 @@ char* buffer;
   
   chunkCode = chunkIDLen = UNUSED;
   
-  buf = readUserInfoHeader(&tag,&size,buf);
+  buf = readUserInfoHeader(&tag1,&size,buf);
   headerSize = buf - buffer;
     
   while (buf < (buffer + size + headerSize))
@@ -436,7 +435,7 @@ DocObj* doc;
 
 /*----------------------------------------------------------------------*/
 
-static char* writeDocObj _AP((DocObj* doc,char* buffer,long* len));
+static char* writeDocObj PARAMS((DocObj* doc,char* buffer,long* len));
 
 static char*
 writeDocObj(doc,buffer,len)
@@ -483,7 +482,7 @@ long* len;
 
 /*----------------------------------------------------------------------*/
 
-static char* readDocObj _AP((DocObj** doc,char* buffer));
+static char* readDocObj PARAMS((DocObj** doc,char* buffer));
 
 static char*
 readDocObj(doc,buffer)
@@ -610,7 +609,7 @@ char* buffer;
     { char* buf = buffer;
       unsigned long size; 
       unsigned long headerSize;
-      data_tag tag;
+      data_tag tag1;
       char* seedWords = NULL;
       char* beginDateRange = NULL;
       char* endDateRange = NULL;
@@ -624,7 +623,7 @@ char* buffer;
 
       dateFactor = maxDocsRetrieved = UNUSED;
   
-      buf = readUserInfoHeader(&tag,&size,buf);
+      buf = readUserInfoHeader(&tag1,&size,buf);
       headerSize = buf - buffer;
   
       while (buf < (buffer + size + headerSize))
@@ -769,7 +768,7 @@ long* len;
   unsigned long header_len = userInfoTagSize(DT_DocumentHeaderGroup ,
 					     DefWAISDocHeaderSize);
   char* buf = buffer + header_len;
-  unsigned long size;
+  unsigned long size1;
   
   RESERVE_SPACE_FOR_WAIS_HEADER(len);
    
@@ -800,8 +799,8 @@ long* len;
   buf = writeString(header->OriginCity,DT_OriginCity,buf,len);
   
   /* now write the header and size */
-  size = buf - buffer; 
-  buf = writeUserInfoHeader(DT_DocumentHeaderGroup,size,header_len,buffer,len);
+  size1 = buf - buffer; 
+  buf = writeUserInfoHeader(DT_DocumentHeaderGroup,size1,header_len,buffer,len);
 
   return(buf);
 }
@@ -814,9 +813,9 @@ WAISDocumentHeader** header;
 char* buffer;
 {
   char* buf = buffer;
-  unsigned long size; 
+  unsigned long size1; 
   unsigned long headerSize;
-  data_tag tag;
+  data_tag tag1;
   any* docID = NULL;
   long versionNumber,score,bestMatch,docLength,lines;
   char** types = NULL;
@@ -827,10 +826,10 @@ char* buffer;
   
   versionNumber = score = bestMatch = docLength = lines = UNUSED;
   
-  buf = readUserInfoHeader(&tag,&size,buf);
+  buf = readUserInfoHeader(&tag1,&size1,buf);
   headerSize = buf - buffer;
     
-  while (buf < (buffer + size + headerSize))
+  while (buf < (buffer + size1 + headerSize))
     { data_tag tag = peekTag(buf);
       switch (tag)
 	{ case DT_DocumentID:
@@ -977,13 +976,13 @@ char* buffer;
   char* buf = buffer;
   unsigned long size; 
   unsigned long headerSize;
-  data_tag tag;
+  data_tag tag1;
   any* docID = NULL;
   long versionNumber,score,bestMatch,docLength,lines;
   
   versionNumber = score = bestMatch = docLength = lines = UNUSED;
   
-  buf = readUserInfoHeader(&tag,&size,buf);
+  buf = readUserInfoHeader(&tag1,&size,buf);
   headerSize = buf - buffer;
     
   while (buf < (buffer + size + headerSize))
@@ -1105,7 +1104,7 @@ long* len;
   unsigned long header_len = userInfoTagSize(DT_DocumentLongHeaderGroup ,
 					     DefWAISLongHeaderSize);
   char* buf = buffer + header_len;
-  unsigned long size;
+  unsigned long size1;
   
   RESERVE_SPACE_FOR_WAIS_HEADER(len);
    
@@ -1139,8 +1138,8 @@ long* len;
   buf = writeString(header->IndustryCodes,DT_IndustryCodes,buf,len);
   
   /* now write the header and size */
-  size = buf - buffer; 
-  buf = writeUserInfoHeader(DT_DocumentLongHeaderGroup,size,header_len,buffer,len);
+  size1 = buf - buffer; 
+  buf = writeUserInfoHeader(DT_DocumentLongHeaderGroup,size1,header_len,buffer,len);
 
   return(buf);
 }
@@ -1153,9 +1152,9 @@ WAISDocumentLongHeader** header;
 char* buffer;
 {
   char* buf = buffer;
-  unsigned long size; 
+  unsigned long size1; 
   unsigned long headerSize;
-  data_tag tag;
+  data_tag tag1;
   any* docID;
   long versionNumber,score,bestMatch,docLength,lines;
   char **types;
@@ -1166,10 +1165,10 @@ char* buffer;
   types = NULL;
   source = date = headline = originCity = stockCodes = companyCodes = industryCodes = NULL;
   
-  buf = readUserInfoHeader(&tag,&size,buf);
+  buf = readUserInfoHeader(&tag1,&size1,buf);
   headerSize = buf - buffer;
     
-  while (buf < (buffer + size + headerSize))
+  while (buf < (buffer + size1 + headerSize))
     { data_tag tag = peekTag(buf);
       switch (tag)
 	{ case DT_DocumentID:
@@ -1396,7 +1395,7 @@ long* len;
 /*----------------------------------------------------------------------*/
 
 static void
-cleanUpWaisSearchResponse _AP((char* buf,char* seedWordsUsed,
+cleanUpWaisSearchResponse PARAMS((char* buf,char* seedWordsUsed,
 			       WAISDocumentHeader** docHeaders,
 			       WAISDocumentShortHeader** shortHeaders,
 			       WAISDocumentLongHeader** longHeaders,
@@ -1474,7 +1473,7 @@ char* buffer;
   char* buf = buffer;
   unsigned long size; 
   unsigned long headerSize;
-  data_tag tag;
+  data_tag tag1;
   void* header = NULL;
   WAISDocumentHeader** docHeaders = NULL;
   WAISDocumentShortHeader** shortHeaders = NULL;
@@ -1491,7 +1490,7 @@ char* buffer;
   
   numDocHeaders = numLongHeaders = numShortHeaders = numText = numHeadlines = numCodes = 0;
   
-  buf = readUserInfoHeader(&tag,&size,buf);
+  buf = readUserInfoHeader(&tag1,&size,buf);
   headerSize = buf - buffer;
     
   while (buf < (buffer + size + headerSize))
@@ -1672,14 +1671,14 @@ char* buffer;
   char* buf = buffer;
   unsigned long size; 
   unsigned long headerSize;
-  data_tag tag;
+  data_tag tag1;
   any *docID,*documentText;
   long versionNumber;
   
   docID = documentText = NULL;
   versionNumber = UNUSED;
   
-  buf = readUserInfoHeader(&tag,&size,buf);
+  buf = readUserInfoHeader(&tag1,&size,buf);
   headerSize = buf - buffer;
     
   while (buf < (buffer + size + headerSize))
@@ -1788,7 +1787,7 @@ char* buffer;
   char* buf = buffer;
   unsigned long size; 
   unsigned long headerSize;
-  data_tag tag;
+  data_tag tag1;
   any* docID;
   long versionNumber;
   char *source,*date,*headline,*originCity;
@@ -1797,7 +1796,7 @@ char* buffer;
   versionNumber = UNUSED;
   source = date = headline = originCity = NULL;
   
-  buf = readUserInfoHeader(&tag,&size,buf);
+  buf = readUserInfoHeader(&tag1,&size,buf);
   headerSize = buf - buffer;
     
   while (buf < (buffer + size + headerSize))
@@ -1913,7 +1912,7 @@ char* buffer;
   char* buf = buffer;
   unsigned long size; 
   unsigned long headerSize;
-  data_tag tag;
+  data_tag tag1;
   any* docID;
   long versionNumber;
   char *stockCodes,*companyCodes,*industryCodes;
@@ -1922,7 +1921,7 @@ char* buffer;
   versionNumber = UNUSED;
   stockCodes = companyCodes = industryCodes = NULL;
   
-  buf = readUserInfoHeader(&tag,&size,buf);
+  buf = readUserInfoHeader(&tag1,&size,buf);
   headerSize = buf - buffer;
     
   while (buf < (buffer + size + headerSize))
@@ -1962,9 +1961,9 @@ char* buffer;
 
 char* 
 writePresentInfo(present,buffer,len)
-PresentAPDU* present;
+PresentAPDU* present GCC_UNUSED;
 char* buffer;
-long* len;
+long* len GCC_UNUSED;
 {
   /* The WAIS protocol doesn't use present info */
   return(buffer);
@@ -1986,9 +1985,9 @@ char* buffer;
 
 char* 
 writePresentResponseInfo(response,buffer,len)
-PresentResponseAPDU* response;
+PresentResponseAPDU* response GCC_UNUSED;
 char* buffer;
-long* len;
+long* len GCC_UNUSED;
 {
   /* The WAIS protocol doesn't use presentResponse info */
   return(buffer);
@@ -2045,7 +2044,7 @@ char* buffer;
         ( XXX return type could be in the element set)
 */
 
-static query_term** makeWAISQueryTerms _AP((DocObj** docs));
+static query_term** makeWAISQueryTerms PARAMS((DocObj** docs));
    
 static query_term**
 makeWAISQueryTerms(docs)
@@ -2164,7 +2163,7 @@ DocObj** docs;
 
 /*----------------------------------------------------------------------*/
 
-static DocObj** makeWAISQueryDocs _AP((query_term** terms));
+static DocObj** makeWAISQueryDocs PARAMS((query_term** terms));
 
 static DocObj** 
 makeWAISQueryDocs(terms)
diff --git a/WWW/Library/Implementation/HTVMS_WaisProt.h b/WWW/Library/Implementation/HTVMS_WaisProt.h
index 1a4e83d5..1b2329b1 100644
--- a/WWW/Library/Implementation/HTVMS_WaisProt.h
+++ b/WWW/Library/Implementation/HTVMS_WaisProt.h
@@ -29,9 +29,11 @@
 */
 
 #ifndef _H_WAIS_protocol_
-
 #define _H_WAIS_protocol_
 
+#include <HTUtils.h>
+#include <HTVMS_WaisUI.h>
+
 /*----------------------------------------------------------------------*/
 /* Data types / constants */
 
@@ -218,88 +220,97 @@ typedef struct WAISSearchResponse {
 /*----------------------------------------------------------------------*/
 /* Functions */
 
-DocObj* makeDocObjUsingWholeDocument _AP((any* aDocID,char* type));
-DocObj* makeDocObjUsingBytes _AP((any* aDocID,char* type,long start,long end));
-DocObj* makeDocObjUsingLines _AP((any* aDocID,char* type,long start,long end));
-DocObj* makeDocObjUsingParagraphs _AP((any* aDocID,char* type,any* start,any* end));
-void freeDocObj _AP((DocObj* doc));
-
-WAISInitResponse* makeWAISInitResponse _AP((long chunkCode,long chunkIDLen,
+char *
+generate_search_apdu PARAMS((char* buff,  /* buffer to hold the apdu */
+			  long *buff_len, /* number of bytes written to the buffer */
+			  char *seed_words, /* string of the seed words */
+			  char *database_name,
+			  DocObj** docobjs,
+			  long maxDocsRetrieved
+			  ));
+
+DocObj* makeDocObjUsingWholeDocument PARAMS((any* aDocID,char* type));
+DocObj* makeDocObjUsingBytes PARAMS((any* aDocID,char* type,long start,long end));
+DocObj* makeDocObjUsingLines PARAMS((any* aDocID,char* type,long start,long end));
+DocObj* makeDocObjUsingParagraphs PARAMS((any* aDocID,char* type,any* start,any* end));
+void freeDocObj PARAMS((DocObj* doc));
+
+WAISInitResponse* makeWAISInitResponse PARAMS((long chunkCode,long chunkIDLen,
 					    char* chunkMarker,char* highlightMarker,
 					    char* deHighlightMarker,char* newLineChars));
-void freeWAISInitResponse _AP((WAISInitResponse* init));
+void freeWAISInitResponse PARAMS((WAISInitResponse* init));
 
-WAISSearch* makeWAISSearch _AP((
+WAISSearch* makeWAISSearch PARAMS((
 	char* seedWords,DocObj** docs,char** textList,
 	long dateFactor,char* beginDateRange,char* endDateRange,
 	long maxDocsRetrieved));
-void freeWAISSearch _AP((WAISSearch* query));
+void freeWAISSearch PARAMS((WAISSearch* query));
 
-WAISDocumentHeader* makeWAISDocumentHeader _AP((
+WAISDocumentHeader* makeWAISDocumentHeader PARAMS((
 	any* aDocID,long versionNumber,long score,long bestMatch,long docLen,
 	long lines,char** types,char* source,char* date,char* headline,char* originCity));
-void freeWAISDocumentHeader _AP((WAISDocumentHeader* header));
-char* writeWAISDocumentHeader _AP((WAISDocumentHeader* header,char* buffer,long* len));
-char* readWAISDocumentHeader _AP((WAISDocumentHeader** header,char* buffer));
+void freeWAISDocumentHeader PARAMS((WAISDocumentHeader* header));
+char* writeWAISDocumentHeader PARAMS((WAISDocumentHeader* header,char* buffer,long* len));
+char* readWAISDocumentHeader PARAMS((WAISDocumentHeader** header,char* buffer));
 
-WAISDocumentShortHeader* makeWAISDocumentShortHeader _AP((
+WAISDocumentShortHeader* makeWAISDocumentShortHeader PARAMS((
 	any* aDocID,long versionNumber,long score,long bestMatch,long docLen,long lines));
-void freeWAISDocumentShortHeader _AP((WAISDocumentShortHeader* header));
-char* writeWAISDocumentShortHeader _AP((WAISDocumentShortHeader* header,
+void freeWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader* header));
+char* writeWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader* header,
                                    char* buffer,long* len));
-char* readWAISDocumentShortHeader _AP((WAISDocumentShortHeader** header,char* buffer));
+char* readWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader** header,char* buffer));
 
-WAISDocumentLongHeader* makeWAISDocumentLongHeader _AP((
+WAISDocumentLongHeader* makeWAISDocumentLongHeader PARAMS((
 	any* aDocID,long versionNumber,long score,long bestMatch,long docLen,
 	long lines,char** types,char* source,char* date, char* headline,char* originCity,
 	char* stockCodes,char* companyCodes,char* industryCodes));
-void freeWAISDocumentLongHeader _AP((WAISDocumentLongHeader* header));
-char* writeWAISDocumentLongHeader _AP((WAISDocumentLongHeader* header,char* buffer,long* len));
-char* readWAISDocumentLongHeader _AP((WAISDocumentLongHeader** header,char* buffer));
+void freeWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader* header));
+char* writeWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader* header,char* buffer,long* len));
+char* readWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader** header,char* buffer));
 
-WAISSearchResponse* makeWAISSearchResponse _AP((
+WAISSearchResponse* makeWAISSearchResponse PARAMS((
 	char* seedWordsUsed,WAISDocumentHeader** docHeaders,
 	WAISDocumentShortHeader** shortHeaders,
 	WAISDocumentLongHeader** longHeaders,
 	WAISDocumentText** text,WAISDocumentHeadlines** headlines,
 	WAISDocumentCodes** codes,
 	diagnosticRecord** diagnostics));
-void freeWAISSearchResponse _AP((WAISSearchResponse* response));
+void freeWAISSearchResponse PARAMS((WAISSearchResponse* response));
 
-WAISDocumentText* makeWAISDocumentText _AP((any* aDocID,long versionNumber,
+WAISDocumentText* makeWAISDocumentText PARAMS((any* aDocID,long versionNumber,
 				       any* documentText));
-void freeWAISDocumentText _AP((WAISDocumentText* docText));
-char* writeWAISDocumentText _AP((WAISDocumentText* docText,char* buffer,long* len));
-char* readWAISDocumentText _AP((WAISDocumentText** docText,char* buffer));
+void freeWAISDocumentText PARAMS((WAISDocumentText* docText));
+char* writeWAISDocumentText PARAMS((WAISDocumentText* docText,char* buffer,long* len));
+char* readWAISDocumentText PARAMS((WAISDocumentText** docText,char* buffer));
 
-WAISDocumentHeadlines* makeWAISDocumentHeadlines _AP((
+WAISDocumentHeadlines* makeWAISDocumentHeadlines PARAMS((
 	any* aDocID,long versionNumber,char* source,char* date,char* headline,
 	char* originCity));
-void freeWAISDocumentHeadlines _AP((WAISDocumentHeadlines* docHeadline));
-char* writeWAISDocumentHeadlines _AP((WAISDocumentHeadlines* docHeadline,char* buffer,long* len));
-char* readWAISDocumentHeadlines _AP((WAISDocumentHeadlines** docHeadline,char* buffer));
+void freeWAISDocumentHeadlines PARAMS((WAISDocumentHeadlines* docHeadline));
+char* writeWAISDocumentHeadlines PARAMS((WAISDocumentHeadlines* docHeadline,char* buffer,long* len));
+char* readWAISDocumentHeadlines PARAMS((WAISDocumentHeadlines** docHeadline,char* buffer));
 
-WAISDocumentCodes* makeWAISDocumentCodes _AP((
+WAISDocumentCodes* makeWAISDocumentCodes PARAMS((
 	any* aDocID,long versionNumber,char* stockCodes,char* companyCodes,
 	char* industryCodes));
-void freeWAISDocumentCodes _AP((WAISDocumentCodes* docCodes));
-char* writeWAISDocumentCodes _AP((WAISDocumentCodes* docCodes,char* buffer,long* len));
-char* readWAISDocumentCodes _AP((WAISDocumentCodes** docCodes,char* buffer));
-
-any* makeWAISTextQuery _AP((DocObj** docs));
-DocObj** readWAISTextQuery _AP((any* terms));
-
-void CSTFreeWAISInitResponse _AP((WAISInitResponse* init));
-void CSTFreeWAISSearch _AP((WAISSearch* query));
-void CSTFreeDocObj _AP((DocObj* doc));
-void CSTFreeWAISDocumentHeader _AP((WAISDocumentHeader* header));
-void CSTFreeWAISDocumentShortHeader _AP((WAISDocumentShortHeader* header));
-void CSTFreeWAISDocumentLongHeader _AP((WAISDocumentLongHeader* header));
-void CSTFreeWAISSearchResponse _AP((WAISSearchResponse* response));
-void CSTFreeWAISDocumentText _AP((WAISDocumentText* docText));
-void CSTFreeWAISDocHeadlines _AP((WAISDocumentHeadlines* docHeadline));
-void CSTFreeWAISDocumentCodes _AP((WAISDocumentCodes* docCodes));
-void CSTFreeWAISTextQuery _AP(( any* query));
+void freeWAISDocumentCodes PARAMS((WAISDocumentCodes* docCodes));
+char* writeWAISDocumentCodes PARAMS((WAISDocumentCodes* docCodes,char* buffer,long* len));
+char* readWAISDocumentCodes PARAMS((WAISDocumentCodes** docCodes,char* buffer));
+
+any* makeWAISTextQuery PARAMS((DocObj** docs));
+DocObj** readWAISTextQuery PARAMS((any* terms));
+
+void CSTFreeWAISInitResponse PARAMS((WAISInitResponse* init));
+void CSTFreeWAISSearch PARAMS((WAISSearch* query));
+void CSTFreeDocObj PARAMS((DocObj* doc));
+void CSTFreeWAISDocumentHeader PARAMS((WAISDocumentHeader* header));
+void CSTFreeWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader* header));
+void CSTFreeWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader* header));
+void CSTFreeWAISSearchResponse PARAMS((WAISSearchResponse* response));
+void CSTFreeWAISDocumentText PARAMS((WAISDocumentText* docText));
+void CSTFreeWAISDocHeadlines PARAMS((WAISDocumentHeadlines* docHeadline));
+void CSTFreeWAISDocumentCodes PARAMS((WAISDocumentCodes* docCodes));
+void CSTFreeWAISTextQuery PARAMS(( any* query));
 
 /*----------------------------------------------------------------------*/
 
@@ -334,6 +345,9 @@ void CSTFreeWAISTextQuery _AP(( any* query));
 #ifndef WMESSAGE_H
 #define WMESSAGE_H
 
+#include <HTUtils.h>
+#include <HTVMS_WaisUI.h>
+
 typedef struct wais_header {
         char    msg_len[10];    /* length in bytes of following message */
         char    msg_type;       /* type of message: 'z'=Z39.50 APDU,
@@ -367,9 +381,9 @@ typedef struct wais_header {
 #define UUENCODE		'u'  
 
 
-void readWAISPacketHeader _AP((char* msgBuffer,WAISMessage *header_struct));
-long getWAISPacketLength _AP((WAISMessage* header));
-void writeWAISPacketHeader _AP((char* header,long dataLen,long type,
+void readWAISPacketHeader PARAMS((char* msgBuffer,WAISMessage *header_struct));
+long getWAISPacketLength PARAMS((WAISMessage* header));
+void writeWAISPacketHeader PARAMS((char* header,long dataLen,long type,
 				char* server,long compression,	
 				long encoding,long version));
 
diff --git a/WWW/Library/Implementation/HTVMS_WaisUI.c b/WWW/Library/Implementation/HTVMS_WaisUI.c
index f8f88da3..6551bc60 100644
--- a/WWW/Library/Implementation/HTVMS_WaisUI.c
+++ b/WWW/Library/Implementation/HTVMS_WaisUI.c
@@ -17,10 +17,10 @@
    Brewster@think.com
 */
 
-/* 
+/*
  * this is a simple ui toolkit for building other ui's on top.
  * -brewster
- * 
+ *
  * top level functions:
  *   generate_search_apdu
  *   generate_retrieval_apdu
@@ -32,26 +32,22 @@
  *   generate multiple queries for long documents.
  *     this will crash if the file being retrieved is larger than 100k.
  *   do log_write()
- *   
+ *
  */
 
 #include <HTUtils.h>
-#include <tcp.h>
 #include <HTVMS_WaisUI.h>
 #include <HTVMS_WaisProt.h>
 #include <HTTCP.h>
-/*#include <stdio> included by HTUtils.h -- FM */
-#include <string.h>
-#include <ctype.h>
+
+#undef MAXINT	/* we don't need it here, and tcp.h may conflict */
 #include <math.h>
-#include <stdarg.h>
 
 #include <LYexit.h>
 #include <LYLeaks.h>
 
 void
-log_write(s)
-char *s;
+log_write(char *s GCC_UNUSED)
 {
     return;
 }
@@ -59,7 +55,7 @@ char *s;
 /*----------------------------------------------------------------------*/
 
 /* returns a pointer in the buffer of the first free byte.
-   if it overflows, then NULL is returned 
+   if it overflows, then NULL is returned
  */
 char *
 generate_search_apdu(buff,
@@ -95,12 +91,12 @@ long maxDocsRetrieved;
                          maxDocsRetrieved
                          );
 
-  search3 = makeSearchAPDU(30, 
+  search3 = makeSearchAPDU(30,
 			   5000, /* should be large */
 			   30,
                            1,	/* replace indicator */
                            "",	/* result set name */
-                           database_names, /* database name */   
+                           database_names, /* database name */
                            QT_RelevanceFeedbackQuery, /* query_type */
                            0,   /* element name */
                            NULL, /* reference ID */
@@ -159,9 +155,9 @@ char *database_name;
 
   refID.size = 1;
   refID.bytes = "3";
-  
+
   switch(chunk_type){
-  case CT_line: 
+  case CT_line:
     DocObjs[0] = makeDocObjUsingLines(docID, type, start, end);
     break;
   case CT_byte:
@@ -170,11 +166,11 @@ char *database_name;
   }
   DocObjs[1] = NULL;
 
-  query = makeWAISTextQuery(DocObjs);   
-  search = makeSearchAPDU( 10, 16, 15, 
+  query = makeWAISTextQuery(DocObjs);
+  search = makeSearchAPDU( 10, 16, 15,
 			  1,	/* replace indicator */
 			  "FOO", /* result set name */
-			  database_names, /* database name */   
+			  database_names, /* database name */
 			  QT_TextRetrievalQuery, /* query_type */
 			  element_names, /* element name */
 			  &refID, /* reference ID */
@@ -192,10 +188,7 @@ char *database_name;
  * to those trying to modify the transport code to use non-UNIX streams:
  *  This is the function to modify!
  */
-long read_from_stream(d,buf,nbytes)
-int d;				/* this is the stream */
-char *buf;
-long nbytes;
+PRIVATE long read_from_stream(int d, char *buf, long nbytes)
 {
   long didRead;
   long toRead = nbytes;
@@ -214,7 +207,7 @@ long nbytes;
     totalRead += didRead;
   }
   if(totalRead != nbytes)	/* we overread for some reason */
-    return(- totalRead);	/* bad news */    
+    return(- totalRead);	/* bad news */
   return(totalRead);
 }
 
@@ -222,25 +215,21 @@ long nbytes;
 
 /* returns the length of the response, 0 if an error */
 
-long 
-transport_message(connection,
-		  request_message,
-		  request_length,
-		  response_message,
-		  response_buffer_length)
-int connection;
-char *request_message;
-long request_length;
-char *response_message;
-long response_buffer_length;
+PRIVATE long
+transport_message(
+	long connection,
+	char *request_message,
+	long request_length,
+	char *response_message,
+	long response_buffer_length)
 {
   WAISMessage header;
   long response_length;
   int rv;
 
-  
+
   /* Write out message. Read back header. Figure out response length. */
-  
+
   if( request_length + HEADER_LENGTH !=
       NETWRITE(connection,request_message,
    		  (int)( request_length +HEADER_LENGTH)) )
@@ -272,7 +261,7 @@ long response_buffer_length;
     response_length = atol(length_array);
     /*
       if(verbose){
-      printf("WAIS header: '%s' length_array: '%s'\n", 
+      printf("WAIS header: '%s' length_array: '%s'\n",
       response_message, length_array);
       }
       */
@@ -281,7 +270,7 @@ long response_buffer_length;
 	 and return 0 */
       long i;
       for(i = 0; i < response_length; i++){
-	rv = read_from_stream(connection, 
+	rv = read_from_stream(connection,
 			      response_message + HEADER_LENGTH,
 			      1);
 	if (rv == HT_INTERRUPTED)
@@ -292,7 +281,7 @@ long response_buffer_length;
       return(0);
     }
   }
-  rv = read_from_stream(connection, 
+  rv = read_from_stream(connection,
 			response_message + HEADER_LENGTH,
 			response_length);
   if (rv == HT_INTERRUPTED)
@@ -304,19 +293,15 @@ long response_buffer_length;
 
 /*----------------------------------------------------------------------*/
 
-/* returns the number of bytes writen.  0 if an error */
+/* returns the number of bytes written.  0 if an error */
 long
-interpret_message(request_message,request_length,
-		  response_message,
-		  response_buffer_length,
-		  connection,
-		  verbose)
-char *request_message;
-long request_length; /* length of the buffer */
-char *response_message;
-long response_buffer_length;
-int connection;
-boolean verbose;
+interpret_message(
+	char *request_message,
+	long request_length, /* length of the buffer */
+	char *response_message,
+	long response_buffer_length,
+	long connection,
+	boolean verbose GCC_UNUSED)
 {
   long response_length;
 
@@ -328,7 +313,7 @@ boolean verbose;
     if(service_name && strlen(service_name) > 0)
       printf(" for service %s", service_name);
     printf("\n");
-    twais_dsply_rsp_apdu(request_message + HEADER_LENGTH, 
+    twais_dsply_rsp_apdu(request_message + HEADER_LENGTH,
 			 request_length);
   }
 
@@ -358,9 +343,7 @@ boolean verbose;
 
 /* modifies the string to exclude all seeker codes. sets length to
    the new length. */
-char *delete_seeker_codes(string,length)
-char *string;
-long *length;
+PRIVATE char *delete_seeker_codes(char *string, long *length)
 {
   long original_count; /* index into the original string */
   long new_count = 0; /* index into the collapsed string */
@@ -378,7 +361,7 @@ long *length;
   *length = new_count;
   return(string);
 }
-  
+
 /*----------------------------------------------------------------------*/
 
 #if defined(VMS) && defined(__GNUC__)			/* 10-AUG-1995 [pr] */
@@ -402,7 +385,7 @@ char *trim_junk(headline)
 char *headline;
 {
   long length = strlen(headline) + 1; /* include the trailing null */
-  long i;
+  size_t i;
   headline = delete_seeker_codes(headline, &length);
   /* delete leading spaces */
   for(i=0; i < strlen(headline); i++){
@@ -430,8 +413,8 @@ char *headline;
 **----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE:`
    No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.	
-  
+   disclaimer.
+
    3.26.90	Harry Morris, morris@think.com
    3.30.90  Harry Morris - Changed any->bits to any->bytes
    4.11.90  HWM - generalized conditional includes (see c-dialect.h)
@@ -439,14 +422,14 @@ char *headline;
 
 #define RESERVE_SPACE_FOR_HEADER(spaceLeft)		\
 	*spaceLeft -= HEADER_LEN;
-	
+
 #define RELEASE_HEADER_SPACE(spaceLeft)			\
 	if (*spaceLeft > 0)				\
 	  *spaceLeft += HEADER_LEN;
-	
+
 /*----------------------------------------------------------------------*/
 
-InitResponseAPDU* 
+InitResponseAPDU*
 makeInitResponseAPDU(result,
 		     search,
 		     present,
@@ -476,7 +459,7 @@ char* version;
 any* refID;
 void* userInfo;
 /* build an initResponse APDU with user specified information */
-{ 
+{
   InitResponseAPDU* init = (InitResponseAPDU*)s_malloc((size_t)sizeof(InitResponseAPDU));
 
   init->PDUType = initResponseAPDU;
@@ -494,13 +477,13 @@ void* userInfo;
   init->ImplementationVersion = s_strdup(version);
   init->ReferenceID = duplicateAny(refID);
   init->UserInformationField = userInfo; /* not copied! */
-  
+
   return(init);
 }
 
 /*----------------------------------------------------------------------*/
 
-void 
+void
 freeInitResponseAPDU(init)
 InitResponseAPDU* init;
 /* free an initAPDU */
@@ -515,23 +498,23 @@ InitResponseAPDU* init;
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 writeInitResponseAPDU(init,buffer,len)
 InitResponseAPDU* init;
 char* buffer;
 long* len;
 /* write the initResponse to a buffer, adding system information */
-{ 
+{
   char* buf = buffer + HEADER_LEN; /* leave room for the header-length-indicator */
   long size;
   bit_map* optionsBM = NULL;
 
   RESERVE_SPACE_FOR_HEADER(len);
-  
+
   buf = writePDUType(init->PDUType,buf,len);
   buf = writeBoolean(init->Result,buf,len);
   buf = writeProtocolVersion(buf,len);
-  
+
   optionsBM = makeBitMap((unsigned long)5,init->willSearch,init->willPresent,
                          init->willDelete,init->supportAccessControl,
                          init->supportResourceControl);
@@ -545,21 +528,21 @@ long* len;
   buf = writeString(init->ImplementationName,DT_ImplementationName,buf,len);
   buf = writeString(init->ImplementationVersion,DT_ImplementationVersion,buf,len);
   buf = writeAny(init->ReferenceID,DT_ReferenceID,buf,len);
-  
+
   /* go back and write the header-length-indicator */
   RELEASE_HEADER_SPACE(len);
-  size = buf - buffer - HEADER_LEN; 
+  size = buf - buffer - HEADER_LEN;
   writeBinaryInteger(size,HEADER_LEN,buffer,len);
 
   if (init->UserInformationField != NULL)
-    buf = writeInitResponseInfo(init,buf,len);   
-    
+    buf = writeInitResponseInfo(init,buf,len);
+
   return(buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 readInitResponseAPDU(init,buffer)
 InitResponseAPDU** init;
 char* buffer;
@@ -568,35 +551,35 @@ char* buffer;
   boolean search,present,delete,accessControl,resourceControl;
   long prefSize,maxMsgSize;
   char *auth,*id,*name,*version;
-  long size; 
+  long size;
   pdu_type pduType;
   bit_map* versionBM = NULL;
   bit_map* optionsBM = NULL;
   boolean result;
   any *refID = NULL;
   void* userInfo = NULL;
-  
+
   auth = id = name = version = NULL;
   refID = NULL;
-  
+
   /* read required part */
-  buf = readBinaryInteger(&size,HEADER_LEN,buf); 
+  buf = readBinaryInteger(&size,HEADER_LEN,buf);
   buf = readPDUType(&pduType,buf);
   buf = readBoolean(&result,buf);
-  buf = readBitMap(&versionBM,buf); 
+  buf = readBitMap(&versionBM,buf);
   buf = readBitMap(&optionsBM,buf);
   buf = readNum(&prefSize,buf);
   buf = readNum(&maxMsgSize,buf);
-  
+
   /* decode optionsBM */
   search = bitAtPos(0,optionsBM);
   present = bitAtPos(1,optionsBM);
   delete = bitAtPos(2,optionsBM);
   accessControl = bitAtPos(3,optionsBM);
   resourceControl = bitAtPos(4,optionsBM);
-  
+
   /* read optional part */
-  while (buf < (buffer + size + HEADER_LEN)) 
+  while (buf < (buffer + size + HEADER_LEN))
     { data_tag tag = peekTag(buf);
       switch (tag)
 	{ case DT_IDAuthentication:
@@ -638,12 +621,12 @@ char* buffer;
       freeAny(refID);
     }
   RETURN_ON_NULL(buf);
-  
+
   /* construct the basic init object */
   *init = makeInitResponseAPDU(result,
 			       search,present,delete,accessControl,resourceControl,
 			       prefSize,maxMsgSize,auth,id,name,version,refID,userInfo);
-			 	 			        	
+
   freeBitMap(versionBM);
   freeBitMap(optionsBM);
   s_free(auth);
@@ -651,19 +634,19 @@ char* buffer;
   s_free(name);
   s_free(version);
   freeAny(refID);
-  
+
   return(buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-InitResponseAPDU* 
+InitResponseAPDU*
 replyToInitAPDU(init,result,userInfo)
 InitAPDU* init;
 boolean result;
 void* userInfo;
 /* respond to an init message in the default way - echoing back
-   the init info 
+   the init info
  */
 {
   InitResponseAPDU* initResp;
@@ -679,7 +662,7 @@ void* userInfo;
 
 /*----------------------------------------------------------------------*/
 
-SearchAPDU* 
+SearchAPDU*
 makeSearchAPDU(small,
 	       large,
 	       medium,
@@ -710,7 +693,7 @@ void* queryInfo;
   query->MediumSetPresentNumber = medium;
   query->ReplaceIndicator = replace;
   query->ResultSetName = s_strdup(name);
-  query->DatabaseNames = NULL; 
+  query->DatabaseNames = NULL;
   if (databases != NULL)
     { for (i = 0, ptr = databases[i]; ptr != NULL; ptr = databases[++i])
 	{ if (query->DatabaseNames == NULL)
@@ -723,7 +706,7 @@ void* queryInfo;
 	  }
       }
   query->QueryType = s_strdup(type);
-  query->ElementSetNames = NULL; 
+  query->ElementSetNames = NULL;
   if (elements != NULL)
     { for (i = 0, ptr = elements[i]; ptr != NULL; ptr = elements[++i])
 	{ if (query->ElementSetNames == NULL)
@@ -742,7 +725,7 @@ void* queryInfo;
 
 /*----------------------------------------------------------------------*/
 
-void 
+void
 freeSearchAPDU(query)
 SearchAPDU* query;
 {
@@ -762,19 +745,19 @@ SearchAPDU* query;
 #define ES_DELIMITER_1 	"\037" 	/* separates database name from element name */
 #define ES_DELIMITER_2 	"\036" 	/* hex 1E separates <db,es> groups from one another */
 
-char* 
+char*
 writeSearchAPDU(query,buffer,len)
 SearchAPDU* query;
 char* buffer;
 long* len;
-{ 
+{
   char* buf = buffer + HEADER_LEN; /* leave room for the header-length-indicator */
   long size,i;
   char* ptr = NULL;
   char* scratch = NULL;
 
   RESERVE_SPACE_FOR_HEADER(len);
-  
+
   buf = writePDUType(query->PDUType,buf,len);
   buf = writeBinaryInteger(query->SmallSetUpperBound,(size_t)3,buf,len);
   buf = writeBinaryInteger(query->LargeSetLowerBound,(size_t)3,buf,len);
@@ -812,7 +795,7 @@ long* len;
 		ptr = query->ElementSetNames[++i]; /* the element set name */
 		scratch = (char*)s_realloc(scratch,newScratchSize);
 		s_strncat(scratch,ES_DELIMITER_1,2,newScratchSize);
-		s_strncat(scratch,ptr,strlen(ptr) + 1,newScratchSize); 
+		s_strncat(scratch,ptr,strlen(ptr) + 1,newScratchSize);
 	      }
 	      }
         else
@@ -822,28 +805,28 @@ long* len;
 	    s_strncat(scratch,ES_DELIMITER_2,2,newScratchSize);
 	    s_strncat(scratch,ptr,strlen(ptr) + 1,newScratchSize);
 	    s_strncat(scratch,ES_DELIMITER_1,2,newScratchSize);
-	    s_strncat(scratch,esPtr,strlen(esPtr) + 1,newScratchSize); 
+	    s_strncat(scratch,esPtr,strlen(esPtr) + 1,newScratchSize);
 	  }
 	  }
 	buf = writeString(scratch,DT_ElementSetNames,buf,len);
 	s_free(scratch);
-      }						
+      }
   buf = writeAny(query->ReferenceID,DT_ReferenceID,buf,len);
-    
+
   /* go back and write the header-length-indicator */
   RELEASE_HEADER_SPACE(len);
-  size = buf - buffer - HEADER_LEN; 
+  size = buf - buffer - HEADER_LEN;
   writeBinaryInteger(size,HEADER_LEN,buffer,len);
 
   if (query->Query != NULL)
-    buf = writeSearchInfo(query,buf,len);    
-    
+    buf = writeSearchInfo(query,buf,len);
+
   return(buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-SearchResponseAPDU* 
+SearchResponseAPDU*
 makeSearchResponseAPDU(result,count,recordsReturned,nextPos,resultStatus,
 		       presentStatus,refID,records)
 long result;
@@ -865,12 +848,12 @@ void* records;
   query->PresentStatus = presentStatus;
   query->ReferenceID = duplicateAny(refID);
   query->DatabaseDiagnosticRecords = records;
-  return(query);  
+  return(query);
 }
 
 /*----------------------------------------------------------------------*/
 
-void 
+void
 freeSearchResponseAPDU(queryResponse)
 SearchResponseAPDU* queryResponse;
 {
@@ -880,7 +863,7 @@ SearchResponseAPDU* queryResponse;
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 writeSearchResponseAPDU(queryResponse,buffer,len)
 SearchResponseAPDU* queryResponse;
 char* buffer;
@@ -890,7 +873,7 @@ long* len;
   long size;
 
   RESERVE_SPACE_FOR_HEADER(len);
-  
+
   buf = writePDUType(queryResponse->PDUType,buf,len);
   buf = writeBinaryInteger(queryResponse->SearchStatus,(size_t)1,buf,len);
   buf = writeBinaryInteger(queryResponse->ResultCount,(size_t)3,buf,len);
@@ -899,21 +882,21 @@ long* len;
   buf = writeNum(queryResponse->ResultSetStatus,DT_ResultSetStatus,buf,len);
   buf = writeNum(queryResponse->PresentStatus,DT_PresentStatus,buf,len);
   buf = writeAny(queryResponse->ReferenceID,DT_ReferenceID,buf,len);
-    
+
   /* go back and write the header-length-indicator */
   RELEASE_HEADER_SPACE(len);
-  size = buf - buffer - HEADER_LEN; 
+  size = buf - buffer - HEADER_LEN;
   writeBinaryInteger(size,HEADER_LEN,buffer,len);
 
   if (queryResponse->DatabaseDiagnosticRecords != NULL)
-    buf = writeSearchResponseInfo(queryResponse,buf,len);    
-    
+    buf = writeSearchResponseInfo(queryResponse,buf,len);
+
   return(buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 readSearchResponseAPDU(queryResponse,buffer)
 SearchResponseAPDU** queryResponse;
 char* buffer;
@@ -925,20 +908,20 @@ char* buffer;
   long resultStatus,presentStatus;
   any *refID = NULL;
   void* userInfo = NULL;
-  
+
   /* read required part */
-  buf = readBinaryInteger(&size,HEADER_LEN,buf); 
+  buf = readBinaryInteger(&size,HEADER_LEN,buf);
   buf = readPDUType(&pduType,buf);
   buf = readBinaryInteger(&result,(size_t)1,buf);
   buf = readBinaryInteger(&count,(size_t)3,buf);
   buf = readBinaryInteger(&recordsReturned,(size_t)3,buf);
   buf = readBinaryInteger(&nextPos,(size_t)3,buf);
-  
+
   resultStatus = presentStatus = UNUSED;
   refID = NULL;
 
   /* read optional part */
-  while (buf < (buffer + size + HEADER_LEN)) 
+  while (buf < (buffer + size + HEADER_LEN))
     { data_tag tag = peekTag(buf);
       switch (tag)
 	{ case DT_ResultSetStatus:
@@ -956,18 +939,18 @@ char* buffer;
 	    break;
 	  }
     }
-  
+
   buf = readSearchResponseInfo(&userInfo,buf);
   if (buf == NULL)
     freeAny(refID);
   RETURN_ON_NULL(buf);
-  
+
   /* construct the search object */
   *queryResponse = makeSearchResponseAPDU(result,count,recordsReturned,nextPos,
 					  (long)resultStatus,(long)presentStatus,refID,userInfo);
 
   freeAny(refID);
-  
+
   return(buf);
 }
 
@@ -978,11 +961,11 @@ char* buffer;
 **----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE:
    No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.	
-  
+   disclaimer.
+
    3.26.90	Harry Morris, morris@think.com
    3.30.90  Harry Morris - Changed any->bits to any->bytes
-   4.11.90  HWM - fixed include file names, changed 
+   4.11.90  HWM - fixed include file names, changed
    				- writeCompressedIntegerWithPadding() to
                   writeCompressedIntWithPadding()
                 - generalized conditional includes (see c-dialect.h)
@@ -992,43 +975,43 @@ char* buffer;
 char* readErrorPosition = NULL; /* pos where buf stoped making sense */
 
 /*----------------------------------------------------------------------*/
-/* A note on error handling 
+/* A note on error handling
    read - these are low level routines, they do not check the type tags
    which (sometimes) preceed the data (this is done by the higher
-   level functions which call these functions).  There is no 
+   level functions which call these functions).  There is no
    attempt made to check that the reading does not exceed the read
-   buffer.  Such cases should be very rare and usually will be 
-   caught by the calling functions. (note - it is unlikely that 
+   buffer.  Such cases should be very rare and usually will be
+   caught by the calling functions. (note - it is unlikely that
    a series of low level reads will go far off the edge without
    triggering a type error.  However, it is possible for a single
-   bad read in an array function (eg. readAny) to attempt to read a 
+   bad read in an array function (eg. readAny) to attempt to read a
    large ammount, possibly causing a segmentation violation or out
    of memory condition.
  */
 /*----------------------------------------------------------------------*/
 
-diagnosticRecord* 
+diagnosticRecord*
 makeDiag(surrogate,code,addInfo)
 boolean surrogate;
 char* code;
 char* addInfo;
 {
-  diagnosticRecord* diag = 
+  diagnosticRecord* diag =
     (diagnosticRecord*)s_malloc((size_t)sizeof(diagnosticRecord));
-  
+
   diag->SURROGATE = surrogate;
   memcpy(diag->DIAG,code,DIAGNOSTIC_CODE_SIZE);
-  diag->ADDINFO = s_strdup(addInfo); 
+  diag->ADDINFO = s_strdup(addInfo);
 
   return(diag);
 }
 
 /*----------------------------------------------------------------------*/
 
-void 
+void
 freeDiag(diag)
 diagnosticRecord* diag;
-{ 
+{
   if (diag != NULL)
     { if (diag->ADDINFO != NULL)
 	s_free(diag->ADDINFO);
@@ -1040,7 +1023,7 @@ diagnosticRecord* diag;
 
 #define END_OF_RECORD	0x1D
 
-char* 
+char*
 writeDiag(diag,buffer,len)
 diagnosticRecord* diag;
 char* buffer;
@@ -1051,42 +1034,42 @@ long* len;
 {
   char* buf = buffer;
   long  length;
-  
+
   if (diag == NULL)		/* handle unspecified optional args */
     return(buf);
 
   buf = writeTag(DT_DatabaseDiagnosticRecords,buf,len);
   CHECK_FOR_SPACE_LEFT(0,len);
-  
-  length = 3; 
+
+  length = 3;
   if (diag->ADDINFO != NULL)
     length += strlen(diag->ADDINFO);
-    
+
   if (length >= 0xFFFF )	/* make sure the length is reasonable */
     { length = 0xFFFF - 1;
       diag->ADDINFO[0xFFFF - 3 - 1] = '\0';
     }
-   
+
   buf = writeBinaryInteger(length,2,buf,len);
 
   CHECK_FOR_SPACE_LEFT(1,len);
-  buf[0] = diag->DIAG[0]; 
+  buf[0] = diag->DIAG[0];
   buf++;
-  
+
   CHECK_FOR_SPACE_LEFT(1,len);
   buf[0] = diag->DIAG[1];
   buf++;
-  
+
   if (length > 3)
     { CHECK_FOR_SPACE_LEFT(3,len);
       memcpy(buf,diag->ADDINFO,(size_t)length - 3);
       buf += length - 3;
     }
-   
+
   CHECK_FOR_SPACE_LEFT(1,len);
   buf[0] = diag->SURROGATE;
   buf++;
-  
+
   CHECK_FOR_SPACE_LEFT(1,len);
   buf[0] = END_OF_RECORD;
   buf++;
@@ -1096,25 +1079,25 @@ long* len;
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 readDiag(diag,buffer)
 diagnosticRecord** diag;
 char* buffer;
 {
   char* buf = buffer;
-  diagnosticRecord* d 
+  diagnosticRecord* d
     = (diagnosticRecord*)s_malloc((size_t)sizeof(diagnosticRecord));
   data_tag tag;
   long len;
-  
+
   buf = readTag(&tag,buf);
-  
+
   buf = readBinaryInteger(&len,2,buf);
-  
+
   d->DIAG[0] = buf[0];
   d->DIAG[1] = buf[1];
   d->DIAG[2] = '\0';
-    
+
   if (len > 3)
     { d->ADDINFO = (char*)s_malloc((size_t)(len - 3 + 1));
       memcpy(d->ADDINFO,(char*)(buf + 2),(size_t)(len - 3));
@@ -1122,9 +1105,9 @@ char* buffer;
     }
   else
     d->ADDINFO = NULL;
-    
+
   d->SURROGATE = buf[len - 1];
-  
+
   *diag = d;
 
   return(buf + len + 1);
@@ -1142,26 +1125,26 @@ unsigned long num;
 char* buf;
 long* len;
 /* write a binary integer in the format described on p. 40.
-   this might be sped up 
+   this might be sped up
 */
 {
   char byte;
-  long i;
+  unsigned long i;
   unsigned long size;
-  
+
   size = writtenCompressedIntSize(num);
   CHECK_FOR_SPACE_LEFT(size,len);
-  
-  for (i = size - 1; i >= 0; i--)
+
+  for (i = size - 1; i != 0; i--)
     { byte = num & dataMask;
       if (i != (size-1))	/* turn on continue bit */
 	byte = (char)(byte | continueBit);
       buf[i] = byte;
       num = num >> dataBits;	/* don't and here */
     }
-   
+
   return(buf + size);
-} 
+}
 
 /*----------------------------------------------------------------------*/
 
@@ -1170,15 +1153,15 @@ readCompressedInteger(num,buf)
 unsigned long *num;
 char* buf;
 /* read a binary integer in the format described on p. 40.
-   this might be sped up 
+   this might be sped up
 */
 {
   long i = 0;
   unsigned char byte;
 
   *num = 0;
-  
-  do 
+
+  do
     { byte = buf[i++];
       *num = *num << dataBits;
       *num += (byte & dataMask);
@@ -1186,7 +1169,7 @@ char* buf;
   while (byte & continueBit);
 
   return(buf + i);
-} 
+}
 
 /*----------------------------------------------------------------------*/
 
@@ -1199,16 +1182,16 @@ unsigned long size;
 char* buffer;
 long* len;
 /* Like writeCompressedInteger, except writes padding (128) to make
-   sure that size bytes are used.  This can be read correctly by 
+   sure that size bytes are used.  This can be read correctly by
    readCompressedInteger()
 */
 {
   char* buf = buffer;
   unsigned long needed,padding;
   long i;
-    
+
   CHECK_FOR_SPACE_LEFT(size,len);
-  
+
   needed = writtenCompressedIntSize(num);
   padding = size - needed;
   i = padding - 1;
@@ -1216,11 +1199,11 @@ long* len;
   for (i = padding - 1;i >= 0;i--)
     { buf[i] = pad;
     }
-  
+
   buf = writeCompressedInteger(num,buf + padding,len);
-  
+
   return(buf);
-} 
+}
 
 /*----------------------------------------------------------------------*/
 
@@ -1231,14 +1214,14 @@ unsigned long num;
    compressed format.  curently limited to 4 bytes
  */
 {
-  if (num < CompressedInt1Byte) 
+  if (num < CompressedInt1Byte)
     return(1);
-  else if (num < CompressedInt2Byte) 
+  else if (num < CompressedInt2Byte)
     return(2);
   else if (num < CompressedInt3Byte)
     return(3);
   else
-    return(4);    
+    return(4);
 }
 
 /*----------------------------------------------------------------------*/
@@ -1249,9 +1232,9 @@ data_tag tag;
 char* buf;
 long* len;
 /* write out a data tag */
-{ 
+{
   return(writeCompressedInteger(tag,buf,len));
-} 
+}
 
 /*----------------------------------------------------------------------*/
 
@@ -1260,16 +1243,16 @@ readTag(tag,buf)
 data_tag* tag;
 char* buf;
 /* read a data tag */
-{ 
+{
   return(readCompressedInteger(tag,buf));
-} 
+}
 
 /*----------------------------------------------------------------------*/
 
-unsigned long 
+unsigned long
 writtenTagSize(tag)
 data_tag tag;
-{ 
+{
   return(writtenCompressedIntSize(tag));
 }
 
@@ -1283,11 +1266,11 @@ char* buf;
   data_tag tag;
   readTag(&tag,buf);
   return(tag);
-} 
+}
 
 /*----------------------------------------------------------------------*/
 
-any* 
+any*
 makeAny(size,data)
 unsigned long size;
 char* data;
@@ -1304,7 +1287,7 @@ void
 freeAny(a)
 any* a;
 /* destroy an any and its associated data. Assumes a->bytes was
-   allocated using the s_malloc family of libraries 
+   allocated using the s_malloc family of libraries
  */
 {
   if (a != NULL)
@@ -1316,7 +1299,7 @@ any* a;
 
 /*----------------------------------------------------------------------*/
 
-any* 
+any*
 duplicateAny(a)
 any* a;
 {
@@ -1338,7 +1321,7 @@ any* a;
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 writeAny(a,tag,buffer,len)
 any* a;
 data_tag tag;
@@ -1350,7 +1333,7 @@ long* len;
 
   if (a == NULL)		/* handle unspecified optional args */
     return(buf);
-  
+
   /* write the tags */
   buf = writeTag(tag,buf,len);
   buf = writeCompressedInteger(a->size,buf,len);
@@ -1379,9 +1362,9 @@ char* buffer;
 a=(any*)s_malloc((size_t)sizeof(any));
 
   buf=buffer;
-  
+
   buf = readTag(&tag,buf);
-  
+
   buf = readCompressedInteger(&a->size,buf);
 
   /* now simply copy the bytes */
@@ -1394,7 +1377,7 @@ a=(any*)s_malloc((size_t)sizeof(any));
 
 /*----------------------------------------------------------------------*/
 
-unsigned long 
+unsigned long
 writtenAnySize(tag,a)
 data_tag tag;
 any* a;
@@ -1417,10 +1400,10 @@ stringToAny(s)
 char* s;
 {
   any* a = NULL;
-  
+
   if (s == NULL)
     return(NULL);
-    
+
   a = (any*)s_malloc((size_t)sizeof(any));
   a->size = strlen(s);
   a->bytes = (char*)s_malloc((size_t)a->size);
@@ -1435,10 +1418,10 @@ anyToString(a)
 any* a;
 {
   char* s = NULL;
-  
+
   if (a == NULL)
     return(NULL);
-    
+
   s = s_malloc((size_t)(a->size + 1));
   memcpy(s,a->bytes,(size_t)a->size);
   s[a->size] = '\0';
@@ -1447,15 +1430,15 @@ any* a;
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 writeString(s,tag,buffer,len)
 char* s;
 data_tag tag;
 char* buffer;
 long* len;
-/* Write a C style string.  The terminating null is not written. 
+/* Write a C style string.  The terminating null is not written.
    This function is not part of the Z39.50 spec.  It is provided
-   for the convienience of those wishing to pass C strings in 
+   for the convienience of those wishing to pass C strings in
    the place of an any.
  */
 {
@@ -1463,7 +1446,7 @@ long* len;
   any* data = NULL;
   if (s == NULL)
     return(buffer);		/* handle unused optional item before making an any */
-  data = (any*)s_malloc((size_t)sizeof(any)); 
+  data = (any*)s_malloc((size_t)sizeof(any));
   data->size = strlen(s);
   data->bytes = s;		/* save a copy here by not using stringToAny() */
   buf = writeAny(data,tag,buf,len);
@@ -1473,14 +1456,14 @@ long* len;
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 readString(s ,buffer)
 char** s ;
 char* buffer;
 /* Read an any and convert it into a C style string.
    This function is not part of the Z39.50 spec.  It is provided
-   for the convienience of those wishing to pass C strings in 
-   the place of an any. 
+   for the convienience of those wishing to pass C strings in
+   the place of an any.
  */
 {
   any* data = NULL;
@@ -1492,7 +1475,7 @@ char* buffer;
 
 /*----------------------------------------------------------------------*/
 
-unsigned long 
+unsigned long
 writtenStringSize(tag,s)
 data_tag tag;
 char* s;
@@ -1510,7 +1493,7 @@ char* s;
 
 /*----------------------------------------------------------------------*/
 
-any* 
+any*
 longToAny(num)
 long num;
 /* a convienience function */
@@ -1518,7 +1501,7 @@ long num;
   char s[40];
 
   sprintf(s,"%ld",num);
-  
+
   return(stringToAny(s));
 }
 
@@ -1537,7 +1520,7 @@ any* a;
   s_free(str);
   return(num);
 }
- 
+
 /*----------------------------------------------------------------------*/
 
 #define bitsPerByte	8
@@ -1551,18 +1534,18 @@ makeBitMap(unsigned long numBits, ...)
   bit_map* bm = NULL;
 
   va_start(ap,numBits);
-  
+
   bm = (bit_map*)s_malloc((size_t)sizeof(bit_map));
-  bm->size = (unsigned long)ceil((double)numBits / bitsPerByte); 
+  bm->size = (unsigned long)(ceil((double)numBits / bitsPerByte));
   bm->bytes = (char*)s_malloc((size_t)bm->size);
-  
+
   /* fill up the bits */
   for (i = 0; i < bm->size; i++) /* iterate over bytes */
     { char byte = 0;
       for (j = 0; j < bitsPerByte; j++) /* iterate over bits */
 	{ if ((i * bitsPerByte + j) < numBits)
 	    { boolean bit = false;
-	      bit = (boolean)va_arg(ap,boolean); 
+	      bit = (boolean)va_arg(ap,boolean);
 	      if (bit)
 	        { byte = byte | (1 << (bitsPerByte - j - 1));
 	        }
@@ -1589,8 +1572,8 @@ bit_map* bm;
 
 /*----------------------------------------------------------------------*/
 
-/* use this routine to interpret a bit map.  pos specifies the bit 
-   number.  bit 0 is the Leftmost bit of the first byte.  
+/* use this routine to interpret a bit map.  pos specifies the bit
+   number.  bit 0 is the Leftmost bit of the first byte.
    Could do bounds checking.
  */
 
@@ -1602,7 +1585,7 @@ bit_map* bm;
   if (pos > bm->size*bitsPerByte)
     return false;
   else
-    return((bm->bytes[(pos / bitsPerByte)] & 
+    return((bm->bytes[(pos / bitsPerByte)] &
 	    (0x80>>(pos % bitsPerByte))) ?
 	   true : false);
 }
@@ -1616,7 +1599,7 @@ data_tag tag;
 char* buffer;
 long* len;
 /* write a bitmap + type and size info */
-{ 
+{
   return(writeAny((any*)bm,tag,buffer,len));
 }
 
@@ -1639,7 +1622,7 @@ c=readAny((any**)bm,buffer);
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 writeByte(byte,buf,len)
 unsigned long byte;
 char* buf;
@@ -1652,7 +1635,7 @@ long* len;
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 readByte(byte,buf)
 unsigned char* byte;
 char* buf;
@@ -1663,7 +1646,7 @@ char* buf;
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 writeBoolean(flag,buf,len)
 boolean flag;
 char* buf;
@@ -1674,7 +1657,7 @@ long* len;
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 readBoolean(flag,buffer)
 boolean* flag;
 char* buffer;
@@ -1695,7 +1678,7 @@ long* len;
 /* PDUType is a single byte */
 {
   return(writeBinaryInteger((long)pduType,(unsigned long)1,buf,len));
-} 
+}
 
 /*----------------------------------------------------------------------*/
 
@@ -1706,14 +1689,14 @@ char* buf;
 /* PDUType is a single byte */
 {
   return(readBinaryInteger((long*)pduType,(unsigned long)1,buf));
-} 
+}
 
 /*----------------------------------------------------------------------*/
 
 pdu_type
 peekPDUType(buf)
 char* buf;
-/* read the next pdu without advancing the buffer, Note that this 
+/* read the next pdu without advancing the buffer, Note that this
    function is to be used on a buffer that is known to contain an
    APDU.  The pdu_type is written HEADER_LEN bytes into the buffer
  */
@@ -1781,11 +1764,11 @@ char* buf;
 
 /*----------------------------------------------------------------------*/
 
-unsigned long 
+unsigned long
 writtenCompressedBinIntSize(num)
 long num;
 /* return the number of bytes needed to represent the value num.
-   currently limited to max of 4 bytes 
+   currently limited to max of 4 bytes
    Only compresses for positive nums - negatives get whole 4 bytes
  */
 {
@@ -1800,7 +1783,7 @@ long num;
   else
     return(4);
 }
- 
+
 /*----------------------------------------------------------------------*/
 
 char*
@@ -1813,13 +1796,13 @@ long* len;
 {
   char* buf = buffer;
   long size = writtenCompressedBinIntSize(num);
-  
+
   if (num == UNUSED)
     return(buffer);
-    
+
   buf = writeTag(tag,buf,len);
-  buf = writeCompressedInteger(size,buf,len); 
-  buf = writeBinaryInteger(num,(unsigned long)size,buf,len); 
+  buf = writeCompressedInteger(size,buf,len);
+  buf = writeBinaryInteger(num,(unsigned long)size,buf,len);
   return(buf);
 }
 
@@ -1835,7 +1818,7 @@ char* buffer;
   data_tag tag;
   unsigned long size;
   unsigned long val;
-  
+
   buf = readTag(&tag,buf);
   buf = readCompressedInteger(&val,buf);
   size = (unsigned long)val;
@@ -1845,24 +1828,24 @@ char* buffer;
 
 /*----------------------------------------------------------------------*/
 
-unsigned long 
+unsigned long
 writtenNumSize(tag,num)
 data_tag tag;
 long num;
 {
   long dataSize = writtenCompressedBinIntSize(num);
   long size;
-  
+
   size = writtenTagSize(tag); /* space for the tag */
   size += writtenCompressedIntSize(dataSize); /* space for the size */
   size += dataSize; /* space for the data */
-  
+
   return(size);
 }
 
 /*----------------------------------------------------------------------*/
 
-typedef void (voidfunc)();
+typedef void (voidfunc)(void *);
 
 void
 doList(list,func)
@@ -1880,7 +1863,7 @@ voidfunc *func;
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 writeProtocolVersion(buf,len)
 char* buf;
 long* len;
@@ -1891,7 +1874,7 @@ long* len;
   if (version == NULL)
    { version = makeBitMap((unsigned long)1,true); /* version 1! */
    }
-    
+
   return(writeBitMap(version,DT_ProtocolVersion,buf,len));
 }
 
@@ -1931,8 +1914,8 @@ defaultImplementationVersion()
 **----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE:
    No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.	
-  
+   disclaimer.
+
    3.26.90	Harry Morris, morris@think.com
    4.11.90  HWM - generalized conditional includes (see c-dialect.h)
 */
@@ -1978,7 +1961,7 @@ any* term;
 query_term*
 makeResultSetTerm(resultSet)
 any* resultSet;
-{ 
+{
   query_term* qt = (query_term*)s_malloc((size_t)sizeof(query_term));
 
   qt->TermType = TT_ResultSetID;
@@ -1986,13 +1969,13 @@ any* resultSet;
   qt->ResultSetID = duplicateAny(resultSet);
 
   qt->Term = NULL;
-  
+
   return(qt);
 }
 
 /*----------------------------------------------------------------------*/
 
-query_term* 
+query_term*
 makeOperatorTerm(operatorCode)
 char* operatorCode;
 {
@@ -2010,10 +1993,11 @@ char* operatorCode;
 
 /*----------------------------------------------------------------------*/
 
-void 
-freeTerm(qt)
-query_term* qt;
+void
+freeTerm(param)
+void* param;
 {
+  query_term* qt = (query_term*)param;
   switch (qt->TermType)
     { case TT_Attribute:
 	freeAny(qt->Term);
@@ -2037,7 +2021,7 @@ query_term* qt;
 #define ATTRIBUTE_LIST_SIZE	ATTRIBUTE_SIZE * 6
 #define AT_DELIMITER	" "
 
-char* 
+char*
 writeQueryTerm(qt,buffer,len)
 query_term* qt;
 char* buffer;
@@ -2048,15 +2032,15 @@ long* len;
 
   switch (qt->TermType)
     { case TT_Attribute:
-	strncpy(attributes,qt->Use,ATTRIBUTE_LIST_SIZE); 
+	strncpy(attributes,qt->Use,ATTRIBUTE_LIST_SIZE);
 	s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,qt->Relation,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); 
+	s_strncat(attributes,qt->Relation,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE);
 	s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,qt->Position,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); 
+	s_strncat(attributes,qt->Position,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE);
 	s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,qt->Structure,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); 
+	s_strncat(attributes,qt->Structure,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE);
 	s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,qt->Truncation,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE); 
+	s_strncat(attributes,qt->Truncation,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE);
 	s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE);
 	s_strncat(attributes,qt->Completeness,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE);
 	buf = writeString(attributes,DT_AttributeList,buf,len);
@@ -2079,7 +2063,7 @@ long* len;
 
 /*----------------------------------------------------------------------*/
 
-char* 
+char*
 readQueryTerm(qt,buffer)
 query_term** qt;
 char* buffer;
@@ -2097,7 +2081,7 @@ char* buffer;
   any*	resultSetID = NULL;
   data_tag tag;
 
-  
+
   tag = peekTag(buffer);
 
   switch(tag)
@@ -2117,7 +2101,7 @@ char* buffer;
 	break;
       case DT_ResultSetID:
 	buf = readAny(&resultSetID,buf);
-	*qt = makeResultSetTerm(resultSetID);	
+	*qt = makeResultSetTerm(resultSetID);
 	freeAny(resultSetID);
 	break;
       case DT_Operator:
@@ -2129,21 +2113,21 @@ char* buffer;
 	REPORT_READ_ERROR(buf);
 	break;
       }
-  
+
   return(buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-static unsigned long getQueryTermSize _AP((query_term* qt));
+static unsigned long getQueryTermSize PARAMS((query_term* qt));
 
 static unsigned long
 getQueryTermSize(qt)
 query_term* qt;
 /* figure out how many bytes it will take to write this query */
 {
-  unsigned long size;
-  static char attributes[] = "11 22 33 44 55 66"; /* we just need this to 
+  unsigned long size = 0;
+  static char attributes[] = "11 22 33 44 55 66"; /* we just need this to
 						     calculate its written
 						     size */
 
@@ -2169,7 +2153,7 @@ query_term* qt;
 
 /*----------------------------------------------------------------------*/
 
-/* A query is simply a null terminated list of query terms. For 
+/* A query is simply a null terminated list of query terms. For
    transmission, a query is written into an any which is sent as
    the user information field. */
 
@@ -2227,7 +2211,7 @@ log_write(tmp);
 	{ terms = (query_term**)s_malloc((size_t)(sizeof(query_term*)*2));
 	}
       else
-	{ terms = 
+	{ terms =
 	    (query_term**)s_realloc((char*)terms,
 				    (size_t)(sizeof(query_term*)*(numTerms+2)));
 	  }
@@ -2258,14 +2242,13 @@ if(qt==NULL)
  * up a little window to explain the problem.
  * On a unix box, it will print out the error and call perror()
  */
- 
+
 /*----------------------------------------------------------------------*/
 
-static void exitAction _AP((long error));
+static void exitAction PARAMS((long error));
 
 static void
-exitAction(error)
-long error;
+exitAction(long error GCC_UNUSED)
 {
   long i;
   for (i = 0; i < 100000; i++)
@@ -2287,7 +2270,7 @@ panic(char *format, ...)
   vfprintf(stderr,format,ap);	/* print the contents */
   va_end(ap);			/* free ap */
   fflush(stderr);
-  
+
   exitAction(0);
 }
 
@@ -2298,24 +2281,21 @@ panic(char *format, ...)
 **	Routines originally from cutil.c -- FM
 **
 **----------------------------------------------------------------------*/
-/* Wide AREA INFORMATION SERVER SOFTWARE	
+/* Wide AREA INFORMATION SERVER SOFTWARE
    No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.  
-  
+   disclaimer.
+
    3.26.90	Harry Morris, morris@think.com
    4.11.90  HWM - generalized conditional includes (see c-dialect.h)
 */
 
-#include <varargs.h>
-
-
 /*----------------------------------------------------------------------*/
 
 void
 fs_checkPtr(ptr)
 void* ptr;
 /* If the ptr is NULL, give an error */
-{ 
+{
   if (ptr == NULL)
     panic("checkPtr found a NULL pointer");
 }
@@ -2326,12 +2306,12 @@ void*
 fs_malloc(size)
 size_t size;
 /* does safety checks and optional accounting */
-{ 
+{
   register void* ptr = NULL;
 
   ptr = (void*)calloc((size_t)size,(size_t)1);
   s_checkPtr(ptr);
-  
+
   return(ptr);
 }
 
@@ -2341,19 +2321,19 @@ void*
 fs_realloc(ptr,size)
 void* ptr;
 size_t size;
-/* does safety checks and optional accounting 
+/* does safety checks and optional accounting
    note - we don't know how big ptr's memory is, so we can't ensure
    that any new memory allocated is NULLed!
  */
-{ 
+{
   register void* nptr = NULL;
-  
+
   if (ptr == NULL)		/* this is really a malloc */
     return(s_malloc(size));
-    
+
   nptr = (void*)realloc(ptr,size);
   s_checkPtr(ptr);
-   
+
   return(nptr);
 }
 
@@ -2378,16 +2358,16 @@ s_strdup(s)
 char* s;
 
 /* return a copy of s.  This is identical to the standard library routine
-   strdup(), except that it is safe.  If s == NULL or malloc fails, 
+   strdup(), except that it is safe.  If s == NULL or malloc fails,
    appropriate action is taken.
  */
 {
   unsigned long len;
   char* copy = NULL;
-  
+
   if (s == NULL)		/* saftey check to postpone stupid errors */
     return(NULL);
-    
+
   len = strlen(s);		/* length of string - terminator */
   copy = (char*)s_malloc((size_t)(sizeof(char)*(len + 1)));
   strncpy(copy,s,len + 1);
@@ -2403,13 +2383,13 @@ char* dst;
    size_t maxToAdd;
    size_t maxTotal;
 
-/* like strncat, except the fourth argument limits the maximum total 
+/* like strncat, except the fourth argument limits the maximum total
    length of the resulting string
  */
 {
   size_t dstSize = strlen(dst);
   size_t srcSize = strlen(src);
-  
+
   if (dstSize + srcSize < maxTotal) /* use regular old strncat */
     return(strncat(dst,src,maxToAdd));
   else
diff --git a/WWW/Library/Implementation/HTVMS_WaisUI.h b/WWW/Library/Implementation/HTVMS_WaisUI.h
index 6f492b87..fbb9278f 100644
--- a/WWW/Library/Implementation/HTVMS_WaisUI.h
+++ b/WWW/Library/Implementation/HTVMS_WaisUI.h
@@ -8,13 +8,9 @@
 #ifndef HTVMSWAIS_H
 #define HTVMSWAIS_H
 
-#ifndef __STDLIB_LOADED
-#include <stdlib.h>
-#endif /* __STDLIB_LOADED */
+#include <HTUtils.h>
 
-#define _AP(args) ()
-
-void	log_write _AP((char *));
+void	log_write PARAMS((char *));
 
 /*
 **	Routines originally from Panic.h -- FM
@@ -59,11 +55,11 @@ void	panic (char* format,...);
 
 /* enhanced memory handling functions - don't call them directly, use the
    macros below */
-void	fs_checkPtr _AP((void* ptr));
-void*	fs_malloc _AP((size_t size));
-void*	fs_realloc _AP((void* ptr,size_t size));
-void	fs_free _AP((void* ptr));
-char* 	fs_strncat _AP((char* dst,char* src,size_t maxToAdd,size_t maxTotal));
+void	fs_checkPtr PARAMS((void* ptr));
+void*	fs_malloc PARAMS((size_t size));
+void*	fs_realloc PARAMS((void* ptr,size_t size));
+void	fs_free PARAMS((void* ptr));
+char* 	fs_strncat PARAMS((char* dst,char* src,size_t maxToAdd,size_t maxTotal));
 
 /* macros for memory functions.  call these in your program.  */
 #define s_checkPtr(ptr) 	fs_checkPtr(ptr)
@@ -72,13 +68,13 @@ char* 	fs_strncat _AP((char* dst,char* src,size_t maxToAdd,size_t maxTotal));
 #define s_free(ptr)		{ fs_free((char*)ptr); ptr = NULL; }
 #define s_strncat(dst,src,maxToAdd,maxTotal)	fs_strncat((dst),(src),(maxToAdd),(maxTotal))
 
-char* 	s_strdup _AP((char* s));
+char* 	s_strdup PARAMS((char* s));
 
 #define IS_DELIMITER	1
 #define	NOT_DELIMITER	!IS_DELIMITER
 
-char char_downcase _AP((unsigned long ch));
-char *string_downcase _AP((char* word));
+char char_downcase PARAMS((unsigned long ch));
+char *string_downcase PARAMS((char* word));
 
 /*----------------------------------------------------------------------*/
 
@@ -283,71 +279,71 @@ extern char* readErrorPosition; 	/* pos where buf stoped making sense */
 
 /*----------------------------------------------------------------------*/
 
-diagnosticRecord* makeDiag _AP((boolean surrogate,char* code,char* addInfo));
-void freeDiag _AP((diagnosticRecord* diag));
-char* writeDiag _AP((diagnosticRecord* diag,char* buffer,long* len));
-char* readDiag _AP((diagnosticRecord** diag,char* buffer));
+diagnosticRecord* makeDiag PARAMS((boolean surrogate,char* code,char* addInfo));
+void freeDiag PARAMS((diagnosticRecord* diag));
+char* writeDiag PARAMS((diagnosticRecord* diag,char* buffer,long* len));
+char* readDiag PARAMS((diagnosticRecord** diag,char* buffer));
 
-char* writeCompressedInteger _AP((unsigned long num,char* buf,long* len));
-char* readCompressedInteger _AP((unsigned long *num,char* buf));
-char* writeCompressedIntWithPadding _AP((unsigned long num,unsigned long size,
+char* writeCompressedInteger PARAMS((unsigned long num,char* buf,long* len));
+char* readCompressedInteger PARAMS((unsigned long *num,char* buf));
+char* writeCompressedIntWithPadding PARAMS((unsigned long num,unsigned long size,
 					 char* buffer,long* len));
-unsigned long writtenCompressedIntSize _AP((unsigned long num));
+unsigned long writtenCompressedIntSize PARAMS((unsigned long num));
 
-char* writeTag _AP((data_tag tag,char* buf,long* len));
-char* readTag _AP((data_tag* tag,char* buf));
-data_tag peekTag _AP((char* buf));
-unsigned long writtenTagSize _AP((data_tag tag));
+char* writeTag PARAMS((data_tag tag,char* buf,long* len));
+char* readTag PARAMS((data_tag* tag,char* buf));
+data_tag peekTag PARAMS((char* buf));
+unsigned long writtenTagSize PARAMS((data_tag tag));
 
-any* makeAny _AP((unsigned long size,char* data));
-void freeAny _AP((any* a));
-any* duplicateAny _AP((any* a));
-char* writeAny _AP((any* a,data_tag tag,char* buffer,long* len));
-char* readAny _AP((any** anAny,char* buffer));
-unsigned long writtenAnySize _AP((data_tag tag,any* a));
+any* makeAny PARAMS((unsigned long size,char* data));
+void freeAny PARAMS((any* a));
+any* duplicateAny PARAMS((any* a));
+char* writeAny PARAMS((any* a,data_tag tag,char* buffer,long* len));
+char* readAny PARAMS((any** anAny,char* buffer));
+unsigned long writtenAnySize PARAMS((data_tag tag,any* a));
 
-any* stringToAny _AP((char* s));
-char* anyToString _AP((any* a));
-unsigned long writtenStringSize _AP((data_tag tag,char* s));
+any* stringToAny PARAMS((char* s));
+char* anyToString PARAMS((any* a));
+unsigned long writtenStringSize PARAMS((data_tag tag,char* s));
 
-any* longToAny _AP((long Num));
-long anyToLong _AP((any* a));
+any* longToAny PARAMS((long Num));
+long anyToLong PARAMS((any* a));
 
-char* writeString _AP((char* s,data_tag tag,char* buffer,long* len));
-char* readString _AP((char** s,char* buffer));
+char* writeString PARAMS((char* s,data_tag tag,char* buffer,long* len));
+char* readString PARAMS((char** s,char* buffer));
 
 bit_map* makeBitMap (unsigned long numBits,...);
 
-void freeBitMap _AP((bit_map* bm));
-boolean bitAtPos _AP((long pos,bit_map* bm));
-char* writeBitMap _AP((bit_map* bm,data_tag tag,char* buffer,long* len));
-char* readBitMap _AP((bit_map** bm,char* buffer));
+void freeBitMap PARAMS((bit_map* bm));
+boolean bitAtPos PARAMS((long pos,bit_map* bm));
+char* writeBitMap PARAMS((bit_map* bm,data_tag tag,char* buffer,long* len));
+char* readBitMap PARAMS((bit_map** bm,char* buffer));
 
-char* writeByte _AP((unsigned long byte,char* buf,long* len));
-char* readByte _AP((unsigned char* byte,char* buf));
+char* writeByte PARAMS((unsigned long byte,char* buf,long* len));
+char* readByte PARAMS((unsigned char* byte,char* buf));
 
-char* writeBoolean _AP((boolean flag,char* buf,long* len));
-char* readBoolean _AP((boolean* flag,char* buf));
+char* writeBoolean PARAMS((boolean flag,char* buf,long* len));
+char* readBoolean PARAMS((boolean* flag,char* buf));
 
-char* writePDUType _AP((pdu_type pduType,char* buf,long* len));
-char* readPDUType _AP((pdu_type* pduType,char* buf));
-pdu_type peekPDUType _AP((char* buf));
+char* writePDUType PARAMS((pdu_type pduType,char* buf,long* len));
+char* readPDUType PARAMS((pdu_type* pduType,char* buf));
+pdu_type peekPDUType PARAMS((char* buf));
 
-char* writeBinaryInteger _AP((long num,unsigned long size,
+char* writeBinaryInteger PARAMS((long num,unsigned long size,
 			      char* buf,long* len));
-char* readBinaryInteger _AP((long* num,unsigned long size,char* buf));
-unsigned long writtenCompressedBinIntSize _AP((long num));
+char* readBinaryInteger PARAMS((long* num,unsigned long size,char* buf));
+unsigned long writtenCompressedBinIntSize PARAMS((long num));
 
-char* writeNum _AP((long num,data_tag tag,char* buffer,long* len));
-char* readNum _AP((long* num,char* buffer));
-unsigned long  writtenNumSize _AP((data_tag tag,long num));
+char* writeNum PARAMS((long num,data_tag tag,char* buffer,long* len));
+char* readNum PARAMS((long* num,char* buffer));
+unsigned long  writtenNumSize PARAMS((data_tag tag,long num));
 
-void doList _AP((void** list,void (*func)()));
+void doList PARAMS((void** list,void (*func)(void *)));
 
-char* writeProtocolVersion _AP((char* buf,long* len));
-char* defaultImplementationID _AP((void));
-char* defaultImplementationName _AP((void));
-char* defaultImplementationVersion _AP((void));
+char* writeProtocolVersion PARAMS((char* buf,long* len));
+char* defaultImplementationID PARAMS((void));
+char* defaultImplementationName PARAMS((void));
+char* defaultImplementationVersion PARAMS((void));
 
 /*----------------------------------------------------------------------*/
 
@@ -462,16 +458,16 @@ typedef struct query_term {
 /*----------------------------------------------------------------------*/
 /* functions */
 
-query_term* makeAttributeTerm _AP((
+query_term* makeAttributeTerm PARAMS((
         char* use,char* relation,char* position,char* structure,
 	char* truncation,char* completeness,any* term));
-query_term* makeResultSetTerm _AP((any* resultSet));
-query_term* makeOperatorTerm _AP((char* operatorCode));
-void freeTerm _AP((query_term* qt));
-char* writeQueryTerm _AP((query_term* qt,char* buffer,long* len));
-char* readQueryTerm _AP((query_term** qt,char* buffer));
-any* writeQuery _AP((query_term** terms));
-query_term** readQuery _AP((any* info));
+query_term* makeResultSetTerm PARAMS((any* resultSet));
+query_term* makeOperatorTerm PARAMS((char* operatorCode));
+void freeTerm PARAMS((void* qt));
+char* writeQueryTerm PARAMS((query_term* qt,char* buffer,long* len));
+char* readQueryTerm PARAMS((query_term** qt,char* buffer));
+any* writeQuery PARAMS((query_term** terms));
+query_term** readQuery PARAMS((any* info));
 
 /*----------------------------------------------------------------------*/
 
@@ -482,16 +478,7 @@ query_term** readQuery _AP((any* info));
 **----------------------------------------------------------------------*/
 
 char *
-generate_search_apdu _AP((char* buff,  /* buffer to hold the apdu */
-			  long *buff_len, /* number of bytes written to the buffer */
-			  char *seed_words, /* string of the seed words */
-			  char *database_name,
-			  DocObj** docobjs,
-			  long maxDocsRetrieved
-			  ));
-
-char *
-generate_retrieval_apdu _AP((char *buff, 
+generate_retrieval_apdu PARAMS((char *buff, 
 			     long *buff_len, 
 			     any *docID,
 			     long chunk_type,
@@ -501,19 +488,14 @@ generate_retrieval_apdu _AP((char *buff,
 
 
 long
-interpret_message _AP((char *request_message,
+interpret_message PARAMS((char *request_message,
 		       long request_length,
 		       char *response_message,
 		       long response_buffer_length, /* length of the buffer (modified)*/
-		       FILE *connection,
+		       long connection,
 		       boolean verbose));
 
-
-void
-display_text_record_completely _AP((WAISDocumentText *record, 
-			       boolean quote_string_quotes));
-
-char *trim_junk _AP((char *headline));
+char *trim_junk PARAMS((char *headline));
 
 
 
@@ -601,74 +583,74 @@ typedef struct PresentResponseAPDU {
 /*----------------------------------------------------------------------*/
 /* Functions */
 
-InitAPDU* makeInitAPDU _AP((boolean search,boolean present,boolean deleteIt,
+InitAPDU* makeInitAPDU PARAMS((boolean search,boolean present,boolean deleteIt,
 			    boolean accessControl,boolean resourceControl,
 			    long prefMsgSize,long maxMsgSize,
 			    char* auth,char* id,char* name, char* version,
 			    any* refID,void* userInfo));
-void freeInitAPDU _AP((InitAPDU* init));
-char* writeInitAPDU _AP((InitAPDU* init,char* buffer,long* len));
-char* readInitAPDU _AP((InitAPDU** init,char* buffer));
+void freeInitAPDU PARAMS((InitAPDU* init));
+char* writeInitAPDU PARAMS((InitAPDU* init,char* buffer,long* len));
+char* readInitAPDU PARAMS((InitAPDU** init,char* buffer));
 
-InitResponseAPDU* makeInitResponseAPDU _AP((boolean result,
+InitResponseAPDU* makeInitResponseAPDU PARAMS((boolean result,
 					    boolean search,boolean present,boolean deleteIt,
 					    boolean accessControl,boolean resourceControl,
 					    long prefMsgSize,long maxMsgSize,
 					    char* auth,char* id,char* name, char* version,
 					    any* refID,void* userInfo));
-void freeInitResponseAPDU _AP((InitResponseAPDU* init));
-char* writeInitResponseAPDU _AP((InitResponseAPDU* init,char* buffer,long* len));
-char* readInitResponseAPDU _AP((InitResponseAPDU** init,char* buffer));
-InitResponseAPDU* replyToInitAPDU _AP((InitAPDU* init,boolean result,void* userInfo));
+void freeInitResponseAPDU PARAMS((InitResponseAPDU* init));
+char* writeInitResponseAPDU PARAMS((InitResponseAPDU* init,char* buffer,long* len));
+char* readInitResponseAPDU PARAMS((InitResponseAPDU** init,char* buffer));
+InitResponseAPDU* replyToInitAPDU PARAMS((InitAPDU* init,boolean result,void* userInfo));
 
-SearchAPDU* makeSearchAPDU _AP((long small,long large, long medium,
+SearchAPDU* makeSearchAPDU PARAMS((long small,long large, long medium,
 				boolean replace,char* name,char** databases,
 				char* type,char** elements,any* refID,void* queryInfo));
-void freeSearchAPDU _AP((SearchAPDU* query));
-char* writeSearchAPDU _AP((SearchAPDU* query,char* buffer,long* len));
-char* readSearchAPDU _AP((SearchAPDU** query,char* buffer));
+void freeSearchAPDU PARAMS((SearchAPDU* query));
+char* writeSearchAPDU PARAMS((SearchAPDU* query,char* buffer,long* len));
+char* readSearchAPDU PARAMS((SearchAPDU** query,char* buffer));
 
-SearchResponseAPDU* makeSearchResponseAPDU _AP((long result,long count,
+SearchResponseAPDU* makeSearchResponseAPDU PARAMS((long result,long count,
 						long recordsReturned,long nextPos,
 						long resultStatus,long presentStatus,
 						any* refID,void* records));
-void freeSearchResponseAPDU _AP((SearchResponseAPDU* queryResponse));
-char* writeSearchResponseAPDU _AP((SearchResponseAPDU* queryResponse,char* buffer,long* len));
-char* readSearchResponseAPDU _AP((SearchResponseAPDU** queryResponse,char* buffer));
+void freeSearchResponseAPDU PARAMS((SearchResponseAPDU* queryResponse));
+char* writeSearchResponseAPDU PARAMS((SearchResponseAPDU* queryResponse,char* buffer,long* len));
+char* readSearchResponseAPDU PARAMS((SearchResponseAPDU** queryResponse,char* buffer));
 
-PresentAPDU* makePresentAPDU _AP((long recsReq, long startPos,
+PresentAPDU* makePresentAPDU PARAMS((long recsReq, long startPos,
 				  char* resultID,any* refID,void* info));
-void freePresentAPDU _AP((PresentAPDU* present));
-char* writePresentAPDU _AP((PresentAPDU* present,char* buffer,long* len));
-char* readPresentAPDU _AP((PresentAPDU** present,char* buffer));
+void freePresentAPDU PARAMS((PresentAPDU* present));
+char* writePresentAPDU PARAMS((PresentAPDU* present,char* buffer,long* len));
+char* readPresentAPDU PARAMS((PresentAPDU** present,char* buffer));
 
-PresentResponseAPDU* makePresentResponseAPDU _AP((boolean status,long recsRet,
+PresentResponseAPDU* makePresentResponseAPDU PARAMS((boolean status,long recsRet,
 						  long nextPos,any* refID,
 						  void* records));
-void freePresentResponseAPDU _AP((PresentResponseAPDU* present));
-char* writePresentResponseAPDU _AP((PresentResponseAPDU* present,char* buffer,long* len));
-char* readPresentResponseAPDU _AP((PresentResponseAPDU** present,char* buffer));
+void freePresentResponseAPDU PARAMS((PresentResponseAPDU* present));
+char* writePresentResponseAPDU PARAMS((PresentResponseAPDU* present,char* buffer,long* len));
+char* readPresentResponseAPDU PARAMS((PresentResponseAPDU** present,char* buffer));
 
 /*----------------------------------------------------------------------*/
 /* user extension hooks: */
 
-extern char* writeInitInfo _AP((InitAPDU* init,char* buffer,long* len));
-extern char* readInitInfo _AP((void** info,char* buffer));
+extern char* writeInitInfo PARAMS((InitAPDU* init,char* buffer,long* len));
+extern char* readInitInfo PARAMS((void** info,char* buffer));
 
-extern char* writeInitResponseInfo _AP((InitResponseAPDU* init,char* buffer,long* len));
-extern char* readInitResponseInfo _AP((void** info,char* buffer));
+extern char* writeInitResponseInfo PARAMS((InitResponseAPDU* init,char* buffer,long* len));
+extern char* readInitResponseInfo PARAMS((void** info,char* buffer));
 
-extern char* writeSearchInfo _AP((SearchAPDU* query,char* buffer,long* len));
-extern char* readSearchInfo _AP((void** info,char* buffer));
+extern char* writeSearchInfo PARAMS((SearchAPDU* query,char* buffer,long* len));
+extern char* readSearchInfo PARAMS((void** info,char* buffer));
 
-extern char* writeSearchResponseInfo _AP((SearchResponseAPDU* query,char* buffer,long* len));
-extern char* readSearchResponseInfo _AP((void** info,char* buffer));
+extern char* writeSearchResponseInfo PARAMS((SearchResponseAPDU* query,char* buffer,long* len));
+extern char* readSearchResponseInfo PARAMS((void** info,char* buffer));
 
-extern char* writePresentInfo _AP((PresentAPDU* present,char* buffer,long* len));
-extern char* readPresentInfo _AP((void** info,char* buffer));
+extern char* writePresentInfo PARAMS((PresentAPDU* present,char* buffer,long* len));
+extern char* readPresentInfo PARAMS((void** info,char* buffer));
 
-extern char* writePresentResponseInfo _AP((PresentResponseAPDU* present,char* buffer,long* len));
-extern char* readPresentResponseInfo _AP((void** info,char* buffer));
+extern char* writePresentResponseInfo PARAMS((PresentResponseAPDU* present,char* buffer,long* len));
+extern char* readPresentResponseInfo PARAMS((void** info,char* buffer));
 
 
 #endif /* HTVMSWAIS_H */
diff --git a/WWW/Library/Implementation/HTWAIS.c b/WWW/Library/Implementation/HTWAIS.c
index cd11af57..81d7239a 100644
--- a/WWW/Library/Implementation/HTWAIS.c
+++ b/WWW/Library/Implementation/HTWAIS.c
@@ -49,7 +49,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>
 #include <HTParse.h>
 #include <HTAccess.h>		/* We implement a protocol */
 #include <HTML.h>		/* The object we will generate */
@@ -78,8 +77,6 @@
 */
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 #define DIRECTORY "/cnidr.org:210/directory-of-servers"
 /* #define DIRECTORY "/quake.think.com:210/directory-of-servers" */
 
diff --git a/WWW/Library/Implementation/HTWAIS.h b/WWW/Library/Implementation/HTWAIS.h
index fe203ef9..e8a6b7f2 100644
--- a/WWW/Library/Implementation/HTWAIS.h
+++ b/WWW/Library/Implementation/HTWAIS.h
@@ -25,9 +25,6 @@
 #ifndef HTWAIS_H
 #define HTWAIS_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTAccess.h>
 
 #ifdef GLOBALREF_IS_MACRO
diff --git a/WWW/Library/Implementation/HTWSRC.c b/WWW/Library/Implementation/HTWSRC.c
index e5a7f830..8b764a73 100644
--- a/WWW/Library/Implementation/HTWSRC.c
+++ b/WWW/Library/Implementation/HTWSRC.c
@@ -9,7 +9,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>
 
 #include <HTWSRC.h>
 
@@ -19,8 +18,6 @@
 
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 #define BIG 10000		/* Arbitrary limit to value length */
 #define PARAM_MAX BIG
 #define CACHE_PERIOD (7*86400)	/* Time to keep .src file in seconds */
diff --git a/WWW/Library/Implementation/HTWSRC.h b/WWW/Library/Implementation/HTWSRC.h
index cde25467..62617022 100644
--- a/WWW/Library/Implementation/HTWSRC.h
+++ b/WWW/Library/Implementation/HTWSRC.h
@@ -11,10 +11,6 @@
 #ifndef HTWSRC_H
 #define HTWSRC_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
-
 #include <HTFormat.h>
 
 extern  char from_hex PARAMS((char c));
diff --git a/WWW/Library/Implementation/HTWriter.c b/WWW/Library/Implementation/HTWriter.c
index c6c88638..c4dba35b 100644
--- a/WWW/Library/Implementation/HTWriter.c
+++ b/WWW/Library/Implementation/HTWriter.c
@@ -2,8 +2,8 @@
 **		===========
 **
 */
+
 #include <HTUtils.h>
-#include <tcp.h>
 
 #include <HTWriter.h>
 
@@ -11,8 +11,6 @@
 
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 /*		HTML Object
 **		-----------
 */
diff --git a/WWW/Library/Implementation/LYLeaks.h b/WWW/Library/Implementation/LYLeaks.h
index 91bfbaac..19fc69f4 100644
--- a/WWW/Library/Implementation/LYLeaks.h
+++ b/WWW/Library/Implementation/LYLeaks.h
@@ -41,7 +41,6 @@
 /*
 **  Required includes
 */
-#include <stdlib.h>
 #include <HTUtils.h>
 
 /*
diff --git a/WWW/Library/Implementation/LYexit.h b/WWW/Library/Implementation/LYexit.h
index 93bc8070..f53561a4 100644
--- a/WWW/Library/Implementation/LYexit.h
+++ b/WWW/Library/Implementation/LYexit.h
@@ -19,7 +19,6 @@
 /*
  *	Required includes
  */
-#include <stdlib.h>
 #include <HTUtils.h>
 
 /*
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index 051885e0..884f6d79 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -10,7 +10,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>		/* For FROMASCII */
 
 /* Remove the following to disable the experimental HTML DTD parsing.
    Currently only used in this source file. - kw */
@@ -26,7 +25,6 @@
 #include <UCDefs.h>
 #include <UCAux.h>
 
-#include <ctype.h>
 #include <HTChunk.h>
 
 #include <LYCharSets.h>
@@ -35,8 +33,6 @@
 
 #define INVALID (-1)
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 PUBLIC HTCJKlang HTCJK = NOCJK; 	/* CJK enum value.		*/
 PUBLIC BOOL HTPassEightBitRaw = FALSE;	/* Pass 161-172,174-255 raw.	*/
 PUBLIC BOOL HTPassEightBitNum = FALSE;	/* Pass ^ numeric entities raw. */
diff --git a/WWW/Library/Implementation/SGML.h b/WWW/Library/Implementation/SGML.h
index fd0bf759..22f4bded 100644
--- a/WWW/Library/Implementation/SGML.h
+++ b/WWW/Library/Implementation/SGML.h
@@ -20,9 +20,6 @@
 #ifndef SGML_H
 #define SGML_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* HTUTILS_H */
 #include <HTStream.h>
 #include <HTAnchor.h>
 
diff --git a/WWW/Library/Implementation/UCAux.h b/WWW/Library/Implementation/UCAux.h
index a1e3df46..3b1df229 100644
--- a/WWW/Library/Implementation/UCAux.h
+++ b/WWW/Library/Implementation/UCAux.h
@@ -1,6 +1,8 @@
 #ifndef UCAUX_H
 #define UCAUX_H
 
+#include <HTUtils.h>
+
 extern BOOL UCCanUniTranslateFrom PARAMS((int from));
 extern BOOL UCCanTranslateUniTo PARAMS((int to));
 extern BOOL UCCanTranslateFromTo PARAMS((int from, int to));
diff --git a/WWW/Library/Implementation/UCDefs.h b/WWW/Library/Implementation/UCDefs.h
index ac2dc3bc..8c370338 100644
--- a/WWW/Library/Implementation/UCDefs.h
+++ b/WWW/Library/Implementation/UCDefs.h
@@ -3,6 +3,8 @@
 #ifndef UCDEFS_H
 #define UCDEFS_H
 
+#include <HTUtils.h>
+
 typedef struct _LYUCcharset {
     int UChndl;
     CONST char * MIMEname;
diff --git a/WWW/Library/Implementation/UCMap.h b/WWW/Library/Implementation/UCMap.h
index e634f760..5a8c1210 100644
--- a/WWW/Library/Implementation/UCMap.h
+++ b/WWW/Library/Implementation/UCMap.h
@@ -2,6 +2,8 @@
 #ifndef UCMAP_H
 #define UCMAP_H
 
+#include <HTUtils.h>
+
 typedef long UCode_t;
 
 extern int UCTransUniChar PARAMS((
@@ -43,6 +45,4 @@ extern int UCLYhndl_HTFile_for_unrec;
 
 #define UCTRANS_NOTFOUND (-4)
 
-#define HT_CANNOT_TRANSLATE -4	/* could go into HTUtils.h */
-
 #endif /* UCMAP_H */
diff --git a/WWW/Library/Implementation/crypt.c b/WWW/Library/Implementation/crypt.c
index 1a01711c..3645f63e 100644
--- a/WWW/Library/Implementation/crypt.c
+++ b/WWW/Library/Implementation/crypt.c
@@ -23,9 +23,7 @@
  *
  */
 
-#ifndef HTUTILS_H
 #include <HTUtils.h>
-#endif
 
 #include <ufc-crypt.h>
 
diff --git a/WWW/Library/Implementation/crypt_util.c b/WWW/Library/Implementation/crypt_util.c
index 5d8c710a..91868b75 100644
--- a/WWW/Library/Implementation/crypt_util.c
+++ b/WWW/Library/Implementation/crypt_util.c
@@ -23,9 +23,7 @@
  *
  */
 
-#ifndef HTUTILS_H
 #include <HTUtils.h>
-#endif
 
 #ifndef STATIC
 #define STATIC static
diff --git a/WWW/Library/Implementation/entities.h b/WWW/Library/Implementation/entities.h
index 55ce977b..a6ca7c1d 100644
--- a/WWW/Library/Implementation/entities.h
+++ b/WWW/Library/Implementation/entities.h
@@ -15,6 +15,12 @@
 *	Why keep two structures for entities?  Backward compatibility..
 */
 
+#ifndef ENTITIES_H
+#define ENTITIES_H 1
+
+#include <HTUtils.h>
+#include <SGML.h>
+
 /* UC_entity_info structure is defined in SGML.h.
    This has to be sorted alphabetically (case-sensitive),
    bear this in mind when you add some more entities..  */
@@ -1082,3 +1088,5 @@ static CONST UC_entity_info unicode_entities[] = {
 /* {"scnap",	0x????},  succeeds, not approximately equal to	 # ISOamsn */
 /* {"smid",	0x????},  shortmid				 # ISOamsr */
 };
+
+#endif /* ENTITIES_H */
diff --git a/WWW/Library/Implementation/getline.c b/WWW/Library/Implementation/getline.c
index 4ee2e744..3168b9ec 100644
--- a/WWW/Library/Implementation/getline.c
+++ b/WWW/Library/Implementation/getline.c
@@ -17,14 +17,11 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 /* CHANGED FOR VMS */
-
 /*
  * <getline.c>
  */
 
 #include <HTUtils.h>
-#include <tcp.h>
-#include <stddef.h>
 
 #include <LYLeaks.h>
 
diff --git a/WWW/Library/Implementation/tcp.h b/WWW/Library/Implementation/tcp.h
index 6d4eae6f..5df279ef 100644
--- a/WWW/Library/Implementation/tcp.h
+++ b/WWW/Library/Implementation/tcp.h
@@ -29,10 +29,6 @@
 #ifndef TCP_H
 #define TCP_H
 
-#ifndef HTUTILS_H
-#include <HTUtils.h>
-#endif /* !HTUTILS_H */
-
 /*
 
 Default values
@@ -97,10 +93,11 @@ typedef struct sockaddr_in SockA;  /* See netinet/in.h */
 # endif
 #endif
 
-#ifdef _AIX
+#if defined(_AIX) && !defined(AIX)
 #define AIX
 #endif /* _AIX */
-#ifdef AIX
+
+#if defined(AIX) && !defined(unix)
 #define unix
 #endif /* AIX */
 
@@ -525,8 +522,16 @@ typedef unsigned short mode_t;
 typedef int pid_t;
 #endif /* !pid_t */
 
+#ifndef S_ISLNK
+#define S_ISLNK(m)	(((m) & S_IFMT) == S_IFLNK)
+#endif /* S_ISLNK */
+
+#ifndef S_ISDIR
+#define S_ISDIR(m)	(((m) & S_IFMT) == S_IFDIR)
+#endif /* S_ISDIR */
+
 #ifndef S_ISREG
-#define S_ISREG(m) (((m) & 0170000) == 0100000)
+#define S_ISREG(m)	(((m) & S_IFMT) == S_IFREG)
 #endif /* S_ISREG */
 
 #ifndef WEXITSTATUS