From: syd@dsinc.DSI.COM (Syd Weinstein)
Subject: elm 2.4 Patch #8
Followup-To: poster
Summary: This is an official patch for elm 2.4 system.  Please apply it.
Priority: HIGH
Organization: Datacomp Systems, Inc., Huntingdon Valley, PA 19006
Date: Tue, 10 Nov 1992 20:23:48 GMT

This is part 2 of a 2 part patch

Fix:	From rn, say "| patch -p -N -d DIR", where DIR is your elm source
	directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
	If you don't have the patch program, apply the following by hand,
	or get patch (version 2.0, latest patchlevel).

	After patching:
		sh lib/Makefile.SH
		sh doc/Makefile.SH
		make
		make install

	If patch indicates that patchlevel is the wrong version, you may need
	to apply one or more previous patches, or the patch may already
	have been applied.  See the patchlevel.h file to find out what has or
	has not been applied.  In any event, don't continue with the patch.

	If you are missing previous patches they can be obtained from our:
	archive server.

	Syd Weinstein
	elm@DSI.COM

	The patches are available from the dsinc archive server
	Send the following message to archive-server@DSI.COM for
	a list of available patches:

	Subject: patch list
	send index elm

Index: hdrs/patchlevel.h
Prereq: "7"
*** ../elm2.4/hdrs/patchlevel.h	Mon Nov  2 15:51:37 1992
--- hdrs/patchlevel.h	Sat Nov  7 15:29:38 1992
***************
*** 1 ****
! #define PATCHLEVEL "7"
--- 1 ----
! #define PATCHLEVEL "8"

Index: src/mime.c
Prereq: 5.4
*** ../elm2.4/src/mime.c	Mon Nov  2 15:51:48 1992
--- src/mime.c	Sat Nov  7 11:21:58 1992
***************
*** 1,5 ****
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,5 ----
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.5 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 11,16 ****
--- 11,20 ----
   *
   ******************************************************************************
   * $Log: mime.c,v $
+  * Revision 5.5  1992/11/07  16:21:56  syd
+  * There is no need to write out the MIME-Version header in subparts
+  * From: Klaus Steinberger <Klaus.Steinberger@Physik.Uni-Muenchen.DE>
+  *
   * Revision 5.4  1992/10/30  21:10:39  syd
   * it invokes metamail (the pseudo is because "text" isn't a legal Content-Type).
   * in src/mime.c notplain() tries to check for text but fails because it should
***************
*** 174,180 ****
  	sleep(2);
  	return(-1);
      }
-     fprintf(dest, "%s\n", MIME_HEADER);
      fprintf(dest, "%s %s\n", MIME_CONTENTTYPE, Content_Type);
      fprintf(dest, "Content-Name: %s\n", Include_Filename);
      fprintf(dest, "Content-Length: %d\n", file_status.st_size);
--- 178,183 ----

Index: src/newmbox.c
Prereq: 5.4
*** ../elm2.4/src/newmbox.c	Mon Nov  2 15:51:49 1992
--- src/newmbox.c	Sat Nov  7 15:06:13 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: newmbox.c,v 5.4 1992/10/31 18:52:51 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: newmbox.c,v 5.6 1992/11/07 20:05:52 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.6 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,27 ----
   *
   *******************************************************************************
   * $Log: newmbox.c,v $
+  * Revision 5.6  1992/11/07  20:05:52  syd
+  * change to use header_cmp to allow for linear white space around the colon
+  * From: Syd
+  *
+  * Revision 5.5  1992/11/07  16:08:52  syd
+  * add tolerance for incorrect content length line
+  * From: Syd
+  *
   * Revision 5.4  1992/10/31  18:52:51  syd
   * Corrections to Unix date parsing and time zone storage
   * From: eotto@hvlpa.att.com
***************
*** 252,262 ****
  	struct header_rec *current_header = NULL;
  	char buffer[LONG_STRING], tbuffer[LONG_STRING], *c;
  	long fbytes = 0L, line_bytes = 0L, content_start = 0L,
! 	  content_remaining = -1L;
! 	register int line = 0, count = 0, another_count,
  	  subj = 0, copyit = 0, in_header = FALSE;
  	int count_x, count_y = 17, err;
! 	int in_to_list = FALSE, forwarding_mail = FALSE, first_line = TRUE;
  
  	static int first_read = 0;
  #ifdef MMDF
--- 260,272 ----
  	struct header_rec *current_header = NULL;
  	char buffer[LONG_STRING], tbuffer[LONG_STRING], *c;
  	long fbytes = 0L, line_bytes = 0L, content_start = 0L,
! 	  content_remaining = -1L, lines_start = 0L;
! 	register long line = 0;
! 	register int count = 0, another_count,
  	  subj = 0, copyit = 0, in_header = FALSE;
  	int count_x, count_y = 17, err;
! 	int in_to_list = FALSE, forwarding_mail = FALSE, first_line = TRUE,
! 	  content_length_found = FALSE;
  
  	static int first_read = 0;
  #ifdef MMDF
***************
*** 465,472 ****
  
  	      if (real_from(buffer, headers[count])) {
  
! 	        dprint(1, (debugfile, "content_remaining = %ld, content_start = %ld, fbytes = %ld\n",
! 			content_remaining, content_start, fbytes));
  
  		current_header = headers[count];
  
--- 475,482 ----
  
  	      if (real_from(buffer, headers[count])) {
  
! 	        dprint(1, (debugfile, "content_remaining = %ld, content_start = %ld, lines_start = %ld, fbytes = %ld\n",
! 			content_remaining, content_start, lines_start, fbytes));
  
  		current_header = headers[count];
  
***************
*** 473,478 ****
--- 483,489 ----
  		current_header->offset = (long) fbytes;
  		current_header->content_length = -1; /* not found yet */
  		current_header->index_number = count+1;
+ 		content_length_found = FALSE;
  		/* set default status - always 'visible'  - and
  		 * if a spool file, presume 'new', otherwise
  		 * 'read', for the time being until overridden
***************
*** 579,584 ****
--- 590,618 ----
  	      dprint(1, (debugfile, "Line is;\n\t%s\n\n", buffer));
  	      mail_only++;	/* to avoid leave() cursor motion */
  	      leave();
+ 	    } else if (in_header == FALSE && content_length_found == TRUE && line_bytes > 1) {
+ 		/* invalid content length, skip back to beginning of
+ 		 * this messages text and ignore the content length
+ 		 * field.  This requires restoring the current position
+ 		 * in the spool file and the number of lines in the
+ 		 * message.
+ 		 */
+ 	      if (fseek(mailfile, content_start, 0) == -1) {
+ 		err = errno;
+ 		Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmCouldntSeekBytesIntoFolder,
+ 		   "\n\rCouldn't seek %ld bytes into folder.\n\r"),
+ 		   1, mailfile_size);	
+ 		Write_to_screen("** %s. **\n\r", 1, error_description(err));
+ 		dprint(1, (debugfile,
+       "Error: Couldn't seek folder %s: (offset %ld) Errno %s (%s)\n",
+ 		   cur_folder, mailfile_size, error_description(err), "reset - read_headers"));
+ 		emergency_exit();
+ 	      }
+ 	      fbytes = content_start;
+ 	      line = lines_start;
+ 	      content_length_found = FALSE;
+ 	      current_header->content_length = -1; /* mark as if not found yet */
+ 	      line_bytes = 0;
  	    }
  	  }
  
