X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/8a14191c0a0ad15bb8f35b49748c75c1e0a8c2f4..d711510305:/uip/slocal.c diff --git a/uip/slocal.c b/uip/slocal.c index 1751add6..97897ad1 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -1,6 +1,4 @@ - -/* - * 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 @@ -29,6 +27,8 @@ #include #include #include +#include "../sbr/lock_file.h" +#include "../sbr/m_mktemp.h" #include #include @@ -710,7 +710,7 @@ parse (int fd) 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; @@ -971,19 +971,11 @@ timely (char *t1, char *t2) 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 */ @@ -993,10 +985,10 @@ usr_file (int fd, char *mailbox, int mbx_style) 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; @@ -1059,7 +1051,7 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress) 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); @@ -1095,9 +1087,9 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress) 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); @@ -1220,7 +1212,7 @@ you_lose: } if (i == -1) goto you_lose; - lseek (fd1, (off_t) 0, SEEK_SET); + lseek(fd1, 0, SEEK_SET); return fd1; } @@ -1285,7 +1277,7 @@ you_lose: return -1; } fclose (qfp); - lseek (fd1, (off_t) 0, SEEK_SET); + lseek(fd1, 0, SEEK_SET); return fd1; @@ -1409,7 +1401,7 @@ static int 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;