-
-/*
- * slocal.c -- asynchronously filter and deliver new mail
+/* slocal.c -- asynchronously filter and deliver new mail
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
#include <h/tws.h>
#include <h/mts.h>
#include <h/utils.h>
+#include "../sbr/lock_file.h"
+#include "../sbr/m_mktemp.h"
#include <pwd.h>
#include <sys/ioctl.h>
int i, state;
int fd1;
char *cp, *dp, *lp;
- char name[NAMESZ], field[BUFSIZ];
+ char name[NAMESZ], field[NMH_BUFSIZ];
struct pair *p, *q;
FILE *in;
m_getfld_state_t gstate = 0;
case LENERR:
case FMTERR:
- advise (NULL, "format error in message");
+ inform("format error in message");
break;
default:
- advise (NULL, "internal error in m_getfld");
+ inform("internal error in m_getfld");
fclose (in);
return -1;
}
static int
usr_file (int fd, char *mailbox, int mbx_style)
{
- int md, mapping;
-
- if (verbose)
- verbose_printf ("delivering to file \"%s\"", mailbox);
+ int md;
- if (mbx_style == MBOX_FORMAT) {
- if (verbose)
- verbose_printf (" (mbox style)");
- mapping = 0;
- } else {
- if (verbose)
- verbose_printf (" (mmdf style)");
- mapping = 1;
+ if (verbose) {
+ verbose_printf("delivering to file \"%s\" (%s style)", mailbox,
+ mbx_style == MBOX_FORMAT ? "mbox" : "mmdf");
}
/* open and lock the file */
return -1;
}
- lseek (fd, (off_t) 0, SEEK_SET);
+ lseek(fd, 0, SEEK_SET);
/* append message to file */
- if (mbx_copy (mailbox, mbx_style, md, fd, mapping, NULL, verbose) == -1) {
+ if (mbx_copy (mailbox, mbx_style, md, fd, NULL) == -1) {
if (verbose)
adorn ("", "error writing to:");
return -1;
if (verbose && !suppress)
verbose_printf ("delivering to pipe \"%s\"", cmd);
- lseek (fd, (off_t) 0, SEEK_SET);
+ lseek(fd, 0, SEEK_SET);
for (i = 0; (child_id = fork()) == -1 && i < 5; i++)
sleep (5);
setpgid ((pid_t) 0, getpid ()); /* put in own process group */
*environ = NULL;
- m_putenv ("USER", pw->pw_name);
- m_putenv ("HOME", pw->pw_dir);
- m_putenv ("SHELL", pw->pw_shell);
+ setenv("USER", pw->pw_name, 1);
+ setenv("HOME", pw->pw_dir, 1);
+ setenv("SHELL", pw->pw_shell, 1);
execvp (pgm, vec);
_exit (-1);
}
if (i == -1)
goto you_lose;
- lseek (fd1, (off_t) 0, SEEK_SET);
+ lseek(fd1, 0, SEEK_SET);
return fd1;
}
return -1;
}
fclose (qfp);
- lseek (fd1, (off_t) 0, SEEK_SET);
+ lseek(fd1, 0, SEEK_SET);
return fd1;
suppress_duplicates (int fd, char *file)
{
int fd1, lockfd, state, result;
- char *cp, buf[BUFSIZ], name[NAMESZ];
+ char *cp, buf[NMH_BUFSIZ], name[NAMESZ];
datum key, value;
DBM *db;
FILE *in;