***************
*** 596,608 ****
  	      real_from(buffer, current_header);
  	    else
  #endif /* MMDF */
! 	    if (first_word_nc(buffer,">From:"))
  	      parse_arpa_who(buffer, current_header->from, FALSE);
  	    else if (first_word_nc(buffer,">From")) 
  	      forwarded(buffer, current_header); /* return address */
! 	    else if (first_word_nc(buffer,"Subject:") ||
! 		     first_word_nc(buffer,"Subj:") ||
! 		     first_word_nc(buffer,"Re:")) {
  	      if (! subj++) {
  		strncpy(tbuffer, buffer, sizeof(tbuffer));
  	        remove_header_keyword(tbuffer);
--- 630,642 ----
  	      real_from(buffer, current_header);
  	    else
  #endif /* MMDF */
! 	    if (header_cmp(buffer,">From", NULL))
  	      parse_arpa_who(buffer, current_header->from, FALSE);
  	    else if (first_word_nc(buffer,">From")) 
  	      forwarded(buffer, current_header); /* return address */
! 	    else if (header_cmp(buffer,"Subject", NULL) ||
! 		     header_cmp(buffer,"Subj", NULL) ||
! 		     header_cmp(buffer,"Re", NULL)) {
  	      if (! subj++) {
  		strncpy(tbuffer, buffer, sizeof(tbuffer));
  	        remove_header_keyword(tbuffer);
***************
*** 610,616 ****
  		remove_possible_trailing_spaces(current_header->subject);
  	      }
  	    }
! 	    else if (first_word_nc(buffer,"From:")) {
  	      dprint(1, (debugfile, 
  		   "\n\n**** Calling parse_arpa_who for from ****\n\n"));
  #ifdef MMDF
--- 644,650 ----
  		remove_possible_trailing_spaces(current_header->subject);
  	      }
  	    }
! 	    else if (header_cmp(buffer,"From", NULL)) {
  	      dprint(1, (debugfile, 
  		   "\n\n**** Calling parse_arpa_who for from ****\n\n"));
  #ifdef MMDF
***************
*** 620,643 ****
  #endif /* MMDF */
  
  	    }
! 	    else if (first_word_nc(buffer, "Message-Id:")) {
  	      buffer[line_bytes - 1] = '\0';
  	      strcpy(current_header->messageid,
  		     (char *) buffer + 12);
  	    }
  
! 	    else if (first_word_nc(buffer, "Content-Length:")) {
  	      buffer[line_bytes - 1] = '\0';
  	      current_header->content_length = atol((char *) buffer + 15);
  	    }
  
! 	    else if (first_word_nc(buffer, "Expires:"))
  	      process_expiration_date((char *) buffer + 9, 
  				      &(current_header->status));
  	    
  	    /** when it was sent... **/
  
! 	    else if (first_word_nc(buffer, "Date:")) {
  	      dprint(1, (debugfile, 
  			   "\n\n**** Calling parse_arpa_date ****\n\n"));
  	      strncpy(tbuffer, buffer, sizeof(tbuffer));
--- 654,678 ----
  #endif /* MMDF */
  
  	    }
! 	    else if (header_cmp(buffer, "Message-Id", NULL)) {
  	      buffer[line_bytes - 1] = '\0';
  	      strcpy(current_header->messageid,
  		     (char *) buffer + 12);
  	    }
  
! 	    else if (header_cmp(buffer, "Content-Length", NULL)) {
  	      buffer[line_bytes - 1] = '\0';
  	      current_header->content_length = atol((char *) buffer + 15);
+ 	      content_length_found = TRUE;
  	    }
  
! 	    else if (header_cmp(buffer, "Expires", NULL))
  	      process_expiration_date((char *) buffer + 9, 
  				      &(current_header->status));
  	    
  	    /** when it was sent... **/
  
! 	    else if (header_cmp(buffer, "Date", NULL)) {
  	      dprint(1, (debugfile, 
  			   "\n\n**** Calling parse_arpa_date ****\n\n"));
  	      strncpy(tbuffer, buffer, sizeof(tbuffer));
***************
*** 647,677 ****
  
  	    /** some status things about the message... **/
  
! 	    else if ((first_word_nc(buffer, "Priority:") ||
! 		     first_word_nc(buffer, "Importance: 2")) &&
! 		   !(first_word_nc(buffer, "priority: normal") ||
! 		     first_word_nc(buffer, "priority: non-urgent")))
  	      current_header->status |= URGENT;
! 	    else if (first_word_nc(buffer, "Sensitivity: 2"))
  	      current_header->status |= PRIVATE;
! 	    else if (first_word_nc(buffer, "Sensitivity: 3"))
  	      current_header->status |= CONFIDENTIAL;
! 	    else if (first_word_nc(buffer, "Content-Type: mailform"))
  	      current_header->status |= FORM_LETTER;
! 	    else if (first_word_nc(buffer, "Action:"))
  	      current_header->status |= ACTION;
  #ifdef	MIME
! 	    else if (first_word_nc(buffer, MIME_HEADER))
  	      current_header->status |= MIME_MESSAGE;
  	    /* Next two lines for backward compatability to old drafts */
! 	    else if (first_word_nc(buffer, MIME_OLDVERSION))
  	      current_header->status |= MIME_MESSAGE;
! 	    else if (first_word_nc(buffer, MIME_CONTENTTYPE) &&
  		(current_header->status & MIME_MESSAGE)) {
  	      if (notplain(buffer+strlen(MIME_CONTENTTYPE)))
  		current_header->status |= MIME_NOTPLAIN;
  	    }
! 	    else if (first_word_nc(buffer, MIME_CONTENTENCOD)) {
  	      if (needs_mmdecode(buffer+strlen(MIME_CONTENTENCOD)))
  		current_header->status |= MIME_NEEDDECOD;
  	    }
--- 682,712 ----
  
  	    /** some status things about the message... **/
  
! 	    else if ((header_cmp(buffer, "Priority", NULL) ||
! 		     header_cmp(buffer, "Importance", "2")) &&
! 		   !(header_cmp(buffer, "priority", "normal") ||
! 		     header_cmp(buffer, "priority", "non-urgent")))
  	      current_header->status |= URGENT;
! 	    else if (header_cmp(buffer, "Sensitivity", "2"))
  	      current_header->status |= PRIVATE;
! 	    else if (header_cmp(buffer, "Sensitivity", "3"))
  	      current_header->status |= CONFIDENTIAL;
! 	    else if (header_cmp(buffer, "Content-Type", "mailform"))
  	      current_header->status |= FORM_LETTER;
! 	    else if (header_cmp(buffer, "Action", NULL))
  	      current_header->status |= ACTION;
  #ifdef	MIME
! 	    else if (header_cmp(buffer, MIME_HEADER_NAME, MIME_HEADER_VERSION))
  	      current_header->status |= MIME_MESSAGE;
  	    /* Next two lines for backward compatability to old drafts */
! 	    else if (header_cmp(buffer, MIME_HEADER_NAME, MIME_HEADER_OLDVERSION))
  	      current_header->status |= MIME_MESSAGE;
! 	    else if (header_cmp(buffer, MIME_HEADER_CONTENTTYPE, NULL) &&
  		(current_header->status & MIME_MESSAGE)) {
  	      if (notplain(buffer+strlen(MIME_CONTENTTYPE)))
  		current_header->status |= MIME_NOTPLAIN;
  	    }
! 	    else if (header_cmp(buffer, MIME_HEADER_CONTENTENCOD, NULL)) {
  	      if (needs_mmdecode(buffer+strlen(MIME_CONTENTENCOD)))
  		current_header->status |= MIME_NEEDDECOD;
  	    }
***************
*** 679,691 ****
  
  	    /** next let's see if it's to us or not... **/
  
! 	    else if (first_word_nc(buffer, "To:")) {
  	      in_to_list = TRUE;
  	      current_header->to[0] = '\0';	/* nothing yet */
  	      figure_out_addressee((char *) buffer +3, 
  				   current_header->to);
  	    }
! 	    else if (first_word_nc(buffer, "Status:")) {
  	      strncpy(tbuffer, buffer, sizeof(tbuffer));
  	      remove_header_keyword(tbuffer);
  	      strncpy(current_header->mailx_status, tbuffer, WLEN-1);
--- 714,726 ----
  
  	    /** next let's see if it's to us or not... **/
  
! 	    else if (header_cmp(buffer, "To", NULL)) {
  	      in_to_list = TRUE;
  	      current_header->to[0] = '\0';	/* nothing yet */
  	      figure_out_addressee((char *) buffer +3, 
  				   current_header->to);
  	    }
! 	    else if (header_cmp(buffer, "Status", NULL)) {
  	      strncpy(tbuffer, buffer, sizeof(tbuffer));
  	      remove_header_keyword(tbuffer);
  	      strncpy(current_header->mailx_status, tbuffer, WLEN-1);
***************
*** 714,719 ****
--- 749,755 ----
  	      in_to_list = FALSE;
  	      content_remaining = current_header->content_length;
  	      content_start = fbytes + 1;
+ 	      lines_start = line;
  	    }
  	    if (in_header == TRUE) {
  	       if ((!whitespace(buffer[0])) && index(buffer, ':') == NULL) {
***************
*** 721,726 ****
--- 757,763 ----
  	        in_to_list = FALSE;
  	        content_remaining = current_header->content_length;
  	        content_start = fbytes;
+ 	        lines_start = line;
  	      }
  	    }
  	    if (in_to_list == TRUE) {

Index: src/options.c
Prereq: 5.2
*** ../elm2.4/src/options.c	Tue Oct 27 11:17:30 1992
--- src/options.c	Sat Nov  7 14:37:23 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: options.c,v 5.2 1992/10/24 13:35:39 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
   *
   * 			Copyright (c) 1986,1987 Dave Taylor
   * 			Copyright (c) 1988-1992 USENET Community Trust
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: options.c,v 5.3 1992/11/07 19:37:21 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
   *
   * 			Copyright (c) 1986,1987 Dave Taylor
   * 			Copyright (c) 1988-1992 USENET Community Trust
***************
*** 14,19 ****
--- 14,24 ----
   *
   *******************************************************************************
   * $Log: options.c,v $
+  * Revision 5.3  1992/11/07  19:37:21  syd
+  * Enhanced printing support.  Added "-I" to readmsg to
+  * suppress spurious diagnostic messages.
+  * From: chip@chinacat.unicom.com (Chip Rosenthal)
+  *
   * Revision 5.2  1992/10/24  13:35:39  syd
   * changes found by using codecenter on Elm 2.4.3
   * From: Graham Hudspith <gwh@inmos.co.uk>
***************
*** 148,154 ****
  "This is where copies of outbound messages are saved automatically.", ElmOptionOutboundHelp},
  
  {'p', "P)rint mail using", ElmOptionPrintMenu,	"print",	post_print,
! "This is how printouts are generated.  \"%s\" will be replaced by the filename.", ElmOptionPrintHelp},
  
  {'r', "R)eply copies msg", ElmOptionReplyMenu,	"autocopy",	NULL,
  "Whether to copy the message being replied to into the reply.", ElmOptionReplyHelp},
--- 153,159 ----
  "This is where copies of outbound messages are saved automatically.", ElmOptionOutboundHelp},
  
  {'p', "P)rint mail using", ElmOptionPrintMenu,	"print",	post_print,
! "This is the command used to print mail messages.", ElmOptionPrintHelp},
  
  {'r', "R)eply copies msg", ElmOptionReplyMenu,	"autocopy",	NULL,
  "Whether to copy the message being replied to into the reply.", ElmOptionReplyHelp},

Index: src/read_rc.c
Prereq: 5.7
*** ../elm2.4/src/read_rc.c	Tue Oct 27 11:17:31 1992
--- src/read_rc.c	Sat Nov  7 11:27:34 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: read_rc.c,v 5.7 1992/10/24 13:44:41 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.7 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: read_rc.c,v 5.8 1992/11/07 16:27:33 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.8 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,25 ----
   *
   *******************************************************************************
   * $Log: read_rc.c,v $
+  * Revision 5.8  1992/11/07  16:27:33  syd
+  * Fix where elm duplicates the entry's from the global elm.rc.
+  * It will however still copy the global weedout headers to your local
+  * elmrc if they where not already in it.
+  * From: janw@fwi.uva.nl (Jan Wortelboer)
+  *
   * Revision 5.7  1992/10/24  13:44:41  syd
   * There is now an additional elmrc option "displaycharset", which
   * sets the charset supported on your terminal. This is to prevent
***************
*** 691,698 ****
  	    for (i=0, len = strlen(header); i< len; i++)
  	      if (header[i] == '_') header[i] = ' ';
  
! 	    strcpy(weedlist[weedcount], header);
! 	    weedcount++;
  /* since this used both for system defaults and user's */
  	    if (equal(header, "*end-of-defaults*")) break;
  	  }
--- 697,706 ----
  	    for (i=0, len = strlen(header); i< len; i++)
  	      if (header[i] == '_') header[i] = ' ';
  
!             if(!matches_weedlist(header)) {
! 	      strcpy(weedlist[weedcount], header);
! 	      weedcount++;
! 	    }
  /* since this used both for system defaults and user's */
  	    if (equal(header, "*end-of-defaults*")) break;
  	  }

