about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2001-04-02 01:02:30 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2001-04-02 01:02:30 -0400
commit8c68f693cc82e6650afff52fe478c0ccde4bc015 (patch)
tree395cb6842d38654cda008ac0524564f59d959392 /WWW/Library/Implementation
parent4bb52da7b05bb0a4331325010be89a0c630f671c (diff)
downloadlynx-snapshots-8c68f693cc82e6650afff52fe478c0ccde4bc015.tar.gz
snapshot of project "lynx", label v2-8-4dev_20
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r--WWW/Library/Implementation/HTAABrow.c117
-rw-r--r--WWW/Library/Implementation/HTAAProt.c62
-rw-r--r--WWW/Library/Implementation/HTAccess.c10
-rw-r--r--WWW/Library/Implementation/HTAnchor.c34
-rw-r--r--WWW/Library/Implementation/HTChunk.c18
-rw-r--r--WWW/Library/Implementation/HTFTP.c2
-rw-r--r--WWW/Library/Implementation/HTFWriter.c4
-rw-r--r--WWW/Library/Implementation/HTFile.c53
-rw-r--r--WWW/Library/Implementation/HTGopher.c2
-rw-r--r--WWW/Library/Implementation/HTGroup.c13
-rw-r--r--WWW/Library/Implementation/HTList.c34
-rw-r--r--WWW/Library/Implementation/HTMIME.c36
-rw-r--r--WWW/Library/Implementation/HTNews.c26
-rw-r--r--WWW/Library/Implementation/HTParse.c30
-rw-r--r--WWW/Library/Implementation/HTRules.c22
-rw-r--r--WWW/Library/Implementation/HTString.c2
-rw-r--r--WWW/Library/Implementation/HTTCP.c15
-rw-r--r--WWW/Library/Implementation/HTTP.c43
-rw-r--r--WWW/Library/Implementation/HTUtils.h11
-rw-r--r--WWW/Library/Implementation/HTVMSUtils.c2
-rw-r--r--WWW/Library/Implementation/HTVMS_WaisUI.c2
-rw-r--r--WWW/Library/Implementation/HTWAIS.c50
-rw-r--r--WWW/Library/Implementation/HTWSRC.c2
-rw-r--r--WWW/Library/Implementation/HTioctl.h11
-rw-r--r--WWW/Library/Implementation/SGML.c2
-rw-r--r--WWW/Library/Implementation/makefile.in109
26 files changed, 352 insertions, 360 deletions
diff --git a/WWW/Library/Implementation/HTAABrow.c b/WWW/Library/Implementation/HTAABrow.c
index 0db66cbb..519030fa 100644
--- a/WWW/Library/Implementation/HTAABrow.c
+++ b/WWW/Library/Implementation/HTAABrow.c
@@ -75,11 +75,11 @@ typedef struct {
     int		portnumber;	/* Port number			*/
     BOOL	IsProxy;	/* Is it a proxy?		*/
     HTList *	setups;		/* List of protection setups	*/
-                                /* on this server; i.e., valid	*/
-                                /* authentication schemes and	*/
-                                /* templates when to use them.	*/
-                                /* This is actually a list of	*/
-                                /* HTAASetup objects.		*/
+				/* on this server; i.e., valid	*/
+				/* authentication schemes and	*/
+				/* templates when to use them.	*/
+				/* This is actually a list of	*/
+				/* HTAASetup objects.		*/
     HTList *	realms;		/* Information about passwords	*/
 } HTAAServer;
 
