home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / aix-rs6000 / elm2.3.11.AIX3.1.5.Z / elm2.3.11.AIX3.1.5 / src / remail.c < prev    next >
C/C++ Source or Header  |  1990-10-10  |  4KB  |  156 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: remail.c,v 4.1.1.2 90/10/10 12:45:07 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 4.1.1.2 $   $State: Exp $
  6.  *
  7.  *             Copyright (c) 1986, 1987 Dave Taylor
  8.  *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log:    remail.c,v $
  17.  * Revision 4.1.1.2  90/10/10  12:45:07  syd
  18.  * Make the symbol look less like a typo, its real
  19.  * From: Syd
  20.  * 
  21.  * Revision 4.1.1.1  90/10/07  19:48:15  syd
  22.  * fix the bounce problem reported earlier when using MMDF submit as the MTA.
  23.  * From: Jim Clausing <jac%brahms.tinton.ccur.com@RELAY.CS.NET>
  24.  * 
  25.  * Revision 4.1  90/04/28  22:43:50  syd
  26.  * checkin of Elm 2.3 as of Release PL0
  27.  * 
  28.  *
  29.  ******************************************************************************/
  30.  
  31. /** For those cases when you want to have a message continue along
  32.     to another person in such a way as they end up receiving it with
  33.     the return address the person YOU received the mail from (does
  34.     this comment make any sense yet??)...
  35.  
  36. **/
  37.  
  38. #include "headers.h"
  39. #include <errno.h>
  40.  
  41. extern int errno;
  42.  
  43. char *error_name(), *error_description();
  44.  
  45. int
  46. remail()
  47. {
  48.     /** remail a message... returns TRUE if new foot needed ... **/
  49.     
  50.     FILE *mailfd;
  51.     char entered[VERY_LONG_STRING], expanded[VERY_LONG_STRING];
  52.     char *filename, buffer[VERY_LONG_STRING], ch;
  53.     char mailerflags[NLEN];
  54.     extern char *tempnam();
  55.  
  56.     entered[0] = '\0';
  57.  
  58.     get_to(entered, expanded);
  59.     if (strlen(entered) == 0)
  60.       return(0);
  61.  
  62.     display_to(expanded);
  63.  
  64.     if((filename=tempnam(temp_dir, "snd.")) == NULL) {
  65.       dprint(1, (debugfile, "couldn't make temp file nam! (remail)\n"));
  66.       sprintf(buffer, "Sorry - couldn't make file temp file name.");
  67.       set_error(buffer);
  68.       return(1);
  69.     }
  70.  
  71.     if ((mailfd = fopen(filename, "w")) == NULL) {
  72.       dprint(1, (debugfile, "couldn't open temp file %s! (remail)\n", 
  73.           filename));
  74.       dprint(1, (debugfile, "** %s - %s **\n", error_name(errno),
  75.           error_description(errno)));
  76.       sprintf(buffer, "Sorry - couldn't open file %s for writing (%s).",
  77.           error_name(errno));
  78.       set_error(buffer);
  79.       return(1);
  80.     }
  81.  
  82.     /** now let's copy the message into the newly opened
  83.         buffer... **/
  84.  
  85.     chown (filename, userid, groupid);
  86.  
  87. #ifdef MMDF
  88.     if (strcmp(submitmail, mailer) == 0)
  89.       do_mmdf_addresses(mailfd, strip_parens(strip_commas(expanded)));
  90. #endif /* MMDF */
  91.  
  92.     copy_message("", mailfd, FALSE, TRUE, FALSE, TRUE, TRUE);  
  93.  
  94.     fclose(mailfd);
  95.  
  96.     /** Got the messsage, now let's ensure the person really wants to 
  97.         remail it... **/
  98.  
  99.     ClearLine(LINES-1);
  100.     ClearLine(LINES);
  101.     PutLine1(LINES-1,0,
  102.         "Are you sure you want to remail this message (y/n)? y%c",
  103.         BACKSPACE);
  104.     fflush(stdin);
  105.     fflush(stdout);
  106.     ch = ReadCh();
  107.     if (tolower(ch) == 'n') { /* another day, another No... */
  108.       Write_to_screen("No.", 0);
  109.       set_error("Bounce of message cancelled.");
  110.       (void) unlink(filename);
  111.       return(1);
  112.     }
  113.     Write_to_screen("Yes.", 0);
  114.  
  115.     if (strcmp(sendmail, mailer) == 0
  116. #ifdef SITE_HIDING
  117.         && ! is_a_hidden_user(username))
  118. #else
  119.                      )
  120. #endif
  121.       strcpy(mailerflags, (sendmail_verbose ? smflagsv : smflags));
  122.     else if (strcmp(submitmail, mailer) == 0) {
  123.       strcpy(mailerflags, submitflags_s);
  124.       strcpy(expanded, " ");
  125.     } else
  126.       mailerflags[0] = '\0';
  127.     
  128.     sprintf(buffer,"( (%s %s %s ; %s %s) & ) < %s", 
  129.           mailer, mailerflags, strip_parens(strip_commas(expanded)), 
  130.           remove_cmd, filename, filename);
  131.  
  132.     PutLine0(LINES,0,"Resending mail...");
  133.     system_call(buffer, SH, FALSE, FALSE);
  134.     set_error("Mail resent.");
  135.  
  136.     return(1);
  137. }
  138. #ifdef MMDF
  139. do_mmdf_addresses(dest_file,buffer)
  140. FILE *dest_file;
  141. char *buffer;
  142. {
  143.     char old[VERY_LONG_STRING], first[VERY_LONG_STRING], 
  144.         rest[VERY_LONG_STRING];
  145.  
  146.     strcpy(old,buffer);
  147.     split_word(old, first, rest);
  148.     while (strcmp(first, "") != 0) {
  149.       fprintf(dest_file, "%s\n", first);
  150.       strcpy(old, rest);
  151.       split_word(old, first, rest);
  152.     }
  153.     fprintf(dest_file, "\n");
  154. }
  155. #endif /* MMDF */
  156.