*
* 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
char *cp, *mdlvr = NULL, buf[BUFSIZ];
char mailbox[BUFSIZ], tmpfil[BUFSIZ];
char **argp, **arguments;
char *cp, *mdlvr = NULL, buf[BUFSIZ];
char mailbox[BUFSIZ], tmpfil[BUFSIZ];
char **argp, **arguments;
arguments = getarguments (invo_name, argc, argv, 0);
argp = arguments;
arguments = getarguments (invo_name, argc, argv, 0);
argp = arguments;
if ((pw = getpwnam (user)) == NULL)
adios (NULL, "no such local user as %s", user);
if (chdir (pw->pw_dir) == -1)
if ((pw = getpwnam (user)) == NULL)
adios (NULL, "no such local user as %s", user);
if (chdir (pw->pw_dir) == -1)
thing would be to delay this unlink() until later if debug == 1, but I'll
leave that for someone who cares about the temp-file-accessing
functionality (they'll have to watch out for cases where we adios()). */
thing would be to delay this unlink() until later if debug == 1, but I'll
leave that for someone who cares about the temp-file-accessing
functionality (they'll have to watch out for cases where we adios()). */
if (!(fp = fdopen (fd, "r+")))
adios (NULL, "unable to access temporary file");
if (!(fp = fdopen (fd, "r+")))
adios (NULL, "unable to access temporary file");
int i, accept, status=1, won, vecp, next;
char *field, *pattern, *action, *result, *string;
char buffer[BUFSIZ], tmpbuf[BUFSIZ];
int i, accept, status=1, won, vecp, next;
char *field, *pattern, *action, *result, *string;
char buffer[BUFSIZ], tmpbuf[BUFSIZ];
/* split buffer into fields */
vecp = split (buffer, vec);
/* split buffer into fields */
vecp = split (buffer, vec);
case 'q':
/* deliver to quoted pipe */
if (strcasecmp (action, "qpipe"))
case 'q':
/* deliver to quoted pipe */
if (strcasecmp (action, "qpipe"))
case '^':
expand (tmpbuf, string, fd);
if (split (tmpbuf, vec) < 1)
case '^':
expand (tmpbuf, string, fd);
if (split (tmpbuf, vec) < 1)
}
/* deliver to nmh folder */
else if (strcasecmp (action, "folder"))
}
/* deliver to nmh folder */
else if (strcasecmp (action, "folder"))
- switch (state = m_getfld (&gstate, name, field, &fieldsz, in)) {
+ switch (state = m_getfld2(&gstate, name, field, &fieldsz)) {
- state = m_getfld (&gstate, name, field, &fieldsz, in);
+ state = m_getfld2(&gstate, name, field, &fieldsz);
if ((p = lookup (vars, "size"))) {
snprintf (buffer, sizeof(buffer), "%d",
fstat (fd, &st) != -1 ? (int) st.st_size : 0);
if ((p = lookup (vars, "size"))) {
snprintf (buffer, sizeof(buffer), "%d",
fstat (fd, &st) != -1 ? (int) st.st_size : 0);
}
if ((p = lookup (vars, "info")))
p->p_value = getcpy (info);
}
if ((p = lookup (vars, "info")))
p->p_value = getcpy (info);
- if (verbose)
- verbose_printf ("delivering to file \"%s\"", mailbox);
-
- 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");
- if (mbx_copy (mailbox, mbx_style, md, fd, mapping, NULL, verbose) == -1) {
+ if (mbx_copy (mailbox, mbx_style, md, fd, NULL) == -1) {
if (verbose && !suppress)
verbose_printf ("delivering to pipe \"%s\"", cmd);
if (verbose && !suppress)
verbose_printf ("delivering to pipe \"%s\"", cmd);
- freopen ("/dev/null", "w", stdout);
- freopen ("/dev/null", "w", stderr);
+ if (freopen ("/dev/null", "w", stdout) == NULL) {
+ advise ("stdout", "freopen");
+ }
+ if (freopen ("/dev/null", "w", stderr) == NULL) {
+ advise ("stderr", "freopen");
+ }
- 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);
- else
- if ((status & 0xff00) == 0xff00)
- verbose_printf (", system error\n");
- else
- pidstatus (status, stdout, ", failed");
+ else if ((status & 0xff00) == 0xff00)
+ verbose_printf (", system error\n");
+ else
+ pidstatus (status, stdout, ", failed");
- } else {
- /*
- * Ruthlessly kill the child and anything
- * else in its process group.
- */
- killpg(child_id, SIGKILL);
- if (verbose)
- verbose_printf (", timed-out; terminated\n");
- return -1;
+ /*
+ * Ruthlessly kill the child and anything
+ * else in its process group.
+ */
+ killpg(child_id, SIGKILL);
+ if (verbose)
+ verbose_printf (", timed-out; terminated\n");
+ return -1;
strncpy (buffer, envelope + i, sizeof(buffer));
if ((cp = strchr(buffer, '\n'))) {
*cp = 0;
strncpy (buffer, envelope + i, sizeof(buffer));
if ((cp = strchr(buffer, '\n'))) {
*cp = 0;
suppress_duplicates (int fd, char *file)
{
int fd1, lockfd, state, result;
suppress_duplicates (int fd, char *file)
{
int fd1, lockfd, state, result;
- state = m_getfld (&gstate, name, buf, &bufsz, in);
+ state = m_getfld2(&gstate, name, buf, &bufsz);
if (strcasecmp (name, "Message-ID")) {
while (state == FLDPLUS) {
bufsz = sizeof buf;
if (strcasecmp (name, "Message-ID")) {
while (state == FLDPLUS) {
bufsz = sizeof buf;
- state = m_getfld (&gstate, name, buf, &bufsz, in);
+ state = m_getfld2(&gstate, name, buf, &bufsz);
- state = m_getfld (&gstate, name, buf, &bufsz, in);
+ state = m_getfld2(&gstate, name, buf, &bufsz);
- if ((lockfd = lkopendata(file, O_RDWR, 0)) == -1) {
+ if ((lockfd = lkopendata(file, O_RDWR, 0, &failed_to_lock))
+ == -1) {