[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.2 and 1.3

version 1.2, 1996/06/11 12:53:48 version 1.3, 1997/03/29 03:01:47
Line 113 
Line 113 
         if (fbuf == NULL)          if (fbuf == NULL)
                 goto newmail;                  goto newmail;
         if (flock(fileno(fbuf), LOCK_EX) == -1) {          if (flock(fileno(fbuf), LOCK_EX) == -1) {
 nolock:  
                 perror("Unable to lock mailbox");                  perror("Unable to lock mailbox");
                 Fclose(fbuf);                  Fclose(fbuf);
                 return;                  return;
         }          }
         if (dot_lock(mailname, 1, stdout, ".") == -1)          if (!spool_lock()) {
                 goto nolock;                  Fclose(fbuf);
                   return;                 /* mail.local 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) {
                 printf("New mail has arrived.\n");                  printf("New mail has arrived.\n");
Line 192 
Line 193 
                 printf("Held %d message%s in %s\n",                  printf("Held %d message%s in %s\n",
                         p, p == 1 ? "" : "s", mailname);                          p, p == 1 ? "" : "s", mailname);
                 Fclose(fbuf);                  Fclose(fbuf);
                 dot_unlock(mailname);                  spool_unlock();
                 return;                  return;
         }          }
         if (c == 0) {          if (c == 0) {
                 if (p != 0) {                  if (p != 0) {
                         writeback(rbuf);                          writeback(rbuf);
                         Fclose(fbuf);                          Fclose(fbuf);
                         dot_unlock(mailname);                          spool_unlock();
                         return;                          return;
                 }                  }
                 goto cream;                  goto cream;
Line 218 
Line 219 
                 if ((obuf = Fopen(tempQuit, "w")) == NULL) {                  if ((obuf = Fopen(tempQuit, "w")) == NULL) {
                         perror(tempQuit);                          perror(tempQuit);
                         Fclose(fbuf);                          Fclose(fbuf);
                         dot_unlock(mailname);                          spool_unlock();
                         return;                          return;
                 }                  }
                 if ((ibuf = Fopen(tempQuit, "r")) == NULL) {                  if ((ibuf = Fopen(tempQuit, "r")) == NULL) {
Line 226 
Line 227 
                         rm(tempQuit);                          rm(tempQuit);
                         Fclose(obuf);                          Fclose(obuf);
                         Fclose(fbuf);                          Fclose(fbuf);
                         dot_unlock(mailname);                          spool_unlock();
                         return;                          return;
                 }                  }
                 rm(tempQuit);                  rm(tempQuit);
Line 240 
Line 241 
                         Fclose(ibuf);                          Fclose(ibuf);
                         Fclose(obuf);                          Fclose(obuf);
                         Fclose(fbuf);                          Fclose(fbuf);
                         dot_unlock(mailname);                          spool_unlock();
                         return;                          return;
                 }                  }
                 Fclose(obuf);                  Fclose(obuf);
Line 249 
Line 250 
                         perror(mbox);                          perror(mbox);
                         Fclose(ibuf);                          Fclose(ibuf);
                         Fclose(fbuf);                          Fclose(fbuf);
                         dot_unlock(mailname);                          spool_unlock();
                         return;                          return;
                 }                  }
         }          }
Line 257 
Line 258 
                 if ((obuf = Fopen(mbox, "a")) == NULL) {                  if ((obuf = Fopen(mbox, "a")) == NULL) {
                         perror(mbox);                          perror(mbox);
                         Fclose(fbuf);                          Fclose(fbuf);
                         dot_unlock(mailname);                          spool_unlock();
                         return;                          return;
                 }                  }
                 fchmod(fileno(obuf), 0600);                  fchmod(fileno(obuf), 0600);
Line 269 
Line 270 
                                 Fclose(ibuf);                                  Fclose(ibuf);
                                 Fclose(obuf);                                  Fclose(obuf);
                                 Fclose(fbuf);                                  Fclose(fbuf);
                                 dot_unlock(mailname);                                  spool_unlock();
                                 return;                                  return;
                         }                          }
   
Line 296 
Line 297 
                 perror(mbox);                  perror(mbox);
                 Fclose(obuf);                  Fclose(obuf);
                 Fclose(fbuf);                  Fclose(fbuf);
                 dot_unlock(mailname);                  spool_unlock();
                 return;                  return;
         }          }
         Fclose(obuf);          Fclose(obuf);
Line 313 
Line 314 
         if (p != 0) {          if (p != 0) {
                 writeback(rbuf);                  writeback(rbuf);
                 Fclose(fbuf);                  Fclose(fbuf);
                 dot_unlock(mailname);                  spool_unlock();
                 return;                  return;
         }          }
   
Line 334 
Line 335 
                 Fclose(abuf);                  Fclose(abuf);
                 alter(mailname);                  alter(mailname);
                 Fclose(fbuf);                  Fclose(fbuf);
                 dot_unlock(mailname);                  spool_unlock();
                 return;                  return;
         }          }
         demail();          demail();
         Fclose(fbuf);          Fclose(fbuf);
         dot_unlock(mailname);          spool_unlock();
         return;          return;
   
 newmail:  newmail:
         printf("Thou hast new mail.\n");          printf("Thou hast new mail.\n");
         if (fbuf != NULL) {          if (fbuf != NULL) {
                 Fclose(fbuf);                  Fclose(fbuf);
                 dot_unlock(mailname);                  spool_unlock();
         }          }
 }  }
   
Line 418 
Line 419 
         register struct message *mp;          register struct message *mp;
         FILE *obuf, *ibuf, *readstat = NULL;          FILE *obuf, *ibuf, *readstat = NULL;
         struct stat statb;          struct stat statb;
         char *tempname;          char tempname[MAXPATHLEN];
   
         if (readonly)          if (readonly)
                 return;                  return;
Line 447 
Line 448 
                 goto done;                  goto done;
         ibuf = NULL;          ibuf = NULL;
         if (stat(mailname, &statb) >= 0 && statb.st_size > mailsize) {          if (stat(mailname, &statb) >= 0 && statb.st_size > mailsize) {
                 tempname = tempnam(tmpdir, "mbox");                  int fd;
   
                 if ((obuf = Fopen(tempname, "w")) == NULL) {                  snprintf(tempname, sizeof(tempname), "%s/%s", tmpdir,
                       "mboxXXXXXXXXXX");
                   if ((fd = mkstemp(tempname)) == -1 ||
                       (obuf = Fdopen(fd, "w")) == NULL) {
                         perror(tempname);                          perror(tempname);
                         relsesigs();                          relsesigs();
                         reset(0);                          reset(0);
Line 473 
Line 477 
                         reset(0);                          reset(0);
                 }                  }
                 rm(tempname);                  rm(tempname);
                 free(tempname);  
         }          }
         printf("\"%s\" ", mailname);          printf("\"%s\" ", mailname);
         fflush(stdout);          fflush(stdout);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3