From: syd@dsinc.DSI.COM (Syd Weinstein)
Newsgroups: comp.mail.elm,comp.sources.bugs
Subject: elm 2.4 Patch #16
Followup-To: poster
Date: 14 Dec 1992 20:48:36 -0500
Organization: Datacomp Systems, Inc., Huntingdon Valley, PA 19006
NNTP-Posting-Host: dsinc.dsi.com
Summary: This is an official patch for elm 2.4 system.  Please apply it.
Priority: LOW

part 3 of a 4 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:
		do nothing, apply patch 17 next

	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: "15"
*** ../elm2.4/hdrs/patchlevel.h	Wed Nov 25 14:10:35 1992
--- hdrs/patchlevel.h	Wed Nov 25 19:50:23 1992
***************
*** 1 ****
! #define PATCHLEVEL "15"
--- 1 ----
! #define PATCHLEVEL "16"

Index: src/alias.c
Prereq: 5.11
*** ../elm2.4/src/alias.c	Tue Nov 17 14:11:04 1992
--- src/alias.c	Sun Dec 13 12:59:18 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: alias.c,v 5.11 1992/11/15 01:24:34 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.11 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: alias.c,v 5.17 1992/12/13 17:59:18 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.17 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,49 ----
   *
   *******************************************************************************
   * $Log: alias.c,v $
