version 1.2, 1996/06/11 12:53:48 |
version 1.3, 1997/03/29 03:01:47 |
|
|
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"); |
|
|
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; |
|
|
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) { |
|
|
rm(tempQuit); |
rm(tempQuit); |
Fclose(obuf); |
Fclose(obuf); |
Fclose(fbuf); |
Fclose(fbuf); |
dot_unlock(mailname); |
spool_unlock(); |
return; |
return; |
} |
} |
rm(tempQuit); |
rm(tempQuit); |
|
|
Fclose(ibuf); |
Fclose(ibuf); |
Fclose(obuf); |
Fclose(obuf); |
Fclose(fbuf); |
Fclose(fbuf); |
dot_unlock(mailname); |
spool_unlock(); |
return; |
return; |
} |
} |
Fclose(obuf); |
Fclose(obuf); |
|
|
perror(mbox); |
perror(mbox); |
Fclose(ibuf); |
Fclose(ibuf); |
Fclose(fbuf); |
Fclose(fbuf); |
dot_unlock(mailname); |
spool_unlock(); |
return; |
return; |
} |
} |
} |
} |
|
|
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); |
|
|
Fclose(ibuf); |
Fclose(ibuf); |
Fclose(obuf); |
Fclose(obuf); |
Fclose(fbuf); |
Fclose(fbuf); |
dot_unlock(mailname); |
spool_unlock(); |
return; |
return; |
} |
} |
|
|
|
|
perror(mbox); |
perror(mbox); |
Fclose(obuf); |
Fclose(obuf); |
Fclose(fbuf); |
Fclose(fbuf); |
dot_unlock(mailname); |
spool_unlock(); |
return; |
return; |
} |
} |
Fclose(obuf); |
Fclose(obuf); |
|
|
if (p != 0) { |
if (p != 0) { |
writeback(rbuf); |
writeback(rbuf); |
Fclose(fbuf); |
Fclose(fbuf); |
dot_unlock(mailname); |
spool_unlock(); |
return; |
return; |
} |
} |
|
|
|
|
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(); |
} |
} |
} |
} |
|
|
|
|
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; |
|
|
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); |
|
|
reset(0); |
reset(0); |
} |
} |
rm(tempname); |
rm(tempname); |
free(tempname); |
|
} |
} |
printf("\"%s\" ", mailname); |
printf("\"%s\" ", mailname); |
fflush(stdout); |
fflush(stdout); |