[BACK]Return to send.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mail

Diff for /src/usr.bin/mail/send.c between version 1.14 and 1.15

version 1.14, 2001/11/21 15:26:39 version 1.15, 2001/11/28 01:26:35
Line 45 
Line 45 
 #include "rcv.h"  #include "rcv.h"
 #include "extern.h"  #include "extern.h"
   
   static volatile sig_atomic_t sendsignal;        /* Interrupted by a signal? */
   
 /*  /*
  * Mail -- a mail program   * Mail -- a mail program
  *   *
Line 70 
Line 72 
         int c = 0;          int c = 0;
         int length;          int length;
         int prefixlen = 0;          int prefixlen = 0;
           int rval;
           struct sigaction act, saveint;
           sigset_t oset;
   
           sendsignal = 0;
           rval = -1;
           sigemptyset(&act.sa_mask);
           act.sa_flags = SA_RESTART;
           act.sa_handler = sendint;
           (void)sigaction(SIGINT, &act, &saveint);
           (void)sigprocmask(SIG_UNBLOCK, &intset, &oset);
   
         /*          /*
          * Compute the prefix string, without trailing whitespace           * Compute the prefix string, without trailing whitespace
          */           */
Line 109 
Line 122 
                          * fields                           * fields
                          */                           */
                         if (dostat) {                          if (dostat) {
                                 statusput(mp, obuf, prefix);                                  if (statusput(mp, obuf, prefix) == -1)
                                           goto out;
                                 dostat = 0;                                  dostat = 0;
                         }                          }
                         ishead = 0;                          ishead = 0;
Line 137 
Line 151 
                                  * there are no headers at all.                                   * there are no headers at all.
                                  */                                   */
                                 if (dostat) {                                  if (dostat) {
                                         statusput(mp, obuf, prefix);                                          if (statusput(mp, obuf, prefix) == -1)
                                                   goto out;
                                         dostat = 0;                                          dostat = 0;
                                 }                                  }
                                 if (doign != ignoreall)                                  if (doign != ignoreall)
Line 160 
Line 175 
                                          * and print the real Status: field                                           * and print the real Status: field
                                          */                                           */
                                         if (dostat) {                                          if (dostat) {
                                                 statusput(mp, obuf, prefix);                                                  if (statusput(mp, obuf, prefix) == -1)
                                                           goto out;
                                                 dostat = 0;                                                  dostat = 0;
                                         }                                          }
                                         ignoring = 1;                                          ignoring = 1;
Line 185 
Line 201 
                         }                          }
                         (void)fwrite(line, sizeof(*line), length, obuf);                          (void)fwrite(line, sizeof(*line), length, obuf);
                         if (ferror(obuf))                          if (ferror(obuf))
                                 return(-1);                                  goto out;
                 }                  }
                   if (sendsignal == SIGINT)
                           goto out;
         }          }
         /*          /*
          * Copy out message body           * Copy out message body
Line 219 
Line 237 
                 if (strncmp(line, "From ", 5) == 0)                  if (strncmp(line, "From ", 5) == 0)
                         (void)fwrite(">", 1, 1, obuf); /* '>' before 'From ' */                          (void)fwrite(">", 1, 1, obuf); /* '>' before 'From ' */
                 (void)fwrite(line, sizeof(*line), c, obuf);                  (void)fwrite(line, sizeof(*line), c, obuf);
                 if (ferror(obuf))                  if (ferror(obuf) || sendsignal == SIGINT)
                         return(-1);                          goto out;
         }          }
         if (doign == ignoreall && c > 0 && line[c - 1] != '\n')          if (doign == ignoreall && c > 0 && line[c - 1] != '\n')
                 /* no final blank line */                  /* no final blank line */
                 if ((c = getc(ibuf)) != EOF && putc(c, obuf) == EOF)                  if ((c = getc(ibuf)) != EOF && putc(c, obuf) == EOF)
                         return(-1);                          goto out;
         return(0);          rval = 0;
   out:
           sendsignal = 0;
           (void)sigprocmask(SIG_SETMASK, &oset, NULL);
           (void)sigaction(SIGINT, &saveint, NULL);
           return(rval);
 }  }
   
 /*  /*
  * Output a reasonable looking status field.   * Output a reasonable looking status field.
  */   */
 void  int
 statusput(struct message *mp, FILE *obuf, char *prefix)  statusput(struct message *mp, FILE *obuf, char *prefix)
 {  {
         char statout[3];          char statout[3];
Line 243 
Line 266 
         if ((mp->m_flag & MNEW) == 0)          if ((mp->m_flag & MNEW) == 0)
                 *cp++ = 'O';                  *cp++ = 'O';
         *cp = 0;          *cp = 0;
         if (statout[0])          if (statout[0]) {
                 fprintf(obuf, "%sStatus: %s\n",                  fprintf(obuf, "%sStatus: %s\n",
                         prefix == NULL ? "" : prefix, statout);                          prefix == NULL ? "" : prefix, statout);
                   return(ferror(obuf) ? -1 : 0);
           }
           return(0);
 }  }
   
 /*  /*
Line 550 
Line 576 
         (void)Fclose(fo);          (void)Fclose(fo);
         rewind(fi);          rewind(fi);
         return(0);          return(0);
   }
   
   /*ARGSUSED*/
   void
   sendint(int s)
   {
   
           sendsignal = s;
 }  }

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15