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

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

version 1.14, 2001/01/16 05:36:09 version 1.15, 2001/11/20 20:50:00
Line 73 
Line 73 
  * Save all untouched messages back in the system mailbox.   * Save all untouched messages back in the system mailbox.
  * Remove the system mailbox, if none saved there.   * Remove the system mailbox, if none saved there.
  */   */
 void  int
 quit()  quit()
 {  {
         int mcount, p, modify, autohold, anystat, holdbit, nohold;          int mcount, p, modify, autohold, anystat, holdbit, nohold;
Line 88 
Line 88 
          * so just return quickly.           * so just return quickly.
          */           */
         if (readonly)          if (readonly)
                 return;                  return(0);
         /*          /*
          * If editing (not reading system mail box), then do the work           * If editing (not reading system mail box), then do the work
          * in edstop()           * in edstop()
          */           */
         if (edit) {          if (edit)
                 edstop();                  return(edstop());
                 return;  
         }  
   
         /*          /*
          * See if there any messages to save in mbox.  If no, we           * See if there any messages to save in mbox.  If no, we
Line 114 
Line 112 
         if (flock(fileno(fbuf), LOCK_EX) == -1) {          if (flock(fileno(fbuf), LOCK_EX) == -1) {
                 warn("Unable to lock mailbox");                  warn("Unable to lock mailbox");
                 (void)Fclose(fbuf);                  (void)Fclose(fbuf);
                 return;                  return(-1);
         }          }
         if (!spool_lock()) {          if (!spool_lock()) {
                 (void)Fclose(fbuf);                  (void)Fclose(fbuf);
                 return;                 /* lockspool printed error for us */                  return(-1);                     /* lockspool printed error for us */
         }          }
         rbuf = NULL;          rbuf = NULL;
         if (fstat(fileno(fbuf), &minfo) >= 0 && minfo.st_size > mailsize) {          if (fstat(fileno(fbuf), &minfo) >= 0 && minfo.st_size > mailsize) {
Line 195 
Line 193 
                         p, p == 1 ? "" : "s", mailname);                          p, p == 1 ? "" : "s", mailname);
                 (void)Fclose(fbuf);                  (void)Fclose(fbuf);
                 spool_unlock();                  spool_unlock();
                 return;                  return(0);
         }          }
         if (c == 0) {          if (c == 0) {
                 if (p != 0) {                  if (p != 0) {
                         writeback(rbuf);                          writeback(rbuf);
                         (void)Fclose(fbuf);                          (void)Fclose(fbuf);
                         spool_unlock();                          spool_unlock();
                         return;                          return(0);
                 }                  }
                 goto cream;                  goto cream;
         }          }
Line 224 
Line 222 
                         warn("%s", tempname);                          warn("%s", tempname);
                         (void)Fclose(fbuf);                          (void)Fclose(fbuf);
                         spool_unlock();                          spool_unlock();
                         return;                          return(-1);
                 }                  }
                 if ((ibuf = Fopen(tempname, "r")) == NULL) {                  if ((ibuf = Fopen(tempname, "r")) == NULL) {
                         warn("%s", tempname);                          warn("%s", tempname);
Line 232 
Line 230 
                         (void)Fclose(obuf);                          (void)Fclose(obuf);
                         (void)Fclose(fbuf);                          (void)Fclose(fbuf);
                         spool_unlock();                          spool_unlock();
                         return;                          return(-1);
                 }                  }
                 (void)rm(tempname);                  (void)rm(tempname);
                 if ((abuf = Fopen(mbox, "r")) != NULL) {                  if ((abuf = Fopen(mbox, "r")) != NULL) {
Line 246 
Line 244 
                         (void)Fclose(obuf);                          (void)Fclose(obuf);
                         (void)Fclose(fbuf);                          (void)Fclose(fbuf);
                         spool_unlock();                          spool_unlock();
                         return;                          return(-1);
                 }                  }
                 (void)Fclose(obuf);                  (void)Fclose(obuf);
                 (void)close(creat(mbox, 0600));                  (void)close(creat(mbox, 0600));
Line 255 
Line 253 
                         (void)Fclose(ibuf);                          (void)Fclose(ibuf);
                         (void)Fclose(fbuf);                          (void)Fclose(fbuf);
                         spool_unlock();                          spool_unlock();
                         return;                          return(-1);
                 }                  }
         }          } else {
         else {  
                 if ((obuf = Fopen(mbox, "a")) == NULL) {                  if ((obuf = Fopen(mbox, "a")) == NULL) {
                         warn("%s", mbox);                          warn("%s", mbox);
                         (void)Fclose(fbuf);                          (void)Fclose(fbuf);
                         spool_unlock();                          spool_unlock();
                         return;                          return(-1);
                 }                  }
                 fchmod(fileno(obuf), 0600);                  fchmod(fileno(obuf), 0600);
         }          }