+  * Revision 5.17  1992/12/13  17:59:18  syd
+  * Please write on the blackboard 500 times `NULL != 0.'
+  * From: chip@chinacat.unicom.com (Chip Rosenthal)
+  *
+  * Revision 5.16  1992/12/11  02:09:06  syd
+  * Fix where the user creates a first new alias, then deletes it, the
+  * alias stays on screen, but the file really will be empty if it was the
+  * last alias, so the retry to delete gives 'cannot open ...file' messages
+  * From: "Robert L. Howard" <robert.howard@matd.gatech.edu>
+  *
+  * Revision 5.15  1992/12/11  01:58:22  syd
+  * Anytime elm wants to re-run newalias, selected is set to 0.
+  * (removing any limit in effect)
+  * From: "Robert L. Howard" <robert.howard@matd.gatech.edu>
+  *
+  * Revision 5.14  1992/12/11  01:45:04  syd
+  * remove sys/types.h include, it is now included by defs.h
+  * and this routine includes defs.h or indirectly includes defs.h
+  * From: Syd
+  *
+  * Revision 5.13  1992/12/07  03:02:03  syd
+  * On machines with 64 bit pointers (and 64 bit longs) using int
+  * for newmax causes pointer truncation.
+  * From: Jim Brown
+  *
+  * Revision 5.12  1992/11/26  00:46:50  syd
+  * Fix how errno is used so err is inited and used instead
+  * as errno gets overwritten by print system call
+  * From: Syd
+  *
   * Revision 5.11  1992/11/15  01:24:34  syd
   * The situation is that the .elm/aliases file is missing, but
   * .elm/aliases.dir and .elm/aliases.pag exist (isn't serendipity
***************
*** 101,107 ****
  #include "s_elm.h"
  #include <errno.h>
  #include <ctype.h>
- #include <sys/types.h>
  #include <sys/stat.h>
  #include "s_aliases.h"
  #include "ndbz.h"
--- 131,136 ----
***************
*** 150,156 ****
  
  open_alias_files()
  {
! 	static int first_time = 1;
  /*
   *	Close and re-open the system and user alias files, if present,
   *	and if they have changed since last we opened them.
--- 179,185 ----
  
  open_alias_files()
  {
! 	static int first_time = TRUE;
  /*
   *	Close and re-open the system and user alias files, if present,
   *	and if they have changed since last we opened them.
***************
*** 221,249 ****
   */
  
  	struct stat hst;
! 	static time_t system_ctime, system_mtime;
  
  	/* If file hasn't changed, don't bother re-opening. */
  
! 	if (stat(system_data_file, &hst) == 0
! 	 && hst.st_ctime == system_ctime
! 	 && hst.st_mtime == system_mtime)
! 	    return(0);
  
! 	/* re-open system hash table.  If we can't, just return. */
  
! 	if (system_hash != NULL)
! 	    dbz_close(system_hash);
  
! 	if ((system_hash = dbz_open(system_data_file, O_RDONLY, 0)) == NULL)
! 	    return(0);
  
! 	/* Remember hash file times. */
  
! 	system_ctime = hst.st_ctime;
! 	system_mtime = hst.st_mtime;
  
-         return(1);
  }
  
  int
--- 250,299 ----
   */
  
  	struct stat hst;
! 	static time_t system_ctime = 0, system_mtime = 0;
  
  	/* If file hasn't changed, don't bother re-opening. */
  
! 	if (stat(system_data_file, &hst) == 0) {	/* File exists */
! 	    if (hst.st_ctime == system_ctime &&
! 	        hst.st_mtime == system_mtime) {		/* No changes */
! 	        return(0);
! 	    }
! 
! 	   /*
! 	    * Re-open system hash table.  If we can't, just return.
! 	    */
! 
! 	    if (system_hash != NULL)
! 	        dbz_close(system_hash);
  
! 	    if ((system_hash = dbz_open(system_data_file, O_RDONLY, 0)) == NULL)
! 	        return(0);
  
! 	    /* Remember hash file times. */
  
! 	    system_ctime = hst.st_ctime;
! 	    system_mtime = hst.st_mtime;
  
!             return(1);
! 	}
! 	else {					/* File does not exist */
! 	    if (system_ctime == 0 && system_mtime == 0) {
! 	        return(0);			/* File never existed */
! 	    }
! 	    else {			/* Once existed, better re-read */
! 
! 	       /*
! 	        * Since we no longer exist, we pretend we never existed.
! 	        */
! 
! 	        system_ctime = 0;
! 	        system_mtime = 0;
  
! 	        return(1);
! 	    }
! 	}
  
  }
  
  int
***************
*** 258,288 ****
  
  	struct stat hst;
  	char fname[SLEN];
! 	static time_t user_ctime, user_mtime;
  
  	/* If hash file hasn't changed, don't bother re-reading. */
  
  	sprintf(fname, "%s/%s", home, ALIAS_DATA);
  
! 	if (stat(fname, &hst) == 0
! 	 && hst.st_ctime == user_ctime
! 	 && hst.st_mtime == user_mtime)
! 	    return(0);
  
! 	/* Open user hash table.  If we can't, just return. */
  
! 	if (user_hash != NULL)
! 	    dbz_close(user_hash);
  
! 	if ((user_hash = dbz_open(fname, O_RDONLY, 0)) == NULL)
! 	    return(0);
  
! 	/* Remember hash file times. */
  
! 	user_ctime = hst.st_ctime;
! 	user_mtime = hst.st_mtime;
  
-         return(1);
  }
  
  int
--- 308,359 ----
  
  	struct stat hst;
  	char fname[SLEN];
! 	static time_t user_ctime = 0, user_mtime = 0;
  
  	/* If hash file hasn't changed, don't bother re-reading. */
  
  	sprintf(fname, "%s/%s", home, ALIAS_DATA);
  
! 	if (stat(fname, &hst) == 0) {			/* File exists */
! 	    if (hst.st_ctime == user_ctime &&
! 	        hst.st_mtime == user_mtime) {		/* No changes */
! 	        return(0);
! 	    }
! 
! 	   /*
! 	    * Open user hash table.  If we can't, just return.
! 	    */
  
! 	    if (user_hash != NULL)
! 	        dbz_close(user_hash);
  
! 	    if ((user_hash = dbz_open(fname, O_RDONLY, 0)) == NULL)
! 	        return(0);
  
! 	    /* Remember hash file times. */
  
! 	    user_ctime = hst.st_ctime;
! 	    user_mtime = hst.st_mtime;
  
!             return(1);
! 	}
! 	else {					/* File does not exist */
! 	    if (user_ctime == 0 && user_mtime == 0) {
! 	        return(0);			/* File never existed */
! 	    }
! 	    else {			/* Once existed, better re-read */
! 
! 	       /*
! 	        * Since we no longer exist, we pretend we never existed.
! 	        */
! 
! 	        user_ctime = 0;
! 	        user_mtime = 0;
! 
! 	        return(1);
! 	    }
! 	}
  
  }
  
  int
***************
*** 556,570 ****
  	FILE *file;
  	char fname[SLEN];
  	char buffer[SLEN];
  	
  	sprintf(fname,"%s/%s", home, ALIAS_TEXT);
  	
  	save_file_stats(fname);
  	if ((file = fopen(fname, "a")) == NULL) {
  	  dprint(2, (debugfile, 
  		 "Failure attempting to add alias to file %s within %s",
  		   fname, "add_to_alias_text"));
! 	  dprint(2, (debugfile, "** %s **\n", error_description(errno)));
  	  error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntOpenAdd,
  		 "Couldn't open %s to add new alias!"), fname);
  	  return(1);
--- 627,643 ----
  	FILE *file;
  	char fname[SLEN];
  	char buffer[SLEN];
+ 	int  err;
  	
  	sprintf(fname,"%s/%s", home, ALIAS_TEXT);
  	
  	save_file_stats(fname);
  	if ((file = fopen(fname, "a")) == NULL) {
+ 	  err = errno;
  	  dprint(2, (debugfile, 
  		 "Failure attempting to add alias to file %s within %s",
  		   fname, "add_to_alias_text"));
! 	  dprint(2, (debugfile, "** %s **\n", error_description(err)));
  	  error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntOpenAdd,
  		 "Couldn't open %s to add new alias!"), fname);
  	  return(1);
***************
*** 581,590 ****
  	    strcat(buffer, comment);
  	}
  	if (fprintf(file,"%s = %s = %s\n", aliasname, buffer, address) == EOF) {
  	    dprint(2, (debugfile,
  		       "Failure attempting to write alias to file within %s",
  		       fname, "add_to_alias_text"));
! 	    dprint(2, (debugfile, "** %s **\n", error_description(errno)));
  	    error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntWrite,
  		   "Couldn't write alias to file %s!"), fname);
  	    fclose(file);
--- 654,664 ----
  	    strcat(buffer, comment);
  	}
  	if (fprintf(file,"%s = %s = %s\n", aliasname, buffer, address) == EOF) {
+ 	    err = errno;
  	    dprint(2, (debugfile,
  		       "Failure attempting to write alias to file within %s",
  		       fname, "add_to_alias_text"));
! 	    dprint(2, (debugfile, "** %s **\n", error_description(err)));
  	    error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntWrite,
  		   "Couldn't write alias to file %s!"), fname);
  	    fclose(file);
***************
*** 618,623 ****
--- 692,698 ----
  	register int i;
  	int num_aliases;
  	int delete_continues;
+ 	int err;
  
  	delete_continues = FALSE;
  
***************
*** 630,639 ****
  	save_file_stats(fname);
  
  	if ((file = fopen(fname, "r")) == NULL) {
  	  dprint(2, (debugfile, 
  		 "Failure attempting to delete alias from file %s within %s",
  		   fname, "delete_from_alias_text"));
! 	  dprint(2, (debugfile, "** %s **\n", error_description(errno)));
  	  error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntOpenDelete,
  		 "Couldn't open %s to delete alias!"), fname);
  	  return(1);
--- 705,715 ----
  	save_file_stats(fname);
  
  	if ((file = fopen(fname, "r")) == NULL) {
+ 	  err = errno;
  	  dprint(2, (debugfile, 
  		 "Failure attempting to delete alias from file %s within %s",
  		   fname, "delete_from_alias_text"));
! 	  dprint(2, (debugfile, "** %s **\n", error_description(err)));
  	  error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntOpenDelete,
  		 "Couldn't open %s to delete alias!"), fname);
  	  return(1);
***************
*** 640,649 ****
  	}
  
  	if ((tmp_file = fopen(tmpfname, "w")) == NULL) {
  	  dprint(2, (debugfile, 
  		 "Failure attempting to open temp file %s within %s",
  		   tmpfname, "delete_from_alias_text"));
! 	  dprint(2, (debugfile, "** %s **\n", error_description(errno)));
  	  error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntOpenTemp,
  	  	 "Couldn't open tempfile %s to delete alias!"), tmpfname);
  	  return(1);
--- 716,726 ----
  	}
  
  	if ((tmp_file = fopen(tmpfname, "w")) == NULL) {
+ 	  err = errno;
  	  dprint(2, (debugfile, 
  		 "Failure attempting to open temp file %s within %s",
  		   tmpfname, "delete_from_alias_text"));
! 	  dprint(2, (debugfile, "** %s **\n", error_description(err)));
  	  error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntOpenTemp,
  	  	 "Couldn't open tempfile %s to delete alias!"), tmpfname);
  	  return(1);
***************
*** 679,688 ****
  	  }
  	  if (! delete_continues) {
  	    if (fprintf(tmp_file,"%s", line_in_file) == EOF) {
  	      dprint(2, (debugfile,
  		"Failure attempting to write to temp file %s within %s",
  		tmpfname, "delete_from_alias_text"));
! 	      dprint(2, (debugfile, "** %s **\n", error_description(errno)));
  	      error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntWriteTemp,
  		"Couldn't write to tempfile %s!"), tmpfname);
  	      fclose(file);
--- 756,766 ----
  	  }
  	  if (! delete_continues) {
  	    if (fprintf(tmp_file,"%s", line_in_file) == EOF) {
+ 	      err = errno;
  	      dprint(2, (debugfile,
  		"Failure attempting to write to temp file %s within %s",
  		tmpfname, "delete_from_alias_text"));
! 	      dprint(2, (debugfile, "** %s **\n", error_description(err)));
  	      error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntWriteTemp,
  		"Couldn't write to tempfile %s!"), tmpfname);
  	      fclose(file);
***************
*** 706,756 ****
  	return(0);
  }
  
- delete_alias_files()
- {
- /*
-  *	This routine remove all the alias text, hash, and data files.
-  *	This is called from delete_aliases when there are no user aliases
-  *	to be kept.
-  */
- 
- 	char fname[SLEN];
- 
- 	sprintf(fname,"%s/%s", home, ALIAS_TEXT);
- 	if (unlink(fname)) {
- 	  error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntDeleteText,
- 		 "Could not delete alias text file %s!"), fname);
- 	  sleep(2);
- 	}
- 
- 	if (user_hash != NULL) {
- 	    dbz_close(user_hash);
- 	    user_hash = NULL;
- 	}
- 
- 	sprintf(fname,"%s/%s", home, ALIAS_DATA);
- 	if (unlink(fname)) {
- 	  error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntDeleteData,
- 	  	 "Could not delete alias data file %s!"), fname);
- 	  sleep(2);
- 	}
- 
- 	sprintf(fname,"%s/%s.dir", home, ALIAS_DATA);
- 	if (unlink(fname)) {
- 	  error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntDeleteHash,
- 	  	 "Could not delete alias hash file %s!"), fname);
- 	  sleep(2);
- 	}
- 
- 	sprintf(fname,"%s/%s.pag", home, ALIAS_DATA);
- 	if (unlink(fname)) {
- 	  error1(catgets(elm_msg_cat, AliasesSet, AliasesCouldntDeleteHash,
- 	  	 "Could not delete alias hash file %s!"), fname);
- 	  sleep(2);
- 	}
- 
- }
- 
  alias()
  {
  /*
--- 784,789 ----
***************
*** 1053,1058 ****
--- 1086,1097 ----
  	sprintf(itextfile, "%s/%s", home, ALIAS_TEXT);
  	sprintf(odatafile, "%s/%s", home, ALIAS_DATA);
  
+ /*
+  *	We need to unlimit everything since aliases are 
+  * 	eing read in from scratch.
+  */
+ 	selected = 0;
+ 
  	na = do_newalias(itextfile, odatafile, TRUE, FALSE);
  	if (na >= 0) {
  	    error1(catgets(elm_msg_cat, AliasesSet, AliasesReReading,
***************
*** 1306,1312 ****
   *	Get an alias (name, address, etc.) from the data file
   */
  
! 	int new_max;
  	register struct alias_rec	**new_aliases, *a;
  	struct alias_rec	ar;
  	FILE *data_file = db->dbz_basef;
--- 1345,1351 ----
   *	Get an alias (name, address, etc.) from the data file
   */
  
! 	long new_max;
  	register struct alias_rec	**new_aliases, *a;
  	struct alias_rec	ar;
  	FILE *data_file = db->dbz_basef;
***************
*** 1364,1370 ****
  	aliases[current] = a;
  	fread((char *) (a + 1), ar.length, 1, data_file);
  	*a = ar;
! 	new_max = (int) (a + 1);
  	a->alias += new_max;
  	a->last_name += new_max;
  	a->name += new_max;
--- 1403,1409 ----
  	aliases[current] = a;
  	fread((char *) (a + 1), ar.length, 1, data_file);
  	*a = ar;
! 	new_max = (long) (a + 1);
  	a->alias += new_max;
  	a->last_name += new_max;
  	a->name += new_max;

Index: src/calendar.c
Prereq: 5.1
*** ../elm2.4/src/calendar.c	Sat Oct  3 18:58:47 1992
--- src/calendar.c	Wed Nov 25 19:47:10 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: calendar.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: calendar.c,v 5.2 1992/11/26 00:46:50 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: calendar.c,v $
+  * Revision 5.2  1992/11/26  00:46:50  syd
+  * Fix how errno is used so err is inited and used instead
+  * as errno gets overwritten by print system call
+  * From: Syd
+  *
   * Revision 5.1  1992/10/03  22:58:40  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 48,61 ****
  {
  	FILE *calendar;
  	int  count;
  
  	/* First step is to open the calendar file for appending... **/
  
  	if (can_open(calendar_file, "a") != 0) {
  	  dprint(2, (debugfile,
  		  "Error: wrong permissions to append to calendar %s\n",
  		  calendar_file));
! 	  dprint(2, (debugfile, "** - %s **\n", error_description(errno)));
  	  error1(catgets(elm_msg_cat, ErrorSet, ErrorCalendarCanOpen,
  		  "Not able to append to file %s!"), calendar_file);
  	  return; 
--- 53,68 ----
  {
  	FILE *calendar;
  	int  count;
+ 	int  err;
  
  	/* First step is to open the calendar file for appending... **/
  
  	if (can_open(calendar_file, "a") != 0) {
+ 	  err = errno;
  	  dprint(2, (debugfile,
  		  "Error: wrong permissions to append to calendar %s\n",
  		  calendar_file));
! 	  dprint(2, (debugfile, "** - %s **\n", error_description(err)));
  	  error1(catgets(elm_msg_cat, ErrorSet, ErrorCalendarCanOpen,
  		  "Not able to append to file %s!"), calendar_file);
  	  return; 
***************
*** 64,73 ****
  	save_file_stats(calendar_file);
  
  	if ((calendar = fopen(calendar_file,"a")) == NULL) {
  	  dprint(2, (debugfile, 
  		"Error: couldn't append to calendar file %s (scan)\n", 
  		calendar_file));
! 	  dprint(2, (debugfile, "** - %s **\n", error_description(errno)));
  	  error1(catgets(elm_msg_cat, ErrorSet, ErrorCalendarAppend,
  		  "Couldn't append to file %s!"), calendar_file);
  	  return; 
--- 71,81 ----
  	save_file_stats(calendar_file);
  
  	if ((calendar = fopen(calendar_file,"a")) == NULL) {
+ 	  err = errno;
  	  dprint(2, (debugfile, 
  		"Error: couldn't append to calendar file %s (scan)\n", 
  		calendar_file));
! 	  dprint(2, (debugfile, "** - %s **\n", error_description(err)));
  	  error1(catgets(elm_msg_cat, ErrorSet, ErrorCalendarAppend,
  		  "Couldn't append to file %s!"), calendar_file);
  	  return; 

Index: src/curses.c
Prereq: 5.7
*** ../elm2.4/src/curses.c	Tue Nov 10 15:20:25 1992
--- src/curses.c	Thu Dec 10 20:45:31 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: curses.c,v 5.7 1992/11/07 20:45:39 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: curses.c,v 5.8 1992/12/11 01:45:04 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,24 ----
   *
   *******************************************************************************
   * $Log: curses.c,v $
+  * Revision 5.8  1992/12/11  01:45:04  syd
+  * remove sys/types.h include, it is now included by defs.h
+  * and this routine includes defs.h or indirectly includes defs.h
+  * From: Syd
+  *
   * Revision 5.7  1992/11/07  20:45:39  syd
   * add no tite flag on options that should not use ti/te
   * Hack by Syd
***************
*** 78,84 ****
  #include <ctype.h>
  
  #ifdef PTEM
- #  include <sys/types.h>
  #  include <sys/stream.h>
  #  include <sys/ptem.h>
  #endif
--- 83,88 ----

Index: src/date.c
Prereq: 5.2
*** ../elm2.4/src/date.c	Tue Nov 17 14:10:56 1992
--- src/date.c	Thu Dec 10 20:45:32 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: date.c,v 5.2 1992/11/15 02:10:11 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: date.c,v 5.4 1992/12/11 01:45:04 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,28 ----
   *
   *******************************************************************************
   * $Log: date.c,v $
+  * Revision 5.4  1992/12/11  01:45:04  syd
+  * remove sys/types.h include, it is now included by defs.h
+  * and this routine includes defs.h or indirectly includes defs.h
+  * From: Syd
+  *
+  * Revision 5.3  1992/12/07  02:57:09  syd
+  * convert long to time_t where relevant
+  * From: Syd via prompting from Jim Brown
+  *
   * Revision 5.2  1992/11/15  02:10:11  syd
   * remove no longer used tzname
   * From: Syd
***************
*** 29,35 ****
  
  
  #include "headers.h"
- #include <sys/types.h>
  
  #ifdef I_TIME
  #  include <time.h>
--- 38,43 ----
***************
*** 162,172 ****
  
  	static char buffer[SLEN];	/* static character buffer       */
  	struct tm *the_time;		/* Time structure, see CTIME(3C) */
- 	long	   junk;		/* time in seconds....		 */
  
  #ifdef BSD
  	struct  timeval  time_val;		
  	struct  timezone time_zone;
  #endif
  
  #ifdef BSD
--- 170,182 ----
  
  	static char buffer[SLEN];	/* static character buffer       */
  	struct tm *the_time;		/* Time structure, see CTIME(3C) */
  
  #ifdef BSD
  	struct  timeval  time_val;		
  	struct  timezone time_zone;
+ 	long	   junk;		/* time in seconds....		 */
+ #else
+ 	time_t	   junk;		/* time in seconds....		 */
  #endif
  
  #ifdef BSD
***************
*** 173,179 ****
  	gettimeofday(&time_val, &time_zone);
  	junk = time_val.tv_sec;
  #else
! 	junk = time((long *) 0);	/* this must be here for it to work! */
  #endif
  	the_time = localtime(&junk);
  
--- 183,189 ----
  	gettimeofday(&time_val, &time_zone);
  	junk = time_val.tv_sec;
  #else
! 	junk = time((time_t *) 0);	/* this must be here for it to work! */
  #endif
  	the_time = localtime(&junk);
  
***************
*** 194,200 ****
  char *
  elm_date_str(buf, seconds)
  char *buf;
! long seconds;
  {
  	struct tm *tmbuf;
  
--- 204,210 ----
  char *
  elm_date_str(buf, seconds)
  char *buf;
! time_t seconds;
  {
  	struct tm *tmbuf;
  
***************
*** 216,222 ****
  struct header_rec *entry;
  {
  	struct tm *tmbuf;
! 	long seconds;
  
  	seconds = entry->time_sent + entry->tz_offset;
  	tmbuf = gmtime(&seconds);
--- 226,232 ----
  struct header_rec *entry;
  {
  	struct tm *tmbuf;
! 	time_t seconds;
  
  	seconds = entry->time_sent + entry->tz_offset;
  	tmbuf = gmtime(&seconds);

Index: src/edit.c
Prereq: 5.2
*** ../elm2.4/src/edit.c	Tue Nov 17 14:11:04 1992
--- src/edit.c	Thu Dec 10 20:56:51 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: edit.c,v 5.2 1992/11/14 21:53:49 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: edit.c,v 5.4 1992/12/07 14:53:21 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,28 ----
   *
   *******************************************************************************
   * $Log: edit.c,v $
+  * Revision 5.4  1992/12/07  14:53:21  syd
+  * Fix typos in edit.c
+  * From: Bo.Asbjorn.Muldbak <bam@jutland.ColumbiaSC.NCR.COM>
+  *
+  * Revision 5.3  1992/11/26  00:46:13  syd
+  * changes to first change screen back (Raw off) and then issue final
+  * error message.
+  * From: Syd
+  *
   * Revision 5.2  1992/11/14  21:53:49  syd
   * When elm copies the temp mailbox back to the mail spool to resync or
   * quit, it changes to the mailgroup before attempting to diddle in the
***************
*** 46,51 ****
--- 55,86 ----
  
  #ifdef ALLOW_MAILBOX_EDITING
  
+ static void copy_failed_emergency_exit(cur_folder, edited_file, linked)
+ char *cur_folder, *edited_file;
+ int linked;
+ {
+ 	int err = errno;
+ 
+ 	MoveCursor(LINES, 0);
+ 	Raw(OFF);
+ 
+ 	if (linked)
+ 		MCprintf(catgets(elm_msg_cat, ElmSet, ElmCouldntLinkMailfile,
+ 			"\nCouldn't link %s to mailfile %s!\n"),
+ 			edited_file, cur_folder);
+ 	else
+ 		MCprintf(catgets(elm_msg_cat, ElmSet, ElmCouldntCopyMailfile,
+ 			"\nCouldn't copy %s to mailfile %s!\n"),
+ 			cur_folder, edited_file);
+ 
+ 	printf(catgets(elm_msg_cat, ElmSet, ElmCheckOutMail,
+ 		"\nYou'll need to check out %s for your mail.\n"),
+ 		edited_file);
+ 	printf("** %s. **\n", error_description(err));
+ 	unlock();					/* ciao!*/
+ 	emergency_exit();
+ }
+ 
  edit_mailbox()
  {
  	/** Allow the user to edit their folder, always resynchronizing
***************
*** 129,150 ****
  
  	     while ((len = mail_gets(buffer, SLEN, real_folder)) != 0)
  	       if (fwrite(buffer, 1, len, temp_folder) != len) {
! 		 Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmCouldntCopyMailfile,
! 		    "\n\rCouldn't copy %s to mailfile %s!\n\r"),
! 		    2, cur_folder, edited_file);
! 		 Write_to_screen("** %s. **\n\r", 1, error_description(errno));
! 		 unlock();					/* ciao!*/
! 	         emergency_exit();
  	       }
  
  	     fclose(real_folder);
  	     if (fclose(temp_folder)) {
! 	       Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmCouldntCopyMailfile,
! 		  "\n\rCouldn't copy %s to mailfile %s!\n\r"),
! 		  2, cur_folder, edited_file);
! 	       Write_to_screen("** %s. **\n\r", 1, error_description(errno));
! 	       unlock();					/* ciao!*/
! 	       emergency_exit();
  	     }
  
   	   } else lock(OUTGOING);
--- 164,175 ----
  
  	     while ((len = mail_gets(buffer, SLEN, real_folder)) != 0)
  	       if (fwrite(buffer, 1, len, temp_folder) != len) {
! 	         copy_failed_emergency_exit(cur_folder, edited_file, FALSE);
  	       }
  
  	     fclose(real_folder);
  	     if (fclose(temp_folder)) {
! 	       copy_failed_emergency_exit(cur_folder, edited_file, FALSE);
  	     }
  
   	   } else lock(OUTGOING);
***************
*** 162,187 ****
  	     if (errno == EXDEV || errno == EEXIST) {
  	       /* attempt to link across file systems */
     	       if (copy(edited_file, cur_folder) != 0) {
! 		 Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmCouldntCopyMailfile,
! 		    "\n\rCouldn't copy %s to mailfile %s!\n\r"),
! 		    2, edited_file, cur_folder);
! 		 Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmCheckOutMail,
! 		    "\n\rYou'll need to check out %s for your mail.\n\r"),
! 		    1, edited_file);
! 		 Write_to_screen("** %s. **\n\r", 1, error_description(errno));
! 		 unlock();					/* ciao!*/
! 		 emergency_exit();
  	       }
  	     } else {
! 		Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmCouldntLinkMailfile,
! 		  "\n\rCouldn't link %s to mailfile %s!\n\r"),
! 		  2, edited_file, cur_folder);
! 		Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmCheckOutMail,
! 		  "\n\rYou'll need to check out %s for your mail.\n\r"),
! 		  1, edited_file);
! 		Write_to_screen("** %s. **\n\r", 1, error_description(errno));
! 	        unlock();					/* ciao!*/
! 	        emergency_exit();
  	     }
  	   }
  
--- 187,196 ----
  	     if (errno == EXDEV || errno == EEXIST) {
  	       /* attempt to link across file systems */
     	       if (copy(edited_file, cur_folder) != 0) {
! 	         copy_failed_emergency_exit(cur_folder, edited_file, FALSE);
  	       }
  	     } else {
! 	         copy_failed_emergency_exit(cur_folder, edited_file, TRUE);
  	     }
  	   }
  

Index: src/editmsg.c
Prereq: 5.4
*** ../elm2.4/src/editmsg.c	Wed Nov 25 14:10:38 1992
--- src/editmsg.c	Fri Dec 11 20:44:19 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: editmsg.c,v 5.4 1992/11/22 00:03:28 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: editmsg.c,v 5.7 1992/12/12 01:44:03 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.7 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,33 ----
   *
   *******************************************************************************
   * $Log: editmsg.c,v $
+  * Revision 5.7  1992/12/12  01:44:03  syd
+  * Fix building editor wrap problem
+  * From: Syd via prompting from vogt@isa.de (Gerald Vogt)
+  *
+  * Revision 5.6  1992/12/11  01:56:11  syd
+  * If sigset() and sigrelse() are available, release signal before
+  * using longjmp() to leave signal handler.
+  * From: chip@tct.com (Chip Salzenberg)
+  *
+  * Revision 5.5  1992/11/26  00:46:13  syd
+  * changes to first change screen back (Raw off) and then issue final
+  * error message.
+  * From: Syd
+  *
   * Revision 5.4  1992/11/22  00:03:28  syd
   * Handle the case where a system does
   * >         #define jmp_buf sigjmp_buf
***************
*** 241,254 ****
  	
  	char buffer[SLEN];
  
! 	fclose(edit_fd);
! 
! 	if ((edit_fd = fopen(filename, "r")) == NULL) {
! 	  Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmCantOpenReadBail,
! 	      "\n\rPanic: Can't open file for reading!  Emergency Exit!\n\r"),
! 	      0);
! 	  emergency_exit();
! 	}
  
  	Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmEditmsgPrintTo,
  	    "\n\rTo: %s\n\r"), 1, format_long(to, 4));
--- 255,262 ----
  	
  	char buffer[SLEN];
  
! 	fflush(edit_fd);
! 	fseek(edit_fd, 0L, 0);
  
  	Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmEditmsgPrintTo,
  	    "\n\rTo: %s\n\r"), 1, format_long(to, 4));
***************
*** 264,278 ****
  	  CarriageReturn();
  	}
  
- 	fclose(edit_fd);
- 
- 	if ((edit_fd = fopen(filename, "a")) == NULL) {
- 	  Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmCantOpenAppendBail,
- 	      "\n\rPanic: Can't reopen file for appending!  Emergency Exit!\n\r"),
- 	      0);
- 	  emergency_exit();
- 	}
- 
  	Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmEditmsgPrintContinue,
  	    "\n\r(Continue entering message.)\n\r"), 0);
  }
--- 272,277 ----
***************
*** 430,435 ****
--- 429,443 ----
  	  Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmEditmsgCancelled,
  		"(Interrupt. Letter cancelled.)\n\r"), 0);
  
+ #if defined(SIGSET) && defined(HASSIGHOLD)
+ 	/*
+ 	 * During execution of a signal handler set with sigset(),
+ 	 * the originating signal is held.  It must be released or
+ 	 * it cannot recur.
+ 	 */
+ 	sigrelse(sig);
+ #endif /* SIGSET and HASSIGHOLD */
+ 
  	LONGJMP(edit_location, 1);		/* get back */
  }
  
***************
*** 445,450 ****
--- 453,459 ----
  
  	char buffer[SLEN];
  	register int stat, return_value = 0, old_raw;
+ 	int  err;
  
  	buffer[0] = '\0';
  
***************
*** 479,488 ****
  	  transmit_functions(OFF);		/* function keys are local */
  
  	if ((stat = system_call(buffer, SY_ENAB_SIGHUP|SY_DUMPSTATE)) == -1) {
  	  dprint(1,(debugfile, 
  		  "System call failed with stat %d (edit_the_message)\n", 
  		  stat));
! 	  dprint(1, (debugfile, "** %s **\n", error_description(errno)));
  	  ClearLine(LINES-1);
  	  error1(catgets(elm_msg_cat, ElmSet, ElmCantInvokeEditor,
  	    "Can't invoke editor '%s' for composition."), editor);
--- 488,498 ----
  	  transmit_functions(OFF);		/* function keys are local */
  
  	if ((stat = system_call(buffer, SY_ENAB_SIGHUP|SY_DUMPSTATE)) == -1) {
+ 	  err = errno;
  	  dprint(1,(debugfile, 
  		  "System call failed with stat %d (edit_the_message)\n", 
  		  stat));
! 	  dprint(1, (debugfile, "** %s **\n", error_description(err)));
  	  ClearLine(LINES-1);
  	  error1(catgets(elm_msg_cat, ElmSet, ElmCantInvokeEditor,
  	    "Can't invoke editor '%s' for composition."), editor);
***************
*** 516,521 ****
--- 526,532 ----
  	int      old_raw, is_wrapped = 0;
  	SIGHAND_TYPE	edit_interrupt();
  	SIGHAND_TYPE	(*oldint)(), (*oldquit)();
+ 	int  err;
  
  	/* The built-in editor is not re-entrant! */
  	if (builtin_editor_active) {
***************
*** 533,546 ****
  		  "(Continue entering message.  Type ^D or '.' on a line by itself to end.)\n\r");
  	}
  
! 	if ((edit_fd = fopen(filename, "a")) == NULL) {
  	  sprintf(buffer, catgets(elm_msg_cat, ElmSet, ElmCouldntOpenAppend,
  	    "Couldn't open %s for appending [%s]."),
! 	    filename, error_description(errno));
  	  Write_to_screen(buffer, 0);
  	  dprint(1, (debugfile,
  		"Error encountered trying to open file %s;\n", filename));
! 	  dprint(1, (debugfile, "** %s **\n", error_description(errno)));
  	  return(1);
  	}
  
--- 544,558 ----
  		  "(Continue entering message.  Type ^D or '.' on a line by itself to end.)\n\r");
  	}
  
! 	if ((edit_fd = fopen(filename, "a+")) == NULL) {
! 	  err = errno;
  	  sprintf(buffer, catgets(elm_msg_cat, ElmSet, ElmCouldntOpenAppend,
  	    "Couldn't open %s for appending [%s]."),
! 	    filename, error_description(err));
  	  Write_to_screen(buffer, 0);
  	  dprint(1, (debugfile,
  		"Error encountered trying to open file %s;\n", filename));
! 	  dprint(1, (debugfile, "** %s **\n", error_description(err)));
  	  return(1);
  	}
  
***************
*** 637,643 ****
  	  		     fclose(edit_fd);
  			     (void) edit_the_message(filename,0);
  			     strcpy(editor, buffer);
! 			     edit_fd = fopen(filename, "a");
  			     Write_to_screen(post_ed_continue, 0);
  			     goto more_input;
  			   }
--- 649,655 ----
  	  		     fclose(edit_fd);
  			     (void) edit_the_message(filename,0);
  			     strcpy(editor, buffer);
! 			     edit_fd = fopen(filename, "a+");
  			     Write_to_screen(post_ed_continue, 0);
  			     goto more_input;
  			   }
***************
*** 657,663 ****
  			  fclose(edit_fd);
  			  (void) edit_the_message(filename,0);
  			  strcpy(editor, buffer);
! 			  edit_fd = fopen(filename, "a");
  			  Write_to_screen(post_ed_continue, 0);
  			  goto more_input;
  
--- 669,675 ----
  			  fclose(edit_fd);
  			  (void) edit_the_message(filename,0);
  			  strcpy(editor, buffer);
! 			  edit_fd = fopen(filename, "a+");
  			  Write_to_screen(post_ed_continue, 0);
  			  goto more_input;
  
***************
*** 672,678 ****
  			    fclose(edit_fd);
  			    (void) edit_the_message(filename,0);
  			    strcpy(editor, buffer);
! 			    edit_fd = fopen(filename, "a");
  			    Write_to_screen(post_ed_continue, 0);
  			    goto more_input;
  			  }
--- 684,690 ----
  			    fclose(edit_fd);
  			    (void) edit_the_message(filename,0);
  			    strcpy(editor, buffer);
! 			    edit_fd = fopen(filename, "a+");
  			    Write_to_screen(post_ed_continue, 0);
  			    goto more_input;
  			  }

Index: src/elm.c
Prereq: 5.5
*** ../elm2.4/src/elm.c	Wed Nov 25 14:10:38 1992
--- src/elm.c	Thu Dec 10 20:45:33 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: elm.c,v 5.5 1992/11/22 00:03:56 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.5 $   $State: Exp $
   *
   * This file and all associated files and documentation:
   *			Copyright (c) 1988-1992 USENET Community Trust
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: elm.c,v 5.8 1992/12/11 01:45:04 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.8 $   $State: Exp $
   *
   * This file and all associated files and documentation:
   *			Copyright (c) 1988-1992 USENET Community Trust
***************
*** 15,20 ****
--- 15,34 ----
   *
   *******************************************************************************
   * $Log: elm.c,v $
+  * Revision 5.8  1992/12/11  01:45:04  syd
+  * remove sys/types.h include, it is now included by defs.h
+  * and this routine includes defs.h or indirectly includes defs.h
+  * From: Syd
+  *
+  * Revision 5.7  1992/12/07  02:58:13  syd
+  * fix long -> time_t
+  * From: Syd
+  *
+  * Revision 5.6  1992/11/26  00:46:13  syd
+  * changes to first change screen back (Raw off) and then issue final
+  * error message.
+  * From: Syd
+  *
   * Revision 5.5  1992/11/22  00:03:56  syd
   * Fix segmentation violation on restricted alias page jump.
   * From: "Robert L. Howard" <robert.howard@matd.gatech.edu>
***************
*** 53,59 ****
  #  include <sys/time.h>
  #endif
  #ifdef BSD
- #  include <sys/types.h>
  #  include <sys/timeb.h>
  
  #undef        toupper
--- 67,72 ----
***************
*** 141,149 ****
  	      dprint(1, (debugfile,
  		    "Error: given file %s as folder - unreadable (%s)!\n", 
  		    cur_folder, error_description(errno)));
  	      fprintf(stderr, catgets(elm_msg_cat, ElmSet, ElmCantOpenFolderRead,
  		"Can't open folder '%s' for reading!\n"), cur_folder);
! 	      leave();
  	      }
  
  	    newmbox(cur_folder, TRUE);	/* last won't be touched! */
--- 154,163 ----
  	      dprint(1, (debugfile,
  		    "Error: given file %s as folder - unreadable (%s)!\n", 
  		    cur_folder, error_description(errno)));
+ 	      Raw(OFF);
  	      fprintf(stderr, catgets(elm_msg_cat, ElmSet, ElmCantOpenFolderRead,
  		"Can't open folder '%s' for reading!\n"), cur_folder);
! 	      leave(0);
  	      }
  
  	    newmbox(cur_folder, TRUE);	/* last won't be touched! */
***************
*** 425,431 ****
  			   if((i=options()) > 0)
  			     get_page(current);
  			   else if(i < 0)
! 			     leave();
  			   redraw++;	/* always fix da screen... */
  			   break;
  
--- 439,445 ----
  			   if((i=options()) > 0)
  			     get_page(current);
  			   else if(i < 0)
! 			     leave(0);
  			   redraw++;	/* always fix da screen... */
  			   break;
  
***************
*** 522,528 ****
  			     catgets(elm_msg_cat, ElmSet, ElmQuickExit,
  			     "Quick Exit"));
                             fflush(stdout);
! 			   leave();
  			   break;
  
  	    case ctrl('Q') :
--- 536,542 ----
  			     catgets(elm_msg_cat, ElmSet, ElmQuickExit,
  			     "Quick Exit"));
                             fflush(stdout);
! 			   leave(0);
  			   break;
  
  	    case ctrl('Q') :
***************
*** 533,539 ****
  			   exit_prog();
  			   break;
  
!             case EOF :  leave();  /* Read failed, control tty died? */
                          break;
  	    
  	    case '@'    : debug_screen();  redraw++;	break;
--- 547,553 ----
  			   exit_prog();
  			   break;
  
!             case EOF :  leave(0);  /* Read failed, control tty died? */
                          break;
  	    
  	    case '@'    : debug_screen();  redraw++;	break;
***************
*** 631,637 ****
  	      in the record structure. **/
  	
  	char buffer[SLEN];
! 	long header_time;
  	register struct header_rec *current_header = headers[current-1];
  
  	ClearScreen();
--- 645,651 ----
  	      in the record structure. **/
  	
  	char buffer[SLEN];
! 	time_t header_time;
  	register struct header_rec *current_header = headers[current-1];
  
  	ClearScreen();

Index: src/encode.c
Prereq: 5.1
*** ../elm2.4/src/encode.c	Sat Oct  3 18:58:52 1992
--- src/encode.c	Sun Dec  6 21:34:57 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: encode.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: encode.c,v 5.2 1992/12/07 02:34:56 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,26 ----
   *
   *******************************************************************************
   * $Log: encode.c,v $
+  * Revision 5.2  1992/12/07  02:34:56  syd
+  * Traditional C used 'unsigned preserving' rules when an integral data
+  * value is widened to integer and ANSI C changed the rules to 'value
+  * preserving'. This is one of the few things that the ANSI X3J11 comitte
+  * did that might break existing programs.  Casting to (int)
+  * From: Bo.Asbjorn.Muldbak <bam@jutland.ColumbiaSC.NCR.COM>
+  *
   * Revision 5.1  1992/10/03  22:58:40  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 136,145 ****
  	    for ( j = 0; j < RN; j++ )		/* rotor forwards */
  	      i = r[(i+p[j])%RTRSZ][j];
  
! 	    i = ((h[(i+ph)%RTRSZ])-ph+RTRSZ)%RTRSZ;	/* half rotor */
  
  	    for ( j--  ; j >= 0; j-- )		/* rotor backwards */
! 	      i = (ir[i][j]+RTRSZ-p[j])%RTRSZ;
  
  	    j = 0;				/* rotate rotors */
  	    p[0]++;
--- 143,152 ----
  	    for ( j = 0; j < RN; j++ )		/* rotor forwards */
  	      i = r[(i+p[j])%RTRSZ][j];
  
! 	    i = (((int)h[(i+ph)%RTRSZ])-ph+RTRSZ)%RTRSZ;	/* half rotor */
  
  	    for ( j--  ; j >= 0; j-- )		/* rotor backwards */
! 	      i = ((int)ir[i][j]+RTRSZ-p[j])%RTRSZ;
  
  	    j = 0;				/* rotate rotors */
  	    p[0]++;

Index: src/expires.c
Prereq: 5.1
*** ../elm2.4/src/expires.c	Sat Oct  3 18:58:53 1992
--- src/expires.c	Sun Dec  6 21:59:02 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: expires.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: expires.c,v 5.2 1992/12/07 02:58:56 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,23 ----
   *
   *******************************************************************************
   * $Log: expires.c,v $
+  * Revision 5.2  1992/12/07  02:58:56  syd
+  * Fix long -> time_t
+  * From: Syd
+  *
   * Revision 5.1  1992/10/03  22:58:40  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 47,58 ****
  int  *message_status;
  {
  	struct tm *timestruct;
! 	long thetime;
  	char word1[WLEN], word2[WLEN], word3[WLEN], word4[WLEN], word5[WLEN];
  	int  month = 0, day = 0, year = 0, hour = 0, minute = 0;
  #ifndef	_POSIX_SOURCE
  	struct tm *localtime();
! 	long time();
  #endif
  
  	/** first step is to break down the date given into MM DD YY HH MM
--- 51,62 ----
  int  *message_status;
  {
  	struct tm *timestruct;
! 	time_t thetime;
  	char word1[WLEN], word2[WLEN], word3[WLEN], word4[WLEN], word5[WLEN];
  	int  month = 0, day = 0, year = 0, hour = 0, minute = 0;
  #ifndef	_POSIX_SOURCE
  	struct tm *localtime();
! 	time_t time();
  #endif
  
  	/** first step is to break down the date given into MM DD YY HH MM
***************
*** 115,121 ****
  
  	/** next let's get the current time and date, please **/
  
! 	thetime = time((long *) 0);
  
  	timestruct = localtime(&thetime);
  
--- 119,125 ----
  
  	/** next let's get the current time and date, please **/
  
! 	thetime = time((time_t *) 0);
  
  	timestruct = localtime(&thetime);
  

Index: src/file.c
Prereq: 5.5
*** ../elm2.4/src/file.c	Mon Nov  2 15:51:46 1992
--- src/file.c	Sun Dec  6 21:38:46 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: file.c,v 5.5 1992/10/30 21:01:49 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.5 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: file.c,v 5.7 1992/12/07 02:38:45 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.7 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,38 ----
   *
   *******************************************************************************
   * $Log: file.c,v $
+  * Revision 5.7  1992/12/07  02:38:45  syd
+  * When ELM is reporting "appending to <foldername>" I never get to see
+  * but a flash of light, before the message line has been replaced by a
+  * dummy "Messages saved" string.  And if you happen to have mistyped the
+  * foldername or the leading '=', you never see the foldername.
+  *
+  * This fix will change file.c to show either
+  *
+  * 	Message <what> to <foldername>
+  *
+  * or
+  * 	<#> messages <what> to <foldername>
+  * From: Bo.Asbjorn.Muldbak <bam@jutland.ColumbiaSC.NCR.COM>
+  *
+  * Revision 5.6  1992/11/26  01:46:26  syd
+  * add Decode option to copy_message, convert copy_message to
+  * use bit or for options.
+  * From: Syd and bjoerns@stud.cs.uit.no (Bjoern Stabell)
+  *
   * Revision 5.5  1992/10/30  21:01:49  syd
   * More changes to folder creation confirmation
   * From: Larry Philps <larryp@sco.COM>
***************
*** 155,161 ****
  	**/
  
  	register int	tagged = 0, i, oldstat, appending = 0,
! 			is_ordinary_file;
  	int mesgnum;	/* message whose address is used for save-by-name fn */
  	char	filename[SLEN], address[LONG_STRING], buffer[LONG_STRING],
  		ch;
--- 174,180 ----
  	**/
  
  	register int	tagged = 0, i, oldstat, appending = 0,
! 			is_ordinary_file, scount = 0;
  	int mesgnum;	/* message whose address is used for save-by-name fn */
  	char	filename[SLEN], address[LONG_STRING], buffer[LONG_STRING],
  		ch;
***************
*** 339,347 ****
  	if(*redraw) silently = TRUE;
  
  	for (i=0; i < message_count; i++) 	/* save each tagged msg */
! 	  if (headers[i]->status & TAGGED)
  	    save_message(i, filename, save_file, (tagged > 1), appending++, 
  			 silently, delete);
  
  	fclose(save_file);
  
--- 358,368 ----
  	if(*redraw) silently = TRUE;
  
  	for (i=0; i < message_count; i++) 	/* save each tagged msg */
! 	  if (headers[i]->status & TAGGED) {
  	    save_message(i, filename, save_file, (tagged > 1), appending++, 
  			 silently, delete);
+ 	    scount++;
+ 	  }
  
  	fclose(save_file);
  
***************
*** 348,358 ****
  	restore_file_stats(filename);
  
  	if (tagged == 1)
! 	  error1(catgets(elm_msg_cat, ElmSet, ElmMessageSaved,
! 		"Message %s."), delete ? saved_word: copied_word);
  	else if (tagged > 1)
! 	  error1(catgets(elm_msg_cat, ElmSet, ElmMessagesSaved,
! 		  "Messages %s."), delete ? saved_word: copied_word);
  	return(1);
  }
  
--- 369,382 ----
  	restore_file_stats(filename);
  
  	if (tagged == 1)
! 	  error2(catgets(elm_msg_cat, ElmSet, ElmMessageSaved,
! 		"Message %s to %s."), delete ? saved_word: copied_word,
! 		filename);
  	else if (tagged > 1)
! 	  error3(catgets(elm_msg_cat, ElmSet, ElmMessagesSaved,
! 		  "%d messages %s to %s."), scount, 
! 		  delete ? saved_word: copied_word,
! 		  filename);
  	return(1);
  }
  
***************
*** 386,392 ****
  	 */
  	if(is_new = ison(headers[number]->status, NEW))
  	  clearit(headers[number]->status, NEW);
! 	copy_message("", fd, FALSE, FALSE, TRUE, FALSE, FALSE);
  	if(is_new)
  	  setit(headers[number]->status, NEW);
  	current = save_current;
--- 410,416 ----
  	 */
  	if(is_new = ison(headers[number]->status, NEW))
  	  clearit(headers[number]->status, NEW);
! 	copy_message("", fd, CM_UPDATE_STATUS);
  	if(is_new)
  	  setit(headers[number]->status, NEW);
  	current = save_current;

Index: src/file_util.c
Prereq: 5.1
*** ../elm2.4/src/file_util.c	Sat Oct  3 18:58:54 1992
--- src/file_util.c	Thu Dec 10 20:45:33 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: file_util.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: file_util.c,v 5.3 1992/12/11 01:45:04 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,29 ----
   *
   *******************************************************************************
   * $Log: file_util.c,v $
+  * Revision 5.3  1992/12/11  01:45:04  syd
+  * remove sys/types.h include, it is now included by defs.h
+  * and this routine includes defs.h or indirectly includes defs.h
+  * From: Syd
+  *
+  * Revision 5.2  1992/11/26  00:46:13  syd
+  * changes to first change screen back (Raw off) and then issue final
+  * error message.
+  * From: Syd
+  *
   * Revision 5.1  1992/10/03  22:58:40  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 26,32 ****
  
  #include "headers.h"
  #include "s_elm.h"
- #include <sys/types.h>
  #include <sys/stat.h>
  #include <ctype.h>
  #include <errno.h>
--- 36,41 ----
***************
*** 50,55 ****
--- 59,65 ----
  bytes(name)
  char *name;
  {
+ 	int err;
  	/** return the number of bytes in the specified file.  This
  	    is to check to see if new mail has arrived....  (also
  	    see "fsize()" to see how we can get the same information
***************
*** 57,74 ****
  	**/
  
  	int ok = 1;
- 	extern int errno;	/* system error number! */
  	struct stat buffer;
  
  	if (stat(name, &buffer) != 0)
  	  if (errno != 2) {
  	    dprint(1,(debugfile,
  		     "Error: errno %s on fstat of file %s (bytes)\n", 
! 		     error_description(errno), name));
! 	    Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmErrorFstat,
! 		     "\n\rError attempting fstat on file %s!\n\r"),
! 		     1, name);
! 	    Write_to_screen("** %s. **\n\r", 1, error_description(errno));
  	    emergency_exit();
  	  }
  	  else
--- 67,86 ----
  	**/
  
  	int ok = 1;
  	struct stat buffer;
  
  	if (stat(name, &buffer) != 0)
  	  if (errno != 2) {
+ 	    err = errno;
+ 	    MoveCursor(LINES, 0);
+ 	    Raw(OFF);
  	    dprint(1,(debugfile,
  		     "Error: errno %s on fstat of file %s (bytes)\n", 
! 		     error_description(err), name));
! 	    printf(catgets(elm_msg_cat, ElmSet, ElmErrorFstat,
! 		     "\nError attempting fstat on file %s!\n"),
! 		     name);
! 	    printf("** %s. **\n", error_description(err));
  	    emergency_exit();
  	  }
  	  else
***************
*** 146,153 ****
  	}
  
  	if (prefix_str != NULL && fputs(prefix_str, fd) == EOF) {
! 	  Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmWriteFailedAppend,
! 		"\n\rWrite failed to tempfile in append\n\r"), 0);
  	  perror(filename);
  	  rm_temps_exit();
  	}
--- 158,167 ----
  	}
  
  	if (prefix_str != NULL && fputs(prefix_str, fd) == EOF) {
! 	  MoveCursor(LINES, 0);
! 	  Raw(OFF);
! 	  printf(catgets(elm_msg_cat, ElmSet, ElmWriteFailedAppend,
! 		"\nWrite failed to tempfile in append\n"));
  	  perror(filename);
  	  rm_temps_exit();
  	}
***************
*** 154,168 ****
  
  	while (len = fread(buffer, 1, VERY_LONG_STRING, my_fd))
  	  if (fwrite(buffer, 1, len, fd) != len) {
! 	      Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmWriteFailedAppend,
! 		      "\n\rWrite failed to tempfile in append\n\r"), 0);
  	      perror(filename);
  	      rm_temps_exit();
  	  }
  
  	if (fclose(my_fd) == EOF) {
! 	  Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmCloseFailedAppend,
! 		  "\n\rClose failed on tempfile in append\n\r"), 0);
  	  perror(filename);
  	  rm_temps_exit();
  	}
--- 168,186 ----
  
  	while (len = fread(buffer, 1, VERY_LONG_STRING, my_fd))
  	  if (fwrite(buffer, 1, len, fd) != len) {
! 	      MoveCursor(LINES, 0);
! 	      Raw(OFF);
! 	      printf(catgets(elm_msg_cat, ElmSet, ElmWriteFailedAppend,
! 		      "\nWrite failed to tempfile in append\n"));
  	      perror(filename);
  	      rm_temps_exit();
  	  }
  
  	if (fclose(my_fd) == EOF) {
! 	  MoveCursor(LINES, 0);
! 	  Raw(OFF);
! 	  printf(catgets(elm_msg_cat, ElmSet, ElmCloseFailedAppend,
! 		  "\nClose failed on tempfile in append\n"));
  	  perror(filename);
  	  rm_temps_exit();
  	}

Index: src/lock.c
Prereq: 5.6
*** ../elm2.4/src/lock.c	Tue Oct 27 11:17:29 1992
--- src/lock.c	Thu Dec 10 20:45:36 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: lock.c,v 5.6 1992/10/27 01:52:16 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.6 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: lock.c,v 5.10 1992/12/11 01:45:04 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.10 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,38 ----
   *
   *******************************************************************************
   * $Log: lock.c,v $
+  * Revision 5.10  1992/12/11  01:45:04  syd
+  * remove sys/types.h include, it is now included by defs.h
+  * and this routine includes defs.h or indirectly includes defs.h
+  * From: Syd
+  *
+  * Revision 5.9  1992/12/07  03:49:49  syd
+  * use BSD or not apollo on file.h include as its not valid
+  * for Apollos under sys5.3 compile type
+  * From: gordonb@mcil.comm.mot.com (Gordon Berkley)
+  *
+  * Revision 5.8  1992/12/07  02:23:35  syd
+  * Always init fcntlerr and flockerr so useage after ifdef code doesnt cause problem
+  * From: Syd via prompt from wdh@grouper.mkt.csd.harris.com (W. David Higgins)
+  *
+  * Revision 5.7  1992/11/26  00:46:13  syd
+  * changes to first change screen back (Raw off) and then issue final
+  * error message.
+  * From: Syd
+  *
   * Revision 5.6  1992/10/27  01:52:16  syd
   * Always include <sys/ioctl.h> in curses.c When calling ioctl()
   *
***************
*** 50,56 ****
  
  #include "headers.h"
  #include "s_elm.h"
- #include <sys/types.h>
  #include <sys/stat.h>
  
  #ifdef USE_FCNTL_LOCKING
--- 69,74 ----
***************
*** 62,68 ****
  #endif
  
  #ifdef SYSCALL_LOCKING
! #include <sys/file.h>
  #endif
  #include <errno.h>
  #ifdef I_TIME
--- 80,88 ----
  #endif
  
  #ifdef SYSCALL_LOCKING
! #  if (defined(BSD) || !defined(apollo))
! #    include <sys/file.h>
! #  endif
  #endif
  #include <errno.h>
  #ifdef I_TIME
***************
*** 153,160 ****
  {
      int	fcntlret = 0,
  	flockret = 0,
! 	fcntlerr,
! 	flockerr;
  
  #ifdef	USE_FLOCK_LOCKING
      errno = 0;
--- 173,180 ----
  {
      int	fcntlret = 0,
  	flockret = 0,
! 	fcntlerr = 0,
! 	flockerr = 0;
  
  #ifdef	USE_FLOCK_LOCKING
      errno = 0;
***************
*** 231,247 ****
  	    if (kill_status != 0 && errno != EPERM) {
  	      close(create_fd);
  	      if (unlink(lockfile) != 0) {
  		dprint(1, (debugfile,
  		  "Error %s\n\ttrying to unlink file %s (%s)\n", 
  		  error_description(errno), lockfile, "lock"));
! 		PutLine1(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmLeaveCouldntRemoveCurLock,
! 		  "\n\rCouldn't remove the current lock file %s\n\r"), lockfile);
! 		PutLine1(LINES, 0, "** %s **\n\r", error_description(errno));
  #ifdef SAVE_GROUP_MAILBOX_ID
  		setgid(groupid);
  #endif
  		if (direction == INCOMING)
! 		  leave();
  		else
  		  emergency_exit();
  	      }
--- 251,269 ----
  	    if (kill_status != 0 && errno != EPERM) {
  	      close(create_fd);
  	      if (unlink(lockfile) != 0) {
+ 	        MoveCursor(LINES, 0);
+ 		Raw(OFF);
  		dprint(1, (debugfile,
  		  "Error %s\n\ttrying to unlink file %s (%s)\n", 
  		  error_description(errno), lockfile, "lock"));
! 		printf(catgets(elm_msg_cat, ElmSet, ElmLeaveCouldntRemoveCurLock,
! 		  "\nCouldn't remove the current lock file %s\n"), lockfile);
! 		printf("** %s **\n", error_description(errno));
  #ifdef SAVE_GROUP_MAILBOX_ID
  		setgid(groupid);
  #endif
  		if (direction == INCOMING)
! 		  leave(0);
  		else
  		  emergency_exit();
  	      }
***************
*** 262,288 ****
  	  if(errno != EEXIST) {
  	    /* Creation of lock failed NOT because it already exists!!! */
  
  	    if (direction == OUTGOING) {
  	      dprint(1, (debugfile, 
  		"Error encountered attempting to create lock %s\n", lockfile));
  	      dprint(1, (debugfile, "** %s **\n", error_description(errno)));
- 	      MoveCursor(LINES, 0);
  	      printf(catgets(elm_msg_cat, ElmSet, ElmLeaveErrorCreatingLock,
! 	   "\n\rError encountered while attempting to create lock file %s;\n\r"),
  		lockfile);
! 	      printf("** %s.**\n\r\n\r", error_description(errno));
  	    } else {	/* incoming - permission denied in the middle?  Odd. */
  	      dprint(1, (debugfile,
  	       "Can't create lock file: creat(%s) raises error %s (lock)\n", 
  		lockfile, error_description(errno)));
! 	      error1(catgets(elm_msg_cat, ElmSet, ElmLeaveCantCreateLock,
! 	       "Can't create lock file! Need write permission in \"%s\".\n\r"),
  		mailhome);
  	    }
  #ifdef SAVE_GROUP_MAILBOX_ID
  	    setgid(groupid);
  #endif
! 	    leave();
  	  }
  	}
  	dprint(2, (debugfile,"File '%s' already exists!  Waiting...(lock)\n", 
--- 284,311 ----
  	  if(errno != EEXIST) {
  	    /* Creation of lock failed NOT because it already exists!!! */
  
+ 	    MoveCursor(LINES, 0);
+ 	    Raw(OFF);
  	    if (direction == OUTGOING) {
  	      dprint(1, (debugfile, 
  		"Error encountered attempting to create lock %s\n", lockfile));
  	      dprint(1, (debugfile, "** %s **\n", error_description(errno)));
  	      printf(catgets(elm_msg_cat, ElmSet, ElmLeaveErrorCreatingLock,
! 	   "\nError encountered while attempting to create lock file %s;\n"),
  		lockfile);
! 	      printf("** %s.**\n\n", error_description(errno));
  	    } else {	/* incoming - permission denied in the middle?  Odd. */
  	      dprint(1, (debugfile,
  	       "Can't create lock file: creat(%s) raises error %s (lock)\n", 
  		lockfile, error_description(errno)));
! 	      printf(catgets(elm_msg_cat, ElmSet, ElmLeaveCantCreateLock,
! 	       "Can't create lock file! Need write permission in \"%s\".\n"),
  		mailhome);
  	    }
  #ifdef SAVE_GROUP_MAILBOX_ID
  	    setgid(groupid);
  #endif
! 	    leave(0);
  	  }
  	}
  	dprint(2, (debugfile,"File '%s' already exists!  Waiting...(lock)\n", 
***************
*** 311,327 ****
  		"Throwing away the current lock file!"));
  
  	if (unlink(lockfile) != 0) {
  	  dprint(1, (debugfile,
  	    "Error %s\n\ttrying to unlink file %s (%s)\n", 
  	    error_description(errno), lockfile, "lock"));
! 	  PutLine1(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmLeaveCouldntRemoveCurLock,
! 	    "\n\rCouldn't remove the current lock file %s\n\r"), lockfile);
! 	  PutLine1(LINES, 0, "** %s **\n\r", error_description(errno));
  #ifdef SAVE_GROUP_MAILBOX_ID
  	  setgid(groupid);
  #endif
  	  if (direction == INCOMING)
! 	    leave();
  	  else
  	    emergency_exit();
  	}
--- 334,352 ----
  		"Throwing away the current lock file!"));
  
  	if (unlink(lockfile) != 0) {
+ 	  MoveCursor(LINES, 0);
+ 	  Raw(OFF);
  	  dprint(1, (debugfile,
  	    "Error %s\n\ttrying to unlink file %s (%s)\n", 
  	    error_description(errno), lockfile, "lock"));
! 	  printf(catgets(elm_msg_cat, ElmSet, ElmLeaveCouldntRemoveCurLock,
! 	    "\nCouldn't remove the current lock file %s\n"), lockfile);
! 	  printf("** %s **\n", error_description(errno));
  #ifdef SAVE_GROUP_MAILBOX_ID
  	  setgid(groupid);
  #endif
  	  if (direction == INCOMING)
! 	    leave(0);
  	  else
  	    emergency_exit();
  	}
***************
*** 334,358 ****
  	    "Error encountered attempting to create lock %s\n", lockfile));
  	  dprint(1, (debugfile, "** %s **\n", error_description(errno)));
  	  MoveCursor(LINES, 0);
  	  printf(catgets(elm_msg_cat, ElmSet, ElmLeaveErrorCreatingLock,
! 	  "\n\rError encountered while attempting to create lock file %s;\n\r"),
  	    lockfile);
! 	  printf("** %s. **\n\r\n\r", error_description(errno));
  #ifdef SAVE_GROUP_MAILBOX_ID
  	  setgid(groupid);
  #endif
! 	  leave();
  	}
  #else
  	/* Okay...we die and leave, not updating the mailfile mbox or
  	   any of those! */
  
  	if (direction == INCOMING) {
! 	  PutLine1(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmLeaveGivingUp,
! 		"\n\r\n\rGiving up after %d iterations.\n\r"), 
  	    create_iteration);
! 	  PutLine0(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmLeavePleaseTryAgain,
! 	  "\n\rPlease try to read your mail again in a few minutes.\n\r\n\r"));
  	  dprint(1, (debugfile, 
  	    "Warning: bailing out after %d iterations...(lock)\n",
  	    create_iteration));
--- 359,386 ----
  	    "Error encountered attempting to create lock %s\n", lockfile));
  	  dprint(1, (debugfile, "** %s **\n", error_description(errno)));
  	  MoveCursor(LINES, 0);
+ 	  Raw(OFF);
  	  printf(catgets(elm_msg_cat, ElmSet, ElmLeaveErrorCreatingLock,
! 	  "\nError encountered while attempting to create lock file %s;\n"),
  	    lockfile);
! 	  printf("** %s. **\n\n", error_description(errno));
  #ifdef SAVE_GROUP_MAILBOX_ID
  	  setgid(groupid);
  #endif
! 	  leave(0);
  	}
  #else
  	/* Okay...we die and leave, not updating the mailfile mbox or
  	   any of those! */
  
+ 	MoveCursor(LINES, 0);
+ 	Raw(OFF);
  	if (direction == INCOMING) {
! 	  printf(catgets(elm_msg_cat, ElmSet, ElmLeaveGivingUp,
! 		"\n\nGiving up after %d iterations.\n"), 
  	    create_iteration);
! 	  printf(catgets(elm_msg_cat, ElmSet, ElmLeavePleaseTryAgain,
! 	  "\nPlease try to read your mail again in a few minutes.\n\n"));
  	  dprint(1, (debugfile, 
  	    "Warning: bailing out after %d iterations...(lock)\n",
  	    create_iteration));
***************
*** 367,374 ****
  #ifdef SAVE_GROUP_MAILBOX_ID
  	  setgid(groupid);
  #endif
! 	  leave(error(catgets(elm_msg_cat, ElmSet, ElmLeaveErrorTimedOutLock,
! 		"Timed out on locking mailbox.  Leaving program.")));
  	}
  #endif
        }
--- 395,403 ----
  #ifdef SAVE_GROUP_MAILBOX_ID
  	  setgid(groupid);
  #endif
! 	  printf(catgets(elm_msg_cat, ElmSet, ElmLeaveErrorTimedOutLock,
! 		"Timed out on locking mailbox.  Leaving program.\n"));
! 	  leave(0);
  	}
  #endif
        }
***************
*** 397,410 ****
  	    "Error encountered attempting to reopen %s for lock\n", cur_folder));
  	dprint(1, (debugfile, "** %s **\n", error_description(errno)));
  	MoveCursor(LINES, 0);
  	printf(catgets(elm_msg_cat, ElmSet, ElmLeaveErrorReopenMailbox,
!  "\n\rError encountered while attempting to reopen mailbox %s for lock;\n\r"), 
  	      cur_folder);
! 	printf("** %s. **\n\r\n\r", error_description(errno));
  #ifdef	USE_DOTLOCK_LOCKING
  	(void)unlink(lockfile);
  #endif /* USE_DOTLOCK_LOCKING */
! 	leave();
        }
  
        /* try to assert lock MAX_ATTEMPTS times */
--- 426,440 ----
  	    "Error encountered attempting to reopen %s for lock\n", cur_folder));
  	dprint(1, (debugfile, "** %s **\n", error_description(errno)));
  	MoveCursor(LINES, 0);
+ 	Raw(OFF);
  	printf(catgets(elm_msg_cat, ElmSet, ElmLeaveErrorReopenMailbox,
!  "\nError encountered while attempting to reopen mailbox %s for lock;\n"), 
  	      cur_folder);
! 	printf("** %s. **\n\n", error_description(errno));
  #ifdef	USE_DOTLOCK_LOCKING
  	(void)unlink(lockfile);
  #endif /* USE_DOTLOCK_LOCKING */
! 	leave(0);
        }
  
        /* try to assert lock MAX_ATTEMPTS times */
***************
*** 426,439 ****
  			cur_folder));
  	    dprint (1, (debugfile, "** %s **\n", error_description(errno)));
  	    MoveCursor(LINES, 0);
  	    printf (catgets(elm_msg_cat, ElmSet, ElmLeaveErrorFlockMailbox,
! 	 "\n\rError encountered while attempting to flock mailbox %s;\n\r"), 
  		  cur_folder);
! 	    printf("** %s. **\n\r\n\r", error_description(errno));
  #ifdef	USE_DOTLOCK_LOCKING
  	    (void)unlink(lockfile);
  #endif /* USE_DOTLOCK_LOCKING */
! 	    leave();
  
  	    break;
  
--- 456,470 ----
  			cur_folder));
  	    dprint (1, (debugfile, "** %s **\n", error_description(errno)));
  	    MoveCursor(LINES, 0);
+ 	    Raw(OFF);
  	    printf (catgets(elm_msg_cat, ElmSet, ElmLeaveErrorFlockMailbox,
! 	 "\nError encountered while attempting to flock mailbox %s;\n"), 
  		  cur_folder);
! 	    printf("** %s. **\n\n", error_description(errno));
  #ifdef	USE_DOTLOCK_LOCKING
  	    (void)unlink(lockfile);
  #endif /* USE_DOTLOCK_LOCKING */
! 	    leave(0);
  
  	    break;
  
***************
*** 453,467 ****
  
        if(errno != 0) {
  
  	/* We couldn't lock the file. We die and leave not updating
  	 * the mailfile mbox or any of those! */
  
  	if (direction == INCOMING) {
! 	  PutLine1(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmLeaveGivingUp,
! 		"\n\r\n\rGiving up after %d iterations.\n\r"), 
  	    flock_iteration);
! 	  PutLine0(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmLeavePleaseTryAgain,
! 	  "\n\rPlease try to read your mail again in a few minutes.\n\r\n\r"));
  	  dprint(1, (debugfile, 
  	    "Warning: bailing out after %d iterations...(lock)\n",
  	    flock_iteration));
--- 484,500 ----
  
        if(errno != 0) {
  
+ 	MoveCursor(LINES, 0);
+ 	Raw(OFF);
  	/* We couldn't lock the file. We die and leave not updating
  	 * the mailfile mbox or any of those! */
  
  	if (direction == INCOMING) {
! 	  printf(catgets(elm_msg_cat, ElmSet, ElmLeaveGivingUp,
! 		"\n\nGiving up after %d iterations.\n"), 
  	    flock_iteration);
! 	  printf(catgets(elm_msg_cat, ElmSet, ElmLeavePleaseTryAgain,
! 	  "\nPlease try to read your mail again in a few minutes.\n\n"));
  	  dprint(1, (debugfile, 
  	    "Warning: bailing out after %d iterations...(lock)\n",
  	    flock_iteration));
***************
*** 473,480 ****
  #ifdef	USE_DOTLOCK_LOCKING
  	(void)unlink(lockfile);
  #endif
! 	leave(error(catgets(elm_msg_cat, ElmSet, ElmLeaveErrorTimedOutLock,
! 		"Timed out on locking mailbox.  Leaving program.")));
        }
  
        /* We locked the file */
--- 506,514 ----
  #ifdef	USE_DOTLOCK_LOCKING
  	(void)unlink(lockfile);
  #endif
! 	printf(catgets(elm_msg_cat, ElmSet, ElmLeaveErrorTimedOutLock,
! 		"Timed out on locking mailbox.  Leaving program.\n"));
! 	leave(0);
        }
  
        /* We locked the file */

Index: src/mailmsg2.c
Prereq: 5.7
*** ../elm2.4/src/mailmsg2.c	Wed Nov 25 14:10:39 1992
--- src/mailmsg2.c	Thu Dec 10 20:58:52 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: mailmsg2.c,v 5.7 1992/11/22 01:14:20 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: mailmsg2.c,v 5.12 1992/12/11 01:58:50 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.12 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,44 ----
   *
   *******************************************************************************
   * $Log: mailmsg2.c,v $
+  * Revision 5.12  1992/12/11  01:58:50  syd
+  * Allow for use from restricted shell by putting SHELL=/bin/sh in the
+  * environment of spawned mail transport program.
+  * From: chip@tct.com (Chip Salzenberg)
+  *
+  * Revision 5.11  1992/12/07  04:26:26  syd
+  * add missing err declare
+  * From: Syd
+  *
+  * Revision 5.10  1992/12/07  03:20:30  syd
+  * Change $HOME/Cancelled.mail in message to /fullpath/Cancelled.mail
+  * as AFS uses different meaning for $HOME than Elm does and it was
+  * confusing to some users.
+  * From: Syd
+  *
+  * Revision 5.9  1992/11/26  01:46:26  syd
+  * add Decode option to copy_message, convert copy_message to
+  * use bit or for options.
+  * From: Syd and bjoerns@stud.cs.uit.no (Bjoern Stabell)
+  *
+  * Revision 5.8  1992/11/26  00:46:13  syd
+  * changes to first change screen back (Raw off) and then issue final
+  * error message.
+  * From: Syd
+  *
   * Revision 5.7  1992/11/22  01:14:20  syd
   * Allow SCO MMDF to use the mmdf library for mailer via execmail.
   * From: Larry Philps <larryp@sco.com>
***************
*** 163,168 ****
--- 188,194 ----
  	int      already_has_text = FALSE;		/* we need an ADDRESS */
  	int	 signature_done = FALSE;
  	int	 need_redraw = 0;
+ 	int	 err;
  
  	static int cancelled_msg = 0;
  
***************
*** 185,197 ****
  
  	if (! retransmit)
  	  if ((reply = fopen(filename,"w")) == NULL) {
  	    dprint(1, (debugfile, 
                 "Attempt to write to temp file %s failed with error %s (mail)\n",
! 		 filename, error_description(errno)));
  	    if(batch_only) {
  	      MCprintf(catgets(elm_msg_cat, ElmSet, ElmCouldNotCreateFile,
  		"Could not create file %s (%s)."),
! 		filename, error_description(errno));
  	      printf("\n");
  	    } else
  	      error2(catgets(elm_msg_cat, ElmSet, ElmCouldNotCreateFile,
--- 211,224 ----
  
  	if (! retransmit)
  	  if ((reply = fopen(filename,"w")) == NULL) {
+ 	    err = errno;
  	    dprint(1, (debugfile, 
                 "Attempt to write to temp file %s failed with error %s (mail)\n",
! 		 filename, error_description(err)));
  	    if(batch_only) {
  	      MCprintf(catgets(elm_msg_cat, ElmSet, ElmCouldNotCreateFile,
  		"Could not create file %s (%s)."),
! 		filename, error_description(err));
  	      printf("\n");
  	    } else
  	      error2(catgets(elm_msg_cat, ElmSet, ElmCouldNotCreateFile,
***************
*** 267,277 ****
  	    fputs("Forwarded message:\n", reply);
  	  }
  	  if (edit_message) {
! 	    copy_message(prefixchars, reply, noheader,FALSE,FALSE,TRUE,FALSE);
  	    already_has_text = TRUE;	/* we just added it, right? */
  	  }
  	  else
! 	    copy_message("", reply, noheader, FALSE, FALSE, TRUE, FALSE);
  	}
  
          /* append signature now if we are going to use an external editor */
--- 294,306 ----
  	    fputs("Forwarded message:\n", reply);
  	  }
  	  if (edit_message) {
! 	    copy_message(prefixchars, reply,
! 		( noheader ? CM_REMOVE_HEADER : 0 ) | CM_MMDF_HEAD | CM_DECODE);
  	    already_has_text = TRUE;	/* we just added it, right? */
  	  }
  	  else
! 	    copy_message(prefixchars, reply,
! 		( noheader ? CM_REMOVE_HEADER : 0 ) | CM_MMDF_HEAD);
  	}
  
          /* append signature now if we are going to use an external editor */
***************
*** 359,378 ****
  	    }
  
  	  if ((reply = fopen(filename,"r")) == NULL) {
  	      dprint(1, (debugfile,
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",
!                 filename, error_description(errno)));
  	      error1(catgets(elm_msg_cat, ElmSet, ElmCouldNotOpenReply,
! 		"Could not open reply file (%s)."), error_description(errno));
  	      return(need_redraw);
  	  }
  	}
  	else if ((reply = fopen(filename,"r")) == NULL) {
  	  dprint(1, (debugfile, 
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",
!              filename, error_description(errno)));
  	  printf(catgets(elm_msg_cat, ElmSet, ElmCouldNotOpenReply,
! 		"Could not open reply file (%s)."), error_description(errno));
  	  printf("\n");
  	  return(need_redraw);
  	}
--- 388,409 ----
  	    }
  
  	  if ((reply = fopen(filename,"r")) == NULL) {
+ 	      err = errno;
  	      dprint(1, (debugfile,
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",
!                 filename, error_description(err)));
  	      error1(catgets(elm_msg_cat, ElmSet, ElmCouldNotOpenReply,
! 		"Could not open reply file (%s)."), error_description(err));
  	      return(need_redraw);
  	  }
  	}
  	else if ((reply = fopen(filename,"r")) == NULL) {
+ 	  err = errno;
  	  dprint(1, (debugfile, 
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",
!              filename, error_description(err)));
  	  printf(catgets(elm_msg_cat, ElmSet, ElmCouldNotOpenReply,
! 		"Could not open reply file (%s)."), error_description(err));
  	  printf("\n");
  	  return(need_redraw);
  	}
***************
*** 536,542 ****
  
  	/* Take note of mailer return value */
  
! 	if ( sys_status = system_call(very_long_buffer, 0) ) {
  		/* problem case: */
  		if (mail_only || batch_only) {
  		   printf("\r\n");
--- 567,573 ----
  
  	/* Take note of mailer return value */
  
! 	if ( sys_status = system_call(very_long_buffer, SY_ENV_SHELL) ) {
  		/* problem case: */
  		if (mail_only || batch_only) {
  		   printf("\r\n");
***************
*** 727,734 ****
  			   fclose(deadfd);
  			   restore_file_stats(fname);
  
! 			   error1(catgets(elm_msg_cat, ElmSet, ElmMessageSavedIn,
! 				"Message saved in file \"$HOME/%s\"."), dead_letter);
  
  			}
  		       } else if (user_level != 0)
--- 758,765 ----
  			   fclose(deadfd);
  			   restore_file_stats(fname);
  
! 			   error2(catgets(elm_msg_cat, ElmSet, ElmMessageSavedIn,
! 				"Message saved in file \"%s/%s\"."), home, dead_letter);
  
  			}
  		       } else if (user_level != 0)
***************
*** 821,826 ****
--- 852,858 ----
  	char *ctime();
  	static FILE *filedesc;		/* our friendly file descriptor  */
          char to_buf[VERY_LONG_STRING];
+ 	int err;
  
  #ifdef SITE_HIDING
  	char  buffer[SLEN];
***************
*** 844,856 ****
  	  filedesc = fopen(filename, "w+");
  
  	if (filedesc == NULL) {
  	  dprint(1, (debugfile,
  	    "Attempt to open file %s for writing failed! (write_header_info)\n",
  	     filename));
! 	  dprint(1, (debugfile, "** %s **\n\n", error_description(errno)));
  	  error2(catgets(elm_msg_cat, ElmSet, ElmErrorTryingToWrite,
  		"Error %s encountered trying to write to %s."), 
! 		error_description(errno), filename);
  	  sleep(2);
  	  return(NULL);		/* couldn't open it!! */
  	}
--- 876,889 ----
  	  filedesc = fopen(filename, "w+");
  
  	if (filedesc == NULL) {
+ 	  err = errno;
  	  dprint(1, (debugfile,
  	    "Attempt to open file %s for writing failed! (write_header_info)\n",
  	     filename));
! 	  dprint(1, (debugfile, "** %s **\n\n", error_description(err)));
  	  error2(catgets(elm_msg_cat, ElmSet, ElmErrorTryingToWrite,
  		"Error %s encountered trying to write to %s."), 
! 		error_description(err), filename);
  	  sleep(2);
  	  return(NULL);		/* couldn't open it!! */
  	}
***************
*** 1080,1087 ****
  	  else if (crypted) {
  	    if (batch_only) {
  	      printf(catgets(elm_msg_cat, ElmSet, ElmNoEncryptInBatch,
! 		"Sorry. Cannot send encrypted mail in \"batch mode\".\n\r"));
! 	      leave();
  	    } else if (! gotten_key++)
  	      getkey(ON);
  	    else if (! encoded_lines)
--- 1113,1120 ----
  	  else if (crypted) {
  	    if (batch_only) {
  	      printf(catgets(elm_msg_cat, ElmSet, ElmNoEncryptInBatch,
! 		"Sorry. Cannot send encrypted mail in \"batch mode\".\n"));
! 	      leave(0);
  	    } else if (! gotten_key++)
  	      getkey(ON);
  	    else if (! encoded_lines)
***************
*** 1117,1124 ****
  	    /* Add in the > to a From on our copy */
  	    fprintf(dest, ">");
  	    if (fwrite(buffer, 1, line_len, dest) != line_len) {
  		Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmWriteFailedCopyAcross,
! 			"\n\rWrite failed in copy_message_across\n\r"), 0);
  		emergency_exit();
  	    }
  	  }
--- 1150,1159 ----
  	    /* Add in the > to a From on our copy */
  	    fprintf(dest, ">");
  	    if (fwrite(buffer, 1, line_len, dest) != line_len) {
+ 		MoveCursor(LINES, 0);
+ 		Raw(OFF);
  		Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmWriteFailedCopyAcross,
! 			"\nWrite failed in copy_message_across\n"), 0);
  		emergency_exit();
  	    }
  	  }
***************
*** 1132,1139 ****
    	  else
  #endif /* DONT_ESCAPE_MESSAGES */
    	    if (fwrite(buffer, 1, line_len, dest) != line_len) {
  		Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmWriteFailedCopyAcross,
! 			"\n\rWrite failed in copy_message_across\n\r"), 0);
  		emergency_exit();
  	    }
  	} 
--- 1167,1176 ----
    	  else
  #endif /* DONT_ESCAPE_MESSAGES */
    	    if (fwrite(buffer, 1, line_len, dest) != line_len) {
+ 		MoveCursor(LINES, 0);
+ 		Raw(OFF);
  		Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmWriteFailedCopyAcross,
! 			"\nWrite failed in copy_message_across\n"), 0);
  		emergency_exit();
  	    }
  	} 

Index: lib/getarpdate.c
Prereq: 5.4
*** ../elm2.4/lib/getarpdate.c	Tue Nov 17 14:10:56 1992
--- lib/getarpdate.c	Fri Dec 11 20:29:27 1992
***************
*** 1,7 ****
! static char rcsid[] = "@(#)$Id: getarpdate.c,v 5.4 1992/11/15 02:18:15 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,7 ----
! static char rcsid[] = "@(#)$Id: getarpdate.c,v 5.5 1992/12/12 01:29:26 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.5 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 13,18 ****
--- 13,22 ----
   *
   *******************************************************************************
   * $Log: getarpdate.c,v $
+  * Revision 5.5  1992/12/12  01:29:26  syd
+  * Fix double inclusion of sys/types.h
+  * From: Tom Moore <tmoore@wnas.DaytonOH.NCR.COM>
+  *
   * Revision 5.4  1992/11/15  02:18:15  syd
   * Change most of the rest of the BSDs to TZNAME
   * From: Syd
***************
*** 37,43 ****
  **/
  
  #include "headers.h"
- #include <sys/types.h>
  
  #ifdef I_TIME
  #  include <time.h>
--- 41,46 ----

Index: lib/opt_utils.c
Prereq: 5.3
*** ../elm2.4/lib/opt_utils.c	Mon Nov  2 15:51:42 1992
--- lib/opt_utils.c	Fri Dec 11 20:29:29 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: opt_utils.c,v 5.3 1992/10/30 21:49:38 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: opt_utils.c,v 5.4 1992/12/12 01:29:26 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: opt_utils.c,v $
+  * Revision 5.4  1992/12/12  01:29:26  syd
+  * Fix double inclusion of sys/types.h
+  * From: Tom Moore <tmoore@wnas.DaytonOH.NCR.COM>
+  *
   * Revision 5.3  1992/10/30  21:49:38  syd
   * Add init of buf
   * From: Syd via request from hessmann@unipas.fmi.uni-passau.de (Georg Hessmann)
***************
*** 51,57 ****
  
  #ifndef GETHOSTNAME
  # ifdef DOUNAME
- #  include <sys/types.h>
  #  include <sys/utsname.h>
  # endif
  #endif
--- 55,60 ----

-- 
========================================================================
Sydney S. Weinstein, CDP, CCP          Elm Coordinator - Current 2.4PL17
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