From 3a1923d81615d14bd183da2973cb565a78b6520a Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Tue, 19 Mar 2019 19:34:26 +0000
Subject: [PATCH] Export/import the original message editor column width (when
 known) as a new FidoNet "Kludge line" (control line): "\1COLS: <columns>\r"
 where <columns> is a value between 0 and 255 and a value of 0 is special,
 meaning "unknown" and not normally specified (this is the default assumption
 when there is no "columns"/COLS header field). When a message editor column
 width is unknown, is is normally assumed to have been 80 columns for
 word-wrapping/re-wrapping purposes when displaying the message text.

This feature has worked well for Synchronet's QWK networking (i.e. there are
far fewer instances of word-wrapping/re-wrapping issues when viewing messages
on DOVE-Net), so I decided to support this message header field over FTN
(SBBSecho) as well. Hopefully other FidoNet software authors will notice and
support this header field in the future as there are still numerous examples
of word-wrap issues when viewing FidoNet messages. At least Synchronet <->
Synchronet systems over FidoNet should be able to re-wrap and display all
message text nicely when both ends support this kludge line.

Incremented SBBSecho version number to 3.07.
---
 src/sbbs3/sbbsecho.c | 9 +++++++++
 src/sbbs3/sbbsecho.h | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/sbbs3/sbbsecho.c b/src/sbbs3/sbbsecho.c
index 84d40532d3..d013bca802 100644
--- a/src/sbbs3/sbbsecho.c
+++ b/src/sbbs3/sbbsecho.c
@@ -1213,6 +1213,8 @@ int create_netmail(const char *to, const smbmsg_t* msg, const char *subject, con
 	if(hdr.origpoint)
 		fprintf(fp,"\1FMPT %hu\r",hdr.origpoint);
 	fprintf(fp,"\1PID: %s\r", (msg==NULL || msg->ftn_pid==NULL) ? sbbsecho_pid() : msg->ftn_pid);
+	if(msg->columns)
+		fprintf(fp,"\1COLS: %u\r", (unsigned int)msg->columns);
 	if(msg != NULL) {
 		/* Unknown kludge lines are added here */
 		for(int i=0; i<msg->total_hfields; i++)
@@ -3472,6 +3474,13 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
 				msg.hdr.when_written.zone = fmsgzone(fbuf+l);
 			}
 
+			else if(!strncmp((char *)fbuf+l+1,"COLS:", 5)) {	/* SBBSecho */
+				l+=5;
+				while(l<length && fbuf[l] <= ' ' && fbuf[l] >= 0) l++;
+				uint8_t columns = atoi(fbuf + l);
+				smb_hfield_bin(&msg, SMB_COLUMNS, columns);
+			}
+
 			else {		/* Unknown kludge line */
 				while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 				m=l;
diff --git a/src/sbbs3/sbbsecho.h b/src/sbbs3/sbbsecho.h
index ae80e89544..34c795db7e 100644
--- a/src/sbbs3/sbbsecho.h
+++ b/src/sbbs3/sbbsecho.h
@@ -42,7 +42,7 @@
 #include "fidodefs.h"
 
 #define SBBSECHO_VERSION_MAJOR		3
-#define SBBSECHO_VERSION_MINOR		6
+#define SBBSECHO_VERSION_MINOR		7
 
 #define SBBSECHO_PRODUCT_CODE		0x12FF	/* from http://ftsc.org/docs/ftscprod.013 */
 
-- 
GitLab