Index: src/reply.c
Prereq: 5.3
*** ../elm2.4/src/reply.c	Tue Oct 27 11:17:31 1992
--- src/reply.c	Sat Nov  7 15:06:14 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: reply.c,v 5.3 1992/10/24 13:35:39 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: reply.c,v 5.4 1992/11/07 20:05:52 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,23 ----
   *
   *******************************************************************************
   * $Log: reply.c,v $
+  * Revision 5.4  1992/11/07  20:05:52  syd
+  * change to use header_cmp to allow for linear white space around the colon
+  * From: Syd
+  *
   * Revision 5.3  1992/10/24  13:35:39  syd
   * changes found by using codecenter on Elm 2.4.3
   * From: Graham Hudspith <gwh@inmos.co.uk>
***************
*** 202,208 ****
  	return;
  
        /* we only want lines with addresses */
!       if (!first_word_nc(buf, "To:") && !first_word_nc(buf, "cc:"))
  	continue;
  
        /* extract the addresses from this line and possible continuation lines */
--- 206,212 ----
  	return;
  
        /* we only want lines with addresses */
!       if (!header_cmp(buf, "To", NULL) && !header_cmp(buf, "cc", NULL))
  	continue;
  
        /* extract the addresses from this line and possible continuation lines */

Index: src/returnadd.c
Prereq: 5.1
*** ../elm2.4/src/returnadd.c	Sat Oct  3 18:59:15 1992
--- src/returnadd.c	Sat Nov  7 15:06:14 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: returnadd.c,v 5.1 1992/10/03 22:58:40 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: returnadd.c,v 5.3 1992/11/07 20:05:52 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,27 ----
   *
   *******************************************************************************
   * $Log: returnadd.c,v $
