From 5e6d804dbd9e79a290bbb38b88f58a1158ebc195 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Sun, 9 Feb 2003 23:35:27 +0000
Subject: [PATCH] Now sends telnet DO/WILL transmit binary command before all
 file transfers. Hopefully fixes Linux telnet client upload/download problem.

---
 src/sbbs3/download.cpp | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/sbbs3/download.cpp b/src/sbbs3/download.cpp
index 5a21d6902d..1160c55122 100644
--- a/src/sbbs3/download.cpp
+++ b/src/sbbs3/download.cpp
@@ -36,6 +36,7 @@
  ****************************************************************************/
 
 #include "sbbs.h"
+#include "telnet.h"
 
 /****************************************************************************/
 /* Updates downloader, uploader and downloaded file data                    */
@@ -192,13 +193,27 @@ int sbbs_t::protocol(char *cmdline, bool cd)
 		p=NULL;
 	sprintf(msg,"Transferring %s",cmdline);
 	spymsg(msg);
-	sys_status|=SS_FILEXFER;
+	sys_status|=SS_FILEXFER;	/* disable spy during file xfer */
+	/* enable telnet binary transmission in both directions */
+	if(!(telnet_mode&TELNET_MODE_BIN_RX)) {
+		send_telnet_cmd(TELNET_DO,TELNET_BINARY);
+		telnet_mode|=TELNET_MODE_BIN_RX;
+	}
+	send_telnet_cmd(TELNET_WILL,TELNET_BINARY);
 	i=external(cmdline
 		,EX_OUTL
 #ifdef __unix__		/* file xfer progs use stdio on Unix */
 		|EX_INR|EX_OUTR|EX_BIN
 #endif
 		,p);
+	/* disable telnet binary transmission mode */
+	send_telnet_cmd(TELNET_WONT,TELNET_BINARY);
+	/* Got back to Text/NVT mode */
+	if(telnet_mode&TELNET_MODE_BIN_RX) {
+		send_telnet_cmd(TELNET_DONT,TELNET_BINARY);
+		telnet_mode&=~TELNET_MODE_BIN_RX;
+	}
+
 	sys_status&=~SS_FILEXFER;
 	if(online==ON_REMOTE)
 		rioctl(IOFB);
-- 
GitLab