Line 275 
Line 272 
                                 (void)Fclose(obuf);                                  (void)Fclose(obuf);
                                 (void)Fclose(fbuf);                                  (void)Fclose(fbuf);
                                 spool_unlock();                                  spool_unlock();
                                 return;                                  return(-1);
                         }                          }
   
         /*          /*
Line 302 
Line 299 
                 (void)Fclose(obuf);                  (void)Fclose(obuf);
                 (void)Fclose(fbuf);                  (void)Fclose(fbuf);
                 spool_unlock();                  spool_unlock();
                 return;                  return(-1);
         }          }
         (void)Fclose(obuf);          (void)Fclose(obuf);
         if (mcount == 1)          if (mcount == 1)
Line 319 
Line 316 
                 writeback(rbuf);                  writeback(rbuf);
                 (void)Fclose(fbuf);                  (void)Fclose(fbuf);
                 spool_unlock();                  spool_unlock();
                 return;                  return(0);
         }          }
   
         /*          /*
Line 340 
Line 337 
                 alter(mailname);                  alter(mailname);
                 (void)Fclose(fbuf);                  (void)Fclose(fbuf);
                 spool_unlock();                  spool_unlock();
                 return;                  return(0);
         }          }
         demail();          demail();
         (void)Fclose(fbuf);          (void)Fclose(fbuf);
         spool_unlock();          spool_unlock();
         return;          return(0);;
   
 newmail:  newmail:
         puts("Thou hast new mail.");          puts("Thou hast new mail.");
Line 353 
Line 350 
                 (void)Fclose(fbuf);                  (void)Fclose(fbuf);
                 spool_unlock();                  spool_unlock();
         }          }
           return(0);
 }  }
   
 /*  /*
Line 415 
Line 413 
  * Terminate an editing session by attempting to write out the user's   * Terminate an editing session by attempting to write out the user's
  * file from the temporary.  Save any new stuff appended to the file.   * file from the temporary.  Save any new stuff appended to the file.
  */   */
 void  int
 edstop()  edstop()
 {  {
         int gotcha, c;          int gotcha, c;
Line 425 
Line 423 
         char tempname[PATHSIZE];          char tempname[PATHSIZE];
   
         if (readonly)          if (readonly)
                 return;                  return(0);
         holdsigs();          holdsigs();
         if (Tflag != NULL) {          if (Tflag != NULL) {
                 if ((readstat = Fopen(Tflag, "w")) == NULL)                  if ((readstat = Fopen(Tflag, "w")) == NULL)
Line 459 
Line 457 
                     (obuf = Fdopen(fd, "w")) == NULL) {                      (obuf = Fdopen(fd, "w")) == NULL) {
                         warn("%s", tempname);                          warn("%s", tempname);
                         relsesigs();                          relsesigs();
                         reset(0);                          return(-1);
                 }                  }
                 if ((ibuf = Fopen(mailname, "r")) == NULL) {                  if ((ibuf = Fopen(mailname, "r")) == NULL) {
                         warn("%s", mailname);                          warn("%s", mailname);
                         (void)Fclose(obuf);                          (void)Fclose(obuf);
                         (void)rm(tempname);                          (void)rm(tempname);
                         relsesigs();                          relsesigs();
                         reset(0);                          return(-1);
                 }                  }
                 fseek(ibuf, (long)mailsize, 0);                  fseek(ibuf, (long)mailsize, 0);
                 while ((c = getc(ibuf)) != EOF)                  while ((c = getc(ibuf)) != EOF)
Line 477 
Line 475 
                         warn("%s", tempname);                          warn("%s", tempname);
                         (void)rm(tempname);                          (void)rm(tempname);
                         relsesigs();                          relsesigs();
                         reset(0);                          return(-1);
                 }                  }
                 (void)rm(tempname);                  (void)rm(tempname);
         }          }
Line 486 
Line 484 
         if ((obuf = Fopen(mailname, "r+")) == NULL) {          if ((obuf = Fopen(mailname, "r+")) == NULL) {
                 warn("%s", mailname);                  warn("%s", mailname);
                 relsesigs();                  relsesigs();
                 reset(0);                  return(-1);
         }          }
         trunc(obuf);          trunc(obuf);
         c = 0;          c = 0;
Line 497 
Line 495 
                 if (sendmessage(mp, obuf, NULL, NULL) < 0) {                  if (sendmessage(mp, obuf, NULL, NULL) < 0) {
                         warn("%s", mailname);                          warn("%s", mailname);
                         relsesigs();                          relsesigs();
                         reset(0);                          return(-1);
                 }                  }
         }          }
         gotcha = (c == 0 && ibuf == NULL);          gotcha = (c == 0 && ibuf == NULL);
Line 510 
Line 508 
         if (ferror(obuf)) {          if (ferror(obuf)) {
                 warn("%s", mailname);                  warn("%s", mailname);
                 relsesigs();                  relsesigs();
                 reset(0);                  return(-1);
         }          }
         (void)Fclose(obuf);          (void)Fclose(obuf);
         if (gotcha) {          if (gotcha) {
Line 522 
Line 520 
   
 done:  done:
         relsesigs();          relsesigs();
           return(0);
 }  }

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