@@ -90,7 +90,7 @@ typedef struct {
 typedef struct {
     HTAAServer *server;		/* Which server serves this tree	     */
     char *	template;	/* Template for this tree		     */
-    HTList *	valid_schemes;	/* Valid authentic.schemes   		     */
+    HTList *	valid_schemes;	/* Valid authentic.schemes		     */
     HTAssocList**scheme_specifics;/* Scheme specific params		     */
     BOOL	retry;		/* Failed last time -- reprompt (or whatever)*/
 } HTAASetup;
@@ -119,14 +119,14 @@ PRIVATE char *compose_auth_stringResult = NULL;	/* Uuencoded presentation */
 PRIVATE HTList *server_table	= NULL;	/* Browser's info about servers	     */
 PRIVATE char *secret_key	= NULL;	/* Browser's latest secret key       */
 PRIVATE HTAASetup *current_setup= NULL;	/* The server setup we are currently */
-                                        /* talking to			     */
+					/* talking to			     */
 PRIVATE char *current_hostname	= NULL;	/* The server's name and portnumber  */
 PRIVATE int current_portnumber	= 80;	/* where we are currently trying to  */
-                                        /* connect.			     */
-PRIVATE char *current_docname	= NULL;	/* The document's name we are        */
-                                        /* trying to access.		     */
+					/* connect.			     */
+PRIVATE char *current_docname	= NULL; /* The document's name we are	     */
+					/* trying to access.		     */
 PRIVATE char *HTAAForwardAuth	= NULL;	/* Authorization: line to forward    */
-                                        /* (used by gateway httpds)	     */
+					/* (used by gateway httpds)	     */
 PRIVATE HTAASetup *proxy_setup	= NULL;	/* Same as above, but for Proxy -AJL */
 PRIVATE char *proxy_hostname	= NULL;
 PRIVATE char *proxy_docname	= NULL;
@@ -140,10 +140,10 @@ PUBLIC void HTAAForwardAuth_set ARGS2(
 	CONST char *,	scheme_specifics)
 {
     int len = 20 + (scheme_name      ? strlen(scheme_name)      : 0)
-	         + (scheme_specifics ? strlen(scheme_specifics) : 0);
+		 + (scheme_specifics ? strlen(scheme_specifics) : 0);
 
     FREE(HTAAForwardAuth);
-    if (!(HTAAForwardAuth = (char*)calloc(1, sizeof(char) * len)))
+    if ((HTAAForwardAuth = typecallocn(char, len)) == 0)
 	outofmem(__FILE__, "HTAAForwardAuth_set");
 
     strcpy(HTAAForwardAuth, "Authorization: ");
@@ -189,7 +189,7 @@ PRIVATE HTAAServer *HTAAServer_new ARGS3(
 {
     HTAAServer *server;
 
-    if (!(server = (HTAAServer *)calloc(1, sizeof(HTAAServer))))
+    if ((server = typecalloc(HTAAServer)) == 0)
 	outofmem(__FILE__, "HTAAServer_new");
 
     server->hostname	= NULL;
@@ -199,10 +199,10 @@ PRIVATE HTAAServer *HTAAServer_new ARGS3(
     server->realms	= HTList_new();
 
     if (hostname)
-        StrAllocCopy(server->hostname, hostname);
+	StrAllocCopy(server->hostname, hostname);
 
     if (!server_table)
-        server_table = HTList_new();
+	server_table = HTList_new();
 
     HTList_addObject(server_table, (void*)server);
 
@@ -233,8 +233,8 @@ PRIVATE void HTAAServer_delete ARGS1(
 	if (killme->setups != NULL) {
 	    n = HTList_count(killme->setups);
 	    for (i = (n - 1); i >= 0; i--) {
-	        if ((setup = (HTAASetup*)HTList_objectAt(killme->setups,
-	     						 i)) != NULL) {
+		if ((setup = (HTAASetup*)HTList_objectAt(killme->setups,
+							 i)) != NULL) {
 		    HTAASetup_delete(setup);
 		    setup = NULL;
 		}
@@ -310,7 +310,7 @@ PRIVATE HTAAServer *HTAAServer_lookup ARGS3(
 **			are trying to access.
 **	IsProxy		should be TRUE if this is a proxy.
 **
-** 	This function goes through the information known about
+**	This function goes through the information known about
 **	all the setups of the server, and finds out if the given
 **	filename resides in one of the protected directories.
 **
@@ -331,7 +331,7 @@ PRIVATE HTAASetup *HTAASetup_lookup ARGS4(
     HTAASetup *setup;
 
     if (portnumber <= 0)
-        portnumber = 80;
+	portnumber = 80;
 
     if (hostname && docname && *hostname && *docname &&
 	NULL != (server = HTAAServer_lookup(hostname,
@@ -352,7 +352,7 @@ PRIVATE HTAASetup *HTAASetup_lookup ARGS4(
 			    "matched template", setup->template));
 		return setup;
 	    } else {
-	        CTRACE((tfp, "%s `%s' %s `%s'\n",
+		CTRACE((tfp, "%s `%s' %s `%s'\n",
 			    "HTAASetup_lookup:", docname,
 			    "did NOT match template", setup->template));
 	    }
@@ -395,16 +395,16 @@ PRIVATE HTAASetup *HTAASetup_new ARGS4(
     HTAASetup *setup;
 
     if (!server || !template || !*template)
-        return NULL;
+	return NULL;
 
-    if (!(setup = (HTAASetup*)calloc(1, sizeof(HTAASetup))))
+    if ((setup = typecalloc(HTAASetup)) == 0)
 	outofmem(__FILE__, "HTAASetup_new");
 
     setup->retry = NO;
     setup->server = server;
     setup->template = NULL;
     if (template)
-        StrAllocCopy(setup->template, template);
+	StrAllocCopy(setup->template, template);
     setup->valid_schemes = valid_schemes;
     setup->scheme_specifics = scheme_specifics;
 
@@ -474,7 +474,7 @@ PRIVATE void HTAASetup_updateSpecifics ARGS2(
 
 /*************************** HTAARealm **********************************/
 
-/* PRIVATE 						HTAARealm_lookup()
+/* PRIVATE						HTAARealm_lookup()
 **		LOOKUP HTAARealm STRUCTURE BY REALM NAME
 ** ON ENTRY:
 **	realm_table	a list of realm objects.
@@ -525,7 +525,7 @@ PRIVATE HTAARealm *HTAARealm_new ARGS4(
     realm = HTAARealm_lookup(realm_table, realmname);
 
     if (!realm) {
-	if (!(realm = (HTAARealm*)calloc(1, sizeof(HTAARealm))))
+	if ((realm = typecalloc(HTAARealm)) == 0)
 	    outofmem(__FILE__, "HTAARealm_new");
 	realm->realmname = NULL;
 	realm->username = NULL;
@@ -535,9 +535,9 @@ PRIVATE HTAARealm *HTAARealm_new ARGS4(
 	    HTList_addObject(realm_table, (void*)realm);
     }
     if (username)
-        StrAllocCopy(realm->username, username);
+	StrAllocCopy(realm->username, username);
     if (password)
-        StrAllocCopy(realm->password, password);
+	StrAllocCopy(realm->password, password);
 
     return realm;
 }
@@ -595,11 +595,11 @@ PRIVATE char *compose_auth_string ARGS3(
 
     realmname = HTAssocList_lookup(setup->scheme_specifics[scheme], "realm");
     if (!realmname)
-        return NULL;
+	return NULL;
 
     realm = HTAARealm_lookup(setup->server->realms, realmname);
     if (!(realm &&
-    	  realm->username && *realm->username &&
+	  realm->username && *realm->username &&
 	  realm->password) || setup->retry) {
 	if (!realm) {
 	    CTRACE((tfp, "%s `%s' %s\n",
@@ -621,7 +621,7 @@ PRIVATE char *compose_auth_string ARGS3(
 	if ((!IsProxy) && using_proxy && setup->template) {
 	    proxiedHost = HTParse(setup->template, "", PARSE_HOST);
 	    if (proxiedHost && *proxiedHost != '\0') {
-	        theHost = proxiedHost;
+		theHost = proxiedHost;
 	    }
 	}
 	/*
@@ -644,7 +644,7 @@ PRIVATE char *compose_auth_string ARGS3(
 	 */
 	len = strlen(realm->realmname) +
 	      strlen(theHost ?
-	      	     theHost : "??") + 50;
+		     theHost : "??") + 50;
 	HTSprintf0(&msg, gettext("Username for '%s' at %s '%s%s':"),
 		     realm->realmname,
 		     (IsProxy ? "proxy" : "server"),
@@ -690,18 +690,18 @@ PRIVATE char *compose_auth_string ARGS3(
 	FREE(secret_key);
     }
 
-    if (!(cleartext  = (char*)calloc(1, sizeof(char) * len)))
+    if ((cleartext = typecallocn(char, len)) == 0)
 	outofmem(__FILE__, "compose_auth_string");
 
     if (realm->username)
-        strcpy(cleartext, realm->username);
+	strcpy(cleartext, realm->username);
     else
-        *cleartext = '\0';
+	*cleartext = '\0';
 
     strcat(cleartext, ":");
 
     if (realm->password)
-        strcat(cleartext, realm->password);
+	strcat(cleartext, realm->password);
 
     if (scheme == HTAA_PUBKEY) {
 	strcat(cleartext, ":");
@@ -712,9 +712,8 @@ PRIVATE char *compose_auth_string ARGS3(
 	if (secret_key)
 	    strcat(cleartext, secret_key);
 
-	if (!((ciphertext = (char *)calloc(1, (sizeof(char) * 2) * len)) &&
-	      (compose_auth_stringResult =
-	      		    (char *)calloc(1, (sizeof(char) * 3) * len))))
+	if (!((ciphertext = typecallocn(char, 2 * len)) &&
+	      (compose_auth_stringResult = typecallocn(char, 3 * len))))
 	    outofmem(__FILE__, "compose_auth_string");
 #ifdef PUBKEY
 	HTPK_encrypt(cleartext, ciphertext, server->public_key);
@@ -726,7 +725,7 @@ PRIVATE char *compose_auth_string ARGS3(
     }
     else { /* scheme == HTAA_BASIC */
 	if (!(compose_auth_stringResult =
-				(char*)calloc(1, (4 * ((len+2)/3)) + 1)))
+				typecallocn(char, (4 * ((len+2)/3)) + 1)))
 	    outofmem(__FILE__, "compose_auth_string");
 	HTUU_encode((unsigned char *)cleartext, strlen(cleartext),
 		    compose_auth_stringResult);
@@ -781,11 +780,11 @@ PRIVATE void free_HTAAGlobals NOARGS
     int n, i;
 
     if (server_table != NULL) {
-        n = HTList_count(server_table);
+	n = HTList_count(server_table);
 	for (i = (n - 1); i >= 0; i--) {
 	    if ((server = (HTAAServer*)HTList_objectAt(server_table,
-	     						i)) != NULL) {
-	        HTAAServer_delete(server);
+							i)) != NULL) {
+		HTAAServer_delete(server);
 		server = NULL;
 	    }
 	}
@@ -839,7 +838,7 @@ PUBLIC char *HTAA_composeAuth ARGS4(
     */
     if (!free_HTAAGlobalsSet) {
 #ifdef LY_FIND_LEAKS
-        atexit(free_HTAAGlobals);
+	atexit(free_HTAAGlobals);
 #endif
 	free_HTAAGlobalsSet = TRUE;
     }
@@ -864,15 +863,15 @@ PUBLIC char *HTAA_composeAuth ARGS4(
     FREE(HTAA_composeAuthResult);	/* From previous call */
 
     if (IsProxy) {
-        /*
+	/*
 	**  Proxy Authorization required. - AJL
 	*/
 
 	CTRACE((tfp, "Composing Proxy Authorization for %s:%d/%s\n",
 		    hostname, portnumber, docname));
 
-	if (proxy_portnumber != portnumber ||
-	    !proxy_hostname || !proxy_docname ||
+	if (proxy_portnumber  != portnumber       ||
+	    !proxy_hostname   || !proxy_docname   ||
 	    !hostname         || !docname         ||
 	    0 != strcmp(proxy_hostname, hostname) ||
 	    0 != strcmp(proxy_docname, docname)) {
@@ -901,7 +900,7 @@ PUBLIC char *HTAA_composeAuth ARGS4(
 	if (!proxy_setup)
 	    return NULL;
 
-    	switch (scheme = HTAA_selectScheme(proxy_setup)) {
+	switch (scheme = HTAA_selectScheme(proxy_setup)) {
 	  case HTAA_BASIC:
 	  case HTAA_PUBKEY:
 	    auth_string = compose_auth_string(scheme, proxy_setup, IsProxy);
@@ -935,7 +934,7 @@ PUBLIC char *HTAA_composeAuth ARGS4(
 	    return(HTAA_composeAuthResult);
 	}
 	len = strlen(auth_string) + strlen((char *)HTAAScheme_name(scheme)) + 26;
-	if (!(HTAA_composeAuthResult = (char*)calloc(1, sizeof(char) * len)))
+	if ((HTAA_composeAuthResult = typecallocn(char, len)) == 0)
 	    outofmem(__FILE__, "HTAA_composeAuth");
 	strcpy(HTAA_composeAuthResult, "Proxy-Authorization: ");
 
@@ -1011,7 +1010,7 @@ PUBLIC char *HTAA_composeAuth ARGS4(
 	}
 
 	len = strlen(auth_string) + strlen((char *)HTAAScheme_name(scheme)) + 20;
-	if (!(HTAA_composeAuthResult = (char*)calloc(1, sizeof(char) * len)))
+	if ((HTAA_composeAuthResult = typecallocn(char, len)) == 0)
 	    outofmem(__FILE__, "HTAA_composeAuth");
 	strcpy(HTAA_composeAuthResult, "Authorization: ");
     }
@@ -1069,7 +1068,7 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4(
     */
     if (!free_HTAAGlobalsSet) {
 #ifdef LY_FIND_LEAKS
-        atexit(free_HTAAGlobals);
+	atexit(free_HTAAGlobals);
 #endif
 	free_HTAAGlobalsSet = TRUE;
     }
@@ -1092,9 +1091,9 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4(
 
 	    if ((IsProxy &&
 		 0==strcasecomp(fieldname, "Proxy-Authenticate:")) ||
-	        (!IsProxy &&
+		(!IsProxy &&
 		 0==strcasecomp(fieldname, "WWW-Authenticate:"))) {
-	        if (!(arg1 && *arg1 && args && *args)) {
+		if (!(arg1 && *arg1 && args && *args)) {
 		    HTSprintf0(&temp, gettext("Invalid header '%s%s%s%s%s'"), line,
 				  ((arg1 && *arg1) ? " "  : ""),
 				  ((arg1 && *arg1) ? arg1 : ""),
@@ -1107,8 +1106,8 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4(
 		    HTList_addObject(valid_schemes, (void*)scheme);
 		    if (!scheme_specifics) {
 			int i;
-			scheme_specifics = (HTAssocList**)
-			    calloc(1, HTAA_MAX_SCHEMES * sizeof(HTAssocList*));
+			scheme_specifics =
+			    typecallocn(HTAssocList *, HTAA_MAX_SCHEMES);
 			if (!scheme_specifics)
 			    outofmem(__FILE__, "HTAA_shouldRetryWithAuth");
 			for (i=0; i < HTAA_MAX_SCHEMES; i++)
@@ -1152,7 +1151,7 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4(
 	    proxy_setup = NULL;
 	    return NO;
 	}
-        /*
+	/*
 	**  Doing it for proxy.  -AJL
 	*/
 	if (proxy_setup && proxy_setup->server) {
@@ -1170,7 +1169,7 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4(
 		proxy_setup = NULL;
 		return NO;
 	    } else {
-	        /*
+		/*
 		**  Re-ask username+password (if misspelled).
 		*/
 		proxy_setup->retry = YES;
@@ -1236,7 +1235,7 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4(
 	    return YES;
 	}
     } else {
-        /*
+	/*
 	**  current_setup == NULL, i.e., we have a
 	**  first connection to a protected server or
 	**  the server serves a wider set of documents
@@ -1258,7 +1257,7 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4(
 				      scheme_specifics);
 	FREE(template);
 
-        HTAlert(gettext("Access without authorization denied -- retrying"));
+	HTAlert(gettext("Access without authorization denied -- retrying"));
 	return YES;
     }
     /* Never reached */
diff --git a/WWW/Library/Implementation/HTAAProt.c b/WWW/Library/Implementation/HTAAProt.c
index 24907b84..1e83df8f 100644
--- a/WWW/Library/Implementation/HTAAProt.c
+++ b/WWW/Library/Implementation/HTAAProt.c
@@ -30,6 +30,7 @@
 #include <HTLex.h>	/* Lexical analysor	*/
 #include <HTAAProt.h>	/* Implemented here	*/
 
+#include <LYUtils.h>
 #include <LYLeaks.h>
 
 #define NOBODY    65534	/* -2 in 16-bit environment */
@@ -46,9 +47,9 @@ typedef struct {
 PRIVATE HTList *  prot_cache	= NULL;	/* Protection setup cache.	*/
 PRIVATE HTAAProt *default_prot	= NULL;	/* Default protection.		*/
 PRIVATE HTAAProt *current_prot	= NULL;	/* Current protection mode	*/
-                                        /* which is set up by callbacks	*/
-                                        /* from the rule system when	*/
-                                        /* a "protect" rule is matched.	*/
+					/* which is set up by callbacks */
+					/* from the rule system when	*/
+					/* a "protect" rule is matched. */
 
 #ifndef NOUSERS
 /* PRIVATE							isNumber()
@@ -86,7 +87,7 @@ PRIVATE BOOL isNumber ARGS1(CONST char *, s)
 PUBLIC char * HTAA_getUidName NOARGS
 {
     if (current_prot && current_prot->uid_name
-                  && (0 != strcmp(current_prot->uid_name,"nobody")) )
+		  && (0 != strcmp(current_prot->uid_name,"nobody")) )
        return(current_prot->uid_name);
     else
        return("");
@@ -257,8 +258,8 @@ PRIVATE void HTAA_parseProtFile ARGS2(HTAAProt *, prot,
 
 		if (LEX_FIELD_SEP != (lex_item = lex(fp)))
 		    unlex(lex_item);	/* If someone wants to use colon */
-		                        /* after field name it's ok, but */
-		                        /* not required. Here we read it.*/
+					/* after field name it's ok, but */
+					/* not required. Here we read it.*/
 
 		if (0==strncasecomp(fieldname, "Auth", 4)) {
 		    lex_item = lex(fp);
@@ -269,9 +270,9 @@ PRIVATE void HTAA_parseProtFile ARGS2(HTAAProt *, prot,
 				prot->valid_schemes = HTList_new();
 			    HTList_addObject(prot->valid_schemes,(void*)scheme);
 			    CTRACE((tfp, "%s %s `%s'\n",
-				        "HTAA_parseProtFile: valid",
-				        "authentication scheme:",
-				        HTAAScheme_name(scheme)));
+					"HTAA_parseProtFile: valid",
+					"authentication scheme:",
+					HTAAScheme_name(scheme)));
 			} else {
 			    CTRACE((tfp, "%s %s `%s'\n",
 					"HTAA_parseProtFile: unknown",
@@ -384,7 +385,7 @@ PRIVATE HTAAProt *HTAAProt_new ARGS3(CONST char *,	cur_docname,
 	CTRACE((tfp, "HTAAProt_new: Loading protection file `%s'\n",
 		    prot_filename));
 
-	if (!(prot = (HTAAProt*)calloc(1, sizeof(HTAAProt))))
+	if ((prot = typecalloc(HTAAProt)) == 0)
 	    outofmem(__FILE__, "HTAAProt_new");
 
 	prot->template	= NULL;
@@ -395,11 +396,10 @@ PRIVATE HTAAProt *HTAAProt_new ARGS3(CONST char *,	cur_docname,
 	prot->mask_group= NULL;		/* Masking disabled by defaults */
 	prot->values	= HTAssocList_new();
 
-	if (prot_filename && NULL != (fp = fopen(prot_filename, "r"))) {
+	if (prot_filename && NULL != (fp = fopen(prot_filename, TXT_R))) {
 	    HTAA_parseProtFile(prot, fp);
 	    fclose(fp);
-	    if (!(cache_item =
-	    		(HTAAProtCache*)calloc(1, sizeof(HTAAProtCache))))
+	    if ((cache_item = typecalloc(HTAAProtCache)) == 0)
 		outofmem(__FILE__, "HTAAProt_new");
 	    cache_item->prot = prot;
 	    cache_item->prot_filename = NULL;
@@ -487,14 +487,14 @@ PUBLIC void HTAA_setCurrentProtection ARGS3(CONST char *,	cur_docname,
 	    current_prot = default_prot;
 	    HTAA_setIds(current_prot, ids);
 	    CTRACE((tfp, "%s %s %s\n",
-		        "HTAA_setCurrentProtection: Protection file",
-		        "not specified for Protect rule",
-		        "-- using default protection"));
+			"HTAA_setCurrentProtection: Protection file",
+			"not specified for Protect rule",
+			"-- using default protection"));
 	} else {
 	    CTRACE((tfp, "%s %s %s\n",
-		        "HTAA_setCurrentProtection: ERROR: Protection",
-		        "file not specified for Protect rule, and",
-		        "default protection is not set!!"));
+			"HTAA_setCurrentProtection: ERROR: Protection",
+			"file not specified for Protect rule, and",
+			"default protection is not set!!"));
 	}
     }
 }
@@ -571,9 +571,9 @@ PUBLIC void HTAA_clearProtections NOARGS
 }
 
 typedef struct {
-    	char *name;
+	char *name;
 	int user;
-    	} USER_DATA;
+	} USER_DATA;
 
 PRIVATE HTList *known_grp = NULL;
 PRIVATE HTList *known_pwd = NULL;
@@ -603,7 +603,7 @@ PRIVATE void clear_uidgid_cache NOARGS
 #ifndef NOUSERS
 PRIVATE void save_gid_info ARGS2(char *, name, int, user)
 {
-    USER_DATA *data = (USER_DATA *)calloc(1, sizeof(USER_DATA));
+    USER_DATA *data = typecalloc(USER_DATA);
     if (!data)
 	return;
     if (!known_grp) {
@@ -624,7 +624,7 @@ PRIVATE void save_gid_info ARGS2(char *, name, int, user)
 #ifndef NOUSERS
 PRIVATE void save_uid_info ARGS2(char *, name, int, user)
 {
-    USER_DATA *data = (USER_DATA *)calloc(1, sizeof(USER_DATA));
+    USER_DATA *data = typecalloc(USER_DATA);
     if (!data)
 	return;
     if (!known_pwd) {
@@ -642,8 +642,8 @@ PRIVATE void save_uid_info ARGS2(char *, name, int, user)
 }
 #endif /* !NOUSERS */
 
-/* PUBLIC                                                       HTAA_UidToName
-**              GET THE USER NAME
+/* PUBLIC							HTAA_UidToName
+**		GET THE USER NAME
 ** ON ENTRY:
 **      The user-id
 **
@@ -675,8 +675,8 @@ PUBLIC char * HTAA_UidToName ARGS1(int, uid)
     return "";
 }
 
-/* PUBLIC                                                       HTAA_NameToUid
-**              GET THE USER ID
+/* PUBLIC							HTAA_NameToUid
+**		GET THE USER ID
 ** ON ENTRY:
 **      The user-name
 **
@@ -707,8 +707,8 @@ PUBLIC int HTAA_NameToUid ARGS1(char *, name)
     return NONESUCH;
 }
 
-/* PUBLIC                                                       HTAA_GidToName
-**              GET THE GROUP NAME
+/* PUBLIC							HTAA_GidToName
+**		GET THE GROUP NAME
 ** ON ENTRY:
 **      The group-id
 **
@@ -740,8 +740,8 @@ PUBLIC char * HTAA_GidToName ARGS1(int, gid)
     return "";
 }
 
-/* PUBLIC                                                       HTAA_NameToGid
-**              GET THE GROUP ID
+/* PUBLIC							HTAA_NameToGid
+**		GET THE GROUP ID
 ** ON ENTRY:
 **      The group-name
 **
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index 86a3bf9e..e1bba633 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -1244,7 +1244,7 @@ PUBLIC BOOL HTSearch ARGS2(
     CONST char * p, *s, *e;		/* Pointers into keywords */
     char * address = NULL;
     BOOL result;
-    char * escaped = (char *)calloc(1, ((strlen(keywords)*3) + 1));
+    char * escaped = typecallocn(char, (strlen(keywords)*3) + 1);
     static CONST BOOL isAcceptable[96] =
 
     /*	 0 1 2 3 4 5 6 7 8 9 A B C D E F */
@@ -1360,10 +1360,10 @@ PUBLIC HTParentAnchor * HTHomeAnchor NOARGS
 	/*
 	**  Someone telnets in, they get a special home.
 	*/
-	FILE * fp = fopen(REMOTE_POINTER, "r");
+	FILE * fp = fopen(REMOTE_POINTER, TXT_R);
 	char * status;
 	if (fp) {
-	    my_home_document = (char*)calloc(1, MAX_FILE_NAME);
+	    my_home_document = typecallocn(char, MAX_FILE_NAME);
 	    if (my_home_document == NULL)
 		outofmem(__FILE__, "HTHomeAnchor");
 	    status = fgets(my_home_document, MAX_FILE_NAME, fp);
@@ -1382,12 +1382,12 @@ PUBLIC HTParentAnchor * HTHomeAnchor NOARGS
 	CONST char * home =  (CONST char*)getenv("HOME");
 	if (home != null) {
 	    HTSprintf0(&my_home_document, "%s/%s", home, PERSONAL_DEFAULT);
-	    fp = fopen(my_home_document, "r");
+	    fp = fopen(my_home_document, TXT_R);
 	}
 
 	if (!fp) {
 	    StrAllocCopy(my_home_document, LOCAL_DEFAULT_FILE);
-	    fp = fopen(my_home_document, "r");
+	    fp = fopen(my_home_document, TXT_R);
 	}
 	if (fp) {
 	    fclose(fp);
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index 976679df..8656c4ac 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -67,12 +67,11 @@ PRIVATE HTList **adult_table = 0;  /* Point to table of lists of all parents */
 */
 PRIVATE HTParentAnchor * HTParentAnchor_new NOARGS
 {
-    HTParentAnchor *newAnchor =
-       (HTParentAnchor *)calloc(1, sizeof(HTParentAnchor));  /* zero-filled */
+    HTParentAnchor *newAnchor = typecalloc(HTParentAnchor);
     if (newAnchor == NULL)
 	outofmem(__FILE__, "HTParentAnchor_new");
     newAnchor->parent = newAnchor;
-    newAnchor->bookmark = NULL; 	/* Bookmark filename. - FM */
+    newAnchor->bookmark = NULL;		/* Bookmark filename. - FM */
     newAnchor->isISMAPScript = FALSE;	/* Lynx appends ?0,0 if TRUE. - FM */
     newAnchor->isHEAD = FALSE;		/* HEAD request if TRUE. - FM */
     newAnchor->safe = FALSE;		/* Safe. - FM */
@@ -81,9 +80,9 @@ PRIVATE HTParentAnchor * HTParentAnchor_new NOARGS
     newAnchor->source_cache_chunk = NULL;
 #endif
     newAnchor->FileCache = NULL;	/* Path to a disk-cached copy. - FM */
-    newAnchor->SugFname = NULL; 	/* Suggested filename. - FM */
-    newAnchor->RevTitle = NULL; 	/* TITLE for a LINK with REV. - FM */
-    newAnchor->citehost = NULL; 	/* LINK REL=citehost - RDC */
+    newAnchor->SugFname = NULL;		/* Suggested filename. - FM */
+    newAnchor->RevTitle = NULL;		/* TITLE for a LINK with REV. - FM */
+    newAnchor->citehost = NULL;		/* LINK REL=citehost - RDC */
     newAnchor->cache_control = NULL;	/* Cache-Control. - FM */
     newAnchor->no_cache = FALSE;	/* no-cache? - FM */
     newAnchor->content_type = NULL;	/* Content-Type. - FM */
@@ -106,7 +105,7 @@ PRIVATE HTChildAnchor * HTChildAnchor_new NOARGS
 {
     HTChildAnchor *p;
 
-    p = (HTChildAnchor *)calloc(1, sizeof(HTChildAnchor)); /* zero-filled */
+    p = typecalloc(HTChildAnchor);
     if (p == NULL)
 	outofmem(__FILE__, "HTChildAnchor_new");
     return p;
@@ -135,7 +134,7 @@ PRIVATE BOOL HTEquivalent ARGS2(
 	}
 	return( TOUPPER(*s) == TOUPPER(*t));
     } else {
-	return(s == t); 	/* Two NULLs are equivalent, aren't they ? */
+	return(s == t);		/* Two NULLs are equivalent, aren't they ? */
     }
 }
 
@@ -389,7 +388,7 @@ PUBLIC HTAnchor * HTAnchor_findAddress ARGS1(
 	*/
 	hash = HASH_FUNCTION(newdoc->address);
 	if (!adult_table) {
-	    adult_table = (HTList **)calloc(HASH_SIZE, sizeof(HTList *));
+	    adult_table = typecallocn(HTList *, HASH_SIZE);
 	    if (!adult_table)
 		outofmem(__FILE__, "HTAnchor_findAddress");
 #ifdef LY_FIND_LEAKS
@@ -750,7 +749,7 @@ PUBLIC BOOL HTAnchor_delete ARGS1(
 #endif
     if (me->FileCache) {
 	FILE *fd;
-	if ((fd = fopen(me->FileCache, "r")) != NULL) {
+	if ((fd = fopen(me->FileCache, TXT_R)) != NULL) {
 	    fclose(fd);
 	    remove(me->FileCache);
 	}
@@ -885,7 +884,7 @@ PUBLIC HTFormat HTAnchor_format ARGS1(
 
 PUBLIC void HTAnchor_setIndex ARGS2(
 	HTParentAnchor *,	me,
-	char *, 		address)
+	char *,			address)
 {
     if (me) {
 	me->isIndex = YES;
@@ -895,7 +894,7 @@ PUBLIC void HTAnchor_setIndex ARGS2(
 
 PUBLIC void HTAnchor_setPrompt ARGS2(
 	HTParentAnchor *,	me,
-	char *, 		prompt)
+	char *,			prompt)
 {
     if (me) {
 	StrAllocCopy(me->isIndexPrompt, prompt);
@@ -1201,7 +1200,7 @@ PUBLIC BOOL HTAnchor_link ARGS3(
 	source->mainLink.dest = destination;
 	source->mainLink.type = type;
     } else {
-	HTLink * newLink = (HTLink *)calloc (1, sizeof (HTLink));
+	HTLink * newLink = typecalloc(HTLink);
 	if (newLink == NULL)
 	    outofmem(__FILE__, "HTAnchor_link");
 	newLink->dest = destination;
@@ -1256,7 +1255,7 @@ PUBLIC BOOL HTAnchor_makeMainLink ARGS2(
 	return(NO);  /* link not found or NULL anchor */
     } else {
 	/* First push current main link onto top of links list */
-	HTLink *newLink = (HTLink *)calloc (1, sizeof (HTLink));
+	HTLink *newLink = typecalloc(HTLink);
 	if (newLink == NULL)
 	    outofmem(__FILE__, "HTAnchor_makeMainLink");
 	memcpy((void *)newLink,
@@ -1311,7 +1310,7 @@ PUBLIC char * HTAnchor_physical ARGS1(
 
 PUBLIC void HTAnchor_setPhysical ARGS2(
 	HTParentAnchor *,	me,
-	char *, 		physical)
+	char *,			physical)
 {
     if (me) {
 	StrAllocCopy(me->physical, physical);
@@ -1349,8 +1348,7 @@ PUBLIC LYUCcharset * HTAnchor_getUCInfoStage ARGS2(
     if (me && !me->UCStages) {
 	int i;
 	int chndl = UCLYhndl_for_unspec;  /* always >= 0 */
-	UCAnchorInfo * stages = (UCAnchorInfo*)calloc(1,
-						      sizeof(UCAnchorInfo));
+	UCAnchorInfo * stages = typecalloc(UCAnchorInfo);
 	if (stages == NULL)
 	    outofmem(__FILE__, "HTAnchor_getUCInfoStage");
 	for (i = 0; i < UCT_STAGEMAX; i++) {
@@ -1504,7 +1502,7 @@ PUBLIC LYUCcharset * HTAnchor_copyUCInfoStage ARGS4(
 	    if ( me->UCStages->s[to_stage].LYhndl >= 0
 		 && me->UCStages->s[to_stage].LYhndl != ohandle
 		 && to_stage == UCT_STAGE_PARSER )
-		setup_switch_display_charset(me, 
+		setup_switch_display_charset(me,
 					     me->UCStages->s[to_stage].LYhndl);
 #endif
 	    if (p_to != p_from)
diff --git a/WWW/Library/Implementation/HTChunk.c b/WWW/Library/Implementation/HTChunk.c
index fc9288da..cce9058c 100644
--- a/WWW/Library/Implementation/HTChunk.c
+++ b/WWW/Library/Implementation/HTChunk.c
@@ -13,7 +13,7 @@
 */
 PUBLIC HTChunk * HTChunkCreate ARGS1 (int,grow)
 {
-    HTChunk * ch = (HTChunk *) calloc(1, sizeof(HTChunk));
+    HTChunk * ch = typecalloc(HTChunk);
     if (ch == NULL)
 	outofmem(__FILE__, "creation of chunk");
 
@@ -25,7 +25,7 @@ PUBLIC HTChunk * HTChunkCreate ARGS1 (int,grow)
 }
 PUBLIC HTChunk * HTChunkCreateMayFail ARGS2 (int,grow, int,failok)
 {
-    HTChunk * ch = (HTChunk *) calloc(1, sizeof(HTChunk));
+    HTChunk * ch = typecalloc(HTChunk);
     if (ch == NULL) {
 	if (!failok) {
 	    outofmem(__FILE__, "creation of chunk");
@@ -46,7 +46,7 @@ PUBLIC HTChunk * HTChunkCreateMayFail ARGS2 (int,grow, int,failok)
 */
 PUBLIC HTChunk * HTChunkCreate2 ARGS2 (int,grow, size_t, needed)
 {
-    HTChunk * ch = (HTChunk *) calloc(1, sizeof(HTChunk));
+    HTChunk * ch = typecalloc(HTChunk);
     if (ch == NULL)
 	outofmem(__FILE__, "HTChunkCreate2");
 
@@ -56,7 +56,7 @@ PUBLIC HTChunk * HTChunkCreate2 ARGS2 (int,grow, size_t, needed)
 	    + ch->growby; /* Round up */
 	CTRACE((tfp, "HTChunkCreate2: requested %d, allocate %d\n",
 	       needed, ch->allocated));
-	ch->data = (char *)calloc(1, ch->allocated);
+	ch->data = typecallocn(char, ch->allocated);
 	if (!ch->data)
 	    outofmem(__FILE__, "HTChunkCreate2 data");
     }
@@ -97,7 +97,7 @@ PUBLIC void HTChunkPutc ARGS2 (HTChunk *,ch, char,c)
 	char *data;
 	ch->allocated = ch->allocated + ch->growby;
 	data = ch->data ? (char *)realloc(ch->data, ch->allocated)
-			: (char *)calloc(1, ch->allocated);
+			: typecallocn(char, ch->allocated);
 	if (data) {
 	    ch->data = data;
 	} else if (ch->failok) {
@@ -120,7 +120,7 @@ PUBLIC void HTChunkEnsure ARGS2 (HTChunk *,ch, int,needed)
     ch->allocated = needed-1 - ((needed-1) % ch->growby)
 			     + ch->growby; /* Round up */
     ch->data = ch->data ? (char *)realloc(ch->data, ch->allocated)
-			: (char *)calloc(1, ch->allocated);
+			: typecallocn(char, ch->allocated);
     if (ch->data == NULL)
 	outofmem(__FILE__, "HTChunkEnsure");
 }
@@ -134,7 +134,7 @@ PUBLIC void HTChunkPutb ARGS3 (HTChunk *,ch, CONST char *,b, int,l)
 	ch->allocated = needed-1 - ((needed-1) % ch->growby)
 	    + ch->growby; /* Round up */
 	data = ch->data ? (char *)realloc(ch->data, ch->allocated)
-			: (char *)calloc(1, ch->allocated);
+			: typecallocn(char, ch->allocated);
 	if (data) {
 	    ch->data = data;
 	} else if (ch->failok) {
@@ -157,7 +157,7 @@ PUBLIC void HTChunkPutUtf8Char ARGS2(
 {
     int utflen;
 
-    if (code < 128)
+    if (TOASCII(code) < 128)
 	utflen = 1;
     else if   (code <     0x800L) {
 	utflen = 2;
@@ -177,7 +177,7 @@ PUBLIC void HTChunkPutUtf8Char ARGS2(
 	int growby = (ch->growby >= utflen) ? ch->growby : utflen;
 	ch->allocated = ch->allocated + growby;
 	data = ch->data ? (char *)realloc(ch->data, ch->allocated)
-			: (char *)calloc(1, ch->allocated);
+			: typecallocn(char, ch->allocated);
 	if (data) {
 	    ch->data = data;
 	} else if (ch->failok) {
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index 8f68cf6b..a580925f 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -718,7 +718,7 @@ PRIVATE int get_connection ARGS2(
 	/*
 	**  Allocate and init control struct.
 	*/
-	con = (connection *)calloc(1, sizeof(connection));
+	con = typecalloc(connection);
 	if (con == NULL)
 	    outofmem(__FILE__, "get_connection");
     }
diff --git a/WWW/Library/Implementation/HTFWriter.c b/WWW/Library/Implementation/HTFWriter.c
index b5666b44..b8b0c5d9 100644
--- a/WWW/Library/Implementation/HTFWriter.c
+++ b/WWW/Library/Implementation/HTFWriter.c
@@ -256,7 +256,7 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3(
     tmpnam (fnam);
     strcat(fnam, suffix);
 
-    me->fp = fopen (fnam, "wb");
+    me->fp = fopen (fnam, BIN_W);
     if (!me->fp) {
 	HTAlert(CANNOT_OPEN_TEMP);
         FREE(fnam);
@@ -333,7 +333,7 @@ PUBLIC HTStream* HTSaveLocally ARGS3(
 
     FREE(fnam);
 
-    me->fp = fopen (answer, "wb");
+    me->fp = fopen (answer, BIN_W);
     if (!me->fp) {
 	HTAlert(CANNOT_OPEN_OUTPUT);
         FREE(answer);
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 0fbbbde7..342a5882 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -472,7 +472,7 @@ PUBLIC void HTSetSuffix5 ARGS5(
 		break;
 	}
 	if (!suff) { /* Not found -- create a new node */
-	    suff = (HTSuffix *) calloc(1, sizeof(HTSuffix));
+	    suff = typecalloc(HTSuffix);
 	    if (suff == NULL)
 		outofmem(__FILE__, "HTSetSuffix");
 
@@ -1301,7 +1301,7 @@ PUBLIC HTStream * HTFileSaveStream ARGS1(
     CONST char * addr = HTAnchor_address((HTAnchor*)anchor);
     char *  localname = HTLocalName(addr);
 
-    FILE* fp = fopen(localname, "wb");
+    FILE* fp = fopen(localname, BIN_W);
     if (!fp)
 	return NULL;
 
@@ -1604,7 +1604,7 @@ PRIVATE void do_readme ARGS2(HTStructured *, target, CONST char *, localname)
 
     HTSprintf0(&readme_file_name, "%s/%s", localname, HT_DIR_README_FILE);
 
-    fp = fopen(readme_file_name,  "r");
+    fp = fopen(readme_file_name,  TXT_R);
 
     if (fp) {
 	HTStructuredClass targetClass;
@@ -1767,13 +1767,14 @@ PRIVATE int print_local_dir ARGS5(
 
 	    StrAllocCat(tmpfilename, dirbuf->d_name);
 	    stat(tmpfilename, &file_info);
-	    if (S_ISDIR(file_info.st_mode))
 #ifndef DIRED_SUPPORT
+	    if (S_ISDIR(file_info.st_mode))
 		HTSprintf0(&dirname, "D%s",dirbuf->d_name);
 	    else
 		HTSprintf0(&dirname, "F%s",dirbuf->d_name);
 		/* D & F to have first directories, then files */
 #else
+	    if (S_ISDIR(file_info.st_mode))
 	    {
 		if (dir_list_style == MIXED_STYLE)
 		    HTSprintf0(&dirname, " %s/", dirbuf->d_name);
@@ -2024,8 +2025,9 @@ PUBLIC int HTStat ARGS2(
      * directory on Windows.
      */
     if (access(temp_name, 0) == 0) {
-	if (stat(temp_name, data) == -1) data->st_mode = S_IFDIR;
-	    result = 0;
+	if (stat(temp_name, data) == -1)
+	    data->st_mode = S_IFDIR;
+	result = 0;
     }
 #else
     result = stat(temp_name, data);
@@ -2092,15 +2094,15 @@ PUBLIC int HTLoadFile ARGS4(
 	strcmp(nodename, HTHostName()) != 0
 #endif /* VMS */
     )) {
+	status = -1;
 	FREE(newname);
 	FREE(filename);
 	FREE(nodename);
 	FREE(acc_method);
 #ifndef DISABLE_FTP
-	return HTFTPLoad(addr, anchor, format_out, sink);
-#else
-	return -1;
+	status = HTFTPLoad(addr, anchor, format_out, sink);
 #endif /* DISABLE_FTP */
+	return status;
     } else {
 	FREE(newname);
 	FREE(acc_method);
@@ -2182,7 +2184,7 @@ PUBLIC int HTLoadFile ARGS4(
 	FILE * fp;
 	char * vmsname = strchr(filename + 1, '/') ?
 		    HTVMS_name(nodename, filename) : filename + 1;
-	fp = fopen(vmsname, "r", "shr=put", "shr=upd");
+	fp = fopen(vmsname, TXT_R, "shr=put", "shr=upd");
 
 	/*
 	**  If the file wasn't VMS syntax, then perhaps it is Ultrix.
@@ -2191,7 +2193,7 @@ PUBLIC int HTLoadFile ARGS4(
 	    char * ultrixname = 0;
 	    CTRACE((tfp, "HTLoadFile: Can't open as %s\n", vmsname));
 	    HTSprintf0(&ultrixname, "%s::\"%s\"", nodename, filename);
-	    fp = fopen(ultrixname, "r", "shr=put", "shr=upd");
+	    fp = fopen(ultrixname, TXT_R, "shr=put", "shr=upd");
 	    if (!fp) {
 		CTRACE((tfp, "HTLoadFile: Can't open as %s\n",
 			    ultrixname));
@@ -2231,7 +2233,7 @@ PUBLIC int HTLoadFile ARGS4(
 		    fclose(fp);
 		    if (semicolon != NULL)
 			*semicolon = ';';
-		    gzfp = gzopen(vmsname, "rb");
+		    gzfp = gzopen(vmsname, BIN_R);
 
 		    CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 				vmsname, (void*)gzfp));
@@ -2271,7 +2273,7 @@ PUBLIC int HTLoadFile ARGS4(
 			fclose(fp);
 			if (semicolon != NULL)
 			    *semicolon = ';';
-			gzfp = gzopen(vmsname, "rb");
+			gzfp = gzopen(vmsname, BIN_R);
 
 			CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 				    vmsname, (void*)gzfp));
@@ -2560,12 +2562,8 @@ PUBLIC int HTLoadFile ARGS4(
 */
 #endif /* HAVE_READDIR */
 	{
-#  if defined(__EMX__) || defined(WIN_EX)
 	    int bin = HTCompressFileType(localname, ".", &dot) != cftNone;
-	    FILE * fp = fopen(localname, (bin ? "rb" : "r"));
-#  else	/* !( defined __EMX__ ) */
-	    FILE * fp = fopen(localname, "r");
-#  endif
+	    FILE * fp = fopen(localname, (bin ? BIN_R : TXT_R));
 
 	    CTRACE((tfp, "HTLoadFile: Opening `%s' gives %p\n",
 				 localname, (void*)fp));
@@ -2591,7 +2589,7 @@ PUBLIC int HTLoadFile ARGS4(
 			(!strcmp(HTAtom_name(myEncoding), "gzip") ||
 			 !strcmp(HTAtom_name(myEncoding), "x-gzip"))) {
 			fclose(fp);
-			gzfp = gzopen(localname, "rb");
+			gzfp = gzopen(localname, BIN_R);
 
 			CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 				    localname, (void*)gzfp));
@@ -2628,7 +2626,7 @@ PUBLIC int HTLoadFile ARGS4(
 #ifdef USE_ZLIB
 			if (strcmp(format_out->name, "www/download") != 0) {
 			    fclose(fp);
-			    gzfp = gzopen(localname, "rb");
+			    gzfp = gzopen(localname, BIN_R);
 
 			    CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 					localname, (void*)gzfp));
@@ -2707,18 +2705,17 @@ PUBLIC int HTLoadFile ARGS4(
 	if (strcmp(nodename, HTHostName()) != 0)
 #endif /* VMS */
 	{
+	    status = -1;
 	    FREE(nodename);
-	    if (!strncmp(addr, "file://localhost", 16)) {
-		return -1;  /* never go to ftp site when URL
-			     * is file://localhost
-			     */
-	    } else {
+	    if (strncmp(addr, "file://localhost", 16)) {
+		/* never go to ftp site when URL
+		 * is file://localhost
+		 */
 #ifndef DISABLE_FTP
-		return HTFTPLoad(addr, anchor, format_out, sink);
-#else
-		return -1;
+		status = HTFTPLoad(addr, anchor, format_out, sink);
 #endif /* DISABLE_FTP */
 	    }
+	    return status;
 	}
 	FREE(nodename);
     }
diff --git a/WWW/Library/Implementation/HTGopher.c b/WWW/Library/Implementation/HTGopher.c
index 33940a63..96681e66 100644
--- a/WWW/Library/Implementation/HTGopher.c
+++ b/WWW/Library/Implementation/HTGopher.c
@@ -1028,7 +1028,7 @@ PRIVATE int parse_cso_fields ARGS2(
 			**  Initialize new block, append to end of list
 			**  to preserve order.
 			*/
-			new = (CSOfield_info *)calloc(1, sizeof(CSOfield_info));
+			new = typecalloc(CSOfield_info);
 			if (!new) {
 			    outofmem(__FILE__, "HTLoadCSO");
 			}
diff --git a/WWW/Library/Implementation/HTGroup.c b/WWW/Library/Implementation/HTGroup.c
index 341099bf..2b16599f 100644
--- a/WWW/Library/Implementation/HTGroup.c
+++ b/WWW/Library/Implementation/HTGroup.c
@@ -48,6 +48,7 @@
 #include <HTLex.h>	/* Lexical analysor	*/
 #include <HTGroup.h>	/* Implemented here	*/
 
+#include <LYUtils.h>
 #include <LYLeaks.h>
 
 /*
@@ -107,7 +108,7 @@ PRIVATE AddressDefList *parse_address_part ARGS1(FILE *, fp)
     address_def_list = HTList_new();
 
     for(;;) {
-	Ref *ref = (Ref*)calloc(1, sizeof(Ref));
+	Ref *ref = typecalloc(Ref);
 	if (ref == NULL)
 	    outofmem(__FILE__, "parse_address_part");
 	ref->name = NULL;
@@ -163,7 +164,7 @@ PRIVATE UserDefList *parse_user_part ARGS1(FILE *, fp)
     user_def_list = HTList_new();
 
     for (;;) {
-	Ref *ref = (Ref*)calloc(1, sizeof(Ref));
+	Ref *ref = typecalloc(Ref);
 	if (ref == NULL)
 	    outofmem(__FILE__, "parse_user_part");
 	ref->name = NULL;
@@ -238,7 +239,7 @@ PRIVATE Item *parse_item ARGS1(FILE *, fp)
 	syntax_error(fp, "Empty item not allowed", lex_item);
 	return NULL;
     }
-    item = (Item*)calloc(1, sizeof(Item));
+    item = typecalloc(Item);
     if (item == NULL)
 	outofmem(__FILE__, "parse_item");
     item->user_def_list = user_def_list;
@@ -287,7 +288,7 @@ PUBLIC GroupDef *HTAA_parseGroupDef ARGS1(FILE *, fp)
     if (!(item_list = parse_item_list(fp))) {
 	return NULL;
     }
-    group_def = (GroupDef*)calloc(1, sizeof(GroupDef));
+    group_def = typecalloc(GroupDef);
     if (group_def == NULL)
 	outofmem(__FILE__, "HTAA_parseGroupDef");
     group_def->group_name = NULL;
@@ -671,14 +672,14 @@ PUBLIC GroupDefList *HTAA_readGroupFile ARGS1(CONST char *, filename)
     CTRACE((tfp, "HTAA_readGroupFile: reading group file `%s'\n",
 		filename));
 
-    if (!(fp = fopen(filename, "r"))) {
+    if (!(fp = fopen(filename, TXT_R))) {
 	CTRACE((tfp, "%s '%s'\n",
 		    "HTAA_readGroupFile: unable to open group file",
 		    filename));
 	return NULL;
     }
 
-    if (!(group_cache = (GroupCache*)calloc(1, sizeof(GroupCache))))
+    if ((group_cache = typecalloc(GroupCache)) == 0)
 	outofmem(__FILE__, "HTAA_readGroupFile");
 
     group_cache->group_filename = NULL;
diff --git a/WWW/Library/Implementation/HTList.c b/WWW/Library/Implementation/HTList.c
index b49c6e58..90871f90 100644
--- a/WWW/Library/Implementation/HTList.c
+++ b/WWW/Library/Implementation/HTList.c
@@ -17,8 +17,8 @@ PUBLIC HTList * HTList_new NOARGS
 {
     HTList *newList;
 
-    if ((newList = (HTList *)calloc(1, sizeof(HTList))) == NULL)
-        outofmem(__FILE__, "HTList_new");
+    if ((newList = typecalloc(HTList)) == NULL)
+	outofmem(__FILE__, "HTList_new");
 
     newList->object = NULL;
     newList->next = NULL;
@@ -71,9 +71,9 @@ PUBLIC HTList * HTList_appendList ARGS2(
     HTList * temp = start;
 
     if (!start) {
-        CTRACE((tfp, "HTList: Trying to append list %p to a nonexisting list\n",
+	CTRACE((tfp, "HTList: Trying to append list %p to a nonexisting list\n",
 		    tail));
-        return NULL;
+	return NULL;
     }
     if (!(tail && tail->next))
 	return start;
@@ -96,14 +96,14 @@ PUBLIC void HTList_addObject ARGS2(
     HTList *newNode;
 
     if (me) {
-        if ((newNode = (HTList *)calloc(1, sizeof(HTList))) == NULL)
+	if ((newNode = typecalloc(HTList)) == NULL)
 	    outofmem(__FILE__, "HTList_addObject");
 	newNode->object = newObject;
 	newNode->next = me->next;
 	me->next = newNode;
 
     } else {
-        CTRACE((tfp, "HTList: Trying to add object %p to a nonexisting list\n",
+	CTRACE((tfp, "HTList: Trying to add object %p to a nonexisting list\n",
 		    newObject));
     }
 
@@ -157,19 +157,19 @@ PUBLIC void HTList_insertObjectAt ARGS3(
     prevNode = temp;
     while ((temp = temp->next)) {
 	if (Pos == 0) {
-	    if ((newNode = (HTList *)calloc(1, sizeof(HTList))) == NULL)
-	        outofmem(__FILE__, "HTList_addObjectAt");
+	    if ((newNode = typecalloc(HTList)) == NULL)
+		outofmem(__FILE__, "HTList_addObjectAt");
 	    newNode->object = newObject;
 	    newNode->next = temp;
 	    if (prevNode)
-	        prevNode->next = newNode;
+		prevNode->next = newNode;
 	    return;
 	}
 	prevNode = temp;
 	Pos--;
     }
     if (Pos >= 0)
-        HTList_addObject(prevNode, newObject);
+	HTList_addObject(prevNode, newObject);
 
     return;
 }
@@ -189,7 +189,7 @@ PUBLIC BOOL HTList_removeObject ARGS2(
 	    prevNode = temp;
 	    temp = temp->next;
 	    if (temp->object == oldObject) {
-	        prevNode->next = temp->next;
+		prevNode->next = temp->next;
 		FREE (temp);
 		return YES;  /* Success */
 	    }
@@ -241,14 +241,14 @@ PUBLIC void * HTList_removeLastObject ARGS1(
     void * lastObject;
 
     if (me && me->next) {
-        lastNode = me->next;
+	lastNode = me->next;
 	lastObject = lastNode->object;
 	me->next = lastNode->next;
 	FREE (lastNode);
 	return lastObject;
 
     } else {  /* Empty list */
-        return NULL;
+	return NULL;
     }
 }
 
@@ -264,7 +264,7 @@ PUBLIC void * HTList_removeFirstObject ARGS1(
     void *firstObject;
 
     if (!temp)
-        return NULL;
+	return NULL;
 
     prevNode = temp;
     if (temp->next) {
@@ -278,7 +278,7 @@ PUBLIC void * HTList_removeFirstObject ARGS1(
 	return firstObject;
 
     } else {  /* Empty list */
-        return NULL;
+	return NULL;
     }
 }
 
@@ -293,7 +293,7 @@ PUBLIC int HTList_count ARGS1(
     int count = 0;
 
     if (temp)
-        while ((temp = temp->next))
+	while ((temp = temp->next))
 	    count++;
 
     return count;
@@ -313,7 +313,7 @@ PUBLIC int HTList_indexOf ARGS2(
     if (temp) {
 	while ((temp = temp->next)) {
 	    if (temp->object == object)
-	        return position;
+		return position;
 	    position++;
 	}
     }
diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c
index c0b0e89b..2d0fb371 100644
--- a/WWW/Library/Implementation/HTMIME.c
+++ b/WWW/Library/Implementation/HTMIME.c
@@ -100,12 +100,12 @@ typedef enum _MIME_state {
 	miJUNK_LINE,		/* Ignore the rest of this folded line */
 	miNEWLINE,		/* Just found a LF .. maybe continuation */
 	miCHECK,		/* check against check_pointer */
-	MIME_NET_ASCII, 	/* Translate from net ascii */
+	MIME_NET_ASCII,		/* Translate from net ascii */
 	MIME_IGNORE		/* Ignore entire file */
 	/* TRANSPARENT and IGNORE are defined as stg else in _WINDOWS */
 } MIME_state;
 
-#define VALUE_SIZE 5120 	/* @@@@@@@ Arbitrary? */
+#define VALUE_SIZE 5120		/* @@@@@@@ Arbitrary? */
 struct _HTStream {
 	CONST HTStreamClass *	isa;
 
@@ -122,7 +122,7 @@ struct _HTStream {
 	char *			value_pointer;	/* storing values */
 	char			value[VALUE_SIZE];
 
-	HTParentAnchor *	anchor; 	/* Given on creation */
+	HTParentAnchor *	anchor;		/* Given on creation */
 	HTStream *		sink;		/* Given on creation */
 
 	char *			boundary;	/* For multipart */
@@ -132,8 +132,8 @@ struct _HTStream {
 
 	HTFormat		encoding;	/* Content-Transfer-Encoding */
 	char *			compression_encoding;
-	HTFormat		format; 	/* Content-Type */
-	HTStream *		target; 	/* While writing out */
+	HTFormat		format;		/* Content-Type */
+	HTStream *		target;		/* While writing out */
 	HTStreamClass		targetClass;
 
 	HTAtom *		targetRep;	/* Converting into? */
@@ -147,7 +147,7 @@ struct _HTStream {
 **  first and last characters are double-quotes. - FM
 */
 PUBLIC void HTMIME_TrimDoubleQuotes ARGS1(
-	char *, 	value)
+	char *,		value)
 {
     int i;
     char *cp = value;
@@ -1187,7 +1187,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	} /* switch on character */
 	break;
 
-    case miCON: 			/* Check for 'n' or 't' */
+    case miCON:				/* Check for 'n' or 't' */
 	switch (c) {
 	case 'n':
 	case 'N':
@@ -1707,7 +1707,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 
     case miGET_VALUE:
     GET_VALUE:
-    	if (c != '\n') {			/* Not end of line */
+	if (c != '\n') {			/* Not end of line */
 	    if (me->value_pointer < me->value + VALUE_SIZE - 1) {
 		*me->value_pointer++ = c;
 		break;
@@ -1732,7 +1732,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 value_too_long:
     CTRACE((tfp, "HTMIME: *** Syntax error. (string too long)\n"));
 
-bad_field_name: 			/* Ignore it */
+bad_field_name:				/* Ignore it */
     me->state = miJUNK_LINE;
     return;
 
@@ -1841,7 +1841,7 @@ PUBLIC HTStream* HTMIMEConvert ARGS3(
 {
     HTStream* me;
 
-    me = (HTStream *)calloc(1, sizeof(*me));
+    me = typecalloc(HTStream);
     if (me == NULL)
 	outofmem(__FILE__, "HTMIMEConvert");
     me->isa	=	&HTMIME;
@@ -1983,8 +1983,8 @@ PRIVATE char HTmmquote[] = "0123456789ABCDEF";
 PRIVATE int HTmmcont = 0;
 
 PUBLIC void HTmmdec_base64 ARGS2(
-	char *, 	t,
-	char *, 	s)
+	char *,		t,
+	char *,		s)
 {
     int   d, count, j, val;
     char  buf[LINE_LENGTH], *bp, nw[4], *p;
@@ -2022,8 +2022,8 @@ PUBLIC void HTmmdec_base64 ARGS2(
 }
 
 PUBLIC void HTmmdec_quote ARGS2(
-	char *, 	t,
-	char *, 	s)
+	char *,		t,
+	char *,		s)
 {
     char  buf[LINE_LENGTH], cval, *bp, *p;
 
@@ -2059,8 +2059,8 @@ PUBLIC void HTmmdec_quote ARGS2(
 **	HTmmdecode for ISO-2022-JP - FM
 */
 PUBLIC void HTmmdecode ARGS2(
-	char *, 	trg,
-	char *, 	str)
+	char *,		trg,
+	char *,		str)
 {
     char buf[LINE_LENGTH], mmbuf[LINE_LENGTH];
     char *s, *t, *u;
@@ -2124,8 +2124,8 @@ end:
 **  (The author of this function "rjis" is S. Ichikawa.)
 */
 PUBLIC int HTrjis ARGS2(
-	char *, 	t,
-	char *, 	s)
+	char *,		t,
+	char *,		s)
 {
     char *p, buf[LINE_LENGTH];
     int kanji = 0;
diff --git a/WWW/Library/Implementation/HTNews.c b/WWW/Library/Implementation/HTNews.c
index b404733b..19be48c8 100644
--- a/WWW/Library/Implementation/HTNews.c
+++ b/WWW/Library/Implementation/HTNews.c
@@ -209,7 +209,7 @@ PRIVATE BOOL initialize NOARGS
 		    HTNewsHost));
     } else {
 	char server_name[256];
-	FILE* fp = fopen(SERVER_FILE, "r");
+	FILE* fp = fopen(SERVER_FILE, TXT_R);
 	if (fp) {
 	    if (fscanf(fp, "%s", server_name)==1) {
 		StrAllocCopy(HTNewsHost, server_name);
@@ -407,8 +407,7 @@ PRIVATE NNTPAuthResult HTHandleAuthInfo ARGS1(
 		/*
 		**  Store the accepted username and no password. - FM
 		*/
-		if ((auth =
-		    (NNTPAuth *)calloc(1, sizeof(NNTPAuth))) != NULL) {
+		if ((auth = typecalloc(NNTPAuth)) != NULL) {
 		    StrAllocCopy(auth->host, host);
 		    auth->user = UserName;
 		    HTList_appendObject(NNTP_AuthInfo, auth);
@@ -515,8 +514,7 @@ PRIVATE NNTPAuthResult HTHandleAuthInfo ARGS1(
 			auth->pass = PassWord;
 		    }
 		} else {
-		    if ((auth =
-			(NNTPAuth *)calloc(1, sizeof(NNTPAuth))) != NULL) {
+		    if ((auth = typecalloc(NNTPAuth)) != NULL) {
 			StrAllocCopy(auth->host, host);
 			auth->user = UserName;
 			auth->pass = PassWord;
@@ -847,12 +845,7 @@ PRIVATE void post_article ARGS1(
     **	Open the temporary file with the
     **	nntp headers and message body. - FM
     */
-#ifdef DOSPATH
-    if ((fd = fopen((postfile ? postfile : ""), "rt")) == NULL)
-#else
-    if ((fd = fopen((postfile ? postfile : ""), "r")) == NULL)
-#endif
-    {
+    if ((fd = fopen((postfile ? postfile : ""), TXT_R)) == NULL) {
 	HTAlert(FAILED_CANNOT_OPEN_POST);
 	return;
     }
@@ -970,12 +963,6 @@ void debug_print(unsigned char *p)
 }
 #endif
 
-#ifdef NOTUSED_CHARTRANS
-static char *decode_mime(char *str)
-{
-    return HTmmdecode(str, str);
-}
-#else
 static char *decode_mime(char *str)
 {
     char temp[LINE_LENGTH];	/* FIXME: what determines the actual size? */
@@ -1006,17 +993,12 @@ static char *decode_mime(char *str)
 
     return str;
 }
-#endif /* NOTUSED_CHARTRANS */
 #else /* !SH_EX */
 static char *decode_mime ARGS1(char *, str)
 {
-#ifdef NOTUSED_CHARTRANS
-    return HTmmdecode(str, str);
-#else
     HTmmdecode(str, str);
     HTrjis(str, str);
     return str;
-#endif
 }
 #endif
 
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c
index c7255995..b5112341 100644
--- a/WWW/Library/Implementation/HTParse.c
+++ b/WWW/Library/Implementation/HTParse.c
@@ -19,7 +19,7 @@ struct struct_parts {
 };
 
 
-/*	Strip white space off a string. 			HTStrip()
+/*	Strip white space off a string.				HTStrip()
 **	-------------------------------
 **
 ** On exit,
@@ -27,7 +27,7 @@ struct struct_parts {
 **	All trailing white space is OVERWRITTEN with zero.
 */
 PUBLIC char * HTStrip ARGS1(
-	char *, 	s)
+	char *,		s)
 {
 #define SPACE(c) ((c == ' ') || (c == '\t') || (c == '\n'))
     char * p = s;
@@ -55,7 +55,7 @@ PUBLIC char * HTStrip ARGS1(
 **	Any which are nonzero point to zero terminated strings.
 */
 PRIVATE void scan ARGS2(
-	char *, 		name,
+	char *,			name,
 	struct struct_parts *,	parts)
 {
     char * after_access;
@@ -178,7 +178,7 @@ PRIVATE void scan ARGS2(
 **	wanted		A mask for the bits which are wanted.
 **
 ** On exit,
-**	returns 	A pointer to a calloc'd string which MUST BE FREED
+**	returns		A pointer to a calloc'd string which MUST BE FREED
 */
 PUBLIC char * HTParse ARGS3(
 	CONST char *,	aName,
@@ -208,7 +208,7 @@ PUBLIC char * HTParse ARGS3(
     **	Allocate the output string.
     */
     len = strlen(aName) + strlen(relatedName) + 10;
-    result = (char *)calloc(1, len);	/* Lots of space: more than enough */
+    result = typecallocn(char, len);	/* Lots of space: more than enough */
     if (result == NULL) {
 	outofmem(__FILE__, "HTParse");
     }
@@ -484,7 +484,7 @@ PUBLIC char * HTParse ARGS3(
 **	or	../../albert.html
 */
 PUBLIC void HTSimplify ARGS1(
-	char *, 	filename)
+	char *,		filename)
 {
     char *p;
     char *q, *q1;
@@ -682,7 +682,7 @@ PUBLIC char * HTRelative ARGS2(
 	for (; *q && (*q != '#'); q++)
 	    if (*q == '/')
 		levels++;
-	result = (char *)calloc(1, (3*levels + strlen(last_slash) + 1));
+	result = typecallocn(char, 3*levels + strlen(last_slash) + 1);
 	if (result == NULL)
 	    outofmem(__FILE__, "HTRelative");
 	result[0] = '\0';
@@ -691,7 +691,7 @@ PUBLIC char * HTRelative ARGS2(
 	strcat(result, last_slash+1);
     }
     CTRACE((tfp,
-        "HTparse: `%s' expressed relative to\n   `%s' is\n   `%s'.\n",
+	"HTparse: `%s' expressed relative to\n	 `%s' is\n   `%s'.\n",
 		aName, relatedName, result));
     return result;
 }
@@ -709,7 +709,7 @@ PUBLIC char * HTRelative ARGS2(
 PRIVATE CONST unsigned char isAcceptable[96] =
 
 /*	Bit 0		xalpha		-- see HTFile.h
-**	Bit 1		xpalpha 	-- as xalpha but with plus.
+**	Bit 1		xpalpha		-- as xalpha but with plus.
 **	Bit 3 ...	path		-- as xpalphas but with /
 */
     /*	 0 1 2 3 4 5 6 7 8 9 A B C D E F */
@@ -734,7 +734,7 @@ PUBLIC char * HTEscape ARGS2(
     for (p = str; *p; p++)
 	if (!ACCEPTABLE(UCH(TOASCII(*p))))
 	    unacceptable++;
-    result = (char *)calloc(1, (p-str + unacceptable + unacceptable + 1));
+    result = typecallocn(char, p-str + unacceptable + unacceptable + 1);
     if (result == NULL)
 	outofmem(__FILE__, "HTEscape");
     for (q = result, p = str; *p; p++) {
@@ -772,7 +772,7 @@ PUBLIC char * HTEscapeSP ARGS2(
     for (p = str; *p; p++)
 	if (!(*p == ' ' || ACCEPTABLE(UCH(TOASCII(*p)))))
 	    unacceptable++;
-    result = (char *)calloc(1, (p-str + unacceptable + unacceptable + 1));
+    result = typecallocn(char, p-str + unacceptable + unacceptable + 1);
     if (result == NULL)
 	outofmem(__FILE__, "HTEscape");
     for (q = result, p = str; *p; p++) {
@@ -808,7 +808,7 @@ PRIVATE char from_hex ARGS1(
 }
 
 PUBLIC char * HTUnEscape ARGS1(
-	char *, 	str)
+	char *,		str)
 {
     char * p = str;
     char * q = str;
@@ -856,7 +856,7 @@ PUBLIC char * HTUnEscape ARGS1(
 **	The first string is converted in place, as it will never grow.
 */
 PUBLIC char * HTUnEscapeSome ARGS2(
-	char *, 	str,
+	char *,		str,
 	CONST char *,	do_trans)
 {
     char * p = str;
@@ -889,7 +889,7 @@ PUBLIC char * HTUnEscapeSome ARGS2(
 PRIVATE CONST unsigned char crfc[96] =
 
 /*	Bit 0		xalpha		-- need "quoting"
-**	Bit 1		xpalpha 	-- need \escape if quoted
+**	Bit 1		xpalpha		-- need \escape if quoted
 */
     /*	 0 1 2 3 4 5 6 7 8 9 A B C D E F */
     {	 1,0,3,0,0,0,0,0,1,1,0,0,1,0,1,0,	/* 2x	!"#$%&'()*+,-./  */
@@ -930,7 +930,7 @@ PUBLIC void HTMake822Word ARGS1(
     }
     if (!added)
 	return;
-    result = (char *)calloc(1, (p-(*str) + added + 1));
+    result = typecallocn(char, p-(*str) + added + 1);
     if (result == NULL)
 	outofmem(__FILE__, "HTMake822Word");
     result[0] = '"';
diff --git a/WWW/Library/Implementation/HTRules.c b/WWW/Library/Implementation/HTRules.c
index def5f7dd..f2b3432e 100644
--- a/WWW/Library/Implementation/HTRules.c
+++ b/WWW/Library/Implementation/HTRules.c
@@ -69,11 +69,11 @@ PRIVATE rule * rule_tail = 0;	/* Pointer to last on list */
 **	--------------------
 **
 **  On entry,
-**	pattern 	points to 0-terminated string containing a single "*"
+**	pattern		points to 0-terminated string containing a single "*"
 **	equiv		points to the equivalent string with * for the
 **			place where the text matched by * goes.
 **  On exit,
-**	returns 	0 if success, -1 if error.
+**	returns		0 if success, -1 if error.
 */
 
 PUBLIC int HTAddRule ARGS5(
@@ -86,7 +86,7 @@ PUBLIC int HTAddRule ARGS5(
     rule *	temp;
     char *	pPattern = NULL;
 
-    temp = (rule *)calloc(1, sizeof(*temp));
+    temp = typecalloc(rule);
     if (temp==NULL)
 	outofmem(__FILE__, "HTAddRule");
     if (equiv) {		/* Two operands */
@@ -135,7 +135,7 @@ PUBLIC int HTAddRule ARGS5(
 }
 
 
-/*	Clear all rules 					HTClearRules()
+/*	Clear all rules						HTClearRules()
 **	---------------
 **
 ** On exit,
@@ -194,7 +194,7 @@ PRIVATE BOOL rule_cond_ok ARGS1(
 ** On entry,
 **	required	points to a string whose equivalent value is neeed
 ** On exit,
-**	returns 	the address of the equivalent string allocated from
+**	returns		the address of the equivalent string allocated from
 **			the heap which the CALLER MUST FREE. If no translation
 **			occured, then it is a copy of te original.
 ** NEW FEATURES:
@@ -332,11 +332,11 @@ char * HTTranslate ARGS1(
 				   r->equiv,
 				   m,
 				   q,
-				   ins + 1); 	
+				   ins + 1);
 			CTRACE((tfp, "For `%s' using `%s'\n",
 				    current, temp));
 			FREE(current);
-			current = temp; 		/* Use this */
+			current = temp;			/* Use this */
 
 		    } else {	/* No insertion point */
 			char * temp = NULL;
@@ -345,7 +345,7 @@ char * HTTranslate ARGS1(
 			CTRACE((tfp, "For `%s' using `%s'\n",
 						current, temp));
 			FREE(current);
-			current = temp; 		/* Use this */
+			current = temp;			/* Use this */
 		    } /* If no insertion point exists */
 		}
 		if (r->op == HT_Pass) {
@@ -475,7 +475,7 @@ PUBLIC int  HTSetConfiguration ARGS1(
 	HTSetPresentation(word2, word3,
 		    status >= 1 ? quality		: 1.0,
 		    status >= 2 ? secs			: 0.0,
-		    status >= 3 ? secs_per_byte 	: 0.0,
+		    status >= 3 ? secs_per_byte		: 0.0,
 		    status >= 4 ? maxbytes		: 0 );
 
     } else if (0==strncasecomp(word1, "htbin", 5) ||
@@ -619,7 +619,7 @@ PUBLIC int  HTSetConfiguration ARGS1(
 ** On exit,
 **	Any existing rules will have been kept.
 **	Any new rules will have been loaded.
-**	Returns 	0 if no error, 0 if error!
+**	Returns		0 if no error, 0 if error!
 **
 ** Bugs:
 **	The strings may not contain spaces.
@@ -628,7 +628,7 @@ PUBLIC int  HTSetConfiguration ARGS1(
 int HTLoadRules ARGS1(
     CONST char *,	filename)
 {
-    FILE * fp = fopen(filename, "r");
+    FILE * fp = fopen(filename, TXT_R);
     char line[LINE_LENGTH+1];
 
     if (!fp) {
diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c
index 09d37f8c..fce10c6f 100644
--- a/WWW/Library/Implementation/HTString.c
+++ b/WWW/Library/Implementation/HTString.c
@@ -1087,7 +1087,7 @@ PUBLIC void HTSABCat ARGS3(
 	    int length = t->len;
 	    t->str = (char *)realloc(t->str, length + len);
 	} else {
-	    t = (bstring *)calloc(1, sizeof(*t));
+	    t = typecalloc(bstring);
 	    if (t == NULL)
 		outofmem(__FILE__, "HTSACat");
 	    t->str = (char *)malloc(len);
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index 93c1b18d..fca17ea5 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -126,9 +126,7 @@ static unsigned long _fork_func (void *arglist)
 **  A routine to mimic the ioctl function for UCX.
 **  Bjorn S. Nilsson, 25-Nov-1993. Based on an example in the UCX manual.
 */
-#include <iodef.h>
-#define IOC_OUT (int)0x40000000
-extern int vaxc$get_sdc(), sys$qiow();
+#include <HTioctl.h>
 
 PUBLIC int HTioctl ARGS3(
 	int,		d,
@@ -152,9 +150,6 @@ PUBLIC int HTioctl ARGS3(
 	set_errno(EBADF);
 	return -1;
     }
-#ifndef UCX$C_IOCTL
-#define UCX$C_IOCTL TCPIP$C_IOCTL
-#endif
     ioctl_desc.opt  = UCX$C_IOCTL;
     ioctl_desc.len  = sizeof(struct comm);
     ioctl_desc.addr = &ioctl_comm;
@@ -191,6 +186,7 @@ PUBLIC int HTioctl ARGS3(
 PUBLIC int HTInetStatus ARGS1(
 	char *,		where)
 {
+    int status;
     int saved_errno = errno;
 #ifdef VMS
 #ifdef MULTINET
@@ -246,13 +242,14 @@ PUBLIC int HTInetStatus ARGS1(
     **	uerrno and errno happen to be zero if vmserrno <> 0
     */
 #ifdef MULTINET
-    return -vmserrno;
+    status = -vmserrno;
 #else
-    return -vaxc$errno;
+    status = -vaxc$errno;
 #endif /* MULTINET */
 #else
-    return -SOCKET_ERRNO;
+    status = -SOCKET_ERRNO;
 #endif /* VMS */
+    return status;
 }
 
 /*	Parse a cardinal value				       parse_cardinal()
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 51c57e9b..5e72f253 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -1,4 +1,4 @@
-/*	HyperText Tranfer Protocol	- Client implementation 	HTTP.c
+/*	HyperText Tranfer Protocol	- Client implementation		HTTP.c
 **	==========================
 ** Modified:
 ** 27 Jan 1994	PDM  Added Ari Luotonen's Fix for Reload when using proxy
@@ -350,16 +350,16 @@ PRIVATE int HTLoadHTTP ARGS4 (
 {
   int s;			/* Socket number for returned data */
   CONST char *url = arg;	/* The URL which get_physical() returned */
-  char *command = NULL; 	/* The whole command */
+  char *command = NULL;		/* The whole command */
   char *eol;			/* End of line if found */
   char *start_of_data;		/* Start of body of reply */
   int status;			/* tcp return */
   int bytes_already_read;
-  char crlf[3]; 		/* A CR LF equivalent string */
+  char crlf[3];			/* A CR LF equivalent string */
   HTStream *target;		/* Unconverted data */
   HTFormat format_in;		/* Format arriving in the message */
-  BOOL do_head = FALSE; 	/* Whether or not we should do a head */
-  BOOL do_post = FALSE; 	/* ARE WE posting ? */
+  BOOL do_head = FALSE;		/* Whether or not we should do a head */
+  BOOL do_post = FALSE;		/* ARE WE posting ? */
   char *METHOD;
 
   BOOL had_header;		/* Have we had at least one header? */
@@ -372,7 +372,7 @@ PRIVATE int HTLoadHTTP ARGS4 (
   BOOL first_Accept = TRUE;
   BOOL show_401 = FALSE;
   BOOL show_407 = FALSE;
-  BOOL auth_proxy = NO; 	/* Generate a proxy authorization. - AJL */
+  BOOL auth_proxy = NO;		/* Generate a proxy authorization. - AJL */
 
   int length, rawlength, rv;
   int server_status;
@@ -455,12 +455,13 @@ try_again:
   line_buffer = NULL;
   line_kept_clean = NULL;
 
-  if (!strncmp(url, "https", 5))
 #ifdef USE_SSL
+  if (!strncmp(url, "https", 5))
     status = HTDoConnect (url, "HTTPS", HTTPS_PORT, &s);
   else
     status = HTDoConnect (url, "HTTP", HTTP_PORT, &s);
 #else
+  if (!strncmp(url, "https", 5))
     {
       HTAlert(gettext("This client does not contain support for HTTPS URLs."));
       status = HT_NOT_LOADED;
@@ -521,7 +522,7 @@ use_tunnel:
 	      try_tls = FALSE;
 	      if (did_connect)
 		  HTTP_NETCLOSE(s, handle);
-      	      goto try_again;
+	      goto try_again;
 	  } else {
 	      unsigned long SSLerror;
 	      CTRACE((tfp,
@@ -531,11 +532,11 @@ use_tunnel:
 	      while((SSLerror=ERR_get_error())!=0) {
 		  CTRACE((tfp,"HTTP: SSL: %s\n",ERR_error_string(SSLerror,NULL)));
 	      }
-      	      HTAlert("Unable to make secure connection to remote host.");
+	      HTAlert("Unable to make secure connection to remote host.");
 	      if (did_connect)
 		  HTTP_NETCLOSE(s, handle);
-      	      status = HT_NOT_LOADED;
-      	      goto done;
+	      status = HT_NOT_LOADED;
+	      goto done;
 	  }
 #else
 	  unsigned long SSLerror;
@@ -546,11 +547,11 @@ use_tunnel:
 	  while((SSLerror=ERR_get_error())!=0) {
 	      CTRACE((tfp,"HTTP: SSL: %s\n",ERR_error_string(SSLerror,NULL)));
 	  }
-      	  HTAlert("Unable to make secure connection to remote host.");
+	  HTAlert("Unable to make secure connection to remote host.");
 	  if (did_connect)
 	      HTTP_NETCLOSE(s, handle);
-      	  status = HT_NOT_LOADED;
-      	  goto done;
+	  status = HT_NOT_LOADED;
+	  goto done;
 #endif /* SSLEAY_VERSION_NUMBER >= 0x0900 */
       }
       sprintf(SSLprogress,"Secure %d-bit %s (%s) HTTP connection",SSL_get_cipher_bits(handle,NULL),SSL_get_cipher_version(handle),SSL_get_cipher(handle));
@@ -558,13 +559,13 @@ use_tunnel:
 
 #ifdef NOTDEFINED
       if (strcmp(HTParse(url, "", PARSE_HOST),
-      		 strstr(X509_NAME_oneline(
-		 	X509_get_subject_name(
+		 strstr(X509_NAME_oneline(
+			X509_get_subject_name(
 				handle->session->peer)),"/CN=")+4)) {
 	  HTAlert("Certificate is for different host name");
 	  HTAlert(strstr(X509_NAME_oneline(
-	  		 X509_get_subject_name(
-			 	handle->session->peer)),"/CN=")+4);
+			 X509_get_subject_name(
+				handle->session->peer)),"/CN=")+4);
       }
 #endif /* NOTDEFINED */
   }
@@ -1056,7 +1057,7 @@ use_tunnel:
     BOOL end_of_file = NO;
     int buffer_length = INIT_LINE_SIZE;
 
-    line_buffer = (char *)calloc(1, (buffer_length * sizeof(char)));
+    line_buffer = typecallocn(char, buffer_length);
     if (line_buffer == NULL)
 	outofmem(__FILE__, "HTLoadHTTP");
 
@@ -1214,13 +1215,13 @@ use_tunnel:
     if (http_error_file) {     /* Make the status code externally available */
 	FILE *error_file;
 #ifdef SERVER_STATUS_ONLY
-	error_file = fopen(http_error_file, "w");
+	error_file = fopen(http_error_file, TXT_W);
 	if (error_file) {		/* Managed to open the file */
 	    fprintf(error_file, "error=%d\n", server_status);
 	    fclose(error_file);
 	}
 #else
-	error_file = fopen(http_error_file, "a");
+	error_file = fopen(http_error_file, TXT_A);
 	if (error_file) {		/* Managed to open the file */
 	    fprintf(error_file, "   URL=%s (%s)\n", url, METHOD);
 	    fprintf(error_file, "STATUS=%s\n", line_buffer);
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index 9f153265..d387e2bd 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -486,6 +486,7 @@ The local equivalents of CR and LF
 #ifdef NO_LYNX_TRACE
 #define WWW_TraceFlag   0
 #define WWW_TraceMask   0
+#define LYTraceLogFP    0
 #else
 extern BOOLEAN WWW_TraceFlag;
 extern unsigned WWW_TraceMask;
@@ -496,8 +497,14 @@ extern unsigned WWW_TraceMask;
 #define TRACE_STYLE     (TRACE_bit(1))
 #define TRACE_TRST      (TRACE_bit(2))
 
-#define CTRACE(p)          if (TRACE) fprintf p
-#define CTRACE2(m,p)       if (m)     fprintf p
+#if defined(LY_TRACELINE)
+#define LY_SHOWWHERE fprintf( tfp, "%s: %d: ", __FILE__, LY_TRACELINE );
+#else
+#define LY_SHOWWHERE /* nothing */
+#endif
+
+#define CTRACE(p)          if (TRACE) { LY_SHOWWHERE fprintf p; }
+#define CTRACE2(m,p)       if (m)     { LY_SHOWWHERE fprintf p; }
 #define tfp TraceFP()
 #define CTRACE_SLEEP(secs) if (TRACE && LYTraceLogFP == 0) sleep(secs)
 #define CTRACE_FLUSH(fp)   if (TRACE) fflush(fp)
diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c
index a83bdce3..d7019411 100644
--- a/WWW/Library/Implementation/HTVMSUtils.c
+++ b/WWW/Library/Implementation/HTVMSUtils.c
@@ -871,7 +871,7 @@ PUBLIC int HTVMSBrowseDir ARGS4(
 	if (header[strlen(header)-1] != '/')
 	    StrAllocCat(header, "/");
 	StrAllocCat(header, HT_DIR_README_FILE);
-	if ((fp = fopen(header,	 "r")) != NULL) {
+	if ((fp = fopen(header,	 TXT_R)) != NULL) {
 	    START(HTML_PRE);
 	    for(;;) {
 		char c = fgetc(fp);
diff --git a/WWW/Library/Implementation/HTVMS_WaisUI.c b/WWW/Library/Implementation/HTVMS_WaisUI.c
index 2890841f..6f0811c0 100644
--- a/WWW/Library/Implementation/HTVMS_WaisUI.c
+++ b/WWW/Library/Implementation/HTVMS_WaisUI.c
@@ -220,7 +220,7 @@ transport_message(
 
   if( request_length + HEADER_LENGTH !=
       NETWRITE(connection,request_message,
-   		  (int)( request_length +HEADER_LENGTH)) )
+		  (int)( request_length +HEADER_LENGTH)) )
     return 0;
 
   /* read for the first '0' */
diff --git a/WWW/Library/Implementation/HTWAIS.c b/WWW/Library/Implementation/HTWAIS.c
index 35277c6d..7d440e7f 100644
--- a/WWW/Library/Implementation/HTWAIS.c
+++ b/WWW/Library/Implementation/HTWAIS.c
@@ -115,9 +115,9 @@ struct _HTStream {
 /* ------------------------------------------------------------------------ */
 /* Returns 1 on success, 0 on fail, -1 on interrupt. */
 PRIVATE int fd_mosaic_connect_to_server ARGS3(
-	char *, 	host_name,
+	char *,		host_name,
 	long,		port,
-	long *, 	fd)
+	long *,		fd)
 {
     char *dummy = NULL;
     int status;
@@ -140,12 +140,12 @@ PRIVATE int fd_mosaic_connect_to_server ARGS3(
 /* Returns 1 on success, 0 on fail, -1 on interrupt. */
 #ifdef VMS
 PRIVATE int mosaic_connect_to_server ARGS3(
-	char *, 	host_name,
+	char *,		host_name,
 	long,		port,
-	long *, 	fdp)
+	long *,		fdp)
 #else
 PRIVATE int mosaic_connect_to_server ARGS3(
-	char *, 	host_name,
+	char *,		host_name,
 	long,		port,
 	FILE **,	fp)
 #endif /* VMS */
@@ -222,18 +222,18 @@ PRIVATE void init_acceptable NOARGS
 **
 **
 ** On exit,
-**	returns 	nil if error
+**	returns		nil if error
 **			pointer to malloced string (must be freed) if ok
 */
 PRIVATE char * WWW_from_archie ARGS1(
-	char *, 	file)
+	char *,		file)
 {
     char * end;
     char * result;
     char * colon;
     for(end=file; *end > ' '; end++);	/* assumes ASCII encoding*/
     result = (char *)malloc(10 + (end-file));
-    if (!result) return result; 	/* Malloc error */
+    if (!result) return result;		/* Malloc error */
     strcpy(result, "file://");
     strncat(result, file, end-file);
     colon = strchr(result+7, ':');	/* Expect colon after host */
@@ -250,7 +250,7 @@ PRIVATE char * WWW_from_archie ARGS1(
 **	The format of the docid MUST be good!
 **
 **  On exit,
-**	returns 	nil if error
+**	returns		nil if error
 **			pointer to malloced string (must be freed) if ok
 */
 PRIVATE char hex [17] = "0123456789ABCDEF";
@@ -317,7 +317,7 @@ PRIVATE char * WWW_from_WAIS ARGS1(
 **	-------------------------------------------
 **
 **  On entry,
-**	docname 	points to valid name produced originally by
+**	docname		points to valid name produced originally by
 **			WWW_from_WAIS
 **  On exit,
 **	docid->size	is valid
@@ -325,7 +325,7 @@ PRIVATE char * WWW_from_WAIS ARGS1(
 */
 PRIVATE any * WAIS_from_WWW ARGS2(
 	any *,		docid,
-	char *, 	docname)
+	char *,		docname)
 {
     char *z;	/* Output pointer */
     char *sor;	/* Start of record - points to size field. */
@@ -351,7 +351,7 @@ PRIVATE any * WAIS_from_WWW ARGS2(
     for (p = docname; *p; ) {	/* Convert of strings */
 				/* Record type */
 
-	*z = 0; 		/* Initialize record type */
+	*z = 0;			/* Initialize record type */
 	while (*p >= '0' && *p <= '9') {
 	    *z = *z*10 + (*p++ - '0');	/* Decode decimal record type */
 	}
@@ -407,8 +407,8 @@ PRIVATE any * WAIS_from_WWW ARGS2(
 **	--------------------------------------
 */
 PRIVATE void output_text_record ARGS4(
-    HTStream *, 		target,
-    WAISDocumentText *, 	record,
+    HTStream *,			target,
+    WAISDocumentText *,		record,
     boolean,			quote_string_quotes,
     boolean,			binary)
 {
@@ -432,7 +432,7 @@ PRIVATE void output_text_record ARGS4(
 	    /* if the next letter is '(' or ')', then ignore two letters */
 	    if ('(' == record->DocumentText->bytes[count + 1] ||
 		')' == record->DocumentText->bytes[count + 1])
-	    count += 1; 	    /* it is a term marker */
+	    count += 1;		    /* it is a term marker */
 	    else count += 4;		/* it is a paragraph marker */
     } else if (ch == '\n' || ch == '\r') {
 	    PUTC('\n');
@@ -442,7 +442,7 @@ PRIVATE void output_text_record ARGS4(
   }
 } /* output text record */
 
-/*	Format A Search response for the client 	display_search_response
+/*	Format A Search response for the client		display_search_response
 **	---------------------------------------
 */
 /* modified from tracy shen's version in wutil.c
@@ -491,7 +491,7 @@ PRIVATE void display_search_response ARGS4(
 		WAISDocumentHeader* head = info->DocHeaders[k];
 		char * headline = trim_junk(head->Headline);
 		any * docid = head->DocumentID;
-		char * docname; 	/* printable version of docid */
+		char * docname;		/* printable version of docid */
 
 		i++;
 		/*
@@ -615,15 +615,15 @@ PUBLIC int HTLoadWAIS ARGS4(
 {
     static CONST char * error_header =
 "<h1>Access error</h1>\nThe following error occured in accesing a WAIS server:<P>\n";
-    char * key; 		  /* pointer to keywords in URL */
+    char * key;			  /* pointer to keywords in URL */
     char* request_message = NULL; /* arbitrary message limit */
     char* response_message = NULL; /* arbitrary message limit */
     long request_buffer_length; /* how of the request is left */
     SearchResponseAPDU	*retrieval_response = 0;
     char keywords[MAX_KEYWORDS_LENGTH + 1];
     char *server_name;
-    char *wais_database = NULL; 	/* name of current database */
-    char *www_database; 		/* Same name escaped */
+    char *wais_database = NULL;		/* name of current database */
+    char *www_database;			/* Same name escaped */
     char *service;
     char *doctype;
     char *doclength;
@@ -731,11 +731,9 @@ PUBLIC int HTLoadWAIS ARGS4(
     **	This below fixed size stuff is terrible.
     */
 #ifdef VMS
-    if (!(request_message =
-	  (char*)calloc((size_t)MAX_MESSAGE_LEN*sizeof(char),1)))
+    if ((request_message = typecallocn(char, MAX_MESSAGE_LEN)) == 0)
 	outofmem(__FILE__, "HTLoadWAIS");
-    if (!(response_message =
-	  (char*)calloc((size_t)MAX_MESSAGE_LEN*sizeof(char),1)))
+    if ((response_message = typecallocn(char, MAX_MESSAGE_LEN)) == 0)
 	outofmem(__FILE__, "HTLoadWAIS");
 #else
     request_message = (char*)s_malloc((size_t)MAX_MESSAGE_LEN * sizeof(char));
@@ -747,7 +745,7 @@ PUBLIC int HTLoadWAIS ARGS4(
     **	the user has followed a link to the index itself.  It would be
     **	appropriate at this point to send him the .SRC file - how?
     */
-    if (key && !*key) { 			/* I N D E X */
+    if (key && !*key) {				/* I N D E X */
 #ifdef CACHE_FILE_PREFIX
 	char * filename = NULL;
 	FILE * fp;
@@ -790,7 +788,7 @@ PUBLIC int HTLoadWAIS ARGS4(
 		CACHE_FILE_PREFIX,
 		server_name, service, www_database);
 
-	fp = fopen(filename, "r");	/* Have we found this already? */
+	fp = fopen(filename, TXT_R);	/* Have we found this already? */
 	CTRACE((tfp, "HTWAIS: Description of server %s %s.\n",
 		    filename,
 		    fp ? "exists already" : "does NOT exist!"));
diff --git a/WWW/Library/Implementation/HTWSRC.c b/WWW/Library/Implementation/HTWSRC.c
index 4fca40ca..0f7577f8 100644
--- a/WWW/Library/Implementation/HTWSRC.c
+++ b/WWW/Library/Implementation/HTWSRC.c
@@ -259,7 +259,7 @@ PRIVATE BOOL write_cache ARGS1(HTStream *, me)
 	me->par_value[PAR_TCP_PORT] ? me->par_value[PAR_TCP_PORT] : "210",
 	www_database);
 
-    if ((fp = fopen(cache_file_name, "w")) != 0) {
+    if ((fp = fopen(cache_file_name, TXT_W)) != 0) {
 	result = YES;
 	if (me->par_value[PAR_DESCRIPTION])
 	    fputs(me->par_value[PAR_DESCRIPTION], fp);
diff --git a/WWW/Library/Implementation/HTioctl.h b/WWW/Library/Implementation/HTioctl.h
new file mode 100644
index 00000000..95e914e6
--- /dev/null
+++ b/WWW/Library/Implementation/HTioctl.h
@@ -0,0 +1,11 @@
+/*
+**  A routine to mimic the ioctl function for UCX.
+**  Bjorn S. Nilsson, 25-Nov-1993. Based on an example in the UCX manual.
+*/
+#include <iodef.h>
+#define IOC_OUT (int)0x40000000
+extern int vaxc$get_sdc(), sys$qiow();
+
+#ifndef UCX$C_IOCTL
+#define UCX$C_IOCTL TCPIP$C_IOCTL
+#endif
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index be3bdc33..fdc492b1 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -82,7 +82,7 @@ PRIVATE void fake_put_character ARGS2(
     if (ch->size >= ch->allocated) {\
 	ch->allocated = ch->allocated + ch->growby;\
 	ch->data = ch->data ? (char *)realloc(ch->data, ch->allocated)\
-			    : (char *)calloc(1, ch->allocated);\
+			    : typecallocn(char, ch->allocated);\
       if (!ch->data)\
 	  outofmem(__FILE__, "HTChunkPutc");\
     }\
diff --git a/WWW/Library/Implementation/makefile.in b/WWW/Library/Implementation/makefile.in
index 5d149785..3cea574d 100644
--- a/WWW/Library/Implementation/makefile.in
+++ b/WWW/Library/Implementation/makefile.in
@@ -19,6 +19,7 @@ LYFLAGS		= # FIXME: set in parent makefile
 CC		= @CC@
 DEFS		= @DEFS@
 CPPFLAGS	= @CPPFLAGS@
+_O		= .o
 
 INTLDIR_CPPFLAGS= @INTLDIR_CPPFLAGS@ -I$(top_srcdir)/intl
 
@@ -78,7 +79,7 @@ LOB = .
 #  uncomment these and fill in WAISINC for adding direct wais access
 #  to Lynx.
 #HTWAIS_c = $(CMN)/HTWAIS.c
-#HTWAIS_o = $(LOB)/HTWAIS.o
+#HTWAIS_o = $(LOB)/HTWAIS$(_O)
 #WAIS = YES
 #WAISINC = -I../../../../freeWAIS-0.202/ir
 #WAISCFLAGS = -DDIRECT_WAIS
@@ -91,21 +92,21 @@ CFLAGS2 = $(CFLAGS) $(LYFLAGS) $(WAISCFLAGS) -I$(CMN) -DXMOSAIC_HACK -DACCESS_AU
 
 COMPILE	= $(ECHO) $(CC) $(CFLAGS2) -c
 
-COMMON = $(LOB)/HTParse.o $(LOB)/HTAccess.o $(LOB)/HTTP.o \
-	$(LOB)/HTFile.o	$(LOB)/HTBTree.o $(LOB)/HTFTP.o $(LOB)/HTTCP.o \
-	$(LOB)/SGML.o $(LOB)/HTMLDTD.o $(LOB)/HTChunk.o \
-	$(LOB)/HTPlain.o \
-	$(LOB)/HTMLGen.o \
-	$(LOB)/HTAtom.o $(LOB)/HTAnchor.o $(LOB)/HTStyle.o \
-	$(LOB)/HTList.o $(LOB)/HTString.o \
-	$(LOB)/HTRules.o $(LOB)/HTFormat.o  $(LOB)/HTMIME.o \
-	$(LOB)/HTNews.o  $(LOB)/HTGopher.o \
-	$(LOB)/HTTelnet.o $(LOB)/HTFinger.o $(LOB)/HTWSRC.o $(HTWAIS_o) \
-	$(LOB)/HTAAUtil.o $(LOB)/HTAABrow.o \
-	$(LOB)/HTGroup.o \
-	$(LOB)/HTAAProt.o \
-	$(LOB)/HTAssoc.o  $(LOB)/HTLex.o    $(LOB)/HTUU.o \
-	$(LOB)/HTDOS.o
+COMMON = $(LOB)/HTParse$(_O) $(LOB)/HTAccess$(_O) $(LOB)/HTTP$(_O) \
+	$(LOB)/HTFile$(_O)	$(LOB)/HTBTree$(_O) $(LOB)/HTFTP$(_O) $(LOB)/HTTCP$(_O) \
+	$(LOB)/SGML$(_O) $(LOB)/HTMLDTD$(_O) $(LOB)/HTChunk$(_O) \
+	$(LOB)/HTPlain$(_O) \
+	$(LOB)/HTMLGen$(_O) \
+	$(LOB)/HTAtom$(_O) $(LOB)/HTAnchor$(_O) $(LOB)/HTStyle$(_O) \
+	$(LOB)/HTList$(_O) $(LOB)/HTString$(_O) \
+	$(LOB)/HTRules$(_O) $(LOB)/HTFormat$(_O)  $(LOB)/HTMIME$(_O) \
+	$(LOB)/HTNews$(_O)  $(LOB)/HTGopher$(_O) \
+	$(LOB)/HTTelnet$(_O) $(LOB)/HTFinger$(_O) $(LOB)/HTWSRC$(_O) $(HTWAIS_o) \
+	$(LOB)/HTAAUtil$(_O) $(LOB)/HTAABrow$(_O) \
+	$(LOB)/HTGroup$(_O) \
+	$(LOB)/HTAAProt$(_O) \
+	$(LOB)/HTAssoc$(_O)  $(LOB)/HTLex$(_O)    $(LOB)/HTUU$(_O) \
+	$(LOB)/HTDOS$(_O)
 
 CFILES = $(CMN)HTParse.c $(CMN)HTAccess.c $(CMN)HTTP.c $(CMN)HTFile.c \
 	$(CMN)HTBTree.c \
@@ -148,9 +149,9 @@ all : $(LOB)/libwww.a
 lint:
 	$(LINT) $(LINTOPTS) $(CPPOPTS) $(srcdir)/../Implementation/*.c  > ../../../lint.libwww
 
-.SUFFIXES: .i .h .html
+.SUFFIXES: $(_O) .i .h .html
 
-.c.o:
+.c$(_O):
 @RULE_CC@
 	@ECHO_CC@$(CC) $(CPPOPTS) $(CFLAGS) -c $(srcdir)/$*.c
 
@@ -172,135 +173,135 @@ $(LOB)/libwww.a : $(COMMON)
 #	Clean up everything generatable except final products
 clean :
 	rm -f core *.core *.leaks *.[oi] *.bak tags TAGS
-	rm $(LOB)/*.o
+	rm $(LOB)/*$(_O)
 
 #			Common code
 #			-----------
 
-$(LOB)/HTList.o : $(OE) $(CMN)HTList.c $(CMN)HTUtils.h $(CMN)HTList.h
+$(LOB)/HTList$(_O) : $(OE) $(CMN)HTList.c $(CMN)HTUtils.h $(CMN)HTList.h
 	$(COMPILE) $(CMN)HTList.c
 
-$(LOB)/HTAnchor.o : $(OE) $(CMN)HTAnchor.c $(CMN)HTUtils.h $(CMN)HTList.h
+$(LOB)/HTAnchor$(_O) : $(OE) $(CMN)HTAnchor.c $(CMN)HTUtils.h $(CMN)HTList.h
 	$(COMPILE) $(CMN)HTAnchor.c
 
-$(LOB)/HTFormat.o : $(OE) $(CMN)HTFormat.c $(CMN)HTUtils.h $(CMN)HTList.h
+$(LOB)/HTFormat$(_O) : $(OE) $(CMN)HTFormat.c $(CMN)HTUtils.h $(CMN)HTList.h
 	$(COMPILE) $(CMN)HTFormat.c
 
-$(LOB)/HTMIME.o : $(OE) $(CMN)HTMIME.c $(CMN)HTUtils.h $(CMN)HTList.h
+$(LOB)/HTMIME$(_O) : $(OE) $(CMN)HTMIME.c $(CMN)HTUtils.h $(CMN)HTList.h
 	$(COMPILE) $(CMN)HTMIME.c
 
-$(LOB)/HTNews.o : $(OE) $(CMN)HTNews.c $(CMN)HTUtils.h $(CMN)HTList.h\
+$(LOB)/HTNews$(_O) : $(OE) $(CMN)HTNews.c $(CMN)HTUtils.h $(CMN)HTList.h\
 	 $(CMN)HTMLDTD.h
 	$(COMPILE) $(CMN)HTNews.c
 
-$(LOB)/HTGopher.o : $(OE) $(CMN)HTGopher.c $(CMN)HTUtils.h $(CMN)HTList.h \
+$(LOB)/HTGopher$(_O) : $(OE) $(CMN)HTGopher.c $(CMN)HTUtils.h $(CMN)HTList.h \
 	 $(CMN)HTMLDTD.h
 	$(COMPILE) $(CMN)HTGopher.c
 
-$(LOB)/HTTelnet.o : $(OE) $(CMN)HTTelnet.c $(CMN)HTUtils.h $(CMN)HTTelnet.h $(CMN)../../../userdefs.h
+$(LOB)/HTTelnet$(_O) : $(OE) $(CMN)HTTelnet.c $(CMN)HTUtils.h $(CMN)HTTelnet.h $(CMN)../../../userdefs.h
 	$(COMPILE) $(CMN)HTTelnet.c
 
-$(LOB)/HTFinger.o : $(OE) $(CMN)HTFinger.c $(CMN)HTUtils.h $(CMN)HTList.h \
+$(LOB)/HTFinger$(_O) : $(OE) $(CMN)HTFinger.c $(CMN)HTUtils.h $(CMN)HTList.h \
 	$(CMN)HTMLDTD.h
 	$(COMPILE) $(CMN)HTFinger.c
 
-$(LOB)/HTStyle.o : $(OE) $(CMN)HTStyle.c $(CMN)HTUtils.h
+$(LOB)/HTStyle$(_O) : $(OE) $(CMN)HTStyle.c $(CMN)HTUtils.h
 	$(COMPILE) $(CMN)HTStyle.c
 
-$(LOB)/HTAtom.o : $(OE) $(CMN)HTAtom.c $(CMN)HTUtils.h $(CMN)HTList.h
+$(LOB)/HTAtom$(_O) : $(OE) $(CMN)HTAtom.c $(CMN)HTUtils.h $(CMN)HTList.h
 	$(COMPILE) $(CMN)HTAtom.c
 
-$(LOB)/HTChunk.o : $(OE) $(CMN)HTChunk.c $(CMN)HTUtils.h
+$(LOB)/HTChunk$(_O) : $(OE) $(CMN)HTChunk.c $(CMN)HTUtils.h
 	$(COMPILE) $(CMN)HTChunk.c
 
-$(LOB)/HTString.o : $(OE) $(CMN)HTString.c $(CMN)HTUtils.h $(CMN)Version.make
+$(LOB)/HTString$(_O) : $(OE) $(CMN)HTString.c $(CMN)HTUtils.h $(CMN)Version.make
 	$(COMPILE) -DVC=\"$(VC)\" $(CMN)HTString.c
 
-$(LOB)/HTRules.o : $(OE) $(CMN)HTRules.c $(CMN)HTUtils.h $(CMN)Version.make \
+$(LOB)/HTRules$(_O) : $(OE) $(CMN)HTRules.c $(CMN)HTUtils.h $(CMN)Version.make \
 	 $(CMN)HTAAProt.h
 	$(COMPILE) -DVC=\"$(VC)\" $(CMN)HTRules.c
 
-$(LOB)/SGML.o : $(OE) $(CMN)SGML.c $(CMN)HTUtils.h $(CMN)UCAux.h
+$(LOB)/SGML$(_O) : $(OE) $(CMN)SGML.c $(CMN)HTUtils.h $(CMN)UCAux.h
 	$(COMPILE) $(CMN)SGML.c
 
-$(LOB)/HTMLGen.o : $(OE) $(CMN)HTMLGen.c $(CMN)HTUtils.h $(CMN)HTMLDTD.h
+$(LOB)/HTMLGen$(_O) : $(OE) $(CMN)HTMLGen.c $(CMN)HTUtils.h $(CMN)HTMLDTD.h
 	$(COMPILE) $(CMN)HTMLGen.c
 
-$(LOB)/HTMLDTD.o : $(OE) $(CMN)HTMLDTD.c $(CMN)SGML.h
+$(LOB)/HTMLDTD$(_O) : $(OE) $(CMN)HTMLDTD.c $(CMN)SGML.h
 	$(COMPILE) $(CMN)HTMLDTD.c
 
-$(LOB)/HTPlain.o : $(OE) $(CMN)HTPlain.c $(CMN)HTPlain.h $(CMN)HTStream.h \
+$(LOB)/HTPlain$(_O) : $(OE) $(CMN)HTPlain.c $(CMN)HTPlain.h $(CMN)HTStream.h \
 	 $(CMN)UCAux.h
 	$(COMPILE) $(CMN)HTPlain.c
 
-$(LOB)/HTWAIS.o : $(OE) $(CMN)HTWAIS.c $(CMN)HTUtils.h $(CMN)HTList.h
+$(LOB)/HTWAIS$(_O) : $(OE) $(CMN)HTWAIS.c $(CMN)HTUtils.h $(CMN)HTList.h
 	$(COMPILE) $(WAISINC) $(CMN)HTWAIS.c
 
-$(LOB)/HTWSRC.o : $(OE) $(CMN)HTWSRC.c $(CMN)HTUtils.h $(CMN)HTList.h
+$(LOB)/HTWSRC$(_O) : $(OE) $(CMN)HTWSRC.c $(CMN)HTUtils.h $(CMN)HTList.h
 	$(COMPILE) $(CMN)HTWSRC.c
 
 #	Access Authorization
 
-$(LOB)/HTAAUtil.o : $(OE) $(CMN)HTAAUtil.c $(CMN)HTAAUtil.h \
+$(LOB)/HTAAUtil$(_O) : $(OE) $(CMN)HTAAUtil.c $(CMN)HTAAUtil.h \
 	 $(CMN)HTUtils.h $(CMN)HTString.h
 	$(COMPILE) $(CMN)HTAAUtil.c
 
-$(LOB)/HTGroup.o : $(OE) $(CMN)HTGroup.c $(CMN)HTGroup.h \
+$(LOB)/HTGroup$(_O) : $(OE) $(CMN)HTGroup.c $(CMN)HTGroup.h \
 	 $(CMN)HTAAUtil.h \
 	 $(CMN)HTAssoc.h $(CMN)HTLex.h
 	$(COMPILE) $(CMN)HTGroup.c
 
-$(LOB)/HTAABrow.o : $(OE) $(CMN)HTAABrow.c $(CMN)HTAABrow.h \
+$(LOB)/HTAABrow$(_O) : $(OE) $(CMN)HTAABrow.c $(CMN)HTAABrow.h \
 	 $(CMN)HTAAUtil.h $(CMN)HTUU.h \
 	 $(CMN)HTUtils.h $(CMN)HTString.h \
 	 $(CMN)HTParse.h $(CMN)HTList.h \
 	 $(CMN)HTAssoc.h
 	$(COMPILE) $(CMN)HTAABrow.c
 
-$(LOB)/HTAAProt.o : $(OE) $(CMN)HTAAProt.c $(CMN)HTAAProt.h \
+$(LOB)/HTAAProt$(_O) : $(OE) $(CMN)HTAAProt.c $(CMN)HTAAProt.h \
 	 $(CMN)HTUtils.h $(CMN)HTAAUtil.h \
 	 $(CMN)HTAssoc.h $(CMN)HTLex.h
 	$(COMPILE) $(CMN)HTAAProt.c
 
-$(LOB)/HTAssoc.o : $(OE) $(CMN)HTAssoc.c $(CMN)HTAssoc.h \
+$(LOB)/HTAssoc$(_O) : $(OE) $(CMN)HTAssoc.c $(CMN)HTAssoc.h \
 	$(CMN)HTUtils.h $(CMN)HTString.h $(CMN)HTList.h
 	$(COMPILE) $(CMN)HTAssoc.c
 
-$(LOB)/HTLex.o : $(OE) $(CMN)HTLex.c $(CMN)HTLex.h $(CMN)HTUtils.h
+$(LOB)/HTLex$(_O) : $(OE) $(CMN)HTLex.c $(CMN)HTLex.h $(CMN)HTUtils.h
 	$(COMPILE) $(CMN)HTLex.c
 
-$(LOB)/HTUU.o : $(OE) $(CMN)HTUU.c $(CMN)HTUU.h $(CMN)HTUtils.h
+$(LOB)/HTUU$(_O) : $(OE) $(CMN)HTUU.c $(CMN)HTUU.h $(CMN)HTUtils.h
 	$(COMPILE) $(CMN)HTUU.c
 
 
 #	Communications & Files
 
-$(LOB)/HTTP.o : $(OE) $(CMN)HTTP.c $(CMN)HTUtils.h $(CMN)HTAABrow.h
+$(LOB)/HTTP$(_O) : $(OE) $(CMN)HTTP.c $(CMN)HTUtils.h $(CMN)HTAABrow.h
 	$(COMPILE) $(CMN)HTTP.c
 
-$(LOB)/HTTCP.o : $(OE) $(CMN)HTTCP.c $(CMN)HTUtils.h
+$(LOB)/HTTCP$(_O) : $(OE) $(CMN)HTTCP.c $(CMN)HTUtils.h
 	$(COMPILE) $(CMN)HTTCP.c
 
-$(LOB)/HTFile.o : $(OE) $(CMN)HTFile.c $(CMN)HTUtils.h \
+$(LOB)/HTFile$(_O) : $(OE) $(CMN)HTFile.c $(CMN)HTUtils.h \
 	 $(CMN)HTMLDTD.h
 	$(COMPILE) $(CMN)HTFile.c
 
-$(LOB)/HTBTree.o : $(OE) $(CMN)HTBTree.c $(CMN)HTUtils.h
+$(LOB)/HTBTree$(_O) : $(OE) $(CMN)HTBTree.c $(CMN)HTUtils.h
 	$(COMPILE) $(CMN)HTBTree.c
 
-$(LOB)/HTFTP.o : $(OE) $(CMN)HTFTP.c $(CMN)HTUtils.h
+$(LOB)/HTFTP$(_O) : $(OE) $(CMN)HTFTP.c $(CMN)HTUtils.h
 	$(COMPILE) $(CMN)HTFTP.c
 
-$(LOB)/HTAccess.o : $(OE)  $(CMN)HTAccess.c $(CMN)HTUtils.h
+$(LOB)/HTAccess$(_O) : $(OE)  $(CMN)HTAccess.c $(CMN)HTUtils.h
 	$(COMPILE) $(CMN)HTAccess.c
 
-$(LOB)/HTParse.o : $(OE) $(CMN)HTParse.c $(CMN)HTUtils.h
+$(LOB)/HTParse$(_O) : $(OE) $(CMN)HTParse.c $(CMN)HTUtils.h
 	$(COMPILE) $(CMN)HTParse.c
 
-$(LOB)/HTVMS_WaisUI.o : $(OE) $(CMN)HTVMS_WaisUI.c $(CMN)HTUtils.h
+$(LOB)/HTVMS_WaisUI$(_O) : $(OE) $(CMN)HTVMS_WaisUI.c $(CMN)HTUtils.h
 	$(COMPILE) $(CMN)HTVMS_WaisUI.c
 
-$(LOB)/HTDOS.o : $(OE) $(CMN)HTDOS.c $(CMN)HTUtils.h
+$(LOB)/HTDOS$(_O) : $(OE) $(CMN)HTDOS.c $(CMN)HTUtils.h
 	$(COMPILE) $(CMN)HTDOS.c
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.