Subject: Getting mail to Eudora mailboxes
To: None <current-users@NetBSD.ORG>
From: Matt Thomas <matt@3am-software.com>
List: current-users
Date: 09/02/1997 13:29:16
Eudora is a Windows based mail readers which is widely used.  It uses
Berkeley type mail files to store its mail.  However since it's
windows-based the lines end with <CRLF> instead of just <LF>.
So to get mail(1) to read Eudora folders, you first have run them
through vi or sed or whatever.

Attached is a small patch to mail(1) which allows mail to directly
read Eudora folders off a DOS partition.

Would anyone complain bitterly if I committed it?

-- 
Matt Thomas              Internet:   matt@3am-software.com
3am Software Foundry     WWW URL:    http://www.3am-software.com/bio/matt.html
Nashua, NH               Disclaimer: I disavow all knowledge of this message

Index: fio.c
===================================================================
RCS file: /cvsroot/src/usr.bin/mail/fio.c,v
retrieving revision 1.8
diff -u -r1.8 fio.c
--- fio.c	1997/07/07 22:57:55	1.8
+++ fio.c	1997/09/02 17:25:52
@@ -114,6 +114,15 @@
 			return;
 		}
 		count = strlen(linebuf);
+		/*
+		 * Transforms lines ending in <CR><LF> to just <LF>.  This allows
+		 * mail to be able to read Eudora mailboxes that reside on a DOS
+		 * partition.
+		 */
+		if (count >= 2 && linebuf[count-1] == '\n' && linebuf[count - 2] == '\r') {
+			linebuf[count-2] = linebuf[count-1];
+			count--;
+		}
 		(void) fwrite(linebuf, sizeof *linebuf, count, otf);
 		if (ferror(otf)) {
 			perror("/tmp");
@@ -187,7 +196,7 @@
 /*
  * Read up a line from the specified input into the line
  * buffer.  Return the number of characters read.  Do not
- * include the newline at the end.
+ * include the newline (or carriage return) at the end.
  */
 int
 readline(ibuf, linebuf, linesize)
@@ -202,6 +211,8 @@
 		return -1;
 	n = strlen(linebuf);
 	if (n > 0 && linebuf[n - 1] == '\n')
+		linebuf[--n] = '\0';
+	if (n > 0 && linebuf[n - 1] == '\r')
 		linebuf[--n] = '\0';
 	return n;
 }