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>1998-04-23 12:35:00 -0400
committerThomas E. Dickey <dickey@invisible-island.net>1998-04-23 12:35:00 -0400
commit2a94396ccd9cf5ade728c53e02cba28e06af4378 (patch)
tree0ee1558f3e81f97725d83250f944aafa4eb43d54 /WWW/Library/Implementation
parent84271e583d80f546251ea914a33f8c537fddbac7 (diff)
downloadlynx-snapshots-2a94396ccd9cf5ade728c53e02cba28e06af4378.tar.gz
snapshot of project "lynx", label v2-8-1dev_7
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r--WWW/Library/Implementation/HTAABrow.c71
-rw-r--r--WWW/Library/Implementation/HTAAProt.c121
-rw-r--r--WWW/Library/Implementation/HTAAServ.c129
-rw-r--r--WWW/Library/Implementation/HTAAUtil.c15
-rw-r--r--WWW/Library/Implementation/HTACL.c18
-rw-r--r--WWW/Library/Implementation/HTAccess.c100
-rw-r--r--WWW/Library/Implementation/HTAnchor.c29
-rw-r--r--WWW/Library/Implementation/HTAssoc.c4
-rw-r--r--WWW/Library/Implementation/HTAtom.c6
-rw-r--r--WWW/Library/Implementation/HTAuth.c18
-rw-r--r--WWW/Library/Implementation/HTFTP.c319
-rw-r--r--WWW/Library/Implementation/HTFWriter.c3
-rw-r--r--WWW/Library/Implementation/HTFile.c88
-rw-r--r--WWW/Library/Implementation/HTFinger.c37
-rw-r--r--WWW/Library/Implementation/HTFormat.c74
-rw-r--r--WWW/Library/Implementation/HTGopher.c72
-rw-r--r--WWW/Library/Implementation/HTGroup.c60
-rw-r--r--WWW/Library/Implementation/HTHistory.c18
-rw-r--r--WWW/Library/Implementation/HTList.c17
-rw-r--r--WWW/Library/Implementation/HTMIME.c541
-rw-r--r--WWW/Library/Implementation/HTMLDTD.c2
-rw-r--r--WWW/Library/Implementation/HTNews.c127
-rw-r--r--WWW/Library/Implementation/HTParse.c25
-rw-r--r--WWW/Library/Implementation/HTPasswd.c16
-rw-r--r--WWW/Library/Implementation/HTPlain.c15
-rw-r--r--WWW/Library/Implementation/HTRules.c152
-rw-r--r--WWW/Library/Implementation/HTStyle.c10
-rw-r--r--WWW/Library/Implementation/HTTCP.c105
-rw-r--r--WWW/Library/Implementation/HTTP.c156
-rw-r--r--WWW/Library/Implementation/HTTelnet.c46
-rw-r--r--WWW/Library/Implementation/HTUtils.h11
-rw-r--r--WWW/Library/Implementation/HTVMSUtils.c24
-rw-r--r--WWW/Library/Implementation/HTWAIS.c67
-rw-r--r--WWW/Library/Implementation/HTWSRC.c5
-rw-r--r--WWW/Library/Implementation/HTWriter.c6
-rw-r--r--WWW/Library/Implementation/SGML.c188
36 files changed, 941 insertions, 1754 deletions
diff --git a/WWW/Library/Implementation/HTAABrow.c b/WWW/Library/Implementation/HTAABrow.c
index 38c6ca50..1be48c4a 100644
--- a/WWW/Library/Implementation/HTAABrow.c
+++ b/WWW/Library/Implementation/HTAABrow.c
@@ -341,32 +341,29 @@ PRIVATE HTAASetup *HTAASetup_lookup ARGS4(
 
 	HTList *cur = server->setups;
 
-	if (TRACE)
-	    fprintf(stderr, "%s %s (%s:%d:%s)\n",
-			    "HTAASetup_lookup: resolving setup for",
-			    (IsProxy ? "proxy" : "server"),
-			    hostname, portnumber, docname);
+	CTRACE(tfp, "%s %s (%s:%d:%s)\n",
+		    "HTAASetup_lookup: resolving setup for",
+		    (IsProxy ? "proxy" : "server"),
+		    hostname, portnumber, docname);
 
 	while (NULL != (setup = (HTAASetup*)HTList_nextObject(cur))) {
 	    if (HTAA_templateMatch(setup->template, docname)) {
-		if (TRACE)
-		    fprintf(stderr, "%s `%s' %s `%s'\n",
-				    "HTAASetup_lookup:", docname,
-				    "matched template", setup->template);
+		CTRACE(tfp, "%s `%s' %s `%s'\n",
+			    "HTAASetup_lookup:", docname,
+			    "matched template", setup->template);
 		return setup;
+	    } else {
+	        CTRACE(tfp, "%s `%s' %s `%s'\n",
+			    "HTAASetup_lookup:", docname,
+			    "did NOT match template", setup->template);
 	    }
-	    else if (TRACE)
-	        fprintf(stderr, "%s `%s' %s `%s'\n",
-				"HTAASetup_lookup:", docname,
-				"did NOT match template", setup->template);
 	} /* while setups remain */
     } /* if valid parameters and server found */
 
-    if (TRACE)
-        fprintf(stderr, "%s `%s' %s\n",
-		        "HTAASetup_lookup: No template matched",
-		        (docname ? docname : "(null)"),
-		        "(so probably not protected)");
+    CTRACE(tfp, "%s `%s' %s\n",
+		 "HTAASetup_lookup: No template matched",
+		 (docname ? docname : "(null)"),
+		 "(so probably not protected)");
 
     return NULL;	/* NULL in parameters, or not found */
 }