+  * Revision 5.3  1992/11/07  20:05:52  syd
+  * change to use header_cmp to allow for linear white space around the colon
+  * From: Syd
+  *
+  * Revision 5.2  1992/11/07  14:59:05  syd
+  * fix format variable for long
+  * From: Syd
+  *
   * Revision 5.1  1992/10/03  22:58:40  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 75,81 ****
  		    headers[msgnum]->offset, error_description(errno), 
  		    "get_existing_address"));
  	    error2(catgets(elm_msg_cat, ElmSet, ElmCouldntSeekBytesIntoFlle,
! 		   "Couldn't seek %d bytes into file (%s)."),
  	           headers[msgnum]->offset, error_description(errno));
  	    return;
          }
--- 83,89 ----
  		    headers[msgnum]->offset, error_description(errno), 
  		    "get_existing_address"));
  	    error2(catgets(elm_msg_cat, ElmSet, ElmCouldntSeekBytesIntoFlle,
! 		   "Couldn't seek %ld bytes into file (%s)."),
  	           headers[msgnum]->offset, error_description(errno));
  	    return;
          }
***************
*** 86,99 ****
            ok = (int) (mail_gets(mybuf, LONG_STRING, mailfile) != 0);
  	  no_ret(mybuf);	/* remove return character */
  
!           if (first_word_nc(mybuf, "To: ")) {
  	    in_to = TRUE;
! 	    strcpy(buffer, (char *) mybuf + strlen("To: "));
            }
- 	  else if (first_word_nc(mybuf, "Original-To:")) {
- 	    in_to = TRUE;
- 	    strcpy(buffer, (char *) mybuf + strlen("Original-To:"));
- 	  }
  	  else if (in_to && whitespace(mybuf[0])) {
  	    strcat(buffer, " ");		/* tag a space in   */
  	    strcat(buffer, (char *) mybuf + 1);	/* skip 1 whitespace */
--- 94,104 ----
            ok = (int) (mail_gets(mybuf, LONG_STRING, mailfile) != 0);
  	  no_ret(mybuf);	/* remove return character */
  
!           if (header_cmp(mybuf, "To", NULL) ||
! 	      header_cmp(mybuf, "Original-To", NULL)) {
  	    in_to = TRUE;
! 	    strcpy(buffer, index(mybuf, ':') + 1);
            }
  	  else if (in_to && whitespace(mybuf[0])) {
  	    strcat(buffer, " ");		/* tag a space in   */
  	    strcat(buffer, (char *) mybuf + 1);	/* skip 1 whitespace */
***************
*** 141,147 ****
  		headers[msgnum]->offset, error_description(errno), 
  	        "get_return"));
  	  error2(catgets(elm_msg_cat, ElmSet, ElmCouldntSeekBytesIntoFlle,
! 		"Couldn't seek %d bytes into file (%s)."),
  	       headers[msgnum]->offset, error_description(errno));
  	  return(using_to);
  	}
--- 146,152 ----
  		headers[msgnum]->offset, error_description(errno), 
  	        "get_return"));
  	  error2(catgets(elm_msg_cat, ElmSet, ElmCouldntSeekBytesIntoFlle,
! 		"Couldn't seek %ld bytes into file (%s)."),
  	       headers[msgnum]->offset, error_description(errno));
  	  return(using_to);
  	}
***************
*** 195,206 ****
  
  #ifdef USE_EMBEDDED_ADDRESSES
  
! 	  else if (first_word_nc(buf, "From:")) {
! 	    get_address_from("From:", buf, hold_return);
  	    buffer[0] = '\0';
            }
!           else if (first_word_nc(buf, "Reply-To:")) {
! 	    get_address_from("Reply-To:", buf, buffer);
  	    return(using_to);
            }
  
--- 200,211 ----
  
  #ifdef USE_EMBEDDED_ADDRESSES
  
! 	  else if (header_cmp(buf, "From", NULL)) {
! 	    get_address_from(buf, hold_return);
  	    buffer[0] = '\0';
            }
!           else if (header_cmp(buf, "Reply-To", NULL)) {
! 	    get_address_from(buf, buffer);
  	    return(using_to);
            }
  
***************
*** 215,222 ****
  	else
  	  add_site(buffer, name1, lastname);	/* get the user name too! */
  
