[comp.emacs] little changes to fakemail.c

wjc@ho5cad.ATT.COM (Bill Carpenter) (12/07/88)

As a side-effect of the recent virus excitement, we temporarily lost
use of "sendmail".  Since we're SysV sites, this wasn't too big a
burden (I've never understood what in the heck was going on _really_
in "sendmail" anyhow).  Of course, that meant that GNUemacs had to use
etc/fakemail instead.  Below are some context diffs for fakemail.c
(from GNUemacs 18.52) You'll find a comment in there briefly
describing the changes and hows come.  As you can see from the dates,
we've been using it this way for about a month or so.


*** GNUfakemail.c	Sun May 22 14:41:48 1988
--- fakemail.c	Wed Nov  9 11:19:38 1988
***************
*** 18,28 ****
  file named COPYING.  Among other things, the copyright notice
  and this notice must be preserved on all copies.  */
  
  
  #define NO_SHORTNAMES
  #include "../src/config.h"
  
! #if defined (BSD) && !defined (BSD4_1)
  /* This program isnot used in BSD, so just avoid loader complaints.  */
  main ()
  {
--- 18,38 ----
  file named COPYING.  Among other things, the copyright notice
  and this notice must be preserved on all copies.  */
  
+ /* four changes ... ho5cad!wjc ... 25 Oct 88
  
+    1.  Uses getenv("FAKEMAILER") if defined instead of /bin/mail
+    2.  Deletes all (comments) and blanks out "<" and ">" from stuff
+        pass as arguments to subprocess (leaves body okay).
+    3.  Wraps lines in headers after comma if it would go past column 79
+    4.  Conditional compile of this thing can be controlled by
+        #define USE_FAKEMAIL; we have BSD on SUNs but don't want to
+ 	   use /usr/lib/sendmail (necessarily)
+ */
+ 
  #define NO_SHORTNAMES
  #include "../src/config.h"
  
! #if defined (BSD) && !defined (BSD4_1) && !defined (USE_FAKEMAIL)
  /* This program isnot used in BSD, so just avoid loader complaints.  */
  main ()
  {
***************
*** 258,263 ****
--- 268,274 ----
    return (get_keyword (field, &ignored) != ((char *) NULL));
  }
  
+ #ifdef NOT_SQUEEZING_FAKEMAIL_ADDRESSES
  char *
  add_field (the_list, field, where)
       line_list the_list;
***************
*** 275,280 ****
--- 286,319 ----
      }
    return where;
  }
+ #else
+ char *
+ add_field (the_list, field, where)
+      line_list the_list;
+      register char *field, *where;
+ {
+   register char c;
+   while (true)
+     {
+       *where++ = ' ';
+       while ((c = *field++) != '\0')
+ 	  {
+ 		  if (c == '(')
+ 		  {
+ 			  while (*field && *field != ')') ++field;
+ 			  if (! (*field++)) break;  /* no closer */
+ 			  if (! (*field))   break;  /* closerNULL */
+ 			  c = *field;
+ 		  }
+ 		  *where++ = ((c == ','||c=='>'||c=='<') ? ' ' : c);
+ 	  }
+ 	  if (the_list == NIL) break;
+       field = the_list->string;
+       the_list = the_list->continuation;
+     }
+   return where;
+ }
+ #endif /* NOT_SQUEEZING_FAKEMAIL_ADDRESSES */
  
  line_list
  make_file_preface ()
***************
*** 400,406 ****
         rem != ((stream_list) NULL);
         rem = rem->rest_streams)
      {
!       fputs (s, rem->handle);
        putc ('\n', rem->handle);
      }
    return;
--- 439,464 ----
         rem != ((stream_list) NULL);
         rem = rem->rest_streams)
      {
!       int column_cursor = 0;
!       char *at;
! 	  for (at=s; *at; ++at)
! 	  {
! 		  fputc (*at, rem->handle);
! 		  ++column_cursor;
! 		  if (*at == ',')
! 		  {
! 			  /* don't really need precision here */
! 			  char *strchr(), *next_comma = strchr(at+1, ',');
! 			  int whats_left = (next_comma ? next_comma - at : strlen(at));
! 			  if (column_cursor + whats_left > 79)
! 			  {
! 				  fputs("\n\t", rem->handle);
! 				  column_cursor = 8;
! 				  while (isspace(*(++at))) continue;
! 				  if (*at) --at;
! 			  }
! 		  }
! 	  }
        putc ('\n', rem->handle);
      }
    return;
***************
*** 572,582 ****
  {
    char *command_line;
    header the_header;
!   long name_length = strlen (MAIL_PROGRAM_NAME);
    char buf[BUFLEN + 1];
    register int size;
    FILE *the_pipe;
  
    my_name = MY_NAME;
    the_streams = ((stream_list) NULL);
    the_date = ((char *) NULL);
--- 630,648 ----
  {
    char *command_line;
    header the_header;
!   char *mail_program_name, *getenv();
!   long name_length;
    char buf[BUFLEN + 1];
    register int size;
    FILE *the_pipe;
  
+   mail_program_name = getenv("FAKEMAILER");
+   if (!(mail_program_name && *mail_program_name))
+   {
+ 	  mail_program_name = MAIL_PROGRAM_NAME;
+   }
+   name_length = strlen (mail_program_name);
+   
    my_name = MY_NAME;
    the_streams = ((stream_list) NULL);
    the_date = ((char *) NULL);
***************
*** 584,590 ****
  
    the_header = read_header ();
    command_line = alloc_string (name_length + args_size (the_header));
!   strcpy (command_line, MAIL_PROGRAM_NAME);
    parse_header (the_header, &command_line[name_length]);
    
    the_pipe = popen (command_line, "w");
--- 650,656 ----
  
    the_header = read_header ();
    command_line = alloc_string (name_length + args_size (the_header));
!   strcpy (command_line, mail_program_name);
    parse_header (the_header, &command_line[name_length]);
    
    the_pipe = popen (command_line, "w");
--
--
   Bill Carpenter         att!ho5cad!wjc  or  attmail!bill