@@ -605,10 +602,9 @@ PRIVATE char *compose_auth_string ARGS3(
     	  realm->username && *realm->username &&
 	  realm->password) || setup->retry) { 
 	if (!realm) {
-	    if (TRACE)
-	        fprintf(stderr, "%s `%s' %s\n",
-			        "compose_auth_string: realm:", realmname,
-			        "not found -- creating");
+	    CTRACE(tfp, "%s `%s' %s\n",
+			"compose_auth_string: realm:", realmname,
+			"not found -- creating");
 	    realm = HTAARealm_new(setup->server->realms,
 				  realmname, NULL, NULL);
 	}
@@ -860,9 +856,8 @@ PUBLIC char *HTAA_composeAuth ARGS4(
     **  on server-side.  Life is hard.)
     */
     if (HTAAForwardAuth) {
-	if (TRACE)
-	    fprintf(stderr, "HTAA_composeAuth: %s\n",
-			    "Forwarding received authorization");
+	CTRACE(tfp, "HTAA_composeAuth: %s\n",
+		    "Forwarding received authorization");
 	StrAllocCopy(HTAA_composeAuthResult, HTAAForwardAuth);
 	HTAAForwardAuth_reset();	/* Just a precaution */
 	return HTAA_composeAuthResult;
@@ -875,9 +870,7 @@ PUBLIC char *HTAA_composeAuth ARGS4(
 	**  Proxy Authorization required. - AJL
 	*/
 
-	if (TRACE)
-	    fprintf(stderr, 
-		    "Composing Proxy Authorization for %s:%d/%s\n",
+	CTRACE(tfp, "Composing Proxy Authorization for %s:%d/%s\n",
 		    hostname, portnumber, docname);
 
 	if (proxy_portnumber != portnumber ||
@@ -952,9 +945,7 @@ PUBLIC char *HTAA_composeAuth ARGS4(
 	/*
 	**  Normal WWW authorization.
 	*/
-	if (TRACE)
-	    fprintf(stderr, 
-		    "Composing Authorization for %s:%d/%s\n",
+	CTRACE(tfp, "Composing Authorization for %s:%d/%s\n",
 		    hostname, portnumber, docname);
 
 	if (current_portnumber != portnumber ||
@@ -1087,13 +1078,11 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS5(
     /*
     **  Read server reply header lines
     */
-    if (TRACE)
-	fprintf(stderr, "Server reply header lines:\n");
+    CTRACE(tfp, "Server reply header lines:\n");
 
     HTAA_setupReader(start_of_headers, length, handle, soc);
     while (NULL != (line = HTAA_getUnfoldedLine())  &&  *line != '\0') {
-	if (TRACE)
-	    fprintf(stderr, "%s\n", line);
+	CTRACE(tfp, "%s\n", line);
 
 	if (strchr(line, ':')) {	/* Valid header line */
 
@@ -1133,9 +1122,8 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS5(
 		    }
 		    scheme_specifics[scheme] = HTAA_parseArgList(args);
 		    num_schemes++;
-		}
-		else if (TRACE) {
-		    fprintf(stderr, "Unknown scheme `%s' %s\n",
+		} else {
+		    CTRACE(tfp, "Unknown scheme `%s' %s\n",
 			    (arg1 ? arg1 : "(null)"),
 			    (IsProxy ?
 			     "in Proxy-Authenticate: field" :
@@ -1145,14 +1133,13 @@ PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS5(
 
 	    else if (!IsProxy &&
 		     0==strcasecomp(fieldname, "WWW-Protection-Template:")) {
-		if (TRACE)
-		    fprintf(stderr, "Protection template set to `%s'\n", arg1);
+		CTRACE(tfp, "Protection template set to `%s'\n", arg1);
 		StrAllocCopy(template, arg1);
 	    }
 
 	} /* if a valid header line */
-	else if (TRACE) {
-	    fprintf(stderr, "Invalid header line `%s' ignored\n", line);
+	else {
+	    CTRACE(tfp, "Invalid header line `%s' ignored\n", line);
 	} /* else invalid header line */
 
 	FREE(line);
diff --git a/WWW/Library/Implementation/HTAAProt.c b/WWW/Library/Implementation/HTAAProt.c
index 6bf8ab3f..e1d6f61f 100644
--- a/WWW/Library/Implementation/HTAAProt.c
+++ b/WWW/Library/Implementation/HTAAProt.c
@@ -125,22 +125,21 @@ PUBLIC int HTAA_getUid NOARGS
     if (current_prot  &&  current_prot->uid_name) {
 	if (isNumber(current_prot->uid_name)) {
 	    if (NULL != (pw = getpwuid(atoi(current_prot->uid_name)))) {
-		if (TRACE) fprintf(stderr, 
-				   "%s(%s) returned (%s:%s:%d:%d:...)\n",
-				   "HTAA_getUid: getpwuid",
-				   current_prot->uid_name,
-				   pw->pw_name, pw->pw_passwd,
-				   pw->pw_uid, pw->pw_gid);
+		CTRACE(tfp, "%s(%s) returned (%s:%s:%d:%d:...)\n",
+			    "HTAA_getUid: getpwuid",
+			    current_prot->uid_name,
+			    pw->pw_name, pw->pw_passwd,
+			    pw->pw_uid, pw->pw_gid);
 		return pw->pw_uid;	
 	    }
 	}
 	else {	/* User name (not a number) */
 	    if (NULL != (pw = getpwnam(current_prot->uid_name))) {
-		if (TRACE) fprintf(stderr, "%s(\"%s\") %s (%s:%s:%d:%d:...)\n",
-				   "HTAA_getUid: getpwnam",
-				   current_prot->uid_name, "returned",
-				   pw->pw_name, pw->pw_passwd,
-				   pw->pw_uid, pw->pw_gid);
+		CTRACE(tfp, "%s(\"%s\") %s (%s:%s:%d:%d:...)\n",
+			    "HTAA_getUid: getpwnam",
+			    current_prot->uid_name, "returned",
+			    pw->pw_name, pw->pw_passwd,
+			    pw->pw_uid, pw->pw_gid);
 		return pw->pw_uid;
 	    }
 	}
@@ -149,8 +148,8 @@ PUBLIC int HTAA_getUid NOARGS
     ** Ok, then let's get uid for nobody.
     */
     if (NULL != (pw = getpwnam("nobody"))) {
-	if (TRACE) fprintf(stderr, "HTAA_getUid: Uid for `nobody' is %d\n",
-			   pw->pw_uid);
+	CTRACE(tfp, "HTAA_getUid: Uid for `nobody' is %d\n",
+		    pw->pw_uid);
 	return pw->pw_uid;
     }
     /*
@@ -177,11 +176,10 @@ PUBLIC int HTAA_getGid NOARGS
 	if (isNumber(current_prot->gid_name)) {
 	    if (NULL != (gr = getgrgid(atoi(current_prot->gid_name)))) {
 #ifndef __EMX__	/* no gr_passwd */
-		if (TRACE) fprintf(stderr,
-				   "%s(%s) returned (%s:%s:%d:...)\n",
-				   "HTAA_getGid: getgrgid",
-				   current_prot->gid_name,
-				   gr->gr_name, gr->gr_passwd, gr->gr_gid);
+		CTRACE(tfp, "%s(%s) returned (%s:%s:%d:...)\n",
+			    "HTAA_getGid: getgrgid",
+			    current_prot->gid_name,
+			    gr->gr_name, gr->gr_passwd, gr->gr_gid);
 #endif
 		return gr->gr_gid;
 	    }
@@ -189,11 +187,10 @@ PUBLIC int HTAA_getGid NOARGS
 	else {	/* Group name (not number) */
 	    if (NULL != (gr = getgrnam(current_prot->gid_name))) {
 #ifndef __EMX__	/* no gr_passwd */
-		if (TRACE) fprintf(stderr, 
-				   "%s(\"%s\") returned (%s:%s:%d:...)\n",
-				   "HTAA_getGid: getgrnam",
-				   current_prot->gid_name,
-				   gr->gr_name, gr->gr_passwd, gr->gr_gid);
+		CTRACE(tfp, "%s(\"%s\") returned (%s:%s:%d:...)\n",
+			    "HTAA_getGid: getgrnam",
+			    current_prot->gid_name,
+			    gr->gr_name, gr->gr_passwd, gr->gr_gid);
 #endif
 		return gr->gr_gid;
 	    }
@@ -203,8 +200,8 @@ PUBLIC int HTAA_getGid NOARGS
     ** Ok, then let's get gid for nogroup.
     */
     if (NULL != (gr = getgrnam("nogroup"))) {
-	if (TRACE) fprintf(stderr, "HTAA_getGid: Gid for `nogroup' is %d\n",
-			   gr->gr_gid);
+	CTRACE(tfp, "HTAA_getGid: Gid for `nogroup' is %d\n",
+		    gr->gr_gid);
 	return gr->gr_gid;
     }
     /*
@@ -294,15 +291,16 @@ PRIVATE void HTAA_parseProtFile ARGS2(HTAAProt *, prot,
 			    if (!prot->valid_schemes)
 				prot->valid_schemes = HTList_new();
 			    HTList_addObject(prot->valid_schemes,(void*)scheme);
-			    if (TRACE) fprintf(stderr, "%s %s `%s'\n",
-					       "HTAA_parseProtFile: valid",
-					       "authentication scheme:",
-					       HTAAScheme_name(scheme));
+			    CTRACE(tfp, "%s %s `%s'\n",
+				        "HTAA_parseProtFile: valid",
+				        "authentication scheme:",
+				        HTAAScheme_name(scheme));
+			} else {
+			    CTRACE(tfp, "%s %s `%s'\n",
+					"HTAA_parseProtFile: unknown",
+					"authentication scheme:",
+					HTlex_buffer);
 			}
-			else if (TRACE) fprintf(stderr, "%s %s `%s'\n",
-						"HTAA_parseProtFile: unknown",
-						"authentication scheme:",
-						HTlex_buffer);
 			
 			if (LEX_ITEM_SEP != (lex_item = lex(fp)))
 			    break;
@@ -322,10 +320,10 @@ PRIVATE void HTAA_parseProtFile ARGS2(HTAAProt *, prot,
 		    lex_item=LEX_REC_SEP; /*groupdef parser read this already*/
 		    if (TRACE) {
 			if (prot->mask_group) {
-			    fprintf(stderr,
+			    fprintf(tfp,
 				    "HTAA_parseProtFile: Mask group:\n");
 			    HTAA_printGroupDef(prot->mask_group);
-			} else fprintf(stderr, "HTAA_parseProtFile: %s\n",
+			} else fprintf(tfp, "HTAA_parseProtFile: %s\n",
 				       "Mask group syntax error");
 		    }
 		} /* if "Mask" */
@@ -337,20 +335,19 @@ PRIVATE void HTAA_parseProtFile ARGS2(HTAAProt *, prot,
 			    prot->values = HTAssocList_new();
 			HTAssocList_add(prot->values, fieldname, HTlex_buffer);
 			lex_item = lex(fp);  /* Read record separator */
-			if (TRACE) fprintf(stderr, 
-					   "%s `%s' bound to value `%s'\n",
-					   "HTAA_parseProtFile: Name",
-					   fieldname, HTlex_buffer);
+			CTRACE(tfp, "%s `%s' bound to value `%s'\n",
+				    "HTAA_parseProtFile: Name",
+				    fieldname, HTlex_buffer);
 		    }
 		} /* else name-value pair */
 
 	    } /* if valid field */
 
 	    if (lex_item != LEX_EOF  &&  lex_item != LEX_REC_SEP) {
-		if (TRACE) fprintf(stderr, "%s %s %d (that line ignored)\n",
-				   "HTAA_parseProtFile: Syntax error",
-				   "in protection setup file at line",
-				   HTlex_line);
+		CTRACE(tfp, "%s %s %d (that line ignored)\n",
+			    "HTAA_parseProtFile: Syntax error",
+			    "in protection setup file at line",
+			    HTlex_line);
 		do {
 		    lex_item = lex(fp);
 		} while (lex_item != LEX_EOF && lex_item != LEX_REC_SEP);
@@ -405,12 +402,11 @@ PRIVATE HTAAProt *HTAAProt_new ARGS3(CONST char *,	cur_docname,
     }
     if (cache_item) {
 	prot = cache_item->prot;
-	if (TRACE) fprintf(stderr, "%s `%s' already in cache\n",
-			   "HTAAProt_new: Protection file", prot_filename);
+	CTRACE(tfp, "%s `%s' already in cache\n",
+		    "HTAAProt_new: Protection file", prot_filename);
     } else {
-	if (TRACE) fprintf(stderr,
-			   "HTAAProt_new: Loading protection file `%s'\n",
-			   prot_filename);
+	CTRACE(tfp, "HTAAProt_new: Loading protection file `%s'\n",
+		    prot_filename);
 
 	if (!(prot = (HTAAProt*)calloc(1, sizeof(HTAAProt))))
 	    outofmem(__FILE__, "HTAAProt_new");
@@ -433,10 +429,11 @@ PRIVATE HTAAProt *HTAAProt_new ARGS3(CONST char *,	cur_docname,
 	    cache_item->prot_filename = NULL;
 	    StrAllocCopy(cache_item->prot_filename, prot_filename);
 	    HTList_addObject(prot_cache, (void*)cache_item);
+	} else {
+	    CTRACE(tfp, "HTAAProt_new: %s `%s'\n",
+			"Unable to open protection setup file",
+			(prot_filename ? prot_filename : "(null)"));
 	}
-	else if (TRACE) fprintf(stderr, "HTAAProt_new: %s `%s'\n",
-				"Unable to open protection setup file",
-				(prot_filename ? prot_filename : "(null)"));
     }
 
     if (cur_docname)
@@ -475,9 +472,9 @@ PUBLIC void HTAA_setDefaultProtection ARGS3(CONST char *,	cur_docname,
     if (prot_filename) {
 	default_prot = HTAAProt_new(cur_docname, prot_filename, ids);
     } else {
-	if (TRACE) fprintf(stderr, "%s %s\n",
-			   "HTAA_setDefaultProtection: ERROR: Protection file",
-			   "not specified (obligatory for DefProt rule)!!\n");
+	CTRACE(tfp, "%s %s\n",
+		    "HTAA_setDefaultProtection: ERROR: Protection file",
+		    "not specified (obligatory for DefProt rule)!!\n");
     }
 }
 
@@ -513,15 +510,15 @@ PUBLIC void HTAA_setCurrentProtection ARGS3(CONST char *,	cur_docname,
 	if (default_prot) {
 	    current_prot = default_prot;
 	    HTAA_setIds(current_prot, ids);
-	    if (TRACE) fprintf(stderr, "%s %s %s\n",
-			       "HTAA_setCurrentProtection: Protection file",
-			       "not specified for Protect rule",
-			       "-- using default protection");
+	    CTRACE(tfp, "%s %s %s\n",
+		        "HTAA_setCurrentProtection: Protection file",
+		        "not specified for Protect rule",
+		        "-- using default protection");
 	} else {
-	    if (TRACE) fprintf(stderr, "%s %s %s\n",
-			       "HTAA_setCurrentProtection: ERROR: Protection",
-			       "file not specified for Protect rule, and",
-			       "default protection is not set!!");
+	    CTRACE(tfp, "%s %s %s\n",
+		        "HTAA_setCurrentProtection: ERROR: Protection",
+		        "file not specified for Protect rule, and",
+		        "default protection is not set!!");
 	}
     }
 }
diff --git a/WWW/Library/Implementation/HTAAServ.c b/WWW/Library/Implementation/HTAAServ.c
index 98779830..5f61cb76 100644
--- a/WWW/Library/Implementation/HTAAServ.c
+++ b/WWW/Library/Implementation/HTAAServ.c
@@ -229,14 +229,12 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *,  pathname,
     htaa_user = NULL;
 
     if (!pathname) {
-	if (TRACE)
-	    fprintf(stderr, "HTAA_checkAuthorization: Forbidden by rule\n");
+	CTRACE(tfp, "HTAA_checkAuthorization: Forbidden by rule\n");
 	return HTAA_BY_RULE;
     }
-    if (TRACE)
-	fprintf(stderr, "%s `%s' %s %s\n",
-			"HTAA_checkAuthorization: translated path:",
-			pathname, "method:", HTAAMethod_name(method));
+    CTRACE(tfp, "%s `%s' %s %s\n",
+		"HTAA_checkAuthorization: translated path:",
+		pathname, "method:", HTAAMethod_name(method));
 
     /*
     ** Get protection setting (set up by callbacks from rule system)
@@ -263,10 +261,9 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *,  pathname,
 		    htaa_user = HTAA_authenticate(scheme,
 						  scheme_specifics,
 						  prot);
-		    if (TRACE)
-			fprintf(stderr, "Authentication returned: %s\n",
-					(htaa_user ? htaa_user->username
-						   : "NOT-AUTHENTICATED"));
+		    CTRACE(tfp, "Authentication returned: %s\n",
+				(htaa_user ? htaa_user->username
+					   : "NOT-AUTHENTICATED"));
 		}
 		HTAA_resolveGroupReferences(prot->mask_group, group_def_list);
 		reason = HTAA_userAndInetInGroup(prot->mask_group,
@@ -274,14 +271,13 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *,  pathname,
 						  ? htaa_user->username : "",
 						 HTClientHost,
 						 NULL);
-		if (TRACE) {
-		    if (reason != HTAA_OK)
-			fprintf(stderr, "%s %s %s %s\n",
+		if (reason != HTAA_OK) {
+		    CTRACE(tfp, "%s %s %s %s\n",
 				"HTAA_checkAuthorization: access denied",
 				"by mask (no ACL, only Protect rule)",
 				"host", HTClientHost);
-		    else
-			fprintf(stderr, "%s %s %s %s\n",
+		} else {
+		    CTRACE(tfp, "%s %s %s %s\n",
 				"HTAA_checkAuthorization: request from",
 				HTClientHost,
 				"accepted by only mask match (no ACL, only",
@@ -290,17 +286,15 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *,  pathname,
 		return reason;
 	    }
 	    else {	/* 403 Forbidden */
-		if (TRACE)
-		    fprintf(stderr, "%s %s\n",
-				    "HTAA_checkAuthorization: Protected, but",
-				    "no mask group nor ACL -- forbidden");
+		CTRACE(tfp, "%s %s\n",
+			    "HTAA_checkAuthorization: Protected, but",
+			    "no mask group nor ACL -- forbidden");
 		return HTAA_NO_ACL;
 	    }
 	}
 	else { /* No protect rule and no ACL => OK 200 */
-	    if (TRACE)
-		fprintf(stderr, "HTAA_checkAuthorization: %s\n",
-				"no protect rule nor ACL -- ok\n");
+	    CTRACE(tfp, "HTAA_checkAuthorization: %s\n",
+			"no protect rule nor ACL -- ok\n");
 	    return HTAA_OK;
 	}
     }
@@ -309,15 +303,13 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *,  pathname,
     ** Now we know that ACL exists
     */
     if (!prot) {		/* Not protected by "protect" rule */
-	if (TRACE)
-	    fprintf(stderr, "HTAA_checkAuthorization: default protection\n");
+	CTRACE(tfp, "HTAA_checkAuthorization: default protection\n");
 	prot = HTAA_getDefaultProtection(); /* Also sets current protection */
 
 	if (!prot) {		/* @@ Default protection not set ?? */
-	    if (TRACE)
-		fprintf(stderr, "%s %s\n",
-				"HTAA_checkAuthorization: default protection",
-				"not set (internal server error)!!");
+	    CTRACE(tfp, "%s %s\n",
+			"HTAA_checkAuthorization: default protection",
+			"not set (internal server error)!!");
 	    return HTAA_SETUP_ERROR;
 	}
     }
@@ -337,10 +329,9 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *,  pathname,
 	    htaa_user = HTAA_authenticate(scheme,
 					  scheme_specifics,
 					  prot);
-	    if (TRACE)
-		fprintf(stderr, "Authentication returned: %s\n",
-				(htaa_user
-				 ? htaa_user->username : "NOT-AUTHENTICATED"));
+	    CTRACE(tfp, "Authentication returned: %s\n",
+			(htaa_user
+			 ? htaa_user->username : "NOT-AUTHENTICATED"));
 	}
 	/*
 	** Check mask group
@@ -352,20 +343,18 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *,  pathname,
 					   HTClientHost,
 					   NULL);
 	    if (reason != HTAA_OK) {
-		if (TRACE)
-		    fprintf(stderr, "%s %s %s\n",
-				    "HTAA_checkAuthorization: access denied",
-				    "by mask, host:", HTClientHost);
+		CTRACE(tfp, "%s %s %s\n",
+			    "HTAA_checkAuthorization: access denied",
+			    "by mask, host:", HTClientHost);
 		return reason;
 	    }
 	    else {
-		if (TRACE)
-		    fprintf(stderr, "%s %s %s %s %s\n",
-				    "HTAA_checkAuthorization: request from",
-				    HTClientHost,
-				    "accepted by just mask group match",
-				    "(no ACL, only Protect rule, and only",
-				    "mask enabled)");
+		CTRACE(tfp, "%s %s %s %s %s\n",
+			    "HTAA_checkAuthorization: request from",
+			    HTClientHost,
+			    "accepted by just mask group match",
+			    "(no ACL, only Protect rule, and only",
+			    "mask enabled)");
 		/* And continue authorization checking */
 	    }
 	}
@@ -376,9 +365,8 @@ PRIVATE HTAAFailReasonType check_authorization ARGS4(CONST char *,  pathname,
 	*/
 	allowed_groups = HTAA_getAclEntry(acl_file, pathname, method);
 	if (!allowed_groups) {
-	    if (TRACE)
-		fprintf(stderr, "%s `%s' %s\n",
-				"No entry for file", pathname, "in ACL");
+	    CTRACE(tfp, "%s `%s' %s\n",
+			"No entry for file", pathname, "in ACL");
 	    HTAA_closeAcl(acl_file);
 	    return HTAA_NO_ENTRY;  /* Forbidden -- no entry in the ACL */
 	}
@@ -458,9 +446,8 @@ PUBLIC int HTAA_checkAuthorization ARGS4(CONST char *,	url,
     ** be a security hole.
     */
     if (strstr(local_copy, "/../")) {
-	if (TRACE)
-	    fprintf(stderr, "HTAA_checkAuthorization: %s (`%s')\n",
-			    "Illegal attempt to use /../", url);
+	CTRACE(tfp, "HTAA_checkAuthorization: %s (`%s')\n",
+		    "Illegal attempt to use /../", url);
 	HTAAFailReason = HTAA_DOTDOT;
     }
     else {
@@ -482,8 +469,7 @@ PUBLIC int HTAA_checkAuthorization ARGS4(CONST char *,	url,
 	}
 
 	if (!pathname) {		/* Forbidden by rule */
-	    if (TRACE)
-		fprintf(stderr, "HTAA_checkAuthorization: Forbidden by rule\n");
+	    CTRACE(tfp, "HTAA_checkAuthorization: Forbidden by rule\n");
 	    HTAAFailReason = HTAA_BY_RULE;
 	}
 	else if (HTAAFailReason != HTAA_HTBIN) {
@@ -500,9 +486,7 @@ PUBLIC int HTAA_checkAuthorization ARGS4(CONST char *,	url,
 	    }
 	    else {  /* Not local access */
 		HTAAFailReason = HTAA_OK_GATEWAY;
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTAA_checkAuthorization: %s (%s access)\n",
+		CTRACE(tfp, "HTAA_checkAuthorization: %s (%s access)\n",
 			    "Gatewaying -- skipping authorization check",
 			    acc_method);
 	    }
@@ -521,15 +505,14 @@ PUBLIC int HTAA_checkAuthorization ARGS4(CONST char *,	url,
 		htaa_user && htaa_user->username
 		? htaa_user->username : "");
 	fflush(htaa_logfile);	/* Actually update it on disk */
-	if (TRACE)
-	    fprintf(stderr, "Log: %24.24s %s %s %s %s %s\n",
-			    ctime(&theTime),
-			    HTClientHost ? HTClientHost : "local",
-			    method_name,
-			    url,
-			    status_name(HTAAFailReason),
-			    htaa_user && htaa_user->username
-			    ? htaa_user->username : "");
+	CTRACE(tfp, "Log: %24.24s %s %s %s %s %s\n",
+		    ctime(&theTime),
+		    HTClientHost ? HTClientHost : "local",
+		    method_name,
+		    url,
+		    status_name(HTAAFailReason),
+		    htaa_user && htaa_user->username
+		    ? htaa_user->username : "");
     }
 
     switch (HTAAFailReason) {
@@ -636,15 +619,14 @@ PUBLIC char *HTAA_composeAuthHeaders NOARGS
     HTAAProt *prot = HTAA_getCurrentProtection();
 
     if (!prot) {
-	if (TRACE)
-	    fprintf(stderr, "%s %s\n",
-			    "HTAA_composeAuthHeaders: Document not protected",
-			    "-- why was this function called??");
+	CTRACE(tfp, "%s %s\n",
+		    "HTAA_composeAuthHeaders: Document not protected",
+		    "-- why was this function called??");
 	return NULL;
+    } else {
+	CTRACE(tfp, "HTAA_composeAuthHeaders: for file `%s'\n",
+		    prot->filename);
     }
-    else if (TRACE)
-	fprintf(stderr, "HTAA_composeAuthHeaders: for file `%s'\n",
-			prot->filename);
 
     FREE(result);	/* From previous call */
     if (!(result = (char*)malloc(4096)))	/* @@ */
@@ -663,9 +645,10 @@ PUBLIC char *HTAA_composeAuthHeaders NOARGS
 		}
 		strcat(result, "\r\n");
 	    } /* scheme name found */
-	    else if (TRACE)
-		fprintf(stderr, "HTAA_composeAuthHeaders: %s %d\n",
-				"No name found for scheme number", scheme);
+	    else {
+		CTRACE(tfp, "HTAA_composeAuthHeaders: %s %d\n",
+			    "No name found for scheme number", scheme);
+	    }
 	} /* scheme valid for requested document */
     } /* for every scheme */
 
diff --git a/WWW/Library/Implementation/HTAAUtil.c b/WWW/Library/Implementation/HTAAUtil.c
index b10dcde0..7857ec52 100644
--- a/WWW/Library/Implementation/HTAAUtil.c
+++ b/WWW/Library/Implementation/HTAAUtil.c
@@ -217,8 +217,7 @@ PUBLIC BOOL HTAAMethod_inList ARGS2(HTAAMethod, method,
     char *item;
 
     while (NULL != (item = (char*)HTList_nextObject(cur))) {
-	if (TRACE)
-	    fprintf(stderr, " %s", item);
+	CTRACE(tfp, " %s", item);
 	if (method == HTAAMethod_enum(item))
 	    return YES;
     }
@@ -367,9 +366,8 @@ PUBLIC char *HTAA_makeProtectionTemplate ARGS1(CONST char *, docname)
     else
 	StrAllocCopy(template, "*");
 
-    if (TRACE)
-	fprintf(stderr, "make_template: made template `%s' for file `%s'\n",
-			template, docname);
+    CTRACE(tfp, "make_template: made template `%s' for file `%s'\n",
+		template, docname);
 
     return template;
 }
@@ -549,10 +547,9 @@ PUBLIC char *HTAA_getUnfoldedLine NOARGS
     BOOL peek_for_folding = NO;
 
     if (in_soc < 0) {
-	if (TRACE)
-	    fprintf(stderr, "%s %s\n",
-			    "HTAA_getUnfoldedLine: buffer not initialized",
-			    "with function HTAA_setupReader()");
+	CTRACE(tfp, "%s %s\n",
+		    "HTAA_getUnfoldedLine: buffer not initialized",
+		    "with function HTAA_setupReader()");
 	return NULL;
     }
 
diff --git a/WWW/Library/Implementation/HTACL.c b/WWW/Library/Implementation/HTACL.c
index fe4e02e4..2dbc79d6 100644
--- a/WWW/Library/Implementation/HTACL.c
+++ b/WWW/Library/Implementation/HTACL.c
@@ -180,14 +180,10 @@ PUBLIC GroupDef *HTAA_getAclEntry ARGS3(FILE *, 	acl_file,
 #endif /* not VMS */
 	    HTList *methods = HTList_new();
 	    HTAAFile_readList(acl_file, methods, MAX_METHODNAME_LEN);
-	    if (TRACE) {
-		fprintf(stderr,
-			"Filename '%s' matched template '%s', allowed methods:",
+	    CTRACE(tfp, "Filename '%s' matched template '%s', allowed methods:",
 			filename, buf);
-	    }
 	    if (HTAAMethod_inList(method, methods)) {	/* right method? */
-		if (TRACE)
-		    fprintf(stderr, " METHOD OK\n");
+		CTRACE(tfp, " METHOD OK\n");
 		HTList_delete(methods);
 		methods = NULL;
 		FREE(buf);
@@ -197,18 +193,15 @@ PUBLIC GroupDef *HTAA_getAclEntry ARGS3(FILE *, 	acl_file,
 		** separator so we don't call HTAAFile_nextRec().
 		*/
 		return group_def;
-	    } else if (TRACE) {
-		fprintf(stderr, " METHOD NOT FOUND\n");
+	    } else {
+		CTRACE(tfp, " METHOD NOT FOUND\n");
 	    }
 	    HTList_delete(methods);
 	    methods = NULL;
 	}	/* if template match */
 	else {
-	    if (TRACE) {
-		fprintf(stderr,
-			"Filename '%s' didn't match template '%s'\n",
+	    CTRACE(tfp, "Filename '%s' didn't match template '%s'\n",
 			filename, buf);
-	    }
 	}
 
 	HTAAFile_nextRec(acl_file);
@@ -218,4 +211,3 @@ PUBLIC GroupDef *HTAA_getAclEntry ARGS3(FILE *, 	acl_file,
     return NULL;	/* No entry for requested file */
 			/* (or an empty entry).        */
 }
-
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index df7f99c2..90d446d9 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -352,8 +352,7 @@ PRIVATE int get_physical ARGS2(
     }
     if (anchor->isISMAPScript == TRUE) {
 	StrAllocCat(physical, "?0,0");
-	if (TRACE)
-	    fprintf(stderr, "HTAccess: Appending '?0,0' coordinate pair.\n");
+	CTRACE(tfp, "HTAccess: Appending '?0,0' coordinate pair.\n");
     }
     HTAnchor_setPhysical(anchor, physical);
     FREE(physical);			/* free our copy */
@@ -361,8 +360,7 @@ PRIVATE int get_physical ARGS2(
     if (anchor->isISMAPScript == TRUE) {
 	StrAllocCopy(physical, addr);
 	StrAllocCat(physical, "?0,0");
-	if (TRACE)
-	    fprintf(stderr, "HTAccess: Appending '?0,0' coordinate pair.\n");
+	CTRACE(tfp, "HTAccess: Appending '?0,0' coordinate pair.\n");
 	HTAnchor_setPhysical(anchor, physical);
 	FREE(physical); 		/* free our copy */
     } else {
@@ -451,10 +449,10 @@ PRIVATE int get_physical ARGS2(
 	proxy = (char *)getenv(gateway_parameter);
 	FREE(gateway_parameter);
 
-	if (TRACE && gateway)
-	    fprintf(stderr, "Gateway found: %s\n", gateway);
-	if (TRACE && proxy)
-	    fprintf(stderr, "proxy server found: %s\n", proxy);
+	if (gateway)
+	    CTRACE(tfp, "Gateway found: %s\n", gateway);
+	if (proxy)
+	    CTRACE(tfp, "proxy server found: %s\n", proxy);
 
 	/*
 	**  Proxy servers have precedence over gateway servers.
@@ -667,8 +665,7 @@ PRIVATE BOOL HTLoadDocument ARGS4(
     BOOL ForcingNoCache = LYforce_no_cache;
     static int redirection_attempts = 0;
 
-    if (TRACE)
-	fprintf (stderr, "HTAccess: loading document %s\n", address_to_load);
+    CTRACE (tfp, "HTAccess: loading document %s\n", address_to_load);
 
     /*
     **	Free use_this_url_instead and reset permanent_redirection
@@ -724,11 +721,9 @@ PRIVATE BOOL HTLoadDocument ARGS4(
 	       !strncmp(cp, "Location=", 9)) {
 	    DocAddress NewDoc;
 
-	    if (TRACE) {
-		fprintf (stderr, "HTAccess: '%s' is a redirection URL.\n",
-				  anchor->address);
-		fprintf (stderr, "HTAccess: Redirecting to '%s'\n", cp+9);
-	    }
+	    CTRACE (tfp, "HTAccess: '%s' is a redirection URL.\n",
+			  anchor->address);
+	    CTRACE (tfp, "HTAccess: Redirecting to '%s'\n", cp+9);
 
 	    /*
 	    **	Don't exceed the redirection_attempts limit. - FM
@@ -826,8 +821,7 @@ PRIVATE BOOL HTLoadDocument ARGS4(
 	     strncmp(full_address, "LYNXIMGMAP:", 11)))
 #endif /* TRACK_INTERNAL_LINKS */
 	{
-	    if (TRACE)
-		fprintf(stderr, "HTAccess: Document already in memory.\n");
+	    CTRACE(tfp, "HTAccess: Document already in memory.\n");
 	    HText_select(text);
 
 #ifdef DIRED_SUPPORT
@@ -844,9 +838,7 @@ PRIVATE BOOL HTLoadDocument ARGS4(
 	    reloading = TRUE;
 #endif
 	    ForcingNoCache = YES;
-	    if (TRACE) {
-		fprintf(stderr, "HTAccess: Auto-reloading document.\n");
-	    }
+	    CTRACE(tfp, "HTAccess: Auto-reloading document.\n");
 	}
     }
 
@@ -861,9 +853,7 @@ PRIVATE BOOL HTLoadDocument ARGS4(
 	FREE(anchor->title);
     }
     status = HTLoad(address_to_load, anchor, format_out, sink);
-    if (TRACE) {
-	fprintf(stderr, "HTAccess:  status=%d\n", status);
-    }
+    CTRACE(tfp, "HTAccess:  status=%d\n", status);
 
     /*
     **	Log the access if necessary.
@@ -877,8 +867,7 @@ PRIVATE BOOL HTLoadDocument ARGS4(
 		status < 0 ? "FAIL" : "GET",
 		full_address);
 	fflush(HTlogfile);	/* Actually update it on disk */
-	if (TRACE)
-	    fprintf(stderr, "Log: %24.24s %s %s %s\n",
+	CTRACE(tfp, "Log: %24.24s %s %s %s\n",
 		    ctime(&theTime),
 		    HTClientHost ? HTClientHost : "local",
 		    status < 0 ? "FAIL" : "GET",
@@ -907,12 +896,10 @@ PRIVATE BOOL HTLoadDocument ARGS4(
 	**  in LYGetFile.c when the status is HT_REDIRECTING.  This may
 	**  seem bizarre, but it works like a charm! - FM
 	*/
-	if (TRACE) {
-	    fprintf(stderr, "HTAccess: '%s' is a redirection URL.\n",
-			    address_to_load);
-	    fprintf(stderr, "HTAccess: Redirecting to '%s'\n",
-			     redirecting_url);
-	}
+	CTRACE(tfp, "HTAccess: '%s' is a redirection URL.\n",
+		    address_to_load);
+	CTRACE(tfp, "HTAccess: Redirecting to '%s'\n",
+		     redirecting_url);
 	/*
 	**  Prevent circular references.
 	*/
@@ -952,46 +939,32 @@ PRIVATE BOOL HTLoadDocument ARGS4(
     permanent_redirection = FALSE;
 
     if (status == HT_LOADED) {
-	if (TRACE) {
-	    fprintf(stderr, "HTAccess: `%s' has been accessed.\n",
-	    full_address);
-	}
+	CTRACE(tfp, "HTAccess: `%s' has been accessed.\n",
+		    full_address);
 	return YES;
     }
     if (status == HT_PARTIAL_CONTENT) {
 	HTAlert("Loading incomplete.");
-	if (TRACE) {
-	    fprintf(stderr, "HTAccess: `%s' has been accessed, partial content.\n",
-	    full_address);
-	}
+	CTRACE(tfp, "HTAccess: `%s' has been accessed, partial content.\n",
+		    full_address);
 	return YES;
     }
 
     if (status == HT_NO_DATA) {
-	if (TRACE) {
-	    fprintf(stderr,
-	    "HTAccess: `%s' has been accessed, No data left.\n",
-	    full_address);
-	}
+	CTRACE(tfp, "HTAccess: `%s' has been accessed, No data left.\n",
+		    full_address);
 	return NO;
     }
 
     if (status == HT_NOT_LOADED) {
-	if (TRACE) {
-	    fprintf(stderr,
-	    "HTAccess: `%s' has been accessed, No data loaded.\n",
-	    full_address);
-	}
+	CTRACE(tfp, "HTAccess: `%s' has been accessed, No data loaded.\n",
+		    full_address);
 	return NO;
     }
 
     if (status == HT_INTERRUPTED) {
-	if (TRACE) {
-	    fprintf(stderr,
-	    "HTAccess: `%s' has been accessed, transfer interrupted.\n",
-	    full_address);
-	}
-/*	_HTProgress("Data transfer interrupted."); */
+	CTRACE(tfp, "HTAccess: `%s' has been accessed, transfer interrupted.\n",
+		    full_address);
 	return NO;
     }
 
@@ -1002,8 +975,7 @@ PRIVATE BOOL HTLoadDocument ARGS4(
 	StrAllocCat(temp, "'");
 	_HTProgress(temp);
 	FREE(temp);
-	if (TRACE) fprintf(stderr,
-		"HTAccess: Can't access `%s'\n", full_address);
+	CTRACE(tfp, "HTAccess: Can't access `%s'\n", full_address);
 	HTLoadError(sink, 500, "Unable to access document.");
 	return NO;
     }
@@ -1012,11 +984,11 @@ PRIVATE BOOL HTLoadDocument ARGS4(
     **	If you get this, then please find which routine is returning
     **	a positive unrecognised error code!
     */
-    fprintf(stderr,
+    fprintf(tfp,
  "**** HTAccess: socket or file number returned by obsolete load routine!\n");
-    fprintf(stderr,
+    fprintf(tfp,
  "**** HTAccess: Internal software error. Please mail lynx_dev@sig.net!\n");
-    fprintf(stderr, "**** HTAccess: Status returned was: %d\n",status);
+    fprintf(tfp, "**** HTAccess: Status returned was: %d\n",status);
     exit(-1);
 
 } /* HTLoadDocument */
@@ -1343,9 +1315,7 @@ PUBLIC HTParentAnchor * HTHomeAnchor NOARGS
 	if (fp) {
 	    fclose(fp);
 	} else {
-	    if (TRACE)
-		fprintf(stderr,
-			"HTBrowse: No local home document ~/%s or %s\n",
+	    CTRACE(tfp, "HTBrowse: No local home document ~/%s or %s\n",
 			PERSONAL_DEFAULT, LOCAL_DEFAULT_FILE);
 	    FREE(my_home_document);
 	}
@@ -1357,9 +1327,7 @@ PUBLIC HTParentAnchor * HTHomeAnchor NOARGS
 		  "file:",
 		  PARSE_ACCESS|PARSE_HOST|PARSE_PATH|PARSE_PUNCTUATION);
     if (my_home_document) {
-	if (TRACE)
-	    fprintf(stderr,
-		    "HTAccess: Using custom home page %s i.e. address %s\n",
+	CTRACE(tfp, "HTAccess: Using custom home page %s i.e. address %s\n",
 		    my_home_document, ref);
 	FREE(my_home_document);
     }
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index 9c8b10cd..14e258f6 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -172,8 +172,7 @@ PUBLIC HTChildAnchor * HTAnchor_findChild ARGS2(
     HTList *kids;
 
     if (!parent) {
-	if (TRACE)
-	    fprintf(stderr, "HTAnchor_findChild called with NULL parent.\n");
+	CTRACE(tfp, "HTAnchor_findChild called with NULL parent.\n");
 	return NULL;
     }
     if ((kids = parent->children) != 0) {
@@ -187,9 +186,7 @@ PUBLIC HTChildAnchor * HTAnchor_findChild ARGS2(
 #else
 		if (HTIdentical(child->tag, tag)) {  /* Case sensitive - FM */
 #endif /* CASE_INSENSITIVE_ANCHORS */
-		    if (TRACE)
-			fprintf(stderr,
-	      "Child anchor %p of parent %p with name `%s' already exists.\n",
+		    CTRACE(tfp, "Child anchor %p of parent %p with name `%s' already exists.\n",
 				(void *)child, (void *)parent, tag);
 		    return child;
 		}
@@ -200,9 +197,7 @@ PUBLIC HTChildAnchor * HTAnchor_findChild ARGS2(
     }
 
     child = HTChildAnchor_new();
-    if (TRACE)
-	fprintf(stderr,
-		"new Anchor %p named `%s' is child of %p\n",
+    CTRACE(tfp, "new Anchor %p named `%s' is child of %p\n",
 		(void *)child,
 		tag ? tag : (CONST char *)"",
 		(void *)parent); /* int for apollo */
@@ -228,8 +223,7 @@ PUBLIC HTChildAnchor * HTAnchor_findChildAndLink ARGS4(
 {
     HTChildAnchor * child = HTAnchor_findChild(parent, tag);
 
-    if (TRACE)
-	fprintf(stderr,"Entered HTAnchor_findChildAndLink\n");
+    CTRACE(tfp,"Entered HTAnchor_findChildAndLink\n");
 
     if (href && *href) {
 	char *relative_to = HTAnchor_address((HTAnchor *)parent);
@@ -306,8 +300,7 @@ PUBLIC HTAnchor * HTAnchor_findAddress ARGS1(
     /* Anchor tag specified ? */
     char *tag = HTParse(newdoc->address, "", PARSE_ANCHOR);
 
-    if (TRACE)
-	fprintf(stderr,"Entered HTAnchor_findAddress\n");
+    CTRACE(tfp,"Entered HTAnchor_findAddress\n");
 
     /*
     **	If the address represents a sub-anchor, we recursively load its
@@ -371,9 +364,7 @@ PUBLIC HTAnchor * HTAnchor_findAddress ARGS1(
 		foundAnchor->isHEAD == newdoc->isHEAD)
 #endif /* CASE_INSENSITIVE_ANCHORS */
 	    {
-		if (TRACE)
-		    fprintf(stderr,
-			    "Anchor %p with address `%s' already exists.\n",
+		CTRACE(tfp, "Anchor %p with address `%s' already exists.\n",
 			    (void *)foundAnchor, newdoc->address);
 		 return (HTAnchor *)foundAnchor;
 	     }
@@ -383,9 +374,7 @@ PUBLIC HTAnchor * HTAnchor_findAddress ARGS1(
 	**  Node not found: create new anchor.
 	*/
 	foundAnchor = HTParentAnchor_new();
-	if (TRACE)
-	    fprintf(stderr,
-		    "New anchor %p has hash %d and address `%s'\n",
+	CTRACE(tfp, "New anchor %p has hash %d and address `%s'\n",
 		    (void *)foundAnchor, hash, newdoc->address);
 	StrAllocCopy(foundAnchor->address, newdoc->address);
 	if (newdoc->post_data)
@@ -1041,9 +1030,7 @@ PUBLIC BOOL HTAnchor_link ARGS3(
 {
     if (!(source && destination))
 	return NO;  /* Can't link to/from non-existing anchor */
-    if (TRACE)
-	fprintf(stderr,
-		"Linking anchor %p to anchor %p\n", source, destination);
+    CTRACE(tfp, "Linking anchor %p to anchor %p\n", source, destination);
     if (!source->mainLink.dest) {
 	source->mainLink.dest = destination;
 	source->mainLink.type = type;
diff --git a/WWW/Library/Implementation/HTAssoc.c b/WWW/Library/Implementation/HTAssoc.c
index 0736a269..dff739be 100644
--- a/WWW/Library/Implementation/HTAssoc.c
+++ b/WWW/Library/Implementation/HTAssoc.c
@@ -66,8 +66,8 @@ PUBLIC void HTAssocList_add ARGS3(HTAssocList *,	alist,
 	if (value)
 	    StrAllocCopy(assoc->value, value);
 	HTList_addObject(alist, (void*)assoc);
-    } else if (TRACE) {
-        fprintf(stderr, "HTAssoc_add: ERROR: assoc list NULL!!\n");
+    } else {
+        CTRACE(tfp, "HTAssoc_add: ERROR: assoc list NULL!!\n");
     }
 }
 
diff --git a/WWW/Library/Implementation/HTAtom.c b/WWW/Library/Implementation/HTAtom.c
index e5aee433..1fd6d9c1 100644
--- a/WWW/Library/Implementation/HTAtom.c
+++ b/WWW/Library/Implementation/HTAtom.c
@@ -67,8 +67,7 @@ PUBLIC HTAtom * HTAtom_for ARGS1(CONST char *, string)
     */
     for (a = hash_table[hash]; a; a = a->next) {
 	if (0 == strcasecomp(a->name, string)) {
-    	    /* if (TRACE) fprintf(stderr,
-	    	"HTAtom: Old atom %p for `%s'\n", a, string); */
+    	    /* CTRACE(tfp, "HTAtom: Old atom %p for `%s'\n", a, string); */
 	    return a;				/* Found: return it */
 	}
     }
@@ -85,8 +84,7 @@ PUBLIC HTAtom * HTAtom_for ARGS1(CONST char *, string)
     a->next = hash_table[hash];		/* Put onto the head of list */
     hash_table[hash] = a;
 #ifdef NOT_DEFINED
-    if (TRACE)
-	fprintf(stderr, "HTAtom: New atom %p for `%s'\n", a, string);
+    CTRACE(tfp, "HTAtom: New atom %p for `%s'\n", a, string);
 #endif /* NOT_DEFINED */
     return a;
 }
diff --git a/WWW/Library/Implementation/HTAuth.c b/WWW/Library/Implementation/HTAuth.c
index b8b4d010..573a24b7 100644
--- a/WWW/Library/Implementation/HTAuth.c
+++ b/WWW/Library/Implementation/HTAuth.c
@@ -99,8 +99,7 @@ PRIVATE HTAAUser *decompose_auth_string ARGS2(char *,		authstring,
 */
     username = cleartext;
     if (!(password = strchr(cleartext, ':'))) {
-	if (TRACE)
-	    fprintf(stderr, "%s %s\n",
+	CTRACE(tfp, "%s %s\n",
 		    "decompose_auth_string: password field",
 		    "missing in authentication string.\n");
 	return NULL;
@@ -116,9 +115,9 @@ PRIVATE HTAAUser *decompose_auth_string ARGS2(char *,		authstring,
 	    (*(timestamp++)   ='\0'), !(browsers_key=strchr(timestamp,':')) ||
 	    (*(browsers_key++)='\0')) {
 
-	    if (TRACE) fprintf(stderr, "%s %s\n",
-			       "decompose_auth_string: Pubkey scheme",
-			       "fields missing in authentication string");
+	    CTRACE(tfp, "%s %s\n",
+		        "decompose_auth_string: Pubkey scheme",
+		        "fields missing in authentication string");
 	    return NULL;
 	}
     }
@@ -132,13 +131,12 @@ PRIVATE HTAAUser *decompose_auth_string ARGS2(char *,		authstring,
     user->timestamp  = timestamp;
     user->secret_key = browsers_key;
 
-    if (TRACE) {
-	if (scheme==HTAA_BASIC)
-	    fprintf(stderr, "decompose_auth_string: %s (%s,%s)\n",
+    if (scheme == HTAA_BASIC) {
+	CTRACE(tfp, "decompose_auth_string: %s (%s,%s)\n",
 		    "Basic scheme authentication string:",
 		    username, password);
-	else
-	    fprintf(stderr, "decompose_auth_string: %s (%s,%s,%s,%s,%s)\n",
+    } else {
+	CTRACE(tfp, "decompose_auth_string: %s (%s,%s,%s,%s,%s)\n",
 		    "Pubkey scheme authentication string:",
 		    username, password, i_net_adr, timestamp, browsers_key);
     }
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index 48d0aa36..38ceddd4 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -338,7 +338,7 @@ PRIVATE int close_connection ARGS1(
     connection * scan;
     int status = NETCLOSE(con->socket);
     if (TRACE) {
-	fprintf(stderr, "HTFTP: Closing control socket %d\n", con->socket);
+	CTRACE(tfp, "HTFTP: Closing control socket %d\n", con->socket);
 #ifdef UNIX
 	if (status != 0)
 	    perror("HTFTP:close_connection");
@@ -375,8 +375,7 @@ PRIVATE void help_message_cache_add ARGS1(
     else
 	StrAllocCopy(help_message_buffer, string);
 
-    if (TRACE)
-	fprintf(stderr,"Adding message to help cache: %s\n",string);
+    CTRACE(tfp,"Adding message to help cache: %s\n",string);
 }
 
 PRIVATE char *help_message_cache_non_empty NOARGS
@@ -417,14 +416,12 @@ PRIVATE int response ARGS1(
     int status;
 
     if (!control) {
-	  if (TRACE)
-	      fprintf(stderr, "HTFTP: No control connection set up!!\n");
-	  return -99;
+	CTRACE(tfp, "HTFTP: No control connection set up!!\n");
+	return -99;
     }
 
     if (cmd) {
-	if (TRACE)
-	    fprintf(stderr, "  Tx: %s", cmd);
+	CTRACE(tfp, "  Tx: %s", cmd);
 #ifdef NOT_ASCII
 	{
 	    char * p;
@@ -435,9 +432,7 @@ PRIVATE int response ARGS1(
 #endif /* NOT_ASCII */
 	status = NETWRITE(control->socket, cmd, (int)strlen(cmd));
 	if (status < 0) {
-	    if (TRACE)
-		fprintf(stderr,
-			"HTFTP: Error %d sending command: closing socket %d\n",
+	    CTRACE(tfp, "HTFTP: Error %d sending command: closing socket %d\n",
 			status, control->socket);
 	    close_connection(control);
 	    return status;
@@ -452,19 +447,15 @@ PRIVATE int response ARGS1(
 
 		char continuation;
 
-		if (interrupted_in_htgetcharacter)
-		  {
-		    if (TRACE)
-		      fprintf (stderr,
-			"HTFTP: Interrupted in HTGetCharacter, apparently.\n");
+		if (interrupted_in_htgetcharacter) {
+		    CTRACE (tfp, "HTFTP: Interrupted in HTGetCharacter, apparently.\n");
 		    NETCLOSE (control->socket);
 		    control->socket = -1;
 		    return HT_INTERRUPTED;
-		  }
+		}
 
 		*p = '\0';			/* Terminate the string */
-		if (TRACE)
-		    fprintf(stderr, "    Rx: %s", response_text);
+		CTRACE(tfp, "    Rx: %s", response_text);
 
 		/* Check for login or help messages */
 		if (!strncmp(response_text,"230-",4) ||
@@ -484,19 +475,15 @@ PRIVATE int response ARGS1(
 		break;
 	    } /* if end of line */
 
-	    if (interrupted_in_htgetcharacter)
-	       {
-		    if (TRACE)
-		      fprintf (stderr,
-			"HTFTP: Interrupted in HTGetCharacter, apparently.\n");
-		    NETCLOSE (control->socket);
-		    control->socket = -1;
-		    return HT_INTERRUPTED;
-	       }
+	    if (interrupted_in_htgetcharacter) {
+		CTRACE (tfp, "HTFTP: Interrupted in HTGetCharacter, apparently.\n");
+		NETCLOSE (control->socket);
+		control->socket = -1;
+		return HT_INTERRUPTED;
+	    }
 
 	    if (*(p-1) == (char) EOF) {
-		if (TRACE)
-		    fprintf(stderr, "Error on rx: closing socket %d\n",
+		CTRACE(tfp, "Error on rx: closing socket %d\n",
 			    control->socket);
 		strcpy(response_text, "000 *** TCP read error on response\n");
 		close_connection(control);
@@ -507,8 +494,7 @@ PRIVATE int response ARGS1(
     } while (continuation_response != -1);
 
     if (result == 421) {
-	if (TRACE)
-	    fprintf(stderr, "HTFTP: They close so we close socket %d\n",
+	CTRACE(tfp, "HTFTP: They close so we close socket %d\n",
 		    control->socket);
 	close_connection(control);
 	return -1;
@@ -564,8 +550,7 @@ PRIVATE void get_ftp_pwd ARGS2(
 	if (*ServerType == TCPC_SERVER) {
 	    *ServerType = ((response_text[5] == '/') ?
 					  NCSA_SERVER : TCPC_SERVER);
-	     if (TRACE)
-		 fprintf(stderr, "HTFTP: Treating as %s server.\n",
+	    CTRACE(tfp, "HTFTP: Treating as %s server.\n",
 			 ((*ServerType == NCSA_SERVER) ?
 						 "NCSA" : "TCPC"));
 	} else if (response_text[5] == '/') {
@@ -574,25 +559,21 @@ PRIVATE void get_ftp_pwd ARGS2(
 	     */
 	    if (set_mac_binary(*ServerType)) {
 		*ServerType = NCSA_SERVER;
-		if (TRACE)
-		    fprintf(stderr, "HTFTP: Treating as NCSA server.\n");
+		CTRACE(tfp, "HTFTP: Treating as NCSA server.\n");
 	    } else {
 		 *ServerType = UNIX_SERVER;
 		 *UseList = TRUE;
-		 if (TRACE)
-		     fprintf(stderr, "HTFTP: Treating as Unix server.\n");
+		 CTRACE(tfp, "HTFTP: Treating as Unix server.\n");
 	    }
 	    return;
 	} else if (response_text[strlen(response_text)-1] == ']') {
 	    /* path names ending with ] imply VMS, right? */
 	    *ServerType = VMS_SERVER;
 	    *UseList = TRUE;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Treating as VMS server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as VMS server.\n");
 	} else {
 	    *ServerType = GENERIC_SERVER;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Treating as Generic server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as Generic server.\n");
 	}
 
 	if ((*ServerType == NCSA_SERVER) ||
@@ -713,42 +694,35 @@ PRIVATE int get_connection ARGS2(
 	    FREE(p1);
     } /* scope of p1 */
 
-  status = HTDoConnect (arg, "FTP", IPPORT_FTP, (int *)&con->socket);
+    status = HTDoConnect (arg, "FTP", IPPORT_FTP, (int *)&con->socket);
 
-  if (status < 0)
-    {
-      if (TRACE)
-	{
-	  if (status == HT_INTERRUPTED)
-	    fprintf (stderr,
-		     "HTFTP: Interrupted on connect\n");
-	  else
-	    fprintf(stderr,
-		    "HTFTP: Unable to connect to remote host for `%s'.\n",
-		    arg);
+    if (status < 0) {
+	if (status == HT_INTERRUPTED) {
+	    CTRACE (tfp, "HTFTP: Interrupted on connect\n");
+	} else {
+	    CTRACE(tfp, "HTFTP: Unable to connect to remote host for `%s'.\n",
+		        arg);
 	}
-      if (status == HT_INTERRUPTED) {
-	_HTProgress ("Connection interrupted.");
-	status = HT_NOT_LOADED;
-      } else {
-	HTAlert("Unable to connect to FTP host.");
-      }
-      if (con->socket != -1)
+	if (status == HT_INTERRUPTED) {
+	    _HTProgress ("Connection interrupted.");
+	    status = HT_NOT_LOADED;
+	} else {
+	    HTAlert("Unable to connect to FTP host.");
+	}
+	if (con->socket != -1)
 	{
 	  NETCLOSE(con->socket);
 	}
 
-      FREE(username);
-      if (control == con)
-	  control = NULL;
-      FREE(con);
-      return status;			/* Bad return */
+	FREE(username);
+	if (control == con)
+	    control = NULL;
+	FREE(con);
+	return status;			/* Bad return */
     }
 
-    if (TRACE) {
-	fprintf(stderr, "FTP connected, socket %d  control %ld\n",
-			con->socket, (long)con);
-    }
+    CTRACE(tfp, "FTP connected, socket %d  control %ld\n",
+		con->socket, (long)con);
     control = con;		/* Current control connection */
 
     /* Initialise buffering for control connection */
@@ -760,16 +734,13 @@ PRIVATE int get_connection ARGS2(
 */
     status = response((char *)0);	/* Get greeting */
 
-    if (status == HT_INTERRUPTED)
-      {
-	if (TRACE)
-	  fprintf (stderr,
-		   "HTFTP: Interrupted at beginning of login.\n");
+    if (status == HT_INTERRUPTED) {
+	CTRACE (tfp, "HTFTP: Interrupted at beginning of login.\n");
 	_HTProgress ("Connection interrupted.");
 	NETCLOSE(control->socket);
 	control->socket = -1;
 	return HT_INTERRUPTED;
-      }
+    }
     server_type = GENERIC_SERVER;	/* reset */
     if (status == 2) {		/* Send username */
 	char *cp;		/* look at greeting text */
@@ -800,16 +771,13 @@ PRIVATE int get_connection ARGS2(
 	}
 	status = response(command);
 	FREE(command);
-	if (status == HT_INTERRUPTED)
-	  {
-	    if (TRACE)
-	      fprintf (stderr,
-		       "HTFTP: Interrupted while sending username.\n");
+	if (status == HT_INTERRUPTED) {
+	    CTRACE (tfp, "HTFTP: Interrupted while sending username.\n");
 	    _HTProgress ("Connection interrupted.");
 	    NETCLOSE(control->socket);
 	    control->socket = -1;
 	    return HT_INTERRUPTED;
-	  }
+	}
     }
     if (status == 3) {		/* Send password */
 	if (password) {
@@ -866,16 +834,14 @@ PRIVATE int get_connection ARGS2(
 	}
 	status = response(command);
 	FREE(command);
-	if (status == HT_INTERRUPTED)
-	  {
-	    if (TRACE)
-	      fprintf (stderr,
+	if (status == HT_INTERRUPTED) {
+	    CTRACE (tfp,
 		       "HTFTP: Interrupted while sending password.\n");
 	    _HTProgress ("Connection interrupted.");
 	    NETCLOSE(control->socket);
 	    control->socket = -1;
 	    return HT_INTERRUPTED;
-	  }
+	}
     }
     FREE(username);
 
@@ -883,25 +849,21 @@ PRIVATE int get_connection ARGS2(
 	char temp[80];
 	sprintf(temp, "ACCT noaccount%c%c", CR, LF);
 	status = response(temp);
-	if (status == HT_INTERRUPTED)
-	  {
-	    if (TRACE)
-	      fprintf (stderr,
-		       "HTFTP: Interrupted while sending password.\n");
+	if (status == HT_INTERRUPTED) {
+	    CTRACE (tfp, "HTFTP: Interrupted while sending password.\n");
 	    _HTProgress ("Connection interrupted.");
 	    NETCLOSE(control->socket);
 	    control->socket = -1;
 	    return HT_INTERRUPTED;
-	  }
+	}
 
     }
     if (status != 2) {
-	if (TRACE)
-	    fprintf(stderr, "HTFTP: Login fail: %s", response_text);
+	CTRACE(tfp, "HTFTP: Login fail: %s", response_text);
 	/* if (control->socket > 0) close_connection(control->socket); */
 	return -1;		/* Bad return */
     }
-    if (TRACE) fprintf(stderr, "HTFTP: Logged in.\n");
+    CTRACE(tfp, "HTFTP: Logged in.\n");
 
     /** Check for host type **/
     if (server_type != NETPRESENZ_SERVER)
@@ -913,88 +875,71 @@ PRIVATE int get_connection ARGS2(
 		    "UNIX Type: L8 MAC-OS MachTen", 28) == 0) {
 	    server_type = MACHTEN_SERVER;
 	    use_list = TRUE;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Treating as MachTen server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as MachTen server.\n");
 
 	} else if (strstr(response_text+4, "UNIX") != NULL ||
 		   strstr(response_text+4, "Unix") != NULL) {
 	    server_type = UNIX_SERVER;
 	    use_list = TRUE;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Treating as Unix server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as Unix server.\n");
 
 	} else if (strstr(response_text+4, "MSDOS") != NULL) {
 	    server_type = MSDOS_SERVER;
 	    use_list = TRUE;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTFTP: Treating as MSDOS (Unix emulation) server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as MSDOS (Unix emulation) server.\n");
 
 	} else if (strncmp(response_text+4, "VMS", 3) == 0) {
 	    server_type = VMS_SERVER;
 	    use_list = TRUE;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Treating as VMS server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as VMS server.\n");
 
 	} else if ((strncmp(response_text+4, "VM/CMS", 6) == 0) ||
 		   (strncmp(response_text+4, "VM ", 3) == 0)) {
 	    server_type = CMS_SERVER;
 	    use_list = TRUE;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Treating as CMS server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as CMS server.\n");
 
 	} else if (strncmp(response_text+4, "DCTS", 4) == 0) {
 	    server_type = DCTS_SERVER;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Treating as DCTS server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as DCTS server.\n");
 
 	} else if (strstr(response_text+4, "MAC-OS TCP/Connect II") != NULL) {
 	    server_type = TCPC_SERVER;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Looks like a TCPC server.\n");
+	    CTRACE(tfp, "HTFTP: Looks like a TCPC server.\n");
 	    get_ftp_pwd(&server_type, &use_list);
 	    unsure_type = TRUE;
 
 	} else if (server_type == NETPRESENZ_SERVER) { /* already set above */
 	    use_list = TRUE;
 	    set_mac_binary(server_type);
-	    if (TRACE)
-		fprintf(stderr,
-			"HTFTP: Treating as NetPresenz (MACOS) server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as NetPresenz (MACOS) server.\n");
 
 	} else if (strncmp(response_text+4, "MACOS Peter's Server", 20) == 0) {
 	    server_type = PETER_LEWIS_SERVER;
 	    use_list = TRUE;
 	    set_mac_binary(server_type);
-	    if (TRACE)
-		fprintf(stderr,
-			"HTFTP: Treating as Peter Lewis (MACOS) server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as Peter Lewis (MACOS) server.\n");
 
 	} else if (strncmp(response_text+4, "Windows_NT", 10) == 0) {
 	    server_type = WINDOWS_NT_SERVER;
 	    use_list = TRUE;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Treating as Window_NT server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as Window_NT server.\n");
 
 	} else if (strncmp(response_text+4, "MS Windows", 10) == 0) {
 	    server_type = MS_WINDOWS_SERVER;
 	    use_list = TRUE;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Treating as MS Windows server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as MS Windows server.\n");
 
 	} else if (strncmp(response_text+4,
 			   "MACOS AppleShare IP FTP Server", 30) == 0) {
 	    server_type = APPLESHARE_SERVER;
 	    use_list = TRUE;
 	    set_mac_binary(server_type);
-	    if (TRACE)
-		fprintf(stderr,
-			"HTFTP: Treating as AppleShare server.\n");
+	    CTRACE(tfp, "HTFTP: Treating as AppleShare server.\n");
 
 	} else	{
 	    server_type = GENERIC_SERVER;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Ugh!  A Generic server.\n");
+	    CTRACE(tfp, "HTFTP: Ugh!  A Generic server.\n");
 	    get_ftp_pwd(&server_type, &use_list);
 	    unsure_type = TRUE;
 	 }
@@ -1013,8 +958,7 @@ PRIVATE int get_connection ARGS2(
 		close_connection(control->socket);
 	    return -status;		/* Bad return */
 	}
-	if (TRACE)
-	    fprintf(stderr, "HTFTP: Port defined.\n");
+	CTRACE(tfp, "HTFTP: Port defined.\n");
     }
 #endif /* NOTREPEAT_PORT */
     return con->socket; 		/* Good return */
@@ -1033,8 +977,7 @@ PRIVATE int close_master_socket NOARGS
     int status;
     FD_CLR(master_socket, &open_sockets);
     status = NETCLOSE(master_socket);
-    if (TRACE)
-	fprintf(stderr, "HTFTP: Closed master socket %d\n", master_socket);
+    CTRACE(tfp, "HTFTP: Closed master socket %d\n", master_socket);
     master_socket = -1;
     if (status < 0)
 	return HTInetStatus("close master socket");
@@ -1079,8 +1022,7 @@ PRIVATE int get_listen_socket NOARGS
     if (new_socket < 0)
 	return HTInetStatus("socket for master socket");
 
-    if (TRACE)
-	fprintf(stderr, "HTFTP: Opened master socket number %d\n", new_socket);
+    CTRACE(tfp, "HTFTP: Opened master socket number %d\n", new_socket);
 
 /*  Search for a free port.
 */
@@ -1115,9 +1057,7 @@ PRIVATE int get_listen_socket NOARGS
 			    /* Cast to generic sockaddr */
 		    sizeof(soc_address))) == 0)
 		break;
-	    if (TRACE)
-		fprintf(stderr,
-			"TCP bind attempt to port %d yields %d, errno=%d\n",
+	    CTRACE(tfp, "TCP bind attempt to port %d yields %d, errno=%d\n",
 		port_number, status, SOCKET_ERRNO);
 	} /* for */
     }
@@ -1592,11 +1532,10 @@ PRIVATE void parse_vms_dir_entry ARGS2(
     }
 
     /** Wrap it up **/
-    if (TRACE)
-	fprintf(stderr, "HTFTP: VMS filename: %s  date: %s  size: %d\n",
-			entry_info->filename,
-			entry_info->date ? entry_info->date : "",
-			entry_info->size);
+    CTRACE(tfp, "HTFTP: VMS filename: %s  date: %s  size: %d\n",
+		entry_info->filename,
+		entry_info->date ? entry_info->date : "",
+		entry_info->size);
     return;
 } /* parse_vms_dir_entry() */
 
@@ -1673,11 +1612,10 @@ PRIVATE void parse_ms_windows_dir_entry ARGS2(
     }
 
     /** Wrap it up **/
-    if (TRACE)
-	fprintf(stderr, "HTFTP: MS Windows filename: %s  date: %s  size: %d\n",
-			entry_info->filename,
-			entry_info->date ? entry_info->date : "",
-			entry_info->size);
+    CTRACE(tfp, "HTFTP: MS Windows filename: %s  date: %s  size: %d\n",
+		entry_info->filename,
+		entry_info->date ? entry_info->date : "",
+		entry_info->size);
     return;
 } /* parse_ms_windows_dir_entry */
 
@@ -1795,11 +1733,10 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2(
     }
 
     /** Wrap it up **/
-    if (TRACE)
-	fprintf(stderr, "HTFTP: Windows NT filename: %s  date: %s  size: %d\n",
-			entry_info->filename,
-			entry_info->date ? entry_info->date : "",
-			entry_info->size);
+    CTRACE(tfp, "HTFTP: Windows NT filename: %s  date: %s  size: %d\n",
+		entry_info->filename,
+		entry_info->date ? entry_info->date : "",
+		entry_info->size);
     return;
 } /* parse_windows_nt_dir_entry */
 #endif /* NOTDEFINED */
@@ -1954,11 +1891,10 @@ PRIVATE void parse_cms_dir_entry ARGS2(
     }
 
     /** Wrap it up. **/
-    if (TRACE)
-	fprintf(stderr, "HTFTP: VM/CMS filename: %s  date: %s  size: %d\n",
-			entry_info->filename,
-			entry_info->date ? entry_info->date : "",
-			entry_info->size);
+    CTRACE(tfp, "HTFTP: VM/CMS filename: %s  date: %s  size: %d\n",
+		entry_info->filename,
+		entry_info->date ? entry_info->date : "",
+		entry_info->size);
     return;
 } /* parse_cms_dir_entry */
 
@@ -2531,15 +2467,13 @@ AgainForMultiNet:
 	    if (c == (char) EOF && chunk->size == 1)
 	    /* 1 means empty: includes terminating 0 */
 		break;
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Line in %s is %s\n",
-				lastpath, chunk->data);
+	    CTRACE(tfp, "HTFTP: Line in %s is %s\n",
+			lastpath, chunk->data);
 
 	    entry_info = parse_dir_entry(chunk->data, &first);
 	    if (entry_info->display) {
-		if (TRACE)
-		    fprintf(stderr, "Adding file to BTree: %s\n",
-				    entry_info->filename);
+		CTRACE(tfp, "Adding file to BTree: %s\n",
+			    entry_info->filename);
 		HTBTree_add(bt, (EntryInfo *)entry_info);
 	    } else {
 		FREE(entry_info);
@@ -2695,22 +2629,19 @@ PUBLIC int HTFTPLoad ARGS4(
 	{
 	    status = response(port_command);
 	    if (status == HT_INTERRUPTED) {
-	      if (TRACE)
-		fprintf (stderr,
-			 "HTFTP: Interrupted in response (port_command)\n");
-	      _HTProgress ("Connection interrupted.");
-	      NETCLOSE (control->socket);
-	      control->socket = -1;
-	      close_master_socket ();
-	      return HT_INTERRUPTED;
+		CTRACE (tfp, "HTFTP: Interrupted in response (port_command)\n");
+		_HTProgress ("Connection interrupted.");
+		NETCLOSE (control->socket);
+		control->socket = -1;
+		close_master_socket ();
+		return HT_INTERRUPTED;
 	    }
 	    if (status != 2) {		/* Could have timed out */
 		if (status < 0)
 		    continue;		/* try again - net error*/
 		return -status; 	/* bad reply */
 	    }
-	    if (TRACE)
-		fprintf(stderr, "HTFTP: Port defined.\n");
+	    CTRACE(tfp, "HTFTP: Port defined.\n");
 	}
 #endif /* REPEAT_PORT */
 #else	/* Use PASV */
@@ -2738,13 +2669,12 @@ PUBLIC int HTFTPLoad ARGS4(
 	   status = sscanf(p+1, "%d,%d,%d,%d,%d,%d",
 		   &h0, &h1, &h2, &h3, &p0, &p1);
 	   if (status < 4) {
-	       fprintf(stderr, "HTFTP: PASV reply has no inet address!\n");
+	       fprintf(tfp, "HTFTP: PASV reply has no inet address!\n");
 	       return -99;
 	   }
 	   passive_port = (p0<<8) + p1;
-	   if (TRACE)
-	       fprintf(stderr, "HTFTP: Server is listening on port %d\n",
-				passive_port);
+	   CTRACE(tfp, "HTFTP: Server is listening on port %d\n",
+			passive_port);
 
 
 /*	Open connection for data:
@@ -2759,8 +2689,7 @@ PUBLIC int HTFTPLoad ARGS4(
 		return status;			/* Bad return */
 	    }
 
-	    if (TRACE)
-		fprintf(stderr, "FTP data connected, socket %d\n", data_soc);
+	    CTRACE(tfp, "FTP data connected, socket %d\n", data_soc);
 	}
 #endif /* use PASV */
 	status = 0;
@@ -2787,10 +2716,7 @@ PUBLIC int HTFTPLoad ARGS4(
 		init_help_message_cache();  /* to free memory */
 		NETCLOSE(control->socket);
 		control->socket = -1;
-		if (TRACE) {
-		    fprintf(stderr,
-		     "HTFTP: Rejecting path due to illegal escaped slash.\n");
-		}
+		CTRACE(tfp, "HTFTP: Rejecting path due to illegal escaped slash.\n");
 		return -1;
 	    }
 	}
@@ -2825,13 +2751,12 @@ PUBLIC int HTFTPLoad ARGS4(
 		    *(filename+1) = '\0';
 		}
 	    }
-	    if (TRACE && *type != '\0') {
-		fprintf(stderr, "HTFTP: type=%s\n", type);
+	    if (*type != '\0') {
+		CTRACE(tfp, "HTFTP: type=%s\n", type);
 	    }
 	}
 	HTUnEscape(filename);
-	if (TRACE)
-	    fprintf(stderr, "HTFTP: UnEscaped %s\n", filename);
+	CTRACE(tfp, "HTFTP: UnEscaped %s\n", filename);
 	if (filename[1] == '~') {
 	    /*
 	    ** Check if translation of HOME as tilde is supported,
@@ -2949,10 +2874,7 @@ PUBLIC int HTFTPLoad ARGS4(
 		init_help_message_cache();  /* to free memory */
 		NETCLOSE(control->socket);
 		control->socket = -1;
-		if (TRACE) {
-		    fprintf(stderr,
-		     "HTFTP: Rejecting path due to non-Unix-style syntax.\n");
-		}
+		CTRACE(tfp, "HTFTP: Rejecting path due to non-Unix-style syntax.\n");
 		return -1;
 	    }
 	    /** Handle any unescaped "/%2F" path **/
@@ -2962,21 +2884,15 @@ PUBLIC int HTFTPLoad ARGS4(
 		for (i = 0; filename[(i+1)]; i++)
 		    filename[i] = filename[(i+1)];
 		filename[i] = '\0';
-		if (TRACE) {
-		    fprintf(stderr, "HTFTP: Trimmed '%s'\n", filename);
-		}
+		CTRACE(tfp, "HTFTP: Trimmed '%s'\n", filename);
 		cp = HTMake_VMS_name("", filename);
-		if (TRACE) {
-		    fprintf(stderr, "HTFTP: VMSized '%s'\n", cp);
-		}
+		CTRACE(tfp, "HTFTP: VMSized '%s'\n", cp);
 		if ((cp1=strrchr(cp, ']')) != NULL) {
 		    cp1++;
 		    for (i = 0; cp1[i]; i++)
 			filename[i] = cp1[i];
 		    filename[i] = '\0';
-		    if (TRACE) {
-			fprintf(stderr, "HTFTP: Filename '%s'\n", filename);
-		    }
+		    CTRACE(tfp, "HTFTP: Filename '%s'\n", filename);
 		    *cp1 = '\0';
 		    sprintf(command, "CWD %s%c%c", cp, CR, LF);
 		    status = response (command);
@@ -3017,9 +2933,7 @@ PUBLIC int HTFTPLoad ARGS4(
 			for (i = 0; cp1[i]; i++)
 			    filename[i] = cp1[i];
 			filename[i] = '\0';
-			if (TRACE) {
-			    fprintf(stderr, "HTFTP: Filename '%s'\n", filename);
-			}
+			CTRACE(tfp, "HTFTP: Filename '%s'\n", filename);
 			*cp1 = '\0';
 			strcat(cp, "[");
 			strcat(cp, filename);
@@ -3359,8 +3273,7 @@ listen:
 	/* Reset buffering to control connection DD 921208 */
 
 	status = NETCLOSE(data_soc);
-	if (TRACE)
-	    fprintf(stderr, "HTFTP: Closing data socket %d\n", data_soc);
+	CTRACE(tfp, "HTFTP: Closing data socket %d\n", data_soc);
 	if (status < 0 && rv != HT_INTERRUPTED && rv != -1) {
 	    (void) HTInetStatus("close");	/* Comment only */
 	    data_soc = -1;			/* invalidate it */
diff --git a/WWW/Library/Implementation/HTFWriter.c b/WWW/Library/Implementation/HTFWriter.c
index 8de75085..74d09866 100644
--- a/WWW/Library/Implementation/HTFWriter.c
+++ b/WWW/Library/Implementation/HTFWriter.c
@@ -153,8 +153,7 @@ PRIVATE void HTFWriter_abort ARGS2(HTStream *, me, HTError, e)
 {
     fclose(me->fp);
     if (me->end_command) {		/* Temp file */
-	if (TRACE) fprintf(stderr,
-		"HTFWriter: Aborting: file not executed.\n");
+	CTRACE(tfp, "HTFWriter: Aborting: file not executed.\n");
 	FREE(me->end_command);
 	if (me->remove_command) {
 	    system(me->remove_command);
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 3bc93f1e..0e405b82 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -578,21 +578,32 @@ PUBLIC char * HTLocalName ARGS1(
 	if ((0 == strcasecomp(host, HTHostName())) ||
 	    (0 == strcasecomp(host, "localhost")) || !*host) {
 	    FREE(host);
-	    if (TRACE)
-		fprintf(stderr, "Node `%s' means path `%s'\n", name, path);
+	    CTRACE(tfp, "Node `%s' means path `%s'\n", name, path);
 #ifdef DOSPATH
 	    {
 		char *ret_path = NULL;
 		StrAllocCopy(ret_path, HTDOS_name(path));
-		if (TRACE) {
-		    fprintf(stderr, "HTDOS_name changed `%s' to `%s'\n",
+		CTRACE(tfp, "HTDOS_name changed `%s' to `%s'\n",
+			    path, ret_path);
+		FREE(path);
+		return(ret_path);
+	    }
+#else
+#ifdef __EMX__
+	    {
+		char *ret_path = NULL;
+		if (path[0] == '/') /* pesky leading slash */
+		    StrAllocCopy(ret_path, path+1);
+		else
+		    StrAllocCopy(ret_path, path);
+		CTRACE(tfp, "EMX hack changed `%s' to `%s'\n",
 			    path, ret_path);
-		}
 		FREE(path);
 		return(ret_path);
 	    }
 #else
 	    return(path);
+#endif /* __EMX__ */
 #endif /* DOSPATH */
 	} else {
 	    char * result = (char *)malloc(
@@ -602,8 +613,7 @@ PUBLIC char * HTLocalName ARGS1(
 	    sprintf(result, "%s%s%s", "/Net/", host, path);
 	    FREE(host);
 	    FREE(path);
-	    if (TRACE)
-		fprintf(stderr, "Node `%s' means file `%s'\n", name, result);
+	    CTRACE(tfp, "Node `%s' means file `%s'\n", name, result);
 	    return result;
 	}
     } else {  /* other access */
@@ -662,8 +672,7 @@ PUBLIC char * WWW_nameOfFile ARGS1(
 	    outofmem(__FILE__, "WWW_nameOfFile");
 	sprintf(result, "file://%s%s", HTHostName(), name);
     }
-    if (TRACE)
-	fprintf(stderr, "File `%s'\n\tmeans node `%s'\n", name, result);
+    CTRACE(tfp, "File `%s'\n\tmeans node `%s'\n", name, result);
     return result;
 }
 
@@ -866,9 +875,7 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
 	cp[i] = TOLOWER(cp[i]);
     if (((cp1 = strchr(cp, ';')) != NULL) &&
 	(cp2 = strstr(cp1, "charset")) != NULL) {
-	if (TRACE)
-	    fprintf(stderr,
-		    "HTCharsetFormat: Extended MIME Content-Type is %s\n",
+	CTRACE(tfp, "HTCharsetFormat: Extended MIME Content-Type is %s\n",
 		    format->name);
 	cp2 += 7;
 	while (*cp2 == ' ' || *cp2 == '=')
@@ -1032,9 +1039,8 @@ PUBLIC float HTFileValue ARGS1(
 	suff = (HTSuffix *)HTList_objectAt(HTSuffixes, i);
 	ls = strlen(suff->suffix);
 	if ((ls <= lf) && 0==strcmp(suff->suffix, filename + lf - ls)) {
-	    if (TRACE)
-		fprintf(stderr, "File: Value of %s is %.3f\n",
-				filename, suff->quality);
+	    CTRACE(tfp, "File: Value of %s is %.3f\n",
+			filename, suff->quality);
 	    return suff->quality;		/* OK -- found */
 	}
     }
@@ -1099,14 +1105,14 @@ PUBLIC BOOL HTEditable ARGS1(
 
     if (TRACE) {
 	int i2;
-	fprintf(stderr,
+	fprintf(tfp,
 	    "File mode is 0%o, uid=%d, gid=%d. My uid=%d, %d groups (",
 	    (unsigned int) fileStatus.st_mode, fileStatus.st_uid,
 	    fileStatus.st_gid,
 	    myUid, ngroups);
 	for (i2 = 0; i2 < ngroups; i2++)
-	    fprintf(stderr, " %d", groups[i2]);
-	fprintf(stderr, ")\n");
+	    fprintf(tfp, " %d", groups[i2]);
+	fprintf(tfp, ")\n");
     }
 
     if (fileStatus.st_mode & 0002)		/* I can write anyway? */
@@ -1123,8 +1129,7 @@ PUBLIC BOOL HTEditable ARGS1(
 		return YES;
 	}
     }
-    if (TRACE)
-	fprintf(stderr, "\tFile is not editable.\n");
+    CTRACE(tfp, "\tFile is not editable.\n");
     return NO;					/* If no excuse, can't do */
 #endif /* NO_GROUPS */
 }
@@ -1527,8 +1532,7 @@ PUBLIC int HTLoadFile ARGS4(
     **	to the directories or files listed.
     */
     if (HTStat(filename, &stat_info) == -1) {
-	if (TRACE)
-	    fprintf(stderr, "HTLoadFile: Can't stat %s\n", filename);
+	CTRACE(tfp, "HTLoadFile: Can't stat %s\n", filename);
     } else {
 	if (((stat_info.st_mode) & S_IFMT) == S_IFDIR) {
 	    if (HTDirAccess == HT_DIR_FORBID) {
@@ -1576,14 +1580,12 @@ PUBLIC int HTLoadFile ARGS4(
 	*/
 	if (!fp) {
 	    char ultrixname[INFINITY];
-	    if (TRACE)
-		fprintf(stderr, "HTLoadFile: Can't open as %s\n", vmsname);
+	    CTRACE(tfp, "HTLoadFile: Can't open as %s\n", vmsname);
 	    sprintf(ultrixname, "%s::\"%s\"", nodename, filename);
 	    fp = fopen(ultrixname, "r", "shr=put", "shr=upd");
 	    if (!fp) {
-		if (TRACE)
-		    fprintf(stderr, "HTLoadFile: Can't open as %s\n",
-				    ultrixname);
+		CTRACE(tfp, "HTLoadFile: Can't open as %s\n",
+			    ultrixname);
 	    }
 	}
 	if (fp) {
@@ -1623,9 +1625,7 @@ PUBLIC int HTLoadFile ARGS4(
 			*semicolon = ';';
 		    gzfp = gzopen(vmsname, "rb");
 
-		    if (TRACE)
-			fprintf(stderr,
-				"HTLoadFile: gzopen of `%s' gives %p\n",
+		    CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 				vmsname, (void*)gzfp);
 		    use_gzread = YES;
 		} else
@@ -1671,9 +1671,7 @@ PUBLIC int HTLoadFile ARGS4(
 				*semicolon = ';';
 			    gzfp = gzopen(vmsname, "rb");
 
-			    if (TRACE)
-				fprintf(stderr,
-				       "HTLoadFile: gzopen of `%s' gives %p\n",
+			    CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 					vmsname, (void*)gzfp);
 			    use_gzread = YES;
 			}
@@ -1846,9 +1844,7 @@ PUBLIC int HTLoadFile ARGS4(
 			}
 		    }
 		    if (value != NO_VALUE_FOUND) {
-			if (TRACE)
-			    fprintf(stderr,
-				 "HTLoadFile: value of presenting %s is %f\n",
+			CTRACE(tfp, "HTLoadFile: value of presenting %s is %f\n",
 				    HTAtom_name(rep), value);
 			if  (value > best) {
 			    best_rep = rep;
@@ -1894,8 +1890,7 @@ PUBLIC int HTLoadFile ARGS4(
 #endif
 	{
 				       /* if can't read file information */
-	    if (TRACE)
-		fprintf(stderr, "HTLoadFile: can't stat %s\n", localname);
+	    CTRACE(tfp, "HTLoadFile: can't stat %s\n", localname);
 
 	}  else {		/* Stat was OK */
 
@@ -1919,8 +1914,7 @@ PUBLIC int HTLoadFile ARGS4(
 		BOOL need_parent_link = FALSE;
 		struct stat file_info;
 
-		if (TRACE)
-		    fprintf(stderr, "%s is a directory\n", localname);
+		CTRACE(tfp, "%s is a directory\n", localname);
 
 		/*
 		**  Check directory access.
@@ -2244,8 +2238,7 @@ PUBLIC int HTLoadFile ARGS4(
 	{
 	    FILE * fp = fopen(localname, "r");
 
-	    if (TRACE)
-		fprintf (stderr, "HTLoadFile: Opening `%s' gives %p\n",
+	    CTRACE (tfp, "HTLoadFile: Opening `%s' gives %p\n",
 				 localname, (void*)fp);
 	    if (fp) {		/* Good! */
 		int len;
@@ -2274,9 +2267,7 @@ PUBLIC int HTLoadFile ARGS4(
 			fclose(fp);
 			gzfp = gzopen(localname, "rb");
 
-			if (TRACE)
-			    fprintf(stderr,
-				    "HTLoadFile: gzopen of `%s' gives %p\n",
+			CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 				    localname, (void*)gzfp);
 			use_gzread = YES;
 		    } else
@@ -2315,9 +2306,7 @@ PUBLIC int HTLoadFile ARGS4(
 			    fclose(fp);
 			    gzfp = gzopen(localname, "rb");
 
-			    if (TRACE)
-				fprintf(stderr,
-				       "HTLoadFile: gzopen of `%s' gives %p\n",
+			    CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 					localname, (void*)gzfp);
 			    use_gzread = YES;
 			}
@@ -2404,8 +2393,7 @@ PUBLIC int HTLoadFile ARGS4(
     **	All attempts have failed.
     */
     {
-	if (TRACE)
-	    fprintf(stderr, "Can't open `%s', errno=%d\n", addr, SOCKET_ERRNO);
+	CTRACE(tfp, "Can't open `%s', errno=%d\n", addr, SOCKET_ERRNO);
 
 	return HTLoadError(sink, 403, "Can't access requested file.");
     }
diff --git a/WWW/Library/Implementation/HTFinger.c b/WWW/Library/Implementation/HTFinger.c
index 042d137c..89c5540c 100644
--- a/WWW/Library/Implementation/HTFinger.c
+++ b/WWW/Library/Implementation/HTFinger.c
@@ -37,8 +37,6 @@
 
 #include <LYLeaks.h>
 
-/* #define TRACE 1 */
-
 #define FINGER_PORT 79		/* See rfc742 */
 #define BIG 1024		/* Bug */
 
@@ -129,13 +127,10 @@ PRIVATE int response ARGS5(
 
     /* Send the command.
     */
-    if (TRACE) 
-        fprintf(stderr, "HTFinger command to be sent: %s", command);
+    CTRACE(tfp, "HTFinger command to be sent: %s", command);
     status = NETWRITE(s, (char *)command, length);
     if (status < 0) {
-        if (TRACE)
-	    fprintf(stderr,
-                    "HTFinger: Unable to send command. Disconnecting.\n");
+	CTRACE(tfp, "HTFinger: Unable to send command. Disconnecting.\n");
         NETCLOSE(s);
         s = -1;
         return status;
@@ -148,8 +143,7 @@ PRIVATE int response ARGS5(
 
     /* Create the results report.
     */
-    if (TRACE)
-	fprintf(stderr,"HTFinger: Reading finger information\n");
+    CTRACE(tfp,"HTFinger: Reading finger information\n");
     START(HTML_HTML);
     PUTS("\n");
     START(HTML_HEAD);
@@ -190,10 +184,7 @@ PRIVATE int response ARGS5(
     while ((ch=NEXT_CHAR) != (char)EOF) {
 
 	if (interrupted_in_htgetcharacter) {
-	    if (TRACE) {
-	        fprintf(stderr,
-		  "HTFinger: Interrupted in HTGetCharacter, apparently.\n");
-	    }
+	    CTRACE(tfp, "HTFinger: Interrupted in HTGetCharacter, apparently.\n");
 	    _HTProgress ("Connection interrupted.");
 	    goto end_html;
         }
@@ -270,9 +261,7 @@ PUBLIC int HTLoadFinger ARGS4(
     int port;				/* Port number from URL */
     int status;				/* tcp return */
   
-    if (TRACE) {
-        fprintf(stderr, "HTFinger: Looking for %s\n", (arg ? arg : "NULL"));
-    }
+    CTRACE(tfp, "HTFinger: Looking for %s\n", (arg ? arg : "NULL"));
   
     if (!(arg && *arg)) {
         HTAlert("Could not load data.");
@@ -391,17 +380,13 @@ PUBLIC int HTLoadFinger ARGS4(
     /* Now, let's get a stream setup up from the FingerHost:
     ** CONNECTING to finger host
     */
-    if (TRACE)
-        fprintf(stderr, "HTFinger: doing HTDoConnect on '%s'\n", str);
+    CTRACE(tfp, "HTFinger: doing HTDoConnect on '%s'\n", str);
     status = HTDoConnect(str, "finger", FINGER_PORT, &s);
-    if (TRACE)
-        fprintf(stderr, "HTFinger: Done DoConnect; status %d\n", status);
+    CTRACE(tfp, "HTFinger: Done DoConnect; status %d\n", status);
 
     if (status == HT_INTERRUPTED) {
         /* Interrupt cleanly */
-	if (TRACE)
-	    fprintf(stderr,
-	    	  "HTFinger: Interrupted on connect; recovering cleanly.\n");
+	CTRACE(tfp, "HTFinger: Interrupted on connect; recovering cleanly.\n");
 	HTProgress ("Connection interrupted.");
 	FREE(str);
 	FREE(command);
@@ -410,15 +395,13 @@ PUBLIC int HTLoadFinger ARGS4(
     if (status < 0) {
         NETCLOSE(s);
 	s = -1;
-	if (TRACE) 
-	    fprintf(stderr, "HTFinger: Unable to connect to finger host.\n");
+	CTRACE(tfp, "HTFinger: Unable to connect to finger host.\n");
         HTAlert("Could not access finger host.");
 	FREE(str);
 	FREE(command);
 	return HT_NOT_LOADED;	/* FAIL */
     }
-    if (TRACE)
-        fprintf(stderr, "HTFinger: Connected to finger host '%s'.\n", str);
+    CTRACE(tfp, "HTFinger: Connected to finger host '%s'.\n", str);
     FREE(str);
 
     /* Send the command, and process response if successful.
diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c
index baffca71..cdd2fa9b 100644
--- a/WWW/Library/Implementation/HTFormat.c
+++ b/WWW/Library/Implementation/HTFormat.c
@@ -235,14 +235,11 @@ PUBLIC char HTGetCharacter NOARGS
 		if (status == 0)
 		    return (char)EOF;
 		if (status == HT_INTERRUPTED) {
-		    if (TRACE)
-			fprintf(stderr,
-				"HTFormat: Interrupted in HTGetCharacter\n");
+		    CTRACE(tfp, "HTFormat: Interrupted in HTGetCharacter\n");
 		    interrupted_in_htgetcharacter = 1;
 		    return (char)EOF;
 		}
-		if (TRACE)
-		    fprintf(stderr, "HTFormat: File read error %d\n", status);
+		CTRACE(tfp, "HTFormat: File read error %d\n", status);
 		return (char)EOF; /* -1 is returned by UCX
 				     at end of HTTP link */
 	    }
@@ -266,9 +263,8 @@ PRIVATE int half_match ARGS2(char *,trial_type, char *,target)
     if (!cp || *(cp+1) != '*')
 	return 0;
 
-    if (TRACE)
-	fprintf(stderr,"HTFormat: comparing %s and %s for half match\n",
-						      trial_type, target);
+    CTRACE(tfp, "HTFormat: comparing %s and %s for half match\n",
+	        trial_type, target);
 
 	/* main type matches */
     if (!strncmp(trial_type, target, (cp-trial_type)-1))
@@ -295,9 +291,7 @@ PRIVATE HTPresentation * HTFindPresentation ARGS3(
 {
     HTAtom * wildcard = HTAtom_for("*");
 
-    if (TRACE)
-	fprintf(stderr,
-		"HTFormat: Looking up presentation for %s to %s\n",
+    CTRACE(tfp, "HTFormat: Looking up presentation for %s to %s\n",
 		HTAtom_name(rep_in), HTAtom_name(rep_out));
 
     /* don't do anymore do it in the Lynx code at startup LJM */
@@ -316,9 +310,7 @@ PRIVATE HTPresentation * HTFindPresentation ARGS3(
 	    pres = (HTPresentation *)HTList_objectAt(HTPresentations, i);
 	    if (pres->rep == rep_in) {
 		if (pres->rep_out == rep_out) {
-		    if (TRACE)
-			fprintf(stderr,
-				"FindPresentation: found exact match: %s\n",
+		    CTRACE(tfp, "FindPresentation: found exact match: %s\n",
 				HTAtom_name(pres->rep));
 		    return pres;
 
@@ -328,9 +320,7 @@ PRIVATE HTPresentation * HTFindPresentation ARGS3(
 		    if (!strong_wildcard_match)
 			strong_wildcard_match = pres;
 		    /* otherwise use the first one */
-		    if (TRACE)
-			fprintf(stderr,
-			     "StreamStack: found strong wildcard match: %s\n",
+		    CTRACE(tfp, "StreamStack: found strong wildcard match: %s\n",
 				HTAtom_name(pres->rep));
 		}
 
@@ -343,9 +333,7 @@ PRIVATE HTPresentation * HTFindPresentation ARGS3(
 		    if (!strong_subtype_wildcard_match)
 			strong_subtype_wildcard_match = pres;
 		    /* otherwise use the first one */
-		    if (TRACE)
-			fprintf(stderr,
-		     "StreamStack: found strong subtype wildcard match: %s\n",
+		    CTRACE(tfp, "StreamStack: found strong subtype wildcard match: %s\n",
 				HTAtom_name(pres->rep));
 		}
 	    }
@@ -355,9 +343,7 @@ PRIVATE HTPresentation * HTFindPresentation ARGS3(
 		    if (!weak_wildcard_match)
 			weak_wildcard_match = pres;
 		    /* otherwise use the first one */
-		    if (TRACE)
-			fprintf(stderr,
-			    "StreamStack: found weak wildcard match: %s\n",
+		    CTRACE(tfp, "StreamStack: found weak wildcard match: %s\n",
 				HTAtom_name(pres->rep_out));
 		}
 		if (pres->rep_out == wildcard) {
@@ -403,9 +389,7 @@ PUBLIC HTStream * HTStreamStack ARGS4(
     HTPresentation temp;
     HTPresentation *match;
 
-    if (TRACE)
-	fprintf(stderr,
-		"HTFormat: Constructing stream stack for %s to %s\n",
+    CTRACE(tfp, "HTFormat: Constructing stream stack for %s to %s\n",
 		HTAtom_name(rep_in), HTAtom_name(rep_out));
 
     /* don't return on WWW_SOURCE some people might like
@@ -419,13 +403,9 @@ PUBLIC HTStream * HTStreamStack ARGS4(
 
     if ((match = HTFindPresentation(rep_in, rep_out, &temp))) {
 	if (match == &temp) {
-	    if (TRACE)
-		fprintf(stderr,
-			"StreamStack: Using %s\n", HTAtom_name(temp.rep_out));
+	    CTRACE(tfp, "StreamStack: Using %s\n", HTAtom_name(temp.rep_out));
 	} else {
-	    if (TRACE)
-		fprintf(stderr,
-			"StreamStack: found exact match: %s\n",
+	    CTRACE(tfp, "StreamStack: found exact match: %s\n",
 			HTAtom_name(match->rep));
 	}
 	return (*match->converter)(match, anchor, sink);
@@ -466,9 +446,7 @@ PUBLIC float HTStackValue ARGS4(
 {
     HTAtom * wildcard = HTAtom_for("*");
 
-    if (TRACE)
-	fprintf(stderr,
-		"HTFormat: Evaluating stream stack for %s worth %.3f to %s\n",
+    CTRACE(tfp, "HTFormat: Evaluating stream stack for %s worth %.3f to %s\n",
 		HTAtom_name(rep_in), initial_value, HTAtom_name(rep_out));
 
     if (rep_out == WWW_SOURCE || rep_out == rep_in)
@@ -579,8 +557,7 @@ PUBLIC int HTCopy ARGS4(
 		    *  Treat what we've gotten already
 		    *  as the complete transmission. - FM
 		    */
-		   if (TRACE)
-		       fprintf(stderr,
+		   CTRACE(tfp,
 	    "HTCopy: Unexpected server disconnect. Treating as completed.\n");
 		   status = 0;
 		   break;
@@ -649,9 +626,7 @@ PUBLIC int HTFileCopy ARGS2(
 		rv = HT_LOADED;
 		break;
 	    }
-	    if (TRACE)
-		fprintf(stderr,
-			"HTFormat: Read error, read returns %d\n",
+	    CTRACE(tfp, "HTFormat: Read error, read returns %d\n",
 			ferror(fp));
 	    if (bytes) {
 		rv = HT_PARTIAL_CONTENT;
@@ -734,13 +709,11 @@ PRIVATE int HTGzFileCopy ARGS2(
 		rv = HT_LOADED;
 		break;
 	    }
-	    if (TRACE) {
-		fprintf(stderr,
-			"HTGzFileCopy: Read error, gzread returns %d\n",
+	    CTRACE(tfp, "HTGzFileCopy: Read error, gzread returns %d\n",
 			status);
-		fprintf(stderr,
-			"gzerror   : %s\n",
+	    CTRACE(tfp, "gzerror   : %s\n",
 			gzerror(gzfp, &gzerrnum));
+	    if (TRACE) {
 		if (gzerrnum == Z_ERRNO)
 		    perror("gzerror   ");
 	    }
@@ -862,8 +835,7 @@ PUBLIC int HTParseSocket ARGS5(
 	}
 	sprintf(buffer, "Sorry, can't convert from %s to %s.",
 		HTAtom_name(rep_in), HTAtom_name(format_out));
-	if (TRACE)
-	    fprintf(stderr, "HTFormat: %s\n", buffer);
+	CTRACE(tfp, "HTFormat: %s\n", buffer);
 	return HTLoadError(sink, 501, buffer); /* returns -501 */
     }
 
@@ -911,8 +883,7 @@ PUBLIC int HTParseFile ARGS5(
 	}
 	sprintf(buffer, "Sorry, can't convert from %s to %s.",
 		HTAtom_name(rep_in), HTAtom_name(format_out));
-	if (TRACE)
-	    fprintf(stderr, "HTFormat(in HTParseFile): %s\n", buffer);
+	CTRACE(tfp, "HTFormat(in HTParseFile): %s\n", buffer);
 	return HTLoadError(sink, 501, buffer);
     }
 
@@ -950,7 +921,7 @@ PRIVATE int HTCloseGzFile ARGS1(
 	if (gzres == Z_ERRNO) {
 	    perror("gzclose   ");
 	} else if (gzres != Z_OK) {
-	    fprintf(stderr, "gzclose   : error number %d\n", gzres);
+	    CTRACE(tfp, "gzclose   : error number %d\n", gzres);
 	}
     }
     return(gzres);
@@ -981,8 +952,7 @@ PUBLIC int HTParseGzFile ARGS5(
 	}
 	sprintf(buffer, "Sorry, can't convert from %s to %s.",
 		HTAtom_name(rep_in), HTAtom_name(format_out));
-	if (TRACE)
-	    fprintf(stderr, "HTFormat(in HTParseGzFile): %s\n", buffer);
+	CTRACE(tfp, "HTFormat(in HTParseGzFile): %s\n", buffer);
 	return HTLoadError(sink, 501, buffer);
     }
 
diff --git a/WWW/Library/Implementation/HTGopher.c b/WWW/Library/Implementation/HTGopher.c
index e168ac8e..ddc6a0aa 100644
--- a/WWW/Library/Implementation/HTGopher.c
+++ b/WWW/Library/Implementation/HTGopher.c
@@ -196,8 +196,7 @@ PRIVATE void write_anchor ARGS2(CONST char *,text, CONST char *,addr)
     present[HTML_A_TITLE] = YES;
     ((CONST char **)value)[HTML_A_TITLE] = text;
 
-    if(TRACE)
-	fprintf(stderr,"HTGopher: adding URL: %s\n",addr);
+    CTRACE(tfp,"HTGopher: adding URL: %s\n",addr);
 
     HT_Is_Gopher_URL = TRUE;  /* tell HTML.c that this is a Gopher URL */
     (*targetClass.start_element)(target, HTML_A, present,
@@ -258,9 +257,7 @@ PRIVATE void parse_menu ARGS2(
     while ((ch=NEXT_CHAR) != (char)EOF) {
 
 	if (interrupted_in_htgetcharacter) {
-	    if (TRACE)
-		fprintf(stderr,
-		    "HTGopher: Interrupted in HTGetCharacter, apparently.\n");
+	    CTRACE(tfp, "HTGopher: Interrupted in HTGetCharacter, apparently.\n");
 	    goto end_html;
 	}
 
@@ -273,8 +270,7 @@ PRIVATE void parse_menu ARGS2(
 	    bytes += p-line;	/* add size */
 	    p = line;		/* Scan it to parse it */
 	    port = 0;		/* Flag "not parsed" */
-	    if (TRACE)
-		fprintf(stderr, "HTGopher: Menu item: %s\n", line);
+	    CTRACE(tfp, "HTGopher: Menu item: %s\n", line);
 	    gtype = *p++;
 
 	    if (bytes > BytesReported + 1024) {
@@ -428,8 +424,7 @@ PRIVATE void parse_menu ARGS2(
 		else
 		    PUTS(name);
 	    } else { /* parse error */
-		if (TRACE)
-		    fprintf(stderr, "HTGopher: Bad menu item.\n");
+		CTRACE(tfp, "HTGopher: Bad menu item.\n");
 		PUTS(line);
 
 	    } /* parse error */
@@ -950,10 +945,7 @@ PRIVATE int parse_cso_fields ARGS2(
     */
     while ((ch = NEXT_CHAR) != (char)EOF) {
 	if (interrupted_in_htgetcharacter) {
-	    if (TRACE) {
-		fprintf(stderr,
-		  "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n");
-	    }
+	    CTRACE(tfp, "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n");
 	    free_CSOfields();
 	    buf[0] = '\0';
 	    return HT_INTERRUPTED;
@@ -1254,10 +1246,7 @@ PRIVATE int generate_cso_report ARGS2(
     while (!stop && (ch = NEXT_CHAR) != (char)EOF) {
 	if (interrupted_in_htgetcharacter) {
 	    buf[0] = '\0';
-	    if (TRACE) {
-		fprintf(stderr,
-		  "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n");
-	    }
+	    CTRACE(tfp, "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n");
 	    _HTProgress ("Connection interrupted.");
 	    goto end_CSOreport;
 	}
@@ -1499,8 +1488,7 @@ PRIVATE int HTLoadCSO ARGS4(
 	return -3;		/* Bad if no name sepcified	*/
     if (!*arg)
 	return -2;		/* Bad if name had zero length	*/
-    if (TRACE)
-	fprintf(stderr, "HTLoadCSO: Looking for %s\n", arg);
+    CTRACE(tfp, "HTLoadCSO: Looking for %s\n", arg);
 
     /*
     **	Set up a socket to the server for the data.
@@ -1510,16 +1498,12 @@ PRIVATE int HTLoadCSO ARGS4(
 	/*
 	**  Interrupt cleanly.
 	*/
-	if (TRACE)
-	    fprintf(stderr,
-		 "HTLoadCSO: Interrupted on connect; recovering cleanly.\n");
+	CTRACE(tfp, "HTLoadCSO: Interrupted on connect; recovering cleanly.\n");
 	_HTProgress ("Connection interrupted.");
 	return HT_NOT_LOADED;
     }
     if (status < 0) {
-	if (TRACE)
-	    fprintf(stderr,
-		    "HTLoadCSO: Unable to connect to remote host for `%s'.\n",
+	CTRACE(tfp, "HTLoadCSO: Unable to connect to remote host for `%s'.\n",
 		    arg);
 	return HTInetStatus("connect");
     }
@@ -1529,16 +1513,13 @@ PRIVATE int HTLoadCSO ARGS4(
     if ((command = (char *)malloc(12)) == NULL)
 	outofmem(__FILE__, "HTLoadCSO");
     sprintf(command, "fields%c%c", CR, LF);
-    if (TRACE)
-	fprintf(stderr,
-		"HTLoadCSO: Connected, writing command `%s' to socket %d\n",
+    CTRACE(tfp, "HTLoadCSO: Connected, writing command `%s' to socket %d\n",
 		command, s);
     _HTProgress ("Sending CSO/PH request.");
     status = NETWRITE(s, command, (int)strlen(command));
     FREE(command);
     if (status < 0) {
-	if (TRACE)
-	    fprintf(stderr, "HTLoadCSO: Unable to send command.\n");
+	CTRACE(tfp, "HTLoadCSO: Unable to send command.\n");
 	return HTInetStatus("send");
     }
     _HTProgress ("CSO/PH request sent; waiting for response.");
@@ -1715,15 +1696,12 @@ PRIVATE int HTLoadCSO ARGS4(
     (*Target->isa->put_block)(Target, command, clen);
     strcpy(buf, "</H2>\n");
     (*Target->isa->put_block)(Target, buf, strlen(buf));
-    if (TRACE)
-	fprintf(stderr,
-		"HTLoadCSO: Writing command `%s' to socket %d\n",
+    CTRACE(tfp, "HTLoadCSO: Writing command `%s' to socket %d\n",
 		command, s);
     status = NETWRITE(s, command, clen);
     FREE(command);
     if (status < 0) {
-	if (TRACE)
-	    fprintf(stderr, "HTLoadCSO: Unable to send command.\n");
+	CTRACE(tfp, "HTLoadCSO: Unable to send command.\n");
 	free_CSOfields();
 	return HTInetStatus("send");
     }
@@ -1761,8 +1739,7 @@ PRIVATE int HTLoadGopher ARGS4(
 	return -3;		/* Bad if no name sepcified	*/
     if (!*arg)
 	return -2;		/* Bad if name had zero length	*/
-    if (TRACE)
-	fprintf(stderr, "HTGopher: Looking for %s\n", arg);
+    CTRACE(tfp, "HTGopher: Looking for %s\n", arg);
 
     /*
     **	If it's a port 105 GOPHER_CSO gtype with no ISINDEX token ('?'),
@@ -1775,8 +1752,7 @@ PRIVATE int HTLoadGopher ARGS4(
 	if ((len = strlen(arg)) > 5) {
 	    if (0 == strcmp((CONST char *)&arg[len-6], ":105/2")) {
 		/* Use CSO gateway. */
-		if (TRACE)
-		    fprintf(stderr, "HTGopher: Passing to CSO/PH gateway.\n");
+		CTRACE(tfp, "HTGopher: Passing to CSO/PH gateway.\n");
 		return HTLoadCSO(arg, anAnchor, format_out, sink);
 	    }
 	}
@@ -1786,8 +1762,7 @@ PRIVATE int HTLoadGopher ARGS4(
     **	If it's a port 79/0[/...] URL, use the finger gateway. - FM
     */
     if (strstr(arg, ":79/0") != NULL) {
-	if (TRACE)
-	    fprintf(stderr, "HTGopher: Passing to finger gateway.\n");
+	CTRACE(tfp, "HTGopher: Passing to finger gateway.\n");
 	return HTLoadFinger(arg, anAnchor, format_out, sink);
     }
 
@@ -1884,17 +1859,13 @@ PRIVATE int HTLoadGopher ARGS4(
 	/*
 	**  Interrupt cleanly.
 	*/
-	if (TRACE)
-	    fprintf(stderr,
-		    "HTGopher: Interrupted on connect; recovering cleanly.\n");
+	CTRACE(tfp, "HTGopher: Interrupted on connect; recovering cleanly.\n");
 	_HTProgress ("Connection interrupted.");
 	FREE(command);
 	return HT_NOT_LOADED;
     }
     if (status < 0) {
-	if (TRACE)
-	    fprintf(stderr,
-		    "HTGopher: Unable to connect to remote host for `%s'.\n",
+	CTRACE(tfp, "HTGopher: Unable to connect to remote host for `%s'.\n",
 		    arg);
 	FREE(command);
 	return HTInetStatus("connect");
@@ -1902,9 +1873,7 @@ PRIVATE int HTLoadGopher ARGS4(
 
     HTInitInput(s);		/* Set up input buffering */
 
-    if (TRACE)
-	fprintf(stderr,
-		"HTGopher: Connected, writing command `%s' to socket %d\n",
+    CTRACE(tfp, "HTGopher: Connected, writing command `%s' to socket %d\n",
 		command, s);
 
 #ifdef NOT_ASCII
@@ -1921,8 +1890,7 @@ PRIVATE int HTLoadGopher ARGS4(
     status = NETWRITE(s, command, (int)strlen(command));
     FREE(command);
     if (status < 0) {
-	if (TRACE)
-	    fprintf(stderr, "HTGopher: Unable to send command.\n");
+	CTRACE(tfp, "HTGopher: Unable to send command.\n");
 	return HTInetStatus("send");
     }
 
diff --git a/WWW/Library/Implementation/HTGroup.c b/WWW/Library/Implementation/HTGroup.c
index d48c298d..71fd1445 100644
--- a/WWW/Library/Implementation/HTGroup.c
+++ b/WWW/Library/Implementation/HTGroup.c
@@ -82,8 +82,7 @@ PRIVATE void syntax_error ARGS3(FILE *,	 fp,
 	if (cnt < 40) buffer[cnt++] = ch;
     buffer[cnt] = (char)0;
 
-    if (TRACE)
-	fprintf(stderr, "%s %d before: '%s'\nHTGroup.c: %s (got %s)\n",
+    CTRACE(tfp, "%s %d before: '%s'\nHTGroup.c: %s (got %s)\n",
 		"HTGroup.c: Syntax error in rule file at line",
 		HTlex_line, buffer, msg, lex_verbose(lex_item));
     HTlex_line++;
@@ -397,7 +396,7 @@ PRIVATE GroupDefList *parse_group_file ARGS1(FILE *, fp)
 PRIVATE void print_item ARGS1(Item *, item)
 {
     if (!item)
-	fprintf(stderr, "\tNULL-ITEM\n");
+	fprintf(tfp, "\tNULL-ITEM\n");
     else {
 	UserDefList *cur1 = item->user_def_list;
 	AddressDefList *cur2 = item->address_def_list;
@@ -405,20 +404,20 @@ PRIVATE void print_item ARGS1(Item *, item)
 	Ref *addr_ref = (Ref*)HTList_nextObject(cur2);
 
 	if (user_ref) {
-	    fprintf(stderr, "\t[%s%s", user_ref->name,
+	    fprintf(tfp, "\t[%s%s", user_ref->name,
 		    (user_ref->translation ? "*REF*" : ""));
 	    while (NULL != (user_ref = (Ref*)HTList_nextObject(cur1)))
-		fprintf(stderr, "; %s%s", user_ref->name,
+		fprintf(tfp, "; %s%s", user_ref->name,
 			(user_ref->translation ? "*REF*" : ""));
-	    fprintf(stderr, "] ");
-	} else fprintf(stderr, "\tANYBODY ");
+	    fprintf(tfp, "] ");
+	} else fprintf(tfp, "\tANYBODY ");
 
 	if (addr_ref) {
-	    fprintf(stderr, "@ [%s", addr_ref->name);
+	    fprintf(tfp, "@ [%s", addr_ref->name);
 	    while (NULL != (addr_ref = (Ref*)HTList_nextObject(cur2)))
-		fprintf(stderr, "; %s", addr_ref->name);
-	    fprintf(stderr, "]\n");
-	} else fprintf(stderr, "@ ANYADDRESS\n");
+		fprintf(tfp, "; %s", addr_ref->name);
+	    fprintf(tfp, "]\n");
+	} else fprintf(tfp, "@ ANYADDRESS\n");
     }
 }
 
@@ -429,7 +428,7 @@ PRIVATE void print_item_list ARGS1(ItemList *, item_list)
     Item *item;
 
     if (!item_list)
-	fprintf(stderr, "EMPTY");
+	fprintf(tfp, "EMPTY");
     else while (NULL != (item = (Item*)HTList_nextObject(cur)))
 	print_item(item);
 }
@@ -438,15 +437,15 @@ PRIVATE void print_item_list ARGS1(ItemList *, item_list)
 PUBLIC void HTAA_printGroupDef ARGS1(GroupDef *, group_def)
 {
     if (!group_def) {
-	fprintf(stderr, "\nNULL RECORD\n");
+	fprintf(tfp, "\nNULL RECORD\n");
 	return;
     }
 
-    fprintf(stderr, "\nGroup %s:\n",
+    fprintf(tfp, "\nGroup %s:\n",
 	    (group_def->group_name ? group_def->group_name : "NULL"));
 
     print_item_list(group_def->item_list);
-    fprintf(stderr, "\n");
+    fprintf(tfp, "\n");
 }
 
 
@@ -483,6 +482,7 @@ PRIVATE BOOL part_match ARGS2(CONST char *, tcur,
     char actual[4];
     CONST char *cur;
     int cnt;
+    BOOL status;
 
     if (!tcur || !icur) return NO;
 
@@ -498,14 +498,11 @@ PRIVATE BOOL part_match ARGS2(CONST char *, tcur,
 	actual[cnt++] = *(cur++);
     actual[cnt] = (char)0;
 
-    if (TRACE) {
-	BOOL status = HTAA_templateMatch(required, actual);
-	fprintf(stderr, "part_match: req: '%s' act: '%s' match: %s\n",
+    status = HTAA_templateMatch(required, actual);
+    CTRACE(tfp, "part_match: req: '%s' act: '%s' match: %s\n",
 		required, actual, (status ? "yes" : "no"));
-	return status;
-    }
 
-    return HTAA_templateMatch(required, actual);
+    return status;
 }
 
 
@@ -656,21 +653,21 @@ PUBLIC GroupDefList *HTAA_readGroupFile ARGS1(CONST char *, filename)
 
 	while (NULL != (group_cache = (GroupCache*)HTList_nextObject(cur))) {
 	    if (!strcmp(filename, group_cache->group_filename)) {
-		if (TRACE) fprintf(stderr, "%s '%s' %s\n",
-				   "HTAA_readGroupFile: group file",
-				   filename, "already found in cache");
+		CTRACE(tfp, "%s '%s' %s\n",
+			    "HTAA_readGroupFile: group file",
+			    filename, "already found in cache");
 		return group_cache->group_list;
 	    } /* if cache match */
 	} /* while cached files remain */
     } /* cache exists */
 
-    if (TRACE) fprintf(stderr, "HTAA_readGroupFile: reading group file `%s'\n",
-		       filename);
+    CTRACE(tfp, "HTAA_readGroupFile: reading group file `%s'\n",
+	        filename);
 
     if (!(fp = fopen(filename, "r"))) {
-	if (TRACE) fprintf(stderr, "%s '%s'\n",
-			   "HTAA_readGroupFile: unable to open group file",
-			   filename);
+	CTRACE(tfp, "%s '%s'\n",
+		    "HTAA_readGroupFile: unable to open group file",
+		    filename);
 	return NULL;
     }
 
@@ -683,10 +680,9 @@ PUBLIC GroupDefList *HTAA_readGroupFile ARGS1(CONST char *, filename)
     HTList_addObject(group_cache_list, (void*)group_cache);
     fclose(fp);
 
-    if (TRACE) {
-	fprintf(stderr, "Read group file '%s', results follow:\n", filename);
+    CTRACE(tfp, "Read group file '%s', results follow:\n", filename);
+    if (TRACE)
 	print_group_def_list(group_cache->group_list);
-    }
 
     return group_cache->group_list;
 }
diff --git a/WWW/Library/Implementation/HTHistory.c b/WWW/Library/Implementation/HTHistory.c
index 232e4341..bbb87d0a 100644
--- a/WWW/Library/Implementation/HTHistory.c
+++ b/WWW/Library/Implementation/HTHistory.c
@@ -71,10 +71,9 @@ HTAnchor * HTHistory_moveBy
       }
       return destination;
     } else {
-      if (TRACE) fprintf(stderr, 
-      		"HTHistory_moveBy: offset by %+d goes out of list %p.\n",
-		offset, (void*)kids);
-      return NULL;
+        CTRACE(tfp, "HTHistory_moveBy: offset by %+d goes out of list %p.\n",
+		    offset, (void*)kids);
+        return NULL;
     }
   } else {  /* Was a parent */
     return NULL;  /* FIXME we could possibly follow the next link... */
@@ -148,10 +147,11 @@ int HTHistory_count
 */
 
 void HTHistory_leavingFrom
-  ARGS1 (HTAnchor *,anchor)
+    ARGS1 (HTAnchor *,anchor)
 {
-  if (HTList_removeLastObject (history))
-    HTList_addObject (history, anchor);
-  else
-    if (TRACE) fprintf(stderr, "HTHistory_leavingFrom: empty history !\n");
+    if (HTList_removeLastObject (history)) {
+        HTList_addObject (history, anchor);
+    } else {
+        CTRACE(tfp, "HTHistory_leavingFrom: empty history !\n");
+    }
 }
diff --git a/WWW/Library/Implementation/HTList.c b/WWW/Library/Implementation/HTList.c
index 28958181..90b2769c 100644
--- a/WWW/Library/Implementation/HTList.c
+++ b/WWW/Library/Implementation/HTList.c
@@ -63,10 +63,9 @@ PUBLIC void HTList_addObject ARGS2(
 	newNode->next = me->next;
 	me->next = newNode;
 
-    } else if (TRACE) {
-        fprintf(stderr,
-		"HTList: Trying to add object %p to a nonexisting list\n",
-		newObject);
+    } else {
+        CTRACE(tfp, "HTList: Trying to add object %p to a nonexisting list\n",
+		    newObject);
     }
 
     return;
@@ -106,20 +105,14 @@ PUBLIC void HTList_insertObjectAt ARGS3(
     int Pos = pos;
 
     if (!temp) {
-	if (TRACE) {
-	    fprintf(stderr,
-		    "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);
-	}
 	return;
     }
     if (Pos < 0) {
 	Pos = 0;
-	if (TRACE) {
-	    fprintf(stderr,
-		    "HTList: Treating negative object position %d as %d.\n",
+	CTRACE(tfp, "HTList: Treating negative object position %d as %d.\n",
 		    pos, Pos);
-	}
     }
 
     prevNode = temp;
diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c
index 44a554eb..f619eb81 100644
--- a/WWW/Library/Implementation/HTMIME.c
+++ b/WWW/Library/Implementation/HTMIME.c
@@ -232,17 +232,13 @@ PRIVATE void HTMIME_put_character ARGS2(
 	case 'a':
 	case 'A':
 	    me->state = miA;
-	    if (TRACE)
-		fprintf(stderr,
-		       "HTMIME: Got 'A' at beginning of line, state now A\n");
+	    CTRACE(tfp, "HTMIME: Got 'A' at beginning of line, state now A\n");
 	    break;
 
 	case 'c':
 	case 'C':
 	    me->state = miC;
-	    if (TRACE)
-		fprintf (stderr,
-		       "HTMIME: Got 'C' at beginning of line, state now C\n");
+	    CTRACE (tfp, "HTMIME: Got 'C' at beginning of line, state now C\n");
 	    break;
 
 	case 'd':
@@ -250,17 +246,13 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ate:";
 	    me->if_ok = miDATE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf (stderr,
-	      "HTMIME: Got 'D' at beginning of line, checking for 'ate:'\n");
+	    CTRACE (tfp, "HTMIME: Got 'D' at beginning of line, checking for 'ate:'\n");
 	    break;
 
 	case 'e':
 	case 'E':
 	    me->state = miE;
-	    if (TRACE)
-		fprintf (stderr,
-		       "HTMIME: Got 'E' at beginning of line, state now E\n");
+	    CTRACE (tfp, "HTMIME: Got 'E' at beginning of line, state now E\n");
 	    break;
 
 	case 'k':
@@ -268,25 +260,19 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "eep-alive:";
 	    me->if_ok = miKEEP_ALIVE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-	 "HTMIME: Got 'K' at beginning of line, checking for 'eep-alive:'\n");
+	    CTRACE(tfp, "HTMIME: Got 'K' at beginning of line, checking for 'eep-alive:'\n");
 	    break;
 
 	case 'l':
 	case 'L':
 	    me->state = miL;
-	    if (TRACE)
-		fprintf (stderr,
-		       "HTMIME: Got 'L' at beginning of line, state now L\n");
+	    CTRACE (tfp, "HTMIME: Got 'L' at beginning of line, state now L\n");
 	    break;
 
 	case 'p':
 	case 'P':
 	    me->state = miP;
-	    if (TRACE)
-		fprintf (stderr,
-		       "HTMIME: Got 'P' at beginning of line, state now P\n");
+	    CTRACE (tfp, "HTMIME: Got 'P' at beginning of line, state now P\n");
 	    break;
 
 	case 'r':
@@ -294,49 +280,37 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "etry-after:";
 	    me->if_ok = miRETRY_AFTER;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-	 "HTMIME: Got 'R' at beginning of line, checking for 'etry-after'\n");
+	    CTRACE(tfp, "HTMIME: Got 'R' at beginning of line, checking for 'etry-after'\n");
 	    break;
 
 	case 's':
 	case 'S':
 	    me->state = miS;
-	    if (TRACE)
-		fprintf (stderr,
-		       "HTMIME: Got 'S' at beginning of line, state now S\n");
+	    CTRACE (tfp, "HTMIME: Got 'S' at beginning of line, state now S\n");
 	    break;
 
 	case 't':
 	case 'T':
 	    me->state = miT;
-	    if (TRACE)
-		fprintf (stderr,
-		       "HTMIME: Got 'T' at beginning of line, state now T\n");
+	    CTRACE (tfp, "HTMIME: Got 'T' at beginning of line, state now T\n");
 	    break;
 
 	case 'u':
 	case 'U':
 	    me->state = miU;
-	    if (TRACE)
-		fprintf (stderr,
-		       "HTMIME: Got 'U' at beginning of line, state now U\n");
+	    CTRACE (tfp, "HTMIME: Got 'U' at beginning of line, state now U\n");
 	    break;
 
 	case 'v':
 	case 'V':
 	    me->state = miV;
-	    if (TRACE)
-		fprintf (stderr,
-		       "HTMIME: Got 'V' at beginning of line, state now V\n");
+	    CTRACE (tfp, "HTMIME: Got 'V' at beginning of line, state now V\n");
 	    break;
 
 	case 'w':
 	case 'W':
 	    me->state = miW;
-	    if (TRACE)
-		fprintf (stderr,
-		       "HTMIME: Got 'W' at beginning of line, state now W\n");
+	    CTRACE (tfp, "HTMIME: Got 'W' at beginning of line, state now W\n");
 	    break;
 
 	case '\n':			/* Blank line: End of Header! */
@@ -345,9 +319,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		if (strchr(HTAtom_name(me->format), ';') != NULL) {
 		    char *cp = NULL, *cp1, *cp2, *cp3 = NULL, *cp4;
 
-		    if (TRACE)
-			fprintf(stderr,
-				"HTMIME: Extended MIME Content-Type is %s\n",
+		    CTRACE(tfp, "HTMIME: Extended MIME Content-Type is %s\n",
 				HTAtom_name(me->format));
 		    StrAllocCopy(cp, HTAtom_name(me->format));
 		    /*
@@ -546,26 +518,17 @@ PRIVATE void HTMIME_put_character ARGS2(
 		StrAllocCopy(me->anchor->content_type,
 			     HTAtom_name(me->format));
 		if (!me->compression_encoding) {
-		    if (TRACE) {
-			fprintf(stderr,
-		    "HTMIME: MIME Content-Type is '%s', converting to '%s'\n",
-			 HTAtom_name(me->format), HTAtom_name(me->targetRep));
-		    }
+		    CTRACE(tfp, "HTMIME: MIME Content-Type is '%s', converting to '%s'\n",
+				HTAtom_name(me->format), HTAtom_name(me->targetRep));
 		} else {
 		    /*
 		    **	Change the format to that for "www/compressed"
 		    **	and set up a stream to deal with it. - FM
 		    */
-		    if (TRACE) {
-			fprintf(stderr,
-	     "HTMIME: MIME Content-Type is '%s',\n", HTAtom_name(me->format));
-		    }
+		    CTRACE(tfp, "HTMIME: MIME Content-Type is '%s',\n", HTAtom_name(me->format));
 		    me->format = HTAtom_for("www/compressed");
-		    if (TRACE) {
-			fprintf(stderr,
-			 "        Treating as '%s'.  Converting to '%s'\n",
-			 HTAtom_name(me->format), HTAtom_name(me->targetRep));
-		    }
+		    CTRACE(tfp, "        Treating as '%s'.  Converting to '%s'\n",
+				HTAtom_name(me->format), HTAtom_name(me->targetRep));
 		}
 		if (me->set_cookie != NULL || me->set_cookie2 != NULL) {
 		    LYSetCookie(me->set_cookie,
@@ -577,8 +540,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		me->target = HTStreamStack(me->format, me->targetRep,
 					   me->sink , me->anchor);
 		if (!me->target) {
-		    if (TRACE)
-			fprintf(stderr, "HTMIME: Can't translate! ** \n");
+		    CTRACE(tfp, "HTMIME: Can't translate! ** \n");
 		    me->target = me->sink;	/* Cheat */
 		}
 		if (me->target) {
@@ -610,9 +572,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "cept-ranges:";
 	    me->if_ok = miACCEPT_RANGES;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		    "HTMIME: Was A, found C, checking for 'cept-ranges:'\n");
+	    CTRACE(tfp, "HTMIME: Was A, found C, checking for 'cept-ranges:'\n");
 	    break;
 
 	case 'g':
@@ -620,23 +580,18 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "e:";
 	    me->if_ok = miAGE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was A, found G, checking for 'e:'\n");
+	    CTRACE(tfp, "HTMIME: Was A, found G, checking for 'e:'\n");
 	    break;
 
 	case 'l':
 	case 'L':
 	    me->state = miAL;
-	    if (TRACE)
-		fprintf(stderr, "HTMIME: Was A, found L, state now AL'\n");
+	    CTRACE(tfp, "HTMIME: Was A, found L, state now AL'\n");
 	    break;
 
 	default:
-	   if (TRACE)
-	       fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
-		       c, "'g' or 'l'");
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
+			c, "'g' or 'l'");
 	    goto bad_field_name;
 	    break;
 
@@ -650,9 +605,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ow:";
 	    me->if_ok = miALLOW;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		      "HTMIME: Was AL, found L, checking for 'ow:'\n");
+	    CTRACE(tfp, "HTMIME: Was AL, found L, checking for 'ow:'\n");
 	    break;
 
 	case 't':
@@ -660,15 +613,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ernates:";
 	    me->if_ok = miALTERNATES;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was AL, found T, checking for 'ernates:'\n");
+	    CTRACE(tfp, "HTMIME: Was AL, found T, checking for 'ernates:'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'l' or 't'");
 	    goto bad_field_name;
 	    break;
@@ -683,23 +632,18 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "che-control:";
 	    me->if_ok = miCACHE_CONTROL;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		     "HTMIME: Was C, found A, checking for 'che-control:'\n");
+	    CTRACE(tfp, "HTMIME: Was C, found A, checking for 'che-control:'\n");
 	    break;
 
 	case 'o':
 	case 'O':
 	    me->state = miCO;
-	    if (TRACE)
-		fprintf(stderr, "HTMIME: Was C, found O, state now CO'\n");
+	    CTRACE(tfp, "HTMIME: Was C, found O, state now CO'\n");
 	    break;
 
 	default:
-	   if (TRACE)
-	       fprintf(stderr,
-		    "HTMIME: Bad character `%c' found where `%s' expected\n",
-		       c, "'a' or 'o'");
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
+			c, "'a' or 'o'");
 	    goto bad_field_name;
 	    break;
 
@@ -711,9 +655,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	case 'n':
 	case 'N':
 	    me->state = miCON;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was CO, found N, state now CON\n");
+	    CTRACE(tfp, "HTMIME: Was CO, found N, state now CON\n");
 	    break;
 
 	case 'o':
@@ -721,15 +663,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "kie:";
 	    me->if_ok = miCOOKIE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was CO, found O, checking for 'kie:'\n");
+	    CTRACE(tfp, "HTMIME: Was CO, found O, checking for 'kie:'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'n' or 'o'");
 	    goto bad_field_name;
 	    break;
@@ -744,9 +682,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ection:";
 	    me->if_ok = miCONNECTION;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		      "HTMIME: Was CON, found N, checking for 'ection:'\n");
+	    CTRACE(tfp, "HTMIME: Was CON, found N, checking for 'ection:'\n");
 	    break;
 
 	case 't':
@@ -754,15 +690,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ent-";
 	    me->if_ok = miCONTENT_;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was CON, found T, checking for 'ent-'\n");
+	    CTRACE(tfp, "HTMIME: Was CON, found T, checking for 'ent-'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'n' or 't'");
 	    goto bad_field_name;
 	    break;
@@ -777,9 +709,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ag:";
 	    me->if_ok = miETAG;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was E, found T, checking for 'ag:'\n");
+	    CTRACE(tfp, "HTMIME: Was E, found T, checking for 'ag:'\n");
 	    break;
 
 	case 'x':
@@ -787,15 +717,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "pires:";
 	    me->if_ok = miEXPIRES;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was E, found X, checking for 'pires:'\n");
+	    CTRACE(tfp, "HTMIME: Was E, found X, checking for 'pires:'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'t' or 'x'");
 	    goto bad_field_name;
 	    break;
@@ -810,9 +736,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "st-modified:";
 	    me->if_ok = miLAST_MODIFIED;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		     "HTMIME: Was L, found A, checking for 'st-modified:'\n");
+	    CTRACE(tfp, "HTMIME: Was L, found A, checking for 'st-modified:'\n");
 	    break;
 
 	case 'i':
@@ -820,9 +744,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "nk:";
 	    me->if_ok = miLINK;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		     "HTMIME: Was L, found I, checking for 'nk:'\n");
+	    CTRACE(tfp, "HTMIME: Was L, found I, checking for 'nk:'\n");
 	    break;
 
 	case 'o':
@@ -830,15 +752,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "cation:";
 	    me->if_ok = miLOCATION;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was L, found O, checking for 'cation:'\n");
+	    CTRACE(tfp, "HTMIME: Was L, found O, checking for 'cation:'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'a', 'i' or 'o'");
 	    goto bad_field_name;
 	    break;
@@ -851,8 +769,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	case 'r':
 	case 'R':
 	    me->state = miPR;
-	    if (TRACE)
-		fprintf(stderr, "HTMIME: Was P, found R, state now PR'\n");
+	    CTRACE(tfp, "HTMIME: Was P, found R, state now PR'\n");
 	    break;
 
 	case 'u':
@@ -860,15 +777,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "blic:";
 	    me->if_ok = miPUBLIC;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was P, found U, checking for 'blic:'\n");
+	    CTRACE(tfp, "HTMIME: Was P, found U, checking for 'blic:'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'r' or 'u'");
 	    goto bad_field_name;
 	    break;
@@ -883,9 +796,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "gma:";
 	    me->if_ok = miPRAGMA;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was PR, found A, checking for 'gma'\n");
+	    CTRACE(tfp, "HTMIME: Was PR, found A, checking for 'gma'\n");
 	    break;
 
 	case 'o':
@@ -893,15 +804,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "xy-authenticate:";
 	    me->if_ok = miPROXY_AUTHENTICATE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		 "HTMIME: Was PR, found O, checking for 'xy-authenticate'\n");
+	    CTRACE(tfp, "HTMIME: Was PR, found O, checking for 'xy-authenticate'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'a' or 'o'");
 	    goto bad_field_name;
 	    break;
@@ -916,21 +823,17 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "fe:";
 	    me->if_ok = miSAFE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr, "HTMIME: Was S, found A, checking for 'fe:'\n");
+	    CTRACE(tfp, "HTMIME: Was S, found A, checking for 'fe:'\n");
 	    break;
 
 	case 'e':
 	case 'E':
 	    me->state = miSE;
-	    if (TRACE)
-		fprintf(stderr, "HTMIME: Was S, found E, state now SE'\n");
+	    CTRACE(tfp, "HTMIME: Was S, found E, state now SE'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'a' or 'e'");
 	    goto bad_field_name;
 	    break;
@@ -945,9 +848,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ver:";
 	    me->if_ok = miSERVER;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was SE, found R, checking for 'ver'\n");
+	    CTRACE(tfp, "HTMIME: Was SE, found R, checking for 'ver'\n");
 	    break;
 
 	case 't':
@@ -955,15 +856,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "-cookie";
 	    me->if_ok = miSET_COOKIE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		 "HTMIME: Was SE, found T, checking for '-cookie'\n");
+	    CTRACE(tfp, "HTMIME: Was SE, found T, checking for '-cookie'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'r' or 't'");
 	    goto bad_field_name;
 	    break;
@@ -976,24 +873,18 @@ PRIVATE void HTMIME_put_character ARGS2(
 	case ':':
 	    me->field = miSET_COOKIE1;		/* remember it */
 	    me->state = miSKIP_GET_VALUE;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was SET_COOKIE, found :, processing\n");
+	    CTRACE(tfp, "HTMIME: Was SET_COOKIE, found :, processing\n");
 	    break;
 
 	case '2':
 	    me->check_pointer = ":";
 	    me->if_ok = miSET_COOKIE2;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		 "HTMIME: Was SET_COOKIE, found 2, checking for ':'\n");
+	    CTRACE(tfp, "HTMIME: Was SET_COOKIE, found 2, checking for ':'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "':' or '2'");
 	    goto bad_field_name;
 	    break;
@@ -1008,9 +899,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "tle:";
 	    me->if_ok = miTITLE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was T, found I, checking for 'tle:'\n");
+	    CTRACE(tfp, "HTMIME: Was T, found I, checking for 'tle:'\n");
 	    break;
 
 	case 'r':
@@ -1018,15 +907,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ansfer-encoding:";
 	    me->if_ok = miTRANSFER_ENCODING;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		 "HTMIME: Was T, found R, checking for 'ansfer-encoding'\n");
+	    CTRACE(tfp, "HTMIME: Was T, found R, checking for 'ansfer-encoding'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'i' or 'r'");
 	    goto bad_field_name;
 	    break;
@@ -1041,9 +926,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "grade:";
 	    me->if_ok = miUPGRADE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was U, found P, checking for 'grade:'\n");
+	    CTRACE(tfp, "HTMIME: Was U, found P, checking for 'grade:'\n");
 	    break;
 
 	case 'r':
@@ -1051,15 +934,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "i:";
 	    me->if_ok = miURI;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was U, found R, checking for 'i:'\n");
+	    CTRACE(tfp, "HTMIME: Was U, found R, checking for 'i:'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'p' or 'r'");
 	    goto bad_field_name;
 	    break;
@@ -1074,9 +953,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ry:";
 	    me->if_ok = miVARY;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was V, found A, checking for 'ry:'\n");
+	    CTRACE(tfp, "HTMIME: Was V, found A, checking for 'ry:'\n");
 	    break;
 
 	case 'i':
@@ -1084,15 +961,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "a:";
 	    me->if_ok = miVIA;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was V, found I, checking for 'a:'\n");
+	    CTRACE(tfp, "HTMIME: Was V, found I, checking for 'a:'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'a' or 'i'");
 	    goto bad_field_name;
 	    break;
@@ -1107,9 +980,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "rning:";
 	    me->if_ok = miWARNING;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was W, found A, checking for 'rning:'\n");
+	    CTRACE(tfp, "HTMIME: Was W, found A, checking for 'rning:'\n");
 	    break;
 
 	case 'w':
@@ -1117,15 +988,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "w-authenticate:";
 	    me->if_ok = miWWW_AUTHENTICATE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		  "HTMIME: Was W, found W, checking for 'w-authenticate:'\n");
+	    CTRACE(tfp, "HTMIME: Was W, found W, checking for 'w-authenticate:'\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, "'a' or 'w'");
 	    goto bad_field_name;
 	    break;
@@ -1138,27 +1005,22 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    if (!*me->check_pointer)
 		me->state = me->if_ok;
 	} else {		/* Error */
-	    if (TRACE)
-		fprintf(stderr,
-		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+	    CTRACE(tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
 			c, me->check_pointer - 1);
 	    goto bad_field_name;
 	}
 	break;
 
     case miCONTENT_:
-	if (TRACE)
-	   fprintf (stderr,
-		 "HTMIME: in case CONTENT_\n");
+	CTRACE (tfp, "HTMIME: in case CONTENT_\n");
+
 	switch(c) {
 	case 'b':
 	case 'B':
 	    me->check_pointer = "ase:";
 	    me->if_ok = miCONTENT_BASE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		      "HTMIME: Was CONTENT_, found B, checking for 'ase:'\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_, found B, checking for 'ase:'\n");
 	    break;
 
 	case 'd':
@@ -1166,9 +1028,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "isposition:";
 	    me->if_ok = miCONTENT_DISPOSITION;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		"HTMIME: Was CONTENT_, found D, checking for 'isposition:'\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_, found D, checking for 'isposition:'\n");
 	    break;
 
 	case 'e':
@@ -1176,9 +1036,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ncoding:";
 	    me->if_ok = miCONTENT_ENCODING;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		  "HTMIME: Was CONTENT_, found E, checking for 'ncoding:'\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_, found E, checking for 'ncoding:'\n");
 	    break;
 
 	case 'f':
@@ -1186,17 +1044,13 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "eatures:";
 	    me->if_ok = miCONTENT_FEATURES;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		  "HTMIME: Was CONTENT_, found F, checking for 'eatures:'\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_, found F, checking for 'eatures:'\n");
 	    break;
 
 	case 'l':
 	case 'L':
 	    me->state = miCONTENT_L;
-	    if (TRACE)
-		fprintf (stderr,
-		     "HTMIME: Was CONTENT_, found L, state now CONTENT_L\n");
+	    CTRACE (tfp, "HTMIME: Was CONTENT_, found L, state now CONTENT_L\n");
 	    break;
 
 	case 'm':
@@ -1204,9 +1058,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "d5:";
 	    me->if_ok = miCONTENT_MD5;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		      "HTMIME: Was CONTENT_, found M, checking for 'd5:'\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_, found M, checking for 'd5:'\n");
 	    break;
 
 	case 'r':
@@ -1214,23 +1066,17 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ange:";
 	    me->if_ok = miCONTENT_RANGE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		    "HTMIME: Was CONTENT_, found R, checking for 'ange:'\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_, found R, checking for 'ange:'\n");
 	    break;
 
 	case 't':
 	case 'T':
 	    me->state = miCONTENT_T;
-	    if (TRACE)
-		fprintf(stderr,
-		    "HTMIME: Was CONTENT_, found T, state now CONTENT_T\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_, found T, state now CONTENT_T\n");
 	    break;
 
 	default:
-	    if (TRACE)
-		fprintf(stderr,
-			"HTMIME: Was CONTENT_, found nothing; bleah\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_, found nothing; bleah\n");
 	    goto bad_field_name;
 	    break;
 
@@ -1238,18 +1084,15 @@ PRIVATE void HTMIME_put_character ARGS2(
 	break;
 
     case miCONTENT_L:
-      if (TRACE)
-	fprintf (stderr,
-		 "HTMIME: in case CONTENT_L\n");
+	CTRACE (tfp, "HTMIME: in case CONTENT_L\n");
+
       switch(c) {
 	case 'a':
 	case 'A':
 	    me->check_pointer = "nguage:";
 	    me->if_ok = miCONTENT_LANGUAGE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Was CONTENT_L, found A, checking for 'nguage:'\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_L, found A, checking for 'nguage:'\n");
 	    break;
 
 	case 'e':
@@ -1257,9 +1100,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "ngth:";
 	    me->if_ok = miCONTENT_LENGTH;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Was CONTENT_L, found E, checking for 'ngth:'\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_L, found E, checking for 'ngth:'\n");
 	    break;
 
 	case 'o':
@@ -1267,15 +1108,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "cation:";
 	    me->if_ok = miCONTENT_LOCATION;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Was CONTENT_L, found O, checking for 'cation:'\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_L, found O, checking for 'cation:'\n");
 	    break;
 
 	default:
-	  if (TRACE)
-	    fprintf (stderr,
-		     "HTMIME: Was CONTENT_L, found nothing; bleah\n");
+	    CTRACE (tfp, "HTMIME: Was CONTENT_L, found nothing; bleah\n");
 	    goto bad_field_name;
 	    break;
 
@@ -1283,18 +1120,15 @@ PRIVATE void HTMIME_put_character ARGS2(
 	break;
 
     case miCONTENT_T:
-      if (TRACE)
-	fprintf (stderr,
-		 "HTMIME: in case CONTENT_T\n");
+	CTRACE (tfp, "HTMIME: in case CONTENT_T\n");
+
       switch(c) {
 	case 'r':
 	case 'R':
 	    me->check_pointer = "ansfer-encoding:";
 	    me->if_ok = miCONTENT_TRANSFER_ENCODING;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-	 "HTMIME: Was CONTENT_T, found R, checking for 'ansfer-encoding:'\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_T, found R, checking for 'ansfer-encoding:'\n");
 	    break;
 
 	case 'y':
@@ -1302,15 +1136,11 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    me->check_pointer = "pe:";
 	    me->if_ok = miCONTENT_TYPE;
 	    me->state = miCHECK;
-	    if (TRACE)
-		fprintf(stderr,
-		   "HTMIME: Was CONTENT_T, found Y, checking for 'pe:'\n");
+	    CTRACE(tfp, "HTMIME: Was CONTENT_T, found Y, checking for 'pe:'\n");
 	    break;
 
 	default:
-	  if (TRACE)
-	    fprintf (stderr,
-		     "HTMIME: Was CONTENT_T, found nothing; bleah\n");
+	    CTRACE (tfp, "HTMIME: Was CONTENT_T, found nothing; bleah\n");
 	    goto bad_field_name;
 	    break;
 
@@ -1391,37 +1221,27 @@ PRIVATE void HTMIME_put_character ARGS2(
 	    switch (me->field) {
 	    case miACCEPT_RANGES:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Accept-Ranges: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Accept-Ranges: '%s'\n",
 			    me->value);
 		break;
 	    case miAGE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Age: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Age: '%s'\n",
 			    me->value);
 		break;
 	    case miALLOW:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Allow: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Allow: '%s'\n",
 			    me->value);
 		break;
 	    case miALTERNATES:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Alternates: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Alternates: '%s'\n",
 			    me->value);
 		break;
 	    case miCACHE_CONTROL:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Cache-Control: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Cache-Control: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1474,23 +1294,17 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miCOOKIE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Cookie: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Cookie: '%s'\n",
 			    me->value);
 		break;
 	    case miCONNECTION:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Connection: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Connection: '%s'\n",
 			    me->value);
 		break;
 	    case miCONTENT_BASE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Content-Base: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Content-Base: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1501,9 +1315,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miCONTENT_DISPOSITION:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Content-Disposition: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Content-Disposition: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1553,9 +1365,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miCONTENT_ENCODING:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-		       "HTMIME: PICKED UP Content-Encoding: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Content-Encoding: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value) ||
 		    !strcasecomp(me->value, "identity"))
@@ -1574,9 +1384,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		    **	Some server indicated "8bit", "7bit" or "binary"
 		    **	inappropriately.  We'll ignore it. - FM
 		    */
-		    if (TRACE)
-			fprintf(stderr,
-				"                Ignoring it!\n");
+		    CTRACE(tfp, "                Ignoring it!\n");
 		} else {
 		    /*
 		    **	Save it to use as a flag for setting
@@ -1587,16 +1395,12 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miCONTENT_FEATURES:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Content-Features: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Content-Features: '%s'\n",
 			    me->value);
 		break;
 	    case miCONTENT_LANGUAGE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Content-Language: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Content-Language: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1609,9 +1413,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miCONTENT_LENGTH:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Content-Length: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Content-Length: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1621,16 +1423,12 @@ PRIVATE void HTMIME_put_character ARGS2(
 		me->anchor->content_length = atoi(me->value);
 		if (me->anchor->content_length < 0)
 		    me->anchor->content_length = 0;
-		if (TRACE)
-		    fprintf(stderr,
-			    "        Converted to integer: '%d'\n",
+		CTRACE(tfp, "        Converted to integer: '%d'\n",
 			    me->anchor->content_length);
 		break;
 	    case miCONTENT_LOCATION:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Content-Location: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Content-Location: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1641,9 +1439,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miCONTENT_MD5:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Content-MD5: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Content-MD5: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1654,16 +1450,12 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miCONTENT_RANGE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Content-Range: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Content-Range: '%s'\n",
 			    me->value);
 		break;
 	    case miCONTENT_TRANSFER_ENCODING:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			"HTMIME: PICKED UP Content-Transfer-Encoding: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Content-Transfer-Encoding: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1677,9 +1469,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miCONTENT_TYPE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Content-Type: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Content-Type: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1697,9 +1487,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miDATE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Date: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Date: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1710,16 +1498,12 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miETAG:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP ETag: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP ETag: '%s'\n",
 			    me->value);
 		break;
 	    case miEXPIRES:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Expires: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Expires: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1730,16 +1514,12 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miKEEP_ALIVE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Keep-Alive: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Keep-Alive: '%s'\n",
 			    me->value);
 		break;
 	    case miLAST_MODIFIED:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Last-Modified: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Last-Modified: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1750,23 +1530,17 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miLINK:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Link: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Link: '%s'\n",
 			    me->value);
 		break;
 	    case miLOCATION:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Location: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Location: '%s'\n",
 			    me->value);
 		break;
 	    case miPRAGMA:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Pragma: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Pragma: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1778,30 +1552,22 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miPROXY_AUTHENTICATE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Proxy-Authenticate: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Proxy-Authenticate: '%s'\n",
 			    me->value);
 		break;
 	    case miPUBLIC:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Public: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Public: '%s'\n",
 			    me->value);
 		break;
 	    case miRETRY_AFTER:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Retry-After: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Retry-After: '%s'\n",
 			    me->value);
 		break;
 	    case miSAFE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Safe: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Safe: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1815,9 +1581,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miSERVER:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Server: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Server: '%s'\n",
 			    me->value);
 		if (!(me->value && *me->value))
 		    break;
@@ -1828,9 +1592,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miSET_COOKIE1:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Set-Cookie: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Set-Cookie: '%s'\n",
 			    me->value);
 		if (me->set_cookie == NULL) {
 		    StrAllocCopy(me->set_cookie, me->value);
@@ -1841,9 +1603,7 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miSET_COOKIE2:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Set-Cookie2: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Set-Cookie2: '%s'\n",
 			    me->value);
 		if (me->set_cookie2 == NULL) {
 		    StrAllocCopy(me->set_cookie2, me->value);
@@ -1854,58 +1614,42 @@ PRIVATE void HTMIME_put_character ARGS2(
 		break;
 	    case miTITLE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Title: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Title: '%s'\n",
 			    me->value);
 		break;
 	    case miTRANSFER_ENCODING:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Transfer-Encoding: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Transfer-Encoding: '%s'\n",
 			    me->value);
 		break;
 	    case miUPGRADE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Upgrade: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Upgrade: '%s'\n",
 			    me->value);
 		break;
 	    case miURI:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP URI: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP URI: '%s'\n",
 			    me->value);
 		break;
 	    case miVARY:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Vary: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Vary: '%s'\n",
 			    me->value);
 		break;
 	    case miVIA:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Via: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Via: '%s'\n",
 			    me->value);
 		break;
 	    case miWARNING:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP Warning: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP Warning: '%s'\n",
 			    me->value);
 		break;
 	    case miWWW_AUTHENTICATE:
 		HTMIME_TrimDoubleQuotes(me->value);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTMIME: PICKED UP WWW-Authenticate: '%s'\n",
+		CTRACE(tfp, "HTMIME: PICKED UP WWW-Authenticate: '%s'\n",
 			    me->value);
 		break;
 	    default:		/* Should never get here */
@@ -1934,8 +1678,7 @@ PRIVATE void HTMIME_put_character ARGS2(
     return;
 
 value_too_long:
-    if (TRACE)
-	fprintf(stderr, "HTMIME: *** Syntax error. (string too long)\n");
+    CTRACE(tfp, "HTMIME: *** Syntax error. (string too long)\n");
 
 bad_field_name: 			/* Ignore it */
     me->state = miJUNK_LINE;
@@ -1960,8 +1703,7 @@ PRIVATE void HTMIME_put_string ARGS2(
 	(*me->targetClass.put_string)(me->target,s);
 
     } else if (me->state != MIME_IGNORE) {
-	if (TRACE)
-	    fprintf(stderr, "HTMIME:  %s\n", s);
+	CTRACE(tfp, "HTMIME:  %s\n", s);
 
 	for (p=s; *p; p++)
 	    HTMIME_put_character(me, *p);
@@ -1983,8 +1725,7 @@ PRIVATE void HTMIME_write ARGS3(
 	(*me->targetClass.put_block)(me->target, s, l);
 
     } else {
-	if (TRACE)
-	    fprintf(stderr, "HTMIME:  %.*s\n", l, s);
+	CTRACE(tfp, "HTMIME:  %.*s\n", l, s);
 
 	for (p = s; p < s+l; p++)
 	    HTMIME_put_character(me, *p);
diff --git a/WWW/Library/Implementation/HTMLDTD.c b/WWW/Library/Implementation/HTMLDTD.c
index bf7a54b7..4b0049d6 100644
--- a/WWW/Library/Implementation/HTMLDTD.c
+++ b/WWW/Library/Implementation/HTMLDTD.c
@@ -1597,7 +1597,7 @@ PUBLIC void HTSwitchDTD ARGS1(
     BOOL,		new)
 {
     if (TRACE)
-	fprintf(stderr,"HTMLDTD: Copying DTD element info of size %d, %d * %d\n",
+	CTRACE(tfp,"HTMLDTD: Copying DTD element info of size %d, %d * %d\n",
 		new ? sizeof(tags_new) : sizeof(tags_old),
 		HTML_ELEMENTS, sizeof(HTTag));
     if (new)
diff --git a/WWW/Library/Implementation/HTNews.c b/WWW/Library/Implementation/HTNews.c
index 89048385..d450d901 100644
--- a/WWW/Library/Implementation/HTNews.c
+++ b/WWW/Library/Implementation/HTNews.c
@@ -189,17 +189,16 @@ PRIVATE BOOL initialize NOARGS
 #else
     if (getenv("NNTPSERVER")) {
 	StrAllocCopy(HTNewsHost, (char *)getenv("NNTPSERVER"));
-	if (TRACE) fprintf(stderr, "HTNews: NNTPSERVER defined as `%s'\n",
-		HTNewsHost);
+	CTRACE(tfp, "HTNews: NNTPSERVER defined as `%s'\n",
+		    HTNewsHost);
     } else {
 	char server_name[256];
 	FILE* fp = fopen(SERVER_FILE, "r");
 	if (fp) {
 	    if (fscanf(fp, "%s", server_name)==1) {
 		StrAllocCopy(HTNewsHost, server_name);
-		if (TRACE) fprintf(stderr,
-		"HTNews: File %s defines news host as `%s'\n",
-			SERVER_FILE, HTNewsHost);
+		CTRACE(tfp, "HTNews: File %s defines news host as `%s'\n",
+			    SERVER_FILE, HTNewsHost);
 	    }
 	    fclose(fp);
 	}
@@ -232,7 +231,7 @@ PRIVATE int response ARGS1(CONST char *,command)
     if (command) {
 	int status;
 	int length = strlen(command);
-	if (TRACE) fprintf(stderr, "NNTP command to be sent: %s", command);
+	CTRACE(tfp, "NNTP command to be sent: %s", command);
 #ifdef NOT_ASCII
 	{
 	    CONST char	* p;
@@ -247,8 +246,7 @@ PRIVATE int response ARGS1(CONST char *,command)
 	status = NEWS_NETWRITE(s, (char *)command, length);
 #endif /* NOT_ASCII */
 	if (status < 0){
-	    if (TRACE) fprintf(stderr,
-		"HTNews: Unable to send command. Disconnecting.\n");
+	    CTRACE(tfp, "HTNews: Unable to send command. Disconnecting.\n");
 	    NEWS_NETCLOSE(s);
 	    s = -1;
 	    return status;
@@ -259,24 +257,19 @@ PRIVATE int response ARGS1(CONST char *,command)
 	if (((*p++ = NEXT_CHAR) == LF) ||
 	    (p == &response_text[LINE_LENGTH])) {
 	    *--p = '\0';			/* Terminate the string */
-	    if (TRACE)
-		fprintf(stderr, "NNTP Response: %s\n", response_text);
+	    CTRACE(tfp, "NNTP Response: %s\n", response_text);
 	    sscanf(response_text, "%d", &result);
 	    return result;
 	} /* if end of line */
 
 	if ((ch = *(p-1)) == (char)EOF) {
 	    *(p-1) = '\0';
-	    if (TRACE) {
-		if (interrupted_in_htgetcharacter) {
-		    fprintf(stderr,
-			    "HTNews: Interrupted on read, closing socket %d\n",
+	    if (interrupted_in_htgetcharacter) {
+		CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
 			    s);
-		} else {
-		    fprintf(stderr,
-			    "HTNews: EOF on read, closing socket %d\n",
+	    } else {
+		CTRACE(tfp, "HTNews: EOF on read, closing socket %d\n",
 			    s);
-		}
 	    }
 	    NEWS_NETCLOSE(s);	/* End of file, close socket */
 	    s = -1;
@@ -560,8 +553,7 @@ PRIVATE char * author_name ARGS1 (char *,email)
     char *p, *e;
 
     StrAllocCopy(name, email);
-    if (TRACE)
-	fprintf(stderr,"Trying to find name in: %s\n",name);
+    CTRACE(tfp,"Trying to find name in: %s\n",name);
 
     if ((p = strchr(name, '(')) && (e = strchr(name, ')'))) {
 	if (e > p) {
@@ -598,8 +590,7 @@ PRIVATE char * author_address ARGS1(char *,email)
     char *p, *at, *e;
 
     StrAllocCopy(address, email);
-    if (TRACE)
-	fprintf(stderr,"Trying to find address in: %s\n",address);
+    CTRACE(tfp,"Trying to find address in: %s\n",address);
 
     if ((p = strchr(address, '<'))) {
 	if ((e = strchr(p, '>')) && (at = strchr(p, '@'))) {
@@ -770,9 +761,7 @@ PRIVATE void write_anchors ARGS1 (char *,text)
 */
 PRIVATE void abort_socket NOARGS
 {
-    if (TRACE)
-	fprintf(stderr,
-		"HTNews: EOF on read, closing socket %d\n", s);
+    CTRACE(tfp, "HTNews: EOF on read, closing socket %d\n", s);
     NEWS_NETCLOSE(s);	/* End of file, close socket */
     PUTS("Network Error: connection lost");
     PUTC('\n');
@@ -983,9 +972,7 @@ PRIVATE int read_article NOARGS
 	    if (ch == (char)EOF) {
 		if (interrupted_in_htgetcharacter) {
 		    interrupted_in_htgetcharacter = 0;
-		    if (TRACE)
-			fprintf(stderr,
-			   "HTNews: Interrupted on read, closing socket %d\n",
+		    CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
 				s);
 		    NEWS_NETCLOSE(s);
 		    s = -1;
@@ -996,8 +983,7 @@ PRIVATE int read_article NOARGS
 	    }
 	    if ((ch == LF) || (p == &line[LINE_LENGTH])) {
 		*--p = '\0';			/* Terminate the string */
-		if (TRACE)
-		    fprintf(stderr, "H %s\n", line);
+		CTRACE(tfp, "H %s\n", line);
 
 		if (line[0] == '\t' || line[0] == ' ') {
 		    int i = 0;
@@ -1253,9 +1239,7 @@ PRIVATE int read_article NOARGS
 	if (ch == (char)EOF) {
 	    if (interrupted_in_htgetcharacter) {
 		interrupted_in_htgetcharacter = 0;
-		if (TRACE)
-		    fprintf(stderr,
-			  "HTNews: Interrupted on read, closing socket %d\n",
+		CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
 			    s);
 		NEWS_NETCLOSE(s);
 		s = -1;
@@ -1266,8 +1250,7 @@ PRIVATE int read_article NOARGS
 	}
 	if ((ch == LF) || (p == &line[LINE_LENGTH])) {
 	    *p++ = '\0';			/* Terminate the string */
-	    if (TRACE)
-		fprintf(stderr, "B %s", line);
+	    CTRACE(tfp, "B %s", line);
 	    if (line[0] == '.') {
 		/*
 		**  End of article?
@@ -1460,9 +1443,7 @@ PRIVATE int read_list ARGS1(char *, arg)
 	if (ch == (char)EOF) {
 	    if (interrupted_in_htgetcharacter) {
 		interrupted_in_htgetcharacter = 0;
-		if (TRACE)
-		    fprintf(stderr,
-			  "HTNews: Interrupted on read, closing socket %d\n",
+		CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
 			    s);
 		NEWS_NETCLOSE(s);
 		s = -1;
@@ -1482,9 +1463,7 @@ PRIVATE int read_list ARGS1(char *, arg)
 		continue;
 	    }
 	} else if (p == &line[LINE_LENGTH]) {
-	    if (TRACE) {
-		fprintf(stderr, "b %.*s%c[...]\n", (LINE_LENGTH), line, ch);
-	    }
+	    CTRACE(tfp, "b %.*s%c[...]\n", (LINE_LENGTH), line, ch);
 	    *p = '\0';
 	    if (ch == LF) {
 		;		/* Will be dealt with below */
@@ -1494,9 +1473,7 @@ PRIVATE int read_list ARGS1(char *, arg)
 	    } else if (strchr(line, ' ') == NULL &&
 		       strchr(line, '\t') == NULL) {
 		/* No separator found */
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTNews..... group name too long, discarding.\n");
+		CTRACE(tfp, "HTNews..... group name too long, discarding.\n");
 		skip_this_line = YES; /* ignore whole line */
 		continue;
 	    } else {
@@ -1508,8 +1485,7 @@ PRIVATE int read_list ARGS1(char *, arg)
 	if (ch == LF) {
 	    skip_rest_of_line = NO;	/* done, reset flag */
 	    *p = '\0';			/* Terminate the string */
-	    if (TRACE)
-		fprintf(stderr, "B %s", line);
+	    CTRACE(tfp, "B %s", line);
 	    if (line[0] == '.') {
 		/*
 		**  End of article?
@@ -1617,9 +1593,7 @@ PRIVATE int read_group ARGS3(
     PUTC('\n');
 
     sscanf(response_text, " %d %d %d %d", &status, &count, &first, &last);
-    if (TRACE)
-	fprintf(stderr,
-		"Newsgroup status=%d, count=%d, (%d-%d) required:(%d-%d)\n",
+    CTRACE(tfp, "Newsgroup status=%d, count=%d, (%d-%d) required:(%d-%d)\n",
 		status, count, first, last, first_required, last_required);
     if (last == 0) {
 	PUTS("\nNo articles in this group.\n");
@@ -1642,9 +1616,8 @@ PRIVATE int read_group ARGS3(
     if (last_required-first_required+1 > HTNewsMaxChunk) { /* Trim this block */
 	first_required = last_required-HTNewsChunkSize+1;
     }
-    if (TRACE)
-	fprintf(stderr, "    Chunk will be (%d-%d)\n",
-			first_required, last_required);
+    CTRACE(tfp, "    Chunk will be (%d-%d)\n",
+		first_required, last_required);
 
     /*
     **	Set window title.
@@ -1667,8 +1640,7 @@ PRIVATE int read_group ARGS3(
 	    before = first_required-HTNewsChunkSize;
 	sprintf(buffer, "%s%s/%d-%d", NewsHREF, groupName,
 				      before, first_required-1);
-	if (TRACE)
-	    fprintf(stderr, "    Block before is %s\n", buffer);
+	CTRACE(tfp, "    Block before is %s\n", buffer);
 	PUTC('(');
 	start_anchor(buffer);
 	PUTS("Earlier articles");
@@ -1696,9 +1668,7 @@ PRIVATE int read_group ARGS3(
 		if (ch == (char)EOF) {
 		    if (interrupted_in_htgetcharacter) {
 			interrupted_in_htgetcharacter = 0;
-			if (TRACE)
-			    fprintf(stderr,
-			   "HTNews: Interrupted on read, closing socket %d\n",
+			CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
 				    s);
 			NEWS_NETCLOSE(s);
 			s = -1;
@@ -1709,8 +1679,7 @@ PRIVATE int read_group ARGS3(
 		}
 		if ((ch == '\n') || (p == &line[LINE_LENGTH])) {
 		    *p = '\0';		/* Terminate the string */
-		    if (TRACE)
-			fprintf(stderr, "X %s", line);
+		    CTRACE(tfp, "X %s", line);
 		    if (line[0] == '.') {
 			/*
 			**  End of article?
@@ -1802,9 +1771,7 @@ PRIVATE int read_group ARGS3(
 		    if (ch == (char)EOF) {
 			if (interrupted_in_htgetcharacter) {
 			    interrupted_in_htgetcharacter = 0;
-			    if (TRACE)
-				fprintf(stderr,
-			   "HTNews: Interrupted on read, closing socket %d\n",
+			    CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
 					s);
 			    NEWS_NETCLOSE(s);
 			    s = -1;
@@ -1818,8 +1785,7 @@ PRIVATE int read_group ARGS3(
 
 			*--p = '\0';		/* Terminate  & chop LF*/
 			p = line;		/* Restart at beginning */
-			if (TRACE)
-			    fprintf(stderr, "G %s\n", line);
+			CTRACE(tfp, "G %s\n", line);
 			switch(line[0]) {
 
 			case '.':
@@ -1913,9 +1879,7 @@ PRIVATE int read_group ARGS3(
 		*/
 	    } else if (status == HT_INTERRUPTED) {
 		interrupted_in_htgetcharacter = 0;
-		if (TRACE)
-		    fprintf(stderr,
-			  "HTNews: Interrupted on read, closing socket %d\n",
+		CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
 			    s);
 		NEWS_NETCLOSE(s);
 		s = -1;
@@ -1957,8 +1921,7 @@ PRIVATE int read_group ARGS3(
 	else
 	    sprintf(buffer, "%s%s/%d-%d", NewsHREF, groupName,
 					  last_required+1, after);
-	if (TRACE)
-	    fprintf(stderr, "    Block after is %s\n", buffer);
+	CTRACE(tfp, "    Block after is %s\n", buffer);
 	PUTC('(');
 	start_anchor(buffer);
 	PUTS("Later articles");
@@ -2029,7 +1992,7 @@ PRIVATE int HTLoadNews ARGS4(
 		  format_out == HTAtom_for("www/dump"));
     rawtext = NO;
 
-    if (TRACE) fprintf(stderr, "HTNews: Looking for %s\n", arg);
+    CTRACE(tfp, "HTNews: Looking for %s\n", arg);
 
     if (!initialized)
 	initialized = initialize();
@@ -2230,9 +2193,7 @@ PRIVATE int HTLoadNews ARGS4(
 	    command[258] = '\0';
 	    FREE(cp);
 	    sprintf(proxycmd, "GET %.251s%c%c%c%c", command, CR, LF, CR, LF);
-	    if (TRACE)
-		fprintf(stderr,
-			"HTNews: Proxy command is '%.*s'\n",
+	    CTRACE(tfp, "HTNews: Proxy command is '%.*s'\n",
 			(int)(strlen(proxycmd) - 4), proxycmd);
 	    strcat(command, "/");
 	    StrAllocCopy(ProxyHREF, NewsHREF);
@@ -2374,8 +2335,7 @@ PRIVATE int HTLoadNews ARGS4(
 	    } else {
 		sprintf (url, "%.259s", NewsHREF);
 	    }
-	    if (TRACE)
-		fprintf (stderr, "News: doing HTDoConnect on '%s'\n", url);
+	    CTRACE (tfp, "News: doing HTDoConnect on '%s'\n", url);
 
 	    _HTProgress("Connecting to NewsHost ...");
 
@@ -2384,9 +2344,7 @@ PRIVATE int HTLoadNews ARGS4(
 		/*
 		**  Interrupt cleanly.
 		*/
-		if (TRACE)
-		    fprintf(stderr,
-		     "HTNews: Interrupted on connect; recovering cleanly.\n");
+		CTRACE(tfp, "HTNews: Interrupted on connect; recovering cleanly.\n");
 		_HTProgress("Connection interrupted.");
 		if (!(post_wanted || reply_wanted ||
 		      spost_wanted || sreply_wanted)) {
@@ -2412,9 +2370,7 @@ PRIVATE int HTLoadNews ARGS4(
 		char message[256];
 		NEWS_NETCLOSE(s);
 		s = -1;
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTNews: Unable to connect to news host.\n");
+		CTRACE(tfp, "HTNews: Unable to connect to news host.\n");
 		if (retries < 1)
 		    continue;
 		sprintf(message, "Could not access %s.", NewsHost);
@@ -2434,15 +2390,12 @@ PRIVATE int HTLoadNews ARGS4(
 		}
 		return HTLoadError(stream, 500, message);
 	    } else {
-		if (TRACE)
-		    fprintf(stderr, "HTNews: Connected to news host %s.\n",
-				    NewsHost);
+		CTRACE(tfp, "HTNews: Connected to news host %s.\n",
+			    NewsHost);
 		HTInitInput(s); 	/* set up buffering */
 		if (proxycmd[0]) {
 		    status = NEWS_NETWRITE(s, proxycmd, strlen(proxycmd));
-		    if (TRACE)
-			fprintf(stderr,
-			     "HTNews: Proxy command returned status '%d'.\n",
+		    CTRACE(tfp, "HTNews: Proxy command returned status '%d'.\n",
 				status);
 		}
 		if (((status = response(NULL)) / 100) != 2) {
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c
index 97d3f5ea..d75b1fde 100644
--- a/WWW/Library/Implementation/HTParse.c
+++ b/WWW/Library/Implementation/HTParse.c
@@ -190,9 +190,7 @@ PUBLIC char * HTParse ARGS3(
     char * acc_method;
     struct struct_parts given, related;
 
-    if (TRACE)
-	fprintf(stderr,
-		"HTParse: aName:%s   relatedName:%s\n", aName, relatedName);
+    CTRACE(tfp, "HTParse: aName:%s   relatedName:%s\n", aName, relatedName);
 
     /*
     **	Allocate the output string.
@@ -365,8 +363,7 @@ PUBLIC char * HTParse ARGS3(
 	    if (wanted & PARSE_PUNCTUATION)
 		strcat(result, "/");
 	    strcat(result, given.absolute);
-	    if (TRACE)
-		fprintf(stderr, "1\n");
+	    CTRACE(tfp, "1\n");
 	} else if (related.absolute) {		/* Adopt path not name */
 	    strcat(result, "/");
 	    strcat(result, related.absolute);
@@ -380,16 +377,13 @@ PUBLIC char * HTParse ARGS3(
 		strcat(result, given.relative); /* Add given one */
 		HTSimplify (result);
 	    }
-	    if (TRACE)
-		fprintf(stderr, "2\n");
+	    CTRACE(tfp, "2\n");
 	} else if (given.relative) {
 	    strcat(result, given.relative);		/* what we've got */
-	    if (TRACE)
-		fprintf(stderr, "3\n");
+	    CTRACE(tfp, "3\n");
 	} else if (related.relative) {
 	    strcat(result, related.relative);
-	    if (TRACE)
-		fprintf(stderr, "4\n");
+	    CTRACE(tfp, "4\n");
 	} else {  /* No inheritance */
 	    if (strncasecomp(aName, "lynxcgi:", 8) &&
 		strncasecomp(aName, "lynxexec:", 9) &&
@@ -398,8 +392,7 @@ PUBLIC char * HTParse ARGS3(
 	    }
 	    if (!strcmp(result, "news:/"))
 		result[5] = '*';
-	    if (TRACE)
-		fprintf(stderr, "5\n");
+	    CTRACE(tfp, "5\n");
 	}
     }
 
@@ -414,8 +407,7 @@ PUBLIC char * HTParse ARGS3(
 	    strcat(result, (given.anchor) ?
 			     given.anchor : related.anchor);
 	}
-    if (TRACE)
-	fprintf(stderr, "HTParse: result:%s\n", result);
+    CTRACE(tfp, "HTParse: result:%s\n", result);
     FREE(rel);
     FREE(name);
 
@@ -647,8 +639,7 @@ PUBLIC char * HTRelative ARGS2(
 	    strcat(result, "../");
 	strcat(result, last_slash+1);
     }
-    if (TRACE)
-	fprintf(stderr, "HT: `%s' expressed relative to\n    `%s' is\n   `%s'.",
+    CTRACE(tfp, "HT: `%s' expressed relative to\n    `%s' is\n   `%s'.",
 		aName, relatedName, result);
     return result;
 }
diff --git a/WWW/Library/Implementation/HTPasswd.c b/WWW/Library/Implementation/HTPasswd.c
index 45a53aee..f8494417 100644
--- a/WWW/Library/Implementation/HTPasswd.c
+++ b/WWW/Library/Implementation/HTPasswd.c
@@ -176,9 +176,7 @@ PUBLIC BOOL HTAA_passwdMatch ARGS2(CONST char *, password,
 
     status = strncmp(result, encrypted, strlen(encrypted));
 
-    if (TRACE)
-	fprintf(stderr,
-		"%s `%s' (encrypted: `%s') with: `%s' => %s\n",
+    CTRACE(tfp, "%s `%s' (encrypted: `%s') with: `%s' => %s\n",
 		"HTAA_passwdMatch: Matching password:",
 		password, result, encrypted,
 		(status==0 ? "OK" : "INCORRECT"));
@@ -266,16 +264,14 @@ PUBLIC BOOL HTAA_checkPassword ARGS3(CONST char *, username,
     else			fp = fopen(PASSWD_FILE,"r");
 
     if (!fp) {
-	if (TRACE) fprintf(stderr, "%s `%s'\n",
-			   "HTAA_checkPassword: Unable to open password file",
-			   (filename && *filename ? filename : PASSWD_FILE));
+	CTRACE(tfp, "%s `%s'\n",
+		    "HTAA_checkPassword: Unable to open password file",
+		    (filename && *filename ? filename : PASSWD_FILE));
 	return NO;
     }
     do {
 	if (2 == (status = HTAAFile_readPasswdRec(fp,user,pw))) {
-	    if (TRACE)
-		fprintf(stderr,
-			"HTAAFile_validateUser: %s \"%s\" %s \"%s:%s\"\n",
+	    CTRACE(tfp, "HTAAFile_validateUser: %s \"%s\" %s \"%s:%s\"\n",
 			"Matching username:", username,
 			"against passwd record:", user, pw);
 	    if (username  &&  user  &&  !strcmp(username,user)) {
@@ -292,7 +288,7 @@ PUBLIC BOOL HTAA_checkPassword ARGS3(CONST char *, username,
 
     fclose(fp);
     
-    if (TRACE) fprintf(stderr, "HTAAFile_checkPassword: (%s,%s) %scorrect\n",
+    CTRACE(tfp, "HTAAFile_checkPassword: (%s,%s) %scorrect\n",
 		       username, password, ((status != EOF) ? "" : "in"));
 
     if (status == EOF)  return NO;  /* We traversed to the end without luck */
diff --git a/WWW/Library/Implementation/HTPlain.c b/WWW/Library/Implementation/HTPlain.c
index 14b89bf8..363ad9e3 100644
--- a/WWW/Library/Implementation/HTPlain.c
+++ b/WWW/Library/Implementation/HTPlain.c
@@ -417,11 +417,8 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l)
 		   (uck = UCTransUniChar(code,
 					 me->outUCLYhndl)) >= 32 &&
 		   uck < 256) {
-	    if (TRACE) {
-		fprintf(stderr,
-			"UCTransUniChar returned 0x%.2lX:'%c'.\n",
+	    CTRACE(tfp, "UCTransUniChar returned 0x%.2lX:'%c'.\n",
 			uck, FROMASCII((char)uck));
-	    }
 	    HText_appendCharacter(me->text, ((char)(uck & 0xff)));
 	} else if (chk &&
 		   (uck == -4 ||
@@ -494,18 +491,12 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l)
 	    /*
 	    **	Ignore 8204 (zwnj) or 8205 (zwj), if we get to here. - FM
 	    */
-	    if (TRACE) {
-		fprintf(stderr,
-			"HTPlain_write: Ignoring '%ld'.\n", code);
-	    }
+	    CTRACE(tfp, "HTPlain_write: Ignoring '%ld'.\n", code);
 	} else if (code == 8206 || code == 8207) {
 	    /*
 	    **	Ignore 8206 (lrm) or 8207 (rlm), if we get to here. - FM
 	    */
-	    if (TRACE) {
-		fprintf(stderr,
-			"HTPlain_write: Ignoring '%ld'.\n", code);
-	    }
+	    CTRACE(tfp, "HTPlain_write: Ignoring '%ld'.\n", code);
 #endif /* NOTDEFINED */
 	} else if (me->T.trans_from_uni && code > 255) {
 	    if (PASSHI8BIT && PASSHICTRL && LYRawMode &&
diff --git a/WWW/Library/Implementation/HTRules.c b/WWW/Library/Implementation/HTRules.c
index 24604e29..b6abe661 100644
--- a/WWW/Library/Implementation/HTRules.c
+++ b/WWW/Library/Implementation/HTRules.c
@@ -7,10 +7,10 @@
 **	10 Aug 91	Authorisation added after Daniel Martin (pass, fail)
 **			Rule order in file changed
 **			Comments allowed with # on 1st char of rule line
-**      17 Jun 92       Bug fix: pass and fail failed if didn't contain '*' TBL
-**       1 Sep 93       Bug fix: no memory check - Nathan Torkington
-**                      BYTE_ADDRESSING removed - Arthur Secret
-**	11 Sep 93  MD	Changed %i into %d in debug printf. 
+**	17 Jun 92	Bug fix: pass and fail failed if didn't contain '*' TBL
+**	 1 Sep 93	Bug fix: no memory check - Nathan Torkington
+**			BYTE_ADDRESSING removed - Arthur Secret
+**	11 Sep 93  MD	Changed %i into %d in debug printf.
 **			VMS does not recognize %i.
 **			Bug Fix: in case of PASS, only one parameter to printf.
 **	19 Sep 93  AL	Added Access Authorization stuff.
@@ -43,7 +43,7 @@ typedef struct _rule {
 **	----------------
 */
 PUBLIC char *HTBinDir = NULL;	/* Physical /htbin directory path.	*/
-                                /* In future this should not be global.	*/
+				/* In future this should not be global. */
 PUBLIC char *HTSearchScript = NULL;	/* Search script name.		*/
 
 
@@ -61,11 +61,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.
 */
 
 #ifdef __STDC__
@@ -77,33 +77,32 @@ int HTAddRule(op, pattern, equiv)
     char *	equiv;
 #endif
 { /* BYTE_ADDRESSING removed and memory check - AS - 1 Sep 93 */
-    rule *      temp;
-    char *      pPattern;
+    rule *	temp;
+    char *	pPattern;
 
     temp = (rule *)malloc(sizeof(*temp));
-    if (temp==NULL) 
-	outofmem(__FILE__, "HTAddRule"); 
+    if (temp==NULL)
+	outofmem(__FILE__, "HTAddRule");
     pPattern = (char *)malloc(strlen(pattern)+1);
-    if (pPattern==NULL) 
-	outofmem(__FILE__, "HTAddRule"); 
+    if (pPattern==NULL)
+	outofmem(__FILE__, "HTAddRule");
     if (equiv) {		/* Two operands */
 	char *	pEquiv = (char *)malloc(strlen(equiv)+1);
-	if (pEquiv==NULL) 
-	    outofmem(__FILE__, "HTAddRule"); 
-        temp->equiv = pEquiv;
-        strcpy(pEquiv, equiv);
+	if (pEquiv==NULL)
+	    outofmem(__FILE__, "HTAddRule");
+	temp->equiv = pEquiv;
+	strcpy(pEquiv, equiv);
     } else {
-        temp->equiv = 0;
+	temp->equiv = 0;
     }
     temp->pattern = pPattern;
     temp->op = op;
 
     strcpy(pPattern, pattern);
-    if (TRACE) {
-       if (equiv)
-          fprintf(stderr, "Rule: For `%s' op %d `%s'\n", pattern, op, equiv);
-       else
-          fprintf(stderr, "Rule: For `%s' op %d\n", pattern, op);
+    if (equiv) {
+	CTRACE(tfp, "Rule: For `%s' op %d `%s'\n", pattern, op, equiv);
+    } else {
+	CTRACE(tfp, "Rule: For `%s' op %d\n", pattern, op);
     }
 
 #ifdef PUT_ON_HEAD
@@ -116,17 +115,17 @@ int HTAddRule(op, pattern, equiv)
     rule_tail = temp;
 #endif
 
-        
+
     return 0;
 }
 
 
-/*	Clear all rules						HTClearRules()
+/*	Clear all rules 					HTClearRules()
 **	---------------
 **
 ** On exit,
 **	There are no rules
-**	returns		0 if success, -1 if error.
+**	returns 	0 if success, -1 if error.
 **
 ** See also
 **	HTAddRule()
@@ -138,7 +137,7 @@ int HTClearRules()
 #endif
 {
     while (rules) {
-    	rule * temp = rules;
+	rule * temp = rules;
 	rules = temp->next;
 	FREE(temp->pattern);
 	FREE(temp->equiv);
@@ -160,7 +159,7 @@ int HTClearRules()
 ** 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:
@@ -185,7 +184,7 @@ char * HTTranslate(required)
     HTAA_clearProtections();	/* Reset from previous call -- AL */
 
     for(r = rules; r; r = r->next) {
-        char * p = r->pattern;
+	char * p = r->pattern;
 	int m=0;   /* Number of characters matched against wildcard */
 	CONST char * q = current;
 	for(;*p && *q; p++, q++) {   /* Find first mismatch */
@@ -194,9 +193,9 @@ char * HTTranslate(required)
 
 	if (*p == '*') {		/* Match up to wildcard */
 	    m = strlen(q) - strlen(p+1); /* Amount to match to wildcard */
-	    if(m<0) continue;           /* tail is too short to match */
+	    if(m<0) continue;		/* tail is too short to match */
 	    if (0!=strcmp(q+m, p+1)) continue;	/* Tail mismatch */
-	} else 				/* Not wildcard */
+	} else				/* Not wildcard */
 	    if (*p != *q) continue;	/* plain mismatch: go to next rule */
 
 	switch (r->op) {		/* Perform operation */
@@ -210,13 +209,12 @@ char * HTTranslate(required)
 		char *eff_ids = NULL;
 		char *prot_file = NULL;
 
-		if (TRACE) fprintf(stderr,
-				   "HTRule: `%s' matched %s %s: `%s'\n",
-				   current,
-				   (r->op==HT_Protect ? "Protect" : "DefProt"),
-				   "rule, setup",
-				   (r->equiv ? r->equiv :
-				    (r->op==HT_Protect ?"DEFAULT" :"NULL!!")));
+		CTRACE(tfp, "HTRule: `%s' matched %s %s: `%s'\n",
+			    current,
+			    (r->op==HT_Protect ? "Protect" : "DefProt"),
+			    "rule, setup",
+			    (r->equiv ? r->equiv :
+			     (r->op==HT_Protect ?"DEFAULT" :"NULL!!")));
 
 		if (r->equiv) {
 		    StrAllocCopy(local_copy, r->equiv);
@@ -238,57 +236,56 @@ char * HTTranslate(required)
 #endif /* ACCESS_AUTH */
 
 	case HT_Pass:				/* Authorised */
-    		if (!r->equiv) {
-		    if (TRACE) fprintf(stderr, "HTRule: Pass `%s'\n", current);
+		if (!r->equiv) {
+		    CTRACE(tfp, "HTRule: Pass `%s'\n", current);
 		    return current;
-	        }
+		}
 		/* Else fall through ...to map and pass */
-		
+
 	case HT_Map:
 	    if (*p == *q) { /* End of both strings, no wildcard */
-    	          if (TRACE) fprintf(stderr,
-			       "For `%s' using `%s'\n", current, r->equiv);  
-	          StrAllocCopy(current, r->equiv); /* use entire translation */
+		  CTRACE(tfp, "For `%s' using `%s'\n", current, r->equiv);
+		  StrAllocCopy(current, r->equiv); /* use entire translation */
 	    } else {
 		  char * ins = strchr(r->equiv, '*');	/* Insertion point */
-	          if (ins) {	/* Consistent rule!!! */
+		  if (ins) {	/* Consistent rule!!! */
 			char * temp = (char *)malloc(
 				strlen(r->equiv)-1 + m + 1);
-			if (temp==NULL) 
+			if (temp==NULL)
 			    outofmem(__FILE__, "HTTranslate"); /* NT & AS */
-			strncpy(temp, 	r->equiv, ins-r->equiv);
+			strncpy(temp,	r->equiv, ins-r->equiv);
 			/* Note: temp may be unterminated now! */
 			strncpy(temp+(ins-r->equiv), q, m);  /* Matched bit */
 			strcpy (temp+(ins-r->equiv)+m, ins+1);	/* Last bit */
-    			if (TRACE) fprintf(stderr, "For `%s' using `%s'\n",
-						current, temp);
+			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 = (char *)malloc(strlen(r->equiv)+1);
-			if (temp==NULL) 
+			if (temp==NULL)
 			    outofmem(__FILE__, "HTTranslate"); /* NT & AS */
 			strcpy(temp, r->equiv);
-    			if (TRACE) fprintf(stderr, "For `%s' using `%s'\n",
+			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) {
-		    if (TRACE) fprintf(stderr, "HTRule: ...and pass `%s'\n",
-		    		       current);
+		    CTRACE(tfp, "HTRule: ...and pass `%s'\n",
+				current);
 		    return current;
 		}
 		break;
 
 	case HT_Invalid:
 	case HT_Fail:				/* Unauthorised */
-    		    if (TRACE) fprintf(stderr, "HTRule: *** FAIL `%s'\n",
-		    		       current);
-		    return (char *)0;
-		    		    
+		CTRACE(tfp, "HTRule: *** FAIL `%s'\n",
+			    current);
+		return (char *)0;
+
 	} /* if tail matches ... switch operation */
 
     } /* loop over rules */
@@ -313,7 +310,7 @@ PUBLIC int  HTSetConfiguration ARGS1(CONST char *, config)
     float quality, secs, secs_per_byte;
     int maxbytes;
     int status;
-    
+
     StrAllocCopy(line, config);
     {
 	char * p = strchr(line, '#');	/* Chop off comments */
@@ -322,9 +319,9 @@ PUBLIC int  HTSetConfiguration ARGS1(CONST char *, config)
     pointer = line;
     word1 = HTNextField(&pointer);
     if (!word1) {
-    	FREE(line);
+	FREE(line);
 	return 0;
-    } ;	/* Comment only or blank */
+    } ; /* Comment only or blank */
 
     word2 = HTNextField(&pointer);
 
@@ -341,7 +338,7 @@ PUBLIC int  HTSetConfiguration ARGS1(CONST char *, config)
     }
 
     if (0==strcasecomp(word1, "suffix")) {
-        char * encoding = HTNextField(&pointer);
+	char * encoding = HTNextField(&pointer);
 	if (pointer) status = sscanf(pointer, "%f", &quality);
 	else status = 0;
 	HTSetSuffix(word2,	word3,
@@ -349,12 +346,12 @@ PUBLIC int  HTSetConfiguration ARGS1(CONST char *, config)
 				status >= 1? quality : 1.0);
 
     } else if (0==strcasecomp(word1, "presentation")) {
-        if (pointer) status = sscanf(pointer, "%f%f%f%d",
+	if (pointer) status = sscanf(pointer, "%f%f%f%d",
 			    &quality, &secs, &secs_per_byte, &maxbytes);
-        else status = 0;
+	else status = 0;
 	HTSetPresentation(word2, word3,
-		    status >= 1? quality 		: 1.0,
-		    status >= 2 ? secs 			: 0.0,
+		    status >= 1? quality		: 1.0,
+		    status >= 2 ? secs			: 0.0,
 		    status >= 3 ? secs_per_byte 	: 0.0,
 		    status >= 4 ? maxbytes		: 0 );
 
@@ -366,17 +363,17 @@ PUBLIC int  HTSetConfiguration ARGS1(CONST char *, config)
 	StrAllocCopy(HTSearchScript, word2);	/* Search script name */
 
     } else {
-	op =	0==strcasecomp(word1, "map")  ?	HT_Map
-	    :	0==strcasecomp(word1, "pass") ?	HT_Pass
-	    :	0==strcasecomp(word1, "fail") ?	HT_Fail
-	    :   0==strcasecomp(word1, "defprot") ? HT_DefProt
+	op =	0==strcasecomp(word1, "map")  ? HT_Map
+	    :	0==strcasecomp(word1, "pass") ? HT_Pass
+	    :	0==strcasecomp(word1, "fail") ? HT_Fail
+	    :	0==strcasecomp(word1, "defprot") ? HT_DefProt
 	    :	0==strcasecomp(word1, "protect") ? HT_Protect
 	    :						HT_Invalid;
 	if (op==HT_Invalid) {
 	    fprintf(stderr, "HTRule: Bad rule `%s'\n", config);
-	} else {  
+	} else {
 	    HTAddRule(op, word2, word3);
-	} 
+	}
     }
     FREE(line);
     return 0;
@@ -391,7 +388,7 @@ PUBLIC int  HTSetConfiguration ARGS1(CONST char *, config)
 ** 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.
@@ -401,10 +398,9 @@ int HTLoadRules ARGS1(CONST char *, filename)
 {
     FILE * fp = fopen(filename, "r");
     char line[LINE_LENGTH+1];
-    
+
     if (!fp) {
-        if (TRACE) fprintf(stderr,
-			   "HTRules: Can't open rules file %s\n", filename);
+	CTRACE(tfp, "HTRules: Can't open rules file %s\n", filename);
 	return -1; /* File open error */
     }
     for(;;) {
diff --git a/WWW/Library/Implementation/HTStyle.c b/WWW/Library/Implementation/HTStyle.c
index 8fc72093..963303d9 100644
--- a/WWW/Library/Implementation/HTStyle.c
+++ b/WWW/Library/Implementation/HTStyle.c
@@ -184,7 +184,7 @@ HTStyle * HTStyleNamed ARGS2 (HTStyleSheet *,self, CONST char *,name)
     HTStyle * scan;
     for (scan=self->styles; scan; scan=scan->next)
 	if (0==strcmp(scan->name, name)) return scan;
-    if (TRACE) fprintf(stderr, "StyleSheet: No style named `%s'\n", name);
+    CTRACE(tfp, "StyleSheet: No style named `%s'\n", name);
     return NULL;
 }
 
@@ -235,8 +235,8 @@ HTStyle * HTStyleForRun (HTStyleSheet *self, NXRun *run)
 	    }
 	}
     }
-    if (TRACE) fprintf(stderr, "HTStyleForRun: Best match for style is %d out of 18\n",
-			 bestMatch);
+    CTRACE(tfp, "HTStyleForRun: Best match for style is %d out of 18\n",
+		 bestMatch);
     return best;
 }
 #endif /* NEXT_SUPRESS */
@@ -325,7 +325,7 @@ HTStyleSheet * HTStyleSheetRead(HTStyleSheet * self, NXStream * stream)
     HTStyle * style;
     char styleName[80];
     NXScanf(stream, " %d ", &numStyles);
-    if (TRACE) fprintf(stderr, "Stylesheet: Reading %d styles\n", numStyles);
+    CTRACE(tfp, "Stylesheet: Reading %d styles\n", numStyles);
     for (i=0; i<numStyles; i++) {
 	NXScanf(stream, "%s", styleName);
 	style = HTStyleNamed(self, styleName);
@@ -353,7 +353,7 @@ HTStyleSheet * HTStyleSheetWrite(HTStyleSheet * self, NXStream * stream)
     for(style=self->styles; style; style=style->next) numStyles++;
     NXPrintf(stream, "%d\n", numStyles);
 
-    if (TRACE) fprintf(stderr, "StyleSheet: Writing %d styles\n", numStyles);
+    CTRACE(tfp, "StyleSheet: Writing %d styles\n", numStyles);
     for (style=self->styles; style; style=style->next) {
 	NXPrintf(stream, "%s ", style->name);
 	(void) HTStyleWrite(style, stream);
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index 9749e530..c7baf292 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -334,15 +334,11 @@ PUBLIC int HTParseInet ARGS2(
 #endif /* _WINDOWS_NSL */
 
     if (!str) {
-	if (TRACE) {
-	    fprintf(stderr, "HTParseInet: Can't parse `NULL'.\n");
-	}
+	CTRACE(tfp, "HTParseInet: Can't parse `NULL'.\n");
 	return -1;
     }
     if (HTCheckForInterrupt()) {
-	if (TRACE) {
-	    fprintf (stderr, "HTParseInet: INTERRUPTED for '%s'.\n", str);
-	}
+	CTRACE (tfp, "HTParseInet: INTERRUPTED for '%s'.\n", str);
 	return -1;
     }
 #ifdef _WINDOWS_NSL
@@ -370,8 +366,8 @@ PUBLIC int HTParseInet ARGS2(
 	    struct servent * serv = getservbyname(port, (char*)0);
 	    if (serv) {
 		soc_in->sin_port = serv->s_port;
-	    } else if (TRACE) {
-		fprintf(stderr, "TCP: Unknown service %s\n", port);
+	    } else {
+		CTRACE(tfp, "TCP: Unknown service %s\n", port);
 	    }
 #endif /* SUPPRESS */
 	}
@@ -384,11 +380,8 @@ PUBLIC int HTParseInet ARGS2(
     */
     soc_in->sdn_nam.n_len = min(DN_MAXNAML, strlen(host));  /* <=6 in phase 4 */
     strncpy(soc_in->sdn_nam.n_name, host, soc_in->sdn_nam.n_len + 1);
-    if (TRACE) {
-	fprintf(stderr,
-		"DECnet: Parsed address as object number %d on host %.6s...\n",
+    CTRACE(tfp, "DECnet: Parsed address as object number %d on host %.6s...\n",
 		soc_in->sdn_objnum, host);
-    }
 #else  /* parse Internet host: */
 
     if (*host >= '0' && *host <= '9') {   /* Test for numeric node address: */
@@ -429,10 +422,7 @@ PUBLIC int HTParseInet ARGS2(
 #endif /* _WINDOWS_NSL */
     } else {		    /* Alphanumeric node name: */
 #ifdef MVS	/* Outstanding problem with crash in MVS gethostbyname */
-	if (TRACE) {
-	    fprintf(stderr,
-		    "HTParseInet: Calling gethostbyname(%s)\n", host);
-	}
+	CTRACE(tfp, "HTParseInet: Calling gethostbyname(%s)\n", host);
 #endif /* MVS */
 
 #ifdef NSL_FORK
@@ -488,10 +478,7 @@ PUBLIC int HTParseInet ARGS2(
 		**  Abort if interrupt key pressed.
 		*/
 		if (HTCheckForInterrupt()) {
-		    if (TRACE) {
-			fprintf(stderr,
-				"HTParseInet: INTERRUPTED gethostbyname.\n");
-		    }
+		    CTRACE(tfp, "HTParseInet: INTERRUPTED gethostbyname.\n");
 		    kill(fpid , SIGKILL);
 		    waitpid(fpid, NULL, 0);
 		    FREE(host);
@@ -507,47 +494,34 @@ PUBLIC int HTParseInet ARGS2(
 	    if (waitret <= 0) {
 		waitret = waitpid(fpid, &cst1, WNOHANG);
 	    }
-	    if (TRACE) {
-		if (WIFEXITED(cst1)) {
-		    fprintf(stderr,
-		      "HTParseInet: NSL_FORK child %d exited, status 0x%x.\n",
+	    if (WIFEXITED(cst1)) {
+		CTRACE(tfp, "HTParseInet: NSL_FORK child %d exited, status 0x%x.\n",
 			    (int)waitret, cst1);
-		} else if (WIFSIGNALED(cst1)) {
-		    fprintf(stderr,
-		  "HTParseInet: NSL_FORK child %d got signal, status 0x%x!\n",
+	    } else if (WIFSIGNALED(cst1)) {
+		CTRACE(tfp, "HTParseInet: NSL_FORK child %d got signal, status 0x%x!\n",
 			    (int)waitret, cst1);
 #ifdef WCOREDUMP
-		    if (WCOREDUMP(cst1)) {
-			fprintf(stderr,
-			      "HTParseInet: NSL_FORK child %d dumped core!\n",
+		if (WCOREDUMP(cst1)) {
+		    CTRACE(tfp, "HTParseInet: NSL_FORK child %d dumped core!\n",
 				(int)waitret);
 		    }
 #endif /* WCOREDUMP */
-		} else if (WIFSTOPPED(cst1)) {
-		    fprintf(stderr,
-		  "HTParseInet: NSL_FORK child %d is stopped, status 0x%x!\n",
+	    } else if (WIFSTOPPED(cst1)) {
+		CTRACE(tfp, "HTParseInet: NSL_FORK child %d is stopped, status 0x%x!\n",
 			    (int)waitret, cst1);
-		}
 	    }
 	    /*
 	    **	Read as much as we can - should be the address.
 	    */
 	    IOCTL(pfd[0], FIONREAD, &cstat);
 	    if (cstat < 4) {
-		if (TRACE) {
-		    fprintf(stderr,
-		       "HTParseInet: NSL_FORK child returns only %d bytes.\n",
+		CTRACE(tfp, "HTParseInet: NSL_FORK child returns only %d bytes.\n",
 			    cstat);
-		    fprintf(stderr,
-			"             Trying again without forking.\n");
-		}
+		CTRACE(tfp, "             Trying again without forking.\n");
 		phost = gethostbyname(host);	/* See netdb.h */
 		if (!OK_HOST(phost)) {
-		    if (TRACE) {
-			fprintf(stderr,
-			 "HTParseInet: Can't find internet node name `%s'.\n",
+		    CTRACE(tfp, "HTParseInet: Can't find internet node name `%s'.\n",
 				host);
-		    }
 		    memset((void *)&soc_in->sin_addr, 0, sizeof(soc_in->sin_addr));
 		} else {
 		    memcpy((void *)&soc_in->sin_addr,
@@ -563,11 +537,8 @@ PUBLIC int HTParseInet ARGS2(
 	    close(pfd[1]);
 	}
 	if (soc_in->sin_addr.s_addr == 0) {
-	    if (TRACE) {
-		fprintf(stderr,
-			"HTParseInet: Can't find internet node name `%s'.\n",
+	    CTRACE(tfp, "HTParseInet: Can't find internet node name `%s'.\n",
 			host);
-	    }
 #ifndef _WINDOWS_NSL
 	    FREE(host);
 #endif /* _WINDOWS_NSL */
@@ -577,10 +548,7 @@ PUBLIC int HTParseInet ARGS2(
 	FREE(host);
 #endif /* _WINDOWS_NSL */
 #ifdef MVS
-	if (TRACE) {
-	    fprintf(stderr,
-		    "HTParseInet: gethostbyname() returned %d\n", phost);
-	}
+	CTRACE(tfp, "HTParseInet: gethostbyname() returned %d\n", phost);
 #endif /* MVS */
 
 #else /* Not NSL_FORK: */
@@ -588,10 +556,8 @@ PUBLIC int HTParseInet ARGS2(
 	soc_in->sin_addr.s_addr = htonl(resolve(host));
 	FREE(host);
 	if (soc_in->sin_addr.s_addr == 0) {
-		 if (TRACE)
-			  fprintf(stderr,
-			 "HTTPAccess: Can't find internet node name `%s'.\n",host);
-		 return -1;  /* Fail? */
+	    CTRACE(tfp, "HTTPAccess: Can't find internet node name `%s'.\n",host);
+	    return -1;  /* Fail? */
 	}
 #else
 #ifdef _WINDOWS_NSL
@@ -627,17 +593,11 @@ PUBLIC int HTParseInet ARGS2(
 	phost = gethostbyname(host);	/* See netdb.h */
 #endif /* _WINDOWS_NSL */
 #ifdef MVS
-	if (TRACE) {
-	    fprintf(stderr,
-		    "HTParseInet: gethostbyname() returned %d\n", phost);
-	}
+	CTRACE(tfp, "HTParseInet: gethostbyname() returned %d\n", phost);
 #endif /* MVS */
 	if (!phost) {
-	    if (TRACE) {
-		fprintf(stderr,
-			"HTParseInet: Can't find internet node name `%s'.\n",
+	    CTRACE(tfp, "HTParseInet: Can't find internet node name `%s'.\n",
 			host);
-	    }
 #ifndef _WINDOWS_NSL
 	    FREE(host);
 #endif /* _WINDOWS_NSL */
@@ -663,15 +623,12 @@ PUBLIC int HTParseInet ARGS2(
 #endif /* NSL_FORK */
     }
 
-    if (TRACE) {
-	fprintf(stderr,
-	   "HTParseInet: Parsed address as port %d, IP address %d.%d.%d.%d\n",
+    CTRACE(tfp, "HTParseInet: Parsed address as port %d, IP address %d.%d.%d.%d\n",
 		(int)ntohs(soc_in->sin_port),
 		(int)*((unsigned char *)(&soc_in->sin_addr)+0),
 		(int)*((unsigned char *)(&soc_in->sin_addr)+1),
 		(int)*((unsigned char *)(&soc_in->sin_addr)+2),
 		(int)*((unsigned char *)(&soc_in->sin_addr)+3));
-    }
 #endif	/* Internet vs. Decnet */
 
     return 0;	/* OK */
@@ -729,15 +686,14 @@ PRIVATE void get_host_details NOARGS
 #ifdef NEED_HOST_ADDRESS		/* no -- needs name server! */
     phost = gethostbyname(name);	/* See netdb.h */
     if (!OK_HOST(phost)) {
-	if (TRACE) fprintf(stderr,
-		"TCP: Can't find my own internet node address for `%s'!!\n",
-		name);
+	CTRACE(tfp, "TCP: Can't find my own internet node address for `%s'!!\n",
+		    name);
 	return;  /* Fail! */
     }
     StrAllocCopy(hostname, phost->h_name);
     memcpy(&HTHostAddress, &phost->h_addr, phost->h_length);
-    if (TRACE) fprintf(stderr, "     Name server says that I am `%s' = %s\n",
-	    hostname, HTInetString(&HTHostAddress));
+    CTRACE(tfp, "     Name server says that I am `%s' = %s\n",
+		hostname, HTInetString(&HTHostAddress));
 #endif /* NEED_HOST_ADDRESS */
 
 #endif /* !DECNET */
@@ -995,8 +951,7 @@ PUBLIC int HTDoConnect ARGS4(
 		}
 	    }
 	    if (HTCheckForInterrupt()) {
-		if (TRACE)
-		    fprintf(stderr, "*** INTERRUPTED in middle of connect.\n");
+		CTRACE(tfp, "*** INTERRUPTED in middle of connect.\n");
 		status = HT_INTERRUPTED;
 		SOCKET_ERRNO = EINTR;
 		break;
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 996ebd4b..4cd22539 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -35,8 +35,6 @@
 #include <LYGlobalDefs.h>
 #include <LYLeaks.h>
 
-/* #define TRACE 1 */
-
 struct _HTStream
 {
   HTStreamClass * isa;
@@ -186,17 +184,13 @@ try_again:
       /*
       **  Interrupt cleanly.
       */
-      if (TRACE)
-	  fprintf (stderr,
-		   "HTTP: Interrupted on connect; recovering cleanly.\n");
-      _HTProgress ("Connection interrupted.");
-      status = HT_NOT_LOADED;
-      goto done;
-  }
-  if (status < 0) {
-      if (TRACE)
-	  fprintf(stderr,
-	    "HTTP: Unable to connect to remote host for `%s' (errno = %d).\n",
+       CTRACE (tfp, "HTTP: Interrupted on connect; recovering cleanly.\n");
+       _HTProgress ("Connection interrupted.");
+       status = HT_NOT_LOADED;
+       goto done;
+   }
+   if (status < 0) {
+	CTRACE(tfp, "HTTP: Unable to connect to remote host for `%s' (errno = %d).\n",
 	    url, SOCKET_ERRNO);
       HTAlert("Unable to connect to remote host.");
       status = HT_NOT_LOADED;
@@ -441,8 +435,7 @@ try_again:
 		*/
 		sprintf(line, "%s%c%c", auth, CR, LF);
 		StrAllocCat(command, line);
-		if (TRACE)
-		    fprintf(stderr, "HTTP: Sending authorization: %s\n", auth);
+		CTRACE(tfp, "HTTP: Sending authorization: %s\n", auth);
 	    } else if (auth && *auth == '\0') {
 		/*
 		**  If auth is a zero-length string, the user either
@@ -466,9 +459,7 @@ try_again:
 		    goto done;
 		}
 	    } else {
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTTP: Not sending authorization (yet).\n");
+		CTRACE(tfp, "HTTP: Not sending authorization (yet).\n");
 	    }
 	    /*
 	    **	Add 'Cookie:' header, if it's HTTP or HTTPS
@@ -501,9 +492,7 @@ try_again:
 		*/
 		StrAllocCat(command, "Cookie2: $Version=\"1\"");
 		StrAllocCat(command, crlf);
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTTP: Sending Cookie2: $Version =\"1\"\n");
+		CTRACE(tfp, "HTTP: Sending Cookie2: $Version =\"1\"\n");
 	    }
 	    if (*cookie != '\0') {
 		/*
@@ -514,8 +503,7 @@ try_again:
 		StrAllocCat(command, "Cookie: ");
 		StrAllocCat(command, cookie);
 		StrAllocCat(command, crlf);
-		if (TRACE)
-		    fprintf(stderr, "HTTP: Sending Cookie: %s\n", cookie);
+		CTRACE(tfp, "HTTP: Sending Cookie: %s\n", cookie);
 	    }
 	    FREE(cookie);
 	}
@@ -540,9 +528,7 @@ try_again:
 	    */
 	    sprintf(line, "%s%c%c", auth, CR, LF);
 	    StrAllocCat(command, line);
-	    if (TRACE)
-		fprintf(stderr,
-			(auth_proxy ?
+	    CTRACE(tfp, (auth_proxy ?
 			 "HTTP: Sending proxy authorization: %s\n" :
 			 "HTTP: Sending authorization: %s\n"),
 			auth);
@@ -569,9 +555,7 @@ try_again:
 		goto done;
 	    }
 	} else {
-	    if (TRACE)
-		fprintf(stderr,
-			(auth_proxy ?
+	    CTRACE(tfp, (auth_proxy ?
 			 "HTTP: Not sending proxy authorization (yet).\n" :
 			 "HTTP: Not sending authorization (yet).\n"));
 	}
@@ -581,12 +565,10 @@ try_again:
       auth_proxy = NO;
   }
 
-  if (do_post)
-    {
-      if (TRACE)
-	  fprintf (stderr, "HTTP: Doing post, content-type '%s'\n",
-		   anAnchor->post_content_type ? anAnchor->post_content_type
-					       : "lose");
+    if (do_post) {
+	CTRACE (tfp, "HTTP: Doing post, content-type '%s'\n",
+		     anAnchor->post_content_type ? anAnchor->post_content_type
+						 : "lose");
       sprintf (line, "Content-type: %s%c%c",
 	       anAnchor->post_content_type ? anAnchor->post_content_type
 					   : "lose", CR, LF);
@@ -609,12 +591,9 @@ try_again:
   else
       StrAllocCat(command, crlf);	/* Blank line means "end" of headers */
 
-  if (TRACE) {
-      fprintf (stderr,
-	       "Writing:\n%s%s----------------------------------\n",
+  CTRACE (tfp, "Writing:\n%s%s----------------------------------\n",
 	       command,
 	       (anAnchor->post_data ? crlf : ""));
-  }
 
   _HTProgress ("Sending HTTP request.");
 
@@ -622,8 +601,7 @@ try_again:
   FREE(command);
   if (status <= 0) {
       if (status == 0) {
-	  if (TRACE)
-	      fprintf (stderr, "HTTP: Got status 0 in initial write\n");
+	  CTRACE (tfp, "HTTP: Got status 0 in initial write\n");
 	  /* Do nothing. */
       } else if ((SOCKET_ERRNO == ENOTCONN ||
 		  SOCKET_ERRNO == ECONNRESET ||
@@ -633,18 +611,14 @@ try_again:
 	    /*
 	    **	Arrrrgh, HTTP 0/1 compability problem, maybe.
 	    */
-	    if (TRACE)
-		fprintf (stderr,
-		 "HTTP: BONZO ON WRITE Trying again with HTTP0 request.\n");
+	    CTRACE (tfp, "HTTP: BONZO ON WRITE Trying again with HTTP0 request.\n");
 	    _HTProgress ("Retrying as HTTP0 request.");
 	    HTTP_NETCLOSE(s, handle);
 	    extensions = NO;
 	    already_retrying = TRUE;
 	    goto try_again;
       } else {
-	  if (TRACE)
-	      fprintf (stderr,
-	   "HTTP: Hit unexpected network WRITE error; aborting connection.\n");
+	  CTRACE (tfp, "HTTP: Hit unexpected network WRITE error; aborting connection.\n");
 	  HTTP_NETCLOSE(s, handle);
 	  status = -1;
 	  HTAlert("Unexpected network write error; connection aborted.");
@@ -652,8 +626,7 @@ try_again:
       }
   }
 
-  if (TRACE)
-      fprintf (stderr, "HTTP: WRITE delivered OK\n");
+  CTRACE (tfp, "HTTP: WRITE delivered OK\n");
   _HTProgress ("HTTP request sent; waiting for response.");
 
   /*	Read the first line of the response
@@ -675,21 +648,18 @@ try_again:
 	    line_buffer =
 	      (char *)realloc(line_buffer, (buffer_length * sizeof(char)));
 	}
-	if (TRACE)
-	    fprintf (stderr, "HTTP: Trying to read %d\n",
+	CTRACE (tfp, "HTTP: Trying to read %d\n",
 		     buffer_length - length - 1);
 	status = HTTP_NETREAD(s, line_buffer + length,
 			      buffer_length - length - 1, handle);
-	if (TRACE)
-	    fprintf (stderr, "HTTP: Read %d\n", status);
+	CTRACE (tfp, "HTTP: Read %d\n", status);
 	if (status <= 0) {
 	    /*
 	     *	Retry if we get nothing back too.
 	     *	Bomb out if we get nothing twice.
 	     */
 	    if (status == HT_INTERRUPTED) {
-		if (TRACE)
-		    fprintf (stderr, "HTTP: Interrupted initial read.\n");
+		CTRACE (tfp, "HTTP: Interrupted initial read.\n");
 		_HTProgress ("Connection interrupted.");
 		HTTP_NETCLOSE(s, handle);
 		status = HT_NO_DATA;
@@ -702,9 +672,7 @@ try_again:
 		/*
 		**  Arrrrgh, HTTP 0/1 compability problem, maybe.
 		*/
-		if (TRACE)
-		    fprintf (stderr,
-			"HTTP: BONZO Trying again with HTTP0 request.\n");
+		CTRACE (tfp, "HTTP: BONZO Trying again with HTTP0 request.\n");
 		HTTP_NETCLOSE(s, handle);
 		FREE(line_buffer);
 		FREE(line_kept_clean);
@@ -714,9 +682,7 @@ try_again:
 		_HTProgress ("Retrying as HTTP0 request.");
 		goto try_again;
 	    } else {
-		if (TRACE)
-		    fprintf (stderr,
-  "HTTP: Hit unexpected network read error; aborting connection; status %d.\n",
+		CTRACE (tfp, "HTTP: Hit unexpected network read error; aborting connection; status %d.\n",
 			   status);
 		HTAlert("Unexpected network read error; connection aborted.");
 		HTTP_NETCLOSE(s, handle);
@@ -771,8 +737,7 @@ try_again:
   /*	We now have a terminated unfolded line. Parse it.
   **	-------------------------------------------------
   */
-  if (TRACE)
-      fprintf(stderr, "HTTP: Rx: %s\n", line_buffer);
+  CTRACE(tfp, "HTTP: Rx: %s\n", line_buffer);
 
   /*
   **  Kludge to work with old buggy servers and the VMS Help gateway.
@@ -788,8 +753,7 @@ try_again:
       FREE(line_kept_clean);
       extensions = NO;
       already_retrying = TRUE;
-      if (TRACE)
-	  fprintf(stderr, "HTTP: close socket %d to retry with HTTP0\n", s);
+      CTRACE(tfp, "HTTP: close socket %d to retry with HTTP0\n", s);
       HTTP_NETCLOSE(s, handle);
       /* print a progress message */
       _HTProgress ("Retrying as HTTP0 request.");
@@ -808,8 +772,7 @@ try_again:
 		    server_version,
 		    &server_status);
 
-    if (TRACE)
-	fprintf (stderr, "HTTP: Scanned %d fields from line_buffer\n", fields);
+    CTRACE (tfp, "HTTP: Scanned %d fields from line_buffer\n", fields);
 
     if (http_error_file) {     /* Make the status code externally available */
 	FILE *error_file;
@@ -841,8 +804,7 @@ try_again:
 	 */
 	HTAtom * encoding;
 
-	if (TRACE)
-	    fprintf (stderr, "--- Talking HTTP0.\n");
+	CTRACE (tfp, "--- Talking HTTP0.\n");
 
 	format_in = HTFileFormat(url, &encoding, NULL);
 	/*
@@ -851,27 +813,19 @@ try_again:
 	**  without looking at content.
 	*/
 	if (!strncmp(HTAtom_name(format_in), "text/plain",10)) {
-	    if (TRACE)
-		fprintf(stderr,
-			   "HTTP: format_in being changed to text/HTML\n");
+	    CTRACE(tfp, "HTTP: format_in being changed to text/HTML\n");
 	    format_in = WWW_HTML;
 	}
 	if (!IsUnityEnc(encoding)) {
 	    /*
 	    **	Change the format to that for "www/compressed".
 	    */
-	    if (TRACE) {
-		fprintf(stderr,
-			"HTTP: format_in is '%s',\n", HTAtom_name(format_in));
-	    }
+	    CTRACE(tfp, "HTTP: format_in is '%s',\n", HTAtom_name(format_in));
 	    StrAllocCopy(anAnchor->content_type, HTAtom_name(format_in));
 	    StrAllocCopy(anAnchor->content_encoding, HTAtom_name(encoding));
 	    format_in = HTAtom_for("www/compressed");
-	    if (TRACE) {
-		fprintf(stderr,
-			"        Treating as '%s' with encoding '%s'\n",
+	    CTRACE(tfp, "        Treating as '%s' with encoding '%s'\n",
 			"www/compressed", HTAtom_name(encoding));
-	    }
 	}
 
 	start_of_data = line_kept_clean;
@@ -880,8 +834,7 @@ try_again:
 	**  Set up to decode full HTTP/1.n response. - FM
 	*/
 	format_in = HTAtom_for("www/mime");
-	if (TRACE)
-	    fprintf (stderr, "--- Talking HTTP1.\n");
+	CTRACE (tfp, "--- Talking HTTP1.\n");
 
 	/*
 	**  We set start_of_data to "" when !eol here because there
@@ -1133,8 +1086,7 @@ try_again:
 		  /*
 		   *  Impatient user. - FM
 		   */
-		  if (TRACE)
-		      fprintf (stderr, "HTTP: Interrupted followup read.\n");
+		  CTRACE (tfp, "HTTP: Interrupted followup read.\n");
 		  _HTProgress ("Connection interrupted.");
 		  status = HT_INTERRUPTED;
 		  goto clean_up;
@@ -1147,9 +1099,7 @@ try_again:
 		       *  Don't make the redirection permanent
 		       *  if we have POST content. - FM
 		       */
-		      if (TRACE)
-			  fprintf(stderr,
-	 "HTTP: Have POST content. Treating 301 (Permanent) as Temporary.\n");
+		      CTRACE(tfp, "HTTP: Have POST content. Treating 301 (Permanent) as Temporary.\n");
 		      HTAlert(
 	 "Have POST content. Treating Permanent Redirection as Temporary.\n");
 		  } else {
@@ -1367,9 +1317,7 @@ Cookie2_continuation:
 			     *	thus is probably something in the body, so
 			     *	we'll show the user what was returned. - FM
 			     */
-			    if (TRACE)
-				fprintf(stderr,
-					"HTTP: 'Location:' is zero-length!\n");
+			    CTRACE(tfp, "HTTP: 'Location:' is zero-length!\n");
 			    if (cp1)
 				*cp1 = LF;
 			    if (cp2)
@@ -1388,9 +1336,7 @@ Cookie2_continuation:
 			 *  seek the document at that Location. - FM
 			 */
 			HTProgress(line_buffer);
-			if (TRACE)
-			    fprintf(stderr,
-				    "HTTP: Picked up location '%s'\n",
+			CTRACE(tfp, "HTTP: Picked up location '%s'\n",
 				    redirecting_url);
 			if (cp1)
 			    *cp1 = LF;
@@ -1408,9 +1354,7 @@ Cookie2_continuation:
 			     *	Append our URL. - FM
 			     */
 			    StrAllocCat(redirecting_url, anAnchor->address);
-			    if (TRACE)
-				fprintf(stderr,
-					"HTTP: Proxy URL is '%s'\n",
+			    CTRACE(tfp, "HTTP: Proxy URL is '%s'\n",
 					redirecting_url);
 			}
 			if (!do_post ||
@@ -1474,8 +1418,7 @@ Cookie2_continuation:
 	       *  header, so we'll show the user what we got, if
 	       *  anything. - FM
 	       */
-	      if (TRACE)
-		  fprintf (stderr, "HTTP: Failed to pick up location.\n");
+	      CTRACE (tfp, "HTTP: Failed to pick up location.\n");
 	      doing_redirect = FALSE;
 	      permanent_redirection = FALSE;
 	      start_of_data = line_kept_clean;
@@ -1532,10 +1475,9 @@ Cookie2_continuation:
 			goto clean_up;
 		    }
 
-		    if (TRACE)
-			fprintf(stderr, "%s %d %s\n",
-			      "HTTP: close socket", s,
-			      "to retry with Access Authorization");
+		    CTRACE(tfp, "%s %d %s\n",
+				"HTTP: close socket", s,
+				"to retry with Access Authorization");
 
 		    _HTProgress (
 			"Retrying with access authorization information.");
@@ -1583,10 +1525,9 @@ Cookie2_continuation:
 			goto clean_up;
 		    }
 
-		    if (TRACE)
-			fprintf(stderr, "%s %d %s\n",
-			      "HTTP: close socket", s,
-			      "to retry with Proxy Authorization");
+		    CTRACE(tfp, "%s %d %s\n",
+				"HTTP: close socket", s,
+				"to retry with Proxy Authorization");
 
 		    _HTProgress (
 			"Retrying with proxy authorization information.");
@@ -1779,8 +1720,7 @@ Cookie2_continuation:
       (*target->isa->_abort)(target, NULL);
       HTTP_NETCLOSE(s, handle);
       if (!already_retrying && !do_post) {
-	  if (TRACE)
-	      fprintf (stderr, "HTTP: Trying again with HTTP0 request.\n");
+	  CTRACE (tfp, "HTTP: Trying again with HTTP0 request.\n");
 	  /*
 	  **  May as well consider it an interrupt -- right?
 	  */
diff --git a/WWW/Library/Implementation/HTTelnet.c b/WWW/Library/Implementation/HTTelnet.c
index 3a03eb33..d842f230 100644
--- a/WWW/Library/Implementation/HTTelnet.c
+++ b/WWW/Library/Implementation/HTTelnet.c
@@ -91,8 +91,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 	    *port++ = '\0';	/* Split */
 
     if (!hostname || *hostname == '\0') {
-	if (TRACE)
-	    fprintf(stderr, "HTTelnet: No host specified!\n");
+	CTRACE(tfp, "HTTelnet: No host specified!\n");
 	return HT_NO_DATA;
     }
 
@@ -149,8 +148,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 		hostname,
 		port ? port : "");
 
-	if (TRACE)
-	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
+	CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command);
 	system(command);
 	return HT_NO_DATA;		/* Ok - it was done but no data */
 #define TELNET_DONE
@@ -176,8 +174,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 		port ? port : "");
 	}
 
-	if (TRACE)
-	    fprintf(stderr, "HTTelnet: Normal: Command is: %s\n\n", command);
+	CTRACE(tfp, "HTTelnet: Normal: Command is: %s\n\n", command);
 #ifdef __DJGPP__
        __djgpp_set_ctrl_c(0);
        _go32_want_ctrl_break(1);
@@ -216,8 +213,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 		hostname);
 	}
 
-	if (TRACE)
-	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
+	CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command);
 	system(command);
 	return HT_NO_DATA;		/* Ok - it was done but no data */
 #define TELNET_DONE
@@ -272,8 +268,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 		}
 	    }
 
-	    if (TRACE)
-		fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
+	    CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command);
 	    system(command);
 	    return HT_NO_DATA;		/* Ok - it was done but no data */
 	}
@@ -300,8 +295,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 		port ? port : "");
 	}
 
-	if (TRACE)
-	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
+	CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command);
 	system(command);
 	return HT_NO_DATA;		/* Ok - it was done but no data */
 #define TELNET_DONE
@@ -313,8 +307,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 		port ? "/PORT=" : "",
 		port ? port : "",
 		hostname);
-	    if (TRACE)
-		fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
+	    CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command);
 	    system(command);
 	}
 	else {
@@ -358,8 +351,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 		hostname);
 	}
 
-	if (TRACE)
-	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
+	CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command);
 	system(command);
 	return HT_NO_DATA;		/* Ok - it was done but no data */
     }
@@ -400,8 +392,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 	    }
 	}
 
-	if (TRACE)
-	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
+	CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command);
 	system(command);
 	return HT_NO_DATA;		/* Ok - it was done but no data */
     }
@@ -424,8 +415,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 		port ? port : "");
 	}
 
-	if (TRACE)
-	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
+	CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command);
 	system(command);
 	return HT_NO_DATA;		/* Ok - it was done but no data */
     }
@@ -435,8 +425,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 		port ? "/PORT=" : "",
 		port ? port : "",
 		hostname);
-	    if (TRACE)
-		fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
+	    CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command);
 	    system(command);
 	}
 	else {
@@ -458,8 +447,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 		port ? "/PORT=" : "",
 		port ? port : "",
 		hostname);
-	    if (TRACE)
-		fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
+	    CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command);
 	    system(command);
 	}
 	else {
@@ -486,8 +474,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 	if (login_protocol == telnet) { 		/* telnet only */
 	    sprintf(command, "TELNET  %s",	/* @@ Bug: port ignored */
 		hostname);
-	    if (TRACE)
-		fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
+	    CTRACE(tfp, "HTTelnet: Command is: %s\n\n", command);
 	    system(command);
 	    return HT_NO_DATA;		/* Ok - it was done but no data */
 	}
@@ -549,9 +536,7 @@ ARGS4
     int status;
 
     if (sink) {
-	if (TRACE)
-	    fprintf(stderr,
-	   "HTTelnet: Can't output a live session -- must be interactive!\n");
+	CTRACE(tfp, "HTTelnet: Can't output a live session -- must be interactive!\n");
 	return HT_NO_DATA;
     }
     acc_method =  HTParse(addr, "file:", PARSE_ACCESS);
@@ -559,8 +544,7 @@ ARGS4
     host = HTParse(addr, "", PARSE_HOST);
     if (!host || *host == '\0') {
 	status = HT_NO_DATA;
-	if (TRACE)
-	    fprintf(stderr, "HTTelnet: No host specified!\n");
+	CTRACE(tfp, "HTTelnet: No host specified!\n");
     } else {
 	status = remote_session(acc_method, host);
     }
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index d96a6cb7..fa3677d2 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -74,7 +74,7 @@
 #define HAVE_UTMP 1
 #endif
 
-#endif
+#endif /* HAVE_CONFIG_H */ 
 
 #ifndef	GCC_UNUSED
 #define	GCC_UNUSED /* nothing */
@@ -88,6 +88,15 @@
 #define popen _popen
 #define pclose _pclose
 #endif /* _WINDOWS */
+ 
+#ifdef __EMX__ 
+#include <unistd.h> /* should be re-include protected under EMX */ 
+#include <stdlib.h> /* should be re-include protected under EMX */ 
+#define getcwd _getcwd2 
+#define chdir _chdir2 
+ 
+#endif 
+ 
 
 #ifdef SHORT_NAMES
 #define WWW_TraceFlag HTTrFlag
diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c
index ca800517..69198b65 100644
--- a/WWW/Library/Implementation/HTVMSUtils.c
+++ b/WWW/Library/Implementation/HTVMSUtils.c
@@ -106,12 +106,10 @@ unsigned long Prv[2], PreviousPrv[2];
    Prv[1] = 0;
    Result = sys$setprv(1,&Prv,0,&PreviousPrv);
 
-   if (TRACE) {
-      if (Result == SS$_NORMAL) {
-         if (!(PreviousPrv[0] & PRV$M_SYSPRV)) {
-            fprintf(stderr, "HTVMS_enableSysPrv: Enabled SYSPRV\n");
-         }
-      }
+   if (Result == SS$_NORMAL) {
+       if (!(PreviousPrv[0] & PRV$M_SYSPRV)) {
+           CTRACE(tfp, "HTVMS_enableSysPrv: Enabled SYSPRV\n");
+       }
    }
 }
 
@@ -134,12 +132,10 @@ unsigned long Prv[2], PreviousPrv[2];
    Prv[1] = 0;
    Result = sys$setprv(0,&Prv,0,&PreviousPrv);
 
-   if (TRACE) {
-      if (Result == SS$_NORMAL) {
-         if (PreviousPrv[0] & PRV$M_SYSPRV) {
-            fprintf(stderr, "HTVMS_disableSysPrv: Disabled SYSPRV\n");
-         }
-      }
+   if (Result == SS$_NORMAL) {
+       if (PreviousPrv[0] & PRV$M_SYSPRV) {
+           CTRACE(tfp, "HTVMS_disableSysPrv: Disabled SYSPRV\n");
+       }
    }
 }
 
@@ -900,7 +896,7 @@ PUBLIC int HTVMSBrowseDir ARGS4(
     extern BOOLEAN no_dotfiles, show_dotfiles;
 
     HTUnEscape(pathname);
-    CTRACE(stderr,"HTVMSBrowseDir: Browsing `%s\'\n", pathname);
+    CTRACE(tfp,"HTVMSBrowseDir: Browsing `%s\'\n", pathname);
 
     /*
      *  Require at least two elements (presumably a device and directory)
@@ -1178,7 +1174,7 @@ PUBLIC int HTVMSBrowseDir ARGS4(
 	    /* Now, update the BTree etc. */
 	    if(entry_info->display)
 	      {
-		 CTRACE(stderr,"Adding file to BTree: %s\n",
+		 CTRACE(tfp,"Adding file to BTree: %s\n",
 						      entry_info->filename);
 	         HTBTree_add(bt, (VMSEntryInfo *)entry_info); 
 	      }
diff --git a/WWW/Library/Implementation/HTWAIS.c b/WWW/Library/Implementation/HTWAIS.c
index 627086ab..11bc6bad 100644
--- a/WWW/Library/Implementation/HTWAIS.c
+++ b/WWW/Library/Implementation/HTWAIS.c
@@ -272,22 +272,20 @@ PRIVATE char * WWW_from_WAIS ARGS1(
     int i, l;
     if (TRACE) {
 	char *p;
-	fprintf(stderr, "WAIS id (%d bytes) is ", (int)docid->size);
+	fprintf(tfp, "WAIS id (%d bytes) is ", (int)docid->size);
 	for (p = docid->bytes; p < docid->bytes+docid->size; p++) {
 	    if ((*p >= ' ') && (*p<= '~')) /* Assume ASCII! */
-		fprintf(stderr, "%c", *p);
+		fprintf(tfp, "%c", *p);
 	    else
-		fprintf(stderr, "<%x>", (unsigned)*p);
+		fprintf(tfp, "<%x>", (unsigned)*p);
 	}
-	fprintf(stderr, "\n");
+	fprintf(tfp, "\n");
     }
     for (p = docid->bytes;
 	 (p < docid->bytes+docid->size) && (q < &buf[BIG]);) {
-	if (TRACE)
-	    fprintf(stderr, "    Record type %d, length %d\n", p[0], p[1]);
+	CTRACE(tfp, "    Record type %d, length %d\n", p[0], p[1]);
 	if (*p > 10) {
-	    if (TRACE)
-		fprintf(stderr, "Eh? DOCID record type of %d!\n", *p);
+	    CTRACE(tfp, "Eh? DOCID record type of %d!\n", *p);
 	    return 0;
 	}
 	{	/* Bug fix -- allow any byte value 15 Apr 93 */
@@ -316,8 +314,7 @@ PRIVATE char * WWW_from_WAIS ARGS1(
 	*q++= ';';		/* Terminate field */
     }
     *q++ = 0;			/* Terminate string */
-    if (TRACE)
-	fprintf(stderr, "WWW form of id: %s\n", buf);
+    CTRACE(tfp, "WWW form of id: %s\n", buf);
     {
 	char * result = (char *)malloc(strlen(buf)+1);
 	if (!result)
@@ -347,8 +344,8 @@ PRIVATE any * WAIS_from_WWW ARGS2(
     char *q;	/* Poisition of "=" */
     char *s;	/* Position of semicolon */
     int n;	/* size */
-    if (TRACE)
-	fprintf(stderr, "WWW id (to become WAIS id): %s\n", docname);
+
+    CTRACE(tfp, "WWW id (to become WAIS id): %s\n", docname);
     for (n = 0, p = docname; *p; p++) { /* Count sizes of strings */
 	n++;
 	if (*p == ';')
@@ -404,14 +401,14 @@ PRIVATE any * WAIS_from_WWW ARGS2(
 
     if (TRACE) {
 	char *p;
-	fprintf(stderr, "WAIS id (%d bytes) is ", (int)docid->size);
+	fprintf(tfp, "WAIS id (%d bytes) is ", (int)docid->size);
 	for (p = docid->bytes; p < docid->bytes+docid->size; p++) {
 	    if ((*p >= ' ') && (*p<= '~')) /* Assume ASCII! */
-		fprintf(stderr, "%c", *p);
+		fprintf(tfp, "%c", *p);
 	    else
-		fprintf(stderr, "<%x>", (unsigned)*p);
+		fprintf(tfp, "<%x>", (unsigned)*p);
 	}
-	fprintf(stderr, "\n");
+	fprintf(tfp, "\n");
     }
     return docid;		/* Ok */
 
@@ -473,8 +470,7 @@ PRIVATE void display_search_response ARGS4(
 
     BOOL archie =  strstr(database, "archie")!=0;	/* Specical handling */
 
-    if (TRACE)
-	fprintf(stderr, "HTWAIS: Displaying search response\n");
+    CTRACE(tfp, "HTWAIS: Displaying search response\n");
     PUTS("Index ");
     START(HTML_EM);
     PUTS(database);
@@ -512,9 +508,7 @@ PRIVATE void display_search_response ARGS4(
 		/*
 		**  Make a printable string out of the document id.
 		*/
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTWAIS:  %2ld: Score: %4ld, lines:%4ld '%s'\n",
+		CTRACE(tfp, "HTWAIS:  %2ld: Score: %4ld, lines:%4ld '%s'\n",
 			    i,
 			    (long int)(info->DocHeaders[k]->Score),
 			    (long int)(info->DocHeaders[k]->Lines),
@@ -706,8 +700,7 @@ PUBLIC int HTLoadWAIS ARGS4(
     if (!ok)
 	return HTLoadError(sink, 500, "Syntax error in WAIS URL");
 
-    if (TRACE)
-	fprintf(stderr, "HTWAIS: Parsed OK\n");
+    CTRACE(tfp, "HTWAIS: Parsed OK\n");
 
     service = strchr(names, ':');
     if (service)
@@ -724,19 +717,16 @@ PUBLIC int HTLoadWAIS ARGS4(
 
     } else if (!(key && !*key)) {
 	int status;
-	if (TRACE)
-	fprintf (stderr, "===WAIS=== calling mosaic_connect_to_server\n");
+	CTRACE (tfp, "===WAIS=== calling mosaic_connect_to_server\n");
 	status = mosaic_connect_to_server(server_name,
 					  atoi(service),
 					  &connection);
 	if (status == 0) {
-	    if (TRACE)
-		fprintf (stderr, "===WAIS=== connection failed\n");
+	    CTRACE (tfp, "===WAIS=== connection failed\n");
 	    FREE(names);
 	    return HT_NOT_LOADED;
 	} else if (status == -1) {
-	    if (TRACE)
-		fprintf (stderr, "===WAIS=== connection interrupted\n");
+	    CTRACE (tfp, "===WAIS=== connection interrupted\n");
 	    FREE(names);
 	    return HT_NOT_LOADED;
 	}
@@ -809,10 +799,9 @@ PUBLIC int HTLoadWAIS ARGS4(
 		server_name, service, www_database);
 
 	fp = fopen(filename, "r");	/* Have we found this already? */
-	if (TRACE) fprintf(stderr,
-		"HTWAIS: Description of server %s %s.\n",
-		filename,
-		fp ? "exists already" : "does NOT exist!");
+	CTRACE(tfp, "HTWAIS: Description of server %s %s.\n",
+		    filename,
+		    fp ? "exists already" : "does NOT exist!");
 
 	if (fp) {
 	    char c;
@@ -865,8 +854,8 @@ PUBLIC int HTLoadWAIS ARGS4(
 	PUTS("\n");
 
 	request_buffer_length = MAX_MESSAGE_LEN; /* Amount left */
-	if (TRACE) fprintf(stderr, "HTWAIS: Search for `%s' in `%s'\n",
-		keywords, wais_database);
+	CTRACE(tfp, "HTWAIS: Search for `%s' in `%s'\n",
+		    keywords, wais_database);
 	if(NULL ==
 	generate_search_apdu(request_message + HEADER_LENGTH,
 				&request_buffer_length,
@@ -924,9 +913,8 @@ PUBLIC int HTLoadWAIS ARGS4(
 	any   doc_chunk;
 	any * docid = &doc_chunk;
 
-	if (TRACE) fprintf(stderr,
-		"HTWAIS: Retrieve document id `%s' type `%s' length %ld\n",
-		docname, doctype, document_length);
+	CTRACE(tfp, "HTWAIS: Retrieve document id `%s' type `%s' length %ld\n",
+		    docname, doctype, document_length);
 
 	format_in =
 	  !strcmp(doctype, "WSRC") ? HTAtom_for("application/x-wais-source") :
@@ -962,8 +950,7 @@ PUBLIC int HTLoadWAIS ARGS4(
 	    char *type = s_strdup(doctype);	/* Gets freed I guess */
 #endif /* VMS */
 	    request_buffer_length = MAX_MESSAGE_LEN; /* Amount left */
-	    if (TRACE)
-		fprintf(stderr, "HTWAIS: Slice number %ld\n", count);
+	    CTRACE(tfp, "HTWAIS: Slice number %ld\n", count);
 
 	    if (HTCheckForInterrupt()) {
 		HTAlert ("Data transfer interrupted.");
diff --git a/WWW/Library/Implementation/HTWSRC.c b/WWW/Library/Implementation/HTWSRC.c
index baf759c9..e5a7f830 100644
--- a/WWW/Library/Implementation/HTWSRC.c
+++ b/WWW/Library/Implementation/HTWSRC.c
@@ -162,9 +162,8 @@ PRIVATE void WSRCParser_put_character ARGS2(HTStream*, me, char, c)
 		}
 	    }
 	    if (!par_name[me->param_number]) {	/* Unknown field */
-		if (TRACE) fprintf(stderr,
-		    "HTWSRC: Unknown field `%s' in source file\n",
-		    me->param);
+		CTRACE(tfp, "HTWSRC: Unknown field `%s' in source file\n",
+			    me->param);
 		me->param_number = PAR_UNKNOWN;
 		me->state = before_value;	/* Could be better ignore */
 		return;
diff --git a/WWW/Library/Implementation/HTWriter.c b/WWW/Library/Implementation/HTWriter.c
index 601bdb0a..1e405cbb 100644
--- a/WWW/Library/Implementation/HTWriter.c
+++ b/WWW/Library/Implementation/HTWriter.c
@@ -52,8 +52,7 @@ PRIVATE void flush ARGS1(HTStream *, me)
 	status = NETWRITE(me->soc, me->buffer,	/* Put timeout? @@@ */
 			write_pointer - read_pointer);
 	if (status<0) {
-	    if(TRACE) fprintf(stderr,
-	    "HTWrite: Error: write() on socket returns %d !!!\n", status);
+	    CTRACE(tfp, "HTWrite: Error: write() on socket returns %d !!!\n", status);
 	    return;
 	}
 	read_pointer = read_pointer + status;
@@ -108,8 +107,7 @@ PRIVATE void HTWriter_write ARGS3(HTStream *, me, CONST char*, s, int, l)
 	int status = NETWRITE(me->soc, (char *)read_pointer,
 			write_pointer - read_pointer);
 	if (status<0) {
-	    if(TRACE) fprintf(stderr,
-	    "HTWriter_write: Error on socket output stream!!!\n");
+	    CTRACE(tfp, "HTWriter_write: Error on socket output stream!!!\n");
 	    return;
 	}
 	read_pointer = read_pointer + status;
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index 90210c13..21937698 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -282,17 +282,15 @@ PRIVATE void handle_attribute_name ARGS2(
 	    FREE(context->value[i]);
 #ifdef USE_COLOR_STYLE
 	    current_is_class=(!strcasecomp("class", s));
-	    if (TRACE)
-		fprintf(stderr, "SGML: found attribute %s, %d\n", s, current_is_class);
+	    CTRACE(tfp, "SGML: found attribute %s, %d\n", s, current_is_class);
 #endif
 	    return;
 	} /* if */
 
     } /* for */
 
-    if (TRACE)
-	fprintf(stderr, "SGML: Unknown attribute %s for tag %s\n",
-	    s, context->current_tag->name);
+    CTRACE(tfp, "SGML: Unknown attribute %s for tag %s\n",
+		s, context->current_tag->name);
     context->current_attribute_number = INVALID;	/* Invalid */
 }
 
@@ -310,18 +308,15 @@ PRIVATE void handle_attribute_value ARGS2(
 	if (current_is_class)
 	{
 	    strncpy (class_string, s, TEMPSTRINGSIZE);
-	    if (TRACE)
-		fprintf(stderr, "SGML: class is '%s'\n", s);
+	    CTRACE(tfp, "SGML: class is '%s'\n", s);
 	}
 	else
 	{
-	    if (TRACE)
-		fprintf(stderr, "SGML: attribute value is '%s'\n", s);
+	    CTRACE(tfp, "SGML: attribute value is '%s'\n", s);
 	}
 #endif
     } else {
-	if (TRACE)
-	    fprintf(stderr, "SGML: Attribute value %s ignored\n", s);
+	CTRACE(tfp, "SGML: Attribute value %s ignored\n", s);
     }
     context->current_attribute_number = INVALID; /* can't have two assignments! */
 }
@@ -512,9 +507,7 @@ PRIVATE void handle_entity ARGS2(
     */
     if (!strcmp(s, "zwnj") ||
 	!strcmp(s, "zwj")) {
-	if (TRACE) {
-	    fprintf(stderr, "handle_entity: Ignoring '%s'.\n", s);
-	}
+	CTRACE(tfp, "handle_entity: Ignoring '%s'.\n", s);
 	FoundEntity = TRUE;
 	return;
     }
@@ -524,9 +517,7 @@ PRIVATE void handle_entity ARGS2(
     */
     if (!strcmp(s, "lrm") ||
 	!strcmp(s, "rlm")) {
-	if (TRACE) {
-	    fprintf(stderr, "handle_entity: Ignoring '%s'.\n", s);
-	}
+	CTRACE(tfp, "handle_entity: Ignoring '%s'.\n", s);
 	FoundEntity = TRUE;
 	return;
     }
@@ -553,8 +544,7 @@ PRIVATE void handle_entity ARGS2(
     /*
     **	If entity string not found, display as text.
     */
-    if (TRACE)
-	fprintf(stderr, "SGML: Unknown entity '%s'\n", s);
+    CTRACE(tfp, "SGML: Unknown entity '%s'\n", s);
     PUTC('&');
     for (p = s; *p; p++) {
 	PUTC(*p);
@@ -572,8 +562,7 @@ PRIVATE void handle_comment ARGS1(
 {
     CONST char *s = context->string->data;
 
-    if (TRACE)
-	fprintf(stderr, "SGML Comment:\n<%s>\n", s);
+    CTRACE(tfp, "SGML Comment:\n<%s>\n", s);
 
     if (context->csi == NULL &&
 	strncmp(s, "!--#", 4) == 0 &&
@@ -593,8 +582,7 @@ PRIVATE void handle_identifier ARGS1(
 {
     CONST char *s = context->string->data;
 
-    if (TRACE)
-	fprintf(stderr, "SGML Identifier\n<%s>\n", s);
+    CTRACE(tfp, "SGML Identifier\n<%s>\n", s);
 
     return;
 }
@@ -608,8 +596,7 @@ PRIVATE void handle_doctype ARGS1(
 {
     CONST char *s = context->string->data;
 
-    if (TRACE)
-	fprintf(stderr, "SGML Doctype\n<%s>\n", s);
+    CTRACE(tfp, "SGML Doctype\n<%s>\n", s);
 
     return;
 }
@@ -623,8 +610,7 @@ PRIVATE void handle_marked ARGS1(
 {
     CONST char *s = context->string->data;
 
-    if (TRACE)
-	fprintf(stderr, "SGML Marked Section:\n<%s>\n", s);
+    CTRACE(tfp, "SGML Marked Section:\n<%s>\n", s);
 
     return;
 }
@@ -638,8 +624,7 @@ PRIVATE void handle_sgmlent ARGS1(
 {
     CONST char *s = context->string->data;
 
-    if (TRACE)
-	fprintf(stderr, "SGML Entity Declaration:\n<%s>\n", s);
+    CTRACE(tfp, "SGML Entity Declaration:\n<%s>\n", s);
 
     return;
 }
@@ -653,8 +638,7 @@ PRIVATE void handle_sgmlele ARGS1(
 {
     CONST char *s = context->string->data;
 
-    if (TRACE)
-	fprintf(stderr, "SGML Element Declaration:\n<%s>\n", s);
+    CTRACE(tfp, "SGML Element Declaration:\n<%s>\n", s);
 
     return;
 }
@@ -668,8 +652,7 @@ PRIVATE void handle_sgmlatt ARGS1(
 {
     CONST char *s = context->string->data;
 
-    if (TRACE)
-	fprintf(stderr, "SGML Attribute Declaration:\n<%s>\n", s);
+    CTRACE(tfp, "SGML Attribute Declaration:\n<%s>\n", s);
 
     return;
 }
@@ -765,8 +748,7 @@ PRIVATE void end_element ARGS2(
 	       (stackpos > 1 || (!extra_action_taken && stackpos == 0))) {
 	    canclose_check = can_close(old_tag, context->element_stack->tag);
 	    if (canclose_check != close_NO) {
-		if (TRACE)
-		    fprintf(stderr, "SGML: End </%s> \t<- %s end </%s>\n",
+		CTRACE(tfp, "SGML: End </%s> \t<- %s end </%s>\n",
 			    context->element_stack->tag->name,
 			    canclose_check == close_valid ? "supplied," : "forced by",
 			    old_tag->name);
@@ -774,8 +756,7 @@ PRIVATE void end_element ARGS2(
 		extra_action_taken = YES;
 		stackpos = is_on_stack(context, old_tag);
 	    } else {
-		if (TRACE)
-		    fprintf(stderr, "SGML: Still open %s \t<- invalid end </%s>\n",
+		CTRACE(tfp, "SGML: Still open %s \t<- invalid end </%s>\n",
 			    context->element_stack->tag->name,
 			    old_tag->name);
 		return;
@@ -783,8 +764,7 @@ PRIVATE void end_element ARGS2(
 	}
 
 	if (stackpos == 0 && old_tag->contents != SGML_EMPTY) {
-	    if (TRACE)
-		fprintf(stderr, "SGML: Still open %s, no open %s for </%s>\n",
+	    CTRACE(tfp, "SGML: Still open %s, no open %s for </%s>\n",
 			context->element_stack ?
 			context->element_stack->tag->name : "none",
 			old_tag->name,
@@ -792,8 +772,7 @@ PRIVATE void end_element ARGS2(
 	    return;
 	}
 	if (stackpos > 1) {
-	    if (TRACE)
-		fprintf(stderr, "SGML: Nesting <%s>...<%s> \t<- invalid end </%s>\n",
+	    CTRACE(tfp, "SGML: Nesting <%s>...<%s> \t<- invalid end </%s>\n",
 			old_tag->name,
 			context->element_stack->tag->name,
 			old_tag->name);
@@ -818,23 +797,18 @@ PRIVATE void end_element ARGS2(
 	    /*
 	    **	Ignore the end tag. - FM
 	    */
-	    if (TRACE) {
-		fprintf(stderr,
-			"SGML: Ignoring end tag </%s> in SELECT block.\n",
+	    CTRACE(tfp, "SGML: Ignoring end tag </%s> in SELECT block.\n",
 			old_tag->name);
-	    }
 	    return;
 	}
     }
     /*
     **	Handle the end tag. - FM
     */
-    if (TRACE)
-	fprintf(stderr, "SGML: End </%s>\n", old_tag->name);
+    CTRACE(tfp, "SGML: End </%s>\n", old_tag->name);
     if (old_tag->contents == SGML_EMPTY) {
-	if (TRACE)
-	    fprintf(stderr, "SGML: Illegal end tag </%s> found.\n",
-			    old_tag->name);
+	CTRACE(tfp, "SGML: Illegal end tag </%s> found.\n",
+		    old_tag->name);
 	return;
     }
 #ifdef WIND_DOWN_STACK
@@ -847,13 +821,11 @@ PRIVATE void end_element ARGS2(
 
 	if (old_tag != t) {		/* Mismatch: syntax error */
 	    if (context->element_stack->next) { /* This is not the last level */
-		if (TRACE) fprintf(stderr,
-		"SGML: Found </%s> when expecting </%s>. </%s> assumed.\n",
-		    old_tag->name, t->name, t->name);
+		CTRACE(tfp, "SGML: Found </%s> when expecting </%s>. </%s> assumed.\n",
+			    old_tag->name, t->name, t->name);
 	    } else {			/* last level */
-		if (TRACE) fprintf(stderr,
-		    "SGML: Found </%s> when expecting </%s>. </%s> Ignored.\n",
-		    old_tag->name, t->name, old_tag->name);
+		CTRACE(tfp, "SGML: Found </%s> when expecting </%s>. </%s> Ignored.\n",
+			    old_tag->name, t->name, old_tag->name);
 		return; 		/* Ignore */
 	    }
 	}
@@ -872,9 +844,8 @@ PRIVATE void end_element ARGS2(
 	/* Syntax error path only */
 
     }
-    if (TRACE)
-	fprintf(stderr, "SGML: Extra end tag </%s> found and ignored.\n",
-			old_tag->name);
+    CTRACE(tfp, "SGML: Extra end tag </%s> found and ignored.\n",
+		old_tag->name);
 }
 
 
@@ -901,8 +872,7 @@ PRIVATE void start_element ARGS1(
 					      direct_container))) {
 	    canclose_check = can_close(new_tag, context->element_stack->tag);
 	    if (canclose_check != close_NO) {
-		if (TRACE)
-		    fprintf(stderr, "SGML: End </%s> \t<- %s start <%s>\n",
+		CTRACE(tfp, "SGML: End </%s> \t<- %s start <%s>\n",
 			    context->element_stack->tag->name,
 			    canclose_check == close_valid ? "supplied," : "forced by",
 			    new_tag->name);
@@ -911,8 +881,7 @@ PRIVATE void start_element ARGS1(
 		if (canclose_check  == close_error)
 		    direct_container = NO;
 	    } else {
-		if (TRACE)
-		    fprintf(stderr, "SGML: Still open %s \t<- invalid start <%s>\n",
+		CTRACE(tfp, "SGML: Still open %s \t<- invalid start <%s>\n",
 			    context->element_stack->tag->name,
 			    new_tag->name);
 	    }
@@ -921,8 +890,7 @@ PRIVATE void start_element ARGS1(
 	    (context->element_stack->tag->flags & Tgf_strict) &&
 	    !(valid = element_valid_within(new_tag, context->element_stack->tag,
 					   direct_container))) {
-	    if (TRACE)
-		fprintf(stderr, "SGML: Still open %s \t<- ignoring start <%s>\n",
+	    CTRACE(tfp, "SGML: Still open %s \t<- ignoring start <%s>\n",
 			context->element_stack->tag->name,
 			new_tag->name);
 	    return;
@@ -935,8 +903,7 @@ PRIVATE void start_element ARGS1(
 	    for (; i< new_tag->number_of_attributes && !has_attributes; i++)
 		has_attributes = context->present[i];
 	    if (!has_attributes) {
-		if (TRACE)
-		    fprintf(stderr, "SGML: Still open %s, converting invalid <%s> to </%s>\n",
+		CTRACE(tfp, "SGML: Still open %s, converting invalid <%s> to </%s>\n",
 			    context->element_stack->tag->name,
 			    new_tag->name,
 			    new_tag->name);
@@ -951,8 +918,7 @@ PRIVATE void start_element ARGS1(
 						   new_tag,
 						   context->element_stack->tag,
 						   direct_container))) {
-	    if (TRACE)
-		fprintf(stderr, "SGML: Still open %s \t<- invalid start <%s>\n",
+	    CTRACE(tfp, "SGML: Still open %s \t<- invalid start <%s>\n",
 			context->element_stack->tag->name,
 			new_tag->name);
 	}
@@ -998,18 +964,14 @@ PRIVATE void start_element ARGS1(
 		**  It is another form-related start tag, so terminate
 		**  the current SELECT block and fall through. - FM
 		*/
-		if (TRACE)
-		    fprintf(stderr,
-		       "SGML: Faking SELECT end tag before <%s> start tag.\n",
+		CTRACE(tfp, "SGML: Faking SELECT end tag before <%s> start tag.\n",
 			    new_tag->name);
 		end_element(context, SGMLFindTag(context->dtd, "SELECT"));
 	    } else {
 		/*
 		**  Ignore the start tag. - FM
 		*/
-		if (TRACE)
-		    fprintf(stderr,
-			  "SGML: Ignoring start tag <%s> in SELECT block.\n",
+		CTRACE(tfp, "SGML: Ignoring start tag <%s> in SELECT block.\n",
 			    new_tag->name);
 		return;
 	    }
@@ -1018,8 +980,7 @@ PRIVATE void start_element ARGS1(
     /*
     **	Handle the start tag. - FM
     */
-    if (TRACE)
-	fprintf(stderr, "SGML: Start <%s>\n", new_tag->name);
+    CTRACE(tfp, "SGML: Start <%s>\n", new_tag->name);
     (*context->actions->start_element)(
 	context->target,
 	new_tag - context->dtd->tags,
@@ -1533,11 +1494,8 @@ top1:
 		   (uck = UCTransUniChar(unsign_c,
 					 context->outUCLYhndl)) >= 32 &&
 		   uck < 256) {
-	    if (TRACE) {
-		fprintf(stderr,
-			"UCTransUniChar returned 0x%.2lX:'%c'.\n",
+	    CTRACE(tfp, "UCTransUniChar returned 0x%.2lX:'%c'.\n",
 			uck, FROMASCII((char)uck));
-	    }
 	    /*
 	    **	We got one octet from the conversions, so use it. - FM
 	    */
@@ -1749,10 +1707,8 @@ top1:
 		*/
 		char temp[8];
 
-		if (TRACE) {
-		    fprintf(stderr,
-		"SGML_character: Handling 'zwnj' entity as 'WBR' element.\n");
-		}
+		CTRACE(tfp, "SGML_character: Handling 'zwnj' entity as 'WBR' element.\n");
+
 		if (c != ';') {
 		    sprintf(temp, "<WBR>%c", c);
 		} else {
@@ -1981,10 +1937,8 @@ top1:
 		    */
 		    char temp[8];
 
-		    if (TRACE) {
-			fprintf(stderr,
-      "SGML_character: Handling '8204' (zwnj) reference as 'WBR' element.\n");
-		    }
+		    CTRACE(tfp, "SGML_character: Handling '8204' (zwnj) reference as 'WBR' element.\n");
+
 		    /*
 		    **	Include the terminator if it is not
 		    **	the standard semi-colon. - FM
@@ -2085,7 +2039,7 @@ top1:
 			LYstrncpy(replace_buf,
 				  string->data,
 				  (string->size < 64 ? string->size : 63));
-			fprintf(stderr,
+			fprintf(tfp,
 				"SGML_character: Ignoring '%s%s'.\n",
 				(context->isHex ? "&#x" : "&#"),
 				replace_buf);
@@ -2266,9 +2220,8 @@ top1:
 	    */
 	    HTTag * t;
 	    if (c == '/') {
-		if (TRACE)
-		    if (string->size!=0)
-			fprintf(stderr,"SGML: `<%s/' found!\n", string->data);
+		if (string->size != 0)
+		    CTRACE(tfp,"SGML: `<%s/' found!\n", string->data);
 		context->state = S_end;
 		break;
 	    }
@@ -2286,21 +2239,18 @@ top1:
 		for (i = 0; i < 3; i++) /* recover */
 		    PUTC(string->data[i]);
 		PUTC(c);
-		if (TRACE)
-		    fprintf(stderr, "SGML: Treating <%s%c as text\n",
+		CTRACE(tfp, "SGML: Treating <%s%c as text\n",
 			    string->data, c);
 		string->size = 0;
 		context->state = S_text;
 		break;
 	    } else if (!t) {
-		if (TRACE)
-		    fprintf(stderr, "SGML: *** Invalid element %s\n",
+		CTRACE(tfp, "SGML: *** Invalid element %s\n",
 			    string->data);
 		context->state = (c == '>') ? S_text : S_junk_tag;
 		break;
 	    } else if (t == context->unknown_tag) {
-		if (TRACE)
-		    fprintf(stderr, "SGML: *** Unknown element %s\n",
+		CTRACE(tfp, "SGML: *** Unknown element %s\n",
 			    string->data);
 		/*
 		**  Fall through and treat like valid
@@ -2655,8 +2605,7 @@ top1:
 	if (WHITE(c))
 	    break;		/* Before attribute value */
 	if (c == '>') { 	/* End of tag */
-	    if (TRACE)
-		fprintf(stderr, "SGML: found = but no value\n");
+	    CTRACE(tfp, "SGML: found = but no value\n");
 	    if (context->current_tag->name)
 		start_element(context);
 	    context->state = S_text;
@@ -2802,8 +2751,7 @@ top1:
 		t = SGMLFindTag(dtd, string->data);
 	    }
 	    if (!t || t == context->unknown_tag) {
-		if (TRACE)
-		    fprintf(stderr, "Unknown end tag </%s>\n", string->data);
+		CTRACE(tfp, "Unknown end tag </%s>\n", string->data);
 	    } else {
 		BOOL tag_OK = (c == '>' || WHITE(c));
 		context->current_tag = t;
@@ -2831,9 +2779,7 @@ top1:
 		    **	Don't treat these end tags as invalid,
 		    **	nor act on them. - FM
 		    */
-		    if (TRACE)
-			fprintf(stderr,
-				"SGML: `</%s%c' found!  Ignoring it.\n",
+		    CTRACE(tfp, "SGML: `</%s%c' found!  Ignoring it.\n",
 				string->data, c);
 		    string->size = 0;
 		    context->current_attribute_number = INVALID;
@@ -2871,27 +2817,19 @@ top1:
 			    /*
 			    **	It is not at FORM end tag, so ignore it. - FM
 			    */
-			    if (TRACE) {
-				fprintf(stderr,
-			    "SGML: Ignoring end tag </%s> in SELECT block.\n",
+			    CTRACE(tfp, "SGML: Ignoring end tag </%s> in SELECT block.\n",
 					string->data);
-			    }
 			} else {
 			    /*
 			    **	End the SELECT block and then
 			    **	handle the FORM end tag. - FM
 			    */
-			    if (TRACE) {
-				fprintf(stderr,
-			"SGML: Faking SELECT end tag before </%s> end tag.\n",
+			    CTRACE(tfp, "SGML: Faking SELECT end tag before </%s> end tag.\n",
 					string->data);
-			    }
 			    end_element(context,
 					SGMLFindTag(context->dtd, "SELECT"));
-			    if (TRACE) {
-				fprintf(stderr,
-					"SGML: End </%s>\n", string->data);
-			    }
+			    CTRACE(tfp, "SGML: End </%s>\n", string->data);
+
 			    (*context->actions->end_element)
 				(context->target,
 				 (context->current_tag - context->dtd->tags),
@@ -2902,9 +2840,7 @@ top1:
 			**  Treat a P end tag like a P start tag (Ugh,
 			**  what a hack! 8-). - FM
 			*/
-			if (TRACE)
-			    fprintf(stderr,
-				    "SGML: `</%s%c' found!  Treating as '<%s%c'.\n",
+			CTRACE(tfp, "SGML: `</%s%c' found!  Treating as '<%s%c'.\n",
 				    string->data, c, string->data, c);
 			{
 			    int i;
@@ -2917,10 +2853,8 @@ top1:
 			if (context->current_tag->name)
 			    start_element(context);
 		    } else {
-			if (TRACE) {
-			    fprintf(stderr,
-				    "SGML: End </%s>\n", string->data);
-			}
+			CTRACE(tfp, "SGML: End </%s>\n", string->data);
+
 			(*context->actions->end_element)
 			    (context->target,
 			     (context->current_tag - context->dtd->tags),
@@ -2945,8 +2879,8 @@ top1:
 	    string->size = 0;
 	    context->current_attribute_number = INVALID;
 	    if (c != '>') {
-		if (TRACE && !WHITE(c))
-		    fprintf(stderr,"SGML: `</%s%c' found!\n", string->data, c);
+		if (!WHITE(c))
+		    CTRACE(tfp,"SGML: `</%s%c' found!\n", string->data, c);
 		context->state = S_junk_tag;
 	    } else {
 		context->state = S_text;