*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
- /* good file descriptor */
- break;
+ if ((fd = lkopenspool (file, O_RDWR | O_CREAT | O_NONBLOCK,
+ mode, &failed_to_lock)) != NOTOK)
+ break;
+
+ if (!failed_to_lock)
+ return NOTOK;
+
+ j = errno;
+ sleep (5);
-mbx_read (FILE *fp, long pos, struct drop **drops, int noisy)
+mbx_read (FILE *fp, long pos, struct drop **drops)
- register struct drop *cp, *dp, *ep, *pp;
+ struct drop *cp, *dp, *ep, *pp;
- pp = (struct drop *) mh_xcalloc ((size_t) (len = MAXFOLDER), sizeof(*dp));
- if (pp == NULL) {
- if (noisy)
- admonish (NULL, "unable to allocate drop storage");
- return NOTOK;
- }
+ len = MAXFOLDER;
+ pp = mh_xcalloc(len, sizeof *pp);
cp = (struct drop *) mh_xrealloc ((char *) pp,
(size_t) (len += MAXFOLDER) * sizeof(*pp));
cp = (struct drop *) mh_xrealloc ((char *) pp,
(size_t) (len += MAXFOLDER) * sizeof(*pp));
mbx_write(char *mailbox, int md, FILE *fp, int id, long last,
long pos, off_t stop, int mapping, int noisy)
{
mbx_write(char *mailbox, int md, FILE *fp, int id, long last,
long pos, off_t stop, int mapping, int noisy)
{
- while ((i = read (fd, buffer, sizeof(buffer))) > 0) {
- /* valgrind noticed that stringdex depends on null
- termination. */
- buffer[i] = '\0';
+ while ((i = read (fd, buffer, sizeof buffer - 1)) > 0) {
+ buffer[i] = '\0'; /* Terminate for stringdex(). */
- if (!strncmp (buffer, "Return-Path:", 12)) {
- char tmpbuffer[BUFSIZ];
+ if (has_prefix(buffer, "Return-Path:")) {
+ char tmpbuffer[sizeof buffer];
tp = dctime(dlocaltimenow());
snprintf (buffer, sizeof(buffer), "From %.*s %s",
(int)(fp - ep), ep, tp);
tp = dctime(dlocaltimenow());
snprintf (buffer, sizeof(buffer), "From %.*s %s",
(int)(fp - ep), ep, tp);
char *ep;
strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
ep = tmpbuffer + 17;
snprintf (buffer, sizeof(buffer), "From %s", ep);
char *ep;
strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
ep = tmpbuffer + 17;
snprintf (buffer, sizeof(buffer), "From %s", ep);
/*
* If there is already a "From " line,
* then leave it alone. Else we add one.
*/
/*
* If there is already a "From " line,
* then leave it alone. Else we add one.
*/
* If this is not first line, and begins with
* "From ", then prepend line with ">".
*/
* If this is not first line, and begins with
* "From ", then prepend line with ">".
*/
if (write (md, ">", 1) < 0) {
advise (mailbox, "write");
}
if (write (md, ">", 1) < 0) {
advise (mailbox, "write");
}
static char buffer[BUFSIZ];
if ((dp = strchr(cp = r1bindex (file, '/'), '.')) == NULL)
static char buffer[BUFSIZ];
if ((dp = strchr(cp = r1bindex (file, '/'), '.')) == NULL)
int
map_read (char *file, long pos, struct drop **drops, int noisy)
{
int
map_read (char *file, long pos, struct drop **drops, int noisy)
{
if ((md = open (cp = map_name (file), O_RDONLY)) == NOTOK
|| map_chk (cp, md, mp = &d, pos, noisy)) {
if ((md = open (cp = map_name (file), O_RDONLY)) == NOTOK
|| map_chk (cp, md, mp = &d, pos, noisy)) {
memcpy((char *) dp, (char *) mp, sizeof(*dp));
lseek (md, (off_t) sizeof(*mp), SEEK_SET);
if ((i = read (md, (char *) (dp + 1), msgp * sizeof(*dp))) <
(int) sizeof(*dp)) {
i = 0;
memcpy((char *) dp, (char *) mp, sizeof(*dp));
lseek (md, (off_t) sizeof(*mp), SEEK_SET);
if ((i = read (md, (char *) (dp + 1), msgp * sizeof(*dp))) <
(int) sizeof(*dp)) {
i = 0;
map_write (char *mailbox, int md, int id, long last, off_t start,
off_t stop, long pos, int size, int noisy)
{
map_write (char *mailbox, int md, int id, long last, off_t start,
off_t stop, long pos, int size, int noisy)
{
- admonish (NULL, "%s: version mismatch (%d != %d)", file,
+ inform("%s: version mismatch (%d != %d), continuing...", file,
- admonish (NULL,
- "%s: pointer mismatch or incomplete index (%ld!=%ld)",
- file, dp->d_stop, (long) pos);
+ inform("%s: pointer mismatch or incomplete index (%ld!=%ld), "
+ "continuing...", file, dp->d_stop, (long) pos);