about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTFTP.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1998-11-10 19:47:00 -0500
committerThomas E. Dickey <dickey@invisible-island.net>1998-11-10 19:47:00 -0500
commitd3f9d5478df478427c2aa5db4507ddd0a38f0eb6 (patch)
treee27eacd6bbda653dd77f11cc020b9e0a59f7f4fc /WWW/Library/Implementation/HTFTP.c
parent18024037b515bfff83e0230b35151babe6005e18 (diff)
downloadlynx-snapshots-d3f9d5478df478427c2aa5db4507ddd0a38f0eb6.tar.gz
snapshot of project "lynx", label v2-8-2dev_2
Diffstat (limited to 'WWW/Library/Implementation/HTFTP.c')
-rw-r--r--WWW/Library/Implementation/HTFTP.c463
1 files changed, 170 insertions, 293 deletions
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index 48d0aa36..5b405b5b 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -76,7 +76,6 @@ BUGS:	@@@	Limit connection cache size!
 #endif
 
 #include <HTUtils.h>
-#include <tcp.h>
 
 #include <HTAlert.h>
 
@@ -110,6 +109,8 @@ BUGS:	@@@	Limit connection cache size!
 #define IPPORT_FTP	21
 #endif /* !IPORT_FTP */
 
+#include <LYUtils.h>
+#include <LYStrings.h>
 #include <LYLeaks.h>
 
 typedef struct _connection {
@@ -138,15 +139,10 @@ struct _HTStructured {
 	/* ... */
 };
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
-extern int HTCheckForInterrupt NOPARAMS;
-
-
 /*	Global Variables
 **	---------------------
 */
-PUBLIC BOOLEAN HTfileSortMethod = FILE_BY_NAME;
+PUBLIC int HTfileSortMethod = FILE_BY_NAME;
 PRIVATE char ThisYear[8];
 PRIVATE char LastYear[8];
 PRIVATE int TheDate;
@@ -264,14 +260,15 @@ PUBLIC char * HTMake_VMS_name ARGS2(
     strcpy(nodename, "");	/* On same node? Yes if node names match */
     if (strncmp(nn, "localhost", 9)) {
 	CONST char *p;
-	char *q;
-	for (p = hostname, q = (char *)nn;
+	CONST char *q;
+	for (p = hostname, q = nn;
 	     *p && *p != '.' && *q && *q != '.'; p++, q++){
 	    if (TOUPPER(*p) != TOUPPER(*q)) {
+		char *r;
 		strcpy(nodename, nn);
-		q = strchr(nodename, '.');	/* Mismatch */
-		if (q)
-		    *q = '\0';			/* Chop domain */
+		r = strchr(nodename, '.');	/* Mismatch */
+		if (r)
+		    *r = '\0';			/* Chop domain */
 		strcat(nodename, "::"); 	/* Try decnet anyway */
 		break;
 	    }
@@ -338,7 +335,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 +372,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 +413,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 +429,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 +444,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 +472,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 +491,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 +547,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 +556,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) ||
@@ -699,7 +677,7 @@ PRIVATE int get_connection ARGS2(
 		    !user_entered_password) {
 
 		    StrAllocCopy(last_username_and_host, tmp);
-		    sprintf(tmp, "Enter password for user %s@%s:",
+		    sprintf(tmp, gettext("Enter password for user %s@%s:"),
 				  username, p1);
 		    FREE(user_entered_password);
 		    user_entered_password = (char *)HTPromptPassword(tmp);
@@ -713,42 +691,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 (gettext("Connection interrupted."));
+	    status = HT_NOT_LOADED;
+	} else {
+	    HTAlert(gettext("Unable to connect to FTP host."));
 	}
-      if (status == HT_INTERRUPTED) {
-	_HTProgress ("Connection interrupted.");
-	status = HT_NOT_LOADED;
-      } else {
-	HTAlert("Unable to connect to FTP host.");
-      }
-      if (con->socket != -1)
+	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,20 +731,18 @@ 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");
-	_HTProgress ("Connection interrupted.");
+    if (status == HT_INTERRUPTED) {
+	CTRACE (tfp, "HTFTP: Interrupted at beginning of login.\n");
+	_HTProgress (gettext("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 */
 
+	/* don't gettext() this -- incoming text: */
 	if (strlen(response_text) > 4) {
 	    if ((cp = strstr(response_text, " awaits your command")) ||
 		(cp = strstr(response_text, " ready."))) {
@@ -800,16 +769,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");
-	    _HTProgress ("Connection interrupted.");
+	if (status == HT_INTERRUPTED) {
+	    CTRACE (tfp, "HTFTP: Interrupted while sending username.\n");
+	    _HTProgress (gettext("Connection interrupted."));
 	    NETCLOSE(control->socket);
 	    control->socket = -1;
 	    return HT_INTERRUPTED;
-	  }
+	}
     }
     if (status == 3) {		/* Send password */
 	if (password) {
@@ -866,16 +832,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.");
+	    _HTProgress (gettext("Connection interrupted."));
 	    NETCLOSE(control->socket);
 	    control->socket = -1;
 	    return HT_INTERRUPTED;
-	  }
+	}
     }
     FREE(username);
 
@@ -883,25 +847,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");
-	    _HTProgress ("Connection interrupted.");
+	if (status == HT_INTERRUPTED) {
+	    CTRACE (tfp, "HTFTP: Interrupted while sending password.\n");
+	    _HTProgress (gettext("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 +873,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 +956,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 */
@@ -1031,13 +973,14 @@ PRIVATE int get_connection ARGS2(
 PRIVATE int close_master_socket NOARGS
 {
     int status;
-    FD_CLR(master_socket, &open_sockets);
+
+    if (master_socket != -1)
+	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");
+	return HTInetStatus(gettext("close master socket"));
     else
 	return status;
 }
@@ -1077,10 +1020,9 @@ PRIVATE int get_listen_socket NOARGS
     new_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
 
     if (new_socket < 0)
-	return HTInetStatus("socket for master socket");
+	return HTInetStatus(gettext("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 */
     }
@@ -1461,7 +1401,8 @@ PRIVATE void parse_vms_dir_entry ARGS2(
 	char *, 	line,
 	EntryInfo *,	entry_info)
 {
-    int i, j, ialloc;
+    int i, j;
+    unsigned int ialloc;
     char *cp, *cpd, *cps, date[16], *sp = " ";
 
     /**  Get rid of blank lines, and information lines.  **/
@@ -1477,8 +1418,8 @@ PRIVATE void parse_vms_dir_entry ARGS2(
 
     /** Cast VMS non-README file and directory names to lowercase. **/
     if (strstr(entry_info->filename, "READ") == NULL) {
-	for (i = 0; entry_info->filename[i]; i++)
-	    entry_info->filename[i] = TOLOWER(entry_info->filename[i]);
+	LYLowerCase(entry_info->filename);
+	i = strlen(entry_info->filename);
     } else {
 	i = ((strstr(entry_info->filename, "READ") - entry_info->filename) + 4);
 	if (!strncmp((char *)&entry_info->filename[i], "ME", 2)) {
@@ -1491,8 +1432,7 @@ PRIVATE void parse_vms_dir_entry ARGS2(
 	} else {
 	    i = 0;
 	}
-	for (; entry_info->filename[i]; i++)
-	    entry_info->filename[i] = TOLOWER(entry_info->filename[i]);
+	LYLowerCase(entry_info->filename + i);
     }
 
     /** Uppercase terminal .z's or _z's. **/
@@ -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() */
 
@@ -1614,28 +1553,22 @@ PRIVATE void parse_ms_windows_dir_entry ARGS2(
     char *end = line + strlen(line);
 
     /**  Get rid of blank or junk lines.  **/
-    while (*cp && isspace(*cp))
-	cp++;
+    cp = LYSkipBlanks(cp);
     if (!(*cp)) {
 	entry_info->display = FALSE;
 	return;
     }
 
     /** Cut out file or directory name. **/
-    cps = cp;
-    while (*cps && !isspace(*cps))
-	cps++;
+    cps = LYSkipNonBlanks(cp);
     *cps++ ='\0';
     cpd = cps;
     StrAllocCopy(entry_info->filename, cp);
 
     /** Track down the size **/
     if (cps < end) {
-	while (*cps && isspace(*cps))
-	    cps++;
-	cpd = cps;
-	while (*cpd && !isspace(*cpd))
-	    cpd++;
+	cps = LYSkipBlanks(cps);
+	cpd = LYSkipNonBlanks(cps);
 	*cpd++ = '\0';
 	if (isdigit(*cps)) {
 	    entry_info->size = atoi(cps);
@@ -1653,8 +1586,7 @@ PRIVATE void parse_ms_windows_dir_entry ARGS2(
 
     /** Track down the date. **/
     if (cpd < end) {
-	while (*cpd && isspace(*cpd))
-	    cpd++;
+	cpd = LYSkipBlanks(cpd);
 	if (strlen(cpd) > 17) {
 	    *(cpd+6)  = '\0';  /* Month and Day */
 	    *(cpd+11) = '\0';  /* Year */
@@ -1673,11 +1605,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 */
 
@@ -1697,8 +1628,7 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2(
     int i;
 
     /**  Get rid of blank or junk lines.  **/
-    while (*cp && isspace(*cp))
-	cp++;
+    cp = LYSkipBlanks(cp);
     if (!(*cp)) {
 	entry_info->display = FALSE;
 	return;
@@ -1706,9 +1636,7 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2(
 
     /** Cut out file or directory name. **/
     cpd = cp;
-    cps = (end-1);
-    while (cps >= cpd && !isspace(*cps))
-	cps--;
+    cps = LYSkipNonBlanks(end-1);
     cp = (cps+1);
     if (!strcmp(cp, ".") || !strcmp(cp, "..")) {
 	entry_info->display = FALSE;
@@ -1727,18 +1655,14 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2(
 
     /** Cut out the date. **/
     cp = cps = cpd;
-    while (*cps && !isspace(*cps))
-	cps++;
+    cps = LYSkipNonBlanks(cps);
     *cps++ ='\0';
     if (cps > end) {
 	entry_info->display = FALSE;
 	return;
     }
-    while (*cps && isspace(*cps))
-	cps++;
-    cpd = cps;
-    while (*cps && !isspace(*cps))
-	cps++;
+    cps = LYSkipBlanks(cps);
+    cpd = LYSkipNonBlanks(cps);
     *cps++ ='\0';
     if (cps > end || cpd == cps || strlen(cpd) < 7) {
 	entry_info->display = FALSE;
@@ -1779,11 +1703,8 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2(
 
     /** Track down the size **/
     if (cps < end) {
-	while (*cps && isspace(*cps))
-	    cps++;
-	cpd = cps;
-	while (*cpd && !isspace(*cpd))
-	    cpd++;
+	cps = LYSkipBlanks(cps);
+	cpd = LYSkipNonBlanks(cps);
 	*cpd = '\0';
 	if (isdigit(*cps)) {
 	    entry_info->size = atoi(cps);
@@ -1795,11 +1716,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 */
@@ -1821,25 +1741,20 @@ PRIVATE void parse_cms_dir_entry ARGS2(
     int i;
 
     /**  Get rid of blank or junk lines.  **/
-    while (*cp && isspace(*cp))
-	cp++;
+    cp = LYSkipBlanks(cp);
     if (!(*cp)) {
 	entry_info->display = FALSE;
 	return;
     }
 
     /** Cut out file or directory name. **/
-    cps = cp;
-    while (*cps && !isspace(*cps))
-	cps++;
+    cps = LYSkipNonBlanks(cp);
     *cps++ ='\0';
     StrAllocCopy(entry_info->filename, cp);
     if (strchr(entry_info->filename, '.') != NULL)
 	/** If we already have a dot, we did an NLST. **/
 	return;
-    cp = cps;
-    while (*cp && isspace(*cp))
-	cp++;
+    cp = LYSkipBlanks(cps);
     if (!(*cp)) {
 	/** If we don't have more, we've misparsed. **/
 	FREE(entry_info->filename);
@@ -1847,9 +1762,7 @@ PRIVATE void parse_cms_dir_entry ARGS2(
 	entry_info->display = FALSE;
 	return;
     }
-    cps = cp;
-    while (*cps && !isspace(*cps))
-	cps++;
+    cps = LYSkipNonBlanks(cp);
     *cps++ ='\0';
     if ((0 == strcasecomp(cp, "DIR")) && (cp - line) > 17) {
 	/** It's an SFS directory. **/
@@ -1864,11 +1777,8 @@ PRIVATE void parse_cms_dir_entry ARGS2(
 	/** Track down the VM/CMS RECFM or type. **/
 	cp = cps;
 	if (cp < end) {
-	    while (*cp && isspace(*cp))
-		cp++;
-	    cps = cp;
-	    while (*cps && !isspace(*cps))
-		cps++;
+	    cp = LYSkipBlanks(cp);
+	    cps = LYSkipNonBlanks(cp);
 	    *cps++ = '\0';
 	    /** Check cp here, if it's relevant someday. **/
 	}
@@ -1877,11 +1787,8 @@ PRIVATE void parse_cms_dir_entry ARGS2(
     /** Track down the record length or dash. **/
     cp = cps;
     if (cp < end) {
-	while (*cp && isspace(*cp))
-	    cp++;
-	cps = cp;
-	while (*cps && !isspace(*cps))
-	    cps++;
+	cp = LYSkipBlanks(cp);
+	cps = LYSkipNonBlanks(cp);
 	*cps++ = '\0';
 	if (isdigit(*cp)) {
 	    RecordLength = atoi(cp);
@@ -1891,11 +1798,8 @@ PRIVATE void parse_cms_dir_entry ARGS2(
     /** Track down the number of records or the dash. **/
     cp = cps;
     if (cps < end) {
-	while (*cp && isspace(*cp))
-	    cp++;
-	cps = cp;
-	while (*cps && !isspace(*cps))
-	    cps++;
+	cp = LYSkipBlanks(cp);
+	cps = LYSkipNonBlanks(cp);
 	*cps++ = '\0';
 	if (isdigit(*cp)) {
 	    Records = atoi(cp);
@@ -1954,11 +1858,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 */
 
@@ -2008,6 +1911,7 @@ PRIVATE EntryInfo * parse_dir_entry ARGS2(
 	    */
 	    len = strlen(entry);
 	    if (*first) {
+		/* don't gettext() this -- incoming text: */
 		if (!strcmp(entry, "can not access directory .")) {
 		    /*
 		     *	Don't reset *first, nothing real will follow. - KW
@@ -2192,7 +2096,6 @@ PRIVATE EntryInfo * parse_dir_entry ARGS2(
 	    */
 	    StrAllocCopy(entry_info->filename, entry);
 	    return(entry_info); /* mostly empty info */
-	    break; /* not needed */
 
     } /* switch (server_type) */
 
@@ -2259,7 +2162,6 @@ PRIVATE int compare_EntryInfo_structs ARGS2(
 		    return(1);
 		else
 		    return(-1);
-	    break;
 
 	case FILE_BY_TYPE:
 	    if (entry1->type && entry2->type) {
@@ -2269,7 +2171,6 @@ PRIVATE int compare_EntryInfo_structs ARGS2(
 		/* else fall to filename comparison */
 	    }
 	    return (strcmp(entry1->filename, entry2->filename));
-	    break;
 
 	case FILE_BY_DATE:
 	    if (entry1->date && entry2->date) {
@@ -2361,7 +2262,6 @@ PRIVATE int compare_EntryInfo_structs ARGS2(
 		/* else fall to filename comparison */
 	    }
 	    return (strcmp(entry1->filename, entry2->filename));
-	    break;
 
 	case FILE_BY_NAME:
 	default:
@@ -2400,7 +2300,7 @@ PRIVATE int read_directory ARGS4(
 
     targetClass = *(target->isa);
 
-    _HTProgress ("Receiving FTP directory.");
+    _HTProgress (gettext("Receiving FTP directory."));
 
     /*
     **	Check whether we always want the home
@@ -2523,7 +2423,7 @@ AgainForMultiNet:
 
 	    BytesReceived += chunk->size;
 	    if (BytesReceived > BytesReported + 1024) {
-		sprintf(NumBytes,"Transferred %d bytes",BytesReceived);
+		sprintf(NumBytes,gettext("Transferred %d bytes"),BytesReceived);
 		HTProgress(NumBytes);
 		BytesReported = BytesReceived;
 	    }
@@ -2531,15 +2431,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);
@@ -2633,7 +2531,7 @@ unload_btree:
     if (WasInterrupted || HTCheckForInterrupt()) {
 	if (server_type != CMS_SERVER)
 	    response(NIL);
-	_HTProgress("Data transfer interrupted.");
+	_HTProgress(gettext("Data transfer interrupted."));
 	return HT_LOADED;
     }
     if (server_type != CMS_SERVER)
@@ -2695,22 +2593,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 (gettext("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 +2633,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:
@@ -2754,13 +2648,12 @@ PUBLIC int HTFTPLoad ARGS4(
 	    status = HTDoConnect(name, "FTP", passive_port, &data_soc);
 
 	    if (status < 0) {
-		(void) HTInetStatus("connect for data");
+		(void) HTInetStatus(gettext("connect for data"));
 		NETCLOSE(data_soc);
 		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 +2680,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 +2715,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 +2838,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 +2848,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 +2897,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);
@@ -3349,18 +3227,17 @@ listen:
 	}
 	FREE(FileName);
 
-	_HTProgress ("Receiving FTP file.");
+	_HTProgress (gettext("Receiving FTP file."));
 	rv = HTParseSocket(format, format_out, anchor, data_soc, sink);
 
 	if (rv == HT_INTERRUPTED)
-	     _HTProgress("Data transfer interrupted.");
+	     _HTProgress(gettext("Data transfer interrupted."));
 
 	HTInitInput(control->socket);
 	/* 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 */