! 	if (first_word_nc(buffer, "To:")) {	/* for backward compatibility */
! 	  get_existing_address(buffer,msgnum);
  	  using_to = TRUE;
  	}
  	else {
--- 220,227 ----
  	else
  	  add_site(buffer, name1, lastname);	/* get the user name too! */
  
! 	if (header_cmp(buffer, "To")) {	/* for backward compatibility */
! 	  get_existing_address(buffer, msgnum);
  	  using_to = TRUE;
  	}
  	else {

Index: src/showmsg.c
Prereq: 5.4
*** ../elm2.4/src/showmsg.c	Mon Nov  2 15:51:49 1992
--- src/showmsg.c	Sat Nov  7 11:23:48 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: showmsg.c,v 5.4 1992/10/30 21:47:30 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: showmsg.c,v 5.5 1992/11/07 16:23:48 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.5 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,23 ----
   *
   *******************************************************************************
   * $Log: showmsg.c,v $
+  * Revision 5.5  1992/11/07  16:23:48  syd
+  * fix null dereferences from patch 5
+  * From: Jukka Ukkonen <ukkonen@csc.fi>
+  *
   * Revision 5.4  1992/10/30  21:47:30  syd
   * Use copy_message in mime shows to get encode processing
   * From: bjoerns@stud.cs.uit.no (Bjoern Stabell)
***************
*** 141,151 ****
  	    if (fseek(mailfile, current_header->offset, 0) != -1) {
  		sprintf(fname, "%semm.%d.%d", temp_dir, getpid(), getuid());
  		if ((fpout = fopen(fname, "w")) != NULL) {
! 		    copy_message(NULL, fpout, FALSE, FALSE, FALSE, FALSE, FALSE);
  		    sprintf(Cmd, "metamail -p -z -m Elm %s", fname);
  		    Raw(OFF);
  		    code = system_call(Cmd, SY_ENAB_SIGINT);
  		    Raw(ON);
  		    PutLine0(LINES,0, catgets(elm_msg_cat, ElmSet, ElmPressAnyKeyIndex,
  			     "Press any key to return to index."));
  		    (void) ReadCh();
--- 145,157 ----
  	    if (fseek(mailfile, current_header->offset, 0) != -1) {
  		sprintf(fname, "%semm.%d.%d", temp_dir, getpid(), getuid());
  		if ((fpout = fopen(fname, "w")) != NULL) {
! 		    copy_message("", fpout, FALSE, FALSE, FALSE, FALSE, FALSE);
! 		    (void) fclose (fpout);
  		    sprintf(Cmd, "metamail -p -z -m Elm %s", fname);
  		    Raw(OFF);
  		    code = system_call(Cmd, SY_ENAB_SIGINT);
  		    Raw(ON);
+ 		    (void) unlink (fname);
  		    PutLine0(LINES,0, catgets(elm_msg_cat, ElmSet, ElmPressAnyKeyIndex,
  			     "Press any key to return to index."));
  		    (void) ReadCh();

Index: src/showmsg_c.c
Prereq: 5.1
*** ../elm2.4/src/showmsg_c.c	Sat Oct  3 18:59:18 1992
--- src/showmsg_c.c	Sat Nov  7 14:37:23 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: showmsg_c.c,v 5.1 1992/10/03 22:58:40 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: showmsg_c.c,v 5.2 1992/11/07 19:37:21 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,24 ----
   *
   *******************************************************************************
   * $Log: showmsg_c.c,v $
+  * Revision 5.2  1992/11/07  19:37:21  syd
+  * Enhanced printing support.  Added "-I" to readmsg to
+  * suppress spurious diagnostic messages.
+  * From: chip@chinacat.unicom.com (Chip Rosenthal)
+  *
   * Revision 5.1  1992/10/03  22:58:40  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 195,202 ****
  
  	    case 'p' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmPrintMessage,
  				"Print message"), FALSE);
! 		       print_msg();
! 		       store_msg("Queued for printing.");
  		       break;
  
  	    case 'r' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmReplyToMessage,
--- 200,206 ----
  
  	    case 'p' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmPrintMessage,
  				"Print message"), FALSE);
! 		       (void) print_msg(FALSE);
  		       break;
  
  	    case 'r' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmReplyToMessage,

Index: src/syscall.c
Prereq: 5.1
*** ../elm2.4/src/syscall.c	Sat Oct  3 18:59:22 1992
--- src/syscall.c	Sat Nov  7 15:45:53 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: syscall.c,v 5.1 1992/10/03 22:58:40 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: syscall.c,v 5.3 1992/11/07 20:45:39 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,28 ----
   *
   *******************************************************************************
   * $Log: syscall.c,v $
+  * Revision 5.3  1992/11/07  20:45:39  syd
+  * add no tite flag on options that should not use ti/te
+  * Hack by Syd
+  *
+  * Revision 5.2  1992/11/07  19:37:21  syd
+  * Enhanced printing support.  Added "-I" to readmsg to
+  * suppress spurious diagnostic messages.
+  * From: chip@chinacat.unicom.com (Chip Rosenthal)
+  *
   * Revision 5.1  1992/10/03  22:58:40  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 145,150 ****
--- 154,162 ----
  #endif
  	extern int errno;
  
+ 	/* flush any pending output */
+ 	fflush(stdout);
+ 
  	/* figure out what shell we are using here */
  	sh = ((options & SY_USER_SHELL) ? shell : "/bin/sh");
  	dprint(2, (debugfile, "System Call: %s\n\t%s\n", sh, string));
***************
*** 302,308 ****
  	if (cursor_control)
  	  transmit_functions(OFF);
  	
! 	sprintf(buffer, "%s -h|%s", readmsg, command);
  	ret = system_call(buffer, SY_USER_SHELL|SY_ENAB_SIGINT|SY_DUMPSTATE);
  
  	SetXYLocation(0, 40);	/* a location not near the next request, so an absolute is used */
--- 314,320 ----
  	if (cursor_control)
  	  transmit_functions(OFF);
  	
! 	sprintf(buffer, "%s -Ih|%s", readmsg, command);
  	ret = system_call(buffer, SY_USER_SHELL|SY_ENAB_SIGINT|SY_DUMPSTATE);
  
  	SetXYLocation(0, 40);	/* a location not near the next request, so an absolute is used */
***************
*** 319,371 ****
  	return(1);
  }
  
! print_msg()
  {
! 	/** Print current message or tagged messages using 'printout' 
! 	    variable.  Error message iff printout not defined! **/
  
  	char buffer[SLEN], filename[SLEN], printbuffer[SLEN];
! 	register int  retcode;
  
! 	if (strlen(printout) == 0) {
! 	  error(catgets(elm_msg_cat, ElmSet, ElmDontKnowHowToPrint,
  		"Don't know how to print - option \"printmail\" undefined!"));
! 	  return;
  	}
  
! 	sprintf(filename,"%s%s%d", temp_dir, temp_print, getpid());
! 
! 	if (in_string(printout, "%s"))
! 	  sprintf(printbuffer, printout, filename);
! 	else
! 	  sprintf(printbuffer, "%s %s", printout, filename);
  
! 	sprintf(buffer,"(%s -p > %s; %s 2>&1) > /dev/null",
  		readmsg, filename, printbuffer);
! 	
! 	dprint(2, (debugfile, "Printing system call...\n"));
  
!   	Centerline(LINES, catgets(elm_msg_cat, ElmSet, ElmQueuing, "Queuing..."));
  
! 	if ((retcode = system_call(buffer, SY_DUMPSTATE)) == 0) {
! 	  int tag_count, i;
! 	  for (tag_count = 0, i = 0 ; i < message_count ; ++i)  {
! 	    if (headers[i]->status & TAGGED)
! 	      ++tag_count;
! 	  }
! 	  if (tag_count > 1)
! 	    sprintf(buffer, catgets(elm_msg_cat, ElmSet, ElmMessagesQueuedToPrint,
! 		"Messages queued up to print."));
! 	  else
! 	    strcpy(buffer, catgets(elm_msg_cat, ElmSet, ElmMessageQueuedToPrint,
! 		"Message queued up to print."));
! 	  Centerline(LINES, buffer);
  	}
! 	else
! 	  error1(catgets(elm_msg_cat, ElmSet, ElmPrintoutFailed,
! 		"Printout failed with return code %d."), retcode);
  
! 	unlink(filename);	/* remove da temp file! */
  }
  
  
--- 331,465 ----
  	return(1);
  }
  
