]> diplodocus.org Git - nmh/blobdiff - uip/slocal.c
Silence more gcc format-string warnings.
[nmh] / uip / slocal.c
index f41b6ad3c140a14af7c3dd8caa7b418e79604508..97897ad1053abd8f59bd9e451069316b1dd97405 100644 (file)
@@ -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 <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>
@@ -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;
@@ -782,11 +782,11 @@ parse (int fd)
 
            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;
        }
@@ -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;