! int print_msg(pause_on_scroll)
! int pause_on_scroll;
  {
! 	/*
! 	 * Print the tagged messages, or the current message if none are
! 	 * tagged.  Message(s) are passed passed into the command specified
! 	 * by "printout".  An error is given if "printout" is undefined.
! 	 *
! 	 * Printing will be done through a pipe so we can print the number
! 	 * of lines output.  This is used to determine whether the screen
! 	 * got trashed by the print command.  One limitation is that only
! 	 * stdout lines are counted, not stderr output.  A nonzero result
! 	 * is returned if we think enough output was generated to trash
! 	 * the display, a zero result indicates the display is probably
! 	 * alright.  Further, if the display is trashed and "pause_on_scroll"
! 	 * is true then we'll give a "hit any key" prompt before returning.
! 	 *
! 	 * This routine has two modes of behavior, depending upon whether
! 	 * there is a "%s" embedded in the "printout" string.  If there,
! 	 * the old Elm behavior is used (a temp file is used, all output
! 	 * from the print command is chucked out).  If there isn't a "%s"
! 	 * then the new behavior is used (message(s) piped right into
! 	 * print command, output is left attached to the terminal).
! 	 *
! 	 * The old behaviour is bizarre.  I hope we can ditch it someday.
! 	 */
  
  	char buffer[SLEN], filename[SLEN], printbuffer[SLEN];
! 	int  nlines, retcode, old_raw;
! 	FILE *fp;
  
! 	/*
! 	 * Make sure we know how to print.
! 	 */
! 	if (printout[0] == '\0') {
! 	    error(catgets(elm_msg_cat, ElmSet, ElmPrintDontKnowHow,
  		"Don't know how to print - option \"printmail\" undefined!"));
! 	    return 0;
  	}
  
! 	/*
! 	 * Temp file name used by "old style" printing.
! 	 */
!         sprintf(filename,"%s%s%d", temp_dir, temp_print, getpid());
  
! 	/*
! 	 * Setup print command.  Select old or new behavior based
! 	 * upon the presence of "%s" in the print command string.
! 	 */
! 	if (in_string(printout, "%s")) {
! 	    sprintf(printbuffer, printout, filename);
! 	    sprintf(buffer,"(%s -Ip > %s; %s 2>&1) > /dev/null",
  		readmsg, filename, printbuffer);
! 	} else {
! 	    sprintf(buffer,"%s -Ip | %s", readmsg, printout);
! 	}
  
! 	/*
! 	 * Create information for "readmsg" command.
! 	 */
! 	if (create_folder_state_file() != 0)
! 	    return 0;
  
! 	/*
! 	 * Put keyboard into normal state.
! 	 */
! 	if ((old_raw = RawState()) == ON)
! 	    Raw(OFF | NO_TITE);
! 	softkeys_off();
! 	if (cursor_control)
! 	    transmit_functions(OFF);
! 
! 	/*
! 	 * Run the print command in a pipe and grab the output.
! 	 */
! 	putchar('\n');
! 	fflush(stdout);
! 	nlines = 0;
! 	if ((fp = popen(buffer, "r")) == NULL) {
! 	    error(catgets(elm_msg_cat, ElmSet, ElmPrintPipeFailed,
! 		"Cannot create pipe to print command."));
! 	    goto done;
! 	}
! 	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
! 	    fputs(buffer, stdout);
! 	    ++nlines;
  	}
! 
! 	/*
! 	 * See if there were enough lines printed to trash the screen.
! 	 */
! 	if (pause_on_scroll && nlines > 1) {
! 	    printf("\n%s ", catgets(elm_msg_cat, ElmSet, ElmPrintPressAKey,
! 		"Press any key to continue:"));
! 	    fflush(stdout);
! 	    Raw(ON | NO_TITE);
! 	    (void) getchar();
! 	}
  
! 	/*
! 	 * Display a status message.
! 	 */
! 	if ((retcode = pclose(fp)) == 0) {
! 	    error(catgets(elm_msg_cat, ElmSet, ElmPrintJobSpooled,
! 		"Print job has been spooled."));
! 	} else if ((retcode & 0xFF) == 0) {
! 	    error1(catgets(elm_msg_cat, ElmSet, ElmPrintFailCode,
! 		"Printout failed with return code %d."), (retcode>>8));
! 	} else {
! 	    error1(catgets(elm_msg_cat, ElmSet, ElmPrintFailStatus,
! 		"Printout failed with status 0x%04x."), (retcode>>8));
! 	}
! 
! 	/*
! 	 * Hack alert:  The only place we use "pause_on_scroll" false is when
! 	 * printing while reading a mail message.  This newline prevents the
! 	 * above message from being wiped out by the command prompt.
! 	 */
! 	if (!pause_on_scroll)
! 		putchar('\n');
! 
! done:
! 	Raw(old_raw | NO_TITE);
! 	softkeys_on();
! 	if (cursor_control)
! 	    transmit_functions(ON);
! 	(void) unlink(filename);
! 	(void) remove_folder_state_file();
! 	return (nlines > 1);
  }
  
  
***************
*** 389,395 ****
  
  	char buffer[SLEN];
  
! 	Raw(OFF);
  	ClearScreen();
  	MoveCursor(LINES, 0);
  	if(helpmsg)
--- 483,489 ----
  
  	char buffer[SLEN];
  
! 	Raw(OFF | NO_TITE);
  	ClearScreen();
  	MoveCursor(LINES, 0);
  	if(helpmsg)
***************
*** 419,425 ****
  	}
  	while(numlines--)
  	    printf("\n\r");
! 	Raw(ON);
  }
  
  
--- 513,519 ----
  	}
  	while(numlines--)
  	    printf("\n\r");
! 	Raw(ON | NO_TITE);
  }
  
  

Index: utils/arepdaem.c
Prereq: 5.4
*** ../elm2.4/utils/arepdaem.c	Tue Oct 27 11:17:32 1992
--- utils/arepdaem.c	Sat Nov  7 15:06:15 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: arepdaem.c,v 5.4 1992/10/27 01:43:40 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: arepdaem.c,v 5.5 1992/11/07 20:05:52 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.5 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,23 ----
   *
   *******************************************************************************
   * $Log: arepdaem.c,v $
+  * Revision 5.5  1992/11/07  20:05:52  syd
+  * change to use header_cmp to allow for linear white space around the colon
+  * From: Syd
+  *
   * Revision 5.4  1992/10/27  01:43:40  syd
   * Move posix_signal to lib directory
   * From: tom@osf.org
***************
*** 384,399 ****
        if (first_word(buffer, "From ")) 
  	in_header++;
        else if (in_header) {
! 	if (first_word_nc(buffer, "From:"))
! 	  get_address_from("From:", buffer, from);
! 	else if (first_word_nc(buffer, "Reply-To:"))
! 	  get_address_from("Reply_To:", buffer, from);
  #endif
!         else if (first_word_nc(buffer,"Subject:")) {
  	  remove_return(buffer);
  	  strcpy(subject, (char *) (buffer + 8));
          }
!         else if (first_word_nc(buffer,"X-Mailer: fastmail"))
  	  *sendit = 0;
          else if (strlen(buffer) == 1)
  	  done = 1;
--- 388,402 ----
        if (first_word(buffer, "From ")) 
  	in_header++;
        else if (in_header) {
! 	if (header_cmp(buffer, "From", NULL) ||
! 	    header_cmp(buffer, "Reply-To", NULL))
! 	  get_address_from(buffer, from);
  #endif
!         else if (header_cmp(buffer,"Subject", NULL)) {
  	  remove_return(buffer);
  	  strcpy(subject, (char *) (buffer + 8));
          }
!         else if (header_cmp(buffer,"X-Mailer", "fastmail"))
  	  *sendit = 0;
          else if (strlen(buffer) == 1)
  	  done = 1;

Index: utils/from.c
Prereq: 5.1
*** ../elm2.4/utils/from.c	Sat Oct  3 20:46:59 1992
--- utils/from.c	Sat Nov  7 16:03:34 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: from.c,v 5.1 1992/10/04 00:46:45 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: from.c,v 5.3 1992/11/07 21:03:33 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,26 ----
   *
   *******************************************************************************
   * $Log: from.c,v $
+  * Revision 5.3  1992/11/07  21:03:33  syd
+  * fix typo
+  *
+  * Revision 5.2  1992/11/07  20:05:52  syd
+  * change to use header_cmp to allow for linear white space around the colon
+  * From: Syd
+  *
   * Revision 5.1  1992/10/04  00:46:45  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 438,456 ****
  #endif /* MMDF */
  	    if (first_word(buffer,">From ")) 
  	      forwarded(buffer, from_whom); /* return address */
! 	    else if (first_word_nc(buffer,"Subject:") ||
! 		     first_word_nc(buffer,"Re:")) {
  	      if (subject[0] == '\0') {
  	        remove_header_keyword(buffer);
  		strcpy(subject, buffer);
  	      }
  	    }
! 	    else if (first_word_nc(buffer,"From:") ||
! 		    first_word_nc(buffer, ">From:"))
  	      parse_arpa_who(buffer, from_whom, FALSE);
! 	    else if (first_word_nc(buffer,"To:"))
! 	      figure_out_addressee(buffer+3, to_whom);
! 	    else if (first_word_nc(buffer,"Status:")) {
  	      remove_header_keyword(buffer);
  	      switch (*buffer) {
  		case 'N': status = NEW_MSG;	break;
--- 445,463 ----
  #endif /* MMDF */
  	    if (first_word(buffer,">From ")) 
  	      forwarded(buffer, from_whom); /* return address */
! 	    else if (header_cmp(buffer,"Subject", NULL) ||
! 		     header_cmp(buffer,"Re", NULL)) {
  	      if (subject[0] == '\0') {
  	        remove_header_keyword(buffer);
  		strcpy(subject, buffer);
  	      }
  	    }
! 	    else if (header_cmp(buffer,"From", NULL) ||
! 		     header_cmp(buffer, ">From", NULL))
  	      parse_arpa_who(buffer, from_whom, FALSE);
! 	    else if (header_cmp(buffer, "To", NULL))
! 	      figure_out_addressee(index(buffer, ':') + 1, to_whom);
! 	    else if (header_cmp(buffer, "Status", NULL)) {
  	      remove_header_keyword(buffer);
  	      switch (*buffer) {
  		case 'N': status = NEW_MSG;	break;

Index: utils/newmail.c
Prereq: 5.4
*** ../elm2.4/utils/newmail.c	Tue Oct 27 11:17:32 1992
--- utils/newmail.c	Sat Nov  7 15:06:16 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: newmail.c,v 5.4 1992/10/27 01:43:40 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: newmail.c,v 5.5 1992/11/07 20:05:52 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.5 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,23 ----
   *
   *******************************************************************************
   * $Log: newmail.c,v $
+  * Revision 5.5  1992/11/07  20:05:52  syd
+  * change to use header_cmp to allow for linear white space around the colon
+  * From: Syd
+  *
   * Revision 5.4  1992/10/27  01:43:40  syd
   * Move posix_signal to lib directory
   * From: tom@osf.org
***************
*** 409,431 ****
  #endif /* MMDF */
  	    if (first_word_nc(buffer,">From")) 
  	      forwarded(buffer, from_whom); /* return address */
! 	    else if (first_word_nc(buffer,"Subject:") ||
! 		     first_word_nc(buffer,"Re:")) {
  	      if (! subj++) {
  	        remove_header_keyword(buffer);
  		strcpy(subject, buffer);
  	      }
  	    }
! 	    else if (first_word_nc(buffer, "Priority:") ||
! 		     first_word_nc(buffer, "Importance: 2")) {
! 		   if (!(first_word_nc(buffer, "priority: normal") ||
! 		     first_word_nc(buffer, "priority: non-urgent")))
  		      priority++;
  		   }
! 	    else if (first_word_nc(buffer,"From:")) 
  	      parse_arpa_who(buffer, from_whom, 0);
! 	    else if (first_word_nc(buffer,"To:"))
! 	      figure_out_addressee(buffer+3, to_whom);
  	    else if (buffer[0] == LINEFEED) {
  	      in_header = 0;	/* in body of message! */
  #ifdef MMDF
--- 413,435 ----
  #endif /* MMDF */
  	    if (first_word_nc(buffer,">From")) 
  	      forwarded(buffer, from_whom); /* return address */
! 	    else if (header_cmp(buffer,"Subject", NULL) ||
! 		     header_cmp(buffer,"Re", NULL)) {
  	      if (! subj++) {
  	        remove_header_keyword(buffer);
  		strcpy(subject, buffer);
  	      }
  	    }
! 	    else if (header_cmp(buffer, "Priority", NULL) ||
! 		     header_cmp(buffer, "Importance", "2")) {
! 		   if (!(header_cmp(buffer, "priority", "normal") ||
! 		     header_cmp(buffer, "priority", "non-urgent")))
  		      priority++;
  		   }
! 	    else if (header_cmp(buffer,"From", NULL)) 
  	      parse_arpa_who(buffer, from_whom, 0);
! 	    else if (header_cmp(buffer, "To", NULL))
! 	      figure_out_addressee(index(buffer, ':') + 1, to_whom);
  	    else if (buffer[0] == LINEFEED) {
  	      in_header = 0;	/* in body of message! */
  #ifdef MMDF

Index: utils/readmsg.c
Prereq: 5.1
*** ../elm2.4/utils/readmsg.c	Sat Oct  3 20:47:01 1992
--- utils/readmsg.c	Sat Nov  7 14:37:25 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: readmsg.c,v 5.1 1992/10/04 00:46:45 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: readmsg.c,v 5.2 1992/11/07 19:37:21 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,24 ----
   *
   *******************************************************************************
   * $Log: readmsg.c,v $
+  * Revision 5.2  1992/11/07  19:37:21  syd
+  * Enhanced printing support.  Added "-I" to readmsg to
+  * suppress spurious diagnostic messages.
+  * From: chip@chinacat.unicom.com (Chip Rosenthal)
+  *
   * Revision 5.1  1992/10/04  00:46:45  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 60,65 ****
--- 65,81 ----
  		    sel == $ -- selects last message in folder
  		    sel == 0 -- selects last message in folder
  
+     The undocumented "-I" option is a kludge to deal with an Elm race
+     condition.  The problem is that Elm does piping/printing/etc. by
+     running "readmsg|command" and placing the mail message selection
+     into a folder state file.  However, if the "command" portion of
+     the pipeline craps out, Elm might regain control before "readmsg"
+     completes.  The first thing Elm does is unlink the folder state
+     file.  Thus "readmsg" can't figure out what to do -- there is no
+     state file or command line args to select a message.  In this
+     case, "readmsg" normally gives a usage diagnostic message.  The
+     "-I" option says to ignore this condition and silently terminate.
+ 
  **/
  
  #include "elmutil.h"
***************
*** 131,136 ****
--- 147,153 ----
      int hdr_disp_level;		/* amount of headers to show		*/
      int do_page_breaks;		/* true to FORMFEED between messages	*/
      int do_all_matches;		/* true to show all mssgs which match pat*/
+     int ign_no_request;		/* terminate if no actions requested	*/
      int exit_status;		/* normally zero, set to one on error	*/
      FILE *fp;			/* file stream for opened folder	*/
      long idx;			/* seek offset within folder		*/
***************
*** 155,160 ****
--- 172,178 ----
      hdr_disp_level = WEED;	/* only display interesting headers	*/
      do_page_breaks = FALSE;	/* suppress formfeed between mssgs	*/
      do_all_matches = FALSE;	/* only show 1st mssg which matches pat	*/
+     ign_no_request = FALSE;	/* no action requested is an error	*/
      exit_status = 0;		/* will set nonzero on error		*/
  
      /* see if an external folder state file exists */
***************
*** 167,173 ****
      fstate_valid = (fstate.folder_name != NULL);
  
      /* crack the command line */
!     while ((i = getopt(argc, argv, "anhf:p")) != EOF) {
  	switch (i) {
  	case 'a' :
  	    do_all_matches = TRUE;
--- 185,191 ----
      fstate_valid = (fstate.folder_name != NULL);
  
      /* crack the command line */
!     while ((i = getopt(argc, argv, "anhf:pI")) != EOF) {
  	switch (i) {
  	case 'a' :
  	    do_all_matches = TRUE;
***************
*** 192,197 ****
--- 210,218 ----
  	case 'p' :
  	    do_page_breaks = TRUE;
  	    break;
+ 	case 'I':
+ 	    ign_no_request = TRUE;
+ 	    break;
  	default:
  	    usage_error();
  	}
***************
*** 236,241 ****
--- 257,264 ----
      if (argc == optind) {
  	if (!fstate_valid) {
  		/* no applicable state file or it didn't select anything */
+ 		if (ign_no_request)
+ 		    exit(0);
  		usage_error();
  	}
  	if (folder_size < 1) {

Index: Patchlist
*** ../elm2.4/Patchlist	Tue Oct 27 11:17:22 1992
--- Patchlist	Sat Nov  7 15:55:04 1992
***************
*** 1,4 ****
--- 1,98 ----
  =========================================================
+ Patch Set - Patches 7 and 8 : Sat Nov  7 15:54:44 EST 1992
+ Elm 2.4PL6 -> Elm 2.4PL8
+ 
+ Add some tolerance for incorrect Content-Length header (fixes bug where
+ Elm would combine two messages if content-length header was incorrect.
+ Still has problem if incorrect content-length exactly matches multiple
+ messages)
+ From: Syd
+ 
+ Change Makefile in doc to use -f as some shells don't have -x in test
+ From: Syd
+ 
+ The first is that when doing a summary, macros are expanded when printing the
+ rule. IMHO they should be printed as with the -r option (i.e. %t is
+ printed as "<time>" and so on).
+ 
+ The second one is that the summary printed "applied n time" regardless of
+ the value of n, not "applied n times" when n > 1.
+ From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+ 
+ There is no need to write out the MIME-Version header in subparts
+ From: Klaus Steinberger <Klaus.Steinberger@Physik.Uni-Muenchen.DE>
+ 
+ fix null dereferences from patch 5
+ From: Jukka Ukkonen <ukkonen@csc.fi>
+ 
+ Fix where elm duplicates the entry's from the global elm.rc.
+ It will however still copy the global weedout headers to your local
+ elmrc if they where not already in it.
+ From: janw@fwi.uva.nl (Jan Wortelboer)
+ 
+ another typo (2.4.6 Ref.guide)
+ From: David.W.Tamkin@gagme.chi.il.us (David W. Tamkin)
+ 
+ comments should be allowed anywhere in the alias file.
+ From: "Robert L. Howard" <robert.howard@matd.gatech.edu>
+ 
+ Symbol change for AIX370
+ From: uri@watson.ibm.com
+ 
+ Fix redefinition complaint by SCO 3.2v2.0.
+ From: chip@chinacat.unicom.com (Chip Rosenthal)
+ 
+ Enhanced printing support.  Added "-I" to readmsg to
+ suppress spurious diagnostic messages.
+ From: chip@chinacat.unicom.com (Chip Rosenthal)
+ 
+ These small typos stopped me from making forms, so here is a patch.
+ From: andrew.mcparland@rd.eng.bbc.co.uk (Andrew McParland)
+ 
+ Add a hack to not use ti/te on list folders and do print
+ From: Syd
+ 
+ New header parsing routine header_cmp to allow for linear
+ white space around the : in headers
+ From: Syd
+ 
+ 
+ 
+ =========================================================
+ Patch Set - Patch 6 : Mon Nov  2 15:52:00 EST 1992
+ Elm 2.4PL5 -> Elm 2.4PL6
+ 
+ Things I found in doc/Ref.guide looking over patches 4 & 5:
+ From: dwolfe@pffft.sps.mot.com (Dave Wolfe)
+ 
+ More changes to folder creation confirmation
+ From: Larry Philps <larryp@sco.COM>
+ 
+ fix a bug in the forms reply caused by the Cc: buffer not being
+ cleared.  If one has sent mail just prior to replying to the form and
+ specified a Cc:  address, the form reply is also sent to those Cc:
+ address(es).
+ From: dwolfe@pffft.sps.mot.com (Dave Wolfe)
+ 
+ Add missing MAKE variable in doc/Makefile.SH
+ From: Syd
+ 
+ it invokes metamail (the pseudo is because "text" isn't a legal Content-Type).
+ in src/mime.c notplain() tries to check for text but fails because it should
+ look for "text\n" not "text".
+ From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+ 
+ Use copy_message in mime shows to get encode processing
+ From: bjoerns@stud.cs.uit.no (Bjoern Stabell)
+ 
+ Corrections to Unix date parsing and time zone storage
+ From: eotto@hvlpa.att.com
+ 
+ Prevent index underflow when wildchar is in first three chars of string
+ From: Syd via note from gwh@dogmatix.inmos.co.uk
+ 
+ 
+ =========================================================
  Patch Set - Patches 4 and 5 : Sat Oct 24 22:48:00 EDT 1992
  Elm 2.4PL3 -> Elm 2.4PL5
  

-- 
========================================================================
Sydney S. Weinstein, CDP, CCP          Elm Coordinator - Current 2.4PL06
Datacomp Systems, Inc.                 Projected 3.0 Release: ??? ?,1994
syd@DSI.COM or dsinc!syd      Voice: (215) 947-9900, FAX: (215) 938-0235
Newsgroups: comp.mail.elm